Lines Matching refs:layer

79 static u32 sparx5_lg_get_leak_time(struct sparx5 *sparx5, u32 layer, u32 group)  in sparx5_lg_get_leak_time()  argument
83 value = spx5_rd(sparx5, HSCH_HSCH_TIMER_CFG(layer, group)); in sparx5_lg_get_leak_time()
87 static void sparx5_lg_set_leak_time(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_set_leak_time() argument
91 HSCH_HSCH_TIMER_CFG(layer, group)); in sparx5_lg_set_leak_time()
94 static u32 sparx5_lg_get_first(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_get_first() argument
98 value = spx5_rd(sparx5, HSCH_HSCH_LEAK_CFG(layer, group)); in sparx5_lg_get_first()
102 static u32 sparx5_lg_get_next(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_get_next() argument
112 static u32 sparx5_lg_get_last(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_get_last() argument
116 itr = sparx5_lg_get_first(sparx5, layer, group); in sparx5_lg_get_last()
119 next = sparx5_lg_get_next(sparx5, layer, group, itr); in sparx5_lg_get_last()
127 static bool sparx5_lg_is_last(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_is_last() argument
130 return idx == sparx5_lg_get_next(sparx5, layer, group, idx); in sparx5_lg_is_last()
133 static bool sparx5_lg_is_first(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_is_first() argument
136 return idx == sparx5_lg_get_first(sparx5, layer, group); in sparx5_lg_is_first()
139 static bool sparx5_lg_is_empty(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_is_empty() argument
141 return sparx5_lg_get_leak_time(sparx5, layer, group) == 0; in sparx5_lg_is_empty()
144 static bool sparx5_lg_is_singular(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_is_singular() argument
146 if (sparx5_lg_is_empty(sparx5, layer, group)) in sparx5_lg_is_singular()
149 return sparx5_lg_get_first(sparx5, layer, group) == in sparx5_lg_is_singular()
150 sparx5_lg_get_last(sparx5, layer, group); in sparx5_lg_is_singular()
153 static void sparx5_lg_enable(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_enable() argument
156 sparx5_lg_set_leak_time(sparx5, layer, group, leak_time); in sparx5_lg_enable()
159 static void sparx5_lg_disable(struct sparx5 *sparx5, u32 layer, u32 group) in sparx5_lg_disable() argument
161 sparx5_lg_set_leak_time(sparx5, layer, group, 0); in sparx5_lg_disable()
164 static int sparx5_lg_get_group_by_index(struct sparx5 *sparx5, u32 layer, in sparx5_lg_get_group_by_index() argument
171 if (sparx5_lg_is_empty(sparx5, layer, i)) in sparx5_lg_get_group_by_index()
174 itr = sparx5_lg_get_first(sparx5, layer, i); in sparx5_lg_get_group_by_index()
177 next = sparx5_lg_get_next(sparx5, layer, i, itr); in sparx5_lg_get_group_by_index()
193 static int sparx5_lg_get_group_by_rate(u32 layer, u32 rate, u32 *group) in sparx5_lg_get_group_by_rate() argument
195 struct sparx5_layer *l = &layers[layer]; in sparx5_lg_get_group_by_rate()
210 static int sparx5_lg_get_adjacent(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_get_adjacent() argument
215 *first = sparx5_lg_get_first(sparx5, layer, group); in sparx5_lg_get_adjacent()
221 *next = sparx5_lg_get_next(sparx5, layer, group, itr); in sparx5_lg_get_adjacent()
236 static int sparx5_lg_conf_set(struct sparx5 *sparx5, u32 layer, u32 group, in sparx5_lg_conf_set() argument
239 u32 leak_time = layers[layer].leak_groups[group].leak_time; in sparx5_lg_conf_set()
242 sparx5_lg_disable(sparx5, layer, group); in sparx5_lg_conf_set()
248 spx5_rmw(HSCH_HSCH_CFG_CFG_HSCH_LAYER_SET(layer), in sparx5_lg_conf_set()
258 HSCH_HSCH_LEAK_CFG(layer, group)); in sparx5_lg_conf_set()
261 sparx5_lg_enable(sparx5, layer, group, leak_time); in sparx5_lg_conf_set()
266 static int sparx5_lg_del(struct sparx5 *sparx5, u32 layer, u32 group, u32 idx) in sparx5_lg_del() argument
272 WARN_ON(sparx5_lg_get_adjacent(sparx5, layer, group, idx, &prev, &next, in sparx5_lg_del()
275 if (sparx5_lg_is_singular(sparx5, layer, group)) { in sparx5_lg_del()
277 } else if (sparx5_lg_is_last(sparx5, layer, group, idx)) { in sparx5_lg_del()
281 } else if (sparx5_lg_is_first(sparx5, layer, group, idx)) { in sparx5_lg_del()
290 return sparx5_lg_conf_set(sparx5, layer, group, first, idx, next, in sparx5_lg_del()
294 static int sparx5_lg_add(struct sparx5 *sparx5, u32 layer, u32 new_group, in sparx5_lg_add() argument
299 pr_debug("ADD: layer: %d, new_group: %d, idx: %d", layer, new_group, in sparx5_lg_add()
303 if (sparx5_lg_get_group_by_index(sparx5, layer, idx, &old_group) >= 0) { in sparx5_lg_add()
306 sparx5_lg_del(sparx5, layer, old_group, idx); in sparx5_lg_add()
316 if (sparx5_lg_is_empty(sparx5, layer, new_group)) in sparx5_lg_add()
319 next = sparx5_lg_get_first(sparx5, layer, new_group); in sparx5_lg_add()
321 return sparx5_lg_conf_set(sparx5, layer, new_group, first, idx, next, in sparx5_lg_add()
326 const struct sparx5_shaper *sh, u32 layer, in sparx5_shaper_conf_set() argument
338 spx5_rmw(HSCH_HSCH_CFG_CFG_HSCH_LAYER_SET(layer), in sparx5_shaper_conf_set()
351 sparx5_lg_action(sparx5, layer, group, idx); in sparx5_shaper_conf_set()
388 struct sparx5_layer *layer; in sparx5_leak_groups_init() local
397 layer = &layers[i]; in sparx5_leak_groups_init()
399 lg = &layer->leak_groups[ii]; in sparx5_leak_groups_init()
491 u32 layer, u32 idx) in sparx5_tc_tbf_add() argument
502 if (sparx5_lg_get_group_by_rate(layer, sh.rate, &group) < 0) { in sparx5_tc_tbf_add()
508 lg = &layers[layer].leak_groups[group]; in sparx5_tc_tbf_add()
522 return sparx5_shaper_conf_set(port, &sh, layer, idx, group); in sparx5_tc_tbf_add()
525 int sparx5_tc_tbf_del(struct sparx5_port *port, u32 layer, u32 idx) in sparx5_tc_tbf_del() argument
530 sparx5_lg_get_group_by_index(port->sparx5, layer, idx, &group); in sparx5_tc_tbf_del()
532 return sparx5_shaper_conf_set(port, &sh, layer, idx, group); in sparx5_tc_tbf_del()