From 4cd24eaf0c6ee7f0242e34ee77ec899f255e66b5 Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Mon, 8 Feb 2010 04:30:35 +0000 Subject: net: use netdev_mc_count and netdev_mc_empty when appropriate 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 Signed-off-by: David S. Miller --- drivers/net/isa-skeleton.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'drivers/net/isa-skeleton.c') diff --git a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c index 04d0502726c0..bb4a3cda6e4b 100644 --- a/drivers/net/isa-skeleton.c +++ b/drivers/net/isa-skeleton.c @@ -655,14 +655,15 @@ set_multicast_list(struct net_device *dev) /* Enable promiscuous mode */ outw(MULTICAST|PROMISC, ioaddr); } - else if((dev->flags&IFF_ALLMULTI) || dev->mc_count > HW_MAX_ADDRS) + else if ((dev->flags&IFF_ALLMULTI) || + netdev_mc_count(dev) > HW_MAX_ADDRS) { /* Disable promiscuous mode, use normal mode. */ hardware_set_filter(NULL); outw(MULTICAST, ioaddr); } - else if(dev->mc_count) + else if (!netdev_mc_empty(dev)) { /* Walk the address list, and load the filter */ hardware_set_filter(dev->mc_list); -- cgit v1.2.3 From 48e2f183cb1709600012265a2e723f45a350d5fe Mon Sep 17 00:00:00 2001 From: Jiri Pirko Date: Mon, 22 Feb 2010 09:22:26 +0000 Subject: net: convert multiple drivers to use netdev_for_each_mc_addr, part4 Signed-off-by: Jiri Pirko Signed-off-by: David S. Miller --- drivers/net/davinci_emac.c | 5 ++--- drivers/net/e100.c | 10 +++++++--- drivers/net/eepro.c | 8 +++----- drivers/net/eexpress.c | 16 ++++++---------- drivers/net/ehea/ehea_main.c | 5 ++--- drivers/net/enic/enic_main.c | 10 ++++++---- drivers/net/epic100.c | 3 +-- drivers/net/ethoc.c | 6 +++--- drivers/net/ewrk3.c | 5 ++--- drivers/net/fealnx.c | 4 +--- drivers/net/fec.c | 6 ++---- drivers/net/fec_mpc52xx.c | 5 +---- drivers/net/forcedeth.c | 6 ++---- drivers/net/fs_enet/mac-fcc.c | 2 +- drivers/net/fs_enet/mac-fec.c | 2 +- drivers/net/fs_enet/mac-scc.c | 2 +- drivers/net/gianfar.c | 2 +- drivers/net/hamachi.c | 7 ++++--- drivers/net/hp100.c | 6 +++--- drivers/net/ibm_newemac/core.c | 2 +- drivers/net/ibmlana.c | 2 +- drivers/net/ibmveth.c | 5 ++--- drivers/net/igb/igb_main.c | 12 ++++-------- drivers/net/igbvf/netdev.c | 12 +++--------- drivers/net/ioc3-eth.c | 6 ++---- drivers/net/ipg.c | 3 +-- drivers/net/isa-skeleton.c | 2 +- drivers/net/iseries_veth.c | 6 ++---- drivers/net/ixgb/ixgb_main.c | 7 +++---- 29 files changed, 69 insertions(+), 98 deletions(-) (limited to 'drivers/net/isa-skeleton.c') diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c index d1e03b5984c0..3f5db83c7cbb 100644 --- a/drivers/net/davinci_emac.c +++ b/drivers/net/davinci_emac.c @@ -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); diff --git a/drivers/net/e100.c b/drivers/net/e100.c index e8c0e823a06f..a26ccab057d5 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c @@ -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) diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c index 5f73ab22db16..1b05bdf62c3c 100644 --- a/drivers/net/eepro.c +++ b/drivers/net/eepro.c @@ -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) @@ -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); diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c index d804ff18eda8..7013dc8a6cbc 100644 --- a/drivers/net/eexpress.c +++ b/drivers/net/eexpress.c @@ -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++; } } diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index 99e4f8360d2f..b004eaba3d7b 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c @@ -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); @@ -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); } diff --git a/drivers/net/enic/enic_main.c b/drivers/net/enic/enic_main.c index 94749ebaaea8..cf098bb636b8 100644 --- a/drivers/net/enic/enic_main.c +++ b/drivers/net/enic/enic_main.c @@ -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; @@ -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++) { diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c index 31a3adb65566..39c271b6be44 100644 --- a/drivers/net/epic100.c +++ b/drivers/net/epic100.c @@ -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); diff --git a/drivers/net/ethoc.c b/drivers/net/ethoc.c index f9d5ca078743..209742304e20 100644 --- a/drivers/net/ethoc.c +++ b/drivers/net/ethoc.c @@ -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 */ @@ -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); } diff --git a/drivers/net/ewrk3.c b/drivers/net/ewrk3.c index 96817a872f47..91e59f3a9d6d 100644 --- a/drivers/net/ewrk3.c +++ b/drivers/net/ewrk3.c @@ -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; @@ -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 */ diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c index f95b5ff0587d..9d5ad08a119f 100644 --- a/drivers/net/fealnx.c +++ b/drivers/net/fealnx.c @@ -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); diff --git a/drivers/net/fec.c b/drivers/net/fec.c index d9d14c83f51c..9f98c1c4a344 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c @@ -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) { @@ -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; diff --git a/drivers/net/fec_mpc52xx.c b/drivers/net/fec_mpc52xx.c index 10903b75802f..0dbd7219bbde 100644 --- a/drivers/net/fec_mpc52xx.c +++ b/drivers/net/fec_mpc52xx.c @@ -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; idmi_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); diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 3eb713b014f9..ca05e5662029 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c @@ -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]; @@ -3105,8 +3105,7 @@ 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])); @@ -3114,7 +3113,6 @@ static void nv_set_multicast(struct net_device *dev) alwaysOff[0] &= ~a; alwaysOn[1] &= b; alwaysOff[1] &= ~b; - walk = walk->next; } } addr[0] = alwaysOn[0]; diff --git a/drivers/net/fs_enet/mac-fcc.c b/drivers/net/fs_enet/mac-fcc.c index 482f27d5f7d4..a761d31e3d6d 100644 --- a/drivers/net/fs_enet/mac-fcc.c +++ b/drivers/net/fs_enet/mac-fcc.c @@ -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 diff --git a/drivers/net/fs_enet/mac-fec.c b/drivers/net/fs_enet/mac-fec.c index ddf13ef8ac87..ca806d1ab3f6 100644 --- a/drivers/net/fs_enet/mac-fec.c +++ b/drivers/net/fs_enet/mac-fec.c @@ -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 diff --git a/drivers/net/fs_enet/mac-scc.c b/drivers/net/fs_enet/mac-scc.c index 141dbc91e5e7..5bfc99b9475e 100644 --- a/drivers/net/fs_enet/mac-scc.c +++ b/drivers/net/fs_enet/mac-scc.c @@ -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 diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index c9be090485dd..6aa526ee9096 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c @@ -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); diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c index c70b147b4feb..373546dd0831 100644 --- a/drivers/net/hamachi.c +++ b/drivers/net/hamachi.c @@ -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++) diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c index debac1bc6799..b766a69bf0ca 100644 --- a/drivers/net/hp100.c +++ b/drivers/net/hp100.c @@ -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; @@ -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); } diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index b75d27e82a3d..fb0ac6d7c040 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c @@ -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); diff --git a/drivers/net/ibmlana.c b/drivers/net/ibmlana.c index 052c74091d91..b5d0f4e973f7 100644 --- a/drivers/net/ibmlana.c +++ b/drivers/net/ibmlana.c @@ -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; diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index 41b9c0efcbdd..f2b937966950 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c @@ -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 | @@ -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); diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index f588e49c65f1..583a21c1def3 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c @@ -2877,7 +2877,7 @@ static int igb_write_mc_addr_list(struct net_device *netdev) { struct igb_adapter *adapter = netdev_priv(netdev); struct e1000_hw *hw = &adapter->hw; - struct dev_mc_list *mc_ptr = netdev->mc_list; + struct dev_mc_list *mc_ptr; u8 *mta_list; int i; @@ -2893,14 +2893,10 @@ static int igb_write_mc_addr_list(struct net_device *netdev) return -ENOMEM; /* The shared function expects a packed array of only addresses. */ - mc_ptr = netdev->mc_list; + i = 0; + netdev_for_each_mc_addr(mc_ptr, netdev) + memcpy(mta_list + (i++ * ETH_ALEN), mc_ptr->dmi_addr, ETH_ALEN); - for (i = 0; i < netdev_mc_count(netdev); i++) { - if (!mc_ptr) - break; - memcpy(mta_list + (i*ETH_ALEN), mc_ptr->dmi_addr, ETH_ALEN); - mc_ptr = mc_ptr->next; - } igb_update_mc_addr_list(hw, mta_list, i); kfree(mta_list); diff --git a/drivers/net/igbvf/netdev.c b/drivers/net/igbvf/netdev.c index 6029c400f2be..a77afd8a14bb 100644 --- a/drivers/net/igbvf/netdev.c +++ b/drivers/net/igbvf/netdev.c @@ -1413,15 +1413,9 @@ static void igbvf_set_multi(struct net_device *netdev) } /* prepare a packed array of only addresses. */ - mc_ptr = netdev->mc_list; - - for (i = 0; i < netdev_mc_count(netdev); i++) { - if (!mc_ptr) - break; - memcpy(mta_list + (i*ETH_ALEN), mc_ptr->dmi_addr, - ETH_ALEN); - mc_ptr = mc_ptr->next; - } + i = 0; + netdev_for_each_mc_addr(mc_ptr, netdev) + memcpy(mta_list + (i++ * ETH_ALEN), mc_ptr->dmi_addr, ETH_ALEN); hw->mac.ops.update_mc_addr_list(hw, mta_list, i, 0, 0); kfree(mta_list); diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c index 0bd5fef22d49..70871b9b045a 100644 --- a/drivers/net/ioc3-eth.c +++ b/drivers/net/ioc3-eth.c @@ -1664,11 +1664,10 @@ static int ioc3_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) static void ioc3_set_multicast_list(struct net_device *dev) { - struct dev_mc_list *dmi = dev->mc_list; + struct dev_mc_list *dmi; struct ioc3_private *ip = netdev_priv(dev); struct ioc3 *ioc3 = ip->regs; u64 ehar = 0; - int i; netif_stop_queue(dev); /* Lock out others. */ @@ -1689,9 +1688,8 @@ static void ioc3_set_multicast_list(struct net_device *dev) ip->ehar_h = 0xffffffff; ip->ehar_l = 0xffffffff; } else { - for (i = 0; i < netdev_mc_count(dev); i++) { + netdev_for_each_mc_addr(dmi, dev) { char *addr = dmi->dmi_addr; - dmi = dmi->next; if (!(*addr & 1)) continue; diff --git a/drivers/net/ipg.c b/drivers/net/ipg.c index 3ca49e348c9d..150415e83f61 100644 --- a/drivers/net/ipg.c +++ b/drivers/net/ipg.c @@ -608,8 +608,7 @@ static void ipg_nic_set_multicast_list(struct net_device *dev) hashtable[1] = 0x00000000; /* Cycle through all multicast addresses to filter. */ - for (mc_list_ptr = dev->mc_list; - mc_list_ptr != NULL; mc_list_ptr = mc_list_ptr->next) { + netdev_for_each_mc_addr(mc_list_ptr, dev) { /* Calculate CRC result for each multicast address. */ hashindex = crc32_le(0xffffffff, mc_list_ptr->dmi_addr, ETH_ALEN); diff --git a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c index bb4a3cda6e4b..d09e4d3a15a6 100644 --- a/drivers/net/isa-skeleton.c +++ b/drivers/net/isa-skeleton.c @@ -666,7 +666,7 @@ set_multicast_list(struct net_device *dev) else if (!netdev_mc_empty(dev)) { /* Walk the address list, and load the filter */ - hardware_set_filter(dev->mc_list); + hardware_set_filter(dev); outw(MULTICAST, ioaddr); } diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c index ff015e15f5d1..966de5d69521 100644 --- a/drivers/net/iseries_veth.c +++ b/drivers/net/iseries_veth.c @@ -961,15 +961,14 @@ static void veth_set_multicast_list(struct net_device *dev) (netdev_mc_count(dev) > VETH_MAX_MCAST)) { port->promiscuous = 1; } else { - struct dev_mc_list *dmi = dev->mc_list; - int i; + struct dev_mc_list *dmi; port->promiscuous = 0; /* Update table */ port->num_mcast = 0; - for (i = 0; i < netdev_mc_count(dev); i++) { + netdev_for_each_mc_addr(dmi, dev) { u8 *addr = dmi->dmi_addr; u64 xaddr = 0; @@ -978,7 +977,6 @@ static void veth_set_multicast_list(struct net_device *dev) port->mcast_addr[port->num_mcast] = xaddr; port->num_mcast++; } - dmi = dmi->next; } } diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c index 93d018505ebb..c9fef65cb98b 100644 --- a/drivers/net/ixgb/ixgb_main.c +++ b/drivers/net/ixgb/ixgb_main.c @@ -1088,10 +1088,9 @@ ixgb_set_multi(struct net_device *netdev) IXGB_WRITE_REG(hw, RCTL, rctl); - for (i = 0, mc_ptr = netdev->mc_list; - mc_ptr; - i++, mc_ptr = mc_ptr->next) - memcpy(&mta[i * IXGB_ETH_LENGTH_OF_ADDRESS], + i = 0; + netdev_for_each_mc_addr(mc_ptr, netdev) + memcpy(&mta[i++ * IXGB_ETH_LENGTH_OF_ADDRESS], mc_ptr->dmi_addr, IXGB_ETH_LENGTH_OF_ADDRESS); ixgb_mc_addr_list_update(hw, mta, netdev_mc_count(netdev), 0); -- cgit v1.2.3 From 9c5f9c2861909753140ad6a41cdc77cdf20c1dc9 Mon Sep 17 00:00:00 2001 From: Atsushi Nemoto Date: Wed, 24 Feb 2010 06:00:17 +0000 Subject: isa-skelton: Remove a wrong netif_wake_queue() call The netif_wake_queue() is called correctly (i.e. only on !txfull condition) from net_tx(). So Unconditional call to the netif_wake_queue() here is wrong. This might cause calling of start_xmit routine on txfull state and trigger tx-ring overflow. This fix is ported from commit 662a96bd6f020782dfbdc0d0bd177c7dbb556687 ("tc35815: Remove a wrong netif_wake_queue() call which triggers BUG_ON"). Signed-off-by: Atsushi Nemoto Signed-off-by: David S. Miller --- drivers/net/isa-skeleton.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/net/isa-skeleton.c') diff --git a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c index d09e4d3a15a6..9e55c3007743 100644 --- a/drivers/net/isa-skeleton.c +++ b/drivers/net/isa-skeleton.c @@ -536,7 +536,6 @@ static irqreturn_t net_interrupt(int irq, void *dev_id) /* Transmit complete. */ net_tx(dev); np->stats.tx_packets++; - netif_wake_queue(dev); } #endif if (status & COUNTERS_INTR) { -- cgit v1.2.3 From 8266d7127c1b0bdf924066c19c71be4d351e9583 Mon Sep 17 00:00:00 2001 From: Jeff Garzik Date: Fri, 26 Feb 2010 12:49:20 -0800 Subject: net: Delete isa-skeleton net driver The ISA skeleton net driver has been obsolete and unmaintained for many years. Any hardware remotely like ISA will use the platform API and look much more like a PCI driver, and make much better use of netdev APIs such as NAPI. Signed-off-by: Jeff Garzik Signed-off-by: David S. Miller --- drivers/net/isa-skeleton.c | 718 --------------------------------------------- 1 file changed, 718 deletions(-) delete mode 100644 drivers/net/isa-skeleton.c (limited to 'drivers/net/isa-skeleton.c') diff --git a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c deleted file mode 100644 index 9e55c3007743..000000000000 --- a/drivers/net/isa-skeleton.c +++ /dev/null @@ -1,718 +0,0 @@ -/* isa-skeleton.c: A network driver outline for linux. - * - * Written 1993-94 by Donald Becker. - * - * Copyright 1993 United States Government as represented by the - * Director, National Security Agency. - * - * This software may be used and distributed according to the terms - * of the GNU General Public License, incorporated herein by reference. - * - * The author may be reached as becker@scyld.com, or C/O - * Scyld Computing Corporation - * 410 Severn Ave., Suite 210 - * Annapolis MD 21403 - * - * This file is an outline for writing a network device driver for the - * the Linux operating system. - * - * To write (or understand) a driver, have a look at the "loopback.c" file to - * get a feel of what is going on, and then use the code below as a skeleton - * for the new driver. - * - */ - -static const char *version = - "isa-skeleton.c:v1.51 9/24/94 Donald Becker (becker@cesdis.gsfc.nasa.gov)\n"; - -/* - * Sources: - * List your sources of programming information to document that - * the driver is your own creation, and give due credit to others - * that contributed to the work. Remember that GNU project code - * cannot use proprietary or trade secret information. Interface - * definitions are generally considered non-copyrightable to the - * extent that the same names and structures must be used to be - * compatible. - * - * Finally, keep in mind that the Linux kernel is has an API, not - * ABI. Proprietary object-code-only distributions are not permitted - * under the GPL. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -/* - * The name of the card. Is used for messages and in the requests for - * io regions, irqs and dma channels - */ -static const char* cardname = "netcard"; - -/* First, a few definitions that the brave might change. */ - -/* A zero-terminated list of I/O addresses to be probed. */ -static unsigned int netcard_portlist[] __initdata = - { 0x200, 0x240, 0x280, 0x2C0, 0x300, 0x320, 0x340, 0}; - -/* use 0 for production, 1 for verification, >2 for debug */ -#ifndef NET_DEBUG -#define NET_DEBUG 2 -#endif -static unsigned int net_debug = NET_DEBUG; - -/* The number of low I/O ports used by the ethercard. */ -#define NETCARD_IO_EXTENT 32 - -#define MY_TX_TIMEOUT ((400*HZ)/1000) - -/* Information that need to be kept for each board. */ -struct net_local { - struct net_device_stats stats; - long open_time; /* Useless example local info. */ - - /* Tx control lock. This protects the transmit buffer ring - * state along with the "tx full" state of the driver. This - * means all netif_queue flow control actions are protected - * by this lock as well. - */ - spinlock_t lock; -}; - -/* The station (ethernet) address prefix, used for IDing the board. */ -#define SA_ADDR0 0x00 -#define SA_ADDR1 0x42 -#define SA_ADDR2 0x65 - -/* Index to functions, as function prototypes. */ - -static int netcard_probe1(struct net_device *dev, int ioaddr); -static int net_open(struct net_device *dev); -static int net_send_packet(struct sk_buff *skb, struct net_device *dev); -static irqreturn_t net_interrupt(int irq, void *dev_id); -static void net_rx(struct net_device *dev); -static int net_close(struct net_device *dev); -static struct net_device_stats *net_get_stats(struct net_device *dev); -static void set_multicast_list(struct net_device *dev); -static void net_tx_timeout(struct net_device *dev); - - -/* Example routines you must write ;->. */ -#define tx_done(dev) 1 -static void hardware_send_packet(short ioaddr, char *buf, int length); -static void chipset_init(struct net_device *dev, int startp); - -/* - * Check for a network adaptor of this type, and return '0' iff one exists. - * If dev->base_addr == 0, probe all likely locations. - * If dev->base_addr == 1, always return failure. - * If dev->base_addr == 2, allocate space for the device and return success - * (detachable devices only). - */ -static int __init do_netcard_probe(struct net_device *dev) -{ - int i; - int base_addr = dev->base_addr; - int irq = dev->irq; - - if (base_addr > 0x1ff) /* Check a single specified location. */ - return netcard_probe1(dev, base_addr); - else if (base_addr != 0) /* Don't probe at all. */ - return -ENXIO; - - for (i = 0; netcard_portlist[i]; i++) { - int ioaddr = netcard_portlist[i]; - if (netcard_probe1(dev, ioaddr) == 0) - return 0; - dev->irq = irq; - } - - return -ENODEV; -} - -static void cleanup_card(struct net_device *dev) -{ -#ifdef jumpered_dma - free_dma(dev->dma); -#endif -#ifdef jumpered_interrupts - free_irq(dev->irq, dev); -#endif - release_region(dev->base_addr, NETCARD_IO_EXTENT); -} - -#ifndef MODULE -struct net_device * __init netcard_probe(int unit) -{ - struct net_device *dev = alloc_etherdev(sizeof(struct net_local)); - int err; - - if (!dev) - return ERR_PTR(-ENOMEM); - - sprintf(dev->name, "eth%d", unit); - netdev_boot_setup_check(dev); - - err = do_netcard_probe(dev); - if (err) - goto out; - return dev; -out: - free_netdev(dev); - return ERR_PTR(err); -} -#endif - -static const struct net_device_ops netcard_netdev_ops = { - .ndo_open = net_open, - .ndo_stop = net_close, - .ndo_start_xmit = net_send_packet, - .ndo_get_stats = net_get_stats, - .ndo_set_multicast_list = set_multicast_list, - .ndo_tx_timeout = net_tx_timeout, - .ndo_validate_addr = eth_validate_addr, - .ndo_set_mac_address = eth_mac_addr, - .ndo_change_mtu = eth_change_mtu, -}; - -/* - * This is the real probe routine. Linux has a history of friendly device - * probes on the ISA bus. A good device probes avoids doing writes, and - * verifies that the correct device exists and functions. - */ -static int __init netcard_probe1(struct net_device *dev, int ioaddr) -{ - struct net_local *np; - static unsigned version_printed; - int i; - int err = -ENODEV; - - /* Grab the region so that no one else tries to probe our ioports. */ - if (!request_region(ioaddr, NETCARD_IO_EXTENT, cardname)) - return -EBUSY; - - /* - * For ethernet adaptors the first three octets of the station address - * contains the manufacturer's unique code. That might be a good probe - * method. Ideally you would add additional checks. - */ - if (inb(ioaddr + 0) != SA_ADDR0 || - inb(ioaddr + 1) != SA_ADDR1 || - inb(ioaddr + 2) != SA_ADDR2) - goto out; - - if (net_debug && version_printed++ == 0) - printk(KERN_DEBUG "%s", version); - - printk(KERN_INFO "%s: %s found at %#3x, ", dev->name, cardname, ioaddr); - - /* Fill in the 'dev' fields. */ - dev->base_addr = ioaddr; - - /* Retrieve and print the ethernet address. */ - for (i = 0; i < 6; i++) - dev->dev_addr[i] = inb(ioaddr + i); - - printk("%pM", dev->dev_addr); - - err = -EAGAIN; -#ifdef jumpered_interrupts - /* - * If this board has jumpered interrupts, allocate the interrupt - * vector now. There is no point in waiting since no other device - * can use the interrupt, and this marks the irq as busy. Jumpered - * interrupts are typically not reported by the boards, and we must - * used autoIRQ to find them. - */ - - if (dev->irq == -1) - ; /* Do nothing: a user-level program will set it. */ - else if (dev->irq < 2) { /* "Auto-IRQ" */ - unsigned long irq_mask = probe_irq_on(); - /* Trigger an interrupt here. */ - - dev->irq = probe_irq_off(irq_mask); - if (net_debug >= 2) - printk(" autoirq is %d", dev->irq); - } else if (dev->irq == 2) - /* - * Fixup for users that don't know that IRQ 2 is really - * IRQ9, or don't know which one to set. - */ - dev->irq = 9; - - { - int irqval = request_irq(dev->irq, net_interrupt, 0, cardname, dev); - if (irqval) { - printk("%s: unable to get IRQ %d (irqval=%d).\n", - dev->name, dev->irq, irqval); - goto out; - } - } -#endif /* jumpered interrupt */ -#ifdef jumpered_dma - /* - * If we use a jumpered DMA channel, that should be probed for and - * allocated here as well. See lance.c for an example. - */ - if (dev->dma == 0) { - if (request_dma(dev->dma, cardname)) { - printk("DMA %d allocation failed.\n", dev->dma); - goto out1; - } else - printk(", assigned DMA %d.\n", dev->dma); - } else { - short dma_status, new_dma_status; - - /* Read the DMA channel status registers. */ - dma_status = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) | - (inb(DMA2_STAT_REG) & 0xf0); - /* Trigger a DMA request, perhaps pause a bit. */ - outw(0x1234, ioaddr + 8); - /* Re-read the DMA status registers. */ - new_dma_status = ((inb(DMA1_STAT_REG) >> 4) & 0x0f) | - (inb(DMA2_STAT_REG) & 0xf0); - /* - * Eliminate the old and floating requests, - * and DMA4 the cascade. - */ - new_dma_status ^= dma_status; - new_dma_status &= ~0x10; - for (i = 7; i > 0; i--) - if (test_bit(i, &new_dma_status)) { - dev->dma = i; - break; - } - if (i <= 0) { - printk("DMA probe failed.\n"); - goto out1; - } - if (request_dma(dev->dma, cardname)) { - printk("probed DMA %d allocation failed.\n", dev->dma); - goto out1; - } - } -#endif /* jumpered DMA */ - - np = netdev_priv(dev); - spin_lock_init(&np->lock); - - dev->netdev_ops = &netcard_netdev_ops; - dev->watchdog_timeo = MY_TX_TIMEOUT; - - err = register_netdev(dev); - if (err) - goto out2; - return 0; -out2: -#ifdef jumpered_dma - free_dma(dev->dma); -#endif -out1: -#ifdef jumpered_interrupts - free_irq(dev->irq, dev); -#endif -out: - release_region(base_addr, NETCARD_IO_EXTENT); - return err; -} - -static void net_tx_timeout(struct net_device *dev) -{ - struct net_local *np = netdev_priv(dev); - - printk(KERN_WARNING "%s: transmit timed out, %s?\n", dev->name, - tx_done(dev) ? "IRQ conflict" : "network cable problem"); - - /* Try to restart the adaptor. */ - chipset_init(dev, 1); - - np->stats.tx_errors++; - - /* If we have space available to accept new transmit - * requests, wake up the queueing layer. This would - * be the case if the chipset_init() call above just - * flushes out the tx queue and empties it. - * - * If instead, the tx queue is retained then the - * netif_wake_queue() call should be placed in the - * TX completion interrupt handler of the driver instead - * of here. - */ - if (!tx_full(dev)) - netif_wake_queue(dev); -} - -/* - * Open/initialize the board. This is called (in the current kernel) - * sometime after booting when the 'ifconfig' program is run. - * - * This routine should set everything up anew at each open, even - * registers that "should" only need to be set once at boot, so that - * there is non-reboot way to recover if something goes wrong. - */ -static int -net_open(struct net_device *dev) -{ - struct net_local *np = netdev_priv(dev); - int ioaddr = dev->base_addr; - /* - * This is used if the interrupt line can turned off (shared). - * See 3c503.c for an example of selecting the IRQ at config-time. - */ - if (request_irq(dev->irq, net_interrupt, 0, cardname, dev)) { - return -EAGAIN; - } - /* - * Always allocate the DMA channel after the IRQ, - * and clean up on failure. - */ - if (request_dma(dev->dma, cardname)) { - free_irq(dev->irq, dev); - return -EAGAIN; - } - - /* Reset the hardware here. Don't forget to set the station address. */ - chipset_init(dev, 1); - outb(0x00, ioaddr); - np->open_time = jiffies; - - /* We are now ready to accept transmit requeusts from - * the queueing layer of the networking. - */ - netif_start_queue(dev); - - return 0; -} - -/* This will only be invoked if your driver is _not_ in XOFF state. - * What this means is that you need not check it, and that this - * invariant will hold if you make sure that the netif_*_queue() - * calls are done at the proper times. - */ -static int net_send_packet(struct sk_buff *skb, struct net_device *dev) -{ - struct net_local *np = netdev_priv(dev); - int ioaddr = dev->base_addr; - short length = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; - unsigned char *buf = skb->data; - - /* If some error occurs while trying to transmit this - * packet, you should return '1' from this function. - * In such a case you _may not_ do anything to the - * SKB, it is still owned by the network queueing - * layer when an error is returned. This means you - * may not modify any SKB fields, you may not free - * the SKB, etc. - */ - -#if TX_RING - /* This is the most common case for modern hardware. - * The spinlock protects this code from the TX complete - * hardware interrupt handler. Queue flow control is - * thus managed under this lock as well. - */ - unsigned long flags; - spin_lock_irqsave(&np->lock, flags); - - add_to_tx_ring(np, skb, length); - dev->trans_start = jiffies; - - /* If we just used up the very last entry in the - * TX ring on this device, tell the queueing - * layer to send no more. - */ - if (tx_full(dev)) - netif_stop_queue(dev); - - /* When the TX completion hw interrupt arrives, this - * is when the transmit statistics are updated. - */ - - spin_unlock_irqrestore(&np->lock, flags); -#else - /* This is the case for older hardware which takes - * a single transmit buffer at a time, and it is - * just written to the device via PIO. - * - * No spin locking is needed since there is no TX complete - * event. If by chance your card does have a TX complete - * hardware IRQ then you may need to utilize np->lock here. - */ - hardware_send_packet(ioaddr, buf, length); - np->stats.tx_bytes += skb->len; - - dev->trans_start = jiffies; - - /* You might need to clean up and record Tx statistics here. */ - if (inw(ioaddr) == /*RU*/81) - np->stats.tx_aborted_errors++; - dev_kfree_skb (skb); -#endif - - return NETDEV_TX_OK; -} - -#if TX_RING -/* This handles TX complete events posted by the device - * via interrupts. - */ -void net_tx(struct net_device *dev) -{ - struct net_local *np = netdev_priv(dev); - int entry; - - /* This protects us from concurrent execution of - * our dev->hard_start_xmit function above. - */ - spin_lock(&np->lock); - - entry = np->tx_old; - while (tx_entry_is_sent(np, entry)) { - struct sk_buff *skb = np->skbs[entry]; - - np->stats.tx_bytes += skb->len; - dev_kfree_skb_irq (skb); - - entry = next_tx_entry(np, entry); - } - np->tx_old = entry; - - /* If we had stopped the queue due to a "tx full" - * condition, and space has now been made available, - * wake up the queue. - */ - if (netif_queue_stopped(dev) && ! tx_full(dev)) - netif_wake_queue(dev); - - spin_unlock(&np->lock); -} -#endif - -/* - * The typical workload of the driver: - * Handle the network interface interrupts. - */ -static irqreturn_t net_interrupt(int irq, void *dev_id) -{ - struct net_device *dev = dev_id; - struct net_local *np; - int ioaddr, status; - int handled = 0; - - ioaddr = dev->base_addr; - - np = netdev_priv(dev); - status = inw(ioaddr + 0); - - if (status == 0) - goto out; - handled = 1; - - if (status & RX_INTR) { - /* Got a packet(s). */ - net_rx(dev); - } -#if TX_RING - if (status & TX_INTR) { - /* Transmit complete. */ - net_tx(dev); - np->stats.tx_packets++; - } -#endif - if (status & COUNTERS_INTR) { - /* Increment the appropriate 'localstats' field. */ - np->stats.tx_window_errors++; - } -out: - return IRQ_RETVAL(handled); -} - -/* We have a good packet(s), get it/them out of the buffers. */ -static void -net_rx(struct net_device *dev) -{ - struct net_local *lp = netdev_priv(dev); - int ioaddr = dev->base_addr; - int boguscount = 10; - - do { - int status = inw(ioaddr); - int pkt_len = inw(ioaddr); - - if (pkt_len == 0) /* Read all the frames? */ - break; /* Done for now */ - - if (status & 0x40) { /* There was an error. */ - lp->stats.rx_errors++; - if (status & 0x20) lp->stats.rx_frame_errors++; - if (status & 0x10) lp->stats.rx_over_errors++; - if (status & 0x08) lp->stats.rx_crc_errors++; - if (status & 0x04) lp->stats.rx_fifo_errors++; - } else { - /* Malloc up new buffer. */ - struct sk_buff *skb; - - lp->stats.rx_bytes+=pkt_len; - - skb = dev_alloc_skb(pkt_len); - if (skb == NULL) { - printk(KERN_NOTICE "%s: Memory squeeze, dropping packet.\n", - dev->name); - lp->stats.rx_dropped++; - break; - } - skb->dev = dev; - - /* 'skb->data' points to the start of sk_buff data area. */ - memcpy(skb_put(skb,pkt_len), (void*)dev->rmem_start, - pkt_len); - /* or */ - insw(ioaddr, skb->data, (pkt_len + 1) >> 1); - - netif_rx(skb); - lp->stats.rx_packets++; - lp->stats.rx_bytes += pkt_len; - } - } while (--boguscount); - - return; -} - -/* The inverse routine to net_open(). */ -static int -net_close(struct net_device *dev) -{ - struct net_local *lp = netdev_priv(dev); - int ioaddr = dev->base_addr; - - lp->open_time = 0; - - netif_stop_queue(dev); - - /* Flush the Tx and disable Rx here. */ - - disable_dma(dev->dma); - - /* If not IRQ or DMA jumpered, free up the line. */ - outw(0x00, ioaddr+0); /* Release the physical interrupt line. */ - - free_irq(dev->irq, dev); - free_dma(dev->dma); - - /* Update the statistics here. */ - - return 0; - -} - -/* - * Get the current statistics. - * This may be called with the card open or closed. - */ -static struct net_device_stats *net_get_stats(struct net_device *dev) -{ - struct net_local *lp = netdev_priv(dev); - short ioaddr = dev->base_addr; - - /* Update the statistics from the device registers. */ - lp->stats.rx_missed_errors = inw(ioaddr+1); - return &lp->stats; -} - -/* - * Set or clear the multicast filter for this adaptor. - * num_addrs == -1 Promiscuous mode, receive all packets - * num_addrs == 0 Normal mode, clear multicast list - * num_addrs > 0 Multicast mode, receive normal and MC packets, - * and do best-effort filtering. - */ -static void -set_multicast_list(struct net_device *dev) -{ - short ioaddr = dev->base_addr; - if (dev->flags&IFF_PROMISC) - { - /* Enable promiscuous mode */ - outw(MULTICAST|PROMISC, ioaddr); - } - else if ((dev->flags&IFF_ALLMULTI) || - netdev_mc_count(dev) > HW_MAX_ADDRS) - { - /* Disable promiscuous mode, use normal mode. */ - hardware_set_filter(NULL); - - outw(MULTICAST, ioaddr); - } - else if (!netdev_mc_empty(dev)) - { - /* Walk the address list, and load the filter */ - hardware_set_filter(dev); - - outw(MULTICAST, ioaddr); - } - else - outw(0, ioaddr); -} - -#ifdef MODULE - -static struct net_device *this_device; -static int io = 0x300; -static int irq; -static int dma; -static int mem; -MODULE_LICENSE("GPL"); - -int init_module(void) -{ - struct net_device *dev; - int result; - - if (io == 0) - printk(KERN_WARNING "%s: You shouldn't use auto-probing with insmod!\n", - cardname); - dev = alloc_etherdev(sizeof(struct net_local)); - if (!dev) - return -ENOMEM; - - /* Copy the parameters from insmod into the device structure. */ - dev->base_addr = io; - dev->irq = irq; - dev->dma = dma; - dev->mem_start = mem; - if (do_netcard_probe(dev) == 0) { - this_device = dev; - return 0; - } - free_netdev(dev); - return -ENXIO; -} - -void -cleanup_module(void) -{ - unregister_netdev(this_device); - cleanup_card(this_device); - free_netdev(this_device); -} - -#endif /* MODULE */ -- cgit v1.2.3