Skip to contentSkip to conversation

net/sfc: create virtual switch to enable VFs

PATCH Applied Andrew Rybchenko 2 participants 2 messages Sep 24, 2020 – Sep 30, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/sfc: create virtual switch to enable VFs

PF driver is responsible for vSwitch creation and vPorts allocation for VFs.

---
 doc/guides/nics/sfc_efx.rst                   |   2 +
 doc/guides/rel_notes/release_20_11.rst        |   6 +
 drivers/common/sfc_efx/efsys.h                |   2 +-
 .../sfc_efx/rte_common_sfc_efx_version.map    |   9 +
 drivers/net/sfc/meson.build                   |   1 +
 drivers/net/sfc/sfc.c                         |  36 ++++
 drivers/net/sfc/sfc.h                         |   4 +-
 drivers/net/sfc/sfc_ethdev.c                  |   2 +
 drivers/net/sfc/sfc_sriov.c                   | 168 ++++++++++++++++++
 drivers/net/sfc/sfc_sriov.h                   |  39 ++++
 10 files changed, 267 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/sfc/sfc_sriov.c
 create mode 100644 drivers/net/sfc/sfc_sriov.h
doc/guides/nics/sfc_efx.rst +2 -0
index be1c2fe1d6..ab44ce66c8 100644
@@ -71,6 +71,8 @@ SFC EFX PMD has support for:
 
 - Loopback
 
+- SR-IOV PF
+
 
 Non-supported Features
 ----------------------
doc/guides/rel_notes/release_20_11.rst +6 -0
index c6642f5f94..56b4ac1515 100644
@@ -62,6 +62,12 @@ New Features
   * Added support for non-zero priorities for group 0 flows
   * Added support for VXLAN decap combined with VLAN pop
 
+* **Updated Solarflare network PMD.**
+
+  Updated the Solarflare ``sfc_efx`` driver with changes including:
+
+  * Added SR-IOV PF support
+
 * **Extended flow-perf application.**
 
   * Started supporting user order instead of bit mask:
drivers/common/sfc_efx/efsys.h +1 -1
index 46b08f9789..3d769d32ae 100644
@@ -156,7 +156,7 @@ prefetch_read_once(const volatile void *addr)
 
 #define EFSYS_OPT_FW_SUBVARIANT_AWARE 1
 
-#define EFSYS_OPT_EVB 0
+#define EFSYS_OPT_EVB 1
 
 #define EFSYS_OPT_MCDI_PROXY_AUTH_SERVER 0
 
