Commit 81cd17a4 authored by Heiner Kallweit's avatar Heiner Kallweit Committed by David S. Miller

r8169: improve rtl_set_rx_mode

This patch improves and simplifies rtl_set_rx_mode a little.
No functional change intended.
Signed-off-by: default avatarHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ce599b1a
...@@ -61,7 +61,7 @@ ...@@ -61,7 +61,7 @@
/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
The RTL chips use a 64 element hash table based on the Ethernet CRC. */ The RTL chips use a 64 element hash table based on the Ethernet CRC. */
static const int multicast_filter_limit = 32; #define MC_FILTER_LIMIT 32
#define TX_DMA_BURST 7 /* Maximum PCI burst, '7' is unlimited */ #define TX_DMA_BURST 7 /* Maximum PCI burst, '7' is unlimited */
#define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */ #define InterFrameGap 0x03 /* 3 means InterFrameGap = the shortest one */
...@@ -4146,54 +4146,46 @@ static void rtl8169_set_magic_reg(struct rtl8169_private *tp, unsigned mac_versi ...@@ -4146,54 +4146,46 @@ static void rtl8169_set_magic_reg(struct rtl8169_private *tp, unsigned mac_versi
static void rtl_set_rx_mode(struct net_device *dev) static void rtl_set_rx_mode(struct net_device *dev)
{ {
u32 rx_mode = AcceptBroadcast | AcceptMyPhys | AcceptMulticast;
/* Multicast hash filter */
u32 mc_filter[2] = { 0xffffffff, 0xffffffff };
struct rtl8169_private *tp = netdev_priv(dev); struct rtl8169_private *tp = netdev_priv(dev);
u32 mc_filter[2]; /* Multicast hash filter */ u32 tmp;
int rx_mode;
u32 tmp = 0;
if (dev->flags & IFF_PROMISC) { if (dev->flags & IFF_PROMISC) {
/* Unconditionally log net taps. */ /* Unconditionally log net taps. */
netif_notice(tp, link, dev, "Promiscuous mode enabled\n"); netif_notice(tp, link, dev, "Promiscuous mode enabled\n");
rx_mode = rx_mode |= AcceptAllPhys;
AcceptBroadcast | AcceptMulticast | AcceptMyPhys | } else if (netdev_mc_count(dev) > MC_FILTER_LIMIT ||
AcceptAllPhys; dev->flags & IFF_ALLMULTI ||
mc_filter[1] = mc_filter[0] = 0xffffffff; tp->mac_version == RTL_GIGA_MAC_VER_35) {
} else if ((netdev_mc_count(dev) > multicast_filter_limit) || /* accept all multicasts */
(dev->flags & IFF_ALLMULTI)) { } else if (netdev_mc_empty(dev)) {
/* Too many to filter perfectly -- accept all multicasts. */ rx_mode &= ~AcceptMulticast;
rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
mc_filter[1] = mc_filter[0] = 0xffffffff;
} else { } else {
struct netdev_hw_addr *ha; struct netdev_hw_addr *ha;
rx_mode = AcceptBroadcast | AcceptMyPhys;
mc_filter[1] = mc_filter[0] = 0; mc_filter[1] = mc_filter[0] = 0;
netdev_for_each_mc_addr(ha, dev) { netdev_for_each_mc_addr(ha, dev) {
int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; u32 bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26;
mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); mc_filter[bit_nr >> 5] |= BIT(bit_nr & 31);
rx_mode |= AcceptMulticast;
} }
}
if (dev->features & NETIF_F_RXALL)
rx_mode |= (AcceptErr | AcceptRunt);
tmp = (RTL_R32(tp, RxConfig) & ~RX_CONFIG_ACCEPT_MASK) | rx_mode;
if (tp->mac_version > RTL_GIGA_MAC_VER_06) { if (tp->mac_version > RTL_GIGA_MAC_VER_06) {
u32 data = mc_filter[0]; tmp = mc_filter[0];
mc_filter[0] = swab32(mc_filter[1]); mc_filter[0] = swab32(mc_filter[1]);
mc_filter[1] = swab32(data); mc_filter[1] = swab32(tmp);
}
} }
if (tp->mac_version == RTL_GIGA_MAC_VER_35) if (dev->features & NETIF_F_RXALL)
mc_filter[1] = mc_filter[0] = 0xffffffff; rx_mode |= (AcceptErr | AcceptRunt);
RTL_W32(tp, MAR0 + 4, mc_filter[1]); RTL_W32(tp, MAR0 + 4, mc_filter[1]);
RTL_W32(tp, MAR0 + 0, mc_filter[0]); RTL_W32(tp, MAR0 + 0, mc_filter[0]);
RTL_W32(tp, RxConfig, tmp); tmp = RTL_R32(tp, RxConfig);
RTL_W32(tp, RxConfig, (tmp & ~RX_CONFIG_ACCEPT_MASK) | rx_mode);
} }
DECLARE_RTL_COND(rtl_csiar_cond) DECLARE_RTL_COND(rtl_csiar_cond)
......
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