common/sfc_efx/base: allow creating invalid mport selectors
authorViacheslav Galaktionov <viacheslav.galaktionov@oktetlabs.ru>
Mon, 11 Oct 2021 14:48:29 +0000 (17:48 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 12 Oct 2021 16:44:11 +0000 (18:44 +0200)
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 <viacheslav.galaktionov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
drivers/common/sfc_efx/base/efx.h
drivers/common/sfc_efx/base/efx_mae.c
drivers/common/sfc_efx/version.map

index 9480381..c0d1535 100644 (file)
@@ -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.
  *
index b38b114..b7afe8f 100644 (file)
@@ -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,
index 3dc2187..611757c 100644 (file)
@@ -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;