1/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ 2/* Copyright (c) 2021 Mellanox Technologies. */ 3 4#ifndef __MLX5_EN_TC_SAMPLE_H__ 5#define __MLX5_EN_TC_SAMPLE_H__ 6 7#include "eswitch.h" 8 9struct mlx5_flow_attr; 10struct mlx5e_tc_psample; 11struct mlx5e_post_act; 12 13struct mlx5e_sample_attr { 14 u32 group_num; 15 u32 rate; 16 u32 trunc_size; 17 u32 restore_obj_id; 18 u32 sampler_id; 19 struct mlx5e_sample_flow *sample_flow; 20}; 21 22#if IS_ENABLED(CONFIG_MLX5_TC_SAMPLE) 23 24void mlx5e_tc_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj); 25 26struct mlx5_flow_handle * 27mlx5e_tc_sample_offload(struct mlx5e_tc_psample *sample_priv, 28 struct mlx5_flow_spec *spec, 29 struct mlx5_flow_attr *attr); 30 31void 32mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *sample_priv, 33 struct mlx5_flow_handle *rule, 34 struct mlx5_flow_attr *attr); 35 36struct mlx5e_tc_psample * 37mlx5e_tc_sample_init(struct mlx5_eswitch *esw, struct mlx5e_post_act *post_act); 38 39void 40mlx5e_tc_sample_cleanup(struct mlx5e_tc_psample *tc_psample); 41 42#else /* CONFIG_MLX5_TC_SAMPLE */ 43 44static inline struct mlx5_flow_handle * 45mlx5e_tc_sample_offload(struct mlx5e_tc_psample *tc_psample, 46 struct mlx5_flow_spec *spec, 47 struct mlx5_flow_attr *attr) 48{ return ERR_PTR(-EOPNOTSUPP); } 49 50static inline void 51mlx5e_tc_sample_unoffload(struct mlx5e_tc_psample *tc_psample, 52 struct mlx5_flow_handle *rule, 53 struct mlx5_flow_attr *attr) {} 54 55static inline struct mlx5e_tc_psample * 56mlx5e_tc_sample_init(struct mlx5_eswitch *esw, struct mlx5e_post_act *post_act) 57{ return ERR_PTR(-EOPNOTSUPP); } 58 59static inline void 60mlx5e_tc_sample_cleanup(struct mlx5e_tc_psample *tc_psample) {} 61 62static inline void 63mlx5e_tc_sample_skb(struct sk_buff *skb, struct mlx5_mapped_obj *mapped_obj) {} 64 65#endif /* CONFIG_MLX5_TC_SAMPLE */ 66#endif /* __MLX5_EN_TC_SAMPLE_H__ */ 67