hfi.h 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068
  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. u32 hdrqtail;
  337. int numpkt;
  338. u16 tlen;
  339. u16 hlen;
  340. s16 etail;
  341. u16 rsize;
  342. u8 updegr;
  343. u8 rcv_flags;
  344. u8 etype;
  345. };
  346. struct rvt_sge_state;
  347. /*
  348. * Get/Set IB link-level config parameters for f_get/set_ib_cfg()
  349. * Mostly for MADs that set or query link parameters, also ipath
  350. * config interfaces
  351. */
  352. #define HFI1_IB_CFG_LIDLMC 0 /* LID (LS16b) and Mask (MS16b) */
  353. #define HFI1_IB_CFG_LWID_DG_ENB 1 /* allowed Link-width downgrade */
  354. #define HFI1_IB_CFG_LWID_ENB 2 /* allowed Link-width */
  355. #define HFI1_IB_CFG_LWID 3 /* currently active Link-width */
  356. #define HFI1_IB_CFG_SPD_ENB 4 /* allowed Link speeds */
  357. #define HFI1_IB_CFG_SPD 5 /* current Link spd */
  358. #define HFI1_IB_CFG_RXPOL_ENB 6 /* Auto-RX-polarity enable */
  359. #define HFI1_IB_CFG_LREV_ENB 7 /* Auto-Lane-reversal enable */
  360. #define HFI1_IB_CFG_LINKLATENCY 8 /* Link Latency (IB1.2 only) */
  361. #define HFI1_IB_CFG_HRTBT 9 /* IB heartbeat off/enable/auto; DDR/QDR only */
  362. #define HFI1_IB_CFG_OP_VLS 10 /* operational VLs */
  363. #define HFI1_IB_CFG_VL_HIGH_CAP 11 /* num of VL high priority weights */
  364. #define HFI1_IB_CFG_VL_LOW_CAP 12 /* num of VL low priority weights */
  365. #define HFI1_IB_CFG_OVERRUN_THRESH 13 /* IB overrun threshold */
  366. #define HFI1_IB_CFG_PHYERR_THRESH 14 /* IB PHY error threshold */
  367. #define HFI1_IB_CFG_LINKDEFAULT 15 /* IB link default (sleep/poll) */
  368. #define HFI1_IB_CFG_PKEYS 16 /* update partition keys */
  369. #define HFI1_IB_CFG_MTU 17 /* update MTU in IBC */
  370. #define HFI1_IB_CFG_VL_HIGH_LIMIT 19
  371. #define HFI1_IB_CFG_PMA_TICKS 20 /* PMA sample tick resolution */
  372. #define HFI1_IB_CFG_PORT 21 /* switch port we are connected to */
  373. /*
  374. * HFI or Host Link States
  375. *
  376. * These describe the states the driver thinks the logical and physical
  377. * states are in. Used as an argument to set_link_state(). Implemented
  378. * as bits for easy multi-state checking. The actual state can only be
  379. * one.
  380. */
  381. #define __HLS_UP_INIT_BP 0
  382. #define __HLS_UP_ARMED_BP 1
  383. #define __HLS_UP_ACTIVE_BP 2
  384. #define __HLS_DN_DOWNDEF_BP 3 /* link down default */
  385. #define __HLS_DN_POLL_BP 4
  386. #define __HLS_DN_DISABLE_BP 5
  387. #define __HLS_DN_OFFLINE_BP 6
  388. #define __HLS_VERIFY_CAP_BP 7
  389. #define __HLS_GOING_UP_BP 8
  390. #define __HLS_GOING_OFFLINE_BP 9
  391. #define __HLS_LINK_COOLDOWN_BP 10
  392. #define HLS_UP_INIT BIT(__HLS_UP_INIT_BP)
  393. #define HLS_UP_ARMED BIT(__HLS_UP_ARMED_BP)
  394. #define HLS_UP_ACTIVE BIT(__HLS_UP_ACTIVE_BP)
  395. #define HLS_DN_DOWNDEF BIT(__HLS_DN_DOWNDEF_BP) /* link down default */
  396. #define HLS_DN_POLL BIT(__HLS_DN_POLL_BP)
  397. #define HLS_DN_DISABLE BIT(__HLS_DN_DISABLE_BP)
  398. #define HLS_DN_OFFLINE BIT(__HLS_DN_OFFLINE_BP)
  399. #define HLS_VERIFY_CAP BIT(__HLS_VERIFY_CAP_BP)
  400. #define HLS_GOING_UP BIT(__HLS_GOING_UP_BP)
  401. #define HLS_GOING_OFFLINE BIT(__HLS_GOING_OFFLINE_BP)
  402. #define HLS_LINK_COOLDOWN BIT(__HLS_LINK_COOLDOWN_BP)
  403. #define HLS_UP (HLS_UP_INIT | HLS_UP_ARMED | HLS_UP_ACTIVE)
  404. #define HLS_DOWN ~(HLS_UP)
  405. /* use this MTU size if none other is given */
  406. #define HFI1_DEFAULT_ACTIVE_MTU 10240
  407. /* use this MTU size as the default maximum */
  408. #define HFI1_DEFAULT_MAX_MTU 10240
  409. /* default partition key */
  410. #define DEFAULT_PKEY 0xffff
  411. /*
  412. * Possible fabric manager config parameters for fm_{get,set}_table()
  413. */
  414. #define FM_TBL_VL_HIGH_ARB 1 /* Get/set VL high prio weights */
  415. #define FM_TBL_VL_LOW_ARB 2 /* Get/set VL low prio weights */
  416. #define FM_TBL_BUFFER_CONTROL 3 /* Get/set Buffer Control */
  417. #define FM_TBL_SC2VLNT 4 /* Get/set SC->VLnt */
  418. #define FM_TBL_VL_PREEMPT_ELEMS 5 /* Get (no set) VL preempt elems */
  419. #define FM_TBL_VL_PREEMPT_MATRIX 6 /* Get (no set) VL preempt matrix */
  420. /*
  421. * Possible "operations" for f_rcvctrl(ppd, op, ctxt)
  422. * these are bits so they can be combined, e.g.
  423. * HFI1_RCVCTRL_INTRAVAIL_ENB | HFI1_RCVCTRL_CTXT_ENB
  424. */
  425. #define HFI1_RCVCTRL_TAILUPD_ENB 0x01
  426. #define HFI1_RCVCTRL_TAILUPD_DIS 0x02
  427. #define HFI1_RCVCTRL_CTXT_ENB 0x04
  428. #define HFI1_RCVCTRL_CTXT_DIS 0x08
  429. #define HFI1_RCVCTRL_INTRAVAIL_ENB 0x10
  430. #define HFI1_RCVCTRL_INTRAVAIL_DIS 0x20
  431. #define HFI1_RCVCTRL_PKEY_ENB 0x40 /* Note, default is enabled */
  432. #define HFI1_RCVCTRL_PKEY_DIS 0x80
  433. #define HFI1_RCVCTRL_TIDFLOW_ENB 0x0400
  434. #define HFI1_RCVCTRL_TIDFLOW_DIS 0x0800
  435. #define HFI1_RCVCTRL_ONE_PKT_EGR_ENB 0x1000
  436. #define HFI1_RCVCTRL_ONE_PKT_EGR_DIS 0x2000
  437. #define HFI1_RCVCTRL_NO_RHQ_DROP_ENB 0x4000
  438. #define HFI1_RCVCTRL_NO_RHQ_DROP_DIS 0x8000
  439. #define HFI1_RCVCTRL_NO_EGR_DROP_ENB 0x10000
  440. #define HFI1_RCVCTRL_NO_EGR_DROP_DIS 0x20000
  441. /* partition enforcement flags */
  442. #define HFI1_PART_ENFORCE_IN 0x1
  443. #define HFI1_PART_ENFORCE_OUT 0x2
  444. /* how often we check for synthetic counter wrap around */
  445. #define SYNTH_CNT_TIME 2
  446. /* Counter flags */
  447. #define CNTR_NORMAL 0x0 /* Normal counters, just read register */
  448. #define CNTR_SYNTH 0x1 /* Synthetic counters, saturate at all 1s */
  449. #define CNTR_DISABLED 0x2 /* Disable this counter */
  450. #define CNTR_32BIT 0x4 /* Simulate 64 bits for this counter */
  451. #define CNTR_VL 0x8 /* Per VL counter */
  452. #define CNTR_SDMA 0x10
  453. #define CNTR_INVALID_VL -1 /* Specifies invalid VL */
  454. #define CNTR_MODE_W 0x0
  455. #define CNTR_MODE_R 0x1
  456. /* VLs Supported/Operational */
  457. #define HFI1_MIN_VLS_SUPPORTED 1
  458. #define HFI1_MAX_VLS_SUPPORTED 8
  459. #define HFI1_GUIDS_PER_PORT 5
  460. #define HFI1_PORT_GUID_INDEX 0
  461. static inline void incr_cntr64(u64 *cntr)
  462. {
  463. if (*cntr < (u64)-1LL)
  464. (*cntr)++;
  465. }
  466. static inline void incr_cntr32(u32 *cntr)
  467. {
  468. if (*cntr < (u32)-1LL)
  469. (*cntr)++;
  470. }
  471. #define MAX_NAME_SIZE 64
  472. struct hfi1_msix_entry {
  473. enum irq_type type;
  474. struct msix_entry msix;
  475. void *arg;
  476. char name[MAX_NAME_SIZE];
  477. cpumask_t mask;
  478. struct irq_affinity_notify notify;
  479. };
  480. /* per-SL CCA information */
  481. struct cca_timer {
  482. struct hrtimer hrtimer;
  483. struct hfi1_pportdata *ppd; /* read-only */
  484. int sl; /* read-only */
  485. u16 ccti; /* read/write - current value of CCTI */
  486. };
  487. struct link_down_reason {
  488. /*
  489. * SMA-facing value. Should be set from .latest when
  490. * HLS_UP_* -> HLS_DN_* transition actually occurs.
  491. */
  492. u8 sma;
  493. u8 latest;
  494. };
  495. enum {
  496. LO_PRIO_TABLE,
  497. HI_PRIO_TABLE,
  498. MAX_PRIO_TABLE
  499. };
  500. struct vl_arb_cache {
  501. /* protect vl arb cache */
  502. spinlock_t lock;
  503. struct ib_vl_weight_elem table[VL_ARB_TABLE_SIZE];
  504. };
  505. /*
  506. * The structure below encapsulates data relevant to a physical IB Port.
  507. * Current chips support only one such port, but the separation
  508. * clarifies things a bit. Note that to conform to IB conventions,
  509. * port-numbers are one-based. The first or only port is port1.
  510. */
  511. struct hfi1_pportdata {
  512. struct hfi1_ibport ibport_data;
  513. struct hfi1_devdata *dd;
  514. struct kobject pport_cc_kobj;
  515. struct kobject sc2vl_kobj;
  516. struct kobject sl2sc_kobj;
  517. struct kobject vl2mtu_kobj;
  518. /* PHY support */
  519. struct qsfp_data qsfp_info;
  520. /* Values for SI tuning of SerDes */
  521. u32 port_type;
  522. u32 tx_preset_eq;
  523. u32 tx_preset_noeq;
  524. u32 rx_preset;
  525. u8 local_atten;
  526. u8 remote_atten;
  527. u8 default_atten;
  528. u8 max_power_class;
  529. /* GUIDs for this interface, in host order, guids[0] is a port guid */
  530. u64 guids[HFI1_GUIDS_PER_PORT];
  531. /* GUID for peer interface, in host order */
  532. u64 neighbor_guid;
  533. /* up or down physical link state */
  534. u32 linkup;
  535. /*
  536. * this address is mapped read-only into user processes so they can
  537. * get status cheaply, whenever they want. One qword of status per port
  538. */
  539. u64 *statusp;
  540. /* SendDMA related entries */
  541. struct workqueue_struct *hfi1_wq;
  542. /* move out of interrupt context */
  543. struct work_struct link_vc_work;
  544. struct work_struct link_up_work;
  545. struct work_struct link_down_work;
  546. struct work_struct sma_message_work;
  547. struct work_struct freeze_work;
  548. struct work_struct link_downgrade_work;
  549. struct work_struct link_bounce_work;
  550. struct delayed_work start_link_work;
  551. /* host link state variables */
  552. struct mutex hls_lock;
  553. u32 host_link_state;
  554. u32 lstate; /* logical link state */
  555. /* these are the "32 bit" regs */
  556. u32 ibmtu; /* The MTU programmed for this unit */
  557. /*
  558. * Current max size IB packet (in bytes) including IB headers, that
  559. * we can send. Changes when ibmtu changes.
  560. */
  561. u32 ibmaxlen;
  562. u32 current_egress_rate; /* units [10^6 bits/sec] */
  563. /* LID programmed for this instance */
  564. u16 lid;
  565. /* list of pkeys programmed; 0 if not set */
  566. u16 pkeys[MAX_PKEY_VALUES];
  567. u16 link_width_supported;
  568. u16 link_width_downgrade_supported;
  569. u16 link_speed_supported;
  570. u16 link_width_enabled;
  571. u16 link_width_downgrade_enabled;
  572. u16 link_speed_enabled;
  573. u16 link_width_active;
  574. u16 link_width_downgrade_tx_active;
  575. u16 link_width_downgrade_rx_active;
  576. u16 link_speed_active;
  577. u8 vls_supported;
  578. u8 vls_operational;
  579. u8 actual_vls_operational;
  580. /* LID mask control */
  581. u8 lmc;
  582. /* Rx Polarity inversion (compensate for ~tx on partner) */
  583. u8 rx_pol_inv;
  584. u8 hw_pidx; /* physical port index */
  585. u8 port; /* IB port number and index into dd->pports - 1 */
  586. /* type of neighbor node */
  587. u8 neighbor_type;
  588. u8 neighbor_normal;
  589. u8 neighbor_fm_security; /* 1 if firmware checking is disabled */
  590. u8 neighbor_port_number;
  591. u8 is_sm_config_started;
  592. u8 offline_disabled_reason;
  593. u8 is_active_optimize_enabled;
  594. u8 driver_link_ready; /* driver ready for active link */
  595. u8 link_enabled; /* link enabled? */
  596. u8 linkinit_reason;
  597. u8 local_tx_rate; /* rate given to 8051 firmware */
  598. u8 last_pstate; /* info only */
  599. u8 qsfp_retry_count;
  600. /* placeholders for IB MAD packet settings */
  601. u8 overrun_threshold;
  602. u8 phy_error_threshold;
  603. /* Used to override LED behavior for things like maintenance beaconing*/
  604. /*
  605. * Alternates per phase of blink
  606. * [0] holds LED off duration, [1] holds LED on duration
  607. */
  608. unsigned long led_override_vals[2];
  609. u8 led_override_phase; /* LSB picks from vals[] */
  610. atomic_t led_override_timer_active;
  611. /* Used to flash LEDs in override mode */
  612. struct timer_list led_override_timer;
  613. u32 sm_trap_qp;
  614. u32 sa_qp;
  615. /*
  616. * cca_timer_lock protects access to the per-SL cca_timer
  617. * structures (specifically the ccti member).
  618. */
  619. spinlock_t cca_timer_lock ____cacheline_aligned_in_smp;
  620. struct cca_timer cca_timer[OPA_MAX_SLS];
  621. /* List of congestion control table entries */
  622. struct ib_cc_table_entry_shadow ccti_entries[CC_TABLE_SHADOW_MAX];
  623. /* congestion entries, each entry corresponding to a SL */
  624. struct opa_congestion_setting_entry_shadow
  625. congestion_entries[OPA_MAX_SLS];
  626. /*
  627. * cc_state_lock protects (write) access to the per-port
  628. * struct cc_state.
  629. */
  630. spinlock_t cc_state_lock ____cacheline_aligned_in_smp;
  631. struct cc_state __rcu *cc_state;
  632. /* Total number of congestion control table entries */
  633. u16 total_cct_entry;
  634. /* Bit map identifying service level */
  635. u32 cc_sl_control_map;
  636. /* CA's max number of 64 entry units in the congestion control table */
  637. u8 cc_max_table_entries;
  638. /*
  639. * begin congestion log related entries
  640. * cc_log_lock protects all congestion log related data
  641. */
  642. spinlock_t cc_log_lock ____cacheline_aligned_in_smp;
  643. u8 threshold_cong_event_map[OPA_MAX_SLS / 8];
  644. u16 threshold_event_counter;
  645. struct opa_hfi1_cong_log_event_internal cc_events[OPA_CONG_LOG_ELEMS];
  646. int cc_log_idx; /* index for logging events */
  647. int cc_mad_idx; /* index for reporting events */
  648. /* end congestion log related entries */
  649. struct vl_arb_cache vl_arb_cache[MAX_PRIO_TABLE];
  650. /* port relative counter buffer */
  651. u64 *cntrs;
  652. /* port relative synthetic counter buffer */
  653. u64 *scntrs;
  654. /* port_xmit_discards are synthesized from different egress errors */
  655. u64 port_xmit_discards;
  656. u64 port_xmit_discards_vl[C_VL_COUNT];
  657. u64 port_xmit_constraint_errors;
  658. u64 port_rcv_constraint_errors;
  659. /* count of 'link_err' interrupts from DC */
  660. u64 link_downed;
  661. /* number of times link retrained successfully */
  662. u64 link_up;
  663. /* number of times a link unknown frame was reported */
  664. u64 unknown_frame_count;
  665. /* port_ltp_crc_mode is returned in 'portinfo' MADs */
  666. u16 port_ltp_crc_mode;
  667. /* port_crc_mode_enabled is the crc we support */
  668. u8 port_crc_mode_enabled;
  669. /* mgmt_allowed is also returned in 'portinfo' MADs */
  670. u8 mgmt_allowed;
  671. u8 part_enforce; /* partition enforcement flags */
  672. struct link_down_reason local_link_down_reason;
  673. struct link_down_reason neigh_link_down_reason;
  674. /* Value to be sent to link peer on LinkDown .*/
  675. u8 remote_link_down_reason;
  676. /* Error events that will cause a port bounce. */
  677. u32 port_error_action;
  678. struct work_struct linkstate_active_work;
  679. /* Does this port need to prescan for FECNs */
  680. bool cc_prescan;
  681. };
  682. typedef int (*rhf_rcv_function_ptr)(struct hfi1_packet *packet);
  683. typedef void (*opcode_handler)(struct hfi1_packet *packet);
  684. /* return values for the RHF receive functions */
  685. #define RHF_RCV_CONTINUE 0 /* keep going */
  686. #define RHF_RCV_DONE 1 /* stop, this packet processed */
  687. #define RHF_RCV_REPROCESS 2 /* stop. retain this packet */
  688. struct rcv_array_data {
  689. u8 group_size;
  690. u16 ngroups;
  691. u16 nctxt_extra;
  692. };
  693. struct per_vl_data {
  694. u16 mtu;
  695. struct send_context *sc;
  696. };
  697. /* 16 to directly index */
  698. #define PER_VL_SEND_CONTEXTS 16
  699. struct err_info_rcvport {
  700. u8 status_and_code;
  701. u64 packet_flit1;
  702. u64 packet_flit2;
  703. };
  704. struct err_info_constraint {
  705. u8 status;
  706. u16 pkey;
  707. u32 slid;
  708. };
  709. struct hfi1_temp {
  710. unsigned int curr; /* current temperature */
  711. unsigned int lo_lim; /* low temperature limit */
  712. unsigned int hi_lim; /* high temperature limit */
  713. unsigned int crit_lim; /* critical temperature limit */
  714. u8 triggers; /* temperature triggers */
  715. };
  716. struct hfi1_i2c_bus {
  717. struct hfi1_devdata *controlling_dd; /* current controlling device */
  718. struct i2c_adapter adapter; /* bus details */
  719. struct i2c_algo_bit_data algo; /* bus algorithm details */
  720. int num; /* bus number, 0 or 1 */
  721. };
  722. /* common data between shared ASIC HFIs */
  723. struct hfi1_asic_data {
  724. struct hfi1_devdata *dds[2]; /* back pointers */
  725. struct mutex asic_resource_mutex;
  726. struct hfi1_i2c_bus *i2c_bus0;
  727. struct hfi1_i2c_bus *i2c_bus1;
  728. };
  729. /* device data struct now contains only "general per-device" info.
  730. * fields related to a physical IB port are in a hfi1_pportdata struct.
  731. */
  732. struct sdma_engine;
  733. struct sdma_vl_map;
  734. #define BOARD_VERS_MAX 96 /* how long the version string can be */
  735. #define SERIAL_MAX 16 /* length of the serial number */
  736. typedef int (*send_routine)(struct rvt_qp *, struct hfi1_pkt_state *, u64);
  737. struct hfi1_devdata {
  738. struct hfi1_ibdev verbs_dev; /* must be first */
  739. struct list_head list;
  740. /* pointers to related structs for this device */
  741. /* pci access data structure */
  742. struct pci_dev *pcidev;
  743. struct cdev user_cdev;
  744. struct cdev diag_cdev;
  745. struct cdev ui_cdev;
  746. struct device *user_device;
  747. struct device *diag_device;
  748. struct device *ui_device;
  749. /* mem-mapped pointer to base of chip regs */
  750. u8 __iomem *kregbase;
  751. /* end of mem-mapped chip space excluding sendbuf and user regs */
  752. u8 __iomem *kregend;
  753. /* physical address of chip for io_remap, etc. */
  754. resource_size_t physaddr;
  755. /* Per VL data. Enough for all VLs but not all elements are set/used. */
  756. struct per_vl_data vld[PER_VL_SEND_CONTEXTS];
  757. /* send context data */
  758. struct send_context_info *send_contexts;
  759. /* map hardware send contexts to software index */
  760. u8 *hw_to_sw;
  761. /* spinlock for allocating and releasing send context resources */
  762. spinlock_t sc_lock;
  763. /* lock for pio_map */
  764. spinlock_t pio_map_lock;
  765. /* Send Context initialization lock. */
  766. spinlock_t sc_init_lock;
  767. /* lock for sdma_map */
  768. spinlock_t sde_map_lock;
  769. /* array of kernel send contexts */
  770. struct send_context **kernel_send_context;
  771. /* array of vl maps */
  772. struct pio_vl_map __rcu *pio_map;
  773. /* default flags to last descriptor */
  774. u64 default_desc1;
  775. /* fields common to all SDMA engines */
  776. volatile __le64 *sdma_heads_dma; /* DMA'ed by chip */
  777. dma_addr_t sdma_heads_phys;
  778. void *sdma_pad_dma; /* DMA'ed by chip */
  779. dma_addr_t sdma_pad_phys;
  780. /* for deallocation */
  781. size_t sdma_heads_size;
  782. /* number from the chip */
  783. u32 chip_sdma_engines;
  784. /* num used */
  785. u32 num_sdma;
  786. /* array of engines sized by num_sdma */
  787. struct sdma_engine *per_sdma;
  788. /* array of vl maps */
  789. struct sdma_vl_map __rcu *sdma_map;
  790. /* SPC freeze waitqueue and variable */
  791. wait_queue_head_t sdma_unfreeze_wq;
  792. atomic_t sdma_unfreeze_count;
  793. u32 lcb_access_count; /* count of LCB users */
  794. /* common data between shared ASIC HFIs in this OS */
  795. struct hfi1_asic_data *asic_data;
  796. /* mem-mapped pointer to base of PIO buffers */
  797. void __iomem *piobase;
  798. /*
  799. * write-combining mem-mapped pointer to base of RcvArray
  800. * memory.
  801. */
  802. void __iomem *rcvarray_wc;
  803. /*
  804. * credit return base - a per-NUMA range of DMA address that
  805. * the chip will use to update the per-context free counter
  806. */
  807. struct credit_return_base *cr_base;
  808. /* send context numbers and sizes for each type */
  809. struct sc_config_sizes sc_sizes[SC_MAX];
  810. char *boardname; /* human readable board info */
  811. /* reset value */
  812. u64 z_int_counter;
  813. u64 z_rcv_limit;
  814. u64 z_send_schedule;
  815. u64 __percpu *send_schedule;
  816. /* number of receive contexts in use by the driver */
  817. u32 num_rcv_contexts;
  818. /* number of pio send contexts in use by the driver */
  819. u32 num_send_contexts;
  820. /*
  821. * number of ctxts available for PSM open
  822. */
  823. u32 freectxts;
  824. /* total number of available user/PSM contexts */
  825. u32 num_user_contexts;
  826. /* base receive interrupt timeout, in CSR units */
  827. u32 rcv_intr_timeout_csr;
  828. u32 freezelen; /* max length of freezemsg */
  829. u64 __iomem *egrtidbase;
  830. spinlock_t sendctrl_lock; /* protect changes to SendCtrl */
  831. spinlock_t rcvctrl_lock; /* protect changes to RcvCtrl */
  832. /* around rcd and (user ctxts) ctxt_cnt use (intr vs free) */
  833. spinlock_t uctxt_lock; /* rcd and user context changes */
  834. /* exclusive access to 8051 */
  835. spinlock_t dc8051_lock;
  836. /* exclusive access to 8051 memory */
  837. spinlock_t dc8051_memlock;
  838. int dc8051_timed_out; /* remember if the 8051 timed out */
  839. /*
  840. * A page that will hold event notification bitmaps for all
  841. * contexts. This page will be mapped into all processes.
  842. */
  843. unsigned long *events;
  844. /*
  845. * per unit status, see also portdata statusp
  846. * mapped read-only into user processes so they can get unit and
  847. * IB link status cheaply
  848. */
  849. struct hfi1_status *status;
  850. /* revision register shadow */
  851. u64 revision;
  852. /* Base GUID for device (network order) */
  853. u64 base_guid;
  854. /* these are the "32 bit" regs */
  855. /* value we put in kr_rcvhdrsize */
  856. u32 rcvhdrsize;
  857. /* number of receive contexts the chip supports */
  858. u32 chip_rcv_contexts;
  859. /* number of receive array entries */
  860. u32 chip_rcv_array_count;
  861. /* number of PIO send contexts the chip supports */
  862. u32 chip_send_contexts;
  863. /* number of bytes in the PIO memory buffer */
  864. u32 chip_pio_mem_size;
  865. /* number of bytes in the SDMA memory buffer */
  866. u32 chip_sdma_mem_size;
  867. /* size of each rcvegrbuffer */
  868. u32 rcvegrbufsize;
  869. /* log2 of above */
  870. u16 rcvegrbufsize_shift;
  871. /* both sides of the PCIe link are gen3 capable */
  872. u8 link_gen3_capable;
  873. /* default link down value (poll/sleep) */
  874. u8 link_default;
  875. /* localbus width (1, 2,4,8,16,32) from config space */
  876. u32 lbus_width;
  877. /* localbus speed in MHz */
  878. u32 lbus_speed;
  879. int unit; /* unit # of this chip */
  880. int node; /* home node of this chip */
  881. /* save these PCI fields to restore after a reset */
  882. u32 pcibar0;
  883. u32 pcibar1;
  884. u32 pci_rom;
  885. u16 pci_command;
  886. u16 pcie_devctl;
  887. u16 pcie_lnkctl;
  888. u16 pcie_devctl2;
  889. u32 pci_msix0;
  890. u32 pci_lnkctl3;
  891. u32 pci_tph2;
  892. /*
  893. * ASCII serial number, from flash, large enough for original
  894. * all digit strings, and longer serial number format
  895. */
  896. u8 serial[SERIAL_MAX];
  897. /* human readable board version */
  898. u8 boardversion[BOARD_VERS_MAX];
  899. u8 lbus_info[32]; /* human readable localbus info */
  900. /* chip major rev, from CceRevision */
  901. u8 majrev;
  902. /* chip minor rev, from CceRevision */
  903. u8 minrev;
  904. /* hardware ID */
  905. u8 hfi1_id;
  906. /* implementation code */
  907. u8 icode;
  908. /* vAU of this device */
  909. u8 vau;
  910. /* vCU of this device */
  911. u8 vcu;
  912. /* link credits of this device */
  913. u16 link_credits;
  914. /* initial vl15 credits to use */
  915. u16 vl15_init;
  916. /* Misc small ints */
  917. u8 n_krcv_queues;
  918. u8 qos_shift;
  919. u16 irev; /* implementation revision */
  920. u16 dc8051_ver; /* 8051 firmware version */
  921. spinlock_t hfi1_diag_trans_lock; /* protect diag observer ops */
  922. struct platform_config platform_config;
  923. struct platform_config_cache pcfg_cache;
  924. struct diag_client *diag_client;
  925. /* MSI-X information */
  926. struct hfi1_msix_entry *msix_entries;
  927. u32 num_msix_entries;
  928. /* INTx information */
  929. u32 requested_intx_irq; /* did we request one? */
  930. char intx_name[MAX_NAME_SIZE]; /* INTx name */
  931. /* general interrupt: mask of handled interrupts */
  932. u64 gi_mask[CCE_NUM_INT_CSRS];
  933. struct rcv_array_data rcv_entries;
  934. /* cycle length of PS* counters in HW (in picoseconds) */
  935. u16 psxmitwait_check_rate;
  936. /*
  937. * 64 bit synthetic counters
  938. */
  939. struct timer_list synth_stats_timer;
  940. /*
  941. * device counters
  942. */
  943. char *cntrnames;
  944. size_t cntrnameslen;
  945. size_t ndevcntrs;
  946. u64 *cntrs;
  947. u64 *scntrs;
  948. /*
  949. * remembered values for synthetic counters
  950. */
  951. u64 last_tx;
  952. u64 last_rx;
  953. /*
  954. * per-port counters
  955. */
  956. size_t nportcntrs;
  957. char *portcntrnames;
  958. size_t portcntrnameslen;
  959. struct err_info_rcvport err_info_rcvport;
  960. struct err_info_constraint err_info_rcv_constraint;
  961. struct err_info_constraint err_info_xmit_constraint;
  962. atomic_t drop_packet;
  963. u8 do_drop;
  964. u8 err_info_uncorrectable;
  965. u8 err_info_fmconfig;
  966. /*
  967. * Software counters for the status bits defined by the
  968. * associated error status registers
  969. */
  970. u64 cce_err_status_cnt[NUM_CCE_ERR_STATUS_COUNTERS];
  971. u64 rcv_err_status_cnt[NUM_RCV_ERR_STATUS_COUNTERS];
  972. u64 misc_err_status_cnt[NUM_MISC_ERR_STATUS_COUNTERS];
  973. u64 send_pio_err_status_cnt[NUM_SEND_PIO_ERR_STATUS_COUNTERS];
  974. u64 send_dma_err_status_cnt[NUM_SEND_DMA_ERR_STATUS_COUNTERS];
  975. u64 send_egress_err_status_cnt[NUM_SEND_EGRESS_ERR_STATUS_COUNTERS];
  976. u64 send_err_status_cnt[NUM_SEND_ERR_STATUS_COUNTERS];
  977. /* Software counter that spans all contexts */
  978. u64 sw_ctxt_err_status_cnt[NUM_SEND_CTXT_ERR_STATUS_COUNTERS];
  979. /* Software counter that spans all DMA engines */
  980. u64 sw_send_dma_eng_err_status_cnt[
  981. NUM_SEND_DMA_ENG_ERR_STATUS_COUNTERS];
  982. /* Software counter that aggregates all cce_err_status errors */
  983. u64 sw_cce_err_status_aggregate;
  984. /* Software counter that aggregates all bypass packet rcv errors */
  985. u64 sw_rcv_bypass_packet_errors;
  986. /* receive interrupt function */
  987. rhf_rcv_function_ptr normal_rhf_rcv_functions[8];
  988. /* Save the enabled LCB error bits */
  989. u64 lcb_err_en;
  990. /*
  991. * Capability to have different send engines simply by changing a
  992. * pointer value.
  993. */
  994. send_routine process_pio_send ____cacheline_aligned_in_smp;
  995. send_routine process_dma_send;
  996. void (*pio_inline_send)(struct hfi1_devdata *dd, struct pio_buf *pbuf,
  997. u64 pbc, const void *from, size_t count);
  998. /* hfi1_pportdata, points to array of (physical) port-specific
  999. * data structs, indexed by pidx (0..n-1)
  1000. */
  1001. struct hfi1_pportdata *pport;
  1002. /* receive context data */
  1003. struct hfi1_ctxtdata **rcd;
  1004. u64 __percpu *int_counter;
  1005. /* device (not port) flags, basically device capabilities */
  1006. u16 flags;
  1007. /* Number of physical ports available */
  1008. u8 num_pports;
  1009. /* Lowest context number which can be used by user processes */
  1010. u8 first_user_ctxt;
  1011. /* adding a new field here would make it part of this cacheline */
  1012. /* seqlock for sc2vl */
  1013. seqlock_t sc2vl_lock ____cacheline_aligned_in_smp;
  1014. u64 sc2vl[4];
  1015. /* receive interrupt functions */
  1016. rhf_rcv_function_ptr *rhf_rcv_function_map;
  1017. u64 __percpu *rcv_limit;
  1018. u16 rhf_offset; /* offset of RHF within receive header entry */
  1019. /* adding a new field here would make it part of this cacheline */
  1020. /* OUI comes from the HW. Used everywhere as 3 separate bytes. */
  1021. u8 oui1;
  1022. u8 oui2;
  1023. u8 oui3;
  1024. u8 dc_shutdown;
  1025. /* Timer and counter used to detect RcvBufOvflCnt changes */
  1026. struct timer_list rcverr_timer;
  1027. wait_queue_head_t event_queue;
  1028. /* receive context tail dummy address */
  1029. __le64 *rcvhdrtail_dummy_kvaddr;
  1030. dma_addr_t rcvhdrtail_dummy_dma;
  1031. u32 rcv_ovfl_cnt;
  1032. /* Serialize ASPM enable/disable between multiple verbs contexts */
  1033. spinlock_t aspm_lock;
  1034. /* Number of verbs contexts which have disabled ASPM */
  1035. atomic_t aspm_disabled_cnt;
  1036. /* Keeps track of user space clients */
  1037. atomic_t user_refcount;
  1038. /* Used to wait for outstanding user space clients before dev removal */
  1039. struct completion user_comp;
  1040. bool eprom_available; /* true if EPROM is available for this device */
  1041. bool aspm_supported; /* Does HW support ASPM */
  1042. bool aspm_enabled; /* ASPM state: enabled/disabled */
  1043. struct rhashtable sdma_rht;
  1044. struct kobject kobj;
  1045. };
  1046. /* 8051 firmware version helper */
  1047. #define dc8051_ver(a, b) ((a) << 8 | (b))
  1048. #define dc8051_ver_maj(a) ((a & 0xff00) >> 8)
  1049. #define dc8051_ver_min(a) (a & 0x00ff)
  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. void hfi1_process_ecn_slowpath(struct rvt_qp *qp, struct hfi1_packet *pkt,
  1390. bool do_cnp);
  1391. static inline bool process_ecn(struct rvt_qp *qp, struct hfi1_packet *pkt,
  1392. bool do_cnp)
  1393. {
  1394. struct ib_other_headers *ohdr = pkt->ohdr;
  1395. u32 bth1;
  1396. bth1 = be32_to_cpu(ohdr->bth[1]);
  1397. if (unlikely(bth1 & (HFI1_BECN_SMASK | HFI1_FECN_SMASK))) {
  1398. hfi1_process_ecn_slowpath(qp, pkt, do_cnp);
  1399. return bth1 & HFI1_FECN_SMASK;
  1400. }
  1401. return false;
  1402. }
  1403. /*
  1404. * Return the indexed PKEY from the port PKEY table.
  1405. */
  1406. static inline u16 hfi1_get_pkey(struct hfi1_ibport *ibp, unsigned index)
  1407. {
  1408. struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
  1409. u16 ret;
  1410. if (index >= ARRAY_SIZE(ppd->pkeys))
  1411. ret = 0;
  1412. else
  1413. ret = ppd->pkeys[index];
  1414. return ret;
  1415. }
  1416. /*
  1417. * Return the indexed GUID from the port GUIDs table.
  1418. */
  1419. static inline __be64 get_sguid(struct hfi1_ibport *ibp, unsigned int index)
  1420. {
  1421. struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
  1422. WARN_ON(index >= HFI1_GUIDS_PER_PORT);
  1423. return cpu_to_be64(ppd->guids[index]);
  1424. }
  1425. /*
  1426. * Called by readers of cc_state only, must call under rcu_read_lock().
  1427. */
  1428. static inline struct cc_state *get_cc_state(struct hfi1_pportdata *ppd)
  1429. {
  1430. return rcu_dereference(ppd->cc_state);
  1431. }
  1432. /*
  1433. * Called by writers of cc_state only, must call under cc_state_lock.
  1434. */
  1435. static inline
  1436. struct cc_state *get_cc_state_protected(struct hfi1_pportdata *ppd)
  1437. {
  1438. return rcu_dereference_protected(ppd->cc_state,
  1439. lockdep_is_held(&ppd->cc_state_lock));
  1440. }
  1441. /*
  1442. * values for dd->flags (_device_ related flags)
  1443. */
  1444. #define HFI1_INITTED 0x1 /* chip and driver up and initted */
  1445. #define HFI1_PRESENT 0x2 /* chip accesses can be done */
  1446. #define HFI1_FROZEN 0x4 /* chip in SPC freeze */
  1447. #define HFI1_HAS_SDMA_TIMEOUT 0x8
  1448. #define HFI1_HAS_SEND_DMA 0x10 /* Supports Send DMA */
  1449. #define HFI1_FORCED_FREEZE 0x80 /* driver forced freeze mode */
  1450. /* IB dword length mask in PBC (lower 11 bits); same for all chips */
  1451. #define HFI1_PBC_LENGTH_MASK ((1 << 11) - 1)
  1452. /* ctxt_flag bit offsets */
  1453. /* context has been setup */
  1454. #define HFI1_CTXT_SETUP_DONE 1
  1455. /* waiting for a packet to arrive */
  1456. #define HFI1_CTXT_WAITING_RCV 2
  1457. /* master has not finished initializing */
  1458. #define HFI1_CTXT_MASTER_UNINIT 4
  1459. /* waiting for an urgent packet to arrive */
  1460. #define HFI1_CTXT_WAITING_URG 5
  1461. /* free up any allocated data at closes */
  1462. struct hfi1_devdata *hfi1_init_dd(struct pci_dev *,
  1463. const struct pci_device_id *);
  1464. void hfi1_free_devdata(struct hfi1_devdata *);
  1465. struct hfi1_devdata *hfi1_alloc_devdata(struct pci_dev *pdev, size_t extra);
  1466. /* LED beaconing functions */
  1467. void hfi1_start_led_override(struct hfi1_pportdata *ppd, unsigned int timeon,
  1468. unsigned int timeoff);
  1469. void shutdown_led_override(struct hfi1_pportdata *ppd);
  1470. #define HFI1_CREDIT_RETURN_RATE (100)
  1471. /*
  1472. * The number of words for the KDETH protocol field. If this is
  1473. * larger then the actual field used, then part of the payload
  1474. * will be in the header.
  1475. *
  1476. * Optimally, we want this sized so that a typical case will
  1477. * use full cache lines. The typical local KDETH header would
  1478. * be:
  1479. *
  1480. * Bytes Field
  1481. * 8 LRH
  1482. * 12 BHT
  1483. * ?? KDETH
  1484. * 8 RHF
  1485. * ---
  1486. * 28 + KDETH
  1487. *
  1488. * For a 64-byte cache line, KDETH would need to be 36 bytes or 9 DWORDS
  1489. */
  1490. #define DEFAULT_RCVHDRSIZE 9
  1491. /*
  1492. * Maximal header byte count:
  1493. *
  1494. * Bytes Field
  1495. * 8 LRH
  1496. * 40 GRH (optional)
  1497. * 12 BTH
  1498. * ?? KDETH
  1499. * 8 RHF
  1500. * ---
  1501. * 68 + KDETH
  1502. *
  1503. * We also want to maintain a cache line alignment to assist DMA'ing
  1504. * of the header bytes. Round up to a good size.
  1505. */
  1506. #define DEFAULT_RCVHDR_ENTSIZE 32
  1507. bool hfi1_can_pin_pages(struct hfi1_devdata *dd, struct mm_struct *mm,
  1508. u32 nlocked, u32 npages);
  1509. int hfi1_acquire_user_pages(struct mm_struct *mm, unsigned long vaddr,
  1510. size_t npages, bool writable, struct page **pages);
  1511. void hfi1_release_user_pages(struct mm_struct *mm, struct page **p,
  1512. size_t npages, bool dirty);
  1513. static inline void clear_rcvhdrtail(const struct hfi1_ctxtdata *rcd)
  1514. {
  1515. *((u64 *)rcd->rcvhdrtail_kvaddr) = 0ULL;
  1516. }
  1517. static inline u32 get_rcvhdrtail(const struct hfi1_ctxtdata *rcd)
  1518. {
  1519. /*
  1520. * volatile because it's a DMA target from the chip, routine is
  1521. * inlined, and don't want register caching or reordering.
  1522. */
  1523. return (u32)le64_to_cpu(*rcd->rcvhdrtail_kvaddr);
  1524. }
  1525. /*
  1526. * sysfs interface.
  1527. */
  1528. extern const char ib_hfi1_version[];
  1529. int hfi1_device_create(struct hfi1_devdata *);
  1530. void hfi1_device_remove(struct hfi1_devdata *);
  1531. int hfi1_create_port_files(struct ib_device *ibdev, u8 port_num,
  1532. struct kobject *kobj);
  1533. int hfi1_verbs_register_sysfs(struct hfi1_devdata *);
  1534. void hfi1_verbs_unregister_sysfs(struct hfi1_devdata *);
  1535. /* Hook for sysfs read of QSFP */
  1536. int qsfp_dump(struct hfi1_pportdata *ppd, char *buf, int len);
  1537. int hfi1_pcie_init(struct pci_dev *, const struct pci_device_id *);
  1538. void hfi1_pcie_cleanup(struct pci_dev *);
  1539. int hfi1_pcie_ddinit(struct hfi1_devdata *, struct pci_dev *);
  1540. void hfi1_pcie_ddcleanup(struct hfi1_devdata *);
  1541. void hfi1_pcie_flr(struct hfi1_devdata *);
  1542. int pcie_speeds(struct hfi1_devdata *);
  1543. void request_msix(struct hfi1_devdata *, u32 *, struct hfi1_msix_entry *);
  1544. void hfi1_enable_intx(struct pci_dev *);
  1545. void restore_pci_variables(struct hfi1_devdata *dd);
  1546. int do_pcie_gen3_transition(struct hfi1_devdata *dd);
  1547. int parse_platform_config(struct hfi1_devdata *dd);
  1548. int get_platform_config_field(struct hfi1_devdata *dd,
  1549. enum platform_config_table_type_encoding
  1550. table_type, int table_index, int field_index,
  1551. u32 *data, u32 len);
  1552. const char *get_unit_name(int unit);
  1553. const char *get_card_name(struct rvt_dev_info *rdi);
  1554. struct pci_dev *get_pci_dev(struct rvt_dev_info *rdi);
  1555. /*
  1556. * Flush write combining store buffers (if present) and perform a write
  1557. * barrier.
  1558. */
  1559. static inline void flush_wc(void)
  1560. {
  1561. asm volatile("sfence" : : : "memory");
  1562. }
  1563. void handle_eflags(struct hfi1_packet *packet);
  1564. int process_receive_ib(struct hfi1_packet *packet);
  1565. int process_receive_bypass(struct hfi1_packet *packet);
  1566. int process_receive_error(struct hfi1_packet *packet);
  1567. int kdeth_process_expected(struct hfi1_packet *packet);
  1568. int kdeth_process_eager(struct hfi1_packet *packet);
  1569. int process_receive_invalid(struct hfi1_packet *packet);
  1570. void update_sge(struct rvt_sge_state *ss, u32 length);
  1571. /* global module parameter variables */
  1572. extern unsigned int hfi1_max_mtu;
  1573. extern unsigned int hfi1_cu;
  1574. extern unsigned int user_credit_return_threshold;
  1575. extern int num_user_contexts;
  1576. extern unsigned long n_krcvqs;
  1577. extern uint krcvqs[];
  1578. extern int krcvqsset;
  1579. extern uint kdeth_qp;
  1580. extern uint loopback;
  1581. extern uint quick_linkup;
  1582. extern uint rcv_intr_timeout;
  1583. extern uint rcv_intr_count;
  1584. extern uint rcv_intr_dynamic;
  1585. extern ushort link_crc_mask;
  1586. extern struct mutex hfi1_mutex;
  1587. /* Number of seconds before our card status check... */
  1588. #define STATUS_TIMEOUT 60
  1589. #define DRIVER_NAME "hfi1"
  1590. #define HFI1_USER_MINOR_BASE 0
  1591. #define HFI1_TRACE_MINOR 127
  1592. #define HFI1_NMINORS 255
  1593. #define PCI_VENDOR_ID_INTEL 0x8086
  1594. #define PCI_DEVICE_ID_INTEL0 0x24f0
  1595. #define PCI_DEVICE_ID_INTEL1 0x24f1
  1596. #define HFI1_PKT_USER_SC_INTEGRITY \
  1597. (SEND_CTXT_CHECK_ENABLE_DISALLOW_NON_KDETH_PACKETS_SMASK \
  1598. | SEND_CTXT_CHECK_ENABLE_DISALLOW_KDETH_PACKETS_SMASK \
  1599. | SEND_CTXT_CHECK_ENABLE_DISALLOW_BYPASS_SMASK \
  1600. | SEND_CTXT_CHECK_ENABLE_DISALLOW_GRH_SMASK)
  1601. #define HFI1_PKT_KERNEL_SC_INTEGRITY \
  1602. (SEND_CTXT_CHECK_ENABLE_DISALLOW_KDETH_PACKETS_SMASK)
  1603. static inline u64 hfi1_pkt_default_send_ctxt_mask(struct hfi1_devdata *dd,
  1604. u16 ctxt_type)
  1605. {
  1606. u64 base_sc_integrity;
  1607. /* No integrity checks if HFI1_CAP_NO_INTEGRITY is set */
  1608. if (HFI1_CAP_IS_KSET(NO_INTEGRITY))
  1609. return 0;
  1610. base_sc_integrity =
  1611. SEND_CTXT_CHECK_ENABLE_DISALLOW_BYPASS_BAD_PKT_LEN_SMASK
  1612. | SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK
  1613. | SEND_CTXT_CHECK_ENABLE_DISALLOW_TOO_LONG_BYPASS_PACKETS_SMASK
  1614. | SEND_CTXT_CHECK_ENABLE_DISALLOW_TOO_LONG_IB_PACKETS_SMASK
  1615. | SEND_CTXT_CHECK_ENABLE_DISALLOW_BAD_PKT_LEN_SMASK
  1616. | SEND_CTXT_CHECK_ENABLE_DISALLOW_PBC_TEST_SMASK
  1617. | SEND_CTXT_CHECK_ENABLE_DISALLOW_TOO_SMALL_BYPASS_PACKETS_SMASK
  1618. | SEND_CTXT_CHECK_ENABLE_DISALLOW_TOO_SMALL_IB_PACKETS_SMASK
  1619. | SEND_CTXT_CHECK_ENABLE_DISALLOW_RAW_IPV6_SMASK
  1620. | SEND_CTXT_CHECK_ENABLE_DISALLOW_RAW_SMASK
  1621. | SEND_CTXT_CHECK_ENABLE_CHECK_BYPASS_VL_MAPPING_SMASK
  1622. | SEND_CTXT_CHECK_ENABLE_CHECK_VL_MAPPING_SMASK
  1623. | SEND_CTXT_CHECK_ENABLE_CHECK_OPCODE_SMASK
  1624. | SEND_CTXT_CHECK_ENABLE_CHECK_SLID_SMASK
  1625. | SEND_CTXT_CHECK_ENABLE_CHECK_VL_SMASK
  1626. | SEND_CTXT_CHECK_ENABLE_CHECK_ENABLE_SMASK;
  1627. if (ctxt_type == SC_USER)
  1628. base_sc_integrity |= HFI1_PKT_USER_SC_INTEGRITY;
  1629. else
  1630. base_sc_integrity |= HFI1_PKT_KERNEL_SC_INTEGRITY;
  1631. /* turn on send-side job key checks if !A0 */
  1632. if (!is_ax(dd))
  1633. base_sc_integrity |= SEND_CTXT_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
  1634. return base_sc_integrity;
  1635. }
  1636. static inline u64 hfi1_pkt_base_sdma_integrity(struct hfi1_devdata *dd)
  1637. {
  1638. u64 base_sdma_integrity;
  1639. /* No integrity checks if HFI1_CAP_NO_INTEGRITY is set */
  1640. if (HFI1_CAP_IS_KSET(NO_INTEGRITY))
  1641. return 0;
  1642. base_sdma_integrity =
  1643. SEND_DMA_CHECK_ENABLE_DISALLOW_BYPASS_BAD_PKT_LEN_SMASK
  1644. | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_LONG_BYPASS_PACKETS_SMASK
  1645. | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_LONG_IB_PACKETS_SMASK
  1646. | SEND_DMA_CHECK_ENABLE_DISALLOW_BAD_PKT_LEN_SMASK
  1647. | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_SMALL_BYPASS_PACKETS_SMASK
  1648. | SEND_DMA_CHECK_ENABLE_DISALLOW_TOO_SMALL_IB_PACKETS_SMASK
  1649. | SEND_DMA_CHECK_ENABLE_DISALLOW_RAW_IPV6_SMASK
  1650. | SEND_DMA_CHECK_ENABLE_DISALLOW_RAW_SMASK
  1651. | SEND_DMA_CHECK_ENABLE_CHECK_BYPASS_VL_MAPPING_SMASK
  1652. | SEND_DMA_CHECK_ENABLE_CHECK_VL_MAPPING_SMASK
  1653. | SEND_DMA_CHECK_ENABLE_CHECK_OPCODE_SMASK
  1654. | SEND_DMA_CHECK_ENABLE_CHECK_SLID_SMASK
  1655. | SEND_DMA_CHECK_ENABLE_CHECK_VL_SMASK
  1656. | SEND_DMA_CHECK_ENABLE_CHECK_ENABLE_SMASK;
  1657. if (!HFI1_CAP_IS_KSET(STATIC_RATE_CTRL))
  1658. base_sdma_integrity |=
  1659. SEND_DMA_CHECK_ENABLE_DISALLOW_PBC_STATIC_RATE_CONTROL_SMASK;
  1660. /* turn on send-side job key checks if !A0 */
  1661. if (!is_ax(dd))
  1662. base_sdma_integrity |=
  1663. SEND_DMA_CHECK_ENABLE_CHECK_JOB_KEY_SMASK;
  1664. return base_sdma_integrity;
  1665. }
  1666. /*
  1667. * hfi1_early_err is used (only!) to print early errors before devdata is
  1668. * allocated, or when dd->pcidev may not be valid, and at the tail end of
  1669. * cleanup when devdata may have been freed, etc. hfi1_dev_porterr is
  1670. * the same as dd_dev_err, but is used when the message really needs
  1671. * the IB port# to be definitive as to what's happening..
  1672. */
  1673. #define hfi1_early_err(dev, fmt, ...) \
  1674. dev_err(dev, fmt, ##__VA_ARGS__)
  1675. #define hfi1_early_info(dev, fmt, ...) \
  1676. dev_info(dev, fmt, ##__VA_ARGS__)
  1677. #define dd_dev_emerg(dd, fmt, ...) \
  1678. dev_emerg(&(dd)->pcidev->dev, "%s: " fmt, \
  1679. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1680. #define dd_dev_err(dd, fmt, ...) \
  1681. dev_err(&(dd)->pcidev->dev, "%s: " fmt, \
  1682. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1683. #define dd_dev_warn(dd, fmt, ...) \
  1684. dev_warn(&(dd)->pcidev->dev, "%s: " fmt, \
  1685. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1686. #define dd_dev_warn_ratelimited(dd, fmt, ...) \
  1687. dev_warn_ratelimited(&(dd)->pcidev->dev, "%s: " fmt, \
  1688. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1689. #define dd_dev_info(dd, fmt, ...) \
  1690. dev_info(&(dd)->pcidev->dev, "%s: " fmt, \
  1691. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1692. #define dd_dev_dbg(dd, fmt, ...) \
  1693. dev_dbg(&(dd)->pcidev->dev, "%s: " fmt, \
  1694. get_unit_name((dd)->unit), ##__VA_ARGS__)
  1695. #define hfi1_dev_porterr(dd, port, fmt, ...) \
  1696. dev_err(&(dd)->pcidev->dev, "%s: port %u: " fmt, \
  1697. get_unit_name((dd)->unit), (port), ##__VA_ARGS__)
  1698. /*
  1699. * this is used for formatting hw error messages...
  1700. */
  1701. struct hfi1_hwerror_msgs {
  1702. u64 mask;
  1703. const char *msg;
  1704. size_t sz;
  1705. };
  1706. /* in intr.c... */
  1707. void hfi1_format_hwerrors(u64 hwerrs,
  1708. const struct hfi1_hwerror_msgs *hwerrmsgs,
  1709. size_t nhwerrmsgs, char *msg, size_t lmsg);
  1710. #define USER_OPCODE_CHECK_VAL 0xC0
  1711. #define USER_OPCODE_CHECK_MASK 0xC0
  1712. #define OPCODE_CHECK_VAL_DISABLED 0x0
  1713. #define OPCODE_CHECK_MASK_DISABLED 0x0
  1714. static inline void hfi1_reset_cpu_counters(struct hfi1_devdata *dd)
  1715. {
  1716. struct hfi1_pportdata *ppd;
  1717. int i;
  1718. dd->z_int_counter = get_all_cpu_total(dd->int_counter);
  1719. dd->z_rcv_limit = get_all_cpu_total(dd->rcv_limit);
  1720. dd->z_send_schedule = get_all_cpu_total(dd->send_schedule);
  1721. ppd = (struct hfi1_pportdata *)(dd + 1);
  1722. for (i = 0; i < dd->num_pports; i++, ppd++) {
  1723. ppd->ibport_data.rvp.z_rc_acks =
  1724. get_all_cpu_total(ppd->ibport_data.rvp.rc_acks);
  1725. ppd->ibport_data.rvp.z_rc_qacks =
  1726. get_all_cpu_total(ppd->ibport_data.rvp.rc_qacks);
  1727. }
  1728. }
  1729. /* Control LED state */
  1730. static inline void setextled(struct hfi1_devdata *dd, u32 on)
  1731. {
  1732. if (on)
  1733. write_csr(dd, DCC_CFG_LED_CNTRL, 0x1F);
  1734. else
  1735. write_csr(dd, DCC_CFG_LED_CNTRL, 0x10);
  1736. }
  1737. /* return the i2c resource given the target */
  1738. static inline u32 i2c_target(u32 target)
  1739. {
  1740. return target ? CR_I2C2 : CR_I2C1;
  1741. }
  1742. /* return the i2c chain chip resource that this HFI uses for QSFP */
  1743. static inline u32 qsfp_resource(struct hfi1_devdata *dd)
  1744. {
  1745. return i2c_target(dd->hfi1_id);
  1746. }
  1747. /* Is this device integrated or discrete? */
  1748. static inline bool is_integrated(struct hfi1_devdata *dd)
  1749. {
  1750. return dd->pcidev->device == PCI_DEVICE_ID_INTEL1;
  1751. }
  1752. int hfi1_tempsense_rd(struct hfi1_devdata *dd, struct hfi1_temp *temp);
  1753. #define DD_DEV_ENTRY(dd) __string(dev, dev_name(&(dd)->pcidev->dev))
  1754. #define DD_DEV_ASSIGN(dd) __assign_str(dev, dev_name(&(dd)->pcidev->dev))
  1755. #define packettype_name(etype) { RHF_RCV_TYPE_##etype, #etype }
  1756. #define show_packettype(etype) \
  1757. __print_symbolic(etype, \
  1758. packettype_name(EXPECTED), \
  1759. packettype_name(EAGER), \
  1760. packettype_name(IB), \
  1761. packettype_name(ERROR), \
  1762. packettype_name(BYPASS))
  1763. #define ib_opcode_name(opcode) { IB_OPCODE_##opcode, #opcode }
  1764. #define show_ib_opcode(opcode) \
  1765. __print_symbolic(opcode, \
  1766. ib_opcode_name(RC_SEND_FIRST), \
  1767. ib_opcode_name(RC_SEND_MIDDLE), \
  1768. ib_opcode_name(RC_SEND_LAST), \
  1769. ib_opcode_name(RC_SEND_LAST_WITH_IMMEDIATE), \
  1770. ib_opcode_name(RC_SEND_ONLY), \
  1771. ib_opcode_name(RC_SEND_ONLY_WITH_IMMEDIATE), \
  1772. ib_opcode_name(RC_RDMA_WRITE_FIRST), \
  1773. ib_opcode_name(RC_RDMA_WRITE_MIDDLE), \
  1774. ib_opcode_name(RC_RDMA_WRITE_LAST), \
  1775. ib_opcode_name(RC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
  1776. ib_opcode_name(RC_RDMA_WRITE_ONLY), \
  1777. ib_opcode_name(RC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
  1778. ib_opcode_name(RC_RDMA_READ_REQUEST), \
  1779. ib_opcode_name(RC_RDMA_READ_RESPONSE_FIRST), \
  1780. ib_opcode_name(RC_RDMA_READ_RESPONSE_MIDDLE), \
  1781. ib_opcode_name(RC_RDMA_READ_RESPONSE_LAST), \
  1782. ib_opcode_name(RC_RDMA_READ_RESPONSE_ONLY), \
  1783. ib_opcode_name(RC_ACKNOWLEDGE), \
  1784. ib_opcode_name(RC_ATOMIC_ACKNOWLEDGE), \
  1785. ib_opcode_name(RC_COMPARE_SWAP), \
  1786. ib_opcode_name(RC_FETCH_ADD), \
  1787. ib_opcode_name(UC_SEND_FIRST), \
  1788. ib_opcode_name(UC_SEND_MIDDLE), \
  1789. ib_opcode_name(UC_SEND_LAST), \
  1790. ib_opcode_name(UC_SEND_LAST_WITH_IMMEDIATE), \
  1791. ib_opcode_name(UC_SEND_ONLY), \
  1792. ib_opcode_name(UC_SEND_ONLY_WITH_IMMEDIATE), \
  1793. ib_opcode_name(UC_RDMA_WRITE_FIRST), \
  1794. ib_opcode_name(UC_RDMA_WRITE_MIDDLE), \
  1795. ib_opcode_name(UC_RDMA_WRITE_LAST), \
  1796. ib_opcode_name(UC_RDMA_WRITE_LAST_WITH_IMMEDIATE), \
  1797. ib_opcode_name(UC_RDMA_WRITE_ONLY), \
  1798. ib_opcode_name(UC_RDMA_WRITE_ONLY_WITH_IMMEDIATE), \
  1799. ib_opcode_name(UD_SEND_ONLY), \
  1800. ib_opcode_name(UD_SEND_ONLY_WITH_IMMEDIATE), \
  1801. ib_opcode_name(CNP))
  1802. #endif /* _HFI1_KERNEL_H */