[dpdk-dev] [PATCH 18/29] net/sfc/base: introduce of EVB module for SR-IOV support

Andrew Rybchenko arybchenko at solarflare.com
Mon Jun 10 09:38:33 CEST 2019


From: Gautam Dawar <gdawar at solarflare.com>

Implement the framework for Enterprise Virtual Briding (EVB) module.
SR-IOV augments the software virtual switch with NIC capbilities
supported from EVB module.
Further patches will add APIs to create and destroy EVB switching
hierarchy required for SR-IOV and APIs to set vPort properties like MAC,
VLAN etc.

Signed-off-by: Gautam Dawar <gdawar at solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko at solarflare.com>
---
 drivers/net/sfc/Makefile         |   2 +
 drivers/net/sfc/base/ef10_evb.c  |  35 +++++++++++++
 drivers/net/sfc/base/ef10_impl.h |  10 ++++
 drivers/net/sfc/base/efx.h       |  12 +++++
 drivers/net/sfc/base/efx_check.h |   7 +++
 drivers/net/sfc/base/efx_evb.c   | 110 +++++++++++++++++++++++++++++++++++++++
 drivers/net/sfc/base/efx_impl.h  |  13 +++++
 drivers/net/sfc/base/meson.build |   2 +
 drivers/net/sfc/efsys.h          |   2 +
 9 files changed, 193 insertions(+)
 create mode 100644 drivers/net/sfc/base/ef10_evb.c
 create mode 100644 drivers/net/sfc/base/efx_evb.c

diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile
index 3bb41a0..7149afd 100644
--- a/drivers/net/sfc/Makefile
+++ b/drivers/net/sfc/Makefile
@@ -89,6 +89,7 @@ VPATH += $(SRCDIR)/base
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_bootcfg.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_crc32.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_ev.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_evb.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_filter.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_hash.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += efx_intr.c
@@ -114,6 +115,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_phy.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_sram.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += siena_vpd.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_ev.c
+SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_evb.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_filter.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_intr.c
 SRCS-$(CONFIG_RTE_LIBRTE_SFC_EFX_PMD) += ef10_image.c
diff --git a/drivers/net/sfc/base/ef10_evb.c b/drivers/net/sfc/base/ef10_evb.c
new file mode 100644
index 0000000..03ac19a
--- /dev/null
+++ b/drivers/net/sfc/base/ef10_evb.c
@@ -0,0 +1,35 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 2018-2019 Solarflare Communications Inc.
+ * All rights reserved.
+ */
+
+#include "efx.h"
+#include "efx_impl.h"
+
+#if EFSYS_OPT_EVB
+
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
+
+	__checkReturn	efx_rc_t
+ef10_evb_init(
+	__in		efx_nic_t *enp)
+{
+	EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+		enp->en_family == EFX_FAMILY_MEDFORD ||
+		enp->en_family == EFX_FAMILY_MEDFORD2);
+
+	return (0);
+}
+
+	void
+ef10_evb_fini(
+	__in		efx_nic_t *enp)
+{
+	EFSYS_ASSERT(enp->en_family == EFX_FAMILY_HUNTINGTON ||
+		enp->en_family == EFX_FAMILY_MEDFORD ||
+		enp->en_family == EFX_FAMILY_MEDFORD2);
+}
+
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
+#endif /* EFSYS_OPT_EVB */
diff --git a/drivers/net/sfc/base/ef10_impl.h b/drivers/net/sfc/base/ef10_impl.h
index 0cfbf59..26242a1 100644
--- a/drivers/net/sfc/base/ef10_impl.h
+++ b/drivers/net/sfc/base/ef10_impl.h
@@ -1262,6 +1262,16 @@ extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 
 #endif	/* EFSYS_OPT_FW_SUBVARIANT_AWARE */
 
+#if EFSYS_OPT_EVB
+extern	__checkReturn	efx_rc_t
+ef10_evb_init(
+	__in		efx_nic_t *enp);
+
+extern void
+ef10_evb_fini(
+	__in		efx_nic_t *enp);
+
+#endif  /* EFSYS_OPT_EVB */
 
 #if EFSYS_OPT_RX_PACKED_STREAM
 
