DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: link status change for bonding cases
@ 2024-02-26 12:03 Haifei Luo
  2024-02-28 17:47 ` Slava Ovsiienko
  2024-03-12  8:00 ` Raslan Darawsheh
  0 siblings, 2 replies; 3+ messages in thread
From: Haifei Luo @ 2024-02-26 12:03 UTC (permalink / raw)
  To: orika, viacheslavo, matan, shahafs, Dariusz Sosnowski, Suanming Mou
  Cc: dev, thomas, wisamm, rasland, roniba

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.

Signed-off-by: Haifei Luo <haifeil@nvidia.com>
---
 drivers/net/mlx5/linux/mlx5_ethdev_os.c | 55 ++++++++++++++++++++++++++++++---
 1 file changed, 50 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/linux/mlx5_ethdev_os.c b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
index dd5a0c5..a9b94f8 100644
--- a/drivers/net/mlx5/linux/mlx5_ethdev_os.c
+++ b/drivers/net/mlx5/linux/mlx5_ethdev_os.c
@@ -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;
 		}
 	}
-- 
1.8.3.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] net/mlx5: link status change for bonding cases
  2024-02-26 12:03 [PATCH] net/mlx5: link status change for bonding cases Haifei Luo
@ 2024-02-28 17:47 ` Slava Ovsiienko
  2024-03-12  8:00 ` Raslan Darawsheh
  1 sibling, 0 replies; 3+ messages in thread
From: Slava Ovsiienko @ 2024-02-28 17:47 UTC (permalink / raw)
  To: Haifei Luo, Ori Kam, Matan Azrad, Shahaf Shuler,
	Dariusz Sosnowski, Suanming Mou
  Cc: dev, NBU-Contact-Thomas Monjalon (EXTERNAL),
	Wisam Jaddo, Raslan Darawsheh, Roni Bar Yanai

> -----Original Message-----
> From: Haifei Luo <haifeil@nvidia.com>
> Sent: Monday, February 26, 2024 2:04 PM
> To: Ori Kam <orika@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>;
> Matan Azrad <matan@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>;
> Dariusz Sosnowski <dsosnowski@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>
> Cc: dev@dpdk.org; NBU-Contact-Thomas Monjalon (EXTERNAL)
> <thomas@monjalon.net>; Wisam Jaddo <wisamm@nvidia.com>; Raslan
> Darawsheh <rasland@nvidia.com>; Roni Bar Yanai <roniba@nvidia.com>
> 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.
> 
> 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.
> 
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] net/mlx5: link status change for bonding cases
  2024-02-26 12:03 [PATCH] net/mlx5: link status change for bonding cases Haifei Luo
  2024-02-28 17:47 ` Slava Ovsiienko
@ 2024-03-12  8:00 ` Raslan Darawsheh
  1 sibling, 0 replies; 3+ messages in thread
From: Raslan Darawsheh @ 2024-03-12  8:00 UTC (permalink / raw)
  To: Haifei Luo, Ori Kam, Slava Ovsiienko, Matan Azrad, Shahaf Shuler,
	Dariusz Sosnowski, Suanming Mou
  Cc: dev, NBU-Contact-Thomas Monjalon (EXTERNAL), Wisam Jaddo, Roni Bar Yanai

Hi,

> -----Original Message-----
> From: Haifei Luo <haifeil@nvidia.com>
> Sent: Monday, February 26, 2024 2:04 PM
> To: Ori Kam <orika@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>;
> Matan Azrad <matan@nvidia.com>; Shahaf Shuler <shahafs@nvidia.com>;
> Dariusz Sosnowski <dsosnowski@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>
> Cc: dev@dpdk.org; NBU-Contact-Thomas Monjalon (EXTERNAL)
> <thomas@monjalon.net>; Wisam Jaddo <wisamm@nvidia.com>; Raslan
> Darawsheh <rasland@nvidia.com>; Roni Bar Yanai <roniba@nvidia.com>
> 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.
> 
> 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.
> 
> Signed-off-by: Haifei Luo <haifeil@nvidia.com>

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-12  8:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-26 12:03 [PATCH] net/mlx5: link status change for bonding cases Haifei Luo
2024-02-28 17:47 ` Slava Ovsiienko
2024-03-12  8:00 ` Raslan Darawsheh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).