avf: binary API and configurable RX/TX queue size
[vpp.git] / src / plugins / avf / virtchnl.h
1 /*
2  *------------------------------------------------------------------
3  * Copyright (c) 2018 Cisco and/or its affiliates.
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *------------------------------------------------------------------
16  */
17
18 #ifndef _AVF_VIRTCHNL_H_
19 #define _AVF_VIRTCHNL_H_
20
21 #define VIRTCHNL_VERSION_MAJOR 1
22 #define VIRTCHNL_VERSION_MINOR 1
23
24
25 #define AVFINT_DYN_CTLN(x)  (0x00003800 + (0x4 * x))
26 #define AVFINT_ICR0         0x00004800
27 #define AVFINT_ICR0_ENA1    0x00005000
28 #define AVFINT_DYN_CTL0     0x00005C00
29 #define AVF_ARQBAH          0x00006000
30 #define AVF_ATQH            0x00006400
31 #define AVF_ATQLEN          0x00006800
32 #define AVF_ARQBAL          0x00006C00
33 #define AVF_ARQT            0x00007000
34 #define AVF_ARQH            0x00007400
35 #define AVF_ATQBAH          0x00007800
36 #define AVF_ATQBAL          0x00007C00
37 #define AVF_ARQLEN          0x00008000
38 #define AVF_ATQT            0x00008400
39 #define AVFGEN_RSTAT        0x00008800
40 #define AVF_QTX_TAIL(q)     (0x00000000 + (0x4 * q))
41 #define AVF_QRX_TAIL(q)     (0x00002000 + (0x4 * q))
42
43 #define AVF_AQ_F_DD  (1 << 0)
44 #define AVF_AQ_F_CMP (1 << 1)
45 #define AVF_AQ_F_ERR (1 << 2)
46 #define AVF_AQ_F_VFE (1 << 3)
47 #define AVF_AQ_F_LB  (1 << 9)
48 #define AVF_AQ_F_RD  (1 << 10)
49 #define AVF_AQ_F_VFC (1 << 11)
50 #define AVF_AQ_F_BUF (1 << 12)
51 #define AVF_AQ_F_SI  (1 << 13)
52 #define AVF_AQ_F_EI  (1 << 14)
53 #define AVF_AQ_F_FE  (1 << 15)
54
55
56 #define foreach_virtchnl_op \
57   _(0, UNKNOWN)                                 \
58   _(1, VERSION)                                 \
59   _(2, RESET_VF)                                \
60   _(3, GET_VF_RESOURCES)                        \
61   _(4, CONFIG_TX_QUEUE)                         \
62   _(5, CONFIG_RX_QUEUE)                         \
63   _(6, CONFIG_VSI_QUEUES)                       \
64   _(7, CONFIG_IRQ_MAP)                          \
65   _(8, ENABLE_QUEUES)                           \
66   _(9, DISABLE_QUEUES)                          \
67   _(10, ADD_ETH_ADDR)                           \
68   _(11, DEL_ETH_ADDR)                           \
69   _(12, ADD_VLAN)                               \
70   _(13, DEL_VLAN)                               \
71   _(14, CONFIG_PROMISCUOUS_MODE)                \
72   _(15, GET_STATS)                              \
73   _(16, RSVD)                                   \
74   _(17, EVENT)                                  \
75   _(18, UNDEF_18)                               \
76   _(19, UNDEF_19)                               \
77   _(20, IWARP)                                  \
78   _(21, CONFIG_IWARP_IRQ_MAP)                   \
79   _(22, RELEASE_IWARP_IRQ_MAP)                  \
80   _(23, CONFIG_RSS_KEY)                         \
81   _(24, CONFIG_RSS_LUT)                         \
82   _(25, GET_RSS_HENA_CAPS)                      \
83   _(26, SET_RSS_HENA)                           \
84   _(27, ENABLE_VLAN_STRIPPING)                  \
85   _(28, DISABLE_VLAN_STRIPPING)                 \
86   _(29, REQUEST_QUEUES)
87
88 typedef enum
89 {
90 #define _(v,n) VIRTCHNL_OP_##n = v,
91   foreach_virtchnl_op
92 #undef _
93     VIRTCHNL_N_OPS,
94 } virtchnl_ops_t;
95
96 typedef enum
97 {
98   VIRTCHNL_STATUS_SUCCESS = 0,
99   VIRTCHNL_ERR_PARAM = -5,
100   VIRTCHNL_STATUS_ERR_OPCODE_MISMATCH = -38,
101   VIRTCHNL_STATUS_ERR_CQP_COMPL_ERROR = -39,
102   VIRTCHNL_STATUS_ERR_INVALID_VF_ID = -40,
103   VIRTCHNL_STATUS_NOT_SUPPORTED = -64,
104 } virtchnl_status_code_t;
105
106 #define foreach_avf_vf_cap_flag \
107   _( 0, L2, "l2") \
108   _( 1, IWARP, "iwarp") \
109   _( 2, RSVD, "rsvd") \
110   _( 3, RSS_AQ, "rss-aq") \
111   _( 4, RSS_REG, "rss-reg") \
112   _( 5, WB_ON_ITR, "wb-on-itr") \
113   _( 6, REQ_QUEUES, "req-queues") \
114   _(16, VLAN, "vlan") \
115   _(17, RX_POLLING, "rx-polling") \
116   _(18, RSS_PCTYPE_V2, "rss-pctype-v2") \
117   _(19, RSS_PF, "rss-pf") \
118   _(20, ENCAP, "encap") \
119   _(21, ENCAP_CSUM, "encap-csum") \
120   _(22, RX_ENCAP_CSUM, "rx-encap-csum")
121
122 typedef enum
123 {
124 #define _(a, b, c) VIRTCHNL_VF_OFFLOAD_##b = (1 << a),
125   foreach_avf_vf_cap_flag
126 #undef _
127 } avf_vf_cap_flag_t;
128
129 typedef enum
130 {
131   VIRTCHNL_VSI_TYPE_INVALID = 0,
132   VIRTCHNL_VSI_SRIOV = 6,
133 } virtchnl_vsi_type_t;
134
135 typedef struct
136 {
137   u16 vsi_id;
138   u16 num_queue_pairs;
139   virtchnl_vsi_type_t vsi_type;
140   u16 qset_handle;
141   u8 default_mac_addr[6];
142 } virtchnl_vsi_resource_t;
143
144 typedef struct
145 {
146   u16 num_vsis;
147   u16 num_queue_pairs;
148   u16 max_vectors;
149   u16 max_mtu;
150   u32 vf_offload_flags;
151   u32 rss_key_size;
152   u32 rss_lut_size;
153   virtchnl_vsi_resource_t vsi_res[1];
154 } virtchnl_vf_resource_t;
155
156 typedef enum
157 {
158   VIRTCHNL_EVENT_UNKNOWN = 0,
159   VIRTCHNL_EVENT_LINK_CHANGE,
160   VIRTCHNL_EVENT_RESET_IMPENDING,
161   VIRTCHNL_EVENT_PF_DRIVER_CLOSE,
162 } virtchnl_event_codes_t;
163
164 #define foreach_virtchnl_link_speed \
165   _(1, 100MB, "100 Mbps")               \
166   _(2, 1GB, "1 Gbps")                   \
167   _(3, 10GB, "10 Gbps")                 \
168   _(4, 40GB, "40 Gbps")                 \
169   _(5, 20GB, "20 Gbps")                 \
170   _(6, 25GB, "25 Gbps")
171
172 typedef enum
173 {
174   VIRTCHNL_LINK_SPEED_UNKNOWN = 0,
175 #define _(a,b,c) VIRTCHNL_LINK_SPEED_##b = (1 << a),
176   foreach_virtchnl_link_speed
177 #undef _
178 } virtchnl_link_speed_t;
179
180 typedef struct
181 {
182   virtchnl_event_codes_t event;
183   union
184   {
185     struct
186     {
187       virtchnl_link_speed_t link_speed;
188       _Bool link_status;
189     } link_event;
190   } event_data;
191   int severity;
192 } virtchnl_pf_event_t;
193
194 STATIC_ASSERT_SIZEOF (virtchnl_pf_event_t, 16);
195
196 typedef struct
197 {
198   u32 major;
199   u32 minor;
200 } virtchnl_version_info_t;
201
202 typedef struct
203 {
204   u16 flags;
205   u16 opcode;
206   u16 datalen;
207   u16 retval;
208   union
209   {
210     u32 cookie_hi;
211     virtchnl_ops_t v_opcode;
212   };
213   union
214   {
215     u32 cookie_lo;
216     virtchnl_status_code_t v_retval;
217   };
218   u32 param0;
219   u32 param1;
220   union
221   {
222     u32 param2;
223     u32 addr_hi;
224   };
225   union
226   {
227     u32 param3;
228     u32 addr_lo;
229   };
230 } avf_aq_desc_t;
231
232 STATIC_ASSERT_SIZEOF (avf_aq_desc_t, 32);
233
234 typedef struct
235 {
236   u16 vsi_id;
237   u16 queue_id;
238   u16 ring_len;
239   u64 dma_ring_addr;
240   u64 dma_headwb_addr;
241 } virtchnl_txq_info_t;
242
243 STATIC_ASSERT_SIZEOF (virtchnl_txq_info_t, 24);
244
245 typedef struct
246 {
247   u16 vsi_id;
248   u16 queue_id;
249   u32 ring_len;
250   u16 hdr_size;
251   u16 splithdr_enabled;
252   u32 databuffer_size;
253   u32 max_pkt_size;
254   u32 pad1;
255   u64 dma_ring_addr;
256   int rx_split_pos;
257   u32 pad2;
258 } virtchnl_rxq_info_t;
259
260 STATIC_ASSERT_SIZEOF (virtchnl_rxq_info_t, 40);
261
262 typedef struct
263 {
264   virtchnl_txq_info_t txq;
265   virtchnl_rxq_info_t rxq;
266 } virtchnl_queue_pair_info_t;
267
268 typedef struct
269 {
270   u16 vsi_id;
271   u16 num_queue_pairs;
272   u32 pad;
273   virtchnl_queue_pair_info_t qpair[1];
274 } virtchnl_vsi_queue_config_info_t;
275
276 STATIC_ASSERT_SIZEOF (virtchnl_vsi_queue_config_info_t, 72);
277
278 typedef struct
279 {
280   u16 vsi_id;
281   u16 pad;
282   u32 rx_queues;
283   u32 tx_queues;
284 } virtchnl_queue_select_t;
285
286 STATIC_ASSERT_SIZEOF (virtchnl_queue_select_t, 12);
287
288 typedef struct
289 {
290   u16 vsi_id;
291   u16 vector_id;
292   u16 rxq_map;
293   u16 txq_map;
294   u16 rxitr_idx;
295   u16 txitr_idx;
296 } virtchnl_vector_map_t;
297
298 typedef struct
299 {
300   u16 num_vectors;
301   virtchnl_vector_map_t vecmap[1];
302 } virtchnl_irq_map_info_t;
303
304 STATIC_ASSERT_SIZEOF (virtchnl_irq_map_info_t, 14);
305
306 typedef struct
307 {
308   u8 addr[6];
309   u8 pad[2];
310 } virtchnl_ether_addr_t;
311
312 typedef struct
313 {
314   u16 vsi_id;
315   u16 num_elements;
316   virtchnl_ether_addr_t list[1];
317 } virtchnl_ether_addr_list_t;
318
319 #define foreach_virtchnl_eth_stats \
320   _(rx_bytes)           \
321   _(rx_unicast)         \
322   _(rx_multicast)       \
323   _(rx_broadcast)       \
324   _(rx_discards)        \
325   _(rx_unknown_protocol)\
326   _(tx_bytes)           \
327   _(tx_unicast)         \
328   _(tx_multicast)       \
329   _(tx_broadcast)       \
330   _(tx_discards)        \
331   _(tx_errors)
332
333 typedef struct
334 {
335 #define _(s) u64 s;
336   foreach_virtchnl_eth_stats
337 #undef _
338 } virtchnl_eth_stats_t;
339
340 typedef struct
341 {
342   u16 vsi_id;
343   u16 key_len;
344   u8 key[1];
345 } virtchnl_rss_key_t;
346
347 STATIC_ASSERT_SIZEOF (virtchnl_rss_key_t, 6);
348
349 typedef struct
350 {
351   u16 vsi_id;
352   u16 lut_entries;
353   u8 lut[1];
354 } virtchnl_rss_lut_t;
355
356 STATIC_ASSERT_SIZEOF (virtchnl_rss_lut_t, 6);
357
358 #endif /* AVF_VIRTCHNL_H */
359
360 /*
361  * fd.io coding-style-patch-verification: ON
362  *
363  * Local Variables:
364  * eval: (c-set-style "gnu")
365  * End:
366  */