Skip to content

Commit

Permalink
net: convert multiple drivers to use netdev_for_each_mc_addr, part2
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 18, 2010
1 parent 2a0d18f commit 5508590
Show file tree
Hide file tree
Showing 23 changed files with 55 additions and 87 deletions.
5 changes: 3 additions & 2 deletions drivers/net/s2io.c
Original file line number Diff line number Diff line change
Expand Up @@ -5092,8 +5092,8 @@ static void s2io_set_multicast(struct net_device *dev)
}

/* Create the new Rx filter list and update the same in H/W. */
for (i = 0, mclist = dev->mc_list; i < netdev_mc_count(dev);
i++, mclist = mclist->next) {
i = 0;
netdev_for_each_mc_addr(mclist, dev) {
memcpy(sp->usr_addrs[i].addr, mclist->dmi_addr,
ETH_ALEN);
mac_addr = 0;
Expand Down Expand Up @@ -5121,6 +5121,7 @@ static void s2io_set_multicast(struct net_device *dev)
dev->name);
return;
}
i++;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/sb1250-mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -2161,13 +2161,13 @@ static void sbmac_setmulti(struct sbmac_softc *sc)
* XXX if the table overflows */

idx = 1; /* skip station address */
mclist = dev->mc_list;
while (mclist && (idx < MAC_ADDR_COUNT)) {
netdev_for_each_mc_addr(mclist, dev) {
if (idx == MAC_ADDR_COUNT)
break;
reg = sbmac_addr2reg(mclist->dmi_addr);
port = sc->sbm_base + R_MAC_ADDR_BASE+(idx * sizeof(uint64_t));
__raw_writeq(reg, port);
idx++;
mclist = mclist->next;
}

/*
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/sc92031.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ static void _sc92031_set_mar(struct net_device *dev)
else if (dev->flags & IFF_MULTICAST) {
struct dev_mc_list *mc_list;

for (mc_list = dev->mc_list; mc_list; mc_list = mc_list->next) {
netdev_for_each_mc_addr(mc_list, dev) {
u32 crc;
unsigned bit = 0;

Expand Down
6 changes: 2 additions & 4 deletions drivers/net/sfc/efx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1602,11 +1602,10 @@ static int efx_set_mac_address(struct net_device *net_dev, void *data)
static void efx_set_multicast_list(struct net_device *net_dev)
{
struct efx_nic *efx = netdev_priv(net_dev);
struct dev_mc_list *mc_list = net_dev->mc_list;
struct dev_mc_list *mc_list;
union efx_multicast_hash *mc_hash = &efx->multicast_hash;
u32 crc;
int bit;
int i;

efx->promiscuous = !!(net_dev->flags & IFF_PROMISC);

Expand All @@ -1615,11 +1614,10 @@ static void efx_set_multicast_list(struct net_device *net_dev)
memset(mc_hash, 0xff, sizeof(*mc_hash));
} else {
memset(mc_hash, 0x00, sizeof(*mc_hash));
for (i = 0; i < netdev_mc_count(net_dev); i++) {
netdev_for_each_mc_addr(mc_list, net_dev) {
crc = ether_crc_le(ETH_ALEN, mc_list->dmi_addr);
bit = crc & (EFX_MCAST_HASH_ENTRIES - 1);
set_bit_le(bit, mc_hash->byte);
mc_list = mc_list->next;
}

/* Broadcast packets go through the multicast hash filter.
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/sis190.c
Original file line number Diff line number Diff line change
Expand Up @@ -849,12 +849,10 @@ static void sis190_set_rx_mode(struct net_device *dev)
mc_filter[1] = mc_filter[0] = 0xffffffff;
} else {
struct dev_mc_list *mclist;
unsigned int i;

rx_mode = AcceptBroadcast | AcceptMyPhys;
mc_filter[1] = mc_filter[0] = 0;
for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
i++, mclist = mclist->next) {
netdev_for_each_mc_addr(mclist, dev) {
int bit_nr =
ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3f;
mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/sis900.c
Original file line number Diff line number Diff line change
Expand Up @@ -2300,9 +2300,8 @@ static void set_rx_mode(struct net_device *net_dev)
* packets */
struct dev_mc_list *mclist;
rx_mode = RFAAB;
for (i = 0, mclist = net_dev->mc_list;
mclist && i < netdev_mc_count(net_dev);
i++, mclist = mclist->next) {

netdev_for_each_mc_addr(mclist, net_dev) {
unsigned int bit_nr =
sis900_mcast_bitnr(mclist->dmi_addr, sis_priv->chipset_rev);
mc_filter[bit_nr >> 4] |= (1 << (bit_nr & 0xf));
Expand Down
10 changes: 3 additions & 7 deletions drivers/net/skfp/skfddi.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,8 +852,7 @@ static void skfp_ctl_set_multicast_list(struct net_device *dev)
static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev)
{
struct s_smc *smc = netdev_priv(dev);
struct dev_mc_list *dmi; /* ptr to multicast addr entry */
int i;
struct dev_mc_list *dmi;

/* Enable promiscuous mode, if necessary */
if (dev->flags & IFF_PROMISC) {
Expand All @@ -877,17 +876,14 @@ static void skfp_ctl_set_multicast_list_wo_lock(struct net_device *dev)
/* use exact filtering */

// point to first multicast addr
dmi = dev->mc_list;

for (i = 0; i < netdev_mc_count(dev); i++) {
netdev_for_each_mc_addr(dmi, dev) {
mac_add_multicast(smc,
(struct fddi_addr *)dmi->dmi_addr,
1);

pr_debug(KERN_INFO "ENABLE MC ADDRESS: %pMF\n",
dmi->dmi_addr);
dmi = dmi->next;
} // for
}

} else { // more MC addresses than HW supports

Expand Down
10 changes: 4 additions & 6 deletions drivers/net/skge.c
Original file line number Diff line number Diff line change
Expand Up @@ -2917,8 +2917,7 @@ static void genesis_set_multicast(struct net_device *dev)
struct skge_port *skge = netdev_priv(dev);
struct skge_hw *hw = skge->hw;
int port = skge->port;
int i, count = netdev_mc_count(dev);
struct dev_mc_list *list = dev->mc_list;
struct dev_mc_list *list;
u32 mode;
u8 filter[8];

Expand All @@ -2938,7 +2937,7 @@ static void genesis_set_multicast(struct net_device *dev)
skge->flow_status == FLOW_STAT_SYMMETRIC)
genesis_add_filter(filter, pause_mc_addr);

for (i = 0; list && i < count; i++, list = list->next)
netdev_for_each_mc_addr(list, dev)
genesis_add_filter(filter, list->dmi_addr);
}

Expand All @@ -2957,7 +2956,7 @@ static void yukon_set_multicast(struct net_device *dev)
struct skge_port *skge = netdev_priv(dev);
struct skge_hw *hw = skge->hw;
int port = skge->port;
struct dev_mc_list *list = dev->mc_list;
struct dev_mc_list *list;
int rx_pause = (skge->flow_status == FLOW_STAT_REM_SEND ||
skge->flow_status == FLOW_STAT_SYMMETRIC);
u16 reg;
Expand All @@ -2975,13 +2974,12 @@ static void yukon_set_multicast(struct net_device *dev)
else if (netdev_mc_empty(dev) && !rx_pause)/* no multicast */
reg &= ~GM_RXCR_MCF_ENA;
else {
int i;
reg |= GM_RXCR_MCF_ENA;

if (rx_pause)
yukon_add_filter(filter, pause_mc_addr);

for (i = 0; list && i < netdev_mc_count(dev); i++, list = list->next)
netdev_for_each_mc_addr(list, dev)
yukon_add_filter(filter, list->dmi_addr);
}

Expand Down
5 changes: 2 additions & 3 deletions drivers/net/sky2.c
Original file line number Diff line number Diff line change
Expand Up @@ -3621,7 +3621,7 @@ static void sky2_set_multicast(struct net_device *dev)
struct sky2_port *sky2 = netdev_priv(dev);
struct sky2_hw *hw = sky2->hw;
unsigned port = sky2->port;
struct dev_mc_list *list = dev->mc_list;
struct dev_mc_list *list;
u16 reg;
u8 filter[8];
int rx_pause;
Expand All @@ -3640,13 +3640,12 @@ static void sky2_set_multicast(struct net_device *dev)
else if (netdev_mc_empty(dev) && !rx_pause)
reg &= ~GM_RXCR_MCF_ENA;
else {
int i;
reg |= GM_RXCR_MCF_ENA;

if (rx_pause)
sky2_add_filter(filter, pause_mc_addr);

for (i = 0; list && i < netdev_mc_count(dev); i++, list = list->next)
netdev_for_each_mc_addr(list, dev)
sky2_add_filter(filter, list->dmi_addr);
}

Expand Down
5 changes: 2 additions & 3 deletions drivers/net/smsc9420.c
Original file line number Diff line number Diff line change
Expand Up @@ -1063,11 +1063,11 @@ static void smsc9420_set_multicast_list(struct net_device *dev)
mac_cr |= MAC_CR_MCPAS_;
mac_cr &= (~MAC_CR_HPFILT_);
} else if (!netdev_mc_empty(dev)) {
struct dev_mc_list *mc_list = dev->mc_list;
struct dev_mc_list *mc_list;
u32 hash_lo = 0, hash_hi = 0;

smsc_dbg(HW, "Multicast filter enabled");
while (mc_list) {
netdev_for_each_mc_addr(mc_list, dev) {
u32 bit_num = smsc9420_hash(mc_list->dmi_addr);
u32 mask = 1 << (bit_num & 0x1F);

Expand All @@ -1076,7 +1076,6 @@ static void smsc9420_set_multicast_list(struct net_device *dev)
else
hash_lo |= mask;

mc_list = mc_list->next;
}
smsc9420_reg_write(pd, HASHH, hash_hi);
smsc9420_reg_write(pd, HASHL, hash_lo);
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ static void sonic_multicast_list(struct net_device *dev)
{
struct sonic_local *lp = netdev_priv(dev);
unsigned int rcr;
struct dev_mc_list *dmi = dev->mc_list;
struct dev_mc_list *dmi;
unsigned char *addr;
int i;

Expand All @@ -549,13 +549,14 @@ static void sonic_multicast_list(struct net_device *dev)
printk("sonic_multicast_list: mc_count %d\n",
netdev_mc_count(dev));
sonic_set_cam_enable(dev, 1); /* always enable our own address */
for (i = 1; i <= netdev_mc_count(dev); i++) {
i = 1;
netdev_for_each_mc_addr(dmi, dev) {
addr = dmi->dmi_addr;
dmi = dmi->next;
sonic_cda_put(dev, i, SONIC_CD_CAP0, addr[1] << 8 | addr[0]);
sonic_cda_put(dev, i, SONIC_CD_CAP1, addr[3] << 8 | addr[2]);
sonic_cda_put(dev, i, SONIC_CD_CAP2, addr[5] << 8 | addr[4]);
sonic_set_cam_enable(dev, sonic_get_cam_enable(dev) | (1 << i));
i++;
}
SONIC_WRITE(SONIC_CDC, 16);
/* issue Load CAM command */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/spider_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ spider_net_set_multi(struct net_device *netdev)
hash = spider_net_get_multicast_hash(netdev, netdev->broadcast); */
set_bit(0xfd, bitmask);

for (mc = netdev->mc_list; mc; mc = mc->next) {
netdev_for_each_mc_addr(mc, netdev) {
hash = spider_net_get_multicast_hash(netdev, mc->dmi_addr);
set_bit(hash, bitmask);
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/starfire.c
Original file line number Diff line number Diff line change
Expand Up @@ -1804,14 +1804,14 @@ static void set_rx_mode(struct net_device *dev)
/* Use the 16 element perfect filter, skip first two entries. */
void __iomem *filter_addr = ioaddr + PerfFilterTable + 2 * 16;
__be16 *eaddrs;
for (i = 2, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev) + 2;
i++, mclist = mclist->next) {
netdev_for_each_mc_addr(mclist, dev) {
eaddrs = (__be16 *)mclist->dmi_addr;
writew(be16_to_cpu(eaddrs[2]), filter_addr); filter_addr += 4;
writew(be16_to_cpu(eaddrs[1]), filter_addr); filter_addr += 4;
writew(be16_to_cpu(eaddrs[0]), filter_addr); filter_addr += 8;
}
eaddrs = (__be16 *)dev->dev_addr;
i = netdev_mc_count(dev) + 2;
while (i++ < 16) {
writew(be16_to_cpu(eaddrs[0]), filter_addr); filter_addr += 4;
writew(be16_to_cpu(eaddrs[1]), filter_addr); filter_addr += 4;
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/stmmac/dwmac100.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ static void dwmac100_set_filter(struct net_device *dev)
value &= ~(MAC_CONTROL_PM | MAC_CONTROL_PR | MAC_CONTROL_IF |
MAC_CONTROL_HO | MAC_CONTROL_HP);
} else {
int i;
u32 mc_filter[2];
struct dev_mc_list *mclist;

Expand All @@ -326,8 +325,7 @@ static void dwmac100_set_filter(struct net_device *dev)
MAC_CONTROL_IF | MAC_CONTROL_HO);

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) {
/* The upper 6 bits of the calculated CRC are used to
* index the contens of the hash table */
int bit_nr =
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/stmmac/dwmac1000_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,14 @@ static void dwmac1000_set_filter(struct net_device *dev)
writel(0xffffffff, ioaddr + GMAC_HASH_HIGH);
writel(0xffffffff, ioaddr + GMAC_HASH_LOW);
} else if (!netdev_mc_empty(dev)) {
int i;
u32 mc_filter[2];
struct dev_mc_list *mclist;

/* Hash filter for multicast */
value = GMAC_FRAME_FILTER_HMC;

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) {
/* The upper 6 bits of the calculated CRC are used to
index the contens of the hash table */
int bit_nr =
Expand Down
8 changes: 5 additions & 3 deletions drivers/net/sun3_82586.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,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=dev->mc_list;
struct dev_mc_list *dmi;
int num_addrs=netdev_mc_count(dev);

ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));
Expand Down Expand Up @@ -536,8 +536,10 @@ static int init586(struct net_device *dev)
mc_cmd->cmd_link = 0xffff;
mc_cmd->mc_cnt = swab16(num_addrs * 6);

for(i=0;i<num_addrs;i++,dmi=dmi->next)
memcpy((char *) mc_cmd->mc_list[i], dmi->dmi_addr,6);
i = 0;
netdev_for_each_mc_addr(dmi, dev)
memcpy((char *) mc_cmd->mc_list[i++],
dmi->dmi_addr, ETH_ALEN);

p->scb->cbl_offset = make16(mc_cmd);
p->scb->cmd_cuc = CUC_START;
Expand Down
5 changes: 2 additions & 3 deletions drivers/net/sunbmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ static void bigmac_set_multicast(struct net_device *dev)
{
struct bigmac *bp = netdev_priv(dev);
void __iomem *bregs = bp->bregs;
struct dev_mc_list *dmi = dev->mc_list;
struct dev_mc_list *dmi;
char *addrs;
int i;
u32 tmp, crc;
Expand Down Expand Up @@ -1028,9 +1028,8 @@ static void bigmac_set_multicast(struct net_device *dev)
for (i = 0; i < 4; i++)
hash_table[i] = 0;

for (i = 0; i < netdev_mc_count(dev); i++) {
netdev_for_each_mc_addr(dmi, dev) {
addrs = dmi->dmi_addr;
dmi = dmi->next;

if (!(*addrs & 1))
continue;
Expand Down
3 changes: 1 addition & 2 deletions drivers/net/sundance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1528,8 +1528,7 @@ static void set_rx_mode(struct net_device *dev)
int index;
int crc;
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) {
crc = ether_crc_le (ETH_ALEN, mclist->dmi_addr);
for (index=0, bit=0; bit < 6; bit++, crc <<= 1)
if (crc & 0x80000000) index |= 1 << bit;
Expand Down
10 changes: 3 additions & 7 deletions drivers/net/sungem.c
Original file line number Diff line number Diff line change
Expand Up @@ -1846,17 +1846,13 @@ static u32 gem_setup_multicast(struct gem *gp)
} else {
u16 hash_table[16];
u32 crc;
struct dev_mc_list *dmi = gp->dev->mc_list;
struct dev_mc_list *dmi;
int i;

for (i = 0; i < 16; i++)
hash_table[i] = 0;

for (i = 0; i < netdev_mc_count(gp->dev); i++) {
memset(hash_table, 0, sizeof(hash_table));
netdev_for_each_mc_addr(dmi, gp->dev) {
char *addrs = dmi->dmi_addr;

dmi = dmi->next;

if (!(*addrs & 1))
continue;

Expand Down
Loading

0 comments on commit 5508590

Please sign in to comment.