RDMA/mlx5: Compile fs.c regardless of INFINIBAND_USER_ACCESS config
authorPatrisious Haddad <phaddad@nvidia.com>
Thu, 13 Mar 2025 14:18:45 +0000 (16:18 +0200)
committerLeon Romanovsky <leon@kernel.org>
Tue, 18 Mar 2025 10:18:52 +0000 (06:18 -0400)
Change mlx5 Makefile, fs.c and fs.h to support fs compilation regardless
of INFINIBAND_USER_ACCESS config.

In addition allow optional counters support regardless of the config.

Signed-off-by: Patrisious Haddad <phaddad@nvidia.com>
Link: https://patch.msgid.link/b8dd220456a91538b22c3aff150ab021d7b9e1bf.1741875070.git.leon@kernel.org
Signed-off-by: Leon Romanovsky <leon@kernel.org>
drivers/infiniband/hw/mlx5/Makefile
drivers/infiniband/hw/mlx5/counters.c
drivers/infiniband/hw/mlx5/fs.c
drivers/infiniband/hw/mlx5/fs.h

index b38961f5058efd2953f0b6047af48e78c87f36a5..11878ddf7cc7f991dee50edb5823928317614c9d 100644 (file)
@@ -9,6 +9,7 @@ mlx5_ib-y := ah.o \
             data_direct.o \
             dm.o \
             doorbell.o \
+            fs.o \
             gsi.o \
             ib_virt.o \
             mad.o \
@@ -26,7 +27,6 @@ mlx5_ib-y := ah.o \
 mlx5_ib-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += odp.o
 mlx5_ib-$(CONFIG_MLX5_ESWITCH) += ib_rep.o
 mlx5_ib-$(CONFIG_INFINIBAND_USER_ACCESS) += devx.o \
-                                           fs.o \
                                            qos.o \
                                            std_types.o
 mlx5_ib-$(CONFIG_MLX5_MACSEC) += macsec.o
index d826f03b6ec51550d828004e2916165514a00856..542f591d73e03d6cd95e601317c80b043d094338 100644 (file)
@@ -849,9 +849,8 @@ static void mlx5_ib_dealloc_counters(struct mlx5_ib_dev *dev)
                                    dev->port[i].cnts.opfcs, j, &in_use_opfc))
                                goto skip;
 
-                       if (IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS))
-                               mlx5_ib_fs_remove_op_fc(dev,
-                                       &dev->port[i].cnts.opfcs[j], j);
+                       mlx5_ib_fs_remove_op_fc(dev,
+                                               &dev->port[i].cnts.opfcs[j], j);
                        mlx5_fc_destroy(dev->mdev,
                                        dev->port[i].cnts.opfcs[j].fc);
 skip:
@@ -1115,8 +1114,7 @@ static const struct ib_device_ops hw_stats_ops = {
        .counter_dealloc = mlx5_ib_counter_dealloc,
        .counter_alloc_stats = mlx5_ib_counter_alloc_stats,
        .counter_update_stats = mlx5_ib_counter_update_stats,
-       .modify_hw_stat = IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS) ?
-                         mlx5_ib_modify_stat : NULL,
+       .modify_hw_stat = mlx5_ib_modify_stat,
        .counter_init = mlx5_ib_counter_init,
 
        INIT_RDMA_OBJ_SIZE(rdma_counter, mlx5_rdma_counter, rdma_counter),
index 93b229e9aab343158c280d47226768d7568d18c7..71a47821a5645c76fb79d928a45f7026beb86cac 100644 (file)
@@ -679,7 +679,7 @@ enum flow_table_type {
 #define MLX5_FS_MAX_TYPES       6
 #define MLX5_FS_MAX_ENTRIES     BIT(16)
 
-static bool mlx5_ib_shared_ft_allowed(struct ib_device *device)
+static bool __maybe_unused mlx5_ib_shared_ft_allowed(struct ib_device *device)
 {
        struct mlx5_ib_dev *dev = to_mdev(device);
 
@@ -3030,6 +3030,7 @@ DECLARE_UVERBS_NAMED_OBJECT(
        &UVERBS_METHOD(MLX5_IB_METHOD_STEERING_ANCHOR_DESTROY));
 
 const struct uapi_definition mlx5_ib_flow_defs[] = {
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
        UAPI_DEF_CHAIN_OBJ_TREE_NAMED(
                MLX5_IB_OBJECT_FLOW_MATCHER),
        UAPI_DEF_CHAIN_OBJ_TREE(
@@ -3040,6 +3041,7 @@ const struct uapi_definition mlx5_ib_flow_defs[] = {
        UAPI_DEF_CHAIN_OBJ_TREE_NAMED(
                MLX5_IB_OBJECT_STEERING_ANCHOR,
                UAPI_DEF_IS_OBJ_SUPPORTED(mlx5_ib_shared_ft_allowed)),
+#endif
        {},
 };
 
index 0516555eb1c1768699e4125d8753e20bf9d31772..2ebe86e5be1080108aaef0e7610f11b89274cb4c 100644 (file)
@@ -8,23 +8,8 @@
 
 #include "mlx5_ib.h"
 
-#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 int mlx5_ib_fs_init(struct mlx5_ib_dev *dev);
 void mlx5_ib_fs_cleanup_anchor(struct mlx5_ib_dev *dev);
-#else
-static inline int mlx5_ib_fs_init(struct mlx5_ib_dev *dev)
-{
-       dev->flow_db = kzalloc(sizeof(*dev->flow_db), GFP_KERNEL);
-
-       if (!dev->flow_db)
-               return -ENOMEM;
-
-       mutex_init(&dev->flow_db->lock);
-       return 0;
-}
-
-inline void mlx5_ib_fs_cleanup_anchor(struct mlx5_ib_dev *dev) {}
-#endif
 
 static inline void mlx5_ib_fs_cleanup(struct mlx5_ib_dev *dev)
 {