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