Skip to content

Commit f79bfda

Browse files
joabreudavem330
authored andcommitted
net: stmmac: dwmac4: Always update the MAC Hash Filter
We need to always update the MAC Hash Filter so that previous entries are invalidated. Found out while running stmmac selftests. Fixes: b8ef702 ("net: stmmac: add support for hash table size 128/256 in dwmac4") Signed-off-by: Jose Abreu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 432439f commit f79bfda

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,8 +401,11 @@ static void dwmac4_set_filter(struct mac_device_info *hw,
401401
int numhashregs = (hw->multicast_filter_bins >> 5);
402402
int mcbitslog2 = hw->mcast_bits_log2;
403403
unsigned int value;
404+
u32 mc_filter[8];
404405
int i;
405406

407+
memset(mc_filter, 0, sizeof(mc_filter));
408+
406409
value = readl(ioaddr + GMAC_PACKET_FILTER);
407410
value &= ~GMAC_PACKET_FILTER_HMC;
408411
value &= ~GMAC_PACKET_FILTER_HPF;
@@ -416,16 +419,13 @@ static void dwmac4_set_filter(struct mac_device_info *hw,
416419
/* Pass all multi */
417420
value |= GMAC_PACKET_FILTER_PM;
418421
/* Set all the bits of the HASH tab */
419-
for (i = 0; i < numhashregs; i++)
420-
writel(0xffffffff, ioaddr + GMAC_HASH_TAB(i));
422+
memset(mc_filter, 0xff, sizeof(mc_filter));
421423
} else if (!netdev_mc_empty(dev)) {
422424
struct netdev_hw_addr *ha;
423-
u32 mc_filter[8];
424425

425426
/* Hash filter for multicast */
426427
value |= GMAC_PACKET_FILTER_HMC;
427428

428-
memset(mc_filter, 0, sizeof(mc_filter));
429429
netdev_for_each_mc_addr(ha, dev) {
430430
/* The upper n bits of the calculated CRC are used to
431431
* index the contents of the hash table. The number of
@@ -440,10 +440,11 @@ static void dwmac4_set_filter(struct mac_device_info *hw,
440440
*/
441441
mc_filter[bit_nr >> 5] |= (1 << (bit_nr & 0x1f));
442442
}
443-
for (i = 0; i < numhashregs; i++)
444-
writel(mc_filter[i], ioaddr + GMAC_HASH_TAB(i));
445443
}
446444

445+
for (i = 0; i < numhashregs; i++)
446+
writel(mc_filter[i], ioaddr + GMAC_HASH_TAB(i));
447+
447448
value |= GMAC_PACKET_FILTER_HPF;
448449

449450
/* Handle multiple unicast addresses */

0 commit comments

Comments
 (0)