Commit | Line | Data |
---|---|---|
225c7b1f RD |
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. | |
51a379d0 | 5 | * Copyright (c) 2005, 2006, 2007, 2008 Mellanox Technologies. All rights reserved. |
225c7b1f RD |
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 | ||
37 | #ifndef MLX4_H | |
38 | #define MLX4_H | |
39 | ||
525f5f44 | 40 | #include <linux/mutex.h> |
225c7b1f | 41 | #include <linux/radix-tree.h> |
4af1c048 | 42 | #include <linux/rbtree.h> |
ee49bd93 | 43 | #include <linux/timer.h> |
3142788b | 44 | #include <linux/semaphore.h> |
27bf91d6 | 45 | #include <linux/workqueue.h> |
225c7b1f RD |
46 | |
47 | #include <linux/mlx4/device.h> | |
37608eea | 48 | #include <linux/mlx4/driver.h> |
225c7b1f | 49 | #include <linux/mlx4/doorbell.h> |
623ed84b | 50 | #include <linux/mlx4/cmd.h> |
225c7b1f RD |
51 | |
52 | #define DRV_NAME "mlx4_core" | |
ab9c17a0 | 53 | #define PFX DRV_NAME ": " |
169a1d85 AV |
54 | #define DRV_VERSION "2.2-1" |
55 | #define DRV_RELDATE "Feb, 2014" | |
225c7b1f | 56 | |
0ff1fb65 HHZ |
57 | #define MLX4_FS_UDP_UC_EN (1 << 1) |
58 | #define MLX4_FS_TCP_UC_EN (1 << 2) | |
59 | #define MLX4_FS_NUM_OF_L2_ADDR 8 | |
60 | #define MLX4_FS_MGM_LOG_ENTRY_SIZE 7 | |
61 | #define MLX4_FS_NUM_MCG (1 << 17) | |
62 | ||
e448834e SM |
63 | #define INIT_HCA_TPT_MW_ENABLE (1 << 7) |
64 | ||
e5395e92 AV |
65 | #define MLX4_NUM_UP 8 |
66 | #define MLX4_NUM_TC 8 | |
67 | #define MLX4_RATELIMIT_UNITS 3 /* 100 Mbps */ | |
68 | #define MLX4_RATELIMIT_DEFAULT 0xffff | |
69 | ||
70 | struct mlx4_set_port_prio2tc_context { | |
71 | u8 prio2tc[4]; | |
72 | }; | |
73 | ||
74 | struct mlx4_port_scheduler_tc_cfg_be { | |
75 | __be16 pg; | |
76 | __be16 bw_precentage; | |
77 | __be16 max_bw_units; /* 3-100Mbps, 4-1Gbps, other values - reserved */ | |
78 | __be16 max_bw_value; | |
79 | }; | |
80 | ||
81 | struct mlx4_set_port_scheduler_context { | |
82 | struct mlx4_port_scheduler_tc_cfg_be tc[MLX4_NUM_TC]; | |
83 | }; | |
84 | ||
225c7b1f RD |
85 | enum { |
86 | MLX4_HCR_BASE = 0x80680, | |
87 | MLX4_HCR_SIZE = 0x0001c, | |
623ed84b JM |
88 | MLX4_CLR_INT_SIZE = 0x00008, |
89 | MLX4_SLAVE_COMM_BASE = 0x0, | |
ddd8a6c1 EE |
90 | MLX4_COMM_PAGESIZE = 0x1000, |
91 | MLX4_CLOCK_SIZE = 0x00008 | |
225c7b1f RD |
92 | }; |
93 | ||
225c7b1f | 94 | enum { |
3c439b55 JM |
95 | MLX4_DEFAULT_MGM_LOG_ENTRY_SIZE = 10, |
96 | MLX4_MIN_MGM_LOG_ENTRY_SIZE = 7, | |
97 | MLX4_MAX_MGM_LOG_ENTRY_SIZE = 12, | |
98 | MLX4_MAX_QP_PER_MGM = 4 * ((1 << MLX4_MAX_MGM_LOG_ENTRY_SIZE) / 16 - 2), | |
0ec2c0f8 | 99 | MLX4_MTT_ENTRY_PER_SEG = 8, |
225c7b1f RD |
100 | }; |
101 | ||
225c7b1f RD |
102 | enum { |
103 | MLX4_NUM_PDS = 1 << 15 | |
104 | }; | |
105 | ||
106 | enum { | |
107 | MLX4_CMPT_TYPE_QP = 0, | |
108 | MLX4_CMPT_TYPE_SRQ = 1, | |
109 | MLX4_CMPT_TYPE_CQ = 2, | |
110 | MLX4_CMPT_TYPE_EQ = 3, | |
111 | MLX4_CMPT_NUM_TYPE | |
112 | }; | |
113 | ||
114 | enum { | |
115 | MLX4_CMPT_SHIFT = 24, | |
116 | MLX4_NUM_CMPTS = MLX4_CMPT_NUM_TYPE << MLX4_CMPT_SHIFT | |
117 | }; | |
118 | ||
b20e519a SM |
119 | enum mlx4_mpt_state { |
120 | MLX4_MPT_DISABLED = 0, | |
121 | MLX4_MPT_EN_HW, | |
122 | MLX4_MPT_EN_SW | |
623ed84b JM |
123 | }; |
124 | ||
125 | #define MLX4_COMM_TIME 10000 | |
126 | enum { | |
127 | MLX4_COMM_CMD_RESET, | |
128 | MLX4_COMM_CMD_VHCR0, | |
129 | MLX4_COMM_CMD_VHCR1, | |
130 | MLX4_COMM_CMD_VHCR2, | |
131 | MLX4_COMM_CMD_VHCR_EN, | |
132 | MLX4_COMM_CMD_VHCR_POST, | |
133 | MLX4_COMM_CMD_FLR = 254 | |
134 | }; | |
135 | ||
99ec41d0 JM |
136 | enum { |
137 | MLX4_VF_SMI_DISABLED, | |
138 | MLX4_VF_SMI_ENABLED | |
139 | }; | |
140 | ||
623ed84b JM |
141 | /*The flag indicates that the slave should delay the RESET cmd*/ |
142 | #define MLX4_DELAY_RESET_SLAVE 0xbbbbbbb | |
143 | /*indicates how many retries will be done if we are in the middle of FLR*/ | |
144 | #define NUM_OF_RESET_RETRIES 10 | |
145 | #define SLEEP_TIME_IN_RESET (2 * 1000) | |
146 | enum mlx4_resource { | |
147 | RES_QP, | |
148 | RES_CQ, | |
149 | RES_SRQ, | |
150 | RES_XRCD, | |
151 | RES_MPT, | |
152 | RES_MTT, | |
153 | RES_MAC, | |
154 | RES_VLAN, | |
155 | RES_EQ, | |
156 | RES_COUNTER, | |
1b9c6b06 | 157 | RES_FS_RULE, |
623ed84b JM |
158 | MLX4_NUM_OF_RESOURCE_TYPE |
159 | }; | |
160 | ||
161 | enum mlx4_alloc_mode { | |
162 | RES_OP_RESERVE, | |
163 | RES_OP_RESERVE_AND_MAP, | |
164 | RES_OP_MAP_ICM, | |
165 | }; | |
166 | ||
b8924951 JM |
167 | enum mlx4_res_tracker_free_type { |
168 | RES_TR_FREE_ALL, | |
169 | RES_TR_FREE_SLAVES_ONLY, | |
170 | RES_TR_FREE_STRUCTS_ONLY, | |
171 | }; | |
623ed84b JM |
172 | |
173 | /* | |
174 | *Virtual HCR structures. | |
175 | * mlx4_vhcr is the sw representation, in machine endianess | |
176 | * | |
177 | * mlx4_vhcr_cmd is the formalized structure, the one that is passed | |
178 | * to FW to go through communication channel. | |
179 | * It is big endian, and has the same structure as the physical HCR | |
180 | * used by command interface | |
181 | */ | |
182 | struct mlx4_vhcr { | |
183 | u64 in_param; | |
184 | u64 out_param; | |
185 | u32 in_modifier; | |
186 | u32 errno; | |
187 | u16 op; | |
188 | u16 token; | |
189 | u8 op_modifier; | |
190 | u8 e_bit; | |
191 | }; | |
192 | ||
193 | struct mlx4_vhcr_cmd { | |
194 | __be64 in_param; | |
195 | __be32 in_modifier; | |
196 | __be64 out_param; | |
197 | __be16 token; | |
198 | u16 reserved; | |
199 | u8 status; | |
200 | u8 flags; | |
201 | __be16 opcode; | |
202 | }; | |
203 | ||
204 | struct mlx4_cmd_info { | |
205 | u16 opcode; | |
206 | bool has_inbox; | |
207 | bool has_outbox; | |
208 | bool out_is_imm; | |
209 | bool encode_slave_id; | |
210 | int (*verify)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, | |
211 | struct mlx4_cmd_mailbox *inbox); | |
212 | int (*wrapper)(struct mlx4_dev *dev, int slave, struct mlx4_vhcr *vhcr, | |
213 | struct mlx4_cmd_mailbox *inbox, | |
214 | struct mlx4_cmd_mailbox *outbox, | |
215 | struct mlx4_cmd_info *cmd); | |
216 | }; | |
217 | ||
225c7b1f RD |
218 | #ifdef CONFIG_MLX4_DEBUG |
219 | extern int mlx4_debug_level; | |
7b0f5df4 RD |
220 | #else /* CONFIG_MLX4_DEBUG */ |
221 | #define mlx4_debug_level (0) | |
222 | #endif /* CONFIG_MLX4_DEBUG */ | |
225c7b1f RD |
223 | |
224 | #define mlx4_dbg(mdev, format, arg...) \ | |
0a645e80 JP |
225 | do { \ |
226 | if (mlx4_debug_level) \ | |
227 | dev_printk(KERN_DEBUG, &mdev->pdev->dev, format, ##arg); \ | |
228 | } while (0) | |
225c7b1f | 229 | |
225c7b1f | 230 | #define mlx4_err(mdev, format, arg...) \ |
0a645e80 | 231 | dev_err(&mdev->pdev->dev, format, ##arg) |
225c7b1f | 232 | #define mlx4_info(mdev, format, arg...) \ |
0a645e80 | 233 | dev_info(&mdev->pdev->dev, format, ##arg) |
225c7b1f | 234 | #define mlx4_warn(mdev, format, arg...) \ |
0a645e80 | 235 | dev_warn(&mdev->pdev->dev, format, ##arg) |
225c7b1f | 236 | |
0ec2c0f8 | 237 | extern int mlx4_log_num_mgm_entry_size; |
2b8fb286 | 238 | extern int log_mtts_per_seg; |
0ec2c0f8 | 239 | |
623ed84b JM |
240 | #define MLX4_MAX_NUM_SLAVES (MLX4_MAX_NUM_PF + MLX4_MAX_NUM_VF) |
241 | #define ALL_SLAVES 0xff | |
242 | ||
225c7b1f RD |
243 | struct mlx4_bitmap { |
244 | u32 last; | |
245 | u32 top; | |
246 | u32 max; | |
93fc9e1b | 247 | u32 reserved_top; |
225c7b1f | 248 | u32 mask; |
42d1e017 | 249 | u32 avail; |
225c7b1f RD |
250 | spinlock_t lock; |
251 | unsigned long *table; | |
252 | }; | |
253 | ||
254 | struct mlx4_buddy { | |
255 | unsigned long **bits; | |
e4044cfc | 256 | unsigned int *num_free; |
3de819e6 | 257 | u32 max_order; |
225c7b1f RD |
258 | spinlock_t lock; |
259 | }; | |
260 | ||
261 | struct mlx4_icm; | |
262 | ||
263 | struct mlx4_icm_table { | |
264 | u64 virt; | |
265 | int num_icm; | |
3de819e6 | 266 | u32 num_obj; |
225c7b1f RD |
267 | int obj_size; |
268 | int lowmem; | |
5b0bf5e2 | 269 | int coherent; |
225c7b1f RD |
270 | struct mutex mutex; |
271 | struct mlx4_icm **icm; | |
272 | }; | |
273 | ||
cc1ade94 SM |
274 | #define MLX4_MPT_FLAG_SW_OWNS (0xfUL << 28) |
275 | #define MLX4_MPT_FLAG_FREE (0x3UL << 28) | |
276 | #define MLX4_MPT_FLAG_MIO (1 << 17) | |
277 | #define MLX4_MPT_FLAG_BIND_ENABLE (1 << 15) | |
278 | #define MLX4_MPT_FLAG_PHYSICAL (1 << 9) | |
279 | #define MLX4_MPT_FLAG_REGION (1 << 8) | |
280 | ||
281 | #define MLX4_MPT_PD_FLAG_FAST_REG (1 << 27) | |
282 | #define MLX4_MPT_PD_FLAG_RAE (1 << 28) | |
283 | #define MLX4_MPT_PD_FLAG_EN_INV (3 << 24) | |
284 | ||
285 | #define MLX4_MPT_QP_FLAG_BOUND_QP (1 << 7) | |
286 | ||
287 | #define MLX4_MPT_STATUS_SW 0xF0 | |
288 | #define MLX4_MPT_STATUS_HW 0x00 | |
289 | ||
c82e9aa0 EC |
290 | /* |
291 | * Must be packed because mtt_seg is 64 bits but only aligned to 32 bits. | |
292 | */ | |
293 | struct mlx4_mpt_entry { | |
294 | __be32 flags; | |
295 | __be32 qpn; | |
296 | __be32 key; | |
297 | __be32 pd_flags; | |
298 | __be64 start; | |
299 | __be64 length; | |
300 | __be32 lkey; | |
301 | __be32 win_cnt; | |
302 | u8 reserved1[3]; | |
303 | u8 mtt_rep; | |
2b8fb286 | 304 | __be64 mtt_addr; |
c82e9aa0 EC |
305 | __be32 mtt_sz; |
306 | __be32 entity_size; | |
307 | __be32 first_byte_offset; | |
308 | } __packed; | |
309 | ||
310 | /* | |
311 | * Must be packed because start is 64 bits but only aligned to 32 bits. | |
312 | */ | |
313 | struct mlx4_eq_context { | |
314 | __be32 flags; | |
315 | u16 reserved1[3]; | |
316 | __be16 page_offset; | |
317 | u8 log_eq_size; | |
318 | u8 reserved2[4]; | |
319 | u8 eq_period; | |
320 | u8 reserved3; | |
321 | u8 eq_max_count; | |
322 | u8 reserved4[3]; | |
323 | u8 intr; | |
324 | u8 log_page_size; | |
325 | u8 reserved5[2]; | |
326 | u8 mtt_base_addr_h; | |
327 | __be32 mtt_base_addr_l; | |
328 | u32 reserved6[2]; | |
329 | __be32 consumer_index; | |
330 | __be32 producer_index; | |
331 | u32 reserved7[4]; | |
332 | }; | |
333 | ||
334 | struct mlx4_cq_context { | |
335 | __be32 flags; | |
336 | u16 reserved1[3]; | |
337 | __be16 page_offset; | |
338 | __be32 logsize_usrpage; | |
339 | __be16 cq_period; | |
340 | __be16 cq_max_count; | |
341 | u8 reserved2[3]; | |
342 | u8 comp_eqn; | |
343 | u8 log_page_size; | |
344 | u8 reserved3[2]; | |
345 | u8 mtt_base_addr_h; | |
346 | __be32 mtt_base_addr_l; | |
347 | __be32 last_notified_index; | |
348 | __be32 solicit_producer_index; | |
349 | __be32 consumer_index; | |
350 | __be32 producer_index; | |
351 | u32 reserved4[2]; | |
352 | __be64 db_rec_addr; | |
353 | }; | |
354 | ||
355 | struct mlx4_srq_context { | |
356 | __be32 state_logsize_srqn; | |
357 | u8 logstride; | |
358 | u8 reserved1; | |
359 | __be16 xrcd; | |
360 | __be32 pg_offset_cqn; | |
361 | u32 reserved2; | |
362 | u8 log_page_size; | |
363 | u8 reserved3[2]; | |
364 | u8 mtt_base_addr_h; | |
365 | __be32 mtt_base_addr_l; | |
366 | __be32 pd; | |
367 | __be16 limit_watermark; | |
368 | __be16 wqe_cnt; | |
369 | u16 reserved4; | |
370 | __be16 wqe_counter; | |
371 | u32 reserved5; | |
372 | __be64 db_rec_addr; | |
373 | }; | |
374 | ||
225c7b1f RD |
375 | struct mlx4_eq { |
376 | struct mlx4_dev *dev; | |
377 | void __iomem *doorbell; | |
378 | int eqn; | |
379 | u32 cons_index; | |
380 | u16 irq; | |
381 | u16 have_irq; | |
382 | int nent; | |
383 | struct mlx4_buf_list *page_list; | |
384 | struct mlx4_mtt mtt; | |
385 | }; | |
386 | ||
623ed84b JM |
387 | struct mlx4_slave_eqe { |
388 | u8 type; | |
389 | u8 port; | |
390 | u32 param; | |
391 | }; | |
392 | ||
393 | struct mlx4_slave_event_eq_info { | |
803143fb | 394 | int eqn; |
623ed84b | 395 | u16 token; |
623ed84b JM |
396 | }; |
397 | ||
225c7b1f RD |
398 | struct mlx4_profile { |
399 | int num_qp; | |
400 | int rdmarc_per_qp; | |
401 | int num_srq; | |
402 | int num_cq; | |
403 | int num_mcg; | |
404 | int num_mpt; | |
db5a7a65 | 405 | unsigned num_mtt; |
225c7b1f RD |
406 | }; |
407 | ||
408 | struct mlx4_fw { | |
409 | u64 clr_int_base; | |
410 | u64 catas_offset; | |
623ed84b | 411 | u64 comm_base; |
ddd8a6c1 | 412 | u64 clock_offset; |
225c7b1f RD |
413 | struct mlx4_icm *fw_icm; |
414 | struct mlx4_icm *aux_icm; | |
415 | u32 catas_size; | |
416 | u16 fw_pages; | |
417 | u8 clr_int_bar; | |
418 | u8 catas_bar; | |
623ed84b | 419 | u8 comm_bar; |
ddd8a6c1 | 420 | u8 clock_bar; |
623ed84b JM |
421 | }; |
422 | ||
423 | struct mlx4_comm { | |
424 | u32 slave_write; | |
425 | u32 slave_read; | |
225c7b1f RD |
426 | }; |
427 | ||
ffe455ad EE |
428 | enum { |
429 | MLX4_MCAST_CONFIG = 0, | |
430 | MLX4_MCAST_DISABLE = 1, | |
431 | MLX4_MCAST_ENABLE = 2, | |
432 | }; | |
433 | ||
623ed84b JM |
434 | #define VLAN_FLTR_SIZE 128 |
435 | ||
436 | struct mlx4_vlan_fltr { | |
437 | __be32 entry[VLAN_FLTR_SIZE]; | |
438 | }; | |
439 | ||
ffe455ad EE |
440 | struct mlx4_mcast_entry { |
441 | struct list_head list; | |
442 | u64 addr; | |
443 | }; | |
444 | ||
b12d93d6 YP |
445 | struct mlx4_promisc_qp { |
446 | struct list_head list; | |
447 | u32 qpn; | |
448 | }; | |
449 | ||
450 | struct mlx4_steer_index { | |
451 | struct list_head list; | |
452 | unsigned int index; | |
453 | struct list_head duplicates; | |
454 | }; | |
455 | ||
803143fb MA |
456 | #define MLX4_EVENT_TYPES_NUM 64 |
457 | ||
623ed84b JM |
458 | struct mlx4_slave_state { |
459 | u8 comm_toggle; | |
460 | u8 last_cmd; | |
461 | u8 init_port_mask; | |
462 | bool active; | |
2c957ff2 | 463 | bool old_vlan_api; |
623ed84b JM |
464 | u8 function; |
465 | dma_addr_t vhcr_dma; | |
466 | u16 mtu[MLX4_MAX_PORTS + 1]; | |
467 | __be32 ib_cap_mask[MLX4_MAX_PORTS + 1]; | |
468 | struct mlx4_slave_eqe eq[MLX4_MFUNC_MAX_EQES]; | |
469 | struct list_head mcast_filters[MLX4_MAX_PORTS + 1]; | |
470 | struct mlx4_vlan_fltr *vlan_filter[MLX4_MAX_PORTS + 1]; | |
803143fb MA |
471 | /* event type to eq number lookup */ |
472 | struct mlx4_slave_event_eq_info event_eq[MLX4_EVENT_TYPES_NUM]; | |
623ed84b JM |
473 | u16 eq_pi; |
474 | u16 eq_ci; | |
475 | spinlock_t lock; | |
476 | /*initialized via the kzalloc*/ | |
477 | u8 is_slave_going_down; | |
478 | u32 cookie; | |
993c401e | 479 | enum slave_port_state port_state[MLX4_MAX_PORTS + 1]; |
623ed84b JM |
480 | }; |
481 | ||
0eb62b93 RE |
482 | #define MLX4_VGT 4095 |
483 | #define NO_INDX (-1) | |
484 | ||
485 | struct mlx4_vport_state { | |
486 | u64 mac; | |
487 | u16 default_vlan; | |
488 | u8 default_qos; | |
489 | u32 tx_rate; | |
490 | bool spoofchk; | |
948e306d | 491 | u32 link_state; |
0eb62b93 RE |
492 | }; |
493 | ||
494 | struct mlx4_vf_admin_state { | |
495 | struct mlx4_vport_state vport[MLX4_MAX_PORTS + 1]; | |
99ec41d0 | 496 | u8 enable_smi[MLX4_MAX_PORTS + 1]; |
0eb62b93 RE |
497 | }; |
498 | ||
499 | struct mlx4_vport_oper_state { | |
500 | struct mlx4_vport_state state; | |
501 | int mac_idx; | |
502 | int vlan_idx; | |
503 | }; | |
99ec41d0 | 504 | |
0eb62b93 RE |
505 | struct mlx4_vf_oper_state { |
506 | struct mlx4_vport_oper_state vport[MLX4_MAX_PORTS + 1]; | |
99ec41d0 | 507 | u8 smi_enabled[MLX4_MAX_PORTS + 1]; |
0eb62b93 RE |
508 | }; |
509 | ||
623ed84b JM |
510 | struct slave_list { |
511 | struct mutex mutex; | |
512 | struct list_head res_list[MLX4_NUM_OF_RESOURCE_TYPE]; | |
513 | }; | |
514 | ||
5a0d0a61 | 515 | struct resource_allocator { |
146f3ef4 | 516 | spinlock_t alloc_lock; /* protect quotas */ |
5a0d0a61 JM |
517 | union { |
518 | int res_reserved; | |
519 | int res_port_rsvd[MLX4_MAX_PORTS]; | |
520 | }; | |
521 | union { | |
522 | int res_free; | |
523 | int res_port_free[MLX4_MAX_PORTS]; | |
524 | }; | |
525 | int *quota; | |
526 | int *allocated; | |
527 | int *guaranteed; | |
528 | }; | |
529 | ||
623ed84b JM |
530 | struct mlx4_resource_tracker { |
531 | spinlock_t lock; | |
532 | /* tree for each resources */ | |
4af1c048 | 533 | struct rb_root res_tree[MLX4_NUM_OF_RESOURCE_TYPE]; |
623ed84b JM |
534 | /* num_of_slave's lists, one per slave */ |
535 | struct slave_list *slave_list; | |
5a0d0a61 | 536 | struct resource_allocator res_alloc[MLX4_NUM_OF_RESOURCE_TYPE]; |
623ed84b JM |
537 | }; |
538 | ||
539 | #define SLAVE_EVENT_EQ_SIZE 128 | |
540 | struct mlx4_slave_event_eq { | |
541 | u32 eqn; | |
542 | u32 cons; | |
543 | u32 prod; | |
992e8e6e | 544 | spinlock_t event_lock; |
623ed84b JM |
545 | struct mlx4_eqe event_eqe[SLAVE_EVENT_EQ_SIZE]; |
546 | }; | |
547 | ||
548 | struct mlx4_master_qp0_state { | |
549 | int proxy_qp0_active; | |
550 | int qp0_active; | |
551 | int port_active; | |
552 | }; | |
553 | ||
554 | struct mlx4_mfunc_master_ctx { | |
555 | struct mlx4_slave_state *slave_state; | |
0eb62b93 RE |
556 | struct mlx4_vf_admin_state *vf_admin; |
557 | struct mlx4_vf_oper_state *vf_oper; | |
623ed84b JM |
558 | struct mlx4_master_qp0_state qp0_state[MLX4_MAX_PORTS + 1]; |
559 | int init_port_ref[MLX4_MAX_PORTS + 1]; | |
560 | u16 max_mtu[MLX4_MAX_PORTS + 1]; | |
561 | int disable_mcast_ref[MLX4_MAX_PORTS + 1]; | |
562 | struct mlx4_resource_tracker res_tracker; | |
563 | struct workqueue_struct *comm_wq; | |
564 | struct work_struct comm_work; | |
565 | struct work_struct slave_event_work; | |
566 | struct work_struct slave_flr_event_work; | |
567 | spinlock_t slave_state_lock; | |
f5311ac1 | 568 | __be32 comm_arm_bit_vector[4]; |
623ed84b JM |
569 | struct mlx4_eqe cmd_eqe; |
570 | struct mlx4_slave_event_eq slave_eq; | |
571 | struct mutex gen_eqe_mutex[MLX4_MFUNC_MAX]; | |
572 | }; | |
573 | ||
574 | struct mlx4_mfunc { | |
575 | struct mlx4_comm __iomem *comm; | |
576 | struct mlx4_vhcr_cmd *vhcr; | |
577 | dma_addr_t vhcr_dma; | |
578 | ||
579 | struct mlx4_mfunc_master_ctx master; | |
580 | }; | |
581 | ||
fe6f700d YP |
582 | #define MGM_QPN_MASK 0x00FFFFFF |
583 | #define MGM_BLCK_LB_BIT 30 | |
584 | ||
585 | struct mlx4_mgm { | |
586 | __be32 next_gid_index; | |
587 | __be32 members_count; | |
588 | u32 reserved[2]; | |
589 | u8 gid[16]; | |
590 | __be32 qp[MLX4_MAX_QP_PER_MGM]; | |
591 | }; | |
592 | ||
225c7b1f RD |
593 | struct mlx4_cmd { |
594 | struct pci_pool *pool; | |
595 | void __iomem *hcr; | |
596 | struct mutex hcr_mutex; | |
f3d4c89e | 597 | struct mutex slave_cmd_mutex; |
225c7b1f RD |
598 | struct semaphore poll_sem; |
599 | struct semaphore event_sem; | |
600 | int max_cmds; | |
601 | spinlock_t context_lock; | |
602 | int free_head; | |
603 | struct mlx4_cmd_context *context; | |
604 | u16 token_mask; | |
605 | u8 use_events; | |
606 | u8 toggle; | |
623ed84b | 607 | u8 comm_toggle; |
225c7b1f RD |
608 | }; |
609 | ||
b01978ca JM |
610 | enum { |
611 | MLX4_VF_IMMED_VLAN_FLAG_VLAN = 1 << 0, | |
612 | MLX4_VF_IMMED_VLAN_FLAG_QOS = 1 << 1, | |
0a6eac24 | 613 | MLX4_VF_IMMED_VLAN_FLAG_LINK_DISABLE = 1 << 2, |
b01978ca JM |
614 | }; |
615 | struct mlx4_vf_immed_vlan_work { | |
616 | struct work_struct work; | |
617 | struct mlx4_priv *priv; | |
618 | int flags; | |
619 | int slave; | |
620 | int vlan_ix; | |
621 | int orig_vlan_ix; | |
622 | u8 port; | |
623 | u8 qos; | |
624 | u16 vlan_id; | |
625 | u16 orig_vlan_id; | |
626 | }; | |
627 | ||
628 | ||
225c7b1f RD |
629 | struct mlx4_uar_table { |
630 | struct mlx4_bitmap bitmap; | |
631 | }; | |
632 | ||
633 | struct mlx4_mr_table { | |
634 | struct mlx4_bitmap mpt_bitmap; | |
635 | struct mlx4_buddy mtt_buddy; | |
636 | u64 mtt_base; | |
637 | u64 mpt_base; | |
638 | struct mlx4_icm_table mtt_table; | |
639 | struct mlx4_icm_table dmpt_table; | |
640 | }; | |
641 | ||
642 | struct mlx4_cq_table { | |
643 | struct mlx4_bitmap bitmap; | |
644 | spinlock_t lock; | |
645 | struct radix_tree_root tree; | |
646 | struct mlx4_icm_table table; | |
647 | struct mlx4_icm_table cmpt_table; | |
648 | }; | |
649 | ||
650 | struct mlx4_eq_table { | |
651 | struct mlx4_bitmap bitmap; | |
b8dd786f | 652 | char *irq_names; |
225c7b1f | 653 | void __iomem *clr_int; |
b8dd786f | 654 | void __iomem **uar_map; |
225c7b1f | 655 | u32 clr_mask; |
b8dd786f | 656 | struct mlx4_eq *eq; |
fa0681d2 | 657 | struct mlx4_icm_table table; |
225c7b1f RD |
658 | struct mlx4_icm_table cmpt_table; |
659 | int have_irq; | |
660 | u8 inta_pin; | |
661 | }; | |
662 | ||
663 | struct mlx4_srq_table { | |
664 | struct mlx4_bitmap bitmap; | |
665 | spinlock_t lock; | |
666 | struct radix_tree_root tree; | |
667 | struct mlx4_icm_table table; | |
668 | struct mlx4_icm_table cmpt_table; | |
669 | }; | |
670 | ||
671 | struct mlx4_qp_table { | |
672 | struct mlx4_bitmap bitmap; | |
673 | u32 rdmarc_base; | |
674 | int rdmarc_shift; | |
675 | spinlock_t lock; | |
676 | struct mlx4_icm_table qp_table; | |
677 | struct mlx4_icm_table auxc_table; | |
678 | struct mlx4_icm_table altc_table; | |
679 | struct mlx4_icm_table rdmarc_table; | |
680 | struct mlx4_icm_table cmpt_table; | |
681 | }; | |
682 | ||
683 | struct mlx4_mcg_table { | |
684 | struct mutex mutex; | |
685 | struct mlx4_bitmap bitmap; | |
686 | struct mlx4_icm_table table; | |
687 | }; | |
688 | ||
689 | struct mlx4_catas_err { | |
690 | u32 __iomem *map; | |
ee49bd93 JM |
691 | struct timer_list timer; |
692 | struct list_head list; | |
225c7b1f RD |
693 | }; |
694 | ||
2a2336f8 YP |
695 | #define MLX4_MAX_MAC_NUM 128 |
696 | #define MLX4_MAC_TABLE_SIZE (MLX4_MAX_MAC_NUM << 3) | |
697 | ||
698 | struct mlx4_mac_table { | |
699 | __be64 entries[MLX4_MAX_MAC_NUM]; | |
700 | int refs[MLX4_MAX_MAC_NUM]; | |
701 | struct mutex mutex; | |
702 | int total; | |
703 | int max; | |
704 | }; | |
705 | ||
706 | #define MLX4_MAX_VLAN_NUM 128 | |
707 | #define MLX4_VLAN_TABLE_SIZE (MLX4_MAX_VLAN_NUM << 2) | |
708 | ||
709 | struct mlx4_vlan_table { | |
710 | __be32 entries[MLX4_MAX_VLAN_NUM]; | |
711 | int refs[MLX4_MAX_VLAN_NUM]; | |
712 | struct mutex mutex; | |
713 | int total; | |
714 | int max; | |
715 | }; | |
716 | ||
ffe455ad EE |
717 | #define SET_PORT_GEN_ALL_VALID 0x7 |
718 | #define SET_PORT_PROMISC_SHIFT 31 | |
719 | #define SET_PORT_MC_PROMISC_SHIFT 30 | |
720 | ||
721 | enum { | |
722 | MCAST_DIRECT_ONLY = 0, | |
723 | MCAST_DIRECT = 1, | |
724 | MCAST_DEFAULT = 2 | |
725 | }; | |
726 | ||
727 | ||
728 | struct mlx4_set_port_general_context { | |
729 | u8 reserved[3]; | |
730 | u8 flags; | |
731 | u16 reserved2; | |
732 | __be16 mtu; | |
733 | u8 pptx; | |
734 | u8 pfctx; | |
735 | u16 reserved3; | |
736 | u8 pprx; | |
737 | u8 pfcrx; | |
738 | u16 reserved4; | |
739 | }; | |
740 | ||
741 | struct mlx4_set_port_rqp_calc_context { | |
742 | __be32 base_qpn; | |
743 | u8 rererved; | |
744 | u8 n_mac; | |
745 | u8 n_vlan; | |
746 | u8 n_prio; | |
747 | u8 reserved2[3]; | |
748 | u8 mac_miss; | |
749 | u8 intra_no_vlan; | |
750 | u8 no_vlan; | |
751 | u8 intra_vlan_miss; | |
752 | u8 vlan_miss; | |
753 | u8 reserved3[3]; | |
754 | u8 no_vlan_prio; | |
755 | __be32 promisc; | |
756 | __be32 mcast; | |
757 | }; | |
758 | ||
2a2336f8 YP |
759 | struct mlx4_port_info { |
760 | struct mlx4_dev *dev; | |
761 | int port; | |
7ff93f8b YP |
762 | char dev_name[16]; |
763 | struct device_attribute port_attr; | |
764 | enum mlx4_port_type tmp_type; | |
096335b3 OG |
765 | char dev_mtu_name[16]; |
766 | struct device_attribute port_mtu_attr; | |
2a2336f8 YP |
767 | struct mlx4_mac_table mac_table; |
768 | struct mlx4_vlan_table vlan_table; | |
1679200f | 769 | int base_qpn; |
2a2336f8 YP |
770 | }; |
771 | ||
27bf91d6 YP |
772 | struct mlx4_sense { |
773 | struct mlx4_dev *dev; | |
774 | u8 do_sense_port[MLX4_MAX_PORTS + 1]; | |
775 | u8 sense_allowed[MLX4_MAX_PORTS + 1]; | |
776 | struct delayed_work sense_poll; | |
777 | }; | |
778 | ||
0b7ca5a9 YP |
779 | struct mlx4_msix_ctl { |
780 | u64 pool_bm; | |
730c41d5 | 781 | struct mutex pool_lock; |
0b7ca5a9 YP |
782 | }; |
783 | ||
b12d93d6 YP |
784 | struct mlx4_steer { |
785 | struct list_head promisc_qps[MLX4_NUM_STEERS]; | |
786 | struct list_head steer_entries[MLX4_NUM_STEERS]; | |
b12d93d6 YP |
787 | }; |
788 | ||
839f1243 RD |
789 | enum { |
790 | MLX4_PCI_DEV_IS_VF = 1 << 0, | |
ca3e57a5 | 791 | MLX4_PCI_DEV_FORCE_SENSE_PORT = 1 << 1, |
839f1243 RD |
792 | }; |
793 | ||
7c6d74d2 JM |
794 | enum { |
795 | MLX4_NO_RR = 0, | |
796 | MLX4_USE_RR = 1, | |
797 | }; | |
798 | ||
6ee51a4e JM |
799 | struct mlx4_roce_gid_entry { |
800 | u8 raw[16]; | |
801 | }; | |
802 | ||
225c7b1f RD |
803 | struct mlx4_priv { |
804 | struct mlx4_dev dev; | |
805 | ||
806 | struct list_head dev_list; | |
807 | struct list_head ctx_list; | |
808 | spinlock_t ctx_lock; | |
809 | ||
839f1243 | 810 | int pci_dev_data; |
befdf897 | 811 | int removed; |
839f1243 | 812 | |
6296883c YP |
813 | struct list_head pgdir_list; |
814 | struct mutex pgdir_mutex; | |
815 | ||
225c7b1f RD |
816 | struct mlx4_fw fw; |
817 | struct mlx4_cmd cmd; | |
623ed84b | 818 | struct mlx4_mfunc mfunc; |
225c7b1f RD |
819 | |
820 | struct mlx4_bitmap pd_bitmap; | |
012a8ff5 | 821 | struct mlx4_bitmap xrcd_bitmap; |
225c7b1f RD |
822 | struct mlx4_uar_table uar_table; |
823 | struct mlx4_mr_table mr_table; | |
824 | struct mlx4_cq_table cq_table; | |
825 | struct mlx4_eq_table eq_table; | |
826 | struct mlx4_srq_table srq_table; | |
827 | struct mlx4_qp_table qp_table; | |
828 | struct mlx4_mcg_table mcg_table; | |
f2a3f6a3 | 829 | struct mlx4_bitmap counters_bitmap; |
225c7b1f RD |
830 | |
831 | struct mlx4_catas_err catas_err; | |
832 | ||
833 | void __iomem *clr_base; | |
834 | ||
835 | struct mlx4_uar driver_uar; | |
836 | void __iomem *kar; | |
2a2336f8 | 837 | struct mlx4_port_info port[MLX4_MAX_PORTS + 1]; |
27bf91d6 | 838 | struct mlx4_sense sense; |
7ff93f8b | 839 | struct mutex port_mutex; |
0b7ca5a9 | 840 | struct mlx4_msix_ctl msix_ctl; |
b12d93d6 | 841 | struct mlx4_steer *steer; |
c1b43dca EC |
842 | struct list_head bf_list; |
843 | struct mutex bf_mutex; | |
844 | struct io_mapping *bf_mapping; | |
ddd8a6c1 | 845 | void __iomem *clock_mapping; |
ea51b377 | 846 | int reserved_mtts; |
0ff1fb65 | 847 | int fs_hash_mode; |
54679e14 | 848 | u8 virt2phys_pkey[MLX4_MFUNC_MAX][MLX4_MAX_PORTS][MLX4_MAX_PORT_PKEYS]; |
afa8fd1d | 849 | __be64 slave_node_guids[MLX4_MFUNC_MAX]; |
6ee51a4e | 850 | struct mlx4_roce_gid_entry roce_gids[MLX4_MAX_PORTS][MLX4_ROCE_MAX_GIDS]; |
54679e14 | 851 | |
fe6f700d YP |
852 | atomic_t opreq_count; |
853 | struct work_struct opreq_task; | |
225c7b1f RD |
854 | }; |
855 | ||
856 | static inline struct mlx4_priv *mlx4_priv(struct mlx4_dev *dev) | |
857 | { | |
858 | return container_of(dev, struct mlx4_priv, dev); | |
859 | } | |
860 | ||
27bf91d6 YP |
861 | #define MLX4_SENSE_RANGE (HZ * 3) |
862 | ||
863 | extern struct workqueue_struct *mlx4_wq; | |
864 | ||
225c7b1f | 865 | u32 mlx4_bitmap_alloc(struct mlx4_bitmap *bitmap); |
7c6d74d2 | 866 | void mlx4_bitmap_free(struct mlx4_bitmap *bitmap, u32 obj, int use_rr); |
a3cdcbfa | 867 | u32 mlx4_bitmap_alloc_range(struct mlx4_bitmap *bitmap, int cnt, int align); |
7c6d74d2 JM |
868 | void mlx4_bitmap_free_range(struct mlx4_bitmap *bitmap, u32 obj, int cnt, |
869 | int use_rr); | |
42d1e017 | 870 | u32 mlx4_bitmap_avail(struct mlx4_bitmap *bitmap); |
93fc9e1b YP |
871 | int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, |
872 | u32 reserved_bot, u32 resetrved_top); | |
225c7b1f RD |
873 | void mlx4_bitmap_cleanup(struct mlx4_bitmap *bitmap); |
874 | ||
875 | int mlx4_reset(struct mlx4_dev *dev); | |
876 | ||
b8dd786f YP |
877 | int mlx4_alloc_eq_table(struct mlx4_dev *dev); |
878 | void mlx4_free_eq_table(struct mlx4_dev *dev); | |
879 | ||
225c7b1f | 880 | int mlx4_init_pd_table(struct mlx4_dev *dev); |
012a8ff5 | 881 | int mlx4_init_xrcd_table(struct mlx4_dev *dev); |
225c7b1f RD |
882 | int mlx4_init_uar_table(struct mlx4_dev *dev); |
883 | int mlx4_init_mr_table(struct mlx4_dev *dev); | |
884 | int mlx4_init_eq_table(struct mlx4_dev *dev); | |
885 | int mlx4_init_cq_table(struct mlx4_dev *dev); | |
886 | int mlx4_init_qp_table(struct mlx4_dev *dev); | |
887 | int mlx4_init_srq_table(struct mlx4_dev *dev); | |
888 | int mlx4_init_mcg_table(struct mlx4_dev *dev); | |
889 | ||
890 | void mlx4_cleanup_pd_table(struct mlx4_dev *dev); | |
012a8ff5 | 891 | void mlx4_cleanup_xrcd_table(struct mlx4_dev *dev); |
225c7b1f RD |
892 | void mlx4_cleanup_uar_table(struct mlx4_dev *dev); |
893 | void mlx4_cleanup_mr_table(struct mlx4_dev *dev); | |
894 | void mlx4_cleanup_eq_table(struct mlx4_dev *dev); | |
895 | void mlx4_cleanup_cq_table(struct mlx4_dev *dev); | |
896 | void mlx4_cleanup_qp_table(struct mlx4_dev *dev); | |
897 | void mlx4_cleanup_srq_table(struct mlx4_dev *dev); | |
898 | void mlx4_cleanup_mcg_table(struct mlx4_dev *dev); | |
c82e9aa0 EC |
899 | int __mlx4_qp_alloc_icm(struct mlx4_dev *dev, int qpn); |
900 | void __mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn); | |
901 | int __mlx4_cq_alloc_icm(struct mlx4_dev *dev, int *cqn); | |
902 | void __mlx4_cq_free_icm(struct mlx4_dev *dev, int cqn); | |
903 | int __mlx4_srq_alloc_icm(struct mlx4_dev *dev, int *srqn); | |
904 | void __mlx4_srq_free_icm(struct mlx4_dev *dev, int srqn); | |
b20e519a SM |
905 | int __mlx4_mpt_reserve(struct mlx4_dev *dev); |
906 | void __mlx4_mpt_release(struct mlx4_dev *dev, u32 index); | |
907 | int __mlx4_mpt_alloc_icm(struct mlx4_dev *dev, u32 index); | |
908 | void __mlx4_mpt_free_icm(struct mlx4_dev *dev, u32 index); | |
c82e9aa0 EC |
909 | u32 __mlx4_alloc_mtt_range(struct mlx4_dev *dev, int order); |
910 | void __mlx4_free_mtt_range(struct mlx4_dev *dev, u32 first_seg, int order); | |
225c7b1f | 911 | |
623ed84b JM |
912 | int mlx4_WRITE_MTT_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_SYNC_TPT_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_SW2HW_MPT_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_HW2SW_MPT_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_QUERY_MPT_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_SW2HW_EQ_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_DMA_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); | |
c82e9aa0 EC |
947 | int __mlx4_qp_reserve_range(struct mlx4_dev *dev, int cnt, int align, |
948 | int *base); | |
949 | void __mlx4_qp_release_range(struct mlx4_dev *dev, int base_qpn, int cnt); | |
950 | int __mlx4_register_mac(struct mlx4_dev *dev, u8 port, u64 mac); | |
951 | void __mlx4_unregister_mac(struct mlx4_dev *dev, u8 port, u64 mac); | |
c82e9aa0 EC |
952 | int __mlx4_write_mtt(struct mlx4_dev *dev, struct mlx4_mtt *mtt, |
953 | int start_index, int npages, u64 *page_list); | |
ba062d52 JM |
954 | int __mlx4_counter_alloc(struct mlx4_dev *dev, u32 *idx); |
955 | void __mlx4_counter_free(struct mlx4_dev *dev, u32 idx); | |
956 | int __mlx4_xrcd_alloc(struct mlx4_dev *dev, u32 *xrcdn); | |
957 | void __mlx4_xrcd_free(struct mlx4_dev *dev, u32 xrcdn); | |
623ed84b | 958 | |
ee49bd93 JM |
959 | void mlx4_start_catas_poll(struct mlx4_dev *dev); |
960 | void mlx4_stop_catas_poll(struct mlx4_dev *dev); | |
27bf91d6 | 961 | void mlx4_catas_init(void); |
ee49bd93 | 962 | int mlx4_restart_one(struct pci_dev *pdev); |
225c7b1f RD |
963 | int mlx4_register_device(struct mlx4_dev *dev); |
964 | void mlx4_unregister_device(struct mlx4_dev *dev); | |
00f5ce99 JM |
965 | void mlx4_dispatch_event(struct mlx4_dev *dev, enum mlx4_dev_event type, |
966 | unsigned long param); | |
225c7b1f RD |
967 | |
968 | struct mlx4_dev_cap; | |
969 | struct mlx4_init_hca_param; | |
970 | ||
971 | u64 mlx4_make_profile(struct mlx4_dev *dev, | |
972 | struct mlx4_profile *request, | |
973 | struct mlx4_dev_cap *dev_cap, | |
974 | struct mlx4_init_hca_param *init_hca); | |
623ed84b JM |
975 | void mlx4_master_comm_channel(struct work_struct *work); |
976 | void mlx4_gen_slave_eqe(struct work_struct *work); | |
977 | void mlx4_master_handle_slave_flr(struct work_struct *work); | |
978 | ||
979 | int mlx4_ALLOC_RES_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_FREE_RES_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_MAP_EQ_wrapper(struct mlx4_dev *dev, int slave, | |
990 | struct mlx4_vhcr *vhcr, struct mlx4_cmd_mailbox *inbox, | |
991 | struct mlx4_cmd_mailbox *outbox, | |
992 | struct mlx4_cmd_info *cmd); | |
993 | int mlx4_COMM_INT_wrapper(struct mlx4_dev *dev, int slave, | |
994 | struct mlx4_vhcr *vhcr, | |
995 | struct mlx4_cmd_mailbox *inbox, | |
996 | struct mlx4_cmd_mailbox *outbox, | |
997 | struct mlx4_cmd_info *cmd); | |
998 | int mlx4_HW2SW_EQ_wrapper(struct mlx4_dev *dev, int slave, | |
999 | struct mlx4_vhcr *vhcr, | |
1000 | struct mlx4_cmd_mailbox *inbox, | |
1001 | struct mlx4_cmd_mailbox *outbox, | |
1002 | struct mlx4_cmd_info *cmd); | |
1003 | int mlx4_QUERY_EQ_wrapper(struct mlx4_dev *dev, int slave, | |
1004 | struct mlx4_vhcr *vhcr, | |
1005 | struct mlx4_cmd_mailbox *inbox, | |
1006 | struct mlx4_cmd_mailbox *outbox, | |
1007 | struct mlx4_cmd_info *cmd); | |
1008 | int mlx4_SW2HW_CQ_wrapper(struct mlx4_dev *dev, int slave, | |
1009 | struct mlx4_vhcr *vhcr, | |
1010 | struct mlx4_cmd_mailbox *inbox, | |
1011 | struct mlx4_cmd_mailbox *outbox, | |
1012 | struct mlx4_cmd_info *cmd); | |
1013 | int mlx4_HW2SW_CQ_wrapper(struct mlx4_dev *dev, int slave, | |
1014 | struct mlx4_vhcr *vhcr, | |
1015 | struct mlx4_cmd_mailbox *inbox, | |
1016 | struct mlx4_cmd_mailbox *outbox, | |
1017 | struct mlx4_cmd_info *cmd); | |
1018 | int mlx4_QUERY_CQ_wrapper(struct mlx4_dev *dev, int slave, | |
1019 | struct mlx4_vhcr *vhcr, | |
1020 | struct mlx4_cmd_mailbox *inbox, | |
1021 | struct mlx4_cmd_mailbox *outbox, | |
1022 | struct mlx4_cmd_info *cmd); | |
1023 | int mlx4_MODIFY_CQ_wrapper(struct mlx4_dev *dev, int slave, | |
1024 | struct mlx4_vhcr *vhcr, | |
1025 | struct mlx4_cmd_mailbox *inbox, | |
1026 | struct mlx4_cmd_mailbox *outbox, | |
1027 | struct mlx4_cmd_info *cmd); | |
1028 | int mlx4_SW2HW_SRQ_wrapper(struct mlx4_dev *dev, int slave, | |
1029 | struct mlx4_vhcr *vhcr, | |
1030 | struct mlx4_cmd_mailbox *inbox, | |
1031 | struct mlx4_cmd_mailbox *outbox, | |
1032 | struct mlx4_cmd_info *cmd); | |
1033 | int mlx4_HW2SW_SRQ_wrapper(struct mlx4_dev *dev, int slave, | |
1034 | struct mlx4_vhcr *vhcr, | |
1035 | struct mlx4_cmd_mailbox *inbox, | |
1036 | struct mlx4_cmd_mailbox *outbox, | |
1037 | struct mlx4_cmd_info *cmd); | |
1038 | int mlx4_QUERY_SRQ_wrapper(struct mlx4_dev *dev, int slave, | |
1039 | struct mlx4_vhcr *vhcr, | |
1040 | struct mlx4_cmd_mailbox *inbox, | |
1041 | struct mlx4_cmd_mailbox *outbox, | |
1042 | struct mlx4_cmd_info *cmd); | |
1043 | int mlx4_ARM_SRQ_wrapper(struct mlx4_dev *dev, int slave, | |
1044 | struct mlx4_vhcr *vhcr, | |
1045 | struct mlx4_cmd_mailbox *inbox, | |
1046 | struct mlx4_cmd_mailbox *outbox, | |
1047 | struct mlx4_cmd_info *cmd); | |
1048 | int mlx4_GEN_QP_wrapper(struct mlx4_dev *dev, int slave, | |
1049 | struct mlx4_vhcr *vhcr, | |
1050 | struct mlx4_cmd_mailbox *inbox, | |
1051 | struct mlx4_cmd_mailbox *outbox, | |
1052 | struct mlx4_cmd_info *cmd); | |
1053 | int mlx4_RST2INIT_QP_wrapper(struct mlx4_dev *dev, int slave, | |
1054 | struct mlx4_vhcr *vhcr, | |
1055 | struct mlx4_cmd_mailbox *inbox, | |
1056 | struct mlx4_cmd_mailbox *outbox, | |
1057 | struct mlx4_cmd_info *cmd); | |
54679e14 JM |
1058 | int mlx4_INIT2INIT_QP_wrapper(struct mlx4_dev *dev, int slave, |
1059 | struct mlx4_vhcr *vhcr, | |
1060 | struct mlx4_cmd_mailbox *inbox, | |
1061 | struct mlx4_cmd_mailbox *outbox, | |
1062 | struct mlx4_cmd_info *cmd); | |
623ed84b JM |
1063 | int mlx4_INIT2RTR_QP_wrapper(struct mlx4_dev *dev, int slave, |
1064 | struct mlx4_vhcr *vhcr, | |
1065 | struct mlx4_cmd_mailbox *inbox, | |
1066 | struct mlx4_cmd_mailbox *outbox, | |
1067 | struct mlx4_cmd_info *cmd); | |
54679e14 JM |
1068 | int mlx4_RTR2RTS_QP_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_RTS2RTS_QP_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_SQERR2RTS_QP_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_2ERR_QP_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_RTS2SQD_QP_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_SQD2SQD_QP_wrapper(struct mlx4_dev *dev, int slave, | |
1094 | struct mlx4_vhcr *vhcr, | |
1095 | struct mlx4_cmd_mailbox *inbox, | |
1096 | struct mlx4_cmd_mailbox *outbox, | |
1097 | struct mlx4_cmd_info *cmd); | |
1098 | int mlx4_SQD2RTS_QP_wrapper(struct mlx4_dev *dev, int slave, | |
1099 | struct mlx4_vhcr *vhcr, | |
1100 | struct mlx4_cmd_mailbox *inbox, | |
1101 | struct mlx4_cmd_mailbox *outbox, | |
1102 | struct mlx4_cmd_info *cmd); | |
623ed84b JM |
1103 | int mlx4_2RST_QP_wrapper(struct mlx4_dev *dev, int slave, |
1104 | struct mlx4_vhcr *vhcr, | |
1105 | struct mlx4_cmd_mailbox *inbox, | |
1106 | struct mlx4_cmd_mailbox *outbox, | |
1107 | struct mlx4_cmd_info *cmd); | |
54679e14 JM |
1108 | int mlx4_QUERY_QP_wrapper(struct mlx4_dev *dev, int slave, |
1109 | struct mlx4_vhcr *vhcr, | |
1110 | struct mlx4_cmd_mailbox *inbox, | |
1111 | struct mlx4_cmd_mailbox *outbox, | |
1112 | struct mlx4_cmd_info *cmd); | |
623ed84b JM |
1113 | |
1114 | int mlx4_GEN_EQE(struct mlx4_dev *dev, int slave, struct mlx4_eqe *eqe); | |
225c7b1f | 1115 | |
225c7b1f RD |
1116 | int mlx4_cmd_init(struct mlx4_dev *dev); |
1117 | void mlx4_cmd_cleanup(struct mlx4_dev *dev); | |
ab9c17a0 JM |
1118 | int mlx4_multi_func_init(struct mlx4_dev *dev); |
1119 | void mlx4_multi_func_cleanup(struct mlx4_dev *dev); | |
225c7b1f RD |
1120 | void mlx4_cmd_event(struct mlx4_dev *dev, u16 token, u8 status, u64 out_param); |
1121 | int mlx4_cmd_use_events(struct mlx4_dev *dev); | |
1122 | void mlx4_cmd_use_polling(struct mlx4_dev *dev); | |
1123 | ||
ab9c17a0 JM |
1124 | int mlx4_comm_cmd(struct mlx4_dev *dev, u8 cmd, u16 param, |
1125 | unsigned long timeout); | |
1126 | ||
225c7b1f RD |
1127 | void mlx4_cq_completion(struct mlx4_dev *dev, u32 cqn); |
1128 | void mlx4_cq_event(struct mlx4_dev *dev, u32 cqn, int event_type); | |
1129 | ||
1130 | void mlx4_qp_event(struct mlx4_dev *dev, u32 qpn, int event_type); | |
1131 | ||
1132 | void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type); | |
1133 | ||
1134 | void mlx4_handle_catas_err(struct mlx4_dev *dev); | |
1135 | ||
ab6dc30d YP |
1136 | int mlx4_SENSE_PORT(struct mlx4_dev *dev, int port, |
1137 | enum mlx4_port_type *type); | |
27bf91d6 YP |
1138 | void mlx4_do_sense_ports(struct mlx4_dev *dev, |
1139 | enum mlx4_port_type *stype, | |
1140 | enum mlx4_port_type *defaults); | |
1141 | void mlx4_start_sense(struct mlx4_dev *dev); | |
1142 | void mlx4_stop_sense(struct mlx4_dev *dev); | |
1143 | void mlx4_sense_init(struct mlx4_dev *dev); | |
1144 | int mlx4_check_port_params(struct mlx4_dev *dev, | |
1145 | enum mlx4_port_type *port_type); | |
1146 | int mlx4_change_port_types(struct mlx4_dev *dev, | |
1147 | enum mlx4_port_type *port_types); | |
1148 | ||
2a2336f8 YP |
1149 | void mlx4_init_mac_table(struct mlx4_dev *dev, struct mlx4_mac_table *table); |
1150 | void mlx4_init_vlan_table(struct mlx4_dev *dev, struct mlx4_vlan_table *table); | |
2009d005 | 1151 | void __mlx4_unregister_vlan(struct mlx4_dev *dev, u8 port, u16 vlan); |
3f7fb021 | 1152 | int __mlx4_register_vlan(struct mlx4_dev *dev, u8 port, u16 vlan, int *index); |
2a2336f8 | 1153 | |
6634961c | 1154 | int mlx4_SET_PORT(struct mlx4_dev *dev, u8 port, int pkey_tbl_sz); |
623ed84b JM |
1155 | /* resource tracker functions*/ |
1156 | int mlx4_get_slave_from_resource_id(struct mlx4_dev *dev, | |
1157 | enum mlx4_resource resource_type, | |
aa1ec3dd | 1158 | u64 resource_id, int *slave); |
623ed84b JM |
1159 | void mlx4_delete_all_resources_for_slave(struct mlx4_dev *dev, int slave_id); |
1160 | int mlx4_init_resource_tracker(struct mlx4_dev *dev); | |
1161 | ||
b8924951 JM |
1162 | void mlx4_free_resource_tracker(struct mlx4_dev *dev, |
1163 | enum mlx4_res_tracker_free_type type); | |
623ed84b | 1164 | |
b91cb3eb JM |
1165 | int mlx4_QUERY_FW_wrapper(struct mlx4_dev *dev, int slave, |
1166 | struct mlx4_vhcr *vhcr, | |
1167 | struct mlx4_cmd_mailbox *inbox, | |
1168 | struct mlx4_cmd_mailbox *outbox, | |
1169 | struct mlx4_cmd_info *cmd); | |
623ed84b JM |
1170 | int mlx4_SET_PORT_wrapper(struct mlx4_dev *dev, int slave, |
1171 | struct mlx4_vhcr *vhcr, | |
1172 | struct mlx4_cmd_mailbox *inbox, | |
1173 | struct mlx4_cmd_mailbox *outbox, | |
1174 | struct mlx4_cmd_info *cmd); | |
1175 | int mlx4_INIT_PORT_wrapper(struct mlx4_dev *dev, int slave, | |
1176 | struct mlx4_vhcr *vhcr, | |
1177 | struct mlx4_cmd_mailbox *inbox, | |
1178 | struct mlx4_cmd_mailbox *outbox, | |
1179 | struct mlx4_cmd_info *cmd); | |
1180 | int mlx4_CLOSE_PORT_wrapper(struct mlx4_dev *dev, int slave, | |
1181 | struct mlx4_vhcr *vhcr, | |
1182 | struct mlx4_cmd_mailbox *inbox, | |
1183 | struct mlx4_cmd_mailbox *outbox, | |
1184 | struct mlx4_cmd_info *cmd); | |
b91cb3eb JM |
1185 | int mlx4_QUERY_DEV_CAP_wrapper(struct mlx4_dev *dev, int slave, |
1186 | struct mlx4_vhcr *vhcr, | |
1187 | struct mlx4_cmd_mailbox *inbox, | |
1188 | struct mlx4_cmd_mailbox *outbox, | |
1189 | struct mlx4_cmd_info *cmd); | |
623ed84b JM |
1190 | int mlx4_QUERY_PORT_wrapper(struct mlx4_dev *dev, int slave, |
1191 | struct mlx4_vhcr *vhcr, | |
1192 | struct mlx4_cmd_mailbox *inbox, | |
1193 | struct mlx4_cmd_mailbox *outbox, | |
1194 | struct mlx4_cmd_info *cmd); | |
9a5aa622 | 1195 | int mlx4_get_port_ib_caps(struct mlx4_dev *dev, u8 port, __be32 *caps); |
7ff93f8b | 1196 | |
6634961c JM |
1197 | int mlx4_get_slave_pkey_gid_tbl_len(struct mlx4_dev *dev, u8 port, |
1198 | int *gid_tbl_len, int *pkey_tbl_len); | |
623ed84b JM |
1199 | |
1200 | int mlx4_QP_ATTACH_wrapper(struct mlx4_dev *dev, int slave, | |
1201 | struct mlx4_vhcr *vhcr, | |
1202 | struct mlx4_cmd_mailbox *inbox, | |
1203 | struct mlx4_cmd_mailbox *outbox, | |
1204 | struct mlx4_cmd_info *cmd); | |
1205 | ||
1206 | int mlx4_PROMISC_wrapper(struct mlx4_dev *dev, int slave, | |
1207 | struct mlx4_vhcr *vhcr, | |
1208 | struct mlx4_cmd_mailbox *inbox, | |
1209 | struct mlx4_cmd_mailbox *outbox, | |
1210 | struct mlx4_cmd_info *cmd); | |
b12d93d6 YP |
1211 | int mlx4_qp_detach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], |
1212 | enum mlx4_protocol prot, enum mlx4_steer_type steer); | |
1213 | int mlx4_qp_attach_common(struct mlx4_dev *dev, struct mlx4_qp *qp, u8 gid[16], | |
1214 | int block_mcast_loopback, enum mlx4_protocol prot, | |
1215 | enum mlx4_steer_type steer); | |
fd91c49f HHZ |
1216 | int mlx4_trans_to_dmfs_attach(struct mlx4_dev *dev, struct mlx4_qp *qp, |
1217 | u8 gid[16], u8 port, | |
1218 | int block_mcast_loopback, | |
1219 | enum mlx4_protocol prot, u64 *reg_id); | |
623ed84b JM |
1220 | int mlx4_SET_MCAST_FLTR_wrapper(struct mlx4_dev *dev, int slave, |
1221 | struct mlx4_vhcr *vhcr, | |
1222 | struct mlx4_cmd_mailbox *inbox, | |
1223 | struct mlx4_cmd_mailbox *outbox, | |
1224 | struct mlx4_cmd_info *cmd); | |
1225 | int mlx4_SET_VLAN_FLTR_wrapper(struct mlx4_dev *dev, int slave, | |
1226 | struct mlx4_vhcr *vhcr, | |
1227 | struct mlx4_cmd_mailbox *inbox, | |
1228 | struct mlx4_cmd_mailbox *outbox, | |
1229 | struct mlx4_cmd_info *cmd); | |
1230 | int mlx4_common_set_vlan_fltr(struct mlx4_dev *dev, int function, | |
1231 | int port, void *buf); | |
1232 | int mlx4_common_dump_eth_stats(struct mlx4_dev *dev, int slave, u32 in_mod, | |
1233 | struct mlx4_cmd_mailbox *outbox); | |
1234 | int mlx4_DUMP_ETH_STATS_wrapper(struct mlx4_dev *dev, int slave, | |
1235 | struct mlx4_vhcr *vhcr, | |
1236 | struct mlx4_cmd_mailbox *inbox, | |
1237 | struct mlx4_cmd_mailbox *outbox, | |
1238 | struct mlx4_cmd_info *cmd); | |
1239 | int mlx4_PKEY_TABLE_wrapper(struct mlx4_dev *dev, int slave, | |
1240 | struct mlx4_vhcr *vhcr, | |
1241 | struct mlx4_cmd_mailbox *inbox, | |
1242 | struct mlx4_cmd_mailbox *outbox, | |
1243 | struct mlx4_cmd_info *cmd); | |
1244 | int mlx4_QUERY_IF_STAT_wrapper(struct mlx4_dev *dev, int slave, | |
1245 | struct mlx4_vhcr *vhcr, | |
1246 | struct mlx4_cmd_mailbox *inbox, | |
1247 | struct mlx4_cmd_mailbox *outbox, | |
1248 | struct mlx4_cmd_info *cmd); | |
8fcfb4db HHZ |
1249 | int mlx4_QP_FLOW_STEERING_ATTACH_wrapper(struct mlx4_dev *dev, int slave, |
1250 | struct mlx4_vhcr *vhcr, | |
1251 | struct mlx4_cmd_mailbox *inbox, | |
1252 | struct mlx4_cmd_mailbox *outbox, | |
1253 | struct mlx4_cmd_info *cmd); | |
1254 | int mlx4_QP_FLOW_STEERING_DETACH_wrapper(struct mlx4_dev *dev, int slave, | |
1255 | struct mlx4_vhcr *vhcr, | |
1256 | struct mlx4_cmd_mailbox *inbox, | |
1257 | struct mlx4_cmd_mailbox *outbox, | |
1258 | struct mlx4_cmd_info *cmd); | |
f5311ac1 | 1259 | |
0ec2c0f8 EE |
1260 | int mlx4_get_mgm_entry_size(struct mlx4_dev *dev); |
1261 | int mlx4_get_qp_per_mgm(struct mlx4_dev *dev); | |
1262 | ||
5cc914f1 MA |
1263 | static inline void set_param_l(u64 *arg, u32 val) |
1264 | { | |
e7dbeba8 | 1265 | *arg = (*arg & 0xffffffff00000000ULL) | (u64) val; |
5cc914f1 MA |
1266 | } |
1267 | ||
1268 | static inline void set_param_h(u64 *arg, u32 val) | |
1269 | { | |
1270 | *arg = (*arg & 0xffffffff) | ((u64) val << 32); | |
1271 | } | |
1272 | ||
1273 | static inline u32 get_param_l(u64 *arg) | |
1274 | { | |
1275 | return (u32) (*arg & 0xffffffff); | |
1276 | } | |
1277 | ||
1278 | static inline u32 get_param_h(u64 *arg) | |
1279 | { | |
1280 | return (u32)(*arg >> 32); | |
1281 | } | |
1282 | ||
c82e9aa0 EC |
1283 | static inline spinlock_t *mlx4_tlock(struct mlx4_dev *dev) |
1284 | { | |
1285 | return &mlx4_priv(dev)->mfunc.master.res_tracker.lock; | |
1286 | } | |
1287 | ||
f5311ac1 JM |
1288 | #define NOT_MASKED_PD_BITS 17 |
1289 | ||
b01978ca JM |
1290 | void mlx4_vf_immed_vlan_work_handler(struct work_struct *_work); |
1291 | ||
5a0d0a61 JM |
1292 | void mlx4_init_quotas(struct mlx4_dev *dev); |
1293 | ||
449fc488 | 1294 | int mlx4_get_slave_num_gids(struct mlx4_dev *dev, int slave, int port); |
f74462ac MB |
1295 | /* Returns the VF index of slave */ |
1296 | int mlx4_get_vf_indx(struct mlx4_dev *dev, int slave); | |
b6ffaeff | 1297 | |
225c7b1f | 1298 | #endif /* MLX4_H */ |