diff --git a/drivers/net/sfc/base/efx.h b/drivers/net/sfc/base/efx.h
index 40308ff..ca8a399 100644
--- a/drivers/net/sfc/base/efx.h
+++ b/drivers/net/sfc/base/efx.h
@@ -3347,6 +3347,18 @@ extern	__checkReturn	__success(return != B_FALSE)	boolean_t
 	__out		efx_phy_link_state_t  *eplsp);
 
 
+#if EFSYS_OPT_EVB
+
+extern  __checkReturn   efx_rc_t
+efx_evb_init(
+	__in		efx_nic_t *enp);
+
+extern	void
+efx_evb_fini(
+	__in		efx_nic_t *enp);
+
+#endif /* EFSYS_OPT_EVB */
+
 #ifdef	__cplusplus
 }
 #endif
diff --git a/drivers/net/sfc/base/efx_check.h b/drivers/net/sfc/base/efx_check.h
index 4800f77..85edaef 100644
--- a/drivers/net/sfc/base/efx_check.h
+++ b/drivers/net/sfc/base/efx_check.h
@@ -351,4 +351,11 @@
 # endif
 #endif
 
+#if EFSYS_OPT_EVB
+/* Support enterprise virtual bridging */
+# if !(EFX_OPTS_EF10())
+#  error "EVB requires EF10 arch"
+# endif
+#endif /* EFSYS_OPT_EVB */
+
 #endif /* _SYS_EFX_CHECK_H */
diff --git a/drivers/net/sfc/base/efx_evb.c b/drivers/net/sfc/base/efx_evb.c
new file mode 100644
index 0000000..f235252
--- /dev/null
+++ b/drivers/net/sfc/base/efx_evb.c
@@ -0,0 +1,110 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ *
+ * Copyright (c) 2018-2019 Solarflare Communications Inc.
+ * All rights reserved.
+ */
+
+#include "efx.h"
+#include "efx_impl.h"
+
+
+#if EFSYS_OPT_EVB
+
+#if EFSYS_OPT_SIENA
+static const efx_evb_ops_t	__efx_evb_dummy_ops = {
+	NULL,		/* eeo_init */
+	NULL,		/* eeo_fini */
+};
+#endif /* EFSYS_OPT_SIENA */
+
+#if EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2
+static const efx_evb_ops_t	__efx_evb_ef10_ops = {
+	ef10_evb_init,		/* eeo_init */
+	ef10_evb_fini,		/* eeo_fini */
+};
+#endif /* EFSYS_OPT_HUNTINGTON || EFSYS_OPT_MEDFORD || EFSYS_OPT_MEDFORD2 */
+
+	__checkReturn	efx_rc_t
+efx_evb_init(
+	__in		efx_nic_t *enp)
+{
+	const efx_evb_ops_t *eeop;
+	efx_rc_t rc;
+	efx_nic_cfg_t *encp = &(enp->en_nic_cfg);
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+	EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_PROBE);
+	EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_EVB));
+
+	switch (enp->en_family) {
+#if EFSYS_OPT_SIENA
+	case EFX_FAMILY_SIENA:
+		eeop = &__efx_evb_dummy_ops;
+		break;
+#endif /* EFSYS_OPT_SIENA */
+
+#if EFSYS_OPT_HUNTINGTON
+	case EFX_FAMILY_HUNTINGTON:
+		eeop = &__efx_evb_ef10_ops;
+		break;
+#endif /* EFSYS_OPT_HUNTINGTON */
+
+#if EFSYS_OPT_MEDFORD
+	case EFX_FAMILY_MEDFORD:
+		eeop = &__efx_evb_ef10_ops;
+		break;
+#endif /* EFSYS_OPT_MEDFORD */
+
+#if EFSYS_OPT_MEDFORD2
+	case EFX_FAMILY_MEDFORD2:
+		eeop = &__efx_evb_ef10_ops;
+		break;
+#endif /* EFSYS_OPT_MEDFORD2 */
+
+	default:
+		EFSYS_ASSERT(0);
+		rc = ENOTSUP;
+		goto fail1;
+	}
+
+	if (!encp->enc_datapath_cap_evb || !eeop->eeo_init) {
+		rc = ENOTSUP;
+		goto fail2;
+	}
+
+	if ((rc = eeop->eeo_init(enp)) != 0)
+		goto fail3;
+
+	enp->en_eeop = eeop;
+	enp->en_mod_flags |= EFX_MOD_EVB;
+	return (0);
+
+fail3:
+	EFSYS_PROBE(fail3);
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
+			void
+efx_evb_fini(
+	__in		efx_nic_t *enp)
+{
+	const efx_evb_ops_t *eeop = enp->en_eeop;
+
+	EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
+	EFSYS_ASSERT(enp->en_mod_flags & EFX_MOD_PROBE);
+	EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_RX));
+	EFSYS_ASSERT(!(enp->en_mod_flags & EFX_MOD_TX));
+
+	if (eeop && eeop->eeo_fini)
+		eeop->eeo_fini(enp);
+
+	enp->en_eeop = NULL;
+	enp->en_mod_flags &= ~EFX_MOD_EVB;
+}
+
+#endif
diff --git a/drivers/net/sfc/base/efx_impl.h b/drivers/net/sfc/base/efx_impl.h
index 067cec3..00f88c8 100644
--- a/drivers/net/sfc/base/efx_impl.h
+++ b/drivers/net/sfc/base/efx_impl.h
@@ -58,6 +58,7 @@
 #define	EFX_MOD_FILTER		0x00001000
 #define	EFX_MOD_LIC		0x00002000
 #define	EFX_MOD_TUNNEL		0x00004000
