mlx4.h 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242
  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. #define MLX4_NUM_UP 8
  59. #define MLX4_NUM_TC 8
  60. #define MLX4_RATELIMIT_UNITS 3 /* 100 Mbps */
  61. #define MLX4_RATELIMIT_DEFAULT 0xffff
  62. struct mlx4_set_port_prio2tc_context {
  63. u8 prio2tc[4];
  64. };
  65. struct mlx4_port_scheduler_tc_cfg_be {
  66. __be16 pg;
  67. __be16 bw_precentage;
  68. __be16 max_bw_units; /* 3-100Mbps, 4-1Gbps, other values - reserved */
  69. __be16 max_bw_value;
  70. };
  71. struct mlx4_set_port_scheduler_context {
  72. struct mlx4_port_scheduler_tc_cfg_be tc[MLX4_NUM_TC];
  73. };
  74. enum {
  75. MLX4_HCR_BASE = 0x80680,
  76. MLX4_HCR_SIZE = 0x0001c,
  77. MLX4_CLR_INT_SIZE = 0x00008,
  78. MLX4_SLAVE_COMM_BASE = 0x0,
  79. MLX4_COMM_PAGESIZE = 0x1000,
  80. MLX4_CLOCK_SIZE = 0x00008
  81. };
  82. enum {
  83. MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE = 10,
  84. MLX4_MIN_MGM_LOG_ENTRY_SIZE = 7,
  85. MLX4_MAX_MGM_LOG_ENTRY_SIZE = 12,
  86. MLX4_MAX_QP_PER_MGM = 4 * ((1 << MLX4_MAX_MGM_LOG_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_mpt_state {
  104. MLX4_MPT_DISABLED = 0,
  105. MLX4_MPT_EN_HW,
  106. MLX4_MPT_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. u32 max_order;
  223. spinlock_t lock;
  224. };
  225. struct mlx4_icm;
  226. struct mlx4_icm_table {
  227. u64 virt;
  228. int num_icm;
  229. u32 num_obj;
  230. int obj_size;
  231. int lowmem;
  232. int coherent;
  233. struct mutex mutex;
  234. struct mlx4_icm **icm;
  235. };
  236. #define MLX4_MPT_FLAG_SW_OWNS (0xfUL << 28)
  237. #define MLX4_MPT_FLAG_FREE (0x3UL << 28)
  238. #define MLX4_MPT_FLAG_MIO (1 << 17)
  239. #define MLX4_MPT_FLAG_BIND_ENABLE (1 << 15)
  240. #define MLX4_MPT_FLAG_PHYSICAL (1 << 9)
  241. #define MLX4_MPT_FLAG_REGION (1 << 8)
  242. #define MLX4_MPT_PD_FLAG_FAST_REG (1 << 27)
  243. #define MLX4_MPT_PD_FLAG_RAE (1 << 28)
  244. #define MLX4_MPT_PD_FLAG_EN_INV (3 << 24)
  245. #define MLX4_MPT_QP_FLAG_BOUND_QP (1 << 7)
  246. #define MLX4_MPT_STATUS_SW 0xF0
  247. #define MLX4_MPT_STATUS_HW 0x00
  248. /*
  249. * Must be packed because mtt_seg is 64 bits but only aligned to 32 bits.
  250. */
  251. struct mlx4_mpt_entry {
  252. __be32 flags;
  253. __be32 qpn;
  254. __be32 key;
  255. __be32 pd_flags;
  256. __be64 start;
  257. __be64 length;
  258. __be32 lkey;
  259. __be32 win_cnt;
  260. u8 reserved1[3];
  261. u8 mtt_rep;
  262. __be64 mtt_addr;
  263. __be32 mtt_sz;
  264. __be32 entity_size;
  265. __be32 first_byte_offset;
  266. } __packed;
  267. /*
  268. * Must be packed because start is 64 bits but only aligned to 32 bits.
  269. */
  270. struct mlx4_eq_context {
  271. __be32 flags;
  272. u16 reserved1[3];
  273. __be16 page_offset;
  274. u8 log_eq_size;
  275. u8 reserved2[4];
  276. u8 eq_period;
  277. u8 reserved3;
  278. u8 eq_max_count;
  279. u8 reserved4[3];
  280. u8 intr;
  281. u8 log_page_size;
  282. u8 reserved5[2];
  283. u8 mtt_base_addr_h;
  284. __be32 mtt_base_addr_l;
  285. u32 reserved6[2];
  286. __be32 consumer_index;
  287. __be32 producer_index;
  288. u32 reserved7[4];
  289. };
  290. struct mlx4_cq_context {
  291. __be32 flags;
  292. u16 reserved1[3];
  293. __be16 page_offset;
  294. __be32 logsize_usrpage;
  295. __be16 cq_period;
  296. __be16 cq_max_count;
  297. u8 reserved2[3];
  298. u8 comp_eqn;
  299. u8 log_page_size;
  300. u8 reserved3[2];
  301. u8 mtt_base_addr_h;
  302. __be32 mtt_base_addr_l;
  303. __be32 last_notified_index;
  304. __be32 solicit_producer_index;
  305. __be32 consumer_index;
  306. __be32 producer_index;
  307. u32 reserved4[2];
  308. __be64 db_rec_addr;
  309. };
  310. struct mlx4_srq_context {
  311. __be32 state_logsize_srqn;
  312. u8 logstride;
  313. u8 reserved1;
  314. __be16 xrcd;
  315. __be32 pg_offset_cqn;
  316. u32 reserved2;
  317. u8 log_page_size;
  318. u8 reserved3[2];
  319. u8 mtt_base_addr_h;
  320. __be32 mtt_base_addr_l;
  321. __be32 pd;
  322. __be16 limit_watermark;
  323. __be16 wqe_cnt;
  324. u16 reserved4;
  325. __be16 wqe_counter;
  326. u32 reserved5;
  327. __be64 db_rec_addr;
  328. };
  329. struct mlx4_eq {
  330. struct mlx4_dev *dev;
  331. void __iomem *doorbell;
  332. int eqn;
  333. u32 cons_index;
  334. u16 irq;
  335. u16 have_irq;
  336. int nent;
  337. struct mlx4_buf_list *page_list;
  338. struct mlx4_mtt mtt;
  339. };
  340. struct mlx4_slave_eqe {
  341. u8 type;
  342. u8 port;
  343. u32 param;
  344. };
  345. struct mlx4_slave_event_eq_info {
  346. int eqn;
  347. u16 token;
  348. };
  349. struct mlx4_profile {
  350. int num_qp;
  351. int rdmarc_per_qp;
  352. int num_srq;
  353. int num_cq;
  354. int num_mcg;
  355. int num_mpt;
  356. unsigned num_mtt;
  357. };
  358. struct mlx4_fw {
  359. u64 clr_int_base;
  360. u64 catas_offset;
  361. u64 comm_base;
  362. u64 clock_offset;
  363. struct mlx4_icm *fw_icm;
  364. struct mlx4_icm *aux_icm;
  365. u32 catas_size;
  366. u16 fw_pages;
  367. u8 clr_int_bar;
  368. u8 catas_bar;
  369. u8 comm_bar;
  370. u8 clock_bar;
  371. };
  372. struct mlx4_comm {
  373. u32 slave_write;
  374. u32 slave_read;
  375. };
  376. enum {
  377. MLX4_MCAST_CONFIG = 0,
  378. MLX4_MCAST_DISABLE = 1,
  379. MLX4_MCAST_ENABLE = 2,
  380. };
  381. #define VLAN_FLTR_SIZE 128
  382. struct mlx4_vlan_fltr {
  383. __be32 entry[VLAN_FLTR_SIZE];
  384. };
  385. struct mlx4_mcast_entry {
  386. struct list_head list;
  387. u64 addr;
  388. };
  389. struct mlx4_promisc_qp {
  390. struct list_head list;
  391. u32 qpn;
  392. };
  393. struct mlx4_steer_index {
  394. struct list_head list;
  395. unsigned int index;
  396. struct list_head duplicates;
  397. };
  398. #define MLX4_EVENT_TYPES_NUM 64
  399. struct mlx4_slave_state {
  400. u8 comm_toggle;
  401. u8 last_cmd;
  402. u8 init_port_mask;
  403. bool active;
  404. u8 function;
  405. dma_addr_t vhcr_dma;
  406. u16 mtu[MLX4_MAX_PORTS + 1];
  407. __be32 ib_cap_mask[MLX4_MAX_PORTS + 1];
  408. struct mlx4_slave_eqe eq[MLX4_MFUNC_MAX_EQES];
  409. struct list_head mcast_filters[MLX4_MAX_PORTS + 1];
  410. struct mlx4_vlan_fltr *vlan_filter[MLX4_MAX_PORTS + 1];
  411. /* event type to eq number lookup */
  412. struct mlx4_slave_event_eq_info event_eq[MLX4_EVENT_TYPES_NUM];
  413. u16 eq_pi;
  414. u16 eq_ci;
  415. spinlock_t lock;
  416. /*initialized via the kzalloc*/
  417. u8 is_slave_going_down;
  418. u32 cookie;
  419. enum slave_port_state port_state[MLX4_MAX_PORTS + 1];
  420. };
  421. #define MLX4_VGT 4095
  422. #define NO_INDX (-1)
  423. struct mlx4_vport_state {
  424. u64 mac;
  425. u16 default_vlan;
  426. u8 default_qos;
  427. u32 tx_rate;
  428. bool spoofchk;
  429. u32 link_state;
  430. };
  431. struct mlx4_vf_admin_state {
  432. struct mlx4_vport_state vport[MLX4_MAX_PORTS + 1];
  433. };
  434. struct mlx4_vport_oper_state {
  435. struct mlx4_vport_state state;
  436. int mac_idx;
  437. int vlan_idx;
  438. };
  439. struct mlx4_vf_oper_state {
  440. struct mlx4_vport_oper_state vport[MLX4_MAX_PORTS + 1];
  441. };
  442. struct slave_list {
  443. struct mutex mutex;
  444. struct list_head res_list[MLX4_NUM_OF_RESOURCE_TYPE];
  445. };
  446. struct mlx4_resource_tracker {
  447. spinlock_t lock;
  448. /* tree for each resources */
  449. struct rb_root res_tree[MLX4_NUM_OF_RESOURCE_TYPE];
  450. /* num_of_slave's lists, one per slave */
  451. struct slave_list *slave_list;
  452. };
  453. #define SLAVE_EVENT_EQ_SIZE 128
  454. struct mlx4_slave_event_eq {
  455. u32 eqn;
  456. u32 cons;
  457. u32 prod;
  458. spinlock_t event_lock;
  459. struct mlx4_eqe event_eqe[SLAVE_EVENT_EQ_SIZE];
  460. };
  461. struct mlx4_master_qp0_state {
  462. int proxy_qp0_active;
  463. int qp0_active;
  464. int port_active;
  465. };
  466. struct mlx4_mfunc_master_ctx {
  467. struct mlx4_slave_state *slave_state;
  468. struct mlx4_vf_admin_state *vf_admin;
  469. struct mlx4_vf_oper_state *vf_oper;
  470. struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1];
  471. int init_port_ref[MLX4_MAX_PORTS + 1];
  472. u16 max_mtu[MLX4_MAX_PORTS + 1];
  473. int disable_mcast_ref[MLX4_MAX_PORTS + 1];
  474. struct mlx4_resource_tracker res_tracker;
  475. struct workqueue_struct *comm_wq;
  476. struct work_struct comm_work;
  477. struct work_struct slave_event_work;
  478. struct work_struct slave_flr_event_work;
  479. spinlock_t slave_state_lock;
  480. __be32 comm_arm_bit_vector[4];
  481. struct mlx4_eqe cmd_eqe;
  482. struct mlx4_slave_event_eq slave_eq;
  483. struct mutex gen_eqe_mutex[MLX4_MFUNC_MAX];
  484. };
  485. struct mlx4_mfunc {
  486. struct mlx4_comm __iomem *comm;
  487. struct mlx4_vhcr_cmd *vhcr;
  488. dma_addr_t vhcr_dma;
  489. struct mlx4_mfunc_master_ctx master;
  490. };
  491. struct mlx4_cmd {
  492. struct pci_pool *pool;
  493. void __iomem *hcr;
  494. struct mutex hcr_mutex;
  495. struct mutex slave_cmd_mutex;
  496. struct semaphore poll_sem;
  497. struct semaphore event_sem;
  498. int max_cmds;
  499. spinlock_t context_lock;
  500. int free_head;
  501. struct mlx4_cmd_context *context;
  502. u16 token_mask;
  503. u8 use_events;
  504. u8 toggle;
  505. u8 comm_toggle;
  506. };
  507. enum {
  508. MLX4_VF_IMMED_VLAN_FLAG_VLAN = 1 << 0,
  509. MLX4_VF_IMMED_VLAN_FLAG_QOS = 1 << 1,
  510. MLX4_VF_IMMED_VLAN_FLAG_LINK_DISABLE = 1 << 2,
  511. };
  512. struct mlx4_vf_immed_vlan_work {
  513. struct work_struct work;
  514. struct mlx4_priv *priv;
  515. int flags;
  516. int slave;
  517. int vlan_ix;
  518. int orig_vlan_ix;
  519. u8 port;
  520. u8 qos;
  521. u16 vlan_id;
  522. u16 orig_vlan_id;
  523. };
  524. struct mlx4_uar_table {
  525. struct mlx4_bitmap bitmap;
  526. };
  527. struct mlx4_mr_table {
  528. struct mlx4_bitmap mpt_bitmap;
  529. struct mlx4_buddy mtt_buddy;
  530. u64 mtt_base;
  531. u64 mpt_base;
  532. struct mlx4_icm_table mtt_table;
  533. struct mlx4_icm_table dmpt_table;
  534. };
  535. struct mlx4_cq_table {
  536. struct mlx4_bitmap bitmap;
  537. spinlock_t lock;
  538. struct radix_tree_root tree;
  539. struct mlx4_icm_table table;
  540. struct mlx4_icm_table cmpt_table;
  541. };
  542. struct mlx4_eq_table {
  543. struct mlx4_bitmap bitmap;
  544. char *irq_names;
  545. void __iomem *clr_int;
  546. void __iomem **uar_map;
  547. u32 clr_mask;
  548. struct mlx4_eq *eq;
  549. struct mlx4_icm_table table;
  550. struct mlx4_icm_table cmpt_table;
  551. int have_irq;
  552. u8 inta_pin;
  553. };
  554. struct mlx4_srq_table {
  555. struct mlx4_bitmap bitmap;
  556. spinlock_t lock;
  557. struct radix_tree_root tree;
  558. struct mlx4_icm_table table;
  559. struct mlx4_icm_table cmpt_table;
  560. };
  561. struct mlx4_qp_table {
  562. struct mlx4_bitmap bitmap;
  563. u32 rdmarc_base;
  564. int rdmarc_shift;
  565. spinlock_t lock;
  566. struct mlx4_icm_table qp_table;
  567. struct mlx4_icm_table auxc_table;
  568. struct mlx4_icm_table altc_table;
  569. struct mlx4_icm_table rdmarc_table;
  570. struct mlx4_icm_table cmpt_table;
  571. };
  572. struct mlx4_mcg_table {
  573. struct mutex mutex;
  574. struct mlx4_bitmap bitmap;
  575. struct mlx4_icm_table table;
  576. };
  577. struct mlx4_catas_err {
  578. u32 __iomem *map;
  579. struct timer_list timer;
  580. struct list_head list;
  581. };
  582. #define MLX4_MAX_MAC_NUM 128
  583. #define MLX4_MAC_TABLE_SIZE (MLX4_MAX_MAC_NUM << 3)
  584. struct mlx4_mac_table {
  585. __be64 entries[MLX4_MAX_MAC_NUM];
  586. int refs[MLX4_MAX_MAC_NUM];
  587. struct mutex mutex;
  588. int total;
  589. int max;
  590. };
  591. #define MLX4_MAX_VLAN_NUM 128
  592. #define MLX4_VLAN_TABLE_SIZE (MLX4_MAX_VLAN_NUM << 2)
  593. struct mlx4_vlan_table {
  594. __be32 entries[MLX4_MAX_VLAN_NUM];
  595. int refs[MLX4_MAX_VLAN_NUM];
  596. struct mutex mutex;
  597. int total;
  598. int max;
  599. };
  600. #define SET_PORT_GEN_ALL_VALID 0x7
  601. #define SET_PORT_PROMISC_SHIFT 31
  602. #define SET_PORT_MC_PROMISC_SHIFT 30
  603. enum {
  604. MCAST_DIRECT_ONLY = 0,
  605. MCAST_DIRECT = 1,
  606. MCAST_DEFAULT = 2
  607. };
  608. struct mlx4_set_port_general_context {
  609. u8 reserved[3];
  610. u8 flags;
  611. u16 reserved2;
  612. __be16 mtu;
  613. u8 pptx;
  614. u8 pfctx;
  615. u16 reserved3;
  616. u8 pprx;
  617. u8 pfcrx;
  618. u16 reserved4;
  619. };
  620. struct mlx4_set_port_rqp_calc_context {
  621. __be32 base_qpn;
  622. u8 rererved;
  623. u8 n_mac;
  624. u8 n_vlan;
  625. u8 n_prio;
  626. u8 reserved2[3];
  627. u8 mac_miss;
  628. u8 intra_no_vlan;
  629. u8 no_vlan;
  630. u8 intra_vlan_miss;
  631. u8 vlan_miss;
  632. u8 reserved3[3];
  633. u8 no_vlan_prio;
  634. __be32 promisc;
  635. __be32 mcast;
  636. };
  637. struct mlx4_port_info {
  638. struct mlx4_dev *dev;
  639. int port;
  640. char dev_name[16];
  641. struct device_attribute port_attr;
  642. enum mlx4_port_type tmp_type;
  643. char dev_mtu_name[16];
  644. struct device_attribute port_mtu_attr;
  645. struct mlx4_mac_table mac_table;
  646. struct mlx4_vlan_table vlan_table;
  647. int base_qpn;
  648. };
  649. struct mlx4_sense {
  650. struct mlx4_dev *dev;
  651. u8 do_sense_port[MLX4_MAX_PORTS + 1];
  652. u8 sense_allowed[MLX4_MAX_PORTS + 1];
  653. struct delayed_work sense_poll;
  654. };
  655. struct mlx4_msix_ctl {
  656. u64 pool_bm;
  657. struct mutex pool_lock;
  658. };
  659. struct mlx4_steer {
  660. struct list_head promisc_qps[MLX4_NUM_STEERS];
  661. struct list_head steer_entries[MLX4_NUM_STEERS];
  662. };
  663. enum {
  664. MLX4_PCI_DEV_IS_VF = 1 << 0,
  665. MLX4_PCI_DEV_FORCE_SENSE_PORT = 1 << 1,
  666. };
  667. struct mlx4_priv {
  668. struct mlx4_dev dev;
  669. struct list_head dev_list;
  670. struct list_head ctx_list;
  671. spinlock_t ctx_lock;
  672. int pci_dev_data;
  673. struct list_head pgdir_list;
  674. struct mutex pgdir_mutex;
  675. struct mlx4_fw fw;
  676. struct mlx4_cmd cmd;
  677. struct mlx4_mfunc mfunc;
  678. struct mlx4_bitmap pd_bitmap;
  679. struct mlx4_bitmap xrcd_bitmap;
  680. struct mlx4_uar_table uar_table;
  681. struct mlx4_mr_table mr_table;
  682. struct mlx4_cq_table cq_table;
  683. struct mlx4_eq_table eq_table;
  684. struct mlx4_srq_table srq_table;
  685. struct mlx4_qp_table qp_table;
  686. struct mlx4_mcg_table mcg_table;
  687. struct mlx4_bitmap counters_bitmap;
  688. struct mlx4_catas_err catas_err;
  689. void __iomem *clr_base;
  690. struct mlx4_uar driver_uar;
  691. void __iomem *kar;
  692. struct mlx4_port_info port[MLX4_MAX_PORTS + 1];
  693. struct mlx4_sense sense;
  694. struct mutex port_mutex;
  695. struct mlx4_msix_ctl msix_ctl;
  696. struct mlx4_steer *steer;
  697. struct list_head bf_list;
  698. struct mutex bf_mutex;
  699. struct io_mapping *bf_mapping;
  700. void __iomem *clock_mapping;
  701. int reserved_mtts;
  702. int fs_hash_mode;
  703. u8 virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS];
  704. __be64 slave_node_guids[MLX4_MFUNC_MAX];
  705. };
  706. static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev)
  707. {
  708. return container_of(dev, struct mlx4_priv, dev);
  709. }
  710. #define MLX4_SENSE_RANGE (HZ * 3)
  711. extern struct workqueue_struct *mlx4_wq;
  712. u32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap);
  713. void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj);
  714. u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt, int align);
  715. void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt);
  716. u32 mlx4_bitmap_avail(struct mlx4_bitmap *bitmap);
  717. int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
  718. u32 reserved_bot, u32 resetrved_top);
  719. void mlx4_bitmap_cleanup(struct mlx4_bitmap *bitmap);
  720. int mlx4_reset(struct mlx4_dev *dev);
  721. int mlx4_alloc_eq_table(struct mlx4_dev *dev);
  722. void mlx4_free_eq_table(struct mlx4_dev *dev);
  723. int mlx4_init_pd_table(struct mlx4_dev *dev);
  724. int mlx4_init_xrcd_table(struct mlx4_dev *dev);
  725. int mlx4_init_uar_table(struct mlx4_dev *dev);
  726. int mlx4_init_mr_table(struct mlx4_dev *dev);
  727. int mlx4_init_eq_table(struct mlx4_dev *dev);
  728. int mlx4_init_cq_table(struct mlx4_dev *dev);
  729. int mlx4_init_qp_table(struct mlx4_dev *dev);
  730. int mlx4_init_srq_table(struct mlx4_dev *dev);
  731. int mlx4_init_mcg_table(struct mlx4_dev *dev);
  732. void mlx4_cleanup_pd_table(struct mlx4_dev *dev);
  733. void mlx4_cleanup_xrcd_table(struct mlx4_dev *dev);
  734. void mlx4_cleanup_uar_table(struct mlx4_dev *dev);
  735. void mlx4_cleanup_mr_table(struct mlx4_dev *dev);
  736. void mlx4_cleanup_eq_table(struct mlx4_dev *dev);
  737. void mlx4_cleanup_cq_table(struct mlx4_dev *dev);
  738. void mlx4_cleanup_qp_table(struct mlx4_dev *dev);
  739. void mlx4_cleanup_srq_table(struct mlx4_dev *dev);
  740. void mlx4_cleanup_mcg_table(struct mlx4_dev *dev);
  741. int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn);
  742. void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn);
  743. int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn);
  744. void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn);
  745. int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn);
  746. void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn);
  747. int __mlx4_mpt_reserve(struct mlx4_dev *dev);
  748. void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index);
  749. int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index);
  750. void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index);
  751. u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order);
  752. void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order);
  753. int mlx4_WRITE_MTT_wrapper(struct mlx4_dev *dev, int slave,
  754. struct mlx4_vhcr *vhcr,
  755. struct mlx4_cmd_mailbox *inbox,
  756. struct mlx4_cmd_mailbox *outbox,
  757. struct mlx4_cmd_info *cmd);
  758. int mlx4_SYNC_TPT_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_SW2HW_MPT_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_HW2SW_MPT_wrapper(struct mlx4_dev *dev, int slave,
  769. struct mlx4_vhcr *vhcr,
  770. struct mlx4_cmd_mailbox *inbox,
  771. struct mlx4_cmd_mailbox *outbox,
  772. struct mlx4_cmd_info *cmd);
  773. int mlx4_QUERY_MPT_wrapper(struct mlx4_dev *dev, int slave,
  774. struct mlx4_vhcr *vhcr,
  775. struct mlx4_cmd_mailbox *inbox,
  776. struct mlx4_cmd_mailbox *outbox,
  777. struct mlx4_cmd_info *cmd);
  778. int mlx4_SW2HW_EQ_wrapper(struct mlx4_dev *dev, int slave,
  779. struct mlx4_vhcr *vhcr,
  780. struct mlx4_cmd_mailbox *inbox,
  781. struct mlx4_cmd_mailbox *outbox,
  782. struct mlx4_cmd_info *cmd);
  783. int mlx4_DMA_wrapper(struct mlx4_dev *dev, int slave,
  784. struct mlx4_vhcr *vhcr,
  785. struct mlx4_cmd_mailbox *inbox,
  786. struct mlx4_cmd_mailbox *outbox,
  787. struct mlx4_cmd_info *cmd);
  788. int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
  789. int *base);
  790. void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
  791. int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  792. void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  793. int __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
  794. int start_index, int npages, u64 *page_list);
  795. int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx);
  796. void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx);
  797. int __mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn);
  798. void __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn);
  799. void mlx4_start_catas_poll(struct mlx4_dev *dev);
  800. void mlx4_stop_catas_poll(struct mlx4_dev *dev);
  801. void mlx4_catas_init(void);
  802. int mlx4_restart_one(struct pci_dev *pdev);
  803. int mlx4_register_device(struct mlx4_dev *dev);
  804. void mlx4_unregister_device(struct mlx4_dev *dev);
  805. void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type,
  806. unsigned long param);
  807. struct mlx4_dev_cap;
  808. struct mlx4_init_hca_param;
  809. u64 mlx4_make_profile(struct mlx4_dev *dev,
  810. struct mlx4_profile *request,
  811. struct mlx4_dev_cap *dev_cap,
  812. struct mlx4_init_hca_param *init_hca);
  813. void mlx4_master_comm_channel(struct work_struct *work);
  814. void mlx4_gen_slave_eqe(struct work_struct *work);
  815. void mlx4_master_handle_slave_flr(struct work_struct *work);
  816. int mlx4_ALLOC_RES_wrapper(struct mlx4_dev *dev, int slave,
  817. struct mlx4_vhcr *vhcr,
  818. struct mlx4_cmd_mailbox *inbox,
  819. struct mlx4_cmd_mailbox *outbox,
  820. struct mlx4_cmd_info *cmd);
  821. int mlx4_FREE_RES_wrapper(struct mlx4_dev *dev, int slave,
  822. struct mlx4_vhcr *vhcr,
  823. struct mlx4_cmd_mailbox *inbox,
  824. struct mlx4_cmd_mailbox *outbox,
  825. struct mlx4_cmd_info *cmd);
  826. int mlx4_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave,
  827. struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox,
  828. struct mlx4_cmd_mailbox *outbox,
  829. struct mlx4_cmd_info *cmd);
  830. int mlx4_COMM_INT_wrapper(struct mlx4_dev *dev, int slave,
  831. struct mlx4_vhcr *vhcr,
  832. struct mlx4_cmd_mailbox *inbox,
  833. struct mlx4_cmd_mailbox *outbox,
  834. struct mlx4_cmd_info *cmd);
  835. int mlx4_HW2SW_EQ_wrapper(struct mlx4_dev *dev, int slave,
  836. struct mlx4_vhcr *vhcr,
  837. struct mlx4_cmd_mailbox *inbox,
  838. struct mlx4_cmd_mailbox *outbox,
  839. struct mlx4_cmd_info *cmd);
  840. int mlx4_QUERY_EQ_wrapper(struct mlx4_dev *dev, int slave,
  841. struct mlx4_vhcr *vhcr,
  842. struct mlx4_cmd_mailbox *inbox,
  843. struct mlx4_cmd_mailbox *outbox,
  844. struct mlx4_cmd_info *cmd);
  845. int mlx4_SW2HW_CQ_wrapper(struct mlx4_dev *dev, int slave,
  846. struct mlx4_vhcr *vhcr,
  847. struct mlx4_cmd_mailbox *inbox,
  848. struct mlx4_cmd_mailbox *outbox,
  849. struct mlx4_cmd_info *cmd);
  850. int mlx4_HW2SW_CQ_wrapper(struct mlx4_dev *dev, int slave,
  851. struct mlx4_vhcr *vhcr,
  852. struct mlx4_cmd_mailbox *inbox,
  853. struct mlx4_cmd_mailbox *outbox,
  854. struct mlx4_cmd_info *cmd);
  855. int mlx4_QUERY_CQ_wrapper(struct mlx4_dev *dev, int slave,
  856. struct mlx4_vhcr *vhcr,
  857. struct mlx4_cmd_mailbox *inbox,
  858. struct mlx4_cmd_mailbox *outbox,
  859. struct mlx4_cmd_info *cmd);
  860. int mlx4_MODIFY_CQ_wrapper(struct mlx4_dev *dev, int slave,
  861. struct mlx4_vhcr *vhcr,
  862. struct mlx4_cmd_mailbox *inbox,
  863. struct mlx4_cmd_mailbox *outbox,
  864. struct mlx4_cmd_info *cmd);
  865. int mlx4_SW2HW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  866. struct mlx4_vhcr *vhcr,
  867. struct mlx4_cmd_mailbox *inbox,
  868. struct mlx4_cmd_mailbox *outbox,
  869. struct mlx4_cmd_info *cmd);
  870. int mlx4_HW2SW_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  871. struct mlx4_vhcr *vhcr,
  872. struct mlx4_cmd_mailbox *inbox,
  873. struct mlx4_cmd_mailbox *outbox,
  874. struct mlx4_cmd_info *cmd);
  875. int mlx4_QUERY_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  876. struct mlx4_vhcr *vhcr,
  877. struct mlx4_cmd_mailbox *inbox,
  878. struct mlx4_cmd_mailbox *outbox,
  879. struct mlx4_cmd_info *cmd);
  880. int mlx4_ARM_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  881. struct mlx4_vhcr *vhcr,
  882. struct mlx4_cmd_mailbox *inbox,
  883. struct mlx4_cmd_mailbox *outbox,
  884. struct mlx4_cmd_info *cmd);
  885. int mlx4_GEN_QP_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_RST2INIT_QP_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_INIT2INIT_QP_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_INIT2RTR_QP_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_RTR2RTS_QP_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_RTS2RTS_QP_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_SQERR2RTS_QP_wrapper(struct mlx4_dev *dev, int slave,
  916. struct mlx4_vhcr *vhcr,
  917. struct mlx4_cmd_mailbox *inbox,
  918. struct mlx4_cmd_mailbox *outbox,
  919. struct mlx4_cmd_info *cmd);
  920. int mlx4_2ERR_QP_wrapper(struct mlx4_dev *dev, int slave,
  921. struct mlx4_vhcr *vhcr,
  922. struct mlx4_cmd_mailbox *inbox,
  923. struct mlx4_cmd_mailbox *outbox,
  924. struct mlx4_cmd_info *cmd);
  925. int mlx4_RTS2SQD_QP_wrapper(struct mlx4_dev *dev, int slave,
  926. struct mlx4_vhcr *vhcr,
  927. struct mlx4_cmd_mailbox *inbox,
  928. struct mlx4_cmd_mailbox *outbox,
  929. struct mlx4_cmd_info *cmd);
  930. int mlx4_SQD2SQD_QP_wrapper(struct mlx4_dev *dev, int slave,
  931. struct mlx4_vhcr *vhcr,
  932. struct mlx4_cmd_mailbox *inbox,
  933. struct mlx4_cmd_mailbox *outbox,
  934. struct mlx4_cmd_info *cmd);
  935. int mlx4_SQD2RTS_QP_wrapper(struct mlx4_dev *dev, int slave,
  936. struct mlx4_vhcr *vhcr,
  937. struct mlx4_cmd_mailbox *inbox,
  938. struct mlx4_cmd_mailbox *outbox,
  939. struct mlx4_cmd_info *cmd);
  940. int mlx4_2RST_QP_wrapper(struct mlx4_dev *dev, int slave,
  941. struct mlx4_vhcr *vhcr,
  942. struct mlx4_cmd_mailbox *inbox,
  943. struct mlx4_cmd_mailbox *outbox,
  944. struct mlx4_cmd_info *cmd);
  945. int mlx4_QUERY_QP_wrapper(struct mlx4_dev *dev, int slave,
  946. struct mlx4_vhcr *vhcr,
  947. struct mlx4_cmd_mailbox *inbox,
  948. struct mlx4_cmd_mailbox *outbox,
  949. struct mlx4_cmd_info *cmd);
  950. int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe);
  951. int mlx4_cmd_init(struct mlx4_dev *dev);
  952. void mlx4_cmd_cleanup(struct mlx4_dev *dev);
  953. int mlx4_multi_func_init(struct mlx4_dev *dev);
  954. void mlx4_multi_func_cleanup(struct mlx4_dev *dev);
  955. void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param);
  956. int mlx4_cmd_use_events(struct mlx4_dev *dev);
  957. void mlx4_cmd_use_polling(struct mlx4_dev *dev);
  958. int mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param,
  959. unsigned long timeout);
  960. void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn);
  961. void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type);
  962. void mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type);
  963. void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type);
  964. void mlx4_handle_catas_err(struct mlx4_dev *dev);
  965. int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
  966. enum mlx4_port_type *type);
  967. void mlx4_do_sense_ports(struct mlx4_dev *dev,
  968. enum mlx4_port_type *stype,
  969. enum mlx4_port_type *defaults);
  970. void mlx4_start_sense(struct mlx4_dev *dev);
  971. void mlx4_stop_sense(struct mlx4_dev *dev);
  972. void mlx4_sense_init(struct mlx4_dev *dev);
  973. int mlx4_check_port_params(struct mlx4_dev *dev,
  974. enum mlx4_port_type *port_type);
  975. int mlx4_change_port_types(struct mlx4_dev *dev,
  976. enum mlx4_port_type *port_types);
  977. void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table);
  978. void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
  979. void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index);
  980. int __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
  981. int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz);
  982. /* resource tracker functions*/
  983. int mlx4_get_slave_from_resource_id(struct mlx4_dev *dev,
  984. enum mlx4_resource resource_type,
  985. u64 resource_id, int *slave);
  986. void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave_id);
  987. int mlx4_init_resource_tracker(struct mlx4_dev *dev);
  988. void mlx4_free_resource_tracker(struct mlx4_dev *dev,
  989. enum mlx4_res_tracker_free_type type);
  990. int mlx4_QUERY_FW_wrapper(struct mlx4_dev *dev, int slave,
  991. struct mlx4_vhcr *vhcr,
  992. struct mlx4_cmd_mailbox *inbox,
  993. struct mlx4_cmd_mailbox *outbox,
  994. struct mlx4_cmd_info *cmd);
  995. int mlx4_SET_PORT_wrapper(struct mlx4_dev *dev, int slave,
  996. struct mlx4_vhcr *vhcr,
  997. struct mlx4_cmd_mailbox *inbox,
  998. struct mlx4_cmd_mailbox *outbox,
  999. struct mlx4_cmd_info *cmd);
  1000. int mlx4_INIT_PORT_wrapper(struct mlx4_dev *dev, int slave,
  1001. struct mlx4_vhcr *vhcr,
  1002. struct mlx4_cmd_mailbox *inbox,
  1003. struct mlx4_cmd_mailbox *outbox,
  1004. struct mlx4_cmd_info *cmd);
  1005. int mlx4_CLOSE_PORT_wrapper(struct mlx4_dev *dev, int slave,
  1006. struct mlx4_vhcr *vhcr,
  1007. struct mlx4_cmd_mailbox *inbox,
  1008. struct mlx4_cmd_mailbox *outbox,
  1009. struct mlx4_cmd_info *cmd);
  1010. int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave,
  1011. struct mlx4_vhcr *vhcr,
  1012. struct mlx4_cmd_mailbox *inbox,
  1013. struct mlx4_cmd_mailbox *outbox,
  1014. struct mlx4_cmd_info *cmd);
  1015. int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
  1016. struct mlx4_vhcr *vhcr,
  1017. struct mlx4_cmd_mailbox *inbox,
  1018. struct mlx4_cmd_mailbox *outbox,
  1019. struct mlx4_cmd_info *cmd);
  1020. int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps);
  1021. int mlx4_get_slave_pkey_gid_tbl_len(struct mlx4_dev *dev, u8 port,
  1022. int *gid_tbl_len, int *pkey_tbl_len);
  1023. int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
  1024. struct mlx4_vhcr *vhcr,
  1025. struct mlx4_cmd_mailbox *inbox,
  1026. struct mlx4_cmd_mailbox *outbox,
  1027. struct mlx4_cmd_info *cmd);
  1028. int mlx4_PROMISC_wrapper(struct mlx4_dev *dev, int slave,
  1029. struct mlx4_vhcr *vhcr,
  1030. struct mlx4_cmd_mailbox *inbox,
  1031. struct mlx4_cmd_mailbox *outbox,
  1032. struct mlx4_cmd_info *cmd);
  1033. int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1034. enum mlx4_protocol prot, enum mlx4_steer_type steer);
  1035. int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1036. int block_mcast_loopback, enum mlx4_protocol prot,
  1037. enum mlx4_steer_type steer);
  1038. int mlx4_trans_to_dmfs_attach(struct mlx4_dev *dev, struct mlx4_qp *qp,
  1039. u8 gid[16], u8 port,
  1040. int block_mcast_loopback,
  1041. enum mlx4_protocol prot, u64 *reg_id);
  1042. int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave,
  1043. struct mlx4_vhcr *vhcr,
  1044. struct mlx4_cmd_mailbox *inbox,
  1045. struct mlx4_cmd_mailbox *outbox,
  1046. struct mlx4_cmd_info *cmd);
  1047. int mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave,
  1048. struct mlx4_vhcr *vhcr,
  1049. struct mlx4_cmd_mailbox *inbox,
  1050. struct mlx4_cmd_mailbox *outbox,
  1051. struct mlx4_cmd_info *cmd);
  1052. int mlx4_common_set_vlan_fltr(struct mlx4_dev *dev, int function,
  1053. int port, void *buf);
  1054. int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave, u32 in_mod,
  1055. struct mlx4_cmd_mailbox *outbox);
  1056. int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave,
  1057. struct mlx4_vhcr *vhcr,
  1058. struct mlx4_cmd_mailbox *inbox,
  1059. struct mlx4_cmd_mailbox *outbox,
  1060. struct mlx4_cmd_info *cmd);
  1061. int mlx4_PKEY_TABLE_wrapper(struct mlx4_dev *dev, int slave,
  1062. struct mlx4_vhcr *vhcr,
  1063. struct mlx4_cmd_mailbox *inbox,
  1064. struct mlx4_cmd_mailbox *outbox,
  1065. struct mlx4_cmd_info *cmd);
  1066. int mlx4_QUERY_IF_STAT_wrapper(struct mlx4_dev *dev, int slave,
  1067. struct mlx4_vhcr *vhcr,
  1068. struct mlx4_cmd_mailbox *inbox,
  1069. struct mlx4_cmd_mailbox *outbox,
  1070. struct mlx4_cmd_info *cmd);
  1071. int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
  1072. struct mlx4_vhcr *vhcr,
  1073. struct mlx4_cmd_mailbox *inbox,
  1074. struct mlx4_cmd_mailbox *outbox,
  1075. struct mlx4_cmd_info *cmd);
  1076. int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
  1077. struct mlx4_vhcr *vhcr,
  1078. struct mlx4_cmd_mailbox *inbox,
  1079. struct mlx4_cmd_mailbox *outbox,
  1080. struct mlx4_cmd_info *cmd);
  1081. int mlx4_get_mgm_entry_size(struct mlx4_dev *dev);
  1082. int mlx4_get_qp_per_mgm(struct mlx4_dev *dev);
  1083. static inline void set_param_l(u64 *arg, u32 val)
  1084. {
  1085. *arg = (*arg & 0xffffffff00000000ULL) | (u64) val;
  1086. }
  1087. static inline void set_param_h(u64 *arg, u32 val)
  1088. {
  1089. *arg = (*arg & 0xffffffff) | ((u64) val << 32);
  1090. }
  1091. static inline u32 get_param_l(u64 *arg)
  1092. {
  1093. return (u32) (*arg & 0xffffffff);
  1094. }
  1095. static inline u32 get_param_h(u64 *arg)
  1096. {
  1097. return (u32)(*arg >> 32);
  1098. }
  1099. static inline spinlock_t *mlx4_tlock(struct mlx4_dev *dev)
  1100. {
  1101. return &mlx4_priv(dev)->mfunc.master.res_tracker.lock;
  1102. }
  1103. #define NOT_MASKED_PD_BITS 17
  1104. void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work);
  1105. #endif /* MLX4_H */