Skip to content

Commit

Permalink
net: convert multiple drivers to use netdev_for_each_mc_addr, part4
Browse files Browse the repository at this point in the history
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Feb 22, 2010
1 parent 7a81e9f commit 48e2f18
Show file tree
Hide file tree
Showing 29 changed files with 69 additions and 98 deletions.
5 changes: 2 additions & 3 deletions drivers/net/davinci_emac.c
Original file line number Diff line number Diff line change
Expand Up @@ -965,10 +965,9 @@ static void emac_dev_mcast_set(struct net_device *ndev)
mbp_enable = (mbp_enable | EMAC_MBP_RXMCAST);
emac_add_mcast(priv, EMAC_ALL_MULTI_CLR, NULL);
/* program multicast address list into EMAC hardware */
for (mc_ptr = ndev->mc_list; mc_ptr;
mc_ptr = mc_ptr->next) {
netdev_for_each_mc_addr(mc_ptr, ndev) {
emac_add_mcast(priv, EMAC_MULTICAST_ADD,
(u8 *)mc_ptr->dmi_addr);
(u8 *) mc_ptr->dmi_addr);
}
} else {
mbp_enable = (mbp_enable & ~EMAC_MBP_RXMCAST);
Expand Down
10 changes: 7 additions & 3 deletions drivers/net/e100.c
Original file line number Diff line number Diff line change
Expand Up @@ -1537,14 +1537,18 @@ static int e100_hw_init(struct nic *nic)
static void e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
{
struct net_device *netdev = nic->netdev;
struct dev_mc_list *list = netdev->mc_list;
struct dev_mc_list *list;
u16 i, count = min(netdev_mc_count(netdev), E100_MAX_MULTICAST_ADDRS);

cb->command = cpu_to_le16(cb_multi);
cb->u.multi.count = cpu_to_le16(count * ETH_ALEN);
for (i = 0; list && i < count; i++, list = list->next)
memcpy(&cb->u.multi.addr[i*ETH_ALEN], &list->dmi_addr,
i = 0;
netdev_for_each_mc_addr(list, netdev) {
if (i == count)
break;
memcpy(&cb->u.multi.addr[i++ * ETH_ALEN], &list->dmi_addr,
ETH_ALEN);
}
}

static void e100_set_multicast_list(struct net_device *netdev)
Expand Down
8 changes: 3 additions & 5 deletions drivers/net/eepro.c
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ set_multicast_list(struct net_device *dev)
struct eepro_local *lp = netdev_priv(dev);
short ioaddr = dev->base_addr;
unsigned short mode;
struct dev_mc_list *dmi=dev->mc_list;
struct dev_mc_list *dmi;
int mc_count = netdev_mc_count(dev);

if (dev->flags&(IFF_ALLMULTI|IFF_PROMISC) || mc_count > 63)
Expand Down Expand Up @@ -1332,10 +1332,8 @@ set_multicast_list(struct net_device *dev)
outw(0, ioaddr + IO_PORT);
outw(6 * (mc_count + 1), ioaddr + IO_PORT);

for (i = 0; i < mc_count; i++)
{
eaddrs=(unsigned short *)dmi->dmi_addr;
dmi=dmi->next;
netdev_for_each_mc_addr(dmi, dev) {
eaddrs = (unsigned short *) dmi->dmi_addr;
outw(*eaddrs++, ioaddr + IO_PORT);
outw(*eaddrs++, ioaddr + IO_PORT);
outw(*eaddrs++, ioaddr + IO_PORT);
Expand Down
16 changes: 6 additions & 10 deletions drivers/net/eexpress.c
Original file line number Diff line number Diff line change
Expand Up @@ -1588,23 +1588,19 @@ static void eexp_setup_filter(struct net_device *dev)

outw(CONF_NR_MULTICAST & ~31, ioaddr+SM_PTR);
outw(6*count, ioaddr+SHADOW(CONF_NR_MULTICAST));
for (i = 0, dmi = dev->mc_list; i < count; i++, dmi = dmi->next) {
unsigned short *data;
if (!dmi) {
printk(KERN_INFO "%s: too few multicast addresses\n", dev->name);
i = 0;
netdev_for_each_mc_addr(dmi, dev) {
unsigned short *data = (unsigned short *) dmi->dmi_addr;

if (i == count)
break;
}
if (dmi->dmi_addrlen != ETH_ALEN) {
printk(KERN_INFO "%s: invalid multicast address length given.\n", dev->name);
continue;
}
data = (unsigned short *)dmi->dmi_addr;
outw((CONF_MULTICAST+(6*i)) & ~31, ioaddr+SM_PTR);
outw(data[0], ioaddr+SHADOW(CONF_MULTICAST+(6*i)));
outw((CONF_MULTICAST+(6*i)+2) & ~31, ioaddr+SM_PTR);
outw(data[1], ioaddr+SHADOW(CONF_MULTICAST+(6*i)+2));
outw((CONF_MULTICAST+(6*i)+4) & ~31, ioaddr+SM_PTR);
outw(data[2], ioaddr+SHADOW(CONF_MULTICAST+(6*i)+4));
i++;
}
}

Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ehea/ehea_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1967,7 +1967,7 @@ static void ehea_set_multicast_list(struct net_device *dev)
{
struct ehea_port *port = netdev_priv(dev);
struct dev_mc_list *k_mcl_entry;
int ret, i;
int ret;

if (dev->flags & IFF_PROMISC) {
ehea_promiscuous(dev, 1);
Expand Down Expand Up @@ -1997,8 +1997,7 @@ static void ehea_set_multicast_list(struct net_device *dev)
goto out;
}

for (i = 0, k_mcl_entry = dev->mc_list; i < netdev_mc_count(dev); i++,
k_mcl_entry = k_mcl_entry->next)
netdev_for_each_mc_addr(k_mcl_entry, dev)
ehea_add_multicast_entry(port, k_mcl_entry->dmi_addr);

}
Expand Down
10 changes: 6 additions & 4 deletions drivers/net/enic/enic_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ static int enic_set_mac_addr(struct net_device *netdev, char *addr)
static void enic_set_multicast_list(struct net_device *netdev)
{
struct enic *enic = netdev_priv(netdev);
struct dev_mc_list *list = netdev->mc_list;
struct dev_mc_list *list;
int directed = 1;
int multicast = (netdev->flags & IFF_MULTICAST) ? 1 : 0;
int broadcast = (netdev->flags & IFF_BROADCAST) ? 1 : 0;
Expand Down Expand Up @@ -851,9 +851,11 @@ static void enic_set_multicast_list(struct net_device *netdev)
* look for changes to add/del.
*/

for (i = 0; list && i < mc_count; i++) {
memcpy(mc_addr[i], list->dmi_addr, ETH_ALEN);
list = list->next;
i = 0;
netdev_for_each_mc_addr(list, netdev) {
if (i == mc_count)
break;
memcpy(mc_addr[i++], list->dmi_addr, ETH_ALEN);
}

for (i = 0; i < enic->mc_count; i++) {
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/epic100.c
Original file line number Diff line number Diff line change
Expand Up @@ -1403,8 +1403,7 @@ static void set_rx_mode(struct net_device *dev)
struct dev_mc_list *mclist;

memset(mc_filter, 0, sizeof(mc_filter));
for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
i++, mclist = mclist->next) {
netdev_for_each_mc_addr(mclist, dev) {
unsigned int bit_nr =
ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x3f;
mc_filter[bit_nr >> 3] |= (1 << bit_nr);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ethoc.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ static void ethoc_set_multicast_list(struct net_device *dev)
{
struct ethoc *priv = netdev_priv(dev);
u32 mode = ethoc_read(priv, MODER);
struct dev_mc_list *mc = NULL;
struct dev_mc_list *mc;
u32 hash[2] = { 0, 0 };

/* set loopback mode if requested */
Expand Down Expand Up @@ -783,8 +783,8 @@ static void ethoc_set_multicast_list(struct net_device *dev)
hash[0] = 0xffffffff;
hash[1] = 0xffffffff;
} else {
for (mc = dev->mc_list; mc; mc = mc->next) {
u32 crc = ether_crc(mc->dmi_addrlen, mc->dmi_addr);
netdev_for_each_mc_addr(mc, dev) {
u32 crc = ether_crc(ETH_ALEN, mc->dmi_addr);
int bit = (crc >> 26) & 0x3f;
hash[bit >> 5] |= 1 << (bit & 0x1f);
}
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ewrk3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ static void set_multicast_list(struct net_device *dev)
static void SetMulticastFilter(struct net_device *dev)
{
struct ewrk3_private *lp = netdev_priv(dev);
struct dev_mc_list *dmi = dev->mc_list;
struct dev_mc_list *dmi;
u_long iobase = dev->base_addr;
int i;
char *addrs, bit, byte;
Expand Down Expand Up @@ -1213,9 +1213,8 @@ static void SetMulticastFilter(struct net_device *dev)
}

/* Update table */
for (i = 0; i < netdev_mc_count(dev); i++) { /* for each address in the list */
netdev_for_each_mc_addr(dmi, dev) {
addrs = dmi->dmi_addr;
dmi = dmi->next;
if ((*addrs & 0x01) == 1) { /* multicast address? */
crc = ether_crc_le(ETH_ALEN, addrs);
hashcode = crc & ((1 << 9) - 1); /* hashcode is 9 LSb of CRC */
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/fealnx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1793,11 +1793,9 @@ static void __set_rx_mode(struct net_device *dev)
rx_mode = CR_W_AB | CR_W_AM;
} else {
struct dev_mc_list *mclist;
int i;

memset(mc_filter, 0, sizeof(mc_filter));
for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
i++, mclist = mclist->next) {
netdev_for_each_mc_addr(mclist, dev) {
unsigned int bit;
bit = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26) ^ 0x3F;
mc_filter[bit >> 5] |= (1 << bit);
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/fec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ static void set_multicast_list(struct net_device *dev)
{
struct fec_enet_private *fep = netdev_priv(dev);
struct dev_mc_list *dmi;
unsigned int i, j, bit, data, crc, tmp;
unsigned int i, bit, data, crc, tmp;
unsigned char hash;

if (dev->flags & IFF_PROMISC) {
Expand Down Expand Up @@ -1604,9 +1604,7 @@ static void set_multicast_list(struct net_device *dev)
writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);

dmi = dev->mc_list;

for (j = 0; j < netdev_mc_count(dev); j++, dmi = dmi->next) {
netdev_for_each_mc_addr(dmi, dev) {
/* Only support group multicast for now */
if (!(dmi->dmi_addr[0] & 1))
continue;
Expand Down
5 changes: 1 addition & 4 deletions drivers/net/fec_mpc52xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -575,19 +575,16 @@ static void mpc52xx_fec_set_multicast_list(struct net_device *dev)
out_be32(&fec->gaddr2, 0xffffffff);
} else {
u32 crc;
int i;
struct dev_mc_list *dmi;
u32 gaddr1 = 0x00000000;
u32 gaddr2 = 0x00000000;

dmi = dev->mc_list;
for (i=0; i<netdev_mc_count(dev); i++) {
netdev_for_each_mc_addr(dmi, dev) {
crc = ether_crc_le(6, dmi->dmi_addr) >> 26;
if (crc >= 32)
gaddr1 |= 1 << (crc-32);
else
gaddr2 |= 1 << crc;
dmi = dmi->next;
}
out_be32(&fec->gaddr1, gaddr1);
out_be32(&fec->gaddr2, gaddr2);
Expand Down
6 changes: 2 additions & 4 deletions drivers/net/forcedeth.c
Original file line number Diff line number Diff line change
Expand Up @@ -3095,7 +3095,7 @@ static void nv_set_multicast(struct net_device *dev)
} else {
pff |= NVREG_PFF_MYADDR;

if (dev->flags & IFF_ALLMULTI || dev->mc_list) {
if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev)) {
u32 alwaysOff[2];
u32 alwaysOn[2];

Expand All @@ -3105,16 +3105,14 @@ static void nv_set_multicast(struct net_device *dev)
} else {
struct dev_mc_list *walk;

walk = dev->mc_list;
while (walk != NULL) {
netdev_for_each_mc_addr(walk, dev) {
u32 a, b;
a = le32_to_cpu(*(__le32 *) walk->dmi_addr);
b = le16_to_cpu(*(__le16 *) (&walk->dmi_addr[4]));
alwaysOn[0] &= a;
alwaysOff[0] &= ~a;
alwaysOn[1] &= b;
alwaysOff[1] &= ~b;
walk = walk->next;
}
}
addr[0] = alwaysOn[0];
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/fs_enet/mac-fcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ static void set_multicast_list(struct net_device *dev)

if ((dev->flags & IFF_PROMISC) == 0) {
set_multicast_start(dev);
for (pmc = dev->mc_list; pmc != NULL; pmc = pmc->next)
netdev_for_each_mc_addr(pmc, dev)
set_multicast_one(dev, pmc->dmi_addr);
set_multicast_finish(dev);
} else
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/fs_enet/mac-fec.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ static void set_multicast_list(struct net_device *dev)

if ((dev->flags & IFF_PROMISC) == 0) {
set_multicast_start(dev);
for (pmc = dev->mc_list; pmc != NULL; pmc = pmc->next)
netdev_for_each_mc_addr(pmc, dev)
set_multicast_one(dev, pmc->dmi_addr);
set_multicast_finish(dev);
} else
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/fs_enet/mac-scc.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static void set_multicast_list(struct net_device *dev)

if ((dev->flags & IFF_PROMISC) == 0) {
set_multicast_start(dev);
for (pmc = dev->mc_list; pmc != NULL; pmc = pmc->next)
netdev_for_each_mc_addr(pmc, dev)
set_multicast_one(dev, pmc->dmi_addr);
set_multicast_finish(dev);
} else
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/gianfar.c
Original file line number Diff line number Diff line change
Expand Up @@ -2867,7 +2867,7 @@ static void gfar_set_multi(struct net_device *dev)
return;

/* Parse the list, and set the appropriate bits */
for(mc_ptr = dev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) {
netdev_for_each_mc_addr(mc_ptr, dev) {
if (idx < em_num) {
gfar_set_mac_for_addr(dev, idx,
mc_ptr->dmi_addr);
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/hamachi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1859,12 +1859,13 @@ static void set_rx_mode(struct net_device *dev)
writew(0x000B, ioaddr + AddrMode);
} else if (!netdev_mc_empty(dev)) { /* Must use the CAM filter. */
struct dev_mc_list *mclist;
int i;
for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
i++, mclist = mclist->next) {
int i = 0;

netdev_for_each_mc_addr(mclist, dev) {
writel(*(u32*)(mclist->dmi_addr), ioaddr + 0x100 + i*8);
writel(0x20000 | (*(u16*)&mclist->dmi_addr[4]),
ioaddr + 0x104 + i*8);
i++;
}
/* Clear remaining entries. */
for (; i < 64; i++)
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/hp100.c
Original file line number Diff line number Diff line change
Expand Up @@ -2098,7 +2098,7 @@ static void hp100_set_multicast_list(struct net_device *dev)
/* set hash filter to receive all multicast packets */
memset(&lp->hash_bytes, 0xff, 8);
} else {
int i, j, idx;
int i, idx;
u_char *addrs;
struct dev_mc_list *dmi;

Expand All @@ -2107,14 +2107,14 @@ static void hp100_set_multicast_list(struct net_device *dev)
printk("hp100: %s: computing hash filter - mc_count = %i\n",
dev->name, netdev_mc_count(dev));
#endif
for (i = 0, dmi = dev->mc_list; i < netdev_mc_count(dev); i++, dmi = dmi->next) {
netdev_for_each_mc_addr(dmi, dev) {
addrs = dmi->dmi_addr;
if ((*addrs & 0x01) == 0x01) { /* multicast address? */
#ifdef HP100_DEBUG
printk("hp100: %s: multicast = %pM, ",
dev->name, addrs);
#endif
for (j = idx = 0; j < 6; j++) {
for (i = idx = 0; i < 6; i++) {
idx ^= *addrs++ & 0x3f;
printk(":%02x:", idx);
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ibm_newemac/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ static void emac_hash_mc(struct emac_instance *dev)

memset(gaht_temp, 0, sizeof (gaht_temp));

for (dmi = dev->ndev->mc_list; dmi; dmi = dmi->next) {
netdev_for_each_mc_addr(dmi, dev->ndev) {
int slot, reg, mask;
DBG2(dev, "mc %pM" NL, dmi->dmi_addr);

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ibmlana.c
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ static void InitBoard(struct net_device *dev)
/* start putting the multicast addresses into the CAM list. Stop if
it is full. */

for (mcptr = dev->mc_list; mcptr != NULL; mcptr = mcptr->next) {
netdev_for_each_mc_addr(mcptr, dev) {
putcam(cams, &camcnt, mcptr->dmi_addr);
if (camcnt == 16)
break;
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/ibmveth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1072,8 +1072,7 @@ static void ibmveth_set_multicast_list(struct net_device *netdev)
ibmveth_error_printk("h_multicast_ctrl rc=%ld when entering promisc mode\n", lpar_rc);
}
} else {
struct dev_mc_list *mclist = netdev->mc_list;
int i;
struct dev_mc_list *mclist;
/* clear the filter table & disable filtering */
lpar_rc = h_multicast_ctrl(adapter->vdev->unit_address,
IbmVethMcastEnableRecv |
Expand All @@ -1084,7 +1083,7 @@ static void ibmveth_set_multicast_list(struct net_device *netdev)
ibmveth_error_printk("h_multicast_ctrl rc=%ld when attempting to clear filter table\n", lpar_rc);
}
/* add the addresses to the filter table */
for(i = 0; i < netdev_mc_count(netdev); ++i, mclist = mclist->next) {
netdev_for_each_mc_addr(mclist, netdev) {
// add the multicast address to the filter table
unsigned long mcast_addr = 0;
memcpy(((char *)&mcast_addr)+2, mclist->dmi_addr, 6);
Expand Down
Loading

0 comments on commit 48e2f18

Please sign in to comment.