Skip to content

Commit a85f2b7

Browse files
committed
Merge branch 'master' into gh
2 parents 74ffbd2 + 3982bd1 commit a85f2b7

5 files changed

Lines changed: 60 additions & 40 deletions

File tree

sys/dev/netmap/if_em_netmap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ em_netmap_rxsync(struct netmap_kring *kring, int flags)
277277
if (addr == NETMAP_BUF_BASE(na)) /* bad buf */
278278
goto ring_reset;
279279

280+
curr->read.buffer_addr = htole64(paddr);
280281
if (slot->flags & NS_BUF_CHANGED) {
281282
/* buffer has changed, reload map */
282-
curr->read.buffer_addr = htole64(paddr);
283283
netmap_reload_map(na, rxr->rxtag, rxbuf->map, addr);
284284
slot->flags &= ~NS_BUF_CHANGED;
285285
}

sys/dev/netmap/netmap.c

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,20 +1046,20 @@ netmap_dtor(void *data)
10461046
* These are associated to a network interface and are just another
10471047
* ring pair managed by userspace.
10481048
*
1049-
* Netmap also supports transparent forwarding (NS_FOWARD and NR_FOWARD
1049+
* Netmap also supports transparent forwarding (NS_FORWARD and NR_FORWARD
10501050
* flags):
10511051
*
10521052
* - Before releasing buffers on hw RX rings, the application can mark
1053-
* them with the NS_FOWARD flag. During the next RXSYNC or poll(), they
1053+
* them with the NS_FORWARD flag. During the next RXSYNC or poll(), they
10541054
* will be forwarded to the host stack, similarly to what happened if
10551055
* the application moved them to the host TX ring.
10561056
*
10571057
* - Before releasing buffers on the host RX ring, the application can
1058-
* mark them with the NS_FOWARD flag. During the next RXSYNC or poll(),
1058+
* mark them with the NS_FORWARD flag. During the next RXSYNC or poll(),
10591059
* they will be forwarded to the hw TX rings, saving the application
10601060
* from doing the same task in user-space.
10611061
*
1062-
* Transparent fowarding can be enabled per-ring, by setting the NR_FOWARD
1062+
* Transparent fowarding can be enabled per-ring, by setting the NR_FORWARD
10631063
* flag, or globally with the netmap_fwd sysctl.
10641064
*
10651065
* The transfer NIC --> host is relatively easy, just encapsulate
@@ -2145,6 +2145,16 @@ nm_sync_finalize(struct netmap_kring *kring)
21452145
kring->rhead, kring->rcur, kring->rtail);
21462146
}
21472147

2148+
/* set ring timestamp */
2149+
static inline void
2150+
ring_timestamp_set(struct netmap_ring *ring)
2151+
{
2152+
if (netmap_no_timestamp == 0 || ring->flags & NR_TIMESTAMP) {
2153+
microtime(&ring->ts);
2154+
}
2155+
}
2156+
2157+
21482158
/*
21492159
* ioctl(2) support for the "netmap" device.
21502160
*
@@ -2160,6 +2170,7 @@ nm_sync_finalize(struct netmap_kring *kring)
21602170
int
21612171
netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, caddr_t data, struct thread *td)
21622172
{
2173+
struct mbq q; /* packets from RX hw queues to host stack */
21632174
struct nmreq *nmr = (struct nmreq *) data;
21642175
struct netmap_adapter *na = NULL;
21652176
struct netmap_mem_d *nmd = NULL;
@@ -2373,6 +2384,7 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, caddr_t data, struct thread
23732384
break;
23742385
}
23752386

2387+
mbq_init(&q);
23762388
t = (cmd == NIOCTXSYNC ? NR_TX : NR_RX);
23772389
krings = NMR(na, t);
23782390
qfirst = priv->np_qfirst[t];
@@ -2404,14 +2416,23 @@ netmap_ioctl(struct netmap_priv_d *priv, u_long cmd, caddr_t data, struct thread
24042416
} else {
24052417
if (nm_rxsync_prologue(kring, ring) >= kring->nkr_num_slots) {
24062418
netmap_ring_reinit(kring);
2407-
} else if (kring->nm_sync(kring, NAF_FORCE_READ) == 0) {
2419+
}
2420+
if (nm_may_forward_up(kring)) {
2421+
/* transparent forwarding, see netmap_poll() */
2422+
netmap_grab_packets(kring, &q, netmap_fwd);
2423+
}
2424+
if (kring->nm_sync(kring, NAF_FORCE_READ) == 0) {
24082425
nm_sync_finalize(kring);
24092426
}
2410-
microtime(&ring->ts);
2427+
ring_timestamp_set(ring);
24112428
}
24122429
nm_kr_put(kring);
24132430
}
24142431

2432+
if (mbq_peek(&q)) {
2433+
netmap_send_up(na->ifp, &q);
2434+
}
2435+
24152436
break;
24162437

