blob: a4377881117071bcfce428e654b1dacecfd85c37 [file] [log] [blame]
Xiaoping Fand44a5b42015-05-26 17:37:37 -07001/*
2 * sfe_cm.h
3 * Shortcut forwarding engine.
4 *
5 * Copyright (c) 2013-2015 Qualcomm Atheros, Inc.
6 *
7 * All Rights Reserved.
8 * Qualcomm Atheros Confidential and Proprietary.
9 */
10
11/*
12 * connection flags.
13 */
14#define SFE_CREATE_FLAG_NO_SEQ_CHECK 0x1
15 /* Indicates that we should not check sequence numbers */
16
17/*
18 * IPv6 address structure
19 */
20struct sfe_ipv6_addr {
21 __be32 addr[4];
22};
23
24typedef union {
25 __be32 ip;
26 struct sfe_ipv6_addr ip6[1];
27} sfe_ip_addr_t;
28
29/*
30 * connection creation structure.
31 */
32struct sfe_connection_create {
33 int protocol;
34 struct net_device *src_dev;
35 struct net_device *dest_dev;
36 uint32_t flags;
37 uint32_t src_mtu;
38 uint32_t dest_mtu;
39 sfe_ip_addr_t src_ip;
40 sfe_ip_addr_t src_ip_xlate;
41 sfe_ip_addr_t dest_ip;
42 sfe_ip_addr_t dest_ip_xlate;
43 __be16 src_port;
44 __be16 src_port_xlate;
45 __be16 dest_port;
46 __be16 dest_port_xlate;
47 uint8_t src_mac[ETH_ALEN];
48 uint8_t src_mac_xlate[ETH_ALEN];
49 uint8_t dest_mac[ETH_ALEN];
50 uint8_t dest_mac_xlate[ETH_ALEN];
51 uint8_t src_td_window_scale;
52 uint32_t src_td_max_window;
53 uint32_t src_td_end;
54 uint32_t src_td_max_end;
55 uint8_t dest_td_window_scale;
56 uint32_t dest_td_max_window;
57 uint32_t dest_td_end;
58 uint32_t dest_td_max_end;
59 uint32_t mark;
Zhi Chen8748eb32015-06-18 12:58:48 -070060#ifdef CONFIG_XFRM
61 uint32_t original_accel;
62 uint32_t reply_accel;
63#endif
Xiaoping Fand44a5b42015-05-26 17:37:37 -070064};
65
66/*
67 * connection destruction structure.
68 */
69struct sfe_connection_destroy {
70 int protocol;
71 sfe_ip_addr_t src_ip;
72 sfe_ip_addr_t dest_ip;
73 __be16 src_port;
74 __be16 dest_port;
75};
76
77/*
78 * Structure used to sync connection stats/state back within the system.
79 *
80 * NOTE: The addresses here are NON-NAT addresses, i.e. the true endpoint addressing.
81 * 'src' is the creator of the connection.
82 */
83struct sfe_connection_sync {
84 struct net_device *src_dev;
85 struct net_device *dest_dev;
86 int is_v6; /* Is it for ipv6? */
87 int protocol; /* IP protocol number (IPPROTO_...) */
88 sfe_ip_addr_t src_ip; /* Non-NAT source address, i.e. the creator of the connection */
89 __be16 src_port; /* Non-NAT source port */
90 sfe_ip_addr_t dest_ip; /* Non-NAT destination address, i.e. to whom the connection was created */
91 __be16 dest_port; /* Non-NAT destination port */
92 uint32_t src_td_max_window;
93 uint32_t src_td_end;
94 uint32_t src_td_max_end;
95 uint64_t src_packet_count;
96 uint64_t src_byte_count;
97 uint32_t src_new_packet_count;
98 uint32_t src_new_byte_count;
99 uint32_t dest_td_max_window;
100 uint32_t dest_td_end;
101 uint32_t dest_td_max_end;
102 uint64_t dest_packet_count;
103 uint64_t dest_byte_count;
104 uint32_t dest_new_packet_count;
105 uint32_t dest_new_byte_count;
106 uint64_t delta_jiffies; /* Time to be added to the current timeout to keep the connection alive */
107};
108
109/*
110 * connection mark structure
111 */
112struct sfe_connection_mark {
113 int protocol;
114 sfe_ip_addr_t src_ip;
115 sfe_ip_addr_t dest_ip;
116 __be16 src_port;
117 __be16 dest_port;
118 uint32_t mark;
119};
120
121/*
122 * Type used for a sync rule callback.
123 */
124typedef void (*sfe_sync_rule_callback_t)(struct sfe_connection_sync *);
125
126/*
127 * IPv4 APIs used by connection manager
128 */
129extern int sfe_ipv4_recv(struct net_device *dev, struct sk_buff *skb);
130extern int sfe_ipv4_create_rule(struct sfe_connection_create *sic);
131extern void sfe_ipv4_destroy_rule(struct sfe_connection_destroy *sid);
132extern void sfe_ipv4_destroy_all_rules_for_dev(struct net_device *dev);
133extern void sfe_ipv4_register_sync_rule_callback(sfe_sync_rule_callback_t callback);
134extern void sfe_ipv4_update_rule(struct sfe_connection_create *sic);
135extern void sfe_ipv4_mark_rule(struct sfe_connection_mark *mark);
Xiaoping Fan978b3772015-05-27 14:15:18 -0700136
137#ifdef SFE_SUPPORT_IPV6
138/*
139 * IPv6 APIs used by connection manager
140 */
141extern int sfe_ipv6_recv(struct net_device *dev, struct sk_buff *skb);
142extern int sfe_ipv6_create_rule(struct sfe_connection_create *sic);
143extern void sfe_ipv6_destroy_rule(struct sfe_connection_destroy *sid);
144extern void sfe_ipv6_destroy_all_rules_for_dev(struct net_device *dev);
145extern void sfe_ipv6_register_sync_rule_callback(sfe_sync_rule_callback_t callback);
146extern void sfe_ipv6_update_rule(struct sfe_connection_create *sic);
147extern void sfe_ipv6_mark_rule(struct sfe_connection_mark *mark);
148#else
149static inline int sfe_ipv6_recv(struct net_device *dev, struct sk_buff *skb)
150{
151 return 0;
152}
153
154static inline int sfe_ipv6_create_rule(struct sfe_connection_create *sic)
155{
156 return -1;
157}
158
159static inline void sfe_ipv6_destroy_rule(struct sfe_connection_destroy *sid)
160{
161 return;
162}
163
164static inline void sfe_ipv6_destroy_all_rules_for_dev(struct net_device *dev)
165{
166 return;
167}
168
169static inline void sfe_ipv6_register_sync_rule_callback(sfe_sync_rule_callback_t callback)
170{
171 return;
172}
173
174static inline void sfe_ipv6_update_rule(struct sfe_connection_create *sic)
175{
176 return;
177}
178
179static inline void sfe_ipv6_mark_rule(struct sfe_connection_mark *mark)
180{
181 return;
182}
183#endif