common/sfc_efx/base: add API to get mport ID by selector
authorIgor Romanov <igor.romanov@oktetlabs.ru>
Mon, 11 Oct 2021 14:48:24 +0000 (17:48 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 12 Oct 2021 16:44:10 +0000 (18:44 +0200)
The mport ID is required to set appropriate egress mport ID
in Tx prefix for port representor TxQ.

Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Reviewed-by: Ivan Malov <ivan.malov@oktetlabs.ru>
drivers/common/sfc_efx/base/efx.h
drivers/common/sfc_efx/base/efx_mae.c
drivers/common/sfc_efx/version.map

index 24e1314..9480381 100644 (file)
@@ -4181,6 +4181,19 @@ typedef struct efx_mport_sel_s {
        uint32_t sel;
 } efx_mport_sel_t;
 
+/*
+ * MPORT ID. Used to refer dynamically to a specific MPORT.
+ * The difference between MPORT selector and MPORT ID is that
+ * selector can specify an exact MPORT ID or it can specify a
+ * pattern by which an exact MPORT ID can be selected. For example,
+ * static MPORT selector can specify MPORT of a current PF, which
+ * will be translated to the dynamic MPORT ID based on which PF is
+ * using that MPORT selector.
+ */
+typedef struct efx_mport_id_s {
+       uint32_t id;
+} efx_mport_id_t;
+
 #define        EFX_MPORT_NULL                  (0U)
 
 /*
@@ -4210,6 +4223,14 @@ efx_mae_mport_by_pcie_function(
        __in                            uint32_t vf,
        __out                           efx_mport_sel_t *mportp);
 
+/* Get MPORT ID by an MPORT selector */
+LIBEFX_API
+extern __checkReturn                   efx_rc_t
+efx_mae_mport_id_by_selector(
+       __in                            efx_nic_t *enp,
+       __in                            const efx_mport_sel_t *mport_selectorp,
+       __out                           efx_mport_id_t *mport_idp);
+
 /*
  * Fields which have BE postfix in their named constants are expected
  * to be passed by callers in big-endian byte order. They will appear
index c22206e..b38b114 100644 (file)
@@ -731,6 +731,70 @@ efx_mae_mport_by_pcie_function(
 
        return (0);
 
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
+static __checkReturn                   efx_rc_t
+efx_mcdi_mae_mport_lookup(
+       __in                            efx_nic_t *enp,
+       __in                            const efx_mport_sel_t *mport_selectorp,
+       __out                           efx_mport_id_t *mport_idp)
+{
+       efx_mcdi_req_t req;
+       EFX_MCDI_DECLARE_BUF(payload,
+           MC_CMD_MAE_MPORT_LOOKUP_IN_LEN,
+           MC_CMD_MAE_MPORT_LOOKUP_OUT_LEN);
+       efx_rc_t rc;
+
+       req.emr_cmd = MC_CMD_MAE_MPORT_LOOKUP;
+       req.emr_in_buf = payload;
+       req.emr_in_length = MC_CMD_MAE_MPORT_LOOKUP_IN_LEN;
+       req.emr_out_buf = payload;
+       req.emr_out_length = MC_CMD_MAE_MPORT_LOOKUP_OUT_LEN;
+
+       MCDI_IN_SET_DWORD(req, MAE_MPORT_LOOKUP_IN_MPORT_SELECTOR,
+           mport_selectorp->sel);
+
+       efx_mcdi_execute(enp, &req);
+
+       if (req.emr_rc != 0) {
+               rc = req.emr_rc;
+               goto fail1;
+       }
+
+       mport_idp->id = MCDI_OUT_DWORD(req, MAE_MPORT_LOOKUP_OUT_MPORT_ID);
+
+       return (0);
+
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
+       __checkReturn                   efx_rc_t
+efx_mae_mport_id_by_selector(
+       __in                            efx_nic_t *enp,
+       __in                            const efx_mport_sel_t *mport_selectorp,
+       __out                           efx_mport_id_t *mport_idp)
+{
+       const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+       efx_rc_t rc;
+
+       if (encp->enc_mae_supported == B_FALSE) {
+               rc = ENOTSUP;
+               goto fail1;
+       }
+
+       rc = efx_mcdi_mae_mport_lookup(enp, mport_selectorp, mport_idp);
+       if (rc != 0)
+               goto fail2;
+
+       return (0);
+
 fail2:
        EFSYS_PROBE(fail2);
 fail1:
index 0c5bcdf..3dc2187 100644 (file)
@@ -126,6 +126,7 @@ INTERNAL {
        efx_mae_match_specs_equal;
        efx_mae_mport_by_pcie_function;
        efx_mae_mport_by_phy_port;
+       efx_mae_mport_id_by_selector;
        efx_mae_outer_rule_insert;
        efx_mae_outer_rule_remove;