]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
net: convert multiple drivers to use netdev_for_each_mc_addr, part6
authorJiri Pirko <jpirko@redhat.com>
Tue, 23 Feb 2010 23:17:07 +0000 (23:17 +0000)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 Feb 2010 10:07:31 +0000 (02:07 -0800)
Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
18 files changed:
drivers/net/smc911x.c
drivers/net/smc9194.c
drivers/net/smc91x.c
drivers/net/starfire.c
drivers/net/tc35815.c
drivers/net/tehuti.c
drivers/net/tg3.c
drivers/net/tlan.c
drivers/net/tsi108_eth.c
drivers/net/typhoon.c
drivers/net/ucc_geth.c
drivers/net/via-rhine.c
drivers/net/via-velocity.c
drivers/net/virtio_net.c
drivers/net/vmxnet3/vmxnet3_drv.c
drivers/net/vxge/vxge-main.c
drivers/net/yellowfin.c
drivers/net/znet.c

index ef9674c6713f969d59744c2585d15690748e92b0..9871a2b61f869c65e051e8515540e7089c158c75 100644 (file)
@@ -1341,7 +1341,6 @@ static void smc911x_set_multicast_list(struct net_device *dev)
         * within that register.
         */
        else if (!netdev_mc_empty(dev)) {
-               int i;
                struct dev_mc_list *cur_addr;
 
                /* Set the Hash perfec mode */
@@ -1350,8 +1349,7 @@ static void smc911x_set_multicast_list(struct net_device *dev)
                /* start with a table of all zeros: reject all */
                memset(multicast_table, 0, sizeof(multicast_table));
 
-               cur_addr = dev->mc_list;
-               for (i = 0; i < netdev_mc_count(dev); i++, cur_addr = cur_addr->next) {
+               netdev_for_each_mc_addr(cur_addr, dev) {
                        u32 position;
 
                        /* do we have a pointer here? */
index 41c3dddeab50365c68b5c57b0dc3feaae6f98a20..f9a960e7fc1fdc351e69f34bb74c694560f77235 100644 (file)
@@ -434,18 +434,18 @@ static void smc_shutdown( int ioaddr )
 */
 
 
-static void smc_setmulticast( int ioaddr, int count, struct dev_mc_list * addrs ) {
+static void smc_setmulticast(int ioaddr, struct net_device *dev)
+{
        int                     i;
        unsigned char           multicast_table[ 8 ];
-       struct dev_mc_list      * cur_addr;
+       struct dev_mc_list *cur_addr;
        /* table for flipping the order of 3 bits */
        unsigned char invert3[] = { 0, 4, 2, 6, 1, 5, 3, 7 };
 
        /* start with a table of all zeros: reject all */
        memset( multicast_table, 0, sizeof( multicast_table ) );
 
-       cur_addr = addrs;
-       for ( i = 0; i < count ; i ++, cur_addr = cur_addr->next  ) {
+       netdev_for_each_mc_addr(cur_addr, dev) {
                int position;
 
                /* do we have a pointer here? */
@@ -1550,7 +1550,7 @@ static void smc_set_multicast_list(struct net_device *dev)
                        ioaddr + RCR );
                /* NOTE: this has to set the bank, so make sure it is the
                   last thing called.  The bank is set to zero at the top */
-               smc_setmulticast(ioaddr, netdev_mc_count(dev), dev->mc_list);
+               smc_setmulticast(ioaddr, dev);
        }
        else  {
                outw( inw( ioaddr + RCR ) & ~(RCR_PROMISC | RCR_ALMUL),
index 66450127c5a13d4a49b0fb93e4d040f761372615..fc1b5a1a3583d7d15983400ab384a81f6c1732b3 100644 (file)
@@ -1413,7 +1413,6 @@ static void smc_set_multicast_list(struct net_device *dev)
         * within that register.
         */
        else if (!netdev_mc_empty(dev)) {
-               int i;
                struct dev_mc_list *cur_addr;
 
                /* table for flipping the order of 3 bits */
@@ -1422,13 +1421,9 @@ static void smc_set_multicast_list(struct net_device *dev)
                /* start with a table of all zeros: reject all */
                memset(multicast_table, 0, sizeof(multicast_table));
 
-               cur_addr = dev->mc_list;
-               for (i = 0; i < netdev_mc_count(dev); i++, cur_addr = cur_addr->next) {
+               netdev_for_each_mc_addr(cur_addr, dev) {
                        int position;
 
-                       /* do we have a pointer here? */
-                       if (!cur_addr)
-                               break;
                        /* make sure this is a multicast address -
                           shouldn't this be a given if we have it here ? */
                        if (!(*cur_addr->dmi_addr & 1))
index 0f405ef5185873e01b59f3379ad3fc312ad39509..6dfa698990198f12f55ee312e7ae701f8bd0e40e 100644 (file)
@@ -1825,8 +1825,7 @@ static void set_rx_mode(struct net_device *dev)
                __le16 mc_filter[32] __attribute__ ((aligned(sizeof(long))));   /* Multicast hash filter */
 
                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 chip uses the upper 9 CRC bits
                           as index into the hash table */
                        int bit_nr = ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 23;
index a2c635ecdab857a3b710c1fa9c3d8a9aba99ea5b..876f45afbed4329a4af82b77a0ae568fa252bc35 100644 (file)
@@ -1945,18 +1945,18 @@ tc35815_set_multicast_list(struct net_device *dev)
                /* Disable promiscuous mode, use normal mode. */
                tc_writel(CAM_CompEn | CAM_BroadAcc | CAM_GroupAcc, &tr->CAM_Ctl);
        } else if (!netdev_mc_empty(dev)) {
-               struct dev_mc_list *cur_addr = dev->mc_list;
+               struct dev_mc_list *cur_addr;
                int i;
                int ena_bits = CAM_Ena_Bit(CAM_ENTRY_SOURCE);
 
                tc_writel(0, &tr->CAM_Ctl);
                /* Walk the address list, and load the filter */
-               for (i = 0; i < netdev_mc_count(dev); i++, cur_addr = cur_addr->next) {
-                       if (!cur_addr)
-                               break;
+               i = 0;
+               netdev_for_each_mc_addr(cur_addr, dev) {
                        /* entry 0,1 is reserved. */
                        tc35815_set_cam_entry(dev, i + 2, cur_addr->dmi_addr);
                        ena_bits |= CAM_Ena_Bit(i + 2);
+                       i++;
                }
                tc_writel(ena_bits, &tr->CAM_Ena);
                tc_writel(CAM_CompEn | CAM_BroadAcc, &tr->CAM_Ctl);
index 2517cc00ac2a74ea92ebbd8bd80906a03633357d..0c9780217c870e63be00ffa520e0ba24d84d8807 100644 (file)
@@ -824,10 +824,8 @@ static void bdx_setmulti(struct net_device *ndev)
                /* TBD: sort addreses and write them in ascending order
                 * into RX_MAC_MCST regs. we skip this phase now and accept ALL
                 * multicast frames throu IMF */
-               mclist = ndev->mc_list;
-
                /* accept the rest of addresses throu IMF */
-               for (; mclist; mclist = mclist->next) {
+               netdev_for_each_mc_addr(mclist, ndev) {
                        hash = 0;
                        for (i = 0; i < ETH_ALEN; i++)
                                hash ^= mclist->dmi_addr[i];
index f204f73c4f99cb0edc0a7939c67ae365b6c1a8a8..0d06e4007f443af169e6fefd74e6f4a5f96b4d01 100644 (file)
@@ -9458,15 +9458,12 @@ static void __tg3_set_rx_mode(struct net_device *dev)
        } else {
                /* Accept one or more multicast(s). */
                struct dev_mc_list *mclist;
-               unsigned int i;
                u32 mc_filter[4] = { 0, };
                u32 regidx;
                u32 bit;
                u32 crc;
 
-               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 = calc_crc (mclist->dmi_addr, ETH_ALEN);
                        bit = ~crc & 0x7f;
                        regidx = (bit & 0x60) >> 5;
index e44d5a074c6912f41105a350e70a83feecc3ed6b..390540c101c7913ad2655eb44a4776f5b9fd603f 100644 (file)
@@ -1314,7 +1314,7 @@ static struct net_device_stats *TLan_GetStats( struct net_device *dev )
 
 static void TLan_SetMulticastList( struct net_device *dev )
 {
-       struct dev_mc_list      *dmi = dev->mc_list;
+       struct dev_mc_list *dmi;
        u32                     hash1 = 0;
        u32                     hash2 = 0;
        int                     i;
@@ -1335,7 +1335,8 @@ static void TLan_SetMulticastList( struct net_device *dev )
                        TLan_DioWrite32( dev->base_addr, TLAN_HASH_1, 0xFFFFFFFF );
                        TLan_DioWrite32( dev->base_addr, TLAN_HASH_2, 0xFFFFFFFF );
                } else {
-                       for ( i = 0; i < netdev_mc_count(dev); i++ ) {
+                       i = 0;
+                       netdev_for_each_mc_addr(dmi, dev) {
                                if ( i < 3 ) {
                                        TLan_SetMac( dev, i + 1,
                                                     (char *) &dmi->dmi_addr );
@@ -1346,7 +1347,7 @@ static void TLan_SetMulticastList( struct net_device *dev )
                                        else
                                                hash2 |= ( 1 << ( offset - 32 ) );
                                }
-                               dmi = dmi->next;
+                               i++;
                        }
                        for ( ; i < 3; i++ )
                                TLan_SetMac( dev, i + 1, NULL );
index f4b30c4826fb5e34dcc6df3c3ee62e95ac1ef22f..647cdd1d4e20a555182deb64352603d4a83d7d72 100644 (file)
@@ -1186,27 +1186,17 @@ static void tsi108_set_rx_mode(struct net_device *dev)
 
        if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev)) {
                int i;
-               struct dev_mc_list *mc = dev->mc_list;
+               struct dev_mc_list *mc;
                rxcfg |= TSI108_EC_RXCFG_MFE | TSI108_EC_RXCFG_MC_HASH;
 
                memset(data->mc_hash, 0, sizeof(data->mc_hash));
 
-               while (mc) {
+               netdev_for_each_mc_addr(mc, dev) {
                        u32 hash, crc;
 
-                       if (mc->dmi_addrlen == 6) {
-                               crc = ether_crc(6, mc->dmi_addr);
-                               hash = crc >> 23;
-
-                               __set_bit(hash, &data->mc_hash[0]);
-                       } else {
-                               printk(KERN_ERR
-               "%s: got multicast address of length %d instead of 6.\n",
-                                      dev->name,
-                                      mc->dmi_addrlen);
-                       }
-
-                       mc = mc->next;
+                       crc = ether_crc(6, mc->dmi_addr);
+                       hash = crc >> 23;
+                       __set_bit(hash, &data->mc_hash[0]);
                }
 
                TSI_WRITE(TSI108_EC_HASHADDR,
index 38c216132ef5d95f6f1c2b82aecf36289e61c67e..e3ddcb8f29df39a5e45784b62f0ffe1b2cb15e7e 100644 (file)
@@ -922,12 +922,9 @@ typhoon_set_rx_mode(struct net_device *dev)
                filter |= TYPHOON_RX_FILTER_ALL_MCAST;
        } else if (!netdev_mc_empty(dev)) {
                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) {
                        int bit = ether_crc(ETH_ALEN, mclist->dmi_addr) & 0x3f;
                        mc_filter[bit >> 5] |= 1 << (bit & 0x1f);
                }
index a05720289c7e849af4cb8299ce79c809f6106ca6..23a97518bc1f9ef9b38d3803127c3a6f4b4e4399 100644 (file)
@@ -2002,7 +2002,6 @@ static void ucc_geth_set_multi(struct net_device *dev)
        struct dev_mc_list *dmi;
        struct ucc_fast __iomem *uf_regs;
        struct ucc_geth_82xx_address_filtering_pram __iomem *p_82xx_addr_filt;
-       int i;
 
        ugeth = netdev_priv(dev);
 
@@ -2029,11 +2028,7 @@ static void ucc_geth_set_multi(struct net_device *dev)
                        out_be32(&p_82xx_addr_filt->gaddr_h, 0x0);
                        out_be32(&p_82xx_addr_filt->gaddr_l, 0x0);
 
-                       dmi = dev->mc_list;
-
-                       for (i = 0; i < netdev_mc_count(dev);
-                            i++, dmi = dmi->next) {
-
+                       netdev_for_each_mc_addr(dmi, dev) {
                                /* Only support group multicast for now.
                                 */
                                if (!(dmi->dmi_addr[0] & 1))
index 85df7ac636b5b45f07021f2412fcb597a756e5ce..50f881aa3939a50606f34412bd05cdbe2d2ad381 100644 (file)
@@ -1705,11 +1705,9 @@ static void rhine_set_rx_mode(struct net_device *dev)
                rx_mode = 0x0C;
        } 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) {
                        int bit_nr = ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26;
 
                        mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31);
index 4e47f2683b834b203ae167026c308aceb5aa4667..3a486f3bad3ddd6477c0fa15102e47c668ea3566 100644 (file)
@@ -1141,11 +1141,11 @@ static void velocity_set_multi(struct net_device *dev)
                int offset = MCAM_SIZE - vptr->multicast_limit;
                mac_get_cam_mask(regs, vptr->mCAMmask);
 
-               for (i = 0, mclist = dev->mc_list;
-                    mclist && i < netdev_mc_count(dev);
-                    i++, mclist = mclist->next) {
+               i = 0;
+               netdev_for_each_mc_addr(mclist, dev) {
                        mac_set_cam(regs, i + offset, mclist->dmi_addr);
                        vptr->mCAMmask[(offset + i) / 8] |= 1 << ((offset + i) & 7);
+                       i++;
                }
 
                mac_set_cam_mask(regs, vptr->mCAMmask);
index ce35b42cc2cb184f7b2cda9fa6d571e258940fa9..e6095f3aa05f3ae853b80a7e45c95a8e71caefbd 100644 (file)
@@ -776,8 +776,9 @@ static void virtnet_set_rx_mode(struct net_device *dev)
 
        mac_data->entries = mc_count;
        addr = dev->mc_list;
-       for (i = 0; i < mc_count; i++, addr = addr->next)
-               memcpy(&mac_data->macs[i][0], addr->da_addr, ETH_ALEN);
+       i = 0;
+       netdev_for_each_mc_addr(addr, dev)
+               memcpy(&mac_data->macs[i++][0], addr->da_addr, ETH_ALEN);
 
        sg_set_buf(&sg[1], mac_data,
                   sizeof(mac_data->entries) + (mc_count * ETH_ALEN));
index ee1b397417f3cfed42615afa16cde17783d7962f..cff3485d967364d1a5803ddd2468a2d302753470 100644 (file)
@@ -1675,15 +1675,12 @@ vmxnet3_copy_mc(struct net_device *netdev)
                /* We may be called with BH disabled */
                buf = kmalloc(sz, GFP_ATOMIC);
                if (buf) {
-                       int i;
-                       struct dev_mc_list *mc = netdev->mc_list;
+                       struct dev_mc_list *mc;
+                       int i = 0;
 
-                       for (i = 0; i < netdev_mc_count(netdev); i++) {
-                               BUG_ON(!mc);
-                               memcpy(buf + i * ETH_ALEN, mc->dmi_addr,
+                       netdev_for_each_mc_addr(mc, netdev)
+                               memcpy(buf + i++ * ETH_ALEN, mc->dmi_addr,
                                       ETH_ALEN);
-                               mc = mc->next;
-                       }
                }
        }
        return buf;
index c248b01218a19ca11ae6a3d9c3d216b35db78791..46a7c9e689ec7dc26d2e29d6760f606562ea5dc5 100644 (file)
@@ -1217,9 +1217,7 @@ static void vxge_set_multicast(struct net_device *dev)
                }
 
                /* Add new ones */
-               for (i = 0, mclist = dev->mc_list; i < netdev_mc_count(dev);
-                       i++, mclist = mclist->next) {
-
+               netdev_for_each_mc_addr(mclist, dev) {
                        memcpy(mac_info.macaddr, mclist->dmi_addr, ETH_ALEN);
                        for (vpath_idx = 0; vpath_idx < vdev->no_of_vpath;
                                        vpath_idx++) {
index e4aab4d5b553822f94362fffb85295acf0eeb828..7d4107f5eeb020d830a2e387dd275fdd47164b36 100644 (file)
@@ -1303,9 +1303,9 @@ static void set_rx_mode(struct net_device *dev)
                struct dev_mc_list *mclist;
                u16 hash_table[4];
                int i;
+
                memset(hash_table, 0, sizeof(hash_table));
-               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;
 
                        /* Due to a bug in the early chip versions, multiple filter
index bc5ae0f6e934f32ad6af763b556ff878e861276a..def49d2ec69ac8c29695ddfced8aec23e8b4cc4d 100644 (file)
@@ -313,7 +313,8 @@ static void znet_set_multicast_list (struct net_device *dev)
        /* Byte D */
        cfblk->dummy_1 = 1;     /* set to 1 */
        cfblk->tx_ifs_retrig = 3; /* Hmm... Disabled */
-       cfblk->mc_all = (dev->mc_list || (dev->flags&IFF_ALLMULTI));/* multicast all mode */
+       cfblk->mc_all = (!netdev_mc_empty(dev) ||
+                       (dev->flags & IFF_ALLMULTI)); /* multicast all mode */
        cfblk->rcv_mon = 0;     /* Monitor mode disabled */
        cfblk->frag_acpt = 0;   /* Do not accept fragments */
        cfblk->tstrttrs = 0;    /* No start transmission threshold */