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)
{
}
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;
}
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;
}
}
}
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) {
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)
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) {
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;
}
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);
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;
}
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;
}
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;
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);
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;
}
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;
}
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 */
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;
}
}
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;
}