Skip to content

Commit 09d23b8

Browse files
pgardocxanguy11
authored andcommitted
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: 0dbfbab ("iavf: Add framework to enable ethtool ntuple filters") Signed-off-by: Piotr Gardocki <piotrx.gardocki@intel.com> Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com> Signed-off-by: Ranganatha Rao <ranganatha.rao@intel.com> Tested-by: Rafal Romanowski <rafal.romanowski@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
1 parent 3a0b5a2 commit 09d23b8

1 file changed

Lines changed: 59 additions & 0 deletions

File tree

drivers/net/ethernet/intel/iavf/iavf_main.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4341,6 +4341,49 @@ static int iavf_change_mtu(struct net_device *netdev, int new_mtu)
43414341
return ret;
43424342
}
43434343

4344+
/**
4345+
* iavf_disable_fdir - disable Flow Director and clear existing filters
4346+
* @adapter: board private structure
4347+
**/
4348+
static void iavf_disable_fdir(struct iavf_adapter *adapter)
4349+
{
4350+
struct iavf_fdir_fltr *fdir, *fdirtmp;
4351+
bool del_filters = false;
4352+
4353+
adapter->flags &= ~IAVF_FLAG_FDIR_ENABLED;
4354+
4355+
/* remove all Flow Director filters */
4356+
spin_lock_bh(&adapter->fdir_fltr_lock);
4357+
list_for_each_entry_safe(fdir, fdirtmp, &adapter->fdir_list_head,
4358+
list) {
4359+
if (fdir->state == IAVF_FDIR_FLTR_ADD_REQUEST ||
4360+
fdir->state == IAVF_FDIR_FLTR_INACTIVE) {
4361+
/* Delete filters not registered in PF */
4362+
list_del(&fdir->list);
4363+
kfree(fdir);
4364+
adapter->fdir_active_fltr--;
4365+
} else if (fdir->state == IAVF_FDIR_FLTR_ADD_PENDING ||
4366+
fdir->state == IAVF_FDIR_FLTR_DIS_REQUEST ||
4367+
fdir->state == IAVF_FDIR_FLTR_ACTIVE) {
4368+
/* Filters registered in PF, schedule their deletion */
4369+
fdir->state = IAVF_FDIR_FLTR_DEL_REQUEST;
4370+
del_filters = true;
4371+
} else if (fdir->state == IAVF_FDIR_FLTR_DIS_PENDING) {
4372+
/* Request to delete filter already sent to PF, change
4373+
* state to DEL_PENDING to delete filter after PF's
4374+
* response, not set as INACTIVE
4375+
*/
4376+
fdir->state = IAVF_FDIR_FLTR_DEL_PENDING;
4377+
}
4378+
}
4379+
spin_unlock_bh(&adapter->fdir_fltr_lock);
4380+
4381+
if (del_filters) {
4382+
adapter->aq_required |= IAVF_FLAG_AQ_DEL_FDIR_FILTER;
4383+
mod_delayed_work(adapter->wq, &adapter->watchdog_task, 0);
4384+
}
4385+
}
4386+
43444387
#define NETIF_VLAN_OFFLOAD_FEATURES (NETIF_F_HW_VLAN_CTAG_RX | \
43454388
NETIF_F_HW_VLAN_CTAG_TX | \
43464389
NETIF_F_HW_VLAN_STAG_RX | \
@@ -4366,6 +4409,13 @@ static int iavf_set_features(struct net_device *netdev,
43664409
((netdev->features & NETIF_F_RXFCS) ^ (features & NETIF_F_RXFCS)))
43674410
iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED);
43684411

4412+
if ((netdev->features & NETIF_F_NTUPLE) ^ (features & NETIF_F_NTUPLE)) {
4413+
if (features & NETIF_F_NTUPLE)
4414+
adapter->flags |= IAVF_FLAG_FDIR_ENABLED;
4415+
else
4416+
iavf_disable_fdir(adapter);
4417+
}
4418+
43694419
return 0;
43704420
}
43714421

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

47164766
features = iavf_fix_netdev_vlan_features(adapter, features);
47174767

4768+
if (!FDIR_FLTR_SUPPORT(adapter))
4769+
features &= ~NETIF_F_NTUPLE;
4770+
47184771
return iavf_fix_strip_features(adapter, features);
47194772
}
47204773

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

4888+
if (FDIR_FLTR_SUPPORT(adapter)) {
4889+
netdev->hw_features |= NETIF_F_NTUPLE;
4890+
netdev->features |= NETIF_F_NTUPLE;
4891+
adapter->flags |= IAVF_FLAG_FDIR_ENABLED;
4892+
}
4893+
48354894
netdev->priv_flags |= IFF_UNICAST_FLT;
48364895

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

0 commit comments

Comments
 (0)