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 32EE8A04F2; Mon, 30 Dec 2019 14:01:26 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 04BEA1C114; Mon, 30 Dec 2019 14:01:26 +0100 (CET) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by dpdk.org (Postfix) with ESMTP id 78DA01C031 for ; Mon, 30 Dec 2019 14:01:23 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Dec 2019 05:01:21 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,375,1571727600"; d="scan'208";a="301254689" Received: from fmsmsx106.amr.corp.intel.com ([10.18.124.204]) by orsmga001.jf.intel.com with ESMTP; 30 Dec 2019 05:01:20 -0800 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX106.amr.corp.intel.com (10.18.124.204) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 30 Dec 2019 05:01:20 -0800 Received: from FMSEDG001.ED.cps.intel.com (10.1.192.133) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 30 Dec 2019 05:01:20 -0800 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (104.47.70.103) by edgegateway.intel.com (192.55.55.68) with Microsoft SMTP Server (TLS) id 14.3.439.0; Mon, 30 Dec 2019 05:01:20 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fpAeBi9I3z7d3jKT9+v07vHuoXiUPz5IByHZA/atYIZnPbWiaZ+F0FSczM3SV5z+4AaLkNpNkCjK2VlA2rjDFSIjnvj5z5Ntehz49TGO1sZPXtEIiivamMYPfKDpp9AyOJduiFkjsGA+u7O4RuvNdCZ7GsWASwuk/Dw9RnhSrcjwwYGeWEvmMJL5+Y6vD7DLYcEssLJ/KrTV49S9KyAZUahuXtwxufXsxYwjBHWxiEcSmJCJZMLtW5sasalvEPAJMO9bKDCpbSlKm3BpyXe/opvDypts1fzg9VkwJZjHFuahn6DkidtPMpZUpBMAkHcDO+LiMxxnisfiKHCHXD+piw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g10pbmib4PP0P8KtF6rFRF6xWjct00PjfPQ/IE/zGB8=; b=YlaERL+6hCUhmKcPYchxiy9dZerOo2B/EBpTROblIwzG2bmIDSvI0rBRP+7jAnVxLiDNh4joMoD8mLScbPlNeYqwrJboKWqAW0KqiV2W7FcsQBbmMOylh0u8+vqbkJculNIqqn41dSbYLsYtL0qV01MAfHSFF1ss3VsFf9kEdfxqngQ+YhnHvFHJFgh9uqCJ69SdRUsF/AGa8aV4rzSnYRhTFMiHnl4SUZPJC+DfFDHiA8MAU4XS8Ro+XZDihqVpWsW8T3lFJn8aufN3gKqJgDrlEjO0LZbL/X8brjFViqM6mpdhIJRj7gDUrfzCU//QLT/OPZPfMcR+4ov6DGJiAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g10pbmib4PP0P8KtF6rFRF6xWjct00PjfPQ/IE/zGB8=; b=oiRZYVqYr78gEbS71PV8o70aC56O/xq7xbhkqrTmDMwYax+/UBJibaVD4cWMKS33AUdE+osHBx71eEa0tQDRmeQDoFmSCWHoNf9pyjsqXYsnXmIV9NuDbEfLdiWG3uwtzdct7LFlhZXuI+XEb6KUNS0I0pgUso2kOywFD+RsD5E= Received: from SN6PR11MB2558.namprd11.prod.outlook.com (52.135.94.19) by SN6PR11MB2992.namprd11.prod.outlook.com (52.135.126.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2581.11; Mon, 30 Dec 2019 13:01:18 +0000 Received: from SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::4d86:362a:13c3:8386]) by SN6PR11MB2558.namprd11.prod.outlook.com ([fe80::4d86:362a:13c3:8386%7]) with mapi id 15.20.2581.007; Mon, 30 Dec 2019 13:01:18 +0000 From: "Ananyev, Konstantin" To: "Di, ChenxuX" , "dev@dpdk.org" CC: "Yang, Qiming" , "Di, ChenxuX" Thread-Topic: [dpdk-dev] [PATCH v6 1/4] net/i40e: cleanup Tx buffers Thread-Index: AQHVvvUfJRpZoMK2o0erOSlOkYI1U6fSpF3A Date: Mon, 30 Dec 2019 13:01:18 +0000 Message-ID: References: <20191203055134.72874-1-chenxux.di@intel.com> <20191230093840.17701-1-chenxux.di@intel.com> <20191230093840.17701-2-chenxux.di@intel.com> In-Reply-To: <20191230093840.17701-2-chenxux.di@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZWU0NzI1YjktZTI4OC00OTNkLWI1YjAtNDk2MTU2NTlhMjMyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiOVJ0cnk5QVhiVDFvYTVJdjd5TDVXY0psbHZzWkVlQitTRlpEUFBHVUJhcjJrRkEwbDRuQzhlTFQrY1VUcnFMeiJ9 dlp-product: dlpe-windows dlp-reaction: no-action dlp-version: 11.2.0.6 x-ctpclassification: CTP_NT authentication-results: spf=none (sender IP is ) smtp.mailfrom=konstantin.ananyev@intel.com; x-originating-ip: [46.7.38.224] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0985c7c7-f7c5-40ea-a6bd-08d78d285c60 x-ms-traffictypediagnostic: SN6PR11MB2992: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7691; x-forefront-prvs: 0267E514F9 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(396003)(366004)(346002)(376002)(189003)(199004)(9686003)(66556008)(64756008)(55016002)(5660300002)(478600001)(66446008)(66476007)(66946007)(8936002)(81166006)(81156014)(8676002)(76116006)(52536014)(71200400001)(26005)(6506007)(107886003)(7696005)(186003)(33656002)(86362001)(54906003)(4326008)(110136005)(316002)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:SN6PR11MB2992; H:SN6PR11MB2558.namprd11.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: Enrhrz5G4Ee4Rjl/2kEUUWlV+EjAgutFdwoTKEtUY4TBTdXf+4GisKZ4co+imV0rvAPguyZbm071+9xc6veTb4nrYilnSnOPLHZ6dpxN/j1FRf2YDpngGkSfgrnXhlwfMuaWlqKgDY2E1h8e6k3fwaBb/ODrAcxCxlPOMwaIiEV2qUQlwte6ZQ+5bjlbo6fGyuj0l1GDkQG9K4hG9TMrtZ2rzxArC7afxaDveqInGBxgS9YsI9iR6vJRbJj5qBfWtmxXLDI2L+Erdhg1gKrL+NHsCMglBhjaWhmfr/oHazlglcqDz37hmiZnW9foRnMkHUui6yp3hfum++ODSe19PEnFIinX/QeoVrxI2vaTX+Vb8YIcVeHBe3OSQLN+F1wDLS/BlPnT8+Uf2XrR5S5BXqRP4OppQUebxzp2cNuBDy7DU49HcAliqqtmCJScvXen Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: 0985c7c7-f7c5-40ea-a6bd-08d78d285c60 X-MS-Exchange-CrossTenant-originalarrivaltime: 30 Dec 2019 13:01:18.2072 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: GUC49tJzh4pukXPz8FJmcNX2SjfYDS4KFGNl5qSlQ1KOZ/VwLxY79ORMc6eZ6HZRQl5A3nB80g3lf+4OPEv9YcgqDZ9JYXCmZQH3gFJkBUQ= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR11MB2992 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH v6 1/4] net/i40e: 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" >=20 > Add support to the i40e driver for the API rte_eth_tx_done_cleanup > to force free consumed buffers on Tx ring. >=20 > Signed-off-by: Chenxu Di > --- > drivers/net/i40e/i40e_ethdev.c | 1 + > drivers/net/i40e/i40e_ethdev_vf.c | 1 + > drivers/net/i40e/i40e_rxtx.c | 121 ++++++++++++++++++++++++++++++ > drivers/net/i40e/i40e_rxtx.h | 1 + > 4 files changed, 124 insertions(+) >=20 > diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethde= v.c > index 5999c964b..fad47a942 100644 > --- a/drivers/net/i40e/i40e_ethdev.c > +++ b/drivers/net/i40e/i40e_ethdev.c > @@ -522,6 +522,7 @@ static const struct eth_dev_ops i40e_eth_dev_ops =3D = { > .mac_addr_set =3D i40e_set_default_mac_addr, > .mtu_set =3D i40e_dev_mtu_set, > .tm_ops_get =3D i40e_tm_ops_get, > + .tx_done_cleanup =3D i40e_tx_done_cleanup, > }; >=20 > /* store statistics names and its offset in stats structure */ > diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_et= hdev_vf.c > index 5dba0928b..0ca5417d7 100644 > --- a/drivers/net/i40e/i40e_ethdev_vf.c > +++ b/drivers/net/i40e/i40e_ethdev_vf.c > @@ -215,6 +215,7 @@ static const struct eth_dev_ops i40evf_eth_dev_ops = =3D { > .rss_hash_conf_get =3D i40evf_dev_rss_hash_conf_get, > .mtu_set =3D i40evf_dev_mtu_set, > .mac_addr_set =3D i40evf_set_default_mac_addr, > + .tx_done_cleanup =3D i40e_tx_done_cleanup, > }; >=20 > /* > diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c > index 17dc8c78f..883419bd7 100644 > --- a/drivers/net/i40e/i40e_rxtx.c > +++ b/drivers/net/i40e/i40e_rxtx.c > @@ -2455,6 +2455,127 @@ i40e_tx_queue_release_mbufs(struct i40e_tx_queue = *txq) > } > } >=20 > +int i40e_tx_done_cleanup(void *q, uint32_t free_cnt) > +{ > + struct i40e_tx_queue *txq =3D (struct i40e_tx_queue *)q; > + struct i40e_tx_entry *sw_ring; > + volatile struct i40e_tx_desc *txr; > + uint16_t tx_first; /* First segment analyzed. */ > + uint16_t tx_id; /* Current segment being processed. */ > + uint16_t tx_last; /* Last segment in the current packet. */ > + uint16_t tx_next; /* First segment of the next packet. */ > + int count; > + > + if (txq =3D=3D NULL) > + return -ENODEV; > + > + count =3D 0; > + sw_ring =3D txq->sw_ring; > + txr =3D txq->tx_ring; > + > + /* > + * tx_tail is the last sent packet on the sw_ring. Goto the end > + * of that packet (the last segment in the packet chain) and > + * then the next segment will be the start of the oldest segment > + * in the sw_ring. This is the first packet that will be > + * attempted to be freed. > + */ Pretty much same comments as for ixgbe. > + > + /* Get last segment in most recently added packet. */ > + tx_last =3D sw_ring[txq->tx_tail].last_id; > + > + /* Get the next segment, which is the oldest segment in ring. */ > + tx_first =3D sw_ring[tx_last].next_id; > + > + /* Set the current index to the first. */ > + tx_id =3D tx_first; > + > + /* > + * Loop through each packet. For each packet, verify that an > + * mbuf exists and that the last segment is free. If so, free > + * it and move on. > + */ > + while (1) { > + tx_last =3D sw_ring[tx_id].last_id; > + > + if (sw_ring[tx_last].mbuf) { > + if ((txr[tx_last].cmd_type_offset_bsz & > + rte_cpu_to_le_64(I40E_TXD_QW1_DTYPE_MASK)) !=3D > + rte_cpu_to_le_64(I40E_TX_DESC_DTYPE_DESC_DONE)) > + /* > + * mbuf still in use, nothing left to > + * free. > + */ > + break; > + > + /* Get the start of the next packet. */ > + tx_next =3D sw_ring[tx_last].next_id; > + > + /* > + * Loop through all segments in a > + * packet. > + */ > + do { > + rte_pktmbuf_free_seg(sw_ring[tx_id].mbuf); > + sw_ring[tx_id].mbuf =3D NULL; > + sw_ring[tx_id].last_id =3D tx_id; > + > + /* Move to next segment. */ > + tx_id =3D sw_ring[tx_id].next_id; > + > + } while (tx_id !=3D tx_next); > + > + /* > + * Increment the number of packets > + * freed. > + */ > + count++; > + > + if (unlikely(count =3D=3D (int)free_cnt)) > + break; > + } else { > + /* > + * There are multiple reasons to be here: > + * 1) All the packets on the ring have been > + * freed - tx_id is equal to tx_first > + * and some packets have been freed. > + * - Done, exit > + * 2) Interfaces has not sent a rings worth of > + * packets yet, so the segment after tail is > + * still empty. Or a previous call to this > + * function freed some of the segments but > + * not all so there is a hole in the list. > + * Hopefully this is a rare case. > + * - Walk the list and find the next mbuf. If > + * there isn't one, then done. > + */ > + if (likely(tx_id =3D=3D tx_first && count !=3D 0)) > + break; > + > + /* > + * Walk the list and find the next mbuf, if any. > + */ > + do { > + /* Move to next segment. */ > + tx_id =3D sw_ring[tx_id].next_id; > + > + if (sw_ring[tx_id].mbuf) > + break; > + > + } while (tx_id !=3D tx_first); > + > + /* > + * Determine why previous loop bailed. If there > + * is not an mbuf, done. > + */ > + if (sw_ring[tx_id].mbuf =3D=3D NULL) > + break; > + } > + } > + > + return count; > +} > + > void > i40e_reset_tx_queue(struct i40e_tx_queue *txq) > { > diff --git a/drivers/net/i40e/i40e_rxtx.h b/drivers/net/i40e/i40e_rxtx.h > index 2106bb355..8f11f011a 100644 > --- a/drivers/net/i40e/i40e_rxtx.h > +++ b/drivers/net/i40e/i40e_rxtx.h > @@ -212,6 +212,7 @@ void i40e_dev_free_queues(struct rte_eth_dev *dev); > void i40e_reset_rx_queue(struct i40e_rx_queue *rxq); > void i40e_reset_tx_queue(struct i40e_tx_queue *txq); > void i40e_tx_queue_release_mbufs(struct i40e_tx_queue *txq); > +int i40e_tx_done_cleanup(void *txq, uint32_t free_cnt); > int i40e_alloc_rx_queue_mbufs(struct i40e_rx_queue *rxq); > void i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq); >=20 > -- > 2.17.1