From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 18D7A16E for ; Mon, 4 Sep 2017 14:13:51 +0200 (CEST) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga104.jf.intel.com with ESMTP; 04 Sep 2017 05:13:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,474,1498546800"; d="scan'208";a="145275041" Received: from irsmsx109.ger.corp.intel.com ([163.33.3.23]) by orsmga005.jf.intel.com with ESMTP; 04 Sep 2017 05:13:50 -0700 Received: from irsmsx105.ger.corp.intel.com ([169.254.7.75]) by IRSMSX109.ger.corp.intel.com ([169.254.13.28]) with mapi id 14.03.0319.002; Mon, 4 Sep 2017 13:13:48 +0100 From: "Ananyev, Konstantin" To: Shahaf Shuler , "thomas@monjalon.net" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 4/4] ethdev: add helpers to move to the new offloads API Thread-Index: AQHTJU1fVpbLAok7P06kzXdRtIICjKKkoe+w Date: Mon, 4 Sep 2017 12:13:48 +0000 Message-ID: <2601191342CEEE43887BDE71AB9772584F245F90@irsmsx105.ger.corp.intel.com> References: <810c1d26724f82f0d9fc9d6684dc4b1c62fd5f62.1504508375.git.shahafs@mellanox.com> In-Reply-To: <810c1d26724f82f0d9fc9d6684dc4b1c62fd5f62.1504508375.git.shahafs@mellanox.com> Accept-Language: en-IE, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [163.33.239.180] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [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: Mon, 04 Sep 2017 12:13:52 -0000 > -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Shahaf Shuler > Sent: Monday, September 4, 2017 8:12 AM > To: thomas@monjalon.net > Cc: dev@dpdk.org > Subject: [dpdk-dev] [PATCH 4/4] ethdev: add helpers to move to the new of= floads API >=20 > A new offloads API was introduced by commits: >=20 > commit 121fff673172 ("ethdev: introduce Rx queue offloads API") > commit 35ac80d92f29 ("ethdev: introduce Tx queue offloads API") >=20 > In order to enable the PMDs to support only one of the APIs, > a conversion functions from the old to new API were added. >=20 > Signed-off-by: Shahaf Shuler > --- > lib/librte_ether/rte_ethdev.c | 99 +++++++++++++++++++++++++++++++++++++= - > 1 file changed, 97 insertions(+), 2 deletions(-) >=20 > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.= c > index 50f8aa98d..1aa21a129 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -1006,6 +1006,34 @@ rte_eth_dev_close(uint8_t port_id) > dev->data->tx_queues =3D NULL; > } >=20 > +/** > + * A conversion function from rxmode offloads API to rte_eth_rxq_conf > + * offloads API. > + */ > +static void > +rte_eth_convert_rxmode_offloads(struct rte_eth_rxmode *rxmode, > + struct rte_eth_rxq_conf *rxq_conf) > +{ I think you need to: rxq_conf->offloads =3D 0; first here. > + 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_TCP_LRO; > +} > + > int > rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, > uint16_t nb_rx_desc, unsigned int socket_id, > @@ -1016,6 +1044,8 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx= _queue_id, > uint32_t mbp_buf_size; > struct rte_eth_dev *dev; > struct rte_eth_dev_info dev_info; > + struct rte_eth_rxq_conf rxq_trans_conf; > + /* Holds translated configuration to be passed to the PMD */ > void **rxq; >=20 > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); > @@ -1062,6 +1092,11 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t r= x_queue_id, > return -EINVAL; > } >=20 > + if ((!(dev->data->dev_flags & RTE_ETH_DEV_RXQ_OFFLOAD)) && > + (dev->data->dev_conf.rxmode.ignore_offloads =3D=3D 1)) { > + return -ENOTSUP; > + } > + > if (nb_rx_desc > dev_info.rx_desc_lim.nb_max || > nb_rx_desc < dev_info.rx_desc_lim.nb_min || > nb_rx_desc % dev_info.rx_desc_lim.nb_align !=3D 0) { > @@ -1086,8 +1121,15 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t r= x_queue_id, > if (rx_conf =3D=3D NULL) > rx_conf =3D &dev_info.default_rxconf; >=20 > + rxq_trans_conf =3D *rx_conf; > + if ((dev->data->dev_flags & RTE_ETH_DEV_RXQ_OFFLOAD) && > + (dev->data->dev_conf.rxmode.ignore_offloads =3D=3D 0)) { > + rte_eth_convert_rxmode_offloads(&dev->data->dev_conf.rxmode, > + &rxq_trans_conf); > + } > + > ret =3D (*dev->dev_ops->rx_queue_setup)(dev, rx_queue_id, nb_rx_desc, > - socket_id, rx_conf, mp); > + socket_id, &rxq_trans_conf, mp); > if (!ret) { > if (!dev->data->min_rx_buf_size || > dev->data->min_rx_buf_size > mbp_buf_size) > @@ -1097,6 +1139,49 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t r= x_queue_id, > return ret; > } >=20 > +/** > + * A conversion function from txq_flags to rte_eth_txq_conf offloads API= . > + */ > +static void > +rte_eth_convert_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; I think you need to: *offloads =3D 0; first here. BTW, might be a bit cleaner: uint64_t offloads; offloads =3D 0; txq_conf->tx_offloads =3D offloads; Konstantin > + > + 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 conversion function between rte_eth_txq_conf offloads API to txq_fl= ags > + * offloads API. > + */ > +static void > +rte_eth_convert_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, > @@ -1104,6 +1189,8 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t tx= _queue_id, > { > struct rte_eth_dev *dev; > struct rte_eth_dev_info dev_info; > + struct rte_eth_txq_conf txq_trans_conf; > + /* Holds translated configuration to be passed to the PMD */ > void **txq; >=20 > RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EINVAL); > @@ -1148,8 +1235,16 @@ rte_eth_tx_queue_setup(uint8_t port_id, uint16_t t= x_queue_id, > if (tx_conf =3D=3D NULL) > tx_conf =3D &dev_info.default_txconf; >=20 > + txq_trans_conf =3D *tx_conf; > + if ((dev->data->dev_flags & RTE_ETH_DEV_TXQ_OFFLOAD) && > + (!(tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE))) > + rte_eth_convert_txq_flags(&txq_trans_conf); > + else if (!(dev->data->dev_flags & RTE_ETH_DEV_TXQ_OFFLOAD) && > + (tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE)) > + rte_eth_convert_txq_offloads(&txq_trans_conf); > + > return (*dev->dev_ops->tx_queue_setup)(dev, tx_queue_id, nb_tx_desc, > - socket_id, tx_conf); > + socket_id, &txq_trans_conf); > } >=20 > void > -- > 2.12.0