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

Commit f8b8b1cd authored by Vivien Didelot's avatar Vivien Didelot Committed by David S. Miller
Browse files

net: dsa: split dsa_port's netdev member



The dsa_port structure has a "netdev" member, which can be used for
either the master device, or the slave device, depending on its type.

It is true that today, CPU port are not exposed to userspace, thus the
port's netdev member can be used to point to its master interface.

But it is still slightly confusing, so split it into more explicit
"master" and "slave" members inside an anonymous union.

Signed-off-by: default avatarVivien Didelot <vivien.didelot@savoirfairelinux.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2231c43b
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -601,7 +601,7 @@ static void bcm_sf2_sw_fixed_link_update(struct dsa_switch *ds, int port,
		 * state machine and make it go in PHY_FORCING state instead.
		 */
		if (!status->link)
			netif_carrier_off(ds->ports[port].netdev);
			netif_carrier_off(ds->ports[port].slave);
		status->duplex = 1;
	} else {
		status->link = 1;
@@ -690,7 +690,7 @@ static int bcm_sf2_sw_resume(struct dsa_switch *ds)
static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,
			       struct ethtool_wolinfo *wol)
{
	struct net_device *p = ds->ports[port].cpu_dp->netdev;
	struct net_device *p = ds->ports[port].cpu_dp->master;
	struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
	struct ethtool_wolinfo pwol;

@@ -713,7 +713,7 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,
static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port,
			      struct ethtool_wolinfo *wol)
{
	struct net_device *p = ds->ports[port].cpu_dp->netdev;
	struct net_device *p = ds->ports[port].cpu_dp->master;
	struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
	s8 cpu_port = ds->ports[port].cpu_dp->index;
	struct ethtool_wolinfo pwol;
+1 −1
Original line number Diff line number Diff line
@@ -933,7 +933,7 @@ mt7530_setup(struct dsa_switch *ds)
	 * controller also is the container for two GMACs nodes representing
	 * as two netdev instances.
	 */
	dn = ds->ports[MT7530_CPU_PORT].netdev->dev.of_node->parent;
	dn = ds->ports[MT7530_CPU_PORT].master->dev.of_node->parent;
	priv->ethernet = syscon_node_to_regmap(dn);
	if (IS_ERR(priv->ethernet))
		return PTR_ERR(priv->ethernet);
+1 −1
Original line number Diff line number Diff line
@@ -1137,7 +1137,7 @@ static int mv88e6xxx_port_check_hw_vlan(struct dsa_switch *ds, int port,
			if (dsa_is_dsa_port(ds, i) || dsa_is_cpu_port(ds, i))
				continue;

			if (!ds->ports[port].netdev)
			if (!ds->ports[port].slave)
				continue;

			if (vlan.member[i] ==
+8 −1
Original line number Diff line number Diff line
@@ -164,6 +164,14 @@ struct dsa_mall_tc_entry {


struct dsa_port {
	/* A CPU port is physically connected to a master device.
	 * A user port exposed to userspace has a slave device.
	 */
	union {
		struct net_device *master;
		struct net_device *slave;
	};

	/* CPU port tagging operations used by master or slave devices */
	const struct dsa_device_ops *tag_ops;

@@ -176,7 +184,6 @@ struct dsa_port {
	unsigned int		index;
	const char		*name;
	struct dsa_port		*cpu_dp;
	struct net_device	*netdev;
	struct device_node	*dn;
	unsigned int		ageing_time;
	u8			stp_state;
+3 −3
Original line number Diff line number Diff line
@@ -201,7 +201,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
#ifdef CONFIG_PM_SLEEP
static bool dsa_is_port_initialized(struct dsa_switch *ds, int p)
{
	return ds->enabled_port_mask & (1 << p) && ds->ports[p].netdev;
	return ds->enabled_port_mask & (1 << p) && ds->ports[p].slave;
}

int dsa_switch_suspend(struct dsa_switch *ds)
@@ -213,7 +213,7 @@ int dsa_switch_suspend(struct dsa_switch *ds)
		if (!dsa_is_port_initialized(ds, i))
			continue;

		ret = dsa_slave_suspend(ds->ports[i].netdev);
		ret = dsa_slave_suspend(ds->ports[i].slave);
		if (ret)
			return ret;
	}
@@ -240,7 +240,7 @@ int dsa_switch_resume(struct dsa_switch *ds)
		if (!dsa_is_port_initialized(ds, i))
			continue;

		ret = dsa_slave_resume(ds->ports[i].netdev);
		ret = dsa_slave_resume(ds->ports[i].slave);
		if (ret)
			return ret;
	}
Loading