1*9948a064SJiri Pirko /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ 2*9948a064SJiri Pirko /* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */ 3c011ec1bSYotam Gigi 4c011ec1bSYotam Gigi #ifndef _MLXSW_SPECTRUM_MCROUTER_H 5c011ec1bSYotam Gigi #define _MLXSW_SPECTRUM_MCROUTER_H 6c011ec1bSYotam Gigi 7c011ec1bSYotam Gigi #include <linux/mroute.h> 86981e104SYuval Mintz #include <linux/mroute6.h> 9c011ec1bSYotam Gigi #include "spectrum_router.h" 10c011ec1bSYotam Gigi #include "spectrum.h" 11c011ec1bSYotam Gigi 12c011ec1bSYotam Gigi enum mlxsw_sp_mr_route_action { 13c011ec1bSYotam Gigi MLXSW_SP_MR_ROUTE_ACTION_FORWARD, 14c011ec1bSYotam Gigi MLXSW_SP_MR_ROUTE_ACTION_TRAP, 15607feadeSYotam Gigi MLXSW_SP_MR_ROUTE_ACTION_TRAP_AND_FORWARD, 16c011ec1bSYotam Gigi }; 17c011ec1bSYotam Gigi 18c011ec1bSYotam Gigi struct mlxsw_sp_mr_route_key { 19c011ec1bSYotam Gigi int vrid; 20c011ec1bSYotam Gigi enum mlxsw_sp_l3proto proto; 21c011ec1bSYotam Gigi union mlxsw_sp_l3addr group; 22c011ec1bSYotam Gigi union mlxsw_sp_l3addr group_mask; 23c011ec1bSYotam Gigi union mlxsw_sp_l3addr source; 24c011ec1bSYotam Gigi union mlxsw_sp_l3addr source_mask; 25c011ec1bSYotam Gigi }; 26c011ec1bSYotam Gigi 27c011ec1bSYotam Gigi struct mlxsw_sp_mr_route_info { 28c011ec1bSYotam Gigi enum mlxsw_sp_mr_route_action route_action; 29c011ec1bSYotam Gigi u16 irif_index; 30c011ec1bSYotam Gigi u16 *erif_indices; 31c011ec1bSYotam Gigi size_t erif_num; 32c011ec1bSYotam Gigi u16 min_mtu; 33c011ec1bSYotam Gigi }; 34c011ec1bSYotam Gigi 35c011ec1bSYotam Gigi struct mlxsw_sp_mr_route_params { 36c011ec1bSYotam Gigi struct mlxsw_sp_mr_route_key key; 37c011ec1bSYotam Gigi struct mlxsw_sp_mr_route_info value; 38c011ec1bSYotam Gigi enum mlxsw_sp_mr_route_prio prio; 39c011ec1bSYotam Gigi }; 40c011ec1bSYotam Gigi 41c011ec1bSYotam Gigi struct mlxsw_sp_mr_ops { 42c011ec1bSYotam Gigi int priv_size; 43c011ec1bSYotam Gigi int route_priv_size; 44c011ec1bSYotam Gigi int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv); 45c011ec1bSYotam Gigi int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv, 46c011ec1bSYotam Gigi void *route_priv, 47c011ec1bSYotam Gigi struct mlxsw_sp_mr_route_params *route_params); 48c011ec1bSYotam Gigi int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 49c011ec1bSYotam Gigi struct mlxsw_sp_mr_route_info *route_info); 50c011ec1bSYotam Gigi int (*route_stats)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 51c011ec1bSYotam Gigi u64 *packets, u64 *bytes); 52c011ec1bSYotam Gigi int (*route_action_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 53c011ec1bSYotam Gigi enum mlxsw_sp_mr_route_action route_action); 54c011ec1bSYotam Gigi int (*route_min_mtu_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 55c011ec1bSYotam Gigi u16 min_mtu); 56c011ec1bSYotam Gigi int (*route_irif_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 57c011ec1bSYotam Gigi u16 irif_index); 58c011ec1bSYotam Gigi int (*route_erif_add)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 59c011ec1bSYotam Gigi u16 erif_index); 60c011ec1bSYotam Gigi int (*route_erif_del)(struct mlxsw_sp *mlxsw_sp, void *route_priv, 61c011ec1bSYotam Gigi u16 erif_index); 62c011ec1bSYotam Gigi void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv, 63c011ec1bSYotam Gigi void *route_priv); 648fae4392SJiri Pirko void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv); 65c011ec1bSYotam Gigi }; 66c011ec1bSYotam Gigi 67c011ec1bSYotam Gigi struct mlxsw_sp_mr; 68c011ec1bSYotam Gigi struct mlxsw_sp_mr_table; 69c011ec1bSYotam Gigi 70c011ec1bSYotam Gigi int mlxsw_sp_mr_init(struct mlxsw_sp *mlxsw_sp, 71c011ec1bSYotam Gigi const struct mlxsw_sp_mr_ops *mr_ops); 72c011ec1bSYotam Gigi void mlxsw_sp_mr_fini(struct mlxsw_sp *mlxsw_sp); 73eb35da0cSYuval Mintz int mlxsw_sp_mr_route_add(struct mlxsw_sp_mr_table *mr_table, 74eb35da0cSYuval Mintz struct mr_mfc *mfc, bool replace); 75eb35da0cSYuval Mintz void mlxsw_sp_mr_route_del(struct mlxsw_sp_mr_table *mr_table, 76eb35da0cSYuval Mintz struct mr_mfc *mfc); 77c011ec1bSYotam Gigi int mlxsw_sp_mr_vif_add(struct mlxsw_sp_mr_table *mr_table, 78c011ec1bSYotam Gigi struct net_device *dev, vifi_t vif_index, 79c011ec1bSYotam Gigi unsigned long vif_flags, 80c011ec1bSYotam Gigi const struct mlxsw_sp_rif *rif); 81c011ec1bSYotam Gigi void mlxsw_sp_mr_vif_del(struct mlxsw_sp_mr_table *mr_table, vifi_t vif_index); 82c011ec1bSYotam Gigi int mlxsw_sp_mr_rif_add(struct mlxsw_sp_mr_table *mr_table, 83c011ec1bSYotam Gigi const struct mlxsw_sp_rif *rif); 84c011ec1bSYotam Gigi void mlxsw_sp_mr_rif_del(struct mlxsw_sp_mr_table *mr_table, 85c011ec1bSYotam Gigi const struct mlxsw_sp_rif *rif); 86c011ec1bSYotam Gigi void mlxsw_sp_mr_rif_mtu_update(struct mlxsw_sp_mr_table *mr_table, 87c011ec1bSYotam Gigi const struct mlxsw_sp_rif *rif, int mtu); 88c011ec1bSYotam Gigi struct mlxsw_sp_mr_table *mlxsw_sp_mr_table_create(struct mlxsw_sp *mlxsw_sp, 89c011ec1bSYotam Gigi u32 tb_id, 90c011ec1bSYotam Gigi enum mlxsw_sp_l3proto proto); 91c011ec1bSYotam Gigi void mlxsw_sp_mr_table_destroy(struct mlxsw_sp_mr_table *mr_table); 92c011ec1bSYotam Gigi void mlxsw_sp_mr_table_flush(struct mlxsw_sp_mr_table *mr_table); 93c011ec1bSYotam Gigi bool mlxsw_sp_mr_table_empty(const struct mlxsw_sp_mr_table *mr_table); 94c011ec1bSYotam Gigi 95c011ec1bSYotam Gigi #endif 96