Commit 5f930713 authored by Andre Guedes's avatar Andre Guedes Committed by Jeff Kirsher
Browse files

igc: Refactor igc_del_mac_filter()



This patch does a code refactoring in igc_del_mac_filter() so it uses
the new helper igc_find_mac_filter() and improves the comment about the
special handling when deleting the default filter.

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>
parent 794e5bc8
Loading
Loading
Loading
Loading
+19 −26
Original line number Diff line number Diff line
@@ -2267,42 +2267,35 @@ update_queue_assignment:
int igc_del_mac_filter(struct igc_adapter *adapter, const u8 *addr,
		       const u8 flags)
{
	struct igc_hw *hw = &adapter->hw;
	int rar_entries = hw->mac.rar_entry_count;
	int i;
	struct igc_mac_addr *entry;
	int index;

	if (!is_valid_ether_addr(addr))
		return -EINVAL;

	for (i = 0; i < rar_entries; i++) {
		if (!(adapter->mac_table[i].state & IGC_MAC_STATE_IN_USE))
			continue;
		if (flags && (adapter->mac_table[i].state & flags) != flags)
			continue;
		if (!ether_addr_equal(adapter->mac_table[i].addr, addr))
			continue;
	index = igc_find_mac_filter(adapter, addr, flags);
	if (index < 0)
		return -ENOENT;

	entry = &adapter->mac_table[index];

		/* When a filter for the default address is "deleted",
		 * we return it to its initial configuration
	if (entry->state & IGC_MAC_STATE_DEFAULT) {
		/* If this is the default filter, we don't actually delete it.
		 * We just reset to its default value i.e. disable queue
		 * assignment.
		 */
		if (adapter->mac_table[i].state & IGC_MAC_STATE_DEFAULT) {
			adapter->mac_table[i].state =
				IGC_MAC_STATE_DEFAULT | IGC_MAC_STATE_IN_USE;
			adapter->mac_table[i].queue = -1;
			igc_set_mac_filter_hw(adapter, 0, addr, -1);
		entry->queue = -1;
		igc_set_mac_filter_hw(adapter, 0, addr, entry->queue);
	} else {
			adapter->mac_table[i].state = 0;
			adapter->mac_table[i].queue = -1;
			memset(adapter->mac_table[i].addr, 0, ETH_ALEN);
			igc_clear_mac_filter_hw(adapter, i);
		entry->state = 0;
		entry->queue = -1;
		memset(entry->addr, 0, ETH_ALEN);
		igc_clear_mac_filter_hw(adapter, index);
	}

	return 0;
}

	return -ENOENT;
}

static int igc_uc_sync(struct net_device *netdev, const unsigned char *addr)
{
	struct igc_adapter *adapter = netdev_priv(netdev);