/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */1/*2* Copyright (c) 2004 Topspin Communications. All rights reserved.3* Copyright (c) 2005 Voltaire, Inc. All rights reserved.4*5* This software is available to you under a choice of one of two6* licenses. You may choose to be licensed under the terms of the GNU7* General Public License (GPL) Version 2, available from the file8* COPYING in the main directory of this source tree, or the9* OpenIB.org BSD license below:10*11* Redistribution and use in source and binary forms, with or12* without modification, are permitted provided that the following13* conditions are met:14*15* - Redistributions of source code must retain the above16* copyright notice, this list of conditions and the following17* disclaimer.18*19* - Redistributions in binary form must reproduce the above20* copyright notice, this list of conditions and the following21* disclaimer in the documentation and/or other materials22* provided with the distribution.23*24* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,25* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF26* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND27* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS28* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN29* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN30* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE31* SOFTWARE.32*/3334#ifndef IB_USER_MAD_H35#define IB_USER_MAD_H3637#include <linux/types.h>38#include <rdma/rdma_user_ioctl.h>3940/*41* Increment this value if any changes that break userspace ABI42* compatibility are made.43*/44#define IB_USER_MAD_ABI_VERSION 54546/*47* Make sure that all structs defined in this file remain laid out so48* that they pack the same way on 32-bit and 64-bit architectures (to49* avoid incompatibility between 32-bit userspace and 64-bit kernels).50*/5152/**53* ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index54* @id - ID of agent MAD received with/to be sent with55* @status - 0 on successful receive, ETIMEDOUT if no response56* received (transaction ID in data[] will be set to TID of original57* request) (ignored on send)58* @timeout_ms - Milliseconds to wait for response (unset on receive)59* @retries - Number of automatic retries to attempt60* @qpn - Remote QP number received from/to be sent to61* @qkey - Remote Q_Key to be sent with (unset on receive)62* @lid - Remote lid received from/to be sent to63* @sl - Service level received with/to be sent with64* @path_bits - Local path bits received with/to be sent with65* @grh_present - If set, GRH was received/should be sent66* @gid_index - Local GID index to send with (unset on receive)67* @hop_limit - Hop limit in GRH68* @traffic_class - Traffic class in GRH69* @gid - Remote GID in GRH70* @flow_label - Flow label in GRH71*/72struct ib_user_mad_hdr_old {73__u32 id;74__u32 status;75__u32 timeout_ms;76__u32 retries;77__u32 length;78__be32 qpn;79__be32 qkey;80__be16 lid;81__u8 sl;82__u8 path_bits;83__u8 grh_present;84__u8 gid_index;85__u8 hop_limit;86__u8 traffic_class;87__u8 gid[16];88__be32 flow_label;89};9091/**92* ib_user_mad_hdr - MAD packet header93* This layout allows specifying/receiving the P_Key index. To use94* this capability, an application must call the95* IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before96* any other actions with the file handle.97* @id - ID of agent MAD received with/to be sent with98* @status - 0 on successful receive, ETIMEDOUT if no response99* received (transaction ID in data[] will be set to TID of original100* request) (ignored on send)101* @timeout_ms - Milliseconds to wait for response (unset on receive)102* @retries - Number of automatic retries to attempt103* @qpn - Remote QP number received from/to be sent to104* @qkey - Remote Q_Key to be sent with (unset on receive)105* @lid - Remote lid received from/to be sent to106* @sl - Service level received with/to be sent with107* @path_bits - Local path bits received with/to be sent with108* @grh_present - If set, GRH was received/should be sent109* @gid_index - Local GID index to send with (unset on receive)110* @hop_limit - Hop limit in GRH111* @traffic_class - Traffic class in GRH112* @gid - Remote GID in GRH113* @flow_label - Flow label in GRH114* @pkey_index - P_Key index115*/116struct ib_user_mad_hdr {117__u32 id;118__u32 status;119__u32 timeout_ms;120__u32 retries;121__u32 length;122__be32 qpn;123__be32 qkey;124__be16 lid;125__u8 sl;126__u8 path_bits;127__u8 grh_present;128__u8 gid_index;129__u8 hop_limit;130__u8 traffic_class;131__u8 gid[16];132__be32 flow_label;133__u16 pkey_index;134__u8 reserved[6];135};136137/**138* ib_user_mad - MAD packet139* @hdr - MAD packet header140* @data - Contents of MAD141*142*/143struct ib_user_mad {144struct ib_user_mad_hdr hdr;145__aligned_u64 data[];146};147148/*149* Earlier versions of this interface definition declared the150* method_mask[] member as an array of __u32 but treated it as a151* bitmap made up of longs in the kernel. This ambiguity meant that152* 32-bit big-endian applications that can run on both 32-bit and153* 64-bit kernels had no consistent ABI to rely on, and 64-bit154* big-endian applications that treated method_mask as being made up155* of 32-bit words would have their bitmap misinterpreted.156*157* To clear up this confusion, we change the declaration of158* method_mask[] to use unsigned long and handle the conversion from159* 32-bit userspace to 64-bit kernel for big-endian systems in the160* compat_ioctl method. Unfortunately, to keep the structure layout161* the same, we need the method_mask[] array to be aligned only to 4162* bytes even when long is 64 bits, which forces us into this ugly163* typedef.164*/165typedef unsigned long __attribute__((aligned(4))) packed_ulong;166#define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long)))167168/**169* ib_user_mad_reg_req - MAD registration request170* @id - Set by the kernel; used to identify agent in future requests.171* @qpn - Queue pair number; must be 0 or 1.172* @method_mask - The caller will receive unsolicited MADs for any method173* where @method_mask = 1.174* @mgmt_class - Indicates which management class of MADs should be receive175* by the caller. This field is only required if the user wishes to176* receive unsolicited MADs, otherwise it should be 0.177* @mgmt_class_version - Indicates which version of MADs for the given178* management class to receive.179* @oui: Indicates IEEE OUI when mgmt_class is a vendor class180* in the range from 0x30 to 0x4f. Otherwise not used.181* @rmpp_version: If set, indicates the RMPP version used.182*183*/184struct ib_user_mad_reg_req {185__u32 id;186packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK];187__u8 qpn;188__u8 mgmt_class;189__u8 mgmt_class_version;190__u8 oui[3];191__u8 rmpp_version;192};193194/**195* ib_user_mad_reg_req2 - MAD registration request196*197* @id - Set by the _kernel_; used by userspace to identify the198* registered agent in future requests.199* @qpn - Queue pair number; must be 0 or 1.200* @mgmt_class - Indicates which management class of MADs should be201* receive by the caller. This field is only required if202* the user wishes to receive unsolicited MADs, otherwise203* it should be 0.204* @mgmt_class_version - Indicates which version of MADs for the given205* management class to receive.206* @res - Ignored.207* @flags - additional registration flags; Must be in the set of208* flags defined in IB_USER_MAD_REG_FLAGS_CAP209* @method_mask - The caller wishes to receive unsolicited MADs for the210* methods whose bit(s) is(are) set.211* @oui - Indicates IEEE OUI to use when mgmt_class is a vendor212* class in the range from 0x30 to 0x4f. Otherwise not213* used.214* @rmpp_version - If set, indicates the RMPP version to use.215*/216enum {217IB_USER_MAD_USER_RMPP = (1 << 0),218};219#define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP)220struct ib_user_mad_reg_req2 {221__u32 id;222__u32 qpn;223__u8 mgmt_class;224__u8 mgmt_class_version;225__u16 res;226__u32 flags;227__aligned_u64 method_mask[2];228__u32 oui;229__u8 rmpp_version;230__u8 reserved[3];231};232233#endif /* IB_USER_MAD_H */234235236