aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEli Cohen <eli@mellanox.com>2016-02-14 10:07:48 -0500
committerDoug Ledford <dledford@redhat.com>2016-03-03 10:18:45 -0500
commit2dbd5186a39c7ef0d92045c43b4857c23cb117ab (patch)
tree9b7b1a5314235762f9d2e38337b7b664a0b1f46b
parent74a0b0a5ea6b48f8945e6e900e9c678866aa7520 (diff)
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>
-rw-r--r--drivers/infiniband/core/uverbs_main.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index 08f1a7b6d63c..20f0049db5e5 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -683,6 +683,21 @@ out:
683 return ev_file; 683 return ev_file;
684} 684}
685 685
686static int verify_command_mask(struct ib_device *ib_dev, __u32 command)
687{
688 u64 mask;
689
690 if (command <= IB_USER_VERBS_CMD_OPEN_QP)
691 mask = ib_dev->uverbs_cmd_mask;
692 else
693 mask = ib_dev->uverbs_ex_cmd_mask;
694
695 if (mask & ((u64)1 << command))
696 return 0;
697
698 return -1;
699}
700
686static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, 701static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
687 size_t count, loff_t *pos) 702 size_t count, loff_t *pos)
688{ 703{
@@ -715,6 +730,10 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
715 } 730 }
716 731
717 command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK; 732 command = hdr.command & IB_USER_VERBS_CMD_COMMAND_MASK;
733 if (verify_command_mask(ib_dev, command)) {
734 ret = -EOPNOTSUPP;
735 goto out;
736 }
718 737
719 flags = (hdr.command & 738 flags = (hdr.command &
720 IB_USER_VERBS_CMD_FLAGS_MASK) >> IB_USER_VERBS_CMD_FLAGS_SHIFT; 739 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,
732 goto out; 751 goto out;
733 } 752 }
734 753
735 if (!(ib_dev->uverbs_cmd_mask & (1ull << command))) {
736 ret = -ENOSYS;
737 goto out;
738 }
739
740 if (hdr.in_words * 4 != count) { 754 if (hdr.in_words * 4 != count) {
741 ret = -EINVAL; 755 ret = -EINVAL;
742 goto out; 756 goto out;
@@ -764,11 +778,6 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
764 goto out; 778 goto out;
765 } 779 }
766 780
767 if (!(ib_dev->uverbs_ex_cmd_mask & (1ull << command))) {
768 ret = -ENOSYS;
769 goto out;
770 }
771
772 if (count < (sizeof(hdr) + sizeof(ex_hdr))) { 781 if (count < (sizeof(hdr) + sizeof(ex_hdr))) {
773 ret = -EINVAL; 782 ret = -EINVAL;
774 goto out; 783 goto out;