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: Parav Pandit <parav@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Reviewed-by: Yuval Avnery <yuvalav@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
This commit is contained in:
Parav Pandit 2019-01-27 20:35:50 +02:00 committed by Jason Gunthorpe
parent cfc30ad3d0
commit cf34e1fe52

View File

@ -476,24 +476,51 @@ out:
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,