Commit 4e831836 authored by Sascha Hauer's avatar Sascha Hauer Committed by David S. Miller

fec: refactor set_multicast_list() to make it more readable

Signed-off-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 22f6b860
...@@ -1517,57 +1517,60 @@ static void set_multicast_list(struct net_device *dev) ...@@ -1517,57 +1517,60 @@ static void set_multicast_list(struct net_device *dev)
tmp = readl(fep->hwp + FEC_R_CNTRL); tmp = readl(fep->hwp + FEC_R_CNTRL);
tmp |= 0x8; tmp |= 0x8;
writel(tmp, fep->hwp + FEC_R_CNTRL); writel(tmp, fep->hwp + FEC_R_CNTRL);
} else { return;
tmp = readl(fep->hwp + FEC_R_CNTRL); }
tmp &= ~0x8;
writel(tmp, fep->hwp + FEC_R_CNTRL);
if (dev->flags & IFF_ALLMULTI) { tmp = readl(fep->hwp + FEC_R_CNTRL);
/* Catch all multicast addresses, so set the tmp &= ~0x8;
* filter to all 1's writel(tmp, fep->hwp + FEC_R_CNTRL);
*/
writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_HIGH); if (dev->flags & IFF_ALLMULTI) {
writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_LOW); /* Catch all multicast addresses, so set the
} else { * filter to all 1's
/* Clear filter and add the addresses in hash register */
*/ writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH); writel(0xffffffff, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
return;
dmi = dev->mc_list; }
for (j = 0; j < dev->mc_count; j++, dmi = dmi->next) { /* Clear filter and add the addresses in hash register
/* Only support group multicast for now */ */
if (!(dmi->dmi_addr[0] & 1)) writel(0, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
continue; writel(0, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
/* calculate crc32 value of mac address */ dmi = dev->mc_list;
crc = 0xffffffff;
for (j = 0; j < dev->mc_count; j++, dmi = dmi->next) {
for (i = 0; i < dmi->dmi_addrlen; i++) { /* Only support group multicast for now */
data = dmi->dmi_addr[i]; if (!(dmi->dmi_addr[0] & 1))
for (bit = 0; bit < 8; bit++, data >>= 1) { continue;
crc = (crc >> 1) ^
(((crc ^ data) & 1) ? CRC32_POLY : 0); /* calculate crc32 value of mac address */
} crc = 0xffffffff;
}
for (i = 0; i < dmi->dmi_addrlen; i++) {
/* only upper 6 bits (HASH_BITS) are used data = dmi->dmi_addr[i];
* which point to specific bit in he hash registers for (bit = 0; bit < 8; bit++, data >>= 1) {
*/ crc = (crc >> 1) ^
hash = (crc >> (32 - HASH_BITS)) & 0x3f; (((crc ^ data) & 1) ? CRC32_POLY : 0);
if (hash > 31) {
tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
tmp |= 1 << (hash - 32);
writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
} else {
tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_LOW);
tmp |= 1 << hash;
writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
}
} }
} }
/* only upper 6 bits (HASH_BITS) are used
* which point to specific bit in he hash registers
*/
hash = (crc >> (32 - HASH_BITS)) & 0x3f;
if (hash > 31) {
tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
tmp |= 1 << (hash - 32);
writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_HIGH);
} else {
tmp = readl(fep->hwp + FEC_GRP_HASH_TABLE_LOW);
tmp |= 1 << hash;
writel(tmp, fep->hwp + FEC_GRP_HASH_TABLE_LOW);
}
} }
} }
......
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