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 /* hiovs pmd use 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),
175 enum hinic_cmdq_cmd_type {
177 HINIC_CMD_TYPE_SET_ARM,
178 HINIC_CMD_TYPE_NORMAL,
181 struct hinic_cmdq_cmd_info {
182 enum hinic_cmdq_cmd_type cmd_type;
188 enum hinic_cmdq_type cmdq_type;
191 hinic_spinlock_t cmdq_lock;
198 struct hinic_cmdq_ctxt cmdq_ctxt;
200 struct hinic_cmdq_cmd_info *cmd_infos;
204 struct hinic_hwdev *hwdev;
206 struct pci_pool *cmd_buf_pool;
208 struct hinic_wq *saved_wqs;
210 struct hinic_cmdq cmdq[HINIC_MAX_CMDQ_TYPES];
215 struct hinic_cmd_buf {
218 struct rte_mbuf *mbuf;
222 int hinic_reinit_cmdq_ctxts(struct hinic_hwdev *hwdev);
224 bool hinic_cmdq_idle(struct hinic_cmdq *cmdq);
226 struct hinic_cmd_buf *hinic_alloc_cmd_buf(void *hwdev);
228 void hinic_free_cmd_buf(void *hwdev, struct hinic_cmd_buf *cmd_buf);
230 /* PF/VF send cmd to ucode by cmdq, and return if success.
231 * timeout=0, use default timeout.
233 int hinic_cmdq_direct_resp(void *hwdev, enum hinic_ack_type ack_type,
234 enum hinic_mod_type mod, u8 cmd,
235 struct hinic_cmd_buf *buf_in,
236 u64 *out_param, u32 timeout);
238 int hinic_comm_cmdqs_init(struct hinic_hwdev *hwdev);
240 void hinic_comm_cmdqs_free(struct hinic_hwdev *hwdev);
242 #endif /* _HINIC_PMD_CMDQ_H_ */