Commit 7c34ec19 authored by Aviv Heller's avatar Aviv Heller Committed by Saeed Mahameed
Browse files

net/mlx5: Make RoCE and SR-IOV LAG modes explicit



With the introduction of SR-IOV LAG, checking whether LAG is active
is no longer good enough, since RoCE and SR-IOV LAG each entails
different behavior by both the core and infiniband drivers.

This patch introduces facilities to discern LAG type, in addition to
mlx5_lag_is_active(). These are implemented in such a way as to allow
more complex mode combinations in the future.

Signed-off-by: default avatarAviv Heller <avivh@mellanox.com>
Reviewed-by: default avatarRoi Dayan <roid@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 292612d6
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -445,7 +445,7 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
	if (!ndev)
		goto out;

	if (mlx5_lag_is_active(dev->mdev)) {
	if (dev->lag_active) {
		rcu_read_lock();
		upper = netdev_master_upper_dev_get_rcu(ndev);
		if (upper) {
@@ -1848,7 +1848,7 @@ static struct ib_ucontext *mlx5_ib_alloc_ucontext(struct ib_device *ibdev,
	context->lib_caps = req.lib_caps;
	print_lib_caps(dev, context->lib_caps);

	if (mlx5_lag_is_active(dev->mdev)) {
	if (dev->lag_active) {
		u8 port = mlx5_core_native_port_num(dev->mdev);

		atomic_set(&context->tx_port_affinity,
@@ -4841,7 +4841,7 @@ static int mlx5_eth_lag_init(struct mlx5_ib_dev *dev)
	struct mlx5_flow_table *ft;
	int err;

	if (!ns || !mlx5_lag_is_active(mdev))
	if (!ns || !mlx5_lag_is_roce(mdev))
		return 0;

	err = mlx5_cmd_create_vport_lag(mdev);
@@ -4855,6 +4855,7 @@ static int mlx5_eth_lag_init(struct mlx5_ib_dev *dev)
	}

	dev->flow_db->lag_demux_ft = ft;
	dev->lag_active = true;
	return 0;

err_destroy_vport_lag:
@@ -4866,7 +4867,9 @@ static void mlx5_eth_lag_cleanup(struct mlx5_ib_dev *dev)
{
	struct mlx5_core_dev *mdev = dev->mdev;

	if (dev->flow_db->lag_demux_ft) {
	if (dev->lag_active) {
		dev->lag_active = false;

		mlx5_destroy_flow_table(dev->flow_db->lag_demux_ft);
		dev->flow_db->lag_demux_ft = NULL;

@@ -6173,7 +6176,7 @@ int mlx5_ib_stage_ib_reg_init(struct mlx5_ib_dev *dev)
	const char *name;

	rdma_set_device_sysfs_group(&dev->ib_dev, &mlx5_attr_group);
	if (!mlx5_lag_is_active(dev->mdev))
	if (!mlx5_lag_is_roce(dev->mdev))
		name = "mlx5_%d";
	else
		name = "mlx5_bond_%d";
+1 −0
Original line number Diff line number Diff line
@@ -936,6 +936,7 @@ struct mlx5_ib_dev {
	struct mlx5_ib_delay_drop	delay_drop;
	const struct mlx5_ib_profile	*profile;
	struct mlx5_eswitch_rep		*rep;
	int				lag_active;

	struct mlx5_ib_lb_state		lb;
	u8			umr_fence;
+1 −1
Original line number Diff line number Diff line
@@ -3258,7 +3258,7 @@ static int __mlx5_ib_modify_qp(struct ib_qp *ibqp,
		    (ibqp->qp_type == IB_QPT_RAW_PACKET) ||
		    (ibqp->qp_type == IB_QPT_XRC_INI) ||
		    (ibqp->qp_type == IB_QPT_XRC_TGT)) {
			if (mlx5_lag_is_active(dev->mdev)) {
			if (dev->lag_active) {
				u8 p = mlx5_core_native_port_num(dev->mdev);
				tx_affinity = get_tx_affinity(dev, pd, base, p);
				context->flags |= cpu_to_be32(tx_affinity << 24);
+2 −2
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ static int mlx5e_route_lookup_ipv4(struct mlx5e_priv *priv,
	dst_is_lag_dev = (uplink_upper &&
			  netif_is_lag_master(uplink_upper) &&
			  rt->dst.dev == uplink_upper &&
			  mlx5_lag_is_active(priv->mdev));
			  mlx5_lag_is_sriov(priv->mdev));

	/* if the egress device isn't on the same HW e-switch or
	 * it's a LAG device, use the uplink
@@ -94,7 +94,7 @@ static int mlx5e_route_lookup_ipv6(struct mlx5e_priv *priv,
	dst_is_lag_dev = (uplink_upper &&
			  netif_is_lag_master(uplink_upper) &&
			  dst->dev == uplink_upper &&
			  mlx5_lag_is_active(priv->mdev));
			  mlx5_lag_is_sriov(priv->mdev));

	/* if the egress device isn't on the same HW e-switch or
	 * it's a LAG device, use the uplink
+1 −1
Original line number Diff line number Diff line
@@ -314,7 +314,7 @@ int mlx5e_attr_get(struct net_device *dev, struct switchdev_attr *attr)
	switch (attr->id) {
	case SWITCHDEV_ATTR_ID_PORT_PARENT_ID:
		attr->u.ppid.id_len = ETH_ALEN;
		if (uplink_upper && mlx5_lag_is_active(uplink_priv->mdev)) {
		if (uplink_upper && mlx5_lag_is_sriov(uplink_priv->mdev)) {
			ether_addr_copy(attr->u.ppid.id, uplink_upper->dev_addr);
		} else {
			struct mlx5e_rep_priv *rpriv = priv->ppriv;
Loading