Commit 4635a899 authored by Tom Barbette's avatar Tom Barbette

Add zero copy support. It uses the current pool "buffer_destructor" feature....

Add zero copy support. It uses the current pool "buffer_destructor" feature. Using the (implemented in later commit) netmap pool is faster for netmap implementation.
parent 8de1ea5f
......@@ -121,6 +121,9 @@
#undef HAVE_TASK_HEAP
#endif
/* Use zerocopy */
#undef HAVE_ZEROCOPY
/* The size of a `int', as computed by sizeof. */
#undef SIZEOF_INT
......
......@@ -170,6 +170,13 @@ Define \$RTE_SDK and \$RTE_TARGET as per Intel DPDK documentation.
AC_SUBST(USE_DPDK, yes)
fi
AC_ARG_ENABLE([zerocopy],
[AS_HELP_STRING([ --enable-zerocopy], [use Zero Copy])],
[:], [enable_zerocopy=no])
if test "x$enable_zerocopy" = xyes; then
AC_DEFINE(HAVE_ZEROCOPY)
fi
dnl linuxmodule driver and features
AC_ARG_ENABLE([linuxmodule],
......
......@@ -109,9 +109,16 @@ bool FromDpdkDevice::run_task(Task * t)
for (int iqueue = queue_for_thread_begin(); iqueue<=queue_for_thread_end();iqueue++) {
unsigned n = rte_eth_rx_burst(_port_no, iqueue, pkts, _burst);
for (unsigned i = 0; i < n; ++i) {
#if HAVE_ZEROCOPY
rte_prefetch0(rte_pktmbuf_mtod(pkts[i], void *));
WritablePacket *p = Packet::make(rte_pktmbuf_mtod(pkts[i], unsigned char *),
rte_pktmbuf_data_len(pkts[i]), DpdkDevice::free_pkt,
pkts[i]);
#else
WritablePacket *p = Packet::make((void*)rte_pktmbuf_mtod(pkts[i], unsigned char *),
(uint32_t)rte_pktmbuf_pkt_len(pkts[i]));
rte_pktmbuf_free(pkts[i]);
#endif
p->set_packet_type_anno(HOST);
output(0).push(p);
}
......
......@@ -281,9 +281,19 @@ inline unsigned int ToNetmapDevice::send_packets(Packet* &head, bool push) {
slot = &txring->slot[cur];
slot->len = p->length();
unsigned char* dstdata = (unsigned char*)NETMAP_BUF(txring, slot->buf_idx);
void* srcdata = (void*)(p->data());
memcpy(dstdata,srcdata,p->length());
#if HAVE_ZEROCOPY
if (likely(NetmapBufQ::is_netmap_packet(p))) {
((NetmapBufQ*)(p->destructor_argument()))->insert(slot->buf_idx);
slot->buf_idx = NETMAP_BUF_IDX(txring,p->buffer());
slot->flags |= NS_BUF_CHANGED;
p->set_buffer_destructor(NetmapBufQ::buffer_destructor_fake);
} else
#endif
{
unsigned char* dstdata = (unsigned char*)NETMAP_BUF(txring, slot->buf_idx);
void* srcdata = (void*)(p->data());
memcpy(dstdata,srcdata,p->length());
}
p->kill();
sent++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment