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

Commit cf34e1fe authored by Parav Pandit's avatar Parav Pandit Committed by Jason Gunthorpe
Browse files

IB/mlx5: Consider vlan of lower netdev for macvlan GID entries



When a given netdev of the GID entry is macvlan netdevice, and if the
lower netdevice is vlan device, GID entry for macvlan based IP address
needs to inherit the vlan of the lower netdevice.

Therefore, attempt to find out if the lower device exist and if so, if
it is vlan device and setup the vlan tag correctly.

Signed-off-by: default avatarParav Pandit <parav@mellanox.com>
Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
Reviewed-by: default avatarYuval Avnery <yuvalav@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@mellanox.com>
parent cfc30ad3
Loading
Loading
Loading
Loading
+34 −6
Original line number Diff line number Diff line
@@ -476,24 +476,51 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
	return err;
}

struct mlx5_ib_vlan_info {
	u16 vlan_id;
	bool vlan;
};

static int get_lower_dev_vlan(struct net_device *lower_dev, void *data)
{
	struct mlx5_ib_vlan_info *vlan_info = data;

	if (is_vlan_dev(lower_dev)) {
		vlan_info->vlan = true;
		vlan_info->vlan_id = vlan_dev_vlan_id(lower_dev);
	}
	/* We are interested only in first level vlan device, so
	 * always return 1 to stop iterating over next level devices.
	 */
	return 1;
}

static int set_roce_addr(struct mlx5_ib_dev *dev, u8 port_num,
			 unsigned int index, const union ib_gid *gid,
			 const struct ib_gid_attr *attr)
{
	enum ib_gid_type gid_type = IB_GID_TYPE_IB;
	struct mlx5_ib_vlan_info vlan_info = { };
	u8 roce_version = 0;
	u8 roce_l3_type = 0;
	bool vlan = false;
	u8 mac[ETH_ALEN];
	u16 vlan_id = 0;

	if (gid) {
		gid_type = attr->gid_type;
		ether_addr_copy(mac, attr->ndev->dev_addr);

		if (is_vlan_dev(attr->ndev)) {
			vlan = true;
			vlan_id = vlan_dev_vlan_id(attr->ndev);
			vlan_info.vlan = true;
			vlan_info.vlan_id = vlan_dev_vlan_id(attr->ndev);
		} else {
			/* If the netdev is upper device and if it's lower
			 * lower device is vlan device, consider vlan id of
			 * the lower vlan device for this gid entry.
			 */
			rcu_read_lock();
			netdev_walk_all_lower_dev_rcu(attr->ndev,
					get_lower_dev_vlan, &vlan_info);
			rcu_read_unlock();
		}
	}

@@ -514,8 +541,9 @@ static int set_roce_addr(struct mlx5_ib_dev *dev, u8 port_num,
	}

	return mlx5_core_roce_gid_set(dev->mdev, index, roce_version,
				      roce_l3_type, gid->raw, mac, vlan,
				      vlan_id, port_num);
				      roce_l3_type, gid->raw, mac,
				      vlan_info.vlan, vlan_info.vlan_id,
				      port_num);
}

static int mlx5_ib_add_gid(const struct ib_gid_attr *attr,