mlx4.h 36 KB

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