Skip to content

Commit 8889f6f

Browse files
committed
RDMA/core: Make the entire API tree static
Compilation of mlx5 driver without CONFIG_INFINIBAND_USER_ACCESS generates the following error. on x86_64: ld: drivers/infiniband/hw/mlx5/main.o: in function `mlx5_ib_handler_MLX5_IB_METHOD_VAR_OBJ_ALLOC': main.c:(.text+0x186d): undefined reference to `ib_uverbs_get_ucontext_file' ld: drivers/infiniband/hw/mlx5/main.o:(.rodata+0x2480): undefined reference to `uverbs_idr_class' ld: drivers/infiniband/hw/mlx5/main.o:(.rodata+0x24d8): undefined reference to `uverbs_destroy_def_handler' This is happening because some parts of the UAPI description are not static. This is a hold over from earlier code that relied on struct pointers to refer to object types, now object types are referenced by number. Remove the unused globals and add statics to the remaining UAPI description elements. Remove the redundent #ifdefs around mlx5_ib_*defs and obsolete mlx5_ib_get_devx_tree(). The compiler now trims alot more unused code, including the above problematic definitions when !CONFIG_INFINIBAND_USER_ACCESS. Fixes: 7be76be ("IB/mlx5: Introduce VAR object and its alloc/destroy methods") Reported-by: Randy Dunlap <[email protected]> Acked-by: Randy Dunlap <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent ba19e16 commit 8889f6f

File tree

4 files changed

+6
-26
lines changed

4 files changed

+6
-26
lines changed

drivers/infiniband/core/uverbs.h

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -271,23 +271,6 @@ int ib_uverbs_kern_spec_to_ib_spec_filter(enum ib_flow_spec_type type,
271271
size_t kern_filter_sz,
272272
union ib_flow_spec *ib_spec);
273273

274-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_DEVICE);
275-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_PD);
276-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_MR);
277-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_COMP_CHANNEL);
278-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_CQ);
279-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_QP);
280-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_AH);
281-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_MW);
282-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_SRQ);
283-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_FLOW);
284-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_WQ);
285-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_RWQ_IND_TBL);
286-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_XRCD);
287-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_FLOW_ACTION);
288-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_DM);
289-
extern const struct uverbs_object_def UVERBS_OBJECT(UVERBS_OBJECT_COUNTERS);
290-
291274
/*
292275
* ib_uverbs_query_port_resp.port_cap_flags started out as just a copy of the
293276
* PortInfo CapabilityMask, but was extended with unique bits.

drivers/infiniband/hw/mlx5/main.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6247,10 +6247,8 @@ ADD_UVERBS_ATTRIBUTES_SIMPLE(
62476247
enum mlx5_ib_uapi_flow_action_flags));
62486248

62496249
static const struct uapi_definition mlx5_ib_defs[] = {
6250-
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
62516250
UAPI_DEF_CHAIN(mlx5_ib_devx_defs),
62526251
UAPI_DEF_CHAIN(mlx5_ib_flow_defs),
6253-
#endif
62546252

62556253
UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_FLOW_ACTION,
62566254
&mlx5_ib_flow_action),

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,22 +1379,21 @@ int mlx5_ib_fill_res_entry(struct sk_buff *msg,
13791379
int mlx5_ib_fill_stat_entry(struct sk_buff *msg,
13801380
struct rdma_restrack_entry *res);
13811381

1382+
extern const struct uapi_definition mlx5_ib_devx_defs[];
1383+
extern const struct uapi_definition mlx5_ib_flow_defs[];
1384+
13821385
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
13831386
int mlx5_ib_devx_create(struct mlx5_ib_dev *dev, bool is_user);
13841387
void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev, u16 uid);
13851388
void mlx5_ib_devx_init_event_table(struct mlx5_ib_dev *dev);
13861389
void mlx5_ib_devx_cleanup_event_table(struct mlx5_ib_dev *dev);
1387-
const struct uverbs_object_tree_def *mlx5_ib_get_devx_tree(void);
1388-
extern const struct uapi_definition mlx5_ib_devx_defs[];
1389-
extern const struct uapi_definition mlx5_ib_flow_defs[];
13901390
struct mlx5_ib_flow_handler *mlx5_ib_raw_fs_rule_add(
13911391
struct mlx5_ib_dev *dev, struct mlx5_ib_flow_matcher *fs_matcher,
13921392
struct mlx5_flow_context *flow_context,
13931393
struct mlx5_flow_act *flow_act, u32 counter_id,
13941394
void *cmd_in, int inlen, int dest_id, int dest_type);
13951395
bool mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id, int *dest_type);
13961396
bool mlx5_ib_devx_is_flow_counter(void *obj, u32 offset, u32 *counter_id);
1397-
int mlx5_ib_get_flow_trees(const struct uverbs_object_tree_def **root);
13981397
void mlx5_ib_destroy_flow_action_raw(struct mlx5_ib_flow_action *maction);
13991398
#else
14001399
static inline int

include/rdma/uverbs_named_ioctl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
#define DECLARE_UVERBS_NAMED_OBJECT(_object_id, _type_attrs, ...) \
7777
static const struct uverbs_method_def *const UVERBS_OBJECT_METHODS( \
7878
_object_id)[] = { __VA_ARGS__ }; \
79-
const struct uverbs_object_def UVERBS_OBJECT(_object_id) = { \
79+
static const struct uverbs_object_def UVERBS_OBJECT(_object_id) = { \
8080
.id = _object_id, \
8181
.type_attrs = &_type_attrs, \
8282
.num_methods = ARRAY_SIZE(UVERBS_OBJECT_METHODS(_object_id)), \
@@ -88,10 +88,10 @@
8888
* identify all uapi methods with a (object,method) tuple. However, they have
8989
* no type pointer.
9090
*/
91-
#define DECLARE_UVERBS_GLOBAL_METHODS(_object_id, ...) \
91+
#define DECLARE_UVERBS_GLOBAL_METHODS(_object_id, ...) \
9292
static const struct uverbs_method_def *const UVERBS_OBJECT_METHODS( \
9393
_object_id)[] = { __VA_ARGS__ }; \
94-
const struct uverbs_object_def UVERBS_OBJECT(_object_id) = { \
94+
static const struct uverbs_object_def UVERBS_OBJECT(_object_id) = { \
9595
.id = _object_id, \
9696
.num_methods = ARRAY_SIZE(UVERBS_OBJECT_METHODS(_object_id)), \
9797
.methods = &UVERBS_OBJECT_METHODS(_object_id) \

0 commit comments

Comments
 (0)