@@ -355,11 +355,18 @@ typedef struct verbs_device *(*verbs_driver_init_func)(const char *uverbs_sys_pa
void verbs_register_driver(const struct verbs_device_ops *ops);
-/* Macro for providers to use to supply verbs_device_ops to the core code */
-#define PROVIDER_DRIVER(drv) \
+/*
+ * Macro for providers to use to supply verbs_device_ops to the core code.
+ * This creates a global symbol for the provider structure to be used by the
+ * ibv_static_providers() machinery, and a global constructor for the dlopen
+ * machinery.
+ */
+#define PROVIDER_DRIVER(provider_name, drv_struct) \
+ extern const struct verbs_device_ops verbs_provider_##provider_name \
+ __attribute__((alias(stringify(drv_struct)))); \
static __attribute__((constructor)) void drv##__register_driver(void) \
{ \
- verbs_register_driver(&drv); \
+ verbs_register_driver(&drv_struct); \
}
void *_verbs_init_and_alloc_context(struct ibv_device *device, int cmd_fd,
@@ -1880,6 +1880,25 @@ static inline struct verbs_context *verbs_get_ctx(struct ibv_context *ctx)
*/
struct ibv_device **ibv_get_device_list(int *num_devices);
+#ifdef RDMA_STATIC_PROVIDERS
+struct verbs_devices_ops;
+extern const struct verbs_device_ops verbs_provider_bnxt_re;
+extern const struct verbs_device_ops verbs_provider_cxgb3;
+extern const struct verbs_device_ops verbs_provider_cxgb4;
+extern const struct verbs_device_ops verbs_provider_hfi1verbs;
+extern const struct verbs_device_ops verbs_provider_hns;
+extern const struct verbs_device_ops verbs_provider_i40iw;
+extern const struct verbs_device_ops verbs_provider_ipathverbs;
+extern const struct verbs_device_ops verbs_provider_mlx4;
+extern const struct verbs_device_ops verbs_provider_mlx5;
+extern const struct verbs_device_ops verbs_provider_mthca;
+extern const struct verbs_device_ops verbs_provider_nes;
+extern const struct verbs_device_ops verbs_provider_ocrdma;
+extern const struct verbs_device_ops verbs_provider_qedr;
+extern const struct verbs_device_ops verbs_provider_rxe;
+extern const struct verbs_device_ops verbs_provider_vmw_pvrdma;
+#endif
+
/**
* ibv_free_device_list - Free list from ibv_get_device_list()
*
@@ -197,4 +197,4 @@ static const struct verbs_device_ops bnxt_re_dev_ops = {
.alloc_context = bnxt_re_alloc_context,
.free_context = bnxt_re_free_context,
};
-PROVIDER_DRIVER(bnxt_re_dev_ops);
+PROVIDER_DRIVER(bnxt_re, bnxt_re_dev_ops);
@@ -267,4 +267,4 @@ static const struct verbs_device_ops iwch_dev_ops = {
.alloc_context = iwch_alloc_context,
.free_context = iwch_free_context,
};
-PROVIDER_DRIVER(iwch_dev_ops);
+PROVIDER_DRIVER(cxgb3, iwch_dev_ops);
@@ -504,7 +504,7 @@ static const struct verbs_device_ops c4iw_dev_ops = {
.alloc_context = c4iw_alloc_context,
.free_context = c4iw_free_context,
};
-PROVIDER_DRIVER(c4iw_dev_ops);
+PROVIDER_DRIVER(cxgb4, c4iw_dev_ops);
#ifdef STATS
void __attribute__ ((destructor)) cs_fini(void);
@@ -206,4 +206,4 @@ static const struct verbs_device_ops hfi1_dev_ops = {
.alloc_context = hfi1_alloc_context,
.free_context = hfi1_free_context,
};
-PROVIDER_DRIVER(hfi1_dev_ops);
+PROVIDER_DRIVER(hfi1verbs, hfi1_dev_ops);
@@ -205,4 +205,4 @@ static const struct verbs_device_ops hns_roce_dev_ops = {
.alloc_context = hns_roce_alloc_context,
.free_context = hns_roce_free_context,
};
-PROVIDER_DRIVER(hns_roce_dev_ops);
+PROVIDER_DRIVER(hns, hns_roce_dev_ops);
@@ -226,4 +226,4 @@ static const struct verbs_device_ops i40iw_udev_ops = {
.alloc_context = i40iw_ualloc_context,
.free_context = i40iw_ufree_context,
};
-PROVIDER_DRIVER(i40iw_udev_ops);
+PROVIDER_DRIVER(i40iw, i40iw_udev_ops);
@@ -204,4 +204,4 @@ static const struct verbs_device_ops ipath_dev_ops = {
.alloc_context = ipath_alloc_context,
.free_context = ipath_free_context,
};
-PROVIDER_DRIVER(ipath_dev_ops);
+PROVIDER_DRIVER(ipathverbs, ipath_dev_ops);
@@ -302,7 +302,7 @@ static const struct verbs_device_ops mlx4_dev_ops = {
.alloc_context = mlx4_alloc_context,
.free_context = mlx4_free_context,
};
-PROVIDER_DRIVER(mlx4_dev_ops);
+PROVIDER_DRIVER(mlx4, mlx4_dev_ops);
static int mlx4dv_get_qp(struct ibv_qp *qp_in,
struct mlx4dv_qp *qp_out)
@@ -1324,4 +1324,4 @@ static const struct verbs_device_ops mlx5_dev_ops = {
.alloc_context = mlx5_alloc_context,
.free_context = mlx5_free_context,
};
-PROVIDER_DRIVER(mlx5_dev_ops);
+PROVIDER_DRIVER(mlx5, mlx5_dev_ops);
@@ -239,4 +239,4 @@ static const struct verbs_device_ops mthca_dev_ops = {
.alloc_context = mthca_alloc_context,
.free_context = mthca_free_context,
};
-PROVIDER_DRIVER(mthca_dev_ops);
+PROVIDER_DRIVER(mthca, mthca_dev_ops);
@@ -218,4 +218,4 @@ static const struct verbs_device_ops nes_udev_ops = {
.alloc_context = nes_ualloc_context,
.free_context = nes_ufree_context,
};
-PROVIDER_DRIVER(nes_udev_ops);
+PROVIDER_DRIVER(nes, nes_udev_ops);
@@ -195,4 +195,4 @@ static const struct verbs_device_ops ocrdma_dev_ops = {
.alloc_context = ocrdma_alloc_context,
.free_context = ocrdma_free_context,
};
-PROVIDER_DRIVER(ocrdma_dev_ops);
+PROVIDER_DRIVER(ocrdma, ocrdma_dev_ops);
@@ -250,4 +250,4 @@ static const struct verbs_device_ops qelr_dev_ops = {
.alloc_context = qelr_alloc_context,
.free_context = qelr_free_context,
};
-PROVIDER_DRIVER(qelr_dev_ops);
+PROVIDER_DRIVER(qedr, qelr_dev_ops);
@@ -923,4 +923,4 @@ static const struct verbs_device_ops rxe_dev_ops = {
.alloc_context = rxe_alloc_context,
.free_context = rxe_free_context,
};
-PROVIDER_DRIVER(rxe_dev_ops);
+PROVIDER_DRIVER(rxe, rxe_dev_ops);
@@ -209,4 +209,4 @@ static const struct verbs_device_ops pvrdma_dev_ops = {
.alloc_context = pvrdma_alloc_context,
.free_context = pvrdma_free_context,
};
-PROVIDER_DRIVER(pvrdma_dev_ops);
+PROVIDER_DRIVER(vmw_pvrdma, pvrdma_dev_ops);