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 6CF94A0352; Thu, 16 Jan 2020 13:48:33 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 487A91D441; Thu, 16 Jan 2020 13:47:58 +0100 (CET) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id A8CD01D3F0 for ; Thu, 16 Jan 2020 13:47:48 +0100 (CET) Received: from dhcp-10-123-153-22.dhcp.broadcom.net (bgccx-dev-host-lnx2.bec.broadcom.net [10.123.153.22]) by relay.smtp.broadcom.com (Postfix) with ESMTP id D1E5128F51E; Thu, 16 Jan 2020 04:47:47 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com D1E5128F51E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1579178868; bh=ABtbxFfQD2YttrWm0hmrzv1UMNNVxExPXLuX/ePmqUk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BRq5ouUpIOk2Kse1D5sGK0FnwfkyOFr3v0vQRrY4ZgciAxeltsSrp5nuzZoXL78Rx +UCY/mciAVWcJ7UlgL7jVUP1ra2pCKouviENoVsGq46Ep0ZasL/cX3311bO9yO2PZw lPPWGMhTLY42P22D9BfubHeOrZ7iJf6tcwEjyvj8= From: Kalesh A P To: dev@dpdk.org Cc: ferruh.yigit@intel.com, ajit.khaparde@broadcom.com Date: Thu, 16 Jan 2020 18:34:50 +0530 Message-Id: <20200116130455.30193-6-kalesh-anakkur.purayil@broadcom.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20200116130455.30193-1-kalesh-anakkur.purayil@broadcom.com> References: <20200116130455.30193-1-kalesh-anakkur.purayil@broadcom.com> Subject: [dpdk-dev] [PATCH V4 05/10] net/bnxt: fix VLAN strip 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: Kalesh AP HWRM_VNIC_CFG command to configure vnic dynamically with traffic running is not working. Driver has to free and recreate the vnic and then reconfigure the vnic filters. Fixes: 7fe5668d2ea3 ("net/bnxt: support VLAN filter and strip") Cc: stable@dpdk.org Signed-off-by: Kalesh AP Reviewed-by: Ajit Kumar Khaparde Reviewed-by: Somnath Kotur --- drivers/net/bnxt/bnxt_ethdev.c | 248 +++++++++++++++++++++++++---------------- 1 file changed, 150 insertions(+), 98 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 83f475d..0b2c29b 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -132,6 +132,7 @@ static int bnxt_dev_uninit(struct rte_eth_dev *eth_dev); static int bnxt_init_resources(struct bnxt *bp, bool reconfig_dev); static int bnxt_uninit_resources(struct bnxt *bp, bool reconfig_dev); static void bnxt_cancel_fw_health_check(struct bnxt *bp); +static int bnxt_restore_vlan_filters(struct bnxt *bp); int is_bnxt_in_error(struct bnxt *bp) { @@ -228,14 +229,97 @@ static int bnxt_alloc_mem(struct bnxt *bp, bool reconfig) return rc; } -static int bnxt_init_chip(struct bnxt *bp) +static int bnxt_setup_one_vnic(struct bnxt *bp, uint16_t vnic_id) { + struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; + struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; + uint64_t rx_offloads = dev_conf->rxmode.offloads; struct bnxt_rx_queue *rxq; + unsigned int j; + int rc; + + rc = bnxt_vnic_grp_alloc(bp, vnic); + if (rc) + goto err_out; + + PMD_DRV_LOG(DEBUG, "vnic[%d] = %p vnic->fw_grp_ids = %p\n", + vnic_id, vnic, vnic->fw_grp_ids); + + rc = bnxt_hwrm_vnic_alloc(bp, vnic); + if (rc) + goto err_out; + + /* Alloc RSS context only if RSS mode is enabled */ + if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) { + int j, nr_ctxs = bnxt_rss_ctxts(bp); + + rc = 0; + for (j = 0; j < nr_ctxs; j++) { + rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic, j); + if (rc) + break; + } + if (rc) { + PMD_DRV_LOG(ERR, + "HWRM vnic %d ctx %d alloc failure rc: %x\n", + vnic_id, j, rc); + goto err_out; + } + vnic->num_lb_ctxts = nr_ctxs; + } + + /* + * Firmware sets pf pair in default vnic cfg. If the VLAN strip + * setting is not available at this time, it will not be + * configured correctly in the CFA. + */ + if (rx_offloads & DEV_RX_OFFLOAD_VLAN_STRIP) + vnic->vlan_strip = true; + else + vnic->vlan_strip = false; + + rc = bnxt_hwrm_vnic_cfg(bp, vnic); + if (rc) + goto err_out; + + rc = bnxt_set_hwrm_vnic_filters(bp, vnic); + if (rc) + goto err_out; + + for (j = 0; j < bp->rx_num_qs_per_vnic; j++) { + rxq = bp->eth_dev->data->rx_queues[j]; + + PMD_DRV_LOG(DEBUG, + "rxq[%d]->vnic=%p vnic->fw_grp_ids=%p\n", + j, rxq->vnic, rxq->vnic->fw_grp_ids); + + if (BNXT_HAS_RING_GRPS(bp) && rxq->rx_deferred_start) + rxq->vnic->fw_grp_ids[j] = INVALID_HW_RING_ID; + } + + rc = bnxt_vnic_rss_configure(bp, vnic); + if (rc) + goto err_out; + + bnxt_hwrm_vnic_plcmode_cfg(bp, vnic); + + if (rx_offloads & DEV_RX_OFFLOAD_TCP_LRO) + bnxt_hwrm_vnic_tpa_cfg(bp, vnic, 1); + else + bnxt_hwrm_vnic_tpa_cfg(bp, vnic, 0); + + return 0; +err_out: + PMD_DRV_LOG(ERR, "HWRM vnic %d cfg failure rc: %x\n", + vnic_id, rc); + return rc; +} + +static int bnxt_init_chip(struct bnxt *bp) +{ struct rte_eth_link new; struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(bp->eth_dev); - struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; struct rte_intr_handle *intr_handle = &pci_dev->intr_handle; - uint64_t rx_offloads = dev_conf->rxmode.offloads; uint32_t intr_vector = 0; uint32_t queue_id, base = BNXT_MISC_VEC_ID; uint32_t vec = BNXT_MISC_VEC_ID; @@ -303,93 +387,11 @@ static int bnxt_init_chip(struct bnxt *bp) /* VNIC configuration */ for (i = 0; i < bp->nr_vnics; i++) { - struct rte_eth_conf *dev_conf = &bp->eth_dev->data->dev_conf; - struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; - - rc = bnxt_vnic_grp_alloc(bp, vnic); + rc = bnxt_setup_one_vnic(bp, i); if (rc) goto err_out; - - PMD_DRV_LOG(DEBUG, "vnic[%d] = %p vnic->fw_grp_ids = %p\n", - i, vnic, vnic->fw_grp_ids); - - rc = bnxt_hwrm_vnic_alloc(bp, vnic); - if (rc) { - PMD_DRV_LOG(ERR, "HWRM vnic %d alloc failure rc: %x\n", - i, rc); - goto err_out; - } - - /* Alloc RSS context only if RSS mode is enabled */ - if (dev_conf->rxmode.mq_mode & ETH_MQ_RX_RSS) { - int j, nr_ctxs = bnxt_rss_ctxts(bp); - - rc = 0; - for (j = 0; j < nr_ctxs; j++) { - rc = bnxt_hwrm_vnic_ctx_alloc(bp, vnic, j); - if (rc) - break; - } - if (rc) { - PMD_DRV_LOG(ERR, - "HWRM vnic %d ctx %d alloc failure rc: %x\n", - i, j, rc); - goto err_out; - } - vnic->num_lb_ctxts = nr_ctxs; - } - - /* - * Firmware sets pf pair in default vnic cfg. If the VLAN strip - * setting is not available at this time, it will not be - * configured correctly in the CFA. - */ - if (rx_offloads & DEV_RX_OFFLOAD_VLAN_STRIP) - vnic->vlan_strip = true; - else - vnic->vlan_strip = false; - - rc = bnxt_hwrm_vnic_cfg(bp, vnic); - if (rc) { - PMD_DRV_LOG(ERR, "HWRM vnic %d cfg failure rc: %x\n", - i, rc); - goto err_out; - } - - rc = bnxt_set_hwrm_vnic_filters(bp, vnic); - if (rc) { - PMD_DRV_LOG(ERR, - "HWRM vnic %d filter failure rc: %x\n", - i, rc); - goto err_out; - } - - for (j = 0; j < bp->rx_num_qs_per_vnic; j++) { - rxq = bp->eth_dev->data->rx_queues[j]; - - PMD_DRV_LOG(DEBUG, - "rxq[%d]->vnic=%p vnic->fw_grp_ids=%p\n", - j, rxq->vnic, rxq->vnic->fw_grp_ids); - - if (BNXT_HAS_RING_GRPS(bp) && rxq->rx_deferred_start) - rxq->vnic->fw_grp_ids[j] = INVALID_HW_RING_ID; - } - - rc = bnxt_vnic_rss_configure(bp, vnic); - if (rc) { - PMD_DRV_LOG(ERR, - "HWRM vnic set RSS failure rc: %x\n", rc); - goto err_out; - } - - bnxt_hwrm_vnic_plcmode_cfg(bp, vnic); - - if (bp->eth_dev->data->dev_conf.rxmode.offloads & - DEV_RX_OFFLOAD_TCP_LRO) - bnxt_hwrm_vnic_tpa_cfg(bp, vnic, 1); - else - bnxt_hwrm_vnic_tpa_cfg(bp, vnic, 0); } + rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, &bp->vnic_info[0], 0, NULL); if (rc) { PMD_DRV_LOG(ERR, @@ -1892,12 +1894,69 @@ bnxt_config_vlan_hw_filter(struct bnxt *bp, uint64_t rx_offloads) return 0; } +static int bnxt_free_one_vnic(struct bnxt *bp, uint16_t vnic_id) +{ + struct bnxt_vnic_info *vnic = &bp->vnic_info[vnic_id]; + unsigned int i; + int rc; + + /* Destroy vnic filters and vnic */ + if (bp->eth_dev->data->dev_conf.rxmode.offloads & + DEV_RX_OFFLOAD_VLAN_FILTER) { + for (i = 0; i < RTE_ETHER_MAX_VLAN_ID; i++) + bnxt_del_vlan_filter(bp, i); + } + bnxt_del_dflt_mac_filter(bp, vnic); + + rc = bnxt_hwrm_vnic_free(bp, vnic); + if (rc) + return rc; + + rte_free(vnic->fw_grp_ids); + vnic->fw_grp_ids = NULL; + + return 0; +} + +static int +bnxt_config_vlan_hw_stripping(struct bnxt *bp, uint64_t rx_offloads) +{ + struct bnxt_vnic_info *vnic = BNXT_GET_DEFAULT_VNIC(bp); + int rc; + + /* Destroy, recreate and reconfigure the default vnic */ + rc = bnxt_free_one_vnic(bp, 0); + if (rc) + return rc; + + /* default vnic 0 */ + rc = bnxt_setup_one_vnic(bp, 0); + if (rc) + return rc; + + if (bp->eth_dev->data->dev_conf.rxmode.offloads & + DEV_RX_OFFLOAD_VLAN_FILTER) { + rc = bnxt_add_vlan_filter(bp, 0); + bnxt_restore_vlan_filters(bp); + } else { + rc = bnxt_add_mac_filter(bp, vnic, NULL, 0, 0); + } + + rc = bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic, 0, NULL); + if (rc) + return rc; + + PMD_DRV_LOG(DEBUG, "VLAN Strip Offload: %d\n", + !!(rx_offloads & DEV_RX_OFFLOAD_VLAN_STRIP)); + + return rc; +} + static int bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask) { uint64_t rx_offloads = dev->data->dev_conf.rxmode.offloads; struct bnxt *bp = dev->data->dev_private; - unsigned int i; int rc; rc = is_bnxt_in_error(bp); @@ -1913,16 +1972,9 @@ bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask) if (mask & ETH_VLAN_STRIP_MASK) { /* Enable or disable VLAN stripping */ - for (i = 0; i < bp->nr_vnics; i++) { - struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; - if (rx_offloads & DEV_RX_OFFLOAD_VLAN_STRIP) - vnic->vlan_strip = true; - else - vnic->vlan_strip = false; - bnxt_hwrm_vnic_cfg(bp, vnic); - } - PMD_DRV_LOG(DEBUG, "VLAN Strip Offload: %d\n", - !!(rx_offloads & DEV_RX_OFFLOAD_VLAN_STRIP)); + rc = bnxt_config_vlan_hw_stripping(bp, rx_offloads); + if (rc) + return rc; } if (mask & ETH_VLAN_EXTEND_MASK) { -- 2.10.1