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 E4DD8A04F0 for ; Wed, 18 Dec 2019 07:24:52 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9F4711BF85; Wed, 18 Dec 2019 07:24:50 +0100 (CET) Received: from relay.smtp.broadcom.com (unknown [192.19.211.62]) by dpdk.org (Postfix) with ESMTP id 900B91BC25 for ; Wed, 18 Dec 2019 07:24:47 +0100 (CET) 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 24BC828FA85; Tue, 17 Dec 2019 22:24:47 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.10.3 relay.smtp.broadcom.com 24BC828FA85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1576650287; bh=Ff4THyNqMNAaB8hefiXy7GHEPHoDl1V7RcRZBd9C4gQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h3OPRB2QAzzkX/lzhLNnslRlc1bzDEWBJhZJljUkWpCa27PmjC4QyaU9zFCfhbsnP I6RgzwxQq+mpnaqQ3svRFUyDGvIa80T8IAex4jDcA4i3BbYAXZ6LXlx841kKeBy4rg +Tx/hTFZwaEPgDSwckemdAf1csmsYX5irIAuihOE= From: Somnath Kotur To: stable@dpdk.org Cc: ktraynor@redhat.com Date: Wed, 18 Dec 2019 11:54:08 +0530 Message-Id: <20191218062411.13079-17-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.10.1.613.g2cc2e70 In-Reply-To: <20191218062411.13079-1-somnath.kotur@broadcom.com> References: <20191218062411.13079-1-somnath.kotur@broadcom.com> Subject: [dpdk-stable] [PATCH 18.11 16/19] net/bnxt: fix crash after removing and adding slaves X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" 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. Fixes: daef48efe5e5 ("net/bnxt: support set MTU") Signed-off-by: Santoshkumar Karanappa Rastapur Signed-off-by: Somnath Kotur Signed-off-by: Ajit Khaparde Signed-off-by: root --- drivers/net/bnxt/bnxt.h | 1 + drivers/net/bnxt/bnxt_ethdev.c | 23 ++++++++++++++++++----- drivers/net/bnxt/bnxt_rxq.c | 4 ++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h index 95c1135..425d425 100644 --- a/drivers/net/bnxt/bnxt.h +++ b/drivers/net/bnxt/bnxt.h @@ -411,6 +411,7 @@ struct bnxt { uint16_t vf_resv_strategy; }; +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); diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 6aec211..fb40816 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -115,7 +115,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); /***********************/ @@ -588,6 +587,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", @@ -1577,7 +1581,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; struct rte_eth_dev_info dev_info; @@ -1585,6 +1589,10 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu) uint32_t rc = 0; uint32_t i; + /* Exit if receive queues are not configured yet */ + if (!eth_dev->data->nb_rx_queues) + return rc; + bnxt_dev_info_get_op(eth_dev, &dev_info); if (new_mtu < ETHER_MIN_MTU || new_mtu > BNXT_MAX_MTU) { @@ -1605,7 +1613,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]; @@ -1626,8 +1636,11 @@ static int bnxt_mtu_set_op(struct rte_eth_dev *eth_dev, uint16_t new_mtu) } } - eth_dev->data->mtu = new_mtu; - PMD_DRV_LOG(INFO, "New MTU is %d\n", new_mtu); + if (!rc) { + eth_dev->data->mtu = new_mtu; + 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 5bc2284..2df61ee 100644 --- a/drivers/net/bnxt/bnxt_rxq.c +++ b/drivers/net/bnxt/bnxt_rxq.c @@ -356,6 +356,10 @@ int bnxt_rx_queue_setup_op(struct rte_eth_dev *eth_dev, RTE_ETH_QUEUE_STATE_STARTED; 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