Skip to content

Commit 8123c74

Browse files
Merge branch 'master' into github-master
2 parents 77df06a + 325dfde commit 8123c74

14 files changed

Lines changed: 76 additions & 31 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,4 @@ LINUX/veth.c
5757
*.sdf
5858
*.opensdf
5959
*~
60+
cscope.out

LINUX/configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,7 @@ add_test 'have RX_HANDLER_RESULT' <<-EOF
831831
#include <linux/netdevice.h>
832832
833833
834-
static rx_handler_result_t dummy_rx_handler(struct sk_buf **pm)
834+
static rx_handler_result_t dummy_rx_handler(struct sk_buff **pm)
835835
{
836836
(void)pm;
837837
return RX_HANDLER_PASS;

LINUX/i40e_netmap_linux.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,19 @@ extern int ix_rx_miss, ix_rx_miss_bufs, ix_crcstrip;
6060
/*
6161
* device-specific sysctl variables:
6262
*
63-
* ix_crcstrip: 0: keep CRC in rx frames (default), 1: strip it.
63+
* ix_crcstrip: 0: NIC keeps CRC in rx frames (default), 1: NIC strips it.
6464
* During regular operations the CRC is stripped, but on some
6565
* hardware reception of frames not multiple of 64 is slower,
6666
* so using crcstrip=0 helps in benchmarks.
67+
* The driver by default strips CRCs and we do not override it.
6768
*
6869
* ix_rx_miss, ix_rx_miss_bufs:
6970
* count packets that might be missed due to lost interrupts.
7071
*/
7172
SYSCTL_DECL(_dev_netmap);
72-
int ix_rx_miss, ix_rx_miss_bufs, ix_crcstrip;
73+
int ix_rx_miss = 0, ix_rx_miss_bufs = 0, ix_crcstrip = 1;
7374
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_crcstrip,
74-
CTLFLAG_RW, &ix_crcstrip, 1, "strip CRC on rx frames");
75+
CTLFLAG_RW, &ix_crcstrip, 1, "NIC strips CRC on rx frames");
7576
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_rx_miss,
7677
CTLFLAG_RW, &ix_rx_miss, 0, "potentially missed rx intr");
7778
SYSCTL_INT(_dev_netmap, OID_AUTO, ix_rx_miss_bufs,

apps/lb/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lb

apps/lb/lb.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -561,23 +561,23 @@ int main(int argc, char **argv)
561561
while (!nm_ring_empty(rxring)) {
562562
struct overflow_queue *q;
563563
struct netmap_slot *rs = next_slot;
564-
next_cur = nm_ring_next(rxring, next_cur);
565-
next_slot = &rxring->slot[next_cur];
566564

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

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

593-
/* try to push packets down to free some space
594-
* in the pipe (no more than once per loop on
595-
* the same pipe, to make sure that there is a
596-
* reasonable amount of time between syncs)
597-
*/
598-
if (port->last_sync != iter) {
599-
port->last_sync = iter;
600-
ioctl(port->nmd->fd, NIOCTXSYNC, NULL);
601-
goto retry;
602-
}
603-
604593
/* use the overflow queue, if available */
605594
if (!oq) {
606595
dropped++;

apps/nmreplay/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nmreplay

apps/tlem/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tlem

examples/ctrs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ wait_for_next_report(struct timeval *prev, struct timeval *cur,
9595

9696
delta.tv_sec = report_interval/1000;
9797
delta.tv_usec = (report_interval%1000)*1000;
98-
if (select(0, NULL, NULL, NULL, &delta) < 0) {
98+
if (select(0, NULL, NULL, NULL, &delta) < 0 && errno != EINTR) {
9999
perror("select");
100100
abort();
101101
}

extra/python/README

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ language.
9595

9696
to see the available options.
9797

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

extra/python/netmap_desc.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ NetmapDesc_dealloc(NetmapDesc* self)
4444

4545
if (self->nmd) {
4646
nm_close(self->nmd);
47+
self->nmd = NULL;
4748
}
4849
self->ob_type->tp_free((PyObject*)self);
4950
}
@@ -170,6 +171,24 @@ static PyGetSetDef NetmapDesc_getseters[] = {
170171

171172
/*########################## NetmapDesc methods ########################*/
172173

174+
static PyObject *
175+
NetmapDesc_enter(NetmapDesc *self)
176+
{
177+
Py_INCREF(self);
178+
return (PyObject *)self;
179+
}
180+
181+
static PyObject *
182+
NetmapDesc_exit(NetmapDesc *self, PyObject *args)
183+
{
184+
if (self->nmd) {
185+
nm_close(self->nmd);
186+
self->nmd = NULL;
187+
}
188+
189+
Py_RETURN_NONE;
190+
}
191+
173192
static PyObject *
174193
NetmapDesc_xxsync(NetmapDesc *self, int iocmd)
175194
{
@@ -217,6 +236,12 @@ NetmapDesc_getflags(NetmapDesc *self)
217236

218237
/* A container for the netmap methods. */
219238
static PyMethodDef NetmapDesc_methods[] = {
239+
{"__enter__", (PyCFunction)NetmapDesc_enter, METH_NOARGS,
240+
"__enter__ implementation to support with statement"
241+
},
242+
{"__exit__", (PyCFunction)NetmapDesc_exit, METH_VARARGS,
243+
"__exit__ implementation to support with statement"
244+
},
220245
{"txsync", (PyCFunction)NetmapDesc_txsync, METH_NOARGS,
221246
"Do a txsync on the registered rings"
222247
},

0 commit comments

Comments
 (0)