xref: /freebsd/sys/dev/mlx5/mlx5_core/flow_table.h (revision 95ee2897)
191ad1bd9SKonstantin Belousov /*-
291ad1bd9SKonstantin Belousov  * Copyright (c) 2013-2017, Mellanox Technologies, Ltd.  All rights reserved.
391ad1bd9SKonstantin Belousov  *
491ad1bd9SKonstantin Belousov  * Redistribution and use in source and binary forms, with or without
591ad1bd9SKonstantin Belousov  * modification, are permitted provided that the following conditions
691ad1bd9SKonstantin Belousov  * are met:
791ad1bd9SKonstantin Belousov  * 1. Redistributions of source code must retain the above copyright
891ad1bd9SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer.
991ad1bd9SKonstantin Belousov  * 2. Redistributions in binary form must reproduce the above copyright
1091ad1bd9SKonstantin Belousov  *    notice, this list of conditions and the following disclaimer in the
1191ad1bd9SKonstantin Belousov  *    documentation and/or other materials provided with the distribution.
1291ad1bd9SKonstantin Belousov  *
1391ad1bd9SKonstantin Belousov  * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS `AS IS' AND
1491ad1bd9SKonstantin Belousov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1591ad1bd9SKonstantin Belousov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1691ad1bd9SKonstantin Belousov  * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
1791ad1bd9SKonstantin Belousov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1891ad1bd9SKonstantin Belousov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
1991ad1bd9SKonstantin Belousov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2091ad1bd9SKonstantin Belousov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2191ad1bd9SKonstantin Belousov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
2291ad1bd9SKonstantin Belousov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2391ad1bd9SKonstantin Belousov  * SUCH DAMAGE.
2491ad1bd9SKonstantin Belousov  */
2591ad1bd9SKonstantin Belousov 
2691ad1bd9SKonstantin Belousov #ifndef MLX5_FLOW_TABLE_H
2791ad1bd9SKonstantin Belousov #define MLX5_FLOW_TABLE_H
2891ad1bd9SKonstantin Belousov 
2991ad1bd9SKonstantin Belousov #include <dev/mlx5/driver.h>
3091ad1bd9SKonstantin Belousov 
3191ad1bd9SKonstantin Belousov #define MLX5_SET_FLOW_TABLE_ROOT_OPMOD_SET      0x0
3291ad1bd9SKonstantin Belousov #define MLX5_SET_FLOW_TABLE_ROOT_OPMOD_RESET    0x1
3391ad1bd9SKonstantin Belousov 
3491ad1bd9SKonstantin Belousov struct mlx5_flow_table_group {
3591ad1bd9SKonstantin Belousov 	u8	log_sz;
3691ad1bd9SKonstantin Belousov 	u8	match_criteria_enable;
3791ad1bd9SKonstantin Belousov 	u32	match_criteria[MLX5_ST_SZ_DW(fte_match_param)];
3891ad1bd9SKonstantin Belousov };
3991ad1bd9SKonstantin Belousov 
4091ad1bd9SKonstantin Belousov void *mlx5_create_flow_table(struct mlx5_core_dev *dev, u8 level, u8 table_type,
4191ad1bd9SKonstantin Belousov 			     u16 vport,
4291ad1bd9SKonstantin Belousov 			     u16 num_groups,
4391ad1bd9SKonstantin Belousov 			     struct mlx5_flow_table_group *group);
4491ad1bd9SKonstantin Belousov void mlx5_destroy_flow_table(void *flow_table);
4591ad1bd9SKonstantin Belousov int mlx5_add_flow_table_entry(void *flow_table, u8 match_criteria_enable,
4691ad1bd9SKonstantin Belousov 			      void *match_criteria, void *flow_context,
4791ad1bd9SKonstantin Belousov 			      u32 *flow_index);
4891ad1bd9SKonstantin Belousov int mlx5_del_flow_table_entry(void *flow_table, u32 flow_index);
4991ad1bd9SKonstantin Belousov u32 mlx5_get_flow_table_id(void *flow_table);
5091ad1bd9SKonstantin Belousov int mlx5_set_flow_table_root(struct mlx5_core_dev *mdev, u16 op_mod,
5191ad1bd9SKonstantin Belousov 			     u8 vport_num, u8 table_type, u32 table_id,
5291ad1bd9SKonstantin Belousov 			     u32 underlay_qpn);
5391ad1bd9SKonstantin Belousov void *mlx5_get_flow_table_properties(void *flow_table);
5491ad1bd9SKonstantin Belousov u32 mlx5_set_flow_table_miss_id(void *flow_table, u32 miss_ft_id);
5591ad1bd9SKonstantin Belousov 
5691ad1bd9SKonstantin Belousov int mlx5_create_flow_counter(struct mlx5_core_dev *dev, u16 *cnt_id);
5791ad1bd9SKonstantin Belousov void mlx5_destroy_flow_counter(struct mlx5_core_dev *dev, u16 cnt_id);
5891ad1bd9SKonstantin Belousov int mlx5_query_flow_counters(struct mlx5_core_dev *dev,
5991ad1bd9SKonstantin Belousov 			     u32 num_counters, u16 *cnt_ids,
6091ad1bd9SKonstantin Belousov 			     struct mlx5_traffic_counter *cnt_data);
6191ad1bd9SKonstantin Belousov int mlx5_reset_flow_counter(struct mlx5_core_dev *dev, u16 cnt_id);
6291ad1bd9SKonstantin Belousov 
6391ad1bd9SKonstantin Belousov #endif /* MLX5_FLOW_TABLE_H */
64