Lines Matching refs:vr
476 struct mlxsw_sp_vr *vr; member
520 struct mlxsw_sp_vr *vr, in mlxsw_sp_fib_create() argument
528 err = ll_ops->init(mlxsw_sp, vr->id, proto); in mlxsw_sp_fib_create()
541 fib->vr = vr; in mlxsw_sp_fib_create()
770 static bool mlxsw_sp_vr_is_used(const struct mlxsw_sp_vr *vr) in mlxsw_sp_vr_is_used() argument
772 return !!vr->fib4 || !!vr->fib6 || in mlxsw_sp_vr_is_used()
773 !!vr->mr_table[MLXSW_SP_L3_PROTO_IPV4] || in mlxsw_sp_vr_is_used()
774 !!vr->mr_table[MLXSW_SP_L3_PROTO_IPV6]; in mlxsw_sp_vr_is_used()
779 struct mlxsw_sp_vr *vr; in mlxsw_sp_vr_find_unused() local
783 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vr_find_unused()
784 if (!mlxsw_sp_vr_is_used(vr)) in mlxsw_sp_vr_find_unused()
785 return vr; in mlxsw_sp_vr_find_unused()
795 mlxsw_reg_xraltb_pack(xraltb_pl, fib->vr->id, in mlxsw_sp_vr_lpm_tree_bind()
807 mlxsw_reg_xraltb_pack(xraltb_pl, fib->vr->id, in mlxsw_sp_vr_lpm_tree_unbind()
823 struct mlxsw_sp_vr *vr; in mlxsw_sp_vr_find() local
829 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vr_find()
830 if (mlxsw_sp_vr_is_used(vr) && vr->tb_id == tb_id) in mlxsw_sp_vr_find()
831 return vr; in mlxsw_sp_vr_find()
839 struct mlxsw_sp_vr *vr; in mlxsw_sp_router_tb_id_vr_id() local
843 vr = mlxsw_sp_vr_find(mlxsw_sp, tb_id); in mlxsw_sp_router_tb_id_vr_id()
844 if (!vr) { in mlxsw_sp_router_tb_id_vr_id()
848 *vr_id = vr->id; in mlxsw_sp_router_tb_id_vr_id()
854 static struct mlxsw_sp_fib *mlxsw_sp_vr_fib(const struct mlxsw_sp_vr *vr, in mlxsw_sp_vr_fib() argument
859 return vr->fib4; in mlxsw_sp_vr_fib()
861 return vr->fib6; in mlxsw_sp_vr_fib()
873 struct mlxsw_sp_vr *vr; in mlxsw_sp_vr_create() local
876 vr = mlxsw_sp_vr_find_unused(mlxsw_sp); in mlxsw_sp_vr_create()
877 if (!vr) { in mlxsw_sp_vr_create()
881 fib4 = mlxsw_sp_fib_create(mlxsw_sp, vr, MLXSW_SP_L3_PROTO_IPV4); in mlxsw_sp_vr_create()
884 fib6 = mlxsw_sp_fib_create(mlxsw_sp, vr, MLXSW_SP_L3_PROTO_IPV6); in mlxsw_sp_vr_create()
889 mr4_table = mlxsw_sp_mr_table_create(mlxsw_sp, vr->id, in mlxsw_sp_vr_create()
895 mr6_table = mlxsw_sp_mr_table_create(mlxsw_sp, vr->id, in mlxsw_sp_vr_create()
902 vr->fib4 = fib4; in mlxsw_sp_vr_create()
903 vr->fib6 = fib6; in mlxsw_sp_vr_create()
904 vr->mr_table[MLXSW_SP_L3_PROTO_IPV4] = mr4_table; in mlxsw_sp_vr_create()
905 vr->mr_table[MLXSW_SP_L3_PROTO_IPV6] = mr6_table; in mlxsw_sp_vr_create()
906 vr->tb_id = tb_id; in mlxsw_sp_vr_create()
907 return vr; in mlxsw_sp_vr_create()
919 struct mlxsw_sp_vr *vr) in mlxsw_sp_vr_destroy() argument
921 mlxsw_sp_mr_table_destroy(vr->mr_table[MLXSW_SP_L3_PROTO_IPV6]); in mlxsw_sp_vr_destroy()
922 vr->mr_table[MLXSW_SP_L3_PROTO_IPV6] = NULL; in mlxsw_sp_vr_destroy()
923 mlxsw_sp_mr_table_destroy(vr->mr_table[MLXSW_SP_L3_PROTO_IPV4]); in mlxsw_sp_vr_destroy()
924 vr->mr_table[MLXSW_SP_L3_PROTO_IPV4] = NULL; in mlxsw_sp_vr_destroy()
925 mlxsw_sp_fib_destroy(mlxsw_sp, vr->fib6); in mlxsw_sp_vr_destroy()
926 vr->fib6 = NULL; in mlxsw_sp_vr_destroy()
927 mlxsw_sp_fib_destroy(mlxsw_sp, vr->fib4); in mlxsw_sp_vr_destroy()
928 vr->fib4 = NULL; in mlxsw_sp_vr_destroy()
934 struct mlxsw_sp_vr *vr; in mlxsw_sp_vr_get() local
937 vr = mlxsw_sp_vr_find(mlxsw_sp, tb_id); in mlxsw_sp_vr_get()
938 if (!vr) in mlxsw_sp_vr_get()
939 vr = mlxsw_sp_vr_create(mlxsw_sp, tb_id, extack); in mlxsw_sp_vr_get()
940 return vr; in mlxsw_sp_vr_get()
943 static void mlxsw_sp_vr_put(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_vr *vr) in mlxsw_sp_vr_put() argument
945 if (!vr->rif_count && list_empty(&vr->fib4->node_list) && in mlxsw_sp_vr_put()
946 list_empty(&vr->fib6->node_list) && in mlxsw_sp_vr_put()
947 mlxsw_sp_mr_table_empty(vr->mr_table[MLXSW_SP_L3_PROTO_IPV4]) && in mlxsw_sp_vr_put()
948 mlxsw_sp_mr_table_empty(vr->mr_table[MLXSW_SP_L3_PROTO_IPV6])) in mlxsw_sp_vr_put()
949 mlxsw_sp_vr_destroy(mlxsw_sp, vr); in mlxsw_sp_vr_put()
953 mlxsw_sp_vr_lpm_tree_should_replace(struct mlxsw_sp_vr *vr, in mlxsw_sp_vr_lpm_tree_should_replace() argument
956 struct mlxsw_sp_fib *fib = mlxsw_sp_vr_fib(vr, proto); in mlxsw_sp_vr_lpm_tree_should_replace()
958 if (!mlxsw_sp_vr_is_used(vr)) in mlxsw_sp_vr_lpm_tree_should_replace()
993 struct mlxsw_sp_vr *vr; in mlxsw_sp_vrs_lpm_tree_replace() local
1000 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vrs_lpm_tree_replace()
1001 if (!mlxsw_sp_vr_lpm_tree_should_replace(vr, proto, old_id)) in mlxsw_sp_vrs_lpm_tree_replace()
1004 mlxsw_sp_vr_fib(vr, proto), in mlxsw_sp_vrs_lpm_tree_replace()
1019 if (!mlxsw_sp_vr_lpm_tree_should_replace(vr, proto, new_id)) in mlxsw_sp_vrs_lpm_tree_replace()
1022 mlxsw_sp_vr_fib(vr, proto), in mlxsw_sp_vrs_lpm_tree_replace()
1030 struct mlxsw_sp_vr *vr; in mlxsw_sp_vrs_init() local
1044 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vrs_init()
1045 vr->id = i; in mlxsw_sp_vrs_init()
1292 struct mlxsw_sp_vr *vr; in mlxsw_sp_router_ip2me_fib_entry_find() local
1297 vr = mlxsw_sp_vr_find(mlxsw_sp, tb_id); in mlxsw_sp_router_ip2me_fib_entry_find()
1298 if (!vr) in mlxsw_sp_router_ip2me_fib_entry_find()
1300 fib = mlxsw_sp_vr_fib(vr, proto); in mlxsw_sp_router_ip2me_fib_entry_find()
3137 key.vr_id = fib->vr->id; in mlxsw_sp_nexthop_group_vr_entry_lookup()
3154 vr_entry->key.vr_id = fib->vr->id; in mlxsw_sp_nexthop_group_vr_entry_create()
5842 fib->ll_ops->fib_entry_pack(op_ctx, fib->proto, op, fib->vr->id, in mlxsw_sp_fib_entry_pack()
6227 struct mlxsw_sp_vr *vr; in mlxsw_sp_fib4_entry_lookup() local
6229 vr = mlxsw_sp_vr_find(mlxsw_sp, fen_info->tb_id); in mlxsw_sp_fib4_entry_lookup()
6230 if (!vr) in mlxsw_sp_fib4_entry_lookup()
6232 fib = mlxsw_sp_vr_fib(vr, MLXSW_SP_L3_PROTO_IPV4); in mlxsw_sp_fib4_entry_lookup()
6410 struct mlxsw_sp_vr *vr; in mlxsw_sp_fib_node_get() local
6413 vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id, NULL); in mlxsw_sp_fib_node_get()
6414 if (IS_ERR(vr)) in mlxsw_sp_fib_node_get()
6415 return ERR_CAST(vr); in mlxsw_sp_fib_node_get()
6416 fib = mlxsw_sp_vr_fib(vr, proto); in mlxsw_sp_fib_node_get()
6437 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_fib_node_get()
6444 struct mlxsw_sp_vr *vr = fib_node->fib->vr; in mlxsw_sp_fib_node_put() local
6450 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_fib_node_put()
7156 struct mlxsw_sp_vr *vr; in mlxsw_sp_fib6_entry_lookup() local
7158 vr = mlxsw_sp_vr_find(mlxsw_sp, rt->fib6_table->tb6_id); in mlxsw_sp_fib6_entry_lookup()
7159 if (!vr) in mlxsw_sp_fib6_entry_lookup()
7161 fib = mlxsw_sp_vr_fib(vr, MLXSW_SP_L3_PROTO_IPV6); in mlxsw_sp_fib6_entry_lookup()
7344 mlxsw_sp_router_fibmr_family_to_table(struct mlxsw_sp_vr *vr, int family) in mlxsw_sp_router_fibmr_family_to_table() argument
7347 return vr->mr_table[MLXSW_SP_L3_PROTO_IPV4]; in mlxsw_sp_router_fibmr_family_to_table()
7349 return vr->mr_table[MLXSW_SP_L3_PROTO_IPV6]; in mlxsw_sp_router_fibmr_family_to_table()
7357 struct mlxsw_sp_vr *vr; in mlxsw_sp_router_fibmr_add() local
7359 vr = mlxsw_sp_vr_get(mlxsw_sp, men_info->tb_id, NULL); in mlxsw_sp_router_fibmr_add()
7360 if (IS_ERR(vr)) in mlxsw_sp_router_fibmr_add()
7361 return PTR_ERR(vr); in mlxsw_sp_router_fibmr_add()
7363 mrt = mlxsw_sp_router_fibmr_family_to_table(vr, men_info->info.family); in mlxsw_sp_router_fibmr_add()
7371 struct mlxsw_sp_vr *vr; in mlxsw_sp_router_fibmr_del() local
7373 vr = mlxsw_sp_vr_find(mlxsw_sp, men_info->tb_id); in mlxsw_sp_router_fibmr_del()
7374 if (WARN_ON(!vr)) in mlxsw_sp_router_fibmr_del()
7377 mrt = mlxsw_sp_router_fibmr_family_to_table(vr, men_info->info.family); in mlxsw_sp_router_fibmr_del()
7379 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_router_fibmr_del()
7388 struct mlxsw_sp_vr *vr; in mlxsw_sp_router_fibmr_vif_add() local
7390 vr = mlxsw_sp_vr_get(mlxsw_sp, ven_info->tb_id, NULL); in mlxsw_sp_router_fibmr_vif_add()
7391 if (IS_ERR(vr)) in mlxsw_sp_router_fibmr_vif_add()
7392 return PTR_ERR(vr); in mlxsw_sp_router_fibmr_vif_add()
7394 mrt = mlxsw_sp_router_fibmr_family_to_table(vr, ven_info->info.family); in mlxsw_sp_router_fibmr_vif_add()
7406 struct mlxsw_sp_vr *vr; in mlxsw_sp_router_fibmr_vif_del() local
7408 vr = mlxsw_sp_vr_find(mlxsw_sp, ven_info->tb_id); in mlxsw_sp_router_fibmr_vif_del()
7409 if (WARN_ON(!vr)) in mlxsw_sp_router_fibmr_vif_del()
7412 mrt = mlxsw_sp_router_fibmr_family_to_table(vr, ven_info->info.family); in mlxsw_sp_router_fibmr_vif_del()
7414 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_router_fibmr_vif_del()
7455 struct mlxsw_sp_vr *vr, in mlxsw_sp_vr_fib_flush() argument
7458 struct mlxsw_sp_fib *fib = mlxsw_sp_vr_fib(vr, proto); in mlxsw_sp_vr_fib_flush()
7475 struct mlxsw_sp_vr *vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_router_fib_flush() local
7477 if (!mlxsw_sp_vr_is_used(vr)) in mlxsw_sp_router_fib_flush()
7481 mlxsw_sp_mr_table_flush(vr->mr_table[j]); in mlxsw_sp_router_fib_flush()
7482 mlxsw_sp_vr_fib_flush(mlxsw_sp, vr, MLXSW_SP_L3_PROTO_IPV4); in mlxsw_sp_router_fib_flush()
7487 if (!mlxsw_sp_vr_is_used(vr)) in mlxsw_sp_router_fib_flush()
7489 mlxsw_sp_vr_fib_flush(mlxsw_sp, vr, MLXSW_SP_L3_PROTO_IPV6); in mlxsw_sp_router_fib_flush()
8157 struct mlxsw_sp_vr *vr; in mlxsw_sp_rif_create() local
8164 vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id ? : RT_TABLE_MAIN, extack); in mlxsw_sp_rif_create()
8165 if (IS_ERR(vr)) in mlxsw_sp_rif_create()
8166 return ERR_CAST(vr); in mlxsw_sp_rif_create()
8167 vr->rif_count++; in mlxsw_sp_rif_create()
8175 rif = mlxsw_sp_rif_alloc(ops->rif_size, rif_index, vr->id, params->dev); in mlxsw_sp_rif_create()
8202 err = mlxsw_sp_mr_rif_add(vr->mr_table[i], rif); in mlxsw_sp_rif_create()
8213 mlxsw_sp_mr_rif_del(vr->mr_table[i], rif); in mlxsw_sp_rif_create()
8224 vr->rif_count--; in mlxsw_sp_rif_create()
8225 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_rif_create()
8234 struct mlxsw_sp_vr *vr; in mlxsw_sp_rif_destroy() local
8238 vr = &mlxsw_sp->router->vrs[rif->vr_id]; in mlxsw_sp_rif_destroy()
8242 mlxsw_sp_mr_rif_del(vr->mr_table[i], rif); in mlxsw_sp_rif_destroy()
8250 vr->rif_count--; in mlxsw_sp_rif_destroy()
8251 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_rif_destroy()
9063 struct mlxsw_sp_vr *vr; in mlxsw_sp_router_port_change_event() local
9070 vr = &mlxsw_sp->router->vrs[rif->vr_id]; in mlxsw_sp_router_port_change_event()
9072 mlxsw_sp_mr_rif_mtu_update(vr->mr_table[i], in mlxsw_sp_router_port_change_event()
9592 mlxsw_sp_ul_rif_create(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_vr *vr, in mlxsw_sp_ul_rif_create() argument
9605 ul_rif = mlxsw_sp_rif_alloc(sizeof(*ul_rif), rif_index, vr->id, NULL); in mlxsw_sp_ul_rif_create()
9636 struct mlxsw_sp_vr *vr; in mlxsw_sp_ul_rif_get() local
9639 vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id, extack); in mlxsw_sp_ul_rif_get()
9640 if (IS_ERR(vr)) in mlxsw_sp_ul_rif_get()
9641 return ERR_CAST(vr); in mlxsw_sp_ul_rif_get()
9643 if (refcount_inc_not_zero(&vr->ul_rif_refcnt)) in mlxsw_sp_ul_rif_get()
9644 return vr->ul_rif; in mlxsw_sp_ul_rif_get()
9646 vr->ul_rif = mlxsw_sp_ul_rif_create(mlxsw_sp, vr, extack); in mlxsw_sp_ul_rif_get()
9647 if (IS_ERR(vr->ul_rif)) { in mlxsw_sp_ul_rif_get()
9648 err = PTR_ERR(vr->ul_rif); in mlxsw_sp_ul_rif_get()
9652 vr->rif_count++; in mlxsw_sp_ul_rif_get()
9653 refcount_set(&vr->ul_rif_refcnt, 1); in mlxsw_sp_ul_rif_get()
9655 return vr->ul_rif; in mlxsw_sp_ul_rif_get()
9658 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_ul_rif_get()
9665 struct mlxsw_sp_vr *vr; in mlxsw_sp_ul_rif_put() local
9667 vr = &mlxsw_sp->router->vrs[ul_rif->vr_id]; in mlxsw_sp_ul_rif_put()
9669 if (!refcount_dec_and_test(&vr->ul_rif_refcnt)) in mlxsw_sp_ul_rif_put()
9672 vr->rif_count--; in mlxsw_sp_ul_rif_put()
9674 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_ul_rif_put()