Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit aef1e0d5 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'dsa-b53-Support-prepended-Broadcom-tags'



Florian Fainelli says:

====================
net: dsa: b53: Support prepended Broadcom tags

This patch series adds support for prepended 4-bytes Broadcom tags that we
already support. This type of tag will typically be used when interfaced to
a SoC like BCM58xx (NorthStar Plus) which supports a Flow Accelerator (WIP).
In that case, we need to support a slightly different tagging format.

The first patch does a bit of re-factoring and passes a port index to
the get_tag_protocol() function since at least two different drivers need
that type of information (mt7530, b53) to support tagging or not.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents ee9d3429 11606039
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@ menuconfig B53
	tristate "Broadcom BCM53xx managed switch support"
	depends on NET_DSA
	select NET_DSA_TAG_BRCM
	select NET_DSA_TAG_BRCM_PREPEND
	help
	  This driver adds support for Broadcom managed switch chips. It supports
	  BCM5325E, BCM5365, BCM539x, BCM53115 and BCM53125 as well as BCM63XX
+21 −21
Original line number Diff line number Diff line
@@ -541,7 +541,8 @@ EXPORT_SYMBOL(b53_disable_port);

void b53_brcm_hdr_setup(struct dsa_switch *ds, int port)
{
	bool tag_en = !!(ds->ops->get_tag_protocol(ds) == DSA_TAG_PROTO_BRCM);
	bool tag_en = !(ds->ops->get_tag_protocol(ds, port) ==
			 DSA_TAG_PROTO_NONE);
	struct b53_device *dev = ds->priv;
	u8 hdr_ctl, val;
	u16 reg;
@@ -1478,40 +1479,39 @@ void b53_br_fast_age(struct dsa_switch *ds, int port)
}
EXPORT_SYMBOL(b53_br_fast_age);

static bool b53_can_enable_brcm_tags(struct dsa_switch *ds)
static bool b53_can_enable_brcm_tags(struct dsa_switch *ds, int port)
{
	unsigned int brcm_tag_mask;
	unsigned int i;

	/* Broadcom switches will accept enabling Broadcom tags on the
	 * following ports: 5, 7 and 8, any other port is not supported
	 */
	brcm_tag_mask = BIT(B53_CPU_PORT_25) | BIT(7) | BIT(B53_CPU_PORT);

	for (i = 0; i < ds->num_ports; i++) {
		if (dsa_is_cpu_port(ds, i)) {
			if (!(BIT(i) & brcm_tag_mask)) {
				dev_warn(ds->dev,
					 "Port %d is not Broadcom tag capable\n",
					 i);
				return false;
			}
		}
	switch (port) {
	case B53_CPU_PORT_25:
	case 7:
	case B53_CPU_PORT:
		return true;
	}

	return true;
	dev_warn(ds->dev, "Port %d is not Broadcom tag capable\n", port);
	return false;
}

static enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds)
static enum dsa_tag_protocol b53_get_tag_protocol(struct dsa_switch *ds,
						  int port)
{
	struct b53_device *dev = ds->priv;

	/* Older models support a different tag format that we do not
	 * support in net/dsa/tag_brcm.c yet.
	 */
	if (is5325(dev) || is5365(dev) || !b53_can_enable_brcm_tags(ds))
	if (is5325(dev) || is5365(dev) || !b53_can_enable_brcm_tags(ds, port))
		return DSA_TAG_PROTO_NONE;
	else

	/* Broadcom BCM58xx chips have a flow accelerator on Port 8
	 * which requires us to use the prepended Broadcom tag type
	 */
	if (dev->chip_id == BCM58XX_DEVICE_ID && port == B53_CPU_PORT)
		return DSA_TAG_PROTO_BRCM_PREPEND;

	return DSA_TAG_PROTO_BRCM;
}

+2 −1
Original line number Diff line number Diff line
@@ -35,7 +35,8 @@
#include "b53/b53_priv.h"
#include "b53/b53_regs.h"

static enum dsa_tag_protocol bcm_sf2_sw_get_tag_protocol(struct dsa_switch *ds)
static enum dsa_tag_protocol bcm_sf2_sw_get_tag_protocol(struct dsa_switch *ds,
							 int port)
{
	return DSA_TAG_PROTO_BRCM;
}
+2 −1
Original line number Diff line number Diff line
@@ -64,7 +64,8 @@ struct dsa_loop_priv {

static struct phy_device *phydevs[PHY_MAX_ADDR];

static enum dsa_tag_protocol dsa_loop_get_protocol(struct dsa_switch *ds)
static enum dsa_tag_protocol dsa_loop_get_protocol(struct dsa_switch *ds,
						   int port)
{
	dev_dbg(ds->dev, "%s\n", __func__);

+2 −1
Original line number Diff line number Diff line
@@ -894,7 +894,8 @@ static int lan9303_check_device(struct lan9303 *chip)

/* ---------------------------- DSA -----------------------------------*/

static enum dsa_tag_protocol lan9303_get_tag_protocol(struct dsa_switch *ds)
static enum dsa_tag_protocol lan9303_get_tag_protocol(struct dsa_switch *ds,
						      int port)
{
	return DSA_TAG_PROTO_LAN9303;
}
Loading