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-2010 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
130 /**
131 * @def PASAHO_PAMOD_MULTI_ROUTE
132 * Instruct PDSP to perform multiple routing
133 */
135 #define PASAHO_PAMOD_MULTI_ROUTE 5
137 /**
138 * @def PASAHO_PAMOD_REPORT_TIMESTAMP
139 * Instruct PDSP to report the system timestamp at the timestamp field of the packet descriptor
140 * when the tx packet is delivered out of the PASS
141 */
143 #define PASAHO_PAMOD_REPORT_TIMESTAMP 6
146 /**
147 * @def PASAHO_PAMOD_GROUP_7
148 * Define this group command so that several command can share the same command code. They will be distinguished
149 * by its unique 5-bit sub-command code as defined at
150 */
152 #define PASAHO_PAMOD_GROUP_7 7
155 /**
156 * @def PASAHO_PAMOD_DUMMY
157 * No action is required. It is for SA alignment only
158 */
160 #define PASAHO_PAMOD_DUMMY PASAHO_PAMOD_GROUP_7
162 /**
163 * @def PASAHO_PAMOD_IP_FRAGMENT
164 * Instruct PDSP to perform IPv4 fragmentation. The transmit IP packets will be divided into smaller
165 * IP fragments with the updated IPv4 header and checksum based on the specified MTU size and forwarded
166 * to the destination specified by the next route command. It is up to the module user to format the
167 * correct IPv4 header. The IP fragmentation command will be ignored if any error is detected.
168 */
169 #define PASAHO_PAMOD_IP_FRAGMENT PASAHO_PAMOD_GROUP_7
171 /**
172 * @def PASAHO_PAMOD_PATCH_MSG_LEN
173 * Instruct PDSP to perform message length patching after IPv4 fragmentation operation. This command is
174 * valid only if it is in conjunction with the PASAHO_PAMOD_IP_FRAGMENT command.
175 */
176 #define PASAHO_PAMOD_PATCH_MSG_LEN PASAHO_PAMOD_GROUP_7
178 /* SA commands */
179 /**
180 * @def PASAHO_SA_LONG_INFO
181 * Provide SA with the packet parsing information in the long form
182 */
184 #define PASAHO_SA_LONG_INFO 0
186 /**
187 * @def PASAHO_SA_SHORT_INFO
188 * Provide SA with the packet parsing information in the short form
189 */
191 #define PASAHO_SA_SHORT_INFO 1
194 /**
195 * @def PASAHO_SA_AIR_INFO
196 * Provide SA with the packet parsing information for the air ciphering
197 * operation
198 */
200 #define PASAHO_SA_AIR_INFO 2
203 /*@}*/
204 /** @} */
206 /** @name PASAHO Common Macros
207 *
208 */
209 /*@{*/
211 /**
212 * @ingroup pasaho_if_macros
213 * @brief PASAHO_READ_BITFIELD is used to read the specific bit fields
214 *
215 * @details It is one of the main macros for accessing configuration bit fields
216 * Input parameter a contains bit field
217 * b is bit offset withing bit field
218 * c is number of bits used by that parameter
219 */
221 #define PASAHO_READ_BITFIELD(a,b,c) (((a)>>(b)) & ((1UL<<(c))-1))
223 /**
224 * @ingroup ingroup pasaho_if_macros
225 * @brief PASAHO_SET_BITFIELD is used to set the specific bit fields
226 *
227 * @details It is one of the main macros for accessing configuration bit fields
228 * Input parameter a contains bit field
229 * b is bit offset withing bit field
230 * c is number of bits used by that parameter
231 * x is new value of parameter that is packed in this bit field
232 *
233 * @note It enforces strict setting to prevent overflow into other bits, would
234 * cost program space for additional protection.
235 */
237 #define PASAHO_SET_BITFIELD(a,x,b,c) (a) &= ~(((1UL<<(c))-1)<<(b)), \
238 (a) |= (((x) & ((1UL<<(c))-1))<<(b))
240 /**
241 * @ingroup ingroup pasaho_if_macros
242 * @brief PASAHO_SET_CMDID is used to set the command ID
243 */
244 #define PASAHO_SET_CMDID(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 29,3)
246 /**
247 * @ingroup ingroup pasaho_if_macros
248 * @brief PASAHO_PACFG_CMD is used to set the PA configuration command only
249 */
250 #define PASAHO_PACFG_CMD (((uint32_t)PASAHO_CONFIGURE << 5) << 24)
252 /*@}*/ /* @name PASAHO Common Macros */
255 /**
256 * @defgroup pasahoHeaderTypes PASS Header Types
257 * @ingroup pasaho_if_constants
258 * @{
259 *
260 * @name PASS Header Types
261 * Definition of protocol header types used at the PASS PDSP Firmwase. In the
262 * long info field these values specify what the next header type will be
263 * at the next parse offset
264 */
265 /*@{*/
267 typedef enum {
269 PASAHO_HDR_MAC = 0, /**< MAC */
270 PASAHO_HDR_VLAN, /**< VLAN */
271 PASAHO_HDR_MPLS, /**< MPLS */
272 PASAHO_HDR_IPv4, /**< IPv4 */
273 PASAHO_HDR_IPv6, /**< IPv6 */
274 PASAHO_HDR_IPv6_EXT_HOP, /**< IPv6 hop by hop extenstion header */
275 PASAHO_HDR_IPv6_EXT_ROUTE, /**< IPv6 routing extenstion header */
276 PASAHO_HDR_IPv6_EXT_FRAG, /**< IPv6 fragmentation extention header */
277 PASAHO_HDR_IPv6_EXT_DEST, /**< IPv6 destination options header */
278 PASAHO_HDR_GRE, /**< Generic Routing Encapsulation header */
279 PASAHO_HDR_ESP, /**< Encapsulating Security Payload header */
280 PASAHO_HDR_ESP_DECODED, /**< Decoded Encapsulating Security Payload header */
281 PASAHO_HDR_AUTH, /**< Authentication header */
282 PASAHO_HDR_CUSTOM_C1, /**< Custom classify 1 header */
283 PASAHO_HDR_PPPoE, /**< PPPoE Header */
284 PASAHO_HDR_SCTP, /**< SCTP Header */
285 PASAHO_HDR_UNKNOWN, /**< Next header type is unknown */
286 PASAHO_HDR_UDP, /**< User Datagram Protocol header */
287 PASAHO_HDR_UDP_LITE, /**< Lightweight User Datagram Protocol header */
288 PASAHO_HDR_TCP, /**< Transmission Control Protocol header */
289 PASAHO_HDR_GTPU, /**< GTPU header */
290 PASAHO_HDR_ESP_DECODED_C2, /**< Decoded Encapsulating Security Payload header at Classifyer2 */
291 PASAHO_HDR_CUSTOM_C2 /**< Custom classify 2 header */
293 } pasaho_HeaderType_e;
294 /*@}*/
295 /** @} */
297 /**
298 * @defgroup pasahoSubCmdCode PASS Sub-Command Code
299 * @ingroup pasaho_if_constants
300 * @{
301 *
302 * @name PASS Sub-Command Code
303 * Definition of the 5-bit sub-command codes which is used to specify the group 7 commands.
304 */
305 /*@{*/
307 typedef enum {
309 PASAHO_SUB_CMD_DUMMY = 0, /**< Dummy */
310 PASAHO_SUB_CMD_IP_FRAG, /**< IPv4 fragmentation */
311 PASAHO_SUB_CMD_PATCH_MSG_LEN /**< Message length Patching */
312 } pasaho_SubCmdCode_e;
313 /*@}*/
314 /** @} */
316 /**
317 * @defgroup pasahoPktType PASS Packet Type
318 * @ingroup pasaho_if_constants
319 * @{
320 *
321 * @name PASS Packet Type
322 * Definition of the MAC or IP packet types.
323 */
324 /*@{*/
326 typedef enum {
328 PASAHO_PKT_TYPE_UNICAST = 0, /**< Unicast MAC/IP */
329 PASAHO_PKT_TYPE_BROADCAST, /**< Broadcast MAC/IP */
330 PASAHO_PKT_TYPE_MULTICAST /**< Multicast MAC/IP */
331 } pasaho_pktType_e;
332 /*@}*/
333 /** @} */
337 /**
338 * @ingroup pasaho_if_structures
339 * @brief pasahoCmdInfo_t defines the general short command information
340 *
341 */
343 typedef struct pasahoCmdInfo_s {
344 uint32_t word0; /**< Control block word 0 */
345 } pasahoCmdInfo_t;
347 /**
348 * @ingroup pasaho_if_structures
349 * @brief pasahoLongInfo_t defines the packet parsing information in the long format.
350 * The information is structured as an array of 32 bit values. These values
351 * are broken down through macros. This allows the representation to be
352 * endian independent to the hardware which operates only on 32 bit values.
353 *
354 * @details
355 */
357 typedef struct pasahoLongInfo_s {
359 uint32_t word0; /**< Control block word 0 */
360 uint32_t word1; /**< Control block word 1 */
361 uint32_t word2; /**< Control block word 2 */
362 uint32_t word3; /**< Control block word 3 */
363 uint32_t word4; /**< Control block word 4 */
364 uint32_t word5; /**< Control block word 5 */
366 } pasahoLongInfo_t;
368 /**
369 * @defgroup PASAHO_long_info_command_macros PASAHO Long Info Command Macros
370 * @ingroup pasaho_if_macros
371 * @{
372 * @name PASAHO Long Info Command Macros
373 * Macros used by the PASAHO Long Info Command
374 */
375 /*@{*/
377 #define PASAHO_LINFO_READ_CMDID(x) PASAHO_READ_BITFIELD((x)->word0,29,3) /**< Extract the command ID defined at @ref pasahoCommands */
378 #define PASAHO_LINFO_READ_RECLEN(x) PASAHO_READ_BITFIELD((x)->word0,24,5) /**< Extract the block length */
379 #define PASAHO_LINFO_READ_START_OFFSET(x) PASAHO_READ_BITFIELD((x)->word0,0,8) /**< Extract the next parse start offset */
381 #define PASAHO_LINFO_IS_MAC_BROADCAST(x) PASAHO_READ_BITFIELD((x)->word0,16,1) /**< Indicate whether it is a broadcast MAC packet */
382 #define PASAHO_LINFO_IS_MAC_MULTICAST(x) PASAHO_READ_BITFIELD((x)->word0,17,1) /**< Indicate whether it is a multicast MAC packet */
383 #define PASAHO_LINFO_READ_MAC_PKTTYPE(x) PASAHO_READ_BITFIELD((x)->word0,16,2) /**< Extract the MAC packet type */
385 #define PASAHO_LINFO_IS_IP_BROADCAST(x) PASAHO_READ_BITFIELD((x)->word0,16,1) /**< Indicate whether it is a broadcast IP packet */
386 #define PASAHO_LINFO_IS_IP_MULTICAST(x) PASAHO_READ_BITFIELD((x)->word0,17,1) /**< Indicate whether it is a multicast IP packet */
387 #define PASAHO_LINFO_READ_IP_PKTTYPE(x) PASAHO_READ_BITFIELD((x)->word0,16,2) /**< Extract the IP packet type */
389 #define PASAHO_LINFO_READ_PMATCH(x) PASAHO_READ_BITFIELD((x)->word0,23,1) /**< Extract the previous match flag */
390 #define PASAHO_LINFO_READ_FLAG_FRAG(x) PASAHO_READ_BITFIELD((x)->word0,19,1) /**< Extract the fragmentation found flag */
392 #define PASAHO_LINFO_READ_END_OFFSET(x) PASAHO_READ_BITFIELD((x)->word1,16,16) /**< Extract the end of packet parse offset */
393 #define PASAHO_LINFO_READ_EIDX(x) PASAHO_READ_BITFIELD((x)->word1,10,6) /**< Extract the exception index */
394 #define PASAHO_LINFO_READ_NXT_HDR_TYPE(x) PASAHO_READ_BITFIELD((x)->word1,0,6) /**< Extract the next header to parse type */
395 #define PASAHO_LINFO_READ_INPORT(x) PASAHO_READ_BITFIELD((x)->word1,6,4) /**< Extract the (1-based) input EMAC port number
396 through CPSW */
398 #define PASAHO_LINFO_READ_L3_OFFSET(x) PASAHO_READ_BITFIELD((x)->word2,24,8) /**< Extract the offset to the level 3 header */
399 #define PASAHO_LINFO_READ_L4_OFFSET(x) PASAHO_READ_BITFIELD((x)->word2,16,8) /**< Extract the offset to the level 4 header */
400 #define PASAHO_LINFO_READ_L5_OFFSET(x) PASAHO_READ_BITFIELD((x)->word2,8,8) /**< Extract the offset to the level 5 header */
401 #define PASAHO_LINFO_READ_ESP_AH_OFFSET(x) PASAHO_READ_BITFIELD((x)->word2,0,8) /**< Extract the offset to the security header */
403 #define PASAHO_LINFO_READ_L1_PDSP_ID(x) PASAHO_READ_BITFIELD((x)->word3,26,6) /**< Extract the first parse module ID */
404 #define PASAHO_LINFO_READ_L1_IDX(x) PASAHO_READ_BITFIELD((x)->word3,16,10) /**< Extract the first parse module match index */
405 #define PASAHO_LINFO_READ_HDR_BITMASK(x) PASAHO_READ_BITFIELD((x)->word3,0,16) /**< Extract the bitmask of parsed header types */
407 #define PASAHO_LINFO_READ_VLAN_COUNT(x) PASAHO_READ_BITFIELD((x)->word4,6,2) /**< Extract the number of VLAN tags found */
408 #define PASAHO_LINFO_READ_IP_COUNT(x) PASAHO_READ_BITFIELD((x)->word4,0,3) /**< Extract the number of IP headers found */
409 #define PASAHO_LINFO_READ_GRE_COUNT(x) PASAHO_READ_BITFIELD((x)->word4,3,3) /**< Extract the number of GRE headers found */
411 #define PASAHO_LINFO_READ_PSEUDO_CHKSM(x) PASAHO_READ_BITFIELD((x)->word5,16,16) /**< Extract the last pseudo-header checksum computed */
413 /* Extract Protocol Information */
415 /*@}*/ /* PASAHO_long_info_command_macros */
416 /** @}*/ /* @name PASAHO Long Info Command Macros */
418 /**
419 * @defgroup PASAHO_long_info_proto_ind_macros PASAHO Long Info Protocol Indication Macros
420 * @ingroup pasaho_if_macros
421 * @{
422 * @name PASAHO Long Info Protocol Indication Macros
423 */
425 #define PASAHO_LINFO_IS_MAC(x) PASAHO_READ_BITFIELD((x)->word3,0,1) /**< Indicate whether it is a MAC packet */
426 #define PASAHO_LINFO_IS_WITH_VLAN(x) PASAHO_LINFO_READ_VLAN_COUNT(x) /**< Indicate whether it is a MAC packet with VLAN */
427 #define PASAHO_LINFO_IS_WITH_MPLS(x) PASAHO_READ_BITFIELD((x)->word3,2,1) /**< Indicate whether it is a MAC packet with MPLS */
428 #define PASAHO_LINFO_IS_802_3(x) PASAHO_READ_BITFIELD((x)->word3,3,1) /**< Indicate whether it is a 802.3 packet */
429 #define PASAHO_LINFO_IS_PPPoE(x) PASAHO_READ_BITFIELD((x)->word3,4,1) /**< Indicate whether it is a PPPoE packet */
430 #define PASAHO_LINFO_IS_IP(x) PASAHO_LINFO_READ_IP_COUNT(x) /**< Indicate whether it is an IP packet */
431 #define PASAHO_LINFO_IS_IPv4(x) PASAHO_READ_BITFIELD((x)->word3,5,1) /**< Indicate whether it is an IPv4 packet */
432 #define PASAHO_LINFO_IS_IPv6(x) PASAHO_READ_BITFIELD((x)->word3,6,1) /**< Indicate whether it is an IPv4 packet */
433 #define PASAHO_LINFO_IS_IP_OPTIONS(x) PASAHO_READ_BITFIELD((x)->word3,7,1) /**< Indicate whether there are IPV4 options or IPv6 extention headers */
434 #define PASAHO_LINFO_IS_IPSEC_ESP(x) PASAHO_READ_BITFIELD((x)->word3,8,1) /**< Indicate whether it is an IPSEC ESP packet */
435 #define PASAHO_LINFO_IS_IPSEC_AH(x) PASAHO_READ_BITFIELD((x)->word3,9,1) /**< Indicate whether it is an IPSEC AH packet */
436 #define PASAHO_LINFO_IS_SCTP(x) PASAHO_READ_BITFIELD((x)->word3,10,1) /**< Indicate whether it is a SCTP packet */
437 #define PASAHO_LINFO_IS_UDP(x) PASAHO_READ_BITFIELD((x)->word3,11,1) /**< Indicate whether it is an UDP packet */
438 #define PASAHO_LINFO_IS_UDP_LITE(x) PASAHO_READ_BITFIELD((x)->word3,11,1) /**< Indicate whether it is an UDP Lite packet */
439 #define PASAHO_LINFO_IS_TCP(x) PASAHO_READ_BITFIELD((x)->word3,12,1) /**< Indicate whether it is a TCP packet */
440 #define PASAHO_LINFO_IS_GRE(x) PASAHO_LINFO_READ_GRE_COUNT(x) /**< Indicate whether it is a GRE packet */
441 #define PASAHO_LINFO_IS_GTPU(x) PASAHO_READ_BITFIELD((x)->word3,13,1) /**< Indicate whether it is a GTPU packet */
442 #define PASAHO_LINFO_IS_CUSTOM(x) PASAHO_READ_BITFIELD((x)->word3,14,1) /**< Indicate whether it is a Custom packet */
443 #define PASAHO_LINFO_IS_IPSEC_NAT_T(x) PASAHO_READ_BITFIELD((x)->word3,15,1) /**< Indicate whether it is an IPSEC NAT-T packet */
445 /*@}*/ /* PASAHO_long_info_proto_ind_macross */
446 /** @}*/ /* @name PASAHO Long Info Protocol Indication Macross */
448 /**
449 * @defgroup PASAHO_long_info_ipReassm_macros PASAHO Long Info IP Reassembly Macros
450 * @ingroup pasaho_if_macros
451 * @{
452 * @name PASAHO Long Info IpReassm Macros
453 * Macros used by the PASAHO PASS-assisted IP Reassembly Operation
454 *
455 */
456 #define PASAHO_LINFO_READ_TFINDEX(x) PASAHO_READ_BITFIELD((x)->word5,24,8) /**< Extract the IP Reassembly Traffic Flow Index */
457 #define PASAHO_LINFO_READ_FRANCNT(x) PASAHO_READ_BITFIELD((x)->word5,16,8) /**< Extract the IP Reassembly Fragment count */
459 #define PASAHO_LINFO_SET_TFINDEX(x, v) PASAHO_SET_BITFIELD((x)->word5,(v),24,8) /**< Set the IP Reassembly Traffic Flow Index */
460 #define PASAHO_LINFO_SET_FRANCNT(x, v) PASAHO_SET_BITFIELD((x)->word5,(v),16,8) /**< Set the IP Reassembly Fragment count */
462 #define PASAHO_LINFO_IS_IPSEC(x) PASAHO_READ_BITFIELD((x)->word3,8,2) /**< Indicate whether it is an IPSEC packet */
463 #define PASAHO_LINFO_CLR_IPSEC(x) PASAHO_SET_BITFIELD((x)->word3,0,8,2) /**< Clear IPSEC indication bits */
464 #define PASAHO_LINFO_CLR_IPSEC_ESP(x) PASAHO_SET_BITFIELD((x)->word3,0,8,1) /**< Clear IPSEC ESP indication bit */
465 #define PASAHO_LINFO_CLR_IPSEC_AH(x) PASAHO_SET_BITFIELD((x)->word3,0,9,1) /**< Claer IPSEC AH indication bit */
466 #define PASAHO_LINFO_CLR_FLAG_FRAG(x) PASAHO_SET_BITFIELD((x)->word1,0,19,1) /**< Clear the fragmentation found flag */
469 #define PASAHO_LINFO_SET_START_OFFSET(x, v) PASAHO_SET_BITFIELD((x)->word0,(v),0,16) /**< Update the next parse start offset */
470 #define PASAHO_LINFO_SET_END_OFFSET(x, v) PASAHO_SET_BITFIELD((x)->word1,(v),16,16) /**< Update the end of packet parse offset */
472 #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.
473 This flag should be set for the null packet to be delivered to PASS when
474 the reassembly timeout occurs */
475 /*@}*/ /* PASAHO_long_info_ipReassm_macros */
476 /** @}*/ /* @name PASAHO Long Info IpReassm Macros */
478 /**
479 * @def PA_INV_TF_INDEX
480 * PASS-asssited IP reassembly traffic flow index to indicate that no traffic flow is available
481 */
482 #define PA_INV_TF_INDEX 0xFF
484 /**
485 * @ingroup pasaho_if_structures
486 * @brief pasahoShortInfo_t defines the packet parsing information in the short format
487 *
488 * @details pasahoShortInfo_t defines the packet parsing information in terms of
489 * payload offset and payload length as described below
490 * SRTP: offset to the RTP header; RTP payload length including ICV
491 * IPSEC AH: offset to the Outer IP; IP payload length
492 * IPSEC ESP: offset to the ESP header; ESP papload length including ICV
493 */
495 typedef struct pasahoShortInfo_s {
496 uint32_t word0; /**< Control block word 0 */
497 uint32_t word1; /**< Optional supplement data (It may be padding for alignment only) */
498 } pasahoShortInfo_t;
500 /**
501 * @defgroup PASAHO_short_info_command_macros PASAHO Short Info Command Macros
502 * @ingroup pasaho_if_macros
503 * @{
504 * @name PASAHO Short Info Command Macros
505 * Macros used by the PASAHO Short Info Command
506 *
507 */
508 /*@{*/
510 #define PASAHO_SINFO_READ_CMDID(x) PASAHO_READ_BITFIELD((x)->word0,29,3) /**< Extract the command ID defined at @ref pasahoCommands */
511 #define PASAHO_SINFO_RESD_PAYLOAD_OFFSET(x) PASAHO_READ_BITFIELD((x)->word0,16,8) /**< Extract the offset to the packet payload */
512 #define PASAHO_SINFO_READ_PAYLOAD_LENGTH(x) PASAHO_READ_BITFIELD((x)->word0,0,16) /**< Extract the byte length of the payload */
514 #define PASAHO_SINFO_SET_PAYLOAD_OFFSET(x, v) PASAHO_SET_BITFIELD((x)->word0, (v), 16, 8) /**< Set the offset to the payload */
515 #define PASAHO_SINFO_SET_PAYLOAD_LENGTH(x, v) PASAHO_SET_BITFIELD((x)->word0, (v), 0, 16) /**< Set the payload length */
516 #define PASAHO_SINFO_FORMAT_CMD(offset, len) (((offset) << 16) | (len) | (PASAHO_SA_SHORT_INFO << 29)) /**< Format the entire short info command */
518 /*@}*/ /* PASAHO_short_info_command_macros */
519 /** @}*/ /* @name PASAHO Short Info Command Macros */
522 /* Header bitmask bits */
523 /**
524 * @defgroup pasahoHeaderBitmap PA/SA/HO Header Bitmap Bit Definitions
525 * @ingroup pasaho_if_constants
526 * @{
527 *
528 * @name PA/SA/HO Header Bitmap Bit Definitions
529 * Bitmap definition of the protocol header bitmask at the long info.
530 */
531 /*@{*/
533 #define PASAHO_HDR_BITMASK_MAC (1 << 0) /**< MAC present */
534 #define PASAHO_HDR_BITMASK_VLAN (1 << 1) /**< VLAN present */
535 #define PASAHO_HDR_BITMASK_MPLS (1 << 2) /**< MPLS present */
536 #define PASAHO_HDR_BITMASK_802_3 (1 << 3) /**< 802.3 present */
537 #define PASAHO_HDR_BITMASK_PPPoE (1 << 4) /**< PPPoE present */
538 #define PASAHO_HDR_BITMASK_IPv4 (1 << 5) /**< IPv4 present */
539 #define PASAHO_HDR_BITMASK_IPv6 (1 << 6) /**< IPv6 present */
540 #define PASAHO_HDR_BITMASK_IP_OPTS (1 << 7) /**< IPv4 options or IPv6 extension headers esent */
541 #define PASAHO_HDR_BITMASK_ESP (1 << 8) /**< IPSEC/ESP present */
542 #define PASAHO_HDR_BITMASK_AH (1 << 9) /**< IPSEC/AH present */
543 #define PASAHO_HDR_BITMASK_SCTP (1 << 10) /**< SCTP present */
544 #define PASAHO_HDR_BITMASK_UDP (1 << 11) /**< UDP present */
545 #define PASAHO_HDR_BITMASK_UDPLITE (1 << 11) /**< UDPLITE present */
546 #define PASAHO_HDR_BITMASK_TCP (1 << 12) /**< TCP present */
547 #define PASAHO_HDR_BITMASK_GTPU (1 << 13) /**< GTPU present */
548 #define PASAHO_HDR_BITMASK_CUSTOM (1 << 14) /**< Custom header present */
549 #define PASAHO_HDR_BITMASK_IPSEC_NAT_T (1 << 15) /**< IPSEC NAT-T present */
551 /*@}*/
552 /** @} */
555 /* Next Route command */
556 /**
557 * @ingroup pasaho_if_structures
558 * @brief pasahoNextRoute_t defines the next route command. The command structure is defined as 32 bit
559 * values to work with the hardware regardless of the device endianness.
560 *
561 * @details
562 */
564 typedef struct pasahoNextRoute_s {
565 uint32_t word0; /**< Contains the next route command information. @ref PASAHO_next_route_command_macros */
566 uint32_t swInfo0; /**< Information placed into returned descriptor. Used if next destination is the host */
567 uint32_t swInfo1; /**< Information placed into returned descriptor. Used if next destination is the host */
568 uint32_t word1; /**< Contains the optional information such as pktType for SRIO. @ref PASAHO_next_route_command_macros */
569 } pasahoNextRoute_t;
571 /**
572 * @defgroup PASAHO_next_route_command_macros PASAHO Next Route Command Macros
573 * @ingroup pasaho_if_macros
574 * @{
575 * @name PASAHO Next Route Command Macros
576 * Macros used by the PASAHO Next Route Command
577 *
578 */
579 /*@{*/
581 #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 */
582 #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 */
583 #define PASAHO_SET_DEST(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 24, 3) /**< Sets the destination of the route defined at @ref pktDest */
584 #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 */
585 #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 */
586 #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 */
587 #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 */
589 /*@}*/ /* PASAHO_next_route_command_macros */
590 /** @}*/ /* @name PASAHO Next Route Command Macros */
593 /* Compute checksum command */
594 /**
595 * @ingroup pasaho_if_structures
596 * @brief pasahoComChkCrc_t defines the checksum and CRC generation command. The command structure is defined as
597 * 32 bit values to wrok with the hardware regardless of the device endianness.
598 *
599 * @details
600 */
602 typedef struct pasahoComChkCrc_s {
603 uint32_t word0; /**< @ref PASAHO_chksum_command_macros */
604 uint32_t word1; /**< @ref PASAHO_chksum_command_macros */
605 uint32_t word2; /**< @ref PASAHO_chksum_command_macros */
607 } pasahoComChkCrc_t;
609 /**
610 * @defgroup PASAHO_chksum_command_macros PASAHO Checksum/CRC Command Macros
611 * @ingroup pasaho_if_macros
612 * @{
613 * @name PASAHO Checksum/CRC Command Macros
614 * Macros used by the ASAHO Checksum/CRC Command
615 */
616 /*@{*/
619 #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 */
620 #define PASAHO_CHKCRC_SET_CTRL(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 16, 4) /**< Sets the optional flags of the CRC/Checksum command */
621 #define PASAHO_CHKCRC_SET_START(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 8, 8) /**< Sets the start offset of the checksum/crc */
622 #define PASAHO_CHKCRC_SET_CRCSIZE(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 0, 8) /**< Sets the size of the crc in bytes */
623 #define PASAHO_CHKCRC_SET_LEN(x,v) PASAHO_SET_BITFIELD((x)->word1, (v), 16, 16) /**< Sets the length of the checksum/crc */
624 #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 */
625 #define PASAHO_CHKCRC_SET_INITVAL(x,v) PASAHO_SET_BITFIELD((x)->word2, (v), 16, 16) /**< Sets the initial value of the 16-bit checksum */
626 #define PASAHO_CHKCRC_SET_INITVAL32(x,v) (x)->word2 = (v) /**< Sets the initial value of the 32-bit crc */
628 /*@}*/ /* @name PASAHO Checksum/CRC Command Macros */
629 /** @}*/ /* PASAHO_chksum_command_macros */
632 /* Blind patch command */
633 /**
634 * @ingroup pasaho_if_structures
635 * @brief pasahoComBlindPatch_t defines the blind patch command. The command structure is defined as
636 * 32 bit values to work with the hardware regardless of the device endianness.
637 *
638 * @details
639 */
641 #define PASAHO_BPATCH_MAX_PATCH_WORDS 4
642 typedef struct pasahoComBlindPatch_s {
643 uint32_t word0; /**< @ref PASAHO_blind_patch_command_macros */
644 uint32_t patch[PASAHO_BPATCH_MAX_PATCH_WORDS]; /**< @ref PASAHO_blind_patch_command_macros */
646 } pasahoComBlindPatch_t;
648 /**
649 * @defgroup PASAHO_blind_patch_command_macros PASAHO Blind Patch Command Macros
650 * @ingroup pasaho_if_macros
651 * @{
652 * @name PASAHO Blind Patch Command Macros
653 * Macros used by the PASAHO Blind Patch Command
654 */
656 #define PASAHO_BPATCH_SET_PATCH_NBYTES(x,v) \
657 PASAHO_SET_BITFIELD((x)->word0, v, 24, 5)
658 /**< Sets the number of bytes to patch */
660 #define PASAHO_BPATCH_SET_PATCH_CMDSIZE(x,v) \
661 PASAHO_SET_BITFIELD((x)->word0, v, 20, 4)
662 /**< Sets the size of the command in 32 bit word units */
664 #define PASAHO_BPATCH_SET_OVERWRITE(x,v) \
665 PASAHO_SET_BITFIELD((x)->word0, v, 19, 1)
666 /**< Sets the overwrite flag. If set the patch will overwrite existing packet data,
667 otherwise data may be inserted */
669 #define PASAHO_BPATCH_SET_DELETE(x,v) \
670 PASAHO_SET_BITFIELD((x)->word0, v, 18, 1)
671 /**< Sets the delete flag. If set, no data will be inserted */
674 #define PASAHO_BPATCH_SET_OFFSET(x,v) \
675 PASAHO_SET_BITFIELD((x)->word0, v, 0, 16)
676 /**< Sets the offset to the start of the patch */
678 #define PASAHO_BPATCH_SET_PATCH_BYTE(x, byteNum, byte) \
679 PASAHO_SET_BITFIELD((x)->patch[(byteNum) >> 2], byte, ((3 - (byteNum & 0x3)) << 3), 8)
680 /**< Sets the data to patch */
682 /*@}*/ /* @name PASAHO Blind Patch Command Macros */
683 /** @}*/ /* PASAHO_blind_patch_command_macros */
685 /* Report Timestamp command */
686 /**
687 * @ingroup pasaho_if_structures
688 * @brief pasahoReportTimestamp_t defines the report timestamp command. The command structure is defined as 32 bit
689 * values to work with the hardware regardless of the device endianness.
690 *
691 * @details
692 */
694 typedef struct pasahoReportTimestamp_s {
695 uint32_t word0; /**< Contains the report timestamp command information. @ref PASAHO_report_timestamp_command_macros */
696 uint32_t swInfo0; /**< Information placed into returned descriptor of the reporting packet. */
697 } pasahoReportTimestamp_t;
699 /**
700 * @defgroup PASAHO_report_timestamp_command_macros PASAHO Report Timestamp Command Macros
701 * @ingroup pasaho_if_macros
702 * @{
703 * @name PASAHO Report Timestamp Command Macros
704 * Macros used by the PASAHO Report Timestamp Command
705 *
706 */
707 /*@{*/
708 #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 */
709 #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 */
711 /*@}*/ /* @name PASAHO Report Timestamp Command Macros */
712 /** @}*/ /* PASAHO_report_timestamp_command_macros */
714 /* IP Fragmentation command */
715 /**
716 * @ingroup pasaho_if_structures
717 * @brief pasahoIpFrag_t defines the IP Fragmentation command. The command structure is defined as 32 bit
718 * values to work with the hardware regardless of the device endianness.
719 *
720 * @details
721 */
723 typedef struct pasahoIpFrag_s {
724 uint32_t word0; /**< Contains the ip fragmentation command information. @ref PASAHO_ip_frag_command_macros */
725 } pasahoIpFrag_t;
727 /**
728 * @defgroup PASAHO_ip_frag_command_macros PASAHO IP Fragmentation Command Macros
729 * @ingroup pasaho_if_macros
730 * @{
731 * @name PASAHO IP Fragmentation Command Macros
732 * Macros used by the PASAHO IP Fragmentation Command
733 *
734 */
735 /*@{*/
737 #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 */
738 #define PASAHO_SET_SUB_CODE(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 24, 5) /**< Specifies the sub-command code */
739 #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 */
740 #define PASAHO_SET_MTU_SIZE(x,v) PASAHO_SET_BITFIELD((x)->word0, (v), 0, 16) /**< Specifies the MTU size */
742 /*@}*/ /* @name PASAHO IP Fragmentation Command Macros */
743 /** @}*/ /* PASAHO_ip_frag_command_macros */
746 /* Patch Message Length command */
747 /**
748 * @ingroup pasaho_if_structures
749 * @brief pasahoPatchMsgLen_t defines the message length patching command. The command structure is defined as 32 bit
750 * values to work with the hardware regardless of the device endianness.
751 *
752 * @details
753 */
755 typedef struct pasahoPatchMsgLen_s {
756 uint32_t word0; /**< Contains the message length patching command information. @ref PASAHO_patch_msg_len_command_macros */
757 } pasahoPatchMsgLen_t;
759 /**
760 * @defgroup PASAHO_patch_msg_len_command_macros PASAHO Message Length Patching Command Macros
761 * @ingroup pasaho_if_macros
762 * @{
763 * @name PASAHO Message Length Patching Command Macros
764 * Macros used by the PASAHO Message Length Patching Command
765 *
766 */
767 /*@{*/
769 #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 */
770 #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 */
771 #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) */
772 #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 */
774 /*@}*/ /* @name PASAHO Message Length Patching Command Macros */
775 /** @}*/ /* PASAHO_patch_msg_len_command_macros */
779 #ifdef __cplusplus
780 }
781 #endif
783 #endif /* _PASAHO_H */