1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2019 Marvell International Ltd.
10 #include <rte_tm_driver.h>
12 #define NIX_TM_DEFAULT_TREE BIT_ULL(0)
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 int otx2_nix_tm_get_leaf_data(struct otx2_eth_dev *dev, uint16_t sq,
20 uint32_t *rr_quantum, uint16_t *smq);
21 int otx2_nix_tm_sw_xoff(void *_txq, bool dev_started);
22 int otx2_nix_sq_sqb_aura_fc(void *_txq, bool enable);
24 struct otx2_nix_tm_node {
25 TAILQ_ENTRY(otx2_nix_tm_node) node;
35 uint32_t parent_hw_id;
37 #define NIX_TM_NODE_HWRES BIT_ULL(0)
38 #define NIX_TM_NODE_ENABLED BIT_ULL(1)
39 #define NIX_TM_NODE_USER BIT_ULL(2)
40 struct otx2_nix_tm_node *parent;
41 struct rte_tm_node_params params;
44 struct otx2_nix_tm_shaper_profile {
45 TAILQ_ENTRY(otx2_nix_tm_shaper_profile) shaper;
46 uint32_t shaper_profile_id;
47 uint32_t reference_count;
48 struct rte_tm_shaper_params profile;
51 struct shaper_params {
52 uint64_t burst_exponent;
53 uint64_t burst_mantissa;
61 TAILQ_HEAD(otx2_nix_tm_node_list, otx2_nix_tm_node);
62 TAILQ_HEAD(otx2_nix_tm_shaper_profile_list, otx2_nix_tm_shaper_profile);
64 #define MAX_SCHED_WEIGHT ((uint8_t)~0)
65 #define NIX_TM_RR_QUANTUM_MAX (BIT_ULL(24) - 1)
67 /* DEFAULT_RR_WEIGHT * NIX_TM_RR_QUANTUM_MAX / MAX_SCHED_WEIGHT */
68 /* = NIX_MAX_HW_MTU */
69 #define DEFAULT_RR_WEIGHT 71
71 /** NIX rate limits */
72 #define MAX_RATE_DIV_EXP 12
73 #define MAX_RATE_EXPONENT 0xf
74 #define MAX_RATE_MANTISSA 0xff
76 /** NIX rate limiter time-wheel resolution */
77 #define L1_TIME_WHEEL_CCLK_TICKS 240
78 #define LX_TIME_WHEEL_CCLK_TICKS 860
80 #define CCLK_HZ 1000000000
82 /* NIX rate calculation
83 * CCLK = coprocessor-clock frequency in MHz
84 * CCLK_TICKS = rate limiter time-wheel resolution
86 * PIR_ADD = ((256 + NIX_*_PIR[RATE_MANTISSA])
87 * << NIX_*_PIR[RATE_EXPONENT]) / 256
88 * PIR = (CCLK / (CCLK_TICKS << NIX_*_PIR[RATE_DIVIDER_EXPONENT]))
91 * CIR_ADD = ((256 + NIX_*_CIR[RATE_MANTISSA])
92 * << NIX_*_CIR[RATE_EXPONENT]) / 256
93 * CIR = (CCLK / (CCLK_TICKS << NIX_*_CIR[RATE_DIVIDER_EXPONENT]))
96 #define SHAPER_RATE(cclk_hz, cclk_ticks, \
97 exponent, mantissa, div_exp) \
98 (((uint64_t)(cclk_hz) * ((256 + (mantissa)) << (exponent))) \
99 / (((cclk_ticks) << (div_exp)) * 256))
101 #define L1_SHAPER_RATE(cclk_hz, exponent, mantissa, div_exp) \
102 SHAPER_RATE(cclk_hz, L1_TIME_WHEEL_CCLK_TICKS, \
103 exponent, mantissa, div_exp)
105 #define LX_SHAPER_RATE(cclk_hz, exponent, mantissa, div_exp) \
106 SHAPER_RATE(cclk_hz, LX_TIME_WHEEL_CCLK_TICKS, \
107 exponent, mantissa, div_exp)
109 /* Shaper rate limits */
110 #define MIN_SHAPER_RATE(cclk_hz, cclk_ticks) \
111 SHAPER_RATE(cclk_hz, cclk_ticks, 0, 0, MAX_RATE_DIV_EXP)
113 #define MAX_SHAPER_RATE(cclk_hz, cclk_ticks) \
114 SHAPER_RATE(cclk_hz, cclk_ticks, MAX_RATE_EXPONENT, \
115 MAX_RATE_MANTISSA, 0)
117 #define MIN_L1_SHAPER_RATE(cclk_hz) \
118 MIN_SHAPER_RATE(cclk_hz, L1_TIME_WHEEL_CCLK_TICKS)
120 #define MAX_L1_SHAPER_RATE(cclk_hz) \
121 MAX_SHAPER_RATE(cclk_hz, L1_TIME_WHEEL_CCLK_TICKS)
123 /** TM Shaper - low level operations */
125 /** NIX burst limits */
126 #define MAX_BURST_EXPONENT 0xf
127 #define MAX_BURST_MANTISSA 0xff
129 /* NIX burst calculation
130 * PIR_BURST = ((256 + NIX_*_PIR[BURST_MANTISSA])
131 * << (NIX_*_PIR[BURST_EXPONENT] + 1))
134 * CIR_BURST = ((256 + NIX_*_CIR[BURST_MANTISSA])
135 * << (NIX_*_CIR[BURST_EXPONENT] + 1))
138 #define SHAPER_BURST(exponent, mantissa) \
139 (((256 + (mantissa)) << ((exponent) + 1)) / 256)
141 /** Shaper burst limits */
142 #define MIN_SHAPER_BURST \
145 #define MAX_SHAPER_BURST \
146 SHAPER_BURST(MAX_BURST_EXPONENT,\
149 /* Default TL1 priority and Quantum from AF */
150 #define TXSCH_TL1_DFLT_RR_QTM ((1 << 24) - 1)
151 #define TXSCH_TL1_DFLT_RR_PRIO 1
153 #endif /* __OTX2_TM_H__ */