brintos

brintos / linux-shallow public Read only

0
0
Text · 8.3 KiB · 10b5f6a Raw
235 lines · c
1/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */2/*3 * Copyright (c) 2004 Topspin Communications.  All rights reserved.4 * Copyright (c) 2005 Voltaire, Inc. All rights reserved.5 *6 * This software is available to you under a choice of one of two7 * licenses.  You may choose to be licensed under the terms of the GNU8 * General Public License (GPL) Version 2, available from the file9 * COPYING in the main directory of this source tree, or the10 * OpenIB.org BSD license below:11 *12 *     Redistribution and use in source and binary forms, with or13 *     without modification, are permitted provided that the following14 *     conditions are met:15 *16 *      - Redistributions of source code must retain the above17 *        copyright notice, this list of conditions and the following18 *        disclaimer.19 *20 *      - Redistributions in binary form must reproduce the above21 *        copyright notice, this list of conditions and the following22 *        disclaimer in the documentation and/or other materials23 *        provided with the distribution.24 *25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE32 * SOFTWARE.33 */34 35#ifndef IB_USER_MAD_H36#define IB_USER_MAD_H37 38#include <linux/types.h>39#include <rdma/rdma_user_ioctl.h>40 41/*42 * Increment this value if any changes that break userspace ABI43 * compatibility are made.44 */45#define IB_USER_MAD_ABI_VERSION	546 47/*48 * Make sure that all structs defined in this file remain laid out so49 * that they pack the same way on 32-bit and 64-bit architectures (to50 * avoid incompatibility between 32-bit userspace and 64-bit kernels).51 */52 53/**54 * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index55 * @id - ID of agent MAD received with/to be sent with56 * @status - 0 on successful receive, ETIMEDOUT if no response57 *   received (transaction ID in data[] will be set to TID of original58 *   request) (ignored on send)59 * @timeout_ms - Milliseconds to wait for response (unset on receive)60 * @retries - Number of automatic retries to attempt61 * @qpn - Remote QP number received from/to be sent to62 * @qkey - Remote Q_Key to be sent with (unset on receive)63 * @lid - Remote lid received from/to be sent to64 * @sl - Service level received with/to be sent with65 * @path_bits - Local path bits received with/to be sent with66 * @grh_present - If set, GRH was received/should be sent67 * @gid_index - Local GID index to send with (unset on receive)68 * @hop_limit - Hop limit in GRH69 * @traffic_class - Traffic class in GRH70 * @gid - Remote GID in GRH71 * @flow_label - Flow label in GRH72 */73struct ib_user_mad_hdr_old {74	__u32	id;75	__u32	status;76	__u32	timeout_ms;77	__u32	retries;78	__u32	length;79	__be32	qpn;80	__be32  qkey;81	__be16	lid;82	__u8	sl;83	__u8	path_bits;84	__u8	grh_present;85	__u8	gid_index;86	__u8	hop_limit;87	__u8	traffic_class;88	__u8	gid[16];89	__be32	flow_label;90};91 92/**93 * ib_user_mad_hdr - MAD packet header94 *   This layout allows specifying/receiving the P_Key index.  To use95 *   this capability, an application must call the96 *   IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before97 *   any other actions with the file handle.98 * @id - ID of agent MAD received with/to be sent with99 * @status - 0 on successful receive, ETIMEDOUT if no response100 *   received (transaction ID in data[] will be set to TID of original101 *   request) (ignored on send)102 * @timeout_ms - Milliseconds to wait for response (unset on receive)103 * @retries - Number of automatic retries to attempt104 * @qpn - Remote QP number received from/to be sent to105 * @qkey - Remote Q_Key to be sent with (unset on receive)106 * @lid - Remote lid received from/to be sent to107 * @sl - Service level received with/to be sent with108 * @path_bits - Local path bits received with/to be sent with109 * @grh_present - If set, GRH was received/should be sent110 * @gid_index - Local GID index to send with (unset on receive)111 * @hop_limit - Hop limit in GRH112 * @traffic_class - Traffic class in GRH113 * @gid - Remote GID in GRH114 * @flow_label - Flow label in GRH115 * @pkey_index - P_Key index116 */117struct ib_user_mad_hdr {118	__u32	id;119	__u32	status;120	__u32	timeout_ms;121	__u32	retries;122	__u32	length;123	__be32	qpn;124	__be32  qkey;125	__be16	lid;126	__u8	sl;127	__u8	path_bits;128	__u8	grh_present;129	__u8	gid_index;130	__u8	hop_limit;131	__u8	traffic_class;132	__u8	gid[16];133	__be32	flow_label;134	__u16	pkey_index;135	__u8	reserved[6];136};137 138/**139 * ib_user_mad - MAD packet140 * @hdr - MAD packet header141 * @data - Contents of MAD142 *143 */144struct ib_user_mad {145	struct ib_user_mad_hdr hdr;146	__aligned_u64	data[];147};148 149/*150 * Earlier versions of this interface definition declared the151 * method_mask[] member as an array of __u32 but treated it as a152 * bitmap made up of longs in the kernel.  This ambiguity meant that153 * 32-bit big-endian applications that can run on both 32-bit and154 * 64-bit kernels had no consistent ABI to rely on, and 64-bit155 * big-endian applications that treated method_mask as being made up156 * of 32-bit words would have their bitmap misinterpreted.157 *158 * To clear up this confusion, we change the declaration of159 * method_mask[] to use unsigned long and handle the conversion from160 * 32-bit userspace to 64-bit kernel for big-endian systems in the161 * compat_ioctl method.  Unfortunately, to keep the structure layout162 * the same, we need the method_mask[] array to be aligned only to 4163 * bytes even when long is 64 bits, which forces us into this ugly164 * typedef.165 */166typedef unsigned long __attribute__((aligned(4))) packed_ulong;167#define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long)))168 169/**170 * ib_user_mad_reg_req - MAD registration request171 * @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 method174 *   where @method_mask = 1.175 * @mgmt_class - Indicates which management class of MADs should be receive176 *   by the caller.  This field is only required if the user wishes to177 *   receive unsolicited MADs, otherwise it should be 0.178 * @mgmt_class_version - Indicates which version of MADs for the given179 *   management class to receive.180 * @oui: Indicates IEEE OUI when mgmt_class is a vendor class181 *   in the range from 0x30 to 0x4f. Otherwise not used.182 * @rmpp_version: If set, indicates the RMPP version used.183 *184 */185struct ib_user_mad_reg_req {186	__u32	id;187	packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK];188	__u8	qpn;189	__u8	mgmt_class;190	__u8	mgmt_class_version;191	__u8    oui[3];192	__u8	rmpp_version;193};194 195/**196 * ib_user_mad_reg_req2 - MAD registration request197 *198 * @id                 - Set by the _kernel_; used by userspace to identify the199 *                       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 be202 *                       receive by the caller.  This field is only required if203 *                       the user wishes to receive unsolicited MADs, otherwise204 *                       it should be 0.205 * @mgmt_class_version - Indicates which version of MADs for the given206 *                       management class to receive.207 * @res                - Ignored.208 * @flags              - additional registration flags; Must be in the set of209 *                       flags defined in IB_USER_MAD_REG_FLAGS_CAP210 * @method_mask        - The caller wishes to receive unsolicited MADs for the211 *                       methods whose bit(s) is(are) set.212 * @oui                - Indicates IEEE OUI to use when mgmt_class is a vendor213 *                       class in the range from 0x30 to 0x4f. Otherwise not214 *                       used.215 * @rmpp_version       - If set, indicates the RMPP version to use.216 */217enum {218	IB_USER_MAD_USER_RMPP = (1 << 0),219};220#define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP)221struct ib_user_mad_reg_req2 {222	__u32	id;223	__u32	qpn;224	__u8	mgmt_class;225	__u8	mgmt_class_version;226	__u16   res;227	__u32   flags;228	__aligned_u64 method_mask[2];229	__u32   oui;230	__u8	rmpp_version;231	__u8	reserved[3];232};233 234#endif /* IB_USER_MAD_H */235