ib_user_mad.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 two
  6. * licenses. You may choose to be licensed under the terms of the GNU
  7. * General Public License (GPL) Version 2, available from the file
  8. * COPYING in the main directory of this source tree, or the
  9. * OpenIB.org BSD license below:
  10. *
  11. * Redistribution and use in source and binary forms, with or
  12. * without modification, are permitted provided that the following
  13. * conditions are met:
  14. *
  15. * - Redistributions of source code must retain the above
  16. * copyright notice, this list of conditions and the following
  17. * disclaimer.
  18. *
  19. * - Redistributions in binary form must reproduce the above
  20. * copyright notice, this list of conditions and the following
  21. * disclaimer in the documentation and/or other materials
  22. * 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 OF
  26. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  28. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  29. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  30. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  31. * SOFTWARE.
  32. */
  33. #ifndef IB_USER_MAD_H
  34. #define IB_USER_MAD_H
  35. #include <linux/types.h>
  36. #include <linux/ioctl.h>
  37. /*
  38. * Increment this value if any changes that break userspace ABI
  39. * compatibility are made.
  40. */
  41. #define IB_USER_MAD_ABI_VERSION 5
  42. /*
  43. * Make sure that all structs defined in this file remain laid out so
  44. * that they pack the same way on 32-bit and 64-bit architectures (to
  45. * avoid incompatibility between 32-bit userspace and 64-bit kernels).
  46. */
  47. /**
  48. * ib_user_mad_hdr_old - Old version of MAD packet header without pkey_index
  49. * @id - ID of agent MAD received with/to be sent with
  50. * @status - 0 on successful receive, ETIMEDOUT if no response
  51. * received (transaction ID in data[] will be set to TID of original
  52. * request) (ignored on send)
  53. * @timeout_ms - Milliseconds to wait for response (unset on receive)
  54. * @retries - Number of automatic retries to attempt
  55. * @qpn - Remote QP number received from/to be sent to
  56. * @qkey - Remote Q_Key to be sent with (unset on receive)
  57. * @lid - Remote lid received from/to be sent to
  58. * @sl - Service level received with/to be sent with
  59. * @path_bits - Local path bits received with/to be sent with
  60. * @grh_present - If set, GRH was received/should be sent
  61. * @gid_index - Local GID index to send with (unset on receive)
  62. * @hop_limit - Hop limit in GRH
  63. * @traffic_class - Traffic class in GRH
  64. * @gid - Remote GID in GRH
  65. * @flow_label - Flow label in GRH
  66. */
  67. struct ib_user_mad_hdr_old {
  68. __u32 id;
  69. __u32 status;
  70. __u32 timeout_ms;
  71. __u32 retries;
  72. __u32 length;
  73. __be32 qpn;
  74. __be32 qkey;
  75. __be16 lid;
  76. __u8 sl;
  77. __u8 path_bits;
  78. __u8 grh_present;
  79. __u8 gid_index;
  80. __u8 hop_limit;
  81. __u8 traffic_class;
  82. __u8 gid[16];
  83. __be32 flow_label;
  84. };
  85. /**
  86. * ib_user_mad_hdr - MAD packet header
  87. * This layout allows specifying/receiving the P_Key index. To use
  88. * this capability, an application must call the
  89. * IB_USER_MAD_ENABLE_PKEY ioctl on the user MAD file handle before
  90. * any other actions with the file handle.
  91. * @id - ID of agent MAD received with/to be sent with
  92. * @status - 0 on successful receive, ETIMEDOUT if no response
  93. * received (transaction ID in data[] will be set to TID of original
  94. * request) (ignored on send)
  95. * @timeout_ms - Milliseconds to wait for response (unset on receive)
  96. * @retries - Number of automatic retries to attempt
  97. * @qpn - Remote QP number received from/to be sent to
  98. * @qkey - Remote Q_Key to be sent with (unset on receive)
  99. * @lid - Remote lid received from/to be sent to
  100. * @sl - Service level received with/to be sent with
  101. * @path_bits - Local path bits received with/to be sent with
  102. * @grh_present - If set, GRH was received/should be sent
  103. * @gid_index - Local GID index to send with (unset on receive)
  104. * @hop_limit - Hop limit in GRH
  105. * @traffic_class - Traffic class in GRH
  106. * @gid - Remote GID in GRH
  107. * @flow_label - Flow label in GRH
  108. * @pkey_index - P_Key index
  109. */
  110. struct ib_user_mad_hdr {
  111. __u32 id;
  112. __u32 status;
  113. __u32 timeout_ms;
  114. __u32 retries;
  115. __u32 length;
  116. __be32 qpn;
  117. __be32 qkey;
  118. __be16 lid;
  119. __u8 sl;
  120. __u8 path_bits;
  121. __u8 grh_present;
  122. __u8 gid_index;
  123. __u8 hop_limit;
  124. __u8 traffic_class;
  125. __u8 gid[16];
  126. __be32 flow_label;
  127. __u16 pkey_index;
  128. __u8 reserved[6];
  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. __u64 data[0];
  139. };
  140. /*
  141. * Earlier versions of this interface definition declared the
  142. * method_mask[] member as an array of __u32 but treated it as a
  143. * bitmap made up of longs in the kernel. This ambiguity meant that
  144. * 32-bit big-endian applications that can run on both 32-bit and
  145. * 64-bit kernels had no consistent ABI to rely on, and 64-bit
  146. * big-endian applications that treated method_mask as being made up
  147. * of 32-bit words would have their bitmap misinterpreted.
  148. *
  149. * To clear up this confusion, we change the declaration of
  150. * method_mask[] to use unsigned long and handle the conversion from
  151. * 32-bit userspace to 64-bit kernel for big-endian systems in the
  152. * compat_ioctl method. Unfortunately, to keep the structure layout
  153. * the same, we need the method_mask[] array to be aligned only to 4
  154. * bytes even when long is 64 bits, which forces us into this ugly
  155. * typedef.
  156. */
  157. typedef unsigned long __attribute__((aligned(4))) packed_ulong;
  158. #define IB_USER_MAD_LONGS_PER_METHOD_MASK (128 / (8 * sizeof (long)))
  159. /**
  160. * ib_user_mad_reg_req - MAD registration request
  161. * @id - Set by the kernel; used to identify agent in future requests.
  162. * @qpn - Queue pair number; must be 0 or 1.
  163. * @method_mask - The caller will receive unsolicited MADs for any method
  164. * where @method_mask = 1.
  165. * @mgmt_class - Indicates which management class of MADs should be receive
  166. * by the caller. This field is only required if the user wishes to
  167. * receive unsolicited MADs, otherwise it should be 0.
  168. * @mgmt_class_version - Indicates which version of MADs for the given
  169. * management class to receive.
  170. * @oui: Indicates IEEE OUI when mgmt_class is a vendor class
  171. * in the range from 0x30 to 0x4f. Otherwise not used.
  172. * @rmpp_version: If set, indicates the RMPP version used.
  173. *
  174. */
  175. struct ib_user_mad_reg_req {
  176. __u32 id;
  177. packed_ulong method_mask[IB_USER_MAD_LONGS_PER_METHOD_MASK];
  178. __u8 qpn;
  179. __u8 mgmt_class;
  180. __u8 mgmt_class_version;
  181. __u8 oui[3];
  182. __u8 rmpp_version;
  183. };
  184. /**
  185. * ib_user_mad_reg_req2 - MAD registration request
  186. *
  187. * @id - Set by the _kernel_; used by userspace to identify the
  188. * registered agent in future requests.
  189. * @qpn - Queue pair number; must be 0 or 1.
  190. * @mgmt_class - Indicates which management class of MADs should be
  191. * receive by the caller. This field is only required if
  192. * the user wishes to receive unsolicited MADs, otherwise
  193. * it should be 0.
  194. * @mgmt_class_version - Indicates which version of MADs for the given
  195. * management class to receive.
  196. * @res - Ignored.
  197. * @flags - additional registration flags; Must be in the set of
  198. * flags defined in IB_USER_MAD_REG_FLAGS_CAP
  199. * @method_mask - The caller wishes to receive unsolicited MADs for the
  200. * methods whose bit(s) is(are) set.
  201. * @oui - Indicates IEEE OUI to use when mgmt_class is a vendor
  202. * class in the range from 0x30 to 0x4f. Otherwise not
  203. * used.
  204. * @rmpp_version - If set, indicates the RMPP version to use.
  205. */
  206. enum {
  207. IB_USER_MAD_USER_RMPP = (1 << 0),
  208. };
  209. #define IB_USER_MAD_REG_FLAGS_CAP (IB_USER_MAD_USER_RMPP)
  210. struct ib_user_mad_reg_req2 {
  211. __u32 id;
  212. __u32 qpn;
  213. __u8 mgmt_class;
  214. __u8 mgmt_class_version;
  215. __u16 res;
  216. __u32 flags;
  217. __u64 method_mask[2];
  218. __u32 oui;
  219. __u8 rmpp_version;
  220. __u8 reserved[3];
  221. };
  222. #define IB_IOCTL_MAGIC 0x1b
  223. #define IB_USER_MAD_REGISTER_AGENT _IOWR(IB_IOCTL_MAGIC, 1, \
  224. struct ib_user_mad_reg_req)
  225. #define IB_USER_MAD_UNREGISTER_AGENT _IOW(IB_IOCTL_MAGIC, 2, __u32)
  226. #define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3)
  227. #define IB_USER_MAD_REGISTER_AGENT2 _IOWR(IB_IOCTL_MAGIC, 4, \
  228. struct ib_user_mad_reg_req2)
  229. #endif /* IB_USER_MAD_H */