pktdescr_dyn4.h

Reference Documentation

Platform
Napatech SmartNIC
Content Type
Reference Information

Go to the documentation of this file.

1/* 2 * %NT_SOFTWARE_LICENSE% 3 */ 4 5/** 6 * @file 7 * This source file contains the NT_DYN4 variable packet descriptor.\n 8 */ 9 10#ifndef __PKT_DESCR_DYN4_H__ 11#define __PKT_DESCR_DYN4_H__ 12 13/** @addtogroup PacketDescriptorDyn4 14 * @{ 15 * 16 * This descriptor provides the option to have the 64-bit correlation key in 17 * the color1 field, alternatively (the default) 32-bits color and 32-bits 18 * hash value can be provided in color1. The color0 field contains the lower 8 19 * bits of the color when the color1 field is used for correlation key, 20 * otherwise (the default) color0 contains the outer protocol number 21 * The default values for the dynamic parts are: 22 * 23 * offset0 = outer L3\n 24 * offset1 = outer L4\n 25 * color0 = outer Protocol / Next Header field\n 26 * color1[31:0] = color value\n 27 * color1[63:32] = hash value\n 28 * descrLength = 24\n 29 * 30 */ 31 32// Ensure that the following is packed. 33#pragma pack(push, 1) 34 35/** 36 * @brief NT Variable descriptor 4 37 */ 38typedef struct NtDyn4Descr_s { 39 40 uint64_t capLength:14; /* 0: The length of the packet incl. descriptor. */ 41 uint64_t offset0:10; /* 14: Programmable offset into the packet. */ 42 uint64_t offset1:10; /* 24: Programmable offset into the packet. */ 43 uint64_t color0:8; /* 34: Programmable packet color. */ 44 uint64_t rxPort:6; /* 42: The port that received the frame. */ 45 uint64_t descrFormat:8; /* 48: The descriptor type. */ 46 uint64_t descrLength:6; /* 56: The length of the descriptor in bytes. */ 47 uint64_t tsColor:1; /* 62: Timestamp color. */ 48 uint64_t ntDynDescr:1; /* 63: Set to 1 to identify this descriptor as a dynamic descriptor. */ 49 uint64_t timestamp; /* 64: The time of arrival of the packet. */ 50 uint64_t color1; /*128: Programmable packet color. */ 51 52} NtDyn4Descr_t; // descrFormat = 4, default descrLength = 24 53 54// Disable 1-byte packing 55#pragma pack(pop) 56 57#ifndef DOXYGEN_INTERNAL_ONLY 58#define _NT_NET_GET_PKT_DESCR_PTR_DYN4(_hNetBuf_) ((NtDyn4Descr_t*)(_hNetBuf_)->hHdr) 59#endif // DOXYGEN_INTERNAL_ONLY 60 61/** @def NT_NET_DESCR_PTR_DYN4 62 * @brief Get a pointer to the packet descriptor 63 * @param[in] "_hNetBuf_" Packet container reference 64 * @return Returns a pointer of type NtDyn4Descr_t* 65 * @hideinitializer 66 */ 67#define NT_NET_DESCR_PTR_DYN4(_hNetBuf_) ((_NT_NET_GET_PKT_DESCR_PTR_DYN4(_hNetBuf_)->descrFormat==4 ? \ 68 (NtDyn4Descr_t*)(_hNetBuf_->hHdr) : (NtDyn4Descr_t*)_NT_NET_DESCR_CAST_ASSERT(NULL))) 69 70 71#ifdef DEBUG 72//Guards against misconfigurations 73#ifdef _MSC_VER 74static void __nt_dyn4_check__(void); 75#else 76static void __nt_dyn4_check__(void) __attribute__ ((unused)); 77#endif 78static void __nt_dyn4_check__(void) { 79 //Compile-time check to avoid sizeof(NtDyn4Descr_t) != 24 80#ifndef WIN32 81 switch (0) { case 0: case sizeof (NtDyn4Descr_t) == 24: ; } 82#endif 83} 84#endif // DEBUG 85 86/** @} */ 87 88#endif // __PKT_DESCR_DYN4_H__ 89