[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 28/148: Cleaned up the parse ethernet stuff
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 28/148: Cleaned up the parse ethernet stuff. Made an official max_buffs method for the transport. |
Date: |
Mon, 15 Aug 2016 00:47:21 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
nwest pushed a commit to annotated tag old_usrp_devel_udp
in repository gnuradio.
commit 24157642fb98bec0a48faf952e1da3930b125c15
Author: Josh Blum <address@hidden>
Date: Thu Nov 5 17:37:10 2009 -0800
Cleaned up the parse ethernet stuff.
Made an official max_buffs method for the transport.
---
usrp2/host/lib/eth_data_transport.h | 2 +-
usrp2/host/lib/transport.cc | 12 ------
usrp2/host/lib/transport.h | 14 +++++--
usrp2/host/lib/usrp2.cc | 79 ++++++++++++++-----------------------
4 files changed, 41 insertions(+), 66 deletions(-)
diff --git a/usrp2/host/lib/eth_data_transport.h
b/usrp2/host/lib/eth_data_transport.h
index 452da9a..990cb8f 100644
--- a/usrp2/host/lib/eth_data_transport.h
+++ b/usrp2/host/lib/eth_data_transport.h
@@ -46,7 +46,7 @@ namespace usrp2{
int sendv(const iovec *iov, size_t iovlen);
std::vector<sbuff::sptr> recv();
void init();
- size_t max_frames(){return d_eth_data->max_frames();} //FIXME hate to
have this here
+ size_t max_buffs(){return d_eth_data->max_frames();}
};
diff --git a/usrp2/host/lib/transport.cc b/usrp2/host/lib/transport.cc
index 51beb38..f886973 100644
--- a/usrp2/host/lib/transport.cc
+++ b/usrp2/host/lib/transport.cc
@@ -34,10 +34,6 @@ usrp2::transport::~transport(){
if (d_running) stop();
}
-void usrp2::transport::init(){
- //NOP
-}
-
void usrp2::transport::start(){
if (not d_cb){
throw std::runtime_error("usrp2::transport for" + d_type_str + " has
no callback\n");
@@ -70,11 +66,3 @@ void usrp2::transport::run(){
}catch(boost::thread_interrupted const &){}
}
}
-
-int usrp2::transport::sendv(const iovec *iov, size_t iovlen){
- return -1; //NOP
-}
-
-std::vector<usrp2::sbuff::sptr> usrp2::transport::recv(){
- return std::vector<sbuff::sptr>(); //NOP
-}
diff --git a/usrp2/host/lib/transport.h b/usrp2/host/lib/transport.h
index 154fe47..4b58248 100644
--- a/usrp2/host/lib/transport.h
+++ b/usrp2/host/lib/transport.h
@@ -59,22 +59,30 @@ namespace usrp2 {
*/
void stop();
/*!
+ * \brief get the maximum number of buffs (override in a subclass)
+ * This number is the maximum number of buffers that recv can return at
once.
+ * This number should be based upon the limitations of the internals of a
subclass.
+ * Ex: for an ethernet packet ring, max buffs will be the max ring size.
+ * \return the number of buffs or 0 for undefined
+ */
+ virtual size_t max_buffs(){return 0;}
+ /*!
* \brief called from thread on init (override in a subclass)
* Purpose: to have a thread initialization hook.
*/
- virtual void init();
+ virtual void init(){/*NOP*/}
/*!
* \brief send the contents of the buffer (override in a subclass)
* \param iovec a list of iovecs
* \param iovlen the number of iovecs
* \return the number of bytes sent, -1 for error
*/
- virtual int sendv(const iovec *iov, size_t iovlen);
+ virtual int sendv(const iovec *iov, size_t iovlen){return -1;}
/*!
* \brief receive data, possibly multiple buffers (override in a subclass)
* \return a new vector of sbuffs, an empty vector is no data
*/
- virtual std::vector<sbuff::sptr> recv();
+ virtual std::vector<sbuff::sptr> recv(){return std::vector<sbuff::sptr>();}
};
} // namespace usrp2
diff --git a/usrp2/host/lib/usrp2.cc b/usrp2/host/lib/usrp2.cc
index 3d2e5aa..6949107 100644
--- a/usrp2/host/lib/usrp2.cc
+++ b/usrp2/host/lib/usrp2.cc
@@ -31,10 +31,8 @@
#include "eth_ctrl_transport.h"
#include "eth_data_transport.h"
-
-//FIXME this is the Nth instance of this function, find it a home
static bool
-parse_mac_addr(const std::string &s, u2_mac_addr_t *p)
+string_to_mac_addr(const std::string &s, u2_mac_addr_t *p)
{
p->addr[0] = 0x00; // Matt's IAB
p->addr[1] = 0x50;
@@ -59,6 +57,23 @@ parse_mac_addr(const std::string &s, u2_mac_addr_t *p)
}
}
+static bool
+parse_mac_addr(const std::string &s, std::string &ns)
+{
+ u2_mac_addr_t p;
+
+ if (not string_to_mac_addr(s, &p))
+ return false;
+
+ char buf[128];
+ snprintf(buf, sizeof(buf),
+ "%02x:%02x:%02x:%02x:%02x:%02x",
+ p.addr[0],p.addr[1],p.addr[2],
+ p.addr[3],p.addr[4],p.addr[5]);
+ ns = std::string(buf);
+ return true;
+}
+
namespace usrp2 {
// --- Table of weak pointers to usrps we know about ---
@@ -109,53 +124,16 @@ namespace usrp2 {
// --- end of table code ---
- static bool
- parse_mac_addr(const std::string &s, std::string &ns)
- {
- u2_mac_addr_t p;
-
- p.addr[0] = 0x00; // Matt's IAB
- p.addr[1] = 0x50;
- p.addr[2] = 0xC2;
- p.addr[3] = 0x85;
- p.addr[4] = 0x30;
- p.addr[5] = 0x00;
-
- int len = s.size();
- switch (len) {
-
- case 5:
- if (sscanf(s.c_str(), "%hhx:%hhx", &p.addr[4], &p.addr[5]) != 2)
- return false;
- break;
-
- case 17:
- if (sscanf(s.c_str(), "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx",
- &p.addr[0], &p.addr[1], &p.addr[2],
- &p.addr[3], &p.addr[4], &p.addr[5]) != 6)
- return false;
- break;
-
- default:
- return false;
- }
-
- char buf[128];
- snprintf(buf, sizeof(buf),
- "%02x:%02x:%02x:%02x:%02x:%02x",
- p.addr[0],p.addr[1],p.addr[2],
- p.addr[3],p.addr[4],p.addr[5]);
- ns = std::string(buf);
- return true;
- }
-
usrp2::sptr
usrp2::make(const std::string &ifc, const std::string &addr, size_t
rx_bufsize)
{
- std::string naddr = "";
- if (addr != "" && !parse_mac_addr(addr, naddr))
+ u2_mac_addr_t mac;
+ if (addr != "" && !string_to_mac_addr(addr, &mac))
throw std::runtime_error("Invalid MAC address");
+ std::string naddr = "";
+ parse_mac_addr(addr, naddr);
+
props_vector_t u2s = find(ifc, naddr);
int n = u2s.size();
@@ -178,13 +156,12 @@ namespace usrp2 {
u2_mac_addr_t mac;
d_mac = p->addr;
d_ifc = ifc;
- parse_mac_addr(d_mac, &mac);
+ string_to_mac_addr(d_mac, &mac);
//create transports for data and control
transport::sptr ctrl_transport(new eth_ctrl_transport(ifc, mac));
- eth_data_transport *data_transport_p = new eth_data_transport(ifc, mac,
rx_bufsize);
- transport::sptr data_transport(data_transport_p);
+ transport::sptr data_transport(new eth_data_transport(ifc, mac,
rx_bufsize));
//pass the transports into a new usrp2 impl
- d_impl = std::auto_ptr<impl>(new usrp2::impl(data_transport,
ctrl_transport, data_transport_p->max_frames()));
+ d_impl = std::auto_ptr<impl>(new usrp2::impl(data_transport,
ctrl_transport, data_transport->max_buffs()));
}
// Public class destructor. d_impl will auto-delete.
@@ -294,12 +271,14 @@ namespace usrp2 {
unsigned int
usrp2::rx_overruns()
{
+ //will probably fix with vrt and usrp2 impl
return 0;//FIXME d_impl->rx_overruns();
}
unsigned int
usrp2::rx_missing()
{
+ //will probably fix with vrt and usrp2 impl
return 0;//FIXME d_impl->rx_missing();
}
@@ -450,7 +429,7 @@ namespace usrp2 {
usrp2::burn_mac_addr(const std::string &new_addr)
{
u2_mac_addr_t mac;
- parse_mac_addr(new_addr, &mac);
+ string_to_mac_addr(new_addr, &mac);
return d_impl->burn_mac_addr(&mac);
}
- [Commit-gnuradio] [gnuradio] 05/148: Removed references to U2_ETHERTYPE and CONTROL_CHAN. Moved non-txrx-related apps in firmware broken by this., (continued)
- [Commit-gnuradio] [gnuradio] 05/148: Removed references to U2_ETHERTYPE and CONTROL_CHAN. Moved non-txrx-related apps in firmware broken by this., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 06/148: Common naming convention for control and data thread stuff., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 02/148: working a separate ctrl ethernet device into the code, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 07/148: using boost threads for control and data, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 09/148: Refactored timeout handling, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 17/148: Began work on eth data transport class. Switched send in transport to use iovecs. Pass mac addr into eth transports rather than re-parsing., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 14/148: Created transport abstraction. Implemented ethernet transport for control. Control transport works in usrp impl. Needs a lot of cleanup., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 08/148: Removed omnithreads dependency from libusrp2, still debugging, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 18/148: Added a callback into the channel ring enqueue and dequeue. This will allow the deqeue caller to make an arbitrary call when its done with the data. Currently, the enqueue caller makes this callback a release_frames., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 15/148: virtual destructor and shared ptr for transport, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 28/148: Cleaned up the parse ethernet stuff. Made an official max_buffs method for the transport.,
git <=
- [Commit-gnuradio] [gnuradio] 20/148: Created sbuff class to house chunks of memory, their length, and possible callback for freeing/cleanup. Switched ring and transport to make use of the sbuff on receive., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 37/148: Fixes usrp2 firmware configure with mb-gcc on ubuntu 9.10/autoconf 2.64. Disables the regression test for fopen since stdio is non-functional., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 22/148: usrp2 impl working with data transport. not up to full potential yet, but working. needs major cleanup., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 23/148: Changed the transport to return a vector of sbuffs. This way the ethernet can pass up as many buffs as ready., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 11/148: some house keeping while trying to fix thread exception, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 12/148: Disable interruption in those functions that use interruption points such as sleep, wait, and timed_wait., git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 30/148: being more c++y with the ring, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 36/148: Merge branch 'vita_rx' of http://gnuradio.org/git/matt into wip/usrp2, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 29/148: cleanup stuff, git, 2016/08/14
- [Commit-gnuradio] [gnuradio] 31/148: pass vector of sbuffs by reference to callback, git, 2016/08/14