net: convert multiple drivers to use netdev_for_each_mc_addr
Signed-off-by: Jiri Pirko <jpirko@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
d7b855c2dc
commit
e1d444771e
@@ -320,7 +320,6 @@ static int cpmac_config(struct net_device *dev, struct ifmap *map)
|
|||||||
static void cpmac_set_multicast_list(struct net_device *dev)
|
static void cpmac_set_multicast_list(struct net_device *dev)
|
||||||
{
|
{
|
||||||
struct dev_mc_list *iter;
|
struct dev_mc_list *iter;
|
||||||
int i;
|
|
||||||
u8 tmp;
|
u8 tmp;
|
||||||
u32 mbp, bit, hash[2] = { 0, };
|
u32 mbp, bit, hash[2] = { 0, };
|
||||||
struct cpmac_priv *priv = netdev_priv(dev);
|
struct cpmac_priv *priv = netdev_priv(dev);
|
||||||
@@ -340,8 +339,7 @@ static void cpmac_set_multicast_list(struct net_device *dev)
|
|||||||
* cpmac uses some strange mac address hashing
|
* cpmac uses some strange mac address hashing
|
||||||
* (not crc32)
|
* (not crc32)
|
||||||
*/
|
*/
|
||||||
for (i = 0, iter = dev->mc_list; i < netdev_mc_count(dev);
|
netdev_for_each_mc_addr(iter, dev) {
|
||||||
i++, iter = iter->next) {
|
|
||||||
bit = 0;
|
bit = 0;
|
||||||
tmp = iter->dmi_addr[0];
|
tmp = iter->dmi_addr[0];
|
||||||
bit ^= (tmp >> 2) ^ (tmp << 4);
|
bit ^= (tmp >> 2) ^ (tmp << 4);
|
||||||
|
@@ -1596,13 +1596,12 @@ set_multicast_list(struct net_device *dev)
|
|||||||
} else {
|
} else {
|
||||||
/* MC mode, receive normal and MC packets */
|
/* MC mode, receive normal and MC packets */
|
||||||
char hash_ix;
|
char hash_ix;
|
||||||
struct dev_mc_list *dmi = dev->mc_list;
|
struct dev_mc_list *dmi;
|
||||||
int i;
|
|
||||||
char *baddr;
|
char *baddr;
|
||||||
|
|
||||||
lo_bits = 0x00000000ul;
|
lo_bits = 0x00000000ul;
|
||||||
hi_bits = 0x00000000ul;
|
hi_bits = 0x00000000ul;
|
||||||
for (i = 0; i < num_addr; i++) {
|
netdev_for_each_mc_addr(dmi, dev) {
|
||||||
/* Calculate the hash index for the GA registers */
|
/* Calculate the hash index for the GA registers */
|
||||||
|
|
||||||
hash_ix = 0;
|
hash_ix = 0;
|
||||||
@@ -1632,7 +1631,6 @@ set_multicast_list(struct net_device *dev)
|
|||||||
} else {
|
} else {
|
||||||
lo_bits |= (1 << hash_ix);
|
lo_bits |= (1 << hash_ix);
|
||||||
}
|
}
|
||||||
dmi = dmi->next;
|
|
||||||
}
|
}
|
||||||
/* Disable individual receive */
|
/* Disable individual receive */
|
||||||
SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, discard);
|
SETS(network_rec_config_shadow, R_NETWORK_REC_CONFIG, individual, discard);
|
||||||
|
@@ -1785,7 +1785,7 @@ static void set_multicast_list(struct net_device *dev)
|
|||||||
{
|
{
|
||||||
lp->rx_mode = RX_ALL_ACCEPT;
|
lp->rx_mode = RX_ALL_ACCEPT;
|
||||||
}
|
}
|
||||||
else if((dev->flags&IFF_ALLMULTI)||dev->mc_list)
|
else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev))
|
||||||
{
|
{
|
||||||
/* The multicast-accept list is initialized to accept-all, and we
|
/* The multicast-accept list is initialized to accept-all, and we
|
||||||
rely on higher-level filtering for now. */
|
rely on higher-level filtering for now. */
|
||||||
|
@@ -940,9 +940,8 @@ static void lance_load_multicast(struct net_device *dev)
|
|||||||
{
|
{
|
||||||
struct lance_private *lp = netdev_priv(dev);
|
struct lance_private *lp = netdev_priv(dev);
|
||||||
volatile u16 *ib = (volatile u16 *)dev->mem_start;
|
volatile u16 *ib = (volatile u16 *)dev->mem_start;
|
||||||
struct dev_mc_list *dmi = dev->mc_list;
|
struct dev_mc_list *dmi;
|
||||||
char *addrs;
|
char *addrs;
|
||||||
int i;
|
|
||||||
u32 crc;
|
u32 crc;
|
||||||
|
|
||||||
/* set all multicast bits */
|
/* set all multicast bits */
|
||||||
@@ -960,9 +959,8 @@ static void lance_load_multicast(struct net_device *dev)
|
|||||||
*lib_ptr(ib, filter[3], lp->type) = 0;
|
*lib_ptr(ib, filter[3], lp->type) = 0;
|
||||||
|
|
||||||
/* Add addresses */
|
/* Add addresses */
|
||||||
for (i = 0; i < netdev_mc_count(dev); i++) {
|
netdev_for_each_mc_addr(dmi, dev) {
|
||||||
addrs = dmi->dmi_addr;
|
addrs = dmi->dmi_addr;
|
||||||
dmi = dmi->next;
|
|
||||||
|
|
||||||
/* multicast address? */
|
/* multicast address? */
|
||||||
if (!(*addrs & 1))
|
if (!(*addrs & 1))
|
||||||
|
@@ -2240,12 +2240,11 @@ static void dfx_ctl_set_multicast_list(struct net_device *dev)
|
|||||||
|
|
||||||
/* Copy addresses to multicast address table, then update adapter CAM */
|
/* Copy addresses to multicast address table, then update adapter CAM */
|
||||||
|
|
||||||
dmi = dev->mc_list; /* point to first multicast addr */
|
i = 0;
|
||||||
for (i=0; i < bp->mc_count; i++)
|
netdev_for_each_mc_addr(dmi, dev)
|
||||||
{
|
memcpy(&bp->mc_table[i++ * FDDI_K_ALEN],
|
||||||
memcpy(&bp->mc_table[i*FDDI_K_ALEN], dmi->dmi_addr, FDDI_K_ALEN);
|
dmi->dmi_addr, FDDI_K_ALEN);
|
||||||
dmi = dmi->next; /* point to next multicast addr */
|
|
||||||
}
|
|
||||||
if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
|
if (dfx_ctl_update_cam(bp) != DFX_K_SUCCESS)
|
||||||
{
|
{
|
||||||
DBG_printk("%s: Could not update multicast address table!\n", dev->name);
|
DBG_printk("%s: Could not update multicast address table!\n", dev->name);
|
||||||
|
@@ -1287,9 +1287,8 @@ static void SetMulticastFilter(struct net_device *dev)
|
|||||||
lp->init_block.mcast_table[i] = 0;
|
lp->init_block.mcast_table[i] = 0;
|
||||||
}
|
}
|
||||||
/* Add multicast addresses */
|
/* Add multicast addresses */
|
||||||
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;
|
addrs = dmi->dmi_addr;
|
||||||
dmi = dmi->next;
|
|
||||||
if ((*addrs & 0x01) == 1) { /* multicast address? */
|
if ((*addrs & 0x01) == 1) { /* multicast address? */
|
||||||
crc = ether_crc(ETH_ALEN, addrs);
|
crc = ether_crc(ETH_ALEN, addrs);
|
||||||
hashcode = (crc & 1); /* hashcode is 6 LSb of CRC ... */
|
hashcode = (crc & 1); /* hashcode is 6 LSb of CRC ... */
|
||||||
|
@@ -1132,15 +1132,12 @@ set_multicast (struct net_device *dev)
|
|||||||
/* Receive broadcast and multicast frames */
|
/* Receive broadcast and multicast frames */
|
||||||
rx_mode = ReceiveBroadcast | ReceiveMulticast | ReceiveUnicast;
|
rx_mode = ReceiveBroadcast | ReceiveMulticast | ReceiveUnicast;
|
||||||
} else if (!netdev_mc_empty(dev)) {
|
} else if (!netdev_mc_empty(dev)) {
|
||||||
int i;
|
|
||||||
struct dev_mc_list *mclist;
|
struct dev_mc_list *mclist;
|
||||||
/* Receive broadcast frames and multicast frames filtering
|
/* Receive broadcast frames and multicast frames filtering
|
||||||
by Hashtable */
|
by Hashtable */
|
||||||
rx_mode =
|
rx_mode =
|
||||||
ReceiveBroadcast | ReceiveMulticastHash | ReceiveUnicast;
|
ReceiveBroadcast | ReceiveMulticastHash | ReceiveUnicast;
|
||||||
for (i=0, mclist = dev->mc_list; mclist && i < netdev_mc_count(dev);
|
netdev_for_each_mc_addr(mclist, dev) {
|
||||||
i++, mclist=mclist->next)
|
|
||||||
{
|
|
||||||
int bit, index = 0;
|
int bit, index = 0;
|
||||||
int crc = ether_crc_le (ETH_ALEN, mclist->dmi_addr);
|
int crc = ether_crc_le (ETH_ALEN, mclist->dmi_addr);
|
||||||
/* The inverted high significant 6 bits of CRC are
|
/* The inverted high significant 6 bits of CRC are
|
||||||
|
@@ -724,8 +724,7 @@ static void
|
|||||||
dm9000_hash_table(struct net_device *dev)
|
dm9000_hash_table(struct net_device *dev)
|
||||||
{
|
{
|
||||||
board_info_t *db = netdev_priv(dev);
|
board_info_t *db = netdev_priv(dev);
|
||||||
struct dev_mc_list *mcptr = dev->mc_list;
|
struct dev_mc_list *mcptr;
|
||||||
int mc_cnt = netdev_mc_count(dev);
|
|
||||||
int i, oft;
|
int i, oft;
|
||||||
u32 hash_val;
|
u32 hash_val;
|
||||||
u16 hash_table[4];
|
u16 hash_table[4];
|
||||||
@@ -753,7 +752,7 @@ dm9000_hash_table(struct net_device *dev)
|
|||||||
rcr |= RCR_ALL;
|
rcr |= RCR_ALL;
|
||||||
|
|
||||||
/* the multicast address in Hash Table : 64 bits */
|
/* the multicast address in Hash Table : 64 bits */
|
||||||
for (i = 0; i < mc_cnt; i++, mcptr = mcptr->next) {
|
netdev_for_each_mc_addr(mcptr, dev) {
|
||||||
hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
|
hash_val = ether_crc_le(6, mcptr->dmi_addr) & 0x3f;
|
||||||
hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
|
hash_table[hash_val / 16] |= (u16) 1 << (hash_val % 16);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user