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