From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id F24C85957 for ; Thu, 12 Nov 2015 05:57:39 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP; 11 Nov 2015 20:57:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,280,1444719600"; d="scan'208";a="849118999" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga002.fm.intel.com with ESMTP; 11 Nov 2015 20:57:38 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id tAC4vaTP001793; Thu, 12 Nov 2015 12:57:36 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id tAC4vXDf004180; Thu, 12 Nov 2015 12:57:35 +0800 Received: (from jingche2@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id tAC4vX1M004176; Thu, 12 Nov 2015 12:57:33 +0800 From: "Chen Jing D(Mark)" To: dev@dpdk.org Date: Thu, 12 Nov 2015 12:57:31 +0800 Message-Id: <1447304251-4145-1-git-send-email-jing.d.chen@intel.com> X-Mailer: git-send-email 1.7.12.2 Subject: [dpdk-dev] [PATCH] fm10k: fix a crash bug when quit from testpmd X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2015 04:57:40 -0000 From: "Chen Jing D(Mark)" When the fm10k port is closed, both func tx_queue_clean() and fm10k_tx_queue_release_mbufs_vec() will try to release buffer in SW ring. The latter func won't do sanity check on those pointers and cause crash. The fix include 2 parts. 1. Remove Vector TX buffer release func since it can share the release functions with regular TX. 2. Add log to print out what actual Rx/Tx func is used. Signed-off-by: Chen Jing D(Mark) --- drivers/net/fm10k/fm10k.h | 1 - drivers/net/fm10k/fm10k_ethdev.c | 17 ++++++++++++----- drivers/net/fm10k/fm10k_rxtx_vec.c | 28 ---------------------------- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h index 754aa6a..38d5489 100644 --- a/drivers/net/fm10k/fm10k.h +++ b/drivers/net/fm10k/fm10k.h @@ -237,7 +237,6 @@ struct fm10k_tx_queue { }; struct fm10k_txq_ops { - void (*release_mbufs)(struct fm10k_tx_queue *txq); void (*reset)(struct fm10k_tx_queue *txq); }; diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_ethdev.c index cf7ada7..af7b0c2 100644 --- a/drivers/net/fm10k/fm10k_ethdev.c +++ b/drivers/net/fm10k/fm10k_ethdev.c @@ -386,7 +386,6 @@ fm10k_check_mq_mode(struct rte_eth_dev *dev) } static const struct fm10k_txq_ops def_txq_ops = { - .release_mbufs = tx_queue_free, .reset = tx_queue_reset, }; @@ -1073,7 +1072,7 @@ fm10k_dev_queue_release(struct rte_eth_dev *dev) for (i = 0; i < dev->data->nb_tx_queues; i++) { struct fm10k_tx_queue *txq = dev->data->tx_queues[i]; - txq->ops->release_mbufs(txq); + tx_queue_free(txq); } } @@ -1793,7 +1792,7 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_id, if (dev->data->tx_queues[queue_id] != NULL) { struct fm10k_tx_queue *txq = dev->data->tx_queues[queue_id]; - txq->ops->release_mbufs(txq); + tx_queue_free(txq); dev->data->tx_queues[queue_id] = NULL; } @@ -1872,7 +1871,7 @@ fm10k_tx_queue_release(void *queue) struct fm10k_tx_queue *q = queue; PMD_INIT_FUNC_TRACE(); - q->ops->release_mbufs(q); + tx_queue_free(q); } static int @@ -2439,13 +2438,16 @@ fm10k_set_tx_function(struct rte_eth_dev *dev) } if (use_sse) { + PMD_INIT_LOG(ERR, "Use vector Tx func"); for (i = 0; i < dev->data->nb_tx_queues; i++) { txq = dev->data->tx_queues[i]; fm10k_txq_vec_setup(txq); } dev->tx_pkt_burst = fm10k_xmit_pkts_vec; - } else + } else { dev->tx_pkt_burst = fm10k_xmit_pkts; + PMD_INIT_LOG(ERR, "Use regular Tx func"); + } } static void __attribute__((cold)) @@ -2469,6 +2471,11 @@ fm10k_set_rx_function(struct rte_eth_dev *dev) (dev->rx_pkt_burst == fm10k_recv_scattered_pkts_vec || dev->rx_pkt_burst == fm10k_recv_pkts_vec); + if (rx_using_sse) + PMD_INIT_LOG(ERR, "Use vector Rx func"); + else + PMD_INIT_LOG(ERR, "Use regular Rx func"); + for (i = 0; i < dev->data->nb_rx_queues; i++) { struct fm10k_rx_queue *rxq = dev->data->rx_queues[i]; diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c b/drivers/net/fm10k/fm10k_rxtx_vec.c index 06beca9..6042568 100644 --- a/drivers/net/fm10k/fm10k_rxtx_vec.c +++ b/drivers/net/fm10k/fm10k_rxtx_vec.c @@ -45,8 +45,6 @@ #endif static void -fm10k_tx_queue_release_mbufs_vec(struct fm10k_tx_queue *txq); -static void fm10k_reset_tx_queue(struct fm10k_tx_queue *txq); /* Handling the offload flags (olflags) field takes computation @@ -634,7 +632,6 @@ fm10k_recv_scattered_pkts_vec(void *rx_queue, } static const struct fm10k_txq_ops vec_txq_ops = { - .release_mbufs = fm10k_tx_queue_release_mbufs_vec, .reset = fm10k_reset_tx_queue, }; @@ -795,31 +792,6 @@ fm10k_xmit_pkts_vec(void *tx_queue, struct rte_mbuf **tx_pkts, } static void __attribute__((cold)) -fm10k_tx_queue_release_mbufs_vec(struct fm10k_tx_queue *txq) -{ - unsigned i; - const uint16_t max_desc = (uint16_t)(txq->nb_desc - 1); - - if (txq->sw_ring == NULL || txq->nb_free == max_desc) - return; - - /* release the used mbufs in sw_ring */ - for (i = txq->next_dd - (txq->rs_thresh - 1); - i != txq->next_free; - i = (i + 1) & max_desc) - rte_pktmbuf_free_seg(txq->sw_ring[i]); - - txq->nb_free = max_desc; - - /* reset tx_entry */ - for (i = 0; i < txq->nb_desc; i++) - txq->sw_ring[i] = NULL; - - rte_free(txq->sw_ring); - txq->sw_ring = NULL; -} - -static void __attribute__((cold)) fm10k_reset_tx_queue(struct fm10k_tx_queue *txq) { static const struct fm10k_tx_desc zeroed_desc = {0}; -- 1.7.7.6