Skip to content

Commit

Permalink
net: use netdev_mc_count and netdev_mc_empty when appropriate
Browse files Browse the repository at this point in the history
This patch replaces dev->mc_count in all drivers (hopefully I didn't miss
anything). Used spatch and did small tweaks and conding style changes when
it was suitable.

Jirka

Signed-off-by: Jiri Pirko <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Jiri Pirko authored and davem330 committed Feb 12, 2010
1 parent 8e55742 commit 4cd24ea
Show file tree
Hide file tree
Showing 173 changed files with 440 additions and 401 deletions.
2 changes: 1 addition & 1 deletion arch/xtensa/platforms/iss/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,7 @@ static void iss_net_set_multicast_list(struct net_device *dev)
#if 0
if (dev->flags & IFF_PROMISC)
return;
else if (dev->mc_count)
else if (!netdev_mc_empty(dev))
dev->flags |= IFF_ALLMULTI;
else
dev->flags &= ~IFF_ALLMULTI;
Expand Down
2 changes: 1 addition & 1 deletion drivers/infiniband/hw/nes/nes_nic.c
Original file line number Diff line number Diff line change
Expand Up @@ -862,7 +862,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
}

nes_debug(NES_DBG_NIC_RX, "Number of MC entries = %d, Promiscous = %d, All Multicast = %d.\n",
netdev->mc_count, !!(netdev->flags & IFF_PROMISC),
netdev_mc_count(netdev), !!(netdev->flags & IFF_PROMISC),
!!(netdev->flags & IFF_ALLMULTI));
if (!mc_all_on) {
multicast_addr = netdev->mc_list;
Expand Down
7 changes: 3 additions & 4 deletions drivers/media/dvb/dvb-core/dvb_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1138,18 +1138,18 @@ static void wq_set_multicast_list (struct work_struct *work)
} else if ((dev->flags & IFF_ALLMULTI)) {
dprintk("%s: allmulti mode\n", dev->name);
priv->rx_mode = RX_MODE_ALL_MULTI;
} else if (dev->mc_count) {
} else if (!netdev_mc_empty(dev)) {
int mci;
struct dev_mc_list *mc;

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

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

for (mci = 0, mc=dev->mc_list;
mci < dev->mc_count;
mci < netdev_mc_count(dev);
mc = mc->next, mci++) {
dvb_set_mc_filter(dev, mc);
}
Expand Down Expand Up @@ -1236,7 +1236,6 @@ static void dvb_net_setup(struct net_device *dev)
dev->header_ops = &dvb_header_ops;
dev->netdev_ops = &dvb_netdev_ops;
dev->mtu = 4096;
dev->mc_count = 0;

dev->flags |= IFF_NOARP;
}
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/3c505.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,8 @@ static void elp_set_mc_list(struct net_device *dev)
/* send a "load multicast list" command to the board, max 10 addrs/cmd */
/* if num_addrs==0 the list will be cleared */
adapter->tx_pcb.command = CMD_LOAD_MULTICAST_LIST;
adapter->tx_pcb.length = 6 * dev->mc_count;
for (i = 0; i < dev->mc_count; i++) {
adapter->tx_pcb.length = 6 * netdev_mc_count(dev);
for (i = 0; i < netdev_mc_count(dev); i++) {
memcpy(adapter->tx_pcb.data.multicast[i], dmi->dmi_addr, 6);
dmi = dmi->next;
}
Expand All @@ -1244,7 +1244,7 @@ static void elp_set_mc_list(struct net_device *dev)
TIMEOUT_MSG(__LINE__);
}
}
if (dev->mc_count)
if (!netdev_mc_empty(dev))
adapter->tx_pcb.data.configure = NO_LOOPBACK | RECV_BROAD | RECV_MULTI;
else /* num_addrs == 0 */
adapter->tx_pcb.data.configure = NO_LOOPBACK | RECV_BROAD;
Expand Down
10 changes: 6 additions & 4 deletions drivers/net/3c509.c
Original file line number Diff line number Diff line change
Expand Up @@ -1111,20 +1111,22 @@ set_multicast_list(struct net_device *dev)
unsigned long flags;
struct el3_private *lp = netdev_priv(dev);
int ioaddr = dev->base_addr;
int mc_count = netdev_mc_count(dev);

