]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - drivers/net/ethernet/qlogic/qed/qed.h
8c85fd2f3949118fa41c346c03023620d6d78b71
[mirror_ubuntu-artful-kernel.git] / drivers / net / ethernet / qlogic / qed / qed.h
1 /* QLogic qed NIC Driver
2 * Copyright (c) 2015-2017 QLogic Corporation
3 *
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
9 *
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
12 * conditions are met:
13 *
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and /or other materials
21 * provided with the distribution.
22 *
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE.
31 */
32
33 #ifndef _QED_H
34 #define _QED_H
35
36 #include <linux/types.h>
37 #include <linux/io.h>
38 #include <linux/delay.h>
39 #include <linux/firmware.h>
40 #include <linux/interrupt.h>
41 #include <linux/list.h>
42 #include <linux/mutex.h>
43 #include <linux/pci.h>
44 #include <linux/slab.h>
45 #include <linux/string.h>
46 #include <linux/workqueue.h>
47 #include <linux/zlib.h>
48 #include <linux/hashtable.h>
49 #include <linux/qed/qed_if.h>
50 #include "qed_debug.h"
51 #include "qed_hsi.h"
52
53 extern const struct qed_common_ops qed_common_ops_pass;
54
55 #define QED_MAJOR_VERSION 8
56 #define QED_MINOR_VERSION 10
57 #define QED_REVISION_VERSION 10
58 #define QED_ENGINEERING_VERSION 21
59
60 #define QED_VERSION \
61 ((QED_MAJOR_VERSION << 24) | (QED_MINOR_VERSION << 16) | \
62 (QED_REVISION_VERSION << 8) | QED_ENGINEERING_VERSION)
63
64 #define STORM_FW_VERSION \
65 ((FW_MAJOR_VERSION << 24) | (FW_MINOR_VERSION << 16) | \
66 (FW_REVISION_VERSION << 8) | FW_ENGINEERING_VERSION)
67
68 #define MAX_HWFNS_PER_DEVICE (4)
69 #define NAME_SIZE 16
70 #define VER_SIZE 16
71
72 #define QED_WFQ_UNIT 100
73
74 #define QED_WID_SIZE (1024)
75 #define QED_PF_DEMS_SIZE (4)
76
77 /* cau states */
78 enum qed_coalescing_mode {
79 QED_COAL_MODE_DISABLE,
80 QED_COAL_MODE_ENABLE
81 };
82
83 struct qed_eth_cb_ops;
84 struct qed_dev_info;
85 union qed_mcp_protocol_stats;
86 enum qed_mcp_protocol_type;
87
88 /* helpers */
89 #define QED_MFW_GET_FIELD(name, field) \
90 (((name) & (field ## _MASK)) >> (field ## _SHIFT))
91
92 #define QED_MFW_SET_FIELD(name, field, value) \
93 do { \
94 (name) &= ~((field ## _MASK) << (field ## _SHIFT)); \
95 (name) |= (((value) << (field ## _SHIFT)) & (field ## _MASK));\
96 } while (0)
97
98 static inline u32 qed_db_addr(u32 cid, u32 DEMS)
99 {
100 u32 db_addr = FIELD_VALUE(DB_LEGACY_ADDR_DEMS, DEMS) |
101 (cid * QED_PF_DEMS_SIZE);
102
103 return db_addr;
104 }
105
106 static inline u32 qed_db_addr_vf(u32 cid, u32 DEMS)
107 {
108 u32 db_addr = FIELD_VALUE(DB_LEGACY_ADDR_DEMS, DEMS) |
109 FIELD_VALUE(DB_LEGACY_ADDR_ICID, cid);
110
111 return db_addr;
112 }
113
114 #define ALIGNED_TYPE_SIZE(type_name, p_hwfn) \
115 ((sizeof(type_name) + (u32)(1 << (p_hwfn->cdev->cache_shift)) - 1) & \
116 ~((1 << (p_hwfn->cdev->cache_shift)) - 1))
117
118 #define for_each_hwfn(cdev, i) for (i = 0; i < cdev->num_hwfns; i++)
119
120 #define D_TRINE(val, cond1, cond2, true1, true2, def) \
121 (val == (cond1) ? true1 : \
122 (val == (cond2) ? true2 : def))
123
124 /* forward */
125 struct qed_ptt_pool;
126 struct qed_spq;
127 struct qed_sb_info;
128 struct qed_sb_attn_info;
129 struct qed_cxt_mngr;
130 struct qed_sb_sp_info;
131 struct qed_ll2_info;
132 struct qed_mcp_info;
133
134 struct qed_rt_data {
135 u32 *init_val;
136 bool *b_valid;
137 };
138
139 enum qed_tunn_mode {
140 QED_MODE_L2GENEVE_TUNN,
141 QED_MODE_IPGENEVE_TUNN,
142 QED_MODE_L2GRE_TUNN,
143 QED_MODE_IPGRE_TUNN,
144 QED_MODE_VXLAN_TUNN,
145 };
146
147 enum qed_tunn_clss {
148 QED_TUNN_CLSS_MAC_VLAN,
149 QED_TUNN_CLSS_MAC_VNI,
150 QED_TUNN_CLSS_INNER_MAC_VLAN,
151 QED_TUNN_CLSS_INNER_MAC_VNI,
152 MAX_QED_TUNN_CLSS,
153 };
154
155 struct qed_tunn_start_params {
156 unsigned long tunn_mode;
157 u16 vxlan_udp_port;
158 u16 geneve_udp_port;
159 u8 update_vxlan_udp_port;
160 u8 update_geneve_udp_port;
161 u8 tunn_clss_vxlan;
162 u8 tunn_clss_l2geneve;
163 u8 tunn_clss_ipgeneve;
164 u8 tunn_clss_l2gre;
165 u8 tunn_clss_ipgre;
166 };
167
168 struct qed_tunn_update_params {
169 unsigned long tunn_mode_update_mask;
170 unsigned long tunn_mode;
171 u16 vxlan_udp_port;
172 u16 geneve_udp_port;
173 u8 update_rx_pf_clss;
174 u8 update_tx_pf_clss;
175 u8 update_vxlan_udp_port;
176 u8 update_geneve_udp_port;
177 u8 tunn_clss_vxlan;
178 u8 tunn_clss_l2geneve;
179 u8 tunn_clss_ipgeneve;
180 u8 tunn_clss_l2gre;
181 u8 tunn_clss_ipgre;
182 };
183
184 /* The PCI personality is not quite synonymous to protocol ID:
185 * 1. All personalities need CORE connections
186 * 2. The Ethernet personality may support also the RoCE protocol
187 */
188 enum qed_pci_personality {
189 QED_PCI_ETH,
190 QED_PCI_FCOE,
191 QED_PCI_ISCSI,
192 QED_PCI_ETH_ROCE,
193 QED_PCI_DEFAULT /* default in shmem */
194 };
195
196 /* All VFs are symmetric, all counters are PF + all VFs */
197 struct qed_qm_iids {
198 u32 cids;
199 u32 vf_cids;
200 u32 tids;
201 };
202
203 /* HW / FW resources, output of features supported below, most information
204 * is received from MFW.
205 */
206 enum qed_resources {
207 QED_SB,
208 QED_L2_QUEUE,
209 QED_VPORT,
210 QED_RSS_ENG,
211 QED_PQ,
212 QED_RL,
213 QED_MAC,
214 QED_VLAN,
215 QED_RDMA_CNQ_RAM,
216 QED_ILT,
217 QED_LL2_QUEUE,
218 QED_CMDQS_CQS,
219 QED_RDMA_STATS_QUEUE,
220 QED_BDQ,
221 QED_MAX_RESC,
222 };
223
224 enum QED_FEATURE {
225 QED_PF_L2_QUE,
226 QED_VF,
227 QED_RDMA_CNQ,
228 QED_VF_L2_QUE,
229 QED_FCOE_CQ,
230 QED_MAX_FEATURES,
231 };
232
233 enum QED_PORT_MODE {
234 QED_PORT_MODE_DE_2X40G,
235 QED_PORT_MODE_DE_2X50G,
236 QED_PORT_MODE_DE_1X100G,
237 QED_PORT_MODE_DE_4X10G_F,
238 QED_PORT_MODE_DE_4X10G_E,
239 QED_PORT_MODE_DE_4X20G,
240 QED_PORT_MODE_DE_1X40G,
241 QED_PORT_MODE_DE_2X25G,
242 QED_PORT_MODE_DE_1X25G,
243 QED_PORT_MODE_DE_4X25G,
244 QED_PORT_MODE_DE_2X10G,
245 };
246
247 enum qed_dev_cap {
248 QED_DEV_CAP_ETH,
249 QED_DEV_CAP_FCOE,
250 QED_DEV_CAP_ISCSI,
251 QED_DEV_CAP_ROCE,
252 };
253
254 enum qed_wol_support {
255 QED_WOL_SUPPORT_NONE,
256 QED_WOL_SUPPORT_PME,
257 };
258
259 struct qed_hw_info {
260 /* PCI personality */
261 enum qed_pci_personality personality;
262
263 /* Resource Allocation scheme results */
264 u32 resc_start[QED_MAX_RESC];
265 u32 resc_num[QED_MAX_RESC];
266 u32 feat_num[QED_MAX_FEATURES];
267
268 #define RESC_START(_p_hwfn, resc) ((_p_hwfn)->hw_info.resc_start[resc])
269 #define RESC_NUM(_p_hwfn, resc) ((_p_hwfn)->hw_info.resc_num[resc])
270 #define RESC_END(_p_hwfn, resc) (RESC_START(_p_hwfn, resc) + \
271 RESC_NUM(_p_hwfn, resc))
272 #define FEAT_NUM(_p_hwfn, resc) ((_p_hwfn)->hw_info.feat_num[resc])
273
274 u8 num_tc;
275 u8 offload_tc;
276 u8 non_offload_tc;
277
278 u32 concrete_fid;
279 u16 opaque_fid;
280 u16 ovlan;
281 u32 part_num[4];
282
283 unsigned char hw_mac_addr[ETH_ALEN];
284 u64 node_wwn;
285 u64 port_wwn;
286
287 u16 num_fcoe_conns;
288
289 struct qed_igu_info *p_igu_info;
290
291 u32 port_mode;
292 u32 hw_mode;
293 unsigned long device_capabilities;
294 u16 mtu;
295
296 enum qed_wol_support b_wol_support;
297 };
298
299 /* maximun size of read/write commands (HW limit) */
300 #define DMAE_MAX_RW_SIZE 0x2000
301
302 struct qed_dmae_info {
303 /* Mutex for synchronizing access to functions */
304 struct mutex mutex;
305
306 u8 channel;
307
308 dma_addr_t completion_word_phys_addr;
309
310 /* The memory location where the DMAE writes the completion
311 * value when an operation is finished on this context.
312 */
313 u32 *p_completion_word;
314
315 dma_addr_t intermediate_buffer_phys_addr;
316
317 /* An intermediate buffer for DMAE operations that use virtual
318 * addresses - data is DMA'd to/from this buffer and then
319 * memcpy'd to/from the virtual address
320 */
321 u32 *p_intermediate_buffer;
322
323 dma_addr_t dmae_cmd_phys_addr;
324 struct dmae_cmd *p_dmae_cmd;
325 };
326
327 struct qed_wfq_data {
328 /* when feature is configured for at least 1 vport */
329 u32 min_speed;
330 bool configured;
331 };
332
333 struct qed_qm_info {
334 struct init_qm_pq_params *qm_pq_params;
335 struct init_qm_vport_params *qm_vport_params;
336 struct init_qm_port_params *qm_port_params;
337 u16 start_pq;
338 u8 start_vport;
339 u8 pure_lb_pq;
340 u8 offload_pq;
341 u8 pure_ack_pq;
342 u8 ooo_pq;
343 u8 vf_queues_offset;
344 u16 num_pqs;
345 u16 num_vf_pqs;
346 u8 num_vports;
347 u8 max_phys_tcs_per_port;
348 bool pf_rl_en;
349 bool pf_wfq_en;
350 bool vport_rl_en;
351 bool vport_wfq_en;
352 u8 pf_wfq;
353 u32 pf_rl;
354 struct qed_wfq_data *wfq_data;
355 u8 num_pf_rls;
356 };
357
358 struct storm_stats {
359 u32 address;
360 u32 len;
361 };
362
363 struct qed_storm_stats {
364 struct storm_stats mstats;
365 struct storm_stats pstats;
366 struct storm_stats tstats;
367 struct storm_stats ustats;
368 };
369
370 struct qed_fw_data {
371 struct fw_ver_info *fw_ver_info;
372 const u8 *modes_tree_buf;
373 union init_op *init_ops;
374 const u32 *arr_data;
375 u32 init_ops_size;
376 };
377
378 #define DRV_MODULE_VERSION \
379 __stringify(QED_MAJOR_VERSION) "." \
380 __stringify(QED_MINOR_VERSION) "." \
381 __stringify(QED_REVISION_VERSION) "." \
382 __stringify(QED_ENGINEERING_VERSION)
383
384 struct qed_simd_fp_handler {
385 void *token;
386 void (*func)(void *);
387 };
388
389 struct qed_hwfn {
390 struct qed_dev *cdev;
391 u8 my_id; /* ID inside the PF */
392 #define IS_LEAD_HWFN(edev) (!((edev)->my_id))
393 u8 rel_pf_id; /* Relative to engine*/
394 u8 abs_pf_id;
395 #define QED_PATH_ID(_p_hwfn) \
396 (QED_IS_K2((_p_hwfn)->cdev) ? 0 : ((_p_hwfn)->abs_pf_id & 1))
397 u8 port_id;
398 bool b_active;
399
400 u32 dp_module;
401 u8 dp_level;
402 char name[NAME_SIZE];
403
404 bool first_on_engine;
405 bool hw_init_done;
406
407 u8 num_funcs_on_engine;
408 u8 enabled_func_idx;
409
410 /* BAR access */
411 void __iomem *regview;
412 void __iomem *doorbells;
413 u64 db_phys_addr;
414 unsigned long db_size;
415
416 /* PTT pool */
417 struct qed_ptt_pool *p_ptt_pool;
418
419 /* HW info */
420 struct qed_hw_info hw_info;
421
422 /* rt_array (for init-tool) */
423 struct qed_rt_data rt_data;
424
425 /* SPQ */
426 struct qed_spq *p_spq;
427
428 /* EQ */
429 struct qed_eq *p_eq;
430
431 /* Consolidate Q*/
432 struct qed_consq *p_consq;
433
434 /* Slow-Path definitions */
435 struct tasklet_struct *sp_dpc;
436 bool b_sp_dpc_enabled;
437
438 struct qed_ptt *p_main_ptt;
439 struct qed_ptt *p_dpc_ptt;
440
441 struct qed_sb_sp_info *p_sp_sb;
442 struct qed_sb_attn_info *p_sb_attn;
443
444 /* Protocol related */
445 bool using_ll2;
446 struct qed_ll2_info *p_ll2_info;
447 struct qed_ooo_info *p_ooo_info;
448 struct qed_rdma_info *p_rdma_info;
449 struct qed_iscsi_info *p_iscsi_info;
450 struct qed_fcoe_info *p_fcoe_info;
451 struct qed_pf_params pf_params;
452
453 bool b_rdma_enabled_in_prs;
454 u32 rdma_prs_search_reg;
455
456 /* Array of sb_info of all status blocks */
457 struct qed_sb_info *sbs_info[MAX_SB_PER_PF_MIMD];
458 u16 num_sbs;
459
460 struct qed_cxt_mngr *p_cxt_mngr;
461
462 /* Flag indicating whether interrupts are enabled or not*/
463 bool b_int_enabled;
464 bool b_int_requested;
465
466 /* True if the driver requests for the link */
467 bool b_drv_link_init;
468
469 struct qed_vf_iov *vf_iov_info;
470 struct qed_pf_iov *pf_iov_info;
471 struct qed_mcp_info *mcp_info;
472
473 struct qed_dcbx_info *p_dcbx_info;
474
475 struct qed_dmae_info dmae_info;
476
477 /* QM init */
478 struct qed_qm_info qm_info;
479 struct qed_storm_stats storm_stats;
480
481 /* Buffer for unzipping firmware data */
482 void *unzip_buf;
483
484 struct dbg_tools_data dbg_info;
485
486 /* PWM region specific data */
487 u32 dpi_size;
488 u32 dpi_count;
489
490 /* This is used to calculate the doorbell address */
491 u32 dpi_start_offset;
492
493 /* If one of the following is set then EDPM shouldn't be used */
494 u8 dcbx_no_edpm;
495 u8 db_bar_no_edpm;
496
497 /* p_ptp_ptt is valid for leading HWFN only */
498 struct qed_ptt *p_ptp_ptt;
499 struct qed_simd_fp_handler simd_proto_handler[64];
500
501 #ifdef CONFIG_QED_SRIOV
502 struct workqueue_struct *iov_wq;
503 struct delayed_work iov_task;
504 unsigned long iov_task_flags;
505 #endif
506
507 struct z_stream_s *stream;
508 struct qed_roce_ll2_info *ll2;
509 };
510
511 struct pci_params {
512 int pm_cap;
513
514 unsigned long mem_start;
515 unsigned long mem_end;
516 unsigned int irq;
517 u8 pf_num;
518 };
519
520 struct qed_int_param {
521 u32 int_mode;
522 u8 num_vectors;
523 u8 min_msix_cnt; /* for minimal functionality */
524 };
525
526 struct qed_int_params {
527 struct qed_int_param in;
528 struct qed_int_param out;
529 struct msix_entry *msix_table;
530 bool fp_initialized;
531 u8 fp_msix_base;
532 u8 fp_msix_cnt;
533 u8 rdma_msix_base;
534 u8 rdma_msix_cnt;
535 };
536
537 struct qed_dbg_feature {
538 struct dentry *dentry;
539 u8 *dump_buf;
540 u32 buf_size;
541 u32 dumped_dwords;
542 };
543
544 struct qed_dbg_params {
545 struct qed_dbg_feature features[DBG_FEATURE_NUM];
546 u8 engine_for_debug;
547 bool print_data;
548 };
549
550 struct qed_dev {
551 u32 dp_module;
552 u8 dp_level;
553 char name[NAME_SIZE];
554
555 enum qed_dev_type type;
556 /* Translate type/revision combo into the proper conditions */
557 #define QED_IS_BB(dev) ((dev)->type == QED_DEV_TYPE_BB)
558 #define QED_IS_BB_A0(dev) (QED_IS_BB(dev) && \
559 CHIP_REV_IS_A0(dev))
560 #define QED_IS_BB_B0(dev) (QED_IS_BB(dev) && \
561 CHIP_REV_IS_B0(dev))
562 #define QED_IS_AH(dev) ((dev)->type == QED_DEV_TYPE_AH)
563 #define QED_IS_K2(dev) QED_IS_AH(dev)
564
565 #define QED_GET_TYPE(dev) (QED_IS_BB_A0(dev) ? CHIP_BB_A0 : \
566 QED_IS_BB_B0(dev) ? CHIP_BB_B0 : CHIP_K2)
567
568 u16 vendor_id;
569 u16 device_id;
570 #define QED_DEV_ID_MASK 0xff00
571 #define QED_DEV_ID_MASK_BB 0x1600
572 #define QED_DEV_ID_MASK_AH 0x8000
573
574 u16 chip_num;
575 #define CHIP_NUM_MASK 0xffff
576 #define CHIP_NUM_SHIFT 16
577
578 u16 chip_rev;
579 #define CHIP_REV_MASK 0xf
580 #define CHIP_REV_SHIFT 12
581 #define CHIP_REV_IS_A0(_cdev) (!(_cdev)->chip_rev)
582 #define CHIP_REV_IS_B0(_cdev) ((_cdev)->chip_rev == 1)
583
584 u16 chip_metal;
585 #define CHIP_METAL_MASK 0xff
586 #define CHIP_METAL_SHIFT 4
587
588 u16 chip_bond_id;
589 #define CHIP_BOND_ID_MASK 0xf
590 #define CHIP_BOND_ID_SHIFT 0
591
592 u8 num_engines;
593 u8 num_ports_in_engines;
594 u8 num_funcs_in_port;
595
596 u8 path_id;
597 enum qed_mf_mode mf_mode;
598 #define IS_MF_DEFAULT(_p_hwfn) (((_p_hwfn)->cdev)->mf_mode == QED_MF_DEFAULT)
599 #define IS_MF_SI(_p_hwfn) (((_p_hwfn)->cdev)->mf_mode == QED_MF_NPAR)
600 #define IS_MF_SD(_p_hwfn) (((_p_hwfn)->cdev)->mf_mode == QED_MF_OVLAN)
601
602 int pcie_width;
603 int pcie_speed;
604 u8 ver_str[VER_SIZE];
605
606 /* Add MF related configuration */
607 u8 mcp_rev;
608 u8 boot_mode;
609
610 /* WoL related configurations */
611 u8 wol_config;
612 u8 wol_mac[ETH_ALEN];
613
614 u32 int_mode;
615 enum qed_coalescing_mode int_coalescing_mode;
616 u16 rx_coalesce_usecs;
617 u16 tx_coalesce_usecs;
618
619 /* Start Bar offset of first hwfn */
620 void __iomem *regview;
621 void __iomem *doorbells;
622 u64 db_phys_addr;
623 unsigned long db_size;
624
625 /* PCI */
626 u8 cache_shift;
627
628 /* Init */
629 const struct iro *iro_arr;
630 #define IRO (p_hwfn->cdev->iro_arr)
631
632 /* HW functions */
633 u8 num_hwfns;
634 struct qed_hwfn hwfns[MAX_HWFNS_PER_DEVICE];
635
636 /* SRIOV */
637 struct qed_hw_sriov_info *p_iov_info;
638 #define IS_QED_SRIOV(cdev) (!!(cdev)->p_iov_info)
639
640 unsigned long tunn_mode;
641
642 bool b_is_vf;
643 u32 drv_type;
644 struct qed_eth_stats *reset_stats;
645 struct qed_fw_data *fw_data;
646
647 u32 mcp_nvm_resp;
648
649 /* Linux specific here */
650 struct qede_dev *edev;
651 struct pci_dev *pdev;
652 u32 flags;
653 #define QED_FLAG_STORAGE_STARTED (BIT(0))
654 int msg_enable;
655
656 struct pci_params pci_params;
657
658 struct qed_int_params int_params;
659
660 u8 protocol;
661 #define IS_QED_ETH_IF(cdev) ((cdev)->protocol == QED_PROTOCOL_ETH)
662 #define IS_QED_FCOE_IF(cdev) ((cdev)->protocol == QED_PROTOCOL_FCOE)
663
664 /* Callbacks to protocol driver */
665 union {
666 struct qed_common_cb_ops *common;
667 struct qed_eth_cb_ops *eth;
668 struct qed_fcoe_cb_ops *fcoe;
669 struct qed_iscsi_cb_ops *iscsi;
670 } protocol_ops;
671 void *ops_cookie;
672
673 struct qed_dbg_params dbg_params;
674
675 #ifdef CONFIG_QED_LL2
676 struct qed_cb_ll2_info *ll2;
677 u8 ll2_mac_address[ETH_ALEN];
678 #endif
679 DECLARE_HASHTABLE(connections, 10);
680 const struct firmware *firmware;
681
682 u32 rdma_max_sge;
683 u32 rdma_max_inline;
684 u32 rdma_max_srq_sge;
685 };
686
687 #define NUM_OF_VFS(dev) (QED_IS_BB(dev) ? MAX_NUM_VFS_BB \
688 : MAX_NUM_VFS_K2)
689 #define NUM_OF_L2_QUEUES(dev) (QED_IS_BB(dev) ? MAX_NUM_L2_QUEUES_BB \
690 : MAX_NUM_L2_QUEUES_K2)
691 #define NUM_OF_PORTS(dev) (QED_IS_BB(dev) ? MAX_NUM_PORTS_BB \
692 : MAX_NUM_PORTS_K2)
693 #define NUM_OF_SBS(dev) (QED_IS_BB(dev) ? MAX_SB_PER_PATH_BB \
694 : MAX_SB_PER_PATH_K2)
695 #define NUM_OF_ENG_PFS(dev) (QED_IS_BB(dev) ? MAX_NUM_PFS_BB \
696 : MAX_NUM_PFS_K2)
697
698 /**
699 * @brief qed_concrete_to_sw_fid - get the sw function id from
700 * the concrete value.
701 *
702 * @param concrete_fid
703 *
704 * @return inline u8
705 */
706 static inline u8 qed_concrete_to_sw_fid(struct qed_dev *cdev,
707 u32 concrete_fid)
708 {
709 u8 vfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFID);
710 u8 pfid = GET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID);
711 u8 vf_valid = GET_FIELD(concrete_fid,
712 PXP_CONCRETE_FID_VFVALID);
713 u8 sw_fid;
714
715 if (vf_valid)
716 sw_fid = vfid + MAX_NUM_PFS;
717 else
718 sw_fid = pfid;
719
720 return sw_fid;
721 }
722
723 #define PURE_LB_TC 8
724 #define OOO_LB_TC 9
725
726 int qed_configure_vport_wfq(struct qed_dev *cdev, u16 vp_id, u32 rate);
727 void qed_configure_vp_wfq_on_link_change(struct qed_dev *cdev,
728 struct qed_ptt *p_ptt,
729 u32 min_pf_rate);
730
731 void qed_clean_wfq_db(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
732 #define QED_LEADING_HWFN(dev) (&dev->hwfns[0])
733 int qed_device_num_engines(struct qed_dev *cdev);
734
735 /* Other Linux specific common definitions */
736 #define DP_NAME(cdev) ((cdev)->name)
737
738 #define REG_ADDR(cdev, offset) (void __iomem *)((u8 __iomem *)\
739 (cdev->regview) + \
740 (offset))
741
742 #define REG_RD(cdev, offset) readl(REG_ADDR(cdev, offset))
743 #define REG_WR(cdev, offset, val) writel((u32)val, REG_ADDR(cdev, offset))
744 #define REG_WR16(cdev, offset, val) writew((u16)val, REG_ADDR(cdev, offset))
745
746 #define DOORBELL(cdev, db_addr, val) \
747 writel((u32)val, (void __iomem *)((u8 __iomem *)\
748 (cdev->doorbells) + (db_addr)))
749
750 /* Prototypes */
751 int qed_fill_dev_info(struct qed_dev *cdev,
752 struct qed_dev_info *dev_info);
753 void qed_link_update(struct qed_hwfn *hwfn);
754 u32 qed_unzip_data(struct qed_hwfn *p_hwfn,
755 u32 input_len, u8 *input_buf,
756 u32 max_size, u8 *unzip_buf);
757 void qed_get_protocol_stats(struct qed_dev *cdev,
758 enum qed_mcp_protocol_type type,
759 union qed_mcp_protocol_stats *stats);
760 int qed_slowpath_irq_req(struct qed_hwfn *hwfn);
761 void qed_slowpath_irq_sync(struct qed_hwfn *p_hwfn);
762
763 #endif /* _QED_H */