Skip to content

Commit

Permalink
net: convert multicast list to list_head
Browse files Browse the repository at this point in the history
Converts the list and the core manipulating with it to be the same as uc_list.

+uses two functions for adding/removing mc address (normal and "global"
 variant) instead of a function parameter.
+removes dev_mcast.c completely.
+exposes netdev_hw_addr_list_* macros along with __hw_addr_* functions for
 manipulation with lists on a sandbox (used in bonding and 80211 drivers)

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and davem330 committed Apr 3, 2010
1 parent a748ee2 commit 22bedad
Show file tree
Hide file tree
Showing 208 changed files with 1,137 additions and 1,327 deletions.
7 changes: 3 additions & 4 deletions drivers/infiniband/hw/nes/nes_nic.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,17 +876,16 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
if (!mc_all_on) {
char *addrs;
int i;
struct dev_mc_list *mcaddr;
struct netdev_hw_addr *ha;

addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
if (!addrs) {
set_allmulti(nesdev, nic_active_bit);
goto unlock;
}
i = 0;
netdev_for_each_mc_addr(mcaddr, netdev)
memcpy(get_addr(addrs, i++),
mcaddr->dmi_addr, ETH_ALEN);
netdev_for_each_mc_addr(ha, netdev)
memcpy(get_addr(addrs, i++), ha->addr, ETH_ALEN);

perfect_filter_register_address = NES_IDX_PERFECT_FILTER_LOW +
pft_entries_preallocated * 0x8;
Expand Down
9 changes: 4 additions & 5 deletions drivers/infiniband/ulp/ipoib/ipoib_multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ void ipoib_mcast_restart_task(struct work_struct *work)
struct ipoib_dev_priv *priv =
container_of(work, struct ipoib_dev_priv, restart_task);
struct net_device *dev = priv->dev;
struct dev_mc_list *mclist;
struct netdev_hw_addr *ha;
struct ipoib_mcast *mcast, *tmcast;
LIST_HEAD(remove_list);
unsigned long flags;
Expand All @@ -808,14 +808,13 @@ void ipoib_mcast_restart_task(struct work_struct *work)
clear_bit(IPOIB_MCAST_FLAG_FOUND, &mcast->flags);

/* Mark all of the entries that are found or don't exist */
netdev_for_each_mc_addr(mclist, dev) {
netdev_for_each_mc_addr(ha, dev) {
union ib_gid mgid;

if (!ipoib_mcast_addr_is_valid(mclist->dmi_addr,
dev->broadcast))
if (!ipoib_mcast_addr_is_valid(ha->addr, dev->broadcast))
continue;

memcpy(mgid.raw, mclist->dmi_addr + 4, sizeof mgid);
memcpy(mgid.raw, ha->addr + 4, sizeof mgid);

mcast = __ipoib_mcast_find(dev, &mgid);
if (!mcast || test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
Expand Down
10 changes: 5 additions & 5 deletions drivers/media/dvb/dvb-core/dvb_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,14 +1109,14 @@ static int dvb_net_feed_stop(struct net_device *dev)
}


static int dvb_set_mc_filter (struct net_device *dev, struct dev_mc_list *mc)
static int dvb_set_mc_filter(struct net_device *dev, unsigned char *addr)
{
struct dvb_net_priv *priv = netdev_priv(dev);

if (priv->multi_num == DVB_NET_MULTICAST_MAX)
return -ENOMEM;

memcpy(priv->multi_macs[priv->multi_num], mc->dmi_addr, 6);
memcpy(priv->multi_macs[priv->multi_num], addr, ETH_ALEN);

priv->multi_num++;
return 0;
Expand All @@ -1140,16 +1140,16 @@ static void wq_set_multicast_list (struct work_struct *work)
dprintk("%s: allmulti mode\n", dev->name);
priv->rx_mode = RX_MODE_ALL_MULTI;
} else if (!netdev_mc_empty(dev)) {
struct dev_mc_list *mc;
struct netdev_hw_addr *ha;

dprintk("%s: set_mc_list, %d entries\n",
dev->name, netdev_mc_count(dev));

priv->rx_mode = RX_MODE_MULTI;
priv->multi_num = 0;

netdev_for_each_mc_addr(mc, dev)
dvb_set_mc_filter(dev, mc);
netdev_for_each_mc_addr(ha, dev)
dvb_set_mc_filter(dev, ha->addr);
}

netif_addr_unlock_bh(dev);
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/3c505.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,7 +1216,7 @@ static int elp_close(struct net_device *dev)
static void elp_set_mc_list(struct net_device *dev)
{
elp_device *adapter = netdev_priv(dev);
struct dev_mc_list *dmi;
struct netdev_hw_addr *ha;
int i;
unsigned long flags;

Expand All @@ -1231,8 +1231,9 @@ static void elp_set_mc_list(struct net_device *dev)
adapter->tx_pcb.command = CMD_LOAD_MULTICAST_LIST;
adapter->tx_pcb.length = 6 * netdev_mc_count(dev);
i = 0;
netdev_for_each_mc_addr(dmi, dev)
memcpy(adapter->tx_pcb.data.multicast[i++], dmi->dmi_addr, 6);
netdev_for_each_mc_addr(ha, dev)
memcpy(adapter->tx_pcb.data.multicast[i++],
ha->addr, 6);
adapter->got[CMD_LOAD_MULTICAST_LIST] = 0;
if (!send_pcb(dev, &adapter->tx_pcb))
pr_err("%s: couldn't send set_multicast command\n", dev->name);
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/3c523.c
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ static int init586(struct net_device *dev)
volatile struct iasetup_cmd_struct *ias_cmd;
volatile struct tdr_cmd_struct *tdr_cmd;
volatile struct mcsetup_cmd_struct *mc_cmd;
struct dev_mc_list *dmi;
struct netdev_hw_addr *ha;
int num_addrs = netdev_mc_count(dev);

ptr = (void *) ((char *) p->scb + sizeof(struct scb_struct));
Expand Down Expand Up @@ -788,8 +788,9 @@ static int init586(struct net_device *dev)
mc_cmd->cmd_link = 0xffff;
mc_cmd->mc_cnt = num_addrs * 6;
i = 0;
netdev_for_each_mc_addr(dmi, dev)
memcpy((char *) mc_cmd->mc_list[i++], dmi->dmi_addr, 6);
netdev_for_each_mc_addr(ha, dev)
memcpy((char *) mc_cmd->mc_list[i++],
ha->addr, 6);
p->scb->cbl_offset = make16(mc_cmd);
p->scb->cmd = CUC_START;
elmc_id_attn586();
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/3c527.c
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ static void do_mc32_set_multicast_list(struct net_device *dev, int retry)
{
unsigned char block[62];
unsigned char *bp;
struct dev_mc_list *dmc;
struct netdev_hw_addr *ha;

if(retry==0)
lp->mc_list_valid = 0;
Expand All @@ -1543,8 +1543,8 @@ static void do_mc32_set_multicast_list(struct net_device *dev, int retry)
block[0]=netdev_mc_count(dev);
bp=block+2;

netdev_for_each_mc_addr(dmc, dev) {
memcpy(bp, dmc->dmi_addr, 6);
netdev_for_each_mc_addr(ha, dev) {
memcpy(bp, ha->addr, 6);
bp+=6;
}
if(mc32_command_nowait(dev, 2, block,
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/7990.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ static void lance_load_multicast (struct net_device *dev)
struct lance_private *lp = netdev_priv(dev);
volatile struct lance_init_block *ib = lp->init_block;
volatile u16 *mcast_table = (u16 *)&ib->filter;
struct dev_mc_list *dmi;
struct netdev_hw_addr *ha;
char *addrs;
u32 crc;

Expand All @@ -610,8 +610,8 @@ static void lance_load_multicast (struct net_device *dev)
ib->filter [1] = 0;

/* Add addresses */
netdev_for_each_mc_addr(dmi, dev) {
addrs = dmi->dmi_addr;
netdev_for_each_mc_addr(ha, dev) {
addrs = ha->addr;

/* multicast address? */
if (!(*addrs & 1))
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/8139cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,11 +909,11 @@ static void __cp_set_rx_mode (struct net_device *dev)
rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
mc_filter[1] = mc_filter[0] = 0xffffffff;
} else {
struct dev_mc_list *mclist;
struct netdev_hw_addr *ha;
rx_mode = AcceptBroadcast | AcceptMyPhys;
mc_filter[1] = mc_filter[0] = 0;
netdev_for_each_mc_addr(mclist, dev) {
int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
netdev_for_each_mc_addr(ha, dev) {
int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;

mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
rx_mode |= AcceptMulticast;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/8139too.c
Original file line number Diff line number Diff line change
Expand Up @@ -2502,11 +2502,11 @@ static void __set_rx_mode (struct net_device *dev)
rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
mc_filter[1] = mc_filter[0] = 0xffffffff;
} else {
struct dev_mc_list *mclist;
struct netdev_hw_addr *ha;
rx_mode = AcceptBroadcast | AcceptMyPhys;
mc_filter[1] = mc_filter[0] = 0;
netdev_for_each_mc_addr(mclist, dev) {
int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
netdev_for_each_mc_addr(ha, dev) {
int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;

mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
rx_mode |= AcceptMulticast;
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/82596.c
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ static void set_multicast_list(struct net_device *dev)
}

if (!netdev_mc_empty(dev)) {
struct dev_mc_list *dmi;
struct netdev_hw_addr *ha;
unsigned char *cp;
struct mc_cmd *cmd;

Expand All @@ -1552,10 +1552,10 @@ static void set_multicast_list(struct net_device *dev)
cmd->cmd.command = CmdMulticastList;
cmd->mc_cnt = cnt * ETH_ALEN;
cp = cmd->mc_addrs;
netdev_for_each_mc_addr(dmi, dev) {
netdev_for_each_mc_addr(ha, dev) {
if (!cnt--)
break;
memcpy(cp, dmi->dmi_addr, ETH_ALEN);
memcpy(cp, ha->addr, ETH_ALEN);
if (i596_debug > 1)
DEB(DEB_MULTI,printk(KERN_INFO "%s: Adding address %pM\n",
dev->name, cp));
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/a2065.c
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ static void lance_load_multicast (struct net_device *dev)
struct lance_private *lp = netdev_priv(dev);
volatile struct lance_init_block *ib = lp->init_block;
volatile u16 *mcast_table = (u16 *)&ib->filter;
struct dev_mc_list *dmi;
struct netdev_hw_addr *ha;
char *addrs;
u32 crc;

Expand All @@ -618,8 +618,8 @@ static void lance_load_multicast (struct net_device *dev)
ib->filter [1] = 0;

/* Add addresses */
netdev_for_each_mc_addr(dmi, dev) {
addrs = dmi->dmi_addr;
netdev_for_each_mc_addr(ha, dev) {
addrs = ha->addr;

/* multicast address? */
if (!(*addrs & 1))
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/amd8111e.c
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ list to the device.
*/
static void amd8111e_set_multicast_list(struct net_device *dev)
{
struct dev_mc_list *mc_ptr;
struct netdev_hw_addr *ha;
struct amd8111e_priv *lp = netdev_priv(dev);
u32 mc_filter[2] ;
int bit_num;
Expand Down Expand Up @@ -1408,8 +1408,8 @@ static void amd8111e_set_multicast_list(struct net_device *dev)
/* load all the multicast addresses in the logic filter */
lp->options |= OPTION_MULTICAST_ENABLE;
mc_filter[1] = mc_filter[0] = 0;
netdev_for_each_mc_addr(mc_ptr, dev) {
bit_num = (ether_crc_le(ETH_ALEN, mc_ptr->dmi_addr) >> 26) & 0x3f;
netdev_for_each_mc_addr(ha, dev) {
bit_num = (ether_crc_le(ETH_ALEN, ha->addr) >> 26) & 0x3f;
mc_filter[bit_num >> 5] |= 1 << (bit_num & 31);
}
amd8111e_writeq(*(u64*)mc_filter,lp->mmio+ LADRF);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/arm/am79c961a.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,12 @@ static void am79c961_setmulticastlist (struct net_device *dev)
} else if (dev->flags & IFF_ALLMULTI) {
memset(multi_hash, 0xff, sizeof(multi_hash));
} else {
struct dev_mc_list *dmi;
struct netdev_hw_addr *ha;

memset(multi_hash, 0x00, sizeof(multi_hash));

netdev_for_each_mc_addr(dmi, dev)
am79c961_mc_hash(dmi->dmi_addr, multi_hash);
netdev_for_each_mc_addr(ha, dev)
am79c961_mc_hash(ha->addr, multi_hash);
}

spin_lock_irqsave(&priv->chip_lock, flags);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/arm/at91_ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -556,14 +556,14 @@ static int hash_get_index(__u8 *addr)
*/
static void at91ether_sethashtable(struct net_device *dev)
{
struct dev_mc_list *curr;
struct netdev_hw_addr *ha;
unsigned long mc_filter[2];
unsigned int bitnr;

mc_filter[0] = mc_filter[1] = 0;

netdev_for_each_mc_addr(curr, dev) {
bitnr = hash_get_index(curr->dmi_addr);
netdev_for_each_mc_addr(ha, dev) {
bitnr = hash_get_index(ha->addr);
mc_filter[bitnr >> 5] |= 1 << (bitnr & 31);
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/net/arm/ixp4xx_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ static int eth_xmit(struct sk_buff *skb, struct net_device *dev)
static void eth_set_mcast_list(struct net_device *dev)
{
struct port *port = netdev_priv(dev);
struct dev_mc_list *mclist;
struct netdev_hw_addr *ha;
u8 diffs[ETH_ALEN], *addr;
int i;

Expand All @@ -748,11 +748,11 @@ static void eth_set_mcast_list(struct net_device *dev)
memset(diffs, 0, ETH_ALEN);

addr = NULL;
netdev_for_each_mc_addr(mclist, dev) {
netdev_for_each_mc_addr(ha, dev) {
if (!addr)
addr = mclist->dmi_addr; /* first MAC address */
addr = ha->addr; /* first MAC address */
for (i = 0; i < ETH_ALEN; i++)
diffs[i] |= addr[i] ^ mclist->dmi_addr[i];
diffs[i] |= addr[i] ^ ha->addr[i];
}

for (i = 0; i < ETH_ALEN; i++) {
Expand Down
10 changes: 5 additions & 5 deletions drivers/net/arm/ks8695net.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,16 @@ ks8695_init_partial_multicast(struct ks8695_priv *ksp,
{
u32 low, high;
int i;
struct dev_mc_list *dmi;
struct netdev_hw_addr *ha;

i = 0;
netdev_for_each_mc_addr(dmi, ndev) {
netdev_for_each_mc_addr(ha, ndev) {
/* Ran out of space in chip? */
BUG_ON(i == KS8695_NR_ADDRESSES);

low = (dmi->dmi_addr[2] << 24) | (dmi->dmi_addr[3] << 16) |
(dmi->dmi_addr[4] << 8) | (dmi->dmi_addr[5]);
high = (dmi->dmi_addr[0] << 8) | (dmi->dmi_addr[1]);
low = (ha->addr[2] << 24) | (ha->addr[3] << 16) |
(ha->addr[4] << 8) | (ha->addr[5]);
high = (ha->addr[0] << 8) | (ha->addr[1]);

ks8695_writereg(ksp, KS8695_AAL_(i), low);
ks8695_writereg(ksp, KS8695_AAH_(i), AAH_E | high);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/at1700.c
Original file line number Diff line number Diff line change
Expand Up @@ -848,12 +848,12 @@ set_rx_mode(struct net_device *dev)
memset(mc_filter, 0x00, sizeof(mc_filter));
outb(1, ioaddr + RX_MODE); /* Ignore almost all multicasts. */
} else {
struct dev_mc_list *mclist;
struct netdev_hw_addr *ha;

memset(mc_filter, 0, sizeof(mc_filter));
netdev_for_each_mc_addr(mclist, dev) {
netdev_for_each_mc_addr(ha, dev) {
unsigned int bit =
ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26;
ether_crc_le(ETH_ALEN, ha->addr) >> 26;
mc_filter[bit >> 3] |= (1 << bit);
}
outb(0x02, ioaddr + RX_MODE); /* Use normal mode. */
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/atl1c/atl1c_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ static void atl1c_set_multi(struct net_device *netdev)
{
struct atl1c_adapter *adapter = netdev_priv(netdev);
struct atl1c_hw *hw = &adapter->hw;
struct dev_mc_list *mc_ptr;
struct netdev_hw_addr *ha;
u32 mac_ctrl_data;
u32 hash_value;

Expand All @@ -377,8 +377,8 @@ static void atl1c_set_multi(struct net_device *netdev)
AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0);

/* comoute mc addresses' hash value ,and put it into hash table */
netdev_for_each_mc_addr(mc_ptr, netdev) {
hash_value = atl1c_hash_mc_addr(hw, mc_ptr->dmi_addr);
netdev_for_each_mc_addr(ha, netdev) {
hash_value = atl1c_hash_mc_addr(hw, ha->addr);
atl1c_hash_set(hw, hash_value);
}
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/atl1e/atl1e_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static void atl1e_set_multi(struct net_device *netdev)
{
struct atl1e_adapter *adapter = netdev_priv(netdev);
struct atl1e_hw *hw = &adapter->hw;
struct dev_mc_list *mc_ptr;
struct netdev_hw_addr *ha;
u32 mac_ctrl_data = 0;
u32 hash_value;

Expand All @@ -307,8 +307,8 @@ static void atl1e_set_multi(struct net_device *netdev)
AT_WRITE_REG_ARRAY(hw, REG_RX_HASH_TABLE, 1, 0);

/* comoute mc addresses' hash value ,and put it into hash table */
netdev_for_each_mc_addr(mc_ptr, netdev) {
hash_value = atl1e_hash_mc_addr(hw, mc_ptr->dmi_addr);
netdev_for_each_mc_addr(ha, netdev) {
hash_value = atl1e_hash_mc_addr(hw, ha->addr);
atl1e_hash_set(hw, hash_value);
}
}
Expand Down
Loading

0 comments on commit 22bedad

Please sign in to comment.