From 94ddd501654d59fd3a6911e1770f35d86a89cfe1 Mon Sep 17 00:00:00 2001 From: Viacheslav Galaktionov Date: Mon, 11 Oct 2021 17:48:29 +0300 Subject: [PATCH] common/sfc_efx/base: allow creating invalid mport selectors There isn't always a valid mport that can be used. For these cases, special invalid selectors can be generated. Requests that use such selectors in any way will be rejected. Signed-off-by: Viacheslav Galaktionov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 11 +++++++++++ drivers/common/sfc_efx/base/efx_mae.c | 25 +++++++++++++++++++++++++ drivers/common/sfc_efx/version.map | 1 + 3 files changed, 37 insertions(+) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index 94803815ac..c0d1535017 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4196,6 +4196,17 @@ typedef struct efx_mport_id_s { #define EFX_MPORT_NULL (0U) +/* + * Generate an invalid MPORT selector. + * + * The resulting MPORT selector is opaque to the caller. Requests + * that attempt to use it will be rejected. + */ +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_mport_invalid( + __out efx_mport_sel_t *mportp); + /* * Get MPORT selector of a physical port. * diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index b38b1143d6..b7afe8fdc8 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -660,6 +660,31 @@ static const efx_mae_mv_bit_desc_t __efx_mae_action_rule_mv_bit_desc_set[] = { #undef EFX_MAE_MV_BIT_DESC }; + __checkReturn efx_rc_t +efx_mae_mport_invalid( + __out efx_mport_sel_t *mportp) +{ + efx_dword_t dword; + efx_rc_t rc; + + if (mportp == NULL) { + rc = EINVAL; + goto fail1; + } + + EFX_POPULATE_DWORD_1(dword, + MAE_MPORT_SELECTOR_TYPE, MAE_MPORT_SELECTOR_TYPE_INVALID); + + memset(mportp, 0, sizeof (*mportp)); + mportp->sel = dword.ed_u32[0]; + + return (0); + +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + __checkReturn efx_rc_t efx_mae_mport_by_phy_port( __in uint32_t phy_port, diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 3dc21878c0..611757ccde 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -127,6 +127,7 @@ INTERNAL { efx_mae_mport_by_pcie_function; efx_mae_mport_by_phy_port; efx_mae_mport_id_by_selector; + efx_mae_mport_invalid; efx_mae_outer_rule_insert; efx_mae_outer_rule_remove; -- 2.20.1