1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Huawei HiNIC PCI Express Linux driver
4 * Copyright(c) 2017 Huawei Technologies Co., Ltd
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)
38 struct hinic_free_db_area
{
39 int db_idx
[HINIC_DB_MAX_AREAS
];
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
;
59 struct hinic_func_to_io
{
60 struct hinic_hwif
*hwif
;
61 struct hinic_hwdev
*hwdev
;
63 struct hinic_ceqs ceqs
;
67 struct hinic_wq
*sq_wq
;
68 struct hinic_wq
*rq_wq
;
77 void __iomem
*db_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
;
89 struct vf_data_storage
*vf_infos
;
91 struct hinic_nic_cfg nic_cfg
;
94 struct hinic_wq_page_size
{
106 int hinic_set_wq_page_size(struct hinic_hwdev
*hwdev
, u16 func_idx
,
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
,
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
);