hfi.h 63 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075
  1. #ifndef _HFI1_KERNEL_H
  2. #define _HFI1_KERNEL_H
  3. /*
  4. * Copyright(c) 2015, 2016 Intel Corporation.
  5. *
  6. * This file is provided under a dual BSD/GPLv2 license. When using or
  7. * redistributing this file, you may do so under either license.
  8. *
  9. * GPL LICENSE SUMMARY
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of version 2 of the GNU General Public License as
  13. * published by the Free Software Foundation.
  14. *
  15. * This program is distributed in the hope that it will be useful, but
  16. * WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * General Public License for more details.
  19. *
  20. * BSD LICENSE
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. *
  26. * - Redistributions of source code must retain the above copyright
  27. * notice, this list of conditions and the following disclaimer.
  28. * - Redistributions in binary form must reproduce the above copyright
  29. * notice, this list of conditions and the following disclaimer in
  30. * the documentation and/or other materials provided with the
  31. * distribution.
  32. * - Neither the name of Intel Corporation nor the names of its
  33. * contributors may be used to endorse or promote products derived
  34. * from this software without specific prior written permission.
  35. *
  36. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  37. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  38. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  39. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  40. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  42. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  43. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  44. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  45. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  46. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  47. *
  48. */
  49. #include <linux/interrupt.h>
  50. #include <linux/pci.h>
  51. #include <linux/dma-mapping.h>
  52. #include <linux/mutex.h>
  53. #include <linux/list.h>
  54. #include <linux/scatterlist.h>
  55. #include <linux/slab.h>
  56. #include <linux/io.h>
  57. #include <linux/fs.h>
  58. #include <linux/completion.h>
  59. #include <linux/kref.h>
  60. #include <linux/sched.h>
  61. #include <linux/cdev.h>
  62. #include <linux/delay.h>
  63. #include <linux/kthread.h>
  64. #include <linux/i2c.h>
  65. #include <linux/i2c-algo-bit.h>
  66. #include <rdma/ib_hdrs.h>
  67. #include <linux/rhashtable.h>
  68. #include <rdma/rdma_vt.h>
  69. #include "chip_registers.h"
  70. #include "common.h"
  71. #include "verbs.h"
  72. #include "pio.h"
  73. #include "chip.h"
  74. #include "mad.h"
  75. #include "qsfp.h"
  76. #include "platform.h"
  77. #include "affinity.h"
  78. /* bumped 1 from s/w major version of TrueScale */
  79. #define HFI1_CHIP_VERS_MAJ 3U
  80. /* don't care about this except printing */
  81. #define HFI1_CHIP_VERS_MIN 0U
  82. /* The Organization Unique Identifier (Mfg code), and its position in GUID */
  83. #define HFI1_OUI 0x001175
  84. #define HFI1_OUI_LSB 40
  85. #define DROP_PACKET_OFF 0
  86. #define DROP_PACKET_ON 1
  87. extern unsigned long hfi1_cap_mask;
  88. #define HFI1_CAP_KGET_MASK(mask, cap) ((mask) & HFI1_CAP_##cap)
  89. #define HFI1_CAP_UGET_MASK(mask, cap) \
  90. (((mask) >> HFI1_CAP_USER_SHIFT) & HFI1_CAP_##cap)
  91. #define HFI1_CAP_KGET(cap) (HFI1_CAP_KGET_MASK(hfi1_cap_mask, cap))
  92. #define HFI1_CAP_UGET(cap) (HFI1_CAP_UGET_MASK(hfi1_cap_mask, cap))
  93. #define HFI1_CAP_IS_KSET(cap) (!!HFI1_CAP_KGET(cap))
  94. #define HFI1_CAP_IS_USET(cap) (!!HFI1_CAP_UGET(cap))
  95. #define HFI1_MISC_GET() ((hfi1_cap_mask >> HFI1_CAP_MISC_SHIFT) & \
  96. HFI1_CAP_MISC_MASK)
  97. /* Offline Disabled Reason is 4-bits */
  98. #define HFI1_ODR_MASK(rsn) ((rsn) & OPA_PI_MASK_OFFLINE_REASON)
  99. /*
  100. * Control context is always 0 and handles the error packets.
  101. * It also handles the VL15 and multicast packets.
  102. */
  103. #define HFI1_CTRL_CTXT 0
  104. /*
  105. * Driver context will store software counters for each of the events
  106. * associated with these status registers
  107. */
  108. #define NUM_CCE_ERR_STATUS_COUNTERS 41
  109. #define NUM_RCV_ERR_STATUS_COUNTERS 64
  110. #define NUM_MISC_ERR_STATUS_COUNTERS 13
  111. #define NUM_SEND_PIO_ERR_STATUS_COUNTERS 36
  112. #define NUM_SEND_DMA_ERR_STATUS_COUNTERS 4
  113. #define NUM_SEND_EGRESS_ERR_STATUS_COUNTERS 64
  114. #define NUM_SEND_ERR_STATUS_COUNTERS 3
  115. #define NUM_SEND_CTXT_ERR_STATUS_COUNTERS 5
  116. #define NUM_SEND_DMA_ENG_ERR_STATUS_COUNTERS 24
  117. /*
  118. * per driver stats, either not device nor port-specific, or
  119. * summed over all of the devices and ports.
  120. * They are described by name via ipathfs filesystem, so layout
  121. * and number of elements can change without breaking compatibility.
  122. * If members are added or deleted hfi1_statnames[] in debugfs.c must
  123. * change to match.
  124. */
  125. struct hfi1_ib_stats {
  126. __u64 sps_ints; /* number of interrupts handled */
  127. __u64 sps_errints; /* number of error interrupts */
  128. __u64 sps_txerrs; /* tx-related packet errors */
  129. __u64 sps_rcverrs; /* non-crc rcv packet errors */
  130. __u64 sps_hwerrs; /* hardware errors reported (parity, etc.) */
  131. __u64 sps_nopiobufs; /* no pio bufs avail from kernel */
  132. __u64 sps_ctxts; /* number of contexts currently open */
  133. __u64 sps_lenerrs; /* number of kernel packets where RHF != LRH len */
  134. __u64 sps_buffull;
  135. __u64 sps_hdrfull;
  136. };
  137. extern struct hfi1_ib_stats hfi1_stats;
  138. extern const struct pci_error_handlers hfi1_pci_err_handler;
  139. /*
  140. * First-cut criterion for "device is active" is
  141. * two thousand dwords combined Tx, Rx traffic per
  142. * 5-second interval. SMA packets are 64 dwords,
  143. * and occur "a few per second", presumably each way.
  144. */
  145. #define HFI1_TRAFFIC_ACTIVE_THRESHOLD (2000)
  146. /*
  147. * Below contains all data related to a single context (formerly called port).
  148. */
  149. #ifdef CONFIG_DEBUG_FS
  150. struct hfi1_opcode_stats_perctx;
  151. #endif
  152. struct ctxt_eager_bufs {
  153. ssize_t size; /* total size of eager buffers */
  154. u32 count; /* size of buffers array */
  155. u32 numbufs; /* number of buffers allocated */
  156. u32 alloced; /* number of rcvarray entries used */
  157. u32 rcvtid_size; /* size of each eager rcv tid */
  158. u32 threshold; /* head update threshold */
  159. struct eager_buffer {
  160. void *addr;
  161. dma_addr_t dma;
  162. ssize_t len;
  163. } *buffers;
  164. struct {
  165. void *addr;
  166. dma_addr_t dma;
  167. } *rcvtids;
  168. };
  169. struct exp_tid_set {
  170. struct list_head list;
  171. u32 count;
  172. };
  173. struct hfi1_ctxtdata {
  174. /* shadow the ctxt's RcvCtrl register */
  175. u64 rcvctrl;
  176. /* rcvhdrq base, needs mmap before useful */
  177. void *rcvhdrq;
  178. /* kernel virtual address where hdrqtail is updated */
  179. volatile __le64 *rcvhdrtail_kvaddr;
  180. /*
  181. * Shared page for kernel to signal user processes that send buffers
  182. * need disarming. The process should call HFI1_CMD_DISARM_BUFS
  183. * or HFI1_CMD_ACK_EVENT with IPATH_EVENT_DISARM_BUFS set.
  184. */
  185. unsigned long *user_event_mask;
  186. /* when waiting for rcv or pioavail */
  187. wait_queue_head_t wait;
  188. /* rcvhdrq size (for freeing) */
  189. size_t rcvhdrq_size;
  190. /* number of rcvhdrq entries */
  191. u16 rcvhdrq_cnt;
  192. /* size of each of the rcvhdrq entries */
  193. u16 rcvhdrqentsize;
  194. /* mmap of hdrq, must fit in 44 bits */
  195. dma_addr_t rcvhdrq_dma;
  196. dma_addr_t rcvhdrqtailaddr_dma;
  197. struct ctxt_eager_bufs egrbufs;
  198. /* this receive context's assigned PIO ACK send context */
  199. struct send_context *sc;
  200. /* dynamic receive available interrupt timeout */
  201. u32 rcvavail_timeout;
  202. /*
  203. * number of opens (including slave sub-contexts) on this instance
  204. * (ignoring forks, dup, etc. for now)
  205. */
  206. int cnt;
  207. /*
  208. * how much space to leave at start of eager TID entries for
  209. * protocol use, on each TID
  210. */
  211. /* instead of calculating it */
  212. unsigned ctxt;
  213. /* non-zero if ctxt is being shared. */
  214. u16 subctxt_cnt;
  215. /* non-zero if ctxt is being shared. */
  216. u16 subctxt_id;
  217. u8 uuid[16];
  218. /* job key */
  219. u16 jkey;
  220. /* number of RcvArray groups for this context. */
  221. u32 rcv_array_groups;
  222. /* index of first eager TID entry. */
  223. u32 eager_base;
  224. /* number of expected TID entries */
  225. u32 expected_count;
  226. /* index of first expected TID entry. */
  227. u32 expected_base;
  228. struct exp_tid_set tid_group_list;
  229. struct exp_tid_set tid_used_list;
  230. struct exp_tid_set tid_full_list;
  231. /* lock protecting all Expected TID data */
  232. struct mutex exp_lock;
  233. /* number of pio bufs for this ctxt (all procs, if shared) */
  234. u32 piocnt;
  235. /* first pio buffer for this ctxt */
  236. u32 pio_base;
  237. /* chip offset of PIO buffers for this ctxt */
  238. u32 piobufs;
  239. /* per-context configuration flags */
  240. unsigned long flags;
  241. /* per-context event flags for fileops/intr communication */
  242. unsigned long event_flags;
  243. /* WAIT_RCV that timed out, no interrupt */
  244. u32 rcvwait_to;
  245. /* WAIT_PIO that timed out, no interrupt */
  246. u32 piowait_to;
  247. /* WAIT_RCV already happened, no wait */
  248. u32 rcvnowait;
  249. /* WAIT_PIO already happened, no wait */
  250. u32 pionowait;
  251. /* total number of polled urgent packets */
  252. u32 urgent;
  253. /* saved total number of polled urgent packets for poll edge trigger */
  254. u32 urgent_poll;
  255. /* same size as task_struct .comm[], command that opened context */
  256. char comm[TASK_COMM_LEN];
  257. /* so file ops can get at unit */
  258. struct hfi1_devdata *dd;
  259. /* so functions that need physical port can get it easily */
  260. struct hfi1_pportdata *ppd;
  261. /* A page of memory for rcvhdrhead, rcvegrhead, rcvegrtail * N */
  262. void *subctxt_uregbase;
  263. /* An array of pages for the eager receive buffers * N */
  264. void *subctxt_rcvegrbuf;
  265. /* An array of pages for the eager header queue entries * N */
  266. void *subctxt_rcvhdr_base;
  267. /* The version of the library which opened this ctxt */
  268. u32 userversion;
  269. /* Bitmask of active slaves */
  270. u32 active_slaves;
  271. /* Type of packets or conditions we want to poll for */
  272. u16 poll_type;
  273. /* receive packet sequence counter */
  274. u8 seq_cnt;
  275. u8 redirect_seq_cnt;
  276. /* ctxt rcvhdrq head offset */
  277. u32 head;
  278. u32 pkt_count;
  279. /* QPs waiting for context processing */
  280. struct list_head qp_wait_list;
  281. /* interrupt handling */
  282. u64 imask; /* clear interrupt mask */
  283. int ireg; /* clear interrupt register */
  284. unsigned numa_id; /* numa node of this context */
  285. /* verbs stats per CTX */
  286. struct hfi1_opcode_stats_perctx *opstats;
  287. /*
  288. * This is the kernel thread that will keep making
  289. * progress on the user sdma requests behind the scenes.
  290. * There is one per context (shared contexts use the master's).
  291. */
  292. struct task_struct *progress;
  293. struct list_head sdma_queues;
  294. /* protect sdma queues */
  295. spinlock_t sdma_qlock;
  296. /* Is ASPM interrupt supported for this context */
  297. bool aspm_intr_supported;
  298. /* ASPM state (enabled/disabled) for this context */
  299. bool aspm_enabled;
  300. /* Timer for re-enabling ASPM if interrupt activity quietens down */
  301. struct timer_list aspm_timer;
  302. /* Lock to serialize between intr, timer intr and user threads */
  303. spinlock_t aspm_lock;
  304. /* Is ASPM processing enabled for this context (in intr context) */
  305. bool aspm_intr_enable;
  306. /* Last interrupt timestamp */
  307. ktime_t aspm_ts_last_intr;
  308. /* Last timestamp at which we scheduled a timer for this context */
  309. ktime_t aspm_ts_timer_sched;
  310. /*
  311. * The interrupt handler for a particular receive context can vary
  312. * throughout it's lifetime. This is not a lock protected data member so
  313. * it must be updated atomically and the prev and new value must always
  314. * be valid. Worst case is we process an extra interrupt and up to 64
  315. * packets with the wrong interrupt handler.
  316. */
  317. int (*do_interrupt)(struct hfi1_ctxtdata *rcd, int threaded);
  318. };
  319. /*
  320. * Represents a single packet at a high level. Put commonly computed things in
  321. * here so we do not have to keep doing them over and over. The rule of thumb is
  322. * if something is used one time to derive some value, store that something in
  323. * here. If it is used multiple times, then store the result of that derivation
  324. * in here.
  325. */
  326. struct hfi1_packet {
  327. void *ebuf;
  328. void *hdr;
  329. struct hfi1_ctxtdata *rcd;
  330. __le32 *rhf_addr;
  331. struct rvt_qp *qp;
  332. struct ib_other_headers *ohdr;
  333. u64 rhf;
  334. u32 maxcnt;
  335. u32 rhqoff;
  336. u16 tlen;
  337. s16 etail;
  338. u8 hlen;
  339. u8 numpkt;
  340. u8 rsize;
  341. u8 updegr;
  342. u8 rcv_flags;
  343. u8 etype;
  344. };
  345. struct rvt_sge_state;
  346. /*
  347. * Get/Set IB link-level config parameters for f_get/set_ib_cfg()
  348. * Mostly for MADs that set or query link parameters, also ipath
  349. * config interfaces
  350. */
  351. #define HFI1_IB_CFG_LIDLMC 0 /* LID (LS16b) and Mask (MS16b) */
  352. #define HFI1_IB_CFG_LWID_DG_ENB 1 /* allowed Link-width downgrade */
  353. #define HFI1_IB_CFG_LWID_ENB 2 /* allowed Link-width */
  354. #define HFI1_IB_CFG_LWID 3 /* currently active Link-width */
  355. #define HFI1_IB_CFG_SPD_ENB 4 /* allowed Link speeds */
  356. #define HFI1_IB_CFG_SPD 5 /* current Link spd */
  357. #define HFI1_IB_CFG_RXPOL_ENB 6 /* Auto-RX-polarity enable */
  358. #define HFI1_IB_CFG_LREV_ENB 7 /* Auto-Lane-reversal enable */
  359. #define HFI1_IB_CFG_LINKLATENCY 8 /* Link Latency (IB1.2 only) */
  360. #define HFI1_IB_CFG_HRTBT 9 /* IB heartbeat off/enable/auto; DDR/QDR only */
  361. #define HFI1_IB_CFG_OP_VLS 10 /* operational VLs */
  362. #define HFI1_IB_CFG_VL_HIGH_CAP 11 /* num of VL high priority weights */
  363. #define HFI1_IB_CFG_VL_LOW_CAP 12 /* num of VL low priority weights */
  364. #define HFI1_IB_CFG_OVERRUN_THRESH 13 /* IB overrun threshold */
  365. #define HFI1_IB_CFG_PHYERR_THRESH 14 /* IB PHY error threshold */
  366. #define HFI1_IB_CFG_LINKDEFAULT 15 /* IB link default (sleep/poll) */
  367. #define HFI1_IB_CFG_PKEYS 16 /* update partition keys */
  368. #define HFI1_IB_CFG_MTU 17 /* update MTU in IBC */
  369. #define HFI1_IB_CFG_VL_HIGH_LIMIT 19
  370. #define HFI1_IB_CFG_PMA_TICKS 20 /* PMA sample tick resolution */
  371. #define HFI1_IB_CFG_PORT 21 /* switch port we are connected to */
  372. /*
  373. * HFI or Host Link States
  374. *
  375. * These describe the states the driver thinks the logical and physical
  376. * states are in. Used as an argument to set_link_state(). Implemented
  377. * as bits for easy multi-state checking. The actual state can only be
  378. * one.
  379. */
  380. #define __HLS_UP_INIT_BP 0
  381. #define __HLS_UP_ARMED_BP 1
  382. #define __HLS_UP_ACTIVE_BP 2
  383. #define __HLS_DN_DOWNDEF_BP 3 /* link down default */
  384. #define __HLS_DN_POLL_BP 4
  385. #define __HLS_DN_DISABLE_BP 5
  386. #define __HLS_DN_OFFLINE_BP 6
  387. #define __HLS_VERIFY_CAP_BP 7
  388. #define __HLS_GOING_UP_BP 8
  389. #define __HLS_GOING_OFFLINE_BP 9
  390. #define __HLS_LINK_COOLDOWN_BP 10
  391. #define HLS_UP_INIT BIT(__HLS_UP_INIT_BP)
  392. #define HLS_UP_ARMED BIT(__HLS_UP_ARMED_BP)
  393. #define HLS_UP_ACTIVE BIT(__HLS_UP_ACTIVE_BP)
  394. #define HLS_DN_DOWNDEF BIT(__HLS_DN_DOWNDEF_BP) /* link down default */
  395. #define HLS_DN_POLL BIT(__HLS_DN_POLL_BP)
  396. #define HLS_DN_DISABLE BIT(__HLS_DN_DISABLE_BP)
  397. #define HLS_DN_OFFLINE BIT(__HLS_DN_OFFLINE_BP)
  398. #define HLS_VERIFY_CAP BIT(__HLS_VERIFY_CAP_BP)
  399. #define HLS_GOING_UP BIT(__HLS_GOING_UP_BP)
  400. #define HLS_GOING_OFFLINE BIT(__HLS_GOING_OFFLINE_BP)
  401. #define HLS_LINK_COOLDOWN BIT(__HLS_LINK_COOLDOWN_BP)
  402. #define HLS_UP (HLS_UP_INIT | HLS_UP_ARMED | HLS_UP_ACTIVE)
  403. #define HLS_DOWN ~(HLS_UP)
  404. /* use this MTU size if none other is given */
  405. #define HFI1_DEFAULT_ACTIVE_MTU 10240
  406. /* use this MTU size as the default maximum */
  407. #define HFI1_DEFAULT_MAX_MTU 10240
  408. /* default partition key */
  409. #define DEFAULT_PKEY 0xffff
  410. /*
  411. * Possible fabric manager config parameters for fm_{get,set}_table()
  412. */
  413. #define FM_TBL_VL_HIGH_ARB 1 /* Get/set VL high prio weights */
  414. #define FM_TBL_VL_LOW_ARB 2 /* Get/set VL low prio weights */
  415. #define FM_TBL_BUFFER_CONTROL 3 /* Get/set Buffer Control */
  416. #define FM_TBL_SC2VLNT 4 /* Get/set SC->VLnt */
  417. #define FM_TBL_VL_PREEMPT_ELEMS 5 /* Get (no set) VL preempt elems */
  418. #define FM_TBL_VL_PREEMPT_MATRIX 6 /* Get (no set) VL preempt matrix */
  419. /*
  420. * Possible "operations" for f_rcvctrl(ppd, op, ctxt)
  421. * these are bits so they can be combined, e.g.
  422. * HFI1_RCVCTRL_INTRAVAIL_ENB | HFI1_RCVCTRL_CTXT_ENB
  423. */
  424. #define HFI1_RCVCTRL_TAILUPD_ENB 0x01
  425. #define HFI1_RCVCTRL_TAILUPD_DIS 0x02
  426. #define HFI1_RCVCTRL_CTXT_ENB 0x04
  427. #define HFI1_RCVCTRL_CTXT_DIS 0x08
  428. #define HFI1_RCVCTRL_INTRAVAIL_ENB 0x10
  429. #define HFI1_RCVCTRL_INTRAVAIL_DIS 0x20
  430. #define HFI1_RCVCTRL_PKEY_ENB 0x40 /* Note, default is enabled */
  431. #define HFI1_RCVCTRL_PKEY_DIS 0x80
  432. #define HFI1_RCVCTRL_TIDFLOW_ENB 0x0400
  433. #define HFI1_RCVCTRL_TIDFLOW_DIS 0x0800
  434. #define HFI1_RCVCTRL_ONE_PKT_EGR_ENB 0x1000
  435. #define HFI1_RCVCTRL_ONE_PKT_EGR_DIS 0x2000
  436. #define HFI1_RCVCTRL_NO_RHQ_DROP_ENB 0x4000
  437. #define HFI1_RCVCTRL_NO_RHQ_DROP_DIS 0x8000
  438. #define HFI1_RCVCTRL_NO_EGR_DROP_ENB 0x10000
  439. #define HFI1_RCVCTRL_NO_EGR_DROP_DIS 0x20000
  440. /* partition enforcement flags */
  441. #define HFI1_PART_ENFORCE_IN 0x1
  442. #define HFI1_PART_ENFORCE_OUT 0x2
  443. /* how often we check for synthetic counter wrap around */
  444. #define SYNTH_CNT_TIME 2
  445. /* Counter flags */
  446. #define CNTR_NORMAL 0x0 /* Normal counters, just read register */
  447. #define CNTR_SYNTH 0x1 /* Synthetic counters, saturate at all 1s */
  448. #define CNTR_DISABLED 0x2 /* Disable this counter */
  449. #define CNTR_32BIT 0x4 /* Simulate 64 bits for this counter */
  450. #define CNTR_VL 0x8 /* Per VL counter */
  451. #define CNTR_SDMA 0x10
  452. #define CNTR_INVALID_VL -1 /* Specifies invalid VL */
  453. #define CNTR_MODE_W 0x0
  454. #define CNTR_MODE_R 0x1
  455. /* VLs Supported/Operational */
  456. #define HFI1_MIN_VLS_SUPPORTED 1
  457. #define HFI1_MAX_VLS_SUPPORTED 8
  458. #define HFI1_GUIDS_PER_PORT 5
  459. #define HFI1_PORT_GUID_INDEX 0
  460. static inline void incr_cntr64(u64 *cntr)
  461. {
  462. if (*cntr < (u64)-1LL)
  463. (*cntr)++;
  464. }
  465. static inline void incr_cntr32(u32 *cntr)
  466. {
  467. if (*cntr < (u32)-1LL)
  468. (*cntr)++;
  469. }
  470. #define MAX_NAME_SIZE 64
  471. struct hfi1_msix_entry {
  472. enum irq_type type;
  473. struct msix_entry msix;
  474. void *arg;
  475. char name[MAX_NAME_SIZE];
  476. cpumask_t mask;
  477. struct irq_affinity_notify notify;
  478. };
  479. /* per-SL CCA information */
  480. struct cca_timer {
  481. struct hrtimer hrtimer;
  482. struct hfi1_pportdata *ppd; /* read-only */
  483. int sl; /* read-only */
  484. u16 ccti; /* read/write - current value of CCTI */
  485. };
  486. struct link_down_reason {
  487. /*
  488. * SMA-facing value. Should be set from .latest when
  489. * HLS_UP_* -> HLS_DN_* transition actually occurs.
  490. */
  491. u8 sma;
  492. u8 latest;
  493. };
  494. enum {
  495. LO_PRIO_TABLE,
  496. HI_PRIO_TABLE,
  497. MAX_PRIO_TABLE
  498. };
  499. struct vl_arb_cache {
  500. /* protect vl arb cache */
  501. spinlock_t lock;
  502. struct ib_vl_weight_elem table[VL_ARB_TABLE_SIZE];
  503. };
  504. /*
  505. * The structure below encapsulates data relevant to a physical IB Port.
  506. * Current chips support only one such port, but the separation
  507. * clarifies things a bit. Note that to conform to IB conventions,
  508. * port-numbers are one-based. The first or only port is port1.
  509. */
  510. struct hfi1_pportdata {
  511. struct hfi1_ibport ibport_data;
  512. struct hfi1_devdata *dd;
  513. struct kobject pport_cc_kobj;
  514. struct kobject sc2vl_kobj;
  515. struct kobject sl2sc_kobj;
  516. struct kobject vl2mtu_kobj;
  517. /* PHY support */
  518. struct qsfp_data qsfp_info;
  519. /* Values for SI tuning of SerDes */
  520. u32 port_type;
  521. u32 tx_preset_eq;
  522. u32 tx_preset_noeq;
  523. u32 rx_preset;
  524. u8 local_atten;
  525. u8 remote_atten;
  526. u8 default_atten;
  527. u8 max_power_class;
  528. /* GUIDs for this interface, in host order, guids[0] is a port guid */
  529. u64 guids[HFI1_GUIDS_PER_PORT];
  530. /* GUID for peer interface, in host order */
  531. u64 neighbor_guid;
  532. /* up or down physical link state */
  533. u32 linkup;
  534. /*
  535. * this address is mapped read-only into user processes so they can
  536. * get status cheaply, whenever they want. One qword of status per port
  537. */
  538. u64 *statusp;
  539. /* SendDMA related entries */
  540. struct workqueue_struct *hfi1_wq;
  541. /* move out of interrupt context */
  542. struct work_struct link_vc_work;
  543. struct work_struct link_up_work;
  544. struct work_struct link_down_work;
  545. struct work_struct sma_message_work;
  546. struct work_struct freeze_work;
  547. struct work_struct link_downgrade_work;
  548. struct work_struct link_bounce_work;
  549. struct delayed_work start_link_work;
  550. /* host link state variables */
  551. struct mutex hls_lock;
  552. u32 host_link_state;
  553. u32 lstate; /* logical link state */
  554. /* these are the "32 bit" regs */
  555. u32 ibmtu; /* The MTU programmed for this unit */
  556. /*
  557. * Current max size IB packet (in bytes) including IB headers, that
  558. * we can send. Changes when ibmtu changes.
  559. */
  560. u32 ibmaxlen;
  561. u32 current_egress_rate; /* units [10^6 bits/sec] */
  562. /* LID programmed for this instance */
  563. u16 lid;
  564. /* list of pkeys programmed; 0 if not set */
  565. u16 pkeys[MAX_PKEY_VALUES];
  566. u16 link_width_supported;
  567. u16 link_width_downgrade_supported;
  568. u16 link_speed_supported;
  569. u16 link_width_enabled;
  570. u16 link_width_downgrade_enabled;
  571. u16 link_speed_enabled;
  572. u16 link_width_active;
  573. u16 link_width_downgrade_tx_active;
  574. u16 link_width_downgrade_rx_active;
  575. u16 link_speed_active;
  576. u8 vls_supported;
  577. u8 vls_operational;
  578. u8 actual_vls_operational;
  579. /* LID mask control */
  580. u8 lmc;
  581. /* Rx Polarity inversion (compensate for ~tx on partner) */
  582. u8 rx_pol_inv;
  583. u8 hw_pidx; /* physical port index */
  584. u8 port; /* IB port number and index into dd->pports - 1 */
  585. /* type of neighbor node */
  586. u8 neighbor_type;
  587. u8 neighbor_normal;
  588. u8 neighbor_fm_security; /* 1 if firmware checking is disabled */
  589. u8 neighbor_port_number;
  590. u8 is_sm_config_started;
  591. u8 offline_disabled_reason;
  592. u8 is_active_optimize_enabled;
  593. u8 driver_link_ready; /* driver ready for active link */
  594. u8 link_enabled; /* link enabled? */
  595. u8 linkinit_reason;
  596. u8 local_tx_rate; /* rate given to 8051 firmware */
  597. u8 last_pstate; /* info only */
  598. u8 qsfp_retry_count;
  599. /* placeholders for IB MAD packet settings */
  600. u8 overrun_threshold;
  601. u8 phy_error_threshold;
  602. /* Used to override LED behavior for things like maintenance beaconing*/
  603. /*
  604. * Alternates per phase of blink
  605. * [0] holds LED off duration, [1] holds LED on duration
  606. */
  607. unsigned long led_override_vals[2];
  608. u8 led_override_phase; /* LSB picks from vals[] */
  609. atomic_t led_override_timer_active;
  610. /* Used to flash LEDs in override mode */
  611. struct timer_list led_override_timer;
  612. u32 sm_trap_qp;
  613. u32 sa_qp;
  614. /*
  615. * cca_timer_lock protects access to the per-SL cca_timer
  616. * structures (specifically the ccti member).
  617. */
  618. spinlock_t cca_timer_lock ____cacheline_aligned_in_smp;
  619. struct cca_timer cca_timer[OPA_MAX_SLS];
  620. /* List of congestion control table entries */
  621. struct ib_cc_table_entry_shadow ccti_entries[CC_TABLE_SHADOW_MAX];
  622. /* congestion entries, each entry corresponding to a SL */
  623. struct opa_congestion_setting_entry_shadow
  624. congestion_entries[OPA_MAX_SLS];
  625. /*
  626. * cc_state_lock protects (write) access to the per-port
  627. * struct cc_state.
  628. */
  629. spinlock_t cc_state_lock ____cacheline_aligned_in_smp;
  630. struct cc_state __rcu *cc_state;
  631. /* Total number of congestion control table entries */
  632. u16 total_cct_entry;
  633. /* Bit map identifying service level */
  634. u32 cc_sl_control_map;
  635. /* CA's max number of 64 entry units in the congestion control table */
  636. u8 cc_max_table_entries;
  637. /*
  638. * begin congestion log related entries
  639. * cc_log_lock protects all congestion log related data
  640. */
  641. spinlock_t cc_log_lock ____cacheline_aligned_in_smp;
  642. u8 threshold_cong_event_map[OPA_MAX_SLS / 8];
  643. u16 threshold_event_counter;
  644. struct opa_hfi1_cong_log_event_internal cc_events[OPA_CONG_LOG_ELEMS];
  645. int cc_log_idx; /* index for logging events */
  646. int cc_mad_idx; /* index for reporting events */
  647. /* end congestion log related entries */
  648. struct vl_arb_cache vl_arb_cache[MAX_PRIO_TABLE];
  649. /* port relative counter buffer */
  650. u64 *cntrs;
  651. /* port relative synthetic counter buffer */
  652. u64 *scntrs;
  653. /* port_xmit_discards are synthesized from different egress errors */
  654. u64 port_xmit_discards;
  655. u64 port_xmit_discards_vl[C_VL_COUNT];
  656. u64 port_xmit_constraint_errors;
  657. u64 port_rcv_constraint_errors;
  658. /* count of 'link_err' interrupts from DC */
  659. u64 link_downed;
  660. /* number of times link retrained successfully */
  661. u64 link_up;
  662. /* number of times a link unknown frame was reported */
  663. u64 unknown_frame_count;
  664. /* port_ltp_crc_mode is returned in 'portinfo' MADs */
  665. u16 port_ltp_crc_mode;
  666. /* port_crc_mode_enabled is the crc we support */
  667. u8 port_crc_mode_enabled;
  668. /* mgmt_allowed is also returned in 'portinfo' MADs */
  669. u8 mgmt_allowed;
  670. u8 part_enforce; /* partition enforcement flags */
  671. struct link_down_reason local_link_down_reason;
  672. struct link_down_reason neigh_link_down_reason;
  673. /* Value to be sent to link peer on LinkDown .*/
  674. u8 remote_link_down_reason;
  675. /* Error events that will cause a port bounce. */
  676. u32 port_error_action;
  677. struct work_struct linkstate_active_work;
  678. /* Does this port need to prescan for FECNs */
  679. bool cc_prescan;
  680. };
  681. typedef int (*rhf_rcv_function_ptr)(struct hfi1_packet *packet);
  682. typedef void (*opcode_handler)(struct hfi1_packet *packet);
  683. /* return values for the RHF receive functions */
  684. #define RHF_RCV_CONTINUE 0 /* keep going */
  685. #define RHF_RCV_DONE 1 /* stop, this packet processed */
  686. #define RHF_RCV_REPROCESS 2 /* stop. retain this packet */
  687. struct rcv_array_data {
  688. u8 group_size;
  689. u16 ngroups;
  690. u16 nctxt_extra;
  691. };
  692. struct per_vl_data {
  693. u16 mtu;
  694. struct send_context *sc;
  695. };
  696. /* 16 to directly index */
  697. #define PER_VL_SEND_CONTEXTS 16
  698. struct err_info_rcvport {
  699. u8 status_and_code;
  700. u64 packet_flit1;
  701. u64 packet_flit2;
  702. };
  703. struct err_info_constraint {
  704. u8 status;
  705. u16 pkey;
  706. u32 slid;
  707. };
  708. struct hfi1_temp {
  709. unsigned int curr; /* current temperature */
  710. unsigned int lo_lim; /* low temperature limit */
  711. unsigned int hi_lim; /* high temperature limit */
  712. unsigned int crit_lim; /* critical temperature limit */
  713. u8 triggers; /* temperature triggers */
  714. };
  715. struct hfi1_i2c_bus {
  716. struct hfi1_devdata *controlling_dd; /* current controlling device */
  717. struct i2c_adapter adapter; /* bus details */
  718. struct i2c_algo_bit_data algo; /* bus algorithm details */
  719. int num; /* bus number, 0 or 1 */
  720. };
  721. /* common data between shared ASIC HFIs */
  722. struct hfi1_asic_data {
  723. struct hfi1_devdata *dds[2]; /* back pointers */
  724. struct mutex asic_resource_mutex;
  725. struct hfi1_i2c_bus *i2c_bus0;
  726. struct hfi1_i2c_bus *i2c_bus1;
  727. };
  728. /* device data struct now contains only "general per-device" info.
  729. * fields related to a physical IB port are in a hfi1_pportdata struct.
  730. */
  731. struct sdma_engine;
  732. struct sdma_vl_map;
  733. #define BOARD_VERS_MAX 96 /* how long the version string can be */
  734. #define SERIAL_MAX 16 /* length of the serial number */
  735. typedef int (*send_routine)(struct rvt_qp *, struct hfi1_pkt_state *, u64);
  736. struct hfi1_devdata {
  737. struct hfi1_ibdev verbs_dev; /* must be first */
  738. struct list_head list;
  739. /* pointers to related structs for this device */
  740. /* pci access data structure */
  741. struct pci_dev *pcidev;
  742. struct cdev user_cdev;
  743. struct cdev diag_cdev;
  744. struct cdev ui_cdev;
  745. struct device *user_device;
  746. struct device *diag_device;
  747. struct device *ui_device;
  748. /* mem-mapped pointer to base of chip regs */
  749. u8 __iomem *kregbase;
  750. /* end of mem-mapped chip space excluding sendbuf and user regs */
  751. u8 __iomem *kregend;
  752. /* physical address of chip for io_remap, etc. */
  753. resource_size_t physaddr;
  754. /* Per VL data. Enough for all VLs but not all elements are set/used. */
  755. struct per_vl_data vld[PER_VL_SEND_CONTEXTS];
  756. /* send context data */
  757. struct send_context_info *send_contexts;
  758. /* map hardware send contexts to software index */
  759. u8 *hw_to_sw;
  760. /* spinlock for allocating and releasing send context resources */
  761. spinlock_t sc_lock;
  762. /* lock for pio_map */
  763. spinlock_t pio_map_lock;
  764. /* Send Context initialization lock. */
  765. spinlock_t sc_init_lock;
  766. /* lock for sdma_map */
  767. spinlock_t sde_map_lock;
  768. /* array of kernel send contexts */
  769. struct send_context **kernel_send_context;
  770. /* array of vl maps */
  771. struct pio_vl_map __rcu *pio_map;
  772. /* default flags to last descriptor */
  773. u64 default_desc1;
  774. /* fields common to all SDMA engines */
  775. volatile __le64 *sdma_heads_dma; /* DMA'ed by chip */
  776. dma_addr_t sdma_heads_phys;
  777. void *sdma_pad_dma; /* DMA'ed by chip */
  778. dma_addr_t sdma_pad_phys;
  779. /* for deallocation */
  780. size_t sdma_heads_size;
  781. /* number from the chip */
  782. u32 chip_sdma_engines;
  783. /* num used */
  784. u32 num_sdma;
  785. /* array of engines sized by num_sdma */
  786. struct sdma_engine *per_sdma;
  787. /* array of vl maps */
  788. struct sdma_vl_map __rcu *sdma_map;
  789. /* SPC freeze waitqueue and variable */
  790. wait_queue_head_t sdma_unfreeze_wq;
  791. atomic_t sdma_unfreeze_count;
  792. u32 lcb_access_count; /* count of LCB users */
  793. /* common data between shared ASIC HFIs in this OS */
  794. struct hfi1_asic_data *asic_data;
  795. /* mem-mapped pointer to base of PIO buffers */
  796. void __iomem *piobase;
  797. /*
  798. * write-combining mem-mapped pointer to base of RcvArray
  799. * memory.
  800. */
  801. void __iomem *rcvarray_wc;
  802. /*
  803. * credit return base - a per-NUMA range of DMA address that
  804. * the chip will use to update the per-context free counter
  805. */
  806. struct credit_return_base *cr_base;
  807. /* send context numbers and sizes for each type */
  808. struct sc_config_sizes sc_sizes[SC_MAX];
  809. char *boardname; /* human readable board info */
  810. /* reset value */
  811. u64 z_int_counter;
  812. u64 z_rcv_limit;
  813. u64 z_send_schedule;
  814. u64 __percpu *send_schedule;
  815. /* number of receive contexts in use by the driver */
  816. u32 num_rcv_contexts;
  817. /* number of pio send contexts in use by the driver */
  818. u32 num_send_contexts;
  819. /*
  820. * number of ctxts available for PSM open
  821. */
  822. u32 freectxts;
  823. /* total number of available user/PSM contexts */
  824. u32 num_user_contexts;
  825. /* base receive interrupt timeout, in CSR units */
  826. u32 rcv_intr_timeout_csr;
  827. u32 freezelen; /* max length of freezemsg */
  828. u64 __iomem *egrtidbase;
  829. spinlock_t sendctrl_lock; /* protect changes to SendCtrl */
  830. spinlock_t rcvctrl_lock; /* protect changes to RcvCtrl */
  831. /* around rcd and (user ctxts) ctxt_cnt use (intr vs free) */
  832. spinlock_t uctxt_lock; /* rcd and user context changes */
  833. /* exclusive access to 8051 */
  834. spinlock_t dc8051_lock;
  835. /* exclusive access to 8051 memory */
  836. spinlock_t dc8051_memlock;
  837. int dc8051_timed_out; /* remember if the 8051 timed out */
  838. /*
  839. * A page that will hold event notification bitmaps for all
  840. * contexts. This page will be mapped into all processes.
  841. */
  842. unsigned long *events;
  843. /*
  844. * per unit status, see also portdata statusp
  845. * mapped read-only into user processes so they can get unit and
  846. * IB link status cheaply
  847. */
  848. struct hfi1_status *status;
  849. /* revision register shadow */
  850. u64 revision;
  851. /* Base GUID for device (network order) */
  852. u64 base_guid;
  853. /* these are the "32 bit" regs */
  854. /* value we put in kr_rcvhdrsize */
  855. u32 rcvhdrsize;
  856. /* number of receive contexts the chip supports */
  857. u32 chip_rcv_contexts;
  858. /* number of receive array entries */
  859. u32 chip_rcv_array_count;
  860. /* number of PIO send contexts the chip supports */
  861. u32 chip_send_contexts;
  862. /* number of bytes in the PIO memory buffer */
  863. u32 chip_pio_mem_size;
  864. /* number of bytes in the SDMA memory buffer */
  865. u32 chip_sdma_mem_size;
  866. /* size of each rcvegrbuffer */
  867. u32 rcvegrbufsize;
  868. /* log2 of above */
  869. u16 rcvegrbufsize_shift;
  870. /* both sides of the PCIe link are gen3 capable */
  871. u8 link_gen3_capable;
  872. /* default link down value (poll/sleep) */
  873. u8 link_default;
  874. /* localbus width (1, 2,4,8,16,32) from config space */
  875. u32 lbus_width;
  876. /* localbus speed in MHz */
  877. u32 lbus_speed;
  878. int unit; /* unit # of this chip */
  879. int node; /* home node of this chip */
  880. /* save these PCI fields to restore after a reset */
  881. u32 pcibar0;
  882. u32 pcibar1;
  883. u32 pci_rom;
  884. u16 pci_command;
  885. u16 pcie_devctl;
  886. u16 pcie_lnkctl;
  887. u16 pcie_devctl2;
  888. u32 pci_msix0;
  889. u32 pci_lnkctl3;
  890. u32 pci_tph2;
  891. /*
  892. * ASCII serial number, from flash, large enough for original
  893. * all digit strings, and longer serial number format
  894. */
  895. u8 serial[SERIAL_MAX];
  896. /* human readable board version */
  897. u8 boardversion[BOARD_VERS_MAX];
  898. u8 lbus_info[32]; /* human readable localbus info */
  899. /* chip major rev, from CceRevision */
  900. u8 majrev;
  901. /* chip minor rev, from CceRevision */
  902. u8 minrev;
  903. /* hardware ID */
  904. u8 hfi1_id;
  905. /* implementation code */
  906. u8 icode;
  907. /* vAU of this device */
  908. u8 vau;
  909. /* vCU of this device */
  910. u8 vcu;
  911. /* link credits of this device */
  912. u16 link_credits;
  913. /* initial vl15 credits to use */
  914. u16 vl15_init;
  915. /* Misc small ints */
  916. u8 n_krcv_queues;
  917. u8 qos_shift;
  918. u16 irev; /* implementation revision */
  919. u32 dc8051_ver; /* 8051 firmware version */
  920. spinlock_t hfi1_diag_trans_lock; /* protect diag observer ops */
  921. struct platform_config platform_config;
  922. struct platform_config_cache pcfg_cache;
  923. struct diag_client *diag_client;
  924. /* MSI-X information */
  925. struct hfi1_msix_entry *msix_entries;
  926. u32 num_msix_entries;
  927. /* INTx information */
  928. u32 requested_intx_irq; /* did we request one? */
  929. char intx_name[MAX_NAME_SIZE]; /* INTx name */
  930. /* general interrupt: mask of handled interrupts */
  931. u64 gi_mask[CCE_NUM_INT_CSRS];
  932. struct rcv_array_data rcv_entries;
  933. /* cycle length of PS* counters in HW (in picoseconds) */
  934. u16 psxmitwait_check_rate;
  935. /*
  936. * 64 bit synthetic counters
  937. */
  938. struct timer_list synth_stats_timer;
  939. /*
  940. * device counters
  941. */
  942. char *cntrnames;
  943. size_t cntrnameslen;
  944. size_t ndevcntrs;
  945. u64 *cntrs;
  946. u64 *scntrs;
  947. /*
  948. * remembered values for synthetic counters
  949. */
  950. u64 last_tx;
  951. u64 last_rx;
  952. /*
  953. * per-port counters
  954. */
  955. size_t nportcntrs;
  956. char *portcntrnames;
  957. size_t portcntrnameslen;
  958. struct err_info_rcvport err_info_rcvport;
  959. struct err_info_constraint err_info_rcv_constraint;
  960. struct err_info_constraint err_info_xmit_constraint;
  961. atomic_t drop_packet;
  962. u8 do_drop;
  963. u8 err_info_uncorrectable;
  964. u8 err_info_fmconfig;
  965. /*
  966. * Software counters for the status bits defined by the
  967. * associated error status registers
  968. */
  969. u64 cce_err_status_cnt[NUM_CCE_ERR_STATUS_COUNTERS];
  970. u64 rcv_err_status_cnt[NUM_RCV_ERR_STATUS_COUNTERS];
  971. u64 misc_err_status_cnt[NUM_MISC_ERR_STATUS_COUNTERS];
  972. u64 send_pio_err_status_cnt[NUM_SEND_PIO_ERR_STATUS_COUNTERS];
  973. u64 send_dma_err_status_cnt[NUM_SEND_DMA_ERR_STATUS_COUNTERS];
  974. u64 send_egress_err_status_cnt[NUM_SEND_EGRESS_ERR_STATUS_COUNTERS];
  975. u64 send_err_status_cnt[NUM_SEND_ERR_STATUS_COUNTERS];
  976. /* Software counter that spans all contexts */
  977. u64 sw_ctxt_err_status_cnt[NUM_SEND_CTXT_ERR_STATUS_COUNTERS];
  978. /* Software counter that spans all DMA engines */
  979. u64 sw_send_dma_eng_err_status_cnt[
  980. NUM_SEND_DMA_ENG_ERR_STATUS_COUNTERS];
  981. /* Software counter that aggregates all cce_err_status errors */
  982. u64 sw_cce_err_status_aggregate;
  983. /* Software counter that aggregates all bypass packet rcv errors */
  984. u64 sw_rcv_bypass_packet_errors;
  985. /* receive interrupt function */
  986. rhf_rcv_function_ptr normal_rhf_rcv_functions[8];
  987. /* Save the enabled LCB error bits */
  988. u64 lcb_err_en;
  989. /*
  990. * Capability to have different send engines simply by changing a
  991. * pointer value.
  992. */
  993. send_routine process_pio_send ____cacheline_aligned_in_smp;
  994. send_routine process_dma_send;
  995. void (*pio_inline_send)(struct hfi1_devdata *dd, struct pio_buf *pbuf,
  996. u64 pbc, const void *from, size_t count);
  997. /* hfi1_pportdata, points to array of (physical) port-specific
  998. * data structs, indexed by pidx (0..n-1)
  999. */
  1000. struct hfi1_pportdata *pport;
  1001. /* receive context data */
  1002. struct hfi1_ctxtdata **rcd;
  1003. u64 __percpu *int_counter;
  1004. /* device (not port) flags, basically device capabilities */
  1005. u16 flags;
  1006. /* Number of physical ports available */
  1007. u8 num_pports;
  1008. /* Lowest context number which can be used by user processes */
  1009. u8 first_user_ctxt;
  1010. /* adding a new field here would make it part of this cacheline */
  1011. /* seqlock for sc2vl */
  1012. seqlock_t sc2vl_lock ____cacheline_aligned_in_smp;
  1013. u64 sc2vl[4];
  1014. /* receive interrupt functions */
  1015. rhf_rcv_function_ptr *rhf_rcv_function_map;
  1016. u64 __percpu *rcv_limit;
  1017. u16 rhf_offset; /* offset of RHF within receive header entry */
  1018. /* adding a new field here would make it part of this cacheline */
  1019. /* OUI comes from the HW. Used everywhere as 3 separate bytes. */
  1020. u8 oui1;
  1021. u8 oui2;
  1022. u8 oui3;
  1023. u8 dc_shutdown;
  1024. /* Timer and counter used to detect RcvBufOvflCnt changes */
  1025. struct timer_list rcverr_timer;
  1026. wait_queue_head_t event_queue;
  1027. /* receive context tail dummy address */
  1028. __le64 *rcvhdrtail_dummy_kvaddr;
  1029. dma_addr_t rcvhdrtail_dummy_dma;
  1030. u32 rcv_ovfl_cnt;
  1031. /* Serialize ASPM enable/disable between multiple verbs contexts */
  1032. spinlock_t aspm_lock;
  1033. /* Number of verbs contexts which have disabled ASPM */
  1034. atomic_t aspm_disabled_cnt;
  1035. /* Keeps track of user space clients */
  1036. atomic_t user_refcount;
  1037. /* Used to wait for outstanding user space clients before dev removal */
  1038. struct completion user_comp;
  1039. bool eprom_available; /* true if EPROM is available for this device */
  1040. bool aspm_supported; /* Does HW support ASPM */
  1041. bool aspm_enabled; /* ASPM state: enabled/disabled */
  1042. struct rhashtable *sdma_rht;
  1043. struct kobject kobj;
  1044. };
  1045. /* 8051 firmware version helper */
  1046. #define dc8051_ver(a, b, c) ((a) << 16 | (b) << 8 | (c))
  1047. #define dc8051_ver_maj(a) (((a) & 0xff0000) >> 16)
  1048. #define dc8051_ver_min(a) (((a) & 0x00ff00) >> 8)
  1049. #define dc8051_ver_patch(a) ((a) & 0x0000ff)
  1050. /* f_put_tid types */
  1051. #define PT_EXPECTED 0
  1052. #define PT_EAGER 1
  1053. #define PT_INVALID 2
  1054. struct tid_rb_node;
  1055. struct mmu_rb_node;
  1056. struct mmu_rb_handler;
  1057. /* Private data for file operations */
  1058. struct hfi1_filedata {
  1059. struct hfi1_ctxtdata *uctxt;
  1060. unsigned subctxt;
  1061. struct hfi1_user_sdma_comp_q *cq;
  1062. struct hfi1_user_sdma_pkt_q *pq;
  1063. /* for cpu affinity; -1 if none */
  1064. int rec_cpu_num;
  1065. u32 tid_n_pinned;
  1066. struct mmu_rb_handler *handler;
  1067. struct tid_rb_node **entry_to_rb;
  1068. spinlock_t tid_lock; /* protect tid_[limit,used] counters */
  1069. u32 tid_limit;
  1070. u32 tid_used;
  1071. u32 *invalid_tids;
  1072. u32 invalid_tid_idx;
  1073. /* protect invalid_tids array and invalid_tid_idx */
  1074. spinlock_t invalid_lock;
  1075. struct mm_struct *mm;
  1076. };
  1077. extern struct list_head hfi1_dev_list;
  1078. extern spinlock_t hfi1_devs_lock;
  1079. struct hfi1_devdata *hfi1_lookup(int unit);
  1080. extern u32 hfi1_cpulist_count;
  1081. extern unsigned long *hfi1_cpulist;
  1082. int hfi1_init(struct hfi1_devdata *, int);
  1083. int hfi1_count_units(int *npresentp, int *nupp);
  1084. int hfi1_count_active_units(void);
  1085. int hfi1_diag_add(struct hfi1_devdata *);
  1086. void hfi1_diag_remove(struct hfi1_devdata *);
  1087. void handle_linkup_change(struct hfi1_devdata *dd, u32 linkup);
  1088. void handle_user_interrupt(struct hfi1_ctxtdata *rcd);
  1089. int hfi1_create_rcvhdrq(struct hfi1_devdata *, struct hfi1_ctxtdata *);
  1090. int hfi1_setup_eagerbufs(struct hfi1_ctxtdata *);
  1091. int hfi1_create_ctxts(struct hfi1_devdata *dd);
  1092. struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *, u32, int);
  1093. void hfi1_init_pportdata(struct pci_dev *, struct hfi1_pportdata *,
  1094. struct hfi1_devdata *, u8, u8);
  1095. void hfi1_free_ctxtdata(struct hfi1_devdata *, struct hfi1_ctxtdata *);
  1096. int handle_receive_interrupt(struct hfi1_ctxtdata *, int);
  1097. int handle_receive_interrupt_nodma_rtail(struct hfi1_ctxtdata *, int);
  1098. int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *, int);
  1099. void set_all_slowpath(struct hfi1_devdata *dd);
  1100. extern const struct pci_device_id hfi1_pci_tbl[];
  1101. /* receive packet handler dispositions */
  1102. #define RCV_PKT_OK 0x0 /* keep going */
  1103. #define RCV_PKT_LIMIT 0x1 /* stop, hit limit, start thread */
  1104. #define RCV_PKT_DONE 0x2 /* stop, no more packets detected */
  1105. /* calculate the current RHF address */
  1106. static inline __le32 *get_rhf_addr(struct hfi1_ctxtdata *rcd)
  1107. {
  1108. return (__le32 *)rcd->rcvhdrq + rcd->head + rcd->dd->rhf_offset;
  1109. }
  1110. int hfi1_reset_device(int);
  1111. /* return the driver's idea of the logical OPA port state */
  1112. static inline u32 driver_lstate(struct hfi1_pportdata *ppd)
  1113. {
  1114. return ppd->lstate; /* use the cached value */
  1115. }
  1116. void receive_interrupt_work(struct work_struct *work);
  1117. /* extract service channel from header and rhf */
  1118. static inline int hdr2sc(struct ib_header *hdr, u64 rhf)
  1119. {
  1120. return ((be16_to_cpu(hdr->lrh[0]) >> 12) & 0xf) |
  1121. ((!!(rhf_dc_info(rhf))) << 4);
  1122. }
  1123. #define HFI1_JKEY_WIDTH 16
  1124. #define HFI1_JKEY_MASK (BIT(16) - 1)
  1125. #define HFI1_ADMIN_JKEY_RANGE 32
  1126. /*
  1127. * J_KEYs are split and allocated in the following groups:
  1128. * 0 - 31 - users with administrator privileges
  1129. * 32 - 63 - kernel protocols using KDETH packets
  1130. * 64 - 65535 - all other users using KDETH packets
  1131. */
  1132. static inline u16 generate_jkey(kuid_t uid)
  1133. {
  1134. u16 jkey = from_kuid(current_user_ns(), uid) & HFI1_JKEY_MASK;
  1135. if (capable(CAP_SYS_ADMIN))
  1136. jkey &= HFI1_ADMIN_JKEY_RANGE - 1;
  1137. else if (jkey < 64)
  1138. jkey |= BIT(HFI1_JKEY_WIDTH - 1);
  1139. return jkey;
  1140. }
  1141. /*
  1142. * active_egress_rate
  1143. *
  1144. * returns the active egress rate in units of [10^6 bits/sec]
  1145. */
  1146. static inline u32 active_egress_rate(struct hfi1_pportdata *ppd)
  1147. {
  1148. u16 link_speed = ppd->link_speed_active;
  1149. u16 link_width = ppd->link_width_active;
  1150. u32 egress_rate;
  1151. if (link_speed == OPA_LINK_SPEED_25G)
  1152. egress_rate = 25000;
  1153. else /* assume OPA_LINK_SPEED_12_5G */
  1154. egress_rate = 12500;
  1155. switch (link_width) {
  1156. case OPA_LINK_WIDTH_4X:
  1157. egress_rate *= 4;
  1158. break;
  1159. case OPA_LINK_WIDTH_3X:
  1160. egress_rate *= 3;
  1161. break;
  1162. case OPA_LINK_WIDTH_2X:
  1163. egress_rate *= 2;
  1164. break;
  1165. default:
  1166. /* assume IB_WIDTH_1X */
  1167. break;
  1168. }
  1169. return egress_rate;
  1170. }
  1171. /*
  1172. * egress_cycles
  1173. *
  1174. * Returns the number of 'fabric clock cycles' to egress a packet
  1175. * of length 'len' bytes, at 'rate' Mbit/s. Since the fabric clock
  1176. * rate is (approximately) 805 MHz, the units of the returned value
  1177. * are (1/805 MHz).
  1178. */
  1179. static inline u32 egress_cycles(u32 len, u32 rate)
  1180. {
  1181. u32 cycles;
  1182. /*
  1183. * cycles is:
  1184. *
  1185. * (length) [bits] / (rate) [bits/sec]
  1186. * ---------------------------------------------------
  1187. * fabric_clock_period == 1 /(805 * 10^6) [cycles/sec]
  1188. */
  1189. cycles = len * 8; /* bits */
  1190. cycles *= 805;
  1191. cycles /= rate;
  1192. return cycles;
  1193. }
  1194. void set_link_ipg(struct hfi1_pportdata *ppd);
  1195. void process_becn(struct hfi1_pportdata *ppd, u8 sl, u16 rlid, u32 lqpn,
  1196. u32 rqpn, u8 svc_type);
  1197. void return_cnp(struct hfi1_ibport *ibp, struct rvt_qp *qp, u32 remote_qpn,
  1198. u32 pkey, u32 slid, u32 dlid, u8 sc5,
  1199. const struct ib_grh *old_grh);
  1200. #define PKEY_CHECK_INVALID -1
  1201. int egress_pkey_check(struct hfi1_pportdata *ppd, __be16 *lrh, __be32 *bth,
  1202. u8 sc5, int8_t s_pkey_index);
  1203. #define PACKET_EGRESS_TIMEOUT 350
  1204. static inline void pause_for_credit_return(struct hfi1_devdata *dd)
  1205. {
  1206. /* Pause at least 1us, to ensure chip returns all credits */
  1207. u32 usec = cclock_to_ns(dd, PACKET_EGRESS_TIMEOUT) / 1000;
  1208. udelay(usec ? usec : 1);
  1209. }
  1210. /**
  1211. * sc_to_vlt() reverse lookup sc to vl
  1212. * @dd - devdata
  1213. * @sc5 - 5 bit sc
  1214. */
  1215. static inline u8 sc_to_vlt(struct hfi1_devdata *dd, u8 sc5)
  1216. {
  1217. unsigned seq;
  1218. u8 rval;
  1219. if (sc5 >= OPA_MAX_SCS)
  1220. return (u8)(0xff);
  1221. do {
  1222. seq = read_seqbegin(&dd->sc2vl_lock);
  1223. rval = *(((u8 *)dd->sc2vl) + sc5);
  1224. } while (read_seqretry(&dd->sc2vl_lock, seq));
  1225. return rval;
  1226. }
  1227. #define PKEY_MEMBER_MASK 0x8000
  1228. #define PKEY_LOW_15_MASK 0x7fff
  1229. /*
  1230. * ingress_pkey_matches_entry - return 1 if the pkey matches ent (ent
  1231. * being an entry from the ingress partition key table), return 0
  1232. * otherwise. Use the matching criteria for ingress partition keys
  1233. * specified in the OPAv1 spec., section 9.10.14.
  1234. */
  1235. static inline int ingress_pkey_matches_entry(u16 pkey, u16 ent)
  1236. {
  1237. u16 mkey = pkey & PKEY_LOW_15_MASK;
  1238. u16 ment = ent & PKEY_LOW_15_MASK;
  1239. if (mkey == ment) {
  1240. /*
  1241. * If pkey[15] is clear (limited partition member),
  1242. * is bit 15 in the corresponding table element
  1243. * clear (limited member)?
  1244. */
  1245. if (!(pkey & PKEY_MEMBER_MASK))
  1246. return !!(ent & PKEY_MEMBER_MASK);
  1247. return 1;
  1248. }
  1249. return 0;
  1250. }
  1251. /*
  1252. * ingress_pkey_table_search - search the entire pkey table for
  1253. * an entry which matches 'pkey'. return 0 if a match is found,
  1254. * and 1 otherwise.
  1255. */
  1256. static int ingress_pkey_table_search(struct hfi1_pportdata *ppd, u16 pkey)
  1257. {
  1258. int i;
  1259. for (i = 0; i < MAX_PKEY_VALUES; i++) {
  1260. if (ingress_pkey_matches_entry(pkey, ppd->pkeys[i]))
  1261. return 0;
  1262. }
  1263. return 1;
  1264. }
  1265. /*
  1266. * ingress_pkey_table_fail - record a failure of ingress pkey validation,
  1267. * i.e., increment port_rcv_constraint_errors for the port, and record
  1268. * the 'error info' for this failure.
  1269. */
  1270. static void ingress_pkey_table_fail(struct hfi1_pportdata *ppd, u16 pkey,
  1271. u16 slid)
  1272. {
  1273. struct hfi1_devdata *dd = ppd->dd;
  1274. incr_cntr64(&ppd->port_rcv_constraint_errors);
  1275. if (!(dd->err_info_rcv_constraint.status & OPA_EI_STATUS_SMASK)) {
  1276. dd->err_info_rcv_constraint.status |= OPA_EI_STATUS_SMASK;
  1277. dd->err_info_rcv_constraint.slid = slid;
  1278. dd->err_info_rcv_constraint.pkey = pkey;
  1279. }
  1280. }
  1281. /*
  1282. * ingress_pkey_check - Return 0 if the ingress pkey is valid, return 1
  1283. * otherwise. Use the criteria in the OPAv1 spec, section 9.10.14. idx
  1284. * is a hint as to the best place in the partition key table to begin
  1285. * searching. This function should not be called on the data path because
  1286. * of performance reasons. On datapath pkey check is expected to be done
  1287. * by HW and rcv_pkey_check function should be called instead.
  1288. */
  1289. static inline int ingress_pkey_check(struct hfi1_pportdata *ppd, u16 pkey,
  1290. u8 sc5, u8 idx, u16 slid)
  1291. {
  1292. if (!(ppd->part_enforce & HFI1_PART_ENFORCE_IN))
  1293. return 0;
  1294. /* If SC15, pkey[0:14] must be 0x7fff */
  1295. if ((sc5 == 0xf) && ((pkey & PKEY_LOW_15_MASK) != PKEY_LOW_15_MASK))
  1296. goto bad;
  1297. /* Is the pkey = 0x0, or 0x8000? */
  1298. if ((pkey & PKEY_LOW_15_MASK) == 0)
  1299. goto bad;
  1300. /* The most likely matching pkey has index 'idx' */
  1301. if (ingress_pkey_matches_entry(pkey, ppd->pkeys[idx]))
  1302. return 0;
  1303. /* no match - try the whole table */
  1304. if (!ingress_pkey_table_search(ppd, pkey))
  1305. return 0;
  1306. bad:
  1307. ingress_pkey_table_fail(ppd, pkey, slid);
  1308. return 1;
  1309. }
  1310. /*
  1311. * rcv_pkey_check - Return 0 if the ingress pkey is valid, return 1
  1312. * otherwise. It only ensures pkey is vlid for QP0. This function
  1313. * should be called on the data path instead of ingress_pkey_check
  1314. * as on data path, pkey check is done by HW (except for QP0).
  1315. */
  1316. static inline int rcv_pkey_check(struct hfi1_pportdata *ppd, u16 pkey,
  1317. u8 sc5, u16 slid)
  1318. {
  1319. if (!(ppd->part_enforce & HFI1_PART_ENFORCE_IN))
  1320. return 0;
  1321. /* If SC15, pkey[0:14] must be 0x7fff */
  1322. if ((sc5 == 0xf) && ((pkey & PKEY_LOW_15_MASK) != PKEY_LOW_15_MASK))
  1323. goto bad;
  1324. return 0;
  1325. bad:
  1326. ingress_pkey_table_fail(ppd, pkey, slid);
  1327. return 1;
  1328. }
  1329. /* MTU handling */
  1330. /* MTU enumeration, 256-4k match IB */
  1331. #define OPA_MTU_0 0
  1332. #define OPA_MTU_256 1
  1333. #define OPA_MTU_512 2
  1334. #define OPA_MTU_1024 3
  1335. #define OPA_MTU_2048 4
  1336. #define OPA_MTU_4096 5
  1337. u32 lrh_max_header_bytes(struct hfi1_devdata *dd);
  1338. int mtu_to_enum(u32 mtu, int default_if_bad);
  1339. u16 enum_to_mtu(int);
  1340. static inline int valid_ib_mtu(unsigned int mtu)
  1341. {
  1342. return mtu == 256 || mtu == 512 ||
  1343. mtu == 1024 || mtu == 2048 ||
  1344. mtu == 4096;
  1345. }
  1346. static inline int valid_opa_max_mtu(unsigned int mtu)
  1347. {
  1348. return mtu >= 2048 &&
  1349. (valid_ib_mtu(mtu) || mtu == 8192 || mtu == 10240);
  1350. }
  1351. int set_mtu(struct hfi1_pportdata *);
  1352. int hfi1_set_lid(struct hfi1_pportdata *, u32, u8);
  1353. void hfi1_disable_after_error(struct hfi1_devdata *);
  1354. int hfi1_set_uevent_bits(struct hfi1_pportdata *, const int);
  1355. int hfi1_rcvbuf_validate(u32, u8, u16 *);
  1356. int fm_get_table(struct hfi1_pportdata *, int, void *);
  1357. int fm_set_table(struct hfi1_pportdata *, int, void *);
  1358. void set_up_vl15(struct hfi1_devdata *dd, u8 vau, u16 vl15buf);
  1359. void reset_link_credits(struct hfi1_devdata *dd);
  1360. void assign_remote_cm_au_table(struct hfi1_devdata *dd, u8 vcu);
  1361. int set_buffer_control(struct hfi1_pportdata *ppd, struct buffer_control *bc);
  1362. static inline struct hfi1_devdata *dd_from_ppd(struct hfi1_pportdata *ppd)
  1363. {
  1364. return ppd->dd;
  1365. }
  1366. static inline struct hfi1_devdata *dd_from_dev(struct hfi1_ibdev *dev)
  1367. {
  1368. return container_of(dev, struct hfi1_devdata, verbs_dev);
  1369. }
  1370. static inline struct hfi1_devdata *dd_from_ibdev(struct ib_device *ibdev)
  1371. {
  1372. return dd_from_dev(to_idev(ibdev));
  1373. }
  1374. static inline struct hfi1_pportdata *ppd_from_ibp(struct hfi1_ibport *ibp)
  1375. {
  1376. return container_of(ibp, struct hfi1_pportdata, ibport_data);
  1377. }
  1378. static inline struct hfi1_ibdev *dev_from_rdi(struct rvt_dev_info *rdi)
  1379. {
  1380. return container_of(rdi, struct hfi1_ibdev, rdi);
  1381. }
  1382. static inline struct hfi1_ibport *to_iport(struct ib_device *ibdev, u8 port)
  1383. {
  1384. struct hfi1_devdata *dd = dd_from_ibdev(ibdev);
  1385. unsigned pidx = port - 1; /* IB number port from 1, hdw from 0 */
  1386. WARN_ON(pidx >= dd->num_pports);
  1387. return &dd->pport[pidx].ibport_data;
  1388. }
  1389. static inline struct hfi1_ibport *rcd_to_iport(struct hfi1_ctxtdata *rcd)
  1390. {
  1391. return &rcd->ppd->ibport_data;
  1392. }
  1393. void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
  1394. bool do_cnp);
  1395. static inline bool process_ecn(struct rvt_qp *qp, struct hfi1_packet *pkt,
  1396. bool do_cnp)
  1397. {
  1398. struct ib_other_headers *ohdr = pkt->ohdr;
  1399. u32 bth1;
  1400. bth1 = be32_to_cpu(ohdr->bth[1]);
  1401. if (unlikely(bth1 & (HFI1_BECN_SMASK | HFI1_FECN_SMASK))) {
  1402. hfi1_process_ecn_slowpath(qp, pkt, do_cnp);
  1403. return bth1 & HFI1_FECN_SMASK;
  1404. }
  1405. return false;
  1406. }
  1407. /*
  1408. * Return the indexed PKEY from the port PKEY table.
  1409. */
  1410. static inline u16 hfi1_get_pkey(struct hfi1_ibport *ibp, unsigned index)
  1411. {
  1412. struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
  1413. u16 ret;
  1414. if (index >= ARRAY_SIZE(ppd->pkeys))
  1415. ret = 0;
  1416. else
  1417. ret = ppd->pkeys[index];
  1418. return ret;
  1419. }
  1420. /*
  1421. * Return the indexed GUID from the port GUIDs table.
  1422. */
  1423. static inline __be64 get_sguid(struct hfi1_ibport *ibp, unsigned int index)
  1424. {
  1425. struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
  1426. WARN_ON(index >= HFI1_GUIDS_PER_PORT);
  1427. return cpu_to_be64(ppd->guids[index]);
  1428. }
  1429. /*
  1430. * Called by readers of cc_state only, must call under rcu_read_lock().
  1431. */
  1432. static inline struct cc_state *get_cc_state(struct hfi1_pportdata *ppd)
  1433. {
  1434. return rcu_dereference(ppd->cc_state);
  1435. }
  1436. /*
  1437. * Called by writers of cc_state only, must call under cc_state_lock.
  1438. */
  1439. static inline
  1440. struct cc_state *get_cc_state_protected(struct hfi1_pportdata *ppd)
  1441. {
  1442. return rcu_dereference_protected(ppd->cc_state,
  1443. lockdep_is_held(&ppd->cc_state_lock));
  1444. }
  1445. /*
  1446. * values for dd->flags (_device_ related flags)
  1447. */
  1448. #define HFI1_INITTED 0x1 /* chip and driver up and initted */
  1449. #define HFI1_PRESENT 0x2 /* chip accesses can be done */
  1450. #define HFI1_FROZEN 0x4 /* chip in SPC freeze */
  1451. #define HFI1_HAS_SDMA_TIMEOUT 0x8
  1452. #define HFI1_HAS_SEND_DMA 0x10 /* Supports Send DMA */
  1453. #define HFI1_FORCED_FREEZE 0x80 /* driver forced freeze mode */
  1454. /* IB dword length mask in PBC (lower 11 bits); same for all chips */
  1455. #define HFI1_PBC_LENGTH_MASK ((1 << 11) - 1)
  1456. /* ctxt_flag bit offsets */
  1457. /* context has been setup */
  1458. #define HFI1_CTXT_SETUP_DONE 1
  1459. /* waiting for a packet to arrive */
  1460. #define HFI1_CTXT_WAITING_RCV 2
  1461. /* master has not finished initializing */
  1462. #define HFI1_CTXT_MASTER_UNINIT 4
  1463. /* waiting for an urgent packet to arrive */
  1464. #define HFI1_CTXT_WAITING_URG 5
  1465. /* free up any allocated data at closes */
  1466. struct hfi1_devdata *hfi1_init_dd(struct pci_dev *,
  1467. const struct pci_device_id *);
  1468. void hfi1_free_devdata(struct hfi1_devdata *);
  1469. struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra);
  1470. /* LED beaconing functions */
  1471. void hfi1_start_led_override(struct hfi1_pportdata *ppd, unsigned int timeon,
  1472. unsigned int timeoff);
  1473. void shutdown_led_override(struct hfi1_pportdata *ppd);
  1474. #define HFI1_CREDIT_RETURN_RATE (100)
  1475. /*
  1476. * The number of words for the KDETH protocol field. If this is
  1477. * larger then the actual field used, then part of the payload
  1478. * will be in the header.
  1479. *
  1480. * Optimally, we want this sized so that a typical case will
  1481. * use full cache lines. The typical local KDETH header would
  1482. * be:
  1483. *
  1484. * Bytes Field
  1485. * 8 LRH
  1486. * 12 BHT
  1487. * ?? KDETH
  1488. * 8 RHF
  1489. * ---
  1490. * 28 + KDETH
  1491. *
  1492. * For a 64-byte cache line, KDETH would need to be 36 bytes or 9 DWORDS
  1493. */
  1494. #define DEFAULT_RCVHDRSIZE 9
  1495. /*
  1496. * Maximal header byte count:
  1497. *
  1498. * Bytes Field
  1499. * 8 LRH
  1500. * 40 GRH (optional)
  1501. * 12 BTH
  1502. * ?? KDETH
  1503. * 8 RHF
  1504. * ---
  1505. * 68 + KDETH
  1506. *
  1507. * We also want to maintain a cache line alignment to assist DMA'ing
  1508. * of the header bytes. Round up to a good size.
  1509. */
  1510. #define DEFAULT_RCVHDR_ENTSIZE 32
  1511. bool hfi1_can_pin_pages(struct hfi1_devdata *dd, struct mm_struct *mm,
  1512. u32 nlocked, u32 npages);
  1513. int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr,
  1514. size_t npages, bool writable, struct page **pages);
  1515. void hfi1_release_user_pages(struct mm_struct *mm, struct page **p,
  1516. size_t npages, bool dirty);
  1517. static inline void clear_rcvhdrtail(const struct hfi1_ctxtdata *rcd)
  1518. {
  1519. *((u64 *)rcd->rcvhdrtail_kvaddr) = 0ULL;
  1520. }
  1521. static inline u32 get_rcvhdrtail(const struct hfi1_ctxtdata *rcd)
  1522. {
  1523. /*
  1524. * volatile because it's a DMA target from the chip, routine is
  1525. * inlined, and don't want register caching or reordering.
  1526. */
  1527. return (u32)le64_to_cpu(*rcd->rcvhdrtail_kvaddr);
  1528. }
  1529. /*
  1530. * sysfs interface.
  1531. */
  1532. extern const char ib_hfi1_version[];
  1533. int hfi1_device_create(struct hfi1_devdata *);
  1534. void hfi1_device_remove(struct hfi1_devdata *);
  1535. int hfi1_create_port_files(struct ib_device *ibdev, u8 port_num,
  1536. struct kobject *kobj);
  1537. int hfi1_verbs_register_sysfs(struct hfi1_devdata *);
  1538. void hfi1_verbs_unregister_sysfs(struct hfi1_devdata *);
  1539. /* Hook for sysfs read of QSFP */
  1540. int qsfp_dump(struct hfi1_pportdata *ppd, char *buf, int len);
  1541. int hfi1_pcie_init(struct pci_dev *, const struct pci_device_id *);
  1542. void hfi1_pcie_cleanup(struct pci_dev *);
  1543. int hfi1_pcie_ddinit(struct hfi1_devdata *, struct pci_dev *);
  1544. void hfi1_pcie_ddcleanup(struct hfi1_devdata *);
  1545. void hfi1_pcie_flr(struct hfi1_devdata *);
  1546. int pcie_speeds(struct hfi1_devdata *);
  1547. void request_msix(struct hfi1_devdata *, u32 *, struct hfi1_msix_entry *);
  1548. void hfi1_enable_intx(struct pci_dev *);
  1549. void restore_pci_variables(struct hfi1_devdata *dd);
  1550. int do_pcie_gen3_transition(struct hfi1_devdata *dd);
  1551. int parse_platform_config(struct hfi1_devdata *dd);
  1552. int get_platform_config_field(struct hfi1_devdata *dd,
  1553. enum platform_config_table_type_encoding
  1554. table_type, int table_index, int field_index,
  1555. u32 *data, u32 len);
  1556. const char *get_unit_name(int unit);
  1557. const char *get_card_name(struct rvt_dev_info *rdi);
  1558. struct pci_dev *get_pci_dev(struct rvt_dev_info *rdi);
  1559. /*
  1560. * Flush write combining store buffers (if present) and perform a write
  1561. * barrier.
  1562. */
  1563. static inline void flush_wc(void)
  1564. {
  1565. asm volatile("sfence" : : : "memory");
  1566. }
  1567. void handle_eflags(struct hfi1_packet *packet);
  1568. int process_receive_ib(struct hfi1_packet *packet);
  1569. int process_receive_bypass(struct hfi1_packet *packet);
  1570. int process_receive_error(struct hfi1_packet *packet);
  1571. int kdeth_process_expected(struct hfi1_packet *packet);
  1572. int kdeth_process_eager(struct hfi1_packet *packet);
  1573. int process_receive_invalid(struct hfi1_packet *packet);
  1574. /* global module parameter variables */
  1575. extern unsigned int hfi1_max_mtu;
  1576. extern unsigned int hfi1_cu;
  1577. extern unsigned int user_credit_return_threshold;
  1578. extern int num_user_contexts;
  1579. extern unsigned long n_krcvqs;
  1580. extern uint krcvqs[];
  1581. extern int krcvqsset;
  1582. extern uint kdeth_qp;
  1583. extern uint loopback;
  1584. extern uint quick_linkup;
  1585. extern uint rcv_intr_timeout;
  1586. extern uint rcv_intr_count;
  1587. extern uint rcv_intr_dynamic;
  1588. extern ushort link_crc_mask;
  1589. extern struct mutex hfi1_mutex;
  1590. /* Number of seconds before our card status check... */
  1591. #define STATUS_TIMEOUT 60
  1592. #define DRIVER_NAME "hfi1"
  1593. #define HFI1_USER_MINOR_BASE 0
  1594. #define HFI1_TRACE_MINOR 127
  1595. #define HFI1_NMINORS 255
  1596. #define PCI_VENDOR_ID_INTEL 0x8086
  1597. #define PCI_DEVICE_ID_INTEL0 0x24f0
  1598. #define PCI_DEVICE_ID_INTEL1 0x24f1
  1599. #define HFI1_PKT_USER_SC_INTEGRITY \
  1600. (SEND_CTXT_CHECK_ENABLE_DISALLOW_NON_KDETH_PACKETS_SMASK \
  1601. | SEND_CTXT_CHECK_ENABLE_DISALLOW_KDETH_PACKETS_SMASK \
  1602. | SEND_CTXT_CHECK_ENABLE_DISALLOW_BYPASS_SMASK \
  1603. | SEND_CTXT_CHECK_ENABLE_DISALLOW_GRH_SMASK)
  1604. #define HFI1_PKT_KERNEL_SC_INTEGRITY \
  1605. (SEND_CTXT_CHECK_ENABLE_DISALLOW_KDETH_PACKETS_SMASK)
  1606. static inline u64 hfi1_pkt_default_send_ctxt_mask(struct hfi1_devdata *dd,
  1607. u16 ctxt_type)
  1608. {
  1609. u64 base_sc_integrity;
  1610. /* No integrity checks if HFI1_CAP_NO_INTEGRITY is set */
  1611. if (HFI1_CAP_IS_KSET(NO_INTEGRITY))
  1612. return 0;
  1613. base_sc_integrity =
  1614. SEND_CTXT_CHECK_ENABLE_DISALLOW_BYPASS_BAD_PKT_LEN_SMASK
  1615. | SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK
  1616. | SEND_CTXT_CHECK_ENABLE_DISALLOW_TOO_LONG_BYPASS_PACKETS_SMASK
  1617. | SEND_CTXT_CHECK_ENABLE_DISALLOW_TOO_LONG_IB_PACKETS_SMASK
  1618. | SEND_CTXT_CHECK_ENABLE_DISALLOW_BAD_PKT_LEN_SMASK
  1619. | SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_TEST_SMASK
  1620. | SEND_CTXT_CHECK_ENABLE_DISALLOW_TOO_SMALL_BYPASS_PACKETS_SMASK
  1621. | SEND_CTXT_CHECK_ENABLE_DISALLOW_TOO_SMALL_IB_PACKETS_SMASK
  1622. | SEND_CTXT_CHECK_ENABLE_DISALLOW_RAW_IPV6_SMASK
  1623. | SEND_CTXT_CHECK_ENABLE_DISALLOW_RAW_SMASK
  1624. | SEND_CTXT_CHECK_ENABLE_CHECK_BYPASS_VL_MAPPING_SMASK
  1625. | SEND_CTXT_CHECK_ENABLE_CHECK_VL_MAPPING_SMASK
  1626. | SEND_CTXT_CHECK_ENABLE_CHECK_OPCODE_SMASK
  1627. | SEND_CTXT_CHECK_ENABLE_CHECK_SLID_SMASK
  1628. | SEND_CTXT_CHECK_ENABLE_CHECK_VL_SMASK
  1629. | SEND_CTXT_CHECK_ENABLE_CHECK_ENABLE_SMASK;
  1630. if (ctxt_type == SC_USER)
  1631. base_sc_integrity |= HFI1_PKT_USER_SC_INTEGRITY;
  1632. else
  1633. base_sc_integrity |= HFI1_PKT_KERNEL_SC_INTEGRITY;
  1634. /* turn on send-side job key checks if !A0 */
  1635. if (!is_ax(dd))
  1636. base_sc_integrity |= SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
  1637. return base_sc_integrity;
  1638. }
  1639. static inline u64 hfi1_pkt_base_sdma_integrity(struct hfi1_devdata *dd)
  1640. {
  1641. u64 base_sdma_integrity;
  1642. /* No integrity checks if HFI1_CAP_NO_INTEGRITY is set */
  1643. if (HFI1_CAP_IS_KSET(NO_INTEGRITY))
  1644. return 0;
  1645. base_sdma_integrity =
  1646. SEND_DMA_CHECK_ENABLE_DISALLOW_BYPASS_BAD_PKT_LEN_SMASK
  1647. | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_LONG_BYPASS_PACKETS_SMASK
  1648. | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_LONG_IB_PACKETS_SMASK
  1649. | SEND_DMA_CHECK_ENABLE_DISALLOW_BAD_PKT_LEN_SMASK
  1650. | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_SMALL_BYPASS_PACKETS_SMASK
  1651. | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_SMALL_IB_PACKETS_SMASK
  1652. | SEND_DMA_CHECK_ENABLE_DISALLOW_RAW_IPV6_SMASK
  1653. | SEND_DMA_CHECK_ENABLE_DISALLOW_RAW_SMASK
  1654. | SEND_DMA_CHECK_ENABLE_CHECK_BYPASS_VL_MAPPING_SMASK
  1655. | SEND_DMA_CHECK_ENABLE_CHECK_VL_MAPPING_SMASK
  1656. | SEND_DMA_CHECK_ENABLE_CHECK_OPCODE_SMASK
  1657. | SEND_DMA_CHECK_ENABLE_CHECK_SLID_SMASK
  1658. | SEND_DMA_CHECK_ENABLE_CHECK_VL_SMASK
  1659. | SEND_DMA_CHECK_ENABLE_CHECK_ENABLE_SMASK;
  1660. if (!HFI1_CAP_IS_KSET(STATIC_RATE_CTRL))
  1661. base_sdma_integrity |=
  1662. SEND_DMA_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK;
  1663. /* turn on send-side job key checks if !A0 */
  1664. if (!is_ax(dd))
  1665. base_sdma_integrity |=
  1666. SEND_DMA_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
  1667. return base_sdma_integrity;
  1668. }
  1669. /*
  1670. * hfi1_early_err is used (only!) to print early errors before devdata is
  1671. * allocated, or when dd->pcidev may not be valid, and at the tail end of
  1672. * cleanup when devdata may have been freed, etc. hfi1_dev_porterr is
  1673. * the same as dd_dev_err, but is used when the message really needs
  1674. * the IB port# to be definitive as to what's happening..
  1675. */
  1676. #define hfi1_early_err(dev, fmt, ...) \
  1677. dev_err(dev, fmt, ##__VA_ARGS__)
  1678. #define hfi1_early_info(dev, fmt, ...) \
  1679. dev_info(dev, fmt, ##__VA_ARGS__)
  1680. #define dd_dev_emerg(dd, fmt, ...) \
  1681. dev_emerg(&(dd)->pcidev->dev, "%s: " fmt, \
  1682. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1683. #define dd_dev_err(dd, fmt, ...) \
  1684. dev_err(&(dd)->pcidev->dev, "%s: " fmt, \
  1685. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1686. #define dd_dev_warn(dd, fmt, ...) \
  1687. dev_warn(&(dd)->pcidev->dev, "%s: " fmt, \
  1688. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1689. #define dd_dev_warn_ratelimited(dd, fmt, ...) \
  1690. dev_warn_ratelimited(&(dd)->pcidev->dev, "%s: " fmt, \
  1691. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1692. #define dd_dev_info(dd, fmt, ...) \
  1693. dev_info(&(dd)->pcidev->dev, "%s: " fmt, \
  1694. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1695. #define dd_dev_info_ratelimited(dd, fmt, ...) \
  1696. dev_info_ratelimited(&(dd)->pcidev->dev, "%s: " fmt, \
  1697. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1698. #define dd_dev_dbg(dd, fmt, ...) \
  1699. dev_dbg(&(dd)->pcidev->dev, "%s: " fmt, \
  1700. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1701. #define hfi1_dev_porterr(dd, port, fmt, ...) \
  1702. dev_err(&(dd)->pcidev->dev, "%s: port %u: " fmt, \
  1703. get_unit_name((dd)->unit), (port), ##__VA_ARGS__)
  1704. /*
  1705. * this is used for formatting hw error messages...
  1706. */
  1707. struct hfi1_hwerror_msgs {
  1708. u64 mask;
  1709. const char *msg;
  1710. size_t sz;
  1711. };
  1712. /* in intr.c... */
  1713. void hfi1_format_hwerrors(u64 hwerrs,
  1714. const struct hfi1_hwerror_msgs *hwerrmsgs,
  1715. size_t nhwerrmsgs, char *msg, size_t lmsg);
  1716. #define USER_OPCODE_CHECK_VAL 0xC0
  1717. #define USER_OPCODE_CHECK_MASK 0xC0
  1718. #define OPCODE_CHECK_VAL_DISABLED 0x0
  1719. #define OPCODE_CHECK_MASK_DISABLED 0x0
  1720. static inline void hfi1_reset_cpu_counters(struct hfi1_devdata *dd)
  1721. {
  1722. struct hfi1_pportdata *ppd;
  1723. int i;
  1724. dd->z_int_counter = get_all_cpu_total(dd->int_counter);
  1725. dd->z_rcv_limit = get_all_cpu_total(dd->rcv_limit);
  1726. dd->z_send_schedule = get_all_cpu_total(dd->send_schedule);
  1727. ppd = (struct hfi1_pportdata *)(dd + 1);
  1728. for (i = 0; i < dd->num_pports; i++, ppd++) {
  1729. ppd->ibport_data.rvp.z_rc_acks =
  1730. get_all_cpu_total(ppd->ibport_data.rvp.rc_acks);
  1731. ppd->ibport_data.rvp.z_rc_qacks =
  1732. get_all_cpu_total(ppd->ibport_data.rvp.rc_qacks);
  1733. }
  1734. }
  1735. /* Control LED state */
  1736. static inline void setextled(struct hfi1_devdata *dd, u32 on)
  1737. {
  1738. if (on)
  1739. write_csr(dd, DCC_CFG_LED_CNTRL, 0x1F);
  1740. else
  1741. write_csr(dd, DCC_CFG_LED_CNTRL, 0x10);
  1742. }
  1743. /* return the i2c resource given the target */
  1744. static inline u32 i2c_target(u32 target)
  1745. {
  1746. return target ? CR_I2C2 : CR_I2C1;
  1747. }
  1748. /* return the i2c chain chip resource that this HFI uses for QSFP */
  1749. static inline u32 qsfp_resource(struct hfi1_devdata *dd)
  1750. {
  1751. return i2c_target(dd->hfi1_id);
  1752. }
  1753. /* Is this device integrated or discrete? */
  1754. static inline bool is_integrated(struct hfi1_devdata *dd)
  1755. {
  1756. return dd->pcidev->device == PCI_DEVICE_ID_INTEL1;
  1757. }
  1758. int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp);
  1759. #define DD_DEV_ENTRY(dd) __string(dev, dev_name(&(dd)->pcidev->dev))
  1760. #define DD_DEV_ASSIGN(dd) __assign_str(dev, dev_name(&(dd)->pcidev->dev))
  1761. #define packettype_name(etype) { RHF_RCV_TYPE_##etype, #etype }
  1762. #define show_packettype(etype) \
  1763. __print_symbolic(etype, \
  1764. packettype_name(EXPECTED), \
  1765. packettype_name(EAGER), \
  1766. packettype_name(IB), \
  1767. packettype_name(ERROR), \
  1768. packettype_name(BYPASS))
  1769. #define ib_opcode_name(opcode) { IB_OPCODE_##opcode, #opcode }
  1770. #define show_ib_opcode(opcode) \
  1771. __print_symbolic(opcode, \
  1772. ib_opcode_name(RC_SEND_FIRST), \
  1773. ib_opcode_name(RC_SEND_MIDDLE), \
  1774. ib_opcode_name(RC_SEND_LAST), \
  1775. ib_opcode_name(RC_SEND_LAST_WITH_IMMEDIATE), \
  1776. ib_opcode_name(RC_SEND_ONLY), \
  1777. ib_opcode_name(RC_SEND_ONLY_WITH_IMMEDIATE), \
  1778. ib_opcode_name(RC_RDMA_WRITE_FIRST), \
  1779. ib_opcode_name(RC_RDMA_WRITE_MIDDLE), \
  1780. ib_opcode_name(RC_RDMA_WRITE_LAST), \
  1781. ib_opcode_name(RC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
  1782. ib_opcode_name(RC_RDMA_WRITE_ONLY), \
  1783. ib_opcode_name(RC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
  1784. ib_opcode_name(RC_RDMA_READ_REQUEST), \
  1785. ib_opcode_name(RC_RDMA_READ_RESPONSE_FIRST), \
  1786. ib_opcode_name(RC_RDMA_READ_RESPONSE_MIDDLE), \
  1787. ib_opcode_name(RC_RDMA_READ_RESPONSE_LAST), \
  1788. ib_opcode_name(RC_RDMA_READ_RESPONSE_ONLY), \
  1789. ib_opcode_name(RC_ACKNOWLEDGE), \
  1790. ib_opcode_name(RC_ATOMIC_ACKNOWLEDGE), \
  1791. ib_opcode_name(RC_COMPARE_SWAP), \
  1792. ib_opcode_name(RC_FETCH_ADD), \
  1793. ib_opcode_name(UC_SEND_FIRST), \
  1794. ib_opcode_name(UC_SEND_MIDDLE), \
  1795. ib_opcode_name(UC_SEND_LAST), \
  1796. ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE), \
  1797. ib_opcode_name(UC_SEND_ONLY), \
  1798. ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE), \
  1799. ib_opcode_name(UC_RDMA_WRITE_FIRST), \
  1800. ib_opcode_name(UC_RDMA_WRITE_MIDDLE), \
  1801. ib_opcode_name(UC_RDMA_WRITE_LAST), \
  1802. ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
  1803. ib_opcode_name(UC_RDMA_WRITE_ONLY), \
  1804. ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
  1805. ib_opcode_name(UD_SEND_ONLY), \
  1806. ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE), \
  1807. ib_opcode_name(CNP))
  1808. #endif /* _HFI1_KERNEL_H */