pktdescr_dyn3.h

Reference Documentation

product_line_custom
Napatech SmartNIC
category
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_DYN3 variable packet descriptor.\n 8 */ 9 10#ifndef __PKT_DESCR_DYN3_H__ 11#define __PKT_DESCR_DYN3_H__ 12 13/** @addtogroup PacketDescriptorDyn3 14 * @{ 15 * 16 * This descriptor is suited for TX and includes the wire length as well as color bits 17 * in the first 8 bytes of the descriptor. This allows SW to reduce the frame size before 18 * TX by modifying the wire length and it allows reduction of the descriptor length down 19 * to only 8 bytes while retaining the possibility to encode TX flags such as txIgnore in 20 * the color. The default values for the dynamic parts are: 21 * 22 * offset0 = outer L3\n 23 * offset1 = outer L4 24 * 25 * descrFormat = 3\n 26 * descrLength = 22 27 * 28 */ 29 30// Ensure that the following is packed. 31#pragma pack(push, 1) 32 33/** 34 * @brief NT Variable descriptor 3 35 */ 36typedef struct NtDyn3Descr_s { 37 uint64_t capLength:14; /**< The length of the packet incl. descriptor. */ /* 0*/ 38 uint64_t wireLength:14; /**< The wire length of the packet. */ /* 14*/ 39 uint64_t color_lo:14; /**< Programmable packet color[13:0]. */ /* 28*/ 40 uint64_t rxPort:6; /**< The port that received the frame. */ /* 42*/ 41 uint64_t descrFormat:8; /**< The descriptor type. */ /* 48*/ 42 uint64_t descrLength:6; /**< The length of the descriptor in bytes. */ /* 56*/ 43 uint64_t tsColor:1; /**< Timestamp color. */ /* 62*/ 44 uint64_t ntDynDescr:1; /**< Set to 1 to identify this descriptor as a */ /* 63*/ 45 /**< dynamic descriptor. */ 46 uint64_t timestamp; /**< The time of arrival of the packet. */ /* 64*/ 47 uint64_t color_hi:28; /**< Programmable packet color[41:14]. */ /*128*/ 48 uint64_t offset0:10; /**< Programmable offset into the packet. */ /*156*/ 49 uint64_t offset1:10; /**< Programmable offset into the packet. */ /*166*/ 50} NtDyn3Descr_t; // descrFormat = 3, descrLength = 22 51 52// Disable 1-byte packing 53#pragma pack(pop) 54 55#ifndef DOXYGEN_INTERNAL_ONLY 56#define _NT_NET_GET_PKT_DESCR_PTR_DYN3(_hNetBuf_) ((NtDyn3Descr_t*)(_hNetBuf_)->hHdr) 57#endif // DOXYGEN_INTERNAL_ONLY 58 59/** @def NT_NET_DESCR_PTR_DYN3 60 * @brief Get a pointer to the packet descriptor 61 * @param[in] "_hNetBuf_" Packet container reference 62 * @return Returns a pointer of type NtDyn3Descr_t* 63 * @hideinitializer 64 */ 65#define NT_NET_DESCR_PTR_DYN3(_hNetBuf_) ((_NT_NET_GET_PKT_DESCR_PTR_DYN3(_hNetBuf_)->descrFormat==3 ? \ 66 (NtDyn3Descr_t*)(_hNetBuf_->hHdr) : (NtDyn3Descr_t*)_NT_NET_DESCR_CAST_ASSERT(NULL))) 67 68 69#ifdef DEBUG 70//Guards against misconfigurations 71#ifdef _MSC_VER 72static void __nt_dyn3_check__(void); 73#else 74static void __nt_dyn3_check__(void) __attribute__ ((unused)); 75#endif 76static void __nt_dyn3_check__(void) { 77 //Compile-time check to avoid sizeof(NtDyn3Descr_t) != 22 78#ifndef WIN32 79 switch (0) { case 0: case sizeof (NtDyn3Descr_t) == 22: ; } 80#endif 81} 82#endif // DEBUG 83 84/** @} */ 85 86#endif // __PKT_DESCR_DYN3_H__ 87