1 #ifndef _PASAHOST_H
2 #define _PASAHOST_H
3 /**
4 * @file pasahost.h
5 *
6 * @brief
7 * This file defines constants, data structures and macros used
8 * among the PA LLD, SA LLD and the host.
9 *
10 * \par
11 * NOTE:
12 * (C) Copyright 2009-2013 Texas Instruments, Inc.
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 *
18 * Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the
24 * distribution.
25 *
26 * Neither the name of Texas Instruments Incorporated nor the names of
27 * its contributors may be used to endorse or promote products derived
28 * from this software without specific prior written permission.
29 *
30 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
31 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
33 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
34 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
35 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
36 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
37 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
38 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
39 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
40 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
41 *
42 */
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
48 /** @defgroup pasaho_if_module PA/SA/Host Interface
49 * @{
50 */
51 /** @} */
53 /** @defgroup pasaho_if_macros PA/SA/Host Macros
54 * @ingroup pasaho_if_module
55 */
57 /** @defgroup pasaho_if_structures PA/SA/Host Data Structures
58 * @ingroup pasaho_if_module
59 */
61 /** @defgroup pasaho_if_constants PA/SA/Host Constants (enum's and define's)
62 * @ingroup pasaho_if_module
63 */
67 /**
68 * @defgroup pasahoCommands PA/SA/Host Commands
69 * @ingroup pasaho_if_constants
70 * @{
71 *
72 * @name PA/SA/Host Commands
73 *
74 * Define PASS Firmware Commands
75 * These values are placed in the 3 msbits of the protocol specific information
76 */
77 /*@{*/
78 /**
79 * @def PASAHO_CONFIGURE
80 * PA/SA Configuration command
81 */
83 #define PASAHO_CONFIGURE 4
85 /* PA commands for receive packet PDSPs */
86 /**
87 * @def PASAHO_PARX_PARSECMD
88 * Instruct PDSP to parse the receive packet
89 */
91 #define PASAHO_PARX_PARSECMD 0
93 /**
94 * @def PASAHO_PARX_MULTI_ROUTE
95 * Instruct PDSP to perform multiple routing
96 */
98 #define PASAHO_PARX_MULTI_ROUTE 5
100 /* PA commands for modify packet PDSPs */
101 /**
102 * @def PASAHO_PAMOD_CMPT_CHKSUM
103 * Instruct PDSP to compute checksum
104 */
106 #define PASAHO_PAMOD_CMPT_CHKSUM 0
108 /**
109 * @def PASAHO_PAMOD_CMPT_CRC
110 * Instruct PDSP to compute CRC
111 */
113 #define PASAHO_PAMOD_CMPT_CRC 1
115 /**
116 * @def PASAHO_PAMOD_PATCH
117 * Instruct PDSP to perform blind patch
118 */
120 #define PASAHO_PAMOD_PATCH 2
122 /**
123 * @def PASAHO_PAMOD_NROUTE
124 * Provide PDSP with the next routing information
125 */
127 #define PASAHO_PAMOD_NROUTE 3
129 /**
130 * @def PASAHO_PAMOD_REPORT_TIMESTAMP
131 * Instruct PDSP to report the system timestamp at the timestamp field of the packet descriptor
132 * when the tx packet is delivered out of the PASS
133 */
135 #define PASAHO_PAMOD_REPORT_TIMESTAMP 6
138 /**
139 * @def PASAHO_PAMOD_GROUP_7
140 * Define this group command so that several command can share the same command code. They will be distinguished
141 * by its unique 5-bit sub-command code as defined at
142 */
144 #define PASAHO_PAMOD_GROUP_7 7
147 /**
148 * @def PASAHO_PAMOD_DUMMY
149 * No action is required. It is for SA alignment only
150 */
152 #define PASAHO_PAMOD_DUMMY PASAHO_PAMOD_GROUP_7
154 /**
155 * @def PASAHO_PAMOD_IP_FRAGMENT
156 * Instruct PDSP to perform IPv4 fragmentation. The transmit IP packets will be divided into smaller
157 * IP fragments with the updated IPv4 header and checksum based on the specified MTU size and forwarded
158 * to the destination specified by the next route command. It is up to the module user to format the
159 * correct IPv4 header. The IP fragmentation command will be ignored if any error is detected.
160 */
161 #define PASAHO_PAMOD_IP_FRAGMENT PASAHO_PAMOD_GROUP_7
163 /**
164 * @def PASAHO_PAMOD_PATCH_MSG_LEN
165 * Instruct PDSP to perform message length patching after IPv4 fragmentation operation. This command is
166 * valid only if it is in conjunction with the PASAHO_PAMOD_IP_FRAGMENT command.
167 */
168 #define PASAHO_PAMOD_PATCH_MSG_LEN PASAHO_PAMOD_GROUP_7
170 /* SA commands */
171 /**
172 * @def PASAHO_SA_LONG_INFO
173 * Provide SA with the packet parsing information in the long form
174 */
176 #define PASAHO_SA_LONG_INFO 0
178 /**
179 * @def PASAHO_SA_SHORT_INFO
180 * Provide SA with the packet parsing information in the short form
181 */
183 #define PASAHO_SA_SHORT_INFO 1
186 /**
187 * @def PASAHO_SA_AIR_INFO
188 * Provide SA with the packet parsing information for the air ciphering
189 * operation
190 */
192 #define PASAHO_SA_AIR_INFO 2
195 /*@}*/
196 /** @} */
198 /** @name PASAHO Common Macros
199 *
200 */
201 /*@{*/
203 /**
204 * @ingroup pasaho_if_macros
205 * @brief PASAHO_READ_BITFIELD is used to read the specific bit fields
206 *
207 * @details It is one of the main macros for accessing configuration bit fields
208 * Input parameter a contains bit field
209 * b is bit offset withing bit field
210 * c is number of bits used by that parameter
211 */
213 #define PASAHO_READ_BITFIELD(a,b,c) (((a)>>(b)) & ((1UL<<(c))-1))
215 /**
216 * @ingroup ingroup pasaho_if_macros
217 * @brief PASAHO_SET_BITFIELD is used to set the specific bit fields
218 *
219 * @details It is one of the main macros for accessing configuration bit fields
220 * Input parameter a contains bit field
221 * b is bit offset withing bit field
222 * c is number of bits used by that parameter
223 * x is new value of parameter that is packed in this bit field
224 *
225 * @note It enforces strict setting to prevent overflow into other bits, would
226 * cost program space for additional protection.
227 */
229 #define PASAHO_SET_BITFIELD(a,x,b,c) (a) &= ~(((1UL<<(c))-1)<<(b)), \
230 (a) |= (((x) & ((1UL<<(c))-1))<<(b))
232 /**
233 * @ingroup ingroup pasaho_if_macros
234 * @brief PASAHO_SET_CMDID is used to set the command ID
235 */
236 #define PASAHO_SET_CMDID(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 29,3)
238 /**
239 * @ingroup ingroup pasaho_if_macros
240 * @brief PASAHO_PACFG_CMD is used to set the PA configuration command only
241 */
242 #define PASAHO_PACFG_CMD (((uint32_t)PASAHO_CONFIGURE << 5) << 24)
244 /*@}*/ /* @name PASAHO Common Macros */
247 /**
248 * @defgroup pasahoHeaderTypes PASS Header Types
249 * @ingroup pasaho_if_constants
250 * @{
251 *
252 * @name PASS Header Types
253 * Definition of protocol header types used at the PASS PDSP Firmwase. In the
254 * long info field these values specify what the next header type will be
255 * at the next parse offset
256 */
257 /*@{*/
259 typedef enum {
261 PASAHO_HDR_MAC = 0, /**< MAC */
262 PASAHO_HDR_VLAN, /**< VLAN */
263 PASAHO_HDR_MPLS, /**< MPLS */
264 PASAHO_HDR_IPv4, /**< IPv4 */
265 PASAHO_HDR_IPv6, /**< IPv6 */
266 PASAHO_HDR_IPv6_EXT_HOP, /**< IPv6 hop by hop extenstion header */
267 PASAHO_HDR_IPv6_EXT_ROUTE, /**< IPv6 routing extenstion header */
268 PASAHO_HDR_IPv6_EXT_FRAG, /**< IPv6 fragmentation extention header */
269 PASAHO_HDR_IPv6_EXT_DEST, /**< IPv6 destination options header */
270 PASAHO_HDR_GRE, /**< Generic Routing Encapsulation header */
271 PASAHO_HDR_ESP, /**< Encapsulating Security Payload header */
272 PASAHO_HDR_ESP_DECODED, /**< Decoded Encapsulating Security Payload header */
273 PASAHO_HDR_AUTH, /**< Authentication header */
274 PASAHO_HDR_CUSTOM_C1, /**< Custom classify 1 header */
275 PASAHO_HDR_FORCE_LOOKUP, /**< A contrived header type used with custom SRIO to force
276 * a parse after looking at only the SRIO L0-L2 */
277 PASAHO_HDR_UNKNOWN, /**< Next header type is unknown */
278 PASAHO_HDR_UDP, /**< User Datagram Protocol header */
279 PASAHO_HDR_UDP_LITE, /**< Lightweight User Datagram Protocol header */
280 PASAHO_HDR_TCP, /**< Transmission Control Protocol header */
281 PASAHO_HDR_CUSTOM_C2 /**< Custom classify 2 header */
283 } pasaho_HeaderType_e;
284 /*@}*/
285 /** @} */
287 /**
288 * @defgroup pasahoSubCmdCode PASS Sub-Command Code
289 * @ingroup pasaho_if_constants
290 * @{
291 *
292 * @name PASS Sub-Command Code
293 * Definition of the 5-bit sub-command codes which is used to specify the group 7 commands.
294 */
295 /*@{*/
297 typedef enum {
299 PASAHO_SUB_CMD_DUMMY = 0, /**< Dummy */
300 PASAHO_SUB_CMD_IP_FRAG, /**< IPv4 fragmentation */
301 PASAHO_SUB_CMD_PATCH_MSG_LEN /**< Message length Patching */
302 } pasaho_SubCmdCode_e;
303 /*@}*/
304 /** @} */
306 /**
307 * @defgroup pasahoPktType PASS Packet Type
308 * @ingroup pasaho_if_constants
309 * @{
310 *
311 * @name PASS Packet Type
312 * Definition of the MAC or IP packet types.
313 */
314 /*@{*/
316 typedef enum {
318 PASAHO_PKT_TYPE_UNICAST = 0, /**< Unicast MAC/IP */
319 PASAHO_PKT_TYPE_BROADCAST, /**< Broadcast MAC/IP */
320 PASAHO_PKT_TYPE_MULTICAST /**< Multicast MAC/IP */
321 } pasaho_pktType_e;
322 /*@}*/
323 /** @} */
327 /**
328 * @ingroup pasaho_if_structures
329 * @brief pasahoCmdInfo_t defines the general short command information
330 *
331 */
333 typedef struct pasahoCmdInfo_s {
334 uint32_t word0; /**< Control block word 0 */
335 } pasahoCmdInfo_t;
337 /**
338 * @ingroup pasaho_if_structures
339 * @brief pasahoLongInfo_t defines the packet parsing information in the long format.
340 * The information is structured as an array of 32 bit values. These values
341 * are broken down through macros. This allows the representation to be
342 * endian independent to the hardware which operates only on 32 bit values.
343 *
344 * @details
345 */
347 typedef struct pasahoLongInfo_s {
349 uint32_t word0; /**< Control block word 0 */
350 uint32_t word1; /**< Control block word 1 */
351 uint32_t word2; /**< Control block word 2 */
352 uint32_t word3; /**< Control block word 3 */
353 uint32_t word4; /**< Control block word 4 */
354 uint32_t word5; /**< Control block word 5 */
356 } pasahoLongInfo_t;
358 /**
359 * @defgroup PASAHO_long_info_command_macros PASAHO Long Info Command Macros
360 * @ingroup pasaho_if_macros
361 * @{
362 * @name PASAHO Long Info Command Macros
363 * Macros used by the PASAHO Long Info Command
364 */
365 /*@{*/
367 #define PASAHO_LINFO_READ_CMDID(x) PASAHO_READ_BITFIELD((x)->word0,29,3) /**< Extract the command ID defined at @ref pasahoCommands */
368 #define PASAHO_LINFO_READ_RECLEN(x) PASAHO_READ_BITFIELD((x)->word0,24,5) /**< Extract the block length */
369 #define PASAHO_LINFO_READ_START_OFFSET(x) PASAHO_READ_BITFIELD((x)->word0,0,16) /**< Extract the next parse start offset */
371 #define PASAHO_LINFO_IS_MAC_BROADCAST(x) PASAHO_READ_BITFIELD((x)->word0,16,1) /**< Indicate whether it is a broadcast MAC packet */
372 #define PASAHO_LINFO_IS_MAC_MULTICAST(x) PASAHO_READ_BITFIELD((x)->word0,17,1) /**< Indicate whether it is a multicast MAC packet */
373 #define PASAHO_LINFO_READ_MAC_PKTTYPE(x) PASAHO_READ_BITFIELD((x)->word0,16,2) /**< Extract the MAC packet type */
375 #define PASAHO_LINFO_IS_IP_BROADCAST(x) PASAHO_READ_BITFIELD((x)->word0,18,1) /**< Indicate whether it is a broadcast IP packet */
376 #define PASAHO_LINFO_IS_IP_MULTICAST(x) PASAHO_READ_BITFIELD((x)->word0,19,1) /**< Indicate whether it is a multicast IP packet */
377 #define PASAHO_LINFO_READ_IP_PKTTYPE(x) PASAHO_READ_BITFIELD((x)->word0,18,2) /**< Extract the IP packet type */
379 #define PASAHO_LINFO_READ_END_OFFSET(x) PASAHO_READ_BITFIELD((x)->word1,16,16) /**< Extract the end of packet parse offset */
380 #define PASAHO_LINFO_READ_EIDX(x) PASAHO_READ_BITFIELD((x)->word1,11,5) /**< Extract the error index */
381 #define PASAHO_LINFO_READ_PMATCH(x) PASAHO_READ_BITFIELD((x)->word1,10,1) /**< Extract the previous match flag */
382 #define PASAHO_LINFO_READ_L1_PDSP_ID(x) PASAHO_READ_BITFIELD((x)->word1,6,3) /**< Extract the first parse module ID */
383 #define PASAHO_LINFO_READ_L1_IDX(x) PASAHO_READ_BITFIELD((x)->word1,0,6) /**< Extract the first parse module match index */
385 #define PASAHO_LINFO_READ_L3_OFFSET(x) PASAHO_READ_BITFIELD((x)->word2,24,8) /**< Extract the offset to the level 3 header */
386 #define PASAHO_LINFO_READ_L4_OFFSET(x) PASAHO_READ_BITFIELD((x)->word2,16,8) /**< Extract the offset to the level 4 header */
387 #define PASAHO_LINFO_READ_L5_OFFSET(x) PASAHO_READ_BITFIELD((x)->word2,8,8) /**< Extract the offset to the level 5 header */
388 #define PASAHO_LINFO_READ_ESP_AH_OFFSET(x) PASAHO_READ_BITFIELD((x)->word2,0,8) /**< Extract the offset to the security header */
390 #define PASAHO_LINFO_READ_HDR_BITMASK(x) PASAHO_READ_BITFIELD((x)->word3,21,11) /**< Extract the bitmask of parsed header types */
391 #define PASAHO_LINFO_READ_HDR_BITMASK2(x) PASAHO_READ_BITFIELD((x)->word3, 4,4) /**< Extract the bitmask2 of parsed header types */
392 #define PASAHO_LINFO_READ_NXT_HDR_TYPE(x) PASAHO_READ_BITFIELD((x)->word3,16,5) /**< Extract the next header to parse type */
393 #define PASAHO_LINFO_READ_VLAN_COUNT(x) PASAHO_READ_BITFIELD((x)->word3,14,2) /**< Extract the number of VLAN tags found */
394 #define PASAHO_LINFO_READ_IP_COUNT(x) PASAHO_READ_BITFIELD((x)->word3,8,3) /**< Extract the number of IP headers found */
395 #define PASAHO_LINFO_READ_GRE_COUNT(x) PASAHO_READ_BITFIELD((x)->word3,11,3) /**< Extract the number of GRE headers found */
396 #define PASAHO_LINFO_READ_FLAG_FRAG(x) PASAHO_READ_BITFIELD((x)->word3,3,1) /**< Extract the fragmentation found flag */
397 #define PASAHO_LINFO_READ_INPORT(x) PASAHO_READ_BITFIELD((x)->word3,0,3) /**< Extract the (1-based) input EMAC port number
398 0: Indicates that the packet does not enter PASS
399 through CPSW */
400 #define PASAHO_LINFO_READ_PSEUDO_CHKSM(x) PASAHO_READ_BITFIELD((x)->word4,16,16) /**< Extract the last pseudo-header checksum computed */
401 #define PASAHO_LINFO_READ_TSTAMP_MSB(x) PASAHO_READ_BITFIELD((x)->word5,0,16) /**< Extract the most significant 16-bit of the 48-bit timestamp */
402 /* Extract Protocol Information */
404 /*@}*/ /* PASAHO_long_info_command_macros */
405 /** @}*/ /* @name PASAHO Long Info Command Macros */
407 /**
408 * @defgroup PASAHO_long_info_proto_ind_macros PASAHO Long Info Protocol Indication Macros
409 * @ingroup pasaho_if_macros
410 * @{
411 * @name PASAHO Long Info Protocol Indication Macros
412 */
414 #define PASAHO_LINFO_IS_MAC(x) PASAHO_READ_BITFIELD((x)->word3,21,1) /**< Indicate whether it is a MAC packet */
415 #define PASAHO_LINFO_IS_802_3(x) PASAHO_READ_BITFIELD((x)->word3,7,1) /**< Indicate whether it is a 802.3 packet */
416 #define PASAHO_LINFO_IS_WITH_VLAN(x) PASAHO_LINFO_READ_VLAN_COUNT(x) /**< Indicate whether it is a MAC packet with VLAN */
417 #define PASAHO_LINFO_IS_WITH_MPLS(x) PASAHO_READ_BITFIELD((x)->word3,23,1) /**< Indicate whether it is a MAC packet with MPLS */
418 #define PASAHO_LINFO_IS_PPPoE(x) PASAHO_READ_BITFIELD((x)->word3,6,1) /**< Indicate whether it is a PPPoE packet */
419 #define PASAHO_LINFO_IS_IP(x) PASAHO_LINFO_READ_IP_COUNT(x) /**< Indicate whether it is an IP packet */
420 #define PASAHO_LINFO_IS_IPSEC_ESP(x) PASAHO_READ_BITFIELD((x)->word3,25,1) /**< Indicate whether it is an IPSEC ESP packet */
421 #define PASAHO_LINFO_IS_IPSEC_AH(x) PASAHO_READ_BITFIELD((x)->word3,26,1) /**< Indicate whether it is an IPSEC AH packet */
422 #define PASAHO_LINFO_IS_UDP(x) PASAHO_READ_BITFIELD((x)->word3,27,1) /**< Indicate whether it is an UDP packet */
423 #define PASAHO_LINFO_IS_UDP_LITE(x) PASAHO_READ_BITFIELD((x)->word3,28,1) /**< Indicate whether it is an UDP Lite packet */
424 #define PASAHO_LINFO_IS_TCP(x) PASAHO_READ_BITFIELD((x)->word3,29,1) /**< Indicate whether it is a TCP packet */
425 #define PASAHO_LINFO_IS_GRE(x) PASAHO_LINFO_READ_GRE_COUNT(x) /**< Indicate whether it is a GRE packet */
426 #define PASAHO_LINFO_IS_GTPU(x) PASAHO_READ_BITFIELD((x)->word3,30,1) /**< Indicate whether it is a GTPU packet */
427 #define PASAHO_LINFO_IS_CUSTOM(x) PASAHO_READ_BITFIELD((x)->word3,31,1) /**< Indicate whether it is a Custom packet */
428 #define PASAHO_LINFO_IS_SCTP(x) PASAHO_READ_BITFIELD((x)->word3,4,1) /**< Indicate whether it is a SCTP packet */
429 #define PASAHO_LINFO_IS_IPSEC_NAT_T(x) PASAHO_READ_BITFIELD((x)->word3,5,1) /**< Indicate whether it is an IPSEC NAT-T packet */
431 /*@}*/ /* PASAHO_long_info_proto_ind_macross */
432 /** @}*/ /* @name PASAHO Long Info Protocol Indication Macross */
434 /**
435 * @defgroup PASAHO_long_info_ipReassm_macros PASAHO Long Info IP Reassembly Macros
436 * @ingroup pasaho_if_macros
437 * @{
438 * @name PASAHO Long Info IpReassm Macros
439 * Macros used by the PASAHO PASS-assisted IP Reassembly Operation
440 *
441 */
442 #define PASAHO_LINFO_READ_TFINDEX(x) PASAHO_READ_BITFIELD((x)->word4,24,8) /**< Extract the IP Reassembly Traffic Flow Index */
443 #define PASAHO_LINFO_READ_FRANCNT(x) PASAHO_READ_BITFIELD((x)->word4,16,8) /**< Extract the IP Reassembly Fragment count */
445 #define PASAHO_LINFO_SET_TFINDEX(x, v) PASAHO_SET_BITFIELD((x)->word4,(v),24,8) /**< Set the IP Reassembly Traffic Flow Index */
446 #define PASAHO_LINFO_SET_FRANCNT(x, v) PASAHO_SET_BITFIELD((x)->word4,(v),16,8) /**< Set the IP Reassembly Fragment count */
448 #define PASAHO_LINFO_IS_IPSEC(x) PASAHO_READ_BITFIELD((x)->word3,25,2) /**< Indicate whether it is an IPSEC packet */
449 #define PASAHO_LINFO_CLR_IPSEC(x) PASAHO_SET_BITFIELD((x)->word3,0,25,2) /**< Clear IPSEC indication bits */
450 #define PASAHO_LINFO_CLR_IPSEC_ESP(x) PASAHO_SET_BITFIELD((x)->word3,0,26,1) /**< Clear IPSEC ESP indication bit */
451 #define PASAHO_LINFO_CLR_IPSEC_AH(x) PASAHO_SET_BITFIELD((x)->word3,0,25,1) /**< Claer IPSEC AH indication bit */
452 #define PASAHO_LINFO_CLR_FLAG_FRAG(x) PASAHO_SET_BITFIELD((x)->word3,0,3,1) /**< Clear the fragmentation found flag */
455 #define PASAHO_LINFO_SET_START_OFFSET(x, v) PASAHO_SET_BITFIELD((x)->word0,(v),0,16) /**< Update the next parse start offset */
456 #define PASAHO_LINFO_SET_END_OFFSET(x, v) PASAHO_SET_BITFIELD((x)->word1,(v),16,16) /**< Update the end of packet parse offset */
458 #define PASAHO_LINFO_SET_NULL_PKT_IND(x, v) PASAHO_SET_BITFIELD((x)->word0,(v),21,1) /**< Set the null packet flag which indicates that the packet should be dropped.
459 This flag should be set for the null packet to be delivered to PASS when
460 the reassembly timeout occurs */
461 /*@}*/ /* PASAHO_long_info_ipReassm_macros */
462 /** @}*/ /* @name PASAHO Long Info IpReassm Macros */
464 /**
465 * @def PA_INV_TF_INDEX
466 * PASS-asssited IP reassembly traffic flow index to indicate that no traffic flow is available
467 */
468 #define PA_INV_TF_INDEX 0xFF
470 /**
471 * @ingroup pasaho_if_structures
472 * @brief pasahoShortInfo_t defines the packet parsing information in the short format
473 *
474 * @details pasahoShortInfo_t defines the packet parsing information in terms of
475 * payload offset and payload length as described below
476 * SRTP: offset to the RTP header; RTP payload length including ICV
477 * IPSEC AH: offset to the Outer IP; IP payload length
478 * IPSEC ESP: offset to the ESP header; ESP papload length including ICV
479 */
481 typedef struct pasahoShortInfo_s {
482 uint32_t word0; /**< Control block word 0 */
483 uint32_t word1; /**< Optional supplement data (It may be padding for alignment only) */
484 } pasahoShortInfo_t;
486 /**
487 * @defgroup PASAHO_short_info_command_macros PASAHO Short Info Command Macros
488 * @ingroup pasaho_if_macros
489 * @{
490 * @name PASAHO Short Info Command Macros
491 * Macros used by the PASAHO Short Info Command
492 *
493 */
494 /*@{*/
496 #define PASAHO_SINFO_READ_CMDID(x) PASAHO_READ_BITFIELD((x)->word0,29,3) /**< Extract the command ID defined at @ref pasahoCommands */
497 #define PASAHO_SINFO_RESD_PAYLOAD_OFFSET(x) PASAHO_READ_BITFIELD((x)->word0,16,8) /**< Extract the offset to the packet payload */
498 #define PASAHO_SINFO_READ_PAYLOAD_LENGTH(x) PASAHO_READ_BITFIELD((x)->word0,0,16) /**< Extract the byte length of the payload */
500 #define PASAHO_SINFO_SET_PAYLOAD_OFFSET(x, v) PASAHO_SET_BITFIELD((x)->word0, (v), 16, 8) /**< Set the offset to the payload */
501 #define PASAHO_SINFO_SET_PAYLOAD_LENGTH(x, v) PASAHO_SET_BITFIELD((x)->word0, (v), 0, 16) /**< Set the payload length */
502 #define PASAHO_SINFO_FORMAT_CMD(offset, len) (((offset) << 16) | (len) | (PASAHO_SA_SHORT_INFO << 29)) /**< Format the entire short info command */
504 /*@}*/ /* PASAHO_short_info_command_macros */
505 /** @}*/ /* @name PASAHO Short Info Command Macros */
508 /* Header bitmask bits */
509 /**
510 * @defgroup pasahoHeaderBitmap PA/SA/HO Header Bitmap Bit Definitions
511 * @ingroup pasaho_if_constants
512 * @{
513 *
514 * @name PA/SA/HO Header Bitmap Bit Definitions
515 * Bitmap definition of the protocol header bitmask at the long info.
516 */
517 /*@{*/
519 #define PASAHO_HDR_BITMASK_MAC (1 << 0) /**< MAC present */
520 #define PASAHO_HDR_BITMASK_VLAN (1 << 1) /**< VLAN present */
521 #define PASAHO_HDR_BITMASK_MPLS (1 << 2) /**< MPLS present */
522 #define PASAHO_HDR_BITMASK_IP (1 << 3) /**< IP present */
523 #define PASAHO_HDR_BITMASK_ESP (1 << 4) /**< IPSEC/ESP present */
524 #define PASAHO_HDR_BITMASK_AH (1 << 5) /**< IPSEC/AH present */
525 #define PASAHO_HDR_BITMASK_UDP (1 << 6) /**< UDP present */
526 #define PASAHO_HDR_BITMASK_UDPLITE (1 << 7) /**< UDPLITE present */
527 #define PASAHO_HDR_BITMASK_TCP (1 << 8) /**< TCP present */
528 #define PASAHO_HDR_BITMASK_GTPU (1 << 9) /**< GTPU present */
529 #define PASAHO_HDR_BITMASK_CUSTOM (1 << 10) /**< Custom header present */
531 #define PASAHO_HDR_BITMASK2_SCTP (1 << 0) /**< SCTP present */
532 #define PASAHO_HDR_BITMASK2_IPSEC_NAT_T (1 << 1) /**< IPSEC NAT-T present */
533 #define PASAHO_HDR_BITMASK2_PPPoE (1 << 2) /**< PPPoE present */
534 #define PASAHO_HDR_BITMASK2_802_3 (1 << 3) /**< 802.3 present */
536 /*@}*/
537 /** @} */
540 /* Next Route command */
541 /**
542 * @ingroup pasaho_if_structures
543 * @brief pasahoNextRoute_t defines the next route command. The command structure is defined as 32 bit
544 * values to work with the hardware regardless of the device endianness.
545 *
546 * @details
547 */
549 typedef struct pasahoNextRoute_s {
550 uint32_t word0; /**< Contains the next route command information. @ref PASAHO_next_route_command_macros */
551 uint32_t swInfo0; /**< Information placed into returned descriptor. Used if next destination is the host */
552 uint32_t swInfo1; /**< Information placed into returned descriptor. Used if next destination is the host */
553 uint32_t word1; /**< Contains the optional information such as pktType for SRIO. @ref PASAHO_next_route_command_macros */
554 } pasahoNextRoute_t;
556 /**
557 * @defgroup PASAHO_next_route_command_macros PASAHO Next Route Command Macros
558 * @ingroup pasaho_if_macros
559 * @{
560 * @name PASAHO Next Route Command Macros
561 * Macros used by the PASAHO Next Route Command
562 *
563 */
564 /*@{*/
566 #define PASAHO_SET_N(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 28, 1) /**< Sets the N bit which indicates the next command should be executed prior to the route command */
567 #define PASAHO_SET_E(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 27, 1) /**< Sets the E bit which indicates the extened parameters (packet type and/or control flags) are present for SRIO */
568 #define PASAHO_SET_DEST(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 24, 3) /**< Sets the destination of the route defined at @ref pktDest */
569 #define PASAHO_SET_FLOW(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 16, 8) /**< Specifies the flow to use for packets sent to the host */
570 #define PASAHO_SET_QUEUE(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 0, 16) /**< Specifies the queue to use for packets send to the host */
571 #define PASAHO_SET_PKTTYPE(x,v) PASAHO_SET_BITFIELD((x)->word1, (v), 24, 8) /**< Specifies the packet type to use for packets send to the SRIO */
572 #define PASAHO_SET_TX_PADDING(x,v) PASAHO_SET_BITFIELD((x)->word1, (v), 0, 1) /**< Sets the tx padding bit which indicates PASS should check padding condition and provide L2 zero padding if required */
573 #define PASAHO_SET_TX_STATS(x,v) PASAHO_SET_BITFIELD((x)->word1, (v), 1, 1) /**< Sets the tx stats bit which indicates PASS should increment the user statistics chain pointed by the user statistics index */
574 #define PASAHO_SET_USR_STATS_INDEX(x,v) PASAHO_SET_BITFIELD((x)->word1, (v), 8, 16) /**< Specifies index of the first user-defined statistics to be updated */
576 /*@}*/ /* PASAHO_next_route_command_macros */
577 /** @}*/ /* @name PASAHO Next Route Command Macros */
580 /* Compute checksum command */
581 /**
582 * @ingroup pasaho_if_structures
583 * @brief pasahoComChkCrc_t defines the checksum and CRC generation command. The command structure is defined as
584 * 32 bit values to wrok with the hardware regardless of the device endianness.
585 *
586 * @details
587 */
589 typedef struct pasahoComChkCrc_s {
590 uint32_t word0; /**< @ref PASAHO_chksum_command_macros */
591 uint32_t word1; /**< @ref PASAHO_chksum_command_macros */
592 uint32_t word2; /**< @ref PASAHO_chksum_command_macros */
594 } pasahoComChkCrc_t;
596 /**
597 * @defgroup PASAHO_chksum_command_macros PASAHO Checksum/CRC Command Macros
598 * @ingroup pasaho_if_macros
599 * @{
600 * @name PASAHO Checksum/CRC Command Macros
601 * Macros used by the ASAHO Checksum/CRC Command
602 */
603 /*@{*/
606 #define PASAHO_CHKCRC_SET_NEG0(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 23, 1) /**< Sets the negative 0 flag - if set a checksum computed as 0 will be sent as 0xffff */
607 #define PASAHO_CHKCRC_SET_CTRL(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 16, 4) /**< Sets the optional flags of the CRC/Checksum command */
608 #define PASAHO_CHKCRC_SET_START(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 0, 16) /**< Sets the start offset of the checksum/crc */
609 #define PASAHO_CHKCRC_SET_LEN(x,v) PASAHO_SET_BITFIELD((x)->word1, (v), 16, 16) /**< Sets the length of the checksum/crc */
610 #define PASAHO_CHKCRC_SET_RESULT_OFF(x,v) PASAHO_SET_BITFIELD((x)->word1, (v), 0, 16) /**< Sets the offset to where to paste the checksum/crc into the packet */
611 #define PASAHO_CHKCRC_SET_INITVAL(x,v) PASAHO_SET_BITFIELD((x)->word2, (v), 16, 16) /**< Sets the initial value of the checksum/crc */
613 /*@}*/ /* @name PASAHO Checksum/CRC Command Macros */
614 /** @}*/ /* PASAHO_chksum_command_macros */
617 /* Blind patch command */
618 /**
619 * @ingroup pasaho_if_structures
620 * @brief pasahoComBlindPatch_t defines the blind patch command. The command structure is defined as
621 * 32 bit values to work with the hardware regardless of the device endianness.
622 *
623 * @details
624 */
626 #define PASAHO_BPATCH_MAX_PATCH_WORDS 4
627 typedef struct pasahoComBlindPatch_s {
628 uint32_t word0; /**< @ref PASAHO_blind_patch_command_macros */
629 uint32_t patch[PASAHO_BPATCH_MAX_PATCH_WORDS]; /**< @ref PASAHO_blind_patch_command_macros */
631 } pasahoComBlindPatch_t;
633 /**
634 * @defgroup PASAHO_blind_patch_command_macros PASAHO Blind Patch Command Macros
635 * @ingroup pasaho_if_macros
636 * @{
637 * @name PASAHO Blind Patch Command Macros
638 * Macros used by the PASAHO Blind Patch Command
639 */
641 #define PASAHO_BPATCH_SET_PATCH_NBYTES(x,v) \
642 PASAHO_SET_BITFIELD((x)->word0, v, 24, 5)
643 /**< Sets the number of bytes to patch */
645 #define PASAHO_BPATCH_SET_PATCH_CMDSIZE(x,v) \
646 PASAHO_SET_BITFIELD((x)->word0, v, 20, 4)
647 /**< Sets the size of the command in 32 bit word units */
649 #define PASAHO_BPATCH_SET_OVERWRITE(x,v) \
650 PASAHO_SET_BITFIELD((x)->word0, v, 19, 1)
651 /**< Sets the overwrite flag. If set the patch will overwrite existing packet data,
652 otherwise data may be inserted */
654 #define PASAHO_BPATCH_SET_DELETE(x,v) \
655 PASAHO_SET_BITFIELD((x)->word0, v, 18, 1)
656 /**< Sets the delete flag. If set, no data will be inserted */
659 #define PASAHO_BPATCH_SET_OFFSET(x,v) \
660 PASAHO_SET_BITFIELD((x)->word0, v, 0, 16)
661 /**< Sets the offset to the start of the patch */
663 #define PASAHO_BPATCH_SET_PATCH_BYTE(x, byteNum, byte) \
664 PASAHO_SET_BITFIELD((x)->patch[(byteNum) >> 2], byte, ((3 - (byteNum & 0x3)) << 3), 8)
665 /**< Sets the data to patch */
667 /*@}*/ /* @name PASAHO Blind Patch Command Macros */
668 /** @}*/ /* PASAHO_blind_patch_command_macros */
670 /* Report Timestamp command */
671 /**
672 * @ingroup pasaho_if_structures
673 * @brief pasahoReportTimestamp_t defines the report timestamp command. The command structure is defined as 32 bit
674 * values to work with the hardware regardless of the device endianness.
675 *
676 * @details
677 */
679 typedef struct pasahoReportTimestamp_s {
680 uint32_t word0; /**< Contains the report timestamp command information. @ref PASAHO_report_timestamp_command_macros */
681 uint32_t swInfo0; /**< Information placed into returned descriptor of the reporting packet. */
682 } pasahoReportTimestamp_t;
684 /**
685 * @defgroup PASAHO_report_timestamp_command_macros PASAHO Report Timestamp Command Macros
686 * @ingroup pasaho_if_macros
687 * @{
688 * @name PASAHO Report Timestamp Command Macros
689 * Macros used by the PASAHO Report Timestamp Command
690 *
691 */
692 /*@{*/
693 #define PASAHO_SET_REPORT_FLOW(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 16, 8) /**< Specifies the flow to use for report packets sent to the host */
694 #define PASAHO_SET_REPORT_QUEUE(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 0, 16) /**< Specifies the queue to use for report packets send to the host */
696 /*@}*/ /* @name PASAHO Report Timestamp Command Macros */
697 /** @}*/ /* PASAHO_report_timestamp_command_macros */
699 /* IP Fragmentation command */
700 /**
701 * @ingroup pasaho_if_structures
702 * @brief pasahoIpFrag_t defines the IP Fragmentation command. The command structure is defined as 32 bit
703 * values to work with the hardware regardless of the device endianness.
704 *
705 * @details
706 */
708 typedef struct pasahoIpFrag_s {
709 uint32_t word0; /**< Contains the ip fragmentation command information. @ref PASAHO_ip_frag_command_macros */
710 } pasahoIpFrag_t;
712 /**
713 * @defgroup PASAHO_ip_frag_command_macros PASAHO IP Fragmentation Command Macros
714 * @ingroup pasaho_if_macros
715 * @{
716 * @name PASAHO IP Fragmentation Command Macros
717 * Macros used by the PASAHO IP Fragmentation Command
718 *
719 */
720 /*@{*/
722 #define PASAHO_SET_SUB_CODE_IP_FRAG(x) PASAHO_SET_BITFIELD((x)->word0, PASAHO_SUB_CMD_IP_FRAG, 24, 5) /**< Set sub-command code to indicate IP Fragmentation command */
723 #define PASAHO_SET_SUB_CODE(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 24, 5) /**< Specifies the sub-command code */
724 #define PASAHO_SET_IP_OFFSET(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 16, 8) /**< Specifies the offset to the IP header to be fragmented */
725 #define PASAHO_SET_MTU_SIZE(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 0, 16) /**< Specifies the MTU size */
727 /*@}*/ /* @name PASAHO IP Fragmentation Command Macros */
728 /** @}*/ /* PASAHO_ip_frag_command_macros */
731 /* Patch Message Length command */
732 /**
733 * @ingroup pasaho_if_structures
734 * @brief pasahoPatchMsgLen_t defines the message length patching command. The command structure is defined as 32 bit
735 * values to work with the hardware regardless of the device endianness.
736 *
737 * @details
738 */
740 typedef struct pasahoPatchMsgLen_s {
741 uint32_t word0; /**< Contains the message length patching command information. @ref PASAHO_patch_msg_len_command_macros */
742 } pasahoPatchMsgLen_t;
744 /**
745 * @defgroup PASAHO_patch_msg_len_command_macros PASAHO Message Length Patching Command Macros
746 * @ingroup pasaho_if_macros
747 * @{
748 * @name PASAHO Message Length Patching Command Macros
749 * Macros used by the PASAHO Message Length Patching Command
750 *
751 */
752 /*@{*/
754 #define PASAHO_SET_SUB_CODE_PATCH_MSG_LEN(x) PASAHO_SET_BITFIELD((x)->word0, PASAHO_SUB_CMD_PATCH_MSG_LEN, 24, 5) /**< Set sub-command code to indicate Message Length Patching command */
755 #define PASAHO_SET_MSGLEN_OFFSET(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 16, 8) /**< Specifies the offset to the message length field to be patched */
756 #define PASAHO_SET_MSGLEN_SIZE(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 15, 1) /**< Specifies the size of the length field (0: 16-bit; 1: 32-bit) */
757 #define PASAHO_SET_MSGLEN(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 0, 15) /**< Specifies the message length excluding the IP header and payload length */
759 /*@}*/ /* @name PASAHO Message Length Patching Command Macros */
760 /** @}*/ /* PASAHO_patch_msg_len_command_macros */
764 #ifdef __cplusplus
765 }
766 #endif
768 #endif /* _PASAHO_H */