Skip to content

Commit 6780c4f

Browse files
gal-pressmanjgunthorpe
authored andcommitted
RDMA: Add indication for in kernel API support to IB device
Drivers that do not provide kernel verbs support should not be used by ib kernel clients at all. In case a device does not implement all mandatory verbs for kverbs usage mark it as a non kverbs provider and prevent its usage for all clients except for uverbs. The device is marked as a non kverbs provider using the 'kverbs_provider' flag which should only be set by the core code. The clients can choose whether kverbs are requested for its usage using the 'no_kverbs_req' flag which is currently set for uverbs only. This patch allows drivers to remove mandatory verbs stubs and simply set the callbacks to NULL. The IB device will be registered as a non-kverbs provider. Note that verbs that are required for the device registration process must be implemented. Signed-off-by: Gal Pressman <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 459cc69 commit 6780c4f

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

drivers/infiniband/core/device.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,12 @@ static int ib_device_check_mandatory(struct ib_device *device)
121121
};
122122
int i;
123123

124+
device->kverbs_provider = true;
124125
for (i = 0; i < ARRAY_SIZE(mandatory_table); ++i) {
125126
if (!*(void **) ((void *) &device->ops +
126127
mandatory_table[i].offset)) {
127-
dev_warn(&device->dev,
128-
"Device is missing mandatory function %s\n",
129-
mandatory_table[i].name);
130-
return -EINVAL;
128+
device->kverbs_provider = false;
129+
break;
131130
}
132131
}
133132

@@ -325,6 +324,9 @@ static int add_client_context(struct ib_device *device, struct ib_client *client
325324
{
326325
struct ib_client_data *context;
327326

327+
if (!device->kverbs_provider && !client->no_kverbs_req)
328+
return -EOPNOTSUPP;
329+
328330
context = kmalloc(sizeof(*context), GFP_KERNEL);
329331
if (!context)
330332
return -ENOMEM;

drivers/infiniband/core/uverbs_main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,6 +1151,7 @@ static const struct file_operations uverbs_mmap_fops = {
11511151

11521152
static struct ib_client uverbs_client = {
11531153
.name = "uverbs",
1154+
.no_kverbs_req = true,
11541155
.add = ib_uverbs_add_one,
11551156
.remove = ib_uverbs_remove_one
11561157
};

include/rdma/ib_verbs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2565,6 +2565,8 @@ struct ib_device {
25652565
__be64 node_guid;
25662566
u32 local_dma_lkey;
25672567
u16 is_switch:1;
2568+
/* Indicates kernel verbs support, should not be used in drivers */
2569+
u16 kverbs_provider:1;
25682570
u8 node_type;
25692571
u8 phys_port_cnt;
25702572
struct ib_device_attr attrs;
@@ -2619,6 +2621,9 @@ struct ib_client {
26192621
const struct sockaddr *addr,
26202622
void *client_data);
26212623
struct list_head list;
2624+
2625+
/* kverbs are not required by the client */
2626+
u8 no_kverbs_req:1;
26222627
};
26232628

26242629
struct ib_device *_ib_alloc_device(size_t size);

0 commit comments

Comments
 (0)