]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.h
Update mlx4ib(4) to Linux 4.9.
[FreeBSD/FreeBSD.git] / sys / ofed / drivers / infiniband / hw / mthca / mthca_cmd.h
1 /*
2  * Copyright (c) 2004, 2005 Topspin Communications.  All rights reserved.
3  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
4  * Copyright (c) 2006 Cisco Systems.  All rights reserved.
5  *
6  * This software is available to you under a choice of one of two
7  * licenses.  You may choose to be licensed under the terms of the GNU
8  * General Public License (GPL) Version 2, available from the file
9  * COPYING in the main directory of this source tree, or the
10  * OpenIB.org BSD license below:
11  *
12  *     Redistribution and use in source and binary forms, with or
13  *     without modification, are permitted provided that the following
14  *     conditions are met:
15  *
16  *      - Redistributions of source code must retain the above
17  *        copyright notice, this list of conditions and the following
18  *        disclaimer.
19  *
20  *      - Redistributions in binary form must reproduce the above
21  *        copyright notice, this list of conditions and the following
22  *        disclaimer in the documentation and/or other materials
23  *        provided with the distribution.
24  *
25  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32  * SOFTWARE.
33  */
34
35 #ifndef MTHCA_CMD_H
36 #define MTHCA_CMD_H
37
38 #include <rdma/ib_verbs.h>
39
40 #define MTHCA_MAILBOX_SIZE 4096
41
42 enum {
43         /* command completed successfully: */
44         MTHCA_CMD_STAT_OK             = 0x00,
45         /* Internal error (such as a bus error) occurred while processing command: */
46         MTHCA_CMD_STAT_INTERNAL_ERR   = 0x01,
47         /* Operation/command not supported or opcode modifier not supported: */
48         MTHCA_CMD_STAT_BAD_OP         = 0x02,
49         /* Parameter not supported or parameter out of range: */
50         MTHCA_CMD_STAT_BAD_PARAM      = 0x03,
51         /* System not enabled or bad system state: */
52         MTHCA_CMD_STAT_BAD_SYS_STATE  = 0x04,
53         /* Attempt to access reserved or unallocaterd resource: */
54         MTHCA_CMD_STAT_BAD_RESOURCE   = 0x05,
55         /* Requested resource is currently executing a command, or is otherwise busy: */
56         MTHCA_CMD_STAT_RESOURCE_BUSY  = 0x06,
57         /* memory error: */
58         MTHCA_CMD_STAT_DDR_MEM_ERR    = 0x07,
59         /* Required capability exceeds device limits: */
60         MTHCA_CMD_STAT_EXCEED_LIM     = 0x08,
61         /* Resource is not in the appropriate state or ownership: */
62         MTHCA_CMD_STAT_BAD_RES_STATE  = 0x09,
63         /* Index out of range: */
64         MTHCA_CMD_STAT_BAD_INDEX      = 0x0a,
65         /* FW image corrupted: */
66         MTHCA_CMD_STAT_BAD_NVMEM      = 0x0b,
67         /* Attempt to modify a QP/EE which is not in the presumed state: */
68         MTHCA_CMD_STAT_BAD_QPEE_STATE = 0x10,
69         /* Bad segment parameters (Address/Size): */
70         MTHCA_CMD_STAT_BAD_SEG_PARAM  = 0x20,
71         /* Memory Region has Memory Windows bound to: */
72         MTHCA_CMD_STAT_REG_BOUND      = 0x21,
73         /* HCA local attached memory not present: */
74         MTHCA_CMD_STAT_LAM_NOT_PRE    = 0x22,
75         /* Bad management packet (silently discarded): */
76         MTHCA_CMD_STAT_BAD_PKT        = 0x30,
77         /* More outstanding CQEs in CQ than new CQ size: */
78         MTHCA_CMD_STAT_BAD_SIZE       = 0x40
79 };
80
81 enum {
82         MTHCA_TRANS_INVALID = 0,
83         MTHCA_TRANS_RST2INIT,
84         MTHCA_TRANS_INIT2INIT,
85         MTHCA_TRANS_INIT2RTR,
86         MTHCA_TRANS_RTR2RTS,
87         MTHCA_TRANS_RTS2RTS,
88         MTHCA_TRANS_SQERR2RTS,
89         MTHCA_TRANS_ANY2ERR,
90         MTHCA_TRANS_RTS2SQD,
91         MTHCA_TRANS_SQD2SQD,
92         MTHCA_TRANS_SQD2RTS,
93         MTHCA_TRANS_ANY2RST,
94 };
95
96 enum {
97         DEV_LIM_FLAG_RC                 = 1 << 0,
98         DEV_LIM_FLAG_UC                 = 1 << 1,
99         DEV_LIM_FLAG_UD                 = 1 << 2,
100         DEV_LIM_FLAG_RD                 = 1 << 3,
101         DEV_LIM_FLAG_RAW_IPV6           = 1 << 4,
102         DEV_LIM_FLAG_RAW_ETHER          = 1 << 5,
103         DEV_LIM_FLAG_SRQ                = 1 << 6,
104         DEV_LIM_FLAG_IPOIB_CSUM         = 1 << 7,
105         DEV_LIM_FLAG_BAD_PKEY_CNTR      = 1 << 8,
106         DEV_LIM_FLAG_BAD_QKEY_CNTR      = 1 << 9,
107         DEV_LIM_FLAG_MW                 = 1 << 16,
108         DEV_LIM_FLAG_AUTO_PATH_MIG      = 1 << 17,
109         DEV_LIM_FLAG_ATOMIC             = 1 << 18,
110         DEV_LIM_FLAG_RAW_MULTI          = 1 << 19,
111         DEV_LIM_FLAG_UD_AV_PORT_ENFORCE = 1 << 20,
112         DEV_LIM_FLAG_UD_MULTI           = 1 << 21,
113 };
114
115 enum {
116         DIAG_RPRT_Q_XPRT_CIERR = 2,
117         DIAG_RPRT_QR_XPRT_CIERR = 3,
118         DIAG_RPRT_Q_PERF = 4,
119         DIAG_RPRT_QR_PERF = 5,
120         DIAG_RPRT_Q_MISC = 6,
121         DIAG_RPRT_QR_MISC = 7,
122 };
123
124 struct mthca_mailbox {
125         dma_addr_t dma;
126         void      *buf;
127 };
128
129 struct mthca_dev_lim {
130         int max_srq_sz;
131         int max_qp_sz;
132         int reserved_qps;
133         int max_qps;
134         int reserved_srqs;
135         int max_srqs;
136         int reserved_eecs;
137         int max_eecs;
138         int max_cq_sz;
139         int reserved_cqs;
140         int max_cqs;
141         int max_mpts;
142         int reserved_eqs;
143         int max_eqs;
144         int reserved_mtts;
145         int max_mrw_sz;
146         int reserved_mrws;
147         int max_mtt_seg;
148         int max_requester_per_qp;
149         int max_responder_per_qp;
150         int max_rdma_global;
151         int local_ca_ack_delay;
152         int max_mtu;
153         int max_port_width;
154         int max_vl;
155         int num_ports;
156         int max_gids;
157         u16 stat_rate_support;
158         int max_pkeys;
159         u32 flags;
160         int reserved_uars;
161         int uar_size;
162         int min_page_sz;
163         int max_sg;
164         int max_desc_sz;
165         int max_qp_per_mcg;
166         int reserved_mgms;
167         int max_mcgs;
168         int reserved_pds;
169         int max_pds;
170         int reserved_rdds;
171         int max_rdds;
172         int eec_entry_sz;
173         int qpc_entry_sz;
174         int eeec_entry_sz;
175         int eqpc_entry_sz;
176         int eqc_entry_sz;
177         int cqc_entry_sz;
178         int srq_entry_sz;
179         int uar_scratch_entry_sz;
180         int mpt_entry_sz;
181         union {
182                 struct {
183                         int max_avs;
184                 } tavor;
185                 struct {
186                         int resize_srq;
187                         int max_pbl_sz;
188                         u8  bmme_flags;
189                         u32 reserved_lkey;
190                         int lam_required;
191                         u64 max_icm_sz;
192                 } arbel;
193         } hca;
194 };
195
196 struct mthca_adapter {
197         u32  vendor_id;
198         u32  device_id;
199         u32  revision_id;
200         char board_id[MTHCA_BOARD_ID_LEN];
201         u8   inta_pin;
202 };
203
204 struct mthca_init_hca_param {
205         u64 qpc_base;
206         u64 eec_base;
207         u64 srqc_base;
208         u64 cqc_base;
209         u64 eqpc_base;
210         u64 eeec_base;
211         u64 eqc_base;
212         u64 rdb_base;
213         u64 mc_base;
214         u64 mpt_base;
215         u64 mtt_base;
216         u64 uar_scratch_base;
217         u64 uarc_base;
218         u16 log_mc_entry_sz;
219         u16 mc_hash_sz;
220         u8  log_num_qps;
221         u8  log_num_eecs;
222         u8  log_num_srqs;
223         u8  log_num_cqs;
224         u8  log_num_eqs;
225         u8  log_mc_table_sz;
226         u8  mtt_seg_sz;
227         u8  log_mpt_sz;
228         u8  log_uar_sz;
229         u8  log_uarc_sz;
230 };
231
232 struct mthca_init_ib_param {
233         int port_width;
234         int vl_cap;
235         int mtu_cap;
236         u16 gid_cap;
237         u16 pkey_cap;
238         int set_guid0;
239         u64 guid0;
240         int set_node_guid;
241         u64 node_guid;
242         int set_si_guid;
243         u64 si_guid;
244 };
245
246 struct mthca_set_ib_param {
247         int set_si_guid;
248         int reset_qkey_viol;
249         u64 si_guid;
250         u32 cap_mask;
251 };
252
253 int mthca_cmd_init(struct mthca_dev *dev);
254 void mthca_cmd_cleanup(struct mthca_dev *dev);
255 int mthca_cmd_use_events(struct mthca_dev *dev);
256 void mthca_cmd_use_polling(struct mthca_dev *dev);
257 void mthca_cmd_event(struct mthca_dev *dev, u16 token,
258                      u8  status, u64 out_param);
259
260 struct mthca_mailbox *mthca_alloc_mailbox(struct mthca_dev *dev,
261                                           gfp_t gfp_mask);
262 void mthca_free_mailbox(struct mthca_dev *dev, struct mthca_mailbox *mailbox);
263
264 int mthca_SYS_EN(struct mthca_dev *dev, u8 *status);
265 int mthca_SYS_DIS(struct mthca_dev *dev, u8 *status);
266 int mthca_MAP_FA(struct mthca_dev *dev, struct mthca_icm *icm, u8 *status);
267 int mthca_UNMAP_FA(struct mthca_dev *dev, u8 *status);
268 int mthca_RUN_FW(struct mthca_dev *dev, u8 *status);
269 int mthca_QUERY_FW(struct mthca_dev *dev, u8 *status);
270 int mthca_ENABLE_LAM(struct mthca_dev *dev, u8 *status);
271 int mthca_DISABLE_LAM(struct mthca_dev *dev, u8 *status);
272 int mthca_QUERY_DDR(struct mthca_dev *dev, u8 *status);
273 int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
274                         struct mthca_dev_lim *dev_lim, u8 *status);
275 int mthca_QUERY_ADAPTER(struct mthca_dev *dev,
276                         struct mthca_adapter *adapter, u8 *status);
277 int mthca_INIT_HCA(struct mthca_dev *dev,
278                    struct mthca_init_hca_param *param,
279                    u8 *status);
280 int mthca_INIT_IB(struct mthca_dev *dev,
281                   struct mthca_init_ib_param *param,
282                   int port, u8 *status);
283 int mthca_CLOSE_IB(struct mthca_dev *dev, int port, u8 *status);
284 int mthca_CLOSE_HCA(struct mthca_dev *dev, int panic, u8 *status);
285 int mthca_SET_IB(struct mthca_dev *dev, struct mthca_set_ib_param *param,
286                  int port, u8 *status);
287 int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt, u8 *status);
288 int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt, u8 *status);
289 int mthca_UNMAP_ICM(struct mthca_dev *dev, u64 virt, u32 page_count, u8 *status);
290 int mthca_MAP_ICM_AUX(struct mthca_dev *dev, struct mthca_icm *icm, u8 *status);
291 int mthca_UNMAP_ICM_AUX(struct mthca_dev *dev, u8 *status);
292 int mthca_SET_ICM_SIZE(struct mthca_dev *dev, u64 icm_size, u64 *aux_pages,
293                        u8 *status);
294 int mthca_SW2HW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
295                     int mpt_index, u8 *status);
296 int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
297                     int mpt_index, u8 *status);
298 int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
299                     int num_mtt, u8 *status);
300 int mthca_SYNC_TPT(struct mthca_dev *dev, u8 *status);
301 int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
302                  int eq_num, u8 *status);
303 int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
304                    int eq_num, u8 *status);
305 int mthca_HW2SW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
306                    int eq_num, u8 *status);
307 int mthca_SW2HW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
308                    int cq_num, u8 *status);
309 int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
310                    int cq_num, u8 *status);
311 int mthca_RESIZE_CQ(struct mthca_dev *dev, int cq_num, u32 lkey, u8 log_size,
312                     u8 *status);
313 int mthca_SW2HW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
314                     int srq_num, u8 *status);
315 int mthca_HW2SW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
316                     int srq_num, u8 *status);
317 int mthca_QUERY_SRQ(struct mthca_dev *dev, u32 num,
318                     struct mthca_mailbox *mailbox, u8 *status);
319 int mthca_ARM_SRQ(struct mthca_dev *dev, int srq_num, int limit, u8 *status);
320 int mthca_MODIFY_QP(struct mthca_dev *dev, enum ib_qp_state cur,
321                     enum ib_qp_state next, u32 num, int is_ee,
322                     struct mthca_mailbox *mailbox, u32 optmask,
323                     u8 *status);
324 int mthca_QUERY_QP(struct mthca_dev *dev, u32 num, int is_ee,
325                    struct mthca_mailbox *mailbox, u8 *status);
326 int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn,
327                           u8 *status);
328 int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
329                   int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
330                   void *in_mad, void *response_mad, u8 *status);
331 int mthca_READ_MGM(struct mthca_dev *dev, int index,
332                    struct mthca_mailbox *mailbox, u8 *status);
333 int mthca_WRITE_MGM(struct mthca_dev *dev, int index,
334                     struct mthca_mailbox *mailbox, u8 *status);
335 int mthca_MGID_HASH(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
336                     u16 *hash, u8 *status);
337 int mthca_DIAG_RPRT(struct mthca_dev *dev, int mod,
338                     struct mthca_mailbox *mailbox, u8 *status);
339 int mthca_NOP(struct mthca_dev *dev, u8 *status);
340
341 #endif /* MTHCA_CMD_H */