mlx4.h 35 KB

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