DPDK patches and discussions
 help / color / mirror / Atom feed
From: Moti Haimovsky <motih@mellanox.com>
To: gaetan.rivet@6wind.com
Cc: dev@dpdk.org, Moti Haimovsky <motih@mellanox.com>
Subject: [dpdk-dev] [PATCH 1/2] net/failsafe: convert to new Tx offloads API
Date: Thu,  4 Jan 2018 21:31:03 +0200	[thread overview]
Message-ID: <1515094264-185657-2-git-send-email-motih@mellanox.com> (raw)
In-Reply-To: <1515094264-185657-1-git-send-email-motih@mellanox.com>

Ethdev Tx offloads API has changed since:
commit cba7f53b717d ("ethdev: introduce Tx queue offloads API)
This commit adds support to the new Tx offloads API.

Signed-off-by: Moti Haimovsky <motih@mellanox.com>
---
 drivers/net/failsafe/failsafe_ops.c | 45 +++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git a/drivers/net/failsafe/failsafe_ops.c b/drivers/net/failsafe/failsafe_ops.c
index e16a590..1fd845f 100644
--- a/drivers/net/failsafe/failsafe_ops.c
+++ b/drivers/net/failsafe/failsafe_ops.c
@@ -31,6 +31,7 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <stdbool.h>
 #include <stdint.h>
 
 #include <rte_debug.h>
@@ -77,6 +78,7 @@
 		DEV_RX_OFFLOAD_TCP_CKSUM |
 		DEV_RX_OFFLOAD_TCP_LRO,
 	.tx_offload_capa = 0x0,
+	.tx_queue_offload_capa = 0x0,
 	.flow_type_rss_offloads = 0x0,
 };
 
@@ -84,9 +86,18 @@
 fs_dev_configure(struct rte_eth_dev *dev)
 {
 	struct sub_device *sdev;
+	uint64_t supp_tx_offloads = PRIV(dev)->infos.tx_offload_capa;
+	uint64_t tx_offloads = dev->data->dev_conf.txmode.offloads;
 	uint8_t i;
 	int ret;
 
+	if ((tx_offloads & supp_tx_offloads) != tx_offloads) {
+		rte_errno = ENOTSUP;
+		ERROR("Some Tx offloads are not supported, "
+		      "requested 0x%lx supported 0x%lx\n",
+		      tx_offloads, supp_tx_offloads);
+		return -rte_errno;
+	}
 	FOREACH_SUBDEV(sdev, i, dev) {
 		int rmv_interrupt = 0;
 		int lsc_interrupt = 0;
@@ -311,6 +322,22 @@
 	return ret;
 }
 
+static bool
+fs_txq_are_offloads_valid(struct rte_eth_dev *dev, uint64_t offloads)
+{
+	uint64_t port_offloads = dev->data->dev_conf.txmode.offloads;
+	uint64_t queue_supp_offloads = PRIV(dev)->infos.tx_queue_offload_capa;
+	uint64_t port_supp_offloads = PRIV(dev)->infos.tx_offload_capa;
+
+	if ((offloads & (queue_supp_offloads | port_supp_offloads)) !=
+	     offloads)
+		return false;
+	/* Verify we have no conflict with port offloads */
+	if ((port_offloads ^ offloads) & port_supp_offloads)
+		return false;
+	return true;
+}
+
 static void
 fs_tx_queue_release(void *queue)
 {
@@ -347,6 +374,22 @@
 		fs_tx_queue_release(txq);
 		dev->data->tx_queues[tx_queue_id] = NULL;
 	}
+	/*
+	 * Don't verify queue offloads for applications which
+	 * use the old API.
+	 */
+	if ((tx_conf != NULL) &&
+	   !!(tx_conf->txq_flags & ETH_TXQ_FLAGS_IGNORE) &&
+	   !fs_txq_are_offloads_valid(dev, tx_conf->offloads)) {
+		rte_errno = ENOTSUP;
+		ERROR("%p: Tx queue offloads 0x%lx don't match port "
+		      "offloads 0x%lx or supported offloads 0x%lx",
+		      (void *)dev, tx_conf->offloads,
+		      dev->data->dev_conf.txmode.offloads,
+		      PRIV(dev)->infos.tx_offload_capa |
+		      PRIV(dev)->infos.tx_queue_offload_capa);
+		return -rte_errno;
+	}
 	txq = rte_zmalloc("ethdev TX queue",
 			  sizeof(*txq) +
 			  sizeof(rte_atomic64_t) * PRIV(dev)->subs_tail,
@@ -559,6 +602,8 @@
 		PRIV(dev)->infos.rx_offload_capa = rx_offload_capa;
 		PRIV(dev)->infos.tx_offload_capa &=
 					default_infos.tx_offload_capa;
+		PRIV(dev)->infos.tx_queue_offload_capa &=
+					default_infos.tx_queue_offload_capa;
 		PRIV(dev)->infos.flow_type_rss_offloads &=
 					default_infos.flow_type_rss_offloads;
 	}
-- 
1.8.3.1

  reply	other threads:[~2018-01-04 19:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04 19:31 [dpdk-dev] [PATCH 0/2] net/failsafe: convert to new ethdev " Moti Haimovsky
2018-01-04 19:31 ` Moti Haimovsky [this message]
2018-01-04 19:50   ` [dpdk-dev] [PATCH V2 " Moti Haimovsky
2018-01-04 19:50     ` [dpdk-dev] [PATCH V2 1/2] net/failsafe: convert to new Tx " Moti Haimovsky
2018-01-04 20:15       ` Stephen Hemminger
2018-01-10 14:40       ` [dpdk-dev] [PATCH V3 " Moti Haimovsky
2018-01-10 14:40         ` [dpdk-dev] [PATCH V3 2/2] net/failsafe: convert to new Rx " Moti Haimovsky
2018-01-15 16:02           ` Gaëtan Rivet
2018-01-15 15:57         ` [dpdk-dev] [PATCH V3 1/2] net/failsafe: convert to new Tx " Gaëtan Rivet
2018-01-17 14:30         ` [dpdk-dev] [PATCH v4 1/2] net/failsafe: use " Moti Haimovsky
2018-01-17 14:30           ` [dpdk-dev] [PATCH v4 2/2] net/failsafe: use new Rx " Moti Haimovsky
2018-01-17 17:30           ` [dpdk-dev] [PATCH v4 1/2] net/failsafe: use new Tx " Gaëtan Rivet
2018-01-17 19:24             ` Ferruh Yigit
2018-01-04 19:50     ` [dpdk-dev] [PATCH V2 2/2] net/failsafe: convert to new Rx " Moti Haimovsky
2018-01-04 19:31 ` [dpdk-dev] [PATCH " Moti Haimovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1515094264-185657-2-git-send-email-motih@mellanox.com \
    --to=motih@mellanox.com \
    --cc=dev@dpdk.org \
    --cc=gaetan.rivet@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).