1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Huawei Technologies Co., Ltd
5 #ifndef _HINIC_PMD_CMDQ_H_
6 #define _HINIC_PMD_CMDQ_H_
8 #define HINIC_DB_OFF 0x00000800
10 #define HINIC_SCMD_DATA_LEN 16
12 /* PMD uses 64, kernel l2nic use 4096 */
13 #define HINIC_CMDQ_DEPTH 64
15 #define HINIC_CMDQ_BUF_SIZE 2048U
16 #define HINIC_CMDQ_BUF_HW_RSVD 8
17 #define HINIC_CMDQ_MAX_DATA_SIZE (HINIC_CMDQ_BUF_SIZE \
18 - HINIC_CMDQ_BUF_HW_RSVD)
20 #define HINIC_CEQ_ID_CMDQ 0
33 CTRL_DIRECT_SECT_LEN = 2,
45 enum completion_format {
50 enum completion_request {
60 enum hinic_cmdq_type {
66 enum hinic_db_src_type {
67 HINIC_DB_SRC_CMDQ_TYPE,
68 HINIC_DB_SRC_L2NIC_SQ_TYPE,
71 enum hinic_cmdq_db_type {
77 struct hinic_cmdq_header {
82 struct hinic_scmd_bufdesc {
85 u8 data[HINIC_SCMD_DATA_LEN];
88 struct hinic_lcmd_bufdesc {
95 struct hinic_cmdq_db {
100 struct hinic_status {
108 struct hinic_sge_resp {
109 struct hinic_sge sge;
113 struct hinic_cmdq_completion {
116 struct hinic_sge_resp sge_resp;
121 struct hinic_cmdq_wqe_scmd {
122 struct hinic_cmdq_header header;
123 struct hinic_cmdq_db db;
124 struct hinic_status status;
125 struct hinic_ctrl ctrl;
126 struct hinic_cmdq_completion completion;
127 struct hinic_scmd_bufdesc buf_desc;
130 struct hinic_cmdq_wqe_lcmd {
131 struct hinic_cmdq_header header;
132 struct hinic_status status;
133 struct hinic_ctrl ctrl;
134 struct hinic_cmdq_completion completion;
135 struct hinic_lcmd_bufdesc buf_desc;
138 struct hinic_cmdq_inline_wqe {
139 struct hinic_cmdq_wqe_scmd wqe_scmd;
142 struct hinic_cmdq_wqe {
145 struct hinic_cmdq_inline_wqe inline_wqe;
146 struct hinic_cmdq_wqe_lcmd wqe_lcmd;
150 struct hinic_cmdq_ctxt_info {
151 u64 curr_wqe_page_pfn;
156 struct hinic_cmdq_ctxt {
168 struct hinic_cmdq_ctxt_info ctxt_info;
171 enum hinic_cmdq_status {
172 HINIC_CMDQ_ENABLE = BIT(0),
173 HINIC_CMDQ_SET_FAIL = BIT(1)
176 enum hinic_cmdq_cmd_type {
178 HINIC_CMD_TYPE_SET_ARM,
179 HINIC_CMD_TYPE_NORMAL,
182 struct hinic_cmdq_cmd_info {
183 enum hinic_cmdq_cmd_type cmd_type;
189 enum hinic_cmdq_type cmdq_type;
192 hinic_spinlock_t cmdq_lock;
199 struct hinic_cmdq_ctxt cmdq_ctxt;
201 struct hinic_cmdq_cmd_info *cmd_infos;
205 struct hinic_hwdev *hwdev;
207 struct pci_pool *cmd_buf_pool;
209 struct hinic_wq *saved_wqs;
211 struct hinic_cmdq cmdq[HINIC_MAX_CMDQ_TYPES];
216 struct hinic_cmd_buf {
219 struct rte_mbuf *mbuf;
223 int hinic_reinit_cmdq_ctxts(struct hinic_hwdev *hwdev);
225 bool hinic_cmdq_idle(struct hinic_cmdq *cmdq);
227 struct hinic_cmd_buf *hinic_alloc_cmd_buf(void *hwdev);
229 void hinic_free_cmd_buf(void *hwdev, struct hinic_cmd_buf *cmd_buf);
231 /* PF/VF send cmd to ucode by cmdq, and return if success.
232 * timeout=0, use default timeout.
234 int hinic_cmdq_direct_resp(void *hwdev, enum hinic_ack_type ack_type,
235 enum hinic_mod_type mod, u8 cmd,
236 struct hinic_cmd_buf *buf_in,
237 u64 *out_param, u32 timeout);
239 int hinic_comm_cmdqs_init(struct hinic_hwdev *hwdev);
241 void hinic_comm_cmdqs_free(struct hinic_hwdev *hwdev);
243 #endif /* _HINIC_PMD_CMDQ_H_ */