]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
[IB] uverbs: Add a mask of device methods allowed for userspace
authorRoland Dreier <rolandd@cisco.com>
Fri, 14 Oct 2005 21:00:58 +0000 (14:00 -0700)
committerRoland Dreier <rolandd@cisco.com>
Mon, 17 Oct 2005 22:20:30 +0000 (15:20 -0700)
Give each device a uverbs_cmd_mask, so that a low-level driver can
control which methods may be called on behalf of userspace.

Signed-off-by: Roland Dreier <rolandd@cisco.com>
drivers/infiniband/core/uverbs_main.c
drivers/infiniband/hw/mthca/mthca_provider.c
include/rdma/ib_verbs.h

index 3a887006b2539a9c97726de11ecdfcb636a225d8..6a5e5084db7a12f5922662c4353d761e40da9ca3 100644 (file)
@@ -514,7 +514,8 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf,
 
        if (hdr.command < 0                             ||
            hdr.command >= ARRAY_SIZE(uverbs_cmd_table) ||
-           !uverbs_cmd_table[hdr.command])
+           !uverbs_cmd_table[hdr.command]              ||
+           !(file->device->ib_dev->uverbs_cmd_mask & (1ull << hdr.command)))
                return -EINVAL;
 
        if (!file->ucontext &&
index 46864d18827d12556974f3630e971b9b753596e2..9e911a1ea4157310645e011fc514be8fd433b657 100644 (file)
@@ -37,6 +37,7 @@
  */
 
 #include <rdma/ib_smi.h>
+#include <rdma/ib_user_verbs.h>
 #include <linux/mm.h>
 
 #include "mthca_dev.h"
@@ -1077,6 +1078,25 @@ int mthca_register_device(struct mthca_dev *dev)
        dev->ib_dev.owner                = THIS_MODULE;
 
        dev->ib_dev.uverbs_abi_ver       = MTHCA_UVERBS_ABI_VERSION;
+       dev->ib_dev.uverbs_cmd_mask      =
+               (1ull << IB_USER_VERBS_CMD_GET_CONTEXT)         |
+               (1ull << IB_USER_VERBS_CMD_QUERY_DEVICE)        |
+               (1ull << IB_USER_VERBS_CMD_QUERY_PORT)          |
+               (1ull << IB_USER_VERBS_CMD_ALLOC_PD)            |
+               (1ull << IB_USER_VERBS_CMD_DEALLOC_PD)          |
+               (1ull << IB_USER_VERBS_CMD_REG_MR)              |
+               (1ull << IB_USER_VERBS_CMD_DEREG_MR)            |
+               (1ull << IB_USER_VERBS_CMD_CREATE_COMP_CHANNEL) |
+               (1ull << IB_USER_VERBS_CMD_CREATE_CQ)           |
+               (1ull << IB_USER_VERBS_CMD_DESTROY_CQ)          |
+               (1ull << IB_USER_VERBS_CMD_CREATE_QP)           |
+               (1ull << IB_USER_VERBS_CMD_MODIFY_QP)           |
+               (1ull << IB_USER_VERBS_CMD_DESTROY_QP)          |
+               (1ull << IB_USER_VERBS_CMD_ATTACH_MCAST)        |
+               (1ull << IB_USER_VERBS_CMD_DETACH_MCAST)        |
+               (1ull << IB_USER_VERBS_CMD_CREATE_SRQ)          |
+               (1ull << IB_USER_VERBS_CMD_MODIFY_SRQ)          |
+               (1ull << IB_USER_VERBS_CMD_DESTROY_SRQ);
        dev->ib_dev.node_type            = IB_NODE_CA;
        dev->ib_dev.phys_port_cnt        = dev->limits.num_ports;
        dev->ib_dev.dma_device           = &dev->pdev->dev;
index d13f25a7819263871663c522652c4aaa759e1148..a5a963cb56762568ef3fa0ac3998809ee8d5e1a7 100644 (file)
@@ -951,6 +951,7 @@ struct ib_device {
                IB_DEV_UNREGISTERED
        }                            reg_state;
 
+       u64                          uverbs_cmd_mask;
        int                          uverbs_abi_ver;
 
        u8                           node_type;