DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ivan Malov <ivan.malov@oktetlabs.ru>
To: dev@dpdk.org
Cc: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>,
	Andy Moreton <amoreton@xilinx.com>
Subject: [dpdk-dev] [PATCH 01/10] net/sfc: fence off 8 bits in Rx mark for tunnel offload
Date: Wed, 29 Sep 2021 23:57:21 +0300	[thread overview]
Message-ID: <20210929205730.775-2-ivan.malov@oktetlabs.ru> (raw)
In-Reply-To: <20210929205730.775-1-ivan.malov@oktetlabs.ru>

Later patches add support for tunnel offload on Riverhead (EF100).
A board can host at most 254 tunnels. Partially offloaded (missed)
tunnel packets are identified by virtue of 8 high bits in Rx mark.

Add basic definitions of the upcoming tunnel offload support and
take care of the dedicated bits in Rx mark across the driver.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/net/sfc/meson.build       |  1 +
 drivers/net/sfc/sfc_dp_rx.h       |  3 +++
 drivers/net/sfc/sfc_ef100_rx.c    | 14 ++++++++++--
 drivers/net/sfc/sfc_ethdev.c      |  4 ++++
 drivers/net/sfc/sfc_flow.c        |  8 ++++++-
 drivers/net/sfc/sfc_flow_tunnel.c | 29 +++++++++++++++++++++++
 drivers/net/sfc/sfc_flow_tunnel.h | 38 +++++++++++++++++++++++++++++++
 drivers/net/sfc/sfc_mae.c         |  6 +++++
 drivers/net/sfc/sfc_rx.c          | 10 +++++++-
 9 files changed, 109 insertions(+), 4 deletions(-)
 create mode 100644 drivers/net/sfc/sfc_flow_tunnel.c
 create mode 100644 drivers/net/sfc/sfc_flow_tunnel.h

