pktdescr_dyn.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_dyn.h Source File
pktdescr_dyn.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_DYN dynamic packet descriptor base.\n
35  * It is <b>not</b> to be used directly but via the @ref PacketMacros.
36  */
37 
38 /** @addtogroup PacketDescriptor
39  *
40  * This is a new class of descriptors that offer more flexibility and less overhead
41  * than the legacy NT and extended descriptors.
42  * The descriptors provide several offset fields that can be programmed via. NTPL as
43  * well as an extended color field that allow for more color and hash bits.
44  *
45  * Unlike the legacy descriptors, dynamic descriptor fields are accessed directly
46  * through the c-struct by obtaining a pointer to it from @ref NtNetBuf_s and the
47  * NT_NET_DESCR_PTR_DYN<X> macros.
48  *
49  * <b>NOTE:</b> The <i>rxPort</i> field indicates the adapter relative port the packet
50  * was received on. To get the absolute port number, @ref NtNetBuf_s.portOffset should
51  * be manually added.
52  *
53  * <b>NOTE:</b> The format of the "timestamp" field in the dynamic descriptors is dependent
54  * upon what is configured in the ini-file setting "TimestampFormat". For a description
55  * of the possible formats see @ref NtTimestampType_e
56  */
57 
58 #ifndef DOXYGEN_INTERNAL_ONLY
59 
60 #ifndef __PKT_DESCR_DYN_H__
61 #define __PKT_DESCR_DYN_H__
62 
63 // Ensure that the following is packed.
64 #pragma pack(push, 1)
65 
66 typedef struct NtDynDescr_s {
67  uint64_t capLength:14; /* 0: The length of the packet incl. descriptor. */
68  uint64_t unused0:34; /* 14: To be used for acceleration fields. */
69  uint64_t descrFormat:8; /* 48: The variable descriptor format. */
70  uint64_t descrLength:6; /* 56: The length of the descriptor in bytes. */
71  uint64_t unused1:1; /* 62: To be used for acceleration fields. */
72  uint64_t ntDynDescr:1; /* 63: Set to 1 to identify this descriptor as a dynamic */
73 } NtDynDescr_t;
74 
75 // Disable 1-byte packing
76 #pragma pack(pop)
77 
78 
79 #define _NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_) ((NtDynDescr_t*)(_hNetBuf_)->hHdr)
80 
81 //
82 // Getters
83 //
84 #define _NT_NET_GET_PKT_CAP_LENGTH_DYN(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->capLength)
85 #define _NT_NET_GET_PKT_DESCR_FORMAT_DYN(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->descrFormat)
86 // descrLength == 0 means descriptor length is 64
87 #define _NT_NET_GET_PKT_DESCR_LENGTH_DYN(_hNetBuf_) ((64&(_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->descrLength-1)) + _NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->descrLength)
88 #define _NT_NET_GET_PKT_DYN_DESCR_DYN(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->ntDynDescr)
89 // The timestamp is stored in the same bits for each of the current 4 dynamic descriptors
90 #define _NT_NET_GET_PKT_TIMESTAMP_DYN(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_DYN1(_hNetBuf_)->timestamp)
91 
92 //
93 // Setters
94 //
95 #define _NT_NET_SET_PKT_CAP_LENGTH_NOALIGN_DYN(_hNetBuf_,_val_) do{_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->capLength=\
96  (uint16_t)((_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->descrLength+(_val_))&0x3FFF);}while(0)
97 #define _NT_NET_SET_PKT_DESCR_FORMAT_DYN(_hNetBuf_, _val_) do{_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->descrFormat=(_val_);}while(0)
98 // descrLength == 0 means descriptor length is 64
99 #define _NT_NET_SET_PKT_DESCR_LENGTH_DYN(_hNetBuf_, _val_) do{_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->descrLength=(_val_);}while(0)
100 #define _NT_NET_SET_PKT_DYN_DESCR_DYN(_hNetBuf_, _val_) do{_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->ntDynDescr=(_val_);}while(0)
101 // The timestamp is stored in the same bits for each of the current 4 dynamic descriptors
102 #define _NT_NET_SET_PKT_TIMESTAMP_DYN(_hNetBuf_, _val_) do{_NT_NET_GET_PKT_DESCR_PTR_DYN1(_hNetBuf_)->timestamp=(_val_);}while(0)
103 
104 #endif // __PKT_DESCR_VAR_H__
105 #endif // DOXYGEN_INTERNAL_ONLY