Commit 49185277 authored by Jiri Pirko's avatar Jiri Pirko Committed by David S. Miller
Browse files

mlxsw: spectrum: Remember split base local port and use it in unsplit



Don't compute the original base local port during unsplit, rather
remember it in mlxsw_sp_port structure during split port creation.

Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Reviewed-by: default avatarShalom Toledo <shalomt@mellanox.com>
Signed-off-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 038784a9
Loading
Loading
Loading
Loading
+7 −9
Original line number Original line Diff line number Diff line
@@ -3692,10 +3692,11 @@ static int mlxsw_sp_port_tc_mc_mode_set(struct mlxsw_sp_port *mlxsw_sp_port,
}
}


static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
				bool split,
				u8 split_base_local_port,
				struct mlxsw_sp_port_mapping *port_mapping)
				struct mlxsw_sp_port_mapping *port_mapping)
{
{
	struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
	struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan;
	bool split = !!split_base_local_port;
	struct mlxsw_sp_port *mlxsw_sp_port;
	struct mlxsw_sp_port *mlxsw_sp_port;
	struct net_device *dev;
	struct net_device *dev;
	int err;
	int err;
@@ -3724,6 +3725,7 @@ static int mlxsw_sp_port_create(struct mlxsw_sp *mlxsw_sp, u8 local_port,
	mlxsw_sp_port->local_port = local_port;
	mlxsw_sp_port->local_port = local_port;
	mlxsw_sp_port->pvid = MLXSW_SP_DEFAULT_VID;
	mlxsw_sp_port->pvid = MLXSW_SP_DEFAULT_VID;
	mlxsw_sp_port->split = split;
	mlxsw_sp_port->split = split;
	mlxsw_sp_port->split_base_local_port = split_base_local_port;
	mlxsw_sp_port->mapping = *port_mapping;
	mlxsw_sp_port->mapping = *port_mapping;
	mlxsw_sp_port->link.autoneg = 1;
	mlxsw_sp_port->link.autoneg = 1;
	INIT_LIST_HEAD(&mlxsw_sp_port->vlans_list);
	INIT_LIST_HEAD(&mlxsw_sp_port->vlans_list);
@@ -4038,7 +4040,7 @@ static int mlxsw_sp_ports_create(struct mlxsw_sp *mlxsw_sp)
		port_mapping = mlxsw_sp->port_mapping[i];
		port_mapping = mlxsw_sp->port_mapping[i];
		if (!port_mapping)
		if (!port_mapping)
			continue;
			continue;
		err = mlxsw_sp_port_create(mlxsw_sp, i, false, port_mapping);
		err = mlxsw_sp_port_create(mlxsw_sp, i, 0, port_mapping);
		if (err)
		if (err)
			goto err_port_create;
			goto err_port_create;
	}
	}
@@ -4118,7 +4120,7 @@ mlxsw_sp_port_split_create(struct mlxsw_sp *mlxsw_sp, u8 base_port,
	split_port_mapping.width /= count;
	split_port_mapping.width /= count;
	for (i = 0; i < count; i++) {
	for (i = 0; i < count; i++) {
		err = mlxsw_sp_port_create(mlxsw_sp, base_port + i * offset,
		err = mlxsw_sp_port_create(mlxsw_sp, base_port + i * offset,
					   true, &split_port_mapping);
					   base_port, &split_port_mapping);
		if (err)
		if (err)
			goto err_port_create;
			goto err_port_create;
		split_port_mapping.lane += split_port_mapping.width;
		split_port_mapping.lane += split_port_mapping.width;
@@ -4150,7 +4152,7 @@ static void mlxsw_sp_port_unsplit_create(struct mlxsw_sp *mlxsw_sp,
		port_mapping = mlxsw_sp->port_mapping[local_port];
		port_mapping = mlxsw_sp->port_mapping[local_port];
		if (!port_mapping)
		if (!port_mapping)
			continue;
			continue;
		mlxsw_sp_port_create(mlxsw_sp, local_port, false, port_mapping);
		mlxsw_sp_port_create(mlxsw_sp, local_port, 0, port_mapping);
	}
	}
}
}


@@ -4312,11 +4314,7 @@ static int mlxsw_sp_port_unsplit(struct mlxsw_core *mlxsw_core, u8 local_port,
		return -EINVAL;
		return -EINVAL;
	}
	}


	base_port = mlxsw_sp_cluster_base_port_get(local_port, max_width);
	base_port = mlxsw_sp_port->split_base_local_port;

	/* Determine which ports to remove. */
	if (count == 2 && local_port >= base_port + 2)
		base_port = base_port + 2;


	for (i = 0; i < count; i++)
	for (i = 0; i < count; i++)
		if (mlxsw_sp_port_created(mlxsw_sp, base_port + i * offset))
		if (mlxsw_sp_port_created(mlxsw_sp, base_port + i * offset))
+1 −0
Original line number Original line Diff line number Diff line
@@ -293,6 +293,7 @@ struct mlxsw_sp_port {
		u16 egr_types;
		u16 egr_types;
		struct mlxsw_sp_ptp_port_stats stats;
		struct mlxsw_sp_ptp_port_stats stats;
	} ptp;
	} ptp;
	u8 split_base_local_port;
};
};


struct mlxsw_sp_port_type_speed_ops {
struct mlxsw_sp_port_type_speed_ops {