mlx4.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. /*
  2. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
  3. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
  4. * Copyright (c) 2005, 2006, 2007 Cisco Systems. All rights reserved.
  5. * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved.
  6. * Copyright (c) 2004 Voltaire, Inc. All rights reserved.
  7. *
  8. * This software is available to you under a choice of one of two
  9. * licenses. You may choose to be licensed under the terms of the GNU
  10. * General Public License (GPL) Version 2, available from the file
  11. * COPYING in the main directory of this source tree, or the
  12. * OpenIB.org BSD license below:
  13. *
  14. * Redistribution and use in source and binary forms, with or
  15. * without modification, are permitted provided that the following
  16. * conditions are met:
  17. *
  18. * - Redistributions of source code must retain the above
  19. * copyright notice, this list of conditions and the following
  20. * disclaimer.
  21. *
  22. * - Redistributions in binary form must reproduce the above
  23. * copyright notice, this list of conditions and the following
  24. * disclaimer in the documentation and/or other materials
  25. * provided with the distribution.
  26. *
  27. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  28. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  29. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  30. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
  31. * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
  32. * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  33. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  34. * SOFTWARE.
  35. */
  36. #ifndef MLX4_H
  37. #define MLX4_H
  38. #include <linux/mutex.h>
  39. #include <linux/radix-tree.h>
  40. #include <linux/timer.h>
  41. #include <linux/semaphore.h>
  42. #include <linux/workqueue.h>
  43. #include <linux/mlx4/device.h>
  44. #include <linux/mlx4/driver.h>
  45. #include <linux/mlx4/doorbell.h>
  46. #include <linux/mlx4/cmd.h>
  47. #define DRV_NAME "mlx4_core"
  48. #define PFX DRV_NAME ": "
  49. #define DRV_VERSION "1.1"
  50. #define DRV_RELDATE "Dec, 2011"
  51. #define MLX4_NUM_UP 8
  52. #define MLX4_NUM_TC 8
  53. #define MLX4_RATELIMIT_UNITS 3 /* 100 Mbps */
  54. #define MLX4_RATELIMIT_DEFAULT 0xffff
  55. struct mlx4_set_port_prio2tc_context {
  56. u8 prio2tc[4];
  57. };
  58. struct mlx4_port_scheduler_tc_cfg_be {
  59. __be16 pg;
  60. __be16 bw_precentage;
  61. __be16 max_bw_units; /* 3-100Mbps, 4-1Gbps, other values - reserved */
  62. __be16 max_bw_value;
  63. };
  64. struct mlx4_set_port_scheduler_context {
  65. struct mlx4_port_scheduler_tc_cfg_be tc[MLX4_NUM_TC];
  66. };
  67. enum {
  68. MLX4_HCR_BASE = 0x80680,
  69. MLX4_HCR_SIZE = 0x0001c,
  70. MLX4_CLR_INT_SIZE = 0x00008,
  71. MLX4_SLAVE_COMM_BASE = 0x0,
  72. MLX4_COMM_PAGESIZE = 0x1000
  73. };
  74. enum {
  75. MLX4_MAX_MGM_ENTRY_SIZE = 0x1000,
  76. MLX4_MAX_QP_PER_MGM = 4 * (MLX4_MAX_MGM_ENTRY_SIZE / 16 - 2),
  77. MLX4_MTT_ENTRY_PER_SEG = 8,
  78. };
  79. enum {
  80. MLX4_NUM_PDS = 1 << 15
  81. };
  82. enum {
  83. MLX4_CMPT_TYPE_QP = 0,
  84. MLX4_CMPT_TYPE_SRQ = 1,
  85. MLX4_CMPT_TYPE_CQ = 2,
  86. MLX4_CMPT_TYPE_EQ = 3,
  87. MLX4_CMPT_NUM_TYPE
  88. };
  89. enum {
  90. MLX4_CMPT_SHIFT = 24,
  91. MLX4_NUM_CMPTS = MLX4_CMPT_NUM_TYPE << MLX4_CMPT_SHIFT
  92. };
  93. enum mlx4_mr_state {
  94. MLX4_MR_DISABLED = 0,
  95. MLX4_MR_EN_HW,
  96. MLX4_MR_EN_SW
  97. };
  98. #define MLX4_COMM_TIME 10000
  99. enum {
  100. MLX4_COMM_CMD_RESET,
  101. MLX4_COMM_CMD_VHCR0,
  102. MLX4_COMM_CMD_VHCR1,
  103. MLX4_COMM_CMD_VHCR2,
  104. MLX4_COMM_CMD_VHCR_EN,
  105. MLX4_COMM_CMD_VHCR_POST,
  106. MLX4_COMM_CMD_FLR = 254
  107. };
  108. /*The flag indicates that the slave should delay the RESET cmd*/
  109. #define MLX4_DELAY_RESET_SLAVE 0xbbbbbbb
  110. /*indicates how many retries will be done if we are in the middle of FLR*/
  111. #define NUM_OF_RESET_RETRIES 10
  112. #define SLEEP_TIME_IN_RESET (2 * 1000)
  113. enum mlx4_resource {
  114. RES_QP,
  115. RES_CQ,
  116. RES_SRQ,
  117. RES_XRCD,
  118. RES_MPT,
  119. RES_MTT,
  120. RES_MAC,
  121. RES_VLAN,
  122. RES_EQ,
  123. RES_COUNTER,
  124. MLX4_NUM_OF_RESOURCE_TYPE
  125. };
  126. enum mlx4_alloc_mode {
  127. RES_OP_RESERVE,
  128. RES_OP_RESERVE_AND_MAP,
  129. RES_OP_MAP_ICM,
  130. };
  131. /*
  132. *Virtual HCR structures.
  133. * mlx4_vhcr is the sw representation, in machine endianess
  134. *
  135. * mlx4_vhcr_cmd is the formalized structure, the one that is passed
  136. * to FW to go through communication channel.
  137. * It is big endian, and has the same structure as the physical HCR
  138. * used by command interface
  139. */
  140. struct mlx4_vhcr {
  141. u64 in_param;
  142. u64 out_param;
  143. u32 in_modifier;
  144. u32 errno;
  145. u16 op;
  146. u16 token;
  147. u8 op_modifier;
  148. u8 e_bit;
  149. };
  150. struct mlx4_vhcr_cmd {
  151. __be64 in_param;
  152. __be32 in_modifier;
  153. __be64 out_param;
  154. __be16 token;
  155. u16 reserved;
  156. u8 status;
  157. u8 flags;
  158. __be16 opcode;
  159. };
  160. struct mlx4_cmd_info {
  161. u16 opcode;
  162. bool has_inbox;
  163. bool has_outbox;
  164. bool out_is_imm;
  165. bool encode_slave_id;
  166. int (*verify)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr,
  167. struct mlx4_cmd_mailbox *inbox);
  168. int (*wrapper)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr,
  169. struct mlx4_cmd_mailbox *inbox,
  170. struct mlx4_cmd_mailbox *outbox,
  171. struct mlx4_cmd_info *cmd);
  172. };
  173. #ifdef CONFIG_MLX4_DEBUG
  174. extern int mlx4_debug_level;
  175. #else /* CONFIG_MLX4_DEBUG */
  176. #define mlx4_debug_level (0)
  177. #endif /* CONFIG_MLX4_DEBUG */
  178. #define mlx4_dbg(mdev, format, arg...) \
  179. do { \
  180. if (mlx4_debug_level) \
  181. dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ##arg); \
  182. } while (0)
  183. #define mlx4_err(mdev, format, arg...) \
  184. dev_err(&mdev->pdev->dev, format, ##arg)
  185. #define mlx4_info(mdev, format, arg...) \
  186. dev_info(&mdev->pdev->dev, format, ##arg)
  187. #define mlx4_warn(mdev, format, arg...) \
  188. dev_warn(&mdev->pdev->dev, format, ##arg)
  189. extern int mlx4_log_num_mgm_entry_size;
  190. extern int log_mtts_per_seg;
  191. #define MLX4_MAX_NUM_SLAVES (MLX4_MAX_NUM_PF + MLX4_MAX_NUM_VF)
  192. #define ALL_SLAVES 0xff
  193. struct mlx4_bitmap {
  194. u32 last;
  195. u32 top;
  196. u32 max;
  197. u32 reserved_top;
  198. u32 mask;
  199. u32 avail;
  200. spinlock_t lock;
  201. unsigned long *table;
  202. };
  203. struct mlx4_buddy {
  204. unsigned long **bits;
  205. unsigned int *num_free;
  206. int max_order;
  207. spinlock_t lock;
  208. };
  209. struct mlx4_icm;
  210. struct mlx4_icm_table {
  211. u64 virt;
  212. int num_icm;
  213. int num_obj;
  214. int obj_size;
  215. int lowmem;
  216. int coherent;
  217. struct mutex mutex;
  218. struct mlx4_icm **icm;
  219. };
  220. /*
  221. * Must be packed because mtt_seg is 64 bits but only aligned to 32 bits.
  222. */
  223. struct mlx4_mpt_entry {
  224. __be32 flags;
  225. __be32 qpn;
  226. __be32 key;
  227. __be32 pd_flags;
  228. __be64 start;
  229. __be64 length;
  230. __be32 lkey;
  231. __be32 win_cnt;
  232. u8 reserved1[3];
  233. u8 mtt_rep;
  234. __be64 mtt_addr;
  235. __be32 mtt_sz;
  236. __be32 entity_size;
  237. __be32 first_byte_offset;
  238. } __packed;
  239. /*
  240. * Must be packed because start is 64 bits but only aligned to 32 bits.
  241. */
  242. struct mlx4_eq_context {
  243. __be32 flags;
  244. u16 reserved1[3];
  245. __be16 page_offset;
  246. u8 log_eq_size;
  247. u8 reserved2[4];
  248. u8 eq_period;
  249. u8 reserved3;
  250. u8 eq_max_count;
  251. u8 reserved4[3];
  252. u8 intr;
  253. u8 log_page_size;
  254. u8 reserved5[2];
  255. u8 mtt_base_addr_h;
  256. __be32 mtt_base_addr_l;
  257. u32 reserved6[2];
  258. __be32 consumer_index;
  259. __be32 producer_index;
  260. u32 reserved7[4];
  261. };
  262. struct mlx4_cq_context {
  263. __be32 flags;
  264. u16 reserved1[3];
  265. __be16 page_offset;
  266. __be32 logsize_usrpage;
  267. __be16 cq_period;
  268. __be16 cq_max_count;
  269. u8 reserved2[3];
  270. u8 comp_eqn;
  271. u8 log_page_size;
  272. u8 reserved3[2];
  273. u8 mtt_base_addr_h;
  274. __be32 mtt_base_addr_l;
  275. __be32 last_notified_index;
  276. __be32 solicit_producer_index;
  277. __be32 consumer_index;
  278. __be32 producer_index;
  279. u32 reserved4[2];
  280. __be64 db_rec_addr;
  281. };
  282. struct mlx4_srq_context {
  283. __be32 state_logsize_srqn;
  284. u8 logstride;
  285. u8 reserved1;
  286. __be16 xrcd;
  287. __be32 pg_offset_cqn;
  288. u32 reserved2;
  289. u8 log_page_size;
  290. u8 reserved3[2];
  291. u8 mtt_base_addr_h;
  292. __be32 mtt_base_addr_l;
  293. __be32 pd;
  294. __be16 limit_watermark;
  295. __be16 wqe_cnt;
  296. u16 reserved4;
  297. __be16 wqe_counter;
  298. u32 reserved5;
  299. __be64 db_rec_addr;
  300. };
  301. struct mlx4_eqe {
  302. u8 reserved1;
  303. u8 type;
  304. u8 reserved2;
  305. u8 subtype;
  306. union {
  307. u32 raw[6];
  308. struct {
  309. __be32 cqn;
  310. } __packed comp;
  311. struct {
  312. u16 reserved1;
  313. __be16 token;
  314. u32 reserved2;
  315. u8 reserved3[3];
  316. u8 status;
  317. __be64 out_param;
  318. } __packed cmd;
  319. struct {
  320. __be32 qpn;
  321. } __packed qp;
  322. struct {
  323. __be32 srqn;
  324. } __packed srq;
  325. struct {
  326. __be32 cqn;
  327. u32 reserved1;
  328. u8 reserved2[3];
  329. u8 syndrome;
  330. } __packed cq_err;
  331. struct {
  332. u32 reserved1[2];
  333. __be32 port;
  334. } __packed port_change;
  335. struct {
  336. #define COMM_CHANNEL_BIT_ARRAY_SIZE 4
  337. u32 reserved;
  338. u32 bit_vec[COMM_CHANNEL_BIT_ARRAY_SIZE];
  339. } __packed comm_channel_arm;
  340. struct {
  341. u8 port;
  342. u8 reserved[3];
  343. __be64 mac;
  344. } __packed mac_update;
  345. struct {
  346. u8 port;
  347. } __packed sw_event;
  348. struct {
  349. __be32 slave_id;
  350. } __packed flr_event;
  351. struct {
  352. __be16 current_temperature;
  353. __be16 warning_threshold;
  354. } __packed warming;
  355. } event;
  356. u8 slave_id;
  357. u8 reserved3[2];
  358. u8 owner;
  359. } __packed;
  360. struct mlx4_eq {
  361. struct mlx4_dev *dev;
  362. void __iomem *doorbell;
  363. int eqn;
  364. u32 cons_index;
  365. u16 irq;
  366. u16 have_irq;
  367. int nent;
  368. struct mlx4_buf_list *page_list;
  369. struct mlx4_mtt mtt;
  370. };
  371. struct mlx4_slave_eqe {
  372. u8 type;
  373. u8 port;
  374. u32 param;
  375. };
  376. struct mlx4_slave_event_eq_info {
  377. int eqn;
  378. u16 token;
  379. };
  380. struct mlx4_profile {
  381. int num_qp;
  382. int rdmarc_per_qp;
  383. int num_srq;
  384. int num_cq;
  385. int num_mcg;
  386. int num_mpt;
  387. unsigned num_mtt;
  388. };
  389. struct mlx4_fw {
  390. u64 clr_int_base;
  391. u64 catas_offset;
  392. u64 comm_base;
  393. struct mlx4_icm *fw_icm;
  394. struct mlx4_icm *aux_icm;
  395. u32 catas_size;
  396. u16 fw_pages;
  397. u8 clr_int_bar;
  398. u8 catas_bar;
  399. u8 comm_bar;
  400. };
  401. struct mlx4_comm {
  402. u32 slave_write;
  403. u32 slave_read;
  404. };
  405. enum {
  406. MLX4_MCAST_CONFIG = 0,
  407. MLX4_MCAST_DISABLE = 1,
  408. MLX4_MCAST_ENABLE = 2,
  409. };
  410. #define VLAN_FLTR_SIZE 128
  411. struct mlx4_vlan_fltr {
  412. __be32 entry[VLAN_FLTR_SIZE];
  413. };
  414. struct mlx4_mcast_entry {
  415. struct list_head list;
  416. u64 addr;
  417. };
  418. struct mlx4_promisc_qp {
  419. struct list_head list;
  420. u32 qpn;
  421. };
  422. struct mlx4_steer_index {
  423. struct list_head list;
  424. unsigned int index;
  425. struct list_head duplicates;
  426. };
  427. #define MLX4_EVENT_TYPES_NUM 64
  428. struct mlx4_slave_state {
  429. u8 comm_toggle;
  430. u8 last_cmd;
  431. u8 init_port_mask;
  432. bool active;
  433. u8 function;
  434. dma_addr_t vhcr_dma;
  435. u16 mtu[MLX4_MAX_PORTS + 1];
  436. __be32 ib_cap_mask[MLX4_MAX_PORTS + 1];
  437. struct mlx4_slave_eqe eq[MLX4_MFUNC_MAX_EQES];
  438. struct list_head mcast_filters[MLX4_MAX_PORTS + 1];
  439. struct mlx4_vlan_fltr *vlan_filter[MLX4_MAX_PORTS + 1];
  440. /* event type to eq number lookup */
  441. struct mlx4_slave_event_eq_info event_eq[MLX4_EVENT_TYPES_NUM];
  442. u16 eq_pi;
  443. u16 eq_ci;
  444. spinlock_t lock;
  445. /*initialized via the kzalloc*/
  446. u8 is_slave_going_down;
  447. u32 cookie;
  448. };
  449. struct slave_list {
  450. struct mutex mutex;
  451. struct list_head res_list[MLX4_NUM_OF_RESOURCE_TYPE];
  452. };
  453. struct mlx4_resource_tracker {
  454. spinlock_t lock;
  455. /* tree for each resources */
  456. struct radix_tree_root res_tree[MLX4_NUM_OF_RESOURCE_TYPE];
  457. /* num_of_slave's lists, one per slave */
  458. struct slave_list *slave_list;
  459. };
  460. #define SLAVE_EVENT_EQ_SIZE 128
  461. struct mlx4_slave_event_eq {
  462. u32 eqn;
  463. u32 cons;
  464. u32 prod;
  465. struct mlx4_eqe event_eqe[SLAVE_EVENT_EQ_SIZE];
  466. };
  467. struct mlx4_master_qp0_state {
  468. int proxy_qp0_active;
  469. int qp0_active;
  470. int port_active;
  471. };
  472. struct mlx4_mfunc_master_ctx {
  473. struct mlx4_slave_state *slave_state;
  474. struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1];
  475. int init_port_ref[MLX4_MAX_PORTS + 1];
  476. u16 max_mtu[MLX4_MAX_PORTS + 1];
  477. int disable_mcast_ref[MLX4_MAX_PORTS + 1];
  478. struct mlx4_resource_tracker res_tracker;
  479. struct workqueue_struct *comm_wq;
  480. struct work_struct comm_work;
  481. struct work_struct slave_event_work;
  482. struct work_struct slave_flr_event_work;
  483. spinlock_t slave_state_lock;
  484. __be32 comm_arm_bit_vector[4];
  485. struct mlx4_eqe cmd_eqe;
  486. struct mlx4_slave_event_eq slave_eq;
  487. struct mutex gen_eqe_mutex[MLX4_MFUNC_MAX];
  488. };
  489. struct mlx4_mfunc {
  490. struct mlx4_comm __iomem *comm;
  491. struct mlx4_vhcr_cmd *vhcr;
  492. dma_addr_t vhcr_dma;
  493. struct mlx4_mfunc_master_ctx master;
  494. };
  495. struct mlx4_cmd {
  496. struct pci_pool *pool;
  497. void __iomem *hcr;
  498. struct mutex hcr_mutex;
  499. struct semaphore poll_sem;
  500. struct semaphore event_sem;
  501. struct semaphore slave_sem;
  502. int max_cmds;
  503. spinlock_t context_lock;
  504. int free_head;
  505. struct mlx4_cmd_context *context;
  506. u16 token_mask;
  507. u8 use_events;
  508. u8 toggle;
  509. u8 comm_toggle;
  510. };
  511. struct mlx4_uar_table {
  512. struct mlx4_bitmap bitmap;
  513. };
  514. struct mlx4_mr_table {
  515. struct mlx4_bitmap mpt_bitmap;
  516. struct mlx4_buddy mtt_buddy;
  517. u64 mtt_base;
  518. u64 mpt_base;
  519. struct mlx4_icm_table mtt_table;
  520. struct mlx4_icm_table dmpt_table;
  521. };
  522. struct mlx4_cq_table {
  523. struct mlx4_bitmap bitmap;
  524. spinlock_t lock;
  525. struct radix_tree_root tree;
  526. struct mlx4_icm_table table;
  527. struct mlx4_icm_table cmpt_table;
  528. };
  529. struct mlx4_eq_table {
  530. struct mlx4_bitmap bitmap;
  531. char *irq_names;
  532. void __iomem *clr_int;
  533. void __iomem **uar_map;
  534. u32 clr_mask;
  535. struct mlx4_eq *eq;
  536. struct mlx4_icm_table table;
  537. struct mlx4_icm_table cmpt_table;
  538. int have_irq;
  539. u8 inta_pin;
  540. };
  541. struct mlx4_srq_table {
  542. struct mlx4_bitmap bitmap;
  543. spinlock_t lock;
  544. struct radix_tree_root tree;
  545. struct mlx4_icm_table table;
  546. struct mlx4_icm_table cmpt_table;
  547. };
  548. struct mlx4_qp_table {
  549. struct mlx4_bitmap bitmap;
  550. u32 rdmarc_base;
  551. int rdmarc_shift;
  552. spinlock_t lock;
  553. struct mlx4_icm_table qp_table;
  554. struct mlx4_icm_table auxc_table;
  555. struct mlx4_icm_table altc_table;
  556. struct mlx4_icm_table rdmarc_table;
  557. struct mlx4_icm_table cmpt_table;
  558. };
  559. struct mlx4_mcg_table {
  560. struct mutex mutex;
  561. struct mlx4_bitmap bitmap;
  562. struct mlx4_icm_table table;
  563. };
  564. struct mlx4_catas_err {
  565. u32 __iomem *map;
  566. struct timer_list timer;
  567. struct list_head list;
  568. };
  569. #define MLX4_MAX_MAC_NUM 128
  570. #define MLX4_MAC_TABLE_SIZE (MLX4_MAX_MAC_NUM << 3)
  571. struct mlx4_mac_table {
  572. __be64 entries[MLX4_MAX_MAC_NUM];
  573. int refs[MLX4_MAX_MAC_NUM];
  574. struct mutex mutex;
  575. int total;
  576. int max;
  577. };
  578. #define MLX4_MAX_VLAN_NUM 128
  579. #define MLX4_VLAN_TABLE_SIZE (MLX4_MAX_VLAN_NUM << 2)
  580. struct mlx4_vlan_table {
  581. __be32 entries[MLX4_MAX_VLAN_NUM];
  582. int refs[MLX4_MAX_VLAN_NUM];
  583. struct mutex mutex;
  584. int total;
  585. int max;
  586. };
  587. #define SET_PORT_GEN_ALL_VALID 0x7
  588. #define SET_PORT_PROMISC_SHIFT 31
  589. #define SET_PORT_MC_PROMISC_SHIFT 30
  590. enum {
  591. MCAST_DIRECT_ONLY = 0,
  592. MCAST_DIRECT = 1,
  593. MCAST_DEFAULT = 2
  594. };
  595. struct mlx4_set_port_general_context {
  596. u8 reserved[3];
  597. u8 flags;
  598. u16 reserved2;
  599. __be16 mtu;
  600. u8 pptx;
  601. u8 pfctx;
  602. u16 reserved3;
  603. u8 pprx;
  604. u8 pfcrx;
  605. u16 reserved4;
  606. };
  607. struct mlx4_set_port_rqp_calc_context {
  608. __be32 base_qpn;
  609. u8 rererved;
  610. u8 n_mac;
  611. u8 n_vlan;
  612. u8 n_prio;
  613. u8 reserved2[3];
  614. u8 mac_miss;
  615. u8 intra_no_vlan;
  616. u8 no_vlan;
  617. u8 intra_vlan_miss;
  618. u8 vlan_miss;
  619. u8 reserved3[3];
  620. u8 no_vlan_prio;
  621. __be32 promisc;
  622. __be32 mcast;
  623. };
  624. struct mlx4_mac_entry {
  625. u64 mac;
  626. };
  627. struct mlx4_port_info {
  628. struct mlx4_dev *dev;
  629. int port;
  630. char dev_name[16];
  631. struct device_attribute port_attr;
  632. enum mlx4_port_type tmp_type;
  633. char dev_mtu_name[16];
  634. struct device_attribute port_mtu_attr;
  635. struct mlx4_mac_table mac_table;
  636. struct radix_tree_root mac_tree;
  637. struct mlx4_vlan_table vlan_table;
  638. int base_qpn;
  639. };
  640. struct mlx4_sense {
  641. struct mlx4_dev *dev;
  642. u8 do_sense_port[MLX4_MAX_PORTS + 1];
  643. u8 sense_allowed[MLX4_MAX_PORTS + 1];
  644. struct delayed_work sense_poll;
  645. };
  646. struct mlx4_msix_ctl {
  647. u64 pool_bm;
  648. struct mutex pool_lock;
  649. };
  650. struct mlx4_steer {
  651. struct list_head promisc_qps[MLX4_NUM_STEERS];
  652. struct list_head steer_entries[MLX4_NUM_STEERS];
  653. };
  654. struct mlx4_priv {
  655. struct mlx4_dev dev;
  656. struct list_head dev_list;
  657. struct list_head ctx_list;
  658. spinlock_t ctx_lock;
  659. struct list_head pgdir_list;
  660. struct mutex pgdir_mutex;
  661. struct mlx4_fw fw;
  662. struct mlx4_cmd cmd;
  663. struct mlx4_mfunc mfunc;
  664. struct mlx4_bitmap pd_bitmap;
  665. struct mlx4_bitmap xrcd_bitmap;
  666. struct mlx4_uar_table uar_table;
  667. struct mlx4_mr_table mr_table;
  668. struct mlx4_cq_table cq_table;
  669. struct mlx4_eq_table eq_table;
  670. struct mlx4_srq_table srq_table;
  671. struct mlx4_qp_table qp_table;
  672. struct mlx4_mcg_table mcg_table;
  673. struct mlx4_bitmap counters_bitmap;
  674. struct mlx4_catas_err catas_err;
  675. void __iomem *clr_base;
  676. struct mlx4_uar driver_uar;
  677. void __iomem *kar;
  678. struct mlx4_port_info port[MLX4_MAX_PORTS + 1];
  679. struct mlx4_sense sense;
  680. struct mutex port_mutex;
  681. struct mlx4_msix_ctl msix_ctl;
  682. struct mlx4_steer *steer;
  683. struct list_head bf_list;
  684. struct mutex bf_mutex;
  685. struct io_mapping *bf_mapping;
  686. int reserved_mtts;
  687. };
  688. static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev)
  689. {
  690. return container_of(dev, struct mlx4_priv, dev);
  691. }
  692. #define MLX4_SENSE_RANGE (HZ * 3)
  693. extern struct workqueue_struct *mlx4_wq;
  694. u32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap);
  695. void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj);
  696. u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt, int align);
  697. void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt);
  698. u32 mlx4_bitmap_avail(struct mlx4_bitmap *bitmap);
  699. int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
  700. u32 reserved_bot, u32 resetrved_top);
  701. void mlx4_bitmap_cleanup(struct mlx4_bitmap *bitmap);
  702. int mlx4_reset(struct mlx4_dev *dev);
  703. int mlx4_alloc_eq_table(struct mlx4_dev *dev);
  704. void mlx4_free_eq_table(struct mlx4_dev *dev);
  705. int mlx4_init_pd_table(struct mlx4_dev *dev);
  706. int mlx4_init_xrcd_table(struct mlx4_dev *dev);
  707. int mlx4_init_uar_table(struct mlx4_dev *dev);
  708. int mlx4_init_mr_table(struct mlx4_dev *dev);
  709. int mlx4_init_eq_table(struct mlx4_dev *dev);
  710. int mlx4_init_cq_table(struct mlx4_dev *dev);
  711. int mlx4_init_qp_table(struct mlx4_dev *dev);
  712. int mlx4_init_srq_table(struct mlx4_dev *dev);
  713. int mlx4_init_mcg_table(struct mlx4_dev *dev);
  714. void mlx4_cleanup_pd_table(struct mlx4_dev *dev);
  715. void mlx4_cleanup_xrcd_table(struct mlx4_dev *dev);
  716. void mlx4_cleanup_uar_table(struct mlx4_dev *dev);
  717. void mlx4_cleanup_mr_table(struct mlx4_dev *dev);
  718. void mlx4_cleanup_eq_table(struct mlx4_dev *dev);
  719. void mlx4_cleanup_cq_table(struct mlx4_dev *dev);
  720. void mlx4_cleanup_qp_table(struct mlx4_dev *dev);
  721. void mlx4_cleanup_srq_table(struct mlx4_dev *dev);
  722. void mlx4_cleanup_mcg_table(struct mlx4_dev *dev);
  723. int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn);
  724. void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn);
  725. int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn);
  726. void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn);
  727. int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn);
  728. void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn);
  729. int __mlx4_mr_reserve(struct mlx4_dev *dev);
  730. void __mlx4_mr_release(struct mlx4_dev *dev, u32 index);
  731. int __mlx4_mr_alloc_icm(struct mlx4_dev *dev, u32 index);
  732. void __mlx4_mr_free_icm(struct mlx4_dev *dev, u32 index);
  733. u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order);
  734. void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order);
  735. int mlx4_WRITE_MTT_wrapper(struct mlx4_dev *dev, int slave,
  736. struct mlx4_vhcr *vhcr,
  737. struct mlx4_cmd_mailbox *inbox,
  738. struct mlx4_cmd_mailbox *outbox,
  739. struct mlx4_cmd_info *cmd);
  740. int mlx4_SYNC_TPT_wrapper(struct mlx4_dev *dev, int slave,
  741. struct mlx4_vhcr *vhcr,
  742. struct mlx4_cmd_mailbox *inbox,
  743. struct mlx4_cmd_mailbox *outbox,
  744. struct mlx4_cmd_info *cmd);
  745. int mlx4_SW2HW_MPT_wrapper(struct mlx4_dev *dev, int slave,
  746. struct mlx4_vhcr *vhcr,
  747. struct mlx4_cmd_mailbox *inbox,
  748. struct mlx4_cmd_mailbox *outbox,
  749. struct mlx4_cmd_info *cmd);
  750. int mlx4_HW2SW_MPT_wrapper(struct mlx4_dev *dev, int slave,
  751. struct mlx4_vhcr *vhcr,
  752. struct mlx4_cmd_mailbox *inbox,
  753. struct mlx4_cmd_mailbox *outbox,
  754. struct mlx4_cmd_info *cmd);
  755. int mlx4_QUERY_MPT_wrapper(struct mlx4_dev *dev, int slave,
  756. struct mlx4_vhcr *vhcr,
  757. struct mlx4_cmd_mailbox *inbox,
  758. struct mlx4_cmd_mailbox *outbox,
  759. struct mlx4_cmd_info *cmd);
  760. int mlx4_SW2HW_EQ_wrapper(struct mlx4_dev *dev, int slave,
  761. struct mlx4_vhcr *vhcr,
  762. struct mlx4_cmd_mailbox *inbox,
  763. struct mlx4_cmd_mailbox *outbox,
  764. struct mlx4_cmd_info *cmd);
  765. int mlx4_DMA_wrapper(struct mlx4_dev *dev, int slave,
  766. struct mlx4_vhcr *vhcr,
  767. struct mlx4_cmd_mailbox *inbox,
  768. struct mlx4_cmd_mailbox *outbox,
  769. struct mlx4_cmd_info *cmd);
  770. int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
  771. int *base);
  772. void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
  773. int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  774. void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  775. int __mlx4_replace_mac(struct mlx4_dev *dev, u8 port, int qpn, u64 new_mac);
  776. int __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
  777. int start_index, int npages, u64 *page_list);
  778. void mlx4_start_catas_poll(struct mlx4_dev *dev);
  779. void mlx4_stop_catas_poll(struct mlx4_dev *dev);
  780. void mlx4_catas_init(void);
  781. int mlx4_restart_one(struct pci_dev *pdev);
  782. int mlx4_register_device(struct mlx4_dev *dev);
  783. void mlx4_unregister_device(struct mlx4_dev *dev);
  784. void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type, int port);
  785. struct mlx4_dev_cap;
  786. struct mlx4_init_hca_param;
  787. u64 mlx4_make_profile(struct mlx4_dev *dev,
  788. struct mlx4_profile *request,
  789. struct mlx4_dev_cap *dev_cap,
  790. struct mlx4_init_hca_param *init_hca);
  791. void mlx4_master_comm_channel(struct work_struct *work);
  792. void mlx4_gen_slave_eqe(struct work_struct *work);
  793. void mlx4_master_handle_slave_flr(struct work_struct *work);
  794. int mlx4_ALLOC_RES_wrapper(struct mlx4_dev *dev, int slave,
  795. struct mlx4_vhcr *vhcr,
  796. struct mlx4_cmd_mailbox *inbox,
  797. struct mlx4_cmd_mailbox *outbox,
  798. struct mlx4_cmd_info *cmd);
  799. int mlx4_FREE_RES_wrapper(struct mlx4_dev *dev, int slave,
  800. struct mlx4_vhcr *vhcr,
  801. struct mlx4_cmd_mailbox *inbox,
  802. struct mlx4_cmd_mailbox *outbox,
  803. struct mlx4_cmd_info *cmd);
  804. int mlx4_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave,
  805. struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox,
  806. struct mlx4_cmd_mailbox *outbox,
  807. struct mlx4_cmd_info *cmd);
  808. int mlx4_COMM_INT_wrapper(struct mlx4_dev *dev, int slave,
  809. struct mlx4_vhcr *vhcr,
  810. struct mlx4_cmd_mailbox *inbox,
  811. struct mlx4_cmd_mailbox *outbox,
  812. struct mlx4_cmd_info *cmd);
  813. int mlx4_HW2SW_EQ_wrapper(struct mlx4_dev *dev, int slave,
  814. struct mlx4_vhcr *vhcr,
  815. struct mlx4_cmd_mailbox *inbox,
  816. struct mlx4_cmd_mailbox *outbox,
  817. struct mlx4_cmd_info *cmd);
  818. int mlx4_QUERY_EQ_wrapper(struct mlx4_dev *dev, int slave,
  819. struct mlx4_vhcr *vhcr,
  820. struct mlx4_cmd_mailbox *inbox,
  821. struct mlx4_cmd_mailbox *outbox,
  822. struct mlx4_cmd_info *cmd);
  823. int mlx4_SW2HW_CQ_wrapper(struct mlx4_dev *dev, int slave,
  824. struct mlx4_vhcr *vhcr,
  825. struct mlx4_cmd_mailbox *inbox,
  826. struct mlx4_cmd_mailbox *outbox,
  827. struct mlx4_cmd_info *cmd);
  828. int mlx4_HW2SW_CQ_wrapper(struct mlx4_dev *dev, int slave,
  829. struct mlx4_vhcr *vhcr,
  830. struct mlx4_cmd_mailbox *inbox,
  831. struct mlx4_cmd_mailbox *outbox,
  832. struct mlx4_cmd_info *cmd);
  833. int mlx4_QUERY_CQ_wrapper(struct mlx4_dev *dev, int slave,
  834. struct mlx4_vhcr *vhcr,
  835. struct mlx4_cmd_mailbox *inbox,
  836. struct mlx4_cmd_mailbox *outbox,
  837. struct mlx4_cmd_info *cmd);
  838. int mlx4_MODIFY_CQ_wrapper(struct mlx4_dev *dev, int slave,
  839. struct mlx4_vhcr *vhcr,
  840. struct mlx4_cmd_mailbox *inbox,
  841. struct mlx4_cmd_mailbox *outbox,
  842. struct mlx4_cmd_info *cmd);
  843. int mlx4_SW2HW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  844. struct mlx4_vhcr *vhcr,
  845. struct mlx4_cmd_mailbox *inbox,
  846. struct mlx4_cmd_mailbox *outbox,
  847. struct mlx4_cmd_info *cmd);
  848. int mlx4_HW2SW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  849. struct mlx4_vhcr *vhcr,
  850. struct mlx4_cmd_mailbox *inbox,
  851. struct mlx4_cmd_mailbox *outbox,
  852. struct mlx4_cmd_info *cmd);
  853. int mlx4_QUERY_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  854. struct mlx4_vhcr *vhcr,
  855. struct mlx4_cmd_mailbox *inbox,
  856. struct mlx4_cmd_mailbox *outbox,
  857. struct mlx4_cmd_info *cmd);
  858. int mlx4_ARM_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  859. struct mlx4_vhcr *vhcr,
  860. struct mlx4_cmd_mailbox *inbox,
  861. struct mlx4_cmd_mailbox *outbox,
  862. struct mlx4_cmd_info *cmd);
  863. int mlx4_GEN_QP_wrapper(struct mlx4_dev *dev, int slave,
  864. struct mlx4_vhcr *vhcr,
  865. struct mlx4_cmd_mailbox *inbox,
  866. struct mlx4_cmd_mailbox *outbox,
  867. struct mlx4_cmd_info *cmd);
  868. int mlx4_RST2INIT_QP_wrapper(struct mlx4_dev *dev, int slave,
  869. struct mlx4_vhcr *vhcr,
  870. struct mlx4_cmd_mailbox *inbox,
  871. struct mlx4_cmd_mailbox *outbox,
  872. struct mlx4_cmd_info *cmd);
  873. int mlx4_INIT2RTR_QP_wrapper(struct mlx4_dev *dev, int slave,
  874. struct mlx4_vhcr *vhcr,
  875. struct mlx4_cmd_mailbox *inbox,
  876. struct mlx4_cmd_mailbox *outbox,
  877. struct mlx4_cmd_info *cmd);
  878. int mlx4_2RST_QP_wrapper(struct mlx4_dev *dev, int slave,
  879. struct mlx4_vhcr *vhcr,
  880. struct mlx4_cmd_mailbox *inbox,
  881. struct mlx4_cmd_mailbox *outbox,
  882. struct mlx4_cmd_info *cmd);
  883. int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe);
  884. int mlx4_cmd_init(struct mlx4_dev *dev);
  885. void mlx4_cmd_cleanup(struct mlx4_dev *dev);
  886. int mlx4_multi_func_init(struct mlx4_dev *dev);
  887. void mlx4_multi_func_cleanup(struct mlx4_dev *dev);
  888. void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param);
  889. int mlx4_cmd_use_events(struct mlx4_dev *dev);
  890. void mlx4_cmd_use_polling(struct mlx4_dev *dev);
  891. int mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param,
  892. unsigned long timeout);
  893. void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn);
  894. void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type);
  895. void mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type);
  896. void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type);
  897. void mlx4_handle_catas_err(struct mlx4_dev *dev);
  898. int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
  899. enum mlx4_port_type *type);
  900. void mlx4_do_sense_ports(struct mlx4_dev *dev,
  901. enum mlx4_port_type *stype,
  902. enum mlx4_port_type *defaults);
  903. void mlx4_start_sense(struct mlx4_dev *dev);
  904. void mlx4_stop_sense(struct mlx4_dev *dev);
  905. void mlx4_sense_init(struct mlx4_dev *dev);
  906. int mlx4_check_port_params(struct mlx4_dev *dev,
  907. enum mlx4_port_type *port_type);
  908. int mlx4_change_port_types(struct mlx4_dev *dev,
  909. enum mlx4_port_type *port_types);
  910. void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table);
  911. void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
  912. int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port);
  913. /* resource tracker functions*/
  914. int mlx4_get_slave_from_resource_id(struct mlx4_dev *dev,
  915. enum mlx4_resource resource_type,
  916. int resource_id, int *slave);
  917. void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave_id);
  918. int mlx4_init_resource_tracker(struct mlx4_dev *dev);
  919. void mlx4_free_resource_tracker(struct mlx4_dev *dev);
  920. int mlx4_SET_PORT_wrapper(struct mlx4_dev *dev, int slave,
  921. struct mlx4_vhcr *vhcr,
  922. struct mlx4_cmd_mailbox *inbox,
  923. struct mlx4_cmd_mailbox *outbox,
  924. struct mlx4_cmd_info *cmd);
  925. int mlx4_INIT_PORT_wrapper(struct mlx4_dev *dev, int slave,
  926. struct mlx4_vhcr *vhcr,
  927. struct mlx4_cmd_mailbox *inbox,
  928. struct mlx4_cmd_mailbox *outbox,
  929. struct mlx4_cmd_info *cmd);
  930. int mlx4_CLOSE_PORT_wrapper(struct mlx4_dev *dev, int slave,
  931. struct mlx4_vhcr *vhcr,
  932. struct mlx4_cmd_mailbox *inbox,
  933. struct mlx4_cmd_mailbox *outbox,
  934. struct mlx4_cmd_info *cmd);
  935. int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
  936. struct mlx4_vhcr *vhcr,
  937. struct mlx4_cmd_mailbox *inbox,
  938. struct mlx4_cmd_mailbox *outbox,
  939. struct mlx4_cmd_info *cmd);
  940. int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps);
  941. int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
  942. struct mlx4_vhcr *vhcr,
  943. struct mlx4_cmd_mailbox *inbox,
  944. struct mlx4_cmd_mailbox *outbox,
  945. struct mlx4_cmd_info *cmd);
  946. int mlx4_PROMISC_wrapper(struct mlx4_dev *dev, int slave,
  947. struct mlx4_vhcr *vhcr,
  948. struct mlx4_cmd_mailbox *inbox,
  949. struct mlx4_cmd_mailbox *outbox,
  950. struct mlx4_cmd_info *cmd);
  951. int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  952. enum mlx4_protocol prot, enum mlx4_steer_type steer);
  953. int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  954. int block_mcast_loopback, enum mlx4_protocol prot,
  955. enum mlx4_steer_type steer);
  956. int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave,
  957. struct mlx4_vhcr *vhcr,
  958. struct mlx4_cmd_mailbox *inbox,
  959. struct mlx4_cmd_mailbox *outbox,
  960. struct mlx4_cmd_info *cmd);
  961. int mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave,
  962. struct mlx4_vhcr *vhcr,
  963. struct mlx4_cmd_mailbox *inbox,
  964. struct mlx4_cmd_mailbox *outbox,
  965. struct mlx4_cmd_info *cmd);
  966. int mlx4_common_set_vlan_fltr(struct mlx4_dev *dev, int function,
  967. int port, void *buf);
  968. int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave, u32 in_mod,
  969. struct mlx4_cmd_mailbox *outbox);
  970. int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave,
  971. struct mlx4_vhcr *vhcr,
  972. struct mlx4_cmd_mailbox *inbox,
  973. struct mlx4_cmd_mailbox *outbox,
  974. struct mlx4_cmd_info *cmd);
  975. int mlx4_PKEY_TABLE_wrapper(struct mlx4_dev *dev, int slave,
  976. struct mlx4_vhcr *vhcr,
  977. struct mlx4_cmd_mailbox *inbox,
  978. struct mlx4_cmd_mailbox *outbox,
  979. struct mlx4_cmd_info *cmd);
  980. int mlx4_QUERY_IF_STAT_wrapper(struct mlx4_dev *dev, int slave,
  981. struct mlx4_vhcr *vhcr,
  982. struct mlx4_cmd_mailbox *inbox,
  983. struct mlx4_cmd_mailbox *outbox,
  984. struct mlx4_cmd_info *cmd);
  985. int mlx4_get_mgm_entry_size(struct mlx4_dev *dev);
  986. int mlx4_get_qp_per_mgm(struct mlx4_dev *dev);
  987. static inline void set_param_l(u64 *arg, u32 val)
  988. {
  989. *((u32 *)arg) = val;
  990. }
  991. static inline void set_param_h(u64 *arg, u32 val)
  992. {
  993. *arg = (*arg & 0xffffffff) | ((u64) val << 32);
  994. }
  995. static inline u32 get_param_l(u64 *arg)
  996. {
  997. return (u32) (*arg & 0xffffffff);
  998. }
  999. static inline u32 get_param_h(u64 *arg)
  1000. {
  1001. return (u32)(*arg >> 32);
  1002. }
  1003. static inline spinlock_t *mlx4_tlock(struct mlx4_dev *dev)
  1004. {
  1005. return &mlx4_priv(dev)->mfunc.master.res_tracker.lock;
  1006. }
  1007. #define NOT_MASKED_PD_BITS 17
  1008. #endif /* MLX4_H */