Commit 91fea585 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller

net/pcmcia: convert to use netdev_for_each_mc_addr

removed fill_multicast_tbl function in smc91c92_cs and do the work inline

rewritten set_addresses function in xirc2ps_cs. This was kinda headache.
Simulated the original and new functions and they bahave the same.
Signed-off-by: default avatarJiri Pirko <jpirko@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2f1eb65f
...@@ -1625,8 +1625,7 @@ static inline void make_mc_bits(u8 *bits, struct net_device *dev) ...@@ -1625,8 +1625,7 @@ static inline void make_mc_bits(u8 *bits, struct net_device *dev)
struct dev_mc_list *dmi; struct dev_mc_list *dmi;
u32 crc; u32 crc;
for (dmi=dev->mc_list; dmi; dmi=dmi->next) { netdev_for_each_mc_addr(dmi, dev) {
crc = ether_crc(ETH_ALEN, dmi->dmi_addr); crc = ether_crc(ETH_ALEN, dmi->dmi_addr);
/* /*
* The 8390 uses the 6 most significant bits of the * The 8390 uses the 6 most significant bits of the
...@@ -1652,7 +1651,7 @@ static void do_set_multicast_list(struct net_device *dev) ...@@ -1652,7 +1651,7 @@ static void do_set_multicast_list(struct net_device *dev)
if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) { if (!(dev->flags&(IFF_PROMISC|IFF_ALLMULTI))) {
memset(ei_local->mcfilter, 0, 8); memset(ei_local->mcfilter, 0, 8);
if (dev->mc_list) if (!netdev_mc_empty(dev))
make_mc_bits(ei_local->mcfilter, dev); make_mc_bits(ei_local->mcfilter, dev);
} else { } else {
/* set to accept-all */ /* set to accept-all */
...@@ -1668,7 +1667,7 @@ static void do_set_multicast_list(struct net_device *dev) ...@@ -1668,7 +1667,7 @@ static void do_set_multicast_list(struct net_device *dev)
if(dev->flags&IFF_PROMISC) if(dev->flags&IFF_PROMISC)
outb_p(E8390_RXCONFIG | 0x58, e8390_base + EN0_RXCR); outb_p(E8390_RXCONFIG | 0x58, e8390_base + EN0_RXCR);
else if(dev->flags&IFF_ALLMULTI || dev->mc_list) else if (dev->flags & IFF_ALLMULTI || !netdev_mc_empty(dev))
outb_p(E8390_RXCONFIG | 0x48, e8390_base + EN0_RXCR); outb_p(E8390_RXCONFIG | 0x48, e8390_base + EN0_RXCR);
else else
outb_p(E8390_RXCONFIG | 0x40, e8390_base + EN0_RXCR); outb_p(E8390_RXCONFIG | 0x40, e8390_base + EN0_RXCR);
......
...@@ -1199,10 +1199,8 @@ static void set_rx_mode(struct net_device *dev) ...@@ -1199,10 +1199,8 @@ static void set_rx_mode(struct net_device *dev)
struct dev_mc_list *mclist; struct dev_mc_list *mclist;
memset(mc_filter, 0, sizeof(mc_filter)); memset(mc_filter, 0, sizeof(mc_filter));
for (i = 0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev); netdev_for_each_mc_addr(mclist, dev) {
i++, mclist = mclist->next) { unsigned int bit = ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26;
unsigned int bit =
ether_crc_le(ETH_ALEN, mclist->dmi_addr) >> 26;
mc_filter[bit >> 3] |= (1 << (bit & 7)); mc_filter[bit >> 3] |= (1 << (bit & 7));
} }
outb(2, ioaddr + RX_MODE); /* Use normal mode. */ outb(2, ioaddr + RX_MODE); /* Use normal mode. */
......
...@@ -1475,8 +1475,7 @@ static void set_multicast_list(struct net_device *dev) ...@@ -1475,8 +1475,7 @@ static void set_multicast_list(struct net_device *dev)
{ {
mace_private *lp = netdev_priv(dev); mace_private *lp = netdev_priv(dev);
int adr[ETHER_ADDR_LEN] = {0}; /* Ethernet address */ int adr[ETHER_ADDR_LEN] = {0}; /* Ethernet address */
int i; struct dev_mc_list *dmi;
struct dev_mc_list *dmi = dev->mc_list;
#ifdef PCMCIA_DEBUG #ifdef PCMCIA_DEBUG
{ {
...@@ -1496,9 +1495,8 @@ static void set_multicast_list(struct net_device *dev) ...@@ -1496,9 +1495,8 @@ static void set_multicast_list(struct net_device *dev)
if (num_addrs > 0) { if (num_addrs > 0) {
/* Calculate multicast logical address filter */ /* Calculate multicast logical address filter */
memset(lp->multicast_ladrf, 0, MACE_LADRF_LEN); memset(lp->multicast_ladrf, 0, MACE_LADRF_LEN);
for (i = 0; i < netdev_mc_count(dev); i++) { netdev_for_each_mc_addr(dmi, dev) {
memcpy(adr, dmi->dmi_addr, ETHER_ADDR_LEN); memcpy(adr, dmi->dmi_addr, ETHER_ADDR_LEN);
dmi = dmi->next;
BuildLAF(lp->multicast_ladrf, adr); BuildLAF(lp->multicast_ladrf, adr);
} }
} }
......
...@@ -1593,27 +1593,6 @@ static void smc_rx(struct net_device *dev) ...@@ -1593,27 +1593,6 @@ static void smc_rx(struct net_device *dev)
return; return;
} }
/*======================================================================
Calculate values for the hardware multicast filter hash table.
======================================================================*/
static void fill_multicast_tbl(int count, struct dev_mc_list *addrs,
u_char *multicast_table)
{
struct dev_mc_list *mc_addr;
for (mc_addr = addrs; mc_addr && count-- > 0; mc_addr = mc_addr->next) {
u_int position = ether_crc(6, mc_addr->dmi_addr);
#ifndef final_version /* Verify multicast address. */
if ((mc_addr->dmi_addr[0] & 1) == 0)
continue;
#endif
multicast_table[position >> 29] |= 1 << ((position >> 26) & 7);
}
}
/*====================================================================== /*======================================================================
Set the receive mode. Set the receive mode.
...@@ -1639,8 +1618,16 @@ static void set_rx_mode(struct net_device *dev) ...@@ -1639,8 +1618,16 @@ static void set_rx_mode(struct net_device *dev)
rx_cfg_setting = RxStripCRC | RxEnable | RxAllMulti; rx_cfg_setting = RxStripCRC | RxEnable | RxAllMulti;
else { else {
if (!netdev_mc_empty(dev)) { if (!netdev_mc_empty(dev)) {
fill_multicast_tbl(netdev_mc_count(dev), dev->mc_list, struct dev_mc_list *mc_addr;
(u_char *)multicast_table);
netdev_for_each_mc_addr(mc_addr, dev) {
u_int position = ether_crc(6, mc_addr->dmi_addr);
#ifndef final_version /* Verify multicast address. */
if ((mc_addr->dmi_addr[0] & 1) == 0)
continue;
#endif
multicast_table[position >> 29] |= 1 << ((position >> 26) & 7);
}
} }
rx_cfg_setting = RxStripCRC | RxEnable; rx_cfg_setting = RxStripCRC | RxEnable;
} }
......
...@@ -1364,46 +1364,62 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1364,46 +1364,62 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev)
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
struct set_address_info {
int reg_nr;
int page_nr;
int mohawk;
unsigned int ioaddr;
};
static void set_address(struct set_address_info *sa_info, char *addr)
{
unsigned int ioaddr = sa_info->ioaddr;
int i;
for (i = 0; i < 6; i++) {
if (sa_info->reg_nr > 15) {
sa_info->reg_nr = 8;
sa_info->page_nr++;
SelectPage(sa_info->page_nr);
}
if (sa_info->mohawk)
PutByte(sa_info->reg_nr++, addr[5 - i]);
else
PutByte(sa_info->reg_nr++, addr[i]);
}
}
/**************** /****************
* Set all addresses: This first one is the individual address, * Set all addresses: This first one is the individual address,
* the next 9 addresses are taken from the multicast list and * the next 9 addresses are taken from the multicast list and
* the rest is filled with the individual address. * the rest is filled with the individual address.
*/ */
static void static void set_addresses(struct net_device *dev)
set_addresses(struct net_device *dev)
{ {
unsigned int ioaddr = dev->base_addr; unsigned int ioaddr = dev->base_addr;
local_info_t *lp = netdev_priv(dev); local_info_t *lp = netdev_priv(dev);
struct dev_mc_list *dmi = dev->mc_list; struct dev_mc_list *dmi;
unsigned char *addr; struct set_address_info sa_info;
int i,j,k,n; int i;
SelectPage(k=0x50);
for (i=0,j=8,n=0; ; i++, j++) {
if (i > 5) {
if (++n > 9)
break;
i = 0;
if (n > 1 && n <= netdev_mc_count(dev) && dmi) {
dmi = dmi->next;
}
}
if (j > 15) {
j = 8;
k++;
SelectPage(k);
}
if (n && n <= netdev_mc_count(dev) && dmi) /*
addr = dmi->dmi_addr; * Setup the info structure so that by first set_address call it will do
else * SelectPage with the right page number. Hence these ones here.
addr = dev->dev_addr; */
sa_info.reg_nr = 15 + 1;
sa_info.page_nr = 0x50 - 1;
sa_info.mohawk = lp->mohawk;
sa_info.ioaddr = ioaddr;
if (lp->mohawk) set_address(&sa_info, dev->dev_addr);
PutByte(j, addr[5-i]); i = 0;
else netdev_for_each_mc_addr(dmi, dev) {
PutByte(j, addr[i]); if (i++ == 9)
break;
set_address(&sa_info, dmi->dmi_addr);
} }
while (i++ < 9)
set_address(&sa_info, dev->dev_addr);
SelectPage(0); SelectPage(0);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment