In DYNPFIELD_ATTR field LENGTH has the invalid value

博客提出ERP系统是否有问题的疑问。ERP系统是企业资源计划系统,在企业管理中应用广泛,此疑问可能涉及系统功能、运行等方面。

什么鬼

ERP系统有问题么

cpssDxChPacketAnalyzer.h File Reference Packet Analyzer APIs for CPSS. More... #include <cpss/common/cpssTypes.h> #include <cpss/dxCh/dxChxGen/packetAnalyzer/cpssDxChPacketAnalyzerTypes.h> #include <cpssDriver/pp/prvCpssDrvPpDefs.h> Functions GT_STATUS cpssDxChPacketAnalyzerManagerCreate (IN GT_U32 managerId) Create Packet Trace Manager. GT_STATUS cpssDxChPacketAnalyzerManagerDelete (IN GT_U32 managerId) Delete Packet Trace Manager. GT_STATUS cpssDxChPacketAnalyzerManagerDeviceAdd (IN GT_U32 managerId, IN GT_U8 devNum) Add device to Packet Trace Manager. GT_STATUS cpssDxChPacketAnalyzerManagerDeviceRemove (IN GT_U32 managerId, IN GT_U8 devNum) Remove device from Packet Trace Manager. GT_STATUS cpssDxChPacketAnalyzerManagerEnableSet (IN GT_U32 managerId, IN GT_BOOL enable) Enable/Disable the packet analyzer on all devices added to manager id. GT_STATUS cpssDxChPacketAnalyzerManagerDevicesGet (IN GT_U32 managerId, OUT GT_BOOL *deviceStatePtr, INOUT GT_U32 *numOfDevicesPtr, OUT GT_U8 devicesArr[]) Get packet analyzer manager information. GT_STATUS cpssDxChPacketAnalyzerManagerResetToDefaults (IN GT_U32 managerId) Reset Packet Trace Manager configuration to default settings. GT_STATUS cpssDxChPacketAnalyzerFieldSizeGet (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldName, OUT GT_U32 *lengthPtr) Get packet analyzer field's size. GT_STATUS cpssDxChPacketAnalyzerLogicalKeyCreate (IN GT_U32 managerId, IN GT_U32 keyId, IN CPSS_DXCH_PACKET_ANALYZER_KEY_ATTRIBUTES_STC *keyAttrPtr, IN GT_U32 numOfStages, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stagesArr[], IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ASSIGNMENT_MODE_ENT fieldMode, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[]) Create logical key. GT_STATUS cpssDxChPacketAnalyzerLogicalKeyFieldsAdd (IN GT_U32 managerId, IN GT_U32 keyId, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[]) Add fields to existing logical key. GT_STATUS cpssDxChPacketAnalyzerLogicalKeyFieldsRemove (IN GT_U32 managerId, IN GT_U32 keyId, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[]) Remove fields from existing logical key. GT_STATUS cpssDxChPacketAnalyzerLogicalKeyDelete (IN GT_U32 managerId, IN GT_U32 keyId) Delete existing logical key. GT_STATUS cpssDxChPacketAnalyzerLogicalKeyInfoGet (IN GT_U32 managerId, IN GT_U32 keyId, OUT CPSS_DXCH_PACKET_ANALYZER_KEY_ATTRIBUTES_STC *keyAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ASSIGNMENT_MODE_ENT *fieldModePtr) Get existing logical key configuration. GT_STATUS cpssDxChPacketAnalyzerLogicalKeyStagesGet (IN GT_U32 managerId, IN GT_U32 keyId, INOUT GT_U32 *numOfStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stagesArr[]) Get existing logical key stages list. GT_STATUS cpssDxChPacketAnalyzerLogicalKeyFieldsPerStageGet (IN GT_U32 managerId, IN GT_U32 keyId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, INOUT GT_U32 *numOfFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[]) Get existing logical key fields list per stage. GT_STATUS cpssDxChPacketAnalyzerStagesGet (IN GT_U32 managerId, INOUT GT_U32 *numOfApplicStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT applicStagesListArr[], INOUT GT_U32 *numOfValidStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT validStagesListArr[]) Get applicable stages and Valid stages - stages that are not muxed for current configuration. GT_STATUS cpssDxChPacketAnalyzerMuxStagesGet (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, INOUT GT_U32 *numOfMuxStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT muxStagesListArr[]) Get mux stages array for specific stage. GT_STATUS cpssDxChPacketAnalyzerGroupCreate (IN GT_U32 managerId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_GROUP_ATTRIBUTES_STC *groupAttrPtr) Create packet analyzer group. GT_STATUS cpssDxChPacketAnalyzerGroupDelete (IN GT_U32 managerId, IN GT_U32 groupId) Delete packet analyzer group. GT_STATUS cpssDxChPacketAnalyzerGroupRuleAdd (IN GT_U32 managerId, IN GT_U32 keyId, IN GT_U32 groupId, IN GT_U32 ruleId, IN CPSS_DXCH_PACKET_ANALYZER_RULE_ATTRIBUTES_STC *ruleAttrPtr, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC fieldsValueArr[], IN GT_U32 actionId) Add packet analyzer rule to packet analyzer group. GT_STATUS cpssDxChPacketAnalyzerGroupRuleUpdate (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC fieldsValueArr[], IN GT_U32 actionId) Replace content of packet analyzer rule. GT_STATUS cpssDxChPacketAnalyzerGroupRuleDelete (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId) Delete packet analyzer rule. GT_STATUS cpssDxChPacketAnalyzerGroupRuleGet (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, OUT GT_U32 *keyIdPtr, OUT CPSS_DXCH_PACKET_ANALYZER_RULE_ATTRIBUTES_STC *ruleAttrPtr, INOUT GT_U32 *numOfFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC fieldsValueArr[], OUT GT_U32 *actionIdPtr) Get packet analyzer rule attributes. GT_STATUS cpssDxChPacketAnalyzerActionCreate (IN GT_U32 managerId, IN GT_U32 actionId, IN CPSS_DXCH_PACKET_ANALYZER_ACTION_STC *actionPtr) Create packet analyzer action. GT_STATUS cpssDxChPacketAnalyzerActionUpdate (IN GT_U32 managerId, IN GT_U32 actionId, IN CPSS_DXCH_PACKET_ANALYZER_ACTION_STC *actionPtr) Update packet analyzer action. GT_STATUS cpssDxChPacketAnalyzerActionDelete (IN GT_U32 managerId, IN GT_U32 actionId) Delete packet analyzer action. GT_STATUS cpssDxChPacketAnalyzerActionGet (IN GT_U32 managerId, IN GT_U32 actionId, OUT CPSS_DXCH_PACKET_ANALYZER_ACTION_STC *actionPtr) Get packet analyzer action. GT_STATUS cpssDxChPacketAnalyzerSampledDataCountersClear (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId) Clear Sampling Data and Counters for packet analyzer rule. GT_STATUS cpssDxChPacketAnalyzerActionSamplingEnableSet (IN GT_U32 managerId, IN GT_U32 actionId, IN GT_BOOL enable) Enable/disable sampling for packet analyzer action. GT_STATUS cpssDxChPacketAnalyzerGroupActivateEnableSet (IN GT_U32 managerId, IN GT_U32 groupId, IN GT_BOOL enable) Enable/disable packet analyzer group activation. GT_STATUS cpssDxChPacketAnalyzerRuleMatchStagesGet (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, INOUT GT_U32 *numOfMatchedStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT matchedStagesArr[]) Get stages where packet analyzer rule was matched. GT_STATUS cpssDxChPacketAnalyzerStageMatchDataGet (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, OUT GT_U32 *numOfHitsPtr, INOUT GT_U32 *numOfSampleFieldsPtr, INOUT CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC sampleFieldsValueArr[]) Get packet analyzer stage match attributes. GT_STATUS cpssDxChPacketAnalyzerStageMatchDataAllFieldsGet (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, OUT GT_U32 *numOfHitsPtr, INOUT GT_U32 *numOfSampleFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC sampleFieldsValueArr[]) Get packet analyzer stage match attributes for all packet analyzer fields. GT_STATUS cpssDxChPacketAnalyzerStageFieldsGet (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, INOUT GT_U32 *numOfFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[]) Get stage fields list array. GT_STATUS cpssDxChPacketAnalyzerStageMatchDataAllInternalFieldsGet (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, OUT GT_U32 *numOfHitsPtr, INOUT GT_U32 *numOfSampleFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_INTERNAL_FIELD_VALUE_STC sampleFieldsValueArr[]) Get packet analyzer stage match attributes for all internal fields. GT_STATUS cpssDxChPacketAnalyzerStageMatchDataAllInternalFieldsByAttributesGet (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, IN CPSS_DXCH_PACKET_ANALYZER_SEARCH_ATTRIBUTE_STC *searchAttributePtr, OUT GT_U32 *numOfHitsPtr, INOUT GT_U32 *numOfSampleFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_INTERNAL_FIELD_VALUE_STC sampleFieldsValueArr[]) Get packet analyzer stage match attributes for all internal fields by specific search attributes. GT_STATUS cpssDxChPacketAnalyzerFieldStagesGet (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldName, INOUT GT_U32 *numOfStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stagesArr[]) Get field's stage list array. GT_STATUS cpssDxChPacketAnalyzerMuxStageBind (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId) Set stage that will be valid in group of muxed stages. GT_STATUS cpssDxChPacketAnalyzerMuxStageUnbind (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId) Set stage that will be invalid in group of muxed stages. GT_STATUS cpssDxChPacketAnalyzerUserDefinedFieldAdd (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDF_ATTRIBUTES_STC *udfAttrPtr, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_NAME_STC *fieldNamePtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT *udfIdPtr) Add packet analyzer user defined field. GT_STATUS cpssDxChPacketAnalyzerUserDefinedFieldDelete (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDF_ATTRIBUTES_STC *udfAttrPtr) Delete packet analyzer user defined field. GT_STATUS cpssDxChPacketAnalyzerUserDefinedFieldGet (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDF_ATTRIBUTES_STC *udfAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT *udfIdPtr, OUT GT_BOOL *validPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_NAME_STC *fieldNamePtr) Get packet analyzer user defined field. GT_STATUS cpssDxChPacketAnalyzerUserDefinedFieldInfoGet (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT udfId, OUT GT_BOOL *validPtr, OUT CPSS_DXCH_PACKET_ANALYZER_UDF_ATTRIBUTES_STC *udfAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_NAME_STC *fieldNamePtr) Get packet analyzer user defined field information. GT_STATUS cpssDxChPacketAnalyzerUserDefinedStageAdd (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDS_ATTRIBUTES_STC *udsAttrPtr, IN CPSS_DXCH_PACKET_ANALYZER_STAGE_INTERFACE_STC *interfaceAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT *udsIdPtr) Add packet analyzer user defined stage. GT_STATUS cpssDxChPacketAnalyzerUserDefinedStageDelete (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDS_ATTRIBUTES_STC *udsAttrPtr) Delete packet analyzer user defined stage. GT_STATUS cpssDxChPacketAnalyzerUserDefinedStageGet (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDS_ATTRIBUTES_STC *udsAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT *udsIdPtr, OUT GT_BOOL *validPtr, OUT CPSS_DXCH_PACKET_ANALYZER_STAGE_INTERFACE_STC *interfaceAttrPtr) Get packet analyzer user defined stage. GT_STATUS cpssDxChPacketAnalyzerUserDefinedStageInfoGet (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT udsId, OUT GT_BOOL *validPtr, OUT CPSS_DXCH_PACKET_ANALYZER_UDS_ATTRIBUTES_STC *udsAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_STAGE_INTERFACE_STC *interfaceAttrPtr) Get packet analyzeruser defined stages information. GT_STATUS cpssDxChPacketAnalyzerRuleMatchDataAllFieldsByAttributeGet (IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, IN CPSS_DXCH_PACKET_ANALYZER_SEARCH_ATTRIBUTE_STC *searchAttributePtr, OUT GT_U32 *numOfHitsPtr, INOUT GT_U32 *numOfSampleFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC sampleFieldsValueArr[]) Get packet analyzer rule match attributes for all packet analyzer fields by specific search attributes. GT_STATUS cpssDxChPacketAnalyzerStageFieldOverlappingFieldsGet (IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldName, INOUT GT_U32 *numOfFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[]) Get packet analyzer overlapping fields for spesific field in stage. Detailed Description Packet Analyzer APIs for CPSS. Version 1 Function Documentation ◆ cpssDxChPacketAnalyzerActionCreate() GT_STATUS cpssDxChPacketAnalyzerActionCreate ( IN GT_U32 managerId, IN GT_U32 actionId, IN CPSS_DXCH_PACKET_ANALYZER_ACTION_STC * actionPtr ) Create packet analyzer action. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] actionId - action identification (APPLICABLE RANGES: 1..128) [in] actionPtr - (pointer to) action configuration Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_FOUND - not found action GT_BAD_PTR - on NULL pointer value GT_ALREADY_EXIST - already initialized GT_OUT_OF_CPU_MEM - Cpu memory allocation failed ◆ cpssDxChPacketAnalyzerActionDelete() GT_STATUS cpssDxChPacketAnalyzerActionDelete ( IN GT_U32 managerId, IN GT_U32 actionId ) Delete packet analyzer action. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] actionId - action identification (APPLICABLE RANGES: 1..128) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_NOT_FOUND - not found action ◆ cpssDxChPacketAnalyzerActionGet() GT_STATUS cpssDxChPacketAnalyzerActionGet ( IN GT_U32 managerId, IN GT_U32 actionId, OUT CPSS_DXCH_PACKET_ANALYZER_ACTION_STC * actionPtr ) Get packet analyzer action. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] actionId - action identification (APPLICABLE RANGES: 1..128) [out] actionPtr - (pointer to) action configuration Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - not found action ◆ cpssDxChPacketAnalyzerActionSamplingEnableSet() GT_STATUS cpssDxChPacketAnalyzerActionSamplingEnableSet ( IN GT_U32 managerId, IN GT_U32 actionId, IN GT_BOOL enable ) Enable/disable sampling for packet analyzer action. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] actionId - action identification (APPLICABLE RANGES: 1..128) [in] enable - enable/disable sampling Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_FOUND - on not found action ◆ cpssDxChPacketAnalyzerActionUpdate() GT_STATUS cpssDxChPacketAnalyzerActionUpdate ( IN GT_U32 managerId, IN GT_U32 actionId, IN CPSS_DXCH_PACKET_ANALYZER_ACTION_STC * actionPtr ) Update packet analyzer action. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] actionId - action identification (APPLICABLE RANGES: 1..128) [in] actionPtr - (pointer to) action configuration Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_FOUND - not found action GT_BAD_PTR - on NULL pointer value ◆ cpssDxChPacketAnalyzerFieldSizeGet() GT_STATUS cpssDxChPacketAnalyzerFieldSizeGet ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldName, OUT GT_U32 * lengthPtr ) Get packet analyzer field's size. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] fieldName - field name [out] lengthPtr - (pointer to) fields length in bits Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - not found manager ◆ cpssDxChPacketAnalyzerFieldStagesGet() GT_STATUS cpssDxChPacketAnalyzerFieldStagesGet ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldName, INOUT GT_U32 * numOfStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stagesArr[] ) Get field's stage list array. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] fieldName - field name [in,out] numOfStagesPtr - in: (pointer to) allocated number of stages out: (pointer to) actual number of stages [out] stagesArr - (pointer to) field's stage list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - on not found manager ◆ cpssDxChPacketAnalyzerGroupActivateEnableSet() GT_STATUS cpssDxChPacketAnalyzerGroupActivateEnableSet ( IN GT_U32 managerId, IN GT_U32 groupId, IN GT_BOOL enable ) Enable/disable packet analyzer group activation. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in] enable - enable/disable group activation Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_HW_ERROR - on hardware error GT_NOT_FOUND - on not found group GT_BAD_STATE - on invalid parameter Note in order to see the results use APIs: cpssDxChPacketAnalyzerRuleMatchStagesGet,cpssDxChPacketAnalyzerRuleMatchDataGet, cpssDxChPacketAnalyzerRuleMatchDataAllFieldsGet ◆ cpssDxChPacketAnalyzerGroupCreate() GT_STATUS cpssDxChPacketAnalyzerGroupCreate ( IN GT_U32 managerId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_GROUP_ATTRIBUTES_STC * groupAttrPtr ) Create packet analyzer group. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in] groupAttrPtr - (pointer to) group attributes Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_FOUND - not found action GT_BAD_PTR - on NULL pointer value GT_ALREADY_EXIST - already initialized GT_OUT_OF_CPU_MEM - Cpu memory allocation failed ◆ cpssDxChPacketAnalyzerGroupDelete() GT_STATUS cpssDxChPacketAnalyzerGroupDelete ( IN GT_U32 managerId, IN GT_U32 groupId ) Delete packet analyzer group. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_NOT_FOUND - not found group ◆ cpssDxChPacketAnalyzerGroupRuleAdd() GT_STATUS cpssDxChPacketAnalyzerGroupRuleAdd ( IN GT_U32 managerId, IN GT_U32 keyId, IN GT_U32 groupId, IN GT_U32 ruleId, IN CPSS_DXCH_PACKET_ANALYZER_RULE_ATTRIBUTES_STC * ruleAttrPtr, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC fieldsValueArr[], IN GT_U32 actionId ) Add packet analyzer rule to packet analyzer group. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] keyId - logical key identification (APPLICABLE RANGES: 1..1024) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] ruleAttrPtr - (pointer to) rule attributes [in] numOfFields - number of fields for rule and group identification [in] fieldsValueArr - rule content array (Data and Mask) [in] actionId - rule action identification (APPLICABLE RANGES: 1..128) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - not found group or action GT_FULL - if array is full GT_ALREADY_EXIST - already initialized GT_OUT_OF_CPU_MEM - Cpu memory allocation failed ◆ cpssDxChPacketAnalyzerGroupRuleDelete() GT_STATUS cpssDxChPacketAnalyzerGroupRuleDelete ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId ) Delete packet analyzer rule. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_NOT_FOUND - not found group or rule GT_FAIL - on error ◆ cpssDxChPacketAnalyzerGroupRuleGet() GT_STATUS cpssDxChPacketAnalyzerGroupRuleGet ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, OUT GT_U32 * keyIdPtr, OUT CPSS_DXCH_PACKET_ANALYZER_RULE_ATTRIBUTES_STC * ruleAttrPtr, INOUT GT_U32 * numOfFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC fieldsValueArr[], OUT GT_U32 * actionIdPtr ) Get packet analyzer rule attributes. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [out] keyIdPtr - (pointer to) logical key identification [out] ruleAttrPtr - (pointer to) rule attributes [in,out] numOfFieldsPtr - in: (pointer to) allocated number of fields for rule identification out: (pointer to) actual number of fields for rule identification [out] fieldsValueArr - rule content array (Data and Mask) [out] actionIdPtr - (pointer to) rule action identification Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - not found group or rule ◆ cpssDxChPacketAnalyzerGroupRuleUpdate() GT_STATUS cpssDxChPacketAnalyzerGroupRuleUpdate ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC fieldsValueArr[], IN GT_U32 actionId ) Replace content of packet analyzer rule. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in] numOfFields - number of fields for rule and group identification [in] fieldsValueArr - rule content array (Data and Mask) [in] actionId - rule action identification (APPLICABLE RANGES: 1..128) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - not found group or action ◆ cpssDxChPacketAnalyzerLogicalKeyCreate() GT_STATUS cpssDxChPacketAnalyzerLogicalKeyCreate ( IN GT_U32 managerId, IN GT_U32 keyId, IN CPSS_DXCH_PACKET_ANALYZER_KEY_ATTRIBUTES_STC * keyAttrPtr, IN GT_U32 numOfStages, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stagesArr[], IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ASSIGNMENT_MODE_ENT fieldMode, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[] ) Create logical key. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] keyId - logical key identification (APPLICABLE RANGES: 1..1024) [in] keyAttrPtr - (pointer to) key attributes [in] numOfStages - number of stages [in] stagesArr - (pointer to) applicable stages list array [in] fieldMode - field mode assignment [in] numOfFields - number of fields [in] fieldsArr - (pointer to) fields list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_ALREADY_EXIST - already initialized GT_OUT_OF_CPU_MEM - Cpu memory allocation failed GT_NOT_FOUND - not found manager GT_FULL - if array is full Note in order to see the results use APIs: cpssDxChPacketAnalyzerLogicalKeyStagesGet, cpssDxChPacketAnalyzerLogicalKeyFieldsPerStageGet ◆ cpssDxChPacketAnalyzerLogicalKeyDelete() GT_STATUS cpssDxChPacketAnalyzerLogicalKeyDelete ( IN GT_U32 managerId, IN GT_U32 keyId ) Delete existing logical key. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] keyId - logical key identification (APPLICABLE RANGES: 1..1024) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - on not found manager GT_BAD_STATE - on wrong state ◆ cpssDxChPacketAnalyzerLogicalKeyFieldsAdd() GT_STATUS cpssDxChPacketAnalyzerLogicalKeyFieldsAdd ( IN GT_U32 managerId, IN GT_U32 keyId, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[] ) Add fields to existing logical key. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] keyId - logical key identification (APPLICABLE RANGES: 1..1024) [in] numOfFields - number of fields [in] fieldsArr - (pointer to) fields list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - not found manager Note in order to see the results use APIs: cpssDxChPacketAnalyzerLogicalKeyStagesGet, cpssDxChPacketAnalyzerLogicalKeyFieldsPerStageGet ◆ cpssDxChPacketAnalyzerLogicalKeyFieldsPerStageGet() GT_STATUS cpssDxChPacketAnalyzerLogicalKeyFieldsPerStageGet ( IN GT_U32 managerId, IN GT_U32 keyId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, INOUT GT_U32 * numOfFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[] ) Get existing logical key fields list per stage. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] keyId - logical key identification [in] stagesId - stage identification [in,out] numOfFieldsPtr - in: (pointer to) allocated number of fields out: (pointer to) actual number of fields [out] fieldsArr - out: (pointer to) field list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_BAD_STATE - on wrong state ◆ cpssDxChPacketAnalyzerLogicalKeyFieldsRemove() GT_STATUS cpssDxChPacketAnalyzerLogicalKeyFieldsRemove ( IN GT_U32 managerId, IN GT_U32 keyId, IN GT_U32 numOfFields, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[] ) Remove fields from existing logical key. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] keyId - logical key identification (APPLICABLE RANGES: 1..1024) [in] numOfFields - number of fields [in] fieldsArr - (pointer to) fields list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - not found manager Note in order to see the results use APIs: cpssDxChPacketAnalyzerLogicalKeyStagesGet, cpssDxChPacketAnalyzerLogicalKeyFieldsPerStageGet ◆ cpssDxChPacketAnalyzerLogicalKeyInfoGet() GT_STATUS cpssDxChPacketAnalyzerLogicalKeyInfoGet ( IN GT_U32 managerId, IN GT_U32 keyId, OUT CPSS_DXCH_PACKET_ANALYZER_KEY_ATTRIBUTES_STC * keyAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ASSIGNMENT_MODE_ENT * fieldModePtr ) Get existing logical key configuration. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] keyId - logical key identification (APPLICABLE RANGES: 1..1024) [out] keyAttrPtr - (pointer to) key attributes [out] fieldModePtr - (pointer to) field Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - on not found manager GT_BAD_STATE - on wrong state ◆ cpssDxChPacketAnalyzerLogicalKeyStagesGet() GT_STATUS cpssDxChPacketAnalyzerLogicalKeyStagesGet ( IN GT_U32 managerId, IN GT_U32 keyId, INOUT GT_U32 * numOfStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stagesArr[] ) Get existing logical key stages list. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] keyId - logical key identification (APPLICABLE RANGES: 1..1024) [in,out] numOfStagesPtr - in: (pointer to) allocated number of stages out: (pointer to) actual number of stages [out] stagesArr - out: (pointer to) stages list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - on not found manager GT_BAD_STATE - on wrong state ◆ cpssDxChPacketAnalyzerManagerCreate() GT_STATUS cpssDxChPacketAnalyzerManagerCreate ( IN GT_U32 managerId ) Create Packet Trace Manager. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_ALREADY_EXIST - already initialized GT_FAIL - on error GT_OUT_OF_CPU_MEM - Cpu memory allocation failed GT_BAD_PTR - on NULL pointer value. ◆ cpssDxChPacketAnalyzerManagerDelete() GT_STATUS cpssDxChPacketAnalyzerManagerDelete ( IN GT_U32 managerId ) Delete Packet Trace Manager. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - on not found manager GT_BAD_STATE - on invalid parameter ◆ cpssDxChPacketAnalyzerManagerDeviceAdd() GT_STATUS cpssDxChPacketAnalyzerManagerDeviceAdd ( IN GT_U32 managerId, IN GT_U8 devNum ) Add device to Packet Trace Manager. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] devNum - device number Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_ALREADY_EXIST - already initialized GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - on not found manager GT_FULL - if array is full ◆ cpssDxChPacketAnalyzerManagerDeviceRemove() GT_STATUS cpssDxChPacketAnalyzerManagerDeviceRemove ( IN GT_U32 managerId, IN GT_U8 devNum ) Remove device from Packet Trace Manager. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] devNum - device number Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - on not found manager GT_BAD_STATE - on invalid parameter ◆ cpssDxChPacketAnalyzerManagerDevicesGet() GT_STATUS cpssDxChPacketAnalyzerManagerDevicesGet ( IN GT_U32 managerId, OUT GT_BOOL * deviceStatePtr, INOUT GT_U32 * numOfDevicesPtr, OUT GT_U8 devicesArr[] ) Get packet analyzer manager information. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [out] deviceStatePtr - (pointer to) whether PA is enabled for manager id's devices [in,out] numOfDevicesPtr - in: (pointer to) allocated number of devices for managerId out: (pointer to) actual number of devices for managerId [out] devicesArr - devices array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value GT_FAIL - on error GT_NOT_FOUND - on not found manager ◆ cpssDxChPacketAnalyzerManagerEnableSet() GT_STATUS cpssDxChPacketAnalyzerManagerEnableSet ( IN GT_U32 managerId, IN GT_BOOL enable ) Enable/Disable the packet analyzer on all devices added to manager id. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] enable - enable/disable PA on manager id Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_FOUND - on not found manager ◆ cpssDxChPacketAnalyzerManagerResetToDefaults() GT_STATUS cpssDxChPacketAnalyzerManagerResetToDefaults ( IN GT_U32 managerId ) Reset Packet Trace Manager configuration to default settings. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - on not found manager GT_BAD_STATE - on invalid parameter ◆ cpssDxChPacketAnalyzerMuxStageBind() GT_STATUS cpssDxChPacketAnalyzerMuxStageBind ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId ) Set stage that will be valid in group of muxed stages. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] stageId - stage identification Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - not found manager ◆ cpssDxChPacketAnalyzerMuxStagesGet() GT_STATUS cpssDxChPacketAnalyzerMuxStagesGet ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, INOUT GT_U32 * numOfMuxStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT muxStagesListArr[] ) Get mux stages array for specific stage. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] stageId - stage identification [in,out] numOfMuxStagesPtr - in: (pointer to) allocated number of muxed stages out: (pointer to) actual number of muxed stages [out] muxStagesListArr - (pointer to) muxed stages list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - not found manager ◆ cpssDxChPacketAnalyzerMuxStageUnbind() GT_STATUS cpssDxChPacketAnalyzerMuxStageUnbind ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId ) Set stage that will be invalid in group of muxed stages. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] stageId - stage identification Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - not found manager ◆ cpssDxChPacketAnalyzerRuleMatchDataAllFieldsByAttributeGet() GT_STATUS cpssDxChPacketAnalyzerRuleMatchDataAllFieldsByAttributeGet ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, IN CPSS_DXCH_PACKET_ANALYZER_SEARCH_ATTRIBUTE_STC * searchAttributePtr, OUT GT_U32 * numOfHitsPtr, INOUT GT_U32 * numOfSampleFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC sampleFieldsValueArr[] ) Get packet analyzer rule match attributes for all packet analyzer fields by specific search attributes. Note APPLICABLE DEVICES: Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; Aldrin; AC3X; Bobcat3; Aldrin2. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in] stageId - stage identification [in] searchAttributePtr -(pointer to) search attributes. [out] numOfHitsPtr - (pointer to) number of hits [in,out] numOfSampleFieldsPtr - in: (pointer to) allocated number of fields for sample data array out: (pointer to) actual number of fields for sample data array [out] sampleFieldsValueArr - out: (pointer to) sample data array values for requested fields Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - on not found manager GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_SUPPORTED - on not supported parameter ◆ cpssDxChPacketAnalyzerRuleMatchStagesGet() GT_STATUS cpssDxChPacketAnalyzerRuleMatchStagesGet ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, INOUT GT_U32 * numOfMatchedStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT matchedStagesArr[] ) Get stages where packet analyzer rule was matched. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in,out] numOfMatchedStagesPtr- in: (pointer to) allocated number of matched stages out: (pointer to) actual number of matched stages [out] matchedStagesArr - (pointer to) matched stages list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - on not found manager GT_NOT_APPLICABLE_DEVICE - on not applicable device ◆ cpssDxChPacketAnalyzerSampledDataCountersClear() GT_STATUS cpssDxChPacketAnalyzerSampledDataCountersClear ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId ) Clear Sampling Data and Counters for packet analyzer rule. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_HW_ERROR - on hardware error GT_NOT_FOUND - on not found group ◆ cpssDxChPacketAnalyzerStageFieldOverlappingFieldsGet() GT_STATUS cpssDxChPacketAnalyzerStageFieldOverlappingFieldsGet ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldName, INOUT GT_U32 * numOfFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[] ) Get packet analyzer overlapping fields for spesific field in stage. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] stageId - stage identification [in] fieldName - field name [in,out] numOfFieldsPtr - in: (pointer to) allocated number of fields out: (pointer to) actual number of fields [out] fieldsArr - out: (pointer to) fields list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - on not found manager GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_SUPPORTED - on not supported parameter ◆ cpssDxChPacketAnalyzerStageFieldsGet() GT_STATUS cpssDxChPacketAnalyzerStageFieldsGet ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, INOUT GT_U32 * numOfFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT fieldsArr[] ) Get stage fields list array. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] stageId - stage identification [in,out] numOfFieldsPtr - in: (pointer to) allocated number of fields out: (pointer to) actual number of fields [out] fieldsArr - (pointer to) stage fields list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - on not found manager GT_NOT_SUPPORTED - on not supported parameter ◆ cpssDxChPacketAnalyzerStageMatchDataAllFieldsGet() GT_STATUS cpssDxChPacketAnalyzerStageMatchDataAllFieldsGet ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, OUT GT_U32 * numOfHitsPtr, INOUT GT_U32 * numOfSampleFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC sampleFieldsValueArr[] ) Get packet analyzer stage match attributes for all packet analyzer fields. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in] stageId - stage identification [out] numOfHitsPtr - (pointer to) number of hits [in,out] numOfSampleFieldsPtr - in: (pointer to) allocated number of fields for sample data array out: (pointer to) actual number of fields for sample data array [out] sampleFieldsValueArr - out: (pointer to) sample data array values for requested fields Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - on not found manager GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_SUPPORTED - on not supported parameter ◆ cpssDxChPacketAnalyzerStageMatchDataAllInternalFieldsByAttributesGet() GT_STATUS cpssDxChPacketAnalyzerStageMatchDataAllInternalFieldsByAttributesGet ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, IN CPSS_DXCH_PACKET_ANALYZER_SEARCH_ATTRIBUTE_STC * searchAttributePtr, OUT GT_U32 * numOfHitsPtr, INOUT GT_U32 * numOfSampleFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_INTERNAL_FIELD_VALUE_STC sampleFieldsValueArr[] ) Get packet analyzer stage match attributes for all internal fields by specific search attributes. Note APPLICABLE DEVICES: Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; Aldrin; AC3X; Bobcat3; Aldrin2. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in] stageId - stage identification [in] searchAttributePtr -(pointer to) search attributes. [out] numOfHitsPtr - (pointer to) number of hits [in,out] numOfSampleFieldsPtr - in: (pointer to) allocated number of fields for sample data array out: (pointer to) actual number of fields for sample data array [out] sampleFieldsValueArr - out: (pointer to) sample data array values for requested fields Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - on not found manager GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_SUPPORTED - on not supported parameter ◆ cpssDxChPacketAnalyzerStageMatchDataAllInternalFieldsGet() GT_STATUS cpssDxChPacketAnalyzerStageMatchDataAllInternalFieldsGet ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, OUT GT_U32 * numOfHitsPtr, INOUT GT_U32 * numOfSampleFieldsPtr, OUT CPSS_DXCH_PACKET_ANALYZER_INTERNAL_FIELD_VALUE_STC sampleFieldsValueArr[] ) Get packet analyzer stage match attributes for all internal fields. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in] stageId - stage identification [out] numOfHitsPtr - (pointer to) number of hits [in,out] numOfSampleFieldsPtr - in: (pointer to) allocated number of fields for sample data array out: (pointer to) actual number of fields for sample data array [out] sampleFieldsValueArr - out: (pointer to) sample data array values for requested fields Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - on not found manager GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_SUPPORTED - on not supported parameter ◆ cpssDxChPacketAnalyzerStageMatchDataGet() GT_STATUS cpssDxChPacketAnalyzerStageMatchDataGet ( IN GT_U32 managerId, IN GT_U32 ruleId, IN GT_U32 groupId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT stageId, OUT GT_U32 * numOfHitsPtr, INOUT GT_U32 * numOfSampleFieldsPtr, INOUT CPSS_DXCH_PACKET_ANALYZER_FIELD_VALUE_STC sampleFieldsValueArr[] ) Get packet analyzer stage match attributes. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] ruleId - rule identification (APPLICABLE RANGES: 1..2048) [in] groupId - group identification (APPLICABLE RANGES: 1..1024) [in] stageId - stage identification [out] numOfHitsPtr - (pointer to) number of hits [in,out] numOfSampleFieldsPtr - in: (pointer to) allocated number of fields for sample data array out: (pointer to) actual number of fields for sample data array [in,out] sampleFieldsValueArr - in: (pointer to) requested fields for sample data array out: (pointer to) sample data array values for requested fields Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_FOUND - on not found manager GT_NOT_APPLICABLE_DEVICE - on not applicable device ◆ cpssDxChPacketAnalyzerStagesGet() GT_STATUS cpssDxChPacketAnalyzerStagesGet ( IN GT_U32 managerId, INOUT GT_U32 * numOfApplicStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT applicStagesListArr[], INOUT GT_U32 * numOfValidStagesPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT validStagesListArr[] ) Get applicable stages and Valid stages - stages that are not muxed for current configuration. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in,out] numOfApplicStagesPtr - in: (pointer to) size of allocated applicStagesListArr out: (pointer to) actual number of applicable stages in applicStagesListArr [out] applicStagesListArr - (pointer to) applicable stages list array [in,out] numOfValidStagesPtr - in: (pointer to) size of allocated ValidStagesListArr out: (pointer to) actual number of valid stages in ValidStagesListArr [out] ValidStagesListArr - (pointer to) valid stages list array Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_BAD_SIZE - in case not enough memory was allocated to parameters list GT_BAD_PTR - on NULL pointer value. GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_FOUND - not found manager ◆ cpssDxChPacketAnalyzerUserDefinedFieldAdd() GT_STATUS cpssDxChPacketAnalyzerUserDefinedFieldAdd ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDF_ATTRIBUTES_STC * udfAttrPtr, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_NAME_STC * fieldNamePtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT * udfIdPtr ) Add packet analyzer user defined field. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] udfAttrPtr - (pointer to) udf attributes [in] fieldNamePtr - (pointer to) field name [out] udfIdPtr - (pointer to)user defined field identification. Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_NOT_FOUND - on not found parameters GT_ALREADY_EXIST - on already initialized ◆ cpssDxChPacketAnalyzerUserDefinedFieldDelete() GT_STATUS cpssDxChPacketAnalyzerUserDefinedFieldDelete ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDF_ATTRIBUTES_STC * udfAttrPtr ) Delete packet analyzer user defined field. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] udfAttrPtr - (pointer to) udf attributes Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_NOT_FOUND - on not found parameters ◆ cpssDxChPacketAnalyzerUserDefinedFieldGet() GT_STATUS cpssDxChPacketAnalyzerUserDefinedFieldGet ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDF_ATTRIBUTES_STC * udfAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT * udfIdPtr, OUT GT_BOOL * validPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_NAME_STC * fieldNamePtr ) Get packet analyzer user defined field. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] udfAttrPtr - (pointer to) udf attributes [out] udfIdPtr - (pointer to) user defined field identification [out] validPtr - (pointer to) whether udf entry is valid or not [out] fieldNamePtr - (pointer to) field name Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_NOT_FOUND - on not found parameters ◆ cpssDxChPacketAnalyzerUserDefinedFieldInfoGet() GT_STATUS cpssDxChPacketAnalyzerUserDefinedFieldInfoGet ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_FIELD_ENT udfId, OUT GT_BOOL * validPtr, OUT CPSS_DXCH_PACKET_ANALYZER_UDF_ATTRIBUTES_STC * udfAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_FIELD_NAME_STC * fieldNamePtr ) Get packet analyzer user defined field information. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] udfId - user defined field identification [out] validPtr - (pointer to) whether udf entry is valid or not [out] udfAttrPtr - (pointer to) udf attributes. Valid only when validPtr == GT_TRUE [out] fieldNamePtr - (pointer to) field name. Valid only when validPtr == GT_TRUE Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_NOT_FOUND - on not found parameters ◆ cpssDxChPacketAnalyzerUserDefinedStageAdd() GT_STATUS cpssDxChPacketAnalyzerUserDefinedStageAdd ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDS_ATTRIBUTES_STC * udsAttrPtr, IN CPSS_DXCH_PACKET_ANALYZER_STAGE_INTERFACE_STC * interfaceAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT * udsIdPtr ) Add packet analyzer user defined stage. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] udsAttrPtr - (pointer to) uds attributes [in] interfaceAttrPtr - (pointer to) interface attributes [out] udsIdPtr - (pointer to) user defined stage identification Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_NOT_FOUND - on not found parameters GT_ALREADY_EXIST - on already initialized ◆ cpssDxChPacketAnalyzerUserDefinedStageDelete() GT_STATUS cpssDxChPacketAnalyzerUserDefinedStageDelete ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDS_ATTRIBUTES_STC * udsAttrPtr ) Delete packet analyzer user defined stage. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] udsAttrPtr - (pointer to) uds attributes Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_NOT_FOUND - on not found parameters ◆ cpssDxChPacketAnalyzerUserDefinedStageGet() GT_STATUS cpssDxChPacketAnalyzerUserDefinedStageGet ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_UDS_ATTRIBUTES_STC * udsAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT * udsIdPtr, OUT GT_BOOL * validPtr, OUT CPSS_DXCH_PACKET_ANALYZER_STAGE_INTERFACE_STC * interfaceAttrPtr ) Get packet analyzer user defined stage. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] udsAttrPtr - (pointer to) uds attributes [out] udsIdPtr - (pointer to) user defined stage identification [out] validPtr - (pointer to) whether uds entry is valid or not [out] interfaceAttrPtr - (pointer to) interface attributes. Valid only when validPtr == GT_TRUE Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_NOT_FOUND - on not found parameters ◆ cpssDxChPacketAnalyzerUserDefinedStageInfoGet() GT_STATUS cpssDxChPacketAnalyzerUserDefinedStageInfoGet ( IN GT_U32 managerId, IN CPSS_DXCH_PACKET_ANALYZER_LOOKUP_STAGES_ENT udsId, OUT GT_BOOL * validPtr, OUT CPSS_DXCH_PACKET_ANALYZER_UDS_ATTRIBUTES_STC * udsAttrPtr, OUT CPSS_DXCH_PACKET_ANALYZER_STAGE_INTERFACE_STC * interfaceAttrPtr ) Get packet analyzeruser defined stages information. Note APPLICABLE DEVICES: Aldrin; Aldrin2; Falcon; AC5P; AC5X; Harrier; Ironman. NOT APPLICABLE DEVICES: xCat3; AC5; Lion2; Bobcat2; Caelum; AC3X; Bobcat3. Parameters [in] managerId - manager identification (APPLICABLE RANGES: 1..10) [in] udsId - user defined stage identification [out] validPtr - (pointer to) whether uds entry is valid or not [out] udsAttrPtr - (pointer to) uds attributes. Valid only when validPtr == GT_TRUE [out] interfaceAttrPtr - (pointer to) interface attributes. Valid only when validPtr == GT_TRUE Return values GT_OK - on success GT_BAD_PARAM - wrong value in any of the parameters GT_FAIL - on error GT_NOT_APPLICABLE_DEVICE - on not applicable device GT_NOT_INITIALIZED - if the driver was not initialized GT_NOT_FOUND - on not found parameters
09-24
/* * Vhost-user RDMA device : init and packets forwarding * * Copyright (C) 2025 KylinSoft Inc. and/or its affiliates. All rights reserved. * * Author: Xiong Weimin <xiongweimin@kylinos.cn> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. */ #ifndef __VHOST_RDMA_IB_H__ #define __VHOST_RDMA_IB_H__ #include <netinet/in.h> #include <linux/virtio_net.h> #include <rte_spinlock.h> #include <rte_atomic.h> #include <rte_timer.h> #include "vhost_rdma.h" #include "eal_interrupts.h" #define OPCODE_NONE (-1) #define VIRTIO_IB_DEVICE_RC_RNR_NAK_GEN (1 << 0) #define VHOST_USER_MEMORY_MAX_NREGIONS 8 #define VHOST_USER_MAX_CONFIG_SIZE 256 #define VHOST_RDMA_CTRL_ROCE 6 #define VHOST_RDMA_CTRL_ROCE_QUERY_DEVICE 0 #define VHOST_RDMA_CTRL_ROCE_QUERY_PORT 1 #define VHOST_RDMA_CTRL_ROCE_CREATE_CQ 2 #define VHOST_RDMA_CTRL_ROCE_DESTROY_CQ 3 #define VHOST_RDMA_CTRL_ROCE_CREATE_PD 4 #define VHOST_RDMA_CTRL_ROCE_DESTROY_PD 5 #define VHOST_RDMA_CTRL_ROCE_GET_DMA_MR 6 #define VHOST_RDMA_CTRL_ROCE_ALLOC_MR 7 #define VHOST_RDMA_CTRL_ROCE_REG_USER_MR 9 #define VHOST_RDMA_CTRL_ROCE_MAP_MR_SG 8 #define VHOST_RDMA_CTRL_ROCE_DEREG_MR 10 #define VHOST_RDMA_CTRL_ROCE_CREATE_QP 11 #define VHOST_RDMA_CTRL_ROCE_MODIFY_QP 12 #define VHOST_RDMA_CTRL_ROCE_QUERY_QP 13 #define VHOST_RDMA_CTRL_ROCE_DESTROY_QP 14 #define VHOST_RDMA_CTRL_ROCE_QUERY_PKEY 15 // #define VHOST_RDMA_CTRL_ROCE_CREATE_AH 13 // #define VHOST_RDMA_CTRL_ROCE_DESTROY_AH 14 #define VHOST_RDMA_CTRL_ROCE_ADD_GID 16 #define VHOST_RDMA_CTRL_ROCE_DEL_GID 17 #define VHOST_RDMA_CTRL_ROCE_REQ_NOTIFY_CQ 18 enum vhost_rdma_ib_qp_state { VHOST_RDMA_IB_QPS_RESET, VHOST_RDMA_IB_QPS_INIT, VHOST_RDMA_IB_QPS_RTR, VHOST_RDMA_IB_QPS_RTS, VHOST_RDMA_IB_QPS_SQD, VHOST_RDMA_IB_QPS_SQE, VHOST_RDMA_IB_QPS_ERR }; enum vhost_rdma_ib_mtu { VHOST_RDMA_IB_MTU_256 = 1, VHOST_RDMA_IB_MTU_512 = 2, VHOST_RDMA_IB_MTU_1024 = 3, VHOST_RDMA_IB_MTU_2048 = 4, VHOST_RDMA_IB_MTU_4096 = 5 }; enum vhost_rdma_ib_wc_status { /* Operation completed successfully */ VHOST_RDMA_IB_WC_SUCCESS, /* Local Length Error */ VHOST_RDMA_IB_WC_LOC_LEN_ERR, /* Local QP Operation Error */ VHOST_RDMA_IB_WC_LOC_QP_OP_ERR, /* Local Protection Error */ VHOST_RDMA_IB_WC_LOC_PROT_ERR, /* Work Request Flushed Error */ VHOST_RDMA_IB_WC_WR_FLUSH_ERR, /* Bad Response Error */ VHOST_RDMA_IB_WC_BAD_RESP_ERR, /* Local Access Error */ VHOST_RDMA_IB_WC_LOC_ACCESS_ERR, /* Remote Invalid Request Error */ VHOST_RDMA_IB_WC_REM_INV_REQ_ERR, /* Remote Access Error */ VHOST_RDMA_IB_WC_REM_ACCESS_ERR, /* Remote Operation Error */ VHOST_RDMA_IB_WC_REM_OP_ERR, /* Transport Retry Counter Exceeded */ VHOST_RDMA_IB_WC_RETRY_EXC_ERR, /* RNR Retry Counter Exceeded */ VHOST_RDMA_IB_WC_RNR_RETRY_EXC_ERR, /* Remote Aborted Error */ VHOST_RDMA_IB_WC_REM_ABORT_ERR, /* Fatal Error */ VHOST_RDMA_IB_WC_FATAL_ERR, /* Response Timeout Error */ VHOST_RDMA_IB_WC_RESP_TIMEOUT_ERR, /* General Error */ VHOST_RDMA_IB_WC_GENERAL_ERR }; enum vhost_rdma_res_state { VHOST_RDMA_RES_STATE_NEXT, VHOST_RDMA_RES_STATE_NEW, VHOST_RDMA_RES_STATE_REPLAY, }; enum vhost_user_rdma_request { VHOST_USER_NONE = 0, VHOST_USER_GET_FEATURES = 1, VHOST_USER_SET_FEATURES = 2, VHOST_USER_SET_OWNER = 3, VHOST_USER_RESET_OWNER = 4, VHOST_USER_SET_MEM_TABLE = 5, VHOST_USER_SET_LOG_BASE = 6, VHOST_USER_SET_LOG_FD = 7, VHOST_USER_SET_VRING_NUM = 8, VHOST_USER_SET_VRING_ADDR = 9, VHOST_USER_SET_VRING_BASE = 10, VHOST_USER_GET_VRING_BASE = 11, VHOST_USER_SET_VRING_KICK = 12, VHOST_USER_SET_VRING_CALL = 13, VHOST_USER_SET_VRING_ERR = 14, VHOST_USER_GET_PROTOCOL_FEATURES = 15, VHOST_USER_SET_PROTOCOL_FEATURES = 16, VHOST_USER_GET_QUEUE_NUM = 17, VHOST_USER_SET_VRING_ENABLE = 18, VHOST_USER_GET_CONFIG = 24, VHOST_USER_SET_CONFIG = 25, VHOST_USER_MAX }; struct vhost_rdma_qp_cap { uint32_t max_send_wr; uint32_t max_send_sge; uint32_t max_recv_wr; uint32_t max_recv_sge; uint32_t max_inline_data; }; struct vhost_rdma_global_route { /* Destination GID or MGID */ uint8_t dgid[16]; /* Flow label */ uint32_t flow_label; /* Source GID index */ uint8_t sgid_index; /* Hop limit */ uint8_t hop_limit; /* Traffic class */ uint8_t traffic_class; }; struct vhost_rdma_ah_attr { /* Global Routing Header (GRH) attributes */ struct vhost_rdma_global_route grh; uint8_t sl; uint8_t static_rate; uint8_t port_num; uint8_t ah_flags; /* Destination MAC address */ uint8_t dmac[6]; }; struct vhost_rdma_qp_attr { enum vhost_rdma_ib_qp_state qp_state; enum vhost_rdma_ib_qp_state cur_qp_state; enum vhost_rdma_ib_mtu path_mtu; uint32_t qkey; uint32_t rq_psn; uint32_t sq_psn; uint32_t dest_qp_num; uint32_t qp_access_flags; uint8_t sq_draining; uint8_t max_rd_atomic; uint8_t max_dest_rd_atomic; uint8_t min_rnr_timer; uint8_t timeout; uint8_t retry_cnt; uint8_t rnr_retry; uint32_t rate_limit; struct vhost_rdma_qp_cap cap; struct vhost_rdma_ah_attr ah_attr; }; struct vhost_rdma_pd { struct vhost_rdma_device *dev; uint32_t pdn; rte_atomic32_t refcnt; }; struct vhost_rdma_queue { struct vhost_queue *vq; void *data; size_t elem_size; size_t num_elems; uint16_t consumer_index; uint16_t producer_index; struct rte_intr_handle intr_handle; rte_intr_callback_fn cb; }; /** Fixed-size vhost_memory struct */ struct vhost_memory_padded { uint32_t nregions; uint32_t padding; struct vhost_memory_region regions[VHOST_USER_MEMORY_MAX_NREGIONS]; }; /** Get/set config msg payload */ struct vhost_user_rdma_config { uint32_t offset; uint32_t size; uint32_t flags; uint8_t region[VHOST_USER_MAX_CONFIG_SIZE]; }; struct vhost_user_rdma_msg { enum vhost_user_rdma_request request; #define VHOST_USER_VERSION_MASK 0x3 #define VHOST_USER_REPLY_MASK (0x1 << 2) uint32_t flags; uint32_t size; /**< the following payload size */ union { #define VHOST_USER_VRING_IDX_MASK 0xff #define VHOST_USER_VRING_NOFD_MASK (0x1 << 8) uint64_t u64; struct vhost_vring_state state; struct vhost_vring_addr addr; struct vhost_memory_padded memory; struct vhost_user_rdma_config cfg; } payload; } __rte_packed; struct vhost_rdma_cq { struct vhost_queue *vq; rte_spinlock_t cq_lock; uint8_t notify; bool is_dying; uint32_t cqn; rte_atomic32_t refcnt; }; struct vhost_rdma_sq { rte_spinlock_t lock; /* guard queue */ struct vhost_rdma_queue queue; }; struct vhost_rdma_rq { rte_spinlock_t lock; /* guard queue */ struct vhost_rdma_queue queue; }; struct vhost_rdma_av { /* From RXE_NETWORK_TYPE_* */ uint8_t network_type; uint8_t dmac[6]; struct vhost_rdma_global_route grh; union { struct sockaddr_in _sockaddr_in; struct sockaddr_in6 _sockaddr_in6; } sgid_addr, dgid_addr; }; struct vhost_rdma_task { char name[8]; int state; bool destroyed; rte_atomic16_t sched; rte_spinlock_t state_lock; /* spinlock for task state */ struct rte_ring *task_ring; int (*func)(void *arg); void *arg; int ret; }; struct vhost_rdma_req_info { enum vhost_rdma_ib_qp_state state; int wqe_index; uint32_t psn; int opcode; rte_atomic32_t rd_atomic; int wait_fence; int need_rd_atomic; int wait_psn; int need_retry; int noack_pkts; struct vhost_rdma_task task; }; struct vhost_rdma_comp_info { uint32_t psn; int opcode; int timeout; int timeout_retry; int started_retry; uint32_t retry_cnt; uint32_t rnr_retry; struct vhost_rdma_task task; }; struct vhost_rdma_sge { __le64 addr; __le32 length; __le32 lkey; }; struct vhost_rdma_dma_info { uint32_t length; uint32_t resid; uint32_t cur_sge; uint32_t num_sge; uint32_t sge_offset; uint32_t reserved; union { uint8_t *inline_data; struct vhost_rdma_sge *sge; void *raw; }; }; struct vhost_rdma_recv_wqe { __aligned_u64 wr_id; __u32 num_sge; __u32 padding; struct vhost_rdma_dma_info dma; }; enum vhost_rdma_mr_type { VHOST_MR_TYPE_NONE, VHOST_MR_TYPE_DMA, VHOST_MR_TYPE_MR, }; enum vhost_rdma_mr_state { VHOST_MR_STATE_ZOMBIE, VHOST_MR_STATE_INVALID, VHOST_MR_STATE_FREE, VHOST_MR_STATE_VALID, }; struct vhost_rdma_mr { struct vhost_rdma_pd *pd; enum vhost_rdma_mr_type type; enum vhost_rdma_mr_state state; uint64_t va; uint64_t iova; size_t length; uint32_t offset; int access; uint32_t lkey; uint32_t rkey; uint32_t npages; uint32_t max_pages; uint64_t *pages; uint32_t mrn; rte_atomic32_t refcnt; }; struct vhost_rdma_resp_res { int type; int replay; uint32_t first_psn; uint32_t last_psn; uint32_t cur_psn; enum vhost_rdma_res_state state; union { struct { struct rte_mbuf *mbuf; } atomic; struct { struct vhost_rdma_mr *mr; uint64_t va_org; uint32_t rkey; uint32_t length; uint64_t va; uint32_t resid; } read; }; }; struct vhost_rdma_resp_info { enum vhost_rdma_ib_qp_state state; uint32_t msn; uint32_t psn; uint32_t ack_psn; int opcode; int drop_msg; int goto_error; int sent_psn_nak; enum vhost_rdma_ib_wc_status status; uint8_t aeth_syndrome; /* Receive only */ struct vhost_rdma_recv_wqe *wqe; /* RDMA read / atomic only */ uint64_t va; uint64_t offset; struct vhost_rdma_mr *mr; uint32_t resid; uint32_t rkey; uint32_t length; uint64_t atomic_orig; /* Responder resources. It's a circular list where the oldest * resource is dropped first. */ struct vhost_rdma_resp_res *resources; unsigned int res_head; unsigned int res_tail; struct vhost_rdma_resp_res *res; struct vhost_rdma_task task; }; struct vhost_rdma_qp { struct vhost_rdma_device *dev; struct vhost_rdma_qp_attr attr; uint32_t qpn; uint8_t type; unsigned int valid; unsigned int mtu; struct vhost_rdma_pd *pd; struct vhost_rdma_cq *scq; struct vhost_rdma_cq *rcq; uint8_t sq_sig_all; struct vhost_rdma_sq sq; struct vhost_rdma_rq rq; void *srq; // reversed uint32_t dst_cookie; uint16_t src_port; struct vhost_rdma_av av; struct rte_ring *req_pkts; struct rte_mbuf *req_pkts_head; // use this to support peek struct rte_ring *resp_pkts; struct vhost_rdma_req_info req; struct vhost_rdma_comp_info comp; struct vhost_rdma_resp_info resp; rte_atomic32_t ssn; rte_atomic32_t mbuf_out; int need_req_mbuf; /* Timer for retranmitting packet when ACKs have been lost. RC * only. The requester sets it when it is not already * started. The responder resets it whenever an ack is * received. */ struct rte_timer retrans_timer; uint64_t qp_timeout_ticks; /* Timer for handling RNR NAKS. */ struct rte_timer rnr_nak_timer; rte_spinlock_t state_lock; /* guard requester and completer */ rte_atomic32_t refcnt; }; struct vhost_user_rdma_sge { uint64_t addr; uint32_t length; uint32_t lkey; }; static inline int ib_mtu_enum_to_int(enum vhost_rdma_ib_mtu mtu) { switch (mtu) { case VHOST_RDMA_IB_MTU_256: return 256; case VHOST_RDMA_IB_MTU_512: return 512; case VHOST_RDMA_IB_MTU_1024: return 1024; case VHOST_RDMA_IB_MTU_2048: return 2048; case VHOST_RDMA_IB_MTU_4096: return 4096; default: return -1; } } void vhost_rdma_init_ib(struct vhost_rdma_device *dev); void vhost_rdma_destroy_ib(struct vhost_rdma_device *dev); void vhost_rdma_handle_ctrl_vq(void* arg); int vhost_rdma_task_scheduler(void *arg); void free_rd_atomic_resource(struct vhost_rdma_qp *qp, struct vhost_rdma_resp_res *res); void free_rd_atomic_resources(struct vhost_rdma_qp *qp); void vhost_rdma_mr_cleanup(void* arg); void vhost_rdma_qp_cleanup(void* arg); void vhost_rdma_queue_cleanup(struct vhost_rdma_qp *qp, struct vhost_rdma_queue* queue); #endif 也改一下
10-10
#下面程序运行时报错: C:\Users\Administrator\AppData\Local\Programs\Python\Python312\python.exe C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py Traceback (most recent call last): File "C:\Users\Administrator\AppData\Local\Programs\Python\Python312\Lib\site-packages\transformers\utils\generic.py", line 34, in <module> from ..utils import logging ImportError: attempted relative import with no known parent package 进程已结束,退出代码为 1 ------------------------------------------------------------------------------------------------ import inspect import json import os import tempfile import warnings from collections import OrderedDict, UserDict, defaultdict from collections.abc import Iterable, MutableMapping from contextlib import ExitStack, contextmanager from dataclasses import dataclass, fields, is_dataclass from enum import Enum from functools import partial, wraps from typing import Any, Callable, ContextManager, Optional, TypedDict import numpy as np from packaging import version from ..utils import logging from .import_utils import ( get_torch_version, is_flax_available, is_mlx_available, is_tf_available, is_torch_available, is_torch_fx_proxy, requires, ) _CAN_RECORD_REGISTRY = {} logger = logging.get_logger(__name__) if is_torch_available(): # required for @can_return_tuple decorator to work with torchdynamo import torch # noqa: F401 from ..model_debugging_utils import model_addition_debugger_context class cached_property(property): """ Descriptor that mimics @property but caches output in member variable. From tensorflow_datasets Built-in in functools from Python 3.8. """ def __get__(self, obj, objtype=None): # See docs.python.org/3/howto/descriptor.html#properties if obj is None: return self if self.fget is None: raise AttributeError("unreadable attribute") attr = "__cached_" + self.fget.__name__ cached = getattr(obj, attr, None) if cached is None: cached = self.fget(obj) setattr(obj, attr, cached) return cached # vendored from distutils.util def strtobool(val): """Convert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. """ val = val.lower() if val in {"y", "yes", "t", "true", "on", "1"}: return 1 if val in {"n", "no", "f", "false", "off", "0"}: return 0 raise ValueError(f"invalid truth value {val!r}") def infer_framework_from_repr(x): """ Tries to guess the framework of an object `x` from its repr (brittle but will help in `is_tensor` to try the frameworks in a smart order, without the need to import the frameworks). """ representation = str(type(x)) if representation.startswith("<class 'torch."): return "pt" elif representation.startswith("<class 'tensorflow."): return "tf" elif representation.startswith("<class 'jax"): return "jax" elif representation.startswith("<class 'numpy."): return "np" elif representation.startswith("<class 'mlx."): return "mlx" def _get_frameworks_and_test_func(x): """ Returns an (ordered since we are in Python 3.7+) dictionary framework to test function, which places the framework we can guess from the repr first, then Numpy, then the others. """ framework_to_test = { "pt": is_torch_tensor, "tf": is_tf_tensor, "jax": is_jax_tensor, "np": is_numpy_array, "mlx": is_mlx_array, } preferred_framework = infer_framework_from_repr(x) # We will test this one first, then numpy, then the others. frameworks = [] if preferred_framework is None else [preferred_framework] if preferred_framework != "np": frameworks.append("np") frameworks.extend([f for f in framework_to_test if f not in [preferred_framework, "np"]]) return {f: framework_to_test[f] for f in frameworks} def is_tensor(x): """ Tests if `x` is a `torch.Tensor`, `tf.Tensor`, `jaxlib.xla_extension.DeviceArray`, `np.ndarray` or `mlx.array` in the order defined by `infer_framework_from_repr` """ # This gives us a smart order to test the frameworks with the corresponding tests. framework_to_test_func = _get_frameworks_and_test_func(x) for test_func in framework_to_test_func.values(): if test_func(x): return True # Tracers if is_torch_fx_proxy(x): return True if is_flax_available(): from jax.core import Tracer if isinstance(x, Tracer): return True return False def _is_numpy(x): return isinstance(x, np.ndarray) def is_numpy_array(x): """ Tests if `x` is a numpy array or not. """ return _is_numpy(x) def _is_torch(x): import torch return isinstance(x, torch.Tensor) def is_torch_tensor(x): """ Tests if `x` is a torch tensor or not. Safe to call even if torch is not installed. """ return False if not is_torch_available() else _is_torch(x) def _is_torch_device(x): import torch return isinstance(x, torch.device) def is_torch_device(x): """ Tests if `x` is a torch device or not. Safe to call even if torch is not installed. """ return False if not is_torch_available() else _is_torch_device(x) def _is_torch_dtype(x): import torch if isinstance(x, str): if hasattr(torch, x): x = getattr(torch, x) else: return False return isinstance(x, torch.dtype) def is_torch_dtype(x): """ Tests if `x` is a torch dtype or not. Safe to call even if torch is not installed. """ return False if not is_torch_available() else _is_torch_dtype(x) def _is_tensorflow(x): import tensorflow as tf return isinstance(x, tf.Tensor) def is_tf_tensor(x): """ Tests if `x` is a tensorflow tensor or not. Safe to call even if tensorflow is not installed. """ return False if not is_tf_available() else _is_tensorflow(x) def _is_tf_symbolic_tensor(x): import tensorflow as tf # the `is_symbolic_tensor` predicate is only available starting with TF 2.14 if hasattr(tf, "is_symbolic_tensor"): return tf.is_symbolic_tensor(x) return isinstance(x, tf.Tensor) def is_tf_symbolic_tensor(x): """ Tests if `x` is a tensorflow symbolic tensor or not (ie. not eager). Safe to call even if tensorflow is not installed. """ return False if not is_tf_available() else _is_tf_symbolic_tensor(x) def _is_jax(x): import jax.numpy as jnp # noqa: F811 return isinstance(x, jnp.ndarray) def is_jax_tensor(x): """ Tests if `x` is a Jax tensor or not. Safe to call even if jax is not installed. """ return False if not is_flax_available() else _is_jax(x) def _is_mlx(x): import mlx.core as mx return isinstance(x, mx.array) def is_mlx_array(x): """ Tests if `x` is a mlx array or not. Safe to call even when mlx is not installed. """ return False if not is_mlx_available() else _is_mlx(x) def to_py_obj(obj): """ Convert a TensorFlow tensor, PyTorch tensor, Numpy array or python list to a python list. """ if isinstance(obj, (int, float)): return obj elif isinstance(obj, (dict, UserDict)): return {k: to_py_obj(v) for k, v in obj.items()} elif isinstance(obj, (list, tuple)): try: arr = np.array(obj) if np.issubdtype(arr.dtype, np.integer) or np.issubdtype(arr.dtype, np.floating): return arr.tolist() except Exception: pass return [to_py_obj(o) for o in obj] framework_to_py_obj = { "pt": lambda obj: obj.tolist(), "tf": lambda obj: obj.numpy().tolist(), "jax": lambda obj: np.asarray(obj).tolist(), "np": lambda obj: obj.tolist(), } # This gives us a smart order to test the frameworks with the corresponding tests. framework_to_test_func = _get_frameworks_and_test_func(obj) for framework, test_func in framework_to_test_func.items(): if test_func(obj): return framework_to_py_obj[framework](obj) # tolist also works on 0d np arrays if isinstance(obj, np.number): return obj.tolist() else: return obj def to_numpy(obj): """ Convert a TensorFlow tensor, PyTorch tensor, Numpy array or python list to a Numpy array. """ framework_to_numpy = { "pt": lambda obj: obj.detach().cpu().numpy(), "tf": lambda obj: obj.numpy(), "jax": lambda obj: np.asarray(obj), "np": lambda obj: obj, } if isinstance(obj, (dict, UserDict)): return {k: to_numpy(v) for k, v in obj.items()} elif isinstance(obj, (list, tuple)): return np.array(obj) # This gives us a smart order to test the frameworks with the corresponding tests. framework_to_test_func = _get_frameworks_and_test_func(obj) for framework, test_func in framework_to_test_func.items(): if test_func(obj): return framework_to_numpy[framework](obj) return obj class ModelOutput(OrderedDict): """ Base class for all model outputs as dataclass. Has a `__getitem__` that allows indexing by integer or slice (like a tuple) or strings (like a dictionary) that will ignore the `None` attributes. Otherwise behaves like a regular python dictionary. <Tip warning={true}> You can't unpack a `ModelOutput` directly. Use the [`~utils.ModelOutput.to_tuple`] method to convert it to a tuple before. </Tip> """ def __init_subclass__(cls) -> None: """Register subclasses as pytree nodes. This is necessary to synchronize gradients when using `torch.nn.parallel.DistributedDataParallel` with `static_graph=True` with modules that output `ModelOutput` subclasses. """ if is_torch_available(): if version.parse(get_torch_version()) >= version.parse("2.2"): from torch.utils._pytree import register_pytree_node register_pytree_node( cls, _model_output_flatten, partial(_model_output_unflatten, output_type=cls), serialized_type_name=f"{cls.__module__}.{cls.__name__}", ) else: from torch.utils._pytree import _register_pytree_node _register_pytree_node( cls, _model_output_flatten, partial(_model_output_unflatten, output_type=cls), ) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) # Subclasses of ModelOutput must use the @dataclass decorator # This check is done in __init__ because the @dataclass decorator operates after __init_subclass__ # issubclass() would return True for issubclass(ModelOutput, ModelOutput) when False is needed # Just need to check that the current class is not ModelOutput is_modeloutput_subclass = self.__class__ != ModelOutput if is_modeloutput_subclass and not is_dataclass(self): raise TypeError( f"{self.__module__}.{self.__class__.__name__} is not a dataclass." " This is a subclass of ModelOutput and so must use the @dataclass decorator." ) def __post_init__(self): """Check the ModelOutput dataclass. Only occurs if @dataclass decorator has been used. """ class_fields = fields(self) # Safety and consistency checks if not len(class_fields): raise ValueError(f"{self.__class__.__name__} has no fields.") if not all(field.default is None for field in class_fields[1:]): raise ValueError(f"{self.__class__.__name__} should not have more than one required field.") first_field = getattr(self, class_fields[0].name) other_fields_are_none = all(getattr(self, field.name) is None for field in class_fields[1:]) if other_fields_are_none and not is_tensor(first_field): if isinstance(first_field, dict): iterator = first_field.items() first_field_iterator = True else: try: iterator = iter(first_field) first_field_iterator = True except TypeError: first_field_iterator = False # if we provided an iterator as first field and the iterator is a (key, value) iterator # set the associated fields if first_field_iterator: for idx, element in enumerate(iterator): if not isinstance(element, (list, tuple)) or len(element) != 2 or not isinstance(element[0], str): if idx == 0: # If we do not have an iterator of key/values, set it as attribute self[class_fields[0].name] = first_field else: # If we have a mixed iterator, raise an error raise ValueError( f"Cannot set key/value for {element}. It needs to be a tuple (key, value)." ) break setattr(self, element[0], element[1]) if element[1] is not None: self[element[0]] = element[1] elif first_field is not None: self[class_fields[0].name] = first_field else: for field in class_fields: v = getattr(self, field.name) if v is not None: self[field.name] = v def __delitem__(self, *args, **kwargs): raise Exception(f"You cannot use ``__delitem__`` on a {self.__class__.__name__} instance.") def setdefault(self, *args, **kwargs): raise Exception(f"You cannot use ``setdefault`` on a {self.__class__.__name__} instance.") def pop(self, *args, **kwargs): raise Exception(f"You cannot use ``pop`` on a {self.__class__.__name__} instance.") def update(self, *args, **kwargs): raise Exception(f"You cannot use ``update`` on a {self.__class__.__name__} instance.") def __getitem__(self, k): if isinstance(k, str): inner_dict = dict(self.items()) return inner_dict[k] else: return self.to_tuple()[k] def __setattr__(self, name, value): if name in self.keys() and value is not None: # Don't call self.__setitem__ to avoid recursion errors super().__setitem__(name, value) super().__setattr__(name, value) def __setitem__(self, key, value): # Will raise a KeyException if needed super().__setitem__(key, value) # Don't call self.__setattr__ to avoid recursion errors super().__setattr__(key, value) def __reduce__(self): if not is_dataclass(self): return super().__reduce__() callable, _args, *remaining = super().__reduce__() args = tuple(getattr(self, field.name) for field in fields(self)) return callable, args, *remaining def to_tuple(self) -> tuple[Any]: """ Convert self to a tuple containing all the attributes/keys that are not `None`. """ return tuple(self[k] for k in self.keys()) if is_torch_available(): import torch.utils._pytree as _torch_pytree def _model_output_flatten(output: ModelOutput) -> tuple[list[Any], "_torch_pytree.Context"]: return list(output.values()), list(output.keys()) def _model_output_unflatten( values: Iterable[Any], context: "_torch_pytree.Context", output_type=None, ) -> ModelOutput: return output_type(**dict(zip(context, values))) if version.parse(get_torch_version()) >= version.parse("2.2"): _torch_pytree.register_pytree_node( ModelOutput, _model_output_flatten, partial(_model_output_unflatten, output_type=ModelOutput), serialized_type_name=f"{ModelOutput.__module__}.{ModelOutput.__name__}", ) else: _torch_pytree._register_pytree_node( ModelOutput, _model_output_flatten, partial(_model_output_unflatten, output_type=ModelOutput), ) class ExplicitEnum(str, Enum): """ Enum with more explicit error message for missing values. """ @classmethod def _missing_(cls, value): raise ValueError( f"{value} is not a valid {cls.__name__}, please select one of {list(cls._value2member_map_.keys())}" ) class PaddingStrategy(ExplicitEnum): """ Possible values for the `padding` argument in [`PreTrainedTokenizerBase.__call__`]. Useful for tab-completion in an IDE. """ LONGEST = "longest" MAX_LENGTH = "max_length" DO_NOT_PAD = "do_not_pad" class TensorType(ExplicitEnum): """ Possible values for the `return_tensors` argument in [`PreTrainedTokenizerBase.__call__`]. Useful for tab-completion in an IDE. """ PYTORCH = "pt" TENSORFLOW = "tf" NUMPY = "np" JAX = "jax" MLX = "mlx" class ContextManagers: """ Wrapper for `contextlib.ExitStack` which enters a collection of context managers. Adaptation of `ContextManagers` in the `fastcore` library. """ def __init__(self, context_managers: list[ContextManager]): self.context_managers = context_managers self.stack = ExitStack() def __enter__(self): for context_manager in self.context_managers: self.stack.enter_context(context_manager) def __exit__(self, *args, **kwargs): self.stack.__exit__(*args, **kwargs) def can_return_loss(model_class): """ Check if a given model can return loss. Args: model_class (`type`): The class of the model. """ framework = infer_framework(model_class) if framework == "tf": signature = inspect.signature(model_class.call) # TensorFlow models elif framework == "pt": signature = inspect.signature(model_class.forward) # PyTorch models else: signature = inspect.signature(model_class.__call__) # Flax models for p in signature.parameters: if p == "return_loss" and signature.parameters[p].default is True: return True return False def find_labels(model_class): """ Find the labels used by a given model. Args: model_class (`type`): The class of the model. """ model_name = model_class.__name__ framework = infer_framework(model_class) if framework == "tf": signature = inspect.signature(model_class.call) # TensorFlow models elif framework == "pt": signature = inspect.signature(model_class.forward) # PyTorch models else: signature = inspect.signature(model_class.__call__) # Flax models if "QuestionAnswering" in model_name: return [p for p in signature.parameters if "label" in p or p in ("start_positions", "end_positions")] else: return [p for p in signature.parameters if "label" in p] def flatten_dict(d: MutableMapping, parent_key: str = "", delimiter: str = "."): """Flatten a nested dict into a single level dict.""" def _flatten_dict(d, parent_key="", delimiter="."): for k, v in d.items(): key = str(parent_key) + delimiter + str(k) if parent_key else k if v and isinstance(v, MutableMapping): yield from flatten_dict(v, key, delimiter=delimiter).items() else: yield key, v return dict(_flatten_dict(d, parent_key, delimiter)) @contextmanager def working_or_temp_dir(working_dir, use_temp_dir: bool = False): if use_temp_dir: with tempfile.TemporaryDirectory() as tmp_dir: yield tmp_dir else: yield working_dir def transpose(array, axes=None): """ Framework-agnostic version of `numpy.transpose` that will work on torch/TensorFlow/Jax tensors as well as NumPy arrays. """ if is_numpy_array(array): return np.transpose(array, axes=axes) elif is_torch_tensor(array): return array.T if axes is None else array.permute(*axes) elif is_tf_tensor(array): import tensorflow as tf return tf.transpose(array, perm=axes) elif is_jax_tensor(array): import jax.numpy as jnp return jnp.transpose(array, axes=axes) else: raise ValueError(f"Type not supported for transpose: {type(array)}.") def reshape(array, newshape): """ Framework-agnostic version of `numpy.reshape` that will work on torch/TensorFlow/Jax tensors as well as NumPy arrays. """ if is_numpy_array(array): return np.reshape(array, newshape) elif is_torch_tensor(array): return array.reshape(*newshape) elif is_tf_tensor(array): import tensorflow as tf return tf.reshape(array, newshape) elif is_jax_tensor(array): import jax.numpy as jnp return jnp.reshape(array, newshape) else: raise ValueError(f"Type not supported for reshape: {type(array)}.") def squeeze(array, axis=None): """ Framework-agnostic version of `numpy.squeeze` that will work on torch/TensorFlow/Jax tensors as well as NumPy arrays. """ if is_numpy_array(array): return np.squeeze(array, axis=axis) elif is_torch_tensor(array): return array.squeeze() if axis is None else array.squeeze(dim=axis) elif is_tf_tensor(array): import tensorflow as tf return tf.squeeze(array, axis=axis) elif is_jax_tensor(array): import jax.numpy as jnp return jnp.squeeze(array, axis=axis) else: raise ValueError(f"Type not supported for squeeze: {type(array)}.") def expand_dims(array, axis): """ Framework-agnostic version of `numpy.expand_dims` that will work on torch/TensorFlow/Jax tensors as well as NumPy arrays. """ if is_numpy_array(array): return np.expand_dims(array, axis) elif is_torch_tensor(array): return array.unsqueeze(dim=axis) elif is_tf_tensor(array): import tensorflow as tf return tf.expand_dims(array, axis=axis) elif is_jax_tensor(array): import jax.numpy as jnp return jnp.expand_dims(array, axis=axis) else: raise ValueError(f"Type not supported for expand_dims: {type(array)}.") def tensor_size(array): """ Framework-agnostic version of `numpy.size` that will work on torch/TensorFlow/Jax tensors as well as NumPy arrays. """ if is_numpy_array(array): return np.size(array) elif is_torch_tensor(array): return array.numel() elif is_tf_tensor(array): import tensorflow as tf return tf.size(array) elif is_jax_tensor(array): return array.size else: raise ValueError(f"Type not supported for tensor_size: {type(array)}.") def infer_framework(model_class): """ Infers the framework of a given model without using isinstance(), because we cannot guarantee that the relevant classes are imported or available. """ for base_class in inspect.getmro(model_class): module = base_class.__module__ name = base_class.__name__ if module.startswith("tensorflow") or module.startswith("keras") or name == "TFPreTrainedModel": return "tf" elif module.startswith("torch") or name == "PreTrainedModel": return "pt" elif module.startswith("flax") or module.startswith("jax") or name == "FlaxPreTrainedModel": return "flax" else: raise TypeError(f"Could not infer framework from class {model_class}.") def torch_int(x): """ Casts an input to a torch int64 tensor if we are in a tracing context, otherwise to a Python int. """ if not is_torch_available(): return int(x) import torch return x.to(torch.int64) if torch.jit.is_tracing() and isinstance(x, torch.Tensor) else int(x) def torch_float(x): """ Casts an input to a torch float32 tensor if we are in a tracing context, otherwise to a Python float. """ if not is_torch_available(): return int(x) import torch return x.to(torch.float32) if torch.jit.is_tracing() and isinstance(x, torch.Tensor) else int(x) def filter_out_non_signature_kwargs(extra: Optional[list] = None): """ Decorator to filter out named arguments that are not in the function signature. This decorator ensures that only the keyword arguments that match the function's signature, or are specified in the `extra` list, are passed to the function. Any additional keyword arguments are filtered out and a warning is issued. Parameters: extra (`Optional[list]`, *optional*): A list of extra keyword argument names that are allowed even if they are not in the function's signature. Returns: Callable: A decorator that wraps the function and filters out invalid keyword arguments. Example usage: ```python @filter_out_non_signature_kwargs(extra=["allowed_extra_arg"]) def my_function(arg1, arg2, **kwargs): print(arg1, arg2, kwargs) my_function(arg1=1, arg2=2, allowed_extra_arg=3, invalid_arg=4) # This will print: 1 2 {"allowed_extra_arg": 3} # And issue a warning: "The following named arguments are not valid for `my_function` and were ignored: 'invalid_arg'" ``` """ extra = extra or [] extra_params_to_pass = set(extra) def decorator(func): sig = inspect.signature(func) function_named_args = set(sig.parameters.keys()) valid_kwargs_to_pass = function_named_args.union(extra_params_to_pass) # Required for better warning message is_instance_method = "self" in function_named_args is_class_method = "cls" in function_named_args # Mark function as decorated func._filter_out_non_signature_kwargs = True @wraps(func) def wrapper(*args, **kwargs): valid_kwargs = {} invalid_kwargs = {} for k, v in kwargs.items(): if k in valid_kwargs_to_pass: valid_kwargs[k] = v else: invalid_kwargs[k] = v if invalid_kwargs: invalid_kwargs_names = [f"'{k}'" for k in invalid_kwargs] invalid_kwargs_names = ", ".join(invalid_kwargs_names) # Get the class name for better warning message if is_instance_method: cls_prefix = args[0].__class__.__name__ + "." elif is_class_method: cls_prefix = args[0].__name__ + "." else: cls_prefix = "" warnings.warn( f"The following named arguments are not valid for `{cls_prefix}{func.__name__}`" f" and were ignored: {invalid_kwargs_names}", UserWarning, stacklevel=2, ) return func(*args, **valid_kwargs) return wrapper return decorator class TransformersKwargs(TypedDict, total=False): """ Keyword arguments to be passed to the loss function Attributes: num_items_in_batch (`Optional[torch.Tensor]`, *optional*): Number of items in the batch. It is recommended to pass it when you are doing gradient accumulation. output_hidden_states (`Optional[bool]`, *optional*): Most of the models support outputing all hidden states computed during the forward pass. output_attentions (`Optional[bool]`, *optional*): Turn this on to return the intermediary attention scores. output_router_logits (`Optional[bool]`, *optional*): For MoE models, this allows returning the router logits to compute the loss. cumulative_seqlens_q (`torch.LongTensor`, *optional*) Gets cumulative sequence length for query state. cumulative_seqlens_k (`torch.LongTensor`, *optional*) Gets cumulative sequence length for key state. max_length_q (`int`, *optional*): Maximum sequence length for query state. max_length_k (`int`, *optional*): Maximum sequence length for key state. """ num_items_in_batch: Optional["torch.Tensor"] output_hidden_states: Optional[bool] output_attentions: Optional[bool] output_router_logits: Optional[bool] cumulative_seqlens_q: Optional["torch.LongTensor"] cumulative_seqlens_k: Optional["torch.LongTensor"] max_length_q: Optional[int] max_length_k: Optional[int] def is_timm_config_dict(config_dict: dict[str, Any]) -> bool: """Checks whether a config dict is a timm config dict.""" return "pretrained_cfg" in config_dict def is_timm_local_checkpoint(pretrained_model_path: str) -> bool: """ Checks whether a checkpoint is a timm model checkpoint. """ if pretrained_model_path is None: return False # in case it's Path, not str pretrained_model_path = str(pretrained_model_path) is_file = os.path.isfile(pretrained_model_path) is_dir = os.path.isdir(pretrained_model_path) # pretrained_model_path is a file if is_file and pretrained_model_path.endswith(".json"): with open(pretrained_model_path) as f: config_dict = json.load(f) return is_timm_config_dict(config_dict) # pretrained_model_path is a directory with a config.json if is_dir and os.path.exists(os.path.join(pretrained_model_path, "config.json")): with open(os.path.join(pretrained_model_path, "config.json")) as f: config_dict = json.load(f) return is_timm_config_dict(config_dict) return False def set_attribute_for_modules(module: "torch.nn.Module", key: str, value: Any): """ Set a value to a module and all submodules. """ setattr(module, key, value) for submodule in module.children(): set_attribute_for_modules(submodule, key, value) def del_attribute_from_modules(module: "torch.nn.Module", key: str): """ Delete a value from a module and all submodules. """ # because we might remove it previously in case it's a shared module, e.g. activation function if hasattr(module, key): delattr(module, key) for submodule in module.children(): del_attribute_from_modules(submodule, key) def can_return_tuple(func): """ Decorator to wrap model method, to call output.to_tuple() if return_dict=False passed as a kwarg or use_return_dict=False is set in the config. Note: output.to_tuple() convert output to tuple skipping all `None` values. """ @wraps(func) def wrapper(self, *args, **kwargs): return_dict = self.config.return_dict if hasattr(self, "config") else True return_dict_passed = kwargs.pop("return_dict", return_dict) if return_dict_passed is not None: return_dict = return_dict_passed output = func(self, *args, **kwargs) if not return_dict and not isinstance(output, tuple): output = output.to_tuple() return output return wrapper # if is_torch_available(): # @torch._dynamo.disable @dataclass @requires(backends=("torch",)) class OutputRecorder: """ Configuration for recording outputs from a model via hooks. Attributes: target_class (Type): The class (e.g., nn.Module) to which the hook will be attached. index (Optional[int]): If the output is a tuple/list, optionally record only at a specific index. layer_name (Optional[str]): Name of the submodule to target (if needed), e.g., "transformer.layer.3.attn". class_name (Optional[str]): Name of the class to which the hook will be attached. Could be the suffix of class name in some cases. """ target_class: "type[torch.nn.Module]" index: Optional[int] = 0 layer_name: Optional[str] = None class_name: Optional[str] = None def check_model_inputs(func): """ Decorator to intercept specific layer outputs without using hooks. Compatible with torch.compile (Dynamo tracing). """ @wraps(func) def wrapper(self, *args, **kwargs): use_cache = kwargs.get("use_cache") if use_cache is None: use_cache = getattr(self.config, "use_cache", False) return_dict = kwargs.pop("return_dict", None) if return_dict is None: return_dict = getattr(self.config, "return_dict", True) if getattr(self, "gradient_checkpointing", False) and self.training and use_cache: logger.warning_once( "`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`." ) use_cache = False kwargs["use_cache"] = use_cache all_args = kwargs.copy() if "kwargs" in all_args: for k, v in all_args["kwargs"].items(): all_args[k] = v capture_flags = _CAN_RECORD_REGISTRY.get(str(self.__class__), {}) # there is a weak ref for executorch recordable_keys = { f"output_{k}": all_args.get( f"output_{k}", getattr( self.config, f"output_{k}", all_args.get("output_attentions", getattr(self.config, "output_attentions", False)), ), ) for k in capture_flags } collected_outputs = defaultdict(tuple) monkey_patched_layers = [] def make_capture_wrapper(module, orig_forward, key, index): @wraps(orig_forward) def wrapped_forward(*args, **kwargs): if key == "hidden_states" and len(collected_outputs[key]) == 0: collected_outputs[key] += (args[0],) if kwargs.get("debug_io", False): with model_addition_debugger_context( module, kwargs.get("debug_io_dir", "~/model_debug"), kwargs.get("prune_layers") ): output = orig_forward(*args, **kwargs) else: output = orig_forward(*args, **kwargs) if not isinstance(output, tuple): collected_outputs[key] += (output,) elif output[index] is not None: if key not in collected_outputs: collected_outputs[key] = (output[index],) else: collected_outputs[key] += (output[index],) return output return wrapped_forward if any(recordable_keys.values()): capture_tasks = [] for key, layer_specs in capture_flags.items(): if not recordable_keys.get(f"output_{key}", False): continue if not isinstance(layer_specs, list): layer_specs = [layer_specs] for specs in layer_specs: if not isinstance(specs, OutputRecorder): index = 0 if "hidden_states" in key else 1 class_name = None if not isinstance(specs, str) else specs target_class = specs if not isinstance(specs, str) else None specs = OutputRecorder(target_class=target_class, index=index, class_name=class_name) capture_tasks.append((key, specs)) for name, module in self.named_modules(): for key, specs in capture_tasks: # The second check is for multimodals where only backbone layer suffix is available if (specs.target_class is not None and isinstance(module, specs.target_class)) or ( specs.class_name is not None and name.endswith(specs.class_name) ): if specs.layer_name is not None and specs.layer_name not in name: continue # Monkey patch forward original_forward = module.forward module.forward = make_capture_wrapper(module, original_forward, key, specs.index) monkey_patched_layers.append((module, original_forward)) outputs = func(self, *args, **kwargs) # Restore original forward methods for module, original_forward in monkey_patched_layers: module.forward = original_forward # Inject collected outputs into model output for key in collected_outputs: if key == "hidden_states": collected_outputs[key] = collected_outputs[key][:-1] if hasattr(outputs, "vision_hidden_states"): collected_outputs[key] += (outputs.vision_hidden_states,) elif hasattr(outputs, "last_hidden_state"): collected_outputs[key] += (outputs.last_hidden_state,) outputs[key] = collected_outputs[key] elif key == "attentions": if isinstance(capture_flags[key], list) and len(capture_flags[key]) == 2: outputs[key] = collected_outputs[key][0::2] outputs["cross_" + key] = collected_outputs[key][1::2] else: outputs[key] = collected_outputs[key] else: outputs[key] = collected_outputs[key] if return_dict is False: outputs = outputs.to_tuple() return outputs return wrapper class GeneralInterface(MutableMapping): """ Dict-like object keeping track of a class-wide mapping, as well as a local one. Allows to have library-wide modifications though the class mapping, as well as local modifications in a single file with the local mapping. """ # Class instance object, so that a call to `register` can be reflected into all other files correctly, even if # a new instance is created (in order to locally override a given function) _global_mapping = {} def __init__(self): self._local_mapping = {} def __getitem__(self, key): # First check if instance has a local override if key in self._local_mapping: return self._local_mapping[key] return self._global_mapping[key] def __setitem__(self, key, value): # Allow local update of the default functions without impacting other instances self._local_mapping.update({key: value}) def __delitem__(self, key): del self._local_mapping[key] def __iter__(self): # Ensure we use all keys, with the overwritten ones on top return iter({**self._global_mapping, **self._local_mapping}) def __len__(self): return len(self._global_mapping.keys() | self._local_mapping.keys()) @classmethod def register(cls, key: str, value: Callable): cls._global_mapping.update({key: value}) def valid_keys(self) -> list[str]: return list(self.keys())
08-08
static STATUS _qosPortMibUpdateCb(dal_ado_t *adoi, dal_attr *attr) { int ret = ERR_NO_ERROR; char *key = NULL; void *handler = NULL; user_port logicPort = {}; user_port physicalPort = {}; QOS_PORT_RATE_DIFF_STRUCT rateDiff = {}; UINT64 ingressVal = 0; UINT64 egressVal = 0; UINT64 bcVal = 0; UINT64 mcVal = 0; UINT32 rate = 0; TIMER_ID recoverTimer; TIMER_ID_INIT(recoverTimer); struct timespec timer = {}; char strUp[STR_STRUP_SIZE] = {}; char timerName[STR_TIMER_NAME_SIZE] = {}; APPQOS_ADCFG_OPT optCfg = {}; QOS_PORT_STATUS portStatus = {}; UINT32 lagId = 0; UINT8 shutdownFlag = 0; NTFY_QOS qosNtfy = {}; MAC_ADDRESS sysMac = {}; char macStr[STR_MAC_SIZE] = {}; char portStr[STR_STRUP_SIZE] = {}; memset(macStr, 0, 20); libStkSysDevMacGet(UNIT_CURRENT, sysMac); ether2str(macStr, sysMac, CSL_UPCASE, STR_TRANS_CLI); qosTrapCounter++; if (qosTrapCounter >= QOS_STORM_EXCEED_LOG_CYCLE) { qosTrapCounter = 0; l_ingressLogEnable = TRUE; l_egressLogEnable = TRUE; l_bcLogEnable = TRUE; l_mcLogEnable = TRUE; } /* 置位flag */ BOOL f_ingressLogEnable = FALSE; BOOL f_egressLogEnable = FALSE; BOOL f_bcLogEnable = FALSE; BOOL f_mcLogEnable = FALSE; if (NULL != (handler = DAL_ADOI_ENTRY(adoi, DAL_PORT_K_MIB))) { DAL_ADOI_ENTRY_LOOP(handler) { if(NULL == (key = DAL_ADOI_ENTRY_KEY(handler)) || !DAL_ADOI_ENTRY_KEY_MATCH(handler, DAL_PORT_K_MIB_ALL)) { continue; } DAL_PORT_KEY_MIB_PARSE_TO_UP(key, physicalPort); /* QOS_TODO:所有端口启用功能并且link-up时存在性能问题 get交换机的时间戳,通过绝对时间来处理 */ adQosGetPortLinkStatus(physicalPort, &portStatus); if (portStatus.status == DISABLE) { continue; } /* KEY inner field&value loop */ if (DAL_ADOI_ENTRY_KEY_EMPTY(handler)) { QOS_DEBUG_COMMON("Invalid operation: deleting Fixed entries!"); } else { DAL_ADOI_ENTRY_FIELD_LOOP(handler, key) { if (DAL_ADOI_ENTRY_FIELD_MATCH(handler, DAL_PORT_K_MIB_F_RXBYTEDIFF)) { dalAdoiGetEntryUI64(adoi, DAL_PORT_K_MIB, &rateDiff.rxbyteDiff); } else if (DAL_ADOI_ENTRY_FIELD_MATCH(handler, DAL_PORT_K_MIB_F_TXBYTEDIFF)) { dalAdoiGetEntryUI64(adoi, DAL_PORT_K_MIB, &rateDiff.txbyteDiff); } else if (DAL_ADOI_ENTRY_FIELD_MATCH(handler, DAL_PORT_K_MIB_F_BCNUMDIFF)) { dalAdoiGetEntryUI64(adoi, DAL_PORT_K_MIB, &rateDiff.bcNumDiff); } else if (DAL_ADOI_ENTRY_FIELD_MATCH(handler, DAL_PORT_K_MIB_F_MCNUMDIFF)) { dalAdoiGetEntryUI64(adoi, DAL_PORT_K_MIB, &rateDiff.mcNumDiff); } } } qosGetLagIdOfPort(physicalPort, &lagId); if (lagId) { UP_FROM_LAG(logicPort, lagId); } else { memcpy(&logicPort, &physicalPort, sizeof(user_port)); } ret = dataQosGetPortConfig(logicPort, &optCfg); if (ret != ERR_NO_ERROR) { continue; } if(optCfg.stormLogging) {QOS_DEBUG("upIdx:%d, rxbyteDiff:%d, txbyteDiff:%d, bcNumDiff:%d, mcNumDiff:%d", UP_INDEX(logicPort), rateDiff.rxbyteDiff, rateDiff.txbyteDiff, rateDiff.bcNumDiff, rateDiff.mcNumDiff);} ingressVal = (UINT64)(optCfg.ingressRateValue) * QOS_RATE_KBPS_THOUSAND / QOS_IFG_DELAY; /*1(sec)*1000*/ egressVal = (UINT64)(optCfg.egressRateValue) * QOS_RATE_KBPS_THOUSAND / QOS_IFG_DELAY; if (QOS_RATE_MODE_PPS != optCfg.rateMode) { if (QOS_RATE_MODE_KBPS == optCfg.rateMode) { bcVal = (UINT64)(optCfg.bcRate) * QOS_RATE_KBPS_THOUSAND / QOS_IFG_DELAY; } else if (QOS_RATE_MODE_RATIO == optCfg.rateMode) { rate = optCfg.bcRate; _rateValueTransform(logicPort, &rate); bcVal = (UINT64)(rate)*QOS_RATE_KBPS_THOUSAND / QOS_IFG_DELAY; } if (QOS_RATE_MODE_KBPS == optCfg.rateMode) { mcVal = (UINT64)(optCfg.mcRate) * QOS_RATE_KBPS_THOUSAND / QOS_IFG_DELAY; } else if (QOS_RATE_MODE_RATIO == optCfg.rateMode) { rate = optCfg.mcRate; _rateValueTransform(logicPort, &rate); mcVal = (UINT64)(rate)*QOS_RATE_KBPS_THOUSAND / QOS_IFG_DELAY; } } else { bcVal = (UINT64)optCfg.bcRate; /*1 sec*/ mcVal = (UINT64)optCfg.mcRate; } if (optCfg.ingressRateValue && rateDiff.rxbyteDiff > ingressVal) { if (l_ingressLogEnable) { //QOS_TODO: snmp trap、controller log f_ingressLogEnable = TRUE; QDW("ingress exceed:%d", UP_PORT(physicalPort)); memset(&qosNtfy, 0, sizeof(qosNtfy)); qosNtfy.physicalPort = physicalPort; qosNtfy.ingressRate = optCfg.ingressRateValue; stateQosSnmpTrapSet(QOS_SNMP_TRAP_TYPE_BANDWIDTH_INGRESS, &qosNtfy); PORT_UP2STR(physicalPort, portStr); QOS_ADD_LOG_ONE_PARA(LOG_QOS_PORT_INGRESS_REACH, portStr); } } else { /*bc trap & notify*/ if (optCfg.bcRate && QOS_RATE_MODE_PPS != optCfg.rateMode && (rateDiff.rxbyteDiff > bcVal)&&(QOS_RATE_ADJUST_PAR * rateDiff.bcNumDiff >= bcVal)) { double factor = 1; int packet_length = rateDiff.rxbyteDiff/rateDiff.bcNumDiff; AD_QOS_RATE_ADJUST_BY_PACKET_LENGTH(factor, packet_length); QOS_DEBUG_COMMON("factor %4f, rateValNew.rxbyteDiff %d",factor,rateDiff.rxbyteDiff); if(rateDiff.rxbyteDiff >= factor * bcVal) { shutdownFlag = TRUE; if (l_bcLogEnable) { //QOS_TODO: snmp trap、controller log f_bcLogEnable = TRUE; QDW("bc exceed:%d",UP_PORT(physicalPort)); memset(&qosNtfy, 0, sizeof(qosNtfy)); qosNtfy.physicalPort = physicalPort; qosNtfy.bcastRate = optCfg.bcRate; qosNtfy.bcastMode = optCfg.rateMode; stateQosSnmpTrapSet(QOS_SNMP_TRAP_TYPE_STORM_CTRL_BCAST, &qosNtfy); stateQosPortStormOccursSet(physicalPort, QOS_RATE_STORM_MODE_BC, TRUE); if (optCfg.stormLogging) { PORT_UP2STR(physicalPort, portStr); QOS_ADD_LOG_ONE_PARA(LOG_QOS_BCSTORM_CONTROL_REACH, portStr); syslogAdd_omada(QOS_LOG_MODULE_NAME, LOG_OMADA_STORM_DETECTED, OMADA_KEY_OSW_STORM, OMD_ALERT_REPORT, portStr, (ULONG)"Broadcast", (ULONG)macStr, (ULONG)portStr, 0, 0, 0); } } } } if (optCfg.bcRate && QOS_RATE_MODE_PPS == optCfg.rateMode && rateDiff.bcNumDiff >= bcVal) { shutdownFlag = TRUE; if (l_bcLogEnable) { //QOS_TODO: snmp trap、controller log f_bcLogEnable = TRUE; QDW("bc exceed:%d",UP_PORT(physicalPort)); memset(&qosNtfy, 0, sizeof(qosNtfy)); qosNtfy.physicalPort = physicalPort; qosNtfy.bcastRate = optCfg.bcRate; qosNtfy.bcastMode = optCfg.rateMode; stateQosSnmpTrapSet(QOS_SNMP_TRAP_TYPE_STORM_CTRL_BCAST, &qosNtfy); stateQosPortStormOccursSet(physicalPort, QOS_RATE_STORM_MODE_BC, TRUE); if (optCfg.stormLogging) { PORT_UP2STR(physicalPort, portStr); QOS_ADD_LOG_ONE_PARA(LOG_QOS_BCSTORM_CONTROL_REACH, portStr); syslogAdd_omada(QOS_LOG_MODULE_NAME, LOG_OMADA_STORM_DETECTED, OMADA_KEY_OSW_STORM, OMD_ALERT_REPORT, portStr, (ULONG)"Broadcast", (ULONG)macStr, (ULONG)portStr, 0, 0, 0); } } } /*mc trap & notify*/ if (optCfg.mcRate && QOS_RATE_MODE_PPS != optCfg.rateMode && (rateDiff.rxbyteDiff > mcVal) && (QOS_RATE_ADJUST_PAR * rateDiff.mcNumDiff >= mcVal)) { double factor = 1; int packet_length = rateDiff.rxbyteDiff/rateDiff.mcNumDiff; AD_QOS_RATE_ADJUST_BY_PACKET_LENGTH(factor, packet_length); QOS_DEBUG_COMMON("factor %4f, rateValNew.rxbyteDiff %d",factor,rateDiff.rxbyteDiff); if(rateDiff.rxbyteDiff >= factor * mcVal) { shutdownFlag = TRUE; if (l_mcLogEnable) { //QOS_TODO: snmp trap、controller log f_mcLogEnable = TRUE; QDW("mc exceed:%d",UP_PORT(physicalPort)); memset(&qosNtfy, 0, sizeof(qosNtfy)); qosNtfy.physicalPort = physicalPort; qosNtfy.mcastRate = optCfg.mcRate; qosNtfy.mcastMode = optCfg.rateMode; stateQosSnmpTrapSet(QOS_SNMP_TRAP_TYPE_STORM_CTRL_MCAST, &qosNtfy); stateQosPortStormOccursSet(physicalPort, QOS_RATE_STORM_MODE_MC, TRUE); if (optCfg.stormLogging) { PORT_UP2STR(physicalPort, portStr); QOS_ADD_LOG_ONE_PARA(LOG_QOS_MCSTORM_CONTROL_REACH, portStr); syslogAdd_omada(QOS_LOG_MODULE_NAME, LOG_OMADA_STORM_DETECTED, OMADA_KEY_OSW_STORM, OMD_ALERT_REPORT, portStr, (ULONG)"Multicast", (ULONG)macStr, (ULONG)portStr, 0, 0, 0); } } } } } if (optCfg.egressRateValue && rateDiff.txbyteDiff > egressVal) { if (l_egressLogEnable) { //QOS_TODO: snmp trap、syslog、controller log f_egressLogEnable = TRUE; QDW("egress exceed:%d",UP_PORT(physicalPort)); memset(&qosNtfy, 0, sizeof(qosNtfy)); qosNtfy.physicalPort = physicalPort; qosNtfy.egressRate = optCfg.egressRateValue; stateQosSnmpTrapSet(QOS_SNMP_TRAP_TYPE_BANDWIDTH_EGRESS, &qosNtfy); PORT_UP2STR(physicalPort, portStr); QOS_ADD_LOG_ONE_PARA(LOG_QOS_PORT_EGRESS_REACH, portStr); } } /*if port belong to a LAG, the optCfg is LAG rate Config*/ if (optCfg.stormOper == QOS_STORM_EXCEED_SHUTDOWN && shutdownFlag /* && portStatus */) { QOS_DEBUG("QOS_STORM_EXCEED_SHUTDOWN"); shutdownFlag = FALSE; adQosSetPortState(physicalPort, DISABLE); stateQosPortBlockStatusSet(physicalPort, ENABLE); PORT_UP2STR(physicalPort, portStr); QOS_ADD_LOG_ONE_PARA(LOG_QOS_PORT_STORM_CONTROL_SHUTDOWN, portStr); syslogAdd_omada(QOS_LOG_MODULE_NAME, LOG_OMADA_STORM_SHUTDOWN, OMADA_KEY_OSW_PB, OMD_ALERT_REPORT, portStr, (ULONG)macStr, (ULONG)portStr, 0, 0, 0, 0); //QOS_TODO:堆叠时,向master发送notify更新block信息 if (optCfg.recoverTime) { if (UP_IS_LAG(logicPort)) dataQosRcvrTimerIdLagGet(physicalPort,&recoverTimer); else dataQosRcvrTimerIdPhyGet(logicPort,&recoverTimer); /*add timer, LAG member set their own logic timer ID: check the timer value, if not 0, LAG has a timer*/ /* controller独有bug,定时器存在,需删除*/ if (TIMER_ID_IS_VALID(recoverTimer)) { DEL_TIMER(recoverTimer); } timer.tv_sec = optCfg.recoverTime; timer.tv_nsec = 0; user_port upArr[2] = {}; upArr[0] = physicalPort; upArr[1] = logicPort; usUp2Str(upArr[0],strUp,UP_STR_BRF_PRFX); snprintf(timerName, sizeof(timerName), "qosRecoverTime:%s",strUp); if (UP_IS_LAG(logicPort)) { recoverTimer = add_timer(timerName, &timer, _qosRateRecoverTimerNotify, upArr, sizeof(upArr), EXECUTE_SINGLE); if (TIMER_ID_IS_VALID(recoverTimer)) dataQosRcvrTimerIdLagSet(physicalPort, recoverTimer); } else { recoverTimer = add_timer(timerName, &timer, _qosRateRecoverTimerNotify, upArr, sizeof(upArr), EXECUTE_SINGLE); if (TIMER_ID_IS_VALID(recoverTimer)) dataQosRcvrTimerIdPhySet(physicalPort, recoverTimer); } } } if(f_ingressLogEnable){ l_ingressLogEnable = FALSE; f_ingressLogEnable = FALSE; } if(f_egressLogEnable){ l_egressLogEnable = FALSE; f_egressLogEnable = FALSE; } if(f_bcLogEnable){ l_bcLogEnable = FALSE; f_bcLogEnable = FALSE; } if(f_mcLogEnable){ l_mcLogEnable = FALSE; f_mcLogEnable = FALSE; } } } return ret; } 能否给我最详细的解释,让我弄清楚这个函数要实现什么功能
最新发布
11-22
08-16
在 IT 领域中,`length` 是一个常见术语,其具体含义取决于上下文。以下是不同场景中 `length` 的用法和解释: ### Java 中的 `length` 和 `length()` 在 Java 中,`length` 用于获取数组的大小,而 `length()` 是 `String` 类的一个方法,用于获取字符串的字符数。例如: ```java int[] array = {1, 2, 3}; int arrayLength = array.length; // 获取数组长度 String str = "Hello"; int stringLength = str.length(); // 获取字符串字符数 ``` 数组的 `length` 属性是公有的实例变量,直接通过数组对象访问[^2]。 ### 数据库中的 `length` 在数据库系统中,如 MySQL 和 Vertica,`length` 函数通常用于计算字符串所占用的字节数,而 `char_length` 或 `character_length` 函数则用于计算字符串中的字符数。例如,在 MySQL 中: ```sql SELECT LENGTH('text') AS byte_length, CHAR_LENGTH('text') AS char_length; ``` 此外,`length` 可以用于查询字符串长度、列的最大字符串长度,甚至可以用来统计某个字符在字符串中出现的次数[^3]。 ### C/C++ 中的 `sizeof` 与 `length` 在 C/C++ 中,`length` 并不是一个内置关键字,但可以使用 `sizeof` 运算符来获取数组的大小。例如: ```c int array[10] = {6, 5, 4, 3, 2, 1}; size_t arraySize = sizeof(array) / sizeof(array[0]); // 获取数组元素个数 ``` 在这种情况下,`sizeof(array)` 返回整个数组占用的字节数,而 `sizeof(array[0])` 返回单个元素的大小,通过除法运算可以得到数组元素的总数[^4]。 ### 字符串处理中的 `length` 在处理字符串时,`length` 通常指字符串中字符的数量。然而,需要注意字符编码的影响,例如 UTF-8 编码下某些字符可能占用多个字节,这会影响 `length` 的结果是否准确[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值