mlx4.h 34 KB

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