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

algo_field.h (83210B)


      1 /**
      2  *  \file bcm_int/dnx/algo/field/algo_field.h
      3  * 
      4  *  Internal DNX RX APIs
      5 PIs This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      6 PIs 
      7 PIs Copyright 2007-2020 Broadcom Inc. All rights reserved.
      8  */
      9 
     10 #ifndef ALGO_FIELD_H_INCLUDED
     11 
     12 #define ALGO_FIELD_H_INCLUDED
     13 
     14 #ifndef BCM_DNX_SUPPORT
     15 #error "This file is for use by DNX (JR2) family only!"
     16 #endif
     17 
     18 /*
     19  * { Include
     20 */
     21 
     22 #include <shared/shrextend/shrextend_debug.h>
     23 #include <soc/dnx/dbal/dbal.h>
     24 #include <bcm/types.h>
     25 #include <soc/dnx/dnx_data/auto_generated/dnx_data_device.h>
     26 #include <soc/dnx/dnx_data/auto_generated/dnx_data_field.h>
     27 #include <include/bcm_int/dnx/field/field_map.h>
     28 #include <include/bcm_int/dnx/field/field_actions.h>
     29 #include <include/bcm_int/dnx/field/field_context.h>
     30 #include <bcm_int/dnx/algo/template_mngr/template_manager_types.h>
     31 
     32 /*
     33  * }
     34  */
     35 
     36 /*
     37  * { Macros
     38  */
     39 
     40 #ifndef MIN
     41 #define MIN(a, b) (((a)<(b)) ? (a) : (b))
     42 #endif
     43 
     44 #ifndef MAX
     45 #define MAX(a, b) (((a)>(b)) ? (a) : (b))
     46 #endif
     47 
     48 /*
     49  * }
     50  */
     51 
     52 /*
     53  * { Define
     54  */
     55 
     56 #define DNX_ALGO_FIELD_IPMF_2_FFC              "IPMF_2_FFC"
     57 #define DNX_ALGO_FIELD_IPMF_3_FFC              "IPMF_3_FFC"
     58 #define DNX_ALGO_FIELD_EPMF_FFC                "EPMF_FFC"
     59 #define DNX_ALGO_FIELD_IFWD2_FFC               "IFWD2_FFC"
     60 #define DNX_ALGO_FIELD_IPMF1_INITIAL_KEY_OCC_BMP "IPMF1_INITIAL_KEY_OCC_BMP"
     61 
     62 #define DNX_ALGO_FIELD_PMF_A_FES_ID           "IPMF_A_FES_ID"
     63 #define DNX_ALGO_FIELD_PMF_B_FES_ID           "IPMF_B_FES_ID"
     64 #define DNX_ALGO_FIELD_E_PMF_FES_ID           "EPMF_FES_ID"
     65 
     66 /*
     67  * Allocation of FEM program.
     68  * Currently, this is done on adding FEM to fiewld group.
     69  */
     70 #define DNX_ALGO_FIELD_PMF_A_FEM_PGM_ID       "IPMF_A_FEM_PGM_ID"
     71 
     72 #define DNX_ALGO_FIELD_LINK_PROFILES          "LINK_PROFILES"
     73 #define DNX_ALGO_FIELD_IPMF1_CONTEXT_ID       "IPMF1_CONTEXT_ID"
     74 #define DNX_ALGO_FIELD_IPMF2_CONTEXT_ID       "IPMF2_CONTEXT_ID"
     75 #define DNX_ALGO_FIELD_IPMF3_CONTEXT_ID       "IPMF3_CONTEXT_ID"
     76 #define DNX_ALGO_FIELD_EPMF_CONTEXT_ID        "EPMF_CONTEXT_ID"
     77 
     78 #define DNX_ALGO_FIELD_USER_QUAL_ID           "USER_QUAL_ID"
     79 #define DNX_ALGO_FIELD_USER_ACTION_ID         "USER_ACTION_ID"
     80 
     81 #define DNX_ALGO_FIELD_GROUP_ID                     "FIELD_GROUP_ID"
     82 /** The resource manager instance name used to allocate APP_DB_IDs to SEXEM-3.*/
     83 #define DNX_ALGO_FIELD_SEXEM_APP_DB_ID              "SEXEM_APP_DB_ID"
     84 /** The resource manager instance name used to allocate APP_DB_IDs to LEXEM.*/
     85 #define DNX_ALGO_FIELD_LEXEM_APP_DB_ID              "LEXEM_APP_DB_ID"
     86 /** The resource manager instance name used to allocate ACE ID (result type).*/
     87 #define DNX_ALGO_FIELD_ACE_ID                       "ACE_ID"
     88 /** The resource manager instance name used to allocate ACE keys (PPMC keys) for MC replication and ACE pointers.*/
     89 #define DNX_ALGO_FIELD_ACE_KEY                      "ACE_KEY"
     90 #define DNX_ALGO_FIELD_ENTRY_TCAM_ACCESS_ID         "ENTRY_TCAM_ACCESS_ID"
     91 /** The resource manager instance name used to allocate profile IDs for iPMF1 context selection based on KBP.*/
     92 #define DNX_ALGO_FIELD_KBP_OPCODE_CS_PROFILE_ID     "KBP_OPCODE_CS_PROFILE_ID"
     93 /** The resource manager instance name used to allocate user defined Apptypes.*/
     94 #define DNX_ALGO_FIELD_KBP_USER_APPTYPE             "KBP_USER_APPTYPE"
     95 /** The resource manager instance name used to allocate Flush Profile ID to SEXEM-3.*/
     96 #define DNX_ALGO_FLUSH_PROFILE_ID                   "FLUSH_PROFILE_ID"
     97 
     98 /*
     99  * Definitions and globals related to 'action' templates (one per FEM).
    100  * {
    101  */
    102 /*
    103  * This is the base string that is used for all templates assigned
    104  * to 'action's on FEMs. There are 16 FEMs so there are 16 templates.
    105  */
    106 #define DNX_ALGO_BASE_ACTION_TEMPLATE_RESOURCE      "ACTION TEMPLATE PER FEM"
    107 
    108 /*
    109  * }
    110  */
    111 /**
    112  * The value in place_in_alloc in dnx_algo_field_action_fes_alloc_out_fes_quartet_change_t that indicates
    113  * that the FES quartet is a movement, not a new FES quartet.
    114  */
    115 #define DNX_ALGO_FIELD_ACTION_MOVEMENT (-1)
    116 
    117 /**
    118  * The value for the first "place_in_fg" for actions added post attach.
    119  */
    120 #define DNX_ALGO_FIELD_ACTION_POST_ATTACH_FIRST_PLACE_IN_FG (DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_ACTION_PER_GROUP)
    121 
    122 /**
    123  * The context link profile Invalid value
    124  */
    125 #define DNX_ALGO_FIELD_CONTEXT_LINK_PROFILE_INVALID (0)
    126 
    127 /*
    128  * Defines for 'algo_field_key' (Key allocation)
    129  * {
    130  */
    131 /**
    132  * Defines for SW STATE
    133  * Shortcuts containing a few steps from root of SW STATE till indicated field.
    134  * See field_key_alloc.xml
    135  * {
    136  */
    137 #define KEYS_AVAILABILITY_STAGE_INFO       dnx_field_keys_per_stage_allocation_sw.keys_availability.keys_availability_stage_info
    138 #define KEYS_AVAILABILITY_GROUP_INFO       KEYS_AVAILABILITY_STAGE_INFO.keys_availability_group_info
    139 #define KEY_STAGE_PROG_OCCUPATION          dnx_field_keys_per_stage_allocation_sw.keys_per_stage.key_stage_prog_occupation
    140 #define KEY_STAGE_SUPPORTS_BITMAP_ALLOCATION    dnx_field_keys_per_stage_allocation_sw.keys_per_stage.key_on_stage_supports_bitmap_allocation
    141 #define KEY_OCCUPATION                     KEY_STAGE_PROG_OCCUPATION.key_occupation
    142 #define KEY_OCCUPATION_BIT_RANGE           KEY_STAGE_PROG_OCCUPATION.key_occupation.bit_range_desc
    143 /*
    144  * }
    145  */
    146 
    147 /*
    148  * Enums for 'algo_field_key' (Key allocation)
    149  * {
    150  */
    151 typedef enum
    152 {
    153     /*
    154      * Allocate key with id that was given by user in API
    155      */
    156     DNX_ALGO_FIELD_KEY_FLAG_WITH_ID = 0x1,
    157     DNX_ALGO_FIELD_KEY_FLAG_NOF
    158 } dnx_algo_field_key_flags_e;
    159 /*
    160  * }
    161  */
    162 
    163 /*
    164  * Definitions related to 'bit-range' feature.
    165  * {
    166  */
    167 /**
    168  * \brief A very custom macro to be used to verify that a specified half key is indeed marked
    169  *   as occupied bit on the 'half key' system and on the 'bit-range' system.
    170  * \param [in] _unit  -
    171  *   HW identifier of this unit.
    172  * \param [in] _field_stage   -
    173  *   Stage on which investigated key (and half key) resides.
    174  * \param [in] _context_id   -
    175  *   Context on stage on which investigated key (and half key) resides.
    176  * \param [in] _half_key   -
    177  *   Index of half key, starting from 'first_available_key_on_stage' with even indices for
    178  *   MS halves and odd for LS halves.
    179  * \param [in] _key_id   -
    180  *   Key (A-J) on which specified half key resides. This is required just for display purposes.
    181  * \param [in] _bit_range_offset_within_key   -
    182  *   Offset, in bits, from LS bit, within key, where invetigated bit-range is assumed to reside.
    183  * \param [in] _ms_or_ls   -
    184  *   String. Either "MS" or "LS" depending which half key it is. For display purposes only.
    185  * \see
    186  *   * dnx_algo_field_key_bit_range_free_generic()
    187  */
    188 #define DNX_FIELD_KEY_VERIFY_HALF_KEY_OCCUPATION(_unit, _field_stage, _context_id, _half_key, _key_id, _bit_range_offset_within_key,_ms_or_ls) \
    189 { \
    190     uint8 _is_half_key_range_occupied; \
    191     dnx_field_key_half_occupation_state_e _key_occupation_state; \
    192     SHR_IF_ERR_EXIT(KEY_OCCUPATION.  \
    193                     is_half_key_range_occupied.get(_unit, _field_stage, _context_id, _half_key,&_is_half_key_range_occupied));  \
    194     if (_is_half_key_range_occupied != TRUE)  \
    195     {  \
    196         LOG_ERROR_EX(BSL_LOG_MODULE,  \
    197             "\r\n"  \
    198             "Fail on free bit-range on key: field_stage %s context_id %d key_id %c bit_range_offset_within_key %d\r\n",  \
    199             dnx_field_stage_e_get_name(_field_stage), _context_id, 'A' + _key_id.id[0], _bit_range_offset_within_key);  \
    200         SHR_ERR_EXIT(_SHR_E_PARAM,  \
    201              "\r\n"  \
    202              "%s half of input key_id is marked as 'not occupied' on bit-range system. Illegal. Quit\r\n",_ms_or_ls);  \
    203     }  \
    204     SHR_IF_ERR_EXIT(KEY_OCCUPATION.key_occupation_state.get  \
    205                                 (_unit, _field_stage, _context_id, _half_key, &_key_occupation_state));  \
    206     if (_key_occupation_state == DNX_FIELD_KEY_OCCUPY_NONE)  \
    207     {  \
    208         LOG_ERROR_EX(BSL_LOG_MODULE,  \
    209             "\r\n"  \
    210             "Fail on free bit-range on key: field_stage %s context_id %d key_id %c bit_range_offset_within_key %d\r\n",  \
    211             dnx_field_stage_e_get_name(_field_stage), _context_id, 'A' + _key_id.id[0], _bit_range_offset_within_key);  \
    212         SHR_ERR_EXIT(_SHR_E_PARAM,  \
    213              "\r\n"  \
    214              "%s half of input key_id is marked as 'not occupied' on half key system. Illegal. Quit\r\n",_ms_or_ls);  \
    215     }  \
    216 }
    217 /**
    218  * \brief A very custom macro to be used to verify that a specified half key, at a specified
    219  *   offset, is allocated and is indeed marked with 'filed group type' which is the same as on input.
    220  * \param [in] _unit  -
    221  *   HW identifier of this unit.
    222  * \param [in] _field_stage   -
    223  *   Stage on which investigated key (and half key) resides.
    224  * \param [in] _context_id   -
    225  *   Context on stage on which investigated key (and half key) resides.
    226  * \param [in] _fg_type   -
    227  *   Field group type which is to be compared with the one stored in swstate.
    228  * \param [in] _half_key   -
    229  *   Index of half key, starting from 'first_available_key_on_stage' with even indices for
    230  *   MS halves and odd for LS halves.
    231  * \param [in] _key_id   -
    232  *   Key (A-J) on which specified half key resides. This is required just for display purposes.
    233  * \param [in] _bit_range_offset_within_key   -
    234  *   Offset, in bits, from LS bit, within key, where invetigated bit-range is assumed to reside.
    235  * \param [in] _ms_or_ls   -
    236  *   String. Either "MS" or "LS" depending which half key it is. For display purposes only.
    237  * \param [out] _key_length_local   -
    238  *   This variable is supplied by the caller and is loaded, by this macro, by the number of bits
    239  *   in the pointed 'bit-range'.
    240  * \see
    241  *   * dnx_algo_field_key_bit_range_free_generic()
    242  */
    243 #define DNX_FIELD_KEY_VERIFY_FG_TYPE_FOR_BIT_RANGE(_unit, _field_stage, _context_id, _fg_type, _half_key, _key_id, _bit_range_offset_within_key,_ms_or_ls,_key_length_local) \
    244 { \
    245     uint8 _local_fg_type; \
    246     /*  \
    247      * Verify bit-range was indeed allocated at this offset.  \
    248      */  \
    249     SHR_IF_ERR_EXIT(KEY_OCCUPATION_BIT_RANGE.bit_range_size.get  \
    250                     (_unit, _field_stage, _context_id, _half_key,  \
    251                     (uint32) ((_bit_range_offset_within_key >= DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_HALF)?  \
    252                         (_bit_range_offset_within_key - DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_HALF):_bit_range_offset_within_key),  \
    253                      &_key_length_local));  \
    254     if (_key_length_local == 0)  \
    255     {  \
    256         SHR_ERR_EXIT(_SHR_E_INTERNAL,  \
    257                      "\r\n"  \
    258                      "Stage %s context_id %d\r\n"  \
    259                      "Bit %d on key %c (%s half) is marked as 'free'. Cannot release a 'free' chunk.\r\n"  \
    260                      "This is probably the wrong offset.\r\n",  \
    261                      dnx_field_stage_e_get_name(_field_stage),_context_id,  \
    262                     (unsigned int) ((_bit_range_offset_within_key >= DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_HALF)?  \
    263                         (_bit_range_offset_within_key - DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_HALF):_bit_range_offset_within_key),  \
    264                      'A' + (unsigned char) (_key_id.id[0]),_ms_or_ls );  \
    265     }   \
    266     /*  \
    267      * '_key_length_local' now contains the number of bits that have been allocated at  \
    268      * offset 'bit_range_offset_within_key'.  \
    269      */  \
    270     SHR_IF_ERR_EXIT(KEY_OCCUPATION_BIT_RANGE.fg_type.get \
    271                     (_unit, _field_stage, _context_id, _half_key, \
    272                     (uint32)((_bit_range_offset_within_key >= DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_HALF)? \
    273                         (_bit_range_offset_within_key - DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_HALF):_bit_range_offset_within_key), \
    274                     &_local_fg_type)); \
    275     if ((dnx_field_group_type_e)_local_fg_type != _fg_type) \
    276     { \
    277         SHR_ERR_EXIT(_SHR_E_INTERNAL, \
    278                      "\r\n" \
    279                      "Stage %s context_id %d\r\n" \
    280                      "Field group type (%s) on this key (%c, %s half) and offset (%d) does not\r\n" \
    281                      "match field group type specified by the caller (%s).\r\n" \
    282                      "Probably caller's mistake.\r\n", \
    283                      dnx_field_stage_e_get_name(_field_stage),_context_id, \
    284                      dnx_field_group_type_e_get_name(_local_fg_type), \
    285                      'A' + (unsigned char) (_key_id.id[0]),_ms_or_ls,(unsigned int) _bit_range_offset_within_key, \
    286                      dnx_field_group_type_e_get_name(_fg_type)); \
    287     } \
    288 }
    289 /*
    290  * Related to 'bit-range':
    291  * Minimal number of bits that may be required to be allocated on 'bit-range'
    292  * (via dnx_algo_field_key_bit_range_alloc_generic()). See dnx_algo_field_key_bit_range_alloc_generic_verify
    293  */
    294 #define DNX_FIELD_KEY_BIT_RANGE_MIN_LENGTH 1
    295 /*
    296  * Related to 'bit-range':
    297  * Maximal value for the number of bit, relative to the first bit on 'key template', which is
    298  * required to be '16 bit aligned' when allocating 'bit-range'
    299  * See dnx_algo_field_key_bit_range_alloc_generic().
    300  */
    301 #define DNX_FIELD_KEY_MAX_VALUE_FOR_ALIGNED_BIT (DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_SINGLE)
    302 
    303 /*
    304  * }
    305  */
    306 
    307 /*
    308  * Enums
    309  * {
    310  */
    311 /**
    312  * Collection of values out of which, one is loaded into 'failed_to_find_p'
    313  * (output of dnx_algo_field_key_alloc_generic())
    314  */
    315 typedef enum
    316 {
    317     DNX_FIELD_KEY_FAILED_FIRST = 0,
    318     /**
    319      * There was NO FAILURE.
    320      * Key was found in a place which has not, previously, been occupied.
    321      */
    322     DNX_FIELD_KEY_FAILED_NO_FAILURE = DNX_FIELD_KEY_FAILED_FIRST,
    323     /**
    324      * No key was found because all available space was already occupied.
    325      */
    326     DNX_FIELD_KEY_FAILED_NO_PLACE,
    327     /**
    328      * No key was found because no available space was set for specified input combination
    329      * (field group type, PMF program, field stage).
    330      */
    331     DNX_FIELD_KEY_FAILED_NOT_INITIALIZED,
    332     /**
    333      * No key was found because configuration has not yet been assigned for specified
    334      * field group type.
    335      */
    336     DNX_FIELD_KEY_FAILED_NOT_ASSIGNED_TO_FG,
    337     /**
    338      * No key was found because configuration is that specified field group type has zero
    339      * keys.
    340      */
    341     DNX_FIELD_KEY_FAILED_FG_HAS_ZERO_KEYS,
    342     /**
    343      * Number of types in dnx_field_key_failed_to_find_e
    344      */
    345     DNX_FIELD_KEY_FAILED_NOF
    346 } dnx_field_key_failed_to_find_e;
    347 
    348 /*
    349  * }
    350  * Enums
    351  */
    352 
    353 /*
    354  * } Define
    355 */
    356 
    357 /*
    358  * typedefs
    359  * {
    360  */
    361 
    362 /**
    363  * Structure containing all the information provided to the FES allocation algorithm about the current
    364  * state of a single FES ID of a single context ID (the FES quartets that is is allocated).
    365  * see dnx_algo_field_action_fes_alloc_single_context_state_in_t.
    366  * see dnx_algo_field_action_fes_alloc_state_in_t.
    367  * see dnx_algo_field_action_fes_allocate()
    368  */
    369 typedef struct
    370 {
    371     /*
    372      * The FES program ID (and therefore FES quartet) used by the context ID for the FES ID.
    373      */
    374     dnx_field_fes_pgm_id_t fes_pgm_id;
    375     /*
    376      * The masks used by the context ID for each instruction in the FES quartet.
    377      */
    378     dnx_field_fes_mask_id_t fes_mask_id[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_PROG_PER_FES];
    379     /*
    380      * The action types used by each fes2msb instruction in the FES quartet.
    381      */
    382     dnx_field_action_type_t fes_action_type[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_PROG_PER_FES];
    383     /*
    384      * Whether or not another context uses the same FES program ID.
    385      */
    386     uint8 is_shared;
    387 } dnx_algo_field_action_fes_alloc_single_context_single_fes_quartet_state_in_t;
    388 
    389 /**
    390  * Structure containing all the information provided to the FES allocation algorithm about the current
    391  * state of the FES configuration for one FES ID.
    392  * see dnx_algo_field_action_fes_alloc_fes_state_in_t.
    393  * see dnx_algo_field_action_fes_alloc_state_in_t.
    394  * see dnx_algo_field_action_fes_allocate()
    395  */
    396 typedef struct
    397 {
    398     /*
    399      * The number of FES quartets in use by the FES ID by all contexts.
    400      */
    401     unsigned int nof_fes_quartets;
    402     /*
    403      * The number of masks in use by the FES ID by all contexts.
    404      */
    405     unsigned int nof_masks;
    406 } dnx_algo_field_action_fes_alloc_single_fes_if_fes_state_in_t;
    407 
    408 /**
    409  * Structure containing all the information provided to the FES allocation algorithm about the current
    410  * state of a single context ID (the FES quartets that is is allocated).
    411  * Used to provide the current allocation status of the context ID we are working on.
    412  * Also used to find the priority of FES quartets.
    413  * see dnx_algo_field_action_fes_alloc_state_in_t.
    414  * see dnx_algo_field_action_fes_allocate()
    415  */
    416 typedef struct
    417 {
    418     /*
    419      * The current state for each FES ID.
    420      */
    421     dnx_algo_field_action_fes_alloc_single_context_single_fes_quartet_state_in_t
    422         fes_id_info[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_INSTRUCTION_PER_CONTEXT];
    423 } dnx_algo_field_action_fes_alloc_single_context_state_in_t;
    424 
    425 /**
    426  * Structure containing all the information provided to the FES allocation algorithm about the current
    427  * state of the FES configuration.
    428  * see dnx_algo_field_action_fes_alloc_state_in_t.
    429  * see dnx_algo_field_action_fes_allocate()
    430  */
    431 typedef struct
    432 {
    433     /*
    434      * The current state for each FES ID.
    435      */
    436     dnx_algo_field_action_fes_alloc_single_fes_if_fes_state_in_t
    437         fes_id_info[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_INSTRUCTION_PER_CONTEXT];
    438 } dnx_algo_field_action_fes_alloc_fes_state_in_t;
    439 
    440 /**
    441  * Structure containing all the information provided to the FES allocation algorithm about the current state.
    442  * see dnx_algo_field_action_fes_context_state_in_t.
    443  * dnx_algo_field_action_fes_allocate()
    444  * see dnx_field_actions_fes_set().
    445  */
    446 typedef struct
    447 {
    448     /*
    449      * The current state given for a specific context ID
    450      */
    451     dnx_algo_field_action_fes_alloc_single_context_state_in_t context_state;
    452     /*
    453      * The current state of each FES ID.
    454      */
    455     dnx_algo_field_action_fes_alloc_fes_state_in_t fes_state;
    456 } dnx_algo_field_action_fes_alloc_state_in_t;
    457 
    458 /**
    459  * Structure containing all the information provided to the FES allocation algorithm about a
    460  * specific FES quartet to be added.
    461  * Used in an array to provide, for each FES ID, the priorities of each fes program.
    462  * see dnx_algo_field_action_fes_alloc_in_t.
    463  */
    464 typedef struct
    465 {
    466     /*
    467      * The action's priority.
    468      */
    469     dnx_field_action_priority_t priority;
    470     /*
    471      * A possible mask ID allocation, ignoring all other FES quartets 
    472      * (used to provide number of distinct non zero masks.
    473      */
    474     dnx_field_fes_mask_id_t fes_mask_id[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_PROG_PER_FES];
    475     /*
    476      * The action types used by each fes2msb instruction in the FES quartet..
    477      */
    478     dnx_field_action_type_t fes_action_type[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_PROG_PER_FES];
    479 } dnx_algo_field_action_fes_alloc_in_fes_quartet_t;
    480 
    481 /**
    482  * Structure containing all the information provided to the FES allocation algorithm about the
    483  * fes quartets to be added.
    484  * see dnx_algo_field_actions_context_state_t.
    485  * dnx_algo_field_action_fes_allocate()
    486  * see dnx_field_actions_fes_set().
    487  */
    488 typedef struct
    489 {
    490     /*
    491      * the number of FES quartets that need to be allocated.
    492      */
    493     unsigned int nof_fes_quartets;
    494     /*
    495      * The information given for each fes quartet.
    496      */
    497         dnx_algo_field_action_fes_alloc_in_fes_quartet_t
    498         fes_quartet[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_ACTION_PER_GROUP];
    499 } dnx_algo_field_action_fes_alloc_in_t;
    500 
    501 /**
    502  * Structure containing the movements of existing FES quartets.
    503  * dnx_algo_field_action_fes_allocate()
    504  * see dnx_field_actions_fes_set().
    505  * see dnx_algo_field_action_fes_alloc_out_t.
    506  */
    507 typedef struct
    508 {
    509     /*
    510      * The index of new FES quartet in dnx_algo_field_action_fes_alloc_in_t fes quartet.
    511      * If it is a movement and not a new FES quartet, the value is DNX_ALGO_FIELD_ACTION_MOVEMENT.
    512      */
    513     int place_in_alloc;
    514     /*
    515      * The FES ID from which we move.
    516      */
    517     dnx_field_fes_id_t source_fes_id;
    518     /*
    519      * The FES PROGRAM ID from which we move (if we move).
    520      */
    521     dnx_field_fes_pgm_id_t source_fes_pgm_id;
    522     /*
    523      * The list of source mask IDs for the FES instructions (if we move).
    524      */
    525     dnx_field_fes_mask_id_t source_fes_mask_id[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_PROG_PER_FES];
    526     /*
    527      * If the source FES quartet is shared (if we move).
    528      */
    529     uint8 source_is_shared;
    530     /*
    531      * The new FES ID of the FES quartet.
    532      */
    533     dnx_field_fes_id_t dest_fes_id;
    534     /*
    535      * The new FES program ID of the FES quartet.
    536      */
    537     dnx_field_fes_pgm_id_t dest_fes_pgm_id;
    538     /*
    539      * The list of newly allocated masks
    540      * Invalid if shared.
    541      */
    542     dnx_field_fes_mask_id_t dest_fes_mask_id[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_PROG_PER_FES];
    543     /*
    544      * If the FES quartet is shared.
    545      */
    546     uint8 dest_is_shared;
    547 } dnx_algo_field_action_fes_alloc_out_fes_quartet_change_t;
    548 
    549 /**
    550  * Structure containing the results of the allocation algorithm.
    551  * see dnx_algo_field_action_fes_allocate()
    552  * see dnx_field_actions_fes_set().
    553  */
    554 typedef struct
    555 {
    556     
    557     dnx_algo_field_action_fes_alloc_out_fes_quartet_change_t
    558         fes_quartet_change[(1 +
    559                             DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_ID_PER_ARRAY) *
    560                            DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_ID_PER_ARRAY * (2 / 2) *
    561                            DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_ARRAY];
    562     /*
    563      * The number of elements in the 'fes_quartet_change'array.
    564      */
    565     unsigned int nof_fes_quartet_changes;
    566 
    567 } dnx_algo_field_action_fes_alloc_out_t;
    568 
    569 /**
    570  * Structure containing all the information provided to the FES deallocation algorithm about the current
    571  * state of each context ID (at this point information about only one context ID is passed).
    572  * Used in an array to provide the current allocation status of the FES quartets
    573  * see dnx_algo_field_action_fes_dealloc_state_in_t.
    574  */
    575 typedef struct
    576 {
    577     /*
    578      * The FES program ID (and therefore FES quartet) used by the context ID for each FES ID.
    579      * Zero FES program indicates that no FES quartet is allocated for the FES_ID.
    580      */
    581     dnx_field_fes_pgm_id_t fes_pgm_id[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_INSTRUCTION_PER_CONTEXT];
    582     /*
    583      * The Number of context IDs that use each FES quartet.
    584      * Note that we use uint32 because it is the type used for context IDs, even though we have only 64 programs.
    585      */
    586     uint8 fes_quartet_nof_refs[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_INSTRUCTION_PER_CONTEXT];
    587     /*
    588      * The Number of context IDs that use each FES action mask.
    589      * Zero indicated the the context ID that we deallocate for doesn't use that mask (whether or not others use it).
    590      */
    591     uint8
    592         mask_nof_refs[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_INSTRUCTION_PER_CONTEXT]
    593         [DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_MASKS_PER_FES];
    594 } dnx_algo_field_action_fes_dealloc_context_state_in_t;
    595 
    596 /**
    597  * Structure containing all the information provided to the FES deallocation algorithm about the current state.
    598  * See dnx_algo_field_action_fes_context_state_in_t.
    599  * See dnx_algo_field_action_fes_dealloc().
    600  * See dnx_field_actions_fes_context_group_delete().
    601  */
    602 typedef struct
    603 {
    604     /*
    605      * The current state given for the specific context ID we deallocate from.
    606      */
    607     dnx_algo_field_action_fes_dealloc_context_state_in_t context_state;
    608 
    609 } dnx_algo_field_action_fes_dealloc_state_in_t;
    610 
    611 /**
    612  * Structure containing the results of the deallocation algorithm.
    613  * Provides the list of FES quartets to be deletes from HW.
    614  * dnx_algo_field_action_fes_dealloc().
    615  * dnx_field_actions_fes_context_group_delete().
    616  */
    617 typedef struct
    618 {
    619     /*
    620      * Marks if the FES ID is being used by the field group that we delete from the context ID.
    621      */
    622     int belongs_to_fg[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_INSTRUCTION_PER_CONTEXT];
    623     /*
    624      * The FES program ID of the FES quartet to delete in each FES ID.
    625      * Zero FES program ID indicates not to delete.
    626      * We could have used only an indication of whether to delete or not the FES quartet belonging to the context ID.
    627      */
    628     dnx_field_fes_pgm_id_t fes_pgm_id_to_delete[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_INSTRUCTION_PER_CONTEXT];
    629     /*
    630      * Indication on whether to delete or not each fes action mask.
    631      */
    632     int delete_mask[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_INSTRUCTION_PER_CONTEXT]
    633         [DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_MASKS_PER_FES];
    634 } dnx_algo_field_action_fes_dealloc_out_t;
    635 
    636 /**
    637  * Structure containing all the information provided to the ACE ACR FES allocation algorithm about the current state.
    638  * Since the only resource that has contention in the ACE ACR in the mask (and we do not take priority into
    639  * consideration as there is no contention between groups) the only information we care about is the action masks.
    640  * Technically, we can omit the zero indexed action mask if we assume the convention (that we use) that the mask with
    641  * ID DNX_ALGO_FIELD_ZERO_FES_ACE_ACTION_MASK_ID is always DNX_ALGO_FIELD_ALL_ZERO_FES_ACTION_MASK.
    642  * dnx_algo_field_action_ace_fes_allocate()
    643  * see dnx_field_actions_ace_fes_set().
    644  */
    645 typedef struct
    646 {
    647     /*
    648      * The current state of the action masks in the ACE ACR FESes.
    649      */
    650     dnx_field_fes_mask_t
    651         masks[DNX_DATA_MAX_FIELD_ACE_NOF_FES_INSTRUCTION_PER_CONTEXT][DNX_DATA_MAX_FIELD_ACE_NOF_MASKS_PER_FES];
    652 } dnx_algo_field_action_ace_fes_alloc_state_in_t;
    653 
    654 /**
    655  * Structure containing all the information provided to the FES allocation algorithm about the
    656  * actions to be added. Includes the number of actions and their required masks.
    657  * dnx_algo_field_action_ace_fes_allocate()
    658  * see dnx_field_actions_ace_fes_set().
    659  */
    660 typedef struct
    661 {
    662     /*
    663      * the number of FES actions that need to be allocated.
    664      */
    665     unsigned int nof_actions;
    666     /*
    667      * The masks that the actions require.
    668      */
    669     dnx_field_fes_mask_t masks[DNX_DATA_MAX_FIELD_ACE_NOF_ACTION_PER_ACE_FORMAT];
    670 } dnx_algo_field_action_ace_fes_alloc_in_t;
    671 
    672 /**
    673  * Structure containing the results of the allocation algorithm for ACE ACR FES configuration.
    674  * see dnx_algo_field_action_ace_fes_allocate()
    675  * see dnx_field_actions_ace_fes_set().
    676  */
    677 typedef struct
    678 {
    679     /*
    680      * The FES ID for each action.
    681      */
    682     dnx_field_fes_id_t fes_id[DNX_DATA_MAX_FIELD_ACE_NOF_ACTION_PER_ACE_FORMAT];
    683     /*
    684      * The mask ID for each action. Using DNX_ALGO_FIELD_ZERO_FES_ACE_ACTION_MASK_ID indicates no mask to write.
    685      */
    686     dnx_field_fes_id_t mask_id[DNX_DATA_MAX_FIELD_ACE_NOF_ACTION_PER_ACE_FORMAT];
    687     /*
    688      * The number of elements in the arrays above. Not necessary.
    689      */
    690     unsigned int nof_actions;
    691 } dnx_algo_field_action_ace_fes_alloc_out_t;
    692 
    693 /**
    694  * Structure containing the information about the SW state of a FES quartet.
    695  * See dnx_algo_field_action_fes_quartet_sw_state_info_get()
    696  */
    697 typedef struct
    698 {
    699     /*
    700      * The field group ID that the FES quartet belongs to.
    701      */
    702     dnx_field_group_t fg_id;
    703     /*
    704      * The ordinal number (the index) of the FES quartet within the field group.
    705      */
    706     uint8 place_in_fg;
    707     /*
    708      * The FES quartet's priority for the context ID.
    709      */
    710     dnx_field_action_priority_t priotrity;
    711 } dnx_algo_field_action_fes_quartet_sw_state_get_info_t;
    712 
    713 /**
    714  * Structure containing the alignment requirements for allocating a bit range on key.
    715  */
    716 typedef struct
    717 {
    718     /**
    719      * Boolean flag. If 'TRUE' then bit range was allocated while aligning the bit, specified
    720      * in 'bit_range_aligned_offset' below to bit_range_align_lsb_step.
    721      * See parameter 'do_align' in 'dnx_algo_field_key_id_bit_range_allocate()'.
    722      * This is used for FEM handling.
    723      */
    724     int align_lsb;
    725     /**
    726      * The granularity/resolution in bits to align the lsb to, when using bit_range_align_lsb.
    727      */
    728     int align_lsb_step;
    729     /**
    730      * Only meaningful if 'bit_range_align_lsb' is 'TRUE'. This is the bit, within allocated bit-range,
    731      * which has been aligned. Bit is identified by its index, starting from '0', which is the first (LS)
    732      * bit of the bit range. So, for example, a value of '2' would mean that the third bit has been aligned
    733      * (i.e., placed on, say, bit(32) of the key.
    734      * This is only relevant for FEM handling.
    735      *   Number of bit, within the allocated 'key_length' bits, which
    736      *   should be aligned to 16 on the physical key. Could be positive or negative
    737      *   (between -16 to 'maximal key size' - 1). Numbering of bits starts from '0' at
    738      *   the LS bit.
    739      *   For example, if 'key_length' is 22 and we need BIT(5) to be aligned then
    740      *   the result may be:
    741      *                         MS                                              LS
    742      *                                                       BIT(5)
    743                                                                 V
    744      *      Allocated 22 bits:                  ++++++++++++++++++++++
    745      *      Key              :   ------------------------------------------------
    746      *      Aligned bits     :                  |               |               |
    747      *                                                          ^
    748      *                                                       BIT(16)
    749      */
    750     int lsb_aligned_bit;
    751     /**
    752      * Boolean flag. If 'TRUE' then bit range was allocated while aligning the bit after the MSB
    753      * to bit_range_align_msb_step.
    754      * See parameter 'do_align' in 'dnx_algo_field_key_id_bit_range_allocate()'.
    755      * This is used for adding EFES with condition bits.
    756      */
    757     int align_msb;
    758     /**
    759      * The granularity/resolution in bits to align the msb to, when using bit_range_align_msb.
    760      */
    761     int align_msb_step;
    762 } dnx_algo_field_key_bit_range_align_t;
    763 
    764 /*
    765  * }
    766  */
    767 
    768 /*
    769  * { Prototypes
    770 */
    771 
    772 /**
    773 * \brief
    774 *   Print an entry of the 'FEM action' template. See
    775 *       \ref dnx_algo_template_print_data_cb for more details.
    776 *  
    777 * \param [in] unit -
    778 *  Identifier of the device to access.
    779 * \param [in] data -
    780 *   Pointer of the struct to be printed.
    781 *   \b As \b input - \n
    782 *    The pointer is expected to hold a struct of type dnx_field_fem_action_entry_t. \n
    783 *     It's the user's responsibility to verify it beforehand.
    784 * \return
    785 *   None
    786 * \remark
    787 *    None
    788 * \see
    789 *   dnx_algo_template_print_data_cb
    790  */
    791 void dnx_algo_fem_action_template_cb(
    792     int unit,
    793     const void *data);
    794 
    795 /**
    796  * \brief
    797  *   Get the null-terminated string representing the template assigned
    798  *   to specified 'fem_id'.
    799  * \param [in] unit -
    800  *   Device ID
    801  * \param [in] fem_id -
    802  *   Indicator for which 'FEM id' this operation is intended.
    803  * \return
    804  *   shr_error_e - Error Type
    805  * \remark
    806  *   * None
    807  * \see
    808  *   * DBAL table, say, FIELD_PMF_A_FEM_FIELD_SELECT_FEMS_2_15_MAP
    809  */
    810 const char *dnx_algo_fem_action_template_id_get(
    811     int unit,
    812     dnx_field_fem_id_t fem_id);
    813 
    814 /**
    815  * \brief
    816  *  Init all need algorithm for Field module functionality
    817  * \param [in] unit  - Device ID
    818  * \return
    819  *   shr_error_e - Error Type
    820  * \remark
    821  *   * None
    822  * \see
    823  *   * None
    824  */
    825 shr_error_e dnx_algo_field_init(
    826     int unit);
    827 
    828 /**
    829  * \brief
    830  *  Deinit all need algorithm for Field module functionality
    831  * \param [in] unit  - Device ID
    832  * \return
    833  *   shr_error_e - Error Type
    834  * \remark
    835  *   * None
    836  * \see
    837  *   * None
    838  */
    839 shr_error_e dnx_algo_field_deinit(
    840     int unit);
    841 
    842 /*
    843  * Procedures related to allocation of keys.
    844  * {
    845  */
    846 /**
    847  * \brief
    848  *  Allocate Key id after the the logical construction of key was completed
    849  * \param [in] unit             -  Device ID
    850  * \param [in] flags          -  please look at dnx_algo_field_key_flags_e
    851  * \param [in] field_stage      -  Field Stage to allocate key for (PMFA,PMFB...)
    852  * \param [in] fg_type          -  Database type that being created (TCAM/DE/DT)
    853  * \param [in] context_id       -  Context ID to allocate the key for
    854  * \param [in] key_length       -
    855  *   Enum of type dnx_field_key_length_type_e. Key size - 80b/160b/320b
    856  * \param [in,out] key_id_p        -
    857  *   dnx_field_key_id_t *. Structure to hold the allocated key ids, A -> J,
    858  *   to contain single keys as per 'key_length'. (Currently, maximal size is 320
    859  *   bits corresponding to DNX_FIELD_KEY_NUM_KEYS_IN_DOUBLE elements on key_id_p->id[])
    860  *   also contains key_part -represents the allocated key part (MSB or LSB),
    861  *   Only meaningful if 'key_length' is 80b.
    862  *   Caller is assumed to have loaded the value of DBAL_NOF_ENUM_FIELD_KEY_VALUES on
    863  *   all key_id_p->id[] to indicate no free key was found. This is changed by this
    864  *   procedure if free key IS found.
    865  * \return
    866  *   shr_error_e - Error Type
    867  * \remark
    868  *   * The allocation is done per Field stage, per PMF program id and per
    869  *     field group type
    870  * \see
    871  *   * dnx_algo_field_key_alloc_generic
    872  *   * dnx_algo_field_key_id_free
    873  */
    874 shr_error_e dnx_algo_field_key_id_allocate(
    875     int unit,
    876     dnx_algo_field_key_flags_e flags,
    877     dnx_field_stage_e field_stage,
    878     dnx_field_group_type_e fg_type,
    879     dnx_field_context_t context_id,
    880     dnx_field_key_length_type_e key_length,
    881     dnx_field_key_id_t *key_id_p);
    882 
    883 /**
    884  * \brief
    885  *  Given 'field stage', 'field group type' and 'context id' (= 'triplet'), allocate
    886  *  a range of bits within the keys assigned to this 'triplet'.
    887  *  This is only done for 'triplet's that were assigned as supporting the 'bit-range'
    888  *  feature.
    889  *  Allocation is only done within within one single key and NOT across keys.
    890  *  Allocation results in a bit-range of size 'key_length' within 'key id'
    891  *  at offset 'bit_range_offset_within_key'. The latter two are the output of
    892  *  this procedure.
    893  * \param [in] unit             -
    894  *   HW identifier of device
    895  * \param [in] field_stage      -
    896  *   Field Stage to allocate key for (PMFA,PMFB...)
    897  * \param [in] fg_type          -
    898  *   Type of requiring 'field group'. (Currently, only DE (direct extraction)
    899  *   is supported. This is enforced at init. See dnx_algo_field_key_alloc_sw_state_init())
    900  * \param [in] context_id       -
    901  *   Context ID to allocate the bit-range (on a key) for
    902  * \param [in] key_length       -
    903  *   uint8. Size of required bit-range. May not be larger than the size of
    904  *   a single key (DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_SINGLE)
    905  * \param [in] align_info_p      -
    906  *   Information for forced alignment of bit range.
    907  * \param [in] force_bit_selection      -
    908  *   If TRUE, allocate the bits requested in key_id_p
    909  * \param [in,out] key_id_p        -
    910  *   dnx_field_key_id_t *. Structure to hold the allocated key ids, A -> J,
    911  *   to contain containing keys as per 'key_length'. Only the first element
    912  *   is updated by this procedure since, currently, maximal size is 160
    913  *   bits corresponding to DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_SINGLE element
    914  *   on key_id_p->id[0]. Caller is assumed to have loaded the value of
    915  *   DBAL_NOF_ENUM_FIELD_KEY_VALUES on all key_id_p->id[] to indicate
    916  *   no free bit-range was found on any key. This is changed by this procedure if
    917  *   free bit-range is found.
    918  *   Also contains key_part which represents the allocated key part (MSB or LSB).
    919  *   The latter is only meaningful if 'key_length' is less than 80 bits and
    920  *   this procedure managed to locate the bits within half-key (without extending
    921  *   from one half key to another). If returned value is DNX_FIELD_KEY_PART_TYPE_INVALID
    922  *   then a full key was required.
    923  *   If force_bit_selection is TRUE, this is the input of the key.
    924  * \param [in, out] bit_range_offset_within_key_p -
    925  *   uint32 *. This procedure loads pointed memory by the offset of the required
    926  *   bit-range within selected key.
    927  *   If force_bit_selection is TRUE, this is the input of the offset on key.
    928  * \return
    929  *   shr_error_e - Error Type
    930  * \remark
    931  *   * The allocation is done per Field stage, per PMF program id (context id) and per
    932  *     field group type
    933  * \see
    934  *   * dnx_algo_field_key_alloc_generic
    935  *   * dnx_algo_field_key_id_free
    936  */
    937 shr_error_e dnx_algo_field_key_id_bit_range_allocate(
    938     int unit,
    939     dnx_field_stage_e field_stage,
    940     dnx_field_group_type_e fg_type,
    941     dnx_field_context_t context_id,
    942     uint8 key_length,
    943     dnx_algo_field_key_bit_range_align_t * align_info_p,
    944     int force_bit_selection,
    945     dnx_field_key_id_t *key_id_p,
    946     uint32 *bit_range_offset_within_key_p);
    947 
    948 /**
    949  * \brief
    950  *  Free (deallocate) an already allocated Key id.
    951  * \param [in]  unit              -
    952  *   Device ID
    953  * \param [in] fg_type -
    954  *   dnx_field_group_type_e. Type of field group requiring the key.
    955  * \param [in]  field_stage -
    956  *   dnx_field_stage_e. Type of stage for which the key was allocated.
    957  * \param [in]  context_id -
    958  *   Identifier of Context ID for which the key was allocated.
    959  * \param [in]  key_id_p -
    960  *   structure holds an array of key Identifier.
    961  * \return
    962  *   shr_error_e - Error Type
    963  * \remark
    964  *   * The free is done per Field stage, per PMF program id.
    965  * \see
    966  *   * dnx_algo_field_key_free_generic_detailed
    967  */
    968 shr_error_e dnx_algo_field_key_id_free(
    969     int unit,
    970     dnx_field_group_type_e fg_type,
    971     dnx_field_stage_e field_stage,
    972     dnx_field_context_t context_id,
    973     dnx_field_key_id_t *key_id_p);
    974 
    975 /**
    976  * \brief
    977  *  Free (deallocate) an already allocated bit-range on specified Key id.
    978  * \param [in]  unit              -
    979  *   Device ID
    980  * \param [in] field_stage      -
    981  *   Field Stage to free bit-range (on key) from (IPMF1,IPMF2...)
    982  * \param [in] fg_type          -
    983  *   Type of 'field group' which wishes to free this bit-range from.
    984  *   See dnx_algo_field_key_alloc_sw_state_init()).
    985  * \param [in] context_id       -
    986  *   Context ID to free the bit-range (on a key) from.
    987  * \param [in] key_id        -
    988  *   dnx_field_key_id_t. Structure hold the key to free bit-range from, A -> J.
    989  *   Only the first element is used by this procedure since, currently, maximal
    990  *   size is 160 bits corresponding to DNX_DATA_MAX_FIELD_TCAM_KEY_SIZE_SINGLE
    991  *   element on key_id.id[0].
    992  *   Also contains 'key_part' element which represents the allocated key part (MSB or LSB).
    993  *   This is ignored by this procedure.
    994  * \param [in] bit_range_offset_within_key -
    995  *   uint32. The offset of the first bit (LS bit) of the bit-range (within specified key)
    996  *   which is required to be released. Must match exactly the value supplied by
    997  *   dnx_algo_field_key_id_bit_range_allocate()
    998  * \return
    999  *   shr_error_e - Error Type
   1000  * \remark
   1001  *   * The free is done per Field stage, per PMF program id.
   1002  * \see
   1003  *   * dnx_algo_field_key_id_bit_range_allocate()
   1004  */
   1005 shr_error_e dnx_algo_field_key_id_bit_range_free(
   1006     int unit,
   1007     dnx_field_stage_e field_stage,
   1008     dnx_field_group_type_e fg_type,
   1009     dnx_field_context_t context_id,
   1010     dnx_field_key_id_t key_id,
   1011     uint32 bit_range_offset_within_key);
   1012 
   1013 /**
   1014  * \brief
   1015  *   Initialize SW STATE for the 'key allocation' sub-module of the 'KEY' module.
   1016  *   See remarks.
   1017  * \param [in] unit     - Device ID
   1018  * \return
   1019  *   shr_error_e - Error Type
   1020  * \remark
   1021  *   * See file field_key_alloc.xml where all definitions, related to \n
   1022  *     SW STATE of key allocation, are stored. Root is 'dnx_field_keys_per_stage_allocation_sw_data'
   1023  *   * Set all configuration into into 'keys_availability_stage_info' and 'keys_availability_group_info'
   1024  *   * Initialize all 'key_occupation' structures to indicate 'free entry'
   1025  * \see
   1026  *   * dnx_field_keys_per_stage_allocation_t
   1027  *   * dnx_field_keys_per_stage_allocation_sw
   1028  *   * dnx_field_keys_per_stage_allocation_sw_data
   1029  *
   1030  *   * dnx_algo_field_key_id_allocate
   1031  *   * dnx_algo_field_key_id_free
   1032  */
   1033 shr_error_e dnx_algo_field_key_alloc_sw_state_init(
   1034     int unit);
   1035 /*
   1036  * }
   1037  */
   1038 
   1039 /**
   1040 * \brief
   1041 *  Allocate FFC id for IPMF 1
   1042 * \param [in] unit         - Device Id
   1043 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1044 * \param [in] context_id   - Context ID
   1045 * \param [in] ranges       - Bitmap of the ranges available for allocation
   1046 * \param [out] alloc_id_p   - Allocated id of FFC
   1047 * \return
   1048 *   shr_error_e - Error Type
   1049 * \remark
   1050 *   * None
   1051 * \see
   1052 *   * None
   1053 */
   1054 shr_error_e dnx_algo_field_key_ipmf_1_ffc_allocate(
   1055     int unit,
   1056     int alloc_flags,
   1057     dnx_field_context_t context_id,
   1058     uint8 ranges,
   1059     int *alloc_id_p);
   1060 
   1061 /**
   1062 * \brief
   1063 *  De-Allocate FFC id for IPMF 1
   1064 * \param [in] unit         - Device Id
   1065 * \param [in] context_id   - Context ID
   1066 * \param [in] ffc_id   - FFC ID to Deallocate
   1067 * \return
   1068 *   shr_error_e - Error Type
   1069 * \remark
   1070 *   * None
   1071 * \see
   1072 *   * None
   1073 */
   1074 shr_error_e dnx_algo_field_key_ipmf_1_ffc_deallocate(
   1075     int unit,
   1076     dnx_field_context_t context_id,
   1077     int ffc_id);
   1078 /**
   1079 * \brief
   1080 *  De-Allocate FFC id for IPMF 2
   1081 * \param [in] unit         - Device Id
   1082 * \param [in] context_id   - Context ID
   1083 * \param [in] ffc_id   - FFC ID to Deallocate
   1084 * \return
   1085 *   shr_error_e - Error Type
   1086 * \remark
   1087 *   * None
   1088 * \see
   1089 *   * None
   1090 */
   1091 shr_error_e dnx_algo_field_key_ipmf_2_ffc_deallocate(
   1092     int unit,
   1093     dnx_field_context_t context_id,
   1094     int ffc_id);
   1095 /**
   1096 * \brief
   1097 *  De-Allocate FFC id for IPMF 3
   1098 * \param [in] unit         - Device Id
   1099 * \param [in] context_id   - Context ID
   1100 * \param [in] ffc_id   - FFC ID to Deallocate
   1101 * \return
   1102 *   shr_error_e - Error Type
   1103 * \remark
   1104 *   * None
   1105 * \see
   1106 *   * None
   1107 */
   1108 shr_error_e dnx_algo_field_key_ipmf_3_ffc_deallocate(
   1109     int unit,
   1110     dnx_field_context_t context_id,
   1111     int ffc_id);
   1112 
   1113 /**
   1114 * \brief
   1115 *  De-Allocate FFC id for EPMF
   1116 * \param [in] unit         - Device Id
   1117 * \param [in] context_id   - Context ID
   1118 * \param [in] ffc_id   - FFC ID to Deallocate
   1119 * \return
   1120 *   shr_error_e - Error Type
   1121 * \remark
   1122 *   * None
   1123 * \see
   1124 *   * None
   1125 */
   1126 shr_error_e dnx_algo_field_key_epmf_ffc_deallocate(
   1127     int unit,
   1128     dnx_field_context_t context_id,
   1129     int ffc_id);
   1130 
   1131 /**
   1132 * \brief
   1133 *  De-Allocate FFC id for IFWD2
   1134 * \param [in] unit         - Device Id
   1135 * \param [in] context_id   - Context ID
   1136 * \param [in] ffc_id   - FFC ID to Deallocate
   1137 * \return
   1138 *   shr_error_e - Error Type
   1139 * \remark
   1140 *   * None
   1141 * \see
   1142 *   * None
   1143 */
   1144 shr_error_e dnx_algo_field_key_ifwd2_ffc_deallocate(
   1145     int unit,
   1146     dnx_field_context_t context_id,
   1147     int ffc_id);
   1148 
   1149 /**
   1150 * \brief
   1151 *  Allocate FFC id for IPMF 2
   1152 * \param [in] unit         - Device Id
   1153 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1154 * \param [in] context_id   - Context ID
   1155 * \param [out] alloc_id_p   - Allocated id of FFC
   1156 * \return
   1157 *   shr_error_e - Error Type
   1158 * \remark
   1159 *   * None
   1160 * \see
   1161 *   * None
   1162 */
   1163 shr_error_e dnx_algo_field_key_ipmf_2_ffc_allocate(
   1164     int unit,
   1165     int alloc_flags,
   1166     dnx_field_context_t context_id,
   1167     int *alloc_id_p);
   1168 
   1169 /**
   1170 * \brief
   1171 *  Allocate FFC id for IPMF 3
   1172 * \param [in] unit         - Device Id
   1173 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1174 * \param [in] context_id   - Context ID
   1175 * \param [out] alloc_id_p   - Allocated id of FFC
   1176 * \return
   1177 *   shr_error_e - Error Type
   1178 * \remark
   1179 *   * None
   1180 * \see
   1181 *   * None
   1182 */
   1183 shr_error_e dnx_algo_field_key_ipmf_3_ffc_allocate(
   1184     int unit,
   1185     int alloc_flags,
   1186     dnx_field_context_t context_id,
   1187     int *alloc_id_p);
   1188 
   1189 /**
   1190 * \brief
   1191 *  Allocate FFC id for EPMF
   1192 * \param [in] unit         - Device Id
   1193 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1194 * \param [in] context_id   - Context ID
   1195 * \param [out] alloc_id_p   - Allocated id of FFC
   1196 * \return
   1197 *   shr_error_e - Error Type
   1198 * \remark
   1199 *   * None
   1200 * \see
   1201 *   * None
   1202 */
   1203 shr_error_e dnx_algo_field_key_epmf_ffc_allocate(
   1204     int unit,
   1205     int alloc_flags,
   1206     dnx_field_context_t context_id,
   1207     int *alloc_id_p);
   1208 
   1209 /**
   1210 * \brief
   1211 *  Allocate FFC id for IFWD2
   1212 * \param [in] unit         - Device Id
   1213 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1214 * \param [in] context_id   - Context ID
   1215 * \param [out] alloc_id_p   - Allocated id of FFC
   1216 * \return
   1217 *   shr_error_e - Error Type
   1218 * \remark
   1219 *   * None
   1220 * \see
   1221 *   * None
   1222 */
   1223 shr_error_e dnx_algo_field_key_ifwd2_ffc_allocate(
   1224     int unit,
   1225     int alloc_flags,
   1226     dnx_field_context_t context_id,
   1227     int *alloc_id_p);
   1228 
   1229 /**
   1230 * \brief
   1231 *  This function will check if given ffc_id for a specific context in stage iFWD2 is allocated.
   1232 * \param [in] unit         - Device Id
   1233 * \param [in] context_id   - Context ID
   1234 * \param [in] ffc_id       - FFC ID
   1235 * \param [out] is_allocated_p  - TRUE if entry is allocated, FALSE otherwise.
   1236 * \return
   1237 *   shr_error_e - Error Type
   1238 * \remark
   1239 *   * None
   1240 * \see
   1241 *   * None
   1242 */
   1243 shr_error_e dnx_algo_field_key_ifwd2_ffc_is_allocated(
   1244     int unit,
   1245     dnx_field_context_t context_id,
   1246     int ffc_id,
   1247     uint8 *is_allocated_p);
   1248 
   1249 /**
   1250 * \brief
   1251 *  Get the number of free FFC id for specific context in IFWD2
   1252 * \param [in] unit         - Device Id
   1253 * \param [in] context_id   - Context ID
   1254 * \param [out] nof_elements_p   - Number of free FFC
   1255 * \return
   1256 *   shr_error_e - Error Type
   1257 * \remark
   1258 *   * None
   1259 * \see
   1260 *   * None
   1261 */
   1262 shr_error_e dnx_algo_field_key_ifwd2_ffc_num_of_elements_get(
   1263     int unit,
   1264     dnx_field_context_t context_id,
   1265     int *nof_elements_p);
   1266 
   1267 /**
   1268 * \brief
   1269 *  Allocate placeholder in the initial key in iPMF1.
   1270 * \param [in] unit           - Device Id
   1271 * \param [in] context_id     - Context ID to allocate the given range
   1272 * \param [in] size           - Number of bits that we try to allocate
   1273 * \param [in] force_position - If true the place to allocate is given.
   1274 * \param [in,out] key_id_p   - If force_position is true input argument for the key to allocate in.
   1275 *                              If force_position is false output argument of what key was allocated in.
   1276 * \param [in,out] bit_lsb_p  - If force_position is true input argument for the lsb on key to allocate.
   1277 *                              If force_position is false output argument of the lsb on key that was allocated.
   1278 * \return
   1279 * \retval Zero if no error was detected
   1280 * \retval Negative if error was detected. See \ref shr_error_e
   1281 * \remark
   1282 *   None* \remark
   1283 * * None
   1284 * \see
   1285 *   * None
   1286 */
   1287 shr_error_e dnx_algo_field_key_ipmf1_initial_key_occupation_bmp_allocate(
   1288     int unit,
   1289     dnx_field_context_t context_id,
   1290     uint32 size,
   1291     int force_position,
   1292     dbal_enum_value_field_field_key_e * key_id_p,
   1293     int *bit_lsb_p);
   1294 
   1295 /**
   1296 * \brief
   1297 *  De-Allocate placeholder in the initial key for a given qualifier in IPMF1
   1298 * \param [in] unit         - Device Id.
   1299 * \param [in] context_id   - Context ID to allocate the given range.
   1300 * \param [in] size         - qualifier size that we try to allocate.
   1301 * \param [in] key_id       - The key to deallocate in.
   1302 * \param [in] initial_offset - Starting index of the allocated range.
   1303 * \return
   1304 * \retval Zero if no error was detected
   1305 * \retval Negative if error was detected. See \ref shr_error_e
   1306 * \remark
   1307 *   None* \remark
   1308 * * None
   1309 * \see
   1310 *   * None
   1311 */
   1312 shr_error_e dnx_algo_field_key_ipmf1_initial_key_occupation_bmp_deallocate(
   1313     int unit,
   1314     dnx_field_context_t context_id,
   1315     uint32 size,
   1316     dbal_enum_value_field_field_key_e key_id,
   1317     int initial_offset);
   1318 
   1319 /**
   1320 * \brief
   1321 *  Allocate CONTEXT_ID for PMFA
   1322 * \param [in] unit         - Device Id
   1323 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1324 * \param [out] alloc_id_p   - Allocated id of CONTEXT_ID
   1325 * \return
   1326 *   shr_error_e - Error Type
   1327 * \remark
   1328 *   * None
   1329 * \see
   1330 *   * None
   1331 */
   1332 shr_error_e dnx_algo_field_presel_pmf_a_context_id_allocate(
   1333     int unit,
   1334     int alloc_flags,
   1335     dnx_field_context_t * alloc_id_p);
   1336 
   1337 /**
   1338 * \brief
   1339 *  Allocate CONTEXT_ID for PMFB
   1340 * \param [in] unit         - Device Id
   1341 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1342 * \param [out] alloc_id_p   - Allocated id of CONTEXT_ID
   1343 * \return
   1344 *   shr_error_e - Error Type
   1345 * \remark
   1346 *   * None
   1347 * \see
   1348 *   * None
   1349 */
   1350 shr_error_e dnx_algo_field_presel_pmf_b_context_id_allocate(
   1351     int unit,
   1352     int alloc_flags,
   1353     dnx_field_context_t * alloc_id_p);
   1354 
   1355 /**
   1356 * \brief
   1357 *  Allocate CONTEXT_ID for E_PMF
   1358 * \param [in] unit         - Device Id
   1359 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1360 * \param [out] alloc_id_p   - Allocated id of CONTEXT_ID
   1361 * \return
   1362 *   shr_error_e - Error Type
   1363 * \remark
   1364 *   * None
   1365 * \see
   1366 *   * None
   1367 */
   1368 shr_error_e dnx_algo_field_presel_e_pmf_context_id_allocate(
   1369     int unit,
   1370     int alloc_flags,
   1371     dnx_field_context_t * alloc_id_p);
   1372 
   1373 /**
   1374 * \brief
   1375 *  Allocate User Qual_ID
   1376 * \param [in] unit         - Device Id
   1377 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1378 * \param [out] user_qual_id_p - Pointer to user qual id to be allocated by the function
   1379 * \return
   1380 *   shr_error_e - Error Type
   1381 * \remark
   1382 *   * None
   1383 * \see
   1384 *   * None
   1385 */
   1386 shr_error_e dnx_algo_field_user_qual_id_allocate(
   1387     int unit,
   1388     int alloc_flags,
   1389     dnx_field_qual_id_t * user_qual_id_p);
   1390 
   1391 /**
   1392 * \brief
   1393 *  Allocate User Action_ID
   1394 * \param [in] unit         - Device Id
   1395 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1396 * \param [out] user_action_id_p  - Pointer to action id to be allocated by the function
   1397 * \return
   1398 *   shr_error_e - Error Type
   1399 * \remark
   1400 *   * None
   1401 * \see
   1402 *   * None
   1403 */
   1404 shr_error_e dnx_algo_field_user_action_id_allocate(
   1405     int unit,
   1406     int alloc_flags,
   1407     dnx_field_action_id_t * user_action_id_p);
   1408 
   1409 /**
   1410 * \brief
   1411 *  Allocate field group id for all PMF's
   1412 * \param [in] unit         - Device Id
   1413 * \param [in] alloc_flags  - allocation flags (DNX_ALGO_TEMPLATE_ALLOCATE..)
   1414 * \param [out] fg_id_p   - Allocated id for Field Group (DNX_DATA_MAX_FIELD_GROUP_NOF_FGS)
   1415 * \return
   1416 *   shr_error_e - Error Type
   1417 * \remark
   1418 *   * None
   1419 * \see
   1420 *   * None
   1421 */
   1422 shr_error_e dnx_algo_field_group_id_allocate(
   1423     int unit,
   1424     int alloc_flags,
   1425     dnx_field_group_t * fg_id_p);
   1426 
   1427 /**
   1428 * \brief
   1429 *  Allocate APP_DB_ID for small EXEM.
   1430 *  APP_DB_ID is the ID of the application database, a logical division of the physical databases in the MDB.
   1431 * \param [in] unit         - Device Id
   1432 * \param [in] alloc_flags  - allocation flags (currently only WITH_ID is supported)
   1433 * \param [out] app_db_id_p  - Allocated APP_DB_ID. Can also be an input parameter if WITH_ID flag is set.
   1434 * \return
   1435 *   shr_error_e - Error Type
   1436 * \remark
   1437 *   * None
   1438 * \see
   1439 *   * dnx_field_group_lexem_app_db_id_alloc
   1440 */
   1441 shr_error_e dnx_algo_field_sexem_app_db_id_allocate(
   1442     int unit,
   1443     int alloc_flags,
   1444     dnx_field_app_db_id_t * app_db_id_p);
   1445 
   1446 /**
   1447 * \brief
   1448 *  Allocate APP_DB_ID for large EXEM.
   1449 *  APP_DB_ID is the ID of the application database, a logical division of the physical databases in the MDB.
   1450 * \param [in] unit         - Device Id
   1451 * \param [in] alloc_flags  - allocation flags (currently only WITH_ID is supported)
   1452 * \param [out] app_db_id_p  - Allocated APP_DB_ID. Can also be an input parameter if WITH_ID flag is set.
   1453 * \return
   1454 *   shr_error_e - Error Type
   1455 * \remark
   1456 *   * None
   1457 * \see
   1458 *   * dnx_field_group_sexem_app_db_id_alloc
   1459 */
   1460 shr_error_e dnx_algo_field_lexem_app_db_id_allocate(
   1461     int unit,
   1462     int alloc_flags,
   1463     dnx_field_app_db_id_t * app_db_id_p);
   1464 
   1465 /**
   1466 * \brief
   1467 *  Allocate ACE_ID for ACE formats (also serves as result type of the PPMC table and context for ACE ACR).
   1468 * \param [in] unit         - Device Id
   1469 * \param [in] alloc_flags  - allocation flags (currently only WITH_ID is supported)
   1470 * \param [out] ace_id_p    - Allocated ACE ID. Can also be an input parameter if WITH_ID flag is set.
   1471 * \return
   1472 *   shr_error_e - Error Type
   1473 * \remark
   1474 *   * None
   1475 * \see
   1476 *   * None
   1477 */
   1478 shr_error_e dnx_algo_field_ace_id_allocate(
   1479     int unit,
   1480     int alloc_flags,
   1481     dnx_field_ace_id_t * ace_id_p);
   1482 
   1483 /**
   1484 * \brief
   1485 *  Allocate ACE key for the ace table (PPMC table for MC replication and ACE pointers).
   1486 * \param [in] unit         - Device Id
   1487 * \param [in] alloc_flags  - allocation flags (currently only WITH_ID is supported)
   1488 * \param [out] ace_key_p    - Allocated ACE key. Can also be an input parameter if WITH_ID flag is set.
   1489 * \return
   1490 *   shr_error_e - Error Type
   1491 * \remark
   1492 *   * None
   1493 * \see
   1494 *   * None
   1495 */
   1496 shr_error_e dnx_algo_field_ace_key_allocate(
   1497     int unit,
   1498     int alloc_flags,
   1499     dnx_field_ace_key_t * ace_key_p);
   1500 /*
   1501  * Procedures related to 'FEM machine'
   1502  * {
   1503  */
   1504 /**
   1505  * \brief
   1506  *  Allocate FEM_PGM_ID (FEM program) for PMFA
   1507  * \param [in] unit         - Device Id
   1508  * \param [in] fem_id -
   1509  *    Indicator for which 'FEM id' on which this fem program
   1510  *    is to be allocated. (Allocation, then, is per 'FEM id')
   1511  *    See DBAL table: FIELD_PMF_A_FEM_CONDITION_MS_BIT
   1512  * \param [in] alloc_flags  -
   1513  *    Allocation flags (Currently, only DNX_ALGO_RES_ALLOCATE_WITH_ID is meaningful)
   1514  * \param [out] fem_program_p  -
   1515  *    Allocated id of FEM_PGM_ID (FEM program)
   1516  * \return
   1517  *   shr_error_e - Error Type
   1518  * \remark
   1519  *   * Currently, this is done when FEM is added to a field group
   1520  * \see
   1521  *   * dnx_field_fem_action_add()
   1522  */
   1523 shr_error_e dnx_algo_field_action_pmf_a_fem_pgm_id_allocate(
   1524     int unit,
   1525     dnx_field_fem_id_t fem_id,
   1526     int alloc_flags,
   1527     dnx_field_fem_program_t * fem_program_p);
   1528 
   1529 /**
   1530  * \brief
   1531  *  Deallocate FEM_PGM_ID (FEM program) for PMFA
   1532  * \param [in] unit   - Device id
   1533  * \param [in] fem_id -
   1534  *    Indicator for which 'FEM id' from which this fem program
   1535  *    is to be deallocated.
   1536  *    See DBAL table: FIELD_PMF_A_FEM_CONDITION_MS_BIT
   1537  * \param [in] fem_program -
   1538  *    Indicator for which 'FEM program' this HW setup is intended.
   1539  *    See, for example, DBAL table: FIELD_PMF_A_FEM_CONDITION_MS_BIT
   1540  * \return
   1541  *   shr_error_e - Error Type
   1542  * \remark
   1543  *   * Currently, this is done when FEM is removed from a field group
   1544  * \see
   1545  *   * dnx_field_fem_action_remove()
   1546  */
   1547 shr_error_e dnx_algo_field_action_pmf_a_fem_pgm_id_deallocate(
   1548     int unit,
   1549     dnx_field_fem_id_t fem_id,
   1550     dnx_field_fem_program_t fem_program);
   1551 /**
   1552  * \brief
   1553  *   Given 'fem_id', find a free 'fem_program'. Also, use scanned info to get a bitmap
   1554  *   of all 'action's used by this FEM. Use SWSTATE of specified 'fem_id'
   1555  * \param [in] unit -
   1556  *   Identifier of HW platform.
   1557  * \param [in] fem_id -
   1558  *    Indicator for which 'FEM id' this operation is intended.
   1559  * \param [out] available_fem_program_p -
   1560  *    This procedure loads pointed memory by the identifier of a free 'fem_program',
   1561  *    provided one is found. Remember that if this procedure returns without an
   1562  *    error then a free 'fem_program' has been found.
   1563  *    See dnx_data_field.stage.stage_info_get(unit, DNX_FIELD_STAGE_IPMF1)->nof_fem_programs
   1564  * \param [out] sum_allocated_actions_p -
   1565  *    This procedure loads pointed memory by a bit map of all the 'action's
   1566  *    which are currently being used by this 'fem_id'. This is a bitmap such that
   1567  *    BIT(0) stands for the first 'action', BIT(1) for the second, etc.
   1568  * \return
   1569  *   \retval Zero - On success
   1570  *   \retval Error - Identifier as per shr_error_e
   1571  * \remark
   1572  *    * If no free 'fem_program' is found, an error, _SHR_E_RESOURCE, is returned.
   1573  * \see
   1574  *   * dnx_field_fem_condition_entry_t
   1575  *   * dnx_field_fem_action_entry_t
   1576  */
   1577 shr_error_e dnx_algo_field_action_find_available_fem_program(
   1578     int unit,
   1579     dnx_field_fem_id_t fem_id,
   1580     dnx_field_fem_program_t * available_fem_program_p,
   1581     uint8 *sum_allocated_actions_p);
   1582 /**
   1583  * \brief
   1584  *   Inspect input 'condition's array (fem_condition_entry[]):
   1585  *   Check whether any of the specified actions (See fem_action_entry[]) is
   1586  *   the same as 'action's currently in HW.
   1587  *   If so, update conditions' array (fem_condition_entry_destination) accordingly
   1588  *   and remove from 'ignore_actions'
   1589  *   See remarks and references below.
   1590  * \param [in] unit -
   1591  *   Identifier of HW platform.
   1592  * \param [in] fem_id -
   1593  *    Indicator for which 'FEM id' this operation is intended.
   1594  * \param [in] fem_condition_entry -
   1595  *   Array of '16' elements (size taken from DATA). Each element contains all info corresponding
   1596  *   to one 'condition'. Among these parameters is an indication on which 'action' (one of the
   1597  *   4 available) is to be activated when this condition is hit. The available 4 'action's are
   1598  *   detailed on 'fem_action_entry' below. See DBAL table: FIELD_PMF_A_FEM_MAP_INDEX
   1599  *   Note that only 'action' indices, that are referred to here, are referenced on 'fem_action_entry'.
   1600  *   For example, if, on all 16 conditions, only indices '0' and '1' are specified then only
   1601  *   fem_action_entry[0] and fem_action_entry[1] will be looked up. The othres will be
   1602  *   ignored.
   1603  * \param [in] fem_encoded_actions -
   1604  *    Array of '4' elements (size taken from DATA). Each element contains encoded value of
   1605  *    action corresponding to one 'action type' on 'fem_action_entry[]' below.
   1606  *    These entries are being 'reshuffled' into fem_encoded_actions_destination[] so
   1607  *    that the indices match the reordering of action in fem_action_entry_destination[].
   1608  * \param [in] fem_action_entry -
   1609  *    Array of '4' elements (size taken from DATA). Each element contains all info corresponding
   1610  *    to one 'action' (= all 4/24 bit descriptors).
   1611  *    See, for example, DBAL tables: FIELD_PMF_A_FEM_FIELD_SELECT_FEMS_*_MAP
   1612  *    Note that, for 'FEM id's 0/1, only 4 bits may be specified. In that case, the per-bit element
   1613  *    'fem_bit_format' on 'dnx_field_fem_action_entry_t' should be marked DNX_FIELD_FEM_BIT_FORMAT_INVALID
   1614  *    for bits 4 to 23. Otherwise, an error will be ejected.
   1615  *    Note that the 'fem_action' element is, at this stage, a valid input parameter. It is not
   1616  *    encoded! This is 'action_type' as written to HW. The input encoded actions are on
   1617  *    'fem_encoded_actions' above.
   1618  *    This array is 'reshuffled' by this procedure so as to match the actions pointed by
   1619  *    fem_condition_entry_destination[] so that it is ready to be written into HW.
   1620  *    Note the 'fem_adder'  element -
   1621  *    Each element contains a 24-bits value to add to action value after all bit-extractions
   1622  *    from 'key select'.
   1623  *    See DBAL table: FIELD_PMF_A_FEM_ADDER_FEMS_2_15_MAP
   1624  * \param [in] sum_allocated_actions -
   1625  *    Bitmap indicating which 'action's are already occupied in HW. (e.g., If BIT(0) is set then
   1626  *    first 'action' is loaded into HW and is being used by some 'condition' on some 'fem program'
   1627  * \param [out] fem_condition_entry_destination -
   1628  *   See 'fem_condition_entry' above. This array of '16' elements is modified to point to
   1629  *   'action's which are actually in HW and is loaded into fem_condition_entry_destination[].
   1630  *   So, bottom line, 'fem_condition_entry_destination' may actually be loaded into HW.
   1631  * \param [out] ignore_actions_p -
   1632  *   Bitmap indicating which 'action's should be ignored when loading values into HW. This
   1633  *   bitmap marks as 'do not ignore' even 'action's which are already in HW (See 'already_in_hw_p').
   1634  *   See also 'sum_allocated_actions' above.
   1635  * \param [out] already_in_hw_p -
   1636  *   Bitmap indicating which 'action's are already loaded into HW. This is used by the caller
   1637  *   to not reload (i.e., 'write') 'action's which are already in HW.
   1638  * \param [out] fem_encoded_actions_destination -
   1639  *    See fem_encoded_actions[] above.
   1640  * \param [out] fem_action_entry_destination -
   1641  *    See fem_action_entry[] above.
   1642  * \return
   1643  *   \retval Zero - On success
   1644  *   \retval Error - Identifier as per shr_error_e
   1645  * \remark
   1646  *    * 'FEM program' is selected automatically by this procedure.
   1647  * \see
   1648  *   * dnx_field_fem_action_add()
   1649  *   * dnx_field_fem_condition_entry_t
   1650  *   * dnx_field_fem_action_entry_t
   1651  */
   1652 shr_error_e dnx_algo_field_action_update_conditions(
   1653     int unit,
   1654     dnx_field_fem_id_t fem_id,
   1655     dnx_field_fem_condition_entry_t fem_condition_entry[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FEM_CONDITION],
   1656     dnx_field_action_t fem_encoded_actions[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FEM_MAP_INDEX],
   1657     dnx_field_fem_action_entry_t fem_action_entry[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FEM_MAP_INDEX],
   1658     uint8 sum_allocated_actions,
   1659     dnx_field_fem_condition_entry_t
   1660     fem_condition_entry_destination[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FEM_CONDITION],
   1661     uint8 *ignore_actions_p,
   1662     uint8 *already_in_hw_p,
   1663     dnx_field_action_t fem_encoded_actions_destination[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FEM_MAP_INDEX],
   1664     dnx_field_fem_action_entry_t fem_action_entry_destination[DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FEM_MAP_INDEX]);
   1665 /*
   1666  * }
   1667  */
   1668 /**
   1669 * \brief
   1670 *  Deallocate CONTEXT_ID for PMFA
   1671 * \param [in] unit   - Device id
   1672 * \param [in] context_id  - CONTEXT_ID to deallocate
   1673 * \return
   1674 *   shr_error_e - Error Type
   1675 * \remark
   1676 *   * None
   1677 * \see
   1678 *   * None
   1679 */
   1680 shr_error_e dnx_algo_field_presel_pmf_a_pmf_pgm_id_deallocate(
   1681     int unit,
   1682     dnx_field_context_t context_id);
   1683 
   1684 /**
   1685 * \brief
   1686 *  Deallocate PMF_PGM_ID for PMFB
   1687 * \param [in] unit   - Device id
   1688 * \param [in] context_id  - CONTEXT_ID to deallocate
   1689 * \return
   1690 *   shr_error_e - Error Type
   1691 * \remark
   1692 *   * None
   1693 * \see
   1694 *   * None
   1695 */
   1696 shr_error_e dnx_algo_field_presel_pmf_b_pmf_pgm_id_deallocate(
   1697     int unit,
   1698     dnx_field_context_t context_id);    
   1699 /**
   1700 * \brief
   1701 *  Deallocate PMF_PGM_ID for E_PMF
   1702 * \param [in] unit   - Device id
   1703 * \param [in] context_id  - CONTEXT_ID to deallocate
   1704 * \return
   1705 *   shr_error_e - Error Type
   1706 * \remark
   1707 *   * None
   1708 * \see
   1709 *   * None
   1710 */
   1711 shr_error_e dnx_algo_field_presel_e_pmf_pmf_pgm_id_deallocate(
   1712     int unit,
   1713     dnx_field_context_t context_id);
   1714 /**
   1715 * \brief
   1716 *  Deallocate user qual id
   1717 * \param [in] unit   - Device id
   1718 * \param [in] user_qual_id  - user qual id for deallocation
   1719 * \return
   1720 *   shr_error_e - Error Type
   1721 * \remark
   1722 *   * None
   1723 * \see
   1724 *   * None
   1725 */
   1726 shr_error_e dnx_algo_field_user_qual_id_deallocate(
   1727     int unit,
   1728     dnx_field_qual_id_t user_qual_id);
   1729 /**
   1730 * \brief
   1731 *  Deallocate user action id
   1732 * \param [in] unit   - Device id
   1733 * \param [in] user_action_id  - user action id for deallocation
   1734 * \return
   1735 *   shr_error_e - Error Type
   1736 * \remark
   1737 *   * None
   1738 * \see
   1739 *   * None
   1740 */
   1741 shr_error_e dnx_algo_field_user_action_id_deallocate(
   1742     int unit,
   1743     dnx_field_action_id_t user_action_id);
   1744 
   1745 /**
   1746 * \brief
   1747 *  Deallocate APP_DB_ID for small EXEM.
   1748 * \param [in] unit         - Device Id
   1749 * \param [in] app_db_id    - APP_DB_ID to deallocate.
   1750 * \return
   1751 *   shr_error_e - Error Type
   1752 * \remark
   1753 *   * None
   1754 * \see
   1755 *   * dnx_field_group_lexem_app_db_id_dealloc
   1756 */
   1757 shr_error_e dnx_algo_field_sexem_app_db_id_deallocate(
   1758     int unit,
   1759     dnx_field_app_db_id_t app_db_id);
   1760 
   1761 /**
   1762 * \brief
   1763 *  Deallocate APP_DB_ID for large EXEM.
   1764 * \param [in] unit         - Device Id
   1765 * \param [in] app_db_id    - APP_DB_ID to deallocate.
   1766 * \return
   1767 *   shr_error_e - Error Type
   1768 * \remark
   1769 *   * None
   1770 * \see
   1771 *   * dnx_field_group_sexem_app_db_id_dealloc
   1772 */
   1773 shr_error_e dnx_algo_field_lexem_app_db_id_deallocate(
   1774     int unit,
   1775     dnx_field_app_db_id_t app_db_id);
   1776 
   1777 /**
   1778 * \brief
   1779 *  Deallocate ACE ID.
   1780 * \param [in] unit         - Device Id
   1781 * \param [in] ace_id       - ACE ID to deallocate.
   1782 * \return
   1783 *   shr_error_e - Error Type
   1784 * \remark
   1785 *   * None
   1786 * \see
   1787 *   * None
   1788 */
   1789 shr_error_e dnx_algo_field_ace_id_deallocate(
   1790     int unit,
   1791     dnx_field_ace_id_t ace_id);
   1792 
   1793 /**
   1794 * \brief
   1795 *  Deallocate ACE KEY.
   1796 * \param [in] unit         - Device Id
   1797 * \param [in] ace_key       - ACE key to deallocate.
   1798 * \return
   1799 *   shr_error_e - Error Type
   1800 * \remark
   1801 *   * None
   1802 * \see
   1803 *   * None
   1804 */
   1805 shr_error_e dnx_algo_field_ace_key_deallocate(
   1806     int unit,
   1807     dnx_field_ace_key_t ace_key);
   1808 
   1809 /**
   1810 * \brief
   1811 *  Deallocate Database for field module
   1812 * \param [in] unit   - Device id
   1813 * \param [in] fg_id  - Field group ID to deallocate
   1814 * \return
   1815 *   shr_error_e - Error Type
   1816 * \remark
   1817 *   * None
   1818 * \see
   1819 *   * None
   1820 */
   1821 shr_error_e dnx_algo_field_group_id_deallocate(
   1822     int unit,
   1823     dnx_field_group_t fg_id);
   1824 
   1825 /**
   1826 * \brief
   1827 *  This function will allocate entry_access_id by using simple allocation manager
   1828 *  entry_access_id is used by entry_add function to identify specific entry and to handle inside TCAM..
   1829 *  the id being allocated per field stage
   1830 * \param [in] unit         - Device ID
   1831 * \param [in] alloc_flags  - Alloc flag with/without ID
   1832 * \param [out] alloc_id_p   - Allocated id
   1833 * \return
   1834 *   shr_error_e - Error Type
   1835 * \remark
   1836 *   * None
   1837 * \see
   1838 *   * None
   1839 */
   1840 shr_error_e dnx_algo_field_entry_tcam_access_id_allocate(
   1841     int unit,
   1842     int alloc_flags,
   1843     int *alloc_id_p);
   1844 
   1845 /**
   1846 * \brief
   1847 *  This function will check if given entry_access_id is allocated.
   1848 *  entry_access_id is used by entry_add function to identify specific entry and to handle inside TCAM.
   1849 * \param [in] unit            - Device ID
   1850 * \param [in] entry_access_id - Entry access ID to check whether allocated
   1851 * \param [out] is_allocated_p - TRUE if entry is allocated, FALSE otherwise.
   1852 * \return
   1853 *   shr_error_e - Error Type
   1854 * \remark
   1855 *   * None
   1856 * \see
   1857 *   * None
   1858 */
   1859 shr_error_e dnx_algo_field_entry_tcam_access_id_is_allocated(
   1860     int unit,
   1861     int entry_access_id,
   1862     uint8 *is_allocated_p);
   1863 
   1864 /**
   1865 * \brief
   1866 *  Deallocate entry_access id
   1867 * \param [in] unit             - Device id
   1868 * \param [in] entry_access_id  - id to deallocate
   1869 * \return
   1870 *   shr_error_e - Error Type
   1871 * \remark
   1872 *   * None
   1873 * \see
   1874 *   * dnx_algo_field_entry_tcam_access_id_allocate() description
   1875 */
   1876 shr_error_e dnx_algo_field_entry_tcam_access_id_deallocate(
   1877     int unit,
   1878     int entry_access_id);
   1879 
   1880 /**
   1881 * \brief
   1882 *  Allocate a KBP profile ID to be used by iPMF1 context selection.
   1883 * \param [in] unit         - Device ID
   1884 * \param [in] alloc_flags  - Alloc flag with/without ID
   1885 * \param [out] cs_prodfile_id_p - Allocated id
   1886 * \return
   1887 *   shr_error_e - Error Type
   1888 * \remark
   1889 *   * None
   1890 * \see
   1891 *   * None
   1892 */
   1893 shr_error_e dnx_algo_field_kbp_opcode_cs_profile_id_allocate(
   1894     int unit,
   1895     int alloc_flags,
   1896     int *cs_prodfile_id_p);
   1897 
   1898 /**
   1899 * \brief
   1900 *  Deallocate KBP profile ID.
   1901 * \param [in] unit             - Device id
   1902 * \param [in] cs_prodfile_id   - id to deallocate
   1903 * \return
   1904 *   shr_error_e - Error Type
   1905 * \remark
   1906 *   * None
   1907 * \see
   1908 *   * dnx_algo_field_kbp_opcode_cs_profile_id_allocate()
   1909 */
   1910 shr_error_e dnx_algo_field_kbp_opcode_cs_profile_id_deallocate(
   1911     int unit,
   1912     int cs_prodfile_id);
   1913 
   1914 /**
   1915 * \brief
   1916 *  This function will check if given KBP profile ID is allocated.
   1917 * \param [in] unit            - Device ID
   1918 * \param [in] cs_prodfile_id - ID to check
   1919 * \param [out] is_allocated_p - TRUE if entry is allocated, FALSE otherwise.
   1920 * \return
   1921 *   shr_error_e - Error Type
   1922 * \remark
   1923 *   * None
   1924 * \see
   1925 *   * None
   1926 */
   1927 shr_error_e dnx_algo_field_kbp_opcode_cs_profile_id_is_allocated(
   1928     int unit,
   1929     int cs_prodfile_id,
   1930     uint8 *is_allocated_p);
   1931 
   1932 /**
   1933 * \brief
   1934 *  This function will check if given flush profile ID is allocated.
   1935 * \param [in] unit            - Device ID
   1936 * \param [in] flush_profile_id - ID to check
   1937 * \param [out] is_allocated_p - TRUE if entry is allocated, FALSE otherwise.
   1938 * \return
   1939 *   shr_error_e - Error Type
   1940 * \remark
   1941 *   * None
   1942 * \see
   1943 *   * None
   1944 */
   1945 shr_error_e dnx_algo_field_flush_profile_is_allocated(
   1946     int unit,
   1947     int flush_profile_id,
   1948     uint8 *is_allocated_p);
   1949 
   1950 /**
   1951 * \brief
   1952 *  Initialize resource allocation for FFC and Keys management
   1953 * \param [in] unit             - Device id
   1954 * \return
   1955 *   shr_error_e - Error Type
   1956 * \remark
   1957 *   * None
   1958 * \see
   1959 *   * dnx_algo_field_key_res_mngr_init() description
   1960 */
   1961 shr_error_e dnx_algo_field_key_res_mngr_init(
   1962     int unit);
   1963 
   1964 /**
   1965 * \brief
   1966 *  De-Allocate resources for FFC and Keys management
   1967 * \param [in] unit             - Device id
   1968 * \return
   1969 *   shr_error_e - Error Type
   1970 * \remark
   1971 *   * None
   1972 * \see
   1973 *   * dnx_algo_field_key_res_mngr_deinit() description
   1974 */ shr_error_e
   1975     dnx_algo_field_key_res_mngr_deinit(
   1976     int unit);
   1977 
   1978 /**
   1979 * \brief
   1980 *  Initialize resource allocation for Context management
   1981 * \param [in] unit             - Device id
   1982 * \return
   1983 *   shr_error_e - Error Type
   1984 * \remark
   1985 *   * None
   1986 * \see
   1987 *   * None
   1988 */
   1989 shr_error_e dnx_algo_field_context_res_mngr_init(
   1990     int unit);
   1991 
   1992 /**
   1993 * \brief
   1994 *  De-Allocate resources for Context management
   1995 * \param [in] unit             - Device id
   1996 * \return
   1997 *   shr_error_e - Error Type
   1998 * \remark
   1999 *   * None
   2000 * \see
   2001 *   * None
   2002 */ shr_error_e
   2003     dnx_algo_field_context_res_mngr_deinit(
   2004     int unit);
   2005 
   2006 /**
   2007 * \brief
   2008 *  Initialize the SW state for FES management.
   2009 * \param [in] unit             - Device id
   2010 * \return
   2011 *   shr_error_e - Error Type
   2012 * \remark
   2013 *   * None
   2014 * \see
   2015 *   * dnx_algo_field_init()
   2016 */
   2017 shr_error_e dnx_algo_field_action_init(
   2018     int unit);
   2019 
   2020 /**
   2021 * \brief
   2022 *  Deinit the SW state for FES management.
   2023 * \param [in] unit             - Device id
   2024 * \return
   2025 *   shr_error_e - Error Type
   2026 * \remark
   2027 *   * None
   2028 * \see
   2029 *   * dnx_algo_field_deinit()
   2030 */
   2031 shr_error_e dnx_algo_field_action_sw_state_deinit(
   2032     int unit);
   2033 
   2034 /**
   2035  * \brief
   2036  *   This procedure allocates FES quartets and FES action masks for a context ID and field group,
   2037  *   and returns if the allocation was successful, and if so which quartets need to be written to the FES HW.
   2038  * \param [in] unit -
   2039  *   Device ID.
   2040  * \param [in] field_stage -
   2041  *   For which of the PMF blocks the configuration is done (iPMF-1, iPMF2, iPMF-3, ePMF-1).
   2042  * \param [in] fg_id -
   2043  *   HW identifier of field group.
   2044  * \param [in] context_id -
   2045  *   The context ID.
   2046  * \param [in] current_state_in_p -
   2047  *   The current state of the allocation given to the allocation algorithm from the outside
   2048  *   (as opposed to the current state in algo field SW state).
   2049  *   At the moment contains the allocated FES quartets to the context ID we allocate for.
   2050  * \param [in] fes_fg_in_p -
   2051  *   The information about the new field group and context ID and what allocations they require.
   2052  * \param [in] allow_fes_pgm_sharing -
   2053  *   Whether to enable fes program sharing for this allocation. This is disabled for direct extraction.
   2054  * \param [in] post_attach -
   2055  *   If we add more EFES after context attach.
   2056  * \param [out] alloc_result_p -
   2057  *   Pointer to the memory to be loaded with the result of the allocation.
   2058  *   The data is only valid if alloc_successful_p points to TRUE.
   2059  * \return
   2060  *   shr_error_e - Error Type
   2061  * \remark
   2062  *   * None
   2063  * \see
   2064  *   * dnx_field_actions_convert_fes_instructions_from_alloc_to_write()
   2065  *   * Fes allocation description on ALGORITHM DESCRIPTIONS section in algo_field_action.c.
   2066  */
   2067 shr_error_e dnx_algo_field_action_fes_allocate(
   2068     int unit,
   2069     dnx_field_stage_e field_stage,
   2070     dnx_field_group_t fg_id,
   2071     dnx_field_context_t context_id,
   2072     dnx_algo_field_action_fes_alloc_state_in_t * current_state_in_p,
   2073     dnx_algo_field_action_fes_alloc_in_t * fes_fg_in_p,
   2074     int allow_fes_pgm_sharing,
   2075     int post_attach,
   2076     dnx_algo_field_action_fes_alloc_out_t * alloc_result_p);
   2077 
   2078 /**
   2079  * \brief
   2080  *   This procedure deallocates FES quartets and FES action masks for a context ID and field group.
   2081  *   It's main use is to clear the relevant SW state in algo_field_action, but is also marks all
   2082  *   Fes quartets and FES action masks owned by the context ID and no other context ID, and related
   2083  *   to the field group to be deleted.
   2084  * \param [in] unit -
   2085  *   Device ID.
   2086  * \param [in] field_stage -
   2087  *   For which of the PMF blocks the configuration is done (iPMF-1, iPMF2, iPMF-3, ePMF-1).
   2088  * \param [in] fg_id -
   2089  *   HW identifier of field group to remove.
   2090  * \param [in] context_id -
   2091  *   The context ID that we remove the field group from.
   2092  * \param [in] fes_id -
   2093  *   If DNX_FIELD_EFES_ID_INVALID ignoring this parameter. Otherwise, only delete this sepcific FES ID.
   2094  * \param [in] current_state_dealloc_in_p -
   2095  *   The current state of the allocation given to the allocation algorithm from the outside
   2096  *   (as opposed to the current state in algo field SW state).
   2097  *   At the moment contains the allocated FES quartets to the context ID we allocate for,
   2098  *   and the number of context IDs that are allocated each FES quartet in each FES.
   2099  * \param [out] dealloc_result_p -
   2100  *   Pointer to the memory to be loaded with the result of the deallocation.
   2101  *   For each FES ID, indicates whether to delete FES quartets and FES action masks.
   2102  * \return
   2103  *   shr_error_e - Error Type
   2104  * \remark
   2105  *   * None
   2106  * \see
   2107  *   * dnx_field_actions_fes_context_group_delete()
   2108  */
   2109 shr_error_e dnx_algo_field_action_fes_dealloc(
   2110     int unit,
   2111     dnx_field_stage_e field_stage,
   2112     dnx_field_group_t fg_id,
   2113     dnx_field_context_t context_id,
   2114     dnx_field_fes_id_t fes_id,
   2115     dnx_algo_field_action_fes_dealloc_state_in_t * current_state_dealloc_in_p,
   2116     dnx_algo_field_action_fes_dealloc_out_t * dealloc_result_p);
   2117 
   2118 /**
   2119  * \brief
   2120  *  This procedure allocated FES IDs and mask IDs for the ACE ACR.
   2121  * \param [in] unit -
   2122  *  Device ID.
   2123  * \param [in] ace_id -
   2124  *  Identifier of ACE Format. Also serves as result type in the ACE table and context for the ACE ACR.
   2125  *  Not used in this algorithm.
   2126  * \param [in] current_state_in_p -
   2127  *  The current state of the allocation given to the allocation algorithm from the outside
   2128  *  (as opposed to the current state in algo field SW state, which doesn't exist for the ACE ACR).
   2129  *  At the moment contains the action masks being used by the ACE ACR FESes.
   2130  * \param [in] fes_fg_in_p -
   2131  *   The information about the action that we want to write.
   2132  *   Contains the number of fes instructions to be written and their action masks.
   2133  * \param [in] alloc_result_p -
   2134  *   Pointer to the memory to be loaded with the results of the allocation.
   2135  * \return
   2136  *   shr_error_e - Error Type
   2137  * \remark
   2138  *   * Note that this algorithm assumes that all FES instructions that use masks that aren't all zeros
   2139  *     use the zero mask, and that an all zero mask that isn't the zero mask means it's free for allocation.
   2140  * \see
   2141  *   * dnx_field_actions_fes_ace_set()
   2142  */
   2143 shr_error_e dnx_algo_field_action_ace_fes_allocate(
   2144     int unit,
   2145     dnx_field_ace_id_t ace_id,
   2146     dnx_algo_field_action_ace_fes_alloc_state_in_t * current_state_in_p,
   2147     dnx_algo_field_action_ace_fes_alloc_in_t * fes_fg_in_p,
   2148     dnx_algo_field_action_ace_fes_alloc_out_t * alloc_result_p);
   2149 
   2150 /**
   2151  * \brief
   2152  *   This procedure provides the SW state saved in algo_field_action for the FES quartets of
   2153  *   a specific context ID and FES ID. It also receives the FES program ID as that information isn't saved to SW state,
   2154  *   and needs to be read from HW.
   2155  * \param [in] unit -
   2156  *   Device ID.
   2157  * \param [in] field_stage -
   2158  *   For which of the PMF blocks the configuration is done (iPMF-1, iPMF2, iPMF-3, ePMF-1).
   2159  * \param [in] context_id -
   2160  *   Context ID.
   2161  * \param [in] fes_id -
   2162  *   FES ID.
   2163  * \param [in] fes_pgm_id -
   2164  *   The FES program ID of the FEQ quartet for the context ID and FES ID.
   2165  *   Note that algo_field_action module cannot verify that the FES program ID given is indeed allocated
   2166  *   to the context ID.
   2167  * \param [out] fes_quartet_sw_state_info_p -
   2168  *   Pointer to an array of structures dnx_algo_field_action_fes_quartet_sw_state_get_info_t with the number of elements
   2169  *   DNX_DATA_MAX_FIELD_COMMON_MAX_VAL_NOF_FES_INSTRUCTION_PER_CONTEXT.
   2170  *   to be loaded with the SW state info for the FES quartet.
   2171  * \return
   2172  *   shr_error_e - Error Type
   2173  * \remark
   2174  *   * None
   2175  * \see
   2176  *   * dnx_field_actions_context_fes_info_get()
   2177  */
   2178 shr_error_e dnx_algo_field_action_fes_quartet_sw_state_info_get(
   2179     int unit,
   2180     dnx_field_stage_e field_stage,
   2181     dnx_field_context_t context_id,
   2182     dnx_field_fes_id_t fes_id,
   2183     dnx_field_fes_pgm_id_t fes_pgm_id,
   2184     dnx_algo_field_action_fes_quartet_sw_state_get_info_t * fes_quartet_sw_state_info_p);
   2185 
   2186 /**
   2187 * \brief
   2188 *  Allocate field Context for Field module per Stage
   2189 * \param [in] unit          - Device id
   2190 * \param [in] alloc_flags   - Alloc Flags (WITH_ID)
   2191 * \param [in] stage         - Field Stage to allocate context to
   2192 * \param [in,out] context_id_p  - pointer to dnx_field_context_t
   2193 *                   as input -  the context id to allocate when WITH_ID flag is set
   2194 *                   as output - allocated Context id
   2195 * \return
   2196 *   shr_error_e - Error Type
   2197 * \remark
   2198 *   * None
   2199 * \see
   2200 *   * None
   2201 */
   2202 shr_error_e dnx_algo_field_context_id_allocate(
   2203     int unit,
   2204     int alloc_flags,
   2205     dnx_field_stage_e stage,
   2206     dnx_field_context_t * context_id_p);
   2207 
   2208 /**
   2209 * \brief
   2210 *  Deallocate the Context ID for Field module per Stage
   2211 * \param [in] unit        - Device id
   2212 * \param [in] stage        - Field Stage to deallocate context in
   2213 * \param [in] context_id  - Context id to deallocate
   2214 * \return
   2215 *   shr_error_e - Error Type
   2216 * \remark
   2217 *   * None
   2218 * \see
   2219 *   * None
   2220 */
   2221 shr_error_e dnx_algo_field_context_id_deallocate(
   2222     int unit,
   2223     dnx_field_stage_e stage,
   2224     dnx_field_context_t context_id);
   2225 
   2226 /**
   2227 * \brief
   2228 *  Deallocate the Context ID for Field module per Stage
   2229 * \param [in] unit        - Device id
   2230 * \param [in] stage        - Field Stage the context is in
   2231 * \param [in] context_id  - Context id to check
   2232 * \param [out] is_allocated_p  - TRUE if context was allocated, false otherwise
   2233 * \return
   2234 *   shr_error_e - Error Type
   2235 * \remark
   2236 *   * None
   2237 * \see
   2238 *   * None
   2239 */
   2240 shr_error_e dnx_algo_field_context_id_is_allocated(
   2241     int unit,
   2242     dnx_field_stage_e stage,
   2243     dnx_field_context_t context_id,
   2244     uint8 *is_allocated_p);
   2245 
   2246 /**
   2247 * \brief
   2248 *  Allocate a user defined Apptype.
   2249 * \param [in] unit          - Device id
   2250 * \param [in] alloc_flags   - Alloc Flags (WITH_ID)
   2251 * \param [in,out] apptype_p  - pointer to dnx_field_context_t
   2252 *                   as input -  the Apptype id to allocate when WITH_ID flag is set
   2253 *                   as output - allocated Apptype id
   2254 * \return
   2255 *   shr_error_e - Error Type
   2256 * \remark
   2257 *   * None
   2258 * \see
   2259 *   * None
   2260 */
   2261 shr_error_e dnx_algo_field_context_apptype_allocate(
   2262     int unit,
   2263     int alloc_flags,
   2264     bcm_field_AppType_t * apptype_p);
   2265 
   2266 /**
   2267 * \brief
   2268 *  Deallocate a user defined Apptype.
   2269 * \param [in] unit        - Device id
   2270 * \param [in] apptype     - Apptype to deallocate
   2271 * \return
   2272 *   shr_error_e - Error Type
   2273 * \remark
   2274 *   * None
   2275 * \see
   2276 *   * None
   2277 */
   2278 shr_error_e dnx_algo_field_context_apptype_deallocate(
   2279     int unit,
   2280     bcm_field_AppType_t apptype);
   2281 
   2282 /**
   2283 * \brief
   2284 *  Deallocate the Context ID for Field module per Stage
   2285 * \param [in] unit        - Device id
   2286 * \param [in] apptype     - Apptype to check
   2287 * \param [out] is_allocated_p  - TRUE if the apptype was allocated, false otherwise
   2288 * \return
   2289 *   shr_error_e - Error Type
   2290 * \remark
   2291 *   * None
   2292 * \see
   2293 *   * None
   2294 */
   2295 shr_error_e dnx_algo_field_context_apptype_is_allocated(
   2296     int unit,
   2297     bcm_field_AppType_t apptype,
   2298     uint8 *is_allocated_p);
   2299 
   2300 /**
   2301 * \brief
   2302 *   Check whether specific field group was already allocated
   2303 *   in DNX_ALGO_FIELD_GROUP_ID
   2304 * \par DIRECT INPUT:
   2305 *   \param [in] unit            -  Unit ID
   2306 *   \param [in] fg_id           -  Field Group id to check
   2307 *   \param [in] is_allocated_p  -  Pointer of type uint8.This procedure
   2308 *                                  This procedure loads pointed memory by
   2309 *                                  a non-zero value if specified fg_id is allocated.
   2310 * \return
   2311 *   shr_error_e - Error Type
   2312 * \remark
   2313 *   * None
   2314 * \see
   2315 *   * None
   2316 */
   2317 shr_error_e dnx_algo_field_group_is_allocated(
   2318     int unit,
   2319     dnx_field_group_t fg_id,
   2320     uint8 *is_allocated_p);
   2321 
   2322 /**
   2323 * \brief
   2324 *   Check whether specific ACE ID was already allocated in DNX_ALGO_FIELD_ACE_ID
   2325 * \par DIRECT INPUT:
   2326 *   \param [in] unit            -  Unit ID
   2327 *   \param [in] ace_id          -  ACE ID to check
   2328 *   \param [in] is_allocated_p  -  Pointer of type uint8.This procedure
   2329 *                                  This procedure loads pointed memory by
   2330 *                                  a non-zero value if specified ace_id is allocated.
   2331 * \return
   2332 *   shr_error_e - Error Type
   2333 * \remark
   2334 *   * None
   2335 * \see
   2336 *   * None
   2337 */
   2338 shr_error_e dnx_algo_field_ace_id_is_allocated(
   2339     int unit,
   2340     dnx_field_ace_id_t ace_id,
   2341     uint8 *is_allocated_p);
   2342 
   2343 /**
   2344 * \brief
   2345 *   Check whether specific ACE key was already allocated in DNX_ALGO_FIELD_ACE_KEY
   2346 * \par DIRECT INPUT:
   2347 *   \param [in] unit            -  Unit ID
   2348 *   \param [in] ace_key         -  ACE key to check
   2349 *   \param [in] is_allocated_p  -  Pointer of type uint8.This procedure
   2350 *                                  This procedure loads pointed memory by
   2351 *                                  a non-zero value if specified ace_id is allocated.
   2352 * \return
   2353 *   shr_error_e - Error Type
   2354 * \remark
   2355 *   * None
   2356 * \see
   2357 *   * None
   2358 */
   2359 shr_error_e dnx_algo_field_ace_key_is_allocated(
   2360     int unit,
   2361     dnx_field_ace_key_t ace_key,
   2362     uint8 *is_allocated_p);
   2363 
   2364 /**
   2365 * \brief
   2366 *  Increases the number of links for the given context ID, the number of links for a given context in
   2367 *  iPMF1 stage indicates how many iPMF2 contexts are "attached" or in other words being "cascaded"
   2368 *  from the iPMF1 context.
   2369 *  This function allocates a new link profile number for the iPMF1 contextfor the first link that
   2370 *  gets created.
   2371 *
   2372 * \param[in] unit       - Device ID
   2373 * \param[in] context_id - iPMF1 Context ID to increase number of links for (possibly allocating a
   2374 *                         new link profile number for)
   2375 *
   2376 * \return
   2377 *   shr_error_e - Error Type
   2378 * \remark
   2379 *   * None
   2380 * \see
   2381 *   * None
   2382 */
   2383 shr_error_e dnx_algo_field_context_links_inc(
   2384     int unit,
   2385     dnx_field_context_t context_id);
   2386 
   2387 /**
   2388 * \brief
   2389 *  Decreases the number of links for the given context ID, the number of links for a given context in
   2390 *  iPMF1 stage indicates how many iPMF2 contexts are "attached" or in other words being "cascaded"
   2391 *  from the iPMF1 context.
   2392 *  This function deallocates the link profile number for the iPMF1 context if no more links are left.
   2393 *
   2394 * \param[in] unit       - Device ID
   2395 * \param[in] context_id - iPMF1 Context ID to decrease number of links for (possibly deallocating its
   2396 *                         link profile number)
   2397 *
   2398 * \return
   2399 *   shr_error_e - Error Type
   2400 * \remark
   2401 *   * None
   2402 * \see
   2403 *   * None
   2404 */
   2405 shr_error_e dnx_algo_field_context_links_dec(
   2406     int unit,
   2407     dnx_field_context_t context_id);
   2408 
   2409 /**
   2410 * \brief
   2411 *  Returns the link profile number for the given context.
   2412 *  Links profile numbers are given to contexts in iPMF1 stage and are required to perform cascading
   2413 *  between foreign contexts.
   2414 *
   2415 * \param[in] unit           - Device ID
   2416 * \param[in] context_id     - Context ID to get link profile number for
   2417 * \param[out] profile_num_p - Link profile number for the given context
   2418 *
   2419 * \return
   2420 *   shr_error_e - Error Type
   2421 * \remark
   2422 *   * None
   2423 * \see
   2424 *   * None
   2425 */
   2426 shr_error_e dnx_algo_field_link_profile_get(
   2427     int unit,
   2428     dnx_field_context_t context_id,
   2429     int *profile_num_p);
   2430 
   2431 /*
   2432  * } Prototypes
   2433 */
   2434 
   2435 /*
   2436  * Utility procedures to be used by diag
   2437  * {
   2438  */
   2439 /**
   2440  * \brief
   2441  *  This function will indicate key allocation state: Is there any occupied key
   2442  *  on specified pair - stage and context
   2443  * \param [in] unit               - Device ID
   2444  * \param [in] field_stage        -
   2445  *   dnx_field_stage_e. Stage to use for searching key occupation state
   2446  * \param [in] context_id            -
   2447  *   dnx_field_context_t. Context id (program) to use for searching key occupation state
   2448  * \param [in] group_type            -
   2449  *   dnx_field_group_type_e. Group type to use for searching key occupation state
   2450  *   If set to DNX_FIELD_GROUP_TYPE_INVALID then this input is ignored (i.e., group
   2451  *   type is 'do not care').
   2452  * \param [in] bit_range_only            -
   2453  *   int. If this input is 'zero' then ignore it. If non-zero then search only
   2454  *   'field group types' which support the 'bit-range' feature. If feature is
   2455  *   not soppurted, this procedure will flag 'not occupied'
   2456  * \param [out] none_occupied_p            -
   2457  *   int pointer. This procedure loads pointed memory by a non-zero value
   2458  *   if no key is occupied for this stage/context pair.
   2459  * \return
   2460  *   shr_error_e - Error Type
   2461  * \remark
   2462  *   * Output of this procedure is based on keys occupation as stored on SW state.
   2463  * \see
   2464  *   * None
   2465  */
   2466 shr_error_e dnx_algo_field_key_is_any_key_occupied(
   2467     int unit,
   2468     dnx_field_stage_e field_stage,
   2469     dnx_field_context_t context_id,
   2470     dnx_field_group_type_e group_type,
   2471     int bit_range_only,
   2472     int *none_occupied_p);
   2473 /*
   2474  * }
   2475  */
   2476 
   2477 #endif/*_FIELD_API_INCLUDED__*/