mlx4.h 29 KB

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