24172438
#ifdef WITH_VALE
@@ -2482,7 +2503,7 @@ netmap_poll(struct netmap_priv_d *priv, int events, NM_SELRECORD_T *sr)
24822503
u_int i, check_all_tx, check_all_rx, want[NR_TXRX], revents = 0;
24832504
#define want_tx want[NR_TX]
24842505
#define want_rx want[NR_RX]
2485-
struct mbq q; /* packets from hw queues to host stack */
2506+
struct mbq q; /* packets from RX hw queues to host stack */
24862507
enum txrx t;
24872508

24882509
/*
@@ -2665,8 +2686,6 @@ netmap_poll(struct netmap_priv_d *priv, int events, NM_SELRECORD_T *sr)
26652686
* hw rxring(s) that have been released by the user
26662687
*/
26672688
if (nm_may_forward_up(kring)) {
2668-
ND(2, "forwarding some buffers up %d to %d",
2669-
kring->nr_hwcur, ring->cur);
26702689
netmap_grab_packets(kring, &q, netmap_fwd);
26712690
}
26722691

@@ -2679,10 +2698,7 @@ netmap_poll(struct netmap_priv_d *priv, int events, NM_SELRECORD_T *sr)
26792698
else
26802699
nm_sync_finalize(kring);
26812700
send_down |= (kring->nr_kflags & NR_FORWARD);
2682-
if (netmap_no_timestamp == 0 ||
2683-
ring->flags & NR_TIMESTAMP) {
2684-
microtime(&ring->ts);
2685-
}
2701+
ring_timestamp_set(ring);
26862702
found = kring->rcur != kring->rtail;
26872703
nm_kr_put(kring);
26882704
if (found) {

sys/dev/netmap/netmap_freebsd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,17 +403,17 @@ netmap_getna(if_t ifp)
403403
int
404404
nm_os_generic_find_num_desc(struct ifnet *ifp, unsigned int *tx, unsigned int *rx)
405405
{
406-
D("called, in tx %d rx %d", *tx, *rx);
407406
return 0;
408407
}
409408

410409

411410
void
412411
nm_os_generic_find_num_queues(struct ifnet *ifp, u_int *txq, u_int *rxq)
413412
{
414-
D("called, in txq %d rxq %d", *txq, *rxq);
415-
*txq = netmap_generic_rings;
416-
*rxq = netmap_generic_rings;
413+
unsigned num_rings = netmap_generic_rings ? netmap_generic_rings : 1;
414+
415+
*txq = num_rings;
416+
*rxq = num_rings;
417417
}
418418

419419
void

utils/switch-modules/ovs-2.4.0/0001-datapath-netmap-VALE-support.patch

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
diff --git a/INSTALL.NETMAP b/INSTALL.NETMAP
22
new file mode 100644
3-
index 000000000..57d796715
3+
index 000000000..f70466798
44
--- /dev/null
55
+++ b/INSTALL.NETMAP
66
@@ -0,0 +1,95 @@
@@ -61,7 +61,7 @@ index 000000000..57d796715
6161
+
6262
+(3) Create an OVS bridge:
6363
+
64-
+# ovs-vsctl add-br vale0
64+
+# ovs-vsctl add-br br0
6565
+
6666
+(4) Create two persistent VALE ports:
6767
+
@@ -70,20 +70,20 @@ index 000000000..57d796715
7070
+
7171
+(5) Attach the two ports to the bridge:
7272
+
73-
+# ovs-vsctl add-port vale0 vi0
74-
+# ovs-vsctl add-port vale0 vi1
73+
+# ovs-vsctl add-port br0 vi0
74+
+# ovs-vsctl add-port br0 vi1
7575
+
7676
+(6) Add some OpenFlow rules, to forward traffic betweeen vi0 and vi1
7777
+(assuming the port identifiers are 1 and 2):
7878
+
79-
+# ovs-ofctl add-flow vale0 in_port=1,actions=output:2
80-
+# ovs-ofctl add-flow vale0 in_port=2,actions=output:1
79+
+# ovs-ofctl add-flow br0 in_port=1,actions=output:2
80+
+# ovs-ofctl add-flow br0 in_port=2,actions=output:1
8181
+
8282
+(7) Bring the various interfaces up:
8383
+
8484
+# ip link set vi0 up
8585
+# ip link set vi1 up
86-
+# ip link set vale0 up
86+
+# ip link set br0 up
8787
+
8888
+(8) Run pkt-gen in receive mode on vi0:
8989
+
@@ -98,7 +98,7 @@ index 000000000..57d796715
9898
+they have netmap support (e.g. Intel NIC veth interfaces,
9999
+etc.):
100100
+
101-
+# ovs-vsctl add-port vale0 eth2
101+
+# ovs-vsctl add-port br0 eth2
102102
diff --git a/Makefile.am b/Makefile.am
103103
index 59a14667d..1f59e74fa 100644
104104
--- a/Makefile.am
@@ -185,10 +185,10 @@ index 3c97b86df..c0307dd22 100644
185185
if (err)
186186
diff --git a/datapath/dp-vale.c b/datapath/dp-vale.c
187187
new file mode 100644
188-
index 000000000..41cb43337
188+
index 000000000..9b38f4431
189189
--- /dev/null
190190
+++ b/datapath/dp-vale.c
191-
@@ -0,0 +1,193 @@
191+
@@ -0,0 +1,195 @@
192192
+/*
193193
+ * Copyright (c) 2014 NEC Europe Ltd.
194194
+ *
@@ -286,7 +286,9 @@ index 000000000..41cb43337
286286
+ return dst.port;
287287
+}
288288
+
289-
+#define OVS_VALE_PREFIX "vale0:"
289+
+/* Name of the VALE switch that will be actually used to
290+
+ * implement the OVS datapath (for all the OVS bridges). */
291+
+#define OVS_VALE_PREFIX "valeOVS:"
290292
+
291293
+static struct netmap_bdg_ops ovs_vale_ops = {
292294
+ .lookup = ovs_vale_lookup,

utils/switch-modules/ovs-2.6.1/0001-datapath-netmap-VALE-support.patch

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
diff --git a/INSTALL.NETMAP b/INSTALL.NETMAP
22
new file mode 100644
3-
index 000000000..088a5d842
3+
index 000000000..12ee16307
44
--- /dev/null
55
+++ b/INSTALL.NETMAP
66
@@ -0,0 +1,95 @@
@@ -61,7 +61,7 @@ index 000000000..088a5d842
6161
+
6262
+(3) Create an OVS bridge:
6363
+
64-
+# ovs-vsctl add-br vale0
64+
+# ovs-vsctl add-br br0
6565
+
6666
+(4) Create two persistent VALE ports:
6767
+
@@ -70,20 +70,20 @@ index 000000000..088a5d842
7070
+
7171
+(5) Attach the two ports to the bridge:
7272
+
73-
+# ovs-vsctl add-port vale0 vi0
74-
+# ovs-vsctl add-port vale0 vi1
73+
+# ovs-vsctl add-port br0 vi0
74+
+# ovs-vsctl add-port br0 vi1
7575
+
7676
+(6) Add some OpenFlow rules, to forward traffic betweeen vi0 and vi1
7777
+(assuming the port identifiers are 1 and 2):
7878
+
79-
+# ovs-ofctl add-flow vale0 in_port=1,actions=output:2
80-
+# ovs-ofctl add-flow vale0 in_port=2,actions=output:1
79+
+# ovs-ofctl add-flow br0 in_port=1,actions=output:2
80+
+# ovs-ofctl add-flow br0 in_port=2,actions=output:1
8181
+
8282
+(7) Bring the various interfaces up:
8383
+
8484
+# ip link set vi0 up
8585
+# ip link set vi1 up
86-
+# ip link set vale0 up
86+
+# ip link set br0 up
8787
+
8888
+(8) Run pkt-gen in receive mode on vi0:
8989
+
@@ -98,7 +98,7 @@ index 000000000..088a5d842
9898
+they have netmap support (e.g. Intel NIC veth interfaces,
9999
+etc.):
100100
+
101-
+# ovs-vsctl add-port vale0 eth2
101+
+# ovs-vsctl add-port br0 eth2
102102
diff --git a/Makefile.am b/Makefile.am
103103
index 49010b3b5..56f4f62ef 100644
104104
--- a/Makefile.am
@@ -196,10 +196,10 @@ index db8a18a13..0352e3d83 100644
196196
if (err)
197197
diff --git a/datapath/dp-vale.c b/datapath/dp-vale.c
198198
new file mode 100644
199-
index 000000000..514bf9197
199+
index 000000000..fb1ac5f6c
200200
--- /dev/null
201201
+++ b/datapath/dp-vale.c
202-
@@ -0,0 +1,195 @@
202+
@@ -0,0 +1,197 @@
203203
+/*
204204
+ * Copyright (c) 2014 NEC Europe Ltd.
205205
+ *
@@ -297,7 +297,9 @@ index 000000000..514bf9197
297297
+ return dst.port;
298298
+}
299299
+
300-
+#define OVS_VALE_PREFIX "vale0:"
300+
+/* Name of the VALE switch that will be actually used to
301+
+ * implement the OVS datapath (for all the OVS bridges). */
302+
+#define OVS_VALE_PREFIX "valeOVS:"
301303
+
302304
+static struct netmap_bdg_ops ovs_vale_ops = {
303305
+ .lookup = ovs_vale_lookup,

0 commit comments

Comments
 (0)