summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorLeon Romanovsky <leon@kernel.org>2026-10-01 11:43:41 -0400
committerLeon Romanovsky <leon@kernel.org>2026-10-01 11:43:41 -0400
commit83289f6596d268699bbe035a511d78fb131fe221 (patch)
tree7a5e54e8b27424a76d2cf098af0ecfc5ea98d345 /include/linux
parent4dd2160af277acf8f2897a2ec7df4352a7ca50bd (diff)
parent00290b9ff59ef47b990d26a6b1a8b2ea6dedf5e9 (diff)
downloadlinux-next-83289f6596d268699bbe035a511d78fb131fe221.tar.gz
linux-next-83289f6596d268699bbe035a511d78fb131fe221.zip
mlx5: Move data direct infrastructure to mlx5_core
Data direct support currently lives in mlx5_ib, which owns the data direct PCI driver, device matching and resource management. To prepare for data direct support in netdev, move this infrastructure to mlx5_core and provide a common interface for its consumers. The series first replaces the direct IB unbind callback with a blocking notifier chain, allowing multiple consumers to receive unbind events. It then separates consumer registration from initialization, consolidates the per-device state and resources, and keeps IB-specific locking and MR teardown in mlx5_ib. With these preparations in place, the final patch moves the shared implementation and PCI driver to mlx5_core. Data direct initialization and resource creation run during core load, before consumers attach; cleanup runs during core unload, after consumers detach. The data direct PCI driver is also explicitly named "mlx5_dd", replacing the previous "mlx5_ib" name derived from KBUILD_MODNAME. This series by Dragos prepares the shared infrastructure for netdev support. The netdev consumer will follow in a separate series. Signed-off-by: Leon Romanovsky <leon@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/mlx5/data_direct.h47
-rw-r--r--include/linux/mlx5/driver.h8
2 files changed, 55 insertions, 0 deletions
diff --git a/include/linux/mlx5/data_direct.h b/include/linux/mlx5/data_direct.h
new file mode 100644
index 000000000000..4cff5ff5489d
--- /dev/null
+++ b/include/linux/mlx5/data_direct.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
+/*
+ * Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved
+ */
+
+#ifndef _MLX5_DATA_DIRECT_H
+#define _MLX5_DATA_DIRECT_H
+
+#include <linux/compiler.h>
+#include <linux/list.h>
+
+struct device;
+struct mlx5_core_dev;
+struct notifier_block;
+struct pci_dev;
+
+enum mlx5_data_direct_event {
+ MLX5_DATA_DIRECT_UNBIND,
+};
+
+struct mlx5_data_direct_dev {
+ struct device *device;
+ struct pci_dev *pdev;
+ char *vuid;
+ struct list_head list;
+};
+
+struct mlx5_data_direct {
+ struct mlx5_data_direct_dev *dev;
+ u32 pdn;
+ u32 mkey;
+ u32 mkey_ro;
+ u8 mkey_ro_valid :1;
+};
+
+static inline struct mlx5_data_direct_dev *
+mlx5_data_direct_get_dev(struct mlx5_data_direct *dd)
+{
+ return dd ? READ_ONCE(dd->dev) : NULL;
+}
+
+int mlx5_data_direct_register(struct mlx5_core_dev *mdev,
+ struct notifier_block *nb);
+void mlx5_data_direct_unregister(struct mlx5_core_dev *mdev,
+ struct notifier_block *nb);
+
+#endif
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index 83d0a83bbfbc..abb99371ff13 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -707,6 +707,7 @@ struct mlx5_rsvd_gids {
struct mlx5_clock;
struct mlx5_clock_dev_state;
+struct mlx5_data_direct;
struct mlx5_dm;
struct mlx5_fw_tracer;
struct mlx5_vxlan;
@@ -801,6 +802,7 @@ struct mlx5_core_dev {
/* sync write combining state */
struct mutex wc_state_lock;
struct devlink *shd;
+ struct mlx5_data_direct *data_direct;
};
struct mlx5_db {
@@ -1395,4 +1397,10 @@ static inline struct net *mlx5_core_net(struct mlx5_core_dev *dev)
#define MLX5_SW_IMAGE_GUID_MAX_BYTES 9
+static inline bool mlx5_data_direct_supported(struct mlx5_core_dev *mdev)
+{
+ return MLX5_CAP_GEN(mdev, data_direct) &&
+ MLX5_CAP_GEN_2(mdev, query_vuid);
+}
+
#endif /* MLX5_DRIVER_H */