From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3F6CDA0C45; Wed, 1 Sep 2021 16:26:16 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B61914119A; Wed, 1 Sep 2021 16:25:11 +0200 (CEST) Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id 93F4341195 for ; Wed, 1 Sep 2021 16:25:10 +0200 (CEST) Received: from S60.dhcp.broadcom.net (unknown [10.123.66.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 2DB382E2D4; Wed, 1 Sep 2021 07:25:08 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 2DB382E2D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1630506310; bh=+z0pV8k9ZdjXszHHwF9QL8v7jGd+UhxrgXHRJw7T9yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RSAJUK3hmsOwS3utKF4UeMDLZ/MQcpC6tuRFJ/ZdTiFpNPmxnjImBKE0BDnaaKGkF MWVecM4hrYRtY96Ygu5wVyrNsiYIB3r0jPtFNDVsDs0AJFwYRSQ1aoq+30QCVz4x9c 7TGrNhYMYTp/4cVY1+uxMIEMqeIPeNtRpfJUqc0A= From: Venkat Duvvuru To: dev@dpdk.org Cc: Venkat Duvvuru Date: Wed, 1 Sep 2021 19:54:33 +0530 Message-Id: <20210901142433.8444-15-venkatkumar.duvvuru@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210901142433.8444-1-venkatkumar.duvvuru@broadcom.com> References: <20210901142433.8444-1-venkatkumar.duvvuru@broadcom.com> Subject: [dpdk-dev] [PATCH 14/14] net/bnxt: add support for testpmd co-existence X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Reviewed-by: Kishore Padmanabha --- 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(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 494a1eff37..c9adc66fda 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -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 diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index de34a2f0bb..20c5b12b53 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -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. diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 3b86410fb1..2ad662fb17 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -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. diff --git a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c index d8336d164e..827fe30acd 100644 --- a/drivers/net/bnxt/tf_ulp/ulp_def_rules.c +++ b/drivers/net/bnxt/tf_ulp/ulp_def_rules.c @@ -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; } -- 2.17.1