DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/3] net/sfc: support VLAN stripping offload
@ 2023-05-31 13:41 Artemii Morozov
  2023-05-31 13:41 ` [PATCH 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
                   ` (7 more replies)
  0 siblings, 8 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-05-31 13:41 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This patch series adds VLAN stripping offload. Note that this                                                                                                                                                  
offload are device level offload.

Artemii Morozov (3):
  common/sfc_efx/base: report VLAN stripping capability
  common/sfc_efx/base: add support to enable VLAN stripping
  net/sfc: support VLAN stripping offload

 doc/guides/nics/sfc_efx.rst               |  4 ++--
 drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  1 +
 drivers/common/sfc_efx/base/ef10_nic.c    |  6 ++++++
 drivers/common/sfc_efx/base/efx.h         | 10 ++++++++++
 drivers/common/sfc_efx/base/efx_filter.c  |  3 ++-
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_rx.c      | 17 +++++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 drivers/common/sfc_efx/base/siena_nic.c   |  1 +
 drivers/net/sfc/sfc_ef100_rx.c            | 21 ++++++++++++++++++++-
 drivers/net/sfc/sfc_rx.c                  | 19 +++++++++++++++++++
 12 files changed, 103 insertions(+), 4 deletions(-)

-- 
2.34.1


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

