Commit 09d23b89 authored by Piotr Gardocki's avatar Piotr Gardocki Committed by Tony Nguyen

iavf: Handle ntuple on/off based on new state machines for flow director

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: 0dbfbabb ("iavf: Add framework to enable ethtool ntuple filters")
Signed-off-by: default avatarPiotr Gardocki <piotrx.gardocki@intel.com>
Reviewed-by: default avatarLarysa Zaremba <larysa.zaremba@intel.com>
Signed-off-by: default avatarRanganatha Rao <ranganatha.rao@intel.com>
Tested-by: default avatarRafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: default avatarTony Nguyen <anthony.l.nguyen@intel.com>
parent 3a0b5a29
......@@ -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 | \
......@@ -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;
}
......@@ -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);
}
......@@ -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.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment