Commit 15240248 authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller

net: dsa: add tagging ops to port

The DSA tagging protocol operations are specific to each CPU port,
thus the dsa_device_ops pointer belongs to the dsa_port structure.

>From now on assign a slave's xmit copy from its CPU port tagging
operations. This will ease the future support for multiple CPU ports.

Also keep the tag_ops at the beginning of the dsa_port structure so that
we ensure copies for hot path are in cacheline 1.
Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 62fc9587
...@@ -175,6 +175,9 @@ struct dsa_mall_tc_entry { ...@@ -175,6 +175,9 @@ struct dsa_mall_tc_entry {
struct dsa_port { struct dsa_port {
/* CPU port tagging operations used by master or slave devices */
const struct dsa_device_ops *tag_ops;
struct dsa_switch *ds; struct dsa_switch *ds;
unsigned int index; unsigned int index;
const char *name; const char *name;
......
...@@ -522,6 +522,7 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index, ...@@ -522,6 +522,7 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
return PTR_ERR(tag_ops); return PTR_ERR(tag_ops);
} }
dst->cpu_dp->tag_ops = tag_ops;
dst->tag_ops = tag_ops; dst->tag_ops = tag_ops;
dst->rcv = dst->tag_ops->rcv; dst->rcv = dst->tag_ops->rcv;
......
...@@ -66,7 +66,7 @@ struct dsa_notifier_vlan_info { ...@@ -66,7 +66,7 @@ struct dsa_notifier_vlan_info {
}; };
struct dsa_slave_priv { struct dsa_slave_priv {
/* Copy of dp->ds->dst->tag_ops->xmit for faster access in hot path */ /* Copy of CPU port xmit for faster access in slave transmit hot path */
struct sk_buff * (*xmit)(struct sk_buff *skb, struct sk_buff * (*xmit)(struct sk_buff *skb,
struct net_device *dev); struct net_device *dev);
......
...@@ -152,6 +152,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, ...@@ -152,6 +152,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds,
if (IS_ERR(tag_ops)) if (IS_ERR(tag_ops))
return PTR_ERR(tag_ops); return PTR_ERR(tag_ops);
dst->cpu_dp->tag_ops = tag_ops;
dst->tag_ops = tag_ops; dst->tag_ops = tag_ops;
dst->rcv = dst->tag_ops->rcv; dst->rcv = dst->tag_ops->rcv;
} }
......
...@@ -1117,7 +1117,6 @@ int dsa_slave_resume(struct net_device *slave_dev) ...@@ -1117,7 +1117,6 @@ int dsa_slave_resume(struct net_device *slave_dev)
int dsa_slave_create(struct dsa_port *port, const char *name) int dsa_slave_create(struct dsa_port *port, const char *name)
{ {
struct dsa_switch *ds = port->ds; struct dsa_switch *ds = port->ds;
struct dsa_switch_tree *dst = ds->dst;
struct net_device *master; struct net_device *master;
struct net_device *slave_dev; struct net_device *slave_dev;
struct dsa_slave_priv *p; struct dsa_slave_priv *p;
...@@ -1162,7 +1161,7 @@ int dsa_slave_create(struct dsa_port *port, const char *name) ...@@ -1162,7 +1161,7 @@ int dsa_slave_create(struct dsa_port *port, const char *name)
} }
p->dp = port; p->dp = port;
INIT_LIST_HEAD(&p->mall_tc_list); INIT_LIST_HEAD(&p->mall_tc_list);
p->xmit = dst->tag_ops->xmit; p->xmit = cpu_dp->tag_ops->xmit;
p->old_pause = -1; p->old_pause = -1;
p->old_link = -1; p->old_link = -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment