Skip to content

Commit

Permalink
Merge branch 'master' into github-master
Browse files Browse the repository at this point in the history
  • Loading branch information
giuseppelettieri committed Apr 28, 2016
2 parents 77df06a + 325dfde commit 8123c74
Show file tree
Hide file tree
Showing 14 changed files with 76 additions and 31 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,4 @@ LINUX/veth.c
*.sdf
*.opensdf
*~
cscope.out
2 changes: 1 addition & 1 deletion LINUX/configure
Original file line number Diff line number Diff line change
Expand Up @@ -831,7 +831,7 @@ add_test 'have RX_HANDLER_RESULT' <<-EOF
#include <linux/netdevice.h>
static rx_handler_result_t dummy_rx_handler(struct sk_buf **pm)
static rx_handler_result_t dummy_rx_handler(struct sk_buff **pm)
{
(void)pm;
return RX_HANDLER_PASS;
Expand Down
7 changes: 4 additions & 3 deletions LINUX/i40e_netmap_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ extern int ix_rx_miss, ix_rx_miss_bufs, ix_crcstrip;
/*
* device-specific sysctl variables:
*
* ix_crcstrip: 0: keep CRC in rx frames (default), 1: strip it.
* ix_crcstrip: 0: NIC keeps CRC in rx frames (default), 1: NIC strips it.
* During regular operations the CRC is stripped, but on some
* hardware reception of frames not multiple of 64 is slower,
* so using crcstrip=0 helps in benchmarks.
* The driver by default strips CRCs and we do not override it.
*
* ix_rx_miss, ix_rx_miss_bufs:
* count packets that might be missed due to lost interrupts.
*/
SYSCTL_DECL(_dev_netmap);
int ix_rx_miss, ix_rx_miss_bufs, ix_crcstrip;
int ix_rx_miss = 0, ix_rx_miss_bufs = 0, ix_crcstrip = 1;
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_crcstrip,
CTLFLAG_RW, &ix_crcstrip, 1, "strip CRC on rx frames");
CTLFLAG_RW, &ix_crcstrip, 1, "NIC strips CRC on rx frames");
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_rx_miss,
CTLFLAG_RW, &ix_rx_miss, 0, "potentially missed rx intr");
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_rx_miss_bufs,
Expand Down
1 change: 1 addition & 0 deletions apps/lb/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lb
23 changes: 6 additions & 17 deletions apps/lb/lb.c
Original file line number Diff line number Diff line change
Expand Up @@ -561,23 +561,23 @@ int main(int argc, char **argv)
while (!nm_ring_empty(rxring)) {
struct overflow_queue *q;
struct netmap_slot *rs = next_slot;
next_cur = nm_ring_next(rxring, next_cur);
next_slot = &rxring->slot[next_cur];

// CHOOSE THE CORRECT OUTPUT PIPE
next_buf = NETMAP_BUF(rxring, next_slot->buf_idx);
__builtin_prefetch(next_buf);
// 'B' is just a hashing seed
uint32_t hash = pkt_hdr_hash((const unsigned char *)next_buf, 4, 'B');
if (hash == 0)
non_ip++; // XXX ??
// prefetch the buffer for the next round
next_cur = nm_ring_next(rxring, next_cur);
next_slot = &rxring->slot[next_cur];
next_buf = NETMAP_BUF(rxring, next_slot->buf_idx);
__builtin_prefetch(next_buf);
// 'B' is just a hashing seed
uint32_t output_port = hash % glob_arg.output_rings;
struct port_des *port = &ports[output_port];
struct netmap_ring *ring = port->ring;
uint32_t free_buf;

// Move the packet to the output pipe.
retry:
if (nm_ring_space(ring)) {
struct netmap_slot *ts = &ring->slot[ring->cur];
free_buf = ts->buf_idx;
Expand All @@ -590,17 +590,6 @@ int main(int argc, char **argv)
goto forward;
}

/* try to push packets down to free some space
* in the pipe (no more than once per loop on
* the same pipe, to make sure that there is a
* reasonable amount of time between syncs)
*/
if (port->last_sync != iter) {
port->last_sync = iter;
ioctl(port->nmd->fd, NIOCTXSYNC, NULL);
goto retry;
}

/* use the overflow queue, if available */
if (!oq) {
dropped++;
Expand Down
1 change: 1 addition & 0 deletions apps/nmreplay/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nmreplay
1 change: 1 addition & 0 deletions apps/tlem/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tlem
2 changes: 1 addition & 1 deletion examples/ctrs.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ wait_for_next_report(struct timeval *prev, struct timeval *cur,

delta.tv_sec = report_interval/1000;
delta.tv_usec = (report_interval%1000)*1000;
if (select(0, NULL, NULL, NULL, &delta) < 0) {
if (select(0, NULL, NULL, NULL, &delta) < 0 && errno != EINTR) {
perror("select");
abort();
}
Expand Down
5 changes: 3 additions & 2 deletions extra/python/README
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ language.

to see the available options.

(5.2) tx.py - An example packet generator using the lower level
Python netmap bindings.
(5.2) tx.py - An minimal packet generator using the lower level
Python netmap bindings, it is able to transmit
more than 20 Mpps.

25 changes: 25 additions & 0 deletions extra/python/netmap_desc.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ NetmapDesc_dealloc(NetmapDesc* self)

if (self->nmd) {
nm_close(self->nmd);
self->nmd = NULL;
}
self->ob_type->tp_free((PyObject*)self);
}
Expand Down Expand Up @@ -170,6 +171,24 @@ static PyGetSetDef NetmapDesc_getseters[] = {

/*########################## NetmapDesc methods ########################*/

static PyObject *
NetmapDesc_enter(NetmapDesc *self)
{
Py_INCREF(self);
return (PyObject *)self;
}

static PyObject *
NetmapDesc_exit(NetmapDesc *self, PyObject *args)
{
if (self->nmd) {
nm_close(self->nmd);
self->nmd = NULL;
}

Py_RETURN_NONE;
}

static PyObject *
NetmapDesc_xxsync(NetmapDesc *self, int iocmd)
{
Expand Down Expand Up @@ -217,6 +236,12 @@ NetmapDesc_getflags(NetmapDesc *self)

/* A container for the netmap methods. */
static PyMethodDef NetmapDesc_methods[] = {
{"__enter__", (PyCFunction)NetmapDesc_enter, METH_NOARGS,
"__enter__ implementation to support with statement"
},
{"__exit__", (PyCFunction)NetmapDesc_exit, METH_VARARGS,
"__exit__ implementation to support with statement"
},
{"txsync", (PyCFunction)NetmapDesc_txsync, METH_NOARGS,
"Do a txsync on the registered rings"
},
Expand Down
28 changes: 26 additions & 2 deletions extra/python/tx.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/env python
# Copyright (C) 2013-2015, Vincenzo Maffione

import netmap
import time
import struct
import select
import argparse # program argument parsing


def build_packet():
Expand All @@ -12,13 +14,28 @@ def build_packet():


############################## MAIN ###########################

parser = argparse.ArgumentParser(description = 'Minimal, high-performance packet '\
'generator written in Python using '\
'the netmap API',
epilog = 'Press Ctrl-C to stop')
parser.add_argument('-i', '--interface', help = 'the interface to register with netmap; '
'can be in the form <OSNAME> or <VALENAME>, where '
'OSNAME is the O.S. name for a network interface (e.g. "eth0"), '
'<VALENAME> is a valid VALE port name (e.g. "vale18:2")',
default = 'vale0:0')

args = parser.parse_args()

pkt = build_packet()

print("Opening interface %s" % (args.interface))

# open the netmap device and register an interface
nm = netmap.Netmap()
nm.open()
nfd = nm.getfd()
nm.if_name = 'vale:1'
nm.if_name = args.interface
nm.register()
time.sleep(1)

Expand All @@ -29,6 +46,7 @@ def build_packet():
txr.slots[i].buf[0:len(pkt)] = pkt
txr.slots[i].len = len(pkt)

print("Starting transmission, press Ctrl-C to stop")

# transmit at maximum speed until Ctr-C is pressed
cnt = 0 # packet counter
Expand Down Expand Up @@ -58,6 +76,12 @@ def build_packet():
pass
t_end = time.time()

print("\nPackets sent: %s, Avg rate %s Kpps" % (cnt, 0.001 * cnt / (t_end - t_start)))
rate = 0.001 * cnt / (t_end - t_start)
unit = 'K'
if rate > 1000:
rate /= 1000.0
unit = 'M'

print("\nPackets sent: %s, Avg rate %6.3f %spps" % (cnt, rate, unit))

nm.close()
4 changes: 2 additions & 2 deletions sys/dev/netmap/if_ixl_netmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ extern int ixl_rx_miss, ixl_rx_miss_bufs, ixl_crcstrip;
/*
* device-specific sysctl variables:
*
* ixl_crcstrip: 0: keep CRC in rx frames (default), 1: strip it.
* ixl_crcstrip: 0: NIC keeps CRC in rx frames (default), 1: NIC strips it.
* During regular operations the CRC is stripped, but on some
* hardware reception of frames not multiple of 64 is slower,
* so using crcstrip=0 helps in benchmarks.
Expand All @@ -74,7 +74,7 @@ SYSCTL_DECL(_dev_netmap);
int ixl_rx_miss, ixl_rx_miss_bufs, ixl_crcstrip = 1;
#if 0
SYSCTL_INT(_dev_netmap, OID_AUTO, ixl_crcstrip,
CTLFLAG_RW, &ixl_crcstrip, 1, "strip CRC on rx frames");
CTLFLAG_RW, &ixl_crcstrip, 1, "NIC strips CRC on rx frames");
#endif
SYSCTL_INT(_dev_netmap, OID_AUTO, ixl_rx_miss,
CTLFLAG_RW, &ixl_rx_miss, 0, "potentially missed rx intr");
Expand Down
4 changes: 2 additions & 2 deletions sys/dev/netmap/ixgbe_netmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
/*
* device-specific sysctl variables:
*
* ix_crcstrip: 0: keep CRC in rx frames (default), 1: strip it.
* ix_crcstrip: 0: NIC keeps CRC in rx frames (default), 1: NIC strips it.
* During regular operations the CRC is stripped, but on some
* hardware reception of frames not multiple of 64 is slower,
* so using crcstrip=0 helps in benchmarks.
Expand All @@ -64,7 +64,7 @@ SYSCTL_DECL(_dev_netmap);
static int ix_rx_miss, ix_rx_miss_bufs;
int ix_crcstrip;
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_crcstrip,
CTLFLAG_RW, &ix_crcstrip, 0, "strip CRC on rx frames");
CTLFLAG_RW, &ix_crcstrip, 0, "NIC strips CRC on rx frames");
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_rx_miss,
CTLFLAG_RW, &ix_rx_miss, 0, "potentially missed rx intr");
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_rx_miss_bufs,
Expand Down
3 changes: 2 additions & 1 deletion sys/dev/netmap/netmap_mem2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,8 +1481,9 @@ static int
netmap_mem_private_finalize(struct netmap_mem_d *nmd)
{
int err;
nmd->active++;
err = netmap_mem_finalize_all(nmd);
if (!err)
nmd->active++;
return err;

}
Expand Down

0 comments on commit 8123c74

Please sign in to comment.