common/sfc_efx/base: add mport alias MCDI wrappers
authorIgor Romanov <igor.romanov@oktetlabs.ru>
Mon, 11 Oct 2021 14:48:33 +0000 (17:48 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 12 Oct 2021 16:44:11 +0000 (18:44 +0200)
The APIs allow creation of mports for port representor
traffic filtering.

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 a59c2e4..0a17812 100644 (file)
@@ -4599,6 +4599,19 @@ efx_mae_action_rule_remove(
        __in                            efx_nic_t *enp,
        __in                            const efx_mae_rule_id_t *ar_idp);
 
+LIBEFX_API
+extern __checkReturn                   efx_rc_t
+efx_mcdi_mport_alloc_alias(
+       __in                            efx_nic_t *enp,
+       __out                           efx_mport_id_t *mportp,
+       __out_opt                       uint32_t *labelp);
+
+LIBEFX_API
+extern __checkReturn                   efx_rc_t
+efx_mae_mport_free(
+       __in                            efx_nic_t *enp,
+       __in                            const efx_mport_id_t *mportp);
+
 #endif /* EFSYS_OPT_MAE */
 
 #if EFSYS_OPT_VIRTIO
index f5d981f..3f498fe 100644 (file)
@@ -3142,4 +3142,94 @@ fail1:
        return (rc);
 }
 
+       __checkReturn                   efx_rc_t
+efx_mcdi_mport_alloc_alias(
+       __in                            efx_nic_t *enp,
+       __out                           efx_mport_id_t *mportp,
+       __out_opt                       uint32_t *labelp)
+{
+       const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+       efx_mcdi_req_t req;
+       EFX_MCDI_DECLARE_BUF(payload,
+           MC_CMD_MAE_MPORT_ALLOC_ALIAS_IN_LEN,
+           MC_CMD_MAE_MPORT_ALLOC_ALIAS_OUT_LEN);
+       efx_rc_t rc;
+
+       if (encp->enc_mae_supported == B_FALSE) {
+               rc = ENOTSUP;
+               goto fail1;
+       }
+
+       req.emr_cmd = MC_CMD_MAE_MPORT_ALLOC;
+       req.emr_in_buf = payload;
+       req.emr_in_length = MC_CMD_MAE_MPORT_ALLOC_ALIAS_IN_LEN;
+       req.emr_out_buf = payload;
+       req.emr_out_length = MC_CMD_MAE_MPORT_ALLOC_ALIAS_OUT_LEN;
+
+       MCDI_IN_SET_DWORD(req, MAE_MPORT_ALLOC_IN_TYPE,
+                         MC_CMD_MAE_MPORT_ALLOC_IN_MPORT_TYPE_ALIAS);
+       MCDI_IN_SET_DWORD(req, MAE_MPORT_ALLOC_ALIAS_IN_DELIVER_MPORT,
+                         MAE_MPORT_SELECTOR_ASSIGNED);
+
+       efx_mcdi_execute(enp, &req);
+
+       if (req.emr_rc != 0) {
+               rc = req.emr_rc;
+               goto fail2;
+       }
+
+       mportp->id = MCDI_OUT_DWORD(req, MAE_MPORT_ALLOC_OUT_MPORT_ID);
+       if (labelp != NULL)
+               *labelp = MCDI_OUT_DWORD(req, MAE_MPORT_ALLOC_ALIAS_OUT_LABEL);
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
+       __checkReturn                   efx_rc_t
+efx_mae_mport_free(
+       __in                            efx_nic_t *enp,
+       __in                            const efx_mport_id_t *mportp)
+{
+       const efx_nic_cfg_t *encp = efx_nic_cfg_get(enp);
+       efx_mcdi_req_t req;
+       EFX_MCDI_DECLARE_BUF(payload,
+           MC_CMD_MAE_MPORT_FREE_IN_LEN,
+           MC_CMD_MAE_MPORT_FREE_OUT_LEN);
+       efx_rc_t rc;
+
+       if (encp->enc_mae_supported == B_FALSE) {
+               rc = ENOTSUP;
+               goto fail1;
+       }
+
+       req.emr_cmd = MC_CMD_MAE_MPORT_FREE;
+       req.emr_in_buf = payload;
+       req.emr_in_length = MC_CMD_MAE_MPORT_FREE_IN_LEN;
+       req.emr_out_buf = payload;
+       req.emr_out_length = MC_CMD_MAE_MPORT_FREE_OUT_LEN;
+
+       MCDI_IN_SET_DWORD(req, MAE_MPORT_FREE_IN_MPORT_ID, mportp->id);
+
+       efx_mcdi_execute(enp, &req);
+
+       if (req.emr_rc != 0) {
+               rc = req.emr_rc;
+               goto fail2;
+       }
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
 #endif /* EFSYS_OPT_MAE */
index 8c5d813..3488367 100644 (file)
@@ -127,6 +127,7 @@ INTERNAL {
        efx_mae_mport_by_pcie_function;
        efx_mae_mport_by_phy_port;
        efx_mae_mport_by_id;
+       efx_mae_mport_free;
        efx_mae_mport_id_by_selector;
        efx_mae_mport_invalid;
        efx_mae_outer_rule_insert;
@@ -136,6 +137,7 @@ INTERNAL {
        efx_mcdi_get_proxy_handle;
        efx_mcdi_get_timeout;
        efx_mcdi_init;
+       efx_mcdi_mport_alloc_alias;
        efx_mcdi_new_epoch;
        efx_mcdi_reboot;
        efx_mcdi_request_abort;