er_tcam.h (9868B)
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 * File: er_tcam_h 7 */ 8 9 #ifndef _SOC_ER_TCAM_H 10 #define _SOC_ER_TCAM_H 11 12 #ifdef BCM_TRIUMPH3_SUPPORT 13 #include <soc/triumph3.h> 14 #endif 15 16 #define TCAM_SIZE_18MB 0x00 17 #define TCAM_REQ_RSP_LATENCY 0x00 18 #define TCAM_BLOCK_ENTRIES 0x800 19 #define MAX_TCAMS 2 20 21 typedef enum soc_tcam_partition_type_e { 22 TCAM_PARTITION_RAW, 23 TCAM_PARTITION_ACL, /* Easyrider */ 24 TCAM_PARTITION_LPM, /* Easyrider */ 25 TCAM_PARTITION_FWD_L2, /* Triumph */ 26 TCAM_PARTITION_FWD_L2_WIDE, /* Triumph3 */ 27 TCAM_PARTITION_FWD_IP4_UCAST,/* Triumph3 */ 28 TCAM_PARTITION_FWD_IP4_UCAST_WIDE, /* Triumph3 */ 29 TCAM_PARTITION_FWD_IP4, /* Triumph */ 30 TCAM_PARTITION_FWD_IP6U, /* Triumph */ 31 TCAM_PARTITION_FWD_IP6_128_UCAST, /* Triumph3 */ 32 TCAM_PARTITION_FWD_IP6_128_UCAST_WIDE, /* Triumph3 */ 33 TCAM_PARTITION_FWD_IP6, /* Triumph */ 34 TCAM_PARTITION_ACL_L2, /* Triumph */ 35 TCAM_PARTITION_ACL_IP4, /* Triumph */ 36 TCAM_PARTITION_ACL_IP6S, /* Triumph */ 37 TCAM_PARTITION_ACL_IP6F, /* Triumph */ 38 TCAM_PARTITION_ACL_L2C, /* Triumph */ 39 TCAM_PARTITION_ACL_IP4C, /* Triumph */ 40 TCAM_PARTITION_ACL_IP6C, /* Triumph */ 41 TCAM_PARTITION_ACL_L2IP4, /* Triumph */ 42 TCAM_PARTITION_ACL_L2IP6, /* Triumph */ 43 TCAM_PARTITION_DEV0_TBL72, /* Triumph */ 44 TCAM_PARTITION_DEV0_TBL144, /* Triumph */ 45 TCAM_PARTITION_DEV1_TBL72, /* Triumph */ 46 TCAM_PARTITION_DEV1_TBL144, /* Triumph */ 47 TCAM_PARTITION_ACL80, /* Triumph3 */ 48 TCAM_PARTITION_ACL160, /* Triumph3 */ 49 TCAM_PARTITION_ACL320, /* Triumph3 */ 50 TCAM_PARTITION_ACL480, /* Triumph3 */ 51 TCAM_PARTITION_FWD_L2_DUP, /* Triumph3 */ 52 TCAM_PARTITION_FWD_IP4_DUP, /* Triumph3 */ 53 TCAM_PARTITION_FWD_IP6U_DUP, /* Triumph3 */ 54 TCAM_PARTITION_FWD_IP6_DUP, /* Triumph3 */ 55 TCAM_PARTITION_COUNT 56 } soc_tcam_partition_type_t; 57 58 #define TCAM_PARTITION_FLAGS_TYPE_L2 0x01 59 #define TCAM_PARTITION_FLAGS_TYPE_L3 0x02 60 #define TCAM_PARTITION_FLAGS_TYPE_ACL 0x03 61 #define TCAM_PARTITION_FLAGS_TYPE_MASK 0x03 62 #define TCAM_PARTITION_FLAGS_AD_IN_SRAM0 0x08 /* forward or policy tbl */ 63 #define TCAM_PARTITION_FLAGS_AD_IN_SRAM1 0x10 /* forward or policy tbl */ 64 #define TCAM_PARTITION_FLAGS_COUNTER_IN_SRAM0 0x20 65 #define TCAM_PARTITION_FLAGS_COUNTER_IN_SRAM1 0x40 66 67 /* 68 * For TR3. If this flag is set, then it indicates multiple partitions should 69 * co-exist in same superblock if necessary. E.g, L2, L2 wide. 70 */ 71 #define TCAM_PARTITION_FLAGS_COALESCE 0x80 72 #define TCAM_PARTITION_FLAGS_NO_AD 0x100 73 74 typedef struct soc_tcam_partition_s { 75 int num_entries; 76 int num_entries_include_pad; 77 int tcam_width_shift; 78 int tcam_base; 79 int sram_width_shift; 80 int sram_base; 81 int counter_base; 82 int hbit_base; 83 uint32 flags; 84 #ifdef BCM_TRIUMPH3_SUPPORT 85 soc_et_pa_xlat_t ad_info; 86 #endif 87 } soc_tcam_partition_t; 88 89 typedef struct soc_tcam_info_s { 90 int subtype; 91 int subtype_override; 92 int num_tcams; 93 int num_tcams_override; 94 int monolith_dev; 95 int mode; 96 int tcam_freq; 97 int sram_freq; 98 int mdio_port_tcam0; /* TR3 tcam mdio port no. */ 99 int mdio_port_tcam1; 100 soc_tcam_partition_t partitions[TCAM_PARTITION_COUNT]; 101 int tcam_init_done[MAX_TCAMS]; 102 int blks_per_dev; 103 } soc_tcam_info_t; 104 105 typedef struct er_tcam_config_s { 106 int tcams; 107 int acl_entries; 108 int lpm_entries; 109 } er_tcam_config_t; 110 111 #ifdef BCM_EASYRIDER_SUPPORT 112 113 extern er_tcam_config_t configs[]; 114 115 extern int er_tcam_init_type1(int u, int ext_table_cfg); 116 extern int er_tcam_init_type2(int u, int ext_table_cfg); 117 extern int soc_er_tcam_type1_read_entry(int u, int cfg, int part, int index, 118 uint32 * mask, uint32 * data, int * valid); 119 extern int soc_er_tcam_type2_read_entry(int u, int cfg, int part, int index, 120 uint32 * mask, uint32 * data, int * valid); 121 extern int soc_er_tcam_type1_write_entry(int u, int cfg, int part, int index, 122 uint32 * mask, uint32 * data); 123 extern int soc_er_tcam_type2_write_entry(int u, int cfg, int part, int index, 124 uint32 * mask, uint32 * data); 125 extern int soc_er_tcam_type1_set_valid(int u, int cfg, int part, int index, 126 int valid); 127 extern int soc_er_tcam_type2_set_valid(int u, int cfg, int part, int index, 128 int valid); 129 extern int soc_er_tcam_type1_search_entry(int u, int cfg, int part, int upper, 130 uint32 *data, int *index); 131 extern int soc_er_tcam_type1_write_ib(int unit, uint32 addr, uint32 data); 132 extern int soc_er_tcam_type1_write_ima(int unit, uint32 addr, 133 uint32 d0_msb, uint32 d1_lsb); 134 extern int soc_er_tcam_type1_read_ima(int unit, uint32 addr, 135 uint32 *d0_msb, uint32 *d1_lsb); 136 extern int soc_er_tcam_type1_write_dbreg(int unit, uint32 addr, 137 uint32 d0_msb, uint32 d1_lsb); 138 extern int soc_er_tcam_type1_read_dbreg(int unit, uint32 addr, 139 uint32 *d0_msb, uint32 *d1_lsb); 140 extern int soc_er_tcam_type2_parity_diagnose(int unit); 141 extern int soc_er_tcam_type1_memtest(int unit, uint32 pattern1, 142 uint32 pattern2); 143 144 #endif 145 146 #ifdef BCM_TRIUMPH_SUPPORT 147 148 #define TCAM_TR_WORDS_PER_ENTRY 3 149 150 enum { 151 TCAM_TR_OP_WRITE = 0, 152 TCAM_TR_OP_SINGLE_SEARCH1 = 1, 153 TCAM_TR_OP_SINGLE_SEARCH0 = 2, 154 TCAM_TR_OP_PARALLEL_SEARCH = 3, 155 TCAM_TR_OP_READ = 4, 156 TCAM_TR_OP_READ_MASK = 5 157 }; 158 159 enum { 160 TCAM_TR3_OP_NOP = 0, 161 TCAM_TR3_OP_WRITE = 1, 162 TCAM_TR3_OP_REG_DB_X_READ = 2, 163 TCAM_TR3_OP_DB_Y_READ = 3, 164 TCAM_TR3_OP_CB_WR_CMP1 = 4, 165 TCAM_TR3_OP_CB_WR_CMP2 = 5, 166 TCAM_TR3_OP_CB_WRITE = 6 167 }; 168 169 extern int tr3_tcam_init(int unit); 170 extern int soc_tr3_tcam_write_entry(int unit, int part, int index, uint32 *mask, 171 uint32 *data, int valid); 172 extern int soc_tr3_tcam_read_entry(int unit, int part, int index, uint32 *mask, 173 uint32 *data, int *valid); 174 extern int soc_tr3_tcam_search_entry(int unit, int part1, int part2, 175 uint32 *data, int *index1, int *index2); 176 extern int soc_tr3_tcam_write_reg(int unit, uint32 addr, uint32 d0_msb, 177 uint32 d1, uint32 d2_lsb); 178 extern int soc_tr3_tcam_read_reg(int unit, uint32 addr, uint32 *d0_msb, 179 uint32 *d1, uint32 *d2_lsb); 180 181 extern int tr_tcam_init_type1(int unit); 182 extern int soc_tr_tcam_type1_write_entry(int unit, int part, int index, 183 uint32 *mask, uint32 *data); 184 extern int soc_tr_tcam_type1_read_entry(int unit, int part, int index, 185 uint32 *mask, uint32 *data, 186 int *valid); 187 extern int soc_tr_tcam_type1_delete_entry(int unit, int part, int index); 188 extern int soc_tr_tcam_type1_search_entry(int unit, int part0, int part1, 189 uint32 *data, int *index0, 190 int *index1); 191 extern int soc_tr_tcam_type1_write_reg(int unit, uint32 addr, uint32 d0_msb, 192 uint32 d1, uint32 d2_lsb); 193 extern int soc_tr_tcam_type1_read_reg(int unit, uint32 addr, uint32 *d0_msb, 194 uint32 *d1, uint32 *d2_lsb); 195 extern int soc_tr_tcam_type1_memtest_dpeo(int unit, int num_entries, 196 uint32 oe_map, uint32 *data); 197 198 199 #endif /* BCM_TRIUMPH_SUPPORT */ 200 201 extern int soc_tcam_init(int unit); 202 extern int soc_tcam_get_info(int unit, int *type, int *subtype, int *dc_val, 203 soc_tcam_info_t **tcam_info); 204 extern int soc_tcam_get_part_size(int unit, soc_tcam_partition_type_t part, 205 int *num_entries, 206 int *num_entries_include_pad); 207 extern int soc_tcam_part_index_to_mem_index(int unit, 208 soc_tcam_partition_type_t part, 209 int part_index, 210 soc_mem_t mem, int *mem_index); 211 extern int soc_tcam_mem_index_to_raw_index(int unit, soc_mem_t mem, 212 int mem_index, soc_mem_t *real_mem, 213 int *raw_index); 214 extern int soc_tcam_raw_index_to_mem_index(int unit, int raw_index, 215 soc_mem_t *mem, int *mem_index); 216 extern int soc_tcam_read_entry(int unit, int part, int index, uint32 *mask, 217 uint32 *data, int *valid); 218 extern int soc_tcam_write_entry(int unit, int part, int index, uint32 *mask, 219 uint32 *data); 220 extern int soc_tcam_set_valid(int unit, int part, int index, int valid); 221 extern int soc_tcam_search_entry(int unit, int part0, int part1, uint32 *data, 222 int *index0, int *index1); 223 extern int soc_tcam_write_ib(int unit, uint32 addr, uint32 data); 224 extern int soc_tcam_write_ima(int unit, uint32 addr, uint32 d0_msb, 225 uint32 d1_lsb); 226 extern int soc_tcam_read_ima(int unit, uint32 addr, uint32 *d0_msb, 227 uint32 *d1_lsb); 228 extern int soc_tcam_write_dbreg(int unit, uint32 addr, uint32 d0_msb, 229 uint32 d1, uint32 d2_lsb); 230 extern int soc_tcam_read_dbreg(int unit, uint32 addr, uint32 *d0_msb, 231 uint32 *d1, uint32 *d2_lsb); 232 #endif /* !_SOC_ER_TCAM_H */