From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on0067.outbound.protection.outlook.com [104.47.0.67]) by dpdk.org (Postfix) with ESMTP id C8D1C7CC5 for ; Mon, 4 Sep 2017 09:12:29 +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=IR4/iVzKuMy/PvPk8Fi6J15yEuqSm/DQF17jIQ1Vu80=; b=W5Ti0/CeuEjzdG3MVmBm+ECuxWTcJIcPJecEv9GRTiwiRzK2LBrcbjwaHTkHyONqMGBA24FORIWbWENxgaV5MlJorLuKdNO8eXapv2i+YdTYngzJbXdTwnWMJj6lEu2p4hCvvF7q7DPHH0jhWnq4g2DLSn4vicgF+mWCAVAwzgI= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=shahafs@mellanox.com; Received: from mellanox.com (82.166.227.17) by HE1PR05MB3148.eurprd05.prod.outlook.com (2603:10a6:7:36::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Mon, 4 Sep 2017 07:12:28 +0000 From: Shahaf Shuler To: thomas@monjalon.net Cc: dev@dpdk.org Date: Mon, 4 Sep 2017 10:12:18 +0300 Message-Id: <810c1d26724f82f0d9fc9d6684dc4b1c62fd5f62.1504508375.git.shahafs@mellanox.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [82.166.227.17] X-ClientProxiedBy: HE1PR07CA0005.eurprd07.prod.outlook.com (2603:10a6:7:67::15) To HE1PR05MB3148.eurprd05.prod.outlook.com (2603:10a6:7:36::18) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 009cfd12-ec71-4567-5534-08d4f3644d7a 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)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:HE1PR05MB3148; X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB3148; 3:1U5qvLE4XgLWUomjkHfyCtYAyoUyzErBrGovDjlQGfE1d9QmG8KjygIcuBzF7Qk2XF5KBCleia2HXsedv/ghjJ66I+/LsgNPF18WDPleKT0WCUESVucJC3AkHCzfLR5f50tL0B0DfSL7/+vl+9v1fukIRwlS5j5fCOC+pJROlsg/EnuYTompAdcJOhf4Ce99DmVzliYm1tYRStS7EM3BS2DtXo4CMBYYllLS4AzTAUN50tqISD9d39fTyKbwCOab; 25:nIHvYXeq4qzqA2jMih2n0yawP3iR9g2Hb9ZtnKhkqm8tt6QbZFZ3P1jaUBp8v7KEviM9tuINL4iSCPwfrRnDhsNDl0sMk8y6GVpN7XJ2Xc8IPuE7soFAh8t9/NAAftTilrdRSxCYTCBAUbx/F/uz16/KMz5VLfmtPz7l1d6XYLrX1Sq3Tz9MxVjuIfcXLpRsgbIy5tp3S9/Q96JMMyDyXnquwvziEkk+azM3Nf8jbDEsFmIASfXjtRF9IzfLwvWbrI3hmBFWoxLxBS0dM1/sByXf0es/O0MHHMVpW+m7P7TOAdBgjNtenW1oOZ4FfHibkUQY/kGO557rd3qXkZ/aTw==; 31:j2qeaRwTrsa99UZ/PSn2vuwCOxm7ni7R4AnrhYfwrqrFQzSYQZXr41xlRXn7oAX1JD7Km92jPjh4lhAb2dIczNtN7dc4mTsPFdWnb40GMrdGKQtFVbpmZxenJXPTdpMKJrVbuJWQrv3SQZuk7CAGjfeHTOQY9D7a+QWsj6O5IWN7wV4lnK7iBdzMOnVDrC1UIlSMms64tjHLErXk7dTNB0oYul5xM1mryvcPYsHEUBU= X-MS-TrafficTypeDiagnostic: HE1PR05MB3148: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB3148; 20:paAbmLn3fQp2ewUeph2LlKc7EXamqawysd/U9KKL7URnjh02Yerklji1ly8vPZexFuQxJOcbSMz+LSkfUXJmL/Wb6MsxDu/dwDNoiw3WPj1hTmJjSEjm4c2PXIO7cJ5KW5Mcs+mJpc1YWxLugBnzNKDa/9RSykSqdUe7oClg6cCIO2Y+dHYXhCxKQiCwa462eKJND46a1plF9QCQ2KcLGYol6JlFH3BcasOMpt/uN/o/TeJQHSBtu1YGP1nh3z9EP0m7qlpa/Bv4/7eYnaQE6axqZCK+9MLplKR9qq/ORUBBzO/80L43c/+GZ7tlGpw9aSi5A/TibY5VJOcqpKP3CFqsQHXSD6MmmvbaIgl0bQGZCTuHHR5N3+Qpv4JR62geEtcKZVs1fNtApYm2xZj7NGQtl61H7lYCrHkHS6Z5iR4rWkzHLkYKMFmHGcyTkuYc014eodsQA8OoJd/ioIvvtmSNcJHAJHyyhDHXYHJ1kHrD5iWc7Qh594v+Ioxl7cvi; 4:u6dKGaiP1gNV+8fyPUPbxFwQCmsdxaXGTyYxG10xivxLjnPCc6NkQi3dLvecViY4AI0BMfHpChvBkYv8G5QE/Yf1IGMl4FMCQWmM+THf/tgzEEQb0E95nWr8etEpVGmtCL/ga8hMXTF5xfx/gWUbLaQoWBbIAmtC6zyGSOS2tqWsgwmQ/WvokynPl3N1u+RiWpnxnp13BfSkLUW8IuSnhlxgqgv19Fw2k2+IowchmfVigYyLxXXe8aJbnUr86OMz X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(20161123555025)(20161123560025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123564025)(20161123558100)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:HE1PR05MB3148; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:HE1PR05MB3148; X-Forefront-PRVS: 0420213CCD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(7370300001)(6009001)(39860400002)(189002)(199003)(105586002)(36756003)(69596002)(97736004)(4326008)(305945005)(5003940100001)(2950100002)(7736002)(6916009)(106356001)(50226002)(53936002)(86362001)(118296001)(5660300001)(68736007)(2361001)(6666003)(110136004)(2351001)(42186005)(55016002)(21086003)(478600001)(33646002)(189998001)(33026002)(3846002)(101416001)(6116002)(2906002)(76176999)(50986999)(48376002)(50466002)(81156014)(81166006)(25786009)(66066001)(47776003)(8676002)(7350300001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR05MB3148; H:mellanox.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) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HE1PR05MB3148; 23:fyPtUSgg0Kl7a0JbX4FgT+1QyKKtmhd2A394W0e2b?= =?us-ascii?Q?ieS9vR9I7C0z6lZ8V9ooyYHicY11ViRoD6GUQvm/PJjsRZY9gex3IU3f5KyT?= =?us-ascii?Q?6XN/ZLTTy9KtTcyXTy7JBE+cPayUVIIktDdRWm/1rChRV0YB6T5oooBNr2Ny?= =?us-ascii?Q?Dlzyr1H0fo31Dxcw7jUBK/PMfaTMhheGEy/gKpzjqqBMaIdU1oeQJg2qDJa6?= =?us-ascii?Q?7et8weJbyLyyIJ6Y+78GgDG0sepKuueC55jD+hhALZSoOAkigw2zqrQQ1moR?= =?us-ascii?Q?gDtcqlvqSbwfVzd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5emhIdU?= =?us-ascii?Q?nbk21uqg5lQ/E0rrdYlxVfXLgaS7gKEJdfk?= X-Microsoft-Exchange-Diagnostics: 1; HE1PR05MB3148; 6:/E0tdspqV+5Gr+dw6WNNYFykMQSBQnnXgZ/+Ozku6/DzZ6x/ehzYB85XIUF6ipBVNQyU4f7q2lwg4v0k6UG3KM8dr10hVeQDysYbBJzEogeKKCoxCPjVd5On1ZmI/n0nL89i02m3SSmkCqMvgUYlLb5UGniCtsMSjJIWNEY6gMo0NHSZ58DFs35viuhlftrdEFp5bbN4UKf6r1dF8FgdvFW5zyQXNSDwF8XEQ+sFueGWM30ZiwR0uy3pVsWr8xpbQMtH2EYmWeObReL+k9N02b7X2kZ4k1XOmMtJ+M/GJy1FyURxhzVm77Y/HoMblsxs7h0SgFOK8cPy3LyXfV7DwA==; 5:gDdyfeHChKjJH9awbB1nelxvPf/31B7EYomRJRoCBi+jx11Xzp+9QtBzci3zI2LvEp3q18b0islHxS7uvFQW+SRwfdVZe2nsubP0+y5O9YY7k4mi/giRN4DqYIo/xAcyWEkzpE5XQ5XDwSnGr8hfSg==; 24:g6IRvAeRHbp0XDGjgtUq2TB11jAX8fNqo5BHn3OpURDmbWxq3zGct6veJ2Re3XeYNb/+NRyLc+gLXZ8axDj17DlLGA+FlJSVPh4Xn1X7EdE=; 7:sz1eMr/dHcc9W1BqIIgs0q8jkaxiZqufXbHe46dp5Q748t4LhrnvVUyZtUalkOOl1222R/ouKO6JvQl3O3LqBwWenqLfSxTzChqS3BzKRtYovXOVRZ+iG4L+FMGk3qoEe1LPtEjXeL/ui73UBjoTsphmyiDXvXH/91cejmC+WHzmFk5iL1N3C6k/WRjBJdTBl03CT0NAiJIJEBY+b0+6xQgU0cAK/PAgUQJ6mknSbOE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2017 07:12:28.4005 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR05MB3148 Subject: [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 07:12:30 -0000 A new offloads API was introduced by commits: commit 121fff673172 ("ethdev: introduce Rx queue offloads API") commit 35ac80d92f29 ("ethdev: introduce Tx queue offloads API") In order to enable the PMDs to support only one of the APIs, a conversion functions from the old to new API were added. Signed-off-by: Shahaf Shuler --- lib/librte_ether/rte_ethdev.c | 99 +++++++++++++++++++++++++++++++++++++- 1 file changed, 97 insertions(+), 2 deletions(-) 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 = NULL; } +/** + * 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) +{ + if (rxmode->header_split == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_HEADER_SPLIT; + if (rxmode->hw_ip_checksum == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_CHECKSUM; + if (rxmode->hw_vlan_filter == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_VLAN_FILTER; + if (rxmode->hw_vlan_strip == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_VLAN_STRIP; + if (rxmode->hw_vlan_extend == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_VLAN_EXTEND; + if (rxmode->jumbo_frame == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME; + if (rxmode->hw_strip_crc == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_CRC_STRIP; + if (rxmode->enable_scatter == 1) + rxq_conf->offloads |= DEV_RX_OFFLOAD_SCATTER; + if (rxmode->enable_lro == 1) + rxq_conf->offloads |= 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; 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 rx_queue_id, return -EINVAL; } + if ((!(dev->data->dev_flags & RTE_ETH_DEV_RXQ_OFFLOAD)) && + (dev->data->dev_conf.rxmode.ignore_offloads == 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 != 0) { @@ -1086,8 +1121,15 @@ rte_eth_rx_queue_setup(uint8_t port_id, uint16_t rx_queue_id, if (rx_conf == NULL) rx_conf = &dev_info.default_rxconf; + rxq_trans_conf = *rx_conf; + if ((dev->data->dev_flags & RTE_ETH_DEV_RXQ_OFFLOAD) && + (dev->data->dev_conf.rxmode.ignore_offloads == 0)) { + rte_eth_convert_rxmode_offloads(&dev->data->dev_conf.rxmode, + &rxq_trans_conf); + } + ret = (*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 rx_queue_id, return ret; } +/** + * 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 = txq_conf->txq_flags; + uint64_t *offloads = &txq_conf->offloads; + + if (!(txq_flags & ETH_TXQ_FLAGS_NOMULTSEGS)) + *offloads |= DEV_TX_OFFLOAD_MULTI_SEGS; + if (!(txq_flags & ETH_TXQ_FLAGS_NOVLANOFFL)) + *offloads |= DEV_TX_OFFLOAD_VLAN_INSERT; + if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMSCTP)) + *offloads |= DEV_TX_OFFLOAD_SCTP_CKSUM; + if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMUDP)) + *offloads |= DEV_TX_OFFLOAD_UDP_CKSUM; + if (!(txq_flags & ETH_TXQ_FLAGS_NOXSUMTCP)) + *offloads |= DEV_TX_OFFLOAD_TCP_CKSUM; +} + +/** + * A conversion function between rte_eth_txq_conf offloads API to txq_flags + * offloads API. + */ +static void +rte_eth_convert_txq_offloads(struct rte_eth_txq_conf *txq_conf) +{ + uint32_t *txq_flags = &txq_conf->txq_flags; + uint64_t offloads = txq_conf->offloads; + + if (!(offloads & DEV_TX_OFFLOAD_MULTI_SEGS)) + *txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS; + if (!(offloads & DEV_TX_OFFLOAD_VLAN_INSERT)) + *txq_flags |= ETH_TXQ_FLAGS_NOVLANOFFL; + if (!(offloads & DEV_TX_OFFLOAD_SCTP_CKSUM)) + *txq_flags |= ETH_TXQ_FLAGS_NOXSUMSCTP; + if (!(offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) + *txq_flags |= ETH_TXQ_FLAGS_NOXSUMUDP; + if (!(offloads & DEV_TX_OFFLOAD_TCP_CKSUM)) + *txq_flags |= 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; 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 tx_queue_id, if (tx_conf == NULL) tx_conf = &dev_info.default_txconf; + txq_trans_conf = *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); } void -- 2.12.0