qib_common.h 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812
  1. /*
  2. * Copyright (c) 2006, 2007, 2008, 2009, 2010 QLogic Corporation.
  3. * All rights reserved.
  4. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. 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. #ifndef _QIB_COMMON_H
  35. #define _QIB_COMMON_H
  36. /*
  37. * This file contains defines, structures, etc. that are used
  38. * to communicate between kernel and user code.
  39. */
  40. /* This is the IEEE-assigned OUI for QLogic Inc. QLogic_IB */
  41. #define QIB_SRC_OUI_1 0x00
  42. #define QIB_SRC_OUI_2 0x11
  43. #define QIB_SRC_OUI_3 0x75
  44. /* version of protocol header (known to chip also). In the long run,
  45. * we should be able to generate and accept a range of version numbers;
  46. * for now we only accept one, and it's compiled in.
  47. */
  48. #define IPS_PROTO_VERSION 2
  49. /*
  50. * These are compile time constants that you may want to enable or disable
  51. * if you are trying to debug problems with code or performance.
  52. * QIB_VERBOSE_TRACING define as 1 if you want additional tracing in
  53. * fastpath code
  54. * QIB_TRACE_REGWRITES define as 1 if you want register writes to be
  55. * traced in faspath code
  56. * _QIB_TRACING define as 0 if you want to remove all tracing in a
  57. * compilation unit
  58. */
  59. /*
  60. * The value in the BTH QP field that QLogic_IB uses to differentiate
  61. * an qlogic_ib protocol IB packet vs standard IB transport
  62. * This it needs to be even (0x656b78), because the LSB is sometimes
  63. * used for the MSB of context. The change may cause a problem
  64. * interoperating with older software.
  65. */
  66. #define QIB_KD_QP 0x656b78
  67. /*
  68. * These are the status bits readable (in ascii form, 64bit value)
  69. * from the "status" sysfs file. For binary compatibility, values
  70. * must remain as is; removed states can be reused for different
  71. * purposes.
  72. */
  73. #define QIB_STATUS_INITTED 0x1 /* basic initialization done */
  74. /* Chip has been found and initted */
  75. #define QIB_STATUS_CHIP_PRESENT 0x20
  76. /* IB link is at ACTIVE, usable for data traffic */
  77. #define QIB_STATUS_IB_READY 0x40
  78. /* link is configured, LID, MTU, etc. have been set */
  79. #define QIB_STATUS_IB_CONF 0x80
  80. /* A Fatal hardware error has occurred. */
  81. #define QIB_STATUS_HWERROR 0x200
  82. /*
  83. * The list of usermode accessible registers. Also see Reg_* later in file.
  84. */
  85. enum qib_ureg {
  86. /* (RO) DMA RcvHdr to be used next. */
  87. ur_rcvhdrtail = 0,
  88. /* (RW) RcvHdr entry to be processed next by host. */
  89. ur_rcvhdrhead = 1,
  90. /* (RO) Index of next Eager index to use. */
  91. ur_rcvegrindextail = 2,
  92. /* (RW) Eager TID to be processed next */
  93. ur_rcvegrindexhead = 3,
  94. /* For internal use only; max register number. */
  95. _QIB_UregMax
  96. };
  97. /* bit values for spi_runtime_flags */
  98. #define QIB_RUNTIME_PCIE 0x0002
  99. #define QIB_RUNTIME_FORCE_WC_ORDER 0x0004
  100. #define QIB_RUNTIME_RCVHDR_COPY 0x0008
  101. #define QIB_RUNTIME_MASTER 0x0010
  102. #define QIB_RUNTIME_RCHK 0x0020
  103. #define QIB_RUNTIME_NODMA_RTAIL 0x0080
  104. #define QIB_RUNTIME_SPECIAL_TRIGGER 0x0100
  105. #define QIB_RUNTIME_SDMA 0x0200
  106. #define QIB_RUNTIME_FORCE_PIOAVAIL 0x0400
  107. #define QIB_RUNTIME_PIO_REGSWAPPED 0x0800
  108. #define QIB_RUNTIME_CTXT_MSB_IN_QP 0x1000
  109. #define QIB_RUNTIME_CTXT_REDIRECT 0x2000
  110. #define QIB_RUNTIME_HDRSUPP 0x4000
  111. /*
  112. * This structure is returned by qib_userinit() immediately after
  113. * open to get implementation-specific info, and info specific to this
  114. * instance.
  115. *
  116. * This struct must have explict pad fields where type sizes
  117. * may result in different alignments between 32 and 64 bit
  118. * programs, since the 64 bit * bit kernel requires the user code
  119. * to have matching offsets
  120. */
  121. struct qib_base_info {
  122. /* version of hardware, for feature checking. */
  123. __u32 spi_hw_version;
  124. /* version of software, for feature checking. */
  125. __u32 spi_sw_version;
  126. /* QLogic_IB context assigned, goes into sent packets */
  127. __u16 spi_ctxt;
  128. __u16 spi_subctxt;
  129. /*
  130. * IB MTU, packets IB data must be less than this.
  131. * The MTU is in bytes, and will be a multiple of 4 bytes.
  132. */
  133. __u32 spi_mtu;
  134. /*
  135. * Size of a PIO buffer. Any given packet's total size must be less
  136. * than this (in words). Included is the starting control word, so
  137. * if 513 is returned, then total pkt size is 512 words or less.
  138. */
  139. __u32 spi_piosize;
  140. /* size of the TID cache in qlogic_ib, in entries */
  141. __u32 spi_tidcnt;
  142. /* size of the TID Eager list in qlogic_ib, in entries */
  143. __u32 spi_tidegrcnt;
  144. /* size of a single receive header queue entry in words. */
  145. __u32 spi_rcvhdrent_size;
  146. /*
  147. * Count of receive header queue entries allocated.
  148. * This may be less than the spu_rcvhdrcnt passed in!.
  149. */
  150. __u32 spi_rcvhdr_cnt;
  151. /* per-chip and other runtime features bitmap (QIB_RUNTIME_*) */
  152. __u32 spi_runtime_flags;
  153. /* address where hardware receive header queue is mapped */
  154. __u64 spi_rcvhdr_base;
  155. /* user program. */
  156. /* base address of eager TID receive buffers used by hardware. */
  157. __u64 spi_rcv_egrbufs;
  158. /* Allocated by initialization code, not by protocol. */
  159. /*
  160. * Size of each TID buffer in host memory, starting at
  161. * spi_rcv_egrbufs. The buffers are virtually contiguous.
  162. */
  163. __u32 spi_rcv_egrbufsize;
  164. /*
  165. * The special QP (queue pair) value that identifies an qlogic_ib
  166. * protocol packet from standard IB packets. More, probably much
  167. * more, to be added.
  168. */
  169. __u32 spi_qpair;
  170. /*
  171. * User register base for init code, not to be used directly by
  172. * protocol or applications. Always points to chip registers,
  173. * for normal or shared context.
  174. */
  175. __u64 spi_uregbase;
  176. /*
  177. * Maximum buffer size in bytes that can be used in a single TID
  178. * entry (assuming the buffer is aligned to this boundary). This is
  179. * the minimum of what the hardware and software support Guaranteed
  180. * to be a power of 2.
  181. */
  182. __u32 spi_tid_maxsize;
  183. /*
  184. * alignment of each pio send buffer (byte count
  185. * to add to spi_piobufbase to get to second buffer)
  186. */
  187. __u32 spi_pioalign;
  188. /*
  189. * The index of the first pio buffer available to this process;
  190. * needed to do lookup in spi_pioavailaddr; not added to
  191. * spi_piobufbase.
  192. */
  193. __u32 spi_pioindex;
  194. /* number of buffers mapped for this process */
  195. __u32 spi_piocnt;
  196. /*
  197. * Base address of writeonly pio buffers for this process.
  198. * Each buffer has spi_piosize words, and is aligned on spi_pioalign
  199. * boundaries. spi_piocnt buffers are mapped from this address
  200. */
  201. __u64 spi_piobufbase;
  202. /*
  203. * Base address of readonly memory copy of the pioavail registers.
  204. * There are 2 bits for each buffer.
  205. */
  206. __u64 spi_pioavailaddr;
  207. /*
  208. * Address where driver updates a copy of the interface and driver
  209. * status (QIB_STATUS_*) as a 64 bit value. It's followed by a
  210. * link status qword (formerly combined with driver status), then a
  211. * string indicating hardware error, if there was one.
  212. */
  213. __u64 spi_status;
  214. /* number of chip ctxts available to user processes */
  215. __u32 spi_nctxts;
  216. __u16 spi_unit; /* unit number of chip we are using */
  217. __u16 spi_port; /* IB port number we are using */
  218. /* num bufs in each contiguous set */
  219. __u32 spi_rcv_egrperchunk;
  220. /* size in bytes of each contiguous set */
  221. __u32 spi_rcv_egrchunksize;
  222. /* total size of mmap to cover full rcvegrbuffers */
  223. __u32 spi_rcv_egrbuftotlen;
  224. __u32 spi_rhf_offset; /* dword offset in hdrqent for rcvhdr flags */
  225. /* address of readonly memory copy of the rcvhdrq tail register. */
  226. __u64 spi_rcvhdr_tailaddr;
  227. /*
  228. * shared memory pages for subctxts if ctxt is shared; these cover
  229. * all the processes in the group sharing a single context.
  230. * all have enough space for the num_subcontexts value on this job.
  231. */
  232. __u64 spi_subctxt_uregbase;
  233. __u64 spi_subctxt_rcvegrbuf;
  234. __u64 spi_subctxt_rcvhdr_base;
  235. /* shared memory page for send buffer disarm status */
  236. __u64 spi_sendbuf_status;
  237. } __aligned(8);
  238. /*
  239. * This version number is given to the driver by the user code during
  240. * initialization in the spu_userversion field of qib_user_info, so
  241. * the driver can check for compatibility with user code.
  242. *
  243. * The major version changes when data structures
  244. * change in an incompatible way. The driver must be the same or higher
  245. * for initialization to succeed. In some cases, a higher version
  246. * driver will not interoperate with older software, and initialization
  247. * will return an error.
  248. */
  249. #define QIB_USER_SWMAJOR 1
  250. /*
  251. * Minor version differences are always compatible
  252. * a within a major version, however if user software is larger
  253. * than driver software, some new features and/or structure fields
  254. * may not be implemented; the user code must deal with this if it
  255. * cares, or it must abort after initialization reports the difference.
  256. */
  257. #define QIB_USER_SWMINOR 13
  258. #define QIB_USER_SWVERSION ((QIB_USER_SWMAJOR << 16) | QIB_USER_SWMINOR)
  259. #ifndef QIB_KERN_TYPE
  260. #define QIB_KERN_TYPE 0
  261. #endif
  262. /*
  263. * Similarly, this is the kernel version going back to the user. It's
  264. * slightly different, in that we want to tell if the driver was built as
  265. * part of a QLogic release, or from the driver from openfabrics.org,
  266. * kernel.org, or a standard distribution, for support reasons.
  267. * The high bit is 0 for non-QLogic and 1 for QLogic-built/supplied.
  268. *
  269. * It's returned by the driver to the user code during initialization in the
  270. * spi_sw_version field of qib_base_info, so the user code can in turn
  271. * check for compatibility with the kernel.
  272. */
  273. #define QIB_KERN_SWVERSION ((QIB_KERN_TYPE << 31) | QIB_USER_SWVERSION)
  274. /*
  275. * Define the driver version number. This is something that refers only
  276. * to the driver itself, not the software interfaces it supports.
  277. */
  278. #define QIB_DRIVER_VERSION_BASE "1.11"
  279. /* create the final driver version string */
  280. #ifdef QIB_IDSTR
  281. #define QIB_DRIVER_VERSION QIB_DRIVER_VERSION_BASE " " QIB_IDSTR
  282. #else
  283. #define QIB_DRIVER_VERSION QIB_DRIVER_VERSION_BASE
  284. #endif
  285. /*
  286. * If the unit is specified via open, HCA choice is fixed. If port is
  287. * specified, it's also fixed. Otherwise we try to spread contexts
  288. * across ports and HCAs, using different algorithims. WITHIN is
  289. * the old default, prior to this mechanism.
  290. */
  291. #define QIB_PORT_ALG_ACROSS 0 /* round robin contexts across HCAs, then
  292. * ports; this is the default */
  293. #define QIB_PORT_ALG_WITHIN 1 /* use all contexts on an HCA (round robin
  294. * active ports within), then next HCA */
  295. #define QIB_PORT_ALG_COUNT 2 /* number of algorithm choices */
  296. /*
  297. * This structure is passed to qib_userinit() to tell the driver where
  298. * user code buffers are, sizes, etc. The offsets and sizes of the
  299. * fields must remain unchanged, for binary compatibility. It can
  300. * be extended, if userversion is changed so user code can tell, if needed
  301. */
  302. struct qib_user_info {
  303. /*
  304. * version of user software, to detect compatibility issues.
  305. * Should be set to QIB_USER_SWVERSION.
  306. */
  307. __u32 spu_userversion;
  308. __u32 _spu_unused2;
  309. /* size of struct base_info to write to */
  310. __u32 spu_base_info_size;
  311. __u32 spu_port_alg; /* which QIB_PORT_ALG_*; unused user minor < 11 */
  312. /*
  313. * If two or more processes wish to share a context, each process
  314. * must set the spu_subctxt_cnt and spu_subctxt_id to the same
  315. * values. The only restriction on the spu_subctxt_id is that
  316. * it be unique for a given node.
  317. */
  318. __u16 spu_subctxt_cnt;
  319. __u16 spu_subctxt_id;
  320. __u32 spu_port; /* IB port requested by user if > 0 */
  321. /*
  322. * address of struct base_info to write to
  323. */
  324. __u64 spu_base_info;
  325. } __aligned(8);
  326. /* User commands. */
  327. /* 16 available, was: old set up userspace (for old user code) */
  328. #define QIB_CMD_CTXT_INFO 17 /* find out what resources we got */
  329. #define QIB_CMD_RECV_CTRL 18 /* control receipt of packets */
  330. #define QIB_CMD_TID_UPDATE 19 /* update expected TID entries */
  331. #define QIB_CMD_TID_FREE 20 /* free expected TID entries */
  332. #define QIB_CMD_SET_PART_KEY 21 /* add partition key */
  333. /* 22 available, was: return info on slave processes (for old user code) */
  334. #define QIB_CMD_ASSIGN_CTXT 23 /* allocate HCA and ctxt */
  335. #define QIB_CMD_USER_INIT 24 /* set up userspace */
  336. #define QIB_CMD_UNUSED_1 25
  337. #define QIB_CMD_UNUSED_2 26
  338. #define QIB_CMD_PIOAVAILUPD 27 /* force an update of PIOAvail reg */
  339. #define QIB_CMD_POLL_TYPE 28 /* set the kind of polling we want */
  340. #define QIB_CMD_ARMLAUNCH_CTRL 29 /* armlaunch detection control */
  341. /* 30 is unused */
  342. #define QIB_CMD_SDMA_INFLIGHT 31 /* sdma inflight counter request */
  343. #define QIB_CMD_SDMA_COMPLETE 32 /* sdma completion counter request */
  344. /* 33 available, was a testing feature */
  345. #define QIB_CMD_DISARM_BUFS 34 /* disarm send buffers w/ errors */
  346. #define QIB_CMD_ACK_EVENT 35 /* ack & clear bits */
  347. #define QIB_CMD_CPUS_LIST 36 /* list of cpus allocated, for pinned
  348. * processes: qib_cpus_list */
  349. /*
  350. * QIB_CMD_ACK_EVENT obsoletes QIB_CMD_DISARM_BUFS, but we keep it for
  351. * compatibility with libraries from previous release. The ACK_EVENT
  352. * will take appropriate driver action (if any, just DISARM for now),
  353. * then clear the bits passed in as part of the mask. These bits are
  354. * in the first 64bit word at spi_sendbuf_status, and are passed to
  355. * the driver in the event_mask union as well.
  356. */
  357. #define _QIB_EVENT_DISARM_BUFS_BIT 0
  358. #define _QIB_EVENT_LINKDOWN_BIT 1
  359. #define _QIB_EVENT_LID_CHANGE_BIT 2
  360. #define _QIB_EVENT_LMC_CHANGE_BIT 3
  361. #define _QIB_EVENT_SL2VL_CHANGE_BIT 4
  362. #define _QIB_MAX_EVENT_BIT _QIB_EVENT_SL2VL_CHANGE_BIT
  363. #define QIB_EVENT_DISARM_BUFS_BIT (1UL << _QIB_EVENT_DISARM_BUFS_BIT)
  364. #define QIB_EVENT_LINKDOWN_BIT (1UL << _QIB_EVENT_LINKDOWN_BIT)
  365. #define QIB_EVENT_LID_CHANGE_BIT (1UL << _QIB_EVENT_LID_CHANGE_BIT)
  366. #define QIB_EVENT_LMC_CHANGE_BIT (1UL << _QIB_EVENT_LMC_CHANGE_BIT)
  367. #define QIB_EVENT_SL2VL_CHANGE_BIT (1UL << _QIB_EVENT_SL2VL_CHANGE_BIT)
  368. /*
  369. * Poll types
  370. */
  371. #define QIB_POLL_TYPE_ANYRCV 0x0
  372. #define QIB_POLL_TYPE_URGENT 0x1
  373. struct qib_ctxt_info {
  374. __u16 num_active; /* number of active units */
  375. __u16 unit; /* unit (chip) assigned to caller */
  376. __u16 port; /* IB port assigned to caller (1-based) */
  377. __u16 ctxt; /* ctxt on unit assigned to caller */
  378. __u16 subctxt; /* subctxt on unit assigned to caller */
  379. __u16 num_ctxts; /* number of ctxts available on unit */
  380. __u16 num_subctxts; /* number of subctxts opened on ctxt */
  381. __u16 rec_cpu; /* cpu # for affinity (ffff if none) */
  382. };
  383. struct qib_tid_info {
  384. __u32 tidcnt;
  385. /* make structure same size in 32 and 64 bit */
  386. __u32 tid__unused;
  387. /* virtual address of first page in transfer */
  388. __u64 tidvaddr;
  389. /* pointer (same size 32/64 bit) to __u16 tid array */
  390. __u64 tidlist;
  391. /*
  392. * pointer (same size 32/64 bit) to bitmap of TIDs used
  393. * for this call; checked for being large enough at open
  394. */
  395. __u64 tidmap;
  396. };
  397. struct qib_cmd {
  398. __u32 type; /* command type */
  399. union {
  400. struct qib_tid_info tid_info;
  401. struct qib_user_info user_info;
  402. /*
  403. * address in userspace where we should put the sdma
  404. * inflight counter
  405. */
  406. __u64 sdma_inflight;
  407. /*
  408. * address in userspace where we should put the sdma
  409. * completion counter
  410. */
  411. __u64 sdma_complete;
  412. /* address in userspace of struct qib_ctxt_info to
  413. write result to */
  414. __u64 ctxt_info;
  415. /* enable/disable receipt of packets */
  416. __u32 recv_ctrl;
  417. /* enable/disable armlaunch errors (non-zero to enable) */
  418. __u32 armlaunch_ctrl;
  419. /* partition key to set */
  420. __u16 part_key;
  421. /* user address of __u32 bitmask of active slaves */
  422. __u64 slave_mask_addr;
  423. /* type of polling we want */
  424. __u16 poll_type;
  425. /* back pressure enable bit for one particular context */
  426. __u8 ctxt_bp;
  427. /* qib_user_event_ack(), IPATH_EVENT_* bits */
  428. __u64 event_mask;
  429. } cmd;
  430. };
  431. struct qib_iovec {
  432. /* Pointer to data, but same size 32 and 64 bit */
  433. __u64 iov_base;
  434. /*
  435. * Length of data; don't need 64 bits, but want
  436. * qib_sendpkt to remain same size as before 32 bit changes, so...
  437. */
  438. __u64 iov_len;
  439. };
  440. /*
  441. * Describes a single packet for send. Each packet can have one or more
  442. * buffers, but the total length (exclusive of IB headers) must be less
  443. * than the MTU, and if using the PIO method, entire packet length,
  444. * including IB headers, must be less than the qib_piosize value (words).
  445. * Use of this necessitates including sys/uio.h
  446. */
  447. struct __qib_sendpkt {
  448. __u32 sps_flags; /* flags for packet (TBD) */
  449. __u32 sps_cnt; /* number of entries to use in sps_iov */
  450. /* array of iov's describing packet. TEMPORARY */
  451. struct qib_iovec sps_iov[4];
  452. };
  453. /*
  454. * Diagnostics can send a packet by "writing" the following
  455. * structs to the diag data special file.
  456. * This allows a custom
  457. * pbc (+ static rate) qword, so that special modes and deliberate
  458. * changes to CRCs can be used. The elements were also re-ordered
  459. * for better alignment and to avoid padding issues.
  460. */
  461. #define _DIAG_XPKT_VERS 3
  462. struct qib_diag_xpkt {
  463. __u16 version;
  464. __u16 unit;
  465. __u16 port;
  466. __u16 len;
  467. __u64 data;
  468. __u64 pbc_wd;
  469. };
  470. /*
  471. * Data layout in I2C flash (for GUID, etc.)
  472. * All fields are little-endian binary unless otherwise stated
  473. */
  474. #define QIB_FLASH_VERSION 2
  475. struct qib_flash {
  476. /* flash layout version (QIB_FLASH_VERSION) */
  477. __u8 if_fversion;
  478. /* checksum protecting if_length bytes */
  479. __u8 if_csum;
  480. /*
  481. * valid length (in use, protected by if_csum), including
  482. * if_fversion and if_csum themselves)
  483. */
  484. __u8 if_length;
  485. /* the GUID, in network order */
  486. __u8 if_guid[8];
  487. /* number of GUIDs to use, starting from if_guid */
  488. __u8 if_numguid;
  489. /* the (last 10 characters of) board serial number, in ASCII */
  490. char if_serial[12];
  491. /* board mfg date (YYYYMMDD ASCII) */
  492. char if_mfgdate[8];
  493. /* last board rework/test date (YYYYMMDD ASCII) */
  494. char if_testdate[8];
  495. /* logging of error counts, TBD */
  496. __u8 if_errcntp[4];
  497. /* powered on hours, updated at driver unload */
  498. __u8 if_powerhour[2];
  499. /* ASCII free-form comment field */
  500. char if_comment[32];
  501. /* Backwards compatible prefix for longer QLogic Serial Numbers */
  502. char if_sprefix[4];
  503. /* 82 bytes used, min flash size is 128 bytes */
  504. __u8 if_future[46];
  505. };
  506. /*
  507. * These are the counters implemented in the chip, and are listed in order.
  508. * The InterCaps naming is taken straight from the chip spec.
  509. */
  510. struct qlogic_ib_counters {
  511. __u64 LBIntCnt;
  512. __u64 LBFlowStallCnt;
  513. __u64 TxSDmaDescCnt; /* was Reserved1 */
  514. __u64 TxUnsupVLErrCnt;
  515. __u64 TxDataPktCnt;
  516. __u64 TxFlowPktCnt;
  517. __u64 TxDwordCnt;
  518. __u64 TxLenErrCnt;
  519. __u64 TxMaxMinLenErrCnt;
  520. __u64 TxUnderrunCnt;
  521. __u64 TxFlowStallCnt;
  522. __u64 TxDroppedPktCnt;
  523. __u64 RxDroppedPktCnt;
  524. __u64 RxDataPktCnt;
  525. __u64 RxFlowPktCnt;
  526. __u64 RxDwordCnt;
  527. __u64 RxLenErrCnt;
  528. __u64 RxMaxMinLenErrCnt;
  529. __u64 RxICRCErrCnt;
  530. __u64 RxVCRCErrCnt;
  531. __u64 RxFlowCtrlErrCnt;
  532. __u64 RxBadFormatCnt;
  533. __u64 RxLinkProblemCnt;
  534. __u64 RxEBPCnt;
  535. __u64 RxLPCRCErrCnt;
  536. __u64 RxBufOvflCnt;
  537. __u64 RxTIDFullErrCnt;
  538. __u64 RxTIDValidErrCnt;
  539. __u64 RxPKeyMismatchCnt;
  540. __u64 RxP0HdrEgrOvflCnt;
  541. __u64 RxP1HdrEgrOvflCnt;
  542. __u64 RxP2HdrEgrOvflCnt;
  543. __u64 RxP3HdrEgrOvflCnt;
  544. __u64 RxP4HdrEgrOvflCnt;
  545. __u64 RxP5HdrEgrOvflCnt;
  546. __u64 RxP6HdrEgrOvflCnt;
  547. __u64 RxP7HdrEgrOvflCnt;
  548. __u64 RxP8HdrEgrOvflCnt;
  549. __u64 RxP9HdrEgrOvflCnt;
  550. __u64 RxP10HdrEgrOvflCnt;
  551. __u64 RxP11HdrEgrOvflCnt;
  552. __u64 RxP12HdrEgrOvflCnt;
  553. __u64 RxP13HdrEgrOvflCnt;
  554. __u64 RxP14HdrEgrOvflCnt;
  555. __u64 RxP15HdrEgrOvflCnt;
  556. __u64 RxP16HdrEgrOvflCnt;
  557. __u64 IBStatusChangeCnt;
  558. __u64 IBLinkErrRecoveryCnt;
  559. __u64 IBLinkDownedCnt;
  560. __u64 IBSymbolErrCnt;
  561. __u64 RxVL15DroppedPktCnt;
  562. __u64 RxOtherLocalPhyErrCnt;
  563. __u64 PcieRetryBufDiagQwordCnt;
  564. __u64 ExcessBufferOvflCnt;
  565. __u64 LocalLinkIntegrityErrCnt;
  566. __u64 RxVlErrCnt;
  567. __u64 RxDlidFltrCnt;
  568. };
  569. /*
  570. * The next set of defines are for packet headers, and chip register
  571. * and memory bits that are visible to and/or used by user-mode software.
  572. */
  573. /* RcvHdrFlags bits */
  574. #define QLOGIC_IB_RHF_LENGTH_MASK 0x7FF
  575. #define QLOGIC_IB_RHF_LENGTH_SHIFT 0
  576. #define QLOGIC_IB_RHF_RCVTYPE_MASK 0x7
  577. #define QLOGIC_IB_RHF_RCVTYPE_SHIFT 11
  578. #define QLOGIC_IB_RHF_EGRINDEX_MASK 0xFFF
  579. #define QLOGIC_IB_RHF_EGRINDEX_SHIFT 16
  580. #define QLOGIC_IB_RHF_SEQ_MASK 0xF
  581. #define QLOGIC_IB_RHF_SEQ_SHIFT 0
  582. #define QLOGIC_IB_RHF_HDRQ_OFFSET_MASK 0x7FF
  583. #define QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT 4
  584. #define QLOGIC_IB_RHF_H_ICRCERR 0x80000000
  585. #define QLOGIC_IB_RHF_H_VCRCERR 0x40000000
  586. #define QLOGIC_IB_RHF_H_PARITYERR 0x20000000
  587. #define QLOGIC_IB_RHF_H_LENERR 0x10000000
  588. #define QLOGIC_IB_RHF_H_MTUERR 0x08000000
  589. #define QLOGIC_IB_RHF_H_IHDRERR 0x04000000
  590. #define QLOGIC_IB_RHF_H_TIDERR 0x02000000
  591. #define QLOGIC_IB_RHF_H_MKERR 0x01000000
  592. #define QLOGIC_IB_RHF_H_IBERR 0x00800000
  593. #define QLOGIC_IB_RHF_H_ERR_MASK 0xFF800000
  594. #define QLOGIC_IB_RHF_L_USE_EGR 0x80000000
  595. #define QLOGIC_IB_RHF_L_SWA 0x00008000
  596. #define QLOGIC_IB_RHF_L_SWB 0x00004000
  597. /* qlogic_ib header fields */
  598. #define QLOGIC_IB_I_VERS_MASK 0xF
  599. #define QLOGIC_IB_I_VERS_SHIFT 28
  600. #define QLOGIC_IB_I_CTXT_MASK 0xF
  601. #define QLOGIC_IB_I_CTXT_SHIFT 24
  602. #define QLOGIC_IB_I_TID_MASK 0x7FF
  603. #define QLOGIC_IB_I_TID_SHIFT 13
  604. #define QLOGIC_IB_I_OFFSET_MASK 0x1FFF
  605. #define QLOGIC_IB_I_OFFSET_SHIFT 0
  606. /* K_PktFlags bits */
  607. #define QLOGIC_IB_KPF_INTR 0x1
  608. #define QLOGIC_IB_KPF_SUBCTXT_MASK 0x3
  609. #define QLOGIC_IB_KPF_SUBCTXT_SHIFT 1
  610. #define QLOGIC_IB_MAX_SUBCTXT 4
  611. /* SendPIO per-buffer control */
  612. #define QLOGIC_IB_SP_TEST 0x40
  613. #define QLOGIC_IB_SP_TESTEBP 0x20
  614. #define QLOGIC_IB_SP_TRIGGER_SHIFT 15
  615. /* SendPIOAvail bits */
  616. #define QLOGIC_IB_SENDPIOAVAIL_BUSY_SHIFT 1
  617. #define QLOGIC_IB_SENDPIOAVAIL_CHECK_SHIFT 0
  618. /* qlogic_ib header format */
  619. struct qib_header {
  620. /*
  621. * Version - 4 bits, Context - 4 bits, TID - 10 bits and Offset -
  622. * 14 bits before ECO change ~28 Dec 03. After that, Vers 4,
  623. * Context 4, TID 11, offset 13.
  624. */
  625. __le32 ver_ctxt_tid_offset;
  626. __le16 chksum;
  627. __le16 pkt_flags;
  628. };
  629. /*
  630. * qlogic_ib user message header format.
  631. * This structure contains the first 4 fields common to all protocols
  632. * that employ qlogic_ib.
  633. */
  634. struct qib_message_header {
  635. __be16 lrh[4];
  636. __be32 bth[3];
  637. /* fields below this point are in host byte order */
  638. struct qib_header iph;
  639. /* fields below are simplified, but should match PSM */
  640. /* some are accessed by driver when packet spliting is needed */
  641. __u8 sub_opcode;
  642. __u8 flags;
  643. __u16 commidx;
  644. __u32 ack_seq_num;
  645. __u8 flowid;
  646. __u8 hdr_dlen;
  647. __u16 mqhdr;
  648. __u32 uwords[4];
  649. };
  650. /* sequence number bits for message */
  651. union qib_seqnum {
  652. struct {
  653. __u32 seq:11;
  654. __u32 gen:8;
  655. __u32 flow:5;
  656. };
  657. struct {
  658. __u32 pkt:16;
  659. __u32 msg:8;
  660. };
  661. __u32 val;
  662. };
  663. /* qib receiving-dma tid-session-member */
  664. struct qib_tid_session_member {
  665. __u16 tid;
  666. __u16 offset;
  667. __u16 length;
  668. };
  669. /* IB - LRH header consts */
  670. #define QIB_LRH_GRH 0x0003 /* 1. word of IB LRH - next header: GRH */
  671. #define QIB_LRH_BTH 0x0002 /* 1. word of IB LRH - next header: BTH */
  672. /* misc. */
  673. #define SIZE_OF_CRC 1
  674. #define QIB_DEFAULT_P_KEY 0xFFFF
  675. #define QIB_PERMISSIVE_LID 0xFFFF
  676. #define QIB_AETH_CREDIT_SHIFT 24
  677. #define QIB_AETH_CREDIT_MASK 0x1F
  678. #define QIB_AETH_CREDIT_INVAL 0x1F
  679. #define QIB_PSN_MASK 0xFFFFFF
  680. #define QIB_MSN_MASK 0xFFFFFF
  681. #define QIB_QPN_MASK 0xFFFFFF
  682. #define QIB_MULTICAST_LID_BASE 0xC000
  683. #define QIB_EAGER_TID_ID QLOGIC_IB_I_TID_MASK
  684. #define QIB_MULTICAST_QPN 0xFFFFFF
  685. /* Receive Header Queue: receive type (from qlogic_ib) */
  686. #define RCVHQ_RCV_TYPE_EXPECTED 0
  687. #define RCVHQ_RCV_TYPE_EAGER 1
  688. #define RCVHQ_RCV_TYPE_NON_KD 2
  689. #define RCVHQ_RCV_TYPE_ERROR 3
  690. #define QIB_HEADER_QUEUE_WORDS 9
  691. /* functions for extracting fields from rcvhdrq entries for the driver.
  692. */
  693. static inline __u32 qib_hdrget_err_flags(const __le32 *rbuf)
  694. {
  695. return __le32_to_cpu(rbuf[1]) & QLOGIC_IB_RHF_H_ERR_MASK;
  696. }
  697. static inline __u32 qib_hdrget_rcv_type(const __le32 *rbuf)
  698. {
  699. return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_RCVTYPE_SHIFT) &
  700. QLOGIC_IB_RHF_RCVTYPE_MASK;
  701. }
  702. static inline __u32 qib_hdrget_length_in_bytes(const __le32 *rbuf)
  703. {
  704. return ((__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_LENGTH_SHIFT) &
  705. QLOGIC_IB_RHF_LENGTH_MASK) << 2;
  706. }
  707. static inline __u32 qib_hdrget_index(const __le32 *rbuf)
  708. {
  709. return (__le32_to_cpu(rbuf[0]) >> QLOGIC_IB_RHF_EGRINDEX_SHIFT) &
  710. QLOGIC_IB_RHF_EGRINDEX_MASK;
  711. }
  712. static inline __u32 qib_hdrget_seq(const __le32 *rbuf)
  713. {
  714. return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_SEQ_SHIFT) &
  715. QLOGIC_IB_RHF_SEQ_MASK;
  716. }
  717. static inline __u32 qib_hdrget_offset(const __le32 *rbuf)
  718. {
  719. return (__le32_to_cpu(rbuf[1]) >> QLOGIC_IB_RHF_HDRQ_OFFSET_SHIFT) &
  720. QLOGIC_IB_RHF_HDRQ_OFFSET_MASK;
  721. }
  722. static inline __u32 qib_hdrget_use_egr_buf(const __le32 *rbuf)
  723. {
  724. return __le32_to_cpu(rbuf[0]) & QLOGIC_IB_RHF_L_USE_EGR;
  725. }
  726. static inline __u32 qib_hdrget_qib_ver(__le32 hdrword)
  727. {
  728. return (__le32_to_cpu(hdrword) >> QLOGIC_IB_I_VERS_SHIFT) &
  729. QLOGIC_IB_I_VERS_MASK;
  730. }
  731. #endif /* _QIB_COMMON_H */