Skip to contentSkip to conversation

net/mlx5: link status change for bonding cases

PATCH In review Haifei Luo 3 participants 3 messages Feb 26, 2024 – Mar 12, 2024 Network drivers

lore
Share & tools
lore

Haifei Luo

author
#0 lore raw

PATCH 1/1 net/mlx5: link status change for bonding cases

The current implementation of mlx5_dev_interrupt_nl_cb routine first compares if event netlink if_index belongs to the same device. This is not fully correct for the bonding device since the bonding master and slave interface netlink events indicate the bonding link status change as well. Add check for if_index is related to the bonding's master/slave.

The following step is that it compares the device link status before and after the netlink event handling. There are also the bonding specifics and it should compare the link status of the bonding master to detect the actual status change.

---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 55 ++++++++++++++++++++++++++++++---
 1 file changed, 50 insertions(+), 5 deletions(-)
drivers/net/mlx5/linux/mlx5_ethdev_os.c +50 -5
index dd5a0c5..a9b94f8 100644
@@ -768,6 +768,47 @@ struct ethtool_link_settings {
 	}
 }
 
+static bool
+mlx5_dev_nl_ifindex_verify(uint32_t if_index, struct mlx5_priv *priv)
+{
+	struct mlx5_bond_info *bond = &priv->sh->bond;
+	int i;
+
+	if (bond->n_port == 0)
+		return (if_index == priv->if_index);
+
+	if (if_index == bond->ifindex)
+		return true;
+	for (i = 0; i < bond->n_port; i++) {
+		if (i >= MLX5_BOND_MAX_PORTS)
+			return false;
+		if (if_index == bond->ports[i].ifindex)
+			return true;
+	}
+
+	return false;
+}
+
+static void
+mlx5_link_update_bond(struct rte_eth_dev *dev)
+{
+	struct mlx5_priv *priv = dev->data->dev_private;
+	struct mlx5_bond_info *bond = &priv->sh->bond;
+	struct ifreq ifr = (struct ifreq) {
+		.ifr_flags = 0,
+	};
+	int ret;
+
+	ret = mlx5_ifreq_by_ifname(bond->ifname, SIOCGIFFLAGS, &ifr);
+	if (ret) {
+		DRV_LOG(WARNING, "ifname %s ioctl(SIOCGIFFLAGS) failed: %s",
+			bond->ifname, strerror(rte_errno));
+		return;
+	}
+	dev->data->dev_link.link_status =
+		((ifr.ifr_flags & IFF_UP) && (ifr.ifr_flags & IFF_RUNNING));
+}
+
 static void
 mlx5_dev_interrupt_nl_cb(struct nlmsghdr *hdr, void *cb_arg)
 {
@@ -790,16 +831,20 @@ struct ethtool_link_settings {
 		    !dev->data->dev_conf.intr_conf.lsc)
 			break;
 		priv = dev->data->dev_private;
-		if (priv->if_index == if_index) {
+		if (mlx5_dev_nl_ifindex_verify(if_index, priv)) {
 			/* Block logical LSC events. */
 			uint16_t prev_status = dev->data->dev_link.link_status;
 
-			if (mlx5_link_update(dev, 0) < 0)
+			if (mlx5_link_update(dev, 0) < 0) {
 				DRV_LOG(ERR, "Failed to update link status: %s",
 					rte_strerror(rte_errno));
-			else if (prev_status != dev->data->dev_link.link_status)
-				rte_eth_dev_callback_process
-					(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+			} else {
+				if (priv->sh->bond.n_port)
+					mlx5_link_update_bond(dev);
+				if (prev_status != dev->data->dev_link.link_status)
+					rte_eth_dev_callback_process
+						(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
+			}
 			break;
 		}
 	}
Signature · 1 line
1.8.3.1
Acked-by on v1 1/1
#1 lore raw
Quoted 18 lines

-----Original Message-----
From: Haifei Luo <[email protected]>
Sent: Monday, February 26, 2024 2:04 PM
To: Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Dariusz Sosnowski <[email protected]>; Suanming Mou <[email protected]>
Cc: [email protected]; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Wisam Jaddo <[email protected]>; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>
Subject: [PATCH] net/mlx5: link status change for bonding cases

The current implementation of mlx5_dev_interrupt_nl_cb routine first compares if event netlink if_index belongs to the same device. This is not fully correct for the bonding device since the bonding master and slave interface netlink events indicate the bonding link status change as well. Add check for if_index is related to the bonding's master/slave.

Quoted 6 lines

The following step is that it compares the device link status before and after the netlink event handling. There are also the bonding specifics and it should compare the link status of the bonding master to detect the actual status change.

#2 lore raw
In reply to Haifei Luo

Hi,

Quoted 19 lines

-----Original Message-----
From: Haifei Luo <[email protected]>
Sent: Monday, February 26, 2024 2:04 PM
To: Ori Kam <[email protected]>; Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Shahaf Shuler <[email protected]>; Dariusz Sosnowski <[email protected]>; Suanming Mou <[email protected]>
Cc: [email protected]; NBU-Contact-Thomas Monjalon (EXTERNAL) <[email protected]>; Wisam Jaddo <[email protected]>; Raslan Darawsheh <[email protected]>; Roni Bar Yanai <[email protected]>
Subject: [PATCH] net/mlx5: link status change for bonding cases

The current implementation of mlx5_dev_interrupt_nl_cb routine first compares if event netlink if_index belongs to the same device. This is not fully correct for the bonding device since the bonding master and slave interface netlink events indicate the bonding link status change as well. Add check for if_index is related to the bonding's master/slave.

Quoted 6 lines

The following step is that it compares the device link status before and after the netlink event handling. There are also the bonding specifics and it should compare the link status of the bonding master to detect the actual status change.

Patch applied to next-net-mlx,
Kindest regards
Raslan Darawsheh