net/i40e/base: use new virtchnl header file
[dpdk.git] / drivers / net / i40e / rte_pmd_i40e.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright (c) 2017 Intel Corporation. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *     * Redistributions of source code must retain the above copyright
11  *       notice, this list of conditions and the following disclaimer.
12  *     * Redistributions in binary form must reproduce the above copyright
13  *       notice, this list of conditions and the following disclaimer in
14  *       the documentation and/or other materials provided with the
15  *       distribution.
16  *     * Neither the name of Intel Corporation nor the names of its
17  *       contributors may be used to endorse or promote products derived
18  *       from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef _PMD_I40E_H_
34 #define _PMD_I40E_H_
35
36 /**
37  * @file rte_pmd_i40e.h
38  *
39  * i40e PMD specific functions.
40  *
41  * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
42  *
43  */
44
45 #include <rte_ethdev.h>
46
47 /**
48  * Response sent back to i40e driver from user app after callback
49  */
50 enum rte_pmd_i40e_mb_event_rsp {
51         RTE_PMD_I40E_MB_EVENT_NOOP_ACK,  /**< skip mbox request and ACK */
52         RTE_PMD_I40E_MB_EVENT_NOOP_NACK, /**< skip mbox request and NACK */
53         RTE_PMD_I40E_MB_EVENT_PROCEED,  /**< proceed with mbox request  */
54         RTE_PMD_I40E_MB_EVENT_MAX       /**< max value of this enum */
55 };
56
57 /**
58  * Data sent to the user application when the callback is executed.
59  */
60 struct rte_pmd_i40e_mb_event_param {
61         uint16_t vfid;     /**< Virtual Function number */
62         uint16_t msg_type; /**< VF to PF message type, see virtchnl_ops */
63         uint16_t retval;   /**< return value */
64         void *msg;         /**< pointer to message */
65         uint16_t msglen;   /**< length of the message */
66 };
67
68 /**
69  * Option of package processing.
70  */
71 enum rte_pmd_i40e_package_op {
72         RTE_PMD_I40E_PKG_OP_UNDEFINED = 0,
73         RTE_PMD_I40E_PKG_OP_WR_ADD,   /**< load package and add to info list */
74         RTE_PMD_I40E_PKG_OP_MAX = 32
75 };
76
77 /**
78  * Types of package information.
79  */
80 enum rte_pmd_i40e_package_info {
81         RTE_PMD_I40E_PKG_INFO_UNDEFINED = 0,
82         RTE_PMD_I40E_PKG_INFO_GLOBAL_HEADER,
83         RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES_SIZE,
84         RTE_PMD_I40E_PKG_INFO_GLOBAL_NOTES,
85         RTE_PMD_I40E_PKG_INFO_GLOBAL_MAX = 1024,
86         RTE_PMD_I40E_PKG_INFO_HEADER,
87         RTE_PMD_I40E_PKG_INFO_DEVID_NUM,
88         RTE_PMD_I40E_PKG_INFO_DEVID_LIST,
89         RTE_PMD_I40E_PKG_INFO_MAX = 0xFFFFFFFF
90 };
91
92 #define RTE_PMD_I40E_DDP_NAME_SIZE 32
93
94 /**
95  * Version for dynamic device personalization.
96  * Version in "major.minor.update.draft" format.
97  */
98 struct rte_pmd_i40e_ddp_version {
99         uint8_t major;
100         uint8_t minor;
101         uint8_t update;
102         uint8_t draft;
103 };
104
105 /**
106  * Device ID for dynamic device personalization.
107  */
108 struct rte_pmd_i40e_ddp_device_id {
109         uint32_t vendor_dev_id;
110         uint32_t sub_vendor_dev_id;
111 };
112
113 /**
114  * Profile information in profile info list.
115  */
116 struct rte_pmd_i40e_profile_info {
117         uint32_t track_id;
118         struct rte_pmd_i40e_ddp_version version;
119         uint8_t owner;
120         uint8_t reserved[7];
121         uint8_t name[RTE_PMD_I40E_DDP_NAME_SIZE];
122 };
123
124 #define RTE_PMD_I40E_DDP_OWNER_UNKNOWN 0xFF
125
126 /**
127  * Profile information list returned from HW.
128  */
129 struct rte_pmd_i40e_profile_list {
130         uint32_t p_count;
131         struct rte_pmd_i40e_profile_info p_info[1];
132 };
133
134 /**
135  * ptype mapping table only accept RTE_PTYPE_XXX or "user defined" ptype.
136  * A ptype with MSB set will be regarded as a user defined ptype.
137  * Below macro help to create a user defined ptype.
138  */
139 #define RTE_PMD_I40E_PTYPE_USER_DEFINE_MASK 0x80000000
140
141 struct rte_pmd_i40e_ptype_mapping {
142         uint16_t hw_ptype; /**< hardware defined packet type*/
143         uint32_t sw_ptype; /**< software defined packet type */
144 };
145
146 /**
147  * Notify VF when PF link status changes.
148  *
149  * @param port
150  *   The port identifier of the Ethernet device.
151  * @param vf
152  *   VF id.
153  * @return
154  *   - (0) if successful.
155  *   - (-ENODEV) if *port* invalid.
156  *   - (-EINVAL) if *vf* invalid.
157  */
158 int rte_pmd_i40e_ping_vfs(uint8_t port, uint16_t vf);
159
160 /**
161  * Enable/Disable VF MAC anti spoofing.
162  *
163  * @param port
164  *    The port identifier of the Ethernet device.
165  * @param vf_id
166  *    VF on which to set MAC anti spoofing.
167  * @param on
168  *    1 - Enable VFs MAC anti spoofing.
169  *    0 - Disable VFs MAC anti spoofing.
170  * @return
171  *   - (0) if successful.
172  *   - (-ENODEV) if *port* invalid.
173  *   - (-EINVAL) if bad parameter.
174  */
175 int rte_pmd_i40e_set_vf_mac_anti_spoof(uint8_t port,
176                                        uint16_t vf_id,
177                                        uint8_t on);
178
179 /**
180  * Enable/Disable VF VLAN anti spoofing.
181  *
182  * @param port
183  *    The port identifier of the Ethernet device.
184  * @param vf_id
185  *    VF on which to set VLAN anti spoofing.
186  * @param on
187  *    1 - Enable VFs VLAN anti spoofing.
188  *    0 - Disable VFs VLAN anti spoofing.
189  * @return
190  *   - (0) if successful.
191  *   - (-ENODEV) if *port* invalid.
192  *   - (-EINVAL) if bad parameter.
193  */
194 int rte_pmd_i40e_set_vf_vlan_anti_spoof(uint8_t port,
195                                         uint16_t vf_id,
196                                         uint8_t on);
197
198 /**
199  * Enable/Disable TX loopback on all the PF and VFs.
200  *
201  * @param port
202  *    The port identifier of the Ethernet device.
203  * @param on
204  *    1 - Enable TX loopback.
205  *    0 - Disable TX loopback.
206  * @return
207  *   - (0) if successful.
208  *   - (-ENODEV) if *port* invalid.
209  *   - (-EINVAL) if bad parameter.
210  */
211 int rte_pmd_i40e_set_tx_loopback(uint8_t port,
212                                  uint8_t on);
213
214 /**
215  * Enable/Disable VF unicast promiscuous mode.
216  *
217  * @param port
218  *    The port identifier of the Ethernet device.
219  * @param vf_id
220  *    VF on which to set.
221  * @param on
222  *    1 - Enable.
223  *    0 - Disable.
224  * @return
225  *   - (0) if successful.
226  *   - (-ENODEV) if *port* invalid.
227  *   - (-EINVAL) if bad parameter.
228  */
229 int rte_pmd_i40e_set_vf_unicast_promisc(uint8_t port,
230                                         uint16_t vf_id,
231                                         uint8_t on);
232
233 /**
234  * Enable/Disable VF multicast promiscuous mode.
235  *
236  * @param port
237  *    The port identifier of the Ethernet device.
238  * @param vf_id
239  *    VF on which to set.
240  * @param on
241  *    1 - Enable.
242  *    0 - Disable.
243  * @return
244  *   - (0) if successful.
245  *   - (-ENODEV) if *port* invalid.
246  *   - (-EINVAL) if bad parameter.
247  */
248 int rte_pmd_i40e_set_vf_multicast_promisc(uint8_t port,
249                                           uint16_t vf_id,
250                                           uint8_t on);
251
252 /**
253  * Set the VF MAC address.
254  *
255  * PF should set MAC address before VF initialized, if PF sets the MAC
256  * address after VF initialized, new MAC address won't be effective until
257  * VF reinitialize.
258  *
259  * This will remove all existing MAC filters.
260  *
261  * @param port
262  *   The port identifier of the Ethernet device.
263  * @param vf_id
264  *   VF id.
265  * @param mac_addr
266  *   VF MAC address.
267  * @return
268  *   - (0) if successful.
269  *   - (-ENODEV) if *port* invalid.
270  *   - (-EINVAL) if *vf* or *mac_addr* is invalid.
271  */
272 int rte_pmd_i40e_set_vf_mac_addr(uint8_t port, uint16_t vf_id,
273                                  struct ether_addr *mac_addr);
274
275 /**
276  * Enable/Disable vf vlan strip for all queues in a pool
277  *
278  * @param port
279  *    The port identifier of the Ethernet device.
280  * @param vf
281  *    ID specifying VF.
282  * @param on
283  *    1 - Enable VF's vlan strip on RX queues.
284  *    0 - Disable VF's vlan strip on RX queues.
285  *
286  * @return
287  *   - (0) if successful.
288  *   - (-ENODEV) if *port* invalid.
289  *   - (-EINVAL) if bad parameter.
290  */
291 int
292 rte_pmd_i40e_set_vf_vlan_stripq(uint8_t port, uint16_t vf, uint8_t on);
293
294 /**
295  * Enable/Disable vf vlan insert
296  *
297  * @param port
298  *    The port identifier of the Ethernet device.
299  * @param vf_id
300  *    ID specifying VF.
301  * @param vlan_id
302  *    0 - Disable VF's vlan insert.
303  *    n - Enable; n is inserted as the vlan id.
304  *
305  * @return
306  *   - (0) if successful.
307  *   - (-ENODEV) if *port* invalid.
308  *   - (-EINVAL) if bad parameter.
309  */
310 int rte_pmd_i40e_set_vf_vlan_insert(uint8_t port, uint16_t vf_id,
311                                     uint16_t vlan_id);
312
313 /**
314  * Enable/Disable vf broadcast mode
315  *
316  * @param port
317  *    The port identifier of the Ethernet device.
318  * @param vf_id
319  *    ID specifying VF.
320  * @param on
321  *    0 - Disable broadcast.
322  *    1 - Enable broadcast.
323  *
324  * @return
325  *   - (0) if successful.
326  *   - (-ENODEV) if *port* invalid.
327  *   - (-EINVAL) if bad parameter.
328  */
329 int rte_pmd_i40e_set_vf_broadcast(uint8_t port, uint16_t vf_id,
330                                   uint8_t on);
331
332 /**
333  * Enable/Disable vf vlan tag
334  *
335  * @param port
336  *    The port identifier of the Ethernet device.
337  * @param vf_id
338  *    ID specifying VF.
339  * @param on
340  *    0 - Disable VF's vlan tag.
341  *    n - Enable VF's vlan tag.
342  *
343  * @return
344  *   - (0) if successful.
345  *   - (-ENODEV) if *port* invalid.
346  *   - (-EINVAL) if bad parameter.
347  */
348 int rte_pmd_i40e_set_vf_vlan_tag(uint8_t port, uint16_t vf_id, uint8_t on);
349
350 /**
351  * Enable/Disable VF VLAN filter
352  *
353  * @param port
354  *    The port identifier of the Ethernet device.
355  * @param vlan_id
356  *    ID specifying VLAN
357  * @param vf_mask
358  *    Mask to filter VF's
359  * @param on
360  *    0 - Disable VF's VLAN filter.
361  *    1 - Enable VF's VLAN filter.
362  *
363  * @return
364  *   - (0) if successful.
365  *   - (-ENODEV) if *port* invalid.
366  *   - (-EINVAL) if bad parameter.
367  *   - (-ENOTSUP) not supported by firmware.
368  */
369 int rte_pmd_i40e_set_vf_vlan_filter(uint8_t port, uint16_t vlan_id,
370                                     uint64_t vf_mask, uint8_t on);
371
372 /**
373  * Get VF's statistics
374  *
375  * @param port
376  *    The port identifier of the Ethernet device.
377  * @param vf_id
378  *    VF on which to get.
379  * @param stats
380  *    A pointer to a structure of type *rte_eth_stats* to be filled with
381  *    the values of device counters for the following set of statistics:
382  *   - *ipackets* with the total of successfully received packets.
383  *   - *opackets* with the total of successfully transmitted packets.
384  *   - *ibytes*   with the total of successfully received bytes.
385  *   - *obytes*   with the total of successfully transmitted bytes.
386  *   - *ierrors*  with the total of erroneous received packets.
387  *   - *oerrors*  with the total of failed transmitted packets.
388  * @return
389  *   - (0) if successful.
390  *   - (-ENODEV) if *port* invalid.
391  *   - (-EINVAL) if bad parameter.
392  */
393
394 int rte_pmd_i40e_get_vf_stats(uint8_t port,
395                               uint16_t vf_id,
396                               struct rte_eth_stats *stats);
397
398 /**
399  * Clear VF's statistics
400  *
401  * @param port
402  *    The port identifier of the Ethernet device.
403  * @param vf_id
404  *    VF on which to get.
405  * @return
406  *   - (0) if successful.
407  *   - (-ENODEV) if *port* invalid.
408  *   - (-EINVAL) if bad parameter.
409  */
410 int rte_pmd_i40e_reset_vf_stats(uint8_t port,
411                                 uint16_t vf_id);
412
413 /**
414  * Set VF's max bandwidth.
415  *
416  * Per VF bandwidth limitation and per TC bandwidth limitation cannot
417  * be enabled in parallel. If per TC bandwidth is enabled, this function
418  * will disable it.
419  *
420  * @param port
421  *    The port identifier of the Ethernet device.
422  * @param vf_id
423  *    ID specifying VF.
424  * @param bw
425  *    Bandwidth for this VF.
426  *    The value should be an absolute bandwidth in Mbps.
427  *    The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
428  *    Not count the bytes added by physical layer.
429  * @return
430  *   - (0) if successful.
431  *   - (-ENODEV) if *port* invalid.
432  *   - (-EINVAL) if bad parameter.
433  *   - (-ENOTSUP) not supported by firmware.
434  */
435 int rte_pmd_i40e_set_vf_max_bw(uint8_t port,
436                                uint16_t vf_id,
437                                uint32_t bw);
438
439 /**
440  * Set all the TCs' bandwidth weight on a specific VF.
441  *
442  * The bw_weight means the percentage occupied by the TC.
443  * It can be taken as the relative min bandwidth setting.
444  *
445  * @param port
446  *    The port identifier of the Ethernet device.
447  * @param vf_id
448  *    ID specifying VF.
449  * @param tc_num
450  *    Number of TCs.
451  * @param bw_weight
452  *    An array of relative bandwidth weight for all the TCs.
453  *    The summary of the bw_weight should be 100.
454  * @return
455  *   - (0) if successful.
456  *   - (-ENODEV) if *port* invalid.
457  *   - (-EINVAL) if bad parameter.
458  *   - (-ENOTSUP) not supported by firmware.
459  */
460 int rte_pmd_i40e_set_vf_tc_bw_alloc(uint8_t port,
461                                     uint16_t vf_id,
462                                     uint8_t tc_num,
463                                     uint8_t *bw_weight);
464
465 /**
466  * Set a specific TC's max bandwidth on a specific VF.
467  *
468  * @param port
469  *    The port identifier of the Ethernet device.
470  * @param vf_id
471  *    ID specifying VF.
472  * @param tc_no
473  *    Number specifying TC.
474  * @param bw
475  *    Max bandwidth for this TC.
476  *    The value should be an absolute bandwidth in Mbps.
477  *    The bandwidth is a L2 bandwidth counting the bytes of ethernet packets.
478  *    Not count the bytes added by physical layer.
479  * @return
480  *   - (0) if successful.
481  *   - (-ENODEV) if *port* invalid.
482  *   - (-EINVAL) if bad parameter.
483  *   - (-ENOTSUP) not supported by firmware.
484  */
485 int rte_pmd_i40e_set_vf_tc_max_bw(uint8_t port,
486                                   uint16_t vf_id,
487                                   uint8_t tc_no,
488                                   uint32_t bw);
489
490 /**
491  * Set some TCs to strict priority mode on a physical port.
492  *
493  * @param port
494  *    The port identifier of the Ethernet device.
495  * @param tc_map
496  *    A bit map for the TCs.
497  * @return
498  *   - (0) if successful.
499  *   - (-ENODEV) if *port* invalid.
500  *   - (-EINVAL) if bad parameter.
501  *   - (-ENOTSUP) not supported by firmware.
502  */
503 int rte_pmd_i40e_set_tc_strict_prio(uint8_t port, uint8_t tc_map);
504
505 /**
506  * Load/Unload a ddp package
507  *
508  * @param port
509  *    The port identifier of the Ethernet device.
510  * @param buff
511  *    buffer of package.
512  * @param size
513  *    size of buffer.
514  * @param op
515  *   Operation of package processing
516  * @return
517  *   - (0) if successful.
518  *   - (-ENODEV) if *port* invalid.
519  *   - (-EINVAL) if bad parameter.
520  *   - (1) if profile exists.
521  */
522 int rte_pmd_i40e_process_ddp_package(uint8_t port, uint8_t *buff,
523                                      uint32_t size,
524                                      enum rte_pmd_i40e_package_op op);
525
526 /**
527  * rte_pmd_i40e_get_ddp_info - Get profile's info
528  * @param pkg
529  *    buffer of package.
530  * @param pkg_size
531  *    package buffer size
532  * @param info
533  *    buffer for response
534  * @param size
535  *    response buffer size
536  * @param type
537  *    type of information requested
538  * @return
539  *   - (0) if successful.
540  *   - (-ENOTSUP) if information type not supported by the profile.
541  *   - (-EINVAL) if bad parameter.
542  */
543 int rte_pmd_i40e_get_ddp_info(uint8_t *pkg, uint32_t pkg_size,
544                                      uint8_t *info, uint32_t size,
545                                      enum rte_pmd_i40e_package_info type);
546
547 /**
548  * rte_pmd_i40e_get_ddp_list - Get loaded profile list
549  * @param port
550  *    port id
551  * @param buff
552  *    buffer for response
553  * @param size
554  *    buffer size
555  * @return
556  *   - (0) if successful.
557  *   - (-ENODEV) if *port* invalid.
558  *   - (-EINVAL) if bad parameter.
559  */
560 int rte_pmd_i40e_get_ddp_list(uint8_t port, uint8_t *buff, uint32_t size);
561
562 /**
563  * Update hardware defined ptype to software defined packet type
564  * mapping table.
565  *
566  * @param port
567  *    pointer to port identifier of the device.
568  * @param mapping_items
569  *    the base address of the mapping items array.
570  * @param count
571  *    number of mapping items.
572  * @param exclusive
573  *    the flag indicate different ptype mapping update method.
574  *    -(0) only overwrite referred PTYPE mapping,
575  *      keep other PTYPEs mapping unchanged.
576  *    -(!0) overwrite referred PTYPE mapping,
577  *      set other PTYPEs maps to PTYPE_UNKNOWN.
578  */
579 int rte_pmd_i40e_ptype_mapping_update(
580                         uint8_t port,
581                         struct rte_pmd_i40e_ptype_mapping *mapping_items,
582                         uint16_t count,
583                         uint8_t exclusive);
584
585 /**
586  * Reset hardware defined ptype to software defined ptype
587  * mapping table to default.
588  *
589  * @param port
590  *    pointer to port identifier of the device
591  */
592 int rte_pmd_i40e_ptype_mapping_reset(uint8_t port);
593
594 /**
595  * Get hardware defined ptype to software defined ptype
596  * mapping items.
597  *
598  * @param port
599  *    pointer to port identifier of the device.
600  * @param mapping_items
601  *    the base address of the array to store returned items.
602  * @param size
603  *    the size of the input array.
604  * @param count
605  *    the place to store the number of returned items.
606  * @param valid_only
607  *    -(0) return full mapping table.
608  *    -(!0) only return mapping items which packet_type != RTE_PTYPE_UNKNOWN.
609  */
610 int rte_pmd_i40e_ptype_mapping_get(
611                         uint8_t port,
612                         struct rte_pmd_i40e_ptype_mapping *mapping_items,
613                         uint16_t size,
614                         uint16_t *count,
615                         uint8_t valid_only);
616
617 /**
618  * Replace a specific or a group of software defined ptypes
619  * with a new one
620  *
621  * @param port
622  *    pointer to port identifier of the device
623  * @param target
624  *    the packet type to be replaced
625  * @param mask
626  *    -(0) target represent a specific software defined ptype.
627  *    -(!0) target is a mask to represent a group of software defined ptypes.
628  * @param pkt_type
629  *    the new packet type to overwrite
630  */
631 int rte_pmd_i40e_ptype_mapping_replace(uint8_t port,
632                                        uint32_t target,
633                                        uint8_t mask,
634                                        uint32_t pkt_type);
635
636 #endif /* _PMD_I40E_H_ */