+#define	EFX_MOD_EVB		0x00008000
 
 #define	EFX_RESET_PHY		0x00000001
 #define	EFX_RESET_RXQ_ERR	0x00000002
@@ -649,6 +650,15 @@
 
 #endif
 
+#if EFSYS_OPT_EVB
+
+typedef struct efx_evb_ops_s {
+	efx_rc_t	(*eeo_init)(efx_nic_t *);
+	void		(*eeo_fini)(efx_nic_t *);
+} efx_evb_ops_t;
+
+#endif /* EFSYS_OPT_EVB */
+
 #define	EFX_DRV_VER_MAX		20
 
 typedef struct efx_drv_cfg_s {
@@ -747,6 +757,9 @@ struct efx_nic_s {
 		} ef10;
 	} en_arch;
 #endif	/* EFX_OPTS_EF10() */
+#if EFSYS_OPT_EVB
+	const efx_evb_ops_t	*en_eeop;
+#endif	/* EFSYS_OPT_EVB */
 };
 
 #define	EFX_FAMILY_IS_EF10(_enp) \
diff --git a/drivers/net/sfc/base/meson.build b/drivers/net/sfc/base/meson.build
index ab66f32..6fa7948 100644
--- a/drivers/net/sfc/base/meson.build
+++ b/drivers/net/sfc/base/meson.build
@@ -8,6 +8,7 @@ sources = [
 	'efx_bootcfg.c',
 	'efx_crc32.c',
 	'efx_ev.c',
+	'efx_evb.c',
 	'efx_filter.c',
 	'efx_hash.c',
 	'efx_intr.c',
@@ -33,6 +34,7 @@ sources = [
 	'siena_sram.c',
 	'siena_vpd.c',
 	'ef10_ev.c',
+	'ef10_evb.c',
 	'ef10_filter.c',
 	'ef10_image.c',
 	'ef10_intr.c',
diff --git a/drivers/net/sfc/efsys.h b/drivers/net/sfc/efsys.h
index f7bcc74..24f3769 100644
--- a/drivers/net/sfc/efsys.h
+++ b/drivers/net/sfc/efsys.h
@@ -166,6 +166,8 @@
 
 #define EFSYS_OPT_FW_SUBVARIANT_AWARE 1
 
+#define EFSYS_OPT_EVB 0
+
 /* ID */
 
 typedef struct __efsys_identifier_s efsys_identifier_t;
-- 
1.8.3.1



More information about the dev mailing list