History

IB/uverbs: Move to new headers and make naming consistent

Use macros to make names consistent in ioctl() uAPI: The ioctl() uAPI works with object-method hierarchy. The method part also states which handler should be executed when this method is called from user-space. Therefore, we need to tie method, method's id, method's handler and the object owning this method together. Previously, this was done through explicit developer chosen names. This makes grepping the code harder. Changing the method's name, method's handler and object's name to be automatically generated based on the ids. The headers are split in a way so they be included and used by user-space. One header strictly contains structures that are used directly by user-space applications, where another header is used for internal library (i.e. libibverbs) to form the ioctl() commands. Other header simply contains the required general command structure.

Matan Barak committed 8 years ago

Commit 1f7ff9d1 parent b470c1510 files · +396 −247Browse files

Showing the changes to include/uapi (4 of 10 files). Show all

Unified · Split

4 files
  1. include/uapi/rdma/ib_user_ioctl_cmds.h +83 −0
  2. include/uapi/rdma/ib_user_ioctl_verbs.h +6 −47
  3. include/uapi/rdma/rdma_user_ioctl.h +1 −37
  4. include/uapi/rdma/rdma_user_ioctl_cmds.h +71 −0
include/uapi/rdma/ib_user_ioctl_cmds.h+83−0
@@ -0,0 +1,83 @@
1+/*
2+ * Copyright (c) 2018, Mellanox Technologies inc. All rights reserved.
3+ *
4+ * This software is available to you under a choice of one of two
5+ * licenses. You may choose to be licensed under the terms of the GNU
6+ * General Public License (GPL) Version 2, available from the file
7+ * COPYING in the main directory of this source tree, or the
8+ * OpenIB.org BSD license below:
9+ *
10+ * Redistribution and use in source and binary forms, with or
11+ * without modification, are permitted provided that the following
12+ * conditions are met:
13+ *
14+ * - Redistributions of source code must retain the above
15+ * copyright notice, this list of conditions and the following
16+ * disclaimer.
17+ *
18+ * - Redistributions in binary form must reproduce the above
19+ * copyright notice, this list of conditions and the following
20+ * disclaimer in the documentation and/or other materials
21+ * provided with the distribution.
22+ *
23+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+ * SOFTWARE.
31+ */
32+
33+#ifndef IB_USER_IOCTL_CMDS_H
34+#define IB_USER_IOCTL_CMDS_H
35+
36+#define UVERBS_ID_NS_MASK 0xF000
37+#define UVERBS_ID_NS_SHIFT 12
38+
39+#define UVERBS_UDATA_DRIVER_DATA_NS 1
40+#define UVERBS_UDATA_DRIVER_DATA_FLAG (1UL << UVERBS_ID_NS_SHIFT)
41+
42+enum uverbs_default_objects {
43+ UVERBS_OBJECT_DEVICE, /* No instances of DEVICE are allowed */
44+ UVERBS_OBJECT_PD,
45+ UVERBS_OBJECT_COMP_CHANNEL,
46+ UVERBS_OBJECT_CQ,
47+ UVERBS_OBJECT_QP,
48+ UVERBS_OBJECT_SRQ,
49+ UVERBS_OBJECT_AH,
50+ UVERBS_OBJECT_MR,
51+ UVERBS_OBJECT_MW,
52+ UVERBS_OBJECT_FLOW,
53+ UVERBS_OBJECT_XRCD,
54+ UVERBS_OBJECT_RWQ_IND_TBL,
55+ UVERBS_OBJECT_WQ,
56+};
57+
58+enum {
59+ UVERBS_ATTR_UHW_IN = UVERBS_UDATA_DRIVER_DATA_FLAG,
60+ UVERBS_ATTR_UHW_OUT,
61+};
62+
63+enum uverbs_attrs_create_cq_cmd_attr_ids {
64+ UVERBS_ATTR_CREATE_CQ_HANDLE,
65+ UVERBS_ATTR_CREATE_CQ_CQE,
66+ UVERBS_ATTR_CREATE_CQ_USER_HANDLE,
67+ UVERBS_ATTR_CREATE_CQ_COMP_CHANNEL,
68+ UVERBS_ATTR_CREATE_CQ_COMP_VECTOR,
69+ UVERBS_ATTR_CREATE_CQ_FLAGS,
70+ UVERBS_ATTR_CREATE_CQ_RESP_CQE,
71+};
72+
73+enum uverbs_attrs_destroy_cq_cmd_attr_ids {
74+ UVERBS_ATTR_DESTROY_CQ_HANDLE,
75+ UVERBS_ATTR_DESTROY_CQ_RESP,
76+};
77+
78+enum uverbs_methods_cq {
79+ UVERBS_METHOD_CQ_CREATE,
80+ UVERBS_METHOD_CQ_DESTROY,
81+};
82+
83+#endif
include/uapi/rdma/ib_user_ioctl_verbs.h+6−47
@@ -1,5 +1,6 @@
1+/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) */
12 /*
2− * Copyright (c) 2017, Mellanox Technologies inc. All rights reserved.
3+ * Copyright (c) 2017-2018, Mellanox Technologies inc. All rights reserved.
34 *
45 * This software is available to you under a choice of one of two
56 * licenses. You may choose to be licensed under the terms of the GNU
@@ -33,52 +34,10 @@ · 27 unmodified lines
3334 #ifndef IB_USER_IOCTL_VERBS_H
3435 #define IB_USER_IOCTL_VERBS_H
3536
36−#include <rdma/rdma_user_ioctl.h>
37−
38−#define UVERBS_UDATA_DRIVER_DATA_NS 1
39−#define UVERBS_UDATA_DRIVER_DATA_FLAG (1UL << UVERBS_ID_NS_SHIFT)
40−
41−enum uverbs_default_objects {
42− UVERBS_OBJECT_DEVICE, /* No instances of DEVICE are allowed */
43− UVERBS_OBJECT_PD,
44− UVERBS_OBJECT_COMP_CHANNEL,
45− UVERBS_OBJECT_CQ,
46− UVERBS_OBJECT_QP,
47− UVERBS_OBJECT_SRQ,
48− UVERBS_OBJECT_AH,
49− UVERBS_OBJECT_MR,
50− UVERBS_OBJECT_MW,
51− UVERBS_OBJECT_FLOW,
52− UVERBS_OBJECT_XRCD,
53− UVERBS_OBJECT_RWQ_IND_TBL,
54− UVERBS_OBJECT_WQ,
55− UVERBS_OBJECT_LAST,
56−};
57−
58−enum {
59− UVERBS_UHW_IN = UVERBS_UDATA_DRIVER_DATA_FLAG,
60− UVERBS_UHW_OUT,
61−};
62−
63−enum uverbs_create_cq_cmd_attr_ids {
64− CREATE_CQ_HANDLE,
65− CREATE_CQ_CQE,
66− CREATE_CQ_USER_HANDLE,
67− CREATE_CQ_COMP_CHANNEL,
68− CREATE_CQ_COMP_VECTOR,
69− CREATE_CQ_FLAGS,
70− CREATE_CQ_RESP_CQE,
71−};
72−
73−enum uverbs_destroy_cq_cmd_attr_ids {
74− DESTROY_CQ_HANDLE,
75− DESTROY_CQ_RESP,
76−};
77−
78−enum uverbs_actions_cq_ops {
79− UVERBS_CQ_CREATE,
80− UVERBS_CQ_DESTROY,
81−};
37+#include <linux/types.h>
8238
39+#ifndef RDMA_UAPI_PTR
40+#define RDMA_UAPI_PTR(_type, _name) _type __attribute__((aligned(8))) _name
8341 #endif
8442
43+#endif
include/uapi/rdma/rdma_user_ioctl.h+1−37
@@ -34,49 +34,13 @@ · 33 unmodified lines
3434 #ifndef RDMA_USER_IOCTL_H
3535 #define RDMA_USER_IOCTL_H
3636
37−#include <linux/types.h>
38−#include <linux/ioctl.h>
3937 #include <rdma/ib_user_mad.h>
4038 #include <rdma/hfi/hfi1_ioctl.h>
39+#include <rdma/rdma_user_ioctl_cmds.h>
4140
42−/* Documentation/ioctl/ioctl-number.txt */
43−#define RDMA_IOCTL_MAGIC 0x1b
4441 /* Legacy name, for user space application which already use it */
4542 #define IB_IOCTL_MAGIC RDMA_IOCTL_MAGIC
4643
47−#define RDMA_VERBS_IOCTL \
48− _IOWR(RDMA_IOCTL_MAGIC, 1, struct ib_uverbs_ioctl_hdr)
49−
50−#define UVERBS_ID_NS_MASK 0xF000
51−#define UVERBS_ID_NS_SHIFT 12
52−
53−enum {
54− /* User input */
55− UVERBS_ATTR_F_MANDATORY = 1U << 0,
56− /*
57− * Valid output bit should be ignored and considered set in
58− * mandatory fields. This bit is kernel output.
59− */
60− UVERBS_ATTR_F_VALID_OUTPUT = 1U << 1,
61−};
62−
63−struct ib_uverbs_attr {
64− __u16 attr_id; /* command specific type attribute */
65− __u16 len; /* only for pointers */
66− __u16 flags; /* combination of UVERBS_ATTR_F_XXXX */
67− __u16 reserved;
68− __aligned_u64 data; /* ptr to command, inline data or idr/fd */
69−};
70−
71−struct ib_uverbs_ioctl_hdr {
72− __u16 length;
73− __u16 object_id;
74− __u16 method_id;
75− __u16 num_attrs;
76− __aligned_u64 reserved;
77− struct ib_uverbs_attr attrs[0];
78−};
79−
8044 /*
8145 * General blocks assignments
8246 * It is closed on purpose do not expose it it user space
include/uapi/rdma/rdma_user_ioctl_cmds.h+71−0
@@ -0,0 +1,71 @@
1+/*
2+ * Copyright (c) 2018, Mellanox Technologies inc. All rights reserved.
3+ *
4+ * This software is available to you under a choice of one of two
5+ * licenses. You may choose to be licensed under the terms of the GNU
6+ * General Public License (GPL) Version 2, available from the file
7+ * COPYING in the main directory of this source tree, or the
8+ * OpenIB.org BSD license below:
9+ *
10+ * Redistribution and use in source and binary forms, with or
11+ * without modification, are permitted provided that the following
12+ * conditions are met:
13+ *
14+ * - Redistributions of source code must retain the above
15+ * copyright notice, this list of conditions and the following
16+ * disclaimer.
17+ *
18+ * - Redistributions in binary form must reproduce the above
19+ * copyright notice, this list of conditions and the following
20+ * disclaimer in the documentation and/or other materials
21+ * provided with the distribution.
22+ *
23+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30+ * SOFTWARE.
31+ */
32+
33+#ifndef RDMA_USER_IOCTL_CMDS_H
34+#define RDMA_USER_IOCTL_CMDS_H
35+
36+#include <linux/types.h>
37+#include <linux/ioctl.h>
38+
39+/* Documentation/ioctl/ioctl-number.txt */
40+#define RDMA_IOCTL_MAGIC 0x1b
41+#define RDMA_VERBS_IOCTL \
42+ _IOWR(RDMA_IOCTL_MAGIC, 1, struct ib_uverbs_ioctl_hdr)
43+
44+enum {
45+ /* User input */
46+ UVERBS_ATTR_F_MANDATORY = 1U << 0,
47+ /*
48+ * Valid output bit should be ignored and considered set in
49+ * mandatory fields. This bit is kernel output.
50+ */
51+ UVERBS_ATTR_F_VALID_OUTPUT = 1U << 1,
52+};
53+
54+struct ib_uverbs_attr {
55+ __u16 attr_id; /* command specific type attribute */
56+ __u16 len; /* only for pointers */
57+ __u16 flags; /* combination of UVERBS_ATTR_F_XXXX */
58+ __u16 reserved;
59+ __aligned_u64 data; /* ptr to command, inline data or idr/fd */
60+};
61+
62+struct ib_uverbs_ioctl_hdr {
63+ __u16 length;
64+ __u16 object_id;
65+ __u16 method_id;
66+ __u16 num_attrs;
67+ __aligned_u64 reserved;
68+ struct ib_uverbs_attr attrs[0];
69+};
70+
71+#endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t