2 * Copyright (c) 2001-2005 Mellanox Technologies LTD. All rights reserved.
3 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
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:
11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following
15 * - Redistributions of source code must retain the above
16 * copyright notice, this list of conditions and the following
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.
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
37 * Header file for common special QP resources creation code.
41 * Version: osmt_mtl_regular_qp.h,v 1.2 2003/03/20 16:05:10 eitan
54 #include <vapi_common.h>
57 #if defined(MAD_IN) || defined(MAD_OUT)
58 #error MACROS MAD_IN and MAD_OUT are in use, do not override
64 #define HCA_ID "mt21108_pci0"
66 #define KNOWN_QP1_QKEY 0x80010000
68 #define MAX_OUTS_SQ 2 /* Max. buffers posted for requests in SQ */
69 #define MAX_OUTS_RQ 5 /* Max. buffers posted for responses in RQ */
71 #define MAX_POLL_CNT 300
72 #define POLL_SLEEP 1 /* for usleep */
74 #define MAD_SIZE 256 /* MADs are always 256B */
75 #define MAD_ATTR_OFFSET 16
76 #define MAD_TID_OFFSET 8
78 /* Verbs SQP resources handles */
80 VAPI_hca_id_t hca_id; /*id of HCA */
81 u_int8_t port_num; /* the port num to use */
82 VAPI_hca_hndl_t hca_hndl; /*handle of HCA */
83 VAPI_qp_hndl_t qp_hndl; /*handle of QP I use */
84 VAPI_mr_hndl_t mr_hndl; /*handle of memory region */
85 VAPI_cq_hndl_t rq_cq_hndl, sq_cq_hndl; /*handle of send & receive completion Queues */
86 VAPI_pd_hndl_t pd_hndl; /*handle of Partition Domain */
87 /* VAPI_ud_av_hndl_t av_hndl; */
89 /*LID*/ void *buf_ptr; /*mem buffer for outstanding pkts */
90 MT_size_t buf_size; /*size of mem buffer for outstanding pkts */
92 u_int32_t max_outs_sq; /*max # of outstanding pkts in send queue */
93 u_int32_t max_outs_rq; /*max # of outstanding pkts in receive queue */
95 IB_rkey_t l_key; /*my l_key for memory regions */
96 VAPI_qkey_t qkey; /*my qkey */
98 EVAPI_compl_handler_hndl_t rq_cq_eventh, sq_cq_eventh; /* event handlers for polling */
100 bool is_sqp; /* relate to union below - my QP */
102 VAPI_special_qp_t sqp_type;
103 VAPI_qp_num_t qp_num;
106 } osmt_mtl_mad_res_t;
108 /* init an osmt_mtl_mad_res_t with all resources initialized (use functions below) */
109 VAPI_ret_t osmt_mtl_init(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
111 VAPI_ret_t osmt_mtl_init_opened_hca(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
114 /* Cleanup all resources of (which are valid) in res */
115 VAPI_ret_t osmt_mtl_mad_cleanup(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
118 /* create CQs and QP as given in res->is_sqp (if TRUE, get special QP) */
119 VAPI_ret_t osmt_mtl_get_qp_resources(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
122 /* move QP to RTS state */
123 VAPI_ret_t osmt_mtl_mad_qp_init(osmt_mtl_mad_res_t * res /*max number of outstanding packets allowed in send queue */
126 /* create and register res->buf_ptr */
127 VAPI_ret_t osmt_mtl_mad_create_mr(osmt_mtl_mad_res_t * res /*pointer to res (resources) struct */
130 VAPI_ret_t osmt_mtl_create_av(osmt_mtl_mad_res_t * res, /* pointer to res (resources) struct */
131 int16_t dlid, /*destination lid */
132 VAPI_ud_av_hndl_t * avh_p /* address vectr handle to update */
135 /* Send MAD to given dest QP*/
136 VAPI_ret_t osmt_mtl_mad_send(osmt_mtl_mad_res_t * res, /*pointer to res (resources) struct */
137 VAPI_wr_id_t id, /*wqe ID */
138 void *mad, /*mad buffer to send */
139 VAPI_qp_num_t dest_qp, /*destination QP */
140 IB_sl_t sl, /*Service Level */
141 u_int32_t dest_qkey, /*Destination QP KEY */
142 VAPI_ud_av_hndl_t avh /* address vectr handle to use */
145 /* post buffers to RQ. returns num of buffers actually posted */
146 int osmt_mtl_mad_post_recv_bufs(osmt_mtl_mad_res_t * res, /*pointer to res (resources) struct */
147 void *buf_array, /*array of receive buffers */
148 u_int32_t num_o_bufs, /*number of receive buffers */
149 u_int32_t size, /* size of expected receive packet - MAD */
150 VAPI_wr_id_t start_id /* start id for receive buffers */
153 /* Poll given CQ for completion max_poll times (POLL_SLEEP [usec] delays). result in wc_desc_p. */
154 VAPI_ret_t osmt_mtl_mad_poll4cqe(VAPI_hca_hndl_t hca, /*handle for HCA */
155 VAPI_cq_hndl_t cq, /*handle for Completion Queue - Rcv/Send */
156 VAPI_wc_desc_t * wc_desc_p, /*handle of cqe */
157 u_int32_t max_poll, /*number of polling iterations */
158 u_int32_t poll_sleep, /*timeout for each polling */
159 VAPI_ud_av_hndl_t * avh_p /* address vectopr handle to cleanup */