/* * * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. * * Copyright 2007-2020 Broadcom Inc. All rights reserved. * * Module: Field Processor APIs * * Purpose: * 'Field Processor' (FP) API for Dune Packet Processor devices * Tests Functions * PPD layer feature enumeration * BCM layer feature configuration */ #ifdef _ERR_MSG_MODULE_NAME #error "_ERR_MSG_MODULE_NAME redefined" #endif #define _ERR_MSG_MODULE_NAME BSL_BCM_FP #define _ERR_CHECK_BCM_PETRA_FIELD_TEST_RESET(rv) \ do { \ if((rv) == -1) /* tr 141 failed */ { \ _BCM_PETRA_FIELD_TEST_FAIL_MSG; \ goto fail; \ } \ } while(0) #include <soc/hwstate/hw_log.h> #include <shared/bsl.h> #include <appl/diag/shell.h> #include <bcm/field.h> #include <bcm/error.h> #include <bcm_int/petra_dispatch.h> #include <bcm_int/dpp/field_int.h> #include <bcm_int/dpp/l3.h> #include <bcm_int/dpp/error.h> #include <bcm_int/dpp/qos.h> #include <bcm_int/common/debug.h> #include <shared/alloc.h> #include <sal/appl/sal.h> #include <shared/swstate/access/sw_state_access.h> #include <soc/dpp/ARAD/ARAD_PP/arad_pp_fp.h> #include <soc/dpp/ARAD/arad_pmf_low_level_ce.h> #include <soc/dpp/ARAD/arad_sw_db.h> #include <soc/dpp/ARAD/arad_header_parsing_utils.h> #include <soc/dpp/PPD/ppd_api_diag.h> #include <soc/dpp/ARAD/ARAD_PP/arad_pp_diag.h> #include <appl/diag/test.h> #include <soc/dcmn/dcmn_wb.h> extern int test_dispatch(int u, test_t *test, int loops, args_t *a); extern int init_deinit_test(int u, args_t *a, void *p); extern int init_deinit_test_init(int unit, args_t *a, void **p); extern int init_deinit_test_done(int unit, void *p); /* The slow level is according to the run time of the test: * 0 - till 0.3 seconds * 1 - 0.3 seconds to 3 seconds * 2 - 3 seconds to 8 seconds * 3 - 8 seconds to 20 seconds * 4 - more then 20 seconds */ #define _BCM_PETRA_FIELD_TEST_NOF_ITERATION_SUPER_FAST(slow_level, nof_iterations)\ switch(slow_level) {\ case 0:\ nof_iterations = 2;\ break;\ case 1:\ nof_iterations = 1;\ break;\ default:\ nof_iterations = 0;\ break;\ } #define _BCM_PETRA_FIELD_TEST_NOF_ITERATION_FAST(slow_level, nof_iterations)\ switch(slow_level) {\ case 0:\ nof_iterations = 10;\ break;\ case 1:\ nof_iterations = 10;\ break;\ case 2:\ nof_iterations = 5;\ break;\ default:\ nof_iterations = 0;\ break;\ } #define _BCM_PETRA_FIELD_TEST_NOF_ITERATION_MEDIUM(slow_level, nof_iterations)\ switch(slow_level) {\ case 0:\ nof_iterations = 100;\ break;\ case 1:\ nof_iterations = 50;\ break;\ case 2:\ nof_iterations = 5;\ break;\ case 3:\ nof_iterations = 8;\ break;\ case 4:\ nof_iterations = 1;\ break;\ default:\ nof_iterations = 0;\ break;\ } #define _BCM_PETRA_FIELD_TEST_NOF_ITERATION_SLOW(slow_level, nof_iterations)\ switch(slow_level) {\ case 0:\ nof_iterations = 10000;\ break;\ case 1:\ nof_iterations = 5000;\ break;\ case 2:\ nof_iterations = 500;\ break;\ case 3:\ nof_iterations = 100;\ break;\ case 4:\ nof_iterations = 10;\ break;\ default:\ nof_iterations = 0;\ break;\ } #define _BCM_PETRA_FIELD_TEST_NOF_ITERATION_SCAN -1 #define _BCM_PETRA_FIELD_SET_AND_REMOVE_TEST_NOF_ITEMS_TO_TEST 10 #define _BCM_PETRA_FIELD_TEST_ENTRY_NOF_GROUPS_ID(stage)\ (stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL ? 2 : 1) #define _BCM_PETRA_FIELD_TEST_ENTRY_NOF_GROUPS_ID_MAX 2 #define _BCM_PETRA_FIELD_TEST_NOF_INTERNAL_ENTRY_IDS(unit) SOC_DPP_DEFS_GET_NOF_ENTRY_IDS(unit) #define _BCM_PETRA_FIELD_TEST_NOF_EXTERNAL_ENTRY_IDS SOC_TMC_TCAM_NL_88650_MAX_NOF_ENTRIES #define _BCM_PETRA_FIELD_TEST_NOF_ENTRIES_FULL_TCAM 1<<14 #define _BCM_PETRA_FIELD_TEST_NOF_ENTRIES_FULL_TCAM_PERF(unit) SOC_DPP_DEFS_GET(unit, nof_tcam_entries_160_bits) #define _BCM_PETRA_FIELD_TEST_NOF_PRIORITIES_FULL_TCAM_PERF 5 #define _BCM_PETRA_FIELD_TEST_NOF_ENTRIES_PER_PRIO_FULL_TCAM_PERF(unit) (SOC_DPP_DEFS_GET(unit, nof_tcam_big_bank_lines) / 2) /* 2 priority blocks per big bank */ #define _BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH 512 #define _BCM_PETRA_FIELD_TEST_MAX_QUALIFIERS_IN_ENTRY 12 #define _BCM_PETRA_FIELD_TEST_MAX_ACTIONS_IN_ENTRY 9 #define _BCM_PETRA_FIELD_TEST_MAX_ENTRIES_IN_GROUP(nof_iterations)\ ((nof_iterations) >= 10000 ? (2*1024) : 100) #define _BCM_PETRA_FIELD_TEST_ENTRY_NOF_ITEMS_TO_TEST 100 #define _BCM_PETRA_FIELD_TEST_FIELD_GROUP_BANK_MAX_SIZE 320 #define _BCM_PETRA_FIELD_TEST_FIELD_GROUP_BANK_SIZE_PERF 160 /* Predefined group bank size for the performance tests */ #define _BCM_PETRA_FIELD_TEST_QUALIFIERS_LENGTH_SPLIT_OVERHEAD 7 #define _BCM_PETRA_FIELD_GROUP_PRIO_HIGHEST 120 /*127 (Highest priority - 7 priorities used for ITMH programmable mode)*/ #define _BCM_PETRA_FIELD_GROUP_PRIO_LOWEST 0 #define _BCM_PETRA_FIELD_TEST_NOF_GROUPS_ID_MAX 3 #define _BCM_PETRA_FIELD_TEST_NOF_GROUPS_ID(stage) \ (stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS ? 3 : 1) #define _BCM_PETRA_FIELD_TEST_NOF_APP_TYPES_MAX 3 /* number of field groups we will create in the test of field_group_destroy in order to have failure in the creation */ #define _BCM_FIELD_GROUP_TEST_NOF_GROUPS_DESTROY 10 #define _BCM_PETRA_FIELD_TEST_FIELD_GROUP_DESTROY_WITH_TRAFFIC_NOF_ACTIONS 7 #define _BCM_PETRA_FIELD_TEST_MAXIMAL_GROUP_ID 120 /*127 (Highest group id - 7 groups used for ITMH programmable mode)*/ #define _BCM_PETRA_FILED_TEST_FIELD_GROUP_MAX_QUALIFIERS(stage)\ (stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS ? 6 : 4) /* It has no meaning for egress */ #define _BCM_PETRA_FILED_TEST_FIELD_GROUP_MAX_ACTIONS 2 #define _BCM_PETRA_FIELD_TEST_FULL_TCAM_NOF_GROUPS 1 #define _BCM_PETRA_FIELD_TEST_FULL_TCAM_NOF_ITEMS_TO_TEST 100 #define _BCM_PETRA_FIELD_TYPE_ETHR 0 #define _BCM_PETRA_FIELD_TYPE_IPV4 1 #define _BCM_PETRA_FIELD_TYPE_IPV6 2 #define _BCM_PETRA_FIELD_TYPE_MPLS 3 #define _BCM_PETRA_FIELD_NOF_TYPES 4 #define _BCM_PETRA_FIELD_QUAL_CHAIN 2 #define _BCM_PETRA_FIELD_ACTION_CHAIN 2 #define _BCM_PETRA_FIELD_TEST_PACKET_SIZE_BYTES(unit) ( SOC_IS_QAX(unit)? 120 : 160 ) #define _BCM_PETRA_FIELD_PRIORITY_TEST_NOF_ENTRIES(nof_iterations) \ ((nof_iterations) >= 10000 ? (3*1024) : 100) #define _BCM_PETRA_FIELD_PRIORITY_TEST_NOF_FLIPS 4 #define _BCM_PETRA_FIELD_EGRESS_COS_PROFILE_FOR_HIT_CHECK 5 #define _BCM_PETRA_FIELD_TEST_PP_FP_NOF_MACRO_SIMPLES SOC_PPC_FP_NOF_MACRO_SIMPLES #define _BCM_PETRA_FIELD_TEST_PP_FP_NOF_MACROS SOC_PPC_FP_NOF_MACROS #define _BCM_PETRA_FIELD_TEST_FIELD_GROUP_PRIORITY_NOF_ACTIONS 4 #define _BCM_PETRA_FIELD_TEST_FIELD_GROUP_PRIORITY_ACTION_CHECKED -16 #define _BCM_PETRA_FIELD_TEST_ENTRY_PRIORITY_MAX_DBS 4 #define _BCM_PETRA_FIELD_TEST_ENTRY_PRIORITY_NOF_ENTRIES_TO_INSTALL_IN_BATCH 200 #define _BCM_PETRA_FIELD_TEST_CASCADED_MIN_NOF_BITS 4 #define _BCM_PETRA_FIELD_TEST_CASCADED_MAX_NOF_BITS(unit) (SOC_DPP_DEFS_GET(unit, tcam_cascaded_data_nof_bits) - 4) #define _BCM_PETRA_FIELD_TEST_CASCADED_FORWARDING_VLAN_ID_NEW_VALUE 10 #define _BCM_PETRA_FIELD_TEST_NOF_PRESELS 5 #define _BCM_PETRA_FIELD_TEST_DB_PRESEL_1_NOF_DBS 4 #define _BCM_PETRA_FIELD_TEST_DB_PRESEL_1_NOF_PORTS 5 #define _BCM_PETRA_FIELD_TEST_DB_PRESEL_1_NOF_PRESELS 4 #define _BCM_PETRA_FIELD_TEST_DB_PRESEL_1_NOF_FLIPS 10 #define _BCM_PETRA_FIELD_TEST_DB_PRESEL_1_NOF_PACKETS_TO_SEND 10 /* * Checking if system mode is FRETTA-XR. * Used in _BCM_PETRA_FIELD_TEST_USED_ITMH_DATA_QUALIFIERS(unit) for calculating * of used ITMH qualifiers. */ int fretta_xr_mode_check(int unit) { char *fretta_mode; fretta_mode = soc_property_get_str(unit, "dvapi_system_indicator"); if(fretta_mode == NULL || strcmp(fretta_mode, "FRETTA-XR")) { return 0; }else{ return 1; } } #define _BCM_PETRA_FIELD_TEST_USED_ITMH_DATA_QUALIFIERS(unit) (fretta_xr_mode_check(unit) ? 7 : 6) /*6 last dataquals are used for ITMH programmable mode setting, but fretta mode uses 7*/ #define _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID(unit) (63 - _BCM_PETRA_FIELD_TEST_USED_ITMH_DATA_QUALIFIERS(unit)) #define _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID_ALL (63 - 6) #define _BCM_PETRA_FIELD_TEST_DATA_QUALIFIER_MAX_OFFSET(unit) (SOC_IS_QAX(unit)? 296:504) #define _BCM_PETRA_FIELD_TEST_DATA_QUALIFIER_MAX_LENGTH 32 #define _BCM_PETRA_FIELD_TEST_NOF_GROUPS_DIRECT_EXTRACTION 5 #define _BCM_PETRA_FIELD_TEST_DIRECT_EXTRACTION_MAX_LSB_FIELD_GROUPS 4 /* the same for msb */ #define _BCM_PETRA_FIELD_TEST_DIRECT_EXTRACTION_MAXIMAL_QUALIFIERS_LENGTH 32 #define _BCM_PETRA_FIELD_TEST_DIRECT_EXTRACTION_NOF_ENTRIES_IN_GROUP 2 #define _BCM_PETRA_FIELD_TEST_MAX_ENTRIES_DIRECT_EXTRACTION 48 /* Direct extraction: more than 19b in Arad, 24b in Jericho - e.g. Trap action */ #define _BCM_PETRA_FIELD_TEST_LARGE_DIRECT_EXTRACTION_ACTION (SOC_IS_JERICHO(unit)? bcmFieldActionTrap: bcmFieldActionLearnInVPortNew) #define _BCM_PETRA_FIELD_TEST_DIRECT_TABLE_MAXIMAL_NOF_ENTRIES 20 #define _BCM_PETRA_FIELD_TEST_DIRECT_TABLE_MAXIMAL_QUALIFIERS_LENGTH_SMALL_BANK 7 #define _BCM_PETRA_FIELD_TEST_ITMH_NOF_FIELD_GROUPS_TRAFFIC 2 #define _BCM_PETRA_FIELD_TEST_ITMH_NOF_ACTIONS 21 #define _BCM_PETRA_FIELD_TEST_ITMH_PARSING_TEST_NOF_FLIPS 100 /* Macros */ #define _BCM_PETRA_FIELD_TEST_DEBUG_CHECK_WARN \ bsl_check(bslLayerBcm, bslSourceFp, bslSeverityWarn, unit) #define _BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR \ bsl_check(bslLayerBcm, bslSourceFp, bslSeverityError, unit) #define _BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB \ bsl_check(bslLayerBcm, bslSourceFp, bslSeverityVerbose, unit) #define _BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VVERB \ bsl_check(bslLayerBcm, bslSourceFp, bslSeverityDebug, unit) #if _BCM_DPP_FIELD_EXCESS_VERBOSITY #define _BCM_PETRA_FIELD_TEST_DEBUG_CHECK_EVERB \ bsl_check(bslLayerBcm, bslSourceFp, bslSeverityDebug, unit) #else /* _BCM_DPP_FIELD_EXCESS_VERBOSITY */ #define _BCM_PETRA_FIELD_TEST_DEBUG_CHECK_EVERB 0 #endif /* _BCM_DPP_FIELD_EXCESS_VERBOSITY */ #define _BCM_PETRA_FIELD_TEST_STAGE_TO_STRING(stage)\ ((stage) == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS ? "Ingress" : \ ((stage) == _BCM_DPP_FIELD_STAGE_INDEX_EGRESS ? "Egress" : "External")) #define _BCM_PETRA_FIELD_TEST_FAIL_MSG\ LOG_ERROR(BSL_LS_BCM_FP,\ (BSL_META_U(unit,\ "Failed in field_tests.c line %d.\n"), __LINE__)); #define _BCM_PETRA_TEST_DEINIT_INIT(unit, rv)\ {\ test_t test;\ test.t_name = "DEINT INIT (SOC BCM)";\ test.t_flags = 0x80100000;\ test.t_test = 141;\ test.t_loops = 1;\ test.t_init_f = init_deinit_test_init;\ test.t_done_f = init_deinit_test_done;\ test.t_test_f = init_deinit_test;\ test.t_default_string = 0x0;\ test.t_override_string = 0x0;\ test.t_runs = 0;\ test.t_success = 0;\ test.t_fail = 0;\ WB_TEST(_ERR_CHECK_BCM_PETRA_FIELD_TEST_RESET(rv));\ rv = test_dispatch(unit, &test, -1, NULL);\ if(rv != BCM_E_NONE) {\ _BCM_PETRA_FIELD_TEST_FAIL_MSG;\ goto fail;\ }\ _DCMN_BCM_WARM_BOOT_API_TEST_OVERRIDE_WB_TEST_MODE(unit);\ } typedef enum{ _bcmPetraFieldTestSuperFast = 0, _bcmPetraFieldTestFast = 1, _bcmPetraFieldTestMedium = 2, _bcmPetraFieldTestSlow = 3, _bcmPetraFieldTestScan = 4 }_bcmPetraFieldTestSpeedMode; typedef struct _bcm_petra_field_test_qualify_info_e { uint8 is_valid; uint8 is_undefined;/* if TRUE - data qualifier */ bcm_field_qualify_t qualify; uint32 data[_BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH/32]; uint32 mask[_BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH/32]; }_bcm_petra_field_test_qualify_info_t; typedef struct _bcm_petra_field_test_action_info_s { uint8 is_valid; bcm_field_action_t action; uint32 param0; uint32 param1; }_bcm_petra_field_test_action_info_t; typedef struct _bcm_petra_field_test_entry_info_e { bcm_field_entry_t id; int priority; _bcm_petra_field_test_qualify_info_t quals_info[_BCM_PETRA_FIELD_TEST_MAX_QUALIFIERS_IN_ENTRY]; _bcm_petra_field_test_action_info_t actions_info[_BCM_PETRA_FIELD_TEST_MAX_ACTIONS_IN_ENTRY]; }_bcm_petra_field_test_entry_info_t; typedef struct _bcm_petra_field_test_qualifier_info_e { bcm_field_qualify_t qualify; int (*set)(void); /* the prototype will be casted */ int (*get)(void); /* the prototype will be casted */ uint32 size; /* in bits */ uint32 prototype_id; /* see details below */ }_bcm_petra_field_test_qualifier_info_t; typedef struct _bcm_petra_field_test_vlan_header_e{ uint16 vlan_id; uint8 cfi; uint8 pri; uint16 tag_protocol_id; }_bcm_petra_field_test_vlan_header_t; typedef struct _bcm_petra_field_test_ethernet_header_e{ uint16 ethertype; uint8 nof_vlans; _bcm_petra_field_test_vlan_header_t vlans[2]; bcm_mac_t source_address; bcm_mac_t destination_address; }_bcm_petra_field_test_ethernet_header_t; typedef struct _bcm_petra_field_test_ipv4_header_e{ bcm_ip_t destination_address; bcm_ip_t source_address; uint16 header_checksum; uint8 protocol; uint8 time_to_live; uint16 fragment_offset; uint8 flags; uint16 identification; uint16 total_length; uint8 ecn; uint8 dscp;/* include the ecn*/ uint8 internet_header_length; uint8 version; }_bcm_petra_field_test_ipv4_header_t; typedef struct _bcm_petra_field_test_ipv6_header_e{ bcm_ip6_t destination_address; bcm_ip6_t source_address; uint8 hop_limit; uint8 next_header; uint16 payload_length; uint32 flow_label; uint8 traffic_class; uint8 version; }_bcm_petra_field_test_ipv6_header_t; typedef struct _bcm_petra_field_test_mpls_header_e{ uint8 time_to_live; uint8 bos; uint8 exp; uint32 label; }_bcm_petra_field_test_mpls_header_t; typedef struct _bcm_petra_field_test_tcp_header_e{ /* * just for the tests. * Don't have all the attributes */ uint16 destination_port; uint16 source_port; uint8 control; }_bcm_petra_field_test_tcp_header_t; STATIC _bcm_petra_field_test_qualifier_info_t qualifiers_info[] = { {bcmFieldQualifySrcIp6, (int (*)(void)) bcm_field_qualify_SrcIp6, (int (*)(void)) bcm_field_qualify_SrcIp6_get, 0, 0}, {bcmFieldQualifyDstIp6, (int (*)(void)) bcm_field_qualify_DstIp6, (int (*)(void)) bcm_field_qualify_DstIp6_get, 0, 0}, {bcmFieldQualifySrcIp6High, (int (*)(void)) bcm_field_qualify_SrcIp6High, (int (*)(void)) bcm_field_qualify_SrcIp6High_get, 0, 0}, {bcmFieldQualifyDstIp6High, (int (*)(void)) bcm_field_qualify_DstIp6High, (int (*)(void)) bcm_field_qualify_DstIp6High_get, 0, 0}, {bcmFieldQualifySrcIp6Low, (int (*)(void)) bcm_field_qualify_SrcIp6Low, (int (*)(void)) bcm_field_qualify_SrcIp6Low_get, 0, 0}, {bcmFieldQualifyDstIp6Low, (int (*)(void)) bcm_field_qualify_DstIp6Low, (int (*)(void)) bcm_field_qualify_DstIp6Low_get, 0, 0}, {bcmFieldQualifySrcMac, (int (*)(void)) bcm_field_qualify_SrcMac, (int (*)(void)) bcm_field_qualify_SrcMac_get, 0, 1}, {bcmFieldQualifyDstMac, (int (*)(void)) bcm_field_qualify_DstMac, (int (*)(void)) bcm_field_qualify_DstMac_get, 0, 1}, {bcmFieldQualifySnap, (int (*)(void)) bcm_field_qualify_Snap, (int (*)(void)) bcm_field_qualify_Snap_get, 0, 2}, {bcmFieldQualifySrcIp, (int (*)(void)) bcm_field_qualify_SrcIp, (int (*)(void)) bcm_field_qualify_SrcIp_get, 0, 3}, {bcmFieldQualifyDstIp, (int (*)(void)) bcm_field_qualify_DstIp, (int (*)(void)) bcm_field_qualify_DstIp_get, 0, 3}, {bcmFieldQualifyLlc, (int (*)(void)) bcm_field_qualify_Llc, (int (*)(void)) bcm_field_qualify_Llc_get, 0, 4}, {bcmFieldQualifyInPort, (int (*)(void)) bcm_field_qualify_InPort, (int (*)(void)) bcm_field_qualify_InPort_get, 0, 5}, {bcmFieldQualifyInPorts, (int (*)(void)) bcm_field_qualify_InPorts, (int (*)(void)) bcm_field_qualify_InPorts_get, 0, 6}, {bcmFieldQualifyOutPorts, (int (*)(void)) bcm_field_qualify_OutPorts, (int (*)(void)) bcm_field_qualify_OutPorts_get, 0, 6}, {bcmFieldQualifyDrop, (int (*)(void)) bcm_field_qualify_Drop, (int (*)(void)) bcm_field_qualify_Drop_get, 0, 7}, {bcmFieldQualifyIp6FlowLabel, (int (*)(void)) bcm_field_qualify_Ip6FlowLabel, (int (*)(void)) bcm_field_qualify_Ip6FlowLabel_get, 0, 8}, {bcmFieldQualifyOuterVlan, (int (*)(void)) bcm_field_qualify_OuterVlan, (int (*)(void)) bcm_field_qualify_OuterVlan_get, 0, 9}, {bcmFieldQualifyOuterVlanId, (int (*)(void)) bcm_field_qualify_OuterVlanId, (int (*)(void)) bcm_field_qualify_OuterVlanId_get, 0, 9}, {bcmFieldQualifyOuterVlanPri, (int (*)(void)) bcm_field_qualify_OuterVlanPri, (int (*)(void)) bcm_field_qualify_OuterVlanPri_get, 0, 7}, {bcmFieldQualifyOuterVlanCfi, (int (*)(void)) bcm_field_qualify_OuterVlanCfi, (int (*)(void)) bcm_field_qualify_OuterVlanCfi_get, 0, 7}, {bcmFieldQualifyOuterVlanPriCfi, (int (*)(void)) bcm_field_qualify_OuterVlanPriCfi, (int (*)(void)) bcm_field_qualify_OuterVlanPriCfi_get, 0, 7}, {bcmFieldQualifyInnerVlan, (int (*)(void)) bcm_field_qualify_InnerVlan, (int (*)(void)) bcm_field_qualify_InnerVlan_get, 0, 9}, {bcmFieldQualifyInnerVlanId, (int (*)(void)) bcm_field_qualify_InnerVlanId, (int (*)(void)) bcm_field_qualify_InnerVlanId_get, 0, 9}, {bcmFieldQualifyInnerVlanPri, (int (*)(void)) bcm_field_qualify_InnerVlanPri, (int (*)(void)) bcm_field_qualify_InnerVlanPri_get, 0, 7}, {bcmFieldQualifyInnerVlanCfi, (int (*)(void)) bcm_field_qualify_InnerVlanCfi, (int (*)(void)) bcm_field_qualify_InnerVlanCfi_get, 0, 7}, {bcmFieldQualifyLookupStatus, NULL, NULL, 0, -1}, {bcmFieldQualifyRangeCheck, NULL, NULL, 0, 10}, {bcmFieldQualifyL4PortRangeCheck, NULL, NULL, 0, 10}, {bcmFieldQualifyL4SrcPort, (int (*)(void)) bcm_field_qualify_L4SrcPort, (int (*)(void)) bcm_field_qualify_L4SrcPort_get, 0, 11}, {bcmFieldQualifyL4DstPort, (int (*)(void)) bcm_field_qualify_L4DstPort, (int (*)(void)) bcm_field_qualify_L4DstPort_get, 0, 11}, {bcmFieldQualifyEtherType, (int (*)(void)) bcm_field_qualify_EtherType, (int (*)(void)) bcm_field_qualify_EtherType_get, 0, 12}, {bcmFieldQualifyIpProtocol, (int (*)(void)) bcm_field_qualify_IpProtocol, (int (*)(void)) bcm_field_qualify_IpProtocol_get, 0, 7}, {bcmFieldQualifyIp6NextHeader, (int (*)(void)) bcm_field_qualify_Ip6NextHeader, (int (*)(void)) bcm_field_qualify_Ip6NextHeader_get, 0, 7}, {bcmFieldQualifyDSCP, (int (*)(void)) bcm_field_qualify_DSCP, (int (*)(void)) bcm_field_qualify_DSCP_get, 0, 7}, {bcmFieldQualifyTos, (int (*)(void)) bcm_field_qualify_Tos, (int (*)(void)) bcm_field_qualify_Tos_get, 0, 7}, {bcmFieldQualifyIp6TrafficClass, (int (*)(void)) bcm_field_qualify_Ip6TrafficClass, (int (*)(void)) bcm_field_qualify_Ip6TrafficClass_get, 0, 7}, {bcmFieldQualifyTtl, (int (*)(void)) bcm_field_qualify_Ttl, (int (*)(void)) bcm_field_qualify_Ttl_get, 0, 7}, {bcmFieldQualifyIp6HopLimit, (int (*)(void)) bcm_field_qualify_Ip6HopLimit, (int (*)(void)) bcm_field_qualify_Ip6HopLimit_get, 0, 7}, {bcmFieldQualifySrcModid, NULL, NULL, 0, -1}, {bcmFieldQualifySrcPortTgid, NULL, NULL, 0, -1}, {bcmFieldQualifySrcPort, (int (*)(void)) bcm_field_qualify_SrcPort, (int (*)(void)) bcm_field_qualify_SrcPort_get, 0, 13}, {bcmFieldQualifySrcTrunk, (int (*)(void)) bcm_field_qualify_SrcTrunk, (int (*)(void)) bcm_field_qualify_SrcTrunk_get, 0, 14}, {bcmFieldQualifyDstModid, NULL, NULL, 0, -1}, {bcmFieldQualifyDstPortTgid, NULL, NULL, 0, -1}, {bcmFieldQualifyDstPort, (int (*)(void)) bcm_field_qualify_DstPort, (int (*)(void)) bcm_field_qualify_DstPort_get, 0, 13}, {bcmFieldQualifyDstTrunk, (int (*)(void)) bcm_field_qualify_DstTrunk, (int (*)(void)) bcm_field_qualify_DstTrunk_get, 0, 14}, {bcmFieldQualifyTcpControl, (int (*)(void)) bcm_field_qualify_TcpControl, (int (*)(void)) bcm_field_qualify_TcpControl_get, 0, 7}, {bcmFieldQualifyPacketRes, (int (*)(void)) bcm_field_qualify_PacketRes, (int (*)(void)) bcm_field_qualify_PacketRes_get, 0, 8}, {bcmFieldQualifyPacketFormat, NULL, NULL, 0, -1}, {bcmFieldQualifySrcClassL2, (int (*)(void)) bcm_field_qualify_SrcClassL2, (int (*)(void)) bcm_field_qualify_SrcClassL2_get, 0, 8}, {bcmFieldQualifySrcClassL3, (int (*)(void)) bcm_field_qualify_SrcClassL3, (int (*)(void)) bcm_field_qualify_SrcClassL3_get, 0, 8}, {bcmFieldQualifySrcClassField, (int (*)(void)) bcm_field_qualify_SrcClassField, (int (*)(void)) bcm_field_qualify_SrcClassField_get, 0, 8}, {bcmFieldQualifyDstClassL2, (int (*)(void)) bcm_field_qualify_DstClassL2, (int (*)(void)) bcm_field_qualify_DstClassL2_get, 0, 8}, {bcmFieldQualifyDstClassL3, (int (*)(void)) bcm_field_qualify_DstClassL3, (int (*)(void)) bcm_field_qualify_DstClassL3_get, 0, 8}, {bcmFieldQualifyDstClassField, (int (*)(void)) bcm_field_qualify_DstClassField, (int (*)(void)) bcm_field_qualify_DstClassField_get, 0, 8}, {bcmFieldQualifyIpInfo, (int (*)(void)) bcm_field_qualify_IpInfo, (int (*)(void)) bcm_field_qualify_IpInfo_get, 0, 8}, {bcmFieldQualifyIpProtocolCommon, (int (*)(void)) bcm_field_qualify_IpProtocolCommon, (int (*)(void)) bcm_field_qualify_IpProtocolCommon_get, 0, 15}, {bcmFieldQualifyMHOpcode, (int (*)(void)) bcm_field_qualify_MHOpcode, (int (*)(void)) bcm_field_qualify_MHOpcode_get, 0, 7}, {bcmFieldQualifyIpFlags, (int (*)(void)) bcm_field_qualify_IpFlags, (int (*)(void)) bcm_field_qualify_IpFlags_get, 0, 7}, {bcmFieldQualifyInnerTpid, (int (*)(void)) bcm_field_qualify_InnerTpid, (int (*)(void)) bcm_field_qualify_InnerTpid_get, 0, 16}, {bcmFieldQualifyOuterTpid, (int (*)(void)) bcm_field_qualify_OuterTpid, (int (*)(void)) bcm_field_qualify_OuterTpid_get, 0, 16}, {bcmFieldQualifyInnerIpType, (int (*)(void)) bcm_field_qualify_InnerIpType, (int (*)(void)) bcm_field_qualify_InnerIpType_get, 0, 17}, {bcmFieldQualifyTunnelType, (int (*)(void)) bcm_field_qualify_TunnelType, (int (*)(void)) bcm_field_qualify_TunnelType_get, 0, 18}, {bcmFieldQualifyLoopbackType, (int (*)(void)) bcm_field_qualify_LoopbackType, (int (*)(void)) bcm_field_qualify_LoopbackType_get, 0, 19}, {bcmFieldQualifyLoopback, (int (*)(void)) bcm_field_qualify_Loopback, (int (*)(void)) bcm_field_qualify_Loopback_get, 0, 7}, {bcmFieldQualifyIpType, (int (*)(void)) bcm_field_qualify_IpType, (int (*)(void)) bcm_field_qualify_IpType_get, 0, 17}, {bcmFieldQualifyForwardingType, (int (*)(void)) bcm_field_qualify_ForwardingType, (int (*)(void)) bcm_field_qualify_ForwardingType_get, 0, 20}, {bcmFieldQualifyDecap, NULL, NULL, 0, -1}, {bcmFieldQualifyHiGig, (int (*)(void)) bcm_field_qualify_HiGig, (int (*)(void)) bcm_field_qualify_HiGig_get, 0, 7}, {bcmFieldQualifyHiGigProxy, NULL, NULL, 0, -1}, {bcmFieldQualifyDstHiGig, (int (*)(void)) bcm_field_qualify_DstHiGig, (int (*)(void)) bcm_field_qualify_DstHiGig_get, 0, 7}, {bcmFieldQualifyStage, (int (*)(void)) bcm_field_qualify_Stage, (int (*)(void)) bcm_field_qualify_Stage_get, 0, 21}, {bcmFieldQualifyStageIngress, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressSecurity, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressQoS, NULL, NULL, 0, -1}, {bcmFieldQualifyStageLookup, NULL, NULL, 0, -1}, {bcmFieldQualifyStageEgress, NULL, NULL, 0, -1}, {bcmFieldQualifyStageEgressSecurity, NULL, NULL, 0, -1}, {bcmFieldQualifyStageExternal, NULL, NULL, 0, -1}, {bcmFieldQualifyTcpSequenceZero, (int (*)(void)) bcm_field_qualify_TcpSequenceZero, (int (*)(void)) bcm_field_qualify_TcpSequenceZero_get, 0, 22}, {bcmFieldQualifyTcpHeaderSize, (int (*)(void)) bcm_field_qualify_TcpHeaderSize, (int (*)(void)) bcm_field_qualify_TcpHeaderSize_get, 0, 7}, {bcmFieldQualifyInterfaceClassL2, (int (*)(void)) bcm_field_qualify_InterfaceClassL2, (int (*)(void)) bcm_field_qualify_InterfaceClassL2_get, 0, 8}, {bcmFieldQualifyInterfaceClassL3, (int (*)(void)) bcm_field_qualify_InterfaceClassL3, (int (*)(void)) bcm_field_qualify_InterfaceClassL3_get, 0, 8}, {bcmFieldQualifyInterfaceClassPort, (int (*)(void)) bcm_field_qualify_InterfaceClassPort, (int (*)(void)) bcm_field_qualify_InterfaceClassPort_get, 0, 8}, {bcmFieldQualifyL3Routable, (int (*)(void)) bcm_field_qualify_L3Routable, (int (*)(void)) bcm_field_qualify_L3Routable_get, 0, 7}, {bcmFieldQualifyIpFrag, (int (*)(void)) bcm_field_qualify_IpFrag, (int (*)(void)) bcm_field_qualify_IpFrag_get, 0, 23}, {bcmFieldQualifyVrf, (int (*)(void)) bcm_field_qualify_Vrf, (int (*)(void)) bcm_field_qualify_Vrf_get, 0, 8}, {bcmFieldQualifyL3Ingress, (int (*)(void)) bcm_field_qualify_L3Ingress, (int (*)(void)) bcm_field_qualify_L3Ingress_get, 0, 8}, {bcmFieldQualifyOutPort, (int (*)(void)) bcm_field_qualify_OutPort, (int (*)(void)) bcm_field_qualify_OutPort_get, 0, 5}, {bcmFieldQualifyIp4, NULL, NULL, 0, -1}, {bcmFieldQualifyIp6, NULL, NULL, 0, -1}, {bcmFieldQualifyL2Format, (int (*)(void)) bcm_field_qualify_L2Format, (int (*)(void)) bcm_field_qualify_L2Format_get, 0, 24}, {bcmFieldQualifyVlanFormat, (int (*)(void)) bcm_field_qualify_VlanFormat, (int (*)(void)) bcm_field_qualify_VlanFormat_get, 0, 7}, {bcmFieldQualifyTranslatedVlanFormat, (int (*)(void)) bcm_field_qualify_TranslatedVlanFormat, (int (*)(void)) bcm_field_qualify_TranslatedVlanFormat_get, 0, 7}, {bcmFieldQualifyExtensionHeaderType, (int (*)(void)) bcm_field_qualify_ExtensionHeaderType, (int (*)(void)) bcm_field_qualify_ExtensionHeaderType_get, 0, 7}, {bcmFieldQualifyExtensionHeaderSubCode, (int (*)(void)) bcm_field_qualify_ExtensionHeaderSubCode, (int (*)(void)) bcm_field_qualify_ExtensionHeaderSubCode_get, 0, 7}, {bcmFieldQualifyExtensionHeader2Type, (int (*)(void)) bcm_field_qualify_ExtensionHeader2Type, (int (*)(void)) bcm_field_qualify_ExtensionHeader2Type_get, 0, 7}, {bcmFieldQualifyL4Ports, (int (*)(void)) bcm_field_qualify_L4Ports, (int (*)(void)) bcm_field_qualify_L4Ports_get, 0, 7}, {bcmFieldQualifyMirrorCopy, (int (*)(void)) bcm_field_qualify_MirrorCopy, (int (*)(void)) bcm_field_qualify_MirrorCopy_get, 0, 7}, {bcmFieldQualifyTunnelTerminated, (int (*)(void)) bcm_field_qualify_TunnelTerminated, (int (*)(void)) bcm_field_qualify_TunnelTerminated_get, 0, 7}, {bcmFieldQualifyMplsTerminated, (int (*)(void)) bcm_field_qualify_MplsTerminated, (int (*)(void)) bcm_field_qualify_MplsTerminated_get, 0, 7}, {bcmFieldQualifyInnerSrcIp, (int (*)(void)) bcm_field_qualify_InnerSrcIp, (int (*)(void)) bcm_field_qualify_InnerSrcIp_get, 0, 3}, {bcmFieldQualifyInnerDstIp, (int (*)(void)) bcm_field_qualify_InnerDstIp, (int (*)(void)) bcm_field_qualify_InnerDstIp_get, 0, 3}, {bcmFieldQualifyInnerSrcIp6, (int (*)(void)) bcm_field_qualify_InnerSrcIp6, (int (*)(void)) bcm_field_qualify_InnerSrcIp6_get, 0, 0}, {bcmFieldQualifyInnerDstIp6, (int (*)(void)) bcm_field_qualify_InnerDstIp6, (int (*)(void)) bcm_field_qualify_InnerDstIp6_get, 0, 0}, {bcmFieldQualifyInnerSrcIp6High, (int (*)(void)) bcm_field_qualify_InnerSrcIp6High, (int (*)(void)) bcm_field_qualify_InnerSrcIp6High_get, 0, 0}, {bcmFieldQualifyInnerDstIp6High, (int (*)(void)) bcm_field_qualify_InnerDstIp6High, (int (*)(void)) bcm_field_qualify_InnerDstIp6High_get, 0, 0}, {bcmFieldQualifyInnerTtl, (int (*)(void)) bcm_field_qualify_InnerTtl, (int (*)(void)) bcm_field_qualify_InnerTtl_get, 0, 7}, {bcmFieldQualifyInnerIp6HopLimit, NULL, NULL, 0, 7}, {bcmFieldQualifyInnerTos, (int (*)(void)) bcm_field_qualify_InnerTos, (int (*)(void)) bcm_field_qualify_InnerTos_get, 0, 7}, {bcmFieldQualifyInnerDSCP, (int (*)(void)) bcm_field_qualify_InnerDSCP, (int (*)(void)) bcm_field_qualify_InnerDSCP_get, 0, 7}, {bcmFieldQualifyInnerIp6TrafficClass, NULL, NULL, 0, -1}, {bcmFieldQualifyInnerIpProtocol, (int (*)(void)) bcm_field_qualify_InnerIpProtocol, (int (*)(void)) bcm_field_qualify_InnerIpProtocol_get, 0, 7}, {bcmFieldQualifyInnerIp6NextHeader, NULL, NULL, 0, 7}, {bcmFieldQualifyInnerIpFrag, (int (*)(void)) bcm_field_qualify_InnerIpFrag, (int (*)(void)) bcm_field_qualify_InnerIpFrag_get, 0, 23}, {bcmFieldQualifyVlanTranslationHit, (int (*)(void)) bcm_field_qualify_VlanTranslationHit, (int (*)(void)) bcm_field_qualify_VlanTranslationHit_get, 0, 7}, {bcmFieldQualifyForwardingVlanValid, (int (*)(void)) bcm_field_qualify_ForwardingVlanValid, (int (*)(void)) bcm_field_qualify_ForwardingVlanValid_get, 0, 7}, {bcmFieldQualifyIngressStpState, (int (*)(void)) bcm_field_qualify_IngressStpState, (int (*)(void)) bcm_field_qualify_IngressStpState_get, 0, 7}, {bcmFieldQualifyL2SrcHit, (int (*)(void)) bcm_field_qualify_L2SrcHit, (int (*)(void)) bcm_field_qualify_L2SrcHit_get, 0, 7}, {bcmFieldQualifyL2SrcStatic, (int (*)(void)) bcm_field_qualify_L2SrcStatic, (int (*)(void)) bcm_field_qualify_L2SrcStatic_get, 0, 7}, {bcmFieldQualifyL2DestHit, (int (*)(void)) bcm_field_qualify_L2DestHit, (int (*)(void)) bcm_field_qualify_L2DestHit_get, 0, 7}, {bcmFieldQualifyL2StationMove, (int (*)(void)) bcm_field_qualify_L2StationMove, (int (*)(void)) bcm_field_qualify_L2StationMove_get, 0, 7}, {bcmFieldQualifyL2CacheHit, (int (*)(void)) bcm_field_qualify_L2CacheHit, (int (*)(void)) bcm_field_qualify_L2CacheHit_get, 0, 7}, {bcmFieldQualifyL3SrcHostHit, (int (*)(void)) bcm_field_qualify_L3SrcHostHit, (int (*)(void)) bcm_field_qualify_L3SrcHostHit_get, 0, 7}, {bcmFieldQualifyL3DestHostHit, (int (*)(void)) bcm_field_qualify_L3DestHostHit, (int (*)(void)) bcm_field_qualify_L3DestHostHit_get, 0, 7}, {bcmFieldQualifyL3DestRouteHit, (int (*)(void)) bcm_field_qualify_L3DestRouteHit, (int (*)(void)) bcm_field_qualify_L3DestRouteHit_get, 0, 7}, {bcmFieldQualifyIpmcStarGroupHit, (int (*)(void)) bcm_field_qualify_IpmcStarGroupHit, (int (*)(void)) bcm_field_qualify_IpmcStarGroupHit_get, 0, 7}, {bcmFieldQualifyDosAttack, (int (*)(void)) bcm_field_qualify_DosAttack, (int (*)(void)) bcm_field_qualify_DosAttack_get, 0, 7}, {bcmFieldQualifyClassId, NULL, NULL, 0, -1}, {bcmFieldQualifyIcmpTypeCode, (int (*)(void)) bcm_field_qualify_IcmpTypeCode, (int (*)(void)) bcm_field_qualify_IcmpTypeCode_get, 0, 12}, {bcmFieldQualifyInnerIpProtocolCommon, (int (*)(void)) bcm_field_qualify_InnerIpProtocolCommon, (int (*)(void)) bcm_field_qualify_InnerIpProtocolCommon_get, 0, 15}, {bcmFieldQualifyInnerL4SrcPort, (int (*)(void)) bcm_field_qualify_InnerL4SrcPort, (int (*)(void)) bcm_field_qualify_InnerL4SrcPort_get, 0, 11}, {bcmFieldQualifyInnerL4DstPort, (int (*)(void)) bcm_field_qualify_InnerL4DstPort, (int (*)(void)) bcm_field_qualify_InnerL4DstPort_get, 0, 11}, {bcmFieldQualifyInnerIp6FlowLabel, (int (*)(void)) bcm_field_qualify_InnerIp6FlowLabel, (int (*)(void)) bcm_field_qualify_InnerIp6FlowLabel_get, 0, 8}, {bcmFieldQualifyDstL3Egress, (int (*)(void)) bcm_field_qualify_DstL3Egress, (int (*)(void)) bcm_field_qualify_DstL3Egress_get, 0, 25}, {bcmFieldQualifyDstMulticastGroup, (int (*)(void)) bcm_field_qualify_DstMulticastGroup, (int (*)(void)) bcm_field_qualify_DstMulticastGroup_get, 0, 38}, {bcmFieldQualifySrcMplsGport, (int (*)(void)) bcm_field_qualify_SrcMplsGport, (int (*)(void)) bcm_field_qualify_SrcMplsGport_get, 0, 26}, {bcmFieldQualifyDstMplsGport, (int (*)(void)) bcm_field_qualify_DstMplsGport, (int (*)(void)) bcm_field_qualify_DstMplsGport_get, 0, 26}, {bcmFieldQualifySrcMimGport, (int (*)(void)) bcm_field_qualify_SrcMimGport, (int (*)(void)) bcm_field_qualify_SrcMimGport_get, 0, 26}, {bcmFieldQualifyDstMimGport, (int (*)(void)) bcm_field_qualify_DstMimGport, (int (*)(void)) bcm_field_qualify_DstMimGport_get, 0, 26}, {bcmFieldQualifySrcWlanGport, (int (*)(void)) bcm_field_qualify_SrcWlanGport, (int (*)(void)) bcm_field_qualify_SrcWlanGport_get, 0, 26}, {bcmFieldQualifyDstWlanGport, (int (*)(void)) bcm_field_qualify_DstWlanGport, (int (*)(void)) bcm_field_qualify_DstWlanGport_get, 0, 26}, {bcmFieldQualifySrcModPortGport, (int (*)(void)) bcm_field_qualify_SrcModPortGport, (int (*)(void)) bcm_field_qualify_SrcModPortGport_get, 0, 26}, {bcmFieldQualifySrcModuleGport, (int (*)(void)) bcm_field_qualify_SrcModuleGport, (int (*)(void)) bcm_field_qualify_SrcModuleGport_get, 0, 26}, {bcmFieldQualifyColor, (int (*)(void)) bcm_field_qualify_Color, (int (*)(void)) bcm_field_qualify_Color_get, 0, 27}, {bcmFieldQualifyIntPriority, (int (*)(void)) bcm_field_qualify_IntPriority, (int (*)(void)) bcm_field_qualify_IntPriority_get, 0, 7}, {bcmFieldQualifyForwardingVlanId, (int (*)(void)) bcm_field_qualify_ForwardingVlanId, (int (*)(void)) bcm_field_qualify_ForwardingVlanId_get, 0, 9}, {bcmFieldQualifyVpn, (int (*)(void)) bcm_field_qualify_Vpn, (int (*)(void)) bcm_field_qualify_Vpn_get, 0, 28}, {bcmFieldQualifyFlowId, (int (*)(void)) bcm_field_qualify_FlowId, (int (*)(void)) bcm_field_qualify_FlowId_get, 0, 12}, {bcmFieldQualifyInVPort, (int (*)(void)) bcm_field_qualify_InVPort32, (int (*)(void)) bcm_field_qualify_InVPort32_get, 0, 8}, {bcmFieldQualifyOutVPort, (int (*)(void)) bcm_field_qualify_OutVPort32, (int (*)(void)) bcm_field_qualify_OutVPort32_get, 0, 8}, {bcmFieldQualifyFibreChanOuter, (int (*)(void)) bcm_field_qualify_FibreChanOuter, (int (*)(void)) bcm_field_qualify_FibreChanOuter_get, 0, 29}, {bcmFieldQualifyFibreChanInner, (int (*)(void)) bcm_field_qualify_FibreChanInner, (int (*)(void)) bcm_field_qualify_FibreChanInner_get, 0, 29}, {bcmFieldQualifyVnTag, (int (*)(void)) bcm_field_qualify_VnTag, (int (*)(void)) bcm_field_qualify_VnTag_get, 0, 8}, {bcmFieldQualifyCnTag, (int (*)(void)) bcm_field_qualify_CnTag, (int (*)(void)) bcm_field_qualify_CnTag_get, 0, 8}, {bcmFieldQualifyFabricQueueTag, (int (*)(void)) bcm_field_qualify_FabricQueueTag, (int (*)(void)) bcm_field_qualify_FabricQueueTag_get, 0, 8}, {bcmFieldQualifyMyStationHit, NULL, NULL, 0, 7}, {bcmFieldQualifyDstMultipath, NULL, NULL, 0, 25}, {bcmFieldQualifyL2PayloadFirstEightBytes, NULL, NULL, 0, 30}, {bcmFieldQualifySrcVirtualPortValid, NULL, NULL, 0, 7}, {bcmFieldQualifyDstL3EgressNextHops, NULL, NULL, 0, 8}, {bcmFieldQualifyRecoverableDrop, NULL, NULL, 0, 7}, {bcmFieldQualifyRepCopy, NULL, NULL, 0, 7}, {bcmFieldQualifyIpTunnelHit, (int (*)(void)) bcm_field_qualify_IpTunnelHit, (int (*)(void)) bcm_field_qualify_IpTunnelHit_get, 0, 7}, {bcmFieldQualifyMplsLabel1Hit, NULL, NULL, 0, 7}, {bcmFieldQualifyTrillEgressRbridgeHit, NULL, NULL, 0, 7}, {bcmFieldQualifyL2GreSrcIpHit, NULL, NULL, 0, 7}, {bcmFieldQualifyMimSrcGportHit, NULL, NULL, 0, 7}, {bcmFieldQualifyMplsLabel2Hit, NULL, NULL, 0, 7}, {bcmFieldQualifyTrillIngressRbridgeHit, NULL, NULL, 0, 7}, {bcmFieldQualifyL2GreVfiHit, NULL, NULL, 0, 7}, {bcmFieldQualifyMimVfiHit, NULL, NULL, 0, 7}, {bcmFieldQualifyGenericAssociatedChannelLabelValid, NULL, NULL, 0, 7}, {bcmFieldQualifyRouterAlertLabelValid, NULL, NULL, 0, 7}, {bcmFieldQualifyDstIpLocal, NULL, NULL, 0, 7}, {bcmFieldQualifyNormalizeIpAddrs, NULL, NULL, 0, -1}, {bcmFieldQualifyNormalizeMacAddrs, NULL, NULL, 0, -1}, {bcmFieldQualifyIpAddrsNormalized, NULL, NULL, 0, 7}, {bcmFieldQualifyMacAddrsNormalized, NULL, NULL, 0, 7}, {bcmFieldQualifyMplsForwardingLabel, (int (*)(void)) bcm_field_qualify_MplsForwardingLabel, (int (*)(void)) bcm_field_qualify_MplsForwardingLabel_get, 0, 8}, {bcmFieldQualifyMplsForwardingLabelTtl, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelTtl, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelTtl_get, 0, 7}, {bcmFieldQualifyMplsForwardingLabelBos, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelBos, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelBos_get, 0, 7}, {bcmFieldQualifyMplsForwardingLabelExp, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelExp, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelExp_get, 0, 7}, {bcmFieldQualifyMplsForwardingLabelId, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelId, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelId_get, 0, 8}, {bcmFieldQualifyMplsControlWord, NULL, NULL, 0, 8}, {bcmFieldQualifyRtag7AHashUpper, NULL, NULL, 0, 12}, {bcmFieldQualifyRtag7AHashLower, NULL, NULL, 0, 12}, {bcmFieldQualifyRtag7BHashUpper, NULL, NULL, 0, 12}, {bcmFieldQualifyRtag7BHashLower, NULL, NULL, 0, 12}, {bcmFieldQualifyMplsForwardingLabelAction, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelAction32, (int (*)(void)) bcm_field_qualify_MplsForwardingLabelAction32_get, 0, 8}, {bcmFieldQualifyMplsControlWordValid, NULL, NULL, 0, 7}, {bcmFieldQualifyEgressClass, NULL, NULL, 0, 12}, {bcmFieldQualifyEgressClassL3Interface, NULL, NULL, 0, 12}, {bcmFieldQualifyEgressClassTrill, NULL, NULL, 0, 12}, {bcmFieldQualifyEgressClassWlan, NULL, NULL, 0, 12}, {bcmFieldQualifyEgressClassL2Gre, NULL, NULL, 0, 12}, {bcmFieldQualifyLlidValue, NULL, NULL, 0, 12}, {bcmFieldQualifyCpuQueue, NULL, NULL, 0, 7}, {bcmFieldQualifyMpls, NULL, NULL, 0, -1}, {bcmFieldQualifySrcGport, (int (*)(void)) bcm_field_qualify_SrcGport, (int (*)(void)) bcm_field_qualify_SrcGport_get, 0, 26}, {bcmFieldQualifyHeaderFormat, (int (*)(void)) bcm_field_qualify_HeaderFormat, (int (*)(void)) bcm_field_qualify_HeaderFormat_get, 0, 31}, {bcmFieldQualifyHeaderFormatSet, (int (*)(void)) bcm_field_qualify_HeaderFormatSet, (int (*)(void)) bcm_field_qualify_HeaderFormatSet_get, 0, 32}, {bcmFieldQualifyL2Learn, (int (*)(void)) bcm_field_qualify_L2Learn, (int (*)(void)) bcm_field_qualify_L2Learn_get, 0, 7}, {bcmFieldQualifyPortOrientation, (int (*)(void)) bcm_field_qualify_PortOrientation, (int (*)(void)) bcm_field_qualify_PortOrientation_get, 0, 7}, {bcmFieldQualifyEcnValue, (int (*)(void)) bcm_field_qualify_EcnValue, (int (*)(void)) bcm_field_qualify_EcnValue_get, 0, 7}, {bcmFieldQualifyRxTrapCode, (int (*)(void)) bcm_field_qualify_RxTrapCode, (int (*)(void)) bcm_field_qualify_RxTrapCode_get, 0, 33}, {bcmFieldQualifyPtch, (int (*)(void)) bcm_field_qualify_Ptch, (int (*)(void)) bcm_field_qualify_Ptch_get, 0, 7}, {bcmFieldQualifyMplsBos, (int (*)(void)) bcm_field_qualify_MplsBos, (int (*)(void)) bcm_field_qualify_MplsBos_get, 0, 7}, {bcmFieldQualifyRxTrapData, (int (*)(void)) bcm_field_qualify_RxTrapData, (int (*)(void)) bcm_field_qualify_RxTrapData_get, 0, 8}, {bcmFieldQualifyPolicerIntPrio, (int (*)(void)) bcm_field_qualify_PolicerIntPrio, (int (*)(void)) bcm_field_qualify_PolicerIntPrio_get, 0, 7}, {bcmFieldQualifyPacketTerminatedBytes, (int (*)(void)) bcm_field_qualify_PacketTerminatedBytes, (int (*)(void)) bcm_field_qualify_PacketTerminatedBytes_get, 0, 8}, {bcmFieldQualifyBypassFilter, (int (*)(void)) bcm_field_qualify_BypassFilter, (int (*)(void)) bcm_field_qualify_BypassFilter_get, 0, 7}, {bcmFieldQualifyReplicantAny, (int (*)(void)) bcm_field_qualify_ReplicantAny, (int (*)(void)) bcm_field_qualify_ReplicantAny_get, 0, 7}, {bcmFieldQualifyReplicantFirst, (int (*)(void)) bcm_field_qualify_ReplicantFirst, (int (*)(void)) bcm_field_qualify_ReplicantFirst_get, 0, 7}, {bcmFieldQualifyTrillEgressRbridge, (int (*)(void)) bcm_field_qualify_TrillEgressRbridge, (int (*)(void)) bcm_field_qualify_TrillEgressRbridge_get, 0, 8}, {bcmFieldQualifyISid, (int (*)(void)) bcm_field_qualify_ISid, (int (*)(void)) bcm_field_qualify_ISid_get, 0, 8}, {bcmFieldQualifyInterfaceClassProcessingPort, (int (*)(void)) bcm_field_qualify_InterfaceClassProcessingPort, (int (*)(void)) bcm_field_qualify_InterfaceClassProcessingPort_get, 0, 34}, {bcmFieldQualifyDstRpfGport, (int (*)(void)) bcm_field_qualify_DstRpfGport, (int (*)(void)) bcm_field_qualify_DstRpfGport_get, 0, 26}, {bcmFieldQualifyTrunkHashResult, (int (*)(void)) bcm_field_qualify_TrunkHashResult, (int (*)(void)) bcm_field_qualify_TrunkHashResult_get, 0, 8}, {bcmFieldQualifyDhcp, (int (*)(void)) bcm_field_qualify_Dhcp, (int (*)(void)) bcm_field_qualify_Dhcp_get, 0, 7}, {bcmFieldQualifySnoopCopy, (int (*)(void)) bcm_field_qualify_SnoopCopy, (int (*)(void)) bcm_field_qualify_SnoopCopy_get, 0, 7}, {bcmFieldQualifyForwardCopy, (int (*)(void)) bcm_field_qualify_ForwardCopy, (int (*)(void)) bcm_field_qualify_ForwardCopy_get, 0, 7}, {bcmFieldQualifyInterfaceClassVPort, (int (*)(void)) bcm_field_qualify_InterfaceClassVPort, (int (*)(void)) bcm_field_qualify_InterfaceClassVPort_get, 0, 8}, {bcmFieldQualifyVPortRangeCheck, NULL, NULL, 0, 10}, {bcmFieldQualifyPacketLengthRangeCheck, NULL, NULL, 0, 10}, {bcmFieldQualifyStageIngressVlanTranslation, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressTunnelTerminated, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressMplsTerminated, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressIpTunnel, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressL2Src, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressL2Dest, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressL3SrcRoute, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressL3DestRoute, NULL, NULL, 0, -1}, {bcmFieldQualifyStageIngressIpmc, NULL, NULL, 0, -1}, {bcmFieldQualifyTunnelTerminatedHit, NULL, NULL, 0, 7}, {bcmFieldQualifyMplsTerminatedHit, NULL, NULL, 0, 7}, {bcmFieldQualifyL3SrcRouteHit, (int (*)(void)) bcm_field_qualify_L3SrcRouteHit, (int (*)(void)) bcm_field_qualify_L3SrcRouteHit_get, 0, 7}, {bcmFieldQualifyIpmcHit, (int (*)(void)) bcm_field_qualify_IpmcHit, (int (*)(void)) bcm_field_qualify_IpmcHit_get, 0, 7}, {bcmFieldQualifyVlanTranslationValue, (int (*)(void)) bcm_field_qualify_VlanTranslationValue, (int (*)(void)) bcm_field_qualify_VlanTranslationValue_get, 0, 34}, {bcmFieldQualifyTunnelTerminatedValue, (int (*)(void)) bcm_field_qualify_TunnelTerminatedValue, (int (*)(void)) bcm_field_qualify_TunnelTerminatedValue_get, 0, 34}, {bcmFieldQualifyMplsTerminatedValue, (int (*)(void)) bcm_field_qualify_MplsTerminatedValue, (int (*)(void)) bcm_field_qualify_MplsTerminatedValue_get, 0, 34}, {bcmFieldQualifyIpTunnelValue, (int (*)(void)) bcm_field_qualify_IpTunnelValue, (int (*)(void)) bcm_field_qualify_IpTunnelValue_get, 0, 34}, {bcmFieldQualifyL2SrcValue, (int (*)(void)) bcm_field_qualify_L2SrcValue, (int (*)(void)) bcm_field_qualify_L2SrcValue_get, 0, 34}, {bcmFieldQualifyL2DestValue, (int (*)(void)) bcm_field_qualify_L2DestValue, (int (*)(void)) bcm_field_qualify_L2DestValue_get, 0, 34}, {bcmFieldQualifyL3SrcRouteValue, (int (*)(void)) bcm_field_qualify_L3SrcRouteValue, (int (*)(void)) bcm_field_qualify_L3SrcRouteValue_get, 0, 34}, {bcmFieldQualifyL3DestRouteValue, (int (*)(void)) bcm_field_qualify_L3DestRouteValue, (int (*)(void)) bcm_field_qualify_L3DestRouteValue_get, 0, 34}, {bcmFieldQualifyIpmcValue, (int (*)(void)) bcm_field_qualify_IpmcValue, (int (*)(void)) bcm_field_qualify_IpmcValue_get, 0, 34}, {bcmFieldQualifyLearnSrcMac, (int (*)(void)) bcm_field_qualify_LearnSrcMac, (int (*)(void)) bcm_field_qualify_LearnSrcMac_get, 0, 1}, {bcmFieldQualifyLearnVlan, (int (*)(void)) bcm_field_qualify_LearnVlan, (int (*)(void)) bcm_field_qualify_LearnVlan_get, 0, 9}, {bcmFieldQualifyLearnSrcPort, (int (*)(void)) bcm_field_qualify_LearnSrcPort, (int (*)(void)) bcm_field_qualify_LearnSrcPort_get, 0, 26}, {bcmFieldQualifyPacketSize, (int (*)(void)) bcm_field_qualify_PacketSize, (int (*)(void)) bcm_field_qualify_PacketSize_get, 0, 8}, {bcmFieldQualifyInnerSrcMac, (int (*)(void)) bcm_field_qualify_InnerSrcMac, (int (*)(void)) bcm_field_qualify_InnerSrcMac_get, 0, 1}, {bcmFieldQualifyInnerDstMac, (int (*)(void)) bcm_field_qualify_InnerDstMac, (int (*)(void)) bcm_field_qualify_InnerDstMac_get, 0, 1}, {bcmFieldQualifyInnerEtherType, (int (*)(void)) bcm_field_qualify_InnerEtherType, (int (*)(void)) bcm_field_qualify_InnerEtherType_get, 0, 12}, {bcmFieldQualifyMplsLabel1, (int (*)(void)) bcm_field_qualify_MplsLabel1, (int (*)(void)) bcm_field_qualify_MplsLabel1_get, 0, 8}, {bcmFieldQualifyMplsLabel1Ttl, (int (*)(void)) bcm_field_qualify_MplsLabel1Ttl, (int (*)(void)) bcm_field_qualify_MplsLabel1Ttl_get, 0, 7}, {bcmFieldQualifyMplsLabel1Bos, (int (*)(void)) bcm_field_qualify_MplsLabel1Bos, (int (*)(void)) bcm_field_qualify_MplsLabel1Bos_get, 0, 7}, {bcmFieldQualifyMplsLabel1Exp, (int (*)(void)) bcm_field_qualify_MplsLabel1Exp, (int (*)(void)) bcm_field_qualify_MplsLabel1Exp_get, 0, 7}, {bcmFieldQualifyMplsLabel1Id, (int (*)(void)) bcm_field_qualify_MplsLabel1Id, (int (*)(void)) bcm_field_qualify_MplsLabel1Id_get, 0, 8}, {bcmFieldQualifyMplsLabel2, (int (*)(void)) bcm_field_qualify_MplsLabel2, (int (*)(void)) bcm_field_qualify_MplsLabel2_get, 0, 8}, {bcmFieldQualifyMplsLabel2Ttl, (int (*)(void)) bcm_field_qualify_MplsLabel2Ttl, (int (*)(void)) bcm_field_qualify_MplsLabel2Ttl_get, 0, 7}, {bcmFieldQualifyMplsLabel2Bos, (int (*)(void)) bcm_field_qualify_MplsLabel2Bos, (int (*)(void)) bcm_field_qualify_MplsLabel2Bos_get, 0, 7}, {bcmFieldQualifyMplsLabel2Exp, (int (*)(void)) bcm_field_qualify_MplsLabel2Exp, (int (*)(void)) bcm_field_qualify_MplsLabel2Exp_get, 0, 7}, {bcmFieldQualifyMplsLabel2Id, (int (*)(void)) bcm_field_qualify_MplsLabel2Id, (int (*)(void)) bcm_field_qualify_MplsLabel2Id_get, 0, 8}, {bcmFieldQualifyMplsLabel3, (int (*)(void)) bcm_field_qualify_MplsLabel3, (int (*)(void)) bcm_field_qualify_MplsLabel3_get, 0, 8}, {bcmFieldQualifyMplsLabel3Ttl, (int (*)(void)) bcm_field_qualify_MplsLabel3Ttl, (int (*)(void)) bcm_field_qualify_MplsLabel3Ttl_get, 0, 7}, {bcmFieldQualifyMplsLabel3Bos, (int (*)(void)) bcm_field_qualify_MplsLabel3Bos, (int (*)(void)) bcm_field_qualify_MplsLabel3Bos_get, 0, 7}, {bcmFieldQualifyMplsLabel3Exp, (int (*)(void)) bcm_field_qualify_MplsLabel3Exp, (int (*)(void)) bcm_field_qualify_MplsLabel3Exp_get, 0, 7}, {bcmFieldQualifyMplsLabel3Id, (int (*)(void)) bcm_field_qualify_MplsLabel3Id, (int (*)(void)) bcm_field_qualify_MplsLabel3Id_get, 0, 8}, {bcmFieldQualifyCascadedKeyValue, (int (*)(void)) bcm_field_qualify_CascadedKeyValue, (int (*)(void)) bcm_field_qualify_CascadedKeyValue_get, 0, 8}, {bcmFieldQualifyMplsOuterLabelPop, NULL, NULL, 0, 7}, {bcmFieldQualifyMplsStationHitTunnelUnterminated, NULL, NULL, 0, 7}, {bcmFieldQualifyIngressClassField, NULL, NULL, 0, 8}, {bcmFieldQualifyIngressInterfaceClassPort, NULL, NULL, 0, 8}, {bcmFieldQualifyExternalValue0, (int (*)(void)) bcm_field_qualify_ExternalValue0, (int (*)(void)) bcm_field_qualify_ExternalValue0_get, 0, 34}, {bcmFieldQualifyExternalValue1, (int (*)(void)) bcm_field_qualify_ExternalValue1, (int (*)(void)) bcm_field_qualify_ExternalValue1_get, 0, 34}, {bcmFieldQualifyExternalValue2, (int (*)(void)) bcm_field_qualify_ExternalValue2, (int (*)(void)) bcm_field_qualify_ExternalValue2_get, 0, 34}, {bcmFieldQualifyExternalValue3, (int (*)(void)) bcm_field_qualify_ExternalValue3, (int (*)(void)) bcm_field_qualify_ExternalValue3_get, 0, 34}, {bcmFieldQualifyExternalValue4, (int (*)(void)) bcm_field_qualify_ExternalValue4, (int (*)(void)) bcm_field_qualify_ExternalValue4_get, 0, 34}, {bcmFieldQualifyExternalValue5, (int (*)(void)) bcm_field_qualify_ExternalValue5, (int (*)(void)) bcm_field_qualify_ExternalValue5_get, 0, 34}, {bcmFieldQualifyExternalValue6, (int (*)(void)) bcm_field_qualify_ExternalValue6, (int (*)(void)) bcm_field_qualify_ExternalValue6_get, 0, 34}, {bcmFieldQualifyExternalValue7, (int (*)(void)) bcm_field_qualify_ExternalValue7, (int (*)(void)) bcm_field_qualify_ExternalValue7_get, 0, 34}, {bcmFieldQualifyExternalHit0, (int (*)(void)) bcm_field_qualify_ExternalHit0, (int (*)(void)) bcm_field_qualify_ExternalHit0_get, 0, 7}, {bcmFieldQualifyExternalHit1, (int (*)(void)) bcm_field_qualify_ExternalHit1, (int (*)(void)) bcm_field_qualify_ExternalHit1_get, 0, 7}, {bcmFieldQualifyExternalHit2, (int (*)(void)) bcm_field_qualify_ExternalHit2, (int (*)(void)) bcm_field_qualify_ExternalHit2_get, 0, 7}, {bcmFieldQualifyExternalHit3, (int (*)(void)) bcm_field_qualify_ExternalHit3, (int (*)(void)) bcm_field_qualify_ExternalHit3_get, 0, 7}, {bcmFieldQualifyExternalHit4, (int (*)(void)) bcm_field_qualify_ExternalHit4, (int (*)(void)) bcm_field_qualify_ExternalHit4_get, 0, 7}, {bcmFieldQualifyExternalHit5, (int (*)(void)) bcm_field_qualify_ExternalHit5, (int (*)(void)) bcm_field_qualify_ExternalHit5_get, 0, 7}, {bcmFieldQualifyExternalHit6, (int (*)(void)) bcm_field_qualify_ExternalHit6, (int (*)(void)) bcm_field_qualify_ExternalHit6_get, 0, 7}, {bcmFieldQualifyExternalHit7, (int (*)(void)) bcm_field_qualify_ExternalHit7, (int (*)(void)) bcm_field_qualify_ExternalHit7_get, 0, 7}, {bcmFieldQualifyVpnUnknownDstMacDstPort, NULL, NULL, 0, 26}, {bcmFieldQualifyVxlanNetworkId, NULL, NULL, 0, 8}, {bcmFieldQualifyVxlanFlags, NULL, NULL, 0, 7}, {bcmFieldQualifyNatNeeded, NULL, NULL, 0, 7}, {bcmFieldQualifyNatDstRealmId, NULL, NULL, 0, 7}, {bcmFieldQualifyNatSrcRealmId, NULL, NULL, 0, 7}, {bcmFieldQualifyIcmpError, NULL, NULL, 0, 7}, {bcmFieldQualifyTunnelId, (int (*)(void)) bcm_field_qualify_TunnelId, (int (*)(void)) bcm_field_qualify_TunnelId_get, 0, 8}, {bcmFieldQualifyArpSenderIp4, (int (*)(void)) bcm_field_qualify_ArpSenderIp4, (int (*)(void)) bcm_field_qualify_ArpSenderIp4_get, 0, 8}, {bcmFieldQualifyArpTargetIp4, (int (*)(void)) bcm_field_qualify_ArpTargetIp4, (int (*)(void)) bcm_field_qualify_ArpTargetIp4_get, 0, 8}, {bcmFieldQualifyArpOpcode, (int (*)(void)) bcm_field_qualify_ArpOpcode, (int (*)(void)) bcm_field_qualify_ArpOpcode_get, 0, 35}, {bcmFieldQualifyTranslatedOuterVlan, (int (*)(void)) bcm_field_qualify_TranslatedOuterVlan, (int (*)(void)) bcm_field_qualify_TranslatedOuterVlan_get, 0, 9}, {bcmFieldQualifyTranslatedOuterVlanId, (int (*)(void)) bcm_field_qualify_TranslatedOuterVlanId, (int (*)(void)) bcm_field_qualify_TranslatedOuterVlanId_get, 0, 9}, {bcmFieldQualifyTranslatedOuterVlanPri, (int (*)(void)) bcm_field_qualify_TranslatedOuterVlanPri, (int (*)(void)) bcm_field_qualify_TranslatedOuterVlanPri_get, 0, 7}, {bcmFieldQualifyTranslatedOuterVlanCfi, (int (*)(void)) bcm_field_qualify_TranslatedOuterVlanCfi, (int (*)(void)) bcm_field_qualify_TranslatedOuterVlanCfi_get, 0, 7}, {bcmFieldQualifyTranslatedInnerVlan, (int (*)(void)) bcm_field_qualify_TranslatedInnerVlan, (int (*)(void)) bcm_field_qualify_TranslatedInnerVlan_get, 0, 9}, {bcmFieldQualifyTranslatedInnerVlanId, (int (*)(void)) bcm_field_qualify_TranslatedInnerVlanId, (int (*)(void)) bcm_field_qualify_TranslatedInnerVlanId_get, 0, 9}, {bcmFieldQualifyTranslatedInnerVlanPri, (int (*)(void)) bcm_field_qualify_TranslatedInnerVlanPri, (int (*)(void)) bcm_field_qualify_TranslatedInnerVlanPri_get, 0, 7}, {bcmFieldQualifyTranslatedInnerVlanCfi, (int (*)(void)) bcm_field_qualify_TranslatedInnerVlanCfi, (int (*)(void)) bcm_field_qualify_TranslatedInnerVlanCfi_get, 0, 7}, {bcmFieldQualifyConstantZero, NULL, NULL, 0, -1}, {bcmFieldQualifyConstantOne, NULL, NULL, 0, -1}, {bcmFieldQualifyForwardingHeaderOffset, (int (*)(void)) bcm_field_qualify_ForwardingHeaderOffset, (int (*)(void)) bcm_field_qualify_ForwardingHeaderOffset_get, 0, 36}, {bcmFieldQualifyL3SrcBind, NULL, NULL, 0, -1}, {bcmFieldQualifyIngressVPortBridgeDisable, (int (*)(void)) bcm_field_qualify_IngressVPortBridgeDisable, (int (*)(void)) bcm_field_qualify_IngressVPortBridgeDisable_get, 0, 7}, {bcmFieldQualifyAppType, (int (*)(void)) bcm_field_qualify_AppType, (int (*)(void)) bcm_field_qualify_AppType_get, 0, 37}, {bcmFieldQualifyMirrorEgressDisabled, (int (*)(void)) bcm_field_qualify_MirrorEgressDisabled, (int (*)(void)) bcm_field_qualify_MirrorEgressDisabled_get, 0, 7}, {bcmFieldQualifyBypassSrcMacFilter, (int (*)(void)) bcm_field_qualify_BypassSrcMacFilter, (int (*)(void)) bcm_field_qualify_BypassSrcMacFilter_get, 0, 7}, {bcmFieldQualifyRxTrapCodeForSnoop, (int (*)(void)) bcm_field_qualify_RxTrapCodeForSnoop, (int (*)(void)) bcm_field_qualify_RxTrapCodeForSnoop_get, 0, 8}, {bcmFieldQualifyNativeVSwitch, (int (*)(void)) bcm_field_qualify_NativeVSwitch, (int (*)(void)) bcm_field_qualify_NativeVSwitch_get, 0, 12}, {bcmFieldQualifyFhei, (int (*)(void)) bcm_field_qualify_Fhei, (int (*)(void)) bcm_field_qualify_Fhei_get, 0, 34}, {bcmFieldQualifyFheiSize, (int (*)(void)) bcm_field_qualify_FheiSize, (int (*)(void)) bcm_field_qualify_FheiSize_get, 0, 8}, {bcmFieldQualifyOuterVlanActionRange, (int (*)(void)) bcm_field_qualify_OuterVlanActionRange, (int (*)(void)) bcm_field_qualify_OuterVlanActionRange_get, 0, 9}, {bcmFieldQualifyInnerVlanActionRange, (int (*)(void)) bcm_field_qualify_InnerVlanActionRange, (int (*)(void)) bcm_field_qualify_InnerVlanActionRange_get, 0, 9}, {bcmFieldQualifyOamInLifIdValid, (int (*)(void)) bcm_field_qualify_OamInLifIdValid, (int (*)(void)) bcm_field_qualify_OamInLifIdValid_get, 0, 7}, {bcmFieldQualifyOamInLifId, (int (*)(void)) bcm_field_qualify_OamInLifId, (int (*)(void)) bcm_field_qualify_OamInLifId_get, 0, 8}, {bcmFieldQualifyOamUpMep, (int (*)(void)) bcm_field_qualify_OamUpMep, (int (*)(void)) bcm_field_qualify_OamUpMep_get, 0, 7}, {bcmFieldQualifyOamSubtype, (int (*)(void)) bcm_field_qualify_OamSubtype, (int (*)(void)) bcm_field_qualify_OamSubtype_get, 0, 7}, {bcmFieldQualifyOamHeaderOffset, (int (*)(void)) bcm_field_qualify_OamHeaderOffset, (int (*)(void)) bcm_field_qualify_OamHeaderOffset_get, 0, 8}, {bcmFieldQualifyOamStampOffset, (int (*)(void)) bcm_field_qualify_OamStampOffset, (int (*)(void)) bcm_field_qualify_OamStampOffset_get, 0, 8}, {bcmFieldQualifyOamMepId, (int (*)(void)) bcm_field_qualify_OamMepId, (int (*)(void)) bcm_field_qualify_OamMepId_get, 0, 8}, {bcmFieldQualifyOamMeterDisable, (int (*)(void)) bcm_field_qualify_OamMeterDisable, (int (*)(void)) bcm_field_qualify_OamMeterDisable_get, 0, 7}, {bcmFieldQualifyOamTsSystemHeader , (int (*)(void)) bcm_field_qualify_OamTsSystemHeader, (int (*)(void)) bcm_field_qualify_OamTsSystemHeader_get, 0, 34}, {bcmFieldQualifyEthernetOamHeaderBits0_31, (int (*)(void)) bcm_field_qualify_EthernetOamHeaderBits0_31, (int (*)(void)) bcm_field_qualify_EthernetOamHeaderBits0_31_get, 0, 8}, {bcmFieldQualifyEthernetOamHeaderBits32_63, (int (*)(void)) bcm_field_qualify_EthernetOamHeaderBits32_63, (int (*)(void)) bcm_field_qualify_EthernetOamHeaderBits32_63_get, 0, 8}, {bcmFieldQualifyMplsOamHeaderBits0_31, (int (*)(void)) bcm_field_qualify_MplsOamHeaderBits0_31, (int (*)(void)) bcm_field_qualify_MplsOamHeaderBits0_31_get, 0, 8}, {bcmFieldQualifyMplsOamHeaderBits32_63, (int (*)(void)) bcm_field_qualify_MplsOamHeaderBits32_63, (int (*)(void)) bcm_field_qualify_MplsOamHeaderBits32_63_get, 0, 8}, {bcmFieldQualifyMplsOamACH, (int (*)(void)) bcm_field_qualify_MplsOamACH, (int (*)(void)) bcm_field_qualify_MplsOamACH_get, 0, 8}, {bcmFieldQualifyOamHeaderBits0_31, (int (*)(void)) bcm_field_qualify_OamHeaderBits0_31, (int (*)(void)) bcm_petra_field_qualify_OamHeaderBits0_31_get, 0, 8}, {bcmFieldQualifyOamHeaderBits32_63, (int (*)(void)) bcm_field_qualify_OamHeaderBits32_63, (int (*)(void)) bcm_petra_field_qualify_OamHeaderBits32_63_get, 0, 8}, {bcmFieldQualifyInterfaceInPorts, (int (*)(void)) bcm_field_qualify_InterfaceInPorts, (int (*)(void)) bcm_field_qualify_InterfaceInPorts_get, 0, 6}, {bcmFieldQualifyHashValue, NULL, NULL, 0, -1}, {bcmFieldQualifyInVPortWide, (int (*)(void)) bcm_field_qualify_InVPortWide, (int (*)(void)) bcm_field_qualify_InVPortWide_get, 0, 34}, {bcmFieldQualifyStackingRoute, (int (*)(void)) bcm_field_qualify_StackingRoute, (int (*)(void)) bcm_field_qualify_StackingRoute_get, 0, 8}, {bcmFieldQualifyDstSysPortExt, (int (*)(void)) bcm_field_qualify_DstSysPortExt, (int (*)(void)) bcm_field_qualify_DstSysPortExt_get, 0, 12}, {bcmFieldQualifyForwardHdrSrcMac, (int (*)(void)) bcm_field_qualify_ForwardHdrSrcMac, (int (*)(void)) bcm_field_qualify_ForwardHdrSrcMac_get, 0, 1}, {bcmFieldQualifyForwardHdrDstMac, (int (*)(void)) bcm_field_qualify_ForwardHdrDstMac, (int (*)(void)) bcm_field_qualify_ForwardHdrDstMac_get, 0, 1}, {bcmFieldQualifyForwardHdrVlanId, (int (*)(void)) bcm_field_qualify_ForwardHdrVlanId, (int (*)(void)) bcm_field_qualify_ForwardHdrVlanId_get, 0, 9}, {bcmFieldQualifyLearnInVPort, (int (*)(void)) bcm_field_qualify_LearnInVPort, (int (*)(void)) bcm_field_qualify_LearnInVPort_get, 0, 8}, {bcmFieldQualifyLearnExtension, (int (*)(void)) bcm_field_qualify_LearnExtension, (int (*)(void)) bcm_field_qualify_LearnExtension_get, 0, 27}, {bcmFieldQualifyVlanAction, (int (*)(void)) bcm_field_qualify_VlanAction, (int (*)(void)) bcm_field_qualify_VlanAction_get, 0, 8}, {bcmFieldQualifyRxTrapStrength, (int (*)(void)) bcm_field_qualify_RxTrapStrength, (int (*)(void)) bcm_field_qualify_RxTrapStrength_get, 0, 8}, {bcmFieldQualifyGeneratedTtl, (int (*)(void)) bcm_field_qualify_GeneratedTtl, (int (*)(void)) bcm_field_qualify_GeneratedTtl_get, 0, 8}, {bcmFieldQualifyIpMulticastCompatible, (int (*)(void)) bcm_field_qualify_IpMulticastCompatible, (int (*)(void)) bcm_field_qualify_IpMulticastCompatible_get, 0, 8}, {bcmFieldQualifyIncomingIpIfClass, (int (*)(void)) bcm_field_qualify_IncomingIpIfClass, (int (*)(void)) bcm_field_qualify_IncomingIpIfClass_get, 0, 8}, {bcmFieldQualifySrcTMPort, NULL, NULL, 0, -1}, {bcmFieldQualifyContainer, NULL, NULL, 0, -1}, {bcmFieldQualifyInVportDataIndex, NULL, NULL, 0, -1}, {bcmFieldQualifyTunnelTerminationProcessingProfile, (int (*)(void)) bcm_field_qualify_TunnelTerminationProcessingProfile, (int (*)(void)) bcm_field_qualify_TunnelTerminationProcessingProfile_get, 0, 7}, {bcmFieldQualifyForwardCode, (int (*)(void)) bcm_field_qualify_ForwardCode, (int (*)(void)) bcm_field_qualify_ForwardCode_get, 0, 7}, {bcmFieldQualifyPphType, (int (*)(void)) bcm_field_qualify_PphType, (int (*)(void)) bcm_field_qualify_PphType_get, 0, 7}, {bcmFieldQualifyInDscpExp, (int (*)(void)) bcm_field_qualify_InDscpExp, (int (*)(void)) bcm_field_qualify_InDscpExp_get, 0, 7}, {bcmFieldQualifyCount, NULL, NULL, 0, -1}, }; /* * The prototype_id options are: * 0 int (*) (int, bcm_field_entry_t, bcm_ip6_t, bcm_ip6_t) * 1 int (*) (int, bcm_field_entry_t, bcm_mac_t, bcm_mac_t) * 2 int (*) (int, bcm_field_entry_t, bcm_field_snap_header_t, bcm_field_snap_header_t) * 3 int (*) (int, bcm_field_entry_t, bcm_ip_t, bcm_ip_t) * 4 int (*) (int, bcm_field_entry_t, bcm_field_llc_header_t, bcm_field_llc_header_t) * 5 int (*) (int, bcm_field_entry_t, bcm_port_t, bcm_port_t) * 6 int (*) (int, bcm_field_entry_t, bcm_pbmp_t, bcm_pbmp_t) * 7 int (*) (int, bcm_field_entry_t, uint8, uint8) * 8 int (*) (int, bcm_field_entry_t, uint32, uint32) * 9 int (*) (int, bcm_field_entry_t, bcm_vlan_t, bcm_vlan_t) * 10 int (*) (int, bcm_field_entry_t, bcm_field_range_t, int) * 11 int (*) (int, bcm_field_entry_t, bcm_l4_port_t, bcm_l4_port_t) * 12 int (*) (int, bcm_field_entry_t, uint16, uint16) * 13 int (*) (int, bcm_field_entry_t, bcm_module_t, bcm_module_t, bcm_port_t, bcm_port_t) * 14 int (*) (int, bcm_field_entry_t, bcm_trunk_t, bcm_trunk_t) * 15 int (*) (int, bcm_field_entry_t, bcm_field_IpProtocolCommon_t) * 16 int (*) (int, bcm_field_entry_t, uint16) * 17 int (*) (int, bcm_field_entry_t, bcm_field_IpType_t) * 18 int (*) (int, bcm_field_entry_t, bcm_field_TunnelType_t) * 19 int (*) (int, bcm_field_entry_t, bcm_field_LoopbackType_t) * 20 int (*) (int, bcm_field_entry_t, bcm_field_ForwardingType_t) * 21 int (*) (int, bcm_field_entry_t, bcm_field_stage_t) * 22 int (*) (int, bcm_field_entry_t, uint32) * 23 int (*) (int, bcm_field_entry_t, bcm_field_IpFrag_t) * 24 int (*) (int, bcm_field_entry_t, bcm_field_L2Format_t) * 25 int (*) (int, bcm_field_entry_t, bcm_if_t) * 26 int (*) (int, bcm_field_entry_t, bcm_gport_t) * 27 int (*) (int, bcm_field_entry_t, uint8) * 28 int (*) (int, bcm_field_entry_t, bcm_vpn_t, bcm_vpn_t) * 29 int (*) (int, bcm_field_entry_t, bcm_field_FibreChan_t) * 30 int (*) (int, bcm_field_entry_t, uint32, uint32, uint32, uint32) * 31 int (*) (int, bcm_field_entry_t, bcm_field_header_format_t) * 32 int (*) (int, bcm_field_entry_t, bcm_field_header_format_set_t) * 33 int (*) (int, bcm_field_entry_t, bcm_rx_trap_t) * 34 int (*) (int, bcm_field_entry_t, uint64, uint64) * 35 int (*) (int, bcm_field_entry_t, bcm_field_ArpOpcode_t) * 36 int (*) (int, bcm_field_entry_t, bcm_field_data_offset_base_t, uint32, uint32) * 37 int (*) (int, bcm_field_entry_t, bcm_field_AppType_t) */ /* for prototype id 15 - from the U.M. */ CONST STATIC bcm_field_IpProtocolCommon_t supported_IpProtocolCommon_Ingress[] = { bcmFieldIpProtocolCommonTcp, bcmFieldIpProtocolCommonUdp, bcmFieldIpProtocolCommonIgmp, bcmFieldIpProtocolCommonIcmp, bcmFieldIpProtocolCommonIp6Icmp, bcmFieldIpProtocolCommonIpInIp, bcmFieldIpProtocolCommonIp6InIp, bcmFieldIpProtocolCommonUnknown, bcmFieldIpProtocolCommonMplsInIp }; #define NOF_SUPPORTED_IP_PROTOCOL_COMMON_INGRESS sizeof(supported_IpProtocolCommon_Ingress)/sizeof(bcm_field_IpProtocolCommon_t) CONST STATIC bcm_field_IpProtocolCommon_t *supported_IpProtocolCommon_Egress = supported_IpProtocolCommon_Ingress; #define NOF_SUPPORTED_IP_PROTOCOL_COMMON_EGRESS NOF_SUPPORTED_IP_PROTOCOL_COMMON_INGRESS /* for prototype id 17 from field_utils.c*/ CONST STATIC bcm_field_IpType_t supported_IpType_Ingress[] = { bcmFieldIpTypeIpv4Any, bcmFieldIpTypeIpv6, bcmFieldIpTypeArp, /*bcmFieldIpTypeTrill, */ /*bcmFieldIpTypeMim, - not good. Hard to explain... */ bcmFieldIpTypeMplsUnicast, bcmFieldIpTypeAny }; #define NOF_SUPPORTED_IP_TYPE_INGRESS sizeof(supported_IpType_Ingress)/sizeof(bcm_field_IpType_t) CONST STATIC bcm_field_IpType_t *supported_IpType_Egress = supported_IpType_Ingress; #define NOF_SUPPORTED_IP_TYPE_EGRESS NOF_SUPPORTED_IP_TYPE_INGRESS /* for prototype id 18 from field_utils.c */ CONST STATIC bcm_field_TunnelType_t supported_TunnelType_Ingress[] = { bcmFieldTunnelTypeIp, bcmFieldTunnelTypeIp6, bcmFieldTunnelTypeMpls, bcmFieldTunnelTypeMplsControlWord, bcmFieldTunnelTypeMplsLabel2, bcmFieldTunnelTypeMplsLabel2ControlWord, bcmFieldTunnelTypeMplsLabel3, bcmFieldTunnelTypeMplsLabel3ControlWord, bcmFieldTunnelTypeTrill, bcmFieldTunnelTypeNone }; #define NOF_SUPPORTED_TUNNEL_TYPE_INGRESS sizeof(supported_TunnelType_Ingress)/sizeof(bcm_field_TunnelType_t) CONST STATIC bcm_field_TunnelType_t *supported_TunnelType_Egress = supported_TunnelType_Ingress; #define NOF_SUPPORTED_TUNNEL_TYPE_EGRESS NOF_SUPPORTED_TUNNEL_TYPE_INGRESS /* for prototype id 37 from field_utils.c */ CONST STATIC bcm_field_AppType_t supported_AppType_Ingress[] = { bcmFieldAppTypeL2, bcmFieldAppTypeIp4Ucast, bcmFieldAppTypeIp6Ucast, bcmFieldAppTypeIp6Mcast, bcmFieldAppTypeMpls, bcmFieldAppTypeTrillUcast, bcmFieldAppTypeTrillMcast, bcmFieldAppTypeTrafficManagement, bcmFieldAppTypeMiM, bcmFieldAppTypeIp4UcastRpf, bcmFieldAppTypeIp6UcastRpf, bcmFieldAppTypeIp4McastRpf, bcmFieldAppTypeCompIp4McastRpf, bcmFieldAppTypeFCoE, bcmFieldAppTypeFCoETransit, bcmFieldAppTypeFCoEVft, bcmFieldAppTypeFCoERemote, bcmFieldAppTypeFCoEVftRemote, bcmFieldAppTypeIp4MacSrcBind, bcmFieldAppTypeIp6MacSrcBind, bcmFieldAppTypeIp4SrcBind, bcmFieldAppTypeIp6SrcBind }; /* for prototype id 19 - Not supported */ /* for prototype id 20 - from the U.M. */ CONST STATIC bcm_field_ForwardingType_t supported_ForwardingType_Ingress[] = { bcmFieldForwardingTypeL2, bcmFieldForwardingTypeIp4Ucast, bcmFieldForwardingTypeIp4Mcast, bcmFieldForwardingTypeIp6Ucast, bcmFieldForwardingTypeIp6Mcast, bcmFieldForwardingTypeMpls, bcmFieldForwardingTypeTrill, bcmFieldForwardingTypeRxReason /* bcmFieldForwardingTypeTrafficManagement is reserved for TM applications */ /* bcmFieldForwardingTypeSnoop is missing */ }; #define NOF_SUPPORTED_FORWARDING_TYPE_INGRESS sizeof(supported_ForwardingType_Ingress)/sizeof(bcm_field_ForwardingType_t) CONST STATIC bcm_field_ForwardingType_t *supported_ForwardingType_Egress = supported_ForwardingType_Ingress; #define NOF_SUPPORTED_FORWARDING_TYPE_EGRESS NOF_SUPPORTED_FORWARDING_TYPE_INGRESS /* for prototype id 21 */ CONST STATIC bcm_field_stage_t supported_stage_Ingress[] = { bcmFieldStageIngress, bcmFieldStageEgress }; #define NOF_SUPPORTED_STAGE_INGRESS sizeof(supported_stage_Ingress)/sizeof(bcm_field_stage_t) CONST STATIC bcm_field_stage_t *supported_stage_Egress = supported_stage_Ingress; #define NOF_SUPPORTED_STAGE_EGRESS NOF_SUPPORTED_STAGE_INGRESS /* for prototype id 23 - from the U.M. */ CONST STATIC bcm_field_IpFrag_t supported_IpFrag_Ingress[] = { bcmFieldIpFragNon, bcmFieldIpFragAny }; #define NOF_SUPPORTED_IP_FRAG_INGRESS sizeof(supported_IpFrag_Ingress)/sizeof(bcm_field_IpFrag_t) CONST STATIC bcm_field_IpFrag_t supported_Jer_IpFrag_Ingress[] = { bcmFieldIpFragNonOrFirst, bcmFieldIpFragNotFirst }; #define NOF_SUPPORTED_JER_IP_FRAG_INGRESS sizeof(supported_Jer_IpFrag_Ingress)/sizeof(bcm_field_IpFrag_t) CONST STATIC bcm_field_IpFrag_t *supported_IpFrag_Egress = supported_IpFrag_Ingress; #define NOF_SUPPORTED_IP_FRAG_EGRESS NOF_SUPPORTED_IP_FRAG_INGRESS /* for prototype id 24 - from the U.M. */ CONST STATIC bcm_field_L2Format_t supported_L2Format_Ingress[] = { bcmFieldL2FormatAny, bcmFieldL2FormatEthII, bcmFieldL2FormatSnap, bcmFieldL2FormatLlc, }; #define NOF_SUPPORTED_L2_FORMAT_INGRESS sizeof(supported_L2Format_Ingress)/sizeof(bcm_field_L2Format_t) CONST STATIC bcm_field_L2Format_t *supported_L2Format_Egress = supported_L2Format_Ingress; #define NOF_SUPPORTED_L2_FORMAT_EGRESS NOF_SUPPORTED_L2_FORMAT_INGRESS /* for prototype id 29 - Not supported */ /* for prototype id 31 - from field_utils */ CONST STATIC bcm_field_header_format_t supported_header_format_Ingress[] = { bcmFieldHeaderFormatL2, bcmFieldHeaderFormatIp4, bcmFieldHeaderFormatIp6, bcmFieldHeaderFormatMplsLabel1, bcmFieldHeaderFormatMplsLabel2, bcmFieldHeaderFormatMplsLabel3, bcmFieldHeaderFormatIp4AnyL2L3, bcmFieldHeaderFormatIp6AnyL2L3, bcmFieldHeaderFormatMplsLabel1AnyL2L3, bcmFieldHeaderFormatMplsLabel2AnyL2L3, bcmFieldHeaderFormatMplsLabel3AnyL2L3, bcmFieldHeaderFormatEthEth, bcmFieldHeaderFormatEthTrillEth, bcmFieldHeaderFormatIp4Ip4, bcmFieldHeaderFormatIp6Ip4, bcmFieldHeaderFormatIp4MplsLabel1, bcmFieldHeaderFormatIp4MplsLabel2, bcmFieldHeaderFormatIp4MplsLabel3, bcmFieldHeaderFormatIp6MplsLabel1, bcmFieldHeaderFormatIp6MplsLabel2, bcmFieldHeaderFormatIp6MplsLabel3, bcmFieldHeaderFormatEthMplsLabel1, bcmFieldHeaderFormatEthMplsLabel2, bcmFieldHeaderFormatEthMplsLabel3 }; CONST STATIC bcm_field_header_format_t *supported_header_format_Egress = supported_header_format_Ingress; /* for prototype id 33 - will be created automatically in the upload */ /* for prototype id 35 */ CONST STATIC bcm_field_ArpOpcode_t supported_ArpOpcode_Ingress[] = { bcmFieldArpOpcodeRequest, bcmFieldArpOpcodeReply, }; void _bcm_petra_field_test_qual_remove_from_qset(bcm_field_qset_t *valid_qset) { /*Qualifiers that shouldn't be used in a qset while creating field group*/ BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyCascadedKeyValue); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyIsEqualValue); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyHashValue); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyStageIngress); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyStageEgress); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyStageExternal); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyLearnInVPort); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyLearnSrcPort); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyLearnExtension); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyGeneratedTtl); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyIpMulticastCompatible); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyMirrorDest); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyPacketIsIEEE1588); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyIEEE1588Encapsulation); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyIEEE1588CompensateTimeStamp); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyIEEE1588Command); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyIEEE1588HeaderOffset); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyContainer); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifySrcTMPort); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyInVportDataIndex); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyTunnelTerminationProcessingProfile); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyForwardCode); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyPphType); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyInDscpExp); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyHeaderFormatExtension); } void _bcm_petra_field_test_ip_qual_remove_from_qset(bcm_field_qset_t *valid_qset) { /*Qualifiers that shouldn't be used in a qset while creating field group*/ BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyIp4); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyIp6); BCM_FIELD_QSET_REMOVE(*valid_qset, bcmFieldQualifyMpls); } /* for prototype id 36 */ STATIC void supported_data_offset_base(uint8 is_for_data_qualifier, uint8 is_for_entries, const bcm_field_data_offset_base_t **array, int *size){ CONST static bcm_field_data_offset_base_t supported[] = { bcmFieldDataOffsetBasePacketStart, bcmFieldDataOffsetBaseL2Header, bcmFieldDataOffsetBaseFirstHeader, bcmFieldDataOffsetBaseSecondHeader, bcmFieldDataOffsetBaseThirdHeader, bcmFieldDataOffsetBaseFourthHeader, bcmFieldDataOffsetBaseForwardingHeader, bcmFieldDataOffsetBaseNextForwardingHeader }; if(!size) { *array = NULL; return; } *array = supported; if(is_for_data_qualifier) { /* we can take also the 2 last offset base */ if(is_for_entries) { /* take only 5 */ *size = 5; } else { *size = 8; } } else { *size = 6; } } /* Takes the random value x the number of iteration i and returns the rand value*/ STATIC uint32 _bcm_petra_field_rand_val(uint32 x, uint32 i) { uint16 x1 = x & 0xffff; uint16 x2 = (x >> 16) & 0xffff; return (i + 1) * x1 + (x2 + i) * i; } /* * Get the length of the qualifier as it lays in the hardware. Both of the cases: best and worst */ STATIC bcm_error_t _bcm_petra_field_test_qualify_hardware_length(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_qualify_t qualify, uint32 *length_best, uint32 *length_worst) { bcm_dpp_field_info_OLD_t *unitData; SOC_PPC_FP_QUAL_TYPE *soc_ppd_qual_ptr; bcm_error_t rv; unsigned int exposed, hardwareBestCase, hardwareWorstCase; uint32 ppd_qual_ndx; BCMDNX_INIT_FUNC_DEFS; _DPP_FIELD_UNIT_CHECK(unit, unitData); rv = _bcm_dpp_ppd_qual_from_bcm_qual(unitData, stage, 1 << type, qualify, &soc_ppd_qual_ptr); BCM_IF_ERROR_RETURN(rv); if(length_best) { *length_best = 0; } if(length_worst) { *length_worst = 0; } for(ppd_qual_ndx = 0; ppd_qual_ndx < _BCM_PETRA_FIELD_QUAL_CHAIN; ++ppd_qual_ndx) { if((soc_ppd_qual_ptr[ppd_qual_ndx] != BCM_FIELD_ENTRY_INVALID) &&(soc_ppd_qual_ptr[ppd_qual_ndx] < SOC_PPC_NOF_FP_QUAL_TYPES)) { rv = _bcm_dpp_ppd_qual_bits(unit, stage, soc_ppd_qual_ptr[ppd_qual_ndx], &exposed, &hardwareBestCase, &hardwareWorstCase); BCM_IF_ERROR_RETURN(rv); if(length_best) { *length_best += hardwareBestCase; } if(length_worst) { *length_worst += hardwareWorstCase; } } } exit: BCMDNX_FUNC_RETURN; } /* * Get the length of the qualifier as it lays in the hardware. Best case only */ STATIC bcm_error_t _bcm_petra_field_test_qualify_hardware_length_best(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_qualify_t qualify, uint32 *length) { bcm_error_t rv; BCMDNX_INIT_FUNC_DEFS; BCMDNX_NULL_CHECK(length); rv = _bcm_petra_field_test_qualify_hardware_length(unit, stage, type, qualify, length, NULL); BCM_IF_ERROR_RETURN(rv); exit: BCMDNX_FUNC_RETURN; } /* * Get the length of the qualifier as it lays in the hardware. Worst case only */ STATIC bcm_error_t _bcm_petra_field_test_qualify_hardware_length_worst(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_qualify_t qualify, uint32 *length) { bcm_error_t rv; BCMDNX_INIT_FUNC_DEFS; BCMDNX_NULL_CHECK(length); rv = _bcm_petra_field_test_qualify_hardware_length(unit, stage, type, qualify, NULL, length); BCM_IF_ERROR_RETURN(rv); exit: BCMDNX_FUNC_RETURN; } /* * Get the length of key (i.e. qset that includes qualifiers and not data qualifiers) */ STATIC bcm_error_t _bcm_petra_field_test_key_length_best(int unit, _bcm_dpp_field_stage_idx_t stage, CONST bcm_field_qset_t *qset, uint32 *length) { bcm_error_t rv; bcm_field_qualify_t cur_qualifier; uint32 cur_qualifier_length; uint32 type; BCMDNX_INIT_FUNC_DEFS; BCMDNX_NULL_CHECK(length); type = _BCM_PETRA_FIELD_TYPE_ETHR; if(BCM_FIELD_QSET_TEST(*qset, bcmFieldQualifyIp4)) { type = _BCM_PETRA_FIELD_TYPE_IPV4; } else if (BCM_FIELD_QSET_TEST(*qset, bcmFieldQualifyIp6)) { type = _BCM_PETRA_FIELD_TYPE_IPV6; } else if (BCM_FIELD_QSET_TEST(*qset, bcmFieldQualifyMpls)) { type = _BCM_PETRA_FIELD_TYPE_MPLS; } *length = 0; for(cur_qualifier = 0; cur_qualifier < bcmFieldQualifyCount; ++cur_qualifier) { if(BCM_FIELD_QSET_TEST(*qset, cur_qualifier)) { rv = _bcm_petra_field_test_qualify_hardware_length_best(unit, stage, type, cur_qualifier, &cur_qualifier_length); BCM_IF_ERROR_RETURN(rv); *length += cur_qualifier_length; } } exit: BCMDNX_FUNC_RETURN; } /* * Get the exposed length of qualifier which determines the maximal value of this. * Needed to choose random mask and value for the qualifier */ STATIC bcm_error_t _bcm_petra_field_test_qualify_exposed_length(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_qualify_t qualify, uint32 *length) { bcm_dpp_field_info_OLD_t *unitData; bcm_error_t rv; int ppd_qual_ndx; SOC_PPC_FP_QUAL_TYPE *ppdQual; unsigned int len[_BCM_PETRA_FIELD_QUAL_CHAIN]; int32 *qualMap ; int32 qualMaps_handle ; BCMDNX_INIT_FUNC_DEFS; _DPP_FIELD_UNIT_CHECK(unit, unitData); BCMDNX_IF_ERR_EXIT(FIELD_ACCESS_QUALMAPS.get(unit, qualify, &qualMaps_handle)) ; if(qualMaps_handle == 0) { /* i.e. the qualifier is not supported */ *length = 0; BCM_EXIT; } /* get the qualifier mapping */ rv = _bcm_dpp_ppd_qual_from_bcm_qual(unitData, stage, (type == 0xffffffff) ? 0xf : (1 << type), qualify, &ppdQual); BCM_IF_ERROR_RETURN(rv); SOC_SAND_QUALMAPS_CONVERT_HANDLE_TO_ELEMENT(unit,qualMaps_handle,qualMap) ; if (qualMap[_BCM_DPP_FIELD_QUALMAP_OFFSET_LENGTH] > 0) { *length = qualMap[_BCM_DPP_FIELD_QUALMAP_OFFSET_LENGTH]; } else { for (ppd_qual_ndx = 0, *length = 0; (BCM_E_NONE == rv) && (ppd_qual_ndx < unitData->devInfo->qualChain); ppd_qual_ndx++) { if ((ppdQual[ppd_qual_ndx] < SOC_PPC_NOF_FP_QUAL_TYPES) &&(ppdQual[ppd_qual_ndx] != BCM_FIELD_ENTRY_INVALID)) { rv = _bcm_dpp_ppd_qual_bits(unit, stage, ppdQual[ppd_qual_ndx], &(len[ppd_qual_ndx]), NULL, NULL); *length += len[ppd_qual_ndx]; } } BCM_IF_ERROR_RETURN(rv); } exit: BCMDNX_FUNC_RETURN; } /* * Get the length of the qualifier as it lays in the hardware */ STATIC bcm_error_t _bcm_petra_field_test_data_qualifier_length(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, uint32 qual_id, uint32 *length) { bcm_error_t rv; bcm_field_data_qualifier_t dq; bcm_field_data_qualifier_t_init(&dq); dq.flags = BCM_FIELD_DATA_QUALIFIER_LENGTH_BIT_RES; rv = bcm_petra_field_data_qualifier_get(unit, qual_id, &dq); if(rv != BCM_E_NONE){ return rv; } *length = dq.length; if((dq.flags & BCM_FIELD_DATA_QUALIFIER_LENGTH_BIT_RES) == 0) { /* i.e the size is in bytes */ *length *= 8; } return BCM_E_NONE; } /* * get the length of the action in bits */ STATIC bcm_error_t _bcm_petra_field_test_action_length(int unit, _bcm_dpp_field_stage_idx_t stage, bcm_field_action_t action, uint32 *length) { bcm_dpp_field_info_OLD_t *unitData; SOC_PPC_FP_ACTION_TYPE *soc_ppd_action_ptr; bcm_error_t rv; unsigned int action_length; uint32 ppd_action_ndx; BCMDNX_INIT_FUNC_DEFS; BCMDNX_NULL_CHECK(length); _DPP_FIELD_UNIT_CHECK(unit, unitData); rv = _bcm_dpp_ppd_act_from_bcm_act(unitData, stage, action, &soc_ppd_action_ptr); BCM_IF_ERROR_RETURN(rv); *length = 0; for(ppd_action_ndx = 0; ppd_action_ndx < _BCM_PETRA_FIELD_ACTION_CHAIN; ++ppd_action_ndx) { if((soc_ppd_action_ptr[ppd_action_ndx] < SOC_PPC_NOF_FP_ACTION_TYPES) && (soc_ppd_action_ptr[ppd_action_ndx] != BCM_FIELD_ENTRY_INVALID)) { rv = _bcm_dpp_ppd_action_bits(unit, stage, soc_ppd_action_ptr[ppd_action_ndx], &action_length); BCM_IF_ERROR_RETURN(rv); *length += action_length; } } exit: BCMDNX_FUNC_RETURN; } STATIC bcm_error_t _bcm_petra_field_test_action_length_with_ppd_actions(int unit, _bcm_dpp_field_stage_idx_t stage, bcm_field_action_t action, uint32 *length, uint32 *nof_ppd_actions) { bcm_dpp_field_info_OLD_t *unitData; SOC_PPC_FP_ACTION_TYPE *soc_ppd_action_ptr; bcm_error_t rv; unsigned int action_length; uint32 ppd_action_ndx; BCMDNX_INIT_FUNC_DEFS; BCMDNX_NULL_CHECK(length); _DPP_FIELD_UNIT_CHECK(unit, unitData); rv = _bcm_dpp_ppd_act_from_bcm_act(unitData, stage, action, &soc_ppd_action_ptr); BCM_IF_ERROR_RETURN(rv); *length = 0; for(ppd_action_ndx = 0; ppd_action_ndx < _BCM_PETRA_FIELD_ACTION_CHAIN; ++ppd_action_ndx) { if((soc_ppd_action_ptr[ppd_action_ndx] < SOC_PPC_NOF_FP_ACTION_TYPES) && (soc_ppd_action_ptr[ppd_action_ndx] != BCM_FIELD_ENTRY_INVALID)) { rv = _bcm_dpp_ppd_action_bits(unit, stage, soc_ppd_action_ptr[ppd_action_ndx], &action_length); BCM_IF_ERROR_RETURN(rv); *length += action_length; if (SOC_IS_JERICHO_PLUS(unit) && (stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS) && ((action == bcmFieldActionRedirect) || (action == bcmFieldActionL3Switch) || (action == bcmFieldActionRedirectTrunk) || (action == bcmFieldActionRedirectIpmc) || (action == bcmFieldActionRedirectMcast) || (action == bcmFieldActionForward) || (action == bcmFieldActionTrapCodeQualifier))) { /* Add length of drop action + valid. Refer to _bcm_dpp_field_group_action_set*/ *length += 2; } *nof_ppd_actions += 1; } } exit: BCMDNX_FUNC_RETURN; } STATIC bcm_error_t _bcm_petra_field_test_action_length_with_valid_bit(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_action_t action, uint32 *length) { bcm_error_t rv; uint32 nof_ppd_actions = 0; rv = _bcm_petra_field_test_action_length_with_ppd_actions(unit, stage, action, length, &nof_ppd_actions); if(rv != BCM_E_NONE) { return rv; } *length += nof_ppd_actions; /* adding a valid bit for each ppd action*/ return BCM_E_NONE; } /* * This function gets the length of each one of the qualifiers and put the value in the global array qualifiers_info */ STATIC cmd_result_t _bcm_petra_field_test_set_qualifiers_info(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type) { static uint8 is_qualifiers_info_set = 0; static int qualifiers_info_unit = -1; static _bcm_dpp_field_stage_idx_t qualifiers_info_stage; static uint32 qualifiers_info_type = 0xffffffff; bcm_error_t rv; uint32 qual_ndx; bcm_field_qset_t valid_qset; bcm_field_aset_t junk; if(is_qualifiers_info_set && qualifiers_info_unit == unit && qualifiers_info_stage == stage && qualifiers_info_type == type) { return CMD_OK; } rv = _bcm_dpp_field_stage_type_qset_aset_get(unit, stage, type, &valid_qset, &junk); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } for(qual_ndx = 0; ((qualifiers_info[qual_ndx].qualify != bcmFieldQualifyCount) && (qualifiers_info[qual_ndx].qualify != BCM_FIELD_ENTRY_INVALID)); ++qual_ndx) { if(qualifiers_info[qual_ndx].set != NULL) { if(BCM_FIELD_QSET_TEST(valid_qset, qualifiers_info[qual_ndx].qualify)) { rv = _bcm_petra_field_test_qualify_exposed_length(unit, stage, type, qualifiers_info[qual_ndx].qualify, &qualifiers_info[qual_ndx].size); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } } } is_qualifiers_info_set = 1; qualifiers_info_unit = unit; qualifiers_info_stage = stage; qualifiers_info_type = type; return CMD_OK; } STATIC void buffer_to_mac(uint32 *buffer, bcm_mac_t *mac_t) { (*mac_t)[5] = buffer[0] & 0xff; (*mac_t)[4] = (buffer[0] >> 8) & 0xff; (*mac_t)[3] = (buffer[0] >> 16) & 0xff; (*mac_t)[2] = (buffer[0] >> 24) & 0xff; (*mac_t)[1] = buffer[1] & 0xff; (*mac_t)[0] = (buffer[1] >> 8) & 0xff; } STATIC void mac_to_buffer(bcm_mac_t mac_t, uint32 *buffer) { buffer[0] = mac_t[5]; buffer[0] |= mac_t[4] << 8; buffer[0] |= mac_t[3] << 16; buffer[0] |= mac_t[2] << 24; buffer[1] = mac_t[1]; buffer[1] |= mac_t[0] << 8; } STATIC void buffer_to_ip6(uint32 *buffer, bcm_ip6_t *ip6) { uint32 i; for(i = 0; i < 4; ++i) { (*ip6)[15 - 4*i] = buffer[i] & 0xff; (*ip6)[14 - 4*i] = (buffer[i] >> 8) & 0xff; (*ip6)[13 - 4*i] = (buffer[i] >> 16) & 0xff; (*ip6)[12 - 4*i] = (buffer[i] >> 24) & 0xff; } } STATIC soc_error_t get_vaild_local_port(int unit, soc_port_t *port_result) { int port_itr; uint32 is_valid_port = FALSE; soc_port_if_t port_interface_type; for ( port_itr = 0 ; port_itr < _BCM_DPP_NOF_LOCAL_PORTS(unit) ; port_itr++ ) { if ( soc_port_sw_db_is_valid_port_get(unit, port_itr, &is_valid_port) != SOC_E_NONE ) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return SOC_E_FAIL; } if ( is_valid_port ) { if ( soc_port_sw_db_interface_type_get(unit,port_itr,&port_interface_type) != SOC_E_NONE ){ _BCM_PETRA_FIELD_TEST_FAIL_MSG; return SOC_E_FAIL; } /* check if it's a nif port*/ if ( (port_interface_type == SOC_PORT_IF_ILKN) || (port_interface_type == SOC_PORT_IF_CAUI) || (port_interface_type == SOC_PORT_IF_XFI)) { *port_result = port_itr; return SOC_E_NONE; } } } return SOC_E_FAIL; } STATIC void ip6_to_buffer(bcm_ip6_t ip6, uint32 *buffer) { uint32 i; for(i = 0; i < 4; ++i) { buffer[i] = ip6[15 - 4*i]; buffer[i] |= ip6[14 - 4*i] << 8; buffer[i] |= ip6[13 - 4*i] << 16; buffer[i] |= ip6[12 - 4*i] << 24; } } /* * This function gets unit, entry, qualifier, arrays that contains the data and the mask (if needed mask). * The function casts the prototype of the qualifier set function from the table qualifiers_info * to the adequate one according to the type_id stored in this table and operates it. */ STATIC bcm_error_t _bcm_petra_field_test_operate_set_function(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_entry_t entry, bcm_field_qualify_t qualifier, uint32 *data, uint32 *mask) { cmd_result_t result; int prototype = -1; int qual_index; BCMDNX_INIT_FUNC_DEFS; for(qual_index=0; ((qualifiers_info[qual_index].qualify != bcmFieldQualifyCount) && (qualifiers_info[qual_index].qualify != BCM_FIELD_ENTRY_INVALID)); ++qual_index) { if(qualifiers_info[qual_index].qualify == qualifier) { prototype = qualifiers_info[qual_index].prototype_id; break; } } result = _bcm_petra_field_test_set_qualifiers_info(unit, stage, type); if(result != CMD_OK) { return BCM_E_FAIL; } switch(prototype) { case 0: { bcm_ip6_t s_data, s_mask; if(qualifier == bcmFieldQualifySrcIp6High || qualifier == bcmFieldQualifyDstIp6High) { /* and hence put the data in the high address */ uint32 tmp_data[4]; uint32 tmp_mask[4]; tmp_data[0] = 0; tmp_data[1] = 0; tmp_data[2] = data[0]; tmp_data[3] = data[1]; tmp_mask[0] = 0; tmp_mask[1] = 0; tmp_mask[2] = mask[0]; tmp_mask[3] = mask[1]; buffer_to_ip6(tmp_data, &s_data); buffer_to_ip6(tmp_mask, &s_mask); } else { /* even toogh the qualifier has only the lower address the high should be 0 */ buffer_to_ip6(data, &s_data); buffer_to_ip6(mask, &s_mask); } return ((int (*) (int, bcm_field_entry_t, bcm_ip6_t, bcm_ip6_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 1: { bcm_mac_t s_data, s_mask; buffer_to_mac(data, &s_data); buffer_to_mac(mask, &s_mask); return ((int (*) (int, bcm_field_entry_t, bcm_mac_t, bcm_mac_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 2: { bcm_field_snap_header_t s_data, s_mask; s_data.org_code = data[0]; s_data.type = data[1] & 0xffff; s_mask.org_code = mask[0]; s_mask.type = mask[1] & 0xffff; return ((int (*) (int, bcm_field_entry_t, bcm_field_snap_header_t, bcm_field_snap_header_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 3: { bcm_ip_t s_data, s_mask; /* bcm_ip_t is uint32 */ s_data = data[0]; s_mask = mask[0]; return ((int (*) (int, bcm_field_entry_t, bcm_ip_t, bcm_ip_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 4: { bcm_field_llc_header_t s_data, s_mask; s_data.dsap = data[0] & 0xff; s_data.ssap = (data[0] >> 8) & 0xff; s_data.control = (data[0] >> 16) & 0xff; s_mask.dsap = mask[0] & 0xff; s_mask.ssap = (mask[0] >> 8) & 0xff; s_mask.control = (mask[0] >> 16) & 0xff; return ((int (*) (int, bcm_field_entry_t, bcm_field_llc_header_t, bcm_field_llc_header_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 5: { /* bcm_port_t is int - we assume 32 bits*/ bcm_port_t s_data, s_mask; s_data = data[0]; s_mask = mask[0]; return ((int (*) (int, bcm_field_entry_t, bcm_port_t, bcm_port_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 6: { bcm_pbmp_t s_data, s_mask; uint32 port; uint32 is_valid; BCM_PBMP_CLEAR(s_data); BCM_PBMP_CLEAR(s_mask); for(port =0; port < _BCM_DPP_NOF_LOCAL_PORTS(unit); ++port){ BCMDNX_IF_ERR_EXIT(soc_port_sw_db_is_valid_port_get(unit, port, &is_valid)); if (is_valid) { /* filter only valid ports */ if(SHR_BITGET(data, port)) { BCM_PBMP_PORT_ADD(s_data, port); } } if(SHR_BITGET(mask, port)) { BCM_PBMP_PORT_ADD(s_mask, port); } } return ((int (*) (int, bcm_field_entry_t, bcm_pbmp_t, bcm_pbmp_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 7: { uint8 s_data, s_mask; s_data = data[0] & 0xff; s_mask = mask[0] & 0xff; return ((int (*) (int, bcm_field_entry_t, uint8, uint8)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 8: { uint32 s_data, s_mask; s_data = data[0]; s_mask = mask[0]; return ((int (*) (int, bcm_field_entry_t, uint32, uint32)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 9: { bcm_vlan_t s_data, s_mask; /* bcm_vlan_t is uint16 */ s_data = data[0] & 0xffff; s_mask = mask[0] & 0xffff; return ((int (*) (int, bcm_field_entry_t, bcm_vlan_t, bcm_vlan_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 10: { /* will be implemented latter*/ return BCM_E_UNAVAIL; /* return ((int (*) (int, bcm_field_entry_t, bcm_field_range_t, int)) qualifiers_info[qual_index].set(unit, entry, s_data, s_mask); */ } case 11: { bcm_l4_port_t s_data, s_mask; /* bcm_l4_port_t is int - we assume 32-bits*/ s_data = data[0]; s_mask = mask[0]; return ((int (*) (int, bcm_field_entry_t, bcm_l4_port_t, bcm_l4_port_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 12: { uint16 s_data, s_mask; s_data = data[0] & 0xffff; s_mask = mask[0] & 0xffff; return ((int (*) (int, bcm_field_entry_t, uint16, uint16)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 13: { /* will be implemented latter */ return BCM_E_UNAVAIL; /* return ((int (*) (int, bcm_field_entry_t, bcm_module_t, bcm_module_t, bcm_port_t, bcm_port_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask);*/ } case 14: { bcm_trunk_t s_data, s_mask; /* bcm_truck_t is int -we assume 32-bits */ s_data = data[0]; s_mask = mask[0]; return ((int (*) (int, bcm_field_entry_t, bcm_trunk_t, bcm_trunk_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 15: { bcm_field_IpProtocolCommon_t s_data; /* bcm_field_IpProtocolCommon_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_IpProtocolCommon_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 16: { uint16 s_data; s_data = data[0] & 0xffff; return ((int (*) (int, bcm_field_entry_t, uint16))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 17: { bcm_field_IpType_t s_data; /* bcm_field_IpType_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_IpType_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 18: { bcm_field_TunnelType_t s_data; /* bcm_field_TunnelType_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_TunnelType_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 19: { bcm_field_LoopbackType_t s_data; /* bcm_field_LoopbackType_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_LoopbackType_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 20: { bcm_field_ForwardingType_t s_data; /* bcm_field_ForwardingType_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_ForwardingType_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 21: { bcm_field_stage_t s_data; /* bcm_field_stage_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_stage_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 22: { uint32 s_data; s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, uint32))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 23: { bcm_field_IpFrag_t s_data; /* bcm_field_IpFrag_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_IpFrag_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 24: { bcm_field_L2Format_t s_data; /* bcm_field_L2Format_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_L2Format_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 25: { bcm_if_t s_data; /* bcm_if_t is int - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_if_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 26: { bcm_gport_t s_data; /* bcm_gport_t is int - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_gport_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 27: { uint8 s_data; s_data = data[0] & 0xff; return ((int (*) (int, bcm_field_entry_t, uint8))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 28: { bcm_vpn_t s_data, s_mask; /* bcm_vpn_t is uint16 */ s_data = data[0] & 0xffff; s_mask = mask[0] & 0xffff; return ((int (*) (int, bcm_field_entry_t, bcm_vpn_t, bcm_vpn_t))qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 29: { bcm_field_FibreChan_t s_data; /* bcm_field_FibreChan_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_FibreChan_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 30: { return BCM_E_UNAVAIL; /* will be implemented latter */ /* return ((int (*) (int, bcm_field_entry_t, uint32, uint32, uint32, uint32)) */ } case 31: { bcm_field_header_format_t s_data; /* bcm_field_header_format_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_header_format_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 32: { bcm_field_header_format_set_t s_data; uint32 index; BCM_FIELD_HEADER_FORMAT_SET_INIT(s_data); for(index = 0; index < bcmFieldHeaderFormatCount; ++index) { if (SHR_BITGET(data, index)) { BCM_FIELD_HEADER_FORMAT_SET_ADD(s_data, index); } } return ((int (*) (int, bcm_field_entry_t, bcm_field_header_format_set_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 33: { bcm_rx_trap_t s_data; /* bcm_rx_trap_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_rx_trap_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 34: { uint64 s_data, s_mask; COMPILER_64_SET(s_data, data[1], data[0]); COMPILER_64_SET(s_mask, mask[1], mask[0]); return ((int (*) (int, bcm_field_entry_t, uint64, uint64))qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask); } case 35: { bcm_field_ArpOpcode_t s_data; /* bcm_field_ArpOpcode_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_ArpOpcode_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 36: { /* here we take data[0] and mask[0] for data and mask, and data offset base will be in data[1] */ bcm_field_data_offset_base_t offset_base = data[1]; uint32 s_data, s_mask; s_data = data[0]; s_mask = mask[0]; return ((int (*)(int, bcm_field_entry_t, bcm_field_data_offset_base_t, uint32, uint32))qualifiers_info[qual_index].set)(unit, entry, offset_base, s_data, s_mask); } case 37: { bcm_field_AppType_t s_data; /* bcm_field_AppType_t is enumerator - we assume 32 bits*/ s_data = data[0]; return ((int (*) (int, bcm_field_entry_t, bcm_field_AppType_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } case 38: { bcm_gport_t s_data; BCM_GPORT_MCAST_SET(s_data, data[0]); return ((int (*) (int, bcm_field_entry_t, bcm_gport_t))qualifiers_info[qual_index].set)(unit, entry, s_data); } default: return BCM_E_FAIL; } exit: BCMDNX_FUNC_RETURN; } /* * This function gets unit, entry, qualifier, arrays that contains the data and the mask to be get. * The function casts the prototype of the qualifier get function from the table qualifiers_info * to the adequate one according to the type_id stored in this table and operates it. */ STATIC bcm_error_t _bcm_petra_field_test_operate_get_function(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_entry_t entry, bcm_field_qualify_t qualifier, uint32 *data, uint32 *mask) { cmd_result_t result; bcm_error_t rv; int prototype = -1; int qual_index; for(qual_index=0; (qualifiers_info[qual_index].qualify != bcmFieldQualifyCount) && (qualifiers_info[qual_index].qualify != BCM_FIELD_ENTRY_INVALID); ++qual_index) { if(qualifiers_info[qual_index].qualify == qualifier) { prototype = qualifiers_info[qual_index].prototype_id; break; } } result = _bcm_petra_field_test_set_qualifiers_info(unit, stage, type); if(result != CMD_OK) { return BCM_E_FAIL; } sal_memset(data, 0x0, _BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH/8); sal_memset(mask, 0x0, _BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH/8); switch(prototype) { case 0: { bcm_ip6_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_ip6_t*, bcm_ip6_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); if(qualifier == bcmFieldQualifySrcIp6High || qualifier == bcmFieldQualifyDstIp6High) { /* and hence put the high address in the data */ uint32 tmp_data[4]; uint32 tmp_mask[4]; ip6_to_buffer(s_data, tmp_data); ip6_to_buffer(s_mask, tmp_mask); data[0] = tmp_data[2]; data[1] = tmp_data[3]; mask[0] = tmp_mask[2]; mask[1] = tmp_mask[3]; } else { /* even toogh the qualifier has only the lower address the high should be 0 */ ip6_to_buffer(s_data, data); ip6_to_buffer(s_mask, mask); } return rv; } case 1: { bcm_mac_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_mac_t*, bcm_mac_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); mac_to_buffer(s_data, data); mac_to_buffer(s_mask, mask); return rv; } case 2: { bcm_field_snap_header_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_snap_header_t*, bcm_field_snap_header_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); data[0] = s_data.org_code; data[1] = s_data.type; mask[0] |= s_mask.org_code; mask[1] |= s_mask.type; return rv; } case 3: { bcm_ip_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_ip_t*, bcm_ip_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); /* bcm_ip_t is uint32 */ data[0] = s_data; mask[0] = s_mask; return rv; } case 4: { bcm_field_llc_header_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_llc_header_t*, bcm_field_llc_header_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); data[0] |= s_data.dsap; data[0] |= s_data.ssap << 8; data[0] |= s_data.control << 16; mask[0] |= s_mask.dsap; mask[0] |= s_mask.ssap << 8; mask[0] |= s_mask.control << 16; return rv; } case 5: { /* bcm_port_t is int - we assume 32 bits*/ bcm_port_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_port_t*, bcm_port_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); data[0] = s_data; mask[0] = s_mask; return rv; } case 6: { bcm_pbmp_t s_data, s_mask; uint32 port; rv = ((int (*) (int, bcm_field_entry_t, bcm_pbmp_t*, bcm_pbmp_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); for(port =0; port < _BCM_DPP_NOF_LOCAL_PORTS(unit); ++port){ if(BCM_PBMP_MEMBER(s_data, port)) { SHR_BITSET(data, port); } if(BCM_PBMP_MEMBER(s_mask, port)) { SHR_BITSET(mask, port); } } return rv; } case 7: { uint8 s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, uint8*, uint8*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); data[0] |= s_data; mask[0] |= s_mask; return rv; } case 8: { uint32 s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, uint32*, uint32*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); data[0] = s_data; mask[0] = s_mask; return rv; } case 9: { bcm_vlan_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_vlan_t*, bcm_vlan_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); /* bcm_vlan_t is uint16 */ data[0] |= s_data; mask[0] |= s_mask; return rv; } case 10: { /* will be implemented latter*/ return BCM_E_UNAVAIL; /* return ((int (*) (int, bcm_field_entry_t, bcm_field_range_t, int)) qualifiers_info[qual_index].set(unit, entry, s_data, s_mask); */ } case 11: { bcm_l4_port_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_l4_port_t*, bcm_l4_port_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); /* bcm_l4_port_t is int - we assume 32-bits*/ data[0] = s_data; mask[0] = s_mask; return rv; } case 12: { uint16 s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, uint16*, uint16*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); data[0] = s_data; mask[0] = s_mask; return rv; } case 13: { /* will be implemented latter */ return BCM_E_UNAVAIL; /* return ((int (*) (int, bcm_field_entry_t, bcm_module_t, bcm_module_t, bcm_port_t, bcm_port_t)) qualifiers_info[qual_index].set)(unit, entry, s_data, s_mask);*/ } case 14: { bcm_trunk_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_trunk_t*, bcm_trunk_t*)) qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); /* bcm_truck_t is int -we assume 32-bits */ data[0] = s_data; mask[0] = s_mask; return rv; } case 15: { bcm_field_IpProtocolCommon_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_IpProtocolCommon_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_IpProtocolCommon_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 16: { uint16 s_data; rv = ((int (*) (int, bcm_field_entry_t, uint16*))qualifiers_info[qual_index].get)(unit, entry, &s_data); data[0] |= s_data; return rv; } case 17: { bcm_field_IpType_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_IpType_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_IpType_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 18: { bcm_field_TunnelType_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_TunnelType_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_TunnelType_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 19: { bcm_field_LoopbackType_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_LoopbackType_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_LoopbackType_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 20: { bcm_field_ForwardingType_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_ForwardingType_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_ForwardingType_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 21: { bcm_field_stage_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_stage_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_stage_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 22: { uint32 s_data; rv = ((int (*) (int, bcm_field_entry_t, uint32*))qualifiers_info[qual_index].get)(unit, entry, &s_data); data[0] = s_data; return rv; } case 23: { bcm_field_IpFrag_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_IpFrag_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_IpFrag_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 24: { bcm_field_L2Format_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_L2Format_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_L2Format_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 25: { bcm_if_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_if_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_if_t is int - we assume 32 bits*/ data[0] = s_data; return rv; } case 26: { bcm_gport_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_gport_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_gport_t is int - we assume 32 bits*/ data[0] = s_data; return rv; } case 27: { uint8 s_data; rv = ((int (*) (int, bcm_field_entry_t, uint8*))qualifiers_info[qual_index].get)(unit, entry, &s_data); data[0] |= s_data; return rv; } case 28: { bcm_vpn_t s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, bcm_vpn_t*, bcm_vpn_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); /* bcm_vpn_t is uint16 */ data[0] |= s_data; mask[0] |= s_mask; return rv; } case 29: { bcm_field_FibreChan_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_FibreChan_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_FibreChan_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 30: { return BCM_E_UNAVAIL; /* will be implemented latter */ /* return ((int (*) (int, bcm_field_entry_t, uint32, uint32, uint32, uint32)) */ } case 31: { bcm_field_header_format_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_header_format_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_header_format_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 32: { bcm_field_header_format_set_t s_data; uint32 index; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_header_format_set_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); for(index = 0; index < bcmFieldHeaderFormatCount; ++index) { if (BCM_FIELD_HEADER_FORMAT_SET_TEST(s_data, index)) { SHR_BITSET(data, index); } } return rv; } case 33: { bcm_rx_trap_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_rx_trap_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_rx_trap_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 34: { uint64 s_data, s_mask; rv = ((int (*) (int, bcm_field_entry_t, uint64*, uint64*))qualifiers_info[qual_index].get)(unit, entry, &s_data, &s_mask); data[0] = COMPILER_64_LO(s_data); data[1] = COMPILER_64_HI(s_data); mask[0] = COMPILER_64_LO(s_mask); mask[1] = COMPILER_64_HI(s_mask); return rv; } case 35: { bcm_field_ArpOpcode_t s_data; /* bcm_field_ArpOpcode_t is enumerator - we assume 32 bits*/ rv = ((int (*) (int, bcm_field_entry_t, bcm_field_ArpOpcode_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); data[0] = s_data; return rv; } case 36: { /* here we take data[0] and mask[0] for data and mask, and data offset base will be in data[1] */ bcm_field_data_offset_base_t offset_base; uint32 s_data, s_mask; rv = ((int (*)(int, bcm_field_entry_t, bcm_field_data_offset_base_t*, uint32*, uint32*))qualifiers_info[qual_index].get)(unit, entry, &offset_base, &s_data, &s_mask); data[0] = s_data; data[1] = offset_base; mask[0] = s_mask; return rv; } case 37: { bcm_field_AppType_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_field_AppType_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_field_AppType_t is enumerator - we assume 32 bits*/ data[0] = s_data; return rv; } case 38: { bcm_gport_t s_data; rv = ((int (*) (int, bcm_field_entry_t, bcm_gport_t*))qualifiers_info[qual_index].get)(unit, entry, &s_data); /* bcm_gport_t is int - we assume 32 bits*/ data[0] = BCM_GPORT_MCAST_GET(s_data); return rv; } default: return BCM_E_FAIL; } } /* Getting adequate value and mask to the qualifier, it should be such that the retrieved value and mask will be the same */ STATIC cmd_result_t _bcm_petra_field_test_get_valid_value_and_mask(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_qualify_t qualifier, uint32 x, uint32 *data, uint32 *mask) { uint32 second_rand_param = 0; cmd_result_t result; int prototype = -1; int i, qual_index; soc_port_t src_port_number; if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { const static char *qualifiers_names[] = BCM_FIELD_QUALIFY_STRINGS; LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Getting valid value and mask for the qualifier %s (%d)\n"), qualifiers_names[qualifier], qualifier)); } if ( get_vaild_local_port(unit,&src_port_number) != SOC_E_NONE ) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } for(qual_index=0; (qualifiers_info[qual_index].qualify != bcmFieldQualifyCount) && (qualifiers_info[qual_index].qualify != BCM_FIELD_ENTRY_INVALID); ++qual_index) { if(qualifiers_info[qual_index].qualify == qualifier) { prototype = qualifiers_info[qual_index].prototype_id; break; } } result = _bcm_petra_field_test_set_qualifiers_info(unit, stage, type); if(result != CMD_OK) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return result; } sal_memset(data, 0x0, _BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH/8); sal_memset(mask, 0x0, _BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH/8); /* * The prototypes ids are: * 0 int (*) (int, bcm_field_entry_t, bcm_ip6_t, bcm_ip6_t) * 1 int (*) (int, bcm_field_entry_t, bcm_mac_t, bcm_mac_t) * 2 int (*) (int, bcm_field_entry_t, bcm_field_snap_header_t, bcm_field_snap_header_t) * 3 int (*) (int, bcm_field_entry_t, bcm_ip_t, bcm_ip_t) * 4 int (*) (int, bcm_field_entry_t, bcm_field_llc_header_t, bcm_field_llc_header_t) * 5 int (*) (int, bcm_field_entry_t, bcm_port_t, bcm_port_t) * 6 int (*) (int, bcm_field_entry_t, bcm_pbmp_t, bcm_pbmp_t) * 7 int (*) (int, bcm_field_entry_t, uint8, uint8) * 8 int (*) (int, bcm_field_entry_t, uint32, uint32) * 9 int (*) (int, bcm_field_entry_t, bcm_vlan_t, bcm_vlan_t) * 10 int (*) (int, bcm_field_entry_t, bcm_field_range_t, int) * 11 int (*) (int, bcm_field_entry_t, bcm_l4_port_t, bcm_l4_port_t) * 12 int (*) (int, bcm_field_entry_t, uint16, uint16) * 13 int (*) (int, bcm_field_entry_t, bcm_module_t, bcm_module_t, bcm_port_t, bcm_port_t) * 14 int (*) (int, bcm_field_entry_t, bcm_trunk_t, bcm_trunk_t) * 15 int (*) (int, bcm_field_entry_t, bcm_field_IpProtocolCommon_t) * 16 int (*) (int, bcm_field_entry_t, uint16) * 17 int (*) (int, bcm_field_entry_t, bcm_field_IpType_t) * 18 int (*) (int, bcm_field_entry_t, bcm_field_TunnelType_t) * 19 int (*) (int, bcm_field_entry_t, bcm_field_LoopbackType_t) * 20 int (*) (int, bcm_field_entry_t, bcm_field_ForwardingType_t) * 21 int (*) (int, bcm_field_entry_t, bcm_field_stage_t) * 22 int (*) (int, bcm_field_entry_t, uint32) * 23 int (*) (int, bcm_field_entry_t, bcm_field_IpFrag_t) * 24 int (*) (int, bcm_field_entry_t, bcm_field_L2Format_t) * 25 int (*) (int, bcm_field_entry_t, bcm_if_t) * 26 int (*) (int, bcm_field_entry_t, bcm_gport_t) * 27 int (*) (int, bcm_field_entry_t, uint8) * 28 int (*) (int, bcm_field_entry_t, bcm_vpn_t, bcm_vpn_t) * 29 int (*) (int, bcm_field_entry_t, bcm_field_FibreChan_t) * 30 int (*) (int, bcm_field_entry_t, uint32, uint32, uint32, uint32) * 31 int (*) (int, bcm_field_entry_t, bcm_field_header_format_t) * 32 int (*) (int, bcm_field_entry_t, bcm_field_header_format_set_t) * 33 int (*) (int, bcm_field_entry_t, bcm_rx_trap_t) * 34 int (*) (int, bcm_field_entry_t, uint64, uint64) * 35 int (*) (int, bcm_field_entry_t, bcm_field_ArpOpcode_t) * 36 int (*) (int, bcm_field_entry_t, bcm_field_data_offset_base_t, uint32, uint32) * 37 int (*) (int, bcm_field_entry_t, bcm_field_AppType_t) */ /* enumerators */ if(prototype == 15) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_IP_PROTOCOL_COMMON_INGRESS; data[0] = supported_IpProtocolCommon_Ingress[i]; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_IP_PROTOCOL_COMMON_EGRESS; data[0] = supported_IpProtocolCommon_Egress[i]; } } else if(prototype == 17) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_IP_TYPE_INGRESS; data[0] = supported_IpType_Ingress[i]; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_IP_TYPE_EGRESS; data[0] = supported_IpType_Egress[i]; } } else if(prototype == 18) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_TUNNEL_TYPE_INGRESS; data[0] = supported_TunnelType_Ingress[i]; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_TUNNEL_TYPE_EGRESS; data[0] = supported_TunnelType_Egress[i]; } } else if(prototype == 19) { /* Do nothing we don't support it */ } else if(prototype == 20) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_FORWARDING_TYPE_INGRESS; data[0] = supported_ForwardingType_Ingress[i]; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_FORWARDING_TYPE_EGRESS; data[0] = supported_ForwardingType_Egress[i]; } } else if(prototype == 21) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_STAGE_INGRESS; data[0] = supported_stage_Ingress[i]; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_STAGE_EGRESS; data[0] = supported_stage_Egress[i]; } } else if(prototype == 23) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % (SOC_IS_JERICHO(unit) ? NOF_SUPPORTED_JER_IP_FRAG_INGRESS : NOF_SUPPORTED_IP_FRAG_INGRESS); data[0] = ( SOC_IS_JERICHO(unit) && (soc_property_get(unit, spn_FIELD_IP_FIRST_FRAGMENT_PARSED, TRUE))) ? supported_Jer_IpFrag_Ingress[i] : supported_IpFrag_Ingress[i]; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_IP_FRAG_EGRESS; data[0] = supported_IpFrag_Egress[i]; } } else if(prototype == 24) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_L2_FORMAT_INGRESS; data[0] = supported_L2Format_Ingress[i]; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % NOF_SUPPORTED_L2_FORMAT_EGRESS; data[0] = supported_L2Format_Egress[i]; } } else if(prototype == 29) { /* Do nothing we don't support it */ } else if(prototype == 31) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % (sizeof(supported_header_format_Ingress)/sizeof(bcm_field_header_format_t)); data[0] = supported_header_format_Ingress[i]; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % (sizeof(supported_header_format_Egress)/sizeof(bcm_field_L2Format_t)); data[0] = supported_header_format_Egress[i]; } } else if(prototype == 33) { static uint8 is_set = 0; static _bcm_dpp_field_stage_idx_t cur_stage; static bcm_rx_trap_t supported[bcmRxTrapCount]; static uint32 supported_count; int soc_ppd_trap_id; if(!is_set || cur_stage != stage) { supported_count = 0; for(i=0; i < bcmRxTrapCount; ++i) { _bcm_dpp_rx_ppd_trap_get(unit, i, &soc_ppd_trap_id); if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { if(soc_ppd_trap_id && ((soc_ppd_trap_id & 0x20000000) == 0) /* i.e it is not egress trap code */) { supported[supported_count++] = i; } } else { if(soc_ppd_trap_id & 0x20000000/* This is the flag indicating that this is egress trap code */) { supported[supported_count++] = i; } } } is_set = TRUE; cur_stage = stage; } if(supported_count == 0) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Not supported rx trap\n"))); _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } data[0] = supported[_bcm_petra_field_rand_val(x, second_rand_param++) % supported_count]; } else if(prototype == 35) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % (sizeof(supported_ArpOpcode_Ingress)/sizeof(bcm_field_ArpOpcode_t)); data[0] = supported_ArpOpcode_Ingress[i]; } } else if(prototype == 36) { /* data[0] and mask[0] will have the data and mask. data[1] will have the bae offset */ const bcm_field_data_offset_base_t *valid_offset_bases; int valid_offset_bases_size; supported_data_offset_base(FALSE, FALSE, &valid_offset_bases, &valid_offset_bases_size); i = _bcm_petra_field_rand_val(x, second_rand_param++) % valid_offset_bases_size; data[1] = valid_offset_bases[i]; data[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 0x80; mask[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 0x80; data[0] &= mask[0]; } else if(prototype == 37) { if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % (sizeof(supported_AppType_Ingress)/sizeof(bcm_field_AppType_t)); data[0] = supported_AppType_Ingress[i]; } } else if (prototype == 5) { data[0] = src_port_number; mask[0] = 0xFFFFFFFF; } else if (prototype == 6) { /* port bit map */ } else if(prototype == 26) { /* gport */ bcm_module_t mymodid = 0; int core; uint32 tm_port; if (BCM_E_NONE != bcm_petra_stk_my_modid_get(unit, &mymodid)) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if (BCM_E_NONE != MBCM_DPP_DRIVER_CALL(unit, mbcm_dpp_local_to_tm_port_get, (unit, src_port_number, &tm_port, &core))) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } BCM_GPORT_MODPORT_SET(data[0], SOC_DPP_CORE_TO_MODID(mymodid, core), tm_port); } else { if(qualifier == bcmFieldQualifyPacketRes) { i = _bcm_petra_field_rand_val(x, second_rand_param++)%2; if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { data[0] = BCM_FIELD_PKT_RES_BPDU; mask[0] = 0x1f; } else { data[0] = BCM_FIELD_PKT_RES_UNKNOWN; mask[0] = 0x1f; } } else if(qualifier == bcmFieldQualifyIngressStpState) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; if(i == 0) { data[0] = 0; mask[0] = 0; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % 3; if(i == 0) { data[0] = BCM_STG_STP_BLOCK; } else if(i == 1) { data[0] = BCM_STG_STP_LEARN; } else { data[0] = BCM_STG_STP_FORWARD; } mask[0] = 0x7; } } else if(qualifier == bcmFieldQualifyDstL3Egress) { BCM_L3_ITF_SET(data[0], BCM_L3_ITF_TYPE_FEC, 0); } else if (qualifier == bcmFieldQualifyColor) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % 4; if (i == 0) { data[0] = BCM_FIELD_COLOR_GREEN; } else if(i == 1) { data[0] = BCM_FIELD_COLOR_YELLOW; } else if(i == 2) { data[0] = BCM_FIELD_COLOR_RED; } else { data[0] = BCM_FIELD_COLOR_BLACK; } } else if(qualifier == bcmFieldQualifyVlanFormat && ( stage != _BCM_DPP_FIELD_STAGE_INDEX_EGRESS && SOC_DPP_IS_VLAN_TRANSLATE_MODE_NORMAL(unit)) ) { /* in these cases the mask should be all 0 or all 1. In the Egress - it is a regular qualifier */ i = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; if(i == 0) { data[0] = 0; mask[0] = 0; } else { i = _bcm_petra_field_rand_val(x, second_rand_param++) % 5; if(i == 0) { data[0] = 0; } else if(i == 1) { data[0] = BCM_FIELD_VLAN_FORMAT_OUTER_TAGGED; } else if (i == 2) { data[0] = BCM_FIELD_VLAN_FORMAT_INNER_TAGGED | BCM_FIELD_VLAN_FORMAT_OUTER_TAGGED; } else if(i == 3) { data[0] = BCM_FIELD_VLAN_FORMAT_OUTER_TAGGED_VID_ZERO; } else { data[0] = BCM_FIELD_VLAN_FORMAT_INNER_TAGGED | BCM_FIELD_VLAN_FORMAT_OUTER_TAGGED_VID_ZERO; } mask[0] = 0xF; } } else if (qualifier == bcmFieldQualifyEcnValue) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; if(i == 0) { data[0] = 0; mask[0] = 0; } else { data[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 3; /* the data may be 0, 1, or 3. not 2. In Egress it also can't be 0. */ if(data[0] == 2) { ++(data[0]); } if(data[0] == 0 && stage == _BCM_DPP_FIELD_STAGE_INDEX_EGRESS) { ++(data[0]); } i = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; if(i == 0) { mask[0] = 0; } else { mask[0] = 0x3; } } } else if (qualifier == bcmFieldQualifyInnerTpid) { data[0] = 0x8100; } else if (qualifier == bcmFieldQualifyOuterTpid) { i = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; if(i == 0) { data[0] = 0x8100; } else { data[0] = 0x9100; } /* The data may be changed, because if there is single valn it may be 0x8100, * and in there is inner vlan also it may be 0x9100 */ } else if(qualifier == bcmFieldQualifyEtherType || qualifier == bcmFieldQualifyInnerEtherType) { do { /* The data can't be 0x5dc or below because it will not be translated as ethertype */ data[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % (0x10000 - 0x5dd); data[0] += 0x5dd; mask[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 0x10000; data[0] &= mask[0]; } /* in all if this case the ethertype will be identified as vlan and not ethertype */ while(data[0] == 0x8100 || data[0] == 0x88a8 || data[0] == 0x9100 || data[0] == 0x9200 || data[0] == 0x9300 || data[0] < 0x5dd); /* in case that we use ipv4 ipv6 or mpls headers the value and mask may be changed */ } else if(qualifier == bcmFieldQualifyISid || qualifier == bcmFieldQualifyTrillEgressRbridge) { /* This qualifiers' relevant size is 16 although it is 24 */ data[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 0x10000; mask[0] = (_bcm_petra_field_rand_val(x, second_rand_param++) % (0x10000 - 1)) + 1;/* the mast can't be 0 */ data[0] &= mask[0]; } else if(qualifier == bcmFieldQualifyDrop) { /* data is 0 and mask is 0, or data is 1 and mask is 1 */ data[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; mask[0] = data[0]; } else if(qualifier == bcmFieldQualifyL2Learn) { data[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; mask[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; data[0] &= mask[0]; } else if(qualifier == bcmFieldQualifyFlowId) { /* This qualifier's relevant size is 16 although it is 19 */ data[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 0x10000; mask[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 0x10000; data[0] &= mask[0]; } else if(qualifier == bcmFieldQualifyIpInfo) { /* It has only two flags */ uint8 tmp_data = _bcm_petra_field_rand_val(x, second_rand_param++) % 4; uint8 tmp_mask = _bcm_petra_field_rand_val(x, second_rand_param++) % 4; tmp_data &= tmp_mask; data[0] = 0; mask[0] = 0; if((tmp_data & 0x1) && (stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) ) { data[0] |= BCM_FIELD_IP_CHECKSUM_OK; } if(tmp_data & 0x2) { data[0] |= BCM_FIELD_IP_VERSION_ERR; } if((tmp_data & 0x1) && (stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) ) { mask[0] |= BCM_FIELD_IP_CHECKSUM_OK; } if(tmp_mask & 0x2) { mask[0] |= BCM_FIELD_IP_VERSION_ERR; } } else if(qualifier == bcmFieldQualifyDstMac) { /* we don't want that data == 0 && mask == 1 */ do { data[0] = _bcm_petra_field_rand_val(x, second_rand_param++); mask[0] = _bcm_petra_field_rand_val(x, second_rand_param++); data[0] &= mask[0]; data[1] = _bcm_petra_field_rand_val(x, second_rand_param++) % 0x10000; mask[1] = _bcm_petra_field_rand_val(x, second_rand_param++) % 0x10000; data[1] &= mask[1]; } while (data[0] == 0 && mask[0] == 0xffffffff && data[1] == 0 && mask[1] == 0xffff); } else if(qualifier == bcmFieldQualifyForwardCopy || qualifier == bcmFieldQualifyMirrorCopy || qualifier == bcmFieldQualifySnoopCopy ) { /* In all these cases the data and mask can be 0 or 1 only */ data[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; mask[0] = data[0]; } else if(qualifier == bcmFieldQualifyFheiSize) { /* The data can be one of 0,3,5,8 ; The mask can be 0x0 or 0x3 only */ i = _bcm_petra_field_rand_val(x, second_rand_param++) % 4; if(i == 0) { data[0] = 0; } else if(i == 1) { data[0] = 3; } else if (i == 2) { data[0] = 5; } else if(i == 3) { data[0] = 8; } mask[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; if(mask[0] == 1) { mask[0] = -1; } data[0] &= mask[0]; } else if(qualifier == bcmFieldQualifyInterfaceClassVPort) { mask[0] = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; } else { if(qualifiers_info[qual_index].size == 0) { if(qualifier == bcmFieldQualifyDstPort) { /* in this case the size is 0, however nothing should be done */ return CMD_OK; } if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "The qualifier %d is not supported \n"), qualifier)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } /* value */ for(i = 0; i < qualifiers_info[qual_index].size; i+=32) { if(qualifiers_info[qual_index].size - i >= 32) { data[i/32] = _bcm_petra_field_rand_val(x, second_rand_param++); } else { data[i/32] = _bcm_petra_field_rand_val(x, second_rand_param++) % (1 << (qualifiers_info[qual_index].size - i)); } } /* mask if needed */ if((prototype >= 0 && prototype <=9) || prototype == 11 || prototype == 12 || prototype == 14 || prototype == 27 || prototype == 28 || prototype == 34) { for(i = 0; i < qualifiers_info[qual_index].size; i+=32) { if(qualifiers_info[qual_index].size - i >= 32) { mask[i/32] = _bcm_petra_field_rand_val(x, second_rand_param++); } else { mask[i/32] = _bcm_petra_field_rand_val(x, second_rand_param++) % (1 << (qualifiers_info[qual_index].size - i)); } data[i/32] &= mask[i/32]; } } } } return CMD_OK; } /* * taking the speed mode and returns the number of iterations. */ STATIC int _bcm_petra_field_test_speed_mode_to_iterations_number(_bcmPetraFieldTestSpeedMode mode, uint8 slow_level, uint32 *nof_iterations) { switch(mode) { case _bcmPetraFieldTestSuperFast: _BCM_PETRA_FIELD_TEST_NOF_ITERATION_SUPER_FAST(slow_level, *nof_iterations); break; case _bcmPetraFieldTestFast: _BCM_PETRA_FIELD_TEST_NOF_ITERATION_FAST(slow_level, *nof_iterations); break; case _bcmPetraFieldTestMedium: _BCM_PETRA_FIELD_TEST_NOF_ITERATION_MEDIUM(slow_level, *nof_iterations); break; case _bcmPetraFieldTestSlow: _BCM_PETRA_FIELD_TEST_NOF_ITERATION_SLOW(slow_level, *nof_iterations); break; case _bcmPetraFieldTestScan: *nof_iterations = _BCM_PETRA_FIELD_TEST_NOF_ITERATION_SCAN; break; default: return 1; } return 0; } /* * This function get empty set, * fills it with max_items items and return vector of the selected items */ STATIC uint32* _bcm_petra_field_create_set( void *set, void (add_function)(void *set, uint32 item), uint8 (test_function)(void *set, uint32 item), int nof_items, void *valid_items_set, uint32 max_items, uint32 x ) { uint32 second_rand_param = 0; uint32 *items; uint32 *valid_items = NULL; uint32 item_idx, index; uint32 item; uint32 nof_valid_items = 0; int unit = BSL_UNIT_UNKNOWN; /* Taking max_items items */ items = sal_alloc(max_items*sizeof(uint32), "_bcm_petra_field_create_set.items"); if(!items) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META("Allocation failure \n"))); } return NULL; } /* counting the number of the valid items. if it smaller or equal to max_items, take all of them */ for(item = 0; item < nof_items; ++item) { if(test_function(valid_items_set, item)) { ++nof_valid_items; } } if(nof_valid_items <= max_items) { item_idx = 0; for(item = 0; item < nof_items; ++item) { if(test_function(valid_items_set, item)) { items[item_idx++] = item; add_function(set, item); } } for(item = nof_valid_items; item < max_items; ++item) { items[item_idx++] = 0xffffffff; /* invalid item */ } return items; } valid_items = sal_alloc(nof_valid_items*sizeof(uint32), "_bcm_petra_field_create_set.valid_items"); if(!valid_items) { sal_free(items); if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META("Allocation failure \n"))); } return NULL; } item_idx = 0; for(item = 0; item < nof_items; ++item) { if(test_function(valid_items_set, item)) { valid_items[item_idx++] = item; } } /* The idea is to take randomly one of the items in valid_items[0 ... nof_valid_items -item_idx], Then take the item in the end of valid_items and put it in the index of this item such that in each iteration valid_items[0 ... nof_valid_items -item_idx] contain the items that haven't been selected */ for(item_idx = 0; item_idx < max_items; ++item_idx) { index = _bcm_petra_field_rand_val(x, second_rand_param++)%(nof_valid_items - item_idx); item = valid_items[index]; valid_items[index] = valid_items[nof_valid_items - item_idx - 1]; items[item_idx] = item; add_function(set, item); } sal_free(valid_items); return items; } /* * This function takes max_items items * add set them to empty set (such as qualifiers set actions set etc.) * Then it takes randomly _BCM_PETRA_FIELD_SET_AND_REMOVE_TEST_NOF_ITEMS_TO_TEST and check if they are in the set. * Then it removes all the items from the set. * Then it verify that no item is in the qse for _BCM_PETRA_FIELD_SET_AND_REMOVE_TEST_NOF_ITEMS_TO_TEST items * return 0 in success and 1 in failure */ STATIC uint8 _bcm_petra_field_add_and_remove_test( void *(init_function)(void), void (add_function)(void *set, uint32 item), void (remove_function)(void *set, uint32 item), uint8 (test_function)(void *set, uint32 item), void (print_function)(const void *set), const char **items_name, int nof_items, void *valid_items_set, uint32 max_items, uint32 x ) { uint32 second_rand_param = 0; uint32 *items; int item_idx, item_idx_2; int item; uint8 is_in_list; uint8 test_res; void *set; int unit = BSL_UNIT_UNKNOWN; /* Creating set*/ set = init_function(); if(!set) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Allocation failure \n"))); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } /* Selecting items */ items = _bcm_petra_field_create_set(set, add_function, test_function, nof_items, valid_items_set, max_items, x); if(!items) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } /* Printing the list */ if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VVERB) { print_function(set); } /* Testing */ for(item_idx = 0; item_idx < _BCM_PETRA_FIELD_SET_AND_REMOVE_TEST_NOF_ITEMS_TO_TEST; ++item_idx) { item = _bcm_petra_field_rand_val(x, second_rand_param++) % nof_items; test_res = test_function(set, item); is_in_list = FALSE; for(item_idx_2 = 0; item_idx_2 < max_items; ++item_idx_2) { if(items[item_idx_2] == item) { is_in_list = TRUE; break; } } if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { if(test_res && is_in_list) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "%s is in the list and the test function returned true - OK\n"), items_name[item])); } else if(!test_res && !is_in_list) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "%s is in not the list and the test function returned false - OK\n"), items_name[item])); }else if(test_res) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "FAILURE: %s is in not the list and the test function returned true\n"), items_name[item])); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "x = %d\n"), x)); sal_free(items); sal_free(set); _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } else { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "FAILURE: %s is in the list and the test function returned false\n"), items_name[item])); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "x = %d\n"), x)); sal_free(items); sal_free(set); _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } } } if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "end\n\n"))); } /* Remove all the items */ for(item_idx = 0; item_idx < max_items; ++item_idx) { if(items[item_idx] == 0xffffffff) { /* i.e. All the valid items have been taken and the other marked as invalid */ break; } remove_function(set, items[item_idx]); } if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "All the items removed\n"))); } /* Verifying that there is no items */ for(item_idx = 0; item_idx < max_items; ++item_idx) { if(items[item_idx] != 0xffffffff && test_function(set, items[item_idx])) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "FAILURE: %s is in not the list and the test function returned true\n"), items_name[items[item_idx]])); } if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "x = %d\n"), x)); } sal_free(items); sal_free(set); _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } } sal_free(items); sal_free(set); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "The add and remove test finished successfully\n\n"))); return 0; } /* * This function takes one item * add set it to empty set (such as qualifiers set actions set etc.) * Then it takes randomly _BCM_PETRA_FIELD_SET_AND_REMOVE_TEST_NOF_ITEMS_TO_TEST and check if they are in the set. * Then it removes this item from the set. * Then it verify that the set is empty * return 0 in success and 1 in failure */ STATIC uint8 _bcm_petra_field_add_and_remove_scan_test( void *(init_function)(void), void (add_function)(void *set, uint32 item), void (remove_function)(void *set, uint32 item), uint8 (test_function)(void *set, uint32 item), void (print_function)(const void *set), const char **items_name, int nof_items ) { int item_idx; uint32 cur_item; int item; uint8 test_res; void *set; uint8 failure = FALSE; int unit = BSL_UNIT_UNKNOWN; /* Creating set*/ set = init_function(); if(!set) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Allocation failure \n"))); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } for(cur_item = 0; cur_item < nof_items; ++cur_item) { add_function(set, cur_item); /* Printing the list */ if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VVERB) { print_function(set); } /* Testing */ for(item_idx = 0; item_idx < _BCM_PETRA_FIELD_SET_AND_REMOVE_TEST_NOF_ITEMS_TO_TEST; ++item_idx) { item = sal_rand() % nof_items; test_res = test_function(set, item); if(test_res && item == cur_item) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "%s is in the list and the test function returned true - OK\n"), items_name[item])); } } else if(!test_res && item != cur_item) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "%s is in not the list and the test function returned false - OK\n"), items_name[item])); } }else if(test_res) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "FAILURE: %s is in not the list and the test function returned true\n"), items_name[item])); _BCM_PETRA_FIELD_TEST_FAIL_MSG; failure = TRUE; } } else { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "FAILURE: %s is in the list and the test function returned false\n"), items_name[item])); _BCM_PETRA_FIELD_TEST_FAIL_MSG; failure = TRUE; } } } if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "end\n\n"))); } /* Remove the item */ remove_function(set, cur_item); if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "All the items removed\n"))); } /* Verifying that there is no item */ if(test_function(set, cur_item)) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "FAILURE: %s is in not the list and the test function returned true\n"), items_name[cur_item])); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; failure = TRUE; } } sal_free(set); if(!failure){ LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "The add and remove test finished successfully\n\n"))); } return failure; } /* * The function gets the set of valid qualifiers and actions for specific type selected randomly * Return 0 in success, 1 in failure * if type is 0 then type will be chosen randomly, otherwise it will take the required type */ uint8 _bcm_petra_field_test_qualify_and_action_get_valid_set(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 x, int type, bcm_field_qset_t *valid_qset, bcm_field_aset_t *valid_aset) { uint32 second_rand_param=0; bcm_field_qset_t valid_qset_get; bcm_field_aset_t valid_aset_get; bcm_error_t rv; if(type == 0) { type = _bcm_petra_field_rand_val(x, second_rand_param++) % _BCM_PETRA_FIELD_NOF_TYPES; } rv = _bcm_dpp_field_stage_type_qset_aset_get(unit, stage, type, &valid_qset_get, &valid_aset_get); if(rv) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } if(valid_aset) { *valid_aset = valid_aset_get; } if(valid_qset) { *valid_qset = valid_qset_get; } return 0; } uint8 _bcm_petra_field_test_qualify_get_valid_set(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 x, bcm_field_qset_t *valid_set) { return _bcm_petra_field_test_qualify_and_action_get_valid_set(unit, stage, x, 0, valid_set, NULL); } STATIC void* _bcm_petra_field_test_qualify_set_init(void) { bcm_field_qset_t *init = sal_alloc(sizeof(bcm_field_qset_t), 0); BCM_FIELD_QSET_INIT(*init); return init; } /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ /*******************************************************************************/ STATIC void _bcm_petra_field_test_qualify_set_add(bcm_field_qset_t *set, uint32 item) { BCM_FIELD_QSET_ADD(*set, item); } STATIC void _bcm_petra_field_test_qualify_set_remove(bcm_field_qset_t *set, uint32 item) { BCM_FIELD_QSET_REMOVE(*set, item); } STATIC uint8 _bcm_petra_field_test_qualify_set_test(bcm_field_qset_t *set, uint32 item) { return (BCM_FIELD_QSET_TEST(*set, item) != 0); } STATIC void _bcm_petra_field_qualify_set_print(const bcm_field_qset_t *qset) { #ifdef BROADCOM_DEBUG LOG_CLI((BSL_META("Printing the qualifiers in the set:\n"))); _bcm_dpp_field_qset_dump(*qset, "bcmFieldQualify"); LOG_CLI((BSL_META("--- The end of the set ---\n\n"))); #endif /* BROADCOM_DEBUG */ } cmd_result_t _bcm_petra_field_test_qualify_set(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 x, _bcmPetraFieldTestSpeedMode mode, uint8 do_warmboot) { uint32 nof_iterations; uint32 iteration_idx; const static char *item_names[] = BCM_FIELD_QUALIFY_STRINGS; bcm_field_qset_t valid_set; if(x == 0) { if(_bcm_petra_field_test_speed_mode_to_iterations_number(mode, 0, &nof_iterations)){ _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } else { nof_iterations = 1; } LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Test of add and remove for qualify set\n"))); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Test Name : qset, stage : %s.\n"), _BCM_PETRA_FIELD_TEST_STAGE_TO_STRING(stage))); if(nof_iterations == _BCM_PETRA_FIELD_TEST_NOF_ITERATION_SCAN) { return _bcm_petra_field_add_and_remove_scan_test( (void* (*)(void)) _bcm_petra_field_test_qualify_set_init, (void (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_add, (void (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_remove, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_test, (void (*)(const void*)) _bcm_petra_field_qualify_set_print, item_names, bcmFieldQualifyCount); } for(iteration_idx = 0; iteration_idx < nof_iterations; ++iteration_idx) { if(iteration_idx > 0 || x == 0) { x = sal_rand(); } if(_bcm_petra_field_test_qualify_get_valid_set(unit, stage, x, &valid_set)) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Getting the valid items set failed\n"))); } if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "x = %d\n"), x)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(_bcm_petra_field_add_and_remove_test( (void* (*)(void)) _bcm_petra_field_test_qualify_set_init, (void (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_add, (void (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_remove, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_test, (void (*)(const void*)) _bcm_petra_field_qualify_set_print, item_names, bcmFieldQualifyCount, &valid_set, 16, x) ) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } return CMD_OK; } uint8 _bcm_petra_field_test_action_get_valid_set(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 x, bcm_field_aset_t *valid_set) { return _bcm_petra_field_test_qualify_and_action_get_valid_set(unit, stage, x, 0, NULL, valid_set); } STATIC void* _bcm_petra_field_test_action_set_init(void) { bcm_field_aset_t *init = sal_alloc(sizeof(bcm_field_aset_t), 0); BCM_FIELD_ASET_INIT(*init); return init; } STATIC void _bcm_petra_field_test_action_set_add(bcm_field_aset_t *set, uint32 item) { BCM_FIELD_ASET_ADD(*set, item); } STATIC void _bcm_petra_field_test_action_set_remove(bcm_field_aset_t *set, uint32 item) { BCM_FIELD_ASET_REMOVE(*set, item); } STATIC uint8 _bcm_petra_field_test_action_set_test(bcm_field_aset_t *set, uint32 item) { return (BCM_FIELD_ASET_TEST(*set, item) != 0); } STATIC void _bcm_petra_field_action_set_print(const bcm_field_aset_t *aset) { #ifdef BROADCOM_DEBUG LOG_CLI((BSL_META("Printing the actions in the set:\n"))); _bcm_dpp_field_aset_dump(aset, "bcmFieldAction"); LOG_CLI((BSL_META("--- The end of the set ---\n\n"))); #endif } cmd_result_t _bcm_petra_field_test_action_set(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 x, _bcmPetraFieldTestSpeedMode mode, uint8 do_warmboot) { uint32 nof_iterations; uint32 iteration_idx; const static char *item_names[] = BCM_FIELD_ACTION_STRINGS; bcm_field_aset_t valid_set; if(x == 0) { if(_bcm_petra_field_test_speed_mode_to_iterations_number(mode, 0, &nof_iterations)){ _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } else { nof_iterations = 1; } LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Test of add and remove for action set\n"))); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Test Name : aset, stage : %s.\n"), _BCM_PETRA_FIELD_TEST_STAGE_TO_STRING(stage))); if(nof_iterations == _BCM_PETRA_FIELD_TEST_NOF_ITERATION_SCAN) { return _bcm_petra_field_add_and_remove_scan_test( (void* (*)(void)) _bcm_petra_field_test_action_set_init, (void (*)(void*, uint32)) _bcm_petra_field_test_action_set_add, (void (*)(void*, uint32)) _bcm_petra_field_test_action_set_remove, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_action_set_test, (void (*)(const void*)) _bcm_petra_field_action_set_print, item_names, bcmFieldActionCount); } for(iteration_idx = 0; iteration_idx < nof_iterations; ++iteration_idx) { if(iteration_idx > 0 || x == 0) { x = sal_rand(); } if(_bcm_petra_field_test_action_get_valid_set(unit, stage, x, &valid_set)) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Getting the valid items set failed\n"))); } if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "x = %d\n"), x)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(_bcm_petra_field_add_and_remove_test( (void* (*)(void)) _bcm_petra_field_test_action_set_init, (void (*)(void*, uint32)) _bcm_petra_field_test_action_set_add, (void (*)(void*, uint32)) _bcm_petra_field_test_action_set_remove, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_action_set_test, (void (*)(const void*)) _bcm_petra_field_action_set_print, item_names, bcmFieldActionCount, &valid_set, 8, x) ) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } return CMD_OK; } uint8 _bcm_petra_field_test_data_qualifier_get_valid_set(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 x, bcm_field_qset_t *valid_set) { uint32 data_qual_id; bcm_error_t rv; BCM_FIELD_QSET_INIT(*valid_set); for(data_qual_id = 0; data_qual_id <= _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID(unit); ++data_qual_id) { rv = bcm_field_qset_data_qualifier_add(unit, valid_set, data_qual_id); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } } return 0; } STATIC void* _bcm_petra_field_test_data_qualifier_set_init(void) { bcm_field_qset_t *init = sal_alloc(sizeof(bcm_field_qset_t), 0); BCM_FIELD_QSET_INIT(*init); return init; } static int data_qualifier_add_remove_test_unit; STATIC void _bcm_petra_field_test_data_qualifier_set_add(bcm_field_qset_t *set, uint32 item) { bcm_error_t rv; rv = bcm_field_qset_data_qualifier_add(data_qualifier_add_remove_test_unit, set, item); if(rv != BCM_E_NONE) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META("Failure in bcm_field_qset_data_qualifier_add\n"))); } } STATIC void _bcm_petra_field_test_data_qualifier_set_remove(bcm_field_qset_t *set, uint32 item) { bcm_error_t rv; rv = bcm_field_qset_data_qualifier_delete(data_qualifier_add_remove_test_unit, set, item); if(rv != BCM_E_NONE) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META("Failure in bcm_field_qset_data_qualifier_delete\n"))); } } STATIC uint8 _bcm_petra_field_test_data_qualifier_set_test(bcm_field_qset_t *set, uint32 item) { int qual_arr[_BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID_ALL + 1]; int qual_count; int qual_idx; bcm_error_t rv; rv = bcm_field_qset_data_qualifier_get(data_qualifier_add_remove_test_unit, *set, _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID(data_qualifier_add_remove_test_unit) + 1, qual_arr, &qual_count); if(rv != BCM_E_NONE) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META("Failure in bcm_field_qset_data_qualifier_get\n"))); } for(qual_idx = 0; qual_idx < qual_count; ++qual_idx) { if(qual_arr[qual_idx] == item) { return 1; } } return 0; } STATIC void _bcm_petra_field_data_qualifier_set_print(const bcm_field_qset_t *qset) { #ifdef BROADCOM_DEBUG int qual_arr[_BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID_ALL + 1]; int qual_count; int qual_idx; bcm_error_t rv; bcm_field_qset_t lcl_qset; int unit = BSL_UNIT_UNKNOWN; sal_memcpy(&lcl_qset, qset, sizeof(bcm_field_qset_t)); LOG_CLI((BSL_META_U(unit, "Printing the presel ids in the set:\n"))); rv = bcm_field_qset_data_qualifier_get(data_qualifier_add_remove_test_unit, lcl_qset, _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID(data_qualifier_add_remove_test_unit) + 1, qual_arr, &qual_count); if(rv != BCM_E_NONE) { LOG_CLI((BSL_META_U(unit, "Failure in bcm_field_qset_data_qualifier_get\n"))); } for(qual_idx = 0; qual_idx < qual_count; ++qual_idx) { LOG_CLI((BSL_META_U(unit, "%d "), qual_arr[qual_idx])); } LOG_CLI((BSL_META_U(unit, "\n"))); LOG_CLI((BSL_META_U(unit, "--- The end of the set ---\n\n"))); #endif /* BROADCOM_DEBUG */ } cmd_result_t _bcm_petra_field_test_data_qualifier_set(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 x, _bcmPetraFieldTestSpeedMode mode, uint8 do_warmboot) { uint32 nof_iterations; uint32 iteration_idx; const static char *item_names[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "60", "61", "62", "63"}; bcm_field_qset_t valid_set; if(x == 0) { if(_bcm_petra_field_test_speed_mode_to_iterations_number(mode, 0, &nof_iterations)){ _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } else { nof_iterations = 1; } LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Test of add and remove for data qualifier set\n"))); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Test Name : data_qualifier_set, stage : %s.\n"), _BCM_PETRA_FIELD_TEST_STAGE_TO_STRING(stage))); if(nof_iterations == _BCM_PETRA_FIELD_TEST_NOF_ITERATION_SCAN) { return _bcm_petra_field_add_and_remove_scan_test( (void* (*)(void)) _bcm_petra_field_test_data_qualifier_set_init, (void (*)(void*, uint32)) _bcm_petra_field_test_data_qualifier_set_add, (void (*)(void*, uint32)) _bcm_petra_field_test_data_qualifier_set_remove, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_data_qualifier_set_test, (void (*)(const void*)) _bcm_petra_field_data_qualifier_set_print, item_names, _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID(unit) + 1); } data_qualifier_add_remove_test_unit = unit; for(iteration_idx = 0; iteration_idx < nof_iterations; ++iteration_idx) { if(iteration_idx > 0 || x == 0) { x = sal_rand(); } if(_bcm_petra_field_test_data_qualifier_get_valid_set(unit, stage, x, &valid_set)) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Getting the valid items set failed\n"))); } if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "x = %d\n"), x)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(_bcm_petra_field_add_and_remove_test( (void* (*)(void)) _bcm_petra_field_test_data_qualifier_set_init, (void (*)(void*, uint32)) _bcm_petra_field_test_data_qualifier_set_add, (void (*)(void*, uint32)) _bcm_petra_field_test_data_qualifier_set_remove, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_data_qualifier_set_test, (void (*)(const void*)) _bcm_petra_field_data_qualifier_set_print, item_names, _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID(unit) + 1, &valid_set, 8, x) ) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } return CMD_OK; } STATIC bcm_error_t _bcm_petra_field_test_qualifier_is_lsb_is_msb(int unit, bcm_field_qualify_t qualifier, uint8 *is_lsb, uint8 *is_msb) { bcm_dpp_field_info_OLD_t *unitData; SOC_PPC_FP_QUAL_TYPE *soc_ppd_qual_ptr; uint8 is_lsb_lcl[_BCM_PETRA_FIELD_QUAL_CHAIN], is_msb_lcl[_BCM_PETRA_FIELD_QUAL_CHAIN]; bcm_error_t rv; uint32 ppd_qual_idx; BCMDNX_INIT_FUNC_DEFS; _DPP_FIELD_UNIT_CHECK(unit, unitData); rv = _bcm_dpp_ppd_qual_from_bcm_qual(unitData, _BCM_DPP_FIELD_STAGE_INDEX_INGRESS, 0xff, qualifier, &soc_ppd_qual_ptr); BCM_IF_ERROR_RETURN(rv); for(ppd_qual_idx = 0; ppd_qual_idx < _BCM_PETRA_FIELD_QUAL_CHAIN; ++ppd_qual_idx) { uint32 soc_sand_res; ARAD_PMF_CE_IRPP_QUALIFIER_INFO junk; soc_sand_res = arad_pmf_ce_internal_field_info_find(unit, soc_ppd_qual_ptr[ppd_qual_idx], _BCM_DPP_FIELD_STAGE_INDEX_INGRESS, FALSE, &is_lsb_lcl[ppd_qual_idx], &junk); SOC_SAND_IF_ERR_EXIT(soc_sand_res); soc_sand_res = arad_pmf_ce_internal_field_info_find(unit, soc_ppd_qual_ptr[ppd_qual_idx], _BCM_DPP_FIELD_STAGE_INDEX_INGRESS, TRUE, &is_msb_lcl[ppd_qual_idx], &junk); SOC_SAND_IF_ERR_EXIT(soc_sand_res); if(!is_lsb_lcl[ppd_qual_idx] && !is_msb_lcl[ppd_qual_idx]) { is_lsb_lcl[ppd_qual_idx] = TRUE; is_msb_lcl[ppd_qual_idx] = TRUE; } } if(is_lsb) { *is_lsb = TRUE; } if(is_msb) { *is_msb = TRUE; } for(ppd_qual_idx = 0; ppd_qual_idx < _BCM_PETRA_FIELD_QUAL_CHAIN; ++ppd_qual_idx) { if(!is_lsb_lcl[ppd_qual_idx]) { if(is_lsb) { *is_lsb = FALSE; } } if(!is_msb_lcl[ppd_qual_idx]) { if(is_msb) { *is_msb = FALSE; } } } exit: BCMDNX_FUNC_RETURN; } /* Available resources for single program */ STATIC uint32 lsb_ces; STATIC uint32 msb_ces; #if defined(INCLUDE_KBP) STATIC uint32 total_nof_ces; #endif /* defined(INCLUDE_KBP) */ STATIC uint32 nof_actions; /* Available resources for single field group */ STATIC uint32 lsb_qualifiers_available_length; STATIC uint32 msb_qualifiers_available_length; /* function for verifying available resources * * _bcm_petra_field_test_reset_resources - reset the available resources * * _bcm_petra_field_test_reset_field_group_resources - reset the available resources for single field group * * _bcm_petra_field_test_take_qualifier - check that we can add qualifier to field group without copy engines overflow * * _bcm_petra_field_test_take_action - verify that we can have another action without overflow the maximal actions */ STATIC void _bcm_petra_field_test_reset_resources(void) { lsb_ces = 16; msb_ces = 16; nof_actions = 32; } STATIC void _bcm_petra_field_test_reset_field_group_resources(uint32 maximal_key_length){ lsb_qualifiers_available_length = maximal_key_length; msb_qualifiers_available_length = maximal_key_length; } #if defined(INCLUDE_KBP) STATIC void _bcm_petra_field_test_kbp_reset_resources(void) { total_nof_ces = 4; } #endif /* defined(INCLUDE_KBP) */ STATIC uint8 _bcm_petra_field_test_take_action(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, uint32 action) { if(nof_actions){ --nof_actions; return TRUE; } return FALSE; } /* * get the number of resources for qualifier in the worst case. * it take its hardware length for each of the possible hardware qualifiers, and any 16 bits or less may take 1 c.e. * it determines also the number of hardware qualifiers */ STATIC bcm_error_t _bcm_petra_field_test_qualify_get_nof_resorces(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_qualify_t qualify, uint32 *nof_ces, uint32 *nof_hw_quals) { bcm_dpp_field_info_OLD_t *unitData; SOC_PPC_FP_QUAL_TYPE *soc_ppd_qual_ptr; bcm_error_t rv; unsigned int exposed, hardwareBestCase, hardwareWorstCase; uint32 ppd_qual_idx; BCMDNX_INIT_FUNC_DEFS; _DPP_FIELD_UNIT_CHECK(unit, unitData); rv = _bcm_dpp_ppd_qual_from_bcm_qual(unitData, stage, 1 << type, qualify, &soc_ppd_qual_ptr); BCM_IF_ERROR_RETURN(rv); if(nof_ces) { *nof_ces = 0; } for(ppd_qual_idx = 0; ppd_qual_idx < _BCM_PETRA_FIELD_QUAL_CHAIN; ++ppd_qual_idx) { if( (soc_ppd_qual_ptr[ppd_qual_idx] < SOC_PPC_NOF_FP_QUAL_TYPES) && (soc_ppd_qual_ptr[ppd_qual_idx] != BCM_FIELD_ENTRY_INVALID)) { if(nof_hw_quals) { *nof_hw_quals = ppd_qual_idx + 1; } rv = _bcm_dpp_ppd_qual_bits(unit, stage, soc_ppd_qual_ptr[ppd_qual_idx], &exposed, &hardwareBestCase, &hardwareWorstCase); BCM_IF_ERROR_RETURN(rv); if(nof_ces) { *nof_ces += hardwareWorstCase / 16; if(hardwareWorstCase % 16) { ++(*nof_ces); } } } } exit: BCMDNX_FUNC_RETURN; } STATIC uint8 _bcm_petra_field_test_take_qualifier(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, uint32 qualifier) { bcm_error_t rv; uint8 is_lsb, is_msb; uint32 nof_ces = 0; uint32 qual_length; rv = _bcm_petra_field_test_qualifier_is_lsb_is_msb(unit, (bcm_field_qualify_t) qualifier, &is_lsb, &is_msb); if(rv != BCM_E_NONE) { return FALSE; } rv = _bcm_petra_field_test_qualify_get_nof_resorces(unit, stage, type, (bcm_field_qualify_t) qualifier, &nof_ces, NULL); if(rv != BCM_E_NONE) { return FALSE; } rv = _bcm_petra_field_test_qualify_hardware_length_worst(unit, stage, type, (bcm_field_qualify_t) qualifier, &qual_length); if(rv != BCM_E_NONE) { return FALSE; } #if defined(INCLUDE_KBP) /* In this case the limit is not tp take more than 4 ces. */ if(stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { if(nof_ces < total_nof_ces) { total_nof_ces-=nof_ces; return TRUE; } return FALSE; } #endif /* defined(INCLUDE_KBP) */ if (SOC_IS_JERICHO(unit)) { if (lsb_ces >= nof_ces) { lsb_ces -= nof_ces; } else if (msb_ces >= nof_ces) { msb_ces -= nof_ces; } else { return FALSE; } } else { /* if the qualifier is only one of them it will take only msb or lsb. * if the qualifier can be both of them, we may not know which c.e. will be taken, assume that it will take msb and lsb */ if(is_lsb && lsb_ces < nof_ces) { return FALSE; } if(is_msb && msb_ces < nof_ces) { return FALSE; } /* verify no exceed of the lsb and msb buffer. * if the qualifier can be nor lsb either msb, we can be confident * because of the check that the total length doen't excess the maximal key length */ if(is_lsb && !is_msb && qual_length > lsb_qualifiers_available_length) { return FALSE; } if(is_msb && !is_lsb && qual_length > msb_qualifiers_available_length) { return FALSE; } if(is_lsb) { lsb_ces -= nof_ces; if(!is_msb) { lsb_qualifiers_available_length -= qual_length; } } if(is_msb) { msb_ces -= nof_ces; if(!is_lsb) { msb_qualifiers_available_length -= qual_length; } } } return TRUE; } /* * This function get empty set, * fills it with items and while the length doesn't excess the max_length */ STATIC bcm_error_t _bcm_petra_field_create_set_max_length( int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, void *set, void (add_function)(void *set, uint32 item), uint8 (test_function)(void *set, uint32 item), bcm_error_t (length_function)(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, uint32 item, uint32 *length), bcm_error_t (can_be_both)(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, uint32 item1, uint32 item2, uint8 *res), uint8 (take_resource_function)(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, uint32 item), int nof_items, void *valid_items_set, uint32 max_length, uint32 max_items, uint32 x ) { bcm_error_t rv; uint32 second_rand_param = 0; uint32 nof_items_in_set; uint32 item_idx; uint8 to_continue; int last_avail_item_ndx; uint32 item; uint32 length = 0, item_length; int *items_not_selected_yet; uint8 can_insert; uint32 *selected_items = NULL; int exit_code ; int ret ; ret = 0 ; exit_code = 0 ; items_not_selected_yet = sal_alloc(nof_items*sizeof(int), "_bcm_petra_field_create_set_max_length.items_not_selected_yet"); if(!items_not_selected_yet) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Memory allocation failure\n"))); _BCM_PETRA_FIELD_TEST_FAIL_MSG; ret = BCM_E_FAIL; exit_code = 5 ; goto exit ; } selected_items = sal_alloc(max_items*sizeof(int), "_bcm_petra_field_create_set_max_length.max_items"); if(!selected_items) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Memory allocation failure\n"))); sal_free(items_not_selected_yet); _BCM_PETRA_FIELD_TEST_FAIL_MSG; ret = BCM_E_FAIL; exit_code = 6 ; goto exit ; } for(item_idx = 0; item_idx <nof_items; ++item_idx) { items_not_selected_yet[item_idx] = item_idx; } last_avail_item_ndx = nof_items - 1; while (last_avail_item_ndx > 0) { if (!test_function(valid_items_set, items_not_selected_yet[last_avail_item_ndx])) { last_avail_item_ndx--; } else { break; } } for(nof_items_in_set = 0; nof_items_in_set < max_items && length < max_length ; ++nof_items_in_set) { do { do { item_idx = _bcm_petra_field_rand_val(x, second_rand_param++)% (last_avail_item_ndx + 1); item = items_not_selected_yet[item_idx]; items_not_selected_yet[item_idx] = items_not_selected_yet[last_avail_item_ndx--]; } while(last_avail_item_ndx >= 0 && !test_function(valid_items_set, item)); if(last_avail_item_ndx < 0) { /* i.e all the valid items selected */ sal_free(items_not_selected_yet); sal_free(selected_items); if(nof_items_in_set == 0) { /* i.e. no item has been selected */ _BCM_PETRA_FIELD_TEST_FAIL_MSG; ret = BCM_E_FAIL; exit_code = 7 ; goto exit ; } else { ret = BCM_E_NONE; exit_code = 8 ; goto exit ; } } to_continue = FALSE; /* check that the new item can be with all the previous */ for(item_idx = 0; item_idx < nof_items_in_set; ++item_idx) { rv = can_be_both(unit, stage, type, item, selected_items[item_idx], &can_insert); if(rv != BCM_E_NONE) { sal_free(items_not_selected_yet); sal_free(selected_items); _BCM_PETRA_FIELD_TEST_FAIL_MSG; ret = rv ; exit_code = 9 ; goto exit ; } if(!can_insert) { to_continue = TRUE; break; } } if(to_continue) { continue; } /* updating the length */ rv = length_function(unit, stage, type, item, &item_length); if(rv != BCM_E_NONE) { sal_free(items_not_selected_yet); sal_free(selected_items); _BCM_PETRA_FIELD_TEST_FAIL_MSG; ret = rv ; exit_code = 10 ; goto exit ; } if((length + item_length <= max_length) && take_resource_function(unit, stage, type, item)) { add_function(set, item); length += item_length; selected_items[nof_items_in_set] = item; } else { /* Try to take shorter item */ to_continue = TRUE; } } while(to_continue); } sal_free(items_not_selected_yet); sal_free(selected_items); ret = BCM_E_NONE; goto exit ; exit: if (exit_code) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Error exit. Exit code %d\r\n"),exit_code)) ; } return (ret) ; } STATIC bcm_error_t _bcm_petra_field_test_qualify_can_be_both(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_qualify_t qualify1, bcm_field_qualify_t qualify2, uint8 *answer) { bcm_dpp_field_info_OLD_t *unitData; SOC_PPC_FP_QUAL_TYPE *soc_ppd_qual_ptr1, *soc_ppd_qual_ptr2; bcm_error_t rv; uint32 ppd_qual_idx1, ppd_qual_idx2; BCMDNX_INIT_FUNC_DEFS; _DPP_FIELD_UNIT_CHECK(unit, unitData); rv = _bcm_dpp_ppd_qual_from_bcm_qual(unitData, stage, (type == 0xffffffff) ? 0xf : (1 << type), qualify1, &soc_ppd_qual_ptr1); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; LOG_ERROR(BSL_LS_BCM_FP, (BSL_META_U(unit, "qualify1 %d\n"), qualify1)); goto exit; } rv = _bcm_dpp_ppd_qual_from_bcm_qual(unitData, stage, (type == 0xffffffff) ? 0xf : (1 << type), qualify2, &soc_ppd_qual_ptr2); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; LOG_ERROR(BSL_LS_BCM_FP, (BSL_META_U(unit, "qualify2 %d\n"), qualify2)); goto exit; } for(ppd_qual_idx1 = 0; ppd_qual_idx1 < _BCM_PETRA_FIELD_QUAL_CHAIN; ++ppd_qual_idx1) { for(ppd_qual_idx2 = 0; ppd_qual_idx2 < _BCM_PETRA_FIELD_QUAL_CHAIN; ++ppd_qual_idx2) { if((soc_ppd_qual_ptr1[ppd_qual_idx1] < SOC_PPC_NOF_FP_QUAL_TYPES ) && (soc_ppd_qual_ptr1[ppd_qual_idx1] != BCM_FIELD_ENTRY_INVALID ) && soc_ppd_qual_ptr1[ppd_qual_idx1] == soc_ppd_qual_ptr2[ppd_qual_idx2]) { *answer = FALSE; BCM_EXIT; } } } *answer = TRUE; exit: BCMDNX_FUNC_RETURN; } STATIC bcm_error_t _bcm_petra_field_test_data_qualifiers_can_be_both(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, uint32 item1, uint32 item2, uint8 *answer) { /* we check this only for predefined data qualifiers */ bcm_error_t rv; bcm_field_data_qualifier_t dq1, dq2; rv = bcm_field_data_qualifier_get(unit, item1, &dq1); if(rv != BCM_E_NONE) { return rv; } rv = bcm_field_data_qualifier_get(unit, item2, &dq2); if(rv != BCM_E_NONE) { return rv; } if((dq1.flags & BCM_FIELD_DATA_QUALIFIER_OFFSET_PREDEFINED) && (dq2.flags & BCM_FIELD_DATA_QUALIFIER_OFFSET_PREDEFINED)) { return _bcm_petra_field_test_qualify_can_be_both(unit, stage, 0xffffffff, dq1.qualifier, dq2.qualifier, answer); } *answer = TRUE; return BCM_E_NONE; } STATIC bcm_error_t _bcm_petra_field_test_action_can_be_both(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_action_t action1, bcm_field_action_t action2, uint8 *answer) { bcm_dpp_field_info_OLD_t *unitData; SOC_PPC_FP_ACTION_TYPE *soc_ppd_action_ptr1, *soc_ppd_action_ptr2; bcm_error_t rv; uint32 ppd_action_idx1, ppd_action_idx2; BCMDNX_INIT_FUNC_DEFS; _DPP_FIELD_UNIT_CHECK(unit, unitData); rv = _bcm_dpp_ppd_act_from_bcm_act(unitData, stage, action1, &soc_ppd_action_ptr1); BCM_IF_ERROR_RETURN(rv); rv = _bcm_dpp_ppd_act_from_bcm_act(unitData, stage, action2, &soc_ppd_action_ptr2); BCM_IF_ERROR_RETURN(rv); for(ppd_action_idx1 = 0; ppd_action_idx1 < _BCM_PETRA_FIELD_ACTION_CHAIN; ++ppd_action_idx1) { for(ppd_action_idx2 = 0; ppd_action_idx2 < _BCM_PETRA_FIELD_ACTION_CHAIN; ++ppd_action_idx2) { if((soc_ppd_action_ptr1[ppd_action_idx1] < SOC_PPC_NOF_FP_ACTION_TYPES) && (soc_ppd_action_ptr1[ppd_action_idx1] != BCM_FIELD_ENTRY_INVALID) && (soc_ppd_action_ptr1[ppd_action_idx1] == soc_ppd_action_ptr2[ppd_action_idx2])) { *answer = FALSE; BCM_EXIT; } } } *answer = TRUE; exit: BCMDNX_FUNC_RETURN; } static const bcm_field_qset_t *get_set_get_qual_failure(void){ const static bcm_field_qualify_t set_get_qual_failure[] = { /* Range Qualifiers */ bcmFieldQualifyPacketLengthRangeCheck, bcmFieldQualifyRangeCheck, bcmFieldQualifyVPortRangeCheck, bcmFieldQualifyRxTrapCode, bcmFieldQualifySrcIp6High, bcmFieldQualifyDstIp6High, bcmFieldQualifyDstL3Egress, bcmFieldQualifyConstantZero, bcmFieldQualifyConstantOne, bcmFieldQualifyFlowId, bcmFieldQualifyAppType, bcmFieldQualifyContainer, bcmFieldQualifySrcTMPort, bcmFieldQualifyInVportDataIndex, bcmFieldQualifyTunnelTerminationProcessingProfile, bcmFieldQualifyForwardCode, bcmFieldQualifyPphType, bcmFieldQualifyInDscpExp }; static uint8 is_set = FALSE; static bcm_field_qset_t qset; uint32 i; if(!is_set){ BCM_FIELD_QSET_INIT(qset); for(i = 0; i < sizeof(set_get_qual_failure)/sizeof(bcm_field_qualify_t); ++i) { BCM_FIELD_QSET_ADD(qset, set_get_qual_failure[i]); } is_set = TRUE; } return &qset; } static const bcm_field_qset_t *get_ingress_traffic_failure(void){ const static bcm_field_qualify_t ingress_traffic_failure[] = { /* traffic failure - test exist */ bcmFieldQualifyEcnValue, bcmFieldQualifyL4SrcPort, bcmFieldQualifyL4DstPort, bcmFieldQualifyTcpControl, bcmFieldQualifyInnerSrcIp, bcmFieldQualifyInnerDstIp, bcmFieldQualifyInnerTtl, bcmFieldQualifyInnerIpProtocol, bcmFieldQualifyInnerIpFrag, bcmFieldQualifyInnerSrcMac, bcmFieldQualifyInnerDstMac, bcmFieldQualifyInnerEtherType, bcmFieldQualifyExtensionHeaderType, /* no test for these qualifiers */ bcmFieldQualifyPacketRes, bcmFieldQualifyTunnelType, bcmFieldQualifyForwardingType, bcmFieldQualifyInterfaceClassL2, bcmFieldQualifyVrf, bcmFieldQualifyL3Ingress, bcmFieldQualifyL2Format, bcmFieldQualifyL2DestHit, bcmFieldQualifyL2StationMove, bcmFieldQualifyL3DestHostHit, bcmFieldQualifyColor, bcmFieldQualifyVlanTranslationHit, bcmFieldQualifyL3DestRouteHit, bcmFieldQualifyIntPriority, bcmFieldQualifyL2SrcHit, bcmFieldQualifyHeaderFormat, bcmFieldQualifyTunnelTerminated, bcmFieldQualifyRxTrapCode, bcmFieldQualifyPtch, bcmFieldQualifyRxTrapData, bcmFieldQualifyPacketTerminatedBytes, bcmFieldQualifyPolicerIntPrio, bcmFieldQualifyInterfaceClassVPort, bcmFieldQualifyVlanTranslationValue, bcmFieldQualifyTunnelTerminatedValue, bcmFieldQualifyMplsTerminatedValue, bcmFieldQualifyIpTunnelValue, bcmFieldQualifyL3SrcRouteValue, bcmFieldQualifyL3DestRouteValue, bcmFieldQualifyPacketSize, bcmFieldQualifyIpmcHit, bcmFieldQualifyL3SrcRouteHit, bcmFieldQualifyDhcp, bcmFieldQualifyPortOrientation, bcmFieldQualifyMplsTerminated, bcmFieldQualifyInnerTos, bcmFieldQualifyInnerL4SrcPort, bcmFieldQualifyInnerL4DstPort, bcmFieldQualifyInVPort, bcmFieldQualifyOutVPort, bcmFieldQualifyIpTunnelHit, bcmFieldQualifyMplsForwardingLabel, bcmFieldQualifyMplsForwardingLabelAction, bcmFieldQualifyIpFlags, bcmFieldQualifyMplsForwardingLabelExp, bcmFieldQualifyMplsForwardingLabelId, bcmFieldQualifyVlanFormat, bcmFieldQualifyIngressStpState, bcmFieldQualifyVpn, bcmFieldQualifyFlowId, bcmFieldQualifyTrillEgressRbridge, bcmFieldQualifyISid, bcmFieldQualifyL2SrcValue, bcmFieldQualifyL2DestValue, bcmFieldQualifyIpmcValue, bcmFieldQualifyLearnSrcMac, bcmFieldQualifyLearnVlan, bcmFieldQualifyMplsForwardingLabelTtl, bcmFieldQualifyCascadedKeyValue, bcmFieldQualifyL2Learn, bcmFieldQualifyMplsForwardingLabelBos, bcmFieldQualifyDrop, bcmFieldQualifyDstMulticastGroup, bcmFieldQualifySrcMplsGport, bcmFieldQualifyDstMplsGport, bcmFieldQualifySrcMimGport, bcmFieldQualifyDstMimGport, bcmFieldQualifySrcWlanGport, bcmFieldQualifyDstWlanGport, bcmFieldQualifySrcModPortGport, bcmFieldQualifySrcModuleGport, bcmFieldQualifySrcGport, bcmFieldQualifyDstRpfGport, bcmFieldQualifyLearnSrcPort, bcmFieldQualifyLearnInVPort, bcmFieldQualifyTunnelId, bcmFieldQualifyArpSenderIp4, bcmFieldQualifyArpTargetIp4, bcmFieldQualifyArpOpcode, bcmFieldQualifyTranslatedOuterVlan, bcmFieldQualifyTranslatedOuterVlanId, bcmFieldQualifyTranslatedOuterVlanPri, bcmFieldQualifyTranslatedOuterVlanCfi, bcmFieldQualifyTranslatedInnerVlan, bcmFieldQualifyTranslatedInnerVlanId, bcmFieldQualifyTranslatedInnerVlanPri, bcmFieldQualifyTranslatedInnerVlanCfi, bcmFieldQualifyForwardingHeaderOffset, bcmFieldQualifyExternalValue0, bcmFieldQualifyExternalValue1, bcmFieldQualifyExternalValue2, bcmFieldQualifyExternalValue3, bcmFieldQualifyExternalValue4, bcmFieldQualifyExternalValue5, bcmFieldQualifyExternalValue6, bcmFieldQualifyExternalValue7, bcmFieldQualifyExternalHit0, bcmFieldQualifyExternalHit1, bcmFieldQualifyExternalHit2, bcmFieldQualifyExternalHit3, bcmFieldQualifyExternalHit4, bcmFieldQualifyExternalHit5, bcmFieldQualifyExternalHit6, bcmFieldQualifyExternalHit7, bcmFieldQualifyIngressVPortBridgeDisable, bcmFieldQualifyMirrorEgressDisabled, bcmFieldQualifyBypassSrcMacFilter, bcmFieldQualifyRxTrapCodeForSnoop, bcmFieldQualifyFhei, bcmFieldQualifyFheiSize, bcmFieldQualifyOuterVlanActionRange, bcmFieldQualifyInnerVlanActionRange, bcmFieldQualifyOamInLifIdValid, bcmFieldQualifyOamInLifId, bcmFieldQualifyOamUpMep, bcmFieldQualifyOamSubtype, bcmFieldQualifyOamHeaderOffset, bcmFieldQualifyOamStampOffset, bcmFieldQualifyOamMepId, bcmFieldQualifyOamMeterDisable, bcmFieldQualifyOamTsSystemHeader, bcmFieldQualifyEthernetOamHeaderBits0_31, bcmFieldQualifyEthernetOamHeaderBits32_63, bcmFieldQualifyMplsOamHeaderBits0_31, bcmFieldQualifyMplsOamHeaderBits32_63, bcmFieldQualifyMplsOamACH, bcmFieldQualifyOamHeaderBits0_31, bcmFieldQualifyOamHeaderBits32_63, bcmFieldQualifyInVPortWide, bcmFieldQualifyStackingRoute, bcmFieldQualifyDstSysPortExt, bcmFieldQualifyOuterVlanPriCfi, bcmFieldQualifyForwardHdrSrcMac, bcmFieldQualifyForwardHdrDstMac, bcmFieldQualifyForwardHdrVlanId, bcmFieldQualifyLearnExtension, bcmFieldQualifyVlanAction, bcmFieldQualifyNativeVSwitch, bcmFieldQualifyRxTrapStrength, bcmFieldQualifyIncomingIpIfClass, bcmFieldQualifyContainer, bcmFieldQualifySrcTMPort, bcmFieldQualifyInVportDataIndex, bcmFieldQualifyTunnelTerminationProcessingProfile, bcmFieldQualifyForwardCode, bcmFieldQualifyPphType, bcmFieldQualifyInDscpExp }; static uint8 is_set = FALSE; static bcm_field_qset_t qset; uint32 i; if(!is_set){ BCM_FIELD_QSET_INIT(qset); for(i = 0; i < sizeof(ingress_traffic_failure)/sizeof(bcm_field_qualify_t); ++i) { BCM_FIELD_QSET_ADD(qset, ingress_traffic_failure[i]); } is_set = TRUE; } return &qset; } static const bcm_field_qset_t *get_ingress_traffic_failure_not_scan(void){ const static bcm_field_qualify_t ingress_traffic_failure_not_scan[] = { /* These qualifiers causes failure if we want to use the qualifier EtheType Or another header, because of failure in the identification of the inner vlan */ bcmFieldQualifyInnerVlan, bcmFieldQualifyInnerVlanId, bcmFieldQualifyInnerVlanPri, bcmFieldQualifyInnerVlanCfi, bcmFieldQualifyInnerTpid, bcmFieldQualifyContainer, bcmFieldQualifySrcTMPort, bcmFieldQualifyInVportDataIndex, bcmFieldQualifyTunnelTerminationProcessingProfile, bcmFieldQualifyForwardCode, bcmFieldQualifyPphType, bcmFieldQualifyInDscpExp }; static uint8 is_set = FALSE; static bcm_field_qset_t qset; uint32 i; if(!is_set){ BCM_FIELD_QSET_INIT(qset); for(i = 0; i < sizeof(ingress_traffic_failure_not_scan)/sizeof(bcm_field_qualify_t); ++i) { BCM_FIELD_QSET_ADD(qset, ingress_traffic_failure_not_scan[i]); } is_set = TRUE; } return &qset; } /* * This function get qset and aset randomly for field group * The function gets also the sum of the qualifiers and the sum actions and updates them * sum_qualifiers and sum_actions may be null. */ STATIC cmd_result_t _bcm_petra_field_test_field_group_get_qset_and_aset(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 nof_residual_groups, /* the number of field group we would like to create * not include this field group */ uint32 x, uint8 is_data_qualifier, uint8 is_large_de, int type, uint32 max_bank_size, bcm_field_qset_t *qset, bcm_field_aset_t *aset, uint32 *sum_qualifiers, uint32 *sum_actions, uint8 perf /*For performance tests, to read max_bank_size as bank_size*/) { bcm_error_t rv; uint32 second_rand_param = 0; int rnd; uint32 data_qual_id; bcm_field_qualify_t qual; bcm_field_action_t action; uint32 max_qualifiers_length; uint32 max_actions_length; uint32 max_qualifiers; uint32 max_actions; bcm_field_qset_t valid_qset; bcm_field_aset_t valid_aset; int qual_arr[_BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID_ALL + 1]; int qual_count; bcm_field_data_qualifier_t dq; uint32 hw_length; uint32 sw_length; uint32 nof_hw_quals; /* qset */ if(!perf) { rnd = _bcm_petra_field_rand_val(x, second_rand_param++)%3; if(rnd == 0 && max_bank_size >= 320) { max_qualifiers_length = 320 - 3*_BCM_PETRA_FIELD_TEST_QUALIFIERS_LENGTH_SPLIT_OVERHEAD;/* It may be split in 4 zones */ } else if(rnd == 1 && max_bank_size >= 160) { max_qualifiers_length = 160 - _BCM_PETRA_FIELD_TEST_QUALIFIERS_LENGTH_SPLIT_OVERHEAD;/* it may be split in 2 zones */ } else { max_qualifiers_length = 80;/* must be in only single zone - no split overheadr */ } } else { /* For performance tests, take the predefined max_qualifiers_length _BCM_PETRA_FIELD_TEST_FIELD_GROUP_BANK_SIZE_PERF */ max_qualifiers_length = _BCM_PETRA_FIELD_TEST_FIELD_GROUP_BANK_SIZE_PERF /* and calculate split overhead as above*/ - (4 / (_BCM_PETRA_FIELD_TEST_FIELD_GROUP_BANK_MAX_SIZE / _BCM_PETRA_FIELD_TEST_FIELD_GROUP_BANK_SIZE_PERF) - 1) * _BCM_PETRA_FIELD_TEST_QUALIFIERS_LENGTH_SPLIT_OVERHEAD; } _bcm_petra_field_test_reset_field_group_resources(max_qualifiers_length / 2); #if defined(INCLUDE_KBP) if(stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { max_qualifiers_length = 160 - _BCM_PETRA_FIELD_TEST_QUALIFIERS_LENGTH_SPLIT_OVERHEAD;/* it may be split in 2 zones */ } #endif /* defined(INCLUDE_KBP) */ if(_bcm_petra_field_test_qualify_and_action_get_valid_set(unit, stage, x, type, &valid_qset, &valid_aset)) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Failed to get valid qset and aset\n"))); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } max_qualifiers = _BCM_PETRA_FILED_TEST_FIELD_GROUP_MAX_QUALIFIERS(stage); #if defined(INCLUDE_KBP) if(stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { if(nof_residual_groups > 0) { max_qualifiers = 1; } else { max_qualifiers = 4; } } /* In order not to take bcmFieldActionExternalValue[0/1]Set * that are not available if the AppType is not L2 only. */ BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionExternalValue0Set); #ifdef BCM_88660_A0 if ((SOC_IS_ARADPLUS(unit)) && (soc_property_suffix_num_get(unit, -1, spn_CUSTOM_FEATURE, "ext_rpf_fwd_parallel", 0) == 0)){ BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionExternalValue2Set); } else #endif /* BCM_88660_A0 */ { BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionExternalValue1Set); } #endif /* defined(INCLUDE_KBP) */ if(sum_qualifiers) { if (*sum_qualifiers + _BCM_PETRA_FILED_TEST_FIELD_GROUP_MAX_QUALIFIERS(stage) + nof_residual_groups > 64) { max_qualifiers = 64 - *sum_qualifiers - nof_residual_groups; } } BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionDropCancel); if(SOC_IS_JERICHO_AND_BELOW(unit)) { BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionAdmitProfile); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionLatencyFlowId); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStatisticPtr0); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStatisticPtr1); } BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionLearnSrcMacNew); type = _BCM_PETRA_FIELD_TYPE_ETHR; BCM_FIELD_QSET_INIT(*qset); if(BCM_FIELD_QSET_TEST(valid_qset, bcmFieldQualifyIp4)) { BCM_FIELD_QSET_ADD(*qset, bcmFieldQualifyIp4); BCM_FIELD_QSET_REMOVE(valid_qset, bcmFieldQualifyIp4); type = _BCM_PETRA_FIELD_TYPE_IPV4; } else if(BCM_FIELD_QSET_TEST(valid_qset, bcmFieldQualifyIp6)) { BCM_FIELD_QSET_ADD(*qset, bcmFieldQualifyIp6); BCM_FIELD_QSET_REMOVE(valid_qset, bcmFieldQualifyIp6); type = _BCM_PETRA_FIELD_TYPE_IPV6; } else if(BCM_FIELD_QSET_TEST(valid_qset, bcmFieldQualifyMpls)) { BCM_FIELD_QSET_ADD(*qset, bcmFieldQualifyMpls); BCM_FIELD_QSET_REMOVE(valid_qset, bcmFieldQualifyMpls); type = _BCM_PETRA_FIELD_TYPE_MPLS; } _bcm_petra_field_test_qual_remove_from_qset(&valid_qset); #if defined(INCLUDE_KBP) if(stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { if(nof_residual_groups > 0) { uint32 nof_ces; /* remove all the qualifiers that have more than 2 ce-s */ for(qual =0; qual < bcmFieldQualifyCount; ++qual) { if(BCM_FIELD_QSET_TEST(valid_qset, qual)) { rv = _bcm_petra_field_test_qualify_get_nof_resorces(unit, stage, type, qual, &nof_ces, NULL); if(rv != BCM_E_NONE) { return CMD_FAIL; } if(nof_ces > 2) { BCM_FIELD_QSET_REMOVE(valid_qset, qual); } } } } } #endif /* defined(INCLUDE_KBP) */ if(!is_data_qualifier) { rv = _bcm_petra_field_create_set_max_length(unit, stage, type, qset, (void (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_add, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_test, _bcm_petra_field_test_qualify_hardware_length_worst, _bcm_petra_field_test_qualify_can_be_both, _bcm_petra_field_test_take_qualifier, bcmFieldQualifyCount, &valid_qset, max_qualifiers_length, max_qualifiers, x + second_rand_param++); } else { data_qualifier_add_remove_test_unit = unit; for(data_qual_id = 0; data_qual_id <= _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID(unit); ++data_qual_id) { bcm_field_data_qualifier_t_init(&dq); rv = bcm_field_data_qualifier_get(unit, data_qual_id, &dq); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if((dq.flags & BCM_FIELD_DATA_QUALIFIER_OFFSET_PREDEFINED) && !BCM_FIELD_QSET_TEST(valid_qset, dq.qualifier)) { /* Remove it from the valid_qset. It may be in the valid qset */ rv = bcm_field_qset_data_qualifier_delete(unit, &valid_qset, data_qual_id); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } else { if(is_large_de) { /* we can't take qualifiers that have 2 hardware qualifiers */ rv = _bcm_petra_field_test_qualify_get_nof_resorces(unit, stage, type, dq.qualifier, NULL, &nof_hw_quals); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(nof_hw_quals > 1) { continue; } /* remove qualifiers whose length is not equal to their hardware length */ rv = _bcm_petra_field_test_qualify_hardware_length_best(unit, stage, type, dq.qualifier, &hw_length); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } rv = _bcm_petra_field_test_qualify_exposed_length(unit, stage, type, dq.qualifier, &sw_length); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(hw_length != sw_length) { continue; } } rv = bcm_field_qset_data_qualifier_add(unit, &valid_qset, data_qual_id); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } } if(is_large_de) { max_qualifiers = 8; rv = _bcm_petra_field_test_action_length(unit, stage, _BCM_PETRA_FIELD_TEST_LARGE_DIRECT_EXTRACTION_ACTION, &max_qualifiers_length); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } /* Round up to 4bits aligned */ max_qualifiers_length = ((max_qualifiers_length+3)/4)*4; } rv = _bcm_petra_field_create_set_max_length(unit, stage, 0xffffffff, qset, (void (*)(void*, uint32)) _bcm_petra_field_test_data_qualifier_set_add, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_data_qualifier_set_test, _bcm_petra_field_test_data_qualifier_length, _bcm_petra_field_test_data_qualifiers_can_be_both, _bcm_petra_field_test_take_action, _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID(unit) + 1, &valid_qset, max_qualifiers_length, max_qualifiers, x + second_rand_param++); } if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(!is_data_qualifier){ for(qual = 0; qual < bcmFieldQualifyCount; ++qual) { if(BCM_FIELD_QSET_TEST(*qset, qual) && qual != bcmFieldQualifyIp4 && qual != bcmFieldQualifyIp6 && qual != bcmFieldQualifyMpls) { if(sum_qualifiers) ++(*sum_qualifiers); } } } else { rv = bcm_field_qset_data_qualifier_get(unit, *qset, _BCM_PETRA_FIELD_TEST_MAX_DATA_QUALIFIER_ID(unit) + 1, qual_arr, &qual_count); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } *sum_qualifiers += qual_count; } /* aset - ingress and external only */ if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS || stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { BCM_FIELD_ASET_INIT(*aset); max_actions = _BCM_PETRA_FILED_TEST_FIELD_GROUP_MAX_ACTIONS; if(sum_actions) { if (*sum_actions + _BCM_PETRA_FILED_TEST_FIELD_GROUP_MAX_ACTIONS + nof_residual_groups > 32) { max_actions = 32 - *sum_actions - nof_residual_groups; } } BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionCascadedKeyValueSet); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionSnoopAndTrap); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStatAndPolicer); if (!SOC_IS_JERICHO_PLUS(unit)) { BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionPphSnoopCode); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStaggeredPreselProfile0Set); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStaggeredPreselProfile1Set); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStaggeredPreselProfile2Set); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStaggeredPreselProfile3Set); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStaggeredPreselProfileDirectSet); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "%s(): Action does not exist for this device. This is just a message.\n"), __func__)); } rnd = _bcm_petra_field_rand_val(x, second_rand_param++)%3; if(rnd == 0) { max_actions_length = 80; } else if(rnd == 1) { max_actions_length = 40; } else { max_actions_length = 20; } #if defined(INCLUDE_KBP) if(stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { max_actions_length = 40; } #endif /* defined(INCLUDE_KBP) */ if(!is_large_de) { if (!SOC_IS_ARADPLUS(unit)) { BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionInterfaceClassVPort); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "%s(): bcmFieldActionInterfaceClassVPort does not exist for Arad and below. This is just a message.\n"), __func__)); } rv = _bcm_petra_field_create_set_max_length(unit, stage, 0, aset, (void (*)(void*, uint32)) _bcm_petra_field_test_action_set_add, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_action_set_test, _bcm_petra_field_test_action_length_with_valid_bit, _bcm_petra_field_test_action_can_be_both, _bcm_petra_field_test_take_action, bcmFieldActionCount, &valid_aset, max_actions_length, max_actions, x + second_rand_param++); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } else { BCM_FIELD_ASET_ADD(*aset, _BCM_PETRA_FIELD_TEST_LARGE_DIRECT_EXTRACTION_ACTION); } for(action = 0; action < bcmFieldActionCount; ++action) { if(BCM_FIELD_ASET_TEST(*aset, action)) { if(sum_actions) ++(*sum_actions); } } } else { sal_memcpy(aset, &valid_aset, sizeof(*aset)); } if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS) { BCM_FIELD_QSET_ADD(*qset, bcmFieldQualifyStageIngress); } else if (stage == _BCM_DPP_FIELD_STAGE_INDEX_EGRESS) { BCM_FIELD_QSET_ADD(*qset, bcmFieldQualifyStageEgress); } else { BCM_FIELD_QSET_ADD(*qset, bcmFieldQualifyStageExternal); } return CMD_OK; } #ifdef BROADCOM_DEBUG STATIC bcm_error_t _bcm_petra_field_test_group_dump(int unit, uint8 group_id) { bcm_dpp_field_info_OLD_t *unitData; BCMDNX_INIT_FUNC_DEFS; _DPP_FIELD_UNIT_CHECK(unit, unitData); BCMDNX_IF_ERR_EXIT(_bcm_dpp_field_group_dump(unitData, group_id, "", FALSE)); exit: BCMDNX_FUNC_RETURN; } #endif /* * This function fills by random values the array of the filed groups */ STATIC cmd_result_t _bcm_petra_field_test_fill_field_groups(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 x, uint8 is_data_qualifier, uint8 is_large_de, int type, uint32 max_bank_size, bcm_field_group_config_t *field_groups, int nof_groups, uint8 perf /* For performance tests, do same field group size */) { uint32 fg_idx, fg_idx_2; uint32 second_rand_param = 0; uint8 is_explicit_id; uint32 id; uint8 does_exist_already; uint32 sum_actions = 0; uint32 sum_qualifiers = 0; cmd_result_t result; uint8 nof_not_explicit = 0; _bcm_petra_field_test_reset_resources(); #if defined(INCLUDE_KBP) _bcm_petra_field_test_kbp_reset_resources(); #endif /* defined(INCLUDE_KBP) */ for(fg_idx = 0; fg_idx < nof_groups; ++fg_idx) { /* id */ bcm_field_group_config_t_init(&field_groups[fg_idx]); if(fg_idx + nof_not_explicit >= nof_groups) { /* We want the implicit field groups to be in the end in order that they will not catch the explicit id of the next field groups */ is_explicit_id = FALSE; } else { do { is_explicit_id = _bcm_petra_field_rand_val(x, second_rand_param++)%2; if (!is_explicit_id) { ++nof_not_explicit; } } while(!is_explicit_id && (fg_idx + nof_not_explicit < nof_groups)); } if(is_explicit_id) { do { id = _bcm_petra_field_rand_val(x, second_rand_param++) %(_BCM_PETRA_FIELD_TEST_MAXIMAL_GROUP_ID + 1); does_exist_already = FALSE; for(fg_idx_2 = 0; fg_idx_2 < fg_idx ;++fg_idx_2) { if (id == field_groups[fg_idx_2].group) { does_exist_already = TRUE; break; } } } while(does_exist_already); field_groups[fg_idx].group = id; field_groups[fg_idx].flags |= BCM_FIELD_GROUP_CREATE_WITH_ID; } /* priority */ do { field_groups[fg_idx].priority = _bcm_petra_field_rand_val(x, second_rand_param++) %(_BCM_PETRA_FIELD_GROUP_PRIO_HIGHEST - _BCM_PETRA_FIELD_GROUP_PRIO_LOWEST) + _BCM_PETRA_FIELD_GROUP_PRIO_LOWEST; does_exist_already = FALSE; for(fg_idx_2 = 0; fg_idx_2 < fg_idx ; ++fg_idx_2) { if (field_groups[fg_idx].priority == field_groups[fg_idx_2].priority) { does_exist_already = TRUE; break; } } } while(does_exist_already); /* qset and aset */ result = _bcm_petra_field_test_field_group_get_qset_and_aset(unit, stage, nof_groups - 1 - fg_idx, x + second_rand_param++, is_data_qualifier, is_large_de, type, max_bank_size, &field_groups[fg_idx].qset, &field_groups[fg_idx].aset, &sum_qualifiers, &sum_actions, perf); if(result != CMD_OK) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return result; } if(stage == _BCM_DPP_FIELD_STAGE_INDEX_INGRESS) { field_groups[fg_idx].flags |= BCM_FIELD_GROUP_CREATE_WITH_ASET; } if(is_large_de) { field_groups[fg_idx].flags |= BCM_FIELD_GROUP_CREATE_WITH_MODE; field_groups[fg_idx].mode = bcmFieldGroupModeDirectExtraction; } #if defined(INCLUDE_KBP) if(stage == _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { /* preselectors */ field_groups[fg_idx].flags |= BCM_FIELD_GROUP_CREATE_WITH_ASET; field_groups[fg_idx].flags |= BCM_FIELD_GROUP_CREATE_WITH_PRESELSET; BCM_FIELD_PRESEL_INIT(field_groups[fg_idx].preselset); BCM_FIELD_PRESEL_ADD(field_groups[fg_idx].preselset, fg_idx + 3); } #endif /* defined(INCLUDE_KBP) */ } return CMD_OK; } CONST STATIC bcm_field_qualify_t _bcm_petra_field_test_comfortable_qualifier_for_direct_table[] = { bcmFieldQualifyTtl, bcmFieldQualifyInnerTtl, bcmFieldQualifyL3DestHostHit, bcmFieldQualifyL3SrcHostHit, bcmFieldQualifyVlanTranslationHit, bcmFieldQualifyIpTunnelHit, bcmFieldQualifyL2DestHit, bcmFieldQualifyL2SrcHit, bcmFieldQualifyL3DestRouteHit, bcmFieldQualifyL3SrcRouteHit, bcmFieldQualifyIpmcHit, bcmFieldQualifyPacketTerminatedBytes, bcmFieldQualifyTrunkHashResult, bcmFieldQualifyIntPriority, bcmFieldQualifyCnTag, bcmFieldQualifyOuterVlanPri, bcmFieldQualifyOuterVlanCfi, bcmFieldQualifyInnerVlanPri, bcmFieldQualifyInnerVlanCfi, bcmFieldQualifyTranslatedOuterVlanPri, bcmFieldQualifyTranslatedOuterVlanCfi, bcmFieldQualifyTranslatedInnerVlanPri, bcmFieldQualifyTranslatedInnerVlanCfi, bcmFieldQualifyMplsForwardingLabelExp, bcmFieldQualifyMplsForwardingLabelBos, bcmFieldQualifyMplsForwardingLabelTtl, bcmFieldQualifyMplsLabel1Exp, bcmFieldQualifyMplsLabel1Bos, bcmFieldQualifyMplsLabel1Ttl, bcmFieldQualifyMplsLabel2Exp, bcmFieldQualifyMplsLabel2Bos, bcmFieldQualifyMplsLabel2Ttl, bcmFieldQualifyMplsLabel3Exp, bcmFieldQualifyMplsLabel3Bos, bcmFieldQualifyMplsLabel3Ttl, bcmFieldQualifyPtch, bcmFieldQualifyExternalValue0, bcmFieldQualifyExternalValue1, bcmFieldQualifyExternalValue2, bcmFieldQualifyExternalValue3, bcmFieldQualifyExternalValue4, bcmFieldQualifyExternalValue5, bcmFieldQualifyExternalValue6, bcmFieldQualifyExternalValue7, bcmFieldQualifyExternalHit0, bcmFieldQualifyExternalHit1, bcmFieldQualifyExternalHit2, bcmFieldQualifyExternalHit3, bcmFieldQualifyExternalHit4, bcmFieldQualifyExternalHit5, bcmFieldQualifyExternalHit6, bcmFieldQualifyExternalHit7, bcmFieldQualifyIngressVPortBridgeDisable }; /* remove from the valid aset actions that don't fill the constrain that the hw action value is equal to param0 */ STATIC void _bcm_petra_field_test_dt_remove_inadequate_actions(bcm_field_aset_t *aset) { BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionDropPrecedence); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionForwardingTypeNew); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionFilters); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionCnmCancel); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionMacDaKnown); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionDoNotLearn); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionStartPacketStrip); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionClassSourceSet); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionClassDestSet); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionEcnNew); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionOrientationSet); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionFabricHeaderSet); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionOam); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionIEEE1588); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionSnoopAndTrap); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionStatAndPolicer); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionTrapCodeQualifier); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionPphSnoopCode); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionStaggeredPreselProfile0Set); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionStaggeredPreselProfile1Set); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionStaggeredPreselProfile2Set); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionStaggeredPreselProfile3Set); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionStaggeredPreselProfileDirectSet); BCM_FIELD_ASET_REMOVE(*aset, bcmFieldActionLearnSrcMacNew); } /* * This function fills by random values the array of the filed groups for direct table mode */ STATIC cmd_result_t _bcm_petra_field_test_fill_field_groups_dt(int unit, uint32 x, bcm_field_group_config_t *field_groups, int nof_groups) { uint32 fg_idx, fg_idx_2; uint32 second_rand_param = 0; uint8 is_explicit_id; uint32 id; uint8 does_exist_already; bcm_field_qset_t valid_qset; bcm_field_aset_t valid_aset; bcm_error_t rv; uint8 nof_not_explicit = 0; bcm_field_qualify_t qual; uint8 is_lsb_qualifier; uint32 maximal_key_length; uint32 max_qualifiers_per_fg; uint32 max_actions_per_fg; uint32 type; uint32 qual_idx; static bcm_field_qset_t comfortable; static uint8 is_comfortable_set = FALSE; _bcm_petra_field_test_reset_resources(); for(fg_idx = 0; fg_idx < nof_groups; ++fg_idx) { bcm_field_group_config_t_init(&field_groups[fg_idx]); /* id */ if(fg_idx + nof_not_explicit >= nof_groups) { /* We want the implicit field groups to be in the end in order that they will not catch the explicit id of the next field groups */ is_explicit_id = FALSE; } else { do { is_explicit_id = _bcm_petra_field_rand_val(x, second_rand_param++)%2; if (!is_explicit_id) { ++nof_not_explicit; } } while(!is_explicit_id && (fg_idx + nof_not_explicit < nof_groups)); } if(is_explicit_id) { do { id = _bcm_petra_field_rand_val(x, second_rand_param++) %(_BCM_PETRA_FIELD_TEST_MAXIMAL_GROUP_ID + 1); does_exist_already = FALSE; for(fg_idx_2 = 0; fg_idx_2 < fg_idx ; ++fg_idx_2) { if (id == field_groups[fg_idx_2].group) { does_exist_already = TRUE; break; } } } while(does_exist_already); field_groups[fg_idx].group = id; field_groups[fg_idx].flags |= BCM_FIELD_GROUP_CREATE_WITH_ID; } /* priority */ do { field_groups[fg_idx].priority = _bcm_petra_field_rand_val(x, second_rand_param++) %(_BCM_PETRA_FIELD_GROUP_PRIO_HIGHEST - _BCM_PETRA_FIELD_GROUP_PRIO_LOWEST) + _BCM_PETRA_FIELD_GROUP_PRIO_LOWEST; does_exist_already = FALSE; for(fg_idx_2 = 0; fg_idx_2 < fg_idx ; ++fg_idx_2) { if (field_groups[fg_idx].priority == field_groups[fg_idx_2].priority) { does_exist_already = TRUE; break; } } } while(does_exist_already); /* qset and aset */ if(_bcm_petra_field_test_qualify_and_action_get_valid_set(unit, _BCM_DPP_FIELD_STAGE_INDEX_INGRESS, x, 0, &valid_qset, &valid_aset)) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Failed to get valid qset and aset\n"))); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } /* qset */ BCM_FIELD_QSET_INIT(field_groups[fg_idx].qset); type = _BCM_PETRA_FIELD_TYPE_ETHR; if(BCM_FIELD_QSET_TEST(valid_qset, bcmFieldQualifyIp4)) { BCM_FIELD_QSET_ADD(field_groups[fg_idx].qset, bcmFieldQualifyIp4); BCM_FIELD_QSET_REMOVE(valid_qset, bcmFieldQualifyIp4); type = _BCM_PETRA_FIELD_TYPE_IPV4; } else if(BCM_FIELD_QSET_TEST(valid_qset, bcmFieldQualifyIp6)) { BCM_FIELD_QSET_ADD(field_groups[fg_idx].qset, bcmFieldQualifyIp6); BCM_FIELD_QSET_REMOVE(valid_qset, bcmFieldQualifyIp6); type = _BCM_PETRA_FIELD_TYPE_IPV6; } else if(BCM_FIELD_QSET_TEST(valid_qset, bcmFieldQualifyMpls)) { BCM_FIELD_QSET_ADD(field_groups[fg_idx].qset, bcmFieldQualifyMpls); BCM_FIELD_QSET_REMOVE(valid_qset, bcmFieldQualifyMpls); type = _BCM_PETRA_FIELD_TYPE_MPLS; } _bcm_petra_field_test_qual_remove_from_qset(&valid_qset); /* take only "comfortable" qualifiers */ if(!is_comfortable_set) { BCM_FIELD_QSET_INIT(comfortable); for(qual_idx = 0; qual_idx < sizeof(_bcm_petra_field_test_comfortable_qualifier_for_direct_table)/sizeof(bcm_field_qualify_t); ++qual_idx) { BCM_FIELD_QSET_ADD(comfortable, _bcm_petra_field_test_comfortable_qualifier_for_direct_table[qual_idx]); } is_comfortable_set = TRUE; } /* remove msb qualifiers and not "comfortable" qualifiers */ for(qual = 0; qual < bcmFieldQualifyCount; ++qual) { if(BCM_FIELD_QSET_TEST(valid_qset, qual)) { rv = _bcm_petra_field_test_qualifier_is_lsb_is_msb(unit, qual, &is_lsb_qualifier, NULL); if (rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(!is_lsb_qualifier) { BCM_FIELD_QSET_REMOVE(valid_qset, qual); } if(!BCM_FIELD_QSET_TEST(comfortable, qual)) { BCM_FIELD_QSET_REMOVE(valid_qset, qual); } } } if(nof_groups <= SOC_DPP_DEFS_GET(unit, nof_tcam_small_banks)) { /* in the test with entries we may use less than SOC_DPP_DEFS_GET(unit, nof_tcam_small_banks) field groups */ maximal_key_length = SOC_DPP_DEFS_GET(unit, tcam_big_bank_key_nof_bits); } else if (fg_idx + SOC_DPP_DEFS_GET(unit, nof_tcam_small_banks) < nof_groups) { /* The last SOC_DPP_DEFS_GET(unit, nof_tcam_small_banks) field groups should be inserted to the small banks - the others in big bank */ maximal_key_length = SOC_DPP_DEFS_GET(unit, tcam_big_bank_key_nof_bits); } else { maximal_key_length = _BCM_PETRA_FIELD_TEST_DIRECT_TABLE_MAXIMAL_QUALIFIERS_LENGTH_SMALL_BANK; } max_qualifiers_per_fg = (nof_groups > 1) ? 1 /* take only 1 qualifier, to have enough c.e.-s */: maximal_key_length; _bcm_petra_field_test_reset_field_group_resources(maximal_key_length);/* anyway all the qualifiers must be lsb */ rv = _bcm_petra_field_create_set_max_length(unit, _BCM_DPP_FIELD_STAGE_INDEX_INGRESS, type, &field_groups[fg_idx].qset, (void (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_add, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_qualify_set_test, _bcm_petra_field_test_qualify_hardware_length_worst, _bcm_petra_field_test_qualify_can_be_both, _bcm_petra_field_test_take_qualifier, bcmFieldQualifyCount, &valid_qset, maximal_key_length, max_qualifiers_per_fg, x + second_rand_param++); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } max_actions_per_fg = (nof_groups > 1) ? 1 /* take only 1 action */: SOC_DPP_DEFS_GET(unit, tcam_action_width); /* aset */ BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionCascadedKeyValueSet); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionDropCancel); if(SOC_IS_JERICHO_AND_BELOW(unit)) { BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionAdmitProfile); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionLatencyFlowId); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStatisticPtr0); BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStatisticPtr1); } _bcm_petra_field_test_dt_remove_inadequate_actions(&valid_aset); if (SOC_IS_QUX(unit) || SOC_IS_QAX(unit)) { BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionStatTag); } if (!SOC_IS_ARADPLUS(unit)) { BCM_FIELD_ASET_REMOVE(valid_aset, bcmFieldActionInterfaceClassVPort); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "%s(): bcmFieldActionInterfaceClassVPort does not exist for Arad and below. This is just a message.\n"), __func__)); } rv = _bcm_petra_field_create_set_max_length(unit, _BCM_DPP_FIELD_STAGE_INDEX_INGRESS, 0, &field_groups[fg_idx].aset, (void (*)(void*, uint32)) _bcm_petra_field_test_action_set_add, (uint8 (*)(void*, uint32)) _bcm_petra_field_test_action_set_test, _bcm_petra_field_test_action_length_with_valid_bit, _bcm_petra_field_test_action_can_be_both, _bcm_petra_field_test_take_action, bcmFieldActionCount, &valid_aset, SOC_DPP_DEFS_GET(unit, tcam_action_width), max_actions_per_fg, x + second_rand_param++); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } field_groups[fg_idx].flags |= BCM_FIELD_GROUP_CREATE_WITH_ASET; field_groups[fg_idx].flags |= BCM_FIELD_GROUP_CREATE_WITH_MODE; field_groups[fg_idx].mode = bcmFieldGroupModeDirect; if(!(maximal_key_length == SOC_DPP_DEFS_GET(unit, tcam_big_bank_key_nof_bits))) { field_groups[fg_idx].flags |= BCM_FIELD_GROUP_CREATE_SMALL; } } return CMD_OK; } /* * This function gets the data of the field group. according to the field group's id it retrieves the priority qset aset, * and compares them to the data stored in the structure. */ STATIC cmd_result_t _bcm_petra_field_field_group_get_and_compare(int unit, bcm_field_group_config_t *field_group, uint8 print_anyway) { bcm_error_t rv; int priority_verify; bcm_field_qset_t qset_verify; bcm_field_group_mode_t mode_verify; bcm_field_aset_t aset_verify; const static char *modes[] = BCM_FIELD_GROUP_MODE_STRINGS; rv = bcm_field_group_get(unit, field_group->group, &qset_verify); if(rv != BCM_E_NONE) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "group id %d - failed to retrieve the field_group\n"), field_group->group)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } /* qset comparing */ /* we just verify that what we have inserted is included. We may have another qualifiers */ rv = _bcm_dpp_field_qset_subset(qset_verify, field_group->qset); if(rv != BCM_E_NONE) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "group id %d - the qset retrieved is not including the qset set \n"), field_group->group)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } /* Priority comparing */ rv = bcm_field_group_priority_get(unit, field_group->group, &priority_verify); if(rv != BCM_E_NONE) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "group id %d - bcm_field_group_priority_get failed\n"), field_group->group)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(priority_verify != field_group->priority) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "group id %d - priorities mismatch: set as %d retrieved %d\n"), field_group->group, field_group->priority, priority_verify)); } } if(field_group->flags & BCM_FIELD_GROUP_CREATE_WITH_MODE) { /* verify the mode */ rv = bcm_field_group_mode_get(unit, field_group->group, &mode_verify); if(rv != BCM_E_NONE) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "group id %d - bcm_field_group_mode_get failed\n"), field_group->group)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(mode_verify != field_group->mode) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "group id %d - Modes mismatch: set %s, get %s.\n"), field_group->group, modes[field_group->mode], modes[mode_verify])); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } /* aset comparing - Skip in the egress stage */ if(BCM_FIELD_QSET_TEST(field_group->qset, bcmFieldQualifyStageEgress)){ return CMD_OK; } rv = bcm_field_group_action_get(unit, field_group->group, &aset_verify); if(rv != BCM_E_NONE) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "group id %d - bcm_field_group_action_get failed\n"), field_group->group)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } /* we just verify that what we have inserted is included. We may have another actions */ rv = _bcm_dpp_field_aset_subset(&aset_verify, &(field_group->aset)); if(rv != BCM_E_NONE) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "group id %d - the aset retrieved is not including the aset set \n"), field_group->group)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } return CMD_OK; } /* * This function gets the data of the entry. according to the entrie's id it retrieves the priority qualifiers' data and mask * actions' param0 and param1, * and compares them to the data stored in the structure. */ STATIC cmd_result_t _bcm_petra_field_test_retrieve_entry_and_compare(int unit, _bcm_dpp_field_stage_idx_t stage, _bcm_petra_field_test_entry_info_t *entry, uint8 is_direct_table, uint8 print_anyway) { bcm_error_t rv; int priority_verify; int qual_idx, action_idx, index; uint32 data_verify[_BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH/32]; uint32 mask_verify[_BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH/32]; uint32 param0_verify, param1_verify; const static char *qualifiers_names[] = BCM_FIELD_QUALIFY_STRINGS; const static char *actions_names[] = BCM_FIELD_ACTION_STRINGS; uint8 data8[8]; uint8 mask8[8]; uint16 length; uint32 qual_length; uint32 type = _BCM_PETRA_FIELD_TYPE_ETHR; int nof_cores = SOC_DPP_DEFS_GET(unit, nof_cores); int size_to_cmp = (_BCM_PETRA_FIELD_MAX_QUALIFY_LENGTH / 2) * nof_cores /8; /* 256 / 8 per each core */ if(!is_direct_table) { if(!_BCM_DPP_FIELD_ENTRY_IS_PRESEL(entry->id)) { rv = bcm_field_entry_prio_get(unit, entry->id, &priority_verify); if(rv != BCM_E_NONE) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d exist and bcm_field_entry_prio_get didn\'t return BCM_E_NONE.\n"), entry->id)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } /* priority verification */ if(priority_verify != entry->priority) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d priority mismatch: set %d get %d.\n"), entry->id, entry->priority, priority_verify)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } } for(qual_idx = 0; qual_idx < _BCM_PETRA_FIELD_TEST_MAX_QUALIFIERS_IN_ENTRY; ++qual_idx) { if(entry->quals_info[qual_idx].qualify == bcmFieldQualifyIp4) { type = _BCM_PETRA_FIELD_TYPE_IPV4; break; } if(entry->quals_info[qual_idx].qualify == bcmFieldQualifyIp6) { type = _BCM_PETRA_FIELD_TYPE_IPV6; break; } if(entry->quals_info[qual_idx].qualify == bcmFieldQualifyMpls) { type = _BCM_PETRA_FIELD_TYPE_MPLS; break; } } /* qualifiers verification */ for(qual_idx = 0; qual_idx < _BCM_PETRA_FIELD_TEST_MAX_QUALIFIERS_IN_ENTRY; ++qual_idx) { /* Do not check the qualifier for Direct Extraction entries if its mask is 0 */ if(entry->quals_info[qual_idx].is_valid && ((entry->id < _BCM_DPP_FIELD_ENT_BIAS(unit, DirExt) || entry->id >= (_BCM_DPP_FIELD_ENT_BIAS(unit, DirExt) + _BCM_PETRA_FIELD_TEST_MAX_ENTRIES_DIRECT_EXTRACTION)) || entry->quals_info[qual_idx].mask[0])) { if((!entry->quals_info[qual_idx].is_undefined)) { if(entry->quals_info[qual_idx].qualify == bcmFieldQualifyOutPort || entry->quals_info[qual_idx].qualify == bcmFieldQualifyOutPorts) { /* For theses qualifiers the get function don't work well */ continue; } if(stage != _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { rv = _bcm_petra_field_test_operate_get_function(unit, stage, type, entry->id, entry->quals_info[qual_idx].qualify, data_verify , mask_verify); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(sal_memcmp(entry->quals_info[qual_idx].data, data_verify, size_to_cmp)) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d qualifier %s data mismatch.\n") , entry->id, qualifiers_names[entry->quals_info[qual_idx].qualify])); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(sal_memcmp(entry->quals_info[qual_idx].mask, mask_verify, size_to_cmp)) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d qualifier %s mask mismatch. Expected %d, Got %d\n") , entry->id, qualifiers_names[entry->quals_info[qual_idx].qualify], *entry->quals_info[qual_idx].mask, *mask_verify)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } } else { if(stage != _BCM_DPP_FIELD_STAGE_INDEX_ING_EXTERNAL) { /* we do it to avoid msb alignment */ rv = _bcm_petra_field_test_data_qualifier_length(unit, stage, type, entry->quals_info[qual_idx].qualify, &qual_length); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } sal_memset(data8, 0, 8); sal_memset(mask8, 0, 8); rv = bcm_field_qualify_data_get(unit, entry->id, entry->quals_info[qual_idx].qualify, qual_length/8 + 1, data8, mask8, &length); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } /* we opposite the data and mask */ for(index = 0; index < length / 2; ++index) { data8[index] ^= data8[length - 1 - index]; data8[length - 1 - index] ^= data8[index]; data8[index] ^= data8[length - 1 - index]; mask8[index] ^= mask8[length - 1 - index]; mask8[length - 1 - index] ^= mask8[index]; mask8[index] ^= mask8[length - 1 - index]; } data_verify[0] = data8[0]; data_verify[0] |= data8[1] << 8; data_verify[0] |= data8[2] << 16; data_verify[0] |= data8[3] << 24; data_verify[1] = data8[4]; data_verify[1] |= data8[5] << 8; data_verify[1] |= data8[6] << 16; data_verify[1] |= data8[7] << 24; mask_verify[0] = mask8[0]; mask_verify[0] |= mask8[1] << 8; mask_verify[0] |= mask8[2] << 16; mask_verify[0] |= mask8[3] << 24; mask_verify[1] = mask8[4]; mask_verify[1] |= mask8[5] << 8; mask_verify[1] |= mask8[6] << 16; mask_verify[1] |= mask8[7] << 24; if(data_verify[0] != entry->quals_info[qual_idx].data[0]) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d data_qualifier %d data low mismatch.\n") , entry->id, entry->quals_info[qual_idx].qualify)); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, " set 0x%x, get 0x%x.\n"), entry->quals_info[qual_idx].data[0], data_verify[0])); _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(mask_verify[0] != entry->quals_info[qual_idx].mask[0]) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d data_qualifier %d mask low mismatch.\n") , entry->id, entry->quals_info[qual_idx].qualify)); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, " set 0x%x, get 0x%x.\n"), entry->quals_info[qual_idx].mask[0], mask_verify[0])); _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(data_verify[1] != entry->quals_info[qual_idx].data[1]) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d data_qualifier %d data high mismatch.\n") , entry->id, entry->quals_info[qual_idx].qualify)); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, " set 0x%x, get 0x%x.\n"), entry->quals_info[qual_idx].data[1], data_verify[1])); _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(mask_verify[1] != entry->quals_info[qual_idx].mask[1]) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d data_qualifier %d mask high mismatch.\n") , entry->id, entry->quals_info[qual_idx].qualify)); LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, " set 0x%x, get 0x%x.\n"), entry->quals_info[qual_idx].mask[1], mask_verify[1])); _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } } } } /* actions verification */ if(!_BCM_DPP_FIELD_ENTRY_IS_PRESEL(entry->id)) { for(action_idx = 0; action_idx < _BCM_PETRA_FIELD_TEST_MAX_ACTIONS_IN_ENTRY; ++action_idx) { if(entry->actions_info[action_idx].is_valid) { rv = bcm_field_action_get(unit, entry->id, entry->actions_info[action_idx].action, &param0_verify, &param1_verify); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(entry->actions_info[action_idx].param0 != param0_verify) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d action %s param0 retrieving mismatch set %d get %d.\n"), entry->id, actions_names[entry->actions_info[action_idx].action], entry->actions_info[action_idx].param0, param0_verify)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } if(entry->actions_info[action_idx].param1 != param1_verify) { if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_ERR || print_anyway) { LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "entry %d action %s param1 retrieving mismatch set %d get %d.\n"), entry->id, actions_names[entry->actions_info[action_idx].action], entry->actions_info[action_idx].param1, param1_verify)); } _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } } } return CMD_OK; } /* Set data and mask for qualifier */ STATIC cmd_result_t _bcm_petra_field_test_set_qualifier(int unit, _bcm_dpp_field_stage_idx_t stage, uint32 type, bcm_field_qualify_t qualifier, uint32 x, uint32 *data, uint32 *mask) { uint32 second_rand_param = 0; cmd_result_t result; result = _bcm_petra_field_test_set_qualifiers_info(unit, stage, type); if(result != CMD_OK) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return result; } result = _bcm_petra_field_test_get_valid_value_and_mask(unit, stage, type, qualifier, x + second_rand_param++, data, mask); return result; } /* * get randomly param0 and param1 for action */ STATIC cmd_result_t _bcm_petra_field_test_set_action(int unit, bcm_field_action_t action, uint32 x, uint32 *param0, uint32 *param1) { uint32 second_rand_param = 0; if(_BCM_PETRA_FIELD_TEST_DEBUG_CHECK_VERB) { const static char *actions_names[] = BCM_FIELD_ACTION_STRINGS; LOG_INFO(BSL_LS_BCM_FP, (BSL_META_U(unit, "Getting valid param0 and param1 for the action %s (%d)\n"), actions_names[action], action)); } switch(action) { case bcmFieldActionUsePolicerResult: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (BCM_FIELD_USE_POLICER_RESULT_EGRESS + 1); *param1 = 0; break; case bcmFieldActionSystemHeaderSet: *param0 = bcmFieldSystemHeaderPphEei; *param1 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0xFFFFFF + 1); break; case bcmFieldActionLearnForwardingVlanIdNew: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0x7FFF + 1); *param1 = 0; break; case bcmFieldActionFilters: *param0 = BCM_FIELD_FILTER_SA_DISABLED; *param1 = 0; break; case bcmFieldActionOrientationSet: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (bcmFieldOrientationAccess + 1); *param1 = 0; break; case bcmFieldActionDhcpPkt: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; *param1 = 0; break; case bcmFieldActionStartPacketStrip: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (bcmFieldStartToFwdNextStrip + 1); *param1 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0x1F + 1); break; case bcmFieldActionForwardingTypeNew: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % 10; if(*param0 == 0) { *param0 = bcmFieldForwardingTypeL2; } else { *param0 += -1 + bcmFieldForwardingTypeIp4Ucast; } *param1 = 0; break; case bcmFieldActionStatTag: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0xFF + 1); *param1 = 0; break; case bcmFieldActionMultipathHashAdditionalInfo: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0xFFFFF + 1); *param1 = 0; break; case bcmFieldActionTrunkHashKeySet: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0xFFFFF + 1); *param1 = 0; break; case bcmFieldActionDropPrecedence: *param0 = (_bcm_petra_field_rand_val(x, second_rand_param++) % (BCM_FIELD_COLOR_BLACK - BCM_FIELD_COLOR_GREEN)) + BCM_FIELD_COLOR_GREEN; *param1 = 0; break; case bcmFieldActionMirrorEgressDisable: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % 2; *param0 = 0; break; case bcmFieldActionVrfSet: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0xFFF + 1); *param1 = 0; break; case bcmFieldActionDscpNew: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0xFF + 1); *param1 = 0; break; case bcmFieldActionTtlSet: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0xFF + 1); *param1 = 0; break; case bcmFieldActionVSwitchNew: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % (0xFFFF + 1); *param1 = 0; break; case bcmFieldActionEcnNew: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % 4; *param1 = 0; break; case bcmFieldActionPrioIntNew: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % 8; *param1 = 0; break; case bcmFieldActionPphPresentSet: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % 4; *param1 = 0; break; case bcmFieldActionFabricHeaderSet: *param0 = _bcm_petra_field_rand_val(x, second_rand_param++) % 16; *param1 = 0; break; case bcmFieldActionExternalValue0Set: case bcmFieldActionExternalValue1Set: case bcmFieldActionExternalValue2Set: case bcmFieldActionExternalValue3Set: case bcmFieldActionExternalValue4Set: case bcmFieldActionExternalValue5Set: case bcmFieldActionExternalValue6Set: case bcmFieldActionExternalValue7Set: *param0 = 1 + _bcm_petra_field_rand_val(x, second_rand_param++) % ((1 << 16) - 1); *param1 = 0; break; case bcmFieldActionCnmCancel: case bcmFieldActionMacDaKnown: case bcmFieldActionDoNotLearn: default: *param0 = 0; *param1 = 0; } return CMD_OK; } /* The following function return 0 is success and 1 in failure */ STATIC uint8 _bcm_petra_field_test_vlan_header_to_buffer(_bcm_petra_field_test_vlan_header_t *vlan_header, uint32* buffer) { if(vlan_header->cfi > 1) { return 1; } if(vlan_header->pri > 7) { return 1; } if(vlan_header->vlan_id > 4095) { return 1; } *buffer = (uint32)vlan_header->vlan_id; *buffer |= (uint32)vlan_header->cfi << 12; *buffer |= (uint32)vlan_header->pri << 13; *buffer |= (uint32)vlan_header->tag_protocol_id << 16; return 0; } STATIC uint8 _bcm_petra_field_test_ethernet_header_to_buffer(_bcm_petra_field_test_ethernet_header_t *ethernet_header, uint32 *buffer) { uint32 vlan_buf; uint32 mac_buf[2]; int unit = BSL_UNIT_UNKNOWN; if(ethernet_header->nof_vlans > 2) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } buffer[0] = (uint32)ethernet_header->ethertype; /* inner vlan if esxist */ if(ethernet_header->nof_vlans == 2) { if(_bcm_petra_field_test_vlan_header_to_buffer(&ethernet_header->vlans[1], &vlan_buf)) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } buffer[0] |= (vlan_buf & 0xffff) << 16; buffer[1] = vlan_buf >> 16; } /* outer vlan if exist */ if(ethernet_header->nof_vlans >= 1) { if(_bcm_petra_field_test_vlan_header_to_buffer(&ethernet_header->vlans[0], &vlan_buf)) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } buffer[ethernet_header->nof_vlans -1] |= (vlan_buf & 0xffff) << 16; buffer[ethernet_header->nof_vlans] = vlan_buf >> 16; } mac_to_buffer(ethernet_header->source_address, mac_buf); buffer[ethernet_header->nof_vlans] |= (mac_buf[0] & 0xffff) << 16; buffer[ethernet_header->nof_vlans + 1] = (mac_buf[0] >> 16) & 0xffff; buffer[ethernet_header->nof_vlans + 1] |= (mac_buf[1] & 0xffff) << 16; mac_to_buffer(ethernet_header->destination_address, &buffer[ethernet_header->nof_vlans + 2]); return 0; } STATIC uint8 _bcm_petra_field_test_ipv4_header_to_buffer(_bcm_petra_field_test_ipv4_header_t *ipv4_header, uint32 *buffer) { int unit = BSL_UNIT_UNKNOWN; if(ipv4_header->fragment_offset > 0x1fff) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } if(ipv4_header->flags > 0x7) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } if(ipv4_header->ecn > 0x3) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } if(ipv4_header->dscp && ipv4_header->ecn) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } if(ipv4_header->internet_header_length > 0xf) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } if(ipv4_header->version > 0xf) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } buffer[0] = ipv4_header->destination_address; buffer[1] = ipv4_header->source_address; buffer[2] = ipv4_header->header_checksum; buffer[2] |= (uint32)ipv4_header->protocol << 16; buffer[2] |= (uint32)ipv4_header->time_to_live << 24; buffer[3] = ipv4_header->fragment_offset; buffer[3] |= (uint32)ipv4_header->flags << 13; buffer[3] |= (uint32)ipv4_header->identification << 16; buffer[4] = ipv4_header->total_length; if(ipv4_header->ecn) { buffer[4] |= (uint32)ipv4_header->ecn << 16; } if(ipv4_header->dscp) { buffer[4] |= (uint32)ipv4_header->dscp << 16; } buffer[4] |= (uint32)ipv4_header->internet_header_length << 24; buffer[4] |= (uint32)ipv4_header->version << 28; return 0; } STATIC uint8 _bcm_petra_field_test_ipv6_header_to_buffer(_bcm_petra_field_test_ipv6_header_t *ipv6_header, uint32 *buffer){ int unit = BSL_UNIT_UNKNOWN; if(ipv6_header->flow_label > 0xfffff){ _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } if(ipv6_header->version > 0xf) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } ip6_to_buffer(ipv6_header->destination_address, buffer); ip6_to_buffer(ipv6_header->source_address, &buffer[4]); buffer[8] = ipv6_header->hop_limit; buffer[8] |= ipv6_header->next_header << 8; buffer[8] |= ipv6_header->payload_length << 16; buffer[9] = ipv6_header->flow_label; buffer[9] |= ipv6_header->traffic_class << 20; buffer[9] |= ipv6_header->version << 28; return 0; } STATIC uint8 _bcm_petra_field_test_mpls_header_to_buffer(_bcm_petra_field_test_mpls_header_t *mpls_header, uint32 *buffer) { int unit = BSL_UNIT_UNKNOWN; if(mpls_header->bos > 1) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } if(mpls_header->exp > 0x7) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } if(mpls_header->label > 0xfffff) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } *buffer = mpls_header->time_to_live; *buffer |= mpls_header->bos << 8; *buffer |= mpls_header->exp << 9; *buffer |= mpls_header->label << 12; return 0; } STATIC uint8 _bcm_petra_field_test_buffer_to_mpls_header(uint32 value, _bcm_petra_field_test_mpls_header_t *mpls_header) { mpls_header->time_to_live = value & 0xff; mpls_header->bos = (value >> 8) & 0x1; mpls_header->exp = (value >> 9) & 0x7; mpls_header->label = value >> 12; return 0; } STATIC uint8 _bcm_petra_field_test_tcp_header_to_buffer(_bcm_petra_field_test_tcp_header_t *tcp_header, uint32 *buffer) { int unit = BSL_UNIT_UNKNOWN; if(tcp_header->control > 0x3f) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } sal_memset(buffer, 0x0, 20); buffer[1] |= tcp_header->control << 16; buffer[4] = tcp_header->destination_port; buffer[4] |= tcp_header->source_port << 16; return 0; } /* for fliping only one bit to cause not match and then not hitting */ STATIC uint8 first_set_bit_ndx(uint32 mask) { uint8 ndx = 0; if(mask == 0) { return 0xff; } while((mask & 0x1) == 0) { mask >>= 1; ++ndx; } return ndx; } /* If we wand to use the qualifier MplsLabel2XXX, we can't expect MplsLabel1Bos to be true. If so, changing the data of the qualifier MplsLabel1Bos. The same if we want to use MplsLabel3XXX idx can be 1 or 2 */ STATIC cmd_result_t _bcm_petra_field_reset_MplsLabelXBos_assert(int unit, _bcm_dpp_field_stage_idx_t stage, uint8 idx, uint8 is_predefined, bcm_field_group_t fg_id, _bcm_petra_field_test_entry_info_t *entry) { uint32 qual_idx; uint8 should_reinstall = FALSE; bcm_error_t rv; uint32 action_index; const static bcm_field_qualify_t relevant_qualifier_bos[] = {-1, bcmFieldQualifyMplsLabel1Bos, bcmFieldQualifyMplsLabel2Bos}; const static bcm_field_qualify_t relevant_qualifier_all[] = {-1, bcmFieldQualifyMplsLabel1, bcmFieldQualifyMplsLabel2}; for(qual_idx = 0; qual_idx < _BCM_PETRA_FIELD_TEST_MAX_QUALIFIERS_IN_ENTRY; ++qual_idx) { if(entry->quals_info[qual_idx].qualify == relevant_qualifier_bos[idx]) { if (entry->quals_info[qual_idx].data[0] == 1 && entry->quals_info[qual_idx].mask[0] == 1) { /* i.e. The first mpls should be the last */ if(is_predefined) { return CMD_NOTIMPL; } else { entry->quals_info[qual_idx].data[0] = 0; should_reinstall = TRUE; break; } } } else if(entry->quals_info[qual_idx].qualify == relevant_qualifier_all[idx]) { if ((entry->quals_info[qual_idx].data[0] & (1 << 8) ) && (entry->quals_info[qual_idx].mask[0] & (1 << 8)) ) { /* i.e. The first mpls should be the last ,because of the Bos bit is set*/ if(is_predefined) { return CMD_NOTIMPL; } else { entry->quals_info[qual_idx].data[0] &= ~(1 << 8); should_reinstall = TRUE; break; } } } } if(should_reinstall) { rv = bcm_field_entry_destroy(unit, entry->id); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } rv = bcm_field_entry_create(unit, fg_id, &entry->id); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } for(qual_idx = 0; qual_idx < _BCM_PETRA_FIELD_TEST_MAX_QUALIFIERS_IN_ENTRY; ++qual_idx) { if(entry->quals_info[qual_idx].is_valid) { _bcm_petra_field_test_operate_set_function(unit, stage, _BCM_PETRA_FIELD_TYPE_MPLS, entry->id, entry->quals_info[qual_idx].qualify, entry->quals_info[qual_idx].data, entry->quals_info[qual_idx].mask); } } for(action_index = 0; action_index < _BCM_PETRA_FIELD_TEST_MAX_ACTIONS_IN_ENTRY; ++action_index) { if(entry->actions_info[action_index].is_valid) { rv = bcm_field_action_add(unit, entry->id, entry->actions_info[action_index].action, entry->actions_info[action_index].param0, entry->actions_info[action_index].param1); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } } rv = bcm_field_entry_install(unit, entry->id); if(rv != BCM_E_NONE) { _BCM_PETRA_FIELD_TEST_FAIL_MSG; return CMD_FAIL; } } return CMD_OK; } STATIC uint8 ip_protocol_common_to_protocol_id(bcm_field_IpProtocolCommon_t bcm_protocol_common, uint8 *protocol) { int unit = BSL_UNIT_UNKNOWN; switch(bcm_protocol_common) { case bcmFieldIpProtocolCommonTcp: *protocol = 6; break; case bcmFieldIpProtocolCommonUdp: *protocol = 17; break; case bcmFieldIpProtocolCommonIgmp: *protocol = 2; break; case bcmFieldIpProtocolCommonIcmp: *protocol = 1; break; case bcmFieldIpProtocolCommonIp6Icmp: *protocol = 58; break; case bcmFieldIpProtocolCommonIp6HopByHop: *protocol = 0; break; case bcmFieldIpProtocolCommonIpInIp: *protocol = 4; break; case bcmFieldIpProtocolCommonTcpUdp: *protocol = 6; /* we choose TCP */ break; case bcmFieldIpProtocolCommonUnknown: *protocol = 5;/* this is the choose */ break; case bcmFieldIpProtocolCommonIp6InIp: *protocol = 0x29; break; case bcmFieldIpProtocolCommonMplsInIp: *protocol = 0x89; break; default: _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } return 0; } STATIC uint8 ip_protocol_common_to_protocol_id_mismatch(bcm_field_IpProtocolCommon_t bcm_protocol_common, uint8 *protocol) { int unit = BSL_UNIT_UNKNOWN; switch(bcm_protocol_common) { case bcmFieldIpProtocolCommonTcp: *protocol = 5; break; case bcmFieldIpProtocolCommonUdp: *protocol = 5; break; case bcmFieldIpProtocolCommonIgmp: *protocol = 5; break; case bcmFieldIpProtocolCommonIcmp: *protocol = 5; break; case bcmFieldIpProtocolCommonIp6Icmp: *protocol = 5; break; case bcmFieldIpProtocolCommonIp6HopByHop: *protocol = 5; break; case bcmFieldIpProtocolCommonIpInIp: *protocol = 5; break; case bcmFieldIpProtocolCommonTcpUdp: *protocol = 5; break; case bcmFieldIpProtocolCommonUnknown: *protocol = 6;/* tcp */ break; case bcmFieldIpProtocolCommonIp6InIp: *protocol = 5; break; case bcmFieldIpProtocolCommonMplsInIp: *protocol = 5; break; default: _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } return 0; } STATIC uint8 ip_type_to_ethertype_id(bcm_field_IpType_t bcm_ip_type, uint16 *ethertype) { int unit = BSL_UNIT_UNKNOWN; switch(bcm_ip_type) { case bcmFieldIpTypeIpv4Any: *ethertype = 0x800; break; case bcmFieldIpTypeIpv6: *ethertype = 0x86dd; break; case bcmFieldIpTypeArp: *ethertype = 0x0806; break; case bcmFieldIpTypeTrill: *ethertype = 0xfefe; break; case bcmFieldIpTypeMim: *ethertype = 0x88e7; break; case bcmFieldIpTypeMplsUnicast: *ethertype = 0x8847; break; case bcmFieldIpTypeAny: *ethertype = 0x801; break; default: _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } return 0; } STATIC uint8 ip_type_to_ethertype_id_mismatch(bcm_field_IpType_t bcm_ip_type, uint16 *ethertype) { int unit = BSL_UNIT_UNKNOWN; switch(bcm_ip_type) { case bcmFieldIpTypeIpv4Any: *ethertype = 0x801; break; case bcmFieldIpTypeIpv6: *ethertype = 0x801; break; case bcmFieldIpTypeArp: *ethertype = 0x801; break; case bcmFieldIpTypeTrill: *ethertype = 0x801; break; case bcmFieldIpTypeMim: *ethertype = 0x801; break; case bcmFieldIpTypeMplsUnicast: *ethertype = 0x801; break; case bcmFieldIpTypeAny: *ethertype = 0x800; break; default: _BCM_PETRA_FIELD_TEST_FAIL_MSG; return 1; } return 0; } /* Build packet for data qualifiers. * We assume that we have ipv4 Other ipv6 other ethernet */ STATIC cmd_result_t _bcm_petra_field_test_data_qualifiers_build_packet(int unit, _bcm_petra_field_test_entry_info_t *entry, uint8 should_hit, uint32 *buffer) { /* in the case we want not hit, if all the masks are 0 it may hit anyway */ uint8 may_not_hit = FALSE; _bcm_petra_field_test_ethernet_header_t ethernet_header; _bcm_petra_field_test_ipv4_header_t ipv4_header; _bcm_petra_field_test_ipv6_header_t ipv6_header; uint32 qual_idx; uint32 tmp_data; uint32 tmp_buffer[10]; bcm_field_data_qualifier_t dq; bcm_error_t rv; uint32 dq_offset_addition; sal_memset(&ethernet_header, 0x0, sizeof(ethernet_header)); sal_memset(&ipv4_header, 0x0, sizeof(ipv4_header)); sal_memset(&ipv6_header, 0x0, sizeof(ipv6_header)); sal_memset(buffer, 0xa5, _BCM_PETRA_FIELD_TEST_PACKET_SIZE_BYTES(unit)); /* The headers will override part of the payload latter */ ethernet_header.ethertype = 0x86dd; /* ipv6 */ ethernet_header.nof_vlans = 1; ethernet_header.vlans[0].tag_protocol_id = 0x8100; /* s.a. != 0 */ mac_to_buffer(ethernet_header.destination_address, tmp_buffer); tmp_buffer[0] = 0x1; buffer_to_mac(tmp_buffer, &ethernet_header.destination_address); ipv6_header.version = 6; ipv6_header.payload_length = _BCM_PETRA_FIELD_TEST_PACKET_SIZE_BYTES(unit) - 60 - 14 - 4 * ethernet_header.nof_vlans; ipv6_header.next_header = 4; /* ipv4 */ ipv4_header.version = 4; ipv4_header.internet_header_length = 0x5; sal_memset(tmp_buffer, 0x0, sizeof(tmp_buffer)); if(_bcm_petra_field_test_ipv4_header_to_buffer(&ipv4_header, tmp_buffer)) {