Add callback and update the code to use the rx_mode snapshot and deferred write model
Signed-off-by: I Viswanath <[email protected]> --- In the old cp_set_rx_mode, cp->lock was protecting access to registers at addresses RxConfig, MAR0 and MAR0+4. The lock was probably meant to provide synchronization for cp_set_rx_mode as these registers were accessed exclusively by __cp_set_rx_mode. drivers/net/ethernet/realtek/8139cp.c | 33 +++++++++++++++------------ 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c index 5652da8a178c..ab0395640305 100644 --- a/drivers/net/ethernet/realtek/8139cp.c +++ b/drivers/net/ethernet/realtek/8139cp.c @@ -372,7 +372,6 @@ struct cp_private { } while (0) -static void __cp_set_rx_mode (struct net_device *dev); static void cp_tx (struct cp_private *cp); static void cp_clean_rings (struct cp_private *cp); #ifdef CONFIG_NET_POLL_CONTROLLER @@ -885,30 +884,31 @@ static netdev_tx_t cp_start_xmit (struct sk_buff *skb, /* Set or clear the multicast filter for this adaptor. This routine is not state sensitive and need not be SMP locked. */ -static void __cp_set_rx_mode (struct net_device *dev) +static void cp_write_rx_mode(struct net_device *dev) { struct cp_private *cp = netdev_priv(dev); u32 mc_filter[2]; /* Multicast hash filter */ + char *ha_addr; int rx_mode; + int ni; /* Note: do not reorder, GCC is clever about common statements. */ - if (dev->flags & IFF_PROMISC) { + if (netif_rx_mode_get_cfg(dev, NETIF_RX_MODE_CFG_PROMISC)) { /* Unconditionally log net taps. */ rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys | AcceptAllPhys; mc_filter[1] = mc_filter[0] = 0xffffffff; - } else if ((netdev_mc_count(dev) > multicast_filter_limit) || - (dev->flags & IFF_ALLMULTI)) { + } else if ((netif_rx_mode_mc_count(dev) > multicast_filter_limit) || + netif_rx_mode_get_cfg(dev, NETIF_RX_MODE_CFG_ALLMULTI)) { /* Too many to filter perfectly -- accept all multicasts. */ rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys; mc_filter[1] = mc_filter[0] = 0xffffffff; } else { - struct netdev_hw_addr *ha; rx_mode = AcceptBroadcast | AcceptMyPhys; mc_filter[1] = mc_filter[0] = 0; - netdev_for_each_mc_addr(ha, dev) { - int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; + netif_rx_mode_for_each_mc_addr(ha_addr, dev, ni) { + int bit_nr = ether_crc(ETH_ALEN, ha_addr) >> 26; mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); rx_mode |= AcceptMulticast; @@ -925,12 +925,14 @@ static void __cp_set_rx_mode (struct net_device *dev) static void cp_set_rx_mode (struct net_device *dev) { - unsigned long flags; - struct cp_private *cp = netdev_priv(dev); + bool allmulti = !!(dev->flags & IFF_ALLMULTI); + bool promisc = !!(dev->flags & IFF_PROMISC); - spin_lock_irqsave (&cp->lock, flags); - __cp_set_rx_mode(dev); - spin_unlock_irqrestore (&cp->lock, flags); + netif_rx_mode_set_flag(dev, NETIF_RX_MODE_UC_SKIP, true); + netif_rx_mode_set_flag(dev, NETIF_RX_MODE_MC_SKIP, promisc | allmulti); + + netif_rx_mode_set_cfg(dev, NETIF_RX_MODE_CFG_ALLMULTI, allmulti); + netif_rx_mode_set_cfg(dev, NETIF_RX_MODE_CFG_PROMISC, promisc); } static void __cp_get_stats(struct cp_private *cp) @@ -1040,7 +1042,7 @@ static void cp_init_hw (struct cp_private *cp) cp_start_hw(cp); cpw8(TxThresh, 0x06); /* XXX convert magic num to a constant */ - __cp_set_rx_mode(dev); + netif_schedule_rx_mode_work(dev); cpw32_f (TxConfig, IFG | (TX_DMA_BURST << TxDMAShift)); cpw8(Config1, cpr8(Config1) | DriverLoaded | PMEnable); @@ -1262,7 +1264,7 @@ static void cp_tx_timeout(struct net_device *dev, unsigned int txqueue) cp_clean_rings(cp); cp_init_rings(cp); cp_start_hw(cp); - __cp_set_rx_mode(dev); + netif_schedule_rx_mode_work(dev); cpw16_f(IntrMask, cp_norx_intr_mask); netif_wake_queue(dev); @@ -1870,6 +1872,7 @@ static const struct net_device_ops cp_netdev_ops = { .ndo_validate_addr = eth_validate_addr, .ndo_set_mac_address = cp_set_mac_address, .ndo_set_rx_mode = cp_set_rx_mode, + .ndo_write_rx_mode = cp_write_rx_mode, .ndo_get_stats = cp_get_stats, .ndo_eth_ioctl = cp_ioctl, .ndo_start_xmit = cp_start_xmit, -- 2.47.3