diff --git a/drivers/net/sfc/meson.build b/drivers/net/sfc/meson.build
index 948c65968a..6a8ccd564b 100644
--- a/drivers/net/sfc/meson.build
+++ b/drivers/net/sfc/meson.build
@@ -90,6 +90,7 @@ sources = files(
         'sfc_mae.c',
         'sfc_mae_counter.c',
         'sfc_flow.c',
+	'sfc_flow_tunnel.c',
         'sfc_dp.c',
         'sfc_ef10_rx.c',
         'sfc_ef10_essb_rx.c',
diff --git a/drivers/net/sfc/sfc_dp_rx.h b/drivers/net/sfc/sfc_dp_rx.h
index b6c44085ce..1be301ced6 100644
--- a/drivers/net/sfc/sfc_dp_rx.h
+++ b/drivers/net/sfc/sfc_dp_rx.h
@@ -92,6 +92,9 @@ struct sfc_dp_rx_qcreate_info {
 	efsys_dma_addr_t	fcw_offset;
 	/** VI window size shift */
 	unsigned int		vi_window_shift;
+
+	/** Mask to extract user bits from Rx prefix mark field */
+	uint32_t		user_mark_mask;
 };
 
 /**
diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index 7d0d6b3d00..3219c972db 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -20,7 +20,9 @@
 #include "efx_regs_ef100.h"
 #include "efx.h"
 
+#include "sfc.h"
 #include "sfc_debug.h"
+#include "sfc_flow_tunnel.h"
 #include "sfc_tweak.h"
 #include "sfc_dp_rx.h"
 #include "sfc_kvargs.h"
@@ -74,6 +76,7 @@ struct sfc_ef100_rxq {
 	uint64_t			rearm_data;
 	uint16_t			buf_size;
 	uint16_t			prefix_size;
+	uint32_t			user_mark_mask;
 
 	unsigned int			evq_hw_index;
 	volatile void			*evq_prime;
@@ -420,10 +423,13 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
 
 	if (rxq->flags & SFC_EF100_RXQ_USER_MARK) {
 		uint32_t user_mark;
+		uint32_t mark;
 
 		/* EFX_OWORD_FIELD converts little-endian to CPU */
-		user_mark = EFX_OWORD_FIELD(rx_prefix[0],
-					    ESF_GZ_RX_PREFIX_USER_MARK);
+		mark = EFX_OWORD_FIELD(rx_prefix[0],
+				       ESF_GZ_RX_PREFIX_USER_MARK);
+
+		user_mark = mark & rxq->user_mark_mask;
 		if (user_mark != SFC_EF100_USER_MARK_INVALID) {
 			ol_flags |= PKT_RX_FDIR | PKT_RX_FDIR_ID;
 			m->hash.fdir.hi = user_mark;
@@ -745,6 +751,10 @@ sfc_ef100_rx_qcreate(uint16_t port_id, uint16_t queue_id,
 	rxq->max_fill_level = info->max_fill_level;
 	rxq->refill_threshold = info->refill_threshold;
 	rxq->prefix_size = info->prefix_size;
+
+	SFC_ASSERT(info->user_mark_mask != 0);
+	rxq->user_mark_mask = info->user_mark_mask;
+
 	rxq->buf_size = info->buf_size;
 	rxq->refill_mb_pool = info->refill_mb_pool;
 	rxq->rxq_hw_ring = info->rxq_hw_ring;
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 75c3da2e52..ab25674929 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -26,6 +26,7 @@
 #include "sfc_rx.h"
 #include "sfc_tx.h"
 #include "sfc_flow.h"
+#include "sfc_flow_tunnel.h"
 #include "sfc_dp.h"
 #include "sfc_dp_rx.h"
 #include "sfc_sw_stats.h"
@@ -1873,6 +1874,9 @@ sfc_rx_meta_negotiate(struct rte_eth_dev *dev, uint64_t *features)
 	if ((sa->priv.dp_rx->features & SFC_DP_RX_FEAT_FLOW_MARK) != 0)
 		supported |= RTE_ETH_RX_META_USER_MARK;
 
+	if (sfc_flow_tunnel_is_supported(sa))
+		supported |= RTE_ETH_RX_META_TUNNEL_ID;
+
 	sa->negotiated_rx_meta = supported & *features;
 	*features = sa->negotiated_rx_meta;
 
diff --git a/drivers/net/sfc/sfc_flow.c b/drivers/net/sfc/sfc_flow.c
index 57cf1ad02b..7510cbb95b 100644
--- a/drivers/net/sfc/sfc_flow.c
+++ b/drivers/net/sfc/sfc_flow.c
@@ -22,6 +22,7 @@
 #include "sfc_rx.h"
 #include "sfc_filter.h"
 #include "sfc_flow.h"
+#include "sfc_flow_tunnel.h"
 #include "sfc_log.h"
 #include "sfc_dp_rx.h"
 #include "sfc_mae_counter.h"
@@ -1740,8 +1741,13 @@ sfc_flow_parse_mark(struct sfc_adapter *sa,
 	struct sfc_flow_spec *spec = &flow->spec;
 	struct sfc_flow_spec_filter *spec_filter = &spec->filter;
 	const efx_nic_cfg_t *encp = efx_nic_cfg_get(sa->nic);
+	uint32_t mark_max;
 
-	if (mark == NULL || mark->id > encp->enc_filter_action_mark_max)
+	mark_max = encp->enc_filter_action_mark_max;
+	if (sfc_flow_tunnel_is_active(sa))
+		mark_max = RTE_MIN(mark_max, SFC_FT_USER_MARK_MASK);
+
+	if (mark == NULL || mark->id > mark_max)
 		return EINVAL;
 
 	spec_filter->template.efs_flags |= EFX_FILTER_FLAG_ACTION_MARK;
diff --git a/drivers/net/sfc/sfc_flow_tunnel.c b/drivers/net/sfc/sfc_flow_tunnel.c
new file mode 100644
index 0000000000..06b4a27a65
--- /dev/null
+++ b/drivers/net/sfc/sfc_flow_tunnel.c
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2021 Xilinx, Inc.
+ */
+
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "sfc.h"
+#include "sfc_dp_rx.h"
+#include "sfc_flow_tunnel.h"
+#include "sfc_mae.h"
+
+bool
+sfc_flow_tunnel_is_supported(struct sfc_adapter *sa)
+{
+	SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+	return ((sa->priv.dp_rx->features & SFC_DP_RX_FEAT_FLOW_MARK) != 0 &&
+		sa->mae.status == SFC_MAE_STATUS_SUPPORTED);
+}
+
+bool
+sfc_flow_tunnel_is_active(struct sfc_adapter *sa)
+{
+	SFC_ASSERT(sfc_adapter_is_locked(sa));
+
+	return ((sa->negotiated_rx_meta & RTE_ETH_RX_META_TUNNEL_ID) != 0);
+}
diff --git a/drivers/net/sfc/sfc_flow_tunnel.h b/drivers/net/sfc/sfc_flow_tunnel.h
new file mode 100644
index 0000000000..fec891fdad
--- /dev/null
+++ b/drivers/net/sfc/sfc_flow_tunnel.h
@@ -0,0 +1,38 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2021 Xilinx, Inc.
+ */
+
+#ifndef _SFC_FLOW_TUNNEL_H
+#define _SFC_FLOW_TUNNEL_H
+
+#include <limits.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Flow Tunnel (FT) SW entry ID */
+typedef uint8_t sfc_ft_id_t;
+
+#define SFC_FT_TUNNEL_MARK_BITS \
+	(sizeof(sfc_ft_id_t) * CHAR_BIT)
+
+#define SFC_FT_USER_MARK_BITS \
+	(sizeof(uint32_t) * CHAR_BIT - SFC_FT_TUNNEL_MARK_BITS)
+
+#define SFC_FT_USER_MARK_MASK \
+	RTE_LEN2MASK(SFC_FT_USER_MARK_BITS, uint32_t)
+
+struct sfc_adapter;
+
+bool sfc_flow_tunnel_is_supported(struct sfc_adapter *sa);
+
+bool sfc_flow_tunnel_is_active(struct sfc_adapter *sa);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _SFC_FLOW_TUNNEL_H */
diff --git a/drivers/net/sfc/sfc_mae.c b/drivers/net/sfc/sfc_mae.c
index 5ecad7347a..2b80492e59 100644
--- a/drivers/net/sfc/sfc_mae.c
+++ b/drivers/net/sfc/sfc_mae.c
@@ -16,6 +16,7 @@
 #include "efx.h"
 
 #include "sfc.h"
+#include "sfc_flow_tunnel.h"
 #include "sfc_mae_counter.h"
 #include "sfc_log.h"
 #include "sfc_switch.h"
@@ -2793,6 +2794,11 @@ sfc_mae_rule_parse_action_mark(struct sfc_adapter *sa,
 {
 	int rc;
 
+	if (conf->id > SFC_FT_USER_MARK_MASK) {
+		sfc_err(sa, "the mark value is too large");
+		return EINVAL;
+	}
+
 	rc = efx_mae_action_set_populate_mark(spec, conf->id);
 	if (rc != 0)
 		sfc_err(sa, "failed to request action MARK: %s", strerror(rc));
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index a3331c5089..3ef43d7c38 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -13,6 +13,7 @@
 
 #include "sfc.h"
 #include "sfc_debug.h"
+#include "sfc_flow_tunnel.h"
 #include "sfc_log.h"
 #include "sfc_ev.h"
 #include "sfc_rx.h"
@@ -1181,7 +1182,8 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	if ((sa->negotiated_rx_meta & RTE_ETH_RX_META_USER_FLAG) != 0)
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_FLAG;
 
-	if ((sa->negotiated_rx_meta & RTE_ETH_RX_META_USER_MARK) != 0)
+	if ((sa->negotiated_rx_meta & RTE_ETH_RX_META_USER_MARK) != 0 ||
+	    sfc_flow_tunnel_is_active(sa))
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_MARK;
 
 	rc = sfc_ev_qinit(sa, SFC_EVQ_TYPE_RX, sw_index,
@@ -1231,6 +1233,12 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	info.buf_size = buf_size;
 	info.batch_max = encp->enc_rx_batch_max;
 	info.prefix_size = encp->enc_rx_prefix_size;
+
+	if (sfc_flow_tunnel_is_active(sa))
+		info.user_mark_mask = SFC_FT_USER_MARK_MASK;
+	else
+		info.user_mark_mask = UINT32_MAX;
+
 	info.flags = rxq_info->rxq_flags;
 	info.rxq_entries = rxq_info->entries;
 	info.rxq_hw_ring = rxq->mem.esm_base;
-- 
2.20.1


  reply	other threads:[~2021-09-29 20:57 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29 20:57 [dpdk-dev] [PATCH 00/10] net/sfc: add support " Ivan Malov
2021-09-29 20:57 ` Ivan Malov [this message]
2021-09-29 20:57 ` [dpdk-dev] [PATCH 02/10] common/sfc_efx/base: add API to set RECIRC ID in outer rules Ivan Malov
2021-09-30  9:53   ` Kinsella, Ray
2021-09-29 20:57 ` [dpdk-dev] [PATCH 03/10] net/sfc: support JUMP flows in tunnel offload Ivan Malov
2021-09-29 20:57 ` [dpdk-dev] [PATCH 04/10] common/sfc_efx/base: add RECIRC ID match in action rules API Ivan Malov
2021-09-29 20:57 ` [dpdk-dev] [PATCH 05/10] net/sfc: support GROUP flows in tunnel offload Ivan Malov
2021-09-29 20:57 ` [dpdk-dev] [PATCH 06/10] net/sfc: implement control path operations " Ivan Malov
2021-09-29 20:57 ` [dpdk-dev] [PATCH 07/10] net/sfc: override match on ETH in tunnel offload JUMP rules Ivan Malov
2021-09-29 20:57 ` [dpdk-dev] [PATCH 08/10] net/sfc: use action rules " Ivan Malov
2021-09-29 20:57 ` [dpdk-dev] [PATCH 09/10] net/sfc: support counters " Ivan Malov
2021-09-29 20:57 ` [dpdk-dev] [PATCH 10/10] net/sfc: refine pattern of GROUP flows in tunnel offload Ivan Malov
2021-10-04 23:55 ` [dpdk-dev] [PATCH v2 00/10] net/sfc: add support for " Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 01/10] net/sfc: fence off 8 bits in Rx mark " Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 02/10] common/sfc_efx/base: add API to set RECIRC ID in outer rules Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 03/10] net/sfc: support JUMP flows in tunnel offload Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 04/10] common/sfc_efx/base: add RECIRC ID match in action rules API Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 05/10] net/sfc: support GROUP flows in tunnel offload Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 06/10] net/sfc: implement control path operations " Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 07/10] net/sfc: override match on ETH in tunnel offload JUMP rules Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 08/10] net/sfc: use action rules " Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 09/10] net/sfc: support counters " Ivan Malov
2021-10-04 23:55   ` [dpdk-dev] [PATCH v2 10/10] net/sfc: refine pattern of GROUP flows in tunnel offload Ivan Malov
2021-10-12 23:46   ` [dpdk-dev] [PATCH v2 00/10] net/sfc: add support for " Ferruh Yigit
2021-10-13  0:28     ` Ivan Malov
2021-10-13  0:24 ` [dpdk-dev] [PATCH v3 " Ivan Malov
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 01/10] net/sfc: fence off 8 bits in Rx mark " Ivan Malov
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 02/10] common/sfc_efx/base: add API to set RECIRC ID in outer rules Ivan Malov
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 03/10] net/sfc: support JUMP flows in tunnel offload Ivan Malov
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 04/10] common/sfc_efx/base: add RECIRC ID match in action rules API Ivan Malov
2021-10-13  8:41     ` Kinsella, Ray
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 05/10] net/sfc: support GROUP flows in tunnel offload Ivan Malov
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 06/10] net/sfc: implement control path operations " Ivan Malov
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 07/10] net/sfc: override match on ETH in tunnel offload JUMP rules Ivan Malov
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 08/10] net/sfc: use action rules " Ivan Malov
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 09/10] net/sfc: support counters " Ivan Malov
2021-10-13  0:24   ` [dpdk-dev] [PATCH v3 10/10] net/sfc: refine pattern of GROUP flows in tunnel offload Ivan Malov
2021-10-13 10:42   ` [dpdk-dev] [PATCH v3 00/10] net/sfc: add support for " Ferruh Yigit
2021-10-13 10:45   ` Ferruh Yigit
2021-10-13 10:55     ` Thomas Monjalon
2021-10-13 13:15 ` [dpdk-dev] [PATCH v4 " Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 01/10] net/sfc: fence off 8 bits in Rx mark " Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 02/10] common/sfc_efx/base: support recirculation ID in outer rules Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 03/10] net/sfc: support jump flows in tunnel offload Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 04/10] common/sfc_efx/base: match on recirc. ID in action rules Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 05/10] net/sfc: support group flows in tunnel offload Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 06/10] net/sfc: implement control path operations " Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 07/10] net/sfc: override match fields in tunnel offload jump rules Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 08/10] net/sfc: use action rules " Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 09/10] net/sfc: support counters " Ivan Malov
2021-10-13 13:15   ` [dpdk-dev] [PATCH v4 10/10] net/sfc: refine pattern of group flows in tunnel offload Ivan Malov
2021-10-13 14:40   ` [dpdk-dev] [PATCH v4 00/10] net/sfc: add support for " 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=20210929205730.775-2-ivan.malov@oktetlabs.ru \
    --to=ivan.malov@oktetlabs.ru \
    --cc=amoreton@xilinx.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

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

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