net/octeontx2: introduce traffic manager
[dpdk.git] / drivers / net / octeontx2 / otx2_tm.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(C) 2019 Marvell International Ltd.
3  */
4
5 #ifndef __OTX2_TM_H__
6 #define __OTX2_TM_H__
7
8 #include <stdbool.h>
9
10 #include <rte_tm_driver.h>
11
12 #define NIX_TM_DEFAULT_TREE     BIT_ULL(0)
13
14 struct otx2_eth_dev;
15
16 void otx2_nix_tm_conf_init(struct rte_eth_dev *eth_dev);
17 int otx2_nix_tm_init_default(struct rte_eth_dev *eth_dev);
18 int otx2_nix_tm_fini(struct rte_eth_dev *eth_dev);
19
20 struct otx2_nix_tm_node {
21         TAILQ_ENTRY(otx2_nix_tm_node) node;
22         uint32_t id;
23         uint32_t hw_id;
24         uint32_t priority;
25         uint32_t weight;
26         uint16_t level_id;
27         uint16_t hw_lvl_id;
28         uint32_t rr_prio;
29         uint32_t rr_num;
30         uint32_t max_prio;
31         uint32_t parent_hw_id;
32         uint32_t flags;
33 #define NIX_TM_NODE_HWRES       BIT_ULL(0)
34 #define NIX_TM_NODE_ENABLED     BIT_ULL(1)
35 #define NIX_TM_NODE_USER        BIT_ULL(2)
36         struct otx2_nix_tm_node *parent;
37         struct rte_tm_node_params params;
38 };
39
40 struct otx2_nix_tm_shaper_profile {
41         TAILQ_ENTRY(otx2_nix_tm_shaper_profile) shaper;
42         uint32_t shaper_profile_id;
43         uint32_t reference_count;
44         struct rte_tm_shaper_params profile;
45 };
46
47 struct shaper_params {
48         uint64_t burst_exponent;
49         uint64_t burst_mantissa;
50         uint64_t div_exp;
51         uint64_t exponent;
52         uint64_t mantissa;
53         uint64_t burst;
54         uint64_t rate;
55 };
56
57 TAILQ_HEAD(otx2_nix_tm_node_list, otx2_nix_tm_node);
58 TAILQ_HEAD(otx2_nix_tm_shaper_profile_list, otx2_nix_tm_shaper_profile);
59
60 #define MAX_SCHED_WEIGHT ((uint8_t)~0)
61 #define NIX_TM_RR_QUANTUM_MAX ((1 << 24) - 1)
62
63 /* DEFAULT_RR_WEIGHT * NIX_TM_RR_QUANTUM_MAX / MAX_SCHED_WEIGHT  */
64 /* = NIX_MAX_HW_MTU */
65 #define DEFAULT_RR_WEIGHT 71
66
67 #endif /* __OTX2_TM_H__ */