Lines Matching refs:lpm_tree

139 static void mlxsw_sp_lpm_tree_hold(struct mlxsw_sp_lpm_tree *lpm_tree);
141 struct mlxsw_sp_lpm_tree *lpm_tree);
426 struct mlxsw_sp_lpm_tree *lpm_tree; member
445 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_fib_create() local
449 lpm_tree = mlxsw_sp->router->lpm.proto_trees[proto]; in mlxsw_sp_fib_create()
459 fib->lpm_tree = lpm_tree; in mlxsw_sp_fib_create()
460 mlxsw_sp_lpm_tree_hold(lpm_tree); in mlxsw_sp_fib_create()
461 err = mlxsw_sp_vr_lpm_tree_bind(mlxsw_sp, fib, lpm_tree->id); in mlxsw_sp_fib_create()
467 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_fib_create()
477 mlxsw_sp_lpm_tree_put(mlxsw_sp, fib->lpm_tree); in mlxsw_sp_fib_destroy()
486 static struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_tree_find_unused() local
490 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_tree_find_unused()
491 if (lpm_tree->ref_count == 0) in mlxsw_sp_lpm_tree_find_unused()
492 return lpm_tree; in mlxsw_sp_lpm_tree_find_unused()
498 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_alloc() argument
503 (enum mlxsw_reg_ralxx_protocol) lpm_tree->proto, in mlxsw_sp_lpm_tree_alloc()
504 lpm_tree->id); in mlxsw_sp_lpm_tree_alloc()
509 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_free() argument
514 (enum mlxsw_reg_ralxx_protocol) lpm_tree->proto, in mlxsw_sp_lpm_tree_free()
515 lpm_tree->id); in mlxsw_sp_lpm_tree_free()
522 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_left_struct_set() argument
532 mlxsw_reg_ralst_pack(ralst_pl, root_bin, lpm_tree->id); in mlxsw_sp_lpm_tree_left_struct_set()
548 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_tree_create() local
551 lpm_tree = mlxsw_sp_lpm_tree_find_unused(mlxsw_sp); in mlxsw_sp_lpm_tree_create()
552 if (!lpm_tree) in mlxsw_sp_lpm_tree_create()
554 lpm_tree->proto = proto; in mlxsw_sp_lpm_tree_create()
555 err = mlxsw_sp_lpm_tree_alloc(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_create()
560 lpm_tree); in mlxsw_sp_lpm_tree_create()
563 memcpy(&lpm_tree->prefix_usage, prefix_usage, in mlxsw_sp_lpm_tree_create()
564 sizeof(lpm_tree->prefix_usage)); in mlxsw_sp_lpm_tree_create()
565 memset(&lpm_tree->prefix_ref_count, 0, in mlxsw_sp_lpm_tree_create()
566 sizeof(lpm_tree->prefix_ref_count)); in mlxsw_sp_lpm_tree_create()
567 lpm_tree->ref_count = 1; in mlxsw_sp_lpm_tree_create()
568 return lpm_tree; in mlxsw_sp_lpm_tree_create()
571 mlxsw_sp_lpm_tree_free(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_create()
576 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_destroy() argument
578 mlxsw_sp_lpm_tree_free(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_destroy()
586 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_tree_get() local
590 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_tree_get()
591 if (lpm_tree->ref_count != 0 && in mlxsw_sp_lpm_tree_get()
592 lpm_tree->proto == proto && in mlxsw_sp_lpm_tree_get()
593 mlxsw_sp_prefix_usage_eq(&lpm_tree->prefix_usage, in mlxsw_sp_lpm_tree_get()
595 mlxsw_sp_lpm_tree_hold(lpm_tree); in mlxsw_sp_lpm_tree_get()
596 return lpm_tree; in mlxsw_sp_lpm_tree_get()
602 static void mlxsw_sp_lpm_tree_hold(struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_hold() argument
604 lpm_tree->ref_count++; in mlxsw_sp_lpm_tree_hold()
608 struct mlxsw_sp_lpm_tree *lpm_tree) in mlxsw_sp_lpm_tree_put() argument
610 if (--lpm_tree->ref_count == 0) in mlxsw_sp_lpm_tree_put()
611 mlxsw_sp_lpm_tree_destroy(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_put()
619 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_init() local
635 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_init()
636 lpm_tree->id = i + MLXSW_SP_LPM_TREE_MIN; in mlxsw_sp_lpm_init()
639 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, in mlxsw_sp_lpm_init()
641 if (IS_ERR(lpm_tree)) { in mlxsw_sp_lpm_init()
642 err = PTR_ERR(lpm_tree); in mlxsw_sp_lpm_init()
645 mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV4] = lpm_tree; in mlxsw_sp_lpm_init()
647 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, in mlxsw_sp_lpm_init()
649 if (IS_ERR(lpm_tree)) { in mlxsw_sp_lpm_init()
650 err = PTR_ERR(lpm_tree); in mlxsw_sp_lpm_init()
653 mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV6] = lpm_tree; in mlxsw_sp_lpm_init()
658 lpm_tree = mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV4]; in mlxsw_sp_lpm_init()
659 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_init()
667 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_lpm_fini() local
669 lpm_tree = mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV6]; in mlxsw_sp_lpm_fini()
670 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_fini()
672 lpm_tree = mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV4]; in mlxsw_sp_lpm_fini()
673 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_fini()
850 if (fib->lpm_tree->id == tree_id) in mlxsw_sp_vr_lpm_tree_should_replace()
859 struct mlxsw_sp_lpm_tree *old_tree = fib->lpm_tree; in mlxsw_sp_vr_lpm_tree_replace()
862 fib->lpm_tree = new_tree; in mlxsw_sp_vr_lpm_tree_replace()
872 fib->lpm_tree = old_tree; in mlxsw_sp_vr_lpm_tree_replace()
4310 struct mlxsw_sp_lpm_tree *lpm_tree; in mlxsw_sp_fib_lpm_tree_link() local
4313 lpm_tree = mlxsw_sp->router->lpm.proto_trees[fib->proto]; in mlxsw_sp_fib_lpm_tree_link()
4314 if (lpm_tree->prefix_ref_count[fib_node->key.prefix_len] != 0) in mlxsw_sp_fib_lpm_tree_link()
4317 mlxsw_sp_prefix_usage_cpy(&req_prefix_usage, &lpm_tree->prefix_usage); in mlxsw_sp_fib_lpm_tree_link()
4319 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, in mlxsw_sp_fib_lpm_tree_link()
4321 if (IS_ERR(lpm_tree)) in mlxsw_sp_fib_lpm_tree_link()
4322 return PTR_ERR(lpm_tree); in mlxsw_sp_fib_lpm_tree_link()
4324 err = mlxsw_sp_vrs_lpm_tree_replace(mlxsw_sp, fib, lpm_tree); in mlxsw_sp_fib_lpm_tree_link()
4329 lpm_tree->prefix_ref_count[fib_node->key.prefix_len]++; in mlxsw_sp_fib_lpm_tree_link()
4333 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_fib_lpm_tree_link()
4340 struct mlxsw_sp_lpm_tree *lpm_tree = fib_node->fib->lpm_tree; in mlxsw_sp_fib_lpm_tree_unlink() local
4345 if (--lpm_tree->prefix_ref_count[fib_node->key.prefix_len] != 0) in mlxsw_sp_fib_lpm_tree_unlink()
4350 mlxsw_sp_prefix_usage_cpy(&req_prefix_usage, &lpm_tree->prefix_usage); in mlxsw_sp_fib_lpm_tree_unlink()
4353 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, in mlxsw_sp_fib_lpm_tree_unlink()
4355 if (IS_ERR(lpm_tree)) in mlxsw_sp_fib_lpm_tree_unlink()
4358 err = mlxsw_sp_vrs_lpm_tree_replace(mlxsw_sp, fib, lpm_tree); in mlxsw_sp_fib_lpm_tree_unlink()
4365 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_fib_lpm_tree_unlink()