From: Gautam Dawar Date: Mon, 10 Jun 2019 07:38:33 +0000 (+0100) Subject: net/sfc/base: introduce EVB module for SR-IOV X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=4f12e20c85dce289668ef0ff61295fdebeb14b7d;p=dpdk.git net/sfc/base: introduce EVB module for SR-IOV Implement the framework for Enterprise Virtual Briding (EVB) module. SR-IOV augments the software virtual switch with NIC capabilities 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 Signed-off-by: Andrew Rybchenko --- diff --git a/drivers/net/sfc/Makefile b/drivers/net/sfc/Makefile index 3bb41a0001..7149afd8d1 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 0000000000..03ac19ae0f --- /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 0cfbf5953a..26242a18f5 100644 --- a/drivers/net/sfc/base/ef10_impl.h +++ b/drivers/net/sfc/base/ef10_impl.h @@ -1262,6 +1262,16 @@ efx_mcdi_set_nic_global( #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 40308ff58d..ca8a399656 100644 --- a/drivers/net/sfc/base/efx.h +++ b/drivers/net/sfc/base/efx.h @@ -3347,6 +3347,18 @@ efx_phy_link_state_get( __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 4800f772bf..85edaef7d7 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 0000000000..f235252493 --- /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 067cec303c..00f88c86c2 100644 --- a/drivers/net/sfc/base/efx_impl.h +++ b/drivers/net/sfc/base/efx_impl.h @@ -58,6 +58,7 @@ extern "C" { #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 @@ typedef struct efx_lic_ops_s { #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 ab66f32f91..6fa79485a9 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 f7bcc74d9a..24f37694a7 100644 --- a/drivers/net/sfc/efsys.h +++ b/drivers/net/sfc/efsys.h @@ -166,6 +166,8 @@ prefetch_read_once(const volatile void *addr) #define EFSYS_OPT_FW_SUBVARIANT_AWARE 1 +#define EFSYS_OPT_EVB 0 + /* ID */ typedef struct __efsys_identifier_s efsys_identifier_t;