Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F152632542
D31550.id93861.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D31550.id93861.diff
View Options
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -993,6 +993,7 @@
u_int const lim = kring->nkr_num_slots - 1;
u_int const head = kring->rhead;
struct if_pkt_info pi;
+ int tx_pkts = 0, tx_bytes = 0;
/*
* interrupts on every tx packet are expensive so request
@@ -1077,6 +1078,10 @@
ctx->isc_txd_encap(ctx->ifc_softc, &pi);
DBG_COUNTER_INC(tx_encap);
+ /* Update transmit counters */
+ tx_bytes += pi.ipi_len;
+ tx_pkts++;
+
/* Reinit per-packet info for the next one. */
flags = seg_idx = pkt_len = 0;
nic_i_start = -1;
@@ -1135,6 +1140,10 @@
iflib_netmap_timer, txq,
txq->ift_netmap_timer.c_cpu, 0);
}
+
+ if_inc_counter(ifp, IFCOUNTER_OBYTES, tx_bytes);
+ if_inc_counter(ifp, IFCOUNTER_OPACKETS, tx_pkts);
+
return (0);
}
@@ -1162,7 +1171,7 @@
u_int n;
u_int const lim = kring->nkr_num_slots - 1;
int force_update = (flags & NAF_FORCE_READ) || kring->nr_kflags & NKR_PENDINTR;
- int i = 0;
+ int i = 0, rx_bytes = 0, rx_pkts = 0;
if_ctx_t ctx = ifp->if_softc;
if_shared_ctx_t sctx = ctx->ifc_sctx;
@@ -1233,6 +1242,10 @@
if (i == (ri.iri_nfrags - 1)) {
ring->slot[nm_i].len -= crclen;
ring->slot[nm_i].flags = 0;
+
+ /* Update receive counters */
+ rx_bytes += ri.iri_len;
+ rx_pkts++;
} else
ring->slot[nm_i].flags = NS_MOREFRAG;
}
@@ -1270,6 +1283,9 @@
*/
netmap_fl_refill(rxq, kring, false);
+ if_inc_counter(ifp, IFCOUNTER_IBYTES, rx_bytes);
+ if_inc_counter(ifp, IFCOUNTER_IPACKETS, rx_pkts);
+
return (0);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 17, 3:44 AM (1 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31637363
Default Alt Text
D31550.id93861.diff (1 KB)
Attached To
Mode
D31550: iflib: emulate counters in netmap mode
Attached
Detach File
Event Timeline
Log In to Comment