USRP Hardware Driver and USRP Manual Version: 4.1.0.1
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#pragma once
9
10#include <uhd/config.hpp>
11#include <stdint.h>
12#include <cstddef> //size_t
13
14namespace uhd { namespace transport { namespace vrt {
15
17static const size_t num_vrl_words32 = 3;
18
20static const size_t max_if_hdr_words32 = 7; // hdr+sid+cid+tsi+tsf
21
28{
29 if_packet_info_t(void);
30
31 // link layer type - always set for pack and unpack
33 LINK_TYPE_NONE = 0x0,
34 LINK_TYPE_CHDR = 0x1,
35 LINK_TYPE_VRLP = 0x2
36 } link_type;
37
38 // packet type
40 // VRT language:
41 PACKET_TYPE_DATA = 0x0,
42 PACKET_TYPE_IF_EXT = 0x1,
43 PACKET_TYPE_CONTEXT = 0x2, // extension context: has_sid = true
44
45 // CHDR language:
46 // PACKET_TYPE_DATA = 0x0, // Data
47 PACKET_TYPE_FC = 0x1, // Flow control
48 PACKET_TYPE_ACK = 0x1, // Flow control (ack)
49 PACKET_TYPE_CMD = 0x2, // Command
50 PACKET_TYPE_RESP = 0x3, // Command response
51 PACKET_TYPE_ERROR =
52 0x3 // Command response: Error (the EOB bit is raised in this case)
53 } packet_type;
54
55 // size fields
56 size_t num_payload_words32; // required in pack, derived in unpack
57 size_t num_payload_bytes; // required in pack, derived in unpack
58 size_t num_header_words32; // derived in pack, derived in unpack
59 size_t num_packet_words32; // derived in pack, required in unpack
60
61 // header fields
64 bool sob, eob;
66 bool error;
68 bool fc_ack;
69
70 // optional fields
72 bool has_sid;
73 uint32_t sid;
75 bool has_cid;
76 uint64_t cid;
78 bool has_tsi;
79 uint32_t tsi;
81 bool has_tsf;
82 uint64_t tsf;
84 bool has_tlr;
85 uint32_t tlr;
86};
87
113UHD_API void if_hdr_pack_be(uint32_t* packet_buff, if_packet_info_t& if_packet_info);
114
149 const uint32_t* packet_buff, if_packet_info_t& if_packet_info);
150
159UHD_API void if_hdr_pack_le(uint32_t* packet_buff, if_packet_info_t& if_packet_info);
160
170 const uint32_t* packet_buff, if_packet_info_t& if_packet_info);
171
173 : link_type(LINK_TYPE_NONE)
174 , packet_type(PACKET_TYPE_DATA)
175 , num_payload_words32(0)
176 , num_payload_bytes(0)
177 , num_header_words32(0)
178 , num_packet_words32(0)
179 , packet_count(0)
180 , sob(false)
181 , eob(false)
182 , error(false)
183 , fc_ack(false)
184 , has_sid(false)
185 , sid(0)
186 , has_cid(false)
187 , cid(0)
188 , has_tsi(false)
189 , tsi(0)
190 , has_tsf(false)
191 , tsf(0)
192 , has_tlr(false)
193 , tlr(0)
194{
195}
196
197}}} // namespace uhd::transport::vrt
#define UHD_INLINE
Definition: config.h:55
#define UHD_API
Definition: config.h:70
@ error
Definition: log.hpp:120
UHD_API void if_hdr_unpack_be(const uint32_t *packet_buff, if_packet_info_t &if_packet_info)
UHD_API void if_hdr_unpack_le(const uint32_t *packet_buff, if_packet_info_t &if_packet_info)
UHD_API void if_hdr_pack_be(uint32_t *packet_buff, if_packet_info_t &if_packet_info)
UHD_API void if_hdr_pack_le(uint32_t *packet_buff, if_packet_info_t &if_packet_info)
Definition: build_info.hpp:12
Definition: vrt_if_packet.hpp:28
bool has_tsf
Fractional timestamp.
Definition: vrt_if_packet.hpp:81
link_type_t
Definition: vrt_if_packet.hpp:32
uint64_t tsf
Definition: vrt_if_packet.hpp:82
uint32_t sid
Definition: vrt_if_packet.hpp:73
if_packet_info_t(void)
Definition: vrt_if_packet.hpp:172
bool eob
Definition: vrt_if_packet.hpp:64
size_t num_payload_bytes
Definition: vrt_if_packet.hpp:57
size_t num_packet_words32
Definition: vrt_if_packet.hpp:59
bool has_sid
Stream ID (SID). See uhd::sid_t.
Definition: vrt_if_packet.hpp:72
size_t packet_count
Definition: vrt_if_packet.hpp:62
packet_type_t
Definition: vrt_if_packet.hpp:39
bool fc_ack
This is asserted for flow control packets are ACKS (CHDR only)
Definition: vrt_if_packet.hpp:68
uint32_t tlr
Definition: vrt_if_packet.hpp:85
bool has_tsi
Integer timestamp.
Definition: vrt_if_packet.hpp:78
bool has_tlr
Trailer.
Definition: vrt_if_packet.hpp:84
bool has_cid
Class ID.
Definition: vrt_if_packet.hpp:75
uint32_t tsi
Definition: vrt_if_packet.hpp:79
size_t num_payload_words32
Definition: vrt_if_packet.hpp:56
uint64_t cid
Definition: vrt_if_packet.hpp:76
size_t num_header_words32
Definition: vrt_if_packet.hpp:58
bool error
This is asserted for command responses that are errors (CHDR only)
Definition: vrt_if_packet.hpp:66