18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* Copyright (c) 2018, Intel Corporation. */ 38c2ecf20Sopenharmony_ci 48c2ecf20Sopenharmony_ci#ifndef _ICE_CONTROLQ_H_ 58c2ecf20Sopenharmony_ci#define _ICE_CONTROLQ_H_ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#include "ice_adminq_cmd.h" 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci/* Maximum buffer lengths for all control queue types */ 108c2ecf20Sopenharmony_ci#define ICE_AQ_MAX_BUF_LEN 4096 118c2ecf20Sopenharmony_ci#define ICE_MBXQ_MAX_BUF_LEN 4096 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci#define ICE_CTL_Q_DESC(R, i) \ 148c2ecf20Sopenharmony_ci (&(((struct ice_aq_desc *)((R).desc_buf.va))[i])) 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define ICE_CTL_Q_DESC_UNUSED(R) \ 178c2ecf20Sopenharmony_ci (u16)((((R)->next_to_clean > (R)->next_to_use) ? 0 : (R)->count) + \ 188c2ecf20Sopenharmony_ci (R)->next_to_clean - (R)->next_to_use - 1) 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* Defines that help manage the driver vs FW API checks. 218c2ecf20Sopenharmony_ci * Take a look at ice_aq_ver_check in ice_controlq.c for actual usage. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci#define EXP_FW_API_VER_BRANCH 0x00 248c2ecf20Sopenharmony_ci#define EXP_FW_API_VER_MAJOR 0x01 258c2ecf20Sopenharmony_ci#define EXP_FW_API_VER_MINOR 0x05 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci/* Different control queue types: These are mainly for SW consumption. */ 288c2ecf20Sopenharmony_cienum ice_ctl_q { 298c2ecf20Sopenharmony_ci ICE_CTL_Q_UNKNOWN = 0, 308c2ecf20Sopenharmony_ci ICE_CTL_Q_ADMIN, 318c2ecf20Sopenharmony_ci ICE_CTL_Q_MAILBOX, 328c2ecf20Sopenharmony_ci}; 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci/* Control Queue timeout settings - max delay 1s */ 358c2ecf20Sopenharmony_ci#define ICE_CTL_Q_SQ_CMD_TIMEOUT 10000 /* Count 10000 times */ 368c2ecf20Sopenharmony_ci#define ICE_CTL_Q_SQ_CMD_USEC 100 /* Check every 100usec */ 378c2ecf20Sopenharmony_ci#define ICE_CTL_Q_ADMIN_INIT_TIMEOUT 10 /* Count 10 times */ 388c2ecf20Sopenharmony_ci#define ICE_CTL_Q_ADMIN_INIT_MSEC 100 /* Check every 100msec */ 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct ice_ctl_q_ring { 418c2ecf20Sopenharmony_ci void *dma_head; /* Virtual address to DMA head */ 428c2ecf20Sopenharmony_ci struct ice_dma_mem desc_buf; /* descriptor ring memory */ 438c2ecf20Sopenharmony_ci void *cmd_buf; /* command buffer memory */ 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci union { 468c2ecf20Sopenharmony_ci struct ice_dma_mem *sq_bi; 478c2ecf20Sopenharmony_ci struct ice_dma_mem *rq_bi; 488c2ecf20Sopenharmony_ci } r; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci u16 count; /* Number of descriptors */ 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci /* used for interrupt processing */ 538c2ecf20Sopenharmony_ci u16 next_to_use; 548c2ecf20Sopenharmony_ci u16 next_to_clean; 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci /* used for queue tracking */ 578c2ecf20Sopenharmony_ci u32 head; 588c2ecf20Sopenharmony_ci u32 tail; 598c2ecf20Sopenharmony_ci u32 len; 608c2ecf20Sopenharmony_ci u32 bah; 618c2ecf20Sopenharmony_ci u32 bal; 628c2ecf20Sopenharmony_ci u32 len_mask; 638c2ecf20Sopenharmony_ci u32 len_ena_mask; 648c2ecf20Sopenharmony_ci u32 len_crit_mask; 658c2ecf20Sopenharmony_ci u32 head_mask; 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* sq transaction details */ 698c2ecf20Sopenharmony_cistruct ice_sq_cd { 708c2ecf20Sopenharmony_ci struct ice_aq_desc *wb_desc; 718c2ecf20Sopenharmony_ci}; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci#define ICE_CTL_Q_DETAILS(R, i) (&(((struct ice_sq_cd *)((R).cmd_buf))[i])) 748c2ecf20Sopenharmony_ci 758c2ecf20Sopenharmony_ci/* rq event information */ 768c2ecf20Sopenharmony_cistruct ice_rq_event_info { 778c2ecf20Sopenharmony_ci struct ice_aq_desc desc; 788c2ecf20Sopenharmony_ci u16 msg_len; 798c2ecf20Sopenharmony_ci u16 buf_len; 808c2ecf20Sopenharmony_ci u8 *msg_buf; 818c2ecf20Sopenharmony_ci}; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* Control Queue information */ 848c2ecf20Sopenharmony_cistruct ice_ctl_q_info { 858c2ecf20Sopenharmony_ci enum ice_ctl_q qtype; 868c2ecf20Sopenharmony_ci enum ice_aq_err rq_last_status; /* last status on receive queue */ 878c2ecf20Sopenharmony_ci struct ice_ctl_q_ring rq; /* receive queue */ 888c2ecf20Sopenharmony_ci struct ice_ctl_q_ring sq; /* send queue */ 898c2ecf20Sopenharmony_ci u32 sq_cmd_timeout; /* send queue cmd write back timeout */ 908c2ecf20Sopenharmony_ci u16 num_rq_entries; /* receive queue depth */ 918c2ecf20Sopenharmony_ci u16 num_sq_entries; /* send queue depth */ 928c2ecf20Sopenharmony_ci u16 rq_buf_size; /* receive queue buffer size */ 938c2ecf20Sopenharmony_ci u16 sq_buf_size; /* send queue buffer size */ 948c2ecf20Sopenharmony_ci enum ice_aq_err sq_last_status; /* last status on send queue */ 958c2ecf20Sopenharmony_ci struct mutex sq_lock; /* Send queue lock */ 968c2ecf20Sopenharmony_ci struct mutex rq_lock; /* Receive queue lock */ 978c2ecf20Sopenharmony_ci}; 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ci#endif /* _ICE_CONTROLQ_H_ */ 100