[v5,3/3] net/sfc: support VLAN stripping offload

Message ID 20230613151238.59112-4-artemii.morozov@arknetworks.am (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers
Series net/sfc: support VLAN stripping offload |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-aarch-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS

Commit Message

Artemii Morozov June 13, 2023, 3:12 p.m. UTC
  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(-)
  

Comments

Andrew Rybchenko June 19, 2023, 10:36 a.m. UTC | #1
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]
  

Patch

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)