Statistics
| Branch: | Tag: | Revision:

root / host / include / uhd / transport / usb_zero_copy.hpp @ 543a6364

History | View | Annotate | Download (2.67 KB)

1
//
2
// Copyright 2010 Ettus Research LLC
3
//
4
// This program is free software: you can redistribute it and/or modify
5
// it under the terms of the GNU General Public License as published by
6
// the Free Software Foundation, either version 3 of the License, or
7
// (at your option) any later version.
8
//
9
// This program is distributed in the hope that it will be useful,
10
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
// GNU General Public License for more details.
13
//
14
// You should have received a copy of the GNU General Public License
15
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
//
17

    
18
#ifndef INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP
19
#define INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP
20

    
21
#include "usb_device_handle.hpp"
22
#include <uhd/transport/zero_copy.hpp>
23

    
24
namespace uhd { namespace transport {
25

    
26
/*!
27
 * A zero copy usb transport provides an efficient way to handle data.
28
 * by avoiding the extra copy when recv() or send() is called on the handle.
29
 * Rather, the zero copy transport gives the caller memory references.
30
 * The caller informs the transport when it is finished with the reference.
31
 *
32
 * On linux systems, the zero copy transport can use a kernel packet ring.
33
 * If no platform specific solution is available, make returns a boost asio
34
 * implementation that wraps functionality around standard send/recv calls.
35
 */
36
class UHD_API usb_zero_copy : public virtual zero_copy_if {
37
public:
38
    typedef boost::shared_ptr<usb_zero_copy> sptr;
39

    
40
    /*!
41
     * Make a new zero copy usb transport:
42
     * This transport is for sending and receiving between the host
43
     * and a pair of USB bulk transfer endpoints.
44
     * The primary usage for this transport is data transactions.
45
     * The underlying implementation may be platform specific.
46
     *
47
     * \param handle a device handle that uniquely identifying the device
48
     * \param recv_endpoint an integer specifiying an IN endpoint number
49
     * \param send_endpoint an integer specifiying an OUT endpoint number
50
     * \param recv_xfer_size the number of bytes for each receive transfer
51
     * \param recv_num_xfers the number of simultaneous receive transfers
52
     * \param send_xfer_size the number of bytes for each send transfer
53
     * \param send_num_xfers the number of simultaneous send transfers
54
     */
55
    static sptr make(
56
        usb_device_handle::sptr handle,
57
        unsigned int recv_endpoint,
58
        unsigned int send_endpoint,
59
        size_t recv_xfer_size = 0,
60
        size_t recv_num_xfers = 0,
61
        size_t send_xfer_size = 0,
62
        size_t send_num_xfers = 0
63
    );
64
};
65

    
66
}} //namespace
67

    
68
#endif /* INCLUDED_UHD_TRANSPORT_USB_ZERO_COPY_HPP */