Lines Matching refs:mr_route
50 struct mlxsw_sp_mr_route *mr_route; member
61 const struct mlxsw_sp_mr_route *mr_route);
111 mlxsw_sp_mr_route_ivif_in_evifs(const struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route_ivif_in_evifs() argument
113 vifi_t ivif = mr_route->mfc->mfc_parent; in mlxsw_sp_mr_route_ivif_in_evifs()
115 return mr_route->mfc->mfc_un.res.ttls[ivif] != 255; in mlxsw_sp_mr_route_ivif_in_evifs()
119 mlxsw_sp_mr_route_valid_evifs_num(const struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route_valid_evifs_num() argument
125 list_for_each_entry(rve, &mr_route->evif_list, route_node) in mlxsw_sp_mr_route_valid_evifs_num()
132 mlxsw_sp_mr_route_action(const struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route_action() argument
137 if (!mlxsw_sp_mr_vif_valid(mr_route->ivif.mr_vif)) in mlxsw_sp_mr_route_action()
143 if (mr_route->mr_table->ops->is_route_starg(mr_route->mr_table, in mlxsw_sp_mr_route_action()
144 mr_route) && in mlxsw_sp_mr_route_action()
145 !mlxsw_sp_mr_route_ivif_in_evifs(mr_route)) in mlxsw_sp_mr_route_action()
149 if (!mlxsw_sp_mr_route_valid_evifs_num(mr_route)) in mlxsw_sp_mr_route_action()
155 list_for_each_entry(rve, &mr_route->evif_list, route_node) in mlxsw_sp_mr_route_action()
163 mlxsw_sp_mr_route_prio(const struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route_prio() argument
165 return mr_route->mr_table->ops->is_route_starg(mr_route->mr_table, in mlxsw_sp_mr_route_prio()
166 mr_route) ? in mlxsw_sp_mr_route_prio()
170 static int mlxsw_sp_mr_route_evif_link(struct mlxsw_sp_mr_route *mr_route, in mlxsw_sp_mr_route_evif_link() argument
178 rve->mr_route = mr_route; in mlxsw_sp_mr_route_evif_link()
180 list_add_tail(&rve->route_node, &mr_route->evif_list); in mlxsw_sp_mr_route_evif_link()
193 static void mlxsw_sp_mr_route_ivif_link(struct mlxsw_sp_mr_route *mr_route, in mlxsw_sp_mr_route_ivif_link() argument
196 mr_route->ivif.mr_route = mr_route; in mlxsw_sp_mr_route_ivif_link()
197 mr_route->ivif.mr_vif = mr_vif; in mlxsw_sp_mr_route_ivif_link()
198 list_add_tail(&mr_route->ivif.vif_node, &mr_vif->route_ivif_list); in mlxsw_sp_mr_route_ivif_link()
201 static void mlxsw_sp_mr_route_ivif_unlink(struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route_ivif_unlink() argument
203 list_del(&mr_route->ivif.vif_node); in mlxsw_sp_mr_route_ivif_unlink()
208 struct mlxsw_sp_mr_route *mr_route, in mlxsw_sp_mr_route_info_create() argument
221 list_for_each_entry(rve, &mr_route->evif_list, route_node) { in mlxsw_sp_mr_route_info_create()
229 if (mlxsw_sp_mr_vif_valid(mr_route->ivif.mr_vif)) in mlxsw_sp_mr_route_info_create()
230 irif_index = mlxsw_sp_rif_index(mr_route->ivif.mr_vif->rif); in mlxsw_sp_mr_route_info_create()
236 route_info->min_mtu = mr_route->min_mtu; in mlxsw_sp_mr_route_info_create()
237 route_info->route_action = mr_route->route_action; in mlxsw_sp_mr_route_info_create()
249 struct mlxsw_sp_mr_route *mr_route, in mlxsw_sp_mr_route_write() argument
257 err = mlxsw_sp_mr_route_info_create(mr_table, mr_route, &route_info); in mlxsw_sp_mr_route_write()
264 mr_route->route_priv = kzalloc(mr->mr_ops->route_priv_size, in mlxsw_sp_mr_route_write()
266 if (!mr_route->route_priv) { in mlxsw_sp_mr_route_write()
271 route_params.key = mr_route->key; in mlxsw_sp_mr_route_write()
273 route_params.prio = mlxsw_sp_mr_route_prio(mr_route); in mlxsw_sp_mr_route_write()
275 mr_route->route_priv, in mlxsw_sp_mr_route_write()
278 kfree(mr_route->route_priv); in mlxsw_sp_mr_route_write()
280 err = mr->mr_ops->route_update(mlxsw_sp, mr_route->route_priv, in mlxsw_sp_mr_route_write()
289 struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route_erase() argument
294 mr->mr_ops->route_destroy(mlxsw_sp, mr->priv, mr_route->route_priv); in mlxsw_sp_mr_route_erase()
295 kfree(mr_route->route_priv); in mlxsw_sp_mr_route_erase()
303 struct mlxsw_sp_mr_route *mr_route; in mlxsw_sp_mr_route_create() local
308 mr_route = kzalloc(sizeof(*mr_route), GFP_KERNEL); in mlxsw_sp_mr_route_create()
309 if (!mr_route) in mlxsw_sp_mr_route_create()
311 INIT_LIST_HEAD(&mr_route->evif_list); in mlxsw_sp_mr_route_create()
314 mr_route->min_mtu = ETH_MAX_MTU; in mlxsw_sp_mr_route_create()
316 mr_route->mfc = mfc; in mlxsw_sp_mr_route_create()
317 mr_table->ops->key_create(mr_table, &mr_route->key, mr_route->mfc); in mlxsw_sp_mr_route_create()
319 mr_route->mr_table = mr_table; in mlxsw_sp_mr_route_create()
322 err = mlxsw_sp_mr_route_evif_link(mr_route, in mlxsw_sp_mr_route_create()
327 mr_table->vifs[i].dev->mtu < mr_route->min_mtu) in mlxsw_sp_mr_route_create()
328 mr_route->min_mtu = mr_table->vifs[i].dev->mtu; in mlxsw_sp_mr_route_create()
331 mlxsw_sp_mr_route_ivif_link(mr_route, in mlxsw_sp_mr_route_create()
334 mr_route->route_action = mlxsw_sp_mr_route_action(mr_route); in mlxsw_sp_mr_route_create()
335 return mr_route; in mlxsw_sp_mr_route_create()
338 list_for_each_entry_safe(rve, tmp, &mr_route->evif_list, route_node) in mlxsw_sp_mr_route_create()
340 kfree(mr_route); in mlxsw_sp_mr_route_create()
345 struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route_destroy() argument
349 mlxsw_sp_mr_route_ivif_unlink(mr_route); in mlxsw_sp_mr_route_destroy()
350 mr_cache_put(mr_route->mfc); in mlxsw_sp_mr_route_destroy()
351 list_for_each_entry_safe(rve, tmp, &mr_route->evif_list, route_node) in mlxsw_sp_mr_route_destroy()
353 kfree(mr_route); in mlxsw_sp_mr_route_destroy()
356 static void mlxsw_sp_mr_mfc_offload_set(struct mlxsw_sp_mr_route *mr_route, in mlxsw_sp_mr_mfc_offload_set() argument
360 mr_route->mfc->mfc_flags |= MFC_OFFLOAD; in mlxsw_sp_mr_mfc_offload_set()
362 mr_route->mfc->mfc_flags &= ~MFC_OFFLOAD; in mlxsw_sp_mr_mfc_offload_set()
365 static void mlxsw_sp_mr_mfc_offload_update(struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_mfc_offload_update() argument
369 offload = mr_route->route_action != MLXSW_SP_MR_ROUTE_ACTION_TRAP; in mlxsw_sp_mr_mfc_offload_update()
370 mlxsw_sp_mr_mfc_offload_set(mr_route, offload); in mlxsw_sp_mr_mfc_offload_update()
374 struct mlxsw_sp_mr_route *mr_route) in __mlxsw_sp_mr_route_del() argument
378 mlxsw_sp_mr_mfc_offload_set(mr_route, false); in __mlxsw_sp_mr_route_del()
379 rhashtable_remove_fast(&mr_table->route_ht, &mr_route->ht_node, in __mlxsw_sp_mr_route_del()
381 list_del(&mr_route->node); in __mlxsw_sp_mr_route_del()
382 mlxsw_sp_mr_route_erase(mr_table, mr_route); in __mlxsw_sp_mr_route_del()
383 mlxsw_sp_mr_route_destroy(mr_table, mr_route); in __mlxsw_sp_mr_route_del()
390 struct mlxsw_sp_mr_route *mr_route; in mlxsw_sp_mr_route_add() local
397 mr_route = mlxsw_sp_mr_route_create(mr_table, mfc); in mlxsw_sp_mr_route_add()
398 if (IS_ERR(mr_route)) in mlxsw_sp_mr_route_add()
399 return PTR_ERR(mr_route); in mlxsw_sp_mr_route_add()
403 &mr_route->key, in mlxsw_sp_mr_route_add()
412 mr_route->route_priv = mr_orig_route->route_priv; in mlxsw_sp_mr_route_add()
424 err = mlxsw_sp_mr_route_write(mr_table, mr_route, replace); in mlxsw_sp_mr_route_add()
430 list_add_tail(&mr_route->node, &mr_table->route_list); in mlxsw_sp_mr_route_add()
433 &mr_route->ht_node, in mlxsw_sp_mr_route_add()
447 mlxsw_sp_mr_mfc_offload_update(mr_route); in mlxsw_sp_mr_route_add()
452 list_del(&mr_route->node); in mlxsw_sp_mr_route_add()
454 mlxsw_sp_mr_route_erase(mr_table, mr_route); in mlxsw_sp_mr_route_add()
458 mlxsw_sp_mr_route_destroy(mr_table, mr_route); in mlxsw_sp_mr_route_add()
465 struct mlxsw_sp_mr_route *mr_route; in mlxsw_sp_mr_route_del() local
469 mr_route = rhashtable_lookup_fast(&mr_table->route_ht, &key, in mlxsw_sp_mr_route_del()
471 if (mr_route) { in mlxsw_sp_mr_route_del()
473 __mlxsw_sp_mr_route_del(mr_table, mr_route); in mlxsw_sp_mr_route_del()
489 route_action = mlxsw_sp_mr_route_action(rve->mr_route); in mlxsw_sp_mr_route_ivif_resolve()
495 err = mr->mr_ops->route_irif_update(mlxsw_sp, rve->mr_route->route_priv, in mlxsw_sp_mr_route_ivif_resolve()
501 rve->mr_route->route_priv, in mlxsw_sp_mr_route_ivif_resolve()
509 rve->mr_route->route_action = route_action; in mlxsw_sp_mr_route_ivif_resolve()
510 mlxsw_sp_mr_mfc_offload_update(rve->mr_route); in mlxsw_sp_mr_route_ivif_resolve()
521 mr->mr_ops->route_action_update(mlxsw_sp, rve->mr_route->route_priv, in mlxsw_sp_mr_route_ivif_unresolve()
523 rve->mr_route->route_action = MLXSW_SP_MR_ROUTE_ACTION_TRAP; in mlxsw_sp_mr_route_ivif_unresolve()
524 mlxsw_sp_mr_mfc_offload_update(rve->mr_route); in mlxsw_sp_mr_route_ivif_unresolve()
542 rve->mr_route->route_priv, in mlxsw_sp_mr_route_evif_resolve()
551 route_action = mlxsw_sp_mr_route_action(rve->mr_route); in mlxsw_sp_mr_route_evif_resolve()
552 if (route_action != rve->mr_route->route_action) { in mlxsw_sp_mr_route_evif_resolve()
554 rve->mr_route->route_priv, in mlxsw_sp_mr_route_evif_resolve()
561 if (rve->mr_vif->dev->mtu < rve->mr_route->min_mtu) { in mlxsw_sp_mr_route_evif_resolve()
562 rve->mr_route->min_mtu = rve->mr_vif->dev->mtu; in mlxsw_sp_mr_route_evif_resolve()
564 rve->mr_route->route_priv, in mlxsw_sp_mr_route_evif_resolve()
565 rve->mr_route->min_mtu); in mlxsw_sp_mr_route_evif_resolve()
570 rve->mr_route->route_action = route_action; in mlxsw_sp_mr_route_evif_resolve()
571 mlxsw_sp_mr_mfc_offload_update(rve->mr_route); in mlxsw_sp_mr_route_evif_resolve()
575 if (route_action != rve->mr_route->route_action) in mlxsw_sp_mr_route_evif_resolve()
577 rve->mr_route->route_priv, in mlxsw_sp_mr_route_evif_resolve()
578 rve->mr_route->route_action); in mlxsw_sp_mr_route_evif_resolve()
581 mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv, in mlxsw_sp_mr_route_evif_resolve()
605 if (mlxsw_sp_mr_route_valid_evifs_num(rve->mr_route) == 1) in mlxsw_sp_mr_route_evif_unresolve()
608 route_action = mlxsw_sp_mr_route_action(rve->mr_route); in mlxsw_sp_mr_route_evif_unresolve()
609 if (route_action != rve->mr_route->route_action) in mlxsw_sp_mr_route_evif_unresolve()
611 rve->mr_route->route_priv, in mlxsw_sp_mr_route_evif_unresolve()
616 mr->mr_ops->route_erif_del(mlxsw_sp, rve->mr_route->route_priv, rifi); in mlxsw_sp_mr_route_evif_unresolve()
617 rve->mr_route->route_action = route_action; in mlxsw_sp_mr_route_evif_unresolve()
618 mlxsw_sp_mr_mfc_offload_update(rve->mr_route); in mlxsw_sp_mr_route_evif_unresolve()
767 if (mtu < rve->mr_route->min_mtu) { in mlxsw_sp_mr_rif_mtu_update()
768 rve->mr_route->min_mtu = mtu; in mlxsw_sp_mr_rif_mtu_update()
770 rve->mr_route->route_priv, in mlxsw_sp_mr_rif_mtu_update()
814 const struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route4_starg() argument
816 return mr_route->key.source_mask.addr4 == htonl(INADDR_ANY); in mlxsw_sp_mr_route4_starg()
860 const struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route6_starg() argument
862 return ipv6_addr_any(&mr_route->key.source_mask.addr6); in mlxsw_sp_mr_route6_starg()
973 struct mlxsw_sp_mr_route *mr_route, *tmp; in mlxsw_sp_mr_table_flush() local
977 list_for_each_entry_safe(mr_route, tmp, &mr_table->route_list, node) in mlxsw_sp_mr_table_flush()
978 __mlxsw_sp_mr_route_del(mr_table, mr_route); in mlxsw_sp_mr_table_flush()
998 struct mlxsw_sp_mr_route *mr_route) in mlxsw_sp_mr_route_stats_update() argument
1003 if (mr_route->route_action == MLXSW_SP_MR_ROUTE_ACTION_TRAP) in mlxsw_sp_mr_route_stats_update()
1006 mr->mr_ops->route_stats(mlxsw_sp, mr_route->route_priv, &packets, in mlxsw_sp_mr_route_stats_update()
1009 if (mr_route->mfc->mfc_un.res.pkt != packets) in mlxsw_sp_mr_route_stats_update()
1010 mr_route->mfc->mfc_un.res.lastuse = jiffies; in mlxsw_sp_mr_route_stats_update()
1011 mr_route->mfc->mfc_un.res.pkt = packets; in mlxsw_sp_mr_route_stats_update()
1012 mr_route->mfc->mfc_un.res.bytes = bytes; in mlxsw_sp_mr_route_stats_update()
1020 struct mlxsw_sp_mr_route *mr_route; in mlxsw_sp_mr_stats_update() local
1026 list_for_each_entry(mr_route, &mr_table->route_list, node) in mlxsw_sp_mr_stats_update()
1028 mr_route); in mlxsw_sp_mr_stats_update()