From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 19E6A5A71 for ; Tue, 17 Nov 2015 13:03:50 +0100 (CET) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 17 Nov 2015 04:03:49 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,307,1444719600"; d="scan'208";a="852860280" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by fmsmga002.fm.intel.com with ESMTP; 17 Nov 2015 04:03:50 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 17 Nov 2015 04:03:49 -0800 Received: from shsmsx104.ccr.corp.intel.com (10.239.110.15) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 17 Nov 2015 04:03:49 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.83]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.223]) with mapi id 14.03.0248.002; Tue, 17 Nov 2015 20:03:47 +0800 From: "Qiu, Michael" To: "Chen, Jing D" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] fm10k: fix a crash bug when quit from testpmd Thread-Index: AQHRHQa+JESKdLnEXkuJvS0XhZzxIQ== Date: Tue, 17 Nov 2015 12:03:46 +0000 Message-ID: <533710CFB86FA344BFBF2D6802E6028621B83278@SHSMSX101.ccr.corp.intel.com> References: <1447304251-4145-1-git-send-email-jing.d.chen@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [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: Tue, 17 Nov 2015 12:03:51 -0000 On 2015/11/12 12:58, Chen Jing D(Mark) wrote:=0A= > From: "Chen Jing D(Mark)" =0A= >=0A= > When the fm10k port is closed, both func tx_queue_clean() and=0A= > fm10k_tx_queue_release_mbufs_vec() will try to release buffer in=0A= > SW ring. The latter func won't do sanity check on those pointers=0A= > and cause crash.=0A= >=0A= > The fix include 2 parts.=0A= > 1. Remove Vector TX buffer release func since it can share the=0A= > release functions with regular TX.=0A= > 2. Add log to print out what actual Rx/Tx func is used.=0A= >=0A= > Signed-off-by: Chen Jing D(Mark) =0A= > ---=0A= =0A= Acked-by: Michael Qiu =0A= > drivers/net/fm10k/fm10k.h | 1 -=0A= > drivers/net/fm10k/fm10k_ethdev.c | 17 ++++++++++++-----=0A= > drivers/net/fm10k/fm10k_rxtx_vec.c | 28 ----------------------------= =0A= > 3 files changed, 12 insertions(+), 34 deletions(-)=0A= >=0A= > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h=0A= > index 754aa6a..38d5489 100644=0A= > --- a/drivers/net/fm10k/fm10k.h=0A= > +++ b/drivers/net/fm10k/fm10k.h=0A= > @@ -237,7 +237,6 @@ struct fm10k_tx_queue {=0A= > };=0A= > =0A= > struct fm10k_txq_ops {=0A= > - void (*release_mbufs)(struct fm10k_tx_queue *txq);=0A= > void (*reset)(struct fm10k_tx_queue *txq);=0A= > };=0A= > =0A= > diff --git a/drivers/net/fm10k/fm10k_ethdev.c b/drivers/net/fm10k/fm10k_e= thdev.c=0A= > index cf7ada7..af7b0c2 100644=0A= > --- a/drivers/net/fm10k/fm10k_ethdev.c=0A= > +++ b/drivers/net/fm10k/fm10k_ethdev.c=0A= > @@ -386,7 +386,6 @@ fm10k_check_mq_mode(struct rte_eth_dev *dev)=0A= > }=0A= > =0A= > static const struct fm10k_txq_ops def_txq_ops =3D {=0A= > - .release_mbufs =3D tx_queue_free,=0A= > .reset =3D tx_queue_reset,=0A= > };=0A= > =0A= > @@ -1073,7 +1072,7 @@ fm10k_dev_queue_release(struct rte_eth_dev *dev)=0A= > for (i =3D 0; i < dev->data->nb_tx_queues; i++) {=0A= > struct fm10k_tx_queue *txq =3D dev->data->tx_queues[i];=0A= > =0A= > - txq->ops->release_mbufs(txq);=0A= > + tx_queue_free(txq);=0A= > }=0A= > }=0A= > =0A= > @@ -1793,7 +1792,7 @@ fm10k_tx_queue_setup(struct rte_eth_dev *dev, uint1= 6_t queue_id,=0A= > if (dev->data->tx_queues[queue_id] !=3D NULL) {=0A= > struct fm10k_tx_queue *txq =3D dev->data->tx_queues[queue_id];=0A= > =0A= > - txq->ops->release_mbufs(txq);=0A= > + tx_queue_free(txq);=0A= > dev->data->tx_queues[queue_id] =3D NULL;=0A= > }=0A= > =0A= > @@ -1872,7 +1871,7 @@ fm10k_tx_queue_release(void *queue)=0A= > struct fm10k_tx_queue *q =3D queue;=0A= > PMD_INIT_FUNC_TRACE();=0A= > =0A= > - q->ops->release_mbufs(q);=0A= > + tx_queue_free(q);=0A= > }=0A= > =0A= > static int=0A= > @@ -2439,13 +2438,16 @@ fm10k_set_tx_function(struct rte_eth_dev *dev)=0A= > }=0A= > =0A= > if (use_sse) {=0A= > + PMD_INIT_LOG(ERR, "Use vector Tx func");=0A= > for (i =3D 0; i < dev->data->nb_tx_queues; i++) {=0A= > txq =3D dev->data->tx_queues[i];=0A= > fm10k_txq_vec_setup(txq);=0A= > }=0A= > dev->tx_pkt_burst =3D fm10k_xmit_pkts_vec;=0A= > - } else=0A= > + } else {=0A= > dev->tx_pkt_burst =3D fm10k_xmit_pkts;=0A= > + PMD_INIT_LOG(ERR, "Use regular Tx func");=0A= > + }=0A= > }=0A= > =0A= > static void __attribute__((cold))=0A= > @@ -2469,6 +2471,11 @@ fm10k_set_rx_function(struct rte_eth_dev *dev)=0A= > (dev->rx_pkt_burst =3D=3D fm10k_recv_scattered_pkts_vec ||=0A= > dev->rx_pkt_burst =3D=3D fm10k_recv_pkts_vec);=0A= > =0A= > + if (rx_using_sse)=0A= > + PMD_INIT_LOG(ERR, "Use vector Rx func");=0A= > + else=0A= > + PMD_INIT_LOG(ERR, "Use regular Rx func");=0A= > +=0A= > for (i =3D 0; i < dev->data->nb_rx_queues; i++) {=0A= > struct fm10k_rx_queue *rxq =3D dev->data->rx_queues[i];=0A= > =0A= > diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c b/drivers/net/fm10k/fm10k= _rxtx_vec.c=0A= > index 06beca9..6042568 100644=0A= > --- a/drivers/net/fm10k/fm10k_rxtx_vec.c=0A= > +++ b/drivers/net/fm10k/fm10k_rxtx_vec.c=0A= > @@ -45,8 +45,6 @@=0A= > #endif=0A= > =0A= > static void=0A= > -fm10k_tx_queue_release_mbufs_vec(struct fm10k_tx_queue *txq);=0A= > -static void=0A= > fm10k_reset_tx_queue(struct fm10k_tx_queue *txq);=0A= > =0A= > /* Handling the offload flags (olflags) field takes computation=0A= > @@ -634,7 +632,6 @@ fm10k_recv_scattered_pkts_vec(void *rx_queue,=0A= > }=0A= > =0A= > static const struct fm10k_txq_ops vec_txq_ops =3D {=0A= > - .release_mbufs =3D fm10k_tx_queue_release_mbufs_vec,=0A= > .reset =3D fm10k_reset_tx_queue,=0A= > };=0A= > =0A= > @@ -795,31 +792,6 @@ fm10k_xmit_pkts_vec(void *tx_queue, struct rte_mbuf = **tx_pkts,=0A= > }=0A= > =0A= > static void __attribute__((cold))=0A= > -fm10k_tx_queue_release_mbufs_vec(struct fm10k_tx_queue *txq)=0A= > -{=0A= > - unsigned i;=0A= > - const uint16_t max_desc =3D (uint16_t)(txq->nb_desc - 1);=0A= > -=0A= > - if (txq->sw_ring =3D=3D NULL || txq->nb_free =3D=3D max_desc)=0A= > - return;=0A= > -=0A= > - /* release the used mbufs in sw_ring */=0A= > - for (i =3D txq->next_dd - (txq->rs_thresh - 1);=0A= > - i !=3D txq->next_free;=0A= > - i =3D (i + 1) & max_desc)=0A= > - rte_pktmbuf_free_seg(txq->sw_ring[i]);=0A= > -=0A= > - txq->nb_free =3D max_desc;=0A= > -=0A= > - /* reset tx_entry */=0A= > - for (i =3D 0; i < txq->nb_desc; i++)=0A= > - txq->sw_ring[i] =3D NULL;=0A= > -=0A= > - rte_free(txq->sw_ring);=0A= > - txq->sw_ring =3D NULL;=0A= > -}=0A= > -=0A= > -static void __attribute__((cold))=0A= > fm10k_reset_tx_queue(struct fm10k_tx_queue *txq)=0A= > {=0A= > static const struct fm10k_tx_desc zeroed_desc =3D {0};=0A= =0A=