]> git.proxmox.com Git - ceph.git/blob - ceph/src/seastar/dpdk/drivers/net/i40e/rte_pmd_i40e.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / seastar / dpdk / drivers / net / i40e / rte_pmd_i40e.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright (c) 2017 Intel Corporation. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33 #ifndef _PMD_I40E_H_
34 #define _PMD_I40E_H_
35
36 /**
37 * @file rte_pmd_i40e.h
38 *
39 * i40e PMD specific functions.
40 *
41 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
42 *
43 */
44
45 #include <rte_ethdev.h>
46
47 /**
48 * Response sent back to i40e driver from user app after callback
49 */
50 enum rte_pmd_i40e_mb_event_rsp {
51 RTE_PMD_I40E_MB_EVENT_NOOP_ACK, /**< skip mbox request and ACK */
52 RTE_PMD_I40E_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
53 RTE_PMD_I40E_MB_EVENT_PROCEED, /**< proceed with mbox request */
54 RTE_PMD_I40E_MB_EVENT_MAX /**< max value of this enum */
55 };
56
57 /**
58 * Data sent to the user application when the callback is executed.
59 */
60 struct rte_pmd_i40e_mb_event_param {
61 uint16_t vfid; /**< Virtual Function number */
62 uint16_t msg_type; /**< VF to PF message type, see i40e_virtchnl_ops */
63 uint16_t retval; /**< return value */
64 void *msg; /**< pointer to message */
65 uint16_t msglen; /**< length of the message */
66 };
67
68 /**
69 * Option of package processing.
70 */
71 enum rte_pmd_i40e_package_op {
72 RTE_PMD_I40E_PKG_OP_UNDEFINED = 0,
73 RTE_PMD_I40E_PKG_OP_WR_ADD, /**< load package and add to info list */
74 RTE_PMD_I40E_PKG_OP_MAX = 32
75 };
76
77 #define RTE_PMD_I40E_DDP_NAME_SIZE 32
78
79 /**
80 * Version for dynamic device personalization.
81 * Version in "major.minor.update.draft" format.
82 */
83 struct rte_pmd_i40e_ddp_version {
84 uint8_t major;
85 uint8_t minor;
86 uint8_t update;
87 uint8_t draft;
88 };
89
90 /**
91 * Profile information in profile info list.
92 */
93 struct rte_pmd_i40e_profile_info {
94 uint32_t track_id;
95 struct rte_pmd_i40e_ddp_version version;
96 uint8_t owner;
97 uint8_t reserved[7];
98 uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
99 };
100
101 /**
102 * Profile information list returned from HW.
103 */
104 struct rte_pmd_i40e_profile_list {
105 uint32_t p_count;
106 struct rte_pmd_i40e_profile_info p_info[1];
107 };
108
109 /**
110 * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
111 * A ptype with MSB set will be regarded as a user defined ptype.
112 * Below macro help to create a user defined ptype.
113 */
114 #define RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK 0x80000000
115
116 struct rte_pmd_i40e_ptype_mapping {
117 uint16_t hw_ptype; /**< hardware defined packet type*/
118 uint32_t sw_ptype; /**< software defined packet type */
119 };
120
121 /**
122 * Notify VF when PF link status changes.
123 *
124 * @param port
125 * The port identifier of the Ethernet device.
126 * @param vf
127 * VF id.
128 * @return
129 * - (0) if successful.
130 * - (-ENODEV) if *port* invalid.
131 * - (-EINVAL) if *vf* invalid.
132 */
133 int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
134
135 /**
136 * Enable/Disable VF MAC anti spoofing.
137 *
138 * @param port
139 * The port identifier of the Ethernet device.
140 * @param vf_id
141 * VF on which to set MAC anti spoofing.
142 * @param on
143 * 1 - Enable VFs MAC anti spoofing.
144 * 0 - Disable VFs MAC anti spoofing.
145 * @return
146 * - (0) if successful.
147 * - (-ENODEV) if *port* invalid.
148 * - (-EINVAL) if bad parameter.
149 */
150 int rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port,
151 uint16_t vf_id,
152 uint8_t on);
153
154 /**
155 * Enable/Disable VF VLAN anti spoofing.
156 *
157 * @param port
158 * The port identifier of the Ethernet device.
159 * @param vf_id
160 * VF on which to set VLAN anti spoofing.
161 * @param on
162 * 1 - Enable VFs VLAN anti spoofing.
163 * 0 - Disable VFs VLAN anti spoofing.
164 * @return
165 * - (0) if successful.
166 * - (-ENODEV) if *port* invalid.
167 * - (-EINVAL) if bad parameter.
168 */
169 int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port,
170 uint16_t vf_id,
171 uint8_t on);
172
173 /**
174 * Enable/Disable TX loopback on all the PF and VFs.
175 *
176 * @param port
177 * The port identifier of the Ethernet device.
178 * @param on
179 * 1 - Enable TX loopback.
180 * 0 - Disable TX loopback.
181 * @return
182 * - (0) if successful.
183 * - (-ENODEV) if *port* invalid.
184 * - (-EINVAL) if bad parameter.
185 */
186 int rte_pmd_i40e_set_tx_loopback(uint8_t port,
187 uint8_t on);
188
189 /**
190 * Enable/Disable VF unicast promiscuous mode.
191 *
192 * @param port
193 * The port identifier of the Ethernet device.
194 * @param vf_id
195 * VF on which to set.
196 * @param on
197 * 1 - Enable.
198 * 0 - Disable.
199 * @return
200 * - (0) if successful.
201 * - (-ENODEV) if *port* invalid.
202 * - (-EINVAL) if bad parameter.
203 */
204 int rte_pmd_i40e_set_vf_unicast_promisc(uint8_t port,
205 uint16_t vf_id,
206 uint8_t on);
207
208 /**
209 * Enable/Disable VF multicast promiscuous mode.
210 *
211 * @param port
212 * The port identifier of the Ethernet device.
213 * @param vf_id
214 * VF on which to set.
215 * @param on
216 * 1 - Enable.
217 * 0 - Disable.
218 * @return
219 * - (0) if successful.
220 * - (-ENODEV) if *port* invalid.
221 * - (-EINVAL) if bad parameter.
222 */
223 int rte_pmd_i40e_set_vf_multicast_promisc(uint8_t port,
224 uint16_t vf_id,
225 uint8_t on);
226
227 /**
228 * Set the VF MAC address.
229 *
230 * PF should set MAC address before VF initialized, if PF sets the MAC
231 * address after VF initialized, new MAC address won't be effective until
232 * VF reinitialize.
233 *
234 * This will remove all existing MAC filters.
235 *
236 * @param port
237 * The port identifier of the Ethernet device.
238 * @param vf_id
239 * VF id.
240 * @param mac_addr
241 * VF MAC address.
242 * @return
243 * - (0) if successful.
244 * - (-ENODEV) if *port* invalid.
245 * - (-EINVAL) if *vf* or *mac_addr* is invalid.
246 */
247 int rte_pmd_i40e_set_vf_mac_addr(uint8_t port, uint16_t vf_id,
248 struct ether_addr *mac_addr);
249
250 /**
251 * Enable/Disable vf vlan strip for all queues in a pool
252 *
253 * @param port
254 * The port identifier of the Ethernet device.
255 * @param vf
256 * ID specifying VF.
257 * @param on
258 * 1 - Enable VF's vlan strip on RX queues.
259 * 0 - Disable VF's vlan strip on RX queues.
260 *
261 * @return
262 * - (0) if successful.
263 * - (-ENODEV) if *port* invalid.
264 * - (-EINVAL) if bad parameter.
265 */
266 int
267 rte_pmd_i40e_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
268
269 /**
270 * Enable/Disable vf vlan insert
271 *
272 * @param port
273 * The port identifier of the Ethernet device.
274 * @param vf_id
275 * ID specifying VF.
276 * @param vlan_id
277 * 0 - Disable VF's vlan insert.
278 * n - Enable; n is inserted as the vlan id.
279 *
280 * @return
281 * - (0) if successful.
282 * - (-ENODEV) if *port* invalid.
283 * - (-EINVAL) if bad parameter.
284 */
285 int rte_pmd_i40e_set_vf_vlan_insert(uint8_t port, uint16_t vf_id,
286 uint16_t vlan_id);
287
288 /**
289 * Enable/Disable vf broadcast mode
290 *
291 * @param port
292 * The port identifier of the Ethernet device.
293 * @param vf_id
294 * ID specifying VF.
295 * @param on
296 * 0 - Disable broadcast.
297 * 1 - Enable broadcast.
298 *
299 * @return
300 * - (0) if successful.
301 * - (-ENODEV) if *port* invalid.
302 * - (-EINVAL) if bad parameter.
303 */
304 int rte_pmd_i40e_set_vf_broadcast(uint8_t port, uint16_t vf_id,
305 uint8_t on);
306
307 /**
308 * Enable/Disable vf vlan tag
309 *
310 * @param port
311 * The port identifier of the Ethernet device.
312 * @param vf_id
313 * ID specifying VF.
314 * @param on
315 * 0 - Disable VF's vlan tag.
316 * n - Enable VF's vlan tag.
317 *
318 * @return
319 * - (0) if successful.
320 * - (-ENODEV) if *port* invalid.
321 * - (-EINVAL) if bad parameter.
322 */
323 int rte_pmd_i40e_set_vf_vlan_tag(uint8_t port, uint16_t vf_id, uint8_t on);
324
325 /**
326 * Enable/Disable VF VLAN filter
327 *
328 * @param port
329 * The port identifier of the Ethernet device.
330 * @param vlan_id
331 * ID specifying VLAN
332 * @param vf_mask
333 * Mask to filter VF's
334 * @param on
335 * 0 - Disable VF's VLAN filter.
336 * 1 - Enable VF's VLAN filter.
337 *
338 * @return
339 * - (0) if successful.
340 * - (-ENODEV) if *port* invalid.
341 * - (-EINVAL) if bad parameter.
342 * - (-ENOTSUP) not supported by firmware.
343 */
344 int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
345 uint64_t vf_mask, uint8_t on);
346
347 /**
348 * Get VF's statistics
349 *
350 * @param port
351 * The port identifier of the Ethernet device.
352 * @param vf_id
353 * VF on which to get.
354 * @param stats
355 * A pointer to a structure of type *rte_eth_stats* to be filled with
356 * the values of device counters for the following set of statistics:
357 * - *ipackets* with the total of successfully received packets.
358 * - *opackets* with the total of successfully transmitted packets.
359 * - *ibytes* with the total of successfully received bytes.
360 * - *obytes* with the total of successfully transmitted bytes.
361 * - *ierrors* with the total of erroneous received packets.
362 * - *oerrors* with the total of failed transmitted packets.
363 * @return
364 * - (0) if successful.
365 * - (-ENODEV) if *port* invalid.
366 * - (-EINVAL) if bad parameter.
367 */
368
369 int rte_pmd_i40e_get_vf_stats(uint8_t port,
370 uint16_t vf_id,
371 struct rte_eth_stats *stats);
372
373 /**
374 * Clear VF's statistics
375 *
376 * @param port
377 * The port identifier of the Ethernet device.
378 * @param vf_id
379 * VF on which to get.
380 * @return
381 * - (0) if successful.
382 * - (-ENODEV) if *port* invalid.
383 * - (-EINVAL) if bad parameter.
384 */
385 int rte_pmd_i40e_reset_vf_stats(uint8_t port,
386 uint16_t vf_id);
387
388 /**
389 * Set VF's max bandwidth.
390 *
391 * Per VF bandwidth limitation and per TC bandwidth limitation cannot
392 * be enabled in parallel. If per TC bandwidth is enabled, this function
393 * will disable it.
394 *
395 * @param port
396 * The port identifier of the Ethernet device.
397 * @param vf_id
398 * ID specifying VF.
399 * @param bw
400 * Bandwidth for this VF.
401 * The value should be an absolute bandwidth in Mbps.
402 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
403 * Not count the bytes added by physical layer.
404 * @return
405 * - (0) if successful.
406 * - (-ENODEV) if *port* invalid.
407 * - (-EINVAL) if bad parameter.
408 * - (-ENOTSUP) not supported by firmware.
409 */
410 int rte_pmd_i40e_set_vf_max_bw(uint8_t port,
411 uint16_t vf_id,
412 uint32_t bw);
413
414 /**
415 * Set all the TCs' bandwidth weight on a specific VF.
416 *
417 * The bw_weight means the percentage occupied by the TC.
418 * It can be taken as the relative min bandwidth setting.
419 *
420 * @param port
421 * The port identifier of the Ethernet device.
422 * @param vf_id
423 * ID specifying VF.
424 * @param tc_num
425 * Number of TCs.
426 * @param bw_weight
427 * An array of relative bandwidth weight for all the TCs.
428 * The summary of the bw_weight should be 100.
429 * @return
430 * - (0) if successful.
431 * - (-ENODEV) if *port* invalid.
432 * - (-EINVAL) if bad parameter.
433 * - (-ENOTSUP) not supported by firmware.
434 */
435 int rte_pmd_i40e_set_vf_tc_bw_alloc(uint8_t port,
436 uint16_t vf_id,
437 uint8_t tc_num,
438 uint8_t *bw_weight);
439
440 /**
441 * Set a specific TC's max bandwidth on a specific VF.
442 *
443 * @param port
444 * The port identifier of the Ethernet device.
445 * @param vf_id
446 * ID specifying VF.
447 * @param tc_no
448 * Number specifying TC.
449 * @param bw
450 * Max bandwidth for this TC.
451 * The value should be an absolute bandwidth in Mbps.
452 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
453 * Not count the bytes added by physical layer.
454 * @return
455 * - (0) if successful.
456 * - (-ENODEV) if *port* invalid.
457 * - (-EINVAL) if bad parameter.
458 * - (-ENOTSUP) not supported by firmware.
459 */
460 int rte_pmd_i40e_set_vf_tc_max_bw(uint8_t port,
461 uint16_t vf_id,
462 uint8_t tc_no,
463 uint32_t bw);
464
465 /**
466 * Set some TCs to strict priority mode on a physical port.
467 *
468 * @param port
469 * The port identifier of the Ethernet device.
470 * @param tc_map
471 * A bit map for the TCs.
472 * @return
473 * - (0) if successful.
474 * - (-ENODEV) if *port* invalid.
475 * - (-EINVAL) if bad parameter.
476 * - (-ENOTSUP) not supported by firmware.
477 */
478 int rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map);
479
480 /**
481 * Load/Unload a ddp package
482 *
483 * @param port
484 * The port identifier of the Ethernet device.
485 * @param buff
486 * buffer of package.
487 * @param size
488 * size of buffer.
489 * @param op
490 * Operation of package processing
491 * @return
492 * - (0) if successful.
493 * - (-ENODEV) if *port* invalid.
494 * - (-EINVAL) if bad parameter.
495 * - (1) if profile exists.
496 */
497 int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
498 uint32_t size,
499 enum rte_pmd_i40e_package_op op);
500
501 /**
502 * rte_pmd_i40e_get_ddp_list - Get loaded profile list
503 * @param port
504 * port id
505 * @param buff
506 * buffer for response
507 * @param size
508 * buffer size
509 * @return
510 * - (0) if successful.
511 * - (-ENODEV) if *port* invalid.
512 * - (-EINVAL) if bad parameter.
513 */
514 int rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size);
515
516 /**
517 * Update hardware defined ptype to software defined packet type
518 * mapping table.
519 *
520 * @param port
521 * pointer to port identifier of the device.
522 * @param mapping_items
523 * the base address of the mapping items array.
524 * @param count
525 * number of mapping items.
526 * @param exclusive
527 * the flag indicate different ptype mapping update method.
528 * -(0) only overwrite referred PTYPE mapping,
529 * keep other PTYPEs mapping unchanged.
530 * -(!0) overwrite referred PTYPE mapping,
531 * set other PTYPEs maps to PTYPE_UNKNOWN.
532 */
533 int rte_pmd_i40e_ptype_mapping_update(
534 uint8_t port,
535 struct rte_pmd_i40e_ptype_mapping *mapping_items,
536 uint16_t count,
537 uint8_t exclusive);
538
539 /**
540 * Reset hardware defined ptype to software defined ptype
541 * mapping table to default.
542 *
543 * @param port
544 * pointer to port identifier of the device
545 */
546 int rte_pmd_i40e_ptype_mapping_reset(uint8_t port);
547
548 /**
549 * Get hardware defined ptype to software defined ptype
550 * mapping items.
551 *
552 * @param port
553 * pointer to port identifier of the device.
554 * @param mapping_items
555 * the base address of the array to store returned items.
556 * @param size
557 * the size of the input array.
558 * @param count
559 * the place to store the number of returned items.
560 * @param valid_only
561 * -(0) return full mapping table.
562 * -(!0) only return mapping items which packet_type != RTE_PTYPE_UNKNOWN.
563 */
564 int rte_pmd_i40e_ptype_mapping_get(
565 uint8_t port,
566 struct rte_pmd_i40e_ptype_mapping *mapping_items,
567 uint16_t size,
568 uint16_t *count,
569 uint8_t valid_only);
570
571 /**
572 * Replace a specific or a group of software defined ptypes
573 * with a new one
574 *
575 * @param port
576 * pointer to port identifier of the device
577 * @param target
578 * the packet type to be replaced
579 * @param mask
580 * -(0) target represent a specific software defined ptype.
581 * -(!0) target is a mask to represent a group of software defined ptypes.
582 * @param pkt_type
583 * the new packet type to overwrite
584 */
585 int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
586 uint32_t target,
587 uint8_t mask,
588 uint32_t pkt_type);
589
590 #endif /* _PMD_I40E_H_ */