From 83352289e1bd7949724e09c1327ba2d7db46d124 Mon Sep 17 00:00:00 2001 From: Ivan Malov Date: Tue, 20 Oct 2020 10:13:12 +0100 Subject: [PATCH] common/sfc_efx/base: support adding mark action to set This action can be added at any point before DELIVER. Signed-off-by: Ivan Malov Signed-off-by: Andrew Rybchenko Reviewed-by: Andy Moreton --- drivers/common/sfc_efx/base/efx.h | 6 +++ drivers/common/sfc_efx/base/efx_impl.h | 2 + drivers/common/sfc_efx/base/efx_mae.c | 58 +++++++++++++++++++++++++- drivers/common/sfc_efx/version.map | 1 + 4 files changed, 65 insertions(+), 2 deletions(-) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index e03da22c3b..1d2987653b 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -4183,6 +4183,12 @@ extern __checkReturn efx_rc_t efx_mae_action_set_populate_flag( __in efx_mae_actions_t *spec); +LIBEFX_API +extern __checkReturn efx_rc_t +efx_mae_action_set_populate_mark( + __in efx_mae_actions_t *spec, + __in uint32_t mark_value); + 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 24e53a2391..5f662b6fe3 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -1711,6 +1711,7 @@ typedef enum efx_mae_action_e { * in the end of the enumeration (before DELIVER). */ EFX_MAE_ACTION_FLAG, + EFX_MAE_ACTION_MARK, /* DELIVER is always the last action. */ EFX_MAE_ACTION_DELIVER, @@ -1737,6 +1738,7 @@ struct efx_mae_actions_s { unsigned int ema_n_vlan_tags_to_push; efx_mae_action_vlan_push_t ema_vlan_push_descs[ EFX_MAE_VLAN_PUSH_MAX_NTAGS]; + uint32_t ema_mark_value; 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 38a7c1a6a9..1f8f71377a 100644 --- a/drivers/common/sfc_efx/base/efx_mae.c +++ b/drivers/common/sfc_efx/base/efx_mae.c @@ -746,6 +746,35 @@ fail1: return (rc); } +static __checkReturn efx_rc_t +efx_mae_action_set_add_mark( + __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 != sizeof (spec->ema_mark_value)) { + rc = EINVAL; + goto fail1; + } + + if (arg == NULL) { + rc = EINVAL; + goto fail2; + } + + memcpy(&spec->ema_mark_value, arg, arg_size); + + return (0); + +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, @@ -791,6 +820,9 @@ static const efx_mae_action_desc_t efx_mae_actions[EFX_MAE_NACTIONS] = { [EFX_MAE_ACTION_FLAG] = { .emad_add = efx_mae_action_set_add_flag }, + [EFX_MAE_ACTION_MARK] = { + .emad_add = efx_mae_action_set_add_mark + }, [EFX_MAE_ACTION_DELIVER] = { .emad_add = efx_mae_action_set_add_deliver } @@ -800,6 +832,7 @@ static const uint32_t efx_mae_action_ordered_map = (1U << EFX_MAE_ACTION_VLAN_POP) | (1U << EFX_MAE_ACTION_VLAN_PUSH) | (1U << EFX_MAE_ACTION_FLAG) | + (1U << EFX_MAE_ACTION_MARK) | (1U << EFX_MAE_ACTION_DELIVER); /* @@ -808,7 +841,8 @@ static const uint32_t efx_mae_action_ordered_map = * strictly ordered actions. */ static const uint32_t efx_mae_action_nonstrict_map = - (1U << EFX_MAE_ACTION_FLAG); + (1U << EFX_MAE_ACTION_FLAG) | + (1U << EFX_MAE_ACTION_MARK); static const uint32_t efx_mae_action_repeat_map = (1U << EFX_MAE_ACTION_VLAN_POP) | @@ -836,7 +870,8 @@ efx_mae_action_set_spec_populate( (sizeof (efx_mae_action_repeat_map) * 8)); EFX_STATIC_ASSERT(EFX_MAE_ACTION_DELIVER + 1 == EFX_MAE_NACTIONS); - EFX_STATIC_ASSERT(EFX_MAE_ACTION_FLAG + 1 == EFX_MAE_ACTION_DELIVER); + EFX_STATIC_ASSERT(EFX_MAE_ACTION_FLAG + 1 == EFX_MAE_ACTION_MARK); + EFX_STATIC_ASSERT(EFX_MAE_ACTION_MARK + 1 == EFX_MAE_ACTION_DELIVER); if (type >= EFX_ARRAY_SIZE(efx_mae_actions)) { rc = EINVAL; @@ -920,6 +955,17 @@ efx_mae_action_set_populate_flag( EFX_MAE_ACTION_FLAG, 0, NULL)); } + __checkReturn efx_rc_t +efx_mae_action_set_populate_mark( + __in efx_mae_actions_t *spec, + __in uint32_t mark_value) +{ + const uint8_t *arg = (const uint8_t *)&mark_value; + + return (efx_mae_action_set_spec_populate(spec, + EFX_MAE_ACTION_MARK, sizeof (mark_value), arg)); +} + __checkReturn efx_rc_t efx_mae_action_set_populate_deliver( __in efx_mae_actions_t *spec, @@ -1117,6 +1163,14 @@ efx_mae_action_set_alloc( MAE_ACTION_SET_ALLOC_IN_FLAG, 1); } + if ((spec->ema_actions & (1U << EFX_MAE_ACTION_MARK)) != 0) { + MCDI_IN_SET_DWORD_FIELD(req, MAE_ACTION_SET_ALLOC_IN_FLAGS, + MAE_ACTION_SET_ALLOC_IN_MARK, 1); + + MCDI_IN_SET_DWORD(req, + MAE_ACTION_SET_ALLOC_IN_MARK_VALUE, spec->ema_mark_value); + } + 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 f57f4a3a8f..6ed412ee39 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -91,6 +91,7 @@ INTERNAL { efx_mae_action_set_free; efx_mae_action_set_populate_deliver; efx_mae_action_set_populate_flag; + efx_mae_action_set_populate_mark; efx_mae_action_set_populate_vlan_pop; efx_mae_action_set_populate_vlan_push; efx_mae_action_set_spec_fini; -- 2.20.1