Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR Linux-OpenIB) */
0002 /*
0003  * Copyright (c) 2004 Topspin Communications.  All rights reserved.
0004  * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
0005  *
0006  * This software is available to you under a choice of one of two
0007  * licenses.  You may choose to be licensed under the terms of the GNU
0008  * General Public License (GPL) Version 2, available from the file
0009  * COPYING in the main directory of this source tree, or the
0010  * OpenIB.org BSD license below:
0011  *
0012  *     Redistribution and use in source and binary forms, with or
0013  *     without modification, are permitted provided that the following
0014  *     conditions are met:
0015  *
0016  *      - Redistributions of source code must retain the above
0017  *        copyright notice, this list of conditions and the following
0018  *        disclaimer.
0019  *
0020  *      - Redistributions in binary form must reproduce the above
0021  *        copyright notice, this list of conditions and the following
0022  *        disclaimer in the documentation and/or other materials
0023  *        provided with the distribution.
0024  *
0025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0026  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0027  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0028  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0029  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0030  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0031  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0032  * SOFTWARE.
0033  */
0034 
0035 #ifndef IB_USER_MAD_H
0036 #define IB_USER_MAD_H
0037 
0038 #include <linux/types.h>
0039 #include <rdma/rdma_user_ioctl.h>
0040 
0041 /*
0042  * Increment this value if any changes that break userspace ABI
0043  * compatibility are made.
0044  */
0045 #define IB_USER_MAD_ABI_VERSION 5
0046 
0047 /*
0048  * Make sure that all structs defined in this file remain laid out so
0049  * that they pack the same way on 32-bit and 64-bit architectures (to
0050  * avoid incompatibility between 32-bit userspace and 64-bit kernels).
0051  */
0052 
0053 /**
0054  * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index
0055  * @id - ID of agent MAD received with/to be sent with
0056  * @status - 0 on successful receive, ETIMEDOUT if no response
0057  *   received (transaction ID in data[] will be set to TID of original
0058  *   request) (ignored on send)
0059  * @timeout_ms - Milliseconds to wait for response (unset on receive)
0060  * @retries - Number of automatic retries to attempt
0061  * @qpn - Remote QP number received from/to be sent to
0062  * @qkey - Remote Q_Key to be sent with (unset on receive)
0063  * @lid - Remote lid received from/to be sent to
0064  * @sl - Service level received with/to be sent with
0065  * @path_bits - Local path bits received with/to be sent with
0066  * @grh_present - If set, GRH was received/should be sent
0067  * @gid_index - Local GID index to send with (unset on receive)
0068  * @hop_limit - Hop limit in GRH
0069  * @traffic_class - Traffic class in GRH
0070  * @gid - Remote GID in GRH
0071  * @flow_label - Flow label in GRH
0072  */
0073 struct ib_user_mad_hdr_old {
0074     __u32   id;
0075     __u32   status;
0076     __u32   timeout_ms;
0077     __u32   retries;
0078     __u32   length;
0079     __be32  qpn;
0080     __be32  qkey;
0081     __be16  lid;
0082     __u8    sl;
0083     __u8    path_bits;
0084     __u8    grh_present;
0085     __u8    gid_index;
0086     __u8    hop_limit;
0087     __u8    traffic_class;
0088     __u8    gid[16];
0089     __be32  flow_label;
0090 };
0091 
0092 /**
0093  * ib_user_mad_hdr - MAD packet header
0094  *   This layout allows specifying/receiving the P_Key index.  To use
0095  *   this capability, an application must call the
0096  *   IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before
0097  *   any other actions with the file handle.
0098  * @id - ID of agent MAD received with/to be sent with
0099  * @status - 0 on successful receive, ETIMEDOUT if no response
0100  *   received (transaction ID in data[] will be set to TID of original
0101  *   request) (ignored on send)
0102  * @timeout_ms - Milliseconds to wait for response (unset on receive)
0103  * @retries - Number of automatic retries to attempt
0104  * @qpn - Remote QP number received from/to be sent to
0105  * @qkey - Remote Q_Key to be sent with (unset on receive)
0106  * @lid - Remote lid received from/to be sent to
0107  * @sl - Service level received with/to be sent with
0108  * @path_bits - Local path bits received with/to be sent with
0109  * @grh_present - If set, GRH was received/should be sent
0110  * @gid_index - Local GID index to send with (unset on receive)
0111  * @hop_limit - Hop limit in GRH
0112  * @traffic_class - Traffic class in GRH
0113  * @gid - Remote GID in GRH
0114  * @flow_label - Flow label in GRH
0115  * @pkey_index - P_Key index
0116  */
0117 struct ib_user_mad_hdr {
0118     __u32   id;
0119     __u32   status;
0120     __u32   timeout_ms;
0121     __u32   retries;
0122     __u32   length;
0123     __be32  qpn;
0124     __be32  qkey;
0125     __be16  lid;
0126     __u8    sl;
0127     __u8    path_bits;
0128     __u8    grh_present;
0129     __u8    gid_index;
0130     __u8    hop_limit;
0131     __u8    traffic_class;
0132     __u8    gid[16];
0133     __be32  flow_label;
0134     __u16   pkey_index;
0135     __u8    reserved[6];
0136 };
0137 
0138 /**
0139  * ib_user_mad - MAD packet
0140  * @hdr - MAD packet header
0141  * @data - Contents of MAD
0142  *
0143  */
0144 struct ib_user_mad {
0145     struct ib_user_mad_hdr hdr;
0146     __aligned_u64   data[];
0147 };
0148 
0149 /*
0150  * Earlier versions of this interface definition declared the
0151  * method_mask[] member as an array of __u32 but treated it as a
0152  * bitmap made up of longs in the kernel.  This ambiguity meant that
0153  * 32-bit big-endian applications that can run on both 32-bit and
0154  * 64-bit kernels had no consistent ABI to rely on, and 64-bit
0155  * big-endian applications that treated method_mask as being made up
0156  * of 32-bit words would have their bitmap misinterpreted.
0157  *
0158  * To clear up this confusion, we change the declaration of
0159  * method_mask[] to use unsigned long and handle the conversion from
0160  * 32-bit userspace to 64-bit kernel for big-endian systems in the
0161  * compat_ioctl method.  Unfortunately, to keep the structure layout
0162  * the same, we need the method_mask[] array to be aligned only to 4
0163  * bytes even when long is 64 bits, which forces us into this ugly
0164  * typedef.
0165  */
0166 typedef unsigned long __attribute__((aligned(4))) packed_ulong;
0167 #define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long)))
0168 
0169 /**
0170  * ib_user_mad_reg_req - MAD registration request
0171  * @id - Set by the kernel; used to identify agent in future requests.
0172  * @qpn - Queue pair number; must be 0 or 1.
0173  * @method_mask - The caller will receive unsolicited MADs for any method
0174  *   where @method_mask = 1.
0175  * @mgmt_class - Indicates which management class of MADs should be receive
0176  *   by the caller.  This field is only required if the user wishes to
0177  *   receive unsolicited MADs, otherwise it should be 0.
0178  * @mgmt_class_version - Indicates which version of MADs for the given
0179  *   management class to receive.
0180  * @oui: Indicates IEEE OUI when mgmt_class is a vendor class
0181  *   in the range from 0x30 to 0x4f. Otherwise not used.
0182  * @rmpp_version: If set, indicates the RMPP version used.
0183  *
0184  */
0185 struct ib_user_mad_reg_req {
0186     __u32   id;
0187     packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK];
0188     __u8    qpn;
0189     __u8    mgmt_class;
0190     __u8    mgmt_class_version;
0191     __u8    oui[3];
0192     __u8    rmpp_version;
0193 };
0194 
0195 /**
0196  * ib_user_mad_reg_req2 - MAD registration request
0197  *
0198  * @id                 - Set by the _kernel_; used by userspace to identify the
0199  *                       registered agent in future requests.
0200  * @qpn                - Queue pair number; must be 0 or 1.
0201  * @mgmt_class         - Indicates which management class of MADs should be
0202  *                       receive by the caller.  This field is only required if
0203  *                       the user wishes to receive unsolicited MADs, otherwise
0204  *                       it should be 0.
0205  * @mgmt_class_version - Indicates which version of MADs for the given
0206  *                       management class to receive.
0207  * @res                - Ignored.
0208  * @flags              - additional registration flags; Must be in the set of
0209  *                       flags defined in IB_USER_MAD_REG_FLAGS_CAP
0210  * @method_mask        - The caller wishes to receive unsolicited MADs for the
0211  *                       methods whose bit(s) is(are) set.
0212  * @oui                - Indicates IEEE OUI to use when mgmt_class is a vendor
0213  *                       class in the range from 0x30 to 0x4f. Otherwise not
0214  *                       used.
0215  * @rmpp_version       - If set, indicates the RMPP version to use.
0216  */
0217 enum {
0218     IB_USER_MAD_USER_RMPP = (1 << 0),
0219 };
0220 #define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP)
0221 struct ib_user_mad_reg_req2 {
0222     __u32   id;
0223     __u32   qpn;
0224     __u8    mgmt_class;
0225     __u8    mgmt_class_version;
0226     __u16   res;
0227     __u32   flags;
0228     __aligned_u64 method_mask[2];
0229     __u32   oui;
0230     __u8    rmpp_version;
0231     __u8    reserved[3];
0232 };
0233 
0234 #endif /* IB_USER_MAD_H */