7ca37b19766546cc5ac06b0b27a9e9d543f1de71
[dpdk.git] / drivers / net / i40e / rte_pmd_i40e.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4
5 #ifndef _PMD_I40E_H_
6 #define _PMD_I40E_H_
7
8 /**
9  * @file rte_pmd_i40e.h
10  *
11  * i40e PMD specific functions.
12  *
13  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
14  *
15  */
16
17 #include <rte_ethdev.h>
18
19 /**
20  * Response sent back to i40e driver from user app after callback
21  */
22 enum rte_pmd_i40e_mb_event_rsp {
23         RTE_PMD_I40E_MB_EVENT_NOOP_ACK,  /**< skip mbox request and ACK */
24         RTE_PMD_I40E_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
25         RTE_PMD_I40E_MB_EVENT_PROCEED,  /**< proceed with mbox request  */
26         RTE_PMD_I40E_MB_EVENT_MAX       /**< max value of this enum */
27 };
28
29 /**
30  * Data sent to the user application when the callback is executed.
31  */
32 struct rte_pmd_i40e_mb_event_param {
33         uint16_t vfid;     /**< Virtual Function number */
34         uint16_t msg_type; /**< VF to PF message type, see virtchnl_ops */
35         uint16_t retval;   /**< return value */
36         void *msg;         /**< pointer to message */
37         uint16_t msglen;   /**< length of the message */
38 };
39
40 /**
41  * Option of package processing.
42  */
43 enum rte_pmd_i40e_package_op {
44         RTE_PMD_I40E_PKG_OP_UNDEFINED = 0,
45         RTE_PMD_I40E_PKG_OP_WR_ADD,   /**< load package and add to info list */
46         RTE_PMD_I40E_PKG_OP_WR_DEL, /**< load package and delete from info list */
47         RTE_PMD_I40E_PKG_OP_WR_ONLY, /**< load package without modifying info list */
48         RTE_PMD_I40E_PKG_OP_MAX = 32
49 };
50
51 /**
52  * Types of package information.
53  */
54 enum rte_pmd_i40e_package_info {
55         RTE_PMD_I40E_PKG_INFO_UNDEFINED = 0,
56         RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER,
57         RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE,
58         RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES,
59         RTE_PMD_I40E_PKG_INFO_GLOBAL_MAX = 1024,
60         RTE_PMD_I40E_PKG_INFO_HEADER,
61         RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
62         RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
63         RTE_PMD_I40E_PKG_INFO_PROTOCOL_NUM,
64         RTE_PMD_I40E_PKG_INFO_PROTOCOL_LIST,
65         RTE_PMD_I40E_PKG_INFO_PCTYPE_NUM,
66         RTE_PMD_I40E_PKG_INFO_PCTYPE_LIST,
67         RTE_PMD_I40E_PKG_INFO_PTYPE_NUM,
68         RTE_PMD_I40E_PKG_INFO_PTYPE_LIST,
69         RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
70 };
71
72 /**
73  *  Option types of queue region.
74  */
75 enum rte_pmd_i40e_queue_region_op {
76         RTE_PMD_I40E_RSS_QUEUE_REGION_UNDEFINED,
77         /** add queue region set */
78         RTE_PMD_I40E_RSS_QUEUE_REGION_SET,
79         /** add PF region pctype set */
80         RTE_PMD_I40E_RSS_QUEUE_REGION_FLOWTYPE_SET,
81         /** add queue region user priority set */
82         RTE_PMD_I40E_RSS_QUEUE_REGION_USER_PRIORITY_SET,
83         /**
84          * ALL configuration about queue region from up layer
85          * at first will only keep in DPDK software stored in driver,
86          * only after " FLUSH_ON ", it commit all configuration to HW.
87          * Because PMD had to set hardware configuration at a time, so
88          * it will record all up layer command at first.
89          */
90         RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_ON,
91         /**
92          * "FLUSH_OFF " is just clean all configuration about queue
93          * region just now, and restore all to DPDK i40e driver default
94          * config when start up.
95          */
96         RTE_PMD_I40E_RSS_QUEUE_REGION_ALL_FLUSH_OFF,
97         RTE_PMD_I40E_RSS_QUEUE_REGION_INFO_GET,
98         RTE_PMD_I40E_RSS_QUEUE_REGION_OP_MAX
99 };
100
101 #define RTE_PMD_I40E_DDP_NAME_SIZE     32
102 #define RTE_PMD_I40E_PCTYPE_MAX        64
103 #define RTE_PMD_I40E_REGION_MAX_NUM    8
104 #define RTE_PMD_I40E_MAX_USER_PRIORITY 8
105
106 /**
107  * Version for dynamic device personalization.
108  * Version in "major.minor.update.draft" format.
109  */
110 struct rte_pmd_i40e_ddp_version {
111         uint8_t major;
112         uint8_t minor;
113         uint8_t update;
114         uint8_t draft;
115 };
116
117 /**
118  * Device ID for dynamic device personalization.
119  */
120 struct rte_pmd_i40e_ddp_device_id {
121         uint32_t vendor_dev_id;
122         uint32_t sub_vendor_dev_id;
123 };
124
125 /**
126  * Profile information in profile info list.
127  */
128 struct rte_pmd_i40e_profile_info {
129         uint32_t track_id;
130         struct rte_pmd_i40e_ddp_version version;
131         uint8_t owner;
132         uint8_t reserved[7];
133         uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
134 };
135
136 #define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
137
138 /**
139  * Profile information list returned from HW.
140  */
141 struct rte_pmd_i40e_profile_list {
142         uint32_t p_count;
143         struct rte_pmd_i40e_profile_info p_info[1];
144 };
145
146 #define RTE_PMD_I40E_PROTO_NUM 6
147 #define RTE_PMD_I40E_PROTO_UNUSED 0xFF
148
149 /**
150  * Protocols information stored in profile
151  */
152 struct rte_pmd_i40e_proto_info {
153         uint8_t proto_id;
154         char name[RTE_PMD_I40E_DDP_NAME_SIZE];
155 };
156
157 /**
158  * Packet classification/ packet type information stored in profile
159  */
160 struct rte_pmd_i40e_ptype_info {
161         uint8_t ptype_id;
162         uint8_t protocols[RTE_PMD_I40E_PROTO_NUM];
163 };
164
165 /**
166  * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
167  * A ptype with MSB set will be regarded as a user defined ptype.
168  * Below macro help to create a user defined ptype.
169  */
170 #define RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK 0x80000000
171
172 struct rte_pmd_i40e_ptype_mapping {
173         uint16_t hw_ptype; /**< hardware defined packet type*/
174         uint32_t sw_ptype; /**< software defined packet type */
175 };
176
177 /**
178  * Queue region related information.
179  */
180 struct rte_pmd_i40e_queue_region_conf {
181         /** the region id for this configuration */
182         uint8_t region_id;
183         /** the pctype or hardware flowtype of packet,
184          * the specific index for each type has been defined
185          * in file i40e_type.h as enum i40e_filter_pctype.
186          */
187         uint8_t hw_flowtype;
188         /** the start queue index for this region */
189         uint8_t queue_start_index;
190         /** the total queue number of this queue region */
191         uint8_t queue_num;
192         /** the packet's user priority for this region */
193         uint8_t user_priority;
194 };
195
196 /* queue region info */
197 struct rte_pmd_i40e_queue_region_info {
198         /** the region id for this configuration */
199         uint8_t region_id;
200         /** the start queue index for this region */
201         uint8_t queue_start_index;
202         /** the total queue number of this queue region */
203         uint8_t queue_num;
204         /** the total number of user priority for this region */
205         uint8_t user_priority_num;
206         /** the packet's user priority for this region */
207         uint8_t user_priority[RTE_PMD_I40E_MAX_USER_PRIORITY];
208         /** the total number of flowtype for this region */
209         uint8_t flowtype_num;
210         /**
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.
214          */
215         uint8_t hw_flowtype[RTE_PMD_I40E_PCTYPE_MAX];
216 };
217
218 struct rte_pmd_i40e_queue_regions {
219         /** the total number of queue region for this port */
220         uint16_t queue_region_number;
221         struct rte_pmd_i40e_queue_region_info
222                 region[RTE_PMD_I40E_REGION_MAX_NUM];
223 };
224
225 /**
226  * Behavior will be taken if raw packet template is matched.
227  */
228 enum rte_pmd_i40e_pkt_template_behavior {
229         RTE_PMD_I40E_PKT_TEMPLATE_ACCEPT,
230         RTE_PMD_I40E_PKT_TEMPLATE_REJECT,
231         RTE_PMD_I40E_PKT_TEMPLATE_PASSTHRU,
232 };
233
234 /**
235  * Flow director report status
236  * It defines what will be reported if raw packet template is matched.
237  */
238 enum rte_pmd_i40e_pkt_template_status {
239         /** report nothing */
240         RTE_PMD_I40E_PKT_TEMPLATE_NO_REPORT_STATUS,
241         /** only report FD ID */
242         RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID,
243         /** report FD ID and 4 flex bytes */
244         RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID_FLEX_4,
245         /** report 8 flex bytes */
246         RTE_PMD_I40E_PKT_TEMPLATE_REPORT_FLEX_8,
247 };
248
249 /**
250  * A structure used to define an action when raw packet template is matched.
251  */
252 struct rte_pmd_i40e_pkt_template_action {
253         /** queue assigned to if raw packet template match */
254         uint16_t rx_queue;
255         /** behavior will be taken */
256         enum rte_pmd_i40e_pkt_template_behavior behavior;
257         /** status report option */
258         enum rte_pmd_i40e_pkt_template_status report_status;
259         /**
260          * If report_status is RTE_PMD_I40E_PKT_TEMPLATE_REPORT_ID_FLEX_4 or
261          * RTE_PMD_I40E_PKT_TEMPLATE_REPORT_FLEX_8, flex_off specifies
262          * where the reported flex bytes start from in flexible payload.
263          */
264         uint8_t flex_off;
265 };
266
267 /**
268  * A structure used to define the input for raw packet template.
269  */
270 struct rte_pmd_i40e_pkt_template_input {
271         /** the pctype used for raw packet template */
272         uint16_t pctype;
273         /** the buffer conatining raw packet template */
274         void *packet;
275         /** the length of buffer with raw packet template */
276         uint32_t length;
277 };
278
279 /**
280  * A structure used to define the configuration parameters
281  * for raw packet template.
282  */
283 struct rte_pmd_i40e_pkt_template_conf {
284         /** the input for raw packet template. */
285         struct rte_pmd_i40e_pkt_template_input input;
286         /** the action to be taken when raw packet template is matched */
287         struct rte_pmd_i40e_pkt_template_action action;
288         /** ID, an unique software index for the raw packet template filter */
289         uint32_t soft_id;
290 };
291
292 /**
293  * Add or remove raw packet template filter to Flow Director.
294  *
295  * @param port
296  *   The port identifier of the Ethernet device.
297  * @param conf
298  *   Specifies configuration parameters of raw packet template filter.
299  * @param add
300  *   Speicifes an action to be taken - add or remove raw packet template filter.
301  * @return
302  *   - (0) if successful.
303  *   - (-ENODEV) if *port* invalid.
304  *   - (-EINVAL) if *conf* invalid.
305  *   - (-ENOTSUP) not supported by firmware.
306  */
307 int rte_pmd_i40e_flow_add_del_packet_template(
308                         uint16_t port,
309                         const struct rte_pmd_i40e_pkt_template_conf *conf,
310                         uint8_t add);
311
312 /**
313  * Notify VF when PF link status changes.
314  *
315  * @param port
316  *   The port identifier of the Ethernet device.
317  * @param vf
318  *   VF id.
319  * @return
320  *   - (0) if successful.
321  *   - (-ENODEV) if *port* invalid.
322  *   - (-EINVAL) if *vf* invalid.
323  */
324 int rte_pmd_i40e_ping_vfs(uint16_t port, uint16_t vf);
325
326 /**
327  * Enable/Disable VF MAC anti spoofing.
328  *
329  * @param port
330  *    The port identifier of the Ethernet device.
331  * @param vf_id
332  *    VF on which to set MAC anti spoofing.
333  * @param on
334  *    1 - Enable VFs MAC anti spoofing.
335  *    0 - Disable VFs MAC anti spoofing.
336  * @return
337  *   - (0) if successful.
338  *   - (-ENODEV) if *port* invalid.
339  *   - (-EINVAL) if bad parameter.
340  */
341 int rte_pmd_i40e_set_vf_mac_anti_spoof(uint16_t port,
342                                        uint16_t vf_id,
343                                        uint8_t on);
344
345 /**
346  * Enable/Disable VF VLAN anti spoofing.
347  *
348  * @param port
349  *    The port identifier of the Ethernet device.
350  * @param vf_id
351  *    VF on which to set VLAN anti spoofing.
352  * @param on
353  *    1 - Enable VFs VLAN anti spoofing.
354  *    0 - Disable VFs VLAN anti spoofing.
355  * @return
356  *   - (0) if successful.
357  *   - (-ENODEV) if *port* invalid.
358  *   - (-EINVAL) if bad parameter.
359  */
360 int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint16_t port,
361                                         uint16_t vf_id,
362                                         uint8_t on);
363
364 /**
365  * Enable/Disable TX loopback on all the PF and VFs.
366  *
367  * @param port
368  *    The port identifier of the Ethernet device.
369  * @param on
370  *    1 - Enable TX loopback.
371  *    0 - Disable TX loopback.
372  * @return
373  *   - (0) if successful.
374  *   - (-ENODEV) if *port* invalid.
375  *   - (-EINVAL) if bad parameter.
376  */
377 int rte_pmd_i40e_set_tx_loopback(uint16_t port,
378                                  uint8_t on);
379
380 /**
381  * Enable/Disable VF unicast promiscuous mode.
382  *
383  * @param port
384  *    The port identifier of the Ethernet device.
385  * @param vf_id
386  *    VF on which to set.
387  * @param on
388  *    1 - Enable.
389  *    0 - Disable.
390  * @return
391  *   - (0) if successful.
392  *   - (-ENODEV) if *port* invalid.
393  *   - (-EINVAL) if bad parameter.
394  */
395 int rte_pmd_i40e_set_vf_unicast_promisc(uint16_t port,
396                                         uint16_t vf_id,
397                                         uint8_t on);
398
399 /**
400  * Enable/Disable VF multicast promiscuous mode.
401  *
402  * @param port
403  *    The port identifier of the Ethernet device.
404  * @param vf_id
405  *    VF on which to set.
406  * @param on
407  *    1 - Enable.
408  *    0 - Disable.
409  * @return
410  *   - (0) if successful.
411  *   - (-ENODEV) if *port* invalid.
412  *   - (-EINVAL) if bad parameter.
413  */
414 int rte_pmd_i40e_set_vf_multicast_promisc(uint16_t port,
415                                           uint16_t vf_id,
416                                           uint8_t on);
417
418 /**
419  * Set the VF MAC address.
420  *
421  * PF should set MAC address before VF initialized, if PF sets the MAC
422  * address after VF initialized, new MAC address won't be effective until
423  * VF reinitialize.
424  *
425  * This will remove all existing MAC filters.
426  *
427  * @param port
428  *   The port identifier of the Ethernet device.
429  * @param vf_id
430  *   VF id.
431  * @param mac_addr
432  *   VF MAC address.
433  * @return
434  *   - (0) if successful.
435  *   - (-ENODEV) if *port* invalid.
436  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
437  */
438 int rte_pmd_i40e_set_vf_mac_addr(uint16_t port, uint16_t vf_id,
439                                  struct ether_addr *mac_addr);
440
441 /**
442  * Enable/Disable vf vlan strip for all queues in a pool
443  *
444  * @param port
445  *    The port identifier of the Ethernet device.
446  * @param vf
447  *    ID specifying VF.
448  * @param on
449  *    1 - Enable VF's vlan strip on RX queues.
450  *    0 - Disable VF's vlan strip on RX queues.
451  *
452  * @return
453  *   - (0) if successful.
454  *   - (-ENODEV) if *port* invalid.
455  *   - (-EINVAL) if bad parameter.
456  */
457 int
458 rte_pmd_i40e_set_vf_vlan_stripq(uint16_t port, uint16_t vf, uint8_t on);
459
460 /**
461  * Enable/Disable vf vlan insert
462  *
463  * @param port
464  *    The port identifier of the Ethernet device.
465  * @param vf_id
466  *    ID specifying VF.
467  * @param vlan_id
468  *    0 - Disable VF's vlan insert.
469  *    n - Enable; n is inserted as the vlan id.
470  *
471  * @return
472  *   - (0) if successful.
473  *   - (-ENODEV) if *port* invalid.
474  *   - (-EINVAL) if bad parameter.
475  */
476 int rte_pmd_i40e_set_vf_vlan_insert(uint16_t port, uint16_t vf_id,
477                                     uint16_t vlan_id);
478
479 /**
480  * Enable/Disable vf broadcast mode
481  *
482  * @param port
483  *    The port identifier of the Ethernet device.
484  * @param vf_id
485  *    ID specifying VF.
486  * @param on
487  *    0 - Disable broadcast.
488  *    1 - Enable broadcast.
489  *
490  * @return
491  *   - (0) if successful.
492  *   - (-ENODEV) if *port* invalid.
493  *   - (-EINVAL) if bad parameter.
494  */
495 int rte_pmd_i40e_set_vf_broadcast(uint16_t port, uint16_t vf_id,
496                                   uint8_t on);
497
498 /**
499  * Enable/Disable vf vlan tag
500  *
501  * @param port
502  *    The port identifier of the Ethernet device.
503  * @param vf_id
504  *    ID specifying VF.
505  * @param on
506  *    0 - Disable VF's vlan tag.
507  *    n - Enable VF's vlan tag.
508  *
509  * @return
510  *   - (0) if successful.
511  *   - (-ENODEV) if *port* invalid.
512  *   - (-EINVAL) if bad parameter.
513  */
514 int rte_pmd_i40e_set_vf_vlan_tag(uint16_t port, uint16_t vf_id, uint8_t on);
515
516 /**
517  * Enable/Disable VF VLAN filter
518  *
519  * @param port
520  *    The port identifier of the Ethernet device.
521  * @param vlan_id
522  *    ID specifying VLAN
523  * @param vf_mask
524  *    Mask to filter VF's
525  * @param on
526  *    0 - Disable VF's VLAN filter.
527  *    1 - Enable VF's VLAN filter.
528  *
529  * @return
530  *   - (0) if successful.
531  *   - (-ENODEV) if *port* invalid.
532  *   - (-EINVAL) if bad parameter.
533  *   - (-ENOTSUP) not supported by firmware.
534  */
535 int rte_pmd_i40e_set_vf_vlan_filter(uint16_t port, uint16_t vlan_id,
536                                     uint64_t vf_mask, uint8_t on);
537
538 /**
539  * Get VF's statistics
540  *
541  * @param port
542  *    The port identifier of the Ethernet device.
543  * @param vf_id
544  *    VF on which to get.
545  * @param stats
546  *    A pointer to a structure of type *rte_eth_stats* to be filled with
547  *    the values of device counters for the following set of statistics:
548  *   - *ipackets* with the total of successfully received packets.
549  *   - *opackets* with the total of successfully transmitted packets.
550  *   - *ibytes*   with the total of successfully received bytes.
551  *   - *obytes*   with the total of successfully transmitted bytes.
552  *   - *ierrors*  with the total of erroneous received packets.
553  *   - *oerrors*  with the total of failed transmitted packets.
554  * @return
555  *   - (0) if successful.
556  *   - (-ENODEV) if *port* invalid.
557  *   - (-EINVAL) if bad parameter.
558  */
559
560 int rte_pmd_i40e_get_vf_stats(uint16_t port,
561                               uint16_t vf_id,
562                               struct rte_eth_stats *stats);
563
564 /**
565  * Clear VF's statistics
566  *
567  * @param port
568  *    The port identifier of the Ethernet device.
569  * @param vf_id
570  *    VF on which to get.
571  * @return
572  *   - (0) if successful.
573  *   - (-ENODEV) if *port* invalid.
574  *   - (-EINVAL) if bad parameter.
575  */
576 int rte_pmd_i40e_reset_vf_stats(uint16_t port,
577                                 uint16_t vf_id);
578
579 /**
580  * Set VF's max bandwidth.
581  *
582  * Per VF bandwidth limitation and per TC bandwidth limitation cannot
583  * be enabled in parallel. If per TC bandwidth is enabled, this function
584  * will disable it.
585  *
586  * @param port
587  *    The port identifier of the Ethernet device.
588  * @param vf_id
589  *    ID specifying VF.
590  * @param bw
591  *    Bandwidth for this VF.
592  *    The value should be an absolute bandwidth in Mbps.
593  *    The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
594  *    Not count the bytes added by physical layer.
595  * @return
596  *   - (0) if successful.
597  *   - (-ENODEV) if *port* invalid.
598  *   - (-EINVAL) if bad parameter.
599  *   - (-ENOTSUP) not supported by firmware.
600  */
601 int rte_pmd_i40e_set_vf_max_bw(uint16_t port,
602                                uint16_t vf_id,
603                                uint32_t bw);
604
605 /**
606  * Set all the TCs' bandwidth weight on a specific VF.
607  *
608  * The bw_weight means the percentage occupied by the TC.
609  * It can be taken as the relative min bandwidth setting.
610  *
611  * @param port
612  *    The port identifier of the Ethernet device.
613  * @param vf_id
614  *    ID specifying VF.
615  * @param tc_num
616  *    Number of TCs.
617  * @param bw_weight
618  *    An array of relative bandwidth weight for all the TCs.
619  *    The summary of the bw_weight should be 100.
620  * @return
621  *   - (0) if successful.
622  *   - (-ENODEV) if *port* invalid.
623  *   - (-EINVAL) if bad parameter.
624  *   - (-ENOTSUP) not supported by firmware.
625  */
626 int rte_pmd_i40e_set_vf_tc_bw_alloc(uint16_t port,
627                                     uint16_t vf_id,
628                                     uint8_t tc_num,
629                                     uint8_t *bw_weight);
630
631 /**
632  * Set a specific TC's max bandwidth on a specific VF.
633  *
634  * @param port
635  *    The port identifier of the Ethernet device.
636  * @param vf_id
637  *    ID specifying VF.
638  * @param tc_no
639  *    Number specifying TC.
640  * @param bw
641  *    Max bandwidth for this TC.
642  *    The value should be an absolute bandwidth in Mbps.
643  *    The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
644  *    Not count the bytes added by physical layer.
645  * @return
646  *   - (0) if successful.
647  *   - (-ENODEV) if *port* invalid.
648  *   - (-EINVAL) if bad parameter.
649  *   - (-ENOTSUP) not supported by firmware.
650  */
651 int rte_pmd_i40e_set_vf_tc_max_bw(uint16_t port,
652                                   uint16_t vf_id,
653                                   uint8_t tc_no,
654                                   uint32_t bw);
655
656 /**
657  * Set some TCs to strict priority mode on a physical port.
658  *
659  * @param port
660  *    The port identifier of the Ethernet device.
661  * @param tc_map
662  *    A bit map for the TCs.
663  * @return
664  *   - (0) if successful.
665  *   - (-ENODEV) if *port* invalid.
666  *   - (-EINVAL) if bad parameter.
667  *   - (-ENOTSUP) not supported by firmware.
668  */
669 int rte_pmd_i40e_set_tc_strict_prio(uint16_t port, uint8_t tc_map);
670
671 /**
672  * Load/Unload a ddp package
673  *
674  * @param port
675  *    The port identifier of the Ethernet device.
676  * @param buff
677  *    buffer of package.
678  * @param size
679  *    size of buffer.
680  * @param op
681  *   Operation of package processing
682  * @return
683  *   - (0) if successful.
684  *   - (-ENODEV) if *port* invalid.
685  *   - (-EINVAL) if bad parameter.
686  *   - (-EEXIST) if profile exists.
687  *   - (-EACCES) if profile does not exist.
688  *   - (-ENOTSUP) if operation not supported.
689  */
690 int rte_pmd_i40e_process_ddp_package(uint16_t port, uint8_t *buff,
691                                      uint32_t size,
692                                      enum rte_pmd_i40e_package_op op);
693
694 /**
695  * rte_pmd_i40e_get_ddp_info - Get profile's info
696  * @param pkg
697  *    buffer of package.
698  * @param pkg_size
699  *    package buffer size
700  * @param info
701  *    buffer for response
702  * @param size
703  *    response buffer size
704  * @param type
705  *    type of information requested
706  * @return
707  *   - (0) if successful.
708  *   - (-ENOTSUP) if information type not supported by the profile.
709  *   - (-EINVAL) if bad parameter.
710  */
711 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
712                                      uint8_t *info, uint32_t size,
713                                      enum rte_pmd_i40e_package_info type);
714
715 /**
716  * rte_pmd_i40e_get_ddp_list - Get loaded profile list
717  * @param port
718  *    port id
719  * @param buff
720  *    buffer for response
721  * @param size
722  *    buffer size
723  * @return
724  *   - (0) if successful.
725  *   - (-ENODEV) if *port* invalid.
726  *   - (-EINVAL) if bad parameter.
727  */
728 int rte_pmd_i40e_get_ddp_list(uint16_t port, uint8_t *buff, uint32_t size);
729
730 /**
731  * Update hardware defined ptype to software defined packet type
732  * mapping table.
733  *
734  * @param port
735  *    pointer to port identifier of the device.
736  * @param mapping_items
737  *    the base address of the mapping items array.
738  * @param count
739  *    number of mapping items.
740  * @param exclusive
741  *    the flag indicate different ptype mapping update method.
742  *    -(0) only overwrite referred PTYPE mapping,
743  *      keep other PTYPEs mapping unchanged.
744  *    -(!0) overwrite referred PTYPE mapping,
745  *      set other PTYPEs maps to PTYPE_UNKNOWN.
746  */
747 int rte_pmd_i40e_ptype_mapping_update(
748                         uint16_t port,
749                         struct rte_pmd_i40e_ptype_mapping *mapping_items,
750                         uint16_t count,
751                         uint8_t exclusive);
752
753 /**
754  * Reset hardware defined ptype to software defined ptype
755  * mapping table to default.
756  *
757  * @param port
758  *    pointer to port identifier of the device
759  */
760 int rte_pmd_i40e_ptype_mapping_reset(uint16_t port);
761
762 /**
763  * Get hardware defined ptype to software defined ptype
764  * mapping items.
765  *
766  * @param port
767  *    pointer to port identifier of the device.
768  * @param mapping_items
769  *    the base address of the array to store returned items.
770  * @param size
771  *    the size of the input array.
772  * @param count
773  *    the place to store the number of returned items.
774  * @param valid_only
775  *    -(0) return full mapping table.
776  *    -(!0) only return mapping items which packet_type != RTE_PTYPE_UNKNOWN.
777  */
778 int rte_pmd_i40e_ptype_mapping_get(
779                         uint16_t port,
780                         struct rte_pmd_i40e_ptype_mapping *mapping_items,
781                         uint16_t size,
782                         uint16_t *count,
783                         uint8_t valid_only);
784
785 /**
786  * Replace a specific or a group of software defined ptypes
787  * with a new one
788  *
789  * @param port
790  *    pointer to port identifier of the device
791  * @param target
792  *    the packet type to be replaced
793  * @param mask
794  *    -(0) target represent a specific software defined ptype.
795  *    -(!0) target is a mask to represent a group of software defined ptypes.
796  * @param pkt_type
797  *    the new packet type to overwrite
798  */
799 int rte_pmd_i40e_ptype_mapping_replace(uint16_t port,
800                                        uint32_t target,
801                                        uint8_t mask,
802                                        uint32_t pkt_type);
803
804 /**
805  * Add a VF MAC address.
806  *
807  * Add more MAC address for VF. The existing MAC addresses
808  * are still effective.
809  *
810  * @param port
811  *   The port identifier of the Ethernet device.
812  * @param vf_id
813  *   VF id.
814  * @param mac_addr
815  *   VF MAC address.
816  * @return
817  *   - (0) if successful.
818  *   - (-ENODEV) if *port* invalid.
819  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
820  */
821 int rte_pmd_i40e_add_vf_mac_addr(uint16_t port, uint16_t vf_id,
822                                  struct ether_addr *mac_addr);
823
824 #define RTE_PMD_I40E_PCTYPE_MAX         64
825 #define RTE_PMD_I40E_FLOW_TYPE_MAX      64
826
827 struct rte_pmd_i40e_flow_type_mapping {
828         uint16_t flow_type; /**< software defined flow type*/
829         uint64_t pctype;    /**< hardware defined pctype */
830 };
831
832 /**
833  * Update hardware defined pctype to software defined flow type
834  * mapping table.
835  *
836  * @param port
837  *    pointer to port identifier of the device.
838  * @param mapping_items
839  *    the base address of the mapping items array.
840  * @param count
841  *    number of mapping items.
842  * @param exclusive
843  *    the flag indicate different pctype mapping update method.
844  *    -(0) only overwrite referred PCTYPE mapping,
845  *      keep other PCTYPEs mapping unchanged.
846  *    -(!0) overwrite referred PCTYPE mapping,
847  *      set other PCTYPEs maps to PCTYPE_INVALID.
848  */
849 int rte_pmd_i40e_flow_type_mapping_update(
850                         uint16_t port,
851                         struct rte_pmd_i40e_flow_type_mapping *mapping_items,
852                         uint16_t count,
853                         uint8_t exclusive);
854
855 /**
856  * Get software defined flow type to hardware defined pctype
857  * mapping items.
858  *
859  * @param port
860  *    pointer to port identifier of the device.
861  * @param mapping_items
862  *    the base address of the array to store returned items.
863  *    array should be allocated by caller with minimum size of
864  *    RTE_PMD_I40E_FLOW_TYPE_MAX items
865  */
866 int rte_pmd_i40e_flow_type_mapping_get(
867                         uint16_t port,
868                         struct rte_pmd_i40e_flow_type_mapping *mapping_items);
869
870 /**
871  * Reset hardware defined pctype to software defined flow type
872  * mapping table to default.
873  *
874  * @param port
875  *    pointer to port identifier of the device
876  */
877 int rte_pmd_i40e_flow_type_mapping_reset(uint16_t port);
878
879 /**
880  * On the PF, find VF index based on VF MAC address
881  *
882  * @param port
883  *    pointer to port identifier of the device
884  * @param vf_mac
885  *    the mac address of the vf to determine index of
886  * @return
887  *    The index of vfid If successful.
888  *    -EINVAL: vf mac address does not exist for this port
889  *    -ENOTSUP: i40e not supported for this port.
890  */
891 int rte_pmd_i40e_query_vfid_by_mac(uint16_t port,
892                                         const struct ether_addr *vf_mac);
893
894 /**
895  * Do RSS queue region configuration for that port as
896  * the command option type
897  *
898  * @param port_id
899  *    The port identifier of the Ethernet device.
900  * @param op_type
901  *    Queue region operation type
902  * @param arg
903  *    Queue region operation type specific data
904  */
905 int rte_pmd_i40e_rss_queue_region_conf(uint16_t port_id,
906                         enum rte_pmd_i40e_queue_region_op op_type, void *arg);
907
908 #endif /* _PMD_I40E_H_ */