From: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
To: dev@dpdk.org
Cc: Kishore Padmanabha <kishore.padmanabha@broadcom.com>,
Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>,
Mike Baucom <michael.baucom@broadcom.com>,
Ajit Khaparde <ajit.khaparde@broadcom.com>
Subject: [PATCH v8 19/47] net/bnxt: tf_ulp: convert recipe table to dynamic memory
Date: Thu, 7 Nov 2024 19:22:26 +0530 [thread overview]
Message-ID: <20241107135254.1611676-20-sriharsha.basavapatna@broadcom.com> (raw)
In-Reply-To: <20241107135254.1611676-1-sriharsha.basavapatna@broadcom.com>
From: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Converted the recipe table allocation from static model to dynamic
memory allocation model.
Signed-off-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
Reviewed-by: Mike Baucom <michael.baucom@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/tf_ulp/ulp_mapper.c | 175 +++++++++++++++------------
drivers/net/bnxt/tf_ulp/ulp_mapper.h | 5 +-
2 files changed, 97 insertions(+), 83 deletions(-)
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.c b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
index 7045efffad..a7b35bf292 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.c
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.c
@@ -1280,65 +1280,71 @@ ulp_mapper_field_opc_next(struct bnxt_ulp_mapper_parms *parms,
static void
ulp_mapper_key_recipe_tbl_deinit(struct bnxt_ulp_mapper_data *mdata)
{
+ struct bnxt_ulp_key_recipe_entry **recipes;
enum bnxt_ulp_direction dir;
+ uint32_t idx, ftype;
+
+ /* If recipe table is not initialized then exit */
+ if (!mdata->key_recipe_info.num_recipes)
+ return;
for (dir = 0; dir < BNXT_ULP_DIRECTION_LAST; dir++) {
- rte_free(mdata->key_recipe_info.em_recipes[dir]);
- rte_free(mdata->key_recipe_info.wc_recipes[dir]);
+ for (ftype = 0; ftype < ULP_RECIPE_TYPE_MAX; ftype++) {
+ recipes = mdata->key_recipe_info.recipes[dir][ftype];
+ for (idx = 0; idx < mdata->key_recipe_info.num_recipes;
+ idx++) {
+ if (recipes[idx])
+ rte_free(recipes[idx]);
+ }
+ rte_free(mdata->key_recipe_info.recipes[dir][ftype]);
+ mdata->key_recipe_info.recipes[dir][ftype] = NULL;
+ }
}
+ mdata->key_recipe_info.num_recipes = 0;
}
static int32_t
ulp_mapper_key_recipe_tbl_init(struct bnxt_ulp_context *ulp_ctx,
struct bnxt_ulp_mapper_data *mdata)
{
- struct bnxt_ulp_key_recipe_entry *recipes;
+ struct bnxt_ulp_key_recipe_entry **recipes;
enum bnxt_ulp_direction dir;
- uint32_t dev_id = 0;
- uint32_t num_recipes;
+ uint32_t dev_id = 0, size_val;
+ uint32_t num_recipes, ftype;
int32_t rc = 0;
rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id);
if (rc) {
BNXT_DRV_DBG(ERR, "Unable to get device id from ulp.\n");
- return rc;
+ return -EINVAL;
}
num_recipes = bnxt_ulp_num_key_recipes_get(ulp_ctx);
if (!num_recipes)
- return 0;
+ return rc;
+ size_val = sizeof(struct bnxt_ulp_key_recipe_entry *);
for (dir = 0; dir < BNXT_ULP_DIRECTION_LAST; dir++) {
- recipes = rte_zmalloc("key_recipe_em",
- sizeof(struct bnxt_ulp_key_recipe_entry) *
- num_recipes, 0);
- if (!recipes)
- goto error;
- mdata->key_recipe_info.em_recipes[dir] = recipes;
-
- recipes = rte_zmalloc("key_recipe_wc",
- sizeof(struct bnxt_ulp_key_recipe_entry) *
- num_recipes, 0);
- if (!recipes)
- goto error;
- mdata->key_recipe_info.wc_recipes[dir] = recipes;
+ for (ftype = 0; ftype < ULP_RECIPE_TYPE_MAX; ftype++) {
+ recipes = rte_zmalloc("key_recipe_list",
+ size_val * num_recipes, 0);
+ if (!recipes) {
+ BNXT_DRV_DBG(ERR, "Uanable to alloc memory\n");
+ return -ENOMEM;
+ }
+ mdata->key_recipe_info.recipes[dir][ftype] = recipes;
+ }
}
-
mdata->key_recipe_info.num_recipes = num_recipes;
mdata->key_recipe_info.max_fields = BNXT_ULP_KEY_RECIPE_MAX_FLDS;
-
- return 0;
-error:
- (void)ulp_mapper_key_recipe_tbl_deinit(mdata);
- return -ENOMEM;
+ return rc;
}
-static struct bnxt_ulp_key_recipe_entry *
-ulp_mapper_key_recipe_entry_get(struct bnxt_ulp_context *ulp_ctx,
- enum bnxt_ulp_direction dir,
- enum bnxt_ulp_resource_sub_type stype,
- uint8_t recipe_id, uint8_t *max_fields)
+static struct bnxt_ulp_mapper_data *
+ulp_mapper_key_recipe_args_validate(struct bnxt_ulp_context *ulp_ctx,
+ enum bnxt_ulp_direction dir,
+ enum bnxt_ulp_resource_sub_type stype,
+ uint8_t recipe_id)
{
- struct bnxt_ulp_key_recipe_entry *recipes;
struct bnxt_ulp_mapper_data *mdata;
mdata = (struct bnxt_ulp_mapper_data *)
@@ -1355,52 +1361,54 @@ ulp_mapper_key_recipe_entry_get(struct bnxt_ulp_context *ulp_ctx,
BNXT_DRV_DBG(ERR, "Recipes are not supported\n");
return NULL;
}
- switch (stype) {
- case BNXT_ULP_RESOURCE_SUB_TYPE_KEY_RECIPE_TABLE_WM:
- recipes = mdata->key_recipe_info.wc_recipes[dir];
- break;
- case BNXT_ULP_RESOURCE_SUB_TYPE_KEY_RECIPE_TABLE_EM:
- recipes = mdata->key_recipe_info.em_recipes[dir];
- break;
- default:
- BNXT_DRV_DBG(ERR, "Invalid type (%d) for key recipe.\n", stype);
+ if (stype != BNXT_ULP_RESOURCE_SUB_TYPE_KEY_RECIPE_TABLE_WM &&
+ stype != BNXT_ULP_RESOURCE_SUB_TYPE_KEY_RECIPE_TABLE_EM) {
+ BNXT_DRV_DBG(ERR, "Invalid type (%d) in key recipe\n", stype);
return NULL;
- };
-
- if (recipe_id >= mdata->key_recipe_info.num_recipes) {
- BNXT_DRV_DBG(ERR, "key recipe id out of range(%d >= %d)\n",
+ }
+ if (recipe_id >= mdata->key_recipe_info.num_recipes ||
+ !mdata->key_recipe_info.num_recipes) {
+ BNXT_DRV_DBG(ERR, "Key recipe id out of range(%d >= %d)\n",
recipe_id, mdata->key_recipe_info.num_recipes);
return NULL;
}
-
- if (max_fields)
- *max_fields = mdata->key_recipe_info.max_fields;
- return &recipes[recipe_id];
+ return mdata;
}
-/* Not a strict alloc, it is allocating with the key id */
static struct bnxt_ulp_key_recipe_entry *
ulp_mapper_key_recipe_alloc(struct bnxt_ulp_context *ulp_ctx,
enum bnxt_ulp_direction dir,
enum bnxt_ulp_resource_sub_type stype,
uint8_t recipe_id, uint8_t *max_fields)
{
- struct bnxt_ulp_key_recipe_entry *recipe;
+ struct bnxt_ulp_key_recipe_entry **recipes;
+ struct bnxt_ulp_mapper_data *mdata = NULL;
+ uint32_t size_s = sizeof(struct bnxt_ulp_key_recipe_entry);
- recipe = ulp_mapper_key_recipe_entry_get(ulp_ctx, dir, stype,
- recipe_id, max_fields);
- if (recipe) {
- if (recipe->in_use) {
- BNXT_DRV_INF("Recipe ID (%d) already allocated\n",
- recipe_id);
+ mdata = ulp_mapper_key_recipe_args_validate(ulp_ctx, dir,
+ stype, recipe_id);
+ if (mdata == NULL)
+ return NULL;
+
+ recipes = mdata->key_recipe_info.recipes[dir][stype];
+ if (recipes[recipe_id] == NULL) {
+ recipes[recipe_id] = rte_zmalloc("key_recipe_entry", size_s, 0);
+ if (recipes[recipe_id] == NULL) {
+ BNXT_DRV_DBG(ERR, "Unable to alloc key recipe\n");
return NULL;
}
- recipe->in_use = true;
- recipe->cnt = 0;
+#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
+#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
+ BNXT_DRV_INF("Alloc key recipe [%s]:[%s] = 0x%X\n",
+ (dir == BNXT_ULP_DIRECTION_INGRESS) ? "rx" : "tx",
+ ulp_mapper_key_recipe_type_to_str(stype), recipe_id);
+#endif
+#endif
+ *max_fields = mdata->key_recipe_info.max_fields;
+ return recipes[recipe_id];
}
-
- /* key will be null if it failed */
- return recipe;
+ BNXT_DRV_DBG(ERR, "Recipe ID (%d) already allocated\n", recipe_id);
+ return NULL;
}
/* The free just marks the entry as not in use and resets the number of entries
@@ -1412,15 +1420,19 @@ ulp_mapper_key_recipe_free(struct bnxt_ulp_context *ulp_ctx,
enum bnxt_ulp_resource_sub_type stype,
uint32_t index)
{
- struct bnxt_ulp_key_recipe_entry *recipe;
+ struct bnxt_ulp_key_recipe_entry **recipes;
+ struct bnxt_ulp_mapper_data *mdata = NULL;
- recipe = ulp_mapper_key_recipe_entry_get(ulp_ctx, dir, stype,
- index, NULL);
- if (recipe == NULL)
+ mdata = ulp_mapper_key_recipe_args_validate(ulp_ctx, dir,
+ stype, index);
+ if (mdata == NULL)
return -EINVAL;
- recipe->in_use = false;
- recipe->cnt = 0;
+ recipes = mdata->key_recipe_info.recipes[dir][stype];
+ if (recipes[index] == NULL)
+ return -EINVAL;
+ rte_free(recipes[index]);
+ recipes[index] = NULL;
#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
BNXT_DRV_INF("Free key recipe [%s]:[%s] = 0x%X\n",
@@ -1428,7 +1440,6 @@ ulp_mapper_key_recipe_free(struct bnxt_ulp_context *ulp_ctx,
ulp_mapper_key_recipe_type_to_str(stype), index);
#endif
#endif
-
return 0;
}
@@ -1454,8 +1465,9 @@ ulp_mapper_key_recipe_fields_get(struct bnxt_ulp_mapper_parms *parms,
struct bnxt_ulp_mapper_tbl_info *tbl,
uint32_t *num_flds)
{
- struct bnxt_ulp_key_recipe_entry *recipe;
+ struct bnxt_ulp_key_recipe_entry **recipes;
enum bnxt_ulp_resource_sub_type stype;
+ struct bnxt_ulp_mapper_data *mdata = NULL;
uint64_t recipe_id = 0;
/* Don't like this, but need to convert from a tbl resource func to the
@@ -1475,22 +1487,25 @@ ulp_mapper_key_recipe_fields_get(struct bnxt_ulp_mapper_parms *parms,
};
/* Get the recipe index from the registry file */
- if (!ulp_regfile_read(parms->regfile,
- tbl->key_recipe_operand,
+ if (!ulp_regfile_read(parms->regfile, tbl->key_recipe_operand,
&recipe_id)) {
- BNXT_DRV_DBG(ERR,
- "Failed to get tbl idx from regfile[%d].\n",
+ BNXT_DRV_DBG(ERR, "Failed to get tbl idx from regfile[%d].\n",
tbl->tbl_operand);
return NULL;
}
recipe_id = tfp_be_to_cpu_64(recipe_id);
- recipe = ulp_mapper_key_recipe_entry_get(parms->ulp_ctx, tbl->direction,
- stype, recipe_id, NULL);
- if (recipe == NULL || !recipe->in_use)
+ mdata = ulp_mapper_key_recipe_args_validate(parms->ulp_ctx,
+ tbl->direction,
+ stype, recipe_id);
+ if (mdata == NULL)
+ return NULL;
+
+ recipes = mdata->key_recipe_info.recipes[tbl->direction][stype];
+ if (recipes[recipe_id] == NULL)
return NULL;
- *num_flds = recipe->cnt;
- return &recipe->flds[0];
+ *num_flds = recipes[recipe_id]->cnt;
+ return &recipes[recipe_id]->flds[0];
}
static int32_t
@@ -3552,7 +3567,7 @@ ulp_mapper_func_info_process(struct bnxt_ulp_mapper_parms *parms,
}
#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG
#ifdef RTE_LIBRTE_BNXT_TRUFLOW_DEBUG_MAPPER
- BNXT_DRV_DBG(DEBUG, "write the %" PRIu64 " into func_opc %u\n", res,
+ BNXT_DRV_DBG(DEBUG, "write the %" PRIX64 " into func_opc %u\n", res,
func_info->func_dst_opr);
#endif
#endif
diff --git a/drivers/net/bnxt/tf_ulp/ulp_mapper.h b/drivers/net/bnxt/tf_ulp/ulp_mapper.h
index 254bbb2156..aa313334e5 100644
--- a/drivers/net/bnxt/tf_ulp/ulp_mapper.h
+++ b/drivers/net/bnxt/tf_ulp/ulp_mapper.h
@@ -31,16 +31,15 @@ struct bnxt_ulp_mapper_glb_resource_entry {
#define BNXT_ULP_KEY_RECIPE_MAX_FLDS 128
struct bnxt_ulp_key_recipe_entry {
- bool in_use;
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 *em_recipes[BNXT_ULP_DIRECTION_LAST];
- struct bnxt_ulp_key_recipe_entry *wc_recipes[BNXT_ULP_DIRECTION_LAST];
+ struct bnxt_ulp_key_recipe_entry **recipes[BNXT_ULP_DIRECTION_LAST][ULP_RECIPE_TYPE_MAX];
};
struct ulp_mapper_core_ops;
--
2.39.3
next prev parent reply other threads:[~2024-11-07 13:44 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 13:52 [PATCH v8 00/47] TruFlow update for Thor2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 01/47] net/bnxt: tf_core: fix wc tcam multi slice delete issue Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 02/47] net/bnxt: tf_core: tcam manager data corruption Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 03/47] net/bnxt: tf_core: External EM support cleanup Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 04/47] net/bnxt: tf_core: Thor TF EM key size check Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 05/47] net/bnxt: tf_core: flow scale improvement Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 06/47] net/bnxt: tf_core: TF support flow scale query Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 07/47] net/bnxt: tf_core: fix slice count in case of HA entry move Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 08/47] net/bnxt: tf_core: convert priority based TCAM manager to dynamic allocation Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 09/47] net/bnxt: tf_core: remove dead AFM code from session-based priority TCAM mgr Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 10/47] net/bnxt: tf_core: remove dead " Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 11/47] net/bnxt: tfc: support tf-core for Thor2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 12/47] net/bnxt: tf_ulp: add vxlan-gpe base support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 13/47] net/bnxt: tf_ulp: add custom l2 etype tunnel support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 14/47] net/bnxt: tf_ulp: add support for vf to vf flow offload Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 15/47] net/bnxt: tf_ulp: Wh+ mirroring support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 16/47] net/bnxt: tf_ulp: miscellaneous fixes Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 17/47] net/bnxt: tf_ulp: support for Thor2 ulp layer Sriharsha Basavapatna
2024-12-10 13:32 ` David Marchand
2024-11-07 13:52 ` [PATCH v8 18/47] net/bnxt: tf_ulp: add support for overlapping flows Sriharsha Basavapatna
2024-11-07 13:52 ` Sriharsha Basavapatna [this message]
2024-11-07 13:52 ` [PATCH v8 20/47] net/bnxt: tf_ulp: add feature bit support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 21/47] net/bnxt: tf_ulp: add action read and clear support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 22/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 23/47] net/bnxt: tf_ulp: VFR updates for Thor 2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 24/47] net/bnxt: tf_ulp: add support for tunnel flow stats Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 25/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 26/47] net/bnxt: tf_ulp: enable recipe id generation Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 27/47] net/bnxt: tf_ulp: fixed parent child db counters Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 28/47] net/bnxt: tf_ulp: modify return values to adhere to C coding standard Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 29/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 30/47] net/bnxt: tf_ulp: add mask defaults when mask is not specified Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 31/47] net/bnxt: tf_ulp: add jump action support Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 32/47] net/bnxt: tf_ulp: add support for flow priority Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 33/47] net/bnxt: tf_ulp: support for dynamic tunnel ports Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 34/47] net/bnxt: tf_ulp: add rte_mtr support for Thor2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 35/47] net/bnxt: tf_ulp: TF support flow scale query Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 36/47] net/bnxt: tf_ulp: add support for rss flow query to ULP Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 37/47] net/bnxt: tf_ulp: add track type feature to tables Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 38/47] net/bnxt: tf_ulp: inline utility functions and use likely/unlikely Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 39/47] net/bnxt: tf_ulp: switch ulp to use rte crc32 hash Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 40/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 41/47] net/bnxt: tf_ulp: support a few generic template items Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 42/47] net/bnxt: tf_ulp: TFC support flow scale query for Thor2 Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 43/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 44/47] net/bnxt: tf_ulp: enable support for truflow feature configuration Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 45/47] net/bnxt: tf_ulp: support a few feature extensions Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 46/47] net/bnxt: tf_ulp: update template files Sriharsha Basavapatna
2024-11-07 13:52 ` [PATCH v8 47/47] net/bnxt: tf_ulp: add stats cache for thor2 Sriharsha Basavapatna
2024-11-08 2:05 ` [PATCH v8 00/47] TruFlow update for Thor2 Sriharsha Basavapatna
2024-11-08 2:14 ` Ajit Khaparde
2024-11-12 11:00 ` Thomas Monjalon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241107135254.1611676-20-sriharsha.basavapatna@broadcom.com \
--to=sriharsha.basavapatna@broadcom.com \
--cc=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=kishore.padmanabha@broadcom.com \
--cc=michael.baucom@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).