| 1 |
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ |
| 2 |
/* Copyright (c) 2020 Mellanox Technologies. */ |
| 3 |
|
| 4 |
#ifndef __ML5_FS_TTC_H__ |
| 5 |
#define __ML5_FS_TTC_H__ |
| 6 |
|
| 7 |
#include <linux/mlx5/fs.h> |
| 8 |
|
| 9 |
enum mlx5_traffic_types { |
| 10 |
MLX5_TT_IPV4_TCP, |
| 11 |
MLX5_TT_IPV6_TCP, |
| 12 |
MLX5_TT_IPV4_UDP, |
| 13 |
MLX5_TT_IPV6_UDP, |
| 14 |
MLX5_TT_IPV4_IPSEC_AH, |
| 15 |
MLX5_TT_IPV6_IPSEC_AH, |
| 16 |
MLX5_TT_IPV4_IPSEC_ESP, |
| 17 |
MLX5_TT_IPV6_IPSEC_ESP, |
| 18 |
MLX5_TT_IPV4, |
| 19 |
MLX5_TT_IPV6, |
| 20 |
MLX5_TT_ANY, |
| 21 |
MLX5_TT_DECRYPTED_ESP_OUTER_IPV4_TCP, |
| 22 |
MLX5_TT_DECRYPTED_ESP_OUTER_IPV6_TCP, |
| 23 |
MLX5_TT_DECRYPTED_ESP_OUTER_IPV4_UDP, |
| 24 |
MLX5_TT_DECRYPTED_ESP_OUTER_IPV6_UDP, |
| 25 |
MLX5_TT_DECRYPTED_ESP_INNER_IPV4_TCP, |
| 26 |
MLX5_TT_DECRYPTED_ESP_INNER_IPV6_TCP, |
| 27 |
MLX5_TT_DECRYPTED_ESP_INNER_IPV4_UDP, |
| 28 |
MLX5_TT_DECRYPTED_ESP_INNER_IPV6_UDP, |
| 29 |
MLX5_NUM_TT, |
| 30 |
MLX5_NUM_INDIR_TIRS = MLX5_TT_ANY, |
| 31 |
}; |
| 32 |
|
| 33 |
enum mlx5_tunnel_types { |
| 34 |
MLX5_TT_IPV4_GRE, |
| 35 |
MLX5_TT_IPV6_GRE, |
| 36 |
MLX5_TT_IPV4_IPIP, |
| 37 |
MLX5_TT_IPV6_IPIP, |
| 38 |
MLX5_TT_IPV4_IPV6, |
| 39 |
MLX5_TT_IPV6_IPV6, |
| 40 |
MLX5_NUM_TUNNEL_TT, |
| 41 |
}; |
| 42 |
|
| 43 |
struct mlx5_ttc_rule { |
| 44 |
struct mlx5_flow_handle *rule; |
| 45 |
struct mlx5_flow_destination default_dest; |
| 46 |
}; |
| 47 |
|
| 48 |
struct mlx5_ttc_table; |
| 49 |
|
| 50 |
struct ttc_params { |
| 51 |
enum mlx5_flow_namespace_type ns_type; |
| 52 |
struct mlx5_flow_table_attr ft_attr; |
| 53 |
struct mlx5_flow_destination dests[MLX5_NUM_TT]; |
| 54 |
DECLARE_BITMAP(ignore_dests, MLX5_NUM_TT); |
| 55 |
bool inner_ttc; |
| 56 |
DECLARE_BITMAP(ignore_tunnel_dests, MLX5_NUM_TUNNEL_TT); |
| 57 |
struct mlx5_flow_destination tunnel_dests[MLX5_NUM_TUNNEL_TT]; |
| 58 |
bool ipsec_rss; |
| 59 |
}; |
| 60 |
|
| 61 |
const char *mlx5_ttc_get_name(enum mlx5_traffic_types tt); |
| 62 |
struct mlx5_flow_table *mlx5_get_ttc_flow_table(struct mlx5_ttc_table *ttc); |
| 63 |
|
| 64 |
struct mlx5_ttc_table *mlx5_create_ttc_table(struct mlx5_core_dev *dev, |
| 65 |
struct ttc_params *params); |
| 66 |
void mlx5_destroy_ttc_table(struct mlx5_ttc_table *ttc); |
| 67 |
|
| 68 |
struct mlx5_ttc_table *mlx5_create_inner_ttc_table(struct mlx5_core_dev *dev, |
| 69 |
struct ttc_params *params); |
| 70 |
|
| 71 |
int mlx5_ttc_fwd_dest(struct mlx5_ttc_table *ttc, enum mlx5_traffic_types type, |
| 72 |
struct mlx5_flow_destination *new_dest); |
| 73 |
struct mlx5_flow_destination |
| 74 |
mlx5_ttc_get_default_dest(struct mlx5_ttc_table *ttc, |
| 75 |
enum mlx5_traffic_types type); |
| 76 |
int mlx5_ttc_fwd_default_dest(struct mlx5_ttc_table *ttc, |
| 77 |
enum mlx5_traffic_types type); |
| 78 |
|
| 79 |
bool mlx5_tunnel_inner_ft_supported(struct mlx5_core_dev *mdev); |
| 80 |
u8 mlx5_get_proto_by_tunnel_type(enum mlx5_tunnel_types tt); |
| 81 |
|
| 82 |
bool mlx5_ttc_has_esp_flow_group(struct mlx5_ttc_table *ttc); |
| 83 |
int mlx5_ttc_create_ipsec_rules(struct mlx5_ttc_table *ttc, |
| 84 |
struct mlx5_ttc_table *inner_ttc); |
| 85 |
void mlx5_ttc_destroy_ipsec_rules(struct mlx5_ttc_table *ttc); |
| 86 |
static inline bool mlx5_ttc_is_decrypted_esp_tt(enum mlx5_traffic_types tt) |
| 87 |
{ |
| 88 |
return tt >= MLX5_TT_DECRYPTED_ESP_OUTER_IPV4_TCP && |
| 89 |
tt <= MLX5_TT_DECRYPTED_ESP_INNER_IPV6_UDP; |
| 90 |
} |
| 91 |
|
| 92 |
#endif /* __MLX5_FS_TTC_H__ */ |