WIP FPC-III support
[linux/fpc-iii.git] / drivers / net / ethernet / huawei / hinic / hinic_hw_io.h
blob52159a90278a0619614c0b97f4594992da4f0d61
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Huawei HiNIC PCI Express Linux driver
4 * Copyright(c) 2017 Huawei Technologies Co., Ltd
5 */
7 #ifndef HINIC_HW_IO_H
8 #define HINIC_HW_IO_H
10 #include <linux/types.h>
11 #include <linux/pci.h>
12 #include <linux/semaphore.h>
13 #include <linux/sizes.h>
15 #include "hinic_hw_if.h"
16 #include "hinic_hw_eqs.h"
17 #include "hinic_hw_wq.h"
18 #include "hinic_hw_cmdq.h"
19 #include "hinic_hw_qp.h"
21 #define HINIC_DB_PAGE_SIZE SZ_4K
22 #define HINIC_DB_SIZE SZ_4M
23 #define HINIC_HW_WQ_PAGE_SIZE SZ_4K
24 #define HINIC_DEFAULT_WQ_PAGE_SIZE SZ_256K
26 #define HINIC_DB_MAX_AREAS (HINIC_DB_SIZE / HINIC_DB_PAGE_SIZE)
28 enum hinic_db_type {
29 HINIC_DB_CMDQ_TYPE,
30 HINIC_DB_SQ_TYPE,
33 enum hinic_io_path {
34 HINIC_CTRL_PATH,
35 HINIC_DATA_PATH,
38 struct hinic_free_db_area {
39 int db_idx[HINIC_DB_MAX_AREAS];
41 int alloc_pos;
42 int return_pos;
44 int num_free;
46 /* Lock for getting db area */
47 struct semaphore idx_lock;
50 struct hinic_nic_cfg {
51 /* lock for getting nic cfg */
52 struct mutex cfg_mutex;
53 bool pause_set;
54 u32 auto_neg;
55 u32 rx_pause;
56 u32 tx_pause;
59 struct hinic_func_to_io {
60 struct hinic_hwif *hwif;
61 struct hinic_hwdev *hwdev;
62 u16 global_qpn;
63 struct hinic_ceqs ceqs;
65 struct hinic_wqs wqs;
67 struct hinic_wq *sq_wq;
68 struct hinic_wq *rq_wq;
70 struct hinic_qp *qps;
71 u16 max_qps;
73 u16 sq_depth;
74 u16 rq_depth;
76 void __iomem **sq_db;
77 void __iomem *db_base;
79 void *ci_addr_base;
80 dma_addr_t ci_dma_base;
82 struct hinic_free_db_area free_db_area;
84 void __iomem *cmdq_db_area[HINIC_MAX_CMDQ_TYPES];
86 struct hinic_cmdqs cmdqs;
88 u16 max_vfs;
89 struct vf_data_storage *vf_infos;
90 u8 link_status;
91 struct hinic_nic_cfg nic_cfg;
94 struct hinic_wq_page_size {
95 u8 status;
96 u8 version;
97 u8 rsvd0[6];
99 u16 func_idx;
100 u8 ppf_idx;
101 u8 page_size;
103 u32 rsvd1;
106 int hinic_set_wq_page_size(struct hinic_hwdev *hwdev, u16 func_idx,
107 u32 page_size);
109 int hinic_io_create_qps(struct hinic_func_to_io *func_to_io,
110 u16 base_qpn, int num_qps,
111 struct msix_entry *sq_msix_entries,
112 struct msix_entry *rq_msix_entries);
114 void hinic_io_destroy_qps(struct hinic_func_to_io *func_to_io,
115 int num_qps);
117 int hinic_io_init(struct hinic_func_to_io *func_to_io,
118 struct hinic_hwif *hwif, u16 max_qps, int num_ceqs,
119 struct msix_entry *ceq_msix_entries);
121 void hinic_io_free(struct hinic_func_to_io *func_to_io);
123 #endif