blob: 50a77330c0ca956c1df97f9965dd5b3a8534ee5f [file] [log] [blame]
Xiaoping Fan0493b2d2015-08-21 19:09:38 -07001/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +05302 * sfe_api.h
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -08003 * 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 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 *
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
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -080021
22/**
23 * @file sfe_api.h
24 * SFE exported function headers for the SFE engine.
25 */
26
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053027#ifndef __SFE_API_H
28#define __SFE_API_H
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070029
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -080030/**
31 * @addtogroup nss_sfe_definitions
32 * @{
33 */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070034
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -080035#define SFE_MAX_VLAN_DEPTH 2 /**< Maximum VLAN depth. */
36#define SFE_VLAN_ID_NOT_CONFIGURED 0xfff /**< VLAN ID not configured. */
Parikshit Gune8d03e972022-06-15 17:24:53 +053037#define SFE_INVALID_VLAN_PCP 0xff /**< VLAN PCP remark is invalid for SAWF (Service Aware Wi-Fi). */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -080038#define SFE_MAX_SERVICE_CLASS_ID 0x80 /**< Maximum service class ID. */
39#define SFE_INVALID_SERVICE_CLASS_ID 0xff /**< Service class ID not valid. */
Jackson Bockus3fafbf32022-02-13 17:15:26 -080040#define SFE_SERVICE_CLASS_STATS_MAX_RETRY 100 /**< Maximum retries for fetching service class statistics. */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -080041#define SFE_INVALID_MSDUQ 0xff /**< Invalid MAC Service Data Unit Queue. */
42
43#define SFE_SPECIAL_INTERFACE_BASE 0x7f00 /**< Special interface base number. */
44#define SFE_SPECIAL_INTERFACE_IPV4 (SFE_SPECIAL_INTERFACE_BASE + 1) /**< Interface number for IPv4. */
45#define SFE_SPECIAL_INTERFACE_IPV6 (SFE_SPECIAL_INTERFACE_BASE + 2) /**< Interface enumber fo IPv6. */
46#define SFE_SPECIAL_INTERFACE_IPSEC (SFE_SPECIAL_INTERFACE_BASE + 3) /**< Interface number for IPSec. */
47#define SFE_SPECIAL_INTERFACE_L2TP (SFE_SPECIAL_INTERFACE_BASE + 4) /**< Interface number for L2TP. */
48#define SFE_SPECIAL_INTERFACE_PPTP (SFE_SPECIAL_INTERFACE_BASE + 5) /**< Interface number for PPTP. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070049
50/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -080051* @}
52*/
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053053
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070054/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -080055 * @addtogroup nss_sfe_flags
56 * @{
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070057 */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +053058
59/*
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -080060 * Rule creation and rule update flags.
61 */
62#define SFE_RULE_CREATE_FLAG_NO_SEQ_CHECK (1<<0) /**< Do not perform TCP sequence number checks. */
63#define SFE_RULE_CREATE_FLAG_BRIDGE_FLOW (1<<1) /**< Rule is for a pure bridge forwarding flow. */
64#define SFE_RULE_CREATE_FLAG_ROUTED (1<<2) /**< Rule is for a routed connection. */
65#define SFE_RULE_CREATE_FLAG_DSCP_MARKING (1<<3) /**< Rule has DSCP marking configured. */
66#define SFE_RULE_CREATE_FLAG_VLAN_MARKING (1<<4) /**< Rule has VLAN marking configured. */
67#define SFE_RULE_UPDATE_FLAG_CHANGE_MTU (1<<5) /**< Update MTU of connection interfaces. */
68#define SFE_RULE_CREATE_FLAG_ICMP_NO_CME_FLUSH (1<<6) /**< Rule to not flush CME on ICMP packets. */
69#define SFE_RULE_CREATE_FLAG_L2_ENCAP (1<<7) /**< Consists of an encapsulating protocol that carries an IPv4 payload within it. */
70#define SFE_RULE_CREATE_FLAG_USE_FLOW_BOTTOM_INTERFACE (1<<8) /**< Use flow interface number instead of top interface. */
71#define SFE_RULE_CREATE_FLAG_USE_RETURN_BOTTOM_INTERFACE (1<<9) /**< Use return interface number instead of top interface. */
Murat Sezgin9c538972022-05-17 13:33:17 -070072#define SFE_RULE_CREATE_FLAG_FLOW_SRC_INTERFACE_CHECK (1<<10) /**< Check source interface on the flow direction. */
73#define SFE_RULE_CREATE_FLAG_RETURN_SRC_INTERFACE_CHECK (1<<11)
74 /**< Check source interface on the return direction. */
75#define SFE_RULE_CREATE_FLAG_FLOW_TRANSMIT_FAST (1<<12) /**< Original flow can be transmitted fast. */
76#define SFE_RULE_CREATE_FLAG_RETURN_TRANSMIT_FAST (1<<13) /**< Return flow can be transmitted fast. */
77#define SFE_RULE_CREATE_FLAG_FLOW_SRC_INTERFACE_CHECK_NO_FLUSH (1<<14)
78 /**< Check source interface on the flow direction but do not flush the connection. */
79#define SFE_RULE_CREATE_FLAG_RETURN_SRC_INTERFACE_CHECK_NO_FLUSH (1<<15)
80 /**< Check source interface on the return direction but do not flush the connection. */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -080081
82/*
83 * Rule creation validity flags.
84 */
85#define SFE_RULE_CREATE_CONN_VALID (1<<0) /**< IPv4 connection is valid. */
86#define SFE_RULE_CREATE_TCP_VALID (1<<1) /**< TCP protocol fields are valid. */
87#define SFE_RULE_CREATE_PPPOE_DECAP_VALID (1<<2) /**< PPPoE decapsulation fields are valid. */
88#define SFE_RULE_CREATE_PPPOE_ENCAP_VALID (1<<3) /**< PPPoE encapsulation fields are valid. */
89#define SFE_RULE_CREATE_QOS_VALID (1<<4) /**< QoS fields are valid. */
90#define SFE_RULE_CREATE_VLAN_VALID (1<<5) /**< VLAN fields are valid. */
91#define SFE_RULE_CREATE_DSCP_MARKING_VALID (1<<6) /**< DSCP marking fields are valid. */
92#define SFE_RULE_CREATE_VLAN_MARKING_VALID (1<<7) /**< VLAN marking fields are valid. */
93#define SFE_RULE_CREATE_DIRECTION_VALID (1<<8) /**< Acceleration direction is valid. */
94#define SFE_RULE_CREATE_SRC_MAC_VALID (1<<9) /**< Source MAC address is valid. */
95#define SFE_RULE_CREATE_MARK_VALID (1<<10) /**< SKB marking fields are valid. */
96
97/*
98 * Source MAC address validity flags; used with the mac_valid_flags field in the sfe_ipv4_src_mac_rule structure.
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +053099 */
100#define SFE_SRC_MAC_FLOW_VALID 0x01
101 /**< MAC address for the flow interface is valid. */
102#define SFE_SRC_MAC_RETURN_VALID 0x02
103 /**< MAC address for the return interface is valid. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700104
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800105/**
106 * @}
107 */
108
109/**
110 * @addtogroup nss_sfe_datatypes
111 * @{
112 */
113
Murat Sezginaffcf9e2020-09-18 13:16:45 -0700114/*
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800115 * 32/64-bit pointer types.
Murat Sezginaffcf9e2020-09-18 13:16:45 -0700116 */
117#ifdef __LP64__
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800118typedef uint64_t sfe_ptr_t; /**< 64-bit pointer. */
Murat Sezginaffcf9e2020-09-18 13:16:45 -0700119#else
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800120typedef uint32_t sfe_ptr_t; /**< 32-bit pointer. */
Murat Sezginaffcf9e2020-09-18 13:16:45 -0700121#endif
122
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800123/**
124* Synchronize reason enum.
125*/
126typedef enum /** @cond */ sfe_rule_sync_reason /** @endcond */ {
127 SFE_RULE_SYNC_REASON_STATS, /**< Synchronize statistics. */
128 SFE_RULE_SYNC_REASON_FLUSH, /**< Synchronize to flush an entry. */
129 SFE_RULE_SYNC_REASON_EVICT, /**< Synchronize to evict an entry. */
130 SFE_RULE_SYNC_REASON_DESTROY /**< Synchronize to destroy an entry (requested by the connection manager). */
Xiaoping Fan1253cd02015-11-11 18:02:20 -0800131
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700132} sfe_rule_sync_reason_t;
133
134/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800135 * Tx command status.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700136 */
137typedef enum {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800138 SFE_TX_SUCCESS = 0, /**< Success. */
139 SFE_TX_FAILURE, /**< Failure other than descriptor not available. */
140 SFE_TX_FAILURE_QUEUE, /**< failure due to descriptor not available. */
141 SFE_TX_FAILURE_NOT_READY, /**< Failure due to SFE state uninitialized. */
142 SFE_TX_FAILURE_TOO_LARGE, /**< Command is too large to fit in one message. */
143 SFE_TX_FAILURE_TOO_SHORT, /**< Command or packet is shorter than expected. */
144 SFE_TX_FAILURE_NOT_SUPPORTED, /**< Command or packet not accepted for forwarding. */
145 SFE_TX_FAILURE_BAD_PARAM, /**< Failure due to bad parameters. */
146 SFE_TX_FAILURE_NOT_ENABLED, /**< Failure due to SFE not enabled. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700147} sfe_tx_status_t;
148
149/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530150 * Common response types.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700151 */
152enum sfe_cmn_response {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800153 SFE_CMN_RESPONSE_ACK, /**< Message acknowledged. */
154 SFE_CMN_RESPONSE_EVERSION, /**< Version error. */
155 SFE_CMN_RESPONSE_EINTERFACE, /**< Interface error. */
156 SFE_CMN_RESPONSE_ELENGTH, /**< Length error. */
157 SFE_CMN_RESPONSE_EMSG, /**< Message error. */
158 SFE_CMM_RESPONSE_NOTIFY, /**< Message independant of request. */
159 SFE_CMN_RESPONSE_LAST /**< Indicates the last item. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700160};
161
162/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800163 * IPv4 bridge/route rule messages.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700164 */
165enum sfe_message_types {
Ken Zhu7a43d882022-01-04 10:51:44 -0800166 SFE_TX_CREATE_RULE_MSG, /**< IPv4/IPv6 create rule message. */
167 SFE_TX_DESTROY_RULE_MSG, /**< IPv4/IPv6 destroy rule message. */
168 SFE_RX_CONN_STATS_SYNC_MSG, /**< IPv4/IPv6 connection statistics synchronize message. */
169 SFE_TX_CONN_STATS_SYNC_MANY_MSG,/**< IPv4/IPv6 connection statistics synchronize many message. */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800170 SFE_TUN6RD_ADD_UPDATE_PEER, /**< Add/update peer for 6RD tunnel. */
Ken Zhu7a43d882022-01-04 10:51:44 -0800171 SFE_MAX_MSG_TYPES, /**< IPv4/IPv6 message max type number. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700172};
173
174/**
Murat Sezginef190392022-04-04 17:56:31 -0700175 * Connection mark structure.
176 */
177struct sfe_connection_mark {
178 int protocol; /**< Protocol number. */
179 __be32 src_ip[4]; /**< Source IP address. */
180 __be32 dest_ip[4]; /**< Destination IP address. */
181 __be16 src_port; /**< Source port number. */
182 __be16 dest_port; /**< Destination port number. */
183 u32 mark; /**< Mark value to be updated. */
184};
185
186/**
Ken Zhu7a43d882022-01-04 10:51:44 -0800187 * Common message structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700188 */
189struct sfe_cmn_msg {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800190 u16 version; /**< Version ID for the main message format. */
191 u16 interface; /**< Primary key for all messages. */
192 enum sfe_cmn_response response; /**< Primary response. */
193 u32 type; /**< Decentralized request ID used to match response ID. */
194 u32 error; /**< Decentralized specific error message; response == EMSG. */
195 sfe_ptr_t cb; /**< Callback pointer. */
196 sfe_ptr_t app_data; /**< Application data. */
197 u32 len; /**< Length of the message excluding this header. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700198};
199
200/**
Ken Zhu7a43d882022-01-04 10:51:44 -0800201 * Common 5-tuple structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700202 */
203struct sfe_ipv4_5tuple {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800204 __be32 flow_ip; /**< Flow IP address. */
205 __be32 return_ip; /**< Return IP address. */
206 __be16 flow_ident; /**< Flow identifier, e.g., TCP/UDP port. */
207 __be16 return_ident; /**< Return identifier, e.g., TCP/UDP port. */
208 u8 protocol; /**< Protocol number. */
209 u8 reserved[3]; /**< Reserved; padding for alignment. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700210};
211
212/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530213 * IPv4 connection rule structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700214 */
215struct sfe_ipv4_connection_rule {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800216 u8 flow_mac[6]; /**< Flow MAC address. */
217 u8 return_mac[6]; /**< Return MAC address. */
218 s32 flow_interface_num; /**< Flow interface number. */
219 s32 return_interface_num; /**< Return interface number. */
220 s32 flow_top_interface_num; /**< Top flow interface number. */
221 s32 return_top_interface_num; /**< Top return interface number. */
222 u32 flow_mtu; /**< Flow interface`s MTU. */
223 u32 return_mtu; /**< Return interface`s MTU. */
224 __be32 flow_ip_xlate; /**< Translated flow IP address. */
225 __be32 return_ip_xlate; /**< Translated return IP address. */
226 __be16 flow_ident_xlate; /**< Translated flow identifier, e.g., port. */
227 __be16 return_ident_xlate; /**< Translated return identifier, e.g., port. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700228};
229
230/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800231 * TCP connection rule structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700232 */
233struct sfe_protocol_tcp_rule {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800234 u32 flow_max_window; /**< Flow direction's largest seen window. */
235 u32 return_max_window; /**< Return direction's largest seen window. */
236 u32 flow_end; /**< Flow direction's largest seen sequence + segment length. */
237 u32 return_end; /**< Return direction's largest seen sequence + segment length. */
238 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win). */
239 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win). */
240 u8 flow_window_scale; /**< Flow direction's window scaling factor. */
241 u8 return_window_scale; /**< Return direction's window scaling factor. */
242 u16 reserved; /**< Reserved; padding for alignment. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700243};
244
245/**
Wayne Tan1cabbf12022-05-01 13:01:45 -0700246 * sfe_pppoe_br_accel_mode_t
247 * PPPoE bridge acceleration modes.
248 */
249typedef enum {
250 SFE_PPPOE_BR_ACCEL_MODE_DISABLED, /**< No acceleration */
251 SFE_PPPOE_BR_ACCEL_MODE_EN_5T, /**< 5-tuple (src_ip, dest_ip, src_port, dest_port, protocol) acceleration */
252 SFE_PPPOE_BR_ACCEL_MODE_EN_3T, /**< 3-tuple (src_ip, dest_ip, pppoe session id) acceleration */
253 SFE_PPPOE_BR_ACCEL_MODE_MAX /**< Indicates the last item */
254} __attribute__ ((__packed__)) sfe_pppoe_br_accel_mode_t;
255
256/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800257 * PPPoE connection rules structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700258 */
259struct sfe_pppoe_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700260 u16 flow_pppoe_session_id; /**< Flow direction`s PPPoE session ID. */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800261 u8 flow_pppoe_remote_mac[ETH_ALEN]; /**< Flow direction`s PPPoE server MAC address. */
262 u16 return_pppoe_session_id; /**< Return direction's PPPoE session ID. */
263 u8 return_pppoe_remote_mac[ETH_ALEN]; /**< Return direction's PPPoE server MAC address. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700264};
265
Suruchi Sumanc1a4a612021-10-21 14:50:23 +0530266/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800267 * Information for source MAC address rules.
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530268 */
269struct sfe_src_mac_rule {
270 uint32_t mac_valid_flags; /**< MAC address validity flags. */
271 uint16_t flow_src_mac[3]; /**< Source MAC address for the flow direction. */
272 uint16_t return_src_mac[3]; /**< Source MAC address for the return direction. */
273};
274
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700275/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800276 * QoS connection rule structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700277 */
278struct sfe_qos_rule {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800279 u32 flow_qos_tag; /**< QoS tag associated with this rule for flow direction. */
280 u32 return_qos_tag; /**< QoS tag associated with this rule for return direction. */
Ken Zhu37040ea2021-09-09 21:11:15 -0700281};
282
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700283/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800284* Mark rule structure.
285*/
286struct sfe_mark_rule {
287 u32 flow_mark; /**< SKB mark associated with this rule for flow direction. */
288 u32 return_mark; /**< SKB mark associated with this rule for return direction. */
289};
290
291/**
292 * DSCP connection rule structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700293 */
294struct sfe_dscp_rule {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800295 u8 flow_dscp; /**< Egress DSCP value for flow direction. */
296 u8 return_dscp; /**< Egress DSCP value for return direction. */
297 u8 reserved[2]; /**< Reserved; padding for alignment. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700298};
299
300/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800301 * VLAN connection rule structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700302 */
303struct sfe_vlan_rule {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800304 u32 ingress_vlan_tag; /**< VLAN tag for ingress packets. */
305 u32 egress_vlan_tag; /**< VLAN tag for egress packets. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700306};
307
308/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800309 * Acceleration direction rule structure.
310 * Sometimes it is useful to accelerate traffic in one direction and not in another.
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700311 */
312struct sfe_acceleration_direction_rule {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800313 u8 flow_accel; /**< Accelerate in flow direction. */
314 u8 return_accel; /**< Accelerate in return direction. */
315 u8 reserved[2]; /**< Reserved; padding for alignment. */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700316};
317
318/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800319 * Service class rule information in both directions.
Parikshit Guned31a8202022-01-05 22:15:04 +0530320 */
321struct sfe_service_class_rule {
Ken Zhu7a43d882022-01-04 10:51:44 -0800322 uint32_t flow_mark; /**< Service class information in flow direction. */
323 uint32_t return_mark; /**< Service class information in return direction. */
Parikshit Guned31a8202022-01-05 22:15:04 +0530324};
325
326/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800327 * IPv4 rule create submessage structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700328 */
329struct sfe_ipv4_rule_create_msg {
330 /* Request */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800331 u16 valid_flags; /**< Bit flags associated with paramater validity. */
332 u16 rule_flags; /**< Bit flags associated with the rule. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700333
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800334 struct sfe_ipv4_5tuple tuple; /**< Holds values of 5-tuple. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700335
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800336 struct sfe_ipv4_connection_rule conn_rule; /**< Basic connection-specific data. */
337 struct sfe_protocol_tcp_rule tcp_rule; /**< TCP-related acceleration parameters. */
338 struct sfe_pppoe_rule pppoe_rule; /**< PPPoE-related acceleration parameters. */
339 struct sfe_qos_rule qos_rule; /**< QoS-related acceleration parameters. */
340 struct sfe_src_mac_rule src_mac_rule; /**< Source MAC address rule. */
341 struct sfe_mark_rule mark_rule; /**< SKB mark-related acceleration parameters. */
342 struct sfe_dscp_rule dscp_rule; /**< DSCP-related acceleration parameters. */
343 struct sfe_vlan_rule vlan_primary_rule; /**< Primary VLAN-related acceleration parameters. */
344 struct sfe_vlan_rule vlan_secondary_rule; /**< Secondary VLAN-related acceleration parameters. */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700345#ifdef CONFIG_XFRM
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800346 struct sfe_acceleration_direction_rule direction_rule;
347 /**< Direction related acceleration parameters. */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700348#endif
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700349 /* Response */
Parikshit Guned31a8202022-01-05 22:15:04 +0530350 struct sfe_service_class_rule sawf_rule;
351 /**< Service class related information */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800352 u32 index; /**< Slot ID for cache statistics to host OS. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700353};
354
355/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800356 * IPv4 rule destroy submessage structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700357 */
358struct sfe_ipv4_rule_destroy_msg {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800359 struct sfe_ipv4_5tuple tuple; /**< Holds values of 5-tuple. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700360};
361
362/**
363 * The SFE IPv4 rule sync structure.
364 */
365struct sfe_ipv4_conn_sync {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800366 u32 index; /**< Slot ID for cache statistics to host OS. */
367 u8 protocol; /**< Protocol number. */
368 __be32 flow_ip; /**< Flow IP address. */
369 __be32 flow_ip_xlate; /**< Translated flow IP address. */
370 __be16 flow_ident; /**< Flow identifier, e.g., port. */
371 __be16 flow_ident_xlate; /**< Translated flow identifier, e.g., port. */
372 u32 flow_max_window; /**< Flow direction's largest seen window. */
373 u32 flow_end; /**< Flow direction's largest seen sequence + segment length. */
374 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win). */
375 u32 flow_rx_packet_count; /**< Flow interface's Rx packet count. */
376 u32 flow_rx_byte_count; /**< Flow interface's Rx byte count. */
377 u32 flow_tx_packet_count; /**< Flow interface's Tx packet count. */
378 u32 flow_tx_byte_count; /**< Flow interface's Tx byte count. */
379 u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */
380 u16 flow_pppoe_remote_mac[3]; /**< Flow interface's PPPoE remote server MAC address (if present). */
381 __be32 return_ip; /**< Return IP address. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700382 __be32 return_ip_xlate; /**< Translated return IP address */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800383 __be16 return_ident; /**< Return identifier, e.g., port. */
384 __be16 return_ident_xlate; /**< Translated return identifier, e.g., port. */
385 u32 return_max_window; /**< Return direction's largest seen window. */
386 u32 return_end; /**< Return direction's largest seen sequence + segment length. */
387 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win). */
388 u32 return_rx_packet_count; /**< Return interface's Rx packet count. */
389 u32 return_rx_byte_count; /**< Return interface's Rx byte count. */
390 u32 return_tx_packet_count; /**< Return interface's Tx packet count. */
391 u32 return_tx_byte_count; /**< Return interface's Tx byte count. */
392 u16 return_pppoe_session_id; /**< Return interface`s PPPoE session ID. */
393 u16 return_pppoe_remote_mac[3]; /**< Return interface's PPPoE remote server MAC address (if present). */
394 u32 inc_ticks; /**< Number of ticks since the last sync. */
395 u32 reason; /**< Synchronization reason. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700396
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800397 u8 flags; /**< Bit flags associated with the rule. */
398 u32 qos_tag; /**< QoS tag. */
399 u32 cause; /**< Flush cause. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700400};
401
402/**
Ken Zhu7a43d882022-01-04 10:51:44 -0800403 * Information for a multiple IPv4 connection statistics synchronization message.
404 */
405struct sfe_ipv4_conn_sync_many_msg {
406 /*
407 * Request
408 */
409 uint16_t index; /**< Request connection statistics from the index. */
410 uint16_t size; /**< Buffer size of this message. */
411
412 /*
413 * Response
414 */
415 uint16_t next; /**< Firmware response for the next connection to be requested. */
416 uint16_t count; /**< Number of synchronized connections included in this message. */
417 struct sfe_ipv4_conn_sync conn_sync[]; /**< Array for the statistics. */
418};
419
420/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800421 * Message structure to send/receive IPv4 bridge/route commands
422 */
423struct sfe_ipv4_msg {
424 struct sfe_cmn_msg cm; /**< Message header. */
425 union {
426 struct sfe_ipv4_rule_create_msg rule_create; /**< Rule create message. */
427 struct sfe_ipv4_rule_destroy_msg rule_destroy; /**< Rule destroy message. */
Ken Zhu7a43d882022-01-04 10:51:44 -0800428 struct sfe_ipv4_conn_sync conn_stats; /**< Connection statistics synchronization message. */
429 struct sfe_ipv4_conn_sync_many_msg conn_stats_many;
430 /**< Many connections' statistics synchronization message. */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800431 } msg; /**< IPv4 message. */
432};
433
434/**
435 * @}
436 */
437
438/**
439 * @addtogroup nss_sfe_functions
440 * @{
441 */
442
443/**
444 * IPv4 message received callback.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700445 */
446typedef void (*sfe_ipv4_msg_callback_t)(void *app_data, struct sfe_ipv4_msg *msg);
447
448/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800449 * @}
450 */
451
452/**
453 * @addtogroup nss_sfe_datatypes
454 * @{
455 */
456
457/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530458 * IPv6 5-tuple structure.
459 */
460struct sfe_ipv6_5tuple {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800461 __be32 flow_ip[4]; /**< Flow IP address. */
462 __be32 return_ip[4]; /**< Return IP address. */
463 __be16 flow_ident; /**< Flow identifier, e.g.,TCP/UDP port. */
464 __be16 return_ident; /**< Return identifier, e.g., TCP/UDP port. */
465 u8 protocol; /**< Protocol number. */
466 u8 reserved[3]; /**< Reserved; padding for alignment. */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530467};
468
469/**
470 * IPv6 connection rule structure.
471 */
472struct sfe_ipv6_connection_rule {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800473 u8 flow_mac[6]; /**< Flow MAC address. */
474 u8 return_mac[6]; /**< Return MAC address. */
475 s32 flow_interface_num; /**< Flow interface number. */
476 s32 return_interface_num; /**< Return interface number. */
477 s32 flow_top_interface_num; /**< Top flow interface number. */
478 s32 return_top_interface_num; /**< Top return interface number. */
479 u32 flow_mtu; /**< Flow interface's MTU. */
480 u32 return_mtu; /**< Return interface's MTU. */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530481};
482
483/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800484 * IPv6 rule create submessage structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700485 */
486struct sfe_ipv6_rule_create_msg {
487 /*
488 * Request
489 */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800490 u16 valid_flags; /**< Bit flags associated with parameter validity. */
491 u16 rule_flags; /**< Bit flags associated with the rule. */
492 struct sfe_ipv6_5tuple tuple; /**< Holds values of the sfe_ipv6_5tuple tuple. */
493 struct sfe_ipv6_connection_rule conn_rule; /**< Basic connection-specific data. */
494 struct sfe_protocol_tcp_rule tcp_rule; /**< Protocol-related acceleration parameters. */
495 struct sfe_pppoe_rule pppoe_rule; /**< PPPoE-related acceleration parameters. */
496 struct sfe_qos_rule qos_rule; /**< QoS-related acceleration parameters. */
497 struct sfe_src_mac_rule src_mac_rule; /**< Source MAC address rule. */
498 struct sfe_mark_rule mark_rule; /**< SKB mark-related acceleration parameters. */
499 struct sfe_dscp_rule dscp_rule; /**< DSCP-related acceleration parameters. */
500 struct sfe_vlan_rule vlan_primary_rule; /**< VLAN-related acceleration parameters. */
501 struct sfe_vlan_rule vlan_secondary_rule; /**< VLAN-related acceleration parameters. */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700502#ifdef CONFIG_XFRM
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800503 struct sfe_acceleration_direction_rule direction_rule;
504 /**< Direction-related acceleration parameters. */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700505#endif
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700506 /*
507 * Response
508 */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800509 struct sfe_service_class_rule sawf_rule; /**< Service class related information. */
510 u32 index; /**< Slot ID for cache statistics to host OS. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700511};
512
513/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800514 * IPv6 rule destroy submessage structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700515 */
516struct sfe_ipv6_rule_destroy_msg {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800517 struct sfe_ipv6_5tuple tuple; /**< Holds values of the sfe_ipv6_5tuple tuple */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700518};
519
520/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800521 * SFE IPv6 rule sync structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700522 */
523struct sfe_ipv6_conn_sync {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800524 u32 index; /**< Slot ID for cache statistics to host OS. */
525 u8 protocol; /**< Protocol number. */
526 __be32 flow_ip[4]; /**< Flow IP address. */
527 __be16 flow_ident; /**< Flow identifier, e.g., port. */
528 u32 flow_max_window; /**< Flow direction's largest seen window. */
529 u32 flow_end; /**< Flow direction's largest seen sequence + segment length. */
530 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win). */
531 u32 flow_rx_packet_count; /**< Flow interface's Rx packet count. */
532 u32 flow_rx_byte_count; /**< Flow interface's Rx byte count. */
533 u32 flow_tx_packet_count; /**< Flow interface's Tx packet count. */
534 u32 flow_tx_byte_count; /**< Flow interface's Tx byte count. */
535 u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */
536 u16 flow_pppoe_remote_mac[3]; /**< Flow interface's PPPoE remote server MAC address (if present). */
537 __be32 return_ip[4]; /**< Return IP address. */
538 __be16 return_ident; /**< Return identifer, e.g., port. */
539 u32 return_max_window; /**< Return direction's largest seen window. */
540 u32 return_end; /**< Return direction's largest seen sequence + segment length. */
541 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win). */
542 u32 return_rx_packet_count; /**< Return interface's Rx packet count. */
543 u32 return_rx_byte_count; /**< Return interface's Rx byte count. */
544 u32 return_tx_packet_count; /**< Return interface's Tx packet count. */
545 u32 return_tx_byte_count; /**< Return interface's Tx byte count. */
546 u16 return_pppoe_session_id; /**< Return interface`s PPPoE session ID. */
547 u16 return_pppoe_remote_mac[3]; /**< Return interface's PPPoE remote server MAC address (if present). */
548 u32 inc_ticks; /**< Number of ticks since the last sync. */
549 u32 reason; /**< Sync reason. */
550 u8 flags; /**< Bit flags associated with the rule. */
551 u32 qos_tag; /**< QoS tag. */
552 u32 cause; /**< Flush cause associated with the rule. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700553};
554
555/**
Ken Zhu7a43d882022-01-04 10:51:44 -0800556 * Information for a multiple IPv6 connection statistics synchronization message.
557 */
558struct sfe_ipv6_conn_sync_many_msg {
559 /*
560 * Request:
561 */
562 uint16_t index; /**< Request connection statistics from the index. */
563 uint16_t size; /**< Buffer size of this message. */
564
565 /*
566 * Response:
567 */
568 uint16_t next; /**< Firmware response for the next connection to be requested. */
569 uint16_t count; /**< Number of synchronized connections included in this message. */
570 struct sfe_ipv6_conn_sync conn_sync[]; /**< Array for the statistics. */
571};
572
573/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800574 * Message structure to send/receive IPv6 bridge/route commands.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700575 */
576struct sfe_ipv6_msg {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800577 struct sfe_cmn_msg cm; /**< Message header. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700578 union {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800579 struct sfe_ipv6_rule_create_msg rule_create;
580 /**< Rule create message. */
581 struct sfe_ipv6_rule_destroy_msg rule_destroy;
582 /**< Rule destroy message. */
583 struct sfe_ipv6_conn_sync conn_stats;
Ken Zhu7a43d882022-01-04 10:51:44 -0800584 /**< Statistics synchronization message. */
585 struct sfe_ipv6_conn_sync_many_msg conn_stats_many;
586 /**< Many Connections' statistics synchronizaion message. */
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800587 } msg; /**< IPv6 message. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700588};
589
590/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800591 * @}
592 */
593
594/**
595 * @addtogroup nss_sfe_functions
596 * @{
597 */
598
599/**
600 * IPv6 message received callback.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700601 */
602typedef void (*sfe_ipv6_msg_callback_t)(void *app_data, struct sfe_ipv6_msg *msg);
603
604/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800605 * @}
606 */
607
608/**
609 * @addtogroup nss_sfe_datatypes
610 * @{
611 */
612
613/**
614 * 6rd tunnel peer address.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700615 */
616struct sfe_tun6rd_set_peer_msg {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800617 __be32 ipv6_address[4]; /**< The peer's IPv6 address. */
618 __be32 dest; /**< The peer's IPv4 address. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700619};
620
621/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800622 * Message structure to send/receive 6rd tunnel messages.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700623 */
624struct sfe_tun6rd_msg {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800625 struct sfe_cmn_msg cm; /**< Message header. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700626 union {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800627 struct sfe_tun6rd_set_peer_msg peer; /**< Add or update peer message. */
628 } msg; /**< 6RD tunnel message. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700629};
630
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800631/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530632 * SFE context instance.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700633 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530634struct sfe_ctx_instance {
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800635 int not_used; /**< Not used. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700636};
637
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800638/**
639 * @}
640 */
641
642/**
643 * @addtogroup nss_sfe_functions
644 * @{
645 */
646
647/**
Jackson Bockus3fafbf32022-02-13 17:15:26 -0800648 * Copy the IPv4 statistics for the given service class.
649 *
650 * @param sid Service class ID
651 * @param bytes Pointer to where byte count should be written.
652 * @param packets Pointer to where packet count should be written.
653 *
654 * @return
655 * True if successful, false if maximum retries exceeded; bool.
656 */
657extern bool sfe_service_class_stats_get(uint8_t sid, uint64_t *bytes, uint64_t *packets);
658
659/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800660 * Gets the maximum number of IPv4 connections supported by the SFE acceleration engine.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700661 *
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800662 * @return
663 * The maximum number of connections that can be accelerated by the SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700664 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530665int sfe_ipv4_max_conn_count(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700666
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800667/**
668 * Transmits an IPv4 message to the SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700669 *
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800670 * @param sfe_ctx SFE context.
671 * @param msg The IPv4 message.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700672 *
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800673 * @return
674 * The status of the Tx operation (#sfe_tx_status_t).
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700675 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530676extern 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 -0700677
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800678/**
679 * Registers a notifier callback for IPv4 messages from the SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700680 *
Ken Zhu7a43d882022-01-04 10:51:44 -0800681 * @param one_rule_cb The callback pointer for one rule.
682 * @param many_rules_cb The callback pointer for many rules.
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800683 * @param app_data The application context for this message.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700684 *
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800685 * @return
686 * The SFE context (#sfe_ctx_instance).
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700687 */
Ken Zhu7a43d882022-01-04 10:51:44 -0800688extern struct sfe_ctx_instance *sfe_ipv4_notify_register(sfe_ipv4_msg_callback_t one_rule_cb,
689 sfe_ipv4_msg_callback_t many_rules_cb,void *app_data);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700690
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800691/**
692 * Unregisters a notifier callback for IPv4 messages from the SFE.
693 *
694 * @return
695 * None.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700696 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530697extern void sfe_ipv4_notify_unregister(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700698
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800699/**
700 * Initializes an IPv4 message.
701 *
702 * @param nim The IPv4 message pointer.
703 * @param if_num The interface number.
704 * @param type The type of the message.
705 * @param len The length of the message.
706 * @param cb The message callback.
707 * @param app_data The application context for this message.
708 *
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700709 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700710extern void sfe_ipv4_msg_init(struct sfe_ipv4_msg *nim, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700711 sfe_ipv4_msg_callback_t cb, void *app_data);
712
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800713/**
714 * Gets the maximum number of IPv6 connections supported by the SFE acceleration engine.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700715 *
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800716 * @return
717 * The maximum number of connections that can be accelerated by the SFE; integer.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700718 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530719int sfe_ipv6_max_conn_count(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700720
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800721/**
722 * Transmits an IPv6 message to the SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700723 *
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800724 * @param sfe_ctx The SFE context.
725 * @param msg The IPv6 message.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700726 *
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800727 * @return
728 * The status of the Tx operation (#sfe_tx_status_t).
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700729 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530730extern 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 -0700731
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800732/**
733 * Registers a notifier callback for IPv6 messages from the SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700734 *
Ken Zhu7a43d882022-01-04 10:51:44 -0800735 * @param one_rule_cb The callback pointer for one rule.
736 * @param many_rules_cb The callback pointer for many rules.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700737 *
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800738 * @return
739 * The SFE context (#sfe_ctx_instance).
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700740 */
Ken Zhu7a43d882022-01-04 10:51:44 -0800741extern struct sfe_ctx_instance *sfe_ipv6_notify_register(sfe_ipv6_msg_callback_t one_rule_cb,
742 sfe_ipv6_msg_callback_t many_rules_cb,void *app_data);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700743
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800744/**
745 * Unregisters a notifier callback for IPv6 messages from the SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700746 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530747extern void sfe_ipv6_notify_unregister(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700748
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800749/**
750 * Initializes an IPv6 message.
751 *
752 * @param nim The IPv6 message pointer.
753 * @param if_num The interface number.
754 * @param type The type of the message.
755 * @param len The length of the message.
756 * @param cb The message callback.
757 * @param app_data The application context for this message.
758 *
759 * @return
760 * None.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700761 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700762extern void sfe_ipv6_msg_init(struct sfe_ipv6_msg *nim, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700763 sfe_ipv6_msg_callback_t cb, void *app_data);
764
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800765/**
766 * Transmits a 6rd tunnel message to the SFE.
767 *
768 * @param sfe_ctx The SFE context pointer.
769 * @param msg The 6rd tunnel message pointer.
770 *
771 * @return
772 * The status of the Tx operation (#sfe_tx_status_t).
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700773 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530774sfe_tx_status_t sfe_tun6rd_tx(struct sfe_ctx_instance *sfe_ctx, struct sfe_tun6rd_msg *msg);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700775
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800776/**
777 * Initializes a 6rd tunnel message.
778 *
779 * @param ncm The 6rd tunnel message pointer.
780 * @param if_num The interface number.
781 * @param type The type of the message.
782 * @param len The length of the message.
783 * @param cb The message callback.
784 * @param app_data The application context for this message.
785 *
786 * @return
787 * None.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700788 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700789void sfe_tun6rd_msg_init(struct sfe_tun6rd_msg *ncm, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700790 void *cb, void *app_data);
791
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800792/**
793 * Indicates whether the l2 feature flag is enabled or disabled.
Ratheesh Kannothdd382ed2021-11-23 09:36:30 +0530794 *
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800795 * @return
796 * True if enabled; false if disabled.
Ratheesh Kannothdd382ed2021-11-23 09:36:30 +0530797 */
798bool sfe_is_l2_feature_enabled(void);
799
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800800/**
Murat Sezginef190392022-04-04 17:56:31 -0700801 * Updates mark values of an IPv4 connection.
802 *
803 * @param mark The mark object.
804 *
805 * @return
806 * None.
807 */
808void sfe_ipv4_mark_rule_update(struct sfe_connection_mark *mark);
809
810/**
811 * Updates mark values of an IPv6 connection.
812 *
813 * @param mark The mark object.
814 *
815 * @return
816 * None.
817 */
818void sfe_ipv6_mark_rule_update(struct sfe_connection_mark *mark);
819
820/**
Wayne Tan1cabbf12022-05-01 13:01:45 -0700821 * Gets the acceleration mode of PPPoE bridge.
822 *
823 * @return
824 * The acceleration mode.
825 */
826sfe_pppoe_br_accel_mode_t sfe_pppoe_get_br_accel_mode(void);
827
828/**
Suruchi Agarwal0eec7f92022-02-11 14:07:09 -0800829 * @}
830 */
831
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530832#endif /* __SFE_API_H */