diff mbox

[rdma-core,10/10] rxe: Use VERBS_NAME_MATCH to match the rxe device

Message ID 1505855931-4956-11-git-send-email-jgunthorpe@obsidianresearch.com (mailing list archive)
State Accepted
Headers show

Commit Message

Jason Gunthorpe Sept. 19, 2017, 9:18 p.m. UTC
This is a placeholder, it obviously cannot work this way once we
add rdma device renaming.

A synthetic modalias is produced that contains the device name,
and the existing modalias framework is used to match it.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
 providers/rxe/rxe.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)
diff mbox

Patch

diff --git a/providers/rxe/rxe.c b/providers/rxe/rxe.c
index d9857aac70d745..683ffaa2a8af9c 100644
--- a/providers/rxe/rxe.c
+++ b/providers/rxe/rxe.c
@@ -57,6 +57,12 @@ 
 #include "rxe-abi.h"
 #include "rxe.h"
 
+static const struct verbs_match_ent hca_table[] = {
+	/* FIXME: rxe needs a more reliable way to detect the rxe device */
+	VERBS_NAME_MATCH("rxe", NULL),
+	{},
+};
+
 static int rxe_query_device(struct ibv_context *context,
 			    struct ibv_device_attr *attr)
 {
@@ -893,22 +899,6 @@  static void rxe_uninit_device(struct verbs_device *verbs_device)
 	free(dev);
 }
 
-static bool rxe_device_match(struct verbs_sysfs_dev *sysfs_dev)
-{
-	const char *uverbs_sys_path = sysfs_dev->sysfs_path;
-	char value[16];
-
-	/* make sure it is a rxe device */
-	if (ibv_read_sysfs_file(uverbs_sys_path, "ibdev",
-				value, sizeof(value)) < 0)
-		return false;
-
-	if (strncmp(value, "rxe", 3))
-		return false;
-
-	return true;
-}
-
 static struct verbs_device *rxe_device_alloc(struct verbs_sysfs_dev *sysfs_dev)
 {
 	struct rxe_device *dev;
@@ -925,7 +915,7 @@  static const struct verbs_device_ops rxe_dev_ops = {
 	.name = "rxe",
 	.match_min_abi_version = 0,
 	.match_max_abi_version = INT_MAX,
-	.match_device = rxe_device_match,
+	.match_table = hca_table,
 	.alloc_device = rxe_device_alloc,
 	.uninit_device = rxe_uninit_device,
 	.alloc_context = rxe_alloc_context,