mlx4.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920
  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 DRV_VERSION "1.0"
  49. #define DRV_RELDATE "July 14, 2011"
  50. enum {
  51. MLX4_HCR_BASE = 0x80680,
  52. MLX4_HCR_SIZE = 0x0001c,
  53. MLX4_CLR_INT_SIZE = 0x00008,
  54. MLX4_SLAVE_COMM_BASE = 0x0,
  55. MLX4_COMM_PAGESIZE = 0x1000
  56. };
  57. enum {
  58. MLX4_MGM_ENTRY_SIZE = 0x100,
  59. MLX4_QP_PER_MGM = 4 * (MLX4_MGM_ENTRY_SIZE / 16 - 2),
  60. MLX4_MTT_ENTRY_PER_SEG = 8
  61. };
  62. enum {
  63. MLX4_NUM_PDS = 1 << 15
  64. };
  65. enum {
  66. MLX4_CMPT_TYPE_QP = 0,
  67. MLX4_CMPT_TYPE_SRQ = 1,
  68. MLX4_CMPT_TYPE_CQ = 2,
  69. MLX4_CMPT_TYPE_EQ = 3,
  70. MLX4_CMPT_NUM_TYPE
  71. };
  72. enum {
  73. MLX4_CMPT_SHIFT = 24,
  74. MLX4_NUM_CMPTS = MLX4_CMPT_NUM_TYPE << MLX4_CMPT_SHIFT
  75. };
  76. enum mlx4_mr_state {
  77. MLX4_MR_DISABLED = 0,
  78. MLX4_MR_EN_HW,
  79. MLX4_MR_EN_SW
  80. };
  81. #define MLX4_COMM_TIME 10000
  82. enum {
  83. MLX4_COMM_CMD_RESET,
  84. MLX4_COMM_CMD_VHCR0,
  85. MLX4_COMM_CMD_VHCR1,
  86. MLX4_COMM_CMD_VHCR2,
  87. MLX4_COMM_CMD_VHCR_EN,
  88. MLX4_COMM_CMD_VHCR_POST,
  89. MLX4_COMM_CMD_FLR = 254
  90. };
  91. /*The flag indicates that the slave should delay the RESET cmd*/
  92. #define MLX4_DELAY_RESET_SLAVE 0xbbbbbbb
  93. /*indicates how many retries will be done if we are in the middle of FLR*/
  94. #define NUM_OF_RESET_RETRIES 10
  95. #define SLEEP_TIME_IN_RESET (2 * 1000)
  96. enum mlx4_resource {
  97. RES_QP,
  98. RES_CQ,
  99. RES_SRQ,
  100. RES_XRCD,
  101. RES_MPT,
  102. RES_MTT,
  103. RES_MAC,
  104. RES_VLAN,
  105. RES_EQ,
  106. RES_COUNTER,
  107. MLX4_NUM_OF_RESOURCE_TYPE
  108. };
  109. enum mlx4_alloc_mode {
  110. RES_OP_RESERVE,
  111. RES_OP_RESERVE_AND_MAP,
  112. RES_OP_MAP_ICM,
  113. };
  114. /*
  115. *Virtual HCR structures.
  116. * mlx4_vhcr is the sw representation, in machine endianess
  117. *
  118. * mlx4_vhcr_cmd is the formalized structure, the one that is passed
  119. * to FW to go through communication channel.
  120. * It is big endian, and has the same structure as the physical HCR
  121. * used by command interface
  122. */
  123. struct mlx4_vhcr {
  124. u64 in_param;
  125. u64 out_param;
  126. u32 in_modifier;
  127. u32 errno;
  128. u16 op;
  129. u16 token;
  130. u8 op_modifier;
  131. u8 e_bit;
  132. };
  133. struct mlx4_vhcr_cmd {
  134. __be64 in_param;
  135. __be32 in_modifier;
  136. __be64 out_param;
  137. __be16 token;
  138. u16 reserved;
  139. u8 status;
  140. u8 flags;
  141. __be16 opcode;
  142. };
  143. struct mlx4_cmd_info {
  144. u16 opcode;
  145. bool has_inbox;
  146. bool has_outbox;
  147. bool out_is_imm;
  148. bool encode_slave_id;
  149. int (*verify)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr,
  150. struct mlx4_cmd_mailbox *inbox);
  151. int (*wrapper)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr,
  152. struct mlx4_cmd_mailbox *inbox,
  153. struct mlx4_cmd_mailbox *outbox,
  154. struct mlx4_cmd_info *cmd);
  155. };
  156. #ifdef CONFIG_MLX4_DEBUG
  157. extern int mlx4_debug_level;
  158. #else /* CONFIG_MLX4_DEBUG */
  159. #define mlx4_debug_level (0)
  160. #endif /* CONFIG_MLX4_DEBUG */
  161. #define mlx4_dbg(mdev, format, arg...) \
  162. do { \
  163. if (mlx4_debug_level) \
  164. dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ##arg); \
  165. } while (0)
  166. #define mlx4_err(mdev, format, arg...) \
  167. dev_err(&mdev->pdev->dev, format, ##arg)
  168. #define mlx4_info(mdev, format, arg...) \
  169. dev_info(&mdev->pdev->dev, format, ##arg)
  170. #define mlx4_warn(mdev, format, arg...) \
  171. dev_warn(&mdev->pdev->dev, format, ##arg)
  172. #define MLX4_MAX_NUM_SLAVES (MLX4_MAX_NUM_PF + MLX4_MAX_NUM_VF)
  173. #define ALL_SLAVES 0xff
  174. struct mlx4_bitmap {
  175. u32 last;
  176. u32 top;
  177. u32 max;
  178. u32 reserved_top;
  179. u32 mask;
  180. u32 avail;
  181. spinlock_t lock;
  182. unsigned long *table;
  183. };
  184. struct mlx4_buddy {
  185. unsigned long **bits;
  186. unsigned int *num_free;
  187. int max_order;
  188. spinlock_t lock;
  189. };
  190. struct mlx4_icm;
  191. struct mlx4_icm_table {
  192. u64 virt;
  193. int num_icm;
  194. int num_obj;
  195. int obj_size;
  196. int lowmem;
  197. int coherent;
  198. struct mutex mutex;
  199. struct mlx4_icm **icm;
  200. };
  201. struct mlx4_eqe {
  202. u8 reserved1;
  203. u8 type;
  204. u8 reserved2;
  205. u8 subtype;
  206. union {
  207. u32 raw[6];
  208. struct {
  209. __be32 cqn;
  210. } __packed comp;
  211. struct {
  212. u16 reserved1;
  213. __be16 token;
  214. u32 reserved2;
  215. u8 reserved3[3];
  216. u8 status;
  217. __be64 out_param;
  218. } __packed cmd;
  219. struct {
  220. __be32 qpn;
  221. } __packed qp;
  222. struct {
  223. __be32 srqn;
  224. } __packed srq;
  225. struct {
  226. __be32 cqn;
  227. u32 reserved1;
  228. u8 reserved2[3];
  229. u8 syndrome;
  230. } __packed cq_err;
  231. struct {
  232. u32 reserved1[2];
  233. __be32 port;
  234. } __packed port_change;
  235. struct {
  236. #define COMM_CHANNEL_BIT_ARRAY_SIZE 4
  237. u32 reserved;
  238. u32 bit_vec[COMM_CHANNEL_BIT_ARRAY_SIZE];
  239. } __packed comm_channel_arm;
  240. struct {
  241. u8 port;
  242. u8 reserved[3];
  243. __be64 mac;
  244. } __packed mac_update;
  245. struct {
  246. u8 port;
  247. } __packed sw_event;
  248. struct {
  249. __be32 slave_id;
  250. } __packed flr_event;
  251. } event;
  252. u8 slave_id;
  253. u8 reserved3[2];
  254. u8 owner;
  255. } __packed;
  256. struct mlx4_eq {
  257. struct mlx4_dev *dev;
  258. void __iomem *doorbell;
  259. int eqn;
  260. u32 cons_index;
  261. u16 irq;
  262. u16 have_irq;
  263. int nent;
  264. struct mlx4_buf_list *page_list;
  265. struct mlx4_mtt mtt;
  266. };
  267. struct mlx4_slave_eqe {
  268. u8 type;
  269. u8 port;
  270. u32 param;
  271. };
  272. struct mlx4_slave_event_eq_info {
  273. u32 eqn;
  274. u16 token;
  275. u64 event_type;
  276. };
  277. struct mlx4_profile {
  278. int num_qp;
  279. int rdmarc_per_qp;
  280. int num_srq;
  281. int num_cq;
  282. int num_mcg;
  283. int num_mpt;
  284. int num_mtt;
  285. };
  286. struct mlx4_fw {
  287. u64 clr_int_base;
  288. u64 catas_offset;
  289. u64 comm_base;
  290. struct mlx4_icm *fw_icm;
  291. struct mlx4_icm *aux_icm;
  292. u32 catas_size;
  293. u16 fw_pages;
  294. u8 clr_int_bar;
  295. u8 catas_bar;
  296. u8 comm_bar;
  297. };
  298. struct mlx4_comm {
  299. u32 slave_write;
  300. u32 slave_read;
  301. };
  302. #define MGM_QPN_MASK 0x00FFFFFF
  303. #define MGM_BLCK_LB_BIT 30
  304. #define VLAN_FLTR_SIZE 128
  305. struct mlx4_vlan_fltr {
  306. __be32 entry[VLAN_FLTR_SIZE];
  307. };
  308. struct mlx4_promisc_qp {
  309. struct list_head list;
  310. u32 qpn;
  311. };
  312. struct mlx4_steer_index {
  313. struct list_head list;
  314. unsigned int index;
  315. struct list_head duplicates;
  316. };
  317. struct mlx4_mgm {
  318. __be32 next_gid_index;
  319. __be32 members_count;
  320. u32 reserved[2];
  321. u8 gid[16];
  322. __be32 qp[MLX4_QP_PER_MGM];
  323. };
  324. struct mlx4_slave_state {
  325. u8 comm_toggle;
  326. u8 last_cmd;
  327. u8 init_port_mask;
  328. bool active;
  329. u8 function;
  330. dma_addr_t vhcr_dma;
  331. u16 mtu[MLX4_MAX_PORTS + 1];
  332. __be32 ib_cap_mask[MLX4_MAX_PORTS + 1];
  333. struct mlx4_slave_eqe eq[MLX4_MFUNC_MAX_EQES];
  334. struct list_head mcast_filters[MLX4_MAX_PORTS + 1];
  335. struct mlx4_vlan_fltr *vlan_filter[MLX4_MAX_PORTS + 1];
  336. struct mlx4_slave_event_eq_info event_eq;
  337. u16 eq_pi;
  338. u16 eq_ci;
  339. spinlock_t lock;
  340. /*initialized via the kzalloc*/
  341. u8 is_slave_going_down;
  342. u32 cookie;
  343. };
  344. struct slave_list {
  345. struct mutex mutex;
  346. struct list_head res_list[MLX4_NUM_OF_RESOURCE_TYPE];
  347. };
  348. struct mlx4_resource_tracker {
  349. spinlock_t lock;
  350. /* tree for each resources */
  351. struct radix_tree_root res_tree[MLX4_NUM_OF_RESOURCE_TYPE];
  352. /* num_of_slave's lists, one per slave */
  353. struct slave_list *slave_list;
  354. };
  355. #define SLAVE_EVENT_EQ_SIZE 128
  356. struct mlx4_slave_event_eq {
  357. u32 eqn;
  358. u32 cons;
  359. u32 prod;
  360. struct mlx4_eqe event_eqe[SLAVE_EVENT_EQ_SIZE];
  361. };
  362. struct mlx4_master_qp0_state {
  363. int proxy_qp0_active;
  364. int qp0_active;
  365. int port_active;
  366. };
  367. struct mlx4_mfunc_master_ctx {
  368. struct mlx4_slave_state *slave_state;
  369. struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1];
  370. int init_port_ref[MLX4_MAX_PORTS + 1];
  371. u16 max_mtu[MLX4_MAX_PORTS + 1];
  372. int disable_mcast_ref[MLX4_MAX_PORTS + 1];
  373. struct mlx4_resource_tracker res_tracker;
  374. struct workqueue_struct *comm_wq;
  375. struct work_struct comm_work;
  376. struct work_struct slave_event_work;
  377. struct work_struct slave_flr_event_work;
  378. spinlock_t slave_state_lock;
  379. __be32 comm_arm_bit_vector[4];
  380. struct mlx4_eqe cmd_eqe;
  381. struct mlx4_slave_event_eq slave_eq;
  382. struct mutex gen_eqe_mutex[MLX4_MFUNC_MAX];
  383. };
  384. struct mlx4_mfunc {
  385. struct mlx4_comm __iomem *comm;
  386. struct mlx4_vhcr_cmd *vhcr;
  387. dma_addr_t vhcr_dma;
  388. struct mlx4_mfunc_master_ctx master;
  389. };
  390. struct mlx4_cmd {
  391. struct pci_pool *pool;
  392. void __iomem *hcr;
  393. struct mutex hcr_mutex;
  394. struct semaphore poll_sem;
  395. struct semaphore event_sem;
  396. struct semaphore slave_sem;
  397. int max_cmds;
  398. spinlock_t context_lock;
  399. int free_head;
  400. struct mlx4_cmd_context *context;
  401. u16 token_mask;
  402. u8 use_events;
  403. u8 toggle;
  404. u8 comm_toggle;
  405. };
  406. struct mlx4_uar_table {
  407. struct mlx4_bitmap bitmap;
  408. };
  409. struct mlx4_mr_table {
  410. struct mlx4_bitmap mpt_bitmap;
  411. struct mlx4_buddy mtt_buddy;
  412. u64 mtt_base;
  413. u64 mpt_base;
  414. struct mlx4_icm_table mtt_table;
  415. struct mlx4_icm_table dmpt_table;
  416. };
  417. struct mlx4_cq_table {
  418. struct mlx4_bitmap bitmap;
  419. spinlock_t lock;
  420. struct radix_tree_root tree;
  421. struct mlx4_icm_table table;
  422. struct mlx4_icm_table cmpt_table;
  423. };
  424. struct mlx4_eq_table {
  425. struct mlx4_bitmap bitmap;
  426. char *irq_names;
  427. void __iomem *clr_int;
  428. void __iomem **uar_map;
  429. u32 clr_mask;
  430. struct mlx4_eq *eq;
  431. struct mlx4_icm_table table;
  432. struct mlx4_icm_table cmpt_table;
  433. int have_irq;
  434. u8 inta_pin;
  435. };
  436. struct mlx4_srq_table {
  437. struct mlx4_bitmap bitmap;
  438. spinlock_t lock;
  439. struct radix_tree_root tree;
  440. struct mlx4_icm_table table;
  441. struct mlx4_icm_table cmpt_table;
  442. };
  443. struct mlx4_qp_table {
  444. struct mlx4_bitmap bitmap;
  445. u32 rdmarc_base;
  446. int rdmarc_shift;
  447. spinlock_t lock;
  448. struct mlx4_icm_table qp_table;
  449. struct mlx4_icm_table auxc_table;
  450. struct mlx4_icm_table altc_table;
  451. struct mlx4_icm_table rdmarc_table;
  452. struct mlx4_icm_table cmpt_table;
  453. };
  454. struct mlx4_mcg_table {
  455. struct mutex mutex;
  456. struct mlx4_bitmap bitmap;
  457. struct mlx4_icm_table table;
  458. };
  459. struct mlx4_catas_err {
  460. u32 __iomem *map;
  461. struct timer_list timer;
  462. struct list_head list;
  463. };
  464. #define MLX4_MAX_MAC_NUM 128
  465. #define MLX4_MAC_TABLE_SIZE (MLX4_MAX_MAC_NUM << 3)
  466. struct mlx4_mac_table {
  467. __be64 entries[MLX4_MAX_MAC_NUM];
  468. int refs[MLX4_MAX_MAC_NUM];
  469. struct mutex mutex;
  470. int total;
  471. int max;
  472. };
  473. #define MLX4_MAX_VLAN_NUM 128
  474. #define MLX4_VLAN_TABLE_SIZE (MLX4_MAX_VLAN_NUM << 2)
  475. struct mlx4_vlan_table {
  476. __be32 entries[MLX4_MAX_VLAN_NUM];
  477. int refs[MLX4_MAX_VLAN_NUM];
  478. struct mutex mutex;
  479. int total;
  480. int max;
  481. };
  482. struct mlx4_mac_entry {
  483. u64 mac;
  484. };
  485. struct mlx4_port_info {
  486. struct mlx4_dev *dev;
  487. int port;
  488. char dev_name[16];
  489. struct device_attribute port_attr;
  490. enum mlx4_port_type tmp_type;
  491. struct mlx4_mac_table mac_table;
  492. struct radix_tree_root mac_tree;
  493. struct mlx4_vlan_table vlan_table;
  494. int base_qpn;
  495. };
  496. struct mlx4_sense {
  497. struct mlx4_dev *dev;
  498. u8 do_sense_port[MLX4_MAX_PORTS + 1];
  499. u8 sense_allowed[MLX4_MAX_PORTS + 1];
  500. struct delayed_work sense_poll;
  501. };
  502. struct mlx4_msix_ctl {
  503. u64 pool_bm;
  504. spinlock_t pool_lock;
  505. };
  506. struct mlx4_steer {
  507. struct list_head promisc_qps[MLX4_NUM_STEERS];
  508. struct list_head steer_entries[MLX4_NUM_STEERS];
  509. struct list_head high_prios;
  510. };
  511. struct mlx4_priv {
  512. struct mlx4_dev dev;
  513. struct list_head dev_list;
  514. struct list_head ctx_list;
  515. spinlock_t ctx_lock;
  516. struct list_head pgdir_list;
  517. struct mutex pgdir_mutex;
  518. struct mlx4_fw fw;
  519. struct mlx4_cmd cmd;
  520. struct mlx4_mfunc mfunc;
  521. struct mlx4_bitmap pd_bitmap;
  522. struct mlx4_bitmap xrcd_bitmap;
  523. struct mlx4_uar_table uar_table;
  524. struct mlx4_mr_table mr_table;
  525. struct mlx4_cq_table cq_table;
  526. struct mlx4_eq_table eq_table;
  527. struct mlx4_srq_table srq_table;
  528. struct mlx4_qp_table qp_table;
  529. struct mlx4_mcg_table mcg_table;
  530. struct mlx4_bitmap counters_bitmap;
  531. struct mlx4_catas_err catas_err;
  532. void __iomem *clr_base;
  533. struct mlx4_uar driver_uar;
  534. void __iomem *kar;
  535. struct mlx4_port_info port[MLX4_MAX_PORTS + 1];
  536. struct mlx4_sense sense;
  537. struct mutex port_mutex;
  538. struct mlx4_msix_ctl msix_ctl;
  539. struct mlx4_steer *steer;
  540. struct list_head bf_list;
  541. struct mutex bf_mutex;
  542. struct io_mapping *bf_mapping;
  543. };
  544. static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev)
  545. {
  546. return container_of(dev, struct mlx4_priv, dev);
  547. }
  548. #define MLX4_SENSE_RANGE (HZ * 3)
  549. extern struct workqueue_struct *mlx4_wq;
  550. u32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap);
  551. void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj);
  552. u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt, int align);
  553. void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt);
  554. u32 mlx4_bitmap_avail(struct mlx4_bitmap *bitmap);
  555. int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
  556. u32 reserved_bot, u32 resetrved_top);
  557. void mlx4_bitmap_cleanup(struct mlx4_bitmap *bitmap);
  558. int mlx4_reset(struct mlx4_dev *dev);
  559. int mlx4_alloc_eq_table(struct mlx4_dev *dev);
  560. void mlx4_free_eq_table(struct mlx4_dev *dev);
  561. int mlx4_init_pd_table(struct mlx4_dev *dev);
  562. int mlx4_init_xrcd_table(struct mlx4_dev *dev);
  563. int mlx4_init_uar_table(struct mlx4_dev *dev);
  564. int mlx4_init_mr_table(struct mlx4_dev *dev);
  565. int mlx4_init_eq_table(struct mlx4_dev *dev);
  566. int mlx4_init_cq_table(struct mlx4_dev *dev);
  567. int mlx4_init_qp_table(struct mlx4_dev *dev);
  568. int mlx4_init_srq_table(struct mlx4_dev *dev);
  569. int mlx4_init_mcg_table(struct mlx4_dev *dev);
  570. void mlx4_cleanup_pd_table(struct mlx4_dev *dev);
  571. void mlx4_cleanup_xrcd_table(struct mlx4_dev *dev);
  572. void mlx4_cleanup_uar_table(struct mlx4_dev *dev);
  573. void mlx4_cleanup_mr_table(struct mlx4_dev *dev);
  574. void mlx4_cleanup_eq_table(struct mlx4_dev *dev);
  575. void mlx4_cleanup_cq_table(struct mlx4_dev *dev);
  576. void mlx4_cleanup_qp_table(struct mlx4_dev *dev);
  577. void mlx4_cleanup_srq_table(struct mlx4_dev *dev);
  578. void mlx4_cleanup_mcg_table(struct mlx4_dev *dev);
  579. int mlx4_WRITE_MTT_wrapper(struct mlx4_dev *dev, int slave,
  580. struct mlx4_vhcr *vhcr,
  581. struct mlx4_cmd_mailbox *inbox,
  582. struct mlx4_cmd_mailbox *outbox,
  583. struct mlx4_cmd_info *cmd);
  584. int mlx4_SYNC_TPT_wrapper(struct mlx4_dev *dev, int slave,
  585. struct mlx4_vhcr *vhcr,
  586. struct mlx4_cmd_mailbox *inbox,
  587. struct mlx4_cmd_mailbox *outbox,
  588. struct mlx4_cmd_info *cmd);
  589. int mlx4_SW2HW_MPT_wrapper(struct mlx4_dev *dev, int slave,
  590. struct mlx4_vhcr *vhcr,
  591. struct mlx4_cmd_mailbox *inbox,
  592. struct mlx4_cmd_mailbox *outbox,
  593. struct mlx4_cmd_info *cmd);
  594. int mlx4_HW2SW_MPT_wrapper(struct mlx4_dev *dev, int slave,
  595. struct mlx4_vhcr *vhcr,
  596. struct mlx4_cmd_mailbox *inbox,
  597. struct mlx4_cmd_mailbox *outbox,
  598. struct mlx4_cmd_info *cmd);
  599. int mlx4_QUERY_MPT_wrapper(struct mlx4_dev *dev, int slave,
  600. struct mlx4_vhcr *vhcr,
  601. struct mlx4_cmd_mailbox *inbox,
  602. struct mlx4_cmd_mailbox *outbox,
  603. struct mlx4_cmd_info *cmd);
  604. int mlx4_SW2HW_EQ_wrapper(struct mlx4_dev *dev, int slave,
  605. struct mlx4_vhcr *vhcr,
  606. struct mlx4_cmd_mailbox *inbox,
  607. struct mlx4_cmd_mailbox *outbox,
  608. struct mlx4_cmd_info *cmd);
  609. int mlx4_DMA_wrapper(struct mlx4_dev *dev, int slave,
  610. struct mlx4_vhcr *vhcr,
  611. struct mlx4_cmd_mailbox *inbox,
  612. struct mlx4_cmd_mailbox *outbox,
  613. struct mlx4_cmd_info *cmd);
  614. void mlx4_start_catas_poll(struct mlx4_dev *dev);
  615. void mlx4_stop_catas_poll(struct mlx4_dev *dev);
  616. void mlx4_catas_init(void);
  617. int mlx4_restart_one(struct pci_dev *pdev);
  618. int mlx4_register_device(struct mlx4_dev *dev);
  619. void mlx4_unregister_device(struct mlx4_dev *dev);
  620. void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type, int port);
  621. struct mlx4_dev_cap;
  622. struct mlx4_init_hca_param;
  623. u64 mlx4_make_profile(struct mlx4_dev *dev,
  624. struct mlx4_profile *request,
  625. struct mlx4_dev_cap *dev_cap,
  626. struct mlx4_init_hca_param *init_hca);
  627. void mlx4_master_comm_channel(struct work_struct *work);
  628. void mlx4_gen_slave_eqe(struct work_struct *work);
  629. void mlx4_master_handle_slave_flr(struct work_struct *work);
  630. int mlx4_ALLOC_RES_wrapper(struct mlx4_dev *dev, int slave,
  631. struct mlx4_vhcr *vhcr,
  632. struct mlx4_cmd_mailbox *inbox,
  633. struct mlx4_cmd_mailbox *outbox,
  634. struct mlx4_cmd_info *cmd);
  635. int mlx4_FREE_RES_wrapper(struct mlx4_dev *dev, int slave,
  636. struct mlx4_vhcr *vhcr,
  637. struct mlx4_cmd_mailbox *inbox,
  638. struct mlx4_cmd_mailbox *outbox,
  639. struct mlx4_cmd_info *cmd);
  640. int mlx4_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave,
  641. struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox,
  642. struct mlx4_cmd_mailbox *outbox,
  643. struct mlx4_cmd_info *cmd);
  644. int mlx4_COMM_INT_wrapper(struct mlx4_dev *dev, int slave,
  645. struct mlx4_vhcr *vhcr,
  646. struct mlx4_cmd_mailbox *inbox,
  647. struct mlx4_cmd_mailbox *outbox,
  648. struct mlx4_cmd_info *cmd);
  649. int mlx4_HW2SW_EQ_wrapper(struct mlx4_dev *dev, int slave,
  650. struct mlx4_vhcr *vhcr,
  651. struct mlx4_cmd_mailbox *inbox,
  652. struct mlx4_cmd_mailbox *outbox,
  653. struct mlx4_cmd_info *cmd);
  654. int mlx4_QUERY_EQ_wrapper(struct mlx4_dev *dev, int slave,
  655. struct mlx4_vhcr *vhcr,
  656. struct mlx4_cmd_mailbox *inbox,
  657. struct mlx4_cmd_mailbox *outbox,
  658. struct mlx4_cmd_info *cmd);
  659. int mlx4_SW2HW_CQ_wrapper(struct mlx4_dev *dev, int slave,
  660. struct mlx4_vhcr *vhcr,
  661. struct mlx4_cmd_mailbox *inbox,
  662. struct mlx4_cmd_mailbox *outbox,
  663. struct mlx4_cmd_info *cmd);
  664. int mlx4_HW2SW_CQ_wrapper(struct mlx4_dev *dev, int slave,
  665. struct mlx4_vhcr *vhcr,
  666. struct mlx4_cmd_mailbox *inbox,
  667. struct mlx4_cmd_mailbox *outbox,
  668. struct mlx4_cmd_info *cmd);
  669. int mlx4_QUERY_CQ_wrapper(struct mlx4_dev *dev, int slave,
  670. struct mlx4_vhcr *vhcr,
  671. struct mlx4_cmd_mailbox *inbox,
  672. struct mlx4_cmd_mailbox *outbox,
  673. struct mlx4_cmd_info *cmd);
  674. int mlx4_MODIFY_CQ_wrapper(struct mlx4_dev *dev, int slave,
  675. struct mlx4_vhcr *vhcr,
  676. struct mlx4_cmd_mailbox *inbox,
  677. struct mlx4_cmd_mailbox *outbox,
  678. struct mlx4_cmd_info *cmd);
  679. int mlx4_SW2HW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  680. struct mlx4_vhcr *vhcr,
  681. struct mlx4_cmd_mailbox *inbox,
  682. struct mlx4_cmd_mailbox *outbox,
  683. struct mlx4_cmd_info *cmd);
  684. int mlx4_HW2SW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  685. struct mlx4_vhcr *vhcr,
  686. struct mlx4_cmd_mailbox *inbox,
  687. struct mlx4_cmd_mailbox *outbox,
  688. struct mlx4_cmd_info *cmd);
  689. int mlx4_QUERY_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  690. struct mlx4_vhcr *vhcr,
  691. struct mlx4_cmd_mailbox *inbox,
  692. struct mlx4_cmd_mailbox *outbox,
  693. struct mlx4_cmd_info *cmd);
  694. int mlx4_ARM_SRQ_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_GEN_QP_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_RST2INIT_QP_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_INIT2RTR_QP_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_2RST_QP_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_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe);
  720. int mlx4_cmd_init(struct mlx4_dev *dev);
  721. void mlx4_cmd_cleanup(struct mlx4_dev *dev);
  722. void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param);
  723. int mlx4_cmd_use_events(struct mlx4_dev *dev);
  724. void mlx4_cmd_use_polling(struct mlx4_dev *dev);
  725. void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn);
  726. void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type);
  727. void mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type);
  728. void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type);
  729. void mlx4_handle_catas_err(struct mlx4_dev *dev);
  730. int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
  731. enum mlx4_port_type *type);
  732. void mlx4_do_sense_ports(struct mlx4_dev *dev,
  733. enum mlx4_port_type *stype,
  734. enum mlx4_port_type *defaults);
  735. void mlx4_start_sense(struct mlx4_dev *dev);
  736. void mlx4_stop_sense(struct mlx4_dev *dev);
  737. void mlx4_sense_init(struct mlx4_dev *dev);
  738. int mlx4_check_port_params(struct mlx4_dev *dev,
  739. enum mlx4_port_type *port_type);
  740. int mlx4_change_port_types(struct mlx4_dev *dev,
  741. enum mlx4_port_type *port_types);
  742. void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table);
  743. void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
  744. int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port);
  745. /* resource tracker functions*/
  746. int mlx4_get_slave_from_resource_id(struct mlx4_dev *dev,
  747. enum mlx4_resource resource_type,
  748. int resource_id, int *slave);
  749. void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave_id);
  750. int mlx4_init_resource_tracker(struct mlx4_dev *dev);
  751. void mlx4_free_resource_tracker(struct mlx4_dev *dev);
  752. int mlx4_SET_PORT_wrapper(struct mlx4_dev *dev, int slave,
  753. struct mlx4_vhcr *vhcr,
  754. struct mlx4_cmd_mailbox *inbox,
  755. struct mlx4_cmd_mailbox *outbox,
  756. struct mlx4_cmd_info *cmd);
  757. int mlx4_INIT_PORT_wrapper(struct mlx4_dev *dev, int slave,
  758. struct mlx4_vhcr *vhcr,
  759. struct mlx4_cmd_mailbox *inbox,
  760. struct mlx4_cmd_mailbox *outbox,
  761. struct mlx4_cmd_info *cmd);
  762. int mlx4_CLOSE_PORT_wrapper(struct mlx4_dev *dev, int slave,
  763. struct mlx4_vhcr *vhcr,
  764. struct mlx4_cmd_mailbox *inbox,
  765. struct mlx4_cmd_mailbox *outbox,
  766. struct mlx4_cmd_info *cmd);
  767. int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
  768. struct mlx4_vhcr *vhcr,
  769. struct mlx4_cmd_mailbox *inbox,
  770. struct mlx4_cmd_mailbox *outbox,
  771. struct mlx4_cmd_info *cmd);
  772. int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps);
  773. int mlx4_check_ext_port_caps(struct mlx4_dev *dev, u8 port);
  774. int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
  775. struct mlx4_vhcr *vhcr,
  776. struct mlx4_cmd_mailbox *inbox,
  777. struct mlx4_cmd_mailbox *outbox,
  778. struct mlx4_cmd_info *cmd);
  779. int mlx4_PROMISC_wrapper(struct mlx4_dev *dev, int slave,
  780. struct mlx4_vhcr *vhcr,
  781. struct mlx4_cmd_mailbox *inbox,
  782. struct mlx4_cmd_mailbox *outbox,
  783. struct mlx4_cmd_info *cmd);
  784. int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  785. enum mlx4_protocol prot, enum mlx4_steer_type steer);
  786. int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  787. int block_mcast_loopback, enum mlx4_protocol prot,
  788. enum mlx4_steer_type steer);
  789. int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave,
  790. struct mlx4_vhcr *vhcr,
  791. struct mlx4_cmd_mailbox *inbox,
  792. struct mlx4_cmd_mailbox *outbox,
  793. struct mlx4_cmd_info *cmd);
  794. int mlx4_SET_VLAN_FLTR_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_common_set_vlan_fltr(struct mlx4_dev *dev, int function,
  800. int port, void *buf);
  801. int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave, u32 in_mod,
  802. struct mlx4_cmd_mailbox *outbox);
  803. int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave,
  804. struct mlx4_vhcr *vhcr,
  805. struct mlx4_cmd_mailbox *inbox,
  806. struct mlx4_cmd_mailbox *outbox,
  807. struct mlx4_cmd_info *cmd);
  808. int mlx4_PKEY_TABLE_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_QUERY_IF_STAT_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. #define NOT_MASKED_PD_BITS 17
  819. #endif /* MLX4_H */