109938b21SHans Petter Selasky /*- 209938b21SHans Petter Selasky * SPDX-License-Identifier: BSD-2-Clause OR GPL-2.0 309938b21SHans Petter Selasky * 49f715dc1SHans Petter Selasky * Copyright (c) 2004 Topspin Communications. All rights reserved. 59f715dc1SHans Petter Selasky * Copyright (c) 2005 Voltaire, Inc. All rights reserved. 69f715dc1SHans Petter Selasky * 79f715dc1SHans Petter Selasky * This software is available to you under a choice of one of two 89f715dc1SHans Petter Selasky * licenses. You may choose to be licensed under the terms of the GNU 99f715dc1SHans Petter Selasky * General Public License (GPL) Version 2, available from the file 109f715dc1SHans Petter Selasky * COPYING in the main directory of this source tree, or the 119f715dc1SHans Petter Selasky * OpenIB.org BSD license below: 129f715dc1SHans Petter Selasky * 139f715dc1SHans Petter Selasky * Redistribution and use in source and binary forms, with or 149f715dc1SHans Petter Selasky * without modification, are permitted provided that the following 159f715dc1SHans Petter Selasky * conditions are met: 169f715dc1SHans Petter Selasky * 179f715dc1SHans Petter Selasky * - Redistributions of source code must retain the above 189f715dc1SHans Petter Selasky * copyright notice, this list of conditions and the following 199f715dc1SHans Petter Selasky * disclaimer. 209f715dc1SHans Petter Selasky * 219f715dc1SHans Petter Selasky * - Redistributions in binary form must reproduce the above 229f715dc1SHans Petter Selasky * copyright notice, this list of conditions and the following 239f715dc1SHans Petter Selasky * disclaimer in the documentation and/or other materials 249f715dc1SHans Petter Selasky * provided with the distribution. 259f715dc1SHans Petter Selasky * 269f715dc1SHans Petter Selasky * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 279f715dc1SHans Petter Selasky * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 289f715dc1SHans Petter Selasky * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 299f715dc1SHans Petter Selasky * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 309f715dc1SHans Petter Selasky * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 319f715dc1SHans Petter Selasky * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 329f715dc1SHans Petter Selasky * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 339f715dc1SHans Petter Selasky * SOFTWARE. 349f715dc1SHans Petter Selasky */ 359f715dc1SHans Petter Selasky 369f715dc1SHans Petter Selasky #ifndef IB_USER_MAD_H 379f715dc1SHans Petter Selasky #define IB_USER_MAD_H 389f715dc1SHans Petter Selasky 39*b633e08cSHans Petter Selasky #include <rdma/rdma_user_ioctl.h> 409f715dc1SHans Petter Selasky 419f715dc1SHans Petter Selasky /* 429f715dc1SHans Petter Selasky * Increment this value if any changes that break userspace ABI 439f715dc1SHans Petter Selasky * compatibility are made. 449f715dc1SHans Petter Selasky */ 459f715dc1SHans Petter Selasky #define IB_USER_MAD_ABI_VERSION 5 469f715dc1SHans Petter Selasky 479f715dc1SHans Petter Selasky /* 489f715dc1SHans Petter Selasky * Make sure that all structs defined in this file remain laid out so 499f715dc1SHans Petter Selasky * that they pack the same way on 32-bit and 64-bit architectures (to 509f715dc1SHans Petter Selasky * avoid incompatibility between 32-bit userspace and 64-bit kernels). 519f715dc1SHans Petter Selasky */ 529f715dc1SHans Petter Selasky 539f715dc1SHans Petter Selasky /** 549f715dc1SHans Petter Selasky * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index 559f715dc1SHans Petter Selasky * @id - ID of agent MAD received with/to be sent with 569f715dc1SHans Petter Selasky * @status - 0 on successful receive, ETIMEDOUT if no response 579f715dc1SHans Petter Selasky * received (transaction ID in data[] will be set to TID of original 589f715dc1SHans Petter Selasky * request) (ignored on send) 599f715dc1SHans Petter Selasky * @timeout_ms - Milliseconds to wait for response (unset on receive) 609f715dc1SHans Petter Selasky * @retries - Number of automatic retries to attempt 619f715dc1SHans Petter Selasky * @qpn - Remote QP number received from/to be sent to 629f715dc1SHans Petter Selasky * @qkey - Remote Q_Key to be sent with (unset on receive) 639f715dc1SHans Petter Selasky * @lid - Remote lid received from/to be sent to 649f715dc1SHans Petter Selasky * @sl - Service level received with/to be sent with 659f715dc1SHans Petter Selasky * @path_bits - Local path bits received with/to be sent with 669f715dc1SHans Petter Selasky * @grh_present - If set, GRH was received/should be sent 679f715dc1SHans Petter Selasky * @gid_index - Local GID index to send with (unset on receive) 689f715dc1SHans Petter Selasky * @hop_limit - Hop limit in GRH 699f715dc1SHans Petter Selasky * @traffic_class - Traffic class in GRH 709f715dc1SHans Petter Selasky * @gid - Remote GID in GRH 719f715dc1SHans Petter Selasky * @flow_label - Flow label in GRH 729f715dc1SHans Petter Selasky */ 739f715dc1SHans Petter Selasky struct ib_user_mad_hdr_old { 749f715dc1SHans Petter Selasky __u32 id; 759f715dc1SHans Petter Selasky __u32 status; 769f715dc1SHans Petter Selasky __u32 timeout_ms; 779f715dc1SHans Petter Selasky __u32 retries; 789f715dc1SHans Petter Selasky __u32 length; 799f715dc1SHans Petter Selasky __be32 qpn; 809f715dc1SHans Petter Selasky __be32 qkey; 819f715dc1SHans Petter Selasky __be16 lid; 829f715dc1SHans Petter Selasky __u8 sl; 839f715dc1SHans Petter Selasky __u8 path_bits; 849f715dc1SHans Petter Selasky __u8 grh_present; 859f715dc1SHans Petter Selasky __u8 gid_index; 869f715dc1SHans Petter Selasky __u8 hop_limit; 879f715dc1SHans Petter Selasky __u8 traffic_class; 889f715dc1SHans Petter Selasky __u8 gid[16]; 899f715dc1SHans Petter Selasky __be32 flow_label; 909f715dc1SHans Petter Selasky }; 919f715dc1SHans Petter Selasky 929f715dc1SHans Petter Selasky /** 939f715dc1SHans Petter Selasky * ib_user_mad_hdr - MAD packet header 949f715dc1SHans Petter Selasky * This layout allows specifying/receiving the P_Key index. To use 959f715dc1SHans Petter Selasky * this capability, an application must call the 969f715dc1SHans Petter Selasky * IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before 979f715dc1SHans Petter Selasky * any other actions with the file handle. 989f715dc1SHans Petter Selasky * @id - ID of agent MAD received with/to be sent with 999f715dc1SHans Petter Selasky * @status - 0 on successful receive, ETIMEDOUT if no response 1009f715dc1SHans Petter Selasky * received (transaction ID in data[] will be set to TID of original 1019f715dc1SHans Petter Selasky * request) (ignored on send) 1029f715dc1SHans Petter Selasky * @timeout_ms - Milliseconds to wait for response (unset on receive) 1039f715dc1SHans Petter Selasky * @retries - Number of automatic retries to attempt 1049f715dc1SHans Petter Selasky * @qpn - Remote QP number received from/to be sent to 1059f715dc1SHans Petter Selasky * @qkey - Remote Q_Key to be sent with (unset on receive) 1069f715dc1SHans Petter Selasky * @lid - Remote lid received from/to be sent to 1079f715dc1SHans Petter Selasky * @sl - Service level received with/to be sent with 1089f715dc1SHans Petter Selasky * @path_bits - Local path bits received with/to be sent with 1099f715dc1SHans Petter Selasky * @grh_present - If set, GRH was received/should be sent 1109f715dc1SHans Petter Selasky * @gid_index - Local GID index to send with (unset on receive) 1119f715dc1SHans Petter Selasky * @hop_limit - Hop limit in GRH 1129f715dc1SHans Petter Selasky * @traffic_class - Traffic class in GRH 1139f715dc1SHans Petter Selasky * @gid - Remote GID in GRH 1149f715dc1SHans Petter Selasky * @flow_label - Flow label in GRH 1159f715dc1SHans Petter Selasky * @pkey_index - P_Key index 1169f715dc1SHans Petter Selasky */ 1179f715dc1SHans Petter Selasky struct ib_user_mad_hdr { 1189f715dc1SHans Petter Selasky __u32 id; 1199f715dc1SHans Petter Selasky __u32 status; 1209f715dc1SHans Petter Selasky __u32 timeout_ms; 1219f715dc1SHans Petter Selasky __u32 retries; 1229f715dc1SHans Petter Selasky __u32 length; 1239f715dc1SHans Petter Selasky __be32 qpn; 1249f715dc1SHans Petter Selasky __be32 qkey; 1259f715dc1SHans Petter Selasky __be16 lid; 1269f715dc1SHans Petter Selasky __u8 sl; 1279f715dc1SHans Petter Selasky __u8 path_bits; 1289f715dc1SHans Petter Selasky __u8 grh_present; 1299f715dc1SHans Petter Selasky __u8 gid_index; 1309f715dc1SHans Petter Selasky __u8 hop_limit; 1319f715dc1SHans Petter Selasky __u8 traffic_class; 1329f715dc1SHans Petter Selasky __u8 gid[16]; 1339f715dc1SHans Petter Selasky __be32 flow_label; 1349f715dc1SHans Petter Selasky __u16 pkey_index; 1359f715dc1SHans Petter Selasky __u8 reserved[6]; 1369f715dc1SHans Petter Selasky }; 1379f715dc1SHans Petter Selasky 1389f715dc1SHans Petter Selasky /** 1399f715dc1SHans Petter Selasky * ib_user_mad - MAD packet 1409f715dc1SHans Petter Selasky * @hdr - MAD packet header 1419f715dc1SHans Petter Selasky * @data - Contents of MAD 1429f715dc1SHans Petter Selasky * 1439f715dc1SHans Petter Selasky */ 1449f715dc1SHans Petter Selasky struct ib_user_mad { 1459f715dc1SHans Petter Selasky struct ib_user_mad_hdr hdr; 1469f715dc1SHans Petter Selasky __u64 data[0]; 1479f715dc1SHans Petter Selasky }; 1489f715dc1SHans Petter Selasky 1499f715dc1SHans Petter Selasky /* 1509f715dc1SHans Petter Selasky * Earlier versions of this interface definition declared the 1519f715dc1SHans Petter Selasky * method_mask[] member as an array of __u32 but treated it as a 1529f715dc1SHans Petter Selasky * bitmap made up of longs in the kernel. This ambiguity meant that 1539f715dc1SHans Petter Selasky * 32-bit big-endian applications that can run on both 32-bit and 1549f715dc1SHans Petter Selasky * 64-bit kernels had no consistent ABI to rely on, and 64-bit 1559f715dc1SHans Petter Selasky * big-endian applications that treated method_mask as being made up 1569f715dc1SHans Petter Selasky * of 32-bit words would have their bitmap misinterpreted. 1579f715dc1SHans Petter Selasky * 1589f715dc1SHans Petter Selasky * To clear up this confusion, we change the declaration of 1599f715dc1SHans Petter Selasky * method_mask[] to use unsigned long and handle the conversion from 1609f715dc1SHans Petter Selasky * 32-bit userspace to 64-bit kernel for big-endian systems in the 1619f715dc1SHans Petter Selasky * compat_ioctl method. Unfortunately, to keep the structure layout 1629f715dc1SHans Petter Selasky * the same, we need the method_mask[] array to be aligned only to 4 1639f715dc1SHans Petter Selasky * bytes even when long is 64 bits, which forces us into this ugly 1649f715dc1SHans Petter Selasky * typedef. 1659f715dc1SHans Petter Selasky */ 1669f715dc1SHans Petter Selasky typedef unsigned long __attribute__((aligned(4))) packed_ulong; 1679f715dc1SHans Petter Selasky #define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long))) 1689f715dc1SHans Petter Selasky 1699f715dc1SHans Petter Selasky /** 1709f715dc1SHans Petter Selasky * ib_user_mad_reg_req - MAD registration request 1719f715dc1SHans Petter Selasky * @id - Set by the kernel; used to identify agent in future requests. 1729f715dc1SHans Petter Selasky * @qpn - Queue pair number; must be 0 or 1. 1739f715dc1SHans Petter Selasky * @method_mask - The caller will receive unsolicited MADs for any method 1749f715dc1SHans Petter Selasky * where @method_mask = 1. 1759f715dc1SHans Petter Selasky * @mgmt_class - Indicates which management class of MADs should be receive 1769f715dc1SHans Petter Selasky * by the caller. This field is only required if the user wishes to 1779f715dc1SHans Petter Selasky * receive unsolicited MADs, otherwise it should be 0. 1789f715dc1SHans Petter Selasky * @mgmt_class_version - Indicates which version of MADs for the given 1799f715dc1SHans Petter Selasky * management class to receive. 1809f715dc1SHans Petter Selasky * @oui: Indicates IEEE OUI when mgmt_class is a vendor class 1819f715dc1SHans Petter Selasky * in the range from 0x30 to 0x4f. Otherwise not used. 1829f715dc1SHans Petter Selasky * @rmpp_version: If set, indicates the RMPP version used. 1839f715dc1SHans Petter Selasky * 1849f715dc1SHans Petter Selasky */ 1859f715dc1SHans Petter Selasky struct ib_user_mad_reg_req { 1869f715dc1SHans Petter Selasky __u32 id; 1879f715dc1SHans Petter Selasky packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK]; 1889f715dc1SHans Petter Selasky __u8 qpn; 1899f715dc1SHans Petter Selasky __u8 mgmt_class; 1909f715dc1SHans Petter Selasky __u8 mgmt_class_version; 1919f715dc1SHans Petter Selasky __u8 oui[3]; 1929f715dc1SHans Petter Selasky __u8 rmpp_version; 1939f715dc1SHans Petter Selasky }; 1949f715dc1SHans Petter Selasky 1959f715dc1SHans Petter Selasky /** 1969f715dc1SHans Petter Selasky * ib_user_mad_reg_req2 - MAD registration request 1979f715dc1SHans Petter Selasky * 1989f715dc1SHans Petter Selasky * @id - Set by the _kernel_; used by userspace to identify the 1999f715dc1SHans Petter Selasky * registered agent in future requests. 2009f715dc1SHans Petter Selasky * @qpn - Queue pair number; must be 0 or 1. 2019f715dc1SHans Petter Selasky * @mgmt_class - Indicates which management class of MADs should be 2029f715dc1SHans Petter Selasky * receive by the caller. This field is only required if 2039f715dc1SHans Petter Selasky * the user wishes to receive unsolicited MADs, otherwise 2049f715dc1SHans Petter Selasky * it should be 0. 2059f715dc1SHans Petter Selasky * @mgmt_class_version - Indicates which version of MADs for the given 2069f715dc1SHans Petter Selasky * management class to receive. 2079f715dc1SHans Petter Selasky * @res - Ignored. 2089f715dc1SHans Petter Selasky * @flags - additional registration flags; Must be in the set of 2099f715dc1SHans Petter Selasky * flags defined in IB_USER_MAD_REG_FLAGS_CAP 2109f715dc1SHans Petter Selasky * @method_mask - The caller wishes to receive unsolicited MADs for the 2119f715dc1SHans Petter Selasky * methods whose bit(s) is(are) set. 2129f715dc1SHans Petter Selasky * @oui - Indicates IEEE OUI to use when mgmt_class is a vendor 2139f715dc1SHans Petter Selasky * class in the range from 0x30 to 0x4f. Otherwise not 2149f715dc1SHans Petter Selasky * used. 2159f715dc1SHans Petter Selasky * @rmpp_version - If set, indicates the RMPP version to use. 2169f715dc1SHans Petter Selasky */ 2179f715dc1SHans Petter Selasky enum { 2189f715dc1SHans Petter Selasky IB_USER_MAD_USER_RMPP = (1 << 0), 2199f715dc1SHans Petter Selasky }; 2209f715dc1SHans Petter Selasky #define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP) 2219f715dc1SHans Petter Selasky struct ib_user_mad_reg_req2 { 2229f715dc1SHans Petter Selasky __u32 id; 2239f715dc1SHans Petter Selasky __u32 qpn; 2249f715dc1SHans Petter Selasky __u8 mgmt_class; 2259f715dc1SHans Petter Selasky __u8 mgmt_class_version; 2269f715dc1SHans Petter Selasky __u16 res; 2279f715dc1SHans Petter Selasky __u32 flags; 2289f715dc1SHans Petter Selasky __u64 method_mask[2]; 2299f715dc1SHans Petter Selasky __u32 oui; 2309f715dc1SHans Petter Selasky __u8 rmpp_version; 2319f715dc1SHans Petter Selasky __u8 reserved[3]; 2329f715dc1SHans Petter Selasky }; 2339f715dc1SHans Petter Selasky 2349f715dc1SHans Petter Selasky #endif /* IB_USER_MAD_H */ 235