1
2
3
4#ifndef _IAVF_ADMINQ_H_
5#define _IAVF_ADMINQ_H_
6
7#include "iavf_osdep.h"
8#include "iavf_status.h"
9#include "iavf_adminq_cmd.h"
10
11#define IAVF_ADMINQ_DESC(R, i) \
12 (&(((struct iavf_aq_desc *)((R).desc_buf.va))[i]))
13
14#define IAVF_ADMINQ_DESC_ALIGNMENT 4096
15
16struct iavf_adminq_ring {
17 struct iavf_virt_mem dma_head;
18 struct iavf_dma_mem desc_buf;
19 struct iavf_virt_mem cmd_buf;
20
21 union {
22 struct iavf_dma_mem *asq_bi;
23 struct iavf_dma_mem *arq_bi;
24 } r;
25
26 u16 count;
27 u16 rx_buf_len;
28
29
30 u16 next_to_use;
31 u16 next_to_clean;
32
33
34 u32 head;
35 u32 tail;
36 u32 len;
37 u32 bah;
38 u32 bal;
39};
40
41
42struct iavf_asq_cmd_details {
43 void *callback;
44 u64 cookie;
45 u16 flags_ena;
46 u16 flags_dis;
47 bool async;
48 bool postpone;
49 struct iavf_aq_desc *wb_desc;
50};
51
52#define IAVF_ADMINQ_DETAILS(R, i) \
53 (&(((struct iavf_asq_cmd_details *)((R).cmd_buf.va))[i]))
54
55
56struct iavf_arq_event_info {
57 struct iavf_aq_desc desc;
58 u16 msg_len;
59 u16 buf_len;
60 u8 *msg_buf;
61};
62
63
64struct iavf_adminq_info {
65 struct iavf_adminq_ring arq;
66 struct iavf_adminq_ring asq;
67 u32 asq_cmd_timeout;
68 u16 num_arq_entries;
69 u16 num_asq_entries;
70 u16 arq_buf_size;
71 u16 asq_buf_size;
72 u16 fw_maj_ver;
73 u16 fw_min_ver;
74 u32 fw_build;
75 u16 api_maj_ver;
76 u16 api_min_ver;
77
78 struct mutex asq_mutex;
79 struct mutex arq_mutex;
80
81
82 enum iavf_admin_queue_err asq_last_status;
83 enum iavf_admin_queue_err arq_last_status;
84};
85
86
87
88
89
90
91static inline int iavf_aq_rc_to_posix(int aq_ret, int aq_rc)
92{
93 int aq_to_posix[] = {
94 0,
95 -EPERM,
96 -ENOENT,
97 -ESRCH,
98 -EINTR,
99 -EIO,
100 -ENXIO,
101 -E2BIG,
102 -EAGAIN,
103 -ENOMEM,
104 -EACCES,
105 -EFAULT,
106 -EBUSY,
107 -EEXIST,
108 -EINVAL,
109 -ENOTTY,
110 -ENOSPC,
111 -ENOSYS,
112 -ERANGE,
113 -EPIPE,
114 -ESPIPE,
115 -EROFS,
116 -EFBIG,
117 };
118
119
120 if (aq_ret == IAVF_ERR_ADMIN_QUEUE_TIMEOUT)
121 return -EAGAIN;
122
123 if (!((u32)aq_rc < (sizeof(aq_to_posix) / sizeof((aq_to_posix)[0]))))
124 return -ERANGE;
125
126 return aq_to_posix[aq_rc];
127}
128
129
130#define IAVF_AQ_LARGE_BUF 512
131#define IAVF_ASQ_CMD_TIMEOUT 250000
132
133void iavf_fill_default_direct_cmd_desc(struct iavf_aq_desc *desc, u16 opcode);
134
135#endif
136