* [PATCH] net: sun4i-emac: add promiscuous support
@ 2014-04-11 9:46 Marc Zyngier
[not found] ` <1397209577-24443-1-git-send-email-marc.zyngier-5wv7dgnIgG8@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Marc Zyngier @ 2014-04-11 9:46 UTC (permalink / raw)
To: linux-sunxi, netdev; +Cc: Stefan Roese, Maxime Ripard
The sun4i-emac driver is rather primitive, and doesn't support
promiscuous mode. This makes usage such as bridging impossible,
which is a shame on virtualization capable HW such as the
Allwinner A20.
The fix is fairly simple: move the RX setup code to the ndo_set_rx_mode
vector, and add the required HW configuration when IFF_PROMISC is passed
by the core code.
This has been tested on a generic A20 box running a few virtual
machines hanging off a bridge with the EMAC chip as the link to the
outside world.
Cc: Stefan Roese <sr@denx.de>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
---
drivers/net/ethernet/allwinner/sun4i-emac.c | 30 ++++++++++++++++++++---------
1 file changed, 21 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 511f6ee..6343beb 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -268,15 +268,6 @@ static unsigned int emac_setup(struct net_device *ndev)
writel(reg_val | EMAC_TX_MODE_ABORTED_FRAME_EN,
db->membase + EMAC_TX_MODE_REG);
- /* set up RX */
- reg_val = readl(db->membase + EMAC_RX_CTL_REG);
-
- writel(reg_val | EMAC_RX_CTL_PASS_LEN_OOR_EN |
- EMAC_RX_CTL_ACCEPT_UNICAST_EN | EMAC_RX_CTL_DA_FILTER_EN |
- EMAC_RX_CTL_ACCEPT_MULTICAST_EN |
- EMAC_RX_CTL_ACCEPT_BROADCAST_EN,
- db->membase + EMAC_RX_CTL_REG);
-
/* set MAC */
/* set MAC CTL0 */
reg_val = readl(db->membase + EMAC_MAC_CTL0_REG);
@@ -309,6 +300,26 @@ static unsigned int emac_setup(struct net_device *ndev)
return 0;
}
+static void emac_set_rx_mode(struct net_device *ndev)
+{
+ struct emac_board_info *db = netdev_priv(ndev);
+ unsigned int reg_val;
+
+ /* set up RX */
+ reg_val = readl(db->membase + EMAC_RX_CTL_REG);
+
+ if (ndev->flags & IFF_PROMISC)
+ reg_val |= EMAC_RX_CTL_PASS_ALL_EN;
+ else
+ reg_val &= ~EMAC_RX_CTL_PASS_ALL_EN;
+
+ writel(reg_val | EMAC_RX_CTL_PASS_LEN_OOR_EN |
+ EMAC_RX_CTL_ACCEPT_UNICAST_EN | EMAC_RX_CTL_DA_FILTER_EN |
+ EMAC_RX_CTL_ACCEPT_MULTICAST_EN |
+ EMAC_RX_CTL_ACCEPT_BROADCAST_EN,
+ db->membase + EMAC_RX_CTL_REG);
+}
+
static unsigned int emac_powerup(struct net_device *ndev)
{
struct emac_board_info *db = netdev_priv(ndev);
@@ -782,6 +793,7 @@ static const struct net_device_ops emac_netdev_ops = {
.ndo_stop = emac_stop,
.ndo_start_xmit = emac_start_xmit,
.ndo_tx_timeout = emac_timeout,
+ .ndo_set_rx_mode = emac_set_rx_mode,
.ndo_do_ioctl = emac_ioctl,
.ndo_change_mtu = eth_change_mtu,
.ndo_validate_addr = eth_validate_addr,
--
1.8.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: sun4i-emac: add promiscuous support
[not found] ` <1397209577-24443-1-git-send-email-marc.zyngier-5wv7dgnIgG8@public.gmane.org>
@ 2014-04-11 9:55 ` Stefan Roese
2014-04-12 6:01 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Roese @ 2014-04-11 9:55 UTC (permalink / raw)
To: Marc Zyngier, linux-sunxi-/JYPxA39Uh5TLH3MbocFFw,
netdev-u79uwXL29TY76Z2rM5mHXA
Cc: Maxime Ripard
On 11.04.2014 11:46, Marc Zyngier wrote:
> The sun4i-emac driver is rather primitive, and doesn't support
> promiscuous mode. This makes usage such as bridging impossible,
> which is a shame on virtualization capable HW such as the
> Allwinner A20.
>
> The fix is fairly simple: move the RX setup code to the ndo_set_rx_mode
> vector, and add the required HW configuration when IFF_PROMISC is passed
> by the core code.
>
> This has been tested on a generic A20 box running a few virtual
> machines hanging off a bridge with the EMAC chip as the link to the
> outside world.
>
> Cc: Stefan Roese <sr-ynQEQJNshbs@public.gmane.org>
> Cc: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Signed-off-by: Marc Zyngier <marc.zyngier-5wv7dgnIgG8@public.gmane.org>
Looks good, so:
Acked-by: Stefan Roese <sr-ynQEQJNshbs@public.gmane.org>
Thanks,
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: sun4i-emac: add promiscuous support
[not found] ` <1397209577-24443-1-git-send-email-marc.zyngier-5wv7dgnIgG8@public.gmane.org>
2014-04-11 9:55 ` Stefan Roese
@ 2014-04-12 6:01 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-04-12 6:01 UTC (permalink / raw)
To: marc.zyngier-5wv7dgnIgG8
Cc: linux-sunxi-/JYPxA39Uh5TLH3MbocFFw, netdev-u79uwXL29TY76Z2rM5mHXA,
sr-ynQEQJNshbs, maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8
From: Marc Zyngier <marc.zyngier-5wv7dgnIgG8@public.gmane.org>
Date: Fri, 11 Apr 2014 10:46:17 +0100
> The sun4i-emac driver is rather primitive, and doesn't support
> promiscuous mode. This makes usage such as bridging impossible,
> which is a shame on virtualization capable HW such as the
> Allwinner A20.
>
> The fix is fairly simple: move the RX setup code to the ndo_set_rx_mode
> vector, and add the required HW configuration when IFF_PROMISC is passed
> by the core code.
>
> This has been tested on a generic A20 box running a few virtual
> machines hanging off a bridge with the EMAC chip as the link to the
> outside world.
>
> Cc: Stefan Roese <sr-ynQEQJNshbs@public.gmane.org>
> Cc: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
> Signed-off-by: Marc Zyngier <marc.zyngier-5wv7dgnIgG8@public.gmane.org>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-04-12 6:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-11 9:46 [PATCH] net: sun4i-emac: add promiscuous support Marc Zyngier
[not found] ` <1397209577-24443-1-git-send-email-marc.zyngier-5wv7dgnIgG8@public.gmane.org>
2014-04-11 9:55 ` Stefan Roese
2014-04-12 6:01 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).