Skip to content

Commit 418e7da

Browse files
paulburtondavem330
authored andcommitted
net: pch_gbe: Clean up pch_gbe_set_multi
Refactor pch_gbe_set_multi in order to avoid unnecessary indentation & make it clearer what the code is doing. The one behavioral change from this patch is that we'll no longer configure the MAC address registers for multicast addresses when the IFF_PROMISC or IFF_ALLMULTI flags are set. In these cases, just as when we want to monitor more multicast addresses than we have MAC address registers, we disable multicast filtering so the MAC address registers are unused. Signed-off-by: Paul Burton <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 6ab91e4 commit 418e7da

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2110,28 +2110,27 @@ static void pch_gbe_set_multi(struct net_device *netdev)
21102110

21112111
netdev_dbg(netdev, "netdev->flags : 0x%08x\n", netdev->flags);
21122112

2113-
/* Check for Promiscuous and All Multicast modes */
2113+
/* By default enable address & multicast filtering */
21142114
rctl = ioread32(&hw->reg->RX_MODE);
2115+
rctl |= PCH_GBE_ADD_FIL_EN | PCH_GBE_MLT_FIL_EN;
2116+
2117+
/* Promiscuous mode disables all hardware address filtering */
2118+
if (netdev->flags & IFF_PROMISC)
2119+
rctl &= ~(PCH_GBE_ADD_FIL_EN | PCH_GBE_MLT_FIL_EN);
2120+
2121+
/* If we want to monitor more multicast addresses than the hardware can
2122+
* support then disable hardware multicast filtering.
2123+
*/
21152124
mc_count = netdev_mc_count(netdev);
2116-
if ((netdev->flags & IFF_PROMISC)) {
2117-
rctl &= ~PCH_GBE_ADD_FIL_EN;
2125+
if ((netdev->flags & IFF_ALLMULTI) || mc_count >= PCH_GBE_MAR_ENTRIES)
21182126
rctl &= ~PCH_GBE_MLT_FIL_EN;
2119-
} else if ((netdev->flags & IFF_ALLMULTI)) {
2120-
/* all the multicasting receive permissions */
2121-
rctl |= PCH_GBE_ADD_FIL_EN;
2122-
rctl &= ~PCH_GBE_MLT_FIL_EN;
2123-
} else {
2124-
if (mc_count >= PCH_GBE_MAR_ENTRIES) {
2125-
/* all the multicasting receive permissions */
2126-
rctl |= PCH_GBE_ADD_FIL_EN;
2127-
rctl &= ~PCH_GBE_MLT_FIL_EN;
2128-
} else {
2129-
rctl |= (PCH_GBE_ADD_FIL_EN | PCH_GBE_MLT_FIL_EN);
2130-
}
2131-
}
2127+
21322128
iowrite32(rctl, &hw->reg->RX_MODE);
21332129

2134-
if (mc_count >= PCH_GBE_MAR_ENTRIES)
2130+
/* If we're not using multicast filtering then there's no point
2131+
* configuring the unused MAC address registers.
2132+
*/
2133+
if (!(rctl & PCH_GBE_MLT_FIL_EN))
21352134
return;
21362135

21372136
/* Load the first set of multicast addresses into MAC address registers

0 commit comments

Comments
 (0)