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