New upstream version 18.11-rc1
[deb_dpdk.git] / drivers / net / mvpp2 / mrvl_qos.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Marvell International Ltd.
3  * Copyright(c) 2017 Semihalf.
4  * All rights reserved.
5  */
6
7 #ifndef _MRVL_QOS_H_
8 #define _MRVL_QOS_H_
9
10 #include <rte_common.h>
11
12 #include "mrvl_ethdev.h"
13
14 /** Code Points per Traffic Class. Equals max(DSCP, PCP). */
15 #define MRVL_CP_PER_TC (64)
16
17 /** Value used as "unknown". */
18 #define MRVL_UNKNOWN_TC (0xFF)
19
20 /* QoS config. */
21 struct mrvl_qos_cfg {
22         struct port_cfg {
23                 int rate_limit_enable;
24                 struct pp2_ppio_rate_limit_params rate_limit_params;
25                 struct {
26                         uint8_t inq[MRVL_PP2_RXQ_MAX];
27                         uint8_t dscp[MRVL_CP_PER_TC];
28                         uint8_t pcp[MRVL_CP_PER_TC];
29                         uint8_t inqs;
30                         uint8_t dscps;
31                         uint8_t pcps;
32                         enum pp2_ppio_color color;
33                 } tc[MRVL_PP2_TC_MAX];
34                 struct {
35                         enum pp2_ppio_outq_sched_mode sched_mode;
36                         uint8_t weight;
37                         int rate_limit_enable;
38                         struct pp2_ppio_rate_limit_params rate_limit_params;
39                 } outq[MRVL_PP2_RXQ_MAX];
40                 enum pp2_cls_qos_tbl_type mapping_priority;
41                 uint16_t inqs;
42                 uint16_t outqs;
43                 uint8_t default_tc;
44                 uint8_t use_global_defaults;
45                 struct pp2_cls_plcr_params policer_params;
46                 uint8_t setup_policer;
47         } port[RTE_MAX_ETHPORTS];
48 };
49
50 /** Global QoS configuration. */
51 extern struct mrvl_qos_cfg *mrvl_qos_cfg;
52
53 /**
54  * Parse QoS configuration - rte_kvargs_process handler.
55  *
56  * Opens configuration file and parses its content.
57  *
58  * @param key Unused.
59  * @param path Path to config file.
60  * @param extra_args Pointer to configuration structure.
61  * @returns 0 in case of success, exits otherwise.
62  */
63 int
64 mrvl_get_qoscfg(const char *key __rte_unused, const char *path,
65                 void *extra_args);
66
67 /**
68  * Configure RX Queues in a given port.
69  *
70  * Sets up RX queues, their Traffic Classes and DPDK rxq->(TC,inq) mapping.
71  *
72  * @param priv Port's private data
73  * @param portid DPDK port ID
74  * @param max_queues Maximum number of queues to configure.
75  * @returns 0 in case of success, negative value otherwise.
76  */
77 int
78 mrvl_configure_rxqs(struct mrvl_priv *priv, uint16_t portid,
79                     uint16_t max_queues);
80
81 /**
82  * Configure TX Queues in a given port.
83  *
84  * Sets up TX queues egress scheduler and limiter.
85  *
86  * @param priv Port's private data
87  * @param portid DPDK port ID
88  * @param max_queues Maximum number of queues to configure.
89  * @returns 0 in case of success, negative value otherwise.
90  */
91 int
92 mrvl_configure_txqs(struct mrvl_priv *priv, uint16_t portid,
93                     uint16_t max_queues);
94
95 /**
96  * Start QoS mapping.
97  *
98  * Finalize QoS table configuration and initialize it in SDK. It can be done
99  * only after port is started, so we have a valid ppio reference.
100  *
101  * @param priv Port's private (configuration) data.
102  * @returns 0 in case of success, exits otherwise.
103  */
104 int
105 mrvl_start_qos_mapping(struct mrvl_priv *priv);
106
107 #endif /* _MRVL_QOS_H_ */