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

alloc_mngr_utils.h (5147B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2020 Broadcom Inc. All rights reserved.
      6  *
      7  * File:        alloc_mngr_utils.h
      8  * Purpose:     Utils for resource allocation. Especially concerning multi core devices.
      9  */
     10 
     11 #ifndef  INCLUDE_ALLOC_MNGR_UTILS_H
     12 #define  INCLUDE_ALLOC_MNGR_UTILS_H
     13 
     14 #include <shared/swstate/sw_state_resmgr.h>
     15 
     16 #define BCM_DPP_AM_DEFAULT_NOF_POOLS    1
     17 #define BCM_DPP_AM_DEFAULT_POOL_IDX     0
     18 #define BCM_DPP_AM_INVALID_POOL_IDX     (-1)
     19 
     20 
     21 /* SW State for alloc manager utility engine */
     22 typedef struct {
     23     PARSER_HINT_ARR int                         *resource_to_pool_map;
     24     PARSER_HINT_ARR int                         *template_to_pool_map;
     25 } bcm_dpp_alloc_mngr_utils_info_t;
     26 
     27 #define DPP_AM_RES_CHECK_SILENT_MODE(_rv,_flags) \
     28     if ( ( _rv == BCM_E_RESOURCE ) && (_flags & SW_STATE_RES_TAG_BITMAP_ALLOC_CHECK_ONLY) ) { BCM_RETURN_VAL_EXIT(_rv); } \
     29     else { BCMDNX_IF_ERR_EXIT(_rv); }
     30 
     31 /*
     32  * GENERAL CORE HANDLING UTILS - START
     33  */
     34 
     35 int 
     36 bcm_dpp_am_resource_to_nof_pools(int unit, int res_type, uint8 *nof_pools);
     37 
     38 int 
     39 bcm_dpp_am_template_to_nof_pools(int unit, int res_type, uint8 *nof_pools);
     40 
     41 int
     42 bcm_dpp_am_resource_id_to_pool_id_get(int unit, int pool_idx, int resource_id, int *pool_id);
     43 
     44 int
     45 bcm_dpp_am_template_id_to_pool_id_get(int unit, int pool_idx, int template_id, int *pool_id);
     46 
     47 int 
     48 bcm_dpp_am_pool_id_to_resource_id_get(int unit, int pool_id, int *res_id, int *pool_idx);
     49 
     50 int 
     51 bcm_dpp_am_pool_id_to_template_id_get(int unit, int pool_id, int *template_id, int *pool_idx);
     52 
     53 
     54 /*
     55  * GENERAL CORE HANDLING UTILS - END
     56  */
     57 
     58 
     59 /*
     60  * RESOURCE MANAGER ENCAPSULATION - START
     61  */
     62 
     63 int 
     64 dpp_am_res_free(int unit, int pool_idx, int res_id, int count, int elem);
     65 
     66 int 
     67 dpp_am_res_free_and_status(int unit, int pool_idx, int res_id, int count, int elem, uint32 *flags);
     68 
     69 int 
     70 dpp_am_res_alloc(int unit, int pool_idx, int res_id, uint32 flags, int count, int *elem);
     71 
     72 int 
     73 dpp_am_res_silent_alloc(int unit, int pool_idx, int res_id, uint32 flags, int count, int *elem);
     74 
     75 int 
     76 dpp_am_res_alloc_align(int unit, int pool_idx, int res_id, uint32 flags, int align, int offset, int count, int *elem);
     77 
     78 int 
     79 dpp_am_res_silent_alloc_align(int unit, int pool_idx, int res_id, uint32 flags, int align, int offset, int count, int *elem);
     80 
     81 int
     82 dpp_am_res_alloc_align_tag(int unit, int pool_idx, int res_id, uint32 flags, int align, int offset, const void *tag, int count, int *elem);
     83 
     84 int
     85 dpp_am_res_alloc_tag(int unit, int pool_idx, int res_id, uint32 flags, const void *tag, int count, int *elem);
     86 
     87 int
     88 dpp_am_res_tag_set(int unit, int pool_idx, int res_id, uint32 flags, int offset, int count, const void *tag);
     89 
     90 int
     91 dpp_am_res_tag_get(int unit, int pool_idx, int res_id, uint32 flags, int elem, const void *tag);
     92 
     93 int
     94 dpp_am_res_check(int unit, int pool_idx, int res_id, int count, int elem);
     95 
     96 /* Return the amount of used elements in res_id. */
     97 int
     98 dpp_am_res_used_count_get(int unit, int pool_idx, int res_id, int *used_count);
     99 
    100 int
    101 dpp_am_res_check_all(int unit, int pool_idx, int res_id, int count, int elem);
    102 
    103 int
    104 dpp_am_res_set_pool(int unit, int pool_idx, int res_id, sw_state_res_allocator_t manager, 
    105                                  int low_id, int count, const void *extras, const char *name);
    106 
    107 int
    108 dpp_am_res_unset_pool(int unit, int pool_idx, int res_id);
    109 
    110 /*
    111  * RESOURCE MANAGER ENCAPSULATION - END
    112  */
    113 
    114 
    115 /*
    116  * TEMPLATE MANAGER ENCAPSULATION - START
    117  */
    118 
    119 
    120 int 
    121 dpp_am_template_allocate(int unit, int pool_idx, int template_id, uint32 flags, const void *data, int *is_allocated, int *template);
    122 
    123 int 
    124 dpp_am_template_allocate_group(int unit, int pool_idx, int template_id, uint32 flags, const void *data, int nof_additions, int *is_allocated, int *template);
    125 
    126 int
    127 dpp_am_template_exchange(int unit, int pool_idx, int template_id, uint32 flags, const void *data, int old_template,
    128                                       int *is_last, int *template, int *is_allocated);
    129 
    130 int
    131 dpp_am_template_exchange_test(int unit, int pool_idx, int template_id, uint32 flags, const void *data, int old_template,
    132                                       int *is_last, int *template, int *is_allocated);
    133 
    134 int
    135 dpp_am_template_free(int unit, int pool_idx, int template_id, int template, int *is_last);
    136 
    137 int
    138 dpp_am_template_free_group(int unit, int pool_idx, int template_id, int template, int nof_deductions, int *is_last);
    139 
    140 int
    141 dpp_am_template_free_all(int unit, int pool_idx, int template_id, int template, int *nof_deductions);
    142 
    143 int 
    144 dpp_am_template_clear(int unit, int pool_idx, int template_id);
    145 
    146 int
    147 dpp_am_template_data_get(int unit, int pool_idx, int template_id, int template, void *data);
    148 
    149 int
    150 dpp_am_template_template_get(int unit, int pool_idx, int template_id, const void *data, int *template);
    151 
    152 int
    153 dpp_am_template_ref_count_get(int unit, int pool_idx, int template_id, int template, uint32 *ref_count);
    154 
    155 int
    156 dpp_am_template_template_count_get(int unit, int pool_idx, int template_id, int *template_count);
    157 
    158 /*
    159  * TEMPLATE MANAGER ENCAPSULATION - END
    160  */
    161 
    162 #endif /*INCLUDE_ALLOC_MNGR_UTILS_H*/
    163