pktdescr_dyn3.h Source File

Reference Documentation

Platform
Intel® PAC
Napatech SmartNIC
Content Type
Reference Information
Capture Software Version
Link™ Capture Software 12.10
Napatech Software Suite: include/ntapi/pktdescr_dyn3.h Source File
pktdescr_dyn3.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (C) 2023 Napatech A/S.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  * * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * * Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * * Neither the name of the Napatech A/S nor the
14  * names of its contributors may be used to endorse or promote products
15  * derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL NAPATECH A/S BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  *
29 
30  */
31 
32 /**
33  * @file
34  * This source file contains the NT_DYN3 variable packet descriptor.\n
35  */
36 
37 #ifndef __PKT_DESCR_DYN3_H__
38 #define __PKT_DESCR_DYN3_H__
39 
40 /** @addtogroup PacketDescriptorDyn3
41  * @{
42  *
43  * This descriptor is suited for TX and includes the wire length as well as color bits
44  * in the first 8 bytes of the descriptor. This allows SW to reduce the frame size before
45  * TX by modifying the wire length and it allows reduction of the descriptor length down
46  * to only 8 bytes while retaining the possibility to encode TX flags such as txIgnore in
47  * the color. The default values for the dynamic parts are:
48  *
49  * offset0 = outer L3\n
50  * offset1 = outer L4
51  *
52  * descrFormat = 3\n
53  * descrLength = 22
54  *
55  */
56 
57 // Ensure that the following is packed.
58 #pragma pack(push, 1)
59 
60 /**
61  * @brief NT Variable descriptor 3
62  */
63 typedef struct NtDyn3Descr_s {
64  uint64_t capLength:14; /**< The length of the packet incl. descriptor. */ /* 0*/
65  uint64_t wireLength:14; /**< The wire length of the packet. */ /* 14*/
66  uint64_t color_lo:14; /**< Programmable packet color[13:0]. */ /* 28*/
67  uint64_t rxPort:6; /**< The port that received the frame. */ /* 42*/
68  uint64_t descrFormat:8; /**< The descriptor type. */ /* 48*/
69  uint64_t descrLength:6; /**< The length of the descriptor in bytes. */ /* 56*/
70  uint64_t tsColor:1; /**< Timestamp color. Reserved for future use. */ /* 62*/
71  uint64_t ntDynDescr:1; /**< Set to 1 to identify this descriptor as a */ /* 63*/
72  /**< dynamic descriptor. */
73  uint64_t timestamp; /**< The time of arrival of the packet. */ /* 64*/
74  uint64_t color_hi:28; /**< Programmable packet color[41:14]. */ /*128*/
75  uint64_t offset0:10; /**< Programmable offset into the packet. */ /*156*/
76  uint64_t offset1:10; /**< Programmable offset into the packet. */ /*166*/
77 } NtDyn3Descr_t; // descrFormat = 3, descrLength = 22 /*176 bits*/
78 
79 // Disable 1-byte packing
80 #pragma pack(pop)
81 
82 #ifndef DOXYGEN_INTERNAL_ONLY
83 
84 
85 #define _NT_NET_GET_PKT_DESCR_PTR_DYN3(_hNetBuf_) ((NtDyn3Descr_t*)(_hNetBuf_)->hHdr)
86 
87 
88 #ifdef DEBUG
89 //Guards against misconfigurations
90 #ifdef _MSC_VER
91 static void __nt_dyn3_check__(void);
92 #else
93 static void __nt_dyn3_check__(void) __attribute__ ((unused));
94 #endif
95 static void __nt_dyn3_check__(void) {
96  //Compile-time check to avoid sizeof(NtDyn3Descr_t) != 22
97 #ifndef WIN32
98  switch (0) { case 0: case sizeof (NtDyn3Descr_t) == 22: ; }
99 #endif
100 }
101 #endif // DEBUG
102 
103 #endif // DOXYGEN_INTERNAL_ONLY
104 
105 /** @} */
106 
107 #endif // __PKT_DESCR_DYN3_H__