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

Commit a29342e7 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller
Browse files

net: dsa: Associate slave network device with CPU port



In preparation for supporting multiple CPU ports with DSA, have the
dsa_port structure know which CPU it is associated with. This will be
important in order to make sure the correct CPU is used for transmission
of the frames. If not for functional reasons, for performance (e.g: load
balancing) and forwarding decisions.

Reviewed-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 67dbb9d4
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -171,6 +171,7 @@ struct dsa_port {
	struct dsa_switch	*ds;
	struct dsa_switch	*ds;
	unsigned int		index;
	unsigned int		index;
	const char		*name;
	const char		*name;
	struct dsa_port		*cpu_dp;
	struct net_device	*netdev;
	struct net_device	*netdev;
	struct device_node	*dn;
	struct device_node	*dn;
	unsigned int		ageing_time;
	unsigned int		ageing_time;
+11 −0
Original line number Original line Diff line number Diff line
@@ -490,6 +490,8 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
	enum dsa_tag_protocol tag_protocol;
	enum dsa_tag_protocol tag_protocol;
	struct net_device *ethernet_dev;
	struct net_device *ethernet_dev;
	struct device_node *ethernet;
	struct device_node *ethernet;
	struct dsa_port *p;
	unsigned int i;


	if (port->dn) {
	if (port->dn) {
		ethernet = of_parse_phandle(port->dn, "ethernet", 0);
		ethernet = of_parse_phandle(port->dn, "ethernet", 0);
@@ -507,6 +509,15 @@ static int dsa_cpu_parse(struct dsa_port *port, u32 index,
	if (!dst->cpu_dp) {
	if (!dst->cpu_dp) {
		dst->cpu_dp = port;
		dst->cpu_dp = port;
		dst->cpu_dp->netdev = ethernet_dev;
		dst->cpu_dp->netdev = ethernet_dev;

		for (i = 0; i < ds->num_ports; i++) {
			p = &ds->ports[i];
			if (!dsa_port_is_valid(p) ||
			    i == index)
				continue;

			p->cpu_dp = port;
		}
	}
	}


	tag_protocol = ds->ops->get_tag_protocol(ds);
	tag_protocol = ds->ops->get_tag_protocol(ds);
+1 −1
Original line number Original line Diff line number Diff line
@@ -185,7 +185,7 @@ extern const struct dsa_device_ops trailer_netdev_ops;


static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p)
static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p)
{
{
	return p->dp->ds->dst->cpu_dp->netdev;
	return p->dp->cpu_dp->netdev;
}
}


#endif
#endif
+1 −0
Original line number Original line Diff line number Diff line
@@ -129,6 +129,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
			ds->dsa_port_mask |= 1 << i;
			ds->dsa_port_mask |= 1 << i;
		} else {
		} else {
			ds->enabled_port_mask |= 1 << i;
			ds->enabled_port_mask |= 1 << i;
			ds->ports[i].cpu_dp = dst->cpu_dp;
		}
		}
		valid_name_found = true;
		valid_name_found = true;
	}
	}
+3 −1
Original line number Original line Diff line number Diff line
@@ -1140,9 +1140,11 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent,
	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;
	struct dsa_port *cpu_dp;
	int ret;
	int ret;


	master = ds->dst->cpu_dp->netdev;
	cpu_dp = ds->dst->cpu_dp;
	master = cpu_dp->netdev;


	slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,
	slave_dev = alloc_netdev(sizeof(struct dsa_slave_priv), name,
				 NET_NAME_UNKNOWN, ether_setup);
				 NET_NAME_UNKNOWN, ether_setup);