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_MAX = 0xFFFFFFFF
94 #define RTE_PMD_I40E_DDP_NAME_SIZE 32
97 * Version for dynamic device personalization.
98 * Version in "major.minor.update.draft" format.
100 struct rte_pmd_i40e_ddp_version {
108 * Device ID for dynamic device personalization.
110 struct rte_pmd_i40e_ddp_device_id {
111 uint32_t vendor_dev_id;
112 uint32_t sub_vendor_dev_id;
116 * Profile information in profile info list.
118 struct rte_pmd_i40e_profile_info {
120 struct rte_pmd_i40e_ddp_version version;
123 uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
126 #define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
129 * Profile information list returned from HW.
131 struct rte_pmd_i40e_profile_list {
133 struct rte_pmd_i40e_profile_info p_info[1];
137 * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
138 * A ptype with MSB set will be regarded as a user defined ptype.
139 * Below macro help to create a user defined ptype.
141 #define RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK 0x80000000
143 struct rte_pmd_i40e_ptype_mapping {
144 uint16_t hw_ptype; /**< hardware defined packet type*/
145 uint32_t sw_ptype; /**< software defined packet type */
149 * Notify VF when PF link status changes.
152 * The port identifier of the Ethernet device.
156 * - (0) if successful.
157 * - (-ENODEV) if *port* invalid.
158 * - (-EINVAL) if *vf* invalid.
160 int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
163 * Enable/Disable VF MAC anti spoofing.
166 * The port identifier of the Ethernet device.
168 * VF on which to set MAC anti spoofing.
170 * 1 - Enable VFs MAC anti spoofing.
171 * 0 - Disable VFs MAC anti spoofing.
173 * - (0) if successful.
174 * - (-ENODEV) if *port* invalid.
175 * - (-EINVAL) if bad parameter.
177 int rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port,
182 * Enable/Disable VF VLAN anti spoofing.
185 * The port identifier of the Ethernet device.
187 * VF on which to set VLAN anti spoofing.
189 * 1 - Enable VFs VLAN anti spoofing.
190 * 0 - Disable VFs VLAN anti spoofing.
192 * - (0) if successful.
193 * - (-ENODEV) if *port* invalid.
194 * - (-EINVAL) if bad parameter.
196 int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port,
201 * Enable/Disable TX loopback on all the PF and VFs.
204 * The port identifier of the Ethernet device.
206 * 1 - Enable TX loopback.
207 * 0 - Disable TX loopback.
209 * - (0) if successful.
210 * - (-ENODEV) if *port* invalid.
211 * - (-EINVAL) if bad parameter.
213 int rte_pmd_i40e_set_tx_loopback(uint8_t port,
217 * Enable/Disable VF unicast promiscuous mode.
220 * The port identifier of the Ethernet device.
222 * VF on which to set.
227 * - (0) if successful.
228 * - (-ENODEV) if *port* invalid.
229 * - (-EINVAL) if bad parameter.
231 int rte_pmd_i40e_set_vf_unicast_promisc(uint8_t port,
236 * Enable/Disable VF multicast promiscuous mode.
239 * The port identifier of the Ethernet device.
241 * VF on which to set.
246 * - (0) if successful.
247 * - (-ENODEV) if *port* invalid.
248 * - (-EINVAL) if bad parameter.
250 int rte_pmd_i40e_set_vf_multicast_promisc(uint8_t port,
255 * Set the VF MAC address.
257 * PF should set MAC address before VF initialized, if PF sets the MAC
258 * address after VF initialized, new MAC address won't be effective until
261 * This will remove all existing MAC filters.
264 * The port identifier of the Ethernet device.
270 * - (0) if successful.
271 * - (-ENODEV) if *port* invalid.
272 * - (-EINVAL) if *vf* or *mac_addr* is invalid.
274 int rte_pmd_i40e_set_vf_mac_addr(uint8_t port, uint16_t vf_id,
275 struct ether_addr *mac_addr);
278 * Enable/Disable vf vlan strip for all queues in a pool
281 * The port identifier of the Ethernet device.
285 * 1 - Enable VF's vlan strip on RX queues.
286 * 0 - Disable VF's vlan strip on RX queues.
289 * - (0) if successful.
290 * - (-ENODEV) if *port* invalid.
291 * - (-EINVAL) if bad parameter.
294 rte_pmd_i40e_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
297 * Enable/Disable vf vlan insert
300 * The port identifier of the Ethernet device.
304 * 0 - Disable VF's vlan insert.
305 * n - Enable; n is inserted as the vlan id.
308 * - (0) if successful.
309 * - (-ENODEV) if *port* invalid.
310 * - (-EINVAL) if bad parameter.
312 int rte_pmd_i40e_set_vf_vlan_insert(uint8_t port, uint16_t vf_id,
316 * Enable/Disable vf broadcast mode
319 * The port identifier of the Ethernet device.
323 * 0 - Disable broadcast.
324 * 1 - Enable broadcast.
327 * - (0) if successful.
328 * - (-ENODEV) if *port* invalid.
329 * - (-EINVAL) if bad parameter.
331 int rte_pmd_i40e_set_vf_broadcast(uint8_t port, uint16_t vf_id,
335 * Enable/Disable vf vlan tag
338 * The port identifier of the Ethernet device.
342 * 0 - Disable VF's vlan tag.
343 * n - Enable VF's vlan tag.
346 * - (0) if successful.
347 * - (-ENODEV) if *port* invalid.
348 * - (-EINVAL) if bad parameter.
350 int rte_pmd_i40e_set_vf_vlan_tag(uint8_t port, uint16_t vf_id, uint8_t on);
353 * Enable/Disable VF VLAN filter
356 * The port identifier of the Ethernet device.
360 * Mask to filter VF's
362 * 0 - Disable VF's VLAN filter.
363 * 1 - Enable VF's VLAN filter.
366 * - (0) if successful.
367 * - (-ENODEV) if *port* invalid.
368 * - (-EINVAL) if bad parameter.
369 * - (-ENOTSUP) not supported by firmware.
371 int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
372 uint64_t vf_mask, uint8_t on);
375 * Get VF's statistics
378 * The port identifier of the Ethernet device.
380 * VF on which to get.
382 * A pointer to a structure of type *rte_eth_stats* to be filled with
383 * the values of device counters for the following set of statistics:
384 * - *ipackets* with the total of successfully received packets.
385 * - *opackets* with the total of successfully transmitted packets.
386 * - *ibytes* with the total of successfully received bytes.
387 * - *obytes* with the total of successfully transmitted bytes.
388 * - *ierrors* with the total of erroneous received packets.
389 * - *oerrors* with the total of failed transmitted packets.
391 * - (0) if successful.
392 * - (-ENODEV) if *port* invalid.
393 * - (-EINVAL) if bad parameter.
396 int rte_pmd_i40e_get_vf_stats(uint8_t port,
398 struct rte_eth_stats *stats);
401 * Clear VF's statistics
404 * The port identifier of the Ethernet device.
406 * VF on which to get.
408 * - (0) if successful.
409 * - (-ENODEV) if *port* invalid.
410 * - (-EINVAL) if bad parameter.
412 int rte_pmd_i40e_reset_vf_stats(uint8_t port,
416 * Set VF's max bandwidth.
418 * Per VF bandwidth limitation and per TC bandwidth limitation cannot
419 * be enabled in parallel. If per TC bandwidth is enabled, this function
423 * The port identifier of the Ethernet device.
427 * Bandwidth for this VF.
428 * The value should be an absolute bandwidth in Mbps.
429 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
430 * Not count the bytes added by physical layer.
432 * - (0) if successful.
433 * - (-ENODEV) if *port* invalid.
434 * - (-EINVAL) if bad parameter.
435 * - (-ENOTSUP) not supported by firmware.
437 int rte_pmd_i40e_set_vf_max_bw(uint8_t port,
442 * Set all the TCs' bandwidth weight on a specific VF.
444 * The bw_weight means the percentage occupied by the TC.
445 * It can be taken as the relative min bandwidth setting.
448 * The port identifier of the Ethernet device.
454 * An array of relative bandwidth weight for all the TCs.
455 * The summary of the bw_weight should be 100.
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_tc_bw_alloc(uint8_t port,
468 * Set a specific TC's max bandwidth on a specific VF.
471 * The port identifier of the Ethernet device.
475 * Number specifying TC.
477 * Max bandwidth for this TC.
478 * The value should be an absolute bandwidth in Mbps.
479 * The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
480 * Not count the bytes added by physical layer.
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_max_bw(uint8_t port,
493 * Set some TCs to strict priority mode on a physical port.
496 * The port identifier of the Ethernet device.
498 * A bit map for the TCs.
500 * - (0) if successful.
501 * - (-ENODEV) if *port* invalid.
502 * - (-EINVAL) if bad parameter.
503 * - (-ENOTSUP) not supported by firmware.
505 int rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map);
508 * Load/Unload a ddp package
511 * The port identifier of the Ethernet device.
517 * Operation of package processing
519 * - (0) if successful.
520 * - (-ENODEV) if *port* invalid.
521 * - (-EINVAL) if bad parameter.
522 * - (-EEXIST) if profile exists.
523 * - (-EACCES) if profile does not exist.
524 * - (-ENOTSUP) if operation not supported.
526 int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
528 enum rte_pmd_i40e_package_op op);
531 * rte_pmd_i40e_get_ddp_info - Get profile's info
535 * package buffer size
537 * buffer for response
539 * response buffer size
541 * type of information requested
543 * - (0) if successful.
544 * - (-ENOTSUP) if information type not supported by the profile.
545 * - (-EINVAL) if bad parameter.
547 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
548 uint8_t *info, uint32_t size,
549 enum rte_pmd_i40e_package_info type);
552 * rte_pmd_i40e_get_ddp_list - Get loaded profile list
556 * buffer for response
560 * - (0) if successful.
561 * - (-ENODEV) if *port* invalid.
562 * - (-EINVAL) if bad parameter.
564 int rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size);
567 * Update hardware defined ptype to software defined packet type
571 * pointer to port identifier of the device.
572 * @param mapping_items
573 * the base address of the mapping items array.
575 * number of mapping items.
577 * the flag indicate different ptype mapping update method.
578 * -(0) only overwrite referred PTYPE mapping,
579 * keep other PTYPEs mapping unchanged.
580 * -(!0) overwrite referred PTYPE mapping,
581 * set other PTYPEs maps to PTYPE_UNKNOWN.
583 int rte_pmd_i40e_ptype_mapping_update(
585 struct rte_pmd_i40e_ptype_mapping *mapping_items,
590 * Reset hardware defined ptype to software defined ptype
591 * mapping table to default.
594 * pointer to port identifier of the device
596 int rte_pmd_i40e_ptype_mapping_reset(uint8_t port);
599 * Get hardware defined ptype to software defined ptype
603 * pointer to port identifier of the device.
604 * @param mapping_items
605 * the base address of the array to store returned items.
607 * the size of the input array.
609 * the place to store the number of returned items.
611 * -(0) return full mapping table.
612 * -(!0) only return mapping items which packet_type != RTE_PTYPE_UNKNOWN.
614 int rte_pmd_i40e_ptype_mapping_get(
616 struct rte_pmd_i40e_ptype_mapping *mapping_items,
622 * Replace a specific or a group of software defined ptypes
626 * pointer to port identifier of the device
628 * the packet type to be replaced
630 * -(0) target represent a specific software defined ptype.
631 * -(!0) target is a mask to represent a group of software defined ptypes.
633 * the new packet type to overwrite
635 int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
641 * Add a VF MAC address.
643 * Add more MAC address for VF. The existing MAC addresses
644 * are still effective.
647 * The port identifier of the Ethernet device.
653 * - (0) if successful.
654 * - (-ENODEV) if *port* invalid.
655 * - (-EINVAL) if *vf* or *mac_addr* is invalid.
657 int rte_pmd_i40e_add_vf_mac_addr(uint8_t port, uint16_t vf_id,
658 struct ether_addr *mac_addr);
660 #endif /* _PMD_I40E_H_ */