net/bnxt: add shared session support to ULP
Shared session permits cooperative sharing of prescribed resources between applications. - devargs added for app-id in order to enable sharing session resources across applications - shared session management added - TRUFLOW resource reservations are now app ID and device dependent Signed-off-by: Mike Baucom <michael.baucom@broadcom.com> Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com> Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com> Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
This commit is contained in:
parent
741172be52
commit
c6062ec0f7
@ -874,9 +874,11 @@ struct bnxt {
|
||||
uint16_t port_svif;
|
||||
|
||||
struct tf tfp;
|
||||
struct tf tfp_shared;
|
||||
struct bnxt_ulp_context *ulp_ctx;
|
||||
struct bnxt_flow_stat_info *flow_stat;
|
||||
uint16_t max_num_kflows;
|
||||
uint8_t app_id;
|
||||
uint16_t tx_cfa_action;
|
||||
struct bnxt_ring_stats *prev_rx_ring_stats;
|
||||
struct bnxt_ring_stats *prev_tx_ring_stats;
|
||||
|
@ -97,6 +97,7 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
|
||||
#define BNXT_DEVARG_REP_Q_F2R "rep-q-f2r"
|
||||
#define BNXT_DEVARG_REP_FC_R2F "rep-fc-r2f"
|
||||
#define BNXT_DEVARG_REP_FC_F2R "rep-fc-f2r"
|
||||
#define BNXT_DEVARG_APP_ID "app-id"
|
||||
|
||||
static const char *const bnxt_dev_args[] = {
|
||||
BNXT_DEVARG_REPRESENTOR,
|
||||
@ -109,6 +110,7 @@ static const char *const bnxt_dev_args[] = {
|
||||
BNXT_DEVARG_REP_Q_F2R,
|
||||
BNXT_DEVARG_REP_FC_R2F,
|
||||
BNXT_DEVARG_REP_FC_F2R,
|
||||
BNXT_DEVARG_APP_ID,
|
||||
NULL
|
||||
};
|
||||
|
||||
@ -118,6 +120,11 @@ static const char *const bnxt_dev_args[] = {
|
||||
*/
|
||||
#define BNXT_DEVARG_ACCUM_STATS_INVALID(accum_stats) ((accum_stats) > 1)
|
||||
|
||||
/*
|
||||
* app-id = an non-negative 8-bit number
|
||||
*/
|
||||
#define BNXT_DEVARG_APP_ID_INVALID(val) ((val) > 255)
|
||||
|
||||
/*
|
||||
* flow_xstat == false to disable the feature
|
||||
* flow_xstat == true to enable the feature
|
||||
@ -5430,6 +5437,42 @@ bnxt_parse_devarg_max_num_kflows(__rte_unused const char *key,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
bnxt_parse_devarg_app_id(__rte_unused const char *key,
|
||||
const char *value, void *opaque_arg)
|
||||
{
|
||||
struct bnxt *bp = opaque_arg;
|
||||
unsigned long app_id;
|
||||
char *end = NULL;
|
||||
|
||||
if (!value || !opaque_arg) {
|
||||
PMD_DRV_LOG(ERR,
|
||||
"Invalid parameter passed to app-id "
|
||||
"devargs.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
app_id = strtoul(value, &end, 10);
|
||||
if (end == NULL || *end != '\0' ||
|
||||
(app_id == ULONG_MAX && errno == ERANGE)) {
|
||||
PMD_DRV_LOG(ERR,
|
||||
"Invalid parameter passed to app_id "
|
||||
"devargs.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (BNXT_DEVARG_APP_ID_INVALID(app_id)) {
|
||||
PMD_DRV_LOG(ERR, "Invalid app-id(%d) devargs.\n",
|
||||
(uint16_t)app_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
bp->app_id = app_id;
|
||||
PMD_DRV_LOG(INFO, "app-id=%d feature enabled.\n", (uint16_t)app_id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
bnxt_parse_devarg_rep_is_pf(__rte_unused const char *key,
|
||||
const char *value, void *opaque_arg)
|
||||
@ -5691,6 +5734,13 @@ bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs *devargs)
|
||||
goto err;
|
||||
|
||||
err:
|
||||
/*
|
||||
* Handler for "app-id" devarg.
|
||||
* Invoked as for ex: "-a 000:00:0d.0,app-id=1"
|
||||
*/
|
||||
rte_kvargs_process(kvlist, BNXT_DEVARG_APP_ID,
|
||||
bnxt_parse_devarg_app_id, bp);
|
||||
|
||||
rte_kvargs_free(kvlist);
|
||||
return ret;
|
||||
}
|
||||
|
@ -68,242 +68,338 @@ bnxt_ulp_devid_get(struct bnxt *bp,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t
|
||||
bnxt_ulp_tf_session_resources_get(struct bnxt *bp,
|
||||
struct tf_session_resources *res)
|
||||
struct bnxt_ulp_app_capabilities_info *
|
||||
bnxt_ulp_app_cap_list_get(uint32_t *num_entries)
|
||||
{
|
||||
uint32_t dev_id;
|
||||
int32_t rc;
|
||||
uint16_t *tmp_cnt;
|
||||
if (!num_entries)
|
||||
return NULL;
|
||||
*num_entries = BNXT_ULP_APP_CAP_TBL_MAX_SZ;
|
||||
return ulp_app_cap_info_list;
|
||||
}
|
||||
|
||||
rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id);
|
||||
struct bnxt_ulp_resource_resv_info *
|
||||
bnxt_ulp_resource_resv_list_get(uint32_t *num_entries)
|
||||
{
|
||||
if (!num_entries)
|
||||
return NULL;
|
||||
*num_entries = BNXT_ULP_RESOURCE_RESV_LIST_MAX_SZ;
|
||||
return ulp_resource_resv_list;
|
||||
}
|
||||
|
||||
struct bnxt_ulp_glb_resource_info *
|
||||
bnxt_ulp_app_glb_resource_info_list_get(uint32_t *num_entries)
|
||||
{
|
||||
if (!num_entries)
|
||||
return NULL;
|
||||
*num_entries = BNXT_ULP_APP_GLB_RESOURCE_TBL_MAX_SZ;
|
||||
return ulp_app_glb_resource_tbl;
|
||||
}
|
||||
|
||||
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 *info = NULL;
|
||||
uint32_t dev_id, res_type, i, num;
|
||||
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");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = bnxt_ulp_cntxt_app_id_get(ulp_ctx, &app_id);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Unable to get the app id from ulp.\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");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
for (i = 0; i < num; i++) {
|
||||
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] = info[i].count;
|
||||
break;
|
||||
case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
|
||||
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] = info[i].count;
|
||||
break;
|
||||
case BNXT_ULP_RESOURCE_FUNC_EM_TABLE:
|
||||
res->em_cnt[dir].cnt[res_type] = info[i].count;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t
|
||||
bnxt_ulp_tf_shared_session_resources_get(struct bnxt_ulp_context *ulp_ctx,
|
||||
struct tf_session_resources *res)
|
||||
{
|
||||
struct bnxt_ulp_glb_resource_info *info;
|
||||
uint32_t dev_id, res_type, i, num;
|
||||
enum tf_dir dir;
|
||||
uint8_t app_id;
|
||||
int32_t rc;
|
||||
|
||||
rc = bnxt_ulp_cntxt_app_id_get(ulp_ctx, &app_id);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Unable to get the app id from ulp.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
switch (dev_id) {
|
||||
case BNXT_ULP_DEVICE_ID_WH_PLUS:
|
||||
/** RX **/
|
||||
/* Identifiers */
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_L2_CTXT_HIGH] = 422;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_L2_CTXT_LOW] = 6;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_WC_PROF] = 192;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 64;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_EM_PROF] = 192;
|
||||
/* Make sure the resources are zero before accumulating. */
|
||||
memset(res, 0, sizeof(struct tf_session_resources));
|
||||
|
||||
/* Table Types */
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 8192;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 8192;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_MODIFY_IPV4] = 1023;
|
||||
/* 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)
|
||||
continue;
|
||||
dir = info[i].direction;
|
||||
res_type = info[i].resource_type;
|
||||
|
||||
/* ENCAP */
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_ENCAP_8B] = 511;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_ENCAP_16B] = 63;
|
||||
switch (info[i].resource_func) {
|
||||
case BNXT_ULP_RESOURCE_FUNC_IDENTIFIER:
|
||||
res->ident_cnt[dir].cnt[res_type]++;
|
||||
break;
|
||||
case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
|
||||
res->tbl_cnt[dir].cnt[res_type]++;
|
||||
break;
|
||||
case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
|
||||
res->tcam_cnt[dir].cnt[res_type]++;
|
||||
break;
|
||||
case BNXT_ULP_RESOURCE_FUNC_EM_TABLE:
|
||||
res->em_cnt[dir].cnt[res_type]++;
|
||||
break;
|
||||
default:
|
||||
BNXT_TF_DBG(ERR, "Unknown resource func (0x%x)\n,",
|
||||
info[i].resource_func);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* TCAMs */
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] =
|
||||
422;
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] =
|
||||
6;
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 960;
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 88;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* EM */
|
||||
res->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 13168;
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_app_caps_init(struct bnxt_ulp_context *ulp_ctx,
|
||||
uint8_t app_id, uint32_t dev_id)
|
||||
{
|
||||
struct bnxt_ulp_app_capabilities_info *info;
|
||||
uint32_t num = 0;
|
||||
uint16_t i;
|
||||
bool found = false;
|
||||
|
||||
/* EEM */
|
||||
res->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
|
||||
if (ULP_APP_DEV_UNSUPPORTED_ENABLED(ulp_ctx->cfg_data->ulp_flags)) {
|
||||
BNXT_TF_DBG(ERR, "APP ID %d, Device ID: 0x%x not supported.\n",
|
||||
app_id, dev_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* SP */
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_SP_SMAC] = 255;
|
||||
info = bnxt_ulp_app_cap_list_get(&num);
|
||||
if (!info || !num) {
|
||||
BNXT_TF_DBG(ERR, "Failed to get app capabilities.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_MIRROR_CONFIG] = 1;
|
||||
|
||||
/** TX **/
|
||||
/* Identifiers */
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_L2_CTXT_HIGH] = 292;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_L2_CTXT_LOW] = 148;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_WC_PROF] = 192;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 64;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_EM_PROF] = 192;
|
||||
|
||||
/* Table Types */
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 8192;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 8192;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_MODIFY_IPV4] = 1023;
|
||||
|
||||
/* ENCAP */
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_64B] = 511;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_16B] = 223;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_8B] = 255;
|
||||
|
||||
/* TCAMs */
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] =
|
||||
292;
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] =
|
||||
144;
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 960;
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 928;
|
||||
|
||||
/* EM */
|
||||
res->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 15232;
|
||||
|
||||
/* EEM */
|
||||
res->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
|
||||
|
||||
/* SP */
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = 488;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = 511;
|
||||
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_MIRROR_CONFIG] = 1;
|
||||
|
||||
break;
|
||||
case BNXT_ULP_DEVICE_ID_STINGRAY:
|
||||
/** RX **/
|
||||
/* Identifiers */
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_L2_CTXT_HIGH] = 315;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_L2_CTXT_LOW] = 6;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_WC_PROF] = 192;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 64;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_EM_PROF] = 192;
|
||||
|
||||
/* Table Types */
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 8192;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 16384;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_MODIFY_IPV4] = 1023;
|
||||
|
||||
/* ENCAP */
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_ENCAP_8B] = 511;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_ENCAP_16B] = 63;
|
||||
|
||||
/* TCAMs */
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] =
|
||||
315;
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] =
|
||||
6;
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 960;
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 112;
|
||||
|
||||
/* EM */
|
||||
res->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 13200;
|
||||
|
||||
/* EEM */
|
||||
res->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
|
||||
|
||||
/* SP */
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_SP_SMAC] = 256;
|
||||
|
||||
/** TX **/
|
||||
/* Identifiers */
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_L2_CTXT_HIGH] = 292;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_L2_CTXT_LOW] = 127;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_WC_PROF] = 192;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 64;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_EM_PROF] = 192;
|
||||
|
||||
/* Table Types */
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 8192;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 16384;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_MODIFY_IPV4] = 1023;
|
||||
|
||||
/* ENCAP */
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_64B] = 367;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_16B] = 223;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_8B] = 255;
|
||||
|
||||
/* TCAMs */
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] =
|
||||
292;
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] =
|
||||
127;
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 960;
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 928;
|
||||
|
||||
/* EM */
|
||||
res->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 15232;
|
||||
|
||||
/* EEM */
|
||||
res->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_TBL_SCOPE] = 1;
|
||||
|
||||
/* SP */
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = 488;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_SP_SMAC_IPV6] = 512;
|
||||
break;
|
||||
case BNXT_ULP_DEVICE_ID_THOR:
|
||||
/** RX **/
|
||||
/* Identifiers */
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_L2_CTXT_HIGH] = 26;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_L2_CTXT_LOW] = 6;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_WC_PROF] = 32;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 32;
|
||||
res->ident_cnt[TF_DIR_RX].cnt[TF_IDENT_TYPE_EM_PROF] = 32;
|
||||
|
||||
/* Table Types */
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 1024;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 512;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_MIRROR_CONFIG] = 14;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_EM_FKB] = 32;
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_WC_FKB] = 32;
|
||||
|
||||
/* ENCAP */
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_ENCAP_64B] = 64;
|
||||
|
||||
/* TCAMs */
|
||||
tmp_cnt = &res->tcam_cnt[TF_DIR_RX].cnt[0];
|
||||
tmp_cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] = 300;
|
||||
tmp_cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] = 6;
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 128;
|
||||
res->tcam_cnt[TF_DIR_RX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 112;
|
||||
|
||||
/* EM */
|
||||
res->em_cnt[TF_DIR_RX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 13200;
|
||||
|
||||
/* SP */
|
||||
res->tbl_cnt[TF_DIR_RX].cnt[TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = 64;
|
||||
|
||||
/** TX **/
|
||||
/* Identifiers */
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_L2_CTXT_HIGH] = 26;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_L2_CTXT_LOW] = 26;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_WC_PROF] = 32;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_PROF_FUNC] = 63;
|
||||
res->ident_cnt[TF_DIR_TX].cnt[TF_IDENT_TYPE_EM_PROF] = 32;
|
||||
|
||||
/* Table Types */
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_FULL_ACT_RECORD] = 1024;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_STATS_64] = 512;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_MIRROR_CONFIG] = 14;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_EM_FKB] = 32;
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_WC_FKB] = 32;
|
||||
|
||||
/* ENCAP */
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_ENCAP_64B] = 64;
|
||||
|
||||
/* TCAMs */
|
||||
tmp_cnt = &res->tcam_cnt[TF_DIR_TX].cnt[0];
|
||||
|
||||
tmp_cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_HIGH] = 200;
|
||||
tmp_cnt[TF_TCAM_TBL_TYPE_L2_CTXT_TCAM_LOW] = 110;
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_PROF_TCAM] = 128;
|
||||
res->tcam_cnt[TF_DIR_TX].cnt[TF_TCAM_TBL_TYPE_WC_TCAM] = 128;
|
||||
|
||||
/* EM */
|
||||
res->em_cnt[TF_DIR_TX].cnt[TF_EM_TBL_TYPE_EM_RECORD] = 15232;
|
||||
|
||||
/* SP */
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_ACT_SP_SMAC_IPV4] = 100;
|
||||
|
||||
res->tbl_cnt[TF_DIR_TX].cnt[TF_TBL_TYPE_MIRROR_CONFIG] = 1;
|
||||
|
||||
break;
|
||||
default:
|
||||
for (i = 0; i < num; i++) {
|
||||
if (info[i].app_id != app_id || info[i].device_id != dev_id)
|
||||
continue;
|
||||
found = true;
|
||||
if (info[i].flags & BNXT_ULP_APP_CAP_SHARED_EN)
|
||||
ulp_ctx->cfg_data->ulp_flags |=
|
||||
BNXT_ULP_SHARED_SESSION_ENABLED;
|
||||
}
|
||||
if (!found) {
|
||||
BNXT_TF_DBG(ERR, "APP ID %d, Device ID: 0x%x not supported.\n",
|
||||
app_id, dev_id);
|
||||
ulp_ctx->cfg_data->ulp_flags |= BNXT_ULP_APP_DEV_UNSUPPORTED;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
ulp_ctx_shared_session_close(struct bnxt *bp,
|
||||
struct bnxt_ulp_session_state *session)
|
||||
{
|
||||
struct tf *tfp;
|
||||
int32_t rc;
|
||||
|
||||
if (!bnxt_ulp_cntxt_shared_session_enabled(bp->ulp_ctx))
|
||||
return;
|
||||
|
||||
tfp = bnxt_ulp_cntxt_shared_tfp_get(bp->ulp_ctx);
|
||||
if (!tfp) {
|
||||
/*
|
||||
* Log it under debug since this is likely a case of the
|
||||
* shared session not being created. For example, a failed
|
||||
* initialization.
|
||||
*/
|
||||
BNXT_TF_DBG(DEBUG, "Failed to get shared tfp on close.\n");
|
||||
return;
|
||||
}
|
||||
rc = tf_close_session(tfp);
|
||||
if (rc)
|
||||
BNXT_TF_DBG(ERR, "Failed to close the shared session rc=%d.\n",
|
||||
rc);
|
||||
(void)bnxt_ulp_cntxt_shared_tfp_set(bp->ulp_ctx, NULL);
|
||||
|
||||
session->g_shared_tfp.session = NULL;
|
||||
}
|
||||
|
||||
static int32_t
|
||||
ulp_ctx_shared_session_open(struct bnxt *bp,
|
||||
struct bnxt_ulp_session_state *session)
|
||||
{
|
||||
struct rte_eth_dev *ethdev = bp->eth_dev;
|
||||
struct tf_session_resources *resources;
|
||||
struct tf_open_session_parms parms;
|
||||
size_t copy_num_bytes;
|
||||
uint32_t ulp_dev_id;
|
||||
int32_t rc = 0;
|
||||
|
||||
/* only perform this if shared session is enabled. */
|
||||
if (!bnxt_ulp_cntxt_shared_session_enabled(bp->ulp_ctx))
|
||||
return 0;
|
||||
|
||||
memset(&parms, 0, sizeof(parms));
|
||||
|
||||
rc = rte_eth_dev_get_name_by_port(ethdev->data->port_id,
|
||||
parms.ctrl_chan_name);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Invalid port %d, rc = %d\n",
|
||||
ethdev->data->port_id, rc);
|
||||
return rc;
|
||||
}
|
||||
resources = &parms.resources;
|
||||
|
||||
/*
|
||||
* Need to account for size of ctrl_chan_name and 1 extra for Null
|
||||
* terminator
|
||||
*/
|
||||
copy_num_bytes = sizeof(parms.ctrl_chan_name) -
|
||||
strlen(parms.ctrl_chan_name) - 1;
|
||||
|
||||
/* Build the ctrl_chan_name with shared token */
|
||||
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");
|
||||
return rc;
|
||||
}
|
||||
|
||||
rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &ulp_dev_id);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Unable to get device id from ulp.\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
switch (ulp_dev_id) {
|
||||
case BNXT_ULP_DEVICE_ID_WH_PLUS:
|
||||
parms.device_type = TF_DEVICE_TYPE_WH;
|
||||
break;
|
||||
case BNXT_ULP_DEVICE_ID_STINGRAY:
|
||||
parms.device_type = TF_DEVICE_TYPE_SR;
|
||||
break;
|
||||
case BNXT_ULP_DEVICE_ID_THOR:
|
||||
parms.device_type = TF_DEVICE_TYPE_THOR;
|
||||
break;
|
||||
default:
|
||||
BNXT_TF_DBG(ERR, "Unable to determine device for "
|
||||
"opening session.\n");
|
||||
return rc;
|
||||
}
|
||||
|
||||
parms.shadow_copy = true;
|
||||
parms.bp = bp;
|
||||
|
||||
/*
|
||||
* Open the session here, but the collect the resources during the
|
||||
* mapper initialization.
|
||||
*/
|
||||
rc = tf_open_session(&bp->tfp_shared, &parms);
|
||||
if (rc)
|
||||
return rc;
|
||||
|
||||
if (parms.shared_session_creator)
|
||||
BNXT_TF_DBG(DEBUG, "Shared session creator.\n");
|
||||
else
|
||||
BNXT_TF_DBG(DEBUG, "Shared session attached.\n");
|
||||
|
||||
/* Save the shared session in global data */
|
||||
if (!session->g_shared_tfp.session)
|
||||
session->g_shared_tfp.session = bp->tfp_shared.session;
|
||||
|
||||
rc = bnxt_ulp_cntxt_shared_tfp_set(bp->ulp_ctx, &bp->tfp_shared);
|
||||
if (rc)
|
||||
BNXT_TF_DBG(ERR, "Failed to add shared tfp to ulp (%d)\n", rc);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int32_t
|
||||
ulp_ctx_shared_session_attach(struct bnxt *bp,
|
||||
struct bnxt_ulp_session_state *session)
|
||||
{
|
||||
int32_t rc = 0;
|
||||
|
||||
/* Simply return success if shared session not enabled */
|
||||
if (bnxt_ulp_cntxt_shared_session_enabled(bp->ulp_ctx)) {
|
||||
bp->tfp_shared.session = session->g_shared_tfp.session;
|
||||
rc = ulp_ctx_shared_session_open(bp, session);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static void
|
||||
ulp_ctx_shared_session_detach(struct bnxt *bp)
|
||||
{
|
||||
if (bnxt_ulp_cntxt_shared_session_enabled(bp->ulp_ctx)) {
|
||||
if (bp->tfp_shared.session) {
|
||||
tf_close_session(&bp->tfp_shared);
|
||||
bp->tfp_shared.session = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize an ULP session.
|
||||
* An ULP session will contain all the resources needed to support rte flow
|
||||
@ -360,7 +456,7 @@ ulp_ctx_session_open(struct bnxt *bp,
|
||||
}
|
||||
|
||||
resources = ¶ms.resources;
|
||||
rc = bnxt_ulp_tf_session_resources_get(bp, 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");
|
||||
@ -557,6 +653,9 @@ ulp_ctx_deinit(struct bnxt *bp,
|
||||
/* close the tf session */
|
||||
ulp_ctx_session_close(bp, session);
|
||||
|
||||
/* The shared session must be closed last. */
|
||||
ulp_ctx_shared_session_close(bp, session);
|
||||
|
||||
/* Free the contents */
|
||||
if (session->cfg_data) {
|
||||
rte_free(session->cfg_data);
|
||||
@ -601,6 +700,29 @@ ulp_ctx_init(struct bnxt *bp,
|
||||
goto error_deinit;
|
||||
}
|
||||
|
||||
rc = bnxt_ulp_cntxt_app_id_set(bp->ulp_ctx, bp->app_id);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Unable to set app_id for ULP init.\n");
|
||||
goto error_deinit;
|
||||
}
|
||||
|
||||
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);
|
||||
goto error_deinit;
|
||||
}
|
||||
|
||||
/*
|
||||
* Shared session must be created before first regular session but after
|
||||
* the ulp_ctx is valid.
|
||||
*/
|
||||
rc = ulp_ctx_shared_session_open(bp, session);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Unable to open shared session (%d)\n", rc);
|
||||
goto error_deinit;
|
||||
}
|
||||
|
||||
/* Open the ulp session. */
|
||||
rc = ulp_ctx_session_open(bp, session);
|
||||
if (rc)
|
||||
@ -677,6 +799,8 @@ ulp_ctx_attach(struct bnxt *bp,
|
||||
struct bnxt_ulp_session_state *session)
|
||||
{
|
||||
int32_t rc = 0;
|
||||
uint32_t flags, dev_id;
|
||||
uint8_t app_id;
|
||||
|
||||
/* Increment the ulp context data reference count usage. */
|
||||
bp->ulp_ctx->cfg_data = session->cfg_data;
|
||||
@ -685,6 +809,29 @@ ulp_ctx_attach(struct bnxt *bp,
|
||||
/* update the session details in bnxt tfp */
|
||||
bp->tfp.session = session->g_tfp->session;
|
||||
|
||||
/*
|
||||
* The supported flag will be set during the init. Use it now to
|
||||
* know if we should go through the attach.
|
||||
*/
|
||||
rc = bnxt_ulp_cntxt_app_id_get(bp->ulp_ctx, &app_id);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Unable to get the app id from ulp.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
rc = bnxt_ulp_cntxt_dev_id_get(bp->ulp_ctx, &dev_id);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Unable do get the dev_id.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
flags = bp->ulp_ctx->cfg_data->ulp_flags;
|
||||
if (ULP_APP_DEV_UNSUPPORTED_ENABLED(flags)) {
|
||||
BNXT_TF_DBG(ERR, "APP ID %d, Device ID: 0x%x not supported.\n",
|
||||
app_id, dev_id);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Create a TF Client */
|
||||
rc = ulp_ctx_session_open(bp, session);
|
||||
if (rc) {
|
||||
@ -1126,6 +1273,18 @@ bnxt_ulp_port_init(struct bnxt *bp)
|
||||
BNXT_TF_DBG(ERR, "Failed to attach the ulp context\n");
|
||||
goto jump_to_error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach to the shared session, must be called after the
|
||||
* ulp_ctx_attach in order to ensure that ulp data is available
|
||||
* for attaching.
|
||||
*/
|
||||
rc = ulp_ctx_shared_session_attach(bp, session);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR,
|
||||
"Failed attach to shared session (%d)", rc);
|
||||
goto jump_to_error;
|
||||
}
|
||||
} else {
|
||||
rc = bnxt_ulp_init(bp, session);
|
||||
if (rc) {
|
||||
@ -1224,6 +1383,9 @@ bnxt_ulp_port_deinit(struct bnxt *bp)
|
||||
|
||||
/* close the session associated with this port */
|
||||
ulp_ctx_detach(bp);
|
||||
|
||||
/* always detach/close shared after the session. */
|
||||
ulp_ctx_shared_session_detach(bp);
|
||||
} else {
|
||||
/* Perform ulp ctx deinit */
|
||||
bnxt_ulp_deinit(bp, session);
|
||||
@ -1264,6 +1426,31 @@ bnxt_ulp_cntxt_ptr2_mark_db_get(struct bnxt_ulp_context *ulp_ctx)
|
||||
return ulp_ctx->cfg_data->mark_tbl;
|
||||
}
|
||||
|
||||
bool
|
||||
bnxt_ulp_cntxt_shared_session_enabled(struct bnxt_ulp_context *ulp_ctx)
|
||||
{
|
||||
return ULP_SHARED_SESSION_IS_ENABLED(ulp_ctx->cfg_data->ulp_flags);
|
||||
}
|
||||
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_app_id_set(struct bnxt_ulp_context *ulp_ctx, uint8_t app_id)
|
||||
{
|
||||
if (!ulp_ctx)
|
||||
return -EINVAL;
|
||||
ulp_ctx->cfg_data->app_id = app_id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_app_id_get(struct bnxt_ulp_context *ulp_ctx, uint8_t *app_id)
|
||||
{
|
||||
/* Default APP id is zero */
|
||||
if (!ulp_ctx || !app_id)
|
||||
return -EINVAL;
|
||||
*app_id = ulp_ctx->cfg_data->app_id;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Function to set the device id of the hardware. */
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_dev_id_set(struct bnxt_ulp_context *ulp_ctx,
|
||||
@ -1341,6 +1528,30 @@ bnxt_ulp_cntxt_tbl_scope_id_set(struct bnxt_ulp_context *ulp_ctx,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Function to set the shared tfp session details from the ulp context. */
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_shared_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp)
|
||||
{
|
||||
if (!ulp) {
|
||||
BNXT_TF_DBG(ERR, "Invalid arguments\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ulp->g_shared_tfp = tfp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Function to get the shared tfp session details from the ulp context. */
|
||||
struct tf *
|
||||
bnxt_ulp_cntxt_shared_tfp_get(struct bnxt_ulp_context *ulp)
|
||||
{
|
||||
if (!ulp) {
|
||||
BNXT_TF_DBG(ERR, "Invalid arguments\n");
|
||||
return NULL;
|
||||
}
|
||||
return ulp->g_shared_tfp;
|
||||
}
|
||||
|
||||
/* Function to set the tfp session details from the ulp context. */
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp)
|
||||
|
@ -29,7 +29,13 @@
|
||||
|
||||
/* defines for the ulp_flags */
|
||||
#define BNXT_ULP_VF_REP_ENABLED 0x1
|
||||
#define BNXT_ULP_SHARED_SESSION_ENABLED 0x2
|
||||
#define BNXT_ULP_APP_DEV_UNSUPPORTED 0x4
|
||||
#define ULP_VF_REP_IS_ENABLED(flag) ((flag) & BNXT_ULP_VF_REP_ENABLED)
|
||||
#define ULP_SHARED_SESSION_IS_ENABLED(flag) ((flag) &\
|
||||
BNXT_ULP_SHARED_SESSION_ENABLED)
|
||||
#define ULP_APP_DEV_UNSUPPORTED_ENABLED(flag) ((flag) &\
|
||||
BNXT_ULP_APP_DEV_UNSUPPORTED)
|
||||
|
||||
enum bnxt_ulp_flow_mem_type {
|
||||
BNXT_ULP_FLOW_MEM_TYPE_INT = 0,
|
||||
@ -67,11 +73,13 @@ struct bnxt_ulp_data {
|
||||
#define BNXT_ULP_MAX_TUN_CACHE_ENTRIES 16
|
||||
struct bnxt_tun_cache_entry tun_tbl[BNXT_ULP_MAX_TUN_CACHE_ENTRIES];
|
||||
bool accum_stats;
|
||||
uint8_t app_id;
|
||||
};
|
||||
|
||||
struct bnxt_ulp_context {
|
||||
struct bnxt_ulp_data *cfg_data;
|
||||
struct tf *g_tfp;
|
||||
struct tf *g_shared_tfp;
|
||||
};
|
||||
|
||||
struct bnxt_ulp_pci_info {
|
||||
@ -86,6 +94,7 @@ struct bnxt_ulp_session_state {
|
||||
struct bnxt_ulp_pci_info pci_info;
|
||||
struct bnxt_ulp_data *cfg_data;
|
||||
struct tf *g_tfp;
|
||||
struct tf g_shared_tfp;
|
||||
uint32_t session_opened;
|
||||
};
|
||||
|
||||
@ -135,6 +144,14 @@ int32_t
|
||||
bnxt_ulp_cntxt_tbl_scope_id_get(struct bnxt_ulp_context *ulp_ctx,
|
||||
uint32_t *tbl_scope_id);
|
||||
|
||||
/* Function to set the tfp session details in the ulp context. */
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_shared_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
|
||||
|
||||
/* Function to get the tfp session details from ulp context. */
|
||||
struct tf *
|
||||
bnxt_ulp_cntxt_shared_tfp_get(struct bnxt_ulp_context *ulp);
|
||||
|
||||
/* Function to set the tfp session details in the ulp context. */
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_tfp_set(struct bnxt_ulp_context *ulp, struct tf *tfp);
|
||||
@ -233,4 +250,26 @@ bnxt_ulp_cntxt_release_fdb_lock(struct bnxt_ulp_context *ulp_ctx);
|
||||
int32_t
|
||||
ulp_post_process_tun_flow(struct ulp_rte_parser_params *params);
|
||||
|
||||
struct bnxt_ulp_glb_resource_info *
|
||||
bnxt_ulp_app_glb_resource_info_list_get(uint32_t *num_entries);
|
||||
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_app_id_set(struct bnxt_ulp_context *ulp_ctx, uint8_t app_id);
|
||||
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_app_id_get(struct bnxt_ulp_context *ulp_ctx, uint8_t *app_id);
|
||||
|
||||
bool
|
||||
bnxt_ulp_cntxt_shared_session_enabled(struct bnxt_ulp_context *ulp_ctx);
|
||||
|
||||
struct bnxt_ulp_app_capabilities_info *
|
||||
bnxt_ulp_app_cap_list_get(uint32_t *num_entries);
|
||||
|
||||
int32_t
|
||||
bnxt_ulp_cntxt_app_caps_init(struct bnxt_ulp_context *ulp_ctx,
|
||||
uint8_t app_id, uint32_t dev_id);
|
||||
|
||||
struct bnxt_ulp_resource_resv_info *
|
||||
bnxt_ulp_resource_resv_list_get(uint32_t *num_entries);
|
||||
|
||||
#endif /* _BNXT_ULP_H_ */
|
||||
|
@ -58,13 +58,15 @@ static int32_t
|
||||
ulp_mapper_glb_resource_read(struct bnxt_ulp_mapper_data *mapper_data,
|
||||
enum tf_dir dir,
|
||||
uint16_t idx,
|
||||
uint64_t *regval)
|
||||
uint64_t *regval,
|
||||
bool *shared)
|
||||
{
|
||||
if (!mapper_data || !regval ||
|
||||
if (!mapper_data || !regval || !shared ||
|
||||
dir >= TF_DIR_MAX || idx >= BNXT_ULP_GLB_RF_IDX_LAST)
|
||||
return -EINVAL;
|
||||
|
||||
*regval = mapper_data->glb_res_tbl[dir][idx].resource_hndl;
|
||||
*shared = mapper_data->glb_res_tbl[dir][idx].shared;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -78,7 +80,7 @@ ulp_mapper_glb_resource_read(struct bnxt_ulp_mapper_data *mapper_data,
|
||||
static int32_t
|
||||
ulp_mapper_glb_resource_write(struct bnxt_ulp_mapper_data *data,
|
||||
struct bnxt_ulp_glb_resource_info *res,
|
||||
uint64_t regval)
|
||||
uint64_t regval, bool shared)
|
||||
{
|
||||
struct bnxt_ulp_mapper_glb_resource_entry *ent;
|
||||
|
||||
@ -92,6 +94,7 @@ ulp_mapper_glb_resource_write(struct bnxt_ulp_mapper_data *data,
|
||||
ent->resource_func = res->resource_func;
|
||||
ent->resource_type = res->resource_type;
|
||||
ent->resource_hndl = regval;
|
||||
ent->shared = shared;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -129,8 +132,12 @@ ulp_mapper_resource_ident_allocate(struct bnxt_ulp_context *ulp_ctx,
|
||||
|
||||
/* entries are stored as big-endian format */
|
||||
regval = tfp_cpu_to_be_64((uint64_t)iparms.id);
|
||||
/* write to the mapper global resource */
|
||||
rc = ulp_mapper_glb_resource_write(mapper_data, glb_res, regval);
|
||||
/*
|
||||
* write to the mapper global resource
|
||||
* Shared resources are never allocated through this method, so the
|
||||
* shared flag is always false.
|
||||
*/
|
||||
rc = ulp_mapper_glb_resource_write(mapper_data, glb_res, regval, false);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Failed to write to global resource id\n");
|
||||
/* Free the identifier when update failed */
|
||||
@ -186,8 +193,12 @@ ulp_mapper_resource_index_tbl_alloc(struct bnxt_ulp_context *ulp_ctx,
|
||||
|
||||
/* entries are stored as big-endian format */
|
||||
regval = tfp_cpu_to_be_64((uint64_t)aparms.idx);
|
||||
/* write to the mapper global resource */
|
||||
rc = ulp_mapper_glb_resource_write(mapper_data, glb_res, regval);
|
||||
/*
|
||||
* write to the mapper global resource
|
||||
* Shared resources are never allocated through this method, so the
|
||||
* shared flag is always false.
|
||||
*/
|
||||
rc = ulp_mapper_glb_resource_write(mapper_data, glb_res, regval, false);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Failed to write to global resource id\n");
|
||||
/* Free the identifier when update failed */
|
||||
@ -963,6 +974,7 @@ ulp_mapper_field_process(struct bnxt_ulp_mapper_parms *parms,
|
||||
uint32_t update_flag = 0;
|
||||
uint64_t src1_val64;
|
||||
uint32_t port_id;
|
||||
bool shared;
|
||||
|
||||
/* process the field opcode */
|
||||
if (fld->field_opc != BNXT_ULP_FIELD_OPC_COND_OP) {
|
||||
@ -1244,9 +1256,8 @@ ulp_mapper_field_process(struct bnxt_ulp_mapper_parms *parms,
|
||||
return -EINVAL;
|
||||
}
|
||||
idx = tfp_be_to_cpu_16(idx);
|
||||
if (ulp_mapper_glb_resource_read(parms->mapper_data,
|
||||
dir,
|
||||
idx, ®val)) {
|
||||
if (ulp_mapper_glb_resource_read(parms->mapper_data, dir,
|
||||
idx, ®val, &shared)) {
|
||||
BNXT_TF_DBG(ERR, "%s global regfile[%d] read failed.\n",
|
||||
name, idx);
|
||||
return -EINVAL;
|
||||
@ -2215,6 +2226,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
|
||||
bool write = false;
|
||||
bool global = false;
|
||||
uint64_t act_rec_size;
|
||||
bool shared = false;
|
||||
|
||||
/* use the max size if encap is enabled */
|
||||
if (tbl->encap_num_fields)
|
||||
@ -2293,7 +2305,7 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
|
||||
if (ulp_mapper_glb_resource_read(parms->mapper_data,
|
||||
tbl->direction,
|
||||
tbl->tbl_operand,
|
||||
®val)) {
|
||||
®val, &shared)) {
|
||||
BNXT_TF_DBG(ERR,
|
||||
"Failed to get tbl idx from Global "
|
||||
"regfile[%d].\n",
|
||||
@ -2400,8 +2412,13 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
|
||||
regval = tfp_cpu_to_be_64(regval);
|
||||
|
||||
if (global) {
|
||||
/*
|
||||
* Shared resources are never allocated through this
|
||||
* method, so the shared flag is always false.
|
||||
*/
|
||||
rc = ulp_mapper_glb_resource_write(parms->mapper_data,
|
||||
&glb_res, regval);
|
||||
&glb_res, regval,
|
||||
false);
|
||||
} else {
|
||||
rc = ulp_regfile_write(parms->regfile,
|
||||
tbl->tbl_operand, regval);
|
||||
@ -2422,6 +2439,8 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
|
||||
sparms.data_sz_in_bytes = ULP_BITS_2_BYTE(tmplen);
|
||||
sparms.idx = index;
|
||||
sparms.tbl_scope_id = tbl_scope_id;
|
||||
if (shared)
|
||||
tfp = bnxt_ulp_cntxt_shared_tfp_get(parms->ulp_ctx);
|
||||
rc = tf_set_tbl_entry(tfp, &sparms);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR,
|
||||
@ -2469,6 +2488,9 @@ ulp_mapper_index_tbl_process(struct bnxt_ulp_mapper_parms *parms,
|
||||
}
|
||||
return rc;
|
||||
error:
|
||||
/* Shared resources are not freed */
|
||||
if (shared)
|
||||
return rc;
|
||||
/*
|
||||
* Free the allocated resource since we failed to either
|
||||
* write to the entry or link the flow
|
||||
@ -2810,7 +2832,8 @@ ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx,
|
||||
struct bnxt_ulp_mapper_data *mapper_data)
|
||||
{
|
||||
struct bnxt_ulp_glb_resource_info *glb_res;
|
||||
uint32_t num_glb_res_ids, idx;
|
||||
uint32_t num_glb_res_ids, idx, dev_id;
|
||||
uint8_t app_id;
|
||||
int32_t rc = 0;
|
||||
|
||||
glb_res = ulp_mapper_glb_resource_info_list_get(&num_glb_res_ids);
|
||||
@ -2819,8 +2842,25 @@ ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Iterate the global resources and process each one */
|
||||
for (idx = 0; idx < num_glb_res_ids; idx++) {
|
||||
if (dev_id != glb_res[idx].device_id ||
|
||||
glb_res[idx].app_id != app_id)
|
||||
continue;
|
||||
switch (glb_res[idx].resource_func) {
|
||||
case BNXT_ULP_RESOURCE_FUNC_IDENTIFIER:
|
||||
rc = ulp_mapper_resource_ident_allocate(ulp_ctx,
|
||||
@ -2844,6 +2884,104 @@ ulp_mapper_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx,
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Iterate over the shared resources assigned during tf_open_session and store
|
||||
* them in the global regfile with the shared flag.
|
||||
*/
|
||||
static int32_t
|
||||
ulp_mapper_app_glb_resource_info_init(struct bnxt_ulp_context *ulp_ctx,
|
||||
struct bnxt_ulp_mapper_data *mapper_data)
|
||||
{
|
||||
struct bnxt_ulp_glb_resource_info *glb_res;
|
||||
struct tf_get_session_info_parms sparms;
|
||||
uint32_t num_entries, i, dev_id, res;
|
||||
struct tf_resource_info *res_info;
|
||||
uint64_t regval;
|
||||
enum tf_dir dir;
|
||||
int32_t rc = 0;
|
||||
struct tf *tfp;
|
||||
uint8_t app_id;
|
||||
|
||||
memset(&sparms, 0, sizeof(sparms));
|
||||
|
||||
glb_res = bnxt_ulp_app_glb_resource_info_list_get(&num_entries);
|
||||
if (!glb_res || !num_entries) {
|
||||
BNXT_TF_DBG(ERR, "Invalid Arguments\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
tfp = bnxt_ulp_cntxt_shared_tfp_get(ulp_ctx);
|
||||
if (!tfp) {
|
||||
BNXT_TF_DBG(ERR, "Failed to get tfp for app global init");
|
||||
return -EINVAL;
|
||||
}
|
||||
/*
|
||||
* Retrieve the resources that were assigned during the shared session
|
||||
* creation.
|
||||
*/
|
||||
rc = tf_get_session_info(tfp, &sparms);
|
||||
if (rc) {
|
||||
BNXT_TF_DBG(ERR, "Failed to get session info (%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);
|
||||
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);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Store all the app global resources */
|
||||
for (i = 0; i < num_entries; i++) {
|
||||
if (dev_id != glb_res[i].device_id ||
|
||||
app_id != glb_res[i].app_id)
|
||||
continue;
|
||||
dir = glb_res[i].direction;
|
||||
res = glb_res[i].resource_type;
|
||||
|
||||
switch (glb_res[i].resource_func) {
|
||||
case BNXT_ULP_RESOURCE_FUNC_IDENTIFIER:
|
||||
res_info = &sparms.session_info.ident[dir].info[res];
|
||||
break;
|
||||
case BNXT_ULP_RESOURCE_FUNC_INDEX_TABLE:
|
||||
res_info = &sparms.session_info.tbl[dir].info[res];
|
||||
break;
|
||||
case BNXT_ULP_RESOURCE_FUNC_TCAM_TABLE:
|
||||
res_info = &sparms.session_info.tcam[dir].info[res];
|
||||
break;
|
||||
case BNXT_ULP_RESOURCE_FUNC_EM_TABLE:
|
||||
res_info = &sparms.session_info.em[dir].info[res];
|
||||
break;
|
||||
default:
|
||||
BNXT_TF_DBG(ERR, "Unknown resource func (0x%x)\n",
|
||||
glb_res[i].resource_func);
|
||||
continue;
|
||||
}
|
||||
|
||||
regval = tfp_cpu_to_be_64((uint64_t)res_info->start);
|
||||
res_info->start++;
|
||||
|
||||
/*
|
||||
* All resources written to the global regfile are shared for
|
||||
* this function.
|
||||
*/
|
||||
rc = ulp_mapper_glb_resource_write(mapper_data, &glb_res[i],
|
||||
regval, true);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common conditional opcode process routine that is used for both the template
|
||||
* rejection and table conditional execution.
|
||||
@ -2994,6 +3132,7 @@ ulp_mapper_cc_upd_opr_compute(struct bnxt_ulp_mapper_parms *parms,
|
||||
uint64_t *result)
|
||||
{
|
||||
uint64_t regval;
|
||||
bool shared;
|
||||
|
||||
*result = false;
|
||||
switch (cc_src) {
|
||||
@ -3013,7 +3152,7 @@ ulp_mapper_cc_upd_opr_compute(struct bnxt_ulp_mapper_parms *parms,
|
||||
break;
|
||||
case BNXT_ULP_CC_UPD_SRC_GLB_REGFILE:
|
||||
if (ulp_mapper_glb_resource_read(parms->mapper_data, dir,
|
||||
cc_opr, ®val)) {
|
||||
cc_opr, ®val, &shared)) {
|
||||
BNXT_TF_DBG(ERR, "global regfile[%d] read failed.\n",
|
||||
cc_opr);
|
||||
return -EINVAL;
|
||||
@ -3493,11 +3632,11 @@ ulp_mapper_glb_resource_info_deinit(struct bnxt_ulp_context *ulp_ctx,
|
||||
|
||||
/* Iterate the global resources and process each one */
|
||||
for (dir = TF_DIR_RX; dir < TF_DIR_MAX; dir++) {
|
||||
for (idx = 0; idx < BNXT_ULP_GLB_RESOURCE_TBL_MAX_SZ;
|
||||
idx++) {
|
||||
for (idx = 0; idx < BNXT_ULP_GLB_RF_IDX_LAST; idx++) {
|
||||
ent = &mapper_data->glb_res_tbl[dir][idx];
|
||||
if (ent->resource_func ==
|
||||
BNXT_ULP_RESOURCE_FUNC_INVALID)
|
||||
BNXT_ULP_RESOURCE_FUNC_INVALID ||
|
||||
ent->shared)
|
||||
continue;
|
||||
memset(&res, 0, sizeof(struct ulp_flow_db_res_params));
|
||||
res.resource_func = ent->resource_func;
|
||||
@ -3673,6 +3812,19 @@ ulp_mapper_init(struct bnxt_ulp_context *ulp_ctx)
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Only initialize the app global resources if a shared session was
|
||||
* created.
|
||||
*/
|
||||
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");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
||||
/* Allocate the generic table list */
|
||||
rc = ulp_mapper_generic_tbl_list_init(data);
|
||||
if (rc) {
|
||||
|
@ -22,6 +22,7 @@ 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;
|
||||
};
|
||||
|
||||
struct bnxt_ulp_mapper_data {
|
||||
|
@ -26,8 +26,10 @@
|
||||
#define BNXT_ULP_ACT_HID_SHFTR 27
|
||||
#define BNXT_ULP_ACT_HID_SHFTL 26
|
||||
#define BNXT_ULP_ACT_HID_MASK 2047
|
||||
#define BNXT_ULP_GLB_RESOURCE_TBL_MAX_SZ 11
|
||||
#define BNXT_ULP_APP_GLB_RESOURCE_TBL_MAX_SZ 10
|
||||
#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_CAP_TBL_MAX_SZ 2
|
||||
#define BNXT_ULP_COND_GOTO_REJECT 1023
|
||||
#define BNXT_ULP_COND_GOTO_RF 0x10000
|
||||
#define BNXT_ULP_GLB_FIELD_TBL_SHIFT 7
|
||||
@ -348,7 +350,8 @@ enum bnxt_ulp_glb_rf_idx {
|
||||
BNXT_ULP_GLB_RF_IDX_APP_GLB_WC_PROFILE_ID_0 = 9,
|
||||
BNXT_ULP_GLB_RF_IDX_APP_GLB_EM_KEY_ID_0 = 10,
|
||||
BNXT_ULP_GLB_RF_IDX_APP_GLB_WC_KEY_ID_0 = 11,
|
||||
BNXT_ULP_GLB_RF_IDX_LAST = 12
|
||||
BNXT_ULP_GLB_RF_IDX_APP_GLB_L2_CNTXT_ID_1 = 12,
|
||||
BNXT_ULP_GLB_RF_IDX_LAST = 13
|
||||
};
|
||||
|
||||
enum bnxt_ulp_hdr_type {
|
||||
@ -476,6 +479,10 @@ enum bnxt_ulp_template_type {
|
||||
BNXT_ULP_TEMPLATE_TYPE_LAST = 2
|
||||
};
|
||||
|
||||
enum bnxt_ulp_app_cap {
|
||||
BNXT_ULP_APP_CAP_SHARED_EN = 0x00000001
|
||||
};
|
||||
|
||||
enum bnxt_ulp_fdb_resource_flags {
|
||||
BNXT_ULP_FDB_RESOURCE_FLAGS_DIR_INGR = 0x00,
|
||||
BNXT_ULP_FDB_RESOURCE_FLAGS_DIR_EGR = 0x01
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -312,11 +312,27 @@ struct bnxt_ulp_mapper_ident_info {
|
||||
};
|
||||
|
||||
struct bnxt_ulp_glb_resource_info {
|
||||
uint8_t app_id;
|
||||
enum bnxt_ulp_device_id device_id;
|
||||
enum tf_dir direction;
|
||||
enum bnxt_ulp_resource_func resource_func;
|
||||
uint32_t resource_type; /* TF_ enum type */
|
||||
enum bnxt_ulp_glb_rf_idx glb_regfile_index;
|
||||
};
|
||||
|
||||
struct bnxt_ulp_resource_resv_info {
|
||||
uint8_t app_id;
|
||||
enum bnxt_ulp_device_id device_id;
|
||||
enum tf_dir direction;
|
||||
enum bnxt_ulp_resource_func resource_func;
|
||||
uint32_t resource_type; /* TF_ enum type */
|
||||
uint32_t count;
|
||||
};
|
||||
|
||||
struct bnxt_ulp_app_capabilities_info {
|
||||
uint8_t app_id;
|
||||
enum bnxt_ulp_device_id device_id;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
struct bnxt_ulp_cache_tbl_params {
|
||||
@ -361,6 +377,23 @@ extern uint32_t ulp_act_prop_map_table[];
|
||||
*/
|
||||
extern struct bnxt_ulp_glb_resource_info ulp_glb_resource_tbl[];
|
||||
|
||||
/*
|
||||
* The ulp_app_glb_resource_tbl provides the list of shared resources required
|
||||
* in the event that shared session is enabled.
|
||||
*/
|
||||
extern struct bnxt_ulp_glb_resource_info ulp_app_glb_resource_tbl[];
|
||||
|
||||
/*
|
||||
* The ulp_resource_resv_list provides the list of tf resources required when
|
||||
* calling tf_open.
|
||||
*/
|
||||
extern struct bnxt_ulp_resource_resv_info ulp_resource_resv_list[];
|
||||
|
||||
/*
|
||||
* The_app_cap_info_list provides the list of ULP capabilities per app/device.
|
||||
*/
|
||||
extern struct bnxt_ulp_app_capabilities_info ulp_app_cap_info_list[];
|
||||
|
||||
/*
|
||||
* The ulp_cache_tbl_parms table provides the sizes of the cache tables the
|
||||
* mapper must dynamically allocate during initialization.
|
||||
|
Loading…
Reference in New Issue
Block a user