1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
3 * Copyright (c) 2004 Topspin Communications. All rights reserved.
4 * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 #include <linux/types.h>
39 #include <rdma/rdma_user_ioctl.h>
42 * Increment this value if any changes that break userspace ABI
43 * compatibility are made.
45 #define IB_USER_MAD_ABI_VERSION 5
48 * Make sure that all structs defined in this file remain laid out so
49 * that they pack the same way on 32-bit and 64-bit architectures (to
50 * avoid incompatibility between 32-bit userspace and 64-bit kernels).
54 * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index
55 * @id - ID of agent MAD received with/to be sent with
56 * @status - 0 on successful receive, ETIMEDOUT if no response
57 * received (transaction ID in data[] will be set to TID of original
58 * request) (ignored on send)
59 * @timeout_ms - Milliseconds to wait for response (unset on receive)
60 * @retries - Number of automatic retries to attempt
61 * @qpn - Remote QP number received from/to be sent to
62 * @qkey - Remote Q_Key to be sent with (unset on receive)
63 * @lid - Remote lid received from/to be sent to
64 * @sl - Service level received with/to be sent with
65 * @path_bits - Local path bits received with/to be sent with
66 * @grh_present - If set, GRH was received/should be sent
67 * @gid_index - Local GID index to send with (unset on receive)
68 * @hop_limit - Hop limit in GRH
69 * @traffic_class - Traffic class in GRH
70 * @gid - Remote GID in GRH
71 * @flow_label - Flow label in GRH
73 struct ib_user_mad_hdr_old {
93 * ib_user_mad_hdr - MAD packet header
94 * This layout allows specifying/receiving the P_Key index. To use
95 * this capability, an application must call the
96 * IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before
97 * any other actions with the file handle.
98 * @id - ID of agent MAD received with/to be sent with
99 * @status - 0 on successful receive, ETIMEDOUT if no response
100 * received (transaction ID in data[] will be set to TID of original
101 * request) (ignored on send)
102 * @timeout_ms - Milliseconds to wait for response (unset on receive)
103 * @retries - Number of automatic retries to attempt
104 * @qpn - Remote QP number received from/to be sent to
105 * @qkey - Remote Q_Key to be sent with (unset on receive)
106 * @lid - Remote lid received from/to be sent to
107 * @sl - Service level received with/to be sent with
108 * @path_bits - Local path bits received with/to be sent with
109 * @grh_present - If set, GRH was received/should be sent
110 * @gid_index - Local GID index to send with (unset on receive)
111 * @hop_limit - Hop limit in GRH
112 * @traffic_class - Traffic class in GRH
113 * @gid - Remote GID in GRH
114 * @flow_label - Flow label in GRH
115 * @pkey_index - P_Key index
117 struct ib_user_mad_hdr {
139 * ib_user_mad - MAD packet
140 * @hdr - MAD packet header
141 * @data - Contents of MAD
145 struct ib_user_mad_hdr hdr;
146 __aligned_u64 data[];
150 * Earlier versions of this interface definition declared the
151 * method_mask[] member as an array of __u32 but treated it as a
152 * bitmap made up of longs in the kernel. This ambiguity meant that
153 * 32-bit big-endian applications that can run on both 32-bit and
154 * 64-bit kernels had no consistent ABI to rely on, and 64-bit
155 * big-endian applications that treated method_mask as being made up
156 * of 32-bit words would have their bitmap misinterpreted.
158 * To clear up this confusion, we change the declaration of
159 * method_mask[] to use unsigned long and handle the conversion from
160 * 32-bit userspace to 64-bit kernel for big-endian systems in the
161 * compat_ioctl method. Unfortunately, to keep the structure layout
162 * the same, we need the method_mask[] array to be aligned only to 4
163 * bytes even when long is 64 bits, which forces us into this ugly
166 typedef unsigned long __attribute__((aligned(4))) packed_ulong;
167 #define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long)))
170 * ib_user_mad_reg_req - MAD registration request
171 * @id - Set by the kernel; used to identify agent in future requests.
172 * @qpn - Queue pair number; must be 0 or 1.
173 * @method_mask - The caller will receive unsolicited MADs for any method
174 * where @method_mask = 1.
175 * @mgmt_class - Indicates which management class of MADs should be receive
176 * by the caller. This field is only required if the user wishes to
177 * receive unsolicited MADs, otherwise it should be 0.
178 * @mgmt_class_version - Indicates which version of MADs for the given
179 * management class to receive.
180 * @oui: Indicates IEEE OUI when mgmt_class is a vendor class
181 * in the range from 0x30 to 0x4f. Otherwise not used.
182 * @rmpp_version: If set, indicates the RMPP version used.
185 struct ib_user_mad_reg_req {
187 packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK];
190 __u8 mgmt_class_version;
196 * ib_user_mad_reg_req2 - MAD registration request
198 * @id - Set by the _kernel_; used by userspace to identify the
199 * registered agent in future requests.
200 * @qpn - Queue pair number; must be 0 or 1.
201 * @mgmt_class - Indicates which management class of MADs should be
202 * receive by the caller. This field is only required if
203 * the user wishes to receive unsolicited MADs, otherwise
205 * @mgmt_class_version - Indicates which version of MADs for the given
206 * management class to receive.
208 * @flags - additional registration flags; Must be in the set of
209 * flags defined in IB_USER_MAD_REG_FLAGS_CAP
210 * @method_mask - The caller wishes to receive unsolicited MADs for the
211 * methods whose bit(s) is(are) set.
212 * @oui - Indicates IEEE OUI to use when mgmt_class is a vendor
213 * class in the range from 0x30 to 0x4f. Otherwise not
215 * @rmpp_version - If set, indicates the RMPP version to use.
218 IB_USER_MAD_USER_RMPP = (1 << 0),
220 #define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP)
221 struct ib_user_mad_reg_req2 {
225 __u8 mgmt_class_version;
228 __aligned_u64 method_mask[2];
234 #endif /* IB_USER_MAD_H */