1
2
3
4
5
6
7 #ifndef HINIC_HW_IO_H
8 #define HINIC_HW_IO_H
9
10 #include <linux/types.h>
11 #include <linux/pci.h>
12 #include <linux/semaphore.h>
13 #include <linux/sizes.h>
14
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"
20
21 #define HINIC_DB_PAGE_SIZE SZ_4K
22 #define HINIC_DB_SIZE SZ_4M
23
24 #define HINIC_DB_MAX_AREAS (HINIC_DB_SIZE / HINIC_DB_PAGE_SIZE)
25
26 enum hinic_db_type {
27 HINIC_DB_CMDQ_TYPE,
28 HINIC_DB_SQ_TYPE,
29 };
30
31 enum hinic_io_path {
32 HINIC_CTRL_PATH,
33 HINIC_DATA_PATH,
34 };
35
36 struct hinic_free_db_area {
37 int db_idx[HINIC_DB_MAX_AREAS];
38
39 int alloc_pos;
40 int return_pos;
41
42 int num_free;
43
44
45 struct semaphore idx_lock;
46 };
47
48 struct hinic_func_to_io {
49 struct hinic_hwif *hwif;
50
51 struct hinic_ceqs ceqs;
52
53 struct hinic_wqs wqs;
54
55 struct hinic_wq *sq_wq;
56 struct hinic_wq *rq_wq;
57
58 struct hinic_qp *qps;
59 u16 max_qps;
60
61 void __iomem **sq_db;
62 void __iomem *db_base;
63
64 void *ci_addr_base;
65 dma_addr_t ci_dma_base;
66
67 struct hinic_free_db_area free_db_area;
68
69 void __iomem *cmdq_db_area[HINIC_MAX_CMDQ_TYPES];
70
71 struct hinic_cmdqs cmdqs;
72 };
73
74 int hinic_io_create_qps(struct hinic_func_to_io *func_to_io,
75 u16 base_qpn, int num_qps,
76 struct msix_entry *sq_msix_entries,
77 struct msix_entry *rq_msix_entries);
78
79 void hinic_io_destroy_qps(struct hinic_func_to_io *func_to_io,
80 int num_qps);
81
82 int hinic_io_init(struct hinic_func_to_io *func_to_io,
83 struct hinic_hwif *hwif, u16 max_qps, int num_ceqs,
84 struct msix_entry *ceq_msix_entries);
85
86 void hinic_io_free(struct hinic_func_to_io *func_to_io);
87
88 #endif