1
2
3
4#ifndef __NFP_FLOWER_CONNTRACK_H__
5#define __NFP_FLOWER_CONNTRACK_H__ 1
6
7#include <net/netfilter/nf_flow_table.h>
8#include "main.h"
9
10#define NFP_FL_CT_NO_TUN 0xff
11
12#define COMPARE_UNMASKED_FIELDS(__match1, __match2, __out) \
13 do { \
14 typeof(__match1) _match1 = (__match1); \
15 typeof(__match2) _match2 = (__match2); \
16 bool *_out = (__out); \
17 int i, size = sizeof(*(_match1).key); \
18 char *k1, *m1, *k2, *m2; \
19 *_out = false; \
20 k1 = (char *)_match1.key; \
21 m1 = (char *)_match1.mask; \
22 k2 = (char *)_match2.key; \
23 m2 = (char *)_match2.mask; \
24 for (i = 0; i < size; i++) \
25 if ((k1[i] & m1[i] & m2[i]) ^ \
26 (k2[i] & m1[i] & m2[i])) { \
27 *_out = true; \
28 break; \
29 } \
30 } while (0) \
31
32extern const struct rhashtable_params nfp_zone_table_params;
33extern const struct rhashtable_params nfp_ct_map_params;
34extern const struct rhashtable_params nfp_tc_ct_merge_params;
35extern const struct rhashtable_params nfp_nft_ct_merge_params;
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59struct nfp_fl_ct_zone_entry {
60 u16 zone;
61 struct rhash_head hash_node;
62
63 struct nfp_flower_priv *priv;
64 struct nf_flowtable *nft;
65
66 struct list_head pre_ct_list;
67 unsigned int pre_ct_count;
68
69 struct list_head post_ct_list;
70 unsigned int post_ct_count;
71
72 struct rhashtable tc_merge_tb;
73 unsigned int tc_merge_count;
74
75 struct list_head nft_flows_list;
76 unsigned int nft_flows_count;
77
78 struct rhashtable nft_merge_tb;
79 unsigned int nft_merge_count;
80};
81
82enum ct_entry_type {
83 CT_TYPE_PRE_CT,
84 CT_TYPE_NFT,
85 CT_TYPE_POST_CT,
86 _CT_TYPE_MAX,
87};
88
89enum nfp_nfp_layer_name {
90 FLOW_PAY_META_TCI = 0,
91 FLOW_PAY_INPORT,
92 FLOW_PAY_EXT_META,
93 FLOW_PAY_MAC_MPLS,
94 FLOW_PAY_L4,
95 FLOW_PAY_IPV4,
96 FLOW_PAY_IPV6,
97 FLOW_PAY_CT,
98 FLOW_PAY_GRE,
99 FLOW_PAY_QINQ,
100 FLOW_PAY_UDP_TUN,
101 FLOW_PAY_GENEVE_OPT,
102
103 _FLOW_PAY_LAYERS_MAX
104};
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119struct nfp_fl_ct_flow_entry {
120 unsigned long cookie;
121 struct list_head list_node;
122 u32 chain_index;
123 enum ct_entry_type type;
124 struct net_device *netdev;
125 struct nfp_fl_ct_zone_entry *zt;
126 struct list_head children;
127 struct flow_rule *rule;
128 struct flow_stats stats;
129 u8 tun_offset;
130};
131
132
133
134
135
136
137
138
139
140
141
142
143struct nfp_fl_ct_tc_merge {
144 unsigned long cookie[2];
145 struct rhash_head hash_node;
146 struct list_head pre_ct_list;
147 struct list_head post_ct_list;
148 struct nfp_fl_ct_zone_entry *zt;
149 struct nfp_fl_ct_flow_entry *pre_ct_parent;
150 struct nfp_fl_ct_flow_entry *post_ct_parent;
151 struct list_head children;
152};
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167struct nfp_fl_nft_tc_merge {
168 struct net_device *netdev;
169 unsigned long cookie[3];
170 struct rhash_head hash_node;
171 struct nfp_fl_ct_zone_entry *zt;
172 struct list_head nft_flow_list;
173 struct list_head tc_merge_list;
174 struct nfp_fl_ct_tc_merge *tc_m_parent;
175 struct nfp_fl_ct_flow_entry *nft_parent;
176 unsigned long tc_flower_cookie;
177 struct nfp_fl_payload *flow_pay;
178};
179
180
181
182
183
184
185
186struct nfp_fl_ct_map_entry {
187 unsigned long cookie;
188 struct rhash_head hash_node;
189 struct nfp_fl_ct_flow_entry *ct_entry;
190};
191
192bool is_pre_ct_flow(struct flow_cls_offload *flow);
193bool is_post_ct_flow(struct flow_cls_offload *flow);
194
195
196
197
198
199
200
201
202
203
204
205
206
207int nfp_fl_ct_handle_pre_ct(struct nfp_flower_priv *priv,
208 struct net_device *netdev,
209 struct flow_cls_offload *flow,
210 struct netlink_ext_ack *extack);
211
212
213
214
215
216
217
218
219
220
221
222
223int nfp_fl_ct_handle_post_ct(struct nfp_flower_priv *priv,
224 struct net_device *netdev,
225 struct flow_cls_offload *flow,
226 struct netlink_ext_ack *extack);
227
228
229
230
231
232void nfp_fl_ct_clean_flow_entry(struct nfp_fl_ct_flow_entry *entry);
233
234
235
236
237
238int nfp_fl_ct_del_flow(struct nfp_fl_ct_map_entry *ct_map_ent);
239
240
241
242
243
244
245
246
247int nfp_fl_ct_handle_nft_flow(enum tc_setup_type type, void *type_data,
248 void *cb_priv);
249
250
251
252
253
254
255int nfp_fl_ct_stats(struct flow_cls_offload *flow,
256 struct nfp_fl_ct_map_entry *ct_map_ent);
257#endif
258