USRP Hardware Driver and USRP Manual  Version: 3.14.0.HEAD-0-g28fe2e2c
UHD and USRP Manual
vrt_if_packet.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2010-2014 Ettus Research LLC
3 // Copyright 2018 Ettus Research, a National Instruments Company
4 //
5 // SPDX-License-Identifier: GPL-3.0-or-later
6 //
7 
8 #ifndef INCLUDED_UHD_TRANSPORT_VRT_IF_PACKET_HPP
9 #define INCLUDED_UHD_TRANSPORT_VRT_IF_PACKET_HPP
10 
11 #include <uhd/config.hpp>
12 #include <stdint.h>
13 #include <cstddef> //size_t
14 
15 namespace uhd{ namespace transport{
16 
17 namespace vrt{
18 
20  static const size_t num_vrl_words32 = 3;
21 
23  static const size_t max_if_hdr_words32 = 7; //hdr+sid+cid+tsi+tsf
24 
31  {
32  if_packet_info_t(void);
33 
34  //link layer type - always set for pack and unpack
36  {
37  LINK_TYPE_NONE = 0x0,
38  LINK_TYPE_CHDR = 0x1,
39  LINK_TYPE_VRLP = 0x2
40  } link_type;
41 
42  //packet type
44  {
45  // VRT language:
46  PACKET_TYPE_DATA = 0x0,
47  PACKET_TYPE_IF_EXT = 0x1,
48  PACKET_TYPE_CONTEXT = 0x2, //extension context: has_sid = true
49 
50  // CHDR language:
51  //PACKET_TYPE_DATA = 0x0, // Data
52  PACKET_TYPE_FC = 0x1, // Flow control
53  PACKET_TYPE_ACK = 0x1, // Flow control (ack)
54  PACKET_TYPE_CMD = 0x2, // Command
55  PACKET_TYPE_RESP = 0x3, // Command response
56  PACKET_TYPE_ERROR = 0x3 // Command response: Error (the EOB bit is raised in this case)
57  } packet_type;
58 
59  //size fields
60  size_t num_payload_words32; //required in pack, derived in unpack
61  size_t num_payload_bytes; //required in pack, derived in unpack
62  size_t num_header_words32; //derived in pack, derived in unpack
63  size_t num_packet_words32; //derived in pack, required in unpack
64 
65  //header fields
66  size_t packet_count;
68  bool sob, eob;
70  bool error;
72  bool fc_ack;
73 
74  //optional fields
76  bool has_sid; uint32_t sid;
78  bool has_cid; uint64_t cid;
80  bool has_tsi; uint32_t tsi;
82  bool has_tsf; uint64_t tsf;
84  bool has_tlr; uint32_t tlr;
85  };
86 
112  UHD_API void if_hdr_pack_be(
113  uint32_t *packet_buff,
114  if_packet_info_t &if_packet_info
115  );
116 
151  const uint32_t *packet_buff,
152  if_packet_info_t &if_packet_info
153  );
154 
163  UHD_API void if_hdr_pack_le(
164  uint32_t *packet_buff,
165  if_packet_info_t &if_packet_info
166  );
167 
177  const uint32_t *packet_buff,
178  if_packet_info_t &if_packet_info
179  );
180 
182  link_type(LINK_TYPE_NONE),
183  packet_type(PACKET_TYPE_DATA),
184  num_payload_words32(0),
185  num_payload_bytes(0),
186  num_header_words32(0),
187  num_packet_words32(0),
188  packet_count(0),
189  sob(false), eob(false),
190  error(false), fc_ack(false),
191  has_sid(false), sid(0),
192  has_cid(false), cid(0),
193  has_tsi(false), tsi(0),
194  has_tsf(false), tsf(0),
195  has_tlr(false), tlr(0)
196  {}
197 
198 } //namespace vrt
199 
200 }} //namespace
201 
202 #endif /* INCLUDED_UHD_TRANSPORT_VRT_IF_PACKET_HPP */
Definition: vrt_if_packet.hpp:30
size_t num_packet_words32
Definition: vrt_if_packet.hpp:63
UHD_API void if_hdr_unpack_le(const uint32_t *packet_buff, if_packet_info_t &if_packet_info)
if_packet_info_t(void)
Definition: vrt_if_packet.hpp:181
packet_type_t
Definition: vrt_if_packet.hpp:43
uint64_t tsf
Definition: vrt_if_packet.hpp:82
UHD_API void if_hdr_unpack_be(const uint32_t *packet_buff, if_packet_info_t &if_packet_info)
bool has_cid
Class ID.
Definition: vrt_if_packet.hpp:78
link_type_t
Definition: vrt_if_packet.hpp:35
uint32_t tlr
Definition: vrt_if_packet.hpp:84
Definition: build_info.hpp:14
uint32_t sid
Definition: vrt_if_packet.hpp:76
UHD_API void if_hdr_pack_be(uint32_t *packet_buff, if_packet_info_t &if_packet_info)
bool error
This is asserted for command responses that are errors (CHDR only)
Definition: vrt_if_packet.hpp:70
size_t num_payload_bytes
Definition: vrt_if_packet.hpp:61
#define UHD_INLINE
Definition: config.h:53
Definition: log.hpp:109
size_t packet_count
Definition: vrt_if_packet.hpp:66
#define UHD_API
Definition: config.h:68
size_t num_payload_words32
Definition: vrt_if_packet.hpp:60
bool fc_ack
This is asserted for flow control packets are ACKS (CHDR only)
Definition: vrt_if_packet.hpp:72
UHD_API void if_hdr_pack_le(uint32_t *packet_buff, if_packet_info_t &if_packet_info)
size_t num_header_words32
Definition: vrt_if_packet.hpp:62
bool sob
Asserted for start- or end-of-burst.
Definition: vrt_if_packet.hpp:68
uint32_t tsi
Definition: vrt_if_packet.hpp:80