@@ -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)
21602170int
21612171netmap_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 ) {
0 commit comments