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