mlx4.h 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255
  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. #define MGM_QPN_MASK 0x00FFFFFF
  492. #define MGM_BLCK_LB_BIT 30
  493. struct mlx4_mgm {
  494. __be32 next_gid_index;
  495. __be32 members_count;
  496. u32 reserved[2];
  497. u8 gid[16];
  498. __be32 qp[MLX4_MAX_QP_PER_MGM];
  499. };
  500. struct mlx4_cmd {
  501. struct pci_pool *pool;
  502. void __iomem *hcr;
  503. struct mutex hcr_mutex;
  504. struct mutex slave_cmd_mutex;
  505. struct semaphore poll_sem;
  506. struct semaphore event_sem;
  507. int max_cmds;
  508. spinlock_t context_lock;
  509. int free_head;
  510. struct mlx4_cmd_context *context;
  511. u16 token_mask;
  512. u8 use_events;
  513. u8 toggle;
  514. u8 comm_toggle;
  515. };
  516. enum {
  517. MLX4_VF_IMMED_VLAN_FLAG_VLAN = 1 << 0,
  518. MLX4_VF_IMMED_VLAN_FLAG_QOS = 1 << 1,
  519. MLX4_VF_IMMED_VLAN_FLAG_LINK_DISABLE = 1 << 2,
  520. };
  521. struct mlx4_vf_immed_vlan_work {
  522. struct work_struct work;
  523. struct mlx4_priv *priv;
  524. int flags;
  525. int slave;
  526. int vlan_ix;
  527. int orig_vlan_ix;
  528. u8 port;
  529. u8 qos;
  530. u16 vlan_id;
  531. u16 orig_vlan_id;
  532. };
  533. struct mlx4_uar_table {
  534. struct mlx4_bitmap bitmap;
  535. };
  536. struct mlx4_mr_table {
  537. struct mlx4_bitmap mpt_bitmap;
  538. struct mlx4_buddy mtt_buddy;
  539. u64 mtt_base;
  540. u64 mpt_base;
  541. struct mlx4_icm_table mtt_table;
  542. struct mlx4_icm_table dmpt_table;
  543. };
  544. struct mlx4_cq_table {
  545. struct mlx4_bitmap bitmap;
  546. spinlock_t lock;
  547. struct radix_tree_root tree;
  548. struct mlx4_icm_table table;
  549. struct mlx4_icm_table cmpt_table;
  550. };
  551. struct mlx4_eq_table {
  552. struct mlx4_bitmap bitmap;
  553. char *irq_names;
  554. void __iomem *clr_int;
  555. void __iomem **uar_map;
  556. u32 clr_mask;
  557. struct mlx4_eq *eq;
  558. struct mlx4_icm_table table;
  559. struct mlx4_icm_table cmpt_table;
  560. int have_irq;
  561. u8 inta_pin;
  562. };
  563. struct mlx4_srq_table {
  564. struct mlx4_bitmap bitmap;
  565. spinlock_t lock;
  566. struct radix_tree_root tree;
  567. struct mlx4_icm_table table;
  568. struct mlx4_icm_table cmpt_table;
  569. };
  570. struct mlx4_qp_table {
  571. struct mlx4_bitmap bitmap;
  572. u32 rdmarc_base;
  573. int rdmarc_shift;
  574. spinlock_t lock;
  575. struct mlx4_icm_table qp_table;
  576. struct mlx4_icm_table auxc_table;
  577. struct mlx4_icm_table altc_table;
  578. struct mlx4_icm_table rdmarc_table;
  579. struct mlx4_icm_table cmpt_table;
  580. };
  581. struct mlx4_mcg_table {
  582. struct mutex mutex;
  583. struct mlx4_bitmap bitmap;
  584. struct mlx4_icm_table table;
  585. };
  586. struct mlx4_catas_err {
  587. u32 __iomem *map;
  588. struct timer_list timer;
  589. struct list_head list;
  590. };
  591. #define MLX4_MAX_MAC_NUM 128
  592. #define MLX4_MAC_TABLE_SIZE (MLX4_MAX_MAC_NUM << 3)
  593. struct mlx4_mac_table {
  594. __be64 entries[MLX4_MAX_MAC_NUM];
  595. int refs[MLX4_MAX_MAC_NUM];
  596. struct mutex mutex;
  597. int total;
  598. int max;
  599. };
  600. #define MLX4_MAX_VLAN_NUM 128
  601. #define MLX4_VLAN_TABLE_SIZE (MLX4_MAX_VLAN_NUM << 2)
  602. struct mlx4_vlan_table {
  603. __be32 entries[MLX4_MAX_VLAN_NUM];
  604. int refs[MLX4_MAX_VLAN_NUM];
  605. struct mutex mutex;
  606. int total;
  607. int max;
  608. };
  609. #define SET_PORT_GEN_ALL_VALID 0x7
  610. #define SET_PORT_PROMISC_SHIFT 31
  611. #define SET_PORT_MC_PROMISC_SHIFT 30
  612. enum {
  613. MCAST_DIRECT_ONLY = 0,
  614. MCAST_DIRECT = 1,
  615. MCAST_DEFAULT = 2
  616. };
  617. struct mlx4_set_port_general_context {
  618. u8 reserved[3];
  619. u8 flags;
  620. u16 reserved2;
  621. __be16 mtu;
  622. u8 pptx;
  623. u8 pfctx;
  624. u16 reserved3;
  625. u8 pprx;
  626. u8 pfcrx;
  627. u16 reserved4;
  628. };
  629. struct mlx4_set_port_rqp_calc_context {
  630. __be32 base_qpn;
  631. u8 rererved;
  632. u8 n_mac;
  633. u8 n_vlan;
  634. u8 n_prio;
  635. u8 reserved2[3];
  636. u8 mac_miss;
  637. u8 intra_no_vlan;
  638. u8 no_vlan;
  639. u8 intra_vlan_miss;
  640. u8 vlan_miss;
  641. u8 reserved3[3];
  642. u8 no_vlan_prio;
  643. __be32 promisc;
  644. __be32 mcast;
  645. };
  646. struct mlx4_port_info {
  647. struct mlx4_dev *dev;
  648. int port;
  649. char dev_name[16];
  650. struct device_attribute port_attr;
  651. enum mlx4_port_type tmp_type;
  652. char dev_mtu_name[16];
  653. struct device_attribute port_mtu_attr;
  654. struct mlx4_mac_table mac_table;
  655. struct mlx4_vlan_table vlan_table;
  656. int base_qpn;
  657. };
  658. struct mlx4_sense {
  659. struct mlx4_dev *dev;
  660. u8 do_sense_port[MLX4_MAX_PORTS + 1];
  661. u8 sense_allowed[MLX4_MAX_PORTS + 1];
  662. struct delayed_work sense_poll;
  663. };
  664. struct mlx4_msix_ctl {
  665. u64 pool_bm;
  666. struct mutex pool_lock;
  667. };
  668. struct mlx4_steer {
  669. struct list_head promisc_qps[MLX4_NUM_STEERS];
  670. struct list_head steer_entries[MLX4_NUM_STEERS];
  671. };
  672. enum {
  673. MLX4_PCI_DEV_IS_VF = 1 << 0,
  674. MLX4_PCI_DEV_FORCE_SENSE_PORT = 1 << 1,
  675. };
  676. struct mlx4_priv {
  677. struct mlx4_dev dev;
  678. struct list_head dev_list;
  679. struct list_head ctx_list;
  680. spinlock_t ctx_lock;
  681. int pci_dev_data;
  682. struct list_head pgdir_list;
  683. struct mutex pgdir_mutex;
  684. struct mlx4_fw fw;
  685. struct mlx4_cmd cmd;
  686. struct mlx4_mfunc mfunc;
  687. struct mlx4_bitmap pd_bitmap;
  688. struct mlx4_bitmap xrcd_bitmap;
  689. struct mlx4_uar_table uar_table;
  690. struct mlx4_mr_table mr_table;
  691. struct mlx4_cq_table cq_table;
  692. struct mlx4_eq_table eq_table;
  693. struct mlx4_srq_table srq_table;
  694. struct mlx4_qp_table qp_table;
  695. struct mlx4_mcg_table mcg_table;
  696. struct mlx4_bitmap counters_bitmap;
  697. struct mlx4_catas_err catas_err;
  698. void __iomem *clr_base;
  699. struct mlx4_uar driver_uar;
  700. void __iomem *kar;
  701. struct mlx4_port_info port[MLX4_MAX_PORTS + 1];
  702. struct mlx4_sense sense;
  703. struct mutex port_mutex;
  704. struct mlx4_msix_ctl msix_ctl;
  705. struct mlx4_steer *steer;
  706. struct list_head bf_list;
  707. struct mutex bf_mutex;
  708. struct io_mapping *bf_mapping;
  709. void __iomem *clock_mapping;
  710. int reserved_mtts;
  711. int fs_hash_mode;
  712. u8 virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS];
  713. __be64 slave_node_guids[MLX4_MFUNC_MAX];
  714. atomic_t opreq_count;
  715. struct work_struct opreq_task;
  716. };
  717. static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev)
  718. {
  719. return container_of(dev, struct mlx4_priv, dev);
  720. }
  721. #define MLX4_SENSE_RANGE (HZ * 3)
  722. extern struct workqueue_struct *mlx4_wq;
  723. u32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap);
  724. void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj);
  725. u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt, int align);
  726. void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt);
  727. u32 mlx4_bitmap_avail(struct mlx4_bitmap *bitmap);
  728. int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
  729. u32 reserved_bot, u32 resetrved_top);
  730. void mlx4_bitmap_cleanup(struct mlx4_bitmap *bitmap);
  731. int mlx4_reset(struct mlx4_dev *dev);
  732. int mlx4_alloc_eq_table(struct mlx4_dev *dev);
  733. void mlx4_free_eq_table(struct mlx4_dev *dev);
  734. int mlx4_init_pd_table(struct mlx4_dev *dev);
  735. int mlx4_init_xrcd_table(struct mlx4_dev *dev);
  736. int mlx4_init_uar_table(struct mlx4_dev *dev);
  737. int mlx4_init_mr_table(struct mlx4_dev *dev);
  738. int mlx4_init_eq_table(struct mlx4_dev *dev);
  739. int mlx4_init_cq_table(struct mlx4_dev *dev);
  740. int mlx4_init_qp_table(struct mlx4_dev *dev);
  741. int mlx4_init_srq_table(struct mlx4_dev *dev);
  742. int mlx4_init_mcg_table(struct mlx4_dev *dev);
  743. void mlx4_cleanup_pd_table(struct mlx4_dev *dev);
  744. void mlx4_cleanup_xrcd_table(struct mlx4_dev *dev);
  745. void mlx4_cleanup_uar_table(struct mlx4_dev *dev);
  746. void mlx4_cleanup_mr_table(struct mlx4_dev *dev);
  747. void mlx4_cleanup_eq_table(struct mlx4_dev *dev);
  748. void mlx4_cleanup_cq_table(struct mlx4_dev *dev);
  749. void mlx4_cleanup_qp_table(struct mlx4_dev *dev);
  750. void mlx4_cleanup_srq_table(struct mlx4_dev *dev);
  751. void mlx4_cleanup_mcg_table(struct mlx4_dev *dev);
  752. int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn);
  753. void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn);
  754. int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn);
  755. void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn);
  756. int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn);
  757. void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn);
  758. int __mlx4_mpt_reserve(struct mlx4_dev *dev);
  759. void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index);
  760. int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index);
  761. void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index);
  762. u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order);
  763. void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order);
  764. int mlx4_WRITE_MTT_wrapper(struct mlx4_dev *dev, int slave,
  765. struct mlx4_vhcr *vhcr,
  766. struct mlx4_cmd_mailbox *inbox,
  767. struct mlx4_cmd_mailbox *outbox,
  768. struct mlx4_cmd_info *cmd);
  769. int mlx4_SYNC_TPT_wrapper(struct mlx4_dev *dev, int slave,
  770. struct mlx4_vhcr *vhcr,
  771. struct mlx4_cmd_mailbox *inbox,
  772. struct mlx4_cmd_mailbox *outbox,
  773. struct mlx4_cmd_info *cmd);
  774. int mlx4_SW2HW_MPT_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_HW2SW_MPT_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_QUERY_MPT_wrapper(struct mlx4_dev *dev, int slave,
  785. struct mlx4_vhcr *vhcr,
  786. struct mlx4_cmd_mailbox *inbox,
  787. struct mlx4_cmd_mailbox *outbox,
  788. struct mlx4_cmd_info *cmd);
  789. int mlx4_SW2HW_EQ_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_DMA_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_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
  800. int *base);
  801. void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
  802. int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  803. void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  804. int __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
  805. int start_index, int npages, u64 *page_list);
  806. int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx);
  807. void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx);
  808. int __mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn);
  809. void __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn);
  810. void mlx4_start_catas_poll(struct mlx4_dev *dev);
  811. void mlx4_stop_catas_poll(struct mlx4_dev *dev);
  812. void mlx4_catas_init(void);
  813. int mlx4_restart_one(struct pci_dev *pdev);
  814. int mlx4_register_device(struct mlx4_dev *dev);
  815. void mlx4_unregister_device(struct mlx4_dev *dev);
  816. void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type,
  817. unsigned long param);
  818. struct mlx4_dev_cap;
  819. struct mlx4_init_hca_param;
  820. u64 mlx4_make_profile(struct mlx4_dev *dev,
  821. struct mlx4_profile *request,
  822. struct mlx4_dev_cap *dev_cap,
  823. struct mlx4_init_hca_param *init_hca);
  824. void mlx4_master_comm_channel(struct work_struct *work);
  825. void mlx4_gen_slave_eqe(struct work_struct *work);
  826. void mlx4_master_handle_slave_flr(struct work_struct *work);
  827. int mlx4_ALLOC_RES_wrapper(struct mlx4_dev *dev, int slave,
  828. struct mlx4_vhcr *vhcr,
  829. struct mlx4_cmd_mailbox *inbox,
  830. struct mlx4_cmd_mailbox *outbox,
  831. struct mlx4_cmd_info *cmd);
  832. int mlx4_FREE_RES_wrapper(struct mlx4_dev *dev, int slave,
  833. struct mlx4_vhcr *vhcr,
  834. struct mlx4_cmd_mailbox *inbox,
  835. struct mlx4_cmd_mailbox *outbox,
  836. struct mlx4_cmd_info *cmd);
  837. int mlx4_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave,
  838. struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox,
  839. struct mlx4_cmd_mailbox *outbox,
  840. struct mlx4_cmd_info *cmd);
  841. int mlx4_COMM_INT_wrapper(struct mlx4_dev *dev, int slave,
  842. struct mlx4_vhcr *vhcr,
  843. struct mlx4_cmd_mailbox *inbox,
  844. struct mlx4_cmd_mailbox *outbox,
  845. struct mlx4_cmd_info *cmd);
  846. int mlx4_HW2SW_EQ_wrapper(struct mlx4_dev *dev, int slave,
  847. struct mlx4_vhcr *vhcr,
  848. struct mlx4_cmd_mailbox *inbox,
  849. struct mlx4_cmd_mailbox *outbox,
  850. struct mlx4_cmd_info *cmd);
  851. int mlx4_QUERY_EQ_wrapper(struct mlx4_dev *dev, int slave,
  852. struct mlx4_vhcr *vhcr,
  853. struct mlx4_cmd_mailbox *inbox,
  854. struct mlx4_cmd_mailbox *outbox,
  855. struct mlx4_cmd_info *cmd);
  856. int mlx4_SW2HW_CQ_wrapper(struct mlx4_dev *dev, int slave,
  857. struct mlx4_vhcr *vhcr,
  858. struct mlx4_cmd_mailbox *inbox,
  859. struct mlx4_cmd_mailbox *outbox,
  860. struct mlx4_cmd_info *cmd);
  861. int mlx4_HW2SW_CQ_wrapper(struct mlx4_dev *dev, int slave,
  862. struct mlx4_vhcr *vhcr,
  863. struct mlx4_cmd_mailbox *inbox,
  864. struct mlx4_cmd_mailbox *outbox,
  865. struct mlx4_cmd_info *cmd);
  866. int mlx4_QUERY_CQ_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_MODIFY_CQ_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_SW2HW_SRQ_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_HW2SW_SRQ_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_QUERY_SRQ_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_ARM_SRQ_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_GEN_QP_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_RST2INIT_QP_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_INIT2INIT_QP_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_INIT2RTR_QP_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_RTR2RTS_QP_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_RTS2RTS_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_SQERR2RTS_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_2ERR_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_RTS2SQD_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_SQD2SQD_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_SQD2RTS_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_2RST_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_QUERY_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_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe);
  962. int mlx4_cmd_init(struct mlx4_dev *dev);
  963. void mlx4_cmd_cleanup(struct mlx4_dev *dev);
  964. int mlx4_multi_func_init(struct mlx4_dev *dev);
  965. void mlx4_multi_func_cleanup(struct mlx4_dev *dev);
  966. void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param);
  967. int mlx4_cmd_use_events(struct mlx4_dev *dev);
  968. void mlx4_cmd_use_polling(struct mlx4_dev *dev);
  969. int mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param,
  970. unsigned long timeout);
  971. void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn);
  972. void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type);
  973. void mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type);
  974. void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type);
  975. void mlx4_handle_catas_err(struct mlx4_dev *dev);
  976. int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
  977. enum mlx4_port_type *type);
  978. void mlx4_do_sense_ports(struct mlx4_dev *dev,
  979. enum mlx4_port_type *stype,
  980. enum mlx4_port_type *defaults);
  981. void mlx4_start_sense(struct mlx4_dev *dev);
  982. void mlx4_stop_sense(struct mlx4_dev *dev);
  983. void mlx4_sense_init(struct mlx4_dev *dev);
  984. int mlx4_check_port_params(struct mlx4_dev *dev,
  985. enum mlx4_port_type *port_type);
  986. int mlx4_change_port_types(struct mlx4_dev *dev,
  987. enum mlx4_port_type *port_types);
  988. void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table);
  989. void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
  990. void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, int index);
  991. int __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
  992. int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz);
  993. /* resource tracker functions*/
  994. int mlx4_get_slave_from_resource_id(struct mlx4_dev *dev,
  995. enum mlx4_resource resource_type,
  996. u64 resource_id, int *slave);
  997. void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave_id);
  998. int mlx4_init_resource_tracker(struct mlx4_dev *dev);
  999. void mlx4_free_resource_tracker(struct mlx4_dev *dev,
  1000. enum mlx4_res_tracker_free_type type);
  1001. int mlx4_QUERY_FW_wrapper(struct mlx4_dev *dev, int slave,
  1002. struct mlx4_vhcr *vhcr,
  1003. struct mlx4_cmd_mailbox *inbox,
  1004. struct mlx4_cmd_mailbox *outbox,
  1005. struct mlx4_cmd_info *cmd);
  1006. int mlx4_SET_PORT_wrapper(struct mlx4_dev *dev, int slave,
  1007. struct mlx4_vhcr *vhcr,
  1008. struct mlx4_cmd_mailbox *inbox,
  1009. struct mlx4_cmd_mailbox *outbox,
  1010. struct mlx4_cmd_info *cmd);
  1011. int mlx4_INIT_PORT_wrapper(struct mlx4_dev *dev, int slave,
  1012. struct mlx4_vhcr *vhcr,
  1013. struct mlx4_cmd_mailbox *inbox,
  1014. struct mlx4_cmd_mailbox *outbox,
  1015. struct mlx4_cmd_info *cmd);
  1016. int mlx4_CLOSE_PORT_wrapper(struct mlx4_dev *dev, int slave,
  1017. struct mlx4_vhcr *vhcr,
  1018. struct mlx4_cmd_mailbox *inbox,
  1019. struct mlx4_cmd_mailbox *outbox,
  1020. struct mlx4_cmd_info *cmd);
  1021. int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave,
  1022. struct mlx4_vhcr *vhcr,
  1023. struct mlx4_cmd_mailbox *inbox,
  1024. struct mlx4_cmd_mailbox *outbox,
  1025. struct mlx4_cmd_info *cmd);
  1026. int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave,
  1027. struct mlx4_vhcr *vhcr,
  1028. struct mlx4_cmd_mailbox *inbox,
  1029. struct mlx4_cmd_mailbox *outbox,
  1030. struct mlx4_cmd_info *cmd);
  1031. int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps);
  1032. int mlx4_get_slave_pkey_gid_tbl_len(struct mlx4_dev *dev, u8 port,
  1033. int *gid_tbl_len, int *pkey_tbl_len);
  1034. int mlx4_QP_ATTACH_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_PROMISC_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_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1045. enum mlx4_protocol prot, enum mlx4_steer_type steer);
  1046. int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1047. int block_mcast_loopback, enum mlx4_protocol prot,
  1048. enum mlx4_steer_type steer);
  1049. int mlx4_trans_to_dmfs_attach(struct mlx4_dev *dev, struct mlx4_qp *qp,
  1050. u8 gid[16], u8 port,
  1051. int block_mcast_loopback,
  1052. enum mlx4_protocol prot, u64 *reg_id);
  1053. int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave,
  1054. struct mlx4_vhcr *vhcr,
  1055. struct mlx4_cmd_mailbox *inbox,
  1056. struct mlx4_cmd_mailbox *outbox,
  1057. struct mlx4_cmd_info *cmd);
  1058. int mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave,
  1059. struct mlx4_vhcr *vhcr,
  1060. struct mlx4_cmd_mailbox *inbox,
  1061. struct mlx4_cmd_mailbox *outbox,
  1062. struct mlx4_cmd_info *cmd);
  1063. int mlx4_common_set_vlan_fltr(struct mlx4_dev *dev, int function,
  1064. int port, void *buf);
  1065. int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave, u32 in_mod,
  1066. struct mlx4_cmd_mailbox *outbox);
  1067. int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave,
  1068. struct mlx4_vhcr *vhcr,
  1069. struct mlx4_cmd_mailbox *inbox,
  1070. struct mlx4_cmd_mailbox *outbox,
  1071. struct mlx4_cmd_info *cmd);
  1072. int mlx4_PKEY_TABLE_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_QUERY_IF_STAT_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_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
  1083. struct mlx4_vhcr *vhcr,
  1084. struct mlx4_cmd_mailbox *inbox,
  1085. struct mlx4_cmd_mailbox *outbox,
  1086. struct mlx4_cmd_info *cmd);
  1087. int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
  1088. struct mlx4_vhcr *vhcr,
  1089. struct mlx4_cmd_mailbox *inbox,
  1090. struct mlx4_cmd_mailbox *outbox,
  1091. struct mlx4_cmd_info *cmd);
  1092. int mlx4_get_mgm_entry_size(struct mlx4_dev *dev);
  1093. int mlx4_get_qp_per_mgm(struct mlx4_dev *dev);
  1094. static inline void set_param_l(u64 *arg, u32 val)
  1095. {
  1096. *arg = (*arg & 0xffffffff00000000ULL) | (u64) val;
  1097. }
  1098. static inline void set_param_h(u64 *arg, u32 val)
  1099. {
  1100. *arg = (*arg & 0xffffffff) | ((u64) val << 32);
  1101. }
  1102. static inline u32 get_param_l(u64 *arg)
  1103. {
  1104. return (u32) (*arg & 0xffffffff);
  1105. }
  1106. static inline u32 get_param_h(u64 *arg)
  1107. {
  1108. return (u32)(*arg >> 32);
  1109. }
  1110. static inline spinlock_t *mlx4_tlock(struct mlx4_dev *dev)
  1111. {
  1112. return &mlx4_priv(dev)->mfunc.master.res_tracker.lock;
  1113. }
  1114. #define NOT_MASKED_PD_BITS 17
  1115. void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work);
  1116. #endif /* MLX4_H */