diff options
author | Beniamino Galvani <b.galvani@gmail.com> | 2014-05-11 18:11:47 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-05-13 18:02:24 -0400 |
commit | 775dd682e2b0ec79fa346152c00870d4a3832a47 (patch) | |
tree | 23a7ad244374a73b6b97d7c9f6750bbef1961b07 /drivers/net/ethernet/arc | |
parent | ae8b42c6fc37ca1b7eb30898f5a65196bbb47291 (diff) | |
download | linux-775dd682e2b0ec79fa346152c00870d4a3832a47.tar.gz linux-775dd682e2b0ec79fa346152c00870d4a3832a47.tar.bz2 linux-775dd682e2b0ec79fa346152c00870d4a3832a47.zip |
arc_emac: implement promiscuous mode and multicast filtering
This patch implements the set_rx_mode function to enable/disable
promiscuous or all-multicast modes and to update the multicast
filtering list of the device.
Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/arc')
-rw-r--r-- | drivers/net/ethernet/arc/emac_main.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c index d647a7d115ac..be090e68e1d1 100644 --- a/drivers/net/ethernet/arc/emac_main.c +++ b/drivers/net/ethernet/arc/emac_main.c @@ -13,6 +13,7 @@ * Vineet Gupta */ +#include <linux/crc32.h> #include <linux/etherdevice.h> #include <linux/interrupt.h> #include <linux/io.h> @@ -451,6 +452,41 @@ static int arc_emac_open(struct net_device *ndev) } /** + * arc_emac_set_rx_mode - Change the receive filtering mode. + * @ndev: Pointer to the network device. + * + * This function enables/disables promiscuous or all-multicast mode + * and updates the multicast filtering list of the network device. + */ +static void arc_emac_set_rx_mode(struct net_device *ndev) +{ + struct arc_emac_priv *priv = netdev_priv(ndev); + + if (ndev->flags & IFF_PROMISC) { + arc_reg_or(priv, R_CTRL, PROM_MASK); + } else { + arc_reg_clr(priv, R_CTRL, PROM_MASK); + + if (ndev->flags & IFF_ALLMULTI) { + arc_reg_set(priv, R_LAFL, ~0); + arc_reg_set(priv, R_LAFH, ~0); + } else { + struct netdev_hw_addr *ha; + unsigned int filter[2] = { 0, 0 }; + int bit; + + netdev_for_each_mc_addr(ha, ndev) { + bit = ether_crc_le(ETH_ALEN, ha->addr) >> 26; + filter[bit >> 5] |= 1 << (bit & 31); + } + + arc_reg_set(priv, R_LAFL, filter[0]); + arc_reg_set(priv, R_LAFH, filter[1]); + } + } +} + +/** * arc_emac_stop - Close the network device. * @ndev: Pointer to the network device. * @@ -620,6 +656,7 @@ static const struct net_device_ops arc_emac_netdev_ops = { .ndo_start_xmit = arc_emac_tx, .ndo_set_mac_address = arc_emac_set_address, .ndo_get_stats = arc_emac_stats, + .ndo_set_rx_mode = arc_emac_set_rx_mode, }; static int arc_emac_probe(struct platform_device *pdev) |