pktdescr_std0.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 standard packet descriptor.\n 8 * It is <b>not</b> to be used directly but via the @ref PacketMacros. 9 */ 10 11#ifndef DOXYGEN_INTERNAL_ONLY 12 13#ifndef __PKT_DESCR_STD_H__ 14#define __PKT_DESCR_STD_H__ 15 16// Ensure that the following is packed. 17#pragma pack(push, 1) 18 19/** 20 * This descriptor is placed in front of all packets being received by the adapter when 21 * the adapter is operating in STANDARD or EXTENDED mode. 22 * Note: The descriptor is used for both RX and TX segments but not all fields apply 23 * in both directions. 24 */ 25#define _NT_DESCR_STD0_FIELDS \ 26 /* Offset 0x00. */ \ 27 uint64_t timestamp; /* RX & TX - 64 Bit time stamp */ \ 28 /* Offset 0x08. */ \ 29 uint32_t storedLength:16; /* RX & TX - length of stored data incl. padding */ \ 30 uint32_t crcError:1; /* RX & TX - Ethernet CRC Error */ \ 31 uint32_t TCPCsumOk:1; /* RX & TX - indicates TCP checksum is correct */ \ 32 uint32_t UDPCsumOk:1; /* RX & TX - indicates UDP checksum is correct */ \ 33 uint32_t IPCsumOk:1; /* RX & TX - indicates IP checksum is correct */ \ 34 uint32_t txCrcOverride:1; /* RX & TX - recalculate the MAC frame CRC */ \ 35 uint32_t cvError:1; /* RX & TX - indicates that this frame had a code violation */ \ 36 uint32_t txSetClock:1; /* TX - Set the FPGA transmission clock equal to the time stamp of this packet */ \ 37 uint32_t frameSliced:1; /* RX & TX - indicates that the current frame has been sliced (either soft or hard) */ \ 38 uint32_t rxPort:5; /* RX only - the adapter port that received the current frame */ \ 39 uint32_t hardSlice:1; /* RX & TX - the packet length is longer than the hardware can handle and has been hard sliced */ \ 40 uint32_t txNow:1; /* TX only - 0 = preserve original IFG between frames, 1 = transmit not preserving original IFG */ \ 41 uint32_t txIgnore:1; /* TX only - setting this bit to 1 will prevent the frame from being transmitted */ \ 42 /* Offset 0x0C. */ \ 43 uint32_t wireLength:16; /* RX & TX - length of frame on the wire */ \ 44 uint32_t txPort:5; /* RX & TX - the adapter port that should transmit the frame */ \ 45 uint32_t TCPFrame:1; /* RX only - indicates the current frame is TCP */ \ 46 uint32_t UDPFrame:1; /* RX only - indicates the current frame is UDP */ \ 47 uint32_t IPFrame:1; /* RX only - indicates the current frame is IP */ \ 48 uint32_t descriptorType:1; /* RX & TX - 0 = PCAP or 1 = STANDARD/EXTENDED, must be 1 for TX */ \ 49 uint32_t extensionLength:3; /* RX & TX - extended header length in 8 byte units, must be 0 or 2 for TX */ \ 50 uint32_t extensionFormat:4; /* RX & TX - extension format type */ 51 52typedef struct NtStd0Descr_s { 53 _NT_DESCR_STD0_FIELDS 54} NtStd0Descr_t; 55 56// Disable 1-byte packing 57#pragma pack(pop) 58 59 60#define _NT_NET_GET_PKT_NT_DESCR_TYPE(_hNetBuf_) ((_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->descriptorType == 0) ? \ 61 NT_PACKET_DESCRIPTOR_TYPE_PCAP : \ 62 ((_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionFormat == 0 ? \ 63 NT_PACKET_DESCRIPTOR_TYPE_NT : NT_PACKET_DESCRIPTOR_TYPE_NT_EXTENDED))) 64#define _NT_NET_GET_PKT_NT_DESCR_FORMAT(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionFormat) 65 66#define _NT_NET_GET_PKT_NT_DESCR_LENGTH(_hNetBuf_) ((uint8_t)sizeof(NtStd0Descr_t)+(_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionLength<<3)) 67#define _NT_NET_GET_PKT_NT_CAP_LENGTH(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->storedLength) 68 69#define _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_) ((NtStd0Descr_t*)(_hNetBuf_)->hHdr) 70 71#define _NT_NET_GET_PKT_DESCRIPTOR_TYPE(_hNetBuf_) ((_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->ntDynDescr == 1 ? \ 72 NT_PACKET_DESCRIPTOR_TYPE_DYNAMIC : _NT_NET_GET_PKT_NT_DESCR_TYPE(_hNetBuf_))) 73 74#define _NT_NET_GET_PKT_DESCRIPTOR_FORMAT(_hNetBuf_) ((_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->ntDynDescr == 1 ? \ 75 _NT_NET_GET_PKT_DESCR_FORMAT_DYN(_hNetBuf_) : _NT_NET_GET_PKT_NT_DESCR_FORMAT(_hNetBuf_))) 76 77#define _NT_NET_GET_PKT_DESCR_PTR(_hNetBuf_) ((NtPktDescr_t*)(_hNetBuf_)->hHdr) 78#define _NT_NET_GET_PKT_DESCR_LENGTH(_hNetBuf_) (((_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->ntDynDescr == 1 ? \ 79 _NT_NET_GET_PKT_DESCR_LENGTH_DYN(_hNetBuf_) : _NT_NET_GET_PKT_NT_DESCR_LENGTH(_hNetBuf_)))) 80#define _NT_NET_GET_PKT_TIMESTAMP(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->timestamp) 81#define _NT_NET_GET_PKT_TIMESTAMP_TYPE(_hNetBuf_) ((_hNetBuf_)->tsType) 82#define _NT_NET_GET_PKT_CAP_LENGTH(_hNetBuf_) (((_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->ntDynDescr == 1 ? \ 83 _NT_NET_GET_PKT_CAP_LENGTH_DYN(_hNetBuf_) : _NT_NET_GET_PKT_NT_CAP_LENGTH(_hNetBuf_)))) 84#define _NT_NET_GET_PKT_WIRE_LENGTH(_hNetBuf_) (((_NT_NET_GET_PKT_DESCR_PTR_DYN(_hNetBuf_)->ntDynDescr == 0 ? \ 85 (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->wireLength) : _NT_NET_GET_PKT_WIRE_LENGTH_DYN(_hNetBuf_)))) 86 87#define _NT_NET_GET_PKT_L2_PTR(_hNetBuf_) ((void*)(_hNetBuf_)->hPkt) 88#define _NT_NET_UPDATE_PKT_L2_PTR(_hNetBuf_) (((_hNetBuf_)->hPkt)=(NtNetBufPkt_t)((uint8_t*)((_hNetBuf_)->hHdr)+_NT_NET_GET_PKT_DESCR_LENGTH(_hNetBuf_))) 89 90#define _NT_NET_GET_PKT_CRC_ERROR(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->crcError) 91#define _NT_NET_GET_PKT_TCP_CSUM_OK(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->TCPCsumOk) 92#define _NT_NET_GET_PKT_UDP_CSUM_OK(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->UDPCsumOk) 93#define _NT_NET_GET_PKT_IP_CSUM_OK(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->IPCsumOk) 94#define _NT_NET_GET_PKT_CV_ERROR(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->cvError) 95#define _NT_NET_GET_PKT_SLICED(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->frameSliced) 96#define _NT_NET_GET_PKT_HARD_SLICED(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->hardSlice) 97#define _NT_NET_GET_PKT_RXPORT(_hNetBuf_) ((_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->rxPort+(_hNetBuf_)->portOffset)) 98#define _NT_NET_GET_PKT_RECALC_L2_CRC(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txCrcOverride) 99#define _NT_NET_GET_PKT_TXNOW(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txNow) 100#define _NT_NET_GET_PKT_TXIGNORE(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txIgnore) 101#define _NT_NET_GET_PKT_IS_TCP(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->TCPFrame) 102#define _NT_NET_GET_PKT_IS_UDP(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->UDPFrame) 103#define _NT_NET_GET_PKT_IS_IP(_hNetBuf_) (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->IPFrame) 104 105#define _NT_NET_GET_PKT_TXPORT(_hNetBuf_) \ 106 ((_hNetBuf_)->egressPort == -1 ? \ 107 (_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txPort + (_hNetBuf_)->portOffset) : (_hNetBuf_)->egressPort) 108 109#define _NT_NET_SET_PKT_CAP_LENGTH(_hNetBuf_,_Length_) do{ _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->storedLength = \ 110 (uint16_t) (((_Length_)+(_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionLength<<3) + \ 111 sizeof(struct NtStd0Descr_s)+7)&~7); } while(0) 112 113#define _NT_NET_SET_PKT_CAP_LENGTH_NOALIGN(_hNetBuf_,_Length_) do{ _NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->storedLength = \ 114 (uint16_t) (((_Length_)+(_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->extensionLength<<3) + \ 115 sizeof(struct NtStd0Descr_s))); } while(0) 116 117#define _NT_NET_SET_PKT_WIRE_LENGTH(_hNetBuf_,_Length_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->wireLength=(_Length_);}while(0) 118#define _NT_NET_SET_PKT_TXPORT(_hNetBuf_,_Port_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txPort=(uint8_t)(((_Port_)-(_hNetBuf_)->portOffset)&0x1F);}while(0) 119 120#define _NT_NET_SET_PKT_RECALC_L2_CRC(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txCrcOverride=(_bval_);}while(0) 121#define _NT_NET_SET_PKT_TIMESTAMP(_hNetBuf_, _ts_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->timestamp=(_ts_);}while(0) 122#define _NT_NET_SET_PKT_TXNOW(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txNow=(_bval_);}while(0) 123#define _NT_NET_SET_PKT_TXSETCLOCK(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txSetClock=(_bval_);}while(0) 124#define _NT_NET_SET_PKT_TXIGNORE(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->txIgnore=(_bval_);}while(0) 125#define _NT_NET_SET_PKT_IS_IP(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->IPFrame=(_bval_);}while(0) 126#define _NT_NET_SET_PKT_IS_UDP(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->UDPFrame=(_bval_);}while(0) 127#define _NT_NET_SET_PKT_IS_TCP(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->TCPFrame=(_bval_);}while(0) 128#define _NT_NET_SET_PKT_CRC_ERROR(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->crcError=(_bval_);}while(0) 129#define _NT_NET_SET_PKT_TCP_CSUM_OK(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->TCPCsumOk=(_bval_);}while(0) 130#define _NT_NET_SET_PKT_UDP_CSUM_OK(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->UDPCsumOk=(_bval_);}while(0) 131#define _NT_NET_SET_PKT_IP_CSUM_OK(_hNetBuf_, _bval_) do{_NT_NET_GET_PKT_DESCR_PTR_STD0(_hNetBuf_)->IPCsumOk=(_bval_);}while(0) 132 133#endif /* __PKT_DESCR_STD_H__ */ 134 135#endif // DOXYGEN_INTERNAL_ONLY