* [PATCH 1/3] common/sfc_efx/base: report VLAN stripping capability
  2023-05-31 13:41 [PATCH 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
@ 2023-05-31 13:41 ` Artemii Morozov
  2023-06-01  8:12   ` [PATCH v2 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-05-31 13:41 ` [PATCH 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-05-31 13:41 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

These changes are necessary in order to add support for stripping
VLAN tags in the future.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 6 ++++++
 drivers/common/sfc_efx/base/efx.h       | 1 +
 drivers/common/sfc_efx/base/siena_nic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index d5b19af8e8..51f7b3fe65 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1316,6 +1316,12 @@ ef10_get_datapath_caps(
 	else
 		encp->enc_init_evq_extended_width_supported = B_FALSE;
 
+	/* Check if firmware supports VLAN stripping. */
+	if (CAP_FLAGS1(req, RX_VLAN_STRIPPING))
+		encp->enc_rx_vlan_stripping = B_TRUE;
+	else
+		encp->enc_rx_vlan_stripping = B_FALSE;
+
 	/*
 	 * Check if the NO_CONT_EV mode for RX events is supported.
 	 */
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index da14941b31..58a0e95bf9 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1650,6 +1650,7 @@ typedef struct efx_nic_cfg_s {
 	boolean_t		enc_pm_and_rxdp_counters;
 	boolean_t		enc_mac_stats_40g_tx_size_bins;
 	uint32_t		enc_tunnel_encapsulations_supported;
+	boolean_t		enc_rx_vlan_stripping;
 	/*
 	 * NIC global maximum for unique UDP tunnel ports shared by all
 	 * functions.
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index c0316676eb..682d2f75c9 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -190,6 +190,7 @@ siena_board_cfg(
 	encp->enc_rx_include_fcs_supported = B_FALSE;
 	encp->enc_rx_es_super_buffer_supported = B_FALSE;
 	encp->enc_fw_subvariant_no_tx_csum_supported = B_FALSE;
+	encp->enc_rx_vlan_stripping = B_FALSE;
 
 	/* Siena supports two 10G ports, and 8 lanes of PCIe Gen2 */
 	encp->enc_required_pcie_bandwidth_mbps = 2 * 10000;
-- 
2.34.1


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

* [PATCH 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-05-31 13:41 [PATCH 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-05-31 13:41 ` [PATCH 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-05-31 13:41 ` Artemii Morozov
  2023-05-31 13:41 ` [PATCH 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-05-31 13:41 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

To enable VLAN stripping, two conditions must be met:
the corresponding flag must be set and the appropriate
RX prefix should be requested.
VLAN stripping is supported for ef100 datapath only.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  1 +
 drivers/common/sfc_efx/base/efx.h         |  9 +++++++++
 drivers/common/sfc_efx/base/efx_filter.c  |  3 ++-
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_rx.c      | 17 +++++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 7 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index d6940011c0..7371451098 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -338,6 +338,11 @@ efx_mcdi_filter_op_add(
 		    FILTER_OP_V3_IN_MATCH_SET_FLAG, 1);
 	}
 
+	if (spec->efs_flags & EFX_FILTER_FLAG_VLAN_STRIP) {
+		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
+			FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);
+	}
+
 	efx_mcdi_execute(enp, &req);
 
 	if (req.emr_rc != 0) {
@@ -852,6 +857,16 @@ ef10_filter_add_internal(
 
 	hash = ef10_filter_hash(spec);
 
+	/*
+	 * VLAN stripping is offload at the device level, and it should be
+	 * applied to all filters if it has been applied at least once before.
+	 * Knowledge of device level vlan strip offload being enabled comes from
+	 * the default RxQ flags, albeit the flag may be set on any queue.
+	 * But only default RxQ affects this 'eft_strip_vlan' decision.
+	 */
+	if (eftp->eft_strip_vlan)
+		spec->efs_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
+
 	/*
 	 * FIXME: Add support for inserting filters of different priorities
 	 * and removing lower priority multicast filters (bug 42378)
@@ -2010,6 +2025,9 @@ ef10_filter_reconfigure(
 	else
 		filter_flags = 0;
 
+	if (table->eft_strip_vlan)
+		filter_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
+
 	/* Mark old filters which may need to be removed */
 	ef10_filter_mark_old_filters(enp);
 
@@ -2142,6 +2160,8 @@ ef10_filter_default_rxq_set(
 	EFSYS_ASSERT(using_rss == B_FALSE);
 	table->eft_using_rss = B_FALSE;
 #endif
+	if (erp->er_flags & EFX_RXQ_FLAG_VLAN_STRIP)
+		table->eft_strip_vlan = B_TRUE;
 	table->eft_default_rxq = erp;
 }
 
@@ -2153,6 +2173,7 @@ ef10_filter_default_rxq_clear(
 
 	table->eft_default_rxq = NULL;
 	table->eft_using_rss = B_FALSE;
+	table->eft_strip_vlan = B_FALSE;
 }
 
 
diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
index 342a9a2006..2aae208f27 100644
--- a/drivers/common/sfc_efx/base/ef10_impl.h
+++ b/drivers/common/sfc_efx/base/ef10_impl.h
@@ -1286,6 +1286,7 @@ typedef struct ef10_filter_table_s {
 	ef10_filter_entry_t	eft_entry[EFX_EF10_FILTER_TBL_ROWS];
 	efx_rxq_t		*eft_default_rxq;
 	boolean_t		eft_using_rss;
+	boolean_t		eft_strip_vlan;
 	uint32_t		eft_unicst_filter_indexes[
 	    EFX_EF10_FILTER_UNICAST_FILTERS_MAX];
 	uint32_t		eft_unicst_filter_count;
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 58a0e95bf9..3f67212810 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -3115,6 +3115,10 @@ typedef enum efx_rxq_type_e {
  * Request user flag field in the Rx prefix of a queue.
  */
 #define	EFX_RXQ_FLAG_USER_FLAG		0x20
+/*
+ * Request vlan tci field in the Rx prefix of a queue.
+ */
+#define	EFX_RXQ_FLAG_VLAN_STRIP		0x40
 
 LIBEFX_API
 extern	__checkReturn	efx_rc_t
@@ -3469,6 +3473,11 @@ efx_tx_qdestroy(
 #define	EFX_FILTER_FLAG_ACTION_FLAG	0x20
 /* Set match mark on the received packet */
 #define	EFX_FILTER_FLAG_ACTION_MARK	0x40
+/*
+ * Request that the first tag in the outer L2 header be stripped
+ * and TCI be indicated in Rx prefix.
+ */
+#define	EFX_FILTER_FLAG_VLAN_STRIP	0x80
 
 typedef uint8_t efx_filter_flags_t;
 
diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
index 83c37ff859..778ed0c370 100644
--- a/drivers/common/sfc_efx/base/efx_filter.c
+++ b/drivers/common/sfc_efx/base/efx_filter.c
@@ -322,7 +322,8 @@ efx_filter_spec_init_rx(
 	EFSYS_ASSERT3P(spec, !=, NULL);
 	EFSYS_ASSERT3P(erp, !=, NULL);
 	EFSYS_ASSERT((flags & ~(EFX_FILTER_FLAG_RX_RSS |
-				EFX_FILTER_FLAG_RX_SCATTER)) == 0);
+				EFX_FILTER_FLAG_RX_SCATTER |
+				EFX_FILTER_FLAG_VLAN_STRIP)) == 0);
 
 	memset(spec, 0, sizeof (*spec));
 	spec->efs_priority = priority;
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index fb9b9e1a20..a48d4f6e04 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -1046,6 +1046,7 @@ struct efx_rxq_s {
 	efsys_mem_t			*er_esmp;
 	efx_evq_rxq_state_t		*er_ev_qstate;
 	efx_rx_prefix_layout_t		er_prefix_layout;
+	uint16_t			er_flags;
 };
 
 #define	EFX_RXQ_MAGIC	0x15022005
diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
index 61726a9f0b..55ffa82033 100644
--- a/drivers/common/sfc_efx/base/efx_rx.c
+++ b/drivers/common/sfc_efx/base/efx_rx.c
@@ -925,6 +925,7 @@ efx_rx_qcreate_internal(
 	erp->er_index = index;
 	erp->er_mask = ndescs - 1;
 	erp->er_esmp = esmp;
+	erp->er_flags = 0;
 
 	if ((rc = erxop->erxo_qcreate(enp, index, label, type, type_data, esmp,
 	    ndescs, id, flags, eep, erp)) != 0)
@@ -943,11 +944,27 @@ efx_rx_qcreate_internal(
 		}
 	}
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIP) {
+		const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout;
+		const efx_rx_prefix_field_info_t *vlan_tci_field;
+
+		vlan_tci_field =
+		    &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI];
+		if (vlan_tci_field->erpfi_width_bits == 0) {
+			rc = ENOTSUP;
+			goto fail6;
+		}
+
+		erp->er_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
+	}
+
 	enp->en_rx_qcount++;
 	*erpp = erp;
 
 	return (0);
 
+fail6:
+	EFSYS_PROBE(fail6);
 fail5:
 	EFSYS_PROBE(fail5);
 
diff --git a/drivers/common/sfc_efx/base/rhead_rx.c b/drivers/common/sfc_efx/base/rhead_rx.c
index d0ac5c02f8..3453227388 100644
--- a/drivers/common/sfc_efx/base/rhead_rx.c
+++ b/drivers/common/sfc_efx/base/rhead_rx.c
@@ -640,6 +640,9 @@ rhead_rx_qcreate(
 	if (flags & EFX_RXQ_FLAG_USER_FLAG)
 		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_USER_FLAG;
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIP)
+		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI;
+
 	/*
 	 * LENGTH is required in EF100 host interface, as receive events
 	 * do not include the packet length.
-- 
2.34.1


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

* [PATCH 3/3] net/sfc: support VLAN stripping offload
  2023-05-31 13:41 [PATCH 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-05-31 13:41 ` [PATCH 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
  2023-05-31 13:41 ` [PATCH 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-05-31 13:41 ` Artemii Morozov
  2023-06-01 15:30 ` [PATCH v4 0/3] " Artemii Morozov
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-05-31 13:41 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

Extract vlan tci provided by the HW in the prefix and put it to mbuf.
VLAN stripping is supported for ef100 datapath only.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 doc/guides/nics/sfc_efx.rst    |  4 ++--
 drivers/net/sfc/sfc_ef100_rx.c | 21 ++++++++++++++++++++-
 drivers/net/sfc/sfc_rx.c       | 19 +++++++++++++++++++
 3 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 88d0fdf3c1..98702465f7 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -80,6 +80,8 @@ SFC EFX PMD has support for:
 
 - Port representors (see :ref: switch_representation)
 
+- VLAN stripping (if running firmware variant supports it)
+
 
 Non-supported Features
 ----------------------
@@ -92,8 +94,6 @@ The features not yet supported include:
 
 - VLAN filtering
 
-- VLAN stripping
-
 - LRO
 
 
diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index 16cd8524d3..b7e3397f77 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -68,6 +68,7 @@ struct sfc_ef100_rxq {
 #define SFC_EF100_RXQ_INGRESS_MPORT	0x80
 #define SFC_EF100_RXQ_USER_FLAG		0x100
 #define SFC_EF100_RXQ_NIC_DMA_MAP	0x200
+#define SFC_EF100_RXQ_VLAN_STRIP	0x400
 	unsigned int			ptr_mask;
 	unsigned int			evq_phase_bit_shift;
 	unsigned int			ready_pkts;
@@ -392,6 +393,7 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
 		SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
+		SFC_EF100_RX_PREFIX_FIELD(VLAN_STRIP_TCI, B_FALSE),
 
 #undef	SFC_EF100_RX_PREFIX_FIELD
 	}
@@ -472,6 +474,17 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
 						ESF_GZ_RX_PREFIX_INGRESS_MPORT);
 	}
 
+	if (rxq->flags & SFC_EF100_RXQ_VLAN_STRIP) {
+		uint32_t vlan_stripped;
+		vlan_stripped = EFX_XWORD_FIELD(rx_prefix[0], ESF_GZ_RX_PREFIX_VLAN_STRIPPED);
+
+		if (vlan_stripped != 0) {
+			ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+			m->vlan_tci = EFX_XWORD_FIELD(rx_prefix[0],
+							ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI);
+		}
+	}
+
 	m->ol_flags = ol_flags;
 	return true;
 }
@@ -882,6 +895,12 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
 	else
 		rxq->flags &= ~SFC_EF100_RXQ_INGRESS_MPORT;
 
+	if ((unsup_rx_prefix_fields &
+	     (1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI)) == 0)
+		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIP;
+	else
+		rxq->flags &= ~SFC_EF100_RXQ_VLAN_STRIP;
+
 	rxq->prefix_size = pinfo->erpl_length;
 	rxq->rearm_data = sfc_ef100_mk_mbuf_rearm_data(rxq->dp.dpq.port_id,
 						       rxq->prefix_size);
@@ -994,7 +1013,7 @@ struct sfc_dp_rx sfc_ef100_rx = {
 				  SFC_DP_RX_FEAT_FLOW_MARK |
 				  SFC_DP_RX_FEAT_INTR |
 				  SFC_DP_RX_FEAT_STATS,
-	.dev_offload_capa	= 0,
+	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_VLAN_STRIP,
 	.queue_offload_capa	= RTE_ETH_RX_OFFLOAD_CHECKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index 921d9d9ca0..aae815a653 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -942,6 +942,9 @@ sfc_rx_get_offload_mask(struct sfc_adapter *sa)
 	if (encp->enc_rx_include_fcs_supported == 0)
 		no_caps |= RTE_ETH_RX_OFFLOAD_KEEP_CRC;
 
+	if (encp->enc_rx_vlan_stripping == 0)
+		no_caps |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
+
 	return ~no_caps;
 }
 
@@ -1190,6 +1193,16 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH)
 		rxq_info->type_flags |= EFX_RXQ_FLAG_RSS_HASH;
 
+
+	if (sa->eth_dev->data->dev_conf.rxmode.offloads &
+	    RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		rxq_info->type_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
+	} else if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		sfc_err(sa, "VLAN stripping must be configured during device configure");
+		rc = EINVAL;
+		goto fail_bad_conf;
+	}
+
 	if ((sa->negotiated_rx_metadata & RTE_ETH_RX_METADATA_USER_FLAG) != 0)
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_FLAG;
 
@@ -1692,6 +1705,12 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 	}
 
+	if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) &&
+	    (~offloads_supported & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)) {
+		sfc_err(sa, "VLAN stripping offload is requested but not supported");
+		rc = ENOTSUP;
+	}
+
 	return rc;
 }
 
-- 
2.34.1


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

* [PATCH v2 0/3] net/sfc: support VLAN stripping offload
  2023-05-31 13:41 ` [PATCH 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-01  8:12   ` Artemii Morozov
  2023-06-01  8:12     ` [PATCH v2 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
                       ` (2 more replies)
  0 siblings, 3 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This patch series adds VLAN stripping offload. Note that this
offload are device level offload.

v2:
  * rebase patches on top of dpdk-next-net/main

Artemii Morozov (3):
  common/sfc_efx/base: report VLAN stripping capability
  common/sfc_efx/base: add support to enable VLAN stripping
  net/sfc: support VLAN stripping offload

 doc/guides/nics/sfc_efx.rst               |  4 ++--
 drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  1 +
 drivers/common/sfc_efx/base/ef10_nic.c    |  6 ++++++
 drivers/common/sfc_efx/base/efx.h         | 10 ++++++++++
 drivers/common/sfc_efx/base/efx_filter.c  |  3 ++-
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_rx.c      | 17 +++++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 drivers/common/sfc_efx/base/siena_nic.c   |  1 +
 drivers/net/sfc/sfc_ef100_rx.c            | 20 +++++++++++++++++++-
 drivers/net/sfc/sfc_rx.c                  | 19 +++++++++++++++++++
 12 files changed, 102 insertions(+), 4 deletions(-)

-- 
2.34.1


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

* [PATCH v2 1/3] common/sfc_efx/base: report VLAN stripping capability
  2023-06-01  8:12   ` [PATCH v2 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
@ 2023-06-01  8:12     ` Artemii Morozov
  2023-06-01 14:35       ` [PATCH v3 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-06-01  8:12     ` [PATCH v2 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
  2023-06-01  8:12     ` [PATCH v2 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

These changes are necessary in order to add support for stripping
VLAN tags in the future.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 6 ++++++
 drivers/common/sfc_efx/base/efx.h       | 1 +
 drivers/common/sfc_efx/base/siena_nic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index e1709d1200..501ce2e37c 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1227,6 +1227,12 @@ ef10_get_datapath_caps(
 	else
 		encp->enc_init_evq_extended_width_supported = B_FALSE;
 
+	/* Check if firmware supports VLAN stripping. */
+	if (CAP_FLAGS1(req, RX_VLAN_STRIPPING))
+		encp->enc_rx_vlan_stripping = B_TRUE;
+	else
+		encp->enc_rx_vlan_stripping = B_FALSE;
+
 	/*
 	 * Check if the NO_CONT_EV mode for RX events is supported.
 	 */
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 49e29dcc1c..ac89b418e0 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1638,6 +1638,7 @@ typedef struct efx_nic_cfg_s {
 	boolean_t		enc_pm_and_rxdp_counters;
 	boolean_t		enc_mac_stats_40g_tx_size_bins;
 	uint32_t		enc_tunnel_encapsulations_supported;
+	boolean_t		enc_rx_vlan_stripping;
 	/*
 	 * NIC global maximum for unique UDP tunnel ports shared by all
 	 * functions.
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index 9f14faf271..451ca81bd7 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -189,6 +189,7 @@ siena_board_cfg(
 	encp->enc_rx_var_packed_stream_supported = B_FALSE;
 	encp->enc_rx_es_super_buffer_supported = B_FALSE;
 	encp->enc_fw_subvariant_no_tx_csum_supported = B_FALSE;
+	encp->enc_rx_vlan_stripping = B_FALSE;
 
 	/* Siena supports two 10G ports, and 8 lanes of PCIe Gen2 */
 	encp->enc_required_pcie_bandwidth_mbps = 2 * 10000;
-- 
2.34.1


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

* [PATCH v2 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-01  8:12   ` [PATCH v2 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-06-01  8:12     ` [PATCH v2 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-01  8:12     ` Artemii Morozov
  2023-06-01  8:12     ` [PATCH v2 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

To enable VLAN stripping, two conditions must be met:
the corresponding flag must be set and the appropriate
RX prefix should be requested.
VLAN stripping is supported for ef100 datapath only.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  1 +
 drivers/common/sfc_efx/base/efx.h         |  9 +++++++++
 drivers/common/sfc_efx/base/efx_filter.c  |  3 ++-
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_rx.c      | 17 +++++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 7 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index d6940011c0..7371451098 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -338,6 +338,11 @@ efx_mcdi_filter_op_add(
 		    FILTER_OP_V3_IN_MATCH_SET_FLAG, 1);
 	}
 
+	if (spec->efs_flags & EFX_FILTER_FLAG_VLAN_STRIP) {
+		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
+			FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);
+	}
+
 	efx_mcdi_execute(enp, &req);
 
 	if (req.emr_rc != 0) {
@@ -852,6 +857,16 @@ ef10_filter_add_internal(
 
 	hash = ef10_filter_hash(spec);
 
+	/*
+	 * VLAN stripping is offload at the device level, and it should be
+	 * applied to all filters if it has been applied at least once before.
+	 * Knowledge of device level vlan strip offload being enabled comes from
+	 * the default RxQ flags, albeit the flag may be set on any queue.
+	 * But only default RxQ affects this 'eft_strip_vlan' decision.
+	 */
+	if (eftp->eft_strip_vlan)
+		spec->efs_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
+
 	/*
 	 * FIXME: Add support for inserting filters of different priorities
 	 * and removing lower priority multicast filters (bug 42378)
@@ -2010,6 +2025,9 @@ ef10_filter_reconfigure(
 	else
 		filter_flags = 0;
 
+	if (table->eft_strip_vlan)
+		filter_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
+
 	/* Mark old filters which may need to be removed */
 	ef10_filter_mark_old_filters(enp);
 
@@ -2142,6 +2160,8 @@ ef10_filter_default_rxq_set(
 	EFSYS_ASSERT(using_rss == B_FALSE);
 	table->eft_using_rss = B_FALSE;
 #endif
+	if (erp->er_flags & EFX_RXQ_FLAG_VLAN_STRIP)
+		table->eft_strip_vlan = B_TRUE;
 	table->eft_default_rxq = erp;
 }
 
@@ -2153,6 +2173,7 @@ ef10_filter_default_rxq_clear(
 
 	table->eft_default_rxq = NULL;
 	table->eft_using_rss = B_FALSE;
+	table->eft_strip_vlan = B_FALSE;
 }
 
 
diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
index 877aedad45..017e561f19 100644
--- a/drivers/common/sfc_efx/base/ef10_impl.h
+++ b/drivers/common/sfc_efx/base/ef10_impl.h
@@ -1287,6 +1287,7 @@ typedef struct ef10_filter_table_s {
 	ef10_filter_entry_t	eft_entry[EFX_EF10_FILTER_TBL_ROWS];
 	efx_rxq_t		*eft_default_rxq;
 	boolean_t		eft_using_rss;
+	boolean_t		eft_strip_vlan;
 	uint32_t		eft_unicst_filter_indexes[
 	    EFX_EF10_FILTER_UNICAST_FILTERS_MAX];
 	uint32_t		eft_unicst_filter_count;
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index ac89b418e0..508d0a802d 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -3101,6 +3101,10 @@ typedef enum efx_rxq_type_e {
  * Request user flag field in the Rx prefix of a queue.
  */
 #define	EFX_RXQ_FLAG_USER_FLAG		0x20
+/*
+ * Request vlan tci field in the Rx prefix of a queue.
+ */
+#define	EFX_RXQ_FLAG_VLAN_STRIP		0x40
 
 LIBEFX_API
 extern	__checkReturn	efx_rc_t
@@ -3455,6 +3459,11 @@ efx_tx_qdestroy(
 #define	EFX_FILTER_FLAG_ACTION_FLAG	0x20
 /* Set match mark on the received packet */
 #define	EFX_FILTER_FLAG_ACTION_MARK	0x40
+/*
+ * Request that the first tag in the outer L2 header be stripped
+ * and TCI be indicated in Rx prefix.
+ */
+#define	EFX_FILTER_FLAG_VLAN_STRIP	0x80
 
 typedef uint8_t efx_filter_flags_t;
 
diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
index 83c37ff859..778ed0c370 100644
--- a/drivers/common/sfc_efx/base/efx_filter.c
+++ b/drivers/common/sfc_efx/base/efx_filter.c
@@ -322,7 +322,8 @@ efx_filter_spec_init_rx(
 	EFSYS_ASSERT3P(spec, !=, NULL);
 	EFSYS_ASSERT3P(erp, !=, NULL);
 	EFSYS_ASSERT((flags & ~(EFX_FILTER_FLAG_RX_RSS |
-				EFX_FILTER_FLAG_RX_SCATTER)) == 0);
+				EFX_FILTER_FLAG_RX_SCATTER |
+				EFX_FILTER_FLAG_VLAN_STRIP)) == 0);
 
 	memset(spec, 0, sizeof (*spec));
 	spec->efs_priority = priority;
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 45e99d01c5..c45669e077 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -1045,6 +1045,7 @@ struct efx_rxq_s {
 	efsys_mem_t			*er_esmp;
 	efx_evq_rxq_state_t		*er_ev_qstate;
 	efx_rx_prefix_layout_t		er_prefix_layout;
+	uint16_t			er_flags;
 };
 
 #define	EFX_RXQ_MAGIC	0x15022005
diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
index 61726a9f0b..55ffa82033 100644
--- a/drivers/common/sfc_efx/base/efx_rx.c
+++ b/drivers/common/sfc_efx/base/efx_rx.c
@@ -925,6 +925,7 @@ efx_rx_qcreate_internal(
 	erp->er_index = index;
 	erp->er_mask = ndescs - 1;
 	erp->er_esmp = esmp;
+	erp->er_flags = 0;
 
 	if ((rc = erxop->erxo_qcreate(enp, index, label, type, type_data, esmp,
 	    ndescs, id, flags, eep, erp)) != 0)
@@ -943,11 +944,27 @@ efx_rx_qcreate_internal(
 		}
 	}
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIP) {
+		const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout;
+		const efx_rx_prefix_field_info_t *vlan_tci_field;
+
+		vlan_tci_field =
+		    &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI];
+		if (vlan_tci_field->erpfi_width_bits == 0) {
+			rc = ENOTSUP;
+			goto fail6;
+		}
+
+		erp->er_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
+	}
+
 	enp->en_rx_qcount++;
 	*erpp = erp;
 
 	return (0);
 
+fail6:
+	EFSYS_PROBE(fail6);
 fail5:
 	EFSYS_PROBE(fail5);
 
diff --git a/drivers/common/sfc_efx/base/rhead_rx.c b/drivers/common/sfc_efx/base/rhead_rx.c
index d0ac5c02f8..3453227388 100644
--- a/drivers/common/sfc_efx/base/rhead_rx.c
+++ b/drivers/common/sfc_efx/base/rhead_rx.c
@@ -640,6 +640,9 @@ rhead_rx_qcreate(
 	if (flags & EFX_RXQ_FLAG_USER_FLAG)
 		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_USER_FLAG;
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIP)
+		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI;
+
 	/*
 	 * LENGTH is required in EF100 host interface, as receive events
 	 * do not include the packet length.
-- 
2.34.1


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

* [PATCH v2 3/3] net/sfc: support VLAN stripping offload
  2023-06-01  8:12   ` [PATCH v2 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-06-01  8:12     ` [PATCH v2 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
  2023-06-01  8:12     ` [PATCH v2 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-01  8:12     ` Artemii Morozov
  2 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01  8:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

Extract vlan tci provided by the HW in the prefix and put it to mbuf.
VLAN stripping is supported for ef100 datapath only.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 doc/guides/nics/sfc_efx.rst    |  4 ++--
 drivers/net/sfc/sfc_ef100_rx.c | 20 +++++++++++++++++++-
 drivers/net/sfc/sfc_rx.c       | 19 +++++++++++++++++++
 3 files changed, 40 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index de0656876b..44fa24e1ba 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -118,6 +118,8 @@ SFC EFX PMD has support for:
 
 - Port representors (see :ref: switch_representation)
 
+- VLAN stripping (if running firmware variant supports it)
+
 
 Non-supported Features
 ----------------------
@@ -132,8 +134,6 @@ The features not yet supported include:
 
 - VLAN filtering
 
-- VLAN stripping
-
 - LRO
 
 
diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index 37b754fa33..c4c75b622c 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -68,6 +68,7 @@ struct sfc_ef100_rxq {
 #define SFC_EF100_RXQ_INGRESS_MPORT	0x80
 #define SFC_EF100_RXQ_USER_FLAG		0x100
 #define SFC_EF100_RXQ_NIC_DMA_MAP	0x200
+#define SFC_EF100_RXQ_VLAN_STRIP	0x400
 	unsigned int			ptr_mask;
 	unsigned int			evq_phase_bit_shift;
 	unsigned int			ready_pkts;
@@ -392,6 +393,7 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
 		SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
+		SFC_EF100_RX_PREFIX_FIELD(VLAN_STRIP_TCI, B_FALSE),
 
 #undef	SFC_EF100_RX_PREFIX_FIELD
 	}
@@ -472,6 +474,17 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
 						ESF_GZ_RX_PREFIX_INGRESS_MPORT);
 	}
 
+	if (rxq->flags & SFC_EF100_RXQ_VLAN_STRIP) {
+		uint32_t vlan_stripped;
+		vlan_stripped = EFX_XWORD_FIELD(rx_prefix[0], ESF_GZ_RX_PREFIX_VLAN_STRIPPED);
+
+		if (vlan_stripped != 0) {
+			ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+			m->vlan_tci = EFX_XWORD_FIELD(rx_prefix[0],
+							ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI);
+		}
+	}
+
 	m->ol_flags = ol_flags;
 	return true;
 }
@@ -879,6 +892,11 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
 	else
 		rxq->flags &= ~SFC_EF100_RXQ_USER_MARK;
 
+	if ((unsup_rx_prefix_fields &
+		(1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI)) == 0)
+		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIP;
+	else
+		rxq->flags &= ~SFC_EF100_RXQ_VLAN_STRIP;
 
 	/*
 	 * At the moment, this feature is used only
@@ -1004,7 +1022,7 @@ struct sfc_dp_rx sfc_ef100_rx = {
 				  SFC_DP_RX_FEAT_FLOW_MARK |
 				  SFC_DP_RX_FEAT_INTR |
 				  SFC_DP_RX_FEAT_STATS,
-	.dev_offload_capa	= 0,
+	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_VLAN_STRIP,
 	.queue_offload_capa	= RTE_ETH_RX_OFFLOAD_CHECKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index edd0f0c038..e9ef1d92ed 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -938,6 +938,9 @@ sfc_rx_get_offload_mask(struct sfc_adapter *sa)
 	if (encp->enc_tunnel_encapsulations_supported == 0)
 		no_caps |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
+	if (encp->enc_rx_vlan_stripping == 0)
+		no_caps |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
+
 	return ~no_caps;
 }
 
@@ -1186,6 +1189,16 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH)
 		rxq_info->type_flags |= EFX_RXQ_FLAG_RSS_HASH;
 
+
+	if (sa->eth_dev->data->dev_conf.rxmode.offloads &
+	    RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		rxq_info->type_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
+	} else if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		sfc_err(sa, "VLAN stripping must be configured during device configure");
+		rc = EINVAL;
+		goto fail_bad_conf;
+	}
+
 	if ((sa->negotiated_rx_metadata & RTE_ETH_RX_METADATA_USER_FLAG) != 0)
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_FLAG;
 
@@ -1691,6 +1704,12 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 	}
 
+	if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) &&
+	    (~offloads_supported & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)) {
+		sfc_err(sa, "VLAN stripping offload is requested but not supported");
+		rc = ENOTSUP;
+	}
+
 	return rc;
 }
 
-- 
2.34.1


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

* [PATCH v3 0/3] net/sfc: support VLAN stripping offload
  2023-06-01  8:12     ` [PATCH v2 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-01 14:35       ` Artemii Morozov
  2023-06-01 14:35         ` [PATCH v3 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
                           ` (2 more replies)
  0 siblings, 3 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01 14:35 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This patch series adds VLAN stripping offload. Note that this
offload are device level offload.

v3:
  * fix apply patch failure warning

v2:
  * rebase patches on top of dpdk-next-net/main

Artemii Morozov (3):
  common/sfc_efx/base: report VLAN stripping capability
  common/sfc_efx/base: add support to enable VLAN stripping
  net/sfc: support VLAN stripping offload

 doc/guides/nics/sfc_efx.rst               |  4 ++--
 drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  1 +
 drivers/common/sfc_efx/base/ef10_nic.c    |  6 ++++++
 drivers/common/sfc_efx/base/efx.h         | 10 ++++++++++
 drivers/common/sfc_efx/base/efx_filter.c  |  3 ++-
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_rx.c      | 17 +++++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 drivers/common/sfc_efx/base/siena_nic.c   |  1 +
 drivers/net/sfc/sfc_ef100_rx.c            | 21 ++++++++++++++++++++-
 drivers/net/sfc/sfc_rx.c                  | 19 +++++++++++++++++++
 12 files changed, 103 insertions(+), 4 deletions(-)

-- 
2.34.1


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

* [PATCH v3 1/3] common/sfc_efx/base: report VLAN stripping capability
  2023-06-01 14:35       ` [PATCH v3 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
@ 2023-06-01 14:35         ` Artemii Morozov
  2023-06-01 14:35         ` [PATCH v3 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
  2023-06-01 14:35         ` [PATCH v3 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01 14:35 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

These changes are necessary in order to add support for stripping
VLAN tags in the future.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 6 ++++++
 drivers/common/sfc_efx/base/efx.h       | 1 +
 drivers/common/sfc_efx/base/siena_nic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index e1709d1200..501ce2e37c 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1227,6 +1227,12 @@ ef10_get_datapath_caps(
 	else
 		encp->enc_init_evq_extended_width_supported = B_FALSE;
 
+	/* Check if firmware supports VLAN stripping. */
+	if (CAP_FLAGS1(req, RX_VLAN_STRIPPING))
+		encp->enc_rx_vlan_stripping = B_TRUE;
+	else
+		encp->enc_rx_vlan_stripping = B_FALSE;
+
 	/*
 	 * Check if the NO_CONT_EV mode for RX events is supported.
 	 */
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 49e29dcc1c..ac89b418e0 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1638,6 +1638,7 @@ typedef struct efx_nic_cfg_s {
 	boolean_t		enc_pm_and_rxdp_counters;
 	boolean_t		enc_mac_stats_40g_tx_size_bins;
 	uint32_t		enc_tunnel_encapsulations_supported;
+	boolean_t		enc_rx_vlan_stripping;
 	/*
 	 * NIC global maximum for unique UDP tunnel ports shared by all
 	 * functions.
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index 9f14faf271..451ca81bd7 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -189,6 +189,7 @@ siena_board_cfg(
 	encp->enc_rx_var_packed_stream_supported = B_FALSE;
 	encp->enc_rx_es_super_buffer_supported = B_FALSE;
 	encp->enc_fw_subvariant_no_tx_csum_supported = B_FALSE;
+	encp->enc_rx_vlan_stripping = B_FALSE;
 
 	/* Siena supports two 10G ports, and 8 lanes of PCIe Gen2 */
 	encp->enc_required_pcie_bandwidth_mbps = 2 * 10000;
-- 
2.34.1


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

* [PATCH v3 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-01 14:35       ` [PATCH v3 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-06-01 14:35         ` [PATCH v3 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-01 14:35         ` Artemii Morozov
  2023-06-01 14:35         ` [PATCH v3 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01 14:35 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

To enable VLAN stripping, two conditions must be met:
the corresponding flag must be set and the appropriate
RX prefix should be requested.
VLAN stripping is supported for ef100 datapath only.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  1 +
 drivers/common/sfc_efx/base/efx.h         |  9 +++++++++
 drivers/common/sfc_efx/base/efx_filter.c  |  3 ++-
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_rx.c      | 17 +++++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 7 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index d6940011c0..7371451098 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -338,6 +338,11 @@ efx_mcdi_filter_op_add(
 		    FILTER_OP_V3_IN_MATCH_SET_FLAG, 1);
 	}
 
+	if (spec->efs_flags & EFX_FILTER_FLAG_VLAN_STRIP) {
+		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
+			FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);
+	}
+
 	efx_mcdi_execute(enp, &req);
 
 	if (req.emr_rc != 0) {
@@ -852,6 +857,16 @@ ef10_filter_add_internal(
 
 	hash = ef10_filter_hash(spec);
 
+	/*
+	 * VLAN stripping is offload at the device level, and it should be
+	 * applied to all filters if it has been applied at least once before.
+	 * Knowledge of device level vlan strip offload being enabled comes from
+	 * the default RxQ flags, albeit the flag may be set on any queue.
+	 * But only default RxQ affects this 'eft_strip_vlan' decision.
+	 */
+	if (eftp->eft_strip_vlan)
+		spec->efs_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
+
 	/*
 	 * FIXME: Add support for inserting filters of different priorities
 	 * and removing lower priority multicast filters (bug 42378)
@@ -2010,6 +2025,9 @@ ef10_filter_reconfigure(
 	else
 		filter_flags = 0;
 
+	if (table->eft_strip_vlan)
+		filter_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
+
 	/* Mark old filters which may need to be removed */
 	ef10_filter_mark_old_filters(enp);
 
@@ -2142,6 +2160,8 @@ ef10_filter_default_rxq_set(
 	EFSYS_ASSERT(using_rss == B_FALSE);
 	table->eft_using_rss = B_FALSE;
 #endif
+	if (erp->er_flags & EFX_RXQ_FLAG_VLAN_STRIP)
+		table->eft_strip_vlan = B_TRUE;
 	table->eft_default_rxq = erp;
 }
 
@@ -2153,6 +2173,7 @@ ef10_filter_default_rxq_clear(
 
 	table->eft_default_rxq = NULL;
 	table->eft_using_rss = B_FALSE;
+	table->eft_strip_vlan = B_FALSE;
 }
 
 
diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
index 877aedad45..017e561f19 100644
--- a/drivers/common/sfc_efx/base/ef10_impl.h
+++ b/drivers/common/sfc_efx/base/ef10_impl.h
@@ -1287,6 +1287,7 @@ typedef struct ef10_filter_table_s {
 	ef10_filter_entry_t	eft_entry[EFX_EF10_FILTER_TBL_ROWS];
 	efx_rxq_t		*eft_default_rxq;
 	boolean_t		eft_using_rss;
+	boolean_t		eft_strip_vlan;
 	uint32_t		eft_unicst_filter_indexes[
 	    EFX_EF10_FILTER_UNICAST_FILTERS_MAX];
 	uint32_t		eft_unicst_filter_count;
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index ac89b418e0..508d0a802d 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -3101,6 +3101,10 @@ typedef enum efx_rxq_type_e {
  * Request user flag field in the Rx prefix of a queue.
  */
 #define	EFX_RXQ_FLAG_USER_FLAG		0x20
+/*
+ * Request vlan tci field in the Rx prefix of a queue.
+ */
+#define	EFX_RXQ_FLAG_VLAN_STRIP		0x40
 
 LIBEFX_API
 extern	__checkReturn	efx_rc_t
@@ -3455,6 +3459,11 @@ efx_tx_qdestroy(
 #define	EFX_FILTER_FLAG_ACTION_FLAG	0x20
 /* Set match mark on the received packet */
 #define	EFX_FILTER_FLAG_ACTION_MARK	0x40
+/*
+ * Request that the first tag in the outer L2 header be stripped
+ * and TCI be indicated in Rx prefix.
+ */
+#define	EFX_FILTER_FLAG_VLAN_STRIP	0x80
 
 typedef uint8_t efx_filter_flags_t;
 
diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
index 83c37ff859..778ed0c370 100644
--- a/drivers/common/sfc_efx/base/efx_filter.c
+++ b/drivers/common/sfc_efx/base/efx_filter.c
@@ -322,7 +322,8 @@ efx_filter_spec_init_rx(
 	EFSYS_ASSERT3P(spec, !=, NULL);
 	EFSYS_ASSERT3P(erp, !=, NULL);
 	EFSYS_ASSERT((flags & ~(EFX_FILTER_FLAG_RX_RSS |
-				EFX_FILTER_FLAG_RX_SCATTER)) == 0);
+				EFX_FILTER_FLAG_RX_SCATTER |
+				EFX_FILTER_FLAG_VLAN_STRIP)) == 0);
 
 	memset(spec, 0, sizeof (*spec));
 	spec->efs_priority = priority;
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 45e99d01c5..c45669e077 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -1045,6 +1045,7 @@ struct efx_rxq_s {
 	efsys_mem_t			*er_esmp;
 	efx_evq_rxq_state_t		*er_ev_qstate;
 	efx_rx_prefix_layout_t		er_prefix_layout;
+	uint16_t			er_flags;
 };
 
 #define	EFX_RXQ_MAGIC	0x15022005
diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
index 61726a9f0b..55ffa82033 100644
--- a/drivers/common/sfc_efx/base/efx_rx.c
+++ b/drivers/common/sfc_efx/base/efx_rx.c
@@ -925,6 +925,7 @@ efx_rx_qcreate_internal(
 	erp->er_index = index;
 	erp->er_mask = ndescs - 1;
 	erp->er_esmp = esmp;
+	erp->er_flags = 0;
 
 	if ((rc = erxop->erxo_qcreate(enp, index, label, type, type_data, esmp,
 	    ndescs, id, flags, eep, erp)) != 0)
@@ -943,11 +944,27 @@ efx_rx_qcreate_internal(
 		}
 	}
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIP) {
+		const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout;
+		const efx_rx_prefix_field_info_t *vlan_tci_field;
+
+		vlan_tci_field =
+		    &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI];
+		if (vlan_tci_field->erpfi_width_bits == 0) {
+			rc = ENOTSUP;
+			goto fail6;
+		}
+
+		erp->er_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
+	}
+
 	enp->en_rx_qcount++;
 	*erpp = erp;
 
 	return (0);
 
+fail6:
+	EFSYS_PROBE(fail6);
 fail5:
 	EFSYS_PROBE(fail5);
 
diff --git a/drivers/common/sfc_efx/base/rhead_rx.c b/drivers/common/sfc_efx/base/rhead_rx.c
index d0ac5c02f8..3453227388 100644
--- a/drivers/common/sfc_efx/base/rhead_rx.c
+++ b/drivers/common/sfc_efx/base/rhead_rx.c
@@ -640,6 +640,9 @@ rhead_rx_qcreate(
 	if (flags & EFX_RXQ_FLAG_USER_FLAG)
 		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_USER_FLAG;
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIP)
+		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI;
+
 	/*
 	 * LENGTH is required in EF100 host interface, as receive events
 	 * do not include the packet length.
-- 
2.34.1


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

* [PATCH v3 3/3] net/sfc: support VLAN stripping offload
  2023-06-01 14:35       ` [PATCH v3 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-06-01 14:35         ` [PATCH v3 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
  2023-06-01 14:35         ` [PATCH v3 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-01 14:35         ` Artemii Morozov
  2 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01 14:35 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

Extract vlan tci provided by the HW in the prefix and put it to mbuf.
VLAN stripping is supported for ef100 datapath only.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 doc/guides/nics/sfc_efx.rst    |  4 ++--
 drivers/net/sfc/sfc_ef100_rx.c | 21 ++++++++++++++++++++-
 drivers/net/sfc/sfc_rx.c       | 19 +++++++++++++++++++
 3 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index de0656876b..44fa24e1ba 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -118,6 +118,8 @@ SFC EFX PMD has support for:
 
 - Port representors (see :ref: switch_representation)
 
+- VLAN stripping (if running firmware variant supports it)
+
 
 Non-supported Features
 ----------------------
@@ -132,8 +134,6 @@ The features not yet supported include:
 
 - VLAN filtering
 
-- VLAN stripping
-
 - LRO
 
 
diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index 37b754fa33..e323156a26 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -68,6 +68,7 @@ struct sfc_ef100_rxq {
 #define SFC_EF100_RXQ_INGRESS_MPORT	0x80
 #define SFC_EF100_RXQ_USER_FLAG		0x100
 #define SFC_EF100_RXQ_NIC_DMA_MAP	0x200
+#define SFC_EF100_RXQ_VLAN_STRIP	0x400
 	unsigned int			ptr_mask;
 	unsigned int			evq_phase_bit_shift;
 	unsigned int			ready_pkts;
@@ -392,6 +393,7 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
 		SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
+		SFC_EF100_RX_PREFIX_FIELD(VLAN_STRIP_TCI, B_FALSE),
 
 #undef	SFC_EF100_RX_PREFIX_FIELD
 	}
@@ -472,6 +474,17 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
 						ESF_GZ_RX_PREFIX_INGRESS_MPORT);
 	}
 
+	if (rxq->flags & SFC_EF100_RXQ_VLAN_STRIP) {
+		uint32_t vlan_stripped;
+		vlan_stripped = EFX_XWORD_FIELD(rx_prefix[0], ESF_GZ_RX_PREFIX_VLAN_STRIPPED);
+
+		if (vlan_stripped != 0) {
+			ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+			m->vlan_tci = EFX_XWORD_FIELD(rx_prefix[0],
+							ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI);
+		}
+	}
+
 	m->ol_flags = ol_flags;
 	return true;
 }
@@ -892,6 +905,12 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
 	    (rxq->flags & SFC_EF100_RXQ_INGRESS_MPORT))
 		return ENOTSUP;
 
+	if ((unsup_rx_prefix_fields &
+	     (1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI)) == 0)
+		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIP;
+	else
+		rxq->flags &= ~SFC_EF100_RXQ_VLAN_STRIP;
+
 	rxq->prefix_size = pinfo->erpl_length;
 	rxq->rearm_data = sfc_ef100_mk_mbuf_rearm_data(rxq->dp.dpq.port_id,
 						       rxq->prefix_size);
@@ -1004,7 +1023,7 @@ struct sfc_dp_rx sfc_ef100_rx = {
 				  SFC_DP_RX_FEAT_FLOW_MARK |
 				  SFC_DP_RX_FEAT_INTR |
 				  SFC_DP_RX_FEAT_STATS,
-	.dev_offload_capa	= 0,
+	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_VLAN_STRIP,
 	.queue_offload_capa	= RTE_ETH_RX_OFFLOAD_CHECKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index edd0f0c038..e9ef1d92ed 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -938,6 +938,9 @@ sfc_rx_get_offload_mask(struct sfc_adapter *sa)
 	if (encp->enc_tunnel_encapsulations_supported == 0)
 		no_caps |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
+	if (encp->enc_rx_vlan_stripping == 0)
+		no_caps |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
+
 	return ~no_caps;
 }
 
@@ -1186,6 +1189,16 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH)
 		rxq_info->type_flags |= EFX_RXQ_FLAG_RSS_HASH;
 
+
+	if (sa->eth_dev->data->dev_conf.rxmode.offloads &
+	    RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		rxq_info->type_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
+	} else if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		sfc_err(sa, "VLAN stripping must be configured during device configure");
+		rc = EINVAL;
+		goto fail_bad_conf;
+	}
+
 	if ((sa->negotiated_rx_metadata & RTE_ETH_RX_METADATA_USER_FLAG) != 0)
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_FLAG;
 
@@ -1691,6 +1704,12 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 	}
 
+	if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) &&
+	    (~offloads_supported & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)) {
+		sfc_err(sa, "VLAN stripping offload is requested but not supported");
+		rc = ENOTSUP;
+	}
+
 	return rc;
 }
 
-- 
2.34.1


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

* [PATCH v4 0/3] net/sfc: support VLAN stripping offload
  2023-05-31 13:41 [PATCH 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
                   ` (2 preceding siblings ...)
  2023-05-31 13:41 ` [PATCH 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
@ 2023-06-01 15:30 ` Artemii Morozov
  2023-06-01 15:30   ` [PATCH v4 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
                     ` (2 more replies)
  2023-06-13 15:12 ` [PATCH v5 0/3] " Artemii Morozov
                   ` (3 subsequent siblings)
  7 siblings, 3 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01 15:30 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This patch series adds VLAN stripping offload. Note that this
offload are device level offload.

v4:
  * fix apply patch failure warning

v3:
  * fix apply patch failure warning

v2:
  * rebase patches on top of dpdk-next-net/main


Artemii Morozov (3):
  common/sfc_efx/base: report VLAN stripping capability
  common/sfc_efx/base: add support to enable VLAN stripping
  net/sfc: support VLAN stripping offload

 doc/guides/nics/sfc_efx.rst               |  4 ++--
 drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  1 +
 drivers/common/sfc_efx/base/ef10_nic.c    |  6 ++++++
 drivers/common/sfc_efx/base/efx.h         | 10 ++++++++++
 drivers/common/sfc_efx/base/efx_filter.c  |  3 ++-
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_rx.c      | 17 +++++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 drivers/common/sfc_efx/base/siena_nic.c   |  1 +
 drivers/net/sfc/sfc_ef100_rx.c            | 21 ++++++++++++++++++++-
 drivers/net/sfc/sfc_rx.c                  | 19 +++++++++++++++++++
 12 files changed, 103 insertions(+), 4 deletions(-)

-- 
2.34.1


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

* [PATCH v4 1/3] common/sfc_efx/base: report VLAN stripping capability
  2023-06-01 15:30 ` [PATCH v4 0/3] " Artemii Morozov
@ 2023-06-01 15:30   ` Artemii Morozov
  2023-06-02  7:22     ` Andrew Rybchenko
  2023-06-01 15:30   ` [PATCH v4 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
  2023-06-01 15:30   ` [PATCH v4 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01 15:30 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

These changes are necessary in order to add support for stripping
VLAN tags in the future.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 6 ++++++
 drivers/common/sfc_efx/base/efx.h       | 1 +
 drivers/common/sfc_efx/base/siena_nic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index e1709d1200..501ce2e37c 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1227,6 +1227,12 @@ ef10_get_datapath_caps(
 	else
 		encp->enc_init_evq_extended_width_supported = B_FALSE;
 
+	/* Check if firmware supports VLAN stripping. */
+	if (CAP_FLAGS1(req, RX_VLAN_STRIPPING))
+		encp->enc_rx_vlan_stripping = B_TRUE;
+	else
+		encp->enc_rx_vlan_stripping = B_FALSE;
+
 	/*
 	 * Check if the NO_CONT_EV mode for RX events is supported.
 	 */
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 49e29dcc1c..ac89b418e0 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1638,6 +1638,7 @@ typedef struct efx_nic_cfg_s {
 	boolean_t		enc_pm_and_rxdp_counters;
 	boolean_t		enc_mac_stats_40g_tx_size_bins;
 	uint32_t		enc_tunnel_encapsulations_supported;
+	boolean_t		enc_rx_vlan_stripping;
 	/*
 	 * NIC global maximum for unique UDP tunnel ports shared by all
 	 * functions.
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index 9f14faf271..451ca81bd7 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -189,6 +189,7 @@ siena_board_cfg(
 	encp->enc_rx_var_packed_stream_supported = B_FALSE;
 	encp->enc_rx_es_super_buffer_supported = B_FALSE;
 	encp->enc_fw_subvariant_no_tx_csum_supported = B_FALSE;
+	encp->enc_rx_vlan_stripping = B_FALSE;
 
 	/* Siena supports two 10G ports, and 8 lanes of PCIe Gen2 */
 	encp->enc_required_pcie_bandwidth_mbps = 2 * 10000;
-- 
2.34.1


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

* [PATCH v4 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-01 15:30 ` [PATCH v4 0/3] " Artemii Morozov
  2023-06-01 15:30   ` [PATCH v4 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-01 15:30   ` Artemii Morozov
  2023-06-02  8:32     ` Andrew Rybchenko
  2023-06-01 15:30   ` [PATCH v4 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01 15:30 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

To enable VLAN stripping, two conditions must be met:
the corresponding flag must be set and the appropriate
RX prefix should be requested.
VLAN stripping is supported for ef100 datapath only.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  1 +
 drivers/common/sfc_efx/base/efx.h         |  9 +++++++++
 drivers/common/sfc_efx/base/efx_filter.c  |  3 ++-
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_rx.c      | 17 +++++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 7 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index 6d19797d16..6371d8d489 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -338,6 +338,11 @@ efx_mcdi_filter_op_add(
 		    MC_CMD_FILTER_OP_V3_IN_MATCH_ACTION_FLAG);
 	}
 
+	if (spec->efs_flags & EFX_FILTER_FLAG_VLAN_STRIP) {
+		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
+			FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);
+	}
+
 	efx_mcdi_execute(enp, &req);
 
 	if (req.emr_rc != 0) {
@@ -852,6 +857,16 @@ ef10_filter_add_internal(
 
 	hash = ef10_filter_hash(spec);
 
+	/*
+	 * VLAN stripping is offload at the device level, and it should be
+	 * applied to all filters if it has been applied at least once before.
+	 * Knowledge of device level vlan strip offload being enabled comes from
+	 * the default RxQ flags, albeit the flag may be set on any queue.
+	 * But only default RxQ affects this 'eft_strip_vlan' decision.
+	 */
+	if (eftp->eft_strip_vlan)
+		spec->efs_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
+
 	/*
 	 * FIXME: Add support for inserting filters of different priorities
 	 * and removing lower priority multicast filters (bug 42378)
@@ -2010,6 +2025,9 @@ ef10_filter_reconfigure(
 	else
 		filter_flags = 0;
 
+	if (table->eft_strip_vlan)
+		filter_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
+
 	/* Mark old filters which may need to be removed */
 	ef10_filter_mark_old_filters(enp);
 
@@ -2142,6 +2160,8 @@ ef10_filter_default_rxq_set(
 	EFSYS_ASSERT(using_rss == B_FALSE);
 	table->eft_using_rss = B_FALSE;
 #endif
+	if (erp->er_flags & EFX_RXQ_FLAG_VLAN_STRIP)
+		table->eft_strip_vlan = B_TRUE;
 	table->eft_default_rxq = erp;
 }
 
@@ -2153,6 +2173,7 @@ ef10_filter_default_rxq_clear(
 
 	table->eft_default_rxq = NULL;
 	table->eft_using_rss = B_FALSE;
+	table->eft_strip_vlan = B_FALSE;
 }
 
 
diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
index 877aedad45..017e561f19 100644
--- a/drivers/common/sfc_efx/base/ef10_impl.h
+++ b/drivers/common/sfc_efx/base/ef10_impl.h
@@ -1287,6 +1287,7 @@ typedef struct ef10_filter_table_s {
 	ef10_filter_entry_t	eft_entry[EFX_EF10_FILTER_TBL_ROWS];
 	efx_rxq_t		*eft_default_rxq;
 	boolean_t		eft_using_rss;
+	boolean_t		eft_strip_vlan;
 	uint32_t		eft_unicst_filter_indexes[
 	    EFX_EF10_FILTER_UNICAST_FILTERS_MAX];
 	uint32_t		eft_unicst_filter_count;
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index ac89b418e0..508d0a802d 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -3101,6 +3101,10 @@ typedef enum efx_rxq_type_e {
  * Request user flag field in the Rx prefix of a queue.
  */
 #define	EFX_RXQ_FLAG_USER_FLAG		0x20
+/*
+ * Request vlan tci field in the Rx prefix of a queue.
+ */
+#define	EFX_RXQ_FLAG_VLAN_STRIP		0x40
 
 LIBEFX_API
 extern	__checkReturn	efx_rc_t
@@ -3455,6 +3459,11 @@ efx_tx_qdestroy(
 #define	EFX_FILTER_FLAG_ACTION_FLAG	0x20
 /* Set match mark on the received packet */
 #define	EFX_FILTER_FLAG_ACTION_MARK	0x40
+/*
+ * Request that the first tag in the outer L2 header be stripped
+ * and TCI be indicated in Rx prefix.
+ */
+#define	EFX_FILTER_FLAG_VLAN_STRIP	0x80
 
 typedef uint8_t efx_filter_flags_t;
 
diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
index 83c37ff859..778ed0c370 100644
--- a/drivers/common/sfc_efx/base/efx_filter.c
+++ b/drivers/common/sfc_efx/base/efx_filter.c
@@ -322,7 +322,8 @@ efx_filter_spec_init_rx(
 	EFSYS_ASSERT3P(spec, !=, NULL);
 	EFSYS_ASSERT3P(erp, !=, NULL);
 	EFSYS_ASSERT((flags & ~(EFX_FILTER_FLAG_RX_RSS |
-				EFX_FILTER_FLAG_RX_SCATTER)) == 0);
+				EFX_FILTER_FLAG_RX_SCATTER |
+				EFX_FILTER_FLAG_VLAN_STRIP)) == 0);
 
 	memset(spec, 0, sizeof (*spec));
 	spec->efs_priority = priority;
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 45e99d01c5..c45669e077 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -1045,6 +1045,7 @@ struct efx_rxq_s {
 	efsys_mem_t			*er_esmp;
 	efx_evq_rxq_state_t		*er_ev_qstate;
 	efx_rx_prefix_layout_t		er_prefix_layout;
+	uint16_t			er_flags;
 };
 
 #define	EFX_RXQ_MAGIC	0x15022005
diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
index 68f42f5cac..5726085953 100644
--- a/drivers/common/sfc_efx/base/efx_rx.c
+++ b/drivers/common/sfc_efx/base/efx_rx.c
@@ -925,6 +925,7 @@ efx_rx_qcreate_internal(
 	erp->er_index = index;
 	erp->er_mask = ndescs - 1;
 	erp->er_esmp = esmp;
+	erp->er_flags = 0;
 
 	if ((rc = erxop->erxo_qcreate(enp, index, label, type, type_data, esmp,
 	    ndescs, id, flags, eep, erp)) != 0)
@@ -941,11 +942,27 @@ efx_rx_qcreate_internal(
 			goto fail5;
 	}
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIP) {
+		const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout;
+		const efx_rx_prefix_field_info_t *vlan_tci_field;
+
+		vlan_tci_field =
+		    &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI];
+		if (vlan_tci_field->erpfi_width_bits == 0) {
+			rc = ENOTSUP;
+			goto fail6;
+		}
+
+		erp->er_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
+	}
+
 	enp->en_rx_qcount++;
 	*erpp = erp;
 
 	return (0);
 
+fail6:
+	EFSYS_PROBE(fail6);
 fail5:
 	EFSYS_PROBE(fail5);
 
diff --git a/drivers/common/sfc_efx/base/rhead_rx.c b/drivers/common/sfc_efx/base/rhead_rx.c
index d0ac5c02f8..3453227388 100644
--- a/drivers/common/sfc_efx/base/rhead_rx.c
+++ b/drivers/common/sfc_efx/base/rhead_rx.c
@@ -640,6 +640,9 @@ rhead_rx_qcreate(
 	if (flags & EFX_RXQ_FLAG_USER_FLAG)
 		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_USER_FLAG;
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIP)
+		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI;
+
 	/*
 	 * LENGTH is required in EF100 host interface, as receive events
 	 * do not include the packet length.
-- 
2.34.1


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

* [PATCH v4 3/3] net/sfc: support VLAN stripping offload
  2023-06-01 15:30 ` [PATCH v4 0/3] " Artemii Morozov
  2023-06-01 15:30   ` [PATCH v4 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
  2023-06-01 15:30   ` [PATCH v4 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-01 15:30   ` Artemii Morozov
  2023-06-02  8:46     ` Andrew Rybchenko
  2 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-01 15:30 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

Extract vlan tci provided by the HW in the prefix and put it to mbuf.
VLAN stripping is supported for ef100 datapath only.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 doc/guides/nics/sfc_efx.rst    |  4 ++--
 drivers/net/sfc/sfc_ef100_rx.c | 21 ++++++++++++++++++++-
 drivers/net/sfc/sfc_rx.c       | 19 +++++++++++++++++++
 3 files changed, 41 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index de0656876b..44fa24e1ba 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -118,6 +118,8 @@ SFC EFX PMD has support for:
 
 - Port representors (see :ref: switch_representation)
 
+- VLAN stripping (if running firmware variant supports it)
+
 
 Non-supported Features
 ----------------------
@@ -132,8 +134,6 @@ The features not yet supported include:
 
 - VLAN filtering
 
-- VLAN stripping
-
 - LRO
 
 
diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index 37b754fa33..e323156a26 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -68,6 +68,7 @@ struct sfc_ef100_rxq {
 #define SFC_EF100_RXQ_INGRESS_MPORT	0x80
 #define SFC_EF100_RXQ_USER_FLAG		0x100
 #define SFC_EF100_RXQ_NIC_DMA_MAP	0x200
+#define SFC_EF100_RXQ_VLAN_STRIP	0x400
 	unsigned int			ptr_mask;
 	unsigned int			evq_phase_bit_shift;
 	unsigned int			ready_pkts;
@@ -392,6 +393,7 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
 		SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
+		SFC_EF100_RX_PREFIX_FIELD(VLAN_STRIP_TCI, B_FALSE),
 
 #undef	SFC_EF100_RX_PREFIX_FIELD
 	}
@@ -472,6 +474,17 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
 						ESF_GZ_RX_PREFIX_INGRESS_MPORT);
 	}
 
+	if (rxq->flags & SFC_EF100_RXQ_VLAN_STRIP) {
+		uint32_t vlan_stripped;
+		vlan_stripped = EFX_XWORD_FIELD(rx_prefix[0], ESF_GZ_RX_PREFIX_VLAN_STRIPPED);
+
+		if (vlan_stripped != 0) {
+			ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+			m->vlan_tci = EFX_XWORD_FIELD(rx_prefix[0],
+							ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI);
+		}
+	}
+
 	m->ol_flags = ol_flags;
 	return true;
 }
@@ -892,6 +905,12 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
 	    (rxq->flags & SFC_EF100_RXQ_INGRESS_MPORT))
 		return ENOTSUP;
 
+	if ((unsup_rx_prefix_fields &
+	     (1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI)) == 0)
+		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIP;
+	else
+		rxq->flags &= ~SFC_EF100_RXQ_VLAN_STRIP;
+
 	rxq->prefix_size = pinfo->erpl_length;
 	rxq->rearm_data = sfc_ef100_mk_mbuf_rearm_data(rxq->dp.dpq.port_id,
 						       rxq->prefix_size);
@@ -1004,7 +1023,7 @@ struct sfc_dp_rx sfc_ef100_rx = {
 				  SFC_DP_RX_FEAT_FLOW_MARK |
 				  SFC_DP_RX_FEAT_INTR |
 				  SFC_DP_RX_FEAT_STATS,
-	.dev_offload_capa	= 0,
+	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_VLAN_STRIP,
 	.queue_offload_capa	= RTE_ETH_RX_OFFLOAD_CHECKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index edd0f0c038..e9ef1d92ed 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -938,6 +938,9 @@ sfc_rx_get_offload_mask(struct sfc_adapter *sa)
 	if (encp->enc_tunnel_encapsulations_supported == 0)
 		no_caps |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
+	if (encp->enc_rx_vlan_stripping == 0)
+		no_caps |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
+
 	return ~no_caps;
 }
 
@@ -1186,6 +1189,16 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH)
 		rxq_info->type_flags |= EFX_RXQ_FLAG_RSS_HASH;
 
+
+	if (sa->eth_dev->data->dev_conf.rxmode.offloads &
+	    RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		rxq_info->type_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
+	} else if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
+		sfc_err(sa, "VLAN stripping must be configured during device configure");
+		rc = EINVAL;
+		goto fail_bad_conf;
+	}
+
 	if ((sa->negotiated_rx_metadata & RTE_ETH_RX_METADATA_USER_FLAG) != 0)
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_FLAG;
 
@@ -1691,6 +1704,12 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
 		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 	}
 
+	if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) &&
+	    (~offloads_supported & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)) {
+		sfc_err(sa, "VLAN stripping offload is requested but not supported");
+		rc = ENOTSUP;
+	}
+
 	return rc;
 }
 
-- 
2.34.1


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

* Re: [PATCH v4 1/3] common/sfc_efx/base: report VLAN stripping capability
  2023-06-01 15:30   ` [PATCH v4 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-02  7:22     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-02  7:22 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/1/23 18:30, Artemii Morozov wrote:
> These changes are necessary in order to add support for stripping
> VLAN tags in the future.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
> ---
>   drivers/common/sfc_efx/base/ef10_nic.c  | 6 ++++++
>   drivers/common/sfc_efx/base/efx.h       | 1 +
>   drivers/common/sfc_efx/base/siena_nic.c | 1 +
>   3 files changed, 8 insertions(+)
> 
> diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
> index e1709d1200..501ce2e37c 100644
> --- a/drivers/common/sfc_efx/base/ef10_nic.c
> +++ b/drivers/common/sfc_efx/base/ef10_nic.c
> @@ -1227,6 +1227,12 @@ ef10_get_datapath_caps(
>   	else
>   		encp->enc_init_evq_extended_width_supported = B_FALSE;
>   
> +	/* Check if firmware supports VLAN stripping. */
> +	if (CAP_FLAGS1(req, RX_VLAN_STRIPPING))
> +		encp->enc_rx_vlan_stripping = B_TRUE;
> +	else
> +		encp->enc_rx_vlan_stripping = B_FALSE;
> +

I'd like to understand the logic how the place is chosen.
Here it is put between two EvQ related flags. Why?
Also as far as I can see it is not about alphabetical order.
It is not at the end of the list.
I perfectly realize that the order here is far from ideal,
but chosen place is very-very strange.
Since we have no requirement to put at the end of the list,
it should be nearby TX_VLAN_INSERTION since these flags are
close in MCDI header and logically related.

>   	/*
>   	 * Check if the NO_CONT_EV mode for RX events is supported.
>   	 */
> diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
> index 49e29dcc1c..ac89b418e0 100644
> --- a/drivers/common/sfc_efx/base/efx.h
> +++ b/drivers/common/sfc_efx/base/efx.h
> @@ -1638,6 +1638,7 @@ typedef struct efx_nic_cfg_s {
>   	boolean_t		enc_pm_and_rxdp_counters;
>   	boolean_t		enc_mac_stats_40g_tx_size_bins;
>   	uint32_t		enc_tunnel_encapsulations_supported;
> +	boolean_t		enc_rx_vlan_stripping;

Here it is put between two tunnel related flags. Why?
Basically above thoughts are applicable here as well.
Moreover there is a hole just after enc_hw_tx_insert_vlan_enabled.

Naming is a separate question. It is definitely inconsistent
vs naming of boolean flags in the structure. The majority of
flags are either _enabled or _supported. As I understand it
should be _supported in this case.

IMHO, _hw_ is redundant in enc_hw_tx_insert_vlan_enabled, so,
we don't need it here as well.

>   	/*
>   	 * NIC global maximum for unique UDP tunnel ports shared by all
>   	 * functions.
> diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
> index 9f14faf271..451ca81bd7 100644
> --- a/drivers/common/sfc_efx/base/siena_nic.c
> +++ b/drivers/common/sfc_efx/base/siena_nic.c
> @@ -189,6 +189,7 @@ siena_board_cfg(
>   	encp->enc_rx_var_packed_stream_supported = B_FALSE;
>   	encp->enc_rx_es_super_buffer_supported = B_FALSE;
>   	encp->enc_fw_subvariant_no_tx_csum_supported = B_FALSE;
> +	encp->enc_rx_vlan_stripping = B_FALSE;
>   
>   	/* Siena supports two 10G ports, and 8 lanes of PCIe Gen2 */
>   	encp->enc_required_pcie_bandwidth_mbps = 2 * 10000;


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

* Re: [PATCH v4 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-01 15:30   ` [PATCH v4 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-02  8:32     ` Andrew Rybchenko
  2023-06-08 11:16       ` Artemii Morozov
  0 siblings, 1 reply; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-02  8:32 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/1/23 18:30, Artemii Morozov wrote:
> To enable VLAN stripping, two conditions must be met:
> the corresponding flag must be set and the appropriate
> RX prefix should be requested.

RX -> Rx

> VLAN stripping is supported for ef100 datapath only.

When you read below notes carefully, you'll understand that the
patch is very raw yet. There are too many questions below.

The major decision to be made is if libefx API should enforce
device level offload or should just provide transparent API and
driver must be responsible for consistency.

If driver must be responsible for consistency, don't try to
enforce VLAN stripping enable via filter table. RxQ flags
should control stripped VLAN delivery. Filter flag and default
RxQ set flag (API should be extended) should control VLAN
stripping enabling.

If libefx must guarantee consistency, we need a new way to
enable device level offload early (efx_rx_init()-like, may
be a new API). If so, it should be impossible to control
VLAN stripping per Rx filter. It still could be possible
to control stripped VLAN delivery per RxQ.

Anyway current solution is really inconsistent.

> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
> ---
>   drivers/common/sfc_efx/base/ef10_filter.c | 21 +++++++++++++++++++++
>   drivers/common/sfc_efx/base/ef10_impl.h   |  1 +
>   drivers/common/sfc_efx/base/efx.h         |  9 +++++++++
>   drivers/common/sfc_efx/base/efx_filter.c  |  3 ++-
>   drivers/common/sfc_efx/base/efx_impl.h    |  1 +
>   drivers/common/sfc_efx/base/efx_rx.c      | 17 +++++++++++++++++
>   drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
>   7 files changed, 54 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
> index 6d19797d16..6371d8d489 100644
> --- a/drivers/common/sfc_efx/base/ef10_filter.c
> +++ b/drivers/common/sfc_efx/base/ef10_filter.c
> @@ -338,6 +338,11 @@ efx_mcdi_filter_op_add(
>   		    MC_CMD_FILTER_OP_V3_IN_MATCH_ACTION_FLAG);
>   	}
>   
> +	if (spec->efs_flags & EFX_FILTER_FLAG_VLAN_STRIP) {
> +		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
> +			FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);
> +	}
> +
>   	efx_mcdi_execute(enp, &req);
>   
>   	if (req.emr_rc != 0) {
> @@ -852,6 +857,16 @@ ef10_filter_add_internal(
>   
>   	hash = ef10_filter_hash(spec);
>   
> +	/*
> +	 * VLAN stripping is offload at the device level, and it should be
> +	 * applied to all filters if it has been applied at least once before.
> +	 * Knowledge of device level vlan strip offload being enabled comes from

vlan -> VLAN

> +	 * the default RxQ flags, albeit the flag may be set on any queue.
> +	 * But only default RxQ affects this 'eft_strip_vlan' decision.
> +	 */
> +	if (eftp->eft_strip_vlan)
> +		spec->efs_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
> +
>   	/*
>   	 * FIXME: Add support for inserting filters of different priorities
>   	 * and removing lower priority multicast filters (bug 42378)
> @@ -2010,6 +2025,9 @@ ef10_filter_reconfigure(
>   	else
>   		filter_flags = 0;
>   
> +	if (table->eft_strip_vlan)
> +		filter_flags |= EFX_FILTER_FLAG_VLAN_STRIP;
> +
>   	/* Mark old filters which may need to be removed */
>   	ef10_filter_mark_old_filters(enp);
>   
> @@ -2142,6 +2160,8 @@ ef10_filter_default_rxq_set(
>   	EFSYS_ASSERT(using_rss == B_FALSE);
>   	table->eft_using_rss = B_FALSE;
>   #endif
> +	if (erp->er_flags & EFX_RXQ_FLAG_VLAN_STRIP)
> +		table->eft_strip_vlan = B_TRUE;

How to enable VLAN stripping in isolated mode where
API to set default RxQ is not called?

>   	table->eft_default_rxq = erp;
>   }
>   
> @@ -2153,6 +2173,7 @@ ef10_filter_default_rxq_clear(
>   
>   	table->eft_default_rxq = NULL;
>   	table->eft_using_rss = B_FALSE;
> +	table->eft_strip_vlan = B_FALSE;
>   }
>   
>   
> diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
> index 877aedad45..017e561f19 100644
> --- a/drivers/common/sfc_efx/base/ef10_impl.h
> +++ b/drivers/common/sfc_efx/base/ef10_impl.h
> @@ -1287,6 +1287,7 @@ typedef struct ef10_filter_table_s {
>   	ef10_filter_entry_t	eft_entry[EFX_EF10_FILTER_TBL_ROWS];
>   	efx_rxq_t		*eft_default_rxq;
>   	boolean_t		eft_using_rss;
> +	boolean_t		eft_strip_vlan;
>   	uint32_t		eft_unicst_filter_indexes[
>   	    EFX_EF10_FILTER_UNICAST_FILTERS_MAX];
>   	uint32_t		eft_unicst_filter_count;
> diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
> index ac89b418e0..508d0a802d 100644
> --- a/drivers/common/sfc_efx/base/efx.h
> +++ b/drivers/common/sfc_efx/base/efx.h
> @@ -3101,6 +3101,10 @@ typedef enum efx_rxq_type_e {
>    * Request user flag field in the Rx prefix of a queue.
>    */
>   #define	EFX_RXQ_FLAG_USER_FLAG		0x20
> +/*
> + * Request vlan tci field in the Rx prefix of a queue.

vlan -> VLAN, tci -> TCI

The name and comment are a bit misleading. Name sounds like it
controls VLAN stripping on the RxQ.

Consider EFX_RXQ_FLAG_STRIPPED_VLAN to highlight that it
just requests stripped VLAN TCI. Moreover, comment should
say that it does *not* control VLAN stripping. It just
controls delivery of the stripped VLAN TCI if VLAN stripping
is enabled and done for a packet.

However, as far as I can see finally the flag is used to
enable VLAN stripping as well and it is terribly bad since
it adds false expectations on per-RxQ control for the feature.
It the flag should really control Rx VLAN stripping,
comment should say so and explain limitations.

> + */
> +#define	EFX_RXQ_FLAG_VLAN_STRIP		0x40
>   
>   LIBEFX_API
>   extern	__checkReturn	efx_rc_t
> @@ -3455,6 +3459,11 @@ efx_tx_qdestroy(
>   #define	EFX_FILTER_FLAG_ACTION_FLAG	0x20
>   /* Set match mark on the received packet */
>   #define	EFX_FILTER_FLAG_ACTION_MARK	0x40
> +/*
> + * Request that the first tag in the outer L2 header be stripped
> + * and TCI be indicated in Rx prefix.
> + */
> +#define	EFX_FILTER_FLAG_VLAN_STRIP	0x80

The flag allows driver to request Rx VLAN stripping in
some filters only. Is it really intended?

>   
>   typedef uint8_t efx_filter_flags_t;
>   
> diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
> index 83c37ff859..778ed0c370 100644
> --- a/drivers/common/sfc_efx/base/efx_filter.c
> +++ b/drivers/common/sfc_efx/base/efx_filter.c
> @@ -322,7 +322,8 @@ efx_filter_spec_init_rx(
>   	EFSYS_ASSERT3P(spec, !=, NULL);
>   	EFSYS_ASSERT3P(erp, !=, NULL);
>   	EFSYS_ASSERT((flags & ~(EFX_FILTER_FLAG_RX_RSS |
> -				EFX_FILTER_FLAG_RX_SCATTER)) == 0);
> +				EFX_FILTER_FLAG_RX_SCATTER |
> +				EFX_FILTER_FLAG_VLAN_STRIP)) == 0);
>   
>   	memset(spec, 0, sizeof (*spec));
>   	spec->efs_priority = priority;
> diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
> index 45e99d01c5..c45669e077 100644
> --- a/drivers/common/sfc_efx/base/efx_impl.h
> +++ b/drivers/common/sfc_efx/base/efx_impl.h
> @@ -1045,6 +1045,7 @@ struct efx_rxq_s {
>   	efsys_mem_t			*er_esmp;
>   	efx_evq_rxq_state_t		*er_ev_qstate;
>   	efx_rx_prefix_layout_t		er_prefix_layout;
> +	uint16_t			er_flags;

Why is it 16-bit width. It shares typedefs with RxQ create
flags which are unsigned int?

>   };
>   
>   #define	EFX_RXQ_MAGIC	0x15022005
> diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
> index 68f42f5cac..5726085953 100644
> --- a/drivers/common/sfc_efx/base/efx_rx.c
> +++ b/drivers/common/sfc_efx/base/efx_rx.c
> @@ -925,6 +925,7 @@ efx_rx_qcreate_internal(
>   	erp->er_index = index;
>   	erp->er_mask = ndescs - 1;
>   	erp->er_esmp = esmp;
> +	erp->er_flags = 0;
>   
>   	if ((rc = erxop->erxo_qcreate(enp, index, label, type, type_data, esmp,
>   	    ndescs, id, flags, eep, erp)) != 0)
> @@ -941,11 +942,27 @@ efx_rx_qcreate_internal(

As far as I can see it is a bug here since rc is 0, but the
function should fail. Please, submit separate patch with
appropriate Fixes tag.

>   			goto fail5;
>   	}
>   
> +	if (flags & EFX_RXQ_FLAG_VLAN_STRIP) {
> +		const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout;
> +		const efx_rx_prefix_field_info_t *vlan_tci_field;
> +
> +		vlan_tci_field =
> +		    &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI];
> +		if (vlan_tci_field->erpfi_width_bits == 0) {
> +			rc = ENOTSUP;
> +			goto fail6;
> +		}

IMHO support for Rx VLAN stripping capability should be
checked here as well. It is different aspects of the HW
support:
  1. Support for Rx VLAN stripping
  2. Delivery of the stripped VLAN tag

> +
> +		erp->er_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
> +	}
> +
>   	enp->en_rx_qcount++;
>   	*erpp = erp;
>   
>   	return (0);
>   
> +fail6:
> +	EFSYS_PROBE(fail6);
>   fail5:
>   	EFSYS_PROBE(fail5);
>   


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

* Re: [PATCH v4 3/3] net/sfc: support VLAN stripping offload
  2023-06-01 15:30   ` [PATCH v4 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
@ 2023-06-02  8:46     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-02  8:46 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/1/23 18:30, Artemii Morozov wrote:
> Extract vlan tci provided by the HW in the prefix and put it to mbuf.

vlan -> VLAN, tci -> TCI

> VLAN stripping is supported for ef100 datapath only.

It should be highlighted that it is device level offload.

> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>
> ---
>   doc/guides/nics/sfc_efx.rst    |  4 ++--
>   drivers/net/sfc/sfc_ef100_rx.c | 21 ++++++++++++++++++++-
>   drivers/net/sfc/sfc_rx.c       | 19 +++++++++++++++++++

Release notes should be updated to advertise the feature.

>   3 files changed, 41 insertions(+), 3 deletions(-)
> 
> diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
> index de0656876b..44fa24e1ba 100644
> --- a/doc/guides/nics/sfc_efx.rst
> +++ b/doc/guides/nics/sfc_efx.rst
> @@ -118,6 +118,8 @@ SFC EFX PMD has support for:
>   
>   - Port representors (see :ref: switch_representation)
>   
> +- VLAN stripping (if running firmware variant supports it)
> +
>   
>   Non-supported Features
>   ----------------------
> @@ -132,8 +134,6 @@ The features not yet supported include:
>   
>   - VLAN filtering
>   
> -- VLAN stripping
> -
>   - LRO
>   
>   
> diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
> index 37b754fa33..e323156a26 100644
> --- a/drivers/net/sfc/sfc_ef100_rx.c
> +++ b/drivers/net/sfc/sfc_ef100_rx.c
> @@ -68,6 +68,7 @@ struct sfc_ef100_rxq {
>   #define SFC_EF100_RXQ_INGRESS_MPORT	0x80
>   #define SFC_EF100_RXQ_USER_FLAG		0x100
>   #define SFC_EF100_RXQ_NIC_DMA_MAP	0x200
> +#define SFC_EF100_RXQ_VLAN_STRIP	0x400
>   	unsigned int			ptr_mask;
>   	unsigned int			evq_phase_bit_shift;
>   	unsigned int			ready_pkts;
> @@ -392,6 +393,7 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
>   		SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
>   		SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
>   		SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
> +		SFC_EF100_RX_PREFIX_FIELD(VLAN_STRIP_TCI, B_FALSE),
>   
>   #undef	SFC_EF100_RX_PREFIX_FIELD
>   	}
> @@ -472,6 +474,17 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
>   						ESF_GZ_RX_PREFIX_INGRESS_MPORT);
>   	}
>   
> +	if (rxq->flags & SFC_EF100_RXQ_VLAN_STRIP) {
> +		uint32_t vlan_stripped;

Please, add empty line after variable declaration.
IMHO, bool type should be used here.

> +		vlan_stripped = EFX_XWORD_FIELD(rx_prefix[0], ESF_GZ_RX_PREFIX_VLAN_STRIPPED);
> +
> +		if (vlan_stripped != 0) {

No comparison if bool is used.

> +			ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
> +			m->vlan_tci = EFX_XWORD_FIELD(rx_prefix[0],
> +							ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI);
> +		}
> +	}
> +
>   	m->ol_flags = ol_flags;
>   	return true;
>   }
> @@ -892,6 +905,12 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
>   	    (rxq->flags & SFC_EF100_RXQ_INGRESS_MPORT))
>   		return ENOTSUP;
>   
> +	if ((unsup_rx_prefix_fields &
> +	     (1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI)) == 0)

Shouldn't offload enable/disable be taken into account here?
If offload is not enabled, it is better to skip extra read
from Rx prefix and branching on fast path.

> +		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIP;
> +	else
> +		rxq->flags &= ~SFC_EF100_RXQ_VLAN_STRIP;
> +
>   	rxq->prefix_size = pinfo->erpl_length;
>   	rxq->rearm_data = sfc_ef100_mk_mbuf_rearm_data(rxq->dp.dpq.port_id,
>   						       rxq->prefix_size);
> @@ -1004,7 +1023,7 @@ struct sfc_dp_rx sfc_ef100_rx = {
>   				  SFC_DP_RX_FEAT_FLOW_MARK |
>   				  SFC_DP_RX_FEAT_INTR |
>   				  SFC_DP_RX_FEAT_STATS,
> -	.dev_offload_capa	= 0,
> +	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_VLAN_STRIP,
>   	.queue_offload_capa	= RTE_ETH_RX_OFFLOAD_CHECKSUM |
>   				  RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
>   				  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
> diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
> index edd0f0c038..e9ef1d92ed 100644
> --- a/drivers/net/sfc/sfc_rx.c
> +++ b/drivers/net/sfc/sfc_rx.c
> @@ -938,6 +938,9 @@ sfc_rx_get_offload_mask(struct sfc_adapter *sa)
>   	if (encp->enc_tunnel_encapsulations_supported == 0)
>   		no_caps |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
>   
> +	if (encp->enc_rx_vlan_stripping == 0)
> +		no_caps |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
> +
>   	return ~no_caps;
>   }
>   
> @@ -1186,6 +1189,16 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
>   	if (offloads & RTE_ETH_RX_OFFLOAD_RSS_HASH)
>   		rxq_info->type_flags |= EFX_RXQ_FLAG_RSS_HASH;
>   
> +

Too many empty lines

> +	if (sa->eth_dev->data->dev_conf.rxmode.offloads &
> +	    RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
> +		rxq_info->type_flags |= EFX_RXQ_FLAG_VLAN_STRIP;
> +	} else if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) {
> +		sfc_err(sa, "VLAN stripping must be configured during device configure");
> +		rc = EINVAL;
> +		goto fail_bad_conf;

As far as I know generic ethdev code will reject the request
earlier. So, the code is unreachable and dead.

> +	}
> +
>   	if ((sa->negotiated_rx_metadata & RTE_ETH_RX_METADATA_USER_FLAG) != 0)
>   		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_FLAG;
>   
> @@ -1691,6 +1704,12 @@ sfc_rx_check_mode(struct sfc_adapter *sa, struct rte_eth_rxmode *rxmode)
>   		rxmode->offloads |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
>   	}
>   
> +	if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP) &&
> +	    (~offloads_supported & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)) {
> +		sfc_err(sa, "VLAN stripping offload is requested but not supported");
> +		rc = ENOTSUP;
> +	}
> +

If I'm not mistaken generic ethdev code will reject the request
earlier and will not allow to reach the code here.

>   	return rc;
>   }
>   


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

* Re: [PATCH v4 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-02  8:32     ` Andrew Rybchenko
@ 2023-06-08 11:16       ` Artemii Morozov
  2023-06-08 12:37         ` Andrew Rybchenko
  0 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-08 11:16 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton, Andrew Rybchenko

Hello,

On 6/2/23 12:32, Andrew Rybchenko wrote:
> On 6/1/23 18:30, Artemii Morozov wrote:
>> To enable VLAN stripping, two conditions must be met:
>> the corresponding flag must be set and the appropriate
>> RX prefix should be requested.
>
> RX -> Rx
>
>> VLAN stripping is supported for ef100 datapath only.
>
> When you read below notes carefully, you'll understand that the
> patch is very raw yet. There are too many questions below.
>
> The major decision to be made is if libefx API should enforce
> device level offload or should just provide transparent API and
> driver must be responsible for consistency.
>
> If driver must be responsible for consistency, don't try to
> enforce VLAN stripping enable via filter table. RxQ flags
> should control stripped VLAN delivery. Filter flag and default
> RxQ set flag (API should be extended) should control VLAN
> stripping enabling.
>
> If libefx must guarantee consistency, we need a new way to
> enable device level offload early (efx_rx_init()-like, may
> be a new API). If so, it should be impossible to control
> VLAN stripping per Rx filter. It still could be possible
> to control stripped VLAN delivery per RxQ.
>
> Anyway current solution is really inconsistent.

How about the following concept:

1. Add a new negotiated flag for metadata: RTE_ETH_RX_METADATA_VLAN_INFO.

2. Extend the driver to allow requesting the delivery of stripped VLAN 
TCI through the metadata
     negotiation method. This request will internally affect the Rx 
prefix configuration via
     libefx EFX_RXQ_FLAG_VLAN_TCI (or something like that).

3.  Set the corresponding boolean flag in the sfc_port(strip_vlan = 
something like that please advice)
      structure if RTE_ETH_RX_OFFLOAD_VLAN_STRIP is received. Map this 
flag to the corresponding flag in
      efx_nic_t, Then, when generating specs for filters, use the 
boolean flag from efx_nic_t to determine
      the VLAN stripping behavior.

4. Users can request VLAN strip action. If a user does not request this 
action, but the driver detects that
    device-level stripping has been requested, it may implicitly enable 
VLAN stripping for that specific flow
    within the efx_mcdi_filter_op_add function.

In this concept, we allow the enabling of device-level VLAN stripping. 
Points 1 and 2 concern the delivery of stripped VLAN TCI, while points 3 
and 4 pertain to the request for VLAN tag stripping.


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

* Re: [PATCH v4 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-08 11:16       ` Artemii Morozov
@ 2023-06-08 12:37         ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-08 12:37 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/8/23 14:16, Artemii Morozov wrote:
> Hello,
> 
> On 6/2/23 12:32, Andrew Rybchenko wrote:
>> On 6/1/23 18:30, Artemii Morozov wrote:
>>> To enable VLAN stripping, two conditions must be met:
>>> the corresponding flag must be set and the appropriate
>>> RX prefix should be requested.
>>
>> RX -> Rx
>>
>>> VLAN stripping is supported for ef100 datapath only.
>>
>> When you read below notes carefully, you'll understand that the
>> patch is very raw yet. There are too many questions below.
>>
>> The major decision to be made is if libefx API should enforce
>> device level offload or should just provide transparent API and
>> driver must be responsible for consistency.
>>
>> If driver must be responsible for consistency, don't try to
>> enforce VLAN stripping enable via filter table. RxQ flags
>> should control stripped VLAN delivery. Filter flag and default
>> RxQ set flag (API should be extended) should control VLAN
>> stripping enabling.
>>
>> If libefx must guarantee consistency, we need a new way to
>> enable device level offload early (efx_rx_init()-like, may
>> be a new API). If so, it should be impossible to control
>> VLAN stripping per Rx filter. It still could be possible
>> to control stripped VLAN delivery per RxQ.
>>
>> Anyway current solution is really inconsistent.
> 
> How about the following concept:
> 
> 1. Add a new negotiated flag for metadata: RTE_ETH_RX_METADATA_VLAN_INFO.
> 
> 2. Extend the driver to allow requesting the delivery of stripped VLAN 
> TCI through the metadata
>      negotiation method. This request will internally affect the Rx 
> prefix configuration via
>      libefx EFX_RXQ_FLAG_VLAN_TCI (or something like that).
> 
> 3.  Set the corresponding boolean flag in the sfc_port(strip_vlan = 
> something like that please advice)
>       structure if RTE_ETH_RX_OFFLOAD_VLAN_STRIP is received. Map this 
> flag to the corresponding flag in
>       efx_nic_t, Then, when generating specs for filters, use the 
> boolean flag from efx_nic_t to determine
>       the VLAN stripping behavior.
> 
> 4. Users can request VLAN strip action. If a user does not request this 
> action, but the driver detects that
>     device-level stripping has been requested, it may implicitly enable 
> VLAN stripping for that specific flow
>     within the efx_mcdi_filter_op_add function.
> 
> In this concept, we allow the enabling of device-level VLAN stripping. 
> Points 1 and 2 concern the delivery of stripped VLAN TCI, while points 3 
> and 4 pertain to the request for VLAN tag stripping.
> 

It does not reply my questions and I see no single point to
complicate VLAN stripping configuration and introduce
corresponding Rx metadata control. Device-level offload is
sufficient and configured early enough to do its job.


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

* [PATCH v5 0/3] net/sfc: support VLAN stripping offload
  2023-05-31 13:41 [PATCH 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
                   ` (3 preceding siblings ...)
  2023-06-01 15:30 ` [PATCH v4 0/3] " Artemii Morozov
@ 2023-06-13 15:12 ` Artemii Morozov
  2023-06-13 15:12   ` [PATCH v5 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
                     ` (2 more replies)
  2023-06-22 11:31 ` [PATCH v6 0/4] " Artemii Morozov
                   ` (2 subsequent siblings)
  7 siblings, 3 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-13 15:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This patch series adds VLAN stripping offload. Note that this
offload are device level offload.

v5:
  * fixed problems with naming
  * fixed problems with abbreviations
  * fixed problems with isolated mode
  * fixed problems with consistency

v4:
  * fix apply patch failure warning

v3:
  * fix apply patch failure warning

v2:
  * rebase patches on top of dpdk-next-net/main

Artemii Morozov (3):
  common/sfc_efx/base: report VLAN stripping capability
  common/sfc_efx/base: add support to enable VLAN stripping
  net/sfc: support VLAN stripping offload

 doc/guides/nics/sfc_efx.rst               |  4 ++--
 doc/guides/rel_notes/release_23_07.rst    |  6 ++++++
 drivers/common/sfc_efx/base/ef10_filter.c |  6 ++++++
 drivers/common/sfc_efx/base/ef10_nic.c    |  6 ++++++
 drivers/common/sfc_efx/base/efx.h         | 13 +++++++++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_port.c    | 18 ++++++++++++++++++
 drivers/common/sfc_efx/base/efx_rx.c      | 14 ++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 drivers/common/sfc_efx/base/siena_nic.c   |  1 +
 drivers/common/sfc_efx/version.map        |  1 +
 drivers/net/sfc/sfc.h                     |  1 +
 drivers/net/sfc/sfc_ef100_rx.c            | 18 +++++++++++++++++-
 drivers/net/sfc/sfc_port.c                | 12 ++++++++++++
 drivers/net/sfc/sfc_rx.c                  |  7 +++++++
 15 files changed, 108 insertions(+), 3 deletions(-)

-- 
2.34.1


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

* [PATCH v5 1/3] common/sfc_efx/base: report VLAN stripping capability
  2023-06-13 15:12 ` [PATCH v5 0/3] " Artemii Morozov
@ 2023-06-13 15:12   ` Artemii Morozov
  2023-06-19  9:43     ` Andrew Rybchenko
  2023-06-13 15:12   ` [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
  2023-06-13 15:12   ` [PATCH v5 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-13 15:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

These changes are necessary in order to add support for stripping
VLAN tags in the future.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 6 ++++++
 drivers/common/sfc_efx/base/efx.h       | 1 +
 drivers/common/sfc_efx/base/siena_nic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index e1709d1200..070f4d08b5 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1146,6 +1146,12 @@ ef10_get_datapath_caps(
 	else
 		encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
 
+	/* Check if firmware supports VLAN stripping. */
+	if (CAP_FLAGS1(req, RX_VLAN_STRIPPING))
+		encp->enc_rx_vlan_stripping_supported = B_TRUE;
+	else
+		encp->enc_rx_vlan_stripping_supported = B_FALSE;
+
 	/* Check if the firmware supports RX event batching */
 	if (CAP_FLAGS1(req, RX_BATCHING))
 		encp->enc_rx_batching_enabled = B_TRUE;
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 49e29dcc1c..aefd78e646 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1616,6 +1616,7 @@ typedef struct efx_nic_cfg_s {
 	/* Number of TSO contexts on the NIC (FATSOv2) */
 	uint32_t		enc_fw_assisted_tso_v2_n_contexts;
 	boolean_t		enc_hw_tx_insert_vlan_enabled;
+	boolean_t		enc_rx_vlan_stripping_supported;
 	/* Number of PFs on the NIC */
 	uint32_t		enc_hw_pf_count;
 	/* Datapath firmware vadapter/vport/vswitch support */
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index 9f14faf271..4b7f7cbb87 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -179,6 +179,7 @@ siena_board_cfg(
 	    (encp->enc_rxq_limit * EFX_RXQ_DC_NDESCS(EFX_RXQ_DC_SIZE));
 
 	encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
+	encp->enc_rx_vlan_stripping_supported = B_FALSE;
 	encp->enc_fw_assisted_tso_enabled = B_FALSE;
 	encp->enc_fw_assisted_tso_v2_enabled = B_FALSE;
 	encp->enc_fw_assisted_tso_v2_n_contexts = 0;
-- 
2.34.1


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

* [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-13 15:12 ` [PATCH v5 0/3] " Artemii Morozov
  2023-06-13 15:12   ` [PATCH v5 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-13 15:12   ` Artemii Morozov
  2023-06-19 10:28     ` Andrew Rybchenko
  2023-06-13 15:12   ` [PATCH v5 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
  2 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-13 15:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

To enable VLAN stripping, two conditions must be met:
the corresponding flag must be set and the appropriate
RX prefix should be requested.
VLAN stripping is supported for ef100 datapath only.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_filter.c |  6 ++++++
 drivers/common/sfc_efx/base/efx.h         | 12 ++++++++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_port.c    | 18 ++++++++++++++++++
 drivers/common/sfc_efx/base/efx_rx.c      | 14 ++++++++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 +++
 drivers/common/sfc_efx/version.map        |  1 +
 7 files changed, 55 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index d6940011c0..07f561a519 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -171,6 +171,7 @@ efx_mcdi_filter_op_add(
 	EFX_MCDI_DECLARE_BUF(payload, MC_CMD_FILTER_OP_V3_IN_LEN,
 		MC_CMD_FILTER_OP_EXT_OUT_LEN);
 	efx_filter_match_flags_t match_flags;
+	efx_port_t *epp = &(enp->en_port);
 	uint32_t port_id;
 	efx_rc_t rc;
 
@@ -338,6 +339,11 @@ efx_mcdi_filter_op_add(
 		    FILTER_OP_V3_IN_MATCH_SET_FLAG, 1);
 	}
 
+	if (epp->ep_vlan_strip) {
+		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
+			FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);
+	}
+
 	efx_mcdi_execute(enp, &req);
 
 	if (req.emr_rc != 0) {
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index aefd78e646..a17f3f92ba 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1147,6 +1147,12 @@ efx_port_poll(
 	__in		efx_nic_t *enp,
 	__out_opt	efx_link_mode_t	*link_modep);
 
+LIBEFX_API
+extern	__checkReturn	efx_rc_t
+efx_port_vlan_strip_set(
+	__in		efx_nic_t *enp,
+	__in		boolean_t enabled);
+
 LIBEFX_API
 extern		void
 efx_port_fini(
@@ -3101,6 +3107,12 @@ typedef enum efx_rxq_type_e {
  * Request user flag field in the Rx prefix of a queue.
  */
 #define	EFX_RXQ_FLAG_USER_FLAG		0x20
+/*
+ * Request VLAN TCI field in the Rx prefix. The flag just
+ * controls delivery of the stripped VLAN TCI if VLAN stripping
+ * is enabled and done.
+ */
+#define	EFX_RXQ_FLAG_VLAN_STRIPPED_TCI		0x40
 
 LIBEFX_API
 extern	__checkReturn	efx_rc_t
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 45e99d01c5..ed1a4be5ac 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -363,6 +363,7 @@ typedef struct efx_port_s {
 	uint32_t		ep_default_adv_cap_mask;
 	uint32_t		ep_phy_cap_mask;
 	boolean_t		ep_mac_drain;
+	boolean_t		ep_vlan_strip;
 #if EFSYS_OPT_BIST
 	efx_bist_type_t		ep_current_bist;
 #endif
diff --git a/drivers/common/sfc_efx/base/efx_port.c b/drivers/common/sfc_efx/base/efx_port.c
index a5f982e335..7804eb76bc 100644
--- a/drivers/common/sfc_efx/base/efx_port.c
+++ b/drivers/common/sfc_efx/base/efx_port.c
@@ -204,6 +204,24 @@ efx_loopback_type_name(
 
 #endif	/* EFSYS_OPT_LOOPBACK */
 
+	__checkReturn	efx_rc_t
+efx_port_vlan_strip_set(
+	__in		efx_nic_t *enp,
+	__in		boolean_t enabled)
+{
+	efx_port_t *epp = &(enp->en_port);
+	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+
+	if (enabled && !encp->enc_rx_vlan_stripping_supported)
+		return ENOTSUP;
+
+	epp->ep_vlan_strip = enabled;
+
+	return 0;
+}
+
 			void
 efx_port_fini(
 	__in		efx_nic_t *enp)
diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
index 68f42f5cac..b3d9e14c67 100644
--- a/drivers/common/sfc_efx/base/efx_rx.c
+++ b/drivers/common/sfc_efx/base/efx_rx.c
@@ -941,11 +941,25 @@ efx_rx_qcreate_internal(
 			goto fail5;
 	}
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI) {
+		const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout;
+		const efx_rx_prefix_field_info_t *vlan_tci_field;
+
+		vlan_tci_field =
+		    &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI];
+		if (vlan_tci_field->erpfi_width_bits == 0) {
+			rc = ENOTSUP;
+			goto fail6;
+		}
+	}
+
 	enp->en_rx_qcount++;
 	*erpp = erp;
 
 	return (0);
 
+fail6:
+	EFSYS_PROBE(fail6);
 fail5:
 	EFSYS_PROBE(fail5);
 
diff --git a/drivers/common/sfc_efx/base/rhead_rx.c b/drivers/common/sfc_efx/base/rhead_rx.c
index d0ac5c02f8..a86551f646 100644
--- a/drivers/common/sfc_efx/base/rhead_rx.c
+++ b/drivers/common/sfc_efx/base/rhead_rx.c
@@ -640,6 +640,9 @@ rhead_rx_qcreate(
 	if (flags & EFX_RXQ_FLAG_USER_FLAG)
 		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_USER_FLAG;
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI;
+
 	/*
 	 * LENGTH is required in EF100 host interface, as receive events
 	 * do not include the packet length.
diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map
index d9b04a611d..e0d473dc72 100644
--- a/drivers/common/sfc_efx/version.map
+++ b/drivers/common/sfc_efx/version.map
@@ -203,6 +203,7 @@ INTERNAL {
 	efx_port_init;
 	efx_port_loopback_set;
 	efx_port_poll;
+	efx_port_vlan_strip_set;
 
 	efx_pseudo_hdr_hash_get;
 	efx_pseudo_hdr_pkt_length_get;
-- 
2.34.1


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

* [PATCH v5 3/3] net/sfc: support VLAN stripping offload
  2023-06-13 15:12 ` [PATCH v5 0/3] " Artemii Morozov
  2023-06-13 15:12   ` [PATCH v5 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
  2023-06-13 15:12   ` [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-13 15:12   ` Artemii Morozov
  2023-06-19 10:36     ` Andrew Rybchenko
  2 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-13 15:12 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

Extract VLAN TCI provided by the HW in the prefix and put it to mbuf.
VLAN stripping is supported for ef100 datapath only. This is device
level offload.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 doc/guides/nics/sfc_efx.rst            |  4 ++--
 doc/guides/rel_notes/release_23_07.rst |  6 ++++++
 drivers/net/sfc/sfc.h                  |  1 +
 drivers/net/sfc/sfc_ef100_rx.c         | 18 +++++++++++++++++-
 drivers/net/sfc/sfc_port.c             | 12 ++++++++++++
 drivers/net/sfc/sfc_rx.c               |  7 +++++++
 6 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index de0656876b..44fa24e1ba 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -118,6 +118,8 @@ SFC EFX PMD has support for:
 
 - Port representors (see :ref: switch_representation)
 
+- VLAN stripping (if running firmware variant supports it)
+
 
 Non-supported Features
 ----------------------
@@ -132,8 +134,6 @@ The features not yet supported include:
 
 - VLAN filtering
 
-- VLAN stripping
-
 - LRO
 
 
diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst
index 027ae7bd2d..1d3db6ef25 100644
--- a/doc/guides/rel_notes/release_23_07.rst
+++ b/doc/guides/rel_notes/release_23_07.rst
@@ -170,6 +170,12 @@ New Features
 
   See :doc:`../prog_guide/pdcp_lib` for more information.
 
+* **Updated Solarflare network PMD.**
+
+  Updated the Solarflare ``sfc_efx`` driver with changes including:
+
+  * Added VLAN stripping support on SN1000 SmartNICs
+
 
 Removed Items
 -------------
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 730d054aea..81f0212b48 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -71,6 +71,7 @@ struct sfc_port {
 
 	unsigned int			flow_ctrl;
 	boolean_t			flow_ctrl_autoneg;
+	boolean_t			vlan_strip;
 	size_t				pdu;
 
 	/*
diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index 37b754fa33..5259b1cdba 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -68,6 +68,7 @@ struct sfc_ef100_rxq {
 #define SFC_EF100_RXQ_INGRESS_MPORT	0x80
 #define SFC_EF100_RXQ_USER_FLAG		0x100
 #define SFC_EF100_RXQ_NIC_DMA_MAP	0x200
+#define SFC_EF100_RXQ_VLAN_STRIPPED_TCI	0x400
 	unsigned int			ptr_mask;
 	unsigned int			evq_phase_bit_shift;
 	unsigned int			ready_pkts;
@@ -392,6 +393,7 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
 		SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
+		SFC_EF100_RX_PREFIX_FIELD(VLAN_STRIP_TCI, B_FALSE),
 
 #undef	SFC_EF100_RX_PREFIX_FIELD
 	}
@@ -472,6 +474,14 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
 						ESF_GZ_RX_PREFIX_INGRESS_MPORT);
 	}
 
+	if (rxq->flags & SFC_EF100_RXQ_VLAN_STRIPPED_TCI &&
+	    EFX_TEST_XWORD_BIT(rx_prefix[0],
+				   ESF_GZ_RX_PREFIX_VLAN_STRIPPED_LBN)) {
+		ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+		m->vlan_tci = EFX_XWORD_FIELD(rx_prefix[0],
+						ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI);
+	}
+
 	m->ol_flags = ol_flags;
 	return true;
 }
@@ -892,6 +902,12 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
 	    (rxq->flags & SFC_EF100_RXQ_INGRESS_MPORT))
 		return ENOTSUP;
 
+	if ((unsup_rx_prefix_fields &
+	     (1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI)) == 0)
+		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIPPED_TCI;
+	else
+		rxq->flags &= ~SFC_EF100_RXQ_VLAN_STRIPPED_TCI;
+
 	rxq->prefix_size = pinfo->erpl_length;
 	rxq->rearm_data = sfc_ef100_mk_mbuf_rearm_data(rxq->dp.dpq.port_id,
 						       rxq->prefix_size);
@@ -1004,7 +1020,7 @@ struct sfc_dp_rx sfc_ef100_rx = {
 				  SFC_DP_RX_FEAT_FLOW_MARK |
 				  SFC_DP_RX_FEAT_INTR |
 				  SFC_DP_RX_FEAT_STATS,
-	.dev_offload_capa	= 0,
+	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_VLAN_STRIP,
 	.queue_offload_capa	= RTE_ETH_RX_OFFLOAD_CHECKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 5f312ab1ba..bf37e2c1f5 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -225,6 +225,11 @@ sfc_port_start(struct sfc_adapter *sa)
 	if (rc != 0)
 		goto fail_mac_fcntl_set;
 
+	sfc_log_init(sa, "set vlan strip to %u", port->vlan_strip);
+	rc = efx_port_vlan_strip_set(sa->nic, port->vlan_strip);
+	if (rc != 0)
+		goto fail_mac_vlan_strip_set;
+
 	/* Preserve pause capabilities set by above efx_mac_fcntl_set()  */
 	efx_phy_adv_cap_get(sa->nic, EFX_PHY_CAP_CURRENT, &phy_adv_cap);
 	SFC_ASSERT((port->phy_adv_cap & phy_pause_caps) == 0);
@@ -348,6 +353,7 @@ sfc_port_start(struct sfc_adapter *sa)
 fail_mac_pdu_set:
 fail_phy_adv_cap_set:
 fail_mac_fcntl_set:
+fail_mac_vlan_strip_set:
 #if EFSYS_OPT_LOOPBACK
 fail_loopback_set:
 #endif
@@ -384,11 +390,17 @@ 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");
 
 	port->pdu = EFX_MAC_PDU(dev_data->mtu);
 
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
+		port->vlan_strip = true;
+	else
+		port->vlan_strip = false;
+
 	return 0;
 }
 
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index edd0f0c038..a59bbf35ab 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -938,6 +938,9 @@ sfc_rx_get_offload_mask(struct sfc_adapter *sa)
 	if (encp->enc_tunnel_encapsulations_supported == 0)
 		no_caps |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
+	if (encp->enc_rx_vlan_stripping_supported == 0)
+		no_caps |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
+
 	return ~no_caps;
 }
 
@@ -1109,6 +1112,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	struct sfc_rxq *rxq;
 	struct sfc_dp_rx_qcreate_info info;
 	struct sfc_dp_rx_hw_limits hw_limits;
+	struct sfc_port *port = &sa->port;
 	uint16_t rx_free_thresh;
 	const char *error;
 
@@ -1193,6 +1197,9 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	    sfc_ft_is_active(sa))
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_MARK;
 
+	if (port->vlan_strip)
+		rxq_info->type_flags |= EFX_RXQ_FLAG_VLAN_STRIPPED_TCI;
+
 	rc = sfc_ev_qinit(sa, SFC_EVQ_TYPE_RX, sw_index,
 			  evq_entries, socket_id, &evq);
 	if (rc != 0)
-- 
2.34.1


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

* Re: [PATCH v5 1/3] common/sfc_efx/base: report VLAN stripping capability
  2023-06-13 15:12   ` [PATCH v5 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-19  9:43     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-19  9:43 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/13/23 18:12, Artemii Morozov wrote:
> These changes are necessary in order to add support for stripping
> VLAN tags in the future.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>



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

* Re: [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-13 15:12   ` [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-19 10:28     ` Andrew Rybchenko
  2023-06-20  9:55       ` Artemii Morozov
  0 siblings, 1 reply; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-19 10:28 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/13/23 18:12, Artemii Morozov wrote:
> To enable VLAN stripping, two conditions must be met:
> the corresponding flag must be set and the appropriate
> RX prefix should be requested.

RX -> Rx

> VLAN stripping is supported for ef100 datapath only.

"ef100 datapath" does not make sense in libefx.
"VLAN stripping is supported on EF100 only."
However, such string could be confusing in the future. So, I'd drop
"only"

LGTM, but the problem of the patch is that it does not ensure and does
not highlight in any way that efx_port_vlan_strip_set() must be called
before any filter insertion to have things consistent.
Am I missing something?

efx_port_vlan_strip_set() should check that no filters are installed
(directly or indirectly via default RxQ set).

> diff --git a/drivers/common/sfc_efx/base/efx_port.c b/drivers/common/sfc_efx/base/efx_port.c
> index a5f982e335..7804eb76bc 100644
> --- a/drivers/common/sfc_efx/base/efx_port.c
> +++ b/drivers/common/sfc_efx/base/efx_port.c
> @@ -204,6 +204,24 @@ efx_loopback_type_name(
>   
>   #endif	/* EFSYS_OPT_LOOPBACK */
>   
> +	__checkReturn	efx_rc_t
> +efx_port_vlan_strip_set(
> +	__in		efx_nic_t *enp,
> +	__in		boolean_t enabled)
> +{
> +	efx_port_t *epp = &(enp->en_port);
> +	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
> +
> +	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
> +
> +	if (enabled && !encp->enc_rx_vlan_stripping_supported)
> +		return ENOTSUP;

Return value must be in parenthesis in libefx (common/sfc_efx/base).

> +
> +	epp->ep_vlan_strip = enabled;
> +
> +	return 0;

Return value must be in parenthesis in libefx (common/sfc_efx/base).

> +}
> +
>   			void
>   efx_port_fini(
>   	__in		efx_nic_t *enp)


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

* Re: [PATCH v5 3/3] net/sfc: support VLAN stripping offload
  2023-06-13 15:12   ` [PATCH v5 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
@ 2023-06-19 10:36     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-19 10:36 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/13/23 18:12, Artemii Morozov wrote:
> Extract VLAN TCI provided by the HW in the prefix and put it to mbuf.
> VLAN stripping is supported for ef100 datapath only. This is device
> level offload.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

Overall LGMT

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

> @@ -892,6 +902,12 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
>   	    (rxq->flags & SFC_EF100_RXQ_INGRESS_MPORT))
>   		return ENOTSUP;
>   
> +	if ((unsup_rx_prefix_fields &
> +	     (1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI)) == 0)
> +		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIPPED_TCI;
> +	else
> +		rxq->flags &= ~SFC_EF100_RXQ_VLAN_STRIPPED_TCI;

Availability of the stripped VLAN in Rx prefix could be too broad
criteria to check Rx prefix. IMHO, it is better to stick to the
offload enabling. It would allow to avoid extra Rx checks checks
on more common case when VLAN stripping offload is disabled.

> +
>   	rxq->prefix_size = pinfo->erpl_length;
>   	rxq->rearm_data = sfc_ef100_mk_mbuf_rearm_data(rxq->dp.dpq.port_id,
>   						       rxq->prefix_size);

[snip]


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

* Re: [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-19 10:28     ` Andrew Rybchenko
@ 2023-06-20  9:55       ` Artemii Morozov
  2023-06-20 11:50         ` Andrew Rybchenko
  0 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-20  9:55 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton, Andrew Rybchenko

On 6/19/23 14:28, Andrew Rybchenko wrote:

> On 6/13/23 18:12, Artemii Morozov wrote:
>> To enable VLAN stripping, two conditions must be met:
>> the corresponding flag must be set and the appropriate
>> RX prefix should be requested.
>
> RX -> Rx
>
>> VLAN stripping is supported for ef100 datapath only.
>
> "ef100 datapath" does not make sense in libefx.
> "VLAN stripping is supported on EF100 only."
> However, such string could be confusing in the future. So, I'd drop
> "only"
>
> LGTM, but the problem of the patch is that it does not ensure and does
> not highlight in any way that efx_port_vlan_strip_set() must be called
> before any filter insertion to have things consistent.

This function is called before the sfc_rx_default_rxq_set_filter


> efx_port_vlan_strip_set() should check that no filters are installed
> (directly or indirectly via default RxQ set).

I believe we have the following options:

1. Move the function efx_port_vlan_strip_set before filter 
initialization(efx_filter_init) and include the statement 
"EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_FILTER))" at the beginning 
of the efx_port_vlan_strip_set function.
2. Introduce a new callback function called 
efx_mac_filter_default_rxq_get. Invoke this function at the start of 
efx_port_vlan_strip_set and verify that it returns NULL.

I don't see any other ways to check that the default filters have been 
initialized. Could you advise me how to do it better? Am I missing 
something?

>
>> diff --git a/drivers/common/sfc_efx/base/efx_port.c 
>> b/drivers/common/sfc_efx/base/efx_port.c
>> index a5f982e335..7804eb76bc 100644
>> --- a/drivers/common/sfc_efx/base/efx_port.c
>> +++ b/drivers/common/sfc_efx/base/efx_port.c
>> @@ -204,6 +204,24 @@ efx_loopback_type_name(
>>     #endif    /* EFSYS_OPT_LOOPBACK */
>>   +    __checkReturn    efx_rc_t
>> +efx_port_vlan_strip_set(
>> +    __in        efx_nic_t *enp,
>> +    __in        boolean_t enabled)
>> +{
>> +    efx_port_t *epp = &(enp->en_port);
>> +    efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
>> +
>> +    EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
>> +
>> +    if (enabled && !encp->enc_rx_vlan_stripping_supported)
>> +        return ENOTSUP;
>
> Return value must be in parenthesis in libefx (common/sfc_efx/base).
>
>> +
>> +    epp->ep_vlan_strip = enabled;
>> +
>> +    return 0;
>
> Return value must be in parenthesis in libefx (common/sfc_efx/base).
>
>> +}
>> +
>>               void
>>   efx_port_fini(
>>       __in        efx_nic_t *enp)
>

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

* Re: [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-20  9:55       ` Artemii Morozov
@ 2023-06-20 11:50         ` Andrew Rybchenko
  2023-06-20 13:10           ` Artemii Morozov
  0 siblings, 1 reply; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-20 11:50 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/20/23 12:55, Artemii Morozov wrote:
> On 6/19/23 14:28, Andrew Rybchenko wrote:
> 
>> On 6/13/23 18:12, Artemii Morozov wrote:
>>> To enable VLAN stripping, two conditions must be met:
>>> the corresponding flag must be set and the appropriate
>>> RX prefix should be requested.
>>
>> RX -> Rx
>>
>>> VLAN stripping is supported for ef100 datapath only.
>>
>> "ef100 datapath" does not make sense in libefx.
>> "VLAN stripping is supported on EF100 only."
>> However, such string could be confusing in the future. So, I'd drop
>> "only"
>>
>> LGTM, but the problem of the patch is that it does not ensure and does
>> not highlight in any way that efx_port_vlan_strip_set() must be called
>> before any filter insertion to have things consistent.
> 
> This function is called before the sfc_rx_default_rxq_set_filter

I'm talking about a way to make sure that it is always the case.
Not this particular case.

>> efx_port_vlan_strip_set() should check that no filters are installed
>> (directly or indirectly via default RxQ set).
> 
> I believe we have the following options:
> 
> 1. Move the function efx_port_vlan_strip_set before filter 
> initialization(efx_filter_init) and include the statement 
> "EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_FILTER))" at the beginning 
> of the efx_port_vlan_strip_set function.

This one is too strong. Also it does the check in debug build only.
We need run-time check and less strong. Filters could be initialized,
but it should be no Rx filters installed.

> 2. Introduce a new callback function called 
> efx_mac_filter_default_rxq_get. Invoke this function at the start of 
> efx_port_vlan_strip_set and verify that it returns NULL.

This one is wrong since it could be filters installed via add.
So, it is not a question about default filters only. All Rx filters.

> 
> I don't see any other ways to check that the default filters have been 
> initialized. Could you advise me how to do it better? Am I missing 
> something?

EF10 counts all installed filters if I remember correctly. So, if number
of installed filters is 0, everything is OK.

> 
>>
>>> diff --git a/drivers/common/sfc_efx/base/efx_port.c 
>>> b/drivers/common/sfc_efx/base/efx_port.c
>>> index a5f982e335..7804eb76bc 100644
>>> --- a/drivers/common/sfc_efx/base/efx_port.c
>>> +++ b/drivers/common/sfc_efx/base/efx_port.c
>>> @@ -204,6 +204,24 @@ efx_loopback_type_name(
>>>     #endif    /* EFSYS_OPT_LOOPBACK */
>>>   +    __checkReturn    efx_rc_t
>>> +efx_port_vlan_strip_set(
>>> +    __in        efx_nic_t *enp,
>>> +    __in        boolean_t enabled)
>>> +{
>>> +    efx_port_t *epp = &(enp->en_port);
>>> +    efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
>>> +
>>> +    EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
>>> +
>>> +    if (enabled && !encp->enc_rx_vlan_stripping_supported)
>>> +        return ENOTSUP;
>>
>> Return value must be in parenthesis in libefx (common/sfc_efx/base).
>>
>>> +
>>> +    epp->ep_vlan_strip = enabled;
>>> +
>>> +    return 0;
>>
>> Return value must be in parenthesis in libefx (common/sfc_efx/base).
>>
>>> +}
>>> +
>>>               void
>>>   efx_port_fini(
>>>       __in        efx_nic_t *enp)
>>


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

* Re: [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-20 11:50         ` Andrew Rybchenko
@ 2023-06-20 13:10           ` Artemii Morozov
  2023-06-20 13:53             ` Andrew Rybchenko
  0 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-20 13:10 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton, Andrew Rybchenko


On 6/20/23 15:50, Andrew Rybchenko wrote:
> On 6/20/23 12:55, Artemii Morozov wrote:
>> On 6/19/23 14:28, Andrew Rybchenko wrote:
>>
>>> On 6/13/23 18:12, Artemii Morozov wrote:
>>>> To enable VLAN stripping, two conditions must be met:
>>>> the corresponding flag must be set and the appropriate
>>>> RX prefix should be requested.
>>>
>>> RX -> Rx
>>>
>>>> VLAN stripping is supported for ef100 datapath only.
>>>
>>> "ef100 datapath" does not make sense in libefx.
>>> "VLAN stripping is supported on EF100 only."
>>> However, such string could be confusing in the future. So, I'd drop
>>> "only"
>>>
>>> LGTM, but the problem of the patch is that it does not ensure and does
>>> not highlight in any way that efx_port_vlan_strip_set() must be called
>>> before any filter insertion to have things consistent.
>>
>> This function is called before the sfc_rx_default_rxq_set_filter
>
> I'm talking about a way to make sure that it is always the case.
> Not this particular case.
>
>>> efx_port_vlan_strip_set() should check that no filters are installed
>>> (directly or indirectly via default RxQ set).
>>
>> I believe we have the following options:
>>
>> 1. Move the function efx_port_vlan_strip_set before filter 
>> initialization(efx_filter_init) and include the statement 
>> "EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_FILTER))" at the 
>> beginning of the efx_port_vlan_strip_set function.
>
> This one is too strong. Also it does the check in debug build only.
> We need run-time check and less strong. Filters could be initialized,
> but it should be no Rx filters installed.
>
>> 2. Introduce a new callback function called 
>> efx_mac_filter_default_rxq_get. Invoke this function at the start of 
>> efx_port_vlan_strip_set and verify that it returns NULL.
>
> This one is wrong since it could be filters installed via add.
> So, it is not a question about default filters only. All Rx filters.
>
>>
>> I don't see any other ways to check that the default filters have 
>> been initialized. Could you advise me how to do it better? Am I 
>> missing something?
>
> EF10 counts all installed filters if I remember correctly. So, if number
> of installed filters is 0, everything is OK.
I think you're talking about eft_unicast_filter_count, 
eft_multicast_filter_count and eft_encap_filter_count from 
ef10_filter_table_t. But these fields are specific to ef10 filters. But 
efx_port_vlan_strip_set is a generic function, and we cannot use fields 
specific to ef10 inside it, since something else may appear in the 
future. Maybe we need a new API to find out the number of filters 
installed? (emo_filter_count or something like that).
>
>>
>>>
>>>> diff --git a/drivers/common/sfc_efx/base/efx_port.c 
>>>> b/drivers/common/sfc_efx/base/efx_port.c
>>>> index a5f982e335..7804eb76bc 100644
>>>> --- a/drivers/common/sfc_efx/base/efx_port.c
>>>> +++ b/drivers/common/sfc_efx/base/efx_port.c
>>>> @@ -204,6 +204,24 @@ efx_loopback_type_name(
>>>>     #endif    /* EFSYS_OPT_LOOPBACK */
>>>>   +    __checkReturn    efx_rc_t
>>>> +efx_port_vlan_strip_set(
>>>> +    __in        efx_nic_t *enp,
>>>> +    __in        boolean_t enabled)
>>>> +{
>>>> +    efx_port_t *epp = &(enp->en_port);
>>>> +    efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
>>>> +
>>>> +    EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
>>>> +
>>>> +    if (enabled && !encp->enc_rx_vlan_stripping_supported)
>>>> +        return ENOTSUP;
>>>
>>> Return value must be in parenthesis in libefx (common/sfc_efx/base).
>>>
>>>> +
>>>> +    epp->ep_vlan_strip = enabled;
>>>> +
>>>> +    return 0;
>>>
>>> Return value must be in parenthesis in libefx (common/sfc_efx/base).
>>>
>>>> +}
>>>> +
>>>>               void
>>>>   efx_port_fini(
>>>>       __in        efx_nic_t *enp)
>>>
>

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

* Re: [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-20 13:10           ` Artemii Morozov
@ 2023-06-20 13:53             ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-20 13:53 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/20/23 16:10, Artemii Morozov wrote:
> 
> On 6/20/23 15:50, Andrew Rybchenko wrote:
>> On 6/20/23 12:55, Artemii Morozov wrote:
>>> On 6/19/23 14:28, Andrew Rybchenko wrote:
>>>
>>>> On 6/13/23 18:12, Artemii Morozov wrote:
>>>>> To enable VLAN stripping, two conditions must be met:
>>>>> the corresponding flag must be set and the appropriate
>>>>> RX prefix should be requested.
>>>>
>>>> RX -> Rx
>>>>
>>>>> VLAN stripping is supported for ef100 datapath only.
>>>>
>>>> "ef100 datapath" does not make sense in libefx.
>>>> "VLAN stripping is supported on EF100 only."
>>>> However, such string could be confusing in the future. So, I'd drop
>>>> "only"
>>>>
>>>> LGTM, but the problem of the patch is that it does not ensure and does
>>>> not highlight in any way that efx_port_vlan_strip_set() must be called
>>>> before any filter insertion to have things consistent.
>>>
>>> This function is called before the sfc_rx_default_rxq_set_filter
>>
>> I'm talking about a way to make sure that it is always the case.
>> Not this particular case.
>>
>>>> efx_port_vlan_strip_set() should check that no filters are installed
>>>> (directly or indirectly via default RxQ set).
>>>
>>> I believe we have the following options:
>>>
>>> 1. Move the function efx_port_vlan_strip_set before filter 
>>> initialization(efx_filter_init) and include the statement 
>>> "EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_FILTER))" at the 
>>> beginning of the efx_port_vlan_strip_set function.
>>
>> This one is too strong. Also it does the check in debug build only.
>> We need run-time check and less strong. Filters could be initialized,
>> but it should be no Rx filters installed.
>>
>>> 2. Introduce a new callback function called 
>>> efx_mac_filter_default_rxq_get. Invoke this function at the start of 
>>> efx_port_vlan_strip_set and verify that it returns NULL.
>>
>> This one is wrong since it could be filters installed via add.
>> So, it is not a question about default filters only. All Rx filters.
>>
>>>
>>> I don't see any other ways to check that the default filters have 
>>> been initialized. Could you advise me how to do it better? Am I 
>>> missing something?
>>
>> EF10 counts all installed filters if I remember correctly. So, if number
>> of installed filters is 0, everything is OK.
> I think you're talking about eft_unicast_filter_count, 
> eft_multicast_filter_count and eft_encap_filter_count from 
> ef10_filter_table_t. But these fields are specific to ef10 filters. But 
> efx_port_vlan_strip_set is a generic function, and we cannot use fields 
> specific to ef10 inside it, since something else may appear in the 
> future. Maybe we need a new API to find out the number of filters 
> installed? (emo_filter_count or something like that).

Of course, I'm talking about solution in principle. Yes, it is required
to wrap it in a right code.

>>
>>>
>>>>
>>>>> diff --git a/drivers/common/sfc_efx/base/efx_port.c 
>>>>> b/drivers/common/sfc_efx/base/efx_port.c
>>>>> index a5f982e335..7804eb76bc 100644
>>>>> --- a/drivers/common/sfc_efx/base/efx_port.c
>>>>> +++ b/drivers/common/sfc_efx/base/efx_port.c
>>>>> @@ -204,6 +204,24 @@ efx_loopback_type_name(
>>>>>     #endif    /* EFSYS_OPT_LOOPBACK */
>>>>>   +    __checkReturn    efx_rc_t
>>>>> +efx_port_vlan_strip_set(
>>>>> +    __in        efx_nic_t *enp,
>>>>> +    __in        boolean_t enabled)
>>>>> +{
>>>>> +    efx_port_t *epp = &(enp->en_port);
>>>>> +    efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
>>>>> +
>>>>> +    EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
>>>>> +
>>>>> +    if (enabled && !encp->enc_rx_vlan_stripping_supported)
>>>>> +        return ENOTSUP;
>>>>
>>>> Return value must be in parenthesis in libefx (common/sfc_efx/base).
>>>>
>>>>> +
>>>>> +    epp->ep_vlan_strip = enabled;
>>>>> +
>>>>> +    return 0;
>>>>
>>>> Return value must be in parenthesis in libefx (common/sfc_efx/base).
>>>>
>>>>> +}
>>>>> +
>>>>>               void
>>>>>   efx_port_fini(
>>>>>       __in        efx_nic_t *enp)
>>>>
>>


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

* [PATCH v6 0/4] net/sfc: support VLAN stripping offload
  2023-05-31 13:41 [PATCH 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
                   ` (4 preceding siblings ...)
  2023-06-13 15:12 ` [PATCH v5 0/3] " Artemii Morozov
@ 2023-06-22 11:31 ` Artemii Morozov
  2023-06-22 11:31   ` [PATCH v6 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
                     ` (3 more replies)
  2023-06-22 15:11 ` [PATCH v7 0/4] " Artemii Morozov
  2023-06-23  5:47 ` [PATCH v8 0/4] " Artemii Morozov
  7 siblings, 4 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 11:31 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This patch series adds VLAN stripping offload. Note that this
offload are device level offload.

v6:
  * highlight that efx_port_vlan_strip_set() must be called before any filter insertion
  * avoid an extra check  if offload is not requested

v5:
  * fixed problems with naming
  * fixed problems with abbreviations
  * fixed problems with isolated mode
  * fixed problems with consistency

v4:
  * fix apply patch failure warning

v3:
  * fix apply patch failure warning

v2:
  * rebase patches on top of dpdk-next-net/main

Artemii Morozov (4):
  common/sfc_efx/base: report VLAN stripping capability
  common/sfc_efx/base: add API to get installed filters count
  common/sfc_efx/base: add support to enable VLAN stripping
  net/sfc: support VLAN stripping offload

 doc/guides/nics/sfc_efx.rst               |  4 +--
 doc/guides/rel_notes/release_23_07.rst    |  6 ++++
 drivers/common/sfc_efx/base/ef10_filter.c | 26 +++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  6 ++++
 drivers/common/sfc_efx/base/ef10_nic.c    |  6 ++++
 drivers/common/sfc_efx/base/efx.h         | 13 ++++++++
 drivers/common/sfc_efx/base/efx_filter.c  | 27 ++++++++++++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  8 +++++
 drivers/common/sfc_efx/base/efx_port.c    | 39 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_rx.c      | 14 ++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 ++
 drivers/common/sfc_efx/base/siena_nic.c   |  1 +
 drivers/common/sfc_efx/version.map        |  1 +
 drivers/net/sfc/sfc.h                     |  1 +
 drivers/net/sfc/sfc_dp_rx.h               |  1 +
 drivers/net/sfc/sfc_ef100_rx.c            | 24 +++++++++++++-
 drivers/net/sfc/sfc_port.c                | 12 +++++++
 drivers/net/sfc/sfc_rx.c                  | 10 ++++++
 18 files changed, 199 insertions(+), 3 deletions(-)

-- 
2.34.1


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

* [PATCH v6 1/4] common/sfc_efx/base: report VLAN stripping capability
  2023-06-22 11:31 ` [PATCH v6 0/4] " Artemii Morozov
@ 2023-06-22 11:31   ` Artemii Morozov
  2023-06-22 11:46     ` Andrew Rybchenko
  2023-06-22 11:31   ` [PATCH v6 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 11:31 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

These changes are necessary in order to add support for stripping
VLAN tags in the future.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 6 ++++++
 drivers/common/sfc_efx/base/efx.h       | 1 +
 drivers/common/sfc_efx/base/siena_nic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index e1709d1200..070f4d08b5 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1146,6 +1146,12 @@ ef10_get_datapath_caps(
 	else
 		encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
 
+	/* Check if firmware supports VLAN stripping. */
+	if (CAP_FLAGS1(req, RX_VLAN_STRIPPING))
+		encp->enc_rx_vlan_stripping_supported = B_TRUE;
+	else
+		encp->enc_rx_vlan_stripping_supported = B_FALSE;
+
 	/* Check if the firmware supports RX event batching */
 	if (CAP_FLAGS1(req, RX_BATCHING))
 		encp->enc_rx_batching_enabled = B_TRUE;
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 10c412bcd7..9a29583ecb 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1616,6 +1616,7 @@ typedef struct efx_nic_cfg_s {
 	/* Number of TSO contexts on the NIC (FATSOv2) */
 	uint32_t		enc_fw_assisted_tso_v2_n_contexts;
 	boolean_t		enc_hw_tx_insert_vlan_enabled;
+	boolean_t		enc_rx_vlan_stripping_supported;
 	/* Number of PFs on the NIC */
 	uint32_t		enc_hw_pf_count;
 	/* Datapath firmware vadapter/vport/vswitch support */
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index 9f14faf271..4b7f7cbb87 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -179,6 +179,7 @@ siena_board_cfg(
 	    (encp->enc_rxq_limit * EFX_RXQ_DC_NDESCS(EFX_RXQ_DC_SIZE));
 
 	encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
+	encp->enc_rx_vlan_stripping_supported = B_FALSE;
 	encp->enc_fw_assisted_tso_enabled = B_FALSE;
 	encp->enc_fw_assisted_tso_v2_enabled = B_FALSE;
 	encp->enc_fw_assisted_tso_v2_n_contexts = 0;
-- 
2.34.1


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

* [PATCH v6 2/4] common/sfc_efx/base: add API to get installed filters count
  2023-06-22 11:31 ` [PATCH v6 0/4] " Artemii Morozov
  2023-06-22 11:31   ` [PATCH v6 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-22 11:31   ` Artemii Morozov
  2023-06-22 11:51     ` Andrew Rybchenko
  2023-06-22 11:31   ` [PATCH v6 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
  2023-06-22 11:31   ` [PATCH v6 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
  3 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 11:31 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This API allows to get number of installed filters. This will
be used in the future patches.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
---
 drivers/common/sfc_efx/base/ef10_filter.c | 20 +++++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  6 +++++
 drivers/common/sfc_efx/base/efx_filter.c  | 27 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  7 ++++++
 4 files changed, 60 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index d6940011c0..278502fb61 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -2113,6 +2113,26 @@ ef10_filter_reconfigure(
 	return (rc);
 }
 
+	__checkReturn	efx_rc_t
+ef10_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count)
+{
+	ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
+	uint32_t filters_count;
+
+	EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
+	EFSYS_ASSERT(count != NULL);
+
+	filters_count = table->eft_unicst_filter_count +
+			table->eft_mulcst_filter_count +
+			table->eft_encap_filter_count;
+
+	*count = filters_count;
+
+	return (0);
+}
+
 		void
 ef10_filter_get_default_rxq(
 	__in		efx_nic_t *enp,
diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
index 877aedad45..914bba10ce 100644
--- a/drivers/common/sfc_efx/base/ef10_impl.h
+++ b/drivers/common/sfc_efx/base/ef10_impl.h
@@ -1347,6 +1347,12 @@ ef10_filter_reconfigure(
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				uint32_t count);
 
+LIBEFX_INTERNAL
+extern	__checkReturn	efx_rc_t
+ef10_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count);
+
 LIBEFX_INTERNAL
 extern		void
 ef10_filter_get_default_rxq(
diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
index 83c37ff859..a8b62ee88d 100644
--- a/drivers/common/sfc_efx/base/efx_filter.c
+++ b/drivers/common/sfc_efx/base/efx_filter.c
@@ -53,6 +53,7 @@ static const efx_filter_ops_t	__efx_filter_siena_ops = {
 	siena_filter_delete,		/* efo_delete */
 	siena_filter_supported_filters,	/* efo_supported_filters */
 	NULL,				/* efo_reconfigure */
+	NULL,				/* efo_get_count */
 };
 #endif /* EFSYS_OPT_SIENA */
 
@@ -65,6 +66,7 @@ static const efx_filter_ops_t	__efx_filter_ef10_ops = {
 	ef10_filter_delete,		/* efo_delete */
 	ef10_filter_supported_filters,	/* efo_supported_filters */
 	ef10_filter_reconfigure,	/* efo_reconfigure */
+	ef10_filter_get_count,		/* efo_get_count */
 };
 #endif /* EFX_OPTS_EF10() */
 
@@ -77,6 +79,7 @@ static const efx_filter_ops_t	__efx_filter_rhead_ops = {
 	ef10_filter_delete,		/* efo_delete */
 	ef10_filter_supported_filters,	/* efo_supported_filters */
 	ef10_filter_reconfigure,	/* efo_reconfigure */
+	ef10_filter_get_count,		/* efo_get_count */
 };
 #endif /* EFSYS_OPT_RIVERHEAD */
 
@@ -306,6 +309,30 @@ efx_filter_reconfigure(
 
 	return (0);
 
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
+	__checkReturn	efx_rc_t
+efx_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count)
+{
+	efx_rc_t rc;
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_FILTER);
+
+	if (enp->en_efop->efo_get_count != NULL) {
+		if ((rc = enp->en_efop->efo_get_count(enp, count)) != 0)
+			goto fail1;
+	}
+
+	return (0);
+
 fail1:
 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 45e99d01c5..d657734bc5 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -288,6 +288,7 @@ typedef struct efx_filter_ops_s {
 	efx_rc_t	(*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
 				   boolean_t, boolean_t, boolean_t,
 				   uint8_t const *, uint32_t);
+	efx_rc_t	(*efo_get_count)(efx_nic_t *, uint32_t *);
 } efx_filter_ops_t;
 
 LIBEFX_INTERNAL
@@ -302,6 +303,12 @@ efx_filter_reconfigure(
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				uint32_t count);
 
+LIBEFX_INTERNAL
+extern	__checkReturn	efx_rc_t
+efx_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count);
+
 #endif /* EFSYS_OPT_FILTER */
 
 #if EFSYS_OPT_TUNNEL
-- 
2.34.1


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

* [PATCH v6 3/4] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-22 11:31 ` [PATCH v6 0/4] " Artemii Morozov
  2023-06-22 11:31   ` [PATCH v6 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
  2023-06-22 11:31   ` [PATCH v6 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
@ 2023-06-22 11:31   ` Artemii Morozov
  2023-06-22 11:54     ` Andrew Rybchenko
  2023-06-22 11:31   ` [PATCH v6 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
  3 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 11:31 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

To enable VLAN stripping, two conditions must be met:
the corresponding flag must be set and the appropriate
Rx prefix should be requested.
VLAN stripping is supported on EF100.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_filter.c |  6 ++++
 drivers/common/sfc_efx/base/efx.h         | 12 +++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_port.c    | 39 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_rx.c      | 14 ++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 ++
 drivers/common/sfc_efx/version.map        |  1 +
 7 files changed, 76 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index 278502fb61..827b3e8f00 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -171,6 +171,7 @@ efx_mcdi_filter_op_add(
 	EFX_MCDI_DECLARE_BUF(payload, MC_CMD_FILTER_OP_V3_IN_LEN,
 		MC_CMD_FILTER_OP_EXT_OUT_LEN);
 	efx_filter_match_flags_t match_flags;
+	efx_port_t *epp = &(enp->en_port);
 	uint32_t port_id;
 	efx_rc_t rc;
 
@@ -338,6 +339,11 @@ efx_mcdi_filter_op_add(
 		    FILTER_OP_V3_IN_MATCH_SET_FLAG, 1);
 	}
 
+	if (epp->ep_vlan_strip) {
+		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
+			FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);
+	}
+
 	efx_mcdi_execute(enp, &req);
 
 	if (req.emr_rc != 0) {
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 9a29583ecb..016bbc8ec9 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1147,6 +1147,12 @@ efx_port_poll(
 	__in		efx_nic_t *enp,
 	__out_opt	efx_link_mode_t	*link_modep);
 
+LIBEFX_API
+extern	__checkReturn	efx_rc_t
+efx_port_vlan_strip_set(
+	__in		efx_nic_t *enp,
+	__in		boolean_t enabled);
+
 LIBEFX_API
 extern		void
 efx_port_fini(
@@ -3101,6 +3107,12 @@ typedef enum efx_rxq_type_e {
  * Request user flag field in the Rx prefix of a queue.
  */
 #define	EFX_RXQ_FLAG_USER_FLAG		0x20
+/*
+ * Request VLAN TCI field in the Rx prefix. The flag just
+ * controls delivery of the stripped VLAN TCI if VLAN stripping
+ * is enabled and done.
+ */
+#define	EFX_RXQ_FLAG_VLAN_STRIPPED_TCI		0x40
 
 LIBEFX_API
 extern	__checkReturn	efx_rc_t
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index d657734bc5..de9d1dddc8 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -370,6 +370,7 @@ typedef struct efx_port_s {
 	uint32_t		ep_default_adv_cap_mask;
 	uint32_t		ep_phy_cap_mask;
 	boolean_t		ep_mac_drain;
+	boolean_t		ep_vlan_strip;
 #if EFSYS_OPT_BIST
 	efx_bist_type_t		ep_current_bist;
 #endif
diff --git a/drivers/common/sfc_efx/base/efx_port.c b/drivers/common/sfc_efx/base/efx_port.c
index a5f982e335..e5a9fa6c53 100644
--- a/drivers/common/sfc_efx/base/efx_port.c
+++ b/drivers/common/sfc_efx/base/efx_port.c
@@ -204,6 +204,45 @@ efx_loopback_type_name(
 
 #endif	/* EFSYS_OPT_LOOPBACK */
 
+	__checkReturn	efx_rc_t
+efx_port_vlan_strip_set(
+	__in		efx_nic_t *enp,
+	__in		boolean_t enabled)
+{
+	efx_port_t *epp = &(enp->en_port);
+	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+	uint32_t filters_count = 0;
+	efx_rc_t rc;
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+
+	if (enabled && !encp->enc_rx_vlan_stripping_supported) {
+		rc = ENOTSUP;
+		goto fail1;
+	}
+
+	if ((rc = efx_filter_get_count(enp, &filters_count)) != 0)
+		goto fail2;
+
+	if (filters_count != 0) {
+		rc = EINVAL;
+		goto fail3;
+	}
+
+	epp->ep_vlan_strip = enabled;
+
+	return (0);
+
+fail3:
+	EFSYS_PROBE(fail3);
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
 			void
 efx_port_fini(
 	__in		efx_nic_t *enp)
diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
index 68f42f5cac..b3d9e14c67 100644
--- a/drivers/common/sfc_efx/base/efx_rx.c
+++ b/drivers/common/sfc_efx/base/efx_rx.c
@@ -941,11 +941,25 @@ efx_rx_qcreate_internal(
 			goto fail5;
 	}
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI) {
+		const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout;
+		const efx_rx_prefix_field_info_t *vlan_tci_field;
+
+		vlan_tci_field =
+		    &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI];
+		if (vlan_tci_field->erpfi_width_bits == 0) {
+			rc = ENOTSUP;
+			goto fail6;
+		}
+	}
+
 	enp->en_rx_qcount++;
 	*erpp = erp;
 
 	return (0);
 
+fail6:
+	EFSYS_PROBE(fail6);
 fail5:
 	EFSYS_PROBE(fail5);
 
diff --git a/drivers/common/sfc_efx/base/rhead_rx.c b/drivers/common/sfc_efx/base/rhead_rx.c
index d0ac5c02f8..a86551f646 100644
--- a/drivers/common/sfc_efx/base/rhead_rx.c
+++ b/drivers/common/sfc_efx/base/rhead_rx.c
@@ -640,6 +640,9 @@ rhead_rx_qcreate(
 	if (flags & EFX_RXQ_FLAG_USER_FLAG)
 		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_USER_FLAG;
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI;
+
 	/*
 	 * LENGTH is required in EF100 host interface, as receive events
 	 * do not include the packet length.
diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map
index d9b04a611d..e0d473dc72 100644
--- a/drivers/common/sfc_efx/version.map
+++ b/drivers/common/sfc_efx/version.map
@@ -203,6 +203,7 @@ INTERNAL {
 	efx_port_init;
 	efx_port_loopback_set;
 	efx_port_poll;
+	efx_port_vlan_strip_set;
 
 	efx_pseudo_hdr_hash_get;
 	efx_pseudo_hdr_pkt_length_get;
-- 
2.34.1


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

* [PATCH v6 4/4] net/sfc: support VLAN stripping offload
  2023-06-22 11:31 ` [PATCH v6 0/4] " Artemii Morozov
                     ` (2 preceding siblings ...)
  2023-06-22 11:31   ` [PATCH v6 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-22 11:31   ` Artemii Morozov
  2023-06-22 12:07     ` Andrew Rybchenko
  3 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 11:31 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

Extract VLAN TCI provided by the HW in the prefix and put it to mbuf.
VLAN stripping is supported for ef100 datapath only. This is device
level offload.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 doc/guides/nics/sfc_efx.rst            |  4 ++--
 doc/guides/rel_notes/release_23_07.rst |  6 ++++++
 drivers/net/sfc/sfc.h                  |  1 +
 drivers/net/sfc/sfc_dp_rx.h            |  1 +
 drivers/net/sfc/sfc_ef100_rx.c         | 24 +++++++++++++++++++++++-
 drivers/net/sfc/sfc_port.c             | 12 ++++++++++++
 drivers/net/sfc/sfc_rx.c               | 10 ++++++++++
 7 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index de0656876b..44fa24e1ba 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -118,6 +118,8 @@ SFC EFX PMD has support for:
 
 - Port representors (see :ref: switch_representation)
 
+- VLAN stripping (if running firmware variant supports it)
+
 
 Non-supported Features
 ----------------------
@@ -132,8 +134,6 @@ The features not yet supported include:
 
 - VLAN filtering
 
-- VLAN stripping
-
 - LRO
 
 
diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst
index dc0d250e16..b961ef139f 100644
--- a/doc/guides/rel_notes/release_23_07.rst
+++ b/doc/guides/rel_notes/release_23_07.rst
@@ -177,6 +177,12 @@ New Features
 
   See :doc:`../prog_guide/pdcp_lib` for more information.
 
+* **Updated Solarflare network PMD.**
+
+  Updated the Solarflare ``sfc_efx`` driver with changes including:
+
+  * Added VLAN stripping support on SN1000 SmartNICs
+
 
 Removed Items
 -------------
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index e42abe42cb..b68bcc7d4f 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -73,6 +73,7 @@ struct sfc_port {
 
 	unsigned int			flow_ctrl;
 	boolean_t			flow_ctrl_autoneg;
+	boolean_t			vlan_strip;
 	size_t				pdu;
 
 	/*
diff --git a/drivers/net/sfc/sfc_dp_rx.h b/drivers/net/sfc/sfc_dp_rx.h
index 8a504bdcf1..9f9bf28988 100644
--- a/drivers/net/sfc/sfc_dp_rx.h
+++ b/drivers/net/sfc/sfc_dp_rx.h
@@ -70,6 +70,7 @@ struct sfc_dp_rx_qcreate_info {
 	unsigned int		flags;
 #define SFC_RXQ_FLAG_RSS_HASH	0x1
 #define SFC_RXQ_FLAG_INGRESS_MPORT	0x2
+#define SFC_RXQ_FLAG_VLAN_STRIPPED_TCI	0x4
 
 	/** Rx queue size */
 	unsigned int		rxq_entries;
diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index 37b754fa33..07381df5cf 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -68,6 +68,7 @@ struct sfc_ef100_rxq {
 #define SFC_EF100_RXQ_INGRESS_MPORT	0x80
 #define SFC_EF100_RXQ_USER_FLAG		0x100
 #define SFC_EF100_RXQ_NIC_DMA_MAP	0x200
+#define SFC_EF100_RXQ_VLAN_STRIPPED_TCI	0x400
 	unsigned int			ptr_mask;
 	unsigned int			evq_phase_bit_shift;
 	unsigned int			ready_pkts;
@@ -392,6 +393,7 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
 		SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
+		SFC_EF100_RX_PREFIX_FIELD(VLAN_STRIP_TCI, B_FALSE),
 
 #undef	SFC_EF100_RX_PREFIX_FIELD
 	}
@@ -472,6 +474,14 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
 						ESF_GZ_RX_PREFIX_INGRESS_MPORT);
 	}
 
+	if (rxq->flags & SFC_EF100_RXQ_VLAN_STRIPPED_TCI &&
+	    EFX_TEST_XWORD_BIT(rx_prefix[0],
+				   ESF_GZ_RX_PREFIX_VLAN_STRIPPED_LBN)) {
+		ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+		m->vlan_tci = EFX_XWORD_FIELD(rx_prefix[0],
+						ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI);
+	}
+
 	m->ol_flags = ol_flags;
 	return true;
 }
@@ -813,6 +823,9 @@ sfc_ef100_rx_qcreate(uint16_t port_id, uint16_t queue_id,
 	if (info->flags & SFC_RXQ_FLAG_INGRESS_MPORT)
 		rxq->flags |= SFC_EF100_RXQ_INGRESS_MPORT;
 
+	if (info->flags & SFC_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIPPED_TCI;
+
 	sfc_ef100_rx_debug(rxq, "RxQ doorbell is %p", rxq->doorbell);
 
 	*dp_rxqp = &rxq->dp;
@@ -892,6 +905,15 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
 	    (rxq->flags & SFC_EF100_RXQ_INGRESS_MPORT))
 		return ENOTSUP;
 
+	/*
+	 * Exclude the SFC_EF100_RXQ_VLAN_STRIPPED_TCI if offload was not requested
+	 * or the prefix does not contain the corresponding field.
+	 */
+	if (!((rxq->flags & SFC_EF100_RXQ_VLAN_STRIPPED_TCI) &&
+		((unsup_rx_prefix_fields &
+		(1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI)) == 0)))
+		rxq->flags &= ~SFC_EF100_RXQ_VLAN_STRIPPED_TCI;
+
 	rxq->prefix_size = pinfo->erpl_length;
 	rxq->rearm_data = sfc_ef100_mk_mbuf_rearm_data(rxq->dp.dpq.port_id,
 						       rxq->prefix_size);
@@ -1004,7 +1026,7 @@ struct sfc_dp_rx sfc_ef100_rx = {
 				  SFC_DP_RX_FEAT_FLOW_MARK |
 				  SFC_DP_RX_FEAT_INTR |
 				  SFC_DP_RX_FEAT_STATS,
-	.dev_offload_capa	= 0,
+	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_VLAN_STRIP,
 	.queue_offload_capa	= RTE_ETH_RX_OFFLOAD_CHECKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 0c887ddedb..f1354f5432 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -225,6 +225,11 @@ sfc_port_start(struct sfc_adapter *sa)
 	if (rc != 0)
 		goto fail_mac_fcntl_set;
 
+	sfc_log_init(sa, "set vlan strip to %u", port->vlan_strip);
+	rc = efx_port_vlan_strip_set(sa->nic, port->vlan_strip);
+	if (rc != 0)
+		goto fail_mac_vlan_strip_set;
+
 	/* Preserve pause capabilities set by above efx_mac_fcntl_set()  */
 	efx_phy_adv_cap_get(sa->nic, EFX_PHY_CAP_CURRENT, &phy_adv_cap);
 	SFC_ASSERT((port->phy_adv_cap & phy_pause_caps) == 0);
@@ -339,6 +344,7 @@ sfc_port_start(struct sfc_adapter *sa)
 fail_mac_pdu_set:
 fail_phy_adv_cap_set:
 fail_mac_fcntl_set:
+fail_mac_vlan_strip_set:
 #if EFSYS_OPT_LOOPBACK
 fail_loopback_set:
 #endif
@@ -375,11 +381,17 @@ 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");
 
 	port->pdu = EFX_MAC_PDU(dev_data->mtu);
 
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
+		port->vlan_strip = true;
+	else
+		port->vlan_strip = false;
+
 	return 0;
 }
 
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index edd0f0c038..505d95a9aa 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -938,6 +938,9 @@ sfc_rx_get_offload_mask(struct sfc_adapter *sa)
 	if (encp->enc_tunnel_encapsulations_supported == 0)
 		no_caps |= RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM;
 
+	if (encp->enc_rx_vlan_stripping_supported == 0)
+		no_caps |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
+
 	return ~no_caps;
 }
 
@@ -1109,6 +1112,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	struct sfc_rxq *rxq;
 	struct sfc_dp_rx_qcreate_info info;
 	struct sfc_dp_rx_hw_limits hw_limits;
+	struct sfc_port *port = &sa->port;
 	uint16_t rx_free_thresh;
 	const char *error;
 
@@ -1193,6 +1197,9 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	    sfc_ft_is_active(sa))
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_MARK;
 
+	if (port->vlan_strip)
+		rxq_info->type_flags |= EFX_RXQ_FLAG_VLAN_STRIPPED_TCI;
+
 	rc = sfc_ev_qinit(sa, SFC_EVQ_TYPE_RX, sw_index,
 			  evq_entries, socket_id, &evq);
 	if (rc != 0)
@@ -1228,6 +1235,9 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	if (rxq_info->type_flags & EFX_RXQ_FLAG_INGRESS_MPORT)
 		rxq_info->rxq_flags |= SFC_RXQ_FLAG_INGRESS_MPORT;
 
+	if (rxq_info->type_flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		rxq_info->rxq_flags |= SFC_RXQ_FLAG_VLAN_STRIPPED_TCI;
+
 	rxq->buf_size = buf_size;
 
 	rc = sfc_dma_alloc(sa, "rxq", sw_index, EFX_NIC_DMA_ADDR_RX_RING,
-- 
2.34.1


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

* Re: [PATCH v6 1/4] common/sfc_efx/base: report VLAN stripping capability
  2023-06-22 11:31   ` [PATCH v6 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-22 11:46     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-22 11:46 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/22/23 14:31, Artemii Morozov wrote:
> These changes are necessary in order to add support for stripping
> VLAN tags in the future.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>



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

* Re: [PATCH v6 2/4] common/sfc_efx/base: add API to get installed filters count
  2023-06-22 11:31   ` [PATCH v6 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
@ 2023-06-22 11:51     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-22 11:51 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov

On 6/22/23 14:31, Artemii Morozov wrote:
> This API allows to get number of installed filters. This will
> be used in the future patches.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> ---
>   drivers/common/sfc_efx/base/ef10_filter.c | 20 +++++++++++++++++
>   drivers/common/sfc_efx/base/ef10_impl.h   |  6 +++++
>   drivers/common/sfc_efx/base/efx_filter.c  | 27 +++++++++++++++++++++++
>   drivers/common/sfc_efx/base/efx_impl.h    |  7 ++++++
>   4 files changed, 60 insertions(+)
> 
> diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
> index d6940011c0..278502fb61 100644
> --- a/drivers/common/sfc_efx/base/ef10_filter.c
> +++ b/drivers/common/sfc_efx/base/ef10_filter.c
> @@ -2113,6 +2113,26 @@ ef10_filter_reconfigure(
>   	return (rc);
>   }
>   
> +	__checkReturn	efx_rc_t
> +ef10_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *count)
> +{
> +	ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
> +	uint32_t filters_count;
> +
> +	EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
> +	EFSYS_ASSERT(count != NULL);
> +
> +	filters_count = table->eft_unicst_filter_count +
> +			table->eft_mulcst_filter_count +
> +			table->eft_encap_filter_count;

I guess encap filters are orthogonal to Rx VLAN stripping. But may be it
is not a problem.

> +
> +	*count = filters_count;
> +
> +	return (0);
> +}
> +
>   		void
>   ef10_filter_get_default_rxq(
>   	__in		efx_nic_t *enp,
> diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
> index 877aedad45..914bba10ce 100644
> --- a/drivers/common/sfc_efx/base/ef10_impl.h
> +++ b/drivers/common/sfc_efx/base/ef10_impl.h
> @@ -1347,6 +1347,12 @@ ef10_filter_reconfigure(
>   	__in_ecount(6*count)		uint8_t const *addrs,
>   	__in				uint32_t count);
>   
> +LIBEFX_INTERNAL
> +extern	__checkReturn	efx_rc_t
> +ef10_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *count);
> +
>   LIBEFX_INTERNAL
>   extern		void
>   ef10_filter_get_default_rxq(
> diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
> index 83c37ff859..a8b62ee88d 100644
> --- a/drivers/common/sfc_efx/base/efx_filter.c
> +++ b/drivers/common/sfc_efx/base/efx_filter.c
> @@ -53,6 +53,7 @@ static const efx_filter_ops_t	__efx_filter_siena_ops = {
>   	siena_filter_delete,		/* efo_delete */
>   	siena_filter_supported_filters,	/* efo_supported_filters */
>   	NULL,				/* efo_reconfigure */
> +	NULL,				/* efo_get_count */
>   };
>   #endif /* EFSYS_OPT_SIENA */
>   
> @@ -65,6 +66,7 @@ static const efx_filter_ops_t	__efx_filter_ef10_ops = {
>   	ef10_filter_delete,		/* efo_delete */
>   	ef10_filter_supported_filters,	/* efo_supported_filters */
>   	ef10_filter_reconfigure,	/* efo_reconfigure */
> +	ef10_filter_get_count,		/* efo_get_count */
>   };
>   #endif /* EFX_OPTS_EF10() */
>   
> @@ -77,6 +79,7 @@ static const efx_filter_ops_t	__efx_filter_rhead_ops = {
>   	ef10_filter_delete,		/* efo_delete */
>   	ef10_filter_supported_filters,	/* efo_supported_filters */
>   	ef10_filter_reconfigure,	/* efo_reconfigure */
> +	ef10_filter_get_count,		/* efo_get_count */
>   };
>   #endif /* EFSYS_OPT_RIVERHEAD */
>   
> @@ -306,6 +309,30 @@ efx_filter_reconfigure(
>   
>   	return (0);
>   
> +fail1:
> +	EFSYS_PROBE1(fail1, efx_rc_t, rc);
> +
> +	return (rc);
> +}
> +
> +	__checkReturn	efx_rc_t
> +efx_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *count)
> +{
> +	efx_rc_t rc;
> +
> +	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
> +	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
> +	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_FILTER);
> +
> +	if (enp->en_efop->efo_get_count != NULL) {

It looks bad to return 0, but do not fill in count.
IMHO, it should be an error if callback is not provided.

> +		if ((rc = enp->en_efop->efo_get_count(enp, count)) != 0)
> +			goto fail1;
> +	}
> +
> +	return (0);
> +
>   fail1:
>   	EFSYS_PROBE1(fail1, efx_rc_t, rc);
>   
> diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
> index 45e99d01c5..d657734bc5 100644
> --- a/drivers/common/sfc_efx/base/efx_impl.h
> +++ b/drivers/common/sfc_efx/base/efx_impl.h
> @@ -288,6 +288,7 @@ typedef struct efx_filter_ops_s {
>   	efx_rc_t	(*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
>   				   boolean_t, boolean_t, boolean_t,
>   				   uint8_t const *, uint32_t);
> +	efx_rc_t	(*efo_get_count)(efx_nic_t *, uint32_t *);
>   } efx_filter_ops_t;
>   
>   LIBEFX_INTERNAL
> @@ -302,6 +303,12 @@ efx_filter_reconfigure(
>   	__in_ecount(6*count)		uint8_t const *addrs,
>   	__in				uint32_t count);
>   
> +LIBEFX_INTERNAL
> +extern	__checkReturn	efx_rc_t
> +efx_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *count);
> +
>   #endif /* EFSYS_OPT_FILTER */
>   
>   #if EFSYS_OPT_TUNNEL


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

* Re: [PATCH v6 3/4] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-22 11:31   ` [PATCH v6 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-22 11:54     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-22 11:54 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/22/23 14:31, Artemii Morozov wrote:
> To enable VLAN stripping, two conditions must be met:
> the corresponding flag must be set and the appropriate
> Rx prefix should be requested.
> VLAN stripping is supported on EF100.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

with minor style fix, see below:

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

> diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
> index 278502fb61..827b3e8f00 100644
> --- a/drivers/common/sfc_efx/base/ef10_filter.c
> +++ b/drivers/common/sfc_efx/base/ef10_filter.c
> @@ -171,6 +171,7 @@ efx_mcdi_filter_op_add(
>   	EFX_MCDI_DECLARE_BUF(payload, MC_CMD_FILTER_OP_V3_IN_LEN,
>   		MC_CMD_FILTER_OP_EXT_OUT_LEN);
>   	efx_filter_match_flags_t match_flags;
> +	efx_port_t *epp = &(enp->en_port);
>   	uint32_t port_id;
>   	efx_rc_t rc;
>   
> @@ -338,6 +339,11 @@ efx_mcdi_filter_op_add(
>   		    FILTER_OP_V3_IN_MATCH_SET_FLAG, 1);
>   	}
>   
> +	if (epp->ep_vlan_strip) {
> +		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
> +			FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);

4 spaces alignment, please, on line continuation in libefx

> +	}
> +
>   	efx_mcdi_execute(enp, &req);
>   
>   	if (req.emr_rc != 0) {
>

[snip]


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

* Re: [PATCH v6 4/4] net/sfc: support VLAN stripping offload
  2023-06-22 11:31   ` [PATCH v6 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
@ 2023-06-22 12:07     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-22 12:07 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/22/23 14:31, Artemii Morozov wrote:
> Extract VLAN TCI provided by the HW in the prefix and put it to mbuf.
> VLAN stripping is supported for ef100 datapath only. This is device
> level offload.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

One, but important question below:

> diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
> index 37b754fa33..07381df5cf 100644
> --- a/drivers/net/sfc/sfc_ef100_rx.c
> +++ b/drivers/net/sfc/sfc_ef100_rx.c

[snip]

> @@ -892,6 +905,15 @@ sfc_ef100_rx_qstart(struct sfc_dp_rxq *dp_rxq, unsigned int evq_read_ptr,
>   	    (rxq->flags & SFC_EF100_RXQ_INGRESS_MPORT))
>   		return ENOTSUP;
>   
> +	/*
> +	 * Exclude the SFC_EF100_RXQ_VLAN_STRIPPED_TCI if offload was not requested
> +	 * or the prefix does not contain the corresponding field.
> +	 */
> +	if (!((rxq->flags & SFC_EF100_RXQ_VLAN_STRIPPED_TCI) &&

Sorry, it is complicated to understand the condition. Please, avoid
leading not.

> +		((unsup_rx_prefix_fields &
> +		(1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI)) == 0)))
> +		rxq->flags &= ~SFC_EF100_RXQ_VLAN_STRIPPED_TCI;
> +

I don't understand why do we need to check Rx prefix field presence
here. We should not allow to enable VLAN stripping if Rx prefix field
is not available.

>   	rxq->prefix_size = pinfo->erpl_length;
>   	rxq->rearm_data = sfc_ef100_mk_mbuf_rearm_data(rxq->dp.dpq.port_id,
>   						       rxq->prefix_size);

[snip]


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

* [PATCH v7 0/4] net/sfc: support VLAN stripping offload
  2023-05-31 13:41 [PATCH 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
                   ` (5 preceding siblings ...)
  2023-06-22 11:31 ` [PATCH v6 0/4] " Artemii Morozov
@ 2023-06-22 15:11 ` Artemii Morozov
  2023-06-22 15:11   ` [PATCH v7 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
                     ` (3 more replies)
  2023-06-23  5:47 ` [PATCH v8 0/4] " Artemii Morozov
  7 siblings, 4 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 15:11 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This patch series adds VLAN stripping offload. Note that this
offload are device level offload.

v7:
  * raise an error if there is no callback for efo_get_count
  * fix alignment
  * remove the extra check

v6:
  * highlight that efx_port_vlan_strip_set() must be called before any filter insertion
  * avoid an extra check if offload is not requested

v5:
  * fixed problems with naming
  * fixed problems with abbreviations
  * fixed problems with isolated mode
  * fixed problems with consistency

v4:
  * fix apply patch failure warning

v3:
  * fix apply patch failure warning

v2:
  * rebase patches on top of dpdk-next-net/main

Artemii Morozov (4):
  common/sfc_efx/base: report VLAN stripping capability
  common/sfc_efx/base: add API to get installed filters count
  common/sfc_efx/base: add support to enable VLAN stripping
  net/sfc: support VLAN stripping offload

 doc/guides/nics/sfc_efx.rst               |  4 +--
 doc/guides/rel_notes/release_23_07.rst    |  6 ++++
 drivers/common/sfc_efx/base/ef10_filter.c | 26 +++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  6 ++++
 drivers/common/sfc_efx/base/ef10_nic.c    |  6 ++++
 drivers/common/sfc_efx/base/efx.h         | 13 ++++++++
 drivers/common/sfc_efx/base/efx_filter.c  | 32 +++++++++++++++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  8 +++++
 drivers/common/sfc_efx/base/efx_port.c    | 39 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_rx.c      | 14 ++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 ++
 drivers/common/sfc_efx/base/siena_nic.c   |  1 +
 drivers/common/sfc_efx/version.map        |  1 +
 drivers/net/sfc/sfc.h                     |  1 +
 drivers/net/sfc/sfc_dp_rx.h               |  1 +
 drivers/net/sfc/sfc_ef100_rx.c            | 16 +++++++++-
 drivers/net/sfc/sfc_port.c                | 11 +++++++
 drivers/net/sfc/sfc_rx.c                  | 10 ++++++
 18 files changed, 195 insertions(+), 3 deletions(-)

-- 
2.34.1


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

* [PATCH v7 1/4] common/sfc_efx/base: report VLAN stripping capability
  2023-06-22 15:11 ` [PATCH v7 0/4] " Artemii Morozov
@ 2023-06-22 15:11   ` Artemii Morozov
  2023-06-22 15:11   ` [PATCH v7 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 15:11 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

These changes are necessary in order to add support for stripping
VLAN tags in the future.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 6 ++++++
 drivers/common/sfc_efx/base/efx.h       | 1 +
 drivers/common/sfc_efx/base/siena_nic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index bf9cb9d309..79d596b5ef 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1223,6 +1223,12 @@ ef10_get_datapath_caps(
 	else
 		encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
 
+	/* Check if firmware supports VLAN stripping. */
+	if (CAP_FLAGS1(req, RX_VLAN_STRIPPING))
+		encp->enc_rx_vlan_stripping_supported = B_TRUE;
+	else
+		encp->enc_rx_vlan_stripping_supported = B_FALSE;
+
 	/* Check if the firmware supports RX event batching */
 	if (CAP_FLAGS1(req, RX_BATCHING))
 		encp->enc_rx_batching_enabled = B_TRUE;
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index ef626cc55a..7fcf48f5e1 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1627,6 +1627,7 @@ typedef struct efx_nic_cfg_s {
 	/* Number of TSO contexts on the NIC (FATSOv2) */
 	uint32_t		enc_fw_assisted_tso_v2_n_contexts;
 	boolean_t		enc_hw_tx_insert_vlan_enabled;
+	boolean_t		enc_rx_vlan_stripping_supported;
 	/* Number of PFs on the NIC */
 	uint32_t		enc_hw_pf_count;
 	/* Datapath firmware vadapter/vport/vswitch support */
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index ca38eefa7e..e334f01b03 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -179,6 +179,7 @@ siena_board_cfg(
 	    (encp->enc_rxq_limit * EFX_RXQ_DC_NDESCS(EFX_RXQ_DC_SIZE));
 
 	encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
+	encp->enc_rx_vlan_stripping_supported = B_FALSE;
 	encp->enc_fw_assisted_tso_enabled = B_FALSE;
 	encp->enc_fw_assisted_tso_v2_enabled = B_FALSE;
 	encp->enc_fw_assisted_tso_v2_n_contexts = 0;
-- 
2.34.1


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

* [PATCH v7 2/4] common/sfc_efx/base: add API to get installed filters count
  2023-06-22 15:11 ` [PATCH v7 0/4] " Artemii Morozov
  2023-06-22 15:11   ` [PATCH v7 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-22 15:11   ` Artemii Morozov
  2023-06-22 15:42     ` Andrew Rybchenko
  2023-06-22 15:11   ` [PATCH v7 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
  2023-06-22 15:11   ` [PATCH v7 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
  3 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 15:11 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This API allows to get number of installed filters. This will
be used in the future patches.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
---
 drivers/common/sfc_efx/base/ef10_filter.c | 20 ++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  6 +++++
 drivers/common/sfc_efx/base/efx_filter.c  | 32 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  7 +++++
 4 files changed, 65 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index d6940011c0..278502fb61 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -2113,6 +2113,26 @@ ef10_filter_reconfigure(
 	return (rc);
 }
 
+	__checkReturn	efx_rc_t
+ef10_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count)
+{
+	ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
+	uint32_t filters_count;
+
+	EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
+	EFSYS_ASSERT(count != NULL);
+
+	filters_count = table->eft_unicst_filter_count +
+			table->eft_mulcst_filter_count +
+			table->eft_encap_filter_count;
+
+	*count = filters_count;
+
+	return (0);
+}
+
 		void
 ef10_filter_get_default_rxq(
 	__in		efx_nic_t *enp,
diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
index 877aedad45..914bba10ce 100644
--- a/drivers/common/sfc_efx/base/ef10_impl.h
+++ b/drivers/common/sfc_efx/base/ef10_impl.h
@@ -1347,6 +1347,12 @@ ef10_filter_reconfigure(
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				uint32_t count);
 
+LIBEFX_INTERNAL
+extern	__checkReturn	efx_rc_t
+ef10_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count);
+
 LIBEFX_INTERNAL
 extern		void
 ef10_filter_get_default_rxq(
diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
index 83c37ff859..064630a66b 100644
--- a/drivers/common/sfc_efx/base/efx_filter.c
+++ b/drivers/common/sfc_efx/base/efx_filter.c
@@ -53,6 +53,7 @@ static const efx_filter_ops_t	__efx_filter_siena_ops = {
 	siena_filter_delete,		/* efo_delete */
 	siena_filter_supported_filters,	/* efo_supported_filters */
 	NULL,				/* efo_reconfigure */
+	NULL,				/* efo_get_count */
 };
 #endif /* EFSYS_OPT_SIENA */
 
@@ -65,6 +66,7 @@ static const efx_filter_ops_t	__efx_filter_ef10_ops = {
 	ef10_filter_delete,		/* efo_delete */
 	ef10_filter_supported_filters,	/* efo_supported_filters */
 	ef10_filter_reconfigure,	/* efo_reconfigure */
+	ef10_filter_get_count,		/* efo_get_count */
 };
 #endif /* EFX_OPTS_EF10() */
 
@@ -77,6 +79,7 @@ static const efx_filter_ops_t	__efx_filter_rhead_ops = {
 	ef10_filter_delete,		/* efo_delete */
 	ef10_filter_supported_filters,	/* efo_supported_filters */
 	ef10_filter_reconfigure,	/* efo_reconfigure */
+	ef10_filter_get_count,		/* efo_get_count */
 };
 #endif /* EFSYS_OPT_RIVERHEAD */
 
@@ -309,6 +312,35 @@ efx_filter_reconfigure(
 fail1:
 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
+	return (rc);
+}
+
+	__checkReturn	efx_rc_t
+efx_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count)
+{
+	efx_rc_t rc;
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_FILTER);
+
+	if (enp->en_efop->efo_get_count == NULL) {
+		rc = ENOTSUP;
+		goto fail1;
+	}
+
+	if ((rc = enp->en_efop->efo_get_count(enp, count)) != 0)
+		goto fail2;
+
+	return (0);
+
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
 	return (rc);
 }
 
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 92a30c34ae..91ba187c73 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -288,6 +288,7 @@ typedef struct efx_filter_ops_s {
 	efx_rc_t	(*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
 				   boolean_t, boolean_t, boolean_t,
 				   uint8_t const *, uint32_t);
+	efx_rc_t	(*efo_get_count)(efx_nic_t *, uint32_t *);
 } efx_filter_ops_t;
 
 LIBEFX_INTERNAL
@@ -302,6 +303,12 @@ efx_filter_reconfigure(
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				uint32_t count);
 
+LIBEFX_INTERNAL
+extern	__checkReturn	efx_rc_t
+efx_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *count);
+
 #endif /* EFSYS_OPT_FILTER */
 
 #if EFSYS_OPT_TUNNEL
-- 
2.34.1


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

* [PATCH v7 3/4] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-22 15:11 ` [PATCH v7 0/4] " Artemii Morozov
  2023-06-22 15:11   ` [PATCH v7 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
  2023-06-22 15:11   ` [PATCH v7 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
@ 2023-06-22 15:11   ` Artemii Morozov
  2023-06-22 15:40     ` Andrew Rybchenko
  2023-06-22 15:11   ` [PATCH v7 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
  3 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 15:11 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

To enable VLAN stripping, two conditions must be met:
the corresponding flag must be set and the appropriate
Rx prefix should be requested.
VLAN stripping is supported on EF100.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 drivers/common/sfc_efx/base/ef10_filter.c |  6 ++++
 drivers/common/sfc_efx/base/efx.h         | 12 +++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_port.c    | 39 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_rx.c      | 14 ++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 ++
 drivers/common/sfc_efx/version.map        |  1 +
 7 files changed, 76 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index 278502fb61..3e6dd2e35c 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -171,6 +171,7 @@ efx_mcdi_filter_op_add(
 	EFX_MCDI_DECLARE_BUF(payload, MC_CMD_FILTER_OP_V3_IN_LEN,
 		MC_CMD_FILTER_OP_EXT_OUT_LEN);
 	efx_filter_match_flags_t match_flags;
+	efx_port_t *epp = &(enp->en_port);
 	uint32_t port_id;
 	efx_rc_t rc;
 
@@ -338,6 +339,11 @@ efx_mcdi_filter_op_add(
 		    FILTER_OP_V3_IN_MATCH_SET_FLAG, 1);
 	}
 
+	if (epp->ep_vlan_strip) {
+		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
+		    FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);
+	}
+
 	efx_mcdi_execute(enp, &req);
 
 	if (req.emr_rc != 0) {
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 7fcf48f5e1..77f855bfb0 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1158,6 +1158,12 @@ efx_port_poll(
 	__in		efx_nic_t *enp,
 	__out_opt	efx_link_mode_t	*link_modep);
 
+LIBEFX_API
+extern	__checkReturn	efx_rc_t
+efx_port_vlan_strip_set(
+	__in		efx_nic_t *enp,
+	__in		boolean_t enabled);
+
 LIBEFX_API
 extern		void
 efx_port_fini(
@@ -3117,6 +3123,12 @@ typedef enum efx_rxq_type_e {
  * Request user flag field in the Rx prefix of a queue.
  */
 #define	EFX_RXQ_FLAG_USER_FLAG		0x20
+/*
+ * Request VLAN TCI field in the Rx prefix. The flag just
+ * controls delivery of the stripped VLAN TCI if VLAN stripping
+ * is enabled and done.
+ */
+#define	EFX_RXQ_FLAG_VLAN_STRIPPED_TCI		0x40
 
 LIBEFX_API
 extern	__checkReturn	efx_rc_t
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 91ba187c73..78cc056576 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -371,6 +371,7 @@ typedef struct efx_port_s {
 	uint32_t		ep_phy_cap_mask;
 	boolean_t		ep_mac_drain;
 	boolean_t		ep_include_fcs;
+	boolean_t		ep_vlan_strip;
 #if EFSYS_OPT_BIST
 	efx_bist_type_t		ep_current_bist;
 #endif
diff --git a/drivers/common/sfc_efx/base/efx_port.c b/drivers/common/sfc_efx/base/efx_port.c
index a5f982e335..e5a9fa6c53 100644
--- a/drivers/common/sfc_efx/base/efx_port.c
+++ b/drivers/common/sfc_efx/base/efx_port.c
@@ -204,6 +204,45 @@ efx_loopback_type_name(
 
 #endif	/* EFSYS_OPT_LOOPBACK */
 
+	__checkReturn	efx_rc_t
+efx_port_vlan_strip_set(
+	__in		efx_nic_t *enp,
+	__in		boolean_t enabled)
+{
+	efx_port_t *epp = &(enp->en_port);
+	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+	uint32_t filters_count = 0;
+	efx_rc_t rc;
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+
+	if (enabled && !encp->enc_rx_vlan_stripping_supported) {
+		rc = ENOTSUP;
+		goto fail1;
+	}
+
+	if ((rc = efx_filter_get_count(enp, &filters_count)) != 0)
+		goto fail2;
+
+	if (filters_count != 0) {
+		rc = EINVAL;
+		goto fail3;
+	}
+
+	epp->ep_vlan_strip = enabled;
+
+	return (0);
+
+fail3:
+	EFSYS_PROBE(fail3);
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
 			void
 efx_port_fini(
 	__in		efx_nic_t *enp)
diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
index 68f42f5cac..b3d9e14c67 100644
--- a/drivers/common/sfc_efx/base/efx_rx.c
+++ b/drivers/common/sfc_efx/base/efx_rx.c
@@ -941,11 +941,25 @@ efx_rx_qcreate_internal(
 			goto fail5;
 	}
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI) {
+		const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout;
+		const efx_rx_prefix_field_info_t *vlan_tci_field;
+
+		vlan_tci_field =
+		    &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI];
+		if (vlan_tci_field->erpfi_width_bits == 0) {
+			rc = ENOTSUP;
+			goto fail6;
+		}
+	}
+
 	enp->en_rx_qcount++;
 	*erpp = erp;
 
 	return (0);
 
+fail6:
+	EFSYS_PROBE(fail6);
 fail5:
 	EFSYS_PROBE(fail5);
 
diff --git a/drivers/common/sfc_efx/base/rhead_rx.c b/drivers/common/sfc_efx/base/rhead_rx.c
index d0ac5c02f8..a86551f646 100644
--- a/drivers/common/sfc_efx/base/rhead_rx.c
+++ b/drivers/common/sfc_efx/base/rhead_rx.c
@@ -640,6 +640,9 @@ rhead_rx_qcreate(
 	if (flags & EFX_RXQ_FLAG_USER_FLAG)
 		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_USER_FLAG;
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI;
+
 	/*
 	 * LENGTH is required in EF100 host interface, as receive events
 	 * do not include the packet length.
diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map
index 01113bffa7..40c97ad2b4 100644
--- a/drivers/common/sfc_efx/version.map
+++ b/drivers/common/sfc_efx/version.map
@@ -211,6 +211,7 @@ INTERNAL {
 	efx_port_init;
 	efx_port_loopback_set;
 	efx_port_poll;
+	efx_port_vlan_strip_set;
 
 	efx_pseudo_hdr_hash_get;
 	efx_pseudo_hdr_pkt_length_get;
-- 
2.34.1


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

* [PATCH v7 4/4] net/sfc: support VLAN stripping offload
  2023-06-22 15:11 ` [PATCH v7 0/4] " Artemii Morozov
                     ` (2 preceding siblings ...)
  2023-06-22 15:11   ` [PATCH v7 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-22 15:11   ` Artemii Morozov
  2023-06-22 15:41     ` Andrew Rybchenko
  2023-06-22 16:05     ` Ferruh Yigit
  3 siblings, 2 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-22 15:11 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

Extract VLAN TCI provided by the HW in the prefix and put it to mbuf.
VLAN stripping is supported for ef100 datapath only. This is device
level offload.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
---
 doc/guides/nics/sfc_efx.rst            |  4 ++--
 doc/guides/rel_notes/release_23_07.rst |  6 ++++++
 drivers/net/sfc/sfc.h                  |  1 +
 drivers/net/sfc/sfc_dp_rx.h            |  1 +
 drivers/net/sfc/sfc_ef100_rx.c         | 16 +++++++++++++++-
 drivers/net/sfc/sfc_port.c             | 11 +++++++++++
 drivers/net/sfc/sfc_rx.c               | 10 ++++++++++
 7 files changed, 46 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 24459da33e..eafb88191a 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -122,6 +122,8 @@ SFC EFX PMD has support for:
 
 - Port representors (see :ref: switch_representation)
 
+- VLAN stripping (if running firmware variant supports it)
+
 
 Non-supported Features
 ----------------------
@@ -134,8 +136,6 @@ The features not yet supported include:
 
 - VLAN filtering
 
-- VLAN stripping
-
 - LRO
 
 
diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst
index 738d35d9f7..ce523800c7 100644
--- a/doc/guides/rel_notes/release_23_07.rst
+++ b/doc/guides/rel_notes/release_23_07.rst
@@ -185,6 +185,12 @@ New Features
 
   See :doc:`../prog_guide/pdcp_lib` for more information.
 
+* **Updated Solarflare network PMD.**
+
+  Updated the Solarflare ``sfc_efx`` driver with changes including:
+
+  * Added VLAN stripping support on SN1000 SmartNICs
+
 
 Removed Items
 -------------
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 25cdeaa5cd..2432a2307e 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -75,6 +75,7 @@ struct sfc_port {
 	unsigned int			flow_ctrl;
 	boolean_t			flow_ctrl_autoneg;
 	boolean_t			include_fcs;
+	boolean_t			vlan_strip;
 	size_t				pdu;
 
 	/*
diff --git a/drivers/net/sfc/sfc_dp_rx.h b/drivers/net/sfc/sfc_dp_rx.h
index 8a504bdcf1..9f9bf28988 100644
--- a/drivers/net/sfc/sfc_dp_rx.h
+++ b/drivers/net/sfc/sfc_dp_rx.h
@@ -70,6 +70,7 @@ struct sfc_dp_rx_qcreate_info {
 	unsigned int		flags;
 #define SFC_RXQ_FLAG_RSS_HASH	0x1
 #define SFC_RXQ_FLAG_INGRESS_MPORT	0x2
+#define SFC_RXQ_FLAG_VLAN_STRIPPED_TCI	0x4
 
 	/** Rx queue size */
 	unsigned int		rxq_entries;
diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index 5563bd9a0b..2677003da3 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -68,6 +68,7 @@ struct sfc_ef100_rxq {
 #define SFC_EF100_RXQ_INGRESS_MPORT	0x80
 #define SFC_EF100_RXQ_USER_FLAG		0x100
 #define SFC_EF100_RXQ_NIC_DMA_MAP	0x200
+#define SFC_EF100_RXQ_VLAN_STRIPPED_TCI	0x400
 	unsigned int			ptr_mask;
 	unsigned int			evq_phase_bit_shift;
 	unsigned int			ready_pkts;
@@ -392,6 +393,7 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
 		SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
+		SFC_EF100_RX_PREFIX_FIELD(VLAN_STRIP_TCI, B_FALSE),
 
 #undef	SFC_EF100_RX_PREFIX_FIELD
 	}
@@ -472,6 +474,14 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
 						ESF_GZ_RX_PREFIX_INGRESS_MPORT);
 	}
 
+	if (rxq->flags & SFC_EF100_RXQ_VLAN_STRIPPED_TCI &&
+	    EFX_TEST_XWORD_BIT(rx_prefix[0],
+				   ESF_GZ_RX_PREFIX_VLAN_STRIPPED_LBN)) {
+		ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+		m->vlan_tci = EFX_XWORD_FIELD(rx_prefix[0],
+						ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI);
+	}
+
 	m->ol_flags = ol_flags;
 	return true;
 }
@@ -813,6 +823,9 @@ sfc_ef100_rx_qcreate(uint16_t port_id, uint16_t queue_id,
 	if (info->flags & SFC_RXQ_FLAG_INGRESS_MPORT)
 		rxq->flags |= SFC_EF100_RXQ_INGRESS_MPORT;
 
+	if (info->flags & SFC_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIPPED_TCI;
+
 	sfc_ef100_rx_debug(rxq, "RxQ doorbell is %p", rxq->doorbell);
 
 	*dp_rxqp = &rxq->dp;
@@ -1004,7 +1017,8 @@ struct sfc_dp_rx sfc_ef100_rx = {
 				  SFC_DP_RX_FEAT_FLOW_MARK |
 				  SFC_DP_RX_FEAT_INTR |
 				  SFC_DP_RX_FEAT_STATS,
-	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_KEEP_CRC,
+	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_KEEP_CRC |
+				  RTE_ETH_RX_OFFLOAD_VLAN_STRIP,
 	.queue_offload_capa	= RTE_ETH_RX_OFFLOAD_CHECKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 3897facfbc..e5bb6d8620 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -225,6 +225,11 @@ sfc_port_start(struct sfc_adapter *sa)
 	if (rc != 0)
 		goto fail_mac_fcntl_set;
 
+	sfc_log_init(sa, "set vlan strip to %u", port->vlan_strip);
+	rc = efx_port_vlan_strip_set(sa->nic, port->vlan_strip);
+	if (rc != 0)
+		goto fail_mac_vlan_strip_set;
+
 	/* Preserve pause capabilities set by above efx_mac_fcntl_set()  */
 	efx_phy_adv_cap_get(sa->nic, EFX_PHY_CAP_CURRENT, &phy_adv_cap);
 	SFC_ASSERT((port->phy_adv_cap & phy_pause_caps) == 0);
@@ -345,6 +350,7 @@ sfc_port_start(struct sfc_adapter *sa)
 fail_mac_pdu_set:
 fail_phy_adv_cap_set:
 fail_mac_fcntl_set:
+fail_mac_vlan_strip_set:
 #if EFSYS_OPT_LOOPBACK
 fail_loopback_set:
 #endif
@@ -392,6 +398,11 @@ sfc_port_configure(struct sfc_adapter *sa)
 	else
 		port->include_fcs = false;
 
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
+		port->vlan_strip = true;
+	else
+		port->vlan_strip = false;
+
 	return 0;
 }
 
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index ac94d973de..1dde2c1110 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -942,6 +942,9 @@ sfc_rx_get_offload_mask(struct sfc_adapter *sa)
 	if (encp->enc_rx_include_fcs_supported == 0)
 		no_caps |= RTE_ETH_RX_OFFLOAD_KEEP_CRC;
 
+	if (encp->enc_rx_vlan_stripping_supported == 0)
+		no_caps |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
+
 	return ~no_caps;
 }
 
@@ -1113,6 +1116,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	struct sfc_rxq *rxq;
 	struct sfc_dp_rx_qcreate_info info;
 	struct sfc_dp_rx_hw_limits hw_limits;
+	struct sfc_port *port = &sa->port;
 	uint16_t rx_free_thresh;
 	const char *error;
 
@@ -1197,6 +1201,9 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	    sfc_ft_is_active(sa))
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_MARK;
 
+	if (port->vlan_strip)
+		rxq_info->type_flags |= EFX_RXQ_FLAG_VLAN_STRIPPED_TCI;
+
 	rc = sfc_ev_qinit(sa, SFC_EVQ_TYPE_RX, sw_index,
 			  evq_entries, socket_id, &evq);
 	if (rc != 0)
@@ -1232,6 +1239,9 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	if (rxq_info->type_flags & EFX_RXQ_FLAG_INGRESS_MPORT)
 		rxq_info->rxq_flags |= SFC_RXQ_FLAG_INGRESS_MPORT;
 
+	if (rxq_info->type_flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		rxq_info->rxq_flags |= SFC_RXQ_FLAG_VLAN_STRIPPED_TCI;
+
 	rxq->buf_size = buf_size;
 
 	rc = sfc_dma_alloc(sa, "rxq", sw_index, EFX_NIC_DMA_ADDR_RX_RING,
-- 
2.34.1


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

* Re: [PATCH v7 3/4] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-22 15:11   ` [PATCH v7 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-22 15:40     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-22 15:40 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/22/23 18:11, Artemii Morozov wrote:
> To enable VLAN stripping, two conditions must be met:
> the corresponding flag must be set and the appropriate
> Rx prefix should be requested.
> VLAN stripping is supported on EF100.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>



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

* Re: [PATCH v7 4/4] net/sfc: support VLAN stripping offload
  2023-06-22 15:11   ` [PATCH v7 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
@ 2023-06-22 15:41     ` Andrew Rybchenko
  2023-06-22 16:05     ` Ferruh Yigit
  1 sibling, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-22 15:41 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andy Moreton

On 6/22/23 18:11, Artemii Morozov wrote:
> Extract VLAN TCI provided by the HW in the prefix and put it to mbuf.
> VLAN stripping is supported for ef100 datapath only. This is device
> level offload.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>



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

* Re: [PATCH v7 2/4] common/sfc_efx/base: add API to get installed filters count
  2023-06-22 15:11   ` [PATCH v7 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
@ 2023-06-22 15:42     ` Andrew Rybchenko
  0 siblings, 0 replies; 57+ messages in thread
From: Andrew Rybchenko @ 2023-06-22 15:42 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov

On 6/22/23 18:11, Artemii Morozov wrote:
> This API allows to get number of installed filters. This will
> be used in the future patches.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>

Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

However, it would be good if it is reviewed as well by Andy and Ivan.

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

* Re: [PATCH v7 4/4] net/sfc: support VLAN stripping offload
  2023-06-22 15:11   ` [PATCH v7 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-06-22 15:41     ` Andrew Rybchenko
@ 2023-06-22 16:05     ` Ferruh Yigit
  1 sibling, 0 replies; 57+ messages in thread
From: Ferruh Yigit @ 2023-06-22 16:05 UTC (permalink / raw)
  To: Artemii Morozov, dev
  Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

On 6/22/2023 4:11 PM, Artemii Morozov wrote:
> Extract VLAN TCI provided by the HW in the prefix and put it to mbuf.
> VLAN stripping is supported for ef100 datapath only. This is device
> level offload.
> 
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
> Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
> Reviewed-by: Andy Moreton <amoreton@xilinx.com>

<...>

> diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst
> index 738d35d9f7..ce523800c7 100644
> --- a/doc/guides/rel_notes/release_23_07.rst
> +++ b/doc/guides/rel_notes/release_23_07.rst
> @@ -185,6 +185,12 @@ New Features
>  
>    See :doc:`../prog_guide/pdcp_lib` for more information.
>  
> +* **Updated Solarflare network PMD.**
> +
> +  Updated the Solarflare ``sfc_efx`` driver with changes including:
> +
> +  * Added VLAN stripping support on SN1000 SmartNICs
> +
>  

Can you please move release notes update to existing Solarflace block above?


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

* [PATCH v8 0/4] net/sfc: support VLAN stripping offload
  2023-05-31 13:41 [PATCH 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
                   ` (6 preceding siblings ...)
  2023-06-22 15:11 ` [PATCH v7 0/4] " Artemii Morozov
@ 2023-06-23  5:47 ` Artemii Morozov
  2023-06-23  5:47   ` [PATCH v8 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
                     ` (4 more replies)
  7 siblings, 5 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-23  5:47 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This patch series adds VLAN stripping offload. Note that this
offload are device level offload.

v8:
  * fix minor issues
  * update the release notes

v7:
  * raise an error if there is no callback for efo_get_count
  * fix alignment
  * remove the extra check

v6:
  * highlight that efx_port_vlan_strip_set() must be called before any filter insertion
  * avoid an extra check if offload is not requested

v5:
  * fixed problems with naming
  * fixed problems with abbreviations
  * fixed problems with isolated mode
  * fixed problems with consistency

v4:
  * fix apply patch failure warning

v3:
  * fix apply patch failure warning

v2:
  * rebase patches on top of dpdk-next-net/main

Artemii Morozov (4):
  common/sfc_efx/base: report VLAN stripping capability
  common/sfc_efx/base: add API to get installed filters count
  common/sfc_efx/base: add support to enable VLAN stripping
  net/sfc: support VLAN stripping offload

 doc/guides/nics/sfc_efx.rst               |  4 +--
 doc/guides/rel_notes/release_23_07.rst    |  2 ++
 drivers/common/sfc_efx/base/ef10_filter.c | 26 +++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  6 ++++
 drivers/common/sfc_efx/base/ef10_nic.c    |  6 ++++
 drivers/common/sfc_efx/base/efx.h         | 13 ++++++++
 drivers/common/sfc_efx/base/efx_filter.c  | 32 +++++++++++++++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  8 +++++
 drivers/common/sfc_efx/base/efx_port.c    | 39 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_rx.c      | 14 ++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 ++
 drivers/common/sfc_efx/base/siena_nic.c   |  1 +
 drivers/common/sfc_efx/version.map        |  1 +
 drivers/net/sfc/sfc.h                     |  1 +
 drivers/net/sfc/sfc_dp_rx.h               |  1 +
 drivers/net/sfc/sfc_ef100_rx.c            | 16 +++++++++-
 drivers/net/sfc/sfc_port.c                | 11 +++++++
 drivers/net/sfc/sfc_rx.c                  | 10 ++++++
 18 files changed, 191 insertions(+), 3 deletions(-)

-- 
2.34.1


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

* [PATCH v8 1/4] common/sfc_efx/base: report VLAN stripping capability
  2023-06-23  5:47 ` [PATCH v8 0/4] " Artemii Morozov
@ 2023-06-23  5:47   ` Artemii Morozov
  2023-06-23  5:47   ` [PATCH v8 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-23  5:47 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

These changes are necessary in order to add support for stripping
VLAN tags in the future.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/common/sfc_efx/base/ef10_nic.c  | 6 ++++++
 drivers/common/sfc_efx/base/efx.h       | 1 +
 drivers/common/sfc_efx/base/siena_nic.c | 1 +
 3 files changed, 8 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_nic.c b/drivers/common/sfc_efx/base/ef10_nic.c
index bf9cb9d309..79d596b5ef 100644
--- a/drivers/common/sfc_efx/base/ef10_nic.c
+++ b/drivers/common/sfc_efx/base/ef10_nic.c
@@ -1223,6 +1223,12 @@ ef10_get_datapath_caps(
 	else
 		encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
 
+	/* Check if firmware supports VLAN stripping. */
+	if (CAP_FLAGS1(req, RX_VLAN_STRIPPING))
+		encp->enc_rx_vlan_stripping_supported = B_TRUE;
+	else
+		encp->enc_rx_vlan_stripping_supported = B_FALSE;
+
 	/* Check if the firmware supports RX event batching */
 	if (CAP_FLAGS1(req, RX_BATCHING))
 		encp->enc_rx_batching_enabled = B_TRUE;
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index ef626cc55a..7fcf48f5e1 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1627,6 +1627,7 @@ typedef struct efx_nic_cfg_s {
 	/* Number of TSO contexts on the NIC (FATSOv2) */
 	uint32_t		enc_fw_assisted_tso_v2_n_contexts;
 	boolean_t		enc_hw_tx_insert_vlan_enabled;
+	boolean_t		enc_rx_vlan_stripping_supported;
 	/* Number of PFs on the NIC */
 	uint32_t		enc_hw_pf_count;
 	/* Datapath firmware vadapter/vport/vswitch support */
diff --git a/drivers/common/sfc_efx/base/siena_nic.c b/drivers/common/sfc_efx/base/siena_nic.c
index ca38eefa7e..e334f01b03 100644
--- a/drivers/common/sfc_efx/base/siena_nic.c
+++ b/drivers/common/sfc_efx/base/siena_nic.c
@@ -179,6 +179,7 @@ siena_board_cfg(
 	    (encp->enc_rxq_limit * EFX_RXQ_DC_NDESCS(EFX_RXQ_DC_SIZE));
 
 	encp->enc_hw_tx_insert_vlan_enabled = B_FALSE;
+	encp->enc_rx_vlan_stripping_supported = B_FALSE;
 	encp->enc_fw_assisted_tso_enabled = B_FALSE;
 	encp->enc_fw_assisted_tso_v2_enabled = B_FALSE;
 	encp->enc_fw_assisted_tso_v2_n_contexts = 0;
-- 
2.34.1


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

* [PATCH v8 2/4] common/sfc_efx/base: add API to get installed filters count
  2023-06-23  5:47 ` [PATCH v8 0/4] " Artemii Morozov
  2023-06-23  5:47   ` [PATCH v8 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
@ 2023-06-23  5:47   ` Artemii Morozov
  2023-06-23  7:24     ` Ivan Malov
  2023-06-23  5:47   ` [PATCH v8 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
                     ` (2 subsequent siblings)
  4 siblings, 1 reply; 57+ messages in thread
From: Artemii Morozov @ 2023-06-23  5:47 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

This API allows to get number of installed filters. This will
be used in the future patches.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/common/sfc_efx/base/ef10_filter.c | 20 ++++++++++++++
 drivers/common/sfc_efx/base/ef10_impl.h   |  6 +++++
 drivers/common/sfc_efx/base/efx_filter.c  | 32 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  7 +++++
 4 files changed, 65 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index d6940011c0..8ceaf98a5f 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -2113,6 +2113,26 @@ ef10_filter_reconfigure(
 	return (rc);
 }
 
+	__checkReturn	efx_rc_t
+ef10_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *countp)
+{
+	ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
+	uint32_t filter_count;
+
+	EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
+	EFSYS_ASSERT(countp != NULL);
+
+	filter_count = table->eft_unicst_filter_count +
+			table->eft_mulcst_filter_count +
+			table->eft_encap_filter_count;
+
+	*countp = filter_count;
+
+	return (0);
+}
+
 		void
 ef10_filter_get_default_rxq(
 	__in		efx_nic_t *enp,
diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
index 877aedad45..3476f274ce 100644
--- a/drivers/common/sfc_efx/base/ef10_impl.h
+++ b/drivers/common/sfc_efx/base/ef10_impl.h
@@ -1347,6 +1347,12 @@ ef10_filter_reconfigure(
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				uint32_t count);
 
+LIBEFX_INTERNAL
+extern	__checkReturn	efx_rc_t
+ef10_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *countp);
+
 LIBEFX_INTERNAL
 extern		void
 ef10_filter_get_default_rxq(
diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
index 83c37ff859..2c8c7bdc33 100644
--- a/drivers/common/sfc_efx/base/efx_filter.c
+++ b/drivers/common/sfc_efx/base/efx_filter.c
@@ -53,6 +53,7 @@ static const efx_filter_ops_t	__efx_filter_siena_ops = {
 	siena_filter_delete,		/* efo_delete */
 	siena_filter_supported_filters,	/* efo_supported_filters */
 	NULL,				/* efo_reconfigure */
+	NULL,				/* efo_get_count */
 };
 #endif /* EFSYS_OPT_SIENA */
 
@@ -65,6 +66,7 @@ static const efx_filter_ops_t	__efx_filter_ef10_ops = {
 	ef10_filter_delete,		/* efo_delete */
 	ef10_filter_supported_filters,	/* efo_supported_filters */
 	ef10_filter_reconfigure,	/* efo_reconfigure */
+	ef10_filter_get_count,		/* efo_get_count */
 };
 #endif /* EFX_OPTS_EF10() */
 
@@ -77,6 +79,7 @@ static const efx_filter_ops_t	__efx_filter_rhead_ops = {
 	ef10_filter_delete,		/* efo_delete */
 	ef10_filter_supported_filters,	/* efo_supported_filters */
 	ef10_filter_reconfigure,	/* efo_reconfigure */
+	ef10_filter_get_count,		/* efo_get_count */
 };
 #endif /* EFSYS_OPT_RIVERHEAD */
 
@@ -309,6 +312,35 @@ efx_filter_reconfigure(
 fail1:
 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
 
+	return (rc);
+}
+
+	__checkReturn	efx_rc_t
+efx_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *countp)
+{
+	efx_rc_t rc;
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_FILTER);
+
+	if (enp->en_efop->efo_get_count == NULL) {
+		rc = ENOTSUP;
+		goto fail1;
+	}
+
+	if ((rc = enp->en_efop->efo_get_count(enp, countp)) != 0)
+		goto fail2;
+
+	return (0);
+
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
 	return (rc);
 }
 
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 92a30c34ae..9a387a7efc 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -288,6 +288,7 @@ typedef struct efx_filter_ops_s {
 	efx_rc_t	(*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
 				   boolean_t, boolean_t, boolean_t,
 				   uint8_t const *, uint32_t);
+	efx_rc_t	(*efo_get_count)(efx_nic_t *, uint32_t *);
 } efx_filter_ops_t;
 
 LIBEFX_INTERNAL
@@ -302,6 +303,12 @@ efx_filter_reconfigure(
 	__in_ecount(6*count)		uint8_t const *addrs,
 	__in				uint32_t count);
 
+LIBEFX_INTERNAL
+extern	__checkReturn	efx_rc_t
+efx_filter_get_count(
+	__in	efx_nic_t *enp,
+	__out	uint32_t *countp);
+
 #endif /* EFSYS_OPT_FILTER */
 
 #if EFSYS_OPT_TUNNEL
-- 
2.34.1


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

* [PATCH v8 3/4] common/sfc_efx/base: add support to enable VLAN stripping
  2023-06-23  5:47 ` [PATCH v8 0/4] " Artemii Morozov
  2023-06-23  5:47   ` [PATCH v8 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
  2023-06-23  5:47   ` [PATCH v8 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
@ 2023-06-23  5:47   ` Artemii Morozov
  2023-06-23  5:47   ` [PATCH v8 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
  2023-06-23 12:35   ` [PATCH v8 0/4] " Ferruh Yigit
  4 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-23  5:47 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

To enable VLAN stripping, two conditions must be met:
the corresponding flag must be set and the appropriate
Rx prefix should be requested.
VLAN stripping is supported on EF100.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/common/sfc_efx/base/ef10_filter.c |  6 ++++
 drivers/common/sfc_efx/base/efx.h         | 12 +++++++
 drivers/common/sfc_efx/base/efx_impl.h    |  1 +
 drivers/common/sfc_efx/base/efx_port.c    | 39 +++++++++++++++++++++++
 drivers/common/sfc_efx/base/efx_rx.c      | 14 ++++++++
 drivers/common/sfc_efx/base/rhead_rx.c    |  3 ++
 drivers/common/sfc_efx/version.map        |  1 +
 7 files changed, 76 insertions(+)

diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
index 8ceaf98a5f..2a10720122 100644
--- a/drivers/common/sfc_efx/base/ef10_filter.c
+++ b/drivers/common/sfc_efx/base/ef10_filter.c
@@ -171,6 +171,7 @@ efx_mcdi_filter_op_add(
 	EFX_MCDI_DECLARE_BUF(payload, MC_CMD_FILTER_OP_V3_IN_LEN,
 		MC_CMD_FILTER_OP_EXT_OUT_LEN);
 	efx_filter_match_flags_t match_flags;
+	efx_port_t *epp = &(enp->en_port);
 	uint32_t port_id;
 	efx_rc_t rc;
 
@@ -338,6 +339,11 @@ efx_mcdi_filter_op_add(
 		    FILTER_OP_V3_IN_MATCH_SET_FLAG, 1);
 	}
 
+	if (epp->ep_vlan_strip) {
+		MCDI_IN_SET_DWORD_FIELD(req, FILTER_OP_V3_IN_MATCH_ACTION_FLAGS,
+		    FILTER_OP_V3_IN_MATCH_STRIP_VLAN, 1);
+	}
+
 	efx_mcdi_execute(enp, &req);
 
 	if (req.emr_rc != 0) {
diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index 7fcf48f5e1..77f855bfb0 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -1158,6 +1158,12 @@ efx_port_poll(
 	__in		efx_nic_t *enp,
 	__out_opt	efx_link_mode_t	*link_modep);
 
+LIBEFX_API
+extern	__checkReturn	efx_rc_t
+efx_port_vlan_strip_set(
+	__in		efx_nic_t *enp,
+	__in		boolean_t enabled);
+
 LIBEFX_API
 extern		void
 efx_port_fini(
@@ -3117,6 +3123,12 @@ typedef enum efx_rxq_type_e {
  * Request user flag field in the Rx prefix of a queue.
  */
 #define	EFX_RXQ_FLAG_USER_FLAG		0x20
+/*
+ * Request VLAN TCI field in the Rx prefix. The flag just
+ * controls delivery of the stripped VLAN TCI if VLAN stripping
+ * is enabled and done.
+ */
+#define	EFX_RXQ_FLAG_VLAN_STRIPPED_TCI		0x40
 
 LIBEFX_API
 extern	__checkReturn	efx_rc_t
diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
index 9a387a7efc..662a21e90c 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -371,6 +371,7 @@ typedef struct efx_port_s {
 	uint32_t		ep_phy_cap_mask;
 	boolean_t		ep_mac_drain;
 	boolean_t		ep_include_fcs;
+	boolean_t		ep_vlan_strip;
 #if EFSYS_OPT_BIST
 	efx_bist_type_t		ep_current_bist;
 #endif
diff --git a/drivers/common/sfc_efx/base/efx_port.c b/drivers/common/sfc_efx/base/efx_port.c
index a5f982e335..389efb2fe9 100644
--- a/drivers/common/sfc_efx/base/efx_port.c
+++ b/drivers/common/sfc_efx/base/efx_port.c
@@ -204,6 +204,45 @@ efx_loopback_type_name(
 
 #endif	/* EFSYS_OPT_LOOPBACK */
 
+	__checkReturn	efx_rc_t
+efx_port_vlan_strip_set(
+	__in		efx_nic_t *enp,
+	__in		boolean_t enabled)
+{
+	efx_port_t *epp = &(enp->en_port);
+	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+	uint32_t filter_count = 0;
+	efx_rc_t rc;
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+
+	if (enabled && !encp->enc_rx_vlan_stripping_supported) {
+		rc = ENOTSUP;
+		goto fail1;
+	}
+
+	if ((rc = efx_filter_get_count(enp, &filter_count)) != 0)
+		goto fail2;
+
+	if (filter_count != 0) {
+		rc = EINVAL;
+		goto fail3;
+	}
+
+	epp->ep_vlan_strip = enabled;
+
+	return (0);
+
+fail3:
+	EFSYS_PROBE(fail3);
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
 			void
 efx_port_fini(
 	__in		efx_nic_t *enp)
diff --git a/drivers/common/sfc_efx/base/efx_rx.c b/drivers/common/sfc_efx/base/efx_rx.c
index 68f42f5cac..b3d9e14c67 100644
--- a/drivers/common/sfc_efx/base/efx_rx.c
+++ b/drivers/common/sfc_efx/base/efx_rx.c
@@ -941,11 +941,25 @@ efx_rx_qcreate_internal(
 			goto fail5;
 	}
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI) {
+		const efx_rx_prefix_layout_t *erplp = &erp->er_prefix_layout;
+		const efx_rx_prefix_field_info_t *vlan_tci_field;
+
+		vlan_tci_field =
+		    &erplp->erpl_fields[EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI];
+		if (vlan_tci_field->erpfi_width_bits == 0) {
+			rc = ENOTSUP;
+			goto fail6;
+		}
+	}
+
 	enp->en_rx_qcount++;
 	*erpp = erp;
 
 	return (0);
 
+fail6:
+	EFSYS_PROBE(fail6);
 fail5:
 	EFSYS_PROBE(fail5);
 
diff --git a/drivers/common/sfc_efx/base/rhead_rx.c b/drivers/common/sfc_efx/base/rhead_rx.c
index d0ac5c02f8..a86551f646 100644
--- a/drivers/common/sfc_efx/base/rhead_rx.c
+++ b/drivers/common/sfc_efx/base/rhead_rx.c
@@ -640,6 +640,9 @@ rhead_rx_qcreate(
 	if (flags & EFX_RXQ_FLAG_USER_FLAG)
 		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_USER_FLAG;
 
+	if (flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		fields_mask |= 1U << EFX_RX_PREFIX_FIELD_VLAN_STRIP_TCI;
+
 	/*
 	 * LENGTH is required in EF100 host interface, as receive events
 	 * do not include the packet length.
diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map
index 01113bffa7..40c97ad2b4 100644
--- a/drivers/common/sfc_efx/version.map
+++ b/drivers/common/sfc_efx/version.map
@@ -211,6 +211,7 @@ INTERNAL {
 	efx_port_init;
 	efx_port_loopback_set;
 	efx_port_poll;
+	efx_port_vlan_strip_set;
 
 	efx_pseudo_hdr_hash_get;
 	efx_pseudo_hdr_pkt_length_get;
-- 
2.34.1


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

* [PATCH v8 4/4] net/sfc: support VLAN stripping offload
  2023-06-23  5:47 ` [PATCH v8 0/4] " Artemii Morozov
                     ` (2 preceding siblings ...)
  2023-06-23  5:47   ` [PATCH v8 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
@ 2023-06-23  5:47   ` Artemii Morozov
  2023-06-23 12:35   ` [PATCH v8 0/4] " Ferruh Yigit
  4 siblings, 0 replies; 57+ messages in thread
From: Artemii Morozov @ 2023-06-23  5:47 UTC (permalink / raw)
  To: dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko, Andy Moreton

Extract VLAN TCI provided by the HW in the prefix and put it to mbuf.
VLAN stripping is supported for ef100 datapath only. This is device
level offload.

Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
Reviewed-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 doc/guides/nics/sfc_efx.rst            |  4 ++--
 doc/guides/rel_notes/release_23_07.rst |  2 ++
 drivers/net/sfc/sfc.h                  |  1 +
 drivers/net/sfc/sfc_dp_rx.h            |  1 +
 drivers/net/sfc/sfc_ef100_rx.c         | 16 +++++++++++++++-
 drivers/net/sfc/sfc_port.c             | 11 +++++++++++
 drivers/net/sfc/sfc_rx.c               | 10 ++++++++++
 7 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/doc/guides/nics/sfc_efx.rst b/doc/guides/nics/sfc_efx.rst
index 24459da33e..eafb88191a 100644
--- a/doc/guides/nics/sfc_efx.rst
+++ b/doc/guides/nics/sfc_efx.rst
@@ -122,6 +122,8 @@ SFC EFX PMD has support for:
 
 - Port representors (see :ref: switch_representation)
 
+- VLAN stripping (if running firmware variant supports it)
+
 
 Non-supported Features
 ----------------------
@@ -134,8 +136,6 @@ The features not yet supported include:
 
 - VLAN filtering
 
-- VLAN stripping
-
 - LRO
 
 
diff --git a/doc/guides/rel_notes/release_23_07.rst b/doc/guides/rel_notes/release_23_07.rst
index 738d35d9f7..1d5e58eea2 100644
--- a/doc/guides/rel_notes/release_23_07.rst
+++ b/doc/guides/rel_notes/release_23_07.rst
@@ -147,6 +147,8 @@ New Features
 
   * Added support for keeping CRC.
 
+  * Added VLAN stripping support on SN1000 SmartNICs.
+
 * **Added vmxnet3 version 7 support.**
 
   Added support for vmxnet3 version 7 which includes support
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 25cdeaa5cd..2432a2307e 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -75,6 +75,7 @@ struct sfc_port {
 	unsigned int			flow_ctrl;
 	boolean_t			flow_ctrl_autoneg;
 	boolean_t			include_fcs;
+	boolean_t			vlan_strip;
 	size_t				pdu;
 
 	/*
diff --git a/drivers/net/sfc/sfc_dp_rx.h b/drivers/net/sfc/sfc_dp_rx.h
index 8a504bdcf1..9f9bf28988 100644
--- a/drivers/net/sfc/sfc_dp_rx.h
+++ b/drivers/net/sfc/sfc_dp_rx.h
@@ -70,6 +70,7 @@ struct sfc_dp_rx_qcreate_info {
 	unsigned int		flags;
 #define SFC_RXQ_FLAG_RSS_HASH	0x1
 #define SFC_RXQ_FLAG_INGRESS_MPORT	0x2
+#define SFC_RXQ_FLAG_VLAN_STRIPPED_TCI	0x4
 
 	/** Rx queue size */
 	unsigned int		rxq_entries;
diff --git a/drivers/net/sfc/sfc_ef100_rx.c b/drivers/net/sfc/sfc_ef100_rx.c
index 5563bd9a0b..2677003da3 100644
--- a/drivers/net/sfc/sfc_ef100_rx.c
+++ b/drivers/net/sfc/sfc_ef100_rx.c
@@ -68,6 +68,7 @@ struct sfc_ef100_rxq {
 #define SFC_EF100_RXQ_INGRESS_MPORT	0x80
 #define SFC_EF100_RXQ_USER_FLAG		0x100
 #define SFC_EF100_RXQ_NIC_DMA_MAP	0x200
+#define SFC_EF100_RXQ_VLAN_STRIPPED_TCI	0x400
 	unsigned int			ptr_mask;
 	unsigned int			evq_phase_bit_shift;
 	unsigned int			ready_pkts;
@@ -392,6 +393,7 @@ static const efx_rx_prefix_layout_t sfc_ef100_rx_prefix_layout = {
 		SFC_EF100_RX_PREFIX_FIELD(RSS_HASH, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_FLAG, B_FALSE),
 		SFC_EF100_RX_PREFIX_FIELD(USER_MARK, B_FALSE),
+		SFC_EF100_RX_PREFIX_FIELD(VLAN_STRIP_TCI, B_FALSE),
 
 #undef	SFC_EF100_RX_PREFIX_FIELD
 	}
@@ -472,6 +474,14 @@ sfc_ef100_rx_prefix_to_offloads(const struct sfc_ef100_rxq *rxq,
 						ESF_GZ_RX_PREFIX_INGRESS_MPORT);
 	}
 
+	if (rxq->flags & SFC_EF100_RXQ_VLAN_STRIPPED_TCI &&
+	    EFX_TEST_XWORD_BIT(rx_prefix[0],
+				   ESF_GZ_RX_PREFIX_VLAN_STRIPPED_LBN)) {
+		ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
+		m->vlan_tci = EFX_XWORD_FIELD(rx_prefix[0],
+						ESF_GZ_RX_PREFIX_VLAN_STRIP_TCI);
+	}
+
 	m->ol_flags = ol_flags;
 	return true;
 }
@@ -813,6 +823,9 @@ sfc_ef100_rx_qcreate(uint16_t port_id, uint16_t queue_id,
 	if (info->flags & SFC_RXQ_FLAG_INGRESS_MPORT)
 		rxq->flags |= SFC_EF100_RXQ_INGRESS_MPORT;
 
+	if (info->flags & SFC_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		rxq->flags |= SFC_EF100_RXQ_VLAN_STRIPPED_TCI;
+
 	sfc_ef100_rx_debug(rxq, "RxQ doorbell is %p", rxq->doorbell);
 
 	*dp_rxqp = &rxq->dp;
@@ -1004,7 +1017,8 @@ struct sfc_dp_rx sfc_ef100_rx = {
 				  SFC_DP_RX_FEAT_FLOW_MARK |
 				  SFC_DP_RX_FEAT_INTR |
 				  SFC_DP_RX_FEAT_STATS,
-	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_KEEP_CRC,
+	.dev_offload_capa	= RTE_ETH_RX_OFFLOAD_KEEP_CRC |
+				  RTE_ETH_RX_OFFLOAD_VLAN_STRIP,
 	.queue_offload_capa	= RTE_ETH_RX_OFFLOAD_CHECKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
 				  RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
diff --git a/drivers/net/sfc/sfc_port.c b/drivers/net/sfc/sfc_port.c
index 3897facfbc..e5bb6d8620 100644
--- a/drivers/net/sfc/sfc_port.c
+++ b/drivers/net/sfc/sfc_port.c
@@ -225,6 +225,11 @@ sfc_port_start(struct sfc_adapter *sa)
 	if (rc != 0)
 		goto fail_mac_fcntl_set;
 
+	sfc_log_init(sa, "set vlan strip to %u", port->vlan_strip);
+	rc = efx_port_vlan_strip_set(sa->nic, port->vlan_strip);
+	if (rc != 0)
+		goto fail_mac_vlan_strip_set;
+
 	/* Preserve pause capabilities set by above efx_mac_fcntl_set()  */
 	efx_phy_adv_cap_get(sa->nic, EFX_PHY_CAP_CURRENT, &phy_adv_cap);
 	SFC_ASSERT((port->phy_adv_cap & phy_pause_caps) == 0);
@@ -345,6 +350,7 @@ sfc_port_start(struct sfc_adapter *sa)
 fail_mac_pdu_set:
 fail_phy_adv_cap_set:
 fail_mac_fcntl_set:
+fail_mac_vlan_strip_set:
 #if EFSYS_OPT_LOOPBACK
 fail_loopback_set:
 #endif
@@ -392,6 +398,11 @@ sfc_port_configure(struct sfc_adapter *sa)
 	else
 		port->include_fcs = false;
 
+	if (rxmode->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
+		port->vlan_strip = true;
+	else
+		port->vlan_strip = false;
+
 	return 0;
 }
 
diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c
index ac94d973de..1dde2c1110 100644
--- a/drivers/net/sfc/sfc_rx.c
+++ b/drivers/net/sfc/sfc_rx.c
@@ -942,6 +942,9 @@ sfc_rx_get_offload_mask(struct sfc_adapter *sa)
 	if (encp->enc_rx_include_fcs_supported == 0)
 		no_caps |= RTE_ETH_RX_OFFLOAD_KEEP_CRC;
 
+	if (encp->enc_rx_vlan_stripping_supported == 0)
+		no_caps |= RTE_ETH_RX_OFFLOAD_VLAN_STRIP;
+
 	return ~no_caps;
 }
 
@@ -1113,6 +1116,7 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	struct sfc_rxq *rxq;
 	struct sfc_dp_rx_qcreate_info info;
 	struct sfc_dp_rx_hw_limits hw_limits;
+	struct sfc_port *port = &sa->port;
 	uint16_t rx_free_thresh;
 	const char *error;
 
@@ -1197,6 +1201,9 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	    sfc_ft_is_active(sa))
 		rxq_info->type_flags |= EFX_RXQ_FLAG_USER_MARK;
 
+	if (port->vlan_strip)
+		rxq_info->type_flags |= EFX_RXQ_FLAG_VLAN_STRIPPED_TCI;
+
 	rc = sfc_ev_qinit(sa, SFC_EVQ_TYPE_RX, sw_index,
 			  evq_entries, socket_id, &evq);
 	if (rc != 0)
@@ -1232,6 +1239,9 @@ sfc_rx_qinit(struct sfc_adapter *sa, sfc_sw_index_t sw_index,
 	if (rxq_info->type_flags & EFX_RXQ_FLAG_INGRESS_MPORT)
 		rxq_info->rxq_flags |= SFC_RXQ_FLAG_INGRESS_MPORT;
 
+	if (rxq_info->type_flags & EFX_RXQ_FLAG_VLAN_STRIPPED_TCI)
+		rxq_info->rxq_flags |= SFC_RXQ_FLAG_VLAN_STRIPPED_TCI;
+
 	rxq->buf_size = buf_size;
 
 	rc = sfc_dma_alloc(sa, "rxq", sw_index, EFX_NIC_DMA_ADDR_RX_RING,
-- 
2.34.1


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

* Re: [PATCH v8 2/4] common/sfc_efx/base: add API to get installed filters count
  2023-06-23  5:47   ` [PATCH v8 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
@ 2023-06-23  7:24     ` Ivan Malov
  0 siblings, 0 replies; 57+ messages in thread
From: Ivan Malov @ 2023-06-23  7:24 UTC (permalink / raw)
  To: Artemii Morozov; +Cc: dev, Viacheslav Galaktionov, Andrew Rybchenko

On Fri, 23 Jun 2023, Artemii Morozov wrote:

> This API allows to get number of installed filters. This will
> be used in the future patches.
>
> Signed-off-by: Artemii Morozov <artemii.morozov@arknetworks.am>
> Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>

Acked-by: Ivan Malov <ivan.malov@arknetworks.am>

Thank you.

> ---
> drivers/common/sfc_efx/base/ef10_filter.c | 20 ++++++++++++++
> drivers/common/sfc_efx/base/ef10_impl.h   |  6 +++++
> drivers/common/sfc_efx/base/efx_filter.c  | 32 +++++++++++++++++++++++
> drivers/common/sfc_efx/base/efx_impl.h    |  7 +++++
> 4 files changed, 65 insertions(+)
>
> diff --git a/drivers/common/sfc_efx/base/ef10_filter.c b/drivers/common/sfc_efx/base/ef10_filter.c
> index d6940011c0..8ceaf98a5f 100644
> --- a/drivers/common/sfc_efx/base/ef10_filter.c
> +++ b/drivers/common/sfc_efx/base/ef10_filter.c
> @@ -2113,6 +2113,26 @@ ef10_filter_reconfigure(
> 	return (rc);
> }
>
> +	__checkReturn	efx_rc_t
> +ef10_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *countp)
> +{
> +	ef10_filter_table_t *table = enp->en_filter.ef_ef10_filter_table;
> +	uint32_t filter_count;
> +
> +	EFSYS_ASSERT(EFX_FAMILY_IS_EF100(enp) || EFX_FAMILY_IS_EF10(enp));
> +	EFSYS_ASSERT(countp != NULL);
> +
> +	filter_count = table->eft_unicst_filter_count +
> +			table->eft_mulcst_filter_count +
> +			table->eft_encap_filter_count;
> +
> +	*countp = filter_count;
> +
> +	return (0);
> +}
> +
> 		void
> ef10_filter_get_default_rxq(
> 	__in		efx_nic_t *enp,
> diff --git a/drivers/common/sfc_efx/base/ef10_impl.h b/drivers/common/sfc_efx/base/ef10_impl.h
> index 877aedad45..3476f274ce 100644
> --- a/drivers/common/sfc_efx/base/ef10_impl.h
> +++ b/drivers/common/sfc_efx/base/ef10_impl.h
> @@ -1347,6 +1347,12 @@ ef10_filter_reconfigure(
> 	__in_ecount(6*count)		uint8_t const *addrs,
> 	__in				uint32_t count);
>
> +LIBEFX_INTERNAL
> +extern	__checkReturn	efx_rc_t
> +ef10_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *countp);
> +
> LIBEFX_INTERNAL
> extern		void
> ef10_filter_get_default_rxq(
> diff --git a/drivers/common/sfc_efx/base/efx_filter.c b/drivers/common/sfc_efx/base/efx_filter.c
> index 83c37ff859..2c8c7bdc33 100644
> --- a/drivers/common/sfc_efx/base/efx_filter.c
> +++ b/drivers/common/sfc_efx/base/efx_filter.c
> @@ -53,6 +53,7 @@ static const efx_filter_ops_t	__efx_filter_siena_ops = {
> 	siena_filter_delete,		/* efo_delete */
> 	siena_filter_supported_filters,	/* efo_supported_filters */
> 	NULL,				/* efo_reconfigure */
> +	NULL,				/* efo_get_count */
> };
> #endif /* EFSYS_OPT_SIENA */
>
> @@ -65,6 +66,7 @@ static const efx_filter_ops_t	__efx_filter_ef10_ops = {
> 	ef10_filter_delete,		/* efo_delete */
> 	ef10_filter_supported_filters,	/* efo_supported_filters */
> 	ef10_filter_reconfigure,	/* efo_reconfigure */
> +	ef10_filter_get_count,		/* efo_get_count */
> };
> #endif /* EFX_OPTS_EF10() */
>
> @@ -77,6 +79,7 @@ static const efx_filter_ops_t	__efx_filter_rhead_ops = {
> 	ef10_filter_delete,		/* efo_delete */
> 	ef10_filter_supported_filters,	/* efo_supported_filters */
> 	ef10_filter_reconfigure,	/* efo_reconfigure */
> +	ef10_filter_get_count,		/* efo_get_count */
> };
> #endif /* EFSYS_OPT_RIVERHEAD */
>
> @@ -309,6 +312,35 @@ efx_filter_reconfigure(
> fail1:
> 	EFSYS_PROBE1(fail1, efx_rc_t, rc);
>
> +	return (rc);
> +}
> +
> +	__checkReturn	efx_rc_t
> +efx_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *countp)
> +{
> +	efx_rc_t rc;
> +
> +	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
> +	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
> +	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_FILTER);
> +
> +	if (enp->en_efop->efo_get_count == NULL) {
> +		rc = ENOTSUP;
> +		goto fail1;
> +	}
> +
> +	if ((rc = enp->en_efop->efo_get_count(enp, countp)) != 0)
> +		goto fail2;
> +
> +	return (0);
> +
> +fail2:
> +	EFSYS_PROBE(fail2);
> +fail1:
> +	EFSYS_PROBE1(fail1, efx_rc_t, rc);
> +
> 	return (rc);
> }
>
> diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h
> index 92a30c34ae..9a387a7efc 100644
> --- a/drivers/common/sfc_efx/base/efx_impl.h
> +++ b/drivers/common/sfc_efx/base/efx_impl.h
> @@ -288,6 +288,7 @@ typedef struct efx_filter_ops_s {
> 	efx_rc_t	(*efo_reconfigure)(efx_nic_t *, uint8_t const *, boolean_t,
> 				   boolean_t, boolean_t, boolean_t,
> 				   uint8_t const *, uint32_t);
> +	efx_rc_t	(*efo_get_count)(efx_nic_t *, uint32_t *);
> } efx_filter_ops_t;
>
> LIBEFX_INTERNAL
> @@ -302,6 +303,12 @@ efx_filter_reconfigure(
> 	__in_ecount(6*count)		uint8_t const *addrs,
> 	__in				uint32_t count);
>
> +LIBEFX_INTERNAL
> +extern	__checkReturn	efx_rc_t
> +efx_filter_get_count(
> +	__in	efx_nic_t *enp,
> +	__out	uint32_t *countp);
> +
> #endif /* EFSYS_OPT_FILTER */
>
> #if EFSYS_OPT_TUNNEL
> -- 
> 2.34.1
>
>

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

* Re: [PATCH v8 0/4] net/sfc: support VLAN stripping offload
  2023-06-23  5:47 ` [PATCH v8 0/4] " Artemii Morozov
                     ` (3 preceding siblings ...)
  2023-06-23  5:47   ` [PATCH v8 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
@ 2023-06-23 12:35   ` Ferruh Yigit
  4 siblings, 0 replies; 57+ messages in thread
From: Ferruh Yigit @ 2023-06-23 12:35 UTC (permalink / raw)
  To: Artemii Morozov, dev; +Cc: Ivan Malov, Viacheslav Galaktionov, Andrew Rybchenko

On 6/23/2023 6:47 AM, Artemii Morozov wrote:
> This patch series adds VLAN stripping offload. Note that this
> offload are device level offload.
> 
> v8:
>   * fix minor issues
>   * update the release notes
> 
> v7:
>   * raise an error if there is no callback for efo_get_count
>   * fix alignment
>   * remove the extra check
> 
> v6:
>   * highlight that efx_port_vlan_strip_set() must be called before any filter insertion
>   * avoid an extra check if offload is not requested
> 
> v5:
>   * fixed problems with naming
>   * fixed problems with abbreviations
>   * fixed problems with isolated mode
>   * fixed problems with consistency
> 
> v4:
>   * fix apply patch failure warning
> 
> v3:
>   * fix apply patch failure warning
> 
> v2:
>   * rebase patches on top of dpdk-next-net/main
> 
> Artemii Morozov (4):
>   common/sfc_efx/base: report VLAN stripping capability
>   common/sfc_efx/base: add API to get installed filters count
>   common/sfc_efx/base: add support to enable VLAN stripping
>   net/sfc: support VLAN stripping offload
>

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


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

end of thread, other threads:[~2023-06-23 12:35 UTC | newest]

Thread overview: 57+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-31 13:41 [PATCH 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
2023-05-31 13:41 ` [PATCH 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
2023-06-01  8:12   ` [PATCH v2 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
2023-06-01  8:12     ` [PATCH v2 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
2023-06-01 14:35       ` [PATCH v3 0/3] net/sfc: support VLAN stripping offload Artemii Morozov
2023-06-01 14:35         ` [PATCH v3 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
2023-06-01 14:35         ` [PATCH v3 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
2023-06-01 14:35         ` [PATCH v3 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
2023-06-01  8:12     ` [PATCH v2 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
2023-06-01  8:12     ` [PATCH v2 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
2023-05-31 13:41 ` [PATCH 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
2023-05-31 13:41 ` [PATCH 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
2023-06-01 15:30 ` [PATCH v4 0/3] " Artemii Morozov
2023-06-01 15:30   ` [PATCH v4 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
2023-06-02  7:22     ` Andrew Rybchenko
2023-06-01 15:30   ` [PATCH v4 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
2023-06-02  8:32     ` Andrew Rybchenko
2023-06-08 11:16       ` Artemii Morozov
2023-06-08 12:37         ` Andrew Rybchenko
2023-06-01 15:30   ` [PATCH v4 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
2023-06-02  8:46     ` Andrew Rybchenko
2023-06-13 15:12 ` [PATCH v5 0/3] " Artemii Morozov
2023-06-13 15:12   ` [PATCH v5 1/3] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
2023-06-19  9:43     ` Andrew Rybchenko
2023-06-13 15:12   ` [PATCH v5 2/3] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
2023-06-19 10:28     ` Andrew Rybchenko
2023-06-20  9:55       ` Artemii Morozov
2023-06-20 11:50         ` Andrew Rybchenko
2023-06-20 13:10           ` Artemii Morozov
2023-06-20 13:53             ` Andrew Rybchenko
2023-06-13 15:12   ` [PATCH v5 3/3] net/sfc: support VLAN stripping offload Artemii Morozov
2023-06-19 10:36     ` Andrew Rybchenko
2023-06-22 11:31 ` [PATCH v6 0/4] " Artemii Morozov
2023-06-22 11:31   ` [PATCH v6 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
2023-06-22 11:46     ` Andrew Rybchenko
2023-06-22 11:31   ` [PATCH v6 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
2023-06-22 11:51     ` Andrew Rybchenko
2023-06-22 11:31   ` [PATCH v6 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
2023-06-22 11:54     ` Andrew Rybchenko
2023-06-22 11:31   ` [PATCH v6 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
2023-06-22 12:07     ` Andrew Rybchenko
2023-06-22 15:11 ` [PATCH v7 0/4] " Artemii Morozov
2023-06-22 15:11   ` [PATCH v7 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
2023-06-22 15:11   ` [PATCH v7 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
2023-06-22 15:42     ` Andrew Rybchenko
2023-06-22 15:11   ` [PATCH v7 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
2023-06-22 15:40     ` Andrew Rybchenko
2023-06-22 15:11   ` [PATCH v7 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
2023-06-22 15:41     ` Andrew Rybchenko
2023-06-22 16:05     ` Ferruh Yigit
2023-06-23  5:47 ` [PATCH v8 0/4] " Artemii Morozov
2023-06-23  5:47   ` [PATCH v8 1/4] common/sfc_efx/base: report VLAN stripping capability Artemii Morozov
2023-06-23  5:47   ` [PATCH v8 2/4] common/sfc_efx/base: add API to get installed filters count Artemii Morozov
2023-06-23  7:24     ` Ivan Malov
2023-06-23  5:47   ` [PATCH v8 3/4] common/sfc_efx/base: add support to enable VLAN stripping Artemii Morozov
2023-06-23  5:47   ` [PATCH v8 4/4] net/sfc: support VLAN stripping offload Artemii Morozov
2023-06-23 12:35   ` [PATCH v8 0/4] " 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).