Lines Matching full:router
490 u16 id; /* virtual router ID */
510 lpm_tree = mlxsw_sp->router->lpm.proto_trees[proto]; in mlxsw_sp_fib_create()
550 for (i = 0; i < mlxsw_sp->router->lpm.tree_count; i++) { in mlxsw_sp_lpm_tree_find_unused()
551 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_tree_find_unused()
650 for (i = 0; i < mlxsw_sp->router->lpm.tree_count; i++) { in mlxsw_sp_lpm_tree_get()
651 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_tree_get()
688 mlxsw_sp->router->lpm.tree_count = max_trees - MLXSW_SP_LPM_TREE_MIN; in mlxsw_sp_lpm_init()
689 mlxsw_sp->router->lpm.trees = kcalloc(mlxsw_sp->router->lpm.tree_count, in mlxsw_sp_lpm_init()
692 if (!mlxsw_sp->router->lpm.trees) in mlxsw_sp_lpm_init()
695 for (i = 0; i < mlxsw_sp->router->lpm.tree_count; i++) { in mlxsw_sp_lpm_init()
696 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_init()
706 mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV4] = lpm_tree; in mlxsw_sp_lpm_init()
714 mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV6] = lpm_tree; in mlxsw_sp_lpm_init()
719 lpm_tree = mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV4]; in mlxsw_sp_lpm_init()
722 kfree(mlxsw_sp->router->lpm.trees); in mlxsw_sp_lpm_init()
730 lpm_tree = mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV6]; in mlxsw_sp_lpm_fini()
733 lpm_tree = mlxsw_sp->router->lpm.proto_trees[MLXSW_SP_L3_PROTO_IPV4]; in mlxsw_sp_lpm_fini()
736 kfree(mlxsw_sp->router->lpm.trees); in mlxsw_sp_lpm_fini()
752 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vr_find_unused()
798 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vr_find()
811 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_tb_id_vr_id()
819 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_tb_id_vr_id()
965 old_tree = mlxsw_sp->router->lpm.proto_trees[proto]; in mlxsw_sp_vrs_lpm_tree_replace()
969 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vrs_lpm_tree_replace()
981 mlxsw_sp->router->lpm.proto_trees[proto] = new_tree; in mlxsw_sp_vrs_lpm_tree_replace()
1007 mlxsw_sp->router->vrs = kcalloc(max_vrs, sizeof(struct mlxsw_sp_vr), in mlxsw_sp_vrs_init()
1009 if (!mlxsw_sp->router->vrs) in mlxsw_sp_vrs_init()
1013 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vrs_init()
1033 kfree(mlxsw_sp->router->vrs); in mlxsw_sp_vrs_fini()
1067 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipipt]; in mlxsw_sp_ipip_ol_ipip_lb_create()
1090 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipipt]; in mlxsw_sp_ipip_entry_alloc()
1125 mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_ipip_entry_dealloc()
1143 if (mlxsw_sp->router->ipip_ops_arr[ipipt]->ul_proto != ul_proto) in mlxsw_sp_ipip_entry_saddr_matches()
1156 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipipt]; in mlxsw_sp_ipip_decap_parsing_depth_inc()
1171 mlxsw_sp->router->ipip_ops_arr[ipipt]; in mlxsw_sp_ipip_decap_parsing_depth_dec()
1312 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_ipip_entry_find_decap()
1361 &mlxsw_sp->router->ipip_list); in mlxsw_sp_ipip_entry_create()
1384 if (mlxsw_sp->router->ipip_ops_arr[ipipt]->ul_proto != ul_proto) in mlxsw_sp_ipip_entry_matches_decap()
1406 list_for_each_entry(ipip_entry, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_entry_find_by_decap()
1426 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_netdev_ipip_type() local
1431 ipip_ops = router->ipip_ops_arr[ipipt]; in mlxsw_sp_netdev_ipip_type()
1453 list_for_each_entry(ipip_entry, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_entry_find_by_ol_dev()
1468 ipip_entry = list_prepare_entry(start, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_entry_find_by_ul_dev()
1470 list_for_each_entry_continue(ipip_entry, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_entry_find_by_ul_dev()
1497 = mlxsw_sp->router->ipip_ops_arr[ipipt]; in mlxsw_sp_netdevice_ipip_can_offload()
1514 ul_proto = mlxsw_sp->router->ipip_ops_arr[ipipt]->ul_proto; in mlxsw_sp_netdevice_ipip_ol_reg_event()
1745 ul_proto = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]->ul_proto; in mlxsw_sp_netdevice_ipip_ul_vrf_event()
1804 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_netdevice_ipip_ol_change_event()
1834 list_for_each_entry_safe(ipip_entry, tmp, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_demote_tunnel_by_saddr()
1852 list_for_each_entry_safe(ipip_entry, tmp, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_demote_tunnel_by_ul_netdev()
1967 &mlxsw_sp->router->ipip_list)) in mlxsw_sp_netdevice_ipip_ul_event()
1989 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_router_nve_promote_decap() local
1993 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_nve_promote_decap()
1995 if (WARN_ON_ONCE(router->nve_decap_config.valid)) { in mlxsw_sp_router_nve_promote_decap()
2000 router->nve_decap_config.ul_tb_id = ul_tb_id; in mlxsw_sp_router_nve_promote_decap()
2001 router->nve_decap_config.tunnel_index = tunnel_index; in mlxsw_sp_router_nve_promote_decap()
2002 router->nve_decap_config.ul_proto = ul_proto; in mlxsw_sp_router_nve_promote_decap()
2003 router->nve_decap_config.ul_sip = *ul_sip; in mlxsw_sp_router_nve_promote_decap()
2004 router->nve_decap_config.valid = true; in mlxsw_sp_router_nve_promote_decap()
2028 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_nve_promote_decap()
2037 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_router_nve_demote_decap() local
2040 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_nve_demote_decap()
2042 if (WARN_ON_ONCE(!router->nve_decap_config.valid)) in mlxsw_sp_router_nve_demote_decap()
2045 router->nve_decap_config.valid = false; in mlxsw_sp_router_nve_demote_decap()
2056 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_nve_demote_decap()
2064 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_router_nve_is_decap() local
2066 return router->nve_decap_config.valid && in mlxsw_sp_router_nve_is_decap()
2067 router->nve_decap_config.ul_tb_id == ul_tb_id && in mlxsw_sp_router_nve_is_decap()
2068 router->nve_decap_config.ul_proto == ul_proto && in mlxsw_sp_router_nve_is_decap()
2069 !memcmp(&router->nve_decap_config.ul_sip, ul_sip, in mlxsw_sp_router_nve_is_decap()
2180 return rhashtable_insert_fast(&mlxsw_sp->router->neigh_ht, in mlxsw_sp_neigh_entry_insert()
2189 rhashtable_remove_fast(&mlxsw_sp->router->neigh_ht, in mlxsw_sp_neigh_entry_remove()
2261 atomic_inc(&mlxsw_sp->router->neighs_update.neigh_count); in mlxsw_sp_neigh_entry_create()
2276 atomic_dec(&mlxsw_sp->router->neighs_update.neigh_count); in mlxsw_sp_neigh_entry_destroy()
2288 return rhashtable_lookup_fast(&mlxsw_sp->router->neigh_ht, in mlxsw_sp_neigh_entry_lookup()
2304 mlxsw_sp->router->neighs_update.interval = jiffies_to_msecs(interval); in mlxsw_sp_router_neighs_update_interval_init()
2322 if (!mlxsw_sp->router->rifs[rif]) { in mlxsw_sp_router_neigh_ent_ipv4_process()
2328 dev = mlxsw_sp->router->rifs[rif]->dev; in mlxsw_sp_router_neigh_ent_ipv4_process()
2351 if (!mlxsw_sp->router->rifs[rif]) { in mlxsw_sp_router_neigh_ent_ipv6_process()
2356 dev = mlxsw_sp->router->rifs[rif]->dev; in mlxsw_sp_router_neigh_ent_ipv6_process()
2449 mutex_lock(&mlxsw_sp->router->lock); in __mlxsw_sp_router_neighs_update_rauhtd()
2463 mutex_unlock(&mlxsw_sp->router->lock); in __mlxsw_sp_router_neighs_update_rauhtd()
2474 if (!atomic_read(&mlxsw_sp->router->neighs_update.neigh_count)) in mlxsw_sp_router_neighs_update_rauhtd()
2497 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_neighs_update_nh()
2498 list_for_each_entry(neigh_entry, &mlxsw_sp->router->nexthop_neighs_list, in mlxsw_sp_router_neighs_update_nh()
2504 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_neighs_update_nh()
2510 unsigned long interval = mlxsw_sp->router->neighs_update.interval; in mlxsw_sp_router_neighs_update_work_schedule()
2512 mlxsw_core_schedule_dw(&mlxsw_sp->router->neighs_update.dw, in mlxsw_sp_router_neighs_update_work_schedule()
2518 struct mlxsw_sp_router *router; in mlxsw_sp_router_neighs_update_work() local
2521 router = container_of(work, struct mlxsw_sp_router, in mlxsw_sp_router_neighs_update_work()
2523 err = mlxsw_sp_router_neighs_update_rauhtd(router->mlxsw_sp); in mlxsw_sp_router_neighs_update_work()
2525 dev_err(router->mlxsw_sp->bus_info->dev, "Could not update kernel for neigh activity"); in mlxsw_sp_router_neighs_update_work()
2527 mlxsw_sp_router_neighs_update_nh(router->mlxsw_sp); in mlxsw_sp_router_neighs_update_work()
2529 mlxsw_sp_router_neighs_update_work_schedule(router->mlxsw_sp); in mlxsw_sp_router_neighs_update_work()
2535 struct mlxsw_sp_router *router; in mlxsw_sp_router_probe_unresolved_nexthops() local
2537 router = container_of(work, struct mlxsw_sp_router, in mlxsw_sp_router_probe_unresolved_nexthops()
2545 mutex_lock(&router->lock); in mlxsw_sp_router_probe_unresolved_nexthops()
2546 list_for_each_entry(neigh_entry, &router->nexthop_neighs_list, in mlxsw_sp_router_probe_unresolved_nexthops()
2550 mutex_unlock(&router->lock); in mlxsw_sp_router_probe_unresolved_nexthops()
2552 mlxsw_core_schedule_dw(&router->nexthop_probe_dw, in mlxsw_sp_router_probe_unresolved_nexthops()
2688 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_neigh_event_work()
2714 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_neigh_event_work()
2748 struct mlxsw_sp_router *router; in mlxsw_sp_router_schedule_work() local
2750 router = container_of(nb, struct mlxsw_sp_router, netevent_nb); in mlxsw_sp_router_schedule_work()
2751 if (!net_eq(net, mlxsw_sp_net(router->mlxsw_sp))) in mlxsw_sp_router_schedule_work()
2759 net_work->mlxsw_sp = router->mlxsw_sp; in mlxsw_sp_router_schedule_work()
2792 mlxsw_sp->router->neighs_update.interval = interval; in mlxsw_sp_router_netevent_event()
2841 err = rhashtable_init(&mlxsw_sp->router->neigh_ht, in mlxsw_sp_neigh_init()
2852 INIT_DELAYED_WORK(&mlxsw_sp->router->neighs_update.dw, in mlxsw_sp_neigh_init()
2854 INIT_DELAYED_WORK(&mlxsw_sp->router->nexthop_probe_dw, in mlxsw_sp_neigh_init()
2856 atomic_set(&mlxsw_sp->router->neighs_update.neigh_count, 0); in mlxsw_sp_neigh_init()
2857 mlxsw_core_schedule_dw(&mlxsw_sp->router->neighs_update.dw, 0); in mlxsw_sp_neigh_init()
2858 mlxsw_core_schedule_dw(&mlxsw_sp->router->nexthop_probe_dw, 0); in mlxsw_sp_neigh_init()
2864 cancel_delayed_work_sync(&mlxsw_sp->router->neighs_update.dw); in mlxsw_sp_neigh_fini()
2865 cancel_delayed_work_sync(&mlxsw_sp->router->nexthop_probe_dw); in mlxsw_sp_neigh_fini()
2866 rhashtable_destroy(&mlxsw_sp->router->neigh_ht); in mlxsw_sp_neigh_fini()
3019 struct mlxsw_sp_nexthop *mlxsw_sp_nexthop_next(struct mlxsw_sp_router *router, in mlxsw_sp_nexthop_next() argument
3023 if (list_empty(&router->nexthop_list)) in mlxsw_sp_nexthop_next()
3026 return list_first_entry(&router->nexthop_list, in mlxsw_sp_nexthop_next()
3029 if (list_is_last(&nh->router_list_node, &router->nexthop_list)) in mlxsw_sp_nexthop_next()
3336 return rhashtable_insert_fast(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_nexthop_group_insert()
3348 rhashtable_remove_fast(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_nexthop_group_remove()
3361 return rhashtable_lookup_fast(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_nexthop4_group_lookup()
3374 return rhashtable_lookup_fast(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_nexthop6_group_lookup()
3388 return rhashtable_insert_fast(&mlxsw_sp->router->nexthop_ht, in mlxsw_sp_nexthop_insert()
3395 rhashtable_remove_fast(&mlxsw_sp->router->nexthop_ht, &nh->ht_node, in mlxsw_sp_nexthop_remove()
3403 return rhashtable_lookup_fast(&mlxsw_sp->router->nexthop_ht, &key, in mlxsw_sp_nexthop_lookup()
3464 mlxsw_sp->router->lb_rif_index; in __mlxsw_sp_nexthop_eth_update()
3519 ipip_ops = mlxsw_sp->router->ipip_ops_arr[nh->ipip_entry->ipipt]; in __mlxsw_sp_nexthop_ipip_update()
3639 for (i = 0; i < mlxsw_sp->router->adj_grp_size_ranges_count; i++) { in mlxsw_sp_adj_grp_size_round_up()
3642 size_range = &mlxsw_sp->router->adj_grp_size_ranges[i]; in mlxsw_sp_adj_grp_size_round_up()
3661 for (i = mlxsw_sp->router->adj_grp_size_ranges_count - 1; i >= 0; i--) { in mlxsw_sp_adj_grp_size_round_down()
3664 size_range = &mlxsw_sp->router->adj_grp_size_ranges[i]; in mlxsw_sp_adj_grp_size_round_down()
4136 &mlxsw_sp->router->nexthop_neighs_list); in mlxsw_sp_nexthop_neigh_init()
4241 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_nexthop_type_init()
4304 list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); in mlxsw_sp_nexthop4_init()
4418 &mlxsw_sp->router->adj_trap_index); in mlxsw_sp_adj_trap_entry_init()
4425 mlxsw_sp->router->adj_trap_index, in mlxsw_sp_adj_trap_entry_init()
4426 mlxsw_sp->router->lb_rif_index); in mlxsw_sp_adj_trap_entry_init()
4437 mlxsw_sp->router->adj_trap_index); in mlxsw_sp_adj_trap_entry_init()
4444 mlxsw_sp->router->adj_trap_index); in mlxsw_sp_adj_trap_entry_fini()
4451 if (refcount_inc_not_zero(&mlxsw_sp->router->num_groups)) in mlxsw_sp_nexthop_group_inc()
4458 refcount_set(&mlxsw_sp->router->num_groups, 1); in mlxsw_sp_nexthop_group_inc()
4465 if (!refcount_dec_and_test(&mlxsw_sp->router->num_groups)) in mlxsw_sp_nexthop_group_dec()
4523 mlxsw_core_schedule_dw(&mlxsw_sp->router->nh_grp_activity_dw, in mlxsw_sp_nh_grp_activity_work_schedule()
4530 struct mlxsw_sp_router *router; in mlxsw_sp_nh_grp_activity_work() local
4533 router = container_of(work, struct mlxsw_sp_router, in mlxsw_sp_nh_grp_activity_work()
4536 mutex_lock(&router->lock); in mlxsw_sp_nh_grp_activity_work()
4538 list_for_each_entry(nhgi, &router->nh_res_grp_list, list) { in mlxsw_sp_nh_grp_activity_work()
4539 mlxsw_sp_nh_grp_activity_update(router->mlxsw_sp, nhgi->nh_grp); in mlxsw_sp_nh_grp_activity_work()
4543 mutex_unlock(&router->lock); in mlxsw_sp_nh_grp_activity_work()
4547 mlxsw_sp_nh_grp_activity_work_schedule(router->mlxsw_sp); in mlxsw_sp_nh_grp_activity_work()
4630 for (i = 0; i < mlxsw_sp->router->adj_grp_size_ranges_count; i++) { in mlxsw_sp_nexthop_obj_res_group_size_validate()
4633 size_range = &mlxsw_sp->router->adj_grp_size_ranges[i]; in mlxsw_sp_nexthop_obj_res_group_size_validate()
4742 u16 lb_rif_index = mlxsw_sp->router->lb_rif_index; in mlxsw_sp_nexthop_obj_blackhole_init()
4750 nh->rif = mlxsw_sp->router->rifs[lb_rif_index]; in mlxsw_sp_nexthop_obj_blackhole_init()
4786 list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); in mlxsw_sp_nexthop_obj_init()
4898 if (list_empty(&mlxsw_sp->router->nh_res_grp_list)) in mlxsw_sp_nexthop_obj_group_info_init()
4900 list_add(&nhgi->list, &mlxsw_sp->router->nh_res_grp_list); in mlxsw_sp_nexthop_obj_group_info_init()
4923 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_nexthop_obj_group_info_fini() local
4928 if (list_empty(&mlxsw_sp->router->nh_res_grp_list)) in mlxsw_sp_nexthop_obj_group_info_fini()
4929 cancel_delayed_work(&router->nh_grp_activity_dw); in mlxsw_sp_nexthop_obj_group_info_fini()
4997 return rhashtable_lookup_fast(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_nexthop_obj_group_lookup()
5259 struct mlxsw_sp_router *router; in mlxsw_sp_nexthop_obj_event() local
5262 router = container_of(nb, struct mlxsw_sp_router, nexthop_nb); in mlxsw_sp_nexthop_obj_event()
5263 err = mlxsw_sp_nexthop_obj_validate(router->mlxsw_sp, event, info); in mlxsw_sp_nexthop_obj_event()
5267 mutex_lock(&router->lock); in mlxsw_sp_nexthop_obj_event()
5271 err = mlxsw_sp_nexthop_obj_new(router->mlxsw_sp, info); in mlxsw_sp_nexthop_obj_event()
5274 mlxsw_sp_nexthop_obj_del(router->mlxsw_sp, info); in mlxsw_sp_nexthop_obj_event()
5277 err = mlxsw_sp_nexthop_obj_bucket_replace(router->mlxsw_sp, in mlxsw_sp_nexthop_obj_event()
5284 mutex_unlock(&router->lock); in mlxsw_sp_nexthop_obj_event()
5753 adjacency_index = mlxsw_sp->router->adj_trap_index; in mlxsw_sp_fib_entry_op_remote()
5844 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_fib_entry_op_ipip_decap()
5928 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_fib4_entry_type_set() local
5948 tunnel_index = router->nve_decap_config.tunnel_index; in mlxsw_sp_fib4_entry_type_set()
6153 lpm_tree = mlxsw_sp->router->lpm.proto_trees[fib->proto]; in mlxsw_sp_fib_lpm_tree_link()
6513 list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); in mlxsw_sp_nexthop6_init()
6832 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_fib6_entry_type_set_local() local
6850 tunnel_index = router->nve_decap_config.tunnel_index; in mlxsw_sp_fib6_entry_type_set_local()
7300 struct mlxsw_sp_vr *vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_router_fib_flush()
7309 /* If virtual router was only used for IPv4, then it's no in mlxsw_sp_router_fib_flush()
7392 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fib4_event_work()
7417 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fib4_event_work()
7429 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fib6_event_work()
7464 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fib6_event_work()
7477 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fibmr_event_work()
7506 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fibmr_event_work()
7630 struct mlxsw_sp_router *router; in mlxsw_sp_router_fib_event() local
7638 router = container_of(nb, struct mlxsw_sp_router, fib_nb); in mlxsw_sp_router_fib_event()
7644 router->mlxsw_sp); in mlxsw_sp_router_fib_event()
7664 fib_work->mlxsw_sp = router->mlxsw_sp; in mlxsw_sp_router_fib_event()
7701 if (mlxsw_sp->router->rifs[i] && in mlxsw_sp_rif_find_by_dev()
7702 mlxsw_sp->router->rifs[i]->dev == dev) in mlxsw_sp_rif_find_by_dev()
7703 return mlxsw_sp->router->rifs[i]; in mlxsw_sp_rif_find_by_dev()
7713 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_exists()
7715 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_exists()
7725 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_vid()
7739 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_vid()
7834 if (!mlxsw_sp->router->rifs[i]) { in mlxsw_sp_rif_index_alloc()
7869 return mlxsw_sp->router->rifs[rif_index]; in mlxsw_sp_rif_by_index()
8045 * acquire the router lock again. Just postpone the notification until in mlxsw_sp_router_hwstats_notify_schedule()
8094 ops = mlxsw_sp->router->rif_ops_arr[type]; in mlxsw_sp_rif_create()
8103 NL_SET_ERR_MSG_MOD(extack, "Exceeded number of supported router interfaces"); in mlxsw_sp_rif_create()
8113 mlxsw_sp->router->rifs[rif_index] = rif; in mlxsw_sp_rif_create()
8149 atomic_inc(&mlxsw_sp->router->rifs_count); in mlxsw_sp_rif_create()
8161 mlxsw_sp->router->rifs[rif_index] = NULL; in mlxsw_sp_rif_create()
8179 atomic_dec(&mlxsw_sp->router->rifs_count); in mlxsw_sp_rif_destroy()
8181 vr = &mlxsw_sp->router->vrs[rif->vr_id]; in mlxsw_sp_rif_destroy()
8198 mlxsw_sp->router->rifs[rif->rif_index] = NULL; in mlxsw_sp_rif_destroy()
8210 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_destroy_by_dev()
8216 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_destroy_by_dev()
8271 u8 max_rif_mac_profiles = mlxsw_sp->router->max_rif_mac_profile; in mlxsw_sp_rif_mac_profile_index_alloc()
8272 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_rif_mac_profile_index_alloc() local
8275 id = idr_alloc(&router->rif_mac_profiles_idr, profile, 0, in mlxsw_sp_rif_mac_profile_index_alloc()
8285 "Exceeded number of supported router interface MAC profiles"); in mlxsw_sp_rif_mac_profile_index_alloc()
8295 profile = idr_remove(&mlxsw_sp->router->rif_mac_profiles_idr, in mlxsw_sp_rif_mac_profile_index_free()
8318 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_rif_mac_profile_find() local
8322 idr_for_each_entry(&router->rif_mac_profiles_idr, profile, id) { in mlxsw_sp_rif_mac_profile_find()
8335 return atomic_read(&mlxsw_sp->router->rif_mac_profiles_count); in mlxsw_sp_rif_mac_profiles_occ_get()
8342 return atomic_read(&mlxsw_sp->router->rifs_count); in mlxsw_sp_rifs_occ_get()
8360 atomic_inc(&mlxsw_sp->router->rif_mac_profiles_count); in mlxsw_sp_rif_mac_profile_create()
8373 atomic_dec(&mlxsw_sp->router->rif_mac_profiles_count); in mlxsw_sp_rif_mac_profile_destroy()
8404 profile = idr_find(&mlxsw_sp->router->rif_mac_profiles_idr, in mlxsw_sp_rif_mac_profile_put()
8420 profile = idr_find(&mlxsw_sp->router->rif_mac_profiles_idr, in mlxsw_sp_rif_mac_profile_is_shared()
8434 profile = idr_find(&mlxsw_sp->router->rif_mac_profiles_idr, in mlxsw_sp_rif_mac_profile_edit()
8543 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_port_vlan_router_join()
8551 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_port_vlan_router_join()
8560 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_port_vlan_router_leave()
8562 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_port_vlan_router_leave()
8742 NL_SET_ERR_MSG_MOD(extack, "macvlan is only supported on top of router interfaces"); in mlxsw_sp_rif_macvlan_add()
8791 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_macvlan_del()
8793 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_macvlan_del()
8839 struct mlxsw_sp_router *router; in mlxsw_sp_inetaddr_event() local
8847 router = container_of(nb, struct mlxsw_sp_router, inetaddr_nb); in mlxsw_sp_inetaddr_event()
8848 mutex_lock(&router->lock); in mlxsw_sp_inetaddr_event()
8849 rif = mlxsw_sp_rif_find_by_dev(router->mlxsw_sp, dev); in mlxsw_sp_inetaddr_event()
8853 err = __mlxsw_sp_inetaddr_event(router->mlxsw_sp, dev, event, NULL); in mlxsw_sp_inetaddr_event()
8855 mutex_unlock(&router->lock); in mlxsw_sp_inetaddr_event()
8872 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_inetaddr_valid_event()
8879 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_inetaddr_valid_event()
8900 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_inet6addr_event_work()
8908 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_inet6addr_event_work()
8921 struct mlxsw_sp_router *router; in mlxsw_sp_inet6addr_event() local
8931 router = container_of(nb, struct mlxsw_sp_router, inet6addr_nb); in mlxsw_sp_inet6addr_event()
8933 inet6addr_work->mlxsw_sp = router->mlxsw_sp; in mlxsw_sp_inet6addr_event()
8955 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_inet6addr_valid_event()
8962 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_inet6addr_valid_event()
9023 vr = &mlxsw_sp->router->vrs[rif->vr_id]; in mlxsw_sp_router_port_change_event()
9061 max_rif_mac_profiles = mlxsw_sp->router->max_rif_mac_profile; in mlxsw_sp_router_port_pre_changeaddr_event()
9069 NL_SET_ERR_MSG_MOD(extack, "Exceeded number of supported router interface MAC profiles"); in mlxsw_sp_router_port_pre_changeaddr_event()
9178 * destroy it and create a new one with the new virtual router ID. in mlxsw_sp_port_vrf_join()
9216 * direct more MAC addresses to the router. in mlxsw_sp_netdevice_vrf_event()
9243 struct mlxsw_sp_router *router; in mlxsw_sp_router_netdevice_event() local
9247 router = container_of(nb, struct mlxsw_sp_router, netdevice_nb); in mlxsw_sp_router_netdevice_event()
9248 mlxsw_sp = router->mlxsw_sp; in mlxsw_sp_router_netdevice_event()
9250 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_netdevice_event()
9266 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_netdevice_event()
9292 netdev_warn(rif->dev, "Router interface is deleted. Upper macvlans will not work\n"); in mlxsw_sp_rif_macvlan_flush()
9733 ul_vr = &mlxsw_sp->router->vrs[lb_rif->ul_vr_id]; in mlxsw_sp1_rif_ipip_lb_deconfigure()
9779 NL_SET_ERR_MSG_MOD(extack, "Exceeded number of supported router interfaces"); in mlxsw_sp_ul_rif_create()
9787 mlxsw_sp->router->rifs[rif_index] = ul_rif; in mlxsw_sp_ul_rif_create()
9793 atomic_inc(&mlxsw_sp->router->rifs_count); in mlxsw_sp_ul_rif_create()
9797 mlxsw_sp->router->rifs[rif_index] = NULL; in mlxsw_sp_ul_rif_create()
9806 atomic_dec(&mlxsw_sp->router->rifs_count); in mlxsw_sp_ul_rif_destroy()
9808 mlxsw_sp->router->rifs[ul_rif->rif_index] = NULL; in mlxsw_sp_ul_rif_destroy()
9847 vr = &mlxsw_sp->router->vrs[ul_rif->vr_id]; in mlxsw_sp_ul_rif_put()
9863 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_ul_rif_get()
9871 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_ul_rif_get()
9879 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_ul_rif_put()
9880 ul_rif = mlxsw_sp->router->rifs[ul_rif_index]; in mlxsw_sp_router_ul_rif_put()
9886 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_ul_rif_put()
9951 mlxsw_sp->router->max_rif_mac_profile = in mlxsw_sp_rifs_init()
9954 mlxsw_sp->router->rifs = kcalloc(max_rifs, in mlxsw_sp_rifs_init()
9957 if (!mlxsw_sp->router->rifs) in mlxsw_sp_rifs_init()
9960 idr_init(&mlxsw_sp->router->rif_mac_profiles_idr); in mlxsw_sp_rifs_init()
9961 atomic_set(&mlxsw_sp->router->rif_mac_profiles_count, 0); in mlxsw_sp_rifs_init()
9962 atomic_set(&mlxsw_sp->router->rifs_count, 0); in mlxsw_sp_rifs_init()
9980 WARN_ON_ONCE(atomic_read(&mlxsw_sp->router->rifs_count)); in mlxsw_sp_rifs_fini()
9982 WARN_ON_ONCE(mlxsw_sp->router->rifs[i]); in mlxsw_sp_rifs_fini()
9987 WARN_ON(!idr_is_empty(&mlxsw_sp->router->rif_mac_profiles_idr)); in mlxsw_sp_rifs_fini()
9988 idr_destroy(&mlxsw_sp->router->rif_mac_profiles_idr); in mlxsw_sp_rifs_fini()
9989 kfree(mlxsw_sp->router->rifs); in mlxsw_sp_rifs_fini()
10005 INIT_LIST_HEAD(&mlxsw_sp->router->ipip_list); in mlxsw_sp_ipips_init()
10019 mlxsw_sp->router->ipip_ops_arr = mlxsw_sp1_ipip_ops_arr; in mlxsw_sp1_ipips_init()
10025 mlxsw_sp->router->ipip_ops_arr = mlxsw_sp2_ipip_ops_arr; in mlxsw_sp2_ipips_init()
10031 WARN_ON(!list_empty(&mlxsw_sp->router->ipip_list)); in mlxsw_sp_ipips_fini()
10036 struct mlxsw_sp_router *router; in mlxsw_sp_router_fib_dump_flush() local
10043 router = container_of(nb, struct mlxsw_sp_router, fib_nb); in mlxsw_sp_router_fib_dump_flush()
10044 mlxsw_sp_router_fib_flush(router->mlxsw_sp); in mlxsw_sp_router_fib_dump_flush()
10265 mlxsw_sp->router->inc_parsing_depth = true; in mlxsw_sp_mp_hash_parsing_depth_adjust()
10268 mlxsw_sp->router->inc_parsing_depth = false; in mlxsw_sp_mp_hash_parsing_depth_adjust()
10288 old_inc_parsing_depth = mlxsw_sp->router->inc_parsing_depth; in mlxsw_sp_mp_hash_init()
10381 mlxsw_sp->router->lb_rif_index = lb_rif_index; in mlxsw_sp_lb_rif_init()
10388 mlxsw_sp_router_ul_rif_put(mlxsw_sp, mlxsw_sp->router->lb_rif_index); in mlxsw_sp_lb_rif_fini()
10395 mlxsw_sp->router->rif_ops_arr = mlxsw_sp1_rif_ops_arr; in mlxsw_sp1_router_init()
10396 mlxsw_sp->router->adj_grp_size_ranges = mlxsw_sp1_adj_grp_size_ranges; in mlxsw_sp1_router_init()
10397 mlxsw_sp->router->adj_grp_size_ranges_count = size_ranges_count; in mlxsw_sp1_router_init()
10411 mlxsw_sp->router->rif_ops_arr = mlxsw_sp2_rif_ops_arr; in mlxsw_sp2_router_init()
10412 mlxsw_sp->router->adj_grp_size_ranges = mlxsw_sp2_adj_grp_size_ranges; in mlxsw_sp2_router_init()
10413 mlxsw_sp->router->adj_grp_size_ranges_count = size_ranges_count; in mlxsw_sp2_router_init()
10426 struct mlxsw_sp_router *router; in mlxsw_sp_router_init() local
10429 router = kzalloc(sizeof(*mlxsw_sp->router), GFP_KERNEL); in mlxsw_sp_router_init()
10430 if (!router) in mlxsw_sp_router_init()
10432 mutex_init(&router->lock); in mlxsw_sp_router_init()
10433 mlxsw_sp->router = router; in mlxsw_sp_router_init()
10434 router->mlxsw_sp = mlxsw_sp; in mlxsw_sp_router_init()
10440 INIT_LIST_HEAD(&mlxsw_sp->router->nh_res_grp_list); in mlxsw_sp_router_init()
10441 INIT_DELAYED_WORK(&mlxsw_sp->router->nh_grp_activity_dw, in mlxsw_sp_router_init()
10443 INIT_LIST_HEAD(&mlxsw_sp->router->nexthop_neighs_list); in mlxsw_sp_router_init()
10456 err = rhashtable_init(&mlxsw_sp->router->nexthop_ht, in mlxsw_sp_router_init()
10461 err = rhashtable_init(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_router_init()
10466 INIT_LIST_HEAD(&mlxsw_sp->router->nexthop_list); in mlxsw_sp_router_init()
10495 router->inetaddr_nb.notifier_call = mlxsw_sp_inetaddr_event; in mlxsw_sp_router_init()
10496 err = register_inetaddr_notifier(&router->inetaddr_nb); in mlxsw_sp_router_init()
10500 router->inet6addr_nb.notifier_call = mlxsw_sp_inet6addr_event; in mlxsw_sp_router_init()
10501 err = register_inet6addr_notifier(&router->inet6addr_nb); in mlxsw_sp_router_init()
10505 mlxsw_sp->router->netevent_nb.notifier_call = in mlxsw_sp_router_init()
10507 err = register_netevent_notifier(&mlxsw_sp->router->netevent_nb); in mlxsw_sp_router_init()
10511 mlxsw_sp->router->nexthop_nb.notifier_call = in mlxsw_sp_router_init()
10514 &mlxsw_sp->router->nexthop_nb, in mlxsw_sp_router_init()
10519 mlxsw_sp->router->fib_nb.notifier_call = mlxsw_sp_router_fib_event; in mlxsw_sp_router_init()
10521 &mlxsw_sp->router->fib_nb, in mlxsw_sp_router_init()
10526 mlxsw_sp->router->netdevice_nb.notifier_call = in mlxsw_sp_router_init()
10529 &mlxsw_sp->router->netdevice_nb); in mlxsw_sp_router_init()
10537 &mlxsw_sp->router->fib_nb); in mlxsw_sp_router_init()
10540 &mlxsw_sp->router->nexthop_nb); in mlxsw_sp_router_init()
10542 unregister_netevent_notifier(&mlxsw_sp->router->netevent_nb); in mlxsw_sp_router_init()
10544 unregister_inet6addr_notifier(&router->inet6addr_nb); in mlxsw_sp_router_init()
10546 unregister_inetaddr_notifier(&router->inetaddr_nb); in mlxsw_sp_router_init()
10561 rhashtable_destroy(&mlxsw_sp->router->nexthop_group_ht); in mlxsw_sp_router_init()
10563 rhashtable_destroy(&mlxsw_sp->router->nexthop_ht); in mlxsw_sp_router_init()
10571 cancel_delayed_work_sync(&mlxsw_sp->router->nh_grp_activity_dw); in mlxsw_sp_router_init()
10573 mutex_destroy(&mlxsw_sp->router->lock); in mlxsw_sp_router_init()
10574 kfree(mlxsw_sp->router); in mlxsw_sp_router_init()
10581 &mlxsw_sp->router->netdevice_nb); in mlxsw_sp_router_fini()
10583 &mlxsw_sp->router->fib_nb); in mlxsw_sp_router_fini()
10585 &mlxsw_sp->router->nexthop_nb); in mlxsw_sp_router_fini()
10586 unregister_netevent_notifier(&mlxsw_sp->router->netevent_nb); in mlxsw_sp_router_fini()
10587 unregister_inet6addr_notifier(&mlxsw_sp->router->inet6addr_nb); in mlxsw_sp_router_fini()
10588 unregister_inetaddr_notifier(&mlxsw_sp->router->inetaddr_nb); in mlxsw_sp_router_fini()
10595 rhashtable_destroy(&mlxsw_sp->router->nexthop_group_ht); in mlxsw_sp_router_fini()
10596 rhashtable_destroy(&mlxsw_sp->router->nexthop_ht); in mlxsw_sp_router_fini()
10600 cancel_delayed_work_sync(&mlxsw_sp->router->nh_grp_activity_dw); in mlxsw_sp_router_fini()
10601 mutex_destroy(&mlxsw_sp->router->lock); in mlxsw_sp_router_fini()
10602 kfree(mlxsw_sp->router); in mlxsw_sp_router_fini()