@@ -77,6 +77,15 @@ bnxt_ulp_app_cap_list_get(uint32_t *num_entries)
return ulp_app_cap_info_list;
}
+static struct bnxt_ulp_resource_resv_info *
+bnxt_ulp_app_resource_resv_list_get(uint32_t *num_entries)
+{
+ if (num_entries == NULL)
+ return NULL;
+ *num_entries = BNXT_ULP_APP_RESOURCE_RESV_LIST_MAX_SZ;
+ return ulp_app_resource_resv_list;
+}
+
struct bnxt_ulp_resource_resv_info *
bnxt_ulp_resource_resv_list_get(uint32_t *num_entries)
{
@@ -96,23 +105,18 @@ bnxt_ulp_app_glb_resource_info_list_get(uint32_t *num_entries)
}
static int32_t
-bnxt_ulp_tf_resources_get(struct bnxt_ulp_context *ulp_ctx,
- struct tf_session_resources *res)
+bnxt_ulp_named_resources_calc(struct bnxt_ulp_context *ulp_ctx,
+ struct bnxt_ulp_glb_resource_info *info,
+ uint32_t num,
+ struct tf_session_resources *res)
{
- struct bnxt_ulp_resource_resv_info *info = NULL;
- uint32_t dev_id, res_type, i, num;
+ uint32_t dev_id, res_type, i;
enum tf_dir dir;
uint8_t app_id;
int32_t rc = 0;
- if (!ulp_ctx || !res) {
- BNXT_TF_DBG(ERR, "Invalid arguments to get resources.\n");
- return -EINVAL;
- }
-
- info = bnxt_ulp_resource_resv_list_get(&num);
- if (!info) {
- BNXT_TF_DBG(ERR, "Unable to get resource reservation list.\n");
+ if (ulp_ctx == NULL || info == NULL || res == NULL || num == 0) {
+ BNXT_TF_DBG(ERR, "Invalid parms to named resources calc.\n");
return -EINVAL;
}
@@ -124,31 +128,33 @@ bnxt_ulp_tf_resources_get(struct bnxt_ulp_context *ulp_ctx,
rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id);
if (rc) {
- BNXT_TF_DBG(ERR, "Unable to get the device id from ulp.\n");
+ BNXT_TF_DBG(ERR, "Unable to get the dev id from ulp.\n");
return -EINVAL;
}
for (i = 0; i < num; i++) {
- if (app_id != info[i].app_id || dev_id != info[i].device_id)
+ if (dev_id != info[i].device_id || app_id != info[i].app_id)
continue;
dir = info[i].direction;
res_type = info[i].resource_type;
switch (info[i].resource_func) {
case BNXT_ULP_RESOURCE_FUNC_IDENTIFIER:
- res->ident_cnt[dir].cnt[res_type] = info[i].count;
+ res->ident_cnt[dir].cnt[res_type]++;
break;
case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
- res->tbl_cnt[dir].cnt[res_type] = info[i].count;
+ res->tbl_cnt[dir].cnt[res_type]++;
break;
case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
- res->tcam_cnt[dir].cnt[res_type] = info[i].count;
+ res->tcam_cnt[dir].cnt[res_type]++;
break;
case BNXT_ULP_RESOURCE_FUNC_EM_TABLE:
- res->em_cnt[dir].cnt[res_type] = info[i].count;
+ res->em_cnt[dir].cnt[res_type]++;
break;
default:
- break;
+ BNXT_TF_DBG(ERR, "Unknown resource func (0x%x)\n,",
+ info[i].resource_func);
+ continue;
}
}
@@ -156,14 +162,20 @@ bnxt_ulp_tf_resources_get(struct bnxt_ulp_context *ulp_ctx,
}
static int32_t
-bnxt_ulp_tf_shared_session_resources_get(struct bnxt_ulp_context *ulp_ctx,
- struct tf_session_resources *res)
+bnxt_ulp_unnamed_resources_calc(struct bnxt_ulp_context *ulp_ctx,
+ struct bnxt_ulp_resource_resv_info *info,
+ uint32_t num,
+ struct tf_session_resources *res)
{
- struct bnxt_ulp_glb_resource_info *info;
- uint32_t dev_id, res_type, i, num;
+ uint32_t dev_id, res_type, i;
enum tf_dir dir;
uint8_t app_id;
- int32_t rc;
+ int32_t rc = 0;
+
+ if (ulp_ctx == NULL || res == NULL || info == NULL || num == 0) {
+ BNXT_TF_DBG(ERR, "Invalid arguments to get resources.\n");
+ return -EINVAL;
+ }
rc = bnxt_ulp_cntxt_app_id_get(ulp_ctx, &app_id);
if (rc) {
@@ -173,48 +185,108 @@ bnxt_ulp_tf_shared_session_resources_get(struct bnxt_ulp_context *ulp_ctx,
rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id);
if (rc) {
- BNXT_TF_DBG(ERR, "Unable to get device id from ulp.\n");
+ BNXT_TF_DBG(ERR, "Unable to get the dev id from ulp.\n");
return -EINVAL;
}
- /* Make sure the resources are zero before accumulating. */
- memset(res, 0, sizeof(struct tf_session_resources));
-
- /* Get the list and tally the resources. */
- info = bnxt_ulp_app_glb_resource_info_list_get(&num);
- if (!info) {
- BNXT_TF_DBG(ERR, "Unable to get app global resource list\n");
- return -EINVAL;
- }
for (i = 0; i < num; i++) {
- if (dev_id != info[i].device_id || app_id != info[i].app_id)
+ if (app_id != info[i].app_id || dev_id != info[i].device_id)
continue;
dir = info[i].direction;
res_type = info[i].resource_type;
switch (info[i].resource_func) {
case BNXT_ULP_RESOURCE_FUNC_IDENTIFIER:
- res->ident_cnt[dir].cnt[res_type]++;
+ res->ident_cnt[dir].cnt[res_type] = info[i].count;
break;
case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
- res->tbl_cnt[dir].cnt[res_type]++;
+ res->tbl_cnt[dir].cnt[res_type] = info[i].count;
break;
case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
- res->tcam_cnt[dir].cnt[res_type]++;
+ res->tcam_cnt[dir].cnt[res_type] = info[i].count;
break;
case BNXT_ULP_RESOURCE_FUNC_EM_TABLE:
- res->em_cnt[dir].cnt[res_type]++;
+ res->em_cnt[dir].cnt[res_type] = info[i].count;
break;
default:
- BNXT_TF_DBG(ERR, "Unknown resource func (0x%x)\n,",
- info[i].resource_func);
- continue;
+ break;
}
}
-
return 0;
}
+static int32_t
+bnxt_ulp_tf_resources_get(struct bnxt_ulp_context *ulp_ctx,
+ struct tf_session_resources *res)
+{
+ struct bnxt_ulp_resource_resv_info *unnamed = NULL;
+ uint32_t unum;
+ int32_t rc = 0;
+
+ if (ulp_ctx == NULL || res == NULL) {
+ BNXT_TF_DBG(ERR, "Invalid arguments to get resources.\n");
+ return -EINVAL;
+ }
+
+ unnamed = bnxt_ulp_resource_resv_list_get(&unum);
+ if (unnamed == NULL) {
+ BNXT_TF_DBG(ERR, "Unable to get resource resv list.\n");
+ return -EINVAL;
+ }
+
+ rc = bnxt_ulp_unnamed_resources_calc(ulp_ctx, unnamed, unum, res);
+ if (rc)
+ BNXT_TF_DBG(ERR, "Unable to calc resources for session.\n");
+
+ return rc;
+}
+
+static int32_t
+bnxt_ulp_tf_shared_session_resources_get(struct bnxt_ulp_context *ulp_ctx,
+ struct tf_session_resources *res)
+{
+ struct bnxt_ulp_resource_resv_info *unnamed;
+ struct bnxt_ulp_glb_resource_info *named;
+ uint32_t unum, nnum;
+ int32_t rc;
+
+ if (ulp_ctx == NULL || res == NULL) {
+ BNXT_TF_DBG(ERR, "Invalid arguments to get resources.\n");
+ return -EINVAL;
+ }
+
+ /* Make sure the resources are zero before accumulating. */
+ memset(res, 0, sizeof(struct tf_session_resources));
+
+ /*
+ * Shared resources are comprised of both named and unnamed resources.
+ * First get the unnamed counts, and then add the named to the result.
+ */
+ /* Get the baseline counts */
+ unnamed = bnxt_ulp_app_resource_resv_list_get(&unum);
+ if (unnamed == NULL) {
+ BNXT_TF_DBG(ERR, "Unable to get shared resource resv list.\n");
+ return -EINVAL;
+ }
+ rc = bnxt_ulp_unnamed_resources_calc(ulp_ctx, unnamed, unum, res);
+ if (rc) {
+ BNXT_TF_DBG(ERR, "Unable to calc resources for shared session.\n");
+ return -EINVAL;
+ }
+
+ /* Get the named list and add the totals */
+ named = bnxt_ulp_app_glb_resource_info_list_get(&nnum);
+ if (named == NULL) {
+ BNXT_TF_DBG(ERR, "Unable to get app global resource list\n");
+ return -EINVAL;
+ }
+ rc = bnxt_ulp_named_resources_calc(ulp_ctx, named, nnum, res);
+ if (rc)
+ BNXT_TF_DBG(ERR, "Unable to calc named resources\n");
+
+ return rc;
+}
+
int32_t
bnxt_ulp_cntxt_app_caps_init(struct bnxt_ulp_context *ulp_ctx,
uint8_t app_id, uint32_t dev_id)
@@ -320,10 +392,8 @@ ulp_ctx_shared_session_open(struct bnxt *bp,
strncat(parms.ctrl_chan_name, "-tf_shared", copy_num_bytes);
rc = bnxt_ulp_tf_shared_session_resources_get(bp->ulp_ctx, resources);
- if (rc) {
- BNXT_TF_DBG(ERR, "Unable to get shared resource count.\n");
+ if (rc)
return rc;
- }
rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &ulp_dev_id);
if (rc) {
@@ -342,8 +412,7 @@ ulp_ctx_shared_session_open(struct bnxt *bp,
parms.device_type = TF_DEVICE_TYPE_THOR;
break;
default:
- BNXT_TF_DBG(ERR, "Unable to determine device for "
- "opening session.\n");
+ BNXT_TF_DBG(ERR, "Unable to determine dev for opening session.\n");
return rc;
}
@@ -450,18 +519,14 @@ ulp_ctx_session_open(struct bnxt *bp,
params.device_type = TF_DEVICE_TYPE_THOR;
break;
default:
- BNXT_TF_DBG(ERR, "Unable to determine device for "
- "opening session.\n");
+ BNXT_TF_DBG(ERR, "Unable to determine device for opening session.\n");
return rc;
}
resources = ¶ms.resources;
rc = bnxt_ulp_tf_resources_get(bp->ulp_ctx, resources);
- if (rc) {
- BNXT_TF_DBG(ERR, "Unable to determine tf resources for "
- "session open.\n");
+ if (rc)
return rc;
- }
params.bp = bp;
rc = tf_open_session(&bp->tfp, ¶ms);
@@ -708,8 +773,8 @@ ulp_ctx_init(struct bnxt *bp,
rc = bnxt_ulp_cntxt_app_caps_init(bp->ulp_ctx, bp->app_id, devid);
if (rc) {
- BNXT_TF_DBG(ERR, "Unable to set capabilities for "
- " app(%x)/dev(%x)\n", bp->app_id, devid);
+ BNXT_TF_DBG(ERR, "Unable to set caps for app(%x)/dev(%x)\n",
+ bp->app_id, devid);
goto error_deinit;
}
@@ -321,8 +321,8 @@ ulp_default_flow_create(struct rte_eth_dev *eth_dev,
ulp_ctx = bnxt_ulp_eth_dev_ptr2_cntxt_get(eth_dev);
if (!ulp_ctx) {
- BNXT_TF_DBG(ERR, "ULP context is not initialized. "
- "Failed to create default flow.\n");
+ BNXT_TF_DBG(ERR,
+ "ULP context is not initialized. Failed to create dflt flow.\n");
return -EINVAL;
}
@@ -2296,8 +2296,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
tbl->tbl_operand,
®val, &shared)) {
BNXT_TF_DBG(ERR,
- "Failed to get tbl idx from Global "
- "regfile[%d].\n",
+ "Failed to get tbl idx from Glb RF[%d].\n",
tbl->tbl_operand);
return -EINVAL;
}
@@ -2347,8 +2346,9 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
gparms.data_sz_in_bytes,
data.byte_order);
if (rc) {
- BNXT_TF_DBG(ERR, "Failed to read fields on tbl read "
- "rc=%d\n", rc);
+ BNXT_TF_DBG(ERR,
+ "Failed to get flds on tbl read rc=%d\n",
+ rc);
return rc;
}
return 0;
@@ -2433,8 +2433,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
rc = tf_set_tbl_entry(tfp, &sparms);
if (rc) {
BNXT_TF_DBG(ERR,
- "Index table[%s][%s][%x] write failed "
- "rc=%d\n",
+ "Index table[%s][%s][%x] write fail rc=%d\n",
tf_tbl_type_2_str(sparms.type),
tf_dir_2_str(sparms.dir),
sparms.idx, rc);
@@ -2833,15 +2832,15 @@ ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx,
rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id);
if (rc) {
- BNXT_TF_DBG(ERR, "Failed to get device id for "
- "global init (%d)\n", rc);
+ BNXT_TF_DBG(ERR, "Failed to get device id for glb init (%d)\n",
+ rc);
return rc;
}
rc = bnxt_ulp_cntxt_app_id_get(ulp_ctx, &app_id);
if (rc) {
- BNXT_TF_DBG(ERR, "Failed to get app id for "
- "global init (%d)\n", rc);
+ BNXT_TF_DBG(ERR, "Failed to get app id for glb init (%d)\n",
+ rc);
return rc;
}
@@ -2916,15 +2915,15 @@ ulp_mapper_app_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx,
rc = bnxt_ulp_cntxt_app_id_get(ulp_ctx, &app_id);
if (rc) {
- BNXT_TF_DBG(ERR, "Failed to get the app id in global init "
- "(%d).\n", rc);
+ BNXT_TF_DBG(ERR, "Failed to get the app id in glb init (%d).\n",
+ rc);
return rc;
}
rc = bnxt_ulp_cntxt_dev_id_get(ulp_ctx, &dev_id);
if (rc) {
- BNXT_TF_DBG(ERR, "Failed to get device id for app "
- "global init (%d)\n", rc);
+ BNXT_TF_DBG(ERR, "Failed to get dev id for app glb init (%d)\n",
+ rc);
return rc;
}
@@ -3413,8 +3412,8 @@ ulp_mapper_tbls_process(struct bnxt_ulp_mapper_parms *parms, uint32_t tid)
cond_tbls, num_cond_tbls,
&cond_rc);
if (rc) {
- BNXT_TF_DBG(ERR, "Failed to process cond opc list "
- "(%d)\n", rc);
+ BNXT_TF_DBG(ERR, "Failed to proc cond opc list (%d)\n",
+ rc);
goto error;
}
/* Skip the table if False */
@@ -3812,8 +3811,7 @@ ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx)
if (bnxt_ulp_cntxt_shared_session_enabled(ulp_ctx)) {
rc = ulp_mapper_app_glb_resource_info_init(ulp_ctx, data);
if (rc) {
- BNXT_TF_DBG(ERR, "Failed to initialize app "
- "global resources\n");
+ BNXT_TF_DBG(ERR, "Failed to init app glb resources\n");
goto error;
}
}
@@ -3840,8 +3838,7 @@ ulp_mapper_deinit(struct bnxt_ulp_context *ulp_ctx)
if (!ulp_ctx) {
BNXT_TF_DBG(ERR,
- "Failed to acquire ulp context, so data may "
- "not be released.\n");
+ "Failed to acquire ulp context, so data may not be released.\n");
return;
}
@@ -29,6 +29,7 @@
#define BNXT_ULP_GLB_RESOURCE_TBL_MAX_SZ 33
#define BNXT_ULP_APP_GLB_RESOURCE_TBL_MAX_SZ 27
#define BNXT_ULP_RESOURCE_RESV_LIST_MAX_SZ 219
+#define BNXT_ULP_APP_RESOURCE_RESV_LIST_MAX_SZ 4
#define BNXT_ULP_APP_CAP_TBL_MAX_SZ 6
#define BNXT_ULP_COND_GOTO_REJECT 1023
#define BNXT_ULP_COND_GOTO_RF 0x10000
@@ -270,6 +270,42 @@ struct bnxt_ulp_app_capabilities_info ulp_app_cap_info_list[] = {
}
};
+/* List of unnamed app tf resources required to be reserved per app/device */
+struct bnxt_ulp_resource_resv_info ulp_app_resource_resv_list[] = {
+ {
+ .app_id = 1,
+ .device_id = BNXT_ULP_DEVICE_ID_WH_PLUS,
+ .direction = TF_DIR_RX,
+ .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE,
+ .resource_type = TF_TCAM_TBL_TYPE_WC_TCAM,
+ .count = 256
+ },
+ {
+ .app_id = 1,
+ .device_id = BNXT_ULP_DEVICE_ID_THOR,
+ .direction = TF_DIR_RX,
+ .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE,
+ .resource_type = TF_TCAM_TBL_TYPE_WC_TCAM,
+ .count = 256
+ },
+ {
+ .app_id = 2,
+ .device_id = BNXT_ULP_DEVICE_ID_WH_PLUS,
+ .direction = TF_DIR_RX,
+ .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE,
+ .resource_type = TF_TCAM_TBL_TYPE_WC_TCAM,
+ .count = 256
+ },
+ {
+ .app_id = 2,
+ .device_id = BNXT_ULP_DEVICE_ID_THOR,
+ .direction = TF_DIR_RX,
+ .resource_func = BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE,
+ .resource_type = TF_TCAM_TBL_TYPE_WC_TCAM,
+ .count = 256
+ }
+};
+
/* List of device specific parameters */
struct bnxt_ulp_glb_resource_info ulp_app_glb_resource_tbl[] = {
{
@@ -391,6 +391,12 @@ extern struct bnxt_ulp_glb_resource_info ulp_app_glb_resource_tbl[];
*/
extern struct bnxt_ulp_resource_resv_info ulp_resource_resv_list[];
+/*
+ * The ulp_app_resource_resv_list provides the list of tf resources required
+ * when calling tf_open.
+ */
+extern struct bnxt_ulp_resource_resv_info ulp_app_resource_resv_list[];
+
/*
* The_app_cap_info_list provides the list of ULP capabilities per app/device.
*/