2 * Huawei HiNIC PCI Express Linux driver
3 * Copyright(c) 2017 Huawei Technologies Co., Ltd
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms and conditions of the GNU General Public License,
7 * version 2, as published by the Free Software Foundation.
9 * This program is distributed in the hope it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 #include <linux/types.h>
20 #include <linux/pci.h>
21 #include <linux/semaphore.h>
22 #include <linux/sizes.h>
24 #include "hinic_hw_if.h"
25 #include "hinic_hw_eqs.h"
26 #include "hinic_hw_wq.h"
27 #include "hinic_hw_cmdq.h"
28 #include "hinic_hw_qp.h"
30 #define HINIC_DB_PAGE_SIZE SZ_4K
31 #define HINIC_DB_SIZE SZ_4M
33 #define HINIC_DB_MAX_AREAS (HINIC_DB_SIZE / HINIC_DB_PAGE_SIZE)
45 struct hinic_free_db_area
{
46 int db_idx
[HINIC_DB_MAX_AREAS
];
53 /* Lock for getting db area */
54 struct semaphore idx_lock
;
57 struct hinic_func_to_io
{
58 struct hinic_hwif
*hwif
;
60 struct hinic_ceqs ceqs
;
64 struct hinic_wq
*sq_wq
;
65 struct hinic_wq
*rq_wq
;
71 void __iomem
*db_base
;
74 dma_addr_t ci_dma_base
;
76 struct hinic_free_db_area free_db_area
;
78 void __iomem
*cmdq_db_area
[HINIC_MAX_CMDQ_TYPES
];
80 struct hinic_cmdqs cmdqs
;
83 int hinic_io_create_qps(struct hinic_func_to_io
*func_to_io
,
84 u16 base_qpn
, int num_qps
,
85 struct msix_entry
*sq_msix_entries
,
86 struct msix_entry
*rq_msix_entries
);
88 void hinic_io_destroy_qps(struct hinic_func_to_io
*func_to_io
,
91 int hinic_io_init(struct hinic_func_to_io
*func_to_io
,
92 struct hinic_hwif
*hwif
, u16 max_qps
, int num_ceqs
,
93 struct msix_entry
*ceq_msix_entries
);
95 void hinic_io_free(struct hinic_func_to_io
*func_to_io
);