Lines Matching refs:lpm_tree

120 static void mlxsw_sp_lpm_tree_hold(struct mlxsw_sp_lpm_tree *lpm_tree);
122 struct mlxsw_sp_lpm_tree *lpm_tree);
410 struct mlxsw_sp_lpm_tree *lpm_tree; member
431 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_fib_create() local
435 lpm_tree = mlxsw_sp->router->lpm.proto_trees[proto]; in mlxsw_sp_fib_create()
445 fib->lpm_tree = lpm_tree; in mlxsw_sp_fib_create()
446 mlxsw_sp_lpm_tree_hold(lpm_tree); in mlxsw_sp_fib_create()
447 err = mlxsw_sp_vr_lpm_tree_bind(mlxsw_sp, fib, lpm_tree->id); in mlxsw_sp_fib_create()
453 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_fib_create()
463 mlxsw_sp_lpm_tree_put(mlxsw_sp, fib->lpm_tree); in mlxsw_sp_fib_destroy()
472 static struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_tree_find_unused() local
476 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_tree_find_unused()
477 if (lpm_tree->ref_count == 0) in mlxsw_sp_lpm_tree_find_unused()
478 return lpm_tree; in mlxsw_sp_lpm_tree_find_unused()
484 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_alloc() argument
489 (enum mlxsw_reg_ralxx_protocol) lpm_tree->proto, in mlxsw_sp_lpm_tree_alloc()
490 lpm_tree->id); in mlxsw_sp_lpm_tree_alloc()
495 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_free() argument
500 (enum mlxsw_reg_ralxx_protocol) lpm_tree->proto, in mlxsw_sp_lpm_tree_free()
501 lpm_tree->id); in mlxsw_sp_lpm_tree_free()
508 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_left_struct_set() argument
518 mlxsw_reg_ralst_pack(ralst_pl, root_bin, lpm_tree->id); in mlxsw_sp_lpm_tree_left_struct_set()
534 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_tree_create() local
537 lpm_tree = mlxsw_sp_lpm_tree_find_unused(mlxsw_sp); in mlxsw_sp_lpm_tree_create()
538 if (!lpm_tree) in mlxsw_sp_lpm_tree_create()
540 lpm_tree->proto = proto; in mlxsw_sp_lpm_tree_create()
541 err = mlxsw_sp_lpm_tree_alloc(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_create()
546 lpm_tree); in mlxsw_sp_lpm_tree_create()
549 memcpy(&lpm_tree->prefix_usage, prefix_usage, in mlxsw_sp_lpm_tree_create()
550 sizeof(lpm_tree->prefix_usage)); in mlxsw_sp_lpm_tree_create()
551 memset(&lpm_tree->prefix_ref_count, 0, in mlxsw_sp_lpm_tree_create()
552 sizeof(lpm_tree->prefix_ref_count)); in mlxsw_sp_lpm_tree_create()
553 lpm_tree->ref_count = 1; in mlxsw_sp_lpm_tree_create()
554 return lpm_tree; in mlxsw_sp_lpm_tree_create()
557 mlxsw_sp_lpm_tree_free(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_create()
562 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_destroy() argument
564 mlxsw_sp_lpm_tree_free(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_destroy()
572 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_tree_get() local
576 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_tree_get()
577 if (lpm_tree->ref_count != 0 && in mlxsw_sp_lpm_tree_get()
578 lpm_tree->proto == proto && in mlxsw_sp_lpm_tree_get()
579 mlxsw_sp_prefix_usage_eq(&lpm_tree->prefix_usage, in mlxsw_sp_lpm_tree_get()
581 mlxsw_sp_lpm_tree_hold(lpm_tree); in mlxsw_sp_lpm_tree_get()
582 return lpm_tree; in mlxsw_sp_lpm_tree_get()
588 static void mlxsw_sp_lpm_tree_hold(struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_hold() argument
590 lpm_tree->ref_count++; in mlxsw_sp_lpm_tree_hold()
594 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_put() argument
596 if (--lpm_tree->ref_count == 0) in mlxsw_sp_lpm_tree_put()
597 mlxsw_sp_lpm_tree_destroy(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_put()
605 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_init() local
621 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_init()
622 lpm_tree->id = i + MLXSW_SP_LPM_TREE_MIN; in mlxsw_sp_lpm_init()
625 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, in mlxsw_sp_lpm_init()
627 if (IS_ERR(lpm_tree)) { in mlxsw_sp_lpm_init()
628 err = PTR_ERR(lpm_tree); in mlxsw_sp_lpm_init()
631 mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV4] = lpm_tree; in mlxsw_sp_lpm_init()
633 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, in mlxsw_sp_lpm_init()
635 if (IS_ERR(lpm_tree)) { in mlxsw_sp_lpm_init()
636 err = PTR_ERR(lpm_tree); in mlxsw_sp_lpm_init()
639 mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV6] = lpm_tree; in mlxsw_sp_lpm_init()
644 lpm_tree = mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV4]; in mlxsw_sp_lpm_init()
645 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_init()
653 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_fini() local
655 lpm_tree = mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV6]; in mlxsw_sp_lpm_fini()
656 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_fini()
658 lpm_tree = mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV4]; in mlxsw_sp_lpm_fini()
659 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_fini()
854 if (fib->lpm_tree->id == tree_id) in mlxsw_sp_vr_lpm_tree_should_replace()
863 struct mlxsw_sp_lpm_tree *old_tree = fib->lpm_tree; in mlxsw_sp_vr_lpm_tree_replace()
866 fib->lpm_tree = new_tree; in mlxsw_sp_vr_lpm_tree_replace()
876 fib->lpm_tree = old_tree; in mlxsw_sp_vr_lpm_tree_replace()
4736 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_fib_lpm_tree_link() local
4739 lpm_tree = mlxsw_sp->router->lpm.proto_trees[fib->proto]; in mlxsw_sp_fib_lpm_tree_link()
4740 if (lpm_tree->prefix_ref_count[fib_node->key.prefix_len] != 0) in mlxsw_sp_fib_lpm_tree_link()
4743 mlxsw_sp_prefix_usage_cpy(&req_prefix_usage, &lpm_tree->prefix_usage); in mlxsw_sp_fib_lpm_tree_link()
4745 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, in mlxsw_sp_fib_lpm_tree_link()
4747 if (IS_ERR(lpm_tree)) in mlxsw_sp_fib_lpm_tree_link()
4748 return PTR_ERR(lpm_tree); in mlxsw_sp_fib_lpm_tree_link()
4750 err = mlxsw_sp_vrs_lpm_tree_replace(mlxsw_sp, fib, lpm_tree); in mlxsw_sp_fib_lpm_tree_link()
4755 lpm_tree->prefix_ref_count[fib_node->key.prefix_len]++; in mlxsw_sp_fib_lpm_tree_link()
4759 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_fib_lpm_tree_link()
4766 struct mlxsw_sp_lpm_tree *lpm_tree = fib_node->fib->lpm_tree; in mlxsw_sp_fib_lpm_tree_unlink() local
4771 if (--lpm_tree->prefix_ref_count[fib_node->key.prefix_len] != 0) in mlxsw_sp_fib_lpm_tree_unlink()
4776 mlxsw_sp_prefix_usage_cpy(&req_prefix_usage, &lpm_tree->prefix_usage); in mlxsw_sp_fib_lpm_tree_unlink()
4779 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, in mlxsw_sp_fib_lpm_tree_unlink()
4781 if (IS_ERR(lpm_tree)) in mlxsw_sp_fib_lpm_tree_unlink()
4784 err = mlxsw_sp_vrs_lpm_tree_replace(mlxsw_sp, fib, lpm_tree); in mlxsw_sp_fib_lpm_tree_unlink()
4791 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_fib_lpm_tree_unlink()