ipath_kernel.h 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127
  1. #ifndef _IPATH_KERNEL_H
  2. #define _IPATH_KERNEL_H
  3. /*
  4. * Copyright (c) 2006, 2007 QLogic Corporation. All rights reserved.
  5. * Copyright (c) 2003, 2004, 2005, 2006 PathScale, Inc. All rights reserved.
  6. *
  7. * This software is available to you under a choice of one of two
  8. * licenses. You may choose to be licensed under the terms of the GNU
  9. * General Public License (GPL) Version 2, available from the file
  10. * COPYING in the main directory of this source tree, or the
  11. * OpenIB.org BSD license below:
  12. *
  13. * Redistribution and use in source and binary forms, with or
  14. * without modification, are permitted provided that the following
  15. * conditions are met:
  16. *
  17. * - Redistributions of source code must retain the above
  18. * copyright notice, this list of conditions and the following
  19. * disclaimer.
  20. *
  21. * - Redistributions in binary form must reproduce the above
  22. * copyright notice, this list of conditions and the following
  23. * disclaimer in the documentation and/or other materials
  24. * provided with the distribution.
  25. *
  26. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  27. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  28. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  29. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  30. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  31. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  32. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  33. * SOFTWARE.
  34. */
  35. /*
  36. * This header file is the base header file for infinipath kernel code
  37. * ipath_user.h serves a similar purpose for user code.
  38. */
  39. #include <linux/interrupt.h>
  40. #include <linux/pci.h>
  41. #include <linux/dma-mapping.h>
  42. #include <linux/mutex.h>
  43. #include <asm/io.h>
  44. #include <rdma/ib_verbs.h>
  45. #include "ipath_common.h"
  46. #include "ipath_debug.h"
  47. #include "ipath_registers.h"
  48. /* only s/w major version of InfiniPath we can handle */
  49. #define IPATH_CHIP_VERS_MAJ 2U
  50. /* don't care about this except printing */
  51. #define IPATH_CHIP_VERS_MIN 0U
  52. /* temporary, maybe always */
  53. extern struct infinipath_stats ipath_stats;
  54. #define IPATH_CHIP_SWVERSION IPATH_CHIP_VERS_MAJ
  55. /*
  56. * First-cut critierion for "device is active" is
  57. * two thousand dwords combined Tx, Rx traffic per
  58. * 5-second interval. SMA packets are 64 dwords,
  59. * and occur "a few per second", presumably each way.
  60. */
  61. #define IPATH_TRAFFIC_ACTIVE_THRESHOLD (2000)
  62. /*
  63. * Struct used to indicate which errors are logged in each of the
  64. * error-counters that are logged to EEPROM. A counter is incremented
  65. * _once_ (saturating at 255) for each event with any bits set in
  66. * the error or hwerror register masks below.
  67. */
  68. #define IPATH_EEP_LOG_CNT (4)
  69. struct ipath_eep_log_mask {
  70. u64 errs_to_log;
  71. u64 hwerrs_to_log;
  72. };
  73. struct ipath_portdata {
  74. void **port_rcvegrbuf;
  75. dma_addr_t *port_rcvegrbuf_phys;
  76. /* rcvhdrq base, needs mmap before useful */
  77. void *port_rcvhdrq;
  78. /* kernel virtual address where hdrqtail is updated */
  79. void *port_rcvhdrtail_kvaddr;
  80. /*
  81. * temp buffer for expected send setup, allocated at open, instead
  82. * of each setup call
  83. */
  84. void *port_tid_pg_list;
  85. /* when waiting for rcv or pioavail */
  86. wait_queue_head_t port_wait;
  87. /*
  88. * rcvegr bufs base, physical, must fit
  89. * in 44 bits so 32 bit programs mmap64 44 bit works)
  90. */
  91. dma_addr_t port_rcvegr_phys;
  92. /* mmap of hdrq, must fit in 44 bits */
  93. dma_addr_t port_rcvhdrq_phys;
  94. dma_addr_t port_rcvhdrqtailaddr_phys;
  95. /*
  96. * number of opens (including slave subports) on this instance
  97. * (ignoring forks, dup, etc. for now)
  98. */
  99. int port_cnt;
  100. /*
  101. * how much space to leave at start of eager TID entries for
  102. * protocol use, on each TID
  103. */
  104. /* instead of calculating it */
  105. unsigned port_port;
  106. /* non-zero if port is being shared. */
  107. u16 port_subport_cnt;
  108. /* non-zero if port is being shared. */
  109. u16 port_subport_id;
  110. /* chip offset of PIO buffers for this port */
  111. u32 port_piobufs;
  112. /* how many alloc_pages() chunks in port_rcvegrbuf_pages */
  113. u32 port_rcvegrbuf_chunks;
  114. /* how many egrbufs per chunk */
  115. u32 port_rcvegrbufs_perchunk;
  116. /* order for port_rcvegrbuf_pages */
  117. size_t port_rcvegrbuf_size;
  118. /* rcvhdrq size (for freeing) */
  119. size_t port_rcvhdrq_size;
  120. /* next expected TID to check when looking for free */
  121. u32 port_tidcursor;
  122. /* next expected TID to check */
  123. unsigned long port_flag;
  124. /* what happened */
  125. unsigned long int_flag;
  126. /* WAIT_RCV that timed out, no interrupt */
  127. u32 port_rcvwait_to;
  128. /* WAIT_PIO that timed out, no interrupt */
  129. u32 port_piowait_to;
  130. /* WAIT_RCV already happened, no wait */
  131. u32 port_rcvnowait;
  132. /* WAIT_PIO already happened, no wait */
  133. u32 port_pionowait;
  134. /* total number of rcvhdrqfull errors */
  135. u32 port_hdrqfull;
  136. /*
  137. * Used to suppress multiple instances of same
  138. * port staying stuck at same point.
  139. */
  140. u32 port_lastrcvhdrqtail;
  141. /* saved total number of rcvhdrqfull errors for poll edge trigger */
  142. u32 port_hdrqfull_poll;
  143. /* total number of polled urgent packets */
  144. u32 port_urgent;
  145. /* saved total number of polled urgent packets for poll edge trigger */
  146. u32 port_urgent_poll;
  147. /* pid of process using this port */
  148. pid_t port_pid;
  149. pid_t port_subpid[INFINIPATH_MAX_SUBPORT];
  150. /* same size as task_struct .comm[] */
  151. char port_comm[16];
  152. /* pkeys set by this use of this port */
  153. u16 port_pkeys[4];
  154. /* so file ops can get at unit */
  155. struct ipath_devdata *port_dd;
  156. /* A page of memory for rcvhdrhead, rcvegrhead, rcvegrtail * N */
  157. void *subport_uregbase;
  158. /* An array of pages for the eager receive buffers * N */
  159. void *subport_rcvegrbuf;
  160. /* An array of pages for the eager header queue entries * N */
  161. void *subport_rcvhdr_base;
  162. /* The version of the library which opened this port */
  163. u32 userversion;
  164. /* Bitmask of active slaves */
  165. u32 active_slaves;
  166. /* Type of packets or conditions we want to poll for */
  167. u16 poll_type;
  168. /* port rcvhdrq head offset */
  169. u32 port_head;
  170. };
  171. struct sk_buff;
  172. /*
  173. * control information for layered drivers
  174. */
  175. struct _ipath_layer {
  176. void *l_arg;
  177. };
  178. struct ipath_skbinfo {
  179. struct sk_buff *skb;
  180. dma_addr_t phys;
  181. };
  182. /*
  183. * Possible IB config parameters for ipath_f_get/set_ib_cfg()
  184. */
  185. #define IPATH_IB_CFG_LIDLMC 0 /* Get/set LID (LS16b) and Mask (MS16b) */
  186. #define IPATH_IB_CFG_HRTBT 1 /* Get/set Heartbeat off/enable/auto */
  187. #define IPATH_IB_HRTBT_ON 3 /* Heartbeat enabled, sent every 100msec */
  188. #define IPATH_IB_HRTBT_OFF 0 /* Heartbeat off */
  189. #define IPATH_IB_CFG_LWID_ENB 2 /* Get/set allowed Link-width */
  190. #define IPATH_IB_CFG_LWID 3 /* Get currently active Link-width */
  191. #define IPATH_IB_CFG_SPD_ENB 4 /* Get/set allowed Link speeds */
  192. #define IPATH_IB_CFG_SPD 5 /* Get current Link spd */
  193. #define IPATH_IB_CFG_RXPOL_ENB 6 /* Get/set Auto-RX-polarity enable */
  194. #define IPATH_IB_CFG_LREV_ENB 7 /* Get/set Auto-Lane-reversal enable */
  195. #define IPATH_IB_CFG_LINKLATENCY 8 /* Get Auto-Lane-reversal enable */
  196. struct ipath_devdata {
  197. struct list_head ipath_list;
  198. struct ipath_kregs const *ipath_kregs;
  199. struct ipath_cregs const *ipath_cregs;
  200. /* mem-mapped pointer to base of chip regs */
  201. u64 __iomem *ipath_kregbase;
  202. /* end of mem-mapped chip space; range checking */
  203. u64 __iomem *ipath_kregend;
  204. /* physical address of chip for io_remap, etc. */
  205. unsigned long ipath_physaddr;
  206. /* base of memory alloced for ipath_kregbase, for free */
  207. u64 *ipath_kregalloc;
  208. /*
  209. * virtual address where port0 rcvhdrqtail updated for this unit.
  210. * only written to by the chip, not the driver.
  211. */
  212. volatile __le64 *ipath_hdrqtailptr;
  213. /* ipath_cfgports pointers */
  214. struct ipath_portdata **ipath_pd;
  215. /* sk_buffs used by port 0 eager receive queue */
  216. struct ipath_skbinfo *ipath_port0_skbinfo;
  217. /* kvirt address of 1st 2k pio buffer */
  218. void __iomem *ipath_pio2kbase;
  219. /* kvirt address of 1st 4k pio buffer */
  220. void __iomem *ipath_pio4kbase;
  221. /*
  222. * points to area where PIOavail registers will be DMA'ed.
  223. * Has to be on a page of it's own, because the page will be
  224. * mapped into user program space. This copy is *ONLY* ever
  225. * written by DMA, not by the driver! Need a copy per device
  226. * when we get to multiple devices
  227. */
  228. volatile __le64 *ipath_pioavailregs_dma;
  229. /* physical address where updates occur */
  230. dma_addr_t ipath_pioavailregs_phys;
  231. struct _ipath_layer ipath_layer;
  232. /* setup intr */
  233. int (*ipath_f_intrsetup)(struct ipath_devdata *);
  234. /* fallback to alternate interrupt type if possible */
  235. int (*ipath_f_intr_fallback)(struct ipath_devdata *);
  236. /* setup on-chip bus config */
  237. int (*ipath_f_bus)(struct ipath_devdata *, struct pci_dev *);
  238. /* hard reset chip */
  239. int (*ipath_f_reset)(struct ipath_devdata *);
  240. int (*ipath_f_get_boardname)(struct ipath_devdata *, char *,
  241. size_t);
  242. void (*ipath_f_init_hwerrors)(struct ipath_devdata *);
  243. void (*ipath_f_handle_hwerrors)(struct ipath_devdata *, char *,
  244. size_t);
  245. void (*ipath_f_quiet_serdes)(struct ipath_devdata *);
  246. int (*ipath_f_bringup_serdes)(struct ipath_devdata *);
  247. int (*ipath_f_early_init)(struct ipath_devdata *);
  248. void (*ipath_f_clear_tids)(struct ipath_devdata *, unsigned);
  249. void (*ipath_f_put_tid)(struct ipath_devdata *, u64 __iomem*,
  250. u32, unsigned long);
  251. void (*ipath_f_tidtemplate)(struct ipath_devdata *);
  252. void (*ipath_f_cleanup)(struct ipath_devdata *);
  253. void (*ipath_f_setextled)(struct ipath_devdata *, u64, u64);
  254. /* fill out chip-specific fields */
  255. int (*ipath_f_get_base_info)(struct ipath_portdata *, void *);
  256. /* free irq */
  257. void (*ipath_f_free_irq)(struct ipath_devdata *);
  258. struct ipath_message_header *(*ipath_f_get_msgheader)
  259. (struct ipath_devdata *, __le32 *);
  260. void (*ipath_f_config_ports)(struct ipath_devdata *, ushort);
  261. int (*ipath_f_get_ib_cfg)(struct ipath_devdata *, int);
  262. int (*ipath_f_set_ib_cfg)(struct ipath_devdata *, int, u32);
  263. void (*ipath_f_config_jint)(struct ipath_devdata *, u16 , u16);
  264. void (*ipath_f_read_counters)(struct ipath_devdata *,
  265. struct infinipath_counters *);
  266. void (*ipath_f_xgxs_reset)(struct ipath_devdata *);
  267. /* per chip actions needed for IB Link up/down changes */
  268. int (*ipath_f_ib_updown)(struct ipath_devdata *, int, u64);
  269. struct ipath_ibdev *verbs_dev;
  270. struct timer_list verbs_timer;
  271. /* total dwords sent (summed from counter) */
  272. u64 ipath_sword;
  273. /* total dwords rcvd (summed from counter) */
  274. u64 ipath_rword;
  275. /* total packets sent (summed from counter) */
  276. u64 ipath_spkts;
  277. /* total packets rcvd (summed from counter) */
  278. u64 ipath_rpkts;
  279. /* ipath_statusp initially points to this. */
  280. u64 _ipath_status;
  281. /* GUID for this interface, in network order */
  282. __be64 ipath_guid;
  283. /*
  284. * aggregrate of error bits reported since last cleared, for
  285. * limiting of error reporting
  286. */
  287. ipath_err_t ipath_lasterror;
  288. /*
  289. * aggregrate of error bits reported since last cleared, for
  290. * limiting of hwerror reporting
  291. */
  292. ipath_err_t ipath_lasthwerror;
  293. /* errors masked because they occur too fast */
  294. ipath_err_t ipath_maskederrs;
  295. /* time in jiffies at which to re-enable maskederrs */
  296. unsigned long ipath_unmasktime;
  297. /* count of egrfull errors, combined for all ports */
  298. u64 ipath_last_tidfull;
  299. /* for ipath_qcheck() */
  300. u64 ipath_lastport0rcv_cnt;
  301. /* template for writing TIDs */
  302. u64 ipath_tidtemplate;
  303. /* value to write to free TIDs */
  304. u64 ipath_tidinvalid;
  305. /* IBA6120 rcv interrupt setup */
  306. u64 ipath_rhdrhead_intr_off;
  307. /* size of memory at ipath_kregbase */
  308. u32 ipath_kregsize;
  309. /* number of registers used for pioavail */
  310. u32 ipath_pioavregs;
  311. /* IPATH_POLL, etc. */
  312. u32 ipath_flags;
  313. /* ipath_flags driver is waiting for */
  314. u32 ipath_state_wanted;
  315. /* last buffer for user use, first buf for kernel use is this
  316. * index. */
  317. u32 ipath_lastport_piobuf;
  318. /* is a stats timer active */
  319. u32 ipath_stats_timer_active;
  320. /* number of interrupts for this device -- saturates... */
  321. u32 ipath_int_counter;
  322. /* dwords sent read from counter */
  323. u32 ipath_lastsword;
  324. /* dwords received read from counter */
  325. u32 ipath_lastrword;
  326. /* sent packets read from counter */
  327. u32 ipath_lastspkts;
  328. /* received packets read from counter */
  329. u32 ipath_lastrpkts;
  330. /* pio bufs allocated per port */
  331. u32 ipath_pbufsport;
  332. /*
  333. * number of ports configured as max; zero is set to number chip
  334. * supports, less gives more pio bufs/port, etc.
  335. */
  336. u32 ipath_cfgports;
  337. /* count of port 0 hdrqfull errors */
  338. u32 ipath_p0_hdrqfull;
  339. /* port 0 number of receive eager buffers */
  340. u32 ipath_p0_rcvegrcnt;
  341. /*
  342. * index of last piobuffer we used. Speeds up searching, by
  343. * starting at this point. Doesn't matter if multiple cpu's use and
  344. * update, last updater is only write that matters. Whenever it
  345. * wraps, we update shadow copies. Need a copy per device when we
  346. * get to multiple devices
  347. */
  348. u32 ipath_lastpioindex;
  349. /* max length of freezemsg */
  350. u32 ipath_freezelen;
  351. /*
  352. * consecutive times we wanted a PIO buffer but were unable to
  353. * get one
  354. */
  355. u32 ipath_consec_nopiobuf;
  356. /*
  357. * hint that we should update ipath_pioavailshadow before
  358. * looking for a PIO buffer
  359. */
  360. u32 ipath_upd_pio_shadow;
  361. /* so we can rewrite it after a chip reset */
  362. u32 ipath_pcibar0;
  363. /* so we can rewrite it after a chip reset */
  364. u32 ipath_pcibar1;
  365. /* interrupt number */
  366. int ipath_irq;
  367. /* HT/PCI Vendor ID (here for NodeInfo) */
  368. u16 ipath_vendorid;
  369. /* HT/PCI Device ID (here for NodeInfo) */
  370. u16 ipath_deviceid;
  371. /* offset in HT config space of slave/primary interface block */
  372. u8 ipath_ht_slave_off;
  373. /* for write combining settings */
  374. unsigned long ipath_wc_cookie;
  375. unsigned long ipath_wc_base;
  376. unsigned long ipath_wc_len;
  377. /* ref count for each pkey */
  378. atomic_t ipath_pkeyrefs[4];
  379. /* shadow copy of all exptids physaddr; used only by funcsim */
  380. u64 *ipath_tidsimshadow;
  381. /* shadow copy of struct page *'s for exp tid pages */
  382. struct page **ipath_pageshadow;
  383. /* shadow copy of dma handles for exp tid pages */
  384. dma_addr_t *ipath_physshadow;
  385. u64 __iomem *ipath_egrtidbase;
  386. /* lock to workaround chip bug 9437 */
  387. spinlock_t ipath_tid_lock;
  388. spinlock_t ipath_sendctrl_lock;
  389. /*
  390. * IPATH_STATUS_*,
  391. * this address is mapped readonly into user processes so they can
  392. * get status cheaply, whenever they want.
  393. */
  394. u64 *ipath_statusp;
  395. /* freeze msg if hw error put chip in freeze */
  396. char *ipath_freezemsg;
  397. /* pci access data structure */
  398. struct pci_dev *pcidev;
  399. struct cdev *user_cdev;
  400. struct cdev *diag_cdev;
  401. struct class_device *user_class_dev;
  402. struct class_device *diag_class_dev;
  403. /* timer used to prevent stats overflow, error throttling, etc. */
  404. struct timer_list ipath_stats_timer;
  405. void *ipath_dummy_hdrq; /* used after port close */
  406. dma_addr_t ipath_dummy_hdrq_phys;
  407. unsigned long ipath_ureg_align; /* user register alignment */
  408. /*
  409. * Shadow copies of registers; size indicates read access size.
  410. * Most of them are readonly, but some are write-only register,
  411. * where we manipulate the bits in the shadow copy, and then write
  412. * the shadow copy to infinipath.
  413. *
  414. * We deliberately make most of these 32 bits, since they have
  415. * restricted range. For any that we read, we won't to generate 32
  416. * bit accesses, since Opteron will generate 2 separate 32 bit HT
  417. * transactions for a 64 bit read, and we want to avoid unnecessary
  418. * HT transactions.
  419. */
  420. /* This is the 64 bit group */
  421. /*
  422. * shadow of pioavail, check to be sure it's large enough at
  423. * init time.
  424. */
  425. unsigned long ipath_pioavailshadow[8];
  426. /* shadow of kr_gpio_out, for rmw ops */
  427. u64 ipath_gpio_out;
  428. /* shadow the gpio mask register */
  429. u64 ipath_gpio_mask;
  430. /* shadow the gpio output enable, etc... */
  431. u64 ipath_extctrl;
  432. /* kr_revision shadow */
  433. u64 ipath_revision;
  434. /*
  435. * shadow of ibcctrl, for interrupt handling of link changes,
  436. * etc.
  437. */
  438. u64 ipath_ibcctrl;
  439. /*
  440. * last ibcstatus, to suppress "duplicate" status change messages,
  441. * mostly from 2 to 3
  442. */
  443. u64 ipath_lastibcstat;
  444. /* hwerrmask shadow */
  445. ipath_err_t ipath_hwerrmask;
  446. ipath_err_t ipath_errormask; /* errormask shadow */
  447. /* interrupt config reg shadow */
  448. u64 ipath_intconfig;
  449. /* kr_sendpiobufbase value */
  450. u64 ipath_piobufbase;
  451. /* these are the "32 bit" regs */
  452. /*
  453. * number of GUIDs in the flash for this interface; may need some
  454. * rethinking for setting on other ifaces
  455. */
  456. u32 ipath_nguid;
  457. /*
  458. * the following two are 32-bit bitmasks, but {test,clear,set}_bit
  459. * all expect bit fields to be "unsigned long"
  460. */
  461. /* shadow kr_rcvctrl */
  462. unsigned long ipath_rcvctrl;
  463. /* shadow kr_sendctrl */
  464. unsigned long ipath_sendctrl;
  465. unsigned long ipath_lastcancel; /* to not count armlaunch after cancel */
  466. /* value we put in kr_rcvhdrcnt */
  467. u32 ipath_rcvhdrcnt;
  468. /* value we put in kr_rcvhdrsize */
  469. u32 ipath_rcvhdrsize;
  470. /* value we put in kr_rcvhdrentsize */
  471. u32 ipath_rcvhdrentsize;
  472. /* offset of last entry in rcvhdrq */
  473. u32 ipath_hdrqlast;
  474. /* kr_portcnt value */
  475. u32 ipath_portcnt;
  476. /* kr_pagealign value */
  477. u32 ipath_palign;
  478. /* number of "2KB" PIO buffers */
  479. u32 ipath_piobcnt2k;
  480. /* size in bytes of "2KB" PIO buffers */
  481. u32 ipath_piosize2k;
  482. /* number of "4KB" PIO buffers */
  483. u32 ipath_piobcnt4k;
  484. /* size in bytes of "4KB" PIO buffers */
  485. u32 ipath_piosize4k;
  486. /* kr_rcvegrbase value */
  487. u32 ipath_rcvegrbase;
  488. /* kr_rcvegrcnt value */
  489. u32 ipath_rcvegrcnt;
  490. /* kr_rcvtidbase value */
  491. u32 ipath_rcvtidbase;
  492. /* kr_rcvtidcnt value */
  493. u32 ipath_rcvtidcnt;
  494. /* kr_sendregbase */
  495. u32 ipath_sregbase;
  496. /* kr_userregbase */
  497. u32 ipath_uregbase;
  498. /* kr_counterregbase */
  499. u32 ipath_cregbase;
  500. /* shadow the control register contents */
  501. u32 ipath_control;
  502. /* PCI revision register (HTC rev on FPGA) */
  503. u32 ipath_pcirev;
  504. /* chip address space used by 4k pio buffers */
  505. u32 ipath_4kalign;
  506. /* The MTU programmed for this unit */
  507. u32 ipath_ibmtu;
  508. /*
  509. * The max size IB packet, included IB headers that we can send.
  510. * Starts same as ipath_piosize, but is affected when ibmtu is
  511. * changed, or by size of eager buffers
  512. */
  513. u32 ipath_ibmaxlen;
  514. /*
  515. * ibmaxlen at init time, limited by chip and by receive buffer
  516. * size. Not changed after init.
  517. */
  518. u32 ipath_init_ibmaxlen;
  519. /* size of each rcvegrbuffer */
  520. u32 ipath_rcvegrbufsize;
  521. /* width (2,4,8,16,32) from HT config reg */
  522. u32 ipath_htwidth;
  523. /* HT speed (200,400,800,1000) from HT config */
  524. u32 ipath_htspeed;
  525. /*
  526. * number of sequential ibcstatus change for polling active/quiet
  527. * (i.e., link not coming up).
  528. */
  529. u32 ipath_ibpollcnt;
  530. /* low and high portions of MSI capability/vector */
  531. u32 ipath_msi_lo;
  532. /* saved after PCIe init for restore after reset */
  533. u32 ipath_msi_hi;
  534. /* MSI data (vector) saved for restore */
  535. u16 ipath_msi_data;
  536. /* MLID programmed for this instance */
  537. u16 ipath_mlid;
  538. /* LID programmed for this instance */
  539. u16 ipath_lid;
  540. /* list of pkeys programmed; 0 if not set */
  541. u16 ipath_pkeys[4];
  542. /*
  543. * ASCII serial number, from flash, large enough for original
  544. * all digit strings, and longer QLogic serial number format
  545. */
  546. u8 ipath_serial[16];
  547. /* human readable board version */
  548. u8 ipath_boardversion[80];
  549. /* chip major rev, from ipath_revision */
  550. u8 ipath_majrev;
  551. /* chip minor rev, from ipath_revision */
  552. u8 ipath_minrev;
  553. /* board rev, from ipath_revision */
  554. u8 ipath_boardrev;
  555. u8 ipath_r_portenable_shift;
  556. u8 ipath_r_intravail_shift;
  557. u8 ipath_r_tailupd_shift;
  558. u8 ipath_r_portcfg_shift;
  559. /* unit # of this chip, if present */
  560. int ipath_unit;
  561. /* saved for restore after reset */
  562. u8 ipath_pci_cacheline;
  563. /* LID mask control */
  564. u8 ipath_lmc;
  565. /* link width supported */
  566. u8 ipath_link_width_supported;
  567. /* link speed supported */
  568. u8 ipath_link_speed_supported;
  569. u8 ipath_link_width_enabled;
  570. u8 ipath_link_speed_enabled;
  571. u8 ipath_link_width_active;
  572. u8 ipath_link_speed_active;
  573. /* Rx Polarity inversion (compensate for ~tx on partner) */
  574. u8 ipath_rx_pol_inv;
  575. /* local link integrity counter */
  576. u32 ipath_lli_counter;
  577. /* local link integrity errors */
  578. u32 ipath_lli_errors;
  579. /*
  580. * Above counts only cases where _successive_ LocalLinkIntegrity
  581. * errors were seen in the receive headers of kern-packets.
  582. * Below are the three (monotonically increasing) counters
  583. * maintained via GPIO interrupts on iba6120-rev2.
  584. */
  585. u32 ipath_rxfc_unsupvl_errs;
  586. u32 ipath_overrun_thresh_errs;
  587. u32 ipath_lli_errs;
  588. /* status check work */
  589. struct delayed_work status_work;
  590. /*
  591. * Not all devices managed by a driver instance are the same
  592. * type, so these fields must be per-device.
  593. */
  594. u64 ipath_i_bitsextant;
  595. ipath_err_t ipath_e_bitsextant;
  596. ipath_err_t ipath_hwe_bitsextant;
  597. /*
  598. * Below should be computable from number of ports,
  599. * since they are never modified.
  600. */
  601. u32 ipath_i_rcvavail_mask;
  602. u32 ipath_i_rcvurg_mask;
  603. u16 ipath_i_rcvurg_shift;
  604. u16 ipath_i_rcvavail_shift;
  605. /*
  606. * Register bits for selecting i2c direction and values, used for
  607. * I2C serial flash.
  608. */
  609. u16 ipath_gpio_sda_num;
  610. u16 ipath_gpio_scl_num;
  611. u64 ipath_gpio_sda;
  612. u64 ipath_gpio_scl;
  613. /* lock for doing RMW of shadows/regs for ExtCtrl and GPIO */
  614. spinlock_t ipath_gpio_lock;
  615. /*
  616. * IB link and linktraining states and masks that vary per chip in
  617. * some way. Set at init, to avoid each IB status change interrupt
  618. */
  619. u8 ibcs_ls_shift;
  620. u8 ibcs_lts_mask;
  621. u32 ibcs_mask;
  622. u32 ib_init;
  623. u32 ib_arm;
  624. u32 ib_active;
  625. u16 ipath_rhf_offset; /* offset of RHF within receive header entry */
  626. /*
  627. * shift/mask for linkcmd, linkinitcmd, maxpktlen in ibccontol
  628. * reg. Changes for IBA7220
  629. */
  630. u8 ibcc_lic_mask; /* LinkInitCmd */
  631. u8 ibcc_lc_shift; /* LinkCmd */
  632. u8 ibcc_mpl_shift; /* Maxpktlen */
  633. u8 delay_mult;
  634. /* used to override LED behavior */
  635. u8 ipath_led_override; /* Substituted for normal value, if non-zero */
  636. u16 ipath_led_override_timeoff; /* delta to next timer event */
  637. u8 ipath_led_override_vals[2]; /* Alternates per blink-frame */
  638. u8 ipath_led_override_phase; /* Just counts, LSB picks from vals[] */
  639. atomic_t ipath_led_override_timer_active;
  640. /* Used to flash LEDs in override mode */
  641. struct timer_list ipath_led_override_timer;
  642. /* Support (including locks) for EEPROM logging of errors and time */
  643. /* control access to actual counters, timer */
  644. spinlock_t ipath_eep_st_lock;
  645. /* control high-level access to EEPROM */
  646. struct mutex ipath_eep_lock;
  647. /* Below inc'd by ipath_snap_cntrs(), locked by ipath_eep_st_lock */
  648. uint64_t ipath_traffic_wds;
  649. /* active time is kept in seconds, but logged in hours */
  650. atomic_t ipath_active_time;
  651. /* Below are nominal shadow of EEPROM, new since last EEPROM update */
  652. uint8_t ipath_eep_st_errs[IPATH_EEP_LOG_CNT];
  653. uint8_t ipath_eep_st_new_errs[IPATH_EEP_LOG_CNT];
  654. uint16_t ipath_eep_hrs;
  655. /*
  656. * masks for which bits of errs, hwerrs that cause
  657. * each of the counters to increment.
  658. */
  659. struct ipath_eep_log_mask ipath_eep_st_masks[IPATH_EEP_LOG_CNT];
  660. /* interrupt mitigation reload register info */
  661. u16 ipath_jint_idle_ticks; /* idle clock ticks */
  662. u16 ipath_jint_max_packets; /* max packets across all ports */
  663. };
  664. /* Private data for file operations */
  665. struct ipath_filedata {
  666. struct ipath_portdata *pd;
  667. unsigned subport;
  668. unsigned tidcursor;
  669. };
  670. extern struct list_head ipath_dev_list;
  671. extern spinlock_t ipath_devs_lock;
  672. extern struct ipath_devdata *ipath_lookup(int unit);
  673. int ipath_init_chip(struct ipath_devdata *, int);
  674. int ipath_enable_wc(struct ipath_devdata *dd);
  675. void ipath_disable_wc(struct ipath_devdata *dd);
  676. int ipath_count_units(int *npresentp, int *nupp, u32 *maxportsp);
  677. void ipath_shutdown_device(struct ipath_devdata *);
  678. void ipath_clear_freeze(struct ipath_devdata *);
  679. struct file_operations;
  680. int ipath_cdev_init(int minor, char *name, const struct file_operations *fops,
  681. struct cdev **cdevp, struct class_device **class_devp);
  682. void ipath_cdev_cleanup(struct cdev **cdevp,
  683. struct class_device **class_devp);
  684. int ipath_diag_add(struct ipath_devdata *);
  685. void ipath_diag_remove(struct ipath_devdata *);
  686. extern wait_queue_head_t ipath_state_wait;
  687. int ipath_user_add(struct ipath_devdata *dd);
  688. void ipath_user_remove(struct ipath_devdata *dd);
  689. struct sk_buff *ipath_alloc_skb(struct ipath_devdata *dd, gfp_t);
  690. extern int ipath_diag_inuse;
  691. irqreturn_t ipath_intr(int irq, void *devid);
  692. int ipath_decode_err(char *buf, size_t blen, ipath_err_t err);
  693. #if __IPATH_INFO || __IPATH_DBG
  694. extern const char *ipath_ibcstatus_str[];
  695. #endif
  696. /* clean up any per-chip chip-specific stuff */
  697. void ipath_chip_cleanup(struct ipath_devdata *);
  698. /* clean up any chip type-specific stuff */
  699. void ipath_chip_done(void);
  700. /* check to see if we have to force ordering for write combining */
  701. int ipath_unordered_wc(void);
  702. void ipath_disarm_piobufs(struct ipath_devdata *, unsigned first,
  703. unsigned cnt);
  704. void ipath_cancel_sends(struct ipath_devdata *, int);
  705. int ipath_create_rcvhdrq(struct ipath_devdata *, struct ipath_portdata *);
  706. void ipath_free_pddata(struct ipath_devdata *, struct ipath_portdata *);
  707. int ipath_parse_ushort(const char *str, unsigned short *valp);
  708. void ipath_kreceive(struct ipath_portdata *);
  709. int ipath_setrcvhdrsize(struct ipath_devdata *, unsigned);
  710. int ipath_reset_device(int);
  711. void ipath_get_faststats(unsigned long);
  712. int ipath_set_linkstate(struct ipath_devdata *, u8);
  713. int ipath_set_mtu(struct ipath_devdata *, u16);
  714. int ipath_set_lid(struct ipath_devdata *, u32, u8);
  715. int ipath_set_rx_pol_inv(struct ipath_devdata *dd, u8 new_pol_inv);
  716. /* for use in system calls, where we want to know device type, etc. */
  717. #define port_fp(fp) ((struct ipath_filedata *)(fp)->private_data)->pd
  718. #define subport_fp(fp) \
  719. ((struct ipath_filedata *)(fp)->private_data)->subport
  720. #define tidcursor_fp(fp) \
  721. ((struct ipath_filedata *)(fp)->private_data)->tidcursor
  722. /*
  723. * values for ipath_flags
  724. */
  725. /* The chip is up and initted */
  726. #define IPATH_INITTED 0x2
  727. /* set if any user code has set kr_rcvhdrsize */
  728. #define IPATH_RCVHDRSZ_SET 0x4
  729. /* The chip is present and valid for accesses */
  730. #define IPATH_PRESENT 0x8
  731. /* HT link0 is only 8 bits wide, ignore upper byte crc
  732. * errors, etc. */
  733. #define IPATH_8BIT_IN_HT0 0x10
  734. /* HT link1 is only 8 bits wide, ignore upper byte crc
  735. * errors, etc. */
  736. #define IPATH_8BIT_IN_HT1 0x20
  737. /* The link is down */
  738. #define IPATH_LINKDOWN 0x40
  739. /* The link level is up (0x11) */
  740. #define IPATH_LINKINIT 0x80
  741. /* The link is in the armed (0x21) state */
  742. #define IPATH_LINKARMED 0x100
  743. /* The link is in the active (0x31) state */
  744. #define IPATH_LINKACTIVE 0x200
  745. /* link current state is unknown */
  746. #define IPATH_LINKUNK 0x400
  747. /* Write combining flush needed for PIO */
  748. #define IPATH_PIO_FLUSH_WC 0x1000
  749. /* no IB cable, or no device on IB cable */
  750. #define IPATH_NOCABLE 0x4000
  751. /* Supports port zero per packet receive interrupts via
  752. * GPIO */
  753. #define IPATH_GPIO_INTR 0x8000
  754. /* uses the coded 4byte TID, not 8 byte */
  755. #define IPATH_4BYTE_TID 0x10000
  756. /* packet/word counters are 32 bit, else those 4 counters
  757. * are 64bit */
  758. #define IPATH_32BITCOUNTERS 0x20000
  759. /* can miss port0 rx interrupts */
  760. /* Interrupt register is 64 bits */
  761. #define IPATH_INTREG_64 0x40000
  762. #define IPATH_DISABLED 0x80000 /* administratively disabled */
  763. /* Use GPIO interrupts for new counters */
  764. #define IPATH_GPIO_ERRINTRS 0x100000
  765. #define IPATH_SWAP_PIOBUFS 0x200000
  766. /* Bits in GPIO for the added interrupts */
  767. #define IPATH_GPIO_PORT0_BIT 2
  768. #define IPATH_GPIO_RXUVL_BIT 3
  769. #define IPATH_GPIO_OVRUN_BIT 4
  770. #define IPATH_GPIO_LLI_BIT 5
  771. #define IPATH_GPIO_ERRINTR_MASK 0x38
  772. /* portdata flag bit offsets */
  773. /* waiting for a packet to arrive */
  774. #define IPATH_PORT_WAITING_RCV 2
  775. /* master has not finished initializing */
  776. #define IPATH_PORT_MASTER_UNINIT 4
  777. /* waiting for an urgent packet to arrive */
  778. #define IPATH_PORT_WAITING_URG 5
  779. /* free up any allocated data at closes */
  780. void ipath_free_data(struct ipath_portdata *dd);
  781. u32 __iomem *ipath_getpiobuf(struct ipath_devdata *, u32 *);
  782. void ipath_init_iba6120_funcs(struct ipath_devdata *);
  783. void ipath_init_iba6110_funcs(struct ipath_devdata *);
  784. void ipath_get_eeprom_info(struct ipath_devdata *);
  785. int ipath_update_eeprom_log(struct ipath_devdata *dd);
  786. void ipath_inc_eeprom_err(struct ipath_devdata *dd, u32 eidx, u32 incr);
  787. u64 ipath_snap_cntr(struct ipath_devdata *, ipath_creg);
  788. void signal_ib_event(struct ipath_devdata *dd, enum ib_event_type ev);
  789. /*
  790. * Set LED override, only the two LSBs have "public" meaning, but
  791. * any non-zero value substitutes them for the Link and LinkTrain
  792. * LED states.
  793. */
  794. #define IPATH_LED_PHYS 1 /* Physical (linktraining) GREEN LED */
  795. #define IPATH_LED_LOG 2 /* Logical (link) YELLOW LED */
  796. void ipath_set_led_override(struct ipath_devdata *dd, unsigned int val);
  797. /*
  798. * number of words used for protocol header if not set by ipath_userinit();
  799. */
  800. #define IPATH_DFLT_RCVHDRSIZE 9
  801. int ipath_get_user_pages(unsigned long, size_t, struct page **);
  802. void ipath_release_user_pages(struct page **, size_t);
  803. void ipath_release_user_pages_on_close(struct page **, size_t);
  804. int ipath_eeprom_read(struct ipath_devdata *, u8, void *, int);
  805. int ipath_eeprom_write(struct ipath_devdata *, u8, const void *, int);
  806. /* these are used for the registers that vary with port */
  807. void ipath_write_kreg_port(const struct ipath_devdata *, ipath_kreg,
  808. unsigned, u64);
  809. /*
  810. * We could have a single register get/put routine, that takes a group type,
  811. * but this is somewhat clearer and cleaner. It also gives us some error
  812. * checking. 64 bit register reads should always work, but are inefficient
  813. * on opteron (the northbridge always generates 2 separate HT 32 bit reads),
  814. * so we use kreg32 wherever possible. User register and counter register
  815. * reads are always 32 bit reads, so only one form of those routines.
  816. */
  817. /*
  818. * At the moment, none of the s-registers are writable, so no
  819. * ipath_write_sreg(), and none of the c-registers are writable, so no
  820. * ipath_write_creg().
  821. */
  822. /**
  823. * ipath_read_ureg32 - read 32-bit virtualized per-port register
  824. * @dd: device
  825. * @regno: register number
  826. * @port: port number
  827. *
  828. * Return the contents of a register that is virtualized to be per port.
  829. * Returns -1 on errors (not distinguishable from valid contents at
  830. * runtime; we may add a separate error variable at some point).
  831. */
  832. static inline u32 ipath_read_ureg32(const struct ipath_devdata *dd,
  833. ipath_ureg regno, int port)
  834. {
  835. if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
  836. return 0;
  837. return readl(regno + (u64 __iomem *)
  838. (dd->ipath_uregbase +
  839. (char __iomem *)dd->ipath_kregbase +
  840. dd->ipath_ureg_align * port));
  841. }
  842. /**
  843. * ipath_write_ureg - write 32-bit virtualized per-port register
  844. * @dd: device
  845. * @regno: register number
  846. * @value: value
  847. * @port: port
  848. *
  849. * Write the contents of a register that is virtualized to be per port.
  850. */
  851. static inline void ipath_write_ureg(const struct ipath_devdata *dd,
  852. ipath_ureg regno, u64 value, int port)
  853. {
  854. u64 __iomem *ubase = (u64 __iomem *)
  855. (dd->ipath_uregbase + (char __iomem *) dd->ipath_kregbase +
  856. dd->ipath_ureg_align * port);
  857. if (dd->ipath_kregbase)
  858. writeq(value, &ubase[regno]);
  859. }
  860. static inline u32 ipath_read_kreg32(const struct ipath_devdata *dd,
  861. ipath_kreg regno)
  862. {
  863. if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
  864. return -1;
  865. return readl((u32 __iomem *) & dd->ipath_kregbase[regno]);
  866. }
  867. static inline u64 ipath_read_kreg64(const struct ipath_devdata *dd,
  868. ipath_kreg regno)
  869. {
  870. if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
  871. return -1;
  872. return readq(&dd->ipath_kregbase[regno]);
  873. }
  874. static inline void ipath_write_kreg(const struct ipath_devdata *dd,
  875. ipath_kreg regno, u64 value)
  876. {
  877. if (dd->ipath_kregbase)
  878. writeq(value, &dd->ipath_kregbase[regno]);
  879. }
  880. static inline u64 ipath_read_creg(const struct ipath_devdata *dd,
  881. ipath_sreg regno)
  882. {
  883. if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
  884. return 0;
  885. return readq(regno + (u64 __iomem *)
  886. (dd->ipath_cregbase +
  887. (char __iomem *)dd->ipath_kregbase));
  888. }
  889. static inline u32 ipath_read_creg32(const struct ipath_devdata *dd,
  890. ipath_sreg regno)
  891. {
  892. if (!dd->ipath_kregbase || !(dd->ipath_flags & IPATH_PRESENT))
  893. return 0;
  894. return readl(regno + (u64 __iomem *)
  895. (dd->ipath_cregbase +
  896. (char __iomem *)dd->ipath_kregbase));
  897. }
  898. static inline void ipath_write_creg(const struct ipath_devdata *dd,
  899. ipath_creg regno, u64 value)
  900. {
  901. if (dd->ipath_kregbase)
  902. writeq(value, regno + (u64 __iomem *)
  903. (dd->ipath_cregbase +
  904. (char __iomem *)dd->ipath_kregbase));
  905. }
  906. static inline void ipath_clear_rcvhdrtail(const struct ipath_portdata *pd)
  907. {
  908. *((u64 *) pd->port_rcvhdrtail_kvaddr) = 0ULL;
  909. }
  910. static inline u32 ipath_get_rcvhdrtail(const struct ipath_portdata *pd)
  911. {
  912. return (u32) le64_to_cpu(*((volatile __le64 *)
  913. pd->port_rcvhdrtail_kvaddr));
  914. }
  915. static inline u64 ipath_read_ireg(const struct ipath_devdata *dd, ipath_kreg r)
  916. {
  917. return (dd->ipath_flags & IPATH_INTREG_64) ?
  918. ipath_read_kreg64(dd, r) : ipath_read_kreg32(dd, r);
  919. }
  920. /*
  921. * from contents of IBCStatus (or a saved copy), return linkstate
  922. * Report ACTIVE_DEFER as ACTIVE, because we treat them the same
  923. * everywhere, anyway (and should be, for almost all purposes).
  924. */
  925. static inline u32 ipath_ib_linkstate(struct ipath_devdata *dd, u64 ibcs)
  926. {
  927. u32 state = (u32)(ibcs >> dd->ibcs_ls_shift) &
  928. INFINIPATH_IBCS_LINKSTATE_MASK;
  929. if (state == INFINIPATH_IBCS_L_STATE_ACT_DEFER)
  930. state = INFINIPATH_IBCS_L_STATE_ACTIVE;
  931. return state;
  932. }
  933. /* from contents of IBCStatus (or a saved copy), return linktrainingstate */
  934. static inline u32 ipath_ib_linktrstate(struct ipath_devdata *dd, u64 ibcs)
  935. {
  936. return (u32)(ibcs >> INFINIPATH_IBCS_LINKTRAININGSTATE_SHIFT) &
  937. dd->ibcs_lts_mask;
  938. }
  939. /*
  940. * sysfs interface.
  941. */
  942. struct device_driver;
  943. extern const char ib_ipath_version[];
  944. extern struct attribute_group *ipath_driver_attr_groups[];
  945. int ipath_device_create_group(struct device *, struct ipath_devdata *);
  946. void ipath_device_remove_group(struct device *, struct ipath_devdata *);
  947. int ipath_expose_reset(struct device *);
  948. int ipath_init_ipathfs(void);
  949. void ipath_exit_ipathfs(void);
  950. int ipathfs_add_device(struct ipath_devdata *);
  951. int ipathfs_remove_device(struct ipath_devdata *);
  952. /*
  953. * dma_addr wrappers - all 0's invalid for hw
  954. */
  955. dma_addr_t ipath_map_page(struct pci_dev *, struct page *, unsigned long,
  956. size_t, int);
  957. dma_addr_t ipath_map_single(struct pci_dev *, void *, size_t, int);
  958. /*
  959. * Flush write combining store buffers (if present) and perform a write
  960. * barrier.
  961. */
  962. #if defined(CONFIG_X86_64)
  963. #define ipath_flush_wc() asm volatile("sfence" ::: "memory")
  964. #else
  965. #define ipath_flush_wc() wmb()
  966. #endif
  967. extern unsigned ipath_debug; /* debugging bit mask */
  968. #define IPATH_MAX_PARITY_ATTEMPTS 10000 /* max times to try recovery */
  969. const char *ipath_get_unit_name(int unit);
  970. extern struct mutex ipath_mutex;
  971. #define IPATH_DRV_NAME "ib_ipath"
  972. #define IPATH_MAJOR 233
  973. #define IPATH_USER_MINOR_BASE 0
  974. #define IPATH_DIAGPKT_MINOR 127
  975. #define IPATH_DIAG_MINOR_BASE 129
  976. #define IPATH_NMINORS 255
  977. #define ipath_dev_err(dd,fmt,...) \
  978. do { \
  979. const struct ipath_devdata *__dd = (dd); \
  980. if (__dd->pcidev) \
  981. dev_err(&__dd->pcidev->dev, "%s: " fmt, \
  982. ipath_get_unit_name(__dd->ipath_unit), \
  983. ##__VA_ARGS__); \
  984. else \
  985. printk(KERN_ERR IPATH_DRV_NAME ": %s: " fmt, \
  986. ipath_get_unit_name(__dd->ipath_unit), \
  987. ##__VA_ARGS__); \
  988. } while (0)
  989. #if _IPATH_DEBUGGING
  990. # define __IPATH_DBG_WHICH(which,fmt,...) \
  991. do { \
  992. if(unlikely(ipath_debug&(which))) \
  993. printk(KERN_DEBUG IPATH_DRV_NAME ": %s: " fmt, \
  994. __func__,##__VA_ARGS__); \
  995. } while(0)
  996. # define ipath_dbg(fmt,...) \
  997. __IPATH_DBG_WHICH(__IPATH_DBG,fmt,##__VA_ARGS__)
  998. # define ipath_cdbg(which,fmt,...) \
  999. __IPATH_DBG_WHICH(__IPATH_##which##DBG,fmt,##__VA_ARGS__)
  1000. #else /* ! _IPATH_DEBUGGING */
  1001. # define ipath_dbg(fmt,...)
  1002. # define ipath_cdbg(which,fmt,...)
  1003. #endif /* _IPATH_DEBUGGING */
  1004. /*
  1005. * this is used for formatting hw error messages...
  1006. */
  1007. struct ipath_hwerror_msgs {
  1008. u64 mask;
  1009. const char *msg;
  1010. };
  1011. #define INFINIPATH_HWE_MSG(a, b) { .mask = INFINIPATH_HWE_##a, .msg = b }
  1012. /* in ipath_intr.c... */
  1013. void ipath_format_hwerrors(u64 hwerrs,
  1014. const struct ipath_hwerror_msgs *hwerrmsgs,
  1015. size_t nhwerrmsgs,
  1016. char *msg, size_t lmsg);
  1017. #endif /* _IPATH_KERNEL_H */