qib.h 51 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552
  1. #ifndef _QIB_KERNEL_H
  2. #define _QIB_KERNEL_H
  3. /*
  4. * Copyright (c) 2012, 2013 Intel Corporation. All rights reserved.
  5. * Copyright (c) 2006 - 2012 QLogic Corporation. All rights reserved.
  6. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  7. *
  8. * This software is available to you under a choice of one of two
  9. * licenses. You may choose to be licensed under the terms of the GNU
  10. * General Public License (GPL) Version 2, available from the file
  11. * COPYING in the main directory of this source tree, or the
  12. * OpenIB.org BSD license below:
  13. *
  14. * Redistribution and use in source and binary forms, with or
  15. * without modification, are permitted provided that the following
  16. * conditions are met:
  17. *
  18. * - Redistributions of source code must retain the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer.
  21. *
  22. * - Redistributions in binary form must reproduce the above
  23. * copyright notice, this list of conditions and the following
  24. * disclaimer in the documentation and/or other materials
  25. * provided with the distribution.
  26. *
  27. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  28. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  30. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  31. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  32. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  33. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  34. * SOFTWARE.
  35. */
  36. /*
  37. * This header file is the base header file for qlogic_ib kernel code
  38. * qib_user.h serves a similar purpose for user code.
  39. */
  40. #include <linux/interrupt.h>
  41. #include <linux/pci.h>
  42. #include <linux/dma-mapping.h>
  43. #include <linux/mutex.h>
  44. #include <linux/list.h>
  45. #include <linux/scatterlist.h>
  46. #include <linux/slab.h>
  47. #include <linux/io.h>
  48. #include <linux/fs.h>
  49. #include <linux/completion.h>
  50. #include <linux/kref.h>
  51. #include <linux/sched.h>
  52. #include <linux/kthread.h>
  53. #include <rdma/ib_hdrs.h>
  54. #include <rdma/rdma_vt.h>
  55. #include "qib_common.h"
  56. #include "qib_verbs.h"
  57. /* only s/w major version of QLogic_IB we can handle */
  58. #define QIB_CHIP_VERS_MAJ 2U
  59. /* don't care about this except printing */
  60. #define QIB_CHIP_VERS_MIN 0U
  61. /* The Organization Unique Identifier (Mfg code), and its position in GUID */
  62. #define QIB_OUI 0x001175
  63. #define QIB_OUI_LSB 40
  64. /*
  65. * per driver stats, either not device nor port-specific, or
  66. * summed over all of the devices and ports.
  67. * They are described by name via ipathfs filesystem, so layout
  68. * and number of elements can change without breaking compatibility.
  69. * If members are added or deleted qib_statnames[] in qib_fs.c must
  70. * change to match.
  71. */
  72. struct qlogic_ib_stats {
  73. __u64 sps_ints; /* number of interrupts handled */
  74. __u64 sps_errints; /* number of error interrupts */
  75. __u64 sps_txerrs; /* tx-related packet errors */
  76. __u64 sps_rcverrs; /* non-crc rcv packet errors */
  77. __u64 sps_hwerrs; /* hardware errors reported (parity, etc.) */
  78. __u64 sps_nopiobufs; /* no pio bufs avail from kernel */
  79. __u64 sps_ctxts; /* number of contexts currently open */
  80. __u64 sps_lenerrs; /* number of kernel packets where RHF != LRH len */
  81. __u64 sps_buffull;
  82. __u64 sps_hdrfull;
  83. };
  84. extern struct qlogic_ib_stats qib_stats;
  85. extern const struct pci_error_handlers qib_pci_err_handler;
  86. #define QIB_CHIP_SWVERSION QIB_CHIP_VERS_MAJ
  87. /*
  88. * First-cut critierion for "device is active" is
  89. * two thousand dwords combined Tx, Rx traffic per
  90. * 5-second interval. SMA packets are 64 dwords,
  91. * and occur "a few per second", presumably each way.
  92. */
  93. #define QIB_TRAFFIC_ACTIVE_THRESHOLD (2000)
  94. /*
  95. * Struct used to indicate which errors are logged in each of the
  96. * error-counters that are logged to EEPROM. A counter is incremented
  97. * _once_ (saturating at 255) for each event with any bits set in
  98. * the error or hwerror register masks below.
  99. */
  100. #define QIB_EEP_LOG_CNT (4)
  101. struct qib_eep_log_mask {
  102. u64 errs_to_log;
  103. u64 hwerrs_to_log;
  104. };
  105. /*
  106. * Below contains all data related to a single context (formerly called port).
  107. */
  108. #ifdef CONFIG_DEBUG_FS
  109. struct qib_opcode_stats_perctx;
  110. #endif
  111. struct qib_ctxtdata {
  112. void **rcvegrbuf;
  113. dma_addr_t *rcvegrbuf_phys;
  114. /* rcvhdrq base, needs mmap before useful */
  115. void *rcvhdrq;
  116. /* kernel virtual address where hdrqtail is updated */
  117. void *rcvhdrtail_kvaddr;
  118. /*
  119. * temp buffer for expected send setup, allocated at open, instead
  120. * of each setup call
  121. */
  122. void *tid_pg_list;
  123. /*
  124. * Shared page for kernel to signal user processes that send buffers
  125. * need disarming. The process should call QIB_CMD_DISARM_BUFS
  126. * or QIB_CMD_ACK_EVENT with IPATH_EVENT_DISARM_BUFS set.
  127. */
  128. unsigned long *user_event_mask;
  129. /* when waiting for rcv or pioavail */
  130. wait_queue_head_t wait;
  131. /*
  132. * rcvegr bufs base, physical, must fit
  133. * in 44 bits so 32 bit programs mmap64 44 bit works)
  134. */
  135. dma_addr_t rcvegr_phys;
  136. /* mmap of hdrq, must fit in 44 bits */
  137. dma_addr_t rcvhdrq_phys;
  138. dma_addr_t rcvhdrqtailaddr_phys;
  139. /*
  140. * number of opens (including slave sub-contexts) on this instance
  141. * (ignoring forks, dup, etc. for now)
  142. */
  143. int cnt;
  144. /*
  145. * how much space to leave at start of eager TID entries for
  146. * protocol use, on each TID
  147. */
  148. /* instead of calculating it */
  149. unsigned ctxt;
  150. /* local node of context */
  151. int node_id;
  152. /* non-zero if ctxt is being shared. */
  153. u16 subctxt_cnt;
  154. /* non-zero if ctxt is being shared. */
  155. u16 subctxt_id;
  156. /* number of eager TID entries. */
  157. u16 rcvegrcnt;
  158. /* index of first eager TID entry. */
  159. u16 rcvegr_tid_base;
  160. /* number of pio bufs for this ctxt (all procs, if shared) */
  161. u32 piocnt;
  162. /* first pio buffer for this ctxt */
  163. u32 pio_base;
  164. /* chip offset of PIO buffers for this ctxt */
  165. u32 piobufs;
  166. /* how many alloc_pages() chunks in rcvegrbuf_pages */
  167. u32 rcvegrbuf_chunks;
  168. /* how many egrbufs per chunk */
  169. u16 rcvegrbufs_perchunk;
  170. /* ilog2 of above */
  171. u16 rcvegrbufs_perchunk_shift;
  172. /* order for rcvegrbuf_pages */
  173. size_t rcvegrbuf_size;
  174. /* rcvhdrq size (for freeing) */
  175. size_t rcvhdrq_size;
  176. /* per-context flags for fileops/intr communication */
  177. unsigned long flag;
  178. /* next expected TID to check when looking for free */
  179. u32 tidcursor;
  180. /* WAIT_RCV that timed out, no interrupt */
  181. u32 rcvwait_to;
  182. /* WAIT_PIO that timed out, no interrupt */
  183. u32 piowait_to;
  184. /* WAIT_RCV already happened, no wait */
  185. u32 rcvnowait;
  186. /* WAIT_PIO already happened, no wait */
  187. u32 pionowait;
  188. /* total number of polled urgent packets */
  189. u32 urgent;
  190. /* saved total number of polled urgent packets for poll edge trigger */
  191. u32 urgent_poll;
  192. /* pid of process using this ctxt */
  193. pid_t pid;
  194. pid_t subpid[QLOGIC_IB_MAX_SUBCTXT];
  195. /* same size as task_struct .comm[], command that opened context */
  196. char comm[16];
  197. /* pkeys set by this use of this ctxt */
  198. u16 pkeys[4];
  199. /* so file ops can get at unit */
  200. struct qib_devdata *dd;
  201. /* so funcs that need physical port can get it easily */
  202. struct qib_pportdata *ppd;
  203. /* A page of memory for rcvhdrhead, rcvegrhead, rcvegrtail * N */
  204. void *subctxt_uregbase;
  205. /* An array of pages for the eager receive buffers * N */
  206. void *subctxt_rcvegrbuf;
  207. /* An array of pages for the eager header queue entries * N */
  208. void *subctxt_rcvhdr_base;
  209. /* The version of the library which opened this ctxt */
  210. u32 userversion;
  211. /* Bitmask of active slaves */
  212. u32 active_slaves;
  213. /* Type of packets or conditions we want to poll for */
  214. u16 poll_type;
  215. /* receive packet sequence counter */
  216. u8 seq_cnt;
  217. u8 redirect_seq_cnt;
  218. /* ctxt rcvhdrq head offset */
  219. u32 head;
  220. /* QPs waiting for context processing */
  221. struct list_head qp_wait_list;
  222. #ifdef CONFIG_DEBUG_FS
  223. /* verbs stats per CTX */
  224. struct qib_opcode_stats_perctx *opstats;
  225. #endif
  226. };
  227. struct rvt_sge_state;
  228. struct qib_sdma_txreq {
  229. int flags;
  230. int sg_count;
  231. dma_addr_t addr;
  232. void (*callback)(struct qib_sdma_txreq *, int);
  233. u16 start_idx; /* sdma private */
  234. u16 next_descq_idx; /* sdma private */
  235. struct list_head list; /* sdma private */
  236. };
  237. struct qib_sdma_desc {
  238. __le64 qw[2];
  239. };
  240. struct qib_verbs_txreq {
  241. struct qib_sdma_txreq txreq;
  242. struct rvt_qp *qp;
  243. struct rvt_swqe *wqe;
  244. u32 dwords;
  245. u16 hdr_dwords;
  246. u16 hdr_inx;
  247. struct qib_pio_header *align_buf;
  248. struct rvt_mregion *mr;
  249. struct rvt_sge_state *ss;
  250. };
  251. #define QIB_SDMA_TXREQ_F_USELARGEBUF 0x1
  252. #define QIB_SDMA_TXREQ_F_HEADTOHOST 0x2
  253. #define QIB_SDMA_TXREQ_F_INTREQ 0x4
  254. #define QIB_SDMA_TXREQ_F_FREEBUF 0x8
  255. #define QIB_SDMA_TXREQ_F_FREEDESC 0x10
  256. #define QIB_SDMA_TXREQ_S_OK 0
  257. #define QIB_SDMA_TXREQ_S_SENDERROR 1
  258. #define QIB_SDMA_TXREQ_S_ABORTED 2
  259. #define QIB_SDMA_TXREQ_S_SHUTDOWN 3
  260. /*
  261. * Get/Set IB link-level config parameters for f_get/set_ib_cfg()
  262. * Mostly for MADs that set or query link parameters, also ipath
  263. * config interfaces
  264. */
  265. #define QIB_IB_CFG_LIDLMC 0 /* LID (LS16b) and Mask (MS16b) */
  266. #define QIB_IB_CFG_LWID_ENB 2 /* allowed Link-width */
  267. #define QIB_IB_CFG_LWID 3 /* currently active Link-width */
  268. #define QIB_IB_CFG_SPD_ENB 4 /* allowed Link speeds */
  269. #define QIB_IB_CFG_SPD 5 /* current Link spd */
  270. #define QIB_IB_CFG_RXPOL_ENB 6 /* Auto-RX-polarity enable */
  271. #define QIB_IB_CFG_LREV_ENB 7 /* Auto-Lane-reversal enable */
  272. #define QIB_IB_CFG_LINKLATENCY 8 /* Link Latency (IB1.2 only) */
  273. #define QIB_IB_CFG_HRTBT 9 /* IB heartbeat off/enable/auto; DDR/QDR only */
  274. #define QIB_IB_CFG_OP_VLS 10 /* operational VLs */
  275. #define QIB_IB_CFG_VL_HIGH_CAP 11 /* num of VL high priority weights */
  276. #define QIB_IB_CFG_VL_LOW_CAP 12 /* num of VL low priority weights */
  277. #define QIB_IB_CFG_OVERRUN_THRESH 13 /* IB overrun threshold */
  278. #define QIB_IB_CFG_PHYERR_THRESH 14 /* IB PHY error threshold */
  279. #define QIB_IB_CFG_LINKDEFAULT 15 /* IB link default (sleep/poll) */
  280. #define QIB_IB_CFG_PKEYS 16 /* update partition keys */
  281. #define QIB_IB_CFG_MTU 17 /* update MTU in IBC */
  282. #define QIB_IB_CFG_LSTATE 18 /* update linkcmd and linkinitcmd in IBC */
  283. #define QIB_IB_CFG_VL_HIGH_LIMIT 19
  284. #define QIB_IB_CFG_PMA_TICKS 20 /* PMA sample tick resolution */
  285. #define QIB_IB_CFG_PORT 21 /* switch port we are connected to */
  286. /*
  287. * for CFG_LSTATE: LINKCMD in upper 16 bits, LINKINITCMD in lower 16
  288. * IB_LINKINITCMD_POLL and SLEEP are also used as set/get values for
  289. * QIB_IB_CFG_LINKDEFAULT cmd
  290. */
  291. #define IB_LINKCMD_DOWN (0 << 16)
  292. #define IB_LINKCMD_ARMED (1 << 16)
  293. #define IB_LINKCMD_ACTIVE (2 << 16)
  294. #define IB_LINKINITCMD_NOP 0
  295. #define IB_LINKINITCMD_POLL 1
  296. #define IB_LINKINITCMD_SLEEP 2
  297. #define IB_LINKINITCMD_DISABLE 3
  298. /*
  299. * valid states passed to qib_set_linkstate() user call
  300. */
  301. #define QIB_IB_LINKDOWN 0
  302. #define QIB_IB_LINKARM 1
  303. #define QIB_IB_LINKACTIVE 2
  304. #define QIB_IB_LINKDOWN_ONLY 3
  305. #define QIB_IB_LINKDOWN_SLEEP 4
  306. #define QIB_IB_LINKDOWN_DISABLE 5
  307. /*
  308. * These 7 values (SDR, DDR, and QDR may be ORed for auto-speed
  309. * negotiation) are used for the 3rd argument to path_f_set_ib_cfg
  310. * with cmd QIB_IB_CFG_SPD_ENB, by direct calls or via sysfs. They
  311. * are also the the possible values for qib_link_speed_enabled and active
  312. * The values were chosen to match values used within the IB spec.
  313. */
  314. #define QIB_IB_SDR 1
  315. #define QIB_IB_DDR 2
  316. #define QIB_IB_QDR 4
  317. #define QIB_DEFAULT_MTU 4096
  318. /* max number of IB ports supported per HCA */
  319. #define QIB_MAX_IB_PORTS 2
  320. /*
  321. * Possible IB config parameters for f_get/set_ib_table()
  322. */
  323. #define QIB_IB_TBL_VL_HIGH_ARB 1 /* Get/set VL high priority weights */
  324. #define QIB_IB_TBL_VL_LOW_ARB 2 /* Get/set VL low priority weights */
  325. /*
  326. * Possible "operations" for f_rcvctrl(ppd, op, ctxt)
  327. * these are bits so they can be combined, e.g.
  328. * QIB_RCVCTRL_INTRAVAIL_ENB | QIB_RCVCTRL_CTXT_ENB
  329. */
  330. #define QIB_RCVCTRL_TAILUPD_ENB 0x01
  331. #define QIB_RCVCTRL_TAILUPD_DIS 0x02
  332. #define QIB_RCVCTRL_CTXT_ENB 0x04
  333. #define QIB_RCVCTRL_CTXT_DIS 0x08
  334. #define QIB_RCVCTRL_INTRAVAIL_ENB 0x10
  335. #define QIB_RCVCTRL_INTRAVAIL_DIS 0x20
  336. #define QIB_RCVCTRL_PKEY_ENB 0x40 /* Note, default is enabled */
  337. #define QIB_RCVCTRL_PKEY_DIS 0x80
  338. #define QIB_RCVCTRL_BP_ENB 0x0100
  339. #define QIB_RCVCTRL_BP_DIS 0x0200
  340. #define QIB_RCVCTRL_TIDFLOW_ENB 0x0400
  341. #define QIB_RCVCTRL_TIDFLOW_DIS 0x0800
  342. /*
  343. * Possible "operations" for f_sendctrl(ppd, op, var)
  344. * these are bits so they can be combined, e.g.
  345. * QIB_SENDCTRL_BUFAVAIL_ENB | QIB_SENDCTRL_ENB
  346. * Some operations (e.g. DISARM, ABORT) are known to
  347. * be "one-shot", so do not modify shadow.
  348. */
  349. #define QIB_SENDCTRL_DISARM (0x1000)
  350. #define QIB_SENDCTRL_DISARM_BUF(bufn) ((bufn) | QIB_SENDCTRL_DISARM)
  351. /* available (0x2000) */
  352. #define QIB_SENDCTRL_AVAIL_DIS (0x4000)
  353. #define QIB_SENDCTRL_AVAIL_ENB (0x8000)
  354. #define QIB_SENDCTRL_AVAIL_BLIP (0x10000)
  355. #define QIB_SENDCTRL_SEND_DIS (0x20000)
  356. #define QIB_SENDCTRL_SEND_ENB (0x40000)
  357. #define QIB_SENDCTRL_FLUSH (0x80000)
  358. #define QIB_SENDCTRL_CLEAR (0x100000)
  359. #define QIB_SENDCTRL_DISARM_ALL (0x200000)
  360. /*
  361. * These are the generic indices for requesting per-port
  362. * counter values via the f_portcntr function. They
  363. * are always returned as 64 bit values, although most
  364. * are 32 bit counters.
  365. */
  366. /* send-related counters */
  367. #define QIBPORTCNTR_PKTSEND 0U
  368. #define QIBPORTCNTR_WORDSEND 1U
  369. #define QIBPORTCNTR_PSXMITDATA 2U
  370. #define QIBPORTCNTR_PSXMITPKTS 3U
  371. #define QIBPORTCNTR_PSXMITWAIT 4U
  372. #define QIBPORTCNTR_SENDSTALL 5U
  373. /* receive-related counters */
  374. #define QIBPORTCNTR_PKTRCV 6U
  375. #define QIBPORTCNTR_PSRCVDATA 7U
  376. #define QIBPORTCNTR_PSRCVPKTS 8U
  377. #define QIBPORTCNTR_RCVEBP 9U
  378. #define QIBPORTCNTR_RCVOVFL 10U
  379. #define QIBPORTCNTR_WORDRCV 11U
  380. /* IB link related error counters */
  381. #define QIBPORTCNTR_RXLOCALPHYERR 12U
  382. #define QIBPORTCNTR_RXVLERR 13U
  383. #define QIBPORTCNTR_ERRICRC 14U
  384. #define QIBPORTCNTR_ERRVCRC 15U
  385. #define QIBPORTCNTR_ERRLPCRC 16U
  386. #define QIBPORTCNTR_BADFORMAT 17U
  387. #define QIBPORTCNTR_ERR_RLEN 18U
  388. #define QIBPORTCNTR_IBSYMBOLERR 19U
  389. #define QIBPORTCNTR_INVALIDRLEN 20U
  390. #define QIBPORTCNTR_UNSUPVL 21U
  391. #define QIBPORTCNTR_EXCESSBUFOVFL 22U
  392. #define QIBPORTCNTR_ERRLINK 23U
  393. #define QIBPORTCNTR_IBLINKDOWN 24U
  394. #define QIBPORTCNTR_IBLINKERRRECOV 25U
  395. #define QIBPORTCNTR_LLI 26U
  396. /* other error counters */
  397. #define QIBPORTCNTR_RXDROPPKT 27U
  398. #define QIBPORTCNTR_VL15PKTDROP 28U
  399. #define QIBPORTCNTR_ERRPKEY 29U
  400. #define QIBPORTCNTR_KHDROVFL 30U
  401. /* sampling counters (these are actually control registers) */
  402. #define QIBPORTCNTR_PSINTERVAL 31U
  403. #define QIBPORTCNTR_PSSTART 32U
  404. #define QIBPORTCNTR_PSSTAT 33U
  405. /* how often we check for packet activity for "power on hours (in seconds) */
  406. #define ACTIVITY_TIMER 5
  407. #define MAX_NAME_SIZE 64
  408. #ifdef CONFIG_INFINIBAND_QIB_DCA
  409. struct qib_irq_notify;
  410. #endif
  411. struct qib_msix_entry {
  412. struct msix_entry msix;
  413. void *arg;
  414. #ifdef CONFIG_INFINIBAND_QIB_DCA
  415. int dca;
  416. int rcv;
  417. struct qib_irq_notify *notifier;
  418. #endif
  419. char name[MAX_NAME_SIZE];
  420. cpumask_var_t mask;
  421. };
  422. /* Below is an opaque struct. Each chip (device) can maintain
  423. * private data needed for its operation, but not germane to the
  424. * rest of the driver. For convenience, we define another that
  425. * is chip-specific, per-port
  426. */
  427. struct qib_chip_specific;
  428. struct qib_chipport_specific;
  429. enum qib_sdma_states {
  430. qib_sdma_state_s00_hw_down,
  431. qib_sdma_state_s10_hw_start_up_wait,
  432. qib_sdma_state_s20_idle,
  433. qib_sdma_state_s30_sw_clean_up_wait,
  434. qib_sdma_state_s40_hw_clean_up_wait,
  435. qib_sdma_state_s50_hw_halt_wait,
  436. qib_sdma_state_s99_running,
  437. };
  438. enum qib_sdma_events {
  439. qib_sdma_event_e00_go_hw_down,
  440. qib_sdma_event_e10_go_hw_start,
  441. qib_sdma_event_e20_hw_started,
  442. qib_sdma_event_e30_go_running,
  443. qib_sdma_event_e40_sw_cleaned,
  444. qib_sdma_event_e50_hw_cleaned,
  445. qib_sdma_event_e60_hw_halted,
  446. qib_sdma_event_e70_go_idle,
  447. qib_sdma_event_e7220_err_halted,
  448. qib_sdma_event_e7322_err_halted,
  449. qib_sdma_event_e90_timer_tick,
  450. };
  451. extern char *qib_sdma_state_names[];
  452. extern char *qib_sdma_event_names[];
  453. struct sdma_set_state_action {
  454. unsigned op_enable:1;
  455. unsigned op_intenable:1;
  456. unsigned op_halt:1;
  457. unsigned op_drain:1;
  458. unsigned go_s99_running_tofalse:1;
  459. unsigned go_s99_running_totrue:1;
  460. };
  461. struct qib_sdma_state {
  462. struct kref kref;
  463. struct completion comp;
  464. enum qib_sdma_states current_state;
  465. struct sdma_set_state_action *set_state_action;
  466. unsigned current_op;
  467. unsigned go_s99_running;
  468. unsigned first_sendbuf;
  469. unsigned last_sendbuf; /* really last +1 */
  470. /* debugging/devel */
  471. enum qib_sdma_states previous_state;
  472. unsigned previous_op;
  473. enum qib_sdma_events last_event;
  474. };
  475. struct xmit_wait {
  476. struct timer_list timer;
  477. u64 counter;
  478. u8 flags;
  479. struct cache {
  480. u64 psxmitdata;
  481. u64 psrcvdata;
  482. u64 psxmitpkts;
  483. u64 psrcvpkts;
  484. u64 psxmitwait;
  485. } counter_cache;
  486. };
  487. /*
  488. * The structure below encapsulates data relevant to a physical IB Port.
  489. * Current chips support only one such port, but the separation
  490. * clarifies things a bit. Note that to conform to IB conventions,
  491. * port-numbers are one-based. The first or only port is port1.
  492. */
  493. struct qib_pportdata {
  494. struct qib_ibport ibport_data;
  495. struct qib_devdata *dd;
  496. struct qib_chippport_specific *cpspec; /* chip-specific per-port */
  497. struct kobject pport_kobj;
  498. struct kobject pport_cc_kobj;
  499. struct kobject sl2vl_kobj;
  500. struct kobject diagc_kobj;
  501. /* GUID for this interface, in network order */
  502. __be64 guid;
  503. /* QIB_POLL, etc. link-state specific flags, per port */
  504. u32 lflags;
  505. /* qib_lflags driver is waiting for */
  506. u32 state_wanted;
  507. spinlock_t lflags_lock;
  508. /* ref count for each pkey */
  509. atomic_t pkeyrefs[4];
  510. /*
  511. * this address is mapped readonly into user processes so they can
  512. * get status cheaply, whenever they want. One qword of status per port
  513. */
  514. u64 *statusp;
  515. /* SendDMA related entries */
  516. /* read mostly */
  517. struct qib_sdma_desc *sdma_descq;
  518. struct workqueue_struct *qib_wq;
  519. struct qib_sdma_state sdma_state;
  520. dma_addr_t sdma_descq_phys;
  521. volatile __le64 *sdma_head_dma; /* DMA'ed by chip */
  522. dma_addr_t sdma_head_phys;
  523. u16 sdma_descq_cnt;
  524. /* read/write using lock */
  525. spinlock_t sdma_lock ____cacheline_aligned_in_smp;
  526. struct list_head sdma_activelist;
  527. struct list_head sdma_userpending;
  528. u64 sdma_descq_added;
  529. u64 sdma_descq_removed;
  530. u16 sdma_descq_tail;
  531. u16 sdma_descq_head;
  532. u8 sdma_generation;
  533. u8 sdma_intrequest;
  534. struct tasklet_struct sdma_sw_clean_up_task
  535. ____cacheline_aligned_in_smp;
  536. wait_queue_head_t state_wait; /* for state_wanted */
  537. /* HoL blocking for SMP replies */
  538. unsigned hol_state;
  539. struct timer_list hol_timer;
  540. /*
  541. * Shadow copies of registers; size indicates read access size.
  542. * Most of them are readonly, but some are write-only register,
  543. * where we manipulate the bits in the shadow copy, and then write
  544. * the shadow copy to qlogic_ib.
  545. *
  546. * We deliberately make most of these 32 bits, since they have
  547. * restricted range. For any that we read, we won't to generate 32
  548. * bit accesses, since Opteron will generate 2 separate 32 bit HT
  549. * transactions for a 64 bit read, and we want to avoid unnecessary
  550. * bus transactions.
  551. */
  552. /* This is the 64 bit group */
  553. /* last ibcstatus. opaque outside chip-specific code */
  554. u64 lastibcstat;
  555. /* these are the "32 bit" regs */
  556. /*
  557. * the following two are 32-bit bitmasks, but {test,clear,set}_bit
  558. * all expect bit fields to be "unsigned long"
  559. */
  560. unsigned long p_rcvctrl; /* shadow per-port rcvctrl */
  561. unsigned long p_sendctrl; /* shadow per-port sendctrl */
  562. u32 ibmtu; /* The MTU programmed for this unit */
  563. /*
  564. * Current max size IB packet (in bytes) including IB headers, that
  565. * we can send. Changes when ibmtu changes.
  566. */
  567. u32 ibmaxlen;
  568. /*
  569. * ibmaxlen at init time, limited by chip and by receive buffer
  570. * size. Not changed after init.
  571. */
  572. u32 init_ibmaxlen;
  573. /* LID programmed for this instance */
  574. u16 lid;
  575. /* list of pkeys programmed; 0 if not set */
  576. u16 pkeys[4];
  577. /* LID mask control */
  578. u8 lmc;
  579. u8 link_width_supported;
  580. u8 link_speed_supported;
  581. u8 link_width_enabled;
  582. u8 link_speed_enabled;
  583. u8 link_width_active;
  584. u8 link_speed_active;
  585. u8 vls_supported;
  586. u8 vls_operational;
  587. /* Rx Polarity inversion (compensate for ~tx on partner) */
  588. u8 rx_pol_inv;
  589. u8 hw_pidx; /* physical port index */
  590. u8 port; /* IB port number and index into dd->pports - 1 */
  591. u8 delay_mult;
  592. /* used to override LED behavior */
  593. u8 led_override; /* Substituted for normal value, if non-zero */
  594. u16 led_override_timeoff; /* delta to next timer event */
  595. u8 led_override_vals[2]; /* Alternates per blink-frame */
  596. u8 led_override_phase; /* Just counts, LSB picks from vals[] */
  597. atomic_t led_override_timer_active;
  598. /* Used to flash LEDs in override mode */
  599. struct timer_list led_override_timer;
  600. struct xmit_wait cong_stats;
  601. struct timer_list symerr_clear_timer;
  602. /* Synchronize access between driver writes and sysfs reads */
  603. spinlock_t cc_shadow_lock
  604. ____cacheline_aligned_in_smp;
  605. /* Shadow copy of the congestion control table */
  606. struct cc_table_shadow *ccti_entries_shadow;
  607. /* Shadow copy of the congestion control entries */
  608. struct ib_cc_congestion_setting_attr_shadow *congestion_entries_shadow;
  609. /* List of congestion control table entries */
  610. struct ib_cc_table_entry_shadow *ccti_entries;
  611. /* 16 congestion entries with each entry corresponding to a SL */
  612. struct ib_cc_congestion_entry_shadow *congestion_entries;
  613. /* Maximum number of congestion control entries that the agent expects
  614. * the manager to send.
  615. */
  616. u16 cc_supported_table_entries;
  617. /* Total number of congestion control table entries */
  618. u16 total_cct_entry;
  619. /* Bit map identifying service level */
  620. u16 cc_sl_control_map;
  621. /* maximum congestion control table index */
  622. u16 ccti_limit;
  623. /* CA's max number of 64 entry units in the congestion control table */
  624. u8 cc_max_table_entries;
  625. };
  626. /* Observers. Not to be taken lightly, possibly not to ship. */
  627. /*
  628. * If a diag read or write is to (bottom <= offset <= top),
  629. * the "hoook" is called, allowing, e.g. shadows to be
  630. * updated in sync with the driver. struct diag_observer
  631. * is the "visible" part.
  632. */
  633. struct diag_observer;
  634. typedef int (*diag_hook) (struct qib_devdata *dd,
  635. const struct diag_observer *op,
  636. u32 offs, u64 *data, u64 mask, int only_32);
  637. struct diag_observer {
  638. diag_hook hook;
  639. u32 bottom;
  640. u32 top;
  641. };
  642. extern int qib_register_observer(struct qib_devdata *dd,
  643. const struct diag_observer *op);
  644. /* Only declared here, not defined. Private to diags */
  645. struct diag_observer_list_elt;
  646. /* device data struct now contains only "general per-device" info.
  647. * fields related to a physical IB port are in a qib_pportdata struct,
  648. * described above) while fields only used by a particular chip-type are in
  649. * a qib_chipdata struct, whose contents are opaque to this file.
  650. */
  651. struct qib_devdata {
  652. struct qib_ibdev verbs_dev; /* must be first */
  653. struct list_head list;
  654. /* pointers to related structs for this device */
  655. /* pci access data structure */
  656. struct pci_dev *pcidev;
  657. struct cdev *user_cdev;
  658. struct cdev *diag_cdev;
  659. struct device *user_device;
  660. struct device *diag_device;
  661. /* mem-mapped pointer to base of chip regs */
  662. u64 __iomem *kregbase;
  663. /* end of mem-mapped chip space excluding sendbuf and user regs */
  664. u64 __iomem *kregend;
  665. /* physical address of chip for io_remap, etc. */
  666. resource_size_t physaddr;
  667. /* qib_cfgctxts pointers */
  668. struct qib_ctxtdata **rcd; /* Receive Context Data */
  669. /* qib_pportdata, points to array of (physical) port-specific
  670. * data structs, indexed by pidx (0..n-1)
  671. */
  672. struct qib_pportdata *pport;
  673. struct qib_chip_specific *cspec; /* chip-specific */
  674. /* kvirt address of 1st 2k pio buffer */
  675. void __iomem *pio2kbase;
  676. /* kvirt address of 1st 4k pio buffer */
  677. void __iomem *pio4kbase;
  678. /* mem-mapped pointer to base of PIO buffers (if using WC PAT) */
  679. void __iomem *piobase;
  680. /* mem-mapped pointer to base of user chip regs (if using WC PAT) */
  681. u64 __iomem *userbase;
  682. void __iomem *piovl15base; /* base of VL15 buffers, if not WC */
  683. /*
  684. * points to area where PIOavail registers will be DMA'ed.
  685. * Has to be on a page of it's own, because the page will be
  686. * mapped into user program space. This copy is *ONLY* ever
  687. * written by DMA, not by the driver! Need a copy per device
  688. * when we get to multiple devices
  689. */
  690. volatile __le64 *pioavailregs_dma; /* DMA'ed by chip */
  691. /* physical address where updates occur */
  692. dma_addr_t pioavailregs_phys;
  693. /* device-specific implementations of functions needed by
  694. * common code. Contrary to previous consensus, we can't
  695. * really just point to a device-specific table, because we
  696. * may need to "bend", e.g. *_f_put_tid
  697. */
  698. /* fallback to alternate interrupt type if possible */
  699. int (*f_intr_fallback)(struct qib_devdata *);
  700. /* hard reset chip */
  701. int (*f_reset)(struct qib_devdata *);
  702. void (*f_quiet_serdes)(struct qib_pportdata *);
  703. int (*f_bringup_serdes)(struct qib_pportdata *);
  704. int (*f_early_init)(struct qib_devdata *);
  705. void (*f_clear_tids)(struct qib_devdata *, struct qib_ctxtdata *);
  706. void (*f_put_tid)(struct qib_devdata *, u64 __iomem*,
  707. u32, unsigned long);
  708. void (*f_cleanup)(struct qib_devdata *);
  709. void (*f_setextled)(struct qib_pportdata *, u32);
  710. /* fill out chip-specific fields */
  711. int (*f_get_base_info)(struct qib_ctxtdata *, struct qib_base_info *);
  712. /* free irq */
  713. void (*f_free_irq)(struct qib_devdata *);
  714. struct qib_message_header *(*f_get_msgheader)
  715. (struct qib_devdata *, __le32 *);
  716. void (*f_config_ctxts)(struct qib_devdata *);
  717. int (*f_get_ib_cfg)(struct qib_pportdata *, int);
  718. int (*f_set_ib_cfg)(struct qib_pportdata *, int, u32);
  719. int (*f_set_ib_loopback)(struct qib_pportdata *, const char *);
  720. int (*f_get_ib_table)(struct qib_pportdata *, int, void *);
  721. int (*f_set_ib_table)(struct qib_pportdata *, int, void *);
  722. u32 (*f_iblink_state)(u64);
  723. u8 (*f_ibphys_portstate)(u64);
  724. void (*f_xgxs_reset)(struct qib_pportdata *);
  725. /* per chip actions needed for IB Link up/down changes */
  726. int (*f_ib_updown)(struct qib_pportdata *, int, u64);
  727. u32 __iomem *(*f_getsendbuf)(struct qib_pportdata *, u64, u32 *);
  728. /* Read/modify/write of GPIO pins (potentially chip-specific */
  729. int (*f_gpio_mod)(struct qib_devdata *dd, u32 out, u32 dir,
  730. u32 mask);
  731. /* Enable writes to config EEPROM (if supported) */
  732. int (*f_eeprom_wen)(struct qib_devdata *dd, int wen);
  733. /*
  734. * modify rcvctrl shadow[s] and write to appropriate chip-regs.
  735. * see above QIB_RCVCTRL_xxx_ENB/DIS for operations.
  736. * (ctxt == -1) means "all contexts", only meaningful for
  737. * clearing. Could remove if chip_spec shutdown properly done.
  738. */
  739. void (*f_rcvctrl)(struct qib_pportdata *, unsigned int op,
  740. int ctxt);
  741. /* Read/modify/write sendctrl appropriately for op and port. */
  742. void (*f_sendctrl)(struct qib_pportdata *, u32 op);
  743. void (*f_set_intr_state)(struct qib_devdata *, u32);
  744. void (*f_set_armlaunch)(struct qib_devdata *, u32);
  745. void (*f_wantpiobuf_intr)(struct qib_devdata *, u32);
  746. int (*f_late_initreg)(struct qib_devdata *);
  747. int (*f_init_sdma_regs)(struct qib_pportdata *);
  748. u16 (*f_sdma_gethead)(struct qib_pportdata *);
  749. int (*f_sdma_busy)(struct qib_pportdata *);
  750. void (*f_sdma_update_tail)(struct qib_pportdata *, u16);
  751. void (*f_sdma_set_desc_cnt)(struct qib_pportdata *, unsigned);
  752. void (*f_sdma_sendctrl)(struct qib_pportdata *, unsigned);
  753. void (*f_sdma_hw_clean_up)(struct qib_pportdata *);
  754. void (*f_sdma_hw_start_up)(struct qib_pportdata *);
  755. void (*f_sdma_init_early)(struct qib_pportdata *);
  756. void (*f_set_cntr_sample)(struct qib_pportdata *, u32, u32);
  757. void (*f_update_usrhead)(struct qib_ctxtdata *, u64, u32, u32, u32);
  758. u32 (*f_hdrqempty)(struct qib_ctxtdata *);
  759. u64 (*f_portcntr)(struct qib_pportdata *, u32);
  760. u32 (*f_read_cntrs)(struct qib_devdata *, loff_t, char **,
  761. u64 **);
  762. u32 (*f_read_portcntrs)(struct qib_devdata *, loff_t, u32,
  763. char **, u64 **);
  764. u32 (*f_setpbc_control)(struct qib_pportdata *, u32, u8, u8);
  765. void (*f_initvl15_bufs)(struct qib_devdata *);
  766. void (*f_init_ctxt)(struct qib_ctxtdata *);
  767. void (*f_txchk_change)(struct qib_devdata *, u32, u32, u32,
  768. struct qib_ctxtdata *);
  769. void (*f_writescratch)(struct qib_devdata *, u32);
  770. int (*f_tempsense_rd)(struct qib_devdata *, int regnum);
  771. #ifdef CONFIG_INFINIBAND_QIB_DCA
  772. int (*f_notify_dca)(struct qib_devdata *, unsigned long event);
  773. #endif
  774. char *boardname; /* human readable board info */
  775. /* template for writing TIDs */
  776. u64 tidtemplate;
  777. /* value to write to free TIDs */
  778. u64 tidinvalid;
  779. /* number of registers used for pioavail */
  780. u32 pioavregs;
  781. /* device (not port) flags, basically device capabilities */
  782. u32 flags;
  783. /* last buffer for user use */
  784. u32 lastctxt_piobuf;
  785. /* reset value */
  786. u64 z_int_counter;
  787. /* percpu intcounter */
  788. u64 __percpu *int_counter;
  789. /* pio bufs allocated per ctxt */
  790. u32 pbufsctxt;
  791. /* if remainder on bufs/ctxt, ctxts < extrabuf get 1 extra */
  792. u32 ctxts_extrabuf;
  793. /*
  794. * number of ctxts configured as max; zero is set to number chip
  795. * supports, less gives more pio bufs/ctxt, etc.
  796. */
  797. u32 cfgctxts;
  798. /*
  799. * number of ctxts available for PSM open
  800. */
  801. u32 freectxts;
  802. /*
  803. * hint that we should update pioavailshadow before
  804. * looking for a PIO buffer
  805. */
  806. u32 upd_pio_shadow;
  807. /* internal debugging stats */
  808. u32 maxpkts_call;
  809. u32 avgpkts_call;
  810. u64 nopiobufs;
  811. /* PCI Vendor ID (here for NodeInfo) */
  812. u16 vendorid;
  813. /* PCI Device ID (here for NodeInfo) */
  814. u16 deviceid;
  815. /* for write combining settings */
  816. int wc_cookie;
  817. unsigned long wc_base;
  818. unsigned long wc_len;
  819. /* shadow copy of struct page *'s for exp tid pages */
  820. struct page **pageshadow;
  821. /* shadow copy of dma handles for exp tid pages */
  822. dma_addr_t *physshadow;
  823. u64 __iomem *egrtidbase;
  824. spinlock_t sendctrl_lock; /* protect changes to sendctrl shadow */
  825. /* around rcd and (user ctxts) ctxt_cnt use (intr vs free) */
  826. spinlock_t uctxt_lock; /* rcd and user context changes */
  827. /*
  828. * per unit status, see also portdata statusp
  829. * mapped readonly into user processes so they can get unit and
  830. * IB link status cheaply
  831. */
  832. u64 *devstatusp;
  833. char *freezemsg; /* freeze msg if hw error put chip in freeze */
  834. u32 freezelen; /* max length of freezemsg */
  835. /* timer used to prevent stats overflow, error throttling, etc. */
  836. struct timer_list stats_timer;
  837. /* timer to verify interrupts work, and fallback if possible */
  838. struct timer_list intrchk_timer;
  839. unsigned long ureg_align; /* user register alignment */
  840. /*
  841. * Protects pioavailshadow, pioavailkernel, pio_need_disarm, and
  842. * pio_writing.
  843. */
  844. spinlock_t pioavail_lock;
  845. /*
  846. * index of last buffer to optimize search for next
  847. */
  848. u32 last_pio;
  849. /*
  850. * min kernel pio buffer to optimize search
  851. */
  852. u32 min_kernel_pio;
  853. /*
  854. * Shadow copies of registers; size indicates read access size.
  855. * Most of them are readonly, but some are write-only register,
  856. * where we manipulate the bits in the shadow copy, and then write
  857. * the shadow copy to qlogic_ib.
  858. *
  859. * We deliberately make most of these 32 bits, since they have
  860. * restricted range. For any that we read, we won't to generate 32
  861. * bit accesses, since Opteron will generate 2 separate 32 bit HT
  862. * transactions for a 64 bit read, and we want to avoid unnecessary
  863. * bus transactions.
  864. */
  865. /* This is the 64 bit group */
  866. unsigned long pioavailshadow[6];
  867. /* bitmap of send buffers available for the kernel to use with PIO. */
  868. unsigned long pioavailkernel[6];
  869. /* bitmap of send buffers which need to be disarmed. */
  870. unsigned long pio_need_disarm[3];
  871. /* bitmap of send buffers which are being written to. */
  872. unsigned long pio_writing[3];
  873. /* kr_revision shadow */
  874. u64 revision;
  875. /* Base GUID for device (from eeprom, network order) */
  876. __be64 base_guid;
  877. /*
  878. * kr_sendpiobufbase value (chip offset of pio buffers), and the
  879. * base of the 2KB buffer s(user processes only use 2K)
  880. */
  881. u64 piobufbase;
  882. u32 pio2k_bufbase;
  883. /* these are the "32 bit" regs */
  884. /* number of GUIDs in the flash for this interface */
  885. u32 nguid;
  886. /*
  887. * the following two are 32-bit bitmasks, but {test,clear,set}_bit
  888. * all expect bit fields to be "unsigned long"
  889. */
  890. unsigned long rcvctrl; /* shadow per device rcvctrl */
  891. unsigned long sendctrl; /* shadow per device sendctrl */
  892. /* value we put in kr_rcvhdrcnt */
  893. u32 rcvhdrcnt;
  894. /* value we put in kr_rcvhdrsize */
  895. u32 rcvhdrsize;
  896. /* value we put in kr_rcvhdrentsize */
  897. u32 rcvhdrentsize;
  898. /* kr_ctxtcnt value */
  899. u32 ctxtcnt;
  900. /* kr_pagealign value */
  901. u32 palign;
  902. /* number of "2KB" PIO buffers */
  903. u32 piobcnt2k;
  904. /* size in bytes of "2KB" PIO buffers */
  905. u32 piosize2k;
  906. /* max usable size in dwords of a "2KB" PIO buffer before going "4KB" */
  907. u32 piosize2kmax_dwords;
  908. /* number of "4KB" PIO buffers */
  909. u32 piobcnt4k;
  910. /* size in bytes of "4KB" PIO buffers */
  911. u32 piosize4k;
  912. /* kr_rcvegrbase value */
  913. u32 rcvegrbase;
  914. /* kr_rcvtidbase value */
  915. u32 rcvtidbase;
  916. /* kr_rcvtidcnt value */
  917. u32 rcvtidcnt;
  918. /* kr_userregbase */
  919. u32 uregbase;
  920. /* shadow the control register contents */
  921. u32 control;
  922. /* chip address space used by 4k pio buffers */
  923. u32 align4k;
  924. /* size of each rcvegrbuffer */
  925. u16 rcvegrbufsize;
  926. /* log2 of above */
  927. u16 rcvegrbufsize_shift;
  928. /* localbus width (1, 2,4,8,16,32) from config space */
  929. u32 lbus_width;
  930. /* localbus speed in MHz */
  931. u32 lbus_speed;
  932. int unit; /* unit # of this chip */
  933. /* start of CHIP_SPEC move to chipspec, but need code changes */
  934. /* low and high portions of MSI capability/vector */
  935. u32 msi_lo;
  936. /* saved after PCIe init for restore after reset */
  937. u32 msi_hi;
  938. /* MSI data (vector) saved for restore */
  939. u16 msi_data;
  940. /* so we can rewrite it after a chip reset */
  941. u32 pcibar0;
  942. /* so we can rewrite it after a chip reset */
  943. u32 pcibar1;
  944. u64 rhdrhead_intr_off;
  945. /*
  946. * ASCII serial number, from flash, large enough for original
  947. * all digit strings, and longer QLogic serial number format
  948. */
  949. u8 serial[16];
  950. /* human readable board version */
  951. u8 boardversion[96];
  952. u8 lbus_info[32]; /* human readable localbus info */
  953. /* chip major rev, from qib_revision */
  954. u8 majrev;
  955. /* chip minor rev, from qib_revision */
  956. u8 minrev;
  957. /* Misc small ints */
  958. /* Number of physical ports available */
  959. u8 num_pports;
  960. /* Lowest context number which can be used by user processes */
  961. u8 first_user_ctxt;
  962. u8 n_krcv_queues;
  963. u8 qpn_mask;
  964. u8 skip_kctxt_mask;
  965. u16 rhf_offset; /* offset of RHF within receive header entry */
  966. /*
  967. * GPIO pins for twsi-connected devices, and device code for eeprom
  968. */
  969. u8 gpio_sda_num;
  970. u8 gpio_scl_num;
  971. u8 twsi_eeprom_dev;
  972. u8 board_atten;
  973. /* Support (including locks) for EEPROM logging of errors and time */
  974. /* control access to actual counters, timer */
  975. spinlock_t eep_st_lock;
  976. /* control high-level access to EEPROM */
  977. struct mutex eep_lock;
  978. uint64_t traffic_wds;
  979. /*
  980. * masks for which bits of errs, hwerrs that cause
  981. * each of the counters to increment.
  982. */
  983. struct qib_eep_log_mask eep_st_masks[QIB_EEP_LOG_CNT];
  984. struct qib_diag_client *diag_client;
  985. spinlock_t qib_diag_trans_lock; /* protect diag observer ops */
  986. struct diag_observer_list_elt *diag_observer_list;
  987. u8 psxmitwait_supported;
  988. /* cycle length of PS* counters in HW (in picoseconds) */
  989. u16 psxmitwait_check_rate;
  990. /* high volume overflow errors defered to tasklet */
  991. struct tasklet_struct error_tasklet;
  992. int assigned_node_id; /* NUMA node closest to HCA */
  993. };
  994. /* hol_state values */
  995. #define QIB_HOL_UP 0
  996. #define QIB_HOL_INIT 1
  997. #define QIB_SDMA_SENDCTRL_OP_ENABLE (1U << 0)
  998. #define QIB_SDMA_SENDCTRL_OP_INTENABLE (1U << 1)
  999. #define QIB_SDMA_SENDCTRL_OP_HALT (1U << 2)
  1000. #define QIB_SDMA_SENDCTRL_OP_CLEANUP (1U << 3)
  1001. #define QIB_SDMA_SENDCTRL_OP_DRAIN (1U << 4)
  1002. /* operation types for f_txchk_change() */
  1003. #define TXCHK_CHG_TYPE_DIS1 3
  1004. #define TXCHK_CHG_TYPE_ENAB1 2
  1005. #define TXCHK_CHG_TYPE_KERN 1
  1006. #define TXCHK_CHG_TYPE_USER 0
  1007. #define QIB_CHASE_TIME msecs_to_jiffies(145)
  1008. #define QIB_CHASE_DIS_TIME msecs_to_jiffies(160)
  1009. /* Private data for file operations */
  1010. struct qib_filedata {
  1011. struct qib_ctxtdata *rcd;
  1012. unsigned subctxt;
  1013. unsigned tidcursor;
  1014. struct qib_user_sdma_queue *pq;
  1015. int rec_cpu_num; /* for cpu affinity; -1 if none */
  1016. };
  1017. extern struct list_head qib_dev_list;
  1018. extern spinlock_t qib_devs_lock;
  1019. extern struct qib_devdata *qib_lookup(int unit);
  1020. extern u32 qib_cpulist_count;
  1021. extern unsigned long *qib_cpulist;
  1022. extern unsigned qib_cc_table_size;
  1023. int qib_init(struct qib_devdata *, int);
  1024. int init_chip_wc_pat(struct qib_devdata *dd, u32);
  1025. int qib_enable_wc(struct qib_devdata *dd);
  1026. void qib_disable_wc(struct qib_devdata *dd);
  1027. int qib_count_units(int *npresentp, int *nupp);
  1028. int qib_count_active_units(void);
  1029. int qib_cdev_init(int minor, const char *name,
  1030. const struct file_operations *fops,
  1031. struct cdev **cdevp, struct device **devp);
  1032. void qib_cdev_cleanup(struct cdev **cdevp, struct device **devp);
  1033. int qib_dev_init(void);
  1034. void qib_dev_cleanup(void);
  1035. int qib_diag_add(struct qib_devdata *);
  1036. void qib_diag_remove(struct qib_devdata *);
  1037. void qib_handle_e_ibstatuschanged(struct qib_pportdata *, u64);
  1038. void qib_sdma_update_tail(struct qib_pportdata *, u16); /* hold sdma_lock */
  1039. int qib_decode_err(struct qib_devdata *dd, char *buf, size_t blen, u64 err);
  1040. void qib_bad_intrstatus(struct qib_devdata *);
  1041. void qib_handle_urcv(struct qib_devdata *, u64);
  1042. /* clean up any per-chip chip-specific stuff */
  1043. void qib_chip_cleanup(struct qib_devdata *);
  1044. /* clean up any chip type-specific stuff */
  1045. void qib_chip_done(void);
  1046. /* check to see if we have to force ordering for write combining */
  1047. int qib_unordered_wc(void);
  1048. void qib_pio_copy(void __iomem *to, const void *from, size_t count);
  1049. void qib_disarm_piobufs(struct qib_devdata *, unsigned, unsigned);
  1050. int qib_disarm_piobufs_ifneeded(struct qib_ctxtdata *);
  1051. void qib_disarm_piobufs_set(struct qib_devdata *, unsigned long *, unsigned);
  1052. void qib_cancel_sends(struct qib_pportdata *);
  1053. int qib_create_rcvhdrq(struct qib_devdata *, struct qib_ctxtdata *);
  1054. int qib_setup_eagerbufs(struct qib_ctxtdata *);
  1055. void qib_set_ctxtcnt(struct qib_devdata *);
  1056. int qib_create_ctxts(struct qib_devdata *dd);
  1057. struct qib_ctxtdata *qib_create_ctxtdata(struct qib_pportdata *, u32, int);
  1058. int qib_init_pportdata(struct qib_pportdata *, struct qib_devdata *, u8, u8);
  1059. void qib_free_ctxtdata(struct qib_devdata *, struct qib_ctxtdata *);
  1060. u32 qib_kreceive(struct qib_ctxtdata *, u32 *, u32 *);
  1061. int qib_reset_device(int);
  1062. int qib_wait_linkstate(struct qib_pportdata *, u32, int);
  1063. int qib_set_linkstate(struct qib_pportdata *, u8);
  1064. int qib_set_mtu(struct qib_pportdata *, u16);
  1065. int qib_set_lid(struct qib_pportdata *, u32, u8);
  1066. void qib_hol_down(struct qib_pportdata *);
  1067. void qib_hol_init(struct qib_pportdata *);
  1068. void qib_hol_up(struct qib_pportdata *);
  1069. void qib_hol_event(unsigned long);
  1070. void qib_disable_after_error(struct qib_devdata *);
  1071. int qib_set_uevent_bits(struct qib_pportdata *, const int);
  1072. /* for use in system calls, where we want to know device type, etc. */
  1073. #define ctxt_fp(fp) \
  1074. (((struct qib_filedata *)(fp)->private_data)->rcd)
  1075. #define subctxt_fp(fp) \
  1076. (((struct qib_filedata *)(fp)->private_data)->subctxt)
  1077. #define tidcursor_fp(fp) \
  1078. (((struct qib_filedata *)(fp)->private_data)->tidcursor)
  1079. #define user_sdma_queue_fp(fp) \
  1080. (((struct qib_filedata *)(fp)->private_data)->pq)
  1081. static inline struct qib_devdata *dd_from_ppd(struct qib_pportdata *ppd)
  1082. {
  1083. return ppd->dd;
  1084. }
  1085. static inline struct qib_devdata *dd_from_dev(struct qib_ibdev *dev)
  1086. {
  1087. return container_of(dev, struct qib_devdata, verbs_dev);
  1088. }
  1089. static inline struct qib_devdata *dd_from_ibdev(struct ib_device *ibdev)
  1090. {
  1091. return dd_from_dev(to_idev(ibdev));
  1092. }
  1093. static inline struct qib_pportdata *ppd_from_ibp(struct qib_ibport *ibp)
  1094. {
  1095. return container_of(ibp, struct qib_pportdata, ibport_data);
  1096. }
  1097. static inline struct qib_ibport *to_iport(struct ib_device *ibdev, u8 port)
  1098. {
  1099. struct qib_devdata *dd = dd_from_ibdev(ibdev);
  1100. unsigned pidx = port - 1; /* IB number port from 1, hdw from 0 */
  1101. WARN_ON(pidx >= dd->num_pports);
  1102. return &dd->pport[pidx].ibport_data;
  1103. }
  1104. /*
  1105. * values for dd->flags (_device_ related flags) and
  1106. */
  1107. #define QIB_HAS_LINK_LATENCY 0x1 /* supports link latency (IB 1.2) */
  1108. #define QIB_INITTED 0x2 /* chip and driver up and initted */
  1109. #define QIB_DOING_RESET 0x4 /* in the middle of doing chip reset */
  1110. #define QIB_PRESENT 0x8 /* chip accesses can be done */
  1111. #define QIB_PIO_FLUSH_WC 0x10 /* Needs Write combining flush for PIO */
  1112. #define QIB_HAS_THRESH_UPDATE 0x40
  1113. #define QIB_HAS_SDMA_TIMEOUT 0x80
  1114. #define QIB_USE_SPCL_TRIG 0x100 /* SpecialTrigger launch enabled */
  1115. #define QIB_NODMA_RTAIL 0x200 /* rcvhdrtail register DMA enabled */
  1116. #define QIB_HAS_INTX 0x800 /* Supports INTx interrupts */
  1117. #define QIB_HAS_SEND_DMA 0x1000 /* Supports Send DMA */
  1118. #define QIB_HAS_VLSUPP 0x2000 /* Supports multiple VLs; PBC different */
  1119. #define QIB_HAS_HDRSUPP 0x4000 /* Supports header suppression */
  1120. #define QIB_BADINTR 0x8000 /* severe interrupt problems */
  1121. #define QIB_DCA_ENABLED 0x10000 /* Direct Cache Access enabled */
  1122. #define QIB_HAS_QSFP 0x20000 /* device (card instance) has QSFP */
  1123. /*
  1124. * values for ppd->lflags (_ib_port_ related flags)
  1125. */
  1126. #define QIBL_LINKV 0x1 /* IB link state valid */
  1127. #define QIBL_LINKDOWN 0x8 /* IB link is down */
  1128. #define QIBL_LINKINIT 0x10 /* IB link level is up */
  1129. #define QIBL_LINKARMED 0x20 /* IB link is ARMED */
  1130. #define QIBL_LINKACTIVE 0x40 /* IB link is ACTIVE */
  1131. /* leave a gap for more IB-link state */
  1132. #define QIBL_IB_AUTONEG_INPROG 0x1000 /* non-IBTA DDR/QDR neg active */
  1133. #define QIBL_IB_AUTONEG_FAILED 0x2000 /* non-IBTA DDR/QDR neg failed */
  1134. #define QIBL_IB_LINK_DISABLED 0x4000 /* Linkdown-disable forced,
  1135. * Do not try to bring up */
  1136. #define QIBL_IB_FORCE_NOTIFY 0x8000 /* force notify on next ib change */
  1137. /* IB dword length mask in PBC (lower 11 bits); same for all chips */
  1138. #define QIB_PBC_LENGTH_MASK ((1 << 11) - 1)
  1139. /* ctxt_flag bit offsets */
  1140. /* waiting for a packet to arrive */
  1141. #define QIB_CTXT_WAITING_RCV 2
  1142. /* master has not finished initializing */
  1143. #define QIB_CTXT_MASTER_UNINIT 4
  1144. /* waiting for an urgent packet to arrive */
  1145. #define QIB_CTXT_WAITING_URG 5
  1146. /* free up any allocated data at closes */
  1147. void qib_free_data(struct qib_ctxtdata *dd);
  1148. void qib_chg_pioavailkernel(struct qib_devdata *, unsigned, unsigned,
  1149. u32, struct qib_ctxtdata *);
  1150. struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *,
  1151. const struct pci_device_id *);
  1152. struct qib_devdata *qib_init_iba7220_funcs(struct pci_dev *,
  1153. const struct pci_device_id *);
  1154. struct qib_devdata *qib_init_iba6120_funcs(struct pci_dev *,
  1155. const struct pci_device_id *);
  1156. void qib_free_devdata(struct qib_devdata *);
  1157. struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra);
  1158. #define QIB_TWSI_NO_DEV 0xFF
  1159. /* Below qib_twsi_ functions must be called with eep_lock held */
  1160. int qib_twsi_reset(struct qib_devdata *dd);
  1161. int qib_twsi_blk_rd(struct qib_devdata *dd, int dev, int addr, void *buffer,
  1162. int len);
  1163. int qib_twsi_blk_wr(struct qib_devdata *dd, int dev, int addr,
  1164. const void *buffer, int len);
  1165. void qib_get_eeprom_info(struct qib_devdata *);
  1166. #define qib_inc_eeprom_err(dd, eidx, incr)
  1167. void qib_dump_lookup_output_queue(struct qib_devdata *);
  1168. void qib_force_pio_avail_update(struct qib_devdata *);
  1169. void qib_clear_symerror_on_linkup(unsigned long opaque);
  1170. /*
  1171. * Set LED override, only the two LSBs have "public" meaning, but
  1172. * any non-zero value substitutes them for the Link and LinkTrain
  1173. * LED states.
  1174. */
  1175. #define QIB_LED_PHYS 1 /* Physical (linktraining) GREEN LED */
  1176. #define QIB_LED_LOG 2 /* Logical (link) YELLOW LED */
  1177. void qib_set_led_override(struct qib_pportdata *ppd, unsigned int val);
  1178. /* send dma routines */
  1179. int qib_setup_sdma(struct qib_pportdata *);
  1180. void qib_teardown_sdma(struct qib_pportdata *);
  1181. void __qib_sdma_intr(struct qib_pportdata *);
  1182. void qib_sdma_intr(struct qib_pportdata *);
  1183. void qib_user_sdma_send_desc(struct qib_pportdata *dd,
  1184. struct list_head *pktlist);
  1185. int qib_sdma_verbs_send(struct qib_pportdata *, struct rvt_sge_state *,
  1186. u32, struct qib_verbs_txreq *);
  1187. /* ppd->sdma_lock should be locked before calling this. */
  1188. int qib_sdma_make_progress(struct qib_pportdata *dd);
  1189. static inline int qib_sdma_empty(const struct qib_pportdata *ppd)
  1190. {
  1191. return ppd->sdma_descq_added == ppd->sdma_descq_removed;
  1192. }
  1193. /* must be called under qib_sdma_lock */
  1194. static inline u16 qib_sdma_descq_freecnt(const struct qib_pportdata *ppd)
  1195. {
  1196. return ppd->sdma_descq_cnt -
  1197. (ppd->sdma_descq_added - ppd->sdma_descq_removed) - 1;
  1198. }
  1199. static inline int __qib_sdma_running(struct qib_pportdata *ppd)
  1200. {
  1201. return ppd->sdma_state.current_state == qib_sdma_state_s99_running;
  1202. }
  1203. int qib_sdma_running(struct qib_pportdata *);
  1204. void dump_sdma_state(struct qib_pportdata *ppd);
  1205. void __qib_sdma_process_event(struct qib_pportdata *, enum qib_sdma_events);
  1206. void qib_sdma_process_event(struct qib_pportdata *, enum qib_sdma_events);
  1207. /*
  1208. * number of words used for protocol header if not set by qib_userinit();
  1209. */
  1210. #define QIB_DFLT_RCVHDRSIZE 9
  1211. /*
  1212. * We need to be able to handle an IB header of at least 24 dwords.
  1213. * We need the rcvhdrq large enough to handle largest IB header, but
  1214. * still have room for a 2KB MTU standard IB packet.
  1215. * Additionally, some processor/memory controller combinations
  1216. * benefit quite strongly from having the DMA'ed data be cacheline
  1217. * aligned and a cacheline multiple, so we set the size to 32 dwords
  1218. * (2 64-byte primary cachelines for pretty much all processors of
  1219. * interest). The alignment hurts nothing, other than using somewhat
  1220. * more memory.
  1221. */
  1222. #define QIB_RCVHDR_ENTSIZE 32
  1223. int qib_get_user_pages(unsigned long, size_t, struct page **);
  1224. void qib_release_user_pages(struct page **, size_t);
  1225. int qib_eeprom_read(struct qib_devdata *, u8, void *, int);
  1226. int qib_eeprom_write(struct qib_devdata *, u8, const void *, int);
  1227. u32 __iomem *qib_getsendbuf_range(struct qib_devdata *, u32 *, u32, u32);
  1228. void qib_sendbuf_done(struct qib_devdata *, unsigned);
  1229. static inline void qib_clear_rcvhdrtail(const struct qib_ctxtdata *rcd)
  1230. {
  1231. *((u64 *) rcd->rcvhdrtail_kvaddr) = 0ULL;
  1232. }
  1233. static inline u32 qib_get_rcvhdrtail(const struct qib_ctxtdata *rcd)
  1234. {
  1235. /*
  1236. * volatile because it's a DMA target from the chip, routine is
  1237. * inlined, and don't want register caching or reordering.
  1238. */
  1239. return (u32) le64_to_cpu(
  1240. *((volatile __le64 *)rcd->rcvhdrtail_kvaddr)); /* DMA'ed */
  1241. }
  1242. static inline u32 qib_get_hdrqtail(const struct qib_ctxtdata *rcd)
  1243. {
  1244. const struct qib_devdata *dd = rcd->dd;
  1245. u32 hdrqtail;
  1246. if (dd->flags & QIB_NODMA_RTAIL) {
  1247. __le32 *rhf_addr;
  1248. u32 seq;
  1249. rhf_addr = (__le32 *) rcd->rcvhdrq +
  1250. rcd->head + dd->rhf_offset;
  1251. seq = qib_hdrget_seq(rhf_addr);
  1252. hdrqtail = rcd->head;
  1253. if (seq == rcd->seq_cnt)
  1254. hdrqtail++;
  1255. } else
  1256. hdrqtail = qib_get_rcvhdrtail(rcd);
  1257. return hdrqtail;
  1258. }
  1259. /*
  1260. * sysfs interface.
  1261. */
  1262. extern const char ib_qib_version[];
  1263. int qib_device_create(struct qib_devdata *);
  1264. void qib_device_remove(struct qib_devdata *);
  1265. int qib_create_port_files(struct ib_device *ibdev, u8 port_num,
  1266. struct kobject *kobj);
  1267. int qib_verbs_register_sysfs(struct qib_devdata *);
  1268. void qib_verbs_unregister_sysfs(struct qib_devdata *);
  1269. /* Hook for sysfs read of QSFP */
  1270. extern int qib_qsfp_dump(struct qib_pportdata *ppd, char *buf, int len);
  1271. int __init qib_init_qibfs(void);
  1272. int __exit qib_exit_qibfs(void);
  1273. int qibfs_add(struct qib_devdata *);
  1274. int qibfs_remove(struct qib_devdata *);
  1275. int qib_pcie_init(struct pci_dev *, const struct pci_device_id *);
  1276. int qib_pcie_ddinit(struct qib_devdata *, struct pci_dev *,
  1277. const struct pci_device_id *);
  1278. void qib_pcie_ddcleanup(struct qib_devdata *);
  1279. int qib_pcie_params(struct qib_devdata *, u32, u32 *, struct qib_msix_entry *);
  1280. int qib_reinit_intr(struct qib_devdata *);
  1281. void qib_enable_intx(struct pci_dev *);
  1282. void qib_nomsi(struct qib_devdata *);
  1283. void qib_nomsix(struct qib_devdata *);
  1284. void qib_pcie_getcmd(struct qib_devdata *, u16 *, u8 *, u8 *);
  1285. void qib_pcie_reenable(struct qib_devdata *, u16, u8, u8);
  1286. /* interrupts for device */
  1287. u64 qib_int_counter(struct qib_devdata *);
  1288. /* interrupt for all devices */
  1289. u64 qib_sps_ints(void);
  1290. /*
  1291. * dma_addr wrappers - all 0's invalid for hw
  1292. */
  1293. dma_addr_t qib_map_page(struct pci_dev *, struct page *, unsigned long,
  1294. size_t, int);
  1295. const char *qib_get_unit_name(int unit);
  1296. const char *qib_get_card_name(struct rvt_dev_info *rdi);
  1297. struct pci_dev *qib_get_pci_dev(struct rvt_dev_info *rdi);
  1298. /*
  1299. * Flush write combining store buffers (if present) and perform a write
  1300. * barrier.
  1301. */
  1302. static inline void qib_flush_wc(void)
  1303. {
  1304. #if defined(CONFIG_X86_64)
  1305. asm volatile("sfence" : : : "memory");
  1306. #else
  1307. wmb(); /* no reorder around wc flush */
  1308. #endif
  1309. }
  1310. /* global module parameter variables */
  1311. extern unsigned qib_ibmtu;
  1312. extern ushort qib_cfgctxts;
  1313. extern ushort qib_num_cfg_vls;
  1314. extern ushort qib_mini_init; /* If set, do few (ideally 0) writes to chip */
  1315. extern unsigned qib_n_krcv_queues;
  1316. extern unsigned qib_sdma_fetch_arb;
  1317. extern unsigned qib_compat_ddr_negotiate;
  1318. extern int qib_special_trigger;
  1319. extern unsigned qib_numa_aware;
  1320. extern struct mutex qib_mutex;
  1321. /* Number of seconds before our card status check... */
  1322. #define STATUS_TIMEOUT 60
  1323. #define QIB_DRV_NAME "ib_qib"
  1324. #define QIB_USER_MINOR_BASE 0
  1325. #define QIB_TRACE_MINOR 127
  1326. #define QIB_DIAGPKT_MINOR 128
  1327. #define QIB_DIAG_MINOR_BASE 129
  1328. #define QIB_NMINORS 255
  1329. #define PCI_VENDOR_ID_PATHSCALE 0x1fc1
  1330. #define PCI_VENDOR_ID_QLOGIC 0x1077
  1331. #define PCI_DEVICE_ID_QLOGIC_IB_6120 0x10
  1332. #define PCI_DEVICE_ID_QLOGIC_IB_7220 0x7220
  1333. #define PCI_DEVICE_ID_QLOGIC_IB_7322 0x7322
  1334. /*
  1335. * qib_early_err is used (only!) to print early errors before devdata is
  1336. * allocated, or when dd->pcidev may not be valid, and at the tail end of
  1337. * cleanup when devdata may have been freed, etc. qib_dev_porterr is
  1338. * the same as qib_dev_err, but is used when the message really needs
  1339. * the IB port# to be definitive as to what's happening..
  1340. * All of these go to the trace log, and the trace log entry is done
  1341. * first to avoid possible serial port delays from printk.
  1342. */
  1343. #define qib_early_err(dev, fmt, ...) \
  1344. dev_err(dev, fmt, ##__VA_ARGS__)
  1345. #define qib_dev_err(dd, fmt, ...) \
  1346. dev_err(&(dd)->pcidev->dev, "%s: " fmt, \
  1347. qib_get_unit_name((dd)->unit), ##__VA_ARGS__)
  1348. #define qib_dev_warn(dd, fmt, ...) \
  1349. dev_warn(&(dd)->pcidev->dev, "%s: " fmt, \
  1350. qib_get_unit_name((dd)->unit), ##__VA_ARGS__)
  1351. #define qib_dev_porterr(dd, port, fmt, ...) \
  1352. dev_err(&(dd)->pcidev->dev, "%s: IB%u:%u " fmt, \
  1353. qib_get_unit_name((dd)->unit), (dd)->unit, (port), \
  1354. ##__VA_ARGS__)
  1355. #define qib_devinfo(pcidev, fmt, ...) \
  1356. dev_info(&(pcidev)->dev, fmt, ##__VA_ARGS__)
  1357. /*
  1358. * this is used for formatting hw error messages...
  1359. */
  1360. struct qib_hwerror_msgs {
  1361. u64 mask;
  1362. const char *msg;
  1363. size_t sz;
  1364. };
  1365. #define QLOGIC_IB_HWE_MSG(a, b) { .mask = a, .msg = b }
  1366. /* in qib_intr.c... */
  1367. void qib_format_hwerrors(u64 hwerrs,
  1368. const struct qib_hwerror_msgs *hwerrmsgs,
  1369. size_t nhwerrmsgs, char *msg, size_t lmsg);
  1370. void qib_stop_send_queue(struct rvt_qp *qp);
  1371. void qib_quiesce_qp(struct rvt_qp *qp);
  1372. void qib_flush_qp_waiters(struct rvt_qp *qp);
  1373. int qib_mtu_to_path_mtu(u32 mtu);
  1374. u32 qib_mtu_from_qp(struct rvt_dev_info *rdi, struct rvt_qp *qp, u32 pmtu);
  1375. void qib_notify_error_qp(struct rvt_qp *qp);
  1376. int qib_get_pmtu_from_attr(struct rvt_dev_info *rdi, struct rvt_qp *qp,
  1377. struct ib_qp_attr *attr);
  1378. #endif /* _QIB_KERNEL_H */