[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r9120 - usrp2/branches/developers/eb/merge-wip/host-ng
From: |
eb |
Subject: |
[Commit-gnuradio] r9120 - usrp2/branches/developers/eb/merge-wip/host-ng/lib |
Date: |
Fri, 1 Aug 2008 01:57:05 -0600 (MDT) |
Author: eb
Date: 2008-08-01 01:57:03 -0600 (Fri, 01 Aug 2008)
New Revision: 9120
Modified:
usrp2/branches/developers/eb/merge-wip/host-ng/lib/eth_buffer.cc
usrp2/branches/developers/eb/merge-wip/host-ng/lib/eth_buffer.h
usrp2/branches/developers/eb/merge-wip/host-ng/lib/ethernet.cc
usrp2/branches/developers/eb/merge-wip/host-ng/lib/ethernet.h
usrp2/branches/developers/eb/merge-wip/host-ng/lib/usrp2_impl.cc
Log:
work-in-progress on transmit
Modified: usrp2/branches/developers/eb/merge-wip/host-ng/lib/eth_buffer.cc
===================================================================
--- usrp2/branches/developers/eb/merge-wip/host-ng/lib/eth_buffer.cc
2008-08-01 07:32:12 UTC (rev 9119)
+++ usrp2/branches/developers/eb/merge-wip/host-ng/lib/eth_buffer.cc
2008-08-01 07:57:03 UTC (rev 9120)
@@ -246,6 +246,21 @@
return EB_OK;
}
+ eth_buffer::result
+ eth_buffer::tx_framev(const eth_iovec *iov, int iovcnt, int flags)
+ {
+ DEBUG_LOG("T");
+
+ if (flags & EF_DONTWAIT) // FIXME: implement flags
+ throw std::runtime_error("tx_frame: EF_DONTWAIT not implemented");
+
+ int res = d_ethernet->write_packetv(iov, iovcnt);
+ if (res < 0)
+ return EB_ERROR;
+
+ return EB_OK;
+ }
+
void
eth_buffer::release_frame(void *base)
{
Modified: usrp2/branches/developers/eb/merge-wip/host-ng/lib/eth_buffer.h
===================================================================
--- usrp2/branches/developers/eb/merge-wip/host-ng/lib/eth_buffer.h
2008-08-01 07:32:12 UTC (rev 9119)
+++ usrp2/branches/developers/eb/merge-wip/host-ng/lib/eth_buffer.h
2008-08-01 07:57:03 UTC (rev 9120)
@@ -22,7 +22,7 @@
#define INCLUDED_USRP2_ETH_BUFFER_H
#include "pktfilter.h"
-#include "eth_common.h"
+#include <eth_common.h>
#include <boost/utility.hpp>
#include <vector>
#include <stdint.h>
Modified: usrp2/branches/developers/eb/merge-wip/host-ng/lib/ethernet.cc
===================================================================
--- usrp2/branches/developers/eb/merge-wip/host-ng/lib/ethernet.cc
2008-08-01 07:32:12 UTC (rev 9119)
+++ usrp2/branches/developers/eb/merge-wip/host-ng/lib/ethernet.cc
2008-08-01 07:57:03 UTC (rev 9120)
@@ -182,6 +182,25 @@
}
return retval;
}
+
+ int
+ ethernet::write_packetv(const eth_iovec *iov, size_t iovlen)
+ {
+ struct msghdr mh;
+ memset(&mh, 0, sizeof(mh));
+ mh.msg_iov = const_cast<eth_iovec*>(iov);
+ mh.msg_iovlen = iovlen;
+
+ int retval = sendmsg(d_fd, &mh, 0);
+ if (retval < 0){
+ if (errno == EINTR)
+ return write_packetv(iov, iovlen);
+
+ perror("ethernet:write_packetv: send");
+ return -1;
+ }
+ return retval;
+ }
bool
ethernet::attach_pktfilter (pktfilter *pf)
Modified: usrp2/branches/developers/eb/merge-wip/host-ng/lib/ethernet.h
===================================================================
--- usrp2/branches/developers/eb/merge-wip/host-ng/lib/ethernet.h
2008-08-01 07:32:12 UTC (rev 9119)
+++ usrp2/branches/developers/eb/merge-wip/host-ng/lib/ethernet.h
2008-08-01 07:57:03 UTC (rev 9120)
@@ -21,6 +21,7 @@
#include <string>
#include <vector>
+#include <eth_common.h>
namespace usrp2 {
@@ -103,6 +104,19 @@
* Packet must begin with 14-byte ethhdr, but does not include the FCS.
*/
int write_packet (const void *buf, int buflen);
+
+ /*
+ * \brief Write ethernet packet to interface.
+ *
+ * \param iov scatter/gather array
+ * \param iovlen number of elements in iov
+ *
+ * \returns number of bytes written or -1 if trouble.
+ *
+ * Packet must begin with 14-byte ethhdr, but does not include the FCS.
+ */
+ int write_packetv (const eth_iovec *iov, size_t iovlen);
+
};
} // namespace usrp2
Modified: usrp2/branches/developers/eb/merge-wip/host-ng/lib/usrp2_impl.cc
===================================================================
--- usrp2/branches/developers/eb/merge-wip/host-ng/lib/usrp2_impl.cc
2008-08-01 07:32:12 UTC (rev 9119)
+++ usrp2/branches/developers/eb/merge-wip/host-ng/lib/usrp2_impl.cc
2008-08-01 07:57:03 UTC (rev 9120)
@@ -22,6 +22,7 @@
#include <usrp2/usrp2.h>
#include <usrp2/tune_result.h>
+#include <usrp2/copiers.h>
#include <gruel/inet.h>
#include <usrp2_types.h>
#include "usrp2_impl.h"
@@ -742,15 +743,15 @@
return success;
}
-
-
bool
usrp2::impl::tx_complex_float(unsigned int channel,
const std::complex<float> *samples,
size_t nsamples,
const tx_metadata *metadata)
{
- throw std::runtime_error("not implemented");
+ uint32_t items[nsamples];
+ copy_host_complex_float_to_u2_complex_16(nsamples, samples, items);
+ return tx_raw(channel, items, nsamples, metadata);
}
bool
@@ -759,7 +760,21 @@
size_t nsamples,
const tx_metadata *metadata)
{
- throw std::runtime_error("not implemented");
+#ifdef WORDS_BIGENDIAN
+
+ // Already binary equivalent to 16-bit I/Q on the wire.
+ // No conversion required.
+
+ assert(sizeof(samples[0]) == sizeof(uint32_t));
+ return tx_raw(channel, (const uint32_t *) samples, nsamples, metadata);
+
+#else
+
+ uint32_t items[nsamples];
+ copy_host_complex_16_to_u2_complex_16(nsamples, samples, items);
+ return tx_raw(channel, items, nsamples, metadata);
+
+#endif
}
bool
@@ -768,7 +783,59 @@
size_t nitems,
const tx_metadata *metadata)
{
- throw std::runtime_error("not implemented");
+ if (nitems == 0)
+ return true;
+
+ // FIXME there's the possibility that we send fewer than 9 items in a
frame.
+ // That would end up glitching the transmitter, since the ethernet will
pad to
+ // 64-bytes total (9 items). We really need some part of the stack to
+ // carry the real length (thdr?).
+
+ // fragment as necessary then fire away
+
+ size_t nframes = (nitems + U2_MAX_SAMPLES - 1) / U2_MAX_SAMPLES;
+ size_t last_frame = nframes - 1;
+ u2_eth_packet_t hdrs;
+
+ size_t n = 0;
+ for (size_t fn = 0; fn < nframes; fn++){
+ uint32_t timestamp = 0;
+ uint32_t flags = 0;
+
+ if (fn == 0){
+ timestamp = metadata->timestamp;
+ if (metadata->send_now)
+ flags |= U2P_TX_IMMEDIATE;
+ if (metadata->start_of_burst)
+ flags |= U2P_TX_START_OF_BURST;
+ }
+ if (fn > 0){
+ flags |= U2P_TX_IMMEDIATE;
+ }
+ if (fn == last_frame){
+ if (metadata->end_of_burst)
+ flags |= U2P_TX_END_OF_BURST;
+ }
+
+ init_etf_hdrs(&hdrs, d_addr, flags, channel, timestamp);
+
+ size_t i = std::min((size_t) U2_MAX_SAMPLES, nitems - n);
+
+ eth_iovec iov[2];
+ iov[0].iov_base = &hdrs;
+ iov[0].iov_len = sizeof(hdrs);
+ iov[1].iov_base = const_cast<uint32_t *>(&items[n]);
+ iov[1].iov_len = i * sizeof(uint32_t);
+
+ if (d_eth_buf->tx_framev(iov, 2) != eth_buffer::EB_OK){
+ return false;
+ }
+
+ n += i;
+ }
+
+ return true;
}
+
} // namespace usrp2
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r9120 - usrp2/branches/developers/eb/merge-wip/host-ng/lib,
eb <=