1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2020 Mellanox Technologies */
3
4 #ifndef __MLX5E_EN_MOD_HDR_H__
5 #define __MLX5E_EN_MOD_HDR_H__
6
7 #include <linux/hashtable.h>
8 #include <linux/mlx5/fs.h>
9
10 struct mlx5e_mod_hdr_handle;
11
12 struct mlx5e_tc_mod_hdr_acts {
13 int num_actions;
14 int max_actions;
15 void *actions;
16 };
17
18 char *mlx5e_mod_hdr_alloc(struct mlx5_core_dev *mdev, int namespace,
19 struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);
20 void mlx5e_mod_hdr_dealloc(struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);
21 char *mlx5e_mod_hdr_get_item(struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts, int pos);
22
23 struct mlx5e_mod_hdr_handle *
24 mlx5e_mod_hdr_attach(struct mlx5_core_dev *mdev,
25 struct mod_hdr_tbl *tbl,
26 enum mlx5_flow_namespace_type namespace,
27 struct mlx5e_tc_mod_hdr_acts *mod_hdr_acts);
28 void mlx5e_mod_hdr_detach(struct mlx5_core_dev *mdev,
29 struct mod_hdr_tbl *tbl,
30 struct mlx5e_mod_hdr_handle *mh);
31 struct mlx5_modify_hdr *mlx5e_mod_hdr_get(struct mlx5e_mod_hdr_handle *mh);
32
33 void mlx5e_mod_hdr_tbl_init(struct mod_hdr_tbl *tbl);
34 void mlx5e_mod_hdr_tbl_destroy(struct mod_hdr_tbl *tbl);
35
mlx5e_mod_hdr_max_actions(struct mlx5_core_dev * mdev,int namespace)36 static inline int mlx5e_mod_hdr_max_actions(struct mlx5_core_dev *mdev, int namespace)
37 {
38 if (namespace == MLX5_FLOW_NAMESPACE_FDB) /* FDB offloading */
39 return MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, max_modify_header_actions);
40 else /* namespace is MLX5_FLOW_NAMESPACE_KERNEL - NIC offloading */
41 return MLX5_CAP_FLOWTABLE_NIC_RX(mdev, max_modify_header_actions);
42 }
43
44 #endif /* __MLX5E_EN_MOD_HDR_H__ */
45