Skip to content

Commit

Permalink
iavf: Handle ntuple on/off based on new state machines for flow director
Browse files Browse the repository at this point in the history
ntuple-filter feature on/off:
Default is on. If turned off, the filters will be removed from both
PF and iavf list. The removal is irrespective of current filter state.

Steps to reproduce:
-------------------

1. Ensure ntuple is on.

ethtool -K enp8s0 ntuple-filters on

2. Create a filter to receive the traffic into non-default rx-queue like 15
and ensure traffic is flowing into queue into 15.
Now, turn off ntuple. Traffic should not flow to configured queue 15.
It should flow to default RX queue.

Fixes: 0dbfbab ("iavf: Add framework to enable ethtool ntuple filters")
Signed-off-by: Piotr Gardocki <[email protected]>
Reviewed-by: Larysa Zaremba <[email protected]>
Signed-off-by: Ranganatha Rao <[email protected]>
Tested-by: Rafal Romanowski <[email protected]>
Signed-off-by: Tony Nguyen <[email protected]>
  • Loading branch information
pgardocx authored and anguy11 committed Dec 12, 2023
1 parent 3a0b5a2 commit 09d23b8
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions drivers/net/ethernet/intel/iavf/iavf_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -4341,6 +4341,49 @@ static int iavf_change_mtu(struct net_device *netdev, int new_mtu)
return ret;
}

/**
* iavf_disable_fdir - disable Flow Director and clear existing filters
* @adapter: board private structure
**/
static void iavf_disable_fdir(struct iavf_adapter *adapter)
{
struct iavf_fdir_fltr *fdir, *fdirtmp;
bool del_filters = false;

adapter->flags &= ~IAVF_FLAG_FDIR_ENABLED;

/* remove all Flow Director filters */
spin_lock_bh(&adapter->fdir_fltr_lock);
list_for_each_entry_safe(fdir, fdirtmp, &adapter->fdir_list_head,
list) {
if (fdir->state == IAVF_FDIR_FLTR_ADD_REQUEST ||
fdir->state == IAVF_FDIR_FLTR_INACTIVE) {
/* Delete filters not registered in PF */
list_del(&fdir->list);
kfree(fdir);
adapter->fdir_active_fltr--;
} else if (fdir->state == IAVF_FDIR_FLTR_ADD_PENDING ||
fdir->state == IAVF_FDIR_FLTR_DIS_REQUEST ||
fdir->state == IAVF_FDIR_FLTR_ACTIVE) {
/* Filters registered in PF, schedule their deletion */
fdir->state = IAVF_FDIR_FLTR_DEL_REQUEST;
del_filters = true;
} else if (fdir->state == IAVF_FDIR_FLTR_DIS_PENDING) {
/* Request to delete filter already sent to PF, change
* state to DEL_PENDING to delete filter after PF's
* response, not set as INACTIVE
*/
fdir->state = IAVF_FDIR_FLTR_DEL_PENDING;
}
}
spin_unlock_bh(&adapter->fdir_fltr_lock);

if (del_filters) {
adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER;
mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0);
}
}

#define NETIF_VLAN_OFFLOAD_FEATURES (NETIF_F_HW_VLAN_CTAG_RX | \
NETIF_F_HW_VLAN_CTAG_TX | \
NETIF_F_HW_VLAN_STAG_RX | \
Expand All @@ -4366,6 +4409,13 @@ static int iavf_set_features(struct net_device *netdev,
((netdev->features & NETIF_F_RXFCS) ^ (features & NETIF_F_RXFCS)))
iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED);

if ((netdev->features & NETIF_F_NTUPLE) ^ (features & NETIF_F_NTUPLE)) {
if (features & NETIF_F_NTUPLE)
adapter->flags |= IAVF_FLAG_FDIR_ENABLED;
else
iavf_disable_fdir(adapter);
}

return 0;
}

Expand Down Expand Up @@ -4715,6 +4765,9 @@ static netdev_features_t iavf_fix_features(struct net_device *netdev,

features = iavf_fix_netdev_vlan_features(adapter, features);

if (!FDIR_FLTR_SUPPORT(adapter))
features &= ~NETIF_F_NTUPLE;

return iavf_fix_strip_features(adapter, features);
}

Expand Down Expand Up @@ -4832,6 +4885,12 @@ int iavf_process_config(struct iavf_adapter *adapter)
if (vfres->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_VLAN)
netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;

if (FDIR_FLTR_SUPPORT(adapter)) {
netdev->hw_features |= NETIF_F_NTUPLE;
netdev->features |= NETIF_F_NTUPLE;
adapter->flags |= IAVF_FLAG_FDIR_ENABLED;
}

netdev->priv_flags |= IFF_UNICAST_FLT;

/* Do not turn on offloads when they are requested to be turned off.
Expand Down

0 comments on commit 09d23b8

Please sign in to comment.