Skip to content

Commit c65cfd5

Browse files
author
Maxim Levitsky
committed
RDMA/mana_ib: Set correct device into ib
JIRA: https://issues.redhat.com/browse/RHEL-54330 commit 1df03a4 Author: Konstantin Taranov <kotaranov@microsoft.com> Date: Thu Jul 11 06:37:57 2024 -0700 RDMA/mana_ib: Set correct device into ib Add mana_get_primary_netdev_rcu helper to get a primary netdevice for a given port. When mana is used with netvsc, the VF netdev is controlled by an upper netvsc device. In a baremetal case, the VF netdev is the primary device. Use the mana_get_primary_netdev_rcu() helper in the mana_ib to get the correct device for querying network states. Fixes: 8b184e4 ("RDMA/mana_ib: Enable RoCE on port 1") Signed-off-by: Konstantin Taranov <kotaranov@microsoft.com> Link: https://lore.kernel.org/r/1720705077-322-1-git-send-email-kotaranov@linux.microsoft.com Reviewed-by: Long Li <longli@microsoft.com> Reviewed-by: Zhu Yanjun <yanjun.zhu@linux.dev> Signed-off-by: Leon Romanovsky <leon@kernel.org> Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com>
1 parent 7cc1d6c commit c65cfd5

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

drivers/infiniband/hw/mana/device.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static int mana_ib_probe(struct auxiliary_device *adev,
5757
{
5858
struct mana_adev *madev = container_of(adev, struct mana_adev, adev);
5959
struct gdma_dev *mdev = madev->mdev;
60-
struct net_device *upper_ndev;
60+
struct net_device *ndev;
6161
struct mana_context *mc;
6262
struct mana_ib_dev *dev;
6363
u8 mac_addr[ETH_ALEN];
@@ -85,17 +85,17 @@ static int mana_ib_probe(struct auxiliary_device *adev,
8585
dev->ib_dev.num_comp_vectors = mdev->gdma_context->max_num_queues;
8686
dev->ib_dev.dev.parent = mdev->gdma_context->dev;
8787

88-
rcu_read_lock(); /* required to get upper dev */
89-
upper_ndev = netdev_master_upper_dev_get_rcu(mc->ports[0]);
90-
if (!upper_ndev) {
88+
rcu_read_lock(); /* required to get primary netdev */
89+
ndev = mana_get_primary_netdev_rcu(mc, 0);
90+
if (!ndev) {
9191
rcu_read_unlock();
9292
ret = -ENODEV;
93-
ibdev_err(&dev->ib_dev, "Failed to get master netdev");
93+
ibdev_err(&dev->ib_dev, "Failed to get netdev for IB port 1");
9494
goto free_ib_device;
9595
}
96-
ether_addr_copy(mac_addr, upper_ndev->dev_addr);
97-
addrconf_addr_eui48((u8 *)&dev->ib_dev.node_guid, upper_ndev->dev_addr);
98-
ret = ib_device_set_netdev(&dev->ib_dev, upper_ndev, 1);
96+
ether_addr_copy(mac_addr, ndev->dev_addr);
97+
addrconf_addr_eui48((u8 *)&dev->ib_dev.node_guid, ndev->dev_addr);
98+
ret = ib_device_set_netdev(&dev->ib_dev, ndev, 1);
9999
rcu_read_unlock();
100100
if (ret) {
101101
ibdev_err(&dev->ib_dev, "Failed to set ib netdev, ret %d", ret);

drivers/net/ethernet/microsoft/mana/mana_en.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3006,3 +3006,22 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
30063006
gd->gdma_context = NULL;
30073007
kfree(ac);
30083008
}
3009+
3010+
struct net_device *mana_get_primary_netdev_rcu(struct mana_context *ac, u32 port_index)
3011+
{
3012+
struct net_device *ndev;
3013+
3014+
RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
3015+
"Taking primary netdev without holding the RCU read lock");
3016+
if (port_index >= ac->num_ports)
3017+
return NULL;
3018+
3019+
/* When mana is used in netvsc, the upper netdevice should be returned. */
3020+
if (ac->ports[port_index]->flags & IFF_SLAVE)
3021+
ndev = netdev_master_upper_dev_get_rcu(ac->ports[port_index]);
3022+
else
3023+
ndev = ac->ports[port_index];
3024+
3025+
return ndev;
3026+
}
3027+
EXPORT_SYMBOL_NS(mana_get_primary_netdev_rcu, NET_MANA);

include/net/mana/mana.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,4 +796,6 @@ void mana_destroy_wq_obj(struct mana_port_context *apc, u32 wq_type,
796796
int mana_cfg_vport(struct mana_port_context *apc, u32 protection_dom_id,
797797
u32 doorbell_pg_id);
798798
void mana_uncfg_vport(struct mana_port_context *apc);
799+
800+
struct net_device *mana_get_primary_netdev_rcu(struct mana_context *ac, u32 port_index);
799801
#endif /* _MANA_H */

0 commit comments

Comments
 (0)