net: dsa: store CPU port pointer in the tree
A dsa_switch_tree instance holds a dsa_switch pointer and a port index to identify the switch port to which the CPU is attached. Now that the DSA layer has a dsa_port structure to hold this data, use it to point the switch CPU port. This patch simply substitutes s/dst->cpu_switch/dst->cpu_dp->ds/ and s/dst->cpu_port/dst->cpu_dp->index/. Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
631581bf46
commit
8b0d3ea555
@@ -443,8 +443,8 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
|
||||
return err;
|
||||
}
|
||||
|
||||
if (dst->cpu_switch) {
|
||||
err = dsa_cpu_port_ethtool_setup(dst->cpu_switch);
|
||||
if (dst->cpu_dp) {
|
||||
err = dsa_cpu_port_ethtool_setup(dst->cpu_dp->ds);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
@@ -484,8 +484,8 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
|
||||
dsa_ds_unapply(dst, ds);
|
||||
}
|
||||
|
||||
if (dst->cpu_switch)
|
||||
dsa_cpu_port_ethtool_restore(dst->cpu_switch);
|
||||
if (dst->cpu_dp)
|
||||
dsa_cpu_port_ethtool_restore(dst->cpu_dp->ds);
|
||||
|
||||
pr_info("DSA: tree %d unapplied\n", dst->tree);
|
||||
dst->applied = false;
|
||||
@@ -518,10 +518,8 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
|
||||
if (!dst->master_netdev)
|
||||
dst->master_netdev = ethernet_dev;
|
||||
|
||||
if (!dst->cpu_switch) {
|
||||
dst->cpu_switch = ds;
|
||||
dst->cpu_port = index;
|
||||
}
|
||||
if (!dst->cpu_dp)
|
||||
dst->cpu_dp = port;
|
||||
|
||||
tag_protocol = ds->ops->get_tag_protocol(ds);
|
||||
dst->tag_ops = dsa_resolve_tag_protocol(tag_protocol);
|
||||
|
@@ -115,13 +115,12 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
|
||||
continue;
|
||||
|
||||
if (!strcmp(name, "cpu")) {
|
||||
if (dst->cpu_switch) {
|
||||
if (dst->cpu_dp) {
|
||||
netdev_err(dst->master_netdev,
|
||||
"multiple cpu ports?!\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
dst->cpu_switch = ds;
|
||||
dst->cpu_port = i;
|
||||
dst->cpu_dp = &ds->ports[i];
|
||||
ds->cpu_port_mask |= 1 << i;
|
||||
} else if (!strcmp(name, "dsa")) {
|
||||
ds->dsa_port_mask |= 1 << i;
|
||||
@@ -144,7 +143,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
|
||||
* tagging protocol to the preferred tagging format of this
|
||||
* switch.
|
||||
*/
|
||||
if (dst->cpu_switch == ds) {
|
||||
if (dst->cpu_dp->ds == ds) {
|
||||
enum dsa_tag_protocol tag_protocol;
|
||||
|
||||
tag_protocol = ops->get_tag_protocol(ds);
|
||||
@@ -624,7 +623,6 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
|
||||
|
||||
dst->pd = pd;
|
||||
dst->master_netdev = dev;
|
||||
dst->cpu_port = -1;
|
||||
|
||||
for (i = 0; i < pd->nr_chips; i++) {
|
||||
struct dsa_switch *ds;
|
||||
@@ -735,7 +733,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
|
||||
dsa_switch_destroy(ds);
|
||||
}
|
||||
|
||||
dsa_cpu_port_ethtool_restore(dst->cpu_switch);
|
||||
dsa_cpu_port_ethtool_restore(dst->cpu_dp->ds);
|
||||
|
||||
dev_put(dst->master_netdev);
|
||||
}
|
||||
|
@@ -821,8 +821,8 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
|
||||
uint64_t *data)
|
||||
{
|
||||
struct dsa_switch_tree *dst = dev->dsa_ptr;
|
||||
struct dsa_switch *ds = dst->cpu_switch;
|
||||
s8 cpu_port = dst->cpu_port;
|
||||
struct dsa_switch *ds = dst->cpu_dp->ds;
|
||||
s8 cpu_port = dst->cpu_dp->index;
|
||||
int count = 0;
|
||||
|
||||
if (dst->master_ethtool_ops.get_sset_count) {
|
||||
@@ -838,7 +838,7 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
|
||||
static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset)
|
||||
{
|
||||
struct dsa_switch_tree *dst = dev->dsa_ptr;
|
||||
struct dsa_switch *ds = dst->cpu_switch;
|
||||
struct dsa_switch *ds = dst->cpu_dp->ds;
|
||||
int count = 0;
|
||||
|
||||
if (dst->master_ethtool_ops.get_sset_count)
|
||||
@@ -854,8 +854,8 @@ static void dsa_cpu_port_get_strings(struct net_device *dev,
|
||||
uint32_t stringset, uint8_t *data)
|
||||
{
|
||||
struct dsa_switch_tree *dst = dev->dsa_ptr;
|
||||
struct dsa_switch *ds = dst->cpu_switch;
|
||||
s8 cpu_port = dst->cpu_port;
|
||||
struct dsa_switch *ds = dst->cpu_dp->ds;
|
||||
s8 cpu_port = dst->cpu_dp->index;
|
||||
int len = ETH_GSTRING_LEN;
|
||||
int mcount = 0, count;
|
||||
unsigned int i;
|
||||
|
@@ -101,7 +101,7 @@ static struct sk_buff *brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||
int source_port;
|
||||
u8 *brcm_tag;
|
||||
|
||||
ds = dst->cpu_switch;
|
||||
ds = dst->cpu_dp->ds;
|
||||
|
||||
if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN)))
|
||||
goto out_drop;
|
||||
|
@@ -99,7 +99,7 @@ static struct sk_buff *qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||
/* This protocol doesn't support cascading multiple switches so it's
|
||||
* safe to assume the switch is first in the tree
|
||||
*/
|
||||
ds = dst->cpu_switch;
|
||||
ds = dst->cpu_dp->ds;
|
||||
if (!ds)
|
||||
goto out_drop;
|
||||
|
||||
|
@@ -67,7 +67,7 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
|
||||
u8 *trailer;
|
||||
int source_port;
|
||||
|
||||
ds = dst->cpu_switch;
|
||||
ds = dst->cpu_dp->ds;
|
||||
|
||||
if (skb_linearize(skb))
|
||||
goto out_drop;
|
||||
|
Reference in New Issue
Block a user