Currently, testpmd support in ULP is enabled only during compilation
time. This patch adds support for testpmd during runtime using
devarg "testpmd".
Signed-off-by: Venkat Duvvuru <venkatkumar.duvvuru@broadcom.com>
Reviewed-by: Kishore Padmanabha <kishore.padmanabha@broadcom.com>
---
drivers/net/bnxt/bnxt.h | 3 ++
drivers/net/bnxt/bnxt_ethdev.c | 56 +++++++++++++++++++++++++
drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 5 +++
drivers/net/bnxt/tf_ulp/ulp_def_rules.c | 4 +-
4 files changed, 67 insertions(+), 1 deletion(-)
@@ -722,6 +722,9 @@ struct bnxt {
((bp)->flags2 & BNXT_FLAGS2_PTP_TIMESYNC_ENABLED)
#define BNXT_ACCUM_STATS_EN(bp) \
((bp)->flags2 & BNXT_FLAGS2_ACCUM_STATS_EN)
+#define BNXT_FLAGS2_TESTPMD_EN BIT(3)
+#define BNXT_TESTPMD_EN(bp) \
+ ((bp)->flags2 & BNXT_FLAGS2_TESTPMD_EN)
uint16_t chip_num;
#define CHIP_NUM_58818 0xd818
@@ -98,6 +98,7 @@ static const struct rte_pci_id bnxt_pci_id_map[] = {
#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"
+#define BNXT_DEVARG_TESTPMD "testpmd"
static const char *const bnxt_dev_args[] = {
BNXT_DEVARG_REPRESENTOR,
@@ -111,9 +112,17 @@ static const char *const bnxt_dev_args[] = {
BNXT_DEVARG_REP_FC_R2F,
BNXT_DEVARG_REP_FC_F2R,
BNXT_DEVARG_APP_ID,
+ BNXT_DEVARG_TESTPMD,
NULL
};
+/*
+ * testpmd == false to disable
+ * testpmd == true to enable
+ */
+#define BNXT_DEVARG_TESTPMD_INVALID(truflow) ((testpmd) > 1)
+
+
/*
* accum-stats == false to disable flow counter accumulation
* accum-stats == true to enable flow counter accumulation
@@ -5853,6 +5862,44 @@ bnxt_parse_devarg_rep_fc_f2r(__rte_unused const char *key,
return 0;
}
+static int
+bnxt_parse_devarg_testpmd(__rte_unused const char *key,
+ const char *value, void *opaque_arg)
+{
+ struct bnxt *bp = opaque_arg;
+ unsigned long testpmd;
+ char *end = NULL;
+
+ if (!value || !opaque_arg) {
+ PMD_DRV_LOG(ERR,
+ "Invalid parameter passed to testpmd devargs.\n");
+ return -EINVAL;
+ }
+
+ testpmd = strtoul(value, &end, 10);
+ if (end == NULL || *end != '\0' ||
+ (testpmd == ULONG_MAX && errno == ERANGE)) {
+ PMD_DRV_LOG(ERR,
+ "Invalid parameter passed to testpmd devargs.\n");
+ return -EINVAL;
+ }
+
+ if (BNXT_DEVARG_TESTPMD_INVALID(testpmd)) {
+ PMD_DRV_LOG(ERR,
+ "Invalid value passed to testpmd devargs.\n");
+ return -EINVAL;
+ }
+
+ if (testpmd) {
+ bp->flags2 |= BNXT_FLAGS2_TESTPMD_EN;
+ PMD_DRV_LOG(INFO, "Host-based testpmd feature enabled.\n");
+ } else {
+ bp->flags2 &= ~BNXT_FLAGS2_TESTPMD_EN;
+ PMD_DRV_LOG(INFO, "Host-based testpmd feature disabled.\n");
+ }
+
+ return 0;
+}
static int
bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs *devargs)
{
@@ -5890,6 +5937,15 @@ bnxt_parse_dev_args(struct bnxt *bp, struct rte_devargs *devargs)
if (ret)
goto err;
+ /*
+ * Handler for "testpmd" devarg.
+ * Invoked as for ex: "-a 0000:00:0d.0,testpmd=1"
+ */
+ ret = rte_kvargs_process(kvlist, BNXT_DEVARG_TESTPMD,
+ bnxt_parse_devarg_testpmd, bp);
+ if (ret)
+ goto err;
+
err:
/*
* Handler for "app-id" devarg.
@@ -844,6 +844,11 @@ ulp_ctx_init(struct bnxt *bp,
goto error_deinit;
}
+ if (BNXT_TESTPMD_EN(bp)) {
+ ulp_data->ulp_flags &= ~BNXT_ULP_VF_REP_ENABLED;
+ BNXT_TF_DBG(ERR, "Enabled Testpmd forward mode\n");
+ }
+
/*
* Shared session must be created before first regular session but after
* the ulp_ctx is valid.
@@ -526,8 +526,10 @@ bnxt_ulp_create_df_rules(struct bnxt *bp)
rc = ulp_default_flow_db_cfa_action_get(bp->ulp_ctx,
info->def_port_flow_id,
&bp->tx_cfa_action);
- if (rc)
+
+ if (rc || BNXT_TESTPMD_EN(bp))
bp->tx_cfa_action = 0;
+
info->valid = true;
return 0;
}