提交 5ed4e3eb 编写于 作者: F Florian Fainelli 提交者: David S. Miller

net: dsa: Pass a port to get_tag_protocol()

A number of drivers want to check whether the configured CPU port is a
possible configuration for enabling tagging, pass down the CPU port
number so they verify that.
Signed-off-by: NFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: NVivien Didelot <vivien.didelot@savoirfairelinux.com>
Reviewed-by: NAndrew Lunn <andrew@lunn.ch>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 ee9d3429
...@@ -541,7 +541,8 @@ EXPORT_SYMBOL(b53_disable_port); ...@@ -541,7 +541,8 @@ EXPORT_SYMBOL(b53_disable_port);
void b53_brcm_hdr_setup(struct dsa_switch *ds, int 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_BRCM);
struct b53_device *dev = ds->priv; struct b53_device *dev = ds->priv;
u8 hdr_ctl, val; u8 hdr_ctl, val;
u16 reg; u16 reg;
...@@ -1478,38 +1479,31 @@ void b53_br_fast_age(struct dsa_switch *ds, int port) ...@@ -1478,38 +1479,31 @@ void b53_br_fast_age(struct dsa_switch *ds, int port)
} }
EXPORT_SYMBOL(b53_br_fast_age); 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 /* Broadcom switches will accept enabling Broadcom tags on the
* following ports: 5, 7 and 8, any other port is not supported * 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); switch (port) {
case B53_CPU_PORT_25:
for (i = 0; i < ds->num_ports; i++) { case 7:
if (dsa_is_cpu_port(ds, i)) { case B53_CPU_PORT:
if (!(BIT(i) & brcm_tag_mask)) { return true;
dev_warn(ds->dev,
"Port %d is not Broadcom tag capable\n",
i);
return false;
}
}
} }
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; struct b53_device *dev = ds->priv;
/* Older models support a different tag format that we do not /* Older models support a different tag format that we do not
* support in net/dsa/tag_brcm.c yet. * 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; return DSA_TAG_PROTO_NONE;
else else
return DSA_TAG_PROTO_BRCM; return DSA_TAG_PROTO_BRCM;
......
...@@ -35,7 +35,8 @@ ...@@ -35,7 +35,8 @@
#include "b53/b53_priv.h" #include "b53/b53_priv.h"
#include "b53/b53_regs.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; return DSA_TAG_PROTO_BRCM;
} }
......
...@@ -64,7 +64,8 @@ struct dsa_loop_priv { ...@@ -64,7 +64,8 @@ struct dsa_loop_priv {
static struct phy_device *phydevs[PHY_MAX_ADDR]; 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__); dev_dbg(ds->dev, "%s\n", __func__);
......
...@@ -894,7 +894,8 @@ static int lan9303_check_device(struct lan9303 *chip) ...@@ -894,7 +894,8 @@ static int lan9303_check_device(struct lan9303 *chip)
/* ---------------------------- DSA -----------------------------------*/ /* ---------------------------- 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; return DSA_TAG_PROTO_LAN9303;
} }
......
...@@ -394,7 +394,8 @@ static int ksz_setup(struct dsa_switch *ds) ...@@ -394,7 +394,8 @@ static int ksz_setup(struct dsa_switch *ds)
return 0; return 0;
} }
static enum dsa_tag_protocol ksz_get_tag_protocol(struct dsa_switch *ds) static enum dsa_tag_protocol ksz_get_tag_protocol(struct dsa_switch *ds,
int port)
{ {
return DSA_TAG_PROTO_KSZ; return DSA_TAG_PROTO_KSZ;
} }
......
...@@ -907,11 +907,11 @@ mt7530_port_fdb_dump(struct dsa_switch *ds, int port, ...@@ -907,11 +907,11 @@ mt7530_port_fdb_dump(struct dsa_switch *ds, int port,
} }
static enum dsa_tag_protocol static enum dsa_tag_protocol
mtk_get_tag_protocol(struct dsa_switch *ds) mtk_get_tag_protocol(struct dsa_switch *ds, int port)
{ {
struct mt7530_priv *priv = ds->priv; struct mt7530_priv *priv = ds->priv;
if (!dsa_is_cpu_port(ds, MT7530_CPU_PORT)) { if (port != MT7530_CPU_PORT) {
dev_warn(priv->dev, dev_warn(priv->dev,
"port not matched with tagging CPU port\n"); "port not matched with tagging CPU port\n");
return DSA_TAG_PROTO_NONE; return DSA_TAG_PROTO_NONE;
......
...@@ -70,7 +70,8 @@ static const char *mv88e6060_get_name(struct mii_bus *bus, int sw_addr) ...@@ -70,7 +70,8 @@ static const char *mv88e6060_get_name(struct mii_bus *bus, int sw_addr)
return NULL; return NULL;
} }
static enum dsa_tag_protocol mv88e6060_get_tag_protocol(struct dsa_switch *ds) static enum dsa_tag_protocol mv88e6060_get_tag_protocol(struct dsa_switch *ds,
int port)
{ {
return DSA_TAG_PROTO_TRAILER; return DSA_TAG_PROTO_TRAILER;
} }
......
...@@ -3731,7 +3731,8 @@ static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip, ...@@ -3731,7 +3731,8 @@ static int mv88e6xxx_smi_init(struct mv88e6xxx_chip *chip,
return 0; return 0;
} }
static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds) static enum dsa_tag_protocol mv88e6xxx_get_tag_protocol(struct dsa_switch *ds,
int port)
{ {
struct mv88e6xxx_chip *chip = ds->priv; struct mv88e6xxx_chip *chip = ds->priv;
......
...@@ -823,7 +823,7 @@ qca8k_port_fdb_dump(struct dsa_switch *ds, int port, ...@@ -823,7 +823,7 @@ qca8k_port_fdb_dump(struct dsa_switch *ds, int port,
} }
static enum dsa_tag_protocol static enum dsa_tag_protocol
qca8k_get_tag_protocol(struct dsa_switch *ds) qca8k_get_tag_protocol(struct dsa_switch *ds, int port)
{ {
return DSA_TAG_PROTO_QCA; return DSA_TAG_PROTO_QCA;
} }
......
...@@ -321,7 +321,8 @@ struct dsa_switch_ops { ...@@ -321,7 +321,8 @@ struct dsa_switch_ops {
struct device *host_dev, int sw_addr, struct device *host_dev, int sw_addr,
void **priv); void **priv);
enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds); enum dsa_tag_protocol (*get_tag_protocol)(struct dsa_switch *ds,
int port);
int (*setup)(struct dsa_switch *ds); int (*setup)(struct dsa_switch *ds);
u32 (*get_phy_flags)(struct dsa_switch *ds, int port); u32 (*get_phy_flags)(struct dsa_switch *ds, int port);
......
...@@ -539,7 +539,7 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master) ...@@ -539,7 +539,7 @@ static int dsa_port_parse_cpu(struct dsa_port *dp, struct net_device *master)
const struct dsa_device_ops *tag_ops; const struct dsa_device_ops *tag_ops;
enum dsa_tag_protocol tag_protocol; enum dsa_tag_protocol tag_protocol;
tag_protocol = ds->ops->get_tag_protocol(ds); tag_protocol = ds->ops->get_tag_protocol(ds, dp->index);
tag_ops = dsa_resolve_tag_protocol(tag_protocol); tag_ops = dsa_resolve_tag_protocol(tag_protocol);
if (IS_ERR(tag_ops)) { if (IS_ERR(tag_ops)) {
dev_warn(ds->dev, "No tagger for this switch\n"); dev_warn(ds->dev, "No tagger for this switch\n");
......
...@@ -151,7 +151,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, ...@@ -151,7 +151,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
const struct dsa_device_ops *tag_ops; const struct dsa_device_ops *tag_ops;
enum dsa_tag_protocol tag_protocol; enum dsa_tag_protocol tag_protocol;
tag_protocol = ops->get_tag_protocol(ds); tag_protocol = ops->get_tag_protocol(ds, dst->cpu_dp->index);
tag_ops = dsa_resolve_tag_protocol(tag_protocol); tag_ops = dsa_resolve_tag_protocol(tag_protocol);
if (IS_ERR(tag_ops)) if (IS_ERR(tag_ops))
return PTR_ERR(tag_ops); return PTR_ERR(tag_ops);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册