Lines Matching refs:sla
83 struct rl_sla *sla; in validate_sla_id() local
90 sla = accel_dev->rate_limiting->sla[sla_id]; in validate_sla_id()
92 if (!sla) { in validate_sla_id()
97 if (sla->type != RL_LEAF) { in validate_sla_id()
132 parent_sla = rl_data->sla[input_parent_id]; in find_parent()
243 static int prepare_rp_ids(struct adf_accel_dev *accel_dev, struct rl_sla *sla, in prepare_rp_ids() argument
246 enum adf_cfg_service_type arb_srv = srv_to_cfg_svc_type(sla->srv); in prepare_rp_ids()
249 size_t rp_cnt_max = ARRAY_SIZE(sla->ring_pairs_ids); in prepare_rp_ids()
273 sla->ring_pairs_ids[cnt++] = rp_id; in prepare_rp_ids()
276 sla->ring_pairs_cnt = cnt; in prepare_rp_ids()
281 static void mark_rps_usage(struct rl_sla *sla, bool *rp_in_use, bool used) in mark_rps_usage() argument
286 for (i = 0; i < sla->ring_pairs_cnt; i++) { in mark_rps_usage()
287 rp_id = sla->ring_pairs_ids[i]; in mark_rps_usage()
293 struct rl_sla *sla, bool clear) in assign_rps_to_leaf() argument
298 u32 node_id = clear ? 0U : (sla->node_id & LEAF_MASK); in assign_rps_to_leaf()
302 for (i = 0; i < sla->ring_pairs_cnt; i++) { in assign_rps_to_leaf()
303 offset = base_offset + (RL_CSR_SIZE * sla->ring_pairs_ids[i]); in assign_rps_to_leaf()
309 struct rl_sla *sla, bool clear) in assign_leaf_to_cluster() argument
314 u32 node_id = sla->node_id & LEAF_MASK; in assign_leaf_to_cluster()
315 u32 parent_id = clear ? 0U : (sla->parent->node_id & CLUSTER_MASK); in assign_leaf_to_cluster()
323 struct rl_sla *sla, bool clear) in assign_cluster_to_root() argument
328 u32 node_id = sla->node_id & CLUSTER_MASK; in assign_cluster_to_root()
329 u32 parent_id = clear ? 0U : (sla->parent->node_id & ROOT_MASK); in assign_cluster_to_root()
337 struct rl_sla *sla, bool clear_assignment) in assign_node_to_parent() argument
339 switch (sla->type) { in assign_node_to_parent()
341 assign_rps_to_leaf(accel_dev, sla, clear_assignment); in assign_node_to_parent()
342 assign_leaf_to_cluster(accel_dev, sla, clear_assignment); in assign_node_to_parent()
345 assign_cluster_to_root(accel_dev, sla, clear_assignment); in assign_node_to_parent()
396 struct rl_sla *sla) in can_node_afford_update() argument
398 u32 cir_in_use = sla->cir - sla->rem_cir; in can_node_afford_update()
405 if (sla_in->pir < sla->pir && sla->type != RL_LEAF && cir_in_use > 0) in can_node_afford_update()
411 static bool is_enough_budget(struct adf_rl *rl_data, struct rl_sla *sla, in is_enough_budget() argument
416 struct rl_sla *parent = sla->parent; in is_enough_budget()
422 switch (sla->type) { in is_enough_budget()
424 ret &= can_parent_afford_sla(sla_in, parent, sla->cir, in is_enough_budget()
428 ret &= can_parent_afford_sla(sla_in, parent, sla->cir, in is_enough_budget()
432 ret &= can_node_afford_update(sla_in, sla); in is_enough_budget()
437 ret &= can_node_afford_update(sla_in, sla); in is_enough_budget()
448 static void update_budget(struct rl_sla *sla, u32 old_cir, bool is_update) in update_budget() argument
450 switch (sla->type) { in update_budget()
453 sla->parent->rem_cir += old_cir; in update_budget()
455 sla->parent->rem_cir -= sla->cir; in update_budget()
456 sla->rem_cir = 0; in update_budget()
460 sla->parent->rem_cir += old_cir; in update_budget()
461 sla->rem_cir = sla->cir - (old_cir - sla->rem_cir); in update_budget()
463 sla->rem_cir = sla->cir; in update_budget()
466 sla->parent->rem_cir -= sla->cir; in update_budget()
470 sla->rem_cir = sla->cir - (old_cir - sla->rem_cir); in update_budget()
472 sla->rem_cir = sla->cir; in update_budget()
491 while (i < RL_NODES_CNT_MAX && rl_data->sla[i++]) in get_next_free_sla_id()
509 static int get_next_free_node_id(struct adf_rl *rl_data, struct rl_sla *sla) in get_next_free_node_id() argument
523 switch (sla->type) { in get_next_free_node_id()
525 i = sla->srv * rp_per_leaf; in get_next_free_node_id()
531 i = sla->srv; in get_next_free_node_id()
537 return sla->srv; in get_next_free_node_id()
653 struct rl_sla *sla; in add_new_sla_entry() local
656 sla = kzalloc(sizeof(*sla), GFP_KERNEL); in add_new_sla_entry()
657 if (!sla) { in add_new_sla_entry()
661 *sla_out = sla; in add_new_sla_entry()
670 sla->srv = sla_in->srv; in add_new_sla_entry()
671 sla->type = sla_in->type; in add_new_sla_entry()
672 ret = get_next_free_node_id(rl_data, sla); in add_new_sla_entry()
678 sla->node_id = ret; in add_new_sla_entry()
686 sla->sla_id = ret; in add_new_sla_entry()
688 sla->parent = find_parent(rl_data, sla_in); in add_new_sla_entry()
689 if (!sla->parent && sla->type != RL_ROOT) { in add_new_sla_entry()
700 if (sla->type == RL_LEAF) { in add_new_sla_entry()
701 ret = prepare_rp_ids(accel_dev, sla, sla_in->rp_mask); in add_new_sla_entry()
702 if (!sla->ring_pairs_cnt || ret) { in add_new_sla_entry()
715 kfree(sla); in add_new_sla_entry()
764 static void clear_sla(struct adf_rl *rl_data, struct rl_sla *sla) in clear_sla() argument
771 sla_id = sla->sla_id; in clear_sla()
772 node_id = sla->node_id; in clear_sla()
773 old_cir = sla->cir; in clear_sla()
774 sla->cir = 0; in clear_sla()
775 sla->pir = 0; in clear_sla()
777 for (i = 0; i < sla->ring_pairs_cnt; i++) in clear_sla()
778 rp_in_use[sla->ring_pairs_ids[i]] = false; in clear_sla()
780 update_budget(sla, old_cir, true); in clear_sla()
781 adf_rl_get_sla_arr_of_type(rl_data, sla->type, &sla_type_arr); in clear_sla()
782 assign_node_to_parent(rl_data->accel_dev, sla, true); in clear_sla()
783 adf_rl_send_admin_delete_msg(rl_data->accel_dev, node_id, sla->type); in clear_sla()
784 mark_rps_usage(sla, rl_data->rp_in_use, false); in clear_sla()
786 kfree(sla); in clear_sla()
787 rl_data->sla[sla_id] = NULL; in clear_sla()
799 if (!rl_data->sla[sla_id]) in free_all_sla()
802 kfree(rl_data->sla[sla_id]); in free_all_sla()
803 rl_data->sla[sla_id] = NULL; in free_all_sla()
826 struct rl_sla *sla = NULL; in add_update_sla() local
848 sla = rl_data->sla[sla_in->sla_id]; in add_update_sla()
849 old_cir = sla->cir; in add_update_sla()
851 ret = add_new_sla_entry(accel_dev, sla_in, &sla); in add_update_sla()
856 if (!is_enough_budget(rl_data, sla, sla_in, is_update)) { in add_update_sla()
863 sla->cir = sla_in->cir; in add_update_sla()
864 sla->pir = sla_in->pir; in add_update_sla()
867 assign_node_to_parent(accel_dev, sla, false); in add_update_sla()
868 ret = adf_rl_send_admin_add_update_msg(accel_dev, sla, is_update); in add_update_sla()
874 update_budget(sla, old_cir, is_update); in add_update_sla()
877 mark_rps_usage(sla, rl_data->rp_in_use, true); in add_update_sla()
878 adf_rl_get_sla_arr_of_type(rl_data, sla->type, &sla_type_arr); in add_update_sla()
879 sla_type_arr[sla->node_id] = sla; in add_update_sla()
880 rl_data->sla[sla->sla_id] = sla; in add_update_sla()
883 sla_in->sla_id = sla->sla_id; in add_update_sla()
889 kfree(sla); in add_update_sla()
942 struct rl_sla *sla; in adf_rl_get_sla() local
949 sla = accel_dev->rate_limiting->sla[sla_in->sla_id]; in adf_rl_get_sla()
950 sla_in->type = sla->type; in adf_rl_get_sla()
951 sla_in->srv = sla->srv; in adf_rl_get_sla()
952 sla_in->cir = sla->cir; in adf_rl_get_sla()
953 sla_in->pir = sla->pir; in adf_rl_get_sla()
955 if (sla->parent) in adf_rl_get_sla()
956 sla_in->parent_id = sla->parent->sla_id; in adf_rl_get_sla()
960 for (i = 0; i < sla->ring_pairs_cnt; i++) in adf_rl_get_sla()
961 sla_in->rp_mask |= BIT(sla->ring_pairs_ids[i]); in adf_rl_get_sla()
987 struct rl_sla *sla = NULL; in adf_rl_get_capability_remaining() local
994 sla = rl_data->sla[sla_id]; in adf_rl_get_capability_remaining()
996 if (sla->srv == srv && sla->type <= RL_CLUSTER) in adf_rl_get_capability_remaining()
1005 sla = rl_data->cluster[i]; in adf_rl_get_capability_remaining()
1012 return sla->rem_cir; in adf_rl_get_capability_remaining()
1027 struct rl_sla *sla; in adf_rl_remove_sla() local
1035 sla = rl_data->sla[sla_id]; in adf_rl_remove_sla()
1037 if (sla->type < RL_LEAF && sla->rem_cir != sla->cir) { in adf_rl_remove_sla()
1044 clear_sla(rl_data, sla); in adf_rl_remove_sla()