aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-06-29 22:55:45 -0700
committerJosh Blum <josh@joshknows.com>2010-07-05 13:45:11 -0700
commit08fad28f209a2f6c79d939ad54ca3a1d4e270b0b (patch)
tree6561410b24bcf0f3e72d680c27143b3b2a015bd0 /host/include
parent01e5f592d62e2193cc88081bd88765cae4708148 (diff)
downloaduhd-08fad28f209a2f6c79d939ad54ca3a1d4e270b0b.tar.gz
uhd-08fad28f209a2f6c79d939ad54ca3a1d4e270b0b.tar.bz2
uhd-08fad28f209a2f6c79d939ad54ca3a1d4e270b0b.zip
uhd: work vectorizing the vrt packet handler, reworked vrt packet stuff, needs testing
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/device.hpp51
-rw-r--r--host/include/uhd/transport/vrt.hpp110
-rw-r--r--host/include/uhd/types/metadata.hpp14
3 files changed, 89 insertions, 86 deletions
diff --git a/host/include/uhd/device.hpp b/host/include/uhd/device.hpp
index d3e9015c4..f04a5b4fb 100644
--- a/host/include/uhd/device.hpp
+++ b/host/include/uhd/device.hpp
@@ -27,6 +27,7 @@
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
#include <boost/asio/buffer.hpp>
+#include <vector>
namespace uhd{
@@ -96,8 +97,22 @@ public:
RECV_MODE_ONE_PACKET = 1
};
+ //! wrapper call for single buffer recv //TODO put somewhere
+ size_t send(
+ const boost::asio::const_buffer &buff,
+ const tx_metadata_t &metadata,
+ const io_type_t &io_type,
+ send_mode_t send_mode
+ ){
+ return send(
+ std::vector<const void *>(1, boost::asio::buffer_cast<const void *>(buff)),
+ boost::asio::buffer_size(buff)/io_type.size,
+ metadata, io_type, send_mode
+ );
+ }
+
/*!
- * Send a buffer containing IF data with its metadata.
+ * Send buffers containing IF data described by the metadata.
*
* Send handles fragmentation as follows:
* If the buffer has more samples than the maximum per packet,
@@ -108,23 +123,39 @@ public:
* Fragmentation only applies in the full buffer send mode.
*
* This is a blocking call and will not return until the number
- * of samples returned have been read out of the buffer.
+ * of samples returned have been read out of each buffer.
*
- * \param buff a buffer pointing to some read-only memory
+ * \param buffs a vector of read-only memory containing IF data
+ * \param nsamps_per_buff the number of samples to send, per buffer
* \param metadata data describing the buffer's contents
* \param io_type the type of data loaded in the buffer
* \param send_mode tells send how to unload the buffer
* \return the number of samples sent
*/
virtual size_t send(
- const boost::asio::const_buffer &buff,
+ const std::vector<const void *> &buffs,
+ size_t nsamps_per_buff,
const tx_metadata_t &metadata,
const io_type_t &io_type,
send_mode_t send_mode
) = 0;
+ //! wrapper call for single buffer recv //TODO put somewhere
+ size_t recv(
+ const boost::asio::mutable_buffer &buff,
+ rx_metadata_t &metadata,
+ const io_type_t &io_type,
+ recv_mode_t recv_mode
+ ){
+ return recv(
+ std::vector<void *>(1, boost::asio::buffer_cast<void *>(buff)),
+ boost::asio::buffer_size(buff)/io_type.size,
+ metadata, io_type, recv_mode
+ );
+ }
+
/*!
- * Receive a buffer containing IF data and its metadata.
+ * Receive buffers containing IF data described by the metadata.
*
* Receive handles fragmentation as follows:
* If the buffer has insufficient space to hold all samples
@@ -138,7 +169,7 @@ public:
* See the rx metadata fragment flags and offset fields for details.
*
* This is a blocking call and will not return until the number
- * of samples returned have been written into the buffer.
+ * of samples returned have been written into each buffer.
* However, a call to receive may timeout and return zero samples.
* The timeout duration is decided by the underlying transport layer.
* The caller should assume that the call to receive will not return
@@ -146,17 +177,19 @@ public:
* and that the timeout duration is reasonably tuned for performance.
*
* When using the full buffer recv mode, the metadata only applies
- * to the first packet received and written into the recv buffer.
+ * to the first packet received and written into the recv buffers.
* Use the one packet recv mode to get per packet metadata.
*
- * \param buff the buffer to fill with IF data
+ * \param buffs a vector of writable memory to fill with IF data
+ * \param nsamps_per_buff the size of each buffer in number of samples
* \param metadata data to fill describing the buffer
* \param io_type the type of data to fill into the buffer
* \param recv_mode tells recv how to load the buffer
* \return the number of samples received
*/
virtual size_t recv(
- const boost::asio::mutable_buffer &buff,
+ const std::vector<void *> &buffs,
+ size_t nsamps_per_buff,
rx_metadata_t &metadata,
const io_type_t &io_type,
recv_mode_t recv_mode
diff --git a/host/include/uhd/transport/vrt.hpp b/host/include/uhd/transport/vrt.hpp
index fb6efc99c..17da2d540 100644
--- a/host/include/uhd/transport/vrt.hpp
+++ b/host/include/uhd/transport/vrt.hpp
@@ -19,93 +19,77 @@
#define INCLUDED_UHD_TRANSPORT_VRT_HPP
#include <uhd/config.hpp>
-#include <uhd/types/metadata.hpp>
-#include <cstddef>
+#include <boost/cstdint.hpp>
+#include <cstddef> //size_t
namespace uhd{ namespace transport{
namespace vrt{
- static const size_t max_header_words32 = 5; //hdr+sid+tsi+tsf (no class id supported)
+ //! The maximum number of 32-bit words in a vrt if packet header
+ static const size_t max_if_hdr_words32 = 7; //hdr+sid+cid+tsi+tsf
+
+ /*!
+ * Definition for fields that can be packed into a vrt if header.
+ * The size fields are used for input and output depending upon
+ * the operation used (ie the pack or unpack function call).
+ */
+ struct UHD_API if_packet_info_t{
+ //size fields
+ size_t num_payload_words32; //required in pack, derived in unpack
+ size_t num_header_words32; //derived in pack, derived in unpack
+ size_t num_packet_words32; //derived in pack, required in unpack
+
+ //header fields
+ size_t packet_count;
+ bool sob, eob;
+
+ //optional fields
+ bool has_sid; boost::uint32_t sid;
+ bool has_cid; boost::uint64_t cid;
+ bool has_tsi; boost::uint32_t tsi;
+ bool has_tsf; boost::uint64_t tsf;
+ bool has_tlr; boost::uint32_t tlr;
+ };
/*!
* Pack a vrt header from metadata (big endian format).
- * \param metadata the tx metadata with flags and timestamps
- * \param header_buff memory to write the packed vrt header
- * \param num_header_words32 number of words in the vrt header
- * \param num_payload_words32 the length of the payload
- * \param num_packet_words32 the length of the packet
- * \param packet_count the packet count sequence number
- * \param tick_rate ticks per second used in time conversion
+ * \param packet_buff memory to write the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
*/
- UHD_API void pack_be(
- const tx_metadata_t &metadata, //input
- boost::uint32_t *header_buff, //output
- size_t &num_header_words32, //output
- size_t num_payload_words32, //input
- size_t &num_packet_words32, //output
- size_t packet_count, //input
- double tick_rate //input
+ UHD_API void if_hdr_pack_be(
+ boost::uint32_t *packet_buff,
+ if_packet_info_t &if_packet_info
);
/*!
* Unpack a vrt header to metadata (big endian format).
- * \param metadata the rx metadata with flags and timestamps
- * \param header_buff memory to read the packed vrt header
- * \param num_header_words32 number of words in the vrt header
- * \param num_payload_words32 the length of the payload
- * \param num_packet_words32 the length of the packet
- * \param packet_count the packet count sequence number
- * \param tick_rate ticks per second used in time conversion
+ * \param packet_buff memory to read the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
*/
- UHD_API void unpack_be(
- rx_metadata_t &metadata, //output
- const boost::uint32_t *header_buff, //input
- size_t &num_header_words32, //output
- size_t &num_payload_words32, //output
- size_t num_packet_words32, //input
- size_t &packet_count, //output
- double tick_rate //input
+ UHD_API void if_hdr_unpack_be(
+ const boost::uint32_t *packet_buff,
+ if_packet_info_t &if_packet_info
);
/*!
* Pack a vrt header from metadata (little endian format).
- * \param metadata the tx metadata with flags and timestamps
- * \param header_buff memory to write the packed vrt header
- * \param num_header_words32 number of words in the vrt header
- * \param num_payload_words32 the length of the payload
- * \param num_packet_words32 the length of the packet
- * \param packet_count the packet count sequence number
- * \param tick_rate ticks per second used in time conversion
+ * \param packet_buff memory to write the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
*/
- UHD_API void pack_le(
- const tx_metadata_t &metadata, //input
- boost::uint32_t *header_buff, //output
- size_t &num_header_words32, //output
- size_t num_payload_words32, //input
- size_t &num_packet_words32, //output
- size_t packet_count, //input
- double tick_rate //input
+ UHD_API void if_hdr_pack_le(
+ boost::uint32_t *packet_buff,
+ if_packet_info_t &if_packet_info
);
/*!
* Unpack a vrt header to metadata (little endian format).
- * \param metadata the rx metadata with flags and timestamps
- * \param header_buff memory to read the packed vrt header
- * \param num_header_words32 number of words in the vrt header
- * \param num_payload_words32 the length of the payload
- * \param num_packet_words32 the length of the packet
- * \param packet_count the packet count sequence number
- * \param tick_rate ticks per second used in time conversion
+ * \param packet_buff memory to read the packed vrt header
+ * \param if_packet_info the if packet info (read/write)
*/
- UHD_API void unpack_le(
- rx_metadata_t &metadata, //output
- const boost::uint32_t *header_buff, //input
- size_t &num_header_words32, //output
- size_t &num_payload_words32, //output
- size_t num_packet_words32, //input
- size_t &packet_count, //output
- double tick_rate //input
+ UHD_API void if_hdr_unpack_le(
+ const boost::uint32_t *packet_buff,
+ if_packet_info_t &if_packet_info
);
} //namespace vrt
diff --git a/host/include/uhd/types/metadata.hpp b/host/include/uhd/types/metadata.hpp
index 55add71cc..f4c962ff7 100644
--- a/host/include/uhd/types/metadata.hpp
+++ b/host/include/uhd/types/metadata.hpp
@@ -31,13 +31,6 @@ namespace uhd{
*/
struct UHD_API rx_metadata_t{
/*!
- * Stream IDs may be used to identify source DSP units.
- * --Not currently used in any known device implementation.--
- */
- bool has_stream_id;
- boost::uint32_t stream_id;
-
- /*!
* Time specification:
* Set from timestamps on incoming data when provided.
*/
@@ -84,13 +77,6 @@ namespace uhd{
*/
struct UHD_API tx_metadata_t{
/*!
- * Stream IDs may be used to identify destination DSP units.
- * --Not currently used in any known device implementation.--
- */
- bool has_stream_id;
- boost::uint32_t stream_id;
-
- /*!
* Time specification:
* Set has time spec to false to perform a send "now".
* Or, set to true, and fill in time spec for a send "at".