Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[cris-mirror.git] / drivers / net / ethernet / huawei / hinic / hinic_hw_io.h
blobadb64179d47d878aa3a329195c8d36a6cb6bc203
1 /*
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
12 * for more details.
16 #ifndef HINIC_HW_IO_H
17 #define HINIC_HW_IO_H
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)
35 enum hinic_db_type {
36 HINIC_DB_CMDQ_TYPE,
37 HINIC_DB_SQ_TYPE,
40 enum hinic_io_path {
41 HINIC_CTRL_PATH,
42 HINIC_DATA_PATH,
45 struct hinic_free_db_area {
46 int db_idx[HINIC_DB_MAX_AREAS];
48 int alloc_pos;
49 int return_pos;
51 int num_free;
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;
62 struct hinic_wqs wqs;
64 struct hinic_wq *sq_wq;
65 struct hinic_wq *rq_wq;
67 struct hinic_qp *qps;
68 u16 max_qps;
70 void __iomem **sq_db;
71 void __iomem *db_base;
73 void *ci_addr_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,
89 int num_qps);
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);
97 #endif