blob: da9c8570931d08517a42bc42aa2150eb6f9103d4 [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 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
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 Kannoth5dee3772022-01-18 11:27:14 +053047#define SFE_RULE_CREATE_FLAG_SRC_INTERFACE_CHECK (1<<10) /**< Check source interface. */
Ken Zhu7e38d1a2021-11-30 17:31:46 -080048#define SFE_RULE_CREATE_FLAG_FLOW_TRANSMIT_FAST (1<<11) /**< original flow transmit fast. */
49#define SFE_RULE_CREATE_FLAG_RETURN_TRANSMIT_FAST (1<<12) /**< return flow transmit fast. */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +053050
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070051/**
52 * Rule creation validity flags.
53 */
54#define SFE_RULE_CREATE_CONN_VALID (1<<0) /**< IPv4 Connection is valid */
55#define SFE_RULE_CREATE_TCP_VALID (1<<1) /**< TCP Protocol fields are valid */
Guduri Prathyusha647fe3e2021-11-22 19:17:51 +053056#define SFE_RULE_CREATE_PPPOE_DECAP_VALID (1<<2) /**< PPPoE Decap fields are valid */
57#define SFE_RULE_CREATE_PPPOE_ENCAP_VALID (1<<3) /**< PPPoE Encap fields are valid */
Guduri Prathyushaeb31c902021-11-10 20:18:50 +053058#define SFE_RULE_CREATE_QOS_VALID (1<<4) /**< QoS fields are valid */
59#define SFE_RULE_CREATE_VLAN_VALID (1<<5) /**< VLAN fields are valid */
60#define SFE_RULE_CREATE_DSCP_MARKING_VALID (1<<6) /**< DSCP marking fields are valid */
61#define SFE_RULE_CREATE_VLAN_MARKING_VALID (1<<7) /**< VLAN marking fields are valid */
62#define SFE_RULE_CREATE_DIRECTION_VALID (1<<8) /**< specify acceleration directions */
63#define SFE_RULE_CREATE_SRC_MAC_VALID (1<<9) /**< Source MAC valid */
Ken Zhu37040ea2021-09-09 21:11:15 -070064#define SFE_RULE_CREATE_MARK_VALID (1<<10) /**< SKB mark fields are valid */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +053065
66/*
67 * Source MAC address valid flags (to be used with mac_valid_flags field of sfe_ipv4_src_mac_rule structure)
68 */
69#define SFE_SRC_MAC_FLOW_VALID 0x01
70 /**< MAC address for the flow interface is valid. */
71#define SFE_SRC_MAC_RETURN_VALID 0x02
72 /**< MAC address for the return interface is valid. */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070073
Murat Sezginaffcf9e2020-09-18 13:16:45 -070074/*
75 * 32/64 bits pointer type
76 */
77#ifdef __LP64__
78typedef uint64_t sfe_ptr_t;
79#else
80typedef uint32_t sfe_ptr_t;
81#endif
82
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070083typedef enum sfe_rule_sync_reason {
Xiaoping Fan1253cd02015-11-11 18:02:20 -080084 SFE_RULE_SYNC_REASON_STATS, /* Sync is to synchronize stats */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070085 SFE_RULE_SYNC_REASON_FLUSH, /* Sync is to flush a entry */
86 SFE_RULE_SYNC_REASON_EVICT, /* Sync is to evict a entry */
Xiaoping Fan1253cd02015-11-11 18:02:20 -080087 SFE_RULE_SYNC_REASON_DESTROY /* Sync is to destroy a entry(requested by connection manager) */
88
Xiaoping Fan0493b2d2015-08-21 19:09:38 -070089} sfe_rule_sync_reason_t;
90
91/**
92 * Tx command status
93 */
94typedef enum {
95 SFE_TX_SUCCESS = 0, /**< Success */
96 SFE_TX_FAILURE, /**< Command failure other than descriptor not available */
97 SFE_TX_FAILURE_QUEUE, /**< Command failure due to descriptor not available */
98 SFE_TX_FAILURE_NOT_READY, /**< Command failure due to SFE state uninitialized */
99 SFE_TX_FAILURE_TOO_LARGE, /**< Command is too large to fit in one message */
100 SFE_TX_FAILURE_TOO_SHORT, /**< Command/Packet is shorter than expected size */
101 SFE_TX_FAILURE_NOT_SUPPORTED, /**< Command/Packet not accepted for forwarding */
102 SFE_TX_FAILURE_BAD_PARAM, /**< Command failure due to bad parameters */
103 SFE_TX_FAILURE_NOT_ENABLED, /**< Command failure due to SFE feature is not enabled */
104} sfe_tx_status_t;
105
106/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530107 * Common response types.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700108 */
109enum sfe_cmn_response {
110 SFE_CMN_RESPONSE_ACK, /**< Message Acknowledge */
111 SFE_CMN_RESPONSE_EVERSION, /**< Message Version Error */
112 SFE_CMN_RESPONSE_EINTERFACE, /**< Message Interface Error */
113 SFE_CMN_RESPONSE_ELENGTH, /**< Message Length Error */
114 SFE_CMN_RESPONSE_EMSG, /**< Message Error */
115 SFE_CMM_RESPONSE_NOTIFY, /**< Message Independant of Request */
116 SFE_CMN_RESPONSE_LAST
117};
118
119/**
120 * IPv4 bridge/route rule messages
121 */
122enum sfe_message_types {
123 SFE_TX_CREATE_RULE_MSG, /**< IPv4/6 create rule message */
124 SFE_TX_DESTROY_RULE_MSG, /**< IPv4/6 destroy rule message */
125 SFE_RX_CONN_STATS_SYNC_MSG, /**< IPv4/6 connection stats sync message */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700126 SFE_TUN6RD_ADD_UPDATE_PEER, /**< Add/update peer for 6rd tunnel */
127 SFE_MAX_MSG_TYPES, /**< IPv4/6 message max type number */
128};
129
130/**
131 * Common message structure
132 */
133struct sfe_cmn_msg {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700134 u16 version; /**< Version id for main message format */
135 u16 interface; /**< Primary Key for all messages */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700136 enum sfe_cmn_response response; /**< Primary response */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700137 u32 type; /**< Decetralized request #, to be used to match response # */
138 u32 error; /**< Decentralized specific error message, response == EMSG */
Murat Sezginaffcf9e2020-09-18 13:16:45 -0700139 sfe_ptr_t cb; /**< Place for callback pointer */
140 sfe_ptr_t app_data; /**< Place for app data */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700141 u32 len; /**< What is the length of the message excluding this header */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700142};
143
144/**
145 * Common 5 tuple structure
146 */
147struct sfe_ipv4_5tuple {
148 __be32 flow_ip; /**< Flow IP address */
149 __be32 return_ip; /**< Return IP address */
150 __be16 flow_ident; /**< Flow ident (e.g. TCP/UDP port) */
151 __be16 return_ident; /**< Return ident (e.g. TCP/UDP port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700152 u8 protocol; /**< Protocol number */
153 u8 reserved[3]; /**< Padded for alignment */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700154};
155
156/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530157 * IPv4 connection rule structure.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700158 */
159struct sfe_ipv4_connection_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700160 u8 flow_mac[6]; /**< Flow MAC address */
161 u8 return_mac[6]; /**< Return MAC address */
162 s32 flow_interface_num; /**< Flow interface number */
163 s32 return_interface_num; /**< Return interface number */
164 s32 flow_top_interface_num; /* Top flow interface number */
165 s32 return_top_interface_num;/* Top return interface number */
166 u32 flow_mtu; /**< Flow interface`s MTU */
167 u32 return_mtu; /**< Return interface`s MTU */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700168 __be32 flow_ip_xlate; /**< Translated flow IP address */
169 __be32 return_ip_xlate; /**< Translated return IP address */
170 __be16 flow_ident_xlate; /**< Translated flow ident (e.g. port) */
171 __be16 return_ident_xlate; /**< Translated return ident (e.g. port) */
172};
173
174/**
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700175 * TCP connection rule structure
176 */
177struct sfe_protocol_tcp_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700178 u32 flow_max_window; /**< Flow direction's largest seen window */
179 u32 return_max_window; /**< Return direction's largest seen window */
180 u32 flow_end; /**< Flow direction's largest seen sequence + segment length */
181 u32 return_end; /**< Return direction's largest seen sequence + segment length */
182 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */
183 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */
184 u8 flow_window_scale; /**< Flow direction's window scaling factor */
185 u8 return_window_scale; /**< Return direction's window scaling factor */
186 u16 reserved; /**< Padded for alignment */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700187};
188
189/**
190 * PPPoE connection rules structure
191 */
192struct sfe_pppoe_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700193 u16 flow_pppoe_session_id; /**< Flow direction`s PPPoE session ID. */
Guduri Prathyushaeb31c902021-11-10 20:18:50 +0530194 u8 flow_pppoe_remote_mac[ETH_ALEN]; /**< Flow direction`s PPPoE Server MAC address */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700195 u16 return_pppoe_session_id; /**< Return direction's PPPoE session ID. */
Guduri Prathyushaeb31c902021-11-10 20:18:50 +0530196 u8 return_pppoe_remote_mac[ETH_ALEN]; /**< Return direction's PPPoE Server MAC address */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700197};
198
Suruchi Sumanc1a4a612021-10-21 14:50:23 +0530199/**
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530200 * sfe_src_mac_rule
201 * Information for source MAC address rules.
202 */
203struct sfe_src_mac_rule {
204 uint32_t mac_valid_flags; /**< MAC address validity flags. */
205 uint16_t flow_src_mac[3]; /**< Source MAC address for the flow direction. */
206 uint16_t return_src_mac[3]; /**< Source MAC address for the return direction. */
207};
208
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700209/**
210 * QoS connection rule structure
211 */
212struct sfe_qos_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700213 u32 flow_qos_tag; /**< QoS tag associated with this rule for flow direction */
214 u32 return_qos_tag; /**< QoS tag associated with this rule for return direction */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700215};
216
Ken Zhu37040ea2021-09-09 21:11:15 -0700217struct sfe_mark_rule {
218 u32 flow_mark; /**< skb mark associated with this rule for flow direction */
219 u32 return_mark; /**< skb mark associated with this rule for return direction */
220};
221
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700222/**
223 * DSCP connection rule structure
224 */
225struct sfe_dscp_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700226 u8 flow_dscp; /**< Egress DSCP value for flow direction */
227 u8 return_dscp; /**< Egress DSCP value for return direction */
228 u8 reserved[2]; /**< Padded for alignment */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700229};
230
231/**
232 * VLAN connection rule structure
233 */
234struct sfe_vlan_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700235 u32 ingress_vlan_tag; /**< VLAN Tag for the ingress packets */
236 u32 egress_vlan_tag; /**< VLAN Tag for egress packets */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700237};
238
239/**
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700240 * Acceleration direction rule structure
241 * Sometimes we just want to accelerate traffic in one direction but not in another.
242 */
243struct sfe_acceleration_direction_rule {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700244 u8 flow_accel; /**< Accelerate in flow direction */
245 u8 return_accel; /**< Accelerate in return direction */
246 u8 reserved[2]; /**< Padded for alignment */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700247};
248
249/**
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700250 * The IPv4 rule create sub-message structure.
251 */
252struct sfe_ipv4_rule_create_msg {
253 /* Request */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700254 u16 valid_flags; /**< Bit flags associated with the validity of parameters */
255 u16 rule_flags; /**< Bit flags associated with the rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700256
257 struct sfe_ipv4_5tuple tuple; /**< Holds values of the 5 tuple */
258
259 struct sfe_ipv4_connection_rule conn_rule; /**< Basic connection specific data */
260 struct sfe_protocol_tcp_rule tcp_rule; /**< TCP related accleration parameters */
261 struct sfe_pppoe_rule pppoe_rule; /**< PPPoE related accleration parameters */
262 struct sfe_qos_rule qos_rule; /**< QoS related accleration parameters */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530263 struct sfe_src_mac_rule src_mac_rule; /**< Src Mac rule */
Ken Zhu37040ea2021-09-09 21:11:15 -0700264 struct sfe_mark_rule mark_rule; /**< skb mark related accleration parameters */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700265 struct sfe_dscp_rule dscp_rule; /**< DSCP related accleration parameters */
266 struct sfe_vlan_rule vlan_primary_rule; /**< Primary VLAN related accleration parameters */
267 struct sfe_vlan_rule vlan_secondary_rule; /**< Secondary VLAN related accleration parameters */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700268#ifdef CONFIG_XFRM
269 struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/
270#endif
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700271 /* Response */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700272 u32 index; /**< Slot ID for cache stats to host OS */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700273};
274
275/**
276 * The IPv4 rule destroy sub-message structure.
277 */
278struct sfe_ipv4_rule_destroy_msg {
279 struct sfe_ipv4_5tuple tuple; /**< Holds values of the 5 tuple */
280};
281
282/**
283 * The SFE IPv4 rule sync structure.
284 */
285struct sfe_ipv4_conn_sync {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700286 u32 index; /**< Slot ID for cache stats to host OS */
287 u8 protocol; /**< Protocol number */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700288 __be32 flow_ip; /**< Flow IP address */
289 __be32 flow_ip_xlate; /**< Translated flow IP address */
290 __be16 flow_ident; /**< Flow ident (e.g. port) */
291 __be16 flow_ident_xlate; /**< Translated flow ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700292 u32 flow_max_window; /**< Flow direction's largest seen window */
293 u32 flow_end; /**< Flow direction's largest seen sequence + segment length */
294 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */
295 u32 flow_rx_packet_count; /**< Flow interface's RX packet count */
296 u32 flow_rx_byte_count; /**< Flow interface's RX byte count */
297 u32 flow_tx_packet_count; /**< Flow interface's TX packet count */
298 u32 flow_tx_byte_count; /**< Flow interface's TX byte count */
299 u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */
300 u16 flow_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700301 /**< Flow interface's PPPoE remote server MAC address if there is any */
302 __be32 return_ip; /**< Return IP address */
303 __be32 return_ip_xlate; /**< Translated return IP address */
304 __be16 return_ident; /**< Return ident (e.g. port) */
305 __be16 return_ident_xlate; /**< Translated return ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700306 u32 return_max_window; /**< Return direction's largest seen window */
307 u32 return_end; /**< Return direction's largest seen sequence + segment length */
308 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */
309 u32 return_rx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700310 /**< Return interface's RX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700311 u32 return_rx_byte_count; /**< Return interface's RX byte count */
312 u32 return_tx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700313 /**< Return interface's TX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700314 u32 return_tx_byte_count; /**< Return interface's TX byte count */
315 u16 return_pppoe_session_id;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700316 /**< Return interface`s PPPoE session ID. */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700317 u16 return_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700318 /**< Return interface's PPPoE remote server MAC address if there is any */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700319 u32 inc_ticks; /**< Number of ticks since the last sync */
320 u32 reason; /**< Reason for the sync */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700321
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700322 u8 flags; /**< Bit flags associated with the rule */
323 u32 qos_tag; /**< QoS Tag */
324 u32 cause; /**< Flush Cause */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700325};
326
327/*
328 * Message structure to send/receive IPv4 bridge/route commands
329 */
330struct sfe_ipv4_msg {
331 struct sfe_cmn_msg cm; /**< Message Header */
332 union {
333 struct sfe_ipv4_rule_create_msg rule_create; /**< Message: rule create */
334 struct sfe_ipv4_rule_destroy_msg rule_destroy; /**< Message: rule destroy */
335 struct sfe_ipv4_conn_sync conn_stats; /**< Message: connection stats sync */
336 } msg;
337};
338
339/**
340 * Callback to be called when IPv4 message is received
341 */
342typedef void (*sfe_ipv4_msg_callback_t)(void *app_data, struct sfe_ipv4_msg *msg);
343
344/**
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530345 * IPv6 5-tuple structure.
346 */
347struct sfe_ipv6_5tuple {
348 __be32 flow_ip[4]; /**< Flow IP address */
349 __be32 return_ip[4]; /**< Return IP address */
350 __be16 flow_ident; /**< Flow ident (e.g. TCP/UDP port) */
351 __be16 return_ident; /**< Return ident (e.g. TCP/UDP port) */
352 u8 protocol; /**< Protocol number */
353 u8 reserved[3]; /**< Padded for alignment */
354};
355
356/**
357 * IPv6 connection rule structure.
358 */
359struct sfe_ipv6_connection_rule {
360 u8 flow_mac[6]; /**< Flow MAC address */
361 u8 return_mac[6]; /**< Return MAC address */
362 s32 flow_interface_num; /**< Flow interface number */
363 s32 return_interface_num; /**< Return interface number */
364 s32 flow_top_interface_num; /* Top flow interface number */
365 s32 return_top_interface_num;/* Top return interface number */
366 u32 flow_mtu; /**< Flow interface's MTU */
367 u32 return_mtu; /**< Return interface's MTU */
368};
369
370/**
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700371 * The IPv6 rule create sub-message structure.
372 */
373struct sfe_ipv6_rule_create_msg {
374 /*
375 * Request
376 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700377 u16 valid_flags; /**< Bit flags associated with the validity of parameters */
378 u16 rule_flags; /**< Bit flags associated with the rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700379 struct sfe_ipv6_5tuple tuple; /**< Holds values of the 5 tuple */
380 struct sfe_ipv6_connection_rule conn_rule; /**< Basic connection specific data */
381 struct sfe_protocol_tcp_rule tcp_rule; /**< Protocol related accleration parameters */
382 struct sfe_pppoe_rule pppoe_rule; /**< PPPoE related accleration parameters */
383 struct sfe_qos_rule qos_rule; /**< QoS related accleration parameters */
Ratheesh Kannoth29140aa2021-10-20 08:25:02 +0530384 struct sfe_src_mac_rule src_mac_rule; /**< Src Mac rule */
Ken Zhu37040ea2021-09-09 21:11:15 -0700385 struct sfe_mark_rule mark_rule; /**< skb mark related accleration parameters */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700386 struct sfe_dscp_rule dscp_rule; /**< DSCP related accleration parameters */
387 struct sfe_vlan_rule vlan_primary_rule; /**< VLAN related accleration parameters */
388 struct sfe_vlan_rule vlan_secondary_rule; /**< VLAN related accleration parameters */
Xiaoping Fanee0afe02015-09-10 17:34:00 -0700389#ifdef CONFIG_XFRM
390 struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/
391#endif
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700392 /*
393 * Response
394 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700395 u32 index; /**< Slot ID for cache stats to host OS */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700396};
397
398/**
399 * The IPv6 rule destroy sub-message structure.
400 */
401struct sfe_ipv6_rule_destroy_msg {
402 struct sfe_ipv6_5tuple tuple; /**< Holds values of the 5 tuple */
403};
404
405/**
406 * The SFE IPv6 rule sync structure.
407 */
408struct sfe_ipv6_conn_sync {
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700409 u32 index; /**< Slot ID for cache stats to host OS */
410 u8 protocol; /**< Protocol number */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700411 __be32 flow_ip[4]; /**< Flow IP address */
412 __be16 flow_ident; /**< Flow ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700413 u32 flow_max_window; /**< Flow direction's largest seen window */
414 u32 flow_end; /**< Flow direction's largest seen sequence + segment length */
415 u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */
416 u32 flow_rx_packet_count; /**< Flow interface's RX packet count */
417 u32 flow_rx_byte_count; /**< Flow interface's RX byte count */
418 u32 flow_tx_packet_count; /**< Flow interface's TX packet count */
419 u32 flow_tx_byte_count; /**< Flow interface's TX byte count */
420 u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */
421 u16 flow_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700422 /**< Flow interface's PPPoE remote server MAC address if there is any */
423 __be32 return_ip[4]; /**< Return IP address */
424 __be16 return_ident; /**< Return ident (e.g. port) */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700425 u32 return_max_window; /**< Return direction's largest seen window */
426 u32 return_end; /**< Return direction's largest seen sequence + segment length */
427 u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */
428 u32 return_rx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700429 /**< Return interface's RX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700430 u32 return_rx_byte_count; /**< Return interface's RX byte count */
431 u32 return_tx_packet_count;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700432 /**< Return interface's TX packet count */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700433 u32 return_tx_byte_count; /**< Return interface's TX byte count */
434 u16 return_pppoe_session_id;
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700435 /**< Return interface`s PPPoE session ID. */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700436 u16 return_pppoe_remote_mac[3];
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700437 /**< Return interface's PPPoE remote server MAC address if there is any */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700438 u32 inc_ticks; /**< Number of ticks since the last sync */
439 u32 reason; /**< Reason for the sync */
440 u8 flags; /**< Bit flags associated with the rule */
441 u32 qos_tag; /**< QoS Tag */
442 u32 cause; /**< Flush cause associated with the rule */
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700443};
444
445/**
446 * Message structure to send/receive IPv6 bridge/route commands
447 */
448struct sfe_ipv6_msg {
449 struct sfe_cmn_msg cm; /**< Message Header */
450 union {
451 struct sfe_ipv6_rule_create_msg rule_create; /**< Message: rule create */
452 struct sfe_ipv6_rule_destroy_msg rule_destroy; /**< Message: rule destroy */
453 struct sfe_ipv6_conn_sync conn_stats; /**< Message: stats sync */
454 } msg;
455};
456
457/**
458 * Callback to be called when IPv6 message is received
459 */
460typedef void (*sfe_ipv6_msg_callback_t)(void *app_data, struct sfe_ipv6_msg *msg);
461
462/**
463 * 6rd tunnel peer addr.
464 */
465struct sfe_tun6rd_set_peer_msg {
466 __be32 ipv6_address[4]; /* The peer's ipv6 addr*/
467 __be32 dest; /* The peer's ipv4 addr*/
468};
469
470/**
471 * Message structure to send/receive 6rd tunnel messages
472 */
473struct sfe_tun6rd_msg {
474 struct sfe_cmn_msg cm; /* Message Header */
475 union {
476 struct sfe_tun6rd_set_peer_msg peer; /* Message: add/update peer */
477 } msg;
478};
479
480/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530481 * SFE context instance.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700482 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530483struct sfe_ctx_instance {
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700484 int not_used;
485};
486
487/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530488 * sfe_ipv4_max_conn_count()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700489 * Return the maximum number of IPv4 connections that the sfe acceleration engine supports
490 *
491 * @return int The number of connections that can be accelerated by the sfe
492 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530493int sfe_ipv4_max_conn_count(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700494
495/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530496 * sfe_ipv4_tx()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700497 * Transmit an IPv4 message to the sfe
498 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530499 * @param sfe_ctx SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700500 * @param msg The IPv4 message
501 *
502 * @return sfe_tx_status_t The status of the Tx operation
503 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530504extern 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 -0700505
506/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530507 * sfe_ipv4_notify_register()
508 * Register a notifier callback for IPv4 messages from SFE
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700509 *
510 * @param cb The callback pointer
511 * @param app_data The application context for this message
512 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530513 * @return struct sfe_ctx_instance * The SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700514 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530515extern struct sfe_ctx_instance *sfe_ipv4_notify_register(sfe_ipv4_msg_callback_t cb, void *app_data);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700516
517/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530518 * sfe_ipv4_notify_unregister()
519 * Un-Register a notifier callback for IPv4 messages from SFE
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700520 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530521extern void sfe_ipv4_notify_unregister(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700522
523/*
524 * sfe_ipv4_msg_init()
525 * IPv4 message init
526 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700527extern void sfe_ipv4_msg_init(struct sfe_ipv4_msg *nim, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700528 sfe_ipv4_msg_callback_t cb, void *app_data);
529
530/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530531 * sfe_ipv6_max_conn_count()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700532 * Return the maximum number of IPv6 connections that the sfe acceleration engine supports
533 *
534 * @return int The number of connections that can be accelerated by the sfe
535 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530536int sfe_ipv6_max_conn_count(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700537
538/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530539 * sfe_ipv6_tx()
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700540 * Transmit an IPv6 message to the sfe
541 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530542 * @param sfe_ctx SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700543 * @param msg The IPv6 message
544 *
545 * @return sfe_tx_status_t The status of the Tx operation
546 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530547extern 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 -0700548
549/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530550 * sfe_ipv6_notify_register()
551 * Register a notifier callback for IPv6 messages from SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700552 *
553 * @param cb The callback pointer
554 * @param app_data The application context for this message
555 *
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530556 * @return struct sfe_ctx_instance * The SFE. context
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700557 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530558extern struct sfe_ctx_instance *sfe_ipv6_notify_register(sfe_ipv6_msg_callback_t cb, void *app_data);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700559
560/*
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530561 * sfe_ipv6_notify_unregister()
562 * Un-Register a notifier callback for IPv6 messages from SFE.
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700563 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530564extern void sfe_ipv6_notify_unregister(void);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700565
566/*
567 * sfe_ipv6_msg_init()
568 * IPv6 message init
569 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700570extern void sfe_ipv6_msg_init(struct sfe_ipv6_msg *nim, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700571 sfe_ipv6_msg_callback_t cb, void *app_data);
572
573/*
574 * sfe_tun6rd_tx()
575 * Transmit a tun6rd message to sfe engine
576 */
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530577sfe_tx_status_t sfe_tun6rd_tx(struct sfe_ctx_instance *sfe_ctx, struct sfe_tun6rd_msg *msg);
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700578
579/*
580 * sfe_tun6rd_msg_init()
581 * Initialize sfe_tun6rd msg.
582 */
Xiaoping Fan6a1672f2016-08-17 19:58:12 -0700583void sfe_tun6rd_msg_init(struct sfe_tun6rd_msg *ncm, u16 if_num, u32 type, u32 len,
Xiaoping Fan0493b2d2015-08-21 19:09:38 -0700584 void *cb, void *app_data);
585
Ratheesh Kannothdd382ed2021-11-23 09:36:30 +0530586/*
587 *
588 * sfe_is_l2_feature_enabled()
589 * l2 feature flag is enabled or disabled
590 */
591bool sfe_is_l2_feature_enabled(void);
592
Ratheesh Kannoth24fb1db2021-10-20 07:28:06 +0530593#endif /* __SFE_API_H */