net: dsa: b53: Turn on Broadcom tags
Subsystems (5)
v3 cover net: dsa: b53: Turn on Broadcom tags
Hi all,
This was long overdue, with this patch series, the b53 driver now turns on Broadcom tags except for 5325 and 5365 which use an older format that we do not support yet (TBD).
First patch is necessary in order for bgmac, used on BCM5301X and Northstar Plus to work correctly and successfully send ARP packets back to the requsester.
Second patch is actually a bug fix, but because net/master and net-next/master diverge in that area, I am targeting net-next/master here.
Finally, the last patch enables Broadcom tags after checking that the CPU port selected is either, 5, 7 or 8, since those are the only valid combinations given currently supported HW.
Changes in v3:
- guarded padding with netdev_uses_dsa() to let the non-DSA use cases not have a performance hit for smaller packets
- added missing select NET_DSA_TAG_BRCM to drivers/net/dsa/b53/Kconfig
Changes in v2:
- moved a hunk between patch 2 and patch 3 to avoid a bisectability issue
Florian Fainelli (3):
net: bgmac: Pad packets to a minimum size
net: dsa: b53: Stop using dev->cpu_port incorrectly
net: dsa: b53: Turn on Broadcom tags
drivers/net/dsa/b53/Kconfig | 1 + drivers/net/dsa/b53/b53_common.c | 58 ++++++++++++++++++++++++++--------- drivers/net/ethernet/broadcom/bgmac.c | 16 ++++++++++ 3 files changed, 60 insertions(+), 15 deletions(-)
Signature · 1 line
2.9.3
PATCH v3 1/3 net: bgmac: Pad packets to a minimum size
In preparation for enabling Broadcom tags with b53, pad packets to a minimum size of 64 bytes (sans FCS) in order for the Broadcom switch to accept ingressing frames. Without this, we would typically be able to DHCP, but not resolve with ARP because packets are too small and get rejected by the switch.
--- drivers/net/ethernet/broadcom/bgmac.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
drivers/net/ethernet/broadcom/bgmac.c +16 -0
@@ -15,6 +15,7 @@#include <linux/bcm47xx_nvram.h> #include <linux/phy.h> #include <linux/phy_fixed.h> +#include <net/dsa.h> #include "bgmac.h" static bool bgmac_wait_value(struct bgmac *bgmac, u16 reg, u32 mask,
@@ -127,6 +128,8 @@ bgmac_dma_tx_add_buf(struct bgmac *bgmac, struct bgmac_dma_ring *ring, dma_desc->ctl1 =cpu_to_le32 (ctl1); } +#define ENET_BRCM_TAG_LEN 4 +static netdev_tx_t bgmac_dma_tx_add (struct bgmac *bgmac,struct bgmac_dma_ring *ring,struct sk_buff *skb)
@@ -139,6 +142,18 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac,u32 flags;int i; +/* The Ethernet switch we are interfaced with needs packets to be at +* least 64 bytes (including FCS) otherwise they will be discarded when +* they enter the switch port logic. When Broadcom tags are enabled, we +* need to make sure that packets are at least 68 bytes +* (including FCS and tag) because the length verification is done after +* the Broadcom tag is stripped off the ingress packet. +*/ +if (netdev_uses_dsa (net_dev)) { +if (skb_put_padto (skb,ETH_ZLEN +ENET_BRCM_TAG_LEN )) + goto err_stats; + } +if (skb->len >BGMAC_DESC_CTL1_LEN ) {netdev_err (bgmac->net_dev,"Too long skb (%d)\n" , skb->len); goto err_drop;
@@ -225,6 +240,7 @@ static netdev_tx_t bgmac_dma_tx_add(struct bgmac *bgmac, err_drop:dev_kfree_skb (skb); +err_stats: net_dev->stats.tx_dropped++; net_dev->stats.tx_errors++;return NETDEV_TX_OK ;
Signature · 1 line
2.9.3
PATCH v3 2/3 net: dsa: b53: Stop using dev->cpu_port incorrectly
In reply to Florian Fainellidev->cpu_port is the driver local information that should only be used to look up register offsets for a particular port, when they differ (e.g: IMP port override), but it should certainly not be used in place of the DSA configured CPU port.
Since the DSA switch layer calls port_vlan_{add,del}() on the CPU port as well, we can remove the specific setting of the CPU port within port_vlan_{add,del}.
--- drivers/net/dsa/b53/b53_common.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/net/dsa/b53/b53_common.c +4 -6
@@ -505,7 +505,7 @@ EXPORT_SYMBOL(b53_imp_vlan_setup);int b53_enable_port (struct dsa_switch *ds,int port,struct phy_device *phy) {struct b53_device *dev = ds->priv; -unsigned int cpu_port = dev->cpu_port; +unsigned int cpu_port = ds->ports[port].cpu_dp->index;u16 pvlan;/* Clear the Rx and Tx disable bits and set to no spanning tree */
@@ -1054,7 +1054,6 @@ void b53_vlan_add(struct dsa_switch *ds, int port,struct b53_device *dev = ds->priv;bool untagged = vlan->flags &BRIDGE_VLAN_INFO_UNTAGGED ;bool pvid = vlan->flags &BRIDGE_VLAN_INFO_PVID ; -unsigned int cpu_port = dev->cpu_port;struct b53_vlan *vl;u16 vid;
@@ -1063,12 +1062,11 @@ void b53_vlan_add(struct dsa_switch *ds, int port,b53_get_vlan_entry (dev, vid, vl); - vl->members |=BIT (port) |BIT (cpu_port); + vl->members |=BIT (port);if (untagged) vl->untag |=BIT (port);else vl->untag &= ~BIT (port); - vl->untag &= ~BIT (cpu_port);b53_set_vlan_entry (dev, vid, vl);b53_fast_age_vlan (dev, vid);
@@ -1432,8 +1430,8 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br)b53_write16 (dev,B53_VLAN_PAGE ,B53_JOIN_ALL_VLAN_EN , reg); }else {b53_get_vlan_entry (dev, pvid, vl); - vl->members |=BIT (port) |BIT (dev->cpu_port); - vl->untag |=BIT (port) |BIT (dev->cpu_port); + vl->members |=BIT (port) |BIT (cpu_port); + vl->untag |=BIT (port) |BIT (cpu_port);b53_set_vlan_entry (dev, pvid, vl); } }
Signature · 1 line
2.9.3
PATCH v3 3/3 net: dsa: b53: Turn on Broadcom tags
In reply to Florian FainelliEnable Broadcom tags for b53 devices, except 5325 and 5365 which use a different Broadcom tag format not yet supported by net/dsa/tag_brcm.c.
We also make sure that we can turn on Broadcom tags on a CPU port number that is capable of that: 5, 7 or 8.
--- drivers/net/dsa/b53/Kconfig | 1 + drivers/net/dsa/b53/b53_common.c | 48 ++++++++++++++++++++++++++++++++-------- 2 files changed, 40 insertions(+), 9 deletions(-)
drivers/net/dsa/b53/Kconfig +1 -0
@@ -1,6 +1,7 @@ menuconfig B53 tristate "Broadcom BCM53xx managed switch support" depends on NET_DSA + select NET_DSA_TAG_BRCM help This driver adds support for Broadcom managed switch chips. It supports BCM5325E, BCM5365, BCM539x, BCM53115 and BCM53125 as well as BCM63XX
drivers/net/dsa/b53/b53_common.c +39 -9
75 lines not on this page · raw message
Signature · 1 line
2.9.3
Re: [PATCH net-next v3 1/3] net: bgmac: Pad packets to a minimum size
In reply to Florian FainelliQuoted 7 lines · Florian Fainelli
In preparation for enabling Broadcom tags with b53, pad packets to a minimum size of 64 bytes (sans FCS) in order for the Broadcom switch to accept ingressing frames. Without this, we would typically be able to DHCP, but not resolve with ARP because packets are too small and get rejected by the switch.
Signed-off-by Florian Fainelli <[email protected]>
Andrew
Re: [PATCH net-next v3 2/3] net: dsa: b53: Stop using dev->cpu_port incorrectly
In reply to Florian FainelliQuoted 5 lines · Florian Fainelli
dev->cpu_portis the driver local information that should only be used to look up register offsets for a particular port, when they differ (e.g: IMP port override), but it should certainly not be used in place of the DSA configured CPU port.
Quoted 7 lines
Since the DSA switch layer calls port_vlan_{add,del}() on the CPU port as well, we can remove the specific setting of the CPU port within port_vlan_{add,del}.
Fixes ff39c2d68679 ("net: dsa: b53: Add bridge support")Fixes 967dd82ffc52 ("net: dsa: b53: Add support for Broadcom RoboSwitch")Signed-off-by Florian Fainelli <[email protected]>
Andrew
Quoted 7 lines · Florian Fainelli
Enable Broadcom tags for b53 devices, except 5325 and 5365 which use a different Broadcom tag format not yet supported by
net/dsa/tag_brcm.c.We also make sure that we can turn on Broadcom tags on a CPU port number that is capable of that: 5, 7 or 8.
Signed-off-by Florian Fainelli <[email protected]>
Andrew
David Miller
maintainerFrom: Florian Fainelli <[email protected]>
Date: Fri, 10 Nov 2017 11:33:24 -0800
Quoted 9 lines
Hi all,
This was long overdue, with this patch series, the b53 driver now turns on Broadcom tags except for 5325 and 5365 which use an older format that we do not support yet (TBD).
First patch is necessary in order for bgmac, used on BCM5301X and Northstar Plus to work correctly and successfully send ARP packets back to the requsester.
Quoted 6 lines
Second patch is actually a bug fix, but because net/master and net-next/master diverge in that area, I am targeting net-next/master here.
Finally, the last patch enables Broadcom tags after checking that the CPU port selected is either, 5, 7 or 8, since those are the only valid combinations given currently supported HW.
...
Series applied.