From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id DEB33A0521; Thu, 23 Jul 2020 14:02:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7ADE71BFEE; Thu, 23 Jul 2020 14:02:07 +0200 (CEST) Received: from relay.smtp.broadcom.com (unknown [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id CB2AF199BC for ; Thu, 23 Jul 2020 14:02:02 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (bgccx-dev-host-lnx35.bec.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 04E2029ADAA; Thu, 23 Jul 2020 05:02:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 04E2029ADAA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1595505722; bh=FMmNgzDbl6rcEIhLU2aGORtfWDAltJXPilEScotj3Bg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CYbiRLxEor0uOX462N5ntk3LiBkZkRu+6zhEyaFWm8BrtM25z3ymbSbslRvQotxiL 0+rEpqxBHWOp9bn1Zv2gt9yXm8eSKZnF8Hs8gxsxjF9umpfmlkSV/DpVgTm3VcqDLl 5tA0Vf56hdpEv7ngEv+k5QRzfS8xUzxlC5621Jkg= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 23 Jul 2020 17:26:21 +0530 Message-Id: <20200723115639.22357-3-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200723115639.22357-1-somnath.kotur@broadcom.com> References: <20200723111329.21855-1-somnath.kotur@broadcom.com> <20200723115639.22357-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH v2 02/20] net/bnxt: nat global registers support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" From: Kishore Padmanabha Add support to enable or disable the NAT global registers. The NAT feature is enabled in hardware during initialization and disabled at deinitialization of the application. Signed-off-by: Kishore Padmanabha Reviewed-by: Michael Baucom --- drivers/net/bnxt/tf_ulp/bnxt_ulp.c | 83 ++++++++++++++++++++++++++++++++++++++ drivers/net/bnxt/tf_ulp/bnxt_ulp.h | 4 ++ 2 files changed, 87 insertions(+) diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c index 0869231..7c65a4b 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.c +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.c @@ -597,6 +597,52 @@ ulp_session_deinit(struct bnxt_ulp_session_state *session) } /* + * Internal api to enable NAT feature. + * Set set_flag to 1 to set the value or zero to reset the value. + * returns 0 on success. + */ +static int32_t +bnxt_ulp_global_cfg_update(struct bnxt *bp, + enum tf_dir dir, + enum tf_global_config_type type, + uint32_t offset, + uint32_t value, + uint32_t set_flag) +{ + uint32_t global_cfg = 0; + int rc; + struct tf_global_cfg_parms parms; + + /* Initialize the params */ + parms.dir = dir, + parms.type = type, + parms.offset = offset, + parms.config = (uint8_t *)&global_cfg, + parms.config_sz_in_bytes = sizeof(global_cfg); + + rc = tf_get_global_cfg(&bp->tfp, &parms); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to get global cfg 0x%x rc:%d\n", + type, rc); + return rc; + } + + if (set_flag) + global_cfg |= value; + else + global_cfg &= ~value; + + /* SET the register RE_CFA_REG_ACT_TECT */ + rc = tf_set_global_cfg(&bp->tfp, &parms); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to set global cfg 0x%x rc:%d\n", + type, rc); + return rc; + } + return rc; +} + +/* * When a port is initialized by dpdk. This functions is called * and this function initializes the ULP context and rest of the * infrastructure associated with it. @@ -732,6 +778,29 @@ bnxt_ulp_init(struct bnxt *bp) goto jump_to_error; } + /* + * Enable NAT feature. Set the global configuration register + * Tunnel encap to enable NAT with the reuse of existing inner + * L2 header smac and dmac + */ + rc = bnxt_ulp_global_cfg_update(bp, TF_DIR_RX, TF_TUNNEL_ENCAP, + TF_TUNNEL_ENCAP_NAT, + (BNXT_ULP_NAT_INNER_L2_HEADER_SMAC | + BNXT_ULP_NAT_INNER_L2_HEADER_DMAC), 1); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to set rx global configuration\n"); + goto jump_to_error; + } + + rc = bnxt_ulp_global_cfg_update(bp, TF_DIR_TX, TF_TUNNEL_ENCAP, + TF_TUNNEL_ENCAP_NAT, + (BNXT_ULP_NAT_INNER_L2_HEADER_SMAC | + BNXT_ULP_NAT_INNER_L2_HEADER_DMAC), 1); + if (rc) { + BNXT_TF_DBG(ERR, "Failed to set tx global configuration\n"); + goto jump_to_error; + } + return rc; jump_to_error: @@ -785,6 +854,19 @@ bnxt_ulp_deinit(struct bnxt *bp) /* Delete the Port database */ ulp_port_db_deinit(bp->ulp_ctx); + /* Disable NAT feature */ + (void)bnxt_ulp_global_cfg_update(bp, TF_DIR_RX, TF_TUNNEL_ENCAP, + TF_TUNNEL_ENCAP_NAT, + (BNXT_ULP_NAT_INNER_L2_HEADER_SMAC | + BNXT_ULP_NAT_INNER_L2_HEADER_DMAC), + 0); + + (void)bnxt_ulp_global_cfg_update(bp, TF_DIR_TX, TF_TUNNEL_ENCAP, + TF_TUNNEL_ENCAP_NAT, + (BNXT_ULP_NAT_INNER_L2_HEADER_SMAC | + BNXT_ULP_NAT_INNER_L2_HEADER_DMAC), + 0); + /* Delete the ulp context and tf session */ ulp_ctx_detach(bp, session); @@ -942,6 +1024,7 @@ bnxt_ulp_eth_dev_ptr2_cntxt_get(struct rte_eth_dev *dev) if (BNXT_ETH_DEV_IS_REPRESENTOR(dev)) { struct bnxt_vf_representor *vfr = dev->data->dev_private; + bp = vfr->parent_dev->data->dev_private; } diff --git a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h index f9e5e2b..7c95ead 100644 --- a/drivers/net/bnxt/tf_ulp/bnxt_ulp.h +++ b/drivers/net/bnxt/tf_ulp/bnxt_ulp.h @@ -14,6 +14,10 @@ #include "ulp_template_db_enum.h" +/* NAT defines to reuse existing inner L2 SMAC and DMAC */ +#define BNXT_ULP_NAT_INNER_L2_HEADER_SMAC 0x2000 +#define BNXT_ULP_NAT_INNER_L2_HEADER_DMAC 0x100 + /* defines for the ulp_flags */ #define BNXT_ULP_VF_REP_ENABLED 0x1 #define ULP_VF_REP_IS_ENABLED(flag) ((flag) & BNXT_ULP_VF_REP_ENABLED) -- 2.7.4