blob: 09558999ca1dd0078c1b4f745b615f4e41704f9c [file] [log] [blame]
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -04001/*
2 *
3 * This file is provided under a dual BSD/GPLv2 license. When using or
4 * redistributing this file, you may do so under either license.
5 *
6 * GPL LICENSE SUMMARY
7 *
8 * Copyright(c) 2015 Intel Corporation.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public License as
12 * published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * BSD LICENSE
20 *
21 * Copyright(c) 2015 Intel Corporation.
22 *
23 * Redistribution and use in source and binary forms, with or without
24 * modification, are permitted provided that the following conditions
25 * are met:
26 *
27 * - Redistributions of source code must retain the above copyright
28 * notice, this list of conditions and the following disclaimer.
29 * - Redistributions in binary form must reproduce the above copyright
30 * notice, this list of conditions and the following disclaimer in
31 * the documentation and/or other materials provided with the
32 * distribution.
33 * - Neither the name of Intel Corporation nor the names of its
34 * contributors may be used to endorse or promote products derived
35 * from this software without specific prior written permission.
36 *
37 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
38 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
39 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
40 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
41 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
45 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
46 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
47 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48 *
49 */
50
51/*
52 * This file contains defines, structures, etc. that are used
53 * to communicate between kernel and user code.
54 */
55
56#ifndef _LINUX__HFI1_USER_H
57#define _LINUX__HFI1_USER_H
58
59#include <linux/types.h>
60
61/*
62 * This version number is given to the driver by the user code during
63 * initialization in the spu_userversion field of hfi1_user_info, so
64 * the driver can check for compatibility with user code.
65 *
66 * The major version changes when data structures change in an incompatible
67 * way. The driver must be the same for initialization to succeed.
68 */
Mitko Haralanov0b091fb2016-02-05 11:57:58 -050069#define HFI1_USER_SWMAJOR 5
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -040070
71/*
72 * Minor version differences are always compatible
73 * a within a major version, however if user software is larger
74 * than driver software, some new features and/or structure fields
75 * may not be implemented; the user code must deal with this if it
76 * cares, or it must abort after initialization reports the difference.
77 */
Dennis Dalessandro0eb62652016-05-19 05:25:50 -070078#define HFI1_USER_SWMINOR 1
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -040079
80/*
81 * Set of HW and driver capability/feature bits.
82 * These bit values are used to configure enabled/disabled HW and
83 * driver features. The same set of bits are communicated to user
84 * space.
85 */
86#define HFI1_CAP_DMA_RTAIL (1UL << 0) /* Use DMA'ed RTail value */
87#define HFI1_CAP_SDMA (1UL << 1) /* Enable SDMA support */
88#define HFI1_CAP_SDMA_AHG (1UL << 2) /* Enable SDMA AHG support */
89#define HFI1_CAP_EXTENDED_PSN (1UL << 3) /* Enable Extended PSN support */
90#define HFI1_CAP_HDRSUPP (1UL << 4) /* Enable Header Suppression */
Easwar Hariharan3c2f85b2015-10-26 10:28:31 -040091/* 1UL << 5 unused */
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -040092#define HFI1_CAP_USE_SDMA_HEAD (1UL << 6) /* DMA Hdr Q tail vs. use CSR */
93#define HFI1_CAP_MULTI_PKT_EGR (1UL << 7) /* Enable multi-packet Egr buffs*/
94#define HFI1_CAP_NODROP_RHQ_FULL (1UL << 8) /* Don't drop on Hdr Q full */
95#define HFI1_CAP_NODROP_EGR_FULL (1UL << 9) /* Don't drop on EGR buffs full */
Mitko Haralanov462075a2016-02-05 11:57:47 -050096#define HFI1_CAP_TID_UNMAP (1UL << 10) /* Disable Expected TID caching */
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -040097#define HFI1_CAP_PRINT_UNIMPL (1UL << 11) /* Show for unimplemented feats */
98#define HFI1_CAP_ALLOW_PERM_JKEY (1UL << 12) /* Allow use of permissive JKEY */
99#define HFI1_CAP_NO_INTEGRITY (1UL << 13) /* Enable ctxt integrity checks */
100#define HFI1_CAP_PKEY_CHECK (1UL << 14) /* Enable ctxt PKey checking */
101#define HFI1_CAP_STATIC_RATE_CTRL (1UL << 15) /* Allow PBC.StaticRateControl */
Easwar Hariharan3c2f85b2015-10-26 10:28:31 -0400102/* 1UL << 16 unused */
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -0400103#define HFI1_CAP_SDMA_HEAD_CHECK (1UL << 17) /* SDMA head checking */
104#define HFI1_CAP_EARLY_CREDIT_RETURN (1UL << 18) /* early credit return */
105
106#define HFI1_RCVHDR_ENTSIZE_2 (1UL << 0)
107#define HFI1_RCVHDR_ENTSIZE_16 (1UL << 1)
108#define HFI1_RCVDHR_ENTSIZE_32 (1UL << 2)
109
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -0400110/* User commands. */
111#define HFI1_CMD_ASSIGN_CTXT 1 /* allocate HFI and context */
112#define HFI1_CMD_CTXT_INFO 2 /* find out what resources we got */
113#define HFI1_CMD_USER_INFO 3 /* set up userspace */
114#define HFI1_CMD_TID_UPDATE 4 /* update expected TID entries */
115#define HFI1_CMD_TID_FREE 5 /* free expected TID entries */
116#define HFI1_CMD_CREDIT_UPD 6 /* force an update of PIO credit */
Mitko Haralanov3bd4dce2015-10-30 18:58:41 -0400117#define HFI1_CMD_SDMA_STATUS_UPD 7 /* force update of SDMA status ring */
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -0400118
119#define HFI1_CMD_RECV_CTRL 8 /* control receipt of packets */
120#define HFI1_CMD_POLL_TYPE 9 /* set the kind of polling we want */
121#define HFI1_CMD_ACK_EVENT 10 /* ack & clear user status bits */
Mitko Haralanov3bd4dce2015-10-30 18:58:41 -0400122#define HFI1_CMD_SET_PKEY 11 /* set context's pkey */
123#define HFI1_CMD_CTXT_RESET 12 /* reset context's HW send context */
Mitko Haralanov955ad362016-02-05 11:57:48 -0500124#define HFI1_CMD_TID_INVAL_READ 13 /* read TID cache invalidations */
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -0400125/* separate EPROM commands from normal PSM commands */
126#define HFI1_CMD_EP_INFO 64 /* read EPROM device ID */
127#define HFI1_CMD_EP_ERASE_CHIP 65 /* erase whole EPROM */
Dean Luickcd371e02015-11-16 21:59:35 -0500128/* range 66-74 no longer used */
129#define HFI1_CMD_EP_ERASE_RANGE 75 /* erase EPROM range */
130#define HFI1_CMD_EP_READ_RANGE 76 /* read EPROM range */
131#define HFI1_CMD_EP_WRITE_RANGE 77 /* write EPROM range */
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -0400132
Mitko Haralanov3bd4dce2015-10-30 18:58:41 -0400133#define _HFI1_EVENT_FROZEN_BIT 0
134#define _HFI1_EVENT_LINKDOWN_BIT 1
135#define _HFI1_EVENT_LID_CHANGE_BIT 2
136#define _HFI1_EVENT_LMC_CHANGE_BIT 3
137#define _HFI1_EVENT_SL2VL_CHANGE_BIT 4
Mitko Haralanov955ad362016-02-05 11:57:48 -0500138#define _HFI1_EVENT_TID_MMU_NOTIFY_BIT 5
139#define _HFI1_MAX_EVENT_BIT _HFI1_EVENT_TID_MMU_NOTIFY_BIT
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -0400140
Mitko Haralanov3bd4dce2015-10-30 18:58:41 -0400141#define HFI1_EVENT_FROZEN (1UL << _HFI1_EVENT_FROZEN_BIT)
142#define HFI1_EVENT_LINKDOWN (1UL << _HFI1_EVENT_LINKDOWN_BIT)
143#define HFI1_EVENT_LID_CHANGE (1UL << _HFI1_EVENT_LID_CHANGE_BIT)
144#define HFI1_EVENT_LMC_CHANGE (1UL << _HFI1_EVENT_LMC_CHANGE_BIT)
145#define HFI1_EVENT_SL2VL_CHANGE (1UL << _HFI1_EVENT_SL2VL_CHANGE_BIT)
Mitko Haralanov955ad362016-02-05 11:57:48 -0500146#define HFI1_EVENT_TID_MMU_NOTIFY (1UL << _HFI1_EVENT_TID_MMU_NOTIFY_BIT)
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -0400147
148/*
149 * These are the status bits readable (in ASCII form, 64bit value)
150 * from the "status" sysfs file. For binary compatibility, values
151 * must remain as is; removed states can be reused for different
152 * purposes.
153 */
154#define HFI1_STATUS_INITTED 0x1 /* basic initialization done */
155/* Chip has been found and initialized */
156#define HFI1_STATUS_CHIP_PRESENT 0x20
157/* IB link is at ACTIVE, usable for data traffic */
158#define HFI1_STATUS_IB_READY 0x40
159/* link is configured, LID, MTU, etc. have been set */
160#define HFI1_STATUS_IB_CONF 0x80
161/* A Fatal hardware error has occurred. */
162#define HFI1_STATUS_HWERROR 0x200
163
164/*
165 * Number of supported shared contexts.
166 * This is the maximum number of software contexts that can share
167 * a hardware send/receive context.
168 */
169#define HFI1_MAX_SHARED_CTXTS 8
170
171/*
172 * Poll types
173 */
174#define HFI1_POLL_TYPE_ANYRCV 0x0
175#define HFI1_POLL_TYPE_URGENT 0x1
176
177/*
178 * This structure is passed to the driver to tell it where
179 * user code buffers are, sizes, etc. The offsets and sizes of the
180 * fields must remain unchanged, for binary compatibility. It can
181 * be extended, if userversion is changed so user code can tell, if needed
182 */
183struct hfi1_user_info {
184 /*
185 * version of user software, to detect compatibility issues.
186 * Should be set to HFI1_USER_SWVERSION.
187 */
188 __u32 userversion;
Dennis Dalessandro0eb62652016-05-19 05:25:50 -0700189 __u32 pad;
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -0400190 /*
191 * If two or more processes wish to share a context, each process
192 * must set the subcontext_cnt and subcontext_id to the same
193 * values. The only restriction on the subcontext_id is that
194 * it be unique for a given node.
195 */
196 __u16 subctxt_cnt;
197 __u16 subctxt_id;
198 /* 128bit UUID passed in by PSM. */
199 __u8 uuid[16];
200};
201
202struct hfi1_ctxt_info {
203 __u64 runtime_flags; /* chip/drv runtime flags (HFI1_CAP_*) */
204 __u32 rcvegr_size; /* size of each eager buffer */
205 __u16 num_active; /* number of active units */
206 __u16 unit; /* unit (chip) assigned to caller */
207 __u16 ctxt; /* ctxt on unit assigned to caller */
208 __u16 subctxt; /* subctxt on unit assigned to caller */
209 __u16 rcvtids; /* number of Rcv TIDs for this context */
210 __u16 credits; /* number of PIO credits for this context */
211 __u16 numa_node; /* NUMA node of the assigned device */
212 __u16 rec_cpu; /* cpu # for affinity (0xffff if none) */
213 __u16 send_ctxt; /* send context in use by this user context */
214 __u16 egrtids; /* number of RcvArray entries for Eager Rcvs */
215 __u16 rcvhdrq_cnt; /* number of RcvHdrQ entries */
216 __u16 rcvhdrq_entsize; /* size (in bytes) for each RcvHdrQ entry */
217 __u16 sdma_ring_size; /* number of entries in SDMA request ring */
218};
219
220struct hfi1_tid_info {
221 /* virtual address of first page in transfer */
222 __u64 vaddr;
223 /* pointer to tid array. this array is big enough */
224 __u64 tidlist;
225 /* number of tids programmed by this request */
226 __u32 tidcnt;
227 /* length of transfer buffer programmed by this request */
228 __u32 length;
Dennis Dalessandrod4ab3472015-07-30 15:17:32 -0400229};
230
231struct hfi1_cmd {
232 __u32 type; /* command type */
233 __u32 len; /* length of struct pointed to by add */
234 __u64 addr; /* pointer to user structure */
235};
236
237enum hfi1_sdma_comp_state {
238 FREE = 0,
239 QUEUED,
240 COMPLETE,
241 ERROR
242};
243
244/*
245 * SDMA completion ring entry
246 */
247struct hfi1_sdma_comp_entry {
248 __u32 status;
249 __u32 errcode;
250};
251
252/*
253 * Device status and notifications from driver to user-space.
254 */
255struct hfi1_status {
256 __u64 dev; /* device/hw status bits */
257 __u64 port; /* port state and status bits */
258 char freezemsg[0];
259};
260
261/*
262 * This structure is returned by the driver immediately after
263 * open to get implementation-specific info, and info specific to this
264 * instance.
265 *
266 * This struct must have explicit pad fields where type sizes
267 * may result in different alignments between 32 and 64 bit
268 * programs, since the 64 bit * bit kernel requires the user code
269 * to have matching offsets
270 */
271struct hfi1_base_info {
272 /* version of hardware, for feature checking. */
273 __u32 hw_version;
274 /* version of software, for feature checking. */
275 __u32 sw_version;
276 /* Job key */
277 __u16 jkey;
278 __u16 padding1;
279 /*
280 * The special QP (queue pair) value that identifies PSM
281 * protocol packet from standard IB packets.
282 */
283 __u32 bthqp;
284 /* PIO credit return address, */
285 __u64 sc_credits_addr;
286 /*
287 * Base address of write-only pio buffers for this process.
288 * Each buffer has sendpio_credits*64 bytes.
289 */
290 __u64 pio_bufbase_sop;
291 /*
292 * Base address of write-only pio buffers for this process.
293 * Each buffer has sendpio_credits*64 bytes.
294 */
295 __u64 pio_bufbase;
296 /* address where receive buffer queue is mapped into */
297 __u64 rcvhdr_bufbase;
298 /* base address of Eager receive buffers. */
299 __u64 rcvegr_bufbase;
300 /* base address of SDMA completion ring */
301 __u64 sdma_comp_bufbase;
302 /*
303 * User register base for init code, not to be used directly by
304 * protocol or applications. Always maps real chip register space.
305 * the register addresses are:
306 * ur_rcvhdrhead, ur_rcvhdrtail, ur_rcvegrhead, ur_rcvegrtail,
307 * ur_rcvtidflow
308 */
309 __u64 user_regbase;
310 /* notification events */
311 __u64 events_bufbase;
312 /* status page */
313 __u64 status_bufbase;
314 /* rcvhdrtail update */
315 __u64 rcvhdrtail_base;
316 /*
317 * shared memory pages for subctxts if ctxt is shared; these cover
318 * all the processes in the group sharing a single context.
319 * all have enough space for the num_subcontexts value on this job.
320 */
321 __u64 subctxt_uregbase;
322 __u64 subctxt_rcvegrbuf;
323 __u64 subctxt_rcvhdrbuf;
324};
325
326enum sdma_req_opcode {
327 EXPECTED = 0,
328 EAGER
329};
330
331#define HFI1_SDMA_REQ_VERSION_MASK 0xF
332#define HFI1_SDMA_REQ_VERSION_SHIFT 0x0
333#define HFI1_SDMA_REQ_OPCODE_MASK 0xF
334#define HFI1_SDMA_REQ_OPCODE_SHIFT 0x4
335#define HFI1_SDMA_REQ_IOVCNT_MASK 0xFF
336#define HFI1_SDMA_REQ_IOVCNT_SHIFT 0x8
337
338struct sdma_req_info {
339 /*
340 * bits 0-3 - version (currently unused)
341 * bits 4-7 - opcode (enum sdma_req_opcode)
342 * bits 8-15 - io vector count
343 */
344 __u16 ctrl;
345 /*
346 * Number of fragments contained in this request.
347 * User-space has already computed how many
348 * fragment-sized packet the user buffer will be
349 * split into.
350 */
351 __u16 npkts;
352 /*
353 * Size of each fragment the user buffer will be
354 * split into.
355 */
356 __u16 fragsize;
357 /*
358 * Index of the slot in the SDMA completion ring
359 * this request should be using. User-space is
360 * in charge of managing its own ring.
361 */
362 __u16 comp_idx;
363} __packed;
364
365/*
366 * SW KDETH header.
367 * swdata is SW defined portion.
368 */
369struct hfi1_kdeth_header {
370 __le32 ver_tid_offset;
371 __le16 jkey;
372 __le16 hcrc;
373 __le32 swdata[7];
374} __packed;
375
376/*
377 * Structure describing the headers that User space uses. The
378 * structure above is a subset of this one.
379 */
380struct hfi1_pkt_header {
381 __le16 pbc[4];
382 __be16 lrh[4];
383 __be32 bth[3];
384 struct hfi1_kdeth_header kdeth;
385} __packed;
386
387
388/*
389 * The list of usermode accessible registers.
390 */
391enum hfi1_ureg {
392 /* (RO) DMA RcvHdr to be used next. */
393 ur_rcvhdrtail = 0,
394 /* (RW) RcvHdr entry to be processed next by host. */
395 ur_rcvhdrhead = 1,
396 /* (RO) Index of next Eager index to use. */
397 ur_rcvegrindextail = 2,
398 /* (RW) Eager TID to be processed next */
399 ur_rcvegrindexhead = 3,
400 /* (RO) Receive Eager Offset Tail */
401 ur_rcvegroffsettail = 4,
402 /* For internal use only; max register number. */
403 ur_maxreg,
404 /* (RW) Receive TID flow table */
405 ur_rcvtidflowtable = 256
406};
407
408#endif /* _LINIUX__HFI1_USER_H */