Skip to contentSkip to conversation

RDMA/core: Do not use netdev if it is a bonded slave

PATCH Superseded [email protected] 1 participant 4 messages Nov 27, 2024

Subsystems (5)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 RDMA/core: Do not use netdev if it is a bonded slave

From: Long Li <[email protected]>

Filter function is_eth_port_of_netdev_filter() is used to determine if a netdev should be used for assigning its IP to GID cache. This function should filter out bonded slave netdevs. For bonded slaves, their master netdevs should be used to cache GIDs.

---
 drivers/infiniband/core/roce_gid_mgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/roce_gid_mgmt.c +1 -1
index a9f2c6b1b29e..27a3ffed11b9 100644
@@ -161,7 +161,7 @@ is_eth_port_of_netdev_filter(struct ib_device *ib_dev, u32 port,
 	res = ((rdma_is_upper_dev_rcu(rdma_ndev, cookie) &&
 	       (is_eth_active_slave_of_bonding_rcu(rdma_ndev, real_dev) &
 		REQUIRED_BOND_STATES)) ||
-	       real_dev == rdma_ndev);
+	       (real_dev == rdma_ndev && !netif_is_bond_slave(rdma_ndev)));
 
 	rcu_read_unlock();
 	return res;
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/1 RDMA/mana_ib: Use the correct net device for IB

From: Long Li <[email protected]>

mana_ib should not set the net device on its master device when it's bonded. The main purpose of doing this is to get the correct GID, however it makes it impossible to unload the master device from kernel, and move to user-space (e.g. DPDK usage).

Fix this by using its VF device as net device. RoCE core will handle the GID caching by looking for its correct master device.

Fixes 1df03a4b4414 ("RDMA/mana_ib: Set correct device into ib")
---
 drivers/infiniband/hw/mana/device.c           |  7 +++----
 drivers/net/ethernet/microsoft/mana/mana_en.c | 16 +++-------------
 include/net/mana/mana.h                       |  2 +-
 3 files changed, 7 insertions(+), 18 deletions(-)
