net/mrvl: support ingress policer
[dpdk.git] / drivers / net / mrvl / 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                 struct {
24                         uint8_t inq[MRVL_PP2_RXQ_MAX];
25                         uint8_t dscp[MRVL_CP_PER_TC];
26                         uint8_t pcp[MRVL_CP_PER_TC];
27                         uint8_t inqs;
28                         uint8_t dscps;
29                         uint8_t pcps;
30                         enum pp2_ppio_color color;
31                 } tc[MRVL_PP2_TC_MAX];
32                 struct {
33                         uint8_t weight;
34                 } outq[MRVL_PP2_RXQ_MAX];
35                 enum pp2_cls_qos_tbl_type mapping_priority;
36                 uint16_t inqs;
37                 uint16_t outqs;
38                 uint8_t default_tc;
39                 uint8_t use_global_defaults;
40                 struct pp2_cls_plcr_params policer_params;
41                 uint8_t policer_enable;
42         } port[RTE_MAX_ETHPORTS];
43 };
44
45 /** Global QoS configuration. */
46 extern struct mrvl_qos_cfg *mrvl_qos_cfg;
47
48 /**
49  * Parse QoS configuration - rte_kvargs_process handler.
50  *
51  * Opens configuration file and parses its content.
52  *
53  * @param key Unused.
54  * @param path Path to config file.
55  * @param extra_args Pointer to configuration structure.
56  * @returns 0 in case of success, exits otherwise.
57  */
58 int
59 mrvl_get_qoscfg(const char *key __rte_unused, const char *path,
60                 void *extra_args);
61
62 /**
63  * Configure RX Queues in a given port.
64  *
65  * Sets up RX queues, their Traffic Classes and DPDK rxq->(TC,inq) mapping.
66  *
67  * @param priv Port's private data
68  * @param portid DPDK port ID
69  * @param max_queues Maximum number of queues to configure.
70  * @returns 0 in case of success, negative value otherwise.
71  */
72 int
73 mrvl_configure_rxqs(struct mrvl_priv *priv, uint16_t portid,
74                     uint16_t max_queues);
75
76 /**
77  * Start QoS mapping.
78  *
79  * Finalize QoS table configuration and initialize it in SDK. It can be done
80  * only after port is started, so we have a valid ppio reference.
81  *
82  * @param priv Port's private (configuration) data.
83  * @returns 0 in case of success, exits otherwise.
84  */
85 int
86 mrvl_start_qos_mapping(struct mrvl_priv *priv);
87
88 #endif /* _MRVL_QOS_H_ */