From b75eb50d0469d20ee4723bae5820f5223a769df7 Mon Sep 17 00:00:00 2001 From: Ivan Malov Date: Tue, 20 Oct 2020 10:12:48 +0100 Subject: [PATCH] common/sfc_efx/base: add match spec init/fini APIs 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 Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 22 ++++++++++++ drivers/common/sfc_efx/base/efx_impl.h | 9 +++++ drivers/common/sfc_efx/base/efx_mae.c | 46 ++++++++++++++++++++++++++ drivers/common/sfc_efx/version.map | 2 ++ 4 files changed, 79 insertions(+) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index db66be0faf..40c5968ea9 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -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 diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 6e9329c203..931989f17a 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -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 diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index c93342de15..b1ebc93714 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -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 */ diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 4b500b646a..57a6c96b3e 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -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; -- 2.20.1