All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Rybchenko <arybchenko@solarflare.com>
To: <dev@dpdk.org>
Cc: Ivan Malov <ivan.malov@oktetlabs.ru>
Subject: [PATCH v2 4/6] net/sfc: convert to the new Rx offload API
Date: Thu, 18 Jan 2018 07:02:29 +0000	[thread overview]
Message-ID: <1516258951-5897-5-git-send-email-arybchenko@solarflare.com> (raw)
In-Reply-To: <1516258951-5897-1-git-send-email-arybchenko@solarflare.com>

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

  parent reply	other threads:[~2018-01-18  7:02 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-11  8:12 [PATCH 0/6] net/sfc: convert to the new offload API Andrew Rybchenko
2018-01-11  8:12 ` [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 ` [PATCH 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
2018-01-11  8:12 ` [PATCH 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
2018-01-11  8:12 ` [PATCH 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
2018-01-11  8:12 ` [PATCH 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
2018-01-11  8:12 ` [PATCH 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
2018-01-17 16:55 ` [PATCH 0/6] net/sfc: convert to the new " Ferruh Yigit
2018-01-18  7:02 ` [PATCH v2 " Andrew Rybchenko
2018-01-18  7:02   ` [PATCH v2 1/6] ethdev: add a function to look up Rx offload names Andrew Rybchenko
2018-01-18  7:02   ` [PATCH v2 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
2018-01-18  7:02   ` [PATCH v2 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
2018-01-18  7:02   ` Andrew Rybchenko [this message]
2018-01-18  7:02   ` [PATCH v2 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
2018-01-18  7:02   ` [PATCH v2 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
2018-01-18  7:07 ` [PATCH v3 0/6] net/sfc: convert to the new " Andrew Rybchenko
2018-01-18  7:07   ` [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   ` [PATCH v3 2/6] ethdev: add a function to look up Tx " Andrew Rybchenko
2018-01-18  7:07   ` [PATCH v3 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
2018-01-18  7:07   ` [PATCH v3 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
2018-01-18  7:07   ` [PATCH v3 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
2018-01-18  7:07   ` [PATCH v3 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
2018-01-18  9:44 ` [PATCH v4 0/6] net/sfc: convert to the new " Andrew Rybchenko
2018-01-18  9:44   ` [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   ` [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   ` [PATCH v4 3/6] net/sfc: factor out function to report Rx capabilities Andrew Rybchenko
2018-01-18  9:44   ` [PATCH v4 4/6] net/sfc: convert to the new Rx offload API Andrew Rybchenko
2018-01-18  9:44   ` [PATCH v4 5/6] net/sfc: factor out function to report Tx capabilities Andrew Rybchenko
2018-01-18  9:44   ` [PATCH v4 6/6] net/sfc: convert to the new Tx offload API Andrew Rybchenko
2018-01-18 15:40   ` [PATCH v4 0/6] net/sfc: convert to the new " Ferruh Yigit

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=1516258951-5897-5-git-send-email-arybchenko@solarflare.com \
    --to=arybchenko@solarflare.com \
    --cc=dev@dpdk.org \
    --cc=ivan.malov@oktetlabs.ru \
    /path/to/YOUR_REPLY

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

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.