DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API
@ 2018-01-11  8:12 Andrew Rybchenko
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
                   ` (9 more replies)
  0 siblings, 10 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-11  8:12 UTC (permalink / raw)
  To: dev; +Cc: Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

May be it is too late to suggest a new API functions to ethdev,
but hopefully if the idea is accepted, it could be applied in the
current release cycle since these functions are trivial.

I'm not sure that rte_ethdev_version.map is updated correctly
since EXPERIMENTAL tag is present and I don't understand how it
should be handled.

In general for the transition period from old offload API to the
new one it would be useful to convert Tx offloads to/from txq_flags
in rte_eth_dev_info_get() for default_txconf and
rte_eth_tx_queue_info_get(). Unfortunately it was lost during
new offload API patches review. However, it would require testing
for all network PMDs and we decided to follow more conservative
approach and kept code to fill in txq_flags which should be simply
removed when txq_flags are removed.

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>

Ivan Malov (6):
  ethdev: add a function to look up Rx offload names
  ethdev: add a function to look up Tx offload names
  net/sfc: factor out function to report Rx capabilities
  net/sfc: convert to the new Rx offload API
  net/sfc: factor out function to report Tx capabilities
  net/sfc: convert to the new Tx offload API

 drivers/net/sfc/sfc_dp_tx.h             |   2 +
 drivers/net/sfc/sfc_ethdev.c            |  58 ++++++----
 drivers/net/sfc/sfc_port.c              |   5 +-
 drivers/net/sfc/sfc_rx.c                | 128 +++++++++++++++------
 drivers/net/sfc/sfc_rx.h                |   3 +
 drivers/net/sfc/sfc_tx.c                | 194 +++++++++++++++++++++-----------
 drivers/net/sfc/sfc_tx.h                |   4 +
 lib/librte_ether/rte_ethdev.c           |  87 ++++++++++++++
 lib/librte_ether/rte_ethdev.h           |  30 +++++
 lib/librte_ether/rte_ethdev_version.map |   7 ++
 10 files changed, 396 insertions(+), 122 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
@ 2018-01-11  8:12 ` Andrew Rybchenko
  2018-01-17 16:55   ` Ferruh Yigit
  2018-01-17 17:33   ` Thomas Monjalon
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-11  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Commonly, drivers converted to the new offload API
may need to log unsupported offloads as a response
to wrong settings. From this perspective, it would
be convenient to have generic functions to look up
offload names. The patch adds such a helper for Rx.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>

---
 lib/librte_ether/rte_ethdev.c           | 42 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 15 ++++++++++++
 lib/librte_ether/rte_ethdev_version.map |  6 +++++
 3 files changed, 63 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b349599..3d09950 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -89,6 +89,32 @@ static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = {
 #define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) /	\
 		sizeof(rte_txq_stats_strings[0]))
 
+#define	RTE_RX_OFFLOAD_BIT2STR(_name)	\
+	{ DEV_RX_OFFLOAD_##_name, #_name }
+
+static const struct {
+	uint64_t offload;
+	const char *name;
+} rte_rx_offload_names[] = {
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(IPV4_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(UDP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(TCP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(TCP_LRO),
+	RTE_RX_OFFLOAD_BIT2STR(QINQ_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(MACSEC_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
+	RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
+	RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(SCATTER),
+	RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
+	RTE_RX_OFFLOAD_BIT2STR(SECURITY),
+};
+
+#undef RTE_RX_OFFLOAD_BIT2STR
 
 /**
  * The user application callback description.
@@ -746,6 +772,22 @@ rte_eth_convert_rx_offloads(const uint64_t rx_offloads,
 		rxmode->security = 0;
 }
 
+const char *
+rte_eth_dev_rx_offload_name(uint64_t offload)
+{
+	const char *name = "UNKNOWN";
+	unsigned int i;
+
+	for (i = 0; i < RTE_DIM(rte_rx_offload_names); ++i) {
+		if (offload == rte_rx_offload_names[i].offload) {
+			name = rte_rx_offload_names[i].name;
+			break;
+		}
+	}
+
+	return name;
+}
+
 int
 rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		      const struct rte_eth_conf *dev_conf)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index f0eeefe..88ceffa 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -945,6 +945,11 @@ struct rte_eth_conf {
 			     DEV_RX_OFFLOAD_VLAN_FILTER | \
 			     DEV_RX_OFFLOAD_VLAN_EXTEND)
 
+/*
+ * If new Rx offload capabilities are defined, they also must be
+ * mentioned in rte_rx_offload_names in rte_ethdev.c file.
+ */
+
 /**
  * TX offload capabilities of a device.
  */
@@ -1922,6 +1927,16 @@ int rte_eth_dev_detach(uint16_t port_id, char *devname);
 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
 
 /**
+ * Get DEV_RX_OFFLOAD_* flag name
+ *
+ * @param offload
+ *   Offload flag
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised
+ */
+const char *rte_eth_dev_rx_offload_name(uint64_t offload);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in the
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index e9681ac..03455cf 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -198,6 +198,12 @@ DPDK_17.11 {
 
 } DPDK_17.08;
 
+DPDK_18.02 {
+	global:
+
+	rte_eth_dev_rx_offload_name;
+} DPDK_17.11;
+
 EXPERIMENTAL {
 	global:
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH 2/6] ethdev: add a function to look up Tx offload names
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
@ 2018-01-11  8:12 ` Andrew Rybchenko
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-11  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Commonly, drivers converted to the new offload API
may need to log unsupported offloads as a response
to wrong settings. From this perspective, it would
be convenient to have generic functions to look up
offload names. The patch adds such a helper for Tx.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c           | 45 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 15 +++++++++++
 lib/librte_ether/rte_ethdev_version.map |  1 +
 3 files changed, 61 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 3d09950..071521e 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -116,6 +116,35 @@ static const struct {
 
 #undef RTE_RX_OFFLOAD_BIT2STR
 
+#define	RTE_TX_OFFLOAD_BIT2STR(_name)	\
+	{ DEV_TX_OFFLOAD_##_name, #_name }
+
+static const struct {
+	uint64_t offload;
+	const char *name;
+} rte_tx_offload_names[] = {
+	RTE_TX_OFFLOAD_BIT2STR(VLAN_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(IPV4_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(UDP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(TCP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(SCTP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(TCP_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(UDP_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(QINQ_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(VXLAN_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(GRE_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(IPIP_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(GENEVE_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(MACSEC_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(MT_LOCKFREE),
+	RTE_TX_OFFLOAD_BIT2STR(MULTI_SEGS),
+	RTE_TX_OFFLOAD_BIT2STR(MBUF_FAST_FREE),
+	RTE_TX_OFFLOAD_BIT2STR(SECURITY),
+};
+
+#undef RTE_TX_OFFLOAD_BIT2STR
+
 /**
  * The user application callback description.
  *
@@ -788,6 +817,22 @@ rte_eth_dev_rx_offload_name(uint64_t offload)
 	return name;
 }
 
+const char *
+rte_eth_dev_tx_offload_name(uint64_t offload)
+{
+	const char *name = "UNKNOWN";
+	unsigned int i;
+
+	for (i = 0; i < RTE_DIM(rte_tx_offload_names); ++i) {
+		if (offload == rte_tx_offload_names[i].offload) {
+			name = rte_tx_offload_names[i].name;
+			break;
+		}
+	}
+
+	return name;
+}
+
 int
 rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		      const struct rte_eth_conf *dev_conf)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 88ceffa..04a4b9c 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -980,6 +980,11 @@ struct rte_eth_conf {
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
 
+/*
+ * If new Tx offload capabilities are defined, they also must be
+ * mentioned in rte_tx_offload_names in rte_ethdev.c file.
+ */
+
 struct rte_pci_device;
 
 /**
@@ -1937,6 +1942,16 @@ uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
 const char *rte_eth_dev_rx_offload_name(uint64_t offload);
 
 /**
+ * Get DEV_TX_OFFLOAD_* flag name
+ *
+ * @param offload
+ *   Offload flag
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised
+ */
+const char *rte_eth_dev_tx_offload_name(uint64_t offload);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in the
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index 03455cf..45f393f 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -202,6 +202,7 @@ DPDK_18.02 {
 	global:
 
 	rte_eth_dev_rx_offload_name;
+	rte_eth_dev_tx_offload_name;
 } DPDK_17.11;
 
 EXPERIMENTAL {
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH 3/6] net/sfc: factor out function to report Rx capabilities
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
@ 2018-01-11  8:12 ` Andrew Rybchenko
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-11  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

The patch adds a separate function to report supported
Rx capabilities because this function will be required
in more places across the code in the upcoming patches.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_ethdev.c |  9 +--------
 drivers/net/sfc/sfc_rx.c     | 17 +++++++++++++++++
 drivers/net/sfc/sfc_rx.h     |  2 ++
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index af867a7..851b38b 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -104,14 +104,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* By default packets are dropped if no descriptors are available */
 	dev_info->default_rxconf.rx_drop_en = 1;
 
-	dev_info->rx_offload_capa =
-		DEV_RX_OFFLOAD_IPV4_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM |
-		DEV_RX_OFFLOAD_TCP_CKSUM;
-
-	if ((encp->enc_tunnel_encapsulations_supported != 0) &&
-	    (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
-		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa);
 
 	dev_info->tx_offload_capa =
 		DEV_TX_OFFLOAD_IPV4_CKSUM |
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index 6fa56b4..d35f4f7 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -762,6 +762,23 @@ sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
 	sfc_ev_qstop(rxq->evq);
 }
 
+uint64_t
+sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
+	caps |= DEV_RX_OFFLOAD_IPV4_CKSUM;
+	caps |= DEV_RX_OFFLOAD_UDP_CKSUM;
+	caps |= DEV_RX_OFFLOAD_TCP_CKSUM;
+
+	if (encp->enc_tunnel_encapsulations_supported &&
+	    (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
+		caps |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+	return caps;
+}
+
 static int
 sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		   const struct rte_eth_rxconf *rx_conf)
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index 2cf75bc..cc9245f 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -142,6 +142,8 @@ void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 
+uint64_t sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa);
+
 void sfc_rx_qflush_done(struct sfc_rxq *rxq);
 void sfc_rx_qflush_failed(struct sfc_rxq *rxq);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH 4/6] net/sfc: convert to the new Rx offload API
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
                   ` (2 preceding siblings ...)
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
@ 2018-01-11  8:12 ` Andrew Rybchenko
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-11  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Ethdev Rx offloads API has changed since:
commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
This commit support the new Rx offloads API.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_ethdev.c |  27 +++++++++--
 drivers/net/sfc/sfc_port.c   |   5 +-
 drivers/net/sfc/sfc_rx.c     | 111 +++++++++++++++++++++++++++++--------------
 drivers/net/sfc/sfc_rx.h     |   1 +
 4 files changed, 103 insertions(+), 41 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 851b38b..0244a0f 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -104,7 +104,15 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* By default packets are dropped if no descriptors are available */
 	dev_info->default_rxconf.rx_drop_en = 1;
 
-	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa);
+	dev_info->rx_queue_offload_capa = sfc_rx_get_queue_offload_caps(sa);
+
+	/*
+	 * rx_offload_capa includes both device and queue offloads since
+	 * the latter may be requested on a per device basis which makes
+	 * sense when some offloads are needed to be set on all queues.
+	 */
+	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
+				    dev_info->rx_queue_offload_capa;
 
 	dev_info->tx_offload_capa =
 		DEV_TX_OFFLOAD_IPV4_CKSUM |
@@ -882,7 +890,13 @@ sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 	 * The driver does not use it, but other PMDs update jumbo_frame
 	 * flag and max_rx_pkt_len when MTU is set.
 	 */
-	dev->data->dev_conf.rxmode.jumbo_frame = (mtu > ETHER_MAX_LEN);
+	if (mtu > ETHER_MAX_LEN) {
+		struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+
+		rxmode->offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+		rxmode->jumbo_frame = 1;
+	}
+
 	dev->data->dev_conf.rxmode.max_rx_pkt_len = sa->port.pdu;
 
 	sfc_adapter_unlock(sa);
@@ -1045,8 +1059,13 @@ sfc_rx_queue_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 	qinfo->conf.rx_free_thresh = rxq->refill_threshold;
 	qinfo->conf.rx_drop_en = 1;
 	qinfo->conf.rx_deferred_start = rxq_info->deferred_start;
-	qinfo->scattered_rx =
-		((rxq_info->type_flags & EFX_RXQ_FLAG_SCATTER) != 0);
+	qinfo->conf.offloads = DEV_RX_OFFLOAD_IPV4_CKSUM |
+			       DEV_RX_OFFLOAD_UDP_CKSUM |
+			       DEV_RX_OFFLOAD_TCP_CKSUM;
+	if (rxq_info->type_flags & EFX_RXQ_FLAG_SCATTER) {
+		qinfo->conf.offloads |= DEV_RX_OFFLOAD_SCATTER;
+		qinfo->scattered_rx = 1;
+	}
 	qinfo->nb_desc = rxq_info->entries;
 
 	sfc_adapter_unlock(sa);
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index a48388d..c423f52 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -299,11 +299,12 @@ sfc_port_configure(struct sfc_adapter *sa)
 {
 	const struct rte_eth_dev_data *dev_data = sa->eth_dev->data;
 	struct sfc_port *port = &sa->port;
+	const struct rte_eth_rxmode *rxmode = &dev_data->dev_conf.rxmode;
 
 	sfc_log_init(sa, "entry");
 
-	if (dev_data->dev_conf.rxmode.jumbo_frame)
-		port->pdu = dev_data->dev_conf.rxmode.max_rx_pkt_len;
+	if (rxmode->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
+		port->pdu = rxmode->max_rx_pkt_len;
 	else
 		port->pdu = EFX_MAC_PDU(dev_data->mtu);
 
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index d35f4f7..abc53fb 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -768,6 +768,8 @@ sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	uint64_t caps = 0;
 
+	caps |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+	caps |= DEV_RX_OFFLOAD_CRC_STRIP;
 	caps |= DEV_RX_OFFLOAD_IPV4_CKSUM;
 	caps |= DEV_RX_OFFLOAD_UDP_CKSUM;
 	caps |= DEV_RX_OFFLOAD_TCP_CKSUM;
@@ -779,10 +781,62 @@ sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
 	return caps;
 }
 
+uint64_t
+sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa)
+{
+	uint64_t caps = 0;
+
+	if (sa->dp_rx->features & SFC_DP_RX_FEAT_SCATTER)
+		caps |= DEV_RX_OFFLOAD_SCATTER;
+
+	return caps;
+}
+
+static void
+sfc_rx_log_offloads(struct sfc_adapter *sa, const char *offload_group,
+		    const char *verdict, uint64_t offloads)
+{
+	unsigned long long bit;
+
+	while ((bit = __builtin_ffsll(offloads)) != 0) {
+		uint64_t flag = (1ULL << --bit);
+
+		sfc_err(sa, "Rx %s offload %s %s", offload_group,
+			rte_eth_dev_rx_offload_name(flag), verdict);
+
+		offloads &= ~flag;
+	}
+}
+
+static boolean_t
+sfc_rx_queue_offloads_mismatch(struct sfc_adapter *sa, uint64_t requested)
+{
+	uint64_t mandatory = sa->eth_dev->data->dev_conf.rxmode.offloads;
+	uint64_t supported = sfc_rx_get_dev_offload_caps(sa) |
+			     sfc_rx_get_queue_offload_caps(sa);
+	uint64_t rejected = requested & ~supported;
+	uint64_t missing = (requested & mandatory) ^ mandatory;
+	boolean_t mismatch = B_FALSE;
+
+	if (rejected) {
+		sfc_rx_log_offloads(sa, "queue", "is unsupported", rejected);
+		mismatch = B_TRUE;
+	}
+
+	if (missing) {
+		sfc_rx_log_offloads(sa, "queue", "must be set", missing);
+		mismatch = B_TRUE;
+	}
+
+	return mismatch;
+}
+
 static int
 sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		   const struct rte_eth_rxconf *rx_conf)
 {
+	uint64_t offloads_supported = sfc_rx_get_dev_offload_caps(sa) |
+				      sfc_rx_get_queue_offload_caps(sa);
 	int rc = 0;
 
 	if (rx_conf->rx_thresh.pthresh != 0 ||
@@ -804,6 +858,17 @@ sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		rc = EINVAL;
 	}
 
+	if ((rx_conf->offloads & DEV_RX_OFFLOAD_CHECKSUM) !=
+	    DEV_RX_OFFLOAD_CHECKSUM)
+		sfc_warn(sa, "Rx checksum offloads cannot be disabled - always on (IPv4/TCP/UDP)");
+
+	if ((offloads_supported & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM) &&
+	    (~rx_conf->offloads & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM))
+		sfc_warn(sa, "Rx outer IPv4 checksum offload cannot be disabled - always on");
+
+	if (sfc_rx_queue_offloads_mismatch(sa, rx_conf->offloads))
+		rc = EINVAL;
+
 	return rc;
 }
 
@@ -946,7 +1011,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	}
 
 	if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) &&
-	    !sa->eth_dev->data->dev_conf.rxmode.enable_scatter) {
+	    (~rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER)) {
 		sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool "
 			"object size is too small", sw_index);
 		sfc_err(sa, "RxQ %u calculated Rx buffer size is %u vs "
@@ -964,7 +1029,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	rxq_info->entries = rxq_entries;
 	rxq_info->type = EFX_RXQ_TYPE_DEFAULT;
 	rxq_info->type_flags =
-		sa->eth_dev->data->dev_conf.rxmode.enable_scatter ?
+		(rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER) ?
 		EFX_RXQ_FLAG_SCATTER : EFX_RXQ_FLAG_NONE;
 
 	if ((encp->enc_tunnel_encapsulations_supported != 0) &&
@@ -1227,6 +1292,9 @@ sfc_rx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
 static int
 sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 {
+	uint64_t offloads_supported = sfc_rx_get_dev_offload_caps(sa) |
+				      sfc_rx_get_queue_offload_caps(sa);
+	uint64_t offloads_rejected = rxmode->offloads & ~offloads_supported;
 	int rc = 0;
 
 	switch (rxmode->mq_mode) {
@@ -1247,45 +1315,18 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 		rc = EINVAL;
 	}
 
-	if (rxmode->header_split) {
-		sfc_err(sa, "Header split on Rx not supported");
-		rc = EINVAL;
-	}
-
-	if (rxmode->hw_vlan_filter) {
-		sfc_err(sa, "HW VLAN filtering not supported");
-		rc = EINVAL;
-	}
-
-	if (rxmode->hw_vlan_strip) {
-		sfc_err(sa, "HW VLAN stripping not supported");
+	if (offloads_rejected) {
+		sfc_rx_log_offloads(sa, "device", "is unsupported",
+				    offloads_rejected);
 		rc = EINVAL;
 	}
 
-	if (rxmode->hw_vlan_extend) {
-		sfc_err(sa,
-			"Q-in-Q HW VLAN stripping not supported");
-		rc = EINVAL;
-	}
-
-	if (!rxmode->hw_strip_crc) {
-		sfc_warn(sa,
-			 "FCS stripping control not supported - always stripped");
+	if (~rxmode->offloads & DEV_RX_OFFLOAD_CRC_STRIP) {
+		sfc_warn(sa, "FCS stripping cannot be disabled - always on");
+		rxmode->offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
 		rxmode->hw_strip_crc = 1;
 	}
 
-	if (rxmode->enable_scatter &&
-	    (~sa->dp_rx->features & SFC_DP_RX_FEAT_SCATTER)) {
-		sfc_err(sa, "Rx scatter not supported by %s datapath",
-			sa->dp_rx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (rxmode->enable_lro) {
-		sfc_err(sa, "LRO not supported");
-		rc = EINVAL;
-	}
-
 	return rc;
 }
 
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index cc9245f..8c0fa71 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -143,6 +143,7 @@ int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 
 uint64_t sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa);
+uint64_t sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa);
 
 void sfc_rx_qflush_done(struct sfc_rxq *rxq);
 void sfc_rx_qflush_failed(struct sfc_rxq *rxq);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH 5/6] net/sfc: factor out function to report Tx capabilities
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
                   ` (3 preceding siblings ...)
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
@ 2018-01-11  8:12 ` Andrew Rybchenko
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-11  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

The patch adds a separate function to report supported
Tx capabilities because this function will be required
in more places across the code in the upcoming patches.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_ethdev.c | 13 +------------
 drivers/net/sfc/sfc_tx.c     | 23 +++++++++++++++++++++++
 drivers/net/sfc/sfc_tx.h     |  2 ++
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 0244a0f..0fe9bf5 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -114,20 +114,12 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
 				    dev_info->rx_queue_offload_capa;
 
-	dev_info->tx_offload_capa =
-		DEV_TX_OFFLOAD_IPV4_CKSUM |
-		DEV_TX_OFFLOAD_UDP_CKSUM |
-		DEV_TX_OFFLOAD_TCP_CKSUM;
-
-	if (encp->enc_tunnel_encapsulations_supported != 0)
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa);
 
 	dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
 	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
 	    !encp->enc_hw_tx_insert_vlan_enabled)
 		dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOVLANOFFL;
-	else
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_VLAN_INSERT;
 
 	if (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)
 		dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
@@ -146,9 +138,6 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	}
 #endif
 
-	if (sa->tso)
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
-
 	/* Initialize to hardware limits */
 	dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS;
 	dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS;
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index ee22049..7504037 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -34,6 +34,29 @@
  */
 #define SFC_TX_QFLUSH_POLL_ATTEMPTS	(2000)
 
+uint64_t
+sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
+	caps |= DEV_TX_OFFLOAD_IPV4_CKSUM;
+	caps |= DEV_TX_OFFLOAD_UDP_CKSUM;
+	caps |= DEV_TX_OFFLOAD_TCP_CKSUM;
+
+	if (encp->enc_tunnel_encapsulations_supported)
+		caps |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
+	    encp->enc_hw_tx_insert_vlan_enabled)
+		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
+
+	if (sa->tso)
+		caps |= DEV_TX_OFFLOAD_TCP_TSO;
+
+	return caps;
+}
+
 static int
 sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 		   const struct rte_eth_txconf *tx_conf)
