Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */
0002 /* Copyright (c) 2017-2018 Mellanox Technologies. All rights reserved */
0003 
0004 #ifndef _MLXSW_SPECTRUM_MCROUTER_H
0005 #define _MLXSW_SPECTRUM_MCROUTER_H
0006 
0007 #include <linux/mroute.h>
0008 #include <linux/mroute6.h>
0009 #include "spectrum_router.h"
0010 #include "spectrum.h"
0011 
0012 enum mlxsw_sp_mr_route_action {
0013     MLXSW_SP_MR_ROUTE_ACTION_FORWARD,
0014     MLXSW_SP_MR_ROUTE_ACTION_TRAP,
0015     MLXSW_SP_MR_ROUTE_ACTION_TRAP_AND_FORWARD,
0016 };
0017 
0018 struct mlxsw_sp_mr_route_key {
0019     int vrid;
0020     enum mlxsw_sp_l3proto proto;
0021     union mlxsw_sp_l3addr group;
0022     union mlxsw_sp_l3addr group_mask;
0023     union mlxsw_sp_l3addr source;
0024     union mlxsw_sp_l3addr source_mask;
0025 };
0026 
0027 struct mlxsw_sp_mr_route_info {
0028     enum mlxsw_sp_mr_route_action route_action;
0029     u16 irif_index;
0030     u16 *erif_indices;
0031     size_t erif_num;
0032     u16 min_mtu;
0033 };
0034 
0035 struct mlxsw_sp_mr_route_params {
0036     struct mlxsw_sp_mr_route_key key;
0037     struct mlxsw_sp_mr_route_info value;
0038     enum mlxsw_sp_mr_route_prio prio;
0039 };
0040 
0041 struct mlxsw_sp_mr_ops {
0042     int priv_size;
0043     int route_priv_size;
0044     int (*init)(struct mlxsw_sp *mlxsw_sp, void *priv);
0045     int (*route_create)(struct mlxsw_sp *mlxsw_sp, void *priv,
0046                 void *route_priv,
0047                 struct mlxsw_sp_mr_route_params *route_params);
0048     int (*route_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
0049                 struct mlxsw_sp_mr_route_info *route_info);
0050     int (*route_stats)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
0051                u64 *packets, u64 *bytes);
0052     int (*route_action_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
0053                    enum mlxsw_sp_mr_route_action route_action);
0054     int (*route_min_mtu_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
0055                     u16 min_mtu);
0056     int (*route_irif_update)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
0057                  u16 irif_index);
0058     int (*route_erif_add)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
0059                   u16 erif_index);
0060     int (*route_erif_del)(struct mlxsw_sp *mlxsw_sp, void *route_priv,
0061                   u16 erif_index);
0062     void (*route_destroy)(struct mlxsw_sp *mlxsw_sp, void *priv,
0063                   void *route_priv);
0064     void (*fini)(struct mlxsw_sp *mlxsw_sp, void *priv);
0065 };
0066 
0067 struct mlxsw_sp_mr;
0068 struct mlxsw_sp_mr_table;
0069 
0070 int mlxsw_sp_mr_init(struct mlxsw_sp *mlxsw_sp,
0071              const struct mlxsw_sp_mr_ops *mr_ops);
0072 void mlxsw_sp_mr_fini(struct mlxsw_sp *mlxsw_sp);
0073 int mlxsw_sp_mr_route_add(struct mlxsw_sp_mr_table *mr_table,
0074               struct mr_mfc *mfc, bool replace);
0075 void mlxsw_sp_mr_route_del(struct mlxsw_sp_mr_table *mr_table,
0076                struct mr_mfc *mfc);
0077 int mlxsw_sp_mr_vif_add(struct mlxsw_sp_mr_table *mr_table,
0078             struct net_device *dev, vifi_t vif_index,
0079             unsigned long vif_flags,
0080             const struct mlxsw_sp_rif *rif);
0081 void mlxsw_sp_mr_vif_del(struct mlxsw_sp_mr_table *mr_table, vifi_t vif_index);
0082 int mlxsw_sp_mr_rif_add(struct mlxsw_sp_mr_table *mr_table,
0083             const struct mlxsw_sp_rif *rif);
0084 void mlxsw_sp_mr_rif_del(struct mlxsw_sp_mr_table *mr_table,
0085              const struct mlxsw_sp_rif *rif);
0086 void mlxsw_sp_mr_rif_mtu_update(struct mlxsw_sp_mr_table *mr_table,
0087                 const struct mlxsw_sp_rif *rif, int mtu);
0088 struct mlxsw_sp_mr_table *mlxsw_sp_mr_table_create(struct mlxsw_sp *mlxsw_sp,
0089                            u32 tb_id,
0090                            enum mlxsw_sp_l3proto proto);
0091 void mlxsw_sp_mr_table_destroy(struct mlxsw_sp_mr_table *mr_table);
0092 void mlxsw_sp_mr_table_flush(struct mlxsw_sp_mr_table *mr_table);
0093 bool mlxsw_sp_mr_table_empty(const struct mlxsw_sp_mr_table *mr_table);
0094 
0095 #endif