Lines Matching refs:mlxsw_sp
62 struct mlxsw_sp *mlxsw_sp; member
117 mlxsw_sp_rif_find_by_dev(const struct mlxsw_sp *mlxsw_sp,
121 static void mlxsw_sp_lpm_tree_put(struct mlxsw_sp *mlxsw_sp,
123 static int mlxsw_sp_vr_lpm_tree_bind(struct mlxsw_sp *mlxsw_sp,
126 static int mlxsw_sp_vr_lpm_tree_unbind(struct mlxsw_sp *mlxsw_sp,
170 static int mlxsw_sp_rif_counter_edit(struct mlxsw_sp *mlxsw_sp, u16 rif_index, in mlxsw_sp_rif_counter_edit() argument
181 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_counter_edit()
187 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_counter_edit()
190 int mlxsw_sp_rif_counter_value_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_counter_value_get() argument
208 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ricnt), ricnt_pl); in mlxsw_sp_rif_counter_value_get()
215 static int mlxsw_sp_rif_counter_clear(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_counter_clear() argument
222 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ricnt), ricnt_pl); in mlxsw_sp_rif_counter_clear()
225 int mlxsw_sp_rif_counter_alloc(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_counter_alloc() argument
235 err = mlxsw_sp_counter_alloc(mlxsw_sp, MLXSW_SP_COUNTER_SUB_POOL_RIF, in mlxsw_sp_rif_counter_alloc()
240 err = mlxsw_sp_rif_counter_clear(mlxsw_sp, *p_counter_index); in mlxsw_sp_rif_counter_alloc()
244 err = mlxsw_sp_rif_counter_edit(mlxsw_sp, rif->rif_index, in mlxsw_sp_rif_counter_alloc()
253 mlxsw_sp_counter_free(mlxsw_sp, MLXSW_SP_COUNTER_SUB_POOL_RIF, in mlxsw_sp_rif_counter_alloc()
258 void mlxsw_sp_rif_counter_free(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_counter_free() argument
270 mlxsw_sp_rif_counter_edit(mlxsw_sp, rif->rif_index, in mlxsw_sp_rif_counter_free()
272 mlxsw_sp_counter_free(mlxsw_sp, MLXSW_SP_COUNTER_SUB_POOL_RIF, in mlxsw_sp_rif_counter_free()
279 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp_rif_counters_alloc() local
282 devlink = priv_to_devlink(mlxsw_sp->core); in mlxsw_sp_rif_counters_alloc()
286 mlxsw_sp_rif_counter_alloc(mlxsw_sp, rif, MLXSW_SP_RIF_COUNTER_EGRESS); in mlxsw_sp_rif_counters_alloc()
291 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp_rif_counters_free() local
293 mlxsw_sp_rif_counter_free(mlxsw_sp, rif, MLXSW_SP_RIF_COUNTER_EGRESS); in mlxsw_sp_rif_counters_free()
427 static struct mlxsw_sp_fib *mlxsw_sp_fib_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_create() argument
435 lpm_tree = mlxsw_sp->router->lpm.proto_trees[proto]; 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()
459 static void mlxsw_sp_fib_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_destroy() argument
462 mlxsw_sp_vr_lpm_tree_unbind(mlxsw_sp, fib); in mlxsw_sp_fib_destroy()
463 mlxsw_sp_lpm_tree_put(mlxsw_sp, fib->lpm_tree); in mlxsw_sp_fib_destroy()
470 mlxsw_sp_lpm_tree_find_unused(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_lpm_tree_find_unused() argument
475 for (i = 0; i < mlxsw_sp->router->lpm.tree_count; i++) { in mlxsw_sp_lpm_tree_find_unused()
476 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_tree_find_unused()
483 static int mlxsw_sp_lpm_tree_alloc(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_lpm_tree_alloc() argument
491 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralta), ralta_pl); in mlxsw_sp_lpm_tree_alloc()
494 static void mlxsw_sp_lpm_tree_free(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_lpm_tree_free() argument
502 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralta), ralta_pl); in mlxsw_sp_lpm_tree_free()
506 mlxsw_sp_lpm_tree_left_struct_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_lpm_tree_left_struct_set() argument
526 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralst), ralst_pl); in mlxsw_sp_lpm_tree_left_struct_set()
530 mlxsw_sp_lpm_tree_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_lpm_tree_create() argument
537 lpm_tree = mlxsw_sp_lpm_tree_find_unused(mlxsw_sp); in mlxsw_sp_lpm_tree_create()
541 err = mlxsw_sp_lpm_tree_alloc(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_create()
545 err = mlxsw_sp_lpm_tree_left_struct_set(mlxsw_sp, prefix_usage, in mlxsw_sp_lpm_tree_create()
557 mlxsw_sp_lpm_tree_free(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_create()
561 static void mlxsw_sp_lpm_tree_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_lpm_tree_destroy() argument
564 mlxsw_sp_lpm_tree_free(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_destroy()
568 mlxsw_sp_lpm_tree_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_lpm_tree_get() argument
575 for (i = 0; i < mlxsw_sp->router->lpm.tree_count; i++) { in mlxsw_sp_lpm_tree_get()
576 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_tree_get()
585 return mlxsw_sp_lpm_tree_create(mlxsw_sp, prefix_usage, proto); in mlxsw_sp_lpm_tree_get()
593 static void mlxsw_sp_lpm_tree_put(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_lpm_tree_put() argument
597 mlxsw_sp_lpm_tree_destroy(mlxsw_sp, lpm_tree); in mlxsw_sp_lpm_tree_put()
602 static int mlxsw_sp_lpm_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_lpm_init() argument
609 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_LPM_TREES)) in mlxsw_sp_lpm_init()
612 max_trees = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_LPM_TREES); in mlxsw_sp_lpm_init()
613 mlxsw_sp->router->lpm.tree_count = max_trees - MLXSW_SP_LPM_TREE_MIN; in mlxsw_sp_lpm_init()
614 mlxsw_sp->router->lpm.trees = kcalloc(mlxsw_sp->router->lpm.tree_count, in mlxsw_sp_lpm_init()
617 if (!mlxsw_sp->router->lpm.trees) in mlxsw_sp_lpm_init()
620 for (i = 0; i < mlxsw_sp->router->lpm.tree_count; i++) { in mlxsw_sp_lpm_init()
621 lpm_tree = &mlxsw_sp->router->lpm.trees[i]; in mlxsw_sp_lpm_init()
625 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, 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()
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()
647 kfree(mlxsw_sp->router->lpm.trees); in mlxsw_sp_lpm_init()
651 static void mlxsw_sp_lpm_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_lpm_fini() argument
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()
661 kfree(mlxsw_sp->router->lpm.trees); in mlxsw_sp_lpm_fini()
671 static struct mlxsw_sp_vr *mlxsw_sp_vr_find_unused(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_vr_find_unused() argument
676 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) { in mlxsw_sp_vr_find_unused()
677 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vr_find_unused()
684 static int mlxsw_sp_vr_lpm_tree_bind(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_vr_lpm_tree_bind() argument
692 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(raltb), raltb_pl); in mlxsw_sp_vr_lpm_tree_bind()
695 static int mlxsw_sp_vr_lpm_tree_unbind(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_vr_lpm_tree_unbind() argument
703 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(raltb), raltb_pl); in mlxsw_sp_vr_lpm_tree_unbind()
714 static struct mlxsw_sp_vr *mlxsw_sp_vr_find(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_vr_find() argument
722 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) { in mlxsw_sp_vr_find()
723 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vr_find()
730 int mlxsw_sp_router_tb_id_vr_id(struct mlxsw_sp *mlxsw_sp, u32 tb_id, in mlxsw_sp_router_tb_id_vr_id() argument
736 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_tb_id_vr_id()
737 vr = mlxsw_sp_vr_find(mlxsw_sp, tb_id); in mlxsw_sp_router_tb_id_vr_id()
744 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_tb_id_vr_id()
760 static struct mlxsw_sp_vr *mlxsw_sp_vr_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_vr_create() argument
770 vr = mlxsw_sp_vr_find_unused(mlxsw_sp); in mlxsw_sp_vr_create()
775 fib4 = mlxsw_sp_fib_create(mlxsw_sp, vr, MLXSW_SP_L3_PROTO_IPV4); in mlxsw_sp_vr_create()
778 fib6 = mlxsw_sp_fib_create(mlxsw_sp, vr, MLXSW_SP_L3_PROTO_IPV6); in mlxsw_sp_vr_create()
783 mr4_table = mlxsw_sp_mr_table_create(mlxsw_sp, vr->id, in mlxsw_sp_vr_create()
789 mr6_table = mlxsw_sp_mr_table_create(mlxsw_sp, vr->id, in mlxsw_sp_vr_create()
806 mlxsw_sp_fib_destroy(mlxsw_sp, fib6); in mlxsw_sp_vr_create()
808 mlxsw_sp_fib_destroy(mlxsw_sp, fib4); in mlxsw_sp_vr_create()
812 static void mlxsw_sp_vr_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_vr_destroy() argument
819 mlxsw_sp_fib_destroy(mlxsw_sp, vr->fib6); in mlxsw_sp_vr_destroy()
821 mlxsw_sp_fib_destroy(mlxsw_sp, vr->fib4); in mlxsw_sp_vr_destroy()
825 static struct mlxsw_sp_vr *mlxsw_sp_vr_get(struct mlxsw_sp *mlxsw_sp, u32 tb_id, in mlxsw_sp_vr_get() argument
831 vr = mlxsw_sp_vr_find(mlxsw_sp, tb_id); in mlxsw_sp_vr_get()
833 vr = mlxsw_sp_vr_create(mlxsw_sp, tb_id, extack); in mlxsw_sp_vr_get()
837 static void mlxsw_sp_vr_put(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_vr *vr) in mlxsw_sp_vr_put() argument
843 mlxsw_sp_vr_destroy(mlxsw_sp, vr); in mlxsw_sp_vr_put()
859 static int mlxsw_sp_vr_lpm_tree_replace(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_vr_lpm_tree_replace() argument
868 err = mlxsw_sp_vr_lpm_tree_bind(mlxsw_sp, fib, new_tree->id); in mlxsw_sp_vr_lpm_tree_replace()
871 mlxsw_sp_lpm_tree_put(mlxsw_sp, old_tree); in mlxsw_sp_vr_lpm_tree_replace()
875 mlxsw_sp_lpm_tree_put(mlxsw_sp, new_tree); in mlxsw_sp_vr_lpm_tree_replace()
880 static int mlxsw_sp_vrs_lpm_tree_replace(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_vrs_lpm_tree_replace() argument
890 old_tree = mlxsw_sp->router->lpm.proto_trees[proto]; in mlxsw_sp_vrs_lpm_tree_replace()
893 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) { in mlxsw_sp_vrs_lpm_tree_replace()
894 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vrs_lpm_tree_replace()
897 err = mlxsw_sp_vr_lpm_tree_replace(mlxsw_sp, in mlxsw_sp_vrs_lpm_tree_replace()
906 mlxsw_sp->router->lpm.proto_trees[proto] = new_tree; in mlxsw_sp_vrs_lpm_tree_replace()
907 mlxsw_sp_lpm_tree_put(mlxsw_sp, old_tree); in mlxsw_sp_vrs_lpm_tree_replace()
915 mlxsw_sp_vr_lpm_tree_replace(mlxsw_sp, in mlxsw_sp_vrs_lpm_tree_replace()
922 static int mlxsw_sp_vrs_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_vrs_init() argument
928 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_VRS)) in mlxsw_sp_vrs_init()
931 max_vrs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); in mlxsw_sp_vrs_init()
932 mlxsw_sp->router->vrs = kcalloc(max_vrs, sizeof(struct mlxsw_sp_vr), in mlxsw_sp_vrs_init()
934 if (!mlxsw_sp->router->vrs) in mlxsw_sp_vrs_init()
938 vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_vrs_init()
945 static void mlxsw_sp_router_fib_flush(struct mlxsw_sp *mlxsw_sp);
947 static void mlxsw_sp_vrs_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_vrs_fini() argument
957 mlxsw_sp_router_fib_flush(mlxsw_sp); in mlxsw_sp_vrs_fini()
958 kfree(mlxsw_sp->router->vrs); in mlxsw_sp_vrs_fini()
987 mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp,
992 mlxsw_sp_ipip_ol_ipip_lb_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_ol_ipip_lb_create() argument
1001 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipipt]; in mlxsw_sp_ipip_ol_ipip_lb_create()
1005 .lb_config = ipip_ops->ol_loopback_config(mlxsw_sp, ol_dev), in mlxsw_sp_ipip_ol_ipip_lb_create()
1008 rif = mlxsw_sp_rif_create(mlxsw_sp, &lb_params.common, extack); in mlxsw_sp_ipip_ol_ipip_lb_create()
1015 mlxsw_sp_ipip_entry_alloc(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_alloc() argument
1023 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipipt]; in mlxsw_sp_ipip_entry_alloc()
1028 ipip_entry->ol_lb = mlxsw_sp_ipip_ol_ipip_lb_create(mlxsw_sp, ipipt, in mlxsw_sp_ipip_entry_alloc()
1062 mlxsw_sp_ipip_entry_saddr_matches(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_saddr_matches() argument
1072 if (mlxsw_sp->router->ipip_ops_arr[ipipt]->ul_proto != ul_proto) in mlxsw_sp_ipip_entry_saddr_matches()
1081 mlxsw_sp_fib_entry_decap_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_decap_init() argument
1088 err = mlxsw_sp_kvdl_alloc(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, in mlxsw_sp_fib_entry_decap_init()
1099 static void mlxsw_sp_fib_entry_decap_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_decap_fini() argument
1105 mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, in mlxsw_sp_fib_entry_decap_fini()
1112 static int mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp,
1116 mlxsw_sp_ipip_entry_demote_decap(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_demote_decap() argument
1121 mlxsw_sp_fib_entry_decap_fini(mlxsw_sp, fib_entry); in mlxsw_sp_ipip_entry_demote_decap()
1124 mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry); in mlxsw_sp_ipip_entry_demote_decap()
1128 mlxsw_sp_ipip_entry_promote_decap(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_promote_decap() argument
1132 if (mlxsw_sp_fib_entry_decap_init(mlxsw_sp, decap_fib_entry, in mlxsw_sp_ipip_entry_promote_decap()
1137 if (mlxsw_sp_fib_entry_update(mlxsw_sp, decap_fib_entry)) in mlxsw_sp_ipip_entry_promote_decap()
1138 mlxsw_sp_ipip_entry_demote_decap(mlxsw_sp, ipip_entry); in mlxsw_sp_ipip_entry_promote_decap()
1142 mlxsw_sp_router_ip2me_fib_entry_find(struct mlxsw_sp *mlxsw_sp, u32 tb_id, in mlxsw_sp_router_ip2me_fib_entry_find() argument
1155 vr = mlxsw_sp_vr_find(mlxsw_sp, tb_id); in mlxsw_sp_router_ip2me_fib_entry_find()
1183 mlxsw_sp_ipip_entry_find_decap(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_find_decap() argument
1197 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_ipip_entry_find_decap()
1200 ul_vr = mlxsw_sp_vr_find(mlxsw_sp, ul_tb_id); in mlxsw_sp_ipip_entry_find_decap()
1230 mlxsw_sp_ipip_entry_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_create() argument
1236 ipip_entry = mlxsw_sp_ipip_entry_alloc(mlxsw_sp, ipipt, ol_dev); in mlxsw_sp_ipip_entry_create()
1241 &mlxsw_sp->router->ipip_list); in mlxsw_sp_ipip_entry_create()
1247 mlxsw_sp_ipip_entry_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_destroy() argument
1255 mlxsw_sp_ipip_entry_matches_decap(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_matches_decap() argument
1264 if (mlxsw_sp->router->ipip_ops_arr[ipipt]->ul_proto != ul_proto) in mlxsw_sp_ipip_entry_matches_decap()
1267 return mlxsw_sp_ipip_entry_saddr_matches(mlxsw_sp, ul_proto, ul_dip, in mlxsw_sp_ipip_entry_matches_decap()
1273 mlxsw_sp_ipip_entry_find_by_decap(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_find_by_decap() argument
1280 list_for_each_entry(ipip_entry, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_entry_find_by_decap()
1282 if (mlxsw_sp_ipip_entry_matches_decap(mlxsw_sp, ul_dev, in mlxsw_sp_ipip_entry_find_by_decap()
1290 static bool mlxsw_sp_netdev_ipip_type(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdev_ipip_type() argument
1294 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_netdev_ipip_type()
1309 bool mlxsw_sp_netdev_is_ipip_ol(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdev_is_ipip_ol() argument
1312 return mlxsw_sp_netdev_ipip_type(mlxsw_sp, dev, NULL); in mlxsw_sp_netdev_is_ipip_ol()
1316 mlxsw_sp_ipip_entry_find_by_ol_dev(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_find_by_ol_dev() argument
1321 list_for_each_entry(ipip_entry, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_entry_find_by_ol_dev()
1330 mlxsw_sp_ipip_entry_find_by_ul_dev(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_find_by_ul_dev() argument
1336 ipip_entry = list_prepare_entry(start, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_entry_find_by_ul_dev()
1338 list_for_each_entry_continue(ipip_entry, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_entry_find_by_ul_dev()
1354 bool mlxsw_sp_netdev_is_ipip_ul(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdev_is_ipip_ul() argument
1359 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_netdev_is_ipip_ul()
1360 is_ipip_ul = mlxsw_sp_ipip_entry_find_by_ul_dev(mlxsw_sp, dev, NULL); in mlxsw_sp_netdev_is_ipip_ul()
1361 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_netdev_is_ipip_ul()
1366 static bool mlxsw_sp_netdevice_ipip_can_offload(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_can_offload() argument
1371 = mlxsw_sp->router->ipip_ops_arr[ipipt]; in mlxsw_sp_netdevice_ipip_can_offload()
1376 return ops->can_offload(mlxsw_sp, ol_dev, MLXSW_SP_L3_PROTO_IPV4) || in mlxsw_sp_netdevice_ipip_can_offload()
1377 ops->can_offload(mlxsw_sp, ol_dev, MLXSW_SP_L3_PROTO_IPV6); in mlxsw_sp_netdevice_ipip_can_offload()
1380 static int mlxsw_sp_netdevice_ipip_ol_reg_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_reg_event() argument
1389 mlxsw_sp_netdev_ipip_type(mlxsw_sp, ol_dev, &ipipt); in mlxsw_sp_netdevice_ipip_ol_reg_event()
1390 if (mlxsw_sp_netdevice_ipip_can_offload(mlxsw_sp, ol_dev, ipipt)) { in mlxsw_sp_netdevice_ipip_ol_reg_event()
1392 ul_proto = mlxsw_sp->router->ipip_ops_arr[ipipt]->ul_proto; in mlxsw_sp_netdevice_ipip_ol_reg_event()
1394 if (!mlxsw_sp_ipip_demote_tunnel_by_saddr(mlxsw_sp, ul_proto, in mlxsw_sp_netdevice_ipip_ol_reg_event()
1397 ipip_entry = mlxsw_sp_ipip_entry_create(mlxsw_sp, ipipt, in mlxsw_sp_netdevice_ipip_ol_reg_event()
1407 static void mlxsw_sp_netdevice_ipip_ol_unreg_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_unreg_event() argument
1412 ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_unreg_event()
1414 mlxsw_sp_ipip_entry_destroy(mlxsw_sp, ipip_entry); in mlxsw_sp_netdevice_ipip_ol_unreg_event()
1418 mlxsw_sp_ipip_entry_ol_up_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_ol_up_event() argument
1423 decap_fib_entry = mlxsw_sp_ipip_entry_find_decap(mlxsw_sp, ipip_entry); in mlxsw_sp_ipip_entry_ol_up_event()
1425 mlxsw_sp_ipip_entry_promote_decap(mlxsw_sp, ipip_entry, in mlxsw_sp_ipip_entry_ol_up_event()
1435 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp_rif_ipip_lb_op() local
1453 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_ipip_lb_op()
1456 static int mlxsw_sp_netdevice_ipip_ol_update_mtu(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_update_mtu() argument
1463 ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_update_mtu()
1477 static void mlxsw_sp_netdevice_ipip_ol_up_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_up_event() argument
1482 ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_up_event()
1484 mlxsw_sp_ipip_entry_ol_up_event(mlxsw_sp, ipip_entry); in mlxsw_sp_netdevice_ipip_ol_up_event()
1488 mlxsw_sp_ipip_entry_ol_down_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_ol_down_event() argument
1492 mlxsw_sp_ipip_entry_demote_decap(mlxsw_sp, ipip_entry); in mlxsw_sp_ipip_entry_ol_down_event()
1495 static void mlxsw_sp_netdevice_ipip_ol_down_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_down_event() argument
1500 ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_down_event()
1502 mlxsw_sp_ipip_entry_ol_down_event(mlxsw_sp, ipip_entry); in mlxsw_sp_netdevice_ipip_ol_down_event()
1505 static void mlxsw_sp_nexthop_rif_migrate(struct mlxsw_sp *mlxsw_sp,
1509 mlxsw_sp_ipip_entry_ol_lb_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_ol_lb_update() argument
1517 new_lb_rif = mlxsw_sp_ipip_ol_ipip_lb_create(mlxsw_sp, in mlxsw_sp_ipip_entry_ol_lb_update()
1526 mlxsw_sp_nexthop_rif_migrate(mlxsw_sp, &old_lb_rif->common, in mlxsw_sp_ipip_entry_ol_lb_update()
1534 static void mlxsw_sp_nexthop_rif_update(struct mlxsw_sp *mlxsw_sp,
1550 int __mlxsw_sp_ipip_entry_update_tunnel(struct mlxsw_sp *mlxsw_sp, in __mlxsw_sp_ipip_entry_update_tunnel() argument
1566 mlxsw_sp_ipip_entry_demote_decap(mlxsw_sp, ipip_entry); in __mlxsw_sp_ipip_entry_update_tunnel()
1569 err = mlxsw_sp_ipip_entry_ol_lb_update(mlxsw_sp, ipip_entry, in __mlxsw_sp_ipip_entry_update_tunnel()
1574 mlxsw_sp_nexthop_rif_update(mlxsw_sp, in __mlxsw_sp_ipip_entry_update_tunnel()
1579 mlxsw_sp_ipip_entry_ol_up_event(mlxsw_sp, ipip_entry); in __mlxsw_sp_ipip_entry_update_tunnel()
1584 static int mlxsw_sp_netdevice_ipip_ol_vrf_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_vrf_event() argument
1589 mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_vrf_event()
1594 return __mlxsw_sp_ipip_entry_update_tunnel(mlxsw_sp, ipip_entry, in mlxsw_sp_netdevice_ipip_ol_vrf_event()
1599 mlxsw_sp_netdevice_ipip_ul_vrf_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ul_vrf_event() argument
1612 ul_proto = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]->ul_proto; in mlxsw_sp_netdevice_ipip_ul_vrf_event()
1614 if (mlxsw_sp_ipip_demote_tunnel_by_saddr(mlxsw_sp, ul_proto, in mlxsw_sp_netdevice_ipip_ul_vrf_event()
1621 return __mlxsw_sp_ipip_entry_update_tunnel(mlxsw_sp, ipip_entry, in mlxsw_sp_netdevice_ipip_ul_vrf_event()
1626 mlxsw_sp_netdevice_ipip_ul_up_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ul_up_event() argument
1630 return __mlxsw_sp_ipip_entry_update_tunnel(mlxsw_sp, ipip_entry, in mlxsw_sp_netdevice_ipip_ul_up_event()
1635 mlxsw_sp_netdevice_ipip_ul_down_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ul_down_event() argument
1643 return __mlxsw_sp_ipip_entry_update_tunnel(mlxsw_sp, ipip_entry, in mlxsw_sp_netdevice_ipip_ul_down_event()
1648 mlxsw_sp_netdevice_ipip_ol_change_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_change_event() argument
1656 ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_change_event()
1665 if (!mlxsw_sp_netdevice_ipip_can_offload(mlxsw_sp, ol_dev, in mlxsw_sp_netdevice_ipip_ol_change_event()
1667 mlxsw_sp_ipip_entry_demote_tunnel(mlxsw_sp, ipip_entry); in mlxsw_sp_netdevice_ipip_ol_change_event()
1671 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_netdevice_ipip_ol_change_event()
1672 err = ipip_ops->ol_netdev_change(mlxsw_sp, ipip_entry, extack); in mlxsw_sp_netdevice_ipip_ol_change_event()
1676 void mlxsw_sp_ipip_entry_demote_tunnel(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_entry_demote_tunnel() argument
1682 mlxsw_sp_ipip_entry_ol_down_event(mlxsw_sp, ipip_entry); in mlxsw_sp_ipip_entry_demote_tunnel()
1683 mlxsw_sp_ipip_entry_destroy(mlxsw_sp, ipip_entry); in mlxsw_sp_ipip_entry_demote_tunnel()
1693 mlxsw_sp_ipip_demote_tunnel_by_saddr(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_demote_tunnel_by_saddr() argument
1701 list_for_each_entry_safe(ipip_entry, tmp, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_demote_tunnel_by_saddr()
1704 mlxsw_sp_ipip_entry_saddr_matches(mlxsw_sp, ul_proto, saddr, in mlxsw_sp_ipip_demote_tunnel_by_saddr()
1706 mlxsw_sp_ipip_entry_demote_tunnel(mlxsw_sp, ipip_entry); in mlxsw_sp_ipip_demote_tunnel_by_saddr()
1714 static void mlxsw_sp_ipip_demote_tunnel_by_ul_netdev(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_ipip_demote_tunnel_by_ul_netdev() argument
1719 list_for_each_entry_safe(ipip_entry, tmp, &mlxsw_sp->router->ipip_list, in mlxsw_sp_ipip_demote_tunnel_by_ul_netdev()
1728 mlxsw_sp_ipip_entry_demote_tunnel(mlxsw_sp, ipip_entry); in mlxsw_sp_ipip_demote_tunnel_by_ul_netdev()
1732 int mlxsw_sp_netdevice_ipip_ol_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_event() argument
1741 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_netdevice_ipip_ol_event()
1744 err = mlxsw_sp_netdevice_ipip_ol_reg_event(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_event()
1747 mlxsw_sp_netdevice_ipip_ol_unreg_event(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_event()
1750 mlxsw_sp_netdevice_ipip_ol_up_event(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_event()
1753 mlxsw_sp_netdevice_ipip_ol_down_event(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_event()
1759 err = mlxsw_sp_netdevice_ipip_ol_vrf_event(mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_event()
1765 err = mlxsw_sp_netdevice_ipip_ol_change_event(mlxsw_sp, in mlxsw_sp_netdevice_ipip_ol_event()
1769 err = mlxsw_sp_netdevice_ipip_ol_update_mtu(mlxsw_sp, ol_dev); in mlxsw_sp_netdevice_ipip_ol_event()
1772 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_netdevice_ipip_ol_event()
1777 __mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, in __mlxsw_sp_netdevice_ipip_ul_event() argument
1792 return mlxsw_sp_netdevice_ipip_ul_vrf_event(mlxsw_sp, in __mlxsw_sp_netdevice_ipip_ul_event()
1800 return mlxsw_sp_netdevice_ipip_ul_up_event(mlxsw_sp, ipip_entry, in __mlxsw_sp_netdevice_ipip_ul_event()
1803 return mlxsw_sp_netdevice_ipip_ul_down_event(mlxsw_sp, in __mlxsw_sp_netdevice_ipip_ul_event()
1811 mlxsw_sp_netdevice_ipip_ul_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_netdevice_ipip_ul_event() argument
1819 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_netdevice_ipip_ul_event()
1820 while ((ipip_entry = mlxsw_sp_ipip_entry_find_by_ul_dev(mlxsw_sp, in mlxsw_sp_netdevice_ipip_ul_event()
1826 err = __mlxsw_sp_netdevice_ipip_ul_event(mlxsw_sp, ipip_entry, in mlxsw_sp_netdevice_ipip_ul_event()
1830 mlxsw_sp_ipip_demote_tunnel_by_ul_netdev(mlxsw_sp, in mlxsw_sp_netdevice_ipip_ul_event()
1837 &mlxsw_sp->router->ipip_list)) in mlxsw_sp_netdevice_ipip_ul_event()
1845 mlxsw_sp_ipip_entry_demote_tunnel(mlxsw_sp, ipip_entry); in mlxsw_sp_netdevice_ipip_ul_event()
1849 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_netdevice_ipip_ul_event()
1854 int mlxsw_sp_router_nve_promote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, in mlxsw_sp_router_nve_promote_decap() argument
1860 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_router_nve_promote_decap()
1864 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_nve_promote_decap()
1880 fib_entry = mlxsw_sp_router_ip2me_fib_entry_find(mlxsw_sp, ul_tb_id, in mlxsw_sp_router_nve_promote_decap()
1889 err = mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry); in mlxsw_sp_router_nve_promote_decap()
1897 mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry); in mlxsw_sp_router_nve_promote_decap()
1899 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_nve_promote_decap()
1903 void mlxsw_sp_router_nve_demote_decap(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, in mlxsw_sp_router_nve_demote_decap() argument
1908 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_router_nve_demote_decap()
1911 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_nve_demote_decap()
1918 fib_entry = mlxsw_sp_router_ip2me_fib_entry_find(mlxsw_sp, ul_tb_id, in mlxsw_sp_router_nve_demote_decap()
1925 mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry); in mlxsw_sp_router_nve_demote_decap()
1927 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_nve_demote_decap()
1930 static bool mlxsw_sp_router_nve_is_decap(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_nve_is_decap() argument
1935 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_router_nve_is_decap()
2014 int mlxsw_sp_neigh_counter_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_counter_get() argument
2021 return mlxsw_sp_flow_counter_get(mlxsw_sp, neigh_entry->counter_index, in mlxsw_sp_neigh_counter_get()
2026 mlxsw_sp_neigh_entry_alloc(struct mlxsw_sp *mlxsw_sp, struct neighbour *n, in mlxsw_sp_neigh_entry_alloc() argument
2048 mlxsw_sp_neigh_entry_insert(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_entry_insert() argument
2051 return rhashtable_insert_fast(&mlxsw_sp->router->neigh_ht, in mlxsw_sp_neigh_entry_insert()
2057 mlxsw_sp_neigh_entry_remove(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_entry_remove() argument
2060 rhashtable_remove_fast(&mlxsw_sp->router->neigh_ht, in mlxsw_sp_neigh_entry_remove()
2066 mlxsw_sp_neigh_counter_should_alloc(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_counter_should_alloc() argument
2084 devlink = priv_to_devlink(mlxsw_sp->core); in mlxsw_sp_neigh_counter_should_alloc()
2089 mlxsw_sp_neigh_counter_alloc(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_counter_alloc() argument
2092 if (!mlxsw_sp_neigh_counter_should_alloc(mlxsw_sp, neigh_entry)) in mlxsw_sp_neigh_counter_alloc()
2095 if (mlxsw_sp_flow_counter_alloc(mlxsw_sp, &neigh_entry->counter_index)) in mlxsw_sp_neigh_counter_alloc()
2102 mlxsw_sp_neigh_counter_free(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_counter_free() argument
2107 mlxsw_sp_flow_counter_free(mlxsw_sp, in mlxsw_sp_neigh_counter_free()
2113 mlxsw_sp_neigh_entry_create(struct mlxsw_sp *mlxsw_sp, struct neighbour *n) in mlxsw_sp_neigh_entry_create() argument
2119 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, n->dev); in mlxsw_sp_neigh_entry_create()
2123 neigh_entry = mlxsw_sp_neigh_entry_alloc(mlxsw_sp, n, rif->rif_index); in mlxsw_sp_neigh_entry_create()
2127 err = mlxsw_sp_neigh_entry_insert(mlxsw_sp, neigh_entry); in mlxsw_sp_neigh_entry_create()
2131 mlxsw_sp_neigh_counter_alloc(mlxsw_sp, neigh_entry); in mlxsw_sp_neigh_entry_create()
2142 mlxsw_sp_neigh_entry_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_entry_destroy() argument
2146 mlxsw_sp_neigh_counter_free(mlxsw_sp, neigh_entry); in mlxsw_sp_neigh_entry_destroy()
2147 mlxsw_sp_neigh_entry_remove(mlxsw_sp, neigh_entry); in mlxsw_sp_neigh_entry_destroy()
2152 mlxsw_sp_neigh_entry_lookup(struct mlxsw_sp *mlxsw_sp, struct neighbour *n) in mlxsw_sp_neigh_entry_lookup() argument
2157 return rhashtable_lookup_fast(&mlxsw_sp->router->neigh_ht, in mlxsw_sp_neigh_entry_lookup()
2162 mlxsw_sp_router_neighs_update_interval_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_neighs_update_interval_init() argument
2173 mlxsw_sp->router->neighs_update.interval = jiffies_to_msecs(interval); in mlxsw_sp_router_neighs_update_interval_init()
2176 static void mlxsw_sp_router_neigh_ent_ipv4_process(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_neigh_ent_ipv4_process() argument
2188 if (!mlxsw_sp->router->rifs[rif]) { in mlxsw_sp_router_neigh_ent_ipv4_process()
2189 dev_err_ratelimited(mlxsw_sp->bus_info->dev, "Incorrect RIF in neighbour entry\n"); in mlxsw_sp_router_neigh_ent_ipv4_process()
2194 dev = mlxsw_sp->router->rifs[rif]->dev; in mlxsw_sp_router_neigh_ent_ipv4_process()
2205 static void mlxsw_sp_router_neigh_ent_ipv6_process(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_neigh_ent_ipv6_process() argument
2217 if (!mlxsw_sp->router->rifs[rif]) { in mlxsw_sp_router_neigh_ent_ipv6_process()
2218 dev_err_ratelimited(mlxsw_sp->bus_info->dev, "Incorrect RIF in neighbour entry\n"); in mlxsw_sp_router_neigh_ent_ipv6_process()
2222 dev = mlxsw_sp->router->rifs[rif]->dev; in mlxsw_sp_router_neigh_ent_ipv6_process()
2232 static void mlxsw_sp_router_neigh_ent_ipv6_process(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_neigh_ent_ipv6_process() argument
2239 static void mlxsw_sp_router_neigh_rec_ipv4_process(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_neigh_rec_ipv4_process() argument
2256 mlxsw_sp_router_neigh_ent_ipv4_process(mlxsw_sp, rauhtd_pl, in mlxsw_sp_router_neigh_rec_ipv4_process()
2262 static void mlxsw_sp_router_neigh_rec_ipv6_process(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_neigh_rec_ipv6_process() argument
2267 mlxsw_sp_router_neigh_ent_ipv6_process(mlxsw_sp, rauhtd_pl, in mlxsw_sp_router_neigh_rec_ipv6_process()
2271 static void mlxsw_sp_router_neigh_rec_process(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_neigh_rec_process() argument
2276 mlxsw_sp_router_neigh_rec_ipv4_process(mlxsw_sp, rauhtd_pl, in mlxsw_sp_router_neigh_rec_process()
2280 mlxsw_sp_router_neigh_rec_ipv6_process(mlxsw_sp, rauhtd_pl, in mlxsw_sp_router_neigh_rec_process()
2307 __mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp, in __mlxsw_sp_router_neighs_update_rauhtd() argument
2315 mutex_lock(&mlxsw_sp->router->lock); in __mlxsw_sp_router_neighs_update_rauhtd()
2318 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(rauhtd), in __mlxsw_sp_router_neighs_update_rauhtd()
2321 dev_err_ratelimited(mlxsw_sp->bus_info->dev, "Failed to dump neighbour table\n"); in __mlxsw_sp_router_neighs_update_rauhtd()
2326 mlxsw_sp_router_neigh_rec_process(mlxsw_sp, rauhtd_pl, in __mlxsw_sp_router_neighs_update_rauhtd()
2329 mutex_unlock(&mlxsw_sp->router->lock); in __mlxsw_sp_router_neighs_update_rauhtd()
2334 static int mlxsw_sp_router_neighs_update_rauhtd(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_neighs_update_rauhtd() argument
2345 err = __mlxsw_sp_router_neighs_update_rauhtd(mlxsw_sp, rauhtd_pl, type); in mlxsw_sp_router_neighs_update_rauhtd()
2350 err = __mlxsw_sp_router_neighs_update_rauhtd(mlxsw_sp, rauhtd_pl, type); in mlxsw_sp_router_neighs_update_rauhtd()
2356 static void mlxsw_sp_router_neighs_update_nh(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_neighs_update_nh() argument
2360 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_neighs_update_nh()
2361 list_for_each_entry(neigh_entry, &mlxsw_sp->router->nexthop_neighs_list, in mlxsw_sp_router_neighs_update_nh()
2367 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_neighs_update_nh()
2371 mlxsw_sp_router_neighs_update_work_schedule(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_neighs_update_work_schedule() argument
2373 unsigned long interval = mlxsw_sp->router->neighs_update.interval; in mlxsw_sp_router_neighs_update_work_schedule()
2375 mlxsw_core_schedule_dw(&mlxsw_sp->router->neighs_update.dw, in mlxsw_sp_router_neighs_update_work_schedule()
2386 err = mlxsw_sp_router_neighs_update_rauhtd(router->mlxsw_sp); in mlxsw_sp_router_neighs_update_work()
2388 dev_err(router->mlxsw_sp->bus_info->dev, "Could not update kernel for neigh activity"); in mlxsw_sp_router_neighs_update_work()
2390 mlxsw_sp_router_neighs_update_nh(router->mlxsw_sp); in mlxsw_sp_router_neighs_update_work()
2392 mlxsw_sp_router_neighs_update_work_schedule(router->mlxsw_sp); in mlxsw_sp_router_neighs_update_work()
2420 mlxsw_sp_nexthop_neigh_update(struct mlxsw_sp *mlxsw_sp,
2431 mlxsw_sp_router_neigh_entry_op4(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_neigh_entry_op4() argument
2444 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rauht), rauht_pl); in mlxsw_sp_router_neigh_entry_op4()
2448 mlxsw_sp_router_neigh_entry_op6(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_neigh_entry_op6() argument
2461 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rauht), rauht_pl); in mlxsw_sp_router_neigh_entry_op6()
2479 mlxsw_sp_neigh_entry_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_entry_update() argument
2490 err = mlxsw_sp_router_neigh_entry_op4(mlxsw_sp, neigh_entry, in mlxsw_sp_neigh_entry_update()
2497 err = mlxsw_sp_router_neigh_entry_op6(mlxsw_sp, neigh_entry, in mlxsw_sp_neigh_entry_update()
2513 mlxsw_sp_neigh_entry_counter_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_entry_counter_update() argument
2518 mlxsw_sp_neigh_counter_alloc(mlxsw_sp, neigh_entry); in mlxsw_sp_neigh_entry_counter_update()
2520 mlxsw_sp_neigh_counter_free(mlxsw_sp, neigh_entry); in mlxsw_sp_neigh_entry_counter_update()
2521 mlxsw_sp_neigh_entry_update(mlxsw_sp, neigh_entry, true); in mlxsw_sp_neigh_entry_counter_update()
2526 struct mlxsw_sp *mlxsw_sp; member
2534 struct mlxsw_sp *mlxsw_sp = net_work->mlxsw_sp; in mlxsw_sp_router_neigh_event_work() local
2551 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_neigh_event_work()
2552 mlxsw_sp_span_respin(mlxsw_sp); in mlxsw_sp_router_neigh_event_work()
2555 neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, n); in mlxsw_sp_router_neigh_event_work()
2559 neigh_entry = mlxsw_sp_neigh_entry_create(mlxsw_sp, n); in mlxsw_sp_router_neigh_event_work()
2565 mlxsw_sp_neigh_entry_update(mlxsw_sp, neigh_entry, entry_connected); in mlxsw_sp_router_neigh_event_work()
2566 mlxsw_sp_nexthop_neigh_update(mlxsw_sp, neigh_entry, !entry_connected, in mlxsw_sp_router_neigh_event_work()
2570 mlxsw_sp_neigh_entry_destroy(mlxsw_sp, neigh_entry); in mlxsw_sp_router_neigh_event_work()
2573 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_neigh_event_work()
2578 static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp);
2584 struct mlxsw_sp *mlxsw_sp = net_work->mlxsw_sp; in mlxsw_sp_router_mp_hash_event_work() local
2586 mlxsw_sp_mp_hash_init(mlxsw_sp); in mlxsw_sp_router_mp_hash_event_work()
2590 static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp);
2596 struct mlxsw_sp *mlxsw_sp = net_work->mlxsw_sp; in mlxsw_sp_router_update_priority_work() local
2598 __mlxsw_sp_router_init(mlxsw_sp); in mlxsw_sp_router_update_priority_work()
2610 if (!net_eq(net, mlxsw_sp_net(router->mlxsw_sp))) in mlxsw_sp_router_schedule_work()
2618 net_work->mlxsw_sp = router->mlxsw_sp; in mlxsw_sp_router_schedule_work()
2628 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_router_netevent_event() local
2649 mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_router_netevent_event()
2651 mlxsw_sp->router->neighs_update.interval = interval; in mlxsw_sp_router_netevent_event()
2672 net_work->mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_router_netevent_event()
2696 static int mlxsw_sp_neigh_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_neigh_init() argument
2700 err = rhashtable_init(&mlxsw_sp->router->neigh_ht, in mlxsw_sp_neigh_init()
2708 mlxsw_sp_router_neighs_update_interval_init(mlxsw_sp); in mlxsw_sp_neigh_init()
2711 INIT_DELAYED_WORK(&mlxsw_sp->router->neighs_update.dw, in mlxsw_sp_neigh_init()
2713 INIT_DELAYED_WORK(&mlxsw_sp->router->nexthop_probe_dw, in mlxsw_sp_neigh_init()
2715 mlxsw_core_schedule_dw(&mlxsw_sp->router->neighs_update.dw, 0); in mlxsw_sp_neigh_init()
2716 mlxsw_core_schedule_dw(&mlxsw_sp->router->nexthop_probe_dw, 0); in mlxsw_sp_neigh_init()
2720 static void mlxsw_sp_neigh_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_neigh_fini() argument
2722 cancel_delayed_work_sync(&mlxsw_sp->router->neighs_update.dw); in mlxsw_sp_neigh_fini()
2723 cancel_delayed_work_sync(&mlxsw_sp->router->nexthop_probe_dw); in mlxsw_sp_neigh_fini()
2724 rhashtable_destroy(&mlxsw_sp->router->neigh_ht); in mlxsw_sp_neigh_fini()
2727 static void mlxsw_sp_neigh_rif_gone_sync(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_neigh_rif_gone_sync() argument
2734 mlxsw_sp_neigh_entry_update(mlxsw_sp, neigh_entry, false); in mlxsw_sp_neigh_rif_gone_sync()
2735 mlxsw_sp_neigh_entry_destroy(mlxsw_sp, neigh_entry); in mlxsw_sp_neigh_rif_gone_sync()
2796 void mlxsw_sp_nexthop_counter_alloc(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_counter_alloc() argument
2801 devlink = priv_to_devlink(mlxsw_sp->core); in mlxsw_sp_nexthop_counter_alloc()
2806 if (mlxsw_sp_flow_counter_alloc(mlxsw_sp, &nh->counter_index)) in mlxsw_sp_nexthop_counter_alloc()
2812 void mlxsw_sp_nexthop_counter_free(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_counter_free() argument
2817 mlxsw_sp_flow_counter_free(mlxsw_sp, nh->counter_index); in mlxsw_sp_nexthop_counter_free()
2821 int mlxsw_sp_nexthop_counter_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_counter_get() argument
2827 return mlxsw_sp_flow_counter_get(mlxsw_sp, nh->counter_index, in mlxsw_sp_nexthop_counter_get()
3052 static int mlxsw_sp_nexthop_group_insert(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_group_insert() argument
3059 return rhashtable_insert_fast(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_nexthop_group_insert()
3064 static void mlxsw_sp_nexthop_group_remove(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_group_remove() argument
3071 rhashtable_remove_fast(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_nexthop_group_remove()
3077 mlxsw_sp_nexthop4_group_lookup(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_group_lookup() argument
3084 return rhashtable_lookup_fast(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_nexthop4_group_lookup()
3090 mlxsw_sp_nexthop6_group_lookup(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_group_lookup() argument
3097 return rhashtable_lookup_fast(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_nexthop6_group_lookup()
3108 static int mlxsw_sp_nexthop_insert(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_insert() argument
3111 return rhashtable_insert_fast(&mlxsw_sp->router->nexthop_ht, in mlxsw_sp_nexthop_insert()
3115 static void mlxsw_sp_nexthop_remove(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_remove() argument
3118 rhashtable_remove_fast(&mlxsw_sp->router->nexthop_ht, &nh->ht_node, in mlxsw_sp_nexthop_remove()
3123 mlxsw_sp_nexthop_lookup(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_lookup() argument
3126 return rhashtable_lookup_fast(&mlxsw_sp->router->nexthop_ht, &key, in mlxsw_sp_nexthop_lookup()
3130 static int mlxsw_sp_adj_index_mass_update_vr(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_adj_index_mass_update_vr() argument
3142 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(raleu), raleu_pl); in mlxsw_sp_adj_index_mass_update_vr()
3145 static int mlxsw_sp_adj_index_mass_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_adj_index_mass_update() argument
3157 err = mlxsw_sp_adj_index_mass_update_vr(mlxsw_sp, fib, in mlxsw_sp_adj_index_mass_update()
3168 static int __mlxsw_sp_nexthop_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index, in __mlxsw_sp_nexthop_update() argument
3183 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ratr), ratr_pl); in __mlxsw_sp_nexthop_update()
3186 int mlxsw_sp_nexthop_update(struct mlxsw_sp *mlxsw_sp, u32 adj_index, in mlxsw_sp_nexthop_update() argument
3194 err = __mlxsw_sp_nexthop_update(mlxsw_sp, adj_index + i, nh); in mlxsw_sp_nexthop_update()
3202 static int __mlxsw_sp_nexthop_ipip_update(struct mlxsw_sp *mlxsw_sp, in __mlxsw_sp_nexthop_ipip_update() argument
3208 ipip_ops = mlxsw_sp->router->ipip_ops_arr[nh->ipip_entry->ipipt]; in __mlxsw_sp_nexthop_ipip_update()
3209 return ipip_ops->nexthop_update(mlxsw_sp, adj_index, nh->ipip_entry); in __mlxsw_sp_nexthop_ipip_update()
3212 static int mlxsw_sp_nexthop_ipip_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_ipip_update() argument
3221 err = __mlxsw_sp_nexthop_ipip_update(mlxsw_sp, adj_index + i, in mlxsw_sp_nexthop_ipip_update()
3231 mlxsw_sp_nexthop_group_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_group_update() argument
3253 (mlxsw_sp, adj_index, nh); in mlxsw_sp_nexthop_group_update()
3257 (mlxsw_sp, adj_index, nh); in mlxsw_sp_nexthop_group_update()
3271 mlxsw_sp_nexthop_fib_entries_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_fib_entries_update() argument
3278 err = mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry); in mlxsw_sp_nexthop_fib_entries_update()
3315 static int mlxsw_sp_fix_adj_grp_size(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fix_adj_grp_size() argument
3325 err = mlxsw_sp_kvdl_alloc_count_query(mlxsw_sp, in mlxsw_sp_fix_adj_grp_size()
3393 mlxsw_sp_nexthop4_group_offload_refresh(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_group_offload_refresh() argument
3427 mlxsw_sp_nexthop6_group_offload_refresh(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_group_offload_refresh() argument
3442 mlxsw_sp_nexthop_group_offload_refresh(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_group_offload_refresh() argument
3447 mlxsw_sp_nexthop4_group_offload_refresh(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop_group_offload_refresh()
3450 mlxsw_sp_nexthop6_group_offload_refresh(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop_group_offload_refresh()
3456 mlxsw_sp_nexthop_group_refresh(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_group_refresh() argument
3469 mlxsw_sp_nexthop_fib_entries_update(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop_group_refresh()
3486 err = mlxsw_sp_nexthop_group_update(mlxsw_sp, nh_grp, false); in mlxsw_sp_nexthop_group_refresh()
3488 dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC in adjacency table.\n"); in mlxsw_sp_nexthop_group_refresh()
3501 err = mlxsw_sp_fix_adj_grp_size(mlxsw_sp, &ecmp_size); in mlxsw_sp_nexthop_group_refresh()
3506 err = mlxsw_sp_kvdl_alloc(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, in mlxsw_sp_nexthop_group_refresh()
3512 dev_warn(mlxsw_sp->bus_info->dev, "Failed to allocate KVD linear area for nexthop group.\n"); in mlxsw_sp_nexthop_group_refresh()
3522 err = mlxsw_sp_nexthop_group_update(mlxsw_sp, nh_grp, true); in mlxsw_sp_nexthop_group_refresh()
3524 dev_warn(mlxsw_sp->bus_info->dev, "Failed to update neigh MAC in adjacency table.\n"); in mlxsw_sp_nexthop_group_refresh()
3528 mlxsw_sp_nexthop_group_offload_refresh(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop_group_refresh()
3534 err = mlxsw_sp_nexthop_fib_entries_update(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop_group_refresh()
3536 dev_warn(mlxsw_sp->bus_info->dev, "Failed to add adjacency index to fib entries.\n"); in mlxsw_sp_nexthop_group_refresh()
3542 err = mlxsw_sp_adj_index_mass_update(mlxsw_sp, nh_grp, in mlxsw_sp_nexthop_group_refresh()
3544 mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, in mlxsw_sp_nexthop_group_refresh()
3547 dev_warn(mlxsw_sp->bus_info->dev, "Failed to mass-update adjacency index for nexthop group.\n"); in mlxsw_sp_nexthop_group_refresh()
3560 err = mlxsw_sp_nexthop_fib_entries_update(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop_group_refresh()
3562 dev_warn(mlxsw_sp->bus_info->dev, "Failed to set traps for fib entries.\n"); in mlxsw_sp_nexthop_group_refresh()
3563 mlxsw_sp_nexthop_group_offload_refresh(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop_group_refresh()
3565 mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, in mlxsw_sp_nexthop_group_refresh()
3580 mlxsw_sp_nexthop_dead_neigh_replace(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_dead_neigh_replace() argument
3601 mlxsw_sp_neigh_entry_remove(mlxsw_sp, neigh_entry); in mlxsw_sp_nexthop_dead_neigh_replace()
3603 err = mlxsw_sp_neigh_entry_insert(mlxsw_sp, neigh_entry); in mlxsw_sp_nexthop_dead_neigh_replace()
3618 mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh->nh_grp); in mlxsw_sp_nexthop_dead_neigh_replace()
3627 mlxsw_sp_neigh_entry_insert(mlxsw_sp, neigh_entry); in mlxsw_sp_nexthop_dead_neigh_replace()
3633 mlxsw_sp_nexthop_neigh_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_neigh_update() argument
3645 err = mlxsw_sp_nexthop_dead_neigh_replace(mlxsw_sp, in mlxsw_sp_nexthop_neigh_update()
3648 dev_err(mlxsw_sp->bus_info->dev, "Failed to replace dead neigh\n"); in mlxsw_sp_nexthop_neigh_update()
3655 mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh->nh_grp); in mlxsw_sp_nexthop_neigh_update()
3678 static int mlxsw_sp_nexthop_neigh_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_neigh_init() argument
3702 neigh_entry = mlxsw_sp_neigh_entry_lookup(mlxsw_sp, n); in mlxsw_sp_nexthop_neigh_init()
3704 neigh_entry = mlxsw_sp_neigh_entry_create(mlxsw_sp, n); in mlxsw_sp_nexthop_neigh_init()
3716 &mlxsw_sp->router->nexthop_neighs_list); in mlxsw_sp_nexthop_neigh_init()
3733 static void mlxsw_sp_nexthop_neigh_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_neigh_fini() argument
3754 mlxsw_sp_neigh_entry_destroy(mlxsw_sp, neigh_entry); in mlxsw_sp_nexthop_neigh_fini()
3772 static void mlxsw_sp_nexthop_ipip_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_ipip_init() argument
3787 static void mlxsw_sp_nexthop_ipip_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_ipip_fini() argument
3799 static bool mlxsw_sp_nexthop4_ipip_type(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_ipip_type() argument
3807 mlxsw_sp_netdev_ipip_type(mlxsw_sp, dev, p_ipipt); in mlxsw_sp_nexthop4_ipip_type()
3810 static void mlxsw_sp_nexthop_type_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_type_fini() argument
3815 mlxsw_sp_nexthop_neigh_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop_type_fini()
3820 mlxsw_sp_nexthop_ipip_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop_type_fini()
3825 static int mlxsw_sp_nexthop4_type_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_type_init() argument
3835 ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, dev); in mlxsw_sp_nexthop4_type_init()
3837 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_nexthop4_type_init()
3838 if (ipip_ops->can_offload(mlxsw_sp, dev, in mlxsw_sp_nexthop4_type_init()
3841 mlxsw_sp_nexthop_ipip_init(mlxsw_sp, nh, ipip_entry); in mlxsw_sp_nexthop4_type_init()
3847 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); in mlxsw_sp_nexthop4_type_init()
3852 err = mlxsw_sp_nexthop_neigh_init(mlxsw_sp, nh); in mlxsw_sp_nexthop4_type_init()
3863 static void mlxsw_sp_nexthop4_type_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_type_fini() argument
3866 mlxsw_sp_nexthop_type_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop4_type_fini()
3869 static int mlxsw_sp_nexthop4_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_init() argument
3886 err = mlxsw_sp_nexthop_insert(mlxsw_sp, nh); in mlxsw_sp_nexthop4_init()
3890 mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh); in mlxsw_sp_nexthop4_init()
3891 list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); in mlxsw_sp_nexthop4_init()
3905 err = mlxsw_sp_nexthop4_type_init(mlxsw_sp, nh, fib_nh); in mlxsw_sp_nexthop4_init()
3912 mlxsw_sp_nexthop_remove(mlxsw_sp, nh); in mlxsw_sp_nexthop4_init()
3916 static void mlxsw_sp_nexthop4_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_fini() argument
3919 mlxsw_sp_nexthop4_type_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop4_fini()
3921 mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh); in mlxsw_sp_nexthop4_fini()
3922 mlxsw_sp_nexthop_remove(mlxsw_sp, nh); in mlxsw_sp_nexthop4_fini()
3925 static void mlxsw_sp_nexthop4_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_event() argument
3931 if (mlxsw_sp->router->aborted) in mlxsw_sp_nexthop4_event()
3935 nh = mlxsw_sp_nexthop_lookup(mlxsw_sp, key); in mlxsw_sp_nexthop4_event()
3941 mlxsw_sp_nexthop4_type_init(mlxsw_sp, nh, fib_nh); in mlxsw_sp_nexthop4_event()
3944 mlxsw_sp_nexthop4_type_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop4_event()
3948 mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh->nh_grp); in mlxsw_sp_nexthop4_event()
3951 static void mlxsw_sp_nexthop_rif_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_rif_update() argument
3971 mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh->nh_grp); in mlxsw_sp_nexthop_rif_update()
3975 static void mlxsw_sp_nexthop_rif_migrate(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_rif_migrate() argument
3984 mlxsw_sp_nexthop_rif_update(mlxsw_sp, new_rif); in mlxsw_sp_nexthop_rif_migrate()
3987 static void mlxsw_sp_nexthop_rif_gone_sync(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop_rif_gone_sync() argument
3993 mlxsw_sp_nexthop_type_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop_rif_gone_sync()
3994 mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh->nh_grp); in mlxsw_sp_nexthop_rif_gone_sync()
3998 static bool mlxsw_sp_fi_is_gateway(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fi_is_gateway() argument
4004 mlxsw_sp_nexthop4_ipip_type(mlxsw_sp, nh, NULL); in mlxsw_sp_fi_is_gateway()
4008 mlxsw_sp_nexthop4_group_create(struct mlxsw_sp *mlxsw_sp, struct fib_info *fi) in mlxsw_sp_nexthop4_group_create() argument
4024 nh_grp->gateway = mlxsw_sp_fi_is_gateway(mlxsw_sp, fi); in mlxsw_sp_nexthop4_group_create()
4030 err = mlxsw_sp_nexthop4_init(mlxsw_sp, nh_grp, nh, fib_nh); in mlxsw_sp_nexthop4_group_create()
4034 err = mlxsw_sp_nexthop_group_insert(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop4_group_create()
4037 mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop4_group_create()
4044 mlxsw_sp_nexthop4_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop4_group_create()
4052 mlxsw_sp_nexthop4_group_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_group_destroy() argument
4058 mlxsw_sp_nexthop_group_remove(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop4_group_destroy()
4061 mlxsw_sp_nexthop4_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop4_group_destroy()
4063 mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop4_group_destroy()
4069 static int mlxsw_sp_nexthop4_group_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_group_get() argument
4075 nh_grp = mlxsw_sp_nexthop4_group_lookup(mlxsw_sp, fi); in mlxsw_sp_nexthop4_group_get()
4077 nh_grp = mlxsw_sp_nexthop4_group_create(mlxsw_sp, fi); in mlxsw_sp_nexthop4_group_get()
4086 static void mlxsw_sp_nexthop4_group_put(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop4_group_put() argument
4094 mlxsw_sp_nexthop4_group_destroy(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop4_group_put()
4156 mlxsw_sp_fib4_entry_hw_flags_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib4_entry_hw_flags_set() argument
4177 fib_alias_hw_flags_set(mlxsw_sp_net(mlxsw_sp), &fri); in mlxsw_sp_fib4_entry_hw_flags_set()
4181 mlxsw_sp_fib4_entry_hw_flags_clear(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib4_entry_hw_flags_clear() argument
4200 fib_alias_hw_flags_set(mlxsw_sp_net(mlxsw_sp), &fri); in mlxsw_sp_fib4_entry_hw_flags_clear()
4204 mlxsw_sp_fib6_entry_hw_flags_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib6_entry_hw_flags_set() argument
4224 mlxsw_sp_fib6_entry_hw_flags_clear(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib6_entry_hw_flags_clear() argument
4237 mlxsw_sp_fib_entry_hw_flags_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_hw_flags_set() argument
4242 mlxsw_sp_fib4_entry_hw_flags_set(mlxsw_sp, fib_entry); in mlxsw_sp_fib_entry_hw_flags_set()
4245 mlxsw_sp_fib6_entry_hw_flags_set(mlxsw_sp, fib_entry); in mlxsw_sp_fib_entry_hw_flags_set()
4251 mlxsw_sp_fib_entry_hw_flags_clear(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_hw_flags_clear() argument
4256 mlxsw_sp_fib4_entry_hw_flags_clear(mlxsw_sp, fib_entry); in mlxsw_sp_fib_entry_hw_flags_clear()
4259 mlxsw_sp_fib6_entry_hw_flags_clear(mlxsw_sp, fib_entry); in mlxsw_sp_fib_entry_hw_flags_clear()
4265 mlxsw_sp_fib_entry_hw_flags_refresh(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_hw_flags_refresh() argument
4271 mlxsw_sp_fib_entry_hw_flags_set(mlxsw_sp, fib_entry); in mlxsw_sp_fib_entry_hw_flags_refresh()
4274 mlxsw_sp_fib_entry_hw_flags_clear(mlxsw_sp, fib_entry); in mlxsw_sp_fib_entry_hw_flags_refresh()
4307 static int mlxsw_sp_adj_discard_write(struct mlxsw_sp *mlxsw_sp, u16 rif_index) in mlxsw_sp_adj_discard_write() argument
4313 if (mlxsw_sp->router->adj_discard_index_valid) in mlxsw_sp_adj_discard_write()
4316 err = mlxsw_sp_kvdl_alloc(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 1, in mlxsw_sp_adj_discard_write()
4317 &mlxsw_sp->router->adj_discard_index); in mlxsw_sp_adj_discard_write()
4324 mlxsw_sp->router->adj_discard_index, rif_index); in mlxsw_sp_adj_discard_write()
4326 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ratr), ratr_pl); in mlxsw_sp_adj_discard_write()
4330 mlxsw_sp->router->adj_discard_index_valid = true; in mlxsw_sp_adj_discard_write()
4335 mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 1, in mlxsw_sp_adj_discard_write()
4336 mlxsw_sp->router->adj_discard_index); in mlxsw_sp_adj_discard_write()
4340 static int mlxsw_sp_fib_entry_op_remote(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_op_remote() argument
4362 err = mlxsw_sp_adj_discard_write(mlxsw_sp, in mlxsw_sp_fib_entry_op_remote()
4367 adjacency_index = mlxsw_sp->router->adj_discard_index; in mlxsw_sp_fib_entry_op_remote()
4377 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralue), ralue_pl); in mlxsw_sp_fib_entry_op_remote()
4380 static int mlxsw_sp_fib_entry_op_local(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_op_local() argument
4401 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralue), ralue_pl); in mlxsw_sp_fib_entry_op_local()
4404 static int mlxsw_sp_fib_entry_op_trap(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_op_trap() argument
4412 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralue), ralue_pl); in mlxsw_sp_fib_entry_op_trap()
4415 static int mlxsw_sp_fib_entry_op_blackhole(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_op_blackhole() argument
4425 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralue), ralue_pl); in mlxsw_sp_fib_entry_op_blackhole()
4429 mlxsw_sp_fib_entry_op_unreachable(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_op_unreachable() argument
4442 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralue), ralue_pl); in mlxsw_sp_fib_entry_op_unreachable()
4446 mlxsw_sp_fib_entry_op_ipip_decap(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_op_ipip_decap() argument
4456 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_fib_entry_op_ipip_decap()
4457 return ipip_ops->fib_entry_op(mlxsw_sp, ipip_entry, op, in mlxsw_sp_fib_entry_op_ipip_decap()
4461 static int mlxsw_sp_fib_entry_op_nve_decap(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_op_nve_decap() argument
4470 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralue), ralue_pl); in mlxsw_sp_fib_entry_op_nve_decap()
4473 static int __mlxsw_sp_fib_entry_op(struct mlxsw_sp *mlxsw_sp, in __mlxsw_sp_fib_entry_op() argument
4479 return mlxsw_sp_fib_entry_op_remote(mlxsw_sp, fib_entry, op); in __mlxsw_sp_fib_entry_op()
4481 return mlxsw_sp_fib_entry_op_local(mlxsw_sp, fib_entry, op); in __mlxsw_sp_fib_entry_op()
4483 return mlxsw_sp_fib_entry_op_trap(mlxsw_sp, fib_entry, op); in __mlxsw_sp_fib_entry_op()
4485 return mlxsw_sp_fib_entry_op_blackhole(mlxsw_sp, fib_entry, op); in __mlxsw_sp_fib_entry_op()
4487 return mlxsw_sp_fib_entry_op_unreachable(mlxsw_sp, fib_entry, in __mlxsw_sp_fib_entry_op()
4490 return mlxsw_sp_fib_entry_op_ipip_decap(mlxsw_sp, in __mlxsw_sp_fib_entry_op()
4493 return mlxsw_sp_fib_entry_op_nve_decap(mlxsw_sp, fib_entry, op); in __mlxsw_sp_fib_entry_op()
4498 static int mlxsw_sp_fib_entry_op(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_op() argument
4502 int err = __mlxsw_sp_fib_entry_op(mlxsw_sp, fib_entry, op); in mlxsw_sp_fib_entry_op()
4507 mlxsw_sp_fib_entry_hw_flags_refresh(mlxsw_sp, fib_entry, op); in mlxsw_sp_fib_entry_op()
4512 static int mlxsw_sp_fib_entry_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_update() argument
4515 return mlxsw_sp_fib_entry_op(mlxsw_sp, fib_entry, in mlxsw_sp_fib_entry_update()
4519 static int mlxsw_sp_fib_entry_del(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_entry_del() argument
4522 return mlxsw_sp_fib_entry_op(mlxsw_sp, fib_entry, in mlxsw_sp_fib_entry_del()
4527 mlxsw_sp_fib4_entry_type_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib4_entry_type_set() argument
4533 struct mlxsw_sp_router *router = mlxsw_sp->router; in mlxsw_sp_fib4_entry_type_set()
4540 ipip_entry = mlxsw_sp_ipip_entry_find_by_decap(mlxsw_sp, dev, in mlxsw_sp_fib4_entry_type_set()
4544 return mlxsw_sp_fib_entry_decap_init(mlxsw_sp, in mlxsw_sp_fib4_entry_type_set()
4548 if (mlxsw_sp_router_nve_is_decap(mlxsw_sp, tb_id, in mlxsw_sp_fib4_entry_type_set()
4574 if (mlxsw_sp_fi_is_gateway(mlxsw_sp, fi)) in mlxsw_sp_fib4_entry_type_set()
4585 mlxsw_sp_fib4_entry_type_unset(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib4_entry_type_unset() argument
4590 mlxsw_sp_fib_entry_decap_fini(mlxsw_sp, fib_entry); in mlxsw_sp_fib4_entry_type_unset()
4598 mlxsw_sp_fib4_entry_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib4_entry_create() argument
4611 err = mlxsw_sp_fib4_entry_type_set(mlxsw_sp, fen_info, fib_entry); in mlxsw_sp_fib4_entry_create()
4615 err = mlxsw_sp_nexthop4_group_get(mlxsw_sp, fib_entry, fen_info->fi); in mlxsw_sp_fib4_entry_create()
4629 mlxsw_sp_fib4_entry_type_unset(mlxsw_sp, fib_entry); in mlxsw_sp_fib4_entry_create()
4635 static void mlxsw_sp_fib4_entry_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib4_entry_destroy() argument
4638 mlxsw_sp_nexthop4_group_put(mlxsw_sp, &fib4_entry->common); in mlxsw_sp_fib4_entry_destroy()
4639 mlxsw_sp_fib4_entry_type_unset(mlxsw_sp, &fib4_entry->common); in mlxsw_sp_fib4_entry_destroy()
4644 mlxsw_sp_fib4_entry_lookup(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib4_entry_lookup() argument
4652 vr = mlxsw_sp_vr_find(mlxsw_sp, fen_info->tb_id); in mlxsw_sp_fib4_entry_lookup()
4731 static int mlxsw_sp_fib_lpm_tree_link(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_lpm_tree_link() argument
4739 lpm_tree = mlxsw_sp->router->lpm.proto_trees[fib->proto]; 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()
4750 err = mlxsw_sp_vrs_lpm_tree_replace(mlxsw_sp, fib, lpm_tree); in mlxsw_sp_fib_lpm_tree_link()
4759 mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree); in mlxsw_sp_fib_lpm_tree_link()
4763 static void mlxsw_sp_fib_lpm_tree_unlink(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_lpm_tree_unlink() argument
4779 lpm_tree = mlxsw_sp_lpm_tree_get(mlxsw_sp, &req_prefix_usage, 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()
4794 static int mlxsw_sp_fib_node_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_node_init() argument
4805 err = mlxsw_sp_fib_lpm_tree_link(mlxsw_sp, fib_node); in mlxsw_sp_fib_node_init()
4817 static void mlxsw_sp_fib_node_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_node_fini() argument
4822 mlxsw_sp_fib_lpm_tree_unlink(mlxsw_sp, fib_node); in mlxsw_sp_fib_node_fini()
4828 mlxsw_sp_fib_node_get(struct mlxsw_sp *mlxsw_sp, u32 tb_id, const void *addr, in mlxsw_sp_fib_node_get() argument
4837 vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id, NULL); in mlxsw_sp_fib_node_get()
4852 err = mlxsw_sp_fib_node_init(mlxsw_sp, fib_node, fib); in mlxsw_sp_fib_node_get()
4861 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_fib_node_get()
4865 static void mlxsw_sp_fib_node_put(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_node_put() argument
4872 mlxsw_sp_fib_node_fini(mlxsw_sp, fib_node); in mlxsw_sp_fib_node_put()
4874 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_fib_node_put()
4877 static int mlxsw_sp_fib_node_entry_link(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_node_entry_link() argument
4885 err = mlxsw_sp_fib_entry_update(mlxsw_sp, fib_entry); in mlxsw_sp_fib_node_entry_link()
4897 mlxsw_sp_fib_node_entry_unlink(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_node_entry_unlink() argument
4902 mlxsw_sp_fib_entry_del(mlxsw_sp, fib_entry); in mlxsw_sp_fib_node_entry_unlink()
4924 mlxsw_sp_router_fib4_replace(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_fib4_replace() argument
4932 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fib4_replace()
4935 fib_node = mlxsw_sp_fib_node_get(mlxsw_sp, fen_info->tb_id, in mlxsw_sp_router_fib4_replace()
4940 dev_warn(mlxsw_sp->bus_info->dev, "Failed to get FIB node\n"); in mlxsw_sp_router_fib4_replace()
4944 fib4_entry = mlxsw_sp_fib4_entry_create(mlxsw_sp, fib_node, fen_info); in mlxsw_sp_router_fib4_replace()
4946 dev_warn(mlxsw_sp->bus_info->dev, "Failed to create FIB entry\n"); in mlxsw_sp_router_fib4_replace()
4952 mlxsw_sp_fib4_entry_destroy(mlxsw_sp, fib4_entry); in mlxsw_sp_router_fib4_replace()
4953 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_router_fib4_replace()
4958 err = mlxsw_sp_fib_node_entry_link(mlxsw_sp, &fib4_entry->common); in mlxsw_sp_router_fib4_replace()
4960 dev_warn(mlxsw_sp->bus_info->dev, "Failed to link FIB entry to node\n"); in mlxsw_sp_router_fib4_replace()
4968 mlxsw_sp_fib_entry_hw_flags_clear(mlxsw_sp, replaced); in mlxsw_sp_router_fib4_replace()
4971 mlxsw_sp_fib4_entry_destroy(mlxsw_sp, fib4_replaced); in mlxsw_sp_router_fib4_replace()
4977 mlxsw_sp_fib4_entry_destroy(mlxsw_sp, fib4_entry); in mlxsw_sp_router_fib4_replace()
4979 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_router_fib4_replace()
4983 static void mlxsw_sp_router_fib4_del(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_fib4_del() argument
4989 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fib4_del()
4992 fib4_entry = mlxsw_sp_fib4_entry_lookup(mlxsw_sp, fen_info); in mlxsw_sp_router_fib4_del()
4997 mlxsw_sp_fib_node_entry_unlink(mlxsw_sp, &fib4_entry->common); in mlxsw_sp_router_fib4_del()
4998 mlxsw_sp_fib4_entry_destroy(mlxsw_sp, fib4_entry); in mlxsw_sp_router_fib4_del()
4999 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_router_fib4_del()
5076 static bool mlxsw_sp_nexthop6_ipip_type(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_ipip_type() argument
5081 mlxsw_sp_netdev_ipip_type(mlxsw_sp, rt->fib6_nh->fib_nh_dev, ret); in mlxsw_sp_nexthop6_ipip_type()
5084 static int mlxsw_sp_nexthop6_type_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_type_init() argument
5095 ipip_entry = mlxsw_sp_ipip_entry_find_by_ol_dev(mlxsw_sp, dev); in mlxsw_sp_nexthop6_type_init()
5097 ipip_ops = mlxsw_sp->router->ipip_ops_arr[ipip_entry->ipipt]; in mlxsw_sp_nexthop6_type_init()
5098 if (ipip_ops->can_offload(mlxsw_sp, dev, in mlxsw_sp_nexthop6_type_init()
5101 mlxsw_sp_nexthop_ipip_init(mlxsw_sp, nh, ipip_entry); in mlxsw_sp_nexthop6_type_init()
5107 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); in mlxsw_sp_nexthop6_type_init()
5112 err = mlxsw_sp_nexthop_neigh_init(mlxsw_sp, nh); in mlxsw_sp_nexthop6_type_init()
5123 static void mlxsw_sp_nexthop6_type_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_type_fini() argument
5126 mlxsw_sp_nexthop_type_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop6_type_fini()
5129 static int mlxsw_sp_nexthop6_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_init() argument
5139 mlxsw_sp_nexthop_counter_alloc(mlxsw_sp, nh); in mlxsw_sp_nexthop6_init()
5141 list_add_tail(&nh->router_list_node, &mlxsw_sp->router->nexthop_list); in mlxsw_sp_nexthop6_init()
5147 return mlxsw_sp_nexthop6_type_init(mlxsw_sp, nh_grp, nh, rt); in mlxsw_sp_nexthop6_init()
5150 static void mlxsw_sp_nexthop6_fini(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_fini() argument
5153 mlxsw_sp_nexthop6_type_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop6_fini()
5155 mlxsw_sp_nexthop_counter_free(mlxsw_sp, nh); in mlxsw_sp_nexthop6_fini()
5158 static bool mlxsw_sp_rt6_is_gateway(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rt6_is_gateway() argument
5162 mlxsw_sp_nexthop6_ipip_type(mlxsw_sp, rt, NULL); in mlxsw_sp_rt6_is_gateway()
5166 mlxsw_sp_nexthop6_group_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_group_create() argument
5185 nh_grp->gateway = mlxsw_sp_rt6_is_gateway(mlxsw_sp, mlxsw_sp_rt6->rt); in mlxsw_sp_nexthop6_group_create()
5191 err = mlxsw_sp_nexthop6_init(mlxsw_sp, nh_grp, nh, rt); in mlxsw_sp_nexthop6_group_create()
5197 err = mlxsw_sp_nexthop_group_insert(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop6_group_create()
5201 mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop6_group_create()
5208 mlxsw_sp_nexthop6_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop6_group_create()
5215 mlxsw_sp_nexthop6_group_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_group_destroy() argument
5221 mlxsw_sp_nexthop_group_remove(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop6_group_destroy()
5224 mlxsw_sp_nexthop6_fini(mlxsw_sp, nh); in mlxsw_sp_nexthop6_group_destroy()
5226 mlxsw_sp_nexthop_group_refresh(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop6_group_destroy()
5231 static int mlxsw_sp_nexthop6_group_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_group_get() argument
5236 nh_grp = mlxsw_sp_nexthop6_group_lookup(mlxsw_sp, fib6_entry); in mlxsw_sp_nexthop6_group_get()
5238 nh_grp = mlxsw_sp_nexthop6_group_create(mlxsw_sp, fib6_entry); in mlxsw_sp_nexthop6_group_get()
5255 static void mlxsw_sp_nexthop6_group_put(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_group_put() argument
5263 mlxsw_sp_nexthop6_group_destroy(mlxsw_sp, nh_grp); in mlxsw_sp_nexthop6_group_put()
5267 mlxsw_sp_nexthop6_group_update(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_nexthop6_group_update() argument
5276 err = mlxsw_sp_nexthop6_group_get(mlxsw_sp, fib6_entry); in mlxsw_sp_nexthop6_group_update()
5284 err = mlxsw_sp_fib_entry_update(mlxsw_sp, &fib6_entry->common); in mlxsw_sp_nexthop6_group_update()
5289 mlxsw_sp_nexthop6_group_destroy(mlxsw_sp, old_nh_grp); in mlxsw_sp_nexthop6_group_update()
5294 mlxsw_sp_nexthop6_group_put(mlxsw_sp, &fib6_entry->common); in mlxsw_sp_nexthop6_group_update()
5303 mlxsw_sp_fib6_entry_nexthop_add(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib6_entry_nexthop_add() argument
5321 err = mlxsw_sp_nexthop6_group_update(mlxsw_sp, fib6_entry); in mlxsw_sp_fib6_entry_nexthop_add()
5341 mlxsw_sp_fib6_entry_nexthop_del(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib6_entry_nexthop_del() argument
5359 mlxsw_sp_nexthop6_group_update(mlxsw_sp, fib6_entry); in mlxsw_sp_fib6_entry_nexthop_del()
5362 static void mlxsw_sp_fib6_entry_type_set(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib6_entry_type_set() argument
5378 else if (mlxsw_sp_rt6_is_gateway(mlxsw_sp, rt)) in mlxsw_sp_fib6_entry_type_set()
5398 mlxsw_sp_fib6_entry_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib6_entry_create() argument
5424 mlxsw_sp_fib6_entry_type_set(mlxsw_sp, fib_entry, rt_arr[0]); in mlxsw_sp_fib6_entry_create()
5426 err = mlxsw_sp_nexthop6_group_get(mlxsw_sp, fib6_entry); in mlxsw_sp_fib6_entry_create()
5448 static void mlxsw_sp_fib6_entry_destroy(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib6_entry_destroy() argument
5451 mlxsw_sp_nexthop6_group_put(mlxsw_sp, &fib6_entry->common); in mlxsw_sp_fib6_entry_destroy()
5458 mlxsw_sp_fib6_entry_lookup(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib6_entry_lookup() argument
5467 vr = mlxsw_sp_vr_find(mlxsw_sp, rt->fib6_table->tb6_id); in mlxsw_sp_fib6_entry_lookup()
5510 static int mlxsw_sp_router_fib6_replace(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_fib6_replace() argument
5520 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fib6_replace()
5529 fib_node = mlxsw_sp_fib_node_get(mlxsw_sp, rt->fib6_table->tb6_id, in mlxsw_sp_router_fib6_replace()
5537 fib6_entry = mlxsw_sp_fib6_entry_create(mlxsw_sp, fib_node, rt_arr, in mlxsw_sp_router_fib6_replace()
5545 mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_entry); in mlxsw_sp_router_fib6_replace()
5546 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_router_fib6_replace()
5551 err = mlxsw_sp_fib_node_entry_link(mlxsw_sp, &fib6_entry->common); in mlxsw_sp_router_fib6_replace()
5559 mlxsw_sp_fib_entry_hw_flags_clear(mlxsw_sp, replaced); in mlxsw_sp_router_fib6_replace()
5562 mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_replaced); in mlxsw_sp_router_fib6_replace()
5568 mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_entry); in mlxsw_sp_router_fib6_replace()
5570 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_router_fib6_replace()
5574 static int mlxsw_sp_router_fib6_append(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_fib6_append() argument
5583 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fib6_append()
5592 fib_node = mlxsw_sp_fib_node_get(mlxsw_sp, rt->fib6_table->tb6_id, in mlxsw_sp_router_fib6_append()
5601 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_router_fib6_append()
5607 err = mlxsw_sp_fib6_entry_nexthop_add(mlxsw_sp, fib6_entry, rt_arr, in mlxsw_sp_router_fib6_append()
5615 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_router_fib6_append()
5619 static void mlxsw_sp_router_fib6_del(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_fib6_del() argument
5627 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fib6_del()
5638 fib6_entry = mlxsw_sp_fib6_entry_lookup(mlxsw_sp, rt); in mlxsw_sp_router_fib6_del()
5646 mlxsw_sp_fib6_entry_nexthop_del(mlxsw_sp, fib6_entry, rt_arr, in mlxsw_sp_router_fib6_del()
5653 mlxsw_sp_fib_node_entry_unlink(mlxsw_sp, &fib6_entry->common); in mlxsw_sp_router_fib6_del()
5654 mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_entry); in mlxsw_sp_router_fib6_del()
5655 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_router_fib6_del()
5658 static int __mlxsw_sp_router_set_abort_trap(struct mlxsw_sp *mlxsw_sp, in __mlxsw_sp_router_set_abort_trap() argument
5667 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralta), ralta_pl); in __mlxsw_sp_router_set_abort_trap()
5672 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralst), ralst_pl); in __mlxsw_sp_router_set_abort_trap()
5676 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) { in __mlxsw_sp_router_set_abort_trap()
5677 struct mlxsw_sp_vr *vr = &mlxsw_sp->router->vrs[i]; in __mlxsw_sp_router_set_abort_trap()
5682 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(raltb), in __mlxsw_sp_router_set_abort_trap()
5690 err = mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ralue), in __mlxsw_sp_router_set_abort_trap()
5708 static int mlxsw_sp_router_fibmr_add(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_fibmr_add() argument
5715 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fibmr_add()
5718 vr = mlxsw_sp_vr_get(mlxsw_sp, men_info->tb_id, NULL); in mlxsw_sp_router_fibmr_add()
5726 static void mlxsw_sp_router_fibmr_del(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_fibmr_del() argument
5732 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fibmr_del()
5735 vr = mlxsw_sp_vr_find(mlxsw_sp, men_info->tb_id); in mlxsw_sp_router_fibmr_del()
5741 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_router_fibmr_del()
5745 mlxsw_sp_router_fibmr_vif_add(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_fibmr_vif_add() argument
5752 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fibmr_vif_add()
5755 vr = mlxsw_sp_vr_get(mlxsw_sp, ven_info->tb_id, NULL); in mlxsw_sp_router_fibmr_vif_add()
5760 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, ven_info->dev); in mlxsw_sp_router_fibmr_vif_add()
5767 mlxsw_sp_router_fibmr_vif_del(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_fibmr_vif_del() argument
5773 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fibmr_vif_del()
5776 vr = mlxsw_sp_vr_find(mlxsw_sp, ven_info->tb_id); in mlxsw_sp_router_fibmr_vif_del()
5782 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_router_fibmr_vif_del()
5785 static int mlxsw_sp_router_set_abort_trap(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_set_abort_trap() argument
5790 err = __mlxsw_sp_router_set_abort_trap(mlxsw_sp, proto, in mlxsw_sp_router_set_abort_trap()
5800 return __mlxsw_sp_router_set_abort_trap(mlxsw_sp, proto, in mlxsw_sp_router_set_abort_trap()
5804 static void mlxsw_sp_fib4_node_flush(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib4_node_flush() argument
5811 mlxsw_sp_fib_node_entry_unlink(mlxsw_sp, fib_node->fib_entry); in mlxsw_sp_fib4_node_flush()
5812 mlxsw_sp_fib4_entry_destroy(mlxsw_sp, fib4_entry); in mlxsw_sp_fib4_node_flush()
5813 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_fib4_node_flush()
5816 static void mlxsw_sp_fib6_node_flush(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib6_node_flush() argument
5823 mlxsw_sp_fib_node_entry_unlink(mlxsw_sp, fib_node->fib_entry); in mlxsw_sp_fib6_node_flush()
5824 mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_entry); in mlxsw_sp_fib6_node_flush()
5825 mlxsw_sp_fib_node_put(mlxsw_sp, fib_node); in mlxsw_sp_fib6_node_flush()
5828 static void mlxsw_sp_fib_node_flush(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_fib_node_flush() argument
5833 mlxsw_sp_fib4_node_flush(mlxsw_sp, fib_node); in mlxsw_sp_fib_node_flush()
5836 mlxsw_sp_fib6_node_flush(mlxsw_sp, fib_node); in mlxsw_sp_fib_node_flush()
5841 static void mlxsw_sp_vr_fib_flush(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_vr_fib_flush() argument
5851 mlxsw_sp_fib_node_flush(mlxsw_sp, fib_node); in mlxsw_sp_vr_fib_flush()
5857 static void mlxsw_sp_router_fib_flush(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_fib_flush() argument
5861 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_VRS); i++) { in mlxsw_sp_router_fib_flush()
5862 struct mlxsw_sp_vr *vr = &mlxsw_sp->router->vrs[i]; in mlxsw_sp_router_fib_flush()
5869 mlxsw_sp_vr_fib_flush(mlxsw_sp, vr, MLXSW_SP_L3_PROTO_IPV4); in mlxsw_sp_router_fib_flush()
5876 mlxsw_sp_vr_fib_flush(mlxsw_sp, vr, MLXSW_SP_L3_PROTO_IPV6); in mlxsw_sp_router_fib_flush()
5883 if (!mlxsw_sp->router->adj_discard_index_valid) in mlxsw_sp_router_fib_flush()
5885 mlxsw_sp_kvdl_free(mlxsw_sp, MLXSW_SP_KVDL_ENTRY_TYPE_ADJ, 1, in mlxsw_sp_router_fib_flush()
5886 mlxsw_sp->router->adj_discard_index); in mlxsw_sp_router_fib_flush()
5887 mlxsw_sp->router->adj_discard_index_valid = false; in mlxsw_sp_router_fib_flush()
5890 static void mlxsw_sp_router_fib_abort(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_fib_abort() argument
5894 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fib_abort()
5896 …dev_warn(mlxsw_sp->bus_info->dev, "FIB abort triggered. Note that FIB entries are no longer being … in mlxsw_sp_router_fib_abort()
5897 mlxsw_sp_router_fib_flush(mlxsw_sp); in mlxsw_sp_router_fib_abort()
5898 mlxsw_sp->router->aborted = true; in mlxsw_sp_router_fib_abort()
5899 err = mlxsw_sp_router_set_abort_trap(mlxsw_sp); in mlxsw_sp_router_fib_abort()
5901 dev_warn(mlxsw_sp->bus_info->dev, "Failed to set abort trap.\n"); in mlxsw_sp_router_fib_abort()
5919 struct mlxsw_sp *mlxsw_sp; member
5975 struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp; in mlxsw_sp_router_fib4_event_work() local
5978 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fib4_event_work()
5979 mlxsw_sp_span_respin(mlxsw_sp); in mlxsw_sp_router_fib4_event_work()
5983 err = mlxsw_sp_router_fib4_replace(mlxsw_sp, in mlxsw_sp_router_fib4_event_work()
5986 mlxsw_sp_router_fib_abort(mlxsw_sp); in mlxsw_sp_router_fib4_event_work()
5990 mlxsw_sp_router_fib4_del(mlxsw_sp, &fib_work->fen_info); in mlxsw_sp_router_fib4_event_work()
5995 mlxsw_sp_nexthop4_event(mlxsw_sp, fib_work->event, in mlxsw_sp_router_fib4_event_work()
6000 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fib4_event_work()
6008 struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp; in mlxsw_sp_router_fib6_event_work() local
6011 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fib6_event_work()
6012 mlxsw_sp_span_respin(mlxsw_sp); in mlxsw_sp_router_fib6_event_work()
6016 err = mlxsw_sp_router_fib6_replace(mlxsw_sp, in mlxsw_sp_router_fib6_event_work()
6020 mlxsw_sp_router_fib_abort(mlxsw_sp); in mlxsw_sp_router_fib6_event_work()
6024 err = mlxsw_sp_router_fib6_append(mlxsw_sp, in mlxsw_sp_router_fib6_event_work()
6028 mlxsw_sp_router_fib_abort(mlxsw_sp); in mlxsw_sp_router_fib6_event_work()
6032 mlxsw_sp_router_fib6_del(mlxsw_sp, in mlxsw_sp_router_fib6_event_work()
6038 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fib6_event_work()
6046 struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp; in mlxsw_sp_router_fibmr_event_work() local
6051 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fibmr_event_work()
6057 err = mlxsw_sp_router_fibmr_add(mlxsw_sp, &fib_work->men_info, in mlxsw_sp_router_fibmr_event_work()
6060 mlxsw_sp_router_fib_abort(mlxsw_sp); in mlxsw_sp_router_fibmr_event_work()
6064 mlxsw_sp_router_fibmr_del(mlxsw_sp, &fib_work->men_info); in mlxsw_sp_router_fibmr_event_work()
6068 err = mlxsw_sp_router_fibmr_vif_add(mlxsw_sp, in mlxsw_sp_router_fibmr_event_work()
6071 mlxsw_sp_router_fib_abort(mlxsw_sp); in mlxsw_sp_router_fibmr_event_work()
6075 mlxsw_sp_router_fibmr_vif_del(mlxsw_sp, in mlxsw_sp_router_fibmr_event_work()
6080 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_fibmr_event_work()
6155 struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_fib_rule_event() argument
6166 if (mlxsw_sp->router->aborted) in mlxsw_sp_router_fib_rule_event()
6173 if (rule->iifindex == mlxsw_sp_net(mlxsw_sp)->loopback_dev->ifindex) in mlxsw_sp_router_fib_rule_event()
6221 router->mlxsw_sp); in mlxsw_sp_router_fib_event()
6259 fib_work->mlxsw_sp = router->mlxsw_sp; in mlxsw_sp_router_fib_event()
6290 mlxsw_sp_rif_find_by_dev(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_find_by_dev() argument
6295 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) in mlxsw_sp_rif_find_by_dev()
6296 if (mlxsw_sp->router->rifs[i] && in mlxsw_sp_rif_find_by_dev()
6297 mlxsw_sp->router->rifs[i]->dev == dev) in mlxsw_sp_rif_find_by_dev()
6298 return mlxsw_sp->router->rifs[i]; in mlxsw_sp_rif_find_by_dev()
6303 bool mlxsw_sp_rif_exists(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_exists() argument
6308 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_exists()
6309 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); in mlxsw_sp_rif_exists()
6310 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_exists()
6315 u16 mlxsw_sp_rif_vid(struct mlxsw_sp *mlxsw_sp, const struct net_device *dev) in mlxsw_sp_rif_vid() argument
6320 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_vid()
6321 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); in mlxsw_sp_rif_vid()
6334 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_vid()
6338 static int mlxsw_sp_router_rif_disable(struct mlxsw_sp *mlxsw_sp, u16 rif) in mlxsw_sp_router_rif_disable() argument
6344 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_router_rif_disable()
6349 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_router_rif_disable()
6352 static void mlxsw_sp_router_rif_gone_sync(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_rif_gone_sync() argument
6355 mlxsw_sp_router_rif_disable(mlxsw_sp, rif->rif_index); in mlxsw_sp_router_rif_gone_sync()
6356 mlxsw_sp_nexthop_rif_gone_sync(mlxsw_sp, rif); in mlxsw_sp_router_rif_gone_sync()
6357 mlxsw_sp_neigh_rif_gone_sync(mlxsw_sp, rif); in mlxsw_sp_router_rif_gone_sync()
6403 mlxsw_sp_dev_rif_type(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_dev_rif_type() argument
6408 if (mlxsw_sp_netdev_ipip_type(mlxsw_sp, dev, NULL)) in mlxsw_sp_dev_rif_type()
6421 return mlxsw_sp_fid_type_rif_type(mlxsw_sp, type); in mlxsw_sp_dev_rif_type()
6424 static int mlxsw_sp_rif_index_alloc(struct mlxsw_sp *mlxsw_sp, u16 *p_rif_index) in mlxsw_sp_rif_index_alloc() argument
6428 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) { in mlxsw_sp_rif_index_alloc()
6429 if (!mlxsw_sp->router->rifs[i]) { in mlxsw_sp_rif_index_alloc()
6461 struct mlxsw_sp_rif *mlxsw_sp_rif_by_index(const struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_by_index() argument
6464 return mlxsw_sp->router->rifs[rif_index]; in mlxsw_sp_rif_by_index()
6482 ul_vr = mlxsw_sp_vr_get(lb_rif->common.mlxsw_sp, ul_tb_id, NULL); in mlxsw_sp_ipip_lb_ul_vr_id()
6505 mlxsw_sp_rif_create(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_create() argument
6518 type = mlxsw_sp_dev_rif_type(mlxsw_sp, params->dev); in mlxsw_sp_rif_create()
6519 ops = mlxsw_sp->rif_ops_arr[type]; in mlxsw_sp_rif_create()
6521 vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id ? : RT_TABLE_MAIN, extack); in mlxsw_sp_rif_create()
6526 err = mlxsw_sp_rif_index_alloc(mlxsw_sp, &rif_index); in mlxsw_sp_rif_create()
6538 mlxsw_sp->router->rifs[rif_index] = rif; in mlxsw_sp_rif_create()
6539 rif->mlxsw_sp = mlxsw_sp; in mlxsw_sp_rif_create()
6576 mlxsw_sp->router->rifs[rif_index] = NULL; in mlxsw_sp_rif_create()
6582 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_rif_create()
6589 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp_rif_destroy() local
6594 mlxsw_sp_router_rif_gone_sync(mlxsw_sp, rif); in mlxsw_sp_rif_destroy()
6595 vr = &mlxsw_sp->router->vrs[rif->vr_id]; in mlxsw_sp_rif_destroy()
6604 mlxsw_sp->router->rifs[rif->rif_index] = NULL; in mlxsw_sp_rif_destroy()
6608 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_rif_destroy()
6611 void mlxsw_sp_rif_destroy_by_dev(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_destroy_by_dev() argument
6616 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_destroy_by_dev()
6617 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); in mlxsw_sp_rif_destroy_by_dev()
6622 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_destroy_by_dev()
6646 mlxsw_sp_rif_subport_get(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_subport_get() argument
6653 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, params->dev); in mlxsw_sp_rif_subport_get()
6655 return mlxsw_sp_rif_create(mlxsw_sp, params, extack); in mlxsw_sp_rif_subport_get()
6679 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vlan_router_join() local
6689 rif = mlxsw_sp_rif_subport_get(mlxsw_sp, ¶ms, extack); in mlxsw_sp_port_vlan_router_join()
6744 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port_vlan->mlxsw_sp_port->mlxsw_sp; in mlxsw_sp_port_vlan_router_leave() local
6746 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_port_vlan_router_leave()
6748 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_port_vlan_router_leave()
6822 static int mlxsw_sp_inetaddr_bridge_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_inetaddr_bridge_event() argument
6834 rif = mlxsw_sp_rif_create(mlxsw_sp, ¶ms, extack); in mlxsw_sp_inetaddr_bridge_event()
6839 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev); in mlxsw_sp_inetaddr_bridge_event()
6847 static int mlxsw_sp_inetaddr_vlan_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_inetaddr_vlan_event() argument
6865 return mlxsw_sp_inetaddr_bridge_event(mlxsw_sp, vlan_dev, event, in mlxsw_sp_inetaddr_vlan_event()
6887 static int mlxsw_sp_rif_vrrp_op(struct mlxsw_sp *mlxsw_sp, u16 rif_index, in mlxsw_sp_rif_vrrp_op() argument
6899 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_vrrp_op()
6908 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_vrrp_op()
6911 static int mlxsw_sp_rif_macvlan_add(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_macvlan_add() argument
6919 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, vlan->lowerdev); in mlxsw_sp_rif_macvlan_add()
6925 err = mlxsw_sp_rif_fdb_op(mlxsw_sp, macvlan_dev->dev_addr, in mlxsw_sp_rif_macvlan_add()
6930 err = mlxsw_sp_rif_vrrp_op(mlxsw_sp, rif->rif_index, in mlxsw_sp_rif_macvlan_add()
6944 mlxsw_sp_rif_fdb_op(mlxsw_sp, macvlan_dev->dev_addr, in mlxsw_sp_rif_macvlan_add()
6949 static void __mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp, in __mlxsw_sp_rif_macvlan_del() argument
6955 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, vlan->lowerdev); in __mlxsw_sp_rif_macvlan_del()
6961 mlxsw_sp_rif_vrrp_op(mlxsw_sp, rif->rif_index, macvlan_dev->dev_addr, in __mlxsw_sp_rif_macvlan_del()
6963 mlxsw_sp_rif_fdb_op(mlxsw_sp, macvlan_dev->dev_addr, in __mlxsw_sp_rif_macvlan_del()
6967 void mlxsw_sp_rif_macvlan_del(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_rif_macvlan_del() argument
6970 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_macvlan_del()
6971 __mlxsw_sp_rif_macvlan_del(mlxsw_sp, macvlan_dev); in mlxsw_sp_rif_macvlan_del()
6972 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_rif_macvlan_del()
6975 static int mlxsw_sp_inetaddr_macvlan_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_inetaddr_macvlan_event() argument
6982 return mlxsw_sp_rif_macvlan_add(mlxsw_sp, macvlan_dev, extack); in mlxsw_sp_inetaddr_macvlan_event()
6984 __mlxsw_sp_rif_macvlan_del(mlxsw_sp, macvlan_dev); in mlxsw_sp_inetaddr_macvlan_event()
6991 static int mlxsw_sp_router_port_check_rif_addr(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_port_check_rif_addr() argument
7005 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) { in mlxsw_sp_router_port_check_rif_addr()
7006 rif = mlxsw_sp->router->rifs[i]; in mlxsw_sp_router_port_check_rif_addr()
7012 mlxsw_sp->mac_mask)) { in mlxsw_sp_router_port_check_rif_addr()
7021 static int __mlxsw_sp_inetaddr_event(struct mlxsw_sp *mlxsw_sp, in __mlxsw_sp_inetaddr_event() argument
7031 return mlxsw_sp_inetaddr_bridge_event(mlxsw_sp, dev, event, in __mlxsw_sp_inetaddr_event()
7034 return mlxsw_sp_inetaddr_vlan_event(mlxsw_sp, dev, event, in __mlxsw_sp_inetaddr_event()
7037 return mlxsw_sp_inetaddr_macvlan_event(mlxsw_sp, dev, event, in __mlxsw_sp_inetaddr_event()
7058 rif = mlxsw_sp_rif_find_by_dev(router->mlxsw_sp, dev); in mlxsw_sp_inetaddr_event()
7062 err = __mlxsw_sp_inetaddr_event(router->mlxsw_sp, dev, event, NULL); in mlxsw_sp_inetaddr_event()
7073 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_inetaddr_valid_event() local
7077 mlxsw_sp = mlxsw_sp_lower_get(dev); in mlxsw_sp_inetaddr_valid_event()
7078 if (!mlxsw_sp) in mlxsw_sp_inetaddr_valid_event()
7081 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_inetaddr_valid_event()
7082 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); in mlxsw_sp_inetaddr_valid_event()
7086 err = mlxsw_sp_router_port_check_rif_addr(mlxsw_sp, dev, dev->dev_addr, in mlxsw_sp_inetaddr_valid_event()
7091 err = __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, ivi->extack); in mlxsw_sp_inetaddr_valid_event()
7093 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_inetaddr_valid_event()
7099 struct mlxsw_sp *mlxsw_sp; member
7108 struct mlxsw_sp *mlxsw_sp = inet6addr_work->mlxsw_sp; in mlxsw_sp_inet6addr_event_work() local
7114 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_inet6addr_event_work()
7116 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); in mlxsw_sp_inet6addr_event_work()
7120 __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, NULL); in mlxsw_sp_inet6addr_event_work()
7122 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_inet6addr_event_work()
7147 inet6addr_work->mlxsw_sp = router->mlxsw_sp; in mlxsw_sp_inet6addr_event()
7161 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_inet6addr_valid_event() local
7165 mlxsw_sp = mlxsw_sp_lower_get(dev); in mlxsw_sp_inet6addr_valid_event()
7166 if (!mlxsw_sp) in mlxsw_sp_inet6addr_valid_event()
7169 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_inet6addr_valid_event()
7170 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); in mlxsw_sp_inet6addr_valid_event()
7174 err = mlxsw_sp_router_port_check_rif_addr(mlxsw_sp, dev, dev->dev_addr, in mlxsw_sp_inet6addr_valid_event()
7179 err = __mlxsw_sp_inetaddr_event(mlxsw_sp, dev, event, i6vi->extack); in mlxsw_sp_inet6addr_valid_event()
7181 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_inet6addr_valid_event()
7185 static int mlxsw_sp_rif_edit(struct mlxsw_sp *mlxsw_sp, u16 rif_index, in mlxsw_sp_rif_edit() argument
7192 err = mlxsw_reg_query(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_edit()
7199 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_edit()
7203 mlxsw_sp_router_port_change_event(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_port_change_event() argument
7212 err = mlxsw_sp_rif_fdb_op(mlxsw_sp, rif->addr, fid_index, false); in mlxsw_sp_router_port_change_event()
7216 err = mlxsw_sp_rif_edit(mlxsw_sp, rif->rif_index, dev->dev_addr, in mlxsw_sp_router_port_change_event()
7221 err = mlxsw_sp_rif_fdb_op(mlxsw_sp, dev->dev_addr, fid_index, true); in mlxsw_sp_router_port_change_event()
7233 vr = &mlxsw_sp->router->vrs[rif->vr_id]; in mlxsw_sp_router_port_change_event()
7247 mlxsw_sp_rif_edit(mlxsw_sp, rif->rif_index, rif->addr, rif->mtu); in mlxsw_sp_router_port_change_event()
7249 mlxsw_sp_rif_fdb_op(mlxsw_sp, rif->addr, fid_index, true); in mlxsw_sp_router_port_change_event()
7259 return mlxsw_sp_router_port_check_rif_addr(rif->mlxsw_sp, rif->dev, in mlxsw_sp_router_port_pre_changeaddr_event()
7266 struct mlxsw_sp *mlxsw_sp; in mlxsw_sp_netdevice_router_port_event() local
7270 mlxsw_sp = mlxsw_sp_lower_get(dev); in mlxsw_sp_netdevice_router_port_event()
7271 if (!mlxsw_sp) in mlxsw_sp_netdevice_router_port_event()
7274 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_netdevice_router_port_event()
7275 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, dev); in mlxsw_sp_netdevice_router_port_event()
7282 err = mlxsw_sp_router_port_change_event(mlxsw_sp, rif); in mlxsw_sp_netdevice_router_port_event()
7290 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_netdevice_router_port_event()
7294 static int mlxsw_sp_port_vrf_join(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_vrf_join() argument
7303 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev); in mlxsw_sp_port_vrf_join()
7305 __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_DOWN, in mlxsw_sp_port_vrf_join()
7308 return __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_UP, extack); in mlxsw_sp_port_vrf_join()
7311 static void mlxsw_sp_port_vrf_leave(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_port_vrf_leave() argument
7316 rif = mlxsw_sp_rif_find_by_dev(mlxsw_sp, l3_dev); in mlxsw_sp_port_vrf_leave()
7319 __mlxsw_sp_inetaddr_event(mlxsw_sp, l3_dev, NETDEV_DOWN, NULL); in mlxsw_sp_port_vrf_leave()
7325 struct mlxsw_sp *mlxsw_sp = mlxsw_sp_lower_get(l3_dev); in mlxsw_sp_netdevice_vrf_event() local
7331 if (!mlxsw_sp || netif_is_macvlan(l3_dev)) in mlxsw_sp_netdevice_vrf_event()
7334 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_netdevice_vrf_event()
7343 err = mlxsw_sp_port_vrf_join(mlxsw_sp, l3_dev, extack); in mlxsw_sp_netdevice_vrf_event()
7345 mlxsw_sp_port_vrf_leave(mlxsw_sp, l3_dev); in mlxsw_sp_netdevice_vrf_event()
7349 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_netdevice_vrf_event()
7362 return mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, dev->dev_addr, in __mlxsw_sp_rif_macvlan_flush()
7397 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp_rif_subport_op() local
7410 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_subport_op()
7421 err = mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, rif->dev->dev_addr, in mlxsw_sp_rif_subport_configure()
7439 mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, rif->dev->dev_addr, in mlxsw_sp_rif_subport_deconfigure()
7449 return mlxsw_sp_fid_rfid_get(rif->mlxsw_sp, rif->rif_index); in mlxsw_sp_rif_subport_fid_get()
7465 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp_rif_vlan_fid_op() local
7473 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_vlan_fid_op()
7476 u8 mlxsw_sp_router_port(const struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_port() argument
7478 return mlxsw_core_max_ports(mlxsw_sp->core) + 1; in mlxsw_sp_router_port()
7483 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp_rif_fid_configure() local
7493 mlxsw_sp_router_port(mlxsw_sp), true); in mlxsw_sp_rif_fid_configure()
7498 mlxsw_sp_router_port(mlxsw_sp), true); in mlxsw_sp_rif_fid_configure()
7502 err = mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, rif->dev->dev_addr, in mlxsw_sp_rif_fid_configure()
7512 mlxsw_sp_router_port(mlxsw_sp), false); in mlxsw_sp_rif_fid_configure()
7515 mlxsw_sp_router_port(mlxsw_sp), false); in mlxsw_sp_rif_fid_configure()
7524 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp_rif_fid_deconfigure() local
7528 mlxsw_sp_rif_fdb_op(rif->mlxsw_sp, rif->dev->dev_addr, in mlxsw_sp_rif_fid_deconfigure()
7532 mlxsw_sp_router_port(mlxsw_sp), false); in mlxsw_sp_rif_fid_deconfigure()
7534 mlxsw_sp_router_port(mlxsw_sp), false); in mlxsw_sp_rif_fid_deconfigure()
7542 return mlxsw_sp_fid_8021d_get(rif->mlxsw_sp, rif->dev->ifindex); in mlxsw_sp_rif_fid_fid_get()
7590 return mlxsw_sp_fid_8021q_get(rif->mlxsw_sp, vid); in mlxsw_sp_rif_vlan_fid_get()
7644 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp1_rif_ipip_lb_configure() local
7648 ul_vr = mlxsw_sp_vr_get(mlxsw_sp, ul_tb_id, NULL); in mlxsw_sp1_rif_ipip_lb_configure()
7662 mlxsw_sp_vr_put(mlxsw_sp, ul_vr); in mlxsw_sp1_rif_ipip_lb_configure()
7669 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp1_rif_ipip_lb_deconfigure() local
7672 ul_vr = &mlxsw_sp->router->vrs[lb_rif->ul_vr_id]; in mlxsw_sp1_rif_ipip_lb_deconfigure()
7676 mlxsw_sp_vr_put(mlxsw_sp, ul_vr); in mlxsw_sp1_rif_ipip_lb_deconfigure()
7697 struct mlxsw_sp *mlxsw_sp = ul_rif->mlxsw_sp; in mlxsw_sp_rif_ipip_lb_ul_rif_op() local
7705 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(ritr), ritr_pl); in mlxsw_sp_rif_ipip_lb_ul_rif_op()
7709 mlxsw_sp_ul_rif_create(struct mlxsw_sp *mlxsw_sp, struct mlxsw_sp_vr *vr, in mlxsw_sp_ul_rif_create() argument
7716 err = mlxsw_sp_rif_index_alloc(mlxsw_sp, &rif_index); in mlxsw_sp_ul_rif_create()
7726 mlxsw_sp->router->rifs[rif_index] = ul_rif; in mlxsw_sp_ul_rif_create()
7727 ul_rif->mlxsw_sp = mlxsw_sp; in mlxsw_sp_ul_rif_create()
7735 mlxsw_sp->router->rifs[rif_index] = NULL; in mlxsw_sp_ul_rif_create()
7742 struct mlxsw_sp *mlxsw_sp = ul_rif->mlxsw_sp; in mlxsw_sp_ul_rif_destroy() local
7745 mlxsw_sp->router->rifs[ul_rif->rif_index] = NULL; in mlxsw_sp_ul_rif_destroy()
7750 mlxsw_sp_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 tb_id, in mlxsw_sp_ul_rif_get() argument
7756 vr = mlxsw_sp_vr_get(mlxsw_sp, tb_id, extack); in mlxsw_sp_ul_rif_get()
7763 vr->ul_rif = mlxsw_sp_ul_rif_create(mlxsw_sp, vr, extack); in mlxsw_sp_ul_rif_get()
7775 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_ul_rif_get()
7781 struct mlxsw_sp *mlxsw_sp = ul_rif->mlxsw_sp; in mlxsw_sp_ul_rif_put() local
7784 vr = &mlxsw_sp->router->vrs[ul_rif->vr_id]; in mlxsw_sp_ul_rif_put()
7791 mlxsw_sp_vr_put(mlxsw_sp, vr); in mlxsw_sp_ul_rif_put()
7794 int mlxsw_sp_router_ul_rif_get(struct mlxsw_sp *mlxsw_sp, u32 ul_tb_id, in mlxsw_sp_router_ul_rif_get() argument
7800 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_ul_rif_get()
7801 ul_rif = mlxsw_sp_ul_rif_get(mlxsw_sp, ul_tb_id, NULL); in mlxsw_sp_router_ul_rif_get()
7808 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_ul_rif_get()
7812 void mlxsw_sp_router_ul_rif_put(struct mlxsw_sp *mlxsw_sp, u16 ul_rif_index) in mlxsw_sp_router_ul_rif_put() argument
7816 mutex_lock(&mlxsw_sp->router->lock); in mlxsw_sp_router_ul_rif_put()
7817 ul_rif = mlxsw_sp->router->rifs[ul_rif_index]; in mlxsw_sp_router_ul_rif_put()
7823 mutex_unlock(&mlxsw_sp->router->lock); in mlxsw_sp_router_ul_rif_put()
7831 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp2_rif_ipip_lb_configure() local
7835 ul_rif = mlxsw_sp_ul_rif_get(mlxsw_sp, ul_tb_id, NULL); in mlxsw_sp2_rif_ipip_lb_configure()
7856 struct mlxsw_sp *mlxsw_sp = rif->mlxsw_sp; in mlxsw_sp2_rif_ipip_lb_deconfigure() local
7859 ul_rif = mlxsw_sp_rif_by_index(mlxsw_sp, lb_rif->ul_rif_id); in mlxsw_sp2_rif_ipip_lb_deconfigure()
7879 static int mlxsw_sp_rifs_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_rifs_init() argument
7881 u64 max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); in mlxsw_sp_rifs_init()
7883 mlxsw_sp->router->rifs = kcalloc(max_rifs, in mlxsw_sp_rifs_init()
7886 if (!mlxsw_sp->router->rifs) in mlxsw_sp_rifs_init()
7892 static void mlxsw_sp_rifs_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_rifs_fini() argument
7896 for (i = 0; i < MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); i++) in mlxsw_sp_rifs_fini()
7897 WARN_ON_ONCE(mlxsw_sp->router->rifs[i]); in mlxsw_sp_rifs_fini()
7899 kfree(mlxsw_sp->router->rifs); in mlxsw_sp_rifs_fini()
7903 mlxsw_sp_ipip_config_tigcr(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ipip_config_tigcr() argument
7908 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(tigcr), tigcr_pl); in mlxsw_sp_ipip_config_tigcr()
7911 static int mlxsw_sp_ipips_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ipips_init() argument
7915 mlxsw_sp->router->ipip_ops_arr = mlxsw_sp_ipip_ops_arr; in mlxsw_sp_ipips_init()
7916 INIT_LIST_HEAD(&mlxsw_sp->router->ipip_list); in mlxsw_sp_ipips_init()
7918 err = mlxsw_sp_ipip_ecn_encap_init(mlxsw_sp); in mlxsw_sp_ipips_init()
7921 err = mlxsw_sp_ipip_ecn_decap_init(mlxsw_sp); in mlxsw_sp_ipips_init()
7925 return mlxsw_sp_ipip_config_tigcr(mlxsw_sp); in mlxsw_sp_ipips_init()
7928 static void mlxsw_sp_ipips_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_ipips_fini() argument
7930 WARN_ON(!list_empty(&mlxsw_sp->router->ipip_list)); in mlxsw_sp_ipips_fini()
7943 mlxsw_sp_router_fib_flush(router->mlxsw_sp); in mlxsw_sp_router_fib_dump_flush()
7957 static void mlxsw_sp_mp4_hash_init(struct mlxsw_sp *mlxsw_sp, char *recr2_pl) in mlxsw_sp_mp4_hash_init() argument
7959 struct net *net = mlxsw_sp_net(mlxsw_sp); in mlxsw_sp_mp4_hash_init()
7975 static void mlxsw_sp_mp6_hash_init(struct mlxsw_sp *mlxsw_sp, char *recr2_pl) in mlxsw_sp_mp6_hash_init() argument
7977 bool only_l3 = !ip6_multipath_hash_policy(mlxsw_sp_net(mlxsw_sp)); in mlxsw_sp_mp6_hash_init()
7998 static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_mp_hash_init() argument
8003 seed = jhash(mlxsw_sp->base_mac, sizeof(mlxsw_sp->base_mac), 0); in mlxsw_sp_mp_hash_init()
8005 mlxsw_sp_mp4_hash_init(mlxsw_sp, recr2_pl); in mlxsw_sp_mp_hash_init()
8006 mlxsw_sp_mp6_hash_init(mlxsw_sp, recr2_pl); in mlxsw_sp_mp_hash_init()
8008 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(recr2), recr2_pl); in mlxsw_sp_mp_hash_init()
8011 static int mlxsw_sp_mp_hash_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_mp_hash_init() argument
8017 static int mlxsw_sp_dscp_init(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_dscp_init() argument
8032 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rdpm), rdpm_pl); in mlxsw_sp_dscp_init()
8035 static int __mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp) in __mlxsw_sp_router_init() argument
8037 struct net *net = mlxsw_sp_net(mlxsw_sp); in __mlxsw_sp_router_init()
8042 if (!MLXSW_CORE_RES_VALID(mlxsw_sp->core, MAX_RIFS)) in __mlxsw_sp_router_init()
8044 max_rifs = MLXSW_CORE_RES_GET(mlxsw_sp->core, MAX_RIFS); in __mlxsw_sp_router_init()
8049 return mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rgcr), rgcr_pl); in __mlxsw_sp_router_init()
8052 static void __mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp) in __mlxsw_sp_router_fini() argument
8057 mlxsw_reg_write(mlxsw_sp->core, MLXSW_REG(rgcr), rgcr_pl); in __mlxsw_sp_router_fini()
8060 int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp, in mlxsw_sp_router_init() argument
8066 router = kzalloc(sizeof(*mlxsw_sp->router), GFP_KERNEL); in mlxsw_sp_router_init()
8070 mlxsw_sp->router = router; in mlxsw_sp_router_init()
8071 router->mlxsw_sp = mlxsw_sp; in mlxsw_sp_router_init()
8073 INIT_LIST_HEAD(&mlxsw_sp->router->nexthop_neighs_list); in mlxsw_sp_router_init()
8074 err = __mlxsw_sp_router_init(mlxsw_sp); in mlxsw_sp_router_init()
8078 err = mlxsw_sp_rifs_init(mlxsw_sp); in mlxsw_sp_router_init()
8082 err = mlxsw_sp_ipips_init(mlxsw_sp); in mlxsw_sp_router_init()
8086 err = rhashtable_init(&mlxsw_sp->router->nexthop_ht, in mlxsw_sp_router_init()
8091 err = rhashtable_init(&mlxsw_sp->router->nexthop_group_ht, in mlxsw_sp_router_init()
8096 INIT_LIST_HEAD(&mlxsw_sp->router->nexthop_list); in mlxsw_sp_router_init()
8097 err = mlxsw_sp_lpm_init(mlxsw_sp); in mlxsw_sp_router_init()
8101 err = mlxsw_sp_mr_init(mlxsw_sp, &mlxsw_sp_mr_tcam_ops); in mlxsw_sp_router_init()
8105 err = mlxsw_sp_vrs_init(mlxsw_sp); in mlxsw_sp_router_init()
8109 err = mlxsw_sp_neigh_init(mlxsw_sp); in mlxsw_sp_router_init()
8113 err = mlxsw_sp_mp_hash_init(mlxsw_sp); in mlxsw_sp_router_init()
8117 err = mlxsw_sp_dscp_init(mlxsw_sp); in mlxsw_sp_router_init()
8131 mlxsw_sp->router->netevent_nb.notifier_call = in mlxsw_sp_router_init()
8133 err = register_netevent_notifier(&mlxsw_sp->router->netevent_nb); in mlxsw_sp_router_init()
8137 mlxsw_sp->router->fib_nb.notifier_call = mlxsw_sp_router_fib_event; in mlxsw_sp_router_init()
8138 err = register_fib_notifier(mlxsw_sp_net(mlxsw_sp), in mlxsw_sp_router_init()
8139 &mlxsw_sp->router->fib_nb, in mlxsw_sp_router_init()
8147 unregister_netevent_notifier(&mlxsw_sp->router->netevent_nb); in mlxsw_sp_router_init()
8156 mlxsw_sp_neigh_fini(mlxsw_sp); in mlxsw_sp_router_init()
8158 mlxsw_sp_vrs_fini(mlxsw_sp); in mlxsw_sp_router_init()
8160 mlxsw_sp_mr_fini(mlxsw_sp); in mlxsw_sp_router_init()
8162 mlxsw_sp_lpm_fini(mlxsw_sp); in mlxsw_sp_router_init()
8164 rhashtable_destroy(&mlxsw_sp->router->nexthop_group_ht); in mlxsw_sp_router_init()
8166 rhashtable_destroy(&mlxsw_sp->router->nexthop_ht); in mlxsw_sp_router_init()
8168 mlxsw_sp_ipips_fini(mlxsw_sp); in mlxsw_sp_router_init()
8170 mlxsw_sp_rifs_fini(mlxsw_sp); in mlxsw_sp_router_init()
8172 __mlxsw_sp_router_fini(mlxsw_sp); in mlxsw_sp_router_init()
8174 mutex_destroy(&mlxsw_sp->router->lock); in mlxsw_sp_router_init()
8175 kfree(mlxsw_sp->router); in mlxsw_sp_router_init()
8179 void mlxsw_sp_router_fini(struct mlxsw_sp *mlxsw_sp) in mlxsw_sp_router_fini() argument
8181 unregister_fib_notifier(mlxsw_sp_net(mlxsw_sp), in mlxsw_sp_router_fini()
8182 &mlxsw_sp->router->fib_nb); in mlxsw_sp_router_fini()
8183 unregister_netevent_notifier(&mlxsw_sp->router->netevent_nb); in mlxsw_sp_router_fini()
8184 unregister_inet6addr_notifier(&mlxsw_sp->router->inet6addr_nb); in mlxsw_sp_router_fini()
8185 unregister_inetaddr_notifier(&mlxsw_sp->router->inetaddr_nb); in mlxsw_sp_router_fini()
8187 mlxsw_sp_neigh_fini(mlxsw_sp); in mlxsw_sp_router_fini()
8188 mlxsw_sp_vrs_fini(mlxsw_sp); in mlxsw_sp_router_fini()
8189 mlxsw_sp_mr_fini(mlxsw_sp); in mlxsw_sp_router_fini()
8190 mlxsw_sp_lpm_fini(mlxsw_sp); in mlxsw_sp_router_fini()
8191 rhashtable_destroy(&mlxsw_sp->router->nexthop_group_ht); in mlxsw_sp_router_fini()
8192 rhashtable_destroy(&mlxsw_sp->router->nexthop_ht); in mlxsw_sp_router_fini()
8193 mlxsw_sp_ipips_fini(mlxsw_sp); in mlxsw_sp_router_fini()
8194 mlxsw_sp_rifs_fini(mlxsw_sp); in mlxsw_sp_router_fini()
8195 __mlxsw_sp_router_fini(mlxsw_sp); in mlxsw_sp_router_fini()
8196 mutex_destroy(&mlxsw_sp->router->lock); in mlxsw_sp_router_fini()
8197 kfree(mlxsw_sp->router); in mlxsw_sp_router_fini()