From d957c6010a907d86d41d1bee024a9827e385c4fa Mon Sep 17 00:00:00 2001 From: Andre Guedes <andre.guedes@intel.com> Date: Fri, 24 Apr 2020 13:16:17 -0700 Subject: igc: Fix NFC rules restoration When network interface is brought up, the driver re-enables the NFC rules previously configured. However, this is done in reverse order the rules were added and hardware filters are configured differently. For example, consider the following rules: $ ethtool -N eth0 flow-type ether dst 00:00:00:00:00:AA queue 0 $ ethtool -N eth0 flow-type ether dst 00:00:00:00:00:BB queue 1 $ ethtool -N eth0 flow-type ether dst 00:00:00:00:00:CC queue 2 $ ethtool -N eth0 flow-type ether dst 00:00:00:00:00:DD queue 3 RAL/RAH registers are configure so filter index 1 has address ending with AA, filter index 2 has address ending in BB, and so on. If we bring the interface down and up again, RAL/RAH registers are configured so filter index 1 has address ending in DD, filter index 2 has CC, and so on. IOW, in reverse order we had before bringing the interface down. This issue can be fixed by traversing adapter->nfc_rule_list in backwards when restoring the rules. Since hlist doesn't support backwards traversal, this patch replaces it by list_head and fixes igc_restore_nfc_rules() accordingly. Signed-off-by: Andre Guedes <andre.guedes@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> --- drivers/net/ethernet/intel/igc/igc_main.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'drivers/net/ethernet/intel/igc/igc_main.c') diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c index acb8dfdf275f..cf76e2c1f9b1 100644 --- a/drivers/net/ethernet/intel/igc/igc_main.c +++ b/drivers/net/ethernet/intel/igc/igc_main.c @@ -2180,7 +2180,7 @@ static void igc_restore_nfc_rules(struct igc_adapter *adapter) spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) + list_for_each_entry_reverse(rule, &adapter->nfc_rule_list, list) igc_enable_nfc_rule(adapter, rule); spin_unlock(&adapter->nfc_rule_lock); @@ -3419,6 +3419,9 @@ static int igc_sw_init(struct igc_adapter *adapter) adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; spin_lock_init(&adapter->nfc_rule_lock); + INIT_LIST_HEAD(&adapter->nfc_rule_list); + adapter->nfc_rule_count = 0; + spin_lock_init(&adapter->stats64_lock); /* Assume MSI-X interrupts, will be checked during IRQ allocation */ adapter->flags |= IGC_FLAG_HAS_MSIX; @@ -3651,7 +3654,7 @@ static void igc_nfc_rule_exit(struct igc_adapter *adapter) spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry(rule, &adapter->nfc_rule_list, nfc_node) + list_for_each_entry(rule, &adapter->nfc_rule_list, list) igc_disable_nfc_rule(adapter, rule); spin_unlock(&adapter->nfc_rule_lock); @@ -3826,14 +3829,13 @@ static int igc_set_features(struct net_device *netdev, return 0; if (!(features & NETIF_F_NTUPLE)) { - struct hlist_node *node2; - struct igc_nfc_rule *rule; + struct igc_nfc_rule *rule, *tmp; spin_lock(&adapter->nfc_rule_lock); - hlist_for_each_entry_safe(rule, node2, - &adapter->nfc_rule_list, nfc_node) { + list_for_each_entry_safe(rule, tmp, + &adapter->nfc_rule_list, list) { igc_disable_nfc_rule(adapter, rule); - hlist_del(&rule->nfc_node); + list_del(&rule->list); kfree(rule); } spin_unlock(&adapter->nfc_rule_lock); -- cgit v1.2.3-70-g09d2