Lines Matching full:sparx5

2 /* Microchip Sparx5 Switch driver
22 static u32 sparx5_lg_get_leak_time(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_get_leak_time() argument
26 value = spx5_rd(sparx5, HSCH_HSCH_TIMER_CFG(layer, group)); in sparx5_lg_get_leak_time()
30 static void sparx5_lg_set_leak_time(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_set_leak_time() argument
33 spx5_wr(HSCH_HSCH_TIMER_CFG_LEAK_TIME_SET(leak_time), sparx5, in sparx5_lg_set_leak_time()
37 static u32 sparx5_lg_get_first(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_get_first() argument
41 value = spx5_rd(sparx5, HSCH_HSCH_LEAK_CFG(layer, group)); in sparx5_lg_get_first()
45 static u32 sparx5_lg_get_next(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_get_next() argument
51 value = spx5_rd(sparx5, HSCH_SE_CONNECT(idx)); in sparx5_lg_get_next()
55 static u32 sparx5_lg_get_last(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_get_last() argument
59 itr = sparx5_lg_get_first(sparx5, layer, group); in sparx5_lg_get_last()
62 next = sparx5_lg_get_next(sparx5, layer, group, itr); in sparx5_lg_get_last()
70 static bool sparx5_lg_is_last(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_is_last() argument
73 return idx == sparx5_lg_get_next(sparx5, layer, group, idx); in sparx5_lg_is_last()
76 static bool sparx5_lg_is_first(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_is_first() argument
79 return idx == sparx5_lg_get_first(sparx5, layer, group); in sparx5_lg_is_first()
82 static bool sparx5_lg_is_empty(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_is_empty() argument
84 return sparx5_lg_get_leak_time(sparx5, layer, group) == 0; in sparx5_lg_is_empty()
87 static bool sparx5_lg_is_singular(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_is_singular() argument
89 if (sparx5_lg_is_empty(sparx5, layer, group)) in sparx5_lg_is_singular()
92 return sparx5_lg_get_first(sparx5, layer, group) == in sparx5_lg_is_singular()
93 sparx5_lg_get_last(sparx5, layer, group); in sparx5_lg_is_singular()
96 static void sparx5_lg_enable(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_enable() argument
99 sparx5_lg_set_leak_time(sparx5, layer, group, leak_time); in sparx5_lg_enable()
102 static void sparx5_lg_disable(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_disable() argument
104 sparx5_lg_set_leak_time(sparx5, layer, group, 0); in sparx5_lg_disable()
107 static int sparx5_lg_get_group_by_index(struct sparx5 *sparx5, u32 layer, in sparx5_lg_get_group_by_index() argument
114 if (sparx5_lg_is_empty(sparx5, layer, i)) in sparx5_lg_get_group_by_index()
117 itr = sparx5_lg_get_first(sparx5, layer, i); in sparx5_lg_get_group_by_index()
120 next = sparx5_lg_get_next(sparx5, layer, i, itr); in sparx5_lg_get_group_by_index()
153 static int sparx5_lg_get_adjacent(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_get_adjacent() argument
158 *first = sparx5_lg_get_first(sparx5, layer, group); in sparx5_lg_get_adjacent()
164 *next = sparx5_lg_get_next(sparx5, layer, group, itr); in sparx5_lg_get_adjacent()
179 static int sparx5_lg_conf_set(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_conf_set() argument
185 sparx5_lg_disable(sparx5, layer, group); in sparx5_lg_conf_set()
192 HSCH_HSCH_CFG_CFG_HSCH_LAYER, sparx5, HSCH_HSCH_CFG_CFG); in sparx5_lg_conf_set()
195 spx5_wr(HSCH_SE_CONNECT_SE_LEAK_LINK_SET(idx_next), sparx5, in sparx5_lg_conf_set()
200 HSCH_HSCH_LEAK_CFG_LEAK_FIRST, sparx5, in sparx5_lg_conf_set()
204 sparx5_lg_enable(sparx5, layer, group, leak_time); in sparx5_lg_conf_set()
209 static int sparx5_lg_del(struct sparx5 *sparx5, u32 layer, u32 group, u32 idx) in sparx5_lg_del() argument
215 WARN_ON(sparx5_lg_get_adjacent(sparx5, layer, group, idx, &prev, &next, in sparx5_lg_del()
218 if (sparx5_lg_is_singular(sparx5, layer, group)) { in sparx5_lg_del()
220 } else if (sparx5_lg_is_last(sparx5, layer, group, idx)) { in sparx5_lg_del()
224 } else if (sparx5_lg_is_first(sparx5, layer, group, idx)) { in sparx5_lg_del()
233 return sparx5_lg_conf_set(sparx5, layer, group, first, idx, next, in sparx5_lg_del()
237 static int sparx5_lg_add(struct sparx5 *sparx5, u32 layer, u32 new_group, in sparx5_lg_add() argument
246 if (sparx5_lg_get_group_by_index(sparx5, layer, idx, &old_group) >= 0) { in sparx5_lg_add()
249 sparx5_lg_del(sparx5, layer, old_group, idx); in sparx5_lg_add()
259 if (sparx5_lg_is_empty(sparx5, layer, new_group)) in sparx5_lg_add()
262 next = sparx5_lg_get_first(sparx5, layer, new_group); in sparx5_lg_add()
264 return sparx5_lg_conf_set(sparx5, layer, new_group, first, idx, next, in sparx5_lg_add()
272 int (*sparx5_lg_action)(struct sparx5 *, u32, u32, u32); in sparx5_shaper_conf_set()
273 struct sparx5 *sparx5 = port->sparx5; in sparx5_shaper_conf_set() local
282 HSCH_HSCH_CFG_CFG_HSCH_LAYER, sparx5, HSCH_HSCH_CFG_CFG); in sparx5_shaper_conf_set()
286 sparx5, HSCH_SE_CFG(idx)); in sparx5_shaper_conf_set()
291 sparx5, HSCH_CIR_CFG(idx)); in sparx5_shaper_conf_set()
294 sparx5_lg_action(sparx5, layer, group, idx); in sparx5_shaper_conf_set()
313 port->sparx5, HSCH_HSCH_CFG_CFG); in sparx5_dwrr_conf_set()
317 HSCH_SE_CFG_SE_DWRR_CNT, port->sparx5, in sparx5_dwrr_conf_set()
322 HSCH_DWRR_ENTRY_DWRR_COST, port->sparx5, in sparx5_dwrr_conf_set()
329 static int sparx5_leak_groups_init(struct sparx5 *sparx5) in sparx5_leak_groups_init() argument
337 sys_clk_per_100ps = spx5_rd(sparx5, HSCH_SYS_CLK_PER); in sparx5_leak_groups_init()
377 sparx5_lg_disable(sparx5, i, ii); in sparx5_leak_groups_init()
384 int sparx5_qos_init(struct sparx5 *sparx5) in sparx5_qos_init() argument
388 ret = sparx5_leak_groups_init(sparx5); in sparx5_qos_init()
467 sparx5_lg_get_group_by_index(port->sparx5, layer, idx, &group); in sparx5_tc_tbf_del()
494 /* On the sparx5, bands with higher indexes are preferred and in sparx5_tc_ets_add()