drivers/common/sfc_efx/rte_common_sfc_efx_version.map +9 -0
index 5e2a7ad919..1049e633c8 100644
@@ -14,6 +14,15 @@ INTERNAL {
 	efx_ev_qprime;
 	efx_ev_usecs_to_ticks;
 
+	efx_evb_fini;
+	efx_evb_init;
+	efx_evb_vport_mac_set;
+	efx_evb_vport_reset;
+	efx_evb_vport_stats;
+	efx_evb_vport_vlan_set;
+	efx_evb_vswitch_create;
+	efx_evb_vswitch_destroy;
+
 	efx_evq_nbufs;
 	efx_evq_size;
 
drivers/net/sfc/meson.build +1 -0
index 26f0323738..1c6451938a 100644
@@ -39,6 +39,7 @@ sources = files(
 	'sfc_kvargs.c',
 	'sfc.c',
 	'sfc_mcdi.c',
+	'sfc_sriov.c',
 	'sfc_intr.c',
 	'sfc_ev.c',
 	'sfc_port.c',
drivers/net/sfc/sfc.c +36 -0
index 03ea5dc128..493a72f3ba 100644
@@ -436,7 +436,20 @@ sfc_start(struct sfc_adapter *sa)
 
 	sa->state = SFC_ADAPTER_STARTING;
 
+	rc = 0;
 	do {
+		/*
+		 * FIXME Try to recreate vSwitch on start retry.
+		 * vSwitch is absent after MC reboot like events and
+		 * we should recreate it. May be we need proper
+		 * indication instead of guessing.
+		 */
+		if (rc != 0) {
+			sfc_sriov_vswitch_destroy(sa);
+			rc = sfc_sriov_vswitch_create(sa);
+			if (rc != 0)
+				goto fail_sriov_vswitch_create;
+		}
 		rc = sfc_try_start(sa);
 	} while ((--start_tries > 0) &&
 		 (rc == EIO || rc == EAGAIN || rc == ENOENT || rc == EINVAL));
@@ -449,6 +462,7 @@ sfc_start(struct sfc_adapter *sa)
 	return 0;
 
 fail_try_start:
+fail_sriov_vswitch_create:
 	sa->state = SFC_ADAPTER_CONFIGURED;
 fail_bad_state:
 	sfc_log_init(sa, "failed %d", rc);
@@ -727,6 +741,10 @@ sfc_attach(struct sfc_adapter *sa)
 	if (rc != 0)
 		goto fail_nic_reset;
 
+	rc = sfc_sriov_attach(sa);
+	if (rc != 0)
+		goto fail_sriov_attach;
+
 	/*
 	 * Probed NIC is sufficient for tunnel init.
 	 * Initialize tunnel support to be able to use libefx
@@ -809,11 +827,24 @@ sfc_attach(struct sfc_adapter *sa)
 
 	sfc_flow_init(sa);
 
+	/*
+	 * Create vSwitch to be able to use VFs when PF is not started yet
+	 * as DPDK port. VFs should be able to talk to each other even
+	 * if PF is down.
+	 */
+	rc = sfc_sriov_vswitch_create(sa);
+	if (rc != 0)
+		goto fail_sriov_vswitch_create;
+
 	sa->state = SFC_ADAPTER_INITIALIZED;
 
 	sfc_log_init(sa, "done");
 	return 0;
 
+fail_sriov_vswitch_create:
+	sfc_flow_fini(sa);
+	sfc_filter_detach(sa);
+
 fail_filter_attach:
 	sfc_rss_detach(sa);
 
@@ -832,7 +863,9 @@ sfc_attach(struct sfc_adapter *sa)
 fail_estimate_rsrc_limits:
 fail_tunnel_init:
 	efx_tunnel_fini(sa->nic);
+	sfc_sriov_detach(sa);
 
+fail_sriov_attach:
 fail_nic_reset:
 
 	sfc_log_init(sa, "failed %d", rc);
@@ -846,6 +879,8 @@ sfc_detach(struct sfc_adapter *sa)
 
 	SFC_ASSERT(sfc_adapter_is_locked(sa));
 
+	sfc_sriov_vswitch_destroy(sa);
+
 	sfc_flow_fini(sa);
 
 	sfc_filter_detach(sa);
@@ -854,6 +889,7 @@ sfc_detach(struct sfc_adapter *sa)
 	sfc_ev_detach(sa);
 	sfc_intr_detach(sa);
 	efx_tunnel_fini(sa->nic);
+	sfc_sriov_detach(sa);
 
 	sa->state = SFC_ADAPTER_UNINITIALIZED;
 }
drivers/net/sfc/sfc.h +3 -1
index fa7c79b80b..0c32527ad5 100644
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- *
+*
  * Copyright(c) 2019-2020 Xilinx, Inc.
  * Copyright(c) 2016-2019 Solarflare Communications Inc.
  *
@@ -26,6 +26,7 @@
 #include "sfc_debug.h"
 #include "sfc_log.h"
 #include "sfc_filter.h"
+#include "sfc_sriov.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -224,6 +225,7 @@ struct sfc_adapter {
 	rte_atomic32_t			restart_required;
 
 	struct sfc_efx_mcdi		mcdi;
+	struct sfc_sriov		sriov;
 	struct sfc_intr			intr;
 	struct sfc_port			port;
 	struct sfc_filter		filter;
drivers/net/sfc/sfc_ethdev.c +2 -0
index 6c96118007..600eaa23ea 100644
@@ -102,6 +102,8 @@ sfc_dev_infos_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
 
 	dev_info->max_rx_pktlen = EFX_MAC_PDU_MAX;
 
+	dev_info->max_vfs = sa->sriov.num_vfs;
+
 	/* Autonegotiation may be disabled */
 	dev_info->speed_capa = ETH_LINK_SPEED_FIXED;
 	if (sa->port.phy_adv_cap_mask & (1u << EFX_PHY_CAP_1000FDX))
drivers/net/sfc/sfc_sriov.c new file +168 -0

168 lines not on this page · raw message

drivers/net/sfc/sfc_sriov.h new file +39 -0
new file mode 100644
index 0000000000..2e2e1c69f1
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright(c) 2019-2020 Xilinx, Inc.
+ * Copyright(c) 2019 Solarflare Communications Inc.
+ *
+ * This software was jointly developed between OKTET Labs (under contract
+ * for Solarflare) and Solarflare Communications, Inc.
+ */
+
+#ifndef _SFC_SRIOV_H
+#define _SFC_SRIOV_H
+
+#include "efx.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct sfc_sriov {
+	/** Number of enabled virtual functions */
+	unsigned int			num_vfs;
+	/** PF and VFs vPorts configuration */
+	efx_vport_config_t		*vport_config;
+	/** vSwitch handle */
+	efx_vswitch_t			*vswitch;
+};
+
+struct sfc_adapter;
+
+int sfc_sriov_attach(struct sfc_adapter *sa);
+void sfc_sriov_detach(struct sfc_adapter *sa);
+
+int sfc_sriov_vswitch_create(struct sfc_adapter *sa);
+void sfc_sriov_vswitch_destroy(struct sfc_adapter *sa);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* _SFC_SRIOV_H */
Signature · 1 line
2.17.1