1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(c) 2014-2023 Broadcom
* All rights reserved.
*/
#ifndef _ULP_MAPPER_H_
#define _ULP_MAPPER_H_
/* TBD: it is added Thor2 testing */
/* #define ULP_MAPPER_TFC_TEST 1 */
#include <rte_log.h>
#include <rte_flow.h>
#include <rte_flow_driver.h>
#include "tf_core.h"
#include "ulp_template_db_enum.h"
#include "ulp_template_struct.h"
#include "bnxt_ulp.h"
#include "ulp_utils.h"
#include "ulp_gen_tbl.h"
#include "tfc_em.h"
#include "bitalloc.h"
#include "ulp_alloc_tbl.h"
#define ULP_IDENTS_INVALID ((uint16_t)0xffff)
struct bnxt_ulp_mapper_glb_resource_entry {
enum bnxt_ulp_resource_func resource_func;
uint32_t resource_type; /* TF_ enum type */
uint64_t resource_hndl;
bool shared;
};
#define BNXT_ULP_KEY_RECIPE_MAX_FLDS 128
struct bnxt_ulp_key_recipe_entry {
uint32_t cnt;
struct bnxt_ulp_mapper_key_info flds[BNXT_ULP_KEY_RECIPE_MAX_FLDS];
};
#define ULP_RECIPE_TYPE_MAX (BNXT_ULP_RESOURCE_SUB_TYPE_KEY_RECIPE_TABLE_WM + 1)
struct bnxt_ulp_key_recipe_info {
uint32_t num_recipes;
uint8_t max_fields;
struct bnxt_ulp_key_recipe_entry **recipes[BNXT_ULP_DIRECTION_LAST][ULP_RECIPE_TYPE_MAX];
struct bitalloc *recipe_ba[BNXT_ULP_DIRECTION_LAST][ULP_RECIPE_TYPE_MAX];
};
struct ulp_mapper_core_ops;
struct bnxt_ulp_mapper_data {
const struct ulp_mapper_core_ops *mapper_oper;
struct bnxt_ulp_mapper_glb_resource_entry
glb_res_tbl[TF_DIR_MAX][BNXT_ULP_GLB_RF_IDX_LAST];
struct ulp_mapper_gen_tbl_list gen_tbl_list[BNXT_ULP_GEN_TBL_MAX_SZ];
struct bnxt_ulp_key_recipe_info key_recipe_info;
struct ulp_allocator_tbl_entry alloc_tbl[BNXT_ULP_ALLOCATOR_TBL_MAX_SZ];
};
/* Internal Structure for passing the arguments around */
struct bnxt_ulp_mapper_parms {
enum bnxt_ulp_template_type tmpl_type;
uint32_t dev_id;
uint32_t act_tid;
uint32_t class_tid;
struct ulp_rte_act_prop *act_prop;
struct ulp_rte_act_bitmap *act_bitmap;
struct ulp_rte_hdr_bitmap *hdr_bitmap;
struct ulp_rte_hdr_bitmap *enc_hdr_bitmap;
struct ulp_rte_hdr_field *hdr_field;
struct ulp_rte_hdr_field *enc_field;
struct ulp_rte_field_bitmap *fld_bitmap;
uint64_t *comp_fld;
struct ulp_regfile *regfile;
struct bnxt_ulp_context *ulp_ctx;
uint32_t flow_id;
uint16_t func_id;
uint32_t rid;
enum bnxt_ulp_fdb_type flow_type;
struct bnxt_ulp_mapper_data *mapper_data;
struct bnxt_ulp_device_params *device_params;
uint32_t child_flow;
uint32_t parent_flow;
uint8_t tun_idx;
uint32_t app_priority;
uint64_t shared_hndl;
uint32_t flow_pattern_id;
uint32_t act_pattern_id;
uint8_t app_id;
uint16_t port_id;
uint16_t fw_fid;
uint64_t cf_bitmap;
uint64_t wc_field_bitmap;
uint64_t exclude_field_bitmap;
struct tfc_mpc_batch_info_t batch_info;
};
/* Function to initialize any dynamic mapper data. */
struct ulp_mapper_core_ops {
int32_t
(*ulp_mapper_core_tcam_tbl_process)(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *t);
int32_t
(*ulp_mapper_core_tcam_entry_free)(struct bnxt_ulp_context *ulp_ctx,
struct ulp_flow_db_res_params *res);
int32_t
(*ulp_mapper_core_tcam_prio_update)(struct bnxt_ulp_mapper_parms *parms,
uint8_t dir,
enum cfa_track_type tt,
enum cfa_resource_subtype_tcam type,
uint32_t tcam_id,
uint16_t priority);
int32_t
(*ulp_mapper_core_em_tbl_process)(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *t,
void *error);
int32_t
(*ulp_mapper_core_em_entry_free)(struct bnxt_ulp_context *ulp,
struct ulp_flow_db_res_params *res,
void *error);
int32_t
(*ulp_mapper_core_index_tbl_process)(struct bnxt_ulp_mapper_parms *parm,
struct bnxt_ulp_mapper_tbl_info
*t);
int32_t
(*ulp_mapper_core_index_entry_free)(struct bnxt_ulp_context *ulp,
struct ulp_flow_db_res_params *res);
int32_t
(*ulp_mapper_core_cmm_tbl_process)(struct bnxt_ulp_mapper_parms *parm,
struct bnxt_ulp_mapper_tbl_info *t,
void *error);
int32_t
(*ulp_mapper_core_cmm_entry_free)(struct bnxt_ulp_context *ulp,
struct ulp_flow_db_res_params *res,
void *error);
int32_t
(*ulp_mapper_core_if_tbl_process)(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *t);
int32_t
(*ulp_mapper_core_ident_alloc_process)(struct bnxt_ulp_context *ulp_ctx,
uint32_t session_type,
uint16_t ident_type,
uint8_t direction,
enum cfa_track_type tt,
uint64_t *identifier_id);
int32_t
(*ulp_mapper_core_index_tbl_alloc_process)(struct bnxt_ulp_context *ulp,
uint32_t session_type,
uint16_t table_type,
uint8_t direction,
uint64_t *index);
int32_t
(*ulp_mapper_core_ident_free)(struct bnxt_ulp_context *ulp_ctx,
struct ulp_flow_db_res_params *res);
int32_t
(*ulp_mapper_core_global_ident_alloc)(struct bnxt_ulp_context *ulp_ctx,
uint16_t ident_type,
uint8_t direction,
uint8_t *context_id,
uint16_t context_len,
uint64_t *identifier_id);
int32_t
(*ulp_mapper_core_global_ident_free)(struct bnxt_ulp_context *ulp_ctx,
struct ulp_flow_db_res_params *r);
int32_t
(*ulp_mapper_core_glb_idx_tbl_alloc)(struct bnxt_ulp_context *ctx,
uint16_t sub_type,
uint8_t direction,
uint8_t *context_id,
uint16_t context_len,
uint64_t *idx_id);
int32_t
(*ulp_mapper_core_glb_idx_tbl_free)(struct bnxt_ulp_context *ulp_ctx,
struct ulp_flow_db_res_params *r);
uint32_t
(*ulp_mapper_core_dyn_tbl_type_get)(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *t,
uint16_t blob_len,
uint16_t *out_len);
int32_t
(*ulp_mapper_core_app_glb_res_info_init)(struct bnxt_ulp_context *ulp_ctx,
struct bnxt_ulp_mapper_data *mapper_data);
int32_t
(*ulp_mapper_core_handle_to_offset)(struct bnxt_ulp_mapper_parms *parms,
uint64_t handle,
uint32_t offset,
uint64_t *result);
int
(*ulp_mapper_mpc_batch_start)(struct tfc_mpc_batch_info_t *batch_info);
bool
(*ulp_mapper_mpc_batch_started)(struct tfc_mpc_batch_info_t *batch_info);
int
(*ulp_mapper_mpc_batch_end)(struct tfc *tfcp,
struct tfc_mpc_batch_info_t *batch_info);
int32_t
(*ulp_mapper_mtr_stats_hndl_set)(struct bnxt_ulp_mapper_parms *parms,
uint32_t mtr_id,
uint64_t stats_hndl);
int32_t
(*ulp_mapper_mtr_stats_hndl_get)(uint32_t mtr_id, uint64_t *stats_hndl);
int
(*ulp_mapper_mtr_stats_hndl_del)(uint32_t mtr_id);
};
static inline const struct ulp_mapper_core_ops *
ulp_mapper_data_oper_get(struct bnxt_ulp_context *ulp_ctx) {
struct bnxt_ulp_mapper_data *m_data;
m_data = (struct bnxt_ulp_mapper_data *)ulp_ctx->cfg_data->mapper_data;
return m_data->mapper_oper;
}
extern const struct ulp_mapper_core_ops ulp_mapper_tf_core_ops;
extern const struct ulp_mapper_core_ops ulp_mapper_tfc_core_ops;
int32_t
ulp_mapper_glb_resource_read(struct bnxt_ulp_mapper_data *mapper_data,
enum tf_dir dir,
uint16_t idx,
uint64_t *regval,
bool *shared);
int32_t
ulp_mapper_glb_resource_write(struct bnxt_ulp_mapper_data *data,
struct bnxt_ulp_glb_resource_info *res,
uint64_t regval, bool shared);
int32_t
ulp_mapper_resource_ident_allocate(struct bnxt_ulp_context *ulp_ctx,
struct bnxt_ulp_mapper_data *mapper_data,
struct bnxt_ulp_glb_resource_info *glb_res,
bool shared);
int32_t
ulp_mapper_resource_index_tbl_alloc(struct bnxt_ulp_context *ulp_ctx,
struct bnxt_ulp_mapper_data *mapper_data,
struct bnxt_ulp_glb_resource_info *glb_res,
bool shared);
struct bnxt_ulp_mapper_key_info *
ulp_mapper_key_fields_get(struct bnxt_ulp_mapper_parms *mparms,
struct bnxt_ulp_mapper_tbl_info *tbl,
uint32_t *num_flds);
uint32_t
ulp_mapper_partial_key_fields_get(struct bnxt_ulp_mapper_parms *mparms,
struct bnxt_ulp_mapper_tbl_info *tbl);
int32_t
ulp_mapper_fdb_opc_process(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl,
struct ulp_flow_db_res_params *fid_parms);
int32_t
ulp_mapper_priority_opc_process(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl,
uint32_t *priority);
int32_t
ulp_mapper_tbl_ident_scan_ext(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl,
uint8_t *byte_data,
uint32_t byte_data_size,
enum bnxt_ulp_byte_order byte_order);
int32_t
ulp_mapper_field_opc_process(struct bnxt_ulp_mapper_parms *parms,
enum tf_dir dir,
struct bnxt_ulp_mapper_field_info *fld,
struct ulp_blob *blob,
uint8_t is_key,
const char *name);
int32_t
ulp_mapper_key_recipe_field_opc_process(struct bnxt_ulp_mapper_parms *parms,
uint8_t dir,
struct bnxt_ulp_mapper_field_info *fld,
uint8_t is_key,
const char *name,
bool *written,
struct bnxt_ulp_mapper_field_info *ofld);
int32_t
ulp_mapper_tbl_result_build(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl,
struct ulp_blob *data,
const char *name);
int32_t
ulp_mapper_mark_gfid_process(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl,
uint64_t flow_id);
int32_t
ulp_mapper_mark_act_ptr_process(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl);
int32_t
ulp_mapper_mark_vfr_idx_process(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl);
int32_t
ulp_mapper_tcam_tbl_ident_alloc(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl);
uint32_t
ulp_mapper_wc_tcam_tbl_dyn_post_process(struct bnxt_ulp_device_params *dparms,
struct ulp_blob *key,
struct ulp_blob *mask,
struct ulp_blob *tkey,
struct ulp_blob *tmask);
void ulp_mapper_wc_tcam_tbl_post_process(struct ulp_blob *blob);
int32_t
ulp_mapper_resources_free(struct bnxt_ulp_context *ulp_ctx,
enum bnxt_ulp_fdb_type flow_type,
uint32_t fid,
void *error);
int32_t
ulp_mapper_flow_destroy(struct bnxt_ulp_context *ulp_ctx,
enum bnxt_ulp_fdb_type flow_type,
uint32_t fid,
void *error);
int32_t
ulp_mapper_flow_create(struct bnxt_ulp_context *ulp_ctx,
struct bnxt_ulp_mapper_parms *parms,
void *error);
struct bnxt_ulp_mapper_key_info *
ulp_mapper_key_recipe_fields_get(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl,
uint32_t *num_flds);
int32_t
ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx);
void
ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx);
int
ulp_mapper_get_mtr_stats_hndl(uint32_t mtr_id, uint64_t *stats_ptr);
int
ulp_mapper_del_mtr_stats_hndl(uint32_t mtr_id);
#ifdef TF_FLOW_SCALE_QUERY
int32_t
ulp_resc_usage_sync(struct bnxt_ulp_context *ulp_ctx);
#endif /* TF_FLOW_SCALE_QUERY */
#endif /* _ULP_MAPPER_H_ */
|