net/mrvl: add net PMD skeleton
[dpdk.git] / drivers / net / mrvl / mrvl_qos.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Semihalf. 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 Semihalf 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 _MRVL_QOS_H_
34 #define _MRVL_QOS_H_
35
36 #include <rte_common.h>
37 #include <rte_config.h>
38
39 #include "mrvl_ethdev.h"
40
41 /** Code Points per Traffic Class. Equals max(DSCP, PCP). */
42 #define MRVL_CP_PER_TC (64)
43
44 /** Value used as "unknown". */
45 #define MRVL_UNKNOWN_TC (0xFF)
46
47 /* QoS config. */
48 struct mrvl_qos_cfg {
49         struct port_cfg {
50                 struct {
51                         uint8_t inq[MRVL_PP2_RXQ_MAX];
52                         uint8_t dscp[MRVL_CP_PER_TC];
53                         uint8_t pcp[MRVL_CP_PER_TC];
54                         uint8_t inqs;
55                         uint8_t dscps;
56                         uint8_t pcps;
57                 } tc[MRVL_PP2_TC_MAX];
58                 struct {
59                         uint8_t weight;
60                 } outq[MRVL_PP2_RXQ_MAX];
61                 enum pp2_cls_qos_tbl_type mapping_priority;
62                 uint16_t inqs;
63                 uint16_t outqs;
64                 uint8_t default_tc;
65                 uint8_t use_global_defaults;
66         } port[RTE_MAX_ETHPORTS];
67 };
68
69 /** Global QoS configuration. */
70 extern struct mrvl_qos_cfg *mrvl_qos_cfg;
71
72 /**
73  * Parse QoS configuration - rte_kvargs_process handler.
74  *
75  * Opens configuration file and parses its content.
76  *
77  * @param key Unused.
78  * @param path Path to config file.
79  * @param extra_args Pointer to configuration structure.
80  * @returns 0 in case of success, exits otherwise.
81  */
82 int
83 mrvl_get_qoscfg(const char *key __rte_unused, const char *path,
84                 void *extra_args);
85
86 /**
87  * Configure RX Queues in a given port.
88  *
89  * Sets up RX queues, their Traffic Classes and DPDK rxq->(TC,inq) mapping.
90  *
91  * @param priv Port's private data
92  * @param portid DPDK port ID
93  * @param max_queues Maximum number of queues to configure.
94  * @returns 0 in case of success, negative value otherwise.
95  */
96 int
97 mrvl_configure_rxqs(struct mrvl_priv *priv, uint8_t portid,
98                     uint16_t max_queues);
99
100 /**
101  * Start QoS mapping.
102  *
103  * Finalize QoS table configuration and initialize it in SDK. It can be done
104  * only after port is started, so we have a valid ppio reference.
105  *
106  * @param priv Port's private (configuration) data.
107  * @returns 0 in case of success, exits otherwise.
108  */
109 int
110 mrvl_start_qos_mapping(struct mrvl_priv *priv);
111
112 #endif /* _MRVL_QOS_H_ */