* [PATCH 1/2] arc_emac: implement promiscuous mode and multicast filtering
2014-05-11 16:11 [PATCH 0/2] arc_emac: promiscuous/multicast mode and netpoll support Beniamino Galvani
@ 2014-05-11 16:11 ` Beniamino Galvani
2014-05-11 16:11 ` [PATCH 2/2] arc_emac: add netpoll support Beniamino Galvani
2014-05-13 22:03 ` [PATCH 0/2] arc_emac: promiscuous/multicast mode and " David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Beniamino Galvani @ 2014-05-11 16:11 UTC (permalink / raw)
To: David S. Miller; +Cc: Alexey Brodkin, netdev, linux-kernel, Beniamino Galvani
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>
---
drivers/net/ethernet/arc/emac_main.c | 37 ++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index 9f45782..12fc810 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)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] arc_emac: add netpoll support
2014-05-11 16:11 [PATCH 0/2] arc_emac: promiscuous/multicast mode and netpoll support Beniamino Galvani
2014-05-11 16:11 ` [PATCH 1/2] arc_emac: implement promiscuous mode and multicast filtering Beniamino Galvani
@ 2014-05-11 16:11 ` Beniamino Galvani
2014-05-13 22:03 ` [PATCH 0/2] arc_emac: promiscuous/multicast mode and " David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Beniamino Galvani @ 2014-05-11 16:11 UTC (permalink / raw)
To: David S. Miller; +Cc: Alexey Brodkin, netdev, linux-kernel, Beniamino Galvani
Signed-off-by: Beniamino Galvani <b.galvani@gmail.com>
---
drivers/net/ethernet/arc/emac_main.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index 12fc810..6a1e589 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -363,6 +363,15 @@ static irqreturn_t arc_emac_intr(int irq, void *dev_instance)
return IRQ_HANDLED;
}
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void arc_emac_poll_controller(struct net_device *dev)
+{
+ disable_irq(dev->irq);
+ arc_emac_intr(dev->irq, dev);
+ enable_irq(dev->irq);
+}
+#endif
+
/**
* arc_emac_open - Open the network device.
* @ndev: Pointer to the network device.
@@ -657,6 +666,9 @@ static const struct net_device_ops arc_emac_netdev_ops = {
.ndo_set_mac_address = arc_emac_set_address,
.ndo_get_stats = arc_emac_stats,
.ndo_set_rx_mode = arc_emac_set_rx_mode,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = arc_emac_poll_controller,
+#endif
};
static int arc_emac_probe(struct platform_device *pdev)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread