qib.h 50 KB

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