dpaa: cross-module buffer free for WiFi offload

Add dtsec_rm_buf_free_external() for dpaa_wifi.ko to release BMan
buffers from dtsec RX pools back to the correct UMA zone. Route
M_PROTO1-tagged mbufs to if_transmit in QMan portal drain path.
This commit is contained in:
Tomaz Zaman 2026-03-04 23:02:08 +01:00 • committed by Maurice Walker
parent 1dd81a66be
commit 7e747b3417
3 changed files with 51 additions and 3 deletions

View file

@ -164,6 +164,16 @@ e_FmPortType dtsec_fm_port_tx_type(enum eth_dev_type type);
/** @} */
/**
* @group dTSEC external buffer release.
*
* Used by dpaa_wifi.ko to free BMan buffers from dtsec RX pools
* back to the correct UMA zone with proper consumption model accounting.
* @{
*/
void dtsec_rm_buf_free_external(uint8_t bpid, void *buf);
/** @} */
/**
* @group dTSEC bus interface.
* @{

View file

@ -610,6 +610,15 @@ dtsec_rm_pool_rx_free(struct dtsec_softc *sc)
uma_zdestroy(sc->sc_rx_zone);
}
/*
* BPID→dtsec_softc mapping for cross-module buffer release.
*
* When dpaa_wifi.ko receives a frame from CDX (buffer from a dtsec BMan
* pool), it needs to free the buffer back to the correct dtsec's UMA zone
* and decrement sc_rx_buf_total. This table maps BPID to dtsec_softc.
*/
static struct dtsec_softc *dtsec_bpid_map[256];
int
dtsec_rm_pool_rx_init(struct dtsec_softc *sc)
{
@ -633,8 +642,27 @@ dtsec_rm_pool_rx_init(struct dtsec_softc *sc)
sc->sc_rx_buf_total = DTSEC_RM_POOL_RX_MAX_SIZE;
/* Register BPID→softc mapping for external buffer release */
dtsec_bpid_map[sc->sc_rx_bpid] = sc;
return (0);
}
void
dtsec_rm_buf_free_external(uint8_t bpid, void *buf)
{
struct dtsec_softc *sc;
sc = dtsec_bpid_map[bpid];
if (__predict_false(sc == NULL)) {
printf("dtsec_rm_buf_free_external: unknown BPID %u\n", bpid);
return;
}
uma_zfree(sc->sc_rx_zone,
(void *)(*(uintptr_t *)buf)); /* recover stashed KVA */
atomic_subtract_32(&sc->sc_rx_buf_total, 1);
}
/** @} */

View file

@ -270,9 +270,19 @@ qman_portal_poll_task(void *arg, int pending)
QM_PORTAL_Poll(portal, e_QM_PORTAL_POLL_SOURCE_BOTH);
QM_PORTAL_Uninhibit(portal);
/* Deliver deferred RX mbufs outside NCSW_PLOCK */
while ((m = mbufq_dequeue(&qman_napi[cpu].rxq)) != NULL)
if_input(m->m_pkthdr.rcvif, m);
/*
* Deliver deferred mbufs outside NCSW_PLOCK.
* M_PROTO1-tagged mbufs are WiFi TX (CDX→WiFi from dpaa_wifi) —
* deliver via if_transmit instead of if_input.
*/
while ((m = mbufq_dequeue(&qman_napi[cpu].rxq)) != NULL) {
if (__predict_false(m->m_flags & M_PROTO1)) {
m->m_flags &= ~M_PROTO1;
if_transmit(m->m_pkthdr.rcvif, m);
} else {
if_input(m->m_pkthdr.rcvif, m);
}
}
}
/*