brintos

brintos / linux-shallow public Read only

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