ca738133b18f87645da853b1c52bdb3cc8711d15
[dpdk.git] / drivers / net / mrvl / mrvl_qos.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2017 Marvell International Ltd.
5  *   Copyright(c) 2017 Semihalf.
6  *   All rights reserved.
7  *
8  *   Redistribution and use in source and binary forms, with or without
9  *   modification, are permitted provided that the following conditions
10  *   are met:
11  *
12  *     * Redistributions of source code must retain the above copyright
13  *       notice, this list of conditions and the following disclaimer.
14  *     * Redistributions in binary form must reproduce the above copyright
15  *       notice, this list of conditions and the following disclaimer in
16  *       the documentation and/or other materials provided with the
17  *       distribution.
18  *     * Neither the name of the copyright holder nor the names of its
19  *       contributors may be used to endorse or promote products derived
20  *       from this software without specific prior written permission.
21  *
22  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 #ifndef _MRVL_QOS_H_
36 #define _MRVL_QOS_H_
37
38 #include <rte_common.h>
39 #include <rte_config.h>
40
41 #include "mrvl_ethdev.h"
42
43 /** Code Points per Traffic Class. Equals max(DSCP, PCP). */
44 #define MRVL_CP_PER_TC (64)
45
46 /** Value used as "unknown". */
47 #define MRVL_UNKNOWN_TC (0xFF)
48
49 /* QoS config. */
50 struct mrvl_qos_cfg {
51         struct port_cfg {
52                 struct {
53                         uint8_t inq[MRVL_PP2_RXQ_MAX];
54                         uint8_t dscp[MRVL_CP_PER_TC];
55                         uint8_t pcp[MRVL_CP_PER_TC];
56                         uint8_t inqs;
57                         uint8_t dscps;
58                         uint8_t pcps;
59                 } tc[MRVL_PP2_TC_MAX];
60                 struct {
61                         uint8_t weight;
62                 } outq[MRVL_PP2_RXQ_MAX];
63                 enum pp2_cls_qos_tbl_type mapping_priority;
64                 uint16_t inqs;
65                 uint16_t outqs;
66                 uint8_t default_tc;
67                 uint8_t use_global_defaults;
68         } port[RTE_MAX_ETHPORTS];
69 };
70
71 /** Global QoS configuration. */
72 extern struct mrvl_qos_cfg *mrvl_qos_cfg;
73
74 /**
75  * Parse QoS configuration - rte_kvargs_process handler.
76  *
77  * Opens configuration file and parses its content.
78  *
79  * @param key Unused.
80  * @param path Path to config file.
81  * @param extra_args Pointer to configuration structure.
82  * @returns 0 in case of success, exits otherwise.
83  */
84 int
85 mrvl_get_qoscfg(const char *key __rte_unused, const char *path,
86                 void *extra_args);
87
88 /**
89  * Configure RX Queues in a given port.
90  *
91  * Sets up RX queues, their Traffic Classes and DPDK rxq->(TC,inq) mapping.
92  *
93  * @param priv Port's private data
94  * @param portid DPDK port ID
95  * @param max_queues Maximum number of queues to configure.
96  * @returns 0 in case of success, negative value otherwise.
97  */
98 int
99 mrvl_configure_rxqs(struct mrvl_priv *priv, uint16_t portid,
100                     uint16_t max_queues);
101
102 /**
103  * Start QoS mapping.
104  *
105  * Finalize QoS table configuration and initialize it in SDK. It can be done
106  * only after port is started, so we have a valid ppio reference.
107  *
108  * @param priv Port's private (configuration) data.
109  * @returns 0 in case of success, exits otherwise.
110  */
111 int
112 mrvl_start_qos_mapping(struct mrvl_priv *priv);
113
114 #endif /* _MRVL_QOS_H_ */