1 /* 2 * This file contains definitions used in OFED defined user/kernel 3 * interfaces. These are imported from the OFED header ib_user_mad.h. Oracle 4 * elects to have and use the contents of ib_user_mad.h under and governed 5 * by the OpenIB.org BSD license (see below for full license text). However, 6 * the following notice accompanied the original version of this file: 7 */ 8 9 /* 10 * Copyright (c) 2004 Topspin Communications. All rights reserved. 11 * Copyright (c) 2005 Voltaire, Inc. All rights reserved. 12 * 13 * This software is available to you under a choice of one of two 14 * licenses. You may choose to be licensed under the terms of the GNU 15 * General Public License (GPL) Version 2, available from the file 16 * COPYING in the main directory of this source tree, or the 17 * OpenIB.org BSD license below: 18 * 19 * Redistribution and use in source and binary forms, with or 20 * without modification, are permitted provided that the following 21 * conditions are met: 22 * 23 * - Redistributions of source code must retain the above 24 * copyright notice, this list of conditions and the following 25 * disclaimer. 26 * 27 * - Redistributions in binary form must reproduce the above 28 * copyright notice, this list of conditions and the following 29 * disclaimer in the documentation and/or other materials 30 * provided with the distribution. 31 * 32 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 33 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 34 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 35 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 36 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 37 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 38 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 39 * SOFTWARE. 40 * 41 */ 42 43 #ifndef _SYS_IB_CLIENTS_OF_RDMA_IB_USER_MAD_H 44 #define _SYS_IB_CLIENTS_OF_RDMA_IB_USER_MAD_H 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 /* 51 * Increment this value if any changes that break userspace ABI 52 * compatibility are made. 53 */ 54 #define IB_USER_MAD_ABI_VERSION 5 55 56 /* 57 * Make sure that all structs defined in this file remain laid out so 58 * that they pack the same way on 32-bit and 64-bit architectures (to 59 * avoid incompatibility between 32-bit userspace and 64-bit kernels). 60 */ 61 62 /* 63 * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index 64 * @id - ID of agent MAD received with/to be sent with 65 * @status - 0 on successful receive, ETIMEDOUT if no response 66 * received (transaction ID in data[] will be set to TID of original 67 * request) (ignored on send) 68 * @timeout_ms - Milliseconds to wait for response (unset on receive) 69 * @retries - Number of automatic retries to attempt 70 * @qpn - Remote QP number received from/to be sent to 71 * @qkey - Remote Q_Key to be sent with (unset on receive) 72 * @lid - Remote lid received from/to be sent to 73 * @sl - Service level received with/to be sent with 74 * @path_bits - Local path bits received with/to be sent with 75 * @grh_present - If set, GRH was received/should be sent 76 * @gid_index - Local GID index to send with (unset on receive) 77 * @hop_limit - Hop limit in GRH 78 * @traffic_class - Traffic class in GRH 79 * @gid - Remote GID in GRH 80 * @flow_label - Flow label in GRH 81 * 82 */ 83 84 /* 85 * ib_user_mad_hdr - MAD packet header 86 * This layout allows specifying/receiving the P_Key index. To use 87 * this capability, an application must call the 88 * IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before 89 * any other actions with the file handle. 90 * @id - ID of agent MAD received with/to be sent with 91 * @status - 0 on successful receive, ETIMEDOUT if no response 92 * received (transaction ID in data[] will be set to TID of original 93 * request) (ignored on send) 94 * @timeout_ms - Milliseconds to wait for response (unset on receive) 95 * @retries - Number of automatic retries to attempt 96 * @qpn - Remote QP number received from/to be sent to 97 * @qkey - Remote Q_Key to be sent with (unset on receive) 98 * @lid - Remote lid received from/to be sent to 99 * @sl - Service level received with/to be sent with 100 * @path_bits - Local path bits received with/to be sent with 101 * @grh_present - If set, GRH was received/should be sent 102 * @gid_index - Local GID index to send with (unset on receive) 103 * @hop_limit - Hop limit in GRH 104 * @traffic_class - Traffic class in GRH 105 * @gid - Remote GID in GRH 106 * @flow_label - Flow label in GRH 107 * 108 */ 109 struct ib_user_mad_hdr { 110 uint32_t id; 111 uint32_t status; 112 uint32_t timeout_ms; 113 uint32_t retries; 114 uint32_t length; 115 uint32_t qpn; 116 uint32_t qkey; 117 uint16_t lid; 118 uint8_t sl; 119 uint8_t path_bits; 120 uint8_t grh_present; 121 uint8_t gid_index; 122 uint8_t hop_limit; 123 uint8_t traffic_class; 124 uint8_t gid[16]; 125 uint32_t flow_label; 126 uint16_t pkey_index; 127 uint8_t reserved[6]; 128 }; 129 130 /* 131 * ib_user_mad - MAD packet 132 * @hdr - MAD packet header 133 * @data - Contents of MAD 134 * 135 */ 136 struct ib_user_mad { 137 struct ib_user_mad_hdr hdr; 138 uint64_t data[]; 139 }; 140 141 /* 142 * ib_user_mad_reg_req - MAD registration request 143 * @id - Set by the kernel; used to identify agent in future requests. 144 * @qpn - Queue pair number; must be 0 or 1. 145 * @method_mask - The caller will receive unsolicited MADs for any method 146 * where @method_mask = 1. 147 * @mgmt_class - Indicates which management class of MADs should be receive 148 * by the caller. This field is only required if the user wishes to 149 * receive unsolicited MADs, otherwise it should be 0. 150 * @mgmt_class_version - Indicates which version of MADs for the given 151 * management class to receive. 152 * @oui: Indicates IEEE OUI when mgmt_class is a vendor class 153 * in the range from 0x30 to 0x4f. Otherwise not used. 154 * @rmpp_version: If set, indicates the RMPP version used. 155 * 156 */ 157 struct ib_user_mad_reg_req { 158 uint32_t id; 159 uint32_t method_mask[4]; 160 uint8_t qpn; 161 uint8_t mgmt_class; 162 uint8_t mgmt_class_version; 163 uint8_t oui[3]; 164 uint8_t rmpp_version; 165 }; 166 167 #define IB_IOCTL_MAGIC 0x1b 168 169 #define IB_USER_MAD_REGISTER_AGENT _IOWR(IB_IOCTL_MAGIC, 1, \ 170 struct ib_user_mad_reg_req) 171 172 #define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, uint32_t) 173 174 #define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3) 175 176 #ifdef __cplusplus 177 } 178 #endif 179 #endif /* _SYS_IB_CLIENTS_OF_RDMA_IB_USER_MAD_H */ 180