netmap: Try to count packet drops in emulated mode

Right now we have little visibility into packet drops within netmap.
Start trying to make packet loss issues more visible by counting queue
drops in the transmit path, and in the input path for interfaces running
in emulated mode, where we place received packets in a bounded software
queue that is processed by rxsync.

Reviewed by:	vmaffione
MFC after:	1 week
Sponsored by:	Zenarmor
Sponsored by:	OPNsense
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D38064
This commit is contained in:
Mark Johnston 2023-01-23 14:42:41 -05:00
parent 854b2f302d
commit df40e30c97
2 changed files with 5 additions and 1 deletions

View File

@ -4329,8 +4329,10 @@ netmap_transmit(struct ifnet *ifp, struct mbuf *m)
mbq_unlock(q);
done:
if (m)
if (m) {
if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1);
m_freem(m);
}
/* unconditionally wake up listeners */
kring->nm_notify(kring, 0);
/* this is normally netmap_notify(), but for nics

View File

@ -837,8 +837,10 @@ generic_rx_handler(struct ifnet *ifp, struct mbuf *m)
* support RX scatter-gather. */
nm_prlim(2, "Warning: driver pushed up big packet "
"(size=%d)", (int)MBUF_LEN(m));
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
m_freem(m);
} else if (unlikely(mbq_len(&kring->rx_queue) > na->num_rx_desc)) {
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
m_freem(m);
} else {
mbq_safe_enqueue(&kring->rx_queue, m);