From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6EB79A0C47; Fri, 19 Nov 2021 04:57:12 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EB67B40143; Fri, 19 Nov 2021 04:57:11 +0100 (CET) Received: from relay.smtp-ext.broadcom.com (relay.smtp-ext.broadcom.com [192.19.166.231]) by mails.dpdk.org (Postfix) with ESMTP id 828D040140 for ; Fri, 19 Nov 2021 04:57:10 +0100 (CET) Received: from dhcp-10-123-153-55.dhcp.broadcom.net (dhcp-10-123-153-55.dhcp.broadcom.net [10.123.153.55]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by relay.smtp-ext.broadcom.com (Postfix) with ESMTPS id 932D7A2; Thu, 18 Nov 2021 19:57:08 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 relay.smtp-ext.broadcom.com 932D7A2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1637294229; bh=WcS2/Imq+/zKaSEvL/KH9/U4SmLEZ2HCzIlKVdtybMI=; h=From:To:Cc:Subject:Date:From; b=GDKFnUw3gnlK3kY2r01rrx840Kt6OMhb/IWKmnFTJeCK2SoLeDYqt2y7pn9AYwL+g CNv2tWADdtEGyJ0BRi8Nglkg2hissFsA1L/mJeE4d0C16WLPHfHsoP3ij3lUtZzlx7 zdeT6m0hvvRccM13+ARqqWBzQfMI9jvyVR/0mp70= From: Somnath Kotur To: dev@dpdk.org Cc: ferruh.yigit@intel.com, Somnath Kotur , Ajit Khaparde Subject: [PATCH] net/bnxt: fix crash caused by error recovery Date: Fri, 19 Nov 2021 09:20:41 +0530 Message-Id: <20211119035041.4493-1-somnath.kotur@broadcom.com> X-Mailer: git-send-email 2.28.0.450.g3a238e5 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org bnxt_stop_rxtx() does not stop data path processing as intended as it does not update the recently introduced fast-path pointers '(struct rte_eth_fp_ops)->rx_pkt_burst'. Since both the burst routines only use the fast-path pointer, the real burst routines get invoked instead of the dummy ones set by bnxt_stop_rxtx() leading to crashes in the data path (e.g. dereferencing freed structures) Fix the segfault by updating the fast-path pointer as well Fixes: c87d435a4d79 ("ethdev: copy fast-path API into separate structure") Signed-off-by: Somnath Kotur Reviewed-by: Ajit Khaparde --- drivers/net/bnxt/bnxt_cpr.c | 9 +++++++++ drivers/net/bnxt/bnxt_ethdev.c | 7 ++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/drivers/net/bnxt/bnxt_cpr.c b/drivers/net/bnxt/bnxt_cpr.c index 6bb70d516e..a43b22a8f8 100644 --- a/drivers/net/bnxt/bnxt_cpr.c +++ b/drivers/net/bnxt/bnxt_cpr.c @@ -387,4 +387,13 @@ void bnxt_stop_rxtx(struct bnxt *bp) { bp->eth_dev->rx_pkt_burst = &bnxt_dummy_recv_pkts; bp->eth_dev->tx_pkt_burst = &bnxt_dummy_xmit_pkts; + + rte_eth_fp_ops[bp->eth_dev->data->port_id].rx_pkt_burst = + bp->eth_dev->rx_pkt_burst; + rte_eth_fp_ops[bp->eth_dev->data->port_id].tx_pkt_burst = + bp->eth_dev->tx_pkt_burst; + rte_mb(); + + /* Allow time for threads to exit the real burst functions. */ + rte_delay_ms(100); } diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 4413b5d72e..c1bdf9a921 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -4323,6 +4323,8 @@ static void bnxt_dev_recover(void *arg) /* Clear Error flag so that device re-init should happen */ bp->flags &= ~BNXT_FLAG_FATAL_ERROR; + PMD_DRV_LOG(INFO, "Port: %u Starting recovery...\n", + bp->eth_dev->data->port_id); rc = bnxt_check_fw_ready(bp); if (rc) @@ -4347,7 +4349,8 @@ static void bnxt_dev_recover(void *arg) if (rc) goto err_start; - PMD_DRV_LOG(INFO, "Recovered from FW reset\n"); + PMD_DRV_LOG(INFO, "Port: %u Recovered from FW reset\n", + bp->eth_dev->data->port_id); pthread_mutex_unlock(&bp->err_recovery_lock); return; @@ -4372,6 +4375,8 @@ void bnxt_dev_reset_and_resume(void *arg) int rc; bnxt_dev_cleanup(bp); + PMD_DRV_LOG(INFO, "Port: %u Finished bnxt_dev_cleanup\n", + bp->eth_dev->data->port_id); bnxt_wait_for_device_shutdown(bp); -- 2.28.0.497.g54e85e7