[PATCH net-next 02/10] net/mlx5e: Register supported netdevs as data direct users

From: Tariq Toukan

Date: Thu Oct 08 2026 - 09:35:52 EST


From: Dragos Tatulea <dtatulea@xxxxxxxxxx>

Register the netdev as a data direct user so it is notified when the
affiliated data direct device is unbound.

Register during NIC enable and unregister during disable so suspend
and resume follow the data direct registration lifetime in mlx5_core.

The notifier callback only traces the unbind event for now; tearing down
the data direct datapath is wired up together with that datapath in
later patches.

Signed-off-by: Dragos Tatulea <dtatulea@xxxxxxxxxx>
Signed-off-by: Tariq Toukan <tariqt@xxxxxxxxxx>
---
drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 +
.../net/ethernet/mellanox/mlx5/core/en_main.c | 21 +++++++++++++++++++
2 files changed, 22 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index a3945195f454..78cf6aedd04d 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -984,6 +984,7 @@ struct mlx5e_priv {
struct mlx5e_mqprio_rl *mqprio_rl;
struct dentry *dfs_root;
struct mlx5_devcom_comp_dev *devcom;
+ struct notifier_block data_direct_nb;
};

static inline u16 mlx5e_stats_nch_read(const struct mlx5e_priv *priv)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index f90b5a34e097..a2b3ac3011c9 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -33,6 +33,7 @@
#include <linux/dim.h>
#include <net/tc_act/tc_gact.h>
#include <linux/mlx5/fs.h>
+#include <linux/mlx5/data_direct.h>
#include <net/vxlan.h>
#include <net/geneve.h>
#include <linux/bpf.h>
@@ -6023,6 +6024,18 @@ void mlx5e_destroy_q_counters(struct mlx5e_priv *priv)
}
}

+static int mlx5e_data_direct_event(struct notifier_block *nb,
+ unsigned long action, void *data)
+{
+ struct mlx5e_priv *priv = container_of(nb, struct mlx5e_priv,
+ data_direct_nb);
+
+ if (action == MLX5_DATA_DIRECT_UNBIND)
+ mlx5_core_dbg(priv->mdev, "data direct device unbound\n");
+
+ return NOTIFY_OK;
+}
+
static int mlx5e_nic_init(struct mlx5_core_dev *mdev,
struct net_device *netdev)
{
@@ -6225,6 +6238,12 @@ static int mlx5e_nic_enable(struct mlx5e_priv *priv)

mlx5e_pcie_cong_event_init(priv);
mlx5e_hv_vhca_stats_create(priv);
+
+ if (mlx5_data_direct_supported(mdev)) {
+ priv->data_direct_nb.notifier_call = mlx5e_data_direct_event;
+ mlx5_data_direct_register(mdev, &priv->data_direct_nb);
+ }
+
if (netdev->reg_state != NETREG_REGISTERED)
return 0;
mlx5e_dcbnl_init_app(priv);
@@ -6251,6 +6270,8 @@ static void mlx5e_nic_disable(struct mlx5e_priv *priv)
{
struct mlx5_core_dev *mdev = priv->mdev;

+ mlx5_data_direct_unregister(mdev, &priv->data_direct_nb);
+
if (priv->netdev->reg_state == NETREG_REGISTERED)
mlx5e_dcbnl_delete_app(priv);

--
2.44.0