Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 1 | /* |
| 2 | * sfe_drv.h |
| 3 | * simulated driver headers for shortcut forwarding engine. |
| 4 | * |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 5 | * Copyright (c) 2015,2016 The Linux Foundation. All rights reserved. |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 6 | * Permission to use, copy, modify, and/or distribute this software for |
| 7 | * any purpose with or without fee is hereby granted, provided that the |
| 8 | * above copyright notice and this permission notice appear in all copies. |
| 9 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
| 10 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
| 11 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
| 12 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
| 13 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
| 14 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
| 15 | * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
| 16 | */ |
| 17 | |
| 18 | #ifndef __SFE_DRV_H |
| 19 | #define __SFE_DRV_H |
| 20 | |
| 21 | #define MAX_VLAN_DEPTH 2 |
| 22 | #define SFE_VLAN_ID_NOT_CONFIGURED 0xfff |
| 23 | #define SFE_MC_IF_MAX 16 |
| 24 | |
| 25 | #define SFE_SPECIAL_INTERFACE_BASE 0x7f00 |
| 26 | #define SFE_SPECIAL_INTERFACE_IPV4 (SFE_SPECIAL_INTERFACE_BASE + 1) |
| 27 | #define SFE_SPECIAL_INTERFACE_IPV6 (SFE_SPECIAL_INTERFACE_BASE + 2) |
| 28 | #define SFE_SPECIAL_INTERFACE_IPSEC (SFE_SPECIAL_INTERFACE_BASE + 3) |
Xiaoping Fan | 6753961 | 2015-12-22 16:20:28 -0800 | [diff] [blame] | 29 | #define SFE_SPECIAL_INTERFACE_L2TP (SFE_SPECIAL_INTERFACE_BASE + 4) |
| 30 | #define SFE_SPECIAL_INTERFACE_PPTP (SFE_SPECIAL_INTERFACE_BASE + 5) |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 31 | |
| 32 | /** |
| 33 | * Rule creation & rule update flags. |
| 34 | */ |
| 35 | #define SFE_RULE_CREATE_FLAG_NO_SEQ_CHECK (1<<0) /**< Do not perform TCP sequence number checks */ |
| 36 | #define SFE_RULE_CREATE_FLAG_BRIDGE_FLOW (1<<1) /**< This is a pure bridge forwarding flow */ |
| 37 | #define SFE_RULE_CREATE_FLAG_ROUTED (1<<2) /**< Rule is for a routed connection */ |
| 38 | #define SFE_RULE_CREATE_FLAG_DSCP_MARKING (1<<3) /**< Rule has for a DSCP marking configured*/ |
| 39 | #define SFE_RULE_CREATE_FLAG_VLAN_MARKING (1<<4) /**< Rule has for a VLAN marking configured*/ |
| 40 | #define SFE_RULE_UPDATE_FLAG_CHANGE_MTU (1<<5) /**< Update MTU of connection interfaces */ |
| 41 | #define SFE_RULE_CREATE_FLAG_ICMP_NO_CME_FLUSH (1<<6)/**< Rule for not flushing CME on ICMP pkt */ |
| 42 | #define SFE_RULE_CREATE_FLAG_L2_ENCAP (1<<7) /**< consists of an encapsulating protocol that carries an IPv4 payload within it. */ |
| 43 | #define SFE_RULE_CREATE_FLAG_MC_JOIN (1<<8) /**< Interface has joined the flow */ |
| 44 | #define SFE_RULE_CREATE_FLAG_MC_LEAVE (1<<9) /**< Interface has left the flow */ |
| 45 | #define SFE_RULE_CREATE_FLAG_MC_UPDATE (1<<10)/**< Multicast Rule update */ |
| 46 | /** |
| 47 | * Rule creation validity flags. |
| 48 | */ |
| 49 | #define SFE_RULE_CREATE_CONN_VALID (1<<0) /**< IPv4 Connection is valid */ |
| 50 | #define SFE_RULE_CREATE_TCP_VALID (1<<1) /**< TCP Protocol fields are valid */ |
| 51 | #define SFE_RULE_CREATE_PPPOE_VALID (1<<2) /**< PPPoE fields are valid */ |
| 52 | #define SFE_RULE_CREATE_QOS_VALID (1<<3) /**< QoS fields are valid */ |
| 53 | #define SFE_RULE_CREATE_VLAN_VALID (1<<4) /**< VLAN fields are valid */ |
| 54 | #define SFE_RULE_CREATE_DSCP_MARKING_VALID (1<<5) /**< DSCP marking fields are valid */ |
| 55 | #define SFE_RULE_CREATE_VLAN_MARKING_VALID (1<<6) /**< VLAN marking fields are valid */ |
| 56 | #define SFE_RULE_CREATE_MC_NAT_VALID (1<<7) /**< Interface is configured with Source-NAT */ |
Xiaoping Fan | ee0afe0 | 2015-09-10 17:34:00 -0700 | [diff] [blame] | 57 | #define SFE_RULE_CREATE_DIRECTION_VALID (1<<8) /**< specify acceleration directions */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 58 | |
| 59 | typedef enum sfe_rule_sync_reason { |
Xiaoping Fan | 1253cd0 | 2015-11-11 18:02:20 -0800 | [diff] [blame] | 60 | SFE_RULE_SYNC_REASON_STATS, /* Sync is to synchronize stats */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 61 | SFE_RULE_SYNC_REASON_FLUSH, /* Sync is to flush a entry */ |
| 62 | SFE_RULE_SYNC_REASON_EVICT, /* Sync is to evict a entry */ |
Xiaoping Fan | 1253cd0 | 2015-11-11 18:02:20 -0800 | [diff] [blame] | 63 | SFE_RULE_SYNC_REASON_DESTROY /* Sync is to destroy a entry(requested by connection manager) */ |
| 64 | |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 65 | } sfe_rule_sync_reason_t; |
| 66 | |
| 67 | /** |
| 68 | * Tx command status |
| 69 | */ |
| 70 | typedef enum { |
| 71 | SFE_TX_SUCCESS = 0, /**< Success */ |
| 72 | SFE_TX_FAILURE, /**< Command failure other than descriptor not available */ |
| 73 | SFE_TX_FAILURE_QUEUE, /**< Command failure due to descriptor not available */ |
| 74 | SFE_TX_FAILURE_NOT_READY, /**< Command failure due to SFE state uninitialized */ |
| 75 | SFE_TX_FAILURE_TOO_LARGE, /**< Command is too large to fit in one message */ |
| 76 | SFE_TX_FAILURE_TOO_SHORT, /**< Command/Packet is shorter than expected size */ |
| 77 | SFE_TX_FAILURE_NOT_SUPPORTED, /**< Command/Packet not accepted for forwarding */ |
| 78 | SFE_TX_FAILURE_BAD_PARAM, /**< Command failure due to bad parameters */ |
| 79 | SFE_TX_FAILURE_NOT_ENABLED, /**< Command failure due to SFE feature is not enabled */ |
| 80 | } sfe_tx_status_t; |
| 81 | |
| 82 | /** |
| 83 | * Common response structure |
| 84 | */ |
| 85 | enum sfe_cmn_response { |
| 86 | SFE_CMN_RESPONSE_ACK, /**< Message Acknowledge */ |
| 87 | SFE_CMN_RESPONSE_EVERSION, /**< Message Version Error */ |
| 88 | SFE_CMN_RESPONSE_EINTERFACE, /**< Message Interface Error */ |
| 89 | SFE_CMN_RESPONSE_ELENGTH, /**< Message Length Error */ |
| 90 | SFE_CMN_RESPONSE_EMSG, /**< Message Error */ |
| 91 | SFE_CMM_RESPONSE_NOTIFY, /**< Message Independant of Request */ |
| 92 | SFE_CMN_RESPONSE_LAST |
| 93 | }; |
| 94 | |
| 95 | /** |
| 96 | * IPv4 bridge/route rule messages |
| 97 | */ |
| 98 | enum sfe_message_types { |
| 99 | SFE_TX_CREATE_RULE_MSG, /**< IPv4/6 create rule message */ |
| 100 | SFE_TX_DESTROY_RULE_MSG, /**< IPv4/6 destroy rule message */ |
| 101 | SFE_RX_CONN_STATS_SYNC_MSG, /**< IPv4/6 connection stats sync message */ |
| 102 | SFE_TX_CREATE_MC_RULE_MSG, /**< IPv4/6 multicast create rule message */ |
| 103 | SFE_TUN6RD_ADD_UPDATE_PEER, /**< Add/update peer for 6rd tunnel */ |
| 104 | SFE_MAX_MSG_TYPES, /**< IPv4/6 message max type number */ |
| 105 | }; |
| 106 | |
| 107 | /** |
| 108 | * Common message structure |
| 109 | */ |
| 110 | struct sfe_cmn_msg { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 111 | u16 version; /**< Version id for main message format */ |
| 112 | u16 interface; /**< Primary Key for all messages */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 113 | enum sfe_cmn_response response; /**< Primary response */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 114 | u32 type; /**< Decetralized request #, to be used to match response # */ |
| 115 | u32 error; /**< Decentralized specific error message, response == EMSG */ |
| 116 | u32 cb; /**< Place for callback pointer */ |
| 117 | u32 app_data; /**< Place for app data */ |
| 118 | u32 len; /**< What is the length of the message excluding this header */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 119 | }; |
| 120 | |
| 121 | /** |
| 122 | * Common 5 tuple structure |
| 123 | */ |
| 124 | struct sfe_ipv4_5tuple { |
| 125 | __be32 flow_ip; /**< Flow IP address */ |
| 126 | __be32 return_ip; /**< Return IP address */ |
| 127 | __be16 flow_ident; /**< Flow ident (e.g. TCP/UDP port) */ |
| 128 | __be16 return_ident; /**< Return ident (e.g. TCP/UDP port) */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 129 | u8 protocol; /**< Protocol number */ |
| 130 | u8 reserved[3]; /**< Padded for alignment */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 131 | }; |
| 132 | |
| 133 | /** |
| 134 | * Common 5 tuple structure |
| 135 | */ |
| 136 | struct sfe_ipv6_5tuple { |
| 137 | __be32 flow_ip[4]; /**< Flow IP address */ |
| 138 | __be32 return_ip[4]; /**< Return IP address */ |
| 139 | __be16 flow_ident; /**< Flow ident (e.g. TCP/UDP port) */ |
| 140 | __be16 return_ident; /**< Return ident (e.g. TCP/UDP port) */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 141 | u8 protocol; /**< Protocol number */ |
| 142 | u8 reserved[3]; /**< Padded for alignment */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 143 | }; |
| 144 | |
| 145 | /** |
| 146 | * Connection create structure |
| 147 | */ |
| 148 | struct sfe_ipv4_connection_rule { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 149 | u8 flow_mac[6]; /**< Flow MAC address */ |
| 150 | u8 return_mac[6]; /**< Return MAC address */ |
| 151 | s32 flow_interface_num; /**< Flow interface number */ |
| 152 | s32 return_interface_num; /**< Return interface number */ |
| 153 | s32 flow_top_interface_num; /* Top flow interface number */ |
| 154 | s32 return_top_interface_num;/* Top return interface number */ |
| 155 | u32 flow_mtu; /**< Flow interface`s MTU */ |
| 156 | u32 return_mtu; /**< Return interface`s MTU */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 157 | __be32 flow_ip_xlate; /**< Translated flow IP address */ |
| 158 | __be32 return_ip_xlate; /**< Translated return IP address */ |
| 159 | __be16 flow_ident_xlate; /**< Translated flow ident (e.g. port) */ |
| 160 | __be16 return_ident_xlate; /**< Translated return ident (e.g. port) */ |
| 161 | }; |
| 162 | |
| 163 | /** |
| 164 | * Connection create structure |
| 165 | */ |
| 166 | struct sfe_ipv6_connection_rule { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 167 | u8 flow_mac[6]; /**< Flow MAC address */ |
| 168 | u8 return_mac[6]; /**< Return MAC address */ |
| 169 | s32 flow_interface_num; /**< Flow interface number */ |
| 170 | s32 return_interface_num; /**< Return interface number */ |
| 171 | s32 flow_top_interface_num; /* Top flow interface number */ |
| 172 | s32 return_top_interface_num;/* Top return interface number */ |
| 173 | u32 flow_mtu; /**< Flow interface's MTU */ |
| 174 | u32 return_mtu; /**< Return interface's MTU */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | /** |
| 178 | * TCP connection rule structure |
| 179 | */ |
| 180 | struct sfe_protocol_tcp_rule { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 181 | u32 flow_max_window; /**< Flow direction's largest seen window */ |
| 182 | u32 return_max_window; /**< Return direction's largest seen window */ |
| 183 | u32 flow_end; /**< Flow direction's largest seen sequence + segment length */ |
| 184 | u32 return_end; /**< Return direction's largest seen sequence + segment length */ |
| 185 | u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */ |
| 186 | u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */ |
| 187 | u8 flow_window_scale; /**< Flow direction's window scaling factor */ |
| 188 | u8 return_window_scale; /**< Return direction's window scaling factor */ |
| 189 | u16 reserved; /**< Padded for alignment */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | /** |
| 193 | * PPPoE connection rules structure |
| 194 | */ |
| 195 | struct sfe_pppoe_rule { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 196 | u16 flow_pppoe_session_id; /**< Flow direction`s PPPoE session ID. */ |
| 197 | u16 flow_pppoe_remote_mac[3]; /**< Flow direction`s PPPoE Server MAC address */ |
| 198 | u16 return_pppoe_session_id; /**< Return direction's PPPoE session ID. */ |
| 199 | u16 return_pppoe_remote_mac[3]; /**< Return direction's PPPoE Server MAC address */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 200 | }; |
| 201 | |
| 202 | /** |
| 203 | * QoS connection rule structure |
| 204 | */ |
| 205 | struct sfe_qos_rule { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 206 | u32 flow_qos_tag; /**< QoS tag associated with this rule for flow direction */ |
| 207 | u32 return_qos_tag; /**< QoS tag associated with this rule for return direction */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 208 | }; |
| 209 | |
| 210 | /** |
| 211 | * DSCP connection rule structure |
| 212 | */ |
| 213 | struct sfe_dscp_rule { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 214 | u8 flow_dscp; /**< Egress DSCP value for flow direction */ |
| 215 | u8 return_dscp; /**< Egress DSCP value for return direction */ |
| 216 | u8 reserved[2]; /**< Padded for alignment */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 217 | }; |
| 218 | |
| 219 | /** |
| 220 | * VLAN connection rule structure |
| 221 | */ |
| 222 | struct sfe_vlan_rule { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 223 | u32 ingress_vlan_tag; /**< VLAN Tag for the ingress packets */ |
| 224 | u32 egress_vlan_tag; /**< VLAN Tag for egress packets */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 225 | }; |
| 226 | |
| 227 | /** |
Xiaoping Fan | ee0afe0 | 2015-09-10 17:34:00 -0700 | [diff] [blame] | 228 | * Acceleration direction rule structure |
| 229 | * Sometimes we just want to accelerate traffic in one direction but not in another. |
| 230 | */ |
| 231 | struct sfe_acceleration_direction_rule { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 232 | u8 flow_accel; /**< Accelerate in flow direction */ |
| 233 | u8 return_accel; /**< Accelerate in return direction */ |
| 234 | u8 reserved[2]; /**< Padded for alignment */ |
Xiaoping Fan | ee0afe0 | 2015-09-10 17:34:00 -0700 | [diff] [blame] | 235 | }; |
| 236 | |
| 237 | /** |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 238 | * The IPv4 rule create sub-message structure. |
| 239 | */ |
| 240 | struct sfe_ipv4_rule_create_msg { |
| 241 | /* Request */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 242 | u16 valid_flags; /**< Bit flags associated with the validity of parameters */ |
| 243 | u16 rule_flags; /**< Bit flags associated with the rule */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 244 | |
| 245 | struct sfe_ipv4_5tuple tuple; /**< Holds values of the 5 tuple */ |
| 246 | |
| 247 | struct sfe_ipv4_connection_rule conn_rule; /**< Basic connection specific data */ |
| 248 | struct sfe_protocol_tcp_rule tcp_rule; /**< TCP related accleration parameters */ |
| 249 | struct sfe_pppoe_rule pppoe_rule; /**< PPPoE related accleration parameters */ |
| 250 | struct sfe_qos_rule qos_rule; /**< QoS related accleration parameters */ |
| 251 | struct sfe_dscp_rule dscp_rule; /**< DSCP related accleration parameters */ |
| 252 | struct sfe_vlan_rule vlan_primary_rule; /**< Primary VLAN related accleration parameters */ |
| 253 | struct sfe_vlan_rule vlan_secondary_rule; /**< Secondary VLAN related accleration parameters */ |
Xiaoping Fan | ee0afe0 | 2015-09-10 17:34:00 -0700 | [diff] [blame] | 254 | #ifdef CONFIG_XFRM |
| 255 | struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/ |
| 256 | #endif |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 257 | /* Response */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 258 | u32 index; /**< Slot ID for cache stats to host OS */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 259 | }; |
| 260 | |
| 261 | /** |
| 262 | * The IPv4 rule destroy sub-message structure. |
| 263 | */ |
| 264 | struct sfe_ipv4_rule_destroy_msg { |
| 265 | struct sfe_ipv4_5tuple tuple; /**< Holds values of the 5 tuple */ |
| 266 | }; |
| 267 | |
| 268 | /** |
| 269 | * The SFE IPv4 rule sync structure. |
| 270 | */ |
| 271 | struct sfe_ipv4_conn_sync { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 272 | u32 index; /**< Slot ID for cache stats to host OS */ |
| 273 | u8 protocol; /**< Protocol number */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 274 | __be32 flow_ip; /**< Flow IP address */ |
| 275 | __be32 flow_ip_xlate; /**< Translated flow IP address */ |
| 276 | __be16 flow_ident; /**< Flow ident (e.g. port) */ |
| 277 | __be16 flow_ident_xlate; /**< Translated flow ident (e.g. port) */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 278 | u32 flow_max_window; /**< Flow direction's largest seen window */ |
| 279 | u32 flow_end; /**< Flow direction's largest seen sequence + segment length */ |
| 280 | u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */ |
| 281 | u32 flow_rx_packet_count; /**< Flow interface's RX packet count */ |
| 282 | u32 flow_rx_byte_count; /**< Flow interface's RX byte count */ |
| 283 | u32 flow_tx_packet_count; /**< Flow interface's TX packet count */ |
| 284 | u32 flow_tx_byte_count; /**< Flow interface's TX byte count */ |
| 285 | u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */ |
| 286 | u16 flow_pppoe_remote_mac[3]; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 287 | /**< Flow interface's PPPoE remote server MAC address if there is any */ |
| 288 | __be32 return_ip; /**< Return IP address */ |
| 289 | __be32 return_ip_xlate; /**< Translated return IP address */ |
| 290 | __be16 return_ident; /**< Return ident (e.g. port) */ |
| 291 | __be16 return_ident_xlate; /**< Translated return ident (e.g. port) */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 292 | u32 return_max_window; /**< Return direction's largest seen window */ |
| 293 | u32 return_end; /**< Return direction's largest seen sequence + segment length */ |
| 294 | u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */ |
| 295 | u32 return_rx_packet_count; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 296 | /**< Return interface's RX packet count */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 297 | u32 return_rx_byte_count; /**< Return interface's RX byte count */ |
| 298 | u32 return_tx_packet_count; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 299 | /**< Return interface's TX packet count */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 300 | u32 return_tx_byte_count; /**< Return interface's TX byte count */ |
| 301 | u16 return_pppoe_session_id; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 302 | /**< Return interface`s PPPoE session ID. */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 303 | u16 return_pppoe_remote_mac[3]; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 304 | /**< Return interface's PPPoE remote server MAC address if there is any */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 305 | u32 inc_ticks; /**< Number of ticks since the last sync */ |
| 306 | u32 reason; /**< Reason for the sync */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 307 | |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 308 | u8 flags; /**< Bit flags associated with the rule */ |
| 309 | u32 qos_tag; /**< QoS Tag */ |
| 310 | u32 cause; /**< Flush Cause */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 311 | }; |
| 312 | |
| 313 | /* |
| 314 | * Message structure to send/receive IPv4 bridge/route commands |
| 315 | */ |
| 316 | struct sfe_ipv4_msg { |
| 317 | struct sfe_cmn_msg cm; /**< Message Header */ |
| 318 | union { |
| 319 | struct sfe_ipv4_rule_create_msg rule_create; /**< Message: rule create */ |
| 320 | struct sfe_ipv4_rule_destroy_msg rule_destroy; /**< Message: rule destroy */ |
| 321 | struct sfe_ipv4_conn_sync conn_stats; /**< Message: connection stats sync */ |
| 322 | } msg; |
| 323 | }; |
| 324 | |
| 325 | /** |
| 326 | * Callback to be called when IPv4 message is received |
| 327 | */ |
| 328 | typedef void (*sfe_ipv4_msg_callback_t)(void *app_data, struct sfe_ipv4_msg *msg); |
| 329 | |
| 330 | /** |
| 331 | * The IPv6 rule create sub-message structure. |
| 332 | */ |
| 333 | struct sfe_ipv6_rule_create_msg { |
| 334 | /* |
| 335 | * Request |
| 336 | */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 337 | u16 valid_flags; /**< Bit flags associated with the validity of parameters */ |
| 338 | u16 rule_flags; /**< Bit flags associated with the rule */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 339 | struct sfe_ipv6_5tuple tuple; /**< Holds values of the 5 tuple */ |
| 340 | struct sfe_ipv6_connection_rule conn_rule; /**< Basic connection specific data */ |
| 341 | struct sfe_protocol_tcp_rule tcp_rule; /**< Protocol related accleration parameters */ |
| 342 | struct sfe_pppoe_rule pppoe_rule; /**< PPPoE related accleration parameters */ |
| 343 | struct sfe_qos_rule qos_rule; /**< QoS related accleration parameters */ |
| 344 | struct sfe_dscp_rule dscp_rule; /**< DSCP related accleration parameters */ |
| 345 | struct sfe_vlan_rule vlan_primary_rule; /**< VLAN related accleration parameters */ |
| 346 | struct sfe_vlan_rule vlan_secondary_rule; /**< VLAN related accleration parameters */ |
Xiaoping Fan | ee0afe0 | 2015-09-10 17:34:00 -0700 | [diff] [blame] | 347 | #ifdef CONFIG_XFRM |
| 348 | struct sfe_acceleration_direction_rule direction_rule;/* Direction related accleration parameters*/ |
| 349 | #endif |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 350 | /* |
| 351 | * Response |
| 352 | */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 353 | u32 index; /**< Slot ID for cache stats to host OS */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 354 | }; |
| 355 | |
| 356 | /** |
| 357 | * The IPv6 rule destroy sub-message structure. |
| 358 | */ |
| 359 | struct sfe_ipv6_rule_destroy_msg { |
| 360 | struct sfe_ipv6_5tuple tuple; /**< Holds values of the 5 tuple */ |
| 361 | }; |
| 362 | |
| 363 | /** |
| 364 | * The SFE IPv6 rule sync structure. |
| 365 | */ |
| 366 | struct sfe_ipv6_conn_sync { |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 367 | u32 index; /**< Slot ID for cache stats to host OS */ |
| 368 | u8 protocol; /**< Protocol number */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 369 | __be32 flow_ip[4]; /**< Flow IP address */ |
| 370 | __be16 flow_ident; /**< Flow ident (e.g. port) */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 371 | u32 flow_max_window; /**< Flow direction's largest seen window */ |
| 372 | u32 flow_end; /**< Flow direction's largest seen sequence + segment length */ |
| 373 | u32 flow_max_end; /**< Flow direction's largest seen ack + max(1, win) */ |
| 374 | u32 flow_rx_packet_count; /**< Flow interface's RX packet count */ |
| 375 | u32 flow_rx_byte_count; /**< Flow interface's RX byte count */ |
| 376 | u32 flow_tx_packet_count; /**< Flow interface's TX packet count */ |
| 377 | u32 flow_tx_byte_count; /**< Flow interface's TX byte count */ |
| 378 | u16 flow_pppoe_session_id; /**< Flow interface`s PPPoE session ID. */ |
| 379 | u16 flow_pppoe_remote_mac[3]; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 380 | /**< Flow interface's PPPoE remote server MAC address if there is any */ |
| 381 | __be32 return_ip[4]; /**< Return IP address */ |
| 382 | __be16 return_ident; /**< Return ident (e.g. port) */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 383 | u32 return_max_window; /**< Return direction's largest seen window */ |
| 384 | u32 return_end; /**< Return direction's largest seen sequence + segment length */ |
| 385 | u32 return_max_end; /**< Return direction's largest seen ack + max(1, win) */ |
| 386 | u32 return_rx_packet_count; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 387 | /**< Return interface's RX packet count */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 388 | u32 return_rx_byte_count; /**< Return interface's RX byte count */ |
| 389 | u32 return_tx_packet_count; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 390 | /**< Return interface's TX packet count */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 391 | u32 return_tx_byte_count; /**< Return interface's TX byte count */ |
| 392 | u16 return_pppoe_session_id; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 393 | /**< Return interface`s PPPoE session ID. */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 394 | u16 return_pppoe_remote_mac[3]; |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 395 | /**< Return interface's PPPoE remote server MAC address if there is any */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 396 | u32 inc_ticks; /**< Number of ticks since the last sync */ |
| 397 | u32 reason; /**< Reason for the sync */ |
| 398 | u8 flags; /**< Bit flags associated with the rule */ |
| 399 | u32 qos_tag; /**< QoS Tag */ |
| 400 | u32 cause; /**< Flush cause associated with the rule */ |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 401 | }; |
| 402 | |
| 403 | /** |
| 404 | * Message structure to send/receive IPv6 bridge/route commands |
| 405 | */ |
| 406 | struct sfe_ipv6_msg { |
| 407 | struct sfe_cmn_msg cm; /**< Message Header */ |
| 408 | union { |
| 409 | struct sfe_ipv6_rule_create_msg rule_create; /**< Message: rule create */ |
| 410 | struct sfe_ipv6_rule_destroy_msg rule_destroy; /**< Message: rule destroy */ |
| 411 | struct sfe_ipv6_conn_sync conn_stats; /**< Message: stats sync */ |
| 412 | } msg; |
| 413 | }; |
| 414 | |
| 415 | /** |
| 416 | * Callback to be called when IPv6 message is received |
| 417 | */ |
| 418 | typedef void (*sfe_ipv6_msg_callback_t)(void *app_data, struct sfe_ipv6_msg *msg); |
| 419 | |
| 420 | /** |
| 421 | * 6rd tunnel peer addr. |
| 422 | */ |
| 423 | struct sfe_tun6rd_set_peer_msg { |
| 424 | __be32 ipv6_address[4]; /* The peer's ipv6 addr*/ |
| 425 | __be32 dest; /* The peer's ipv4 addr*/ |
| 426 | }; |
| 427 | |
| 428 | /** |
| 429 | * Message structure to send/receive 6rd tunnel messages |
| 430 | */ |
| 431 | struct sfe_tun6rd_msg { |
| 432 | struct sfe_cmn_msg cm; /* Message Header */ |
| 433 | union { |
| 434 | struct sfe_tun6rd_set_peer_msg peer; /* Message: add/update peer */ |
| 435 | } msg; |
| 436 | }; |
| 437 | |
| 438 | /* |
| 439 | * sfe driver context instance |
| 440 | */ |
| 441 | struct sfe_drv_ctx_instance { |
| 442 | int not_used; |
| 443 | }; |
| 444 | |
| 445 | /* |
| 446 | * sfe_drv_ipv4_max_conn_count() |
| 447 | * Return the maximum number of IPv4 connections that the sfe acceleration engine supports |
| 448 | * |
| 449 | * @return int The number of connections that can be accelerated by the sfe |
| 450 | */ |
| 451 | int sfe_drv_ipv4_max_conn_count(void); |
| 452 | |
| 453 | /* |
| 454 | * sfe_drv_ipv4_tx() |
| 455 | * Transmit an IPv4 message to the sfe |
| 456 | * |
| 457 | * @param sfe_drv_ctx sfe driver context |
| 458 | * @param msg The IPv4 message |
| 459 | * |
| 460 | * @return sfe_tx_status_t The status of the Tx operation |
| 461 | */ |
| 462 | extern sfe_tx_status_t sfe_drv_ipv4_tx(struct sfe_drv_ctx_instance *sfe_drv_ctx, struct sfe_ipv4_msg *msg); |
| 463 | |
| 464 | /* |
| 465 | * sfe_drv_ipv4_notify_register() |
| 466 | * Register a notifier callback for IPv4 messages from sfe driver |
| 467 | * |
| 468 | * @param cb The callback pointer |
| 469 | * @param app_data The application context for this message |
| 470 | * |
| 471 | * @return struct sfe_drv_ctx_instance * The sfe driver context |
| 472 | */ |
| 473 | extern struct sfe_drv_ctx_instance *sfe_drv_ipv4_notify_register(sfe_ipv4_msg_callback_t cb, void *app_data); |
| 474 | |
| 475 | /* |
| 476 | * sfe_drv_ipv4_notify_unregister() |
| 477 | * Un-Register a notifier callback for IPv4 messages from sfe driver |
| 478 | */ |
| 479 | extern void sfe_drv_ipv4_notify_unregister(void); |
| 480 | |
| 481 | /* |
| 482 | * sfe_ipv4_msg_init() |
| 483 | * IPv4 message init |
| 484 | */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 485 | extern void sfe_ipv4_msg_init(struct sfe_ipv4_msg *nim, u16 if_num, u32 type, u32 len, |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 486 | sfe_ipv4_msg_callback_t cb, void *app_data); |
| 487 | |
| 488 | /* |
| 489 | * sfe_drv_ipv6_max_conn_count() |
| 490 | * Return the maximum number of IPv6 connections that the sfe acceleration engine supports |
| 491 | * |
| 492 | * @return int The number of connections that can be accelerated by the sfe |
| 493 | */ |
| 494 | int sfe_drv_ipv6_max_conn_count(void); |
| 495 | |
| 496 | /* |
| 497 | * sfe_drv_ipv6_tx() |
| 498 | * Transmit an IPv6 message to the sfe |
| 499 | * |
| 500 | * @param sfe_drv_ctx sfe driver context |
| 501 | * @param msg The IPv6 message |
| 502 | * |
| 503 | * @return sfe_tx_status_t The status of the Tx operation |
| 504 | */ |
| 505 | extern sfe_tx_status_t sfe_drv_ipv6_tx(struct sfe_drv_ctx_instance *sfe_drv_ctx, struct sfe_ipv6_msg *msg); |
| 506 | |
| 507 | /* |
| 508 | * sfe_drv_ipv6_notify_register() |
| 509 | * Register a notifier callback for IPv6 messages from sfe driver |
| 510 | * |
| 511 | * @param cb The callback pointer |
| 512 | * @param app_data The application context for this message |
| 513 | * |
| 514 | * @return struct sfe_drv_ctx_instance * The sfe driver context |
| 515 | */ |
| 516 | extern struct sfe_drv_ctx_instance *sfe_drv_ipv6_notify_register(sfe_ipv6_msg_callback_t cb, void *app_data); |
| 517 | |
| 518 | /* |
| 519 | * sfe_drv_ipv6_notify_unregister() |
| 520 | * Un-Register a notifier callback for IPv6 messages from sfe driver |
| 521 | */ |
| 522 | extern void sfe_drv_ipv6_notify_unregister(void); |
| 523 | |
| 524 | /* |
| 525 | * sfe_ipv6_msg_init() |
| 526 | * IPv6 message init |
| 527 | */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 528 | extern void sfe_ipv6_msg_init(struct sfe_ipv6_msg *nim, u16 if_num, u32 type, u32 len, |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 529 | sfe_ipv6_msg_callback_t cb, void *app_data); |
| 530 | |
| 531 | /* |
| 532 | * sfe_tun6rd_tx() |
| 533 | * Transmit a tun6rd message to sfe engine |
| 534 | */ |
| 535 | sfe_tx_status_t sfe_tun6rd_tx(struct sfe_drv_ctx_instance *sfe_ctx, struct sfe_tun6rd_msg *msg); |
| 536 | |
| 537 | /* |
| 538 | * sfe_tun6rd_msg_init() |
| 539 | * Initialize sfe_tun6rd msg. |
| 540 | */ |
Xiaoping Fan | 6a1672f | 2016-08-17 19:58:12 -0700 | [diff] [blame] | 541 | void sfe_tun6rd_msg_init(struct sfe_tun6rd_msg *ncm, u16 if_num, u32 type, u32 len, |
Xiaoping Fan | 0493b2d | 2015-08-21 19:09:38 -0700 | [diff] [blame] | 542 | void *cb, void *app_data); |
| 543 | |
| 544 | #endif /* __SFE_DRV_H */ |