openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

field.c (28114B)


      1 
      2 /*
      3  * 
      4  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      5  * 
      6  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      7  *
      8  * Field - Broadcom StrataSwitch Field Processor switch common API.
      9  */
     10 #include <soc/types.h>
     11 #include <soc/ll.h>
     12 
     13 #include <bcm/field.h>
     14 
     15 /*
     16  * Function:
     17  *      bcm_field_udf_spec_t_init
     18  * Purpose:
     19  *      Initialize a UDF data type.
     20  */
     21 
     22 void 
     23 bcm_field_udf_spec_t_init(bcm_field_udf_spec_t *udf_spec)
     24 {
     25     if (NULL != udf_spec) {
     26         sal_memset(udf_spec, 0, sizeof(bcm_field_udf_spec_t));
     27     }
     28     return;
     29 }
     30 
     31 /*
     32  * Function:
     33  *      bcm_field_llc_header_t_init
     34  * Purpose:
     35  *      Initialize the bcm_field_llc_header_t structure.
     36  * Parameters:
     37  *      llc_header - Pointer to llc header structure.
     38  * Returns:
     39  *      NONE
     40  */
     41 void
     42 bcm_field_llc_header_t_init(bcm_field_llc_header_t *llc_header)
     43 {
     44     if (llc_header != NULL) {
     45         sal_memset(llc_header, 0, sizeof (*llc_header));
     46     }
     47     return;
     48 }
     49 
     50 /*
     51  * Function:
     52  *      bcm_field_snap_header_t_init
     53  * Purpose:
     54  *      Initialize the bcm_field_snap_header_t structure.
     55  * Parameters:
     56  *      snap_header - Pointer to snap header structure.
     57  * Returns:
     58  *      NONE 
     59  */
     60 void
     61 bcm_field_snap_header_t_init(bcm_field_snap_header_t *snap_header)
     62 {
     63     if (snap_header != NULL) {
     64         sal_memset(snap_header, 0, sizeof (*snap_header));
     65     }
     66     return;
     67 }
     68 
     69 /*
     70  * Function:
     71  *      bcm_field_qset_t_init
     72  * Purpose:
     73  *      Initialize the bcm_field_qset_t structure.
     74  * Parameters:
     75  *      qset - Pointer to field qset structure.
     76  * Returns:
     77  *      NONE
     78  */
     79 void
     80 bcm_field_qset_t_init(bcm_field_qset_t *qset)
     81 {
     82     if (qset != NULL) {
     83         sal_memset(qset, 0, sizeof (*qset));
     84     }
     85     return;
     86 }
     87 
     88 /*
     89  * Function:
     90  *      bcm_field_aset_t_init
     91  * Purpose:
     92  *      Initialize the bcm_field_aset_t structure.
     93  * Parameters:
     94  *      aset - Pointer to field aset structure.
     95  * Returns:
     96  *      NONE
     97  */
     98 void
     99 bcm_field_aset_t_init(bcm_field_aset_t *aset)
    100 {
    101     if (aset != NULL) {
    102         sal_memset(aset, 0, sizeof (*aset));
    103     }
    104     return;
    105 }
    106 
    107 /*
    108  * Function:
    109  *      bcm_field_presel_set_t_init
    110  * Purpose:
    111  *      Initialize the bcm_field_presel_set_t structure.
    112  * Parameters:
    113  *      presel_set - Pointer to field aset structure.
    114  * Returns:
    115  *      NONE
    116  */
    117 void
    118 bcm_field_presel_set_t_init(bcm_field_presel_set_t *presel_set)
    119 {
    120     if (presel_set != NULL) {
    121         sal_memset(presel_set, 0, sizeof (*presel_set));
    122     }
    123     return;
    124 }
    125 
    126 /*
    127  * Function:
    128  *      bcm_field_group_status_t_init
    129  * Purpose:
    130  *      Initialize the Field Group Status structure.
    131  * Parameters:
    132  *      fgroup - Pointer to Field Group Status structure.
    133  * Returns:
    134  *      NONE
    135  */
    136 void
    137 bcm_field_group_status_t_init(bcm_field_group_status_t *fgroup)
    138 {
    139     if (fgroup != NULL) {
    140         sal_memset(fgroup, 0, sizeof (*fgroup));
    141     }
    142     return;
    143 }
    144 
    145 /*
    146  * Function:
    147  *      bcm_field_class_info_t_init
    148  * Purpose:
    149  *      Initialize the Field Class Info structure.
    150  * Parameters:
    151  *      fclass - Pointer to Field Class Info structure.
    152  * Returns:
    153  *      NONE
    154  */
    155 void
    156 bcm_field_class_info_t_init(bcm_field_class_info_t *fclass)
    157 {
    158     if (fclass != NULL) {
    159         sal_memset(fclass, 0, sizeof (*fclass));
    160     }
    161     return;
    162 }
    163 
    164 /*
    165  * Function:
    166  *      bcm_field_data_qualifier_t
    167  * Purpose:
    168  *      Initialize the Field Data Qualifier structure.
    169  * Parameters:
    170  *      data_qual - Pointer to field data qualifier structure.
    171  * Returns:
    172  *      NONE
    173  */
    174 void
    175 bcm_field_data_qualifier_t_init(bcm_field_data_qualifier_t *data_qual)
    176 {
    177     if (data_qual != NULL) {
    178         sal_memset(data_qual, 0, sizeof (bcm_field_data_qualifier_t));
    179     }
    180     return;
    181 }
    182 
    183 /*
    184  * Function:
    185  *      bcm_field_data_ethertype_t_init
    186  * Purpose:
    187  *      Initialize ethertype based field data qualifier. 
    188  * Parameters:
    189  *      etype - Pointer to ethertype based data qualifier structure.
    190  * Returns:
    191  *      NONE
    192  */
    193 void
    194 bcm_field_data_ethertype_t_init (bcm_field_data_ethertype_t *etype)
    195 {
    196     if (etype != NULL) {
    197         sal_memset(etype, 0, sizeof (bcm_field_data_ethertype_t));
    198         etype->l2 = BCM_FIELD_DATA_FORMAT_L2_ANY;
    199         etype->vlan_tag = BCM_FIELD_DATA_FORMAT_VLAN_TAG_ANY; 
    200     }
    201     return;
    202 }
    203 
    204 /*
    205  * Function:
    206  *      bcm_field_data_ip_protocol_t_init
    207  * Purpose:
    208  *      Initialize ip protocol based field data qualifier. 
    209  * Parameters:
    210  *      etype - Pointer to ip_protocol based data qualifier structure.
    211  * Returns:
    212  *      NONE
    213  */
    214 void
    215 bcm_field_data_ip_protocol_t_init (bcm_field_data_ip_protocol_t *ip_protocol)
    216 {
    217     if (ip_protocol != NULL) {
    218         sal_memset(ip_protocol, 0, sizeof (bcm_field_data_ip_protocol_t));
    219         ip_protocol->flags = BCM_FIELD_DATA_FORMAT_IP_ANY;
    220         ip_protocol->ip = 0xFF; /* Reserved  IP Protocol ID */
    221         ip_protocol->l2 = BCM_FIELD_DATA_FORMAT_L2_ANY;
    222         ip_protocol->vlan_tag = BCM_FIELD_DATA_FORMAT_VLAN_TAG_ANY; 
    223     }
    224     return;
    225 }
    226 
    227 /*
    228  * Function:
    229  *      bcm_field_data_packet_format_t_init
    230  * Purpose:
    231  *      Initialize packet format based field data qualifier. 
    232  * Parameters:
    233  *      packet_format - Pointer to packet_format based data qualifier structure.
    234  * Returns:
    235  *      NONE
    236  */
    237 void
    238 bcm_field_data_packet_format_t_init (bcm_field_data_packet_format_t *packet_format)
    239 {
    240     if (packet_format != NULL) {
    241         sal_memset(packet_format, 0, sizeof (bcm_field_data_packet_format_t));
    242         packet_format->l2  = BCM_FIELD_DATA_FORMAT_L2_ANY;
    243         packet_format->vlan_tag  = BCM_FIELD_DATA_FORMAT_VLAN_TAG_ANY;
    244         packet_format->outer_ip  = BCM_FIELD_DATA_FORMAT_IP_ANY;
    245         packet_format->inner_ip  = BCM_FIELD_DATA_FORMAT_IP_ANY;
    246         packet_format->tunnel  = BCM_FIELD_DATA_FORMAT_TUNNEL_ANY;
    247         packet_format->mpls  = BCM_FIELD_DATA_FORMAT_MPLS_ANY;
    248         packet_format->fibre_chan_outer  = BCM_FIELD_DATA_FORMAT_FIBRE_CHAN_ANY;
    249         packet_format->fibre_chan_inner  = BCM_FIELD_DATA_FORMAT_FIBRE_CHAN_ANY;
    250         packet_format->flags = 0x0;
    251     }
    252     return;
    253 }
    254 
    255 /*
    256  * Function:
    257  *      bcm_field_group_config_t_init
    258  * Purpose:
    259  *      Initialize the Field Group Config structure.
    260  * Parameters:
    261  *      data_qual - Pointer to field group config structure.
    262  * Returns:
    263  *      NONE
    264  */
    265 void
    266 bcm_field_group_config_t_init(bcm_field_group_config_t *group_config)
    267 {
    268     if (group_config != NULL) {
    269         sal_memset(group_config, 0, sizeof (bcm_field_group_config_t));
    270         group_config->action_res_id = BCM_FIELD_GROUP_ACTION_RES_ID_DEFAULT;
    271     }
    272 
    273     return;
    274 }
    275 
    276 void
    277 bcm_field_group_config_extension_t_init(bcm_field_group_config_extension_t *group_config)
    278 {
    279     if (group_config != NULL) {
    280         sal_memset(group_config, 0, sizeof (bcm_field_group_config_extension_t));
    281         group_config->action_res_id = BCM_FIELD_GROUP_ACTION_RES_ID_DEFAULT;
    282     }
    283 
    284     return;
    285 }
    286 
    287 void bcm_field_group_presel_info_init(
    288     int nof_presel_info,
    289     bcm_field_group_presel_info_t *presel_info
    290 )
    291 {
    292     int hw_index, qual_index, presel_index;
    293 
    294     for (presel_index = 0; presel_index < nof_presel_info; presel_index++)
    295     {
    296         presel_info[presel_index].presel_id = BCM_FIELD_ENTRY_INVALID;
    297         for (qual_index = 0; qual_index < BCM_FIELD_NOF_QUALS_PER_FG; qual_index++)
    298         {
    299             presel_info[presel_index].qual_info[qual_index].qual = BCM_FIELD_ENTRY_INVALID;
    300             for (hw_index = 0; hw_index < BCM_FIELD_NOF_CE_ID_PER_QUAL; hw_index++)
    301             {
    302                 presel_info[presel_index].qual_info[qual_index].ce_id[hw_index] = BCM_FIELD_ENTRY_INVALID;
    303             }
    304         }
    305     }
    306     return;
    307 }
    308 
    309 /*
    310  * Function:
    311  *     bcm_field_entry_oper_t_init
    312  * Purpose:
    313  *     Initialize a field entry operation structure
    314  * Parameters:
    315  *     entry_oper - Pointer to field entry operation structure
    316  * Returns:
    317  *     NONE
    318  */ 
    319 void
    320 bcm_field_entry_oper_t_init(bcm_field_entry_oper_t *entry_oper)
    321 {
    322     if (entry_oper != NULL) {
    323         sal_memset(entry_oper, 0, sizeof (bcm_field_entry_oper_t));
    324     }
    325     return;
    326 }
    327 
    328 /*
    329  * Function:
    330  *      bcm_field_extraction_action_t_init
    331  * Purpose:
    332  *      Initialize the Field Extraction Action structure.
    333  * Parameters:
    334  *      action - Pointer to field extraction action structure.
    335  * Returns:
    336  *      NONE
    337  */
    338 void
    339 bcm_field_extraction_action_t_init(bcm_field_extraction_action_t *action)
    340 {
    341     if (NULL != action) {
    342         sal_memset(action, 0x00, sizeof(*action));
    343     }
    344 }
    345 
    346 /*
    347  * Function:
    348  *      bcm_field_extraction_field_t_init
    349  * Purpose:
    350  *      Initialize the Field Extraction Field structure
    351  * Parameters:
    352  *      extraction - pointer to field extraction field structure
    353  * Returns:
    354  *      NONE
    355  */
    356 void
    357 bcm_field_extraction_field_t_init(bcm_field_extraction_field_t *extraction)
    358 {
    359     if (NULL != extraction) {
    360         sal_memset(extraction, 0x00, sizeof(*extraction));
    361     }
    362 }
    363 
    364 /* Function: bcm_field_hint_t_init
    365  *
    366  * Purpose:
    367  *     Initialize hint data structure.
    368  * Parameters:
    369  *     unit - (IN) BCM device number.
    370  *     hint - (IN) Pointer to bcm_field_hint_t structure
    371  * Returns:
    372  *     None.
    373  */
    374 void bcm_field_hint_t_init(bcm_field_hint_t *hint)
    375 {
    376     if (hint != NULL) {
    377         sal_memset (hint, 0, sizeof (bcm_field_hint_t));
    378     }
    379     return;
    380 }
    381 
    382 /* Function: bcm_field_oam_stat_action_t_init
    383  *
    384  * Purpose:
    385  *     Initialize oam stat action data structure.
    386  * Parameters:
    387  *     unit - (IN) BCM device number.
    388  *     oam_action - (IN) Pointer to bcm_field_oam_stat_action_t structure
    389 
    390  * Returns:
    391  *     None.
    392  */
    393 void bcm_field_oam_stat_action_t_init (bcm_field_oam_stat_action_t *oam_action)
    394 {
    395     if (oam_action != NULL) {
    396         sal_memset (oam_action, 0, sizeof (bcm_field_oam_stat_action_t));
    397     }
    398     return;
    399 }
    400 
    401 /* Function: bcm_field_src_class_t_init
    402  *
    403  * Purpose:
    404  *     Initialize source class mode structure.
    405  * Parameters:
    406  *     unit - (IN) BCM device number.
    407  *     src_class - (IN) Pointer to bcm_field_src_class_t structure
    408 
    409  * Returns:
    410  *     None.
    411  */
    412 void bcm_field_src_class_t_init (bcm_field_src_class_t *src_class)
    413 {
    414     if (src_class != NULL) {
    415         sal_memset (src_class, 0, sizeof (bcm_field_src_class_t));
    416     }
    417     return;
    418 }
    419 
    420 /* Function: bcm_field_copytocpu_config_t_init
    421  *
    422  * Purpose:
    423  *     Initialize CopyToCpu config structure.
    424  * Parameters:
    425  *     unit - (IN) BCM device number.
    426  *     CopyToCpu_config - (IN) Pointer to bcm_field_CopyToCpu_config_t structure
    427  * Returns:
    428  *     None.
    429  */
    430 void bcm_field_copytocpu_config_t_init (bcm_field_CopyToCpu_config_t *CopyToCpu_config)
    431 {
    432     if (CopyToCpu_config != NULL) {
    433         sal_memset (CopyToCpu_config, 0, sizeof (bcm_field_CopyToCpu_config_t));
    434         CopyToCpu_config->flags = BCM_FIELD_COPYTOCPU_ALL_PACKET;
    435     }
    436     return;
    437 }
    438 
    439 /* Function: bcm_field_redirect_config_t_init
    440  *
    441  * Purpose:
    442  *     Initialize redirect config structure.
    443  * Parameters:
    444  *     unit - (IN) BCM device number.
    445  *     redirect_config - (IN) Pointer to bcm_field_redirect_config_t structure
    446  * Returns:
    447  *     None.
    448  */
    449 void bcm_field_redirect_config_t_init (bcm_field_redirect_config_t *redirect_config)
    450 {
    451     if (redirect_config != NULL) {
    452         sal_memset (redirect_config, 0, sizeof (bcm_field_redirect_config_t));
    453         redirect_config->flags = BCM_FIELD_REDIRECT_ALL_PACKET;
    454         redirect_config->destination_type = bcmFieldRedirectDestinationInvalid;
    455         redirect_config->destination = BCM_GPORT_INVALID;
    456         redirect_config->source_port = BCM_GPORT_INVALID;
    457     }
    458     return;
    459 }
    460 
    461 /*
    462  * Function:
    463  *      bcm_field_presel_config_t_init
    464  * Purpose:
    465  *      Initialize Field Presel Config structure.
    466  * Parameters:
    467  *      presel_config - (INOUT) Presel name.
    468  * Returns:
    469  *      None.
    470  */
    471 extern void bcm_field_presel_config_t_init(
    472     bcm_field_presel_config_t *presel_config)
    473 {
    474     if (presel_config != NULL) {
    475         sal_memset (presel_config, 0, sizeof (bcm_field_presel_config_t));
    476     }
    477     return;
    478 }
    479 
    480 /**
    481  * \brief
    482  *  Initialize the bcm_field_context_info_t
    483  * \param [out] context_info  -
    484  *  Pointer to input structure of bcm_field_context_info_t
    485  *  that needs to be initialized
    486  * \return
    487  *  void
    488  * \remark
    489  *  This function should be called prior of using bcm_field_context_info_t struct
    490  * \see
    491  *  Reference to bcm_field_context_create/get
    492  */
    493 extern void bcm_field_context_info_t_init(
    494     bcm_field_context_info_t * context_info)
    495 {
    496     /** Set default values for relevant fields in bcm_field_context_info_t */
    497     if (context_info != NULL)
    498     {
    499         context_info->context_compare_modes.compare_1_mode = bcmFieldContextCompareTypeNone;
    500         context_info->context_compare_modes.compare_2_mode = bcmFieldContextCompareTypeNone;
    501         context_info->state_table_enabled = FALSE;
    502         context_info->hashing_enabled = FALSE;
    503         context_info->state_table_enabled = FALSE;
    504         context_info->cascaded_from = BCM_FIELD_CONTEXT_ID_INVALID;
    505         context_info->name[0] = 0;
    506     }
    507     return;
    508 }
    509 
    510 /**
    511 * \brief
    512 *  Initialize the bcm_field_group_info_t
    513 * \param [in] fg_info  - Pointer to input structure of bcm_field_group_info_t that needs to be initialized
    514 * \return
    515 *  void
    516 * \remark
    517 *  This function should be called prior of using bcm_field_group_info_t struct
    518 * \see
    519 *  Reference to bcm_field_group_add
    520 */
    521 extern void
    522 bcm_field_group_info_t_init(
    523     bcm_field_group_info_t * fg_info)
    524 {
    525     int ii;
    526     if (fg_info != NULL)
    527     {
    528         sal_memset (fg_info, 0, sizeof (bcm_field_group_info_t));
    529         fg_info->stage = bcmFieldStageCount;
    530         fg_info->fg_type = bcmFieldGroupTypeCount;
    531 		fg_info->tcam_info.bank_allocation_mode = bcmFieldTcamBankAllocationModeAuto;
    532         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_ACTIONS_PER_GROUP; ii++)
    533         {
    534             fg_info->action_types[ii] = bcmFieldActionCount;
    535             fg_info->action_with_valid_bit[ii] = TRUE;
    536         }
    537         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_QUALS_PER_GROUP; ii++)
    538         {
    539             fg_info->qual_types[ii] = bcmFieldQualifyCount;
    540             fg_info->qual_is_ranged[ii] = FALSE;
    541         }
    542     }
    543 
    544     return;
    545 }
    546 
    547 /**
    548  * \brief
    549  *  Initialize the bcm_field_qualify_attach_info_t
    550  * \param [out] qual_info -
    551  *  Pointer to input structure of bcm_field_qualify_attach_info_t
    552  *  that needs to be initialized
    553  * \return
    554  *  void
    555  * \remark
    556  *  This function should be called prior of using bcm_field_qualify_attach_info_t struct
    557  * \see
    558  *  Reference to:
    559  *    - bcm_field_group_attach_info_t_init
    560  *    - bcm_field_group_context_attach
    561  *    - bcm_field_group_context_get
    562  */
    563 extern void
    564 bcm_field_qual_attach_info_t_init(
    565     bcm_field_qualify_attach_info_t * qual_info)
    566 {
    567     if (qual_info != NULL) {
    568         sal_memset (qual_info, 0, sizeof (bcm_field_qualify_attach_info_t));
    569         qual_info->input_type = BCM_FIELD_INVALID;
    570         qual_info->input_arg = BCM_FIELD_INVALID;
    571         qual_info->offset = BCM_FIELD_INVALID;
    572     }
    573     return;
    574 }
    575 
    576 
    577 /**
    578  * \brief
    579  *  Initialize the bcm_field_group_attach_info_t
    580  * \param [out] attach_info  -
    581  *  Pointer to input structure of bcm_field_group_attach_info_t
    582  *  that needs to be initialized
    583  * \return
    584  *  void
    585  * \remark
    586  *  This function should be called prior of using bcm_field_group_attach_info_t struct
    587  * \see
    588  *  Reference to:
    589  *    - bcm_field_group_attach_info_t_init
    590  *    - bcm_field_group_context_attach
    591  *    - bcm_field_group_context_get
    592  */
    593 extern void
    594 bcm_field_group_attach_info_t_init(
    595     bcm_field_group_attach_info_t * attach_info)
    596 {
    597     int ii;
    598     if (attach_info != NULL) {
    599         sal_memset (attach_info, 0, sizeof (bcm_field_group_attach_info_t));
    600         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_ACTIONS_PER_GROUP; ii++)
    601         {
    602             attach_info->payload_info.action_types[ii] = bcmFieldActionCount;
    603             attach_info->payload_info.action_info[ii].priority = BCM_FIELD_ACTION_DONT_CARE;
    604             attach_info->payload_info.action_info[ii].valid_bit_polarity = 1;
    605         }
    606         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_QUALS_PER_GROUP; ii++)
    607         {
    608             attach_info->key_info.qual_types[ii] = bcmFieldQualifyCount;
    609             bcm_field_qual_attach_info_t_init(&attach_info->key_info.qual_info[ii]);
    610         }
    611     }
    612     return;
    613 }
    614 
    615 /**
    616 * \brief
    617 *  Initialize the bcm_field_action_info_t
    618 * \param [out] action_info  - Pointer to input structure of bcm_field_action_info_t that needs to be initialized
    619 * \return
    620 *  void
    621 * \remark
    622 *  This function should be called prior of using bcm_dnx_field_action_info_t_init struct
    623 * \see
    624 *  Reference to:
    625 *  - bcm_field_action_create
    626 */
    627 extern void bcm_field_action_info_t_init(
    628     bcm_field_action_info_t *action_info)
    629 {
    630     if (action_info != NULL) {
    631         sal_memset (action_info, 0, sizeof (bcm_field_action_info_t));
    632         action_info->stage = bcmFieldStageCount;
    633         action_info->action_type = bcmFieldActionCount;
    634     }
    635     return;
    636 }
    637 
    638 /**
    639 * \brief
    640 *  Initialize the bcm_field_qualifier_info_create_t
    641 * \param [out] qual_info  - Pointer to input structure of bcm_field_qualifier_info_create_t that needs to be initialized
    642 * \return
    643 *  void
    644 * \remark
    645 *  This function should be called prior of using bcm_field_qualifier_info_create_t struct
    646 * \see
    647 *  Reference to:
    648 *  - bcm_field_qualifier_create
    649 */
    650 extern void bcm_field_qualifier_info_create_t_init(
    651     bcm_field_qualifier_info_create_t *qual_info)
    652 {
    653     if (qual_info != NULL) {
    654         sal_memset (qual_info, 0, sizeof (bcm_field_qualifier_info_create_t));
    655     }
    656     return;
    657 }
    658 
    659 /**
    660 * \brief
    661 *  Initialize the bcm_field_qualifier_info_get_t
    662 * \param [out] qual_info  - Pointer to input structure of bcm_field_qualifier_info_get_t that needs to be initialized
    663 * \return
    664 *  void
    665 * \remark
    666 *  This function should be called prior of using bcm_field_qualifier_info_get_t struct
    667 * \see
    668 *  Reference to:
    669 *  - bcm_field_qualifier_create
    670 */
    671 extern void bcm_field_qualifier_info_get_t_init(
    672     bcm_field_qualifier_info_get_t *qual_info)
    673 {
    674     if (qual_info != NULL) {
    675         sal_memset (qual_info, 0, sizeof (bcm_field_qualifier_info_get_t));
    676         qual_info->qual_class = bcmFieldQualifierClassCount;
    677     }
    678     return;
    679 }
    680 
    681 /**
    682  * \brief
    683  *  Initialize an array of bcm_field_entry_qual_t
    684  * \param [out] entry_qual  -
    685  *  Pointer to an array of BCM_FIELD_NUMBER_OF_ACTIONS_PER_GROUP structures of bcm_field_entry_qual_t
    686  *  that needs to be initialized
    687  * \return
    688  *  void
    689  * \remark
    690  *  This function should be called prior of using an array of bcm_field_entry_qual_t structs
    691  * \see
    692  *  Reference to:
    693  *    - bcm_field_entry_delete
    694  */
    695 extern void bcm_field_entry_qual_t_init(
    696     bcm_field_entry_qual_t entry_qual[BCM_FIELD_NUMBER_OF_ACTIONS_PER_GROUP])
    697 {
    698     int ii;
    699     if (entry_qual != NULL) {
    700         sal_memset (entry_qual, 0, sizeof (bcm_field_entry_qual_t));
    701         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_QUALS_PER_GROUP; ii++)
    702         {
    703             entry_qual[ii].type = bcmFieldQualifyCount;
    704         }
    705     }
    706     return;
    707 }
    708 
    709 /**
    710  * \brief
    711  *  Initialize the bcm_field_entry_info_t
    712  * \param [out] entry_info  -
    713  *  Pointer to input structure of bcm_field_entry_info_t
    714  *  that needs to be initialized
    715  * \return
    716  *  void
    717  * \remark
    718  *  This function should be called prior of using bcm_field_entry_info_t struct
    719  * \see
    720  *  Reference to:
    721  *    - bcm_field_entry_add
    722  *    - bcm_field_entry_info_get
    723  */
    724 extern void bcm_field_entry_info_t_init(
    725     bcm_field_entry_info_t *entry_info)
    726 {
    727     int ii;
    728     if (entry_info != NULL) {
    729         sal_memset (entry_info, 0, sizeof (bcm_field_entry_info_t));
    730         entry_info->nof_entry_quals = BCM_FIELD_INVALID;
    731         entry_info->nof_entry_actions = BCM_FIELD_INVALID;
    732         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_ACTIONS_PER_GROUP; ii++)
    733         {
    734             entry_info->entry_action[ii].type = bcmFieldActionCount;
    735         }
    736         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_QUALS_PER_GROUP; ii++)
    737         {
    738             entry_info->entry_qual[ii].type = bcmFieldQualifyCount;
    739         }
    740         entry_info->core = BCM_CORE_ALL;
    741         entry_info->valid_bit = TRUE;
    742     }
    743     return;
    744 }
    745 
    746 /**
    747  * \brief
    748  *  Initialize the bcm_field_context_hash_info_t
    749  * \param [out] hash_info  -
    750  *  Pointer to input structure of bcm_field_context_hash_info_t
    751  *  that needs to be initialized
    752  * \return
    753  *  void
    754  * \remark
    755  *  This function should be called prior of using bcm_field_context_hash_info_t struct
    756  * \see
    757  *  Reference to:
    758  *    - bcm_field_context_hash_create
    759  */
    760 extern void bcm_field_context_hash_info_t_init(
    761     bcm_field_context_hash_info_t *hash_info)
    762 {
    763     int ii;
    764     if (hash_info != NULL)
    765     {
    766         sal_memset (hash_info, 0, sizeof (bcm_field_context_hash_info_t));
    767         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_QUALS_PER_GROUP; ii++)
    768         {
    769             hash_info->key_info.qual_types[ii] = bcmFieldQualifyCount;
    770             hash_info->key_info.qual_info[ii].input_type = BCM_FIELD_INVALID;
    771             hash_info->key_info.qual_info[ii].input_arg = BCM_FIELD_INVALID;
    772             hash_info->key_info.qual_info[ii].offset = BCM_FIELD_INVALID;
    773         }
    774     }
    775     return;
    776 }
    777 
    778 /**
    779  * \brief
    780  *  Initialize the bcm_field_context_compare_info_t
    781  * \param [out] compare_info  -
    782  *  Pointer to input structure of bcm_field_context_compare_info_t
    783  *  that needs to be initialized
    784  * \return
    785  *  void
    786  * \remark
    787  *  This function should be called prior of using bcm_field_context_compare_info_t struct
    788  * \see
    789  *  Reference to:
    790  *    - bcm_field_context_compare_create
    791  */
    792 extern void bcm_field_context_compare_info_t_init(
    793     bcm_field_context_compare_info_t *compare_info)
    794 {
    795     int ii;
    796     if (compare_info != NULL)
    797     {
    798         sal_memset (compare_info, 0, sizeof (bcm_field_context_compare_info_t));
    799         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_QUALS_PER_GROUP; ii++)
    800         {
    801             compare_info->first_key_info.qual_types[ii] = bcmFieldQualifyCount;
    802             compare_info->first_key_info.qual_info[ii].input_type = BCM_FIELD_INVALID;
    803             compare_info->first_key_info.qual_info[ii].input_arg = BCM_FIELD_INVALID;
    804             compare_info->first_key_info.qual_info[ii].offset = BCM_FIELD_INVALID;
    805         }
    806         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_QUALS_PER_GROUP; ii++)
    807         {
    808             compare_info->second_key_info.qual_types[ii] = bcmFieldQualifyCount;
    809             compare_info->second_key_info.qual_info[ii].input_type = BCM_FIELD_INVALID;
    810             compare_info->second_key_info.qual_info[ii].input_arg = BCM_FIELD_INVALID;
    811             compare_info->second_key_info.qual_info[ii].offset = BCM_FIELD_INVALID;
    812         }
    813     }
    814     return;
    815 }
    816 
    817 /**
    818  * \brief
    819  *  Initialize the bcm_field_ace_format_info_t
    820  * \param [out] ace_format_info -
    821  *  Pointer to input structure of bcm_field_ace_format_info_t
    822  *  that needs to be initialized
    823  * \return
    824  *  void
    825  * \remark
    826  *  This function should be called prior of using bcm_field_ace_format_info_t struct
    827  * \see
    828  *  Reference to:
    829  *    - bcm_field_ace_format_add
    830  *    - bcm_field_ace_format_info_get
    831  */
    832 extern void bcm_field_ace_format_info_t_init(
    833     bcm_field_ace_format_info_t *ace_format_info)
    834 {
    835     int ii;
    836     if (ace_format_info != NULL)
    837     {
    838         sal_memset (ace_format_info, 0, sizeof (bcm_field_ace_format_info_t));
    839         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_ACTIONS_PER_GROUP; ii++)
    840         {
    841             ace_format_info->action_types[ii] = bcmFieldActionCount;
    842             ace_format_info->action_with_valid_bit[ii] = TRUE;
    843         }
    844     }
    845     return;
    846 }
    847 
    848 /**
    849  * \brief
    850  *  Initialize the bcm_field_ace_entry_info_t
    851  * \param [out] entry_info  -
    852  *  Pointer to input structure of bcm_field_ace_entry_info_t
    853  *  that needs to be initialized
    854  * \return
    855  *  void
    856  * \remark
    857  *  This function should be called prior of using bcm_field_ace_entry_info_t struct
    858  * \see
    859  *  Reference to:
    860  *    - bcm_field_ace_entry_add
    861  *    - bcm_field_ace_entry_info_get
    862  */
    863 extern void bcm_field_ace_entry_info_t_init(
    864     bcm_field_ace_entry_info_t *entry_info)
    865 {
    866     int ii;
    867     if (entry_info != NULL)
    868     {
    869         sal_memset (entry_info, 0, sizeof (bcm_field_ace_entry_info_t));
    870         for (ii = 0; ii < BCM_FIELD_NUMBER_OF_ACTIONS_PER_GROUP; ii++)
    871         {
    872             entry_info->entry_action[ii].type = bcmFieldActionCount;
    873         }
    874     }
    875     return;
    876 }
    877 
    878 /**
    879  * \brief
    880  *  Initialize the bcm_field_presel_entry_id_t
    881  * \param [out] entry_id  -
    882  *  Pointer to input structure of bcm_field_presel_entry_id_t
    883  *  that needs to be initialized
    884  * \return
    885  *  void
    886  * \remark
    887  *  This function should be called prior of using bcm_field_presel_entry_id_t struct
    888  * \see
    889  *  Reference to:
    890  *    - bcm_field_presel_set
    891  *    - bcm_field_presel_get
    892  */
    893 extern void bcm_field_presel_entry_id_info_init(
    894     bcm_field_presel_entry_id_t *entry_id)
    895 {
    896     if (entry_id != NULL)
    897     {
    898         entry_id->presel_id = BCM_FIELD_ID_INVALID;
    899         entry_id->stage = bcmFieldStageCount;
    900     }
    901     return;
    902 }
    903 
    904 /**
    905  * \brief
    906  *  Initialize the bcm_field_presel_entry_data_t
    907  * \param [out] entry_data  -
    908  *  Pointer to input structure of bcm_field_presel_entry_data_t
    909  *  that needs to be initialized
    910  * \return
    911  *  void
    912  * \remark
    913  *  This function should be called prior of using bcm_field_presel_entry_data_t struct
    914  * \see
    915  *  Reference to:
    916  *    - bcm_field_presel_set
    917  *    - bcm_field_presel_get
    918  */
    919 extern void bcm_field_presel_entry_data_info_init(
    920     bcm_field_presel_entry_data_t *entry_data)
    921 {
    922     int ii;
    923     if (entry_data != NULL)
    924     {
    925         sal_memset (entry_data, 0, sizeof (bcm_field_presel_entry_data_t));
    926         entry_data->context_id = BCM_FIELD_CONTEXT_ID_INVALID;
    927         for (ii = 0; ii < BCM_FIELD_MAX_NOF_CS_QUALIFIERS; ii++)
    928         {
    929             entry_data->qual_data[ii].qual_type = bcmFieldQualifyCount;
    930         }
    931     }
    932     return;
    933 }
    934 
    935 /**
    936  * \brief
    937  *  Initialize the bcm_field_fem_action_info_t
    938  * \param [out] fem_action_info  -
    939  *  Pointer to input structure of bcm_field_fem_action_info_t
    940  *  that needs to be initialized
    941  * \return
    942  *  void
    943  * \remark
    944  *  This function should be called prior of using bcm_field_fem_action_info_t struct
    945  * \see
    946  *    * bcm_field_fem_action_add
    947  *    * bcm_field_fem_action_info_get
    948  */
    949 extern void bcm_field_fem_action_info_t_init(
    950     bcm_field_fem_action_info_t *fem_action_info)
    951 {
    952     int map_bits_per_fem_iter, extr_per_fem_iter;
    953     if (fem_action_info != NULL)
    954     {
    955         sal_memset (fem_action_info, 0, sizeof (bcm_field_fem_action_info_t));
    956         fem_action_info->fem_input.overriding_fg_id = BCM_FIELD_ID_INVALID;
    957         for (extr_per_fem_iter = 0; extr_per_fem_iter < BCM_FIELD_NUMBER_OF_EXTRACTIONS_PER_FEM; extr_per_fem_iter++)
    958         {
    959             fem_action_info->fem_extraction[extr_per_fem_iter].action_type = bcmFieldActionCount;
    960 
    961             for (map_bits_per_fem_iter = 0; map_bits_per_fem_iter < BCM_FIELD_NUMBER_OF_MAPPING_BITS_PER_FEM; map_bits_per_fem_iter++)
    962             {
    963                 fem_action_info->fem_extraction[extr_per_fem_iter].output_bit[map_bits_per_fem_iter].source_type = bcmFieldFemExtractionOutputSourceTypeCount;
    964             }
    965         }
    966     }
    967     return;
    968 }
    969 
    970 /**
    971  * \brief
    972  *  Initialize the bcm_field_context_param_info_t
    973  * \param [out] context_params -
    974  *  Pointer to input structure of bcm_field_context_param_info_t
    975  *  that needs to be initialized
    976  * \return
    977  *  void
    978  * \remark
    979  *  This function should be called prior of using bcm_field_context_param_info_t struct
    980  * \see
    981  *  Reference to:
    982  *   - bcm_field_context_param_set
    983  */
    984 extern void bcm_field_context_param_info_t_init(
    985     bcm_field_context_param_info_t *context_params)
    986 {
    987     if (context_params != NULL)
    988     {
    989         sal_memset (context_params, 0, sizeof (bcm_field_context_param_info_t));
    990         context_params->param_type = bcmFieldContextParamCount;
    991     }
    992     return;
    993 }
    994 
    995 /**
    996  * \brief
    997  *  Initialize the bcm_field_range_info_t
    998  * \param [out] range_info -
    999  *  Pointer to input structure of bcm_field_range_info_t
   1000  *  that needs to be initialized
   1001  * \return
   1002  *  void
   1003  * \remark
   1004  *  This function should be called prior of using bcm_field_range_info_t struct
   1005  * \see
   1006  *  Reference to:
   1007  *   - bcm_field_range_set
   1008  */
   1009 extern void bcm_field_range_info_t_init(
   1010     bcm_field_range_info_t *range_info)
   1011 {
   1012     if (range_info != NULL)
   1013     {
   1014         sal_memset (range_info, -1, sizeof (bcm_field_range_info_t));
   1015     }
   1016     return;
   1017 }