Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

hermon.h 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610
  1. #ifndef _HERMON_H
  2. #define _HERMON_H
  3. /** @file
  4. *
  5. * Mellanox Hermon Infiniband HCA driver
  6. *
  7. */
  8. FILE_LICENCE ( GPL2_OR_LATER );
  9. #include <stdint.h>
  10. #include <gpxe/uaccess.h>
  11. #include <gpxe/ib_packet.h>
  12. #include "mlx_bitops.h"
  13. #include "MT25408_PRM.h"
  14. /*
  15. * Hardware constants
  16. *
  17. */
  18. /* Ports in existence */
  19. #define HERMON_MAX_PORTS 2
  20. #define HERMON_PORT_BASE 1
  21. /* PCI BARs */
  22. #define HERMON_PCI_CONFIG_BAR PCI_BASE_ADDRESS_0
  23. #define HERMON_PCI_CONFIG_BAR_SIZE 0x100000
  24. #define HERMON_PCI_UAR_BAR PCI_BASE_ADDRESS_2
  25. /* Device reset */
  26. #define HERMON_RESET_OFFSET 0x0f0010
  27. #define HERMON_RESET_MAGIC 0x01000000UL
  28. #define HERMON_RESET_WAIT_TIME_MS 1000
  29. /* Work queue entry and completion queue entry opcodes */
  30. #define HERMON_OPCODE_NOP 0x00
  31. #define HERMON_OPCODE_SEND 0x0a
  32. #define HERMON_OPCODE_RECV_ERROR 0xfe
  33. #define HERMON_OPCODE_SEND_ERROR 0xff
  34. /* HCA command register opcodes */
  35. #define HERMON_HCR_QUERY_DEV_CAP 0x0003
  36. #define HERMON_HCR_QUERY_FW 0x0004
  37. #define HERMON_HCR_INIT_HCA 0x0007
  38. #define HERMON_HCR_CLOSE_HCA 0x0008
  39. #define HERMON_HCR_INIT_PORT 0x0009
  40. #define HERMON_HCR_CLOSE_PORT 0x000a
  41. #define HERMON_HCR_SW2HW_MPT 0x000d
  42. #define HERMON_HCR_WRITE_MTT 0x0011
  43. #define HERMON_HCR_MAP_EQ 0x0012
  44. #define HERMON_HCR_SW2HW_EQ 0x0013
  45. #define HERMON_HCR_HW2SW_EQ 0x0014
  46. #define HERMON_HCR_QUERY_EQ 0x0015
  47. #define HERMON_HCR_SW2HW_CQ 0x0016
  48. #define HERMON_HCR_HW2SW_CQ 0x0017
  49. #define HERMON_HCR_RST2INIT_QP 0x0019
  50. #define HERMON_HCR_INIT2RTR_QP 0x001a
  51. #define HERMON_HCR_RTR2RTS_QP 0x001b
  52. #define HERMON_HCR_RTS2RTS_QP 0x001c
  53. #define HERMON_HCR_2RST_QP 0x0021
  54. #define HERMON_HCR_QUERY_QP 0x0022
  55. #define HERMON_HCR_CONF_SPECIAL_QP 0x0023
  56. #define HERMON_HCR_MAD_IFC 0x0024
  57. #define HERMON_HCR_READ_MCG 0x0025
  58. #define HERMON_HCR_WRITE_MCG 0x0026
  59. #define HERMON_HCR_MGID_HASH 0x0027
  60. #define HERMON_HCR_SENSE_PORT 0x004d
  61. #define HERMON_HCR_RUN_FW 0x0ff6
  62. #define HERMON_HCR_DISABLE_LAM 0x0ff7
  63. #define HERMON_HCR_ENABLE_LAM 0x0ff8
  64. #define HERMON_HCR_UNMAP_ICM 0x0ff9
  65. #define HERMON_HCR_MAP_ICM 0x0ffa
  66. #define HERMON_HCR_UNMAP_ICM_AUX 0x0ffb
  67. #define HERMON_HCR_MAP_ICM_AUX 0x0ffc
  68. #define HERMON_HCR_SET_ICM_SIZE 0x0ffd
  69. #define HERMON_HCR_UNMAP_FA 0x0ffe
  70. #define HERMON_HCR_MAP_FA 0x0fff
  71. /* Service types */
  72. #define HERMON_ST_RC 0x00
  73. #define HERMON_ST_UD 0x03
  74. #define HERMON_ST_MLX 0x07
  75. /* MTUs */
  76. #define HERMON_MTU_2048 0x04
  77. #define HERMON_INVALID_LKEY 0x00000100UL
  78. #define HERMON_PAGE_SIZE 4096
  79. #define HERMON_DB_POST_SND_OFFSET 0x14
  80. #define HERMON_DB_EQ_OFFSET(_eqn) \
  81. ( 0x800 + HERMON_PAGE_SIZE * ( (_eqn) / 4 ) + 0x08 * ( (_eqn) % 4 ) )
  82. #define HERMON_QP_OPT_PARAM_PM_STATE 0x00000400UL
  83. #define HERMON_QP_OPT_PARAM_QKEY 0x00000020UL
  84. #define HERMON_QP_OPT_PARAM_ALT_PATH 0x00000001UL
  85. #define HERMON_MAP_EQ ( 0UL << 31 )
  86. #define HERMON_UNMAP_EQ ( 1UL << 31 )
  87. #define HERMON_EV_PORT_STATE_CHANGE 0x09
  88. #define HERMON_SCHED_QP0 0x3f
  89. #define HERMON_SCHED_DEFAULT 0x83
  90. #define HERMON_PM_STATE_ARMED 0x00
  91. #define HERMON_PM_STATE_REARM 0x01
  92. #define HERMON_PM_STATE_MIGRATED 0x03
  93. #define HERMON_RETRY_MAX 0x07
  94. /*
  95. * Datatypes that seem to be missing from the autogenerated documentation
  96. *
  97. */
  98. struct hermonprm_mgm_hash_st {
  99. pseudo_bit_t reserved0[0x00020];
  100. /* -------------- */
  101. pseudo_bit_t hash[0x00010];
  102. pseudo_bit_t reserved1[0x00010];
  103. } __attribute__ (( packed ));
  104. struct hermonprm_mcg_entry_st {
  105. struct hermonprm_mcg_hdr_st hdr;
  106. struct hermonprm_mcg_qp_dw_st qp[8];
  107. } __attribute__ (( packed ));
  108. struct hermonprm_cq_db_record_st {
  109. pseudo_bit_t update_ci[0x00018];
  110. pseudo_bit_t reserved0[0x00008];
  111. /* -------------- */
  112. pseudo_bit_t arm_ci[0x00018];
  113. pseudo_bit_t cmd[0x00003];
  114. pseudo_bit_t reserved1[0x00001];
  115. pseudo_bit_t cmd_sn[0x00002];
  116. pseudo_bit_t reserved2[0x00002];
  117. } __attribute__ (( packed ));
  118. struct hermonprm_send_db_register_st {
  119. pseudo_bit_t reserved[0x00008];
  120. pseudo_bit_t qn[0x00018];
  121. } __attribute__ (( packed ));
  122. struct hermonprm_event_db_register_st {
  123. pseudo_bit_t ci[0x00018];
  124. pseudo_bit_t reserver[0x00007];
  125. pseudo_bit_t a[0x00001];
  126. } __attribute__ (( packed ));
  127. struct hermonprm_scalar_parameter_st {
  128. pseudo_bit_t value_hi[0x00020];
  129. /* -------------- */
  130. pseudo_bit_t value[0x00020];
  131. } __attribute__ (( packed ));
  132. struct hermonprm_event_mask_st {
  133. pseudo_bit_t reserved0[0x00020];
  134. /* -------------- */
  135. pseudo_bit_t completion[0x00001];
  136. pseudo_bit_t reserved1[0x0008];
  137. pseudo_bit_t port_state_change[0x00001];
  138. pseudo_bit_t reserved2[0x00016];
  139. } __attribute__ (( packed ));
  140. struct hermonprm_port_state_change_event_st {
  141. pseudo_bit_t reserved[0x00020];
  142. struct hermonprm_port_state_change_st data;
  143. } __attribute__ (( packed ));
  144. /** Hermon sense port */
  145. struct hermonprm_sense_port_st {
  146. pseudo_bit_t port_type[0x00020];
  147. /* -------------- */
  148. pseudo_bit_t reserved[0x00020];
  149. };
  150. #define HERMON_PORT_TYPE_IB 1
  151. /*
  152. * Wrapper structures for hardware datatypes
  153. *
  154. */
  155. struct MLX_DECLARE_STRUCT ( hermonprm_completion_queue_context );
  156. struct MLX_DECLARE_STRUCT ( hermonprm_completion_queue_entry );
  157. struct MLX_DECLARE_STRUCT ( hermonprm_completion_with_error );
  158. struct MLX_DECLARE_STRUCT ( hermonprm_cq_db_record );
  159. struct MLX_DECLARE_STRUCT ( hermonprm_eqc );
  160. struct MLX_DECLARE_STRUCT ( hermonprm_event_db_register );
  161. struct MLX_DECLARE_STRUCT ( hermonprm_event_mask );
  162. struct MLX_DECLARE_STRUCT ( hermonprm_event_queue_entry );
  163. struct MLX_DECLARE_STRUCT ( hermonprm_hca_command_register );
  164. struct MLX_DECLARE_STRUCT ( hermonprm_init_hca );
  165. struct MLX_DECLARE_STRUCT ( hermonprm_init_port );
  166. struct MLX_DECLARE_STRUCT ( hermonprm_mad_ifc );
  167. struct MLX_DECLARE_STRUCT ( hermonprm_mcg_entry );
  168. struct MLX_DECLARE_STRUCT ( hermonprm_mgm_hash );
  169. struct MLX_DECLARE_STRUCT ( hermonprm_mpt );
  170. struct MLX_DECLARE_STRUCT ( hermonprm_mtt );
  171. struct MLX_DECLARE_STRUCT ( hermonprm_port_state_change_event );
  172. struct MLX_DECLARE_STRUCT ( hermonprm_qp_db_record );
  173. struct MLX_DECLARE_STRUCT ( hermonprm_qp_ee_state_transitions );
  174. struct MLX_DECLARE_STRUCT ( hermonprm_query_dev_cap );
  175. struct MLX_DECLARE_STRUCT ( hermonprm_query_fw );
  176. struct MLX_DECLARE_STRUCT ( hermonprm_queue_pair_ee_context_entry );
  177. struct MLX_DECLARE_STRUCT ( hermonprm_scalar_parameter );
  178. struct MLX_DECLARE_STRUCT ( hermonprm_sense_port );
  179. struct MLX_DECLARE_STRUCT ( hermonprm_send_db_register );
  180. struct MLX_DECLARE_STRUCT ( hermonprm_ud_address_vector );
  181. struct MLX_DECLARE_STRUCT ( hermonprm_virtual_physical_mapping );
  182. struct MLX_DECLARE_STRUCT ( hermonprm_wqe_segment_ctrl_mlx );
  183. struct MLX_DECLARE_STRUCT ( hermonprm_wqe_segment_ctrl_send );
  184. struct MLX_DECLARE_STRUCT ( hermonprm_wqe_segment_data_ptr );
  185. struct MLX_DECLARE_STRUCT ( hermonprm_wqe_segment_ud );
  186. /*
  187. * Composite hardware datatypes
  188. *
  189. */
  190. struct hermonprm_write_mtt {
  191. struct hermonprm_scalar_parameter mtt_base_addr;
  192. struct hermonprm_scalar_parameter reserved;
  193. struct hermonprm_mtt mtt;
  194. } __attribute__ (( packed ));
  195. #define HERMON_MAX_GATHER 2
  196. struct hermonprm_ud_send_wqe {
  197. struct hermonprm_wqe_segment_ctrl_send ctrl;
  198. struct hermonprm_wqe_segment_ud ud;
  199. struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER];
  200. } __attribute__ (( packed ));
  201. struct hermonprm_mlx_send_wqe {
  202. struct hermonprm_wqe_segment_ctrl_mlx ctrl;
  203. struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER];
  204. uint8_t headers[IB_MAX_HEADER_SIZE];
  205. } __attribute__ (( packed ));
  206. struct hermonprm_rc_send_wqe {
  207. struct hermonprm_wqe_segment_ctrl_send ctrl;
  208. struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_GATHER];
  209. } __attribute__ (( packed ));
  210. #define HERMON_MAX_SCATTER 1
  211. struct hermonprm_recv_wqe {
  212. struct hermonprm_wqe_segment_data_ptr data[HERMON_MAX_SCATTER];
  213. } __attribute__ (( packed ));
  214. union hermonprm_completion_entry {
  215. struct hermonprm_completion_queue_entry normal;
  216. struct hermonprm_completion_with_error error;
  217. } __attribute__ (( packed ));
  218. union hermonprm_event_entry {
  219. struct hermonprm_event_queue_entry generic;
  220. struct hermonprm_port_state_change_event port_state_change;
  221. } __attribute__ (( packed ));
  222. union hermonprm_doorbell_register {
  223. struct hermonprm_send_db_register send;
  224. struct hermonprm_event_db_register event;
  225. uint32_t dword[1];
  226. } __attribute__ (( packed ));
  227. union hermonprm_mad {
  228. struct hermonprm_mad_ifc ifc;
  229. union ib_mad mad;
  230. } __attribute__ (( packed ));
  231. /*
  232. * gPXE-specific definitions
  233. *
  234. */
  235. /** Hermon device capabilitiess */
  236. struct hermon_dev_cap {
  237. /** CMPT entry size */
  238. size_t cmpt_entry_size;
  239. /** Number of reserved QPs */
  240. unsigned int reserved_qps;
  241. /** QP context entry size */
  242. size_t qpc_entry_size;
  243. /** Alternate path context entry size */
  244. size_t altc_entry_size;
  245. /** Auxiliary context entry size */
  246. size_t auxc_entry_size;
  247. /** Number of reserved SRQs */
  248. unsigned int reserved_srqs;
  249. /** SRQ context entry size */
  250. size_t srqc_entry_size;
  251. /** Number of reserved CQs */
  252. unsigned int reserved_cqs;
  253. /** CQ context entry size */
  254. size_t cqc_entry_size;
  255. /** Number of reserved EQs */
  256. unsigned int reserved_eqs;
  257. /** EQ context entry size */
  258. size_t eqc_entry_size;
  259. /** Number of reserved MTTs */
  260. unsigned int reserved_mtts;
  261. /** MTT entry size */
  262. size_t mtt_entry_size;
  263. /** Number of reserved MRWs */
  264. unsigned int reserved_mrws;
  265. /** DMPT entry size */
  266. size_t dmpt_entry_size;
  267. /** Number of reserved UARs */
  268. unsigned int reserved_uars;
  269. /** Number of ports */
  270. unsigned int num_ports;
  271. /** Dual-port different protocol */
  272. int dpdp;
  273. };
  274. /** Number of cMPT entries of each type */
  275. #define HERMON_CMPT_MAX_ENTRIES ( 1 << 24 )
  276. /** Hermon ICM memory map entry */
  277. struct hermon_icm_map {
  278. /** Offset (virtual address within ICM) */
  279. uint64_t offset;
  280. /** Length */
  281. size_t len;
  282. };
  283. /** Discontiguous regions within Hermon ICM */
  284. enum hermon_icm_map_regions {
  285. HERMON_ICM_QP_CMPT = 0,
  286. HERMON_ICM_SRQ_CMPT,
  287. HERMON_ICM_CQ_CMPT,
  288. HERMON_ICM_EQ_CMPT,
  289. HERMON_ICM_OTHER,
  290. HERMON_ICM_NUM_REGIONS
  291. };
  292. /** UAR page for doorbell accesses
  293. *
  294. * Pages 0-127 are reserved for event queue doorbells only, so we use
  295. * page 128.
  296. */
  297. #define HERMON_UAR_NON_EQ_PAGE 128
  298. /** Maximum number of allocatable MTT entries
  299. *
  300. * This is a policy decision, not a device limit.
  301. */
  302. #define HERMON_MAX_MTTS 64
  303. /** A Hermon MTT descriptor */
  304. struct hermon_mtt {
  305. /** MTT offset */
  306. unsigned int mtt_offset;
  307. /** Number of pages */
  308. unsigned int num_pages;
  309. /** MTT base address */
  310. unsigned int mtt_base_addr;
  311. /** Offset within page */
  312. unsigned int page_offset;
  313. };
  314. /** Alignment of Hermon send work queue entries */
  315. #define HERMON_SEND_WQE_ALIGN 128
  316. /** A Hermon send work queue entry */
  317. union hermon_send_wqe {
  318. struct hermonprm_wqe_segment_ctrl_send ctrl;
  319. struct hermonprm_ud_send_wqe ud;
  320. struct hermonprm_mlx_send_wqe mlx;
  321. struct hermonprm_rc_send_wqe rc;
  322. uint8_t force_align[HERMON_SEND_WQE_ALIGN];
  323. } __attribute__ (( packed ));
  324. /** A Hermon send work queue */
  325. struct hermon_send_work_queue {
  326. /** Number of work queue entries, including headroom
  327. *
  328. * Hermon requires us to leave unused space within the send
  329. * WQ, so we create a send WQ with more entries than are
  330. * requested in the create_qp() call.
  331. */
  332. unsigned int num_wqes;
  333. /** Work queue entries */
  334. union hermon_send_wqe *wqe;
  335. /** Size of work queue */
  336. size_t wqe_size;
  337. /** Doorbell register */
  338. void *doorbell;
  339. };
  340. /** Alignment of Hermon receive work queue entries */
  341. #define HERMON_RECV_WQE_ALIGN 16
  342. /** A Hermon receive work queue entry */
  343. union hermon_recv_wqe {
  344. struct hermonprm_recv_wqe recv;
  345. uint8_t force_align[HERMON_RECV_WQE_ALIGN];
  346. } __attribute__ (( packed ));
  347. /** A Hermon receive work queue */
  348. struct hermon_recv_work_queue {
  349. /** Work queue entries */
  350. union hermon_recv_wqe *wqe;
  351. /** Size of work queue */
  352. size_t wqe_size;
  353. /** Doorbell */
  354. struct hermonprm_qp_db_record doorbell __attribute__ (( aligned (4) ));
  355. };
  356. /** Number of special queue pairs */
  357. #define HERMON_NUM_SPECIAL_QPS 8
  358. /** Number of queue pairs reserved for the "special QP" block
  359. *
  360. * The special QPs must be within a contiguous block aligned on its
  361. * own size.
  362. */
  363. #define HERMON_RSVD_SPECIAL_QPS ( ( HERMON_NUM_SPECIAL_QPS << 1 ) - 1 )
  364. /** Maximum number of allocatable queue pairs
  365. *
  366. * This is a policy decision, not a device limit.
  367. */
  368. #define HERMON_MAX_QPS 8
  369. /** Queue pair number randomisation mask */
  370. #define HERMON_QPN_RANDOM_MASK 0xfff000
  371. /** Hermon queue pair state */
  372. enum hermon_queue_pair_state {
  373. HERMON_QP_ST_RST = 0,
  374. HERMON_QP_ST_INIT,
  375. HERMON_QP_ST_RTR,
  376. HERMON_QP_ST_RTS,
  377. };
  378. /** A Hermon queue pair */
  379. struct hermon_queue_pair {
  380. /** Work queue buffer */
  381. void *wqe;
  382. /** Size of work queue buffer */
  383. size_t wqe_size;
  384. /** MTT descriptor */
  385. struct hermon_mtt mtt;
  386. /** Send work queue */
  387. struct hermon_send_work_queue send;
  388. /** Receive work queue */
  389. struct hermon_recv_work_queue recv;
  390. /** Queue state */
  391. enum hermon_queue_pair_state state;
  392. };
  393. /** Maximum number of allocatable completion queues
  394. *
  395. * This is a policy decision, not a device limit.
  396. */
  397. #define HERMON_MAX_CQS 8
  398. /** A Hermon completion queue */
  399. struct hermon_completion_queue {
  400. /** Completion queue entries */
  401. union hermonprm_completion_entry *cqe;
  402. /** Size of completion queue */
  403. size_t cqe_size;
  404. /** MTT descriptor */
  405. struct hermon_mtt mtt;
  406. /** Doorbell */
  407. struct hermonprm_cq_db_record doorbell __attribute__ (( aligned (8) ));
  408. };
  409. /** Maximum number of allocatable event queues
  410. *
  411. * This is a policy decision, not a device limit.
  412. */
  413. #define HERMON_MAX_EQS 8
  414. /** A Hermon event queue */
  415. struct hermon_event_queue {
  416. /** Event queue entries */
  417. union hermonprm_event_entry *eqe;
  418. /** Size of event queue */
  419. size_t eqe_size;
  420. /** MTT descriptor */
  421. struct hermon_mtt mtt;
  422. /** Event queue number */
  423. unsigned long eqn;
  424. /** Next event queue entry index */
  425. unsigned long next_idx;
  426. /** Doorbell register */
  427. void *doorbell;
  428. };
  429. /** Number of event queue entries
  430. *
  431. * This is a policy decision.
  432. */
  433. #define HERMON_NUM_EQES 4
  434. /** A Hermon resource bitmask */
  435. typedef uint32_t hermon_bitmask_t;
  436. /** Size of a hermon resource bitmask */
  437. #define HERMON_BITMASK_SIZE(max_entries) \
  438. ( ( (max_entries) + ( 8 * sizeof ( hermon_bitmask_t ) ) - 1 ) / \
  439. ( 8 * sizeof ( hermon_bitmask_t ) ) )
  440. /** A Hermon device */
  441. struct hermon {
  442. /** PCI configuration registers */
  443. void *config;
  444. /** PCI user Access Region */
  445. void *uar;
  446. /** Command toggle */
  447. unsigned int toggle;
  448. /** Command input mailbox */
  449. void *mailbox_in;
  450. /** Command output mailbox */
  451. void *mailbox_out;
  452. /** Firmware area in external memory */
  453. userptr_t firmware_area;
  454. /** ICM map */
  455. struct hermon_icm_map icm_map[HERMON_ICM_NUM_REGIONS];
  456. /** ICM area */
  457. userptr_t icm;
  458. /** Event queue */
  459. struct hermon_event_queue eq;
  460. /** Unrestricted LKey
  461. *
  462. * Used to get unrestricted memory access.
  463. */
  464. unsigned long lkey;
  465. /** Completion queue in-use bitmask */
  466. hermon_bitmask_t cq_inuse[ HERMON_BITMASK_SIZE ( HERMON_MAX_CQS ) ];
  467. /** Queue pair in-use bitmask */
  468. hermon_bitmask_t qp_inuse[ HERMON_BITMASK_SIZE ( HERMON_MAX_QPS ) ];
  469. /** MTT entry in-use bitmask */
  470. hermon_bitmask_t mtt_inuse[ HERMON_BITMASK_SIZE ( HERMON_MAX_MTTS ) ];
  471. /** Device capabilities */
  472. struct hermon_dev_cap cap;
  473. /** Special QPN base */
  474. unsigned long special_qpn_base;
  475. /** QPN base */
  476. unsigned long qpn_base;
  477. /** Infiniband devices */
  478. struct ib_device *ibdev[HERMON_MAX_PORTS];
  479. };
  480. /** Global protection domain */
  481. #define HERMON_GLOBAL_PD 0x123456
  482. /** Memory key prefix */
  483. #define HERMON_MKEY_PREFIX 0x77000000UL
  484. /*
  485. * HCA commands
  486. *
  487. */
  488. #define HERMON_HCR_BASE 0x80680
  489. #define HERMON_HCR_REG(x) ( HERMON_HCR_BASE + 4 * (x) )
  490. #define HERMON_HCR_MAX_WAIT_MS 2000
  491. #define HERMON_MBOX_ALIGN 4096
  492. #define HERMON_MBOX_SIZE 512
  493. /* HCA command is split into
  494. *
  495. * bits 11:0 Opcode
  496. * bit 12 Input uses mailbox
  497. * bit 13 Output uses mailbox
  498. * bits 22:14 Input parameter length (in dwords)
  499. * bits 31:23 Output parameter length (in dwords)
  500. *
  501. * Encoding the information in this way allows us to cut out several
  502. * parameters to the hermon_command() call.
  503. */
  504. #define HERMON_HCR_IN_MBOX 0x00001000UL
  505. #define HERMON_HCR_OUT_MBOX 0x00002000UL
  506. #define HERMON_HCR_OPCODE( _command ) ( (_command) & 0xfff )
  507. #define HERMON_HCR_IN_LEN( _command ) ( ( (_command) >> 12 ) & 0x7fc )
  508. #define HERMON_HCR_OUT_LEN( _command ) ( ( (_command) >> 21 ) & 0x7fc )
  509. /** Build HCR command from component parts */
  510. #define HERMON_HCR_INOUT_CMD( _opcode, _in_mbox, _in_len, \
  511. _out_mbox, _out_len ) \
  512. ( (_opcode) | \
  513. ( (_in_mbox) ? HERMON_HCR_IN_MBOX : 0 ) | \
  514. ( ( (_in_len) / 4 ) << 14 ) | \
  515. ( (_out_mbox) ? HERMON_HCR_OUT_MBOX : 0 ) | \
  516. ( ( (_out_len) / 4 ) << 23 ) )
  517. #define HERMON_HCR_IN_CMD( _opcode, _in_mbox, _in_len ) \
  518. HERMON_HCR_INOUT_CMD ( _opcode, _in_mbox, _in_len, 0, 0 )
  519. #define HERMON_HCR_OUT_CMD( _opcode, _out_mbox, _out_len ) \
  520. HERMON_HCR_INOUT_CMD ( _opcode, 0, 0, _out_mbox, _out_len )
  521. #define HERMON_HCR_VOID_CMD( _opcode ) \
  522. HERMON_HCR_INOUT_CMD ( _opcode, 0, 0, 0, 0 )
  523. #endif /* _HERMON_H */