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/semaphore.h>
21 #include <linux/atomic.h>
23 #include "hinic_hw_if.h"
24 #include "hinic_hw_wqe.h"
26 struct hinic_free_block
{
32 struct hinic_hwif
*hwif
;
41 u16 num_wqebbs_per_page
;
43 /* The addresses are 64 bit in the HW */
45 void **shadow_block_vaddr
;
59 struct hinic_hwif
*hwif
;
62 /* The addresses are 64 bit in the HW */
65 void ***shadow_page_vaddr
;
67 struct hinic_free_block
*free_blocks
;
72 /* Lock for getting a free block from the WQ set */
73 struct semaphore alloc_blocks_lock
;
76 struct hinic_cmdq_pages
{
77 /* The addresses are 64 bit in the HW */
80 void **shadow_page_vaddr
;
82 struct hinic_hwif
*hwif
;
85 int hinic_wqs_cmdq_alloc(struct hinic_cmdq_pages
*cmdq_pages
,
86 struct hinic_wq
*wq
, struct hinic_hwif
*hwif
,
87 int cmdq_blocks
, u16 wqebb_size
, u16 wq_page_size
,
88 u16 q_depth
, u16 max_wqe_size
);
90 void hinic_wqs_cmdq_free(struct hinic_cmdq_pages
*cmdq_pages
,
91 struct hinic_wq
*wq
, int cmdq_blocks
);
93 int hinic_wqs_alloc(struct hinic_wqs
*wqs
, int num_wqs
,
94 struct hinic_hwif
*hwif
);
96 void hinic_wqs_free(struct hinic_wqs
*wqs
);
98 int hinic_wq_allocate(struct hinic_wqs
*wqs
, struct hinic_wq
*wq
,
99 u16 wqebb_size
, u16 wq_page_size
, u16 q_depth
,
102 void hinic_wq_free(struct hinic_wqs
*wqs
, struct hinic_wq
*wq
);
104 struct hinic_hw_wqe
*hinic_get_wqe(struct hinic_wq
*wq
, unsigned int wqe_size
,
107 void hinic_put_wqe(struct hinic_wq
*wq
, unsigned int wqe_size
);
109 struct hinic_hw_wqe
*hinic_read_wqe(struct hinic_wq
*wq
, unsigned int wqe_size
,
112 struct hinic_hw_wqe
*hinic_read_wqe_direct(struct hinic_wq
*wq
, u16 cons_idx
);
114 void hinic_write_wqe(struct hinic_wq
*wq
, struct hinic_hw_wqe
*wqe
,
115 unsigned int wqe_size
);