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 96B15A04FD; Tue, 14 Jan 2020 02:55:11 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E20361C43F; Tue, 14 Jan 2020 02:55:10 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 698201C1CB for ; Tue, 14 Jan 2020 02:55:08 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Jan 2020 17:55:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,431,1571727600"; d="scan'208";a="218826883" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga007.fm.intel.com with ESMTP; 13 Jan 2020 17:55:07 -0800 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 13 Jan 2020 17:55:07 -0800 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 13 Jan 2020 17:55:06 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.30]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.203]) with mapi id 14.03.0439.000; Tue, 14 Jan 2020 09:55:04 +0800 From: "Yang, Qiming" To: "Di, ChenxuX" , "dev@dpdk.org" Thread-Topic: [PATCH v9 2/4] net/ice: cleanup Tx buffers Thread-Index: AQHVyffkQvDpYDgsJE6e3IMJBxm9mafpZylA Date: Tue, 14 Jan 2020 01:55:04 +0000 Message-ID: References: <20191203055134.72874-1-chenxux.di@intel.com> <20200113095708.67598-1-chenxux.di@intel.com> <20200113095708.67598-3-chenxux.di@intel.com> In-Reply-To: <20200113095708.67598-3-chenxux.di@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNWI3YWNkNzQtNDMwZi00ZWM2LWIxZGItMmEyMWUzOWJjZTlkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiUWJiaHdLVXBGMytIK2MwZnpQbFY1ak9vSWNJOEtTSktSekgwa1JsNnpTejkyS2dHZmFVUk50aVErTVlnVXpSRSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action 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 v9 2/4] net/ice: cleanup Tx buffers 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" > -----Original Message----- > From: Di, ChenxuX > Sent: Monday, January 13, 2020 5:57 PM > To: dev@dpdk.org > Cc: Yang, Qiming ; Di, ChenxuX > > Subject: [PATCH v9 2/4] net/ice: cleanup Tx buffers >=20 > Add support to the ice driver for the API rte_eth_tx_done_cleanup to forc= e free > consumed buffers on Tx ring. >=20 > Signed-off-by: Chenxu Di Acked-by: Qiming Yang > --- > drivers/net/ice/ice_ethdev.c | 1 + > drivers/net/ice/ice_rxtx.c | 111 +++++++++++++++++++++++++++++++++++ > drivers/net/ice/ice_rxtx.h | 2 + > 3 files changed, 114 insertions(+) >=20 > diff --git a/drivers/net/ice/ice_ethdev.c b/drivers/net/ice/ice_ethdev.c = index > de189daba..b55cdbf74 100644 > --- a/drivers/net/ice/ice_ethdev.c > +++ b/drivers/net/ice/ice_ethdev.c > @@ -220,6 +220,7 @@ static const struct eth_dev_ops ice_eth_dev_ops =3D { > .filter_ctrl =3D ice_dev_filter_ctrl, > .udp_tunnel_port_add =3D ice_dev_udp_tunnel_port_add, > .udp_tunnel_port_del =3D ice_dev_udp_tunnel_port_del, > + .tx_done_cleanup =3D ice_tx_done_cleanup, > }; >=20 > /* store statistics names and its offset in stats structure */ diff --gi= t > a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index > 2db174456..8f12df807 100644 > --- a/drivers/net/ice/ice_rxtx.c > +++ b/drivers/net/ice/ice_rxtx.c > @@ -863,6 +863,9 @@ ice_fdir_tx_queue_stop(struct rte_eth_dev *dev, > uint16_t tx_queue_id) > return 0; > } >=20 > + > + > + > int > ice_rx_queue_setup(struct rte_eth_dev *dev, > uint16_t queue_idx, > @@ -2643,6 +2646,114 @@ ice_tx_free_bufs(struct ice_tx_queue *txq) > return txq->tx_rs_thresh; > } >=20 > +static int > +ice_tx_done_cleanup_full(struct ice_tx_queue *txq, > + uint32_t free_cnt) > +{ > + struct ice_tx_entry *swr_ring =3D txq->sw_ring; > + uint16_t i, tx_last, tx_id; > + uint16_t nb_tx_free_last; > + uint16_t nb_tx_to_clean; > + uint32_t pkt_cnt; > + > + /* Start free mbuf from the next of tx_tail */ > + tx_last =3D txq->tx_tail; > + tx_id =3D swr_ring[tx_last].next_id; > + > + if (txq->nb_tx_free =3D=3D 0 && ice_xmit_cleanup(txq)) > + return 0; > + > + nb_tx_to_clean =3D txq->nb_tx_free; > + nb_tx_free_last =3D txq->nb_tx_free; > + if (!free_cnt) > + free_cnt =3D txq->nb_tx_desc; > + > + /* Loop through swr_ring to count the amount of > + * freeable mubfs and packets. > + */ > + for (pkt_cnt =3D 0; pkt_cnt < free_cnt; ) { > + for (i =3D 0; i < nb_tx_to_clean && > + pkt_cnt < free_cnt && > + tx_id !=3D tx_last; i++) { > + if (swr_ring[tx_id].mbuf !=3D NULL) { > + rte_pktmbuf_free_seg(swr_ring[tx_id].mbuf); > + swr_ring[tx_id].mbuf =3D NULL; > + > + /* > + * last segment in the packet, > + * increment packet count > + */ > + pkt_cnt +=3D (swr_ring[tx_id].last_id =3D=3D tx_id); > + } > + > + tx_id =3D swr_ring[tx_id].next_id; > + } > + > + if (txq->tx_rs_thresh > txq->nb_tx_desc - > + txq->nb_tx_free || tx_id =3D=3D tx_last) > + break; > + > + if (pkt_cnt < free_cnt) { > + if (ice_xmit_cleanup(txq)) > + break; > + > + nb_tx_to_clean =3D txq->nb_tx_free - nb_tx_free_last; > + nb_tx_free_last =3D txq->nb_tx_free; > + } > + } > + > + return (int)pkt_cnt; > +} > + > +static int > +ice_tx_done_cleanup_vec(struct ice_tx_queue *txq __rte_unused, > + uint32_t free_cnt __rte_unused) > +{ > + return -ENOTSUP; > +} > + > +static int > +ice_tx_done_cleanup_simple(struct ice_tx_queue *txq, > + uint32_t free_cnt) > +{ > + int i, n, cnt; > + > + if (free_cnt =3D=3D 0 || free_cnt > txq->nb_tx_desc) > + free_cnt =3D txq->nb_tx_desc; > + > + cnt =3D free_cnt - free_cnt % txq->tx_rs_thresh; > + > + for (i =3D 0; i < cnt; i +=3D n) { > + if (txq->nb_tx_desc - txq->nb_tx_free < txq->tx_rs_thresh) > + break; > + > + n =3D ice_tx_free_bufs(txq); > + > + if (n =3D=3D 0) > + break; > + } > + > + return i; > +} > + > +int > +ice_tx_done_cleanup(void *txq, uint32_t free_cnt) { > + struct ice_tx_queue *q =3D (struct ice_tx_queue *)txq; > + struct rte_eth_dev *dev =3D &rte_eth_devices[q->port_id]; > + struct ice_adapter *ad =3D > + ICE_DEV_PRIVATE_TO_ADAPTER(dev->data->dev_private); > + > +#ifdef RTE_ARCH_X86 > + if (ad->tx_vec_allowed) > + return ice_tx_done_cleanup_vec(q, free_cnt); #endif > + if (ad->tx_simple_allowed) > + return ice_tx_done_cleanup_simple(q, free_cnt); > + else > + return ice_tx_done_cleanup_full(q, free_cnt); } > + > /* Populate 4 descriptors with data from 4 mbufs */ static inline void > tx4(volatile struct ice_tx_desc *txdp, struct rte_mbuf **pkts) diff --git > a/drivers/net/ice/ice_rxtx.h b/drivers/net/ice/ice_rxtx.h index > 9e3d2cd07..0946ee69e 100644 > --- a/drivers/net/ice/ice_rxtx.h > +++ b/drivers/net/ice/ice_rxtx.h > @@ -202,4 +202,6 @@ uint16_t ice_recv_scattered_pkts_vec_avx2(void > *rx_queue, uint16_t ice_xmit_pkts_vec_avx2(void *tx_queue, struct rte_mb= uf > **tx_pkts, > uint16_t nb_pkts); > int ice_fdir_programming(struct ice_pf *pf, struct ice_fltr_desc *fdir_d= esc); > +int ice_tx_done_cleanup(void *txq, uint32_t free_cnt); > + > #endif /* _ICE_RXTX_H_ */ > -- > 2.17.1