blob: 016ee8fc56aeba3412a5fbdc71c2b41b3ce2e6fa [file] [log] [blame]
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +05301/*
2 * sfe_ipv4.h
3 * Shortcut forwarding engine header file for IPv4.
4 *
5 * Copyright (c) 2013-2016, 2019-2020, The Linux Foundation. All rights reserved.
Guduri Prathyusha5f27e232022-01-06 14:39:04 +05306 * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +05307 *
8 * Permission to use, copy, modify, and/or distribute this software for any
9 * purpose with or without fee is hereby granted, provided that the above
10 * copyright notice and this permission notice appear in all copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 */
20
Wayne Tanbb7f1782021-12-13 11:16:04 -080021#ifndef __SFE_IPV4_H
22#define __SFE_IPV4_H
23
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053024#define SFE_IPV4_DSCP_MASK 0x3
25#define SFE_IPV4_DSCP_SHIFT 2
26
27/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053028 * Specifies the lower bound on ACK numbers carried in the TCP header
29 */
30#define SFE_IPV4_TCP_MAX_ACK_WINDOW 65520
31
32/*
33 * IPv4 TCP connection match additional data.
34 */
35struct sfe_ipv4_tcp_connection_match {
36 u8 win_scale; /* Window scale */
37 u32 max_win; /* Maximum window size seen */
38 u32 end; /* Sequence number of the next byte to send (seq + segment length) */
39 u32 max_end; /* Sequence number of the last byte to ack */
40};
41
42/*
43 * Bit flags for IPv4 connection matching entry.
44 */
45#define SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_SRC (1<<0)
46 /* Perform source translation */
47#define SFE_IPV4_CONNECTION_MATCH_FLAG_XLATE_DEST (1<<1)
48 /* Perform destination translation */
49#define SFE_IPV4_CONNECTION_MATCH_FLAG_NO_SEQ_CHECK (1<<2)
50 /* Ignore TCP sequence numbers */
51#define SFE_IPV4_CONNECTION_MATCH_FLAG_WRITE_FAST_ETH_HDR (1<<3)
52 /* Fast Ethernet header write */
53#define SFE_IPV4_CONNECTION_MATCH_FLAG_WRITE_L2_HDR (1<<4)
54 /* Fast Ethernet header write */
55#define SFE_IPV4_CONNECTION_MATCH_FLAG_PRIORITY_REMARK (1<<5)
56 /* remark priority of SKB */
57#define SFE_IPV4_CONNECTION_MATCH_FLAG_DSCP_REMARK (1<<6)
58 /* remark DSCP of packet */
Ratheesh Kannotha3cf0e02021-12-09 09:44:10 +053059#define SFE_IPV4_CONNECTION_MATCH_FLAG_CSUM_OFFLOAD (1<<7)
60 /* checksum offload.*/
Guduri Prathyushaeb31c902021-11-10 20:18:50 +053061#define SFE_IPV4_CONNECTION_MATCH_FLAG_PPPOE_DECAP (1<<8)
62 /* Indicates that PPPoE should be decapsulated */
63#define SFE_IPV4_CONNECTION_MATCH_FLAG_PPPOE_ENCAP (1<<9)
64 /* Indicates that PPPoE should be encapsulated */
Ratheesh Kannoth71fc51e2022-01-05 10:02:47 +053065#define SFE_IPV4_CONNECTION_MATCH_FLAG_BRIDGE_FLOW (1<<10)
66 /* Bridge flow */
Ken Zhu37040ea2021-09-09 21:11:15 -070067#define SFE_IPV4_CONNECTION_MATCH_FLAG_MARK (1<<11)
68 /* skb mark of the packet */
Wayne Tanbb7f1782021-12-13 11:16:04 -080069#define SFE_IPV4_CONNECTION_MATCH_FLAG_INSERT_EGRESS_VLAN_TAG (1<<12)
70 /* Insert VLAN tag */
Ratheesh Kannoth5dee3772022-01-18 11:27:14 +053071#define SFE_IPV4_CONNECTION_MATCH_FLAG_SRC_INTERFACE_CHECK (1<<13)
72 /* Source interface check.*/
Nitin Shettye6ed5b52021-12-27 14:50:11 +053073#define SFE_IPV4_CONNECTION_MATCH_FLAG_PASSTHROUGH (1<<14)
74 /* passthrough flow: encap/decap to be skipped for this flow */
Wayne Tanbb7f1782021-12-13 11:16:04 -080075
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053076/*
77 * IPv4 connection matching structure.
78 */
79struct sfe_ipv4_connection_match {
80 /*
81 * References to other objects.
82 */
Ratheesh Kannoth94fc5b82021-10-20 07:45:06 +053083 struct hlist_node hnode;
84
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053085 struct sfe_ipv4_connection *connection;
86 struct sfe_ipv4_connection_match *counter_match;
87 /* Matches the flow in the opposite direction as the one in *connection */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053088 /*
89 * Characteristics that identify flows that match this rule.
90 */
91 struct net_device *match_dev; /* Network device */
92 u8 match_protocol; /* Protocol */
93 __be32 match_src_ip; /* Source IP address */
94 __be32 match_dest_ip; /* Destination IP address */
95 __be16 match_src_port; /* Source port/connection ident */
96 __be16 match_dest_port; /* Destination port/connection ident */
97
Amitesh Anand63be37d2021-12-24 20:51:48 +053098 struct udp_sock *up; /* Stores UDP sock information; valid only in decap path */
Nitin Shettye6ed5b52021-12-27 14:50:11 +053099 struct net_protocol *proto; /* stores protocol handler; valid only in decap path */
Amitesh Anand63be37d2021-12-24 20:51:48 +0530100
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530101 /*
102 * Control the operations of the match.
103 */
104 u32 flags; /* Bit flags */
105#ifdef CONFIG_NF_FLOW_COOKIE
106 u32 flow_cookie; /* used flow cookie, for debug */
107#endif
108#ifdef CONFIG_XFRM
109 u32 flow_accel; /* The flow accelerated or not */
110#endif
111
112 /*
113 * Connection state that we track once we match.
114 */
115 union { /* Protocol-specific state */
116 struct sfe_ipv4_tcp_connection_match tcp;
117 } protocol_state;
Wayne Tanbb7f1782021-12-13 11:16:04 -0800118
119 /*
120 * VLAN headers
121 */
122 struct sfe_vlan_hdr ingress_vlan_hdr[SFE_MAX_VLAN_DEPTH];
123 struct sfe_vlan_hdr egress_vlan_hdr[SFE_MAX_VLAN_DEPTH];
124
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530125 /*
126 * Stats recorded in a sync period. These stats will be added to
127 * rx_packet_count64/rx_byte_count64 after a sync period.
128 */
Ratheesh Kannoth94fc5b82021-10-20 07:45:06 +0530129 atomic_t rx_packet_count;
130 atomic_t rx_byte_count;
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530131
132 /*
133 * Packet translation information.
134 */
135 __be32 xlate_src_ip; /* Address after source translation */
136 __be16 xlate_src_port; /* Port/connection ident after source translation */
137 u16 xlate_src_csum_adjustment;
138 /* Transport layer checksum adjustment after source translation */
139 u16 xlate_src_partial_csum_adjustment;
140 /* Transport layer pseudo header checksum adjustment after source translation */
141
142 __be32 xlate_dest_ip; /* Address after destination translation */
143 __be16 xlate_dest_port; /* Port/connection ident after destination translation */
144 u16 xlate_dest_csum_adjustment;
145 /* Transport layer checksum adjustment after destination translation */
146 u16 xlate_dest_partial_csum_adjustment;
147 /* Transport layer pseudo header checksum adjustment after destination translation */
148
149 /*
150 * QoS information
151 */
152 u32 priority;
153 u32 dscp;
Ken Zhu37040ea2021-09-09 21:11:15 -0700154 u32 mark; /* mark for outgoing packet */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530155
156 /*
157 * Packet transmit information.
158 */
159 struct net_device *xmit_dev; /* Network device on which to transmit */
160 unsigned short int xmit_dev_mtu;
161 /* Interface MTU */
162 u16 xmit_dest_mac[ETH_ALEN / 2];
163 /* Destination MAC address to use when forwarding */
164 u16 xmit_src_mac[ETH_ALEN / 2];
165 /* Source MAC address to use when forwarding */
166
Wayne Tanbb7f1782021-12-13 11:16:04 -0800167 u8 ingress_vlan_hdr_cnt; /* Ingress active vlan headers count */
168 u8 egress_vlan_hdr_cnt; /* Egress active vlan headers count */
169
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530170 /*
171 * Summary stats.
172 */
173 u64 rx_packet_count64;
174 u64 rx_byte_count64;
Guduri Prathyushaeb31c902021-11-10 20:18:50 +0530175
176 /*
177 * PPPoE information
178 */
179 u16 pppoe_session_id;
180 u8 pppoe_remote_mac[ETH_ALEN];
Wayne Tanbb7f1782021-12-13 11:16:04 -0800181
182 /*
183 * Size of all needed L2 headers
184 */
185 u16 l2_hdr_size;
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530186};
187
188/*
189 * Per-connection data structure.
190 */
191struct sfe_ipv4_connection {
192 struct sfe_ipv4_connection *next;
193 /* Pointer to the next entry in a hash chain */
194 struct sfe_ipv4_connection *prev;
195 /* Pointer to the previous entry in a hash chain */
196 int protocol; /* IP protocol number */
197 __be32 src_ip; /* Src IP addr pre-translation */
198 __be32 src_ip_xlate; /* Src IP addr post-translation */
199 __be32 dest_ip; /* Dest IP addr pre-translation */
200 __be32 dest_ip_xlate; /* Dest IP addr post-translation */
201 __be16 src_port; /* Src port pre-translation */
202 __be16 src_port_xlate; /* Src port post-translation */
203 __be16 dest_port; /* Dest port pre-translation */
204 __be16 dest_port_xlate; /* Dest port post-translation */
205 struct sfe_ipv4_connection_match *original_match;
206 /* Original direction matching structure */
207 struct net_device *original_dev;
208 /* Original direction source device */
209 struct sfe_ipv4_connection_match *reply_match;
210 /* Reply direction matching structure */
211 struct net_device *reply_dev; /* Reply direction source device */
212 u64 last_sync_jiffies; /* Jiffies count for the last sync */
213 struct sfe_ipv4_connection *all_connections_next;
214 /* Pointer to the next entry in the list of all connections */
215 struct sfe_ipv4_connection *all_connections_prev;
216 /* Pointer to the previous entry in the list of all connections */
217 u32 mark; /* mark for outgoing packet */
218 u32 debug_read_seq; /* sequence number for debug dump */
Ratheesh Kannoth94fc5b82021-10-20 07:45:06 +0530219 bool removed; /* Indicates the connection is removed */
220 struct rcu_head rcu; /* delay rcu free */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530221};
222
223/*
224 * IPv4 connections and hash table size information.
225 */
226#define SFE_IPV4_CONNECTION_HASH_SHIFT 12
227#define SFE_IPV4_CONNECTION_HASH_SIZE (1 << SFE_IPV4_CONNECTION_HASH_SHIFT)
228#define SFE_IPV4_CONNECTION_HASH_MASK (SFE_IPV4_CONNECTION_HASH_SIZE - 1)
229
230enum sfe_ipv4_exception_events {
231 SFE_IPV4_EXCEPTION_EVENT_UDP_HEADER_INCOMPLETE,
232 SFE_IPV4_EXCEPTION_EVENT_UDP_NO_CONNECTION,
233 SFE_IPV4_EXCEPTION_EVENT_UDP_IP_OPTIONS_OR_INITIAL_FRAGMENT,
234 SFE_IPV4_EXCEPTION_EVENT_UDP_SMALL_TTL,
235 SFE_IPV4_EXCEPTION_EVENT_UDP_NEEDS_FRAGMENTATION,
236 SFE_IPV4_EXCEPTION_EVENT_TCP_HEADER_INCOMPLETE,
237 SFE_IPV4_EXCEPTION_EVENT_TCP_NO_CONNECTION_SLOW_FLAGS,
238 SFE_IPV4_EXCEPTION_EVENT_TCP_NO_CONNECTION_FAST_FLAGS,
239 SFE_IPV4_EXCEPTION_EVENT_TCP_IP_OPTIONS_OR_INITIAL_FRAGMENT,
240 SFE_IPV4_EXCEPTION_EVENT_TCP_SMALL_TTL,
241 SFE_IPV4_EXCEPTION_EVENT_TCP_NEEDS_FRAGMENTATION,
242 SFE_IPV4_EXCEPTION_EVENT_TCP_FLAGS,
243 SFE_IPV4_EXCEPTION_EVENT_TCP_SEQ_EXCEEDS_RIGHT_EDGE,
244 SFE_IPV4_EXCEPTION_EVENT_TCP_SMALL_DATA_OFFS,
245 SFE_IPV4_EXCEPTION_EVENT_TCP_BAD_SACK,
246 SFE_IPV4_EXCEPTION_EVENT_TCP_BIG_DATA_OFFS,
247 SFE_IPV4_EXCEPTION_EVENT_TCP_SEQ_BEFORE_LEFT_EDGE,
248 SFE_IPV4_EXCEPTION_EVENT_TCP_ACK_EXCEEDS_RIGHT_EDGE,
249 SFE_IPV4_EXCEPTION_EVENT_TCP_ACK_BEFORE_LEFT_EDGE,
250 SFE_IPV4_EXCEPTION_EVENT_ICMP_HEADER_INCOMPLETE,
251 SFE_IPV4_EXCEPTION_EVENT_ICMP_UNHANDLED_TYPE,
252 SFE_IPV4_EXCEPTION_EVENT_ICMP_IPV4_HEADER_INCOMPLETE,
253 SFE_IPV4_EXCEPTION_EVENT_ICMP_IPV4_NON_V4,
254 SFE_IPV4_EXCEPTION_EVENT_ICMP_IPV4_IP_OPTIONS_INCOMPLETE,
255 SFE_IPV4_EXCEPTION_EVENT_ICMP_IPV4_UDP_HEADER_INCOMPLETE,
256 SFE_IPV4_EXCEPTION_EVENT_ICMP_IPV4_TCP_HEADER_INCOMPLETE,
257 SFE_IPV4_EXCEPTION_EVENT_ICMP_IPV4_UNHANDLED_PROTOCOL,
258 SFE_IPV4_EXCEPTION_EVENT_ICMP_NO_CONNECTION,
259 SFE_IPV4_EXCEPTION_EVENT_ICMP_FLUSHED_CONNECTION,
260 SFE_IPV4_EXCEPTION_EVENT_HEADER_INCOMPLETE,
Ratheesh Kannoth43d64f82021-10-20 08:23:29 +0530261 SFE_IPV4_EXCEPTION_EVENT_HEADER_CSUM_BAD,
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530262 SFE_IPV4_EXCEPTION_EVENT_BAD_TOTAL_LENGTH,
263 SFE_IPV4_EXCEPTION_EVENT_NON_V4,
264 SFE_IPV4_EXCEPTION_EVENT_NON_INITIAL_FRAGMENT,
265 SFE_IPV4_EXCEPTION_EVENT_DATAGRAM_INCOMPLETE,
266 SFE_IPV4_EXCEPTION_EVENT_IP_OPTIONS_INCOMPLETE,
267 SFE_IPV4_EXCEPTION_EVENT_UNHANDLED_PROTOCOL,
Guduri Prathyusha5f27e232022-01-06 14:39:04 +0530268 SFE_IPV4_EXCEPTION_EVENT_NO_HEADROOM,
Guduri Prathyusha647fe3e2021-11-22 19:17:51 +0530269 SFE_IPV4_EXCEPTION_EVENT_INVALID_PPPOE_SESSION,
270 SFE_IPV4_EXCEPTION_EVENT_INCORRECT_PPPOE_PARSING,
271 SFE_IPV4_EXCEPTION_EVENT_PPPOE_NOT_SET_IN_CME,
Wayne Tanbb7f1782021-12-13 11:16:04 -0800272 SFE_IPV4_EXCEPTION_EVENT_INGRESS_VLAN_TAG_MISMATCH,
Ratheesh Kannoth5dee3772022-01-18 11:27:14 +0530273 SFE_IPV4_EXCEPTION_EVENT_INVALID_SRC_IFACE,
Nitin Shettye6ed5b52021-12-27 14:50:11 +0530274 SFE_IPV4_EXCEPTION_EVENT_GRE_HEADER_INCOMPLETE,
275 SFE_IPV4_EXCEPTION_EVENT_GRE_NO_CONNECTION,
276 SFE_IPV4_EXCEPTION_EVENT_GRE_IP_OPTIONS_OR_INITIAL_FRAGMENT,
277 SFE_IPV4_EXCEPTION_EVENT_GRE_SMALL_TTL,
278 SFE_IPV4_EXCEPTION_EVENT_GRE_NEEDS_FRAGMENTATION,
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530279 SFE_IPV4_EXCEPTION_EVENT_LAST
280};
281
282/*
Ratheesh Kannoth3aeb2892021-10-20 07:57:15 +0530283 * per CPU stats
284 */
285struct sfe_ipv4_stats {
286 /*
287 * Stats recorded in a sync period. These stats will be added to
288 * connection_xxx64 after a sync period.
289 */
290 u64 connection_create_requests64;
291 /* Number of IPv4 connection create requests */
292 u64 connection_create_collisions64;
293 /* Number of IPv4 connection create requests that collided with existing hash table entries */
Ratheesh Kannoth89302a72021-10-20 08:10:37 +0530294 u64 connection_create_failures64;
295 /* Number of IPv4 connection create requests that failed */
Ratheesh Kannoth3aeb2892021-10-20 07:57:15 +0530296 u64 connection_destroy_requests64;
297 /* Number of IPv4 connection destroy requests */
298 u64 connection_destroy_misses64;
299 /* Number of IPv4 connection destroy requests that missed our hash table */
300 u64 connection_match_hash_hits64;
301 /* Number of IPv4 connection match hash hits */
302 u64 connection_match_hash_reorders64;
303 /* Number of IPv4 connection match hash reorders */
304 u64 connection_flushes64; /* Number of IPv4 connection flushes */
Amitesh Anand63be37d2021-12-24 20:51:48 +0530305 u64 packets_dropped64; /* Number of IPv4 packets dropped */
Ratheesh Kannoth3aeb2892021-10-20 07:57:15 +0530306 u64 packets_forwarded64; /* Number of IPv4 packets forwarded */
307 u64 packets_not_forwarded64; /* Number of IPv4 packets not forwarded */
308 u64 exception_events64[SFE_IPV4_EXCEPTION_EVENT_LAST];
Guduri Prathyusha034d6352022-01-12 16:49:04 +0530309 u64 pppoe_encap_packets_forwarded64; /* Number of IPv4 PPPoE encap packets forwarded */
310 u64 pppoe_decap_packets_forwarded64; /* Number of IPv4 PPPoE decap packets forwarded */
311 u64 pppoe_bridge_packets_forwarded64; /* Number of IPv4 PPPoE bridge packets forwarded */
Ratheesh Kannoth3aeb2892021-10-20 07:57:15 +0530312};
313
314/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530315 * Per-module structure.
316 */
317struct sfe_ipv4 {
318 spinlock_t lock; /* Lock for SMP correctness */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530319 struct sfe_ipv4_connection *all_connections_head;
320 /* Head of the list of all connections */
321 struct sfe_ipv4_connection *all_connections_tail;
322 /* Tail of the list of all connections */
323 unsigned int num_connections; /* Number of connections */
Ken Zhu137722d2021-09-23 17:57:36 -0700324 struct delayed_work sync_dwork; /* Work to sync the statistics */
325 unsigned int work_cpu; /* The core to run stats sync on */
326
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530327 sfe_sync_rule_callback_t __rcu sync_rule_callback;
328 /* Callback function registered by a connection manager for stats syncing */
329 struct sfe_ipv4_connection *conn_hash[SFE_IPV4_CONNECTION_HASH_SIZE];
330 /* Connection hash table */
Ratheesh Kannoth94fc5b82021-10-20 07:45:06 +0530331
332 struct hlist_head hlist_conn_match_hash_head[SFE_IPV4_CONNECTION_HASH_SIZE];
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530333 /* Connection match hash table */
Ratheesh Kannoth94fc5b82021-10-20 07:45:06 +0530334
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530335#ifdef CONFIG_NF_FLOW_COOKIE
336 struct sfe_flow_cookie_entry sfe_flow_cookie_table[SFE_FLOW_COOKIE_SIZE];
337 /* flow cookie table*/
338 flow_cookie_set_func_t flow_cookie_set_func;
339 /* function used to configure flow cookie in hardware*/
340 int flow_cookie_enable;
341 /* Enable/disable flow cookie at runtime */
342#endif
343
Ratheesh Kannoth3aeb2892021-10-20 07:57:15 +0530344 struct sfe_ipv4_stats __percpu *stats_pcpu;
345 /* Per CPU statistics. */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530346
Ken Zhudc423672021-09-02 18:27:01 -0700347 struct sfe_ipv4_connection *wc_next; /* Connection list walk pointer for stats sync */
348
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530349 /*
350 * Control state.
351 */
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530352 struct kobject *sys_ipv4; /* sysfs linkage */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530353 int debug_dev; /* Major number of the debug char device */
354 u32 debug_read_seq; /* sequence number for debug dump */
355};
356
357/*
358 * Enumeration of the XML output.
359 */
360enum sfe_ipv4_debug_xml_states {
361 SFE_IPV4_DEBUG_XML_STATE_START,
362 SFE_IPV4_DEBUG_XML_STATE_CONNECTIONS_START,
363 SFE_IPV4_DEBUG_XML_STATE_CONNECTIONS_CONNECTION,
364 SFE_IPV4_DEBUG_XML_STATE_CONNECTIONS_END,
365 SFE_IPV4_DEBUG_XML_STATE_EXCEPTIONS_START,
366 SFE_IPV4_DEBUG_XML_STATE_EXCEPTIONS_EXCEPTION,
367 SFE_IPV4_DEBUG_XML_STATE_EXCEPTIONS_END,
368 SFE_IPV4_DEBUG_XML_STATE_STATS,
369 SFE_IPV4_DEBUG_XML_STATE_END,
370 SFE_IPV4_DEBUG_XML_STATE_DONE
371};
372
373/*
374 * XML write state.
375 */
376struct sfe_ipv4_debug_xml_write_state {
377 enum sfe_ipv4_debug_xml_states state;
378 /* XML output file state machine state */
379 int iter_exception; /* Next exception iterator */
380};
381
382typedef bool (*sfe_ipv4_debug_xml_write_method_t)(struct sfe_ipv4 *si, char *buffer, char *msg, size_t *length,
383 int *total_read, struct sfe_ipv4_debug_xml_write_state *ws);
384
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530385u16 sfe_ipv4_gen_ip_csum(struct iphdr *iph);
386void sfe_ipv4_exception_stats_inc(struct sfe_ipv4 *si, enum sfe_ipv4_exception_events reason);
387bool sfe_ipv4_remove_connection(struct sfe_ipv4 *si, struct sfe_ipv4_connection *c);
388void sfe_ipv4_flush_connection(struct sfe_ipv4 *si, struct sfe_ipv4_connection *c, sfe_sync_reason_t reason);
Ken Zhu88c58152021-12-09 15:12:06 -0800389void sfe_ipv4_sync_status(struct sfe_ipv4 *si, struct sfe_ipv4_connection *c, sfe_sync_reason_t reason);
Ratheesh Kannoth6307bec2021-11-25 08:26:39 +0530390
391struct sfe_ipv4_connection_match *
392sfe_ipv4_find_connection_match_rcu(struct sfe_ipv4 *si, struct net_device *dev, u8 protocol,
393 __be32 src_ip, __be16 src_port,
394 __be32 dest_ip, __be16 dest_port);
395
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530396void sfe_ipv4_exit(void);
397int sfe_ipv4_init(void);
Wayne Tanbb7f1782021-12-13 11:16:04 -0800398
399#endif /* __SFE_IPV4_H */