From patchwork Thu Jul 23 11:13:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Somnath Kotur X-Patchwork-Id: 74652 X-Patchwork-Delegate: ajit.khaparde@broadcom.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 79F1CA0521; Thu, 23 Jul 2020 13:21:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5B21C1C02E; Thu, 23 Jul 2020 13:20:04 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id 21D941C027 for ; Thu, 23 Jul 2020 13:19:14 +0200 (CEST) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) by relay.smtp.broadcom.com (Postfix) with ESMTP id 7326D1BD9B4; Thu, 23 Jul 2020 04:19:13 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 7326D1BD9B4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1595503154; bh=raQDN1gOVoNNo3SNeK+X0k1HcSLTmpsZ7SWCITvD9wc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XJEAh2mCvel1PN/06wXfqC73GdRX/ZA0XCRkB9kkbzJFl0hEmcfRWWce5WlEla+O0 0wPC/Mu5UuGTRngtX5jP7mNT3ZnzC5/aR+DxvxTf2do5qwz56WQ1TDXpFMzQyEIepr PLOtQhQPiVIxdvKtAFJk2o2Xf9dBasySA5HdpUhc= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 23 Jul 2020 16:43:24 +0530 Message-Id: <20200723111329.21855-16-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20200723111329.21855-1-somnath.kotur@broadcom.com> References: <20200723111329.21855-1-somnath.kotur@broadcom.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH 15/20] net/bnxt: delete VF FW rules when a representor is created 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: Venkat Duvvuru Truflow stack adds VFR to VF and VF to VFR conduits when VF representor is created. However, in the ingress direction the VF's fw rules conflict with Truflow rules, resulting in not hitting the Truflow VFR rules. To fix this, fw is going to remove it’s VF rules when vf representor is created in Truflow mode and will restore the removed rules when vf representor is destroyed. This patch invokes the vf representor alloc and free hwrm commands as part of which fw will do the above mentioned actions. Signed-off-by: Venkat Duvvuru Signed-off-by: Somnath Kotur Reviewed-by: Shahaji Bhosle --- drivers/net/bnxt/bnxt_hwrm.c | 49 ++++++++++++ drivers/net/bnxt/bnxt_hwrm.h | 2 + drivers/net/bnxt/bnxt_reps.c | 19 ++++- drivers/net/bnxt/hsi_struct_def_dpdk.h | 138 +++++++++++++++++++++++++++++++++ 4 files changed, 205 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index 7ea13a8..f5f0dfe 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -5486,6 +5486,55 @@ int bnxt_hwrm_cfa_counter_qstats(struct bnxt *bp, return 0; } +int bnxt_hwrm_cfa_vfr_alloc(struct bnxt *bp, uint16_t vf_idx) +{ + struct hwrm_cfa_vfr_alloc_output *resp = bp->hwrm_cmd_resp_addr; + struct hwrm_cfa_vfr_alloc_input req = {0}; + int rc; + + if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) { + PMD_DRV_LOG(DEBUG, + "Not a PF or trusted VF. Command not supported\n"); + return 0; + } + + HWRM_PREP(&req, HWRM_CFA_VFR_ALLOC, BNXT_USE_CHIMP_MB); + req.vf_id = rte_cpu_to_le_16(vf_idx); + snprintf(req.vfr_name, sizeof(req.vfr_name), "%svfr%d", + bp->eth_dev->data->name, vf_idx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB); + HWRM_CHECK_RESULT(); + + HWRM_UNLOCK(); + PMD_DRV_LOG(DEBUG, "VFR %d allocated\n", vf_idx); + return rc; +} + +int bnxt_hwrm_cfa_vfr_free(struct bnxt *bp, uint16_t vf_idx) +{ + struct hwrm_cfa_vfr_free_output *resp = bp->hwrm_cmd_resp_addr; + struct hwrm_cfa_vfr_free_input req = {0}; + int rc; + + if (!(BNXT_PF(bp) || BNXT_VF_IS_TRUSTED(bp))) { + PMD_DRV_LOG(DEBUG, + "Not a PF or trusted VF. Command not supported\n"); + return 0; + } + + HWRM_PREP(&req, HWRM_CFA_VFR_FREE, BNXT_USE_CHIMP_MB); + req.vf_id = rte_cpu_to_le_16(vf_idx); + snprintf(req.vfr_name, sizeof(req.vfr_name), "%svfr%d", + bp->eth_dev->data->name, vf_idx); + + rc = bnxt_hwrm_send_message(bp, &req, sizeof(req), BNXT_USE_CHIMP_MB); + HWRM_CHECK_RESULT(); + HWRM_UNLOCK(); + PMD_DRV_LOG(DEBUG, "VFR %d freed\n", vf_idx); + return rc; +} + #ifdef RTE_LIBRTE_BNXT_PMD_SYSTEM int bnxt_hwrm_oem_cmd(struct bnxt *bp, uint32_t entry_num) diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 01201a7..4a2af13 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -278,4 +278,6 @@ int bnxt_hwrm_port_phy_qcaps(struct bnxt *bp); int bnxt_hwrm_oem_cmd(struct bnxt *bp, uint32_t entry_num); int bnxt_clear_one_vnic_filter(struct bnxt *bp, struct bnxt_filter_info *filter); +int bnxt_hwrm_cfa_vfr_alloc(struct bnxt *bp, uint16_t vf_idx); +int bnxt_hwrm_cfa_vfr_free(struct bnxt *bp, uint16_t vf_idx); #endif diff --git a/drivers/net/bnxt/bnxt_reps.c b/drivers/net/bnxt/bnxt_reps.c index c425e69..2f775e0 100644 --- a/drivers/net/bnxt/bnxt_reps.c +++ b/drivers/net/bnxt/bnxt_reps.c @@ -272,7 +272,7 @@ static int bnxt_tf_vfr_alloc(struct rte_eth_dev *vfr_ethdev) if (rc) { BNXT_TF_DBG(DEBUG, "Default flow rule creation for VFR->VF failed!\n"); - return -EIO; + goto err; } BNXT_TF_DBG(DEBUG, "*** Default flow rule created for VFR->VF! ***\n"); @@ -283,7 +283,7 @@ static int bnxt_tf_vfr_alloc(struct rte_eth_dev *vfr_ethdev) if (rc) { BNXT_TF_DBG(DEBUG, "Failed to get action_ptr for VFR->VF dflt rule\n"); - return -EIO; + goto rep2vf_free; } BNXT_TF_DBG(DEBUG, "tx_cfa_action = %d\n", vfr->vfr_tx_cfa_action); rc = ulp_default_flow_create(parent_dev, param_list, @@ -292,13 +292,24 @@ static int bnxt_tf_vfr_alloc(struct rte_eth_dev *vfr_ethdev) if (rc) { BNXT_TF_DBG(DEBUG, "Default flow rule creation for VF->VFR failed!\n"); - return -EIO; + goto rep2vf_free; } BNXT_TF_DBG(DEBUG, "*** Default flow rule created for VF->VFR! ***\n"); BNXT_TF_DBG(DEBUG, "vfr2rep_flow_id = %d\n", vfr->vf2rep_flow_id); + rc = bnxt_hwrm_cfa_vfr_alloc(parent_bp, vfr->vf_id); + if (rc) + goto vf2rep_free; + return 0; + +vf2rep_free: + ulp_default_flow_destroy(vfr->parent_dev, vfr->vf2rep_flow_id); +rep2vf_free: + ulp_default_flow_destroy(vfr->parent_dev, vfr->rep2vf_flow_id); +err: + return -EIO; } static int bnxt_vfr_alloc(struct rte_eth_dev *vfr_ethdev) @@ -414,6 +425,8 @@ static int bnxt_vfr_free(struct bnxt_vf_representor *vfr) vfr->vfr_tx_cfa_action = 0; vfr->rx_cfa_code = 0; + rc = bnxt_hwrm_cfa_vfr_free(parent_bp, vfr->vf_id); + return rc; } diff --git a/drivers/net/bnxt/hsi_struct_def_dpdk.h b/drivers/net/bnxt/hsi_struct_def_dpdk.h index 598da71..3553935 100644 --- a/drivers/net/bnxt/hsi_struct_def_dpdk.h +++ b/drivers/net/bnxt/hsi_struct_def_dpdk.h @@ -35127,6 +35127,144 @@ struct hwrm_cfa_pair_info_output { uint8_t valid; } __rte_packed; +/********************** + * hwrm_cfa_vfr_alloc * + **********************/ + + +/* hwrm_cfa_vfr_alloc_input (size:448b/56B) */ +struct hwrm_cfa_vfr_alloc_input { + /* The HWRM command request type. */ + uint16_t req_type; + /* + * The completion ring to send the completion event on. This should + * be the NQ ID returned from the `nq_alloc` HWRM command. + */ + uint16_t cmpl_ring; + /* + * The sequence ID is used by the driver for tracking multiple + * commands. This ID is treated as opaque data by the firmware and + * the value is returned in the `hwrm_resp_hdr` upon completion. + */ + uint16_t seq_id; + /* + * The target ID of the command: + * * 0x0-0xFFF8 - The function ID + * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors + * * 0xFFFD - Reserved for user-space HWRM interface + * * 0xFFFF - HWRM + */ + uint16_t target_id; + /* + * A physical address pointer pointing to a host buffer that the + * command's response data will be written. This can be either a host + * physical address (HPA) or a guest physical address (GPA) and must + * point to a physically contiguous block of memory. + */ + uint64_t resp_addr; + /* Logical VF number (range: 0 -> MAX_VFS -1). */ + uint16_t vf_id; + /* + * This field is reserved for the future use. + * It shall be set to 0. + */ + uint16_t reserved; + uint8_t unused_0[4]; + /* VF Representor name (32 byte string). */ + char vfr_name[32]; +} __attribute__((packed)); + +/* hwrm_cfa_vfr_alloc_output (size:128b/16B) */ +struct hwrm_cfa_vfr_alloc_output { + /* The specific error status for the command. */ + uint16_t error_code; + /* The HWRM command request type. */ + uint16_t req_type; + /* The sequence ID from the original command. */ + uint16_t seq_id; + /* The length of the response data in number of bytes. */ + uint16_t resp_len; + /* Rx CFA code. */ + uint16_t rx_cfa_code; + /* Tx CFA action. */ + uint16_t tx_cfa_action; + uint8_t unused_0[3]; + /* + * This field is used in Output records to indicate that the output + * is completely written to RAM. This field should be read as '1' + * to indicate that the output has been completely written. + * When writing a command completion or response to an internal processor, + * the order of writes has to be such that this field is written last. + */ + uint8_t valid; +} __attribute__((packed)); + +/********************* + * hwrm_cfa_vfr_free * + *********************/ + + +/* hwrm_cfa_vfr_free_input (size:448b/56B) */ +struct hwrm_cfa_vfr_free_input { + /* The HWRM command request type. */ + uint16_t req_type; + /* + * The completion ring to send the completion event on. This should + * be the NQ ID returned from the `nq_alloc` HWRM command. + */ + uint16_t cmpl_ring; + /* + * The sequence ID is used by the driver for tracking multiple + * commands. This ID is treated as opaque data by the firmware and + * the value is returned in the `hwrm_resp_hdr` upon completion. + */ + uint16_t seq_id; + /* + * The target ID of the command: + * * 0x0-0xFFF8 - The function ID + * * 0xFFF8-0xFFFC, 0xFFFE - Reserved for internal processors + * * 0xFFFD - Reserved for user-space HWRM interface + * * 0xFFFF - HWRM + */ + uint16_t target_id; + /* + * A physical address pointer pointing to a host buffer that the + * command's response data will be written. This can be either a host + * physical address (HPA) or a guest physical address (GPA) and must + * point to a physically contiguous block of memory. + */ + uint64_t resp_addr; + /* VF Representor name (32 byte string). */ + char vfr_name[32]; + /* Logical VF number (range: 0 -> MAX_VFS -1). */ + uint16_t vf_id; + uint16_t reserved; + uint8_t unused_0[4]; +} __attribute__((packed)); + +/* hwrm_cfa_vfr_free_output (size:128b/16B) */ +struct hwrm_cfa_vfr_free_output { + /* The specific error status for the command. */ + uint16_t error_code; + /* The HWRM command request type. */ + uint16_t req_type; + /* The sequence ID from the original command. */ + uint16_t seq_id; + /* The length of the response data in number of bytes. */ + uint16_t resp_len; + uint8_t unused_0[7]; + /* + * This field is used in Output records to indicate that the output + * is completely written to RAM. This field should be read as '1' + * to indicate that the output has been completely written. + * When writing a command completion or response to an internal processor, + * the order of writes has to be such that this field is written last. + */ + uint8_t valid; +} __attribute__((packed)); + + + /*************************************** * hwrm_cfa_redirect_query_tunnel_type * ***************************************/