aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJiri Pirko <jpirko@redhat.com>2010-02-17 22:34:54 -0500
committerDavid S. Miller <davem@davemloft.net>2010-02-18 17:47:50 -0500
commit4302b67e041ea81c8fc233bee1296516e1294a27 (patch)
treec6160bcf70f321c7436f34033d39180c9043bfd9 /drivers
parent5508590c193661bc1484ad7b952af5fceacea40d (diff)
tulip: convert to use netdev_for_each_mc_addr
also bug in de2104x.c was corrected: for (i = 0; i < 32; i++) loop should be outside mc_list iteration. Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/tulip/de2104x.c19
-rw-r--r--drivers/net/tulip/de4x5.c14
-rw-r--r--drivers/net/tulip/dmfe.c27
-rw-r--r--drivers/net/tulip/tulip_core.c15
-rw-r--r--drivers/net/tulip/uli526x.c4
-rw-r--r--drivers/net/tulip/winbond-840.c6
6 files changed, 35 insertions, 50 deletions
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c
index a4cff23dcdf9..cb429723b2c8 100644
--- a/drivers/net/tulip/de2104x.c
+++ b/drivers/net/tulip/de2104x.c
@@ -677,18 +677,17 @@ static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
677 memset(hash_table, 0, sizeof(hash_table)); 677 memset(hash_table, 0, sizeof(hash_table));
678 set_bit_le(255, hash_table); /* Broadcast entry */ 678 set_bit_le(255, hash_table); /* Broadcast entry */
679 /* This should work on big-endian machines as well. */ 679 /* This should work on big-endian machines as well. */
680 for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev); 680 netdev_for_each_mc_addr(mclist, dev) {
681 i++, mclist = mclist->next) {
682 int index = ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x1ff; 681 int index = ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x1ff;
683 682
684 set_bit_le(index, hash_table); 683 set_bit_le(index, hash_table);
684 }
685 685
686 for (i = 0; i < 32; i++) { 686 for (i = 0; i < 32; i++) {
687 *setup_frm++ = hash_table[i]; 687 *setup_frm++ = hash_table[i];
688 *setup_frm++ = hash_table[i]; 688 *setup_frm++ = hash_table[i];
689 }
690 setup_frm = &de->setup_frame[13*6];
691 } 689 }
690 setup_frm = &de->setup_frame[13*6];
692 691
693 /* Fill the final entry with our physical address. */ 692 /* Fill the final entry with our physical address. */
694 eaddrs = (u16 *)dev->dev_addr; 693 eaddrs = (u16 *)dev->dev_addr;
@@ -701,20 +700,18 @@ static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev)
701{ 700{
702 struct de_private *de = netdev_priv(dev); 701 struct de_private *de = netdev_priv(dev);
703 struct dev_mc_list *mclist; 702 struct dev_mc_list *mclist;
704 int i;
705 u16 *eaddrs; 703 u16 *eaddrs;
706 704
707 /* We have <= 14 addresses so we can use the wonderful 705 /* We have <= 14 addresses so we can use the wonderful
708 16 address perfect filtering of the Tulip. */ 706 16 address perfect filtering of the Tulip. */
709 for (i = 0, mclist = dev->mc_list; i < netdev_mc_count(dev); 707 netdev_for_each_mc_addr(mclist, dev) {
710 i++, mclist = mclist->next) {
711 eaddrs = (u16 *)mclist->dmi_addr; 708 eaddrs = (u16 *)mclist->dmi_addr;
712 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 709 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
713 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 710 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
714 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 711 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
715 } 712 }
716 /* Fill the unused entries with the broadcast address. */ 713 /* Fill the unused entries with the broadcast address. */
717 memset(setup_frm, 0xff, (15-i)*12); 714 memset(setup_frm, 0xff, (15 - netdev_mc_count(dev)) * 12);
718 setup_frm = &de->setup_frame[15*6]; 715 setup_frm = &de->setup_frame[15*6];
719 716
720 /* Fill the final entry with our physical address. */ 717 /* Fill the final entry with our physical address. */
diff --git a/drivers/net/tulip/de4x5.c b/drivers/net/tulip/de4x5.c
index 0b6a9731091c..c4ecb9a95409 100644
--- a/drivers/net/tulip/de4x5.c
+++ b/drivers/net/tulip/de4x5.c
@@ -1951,9 +1951,9 @@ static void
1951SetMulticastFilter(struct net_device *dev) 1951SetMulticastFilter(struct net_device *dev)
1952{ 1952{
1953 struct de4x5_private *lp = netdev_priv(dev); 1953 struct de4x5_private *lp = netdev_priv(dev);
1954 struct dev_mc_list *dmi=dev->mc_list; 1954 struct dev_mc_list *dmi;
1955 u_long iobase = dev->base_addr; 1955 u_long iobase = dev->base_addr;
1956 int i, j, bit, byte; 1956 int i, bit, byte;
1957 u16 hashcode; 1957 u16 hashcode;
1958 u32 omr, crc; 1958 u32 omr, crc;
1959 char *pa; 1959 char *pa;
@@ -1966,9 +1966,8 @@ SetMulticastFilter(struct net_device *dev)
1966 if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 14)) { 1966 if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 14)) {
1967 omr |= OMR_PM; /* Pass all multicasts */ 1967 omr |= OMR_PM; /* Pass all multicasts */
1968 } else if (lp->setup_f == HASH_PERF) { /* Hash Filtering */ 1968 } else if (lp->setup_f == HASH_PERF) { /* Hash Filtering */
1969 for (i = 0; i < netdev_mc_count(dev) ;i++) { 1969 netdev_for_each_mc_addr(dmi, dev) {
1970 addrs=dmi->dmi_addr; 1970 addrs = dmi->dmi_addr;
1971 dmi=dmi->next;
1972 if ((*addrs & 0x01) == 1) { /* multicast address? */ 1971 if ((*addrs & 0x01) == 1) { /* multicast address? */
1973 crc = ether_crc_le(ETH_ALEN, addrs); 1972 crc = ether_crc_le(ETH_ALEN, addrs);
1974 hashcode = crc & HASH_BITS; /* hashcode is 9 LSb of CRC */ 1973 hashcode = crc & HASH_BITS; /* hashcode is 9 LSb of CRC */
@@ -1984,9 +1983,8 @@ SetMulticastFilter(struct net_device *dev)
1984 } 1983 }
1985 } 1984 }
1986 } else { /* Perfect filtering */ 1985 } else { /* Perfect filtering */
1987 for (j=0; j<netdev_mc_count(dev); j++) { 1986 netdev_for_each_mc_addr(dmi, dev) {
1988 addrs=dmi->dmi_addr; 1987 addrs = dmi->dmi_addr;
1989 dmi=dmi->next;
1990 for (i=0; i<ETH_ALEN; i++) { 1988 for (i=0; i<ETH_ALEN; i++) {
1991 *(pa + (i&1)) = *addrs++; 1989 *(pa + (i&1)) = *addrs++;
1992 if (i & 0x01) pa += 4; 1990 if (i & 0x01) pa += 4;
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c
index 534afbdb9c91..95b38d803e9b 100644
--- a/drivers/net/tulip/dmfe.c
+++ b/drivers/net/tulip/dmfe.c
@@ -330,8 +330,8 @@ static void poll_dmfe (struct net_device *dev);
330static void dmfe_descriptor_init(struct dmfe_board_info *, unsigned long); 330static void dmfe_descriptor_init(struct dmfe_board_info *, unsigned long);
331static void allocate_rx_buffer(struct dmfe_board_info *); 331static void allocate_rx_buffer(struct dmfe_board_info *);
332static void update_cr6(u32, unsigned long); 332static void update_cr6(u32, unsigned long);
333static void send_filter_frame(struct DEVICE * ,int); 333static void send_filter_frame(struct DEVICE *);
334static void dm9132_id_table(struct DEVICE * ,int); 334static void dm9132_id_table(struct DEVICE *);
335static u16 phy_read(unsigned long, u8, u8, u32); 335static u16 phy_read(unsigned long, u8, u8, u32);
336static void phy_write(unsigned long, u8, u8, u16, u32); 336static void phy_write(unsigned long, u8, u8, u16, u32);
337static void phy_write_1bit(unsigned long, u32); 337static void phy_write_1bit(unsigned long, u32);
@@ -658,9 +658,9 @@ static void dmfe_init_dm910x(struct DEVICE *dev)
658 658
659 /* Send setup frame */ 659 /* Send setup frame */
660 if (db->chip_id == PCI_DM9132_ID) 660 if (db->chip_id == PCI_DM9132_ID)
661 dm9132_id_table(dev, netdev_mc_count(dev)); /* DM9132 */ 661 dm9132_id_table(dev); /* DM9132 */
662 else 662 else
663 send_filter_frame(dev, netdev_mc_count(dev)); /* DM9102/DM9102A */ 663 send_filter_frame(dev); /* DM9102/DM9102A */
664 664
665 /* Init CR7, interrupt active bit */ 665 /* Init CR7, interrupt active bit */
666 db->cr7_data = CR7_DEFAULT; 666 db->cr7_data = CR7_DEFAULT;
@@ -1075,9 +1075,9 @@ static void dmfe_set_filter_mode(struct DEVICE * dev)
1075 1075
1076 DMFE_DBUG(0, "Set multicast address", mc_count); 1076 DMFE_DBUG(0, "Set multicast address", mc_count);
1077 if (db->chip_id == PCI_DM9132_ID) 1077 if (db->chip_id == PCI_DM9132_ID)
1078 dm9132_id_table(dev, mc_count); /* DM9132 */ 1078 dm9132_id_table(dev); /* DM9132 */
1079 else 1079 else
1080 send_filter_frame(dev, mc_count); /* DM9102/DM9102A */ 1080 send_filter_frame(dev); /* DM9102/DM9102A */
1081 spin_unlock_irqrestore(&db->lock, flags); 1081 spin_unlock_irqrestore(&db->lock, flags);
1082} 1082}
1083 1083
@@ -1452,7 +1452,7 @@ static void update_cr6(u32 cr6_data, unsigned long ioaddr)
1452 * This setup frame initilize DM910X address filter mode 1452 * This setup frame initilize DM910X address filter mode
1453*/ 1453*/
1454 1454
1455static void dm9132_id_table(struct DEVICE *dev, int mc_cnt) 1455static void dm9132_id_table(struct DEVICE *dev)
1456{ 1456{
1457 struct dev_mc_list *mcptr; 1457 struct dev_mc_list *mcptr;
1458 u16 * addrptr; 1458 u16 * addrptr;
@@ -1472,15 +1472,14 @@ static void dm9132_id_table(struct DEVICE *dev, int mc_cnt)
1472 ioaddr += 4; 1472 ioaddr += 4;
1473 1473
1474 /* Clear Hash Table */ 1474 /* Clear Hash Table */
1475 for (i = 0; i < 4; i++) 1475 memset(hash_table, 0, sizeof(hash_table));
1476 hash_table[i] = 0x0;
1477 1476
1478 /* broadcast address */ 1477 /* broadcast address */
1479 hash_table[3] = 0x8000; 1478 hash_table[3] = 0x8000;
1480 1479
1481 /* the multicast address in Hash Table : 64 bits */ 1480 /* the multicast address in Hash Table : 64 bits */
1482 for (mcptr = dev->mc_list, i = 0; i < mc_cnt; i++, mcptr = mcptr->next) { 1481 netdev_for_each_mc_addr(mcptr, dev) {
1483 hash_val = cal_CRC( (char *) mcptr->dmi_addr, 6, 0) & 0x3f; 1482 hash_val = cal_CRC((char *) mcptr->dmi_addr, 6, 0) & 0x3f;
1484 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16); 1483 hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
1485 } 1484 }
1486 1485
@@ -1495,7 +1494,7 @@ static void dm9132_id_table(struct DEVICE *dev, int mc_cnt)
1495 * This setup frame initilize DM910X address filter mode 1494 * This setup frame initilize DM910X address filter mode
1496 */ 1495 */
1497 1496
1498static void send_filter_frame(struct DEVICE *dev, int mc_cnt) 1497static void send_filter_frame(struct DEVICE *dev)
1499{ 1498{
1500 struct dmfe_board_info *db = netdev_priv(dev); 1499 struct dmfe_board_info *db = netdev_priv(dev);
1501 struct dev_mc_list *mcptr; 1500 struct dev_mc_list *mcptr;
@@ -1521,14 +1520,14 @@ static void send_filter_frame(struct DEVICE *dev, int mc_cnt)
1521 *suptr++ = 0xffff; 1520 *suptr++ = 0xffff;
1522 1521
1523 /* fit the multicast address */ 1522 /* fit the multicast address */
1524 for (mcptr = dev->mc_list, i = 0; i < mc_cnt; i++, mcptr = mcptr->next) { 1523 netdev_for_each_mc_addr(mcptr, dev) {
1525 addrptr = (u16 *) mcptr->dmi_addr; 1524 addrptr = (u16 *) mcptr->dmi_addr;
1526 *suptr++ = addrptr[0]; 1525 *suptr++ = addrptr[0];
1527 *suptr++ = addrptr[1]; 1526 *suptr++ = addrptr[1];
1528 *suptr++ = addrptr[2]; 1527 *suptr++ = addrptr[2];
1529 } 1528 }
1530 1529
1531 for (; i<14; i++) { 1530 for (i = netdev_mc_count(dev); i < 14; i++) {
1532 *suptr++ = 0xffff; 1531 *suptr++ = 0xffff;
1533 *suptr++ = 0xffff; 1532 *suptr++ = 0xffff;
1534 *suptr++ = 0xffff; 1533 *suptr++ = 0xffff;
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c
index cce2ada07950..7f544ef2f5fc 100644
--- a/drivers/net/tulip/tulip_core.c
+++ b/drivers/net/tulip/tulip_core.c
@@ -997,12 +997,10 @@ static void build_setup_frame_hash(u16 *setup_frm, struct net_device *dev)
997 memset(hash_table, 0, sizeof(hash_table)); 997 memset(hash_table, 0, sizeof(hash_table));
998 set_bit_le(255, hash_table); /* Broadcast entry */ 998 set_bit_le(255, hash_table); /* Broadcast entry */
999 /* This should work on big-endian machines as well. */ 999 /* This should work on big-endian machines as well. */
1000 for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev); 1000 netdev_for_each_mc_addr(mclist, dev) {
1001 i++, mclist = mclist->next) {
1002 int index = ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x1ff; 1001 int index = ether_crc_le(ETH_ALEN, mclist->dmi_addr) & 0x1ff;
1003 1002
1004 set_bit_le(index, hash_table); 1003 set_bit_le(index, hash_table);
1005
1006 } 1004 }
1007 for (i = 0; i < 32; i++) { 1005 for (i = 0; i < 32; i++) {
1008 *setup_frm++ = hash_table[i]; 1006 *setup_frm++ = hash_table[i];
@@ -1021,20 +1019,18 @@ static void build_setup_frame_perfect(u16 *setup_frm, struct net_device *dev)
1021{ 1019{
1022 struct tulip_private *tp = netdev_priv(dev); 1020 struct tulip_private *tp = netdev_priv(dev);
1023 struct dev_mc_list *mclist; 1021 struct dev_mc_list *mclist;
1024 int i;
1025 u16 *eaddrs; 1022 u16 *eaddrs;
1026 1023
1027 /* We have <= 14 addresses so we can use the wonderful 1024 /* We have <= 14 addresses so we can use the wonderful
1028 16 address perfect filtering of the Tulip. */ 1025 16 address perfect filtering of the Tulip. */
1029 for (i = 0, mclist = dev->mc_list; i < netdev_mc_count(dev); 1026 netdev_for_each_mc_addr(mclist, dev) {
1030 i++, mclist = mclist->next) {
1031 eaddrs = (u16 *)mclist->dmi_addr; 1027 eaddrs = (u16 *)mclist->dmi_addr;
1032 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 1028 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
1033 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 1029 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
1034 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++; 1030 *setup_frm++ = *eaddrs; *setup_frm++ = *eaddrs++;
1035 } 1031 }
1036 /* Fill the unused entries with the broadcast address. */ 1032 /* Fill the unused entries with the broadcast address. */
1037 memset(setup_frm, 0xff, (15-i)*12); 1033 memset(setup_frm, 0xff, (15 - netdev_mc_count(dev)) * 12);
1038 setup_frm = &tp->setup_frame[15*6]; 1034 setup_frm = &tp->setup_frame[15*6];
1039 1035
1040 /* Fill the final entry with our physical address. */ 1036 /* Fill the final entry with our physical address. */
@@ -1066,7 +1062,6 @@ static void set_rx_mode(struct net_device *dev)
1066 /* Some work-alikes have only a 64-entry hash filter table. */ 1062 /* Some work-alikes have only a 64-entry hash filter table. */
1067 /* Should verify correctness on big-endian/__powerpc__ */ 1063 /* Should verify correctness on big-endian/__powerpc__ */
1068 struct dev_mc_list *mclist; 1064 struct dev_mc_list *mclist;
1069 int i;
1070 if (netdev_mc_count(dev) > 64) { 1065 if (netdev_mc_count(dev) > 64) {
1071 /* Arbitrary non-effective limit. */ 1066 /* Arbitrary non-effective limit. */
1072 tp->csr6 |= AcceptAllMulticast; 1067 tp->csr6 |= AcceptAllMulticast;
@@ -1074,9 +1069,7 @@ static void set_rx_mode(struct net_device *dev)
1074 } else { 1069 } else {
1075 u32 mc_filter[2] = {0, 0}; /* Multicast hash filter */ 1070 u32 mc_filter[2] = {0, 0}; /* Multicast hash filter */
1076 int filterbit; 1071 int filterbit;
1077 for (i = 0, mclist = dev->mc_list; 1072 netdev_for_each_mc_addr(mclist, dev) {
1078 mclist && i < netdev_mc_count(dev);
1079 i++, mclist = mclist->next) {
1080 if (tp->flags & COMET_MAC_ADDR) 1073 if (tp->flags & COMET_MAC_ADDR)
1081 filterbit = ether_crc_le(ETH_ALEN, mclist->dmi_addr); 1074 filterbit = ether_crc_le(ETH_ALEN, mclist->dmi_addr);
1082 else 1075 else
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c
index 216ceb322ed4..0ab05af237e5 100644
--- a/drivers/net/tulip/uli526x.c
+++ b/drivers/net/tulip/uli526x.c
@@ -1415,14 +1415,14 @@ static void send_filter_frame(struct net_device *dev, int mc_cnt)
1415 *suptr++ = 0xffff << FLT_SHIFT; 1415 *suptr++ = 0xffff << FLT_SHIFT;
1416 1416
1417 /* fit the multicast address */ 1417 /* fit the multicast address */
1418 for (mcptr = dev->mc_list, i = 0; i < mc_cnt; i++, mcptr = mcptr->next) { 1418 netdev_for_each_mc_addr(mcptr, dev) {
1419 addrptr = (u16 *) mcptr->dmi_addr; 1419 addrptr = (u16 *) mcptr->dmi_addr;
1420 *suptr++ = addrptr[0] << FLT_SHIFT; 1420 *suptr++ = addrptr[0] << FLT_SHIFT;
1421 *suptr++ = addrptr[1] << FLT_SHIFT; 1421 *suptr++ = addrptr[1] << FLT_SHIFT;
1422 *suptr++ = addrptr[2] << FLT_SHIFT; 1422 *suptr++ = addrptr[2] << FLT_SHIFT;
1423 } 1423 }
1424 1424
1425 for (; i<14; i++) { 1425 for (i = netdev_mc_count(dev); i < 14; i++) {
1426 *suptr++ = 0xffff << FLT_SHIFT; 1426 *suptr++ = 0xffff << FLT_SHIFT;
1427 *suptr++ = 0xffff << FLT_SHIFT; 1427 *suptr++ = 0xffff << FLT_SHIFT;
1428 *suptr++ = 0xffff << FLT_SHIFT; 1428 *suptr++ = 0xffff << FLT_SHIFT;
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c
index 98711a9f35ac..304f43866c44 100644
--- a/drivers/net/tulip/winbond-840.c
+++ b/drivers/net/tulip/winbond-840.c
@@ -1368,11 +1368,9 @@ static u32 __set_rx_mode(struct net_device *dev)
1368 rx_mode = RxAcceptBroadcast | AcceptMulticast | AcceptMyPhys; 1368 rx_mode = RxAcceptBroadcast | AcceptMulticast | AcceptMyPhys;
1369 } else { 1369 } else {
1370 struct dev_mc_list *mclist; 1370 struct dev_mc_list *mclist;
1371 int i; 1371
1372 memset(mc_filter, 0, sizeof(mc_filter)); 1372 memset(mc_filter, 0, sizeof(mc_filter));
1373 for (i = 0, mclist = dev->mc_list; 1373 netdev_for_each_mc_addr(mclist, dev) {
1374 mclist && i < netdev_mc_count(dev);
1375 i++, mclist = mclist->next) {
1376 int filterbit = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26) ^ 0x3F; 1374 int filterbit = (ether_crc(ETH_ALEN, mclist->dmi_addr) >> 26) ^ 0x3F;
1377 filterbit &= 0x3f; 1375 filterbit &= 0x3f;
1378 mc_filter[filterbit >> 5] |= 1 << (filterbit & 31); 1376 mc_filter[filterbit >> 5] |= 1 << (filterbit & 31);