Skip to content

Commit

Permalink
net/sfc: invalidate dangling MAE flow action FW resource IDs
Browse files Browse the repository at this point in the history
[ upstream commit cf1e1a8e869b49ac9e2e097bbd272e94cc4f2c74 ]

When reinserting a flow (on port restart, for instance)
FW resource IDs found in the action set specification
need to be invalidated so that the new (reallocated)
FW resource IDs can be accepted by libefx again.

Fixes: 1bbd1ec ("net/sfc: support action VXLAN encap in MAE backend")

Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Andy Moreton <amoreton@xilinx.com>
Tested-by: Denis Pryazhennikov <denis.pryazhennikov@arknetworks.am>
Acked-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
  • Loading branch information
okt-imalov authored and kevintraynor committed Jul 11, 2023
1 parent b3741df commit fbfa671
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ Deepak Khandelwal <deepak.khandelwal@intel.com>
Deepak Kumar Jain <deepak.k.jain@intel.com>
Deirdre O'Connor <deirdre.o.connor@intel.com>
Dekel Peled <dekelp@nvidia.com> <dekelp@mellanox.com>
Denis Pryazhennikov <denis.pryazhennikov@arknetworks.am>
Dennis Marinus <dmarinus@amazon.com>
Derek Chickles <derek.chickles@caviumnetworks.com>
Des O Dea <des.j.o.dea@intel.com>
Expand Down
14 changes: 14 additions & 0 deletions drivers/common/sfc_efx/base/efx.h
Original file line number Diff line number Diff line change
Expand Up @@ -4701,6 +4701,20 @@ efx_mae_action_set_fill_in_counter_id(
__in efx_mae_actions_t *spec,
__in const efx_counter_t *counter_idp);

/*
* Clears dangling FW object IDs (counter ID, for instance) in
* the action set specification. Useful for adapter restarts,
* when all MAE objects need to be reallocated by the driver.
*
* This method only clears the IDs in the specification.
* The driver is still responsible for keeping the IDs
* separately and freeing them when stopping the port.
*/
LIBEFX_API
extern void
efx_mae_action_set_clear_fw_rsrc_ids(
__in efx_mae_actions_t *spec);

/* Action set ID */
typedef struct efx_mae_aset_id_s {
uint32_t id;
Expand Down
4 changes: 4 additions & 0 deletions drivers/common/sfc_efx/base/efx_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,10 @@ typedef struct efx_mae_action_vlan_push_s {
uint16_t emavp_tci_be;
} efx_mae_action_vlan_push_t;

/*
* Helper efx_mae_action_set_clear_fw_rsrc_ids() is responsible
* to initialise every field in this structure to INVALID value.
*/
typedef struct efx_mae_actions_rsrc_s {
efx_mae_mac_id_t emar_dst_mac_id;
efx_mae_mac_id_t emar_src_mac_id;
Expand Down
15 changes: 11 additions & 4 deletions drivers/common/sfc_efx/base/efx_mae.c
Original file line number Diff line number Diff line change
Expand Up @@ -1394,10 +1394,7 @@ efx_mae_action_set_spec_init(
goto fail1;
}

spec->ema_rsrc.emar_dst_mac_id.id = EFX_MAE_RSRC_ID_INVALID;
spec->ema_rsrc.emar_src_mac_id.id = EFX_MAE_RSRC_ID_INVALID;
spec->ema_rsrc.emar_eh_id.id = EFX_MAE_RSRC_ID_INVALID;
spec->ema_rsrc.emar_counter_id.id = EFX_MAE_RSRC_ID_INVALID;
efx_mae_action_set_clear_fw_rsrc_ids(spec);

/*
* Helpers which populate v2 actions must reject them when v2 is not
Expand Down Expand Up @@ -3027,6 +3024,16 @@ efx_mae_action_set_fill_in_counter_id(
return (rc);
}

void
efx_mae_action_set_clear_fw_rsrc_ids(
__in efx_mae_actions_t *spec)
{
spec->ema_rsrc.emar_dst_mac_id.id = EFX_MAE_RSRC_ID_INVALID;
spec->ema_rsrc.emar_src_mac_id.id = EFX_MAE_RSRC_ID_INVALID;
spec->ema_rsrc.emar_eh_id.id = EFX_MAE_RSRC_ID_INVALID;
spec->ema_rsrc.emar_counter_id.id = EFX_MAE_RSRC_ID_INVALID;
}

__checkReturn efx_rc_t
efx_mae_counters_alloc(
__in efx_nic_t *enp,
Expand Down
1 change: 1 addition & 0 deletions drivers/common/sfc_efx/version.map
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ INTERNAL {
efx_mae_action_rule_insert;
efx_mae_action_rule_remove;
efx_mae_action_set_alloc;
efx_mae_action_set_clear_fw_rsrc_ids;
efx_mae_action_set_fill_in_counter_id;
efx_mae_action_set_fill_in_dst_mac_id;
efx_mae_action_set_fill_in_eh_id;
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/sfc/sfc_mae.c
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,8 @@ sfc_mae_action_set_disable(struct sfc_adapter *sa,
}

if (fw_rsrc->refcnt == 1) {
efx_mae_action_set_clear_fw_rsrc_ids(action_set->spec);

rc = efx_mae_action_set_free(sa->nic, &fw_rsrc->aset_id);
if (rc == 0) {
sfc_dbg(sa, "disabled action_set=%p with AS_ID=0x%08x",
Expand Down

0 comments on commit fbfa671

Please sign in to comment.