diff --git a/drivers/infiniband/hw/mlx5/fs.c b/drivers/infiniband/hw/mlx5/fs.c
index 251246c73b33..f089abbed6af 100644
--- a/drivers/infiniband/hw/mlx5/fs.c
+++ b/drivers/infiniband/hw/mlx5/fs.c
@@ -684,12 +684,14 @@ enum flow_table_type {
 #define MLX5_FS_MAX_TYPES	 6
 #define MLX5_FS_MAX_ENTRIES	 BIT(16)
 
-static bool __maybe_unused mlx5_ib_shared_ft_allowed(struct ib_device *device)
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
+static bool mlx5_ib_shared_ft_allowed(struct ib_device *device)
 {
 	struct mlx5_ib_dev *dev = to_mdev(device);
 
 	return MLX5_CAP_GEN(dev->mdev, shared_object_to_user_object_allowed);
 }
+#endif
 
 static struct mlx5_ib_flow_prio *_get_prio(struct mlx5_ib_dev *dev,
 					   struct mlx5_flow_namespace *ns,
@@ -1888,6 +1890,7 @@ static struct ib_flow *mlx5_ib_create_flow(struct ib_qp *qp,
 	return ERR_PTR(err);
 }
 
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 static int mlx5_ib_fill_transport_ns_info(struct mlx5_ib_dev *dev,
 					  enum mlx5_flow_namespace_type type,
 					  u32 *flags, u16 *vport_idx,
@@ -2227,6 +2230,7 @@ static struct mlx5_ib_flow_handler *raw_fs_rule_add(
 
 	return ERR_PTR(err);
 }
+#endif
 
 static void destroy_flow_action_raw(struct mlx5_ib_flow_action *maction)
 {
@@ -2263,6 +2267,7 @@ static int mlx5_ib_destroy_flow_action(struct ib_flow_action *action)
 	return 0;
 }
 
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 static int
 mlx5_ib_ft_type_to_namespace(enum mlx5_ib_uapi_flow_table_type table_type,
 			     enum mlx5_flow_namespace_type *namespace)
@@ -2618,6 +2623,7 @@ static int steering_anchor_create_ft(struct mlx5_ib_dev *dev,
 
 	return 0;
 }
+#endif
 
 static void steering_anchor_destroy_ft(struct mlx5_ib_flow_prio *ft_prio)
 {
@@ -2627,6 +2633,7 @@ static void steering_anchor_destroy_ft(struct mlx5_ib_flow_prio *ft_prio)
 	}
 }
 
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 static int
 steering_anchor_create_fg_drop(struct mlx5_ib_flow_prio *ft_prio)
 {
@@ -2658,6 +2665,7 @@ steering_anchor_create_fg_drop(struct mlx5_ib_flow_prio *ft_prio)
 
 	return err;
 }
+#endif
 
 static void
 steering_anchor_destroy_fg_drop(struct mlx5_ib_flow_prio *ft_prio)
@@ -2668,6 +2676,7 @@ steering_anchor_destroy_fg_drop(struct mlx5_ib_flow_prio *ft_prio)
 	}
 }
 
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 static int
 steering_anchor_create_fg_goto_table(struct mlx5_ib_flow_prio *ft_prio)
 {
@@ -2695,6 +2704,7 @@ steering_anchor_create_fg_goto_table(struct mlx5_ib_flow_prio *ft_prio)
 
 	return err;
 }
+#endif
 
 static void
 steering_anchor_destroy_fg_goto_table(struct mlx5_ib_flow_prio *ft_prio)
@@ -2705,6 +2715,7 @@ steering_anchor_destroy_fg_goto_table(struct mlx5_ib_flow_prio *ft_prio)
 	}
 }
 
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 static int
 steering_anchor_create_rule_drop(struct mlx5_ib_flow_prio *ft_prio)
 {
@@ -2726,6 +2737,7 @@ steering_anchor_create_rule_drop(struct mlx5_ib_flow_prio *ft_prio)
 
 	return 0;
 }
+#endif
 
 static void steering_anchor_destroy_rule_drop(struct mlx5_ib_flow_prio *ft_prio)
 {
@@ -2735,6 +2747,7 @@ static void steering_anchor_destroy_rule_drop(struct mlx5_ib_flow_prio *ft_prio)
 	}
 }
 
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 static int
 steering_anchor_create_rule_goto_table(struct mlx5_ib_flow_prio *ft_prio)
 {
@@ -2761,6 +2774,7 @@ steering_anchor_create_rule_goto_table(struct mlx5_ib_flow_prio *ft_prio)
 
 	return 0;
 }
+#endif
 
 static void
 steering_anchor_destroy_rule_goto_table(struct mlx5_ib_flow_prio *ft_prio)
@@ -2771,6 +2785,7 @@ steering_anchor_destroy_rule_goto_table(struct mlx5_ib_flow_prio *ft_prio)
 	}
 }
 
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 static int steering_anchor_create_res(struct mlx5_ib_dev *dev,
 				      struct mlx5_ib_flow_prio *ft_prio,
 				      enum mlx5_flow_namespace_type ns_type)
@@ -2810,6 +2825,7 @@ static int steering_anchor_create_res(struct mlx5_ib_dev *dev,
 
 	return err;
 }
+#endif
 
 static void mlx5_steering_anchor_destroy_res(struct mlx5_ib_flow_prio *ft_prio)
 {
@@ -2820,6 +2836,7 @@ static void mlx5_steering_anchor_destroy_res(struct mlx5_ib_flow_prio *ft_prio)
 	steering_anchor_destroy_ft(ft_prio);
 }
 
+#ifdef CONFIG_INFINIBAND_USER_ACCESS
 static int steering_anchor_cleanup(struct ib_uobject *uobject,
 				   enum rdma_remove_reason why,
 				   struct uverbs_attr_bundle *attrs)
@@ -2839,6 +2856,7 @@ static int steering_anchor_cleanup(struct ib_uobject *uobject,
 	kfree(obj);
 	return 0;
 }
+#endif
 
 static void fs_cleanup_anchor(struct mlx5_ib_flow_prio *prio,
 			      int count)
@@ -2858,6 +2876,7 @@ void mlx5_ib_fs_cleanup_anchor(struct mlx5_ib_dev *dev)
 	fs_cleanup_anchor(dev->flow_db->rdma_tx, MLX5_IB_NUM_FLOW_FT);
 }
 
+#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
 static int mlx5_ib_matcher_ns(struct uverbs_attr_bundle *attrs,
 			      struct mlx5_ib_flow_matcher *obj)
 {
@@ -3459,6 +3478,7 @@ DECLARE_UVERBS_NAMED_OBJECT(
 	UVERBS_TYPE_ALLOC_IDR(steering_anchor_cleanup),
 	&UVERBS_METHOD(MLX5_IB_METHOD_STEERING_ANCHOR_CREATE),
 	&UVERBS_METHOD(MLX5_IB_METHOD_STEERING_ANCHOR_DESTROY));
+#endif
 
 const struct uapi_definition mlx5_ib_flow_defs[] = {
 #if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
