From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20041.outbound.protection.outlook.com [40.107.2.41]) by dpdk.org (Postfix) with ESMTP id 404397D4F for ; Wed, 23 Aug 2017 15:13:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=oh+g/bjaCW3xNLgK6xQ7HssEUbtvc602v6zBG4qUON8=; b=Zu4W9kFVOI8O/WyIg7gUeIXdwrCxO29+QHP0OJtJdeErfJbtmScV5ZiCneL4mNVwd3+WoOh+2KDujUW7obU6rltHtK2iYkLVZLenE/mpn7d/F611AMqjKF4mvSwh4hDFitWupsYGYXqBf+wyf8gHqEpJr+yGG2W2Xvy/72vcYEw= Received: from VI1PR05MB3149.eurprd05.prod.outlook.com (10.170.237.142) by VI1PR05MB3246.eurprd05.prod.outlook.com (10.170.238.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.1362.18; Wed, 23 Aug 2017 13:13:21 +0000 Received: from VI1PR05MB3149.eurprd05.prod.outlook.com ([fe80::8450:1a86:2dd0:82c2]) by VI1PR05MB3149.eurprd05.prod.outlook.com ([fe80::8450:1a86:2dd0:82c2%13]) with mapi id 15.01.1362.019; Wed, 23 Aug 2017 13:13:20 +0000 From: Shahaf Shuler To: "Ananyev, Konstantin" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [RFC PATCH 4/4] ethdev: add helpers to move to the new offloads API Thread-Index: AQHTD2u4RV3tbOCxDUKE02RjhLsQ9qKR99qAgAAKqKA= Date: Wed, 23 Aug 2017 13:13:20 +0000 Message-ID: References: <1e9c5ead0fbd92a3e7fb4c76397cb3dc369eca89.1502096064.git.shahafs@mellanox.com> <2601191342CEEE43887BDE71AB977258489B5073@irsmsx105.ger.corp.intel.com> In-Reply-To: <2601191342CEEE43887BDE71AB977258489B5073@irsmsx105.ger.corp.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; x-originating-ip: [193.47.165.251] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR05MB3246; 6:GDyGJc9k+6grjrihlQoFfYuScRAQWkmOT9w9s5enMmpVTHWc1VQbJ4wyco982+ERXYJt5qQ3Oir0TMHbgshHJxA6PHE167kmilkeeOt7i9VDaqn3NipKbkcd5vkOGpEeD6qYKOwtcdSl1v/pWKDYy7HXWEaAg3EPEy20SvcEWKvTEHRPJSAT9XBIczwU1jlbCFXyG3pm9Wp8PYbApX5ruEP1vsQCEdR4PHEzjjUvsSPDUaw7e8sF35JPFaPH87552WSHK1yGqMpLpOZAix5G+/W0ABvy4HnqBSaf09TLj4ohCgXJKEPaurHZngXqQ5RWr9+hwORzmKiGOJZUCfj0cQ==; 5:vPANkpQNH6kioHaz/OknkeYjWOyGaMOA5Cl09pqz7SO1SBgcgLedNp96NoVmEPJy9a7dTrf/Cy01uAzHgRxtdwzO4KMW35m2sRM8uR8528wSmjtBbBvV/V4JTuiQ9IlHyDmj3pS9u2Gnb1m6H7/YVg==; 24:PByz4FprfpcpDtf+IhdWoXyKOkzvMWTK9/Wqe2f5j6USQihFgrA6oYjHa8vr3AlutrmpPBqJ4dIw5Z1YdtufOMYZmcWQQTX9WgJ6z0u+koU=; 7:n7OHbvdO5b8ETMVacWghR4kT0qzilB+5uDh+xXHFLt/K4yqkzgpT/gmZ7DvTvRkir6DI2anQrOwWYno4oBeBgWRH9JZf7xqCU22bDAyKFAfhqspinr3dnEShS83Deh0U/uY+jiEHSw+8zPyfFZAJWmb9YkkXezzBNZsru9Z9qse+ioIR0ZvUajyF7OBH2kKU/aHPvW26H5VpFpx/zhdGZAUu2xgWDLZP6uyMZdw+k8c= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: 1c44071a-68e7-48f9-44ab-08d4ea28ba2c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603184)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:VI1PR05MB3246; x-ms-traffictypediagnostic: VI1PR05MB3246: x-exchange-antispam-report-test: UriScan:(278428928389397); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(3002001)(93006095)(93001095)(100000703101)(100105400095)(10201501046)(6055026)(6041248)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:VI1PR05MB3246; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:VI1PR05MB3246; x-forefront-prvs: 040866B734 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(13464003)(189002)(377454003)(199003)(50986999)(8936002)(81166006)(305945005)(14454004)(6246003)(81156014)(76176999)(9686003)(54356999)(99286003)(53936002)(25786009)(55016002)(2906002)(7736002)(6436002)(68736007)(53546010)(66066001)(86362001)(478600001)(101416001)(5250100002)(33656002)(2900100001)(74316002)(3660700001)(6116002)(102836003)(97736004)(2950100002)(2501003)(189998001)(7696004)(3846002)(106356001)(105586002)(5660300001)(3280700002)(6506006)(229853002)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR05MB3246; H:VI1PR05MB3149.eurprd05.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Aug 2017 13:13:20.8512 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR05MB3246 Subject: Re: [dpdk-dev] [RFC PATCH 4/4] ethdev: add helpers to move to the new offloads API 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: , X-List-Received-Date: Wed, 23 Aug 2017 13:13:22 -0000 Wednesday, August 23, 2017 3:29 PM, Ananyev, Konstantin: >=20 >=20 > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Shahaf Shuler > > Sent: Monday, August 7, 2017 1:55 PM > > To: dev@dpdk.org > > Subject: [dpdk-dev] [RFC PATCH 4/4] ethdev: add helpers to move to the > > new offloads API > > > > A new offloads API was introduced by commits: > > > > commit 8b07fcae6061 ("ethdev: introduce Tx queue offloads API") commit > > c6504557763e ("ethdev: introduce Rx queue offloads API") > > > > In order to enable PMDs to support only one of the APIs, and > > applications to avoid branching according to the underlying device a > > copy functions to/from the old/new APIs were added. > > > > Signed-off-by: Shahaf Shuler > > --- > > lib/librte_ether/rte_ethdev.c | 140 > > +++++++++++++++++++++++++++++++++++++ > > 1 file changed, 140 insertions(+) > > > > diff --git a/lib/librte_ether/rte_ethdev.c > > b/lib/librte_ether/rte_ethdev.c index f73307e99..2b4a28c97 100644 > > --- a/lib/librte_ether/rte_ethdev.c > > +++ b/lib/librte_ether/rte_ethdev.c > > @@ -1003,6 +1003,63 @@ rte_eth_dev_close(uint8_t port_id) > > dev->data->tx_queues =3D NULL; > > } > > > > +/** > > + * A copy function from rxmode offloads API to rte_eth_rxq_conf > > + * offloads API, to enable PMDs to support only one of the APIs. > > + */ > > +static void > > +rte_eth_copy_rxmode_offloads(struct rte_eth_rxmode *rxmode, > > + struct rte_eth_rxq_conf *rxq_conf) { > > + if (rxmode->header_split =3D=3D 1) > > + rxq_conf->offloads |=3D DEV_RX_OFFLOAD_HEADER_SPLIT; > > + if (rxmode->hw_ip_checksum =3D=3D 1) > > + rxq_conf->offloads |=3D DEV_RX_OFFLOAD_CHECKSUM; > > + if (rxmode->hw_vlan_filter =3D=3D 1) > > + rxq_conf->offloads |=3D DEV_RX_OFFLOAD_VLAN_FILTER; > > + if (rxmode->hw_vlan_strip =3D=3D 1) > > + rxq_conf->offloads |=3D DEV_RX_OFFLOAD_VLAN_STRIP; > > + if (rxmode->hw_vlan_extend =3D=3D 1) > > + rxq_conf->offloads |=3D DEV_RX_OFFLOAD_VLAN_EXTEND; > > + if (rxmode->jumbo_frame =3D=3D 1) > > + rxq_conf->offloads |=3D DEV_RX_OFFLOAD_JUMBO_FRAME; > > + if (rxmode->hw_strip_crc =3D=3D 1) > > + rxq_conf->offloads |=3D DEV_RX_OFFLOAD_CRC_STRIP; > > + if (rxmode->enable_scatter =3D=3D 1) > > + rxq_conf->offloads |=3D DEV_RX_OFFLOAD_SCATTER; > > + if (rxmode->enable_lro =3D=3D 1) > > + rxq_conf->offloads |=3D DEV_RX_OFFLOAD_LRO; } > > + > > +/** > > + * A copy function between rte_eth_rxq_conf offloads API to rxmode > > + * offloads API, to enable application to be agnostic to the PMD > > +supported > > + * offload API. > > + */ > > +static void > > +rte_eth_copy_rxq_offloads(struct rte_eth_rxmode *rxmode, > > + struct rte_eth_rxq_conf *rxq_conf) { > > + if (rxq_conf->offloads & DEV_RX_OFFLOAD_HEADER_SPLIT) > > + rxmode->header_split =3D 1; > > + if (rxq_conf->offloads & DEV_RX_OFFLOAD_CHECKSUM) > > + rxmode->hw_ip_checksum =3D 1; > > + if (rxq_conf->offloads & DEV_RX_OFFLOAD_VLAN_FILTER) > > + rxmode->hw_vlan_filter =3D 1; > > + if (rxq_conf->offloads & DEV_RX_OFFLOAD_VLAN_STRIP) > > + rxmode->hw_vlan_strip =3D 1; > > + if (rxq_conf->offloads & DEV_RX_OFFLOAD_VLAN_EXTEND) > > + rxmode->hw_vlan_extend =3D 1; > > + if (rxq_conf->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) > > + rxmode->jumbo_frame =3D 1; > > + if (rxq_conf->offloads & DEV_RX_OFFLOAD_CRC_STRIP) > > + rxmode->hw_strip_crc =3D 1; > > + if (rxq_conf->offloads & DEV_RX_OFFLOAD_SCATTER) > > + rxmode->enable_scatter =3D 1; > > + if (rxq_conf->offloads & DEV_RX_OFFLOAD_LRO) > > + rxmode->enable_lro =3D 1; > > +} > > + > > int > > rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, > > uint16_t nb_rx_desc, unsigned int socket_id, @@ -1083,6 > > +1140,37 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t > rx_queue_id, > > if (rx_conf =3D=3D NULL) > > rx_conf =3D &dev_info.default_rxconf; > > > > + if ((dev->data->dev_flags & RTE_ETH_DEV_RXQ_OFFLOAD) && > > + (dev->data->dev_conf.rxmode.ignore =3D=3D 0)) { > > + rte_eth_copy_rxmode_offloads(&dev->data- > >dev_conf.rxmode, > > + rx_conf); > > + } else if ((!(dev->data->dev_flags & RTE_ETH_DEV_RXQ_OFFLOAD)) > && > > + (dev->data->dev_conf.rxmode.ignore =3D=3D 1)) { > > + int ret; > > + struct rte_eth_rxmode rxmode; > > + > > + rte_eth_copy_rxq_offloads(&rxmode, rx_conf); > > + if (memcmp(&rxmode, &dev->data->dev_conf.rxmode, > > + sizeof(rxmode))) { > > + /* > > + * device which work with rxmode offloads API > requires > > + * a re-configuration in order to apply the new > offloads > > + * configuration. > > + */ > > + dev->data->dev_conf.rxmode =3D rxmode; > > + ret =3D rte_eth_dev_configure(port_id, > > + dev->data->nb_rx_queues, > > + dev->data->nb_tx_queues, > > + &dev->data->dev_conf); >=20 >=20 > Hmm, and why we would need to reconfigure our device in the middle of rx > queue setup? The reason is the old Rx offloads API is configured on device configure.=20 This if section is for applications which already moved to the new offload = API however the underlying PMD still uses the old one. >=20 > > + if (ret < 0) { > > + RTE_PMD_DEBUG_TRACE( > > + "unable to re-configure port %d " > > + "in order to apply rxq offloads " > > + "configuration\n", port_id); > > + } > > + } > > + } > > + > > ret =3D (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, > nb_rx_desc, > > socket_id, rx_conf, mp); >=20 > BTW, I don't see changes in any PMD for new offload flags? > Is it because it is just a n RFC and full patch would contain such change= s? Yes this is because this is an RFC. =20 The full patch I intend will move all examples and testpmd to the new offlo= ads API. In addition it will include the mlx5 PMD support for the new offloads API.= =20 As I said on previous mail, I believe that the work to move the different P= MDs to the new API should be done by their developers or maintainers. >=20 >=20 > > if (!ret) { > > @@ -1094,6 +1182,51 @@ rte_eth_rx_queue_setup(uint8_t port_id, > uint16_t rx_queue_id, > > return ret; > > } > > > > +/** > > + * A copy function from txq_flags to rte_eth_txq_conf offloads API, > > + * to enable PMDs to support only one of the APIs. > > + */ > > +static void > > +rte_eth_copy_txq_flags(struct rte_eth_txq_conf *txq_conf) { > > + uint32_t txq_flags =3D txq_conf->txq_flags > > + uint64_t *offloads =3D &txq_conf->offloads; > > + > > + if (!(txq_flags & ETH_TXQ_FLAGS_NOMULTSEGS)) > > + *offloads |=3D DEV_TX_OFFLOAD_MULTI_SEGS; > > + if (!(txq_flags & ETH_TXQ_FLAGS_NOVLANOFFL)) > > + *offloads |=3D DEV_TX_OFFLOAD_VLAN_INSERT; > > + if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP)) > > + *offloads |=3D DEV_TX_OFFLOAD_SCTP_CKSUM; > > + if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMUDP)) > > + *offloads |=3D DEV_TX_OFFLOAD_UDP_CKSUM; > > + if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMTCP)) > > + *offloads |=3D DEV_TX_OFFLOAD_TCP_CKSUM; } > > + > > +/** > > + * A copy function between rte_eth_txq_conf offloads API to txq_flags > > + * offloads API, to enable application to be agnostic to the PMD > > +supported > > + * API. > > + */ > > +static void > > +rte_eth_copy_txq_offloads(struct rte_eth_txq_conf *txq_conf) { > > + uint32_t *txq_flags =3D &txq_conf->txq_flags > > + uint64_t offloads =3D txq_conf->offloads; > > + > > + if (!(offloads & DEV_TX_OFFLOAD_MULTI_SEGS)) > > + *txq_flags |=3D ETH_TXQ_FLAGS_NOMULTSEGS; > > + if (!(offloads & DEV_TX_OFFLOAD_VLAN_INSERT)) > > + *txq_flags |=3D ETH_TXQ_FLAGS_NOVLANOFFL; > > + if (!(offloads & DEV_TX_OFFLOAD_SCTP_CKSUM)) > > + *txq_flags |=3D ETH_TXQ_FLAGS_NOXSUMSCTP; > > + if (!(offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) > > + *txq_flags |=3D ETH_TXQ_FLAGS_NOXSUMUDP; > > + if (!(offloads & DEV_TX_OFFLOAD_TCP_CKSUM)) > > + *txq_flags |=3D ETH_TXQ_FLAGS_NOXSUMTCP; } > > + > > int > > rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx_queue_id, > > uint16_t nb_tx_desc, unsigned int socket_id, @@ -1145,6 > > +1278,13 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t > tx_queue_id, > > if (tx_conf =3D=3D NULL) > > tx_conf =3D &dev_info.default_txconf; > > > > + if ((dev->data->dev_flags & RTE_ETH_DEV_TXQ_OFFLOAD) && > > + (!(tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE))) > > + rte_eth_copy_txq_flags(tx_conf); > > + else if (!(dev->data->dev_flags & RTE_ETH_DEV_TXQ_OFFLOAD) && > > + (tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE)) > > + rte_eth_copy_txq_offloads(tx_conf); > > + >=20 > As I said in my previous mail - I think better to always convrert from ol= d > txq_flags to new TX offload flags and make each PMD to understand new > offload values only. > Konstantin >=20 > > return (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, > nb_tx_desc, > > socket_id, tx_conf); > > } > > -- > > 2.12.0