aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h
blob: adda9cbfba4535218e7bd72244f6a2d364023752 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
/* Copyright (c) 2019, Mellanox Technologies */

#ifndef _MLX5DR_H_
#define _MLX5DR_H_

struct mlx5dr_domain;
struct mlx5dr_table;
struct mlx5dr_matcher;
struct mlx5dr_rule;
struct mlx5dr_action;

enum mlx5dr_domain_type {
	MLX5DR_DOMAIN_TYPE_NIC_RX,
	MLX5DR_DOMAIN_TYPE_NIC_TX,
	MLX5DR_DOMAIN_TYPE_FDB,
};

enum mlx5dr_domain_sync_flags {
	MLX5DR_DOMAIN_SYNC_FLAGS_SW = 1 << 0,
	MLX5DR_DOMAIN_SYNC_FLAGS_HW = 1 << 1,
};

enum mlx5dr_action_reformat_type {
	DR_ACTION_REFORMAT_TYP_TNL_L2_TO_L2,
	DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L2,
	DR_ACTION_REFORMAT_TYP_TNL_L3_TO_L2,
	DR_ACTION_REFORMAT_TYP_L2_TO_TNL_L3,
};

struct mlx5dr_match_parameters {
	size_t match_sz;
	u64 *match_buf; /* Device spec format */
};

#ifdef CONFIG_MLX5_SW_STEERING

struct mlx5dr_domain *
mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type);

int mlx5dr_domain_destroy(struct mlx5dr_domain *domain);

int mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags);

void mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
			    struct mlx5dr_domain *peer_dmn);

struct mlx5dr_table *
mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level);

int mlx5dr_table_destroy(struct mlx5dr_table *table);

u32 mlx5dr_table_get_id(struct mlx5dr_table *table);

struct mlx5dr_matcher *
mlx5dr_matcher_create(struct mlx5dr_table *table,
		      u16 priority,
		      u8 match_criteria_enable,
		      struct mlx5dr_match_parameters *mask);

int mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher);

struct mlx5dr_rule *
mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
		   struct mlx5dr_match_parameters *value,
		   size_t num_actions,
		   struct mlx5dr_action *actions[]);

int mlx5dr_rule_destroy(struct mlx5dr_rule *rule);

int mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
				 struct mlx5dr_action *action);

struct mlx5dr_action *
mlx5dr_action_create_dest_table(struct mlx5dr_table *table);

struct mlx5dr_action *
mlx5dr_create_action_dest_flow_fw_table(struct mlx5_flow_table *ft,
					struct mlx5_core_dev *mdev);

struct mlx5dr_action *
mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain,
				u32 vport, u8 vhca_id_valid,
				u16 vhca_id);

struct mlx5dr_action *mlx5dr_action_create_drop(void);

struct mlx5dr_action *mlx5dr_action_create_tag(u32 tag_value);

struct mlx5dr_action *
mlx5dr_action_create_flow_counter(u32 counter_id);

struct mlx5dr_action *
mlx5dr_action_create_packet_reformat(struct mlx5dr_domain *dmn,
				     enum mlx5dr_action_reformat_type reformat_type,
				     size_t data_sz,
				     void *data);

struct mlx5dr_action *
mlx5dr_action_create_modify_header(struct mlx5dr_domain *domain,
				   u32 flags,
				   size_t actions_sz,
				   __be64 actions[]);

struct mlx5dr_action *mlx5dr_action_create_pop_vlan(void);

struct mlx5dr_action *
mlx5dr_action_create_push_vlan(struct mlx5dr_domain *domain, __be32 vlan_hdr);

int mlx5dr_action_destroy(struct mlx5dr_action *action);

static inline bool
mlx5dr_is_supported(struct mlx5_core_dev *dev)
{
	return MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner);
}

#else /* CONFIG_MLX5_SW_STEERING */

static inline struct mlx5dr_domain *
mlx5dr_domain_create(struct mlx5_core_dev *mdev, enum mlx5dr_domain_type type) { return NULL; }

static inline int
mlx5dr_domain_destroy(struct mlx5dr_domain *domain) { return 0; }

static inline int
mlx5dr_domain_sync(struct mlx5dr_domain *domain, u32 flags) { return 0; }

static inline void
mlx5dr_domain_set_peer(struct mlx5dr_domain *dmn,
		       struct mlx5dr_domain *peer_dmn) { }

static inline struct mlx5dr_table *
mlx5dr_table_create(struct mlx5dr_domain *domain, u32 level) { return NULL; }

static inline int
mlx5dr_table_destroy(struct mlx5dr_table *table) { return 0; }

static inline u32
mlx5dr_table_get_id(struct mlx5dr_table *table) { return 0; }

static inline struct mlx5dr_matcher *
mlx5dr_matcher_create(struct mlx5dr_table *table,
		      u16 priority,
		      u8 match_criteria_enable,
		      struct mlx5dr_match_parameters *mask) { return NULL; }

static inline int
mlx5dr_matcher_destroy(struct mlx5dr_matcher *matcher) { return 0; }

static inline struct mlx5dr_rule *
mlx5dr_rule_create(struct mlx5dr_matcher *matcher,
		   struct mlx5dr_match_parameters *value,
		   size_t num_actions,
		   struct mlx5dr_action *actions[]) { return NULL; }

static inline int
mlx5dr_rule_destroy(struct mlx5dr_rule *rule) { return 0; }

static inline int
mlx5dr_table_set_miss_action(struct mlx5dr_table *tbl,
			     struct mlx5dr_action *action) { return 0; }

static inline struct mlx5dr_action *
mlx5dr_action_create_dest_table(struct mlx5dr_table *table) { return NULL; }

static inline struct mlx5dr_action *
mlx5dr_create_action_dest_flow_fw_table(struct mlx5_flow_table *ft,
					struct mlx5_core_dev *mdev) { return NULL; }

static inline struct mlx5dr_action *
mlx5dr_action_create_dest_vport(struct mlx5dr_domain *domain,
				u32 vport, u8 vhca_id_valid,
				u16 vhca_id) { return NULL; }

static inline struct mlx5dr_action *
mlx5dr_action_create_drop(void) { return NULL; }

static inline struct mlx5dr_action *
mlx5dr_action_create_tag(u32 tag_value) { return NULL; }

static inline struct mlx5dr_action *
mlx5dr_action_create_flow_counter(u32 counter_id) { return NULL; }

static inline struct mlx5dr_action *
mlx5dr_action_create_packet_reformat(struct mlx5dr_domain *dmn,
				     enum mlx5dr_action_reformat_type reformat_type,
				     size_t data_sz,
				     void *data) { return NULL; }

static inline struct mlx5dr_action *
mlx5dr_action_create_modify_header(struct mlx5dr_domain *domain,
				   u32 flags,
				   size_t actions_sz,
				   __be64 actions[]) { return NULL; }

static inline struct mlx5dr_action *
mlx5dr_action_create_pop_vlan(void) { return NULL; }

static inline struct mlx5dr_action *
mlx5dr_action_create_push_vlan(struct mlx5dr_domain *domain,
			       __be32 vlan_hdr) { return NULL; }

static inline int
mlx5dr_action_destroy(struct mlx5dr_action *action) { return 0; }

static inline bool
mlx5dr_is_supported(struct mlx5_core_dev *dev) { return false; }

#endif /* CONFIG_MLX5_SW_STEERING */

#endif /* _MLX5DR_H_ */