USRP Hardware Driver and USRP Manual  Version: 003.008.002-0-ge9d11b35
UHD and USRP Manual
nirio_quirks.h
Go to the documentation of this file.
1 //
2 // Copyright 2013-2014 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 
19 #ifndef INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_QUIRKS_H
20 #define INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_QUIRKS_H
21 
22 #include <set>
23 #include <stdint.h>
24 #include <uhd/utils/log.hpp>
25 
26 //Quirk#1: We need to verify RX zero-copy data transfers from the RIO
27 // driver if we are in full duplex mode.
28 // This option allows enabling this quirk.
29 #define UHD_NIRIO_RX_FIFO_XFER_CHECK_EN 0
30 
31 namespace uhd { namespace niusrprio {
32 
33 class nirio_quirks {
34 public:
35  nirio_quirks() : _tx_stream_count(0) {
36  }
37 
38  UHD_INLINE void register_tx_streams(const uint32_t tx_stream_indices[]) {
39  for (size_t i = 0; i < sizeof(tx_stream_indices)/sizeof(*tx_stream_indices); i++) {
40  _tx_stream_fifo_indices.insert(tx_stream_indices[i]);
41  }
42  }
43 
44  UHD_INLINE void add_tx_fifo(uint32_t index) {
45  if (_tx_stream_fifo_indices.find(index) != _tx_stream_fifo_indices.end()) {
46  if (_tx_stream_count == 0) {
47  UHD_LOG << "NI-RIO RX FIFO Transfer Check Quirk Enabled.";
48  }
49  _tx_stream_count++;
50  }
51  }
52 
53  UHD_INLINE void remove_tx_fifo(uint32_t index) {
54  if (_tx_stream_fifo_indices.find(index) != _tx_stream_fifo_indices.end()) {
55  _tx_stream_count--;
56  if (_tx_stream_count == 0) {
57  UHD_LOG << "NI-RIO RX FIFO Transfer Check Quirk Disabled.";
58  }
59  }
60  }
61 
62  //Quirk#1: We need to verify RX zero-copy data transfers from the RIO
63  // driver if we are in full duplex mode.
64  // This function returns true if the quirk is enabled for the
65  // current uhd_device configuration (dynamic)
67  //This function must be as fast as possible because it is in a high
68  //throughput data path
69  return _tx_stream_count > 0;
70  }
71 
72 private:
73  std::set<uint32_t> _tx_stream_fifo_indices;
74  size_t _tx_stream_count;
75 };
76 
77 }}
78 
79 #endif /* INCLUDED_UHD_TRANSPORT_NIRIO_NIRIO_QUIRKS_H */
UHD_INLINE void register_tx_streams(const uint32_t tx_stream_indices[])
Definition: nirio_quirks.h:38
UHD_INLINE void add_tx_fifo(uint32_t index)
Definition: nirio_quirks.h:44
Definition: nirio_quirks.h:33
UHD_INLINE void remove_tx_fifo(uint32_t index)
Definition: nirio_quirks.h:53
UHD_INLINE bool rx_fifo_xfer_check_en() const
Definition: nirio_quirks.h:66
Definition: convert.hpp:28
#define UHD_INLINE
Definition: config.hpp:69
#define UHD_LOG
Definition: log.hpp:66
nirio_quirks()
Definition: nirio_quirks.h:35