blob: 99c689f7fef47d02bb01833974005768e52acdec [file] [log] [blame]
Sol Kavy879eb8b2014-04-07 19:11:31 -07001/*
2 **************************************************************************
3 * Copyright (c) 2014, Qualcomm Atheros, Inc.
4 * Permission to use, copy, modify, and/or distribute this software for
5 * any purpose with or without fee is hereby granted, provided that the
6 * above copyright notice and this permission notice appear in all copies.
7 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
8 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
9 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
10 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
11 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
12 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
13 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
14 **************************************************************************
15 */
16
17/*
18 * nss_ipv6.h
19 * NSS to HLOS interface definitions.
20 */
21
22/*
23 * TODO: Since this is the now the public header file for writting an
24 * IPv6 message, we need to convert the entire file to doxygen.
25 */
26
27#ifndef __NSS_IPV6_H
28#define __NSS_IPV6_H
29
30/*
31 * IPv6 bridge/route rule messages
32 */
33
34/*
35 * NSS IPv6 rule creation flags.
36 */
37#define NSS_IPV6_RULE_CREATE_FLAG_NO_SEQ_CHECK 0x01
38 /* Do not perform sequence number checks */
39#define NSS_IPV6_RULE_CREATE_FLAG_BRIDGE_FLOW 0x02
40 /* This is a pure bridge forwarding flow */
41#define NSS_IPV6_RULE_CREATE_FLAG_ROUTED 0x04
42 /* Rule is for a routed connection. */
43#define NSS_IPV6_RULE_CREATE_FLAG_DSCP_MARKING 0x08
44 /* Rule is for a DSCP marking . */
45#define NSS_IPV6_RULE_CREATE_FLAG_VLAN_MARKING 0x10
46 /* Rule is for a VLAN marking . */
47
48/*
49 * IPv6 rule creation validity flags.
50 */
51#define NSS_IPV6_RULE_CREATE_CONN_VALID 0x01 /* Protocol fields are valid */
52#define NSS_IPV6_RULE_CREATE_TCP_VALID 0x02 /* Protocol fields are valid */
53#define NSS_IPV6_RULE_CREATE_PPPOE_VALID 0x04 /* PPPoE fields are valid */
54#define NSS_IPV6_RULE_CREATE_QOS_VALID 0x08 /* QoS fields are valid */
55#define NSS_IPV6_RULE_CREATE_VLAN_VALID 0x10 /* VLAN fields are valid */
56#define NSS_IPV6_RULE_CREATE_DSCP_MARKING_VALID 0x20 /* DSCP fields are valid */
57#define NSS_IPV6_RULE_CREATE_VLAN_MARKING_VALID 0x40 /* VLAN fields are valid */
58
59/*
60 * Exception events from IPv6 bridge/route handler
61 */
62enum exception_events_ipv6 {
63 NSS_EXCEPTION_EVENT_IPV6_ICMP_HEADER_INCOMPLETE,
64 NSS_EXCEPTION_EVENT_IPV6_ICMP_UNHANDLED_TYPE,
65 NSS_EXCEPTION_EVENT_IPV6_ICMP_IPV6_HEADER_INCOMPLETE,
66 NSS_EXCEPTION_EVENT_IPV6_ICMP_IPV6_UDP_HEADER_INCOMPLETE,
67 NSS_EXCEPTION_EVENT_IPV6_ICMP_IPV6_TCP_HEADER_INCOMPLETE,
68 NSS_EXCEPTION_EVENT_IPV6_ICMP_IPV6_UNKNOWN_PROTOCOL,
69 NSS_EXCEPTION_EVENT_IPV6_ICMP_NO_ICME,
70 NSS_EXCEPTION_EVENT_IPV6_ICMP_FLUSH_TO_HOST,
71 NSS_EXCEPTION_EVENT_IPV6_TCP_HEADER_INCOMPLETE,
72 NSS_EXCEPTION_EVENT_IPV6_TCP_NO_ICME,
73 NSS_EXCEPTION_EVENT_IPV6_TCP_SMALL_HOP_LIMIT,
74 NSS_EXCEPTION_EVENT_IPV6_TCP_NEEDS_FRAGMENTATION,
75 NSS_EXCEPTION_EVENT_IPV6_TCP_FLAGS,
76 NSS_EXCEPTION_EVENT_IPV6_TCP_SEQ_EXCEEDS_RIGHT_EDGE,
77 NSS_EXCEPTION_EVENT_IPV6_TCP_SMALL_DATA_OFFS,
78 NSS_EXCEPTION_EVENT_IPV6_TCP_BAD_SACK,
79 NSS_EXCEPTION_EVENT_IPV6_TCP_BIG_DATA_OFFS,
80 NSS_EXCEPTION_EVENT_IPV6_TCP_SEQ_BEFORE_LEFT_EDGE,
81 NSS_EXCEPTION_EVENT_IPV6_TCP_ACK_EXCEEDS_RIGHT_EDGE,
82 NSS_EXCEPTION_EVENT_IPV6_TCP_ACK_BEFORE_LEFT_EDGE,
83 NSS_EXCEPTION_EVENT_IPV6_UDP_HEADER_INCOMPLETE,
84 NSS_EXCEPTION_EVENT_IPV6_UDP_NO_ICME,
85 NSS_EXCEPTION_EVENT_IPV6_UDP_SMALL_HOP_LIMIT,
86 NSS_EXCEPTION_EVENT_IPV6_UDP_NEEDS_FRAGMENTATION,
87 NSS_EXCEPTION_EVENT_IPV6_WRONG_TARGET_MAC,
88 NSS_EXCEPTION_EVENT_IPV6_HEADER_INCOMPLETE,
89 NSS_EXCEPTION_EVENT_IPV6_UNKNOWN_PROTOCOL,
90 NSS_EXCEPTION_EVENT_IPV6_IVID_MISMATCH,
91 NSS_EXCEPTION_EVENT_IPV6_DSCP_MARKING_MISMATCH,
92 NSS_EXCEPTION_EVENT_IPV6_VLAN_MARKING_MISMATCH,
93 NSS_EXCEPTION_EVENT_IPV6_MAX
94};
95
96/*
97 * Common 5 tuple structure
98 */
99struct nss_ipv6_5tuple {
100 uint32_t flow_ip[4]; /* Flow IP address */
101 uint32_t flow_ident; /* Flow ident (e.g. port) */
102 uint32_t return_ip[4]; /* Return IP address */
103 uint32_t return_ident; /* Return ident (e.g. port) */
104 uint8_t protocol; /* Protocol number */
105 uint8_t reserved[3]; /* Padded for alignment */
106};
107
108/*
109 * Connection create structure
110 */
111struct nss_ipv6_connection_rule {
112 uint16_t flow_mac[3]; /* Flow MAC address */
113 uint16_t return_mac[3]; /* Return MAC address */
114 int32_t flow_interface_num; /* Flow interface number */
115 int32_t return_interface_num; /* Return interface number */
116 uint32_t flow_mtu; /* Flow interface`s MTU */
117 uint32_t return_mtu; /* Return interface`s MTU */
118};
119
120/*
121 * PPPoE connection rules structure
122 */
123struct nss_ipv6_pppoe_rule {
124 uint16_t flow_pppoe_session_id; /* Flow direction`s PPPoE session ID. */
125 uint16_t flow_pppoe_remote_mac[3];
126 /* Flow direction`s PPPoE Server MAC address */
127 uint16_t return_pppoe_session_id;
128 /* Return direction's PPPoE session ID. */
129 uint16_t return_pppoe_remote_mac[3];
130 /* Return direction's PPPoE Server MAC address */
131};
132
133/*
134 * DSCP connection rule structure
135 */
136struct nss_ipv6_dscp_rule {
137 uint8_t dscp_itag; /* Input tag for DSCP marking */
138 uint8_t dscp_imask; /* Input mask for DSCP marking */
139 uint8_t dscp_omask; /* Output mask for DSCP marking */
140 uint8_t dscp_oval; /* Output value of DSCP marking */
141};
142
143/*
144 * Action types for VLAN
145 */
146enum nss_ipv6_vlan_types {
147 NSS_IPV6_VLAN_MATCH = 0,
148 NSS_IPV6_VLAN_ADD = 1,
149 NSS_IPV6_VLAN_REMOVE = 2,
150};
151
152/*
153 * VLAN connection rule structure
154 */
155struct nss_ipv6_vlan_rule {
156 uint8_t action; /* The type of action to perform */
157 uint8_t reserved[3]; /* Padded for alignment */
158 uint16_t ingress_vlan_tag; /* VLAN Tag for the ingress packets */
159 uint16_t egress_vlan_tag; /* VLAN Tag for egress packets */
160 uint16_t vlan_itag; /* Input tag for VLAN marking */
161 uint16_t vlan_imask; /* Input mask for VLAN marking */
162 uint16_t vlan_omask; /* Output mask for VLAN marking */
163 uint16_t vlan_oval; /* Output value of VLAN marking */
164};
165
166/*
167 * TCP connection rulr structure
168 */
169struct nss_ipv6_protocol_tcp_rule {
170 uint32_t flow_max_window; /* Flow direction's largest seen window */
171 uint32_t flow_end; /* Flow direction's largest seen sequence + segment length */
172 uint32_t flow_max_end; /* Flow direction's largest seen ack + max(1, win) */
173 uint32_t return_max_window; /* Return direction's largest seen window */
174 uint32_t return_end; /* Return direction's largest seen sequence + segment length */
175 uint32_t return_max_end; /* Return direction's largest seen ack + max(1, win) */
176 uint8_t flow_window_scale; /* Flow direction's window scaling factor */
177 uint8_t return_window_scale; /* Return direction's window scaling factor */
178 uint16_t reserved; /* Padded for alignment */
179};
180
181/*
182 * QoS connection rule structure
183 */
184struct nss_ipv6_qos_rule {
185 uint32_t qos_tag; /* QoS tag associated with this rule */
186};
187
188/*
189 * Error types for ipv6 messages
190 */
191enum nss_ipv6_error_response_types {
192 NSS_IPV6_CR_INVALID_PNODE_ERROR = 1,
193 NSS_IPV6_CR_MISSING_CONNECTION_RULE_ERROR,
194 NSS_IPV6_CR_BUFFER_ALLOC_FAIL_ERROR,
195 NSS_IPV6_CR_PPPOE_SESSION_CREATION_ERROR,
196 NSS_IPV6_DR_NO_CONNECTION_ENTRY_ERROR,
197 NSS_IPV6_UNKNOWN_MSG_TYPE,
198};
199
200/*
201 * The IPv6 rule create sub-message structure.
202 */
203struct nss_ipv6_rule_create_msg {
204 /* Request */
205 uint16_t valid_flags; /* Bit flags associated with the validity of parameters */
206 uint16_t rule_flags; /* Bit flags associated with the rule */
207 struct nss_ipv6_5tuple tuple; /* Holds values of the 5 tuple */
208 struct nss_ipv6_connection_rule conn_rule; /* Basic connection specific data */
209 struct nss_ipv6_protocol_tcp_rule tcp_rule; /* Protocol related accleration parameters */
210 struct nss_ipv6_pppoe_rule pppoe_rule; /* PPPoE related accleration parameters */
211 struct nss_ipv6_qos_rule qos_rule; /* QoS related accleration parameters */
212 struct nss_ipv6_dscp_rule dscp_rule; /* DSCP related accleration parameters */
213 struct nss_ipv6_vlan_rule vlan_primary_rule; /* VLAN related accleration parameters */
214 struct nss_ipv6_vlan_rule vlan_secondary_rule; /* VLAN related accleration parameters */
215
216 /*
217 * Response
218 */
219 uint32_t index; /* Slot ID for cache stats to host OS */
220};
221
222/*
223 * The IPv6 rule destroy sub-message structure.
224 */
225struct nss_ipv6_rule_destroy_msg {
226 struct nss_ipv6_5tuple tuple; /* Holds values of the 5 tuple */
227};
228
229/*
230 * The NSS IPv6 rule establish structure.
231 */
232struct nss_ipv6_rule_establish {
233 uint32_t index; /* Slot ID for cache stats to host OS */
234 uint8_t protocol; /* Protocol number */
235 uint8_t reserved[3]; /* Reserved to align fields */
236 int32_t flow_interface; /* Flow interface number */
237 uint32_t flow_mtu; /* MTU for flow interface */
238 uint32_t flow_ip[4]; /* Flow IP address */
239 uint32_t flow_ident; /* Flow ident (e.g. port) */
240 uint16_t flow_mac[3]; /* Flow direction source MAC address */
241 uint16_t flow_pppoe_session_id; /* Flow direction`s PPPoE session ID. */
242 uint16_t flow_pppoe_remote_mac[3]; /* Flow direction`s PPPoE Server MAC address */
243 uint16_t ingress_vlan_tag; /* Ingress VLAN tag */
244 int32_t return_interface; /* Return interface number */
245 uint32_t return_mtu; /* MTU for return interface */
246 uint32_t return_ip[4]; /* Return IP address */
247 uint32_t return_ident; /* Return ident (e.g. port) */
248 uint16_t return_mac[3]; /* Return direction source MAC address */
249 uint16_t return_pppoe_session_id; /* Return direction's PPPoE session ID. */
250 uint16_t return_pppoe_remote_mac[3]; /* Return direction's PPPoE Server MAC address */
251 uint16_t egress_vlan_tag; /* Egress VLAN tag */
252 uint8_t flags; /* Bit flags associated with the rule */
253 uint32_t qos_tag; /* Qos Tag */
254};
255
256/*
257 * IPv6 rule sync reasons.
258 */
259#define NSS_IPV6_RULE_SYNC_REASON_STATS 0
260 /* Sync is to synchronize stats */
261#define NSS_IPV6_RULE_SYNC_REASON_FLUSH 1
262 /* Sync is to flush a cache entry */
263#define NSS_IPV6_RULE_SYNC_REASON_EVICT 2
264 /* Sync is to evict a cache entry */
265#define NSS_IPV6_RULE_SYNC_REASON_DESTROY 3
266 /* Sync is to destroy a cache entry (requested by host OS) */
267#define NSS_IPV6_RULE_SYNC_REASON_PPPOE_DESTROY 4
268 /* Sync is to destroy a cache entry which belongs to a particular PPPoE session */
269
270/*
271 * The NSS IPv6 rule sync structure.
272 */
273struct nss_ipv6_conn_sync {
274 uint32_t index; /* Slot ID for cache stats to host OS */
275 uint32_t flow_max_window; /* Flow direction's largest seen window */
276 uint32_t flow_end; /* Flow direction's largest seen sequence + segment length */
277 uint32_t flow_max_end; /* Flow direction's largest seen ack + max(1, win) */
278 uint32_t flow_rx_packet_count; /* Flow interface's RX packet count */
279 uint32_t flow_rx_byte_count; /* Flow interface's RX byte count */
280 uint32_t flow_tx_packet_count; /* Flow interface's TX packet count */
281 uint32_t flow_tx_byte_count; /* Flow interface's TX byte count */
282 uint16_t flow_pppoe_session_id; /* Flow interface`s PPPoE session ID. */
283 uint16_t flow_pppoe_remote_mac[3];
284 /* Flow interface's PPPoE remote server MAC address if there is any */
285 uint32_t return_max_window; /* Return direction's largest seen window */
286 uint32_t return_end; /* Return direction's largest seen sequence + segment length */
287 uint32_t return_max_end; /* Return direction's largest seen ack + max(1, win) */
288 uint32_t return_rx_packet_count;
289 /* Return interface's RX packet count */
290 uint32_t return_rx_byte_count; /* Return interface's RX byte count */
291 uint32_t return_tx_packet_count;
292 /* Return interface's TX packet count */
293 uint32_t return_tx_byte_count; /* Return interface's TX byte count */
294 uint16_t return_pppoe_session_id;
295 /* Return interface`s PPPoE session ID. */
296 uint16_t return_pppoe_remote_mac[3];
297 /* Return interface's PPPoE remote server MAC address if there is any */
298 uint32_t inc_ticks; /* Number of ticks since the last sync */
299 uint32_t reason; /* Reason for the sync */
300
301 uint8_t flags; /* Bit flags associated with the rule */
302 uint32_t qos_tag; /* Qos Tag */
303};
304
305/*
306 * NSS IPv6 node stats sync structure
307 */
308struct nss_ipv6_node_sync {
309 struct nss_cmn_node_stats node_stats;
310 /* Common node stats for IPv6 */
311 uint32_t ipv6_connection_create_requests;
312 /* Number of IPv6 connection create requests */
313 uint32_t ipv6_connection_create_collisions;
314 /* Number of IPv6 connection create requests that collided with existing entries */
315 uint32_t ipv6_connection_create_invalid_interface;
316 /* Number of IPv6 connection create requests that had invalid interface */
317 uint32_t ipv6_connection_destroy_requests;
318 /* Number of IPv6 connection destroy requests */
319 uint32_t ipv6_connection_destroy_misses;
320 /* Number of IPv6 connection destroy requests that missed the cache */
321 uint32_t ipv6_connection_hash_hits;
322 /* Number of IPv6 connection hash hits */
323 uint32_t ipv6_connection_hash_reorders;
324 /* Number of IPv6 connection hash reorders */
325 uint32_t ipv6_connection_flushes;
326 /* Number of IPv6 connection flushes */
327 uint32_t ipv6_connection_evictions;
328 /* Number of IPv6 connection evictions */
329 uint32_t exception_events[NSS_EXCEPTION_EVENT_IPV6_MAX];
330 /* Number of IPv6 exception events */
331};
332
333enum nss_ipv6_message_types {
334 NSS_IPV6_TX_CREATE_RULE_MSG,
335 NSS_IPV6_TX_DESTROY_RULE_MSG,
336 NSS_IPV6_RX_ESTABLISH_RULE_MSG,
337 NSS_IPV6_RX_CONN_STATS_SYNC_MSG,
338 NSS_IPV6_RX_NODE_STATS_SYNC_MSG,
339 NSS_IPV6_MAX_MSG_TYPES,
340};
341
342/*
343 * Message structure to send/receive IPv6 bridge/route commands
344 */
345struct nss_ipv6_msg {
346 struct nss_cmn_msg cm; /* Message Header */
347 union {
348 struct nss_ipv6_rule_create_msg rule_create; /* Message: rule create */
349 struct nss_ipv6_rule_destroy_msg rule_destroy; /* Message: rule destroy */
350 struct nss_ipv6_rule_establish rule_establish; /* Message: rule establish confirmation */
351 struct nss_ipv6_conn_sync conn_stats; /* Message: stats sync */
352 struct nss_ipv6_node_sync node_stats; /* Message: node stats sync */
353 } msg;
354};
355
356typedef void (*nss_ipv6_msg_callback_t)(void *app_data, struct nss_ipv6_msg *msg);
357extern nss_tx_status_t nss_ipv6_tx(struct nss_ctx_instance *nss_ctx, struct nss_ipv6_msg *msg);
358extern struct nss_ctx_instance *nss_ipv6_notify_register(nss_ipv6_msg_callback_t cb, void *app_data);
359extern void nss_ipv6_notify_unregister(void);
360extern struct nss_ctx_instance *nss_ipv6_get_mgr(void);
361extern void nss_ipv6_register_handler(void);
362#endif /* __NSS_IPV6_H */