1 /* 2 * SPDX-License-Identifier: BSD-3-Clause 3 * Copyright(c) 2023 Napatech A/S 4 */ 5 6 #ifndef _HW_MOD_BACKEND_H_ 7 #define _HW_MOD_BACKEND_H_ 8 9 #include <stdbool.h> 10 11 #include "ntlog.h" 12 13 #include "hw_mod_cat_v18.h" 14 #include "hw_mod_cat_v21.h" 15 #include "hw_mod_flm_v25.h" 16 #include "hw_mod_km_v7.h" 17 #include "hw_mod_qsl_v7.h" 18 #include "hw_mod_pdb_v9.h" 19 #include "hw_mod_slc_lr_v2.h" 20 #include "hw_mod_hsh_v5.h" 21 #include "hw_mod_tpe_v3.h" 22 23 #define MAX_PHYS_ADAPTERS 8 24 25 #define VER_MAJOR(ver) (((ver) >> 16) & 0xffff) 26 #define VER_MINOR(ver) ((ver) & 0xffff) 27 28 struct flow_api_backend_s; 29 struct common_func_s; 30 31 void *callocate_mod(struct common_func_s *mod, int sets, ...); 32 void zero_module_cache(struct common_func_s *mod); 33 34 #define ALL_ENTRIES -1000 35 #define ALL_BANK_ENTRIES -1001 36 37 #define INDEX_TOO_LARGE (-2) 38 #define INDEX_TOO_LARGE_LOG NT_LOG(INF, FILTER, "ERROR:%s: Index too large", __func__) 39 40 #define WORD_OFF_TOO_LARGE (-3) 41 #define WORD_OFF_TOO_LARGE_LOG NT_LOG(INF, FILTER, "ERROR:%s: Word offset too large", __func__) 42 43 #define UNSUP_FIELD (-5) 44 #define UNSUP_FIELD_LOG \ 45 NT_LOG(INF, FILTER, "ERROR:%s: Unsupported field in NIC module", __func__) 46 47 #define UNSUP_VER (-4) 48 #define UNSUP_VER_LOG \ 49 NT_LOG(INF, FILTER, "ERROR:%s: Unsupported NIC module: %s ver %i.%i", __func__, _MOD_, \ 50 VER_MAJOR(_VER_), VER_MINOR(_VER_)) 51 52 #define COUNT_ERROR (-4) 53 #define COUNT_ERROR_LOG(_RESOURCE_) \ 54 NT_LOG(INF, FILTER, \ 55 "ERROR:%s: Insufficient resource [ %s ] : NIC module: %s ver %i.%i", __func__, \ 56 #_RESOURCE_, _MOD_, VER_MAJOR(_VER_), VER_MINOR(_VER_)) \ 57 58 #define NOT_FOUND 0xffffffff 59 60 enum { 61 EXTRA_INDEXES 62 }; 63 64 #define GET(cached_val, val) ({ *(val) = *(cached_val); }) 65 66 #define SET(cached_val, val) ({ *(cached_val) = *(val); }) 67 68 #define GET_SET(cached_val, val) \ 69 do { \ 70 uint32_t *temp_val = (val); \ 71 typeof(cached_val) *temp_cached_val = &(cached_val); \ 72 if (get) \ 73 GET(temp_cached_val, temp_val); \ 74 else \ 75 SET(temp_cached_val, temp_val); \ 76 } while (0) 77 78 #define GET_SIGNED(cached_val, val) ({ *(val) = (uint32_t)(*(cached_val)); }) 79 80 #define SET_SIGNED(cached_val, val) ({ *(cached_val) = (int32_t)(*(val)); }) 81 82 #define GET_SET_SIGNED(cached_val, val) \ 83 do { \ 84 uint32_t *temp_val = (val); \ 85 typeof(cached_val) *temp_cached_val = &(cached_val); \ 86 if (get) \ 87 GET_SIGNED(temp_cached_val, temp_val); \ 88 else \ 89 SET_SIGNED(temp_cached_val, temp_val); \ 90 } while (0) 91 92 #define FIND_EQUAL_INDEX(be_module_reg, type, idx, start, nb_elements) \ 93 do { \ 94 typeof(be_module_reg) *temp_be_module = \ 95 (typeof(be_module_reg) *)be_module_reg; \ 96 typeof(idx) tmp_idx = (idx); \ 97 typeof(nb_elements) tmp_nb_elements = (nb_elements); \ 98 unsigned int start_idx = (unsigned int)(start); \ 99 *value = NOT_FOUND; \ 100 for (unsigned int i = start_idx; i < tmp_nb_elements; i++) { \ 101 if ((unsigned int)(tmp_idx) == i) \ 102 continue; \ 103 if (memcmp(&temp_be_module[tmp_idx], &temp_be_module[i], sizeof(type)) == \ 104 0) { \ 105 *value = i; \ 106 break; \ 107 } \ 108 } \ 109 } while (0) 110 111 #define DO_COMPARE_INDEXS(be_module_reg, type, idx, cmp_idx) \ 112 do { \ 113 typeof(be_module_reg) *temp_be_module = &(be_module_reg); \ 114 typeof(idx) tmp_idx = (idx); \ 115 typeof(cmp_idx) tmp_cmp_idx = (cmp_idx); \ 116 if ((unsigned int)(tmp_idx) != (unsigned int)(tmp_cmp_idx)) { \ 117 (void)memcmp(temp_be_module + tmp_idx, &temp_be_module[tmp_cmp_idx], \ 118 sizeof(type)); \ 119 } \ 120 } while (0) 121 122 enum km_flm_if_select_e { 123 KM_FLM_IF_FIRST = 0, 124 KM_FLM_IF_SECOND = 1 125 }; 126 127 #define FIELD_START_INDEX 100 128 129 #define COMMON_FUNC_INFO_S \ 130 int ver; \ 131 void *base; \ 132 unsigned int alloced_size; \ 133 int debug 134 135 struct common_func_s { 136 COMMON_FUNC_INFO_S; 137 }; 138 139 struct cat_func_s { 140 COMMON_FUNC_INFO_S; 141 uint32_t nb_cat_funcs; 142 uint32_t nb_flow_types; 143 uint32_t nb_pm_ext; 144 uint32_t nb_len; 145 uint32_t kcc_size; 146 uint32_t cts_num; 147 uint32_t kcc_banks; 148 uint32_t kcc_id_bit_size; 149 uint32_t kcc_records; 150 uint32_t km_if_count; 151 int32_t km_if_m0; 152 int32_t km_if_m1; 153 154 union { 155 struct hw_mod_cat_v18_s v18; 156 struct hw_mod_cat_v21_s v21; 157 }; 158 }; 159 enum hw_cat_e { 160 /* 161 * functions initial CAT v18 162 */ 163 /* 00 */ HW_CAT_CFN_SET_ALL_DEFAULTS = 0, 164 /* 01 */ HW_CAT_CFN_PRESET_ALL, 165 /* 02 */ HW_CAT_CFN_COMPARE, 166 /* 03 */ HW_CAT_CFN_FIND, 167 /* 04 */ HW_CAT_CFN_COPY_FROM, 168 /* 05 */ HW_CAT_COT_PRESET_ALL, 169 /* 06 */ HW_CAT_COT_COMPARE, 170 /* 07 */ HW_CAT_COT_FIND, 171 /* 08 */ HW_CAT_COT_COPY_FROM, 172 /* fields */ 173 /* 00 */ HW_CAT_CFN_ENABLE = FIELD_START_INDEX, 174 /* 01 */ HW_CAT_CFN_INV, 175 /* 02 */ HW_CAT_CFN_PTC_INV, 176 /* 03 */ HW_CAT_CFN_PTC_ISL, 177 /* 04 */ HW_CAT_CFN_PTC_CFP, 178 /* 05 */ HW_CAT_CFN_PTC_MAC, 179 /* 06 */ HW_CAT_CFN_PTC_L2, 180 /* 07 */ HW_CAT_CFN_PTC_VNTAG, 181 /* 08 */ HW_CAT_CFN_PTC_VLAN, 182 /* 09 */ HW_CAT_CFN_PTC_MPLS, 183 /* 10 */ HW_CAT_CFN_PTC_L3, 184 /* 11 */ HW_CAT_CFN_PTC_FRAG, 185 /* 12 */ HW_CAT_CFN_PTC_IP_PROT, 186 /* 13 */ HW_CAT_CFN_PTC_L4, 187 /* 14 */ HW_CAT_CFN_PTC_TUNNEL, 188 /* 15 */ HW_CAT_CFN_PTC_TNL_L2, 189 /* 16 */ HW_CAT_CFN_PTC_TNL_VLAN, 190 /* 17 */ HW_CAT_CFN_PTC_TNL_MPLS, 191 /* 18 */ HW_CAT_CFN_PTC_TNL_L3, 192 /* 19 */ HW_CAT_CFN_PTC_TNL_FRAG, 193 /* 20 */ HW_CAT_CFN_PTC_TNL_IP_PROT, 194 /* 21 */ HW_CAT_CFN_PTC_TNL_L4, 195 /* 22 */ HW_CAT_CFN_ERR_INV, 196 /* 23 */ HW_CAT_CFN_ERR_CV, 197 /* 24 */ HW_CAT_CFN_ERR_FCS, 198 /* 25 */ HW_CAT_CFN_ERR_TRUNC, 199 /* 26 */ HW_CAT_CFN_ERR_L3_CS, 200 /* 27 */ HW_CAT_CFN_ERR_L4_CS, 201 /* 28 */ HW_CAT_CFN_MAC_PORT, 202 /* 29 */ HW_CAT_CFN_PM_CMP, 203 /* 30 */ HW_CAT_CFN_PM_DCT, 204 /* 31 */ HW_CAT_CFN_PM_EXT_INV, 205 /* 32 */ HW_CAT_CFN_PM_CMB, 206 /* 33 */ HW_CAT_CFN_PM_AND_INV, 207 /* 34 */ HW_CAT_CFN_PM_OR_INV, 208 /* 35 */ HW_CAT_CFN_PM_INV, 209 /* 36 */ HW_CAT_CFN_LC, 210 /* 37 */ HW_CAT_CFN_LC_INV, 211 /* 38 */ HW_CAT_CFN_KM0_OR, 212 /* 39 */ HW_CAT_CFN_KM1_OR, 213 /* 40 */ HW_CAT_KCE_ENABLE_BM, 214 /* 41 */ HW_CAT_KCS_CATEGORY, 215 /* 42 */ HW_CAT_FTE_ENABLE_BM, 216 /* 43 */ HW_CAT_CTE_ENABLE_BM, 217 /* 44 */ HW_CAT_CTS_CAT_A, 218 /* 45 */ HW_CAT_CTS_CAT_B, 219 /* 46 */ HW_CAT_COT_COLOR, 220 /* 47 */ HW_CAT_COT_KM, 221 /* 48 */ HW_CAT_CCT_COLOR, 222 /* 49 */ HW_CAT_CCT_KM, 223 /* 50 */ HW_CAT_KCC_KEY, 224 /* 51 */ HW_CAT_KCC_CATEGORY, 225 /* 52 */ HW_CAT_KCC_ID, 226 /* 53 */ HW_CAT_EXO_DYN, 227 /* 54 */ HW_CAT_EXO_OFS, 228 /* 55 */ HW_CAT_RCK_DATA, 229 /* 56 */ HW_CAT_LEN_LOWER, 230 /* 57 */ HW_CAT_LEN_UPPER, 231 /* 58 */ HW_CAT_LEN_DYN1, 232 /* 59 */ HW_CAT_LEN_DYN2, 233 /* 60 */ HW_CAT_LEN_INV, 234 /* 61 */ HW_CAT_CFN_ERR_TNL_L3_CS, 235 /* 62 */ HW_CAT_CFN_ERR_TNL_L4_CS, 236 /* 63 */ HW_CAT_CFN_ERR_TTL_EXP, 237 /* 64 */ HW_CAT_CFN_ERR_TNL_TTL_EXP, 238 }; 239 240 bool hw_mod_cat_present(struct flow_api_backend_s *be); 241 int hw_mod_cat_alloc(struct flow_api_backend_s *be); 242 void hw_mod_cat_free(struct flow_api_backend_s *be); 243 int hw_mod_cat_reset(struct flow_api_backend_s *be); 244 int hw_mod_cat_cfn_flush(struct flow_api_backend_s *be, int start_idx, int count); 245 int hw_mod_cat_cfn_set(struct flow_api_backend_s *be, enum hw_cat_e field, int index, int word_off, 246 uint32_t value); 247 248 int hw_mod_cat_cte_flush(struct flow_api_backend_s *be, int start_idx, int count); 249 int hw_mod_cat_cts_flush(struct flow_api_backend_s *be, int start_idx, int count); 250 int hw_mod_cat_cot_flush(struct flow_api_backend_s *be, int start_idx, int count); 251 int hw_mod_cat_cct_flush(struct flow_api_backend_s *be, int start_idx, int count); 252 int hw_mod_cat_kcc_flush(struct flow_api_backend_s *be, int start_idx, int count); 253 254 int hw_mod_cat_exo_flush(struct flow_api_backend_s *be, int start_idx, int count); 255 int hw_mod_cat_rck_flush(struct flow_api_backend_s *be, int start_idx, int count); 256 int hw_mod_cat_len_flush(struct flow_api_backend_s *be, int start_idx, int count); 257 258 struct km_func_s { 259 COMMON_FUNC_INFO_S; 260 uint32_t nb_categories; 261 uint32_t nb_cam_banks; 262 uint32_t nb_cam_record_words; 263 uint32_t nb_cam_records; 264 uint32_t nb_tcam_banks; 265 uint32_t nb_tcam_bank_width; 266 /* not read from backend, but rather set using version */ 267 uint32_t nb_km_rcp_mask_a_word_size; 268 /* --- || --- */ 269 uint32_t nb_km_rcp_mask_b_word_size; 270 union { 271 struct hw_mod_km_v7_s v7; 272 }; 273 }; 274 enum hw_km_e { 275 /* functions */ 276 HW_KM_RCP_PRESET_ALL = 0, 277 HW_KM_CAM_PRESET_ALL, 278 /* to sync and reset hw with cache - force write all entries in a bank */ 279 HW_KM_TCAM_BANK_RESET, 280 /* fields */ 281 HW_KM_RCP_QW0_DYN = FIELD_START_INDEX, 282 HW_KM_RCP_QW0_OFS, 283 HW_KM_RCP_QW0_SEL_A, 284 HW_KM_RCP_QW0_SEL_B, 285 HW_KM_RCP_QW4_DYN, 286 HW_KM_RCP_QW4_OFS, 287 HW_KM_RCP_QW4_SEL_A, 288 HW_KM_RCP_QW4_SEL_B, 289 HW_KM_RCP_DW8_DYN, 290 HW_KM_RCP_DW8_OFS, 291 HW_KM_RCP_DW8_SEL_A, 292 HW_KM_RCP_DW8_SEL_B, 293 HW_KM_RCP_DW10_DYN, 294 HW_KM_RCP_DW10_OFS, 295 HW_KM_RCP_DW10_SEL_A, 296 HW_KM_RCP_DW10_SEL_B, 297 HW_KM_RCP_SWX_CCH, 298 HW_KM_RCP_SWX_SEL_A, 299 HW_KM_RCP_SWX_SEL_B, 300 HW_KM_RCP_MASK_A, 301 HW_KM_RCP_MASK_B, 302 HW_KM_RCP_DUAL, 303 HW_KM_RCP_PAIRED, 304 HW_KM_RCP_EL_A, 305 HW_KM_RCP_EL_B, 306 HW_KM_RCP_INFO_A, 307 HW_KM_RCP_INFO_B, 308 HW_KM_RCP_FTM_A, 309 HW_KM_RCP_FTM_B, 310 HW_KM_RCP_BANK_A, 311 HW_KM_RCP_BANK_B, 312 HW_KM_RCP_KL_A, 313 HW_KM_RCP_KL_B, 314 HW_KM_RCP_KEYWAY_A, 315 HW_KM_RCP_KEYWAY_B, 316 HW_KM_RCP_SYNERGY_MODE, 317 HW_KM_RCP_DW0_B_DYN, 318 HW_KM_RCP_DW0_B_OFS, 319 HW_KM_RCP_DW2_B_DYN, 320 HW_KM_RCP_DW2_B_OFS, 321 HW_KM_RCP_SW4_B_DYN, 322 HW_KM_RCP_SW4_B_OFS, 323 HW_KM_RCP_SW5_B_DYN, 324 HW_KM_RCP_SW5_B_OFS, 325 HW_KM_CAM_W0, 326 HW_KM_CAM_W1, 327 HW_KM_CAM_W2, 328 HW_KM_CAM_W3, 329 HW_KM_CAM_W4, 330 HW_KM_CAM_W5, 331 HW_KM_CAM_FT0, 332 HW_KM_CAM_FT1, 333 HW_KM_CAM_FT2, 334 HW_KM_CAM_FT3, 335 HW_KM_CAM_FT4, 336 HW_KM_CAM_FT5, 337 HW_KM_TCAM_T, 338 HW_KM_TCI_COLOR, 339 HW_KM_TCI_FT, 340 HW_KM_TCQ_BANK_MASK, 341 HW_KM_TCQ_QUAL 342 }; 343 bool hw_mod_km_present(struct flow_api_backend_s *be); 344 int hw_mod_km_alloc(struct flow_api_backend_s *be); 345 void hw_mod_km_free(struct flow_api_backend_s *be); 346 int hw_mod_km_reset(struct flow_api_backend_s *be); 347 int hw_mod_km_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); 348 int hw_mod_km_cam_flush(struct flow_api_backend_s *be, int start_bank, int start_record, 349 int count); 350 int hw_mod_km_tcam_flush(struct flow_api_backend_s *be, int start_bank, int count); 351 int hw_mod_km_tcam_set(struct flow_api_backend_s *be, enum hw_km_e field, int bank, int byte, 352 int byte_val, uint32_t *value_set); 353 int hw_mod_km_tci_flush(struct flow_api_backend_s *be, int start_bank, int start_record, 354 int count); 355 int hw_mod_km_tcq_flush(struct flow_api_backend_s *be, int start_bank, int start_record, 356 int count); 357 358 struct flm_func_s { 359 COMMON_FUNC_INFO_S; 360 uint32_t nb_categories; 361 uint32_t nb_size_mb; 362 uint32_t nb_entry_size; 363 uint32_t nb_variant; 364 uint32_t nb_prios; 365 uint32_t nb_pst_profiles; 366 uint32_t nb_scrub_profiles; 367 uint32_t nb_rpp_clock_in_ps; 368 uint32_t nb_load_aps_max; 369 union { 370 struct hw_mod_flm_v25_s v25; 371 }; 372 }; 373 enum hw_flm_e { 374 /* functions */ 375 HW_FLM_CONTROL_PRESET_ALL = 0, 376 HW_FLM_RCP_PRESET_ALL, 377 HW_FLM_FLOW_LRN_DATA, 378 HW_FLM_FLOW_INF_STA_DATA, 379 /* Control fields */ 380 HW_FLM_CONTROL_ENABLE = FIELD_START_INDEX, 381 HW_FLM_CONTROL_INIT, 382 HW_FLM_CONTROL_LDS, 383 HW_FLM_CONTROL_LFS, 384 HW_FLM_CONTROL_LIS, 385 HW_FLM_CONTROL_UDS, 386 HW_FLM_CONTROL_UIS, 387 HW_FLM_CONTROL_RDS, 388 HW_FLM_CONTROL_RIS, 389 HW_FLM_CONTROL_PDS, 390 HW_FLM_CONTROL_PIS, 391 HW_FLM_CONTROL_CRCWR, 392 HW_FLM_CONTROL_CRCRD, 393 HW_FLM_CONTROL_RBL, 394 HW_FLM_CONTROL_EAB, 395 HW_FLM_CONTROL_SPLIT_SDRAM_USAGE, 396 HW_FLM_STATUS_CALIB_SUCCESS, 397 HW_FLM_STATUS_CALIB_FAIL, 398 HW_FLM_STATUS_INITDONE, 399 HW_FLM_STATUS_IDLE, 400 HW_FLM_STATUS_CRITICAL, 401 HW_FLM_STATUS_PANIC, 402 HW_FLM_STATUS_CRCERR, 403 HW_FLM_STATUS_EFT_BP, 404 HW_FLM_STATUS_CACHE_BUFFER_CRITICAL, 405 HW_FLM_LOAD_BIN, 406 HW_FLM_LOAD_LPS, 407 HW_FLM_LOAD_APS, 408 HW_FLM_PRIO_LIMIT0, 409 HW_FLM_PRIO_FT0, 410 HW_FLM_PRIO_LIMIT1, 411 HW_FLM_PRIO_FT1, 412 HW_FLM_PRIO_LIMIT2, 413 HW_FLM_PRIO_FT2, 414 HW_FLM_PRIO_LIMIT3, 415 HW_FLM_PRIO_FT3, 416 HW_FLM_PST_PRESET_ALL, 417 HW_FLM_PST_BP, 418 HW_FLM_PST_PP, 419 HW_FLM_PST_TP, 420 HW_FLM_RCP_LOOKUP, 421 HW_FLM_RCP_QW0_DYN, 422 HW_FLM_RCP_QW0_OFS, 423 HW_FLM_RCP_QW0_SEL, 424 HW_FLM_RCP_QW4_DYN, 425 HW_FLM_RCP_QW4_OFS, 426 HW_FLM_RCP_SW8_DYN, 427 HW_FLM_RCP_SW8_OFS, 428 HW_FLM_RCP_SW8_SEL, 429 HW_FLM_RCP_SW9_DYN, 430 HW_FLM_RCP_SW9_OFS, 431 HW_FLM_RCP_MASK, 432 HW_FLM_RCP_KID, 433 HW_FLM_RCP_OPN, 434 HW_FLM_RCP_IPN, 435 HW_FLM_RCP_BYT_DYN, 436 HW_FLM_RCP_BYT_OFS, 437 HW_FLM_RCP_TXPLM, 438 HW_FLM_RCP_AUTO_IPV4_MASK, 439 HW_FLM_BUF_CTRL_LRN_FREE, 440 HW_FLM_BUF_CTRL_INF_AVAIL, 441 HW_FLM_BUF_CTRL_STA_AVAIL, 442 HW_FLM_STAT_LRN_DONE, 443 HW_FLM_STAT_LRN_IGNORE, 444 HW_FLM_STAT_LRN_FAIL, 445 HW_FLM_STAT_UNL_DONE, 446 HW_FLM_STAT_UNL_IGNORE, 447 HW_FLM_STAT_REL_DONE, 448 HW_FLM_STAT_REL_IGNORE, 449 HW_FLM_STAT_PRB_DONE, 450 HW_FLM_STAT_PRB_IGNORE, 451 HW_FLM_STAT_AUL_DONE, 452 HW_FLM_STAT_AUL_IGNORE, 453 HW_FLM_STAT_AUL_FAIL, 454 HW_FLM_STAT_TUL_DONE, 455 HW_FLM_STAT_FLOWS, 456 HW_FLM_STAT_STA_DONE, /* module ver 0.20 */ 457 HW_FLM_STAT_INF_DONE, /* module ver 0.20 */ 458 HW_FLM_STAT_INF_SKIP, /* module ver 0.20 */ 459 HW_FLM_STAT_PCK_HIT, /* module ver 0.20 */ 460 HW_FLM_STAT_PCK_MISS, /* module ver 0.20 */ 461 HW_FLM_STAT_PCK_UNH, /* module ver 0.20 */ 462 HW_FLM_STAT_PCK_DIS, /* module ver 0.20 */ 463 HW_FLM_STAT_CSH_HIT, /* module ver 0.20 */ 464 HW_FLM_STAT_CSH_MISS, /* module ver 0.20 */ 465 HW_FLM_STAT_CSH_UNH, /* module ver 0.20 */ 466 HW_FLM_STAT_CUC_START, /* module ver 0.20 */ 467 HW_FLM_STAT_CUC_MOVE, /* module ver 0.20 */ 468 HW_FLM_SCAN_I, /* module ver 0.22 */ 469 HW_FLM_SCRUB_PRESET_ALL, 470 HW_FLM_SCRUB_T, /* module ver 0.22 */ 471 HW_FLM_SCRUB_R, /* module ver 0.24 */ 472 HW_FLM_SCRUB_DEL, /* module ver 0.24 */ 473 HW_FLM_SCRUB_INF, /* module ver 0.24 */ 474 }; 475 476 bool hw_mod_flm_present(struct flow_api_backend_s *be); 477 int hw_mod_flm_alloc(struct flow_api_backend_s *be); 478 void hw_mod_flm_free(struct flow_api_backend_s *be); 479 int hw_mod_flm_reset(struct flow_api_backend_s *be); 480 481 int hw_mod_flm_control_flush(struct flow_api_backend_s *be); 482 int hw_mod_flm_control_set(struct flow_api_backend_s *be, enum hw_flm_e field, uint32_t value); 483 484 int hw_mod_flm_scan_flush(struct flow_api_backend_s *be); 485 486 int hw_mod_flm_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); 487 488 int hw_mod_flm_scrub_flush(struct flow_api_backend_s *be, int start_idx, int count); 489 490 struct hsh_func_s { 491 COMMON_FUNC_INFO_S; 492 uint32_t nb_rcp;/* number of HSH recipes supported by FPGA */ 493 /* indication if Toeplitz is supported by FPGA, i.e. 0 - unsupported, 1 - supported */ 494 uint32_t toeplitz; 495 union { 496 struct hw_mod_hsh_v5_s v5; 497 }; 498 }; 499 enum hw_hsh_e { 500 /* functions */ 501 HW_HSH_RCP_PRESET_ALL = 0, 502 HW_HSH_RCP_COMPARE, 503 HW_HSH_RCP_FIND, 504 /* fields */ 505 HW_HSH_RCP_LOAD_DIST_TYPE = FIELD_START_INDEX, 506 HW_HSH_RCP_MAC_PORT_MASK, 507 HW_HSH_RCP_SORT, 508 HW_HSH_RCP_QW0_PE, 509 HW_HSH_RCP_QW0_OFS, 510 HW_HSH_RCP_QW4_PE, 511 HW_HSH_RCP_QW4_OFS, 512 HW_HSH_RCP_W8_PE, 513 HW_HSH_RCP_W8_OFS, 514 HW_HSH_RCP_W8_SORT, 515 HW_HSH_RCP_W9_PE, 516 HW_HSH_RCP_W9_OFS, 517 HW_HSH_RCP_W9_SORT, 518 HW_HSH_RCP_W9_P, 519 HW_HSH_RCP_P_MASK, 520 HW_HSH_RCP_WORD_MASK, 521 HW_HSH_RCP_SEED, 522 HW_HSH_RCP_TNL_P, 523 HW_HSH_RCP_HSH_VALID, 524 HW_HSH_RCP_HSH_TYPE, 525 HW_HSH_RCP_TOEPLITZ, 526 HW_HSH_RCP_K, 527 HW_HSH_RCP_AUTO_IPV4_MASK 528 }; 529 bool hw_mod_hsh_present(struct flow_api_backend_s *be); 530 int hw_mod_hsh_alloc(struct flow_api_backend_s *be); 531 void hw_mod_hsh_free(struct flow_api_backend_s *be); 532 int hw_mod_hsh_reset(struct flow_api_backend_s *be); 533 int hw_mod_hsh_rcp_flush(struct flow_api_backend_s *be, int start_idx, int count); 534 535 struct qsl_func_s { 536 COMMON_FUNC_INFO_S; 537 uint32_t nb_rcp_categories; 538 uint32_t nb_qst_entries; 539 union { 540 struct hw_mod_qsl_v7_s v7; 541 }; 542 }; 543 544 struct slc_lr_func_s { 545 COMMON_FUNC_INFO_S; 546 union { 547 struct hw_mod_slc_lr_v2_s v2; 548 }; 549 }; 550 551 struct pdb_func_s { 552 COMMON_FUNC_INFO_S; 553 uint32_t nb_pdb_rcp_categories; 554 555 union { 556 struct hw_mod_pdb_v9_s v9; 557 }; 558 }; 559 560 struct tpe_func_s { 561 COMMON_FUNC_INFO_S; 562 uint32_t nb_rcp_categories; 563 uint32_t nb_ifr_categories; 564 uint32_t nb_cpy_writers; 565 uint32_t nb_rpl_depth; 566 uint32_t nb_rpl_ext_categories; 567 union { 568 struct hw_mod_tpe_v3_s v3; 569 }; 570 }; 571 572 enum debug_mode_e { 573 FLOW_BACKEND_DEBUG_MODE_NONE = 0x0000, 574 FLOW_BACKEND_DEBUG_MODE_WRITE = 0x0001 575 }; 576 577 struct flow_api_backend_ops { 578 int version; 579 int (*set_debug_mode)(void *dev, enum debug_mode_e mode); 580 int (*get_nb_phy_port)(void *dev); 581 int (*get_nb_rx_port)(void *dev); 582 int (*get_ltx_avail)(void *dev); 583 int (*get_nb_cat_funcs)(void *dev); 584 int (*get_nb_categories)(void *dev); 585 int (*get_nb_cat_km_if_cnt)(void *dev); 586 int (*get_nb_cat_km_if_m0)(void *dev); 587 int (*get_nb_cat_km_if_m1)(void *dev); 588 589 int (*get_nb_queues)(void *dev); 590 int (*get_nb_km_flow_types)(void *dev); 591 int (*get_nb_pm_ext)(void *dev); 592 int (*get_nb_len)(void *dev); 593 int (*get_kcc_size)(void *dev); 594 int (*get_kcc_banks)(void *dev); 595 int (*get_nb_km_categories)(void *dev); 596 int (*get_nb_km_cam_banks)(void *dev); 597 int (*get_nb_km_cam_record_words)(void *dev); 598 int (*get_nb_km_cam_records)(void *dev); 599 int (*get_nb_km_tcam_banks)(void *dev); 600 int (*get_nb_km_tcam_bank_width)(void *dev); 601 int (*get_nb_flm_categories)(void *dev); 602 int (*get_nb_flm_size_mb)(void *dev); 603 int (*get_nb_flm_entry_size)(void *dev); 604 int (*get_nb_flm_variant)(void *dev); 605 int (*get_nb_flm_prios)(void *dev); 606 int (*get_nb_flm_pst_profiles)(void *dev); 607 int (*get_nb_flm_scrub_profiles)(void *dev); 608 int (*get_nb_flm_load_aps_max)(void *dev); 609 int (*get_nb_qsl_categories)(void *dev); 610 int (*get_nb_qsl_qst_entries)(void *dev); 611 int (*get_nb_pdb_categories)(void *dev); 612 int (*get_nb_roa_categories)(void *dev); 613 int (*get_nb_tpe_categories)(void *dev); 614 int (*get_nb_tx_cpy_writers)(void *dev); 615 int (*get_nb_tx_cpy_mask_mem)(void *dev); 616 int (*get_nb_tx_rpl_depth)(void *dev); 617 int (*get_nb_tx_rpl_ext_categories)(void *dev); 618 int (*get_nb_tpe_ifr_categories)(void *dev); 619 int (*get_nb_rpp_per_ps)(void *dev); 620 int (*get_nb_hsh_categories)(void *dev); 621 int (*get_nb_hsh_toeplitz)(void *dev); 622 623 int (*alloc_rx_queue)(void *dev, int queue_id); 624 int (*free_rx_queue)(void *dev, int hw_queue); 625 626 /* CAT */ 627 bool (*get_cat_present)(void *dev); 628 uint32_t (*get_cat_version)(void *dev); 629 int (*cat_cfn_flush)(void *dev, const struct cat_func_s *cat, int cat_func, int cnt); 630 int (*cat_kce_flush)(void *dev, const struct cat_func_s *cat, int km_if_idx, int index, 631 int cnt); 632 int (*cat_kcs_flush)(void *dev, const struct cat_func_s *cat, int km_if_idx, int cat_func, 633 int cnt); 634 int (*cat_fte_flush)(void *dev, const struct cat_func_s *cat, int km_if_idx, int index, 635 int cnt); 636 int (*cat_cte_flush)(void *dev, const struct cat_func_s *cat, int cat_func, int cnt); 637 int (*cat_cts_flush)(void *dev, const struct cat_func_s *cat, int index, int cnt); 638 int (*cat_cot_flush)(void *dev, const struct cat_func_s *cat, int cat_func, int cnt); 639 int (*cat_cct_flush)(void *dev, const struct cat_func_s *cat, int index, int cnt); 640 int (*cat_exo_flush)(void *dev, const struct cat_func_s *cat, int index, int cnt); 641 int (*cat_rck_flush)(void *dev, const struct cat_func_s *cat, int index, int cnt); 642 int (*cat_len_flush)(void *dev, const struct cat_func_s *cat, int index, int cnt); 643 int (*cat_kcc_flush)(void *dev, const struct cat_func_s *cat, int index, int cnt); 644 645 /* KM */ 646 bool (*get_km_present)(void *dev); 647 uint32_t (*get_km_version)(void *dev); 648 int (*km_rcp_flush)(void *dev, const struct km_func_s *km, int category, int cnt); 649 int (*km_cam_flush)(void *dev, const struct km_func_s *km, int bank, int record, int cnt); 650 int (*km_tcam_flush)(void *dev, const struct km_func_s *km, int bank, int byte, int value, 651 int cnt); 652 int (*km_tci_flush)(void *dev, const struct km_func_s *km, int bank, int record, int cnt); 653 int (*km_tcq_flush)(void *dev, const struct km_func_s *km, int bank, int record, int cnt); 654 655 /* FLM */ 656 bool (*get_flm_present)(void *dev); 657 uint32_t (*get_flm_version)(void *dev); 658 int (*flm_control_flush)(void *dev, const struct flm_func_s *flm); 659 int (*flm_status_flush)(void *dev, const struct flm_func_s *flm); 660 int (*flm_status_update)(void *dev, const struct flm_func_s *flm); 661 int (*flm_scan_flush)(void *dev, const struct flm_func_s *flm); 662 int (*flm_load_bin_flush)(void *dev, const struct flm_func_s *flm); 663 int (*flm_prio_flush)(void *dev, const struct flm_func_s *flm); 664 int (*flm_pst_flush)(void *dev, const struct flm_func_s *flm, int index, int cnt); 665 int (*flm_rcp_flush)(void *dev, const struct flm_func_s *flm, int index, int cnt); 666 int (*flm_scrub_flush)(void *dev, const struct flm_func_s *flm, int index, int cnt); 667 int (*flm_buf_ctrl_update)(void *dev, const struct flm_func_s *flm); 668 int (*flm_stat_update)(void *dev, const struct flm_func_s *flm); 669 int (*flm_lrn_data_flush)(void *be_dev, const struct flm_func_s *flm, 670 const uint32_t *lrn_data, uint32_t records, 671 uint32_t *handled_records, uint32_t words_per_record, 672 uint32_t *inf_word_cnt, uint32_t *sta_word_cnt); 673 int (*flm_inf_sta_data_update)(void *be_dev, const struct flm_func_s *flm, 674 uint32_t *inf_data, uint32_t inf_size, 675 uint32_t *inf_word_cnt, uint32_t *sta_data, 676 uint32_t sta_size, uint32_t *sta_word_cnt); 677 678 /* HSH */ 679 bool (*get_hsh_present)(void *dev); 680 uint32_t (*get_hsh_version)(void *dev); 681 int (*hsh_rcp_flush)(void *dev, const struct hsh_func_s *hsh, int category, int cnt); 682 683 /* QSL */ 684 bool (*get_qsl_present)(void *dev); 685 uint32_t (*get_qsl_version)(void *dev); 686 int (*qsl_rcp_flush)(void *dev, const struct qsl_func_s *qsl, int category, int cnt); 687 int (*qsl_qst_flush)(void *dev, const struct qsl_func_s *qsl, int entry, int cnt); 688 int (*qsl_qen_flush)(void *dev, const struct qsl_func_s *qsl, int entry, int cnt); 689 int (*qsl_unmq_flush)(void *dev, const struct qsl_func_s *qsl, int entry, int cnt); 690 691 /* SLC LR */ 692 bool (*get_slc_lr_present)(void *dev); 693 uint32_t (*get_slc_lr_version)(void *dev); 694 int (*slc_lr_rcp_flush)(void *dev, const struct slc_lr_func_s *slc_lr, int category, 695 int cnt); 696 697 /* PDB */ 698 bool (*get_pdb_present)(void *dev); 699 uint32_t (*get_pdb_version)(void *dev); 700 int (*pdb_rcp_flush)(void *dev, const struct pdb_func_s *pdb, int category, int cnt); 701 int (*pdb_config_flush)(void *dev, const struct pdb_func_s *pdb); 702 703 /* TPE */ 704 bool (*get_tpe_present)(void *dev); 705 uint32_t (*get_tpe_version)(void *dev); 706 int (*tpe_rpp_rcp_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 707 int (*tpe_rpp_ifr_rcp_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 708 int (*tpe_ifr_rcp_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 709 int (*tpe_ins_rcp_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 710 int (*tpe_rpl_rcp_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 711 int (*tpe_rpl_ext_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 712 int (*tpe_rpl_rpl_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 713 int (*tpe_cpy_rcp_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 714 int (*tpe_hfu_rcp_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 715 int (*tpe_csu_rcp_flush)(void *dev, const struct tpe_func_s *tpe, int index, int cnt); 716 }; 717 718 struct flow_api_backend_s { 719 void *be_dev; 720 const struct flow_api_backend_ops *iface; 721 722 /* flow filter FPGA modules */ 723 struct cat_func_s cat; 724 struct km_func_s km; 725 struct flm_func_s flm; 726 struct hsh_func_s hsh; 727 728 /* NIC attributes */ 729 unsigned int num_phy_ports; 730 unsigned int num_rx_ports; 731 732 /* flow filter resource capacities */ 733 unsigned int max_categories; 734 unsigned int max_queues; 735 }; 736 737 int flow_api_backend_init(struct flow_api_backend_s *dev, const struct flow_api_backend_ops *iface, 738 void *be_dev); 739 int flow_api_backend_done(struct flow_api_backend_s *dev); 740 741 #endif /* _HW_MOD_BACKEND_H_ */ 742