From: patrick Date: Wed, 2 Jun 2021 19:16:11 +0000 (+0000) Subject: When processing a received packet, only sync the amount of bytes X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=cb533b84c1c6d0f6366fc179989e2c21a0564d19;p=openbsd When processing a received packet, only sync the amount of bytes mcx(4) told us has arrived. The DMA map's mapsize on RX packets is the length of the allocated buffer. For mcx(4), this can be more than around 9000 bytes, as each buffer will be at least as big as the maximum supported MTU. There's no need to sync the whole buffer, if it's only a small packet. ok dlg@ jmatthew@ --- diff --git a/sys/dev/pci/if_mcx.c b/sys/dev/pci/if_mcx.c index 38437e54897..99b7c5f8d62 100644 --- a/sys/dev/pci/if_mcx.c +++ b/sys/dev/pci/if_mcx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mcx.c,v 1.100 2021/02/25 02:48:20 dlg Exp $ */ +/* $OpenBSD: if_mcx.c,v 1.101 2021/06/02 19:16:11 patrick Exp $ */ /* * Copyright (c) 2017 David Gwynne @@ -6800,20 +6800,20 @@ mcx_process_rx(struct mcx_softc *sc, struct mcx_rx *rx, { struct mcx_slot *ms; struct mbuf *m; - uint32_t flags; + uint32_t flags, len; int slot; + len = bemtoh32(&cqe->cq_byte_cnt); slot = betoh16(cqe->cq_wqe_count) % (1 << MCX_LOG_RQ_SIZE); ms = &rx->rx_slots[slot]; - bus_dmamap_sync(sc->sc_dmat, ms->ms_map, 0, ms->ms_map->dm_mapsize, - BUS_DMASYNC_POSTREAD); + bus_dmamap_sync(sc->sc_dmat, ms->ms_map, 0, len, BUS_DMASYNC_POSTREAD); bus_dmamap_unload(sc->sc_dmat, ms->ms_map); m = ms->ms_m; ms->ms_m = NULL; - m->m_pkthdr.len = m->m_len = bemtoh32(&cqe->cq_byte_cnt); + m->m_pkthdr.len = m->m_len = len; if (cqe->cq_rx_hash_type) { m->m_pkthdr.ph_flowid = betoh32(cqe->cq_rx_hash);