pktdescr_std0.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_std0.h Source File
pktdescr_std0.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 standard packet descriptor.\n
35  * It is <b>not</b> to be used directly but via the @ref PacketMacros.
36  */
37 
38 #ifndef DOXYGEN_INTERNAL_ONLY
39 
40 #ifndef __PKT_DESCR_STD_H__
41 #define __PKT_DESCR_STD_H__
42 
43 // Ensure that the following is packed.
44 #pragma pack(push, 1)
45 
46 /**
47  * This descriptor is placed in front of all packets being received by the adapter when
48  * the adapter is operating in STANDARD or EXTENDED mode.
49  * Note: The descriptor is used for both RX and TX segments but not all fields apply
50  * in both directions.
51  */
52 #define _NT_DESCR_STD0_FIELDS \
53  /* Offset 0x00. */ \
54  uint64_t timestamp; /* RX & TX - 64 Bit time stamp */ \
55  /* Offset 0x08. */ \
56  uint32_t storedLength:16; /* RX & TX - length of stored data incl. padding */ \
57  uint32_t crcError:1; /* RX & TX - Ethernet CRC Error */ \
58  uint32_t TCPCsumOk:1; /* RX & TX - indicates TCP checksum is correct */ \
59  uint32_t UDPCsumOk:1; /* RX & TX - indicates UDP checksum is correct */ \
60  uint32_t IPCsumOk:1; /* RX & TX - indicates IP checksum is correct */ \
61  uint32_t txCrcOverride:1; /* RX & TX - recalculate the MAC frame CRC */ \
62  uint32_t cvError:1; /* RX & TX - indicates that this frame had a code violation */ \
63  uint32_t txSetClock:1; /* TX - Set the FPGA transmission clock equal to the time stamp of this packet */ \
64  uint32_t frameSliced:1; /* RX & TX - indicates that the current frame has been sliced (either soft or hard) */ \
65  uint32_t rxPort:5; /* RX only - the adapter port that received the current frame */ \
66  uint32_t hardSlice:1; /* RX & TX - the packet length is longer than the hardware can handle and has been hard sliced */ \
67  uint32_t txNow:1; /* TX only - 0 = preserve original IFG between frames, 1 = transmit not preserving original IFG */ \
68  uint32_t txIgnore:1; /* TX only - setting this bit to 1 will prevent the frame from being transmitted */ \
69  /* Offset 0x0C. */ \
70  uint32_t wireLength:16; /* RX & TX - length of frame on the wire */ \
71  uint32_t txPort:5; /* RX & TX - the adapter port that should transmit the frame */ \
72  uint32_t TCPFrame:1; /* RX only - indicates the current frame is TCP */ \
73  uint32_t UDPFrame:1; /* RX only - indicates the current frame is UDP */ \
74  uint32_t IPFrame:1; /* RX only - indicates the current frame is IP */ \
75  uint32_t descriptorType:1; /* RX & TX - 0 = PCAP or 1 = STANDARD/EXTENDED, must be 1 for TX */ \
76  uint32_t extensionLength:3; /* RX & TX - extended header length in 8 byte units, must be 0 or 2 for TX */ \
77  uint32_t extensionFormat:4; /* RX & TX - extension format type */
78 
79 typedef struct NtStd0Descr_s {
80  _NT_DESCR_STD0_FIELDS
81 } NtStd0Descr_t; // descrLength = 16 /*128 bits*/
82 
83 // Disable 1-byte packing
84 #pragma pack(pop)
85 
86 #define _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_) ((NtStd0Descr_t*)(_hNetBuf_)->hHdr)
87 
88 //
89 // Getters
90 //
91 #define _NT_NET_GET_PKT_TIMESTAMP_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->timestamp)
92 #define _NT_NET_GET_PKT_CAP_LENGTH_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->storedLength)
93 #define _NT_NET_GET_PKT_CRC_ERROR_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->crcError)
94 #define _NT_NET_GET_PKT_TCP_CSUM_OK_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->TCPCsumOk)
95 #define _NT_NET_GET_PKT_UDP_CSUM_OK_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->UDPCsumOk)
96 #define _NT_NET_GET_PKT_IP_CSUM_OK_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->IPCsumOk)
97 #define _NT_NET_GET_PKT_RECALC_L2_CRC_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txCrcOverride)
98 #define _NT_NET_GET_PKT_CV_ERROR_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->cvError)
99 // Get txSetClock is excluded from the API
100 #define _NT_NET_GET_PKT_SLICED_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->frameSliced)
101 #define _NT_NET_GET_PKT_RXPORT_NT(_hNetBuf_) ((uint8_t)(_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->rxPort+(_hNetBuf_)->portOffset))
102 #define _NT_NET_GET_PKT_HARD_SLICED_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->hardSlice)
103 #define _NT_NET_GET_PKT_TXNOW_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txNow)
104 #define _NT_NET_GET_PKT_TXIGNORE_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txIgnore)
105 #define _NT_NET_GET_PKT_WIRE_LENGTH_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->wireLength)
106 #define _NT_NET_GET_PKT_TXPORT_NT(_hNetBuf_) ((_hNetBuf_)->egressPort == -1 ? \
107  (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txPort + (_hNetBuf_)->portOffset) : \
108  (_hNetBuf_)->egressPort)
109 #define _NT_NET_GET_PKT_TCP_FRAME_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->TCPFrame)
110 #define _NT_NET_GET_PKT_UDP_FRAME_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->UDPFrame)
111 #define _NT_NET_GET_PKT_IP_FRAME_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->IPFrame)
112 // Get descriptorType is excluded from the API
113 #define _NT_NET_GET_PKT_DESCR_LENGTH_NT(_hNetBuf_) ((uint8_t)sizeof(NtStd0Descr_t)+(uint16_t)(_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionLength<<3))
114 #define _NT_NET_GET_PKT_DESCR_FORMAT_NT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionFormat)
115 
116 //
117 // Setters
118 //
119 #define _NT_NET_SET_PKT_TIMESTAMP_NT(_hNetBuf_, _ts_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->timestamp=(_ts_);}while(0)
120 #define _NT_NET_SET_PKT_CAP_LENGTH_ALIGN_NT(_hNetBuf_,_Length_) do{ _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->storedLength = \
121  (uint16_t)(((uint32_t)_NT_NET_GET_PKT_DESCR_LENGTH_NT(_hNetBuf_) + (uint32_t)(_Length_) + 7U) & ~7U);} while(0)
122 #define _NT_NET_SET_PKT_CAP_LENGTH_NOALIGN_NT(_hNetBuf_,_Length_) do{ _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->storedLength = \
123  (uint16_t)((_NT_NET_GET_PKT_DESCR_LENGTH_NT(_hNetBuf_)+(_Length_) ) );} while(0)
124 #define _NT_NET_SET_PKT_CRC_ERROR_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->crcError=(_bval_);}while(0)
125 #define _NT_NET_SET_PKT_TCP_CSUM_OK_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->TCPCsumOk=(_bval_);}while(0)
126 #define _NT_NET_SET_PKT_UDP_CSUM_OK_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->UDPCsumOk=(_bval_);}while(0)
127 #define _NT_NET_SET_PKT_IP_CSUM_OK_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->IPCsumOk=(_bval_);}while(0)
128 #define _NT_NET_SET_PKT_RECALC_L2_CRC_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txCrcOverride=(_bval_);}while(0)
129 #define _NT_NET_SET_PKT_CV_ERROR_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->cvError=(_bval_);}while(0) // NEW
130 #define _NT_NET_SET_PKT_TXSETCLOCK_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txSetClock=(_bval_);}while(0)
131 #define _NT_NET_SET_PKT_SLICED_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->frameSliced=(_bval_);}while(0) // NEW
132 // Set rxPort is excluded from the API
133 #define _NT_NET_SET_PKT_HARD_SLICED_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->hardSlice=(_bval_);}while(0) // NEW
134 #define _NT_NET_SET_PKT_TXNOW_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txNow=(_bval_);}while(0)
135 #define _NT_NET_SET_PKT_TXIGNORE_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txIgnore=(_bval_);}while(0)
136 #define _NT_NET_SET_PKT_WIRE_LENGTH_NT(_hNetBuf_,_Length_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->wireLength=(_Length_);}while(0)
137 #define _NT_NET_SET_PKT_TXPORT_NT(_hNetBuf_,_Port_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txPort=(uint8_t)(((_Port_)-(_hNetBuf_)->portOffset)&0x1F);}while(0)
138 #define _NT_NET_SET_PKT_IS_TCP_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->TCPFrame=(_bval_);}while(0) // Should be excluded ??
139 #define _NT_NET_SET_PKT_IS_UDP_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->UDPFrame=(_bval_);}while(0) // Should be excluded ??
140 #define _NT_NET_SET_PKT_IS_IP_NT(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->IPFrame=(_bval_);}while(0) // Should be excluded ??
141 // Set descriptorType is excluded from the API
142 // Set extensionLength is excluded from the API
143 // Set extensionFormat is excluded from the API
144 
145 
146 #endif /* __PKT_DESCR_STD_H__ */
147 
148 #endif // DOXYGEN_INTERNAL_ONLY