/*1* Copyright (c) 2004 Topspin Communications. All rights reserved.2* Copyright (c) 2005 Voltaire, Inc. All rights reserved.3*4* This software is available to you under a choice of one of two5* licenses. You may choose to be licensed under the terms of the GNU6* General Public License (GPL) Version 2, available from the file7* COPYING in the main directory of this source tree, or the8* OpenIB.org BSD license below:9*10* Redistribution and use in source and binary forms, with or11* without modification, are permitted provided that the following12* conditions are met:13*14* - Redistributions of source code must retain the above15* copyright notice, this list of conditions and the following16* disclaimer.17*18* - Redistributions in binary form must reproduce the above19* copyright notice, this list of conditions and the following20* disclaimer in the documentation and/or other materials21* provided with the distribution.22*23* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,24* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF25* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND26* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS27* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN28* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN29* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE30* SOFTWARE.31*/3233#ifndef IB_USER_MAD_H34#define IB_USER_MAD_H3536#include <linux/types.h>37#include <linux/ioctl.h>3839/*40* Increment this value if any changes that break userspace ABI41* compatibility are made.42*/43#define IB_USER_MAD_ABI_VERSION 54445/*46* Make sure that all structs defined in this file remain laid out so47* that they pack the same way on 32-bit and 64-bit architectures (to48* avoid incompatibility between 32-bit userspace and 64-bit kernels).49*/5051/**52* ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index53* @id - ID of agent MAD received with/to be sent with54* @status - 0 on successful receive, ETIMEDOUT if no response55* received (transaction ID in data[] will be set to TID of original56* request) (ignored on send)57* @timeout_ms - Milliseconds to wait for response (unset on receive)58* @retries - Number of automatic retries to attempt59* @qpn - Remote QP number received from/to be sent to60* @qkey - Remote Q_Key to be sent with (unset on receive)61* @lid - Remote lid received from/to be sent to62* @sl - Service level received with/to be sent with63* @path_bits - Local path bits received with/to be sent with64* @grh_present - If set, GRH was received/should be sent65* @gid_index - Local GID index to send with (unset on receive)66* @hop_limit - Hop limit in GRH67* @traffic_class - Traffic class in GRH68* @gid - Remote GID in GRH69* @flow_label - Flow label in GRH70*/71struct ib_user_mad_hdr_old {72__u32 id;73__u32 status;74__u32 timeout_ms;75__u32 retries;76__u32 length;77__be32 qpn;78__be32 qkey;79__be16 lid;80__u8 sl;81__u8 path_bits;82__u8 grh_present;83__u8 gid_index;84__u8 hop_limit;85__u8 traffic_class;86__u8 gid[16];87__be32 flow_label;88};8990/**91* ib_user_mad_hdr - MAD packet header92* This layout allows specifying/receiving the P_Key index. To use93* this capability, an application must call the94* IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before95* any other actions with the file handle.96* @id - ID of agent MAD received with/to be sent with97* @status - 0 on successful receive, ETIMEDOUT if no response98* received (transaction ID in data[] will be set to TID of original99* request) (ignored on send)100* @timeout_ms - Milliseconds to wait for response (unset on receive)101* @retries - Number of automatic retries to attempt102* @qpn - Remote QP number received from/to be sent to103* @qkey - Remote Q_Key to be sent with (unset on receive)104* @lid - Remote lid received from/to be sent to105* @sl - Service level received with/to be sent with106* @path_bits - Local path bits received with/to be sent with107* @grh_present - If set, GRH was received/should be sent108* @gid_index - Local GID index to send with (unset on receive)109* @hop_limit - Hop limit in GRH110* @traffic_class - Traffic class in GRH111* @gid - Remote GID in GRH112* @flow_label - Flow label in GRH113* @pkey_index - P_Key index114*/115struct ib_user_mad_hdr {116__u32 id;117__u32 status;118__u32 timeout_ms;119__u32 retries;120__u32 length;121__be32 qpn;122__be32 qkey;123__be16 lid;124__u8 sl;125__u8 path_bits;126__u8 grh_present;127__u8 gid_index;128__u8 hop_limit;129__u8 traffic_class;130__u8 gid[16];131__be32 flow_label;132__u16 pkey_index;133__u8 reserved[6];134};135136/**137* ib_user_mad - MAD packet138* @hdr - MAD packet header139* @data - Contents of MAD140*141*/142struct ib_user_mad {143struct ib_user_mad_hdr hdr;144__u64 data[0];145};146147/*148* Earlier versions of this interface definition declared the149* method_mask[] member as an array of __u32 but treated it as a150* bitmap made up of longs in the kernel. This ambiguity meant that151* 32-bit big-endian applications that can run on both 32-bit and152* 64-bit kernels had no consistent ABI to rely on, and 64-bit153* big-endian applications that treated method_mask as being made up154* of 32-bit words would have their bitmap misinterpreted.155*156* To clear up this confusion, we change the declaration of157* method_mask[] to use unsigned long and handle the conversion from158* 32-bit userspace to 64-bit kernel for big-endian systems in the159* compat_ioctl method. Unfortunately, to keep the structure layout160* the same, we need the method_mask[] array to be aligned only to 4161* bytes even when long is 64 bits, which forces us into this ugly162* typedef.163*/164typedef unsigned long __attribute__((aligned(4))) packed_ulong;165#define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long)))166167/**168* ib_user_mad_reg_req - MAD registration request169* @id - Set by the kernel; used to identify agent in future requests.170* @qpn - Queue pair number; must be 0 or 1.171* @method_mask - The caller will receive unsolicited MADs for any method172* where @method_mask = 1.173* @mgmt_class - Indicates which management class of MADs should be receive174* by the caller. This field is only required if the user wishes to175* receive unsolicited MADs, otherwise it should be 0.176* @mgmt_class_version - Indicates which version of MADs for the given177* management class to receive.178* @oui: Indicates IEEE OUI when mgmt_class is a vendor class179* in the range from 0x30 to 0x4f. Otherwise not used.180* @rmpp_version: If set, indicates the RMPP version used.181*182*/183struct ib_user_mad_reg_req {184__u32 id;185packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK];186__u8 qpn;187__u8 mgmt_class;188__u8 mgmt_class_version;189__u8 oui[3];190__u8 rmpp_version;191};192193#define IB_IOCTL_MAGIC 0x1b194195#define IB_USER_MAD_REGISTER_AGENT _IOWR(IB_IOCTL_MAGIC, 1, \196struct ib_user_mad_reg_req)197198#define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, __u32)199200#define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3)201202#endif /* IB_USER_MAD_H */203204205