From 616b03e09e04b9ff8ed30c830bfb017b38043a62 Mon Sep 17 00:00:00 2001 From: Ivan Malov Date: Tue, 20 Oct 2020 10:13:05 +0100 Subject: [PATCH] common/sfc_efx/base: support adding VLAN pop action to set MAE supports stripping two tags, so this action can be requested once or twice. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 5 +++ drivers/common/sfc_efx/base/efx_impl.h | 7 ++++ drivers/common/sfc_efx/base/efx_mae.c | 54 +++++++++++++++++++++++++- drivers/common/sfc_efx/version.map | 1 + 4 files changed, 66 insertions(+), 1 deletion(-) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index d37850eda6..17bfc6fdfd 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4166,6 +4166,11 @@ efx_mae_action_set_spec_fini( __in efx_nic_t *enp, __in efx_mae_actions_t *spec); +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_action_set_populate_vlan_pop( + __in efx_mae_actions_t *spec); + LIBEFX_API extern __checkReturn efx_rc_t efx_mae_action_set_populate_deliver( diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index 50f2b742c7..63ede90a86 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -1700,16 +1700,23 @@ struct efx_mae_match_spec_s { }; typedef enum efx_mae_action_e { + /* These actions are strictly ordered. */ + EFX_MAE_ACTION_VLAN_POP, + /* DELIVER is always the last action. */ EFX_MAE_ACTION_DELIVER, EFX_MAE_NACTIONS } efx_mae_action_t; +/* MAE VLAN_POP action can handle 1 or 2 tags. */ +#define EFX_MAE_VLAN_POP_MAX_NTAGS (2) + struct efx_mae_actions_s { /* Bitmap of actions in spec, indexed by action type */ uint32_t ema_actions; + unsigned int ema_n_vlan_tags_to_pop; efx_mport_sel_t ema_deliver_mport; }; diff --git a/drivers/common/sfc_efx/base/efx_mae.c b/drivers/common/sfc_efx/base/efx_mae.c index f85ddcf69a..644ad312f7 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -641,6 +641,42 @@ efx_mae_action_set_spec_fini( EFSYS_KMEM_FREE(enp->en_esip, sizeof (*spec), spec); } +static __checkReturn efx_rc_t +efx_mae_action_set_add_vlan_pop( + __in efx_mae_actions_t *spec, + __in size_t arg_size, + __in_bcount(arg_size) const uint8_t *arg) +{ + efx_rc_t rc; + + if (arg_size != 0) { + rc = EINVAL; + goto fail1; + } + + if (arg != NULL) { + rc = EINVAL; + goto fail2; + } + + if (spec->ema_n_vlan_tags_to_pop == EFX_MAE_VLAN_POP_MAX_NTAGS) { + rc = ENOTSUP; + goto fail3; + } + + ++spec->ema_n_vlan_tags_to_pop; + + return (0); + +fail3: + EFSYS_PROBE(fail3); +fail2: + EFSYS_PROBE(fail2); +fail1: + EFSYS_PROBE1(fail1, efx_rc_t, rc); + return (rc); +} + static __checkReturn efx_rc_t efx_mae_action_set_add_deliver( __in efx_mae_actions_t *spec, @@ -677,15 +713,20 @@ typedef struct efx_mae_action_desc_s { } efx_mae_action_desc_t; static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { + [EFX_MAE_ACTION_VLAN_POP] = { + .emad_add = efx_mae_action_set_add_vlan_pop + }, [EFX_MAE_ACTION_DELIVER] = { .emad_add = efx_mae_action_set_add_deliver } }; static const uint32_t efx_mae_action_ordered_map = + (1U << EFX_MAE_ACTION_VLAN_POP) | (1U << EFX_MAE_ACTION_DELIVER); -static const uint32_t efx_mae_action_repeat_map = 0; +static const uint32_t efx_mae_action_repeat_map = + (1U << EFX_MAE_ACTION_VLAN_POP); /* * Add an action to an action set. @@ -759,6 +800,14 @@ fail1: return (rc); } + __checkReturn efx_rc_t +efx_mae_action_set_populate_vlan_pop( + __in efx_mae_actions_t *spec) +{ + return (efx_mae_action_set_spec_populate(spec, + EFX_MAE_ACTION_VLAN_POP, 0, NULL)); +} + __checkReturn efx_rc_t efx_mae_action_set_populate_deliver( __in efx_mae_actions_t *spec, @@ -923,6 +972,9 @@ efx_mae_action_set_alloc( MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_ENCAP_HEADER_ID, EFX_MAE_RSRC_ID_INVALID); + MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS, + MAE_ACTION_SET_ALLOC_IN_VLAN_POP, spec->ema_n_vlan_tags_to_pop); + MCDI_IN_SET_DWORD(req, MAE_ACTION_SET_ALLOC_IN_DELIVER, spec->ema_deliver_mport.sel); diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 0e0d058c8f..41c14c6451 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -90,6 +90,7 @@ INTERNAL { efx_mae_action_set_alloc; efx_mae_action_set_free; efx_mae_action_set_populate_deliver; + efx_mae_action_set_populate_vlan_pop; efx_mae_action_set_spec_fini; efx_mae_action_set_spec_init; efx_mae_action_set_specs_equal; -- 2.20.1