diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2014-04-11 05:46:17 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-04-12 01:59:38 -0400 |
commit | cec9ae50ccb1491efee90dc8e9998e29e43652b6 (patch) | |
tree | a22563a221ae67e36797ac16af46403e60396df5 /drivers/net/ethernet/allwinner | |
parent | 0af764e3f79afe7c758856a2a9376e8ee4f812d7 (diff) |
net: sun4i-emac: add promiscuous support
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>
Acked-by: Stefan Roese <sr@denx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/allwinner')
-rw-r--r-- | drivers/net/ethernet/allwinner/sun4i-emac.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c index fcaeeb8a4929..28460676b8ca 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) | |||
268 | writel(reg_val | EMAC_TX_MODE_ABORTED_FRAME_EN, | 268 | writel(reg_val | EMAC_TX_MODE_ABORTED_FRAME_EN, |
269 | db->membase + EMAC_TX_MODE_REG); | 269 | db->membase + EMAC_TX_MODE_REG); |
270 | 270 | ||
271 | /* set up RX */ | ||
272 | reg_val = readl(db->membase + EMAC_RX_CTL_REG); | ||
273 | |||
274 | writel(reg_val | EMAC_RX_CTL_PASS_LEN_OOR_EN | | ||
275 | EMAC_RX_CTL_ACCEPT_UNICAST_EN | EMAC_RX_CTL_DA_FILTER_EN | | ||
276 | EMAC_RX_CTL_ACCEPT_MULTICAST_EN | | ||
277 | EMAC_RX_CTL_ACCEPT_BROADCAST_EN, | ||
278 | db->membase + EMAC_RX_CTL_REG); | ||
279 | |||
280 | /* set MAC */ | 271 | /* set MAC */ |
281 | /* set MAC CTL0 */ | 272 | /* set MAC CTL0 */ |
282 | reg_val = readl(db->membase + EMAC_MAC_CTL0_REG); | 273 | reg_val = readl(db->membase + EMAC_MAC_CTL0_REG); |
@@ -309,6 +300,26 @@ static unsigned int emac_setup(struct net_device *ndev) | |||
309 | return 0; | 300 | return 0; |
310 | } | 301 | } |
311 | 302 | ||
303 | static void emac_set_rx_mode(struct net_device *ndev) | ||
304 | { | ||
305 | struct emac_board_info *db = netdev_priv(ndev); | ||
306 | unsigned int reg_val; | ||
307 | |||
308 | /* set up RX */ | ||
309 | reg_val = readl(db->membase + EMAC_RX_CTL_REG); | ||
310 | |||
311 | if (ndev->flags & IFF_PROMISC) | ||
312 | reg_val |= EMAC_RX_CTL_PASS_ALL_EN; | ||
313 | else | ||
314 | reg_val &= ~EMAC_RX_CTL_PASS_ALL_EN; | ||
315 | |||
316 | writel(reg_val | EMAC_RX_CTL_PASS_LEN_OOR_EN | | ||
317 | EMAC_RX_CTL_ACCEPT_UNICAST_EN | EMAC_RX_CTL_DA_FILTER_EN | | ||
318 | EMAC_RX_CTL_ACCEPT_MULTICAST_EN | | ||
319 | EMAC_RX_CTL_ACCEPT_BROADCAST_EN, | ||
320 | db->membase + EMAC_RX_CTL_REG); | ||
321 | } | ||
322 | |||
312 | static unsigned int emac_powerup(struct net_device *ndev) | 323 | static unsigned int emac_powerup(struct net_device *ndev) |
313 | { | 324 | { |
314 | struct emac_board_info *db = netdev_priv(ndev); | 325 | struct emac_board_info *db = netdev_priv(ndev); |
@@ -782,6 +793,7 @@ static const struct net_device_ops emac_netdev_ops = { | |||
782 | .ndo_stop = emac_stop, | 793 | .ndo_stop = emac_stop, |
783 | .ndo_start_xmit = emac_start_xmit, | 794 | .ndo_start_xmit = emac_start_xmit, |
784 | .ndo_tx_timeout = emac_timeout, | 795 | .ndo_tx_timeout = emac_timeout, |
796 | .ndo_set_rx_mode = emac_set_rx_mode, | ||
785 | .ndo_do_ioctl = emac_ioctl, | 797 | .ndo_do_ioctl = emac_ioctl, |
786 | .ndo_change_mtu = eth_change_mtu, | 798 | .ndo_change_mtu = eth_change_mtu, |
787 | .ndo_validate_addr = eth_validate_addr, | 799 | .ndo_validate_addr = eth_validate_addr, |