1. 23 May, 2020 7 commits
    • Andre Guedes's avatar
      igc: Refactor igc_ethtool_update_nfc_rule() · 36fa2152
      Andre Guedes authored
      Current implementation of igc_ethtool_update_nfc_rule() is a bit
      convoluted since it handles too many things: rule lookup, deletion
      and addition. This patch breaks it into three functions so we simplify
      the code and improve code reuse.
      
      Code related to rule lookup is refactored out to a new function called
      igc_get_nfc_rule().
      
      Code related to rule addition is refactored out to a new function called
      igc_add_nfc_rule(). This function enables the rule in hardware and adds
      it to the adapter's list.
      
      Code related to rule deletion is refactored out to a new function called
      igc_del_nfc_rule(). This function disables the rule in hardware, removes
      it from adapter's list, and deletes it.
      
      As a byproduct of this refactoring, igc_enable_nfc_rule() and
      igc_disable_nfc_rule() are moved to igc_main.c since they are not used
      in igc_ethtool.c anymore, and igc_restore_nfc_rules() and igc_nfc_rule_
      exit() are moved around to avoid forward declaration.
      
      Also, since this patch already touches igc_ethtool_get_nfc_rule(), it
      takes the opportunity to remove the 'match_flags' check. Empty flags
      are not allowed to be added so no need to check that.
      Signed-off-by: default avatarAndre Guedes <andre.guedes@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      36fa2152
    • Andre Guedes's avatar
      igc: Fix NFC rules restoration · d957c601
      Andre Guedes authored
      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: default avatarAndre Guedes <andre.guedes@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      d957c601
    • Andre Guedes's avatar
      igc: Fix NFC rules with multicast addresses · 39707c16
      Andre Guedes authored
      Multicast MAC addresses are valid address for NFC rules but
      igc_add_mac_filter() is currently rejecting them. In fact, the I225
      controller doesn't impose any constraint on the address value so this
      patch gets rid of the address validation check in MAC filter APIs.
      Signed-off-by: default avatarAndre Guedes <andre.guedes@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      39707c16
    • Andre Guedes's avatar
      igc: Fix NFC rule overwrite cases · 4bdf89e8
      Andre Guedes authored
      When the 'loc' argument is passed in ethtool, the input rule overwrites
      any rule present in that location. In this situation we must disable the
      old rule otherwise it is left enabled in hardware. This patch fixes
      the issue by always calling igc_disable_nfc_rule() when deleting the
      old rule, no matter the value of 'input' argument.
      Signed-off-by: default avatarAndre Guedes <andre.guedes@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      4bdf89e8
    • Andre Guedes's avatar
      igc: Fix locking issue when retrieving NFC rules · b500350a
      Andre Guedes authored
      Access to NFC rules stored in adapter->nfc_rule_list is protect by
      adapter->nfc_rule_lock. The functions igc_ethtool_get_nfc_rule()
      and igc_ethtool_get_nfc_rules() are missing to hold the lock while
      accessing rule objects.
      Signed-off-by: default avatarAndre Guedes <andre.guedes@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      b500350a
    • Andre Guedes's avatar
      igc: Fix 'sw_idx' type in struct igc_nfc_rule · d3ba9e6f
      Andre Guedes authored
      The 'sw_idx' field from 'struct igc_nfc_rule' is u16 type but it is
      assigned an u32 value in igc_ethtool_init_nfc_rule(). This patch changes
      'sw_idx' type to u32 so they match. Also, it makes more sense to call
      this field 'location' since it holds the NFC rule location.
      Signed-off-by: default avatarAndre Guedes <andre.guedes@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      d3ba9e6f
    • Andre Guedes's avatar
      igc: Refactor igc_ethtool_add_nfc_rule() · 16fdc16c
      Andre Guedes authored
      Current implementation of igc_ethtool_add_nfc_rule() is quite long and a
      bit convoluted so this patch does a code refactoring to improve the
      code.
      
      Code related to NFC rule object initialization is refactored out to the
      local helper function igc_ethtool_init_nfc_rule(). Likewise, code
      related to NFC rule validation is refactored out to another local
      helper, igc_ethtool_is_nfc_rule_valid().
      
      RX_CLS_FLOW_DISC check is removed since it is redundant. The macro is
      defined as the max value fsp->ring_cookie can have, so checking if
      fsp->ring_cookie >= adapter->num_rx_queues is already sufficient.
      
      Finally, some log messages are improved or added, and obvious comments
      are removed.
      Signed-off-by: default avatarAndre Guedes <andre.guedes@intel.com>
      Tested-by: default avatarAaron Brown <aaron.f.brown@intel.com>
      Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
      16fdc16c
  2. 22 May, 2020 33 commits