diff options
Diffstat (limited to 'drivers/infiniband/include/ib_mad.h')
| -rw-r--r-- | drivers/infiniband/include/ib_mad.h | 213 |
1 files changed, 193 insertions, 20 deletions
diff --git a/drivers/infiniband/include/ib_mad.h b/drivers/infiniband/include/ib_mad.h index 4a6bf6763a97..491b6f25b3b8 100644 --- a/drivers/infiniband/include/ib_mad.h +++ b/drivers/infiniband/include/ib_mad.h | |||
| @@ -33,12 +33,14 @@ | |||
| 33 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | 33 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 34 | * SOFTWARE. | 34 | * SOFTWARE. |
| 35 | * | 35 | * |
| 36 | * $Id: ib_mad.h 1389 2004-12-27 22:56:47Z roland $ | 36 | * $Id: ib_mad.h 2775 2005-07-02 13:42:12Z halr $ |
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | #if !defined( IB_MAD_H ) | 39 | #if !defined( IB_MAD_H ) |
| 40 | #define IB_MAD_H | 40 | #define IB_MAD_H |
| 41 | 41 | ||
| 42 | #include <linux/pci.h> | ||
| 43 | |||
| 42 | #include <ib_verbs.h> | 44 | #include <ib_verbs.h> |
| 43 | 45 | ||
| 44 | /* Management base version */ | 46 | /* Management base version */ |
| @@ -56,6 +58,8 @@ | |||
| 56 | #define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30 | 58 | #define IB_MGMT_CLASS_VENDOR_RANGE2_START 0x30 |
| 57 | #define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F | 59 | #define IB_MGMT_CLASS_VENDOR_RANGE2_END 0x4F |
| 58 | 60 | ||
| 61 | #define IB_OPENIB_OUI (0x001405) | ||
| 62 | |||
| 59 | /* Management methods */ | 63 | /* Management methods */ |
| 60 | #define IB_MGMT_METHOD_GET 0x01 | 64 | #define IB_MGMT_METHOD_GET 0x01 |
| 61 | #define IB_MGMT_METHOD_SET 0x02 | 65 | #define IB_MGMT_METHOD_SET 0x02 |
| @@ -70,18 +74,37 @@ | |||
| 70 | 74 | ||
| 71 | #define IB_MGMT_MAX_METHODS 128 | 75 | #define IB_MGMT_MAX_METHODS 128 |
| 72 | 76 | ||
| 77 | /* RMPP information */ | ||
| 78 | #define IB_MGMT_RMPP_VERSION 1 | ||
| 79 | |||
| 80 | #define IB_MGMT_RMPP_TYPE_DATA 1 | ||
| 81 | #define IB_MGMT_RMPP_TYPE_ACK 2 | ||
| 82 | #define IB_MGMT_RMPP_TYPE_STOP 3 | ||
| 83 | #define IB_MGMT_RMPP_TYPE_ABORT 4 | ||
| 84 | |||
| 85 | #define IB_MGMT_RMPP_FLAG_ACTIVE 1 | ||
| 86 | #define IB_MGMT_RMPP_FLAG_FIRST (1<<1) | ||
| 87 | #define IB_MGMT_RMPP_FLAG_LAST (1<<2) | ||
| 88 | |||
| 89 | #define IB_MGMT_RMPP_NO_RESPTIME 0x1F | ||
| 90 | |||
| 91 | #define IB_MGMT_RMPP_STATUS_SUCCESS 0 | ||
| 92 | #define IB_MGMT_RMPP_STATUS_RESX 1 | ||
| 93 | #define IB_MGMT_RMPP_STATUS_T2L 118 | ||
| 94 | #define IB_MGMT_RMPP_STATUS_BAD_LEN 119 | ||
| 95 | #define IB_MGMT_RMPP_STATUS_BAD_SEG 120 | ||
| 96 | #define IB_MGMT_RMPP_STATUS_BADT 121 | ||
| 97 | #define IB_MGMT_RMPP_STATUS_W2S 122 | ||
| 98 | #define IB_MGMT_RMPP_STATUS_S2B 123 | ||
| 99 | #define IB_MGMT_RMPP_STATUS_BAD_STATUS 124 | ||
| 100 | #define IB_MGMT_RMPP_STATUS_UNV 125 | ||
| 101 | #define IB_MGMT_RMPP_STATUS_TMR 126 | ||
| 102 | #define IB_MGMT_RMPP_STATUS_UNSPEC 127 | ||
| 103 | |||
| 73 | #define IB_QP0 0 | 104 | #define IB_QP0 0 |
| 74 | #define IB_QP1 __constant_htonl(1) | 105 | #define IB_QP1 __constant_htonl(1) |
| 75 | #define IB_QP1_QKEY 0x80010000 | 106 | #define IB_QP1_QKEY 0x80010000 |
| 76 | 107 | #define IB_QP_SET_QKEY 0x80000000 | |
| 77 | struct ib_grh { | ||
| 78 | u32 version_tclass_flow; | ||
| 79 | u16 paylen; | ||
| 80 | u8 next_hdr; | ||
| 81 | u8 hop_limit; | ||
| 82 | union ib_gid sgid; | ||
| 83 | union ib_gid dgid; | ||
| 84 | } __attribute__ ((packed)); | ||
| 85 | 108 | ||
| 86 | struct ib_mad_hdr { | 109 | struct ib_mad_hdr { |
| 87 | u8 base_version; | 110 | u8 base_version; |
| @@ -94,7 +117,7 @@ struct ib_mad_hdr { | |||
| 94 | u16 attr_id; | 117 | u16 attr_id; |
| 95 | u16 resv; | 118 | u16 resv; |
| 96 | u32 attr_mod; | 119 | u32 attr_mod; |
| 97 | } __attribute__ ((packed)); | 120 | }; |
| 98 | 121 | ||
| 99 | struct ib_rmpp_hdr { | 122 | struct ib_rmpp_hdr { |
| 100 | u8 rmpp_version; | 123 | u8 rmpp_version; |
| @@ -103,17 +126,41 @@ struct ib_rmpp_hdr { | |||
| 103 | u8 rmpp_status; | 126 | u8 rmpp_status; |
| 104 | u32 seg_num; | 127 | u32 seg_num; |
| 105 | u32 paylen_newwin; | 128 | u32 paylen_newwin; |
| 129 | }; | ||
| 130 | |||
| 131 | typedef u64 __bitwise ib_sa_comp_mask; | ||
| 132 | |||
| 133 | #define IB_SA_COMP_MASK(n) ((__force ib_sa_comp_mask) cpu_to_be64(1ull << n)) | ||
| 134 | |||
| 135 | /* | ||
| 136 | * ib_sa_hdr and ib_sa_mad structures must be packed because they have | ||
| 137 | * 64-bit fields that are only 32-bit aligned. 64-bit architectures will | ||
| 138 | * lay them out wrong otherwise. (And unfortunately they are sent on | ||
| 139 | * the wire so we can't change the layout) | ||
| 140 | */ | ||
| 141 | struct ib_sa_hdr { | ||
| 142 | u64 sm_key; | ||
| 143 | u16 attr_offset; | ||
| 144 | u16 reserved; | ||
| 145 | ib_sa_comp_mask comp_mask; | ||
| 106 | } __attribute__ ((packed)); | 146 | } __attribute__ ((packed)); |
| 107 | 147 | ||
| 108 | struct ib_mad { | 148 | struct ib_mad { |
| 109 | struct ib_mad_hdr mad_hdr; | 149 | struct ib_mad_hdr mad_hdr; |
| 110 | u8 data[232]; | 150 | u8 data[232]; |
| 111 | } __attribute__ ((packed)); | 151 | }; |
| 112 | 152 | ||
| 113 | struct ib_rmpp_mad { | 153 | struct ib_rmpp_mad { |
| 114 | struct ib_mad_hdr mad_hdr; | 154 | struct ib_mad_hdr mad_hdr; |
| 115 | struct ib_rmpp_hdr rmpp_hdr; | 155 | struct ib_rmpp_hdr rmpp_hdr; |
| 116 | u8 data[220]; | 156 | u8 data[220]; |
| 157 | }; | ||
| 158 | |||
| 159 | struct ib_sa_mad { | ||
| 160 | struct ib_mad_hdr mad_hdr; | ||
| 161 | struct ib_rmpp_hdr rmpp_hdr; | ||
| 162 | struct ib_sa_hdr sa_hdr; | ||
| 163 | u8 data[200]; | ||
| 117 | } __attribute__ ((packed)); | 164 | } __attribute__ ((packed)); |
| 118 | 165 | ||
| 119 | struct ib_vendor_mad { | 166 | struct ib_vendor_mad { |
| @@ -122,7 +169,70 @@ struct ib_vendor_mad { | |||
| 122 | u8 reserved; | 169 | u8 reserved; |
| 123 | u8 oui[3]; | 170 | u8 oui[3]; |
| 124 | u8 data[216]; | 171 | u8 data[216]; |
| 125 | } __attribute__ ((packed)); | 172 | }; |
| 173 | |||
| 174 | /** | ||
| 175 | * ib_mad_send_buf - MAD data buffer and work request for sends. | ||
| 176 | * @mad: References an allocated MAD data buffer. The size of the data | ||
| 177 | * buffer is specified in the @send_wr.length field. | ||
| 178 | * @mapping: DMA mapping information. | ||
| 179 | * @mad_agent: MAD agent that allocated the buffer. | ||
| 180 | * @context: User-controlled context fields. | ||
| 181 | * @send_wr: An initialized work request structure used when sending the MAD. | ||
| 182 | * The wr_id field of the work request is initialized to reference this | ||
| 183 | * data structure. | ||
| 184 | * @sge: A scatter-gather list referenced by the work request. | ||
| 185 | * | ||
| 186 | * Users are responsible for initializing the MAD buffer itself, with the | ||
| 187 | * exception of specifying the payload length field in any RMPP MAD. | ||
| 188 | */ | ||
| 189 | struct ib_mad_send_buf { | ||
| 190 | struct ib_mad *mad; | ||
| 191 | DECLARE_PCI_UNMAP_ADDR(mapping) | ||
| 192 | struct ib_mad_agent *mad_agent; | ||
| 193 | void *context[2]; | ||
| 194 | struct ib_send_wr send_wr; | ||
| 195 | struct ib_sge sge; | ||
| 196 | }; | ||
| 197 | |||
| 198 | /** | ||
| 199 | * ib_get_rmpp_resptime - Returns the RMPP response time. | ||
| 200 | * @rmpp_hdr: An RMPP header. | ||
| 201 | */ | ||
| 202 | static inline u8 ib_get_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr) | ||
| 203 | { | ||
| 204 | return rmpp_hdr->rmpp_rtime_flags >> 3; | ||
| 205 | } | ||
| 206 | |||
| 207 | /** | ||
| 208 | * ib_get_rmpp_flags - Returns the RMPP flags. | ||
| 209 | * @rmpp_hdr: An RMPP header. | ||
| 210 | */ | ||
| 211 | static inline u8 ib_get_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr) | ||
| 212 | { | ||
| 213 | return rmpp_hdr->rmpp_rtime_flags & 0x7; | ||
| 214 | } | ||
| 215 | |||
| 216 | /** | ||
| 217 | * ib_set_rmpp_resptime - Sets the response time in an RMPP header. | ||
| 218 | * @rmpp_hdr: An RMPP header. | ||
| 219 | * @rtime: The response time to set. | ||
| 220 | */ | ||
| 221 | static inline void ib_set_rmpp_resptime(struct ib_rmpp_hdr *rmpp_hdr, u8 rtime) | ||
| 222 | { | ||
| 223 | rmpp_hdr->rmpp_rtime_flags = ib_get_rmpp_flags(rmpp_hdr) | (rtime << 3); | ||
| 224 | } | ||
| 225 | |||
| 226 | /** | ||
| 227 | * ib_set_rmpp_flags - Sets the flags in an RMPP header. | ||
| 228 | * @rmpp_hdr: An RMPP header. | ||
| 229 | * @flags: The flags to set. | ||
| 230 | */ | ||
| 231 | static inline void ib_set_rmpp_flags(struct ib_rmpp_hdr *rmpp_hdr, u8 flags) | ||
| 232 | { | ||
| 233 | rmpp_hdr->rmpp_rtime_flags = (rmpp_hdr->rmpp_rtime_flags & 0xF1) | | ||
| 234 | (flags & 0x7); | ||
| 235 | } | ||
| 126 | 236 | ||
| 127 | struct ib_mad_agent; | 237 | struct ib_mad_agent; |
| 128 | struct ib_mad_send_wc; | 238 | struct ib_mad_send_wc; |
| @@ -168,6 +278,7 @@ typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent, | |||
| 168 | * ib_mad_agent - Used to track MAD registration with the access layer. | 278 | * ib_mad_agent - Used to track MAD registration with the access layer. |
| 169 | * @device: Reference to device registration is on. | 279 | * @device: Reference to device registration is on. |
| 170 | * @qp: Reference to QP used for sending and receiving MADs. | 280 | * @qp: Reference to QP used for sending and receiving MADs. |
| 281 | * @mr: Memory region for system memory usable for DMA. | ||
| 171 | * @recv_handler: Callback handler for a received MAD. | 282 | * @recv_handler: Callback handler for a received MAD. |
| 172 | * @send_handler: Callback handler for a sent MAD. | 283 | * @send_handler: Callback handler for a sent MAD. |
| 173 | * @snoop_handler: Callback handler for snooped sent MADs. | 284 | * @snoop_handler: Callback handler for snooped sent MADs. |
| @@ -176,16 +287,19 @@ typedef void (*ib_mad_recv_handler)(struct ib_mad_agent *mad_agent, | |||
| 176 | * Unsolicited MADs sent by this client will have the upper 32-bits | 287 | * Unsolicited MADs sent by this client will have the upper 32-bits |
| 177 | * of their TID set to this value. | 288 | * of their TID set to this value. |
| 178 | * @port_num: Port number on which QP is registered | 289 | * @port_num: Port number on which QP is registered |
| 290 | * @rmpp_version: If set, indicates the RMPP version used by this agent. | ||
| 179 | */ | 291 | */ |
| 180 | struct ib_mad_agent { | 292 | struct ib_mad_agent { |
| 181 | struct ib_device *device; | 293 | struct ib_device *device; |
| 182 | struct ib_qp *qp; | 294 | struct ib_qp *qp; |
| 295 | struct ib_mr *mr; | ||
| 183 | ib_mad_recv_handler recv_handler; | 296 | ib_mad_recv_handler recv_handler; |
| 184 | ib_mad_send_handler send_handler; | 297 | ib_mad_send_handler send_handler; |
| 185 | ib_mad_snoop_handler snoop_handler; | 298 | ib_mad_snoop_handler snoop_handler; |
| 186 | void *context; | 299 | void *context; |
| 187 | u32 hi_tid; | 300 | u32 hi_tid; |
| 188 | u8 port_num; | 301 | u8 port_num; |
| 302 | u8 rmpp_version; | ||
| 189 | }; | 303 | }; |
| 190 | 304 | ||
| 191 | /** | 305 | /** |
| @@ -219,6 +333,7 @@ struct ib_mad_recv_buf { | |||
| 219 | * ib_mad_recv_wc - received MAD information. | 333 | * ib_mad_recv_wc - received MAD information. |
| 220 | * @wc: Completion information for the received data. | 334 | * @wc: Completion information for the received data. |
| 221 | * @recv_buf: Specifies the location of the received data buffer(s). | 335 | * @recv_buf: Specifies the location of the received data buffer(s). |
| 336 | * @rmpp_list: Specifies a list of RMPP reassembled received MAD buffers. | ||
| 222 | * @mad_len: The length of the received MAD, without duplicated headers. | 337 | * @mad_len: The length of the received MAD, without duplicated headers. |
| 223 | * | 338 | * |
| 224 | * For received response, the wr_id field of the wc is set to the wr_id | 339 | * For received response, the wr_id field of the wc is set to the wr_id |
| @@ -227,6 +342,7 @@ struct ib_mad_recv_buf { | |||
| 227 | struct ib_mad_recv_wc { | 342 | struct ib_mad_recv_wc { |
| 228 | struct ib_wc *wc; | 343 | struct ib_wc *wc; |
| 229 | struct ib_mad_recv_buf recv_buf; | 344 | struct ib_mad_recv_buf recv_buf; |
| 345 | struct list_head rmpp_list; | ||
| 230 | int mad_len; | 346 | int mad_len; |
| 231 | }; | 347 | }; |
| 232 | 348 | ||
| @@ -322,6 +438,16 @@ int ib_unregister_mad_agent(struct ib_mad_agent *mad_agent); | |||
| 322 | * @bad_send_wr: Specifies the MAD on which an error was encountered. | 438 | * @bad_send_wr: Specifies the MAD on which an error was encountered. |
| 323 | * | 439 | * |
| 324 | * Sent MADs are not guaranteed to complete in the order that they were posted. | 440 | * Sent MADs are not guaranteed to complete in the order that they were posted. |
| 441 | * | ||
| 442 | * If the MAD requires RMPP, the data buffer should contain a single copy | ||
| 443 | * of the common MAD, RMPP, and class specific headers, followed by the class | ||
| 444 | * defined data. If the class defined data would not divide evenly into | ||
| 445 | * RMPP segments, then space must be allocated at the end of the referenced | ||
| 446 | * buffer for any required padding. To indicate the amount of class defined | ||
| 447 | * data being transferred, the paylen_newwin field in the RMPP header should | ||
| 448 | * be set to the size of the class specific header plus the amount of class | ||
| 449 | * defined data being transferred. The paylen_newwin field should be | ||
| 450 | * specified in network-byte order. | ||
| 325 | */ | 451 | */ |
| 326 | int ib_post_send_mad(struct ib_mad_agent *mad_agent, | 452 | int ib_post_send_mad(struct ib_mad_agent *mad_agent, |
| 327 | struct ib_send_wr *send_wr, | 453 | struct ib_send_wr *send_wr, |
| @@ -334,15 +460,13 @@ int ib_post_send_mad(struct ib_mad_agent *mad_agent, | |||
| 334 | * referenced buffer should be at least the size of the mad_len specified | 460 | * referenced buffer should be at least the size of the mad_len specified |
| 335 | * by @mad_recv_wc. | 461 | * by @mad_recv_wc. |
| 336 | * | 462 | * |
| 337 | * This call copies a chain of received RMPP MADs into a single data buffer, | 463 | * This call copies a chain of received MAD segments into a single data buffer, |
| 338 | * removing duplicated headers. | 464 | * removing duplicated headers. |
| 339 | */ | 465 | */ |
| 340 | void ib_coalesce_recv_mad(struct ib_mad_recv_wc *mad_recv_wc, | 466 | void ib_coalesce_recv_mad(struct ib_mad_recv_wc *mad_recv_wc, void *buf); |
| 341 | void *buf); | ||
| 342 | 467 | ||
| 343 | /** | 468 | /** |
| 344 | * ib_free_recv_mad - Returns data buffers used to receive a MAD to the | 469 | * ib_free_recv_mad - Returns data buffers used to receive a MAD. |
| 345 | * access layer. | ||
| 346 | * @mad_recv_wc: Work completion information for a received MAD. | 470 | * @mad_recv_wc: Work completion information for a received MAD. |
| 347 | * | 471 | * |
| 348 | * Clients receiving MADs through their ib_mad_recv_handler must call this | 472 | * Clients receiving MADs through their ib_mad_recv_handler must call this |
| @@ -358,8 +482,18 @@ void ib_free_recv_mad(struct ib_mad_recv_wc *mad_recv_wc); | |||
| 358 | * MADs will be returned to the user through the corresponding | 482 | * MADs will be returned to the user through the corresponding |
| 359 | * ib_mad_send_handler. | 483 | * ib_mad_send_handler. |
| 360 | */ | 484 | */ |
| 361 | void ib_cancel_mad(struct ib_mad_agent *mad_agent, | 485 | void ib_cancel_mad(struct ib_mad_agent *mad_agent, u64 wr_id); |
| 362 | u64 wr_id); | 486 | |
| 487 | /** | ||
| 488 | * ib_modify_mad - Modifies an outstanding send MAD operation. | ||
| 489 | * @mad_agent: Specifies the registration associated with sent MAD. | ||
| 490 | * @wr_id: Indicates the work request identifier of the MAD to modify. | ||
| 491 | * @timeout_ms: New timeout value for sent MAD. | ||
| 492 | * | ||
| 493 | * This call will reset the timeout value for a sent MAD to the specified | ||
| 494 | * value. | ||
| 495 | */ | ||
| 496 | int ib_modify_mad(struct ib_mad_agent *mad_agent, u64 wr_id, u32 timeout_ms); | ||
| 363 | 497 | ||
| 364 | /** | 498 | /** |
| 365 | * ib_redirect_mad_qp - Registers a QP for MAD services. | 499 | * ib_redirect_mad_qp - Registers a QP for MAD services. |
| @@ -401,4 +535,43 @@ struct ib_mad_agent *ib_redirect_mad_qp(struct ib_qp *qp, | |||
| 401 | int ib_process_mad_wc(struct ib_mad_agent *mad_agent, | 535 | int ib_process_mad_wc(struct ib_mad_agent *mad_agent, |
| 402 | struct ib_wc *wc); | 536 | struct ib_wc *wc); |
| 403 | 537 | ||
| 538 | /** | ||
| 539 | * ib_create_send_mad - Allocate and initialize a data buffer and work request | ||
| 540 | * for sending a MAD. | ||
| 541 | * @mad_agent: Specifies the registered MAD service to associate with the MAD. | ||
| 542 | * @remote_qpn: Specifies the QPN of the receiving node. | ||
| 543 | * @pkey_index: Specifies which PKey the MAD will be sent using. This field | ||
| 544 | * is valid only if the remote_qpn is QP 1. | ||
| 545 | * @ah: References the address handle used to transfer to the remote node. | ||
| 546 | * @rmpp_active: Indicates if the send will enable RMPP. | ||
| 547 | * @hdr_len: Indicates the size of the data header of the MAD. This length | ||
| 548 | * should include the common MAD header, RMPP header, plus any class | ||
| 549 | * specific header. | ||
| 550 | * @data_len: Indicates the size of any user-transferred data. The call will | ||
| 551 | * automatically adjust the allocated buffer size to account for any | ||
| 552 | * additional padding that may be necessary. | ||
| 553 | * @gfp_mask: GFP mask used for the memory allocation. | ||
| 554 | * | ||
| 555 | * This is a helper routine that may be used to allocate a MAD. Users are | ||
| 556 | * not required to allocate outbound MADs using this call. The returned | ||
| 557 | * MAD send buffer will reference a data buffer usable for sending a MAD, along | ||
| 558 | * with an initialized work request structure. Users may modify the returned | ||
| 559 | * MAD data buffer or work request before posting the send. | ||
| 560 | * | ||
| 561 | * The returned data buffer will be cleared. Users are responsible for | ||
| 562 | * initializing the common MAD and any class specific headers. If @rmpp_active | ||
| 563 | * is set, the RMPP header will be initialized for sending. | ||
| 564 | */ | ||
| 565 | struct ib_mad_send_buf * ib_create_send_mad(struct ib_mad_agent *mad_agent, | ||
| 566 | u32 remote_qpn, u16 pkey_index, | ||
| 567 | struct ib_ah *ah, int rmpp_active, | ||
| 568 | int hdr_len, int data_len, | ||
| 569 | unsigned int __nocast gfp_mask); | ||
| 570 | |||
| 571 | /** | ||
| 572 | * ib_free_send_mad - Returns data buffers used to send a MAD. | ||
| 573 | * @send_buf: Previously allocated send data buffer. | ||
| 574 | */ | ||
| 575 | void ib_free_send_mad(struct ib_mad_send_buf *send_buf); | ||
| 576 | |||
| 404 | #endif /* IB_MAD_H */ | 577 | #endif /* IB_MAD_H */ |
