4 * Copyright (c) 2017 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
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
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.
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.
37 * @file rte_pmd_i40e.h
39 * i40e PMD specific functions.
41 * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
45 #include <rte_ethdev.h>
48 * Response sent back to i40e driver from user app after callback
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 */
58 * Data sent to the user application when the callback is executed.
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 virtchnl_ops */
63 uint16_t retval; /**< return value */
64 void *msg; /**< pointer to message */
65 uint16_t msglen; /**< length of the message */
69 * Option of package processing.
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_WR_DEL, /**< load package and delete from info list */
75 RTE_PMD_I40E_PKG_OP_WR_ONLY, /**< load package without modifying info list */
76 RTE_PMD_I40E_PKG_OP_MAX = 32
80 * Types of package information.
82 enum rte_pmd_i40e_package_info {
83 RTE_PMD_I40E_PKG_INFO_UNDEFINED = 0,
84 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER,
85 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE,
86 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES,
87 RTE_PMD_I40E_PKG_INFO_GLOBAL_MAX = 1024,
88 RTE_PMD_I40E_PKG_INFO_HEADER,
89 RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
90 RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
91 RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
92 RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
93 RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
94 RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
95 RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
96 RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
97 RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
100 #define RTE_PMD_I40E_DDP_NAME_SIZE 32
103 * Version for dynamic device personalization.
104 * Version in "major.minor.update.draft" format.
106 struct rte_pmd_i40e_ddp_version {
114 * Device ID for dynamic device personalization.
116 struct rte_pmd_i40e_ddp_device_id {
117 uint32_t vendor_dev_id;
118 uint32_t sub_vendor_dev_id;
122 * Profile information in profile info list.
124 struct rte_pmd_i40e_profile_info {
126 struct rte_pmd_i40e_ddp_version version;
129 uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
132 #define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
135 * Profile information list returned from HW.
137 struct rte_pmd_i40e_profile_list {
139 struct rte_pmd_i40e_profile_info p_info[1];
142 #define RTE_PMD_I40E_PROTO_NUM 6
143 #define RTE_PMD_I40E_PROTO_UNUSED 0xFF
146 * Protocols information stored in profile
148 struct rte_pmd_i40e_proto_info {
150 char name[RTE_PMD_I40E_DDP_NAME_SIZE];
154 * Packet classification/ packet type information stored in profile
156 struct rte_pmd_i40e_ptype_info {
158 uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
162 * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
163 * A ptype with MSB set will be regarded as a user defined ptype.
164 * Below macro help to create a user defined ptype.
166 #define RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK 0x80000000
168 struct rte_pmd_i40e_ptype_mapping {
169 uint16_t hw_ptype; /**< hardware defined packet type*/
170 uint32_t sw_ptype; /**< software defined packet type */
174 * Notify VF when PF link status changes.
177 * The port identifier of the Ethernet device.
181 * - (0) if successful.
182 * - (-ENODEV) if *port* invalid.
183 * - (-EINVAL) if *vf* invalid.
185 int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
188 * Enable/Disable VF MAC anti spoofing.
191 * The port identifier of the Ethernet device.
193 * VF on which to set MAC anti spoofing.
195 * 1 - Enable VFs MAC anti spoofing.
196 * 0 - Disable VFs MAC anti spoofing.
198 * - (0) if successful.
199 * - (-ENODEV) if *port* invalid.
200 * - (-EINVAL) if bad parameter.
202 int rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port,
207 * Enable/Disable VF VLAN anti spoofing.
210 * The port identifier of the Ethernet device.
212 * VF on which to set VLAN anti spoofing.
214 * 1 - Enable VFs VLAN anti spoofing.
215 * 0 - Disable VFs VLAN anti spoofing.
217 * - (0) if successful.
218 * - (-ENODEV) if *port* invalid.
219 * - (-EINVAL) if bad parameter.
221 int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port,
226 * Enable/Disable TX loopback on all the PF and VFs.
229 * The port identifier of the Ethernet device.
231 * 1 - Enable TX loopback.
232 * 0 - Disable TX loopback.
234 * - (0) if successful.
235 * - (-ENODEV) if *port* invalid.
236 * - (-EINVAL) if bad parameter.
238 int rte_pmd_i40e_set_tx_loopback(uint8_t port,
242 * Enable/Disable VF unicast promiscuous mode.
245 * The port identifier of the Ethernet device.
247 * VF on which to set.
252 * - (0) if successful.
253 * - (-ENODEV) if *port* invalid.
254 * - (-EINVAL) if bad parameter.
256 int rte_pmd_i40e_set_vf_unicast_promisc(uint8_t port,
261 * Enable/Disable VF multicast promiscuous mode.
264 * The port identifier of the Ethernet device.
266 * VF on which to set.
271 * - (0) if successful.
272 * - (-ENODEV) if *port* invalid.
273 * - (-EINVAL) if bad parameter.
275 int rte_pmd_i40e_set_vf_multicast_promisc(uint8_t port,
280 * Set the VF MAC address.
282 * PF should set MAC address before VF initialized, if PF sets the MAC
283 * address after VF initialized, new MAC address won't be effective until
286 * This will remove all existing MAC filters.
289 * The port identifier of the Ethernet device.
295 * - (0) if successful.
296 * - (-ENODEV) if *port* invalid.
297 * - (-EINVAL) if *vf* or *mac_addr* is invalid.
299 int rte_pmd_i40e_set_vf_mac_addr(uint8_t port, uint16_t vf_id,
300 struct ether_addr *mac_addr);
303 * Enable/Disable vf vlan strip for all queues in a pool
306 * The port identifier of the Ethernet device.
310 * 1 - Enable VF's vlan strip on RX queues.
311 * 0 - Disable VF's vlan strip on RX queues.
314 * - (0) if successful.
315 * - (-ENODEV) if *port* invalid.
316 * - (-EINVAL) if bad parameter.
319 rte_pmd_i40e_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
322 * Enable/Disable vf vlan insert
325 * The port identifier of the Ethernet device.
329 * 0 - Disable VF's vlan insert.
330 * n - Enable; n is inserted as the vlan id.
333 * - (0) if successful.
334 * - (-ENODEV) if *port* invalid.
335 * - (-EINVAL) if bad parameter.
337 int rte_pmd_i40e_set_vf_vlan_insert(uint8_t port, uint16_t vf_id,
341 * Enable/Disable vf broadcast mode
344 * The port identifier of the Ethernet device.
348 * 0 - Disable broadcast.
349 * 1 - Enable broadcast.
352 * - (0) if successful.
353 * - (-ENODEV) if *port* invalid.
354 * - (-EINVAL) if bad parameter.
356 int rte_pmd_i40e_set_vf_broadcast(uint8_t port, uint16_t vf_id,
360 * Enable/Disable vf vlan tag
363 * The port identifier of the Ethernet device.
367 * 0 - Disable VF's vlan tag.
368 * n - Enable VF's vlan tag.
371 * - (0) if successful.
372 * - (-ENODEV) if *port* invalid.
373 * - (-EINVAL) if bad parameter.
375 int rte_pmd_i40e_set_vf_vlan_tag(uint8_t port, uint16_t vf_id, uint8_t on);
378 * Enable/Disable VF VLAN filter
381 * The port identifier of the Ethernet device.
385 * Mask to filter VF's
387 * 0 - Disable VF's VLAN filter.
388 * 1 - Enable VF's VLAN filter.
391 * - (0) if successful.
392 * - (-ENODEV) if *port* invalid.
393 * - (-EINVAL) if bad parameter.
394 * - (-ENOTSUP) not supported by firmware.
396 int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
397 uint64_t vf_mask, uint8_t on);
400 * Get VF's statistics
403 * The port identifier of the Ethernet device.
405 * VF on which to get.
407 * A pointer to a structure of type *rte_eth_stats* to be filled with
408 * the values of device counters for the following set of statistics:
409 * - *ipackets* with the total of successfully received packets.
410 * - *opackets* with the total of successfully transmitted packets.
411 * - *ibytes* with the total of successfully received bytes.
412 * - *obytes* with the total of successfully transmitted bytes.
413 * - *ierrors* with the total of erroneous received packets.
414 * - *oerrors* with the total of failed transmitted packets.
416 * - (0) if successful.
417 * - (-ENODEV) if *port* invalid.
418 * - (-EINVAL) if bad parameter.
421 int rte_pmd_i40e_get_vf_stats(uint8_t port,
423 struct rte_eth_stats *stats);
426 * Clear VF's statistics
429 * The port identifier of the Ethernet device.
431 * VF on which to get.
433 * - (0) if successful.
434 * - (-ENODEV) if *port* invalid.
435 * - (-EINVAL) if bad parameter.
437 int rte_pmd_i40e_reset_vf_stats(uint8_t port,
441 * Set VF's max bandwidth.
443 * Per VF bandwidth limitation and per TC bandwidth limitation cannot
444 * be enabled in parallel. If per TC bandwidth is enabled, this function
448 * The port identifier of the Ethernet device.
452 * Bandwidth for this VF.
453 * The value should be an absolute bandwidth in Mbps.
454 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
455 * Not count the bytes added by physical layer.
457 * - (0) if successful.
458 * - (-ENODEV) if *port* invalid.
459 * - (-EINVAL) if bad parameter.
460 * - (-ENOTSUP) not supported by firmware.
462 int rte_pmd_i40e_set_vf_max_bw(uint8_t port,
467 * Set all the TCs' bandwidth weight on a specific VF.
469 * The bw_weight means the percentage occupied by the TC.
470 * It can be taken as the relative min bandwidth setting.
473 * The port identifier of the Ethernet device.
479 * An array of relative bandwidth weight for all the TCs.
480 * The summary of the bw_weight should be 100.
482 * - (0) if successful.
483 * - (-ENODEV) if *port* invalid.
484 * - (-EINVAL) if bad parameter.
485 * - (-ENOTSUP) not supported by firmware.
487 int rte_pmd_i40e_set_vf_tc_bw_alloc(uint8_t port,
493 * Set a specific TC's max bandwidth on a specific VF.
496 * The port identifier of the Ethernet device.
500 * Number specifying TC.
502 * Max bandwidth for this TC.
503 * The value should be an absolute bandwidth in Mbps.
504 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
505 * Not count the bytes added by physical layer.
507 * - (0) if successful.
508 * - (-ENODEV) if *port* invalid.
509 * - (-EINVAL) if bad parameter.
510 * - (-ENOTSUP) not supported by firmware.
512 int rte_pmd_i40e_set_vf_tc_max_bw(uint8_t port,
518 * Set some TCs to strict priority mode on a physical port.
521 * The port identifier of the Ethernet device.
523 * A bit map for the TCs.
525 * - (0) if successful.
526 * - (-ENODEV) if *port* invalid.
527 * - (-EINVAL) if bad parameter.
528 * - (-ENOTSUP) not supported by firmware.
530 int rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map);
533 * Load/Unload a ddp package
536 * The port identifier of the Ethernet device.
542 * Operation of package processing
544 * - (0) if successful.
545 * - (-ENODEV) if *port* invalid.
546 * - (-EINVAL) if bad parameter.
547 * - (-EEXIST) if profile exists.
548 * - (-EACCES) if profile does not exist.
549 * - (-ENOTSUP) if operation not supported.
551 int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
553 enum rte_pmd_i40e_package_op op);
556 * rte_pmd_i40e_get_ddp_info - Get profile's info
560 * package buffer size
562 * buffer for response
564 * response buffer size
566 * type of information requested
568 * - (0) if successful.
569 * - (-ENOTSUP) if information type not supported by the profile.
570 * - (-EINVAL) if bad parameter.
572 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
573 uint8_t *info, uint32_t size,
574 enum rte_pmd_i40e_package_info type);
577 * rte_pmd_i40e_get_ddp_list - Get loaded profile list
581 * buffer for response
585 * - (0) if successful.
586 * - (-ENODEV) if *port* invalid.
587 * - (-EINVAL) if bad parameter.
589 int rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size);
592 * Update hardware defined ptype to software defined packet type
596 * pointer to port identifier of the device.
597 * @param mapping_items
598 * the base address of the mapping items array.
600 * number of mapping items.
602 * the flag indicate different ptype mapping update method.
603 * -(0) only overwrite referred PTYPE mapping,
604 * keep other PTYPEs mapping unchanged.
605 * -(!0) overwrite referred PTYPE mapping,
606 * set other PTYPEs maps to PTYPE_UNKNOWN.
608 int rte_pmd_i40e_ptype_mapping_update(
610 struct rte_pmd_i40e_ptype_mapping *mapping_items,
615 * Reset hardware defined ptype to software defined ptype
616 * mapping table to default.
619 * pointer to port identifier of the device
621 int rte_pmd_i40e_ptype_mapping_reset(uint8_t port);
624 * Get hardware defined ptype to software defined ptype
628 * pointer to port identifier of the device.
629 * @param mapping_items
630 * the base address of the array to store returned items.
632 * the size of the input array.
634 * the place to store the number of returned items.
636 * -(0) return full mapping table.
637 * -(!0) only return mapping items which packet_type != RTE_PTYPE_UNKNOWN.
639 int rte_pmd_i40e_ptype_mapping_get(
641 struct rte_pmd_i40e_ptype_mapping *mapping_items,
647 * Replace a specific or a group of software defined ptypes
651 * pointer to port identifier of the device
653 * the packet type to be replaced
655 * -(0) target represent a specific software defined ptype.
656 * -(!0) target is a mask to represent a group of software defined ptypes.
658 * the new packet type to overwrite
660 int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
666 * Add a VF MAC address.
668 * Add more MAC address for VF. The existing MAC addresses
669 * are still effective.
672 * The port identifier of the Ethernet device.
678 * - (0) if successful.
679 * - (-ENODEV) if *port* invalid.
680 * - (-EINVAL) if *vf* or *mac_addr* is invalid.
682 int rte_pmd_i40e_add_vf_mac_addr(uint8_t port, uint16_t vf_id,
683 struct ether_addr *mac_addr);
685 #endif /* _PMD_I40E_H_ */