dpaa2: add support for several interface counters

Add support for IFCOUNTER_IPACKETS, IFCOUNTER_OPACKETS,
IFCOUNTER_OBYTES, IFCOUNTER_OMCASTS, IFCOUNTER_OERRORS, and
IFCOUNTER_OQDROPS.
This allows tools like systat to report the incoming and outgoing
bandwidth.

Reviewed by:		dsl, Timo Völker
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D54893
This commit is contained in:
Michael Tuexen
2026-01-30 10:58:57 +01:00
parent 03e4cc9fde
commit 33596d9255
+14
View File
@@ -2532,6 +2532,7 @@ dpaa2_ni_transmit(if_t ifp, struct mbuf *m)
ch = sc->channels[chidx];
error = buf_ring_enqueue(ch->xmit_br, m);
if (__predict_false(error != 0)) {
if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1);
m_freem(m);
} else {
taskqueue_enqueue(ch->cleanup_tq, &ch->cleanup_task);
@@ -2943,6 +2944,8 @@ dpaa2_ni_tx(struct dpaa2_ni_softc *sc, struct dpaa2_channel *ch,
bus_dma_segment_t segs[DPAA2_TX_SEGLIMIT];
int rc, nsegs;
int error;
int len;
bool mcast;
mtx_assert(&tx->lock, MA_NOTOWNED);
mtx_lock(&tx->lock);
@@ -2957,6 +2960,8 @@ dpaa2_ni_tx(struct dpaa2_ni_softc *sc, struct dpaa2_channel *ch,
buf->m = m;
sgt = buf->sgt;
}
len = m->m_pkthdr.len;
mcast = (m->m_flags & M_MCAST) != 0;
#if defined(INVARIANTS)
struct dpaa2_ni_tx_ring *btx = (struct dpaa2_ni_tx_ring *)buf->opt;
@@ -2974,6 +2979,7 @@ dpaa2_ni_tx(struct dpaa2_ni_softc *sc, struct dpaa2_channel *ch,
if (md == NULL) {
device_printf(dev, "%s: m_collapse() failed\n", __func__);
fq->chan->tx_dropped++;
if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1);
goto err;
}
@@ -2984,6 +2990,7 @@ dpaa2_ni_tx(struct dpaa2_ni_softc *sc, struct dpaa2_channel *ch,
device_printf(dev, "%s: bus_dmamap_load_mbuf_sg() "
"failed: error=%d\n", __func__, error);
fq->chan->tx_dropped++;
if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1);
goto err;
}
}
@@ -2993,6 +3000,7 @@ dpaa2_ni_tx(struct dpaa2_ni_softc *sc, struct dpaa2_channel *ch,
device_printf(dev, "%s: failed to build frame descriptor: "
"error=%d\n", __func__, error);
fq->chan->tx_dropped++;
if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1);
goto err_unload;
}
@@ -3010,8 +3018,13 @@ dpaa2_ni_tx(struct dpaa2_ni_softc *sc, struct dpaa2_channel *ch,
if (rc != 1) {
fq->chan->tx_dropped++;
if_inc_counter(sc->ifp, IFCOUNTER_OERRORS, 1);
goto err_unload;
} else {
if (mcast)
if_inc_counter(sc->ifp, IFCOUNTER_OMCASTS, 1);
if_inc_counter(sc->ifp, IFCOUNTER_OPACKETS, 1);
if_inc_counter(sc->ifp, IFCOUNTER_OBYTES, len);
fq->chan->tx_frames++;
}
return;
@@ -3190,6 +3203,7 @@ dpaa2_ni_rx(struct dpaa2_channel *ch, struct dpaa2_ni_fq *fq, struct dpaa2_fd *f
m->m_pkthdr.rcvif = sc->ifp;
m->m_pkthdr.flowid = fq->fqid;
M_HASHTYPE_SET(m, M_HASHTYPE_OPAQUE);
if_inc_counter(sc->ifp, IFCOUNTER_IPACKETS, 1);
if (ctx->head == NULL) {
KASSERT(ctx->tail == NULL, ("%s: tail already given?", __func__));