IB/core: IB/core: Allow legacy verbs through extended interfaces
When an extended verb is an extension to a legacy verb, the original functionality is preserved. Hence we do not require each hardware driver to set the extended capability. This will allow the use of the extended verb in its simple form with drivers that do not support the extended capability. Signed-off-by: Eli Cohen <eli@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
This commit is contained in:
parent
74a0b0a5ea
commit
2dbd5186a3
|
@ -683,6 +683,21 @@ struct ib_uverbs_event_file *ib_uverbs_lookup_comp_file(int fd)
|
||||||
return ev_file;
|
return ev_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int verify_command_mask(struct ib_device *ib_dev, __u32 command)
|
||||||
|
{
|
||||||
|
u64 mask;
|
||||||
|
|
||||||
|
if (command <= IB_USER_VERBS_CMD_OPEN_QP)
|
||||||
|
mask = ib_dev->uverbs_cmd_mask;
|
||||||
|
else
|
||||||
|
mask = ib_dev->uverbs_ex_cmd_mask;
|
||||||
|
|
||||||
|
if (mask & ((u64)1 << command))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
|
static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
|
||||||
size_t count, loff_t *pos)
|
size_t count, loff_t *pos)
|
||||||
{
|
{
|
||||||
|
@ -715,6 +730,10 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
|
||||||
}
|
}
|
||||||
|
|
||||||
command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK;
|
command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK;
|
||||||
|
if (verify_command_mask(ib_dev, command)) {
|
||||||
|
ret = -EOPNOTSUPP;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
flags = (hdr.command &
|
flags = (hdr.command &
|
||||||
IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT;
|
IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT;
|
||||||
|
@ -732,11 +751,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ib_dev->uverbs_cmd_mask & (1ull << command))) {
|
|
||||||
ret = -ENOSYS;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hdr.in_words * 4 != count) {
|
if (hdr.in_words * 4 != count) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
|
@ -764,11 +778,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(ib_dev->uverbs_ex_cmd_mask & (1ull << command))) {
|
|
||||||
ret = -ENOSYS;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count < (sizeof(hdr) + sizeof(ex_hdr))) {
|
if (count < (sizeof(hdr) + sizeof(ex_hdr))) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
|
|
Loading…
Reference in New Issue