if (el3_debug > 1) {
static int old;
if (old != dev->mc_count) {
old = dev->mc_count;
pr_debug("%s: Setting Rx mode to %d addresses.\n", dev->name, dev->mc_count);
if (old != mc_count) {
old = mc_count;
pr_debug("%s: Setting Rx mode to %d addresses.\n",
dev->name, mc_count);
}
}
spin_lock_irqsave(&lp->lock, flags);
if (dev->flags&IFF_PROMISC) {
outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast | RxProm,
ioaddr + EL3_CMD);
}
else if (dev->mc_count || (dev->flags&IFF_ALLMULTI)) {
else if (mc_count || (dev->flags&IFF_ALLMULTI)) {
outw(SetRxFilter | RxStation | RxMulticast | RxBroadcast, ioaddr + EL3_CMD);
}
else
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/3c523.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,7 @@ static int init586(struct net_device *dev)
volatile struct tdr_cmd_struct *tdr_cmd;
volatile struct mcsetup_cmd_struct *mc_cmd;
struct dev_mc_list *dmi = dev->mc_list;
int num_addrs = dev->mc_count;
int num_addrs = netdev_mc_count(dev);

ptr = (void *) ((char *) p->scb + sizeof(struct scb_struct));

Expand Down Expand Up @@ -771,7 +771,7 @@ static int init586(struct net_device *dev)
* Multicast setup
*/

if (dev->mc_count) {
if (num_addrs) {
/* I don't understand this: do we really need memory after the init? */
int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
if (len <= 0) {
Expand Down
11 changes: 6 additions & 5 deletions drivers/net/3c527.c
Original file line number Diff line number Diff line change
Expand Up @@ -1526,10 +1526,10 @@ static void do_mc32_set_multicast_list(struct net_device *dev, int retry)

if ((dev->flags&IFF_PROMISC) ||
(dev->flags&IFF_ALLMULTI) ||
dev->mc_count > 10)
netdev_mc_count(dev) > 10)
/* Enable promiscuous mode */
filt |= 1;
else if(dev->mc_count)
else if (!netdev_mc_empty(dev))
{
unsigned char block[62];
unsigned char *bp;
Expand All @@ -1542,16 +1542,17 @@ static void do_mc32_set_multicast_list(struct net_device *dev, int retry)
if(!lp->mc_list_valid)
{
block[1]=0;
block[0]=dev->mc_count;
block[0]=netdev_mc_count(dev);
bp=block+2;

for(i=0;i<dev->mc_count;i++)
for(i=0;i<netdev_mc_count(dev);i++)
{
memcpy(bp, dmc->dmi_addr, 6);
bp+=6;
dmc=dmc->next;
}
if(mc32_command_nowait(dev, 2, block, 2+6*dev->mc_count)==-1)
if(mc32_command_nowait(dev, 2, block,
2+6*netdev_mc_count(dev))==-1)
{
lp->mc_reload_wait = 1;
return;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/7990.c
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ static void lance_load_multicast (struct net_device *dev)
ib->filter [1] = 0;

/* Add addresses */
for (i = 0; i < dev->mc_count; i++){
for (i = 0; i < netdev_mc_count(dev); i++){
addrs = dmi->dmi_addr;
dmi = dmi->next;

Expand Down
8 changes: 4 additions & 4 deletions drivers/net/82596.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ static void set_multicast_list(struct net_device *dev)
int config = 0, cnt;

DEB(DEB_MULTI,printk(KERN_DEBUG "%s: set multicast list, %d entries, promisc %s, allmulti %s\n",
dev->name, dev->mc_count,
dev->name, netdev_mc_count(dev),
dev->flags & IFF_PROMISC ? "ON" : "OFF",
dev->flags & IFF_ALLMULTI ? "ON" : "OFF"));

Expand Down Expand Up @@ -1533,15 +1533,15 @@ static void set_multicast_list(struct net_device *dev)
i596_add_cmd(dev, &lp->cf_cmd.cmd);
}

cnt = dev->mc_count;
cnt = netdev_mc_count(dev);
if (cnt > MAX_MC_CNT)
{
cnt = MAX_MC_CNT;
printk(KERN_ERR "%s: Only %d multicast addresses supported",
dev->name, cnt);
}

if (dev->mc_count > 0) {
if (!netdev_mc_empty(dev)) {
struct dev_mc_list *dmi;
unsigned char *cp;
struct mc_cmd *cmd;
Expand All @@ -1550,7 +1550,7 @@ static void set_multicast_list(struct net_device *dev)
return;
cmd = &lp->mc_cmd;
cmd->cmd.command = CmdMulticastList;
cmd->mc_cnt = dev->mc_count * 6;
cmd->mc_cnt = netdev_mc_count(dev) * 6;
cp = cmd->mc_addrs;
for (dmi = dev->mc_list; cnt && dmi != NULL; dmi = dmi->next, cnt--, cp += 6) {
memcpy(cp, dmi->dmi_addr, 6);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/a2065.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ static void lance_load_multicast (struct net_device *dev)
ib->filter [1] = 0;

/* Add addresses */
for (i = 0; i < dev->mc_count; i++){
for (i = 0; i < netdev_mc_count(dev); i++){
addrs = dmi->dmi_addr;
dmi = dmi->next;

Expand Down
2 changes: 1 addition & 1 deletion drivers/net/acenic.c
Original file line number Diff line number Diff line change
Expand Up @@ -2845,7 +2845,7 @@ static void ace_set_multicast_list(struct net_device *dev)
* set the entire multicast list at a time and keeping track of
* it here is going to be messy.
*/
if ((dev->mc_count) && !(ap->mcast_all)) {
if (!netdev_mc_empty(dev) && !ap->mcast_all) {
cmd.evt = C_SET_MULTICAST_MODE;
cmd.code = C_C_MCAST_ENABLE;
cmd.idx = 0;
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/amd8111e.c
Original file line number Diff line number Diff line change
Expand Up @@ -1387,15 +1387,16 @@ static void amd8111e_set_multicast_list(struct net_device *dev)
}
else
writel( PROM, lp->mmio + CMD2);
if(dev->flags & IFF_ALLMULTI || dev->mc_count > MAX_FILTER_SIZE){
if (dev->flags & IFF_ALLMULTI ||
netdev_mc_count(dev) > MAX_FILTER_SIZE) {
/* get all multicast packet */
mc_filter[1] = mc_filter[0] = 0xffffffff;
lp->mc_list = dev->mc_list;
lp->options |= OPTION_MULTICAST_ENABLE;
amd8111e_writeq(*(u64*)mc_filter,lp->mmio + LADRF);
return;
}
if( dev->mc_count == 0 ){
if (netdev_mc_empty(dev)) {
/* get only own packets */
mc_filter[1] = mc_filter[0] = 0;
lp->mc_list = NULL;
Expand All @@ -1409,7 +1410,7 @@ static void amd8111e_set_multicast_list(struct net_device *dev)
lp->options |= OPTION_MULTICAST_ENABLE;
lp->mc_list = dev->mc_list;
mc_filter[1] = mc_filter[0] = 0;
for (i = 0, mc_ptr = dev->mc_list; mc_ptr && i < dev->mc_count;
for (i = 0, mc_ptr = dev->mc_list; mc_ptr && i < netdev_mc_count(dev);
i++, mc_ptr = mc_ptr->next) {
bit_num = (ether_crc_le(ETH_ALEN, mc_ptr->dmi_addr) >> 26) & 0x3f;
mc_filter[bit_num >> 5] |= 1 << (bit_num & 31);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ariadne.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,7 @@ static void set_multicast_list(struct net_device *dev)
lance->RDP = PROM; /* Set promiscuous mode */
} else {
short multicast_table[4];
int num_addrs = dev->mc_count;
int num_addrs = netdev_mc_count(dev);
int i;
/* We don't use the multicast table, but rely on upper-layer filtering. */
memset(multicast_table, (num_addrs == 0) ? 0 : -1,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/arm/at91_ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ static void at91ether_sethashtable(struct net_device *dev)
mc_filter[0] = mc_filter[1] = 0;

curr = dev->mc_list;
for (i = 0; i < dev->mc_count; i++, curr = curr->next) {
for (i = 0; i < netdev_mc_count(dev); i++, curr = curr->next) {
if (!curr) break; /* unexpected end of list */

bitnr = hash_get_index(curr->dmi_addr);
Expand Down Expand Up @@ -592,7 +592,7 @@ static void at91ether_set_multicast_list(struct net_device *dev)
at91_emac_write(AT91_EMAC_HSH, -1);
at91_emac_write(AT91_EMAC_HSL, -1);
cfg |= AT91_EMAC_MTI;
} else if (dev->mc_count > 0) { /* Enable specific multicasts */
} else if (!netdev_mc_empty(dev)) { /* Enable specific multicasts */
at91ether_sethashtable(dev);
cfg |= AT91_EMAC_MTI;
} else if (dev->flags & (~IFF_ALLMULTI)) { /* Disable all multicast mode */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/arm/ether3.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ static void ether3_setmulticastlist(struct net_device *dev)
if (dev->flags & IFF_PROMISC) {
/* promiscuous mode */
priv(dev)->regs.config1 |= CFG1_RECVPROMISC;
} else if (dev->flags & IFF_ALLMULTI || dev->mc_count) {
} else if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev)) {
priv(dev)->regs.config1 |= CFG1_RECVSPECBRMULTI;
} else
priv(dev)->regs.config1 |= CFG1_RECVSPECBROAD;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/arm/ixp4xx_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ static void eth_set_mcast_list(struct net_device *dev)
struct port *port = netdev_priv(dev);
struct dev_mc_list *mclist = dev->mc_list;
u8 diffs[ETH_ALEN], *addr;
int cnt = dev->mc_count, i;
int cnt = netdev_mc_count(dev), i;

if ((dev->flags & IFF_PROMISC) || !mclist || !cnt) {
__raw_writel(DEFAULT_RX_CNTRL0 & ~RX_CNTRL0_ADDR_FLTR_EN,
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/arm/ks8695net.c
Original file line number Diff line number Diff line change
Expand Up @@ -1207,7 +1207,7 @@ ks8695_set_multicast(struct net_device *ndev)
if (ndev->flags & IFF_ALLMULTI) {
/* enable all multicast mode */
ctrl |= DRXC_RM;
} else if (ndev->mc_count > KS8695_NR_ADDRESSES) {
} else if (netdev_mc_count(ndev) > KS8695_NR_ADDRESSES) {
/* more specific multicast addresses than can be
* handled in hardware
*/
Expand All @@ -1216,7 +1216,7 @@ ks8695_set_multicast(struct net_device *ndev)
/* enable specific multicasts */
ctrl &= ~DRXC_RM;
ks8695_init_partial_multicast(ksp, ndev->mc_list,
ndev->mc_count);
netdev_mc_count(ndev));
}

ks8695_writereg(ksp, KS8695_DRXC, ctrl);
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/at1700.c
Original file line number Diff line number Diff line change
Expand Up @@ -839,20 +839,20 @@ set_rx_mode(struct net_device *dev)
if (dev->flags & IFF_PROMISC) {
memset(mc_filter, 0xff, sizeof(mc_filter));
outb(3, ioaddr + RX_MODE); /* Enable promiscuous mode */
} else if (dev->mc_count > MC_FILTERBREAK ||
} else if (netdev_mc_count(dev) > MC_FILTERBREAK ||
(dev->flags & IFF_ALLMULTI)) {
/* Too many to filter perfectly -- accept all multicasts. */
memset(mc_filter, 0xff, sizeof(mc_filter));
outb(2, ioaddr + RX_MODE); /* Use normal mode. */
} else if (dev->mc_count == 0) {
} else if (netdev_mc_empty(dev)) {
memset(mc_filter, 0x00, sizeof(mc_filter));
outb(1, ioaddr + RX_MODE); /* Ignore almost all multicasts. */
} else {
struct dev_mc_list *mclist;
int i;

memset(mc_filter, 0, sizeof(mc_filter));
for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
i++, mclist = mclist->next) {
unsigned int bit =
ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/atarilance.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,7 @@ static void set_multicast_list( struct net_device *dev )
REGA( CSR15 ) = 0x8000; /* Set promiscuous mode */
} else {
short multicast_table[4];
int num_addrs = dev->mc_count;
int num_addrs = netdev_mc_count(dev);
int i;
/* We don't use the multicast table, but rely on upper-layer
* filtering. */
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/atp.c
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ static void set_rx_mode_8002(struct net_device *dev)
struct net_local *lp = netdev_priv(dev);
long ioaddr = dev->base_addr;

if (dev->mc_count > 0 || (dev->flags & (IFF_ALLMULTI|IFF_PROMISC)))
if (!netdev_mc_empty(dev) || (dev->flags & (IFF_ALLMULTI|IFF_PROMISC)))
lp->addr_mode = CMR2h_PROMISC;
else
lp->addr_mode = CMR2h_Normal;
Expand All @@ -877,15 +877,16 @@ static void set_rx_mode_8012(struct net_device *dev)

if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
new_mode = CMR2h_PROMISC;
} else if ((dev->mc_count > 1000) || (dev->flags & IFF_ALLMULTI)) {
} else if ((netdev_mc_count(dev) > 1000) ||
(dev->flags & IFF_ALLMULTI)) {
/* Too many to filter perfectly -- accept all multicasts. */
memset(mc_filter, 0xff, sizeof(mc_filter));
new_mode = CMR2h_Normal;
} else {
struct dev_mc_list *mclist;

memset(mc_filter, 0, sizeof(mc_filter));
for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
i++, mclist = mclist->next)
{
int filterbit = ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x3f;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/au1000_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,7 @@ static void au1000_multicast_list(struct net_device *dev)
if (dev->flags & IFF_PROMISC) { /* Set promiscuous. */
aup->mac->control |= MAC_PROMISCUOUS;
} else if ((dev->flags & IFF_ALLMULTI) ||
dev->mc_count > MULTICAST_FILTER_LIMIT) {
netdev_mc_count(dev) > MULTICAST_FILTER_LIMIT) {
aup->mac->control |= MAC_PASS_ALL_MULTI;
aup->mac->control &= ~MAC_PROMISCUOUS;
printk(KERN_INFO "%s: Pass all multicast\n", dev->name);
Expand All @@ -1023,7 +1023,7 @@ static void au1000_multicast_list(struct net_device *dev)
u32 mc_filter[2]; /* Multicast hash filter */

mc_filter[1] = mc_filter[0] = 0;
for (i = 0, mclist = dev->mc_list; mclist && i < dev->mc_count;
for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
i++, mclist = mclist->next) {
set_bit(ether_crc(ETH_ALEN, mclist->dmi_addr)>>26,
(long *)mc_filter);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/b44.c
Original file line number Diff line number Diff line change
Expand Up @@ -1691,7 +1691,7 @@ static int __b44_load_mcast(struct b44 *bp, struct net_device *dev)
struct dev_mc_list *mclist;
int i, num_ents;

num_ents = min_t(int, dev->mc_count, B44_MCAST_TABLE_SIZE);
num_ents = min_t(int, netdev_mc_count(dev), B44_MCAST_TABLE_SIZE);
mclist = dev->mc_list;
for (i = 0; mclist && i < num_ents; i++, mclist = mclist->next) {
__b44_cam_write(bp, mclist->dmi_addr, i + 1);
Expand All @@ -1716,7 +1716,7 @@ static void __b44_set_rx_mode(struct net_device *dev)
__b44_set_mac_addr(bp);

if ((dev->flags & IFF_ALLMULTI) ||
(dev->mc_count > B44_MCAST_TABLE_SIZE))
(netdev_mc_count(dev) > B44_MCAST_TABLE_SIZE))
val |= RXCONFIG_ALLMULTI;
else
i = __b44_load_mcast(bp, dev);
Expand Down
Loading

0 comments on commit 4cd24ea

Please sign in to comment.