common/sfc_efx/base: add match spec init/fini APIs
authorIvan Malov <ivan.malov@oktetlabs.ru>
Tue, 20 Oct 2020 09:12:48 +0000 (10:12 +0100)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 3 Nov 2020 22:24:24 +0000 (23:24 +0100)
An MAE rule is a function of match criteria and a priority. The said match
criteria have to be provided using "mask-value pairs" packing format which
on its own should not be exposed to client drivers. The latter have to use
a functional interface of sorts in order to generate a match specification.

Define an EFX match specification and implement initialise / finalise APIs.
The "mask-value pairs" buffer itself is not used in this particular patch,
so the corresponding struct member will be added in the follow-up patch.

Signed-off-by: Ivan Malov <ivan.malov@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
drivers/common/sfc_efx/base/efx.h
drivers/common/sfc_efx/base/efx_impl.h
drivers/common/sfc_efx/base/efx_mae.c
drivers/common/sfc_efx/version.map

index db66be0..40c5968 100644 (file)
@@ -4058,6 +4058,28 @@ efx_mae_get_limits(
        __in                            efx_nic_t *enp,
        __out                           efx_mae_limits_t *emlp);
 
+typedef enum efx_mae_rule_type_e {
+       EFX_MAE_RULE_ACTION = 0,
+
+       EFX_MAE_RULE_NTYPES
+} efx_mae_rule_type_t;
+
+typedef struct efx_mae_match_spec_s    efx_mae_match_spec_t;
+
+LIBEFX_API
+extern __checkReturn                   efx_rc_t
+efx_mae_match_spec_init(
+       __in                            efx_nic_t *enp,
+       __in                            efx_mae_rule_type_t type,
+       __in                            uint32_t prio,
+       __out                           efx_mae_match_spec_t **specp);
+
+LIBEFX_API
+extern                                 void
+efx_mae_match_spec_fini(
+       __in                            efx_nic_t *enp,
+       __in                            efx_mae_match_spec_t *spec);
+
 #endif /* EFSYS_OPT_MAE */
 
 #ifdef __cplusplus
index 6e9329c..931989f 100644 (file)
@@ -1675,6 +1675,15 @@ efx_pci_xilinx_cap_tbl_find(
 
 #endif /* EFSYS_OPT_PCI */
 
+#if EFSYS_OPT_MAE
+
+struct efx_mae_match_spec_s {
+       efx_mae_rule_type_t             emms_type;
+       uint32_t                        emms_prio;
+};
+
+#endif /* EFSYS_OPT_MAE */
+
 #ifdef __cplusplus
 }
 #endif
index c93342d..b1ebc93 100644 (file)
@@ -126,4 +126,50 @@ fail1:
        return (rc);
 }
 
+       __checkReturn                   efx_rc_t
+efx_mae_match_spec_init(
+       __in                            efx_nic_t *enp,
+       __in                            efx_mae_rule_type_t type,
+       __in                            uint32_t prio,
+       __out                           efx_mae_match_spec_t **specp)
+{
+       efx_mae_match_spec_t *spec;
+       efx_rc_t rc;
+
+       switch (type) {
+       case EFX_MAE_RULE_ACTION:
+               break;
+       default:
+               rc = ENOTSUP;
+               goto fail1;
+       }
+
+       EFSYS_KMEM_ALLOC(enp->en_esip, sizeof (*spec), spec);
+       if (spec == NULL) {
+               rc = ENOMEM;
+               goto fail2;
+       }
+
+       spec->emms_type = type;
+       spec->emms_prio = prio;
+
+       *specp = spec;
+
+       return (0);
+
+fail2:
+       EFSYS_PROBE(fail2);
+fail1:
+       EFSYS_PROBE1(fail1, efx_rc_t, rc);
+       return (rc);
+}
+
+                                       void
+efx_mae_match_spec_fini(
+       __in                            efx_nic_t *enp,
+       __in                            efx_mae_match_spec_t *spec)
+{
+       EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), spec);
+}
+
 #endif /* EFSYS_OPT_MAE */
index 4b500b6..57a6c96 100644 (file)
@@ -88,6 +88,8 @@ INTERNAL {
        efx_mae_fini;
        efx_mae_get_limits;
        efx_mae_init;
+       efx_mae_match_spec_fini;
+       efx_mae_match_spec_init;
 
        efx_mcdi_fini;
        efx_mcdi_get_proxy_handle;