blob: a029c715850da5a091232f71bec15a5cc16534d0 [file] [log] [blame]
Xiaoping Fan0493b2d2015-08-21 19:09:38 -07001/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +05302 * sfe_api.h
3 * SFE exported function headers for SFE engine
Xiaoping Fan0493b2d2015-08-21 19:09:38 -07004 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +05305 * Copyright (c) 2015,2016, The Linux Foundation. All rights reserved.
Guduri Prathyusha647fe3e2021-11-22 19:17:51 +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 *
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070012 * 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
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053017 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070019 */
20
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053021#ifndef __SFE_API_H
22#define __SFE_API_H
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070023
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053024#define SFE_MAX_VLAN_DEPTH 2
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070025#define SFE_VLAN_ID_NOT_CONFIGURED 0xfff
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070026
27#define SFE_SPECIAL_INTERFACE_BASE 0x7f00
28#define SFE_SPECIAL_INTERFACE_IPV4 (SFE_SPECIAL_INTERFACE_BASE + 1)
29#define SFE_SPECIAL_INTERFACE_IPV6 (SFE_SPECIAL_INTERFACE_BASE + 2)
30#define SFE_SPECIAL_INTERFACE_IPSEC (SFE_SPECIAL_INTERFACE_BASE + 3)
Xiaoping Fan67539612015-12-22 16:20:28 -080031#define SFE_SPECIAL_INTERFACE_L2TP (SFE_SPECIAL_INTERFACE_BASE + 4)
32#define SFE_SPECIAL_INTERFACE_PPTP (SFE_SPECIAL_INTERFACE_BASE + 5)
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070033
34/**
35 * Rule creation & rule update flags.
36 */
37#define SFE_RULE_CREATE_FLAG_NO_SEQ_CHECK (1<<0) /**< Do not perform TCP sequence number checks */
38#define SFE_RULE_CREATE_FLAG_BRIDGE_FLOW (1<<1) /**< This is a pure bridge forwarding flow */
39#define SFE_RULE_CREATE_FLAG_ROUTED (1<<2) /**< Rule is for a routed connection */
40#define SFE_RULE_CREATE_FLAG_DSCP_MARKING (1<<3) /**< Rule has for a DSCP marking configured*/
41#define SFE_RULE_CREATE_FLAG_VLAN_MARKING (1<<4) /**< Rule has for a VLAN marking configured*/
42#define SFE_RULE_UPDATE_FLAG_CHANGE_MTU (1<<5) /**< Update MTU of connection interfaces */
43#define SFE_RULE_CREATE_FLAG_ICMP_NO_CME_FLUSH (1<<6)/**< Rule for not flushing CME on ICMP pkt */
44#define SFE_RULE_CREATE_FLAG_L2_ENCAP (1<<7) /**< consists of an encapsulating protocol that carries an IPv4 payload within it. */
Suruchi Sumanc1a4a612021-10-21 14:50:23 +053045#define SFE_RULE_CREATE_FLAG_USE_FLOW_BOTTOM_INTERFACE (1<<8) /**< Use flow interface number instead of top interface. */
46#define SFE_RULE_CREATE_FLAG_USE_RETURN_BOTTOM_INTERFACE (1<<9) /**< Use return interface number instead of top interface. */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053047
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070048/**
49 * Rule creation validity flags.
50 */
51#define SFE_RULE_CREATE_CONN_VALID (1<<0) /**< IPv4 Connection is valid */
52#define SFE_RULE_CREATE_TCP_VALID (1<<1) /**< TCP Protocol fields are valid */
Guduri Prathyusha647fe3e2021-11-22 19:17:51 +053053#define SFE_RULE_CREATE_PPPOE_DECAP_VALID (1<<2) /**< PPPoE Decap fields are valid */
54#define SFE_RULE_CREATE_PPPOE_ENCAP_VALID (1<<3) /**< PPPoE Encap fields are valid */
Guduri Prathyushaeb31c902021-11-10 20:18:50 +053055#define SFE_RULE_CREATE_QOS_VALID (1<<4) /**< QoS fields are valid */
56#define SFE_RULE_CREATE_VLAN_VALID (1<<5) /**< VLAN fields are valid */
57#define SFE_RULE_CREATE_DSCP_MARKING_VALID (1<<6) /**< DSCP marking fields are valid */
58#define SFE_RULE_CREATE_VLAN_MARKING_VALID (1<<7) /**< VLAN marking fields are valid */
59#define SFE_RULE_CREATE_DIRECTION_VALID (1<<8) /**< specify acceleration directions */
60#define SFE_RULE_CREATE_SRC_MAC_VALID (1<<9) /**< Source MAC valid */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +053061
62/*
63 * Source MAC address valid flags (to be used with mac_valid_flags field of sfe_ipv4_src_mac_rule structure)
64 */
65#define SFE_SRC_MAC_FLOW_VALID 0x01
66 /**< MAC address for the flow interface is valid. */
67#define SFE_SRC_MAC_RETURN_VALID 0x02
68 /**< MAC address for the return interface is valid. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070069
Murat Sezginaffcf9e2020-09-18 13:16:45 -070070/*
71 * 32/64 bits pointer type
72 */
73#ifdef __LP64__
74typedef uint64_t sfe_ptr_t;
75#else
76typedef uint32_t sfe_ptr_t;
77#endif
78
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070079typedef enum sfe_rule_sync_reason {
Xiaoping Fan1253cd02015-11-11 18:02:20 -080080 SFE_RULE_SYNC_REASON_STATS, /* Sync is to synchronize stats */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070081 SFE_RULE_SYNC_REASON_FLUSH, /* Sync is to flush a entry */
82 SFE_RULE_SYNC_REASON_EVICT, /* Sync is to evict a entry */
Xiaoping Fan1253cd02015-11-11 18:02:20 -080083 SFE_RULE_SYNC_REASON_DESTROY /* Sync is to destroy a entry(requested by connection manager) */
84
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070085} sfe_rule_sync_reason_t;
86
87/**
88 * Tx command status
89 */
90typedef enum {
91 SFE_TX_SUCCESS = 0, /**< Success */
92 SFE_TX_FAILURE, /**< Command failure other than descriptor not available */
93 SFE_TX_FAILURE_QUEUE, /**< Command failure due to descriptor not available */
94 SFE_TX_FAILURE_NOT_READY, /**< Command failure due to SFE state uninitialized */
95 SFE_TX_FAILURE_TOO_LARGE, /**< Command is too large to fit in one message */
96 SFE_TX_FAILURE_TOO_SHORT, /**< Command/Packet is shorter than expected size */
97 SFE_TX_FAILURE_NOT_SUPPORTED, /**< Command/Packet not accepted for forwarding */
98 SFE_TX_FAILURE_BAD_PARAM, /**< Command failure due to bad parameters */
99 SFE_TX_FAILURE_NOT_ENABLED, /**< Command failure due to SFE feature is not enabled */
100} sfe_tx_status_t;
101
102/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530103 * Common response types.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700104 */
105enum sfe_cmn_response {
106 SFE_CMN_RESPONSE_ACK, /**< Message Acknowledge */
107 SFE_CMN_RESPONSE_EVERSION, /**< Message Version Error */
108 SFE_CMN_RESPONSE_EINTERFACE, /**< Message Interface Error */
109 SFE_CMN_RESPONSE_ELENGTH, /**< Message Length Error */
110 SFE_CMN_RESPONSE_EMSG, /**< Message Error */
111 SFE_CMM_RESPONSE_NOTIFY, /**< Message Independant of Request */
112 SFE_CMN_RESPONSE_LAST
113};
114
115/**
116 * IPv4 bridge/route rule messages
117 */
118enum sfe_message_types {
119 SFE_TX_CREATE_RULE_MSG, /**< IPv4/6 create rule message */
120 SFE_TX_DESTROY_RULE_MSG, /**< IPv4/6 destroy rule message */
121 SFE_RX_CONN_STATS_SYNC_MSG, /**< IPv4/6 connection stats sync message */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700122 SFE_TUN6RD_ADD_UPDATE_PEER, /**< Add/update peer for 6rd tunnel */
123 SFE_MAX_MSG_TYPES, /**< IPv4/6 message max type number */
124};
125
126/**
127 * Common message structure
128 */
129struct sfe_cmn_msg {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700130 u16 version; /**< Version id for main message format */
131 u16 interface; /**< Primary Key for all messages */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700132 enum sfe_cmn_response response; /**< Primary response */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700133 u32 type; /**< Decetralized request #, to be used to match response # */
134 u32 error; /**< Decentralized specific error message, response == EMSG */
Murat Sezginaffcf9e2020-09-18 13:16:45 -0700135 sfe_ptr_t cb; /**< Place for callback pointer */
136 sfe_ptr_t app_data; /**< Place for app data */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700137 u32 len; /**< What is the length of the message excluding this header */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700138};
139
140/**
141 * Common 5 tuple structure
142 */
143struct sfe_ipv4_5tuple {
144 __be32 flow_ip; /**< Flow IP address */
145 __be32 return_ip; /**< Return IP address */
146 __be16 flow_ident; /**< Flow ident (e.g. TCP/UDP port) */
147 __be16 return_ident; /**< Return ident (e.g. TCP/UDP port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700148 u8 protocol; /**< Protocol number */
149 u8 reserved[3]; /**< Padded for alignment */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700150};
151
152/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530153 * IPv4 connection rule structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700154 */
155struct sfe_ipv4_connection_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700156 u8 flow_mac[6]; /**< Flow MAC address */
157 u8 return_mac[6]; /**< Return MAC address */
158 s32 flow_interface_num; /**< Flow interface number */
159 s32 return_interface_num; /**< Return interface number */
160 s32 flow_top_interface_num; /* Top flow interface number */
161 s32 return_top_interface_num;/* Top return interface number */
162 u32 flow_mtu; /**< Flow interface`s MTU */
163 u32 return_mtu; /**< Return interface`s MTU */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700164 __be32 flow_ip_xlate; /**< Translated flow IP address */
165 __be32 return_ip_xlate; /**< Translated return IP address */
166 __be16 flow_ident_xlate; /**< Translated flow ident (e.g. port) */
167 __be16 return_ident_xlate; /**< Translated return ident (e.g. port) */
168};
169
170/**
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700171 * TCP connection rule structure
172 */
173struct sfe_protocol_tcp_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700174 u32 flow_max_window; /**< Flow direction's largest seen window */
175 u32 return_max_window; /**< Return direction's largest seen window */
176 u32 flow_end; /**< Flow direction's largest seen sequence + segment length */
177 u32 return_end; /**< Return direction's largest seen sequence + segment length */
178 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */
179 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */
180 u8 flow_window_scale; /**< Flow direction's window scaling factor */
181 u8 return_window_scale; /**< Return direction's window scaling factor */
182 u16 reserved; /**< Padded for alignment */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700183};
184
185/**
186 * PPPoE connection rules structure
187 */
188struct sfe_pppoe_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700189 u16 flow_pppoe_session_id; /**< Flow direction`s PPPoE session ID. */
Guduri Prathyushaeb31c902021-11-10 20:18:50 +0530190 u8 flow_pppoe_remote_mac[ETH_ALEN]; /**< Flow direction`s PPPoE Server MAC address */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700191 u16 return_pppoe_session_id; /**< Return direction's PPPoE session ID. */
Guduri Prathyushaeb31c902021-11-10 20:18:50 +0530192 u8 return_pppoe_remote_mac[ETH_ALEN]; /**< Return direction's PPPoE Server MAC address */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700193};
194
Suruchi Sumanc1a4a612021-10-21 14:50:23 +0530195/**
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530196 * sfe_src_mac_rule
197 * Information for source MAC address rules.
198 */
199struct sfe_src_mac_rule {
200 uint32_t mac_valid_flags; /**< MAC address validity flags. */
201 uint16_t flow_src_mac[3]; /**< Source MAC address for the flow direction. */
202 uint16_t return_src_mac[3]; /**< Source MAC address for the return direction. */
203};
204
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700205/**
206 * QoS connection rule structure
207 */
208struct sfe_qos_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700209 u32 flow_qos_tag; /**< QoS tag associated with this rule for flow direction */
210 u32 return_qos_tag; /**< QoS tag associated with this rule for return direction */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700211};
212
213/**
214 * DSCP connection rule structure
215 */
216struct sfe_dscp_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700217 u8 flow_dscp; /**< Egress DSCP value for flow direction */
218 u8 return_dscp; /**< Egress DSCP value for return direction */
219 u8 reserved[2]; /**< Padded for alignment */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700220};
221
222/**
223 * VLAN connection rule structure
224 */
225struct sfe_vlan_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700226 u32 ingress_vlan_tag; /**< VLAN Tag for the ingress packets */
227 u32 egress_vlan_tag; /**< VLAN Tag for egress packets */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700228};
229
230/**
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700231 * Acceleration direction rule structure
232 * Sometimes we just want to accelerate traffic in one direction but not in another.
233 */
234struct sfe_acceleration_direction_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700235 u8 flow_accel; /**< Accelerate in flow direction */
236 u8 return_accel; /**< Accelerate in return direction */
237 u8 reserved[2]; /**< Padded for alignment */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700238};
239
240/**
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700241 * The IPv4 rule create sub-message structure.
242 */
243struct sfe_ipv4_rule_create_msg {
244 /* Request */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700245 u16 valid_flags; /**< Bit flags associated with the validity of parameters */
246 u16 rule_flags; /**< Bit flags associated with the rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700247
248 struct sfe_ipv4_5tuple tuple; /**< Holds values of the 5 tuple */
249
250 struct sfe_ipv4_connection_rule conn_rule; /**< Basic connection specific data */
251 struct sfe_protocol_tcp_rule tcp_rule; /**< TCP related accleration parameters */
252 struct sfe_pppoe_rule pppoe_rule; /**< PPPoE related accleration parameters */
253 struct sfe_qos_rule qos_rule; /**< QoS related accleration parameters */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530254 struct sfe_src_mac_rule src_mac_rule; /**< Src Mac rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700255 struct sfe_dscp_rule dscp_rule; /**< DSCP related accleration parameters */
256 struct sfe_vlan_rule vlan_primary_rule; /**< Primary VLAN related accleration parameters */
257 struct sfe_vlan_rule vlan_secondary_rule; /**< Secondary VLAN related accleration parameters */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700258#ifdef CONFIG_XFRM
259 struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/
260#endif
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700261 /* Response */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700262 u32 index; /**< Slot ID for cache stats to host OS */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700263};
264
265/**
266 * The IPv4 rule destroy sub-message structure.
267 */
268struct sfe_ipv4_rule_destroy_msg {
269 struct sfe_ipv4_5tuple tuple; /**< Holds values of the 5 tuple */
270};
271
272/**
273 * The SFE IPv4 rule sync structure.
274 */
275struct sfe_ipv4_conn_sync {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700276 u32 index; /**< Slot ID for cache stats to host OS */
277 u8 protocol; /**< Protocol number */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700278 __be32 flow_ip; /**< Flow IP address */
279 __be32 flow_ip_xlate; /**< Translated flow IP address */
280 __be16 flow_ident; /**< Flow ident (e.g. port) */
281 __be16 flow_ident_xlate; /**< Translated flow ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700282 u32 flow_max_window; /**< Flow direction's largest seen window */
283 u32 flow_end; /**< Flow direction's largest seen sequence + segment length */
284 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */
285 u32 flow_rx_packet_count; /**< Flow interface's RX packet count */
286 u32 flow_rx_byte_count; /**< Flow interface's RX byte count */
287 u32 flow_tx_packet_count; /**< Flow interface's TX packet count */
288 u32 flow_tx_byte_count; /**< Flow interface's TX byte count */
289 u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */
290 u16 flow_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700291 /**< Flow interface's PPPoE remote server MAC address if there is any */
292 __be32 return_ip; /**< Return IP address */
293 __be32 return_ip_xlate; /**< Translated return IP address */
294 __be16 return_ident; /**< Return ident (e.g. port) */
295 __be16 return_ident_xlate; /**< Translated return ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700296 u32 return_max_window; /**< Return direction's largest seen window */
297 u32 return_end; /**< Return direction's largest seen sequence + segment length */
298 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */
299 u32 return_rx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700300 /**< Return interface's RX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700301 u32 return_rx_byte_count; /**< Return interface's RX byte count */
302 u32 return_tx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700303 /**< Return interface's TX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700304 u32 return_tx_byte_count; /**< Return interface's TX byte count */
305 u16 return_pppoe_session_id;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700306 /**< Return interface`s PPPoE session ID. */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700307 u16 return_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700308 /**< Return interface's PPPoE remote server MAC address if there is any */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700309 u32 inc_ticks; /**< Number of ticks since the last sync */
310 u32 reason; /**< Reason for the sync */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700311
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700312 u8 flags; /**< Bit flags associated with the rule */
313 u32 qos_tag; /**< QoS Tag */
314 u32 cause; /**< Flush Cause */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700315};
316
317/*
318 * Message structure to send/receive IPv4 bridge/route commands
319 */
320struct sfe_ipv4_msg {
321 struct sfe_cmn_msg cm; /**< Message Header */
322 union {
323 struct sfe_ipv4_rule_create_msg rule_create; /**< Message: rule create */
324 struct sfe_ipv4_rule_destroy_msg rule_destroy; /**< Message: rule destroy */
325 struct sfe_ipv4_conn_sync conn_stats; /**< Message: connection stats sync */
326 } msg;
327};
328
329/**
330 * Callback to be called when IPv4 message is received
331 */
332typedef void (*sfe_ipv4_msg_callback_t)(void *app_data, struct sfe_ipv4_msg *msg);
333
334/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530335 * IPv6 5-tuple structure.
336 */
337struct sfe_ipv6_5tuple {
338 __be32 flow_ip[4]; /**< Flow IP address */
339 __be32 return_ip[4]; /**< Return IP address */
340 __be16 flow_ident; /**< Flow ident (e.g. TCP/UDP port) */
341 __be16 return_ident; /**< Return ident (e.g. TCP/UDP port) */
342 u8 protocol; /**< Protocol number */
343 u8 reserved[3]; /**< Padded for alignment */
344};
345
346/**
347 * IPv6 connection rule structure.
348 */
349struct sfe_ipv6_connection_rule {
350 u8 flow_mac[6]; /**< Flow MAC address */
351 u8 return_mac[6]; /**< Return MAC address */
352 s32 flow_interface_num; /**< Flow interface number */
353 s32 return_interface_num; /**< Return interface number */
354 s32 flow_top_interface_num; /* Top flow interface number */
355 s32 return_top_interface_num;/* Top return interface number */
356 u32 flow_mtu; /**< Flow interface's MTU */
357 u32 return_mtu; /**< Return interface's MTU */
358};
359
360/**
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700361 * The IPv6 rule create sub-message structure.
362 */
363struct sfe_ipv6_rule_create_msg {
364 /*
365 * Request
366 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700367 u16 valid_flags; /**< Bit flags associated with the validity of parameters */
368 u16 rule_flags; /**< Bit flags associated with the rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700369 struct sfe_ipv6_5tuple tuple; /**< Holds values of the 5 tuple */
370 struct sfe_ipv6_connection_rule conn_rule; /**< Basic connection specific data */
371 struct sfe_protocol_tcp_rule tcp_rule; /**< Protocol related accleration parameters */
372 struct sfe_pppoe_rule pppoe_rule; /**< PPPoE related accleration parameters */
373 struct sfe_qos_rule qos_rule; /**< QoS related accleration parameters */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530374 struct sfe_src_mac_rule src_mac_rule; /**< Src Mac rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700375 struct sfe_dscp_rule dscp_rule; /**< DSCP related accleration parameters */
376 struct sfe_vlan_rule vlan_primary_rule; /**< VLAN related accleration parameters */
377 struct sfe_vlan_rule vlan_secondary_rule; /**< VLAN related accleration parameters */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700378#ifdef CONFIG_XFRM
379 struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/
380#endif
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700381 /*
382 * Response
383 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700384 u32 index; /**< Slot ID for cache stats to host OS */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700385};
386
387/**
388 * The IPv6 rule destroy sub-message structure.
389 */
390struct sfe_ipv6_rule_destroy_msg {
391 struct sfe_ipv6_5tuple tuple; /**< Holds values of the 5 tuple */
392};
393
394/**
395 * The SFE IPv6 rule sync structure.
396 */
397struct sfe_ipv6_conn_sync {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700398 u32 index; /**< Slot ID for cache stats to host OS */
399 u8 protocol; /**< Protocol number */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700400 __be32 flow_ip[4]; /**< Flow IP address */
401 __be16 flow_ident; /**< Flow ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700402 u32 flow_max_window; /**< Flow direction's largest seen window */
403 u32 flow_end; /**< Flow direction's largest seen sequence + segment length */
404 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */
405 u32 flow_rx_packet_count; /**< Flow interface's RX packet count */
406 u32 flow_rx_byte_count; /**< Flow interface's RX byte count */
407 u32 flow_tx_packet_count; /**< Flow interface's TX packet count */
408 u32 flow_tx_byte_count; /**< Flow interface's TX byte count */
409 u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */
410 u16 flow_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700411 /**< Flow interface's PPPoE remote server MAC address if there is any */
412 __be32 return_ip[4]; /**< Return IP address */
413 __be16 return_ident; /**< Return ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700414 u32 return_max_window; /**< Return direction's largest seen window */
415 u32 return_end; /**< Return direction's largest seen sequence + segment length */
416 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */
417 u32 return_rx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700418 /**< Return interface's RX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700419 u32 return_rx_byte_count; /**< Return interface's RX byte count */
420 u32 return_tx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700421 /**< Return interface's TX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700422 u32 return_tx_byte_count; /**< Return interface's TX byte count */
423 u16 return_pppoe_session_id;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700424 /**< Return interface`s PPPoE session ID. */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700425 u16 return_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700426 /**< Return interface's PPPoE remote server MAC address if there is any */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700427 u32 inc_ticks; /**< Number of ticks since the last sync */
428 u32 reason; /**< Reason for the sync */
429 u8 flags; /**< Bit flags associated with the rule */
430 u32 qos_tag; /**< QoS Tag */
431 u32 cause; /**< Flush cause associated with the rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700432};
433
434/**
435 * Message structure to send/receive IPv6 bridge/route commands
436 */
437struct sfe_ipv6_msg {
438 struct sfe_cmn_msg cm; /**< Message Header */
439 union {
440 struct sfe_ipv6_rule_create_msg rule_create; /**< Message: rule create */
441 struct sfe_ipv6_rule_destroy_msg rule_destroy; /**< Message: rule destroy */
442 struct sfe_ipv6_conn_sync conn_stats; /**< Message: stats sync */
443 } msg;
444};
445
446/**
447 * Callback to be called when IPv6 message is received
448 */
449typedef void (*sfe_ipv6_msg_callback_t)(void *app_data, struct sfe_ipv6_msg *msg);
450
451/**
452 * 6rd tunnel peer addr.
453 */
454struct sfe_tun6rd_set_peer_msg {
455 __be32 ipv6_address[4]; /* The peer's ipv6 addr*/
456 __be32 dest; /* The peer's ipv4 addr*/
457};
458
459/**
460 * Message structure to send/receive 6rd tunnel messages
461 */
462struct sfe_tun6rd_msg {
463 struct sfe_cmn_msg cm; /* Message Header */
464 union {
465 struct sfe_tun6rd_set_peer_msg peer; /* Message: add/update peer */
466 } msg;
467};
468
469/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530470 * SFE context instance.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700471 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530472struct sfe_ctx_instance {
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700473 int not_used;
474};
475
476/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530477 * sfe_ipv4_max_conn_count()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700478 * Return the maximum number of IPv4 connections that the sfe acceleration engine supports
479 *
480 * @return int The number of connections that can be accelerated by the sfe
481 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530482int sfe_ipv4_max_conn_count(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700483
484/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530485 * sfe_ipv4_tx()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700486 * Transmit an IPv4 message to the sfe
487 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530488 * @param sfe_ctx SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700489 * @param msg The IPv4 message
490 *
491 * @return sfe_tx_status_t The status of the Tx operation
492 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530493extern sfe_tx_status_t sfe_ipv4_tx(struct sfe_ctx_instance *sfe_ctx, struct sfe_ipv4_msg *msg);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700494
495/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530496 * sfe_ipv4_notify_register()
497 * Register a notifier callback for IPv4 messages from SFE
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700498 *
499 * @param cb The callback pointer
500 * @param app_data The application context for this message
501 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530502 * @return struct sfe_ctx_instance * The SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700503 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530504extern struct sfe_ctx_instance *sfe_ipv4_notify_register(sfe_ipv4_msg_callback_t cb, void *app_data);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700505
506/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530507 * sfe_ipv4_notify_unregister()
508 * Un-Register a notifier callback for IPv4 messages from SFE
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700509 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530510extern void sfe_ipv4_notify_unregister(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700511
512/*
513 * sfe_ipv4_msg_init()
514 * IPv4 message init
515 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700516extern void sfe_ipv4_msg_init(struct sfe_ipv4_msg *nim, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700517 sfe_ipv4_msg_callback_t cb, void *app_data);
518
519/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530520 * sfe_ipv6_max_conn_count()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700521 * Return the maximum number of IPv6 connections that the sfe acceleration engine supports
522 *
523 * @return int The number of connections that can be accelerated by the sfe
524 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530525int sfe_ipv6_max_conn_count(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700526
527/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530528 * sfe_ipv6_tx()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700529 * Transmit an IPv6 message to the sfe
530 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530531 * @param sfe_ctx SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700532 * @param msg The IPv6 message
533 *
534 * @return sfe_tx_status_t The status of the Tx operation
535 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530536extern sfe_tx_status_t sfe_ipv6_tx(struct sfe_ctx_instance *sfe_ctx, struct sfe_ipv6_msg *msg);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700537
538/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530539 * sfe_ipv6_notify_register()
540 * Register a notifier callback for IPv6 messages from SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700541 *
542 * @param cb The callback pointer
543 * @param app_data The application context for this message
544 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530545 * @return struct sfe_ctx_instance * The SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700546 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530547extern struct sfe_ctx_instance *sfe_ipv6_notify_register(sfe_ipv6_msg_callback_t cb, void *app_data);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700548
549/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530550 * sfe_ipv6_notify_unregister()
551 * Un-Register a notifier callback for IPv6 messages from SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700552 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530553extern void sfe_ipv6_notify_unregister(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700554
555/*
556 * sfe_ipv6_msg_init()
557 * IPv6 message init
558 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700559extern void sfe_ipv6_msg_init(struct sfe_ipv6_msg *nim, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700560 sfe_ipv6_msg_callback_t cb, void *app_data);
561
562/*
563 * sfe_tun6rd_tx()
564 * Transmit a tun6rd message to sfe engine
565 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530566sfe_tx_status_t sfe_tun6rd_tx(struct sfe_ctx_instance *sfe_ctx, struct sfe_tun6rd_msg *msg);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700567
568/*
569 * sfe_tun6rd_msg_init()
570 * Initialize sfe_tun6rd msg.
571 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700572void sfe_tun6rd_msg_init(struct sfe_tun6rd_msg *ncm, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700573 void *cb, void *app_data);
574
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530575#endif /* __SFE_API_H */