l3x.h (4430B)
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-2019 Broadcom Inc. All rights reserved. 6 * 7 * File: l3x.h 8 * Purpose: Draco L3X hardware table manipulation support 9 */ 10 11 #ifndef _L3X_H_ 12 #define _L3X_H_ 13 14 #include <soc/macipadr.h> 15 #include <soc/hash.h> 16 17 #define L3_LOCK(_unit_) soc_esw_l3_lock(_unit_) 18 #define L3_UNLOCK(_unit_) soc_esw_l3_unlock(_unit_) 19 20 extern int soc_esw_l3_lock(int unit); 21 extern int soc_esw_l3_unlock(int unit); 22 23 #ifdef BCM_XGS_SWITCH_SUPPORT 24 #if defined(INCLUDE_L3) 25 #define SOC_MEM_L3X_ENTRY_VALID (1 << 0) 26 #define SOC_MEM_L3X_ENTRY_MOVED (1 << 1) 27 #define SOC_MEM_L3X_ENTRY_MOVE_FAIL (1 << 2) 28 29 /* 30 * Dual hash l3x entry info. 31 */ 32 typedef struct soc_mem_l3x_entry_info_s { 33 int index; /* Entry start index in the bucket. */ 34 int size; /* Entry size - number of base memory */ 35 /* slots entry occupies. */ 36 soc_mem_t mem; /* View name. */ 37 uint8 flags; /* Entry flags - valid/move attempted. */ 38 } soc_mem_l3x_entry_info_t; 39 40 /* 41 * Dual hash l3x half bucket entries map. 42 */ 43 typedef struct soc_mem_l3x_bucket_map_s { 44 int size; /* Bucket map size (#valid entries). */ 45 int valid_count; /* Count of valid base entries in the bucket. */ 46 int total_count; /* Total number of base entries in the bucket.*/ 47 soc_mem_t base_mem;/* Base memory/view name. */ 48 soc_mem_t base_idx;/* Bucket start index in base memory. */ 49 soc_mem_l3x_entry_info_t *entry_arr; 50 /* Bucket entries information array. */ 51 } soc_mem_l3x_bucket_map_t; 52 #endif /* INCLUDE_L3 */ 53 54 extern int soc_l3x_init(int unit); 55 56 /* These defines should be replaced with unit-based accessors someday */ 57 #define SOC_L3X_MAX_BUCKET_SIZE 16 58 #define SOC_L3X_BUCKET_SIZE(_u) ((SOC_IS_RAVEN(_u) || SOC_IS_TR_VL(_u)) ? 16 : 8) 59 #define SOC_L3X_IP_MULTICAST(i) (((uint32)(i) & 0xf0000000) == 0xe0000000) 60 extern int soc_l3x_entries(int unit); /* Warning: very slow */ 61 62 extern int soc_l3x_lock(int unit); 63 extern int soc_l3x_unlock(int unit); 64 65 /* 66 * L3 software-based sanity routines 67 */ 68 69 #endif /* BCM_XGS_SWITCH_SUPPORT */ 70 71 #ifdef BCM_FIREBOLT_SUPPORT 72 73 extern int soc_fb_l3x_bank_insert(int unit, uint8 banks, 74 l3_entry_ipv6_multicast_entry_t *entry); 75 extern int soc_fb_l3x_bank_delete(int unit, uint8 banks, 76 l3_entry_ipv6_multicast_entry_t *entry); 77 extern int soc_fb_l3x_bank_lookup(int unit, uint8 banks, 78 l3_entry_ipv6_multicast_entry_t *key, 79 l3_entry_ipv6_multicast_entry_t *result, 80 int *index_ptr); 81 82 extern int soc_fb_l3x_insert(int unit, l3_entry_ipv6_multicast_entry_t *entry); 83 extern int soc_fb_l3x_delete(int unit, l3_entry_ipv6_multicast_entry_t *entry); 84 extern int soc_fb_l3x_lookup(int unit, l3_entry_ipv6_multicast_entry_t *key, 85 l3_entry_ipv6_multicast_entry_t *result, 86 int *index_ptr); 87 88 /* 89 * We must use SOC_MEM_INFO here, because we may redefine the 90 * index_max due to configuration, but the SCHAN msg uses the maximum size. 91 */ 92 #define SOC_L3X_PERR_PBM_POS(unit, mem) \ 93 ((_shr_popcount(SOC_MEM_INFO(unit, mem).index_max) + \ 94 soc_mem_entry_bits(unit, mem)) %32) 95 #endif /* BCM_FIREBOLT_SUPPORT */ 96 97 #ifdef BCM_EASYRIDER_SUPPORT 98 99 #define SOC_ER_L3V6_BUCKET_SIZE 4 100 #define soc_er_l3v4_insert(unit, entry) \ 101 soc_mem_insert((unit), L3_ENTRY_V4m, COPYNO_ALL, (entry)) 102 #define soc_er_l3v6_insert(unit, entry) \ 103 soc_mem_insert((unit), L3_ENTRY_V6m, COPYNO_ALL, (entry)) 104 #define soc_er_l3v4_delete(unit, entry) \ 105 soc_mem_delete((unit), L3_ENTRY_V4m, COPYNO_ALL, (entry)) 106 #define soc_er_l3v6_delete(unit, entry) \ 107 soc_mem_delete((unit), L3_ENTRY_V6m, COPYNO_ALL, (entry)) 108 extern int soc_er_l3v4_lookup(int unit, l3_entry_v4_entry_t *key, 109 l3_entry_v4_entry_t *result, int *index_ptr); 110 extern int soc_er_l3v6_lookup(int unit, l3_entry_v6_entry_t *key, 111 l3_entry_v6_entry_t *result, int *index_ptr); 112 113 #endif /* BCM_EASYRIDER_SUPPORT */ 114 115 #endif /* !_L3X_H_ */