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 i40e_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_MAX = 32
78 * Types of package information.
80 enum rte_pmd_i40e_package_info {
81 RTE_PMD_I40E_PKG_INFO_UNDEFINED = 0,
82 RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER,
83 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE,
84 RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES,
85 RTE_PMD_I40E_PKG_INFO_GLOBAL_MAX = 1024,
86 RTE_PMD_I40E_PKG_INFO_HEADER,
87 RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
88 RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
89 RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
92 #define RTE_PMD_I40E_DDP_NAME_SIZE 32
95 * Version for dynamic device personalization.
96 * Version in "major.minor.update.draft" format.
98 struct rte_pmd_i40e_ddp_version {
106 * Device ID for dynamic device personalization.
108 struct rte_pmd_i40e_ddp_device_id {
109 uint32_t vendor_dev_id;
110 uint32_t sub_vendor_dev_id;
114 * Profile information in profile info list.
116 struct rte_pmd_i40e_profile_info {
118 struct rte_pmd_i40e_ddp_version version;
121 uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
124 #define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
127 * Profile information list returned from HW.
129 struct rte_pmd_i40e_profile_list {
131 struct rte_pmd_i40e_profile_info p_info[1];
135 * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
136 * A ptype with MSB set will be regarded as a user defined ptype.
137 * Below macro help to create a user defined ptype.
139 #define RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK 0x80000000
141 struct rte_pmd_i40e_ptype_mapping {
142 uint16_t hw_ptype; /**< hardware defined packet type*/
143 uint32_t sw_ptype; /**< software defined packet type */
147 * Notify VF when PF link status changes.
150 * The port identifier of the Ethernet device.
154 * - (0) if successful.
155 * - (-ENODEV) if *port* invalid.
156 * - (-EINVAL) if *vf* invalid.
158 int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
161 * Enable/Disable VF MAC anti spoofing.
164 * The port identifier of the Ethernet device.
166 * VF on which to set MAC anti spoofing.
168 * 1 - Enable VFs MAC anti spoofing.
169 * 0 - Disable VFs MAC anti spoofing.
171 * - (0) if successful.
172 * - (-ENODEV) if *port* invalid.
173 * - (-EINVAL) if bad parameter.
175 int rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port,
180 * Enable/Disable VF VLAN anti spoofing.
183 * The port identifier of the Ethernet device.
185 * VF on which to set VLAN anti spoofing.
187 * 1 - Enable VFs VLAN anti spoofing.
188 * 0 - Disable VFs VLAN anti spoofing.
190 * - (0) if successful.
191 * - (-ENODEV) if *port* invalid.
192 * - (-EINVAL) if bad parameter.
194 int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port,
199 * Enable/Disable TX loopback on all the PF and VFs.
202 * The port identifier of the Ethernet device.
204 * 1 - Enable TX loopback.
205 * 0 - Disable TX loopback.
207 * - (0) if successful.
208 * - (-ENODEV) if *port* invalid.
209 * - (-EINVAL) if bad parameter.
211 int rte_pmd_i40e_set_tx_loopback(uint8_t port,
215 * Enable/Disable VF unicast promiscuous mode.
218 * The port identifier of the Ethernet device.
220 * VF on which to set.
225 * - (0) if successful.
226 * - (-ENODEV) if *port* invalid.
227 * - (-EINVAL) if bad parameter.
229 int rte_pmd_i40e_set_vf_unicast_promisc(uint8_t port,
234 * Enable/Disable VF multicast promiscuous mode.
237 * The port identifier of the Ethernet device.
239 * VF on which to set.
244 * - (0) if successful.
245 * - (-ENODEV) if *port* invalid.
246 * - (-EINVAL) if bad parameter.
248 int rte_pmd_i40e_set_vf_multicast_promisc(uint8_t port,
253 * Set the VF MAC address.
255 * PF should set MAC address before VF initialized, if PF sets the MAC
256 * address after VF initialized, new MAC address won't be effective until
259 * This will remove all existing MAC filters.
262 * The port identifier of the Ethernet device.
268 * - (0) if successful.
269 * - (-ENODEV) if *port* invalid.
270 * - (-EINVAL) if *vf* or *mac_addr* is invalid.
272 int rte_pmd_i40e_set_vf_mac_addr(uint8_t port, uint16_t vf_id,
273 struct ether_addr *mac_addr);
276 * Enable/Disable vf vlan strip for all queues in a pool
279 * The port identifier of the Ethernet device.
283 * 1 - Enable VF's vlan strip on RX queues.
284 * 0 - Disable VF's vlan strip on RX queues.
287 * - (0) if successful.
288 * - (-ENODEV) if *port* invalid.
289 * - (-EINVAL) if bad parameter.
292 rte_pmd_i40e_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
295 * Enable/Disable vf vlan insert
298 * The port identifier of the Ethernet device.
302 * 0 - Disable VF's vlan insert.
303 * n - Enable; n is inserted as the vlan id.
306 * - (0) if successful.
307 * - (-ENODEV) if *port* invalid.
308 * - (-EINVAL) if bad parameter.
310 int rte_pmd_i40e_set_vf_vlan_insert(uint8_t port, uint16_t vf_id,
314 * Enable/Disable vf broadcast mode
317 * The port identifier of the Ethernet device.
321 * 0 - Disable broadcast.
322 * 1 - Enable broadcast.
325 * - (0) if successful.
326 * - (-ENODEV) if *port* invalid.
327 * - (-EINVAL) if bad parameter.
329 int rte_pmd_i40e_set_vf_broadcast(uint8_t port, uint16_t vf_id,
333 * Enable/Disable vf vlan tag
336 * The port identifier of the Ethernet device.
340 * 0 - Disable VF's vlan tag.
341 * n - Enable VF's vlan tag.
344 * - (0) if successful.
345 * - (-ENODEV) if *port* invalid.
346 * - (-EINVAL) if bad parameter.
348 int rte_pmd_i40e_set_vf_vlan_tag(uint8_t port, uint16_t vf_id, uint8_t on);
351 * Enable/Disable VF VLAN filter
354 * The port identifier of the Ethernet device.
358 * Mask to filter VF's
360 * 0 - Disable VF's VLAN filter.
361 * 1 - Enable VF's VLAN filter.
364 * - (0) if successful.
365 * - (-ENODEV) if *port* invalid.
366 * - (-EINVAL) if bad parameter.
367 * - (-ENOTSUP) not supported by firmware.
369 int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
370 uint64_t vf_mask, uint8_t on);
373 * Get VF's statistics
376 * The port identifier of the Ethernet device.
378 * VF on which to get.
380 * A pointer to a structure of type *rte_eth_stats* to be filled with
381 * the values of device counters for the following set of statistics:
382 * - *ipackets* with the total of successfully received packets.
383 * - *opackets* with the total of successfully transmitted packets.
384 * - *ibytes* with the total of successfully received bytes.
385 * - *obytes* with the total of successfully transmitted bytes.
386 * - *ierrors* with the total of erroneous received packets.
387 * - *oerrors* with the total of failed transmitted packets.
389 * - (0) if successful.
390 * - (-ENODEV) if *port* invalid.
391 * - (-EINVAL) if bad parameter.
394 int rte_pmd_i40e_get_vf_stats(uint8_t port,
396 struct rte_eth_stats *stats);
399 * Clear VF's statistics
402 * The port identifier of the Ethernet device.
404 * VF on which to get.
406 * - (0) if successful.
407 * - (-ENODEV) if *port* invalid.
408 * - (-EINVAL) if bad parameter.
410 int rte_pmd_i40e_reset_vf_stats(uint8_t port,
414 * Set VF's max bandwidth.
416 * Per VF bandwidth limitation and per TC bandwidth limitation cannot
417 * be enabled in parallel. If per TC bandwidth is enabled, this function
421 * The port identifier of the Ethernet device.
425 * Bandwidth for this VF.
426 * The value should be an absolute bandwidth in Mbps.
427 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
428 * Not count the bytes added by physical layer.
430 * - (0) if successful.
431 * - (-ENODEV) if *port* invalid.
432 * - (-EINVAL) if bad parameter.
433 * - (-ENOTSUP) not supported by firmware.
435 int rte_pmd_i40e_set_vf_max_bw(uint8_t port,
440 * Set all the TCs' bandwidth weight on a specific VF.
442 * The bw_weight means the percentage occupied by the TC.
443 * It can be taken as the relative min bandwidth setting.
446 * The port identifier of the Ethernet device.
452 * An array of relative bandwidth weight for all the TCs.
453 * The summary of the bw_weight should be 100.
455 * - (0) if successful.
456 * - (-ENODEV) if *port* invalid.
457 * - (-EINVAL) if bad parameter.
458 * - (-ENOTSUP) not supported by firmware.
460 int rte_pmd_i40e_set_vf_tc_bw_alloc(uint8_t port,
466 * Set a specific TC's max bandwidth on a specific VF.
469 * The port identifier of the Ethernet device.
473 * Number specifying TC.
475 * Max bandwidth for this TC.
476 * The value should be an absolute bandwidth in Mbps.
477 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
478 * Not count the bytes added by physical layer.
480 * - (0) if successful.
481 * - (-ENODEV) if *port* invalid.
482 * - (-EINVAL) if bad parameter.
483 * - (-ENOTSUP) not supported by firmware.
485 int rte_pmd_i40e_set_vf_tc_max_bw(uint8_t port,
491 * Set some TCs to strict priority mode on a physical port.
494 * The port identifier of the Ethernet device.
496 * A bit map for the TCs.
498 * - (0) if successful.
499 * - (-ENODEV) if *port* invalid.
500 * - (-EINVAL) if bad parameter.
501 * - (-ENOTSUP) not supported by firmware.
503 int rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map);
506 * Load/Unload a ddp package
509 * The port identifier of the Ethernet device.
515 * Operation of package processing
517 * - (0) if successful.
518 * - (-ENODEV) if *port* invalid.
519 * - (-EINVAL) if bad parameter.
520 * - (1) if profile exists.
522 int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
524 enum rte_pmd_i40e_package_op op);
527 * rte_pmd_i40e_get_ddp_info - Get profile's info
531 * package buffer size
533 * buffer for response
535 * response buffer size
537 * type of information requested
539 * - (0) if successful.
540 * - (-ENOTSUP) if information type not supported by the profile.
541 * - (-EINVAL) if bad parameter.
543 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
544 uint8_t *info, uint32_t size,
545 enum rte_pmd_i40e_package_info type);
548 * rte_pmd_i40e_get_ddp_list - Get loaded profile list
552 * buffer for response
556 * - (0) if successful.
557 * - (-ENODEV) if *port* invalid.
558 * - (-EINVAL) if bad parameter.
560 int rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size);
563 * Update hardware defined ptype to software defined packet type
567 * pointer to port identifier of the device.
568 * @param mapping_items
569 * the base address of the mapping items array.
571 * number of mapping items.
573 * the flag indicate different ptype mapping update method.
574 * -(0) only overwrite referred PTYPE mapping,
575 * keep other PTYPEs mapping unchanged.
576 * -(!0) overwrite referred PTYPE mapping,
577 * set other PTYPEs maps to PTYPE_UNKNOWN.
579 int rte_pmd_i40e_ptype_mapping_update(
581 struct rte_pmd_i40e_ptype_mapping *mapping_items,
586 * Reset hardware defined ptype to software defined ptype
587 * mapping table to default.
590 * pointer to port identifier of the device
592 int rte_pmd_i40e_ptype_mapping_reset(uint8_t port);
595 * Get hardware defined ptype to software defined ptype
599 * pointer to port identifier of the device.
600 * @param mapping_items
601 * the base address of the array to store returned items.
603 * the size of the input array.
605 * the place to store the number of returned items.
607 * -(0) return full mapping table.
608 * -(!0) only return mapping items which packet_type != RTE_PTYPE_UNKNOWN.
610 int rte_pmd_i40e_ptype_mapping_get(
612 struct rte_pmd_i40e_ptype_mapping *mapping_items,
618 * Replace a specific or a group of software defined ptypes
622 * pointer to port identifier of the device
624 * the packet type to be replaced
626 * -(0) target represent a specific software defined ptype.
627 * -(!0) target is a mask to represent a group of software defined ptypes.
629 * the new packet type to overwrite
631 int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
636 #endif /* _PMD_I40E_H_ */