1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright(c) 2013 - 2018 Intel Corporation. */
4 #ifndef _IAVF_ADMINQ_H_
5 #define _IAVF_ADMINQ_H_
7 #include "iavf_osdep.h"
8 #include "iavf_status.h"
9 #include "iavf_adminq_cmd.h"
11 #define IAVF_ADMINQ_DESC(R, i) \
12 (&(((struct iavf_aq_desc *)((R).desc_buf.va))[i]))
14 #define IAVF_ADMINQ_DESC_ALIGNMENT 4096
16 struct iavf_adminq_ring
{
17 struct iavf_virt_mem dma_head
; /* space for dma structures */
18 struct iavf_dma_mem desc_buf
; /* descriptor ring memory */
19 struct iavf_virt_mem cmd_buf
; /* command buffer memory */
22 struct iavf_dma_mem
*asq_bi
;
23 struct iavf_dma_mem
*arq_bi
;
26 u16 count
; /* Number of descriptors */
27 u16 rx_buf_len
; /* Admin Receive Queue buffer length */
29 /* used for interrupt processing */
33 /* used for queue tracking */
41 /* ASQ transaction details */
42 struct iavf_asq_cmd_details
{
43 void *callback
; /* cast from type IAVF_ADMINQ_CALLBACK */
49 struct iavf_aq_desc
*wb_desc
;
52 #define IAVF_ADMINQ_DETAILS(R, i) \
53 (&(((struct iavf_asq_cmd_details *)((R).cmd_buf.va))[i]))
55 /* ARQ event information */
56 struct iavf_arq_event_info
{
57 struct iavf_aq_desc desc
;
63 /* Admin Queue information */
64 struct iavf_adminq_info
{
65 struct iavf_adminq_ring arq
; /* receive queue */
66 struct iavf_adminq_ring asq
; /* send queue */
67 u32 asq_cmd_timeout
; /* send queue cmd write back timeout*/
68 u16 num_arq_entries
; /* receive queue depth */
69 u16 num_asq_entries
; /* send queue depth */
70 u16 arq_buf_size
; /* receive queue buffer size */
71 u16 asq_buf_size
; /* send queue buffer size */
72 u16 fw_maj_ver
; /* firmware major version */
73 u16 fw_min_ver
; /* firmware minor version */
74 u32 fw_build
; /* firmware build number */
75 u16 api_maj_ver
; /* api major version */
76 u16 api_min_ver
; /* api minor version */
78 struct mutex asq_mutex
; /* Send queue lock */
79 struct mutex arq_mutex
; /* Receive queue lock */
81 /* last status values on send and receive queues */
82 enum iavf_admin_queue_err asq_last_status
;
83 enum iavf_admin_queue_err arq_last_status
;
87 * iavf_aq_rc_to_posix - convert errors to user-land codes
88 * @aq_ret: AdminQ handler error code can override aq_rc
89 * @aq_rc: AdminQ firmware error code to convert
91 static inline int iavf_aq_rc_to_posix(int aq_ret
, int aq_rc
)
94 0, /* IAVF_AQ_RC_OK */
95 -EPERM
, /* IAVF_AQ_RC_EPERM */
96 -ENOENT
, /* IAVF_AQ_RC_ENOENT */
97 -ESRCH
, /* IAVF_AQ_RC_ESRCH */
98 -EINTR
, /* IAVF_AQ_RC_EINTR */
99 -EIO
, /* IAVF_AQ_RC_EIO */
100 -ENXIO
, /* IAVF_AQ_RC_ENXIO */
101 -E2BIG
, /* IAVF_AQ_RC_E2BIG */
102 -EAGAIN
, /* IAVF_AQ_RC_EAGAIN */
103 -ENOMEM
, /* IAVF_AQ_RC_ENOMEM */
104 -EACCES
, /* IAVF_AQ_RC_EACCES */
105 -EFAULT
, /* IAVF_AQ_RC_EFAULT */
106 -EBUSY
, /* IAVF_AQ_RC_EBUSY */
107 -EEXIST
, /* IAVF_AQ_RC_EEXIST */
108 -EINVAL
, /* IAVF_AQ_RC_EINVAL */
109 -ENOTTY
, /* IAVF_AQ_RC_ENOTTY */
110 -ENOSPC
, /* IAVF_AQ_RC_ENOSPC */
111 -ENOSYS
, /* IAVF_AQ_RC_ENOSYS */
112 -ERANGE
, /* IAVF_AQ_RC_ERANGE */
113 -EPIPE
, /* IAVF_AQ_RC_EFLUSHED */
114 -ESPIPE
, /* IAVF_AQ_RC_BAD_ADDR */
115 -EROFS
, /* IAVF_AQ_RC_EMODE */
116 -EFBIG
, /* IAVF_AQ_RC_EFBIG */
119 /* aq_rc is invalid if AQ timed out */
120 if (aq_ret
== IAVF_ERR_ADMIN_QUEUE_TIMEOUT
)
123 if (!((u32
)aq_rc
< (sizeof(aq_to_posix
) / sizeof((aq_to_posix
)[0]))))
126 return aq_to_posix
[aq_rc
];
129 /* general information */
130 #define IAVF_AQ_LARGE_BUF 512
131 #define IAVF_ASQ_CMD_TIMEOUT 250000 /* usecs */
133 void iavf_fill_default_direct_cmd_desc(struct iavf_aq_desc
*desc
, u16 opcode
);
135 #endif /* _IAVF_ADMINQ_H_ */