blob: 92c590f127252f9f0bba40c6c756fbb39193557a [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.
6 * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
7 *
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 */
53#define SFE_RULE_CREATE_PPPOE_VALID (1<<2) /**< PPPoE fields are valid */
54#define SFE_RULE_CREATE_QOS_VALID (1<<3) /**< QoS fields are valid */
55#define SFE_RULE_CREATE_VLAN_VALID (1<<4) /**< VLAN fields are valid */
56#define SFE_RULE_CREATE_DSCP_MARKING_VALID (1<<5) /**< DSCP marking fields are valid */
57#define SFE_RULE_CREATE_VLAN_MARKING_VALID (1<<6) /**< VLAN marking fields are valid */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053058#define SFE_RULE_CREATE_DIRECTION_VALID (1<<7) /**< specify acceleration directions */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +053059#define SFE_RULE_CREATE_SRC_MAC_VALID (1<<8) /**< Source MAC valid */
60
61/*
62 * Source MAC address valid flags (to be used with mac_valid_flags field of sfe_ipv4_src_mac_rule structure)
63 */
64#define SFE_SRC_MAC_FLOW_VALID 0x01
65 /**< MAC address for the flow interface is valid. */
66#define SFE_SRC_MAC_RETURN_VALID 0x02
67 /**< MAC address for the return interface is valid. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070068
Murat Sezginaffcf9e2020-09-18 13:16:45 -070069/*
70 * 32/64 bits pointer type
71 */
72#ifdef __LP64__
73typedef uint64_t sfe_ptr_t;
74#else
75typedef uint32_t sfe_ptr_t;
76#endif
77
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070078typedef enum sfe_rule_sync_reason {
Xiaoping Fan1253cd02015-11-11 18:02:20 -080079 SFE_RULE_SYNC_REASON_STATS, /* Sync is to synchronize stats */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070080 SFE_RULE_SYNC_REASON_FLUSH, /* Sync is to flush a entry */
81 SFE_RULE_SYNC_REASON_EVICT, /* Sync is to evict a entry */
Xiaoping Fan1253cd02015-11-11 18:02:20 -080082 SFE_RULE_SYNC_REASON_DESTROY /* Sync is to destroy a entry(requested by connection manager) */
83
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070084} sfe_rule_sync_reason_t;
85
86/**
87 * Tx command status
88 */
89typedef enum {
90 SFE_TX_SUCCESS = 0, /**< Success */
91 SFE_TX_FAILURE, /**< Command failure other than descriptor not available */
92 SFE_TX_FAILURE_QUEUE, /**< Command failure due to descriptor not available */
93 SFE_TX_FAILURE_NOT_READY, /**< Command failure due to SFE state uninitialized */
94 SFE_TX_FAILURE_TOO_LARGE, /**< Command is too large to fit in one message */
95 SFE_TX_FAILURE_TOO_SHORT, /**< Command/Packet is shorter than expected size */
96 SFE_TX_FAILURE_NOT_SUPPORTED, /**< Command/Packet not accepted for forwarding */
97 SFE_TX_FAILURE_BAD_PARAM, /**< Command failure due to bad parameters */
98 SFE_TX_FAILURE_NOT_ENABLED, /**< Command failure due to SFE feature is not enabled */
99} sfe_tx_status_t;
100
101/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530102 * Common response types.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700103 */
104enum sfe_cmn_response {
105 SFE_CMN_RESPONSE_ACK, /**< Message Acknowledge */
106 SFE_CMN_RESPONSE_EVERSION, /**< Message Version Error */
107 SFE_CMN_RESPONSE_EINTERFACE, /**< Message Interface Error */
108 SFE_CMN_RESPONSE_ELENGTH, /**< Message Length Error */
109 SFE_CMN_RESPONSE_EMSG, /**< Message Error */
110 SFE_CMM_RESPONSE_NOTIFY, /**< Message Independant of Request */
111 SFE_CMN_RESPONSE_LAST
112};
113
114/**
115 * IPv4 bridge/route rule messages
116 */
117enum sfe_message_types {
118 SFE_TX_CREATE_RULE_MSG, /**< IPv4/6 create rule message */
119 SFE_TX_DESTROY_RULE_MSG, /**< IPv4/6 destroy rule message */
120 SFE_RX_CONN_STATS_SYNC_MSG, /**< IPv4/6 connection stats sync message */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700121 SFE_TUN6RD_ADD_UPDATE_PEER, /**< Add/update peer for 6rd tunnel */
122 SFE_MAX_MSG_TYPES, /**< IPv4/6 message max type number */
123};
124
125/**
126 * Common message structure
127 */
128struct sfe_cmn_msg {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700129 u16 version; /**< Version id for main message format */
130 u16 interface; /**< Primary Key for all messages */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700131 enum sfe_cmn_response response; /**< Primary response */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700132 u32 type; /**< Decetralized request #, to be used to match response # */
133 u32 error; /**< Decentralized specific error message, response == EMSG */
Murat Sezginaffcf9e2020-09-18 13:16:45 -0700134 sfe_ptr_t cb; /**< Place for callback pointer */
135 sfe_ptr_t app_data; /**< Place for app data */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700136 u32 len; /**< What is the length of the message excluding this header */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700137};
138
139/**
140 * Common 5 tuple structure
141 */
142struct sfe_ipv4_5tuple {
143 __be32 flow_ip; /**< Flow IP address */
144 __be32 return_ip; /**< Return IP address */
145 __be16 flow_ident; /**< Flow ident (e.g. TCP/UDP port) */
146 __be16 return_ident; /**< Return ident (e.g. TCP/UDP port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700147 u8 protocol; /**< Protocol number */
148 u8 reserved[3]; /**< Padded for alignment */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700149};
150
151/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530152 * IPv4 connection rule structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700153 */
154struct sfe_ipv4_connection_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700155 u8 flow_mac[6]; /**< Flow MAC address */
156 u8 return_mac[6]; /**< Return MAC address */
157 s32 flow_interface_num; /**< Flow interface number */
158 s32 return_interface_num; /**< Return interface number */
159 s32 flow_top_interface_num; /* Top flow interface number */
160 s32 return_top_interface_num;/* Top return interface number */
161 u32 flow_mtu; /**< Flow interface`s MTU */
162 u32 return_mtu; /**< Return interface`s MTU */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700163 __be32 flow_ip_xlate; /**< Translated flow IP address */
164 __be32 return_ip_xlate; /**< Translated return IP address */
165 __be16 flow_ident_xlate; /**< Translated flow ident (e.g. port) */
166 __be16 return_ident_xlate; /**< Translated return ident (e.g. port) */
167};
168
169/**
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700170 * TCP connection rule structure
171 */
172struct sfe_protocol_tcp_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700173 u32 flow_max_window; /**< Flow direction's largest seen window */
174 u32 return_max_window; /**< Return direction's largest seen window */
175 u32 flow_end; /**< Flow direction's largest seen sequence + segment length */
176 u32 return_end; /**< Return direction's largest seen sequence + segment length */
177 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */
178 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */
179 u8 flow_window_scale; /**< Flow direction's window scaling factor */
180 u8 return_window_scale; /**< Return direction's window scaling factor */
181 u16 reserved; /**< Padded for alignment */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700182};
183
184/**
185 * PPPoE connection rules structure
186 */
187struct sfe_pppoe_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700188 u16 flow_pppoe_session_id; /**< Flow direction`s PPPoE session ID. */
189 u16 flow_pppoe_remote_mac[3]; /**< Flow direction`s PPPoE Server MAC address */
190 u16 return_pppoe_session_id; /**< Return direction's PPPoE session ID. */
191 u16 return_pppoe_remote_mac[3]; /**< Return direction's PPPoE Server MAC address */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700192};
193
Suruchi Sumanc1a4a612021-10-21 14:50:23 +0530194/**
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530195 * sfe_src_mac_rule
196 * Information for source MAC address rules.
197 */
198struct sfe_src_mac_rule {
199 uint32_t mac_valid_flags; /**< MAC address validity flags. */
200 uint16_t flow_src_mac[3]; /**< Source MAC address for the flow direction. */
201 uint16_t return_src_mac[3]; /**< Source MAC address for the return direction. */
202};
203
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700204/**
205 * QoS connection rule structure
206 */
207struct sfe_qos_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700208 u32 flow_qos_tag; /**< QoS tag associated with this rule for flow direction */
209 u32 return_qos_tag; /**< QoS tag associated with this rule for return direction */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700210};
211
212/**
213 * DSCP connection rule structure
214 */
215struct sfe_dscp_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700216 u8 flow_dscp; /**< Egress DSCP value for flow direction */
217 u8 return_dscp; /**< Egress DSCP value for return direction */
218 u8 reserved[2]; /**< Padded for alignment */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700219};
220
221/**
222 * VLAN connection rule structure
223 */
224struct sfe_vlan_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700225 u32 ingress_vlan_tag; /**< VLAN Tag for the ingress packets */
226 u32 egress_vlan_tag; /**< VLAN Tag for egress packets */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700227};
228
229/**
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700230 * Acceleration direction rule structure
231 * Sometimes we just want to accelerate traffic in one direction but not in another.
232 */
233struct sfe_acceleration_direction_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700234 u8 flow_accel; /**< Accelerate in flow direction */
235 u8 return_accel; /**< Accelerate in return direction */
236 u8 reserved[2]; /**< Padded for alignment */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700237};
238
239/**
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700240 * The IPv4 rule create sub-message structure.
241 */
242struct sfe_ipv4_rule_create_msg {
243 /* Request */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700244 u16 valid_flags; /**< Bit flags associated with the validity of parameters */
245 u16 rule_flags; /**< Bit flags associated with the rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700246
247 struct sfe_ipv4_5tuple tuple; /**< Holds values of the 5 tuple */
248
249 struct sfe_ipv4_connection_rule conn_rule; /**< Basic connection specific data */
250 struct sfe_protocol_tcp_rule tcp_rule; /**< TCP related accleration parameters */
251 struct sfe_pppoe_rule pppoe_rule; /**< PPPoE related accleration parameters */
252 struct sfe_qos_rule qos_rule; /**< QoS related accleration parameters */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530253 struct sfe_src_mac_rule src_mac_rule; /**< Src Mac rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700254 struct sfe_dscp_rule dscp_rule; /**< DSCP related accleration parameters */
255 struct sfe_vlan_rule vlan_primary_rule; /**< Primary VLAN related accleration parameters */
256 struct sfe_vlan_rule vlan_secondary_rule; /**< Secondary VLAN related accleration parameters */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700257#ifdef CONFIG_XFRM
258 struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/
259#endif
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700260 /* Response */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700261 u32 index; /**< Slot ID for cache stats to host OS */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700262};
263
264/**
265 * The IPv4 rule destroy sub-message structure.
266 */
267struct sfe_ipv4_rule_destroy_msg {
268 struct sfe_ipv4_5tuple tuple; /**< Holds values of the 5 tuple */
269};
270
271/**
272 * The SFE IPv4 rule sync structure.
273 */
274struct sfe_ipv4_conn_sync {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700275 u32 index; /**< Slot ID for cache stats to host OS */
276 u8 protocol; /**< Protocol number */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700277 __be32 flow_ip; /**< Flow IP address */
278 __be32 flow_ip_xlate; /**< Translated flow IP address */
279 __be16 flow_ident; /**< Flow ident (e.g. port) */
280 __be16 flow_ident_xlate; /**< Translated flow ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700281 u32 flow_max_window; /**< Flow direction's largest seen window */
282 u32 flow_end; /**< Flow direction's largest seen sequence + segment length */
283 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */
284 u32 flow_rx_packet_count; /**< Flow interface's RX packet count */
285 u32 flow_rx_byte_count; /**< Flow interface's RX byte count */
286 u32 flow_tx_packet_count; /**< Flow interface's TX packet count */
287 u32 flow_tx_byte_count; /**< Flow interface's TX byte count */
288 u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */
289 u16 flow_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700290 /**< Flow interface's PPPoE remote server MAC address if there is any */
291 __be32 return_ip; /**< Return IP address */
292 __be32 return_ip_xlate; /**< Translated return IP address */
293 __be16 return_ident; /**< Return ident (e.g. port) */
294 __be16 return_ident_xlate; /**< Translated return ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700295 u32 return_max_window; /**< Return direction's largest seen window */
296 u32 return_end; /**< Return direction's largest seen sequence + segment length */
297 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */
298 u32 return_rx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700299 /**< Return interface's RX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700300 u32 return_rx_byte_count; /**< Return interface's RX byte count */
301 u32 return_tx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700302 /**< Return interface's TX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700303 u32 return_tx_byte_count; /**< Return interface's TX byte count */
304 u16 return_pppoe_session_id;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700305 /**< Return interface`s PPPoE session ID. */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700306 u16 return_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700307 /**< Return interface's PPPoE remote server MAC address if there is any */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700308 u32 inc_ticks; /**< Number of ticks since the last sync */
309 u32 reason; /**< Reason for the sync */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700310
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700311 u8 flags; /**< Bit flags associated with the rule */
312 u32 qos_tag; /**< QoS Tag */
313 u32 cause; /**< Flush Cause */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700314};
315
316/*
317 * Message structure to send/receive IPv4 bridge/route commands
318 */
319struct sfe_ipv4_msg {
320 struct sfe_cmn_msg cm; /**< Message Header */
321 union {
322 struct sfe_ipv4_rule_create_msg rule_create; /**< Message: rule create */
323 struct sfe_ipv4_rule_destroy_msg rule_destroy; /**< Message: rule destroy */
324 struct sfe_ipv4_conn_sync conn_stats; /**< Message: connection stats sync */
325 } msg;
326};
327
328/**
329 * Callback to be called when IPv4 message is received
330 */
331typedef void (*sfe_ipv4_msg_callback_t)(void *app_data, struct sfe_ipv4_msg *msg);
332
333/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530334 * IPv6 5-tuple structure.
335 */
336struct sfe_ipv6_5tuple {
337 __be32 flow_ip[4]; /**< Flow IP address */
338 __be32 return_ip[4]; /**< Return IP address */
339 __be16 flow_ident; /**< Flow ident (e.g. TCP/UDP port) */
340 __be16 return_ident; /**< Return ident (e.g. TCP/UDP port) */
341 u8 protocol; /**< Protocol number */
342 u8 reserved[3]; /**< Padded for alignment */
343};
344
345/**
346 * IPv6 connection rule structure.
347 */
348struct sfe_ipv6_connection_rule {
349 u8 flow_mac[6]; /**< Flow MAC address */
350 u8 return_mac[6]; /**< Return MAC address */
351 s32 flow_interface_num; /**< Flow interface number */
352 s32 return_interface_num; /**< Return interface number */
353 s32 flow_top_interface_num; /* Top flow interface number */
354 s32 return_top_interface_num;/* Top return interface number */
355 u32 flow_mtu; /**< Flow interface's MTU */
356 u32 return_mtu; /**< Return interface's MTU */
357};
358
359/**
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700360 * The IPv6 rule create sub-message structure.
361 */
362struct sfe_ipv6_rule_create_msg {
363 /*
364 * Request
365 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700366 u16 valid_flags; /**< Bit flags associated with the validity of parameters */
367 u16 rule_flags; /**< Bit flags associated with the rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700368 struct sfe_ipv6_5tuple tuple; /**< Holds values of the 5 tuple */
369 struct sfe_ipv6_connection_rule conn_rule; /**< Basic connection specific data */
370 struct sfe_protocol_tcp_rule tcp_rule; /**< Protocol related accleration parameters */
371 struct sfe_pppoe_rule pppoe_rule; /**< PPPoE related accleration parameters */
372 struct sfe_qos_rule qos_rule; /**< QoS related accleration parameters */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530373 struct sfe_src_mac_rule src_mac_rule; /**< Src Mac rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700374 struct sfe_dscp_rule dscp_rule; /**< DSCP related accleration parameters */
375 struct sfe_vlan_rule vlan_primary_rule; /**< VLAN related accleration parameters */
376 struct sfe_vlan_rule vlan_secondary_rule; /**< VLAN related accleration parameters */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700377#ifdef CONFIG_XFRM
378 struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/
379#endif
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700380 /*
381 * Response
382 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700383 u32 index; /**< Slot ID for cache stats to host OS */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700384};
385
386/**
387 * The IPv6 rule destroy sub-message structure.
388 */
389struct sfe_ipv6_rule_destroy_msg {
390 struct sfe_ipv6_5tuple tuple; /**< Holds values of the 5 tuple */
391};
392
393/**
394 * The SFE IPv6 rule sync structure.
395 */
396struct sfe_ipv6_conn_sync {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700397 u32 index; /**< Slot ID for cache stats to host OS */
398 u8 protocol; /**< Protocol number */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700399 __be32 flow_ip[4]; /**< Flow IP address */
400 __be16 flow_ident; /**< Flow ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700401 u32 flow_max_window; /**< Flow direction's largest seen window */
402 u32 flow_end; /**< Flow direction's largest seen sequence + segment length */
403 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */
404 u32 flow_rx_packet_count; /**< Flow interface's RX packet count */
405 u32 flow_rx_byte_count; /**< Flow interface's RX byte count */
406 u32 flow_tx_packet_count; /**< Flow interface's TX packet count */
407 u32 flow_tx_byte_count; /**< Flow interface's TX byte count */
408 u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */
409 u16 flow_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700410 /**< Flow interface's PPPoE remote server MAC address if there is any */
411 __be32 return_ip[4]; /**< Return IP address */
412 __be16 return_ident; /**< Return ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700413 u32 return_max_window; /**< Return direction's largest seen window */
414 u32 return_end; /**< Return direction's largest seen sequence + segment length */
415 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */
416 u32 return_rx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700417 /**< Return interface's RX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700418 u32 return_rx_byte_count; /**< Return interface's RX byte count */
419 u32 return_tx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700420 /**< Return interface's TX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700421 u32 return_tx_byte_count; /**< Return interface's TX byte count */
422 u16 return_pppoe_session_id;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700423 /**< Return interface`s PPPoE session ID. */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700424 u16 return_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700425 /**< Return interface's PPPoE remote server MAC address if there is any */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700426 u32 inc_ticks; /**< Number of ticks since the last sync */
427 u32 reason; /**< Reason for the sync */
428 u8 flags; /**< Bit flags associated with the rule */
429 u32 qos_tag; /**< QoS Tag */
430 u32 cause; /**< Flush cause associated with the rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700431};
432
433/**
434 * Message structure to send/receive IPv6 bridge/route commands
435 */
436struct sfe_ipv6_msg {
437 struct sfe_cmn_msg cm; /**< Message Header */
438 union {
439 struct sfe_ipv6_rule_create_msg rule_create; /**< Message: rule create */
440 struct sfe_ipv6_rule_destroy_msg rule_destroy; /**< Message: rule destroy */
441 struct sfe_ipv6_conn_sync conn_stats; /**< Message: stats sync */
442 } msg;
443};
444
445/**
446 * Callback to be called when IPv6 message is received
447 */
448typedef void (*sfe_ipv6_msg_callback_t)(void *app_data, struct sfe_ipv6_msg *msg);
449
450/**
451 * 6rd tunnel peer addr.
452 */
453struct sfe_tun6rd_set_peer_msg {
454 __be32 ipv6_address[4]; /* The peer's ipv6 addr*/
455 __be32 dest; /* The peer's ipv4 addr*/
456};
457
458/**
459 * Message structure to send/receive 6rd tunnel messages
460 */
461struct sfe_tun6rd_msg {
462 struct sfe_cmn_msg cm; /* Message Header */
463 union {
464 struct sfe_tun6rd_set_peer_msg peer; /* Message: add/update peer */
465 } msg;
466};
467
468/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530469 * SFE context instance.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700470 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530471struct sfe_ctx_instance {
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700472 int not_used;
473};
474
475/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530476 * sfe_ipv4_max_conn_count()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700477 * Return the maximum number of IPv4 connections that the sfe acceleration engine supports
478 *
479 * @return int The number of connections that can be accelerated by the sfe
480 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530481int sfe_ipv4_max_conn_count(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700482
483/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530484 * sfe_ipv4_tx()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700485 * Transmit an IPv4 message to the sfe
486 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530487 * @param sfe_ctx SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700488 * @param msg The IPv4 message
489 *
490 * @return sfe_tx_status_t The status of the Tx operation
491 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530492extern 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 -0700493
494/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530495 * sfe_ipv4_notify_register()
496 * Register a notifier callback for IPv4 messages from SFE
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700497 *
498 * @param cb The callback pointer
499 * @param app_data The application context for this message
500 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530501 * @return struct sfe_ctx_instance * The SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700502 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530503extern struct sfe_ctx_instance *sfe_ipv4_notify_register(sfe_ipv4_msg_callback_t cb, void *app_data);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700504
505/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530506 * sfe_ipv4_notify_unregister()
507 * Un-Register a notifier callback for IPv4 messages from SFE
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700508 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530509extern void sfe_ipv4_notify_unregister(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700510
511/*
512 * sfe_ipv4_msg_init()
513 * IPv4 message init
514 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700515extern void sfe_ipv4_msg_init(struct sfe_ipv4_msg *nim, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700516 sfe_ipv4_msg_callback_t cb, void *app_data);
517
518/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530519 * sfe_ipv6_max_conn_count()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700520 * Return the maximum number of IPv6 connections that the sfe acceleration engine supports
521 *
522 * @return int The number of connections that can be accelerated by the sfe
523 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530524int sfe_ipv6_max_conn_count(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700525
526/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530527 * sfe_ipv6_tx()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700528 * Transmit an IPv6 message to the sfe
529 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530530 * @param sfe_ctx SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700531 * @param msg The IPv6 message
532 *
533 * @return sfe_tx_status_t The status of the Tx operation
534 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530535extern 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 -0700536
537/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530538 * sfe_ipv6_notify_register()
539 * Register a notifier callback for IPv6 messages from SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700540 *
541 * @param cb The callback pointer
542 * @param app_data The application context for this message
543 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530544 * @return struct sfe_ctx_instance * The SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700545 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530546extern struct sfe_ctx_instance *sfe_ipv6_notify_register(sfe_ipv6_msg_callback_t cb, void *app_data);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700547
548/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530549 * sfe_ipv6_notify_unregister()
550 * Un-Register a notifier callback for IPv6 messages from SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700551 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530552extern void sfe_ipv6_notify_unregister(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700553
554/*
555 * sfe_ipv6_msg_init()
556 * IPv6 message init
557 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700558extern void sfe_ipv6_msg_init(struct sfe_ipv6_msg *nim, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700559 sfe_ipv6_msg_callback_t cb, void *app_data);
560
561/*
562 * sfe_tun6rd_tx()
563 * Transmit a tun6rd message to sfe engine
564 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530565sfe_tx_status_t sfe_tun6rd_tx(struct sfe_ctx_instance *sfe_ctx, struct sfe_tun6rd_msg *msg);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700566
567/*
568 * sfe_tun6rd_msg_init()
569 * Initialize sfe_tun6rd msg.
570 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700571void sfe_tun6rd_msg_init(struct sfe_tun6rd_msg *ncm, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700572 void *cb, void *app_data);
573
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530574#endif /* __SFE_API_H */