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