History

IB/core: Add new ioctl interface

In this ioctl interface, processing the command starts from properties of the command and fetching the appropriate user objects before calling the handler. Parsing and validation is done according to a specifier declared by the driver's code. In the driver, all supported objects are declared. These objects are separated to different object namepsaces. Dividing objects to namespaces is done at initialization by using the higher bits of the object ids. This initialization can mix objects declared in different places to one parsing tree using in this ioctl interface. For each object we list all supported methods. Similarly to objects, methods are separated to method namespaces too. Namespacing is done similarly to the objects case. This could be used in order to add methods to an existing object. Each method has a specific handler, which could be either a default handler or a driver specific handler. Along with the handler, a bunch of attributes are specified as well. Similarly to objects and method, attributes are namespaced and hashed by their ids at initialization too. All supported attributes are subject to automatic fetching and validation. These attributes include the command, response and the method's related objects' ids. When these entities (objects, methods and attributes) are used, the high bits of the entities ids are used in order to calculate the hash bucket index. Then, these high bits are masked out in order to have a zero based index. Since we use these high bits for both bucketing and namespacing, we get a compact representation and O(1) array access. This is mandatory for efficient dispatching. Each attribute has a type (PTR_IN, PTR_OUT, IDR and FD) and a length. Attributes could be validated through some attributes, like: (*) Minimum size / Exact size (*) Fops for FD (*) Object type for IDR If an IDR/fd attribute is specified, the kernel also states the object type and the required access (NEW, WRITE, READ or DESTROY). All uobject/fd management is done automatically by the infrastructure, meaning - the infrastructure will fail concurrent commands that at least one of them requires concurrent access (WRITE/DESTROY), synchronize actions with device removals (dissociate context events) and take care of reference counting (increase/decrease) for concurrent actions invocation. The reference counts on the actual kernel objects shall be handled by the handlers. objects +--------+ | | | | methods +--------+ | | ns method method_spec +-----+ |len | +--------+ +------+[d]+-------+ +----------------+[d]+------------+ |attr1+-> |type | | object +> |method+-> | spec +-> + attr_buckets +-> |default_chain+--> +-----+ |idr_type| +--------+ +------+ |handler| | | +------------+ |attr2| |access | | | | | +-------+ +----------------+ |driver chain| +-----+ +--------+ | | | | +------------+ | | +------+ | | | | | | | | | | | | | | | | | | | | +--------+ [d] = Hash ids to groups using the high order bits The right types table is also chosen by using the high bits from the ids. Currently we have either default or driver specific groups. Once validation and object fetching (or creation) completed, we call the handler: int (*handler)(struct ib_device *ib_dev, struct ib_uverbs_file *ufile, struct uverbs_attr_bundle *ctx); ctx bundles attributes of different namespaces. Each element there is an array of attributes which corresponds to one namespaces of attributes. For example, in the usually used case: ctx core +----------------------------+ +------------+ | core: +---> | valid | +----------------------------+ | cmd_attr | | driver: | +------------+ |----------------------------+--+ | valid | | | cmd_attr | | +------------+ | | valid | | | obj_attr | | +------------+ | | drivers | +------------+ +> | valid | | cmd_attr | +------------+ | valid | | cmd_attr | +------------+ | valid | | obj_attr | +------------+

Matan Barak committed 9 years ago

Commit fac96581 parent 14d6c3a7 files · +543 −10Browse files

Showing the changes to include/uapi (1 of 7 files). Show all

Unified · Split

include/uapi/rdma/rdma_user_ioctl.h+33−0
@@ -43,6 +43,39 @@ · 42 unmodified lines
43/* Legacy name, for user space application which already use it */43/* Legacy name, for user space application which already use it */
44#define IB_IOCTL_MAGIC RDMA_IOCTL_MAGIC44#define IB_IOCTL_MAGIC RDMA_IOCTL_MAGIC
45 45
46#define RDMA_VERBS_IOCTL \
47 _IOWR(RDMA_IOCTL_MAGIC, 1, struct ib_uverbs_ioctl_hdr)
48
49#define UVERBS_ID_NS_MASK 0xF000
50#define UVERBS_ID_NS_SHIFT 12
51
52enum {
53 /* User input */
54 UVERBS_ATTR_F_MANDATORY = 1U << 0,
55 /*
56 * Valid output bit should be ignored and considered set in
57 * mandatory fields. This bit is kernel output.
58 */
59 UVERBS_ATTR_F_VALID_OUTPUT = 1U << 1,
60};
61
62struct ib_uverbs_attr {
63 __u16 attr_id; /* command specific type attribute */
64 __u16 len; /* only for pointers */
65 __u16 flags; /* combination of UVERBS_ATTR_F_XXXX */
66 __u16 reserved;
67 __u64 data; /* ptr to command, inline data or idr/fd */
68};
69
70struct ib_uverbs_ioctl_hdr {
71 __u16 length;
72 __u16 object_id;
73 __u16 method_id;
74 __u16 num_attrs;
75 __u64 reserved;
76 struct ib_uverbs_attr attrs[0];
77};
78
46/*79/*
47 * General blocks assignments80 * General blocks assignments
48 * It is closed on purpose do not expose it it user space81 * It is closed on purpose do not expose it it user space

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