drivers/infiniband/hw/mana/device.c +3 -4
index 7ac01918ef7c..52784a7cf89a 100644
@@ -84,18 +84,17 @@ static int mana_ib_probe(struct auxiliary_device *adev,
 	dev->ib_dev.num_comp_vectors = mdev->gdma_context->max_num_queues;
 	dev->ib_dev.dev.parent = mdev->gdma_context->dev;
 
-	rcu_read_lock(); /* required to get primary netdev */
-	ndev = mana_get_primary_netdev_rcu(mc, 0);
+	ndev = mana_get_primary_netdev(mc, 0);
 	if (!ndev) {
-		rcu_read_unlock();
 		ret = -ENODEV;
 		ibdev_err(&dev->ib_dev, "Failed to get netdev for IB port 1");
 		goto free_ib_device;
 	}
+
 	ether_addr_copy(mac_addr, ndev->dev_addr);
 	addrconf_addr_eui48((u8 *)&dev->ib_dev.node_guid, ndev->dev_addr);
+
 	ret = ib_device_set_netdev(&dev->ib_dev, ndev, 1);
-	rcu_read_unlock();
 	if (ret) {
 		ibdev_err(&dev->ib_dev, "Failed to set ib netdev, ret %d", ret);
 		goto free_ib_device;
drivers/net/ethernet/microsoft/mana/mana_en.c +3 -13
index 57ac732e7707..c0c5e2997a9d 100644
@@ -3130,21 +3130,11 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
 	kfree(ac);
 }
 
-struct net_device *mana_get_primary_netdev_rcu(struct mana_context *ac, u32 port_index)
+struct net_device *mana_get_primary_netdev(struct mana_context *ac, u32 port_index)
 {
-	struct net_device *ndev;
-
-	RCU_LOCKDEP_WARN(!rcu_read_lock_held(),
-			 "Taking primary netdev without holding the RCU read lock");
 	if (port_index >= ac->num_ports)
 		return NULL;
 
-	/* When mana is used in netvsc, the upper netdevice should be returned. */
-	if (ac->ports[port_index]->flags & IFF_SLAVE)
-		ndev = netdev_master_upper_dev_get_rcu(ac->ports[port_index]);
-	else
-		ndev = ac->ports[port_index];
-
-	return ndev;
+	return ac->ports[port_index];
 }
-EXPORT_SYMBOL_NS(mana_get_primary_netdev_rcu, NET_MANA);
+EXPORT_SYMBOL_NS(mana_get_primary_netdev, NET_MANA);
include/net/mana/mana.h +1 -1
index 0d00b24eacaf..770359ce7d3b 100644
@@ -827,5 +827,5 @@ int mana_cfg_vport(struct mana_port_context *apc, u32 protection_dom_id,
 		   u32 doorbell_pg_id);
 void mana_uncfg_vport(struct mana_port_context *apc);
 
-struct net_device *mana_get_primary_netdev_rcu(struct mana_context *ac, u32 port_index);
+struct net_device *mana_get_primary_netdev(struct mana_context *ac, u32 port_index);
 #endif /* _MANA_H */
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 RDMA/core: Use upper_device_filter() to add upper IPs

In reply to [email protected]

From: Long Li <[email protected]>

add_cmd_upper_ips() is used to add upper IPs on a bonded slave. Its filter function should be set to the same as upper_ips_del_cmd() in that it looks for upper netdevs for GIDs.

---
 drivers/infiniband/core/roce_gid_mgmt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/core/roce_gid_mgmt.c +1 -1
index 27a3ffed11b9..827a50dbd308 100644
@@ -689,7 +689,7 @@ static const struct netdev_event_work_cmd add_cmd = {
 
 static const struct netdev_event_work_cmd add_cmd_upper_ips = {
 	.cb	= add_netdev_upper_ips,
-	.filter = is_eth_port_of_netdev_filter
+	.filter = upper_device_filter
 };
 
 static void
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/3 RDMA/core: Add default IP when a bonded slave is unlinked

In reply to [email protected]

From: Long Li <[email protected]>

When a bonded slave is unlikned, the current code doesn't add a default GID for the new unlinked netdev.

Add a default GID for the netdev.

---
 drivers/infiniband/core/roce_gid_mgmt.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/infiniband/core/roce_gid_mgmt.c +7 -6
index 827a50dbd308..3fa2740fa0d2 100644
@@ -692,6 +692,11 @@ static const struct netdev_event_work_cmd add_cmd_upper_ips = {
 	.filter = upper_device_filter
 };
 
+static const struct netdev_event_work_cmd add_default_gid_cmd = {
+	.cb	= add_default_gids,
+	.filter	= is_ndev_for_default_gid_filter,
+};
+
 static void
 ndev_event_unlink(struct netdev_notifier_changeupper_info *changeupper_info,
 		  struct netdev_event_work_cmd *cmds)
@@ -704,7 +709,8 @@ ndev_event_unlink(struct netdev_notifier_changeupper_info *changeupper_info,
 
 	cmds[0] = upper_ips_del_cmd;
 	cmds[0].ndev = changeupper_info->upper_dev;
-	cmds[1] = add_cmd;
+	cmds[1] = add_default_gid_cmd;
+	cmds[2] = add_cmd;
 }
 
 static const struct netdev_event_work_cmd bonding_default_add_cmd = {
@@ -751,11 +757,6 @@ static void netdevice_event_changeupper(struct net_device *event_ndev,
 		ndev_event_unlink(changeupper_info, cmds);
 }
 
-static const struct netdev_event_work_cmd add_default_gid_cmd = {
-	.cb	= add_default_gids,
-	.filter	= is_ndev_for_default_gid_filter,
-};
-
 static int netdevice_event(struct notifier_block *this, unsigned long event,
 			   void *ptr)
 {
Signature · 1 line
2.34.1