mlx4.h 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426
  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/interrupt.h>
  45. #include <linux/spinlock.h>
  46. #include <linux/mlx4/device.h>
  47. #include <linux/mlx4/driver.h>
  48. #include <linux/mlx4/doorbell.h>
  49. #include <linux/mlx4/cmd.h>
  50. #define DRV_NAME "mlx4_core"
  51. #define PFX DRV_NAME ": "
  52. #define DRV_VERSION "2.2-1"
  53. #define DRV_RELDATE "Feb, 2014"
  54. #define MLX4_FS_UDP_UC_EN (1 << 1)
  55. #define MLX4_FS_TCP_UC_EN (1 << 2)
  56. #define MLX4_FS_NUM_OF_L2_ADDR 8
  57. #define MLX4_FS_MGM_LOG_ENTRY_SIZE 7
  58. #define MLX4_FS_NUM_MCG (1 << 17)
  59. #define INIT_HCA_TPT_MW_ENABLE (1 << 7)
  60. struct mlx4_set_port_prio2tc_context {
  61. u8 prio2tc[4];
  62. };
  63. struct mlx4_port_scheduler_tc_cfg_be {
  64. __be16 pg;
  65. __be16 bw_precentage;
  66. __be16 max_bw_units; /* 3-100Mbps, 4-1Gbps, other values - reserved */
  67. __be16 max_bw_value;
  68. };
  69. struct mlx4_set_port_scheduler_context {
  70. struct mlx4_port_scheduler_tc_cfg_be tc[MLX4_NUM_TC];
  71. };
  72. enum {
  73. MLX4_HCR_BASE = 0x80680,
  74. MLX4_HCR_SIZE = 0x0001c,
  75. MLX4_CLR_INT_SIZE = 0x00008,
  76. MLX4_SLAVE_COMM_BASE = 0x0,
  77. MLX4_COMM_PAGESIZE = 0x1000,
  78. MLX4_CLOCK_SIZE = 0x00008
  79. };
  80. enum {
  81. MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE = 10,
  82. MLX4_MIN_MGM_LOG_ENTRY_SIZE = 7,
  83. MLX4_MAX_MGM_LOG_ENTRY_SIZE = 12,
  84. MLX4_MAX_QP_PER_MGM = 4 * ((1 << MLX4_MAX_MGM_LOG_ENTRY_SIZE) / 16 - 2),
  85. MLX4_MTT_ENTRY_PER_SEG = 8,
  86. };
  87. enum {
  88. MLX4_NUM_PDS = 1 << 15
  89. };
  90. enum {
  91. MLX4_CMPT_TYPE_QP = 0,
  92. MLX4_CMPT_TYPE_SRQ = 1,
  93. MLX4_CMPT_TYPE_CQ = 2,
  94. MLX4_CMPT_TYPE_EQ = 3,
  95. MLX4_CMPT_NUM_TYPE
  96. };
  97. enum {
  98. MLX4_CMPT_SHIFT = 24,
  99. MLX4_NUM_CMPTS = MLX4_CMPT_NUM_TYPE << MLX4_CMPT_SHIFT
  100. };
  101. enum mlx4_mpt_state {
  102. MLX4_MPT_DISABLED = 0,
  103. MLX4_MPT_EN_HW,
  104. MLX4_MPT_EN_SW
  105. };
  106. #define MLX4_COMM_TIME 10000
  107. enum {
  108. MLX4_COMM_CMD_RESET,
  109. MLX4_COMM_CMD_VHCR0,
  110. MLX4_COMM_CMD_VHCR1,
  111. MLX4_COMM_CMD_VHCR2,
  112. MLX4_COMM_CMD_VHCR_EN,
  113. MLX4_COMM_CMD_VHCR_POST,
  114. MLX4_COMM_CMD_FLR = 254
  115. };
  116. enum {
  117. MLX4_VF_SMI_DISABLED,
  118. MLX4_VF_SMI_ENABLED
  119. };
  120. /*The flag indicates that the slave should delay the RESET cmd*/
  121. #define MLX4_DELAY_RESET_SLAVE 0xbbbbbbb
  122. /*indicates how many retries will be done if we are in the middle of FLR*/
  123. #define NUM_OF_RESET_RETRIES 10
  124. #define SLEEP_TIME_IN_RESET (2 * 1000)
  125. enum mlx4_resource {
  126. RES_QP,
  127. RES_CQ,
  128. RES_SRQ,
  129. RES_XRCD,
  130. RES_MPT,
  131. RES_MTT,
  132. RES_MAC,
  133. RES_VLAN,
  134. RES_EQ,
  135. RES_COUNTER,
  136. RES_FS_RULE,
  137. MLX4_NUM_OF_RESOURCE_TYPE
  138. };
  139. enum mlx4_alloc_mode {
  140. RES_OP_RESERVE,
  141. RES_OP_RESERVE_AND_MAP,
  142. RES_OP_MAP_ICM,
  143. };
  144. enum mlx4_res_tracker_free_type {
  145. RES_TR_FREE_ALL,
  146. RES_TR_FREE_SLAVES_ONLY,
  147. RES_TR_FREE_STRUCTS_ONLY,
  148. };
  149. /*
  150. *Virtual HCR structures.
  151. * mlx4_vhcr is the sw representation, in machine endianess
  152. *
  153. * mlx4_vhcr_cmd is the formalized structure, the one that is passed
  154. * to FW to go through communication channel.
  155. * It is big endian, and has the same structure as the physical HCR
  156. * used by command interface
  157. */
  158. struct mlx4_vhcr {
  159. u64 in_param;
  160. u64 out_param;
  161. u32 in_modifier;
  162. u32 errno;
  163. u16 op;
  164. u16 token;
  165. u8 op_modifier;
  166. u8 e_bit;
  167. };
  168. struct mlx4_vhcr_cmd {
  169. __be64 in_param;
  170. __be32 in_modifier;
  171. __be64 out_param;
  172. __be16 token;
  173. u16 reserved;
  174. u8 status;
  175. u8 flags;
  176. __be16 opcode;
  177. };
  178. struct mlx4_cmd_info {
  179. u16 opcode;
  180. bool has_inbox;
  181. bool has_outbox;
  182. bool out_is_imm;
  183. bool encode_slave_id;
  184. int (*verify)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr,
  185. struct mlx4_cmd_mailbox *inbox);
  186. int (*wrapper)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr,
  187. struct mlx4_cmd_mailbox *inbox,
  188. struct mlx4_cmd_mailbox *outbox,
  189. struct mlx4_cmd_info *cmd);
  190. };
  191. #ifdef CONFIG_MLX4_DEBUG
  192. extern int mlx4_debug_level;
  193. #else /* CONFIG_MLX4_DEBUG */
  194. #define mlx4_debug_level (0)
  195. #endif /* CONFIG_MLX4_DEBUG */
  196. #define mlx4_dbg(mdev, format, ...) \
  197. do { \
  198. if (mlx4_debug_level) \
  199. dev_printk(KERN_DEBUG, &(mdev)->pdev->dev, format, \
  200. ##__VA_ARGS__); \
  201. } while (0)
  202. #define mlx4_err(mdev, format, ...) \
  203. dev_err(&(mdev)->pdev->dev, format, ##__VA_ARGS__)
  204. #define mlx4_info(mdev, format, ...) \
  205. dev_info(&(mdev)->pdev->dev, format, ##__VA_ARGS__)
  206. #define mlx4_warn(mdev, format, ...) \
  207. dev_warn(&(mdev)->pdev->dev, format, ##__VA_ARGS__)
  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. u32 effective_len;
  220. spinlock_t lock;
  221. unsigned long *table;
  222. };
  223. struct mlx4_buddy {
  224. unsigned long **bits;
  225. unsigned int *num_free;
  226. u32 max_order;
  227. spinlock_t lock;
  228. };
  229. struct mlx4_icm;
  230. struct mlx4_icm_table {
  231. u64 virt;
  232. int num_icm;
  233. u32 num_obj;
  234. int obj_size;
  235. int lowmem;
  236. int coherent;
  237. struct mutex mutex;
  238. struct mlx4_icm **icm;
  239. };
  240. #define MLX4_MPT_FLAG_SW_OWNS (0xfUL << 28)
  241. #define MLX4_MPT_FLAG_FREE (0x3UL << 28)
  242. #define MLX4_MPT_FLAG_MIO (1 << 17)
  243. #define MLX4_MPT_FLAG_BIND_ENABLE (1 << 15)
  244. #define MLX4_MPT_FLAG_PHYSICAL (1 << 9)
  245. #define MLX4_MPT_FLAG_REGION (1 << 8)
  246. #define MLX4_MPT_PD_MASK (0x1FFFFUL)
  247. #define MLX4_MPT_PD_VF_MASK (0xFE0000UL)
  248. #define MLX4_MPT_PD_FLAG_FAST_REG (1 << 27)
  249. #define MLX4_MPT_PD_FLAG_RAE (1 << 28)
  250. #define MLX4_MPT_PD_FLAG_EN_INV (3 << 24)
  251. #define MLX4_MPT_QP_FLAG_BOUND_QP (1 << 7)
  252. #define MLX4_MPT_STATUS_SW 0xF0
  253. #define MLX4_MPT_STATUS_HW 0x00
  254. #define MLX4_CQE_SIZE_MASK_STRIDE 0x3
  255. #define MLX4_EQE_SIZE_MASK_STRIDE 0x30
  256. /*
  257. * Must be packed because mtt_seg is 64 bits but only aligned to 32 bits.
  258. */
  259. struct mlx4_mpt_entry {
  260. __be32 flags;
  261. __be32 qpn;
  262. __be32 key;
  263. __be32 pd_flags;
  264. __be64 start;
  265. __be64 length;
  266. __be32 lkey;
  267. __be32 win_cnt;
  268. u8 reserved1[3];
  269. u8 mtt_rep;
  270. __be64 mtt_addr;
  271. __be32 mtt_sz;
  272. __be32 entity_size;
  273. __be32 first_byte_offset;
  274. } __packed;
  275. /*
  276. * Must be packed because start is 64 bits but only aligned to 32 bits.
  277. */
  278. struct mlx4_eq_context {
  279. __be32 flags;
  280. u16 reserved1[3];
  281. __be16 page_offset;
  282. u8 log_eq_size;
  283. u8 reserved2[4];
  284. u8 eq_period;
  285. u8 reserved3;
  286. u8 eq_max_count;
  287. u8 reserved4[3];
  288. u8 intr;
  289. u8 log_page_size;
  290. u8 reserved5[2];
  291. u8 mtt_base_addr_h;
  292. __be32 mtt_base_addr_l;
  293. u32 reserved6[2];
  294. __be32 consumer_index;
  295. __be32 producer_index;
  296. u32 reserved7[4];
  297. };
  298. struct mlx4_cq_context {
  299. __be32 flags;
  300. u16 reserved1[3];
  301. __be16 page_offset;
  302. __be32 logsize_usrpage;
  303. __be16 cq_period;
  304. __be16 cq_max_count;
  305. u8 reserved2[3];
  306. u8 comp_eqn;
  307. u8 log_page_size;
  308. u8 reserved3[2];
  309. u8 mtt_base_addr_h;
  310. __be32 mtt_base_addr_l;
  311. __be32 last_notified_index;
  312. __be32 solicit_producer_index;
  313. __be32 consumer_index;
  314. __be32 producer_index;
  315. u32 reserved4[2];
  316. __be64 db_rec_addr;
  317. };
  318. struct mlx4_srq_context {
  319. __be32 state_logsize_srqn;
  320. u8 logstride;
  321. u8 reserved1;
  322. __be16 xrcd;
  323. __be32 pg_offset_cqn;
  324. u32 reserved2;
  325. u8 log_page_size;
  326. u8 reserved3[2];
  327. u8 mtt_base_addr_h;
  328. __be32 mtt_base_addr_l;
  329. __be32 pd;
  330. __be16 limit_watermark;
  331. __be16 wqe_cnt;
  332. u16 reserved4;
  333. __be16 wqe_counter;
  334. u32 reserved5;
  335. __be64 db_rec_addr;
  336. };
  337. struct mlx4_eq_tasklet {
  338. struct list_head list;
  339. struct list_head process_list;
  340. struct tasklet_struct task;
  341. /* lock on completion tasklet list */
  342. spinlock_t lock;
  343. };
  344. struct mlx4_eq {
  345. struct mlx4_dev *dev;
  346. void __iomem *doorbell;
  347. int eqn;
  348. u32 cons_index;
  349. u16 irq;
  350. u16 have_irq;
  351. int nent;
  352. struct mlx4_buf_list *page_list;
  353. struct mlx4_mtt mtt;
  354. struct mlx4_eq_tasklet tasklet_ctx;
  355. };
  356. struct mlx4_slave_eqe {
  357. u8 type;
  358. u8 port;
  359. u32 param;
  360. };
  361. struct mlx4_slave_event_eq_info {
  362. int eqn;
  363. u16 token;
  364. };
  365. struct mlx4_profile {
  366. int num_qp;
  367. int rdmarc_per_qp;
  368. int num_srq;
  369. int num_cq;
  370. int num_mcg;
  371. int num_mpt;
  372. unsigned num_mtt;
  373. };
  374. struct mlx4_fw {
  375. u64 clr_int_base;
  376. u64 catas_offset;
  377. u64 comm_base;
  378. u64 clock_offset;
  379. struct mlx4_icm *fw_icm;
  380. struct mlx4_icm *aux_icm;
  381. u32 catas_size;
  382. u16 fw_pages;
  383. u8 clr_int_bar;
  384. u8 catas_bar;
  385. u8 comm_bar;
  386. u8 clock_bar;
  387. };
  388. struct mlx4_comm {
  389. u32 slave_write;
  390. u32 slave_read;
  391. };
  392. enum {
  393. MLX4_MCAST_CONFIG = 0,
  394. MLX4_MCAST_DISABLE = 1,
  395. MLX4_MCAST_ENABLE = 2,
  396. };
  397. #define VLAN_FLTR_SIZE 128
  398. struct mlx4_vlan_fltr {
  399. __be32 entry[VLAN_FLTR_SIZE];
  400. };
  401. struct mlx4_mcast_entry {
  402. struct list_head list;
  403. u64 addr;
  404. };
  405. struct mlx4_promisc_qp {
  406. struct list_head list;
  407. u32 qpn;
  408. };
  409. struct mlx4_steer_index {
  410. struct list_head list;
  411. unsigned int index;
  412. struct list_head duplicates;
  413. };
  414. #define MLX4_EVENT_TYPES_NUM 64
  415. struct mlx4_slave_state {
  416. u8 comm_toggle;
  417. u8 last_cmd;
  418. u8 init_port_mask;
  419. bool active;
  420. bool old_vlan_api;
  421. u8 function;
  422. dma_addr_t vhcr_dma;
  423. u16 mtu[MLX4_MAX_PORTS + 1];
  424. __be32 ib_cap_mask[MLX4_MAX_PORTS + 1];
  425. struct mlx4_slave_eqe eq[MLX4_MFUNC_MAX_EQES];
  426. struct list_head mcast_filters[MLX4_MAX_PORTS + 1];
  427. struct mlx4_vlan_fltr *vlan_filter[MLX4_MAX_PORTS + 1];
  428. /* event type to eq number lookup */
  429. struct mlx4_slave_event_eq_info event_eq[MLX4_EVENT_TYPES_NUM];
  430. u16 eq_pi;
  431. u16 eq_ci;
  432. spinlock_t lock;
  433. /*initialized via the kzalloc*/
  434. u8 is_slave_going_down;
  435. u32 cookie;
  436. enum slave_port_state port_state[MLX4_MAX_PORTS + 1];
  437. };
  438. #define MLX4_VGT 4095
  439. #define NO_INDX (-1)
  440. struct mlx4_vport_state {
  441. u64 mac;
  442. u16 default_vlan;
  443. u8 default_qos;
  444. u32 tx_rate;
  445. bool spoofchk;
  446. u32 link_state;
  447. };
  448. struct mlx4_vf_admin_state {
  449. struct mlx4_vport_state vport[MLX4_MAX_PORTS + 1];
  450. u8 enable_smi[MLX4_MAX_PORTS + 1];
  451. };
  452. struct mlx4_vport_oper_state {
  453. struct mlx4_vport_state state;
  454. int mac_idx;
  455. int vlan_idx;
  456. };
  457. struct mlx4_vf_oper_state {
  458. struct mlx4_vport_oper_state vport[MLX4_MAX_PORTS + 1];
  459. u8 smi_enabled[MLX4_MAX_PORTS + 1];
  460. };
  461. struct slave_list {
  462. struct mutex mutex;
  463. struct list_head res_list[MLX4_NUM_OF_RESOURCE_TYPE];
  464. };
  465. struct resource_allocator {
  466. spinlock_t alloc_lock; /* protect quotas */
  467. union {
  468. int res_reserved;
  469. int res_port_rsvd[MLX4_MAX_PORTS];
  470. };
  471. union {
  472. int res_free;
  473. int res_port_free[MLX4_MAX_PORTS];
  474. };
  475. int *quota;
  476. int *allocated;
  477. int *guaranteed;
  478. };
  479. struct mlx4_resource_tracker {
  480. spinlock_t lock;
  481. /* tree for each resources */
  482. struct rb_root res_tree[MLX4_NUM_OF_RESOURCE_TYPE];
  483. /* num_of_slave's lists, one per slave */
  484. struct slave_list *slave_list;
  485. struct resource_allocator res_alloc[MLX4_NUM_OF_RESOURCE_TYPE];
  486. };
  487. #define SLAVE_EVENT_EQ_SIZE 128
  488. struct mlx4_slave_event_eq {
  489. u32 eqn;
  490. u32 cons;
  491. u32 prod;
  492. spinlock_t event_lock;
  493. struct mlx4_eqe event_eqe[SLAVE_EVENT_EQ_SIZE];
  494. };
  495. struct mlx4_master_qp0_state {
  496. int proxy_qp0_active;
  497. int qp0_active;
  498. int port_active;
  499. };
  500. struct mlx4_mfunc_master_ctx {
  501. struct mlx4_slave_state *slave_state;
  502. struct mlx4_vf_admin_state *vf_admin;
  503. struct mlx4_vf_oper_state *vf_oper;
  504. struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1];
  505. int init_port_ref[MLX4_MAX_PORTS + 1];
  506. u16 max_mtu[MLX4_MAX_PORTS + 1];
  507. int disable_mcast_ref[MLX4_MAX_PORTS + 1];
  508. struct mlx4_resource_tracker res_tracker;
  509. struct workqueue_struct *comm_wq;
  510. struct work_struct comm_work;
  511. struct work_struct slave_event_work;
  512. struct work_struct slave_flr_event_work;
  513. spinlock_t slave_state_lock;
  514. __be32 comm_arm_bit_vector[4];
  515. struct mlx4_eqe cmd_eqe;
  516. struct mlx4_slave_event_eq slave_eq;
  517. struct mutex gen_eqe_mutex[MLX4_MFUNC_MAX];
  518. };
  519. struct mlx4_mfunc {
  520. struct mlx4_comm __iomem *comm;
  521. struct mlx4_vhcr_cmd *vhcr;
  522. dma_addr_t vhcr_dma;
  523. struct mlx4_mfunc_master_ctx master;
  524. };
  525. #define MGM_QPN_MASK 0x00FFFFFF
  526. #define MGM_BLCK_LB_BIT 30
  527. struct mlx4_mgm {
  528. __be32 next_gid_index;
  529. __be32 members_count;
  530. u32 reserved[2];
  531. u8 gid[16];
  532. __be32 qp[MLX4_MAX_QP_PER_MGM];
  533. };
  534. struct mlx4_cmd {
  535. struct pci_pool *pool;
  536. void __iomem *hcr;
  537. struct mutex hcr_mutex;
  538. struct mutex slave_cmd_mutex;
  539. struct semaphore poll_sem;
  540. struct semaphore event_sem;
  541. int max_cmds;
  542. spinlock_t context_lock;
  543. int free_head;
  544. struct mlx4_cmd_context *context;
  545. u16 token_mask;
  546. u8 use_events;
  547. u8 toggle;
  548. u8 comm_toggle;
  549. u8 initialized;
  550. };
  551. enum {
  552. MLX4_VF_IMMED_VLAN_FLAG_VLAN = 1 << 0,
  553. MLX4_VF_IMMED_VLAN_FLAG_QOS = 1 << 1,
  554. MLX4_VF_IMMED_VLAN_FLAG_LINK_DISABLE = 1 << 2,
  555. };
  556. struct mlx4_vf_immed_vlan_work {
  557. struct work_struct work;
  558. struct mlx4_priv *priv;
  559. int flags;
  560. int slave;
  561. int vlan_ix;
  562. int orig_vlan_ix;
  563. u8 port;
  564. u8 qos;
  565. u16 vlan_id;
  566. u16 orig_vlan_id;
  567. };
  568. struct mlx4_uar_table {
  569. struct mlx4_bitmap bitmap;
  570. };
  571. struct mlx4_mr_table {
  572. struct mlx4_bitmap mpt_bitmap;
  573. struct mlx4_buddy mtt_buddy;
  574. u64 mtt_base;
  575. u64 mpt_base;
  576. struct mlx4_icm_table mtt_table;
  577. struct mlx4_icm_table dmpt_table;
  578. };
  579. struct mlx4_cq_table {
  580. struct mlx4_bitmap bitmap;
  581. spinlock_t lock;
  582. struct radix_tree_root tree;
  583. struct mlx4_icm_table table;
  584. struct mlx4_icm_table cmpt_table;
  585. };
  586. struct mlx4_eq_table {
  587. struct mlx4_bitmap bitmap;
  588. char *irq_names;
  589. void __iomem *clr_int;
  590. void __iomem **uar_map;
  591. u32 clr_mask;
  592. struct mlx4_eq *eq;
  593. struct mlx4_icm_table table;
  594. struct mlx4_icm_table cmpt_table;
  595. int have_irq;
  596. u8 inta_pin;
  597. };
  598. struct mlx4_srq_table {
  599. struct mlx4_bitmap bitmap;
  600. spinlock_t lock;
  601. struct radix_tree_root tree;
  602. struct mlx4_icm_table table;
  603. struct mlx4_icm_table cmpt_table;
  604. };
  605. enum mlx4_qp_table_zones {
  606. MLX4_QP_TABLE_ZONE_GENERAL,
  607. MLX4_QP_TABLE_ZONE_RSS,
  608. MLX4_QP_TABLE_ZONE_RAW_ETH,
  609. MLX4_QP_TABLE_ZONE_NUM
  610. };
  611. struct mlx4_qp_table {
  612. struct mlx4_bitmap *bitmap_gen;
  613. struct mlx4_zone_allocator *zones;
  614. u32 zones_uids[MLX4_QP_TABLE_ZONE_NUM];
  615. u32 rdmarc_base;
  616. int rdmarc_shift;
  617. spinlock_t lock;
  618. struct mlx4_icm_table qp_table;
  619. struct mlx4_icm_table auxc_table;
  620. struct mlx4_icm_table altc_table;
  621. struct mlx4_icm_table rdmarc_table;
  622. struct mlx4_icm_table cmpt_table;
  623. };
  624. struct mlx4_mcg_table {
  625. struct mutex mutex;
  626. struct mlx4_bitmap bitmap;
  627. struct mlx4_icm_table table;
  628. };
  629. struct mlx4_catas_err {
  630. u32 __iomem *map;
  631. struct timer_list timer;
  632. struct list_head list;
  633. };
  634. #define MLX4_MAX_MAC_NUM 128
  635. #define MLX4_MAC_TABLE_SIZE (MLX4_MAX_MAC_NUM << 3)
  636. struct mlx4_mac_table {
  637. __be64 entries[MLX4_MAX_MAC_NUM];
  638. int refs[MLX4_MAX_MAC_NUM];
  639. struct mutex mutex;
  640. int total;
  641. int max;
  642. };
  643. #define MLX4_ROCE_GID_ENTRY_SIZE 16
  644. struct mlx4_roce_gid_entry {
  645. u8 raw[MLX4_ROCE_GID_ENTRY_SIZE];
  646. };
  647. struct mlx4_roce_gid_table {
  648. struct mlx4_roce_gid_entry roce_gids[MLX4_ROCE_MAX_GIDS];
  649. struct mutex mutex;
  650. };
  651. #define MLX4_MAX_VLAN_NUM 128
  652. #define MLX4_VLAN_TABLE_SIZE (MLX4_MAX_VLAN_NUM << 2)
  653. struct mlx4_vlan_table {
  654. __be32 entries[MLX4_MAX_VLAN_NUM];
  655. int refs[MLX4_MAX_VLAN_NUM];
  656. struct mutex mutex;
  657. int total;
  658. int max;
  659. };
  660. #define SET_PORT_GEN_ALL_VALID 0x7
  661. #define SET_PORT_PROMISC_SHIFT 31
  662. #define SET_PORT_MC_PROMISC_SHIFT 30
  663. enum {
  664. MCAST_DIRECT_ONLY = 0,
  665. MCAST_DIRECT = 1,
  666. MCAST_DEFAULT = 2
  667. };
  668. struct mlx4_set_port_general_context {
  669. u8 reserved[3];
  670. u8 flags;
  671. u16 reserved2;
  672. __be16 mtu;
  673. u8 pptx;
  674. u8 pfctx;
  675. u16 reserved3;
  676. u8 pprx;
  677. u8 pfcrx;
  678. u16 reserved4;
  679. };
  680. struct mlx4_set_port_rqp_calc_context {
  681. __be32 base_qpn;
  682. u8 rererved;
  683. u8 n_mac;
  684. u8 n_vlan;
  685. u8 n_prio;
  686. u8 reserved2[3];
  687. u8 mac_miss;
  688. u8 intra_no_vlan;
  689. u8 no_vlan;
  690. u8 intra_vlan_miss;
  691. u8 vlan_miss;
  692. u8 reserved3[3];
  693. u8 no_vlan_prio;
  694. __be32 promisc;
  695. __be32 mcast;
  696. };
  697. struct mlx4_port_info {
  698. struct mlx4_dev *dev;
  699. int port;
  700. char dev_name[16];
  701. struct device_attribute port_attr;
  702. enum mlx4_port_type tmp_type;
  703. char dev_mtu_name[16];
  704. struct device_attribute port_mtu_attr;
  705. struct mlx4_mac_table mac_table;
  706. struct mlx4_vlan_table vlan_table;
  707. struct mlx4_roce_gid_table gid_table;
  708. int base_qpn;
  709. };
  710. struct mlx4_sense {
  711. struct mlx4_dev *dev;
  712. u8 do_sense_port[MLX4_MAX_PORTS + 1];
  713. u8 sense_allowed[MLX4_MAX_PORTS + 1];
  714. struct delayed_work sense_poll;
  715. };
  716. struct mlx4_msix_ctl {
  717. u64 pool_bm;
  718. struct mutex pool_lock;
  719. };
  720. struct mlx4_steer {
  721. struct list_head promisc_qps[MLX4_NUM_STEERS];
  722. struct list_head steer_entries[MLX4_NUM_STEERS];
  723. };
  724. enum {
  725. MLX4_PCI_DEV_IS_VF = 1 << 0,
  726. MLX4_PCI_DEV_FORCE_SENSE_PORT = 1 << 1,
  727. };
  728. enum {
  729. MLX4_NO_RR = 0,
  730. MLX4_USE_RR = 1,
  731. };
  732. struct mlx4_priv {
  733. struct mlx4_dev dev;
  734. struct list_head dev_list;
  735. struct list_head ctx_list;
  736. spinlock_t ctx_lock;
  737. int pci_dev_data;
  738. int removed;
  739. struct list_head pgdir_list;
  740. struct mutex pgdir_mutex;
  741. struct mlx4_fw fw;
  742. struct mlx4_cmd cmd;
  743. struct mlx4_mfunc mfunc;
  744. struct mlx4_bitmap pd_bitmap;
  745. struct mlx4_bitmap xrcd_bitmap;
  746. struct mlx4_uar_table uar_table;
  747. struct mlx4_mr_table mr_table;
  748. struct mlx4_cq_table cq_table;
  749. struct mlx4_eq_table eq_table;
  750. struct mlx4_srq_table srq_table;
  751. struct mlx4_qp_table qp_table;
  752. struct mlx4_mcg_table mcg_table;
  753. struct mlx4_bitmap counters_bitmap;
  754. struct mlx4_catas_err catas_err;
  755. void __iomem *clr_base;
  756. struct mlx4_uar driver_uar;
  757. void __iomem *kar;
  758. struct mlx4_port_info port[MLX4_MAX_PORTS + 1];
  759. struct mlx4_sense sense;
  760. struct mutex port_mutex;
  761. struct mlx4_msix_ctl msix_ctl;
  762. struct mlx4_steer *steer;
  763. struct list_head bf_list;
  764. struct mutex bf_mutex;
  765. struct io_mapping *bf_mapping;
  766. void __iomem *clock_mapping;
  767. int reserved_mtts;
  768. int fs_hash_mode;
  769. u8 virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS];
  770. __be64 slave_node_guids[MLX4_MFUNC_MAX];
  771. atomic_t opreq_count;
  772. struct work_struct opreq_task;
  773. };
  774. static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev)
  775. {
  776. return container_of(dev, struct mlx4_priv, dev);
  777. }
  778. #define MLX4_SENSE_RANGE (HZ * 3)
  779. extern struct workqueue_struct *mlx4_wq;
  780. u32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap);
  781. void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj, int use_rr);
  782. u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt,
  783. int align, u32 skip_mask);
  784. void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt,
  785. int use_rr);
  786. u32 mlx4_bitmap_avail(struct mlx4_bitmap *bitmap);
  787. int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
  788. u32 reserved_bot, u32 resetrved_top);
  789. void mlx4_bitmap_cleanup(struct mlx4_bitmap *bitmap);
  790. int mlx4_reset(struct mlx4_dev *dev);
  791. int mlx4_alloc_eq_table(struct mlx4_dev *dev);
  792. void mlx4_free_eq_table(struct mlx4_dev *dev);
  793. int mlx4_init_pd_table(struct mlx4_dev *dev);
  794. int mlx4_init_xrcd_table(struct mlx4_dev *dev);
  795. int mlx4_init_uar_table(struct mlx4_dev *dev);
  796. int mlx4_init_mr_table(struct mlx4_dev *dev);
  797. int mlx4_init_eq_table(struct mlx4_dev *dev);
  798. int mlx4_init_cq_table(struct mlx4_dev *dev);
  799. int mlx4_init_qp_table(struct mlx4_dev *dev);
  800. int mlx4_init_srq_table(struct mlx4_dev *dev);
  801. int mlx4_init_mcg_table(struct mlx4_dev *dev);
  802. void mlx4_cleanup_pd_table(struct mlx4_dev *dev);
  803. void mlx4_cleanup_xrcd_table(struct mlx4_dev *dev);
  804. void mlx4_cleanup_uar_table(struct mlx4_dev *dev);
  805. void mlx4_cleanup_mr_table(struct mlx4_dev *dev);
  806. void mlx4_cleanup_eq_table(struct mlx4_dev *dev);
  807. void mlx4_cleanup_cq_table(struct mlx4_dev *dev);
  808. void mlx4_cleanup_qp_table(struct mlx4_dev *dev);
  809. void mlx4_cleanup_srq_table(struct mlx4_dev *dev);
  810. void mlx4_cleanup_mcg_table(struct mlx4_dev *dev);
  811. int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn, gfp_t gfp);
  812. void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn);
  813. int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn);
  814. void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn);
  815. int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn);
  816. void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn);
  817. int __mlx4_mpt_reserve(struct mlx4_dev *dev);
  818. void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index);
  819. int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index, gfp_t gfp);
  820. void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index);
  821. u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order);
  822. void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order);
  823. int mlx4_WRITE_MTT_wrapper(struct mlx4_dev *dev, int slave,
  824. struct mlx4_vhcr *vhcr,
  825. struct mlx4_cmd_mailbox *inbox,
  826. struct mlx4_cmd_mailbox *outbox,
  827. struct mlx4_cmd_info *cmd);
  828. int mlx4_SYNC_TPT_wrapper(struct mlx4_dev *dev, int slave,
  829. struct mlx4_vhcr *vhcr,
  830. struct mlx4_cmd_mailbox *inbox,
  831. struct mlx4_cmd_mailbox *outbox,
  832. struct mlx4_cmd_info *cmd);
  833. int mlx4_SW2HW_MPT_wrapper(struct mlx4_dev *dev, int slave,
  834. struct mlx4_vhcr *vhcr,
  835. struct mlx4_cmd_mailbox *inbox,
  836. struct mlx4_cmd_mailbox *outbox,
  837. struct mlx4_cmd_info *cmd);
  838. int mlx4_HW2SW_MPT_wrapper(struct mlx4_dev *dev, int slave,
  839. struct mlx4_vhcr *vhcr,
  840. struct mlx4_cmd_mailbox *inbox,
  841. struct mlx4_cmd_mailbox *outbox,
  842. struct mlx4_cmd_info *cmd);
  843. int mlx4_QUERY_MPT_wrapper(struct mlx4_dev *dev, int slave,
  844. struct mlx4_vhcr *vhcr,
  845. struct mlx4_cmd_mailbox *inbox,
  846. struct mlx4_cmd_mailbox *outbox,
  847. struct mlx4_cmd_info *cmd);
  848. int mlx4_SW2HW_EQ_wrapper(struct mlx4_dev *dev, int slave,
  849. struct mlx4_vhcr *vhcr,
  850. struct mlx4_cmd_mailbox *inbox,
  851. struct mlx4_cmd_mailbox *outbox,
  852. struct mlx4_cmd_info *cmd);
  853. int mlx4_CONFIG_DEV_wrapper(struct mlx4_dev *dev, int slave,
  854. struct mlx4_vhcr *vhcr,
  855. struct mlx4_cmd_mailbox *inbox,
  856. struct mlx4_cmd_mailbox *outbox,
  857. struct mlx4_cmd_info *cmd);
  858. int mlx4_DMA_wrapper(struct mlx4_dev *dev, int slave,
  859. struct mlx4_vhcr *vhcr,
  860. struct mlx4_cmd_mailbox *inbox,
  861. struct mlx4_cmd_mailbox *outbox,
  862. struct mlx4_cmd_info *cmd);
  863. int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align,
  864. int *base, u8 flags);
  865. void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt);
  866. int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  867. void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac);
  868. int __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt,
  869. int start_index, int npages, u64 *page_list);
  870. int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx);
  871. void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx);
  872. int __mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn);
  873. void __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn);
  874. void mlx4_start_catas_poll(struct mlx4_dev *dev);
  875. void mlx4_stop_catas_poll(struct mlx4_dev *dev);
  876. void mlx4_catas_init(void);
  877. int mlx4_restart_one(struct pci_dev *pdev);
  878. int mlx4_register_device(struct mlx4_dev *dev);
  879. void mlx4_unregister_device(struct mlx4_dev *dev);
  880. void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type,
  881. unsigned long param);
  882. struct mlx4_dev_cap;
  883. struct mlx4_init_hca_param;
  884. u64 mlx4_make_profile(struct mlx4_dev *dev,
  885. struct mlx4_profile *request,
  886. struct mlx4_dev_cap *dev_cap,
  887. struct mlx4_init_hca_param *init_hca);
  888. void mlx4_master_comm_channel(struct work_struct *work);
  889. void mlx4_gen_slave_eqe(struct work_struct *work);
  890. void mlx4_master_handle_slave_flr(struct work_struct *work);
  891. int mlx4_ALLOC_RES_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_FREE_RES_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_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave,
  902. struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox,
  903. struct mlx4_cmd_mailbox *outbox,
  904. struct mlx4_cmd_info *cmd);
  905. int mlx4_COMM_INT_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_HW2SW_EQ_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_QUERY_EQ_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_SW2HW_CQ_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_HW2SW_CQ_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_QUERY_CQ_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_MODIFY_CQ_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_SW2HW_SRQ_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_HW2SW_SRQ_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_QUERY_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  951. struct mlx4_vhcr *vhcr,
  952. struct mlx4_cmd_mailbox *inbox,
  953. struct mlx4_cmd_mailbox *outbox,
  954. struct mlx4_cmd_info *cmd);
  955. int mlx4_ARM_SRQ_wrapper(struct mlx4_dev *dev, int slave,
  956. struct mlx4_vhcr *vhcr,
  957. struct mlx4_cmd_mailbox *inbox,
  958. struct mlx4_cmd_mailbox *outbox,
  959. struct mlx4_cmd_info *cmd);
  960. int mlx4_GEN_QP_wrapper(struct mlx4_dev *dev, int slave,
  961. struct mlx4_vhcr *vhcr,
  962. struct mlx4_cmd_mailbox *inbox,
  963. struct mlx4_cmd_mailbox *outbox,
  964. struct mlx4_cmd_info *cmd);
  965. int mlx4_RST2INIT_QP_wrapper(struct mlx4_dev *dev, int slave,
  966. struct mlx4_vhcr *vhcr,
  967. struct mlx4_cmd_mailbox *inbox,
  968. struct mlx4_cmd_mailbox *outbox,
  969. struct mlx4_cmd_info *cmd);
  970. int mlx4_INIT2INIT_QP_wrapper(struct mlx4_dev *dev, int slave,
  971. struct mlx4_vhcr *vhcr,
  972. struct mlx4_cmd_mailbox *inbox,
  973. struct mlx4_cmd_mailbox *outbox,
  974. struct mlx4_cmd_info *cmd);
  975. int mlx4_INIT2RTR_QP_wrapper(struct mlx4_dev *dev, int slave,
  976. struct mlx4_vhcr *vhcr,
  977. struct mlx4_cmd_mailbox *inbox,
  978. struct mlx4_cmd_mailbox *outbox,
  979. struct mlx4_cmd_info *cmd);
  980. int mlx4_RTR2RTS_QP_wrapper(struct mlx4_dev *dev, int slave,
  981. struct mlx4_vhcr *vhcr,
  982. struct mlx4_cmd_mailbox *inbox,
  983. struct mlx4_cmd_mailbox *outbox,
  984. struct mlx4_cmd_info *cmd);
  985. int mlx4_RTS2RTS_QP_wrapper(struct mlx4_dev *dev, int slave,
  986. struct mlx4_vhcr *vhcr,
  987. struct mlx4_cmd_mailbox *inbox,
  988. struct mlx4_cmd_mailbox *outbox,
  989. struct mlx4_cmd_info *cmd);
  990. int mlx4_SQERR2RTS_QP_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_2ERR_QP_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_RTS2SQD_QP_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_SQD2SQD_QP_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_SQD2RTS_QP_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_2RST_QP_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_QUERY_QP_wrapper(struct mlx4_dev *dev, int slave,
  1021. struct mlx4_vhcr *vhcr,
  1022. struct mlx4_cmd_mailbox *inbox,
  1023. struct mlx4_cmd_mailbox *outbox,
  1024. struct mlx4_cmd_info *cmd);
  1025. int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe);
  1026. enum {
  1027. MLX4_CMD_CLEANUP_STRUCT = 1UL << 0,
  1028. MLX4_CMD_CLEANUP_POOL = 1UL << 1,
  1029. MLX4_CMD_CLEANUP_HCR = 1UL << 2,
  1030. MLX4_CMD_CLEANUP_VHCR = 1UL << 3,
  1031. MLX4_CMD_CLEANUP_ALL = (MLX4_CMD_CLEANUP_VHCR << 1) - 1
  1032. };
  1033. int mlx4_cmd_init(struct mlx4_dev *dev);
  1034. void mlx4_cmd_cleanup(struct mlx4_dev *dev, int cleanup_mask);
  1035. int mlx4_multi_func_init(struct mlx4_dev *dev);
  1036. void mlx4_multi_func_cleanup(struct mlx4_dev *dev);
  1037. void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param);
  1038. int mlx4_cmd_use_events(struct mlx4_dev *dev);
  1039. void mlx4_cmd_use_polling(struct mlx4_dev *dev);
  1040. int mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param,
  1041. unsigned long timeout);
  1042. void mlx4_cq_tasklet_cb(unsigned long data);
  1043. void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn);
  1044. void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type);
  1045. void mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type);
  1046. void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type);
  1047. void mlx4_handle_catas_err(struct mlx4_dev *dev);
  1048. int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port,
  1049. enum mlx4_port_type *type);
  1050. void mlx4_do_sense_ports(struct mlx4_dev *dev,
  1051. enum mlx4_port_type *stype,
  1052. enum mlx4_port_type *defaults);
  1053. void mlx4_start_sense(struct mlx4_dev *dev);
  1054. void mlx4_stop_sense(struct mlx4_dev *dev);
  1055. void mlx4_sense_init(struct mlx4_dev *dev);
  1056. int mlx4_check_port_params(struct mlx4_dev *dev,
  1057. enum mlx4_port_type *port_type);
  1058. int mlx4_change_port_types(struct mlx4_dev *dev,
  1059. enum mlx4_port_type *port_types);
  1060. void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table);
  1061. void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table);
  1062. void mlx4_init_roce_gid_table(struct mlx4_dev *dev,
  1063. struct mlx4_roce_gid_table *table);
  1064. void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan);
  1065. int __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index);
  1066. int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz);
  1067. /* resource tracker functions*/
  1068. int mlx4_get_slave_from_resource_id(struct mlx4_dev *dev,
  1069. enum mlx4_resource resource_type,
  1070. u64 resource_id, int *slave);
  1071. void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave_id);
  1072. void mlx4_reset_roce_gids(struct mlx4_dev *dev, int slave);
  1073. int mlx4_init_resource_tracker(struct mlx4_dev *dev);
  1074. void mlx4_free_resource_tracker(struct mlx4_dev *dev,
  1075. enum mlx4_res_tracker_free_type type);
  1076. int mlx4_QUERY_FW_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_SET_PORT_wrapper(struct mlx4_dev *dev, int slave,
  1082. struct mlx4_vhcr *vhcr,
  1083. struct mlx4_cmd_mailbox *inbox,
  1084. struct mlx4_cmd_mailbox *outbox,
  1085. struct mlx4_cmd_info *cmd);
  1086. int mlx4_INIT_PORT_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_CLOSE_PORT_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_DEV_CAP_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_QUERY_PORT_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_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps);
  1107. int mlx4_get_slave_pkey_gid_tbl_len(struct mlx4_dev *dev, u8 port,
  1108. int *gid_tbl_len, int *pkey_tbl_len);
  1109. int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
  1110. struct mlx4_vhcr *vhcr,
  1111. struct mlx4_cmd_mailbox *inbox,
  1112. struct mlx4_cmd_mailbox *outbox,
  1113. struct mlx4_cmd_info *cmd);
  1114. int mlx4_UPDATE_QP_wrapper(struct mlx4_dev *dev, int slave,
  1115. struct mlx4_vhcr *vhcr,
  1116. struct mlx4_cmd_mailbox *inbox,
  1117. struct mlx4_cmd_mailbox *outbox,
  1118. struct mlx4_cmd_info *cmd);
  1119. int mlx4_PROMISC_wrapper(struct mlx4_dev *dev, int slave,
  1120. struct mlx4_vhcr *vhcr,
  1121. struct mlx4_cmd_mailbox *inbox,
  1122. struct mlx4_cmd_mailbox *outbox,
  1123. struct mlx4_cmd_info *cmd);
  1124. int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1125. enum mlx4_protocol prot, enum mlx4_steer_type steer);
  1126. int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16],
  1127. int block_mcast_loopback, enum mlx4_protocol prot,
  1128. enum mlx4_steer_type steer);
  1129. int mlx4_trans_to_dmfs_attach(struct mlx4_dev *dev, struct mlx4_qp *qp,
  1130. u8 gid[16], u8 port,
  1131. int block_mcast_loopback,
  1132. enum mlx4_protocol prot, u64 *reg_id);
  1133. int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave,
  1134. struct mlx4_vhcr *vhcr,
  1135. struct mlx4_cmd_mailbox *inbox,
  1136. struct mlx4_cmd_mailbox *outbox,
  1137. struct mlx4_cmd_info *cmd);
  1138. int mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave,
  1139. struct mlx4_vhcr *vhcr,
  1140. struct mlx4_cmd_mailbox *inbox,
  1141. struct mlx4_cmd_mailbox *outbox,
  1142. struct mlx4_cmd_info *cmd);
  1143. int mlx4_common_set_vlan_fltr(struct mlx4_dev *dev, int function,
  1144. int port, void *buf);
  1145. int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave, u32 in_mod,
  1146. struct mlx4_cmd_mailbox *outbox);
  1147. int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave,
  1148. struct mlx4_vhcr *vhcr,
  1149. struct mlx4_cmd_mailbox *inbox,
  1150. struct mlx4_cmd_mailbox *outbox,
  1151. struct mlx4_cmd_info *cmd);
  1152. int mlx4_PKEY_TABLE_wrapper(struct mlx4_dev *dev, int slave,
  1153. struct mlx4_vhcr *vhcr,
  1154. struct mlx4_cmd_mailbox *inbox,
  1155. struct mlx4_cmd_mailbox *outbox,
  1156. struct mlx4_cmd_info *cmd);
  1157. int mlx4_QUERY_IF_STAT_wrapper(struct mlx4_dev *dev, int slave,
  1158. struct mlx4_vhcr *vhcr,
  1159. struct mlx4_cmd_mailbox *inbox,
  1160. struct mlx4_cmd_mailbox *outbox,
  1161. struct mlx4_cmd_info *cmd);
  1162. int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave,
  1163. struct mlx4_vhcr *vhcr,
  1164. struct mlx4_cmd_mailbox *inbox,
  1165. struct mlx4_cmd_mailbox *outbox,
  1166. struct mlx4_cmd_info *cmd);
  1167. int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave,
  1168. struct mlx4_vhcr *vhcr,
  1169. struct mlx4_cmd_mailbox *inbox,
  1170. struct mlx4_cmd_mailbox *outbox,
  1171. struct mlx4_cmd_info *cmd);
  1172. int mlx4_ACCESS_REG_wrapper(struct mlx4_dev *dev, int slave,
  1173. struct mlx4_vhcr *vhcr,
  1174. struct mlx4_cmd_mailbox *inbox,
  1175. struct mlx4_cmd_mailbox *outbox,
  1176. struct mlx4_cmd_info *cmd);
  1177. int mlx4_get_mgm_entry_size(struct mlx4_dev *dev);
  1178. int mlx4_get_qp_per_mgm(struct mlx4_dev *dev);
  1179. static inline void set_param_l(u64 *arg, u32 val)
  1180. {
  1181. *arg = (*arg & 0xffffffff00000000ULL) | (u64) val;
  1182. }
  1183. static inline void set_param_h(u64 *arg, u32 val)
  1184. {
  1185. *arg = (*arg & 0xffffffff) | ((u64) val << 32);
  1186. }
  1187. static inline u32 get_param_l(u64 *arg)
  1188. {
  1189. return (u32) (*arg & 0xffffffff);
  1190. }
  1191. static inline u32 get_param_h(u64 *arg)
  1192. {
  1193. return (u32)(*arg >> 32);
  1194. }
  1195. static inline spinlock_t *mlx4_tlock(struct mlx4_dev *dev)
  1196. {
  1197. return &mlx4_priv(dev)->mfunc.master.res_tracker.lock;
  1198. }
  1199. #define NOT_MASKED_PD_BITS 17
  1200. void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work);
  1201. void mlx4_init_quotas(struct mlx4_dev *dev);
  1202. int mlx4_get_slave_num_gids(struct mlx4_dev *dev, int slave, int port);
  1203. /* Returns the VF index of slave */
  1204. int mlx4_get_vf_indx(struct mlx4_dev *dev, int slave);
  1205. int mlx4_config_mad_demux(struct mlx4_dev *dev);
  1206. enum mlx4_zone_flags {
  1207. MLX4_ZONE_ALLOW_ALLOC_FROM_LOWER_PRIO = 1UL << 0,
  1208. MLX4_ZONE_ALLOW_ALLOC_FROM_EQ_PRIO = 1UL << 1,
  1209. MLX4_ZONE_FALLBACK_TO_HIGHER_PRIO = 1UL << 2,
  1210. MLX4_ZONE_USE_RR = 1UL << 3,
  1211. };
  1212. enum mlx4_zone_alloc_flags {
  1213. /* No two objects could overlap between zones. UID
  1214. * could be left unused. If this flag is given and
  1215. * two overlapped zones are used, an object will be free'd
  1216. * from the smallest possible matching zone.
  1217. */
  1218. MLX4_ZONE_ALLOC_FLAGS_NO_OVERLAP = 1UL << 0,
  1219. };
  1220. struct mlx4_zone_allocator;
  1221. /* Create a new zone allocator */
  1222. struct mlx4_zone_allocator *mlx4_zone_allocator_create(enum mlx4_zone_alloc_flags flags);
  1223. /* Attach a mlx4_bitmap <bitmap> of priority <priority> to the zone allocator
  1224. * <zone_alloc>. Allocating an object from this zone adds an offset <offset>.
  1225. * Similarly, when searching for an object to free, this offset it taken into
  1226. * account. The use_rr mlx4_ib parameter for allocating objects from this <bitmap>
  1227. * is given through the MLX4_ZONE_USE_RR flag in <flags>.
  1228. * When an allocation fails, <zone_alloc> tries to allocate from other zones
  1229. * according to the policy set by <flags>. <puid> is the unique identifier
  1230. * received to this zone.
  1231. */
  1232. int mlx4_zone_add_one(struct mlx4_zone_allocator *zone_alloc,
  1233. struct mlx4_bitmap *bitmap,
  1234. u32 flags,
  1235. int priority,
  1236. int offset,
  1237. u32 *puid);
  1238. /* Remove bitmap indicated by <uid> from <zone_alloc> */
  1239. int mlx4_zone_remove_one(struct mlx4_zone_allocator *zone_alloc, u32 uid);
  1240. /* Delete the zone allocator <zone_alloc. This function doesn't destroy
  1241. * the attached bitmaps.
  1242. */
  1243. void mlx4_zone_allocator_destroy(struct mlx4_zone_allocator *zone_alloc);
  1244. /* Allocate <count> objects with align <align> and skip_mask <skip_mask>
  1245. * from the mlx4_bitmap whose uid is <uid>. The bitmap which we actually
  1246. * allocated from is returned in <puid>. If the allocation fails, a negative
  1247. * number is returned. Otherwise, the offset of the first object is returned.
  1248. */
  1249. u32 mlx4_zone_alloc_entries(struct mlx4_zone_allocator *zones, u32 uid, int count,
  1250. int align, u32 skip_mask, u32 *puid);
  1251. /* Free <count> objects, start from <obj> of the uid <uid> from zone_allocator
  1252. * <zones>.
  1253. */
  1254. u32 mlx4_zone_free_entries(struct mlx4_zone_allocator *zones,
  1255. u32 uid, u32 obj, u32 count);
  1256. /* If <zones> was allocated with MLX4_ZONE_ALLOC_FLAGS_NO_OVERLAP, instead of
  1257. * specifying the uid when freeing an object, zone allocator could figure it by
  1258. * itself. Other parameters are similar to mlx4_zone_free.
  1259. */
  1260. u32 mlx4_zone_free_entries_unique(struct mlx4_zone_allocator *zones, u32 obj, u32 count);
  1261. /* Returns a pointer to mlx4_bitmap that was attached to <zones> with <uid> */
  1262. struct mlx4_bitmap *mlx4_zone_get_bitmap(struct mlx4_zone_allocator *zones, u32 uid);
  1263. #endif /* MLX4_H */