Skip to content

Commit cf34e1f

Browse files
paravmellanoxjgunthorpe
authored andcommitted
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 <[email protected]> Reviewed-by: Mark Bloch <[email protected]> Reviewed-by: Yuval Avnery <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent cfc30ad commit cf34e1f

File tree

1 file changed

+34
-6
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+34
-6
lines changed

drivers/infiniband/hw/mlx5/main.c

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,24 +476,51 @@ static int mlx5_query_port_roce(struct ib_device *device, u8 port_num,
476476
return err;
477477
}
478478

479+
struct mlx5_ib_vlan_info {
480+
u16 vlan_id;
481+
bool vlan;
482+
};
483+
484+
static int get_lower_dev_vlan(struct net_device *lower_dev, void *data)
485+
{
486+
struct mlx5_ib_vlan_info *vlan_info = data;
487+
488+
if (is_vlan_dev(lower_dev)) {
489+
vlan_info->vlan = true;
490+
vlan_info->vlan_id = vlan_dev_vlan_id(lower_dev);
491+
}
492+
/* We are interested only in first level vlan device, so
493+
* always return 1 to stop iterating over next level devices.
494+
*/
495+
return 1;
496+
}
497+
479498
static int set_roce_addr(struct mlx5_ib_dev *dev, u8 port_num,
480499
unsigned int index, const union ib_gid *gid,
481500
const struct ib_gid_attr *attr)
482501
{
483502
enum ib_gid_type gid_type = IB_GID_TYPE_IB;
503+
struct mlx5_ib_vlan_info vlan_info = { };
484504
u8 roce_version = 0;
485505
u8 roce_l3_type = 0;
486-
bool vlan = false;
487506
u8 mac[ETH_ALEN];
488-
u16 vlan_id = 0;
489507

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

494512
if (is_vlan_dev(attr->ndev)) {
495-
vlan = true;
496-
vlan_id = vlan_dev_vlan_id(attr->ndev);
513+
vlan_info.vlan = true;
514+
vlan_info.vlan_id = vlan_dev_vlan_id(attr->ndev);
515+
} else {
516+
/* If the netdev is upper device and if it's lower
517+
* lower device is vlan device, consider vlan id of
518+
* the lower vlan device for this gid entry.
519+
*/
520+
rcu_read_lock();
521+
netdev_walk_all_lower_dev_rcu(attr->ndev,
522+
get_lower_dev_vlan, &vlan_info);
523+
rcu_read_unlock();
497524
}
498525
}
499526

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

516543
return mlx5_core_roce_gid_set(dev->mdev, index, roce_version,
517-
roce_l3_type, gid->raw, mac, vlan,
518-
vlan_id, port_num);
544+
roce_l3_type, gid->raw, mac,
545+
vlan_info.vlan, vlan_info.vlan_id,
546+
port_num);
519547
}
520548

521549
static int mlx5_ib_add_gid(const struct ib_gid_attr *attr,

0 commit comments

Comments
 (0)