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
101 * Option types of queue region.
103 enum rte_pmd_i40e_queue_region_op {
104 RTE_PMD_I40E_RSS_QUEUE_REGION_UNDEFINED,
105 /** add queue region set */
106 RTE_PMD_I40E_RSS_QUEUE_REGION_SET,
107 /** add PF region pctype set */
108 RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET,
109 /** add queue region user priority set */
110 RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET,
112 * ALL configuration about queue region from up layer
113 * at first will only keep in DPDK software stored in driver,
114 * only after " FLUSH_ON ", it commit all configuration to HW.
115 * Because PMD had to set hardware configuration at a time, so
116 * it will record all up layer command at first.
118 RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON,
120 * "FLUSH_OFF " is just clean all configuration about queue
121 * region just now, and restore all to DPDK i40e driver default
122 * config when start up.
124 RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF,
125 RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET,
126 RTE_PMD_I40E_RSS_QUEUE_REGION_OP_MAX
129 #define RTE_PMD_I40E_DDP_NAME_SIZE 32
130 #define RTE_PMD_I40E_PCTYPE_MAX 64
131 #define RTE_PMD_I40E_REGION_MAX_NUM 8
132 #define RTE_PMD_I40E_MAX_USER_PRIORITY 8
135 * Version for dynamic device personalization.
136 * Version in "major.minor.update.draft" format.
138 struct rte_pmd_i40e_ddp_version {
146 * Device ID for dynamic device personalization.
148 struct rte_pmd_i40e_ddp_device_id {
149 uint32_t vendor_dev_id;
150 uint32_t sub_vendor_dev_id;
154 * Profile information in profile info list.
156 struct rte_pmd_i40e_profile_info {
158 struct rte_pmd_i40e_ddp_version version;
161 uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
164 #define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
167 * Profile information list returned from HW.
169 struct rte_pmd_i40e_profile_list {
171 struct rte_pmd_i40e_profile_info p_info[1];
174 #define RTE_PMD_I40E_PROTO_NUM 6
175 #define RTE_PMD_I40E_PROTO_UNUSED 0xFF
178 * Protocols information stored in profile
180 struct rte_pmd_i40e_proto_info {
182 char name[RTE_PMD_I40E_DDP_NAME_SIZE];
186 * Packet classification/ packet type information stored in profile
188 struct rte_pmd_i40e_ptype_info {
190 uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
194 * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
195 * A ptype with MSB set will be regarded as a user defined ptype.
196 * Below macro help to create a user defined ptype.
198 #define RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK 0x80000000
200 struct rte_pmd_i40e_ptype_mapping {
201 uint16_t hw_ptype; /**< hardware defined packet type*/
202 uint32_t sw_ptype; /**< software defined packet type */
206 * Queue region related information.
208 struct rte_pmd_i40e_queue_region_conf {
209 /** the region id for this configuration */
211 /** the pctype or hardware flowtype of packet,
212 * the specific index for each type has been defined
213 * in file i40e_type.h as enum i40e_filter_pctype.
216 /** the start queue index for this region */
217 uint8_t queue_start_index;
218 /** the total queue number of this queue region */
220 /** the packet's user priority for this region */
221 uint8_t user_priority;
224 /* queue region info */
225 struct rte_pmd_i40e_queue_region_info {
226 /** the region id for this configuration */
228 /** the start queue index for this region */
229 uint8_t queue_start_index;
230 /** the total queue number of this queue region */
232 /** the total number of user priority for this region */
233 uint8_t user_priority_num;
234 /** the packet's user priority for this region */
235 uint8_t user_priority[RTE_PMD_I40E_MAX_USER_PRIORITY];
236 /** the total number of flowtype for this region */
237 uint8_t flowtype_num;
239 * the pctype or hardware flowtype of packet,
240 * the specific index for each type has been defined
241 * in file i40e_type.h as enum i40e_filter_pctype.
243 uint8_t hw_flowtype[RTE_PMD_I40E_PCTYPE_MAX];
246 struct rte_pmd_i40e_queue_regions {
247 /** the total number of queue region for this port */
248 uint16_t queue_region_number;
249 struct rte_pmd_i40e_queue_region_info
250 region[RTE_PMD_I40E_REGION_MAX_NUM];
254 * Notify VF when PF link status changes.
257 * The port identifier of the Ethernet device.
261 * - (0) if successful.
262 * - (-ENODEV) if *port* invalid.
263 * - (-EINVAL) if *vf* invalid.
265 int rte_pmd_i40e_ping_vfs(uint16_t port, uint16_t vf);
268 * Enable/Disable VF MAC anti spoofing.
271 * The port identifier of the Ethernet device.
273 * VF on which to set MAC anti spoofing.
275 * 1 - Enable VFs MAC anti spoofing.
276 * 0 - Disable VFs MAC anti spoofing.
278 * - (0) if successful.
279 * - (-ENODEV) if *port* invalid.
280 * - (-EINVAL) if bad parameter.
282 int rte_pmd_i40e_set_vf_mac_anti_spoof(uint16_t port,
287 * Enable/Disable VF VLAN anti spoofing.
290 * The port identifier of the Ethernet device.
292 * VF on which to set VLAN anti spoofing.
294 * 1 - Enable VFs VLAN anti spoofing.
295 * 0 - Disable VFs VLAN anti spoofing.
297 * - (0) if successful.
298 * - (-ENODEV) if *port* invalid.
299 * - (-EINVAL) if bad parameter.
301 int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint16_t port,
306 * Enable/Disable TX loopback on all the PF and VFs.
309 * The port identifier of the Ethernet device.
311 * 1 - Enable TX loopback.
312 * 0 - Disable TX loopback.
314 * - (0) if successful.
315 * - (-ENODEV) if *port* invalid.
316 * - (-EINVAL) if bad parameter.
318 int rte_pmd_i40e_set_tx_loopback(uint16_t port,
322 * Enable/Disable VF unicast promiscuous mode.
325 * The port identifier of the Ethernet device.
327 * VF on which to set.
332 * - (0) if successful.
333 * - (-ENODEV) if *port* invalid.
334 * - (-EINVAL) if bad parameter.
336 int rte_pmd_i40e_set_vf_unicast_promisc(uint16_t port,
341 * Enable/Disable VF multicast promiscuous mode.
344 * The port identifier of the Ethernet device.
346 * VF on which to set.
351 * - (0) if successful.
352 * - (-ENODEV) if *port* invalid.
353 * - (-EINVAL) if bad parameter.
355 int rte_pmd_i40e_set_vf_multicast_promisc(uint16_t port,
360 * Set the VF MAC address.
362 * PF should set MAC address before VF initialized, if PF sets the MAC
363 * address after VF initialized, new MAC address won't be effective until
366 * This will remove all existing MAC filters.
369 * The port identifier of the Ethernet device.
375 * - (0) if successful.
376 * - (-ENODEV) if *port* invalid.
377 * - (-EINVAL) if *vf* or *mac_addr* is invalid.
379 int rte_pmd_i40e_set_vf_mac_addr(uint16_t port, uint16_t vf_id,
380 struct ether_addr *mac_addr);
383 * Enable/Disable vf vlan strip for all queues in a pool
386 * The port identifier of the Ethernet device.
390 * 1 - Enable VF's vlan strip on RX queues.
391 * 0 - Disable VF's vlan strip on RX queues.
394 * - (0) if successful.
395 * - (-ENODEV) if *port* invalid.
396 * - (-EINVAL) if bad parameter.
399 rte_pmd_i40e_set_vf_vlan_stripq(uint16_t port, uint16_t vf, uint8_t on);
402 * Enable/Disable vf vlan insert
405 * The port identifier of the Ethernet device.
409 * 0 - Disable VF's vlan insert.
410 * n - Enable; n is inserted as the vlan id.
413 * - (0) if successful.
414 * - (-ENODEV) if *port* invalid.
415 * - (-EINVAL) if bad parameter.
417 int rte_pmd_i40e_set_vf_vlan_insert(uint16_t port, uint16_t vf_id,
421 * Enable/Disable vf broadcast mode
424 * The port identifier of the Ethernet device.
428 * 0 - Disable broadcast.
429 * 1 - Enable broadcast.
432 * - (0) if successful.
433 * - (-ENODEV) if *port* invalid.
434 * - (-EINVAL) if bad parameter.
436 int rte_pmd_i40e_set_vf_broadcast(uint16_t port, uint16_t vf_id,
440 * Enable/Disable vf vlan tag
443 * The port identifier of the Ethernet device.
447 * 0 - Disable VF's vlan tag.
448 * n - Enable VF's vlan tag.
451 * - (0) if successful.
452 * - (-ENODEV) if *port* invalid.
453 * - (-EINVAL) if bad parameter.
455 int rte_pmd_i40e_set_vf_vlan_tag(uint16_t port, uint16_t vf_id, uint8_t on);
458 * Enable/Disable VF VLAN filter
461 * The port identifier of the Ethernet device.
465 * Mask to filter VF's
467 * 0 - Disable VF's VLAN filter.
468 * 1 - Enable VF's VLAN filter.
471 * - (0) if successful.
472 * - (-ENODEV) if *port* invalid.
473 * - (-EINVAL) if bad parameter.
474 * - (-ENOTSUP) not supported by firmware.
476 int rte_pmd_i40e_set_vf_vlan_filter(uint16_t port, uint16_t vlan_id,
477 uint64_t vf_mask, uint8_t on);
480 * Get VF's statistics
483 * The port identifier of the Ethernet device.
485 * VF on which to get.
487 * A pointer to a structure of type *rte_eth_stats* to be filled with
488 * the values of device counters for the following set of statistics:
489 * - *ipackets* with the total of successfully received packets.
490 * - *opackets* with the total of successfully transmitted packets.
491 * - *ibytes* with the total of successfully received bytes.
492 * - *obytes* with the total of successfully transmitted bytes.
493 * - *ierrors* with the total of erroneous received packets.
494 * - *oerrors* with the total of failed transmitted packets.
496 * - (0) if successful.
497 * - (-ENODEV) if *port* invalid.
498 * - (-EINVAL) if bad parameter.
501 int rte_pmd_i40e_get_vf_stats(uint16_t port,
503 struct rte_eth_stats *stats);
506 * Clear VF's statistics
509 * The port identifier of the Ethernet device.
511 * VF on which to get.
513 * - (0) if successful.
514 * - (-ENODEV) if *port* invalid.
515 * - (-EINVAL) if bad parameter.
517 int rte_pmd_i40e_reset_vf_stats(uint16_t port,
521 * Set VF's max bandwidth.
523 * Per VF bandwidth limitation and per TC bandwidth limitation cannot
524 * be enabled in parallel. If per TC bandwidth is enabled, this function
528 * The port identifier of the Ethernet device.
532 * Bandwidth for this VF.
533 * The value should be an absolute bandwidth in Mbps.
534 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
535 * Not count the bytes added by physical layer.
537 * - (0) if successful.
538 * - (-ENODEV) if *port* invalid.
539 * - (-EINVAL) if bad parameter.
540 * - (-ENOTSUP) not supported by firmware.
542 int rte_pmd_i40e_set_vf_max_bw(uint16_t port,
547 * Set all the TCs' bandwidth weight on a specific VF.
549 * The bw_weight means the percentage occupied by the TC.
550 * It can be taken as the relative min bandwidth setting.
553 * The port identifier of the Ethernet device.
559 * An array of relative bandwidth weight for all the TCs.
560 * The summary of the bw_weight should be 100.
562 * - (0) if successful.
563 * - (-ENODEV) if *port* invalid.
564 * - (-EINVAL) if bad parameter.
565 * - (-ENOTSUP) not supported by firmware.
567 int rte_pmd_i40e_set_vf_tc_bw_alloc(uint16_t port,
573 * Set a specific TC's max bandwidth on a specific VF.
576 * The port identifier of the Ethernet device.
580 * Number specifying TC.
582 * Max bandwidth for this TC.
583 * The value should be an absolute bandwidth in Mbps.
584 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
585 * Not count the bytes added by physical layer.
587 * - (0) if successful.
588 * - (-ENODEV) if *port* invalid.
589 * - (-EINVAL) if bad parameter.
590 * - (-ENOTSUP) not supported by firmware.
592 int rte_pmd_i40e_set_vf_tc_max_bw(uint16_t port,
598 * Set some TCs to strict priority mode on a physical port.
601 * The port identifier of the Ethernet device.
603 * A bit map for the TCs.
605 * - (0) if successful.
606 * - (-ENODEV) if *port* invalid.
607 * - (-EINVAL) if bad parameter.
608 * - (-ENOTSUP) not supported by firmware.
610 int rte_pmd_i40e_set_tc_strict_prio(uint16_t port, uint8_t tc_map);
613 * Load/Unload a ddp package
616 * The port identifier of the Ethernet device.
622 * Operation of package processing
624 * - (0) if successful.
625 * - (-ENODEV) if *port* invalid.
626 * - (-EINVAL) if bad parameter.
627 * - (-EEXIST) if profile exists.
628 * - (-EACCES) if profile does not exist.
629 * - (-ENOTSUP) if operation not supported.
631 int rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,
633 enum rte_pmd_i40e_package_op op);
636 * rte_pmd_i40e_get_ddp_info - Get profile's info
640 * package buffer size
642 * buffer for response
644 * response buffer size
646 * type of information requested
648 * - (0) if successful.
649 * - (-ENOTSUP) if information type not supported by the profile.
650 * - (-EINVAL) if bad parameter.
652 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
653 uint8_t *info, uint32_t size,
654 enum rte_pmd_i40e_package_info type);
657 * rte_pmd_i40e_get_ddp_list - Get loaded profile list
661 * buffer for response
665 * - (0) if successful.
666 * - (-ENODEV) if *port* invalid.
667 * - (-EINVAL) if bad parameter.
669 int rte_pmd_i40e_get_ddp_list(uint16_t port, uint8_t *buff, uint32_t size);
672 * Update hardware defined ptype to software defined packet type
676 * pointer to port identifier of the device.
677 * @param mapping_items
678 * the base address of the mapping items array.
680 * number of mapping items.
682 * the flag indicate different ptype mapping update method.
683 * -(0) only overwrite referred PTYPE mapping,
684 * keep other PTYPEs mapping unchanged.
685 * -(!0) overwrite referred PTYPE mapping,
686 * set other PTYPEs maps to PTYPE_UNKNOWN.
688 int rte_pmd_i40e_ptype_mapping_update(
690 struct rte_pmd_i40e_ptype_mapping *mapping_items,
695 * Reset hardware defined ptype to software defined ptype
696 * mapping table to default.
699 * pointer to port identifier of the device
701 int rte_pmd_i40e_ptype_mapping_reset(uint16_t port);
704 * Get hardware defined ptype to software defined ptype
708 * pointer to port identifier of the device.
709 * @param mapping_items
710 * the base address of the array to store returned items.
712 * the size of the input array.
714 * the place to store the number of returned items.
716 * -(0) return full mapping table.
717 * -(!0) only return mapping items which packet_type != RTE_PTYPE_UNKNOWN.
719 int rte_pmd_i40e_ptype_mapping_get(
721 struct rte_pmd_i40e_ptype_mapping *mapping_items,
727 * Replace a specific or a group of software defined ptypes
731 * pointer to port identifier of the device
733 * the packet type to be replaced
735 * -(0) target represent a specific software defined ptype.
736 * -(!0) target is a mask to represent a group of software defined ptypes.
738 * the new packet type to overwrite
740 int rte_pmd_i40e_ptype_mapping_replace(uint16_t port,
746 * Add a VF MAC address.
748 * Add more MAC address for VF. The existing MAC addresses
749 * are still effective.
752 * The port identifier of the Ethernet device.
758 * - (0) if successful.
759 * - (-ENODEV) if *port* invalid.
760 * - (-EINVAL) if *vf* or *mac_addr* is invalid.
762 int rte_pmd_i40e_add_vf_mac_addr(uint8_t port, uint16_t vf_id,
763 struct ether_addr *mac_addr);
765 #define RTE_PMD_I40E_PCTYPE_MAX 64
766 #define RTE_PMD_I40E_FLOW_TYPE_MAX 64
768 struct rte_pmd_i40e_flow_type_mapping {
769 uint16_t flow_type; /**< software defined flow type*/
770 uint64_t pctype; /**< hardware defined pctype */
774 * Update hardware defined pctype to software defined flow type
778 * pointer to port identifier of the device.
779 * @param mapping_items
780 * the base address of the mapping items array.
782 * number of mapping items.
784 * the flag indicate different pctype mapping update method.
785 * -(0) only overwrite referred PCTYPE mapping,
786 * keep other PCTYPEs mapping unchanged.
787 * -(!0) overwrite referred PCTYPE mapping,
788 * set other PCTYPEs maps to PCTYPE_INVALID.
790 int rte_pmd_i40e_flow_type_mapping_update(
792 struct rte_pmd_i40e_flow_type_mapping *mapping_items,
797 * Get software defined flow type to hardware defined pctype
801 * pointer to port identifier of the device.
802 * @param mapping_items
803 * the base address of the array to store returned items.
804 * array should be allocated by caller with minimum size of
805 * RTE_PMD_I40E_FLOW_TYPE_MAX items
807 int rte_pmd_i40e_flow_type_mapping_get(
809 struct rte_pmd_i40e_flow_type_mapping *mapping_items);
812 * Reset hardware defined pctype to software defined flow type
813 * mapping table to default.
816 * pointer to port identifier of the device
818 int rte_pmd_i40e_flow_type_mapping_reset(uint8_t port);
821 * On the PF, find VF index based on VF MAC address
824 * pointer to port identifier of the device
826 * the mac address of the vf to determine index of
828 * The index of vfid If successful.
829 * -EINVAL: vf mac address does not exist for this port
830 * -ENOTSUP: i40e not supported for this port.
832 int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
833 const struct ether_addr *vf_mac);
836 * Do RSS queue region configuration for that port as
837 * the command option type
840 * The port identifier of the Ethernet device.
842 * Queue region operation type
844 * Queue region operation type specific data
846 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
847 enum rte_pmd_i40e_queue_region_op op_type, void *arg);
849 #endif /* _PMD_I40E_H_ */