diff --git a/drivers/net/sfc/sfc_tx.h b/drivers/net/sfc/sfc_tx.h
index c2b889f..fc9a9f7 100644
--- a/drivers/net/sfc/sfc_tx.h
+++ b/drivers/net/sfc/sfc_tx.h
@@ -129,6 +129,8 @@ void sfc_tx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_tx_start(struct sfc_adapter *sa);
 void sfc_tx_stop(struct sfc_adapter *sa);
 
+uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
+
 /* From 'sfc_tso.c' */
 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
 				unsigned int txq_entries,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH 6/6] net/sfc: convert to the new Tx offload API
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
                   ` (4 preceding siblings ...)
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
@ 2018-01-11  8:12 ` Andrew Rybchenko
  2018-01-17 16:55 ` [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new " Ferruh Yigit
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-11  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

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

The code which fills in txq_flags in default_txconf is preserved
because rte_eth_dev_info_get() lacks conversion between offloads
and txq_flags fields which means that a legacy application which
relies on default_txconf will fail to configure Tx queues in the
case when some bits in txq_flags are mandatory.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_dp_tx.h  |   2 +
 drivers/net/sfc/sfc_ethdev.c |  17 +++-
 drivers/net/sfc/sfc_tx.c     | 179 +++++++++++++++++++++++++++----------------
 drivers/net/sfc/sfc_tx.h     |   2 +
 4 files changed, 131 insertions(+), 69 deletions(-)

diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h
index f400755..75d72fe 100644
--- a/drivers/net/sfc/sfc_dp_tx.h
+++ b/drivers/net/sfc/sfc_dp_tx.h
@@ -41,6 +41,8 @@ struct sfc_dp_tx_qcreate_info {
 	unsigned int		free_thresh;
 	/** Transmit queue configuration flags */
 	unsigned int		flags;
+	/** Offloads enabled on the transmit queue */
+	uint64_t		offloads;
 	/** Tx queue size */
 	unsigned int		txq_entries;
 	/** Maximum size of data in the DMA descriptor */
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 0fe9bf5..a86cff6 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -83,6 +83,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t txq_offloads_def = 0;
 
 	sfc_log_init(sa, "entry");
 
@@ -114,7 +115,20 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
 				    dev_info->rx_queue_offload_capa;
 
-	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa);
+	dev_info->tx_queue_offload_capa = sfc_tx_get_queue_offload_caps(sa);
+
+	/*
+	 * tx_offload_capa includes both device and queue offloads since
+	 * the latter may be requested on a per device basis which makes
+	 * sense when some offloads are needed to be set on all queues.
+	 */
+	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa) |
+				    dev_info->tx_queue_offload_capa;
+
+	if (dev_info->tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+		txq_offloads_def |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	dev_info->default_txconf.offloads |= txq_offloads_def;
 
 	dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
 	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
@@ -1081,6 +1095,7 @@ sfc_tx_queue_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	memset(qinfo, 0, sizeof(*qinfo));
 
 	qinfo->conf.txq_flags = txq_info->txq->flags;
+	qinfo->conf.offloads = txq_info->txq->offloads;
 	qinfo->conf.tx_free_thresh = txq_info->txq->free_thresh;
 	qinfo->conf.tx_deferred_start = txq_info->deferred_start;
 	qinfo->nb_desc = txq_info->entries;
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index 7504037..757b03b 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -40,6 +40,26 @@ sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	uint64_t caps = 0;
 
+	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
+	    encp->enc_hw_tx_insert_vlan_enabled)
+		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
+
+	if (sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)
+		caps |= DEV_TX_OFFLOAD_MULTI_SEGS;
+
+	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_POOL) &&
+	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_REFCNT))
+		caps |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	return caps;
+}
+
+uint64_t
+sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
 	caps |= DEV_TX_OFFLOAD_IPV4_CKSUM;
 	caps |= DEV_TX_OFFLOAD_UDP_CKSUM;
 	caps |= DEV_TX_OFFLOAD_TCP_CKSUM;
@@ -47,22 +67,55 @@ sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
 	if (encp->enc_tunnel_encapsulations_supported)
 		caps |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
 
-	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
-	    encp->enc_hw_tx_insert_vlan_enabled)
-		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
-
 	if (sa->tso)
 		caps |= DEV_TX_OFFLOAD_TCP_TSO;
 
 	return caps;
 }
 
+static void
+sfc_tx_log_offloads(struct sfc_adapter *sa, const char *offload_group,
+		    const char *verdict, uint64_t offloads)
+{
+	unsigned long long bit;
+
+	while ((bit = __builtin_ffsll(offloads)) != 0) {
+		uint64_t flag = (1ULL << --bit);
+
+		sfc_err(sa, "Tx %s offload %s %s", offload_group,
+			rte_eth_dev_tx_offload_name(flag), verdict);
+
+		offloads &= ~flag;
+	}
+}
+
+static int
+sfc_tx_queue_offload_mismatch(struct sfc_adapter *sa, uint64_t requested)
+{
+	uint64_t mandatory = sa->eth_dev->data->dev_conf.txmode.offloads;
+	uint64_t supported = sfc_tx_get_dev_offload_caps(sa) |
+			     sfc_tx_get_queue_offload_caps(sa);
+	uint64_t rejected = requested & ~supported;
+	uint64_t missing = (requested & mandatory) ^ mandatory;
+	boolean_t mismatch = B_FALSE;
+
+	if (rejected) {
+		sfc_tx_log_offloads(sa, "queue", "is unsupported", rejected);
+		mismatch = B_TRUE;
+	}
+
+	if (missing) {
+		sfc_tx_log_offloads(sa, "queue", "must be set", missing);
+		mismatch = B_TRUE;
+	}
+
+	return mismatch;
+}
+
 static int
 sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 		   const struct rte_eth_txconf *tx_conf)
 {
-	unsigned int flags = tx_conf->txq_flags;
-	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	int rc = 0;
 
 	if (tx_conf->tx_rs_thresh != 0) {
@@ -84,52 +137,16 @@ sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 			"prefetch/host/writeback thresholds are not supported");
 	}
 
-	if (((flags & ETH_TXQ_FLAGS_NOMULTSEGS) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)) {
-		sfc_err(sa, "Multi-segment is not supported by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (((flags & ETH_TXQ_FLAGS_NOMULTMEMP) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_POOL)) {
-		sfc_err(sa, "multi-mempool is not supported by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (((flags & ETH_TXQ_FLAGS_NOREFCOUNT) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_REFCNT)) {
-		sfc_err(sa,
-			"mbuf reference counters are neglected by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if ((flags & ETH_TXQ_FLAGS_NOVLANOFFL) == 0) {
-		if (!encp->enc_hw_tx_insert_vlan_enabled) {
-			sfc_err(sa, "VLAN offload is not supported");
-			rc = EINVAL;
-		} else if (~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) {
-			sfc_err(sa,
-				"VLAN offload is not supported by %s datapath",
-				sa->dp_tx->dp.name);
-			rc = EINVAL;
-		}
-	}
-
-	if ((flags & ETH_TXQ_FLAGS_NOXSUMSCTP) == 0) {
-		sfc_err(sa, "SCTP offload is not supported");
-		rc = EINVAL;
-	}
-
 	/* We either perform both TCP and UDP offload, or no offload at all */
-	if (((flags & ETH_TXQ_FLAGS_NOXSUMTCP) == 0) !=
-	    ((flags & ETH_TXQ_FLAGS_NOXSUMUDP) == 0)) {
+	if (((tx_conf->offloads & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) !=
+	    ((tx_conf->offloads & DEV_TX_OFFLOAD_UDP_CKSUM) == 0)) {
 		sfc_err(sa, "TCP and UDP offloads can't be set independently");
 		rc = EINVAL;
 	}
 
+	if (sfc_tx_queue_offload_mismatch(sa, tx_conf->offloads))
+		rc = EINVAL;
+
 	return rc;
 }
 
@@ -193,6 +210,7 @@ sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		(tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh :
 		SFC_TX_DEFAULT_FREE_THRESH;
 	txq->flags = tx_conf->txq_flags;
+	txq->offloads = tx_conf->offloads;
 
 	rc = sfc_dma_alloc(sa, "txq", sw_index, EFX_TXQ_SIZE(txq_info->entries),
 			   socket_id, &txq->mem);
@@ -203,6 +221,7 @@ sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	info.max_fill_level = txq_max_fill_level;
 	info.free_thresh = txq->free_thresh;
 	info.flags = tx_conf->txq_flags;
+	info.offloads = tx_conf->offloads;
 	info.txq_entries = txq_info->entries;
 	info.dma_desc_size_max = encp->enc_tx_dma_desc_size_max;
 	info.txq_hw_ring = txq->mem.esm_base;
@@ -284,6 +303,9 @@ sfc_tx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
 static int
 sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
 {
+	uint64_t offloads_supported = sfc_tx_get_dev_offload_caps(sa) |
+				      sfc_tx_get_queue_offload_caps(sa);
+	uint64_t offloads_rejected = txmode->offloads & ~offloads_supported;
 	int rc = 0;
 
 	switch (txmode->mq_mode) {
@@ -314,6 +336,12 @@ sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
 		rc = EINVAL;
 	}
 
+	if (offloads_rejected) {
+		sfc_tx_log_offloads(sa, "device", "is unsupported",
+				    offloads_rejected);
+		rc = EINVAL;
+	}
+
 	return rc;
 }
 
@@ -424,12 +452,13 @@ sfc_tx_close(struct sfc_adapter *sa)
 int
 sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
 {
-	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t offloads_supported = sfc_tx_get_dev_offload_caps(sa) |
+				      sfc_tx_get_queue_offload_caps(sa);
 	struct rte_eth_dev_data *dev_data;
 	struct sfc_txq_info *txq_info;
 	struct sfc_txq *txq;
 	struct sfc_evq *evq;
-	uint16_t flags;
+	uint16_t flags = 0;
 	unsigned int desc_index;
 	int rc = 0;
 
@@ -449,26 +478,40 @@ sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
 		goto fail_ev_qstart;
 
 	/*
-	 * It seems that DPDK has no controls regarding IPv4 offloads,
-	 * hence, we always enable it here
+	 * The absence of ETH_TXQ_FLAGS_IGNORE is associated with a legacy
+	 * application which expects that IPv4 checksum offload is enabled
+	 * all the time as there is no legacy flag to turn off the offload.
 	 */
-	if ((txq->flags & ETH_TXQ_FLAGS_NOXSUMTCP) ||
-	    (txq->flags & ETH_TXQ_FLAGS_NOXSUMUDP)) {
-		flags = EFX_TXQ_CKSUM_IPV4;
-
-		if (encp->enc_tunnel_encapsulations_supported != 0)
-			flags |= EFX_TXQ_CKSUM_INNER_IPV4;
-	} else {
-		flags = EFX_TXQ_CKSUM_IPV4 | EFX_TXQ_CKSUM_TCPUDP;
-
-		if (encp->enc_tunnel_encapsulations_supported != 0)
-			flags |= EFX_TXQ_CKSUM_INNER_IPV4 |
-				 EFX_TXQ_CKSUM_INNER_TCPUDP;
-
-		if (sa->tso)
-			flags |= EFX_TXQ_FATSOV2;
+	if ((txq->offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ||
+	    (~txq->flags & ETH_TXQ_FLAGS_IGNORE))
+		flags |= EFX_TXQ_CKSUM_IPV4;
+
+	if ((txq->offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
+	    ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+	     (offloads_supported & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)))
+		flags |= EFX_TXQ_CKSUM_INNER_IPV4;
+
+	if ((txq->offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ||
+	    (txq->offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) {
+		flags |= EFX_TXQ_CKSUM_TCPUDP;
+
+		if ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+		    (offloads_supported & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
+			flags |= EFX_TXQ_CKSUM_INNER_TCPUDP;
 	}
 
+	/*
+	 * The absence of ETH_TXQ_FLAGS_IGNORE is associated with a legacy
+	 * application. In turn, the absence of ETH_TXQ_FLAGS_NOXSUMTCP is
+	 * associated specifically with a legacy application which expects
+	 * both TCP checksum offload and TSO to be enabled because the legacy
+	 * API does not provide a dedicated mechanism to control TSO.
+	 */
+	if ((txq->offloads & DEV_TX_OFFLOAD_TCP_TSO) ||
+	    ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+	     (~txq->flags & ETH_TXQ_FLAGS_NOXSUMTCP)))
+		flags |= EFX_TXQ_FATSOV2;
+
 	rc = efx_tx_qcreate(sa->nic, sw_index, 0, &txq->mem,
 			    txq_info->entries, 0 /* not used on EF10 */,
 			    flags, evq->common,
@@ -736,9 +779,9 @@ sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		/*
 		 * Here VLAN TCI is expected to be zero in case if no
-		 * DEV_TX_VLAN_OFFLOAD capability is advertised;
+		 * DEV_TX_OFFLOAD_VLAN_INSERT capability is advertised;
 		 * if the calling app ignores the absence of
-		 * DEV_TX_VLAN_OFFLOAD and pushes VLAN TCI, then
+		 * DEV_TX_OFFLOAD_VLAN_INSERT and pushes VLAN TCI, then
 		 * TX_ERROR will occur
 		 */
 		pkt_descs += sfc_efx_tx_maybe_insert_tag(txq, m_seg, &pend);
diff --git a/drivers/net/sfc/sfc_tx.h b/drivers/net/sfc/sfc_tx.h
index fc9a9f7..e3c5d51 100644
--- a/drivers/net/sfc/sfc_tx.h
+++ b/drivers/net/sfc/sfc_tx.h
@@ -59,6 +59,7 @@ struct sfc_txq {
 	efx_txq_t			*common;
 	unsigned int			free_thresh;
 	unsigned int			flags;
+	uint64_t			offloads;
 };
 
 static inline unsigned int
@@ -130,6 +131,7 @@ int sfc_tx_start(struct sfc_adapter *sa);
 void sfc_tx_stop(struct sfc_adapter *sa);
 
 uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
+uint64_t sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa);
 
 /* From 'sfc_tso.c' */
 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
                   ` (5 preceding siblings ...)
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
@ 2018-01-17 16:55 ` Ferruh Yigit
  2018-01-18  7:02 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 41+ messages in thread
From: Ferruh Yigit @ 2018-01-17 16:55 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: Thomas Monjalon, Shahaf Shuler

On 1/11/2018 8:12 AM, Andrew Rybchenko wrote:
> May be it is too late to suggest a new API functions to ethdev,
> but hopefully if the idea is accepted, it could be applied in the
> current release cycle since these functions are trivial.

Agreed, I think they are OK to get in even late.

> 
> I'm not sure that rte_ethdev_version.map is updated correctly
> since EXPERIMENTAL tag is present and I don't understand how it
> should be handled.
> 
> In general for the transition period from old offload API to the
> new one it would be useful to convert Tx offloads to/from txq_flags
> in rte_eth_dev_info_get() for default_txconf and
> rte_eth_tx_queue_info_get(). Unfortunately it was lost during
> new offload API patches review. However, it would require testing
> for all network PMDs and we decided to follow more conservative
> approach and kept code to fill in txq_flags which should be simply
> removed when txq_flags are removed.
> 
> Cc: Thomas Monjalon <thomas@monjalon.net>
> Cc: Ferruh Yigit <ferruh.yigit@intel.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>
> 
> Ivan Malov (6):
>   ethdev: add a function to look up Rx offload names
>   ethdev: add a function to look up Tx offload names
>   net/sfc: factor out function to report Rx capabilities
>   net/sfc: convert to the new Rx offload API
>   net/sfc: factor out function to report Tx capabilities
>   net/sfc: convert to the new Tx offload API

Series
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
@ 2018-01-17 16:55   ` Ferruh Yigit
  2018-01-17 17:06     ` Thomas Monjalon
  2018-01-17 17:33   ` Thomas Monjalon
  1 sibling, 1 reply; 41+ messages in thread
From: Ferruh Yigit @ 2018-01-17 16:55 UTC (permalink / raw)
  To: dev, Thomas Monjalon, Shahaf Shuler; +Cc: Andrew Rybchenko, Ivan Malov

On 1/11/2018 8:12 AM, Andrew Rybchenko wrote:
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
> 
> Commonly, drivers converted to the new offload API
> may need to log unsupported offloads as a response
> to wrong settings. From this perspective, it would
> be convenient to have generic functions to look up
> offload names. The patch adds such a helper for Rx.
> 
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> 
> Cc: Thomas Monjalon <thomas@monjalon.net>
> Cc: Ferruh Yigit <ferruh.yigit@intel.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>

Hi Thomas, Shahaf,

Any comment on ethdev patches?

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names
  2018-01-17 16:55   ` Ferruh Yigit
@ 2018-01-17 17:06     ` Thomas Monjalon
  0 siblings, 0 replies; 41+ messages in thread
From: Thomas Monjalon @ 2018-01-17 17:06 UTC (permalink / raw)
  To: Ferruh Yigit, Andrew Rybchenko, Ivan Malov; +Cc: dev, Shahaf Shuler

17/01/2018 17:55, Ferruh Yigit:
> On 1/11/2018 8:12 AM, Andrew Rybchenko wrote:
> > From: Ivan Malov <ivan.malov@oktetlabs.ru>
> > 
> > Commonly, drivers converted to the new offload API
> > may need to log unsupported offloads as a response
> > to wrong settings. From this perspective, it would
> > be convenient to have generic functions to look up
> > offload names. The patch adds such a helper for Rx.
> > 
> > Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> > Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> > 
> > Cc: Thomas Monjalon <thomas@monjalon.net>
> > Cc: Ferruh Yigit <ferruh.yigit@intel.com>
> > Cc: Shahaf Shuler <shahafs@mellanox.com>
> 
> Hi Thomas, Shahaf,
> 
> Any comment on ethdev patches?

Yes, one comment: it should be experimental.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names
  2018-01-11  8:12 ` [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
  2018-01-17 16:55   ` Ferruh Yigit
@ 2018-01-17 17:33   ` Thomas Monjalon
  2018-01-18  6:32     ` Shahaf Shuler
  2018-01-18  7:16     ` Andrew Rybchenko
  1 sibling, 2 replies; 41+ messages in thread
From: Thomas Monjalon @ 2018-01-17 17:33 UTC (permalink / raw)
  To: Andrew Rybchenko, Ivan Malov; +Cc: dev, Ferruh Yigit, Shahaf Shuler

Hi, 2 comments below

11/01/2018 09:12, Andrew Rybchenko:
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
> 
> +#define	RTE_RX_OFFLOAD_BIT2STR(_name)	\
> +	{ DEV_RX_OFFLOAD_##_name, #_name }
> +
> +static const struct {
> +	uint64_t offload;
> +	const char *name;
> +} rte_rx_offload_names[] = {
> +	RTE_RX_OFFLOAD_BIT2STR(VLAN_STRIP),
> +	RTE_RX_OFFLOAD_BIT2STR(IPV4_CKSUM),
> +	RTE_RX_OFFLOAD_BIT2STR(UDP_CKSUM),
> +	RTE_RX_OFFLOAD_BIT2STR(TCP_CKSUM),
> +	RTE_RX_OFFLOAD_BIT2STR(TCP_LRO),
> +	RTE_RX_OFFLOAD_BIT2STR(QINQ_STRIP),
> +	RTE_RX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
> +	RTE_RX_OFFLOAD_BIT2STR(MACSEC_STRIP),
> +	RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
> +	RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
> +	RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
> +	RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
> +	RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
> +	RTE_RX_OFFLOAD_BIT2STR(SCATTER),
> +	RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
> +	RTE_RX_OFFLOAD_BIT2STR(SECURITY),
> +};
> +
> +#undef RTE_RX_OFFLOAD_BIT2STR

Why this undef?

> --- a/lib/librte_ether/rte_ethdev_version.map
> +++ b/lib/librte_ether/rte_ethdev_version.map
> @@ -198,6 +198,12 @@ DPDK_17.11 {
>  
>  } DPDK_17.08;
>  
> +DPDK_18.02 {
> +	global:
> +
> +	rte_eth_dev_rx_offload_name;
> +} DPDK_17.11;

New functions should be experimental.

>  EXPERIMENTAL {
>  	global:

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names
  2018-01-17 17:33   ` Thomas Monjalon
@ 2018-01-18  6:32     ` Shahaf Shuler
  2018-01-18  7:16     ` Andrew Rybchenko
  1 sibling, 0 replies; 41+ messages in thread
From: Shahaf Shuler @ 2018-01-18  6:32 UTC (permalink / raw)
  To: Thomas Monjalon, Andrew Rybchenko, Ivan Malov; +Cc: dev, Ferruh Yigit

