alloc_mngr_local_lif.h (12976B)
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_lif.h 8 * Purpose: Resource allocation for lif. 9 */ 10 11 #ifndef INCLUDE_ALLOC_MNGR_LOCAL_LIF_H 12 /* { */ 13 #define INCLUDE_ALLOC_MNGR_LOCAL_LIF_H 14 15 /************* 16 * INCLUDES * 17 */ 18 /* { */ 19 #include <soc/dpp/mbcm.h> 20 #include <soc/dpp/mbcm_pp.h> 21 #include <bcm_int/dpp/alloc_mngr_lif.h> 22 #include <soc/dpp/ARAD/ARAD_PP/arad_pp_eg_encap.h> 23 /* } */ 24 /************* 25 * DEFINES * 26 */ 27 /* 28 * SW_STATE ACCESS 29 */ 30 #define LIF_LINKED_LIST_ACCESS sw_state_access[unit].dpp.bcm.lif_linked_list 31 #define LIF_LINKED_LISTS_ARRAY_ACCESS LIF_LINKED_LIST_ACCESS.lif_linked_lists_array 32 #define LIF_LINKED_LIST_MEMBERS_ARRAY_ACCESS LIF_LINKED_LIST_ACCESS.lif_linked_list_members_array 33 34 #define BCM_DPP_AM_IN_LIF_FLAG_COMMON (1<<0) 35 #define BCM_DPP_AM_IN_LIF_FLAG_WIDE (1<<1) 36 #define BCM_DPP_AM_IN_LIF_FLAG_ALLOC_WITH_ID (1<<2) 37 #define BCM_DPP_AM_IN_LIF_FLAG_ALLOC_CHECK_ONLY (1<<3) 38 39 #define BCM_DPP_AM_OUT_LIF_FLAG_DIRECT (1<<0) 40 #define BCM_DPP_AM_OUT_LIF_FLAG_COUPLED (1<<1) 41 #define BCM_DPP_AM_OUT_LIF_FLAG_WIDE (1<<2) 42 #define BCM_DPP_AM_OUT_LIF_FLAG_ODD_HALF (1<<3) 43 #define BCM_DPP_AM_OUT_LIF_FLAG_EVEN_HALF (1<<4) 44 #define BCM_DPP_AM_OUT_LIF_FLAG_ALLOC_CHECK_ONLY (1<<5) 45 #define BCM_DPP_AM_OUT_LIF_FLAG_FORCE_FRONT_SIXTEEN (1<<6) 46 47 48 #define BCM_DPP_AM_COUNTING_PROFILE_NONE (0xFF) 49 #define BCM_DPP_AM_COUNTING_PROFILE_RESERVED (0xFE) 50 51 #define BCM_DPP_AM_LOCAL_IN_LIF_NOF_RESERVED_LIFS (0x10) 52 53 #define _BCM_DPP_AM_INGRESS_LIF_NOF_BANKS (SOC_DPP_DEFS_GET(unit, nof_inlif_banks)) 54 #define _BCM_DPP_AM_LOCAL_LIF_NOF_INLIF_ENTRIES_PER_BANK (SOC_DPP_DEFS_GET(unit, nof_local_lifs_per_bank)) 55 56 #define _BCM_DPP_AM_LOCAL_LIF_NOF_INLIF_HALF_ENTRIES_PER_BANK \ 57 (2 * _BCM_DPP_AM_LOCAL_LIF_NOF_INLIF_ENTRIES_PER_BANK) 58 59 /*The max number of inLIF IDs*/ 60 #define _BCM_DPP_AM_INGRESS_LIF_NOF_INLIF_IDS \ 61 (SOC_DPP_DEFS_NOF_INLIF_BANKS_MAX * SOC_DPP_DEFS_NOF_LOCAL_LIFS_PER_BANK_MAX) 62 63 #define _BCM_DPP_AM_EGRESS_LIF_NOF_ENTRIES_BLOCKS (256) 64 #define _BCM_DPP_AM_EGRESS_LIF_NOF_ENTRIES_PER_BANK(_unit) (2 * SOC_DPP_DEFS_GET(_unit, nof_eedb_lines_per_bank)) 65 #define _BCM_DPP_AM_EGRESS_LIF_NOF_ENTRIES_PER_HALF_BANK(_unit) (_BCM_DPP_AM_EGRESS_LIF_NOF_ENTRIES_PER_BANK(_unit) /2) 66 #define _BCM_DPP_AM_EGRESS_LIF_NOF_TOP_BANKS_PER_EEDB_BANK (4) 67 #define _BCM_DPP_AM_EGRESS_LIF_NOF_TOP_BANKS_PER_EEDB_HALF_BANK (_BCM_DPP_AM_EGRESS_LIF_NOF_TOP_BANKS_PER_EEDB_BANK / 2) 68 #define _BCM_DPP_AM_EGRESS_LIF_NOF_ENTRIES_PER_TOP_BANK(unit) (_BCM_DPP_AM_EGRESS_LIF_NOF_ENTRIES_PER_HALF_BANK(unit) /_BCM_DPP_AM_EGRESS_LIF_NOF_TOP_BANKS_PER_EEDB_HALF_BANK) 69 #define _BCM_DPP_AM_EGRESS_LIF_NOF_TOP_BANKS(unit) (SOC_DPP_DEFS_GET(unit, eg_encap_nof_top_banks)) 70 #define _BCM_DPP_AM_EGRESS_LIF_NOF_TOP_EEDB_BANKS(unit) (_BCM_DPP_AM_EGRESS_LIF_NOF_TOP_BANKS(unit) / _BCM_DPP_AM_EGRESS_LIF_NOF_TOP_BANKS_PER_EEDB_BANK) 71 #define _BCM_DPP_AM_EGRESS_LIF_NOF_EEDB_BANKS(unit) (SOC_DPP_DEFS_GET(unit, eg_encap_nof_banks)) 72 #define _BCM_DPP_AM_EGRESS_LIF_NOF_EEDB_REGULAR_BANKS(unit) (_BCM_DPP_AM_EGRESS_LIF_NOF_EEDB_BANKS(unit) \ 73 - _BCM_DPP_AM_EGRESS_LIF_NOF_TOP_EEDB_BANKS(unit)) 74 #define _BCM_DPP_AM_EGRESS_LIF_NOF_EEDB_HALF_BANKS(unit) (_BCM_DPP_AM_EGRESS_LIF_NOF_EEDB_BANKS(unit) * 2) 75 #define _BCM_DPP_AM_EGRESS_LIF_NOF_EEDB_REGULAR_HALF_BANKS(unit) (_BCM_DPP_AM_EGRESS_LIF_NOF_EEDB_REGULAR_BANKS(unit) * 2) 76 77 #define BCM_DPP_AM_LOCAL_OUT_LIF_BANK_FLAG_FORCE_TYPE (1<<0) 78 #define BCM_DPP_AM_LOCAL_OUT_LIF_BANK_FLAG_FORCE_EXTENSION (1<<1) 79 #define BCM_DPP_AM_LOCAL_OUT_LIF_BANK_FLAG_FORCE_PHASE (1<<2) 80 #define BCM_DPP_AM_LOCAL_OUT_LIF_BANK_FLAG_FORCE_EXT_TYPE (1<<3) 81 82 #define _BCM_DPP_AM_EEDB_BANK_UNASSIGNED (0xFF) 83 #define _BCM_DPP_AM_LOCAL_LIF_ID_UNASSIGNED (0xFFFFFFFF) 84 85 #define _BCM_DPP_AM_LOCAL_LIF_NOF_FAILOVER_IDS (32 * 1024) /* 32K Failover-ids*/ 86 87 #define BCM_DPP_AM_LOCAL_OUT_LIF_HALF_BANK_IN_RANGE(unit, bank_id) \ 88 (bank_id<_BCM_DPP_AM_EGRESS_LIF_NOF_EEDB_HALF_BANKS(unit)) 89 90 #define BCM_DPP_AM_LOCAL_OUT_LIF_REGULAR_HALF_BANK_IN_RANGE(unit, bank_id) \ 91 (bank_id<_BCM_DPP_AM_EGRESS_LIF_NOF_EEDB_REGULAR_HALF_BANKS(unit)) 92 93 94 #define _BCM_DPP_AM_INGRESS_LOCAL_COMMON_LIF_POOL_ID_START (dpp_am_res_local_inlif_common) 95 96 #define _BCM_DPP_AM_INGRESS_LOCAL_COMMON_LIF_POOL_ID_END \ 97 (_BCM_DPP_AM_INGRESS_LOCAL_COMMON_LIF_POOL_ID_START + _BCM_DPP_AM_INGRESS_LIF_NOF_BANKS) 98 99 #define _BCM_DPP_AM_INGRESS_LOCAL_WIDE_LIF_POOL_ID_START \ 100 (_BCM_DPP_AM_INGRESS_LOCAL_COMMON_LIF_POOL_ID_END) 101 102 #define _BCM_DPP_AM_INGRESS_LOCAL_WIDE_LIF_POOL_ID_END \ 103 (_BCM_DPP_AM_INGRESS_LOCAL_WIDE_LIF_POOL_ID_START + _BCM_DPP_AM_INGRESS_LIF_NOF_BANKS) 104 105 106 /* LIF ranges counting profiles */ 107 108 #define _BCM_DPP_AM_LOCAL_IN_LIF_NOF_COUNTING_RANGES (2) 109 #define _BCM_DPP_AM_LOCAL_IN_LIF_NOF_COUNTING_PROFILES_PER_RANGE (1) 110 #define _BCM_DPP_AM_LOCAL_IN_LIF_NOF_COUNTING_PROFILES \ 111 (_BCM_DPP_AM_LOCAL_IN_LIF_NOF_COUNTING_PROFILES_PER_RANGE * _BCM_DPP_AM_LOCAL_IN_LIF_NOF_COUNTING_RANGES) 112 113 114 #define _BCM_DPP_AM_LOCAL_OUT_LIF_NOF_COUNTING_RANGES (64) 115 #define _BCM_DPP_AM_LOCAL_OUT_LIF_NOF_COUNTING_PROFILES_PER_RANGE (1) 116 #define _BCM_DPP_AM_LOCAL_OUT_LIF_NOF_COUNTING_PROFILES \ 117 (_BCM_DPP_AM_LOCAL_OUT_LIF_NOF_COUNTING_PROFILES_PER_RANGE * _BCM_DPP_AM_LOCAL_OUT_LIF_NOF_COUNTING_RANGES) 118 119 /*IN QAX/J+ the number of outlif counting ranges were changed to 64*/ 120 #define _BCM_DPP_AM_LOCAL_OUT_LIF_NOF_COUNTING_PROFILES_GET(unit) \ 121 ((SOC_IS_JERICHO_PLUS(unit)) ? _BCM_DPP_AM_LOCAL_OUT_LIF_NOF_COUNTING_PROFILES : _BCM_DPP_AM_LOCAL_IN_LIF_NOF_COUNTING_RANGES) 122 123 #define _BCM_DPP_AM_LOCAL_OUT_LIF_ARP_POINTED_LSB_NOF_BITS (6) 124 #define _BCM_DPP_AM_LOCAL_OUT_LIF_NOF_ARP_POINTED (1 << _BCM_DPP_AM_LOCAL_OUT_LIF_ARP_POINTED_LSB_NOF_BITS) 125 #define _BCM_DPP_AM_LOCAL_OUT_LIF_ARP_POINTED_LSB_MASK (_BCM_DPP_AM_LOCAL_OUT_LIF_NOF_ARP_POINTED - 1) 126 127 128 /* } */ 129 /************* 130 * MACROS * 131 */ 132 /* { */ 133 #define BCM_DPP_AM_LOCAL_INLIF_HANDLE_TO_BASE_LIF_ID(lif_handle) \ 134 ( (lif_handle%2==0) ? (lif_handle/2) : (lif_handle/2 + 1) ) 135 136 #define BCM_DPP_AM_LOCAL_INLIF_HANDLE_TO_ADDITIONAL_LIF_ID(lif_handle) \ 137 ( (lif_handle%2==0) ? (lif_handle/2 + 1) : (lif_handle/2) ) 138 139 #define BCM_DPP_AM_LOCAL_INLIF_HANDLE_TO_SEM_RESULT_ID(lif_handle) \ 140 (lif_handle/2 ) 141 142 143 /* } */ 144 /************* 145 * TYPE DEFS * 146 */ 147 /* { */ 148 /*The following structure defines an entry in the Ingress Local LIF table*/ 149 typedef struct bcm_dpp_am_local_inlif_info_s 150 { 151 bcm_dpp_am_ingress_lif_app_t app_type; 152 int local_lif_flags; 153 int base_lif_id; 154 int ext_lif_id; 155 int glif; 156 uint8 valid; 157 uint8 counting_profile_id; 158 } bcm_dpp_am_local_inlif_info_t; 159 160 typedef struct bcm_dpp_am_local_inlif_six_packs_info_s 161 { 162 uint8 is_used; 163 uint8 lif_type; 164 } bcm_dpp_am_local_inlif_six_packs_info_t; 165 166 167 typedef struct bcm_dpp_am_local_inlif_table_bank_info_s 168 { 169 uint8 valid; 170 uint32 phase_bmp; 171 bcm_dpp_am_local_inlif_six_packs_info_t packs_info[SOC_DPP_DEFS_NOF_LOCAL_LIFS_PER_BANK_MAX * 2/6 + 1]; 172 173 } bcm_dpp_am_local_inlif_table_bank_info_t; 174 175 176 typedef struct bcm_dpp_am_local_inlif_application_type_info_s 177 { 178 uint8 banks_bmp; 179 } bcm_dpp_am_local_inlif_application_type_info_t; 180 181 182 typedef struct bcm_dpp_am_local_lif_counter_profile_info_s{ 183 int size; 184 int base_offset; 185 int double_entry; 186 } bcm_dpp_am_local_lif_counter_profile_info_t; 187 188 189 typedef struct bcm_dpp_alloc_mngr_local_inlif_info_s { 190 uint8 initalized; 191 uint8 lif_allocated; 192 bcm_dpp_am_local_inlif_info_t data_base[_BCM_DPP_AM_INGRESS_LIF_NOF_INLIF_IDS]; 193 bcm_dpp_am_local_inlif_table_bank_info_t bank_info[SOC_DPP_DEFS_NOF_INLIF_BANKS_MAX]; 194 bcm_dpp_am_local_inlif_application_type_info_t application_type_info[bcm_dpp_am_ingress_lif_nof_app_types]; 195 bcm_dpp_am_local_lif_counter_profile_info_t counter_profile_info[_BCM_DPP_AM_LOCAL_IN_LIF_NOF_COUNTING_PROFILES]; 196 } bcm_dpp_alloc_mngr_local_inlif_info_t; 197 198 typedef struct bcm_dpp_am_local_out_lif_info_s 199 { 200 bcm_dpp_am_egress_encap_alloc_info_t app_alloc_info; 201 int local_lif_flags; 202 int glif; 203 int failover_id; /*device mode */ 204 int base_lif_id; 205 int ext_lif_id; 206 uint8 counting_profile_id; 207 } bcm_dpp_am_local_out_lif_info_t; 208 209 210 211 /* failover-id linked list member struct */ 212 typedef struct failover_free_lif_linked_list_member_s { 213 int lif_id; 214 uint8 is_even; 215 int next; 216 } failover_free_lif_linked_list_member_t; 217 218 /* failover-id linked list struct */ 219 typedef struct failover_free_lif_linked_list_s { 220 int first_member; 221 uint32 size; 222 } failover_free_lif_linked_list_t; 223 224 typedef struct bcm_dpp_am_arp_next_lif_info_s { 225 int lif_base; 226 int nof_alloc_lifs; /* nof lif allocated already from alloc_bmp*/ 227 uint8 ready; /* is LIF resource allocated in res_bmp */ 228 PARSER_HINT_ARR SHR_BITDCL *res_bmp; /* available resource bitmap */ 229 PARSER_HINT_ARR SHR_BITDCL *alloc_bmp; /* allocated resource bitmap */ 230 } bcm_dpp_am_arp_next_lif_info_t; 231 232 typedef struct bcm_dpp_alloc_mngr_local_outlif_info_s { 233 uint8 initalized; 234 uint8 lif_allocated; 235 PARSER_HINT_ARR bcm_dpp_am_local_out_lif_info_t *data_base; 236 bcm_dpp_am_local_lif_counter_profile_info_t counter_profile_info[_BCM_DPP_AM_LOCAL_OUT_LIF_NOF_COUNTING_PROFILES]; 237 bcm_dpp_am_arp_next_lif_info_t arp_next_lif; 238 } bcm_dpp_alloc_mngr_local_outlif_info_t; 239 240 typedef struct bcm_dpp_alloc_mngr_outlif_eedb_banks_info_s { 241 PARSER_HINT_ARR arad_pp_eg_encap_eedb_bank_info_t *banks; 242 PARSER_HINT_ARR arad_pp_eg_encap_eedb_top_bank_info_t *top_banks; 243 } bcm_dpp_alloc_mngr_outlif_eedb_banks_info_t; 244 245 typedef struct bcm_dpp_alloc_mngr_local_lif_info_s { 246 bcm_dpp_alloc_mngr_local_inlif_info_t inlif_info; 247 bcm_dpp_alloc_mngr_local_outlif_info_t outlif_info; 248 bcm_dpp_alloc_mngr_outlif_eedb_banks_info_t eedb_info; 249 } bcm_dpp_alloc_mngr_local_lif_info_t; 250 /* 251 * Control Structure for all created fail-over link lists. 252 * Each linked list is rooted by failover_free_lif_linked_list_t. 253 * See _bcm_dpp_am_local_outlif_init() 254 */ 255 typedef struct bcm_dpp_lif_linked_list_s 256 { 257 uint32 max_nof_lif_linked_lists ; 258 PARSER_HINT_ARR failover_free_lif_linked_list_t *lif_linked_lists_array ; 259 260 uint32 max_nof_lif_linked_list_members ; 261 PARSER_HINT_ARR failover_free_lif_linked_list_member_t *lif_linked_list_members_array ; 262 263 } bcm_dpp_lif_linked_list_t ; 264 265 /* } */ 266 /************* 267 * GLOBALS * 268 */ 269 /* { */ 270 271 /* } */ 272 /************* 273 * FUNCTIONS * 274 */ 275 276 int failover_linked_list_print( 277 /*in*/ 278 int unit, 279 int linked_list) ; 280 281 uint32 282 _bcm_dpp_am_local_inlif_init(int unit); 283 284 uint32 285 _bcm_dpp_am_local_inlif_deinit(int unit); 286 287 uint32 288 _bcm_dpp_am_local_inlif_alloc(int unit, int flags, bcm_dpp_am_local_inlif_info_t *lif_info); 289 290 uint32 291 _bcm_dpp_am_local_inlif_dealloc(int unit, int lif_index); 292 293 uint32 294 _bcm_dpp_am_local_inlif_is_alloc(int unit, int lif_index); 295 296 uint32 297 _bcm_dpp_am_local_inlif_counting_profile_set(int unit, int counting_profile_id, int base, int size); 298 299 uint32 300 _bcm_dpp_am_local_outlif_init(int unit); 301 302 uint32 303 _bcm_dpp_am_local_outlif_deinit(int unit); 304 305 uint32 306 _bcm_dpp_am_local_outlif_alloc(int unit, int flags, bcm_dpp_am_local_out_lif_info_t *lif_info); 307 308 uint32 309 _bcm_dpp_am_local_outlif_arp_pointed_alloc(int unit, int flags, bcm_dpp_am_local_out_lif_info_t *lif_info); 310 311 uint32 312 _bcm_dpp_am_local_outlif_dealloc(int unit, int lif_index); 313 314 uint32 315 _bcm_dpp_am_local_outlif_arp_pointed_dealloc(int unit, int lif_index); 316 317 uint32 318 _bcm_dpp_am_local_outlif_dealloc_only(int unit, int lif_index); 319 320 uint32 321 _bcm_dpp_am_local_outlif_is_alloc(int unit, int lif_index); 322 323 uint32 324 _bcm_dpp_am_local_outlif_extension_bank_alloc(int unit, int bank_id, int *ext_bank_id, uint8 *bank_found); 325 326 uint32 327 _bcm_dpp_am_local_outlif_extension_bank_dealloc(int unit, int bank_id); 328 329 uint32 330 _bcm_dpp_am_local_outlif_bank_phase_set(int unit, int bank_id, int phase); 331 332 uint32 333 _bcm_dpp_am_local_outlif_counting_profile_set(int unit, int counting_profile_id, int base, int size, int double_entry); 334 335 uint32 336 _bcm_dpp_am_local_outlif_counting_profile_get(int unit, int counting_profile_id, int *base, int *size, int *double_entry); 337 338 339 uint32 340 _bcm_dpp_local_lif_is_wide_entry(int unit, int local_lif, int is_ingress, int *is_wide_entry); 341 342 343 /* } */ 344 #endif /*INCLUDE_ALLOC_MNGR_LOCAL_LIF_H*/ 345