f2e341c372dc12542b3bf94fc9fe306ed9586682
[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 /* config. */
21 struct mrvl_cfg {
22         struct  {
23                 struct pp2_parse_udfs   prs_udfs;
24         } pp2_cfg;
25         struct port_cfg {
26                 enum pp2_ppio_eth_start_hdr eth_start_hdr;
27                 int rate_limit_enable;
28                 struct pp2_ppio_rate_limit_params rate_limit_params;
29                 struct {
30                         uint8_t inq[MRVL_PP2_RXQ_MAX];
31                         uint8_t dscp[MRVL_CP_PER_TC];
32                         uint8_t pcp[MRVL_CP_PER_TC];
33                         uint8_t inqs;
34                         uint8_t dscps;
35                         uint8_t pcps;
36                         enum pp2_ppio_color color;
37                 } tc[MRVL_PP2_TC_MAX];
38                 struct {
39                         enum pp2_ppio_outq_sched_mode sched_mode;
40                         uint8_t weight;
41                         int rate_limit_enable;
42                         struct pp2_ppio_rate_limit_params rate_limit_params;
43                 } outq[MRVL_PP2_RXQ_MAX];
44                 enum pp2_cls_qos_tbl_type mapping_priority;
45                 uint16_t inqs;
46                 uint16_t outqs;
47                 uint8_t default_tc;
48                 uint8_t use_global_defaults;
49                 struct pp2_cls_plcr_params policer_params;
50                 uint8_t setup_policer;
51                 uint8_t forward_bad_frames;
52         } port[RTE_MAX_ETHPORTS];
53 };
54
55 /** Global configuration. */
56 extern struct mrvl_cfg *mrvl_cfg;
57
58 /**
59  * Parse configuration - rte_kvargs_process handler.
60  *
61  * Opens configuration file and parses its content.
62  *
63  * @param key Unused.
64  * @param path Path to config file.
65  * @param extra_args Pointer to configuration structure.
66  * @returns 0 in case of success, exits otherwise.
67  */
68 int
69 mrvl_get_cfg(const char *key __rte_unused, const char *path, void *extra_args);
70
71 /**
72  * Configure RX Queues in a given port.
73  *
74  * Sets up RX queues, their Traffic Classes and DPDK rxq->(TC,inq) mapping.
75  *
76  * @param priv Port's private data
77  * @param portid DPDK port ID
78  * @param max_queues Maximum number of queues to configure.
79  * @returns 0 in case of success, negative value otherwise.
80  */
81 int
82 mrvl_configure_rxqs(struct mrvl_priv *priv, uint16_t portid,
83                     uint16_t max_queues);
84
85 /**
86  * Configure TX Queues in a given port.
87  *
88  * Sets up TX queues egress scheduler and limiter.
89  *
90  * @param priv Port's private data
91  * @param portid DPDK port ID
92  * @param max_queues Maximum number of queues to configure.
93  * @returns 0 in case of success, negative value otherwise.
94  */
95 int
96 mrvl_configure_txqs(struct mrvl_priv *priv, uint16_t portid,
97                     uint16_t max_queues);
98
99 /**
100  * Start QoS mapping.
101  *
102  * Finalize QoS table configuration and initialize it in SDK. It can be done
103  * only after port is started, so we have a valid ppio reference.
104  *
105  * @param priv Port's private (configuration) data.
106  * @returns 0 in case of success, exits otherwise.
107  */
108 int
109 mrvl_start_qos_mapping(struct mrvl_priv *priv);
110
111 #endif /* _MRVL_QOS_H_ */