Wednesday, January 17, 2018 7:33 PM, Thomas Monjalon:
09:12, Andrew Rybchenko:
> > From: Ivan Malov <ivan.malov@oktetlabs.ru>
> >
> > +#define	RTE_RX_OFFLOAD_BIT2STR(_name)	\
> > +	{ DEV_RX_OFFLOAD_##_name, #_name }
> > +
> > +static const struct {
> > +	uint64_t offload;
> > +	const char *name;
> > +} rte_rx_offload_names[] = {
> > +	RTE_RX_OFFLOAD_BIT2STR(VLAN_STRIP),
> > +	RTE_RX_OFFLOAD_BIT2STR(IPV4_CKSUM),
> > +	RTE_RX_OFFLOAD_BIT2STR(UDP_CKSUM),
> > +	RTE_RX_OFFLOAD_BIT2STR(TCP_CKSUM),
> > +	RTE_RX_OFFLOAD_BIT2STR(TCP_LRO),
> > +	RTE_RX_OFFLOAD_BIT2STR(QINQ_STRIP),
> > +	RTE_RX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
> > +	RTE_RX_OFFLOAD_BIT2STR(MACSEC_STRIP),
> > +	RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
> > +	RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
> > +	RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
> > +	RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
> > +	RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
> > +	RTE_RX_OFFLOAD_BIT2STR(SCATTER),
> > +	RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
> > +	RTE_RX_OFFLOAD_BIT2STR(SECURITY),
> > +};
> > +
> > +#undef RTE_RX_OFFLOAD_BIT2STR
> 
> Why this undef?
> 
> > --- a/lib/librte_ether/rte_ethdev_version.map
> > +++ b/lib/librte_ether/rte_ethdev_version.map
> > @@ -198,6 +198,12 @@ DPDK_17.11 {
> >
> >  } DPDK_17.08;
> >
> > +DPDK_18.02 {
> > +	global:
> > +
> > +	rte_eth_dev_rx_offload_name;
> > +} DPDK_17.11;
> 
> New functions should be experimental.
> 
> >  EXPERIMENTAL {
> >  	global:

Apart from Thomas comments looks OK to me. 

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v2 0/6] net/sfc: convert to the new offload API
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
                   ` (6 preceding siblings ...)
  2018-01-17 16:55 ` [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new " Ferruh Yigit
@ 2018-01-18  7:02 ` Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
                     ` (5 more replies)
  2018-01-18  7:07 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
  2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
  9 siblings, 6 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:02 UTC (permalink / raw)
  To: dev; +Cc: Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

May be it is too late to suggest a new API functions to ethdev,
but hopefully if the idea is accepted, it could be applied in the
current release cycle since these functions are trivial.

I'm not sure that rte_ethdev_version.map is updated correctly
since EXPERIMENTAL tag is present and I don't understand how it
should be handled.

In general for the transition period from old offload API to the
new one it would be useful to convert Tx offloads to/from txq_flags
in rte_eth_dev_info_get() for default_txconf and
rte_eth_tx_queue_info_get(). Unfortunately it was lost during
new offload API patches review. However, it would require testing
for all network PMDs and we decided to follow more conservative
approach and kept code to fill in txq_flags which should be simply
removed when txq_flags are removed.

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>

---

v2:
 - make new ethdev API experimentatal (map file and function comment)
 - use space instead of TAB after #define for RTE_?X_OFFLOAD_BIT2STR

Ivan Malov (6):
  ethdev: add a function to look up Rx offload names
  ethdev: add a function to look up Tx offload names
  net/sfc: factor out function to report Rx capabilities
  net/sfc: convert to the new Rx offload API
  net/sfc: factor out function to report Tx capabilities
  net/sfc: convert to the new Tx offload API

 drivers/net/sfc/sfc_dp_tx.h             |   2 +
 drivers/net/sfc/sfc_ethdev.c            |  58 ++++++----
 drivers/net/sfc/sfc_port.c              |   5 +-
 drivers/net/sfc/sfc_rx.c                | 128 +++++++++++++++------
 drivers/net/sfc/sfc_rx.h                |   3 +
 drivers/net/sfc/sfc_tx.c                | 194 +++++++++++++++++++++-----------
 drivers/net/sfc/sfc_tx.h                |   4 +
 lib/librte_ether/rte_ethdev.c           |  87 ++++++++++++++
 lib/librte_ether/rte_ethdev.h           |  36 ++++++
 lib/librte_ether/rte_ethdev_version.map |   2 +
 10 files changed, 397 insertions(+), 122 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v2 1/6] ethdev: add a function to look up Rx offload names
  2018-01-18  7:02 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
@ 2018-01-18  7:02   ` Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:02 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Commonly, drivers converted to the new offload API
may need to log unsupported offloads as a response
to wrong settings. From this perspective, it would
be convenient to have generic functions to look up
offload names. The patch adds such a helper for Rx.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c           | 42 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 18 ++++++++++++++
 lib/librte_ether/rte_ethdev_version.map |  1 +
 3 files changed, 61 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b349599..9e9ef83 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -89,6 +89,32 @@ static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = {
 #define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) /	\
 		sizeof(rte_txq_stats_strings[0]))
 
+#define RTE_RX_OFFLOAD_BIT2STR(_name)	\
+	{ DEV_RX_OFFLOAD_##_name, #_name }
+
+static const struct {
+	uint64_t offload;
+	const char *name;
+} rte_rx_offload_names[] = {
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(IPV4_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(UDP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(TCP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(TCP_LRO),
+	RTE_RX_OFFLOAD_BIT2STR(QINQ_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(MACSEC_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
+	RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
+	RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(SCATTER),
+	RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
+	RTE_RX_OFFLOAD_BIT2STR(SECURITY),
+};
+
+#undef RTE_RX_OFFLOAD_BIT2STR
 
 /**
  * The user application callback description.
@@ -746,6 +772,22 @@ rte_eth_convert_rx_offloads(const uint64_t rx_offloads,
 		rxmode->security = 0;
 }
 
+const char *
+rte_eth_dev_rx_offload_name(uint64_t offload)
+{
+	const char *name = "UNKNOWN";
+	unsigned int i;
+
+	for (i = 0; i < RTE_DIM(rte_rx_offload_names); ++i) {
+		if (offload == rte_rx_offload_names[i].offload) {
+			name = rte_rx_offload_names[i].name;
+			break;
+		}
+	}
+
+	return name;
+}
+
 int
 rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		      const struct rte_eth_conf *dev_conf)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index a5ba564..0396465 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -946,6 +946,11 @@ struct rte_eth_conf {
 			     DEV_RX_OFFLOAD_VLAN_FILTER | \
 			     DEV_RX_OFFLOAD_VLAN_EXTEND)
 
+/*
+ * If new Rx offload capabilities are defined, they also must be
+ * mentioned in rte_rx_offload_names in rte_ethdev.c file.
+ */
+
 /**
  * TX offload capabilities of a device.
  */
@@ -1923,6 +1928,19 @@ int rte_eth_dev_detach(uint16_t port_id, char *devname);
 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
 
 /**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get DEV_RX_OFFLOAD_* flag name
+ *
+ * @param offload
+ *   Offload flag
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised
+ */
+const char *rte_eth_dev_rx_offload_name(uint64_t offload);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in the
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index e9681ac..94d348f 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -213,5 +213,6 @@ EXPERIMENTAL {
 	rte_mtr_policer_actions_update;
 	rte_mtr_stats_read;
 	rte_mtr_stats_update;
+	rte_eth_dev_rx_offload_name;
 
 } DPDK_17.11;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v2 2/6] ethdev: add a function to look up Tx offload names
  2018-01-18  7:02 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
@ 2018-01-18  7:02   ` Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:02 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Commonly, drivers converted to the new offload API
may need to log unsupported offloads as a response
to wrong settings. From this perspective, it would
be convenient to have generic functions to look up
offload names. The patch adds such a helper for Tx.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c           | 45 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 18 +++++++++++++
 lib/librte_ether/rte_ethdev_version.map |  1 +
 3 files changed, 64 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 9e9ef83..cd4a3ed 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -116,6 +116,35 @@ static const struct {
 
 #undef RTE_RX_OFFLOAD_BIT2STR
 
+#define RTE_TX_OFFLOAD_BIT2STR(_name)	\
+	{ DEV_TX_OFFLOAD_##_name, #_name }
+
+static const struct {
+	uint64_t offload;
+	const char *name;
+} rte_tx_offload_names[] = {
+	RTE_TX_OFFLOAD_BIT2STR(VLAN_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(IPV4_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(UDP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(TCP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(SCTP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(TCP_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(UDP_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(QINQ_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(VXLAN_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(GRE_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(IPIP_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(GENEVE_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(MACSEC_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(MT_LOCKFREE),
+	RTE_TX_OFFLOAD_BIT2STR(MULTI_SEGS),
+	RTE_TX_OFFLOAD_BIT2STR(MBUF_FAST_FREE),
+	RTE_TX_OFFLOAD_BIT2STR(SECURITY),
+};
+
+#undef RTE_TX_OFFLOAD_BIT2STR
+
 /**
  * The user application callback description.
  *
@@ -788,6 +817,22 @@ rte_eth_dev_rx_offload_name(uint64_t offload)
 	return name;
 }
 
+const char *
+rte_eth_dev_tx_offload_name(uint64_t offload)
+{
+	const char *name = "UNKNOWN";
+	unsigned int i;
+
+	for (i = 0; i < RTE_DIM(rte_tx_offload_names); ++i) {
+		if (offload == rte_tx_offload_names[i].offload) {
+			name = rte_tx_offload_names[i].name;
+			break;
+		}
+	}
+
+	return name;
+}
+
 int
 rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		      const struct rte_eth_conf *dev_conf)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 0396465..5fab553 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -981,6 +981,11 @@ struct rte_eth_conf {
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
 
+/*
+ * If new Tx offload capabilities are defined, they also must be
+ * mentioned in rte_tx_offload_names in rte_ethdev.c file.
+ */
+
 struct rte_pci_device;
 
 /**
@@ -1941,6 +1946,19 @@ uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
 const char *rte_eth_dev_rx_offload_name(uint64_t offload);
 
 /**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get DEV_TX_OFFLOAD_* flag name
+ *
+ * @param offload
+ *   Offload flag
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised
+ */
+const char *rte_eth_dev_tx_offload_name(uint64_t offload);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in the
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index 94d348f..4239e8a 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -214,5 +214,6 @@ EXPERIMENTAL {
 	rte_mtr_stats_read;
 	rte_mtr_stats_update;
 	rte_eth_dev_rx_offload_name;
+	rte_eth_dev_tx_offload_name;
 
 } DPDK_17.11;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v2 3/6] net/sfc: factor out function to report Rx capabilities
  2018-01-18  7:02 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
@ 2018-01-18  7:02   ` Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:02 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

The patch adds a separate function to report supported
Rx capabilities because this function will be required
in more places across the code in the upcoming patches.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_ethdev.c |  9 +--------
 drivers/net/sfc/sfc_rx.c     | 17 +++++++++++++++++
 drivers/net/sfc/sfc_rx.h     |  2 ++
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index af867a7..851b38b 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -104,14 +104,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* By default packets are dropped if no descriptors are available */
 	dev_info->default_rxconf.rx_drop_en = 1;
 
-	dev_info->rx_offload_capa =
-		DEV_RX_OFFLOAD_IPV4_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM |
-		DEV_RX_OFFLOAD_TCP_CKSUM;
-
-	if ((encp->enc_tunnel_encapsulations_supported != 0) &&
-	    (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
-		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa);
 
 	dev_info->tx_offload_capa =
 		DEV_TX_OFFLOAD_IPV4_CKSUM |
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index 6fa56b4..d35f4f7 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -762,6 +762,23 @@ sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
 	sfc_ev_qstop(rxq->evq);
 }
 
+uint64_t
+sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
+	caps |= DEV_RX_OFFLOAD_IPV4_CKSUM;
+	caps |= DEV_RX_OFFLOAD_UDP_CKSUM;
+	caps |= DEV_RX_OFFLOAD_TCP_CKSUM;
+
+	if (encp->enc_tunnel_encapsulations_supported &&
+	    (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
+		caps |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+	return caps;
+}
+
 static int
 sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		   const struct rte_eth_rxconf *rx_conf)
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index 2cf75bc..cc9245f 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -142,6 +142,8 @@ void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 
+uint64_t sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa);
+
 void sfc_rx_qflush_done(struct sfc_rxq *rxq);
 void sfc_rx_qflush_failed(struct sfc_rxq *rxq);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v2 4/6] net/sfc: convert to the new Rx offload API
  2018-01-18  7:02 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
                     ` (2 preceding siblings ...)
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
@ 2018-01-18  7:02   ` Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:02 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Ethdev Rx offloads API has changed since:
commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
This commit support the new Rx offloads API.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_ethdev.c |  27 +++++++++--
 drivers/net/sfc/sfc_port.c   |   5 +-
 drivers/net/sfc/sfc_rx.c     | 111 +++++++++++++++++++++++++++++--------------
 drivers/net/sfc/sfc_rx.h     |   1 +
 4 files changed, 103 insertions(+), 41 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 851b38b..0244a0f 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -104,7 +104,15 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* By default packets are dropped if no descriptors are available */
 	dev_info->default_rxconf.rx_drop_en = 1;
 
-	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa);
+	dev_info->rx_queue_offload_capa = sfc_rx_get_queue_offload_caps(sa);
+
+	/*
+	 * rx_offload_capa includes both device and queue offloads since
+	 * the latter may be requested on a per device basis which makes
+	 * sense when some offloads are needed to be set on all queues.
+	 */
+	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
+				    dev_info->rx_queue_offload_capa;
 
 	dev_info->tx_offload_capa =
 		DEV_TX_OFFLOAD_IPV4_CKSUM |
@@ -882,7 +890,13 @@ sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 	 * The driver does not use it, but other PMDs update jumbo_frame
 	 * flag and max_rx_pkt_len when MTU is set.
 	 */
-	dev->data->dev_conf.rxmode.jumbo_frame = (mtu > ETHER_MAX_LEN);
+	if (mtu > ETHER_MAX_LEN) {
+		struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+
+		rxmode->offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+		rxmode->jumbo_frame = 1;
+	}
+
 	dev->data->dev_conf.rxmode.max_rx_pkt_len = sa->port.pdu;
 
 	sfc_adapter_unlock(sa);
@@ -1045,8 +1059,13 @@ sfc_rx_queue_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 	qinfo->conf.rx_free_thresh = rxq->refill_threshold;
 	qinfo->conf.rx_drop_en = 1;
 	qinfo->conf.rx_deferred_start = rxq_info->deferred_start;
-	qinfo->scattered_rx =
-		((rxq_info->type_flags & EFX_RXQ_FLAG_SCATTER) != 0);
+	qinfo->conf.offloads = DEV_RX_OFFLOAD_IPV4_CKSUM |
+			       DEV_RX_OFFLOAD_UDP_CKSUM |
+			       DEV_RX_OFFLOAD_TCP_CKSUM;
+	if (rxq_info->type_flags & EFX_RXQ_FLAG_SCATTER) {
+		qinfo->conf.offloads |= DEV_RX_OFFLOAD_SCATTER;
+		qinfo->scattered_rx = 1;
+	}
 	qinfo->nb_desc = rxq_info->entries;
 
 	sfc_adapter_unlock(sa);
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index a48388d..c423f52 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -299,11 +299,12 @@ sfc_port_configure(struct sfc_adapter *sa)
 {
 	const struct rte_eth_dev_data *dev_data = sa->eth_dev->data;
 	struct sfc_port *port = &sa->port;
+	const struct rte_eth_rxmode *rxmode = &dev_data->dev_conf.rxmode;
 
 	sfc_log_init(sa, "entry");
 
-	if (dev_data->dev_conf.rxmode.jumbo_frame)
-		port->pdu = dev_data->dev_conf.rxmode.max_rx_pkt_len;
+	if (rxmode->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
+		port->pdu = rxmode->max_rx_pkt_len;
 	else
 		port->pdu = EFX_MAC_PDU(dev_data->mtu);
 
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index d35f4f7..abc53fb 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -768,6 +768,8 @@ sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	uint64_t caps = 0;
 
+	caps |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+	caps |= DEV_RX_OFFLOAD_CRC_STRIP;
 	caps |= DEV_RX_OFFLOAD_IPV4_CKSUM;
 	caps |= DEV_RX_OFFLOAD_UDP_CKSUM;
 	caps |= DEV_RX_OFFLOAD_TCP_CKSUM;
@@ -779,10 +781,62 @@ sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
 	return caps;
 }
 
+uint64_t
+sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa)
+{
+	uint64_t caps = 0;
+
+	if (sa->dp_rx->features & SFC_DP_RX_FEAT_SCATTER)
+		caps |= DEV_RX_OFFLOAD_SCATTER;
+
+	return caps;
+}
+
+static void
+sfc_rx_log_offloads(struct sfc_adapter *sa, const char *offload_group,
+		    const char *verdict, uint64_t offloads)
+{
+	unsigned long long bit;
+
+	while ((bit = __builtin_ffsll(offloads)) != 0) {
+		uint64_t flag = (1ULL << --bit);
+
+		sfc_err(sa, "Rx %s offload %s %s", offload_group,
+			rte_eth_dev_rx_offload_name(flag), verdict);
+
+		offloads &= ~flag;
+	}
+}
+
+static boolean_t
+sfc_rx_queue_offloads_mismatch(struct sfc_adapter *sa, uint64_t requested)
+{
+	uint64_t mandatory = sa->eth_dev->data->dev_conf.rxmode.offloads;
+	uint64_t supported = sfc_rx_get_dev_offload_caps(sa) |
+			     sfc_rx_get_queue_offload_caps(sa);
+	uint64_t rejected = requested & ~supported;
+	uint64_t missing = (requested & mandatory) ^ mandatory;
+	boolean_t mismatch = B_FALSE;
+
+	if (rejected) {
+		sfc_rx_log_offloads(sa, "queue", "is unsupported", rejected);
+		mismatch = B_TRUE;
+	}
+
+	if (missing) {
+		sfc_rx_log_offloads(sa, "queue", "must be set", missing);
+		mismatch = B_TRUE;
+	}
+
+	return mismatch;
+}
+
 static int
 sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		   const struct rte_eth_rxconf *rx_conf)
 {
+	uint64_t offloads_supported = sfc_rx_get_dev_offload_caps(sa) |
+				      sfc_rx_get_queue_offload_caps(sa);
 	int rc = 0;
 
 	if (rx_conf->rx_thresh.pthresh != 0 ||
@@ -804,6 +858,17 @@ sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		rc = EINVAL;
 	}
 
+	if ((rx_conf->offloads & DEV_RX_OFFLOAD_CHECKSUM) !=
+	    DEV_RX_OFFLOAD_CHECKSUM)
+		sfc_warn(sa, "Rx checksum offloads cannot be disabled - always on (IPv4/TCP/UDP)");
+
+	if ((offloads_supported & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM) &&
+	    (~rx_conf->offloads & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM))
+		sfc_warn(sa, "Rx outer IPv4 checksum offload cannot be disabled - always on");
+
+	if (sfc_rx_queue_offloads_mismatch(sa, rx_conf->offloads))
+		rc = EINVAL;
+
 	return rc;
 }
 
@@ -946,7 +1011,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	}
 
 	if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) &&
-	    !sa->eth_dev->data->dev_conf.rxmode.enable_scatter) {
+	    (~rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER)) {
 		sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool "
 			"object size is too small", sw_index);
 		sfc_err(sa, "RxQ %u calculated Rx buffer size is %u vs "
@@ -964,7 +1029,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	rxq_info->entries = rxq_entries;
 	rxq_info->type = EFX_RXQ_TYPE_DEFAULT;
 	rxq_info->type_flags =
-		sa->eth_dev->data->dev_conf.rxmode.enable_scatter ?
+		(rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER) ?
 		EFX_RXQ_FLAG_SCATTER : EFX_RXQ_FLAG_NONE;
 
 	if ((encp->enc_tunnel_encapsulations_supported != 0) &&
@@ -1227,6 +1292,9 @@ sfc_rx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
 static int
 sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 {
+	uint64_t offloads_supported = sfc_rx_get_dev_offload_caps(sa) |
+				      sfc_rx_get_queue_offload_caps(sa);
+	uint64_t offloads_rejected = rxmode->offloads & ~offloads_supported;
 	int rc = 0;
 
 	switch (rxmode->mq_mode) {
@@ -1247,45 +1315,18 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 		rc = EINVAL;
 	}
 
-	if (rxmode->header_split) {
-		sfc_err(sa, "Header split on Rx not supported");
-		rc = EINVAL;
-	}
-
-	if (rxmode->hw_vlan_filter) {
-		sfc_err(sa, "HW VLAN filtering not supported");
-		rc = EINVAL;
-	}
-
-	if (rxmode->hw_vlan_strip) {
-		sfc_err(sa, "HW VLAN stripping not supported");
+	if (offloads_rejected) {
+		sfc_rx_log_offloads(sa, "device", "is unsupported",
+				    offloads_rejected);
 		rc = EINVAL;
 	}
 
-	if (rxmode->hw_vlan_extend) {
-		sfc_err(sa,
-			"Q-in-Q HW VLAN stripping not supported");
-		rc = EINVAL;
-	}
-
-	if (!rxmode->hw_strip_crc) {
-		sfc_warn(sa,
-			 "FCS stripping control not supported - always stripped");
+	if (~rxmode->offloads & DEV_RX_OFFLOAD_CRC_STRIP) {
+		sfc_warn(sa, "FCS stripping cannot be disabled - always on");
+		rxmode->offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
 		rxmode->hw_strip_crc = 1;
 	}
 
-	if (rxmode->enable_scatter &&
-	    (~sa->dp_rx->features & SFC_DP_RX_FEAT_SCATTER)) {
-		sfc_err(sa, "Rx scatter not supported by %s datapath",
-			sa->dp_rx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (rxmode->enable_lro) {
-		sfc_err(sa, "LRO not supported");
-		rc = EINVAL;
-	}
-
 	return rc;
 }
 
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index cc9245f..8c0fa71 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -143,6 +143,7 @@ int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 
 uint64_t sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa);
+uint64_t sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa);
 
 void sfc_rx_qflush_done(struct sfc_rxq *rxq);
 void sfc_rx_qflush_failed(struct sfc_rxq *rxq);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v2 5/6] net/sfc: factor out function to report Tx capabilities
  2018-01-18  7:02 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
                     ` (3 preceding siblings ...)
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
@ 2018-01-18  7:02   ` Andrew Rybchenko
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:02 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

The patch adds a separate function to report supported
Tx capabilities because this function will be required
in more places across the code in the upcoming patches.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_ethdev.c | 13 +------------
 drivers/net/sfc/sfc_tx.c     | 23 +++++++++++++++++++++++
 drivers/net/sfc/sfc_tx.h     |  2 ++
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 0244a0f..0fe9bf5 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -114,20 +114,12 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
 				    dev_info->rx_queue_offload_capa;
 
-	dev_info->tx_offload_capa =
-		DEV_TX_OFFLOAD_IPV4_CKSUM |
-		DEV_TX_OFFLOAD_UDP_CKSUM |
-		DEV_TX_OFFLOAD_TCP_CKSUM;
-
-	if (encp->enc_tunnel_encapsulations_supported != 0)
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa);
 
 	dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
 	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
 	    !encp->enc_hw_tx_insert_vlan_enabled)
 		dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOVLANOFFL;
-	else
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_VLAN_INSERT;
 
 	if (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)
 		dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
@@ -146,9 +138,6 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	}
 #endif
 
-	if (sa->tso)
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
-
 	/* Initialize to hardware limits */
 	dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS;
 	dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS;
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index ee22049..7504037 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -34,6 +34,29 @@
  */
 #define SFC_TX_QFLUSH_POLL_ATTEMPTS	(2000)
 
+uint64_t
+sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
+	caps |= DEV_TX_OFFLOAD_IPV4_CKSUM;
+	caps |= DEV_TX_OFFLOAD_UDP_CKSUM;
+	caps |= DEV_TX_OFFLOAD_TCP_CKSUM;
+
+	if (encp->enc_tunnel_encapsulations_supported)
+		caps |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
+	    encp->enc_hw_tx_insert_vlan_enabled)
+		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
+
+	if (sa->tso)
+		caps |= DEV_TX_OFFLOAD_TCP_TSO;
+
+	return caps;
+}
+
 static int
 sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 		   const struct rte_eth_txconf *tx_conf)
diff --git a/drivers/net/sfc/sfc_tx.h b/drivers/net/sfc/sfc_tx.h
index c2b889f..fc9a9f7 100644
--- a/drivers/net/sfc/sfc_tx.h
+++ b/drivers/net/sfc/sfc_tx.h
@@ -129,6 +129,8 @@ void sfc_tx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_tx_start(struct sfc_adapter *sa);
 void sfc_tx_stop(struct sfc_adapter *sa);
 
+uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
+
 /* From 'sfc_tso.c' */
 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
 				unsigned int txq_entries,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v2 6/6] net/sfc: convert to the new Tx offload API
  2018-01-18  7:02 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
                     ` (4 preceding siblings ...)
  2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
@ 2018-01-18  7:02   ` Andrew Rybchenko
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:02 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

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

The code which fills in txq_flags in default_txconf is preserved
because rte_eth_dev_info_get() lacks conversion between offloads
and txq_flags fields which means that a legacy application which
relies on default_txconf will fail to configure Tx queues in the
case when some bits in txq_flags are mandatory.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
---
 drivers/net/sfc/sfc_dp_tx.h  |   2 +
 drivers/net/sfc/sfc_ethdev.c |  17 +++-
 drivers/net/sfc/sfc_tx.c     | 179 +++++++++++++++++++++++++++----------------
 drivers/net/sfc/sfc_tx.h     |   2 +
 4 files changed, 131 insertions(+), 69 deletions(-)

diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h
index f400755..75d72fe 100644
--- a/drivers/net/sfc/sfc_dp_tx.h
+++ b/drivers/net/sfc/sfc_dp_tx.h
@@ -41,6 +41,8 @@ struct sfc_dp_tx_qcreate_info {
 	unsigned int		free_thresh;
 	/** Transmit queue configuration flags */
 	unsigned int		flags;
+	/** Offloads enabled on the transmit queue */
+	uint64_t		offloads;
 	/** Tx queue size */
 	unsigned int		txq_entries;
 	/** Maximum size of data in the DMA descriptor */
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 0fe9bf5..a86cff6 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -83,6 +83,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t txq_offloads_def = 0;
 
 	sfc_log_init(sa, "entry");
 
@@ -114,7 +115,20 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
 				    dev_info->rx_queue_offload_capa;
 
-	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa);
+	dev_info->tx_queue_offload_capa = sfc_tx_get_queue_offload_caps(sa);
+
+	/*
+	 * tx_offload_capa includes both device and queue offloads since
+	 * the latter may be requested on a per device basis which makes
+	 * sense when some offloads are needed to be set on all queues.
+	 */
+	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa) |
+				    dev_info->tx_queue_offload_capa;
+
+	if (dev_info->tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+		txq_offloads_def |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	dev_info->default_txconf.offloads |= txq_offloads_def;
 
 	dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
 	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
@@ -1081,6 +1095,7 @@ sfc_tx_queue_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	memset(qinfo, 0, sizeof(*qinfo));
 
 	qinfo->conf.txq_flags = txq_info->txq->flags;
+	qinfo->conf.offloads = txq_info->txq->offloads;
 	qinfo->conf.tx_free_thresh = txq_info->txq->free_thresh;
 	qinfo->conf.tx_deferred_start = txq_info->deferred_start;
 	qinfo->nb_desc = txq_info->entries;
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index 7504037..757b03b 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -40,6 +40,26 @@ sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	uint64_t caps = 0;
 
+	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
+	    encp->enc_hw_tx_insert_vlan_enabled)
+		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
+
+	if (sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)
+		caps |= DEV_TX_OFFLOAD_MULTI_SEGS;
+
+	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_POOL) &&
+	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_REFCNT))
+		caps |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	return caps;
+}
+
+uint64_t
+sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
 	caps |= DEV_TX_OFFLOAD_IPV4_CKSUM;
 	caps |= DEV_TX_OFFLOAD_UDP_CKSUM;
 	caps |= DEV_TX_OFFLOAD_TCP_CKSUM;
@@ -47,22 +67,55 @@ sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
 	if (encp->enc_tunnel_encapsulations_supported)
 		caps |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
 
-	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
-	    encp->enc_hw_tx_insert_vlan_enabled)
-		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
-
 	if (sa->tso)
 		caps |= DEV_TX_OFFLOAD_TCP_TSO;
 
 	return caps;
 }
 
+static void
+sfc_tx_log_offloads(struct sfc_adapter *sa, const char *offload_group,
+		    const char *verdict, uint64_t offloads)
+{
+	unsigned long long bit;
+
+	while ((bit = __builtin_ffsll(offloads)) != 0) {
+		uint64_t flag = (1ULL << --bit);
+
+		sfc_err(sa, "Tx %s offload %s %s", offload_group,
+			rte_eth_dev_tx_offload_name(flag), verdict);
+
+		offloads &= ~flag;
+	}
+}
+
+static int
+sfc_tx_queue_offload_mismatch(struct sfc_adapter *sa, uint64_t requested)
+{
+	uint64_t mandatory = sa->eth_dev->data->dev_conf.txmode.offloads;
+	uint64_t supported = sfc_tx_get_dev_offload_caps(sa) |
+			     sfc_tx_get_queue_offload_caps(sa);
+	uint64_t rejected = requested & ~supported;
+	uint64_t missing = (requested & mandatory) ^ mandatory;
+	boolean_t mismatch = B_FALSE;
+
+	if (rejected) {
+		sfc_tx_log_offloads(sa, "queue", "is unsupported", rejected);
+		mismatch = B_TRUE;
+	}
+
+	if (missing) {
+		sfc_tx_log_offloads(sa, "queue", "must be set", missing);
+		mismatch = B_TRUE;
+	}
+
+	return mismatch;
+}
+
 static int
 sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 		   const struct rte_eth_txconf *tx_conf)
 {
-	unsigned int flags = tx_conf->txq_flags;
-	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	int rc = 0;
 
 	if (tx_conf->tx_rs_thresh != 0) {
@@ -84,52 +137,16 @@ sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 			"prefetch/host/writeback thresholds are not supported");
 	}
 
-	if (((flags & ETH_TXQ_FLAGS_NOMULTSEGS) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)) {
-		sfc_err(sa, "Multi-segment is not supported by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (((flags & ETH_TXQ_FLAGS_NOMULTMEMP) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_POOL)) {
-		sfc_err(sa, "multi-mempool is not supported by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (((flags & ETH_TXQ_FLAGS_NOREFCOUNT) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_REFCNT)) {
-		sfc_err(sa,
-			"mbuf reference counters are neglected by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if ((flags & ETH_TXQ_FLAGS_NOVLANOFFL) == 0) {
-		if (!encp->enc_hw_tx_insert_vlan_enabled) {
-			sfc_err(sa, "VLAN offload is not supported");
-			rc = EINVAL;
-		} else if (~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) {
-			sfc_err(sa,
-				"VLAN offload is not supported by %s datapath",
-				sa->dp_tx->dp.name);
-			rc = EINVAL;
-		}
-	}
-
-	if ((flags & ETH_TXQ_FLAGS_NOXSUMSCTP) == 0) {
-		sfc_err(sa, "SCTP offload is not supported");
-		rc = EINVAL;
-	}
-
 	/* We either perform both TCP and UDP offload, or no offload at all */
-	if (((flags & ETH_TXQ_FLAGS_NOXSUMTCP) == 0) !=
-	    ((flags & ETH_TXQ_FLAGS_NOXSUMUDP) == 0)) {
+	if (((tx_conf->offloads & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) !=
+	    ((tx_conf->offloads & DEV_TX_OFFLOAD_UDP_CKSUM) == 0)) {
 		sfc_err(sa, "TCP and UDP offloads can't be set independently");
 		rc = EINVAL;
 	}
 
+	if (sfc_tx_queue_offload_mismatch(sa, tx_conf->offloads))
+		rc = EINVAL;
+
 	return rc;
 }
 
@@ -193,6 +210,7 @@ sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		(tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh :
 		SFC_TX_DEFAULT_FREE_THRESH;
 	txq->flags = tx_conf->txq_flags;
+	txq->offloads = tx_conf->offloads;
 
 	rc = sfc_dma_alloc(sa, "txq", sw_index, EFX_TXQ_SIZE(txq_info->entries),
 			   socket_id, &txq->mem);
@@ -203,6 +221,7 @@ sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	info.max_fill_level = txq_max_fill_level;
 	info.free_thresh = txq->free_thresh;
 	info.flags = tx_conf->txq_flags;
+	info.offloads = tx_conf->offloads;
 	info.txq_entries = txq_info->entries;
 	info.dma_desc_size_max = encp->enc_tx_dma_desc_size_max;
 	info.txq_hw_ring = txq->mem.esm_base;
@@ -284,6 +303,9 @@ sfc_tx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
 static int
 sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
 {
+	uint64_t offloads_supported = sfc_tx_get_dev_offload_caps(sa) |
+				      sfc_tx_get_queue_offload_caps(sa);
+	uint64_t offloads_rejected = txmode->offloads & ~offloads_supported;
 	int rc = 0;
 
 	switch (txmode->mq_mode) {
@@ -314,6 +336,12 @@ sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
 		rc = EINVAL;
 	}
 
+	if (offloads_rejected) {
+		sfc_tx_log_offloads(sa, "device", "is unsupported",
+				    offloads_rejected);
+		rc = EINVAL;
+	}
+
 	return rc;
 }
 
@@ -424,12 +452,13 @@ sfc_tx_close(struct sfc_adapter *sa)
 int
 sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
 {
-	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t offloads_supported = sfc_tx_get_dev_offload_caps(sa) |
+				      sfc_tx_get_queue_offload_caps(sa);
 	struct rte_eth_dev_data *dev_data;
 	struct sfc_txq_info *txq_info;
 	struct sfc_txq *txq;
 	struct sfc_evq *evq;
-	uint16_t flags;
+	uint16_t flags = 0;
 	unsigned int desc_index;
 	int rc = 0;
 
@@ -449,26 +478,40 @@ sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
 		goto fail_ev_qstart;
 
 	/*
-	 * It seems that DPDK has no controls regarding IPv4 offloads,
-	 * hence, we always enable it here
+	 * The absence of ETH_TXQ_FLAGS_IGNORE is associated with a legacy
+	 * application which expects that IPv4 checksum offload is enabled
+	 * all the time as there is no legacy flag to turn off the offload.
 	 */
-	if ((txq->flags & ETH_TXQ_FLAGS_NOXSUMTCP) ||
-	    (txq->flags & ETH_TXQ_FLAGS_NOXSUMUDP)) {
-		flags = EFX_TXQ_CKSUM_IPV4;
-
-		if (encp->enc_tunnel_encapsulations_supported != 0)
-			flags |= EFX_TXQ_CKSUM_INNER_IPV4;
-	} else {
-		flags = EFX_TXQ_CKSUM_IPV4 | EFX_TXQ_CKSUM_TCPUDP;
-
-		if (encp->enc_tunnel_encapsulations_supported != 0)
-			flags |= EFX_TXQ_CKSUM_INNER_IPV4 |
-				 EFX_TXQ_CKSUM_INNER_TCPUDP;
-
-		if (sa->tso)
-			flags |= EFX_TXQ_FATSOV2;
+	if ((txq->offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ||
+	    (~txq->flags & ETH_TXQ_FLAGS_IGNORE))
+		flags |= EFX_TXQ_CKSUM_IPV4;
+
+	if ((txq->offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
+	    ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+	     (offloads_supported & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)))
+		flags |= EFX_TXQ_CKSUM_INNER_IPV4;
+
+	if ((txq->offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ||
+	    (txq->offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) {
+		flags |= EFX_TXQ_CKSUM_TCPUDP;
+
+		if ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+		    (offloads_supported & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
+			flags |= EFX_TXQ_CKSUM_INNER_TCPUDP;
 	}
 
+	/*
+	 * The absence of ETH_TXQ_FLAGS_IGNORE is associated with a legacy
+	 * application. In turn, the absence of ETH_TXQ_FLAGS_NOXSUMTCP is
+	 * associated specifically with a legacy application which expects
+	 * both TCP checksum offload and TSO to be enabled because the legacy
+	 * API does not provide a dedicated mechanism to control TSO.
+	 */
+	if ((txq->offloads & DEV_TX_OFFLOAD_TCP_TSO) ||
+	    ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+	     (~txq->flags & ETH_TXQ_FLAGS_NOXSUMTCP)))
+		flags |= EFX_TXQ_FATSOV2;
+
 	rc = efx_tx_qcreate(sa->nic, sw_index, 0, &txq->mem,
 			    txq_info->entries, 0 /* not used on EF10 */,
 			    flags, evq->common,
@@ -736,9 +779,9 @@ sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		/*
 		 * Here VLAN TCI is expected to be zero in case if no
-		 * DEV_TX_VLAN_OFFLOAD capability is advertised;
+		 * DEV_TX_OFFLOAD_VLAN_INSERT capability is advertised;
 		 * if the calling app ignores the absence of
-		 * DEV_TX_VLAN_OFFLOAD and pushes VLAN TCI, then
+		 * DEV_TX_OFFLOAD_VLAN_INSERT and pushes VLAN TCI, then
 		 * TX_ERROR will occur
 		 */
 		pkt_descs += sfc_efx_tx_maybe_insert_tag(txq, m_seg, &pend);
diff --git a/drivers/net/sfc/sfc_tx.h b/drivers/net/sfc/sfc_tx.h
index fc9a9f7..e3c5d51 100644
--- a/drivers/net/sfc/sfc_tx.h
+++ b/drivers/net/sfc/sfc_tx.h
@@ -59,6 +59,7 @@ struct sfc_txq {
 	efx_txq_t			*common;
 	unsigned int			free_thresh;
 	unsigned int			flags;
+	uint64_t			offloads;
 };
 
 static inline unsigned int
@@ -130,6 +131,7 @@ int sfc_tx_start(struct sfc_adapter *sa);
 void sfc_tx_stop(struct sfc_adapter *sa);
 
 uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
+uint64_t sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa);
 
 /* From 'sfc_tso.c' */
 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new offload API
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
                   ` (7 preceding siblings ...)
  2018-01-18  7:02 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
@ 2018-01-18  7:07 ` Andrew Rybchenko
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
                     ` (5 more replies)
  2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
  9 siblings, 6 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:07 UTC (permalink / raw)
  To: dev; +Cc: Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

May be it is too late to suggest a new API functions to ethdev,
but hopefully if the idea is accepted, it could be applied in the
current release cycle since these functions are trivial.

I'm not sure that rte_ethdev_version.map is updated correctly
since EXPERIMENTAL tag is present and I don't understand how it
should be handled.

In general for the transition period from old offload API to the
new one it would be useful to convert Tx offloads to/from txq_flags
in rte_eth_dev_info_get() for default_txconf and
rte_eth_tx_queue_info_get(). Unfortunately it was lost during
new offload API patches review. However, it would require testing
for all network PMDs and we decided to follow more conservative
approach and kept code to fill in txq_flags which should be simply
removed when txq_flags are removed.

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>

---

v3:
 - add Reviewed-by lost in previous version

v2:
 - make new ethdev API experimentatal (map file and function comment)
 - use space instead of TAB after #define for RTE_?X_OFFLOAD_BIT2STR


Ivan Malov (6):
  ethdev: add a function to look up Rx offload names
  ethdev: add a function to look up Tx offload names
  net/sfc: factor out function to report Rx capabilities
  net/sfc: convert to the new Rx offload API
  net/sfc: factor out function to report Tx capabilities
  net/sfc: convert to the new Tx offload API

 drivers/net/sfc/sfc_dp_tx.h             |   2 +
 drivers/net/sfc/sfc_ethdev.c            |  58 ++++++----
 drivers/net/sfc/sfc_port.c              |   5 +-
 drivers/net/sfc/sfc_rx.c                | 128 +++++++++++++++------
 drivers/net/sfc/sfc_rx.h                |   3 +
 drivers/net/sfc/sfc_tx.c                | 194 +++++++++++++++++++++-----------
 drivers/net/sfc/sfc_tx.h                |   4 +
 lib/librte_ether/rte_ethdev.c           |  87 ++++++++++++++
 lib/librte_ether/rte_ethdev.h           |  36 ++++++
 lib/librte_ether/rte_ethdev_version.map |   2 +
 10 files changed, 397 insertions(+), 122 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v3 1/6] ethdev: add a function to look up Rx offload names
  2018-01-18  7:07 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
@ 2018-01-18  7:07   ` Andrew Rybchenko
  2018-01-18  9:26     ` Thomas Monjalon
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:07 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Commonly, drivers converted to the new offload API
may need to log unsupported offloads as a response
to wrong settings. From this perspective, it would
be convenient to have generic functions to look up
offload names. The patch adds such a helper for Rx.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c           | 42 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 18 ++++++++++++++
 lib/librte_ether/rte_ethdev_version.map |  1 +
 3 files changed, 61 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b349599..9e9ef83 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -89,6 +89,32 @@ static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = {
 #define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) /	\
 		sizeof(rte_txq_stats_strings[0]))
 
+#define RTE_RX_OFFLOAD_BIT2STR(_name)	\
+	{ DEV_RX_OFFLOAD_##_name, #_name }
+
+static const struct {
+	uint64_t offload;
+	const char *name;
+} rte_rx_offload_names[] = {
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(IPV4_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(UDP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(TCP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(TCP_LRO),
+	RTE_RX_OFFLOAD_BIT2STR(QINQ_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(MACSEC_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
+	RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
+	RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(SCATTER),
+	RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
+	RTE_RX_OFFLOAD_BIT2STR(SECURITY),
+};
+
+#undef RTE_RX_OFFLOAD_BIT2STR
 
 /**
  * The user application callback description.
@@ -746,6 +772,22 @@ rte_eth_convert_rx_offloads(const uint64_t rx_offloads,
 		rxmode->security = 0;
 }
 
+const char *
+rte_eth_dev_rx_offload_name(uint64_t offload)
+{
+	const char *name = "UNKNOWN";
+	unsigned int i;
+
+	for (i = 0; i < RTE_DIM(rte_rx_offload_names); ++i) {
+		if (offload == rte_rx_offload_names[i].offload) {
+			name = rte_rx_offload_names[i].name;
+			break;
+		}
+	}
+
+	return name;
+}
+
 int
 rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		      const struct rte_eth_conf *dev_conf)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index a5ba564..0396465 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -946,6 +946,11 @@ struct rte_eth_conf {
 			     DEV_RX_OFFLOAD_VLAN_FILTER | \
 			     DEV_RX_OFFLOAD_VLAN_EXTEND)
 
+/*
+ * If new Rx offload capabilities are defined, they also must be
+ * mentioned in rte_rx_offload_names in rte_ethdev.c file.
+ */
+
 /**
  * TX offload capabilities of a device.
  */
@@ -1923,6 +1928,19 @@ int rte_eth_dev_detach(uint16_t port_id, char *devname);
 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
 
 /**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get DEV_RX_OFFLOAD_* flag name
+ *
+ * @param offload
+ *   Offload flag
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised
+ */
+const char *rte_eth_dev_rx_offload_name(uint64_t offload);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in the
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index e9681ac..94d348f 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -213,5 +213,6 @@ EXPERIMENTAL {
 	rte_mtr_policer_actions_update;
 	rte_mtr_stats_read;
 	rte_mtr_stats_update;
+	rte_eth_dev_rx_offload_name;
 
 } DPDK_17.11;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v3 2/6] ethdev: add a function to look up Tx offload names
  2018-01-18  7:07 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
@ 2018-01-18  7:07   ` Andrew Rybchenko
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
                     ` (3 subsequent siblings)
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:07 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Commonly, drivers converted to the new offload API
may need to log unsupported offloads as a response
to wrong settings. From this perspective, it would
be convenient to have generic functions to look up
offload names. The patch adds such a helper for Tx.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c           | 45 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 18 +++++++++++++
 lib/librte_ether/rte_ethdev_version.map |  1 +
 3 files changed, 64 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 9e9ef83..cd4a3ed 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -116,6 +116,35 @@ static const struct {
 
 #undef RTE_RX_OFFLOAD_BIT2STR
 
+#define RTE_TX_OFFLOAD_BIT2STR(_name)	\
+	{ DEV_TX_OFFLOAD_##_name, #_name }
+
+static const struct {
+	uint64_t offload;
+	const char *name;
+} rte_tx_offload_names[] = {
+	RTE_TX_OFFLOAD_BIT2STR(VLAN_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(IPV4_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(UDP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(TCP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(SCTP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(TCP_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(UDP_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(QINQ_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(VXLAN_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(GRE_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(IPIP_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(GENEVE_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(MACSEC_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(MT_LOCKFREE),
+	RTE_TX_OFFLOAD_BIT2STR(MULTI_SEGS),
+	RTE_TX_OFFLOAD_BIT2STR(MBUF_FAST_FREE),
+	RTE_TX_OFFLOAD_BIT2STR(SECURITY),
+};
+
+#undef RTE_TX_OFFLOAD_BIT2STR
+
 /**
  * The user application callback description.
  *
@@ -788,6 +817,22 @@ rte_eth_dev_rx_offload_name(uint64_t offload)
 	return name;
 }
 
+const char *
+rte_eth_dev_tx_offload_name(uint64_t offload)
+{
+	const char *name = "UNKNOWN";
+	unsigned int i;
+
+	for (i = 0; i < RTE_DIM(rte_tx_offload_names); ++i) {
+		if (offload == rte_tx_offload_names[i].offload) {
+			name = rte_tx_offload_names[i].name;
+			break;
+		}
+	}
+
+	return name;
+}
+
 int
 rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		      const struct rte_eth_conf *dev_conf)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index 0396465..5fab553 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -981,6 +981,11 @@ struct rte_eth_conf {
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
 
+/*
+ * If new Tx offload capabilities are defined, they also must be
+ * mentioned in rte_tx_offload_names in rte_ethdev.c file.
+ */
+
 struct rte_pci_device;
 
 /**
@@ -1941,6 +1946,19 @@ uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
 const char *rte_eth_dev_rx_offload_name(uint64_t offload);
 
 /**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get DEV_TX_OFFLOAD_* flag name
+ *
+ * @param offload
+ *   Offload flag
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised
+ */
+const char *rte_eth_dev_tx_offload_name(uint64_t offload);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in the
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index 94d348f..4239e8a 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -214,5 +214,6 @@ EXPERIMENTAL {
 	rte_mtr_stats_read;
 	rte_mtr_stats_update;
 	rte_eth_dev_rx_offload_name;
+	rte_eth_dev_tx_offload_name;
 
 } DPDK_17.11;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v3 3/6] net/sfc: factor out function to report Rx capabilities
  2018-01-18  7:07 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
@ 2018-01-18  7:07   ` Andrew Rybchenko
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:07 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

The patch adds a separate function to report supported
Rx capabilities because this function will be required
in more places across the code in the upcoming patches.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/sfc/sfc_ethdev.c |  9 +--------
 drivers/net/sfc/sfc_rx.c     | 17 +++++++++++++++++
 drivers/net/sfc/sfc_rx.h     |  2 ++
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index af867a7..851b38b 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -104,14 +104,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* By default packets are dropped if no descriptors are available */
 	dev_info->default_rxconf.rx_drop_en = 1;
 
-	dev_info->rx_offload_capa =
-		DEV_RX_OFFLOAD_IPV4_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM |
-		DEV_RX_OFFLOAD_TCP_CKSUM;
-
-	if ((encp->enc_tunnel_encapsulations_supported != 0) &&
-	    (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
-		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa);
 
 	dev_info->tx_offload_capa =
 		DEV_TX_OFFLOAD_IPV4_CKSUM |
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index 6fa56b4..d35f4f7 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -762,6 +762,23 @@ sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
 	sfc_ev_qstop(rxq->evq);
 }
 
+uint64_t
+sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
+	caps |= DEV_RX_OFFLOAD_IPV4_CKSUM;
+	caps |= DEV_RX_OFFLOAD_UDP_CKSUM;
+	caps |= DEV_RX_OFFLOAD_TCP_CKSUM;
+
+	if (encp->enc_tunnel_encapsulations_supported &&
+	    (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
+		caps |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+	return caps;
+}
+
 static int
 sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		   const struct rte_eth_rxconf *rx_conf)
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index 2cf75bc..cc9245f 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -142,6 +142,8 @@ void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 
+uint64_t sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa);
+
 void sfc_rx_qflush_done(struct sfc_rxq *rxq);
 void sfc_rx_qflush_failed(struct sfc_rxq *rxq);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v3 4/6] net/sfc: convert to the new Rx offload API
  2018-01-18  7:07 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
                     ` (2 preceding siblings ...)
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
@ 2018-01-18  7:07   ` Andrew Rybchenko
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:07 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Ethdev Rx offloads API has changed since:
commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
This commit support the new Rx offloads API.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/sfc/sfc_ethdev.c |  27 +++++++++--
 drivers/net/sfc/sfc_port.c   |   5 +-
 drivers/net/sfc/sfc_rx.c     | 111 +++++++++++++++++++++++++++++--------------
 drivers/net/sfc/sfc_rx.h     |   1 +
 4 files changed, 103 insertions(+), 41 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 851b38b..0244a0f 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -104,7 +104,15 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* By default packets are dropped if no descriptors are available */
 	dev_info->default_rxconf.rx_drop_en = 1;
 
-	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa);
+	dev_info->rx_queue_offload_capa = sfc_rx_get_queue_offload_caps(sa);
+
+	/*
+	 * rx_offload_capa includes both device and queue offloads since
+	 * the latter may be requested on a per device basis which makes
+	 * sense when some offloads are needed to be set on all queues.
+	 */
+	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
+				    dev_info->rx_queue_offload_capa;
 
 	dev_info->tx_offload_capa =
 		DEV_TX_OFFLOAD_IPV4_CKSUM |
@@ -882,7 +890,13 @@ sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 	 * The driver does not use it, but other PMDs update jumbo_frame
 	 * flag and max_rx_pkt_len when MTU is set.
 	 */
-	dev->data->dev_conf.rxmode.jumbo_frame = (mtu > ETHER_MAX_LEN);
+	if (mtu > ETHER_MAX_LEN) {
+		struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+
+		rxmode->offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+		rxmode->jumbo_frame = 1;
+	}
+
 	dev->data->dev_conf.rxmode.max_rx_pkt_len = sa->port.pdu;
 
 	sfc_adapter_unlock(sa);
@@ -1045,8 +1059,13 @@ sfc_rx_queue_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 	qinfo->conf.rx_free_thresh = rxq->refill_threshold;
 	qinfo->conf.rx_drop_en = 1;
 	qinfo->conf.rx_deferred_start = rxq_info->deferred_start;
-	qinfo->scattered_rx =
-		((rxq_info->type_flags & EFX_RXQ_FLAG_SCATTER) != 0);
+	qinfo->conf.offloads = DEV_RX_OFFLOAD_IPV4_CKSUM |
+			       DEV_RX_OFFLOAD_UDP_CKSUM |
+			       DEV_RX_OFFLOAD_TCP_CKSUM;
+	if (rxq_info->type_flags & EFX_RXQ_FLAG_SCATTER) {
+		qinfo->conf.offloads |= DEV_RX_OFFLOAD_SCATTER;
+		qinfo->scattered_rx = 1;
+	}
 	qinfo->nb_desc = rxq_info->entries;
 
 	sfc_adapter_unlock(sa);
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index a48388d..c423f52 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -299,11 +299,12 @@ sfc_port_configure(struct sfc_adapter *sa)
 {
 	const struct rte_eth_dev_data *dev_data = sa->eth_dev->data;
 	struct sfc_port *port = &sa->port;
+	const struct rte_eth_rxmode *rxmode = &dev_data->dev_conf.rxmode;
 
 	sfc_log_init(sa, "entry");
 
-	if (dev_data->dev_conf.rxmode.jumbo_frame)
-		port->pdu = dev_data->dev_conf.rxmode.max_rx_pkt_len;
+	if (rxmode->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
+		port->pdu = rxmode->max_rx_pkt_len;
 	else
 		port->pdu = EFX_MAC_PDU(dev_data->mtu);
 
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index d35f4f7..abc53fb 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -768,6 +768,8 @@ sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	uint64_t caps = 0;
 
+	caps |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+	caps |= DEV_RX_OFFLOAD_CRC_STRIP;
 	caps |= DEV_RX_OFFLOAD_IPV4_CKSUM;
 	caps |= DEV_RX_OFFLOAD_UDP_CKSUM;
 	caps |= DEV_RX_OFFLOAD_TCP_CKSUM;
@@ -779,10 +781,62 @@ sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
 	return caps;
 }
 
+uint64_t
+sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa)
+{
+	uint64_t caps = 0;
+
+	if (sa->dp_rx->features & SFC_DP_RX_FEAT_SCATTER)
+		caps |= DEV_RX_OFFLOAD_SCATTER;
+
+	return caps;
+}
+
+static void
+sfc_rx_log_offloads(struct sfc_adapter *sa, const char *offload_group,
+		    const char *verdict, uint64_t offloads)
+{
+	unsigned long long bit;
+
+	while ((bit = __builtin_ffsll(offloads)) != 0) {
+		uint64_t flag = (1ULL << --bit);
+
+		sfc_err(sa, "Rx %s offload %s %s", offload_group,
+			rte_eth_dev_rx_offload_name(flag), verdict);
+
+		offloads &= ~flag;
+	}
+}
+
+static boolean_t
+sfc_rx_queue_offloads_mismatch(struct sfc_adapter *sa, uint64_t requested)
+{
+	uint64_t mandatory = sa->eth_dev->data->dev_conf.rxmode.offloads;
+	uint64_t supported = sfc_rx_get_dev_offload_caps(sa) |
+			     sfc_rx_get_queue_offload_caps(sa);
+	uint64_t rejected = requested & ~supported;
+	uint64_t missing = (requested & mandatory) ^ mandatory;
+	boolean_t mismatch = B_FALSE;
+
+	if (rejected) {
+		sfc_rx_log_offloads(sa, "queue", "is unsupported", rejected);
+		mismatch = B_TRUE;
+	}
+
+	if (missing) {
+		sfc_rx_log_offloads(sa, "queue", "must be set", missing);
+		mismatch = B_TRUE;
+	}
+
+	return mismatch;
+}
+
 static int
 sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		   const struct rte_eth_rxconf *rx_conf)
 {
+	uint64_t offloads_supported = sfc_rx_get_dev_offload_caps(sa) |
+				      sfc_rx_get_queue_offload_caps(sa);
 	int rc = 0;
 
 	if (rx_conf->rx_thresh.pthresh != 0 ||
@@ -804,6 +858,17 @@ sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		rc = EINVAL;
 	}
 
+	if ((rx_conf->offloads & DEV_RX_OFFLOAD_CHECKSUM) !=
+	    DEV_RX_OFFLOAD_CHECKSUM)
+		sfc_warn(sa, "Rx checksum offloads cannot be disabled - always on (IPv4/TCP/UDP)");
+
+	if ((offloads_supported & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM) &&
+	    (~rx_conf->offloads & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM))
+		sfc_warn(sa, "Rx outer IPv4 checksum offload cannot be disabled - always on");
+
+	if (sfc_rx_queue_offloads_mismatch(sa, rx_conf->offloads))
+		rc = EINVAL;
+
 	return rc;
 }
 
@@ -946,7 +1011,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	}
 
 	if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) &&
-	    !sa->eth_dev->data->dev_conf.rxmode.enable_scatter) {
+	    (~rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER)) {
 		sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool "
 			"object size is too small", sw_index);
 		sfc_err(sa, "RxQ %u calculated Rx buffer size is %u vs "
@@ -964,7 +1029,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	rxq_info->entries = rxq_entries;
 	rxq_info->type = EFX_RXQ_TYPE_DEFAULT;
 	rxq_info->type_flags =
-		sa->eth_dev->data->dev_conf.rxmode.enable_scatter ?
+		(rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER) ?
 		EFX_RXQ_FLAG_SCATTER : EFX_RXQ_FLAG_NONE;
 
 	if ((encp->enc_tunnel_encapsulations_supported != 0) &&
@@ -1227,6 +1292,9 @@ sfc_rx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
 static int
 sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 {
+	uint64_t offloads_supported = sfc_rx_get_dev_offload_caps(sa) |
+				      sfc_rx_get_queue_offload_caps(sa);
+	uint64_t offloads_rejected = rxmode->offloads & ~offloads_supported;
 	int rc = 0;
 
 	switch (rxmode->mq_mode) {
@@ -1247,45 +1315,18 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 		rc = EINVAL;
 	}
 
-	if (rxmode->header_split) {
-		sfc_err(sa, "Header split on Rx not supported");
-		rc = EINVAL;
-	}
-
-	if (rxmode->hw_vlan_filter) {
-		sfc_err(sa, "HW VLAN filtering not supported");
-		rc = EINVAL;
-	}
-
-	if (rxmode->hw_vlan_strip) {
-		sfc_err(sa, "HW VLAN stripping not supported");
+	if (offloads_rejected) {
+		sfc_rx_log_offloads(sa, "device", "is unsupported",
+				    offloads_rejected);
 		rc = EINVAL;
 	}
 
-	if (rxmode->hw_vlan_extend) {
-		sfc_err(sa,
-			"Q-in-Q HW VLAN stripping not supported");
-		rc = EINVAL;
-	}
-
-	if (!rxmode->hw_strip_crc) {
-		sfc_warn(sa,
-			 "FCS stripping control not supported - always stripped");
+	if (~rxmode->offloads & DEV_RX_OFFLOAD_CRC_STRIP) {
+		sfc_warn(sa, "FCS stripping cannot be disabled - always on");
+		rxmode->offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
 		rxmode->hw_strip_crc = 1;
 	}
 
-	if (rxmode->enable_scatter &&
-	    (~sa->dp_rx->features & SFC_DP_RX_FEAT_SCATTER)) {
-		sfc_err(sa, "Rx scatter not supported by %s datapath",
-			sa->dp_rx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (rxmode->enable_lro) {
-		sfc_err(sa, "LRO not supported");
-		rc = EINVAL;
-	}
-
 	return rc;
 }
 
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index cc9245f..8c0fa71 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -143,6 +143,7 @@ int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 
 uint64_t sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa);
+uint64_t sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa);
 
 void sfc_rx_qflush_done(struct sfc_rxq *rxq);
 void sfc_rx_qflush_failed(struct sfc_rxq *rxq);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v3 5/6] net/sfc: factor out function to report Tx capabilities
  2018-01-18  7:07 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
                     ` (3 preceding siblings ...)
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
@ 2018-01-18  7:07   ` Andrew Rybchenko
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:07 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

The patch adds a separate function to report supported
Tx capabilities because this function will be required
in more places across the code in the upcoming patches.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/sfc/sfc_ethdev.c | 13 +------------
 drivers/net/sfc/sfc_tx.c     | 23 +++++++++++++++++++++++
 drivers/net/sfc/sfc_tx.h     |  2 ++
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 0244a0f..0fe9bf5 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -114,20 +114,12 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
 				    dev_info->rx_queue_offload_capa;
 
-	dev_info->tx_offload_capa =
-		DEV_TX_OFFLOAD_IPV4_CKSUM |
-		DEV_TX_OFFLOAD_UDP_CKSUM |
-		DEV_TX_OFFLOAD_TCP_CKSUM;
-
-	if (encp->enc_tunnel_encapsulations_supported != 0)
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa);
 
 	dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
 	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
 	    !encp->enc_hw_tx_insert_vlan_enabled)
 		dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOVLANOFFL;
-	else
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_VLAN_INSERT;
 
 	if (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)
 		dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
@@ -146,9 +138,6 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	}
 #endif
 
-	if (sa->tso)
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
-
 	/* Initialize to hardware limits */
 	dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS;
 	dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS;
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index ee22049..7504037 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -34,6 +34,29 @@
  */
 #define SFC_TX_QFLUSH_POLL_ATTEMPTS	(2000)
 
+uint64_t
+sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
+	caps |= DEV_TX_OFFLOAD_IPV4_CKSUM;
+	caps |= DEV_TX_OFFLOAD_UDP_CKSUM;
+	caps |= DEV_TX_OFFLOAD_TCP_CKSUM;
+
+	if (encp->enc_tunnel_encapsulations_supported)
+		caps |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
+	    encp->enc_hw_tx_insert_vlan_enabled)
+		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
+
+	if (sa->tso)
+		caps |= DEV_TX_OFFLOAD_TCP_TSO;
+
+	return caps;
+}
+
 static int
 sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 		   const struct rte_eth_txconf *tx_conf)
diff --git a/drivers/net/sfc/sfc_tx.h b/drivers/net/sfc/sfc_tx.h
index c2b889f..fc9a9f7 100644
--- a/drivers/net/sfc/sfc_tx.h
+++ b/drivers/net/sfc/sfc_tx.h
@@ -129,6 +129,8 @@ void sfc_tx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_tx_start(struct sfc_adapter *sa);
 void sfc_tx_stop(struct sfc_adapter *sa);
 
+uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
+
 /* From 'sfc_tso.c' */
 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
 				unsigned int txq_entries,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v3 6/6] net/sfc: convert to the new Tx offload API
  2018-01-18  7:07 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
                     ` (4 preceding siblings ...)
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
@ 2018-01-18  7:07   ` Andrew Rybchenko
  5 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:07 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

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

The code which fills in txq_flags in default_txconf is preserved
because rte_eth_dev_info_get() lacks conversion between offloads
and txq_flags fields which means that a legacy application which
relies on default_txconf will fail to configure Tx queues in the
case when some bits in txq_flags are mandatory.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/sfc/sfc_dp_tx.h  |   2 +
 drivers/net/sfc/sfc_ethdev.c |  17 +++-
 drivers/net/sfc/sfc_tx.c     | 179 +++++++++++++++++++++++++++----------------
 drivers/net/sfc/sfc_tx.h     |   2 +
 4 files changed, 131 insertions(+), 69 deletions(-)

diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h
index f400755..75d72fe 100644
--- a/drivers/net/sfc/sfc_dp_tx.h
+++ b/drivers/net/sfc/sfc_dp_tx.h
@@ -41,6 +41,8 @@ struct sfc_dp_tx_qcreate_info {
 	unsigned int		free_thresh;
 	/** Transmit queue configuration flags */
 	unsigned int		flags;
+	/** Offloads enabled on the transmit queue */
+	uint64_t		offloads;
 	/** Tx queue size */
 	unsigned int		txq_entries;
 	/** Maximum size of data in the DMA descriptor */
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 0fe9bf5..a86cff6 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -83,6 +83,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t txq_offloads_def = 0;
 
 	sfc_log_init(sa, "entry");
 
@@ -114,7 +115,20 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
 				    dev_info->rx_queue_offload_capa;
 
-	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa);
+	dev_info->tx_queue_offload_capa = sfc_tx_get_queue_offload_caps(sa);
+
+	/*
+	 * tx_offload_capa includes both device and queue offloads since
+	 * the latter may be requested on a per device basis which makes
+	 * sense when some offloads are needed to be set on all queues.
+	 */
+	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa) |
+				    dev_info->tx_queue_offload_capa;
+
+	if (dev_info->tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+		txq_offloads_def |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	dev_info->default_txconf.offloads |= txq_offloads_def;
 
 	dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
 	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
@@ -1081,6 +1095,7 @@ sfc_tx_queue_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	memset(qinfo, 0, sizeof(*qinfo));
 
 	qinfo->conf.txq_flags = txq_info->txq->flags;
+	qinfo->conf.offloads = txq_info->txq->offloads;
 	qinfo->conf.tx_free_thresh = txq_info->txq->free_thresh;
 	qinfo->conf.tx_deferred_start = txq_info->deferred_start;
 	qinfo->nb_desc = txq_info->entries;
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index 7504037..757b03b 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -40,6 +40,26 @@ sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	uint64_t caps = 0;
 
+	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
+	    encp->enc_hw_tx_insert_vlan_enabled)
+		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
+
+	if (sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)
+		caps |= DEV_TX_OFFLOAD_MULTI_SEGS;
+
+	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_POOL) &&
+	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_REFCNT))
+		caps |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	return caps;
+}
+
+uint64_t
+sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
 	caps |= DEV_TX_OFFLOAD_IPV4_CKSUM;
 	caps |= DEV_TX_OFFLOAD_UDP_CKSUM;
 	caps |= DEV_TX_OFFLOAD_TCP_CKSUM;
@@ -47,22 +67,55 @@ sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
 	if (encp->enc_tunnel_encapsulations_supported)
 		caps |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
 
-	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
-	    encp->enc_hw_tx_insert_vlan_enabled)
-		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
-
 	if (sa->tso)
 		caps |= DEV_TX_OFFLOAD_TCP_TSO;
 
 	return caps;
 }
 
+static void
+sfc_tx_log_offloads(struct sfc_adapter *sa, const char *offload_group,
+		    const char *verdict, uint64_t offloads)
+{
+	unsigned long long bit;
+
+	while ((bit = __builtin_ffsll(offloads)) != 0) {
+		uint64_t flag = (1ULL << --bit);
+
+		sfc_err(sa, "Tx %s offload %s %s", offload_group,
+			rte_eth_dev_tx_offload_name(flag), verdict);
+
+		offloads &= ~flag;
+	}
+}
+
+static int
+sfc_tx_queue_offload_mismatch(struct sfc_adapter *sa, uint64_t requested)
+{
+	uint64_t mandatory = sa->eth_dev->data->dev_conf.txmode.offloads;
+	uint64_t supported = sfc_tx_get_dev_offload_caps(sa) |
+			     sfc_tx_get_queue_offload_caps(sa);
+	uint64_t rejected = requested & ~supported;
+	uint64_t missing = (requested & mandatory) ^ mandatory;
+	boolean_t mismatch = B_FALSE;
+
+	if (rejected) {
+		sfc_tx_log_offloads(sa, "queue", "is unsupported", rejected);
+		mismatch = B_TRUE;
+	}
+
+	if (missing) {
+		sfc_tx_log_offloads(sa, "queue", "must be set", missing);
+		mismatch = B_TRUE;
+	}
+
+	return mismatch;
+}
+
 static int
 sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 		   const struct rte_eth_txconf *tx_conf)
 {
-	unsigned int flags = tx_conf->txq_flags;
-	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	int rc = 0;
 
 	if (tx_conf->tx_rs_thresh != 0) {
@@ -84,52 +137,16 @@ sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 			"prefetch/host/writeback thresholds are not supported");
 	}
 
-	if (((flags & ETH_TXQ_FLAGS_NOMULTSEGS) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)) {
-		sfc_err(sa, "Multi-segment is not supported by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (((flags & ETH_TXQ_FLAGS_NOMULTMEMP) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_POOL)) {
-		sfc_err(sa, "multi-mempool is not supported by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (((flags & ETH_TXQ_FLAGS_NOREFCOUNT) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_REFCNT)) {
-		sfc_err(sa,
-			"mbuf reference counters are neglected by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if ((flags & ETH_TXQ_FLAGS_NOVLANOFFL) == 0) {
-		if (!encp->enc_hw_tx_insert_vlan_enabled) {
-			sfc_err(sa, "VLAN offload is not supported");
-			rc = EINVAL;
-		} else if (~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) {
-			sfc_err(sa,
-				"VLAN offload is not supported by %s datapath",
-				sa->dp_tx->dp.name);
-			rc = EINVAL;
-		}
-	}
-
-	if ((flags & ETH_TXQ_FLAGS_NOXSUMSCTP) == 0) {
-		sfc_err(sa, "SCTP offload is not supported");
-		rc = EINVAL;
-	}
-
 	/* We either perform both TCP and UDP offload, or no offload at all */
-	if (((flags & ETH_TXQ_FLAGS_NOXSUMTCP) == 0) !=
-	    ((flags & ETH_TXQ_FLAGS_NOXSUMUDP) == 0)) {
+	if (((tx_conf->offloads & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) !=
+	    ((tx_conf->offloads & DEV_TX_OFFLOAD_UDP_CKSUM) == 0)) {
 		sfc_err(sa, "TCP and UDP offloads can't be set independently");
 		rc = EINVAL;
 	}
 
+	if (sfc_tx_queue_offload_mismatch(sa, tx_conf->offloads))
+		rc = EINVAL;
+
 	return rc;
 }
 
@@ -193,6 +210,7 @@ sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		(tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh :
 		SFC_TX_DEFAULT_FREE_THRESH;
 	txq->flags = tx_conf->txq_flags;
+	txq->offloads = tx_conf->offloads;
 
 	rc = sfc_dma_alloc(sa, "txq", sw_index, EFX_TXQ_SIZE(txq_info->entries),
 			   socket_id, &txq->mem);
@@ -203,6 +221,7 @@ sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	info.max_fill_level = txq_max_fill_level;
 	info.free_thresh = txq->free_thresh;
 	info.flags = tx_conf->txq_flags;
+	info.offloads = tx_conf->offloads;
 	info.txq_entries = txq_info->entries;
 	info.dma_desc_size_max = encp->enc_tx_dma_desc_size_max;
 	info.txq_hw_ring = txq->mem.esm_base;
@@ -284,6 +303,9 @@ sfc_tx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
 static int
 sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
 {
+	uint64_t offloads_supported = sfc_tx_get_dev_offload_caps(sa) |
+				      sfc_tx_get_queue_offload_caps(sa);
+	uint64_t offloads_rejected = txmode->offloads & ~offloads_supported;
 	int rc = 0;
 
 	switch (txmode->mq_mode) {
@@ -314,6 +336,12 @@ sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
 		rc = EINVAL;
 	}
 
+	if (offloads_rejected) {
+		sfc_tx_log_offloads(sa, "device", "is unsupported",
+				    offloads_rejected);
+		rc = EINVAL;
+	}
+
 	return rc;
 }
 
@@ -424,12 +452,13 @@ sfc_tx_close(struct sfc_adapter *sa)
 int
 sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
 {
-	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t offloads_supported = sfc_tx_get_dev_offload_caps(sa) |
+				      sfc_tx_get_queue_offload_caps(sa);
 	struct rte_eth_dev_data *dev_data;
 	struct sfc_txq_info *txq_info;
 	struct sfc_txq *txq;
 	struct sfc_evq *evq;
-	uint16_t flags;
+	uint16_t flags = 0;
 	unsigned int desc_index;
 	int rc = 0;
 
@@ -449,26 +478,40 @@ sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
 		goto fail_ev_qstart;
 
 	/*
-	 * It seems that DPDK has no controls regarding IPv4 offloads,
-	 * hence, we always enable it here
+	 * The absence of ETH_TXQ_FLAGS_IGNORE is associated with a legacy
+	 * application which expects that IPv4 checksum offload is enabled
+	 * all the time as there is no legacy flag to turn off the offload.
 	 */
-	if ((txq->flags & ETH_TXQ_FLAGS_NOXSUMTCP) ||
-	    (txq->flags & ETH_TXQ_FLAGS_NOXSUMUDP)) {
-		flags = EFX_TXQ_CKSUM_IPV4;
-
-		if (encp->enc_tunnel_encapsulations_supported != 0)
-			flags |= EFX_TXQ_CKSUM_INNER_IPV4;
-	} else {
-		flags = EFX_TXQ_CKSUM_IPV4 | EFX_TXQ_CKSUM_TCPUDP;
-
-		if (encp->enc_tunnel_encapsulations_supported != 0)
-			flags |= EFX_TXQ_CKSUM_INNER_IPV4 |
-				 EFX_TXQ_CKSUM_INNER_TCPUDP;
-
-		if (sa->tso)
-			flags |= EFX_TXQ_FATSOV2;
+	if ((txq->offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ||
+	    (~txq->flags & ETH_TXQ_FLAGS_IGNORE))
+		flags |= EFX_TXQ_CKSUM_IPV4;
+
+	if ((txq->offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
+	    ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+	     (offloads_supported & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)))
+		flags |= EFX_TXQ_CKSUM_INNER_IPV4;
+
+	if ((txq->offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ||
+	    (txq->offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) {
+		flags |= EFX_TXQ_CKSUM_TCPUDP;
+
+		if ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+		    (offloads_supported & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
+			flags |= EFX_TXQ_CKSUM_INNER_TCPUDP;
 	}
 
+	/*
+	 * The absence of ETH_TXQ_FLAGS_IGNORE is associated with a legacy
+	 * application. In turn, the absence of ETH_TXQ_FLAGS_NOXSUMTCP is
+	 * associated specifically with a legacy application which expects
+	 * both TCP checksum offload and TSO to be enabled because the legacy
+	 * API does not provide a dedicated mechanism to control TSO.
+	 */
+	if ((txq->offloads & DEV_TX_OFFLOAD_TCP_TSO) ||
+	    ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+	     (~txq->flags & ETH_TXQ_FLAGS_NOXSUMTCP)))
+		flags |= EFX_TXQ_FATSOV2;
+
 	rc = efx_tx_qcreate(sa->nic, sw_index, 0, &txq->mem,
 			    txq_info->entries, 0 /* not used on EF10 */,
 			    flags, evq->common,
@@ -736,9 +779,9 @@ sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		/*
 		 * Here VLAN TCI is expected to be zero in case if no
-		 * DEV_TX_VLAN_OFFLOAD capability is advertised;
+		 * DEV_TX_OFFLOAD_VLAN_INSERT capability is advertised;
 		 * if the calling app ignores the absence of
-		 * DEV_TX_VLAN_OFFLOAD and pushes VLAN TCI, then
+		 * DEV_TX_OFFLOAD_VLAN_INSERT and pushes VLAN TCI, then
 		 * TX_ERROR will occur
 		 */
 		pkt_descs += sfc_efx_tx_maybe_insert_tag(txq, m_seg, &pend);
diff --git a/drivers/net/sfc/sfc_tx.h b/drivers/net/sfc/sfc_tx.h
index fc9a9f7..e3c5d51 100644
--- a/drivers/net/sfc/sfc_tx.h
+++ b/drivers/net/sfc/sfc_tx.h
@@ -59,6 +59,7 @@ struct sfc_txq {
 	efx_txq_t			*common;
 	unsigned int			free_thresh;
 	unsigned int			flags;
+	uint64_t			offloads;
 };
 
 static inline unsigned int
@@ -130,6 +131,7 @@ int sfc_tx_start(struct sfc_adapter *sa);
 void sfc_tx_stop(struct sfc_adapter *sa);
 
 uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
+uint64_t sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa);
 
 /* From 'sfc_tso.c' */
 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names
  2018-01-17 17:33   ` Thomas Monjalon
  2018-01-18  6:32     ` Shahaf Shuler
@ 2018-01-18  7:16     ` Andrew Rybchenko
  2018-01-18  7:52       ` Andrew Rybchenko
  1 sibling, 1 reply; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:16 UTC (permalink / raw)
  To: Thomas Monjalon, Ivan Malov; +Cc: dev, Ferruh Yigit, Shahaf Shuler

On 01/17/2018 08:33 PM, Thomas Monjalon wrote:
> Hi, 2 comments below
>
> 11/01/2018 09:12, Andrew Rybchenko:
>> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>>
>> +#define	RTE_RX_OFFLOAD_BIT2STR(_name)	\
>> +	{ DEV_RX_OFFLOAD_##_name, #_name }
>> +
>> +static const struct {
>> +	uint64_t offload;
>> +	const char *name;
>> +} rte_rx_offload_names[] = {
>> +	RTE_RX_OFFLOAD_BIT2STR(VLAN_STRIP),
>> +	RTE_RX_OFFLOAD_BIT2STR(IPV4_CKSUM),
>> +	RTE_RX_OFFLOAD_BIT2STR(UDP_CKSUM),
>> +	RTE_RX_OFFLOAD_BIT2STR(TCP_CKSUM),
>> +	RTE_RX_OFFLOAD_BIT2STR(TCP_LRO),
>> +	RTE_RX_OFFLOAD_BIT2STR(QINQ_STRIP),
>> +	RTE_RX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
>> +	RTE_RX_OFFLOAD_BIT2STR(MACSEC_STRIP),
>> +	RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
>> +	RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
>> +	RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
>> +	RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
>> +	RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
>> +	RTE_RX_OFFLOAD_BIT2STR(SCATTER),
>> +	RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
>> +	RTE_RX_OFFLOAD_BIT2STR(SECURITY),
>> +};
>> +
>> +#undef RTE_RX_OFFLOAD_BIT2STR
> Why this undef?

It is a constant-local macro with assumption to be used as
initializer of the corresponding structure. So, under is just to
limit its context and be sure that it is will not clash or be reused
most likely in a wrong way.

>> --- a/lib/librte_ether/rte_ethdev_version.map
>> +++ b/lib/librte_ether/rte_ethdev_version.map
>> @@ -198,6 +198,12 @@ DPDK_17.11 {
>>   
>>   } DPDK_17.08;
>>   
>> +DPDK_18.02 {
>> +	global:
>> +
>> +	rte_eth_dev_rx_offload_name;
>> +} DPDK_17.11;
> New functions should be experimental.

Thanks, I've moved it to EXPERIMENTAL and added a comment
as highlighted by Ferruh in another review.

I've not removed DPDK_17.11 base for EXPERIMENTAL in map file.
If it should be done, it should be done separately.

Thanks.

>>   EXPERIMENTAL {
>>   	global:

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names
  2018-01-18  7:16     ` Andrew Rybchenko
@ 2018-01-18  7:52       ` Andrew Rybchenko
  2018-01-18  9:24         ` Thomas Monjalon
  0 siblings, 1 reply; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  7:52 UTC (permalink / raw)
  To: Thomas Monjalon, Ivan Malov; +Cc: dev, Ferruh Yigit, Shahaf Shuler

On 01/18/2018 10:16 AM, Andrew Rybchenko wrote:
> On 01/17/2018 08:33 PM, Thomas Monjalon wrote:
>> Hi, 2 comments below
>>
>> 11/01/2018 09:12, Andrew Rybchenko:
>>> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>>>
>>> +#define    RTE_RX_OFFLOAD_BIT2STR(_name)    \
>>> +    { DEV_RX_OFFLOAD_##_name, #_name }
>>> +
>>> +static const struct {
>>> +    uint64_t offload;
>>> +    const char *name;
>>> +} rte_rx_offload_names[] = {
>>> +    RTE_RX_OFFLOAD_BIT2STR(VLAN_STRIP),
>>> +    RTE_RX_OFFLOAD_BIT2STR(IPV4_CKSUM),
>>> +    RTE_RX_OFFLOAD_BIT2STR(UDP_CKSUM),
>>> +    RTE_RX_OFFLOAD_BIT2STR(TCP_CKSUM),
>>> +    RTE_RX_OFFLOAD_BIT2STR(TCP_LRO),
>>> +    RTE_RX_OFFLOAD_BIT2STR(QINQ_STRIP),
>>> +    RTE_RX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
>>> +    RTE_RX_OFFLOAD_BIT2STR(MACSEC_STRIP),
>>> +    RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
>>> +    RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
>>> +    RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
>>> +    RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
>>> +    RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
>>> +    RTE_RX_OFFLOAD_BIT2STR(SCATTER),
>>> +    RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
>>> +    RTE_RX_OFFLOAD_BIT2STR(SECURITY),
>>> +};
>>> +
>>> +#undef RTE_RX_OFFLOAD_BIT2STR
>> Why this undef?
>
> It is a constant-local macro with assumption to be used as

I mean context-local, sorry.

> initializer of the corresponding structure. So, under is just to
> limit its context and be sure that it is will not clash or be reused
> most likely in a wrong way.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names
  2018-01-18  7:52       ` Andrew Rybchenko
@ 2018-01-18  9:24         ` Thomas Monjalon
  0 siblings, 0 replies; 41+ messages in thread
From: Thomas Monjalon @ 2018-01-18  9:24 UTC (permalink / raw)
  To: Andrew Rybchenko, Ivan Malov; +Cc: dev, Ferruh Yigit, Shahaf Shuler

18/01/2018 08:52, Andrew Rybchenko:
> On 01/18/2018 10:16 AM, Andrew Rybchenko wrote:
> > On 01/17/2018 08:33 PM, Thomas Monjalon wrote:
> >> Hi, 2 comments below
> >>
> >> 11/01/2018 09:12, Andrew Rybchenko:
> >>> From: Ivan Malov <ivan.malov@oktetlabs.ru>
> >>>
> >>> +#define    RTE_RX_OFFLOAD_BIT2STR(_name)    \
> >>> +    { DEV_RX_OFFLOAD_##_name, #_name }
> >>> +
> >>> +static const struct {
> >>> +    uint64_t offload;
> >>> +    const char *name;
> >>> +} rte_rx_offload_names[] = {
> >>> +    RTE_RX_OFFLOAD_BIT2STR(VLAN_STRIP),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(IPV4_CKSUM),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(UDP_CKSUM),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(TCP_CKSUM),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(TCP_LRO),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(QINQ_STRIP),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(MACSEC_STRIP),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(SCATTER),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
> >>> +    RTE_RX_OFFLOAD_BIT2STR(SECURITY),
> >>> +};
> >>> +
> >>> +#undef RTE_RX_OFFLOAD_BIT2STR
> >> Why this undef?
> >
> > It is a constant-local macro with assumption to be used as
> 
> I mean context-local, sorry.
> 
> > initializer of the corresponding structure. So, under is just to
> > limit its context and be sure that it is will not clash or be reused
> > most likely in a wrong way.

We do not take this precaution usually in DPDK.
No strong opinion however.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add a function to look up Rx offload names
  2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
@ 2018-01-18  9:26     ` Thomas Monjalon
  2018-01-18  9:47       ` Andrew Rybchenko
  0 siblings, 1 reply; 41+ messages in thread
From: Thomas Monjalon @ 2018-01-18  9:26 UTC (permalink / raw)
  To: Andrew Rybchenko, Ivan Malov; +Cc: dev, Ferruh Yigit, Shahaf Shuler

18/01/2018 08:07, Andrew Rybchenko:
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
> --- a/lib/librte_ether/rte_ethdev_version.map
> +++ b/lib/librte_ether/rte_ethdev_version.map
> @@ -213,5 +213,6 @@ EXPERIMENTAL {
>  	rte_mtr_policer_actions_update;
>  	rte_mtr_stats_read;
>  	rte_mtr_stats_update;
> +	rte_eth_dev_rx_offload_name;
>  
>  } DPDK_17.11;

Please keep it in alphabetical order.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new offload API
  2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
                   ` (8 preceding siblings ...)
  2018-01-18  7:07 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
@ 2018-01-18  9:44 ` Andrew Rybchenko
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
                     ` (6 more replies)
  9 siblings, 7 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  9:44 UTC (permalink / raw)
  To: dev; +Cc: Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

May be it is too late to suggest a new API functions to ethdev,
but hopefully if the idea is accepted, it could be applied in the
current release cycle since these functions are trivial.

I'm not sure that rte_ethdev_version.map is updated correctly
since EXPERIMENTAL tag is present and I don't understand how it
should be handled.

In general for the transition period from old offload API to the
new one it would be useful to convert Tx offloads to/from txq_flags
in rte_eth_dev_info_get() for default_txconf and
rte_eth_tx_queue_info_get(). Unfortunately it was lost during
new offload API patches review. However, it would require testing
for all network PMDs and we decided to follow more conservative
approach and kept code to fill in txq_flags which should be simply
removed when txq_flags are removed.

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>

---

v4:
 - add symbols to map file in aphabetical order
 - add dots in ethdev function descriptions (seems to be more common
   for rte_ethdev.h file)

v3:
 - add Reviewed-by lost in previous version

v2:
 - make new ethdev API experimentatal (map file and function comment)
 - use space instead of TAB after #define for RTE_?X_OFFLOAD_BIT2STR


Ivan Malov (6):
  ethdev: add a function to look up Rx offload names
  ethdev: add a function to look up Tx offload names
  net/sfc: factor out function to report Rx capabilities
  net/sfc: convert to the new Rx offload API
  net/sfc: factor out function to report Tx capabilities
  net/sfc: convert to the new Tx offload API

 drivers/net/sfc/sfc_dp_tx.h             |   2 +
 drivers/net/sfc/sfc_ethdev.c            |  58 ++++++----
 drivers/net/sfc/sfc_port.c              |   5 +-
 drivers/net/sfc/sfc_rx.c                | 128 +++++++++++++++------
 drivers/net/sfc/sfc_rx.h                |   3 +
 drivers/net/sfc/sfc_tx.c                | 194 +++++++++++++++++++++-----------
 drivers/net/sfc/sfc_tx.h                |   4 +
 lib/librte_ether/rte_ethdev.c           |  87 ++++++++++++++
 lib/librte_ether/rte_ethdev.h           |  36 ++++++
 lib/librte_ether/rte_ethdev_version.map |   2 +
 10 files changed, 397 insertions(+), 122 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v4 1/6] ethdev: add a function to look up Rx offload names
  2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
@ 2018-01-18  9:44   ` Andrew Rybchenko
  2018-01-18 10:29     ` Thomas Monjalon
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  9:44 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Commonly, drivers converted to the new offload API
may need to log unsupported offloads as a response
to wrong settings. From this perspective, it would
be convenient to have generic functions to look up
offload names. The patch adds such a helper for Rx.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c           | 42 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 18 ++++++++++++++
 lib/librte_ether/rte_ethdev_version.map |  1 +
 3 files changed, 61 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index b349599..9e9ef83 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -89,6 +89,32 @@ static const struct rte_eth_xstats_name_off rte_txq_stats_strings[] = {
 #define RTE_NB_TXQ_STATS (sizeof(rte_txq_stats_strings) /	\
 		sizeof(rte_txq_stats_strings[0]))
 
+#define RTE_RX_OFFLOAD_BIT2STR(_name)	\
+	{ DEV_RX_OFFLOAD_##_name, #_name }
+
+static const struct {
+	uint64_t offload;
+	const char *name;
+} rte_rx_offload_names[] = {
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(IPV4_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(UDP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(TCP_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(TCP_LRO),
+	RTE_RX_OFFLOAD_BIT2STR(QINQ_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
+	RTE_RX_OFFLOAD_BIT2STR(MACSEC_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(HEADER_SPLIT),
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_FILTER),
+	RTE_RX_OFFLOAD_BIT2STR(VLAN_EXTEND),
+	RTE_RX_OFFLOAD_BIT2STR(JUMBO_FRAME),
+	RTE_RX_OFFLOAD_BIT2STR(CRC_STRIP),
+	RTE_RX_OFFLOAD_BIT2STR(SCATTER),
+	RTE_RX_OFFLOAD_BIT2STR(TIMESTAMP),
+	RTE_RX_OFFLOAD_BIT2STR(SECURITY),
+};
+
+#undef RTE_RX_OFFLOAD_BIT2STR
 
 /**
  * The user application callback description.
@@ -746,6 +772,22 @@ rte_eth_convert_rx_offloads(const uint64_t rx_offloads,
 		rxmode->security = 0;
 }
 
+const char *
+rte_eth_dev_rx_offload_name(uint64_t offload)
+{
+	const char *name = "UNKNOWN";
+	unsigned int i;
+
+	for (i = 0; i < RTE_DIM(rte_rx_offload_names); ++i) {
+		if (offload == rte_rx_offload_names[i].offload) {
+			name = rte_rx_offload_names[i].name;
+			break;
+		}
+	}
+
+	return name;
+}
+
 int
 rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		      const struct rte_eth_conf *dev_conf)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index a5ba564..f37a5b8 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -946,6 +946,11 @@ struct rte_eth_conf {
 			     DEV_RX_OFFLOAD_VLAN_FILTER | \
 			     DEV_RX_OFFLOAD_VLAN_EXTEND)
 
+/*
+ * If new Rx offload capabilities are defined, they also must be
+ * mentioned in rte_rx_offload_names in rte_ethdev.c file.
+ */
+
 /**
  * TX offload capabilities of a device.
  */
@@ -1923,6 +1928,19 @@ int rte_eth_dev_detach(uint16_t port_id, char *devname);
 uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
 
 /**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get DEV_RX_OFFLOAD_* flag name.
+ *
+ * @param offload
+ *   Offload flag.
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
+ */
+const char *rte_eth_dev_rx_offload_name(uint64_t offload);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in the
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index e9681ac..83a9926 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -201,6 +201,7 @@ DPDK_17.11 {
 EXPERIMENTAL {
 	global:
 
+	rte_eth_dev_rx_offload_name;
 	rte_mtr_capabilities_get;
 	rte_mtr_create;
 	rte_mtr_destroy;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v4 2/6] ethdev: add a function to look up Tx offload names
  2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
@ 2018-01-18  9:44   ` Andrew Rybchenko
  2018-01-18 10:30     ` Thomas Monjalon
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
                     ` (4 subsequent siblings)
  6 siblings, 1 reply; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  9:44 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Thomas Monjalon, Ferruh Yigit, Shahaf Shuler

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Commonly, drivers converted to the new offload API
may need to log unsupported offloads as a response
to wrong settings. From this perspective, it would
be convenient to have generic functions to look up
offload names. The patch adds such a helper for Tx.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Cc: Thomas Monjalon <thomas@monjalon.net>
Cc: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: Shahaf Shuler <shahafs@mellanox.com>
---
 lib/librte_ether/rte_ethdev.c           | 45 +++++++++++++++++++++++++++++++++
 lib/librte_ether/rte_ethdev.h           | 18 +++++++++++++
 lib/librte_ether/rte_ethdev_version.map |  1 +
 3 files changed, 64 insertions(+)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 9e9ef83..cd4a3ed 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -116,6 +116,35 @@ static const struct {
 
 #undef RTE_RX_OFFLOAD_BIT2STR
 
+#define RTE_TX_OFFLOAD_BIT2STR(_name)	\
+	{ DEV_TX_OFFLOAD_##_name, #_name }
+
+static const struct {
+	uint64_t offload;
+	const char *name;
+} rte_tx_offload_names[] = {
+	RTE_TX_OFFLOAD_BIT2STR(VLAN_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(IPV4_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(UDP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(TCP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(SCTP_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(TCP_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(UDP_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(OUTER_IPV4_CKSUM),
+	RTE_TX_OFFLOAD_BIT2STR(QINQ_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(VXLAN_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(GRE_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(IPIP_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(GENEVE_TNL_TSO),
+	RTE_TX_OFFLOAD_BIT2STR(MACSEC_INSERT),
+	RTE_TX_OFFLOAD_BIT2STR(MT_LOCKFREE),
+	RTE_TX_OFFLOAD_BIT2STR(MULTI_SEGS),
+	RTE_TX_OFFLOAD_BIT2STR(MBUF_FAST_FREE),
+	RTE_TX_OFFLOAD_BIT2STR(SECURITY),
+};
+
+#undef RTE_TX_OFFLOAD_BIT2STR
+
 /**
  * The user application callback description.
  *
@@ -788,6 +817,22 @@ rte_eth_dev_rx_offload_name(uint64_t offload)
 	return name;
 }
 
+const char *
+rte_eth_dev_tx_offload_name(uint64_t offload)
+{
+	const char *name = "UNKNOWN";
+	unsigned int i;
+
+	for (i = 0; i < RTE_DIM(rte_tx_offload_names); ++i) {
+		if (offload == rte_tx_offload_names[i].offload) {
+			name = rte_tx_offload_names[i].name;
+			break;
+		}
+	}
+
+	return name;
+}
+
 int
 rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		      const struct rte_eth_conf *dev_conf)
diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h
index f37a5b8..8f26f50 100644
--- a/lib/librte_ether/rte_ethdev.h
+++ b/lib/librte_ether/rte_ethdev.h
@@ -981,6 +981,11 @@ struct rte_eth_conf {
  */
 #define DEV_TX_OFFLOAD_SECURITY         0x00020000
 
+/*
+ * If new Tx offload capabilities are defined, they also must be
+ * mentioned in rte_tx_offload_names in rte_ethdev.c file.
+ */
+
 struct rte_pci_device;
 
 /**
@@ -1941,6 +1946,19 @@ uint32_t rte_eth_speed_bitflag(uint32_t speed, int duplex);
 const char *rte_eth_dev_rx_offload_name(uint64_t offload);
 
 /**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice
+ *
+ * Get DEV_TX_OFFLOAD_* flag name.
+ *
+ * @param offload
+ *   Offload flag.
+ * @return
+ *   Offload name or 'UNKNOWN' if the flag cannot be recognised.
+ */
+const char *rte_eth_dev_tx_offload_name(uint64_t offload);
+
+/**
  * Configure an Ethernet device.
  * This function must be invoked first before any other function in the
  * Ethernet API. This function can also be re-invoked when a device is in the
diff --git a/lib/librte_ether/rte_ethdev_version.map b/lib/librte_ether/rte_ethdev_version.map
index 83a9926..4e166a7 100644
--- a/lib/librte_ether/rte_ethdev_version.map
+++ b/lib/librte_ether/rte_ethdev_version.map
@@ -202,6 +202,7 @@ EXPERIMENTAL {
 	global:
 
 	rte_eth_dev_rx_offload_name;
+	rte_eth_dev_tx_offload_name;
 	rte_mtr_capabilities_get;
 	rte_mtr_create;
 	rte_mtr_destroy;
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v4 3/6] net/sfc: factor out function to report Rx capabilities
  2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
@ 2018-01-18  9:44   ` Andrew Rybchenko
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  9:44 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

The patch adds a separate function to report supported
Rx capabilities because this function will be required
in more places across the code in the upcoming patches.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/sfc/sfc_ethdev.c |  9 +--------
 drivers/net/sfc/sfc_rx.c     | 17 +++++++++++++++++
 drivers/net/sfc/sfc_rx.h     |  2 ++
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index af867a7..851b38b 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -104,14 +104,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* By default packets are dropped if no descriptors are available */
 	dev_info->default_rxconf.rx_drop_en = 1;
 
-	dev_info->rx_offload_capa =
-		DEV_RX_OFFLOAD_IPV4_CKSUM |
-		DEV_RX_OFFLOAD_UDP_CKSUM |
-		DEV_RX_OFFLOAD_TCP_CKSUM;
-
-	if ((encp->enc_tunnel_encapsulations_supported != 0) &&
-	    (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
-		dev_info->rx_offload_capa |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa);
 
 	dev_info->tx_offload_capa =
 		DEV_TX_OFFLOAD_IPV4_CKSUM |
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index 6fa56b4..d35f4f7 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -762,6 +762,23 @@ sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index)
 	sfc_ev_qstop(rxq->evq);
 }
 
+uint64_t
+sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
+	caps |= DEV_RX_OFFLOAD_IPV4_CKSUM;
+	caps |= DEV_RX_OFFLOAD_UDP_CKSUM;
+	caps |= DEV_RX_OFFLOAD_TCP_CKSUM;
+
+	if (encp->enc_tunnel_encapsulations_supported &&
+	    (sa->dp_rx->features & SFC_DP_RX_FEAT_TUNNELS))
+		caps |= DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+	return caps;
+}
+
 static int
 sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		   const struct rte_eth_rxconf *rx_conf)
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index 2cf75bc..cc9245f 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -142,6 +142,8 @@ void sfc_rx_qfini(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 
+uint64_t sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa);
+
 void sfc_rx_qflush_done(struct sfc_rxq *rxq);
 void sfc_rx_qflush_failed(struct sfc_rxq *rxq);
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v4 4/6] net/sfc: convert to the new Rx offload API
  2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
                     ` (2 preceding siblings ...)
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
@ 2018-01-18  9:44   ` Andrew Rybchenko
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  9:44 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

Ethdev Rx offloads API has changed since:
commit ce17eddefc20 ("ethdev: introduce Rx queue offloads API")
This commit support the new Rx offloads API.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/sfc/sfc_ethdev.c |  27 +++++++++--
 drivers/net/sfc/sfc_port.c   |   5 +-
 drivers/net/sfc/sfc_rx.c     | 111 +++++++++++++++++++++++++++++--------------
 drivers/net/sfc/sfc_rx.h     |   1 +
 4 files changed, 103 insertions(+), 41 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 851b38b..0244a0f 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -104,7 +104,15 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	/* By default packets are dropped if no descriptors are available */
 	dev_info->default_rxconf.rx_drop_en = 1;
 
-	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa);
+	dev_info->rx_queue_offload_capa = sfc_rx_get_queue_offload_caps(sa);
+
+	/*
+	 * rx_offload_capa includes both device and queue offloads since
+	 * the latter may be requested on a per device basis which makes
+	 * sense when some offloads are needed to be set on all queues.
+	 */
+	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
+				    dev_info->rx_queue_offload_capa;
 
 	dev_info->tx_offload_capa =
 		DEV_TX_OFFLOAD_IPV4_CKSUM |
@@ -882,7 +890,13 @@ sfc_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
 	 * The driver does not use it, but other PMDs update jumbo_frame
 	 * flag and max_rx_pkt_len when MTU is set.
 	 */
-	dev->data->dev_conf.rxmode.jumbo_frame = (mtu > ETHER_MAX_LEN);
+	if (mtu > ETHER_MAX_LEN) {
+		struct rte_eth_rxmode *rxmode = &dev->data->dev_conf.rxmode;
+
+		rxmode->offloads |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+		rxmode->jumbo_frame = 1;
+	}
+
 	dev->data->dev_conf.rxmode.max_rx_pkt_len = sa->port.pdu;
 
 	sfc_adapter_unlock(sa);
@@ -1045,8 +1059,13 @@ sfc_rx_queue_info_get(struct rte_eth_dev *dev, uint16_t rx_queue_id,
 	qinfo->conf.rx_free_thresh = rxq->refill_threshold;
 	qinfo->conf.rx_drop_en = 1;
 	qinfo->conf.rx_deferred_start = rxq_info->deferred_start;
-	qinfo->scattered_rx =
-		((rxq_info->type_flags & EFX_RXQ_FLAG_SCATTER) != 0);
+	qinfo->conf.offloads = DEV_RX_OFFLOAD_IPV4_CKSUM |
+			       DEV_RX_OFFLOAD_UDP_CKSUM |
+			       DEV_RX_OFFLOAD_TCP_CKSUM;
+	if (rxq_info->type_flags & EFX_RXQ_FLAG_SCATTER) {
+		qinfo->conf.offloads |= DEV_RX_OFFLOAD_SCATTER;
+		qinfo->scattered_rx = 1;
+	}
 	qinfo->nb_desc = rxq_info->entries;
 
 	sfc_adapter_unlock(sa);
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index a48388d..c423f52 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -299,11 +299,12 @@ sfc_port_configure(struct sfc_adapter *sa)
 {
 	const struct rte_eth_dev_data *dev_data = sa->eth_dev->data;
 	struct sfc_port *port = &sa->port;
+	const struct rte_eth_rxmode *rxmode = &dev_data->dev_conf.rxmode;
 
 	sfc_log_init(sa, "entry");
 
-	if (dev_data->dev_conf.rxmode.jumbo_frame)
-		port->pdu = dev_data->dev_conf.rxmode.max_rx_pkt_len;
+	if (rxmode->offloads & DEV_RX_OFFLOAD_JUMBO_FRAME)
+		port->pdu = rxmode->max_rx_pkt_len;
 	else
 		port->pdu = EFX_MAC_PDU(dev_data->mtu);
 
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index d35f4f7..abc53fb 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -768,6 +768,8 @@ sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	uint64_t caps = 0;
 
+	caps |= DEV_RX_OFFLOAD_JUMBO_FRAME;
+	caps |= DEV_RX_OFFLOAD_CRC_STRIP;
 	caps |= DEV_RX_OFFLOAD_IPV4_CKSUM;
 	caps |= DEV_RX_OFFLOAD_UDP_CKSUM;
 	caps |= DEV_RX_OFFLOAD_TCP_CKSUM;
@@ -779,10 +781,62 @@ sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa)
 	return caps;
 }
 
+uint64_t
+sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa)
+{
+	uint64_t caps = 0;
+
+	if (sa->dp_rx->features & SFC_DP_RX_FEAT_SCATTER)
+		caps |= DEV_RX_OFFLOAD_SCATTER;
+
+	return caps;
+}
+
+static void
+sfc_rx_log_offloads(struct sfc_adapter *sa, const char *offload_group,
+		    const char *verdict, uint64_t offloads)
+{
+	unsigned long long bit;
+
+	while ((bit = __builtin_ffsll(offloads)) != 0) {
+		uint64_t flag = (1ULL << --bit);
+
+		sfc_err(sa, "Rx %s offload %s %s", offload_group,
+			rte_eth_dev_rx_offload_name(flag), verdict);
+
+		offloads &= ~flag;
+	}
+}
+
+static boolean_t
+sfc_rx_queue_offloads_mismatch(struct sfc_adapter *sa, uint64_t requested)
+{
+	uint64_t mandatory = sa->eth_dev->data->dev_conf.rxmode.offloads;
+	uint64_t supported = sfc_rx_get_dev_offload_caps(sa) |
+			     sfc_rx_get_queue_offload_caps(sa);
+	uint64_t rejected = requested & ~supported;
+	uint64_t missing = (requested & mandatory) ^ mandatory;
+	boolean_t mismatch = B_FALSE;
+
+	if (rejected) {
+		sfc_rx_log_offloads(sa, "queue", "is unsupported", rejected);
+		mismatch = B_TRUE;
+	}
+
+	if (missing) {
+		sfc_rx_log_offloads(sa, "queue", "must be set", missing);
+		mismatch = B_TRUE;
+	}
+
+	return mismatch;
+}
+
 static int
 sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		   const struct rte_eth_rxconf *rx_conf)
 {
+	uint64_t offloads_supported = sfc_rx_get_dev_offload_caps(sa) |
+				      sfc_rx_get_queue_offload_caps(sa);
 	int rc = 0;
 
 	if (rx_conf->rx_thresh.pthresh != 0 ||
@@ -804,6 +858,17 @@ sfc_rx_qcheck_conf(struct sfc_adapter *sa, unsigned int rxq_max_fill_level,
 		rc = EINVAL;
 	}
 
+	if ((rx_conf->offloads & DEV_RX_OFFLOAD_CHECKSUM) !=
+	    DEV_RX_OFFLOAD_CHECKSUM)
+		sfc_warn(sa, "Rx checksum offloads cannot be disabled - always on (IPv4/TCP/UDP)");
+
+	if ((offloads_supported & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM) &&
+	    (~rx_conf->offloads & DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM))
+		sfc_warn(sa, "Rx outer IPv4 checksum offload cannot be disabled - always on");
+
+	if (sfc_rx_queue_offloads_mismatch(sa, rx_conf->offloads))
+		rc = EINVAL;
+
 	return rc;
 }
 
@@ -946,7 +1011,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	}
 
 	if ((buf_size < sa->port.pdu + encp->enc_rx_prefix_size) &&
-	    !sa->eth_dev->data->dev_conf.rxmode.enable_scatter) {
+	    (~rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER)) {
 		sfc_err(sa, "Rx scatter is disabled and RxQ %u mbuf pool "
 			"object size is too small", sw_index);
 		sfc_err(sa, "RxQ %u calculated Rx buffer size is %u vs "
@@ -964,7 +1029,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	rxq_info->entries = rxq_entries;
 	rxq_info->type = EFX_RXQ_TYPE_DEFAULT;
 	rxq_info->type_flags =
-		sa->eth_dev->data->dev_conf.rxmode.enable_scatter ?
+		(rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER) ?
 		EFX_RXQ_FLAG_SCATTER : EFX_RXQ_FLAG_NONE;
 
 	if ((encp->enc_tunnel_encapsulations_supported != 0) &&
@@ -1227,6 +1292,9 @@ sfc_rx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
 static int
 sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 {
+	uint64_t offloads_supported = sfc_rx_get_dev_offload_caps(sa) |
+				      sfc_rx_get_queue_offload_caps(sa);
+	uint64_t offloads_rejected = rxmode->offloads & ~offloads_supported;
 	int rc = 0;
 
 	switch (rxmode->mq_mode) {
@@ -1247,45 +1315,18 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 		rc = EINVAL;
 	}
 
-	if (rxmode->header_split) {
-		sfc_err(sa, "Header split on Rx not supported");
-		rc = EINVAL;
-	}
-
-	if (rxmode->hw_vlan_filter) {
-		sfc_err(sa, "HW VLAN filtering not supported");
-		rc = EINVAL;
-	}
-
-	if (rxmode->hw_vlan_strip) {
-		sfc_err(sa, "HW VLAN stripping not supported");
+	if (offloads_rejected) {
+		sfc_rx_log_offloads(sa, "device", "is unsupported",
+				    offloads_rejected);
 		rc = EINVAL;
 	}
 
-	if (rxmode->hw_vlan_extend) {
-		sfc_err(sa,
-			"Q-in-Q HW VLAN stripping not supported");
-		rc = EINVAL;
-	}
-
-	if (!rxmode->hw_strip_crc) {
-		sfc_warn(sa,
-			 "FCS stripping control not supported - always stripped");
+	if (~rxmode->offloads & DEV_RX_OFFLOAD_CRC_STRIP) {
+		sfc_warn(sa, "FCS stripping cannot be disabled - always on");
+		rxmode->offloads |= DEV_RX_OFFLOAD_CRC_STRIP;
 		rxmode->hw_strip_crc = 1;
 	}
 
-	if (rxmode->enable_scatter &&
-	    (~sa->dp_rx->features & SFC_DP_RX_FEAT_SCATTER)) {
-		sfc_err(sa, "Rx scatter not supported by %s datapath",
-			sa->dp_rx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (rxmode->enable_lro) {
-		sfc_err(sa, "LRO not supported");
-		rc = EINVAL;
-	}
-
 	return rc;
 }
 
diff --git a/drivers/net/sfc/sfc_rx.h b/drivers/net/sfc/sfc_rx.h
index cc9245f..8c0fa71 100644
--- a/drivers/net/sfc/sfc_rx.h
+++ b/drivers/net/sfc/sfc_rx.h
@@ -143,6 +143,7 @@ int sfc_rx_qstart(struct sfc_adapter *sa, unsigned int sw_index);
 void sfc_rx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 
 uint64_t sfc_rx_get_dev_offload_caps(struct sfc_adapter *sa);
+uint64_t sfc_rx_get_queue_offload_caps(struct sfc_adapter *sa);
 
 void sfc_rx_qflush_done(struct sfc_rxq *rxq);
 void sfc_rx_qflush_failed(struct sfc_rxq *rxq);
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v4 5/6] net/sfc: factor out function to report Tx capabilities
  2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
                     ` (3 preceding siblings ...)
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
@ 2018-01-18  9:44   ` Andrew Rybchenko
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
  2018-01-18 15:40   ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Ferruh Yigit
  6 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  9:44 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

The patch adds a separate function to report supported
Tx capabilities because this function will be required
in more places across the code in the upcoming patches.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/sfc/sfc_ethdev.c | 13 +------------
 drivers/net/sfc/sfc_tx.c     | 23 +++++++++++++++++++++++
 drivers/net/sfc/sfc_tx.h     |  2 ++
 3 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 0244a0f..0fe9bf5 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -114,20 +114,12 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
 				    dev_info->rx_queue_offload_capa;
 
-	dev_info->tx_offload_capa =
-		DEV_TX_OFFLOAD_IPV4_CKSUM |
-		DEV_TX_OFFLOAD_UDP_CKSUM |
-		DEV_TX_OFFLOAD_TCP_CKSUM;
-
-	if (encp->enc_tunnel_encapsulations_supported != 0)
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa);
 
 	dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
 	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
 	    !encp->enc_hw_tx_insert_vlan_enabled)
 		dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOVLANOFFL;
-	else
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_VLAN_INSERT;
 
 	if (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)
 		dev_info->default_txconf.txq_flags |= ETH_TXQ_FLAGS_NOMULTSEGS;
@@ -146,9 +138,6 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	}
 #endif
 
-	if (sa->tso)
-		dev_info->tx_offload_capa |= DEV_TX_OFFLOAD_TCP_TSO;
-
 	/* Initialize to hardware limits */
 	dev_info->rx_desc_lim.nb_max = EFX_RXQ_MAXNDESCS;
 	dev_info->rx_desc_lim.nb_min = EFX_RXQ_MINNDESCS;
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index ee22049..7504037 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -34,6 +34,29 @@
  */
 #define SFC_TX_QFLUSH_POLL_ATTEMPTS	(2000)
 
+uint64_t
+sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
+	caps |= DEV_TX_OFFLOAD_IPV4_CKSUM;
+	caps |= DEV_TX_OFFLOAD_UDP_CKSUM;
+	caps |= DEV_TX_OFFLOAD_TCP_CKSUM;
+
+	if (encp->enc_tunnel_encapsulations_supported)
+		caps |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
+
+	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
+	    encp->enc_hw_tx_insert_vlan_enabled)
+		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
+
+	if (sa->tso)
+		caps |= DEV_TX_OFFLOAD_TCP_TSO;
+
+	return caps;
+}
+
 static int
 sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 		   const struct rte_eth_txconf *tx_conf)
diff --git a/drivers/net/sfc/sfc_tx.h b/drivers/net/sfc/sfc_tx.h
index c2b889f..fc9a9f7 100644
--- a/drivers/net/sfc/sfc_tx.h
+++ b/drivers/net/sfc/sfc_tx.h
@@ -129,6 +129,8 @@ void sfc_tx_qstop(struct sfc_adapter *sa, unsigned int sw_index);
 int sfc_tx_start(struct sfc_adapter *sa);
 void sfc_tx_stop(struct sfc_adapter *sa);
 
+uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
+
 /* From 'sfc_tso.c' */
 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
 				unsigned int txq_entries,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* [dpdk-dev] [PATCH v4 6/6] net/sfc: convert to the new Tx offload API
  2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
                     ` (4 preceding siblings ...)
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
@ 2018-01-18  9:44   ` Andrew Rybchenko
  2018-01-18 15:40   ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Ferruh Yigit
  6 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  9:44 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov

From: Ivan Malov <ivan.malov@oktetlabs.ru>

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

The code which fills in txq_flags in default_txconf is preserved
because rte_eth_dev_info_get() lacks conversion between offloads
and txq_flags fields which means that a legacy application which
relies on default_txconf will fail to configure Tx queues in the
case when some bits in txq_flags are mandatory.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 drivers/net/sfc/sfc_dp_tx.h  |   2 +
 drivers/net/sfc/sfc_ethdev.c |  17 +++-
 drivers/net/sfc/sfc_tx.c     | 179 +++++++++++++++++++++++++++----------------
 drivers/net/sfc/sfc_tx.h     |   2 +
 4 files changed, 131 insertions(+), 69 deletions(-)

diff --git a/drivers/net/sfc/sfc_dp_tx.h b/drivers/net/sfc/sfc_dp_tx.h
index f400755..75d72fe 100644
--- a/drivers/net/sfc/sfc_dp_tx.h
+++ b/drivers/net/sfc/sfc_dp_tx.h
@@ -41,6 +41,8 @@ struct sfc_dp_tx_qcreate_info {
 	unsigned int		free_thresh;
 	/** Transmit queue configuration flags */
 	unsigned int		flags;
+	/** Offloads enabled on the transmit queue */
+	uint64_t		offloads;
 	/** Tx queue size */
 	unsigned int		txq_entries;
 	/** Maximum size of data in the DMA descriptor */
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 0fe9bf5..a86cff6 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -83,6 +83,7 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 {
 	struct sfc_adapter *sa = dev->data->dev_private;
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t txq_offloads_def = 0;
 
 	sfc_log_init(sa, "entry");
 
@@ -114,7 +115,20 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 	dev_info->rx_offload_capa = sfc_rx_get_dev_offload_caps(sa) |
 				    dev_info->rx_queue_offload_capa;
 
-	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa);
+	dev_info->tx_queue_offload_capa = sfc_tx_get_queue_offload_caps(sa);
+
+	/*
+	 * tx_offload_capa includes both device and queue offloads since
+	 * the latter may be requested on a per device basis which makes
+	 * sense when some offloads are needed to be set on all queues.
+	 */
+	dev_info->tx_offload_capa = sfc_tx_get_dev_offload_caps(sa) |
+				    dev_info->tx_queue_offload_capa;
+
+	if (dev_info->tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
+		txq_offloads_def |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	dev_info->default_txconf.offloads |= txq_offloads_def;
 
 	dev_info->default_txconf.txq_flags = ETH_TXQ_FLAGS_NOXSUMSCTP;
 	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) ||
@@ -1081,6 +1095,7 @@ sfc_tx_queue_info_get(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 	memset(qinfo, 0, sizeof(*qinfo));
 
 	qinfo->conf.txq_flags = txq_info->txq->flags;
+	qinfo->conf.offloads = txq_info->txq->offloads;
 	qinfo->conf.tx_free_thresh = txq_info->txq->free_thresh;
 	qinfo->conf.tx_deferred_start = txq_info->deferred_start;
 	qinfo->nb_desc = txq_info->entries;
diff --git a/drivers/net/sfc/sfc_tx.c b/drivers/net/sfc/sfc_tx.c
index 7504037..757b03b 100644
--- a/drivers/net/sfc/sfc_tx.c
+++ b/drivers/net/sfc/sfc_tx.c
@@ -40,6 +40,26 @@ sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	uint64_t caps = 0;
 
+	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
+	    encp->enc_hw_tx_insert_vlan_enabled)
+		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
+
+	if (sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)
+		caps |= DEV_TX_OFFLOAD_MULTI_SEGS;
+
+	if ((~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_POOL) &&
+	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_REFCNT))
+		caps |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+	return caps;
+}
+
+uint64_t
+sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa)
+{
+	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t caps = 0;
+
 	caps |= DEV_TX_OFFLOAD_IPV4_CKSUM;
 	caps |= DEV_TX_OFFLOAD_UDP_CKSUM;
 	caps |= DEV_TX_OFFLOAD_TCP_CKSUM;
@@ -47,22 +67,55 @@ sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa)
 	if (encp->enc_tunnel_encapsulations_supported)
 		caps |= DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
 
-	if ((sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) &&
-	    encp->enc_hw_tx_insert_vlan_enabled)
-		caps |= DEV_TX_OFFLOAD_VLAN_INSERT;
-
 	if (sa->tso)
 		caps |= DEV_TX_OFFLOAD_TCP_TSO;
 
 	return caps;
 }
 
+static void
+sfc_tx_log_offloads(struct sfc_adapter *sa, const char *offload_group,
+		    const char *verdict, uint64_t offloads)
+{
+	unsigned long long bit;
+
+	while ((bit = __builtin_ffsll(offloads)) != 0) {
+		uint64_t flag = (1ULL << --bit);
+
+		sfc_err(sa, "Tx %s offload %s %s", offload_group,
+			rte_eth_dev_tx_offload_name(flag), verdict);
+
+		offloads &= ~flag;
+	}
+}
+
+static int
+sfc_tx_queue_offload_mismatch(struct sfc_adapter *sa, uint64_t requested)
+{
+	uint64_t mandatory = sa->eth_dev->data->dev_conf.txmode.offloads;
+	uint64_t supported = sfc_tx_get_dev_offload_caps(sa) |
+			     sfc_tx_get_queue_offload_caps(sa);
+	uint64_t rejected = requested & ~supported;
+	uint64_t missing = (requested & mandatory) ^ mandatory;
+	boolean_t mismatch = B_FALSE;
+
+	if (rejected) {
+		sfc_tx_log_offloads(sa, "queue", "is unsupported", rejected);
+		mismatch = B_TRUE;
+	}
+
+	if (missing) {
+		sfc_tx_log_offloads(sa, "queue", "must be set", missing);
+		mismatch = B_TRUE;
+	}
+
+	return mismatch;
+}
+
 static int
 sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 		   const struct rte_eth_txconf *tx_conf)
 {
-	unsigned int flags = tx_conf->txq_flags;
-	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
 	int rc = 0;
 
 	if (tx_conf->tx_rs_thresh != 0) {
@@ -84,52 +137,16 @@ sfc_tx_qcheck_conf(struct sfc_adapter *sa, unsigned int txq_max_fill_level,
 			"prefetch/host/writeback thresholds are not supported");
 	}
 
-	if (((flags & ETH_TXQ_FLAGS_NOMULTSEGS) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_SEG)) {
-		sfc_err(sa, "Multi-segment is not supported by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (((flags & ETH_TXQ_FLAGS_NOMULTMEMP) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_MULTI_POOL)) {
-		sfc_err(sa, "multi-mempool is not supported by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if (((flags & ETH_TXQ_FLAGS_NOREFCOUNT) == 0) &&
-	    (~sa->dp_tx->features & SFC_DP_TX_FEAT_REFCNT)) {
-		sfc_err(sa,
-			"mbuf reference counters are neglected by %s datapath",
-			sa->dp_tx->dp.name);
-		rc = EINVAL;
-	}
-
-	if ((flags & ETH_TXQ_FLAGS_NOVLANOFFL) == 0) {
-		if (!encp->enc_hw_tx_insert_vlan_enabled) {
-			sfc_err(sa, "VLAN offload is not supported");
-			rc = EINVAL;
-		} else if (~sa->dp_tx->features & SFC_DP_TX_FEAT_VLAN_INSERT) {
-			sfc_err(sa,
-				"VLAN offload is not supported by %s datapath",
-				sa->dp_tx->dp.name);
-			rc = EINVAL;
-		}
-	}
-
-	if ((flags & ETH_TXQ_FLAGS_NOXSUMSCTP) == 0) {
-		sfc_err(sa, "SCTP offload is not supported");
-		rc = EINVAL;
-	}
-
 	/* We either perform both TCP and UDP offload, or no offload at all */
-	if (((flags & ETH_TXQ_FLAGS_NOXSUMTCP) == 0) !=
-	    ((flags & ETH_TXQ_FLAGS_NOXSUMUDP) == 0)) {
+	if (((tx_conf->offloads & DEV_TX_OFFLOAD_TCP_CKSUM) == 0) !=
+	    ((tx_conf->offloads & DEV_TX_OFFLOAD_UDP_CKSUM) == 0)) {
 		sfc_err(sa, "TCP and UDP offloads can't be set independently");
 		rc = EINVAL;
 	}
 
+	if (sfc_tx_queue_offload_mismatch(sa, tx_conf->offloads))
+		rc = EINVAL;
+
 	return rc;
 }
 
@@ -193,6 +210,7 @@ sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 		(tx_conf->tx_free_thresh) ? tx_conf->tx_free_thresh :
 		SFC_TX_DEFAULT_FREE_THRESH;
 	txq->flags = tx_conf->txq_flags;
+	txq->offloads = tx_conf->offloads;
 
 	rc = sfc_dma_alloc(sa, "txq", sw_index, EFX_TXQ_SIZE(txq_info->entries),
 			   socket_id, &txq->mem);
@@ -203,6 +221,7 @@ sfc_tx_qinit(struct sfc_adapter *sa, unsigned int sw_index,
 	info.max_fill_level = txq_max_fill_level;
 	info.free_thresh = txq->free_thresh;
 	info.flags = tx_conf->txq_flags;
+	info.offloads = tx_conf->offloads;
 	info.txq_entries = txq_info->entries;
 	info.dma_desc_size_max = encp->enc_tx_dma_desc_size_max;
 	info.txq_hw_ring = txq->mem.esm_base;
@@ -284,6 +303,9 @@ sfc_tx_qinit_info(struct sfc_adapter *sa, unsigned int sw_index)
 static int
 sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
 {
+	uint64_t offloads_supported = sfc_tx_get_dev_offload_caps(sa) |
+				      sfc_tx_get_queue_offload_caps(sa);
+	uint64_t offloads_rejected = txmode->offloads & ~offloads_supported;
 	int rc = 0;
 
 	switch (txmode->mq_mode) {
@@ -314,6 +336,12 @@ sfc_tx_check_mode(struct sfc_adapter *sa, const struct rte_eth_txmode *txmode)
 		rc = EINVAL;
 	}
 
+	if (offloads_rejected) {
+		sfc_tx_log_offloads(sa, "device", "is unsupported",
+				    offloads_rejected);
+		rc = EINVAL;
+	}
+
 	return rc;
 }
 
@@ -424,12 +452,13 @@ sfc_tx_close(struct sfc_adapter *sa)
 int
 sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
 {
-	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint64_t offloads_supported = sfc_tx_get_dev_offload_caps(sa) |
+				      sfc_tx_get_queue_offload_caps(sa);
 	struct rte_eth_dev_data *dev_data;
 	struct sfc_txq_info *txq_info;
 	struct sfc_txq *txq;
 	struct sfc_evq *evq;
-	uint16_t flags;
+	uint16_t flags = 0;
 	unsigned int desc_index;
 	int rc = 0;
 
@@ -449,26 +478,40 @@ sfc_tx_qstart(struct sfc_adapter *sa, unsigned int sw_index)
 		goto fail_ev_qstart;
 
 	/*
-	 * It seems that DPDK has no controls regarding IPv4 offloads,
-	 * hence, we always enable it here
+	 * The absence of ETH_TXQ_FLAGS_IGNORE is associated with a legacy
+	 * application which expects that IPv4 checksum offload is enabled
+	 * all the time as there is no legacy flag to turn off the offload.
 	 */
-	if ((txq->flags & ETH_TXQ_FLAGS_NOXSUMTCP) ||
-	    (txq->flags & ETH_TXQ_FLAGS_NOXSUMUDP)) {
-		flags = EFX_TXQ_CKSUM_IPV4;
-
-		if (encp->enc_tunnel_encapsulations_supported != 0)
-			flags |= EFX_TXQ_CKSUM_INNER_IPV4;
-	} else {
-		flags = EFX_TXQ_CKSUM_IPV4 | EFX_TXQ_CKSUM_TCPUDP;
-
-		if (encp->enc_tunnel_encapsulations_supported != 0)
-			flags |= EFX_TXQ_CKSUM_INNER_IPV4 |
-				 EFX_TXQ_CKSUM_INNER_TCPUDP;
-
-		if (sa->tso)
-			flags |= EFX_TXQ_FATSOV2;
+	if ((txq->offloads & DEV_TX_OFFLOAD_IPV4_CKSUM) ||
+	    (~txq->flags & ETH_TXQ_FLAGS_IGNORE))
+		flags |= EFX_TXQ_CKSUM_IPV4;
+
+	if ((txq->offloads & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM) ||
+	    ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+	     (offloads_supported & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM)))
+		flags |= EFX_TXQ_CKSUM_INNER_IPV4;
+
+	if ((txq->offloads & DEV_TX_OFFLOAD_TCP_CKSUM) ||
+	    (txq->offloads & DEV_TX_OFFLOAD_UDP_CKSUM)) {
+		flags |= EFX_TXQ_CKSUM_TCPUDP;
+
+		if ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+		    (offloads_supported & DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM))
+			flags |= EFX_TXQ_CKSUM_INNER_TCPUDP;
 	}
 
+	/*
+	 * The absence of ETH_TXQ_FLAGS_IGNORE is associated with a legacy
+	 * application. In turn, the absence of ETH_TXQ_FLAGS_NOXSUMTCP is
+	 * associated specifically with a legacy application which expects
+	 * both TCP checksum offload and TSO to be enabled because the legacy
+	 * API does not provide a dedicated mechanism to control TSO.
+	 */
+	if ((txq->offloads & DEV_TX_OFFLOAD_TCP_TSO) ||
+	    ((~txq->flags & ETH_TXQ_FLAGS_IGNORE) &&
+	     (~txq->flags & ETH_TXQ_FLAGS_NOXSUMTCP)))
+		flags |= EFX_TXQ_FATSOV2;
+
 	rc = efx_tx_qcreate(sa->nic, sw_index, 0, &txq->mem,
 			    txq_info->entries, 0 /* not used on EF10 */,
 			    flags, evq->common,
@@ -736,9 +779,9 @@ sfc_efx_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 		/*
 		 * Here VLAN TCI is expected to be zero in case if no
-		 * DEV_TX_VLAN_OFFLOAD capability is advertised;
+		 * DEV_TX_OFFLOAD_VLAN_INSERT capability is advertised;
 		 * if the calling app ignores the absence of
-		 * DEV_TX_VLAN_OFFLOAD and pushes VLAN TCI, then
+		 * DEV_TX_OFFLOAD_VLAN_INSERT and pushes VLAN TCI, then
 		 * TX_ERROR will occur
 		 */
 		pkt_descs += sfc_efx_tx_maybe_insert_tag(txq, m_seg, &pend);
diff --git a/drivers/net/sfc/sfc_tx.h b/drivers/net/sfc/sfc_tx.h
index fc9a9f7..e3c5d51 100644
--- a/drivers/net/sfc/sfc_tx.h
+++ b/drivers/net/sfc/sfc_tx.h
@@ -59,6 +59,7 @@ struct sfc_txq {
 	efx_txq_t			*common;
 	unsigned int			free_thresh;
 	unsigned int			flags;
+	uint64_t			offloads;
 };
 
 static inline unsigned int
@@ -130,6 +131,7 @@ int sfc_tx_start(struct sfc_adapter *sa);
 void sfc_tx_stop(struct sfc_adapter *sa);
 
 uint64_t sfc_tx_get_dev_offload_caps(struct sfc_adapter *sa);
+uint64_t sfc_tx_get_queue_offload_caps(struct sfc_adapter *sa);
 
 /* From 'sfc_tso.c' */
 int sfc_efx_tso_alloc_tsoh_objs(struct sfc_efx_tx_sw_desc *sw_ring,
-- 
2.7.4

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH v3 1/6] ethdev: add a function to look up Rx offload names
  2018-01-18  9:26     ` Thomas Monjalon
@ 2018-01-18  9:47       ` Andrew Rybchenko
  0 siblings, 0 replies; 41+ messages in thread
From: Andrew Rybchenko @ 2018-01-18  9:47 UTC (permalink / raw)
  To: Thomas Monjalon, Ivan Malov; +Cc: dev, Ferruh Yigit, Shahaf Shuler

On 01/18/2018 12:26 PM, Thomas Monjalon wrote:
> 18/01/2018 08:07, Andrew Rybchenko:
>> From: Ivan Malov <ivan.malov@oktetlabs.ru>
>> --- a/lib/librte_ether/rte_ethdev_version.map
>> +++ b/lib/librte_ether/rte_ethdev_version.map
>> @@ -213,5 +213,6 @@ EXPERIMENTAL {
>>   	rte_mtr_policer_actions_update;
>>   	rte_mtr_stats_read;
>>   	rte_mtr_stats_update;
>> +	rte_eth_dev_rx_offload_name;
>>   
>>   } DPDK_17.11;
> Please keep it in alphabetical order.

Lost it from my view, fixed in v4.

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH v4 1/6] ethdev: add a function to look up Rx offload names
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
@ 2018-01-18 10:29     ` Thomas Monjalon
  0 siblings, 0 replies; 41+ messages in thread
From: Thomas Monjalon @ 2018-01-18 10:29 UTC (permalink / raw)
  To: Andrew Rybchenko; +Cc: dev, Ivan Malov, Ferruh Yigit, Shahaf Shuler

18/01/2018 10:44, Andrew Rybchenko:
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
> 
> Commonly, drivers converted to the new offload API
> may need to log unsupported offloads as a response
> to wrong settings. From this perspective, it would
> be convenient to have generic functions to look up
> offload names. The patch adds such a helper for Rx.
> 
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Acked-by: Thomas Monjalon <thomas@monjalon.net>

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH v4 2/6] ethdev: add a function to look up Tx offload names
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
@ 2018-01-18 10:30     ` Thomas Monjalon
  0 siblings, 0 replies; 41+ messages in thread
From: Thomas Monjalon @ 2018-01-18 10:30 UTC (permalink / raw)
  To: Andrew Rybchenko, Ivan Malov; +Cc: dev, Ferruh Yigit, Shahaf Shuler

18/01/2018 10:44, Andrew Rybchenko:
> From: Ivan Malov <ivan.malov@oktetlabs.ru>
> 
> Commonly, drivers converted to the new offload API
> may need to log unsupported offloads as a response
> to wrong settings. From this perspective, it would
> be convenient to have generic functions to look up
> offload names. The patch adds such a helper for Tx.
> 
> Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Acked-by: Thomas Monjalon <thomas@monjalon.net>

^ permalink raw reply	[flat|nested] 41+ messages in thread

* Re: [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new offload API
  2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
                     ` (5 preceding siblings ...)
  2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
@ 2018-01-18 15:40   ` Ferruh Yigit
  6 siblings, 0 replies; 41+ messages in thread
From: Ferruh Yigit @ 2018-01-18 15:40 UTC (permalink / raw)
  To: Andrew Rybchenko, dev; +Cc: Thomas Monjalon, Shahaf Shuler

On 1/18/2018 9:44 AM, Andrew Rybchenko wrote:
> May be it is too late to suggest a new API functions to ethdev,
> but hopefully if the idea is accepted, it could be applied in the
> current release cycle since these functions are trivial.
> 
> I'm not sure that rte_ethdev_version.map is updated correctly
> since EXPERIMENTAL tag is present and I don't understand how it
> should be handled.
> 
> In general for the transition period from old offload API to the
> new one it would be useful to convert Tx offloads to/from txq_flags
> in rte_eth_dev_info_get() for default_txconf and
> rte_eth_tx_queue_info_get(). Unfortunately it was lost during
> new offload API patches review. However, it would require testing
> for all network PMDs and we decided to follow more conservative
> approach and kept code to fill in txq_flags which should be simply
> removed when txq_flags are removed.
> 
> Cc: Thomas Monjalon <thomas@monjalon.net>
> Cc: Ferruh Yigit <ferruh.yigit@intel.com>
> Cc: Shahaf Shuler <shahafs@mellanox.com>

Series applied to dpdk-next-net/master, thanks.

^ permalink raw reply	[flat|nested] 41+ messages in thread

end of thread, other threads:[~2018-01-18 15:40 UTC | newest]

Thread overview: 41+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-11  8:12 [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
2018-01-11  8:12 ` [dpdk-dev] [PATCH 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
2018-01-17 16:55   ` Ferruh Yigit
2018-01-17 17:06     ` Thomas Monjalon
2018-01-17 17:33   ` Thomas Monjalon
2018-01-18  6:32     ` Shahaf Shuler
2018-01-18  7:16     ` Andrew Rybchenko
2018-01-18  7:52       ` Andrew Rybchenko
2018-01-18  9:24         ` Thomas Monjalon
2018-01-11  8:12 ` [dpdk-dev] [PATCH 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
2018-01-11  8:12 ` [dpdk-dev] [PATCH 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
2018-01-11  8:12 ` [dpdk-dev] [PATCH 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
2018-01-11  8:12 ` [dpdk-dev] [PATCH 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
2018-01-11  8:12 ` [dpdk-dev] [PATCH 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
2018-01-17 16:55 ` [dpdk-dev] [PATCH 0/6] net/sfc: convert to the new " Ferruh Yigit
2018-01-18  7:02 ` [dpdk-dev] [PATCH v2 " Andrew Rybchenko
2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
2018-01-18  7:02   ` [dpdk-dev] [PATCH v2 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
2018-01-18  7:07 ` [dpdk-dev] [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
2018-01-18  9:26     ` Thomas Monjalon
2018-01-18  9:47       ` Andrew Rybchenko
2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
2018-01-18  7:07   ` [dpdk-dev] [PATCH v3 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
2018-01-18  9:44 ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
2018-01-18 10:29     ` Thomas Monjalon
2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
2018-01-18 10:30     ` Thomas Monjalon
2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
2018-01-18  9:44   ` [dpdk-dev] [PATCH v4 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
2018-01-18 15:40   ` [dpdk-dev] [PATCH v4 0/6] net/sfc: convert to the new " Ferruh Yigit

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).