aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/examples/gpio.cpp6
-rw-r--r--host/lib/rfnoc/legacy_compat.cpp4
-rw-r--r--host/lib/usrp/device3/device3_io_impl.cpp2
-rw-r--r--host/lib/usrp/x300/x300_impl.cpp18
-rw-r--r--host/lib/usrp/x300/x300_impl.hpp24
-rwxr-xr-xhost/tests/devtest/bitbang_test.py48
-rwxr-xr-xhost/tests/devtest/devtest_x3x0.py1
-rwxr-xr-xhost/tests/devtest/gpio_test.py2
8 files changed, 79 insertions, 26 deletions
diff --git a/host/examples/gpio.cpp b/host/examples/gpio.cpp
index 1a1b2982f..02c73e96b 100644
--- a/host/examples/gpio.cpp
+++ b/host/examples/gpio.cpp
@@ -228,6 +228,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
//set data direction register (DDR)
usrp->set_gpio_attr(gpio, "DDR", ddr, mask);
+ //set control register
+ usrp->set_gpio_attr(gpio, "CTRL", ctrl, mask);
+
//set output values (OUT)
usrp->set_gpio_attr(gpio, "OUT", out, mask);
@@ -237,9 +240,6 @@ int UHD_SAFE_MAIN(int argc, char *argv[])
usrp->set_gpio_attr(gpio, "ATR_TX", atr_tx, mask);
usrp->set_gpio_attr(gpio, "ATR_XX", atr_duplex, mask);
- //set control register
- usrp->set_gpio_attr(gpio, "CTRL", ctrl, mask);
-
//print out initial state of FP GPIO
std::cout << "\nConfigured GPIO values:" << std::endl;
output_reg_values(gpio, usrp, num_bits);
diff --git a/host/lib/rfnoc/legacy_compat.cpp b/host/lib/rfnoc/legacy_compat.cpp
index 2c8ffdde2..a8b6d4f68 100644
--- a/host/lib/rfnoc/legacy_compat.cpp
+++ b/host/lib/rfnoc/legacy_compat.cpp
@@ -340,7 +340,6 @@ public:
}
}
BOOST_FOREACH(const size_t this_chan, chans_to_change) {
- UHD_MSG(status) << "setting rate on chan " << this_chan << " " << rate << std::endl;
size_t mboard, mb_chan;
chan_to_mcp<uhd::RX_DIRECTION>(this_chan, _rx_channel_map, mboard, mb_chan);
const size_t dsp_index = _rx_channel_map[mboard][mb_chan].radio_index;
@@ -437,8 +436,7 @@ private: // methods
mboard_idx = 0;
mb_chan_idx = chan;
while (mb_chan_idx >= chan_map[mboard_idx].size()) {
- mboard_idx++;
- mb_chan_idx -= chan_map[mboard_idx].size();
+ mb_chan_idx -= chan_map[mboard_idx++].size();
}
if (mboard_idx >= chan_map.size()) {
throw uhd::index_error(str(
diff --git a/host/lib/usrp/device3/device3_io_impl.cpp b/host/lib/usrp/device3/device3_io_impl.cpp
index 6df9f6336..b3a34afe3 100644
--- a/host/lib/usrp/device3/device3_io_impl.cpp
+++ b/host/lib/usrp/device3/device3_io_impl.cpp
@@ -114,7 +114,7 @@ void generate_channel_list(
if (args.args.has_key(key)) {
chan_list_[i] = args.args.pop(key);
} else if (args.args.has_key("block_id")) {
- chan_list[i] = args.args["block_id"];
+ chan_list_[i] = args.args["block_id"];
} else {
throw uhd::runtime_error(str(
boost::format("Cannot create streamers: No block_id specified for channel %d.")
diff --git a/host/lib/usrp/x300/x300_impl.cpp b/host/lib/usrp/x300/x300_impl.cpp
index 548f7bd9c..9668c8316 100644
--- a/host/lib/usrp/x300/x300_impl.cpp
+++ b/host/lib/usrp/x300/x300_impl.cpp
@@ -105,8 +105,8 @@ static device_addrs_t x300_find_with_addr(const device_addr_t &hint)
const size_t nbytes = comm->recv(asio::buffer(buff), 0.050);
if (nbytes == 0) break;
const x300_fw_comms_t *reply = (const x300_fw_comms_t *)buff;
- if (request.flags != reply->flags) break;
- if (request.sequence != reply->sequence) break;
+ if (request.flags != reply->flags) continue;
+ if (request.sequence != reply->sequence) continue;
device_addr_t new_addr;
new_addr["type"] = "x300";
new_addr["addr"] = comm->get_recv_addr();
@@ -652,7 +652,7 @@ void x300_impl::setup_mb(const size_t mb_i, const uhd::device_addr_t &dev_addr)
}
_tree->create<size_t>(mb_path / "mtu/recv").set(_max_frame_sizes.recv_frame_size);
- _tree->create<size_t>(mb_path / "mtu/send").set(std::min(_max_frame_sizes.send_frame_size, X300_1GE_DATA_FRAME_MAX_SIZE));
+ _tree->create<size_t>(mb_path / "mtu/send").set(std::min(_max_frame_sizes.send_frame_size, X300_ETH_DATA_FRAME_MAX_TX_SIZE));
_tree->create<double>(mb_path / "link_max_rate").set(X300_MAX_RATE_10GIGE);
}
@@ -1024,14 +1024,14 @@ x300_impl::~x300_impl(void)
}
}
-uint32_t x300_impl::allocate_pcie_dma_chan(const uhd::sid_t &tx_sid, const xport_type_t xport_type)
+uint32_t x300_impl::mboard_members_t::allocate_pcie_dma_chan(const uhd::sid_t &tx_sid, const xport_type_t xport_type)
{
static const uint32_t CTRL_CHANNEL = 0;
static const uint32_t FIRST_DATA_CHANNEL = 1;
if (xport_type == CTRL) {
return CTRL_CHANNEL;
} else {
- // sid_t has no comparison defined
+ // sid_t has no comparison defined, so we need to convert it uint32_t
uint32_t raw_sid = tx_sid.get();
if (_dma_chan_pool.count(raw_sid) == 0) {
@@ -1067,10 +1067,10 @@ uhd::both_xports_t x300_impl::make_transport(
xports.send_sid = this->allocate_sid(mb, address, X300_SRC_ADDR0, X300_XB_DST_PCI);
xports.recv_sid = xports.send_sid.reversed();
- uint32_t dma_channel_num = allocate_pcie_dma_chan(xports.send_sid, xport_type);
+ uint32_t dma_channel_num = mb.allocate_pcie_dma_chan(xports.send_sid, xport_type);
if (xport_type == CTRL) {
//Transport for control stream
- if (_ctrl_dma_xport.get() == NULL) {
+ if (not mb.ctrl_dma_xport) {
//One underlying DMA channel will handle
//all control traffic
zero_copy_xport_params ctrl_buff_args;
@@ -1082,10 +1082,10 @@ uhd::both_xports_t x300_impl::make_transport(
zero_copy_if::sptr base_xport = nirio_zero_copy::make(
mb.rio_fpga_interface, dma_channel_num,
ctrl_buff_args, uhd::device_addr_t());
- _ctrl_dma_xport = muxed_zero_copy_if::make(base_xport, extract_sid_from_pkt, X300_PCIE_MAX_MUXED_XPORTS);
+ mb.ctrl_dma_xport = muxed_zero_copy_if::make(base_xport, extract_sid_from_pkt, X300_PCIE_MAX_MUXED_XPORTS);
}
//Create a virtual control transport
- xports.recv = _ctrl_dma_xport->make_stream(xports.recv_sid.get_dst());
+ xports.recv = mb.ctrl_dma_xport->make_stream(xports.recv_sid.get_dst());
} else {
//Transport for data stream
default_buff_args.send_frame_size =
diff --git a/host/lib/usrp/x300/x300_impl.hpp b/host/lib/usrp/x300/x300_impl.hpp
index 3ae37b54a..53ef012d4 100644
--- a/host/lib/usrp/x300/x300_impl.hpp
+++ b/host/lib/usrp/x300/x300_impl.hpp
@@ -67,6 +67,8 @@ static const size_t X300_PCIE_MAX_MUXED_XPORTS = 32;
static const size_t X300_10GE_DATA_FRAME_MAX_SIZE = 8000; // CHDR packet size in bytes
static const size_t X300_1GE_DATA_FRAME_MAX_SIZE = 1472; // CHDR packet size in bytes
static const size_t X300_ETH_MSG_FRAME_SIZE = uhd::transport::udp_simple::mtu; //bytes
+// MTU throttling for ethernet/TX (see above):
+static const size_t X300_ETH_DATA_FRAME_MAX_TX_SIZE = 2000;
static const double X300_THREAD_BUFFER_TIMEOUT = 0.1; // Time in seconds
@@ -191,6 +193,19 @@ private:
std::string current_refclk_src;
std::vector<uhd::rfnoc::x300_radio_ctrl_impl::sptr> radios;
+
+ // PCIe specific components:
+
+ //! Maps SID -> DMA channel
+ std::map<uint32_t, uint32_t> _dma_chan_pool;
+ //! Control transport for one PCIe connection
+ uhd::transport::muxed_zero_copy_if::sptr ctrl_dma_xport;
+
+ /*! Allocate or return a previously allocated PCIe channel pair
+ *
+ * Note the SID is always the transmit SID (i.e. from host to device).
+ */
+ uint32_t allocate_pcie_dma_chan(const uhd::sid_t &tx_sid, const xport_type_t xport_type);
};
std::vector<mboard_members_t> _mb;
@@ -224,15 +239,6 @@ private:
*/
frame_size_t determine_max_frame_size(const std::string &addr, const frame_size_t &user_mtu);
- std::map<uint32_t, uint32_t> _dma_chan_pool;
- uhd::transport::muxed_zero_copy_if::sptr _ctrl_dma_xport;
-
- /*! Allocate or return a previously allocated PCIe channel pair
- *
- * Note the SID is always the transmit SID (i.e. from host to device).
- */
- uint32_t allocate_pcie_dma_chan(const uhd::sid_t &tx_sid, const xport_type_t xport_type);
-
////////////////////////////////////////////////////////////////////
//
//Caching for transport interface re-use -- like sharing a DMA.
diff --git a/host/tests/devtest/bitbang_test.py b/host/tests/devtest/bitbang_test.py
new file mode 100755
index 000000000..24295c5cd
--- /dev/null
+++ b/host/tests/devtest/bitbang_test.py
@@ -0,0 +1,48 @@
+#
+# Copyright 2015 Ettus Research LLC
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+""" Test for gpio --bitbang. """
+
+import re
+from uhd_test_base import uhd_example_test_case
+
+class bitbang_test(uhd_example_test_case):
+ """ Run gpio --bitbang. """
+ tests = {'default': {},}
+
+ def setup_example(self):
+ """
+ Set args.
+ """
+ self.test_params = bitbang_test.tests
+
+ def run_test(self, test_name, test_args):
+ """ Run the app and scrape for the success message. """
+ self.log.info('Running test {n}'.format(n=test_name,))
+ # Run example:
+ args = [
+ self.create_addr_args_str(),
+ '--bitbang',
+ ]
+ (app, run_results) = self.run_example('gpio', args)
+ # Evaluate pass/fail:
+ run_results['passed'] = all([
+ app.returncode == 0,
+ # re.search('All tests passed!', app.stdout) is not None,
+ ])
+ self.report_example_results(test_name, run_results)
+ return run_results
+
diff --git a/host/tests/devtest/devtest_x3x0.py b/host/tests/devtest/devtest_x3x0.py
index dd62d8910..fc6e6b8ef 100755
--- a/host/tests/devtest/devtest_x3x0.py
+++ b/host/tests/devtest/devtest_x3x0.py
@@ -62,4 +62,5 @@ uhd_benchmark_rate_test.tests = {
from tx_bursts_test import uhd_tx_bursts_test
from test_pps_test import uhd_test_pps_test
from gpio_test import gpio_test
+from bitbang_test import bitbang_test
diff --git a/host/tests/devtest/gpio_test.py b/host/tests/devtest/gpio_test.py
index d764a8d96..6ea4413f4 100755
--- a/host/tests/devtest/gpio_test.py
+++ b/host/tests/devtest/gpio_test.py
@@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
-""" Test for test_pps_input. """
+""" Test for gpio. """
import re
from uhd_test_base import uhd_example_test_case