Commit ccffad25 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

net: convert unicast addr list

This patch converts unicast address list to standard list_head using
previously introduced struct netdev_hw_addr. It also relaxes the
locking. Original spinlock (still used for multicast addresses) is not
needed and is no longer used for a protection of this list. All
reading and writing takes place under rtnl (with no changes).

I also removed a possibility to specify the length of the address
while adding or deleting unicast address. It's always dev->addr_len.

The convertion touched especially e1000 and ixgbe codes when the
change is not so trivial.
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>

 drivers/net/bnx2.c               |   13 +--
 drivers/net/e1000/e1000_main.c   |   24 +++--
 drivers/net/ixgbe/ixgbe_common.c |   14 ++--
 drivers/net/ixgbe/ixgbe_common.h |    4 +-
 drivers/net/ixgbe/ixgbe_main.c   |    6 +-
 drivers/net/ixgbe/ixgbe_type.h   |    4 +-
 drivers/net/macvlan.c            |   11 +-
 drivers/net/mv643xx_eth.c        |   11 +-
 drivers/net/niu.c                |    7 +-
 drivers/net/virtio_net.c         |    7 +-
 drivers/s390/net/qeth_l2_main.c  |    6 +-
 drivers/scsi/fcoe/fcoe.c         |   16 ++--
 include/linux/netdevice.h        |   18 ++--
 net/8021q/vlan.c                 |    4 +-
 net/8021q/vlan_dev.c             |   10 +-
 net/core/dev.c                   |  195 +++++++++++++++++++++++++++-----------
 net/dsa/slave.c                  |   10 +-
 net/packet/af_packet.c           |    4 +-
 18 files changed, 227 insertions(+), 137 deletions(-)
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ae63e808
...@@ -48,6 +48,7 @@ ...@@ -48,6 +48,7 @@
#include <linux/cache.h> #include <linux/cache.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/list.h>
#include "bnx2.h" #include "bnx2.h"
#include "bnx2_fw.h" #include "bnx2_fw.h"
...@@ -3310,7 +3311,7 @@ bnx2_set_rx_mode(struct net_device *dev) ...@@ -3310,7 +3311,7 @@ bnx2_set_rx_mode(struct net_device *dev)
{ {
struct bnx2 *bp = netdev_priv(dev); struct bnx2 *bp = netdev_priv(dev);
u32 rx_mode, sort_mode; u32 rx_mode, sort_mode;
struct dev_addr_list *uc_ptr; struct netdev_hw_addr *ha;
int i; int i;
if (!netif_running(dev)) if (!netif_running(dev))
...@@ -3369,21 +3370,19 @@ bnx2_set_rx_mode(struct net_device *dev) ...@@ -3369,21 +3370,19 @@ bnx2_set_rx_mode(struct net_device *dev)
sort_mode |= BNX2_RPM_SORT_USER0_MC_HSH_EN; sort_mode |= BNX2_RPM_SORT_USER0_MC_HSH_EN;
} }
uc_ptr = NULL;
if (dev->uc_count > BNX2_MAX_UNICAST_ADDRESSES) { if (dev->uc_count > BNX2_MAX_UNICAST_ADDRESSES) {
rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS; rx_mode |= BNX2_EMAC_RX_MODE_PROMISCUOUS;
sort_mode |= BNX2_RPM_SORT_USER0_PROM_EN | sort_mode |= BNX2_RPM_SORT_USER0_PROM_EN |
BNX2_RPM_SORT_USER0_PROM_VLAN; BNX2_RPM_SORT_USER0_PROM_VLAN;
} else if (!(dev->flags & IFF_PROMISC)) { } else if (!(dev->flags & IFF_PROMISC)) {
uc_ptr = dev->uc_list;
/* Add all entries into to the match filter list */ /* Add all entries into to the match filter list */
for (i = 0; i < dev->uc_count; i++) { i = 0;
bnx2_set_mac_addr(bp, uc_ptr->da_addr, list_for_each_entry(ha, &dev->uc_list, list) {
bnx2_set_mac_addr(bp, ha->addr,
i + BNX2_START_UNICAST_ADDRESS_INDEX); i + BNX2_START_UNICAST_ADDRESS_INDEX);
sort_mode |= (1 << sort_mode |= (1 <<
(i + BNX2_START_UNICAST_ADDRESS_INDEX)); (i + BNX2_START_UNICAST_ADDRESS_INDEX));
uc_ptr = uc_ptr->next; i++;
} }
} }
......
...@@ -2330,7 +2330,8 @@ static void e1000_set_rx_mode(struct net_device *netdev) ...@@ -2330,7 +2330,8 @@ static void e1000_set_rx_mode(struct net_device *netdev)
{ {
struct e1000_adapter *adapter = netdev_priv(netdev); struct e1000_adapter *adapter = netdev_priv(netdev);
struct e1000_hw *hw = &adapter->hw; struct e1000_hw *hw = &adapter->hw;
struct dev_addr_list *uc_ptr; struct netdev_hw_addr *ha;
bool use_uc = false;
struct dev_addr_list *mc_ptr; struct dev_addr_list *mc_ptr;
u32 rctl; u32 rctl;
u32 hash_value; u32 hash_value;
...@@ -2369,12 +2370,11 @@ static void e1000_set_rx_mode(struct net_device *netdev) ...@@ -2369,12 +2370,11 @@ static void e1000_set_rx_mode(struct net_device *netdev)
rctl |= E1000_RCTL_VFE; rctl |= E1000_RCTL_VFE;
} }
uc_ptr = NULL;
if (netdev->uc_count > rar_entries - 1) { if (netdev->uc_count > rar_entries - 1) {
rctl |= E1000_RCTL_UPE; rctl |= E1000_RCTL_UPE;
} else if (!(netdev->flags & IFF_PROMISC)) { } else if (!(netdev->flags & IFF_PROMISC)) {
rctl &= ~E1000_RCTL_UPE; rctl &= ~E1000_RCTL_UPE;
uc_ptr = netdev->uc_list; use_uc = true;
} }
ew32(RCTL, rctl); ew32(RCTL, rctl);
...@@ -2392,13 +2392,20 @@ static void e1000_set_rx_mode(struct net_device *netdev) ...@@ -2392,13 +2392,20 @@ static void e1000_set_rx_mode(struct net_device *netdev)
* if there are not 14 addresses, go ahead and clear the filters * if there are not 14 addresses, go ahead and clear the filters
* -- with 82571 controllers only 0-13 entries are filled here * -- with 82571 controllers only 0-13 entries are filled here
*/ */
i = 1;
if (use_uc)
list_for_each_entry(ha, &netdev->uc_list, list) {
if (i == rar_entries)
break;
e1000_rar_set(hw, ha->addr, i++);
}
WARN_ON(i == rar_entries);
mc_ptr = netdev->mc_list; mc_ptr = netdev->mc_list;
for (i = 1; i < rar_entries; i++) { for (; i < rar_entries; i++) {
if (uc_ptr) { if (mc_ptr) {
e1000_rar_set(hw, uc_ptr->da_addr, i);
uc_ptr = uc_ptr->next;
} else if (mc_ptr) {
e1000_rar_set(hw, mc_ptr->da_addr, i); e1000_rar_set(hw, mc_ptr->da_addr, i);
mc_ptr = mc_ptr->next; mc_ptr = mc_ptr->next;
} else { } else {
...@@ -2408,7 +2415,6 @@ static void e1000_set_rx_mode(struct net_device *netdev) ...@@ -2408,7 +2415,6 @@ static void e1000_set_rx_mode(struct net_device *netdev)
E1000_WRITE_FLUSH(); E1000_WRITE_FLUSH();
} }
} }
WARN_ON(uc_ptr != NULL);
/* load any remaining addresses into the hash table */ /* load any remaining addresses into the hash table */
......
...@@ -28,6 +28,8 @@ ...@@ -28,6 +28,8 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/list.h>
#include <linux/netdevice.h>
#include "ixgbe.h" #include "ixgbe.h"
#include "ixgbe_common.h" #include "ixgbe_common.h"
...@@ -1356,15 +1358,14 @@ static void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq) ...@@ -1356,15 +1358,14 @@ static void ixgbe_add_uc_addr(struct ixgbe_hw *hw, u8 *addr, u32 vmdq)
* Drivers using secondary unicast addresses must set user_set_promisc when * Drivers using secondary unicast addresses must set user_set_promisc when
* manually putting the device into promiscuous mode. * manually putting the device into promiscuous mode.
**/ **/
s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw, u8 *addr_list, s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw,
u32 addr_count, ixgbe_mc_addr_itr next) struct list_head *uc_list)
{ {
u8 *addr;
u32 i; u32 i;
u32 old_promisc_setting = hw->addr_ctrl.overflow_promisc; u32 old_promisc_setting = hw->addr_ctrl.overflow_promisc;
u32 uc_addr_in_use; u32 uc_addr_in_use;
u32 fctrl; u32 fctrl;
u32 vmdq; struct netdev_hw_addr *ha;
/* /*
* Clear accounting of old secondary address list, * Clear accounting of old secondary address list,
...@@ -1382,10 +1383,9 @@ s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw, u8 *addr_list, ...@@ -1382,10 +1383,9 @@ s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw, u8 *addr_list,
} }
/* Add the new addresses */ /* Add the new addresses */
for (i = 0; i < addr_count; i++) { list_for_each_entry(ha, uc_list, list) {
hw_dbg(hw, " Adding the secondary addresses:\n"); hw_dbg(hw, " Adding the secondary addresses:\n");
addr = next(hw, &addr_list, &vmdq); ixgbe_add_uc_addr(hw, ha->addr, 0);
ixgbe_add_uc_addr(hw, addr, vmdq);
} }
if (hw->addr_ctrl.overflow_promisc) { if (hw->addr_ctrl.overflow_promisc) {
......
...@@ -59,8 +59,8 @@ s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw); ...@@ -59,8 +59,8 @@ s32 ixgbe_init_rx_addrs_generic(struct ixgbe_hw *hw);
s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, u8 *mc_addr_list, s32 ixgbe_update_mc_addr_list_generic(struct ixgbe_hw *hw, u8 *mc_addr_list,
u32 mc_addr_count, u32 mc_addr_count,
ixgbe_mc_addr_itr func); ixgbe_mc_addr_itr func);
s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw, u8 *addr_list, s32 ixgbe_update_uc_addr_list_generic(struct ixgbe_hw *hw,
u32 addr_count, ixgbe_mc_addr_itr func); struct list_head *uc_list);
s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw); s32 ixgbe_enable_mc_generic(struct ixgbe_hw *hw);
s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw); s32 ixgbe_disable_mc_generic(struct ixgbe_hw *hw);
s32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval); s32 ixgbe_enable_rx_dma_generic(struct ixgbe_hw *hw, u32 regval);
......
...@@ -2181,11 +2181,7 @@ static void ixgbe_set_rx_mode(struct net_device *netdev) ...@@ -2181,11 +2181,7 @@ static void ixgbe_set_rx_mode(struct net_device *netdev)
IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl); IXGBE_WRITE_REG(hw, IXGBE_VLNCTRL, vlnctrl);
/* reprogram secondary unicast list */ /* reprogram secondary unicast list */
addr_count = netdev->uc_count; hw->mac.ops.update_uc_addr_list(hw, &netdev->uc_list);
if (addr_count)
addr_list = netdev->uc_list->dmi_addr;
hw->mac.ops.update_uc_addr_list(hw, addr_list, addr_count,
ixgbe_addr_list_itr);
/* reprogram multicast list */ /* reprogram multicast list */
addr_count = netdev->mc_count; addr_count = netdev->mc_count;
......
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/mdio.h> #include <linux/mdio.h>
#include <linux/list.h>
/* Vendor ID */ /* Vendor ID */
#define IXGBE_INTEL_VENDOR_ID 0x8086 #define IXGBE_INTEL_VENDOR_ID 0x8086
...@@ -2223,8 +2224,7 @@ struct ixgbe_mac_operations { ...@@ -2223,8 +2224,7 @@ struct ixgbe_mac_operations {
s32 (*set_vmdq)(struct ixgbe_hw *, u32, u32); s32 (*set_vmdq)(struct ixgbe_hw *, u32, u32);
s32 (*clear_vmdq)(struct ixgbe_hw *, u32, u32); s32 (*clear_vmdq)(struct ixgbe_hw *, u32, u32);
s32 (*init_rx_addrs)(struct ixgbe_hw *); s32 (*init_rx_addrs)(struct ixgbe_hw *);
s32 (*update_uc_addr_list)(struct ixgbe_hw *, u8 *, u32, s32 (*update_uc_addr_list)(struct ixgbe_hw *, struct list_head *);
ixgbe_mc_addr_itr);
s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32, s32 (*update_mc_addr_list)(struct ixgbe_hw *, u8 *, u32,
ixgbe_mc_addr_itr); ixgbe_mc_addr_itr);
s32 (*enable_mc)(struct ixgbe_hw *); s32 (*enable_mc)(struct ixgbe_hw *);
......
...@@ -232,7 +232,7 @@ static int macvlan_open(struct net_device *dev) ...@@ -232,7 +232,7 @@ static int macvlan_open(struct net_device *dev)
if (macvlan_addr_busy(vlan->port, dev->dev_addr)) if (macvlan_addr_busy(vlan->port, dev->dev_addr))
goto out; goto out;
err = dev_unicast_add(lowerdev, dev->dev_addr, ETH_ALEN); err = dev_unicast_add(lowerdev, dev->dev_addr);
if (err < 0) if (err < 0)
goto out; goto out;
if (dev->flags & IFF_ALLMULTI) { if (dev->flags & IFF_ALLMULTI) {
...@@ -244,7 +244,7 @@ static int macvlan_open(struct net_device *dev) ...@@ -244,7 +244,7 @@ static int macvlan_open(struct net_device *dev)
return 0; return 0;
del_unicast: del_unicast:
dev_unicast_delete(lowerdev, dev->dev_addr, ETH_ALEN); dev_unicast_delete(lowerdev, dev->dev_addr);
out: out:
return err; return err;
} }
...@@ -258,7 +258,7 @@ static int macvlan_stop(struct net_device *dev) ...@@ -258,7 +258,7 @@ static int macvlan_stop(struct net_device *dev)
if (dev->flags & IFF_ALLMULTI) if (dev->flags & IFF_ALLMULTI)
dev_set_allmulti(lowerdev, -1); dev_set_allmulti(lowerdev, -1);
dev_unicast_delete(lowerdev, dev->dev_addr, ETH_ALEN); dev_unicast_delete(lowerdev, dev->dev_addr);
macvlan_hash_del(vlan); macvlan_hash_del(vlan);
return 0; return 0;
...@@ -282,10 +282,11 @@ static int macvlan_set_mac_address(struct net_device *dev, void *p) ...@@ -282,10 +282,11 @@ static int macvlan_set_mac_address(struct net_device *dev, void *p)
if (macvlan_addr_busy(vlan->port, addr->sa_data)) if (macvlan_addr_busy(vlan->port, addr->sa_data))
return -EBUSY; return -EBUSY;
if ((err = dev_unicast_add(lowerdev, addr->sa_data, ETH_ALEN))) err = dev_unicast_add(lowerdev, addr->sa_data);
if (err)
return err; return err;
dev_unicast_delete(lowerdev, dev->dev_addr, ETH_ALEN); dev_unicast_delete(lowerdev, dev->dev_addr);
macvlan_hash_change_addr(vlan, addr->sa_data); macvlan_hash_change_addr(vlan, addr->sa_data);
} }
......
...@@ -55,6 +55,7 @@ ...@@ -55,6 +55,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/inet_lro.h> #include <linux/inet_lro.h>
#include <asm/system.h> #include <asm/system.h>
#include <linux/list.h>
static char mv643xx_eth_driver_name[] = "mv643xx_eth"; static char mv643xx_eth_driver_name[] = "mv643xx_eth";
static char mv643xx_eth_driver_version[] = "1.4"; static char mv643xx_eth_driver_version[] = "1.4";
...@@ -1721,20 +1722,20 @@ static void uc_addr_set(struct mv643xx_eth_private *mp, unsigned char *addr) ...@@ -1721,20 +1722,20 @@ static void uc_addr_set(struct mv643xx_eth_private *mp, unsigned char *addr)
static u32 uc_addr_filter_mask(struct net_device *dev) static u32 uc_addr_filter_mask(struct net_device *dev)
{ {
struct dev_addr_list *uc_ptr; struct netdev_hw_addr *ha;
u32 nibbles; u32 nibbles;
if (dev->flags & IFF_PROMISC) if (dev->flags & IFF_PROMISC)
return 0; return 0;
nibbles = 1 << (dev->dev_addr[5] & 0x0f); nibbles = 1 << (dev->dev_addr[5] & 0x0f);
for (uc_ptr = dev->uc_list; uc_ptr != NULL; uc_ptr = uc_ptr->next) { list_for_each_entry(ha, &dev->uc_list, list) {
if (memcmp(dev->dev_addr, uc_ptr->da_addr, 5)) if (memcmp(dev->dev_addr, ha->addr, 5))
return 0; return 0;
if ((dev->dev_addr[5] ^ uc_ptr->da_addr[5]) & 0xf0) if ((dev->dev_addr[5] ^ ha->addr[5]) & 0xf0)
return 0; return 0;
nibbles |= 1 << (uc_ptr->da_addr[5] & 0x0f); nibbles |= 1 << (ha->addr[5] & 0x0f);
} }
return nibbles; return nibbles;
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/log2.h> #include <linux/log2.h>
#include <linux/jiffies.h> #include <linux/jiffies.h>
#include <linux/crc32.h> #include <linux/crc32.h>
#include <linux/list.h>
#include <linux/io.h> #include <linux/io.h>
...@@ -6362,6 +6363,7 @@ static void niu_set_rx_mode(struct net_device *dev) ...@@ -6362,6 +6363,7 @@ static void niu_set_rx_mode(struct net_device *dev)
struct niu *np = netdev_priv(dev); struct niu *np = netdev_priv(dev);
int i, alt_cnt, err; int i, alt_cnt, err;
struct dev_addr_list *addr; struct dev_addr_list *addr;
struct netdev_hw_addr *ha;
unsigned long flags; unsigned long flags;
u16 hash[16] = { 0, }; u16 hash[16] = { 0, };
...@@ -6383,9 +6385,8 @@ static void niu_set_rx_mode(struct net_device *dev) ...@@ -6383,9 +6385,8 @@ static void niu_set_rx_mode(struct net_device *dev)
if (alt_cnt) { if (alt_cnt) {
int index = 0; int index = 0;
for (addr = dev->uc_list; addr; addr = addr->next) { list_for_each_entry(ha, &dev->uc_list, list) {
err = niu_set_alt_mac(np, index, err = niu_set_alt_mac(np, index, ha->addr);
addr->da_addr);
if (err) if (err)
printk(KERN_WARNING PFX "%s: Error %d " printk(KERN_WARNING PFX "%s: Error %d "
"adding alt mac %d\n", "adding alt mac %d\n",
......
...@@ -680,6 +680,7 @@ static void virtnet_set_rx_mode(struct net_device *dev) ...@@ -680,6 +680,7 @@ static void virtnet_set_rx_mode(struct net_device *dev)
u8 promisc, allmulti; u8 promisc, allmulti;
struct virtio_net_ctrl_mac *mac_data; struct virtio_net_ctrl_mac *mac_data;
struct dev_addr_list *addr; struct dev_addr_list *addr;
struct netdev_hw_addr *ha;
void *buf; void *buf;
int i; int i;
...@@ -718,9 +719,9 @@ static void virtnet_set_rx_mode(struct net_device *dev) ...@@ -718,9 +719,9 @@ static void virtnet_set_rx_mode(struct net_device *dev)
/* Store the unicast list and count in the front of the buffer */ /* Store the unicast list and count in the front of the buffer */
mac_data->entries = dev->uc_count; mac_data->entries = dev->uc_count;
addr = dev->uc_list; i = 0;
for (i = 0; i < dev->uc_count; i++, addr = addr->next) list_for_each_entry(ha, &dev->uc_list, list)
memcpy(&mac_data->macs[i][0], addr->da_addr, ETH_ALEN); memcpy(&mac_data->macs[i++][0], ha->addr, ETH_ALEN);
sg_set_buf(&sg[0], mac_data, sg_set_buf(&sg[0], mac_data,
sizeof(mac_data->entries) + (dev->uc_count * ETH_ALEN)); sizeof(mac_data->entries) + (dev->uc_count * ETH_ALEN));
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <linux/mii.h> #include <linux/mii.h>
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/list.h>
#include "qeth_core.h" #include "qeth_core.h"
...@@ -640,6 +641,7 @@ static void qeth_l2_set_multicast_list(struct net_device *dev) ...@@ -640,6 +641,7 @@ static void qeth_l2_set_multicast_list(struct net_device *dev)
{ {
struct qeth_card *card = dev->ml_priv; struct qeth_card *card = dev->ml_priv;
struct dev_addr_list *dm; struct dev_addr_list *dm;
struct netdev_hw_addr *ha;
if (card->info.type == QETH_CARD_TYPE_OSN) if (card->info.type == QETH_CARD_TYPE_OSN)
return ; return ;
...@@ -653,8 +655,8 @@ static void qeth_l2_set_multicast_list(struct net_device *dev) ...@@ -653,8 +655,8 @@ static void qeth_l2_set_multicast_list(struct net_device *dev)
for (dm = dev->mc_list; dm; dm = dm->next) for (dm = dev->mc_list; dm; dm = dm->next)
qeth_l2_add_mc(card, dm->da_addr, 0); qeth_l2_add_mc(card, dm->da_addr, 0);
for (dm = dev->uc_list; dm; dm = dm->next) list_for_each_entry(ha, &dev->uc_list, list)
qeth_l2_add_mc(card, dm->da_addr, 1); qeth_l2_add_mc(card, ha->addr, 1);
spin_unlock_bh(&card->mclock); spin_unlock_bh(&card->mclock);
if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) if (!qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE))
......
...@@ -182,8 +182,8 @@ static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new) ...@@ -182,8 +182,8 @@ static void fcoe_update_src_mac(struct fcoe_ctlr *fip, u8 *old, u8 *new)
fc = fcoe_from_ctlr(fip); fc = fcoe_from_ctlr(fip);
rtnl_lock(); rtnl_lock();
if (!is_zero_ether_addr(old)) if (!is_zero_ether_addr(old))
dev_unicast_delete(fc->real_dev, old, ETH_ALEN); dev_unicast_delete(fc->real_dev, old);
dev_unicast_add(fc->real_dev, new, ETH_ALEN); dev_unicast_add(fc->real_dev, new);
rtnl_unlock(); rtnl_unlock();
} }
...@@ -233,13 +233,11 @@ void fcoe_netdev_cleanup(struct fcoe_softc *fc) ...@@ -233,13 +233,11 @@ void fcoe_netdev_cleanup(struct fcoe_softc *fc)
/* Delete secondary MAC addresses */ /* Delete secondary MAC addresses */
rtnl_lock(); rtnl_lock();
memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
dev_unicast_delete(fc->real_dev, flogi_maddr, ETH_ALEN); dev_unicast_delete(fc->real_dev, flogi_maddr);
if (!is_zero_ether_addr(fc->ctlr.data_src_addr)) if (!is_zero_ether_addr(fc->ctlr.data_src_addr))
dev_unicast_delete(fc->real_dev, dev_unicast_delete(fc->real_dev, fc->ctlr.data_src_addr);
fc->ctlr.data_src_addr, ETH_ALEN);
if (fc->ctlr.spma) if (fc->ctlr.spma)
dev_unicast_delete(fc->real_dev, dev_unicast_delete(fc->real_dev, fc->ctlr.ctl_src_addr);
fc->ctlr.ctl_src_addr, ETH_ALEN);
dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); dev_mc_delete(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
rtnl_unlock(); rtnl_unlock();
} }
...@@ -347,9 +345,9 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev) ...@@ -347,9 +345,9 @@ static int fcoe_netdev_config(struct fc_lport *lp, struct net_device *netdev)
*/ */
rtnl_lock(); rtnl_lock();
memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN); memcpy(flogi_maddr, (u8[6]) FC_FCOE_FLOGI_MAC, ETH_ALEN);
dev_unicast_add(fc->real_dev, flogi_maddr, ETH_ALEN); dev_unicast_add(fc->real_dev, flogi_maddr);
if (fc->ctlr.spma) if (fc->ctlr.spma)
dev_unicast_add(fc->real_dev, fc->ctlr.ctl_src_addr, ETH_ALEN); dev_unicast_add(fc->real_dev, fc->ctlr.ctl_src_addr);
dev_mc_add(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0); dev_mc_add(fc->real_dev, FIP_ALL_ENODE_MACS, ETH_ALEN, 0);
rtnl_unlock(); rtnl_unlock();
......
...@@ -218,6 +218,9 @@ struct netdev_hw_addr { ...@@ -218,6 +218,9 @@ struct netdev_hw_addr {
#define NETDEV_HW_ADDR_T_LAN 1 #define NETDEV_HW_ADDR_T_LAN 1
#define NETDEV_HW_ADDR_T_SAN 2 #define NETDEV_HW_ADDR_T_SAN 2
#define NETDEV_HW_ADDR_T_SLAVE 3 #define NETDEV_HW_ADDR_T_SLAVE 3
#define NETDEV_HW_ADDR_T_UNICAST 4
int refcount;
bool synced;
struct rcu_head rcu_head; struct rcu_head rcu_head;
}; };
...@@ -773,10 +776,11 @@ struct net_device ...@@ -773,10 +776,11 @@ struct net_device
unsigned char addr_len; /* hardware address length */ unsigned char addr_len; /* hardware address length */
unsigned short dev_id; /* for shared network cards */ unsigned short dev_id; /* for shared network cards */
spinlock_t addr_list_lock; struct list_head uc_list; /* Secondary unicast mac
struct dev_addr_list *uc_list; /* Secondary unicast mac addresses */ addresses */
int uc_count; /* Number of installed ucasts */ int uc_count; /* Number of installed ucasts */
int uc_promisc; int uc_promisc;
spinlock_t addr_list_lock;
struct dev_addr_list *mc_list; /* Multicast mac addresses */ struct dev_addr_list *mc_list; /* Multicast mac addresses */
int mc_count; /* Number of installed mcasts */ int mc_count; /* Number of installed mcasts */
unsigned int promiscuity; unsigned int promiscuity;
...@@ -1836,8 +1840,8 @@ extern int dev_addr_del_multiple(struct net_device *to_dev, ...@@ -1836,8 +1840,8 @@ extern int dev_addr_del_multiple(struct net_device *to_dev,
/* Functions used for secondary unicast and multicast support */ /* Functions used for secondary unicast and multicast support */
extern void dev_set_rx_mode(struct net_device *dev); extern void dev_set_rx_mode(struct net_device *dev);
extern void __dev_set_rx_mode(struct net_device *dev); extern void __dev_set_rx_mode(struct net_device *dev);
extern int dev_unicast_delete(struct net_device *dev, void *addr, int alen); extern int dev_unicast_delete(struct net_device *dev, void *addr);
extern int dev_unicast_add(struct net_device *dev, void *addr, int alen); extern int dev_unicast_add(struct net_device *dev, void *addr);
extern int dev_unicast_sync(struct net_device *to, struct net_device *from); extern int dev_unicast_sync(struct net_device *to, struct net_device *from);
extern void dev_unicast_unsync(struct net_device *to, struct net_device *from); extern void dev_unicast_unsync(struct net_device *to, struct net_device *from);
extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all); extern int dev_mc_delete(struct net_device *dev, void *addr, int alen, int all);
......
...@@ -378,13 +378,13 @@ static void vlan_sync_address(struct net_device *dev, ...@@ -378,13 +378,13 @@ static void vlan_sync_address(struct net_device *dev,
* the new address */ * the new address */
if (compare_ether_addr(vlandev->dev_addr, vlan->real_dev_addr) && if (compare_ether_addr(vlandev->dev_addr, vlan->real_dev_addr) &&
!compare_ether_addr(vlandev->dev_addr, dev->dev_addr)) !compare_ether_addr(vlandev->dev_addr, dev->dev_addr))
dev_unicast_delete(dev, vlandev->dev_addr, ETH_ALEN); dev_unicast_delete(dev, vlandev->dev_addr);
/* vlan address was equal to the old address and is different from /* vlan address was equal to the old address and is different from
* the new address */ * the new address */
if (!compare_ether_addr(vlandev->dev_addr, vlan->real_dev_addr) && if (!compare_ether_addr(vlandev->dev_addr, vlan->real_dev_addr) &&
compare_ether_addr(vlandev->dev_addr, dev->dev_addr)) compare_ether_addr(vlandev->dev_addr, dev->dev_addr))
dev_unicast_add(dev, vlandev->dev_addr, ETH_ALEN); dev_unicast_add(dev, vlandev->dev_addr);
memcpy(vlan->real_dev_addr, dev->dev_addr, ETH_ALEN); memcpy(vlan->real_dev_addr, dev->dev_addr, ETH_ALEN);
} }
......
...@@ -441,7 +441,7 @@ static int vlan_dev_open(struct net_device *dev) ...@@ -441,7 +441,7 @@ static int vlan_dev_open(struct net_device *dev)
return -ENETDOWN; return -ENETDOWN;
if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr)) { if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr)) {
err = dev_unicast_add(real_dev, dev->dev_addr, ETH_ALEN); err = dev_unicast_add(real_dev, dev->dev_addr);
if (err < 0) if (err < 0)
goto out; goto out;
} }
...@@ -470,7 +470,7 @@ static int vlan_dev_open(struct net_device *dev) ...@@ -470,7 +470,7 @@ static int vlan_dev_open(struct net_device *dev)
dev_set_allmulti(real_dev, -1); dev_set_allmulti(real_dev, -1);
del_unicast: del_unicast:
if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr)) if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr))
dev_unicast_delete(real_dev, dev->dev_addr, ETH_ALEN); dev_unicast_delete(real_dev, dev->dev_addr);
out: out:
netif_carrier_off(dev); netif_carrier_off(dev);
return err; return err;
...@@ -492,7 +492,7 @@ static int vlan_dev_stop(struct net_device *dev) ...@@ -492,7 +492,7 @@ static int vlan_dev_stop(struct net_device *dev)
dev_set_promiscuity(real_dev, -1); dev_set_promiscuity(real_dev, -1);
if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr)) if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr))
dev_unicast_delete(real_dev, dev->dev_addr, dev->addr_len); dev_unicast_delete(real_dev, dev->dev_addr);
netif_carrier_off(dev); netif_carrier_off(dev);
return 0; return 0;
...@@ -511,13 +511,13 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p) ...@@ -511,13 +511,13 @@ static int vlan_dev_set_mac_address(struct net_device *dev, void *p)
goto out; goto out;
if (compare_ether_addr(addr->sa_data, real_dev->dev_addr)) { if (compare_ether_addr(addr->sa_data, real_dev->dev_addr)) {
err = dev_unicast_add(real_dev, addr->sa_data, ETH_ALEN); err = dev_unicast_add(real_dev, addr->sa_data);
if (err < 0) if (err < 0)
return err; return err;
} }
if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr)) if (compare_ether_addr(dev->dev_addr, real_dev->dev_addr))
dev_unicast_delete(real_dev, dev->dev_addr, ETH_ALEN); dev_unicast_delete(real_dev, dev->dev_addr);
out: out:
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
......
This diff is collapsed.
...@@ -67,7 +67,7 @@ static int dsa_slave_open(struct net_device *dev) ...@@ -67,7 +67,7 @@ static int dsa_slave_open(struct net_device *dev)
return -ENETDOWN; return -ENETDOWN;
if (compare_ether_addr(dev->dev_addr, master->dev_addr)) { if (compare_ether_addr(dev->dev_addr, master->dev_addr)) {
err = dev_unicast_add(master, dev->dev_addr, ETH_ALEN); err = dev_unicast_add(master, dev->dev_addr);
if (err < 0) if (err < 0)
goto out; goto out;
} }
...@@ -90,7 +90,7 @@ static int dsa_slave_open(struct net_device *dev) ...@@ -90,7 +90,7 @@ static int dsa_slave_open(struct net_device *dev)
dev_set_allmulti(master, -1); dev_set_allmulti(master, -1);
del_unicast: del_unicast:
if (compare_ether_addr(dev->dev_addr, master->dev_addr)) if (compare_ether_addr(dev->dev_addr, master->dev_addr))
dev_unicast_delete(master, dev->dev_addr, ETH_ALEN); dev_unicast_delete(master, dev->dev_addr);
out: out:
return err; return err;
} }
...@@ -108,7 +108,7 @@ static int dsa_slave_close(struct net_device *dev) ...@@ -108,7 +108,7 @@ static int dsa_slave_close(struct net_device *dev)
dev_set_promiscuity(master, -1); dev_set_promiscuity(master, -1);
if (compare_ether_addr(dev->dev_addr, master->dev_addr)) if (compare_ether_addr(dev->dev_addr, master->dev_addr))
dev_unicast_delete(master, dev->dev_addr, ETH_ALEN); dev_unicast_delete(master, dev->dev_addr);
return 0; return 0;
} }
...@@ -147,13 +147,13 @@ static int dsa_slave_set_mac_address(struct net_device *dev, void *a) ...@@ -147,13 +147,13 @@ static int dsa_slave_set_mac_address(struct net_device *dev, void *a)
goto out; goto out;
if (compare_ether_addr(addr->sa_data, master->dev_addr)) { if (compare_ether_addr(addr->sa_data, master->dev_addr)) {
err = dev_unicast_add(master, addr->sa_data, ETH_ALEN); err = dev_unicast_add(master, addr->sa_data);
if (err < 0) if (err < 0)
return err; return err;
} }
if (compare_ether_addr(dev->dev_addr, master->dev_addr)) if (compare_ether_addr(dev->dev_addr, master->dev_addr))
dev_unicast_delete(master, dev->dev_addr, ETH_ALEN); dev_unicast_delete(master, dev->dev_addr);
out: out:
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
......
...@@ -1582,9 +1582,9 @@ static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i, ...@@ -1582,9 +1582,9 @@ static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i,
break; break;
case PACKET_MR_UNICAST: case PACKET_MR_UNICAST:
if (what > 0) if (what > 0)
return dev_unicast_add(dev, i->addr, i->alen); return dev_unicast_add(dev, i->addr);
else else
return dev_unicast_delete(dev, i->addr, i->alen); return dev_unicast_delete(dev, i->addr);
break; break;
default:; default:;
} }
......
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