[Bug 299204] re driver's netmap deregistration should unload the dma mappings

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 07 Oct 2026 13:07:14 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=299204

            Bug ID: 299204
           Summary: re driver's netmap deregistration should unload the
                    dma mappings
           Product: Base System
           Version: 14.5-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: mibelanger@qnx.com

Running pkt_gen twice with an invariants build should show the issue.
e.g.
pkt-gen -i re0 -f tx -n 1 -X 

The following addition to the deregistration in if_re_netmap.h should resolve
the issue:

/*
 * Register/unregister. We are already under netmap lock.
 */
static int
re_netmap_reg(struct netmap_adapter *na, int onoff)
{
        if_t ifp = na->ifp;
        struct rl_softc *adapter = if_getsoftc(ifp);

        RL_LOCK(adapter);
        re_stop(adapter); /* also clears IFF_DRV_RUNNING */
        if (onoff) {
                nm_set_native_flags(na);
        } else {
                nm_clear_native_flags(na);
#if PROPOSED_FIX
                /* Clean up Tx ring mappings */
                for (int i = 0; i < adapter->rl_ldata.rl_tx_desc_cnt; i++ ) {
                        netmap_unload_map(na, adapter->rl_ldata.rl_tx_mtag,
                            adapter->rl_ldata.rl_tx_desc[i].tx_dmamap);
                }
                /* Clean up Rx ring mappings */
                for (int i = 0; i < adapter->rl_ldata.rl_rx_desc_cnt; i++ ) {
                        netmap_unload_map(na, adapter->rl_ldata.rl_rx_mtag,
                            adapter->rl_ldata.rl_rx_desc[i].rx_dmamap);
                }
#endif
        }
        re_init_locked(adapter);        /* also enables intr */
        RL_UNLOCK(adapter);
        return (if_getdrvflags(ifp) & IFF_DRV_RUNNING ? 0 : 1);
}

-- 
You are receiving this mail because:
You are the assignee for the bug.