blob: 6f533603eae0df7e13e50e070e6b23801f216a94 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
//
// Copyright 2019 Ettus Research, a National Instruments Brand
//
// SPDX-License-Identifier: GPL-3.0-or-later
//
#include <uhd/transport/adapter_id.hpp>
#include <uhd/transport/frame_buff.hpp>
#include <memory>
#ifndef INCLUDED_UHDLIB_TRANSPORT_LINK_IF_HPP
# define INCLUDED_UHDLIB_TRANSPORT_LINK_IF_HPP
namespace uhd { namespace transport {
/*!
* Link interface for transmitting packets.
*/
class send_link_if
{
public:
using sptr = std::shared_ptr<send_link_if>;
/*!
* Get the number of frame buffers that can be queued by this link.
*/
virtual size_t get_num_send_frames() const = 0;
/*!
* Get the maximum capacity of a frame buffer.
*/
virtual size_t get_send_frame_size() const = 0;
/*!
* Get an empty frame buffer in which to write packet contents.
*
* \param timeout_ms a positive timeout value specifies the maximum number
of ms to wait, a negative value specifies to block
until successful, and a value of 0 specifies no wait.
* \return a frame buffer, or null uptr if timeout occurs
*/
virtual frame_buff::uptr get_send_buff(int32_t timeout_ms) = 0;
/*!
* Send a packet with the contents of the frame buffer and release the
* buffer, allowing the link driver to reuse it. If the size of the frame
* buffer is 0, the buffer is released with no packet being sent.
*
* \param buffer frame buffer containing packet data
*
* Throws an exception if an I/O error occurs while sending
*/
virtual void release_send_buff(frame_buff::uptr buff) = 0;
/*!
* Get the physical adapter id used for this link
*/
virtual adapter_id_t get_send_adapter_id() const = 0;
send_link_if() = default;
send_link_if(const send_link_if&) = delete;
send_link_if& operator=(const send_link_if&) = delete;
};
/*!
* Link interface for receiving packets.
*/
class recv_link_if
{
public:
using sptr = std::shared_ptr<recv_link_if>;
/*!
* Get the number of frame buffers that can be queued by this link.
*/
virtual size_t get_num_recv_frames() const = 0;
/*!
* Get the maximum capacity of a frame buffer.
*/
virtual size_t get_recv_frame_size() const = 0;
/*!
* Receive a packet and return a frame buffer containing the packet data.
*
* \param timeout_ms a positive timeout value specifies the maximum number
of ms to wait, a negative value specifies to block
until successful, and a value of 0 specifies no wait.
* \return a frame buffer, or null uptr if timeout occurs
*/
virtual frame_buff::uptr get_recv_buff(int32_t timeout_ms) = 0;
/*!
* Release a frame buffer, allowing the link driver to reuse it.
*
* \param buffer frame buffer to release for reuse by the link
*/
virtual void release_recv_buff(frame_buff::uptr buff) = 0;
/*!
* Get the physical adapter ID used for this link
*/
virtual adapter_id_t get_recv_adapter_id() const = 0;
recv_link_if() = default;
recv_link_if(const recv_link_if&) = delete;
recv_link_if& operator=(const recv_link_if&) = delete;
};
}} // namespace uhd::transport
#endif /* INCLUDED_UHDLIB_TRANSPORT_LINK_IF_HPP */
|