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 67C85A32A1 for ; Thu, 24 Oct 2019 09:54:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BBB7B1E4E0; Thu, 24 Oct 2019 09:53:02 +0200 (CEST) Received: from relay.smtp.broadcom.com (relay.smtp.broadcom.com [192.19.232.149]) by dpdk.org (Postfix) with ESMTP id 47A631D41E for ; Thu, 24 Oct 2019 09:52:34 +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 2C98B1B6D5E; Thu, 24 Oct 2019 00:52:32 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 2C98B1B6D5E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1571903554; bh=Jg6MNwGPgjQtA6Pdn5/U+rT02T2ryacASRd2MQQwdHo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HY+GEXVeAVZCMP6xzeiE0cvWnXBIFqDLI78CGsGL3DO6HiN5F5yeGE9KCpDVFzpDd R6VYtA2ci6ZEXTylamAe3IyjfeAAfRnEBmZTEIMP6KlbOCAD10Rg8jpMpVEwAPuaVm ySWaC91b9xiFW8wrwPlzyUDZ9hYVwhWGkLR24QVY= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Thu, 24 Oct 2019 13:14:27 +0530 Message-Id: <20191024074432.30705-13-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20191024074432.30705-1-somnath.kotur@broadcom.com> References: <20191024074432.30705-1-somnath.kotur@broadcom.com> Subject: [dpdk-dev] [PATCH 12/17] net/bnxt: fix segfault after removing and adding the slaves 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: Santoshkumar Karanappa Rastapur On removing the slave interface, slave_remove in bonding module calls _rte_eth_dev_reset which in turn frees both Tx and Rx queues. 1. segfault is seen after removing/adding the slave interface and starting bond interface. In this below path, when mtu is set for the slave interface, queues are not created yet and driver reference to queue[0] causes the segfault. slave_configure: rte_eth_dev_set_mtu rte_eth_dev_configure rte_eth_rx_queue_setup 2. segfault is seen on starting the port after removing from bond device. This is a testpmd bug where in, on starting the port, testpmd is supposed to recreate the queues before starting the port. Fixed these by adding check for queues created before accessing them. Signed-off-by: Santoshkumar Karanappa Rastapur Reviewed-by: Somnath Kotur Signed-off-by: Somnath Kotur --- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_ethdev.c | 19 ++++++++++++++++--- drivers/net/bnxt/bnxt_rxq.c | 4 ++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 975bcf9..ffc37ea 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -639,6 +639,7 @@ struct bnxt { struct bnxt_error_recovery_info *recovery_info; }; +int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu); int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete); int bnxt_rcv_msg_from_vf(struct bnxt *bp, uint16_t vf_id, void *msg); int is_bnxt_in_error(struct bnxt *bp); diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index e24fd41..4187247 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -121,7 +121,6 @@ static const struct rte_pci_id bnxt_pci_id_map[] = { static int bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask); static void bnxt_print_link_info(struct rte_eth_dev *eth_dev); -static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu); 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); @@ -831,6 +830,11 @@ static int bnxt_dev_start_op(struct rte_eth_dev *eth_dev) int vlan_mask = 0; int rc; + if (!eth_dev->data->nb_tx_queues || !eth_dev->data->nb_rx_queues) { + PMD_DRV_LOG(ERR, "Queues are not configured yet!\n"); + return -EINVAL; + } + if (bp->rx_cp_nr_rings > RTE_ETHDEV_QUEUE_STAT_CNTRS) { PMD_DRV_LOG(ERR, "RxQ cnt %d > CONFIG_RTE_ETHDEV_QUEUE_STAT_CNTRS %d\n", @@ -2126,7 +2130,7 @@ bnxt_txq_info_get_op(struct rte_eth_dev *dev, uint16_t queue_id, qinfo->conf.tx_deferred_start = txq->tx_deferred_start; } -static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu) +int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu) { struct bnxt *bp = eth_dev->data->dev_private; uint32_t new_pkt_size; @@ -2137,6 +2141,10 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu) if (rc) return rc; + /* Exit if receive queues are not configured yet */ + if (!eth_dev->data->nb_rx_queues) + return rc; + new_pkt_size = new_mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN + VLAN_TAG_SIZE * BNXT_NUM_VLANS; @@ -2167,7 +2175,9 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu) bp->flags &= ~BNXT_FLAG_JUMBO; } - eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = new_pkt_size; + /* Is there a change in mtu setting? */ + if (eth_dev->data->dev_conf.rxmode.max_rx_pkt_len == new_pkt_size) + return rc; for (i = 0; i < bp->nr_vnics; i++) { struct bnxt_vnic_info *vnic = &bp->vnic_info[i]; @@ -2188,6 +2198,9 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu) } } + if (!rc) + eth_dev->data->dev_conf.rxmode.max_rx_pkt_len = new_pkt_size; + PMD_DRV_LOG(INFO, "New MTU is %d\n", new_mtu); return rc; diff --git a/drivers/net/bnxt/bnxt_rxq.c b/drivers/net/bnxt/bnxt_rxq.c index e1ed360..d55adc3 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -366,6 +366,10 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, eth_dev->data->rx_queue_state[queue_idx] = queue_state; rte_spinlock_init(&rxq->lock); + /* Configure mtu if it is different from what was configured before */ + if (!queue_idx) + bnxt_mtu_set_op(eth_dev, eth_dev->data->mtu); + out: return rc; } -- 2.10.1.613.g2cc2e70