From f21e821556fba84dc8e15e5b51011635c4e47f78 Mon Sep 17 00:00:00 2001 From: jmatthew Date: Tue, 19 Jul 2022 21:49:22 +0000 Subject: [PATCH] Fix up tx ring slot calculations so we store the mbuf and dma map with the last slot of the packet rather than the first slot of the next. ok dlg@ --- sys/dev/fdt/if_mvneta.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/dev/fdt/if_mvneta.c b/sys/dev/fdt/if_mvneta.c index 2339ca82186..9ee7a9c5ab0 100644 --- a/sys/dev/fdt/if_mvneta.c +++ b/sys/dev/fdt/if_mvneta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mvneta.c,v 1.26 2022/06/05 02:54:18 dlg Exp $ */ +/* $OpenBSD: if_mvneta.c,v 1.27 2022/07/19 21:49:22 jmatthew Exp $ */ /* $NetBSD: if_mvneta.c,v 1.41 2015/04/15 10:15:40 hsuenaga Exp $ */ /* * Copyright (c) 2007, 2008, 2013 KIYOHARA Takashi @@ -975,11 +975,15 @@ mvneta_start(struct ifqueue *ifq) mvneta_encap(sc, map, m, prod); - nprod = (prod + map->dm_nsegs) % MVNETA_TX_RING_CNT; - sc->sc_txbuf[prod].tb_map = sc->sc_txbuf[nprod].tb_map; - prod = nprod; - sc->sc_txbuf[prod].tb_map = map; + if (map->dm_nsegs > 1) { + nprod = (prod + (map->dm_nsegs - 1)) % + MVNETA_TX_RING_CNT; + sc->sc_txbuf[prod].tb_map = sc->sc_txbuf[nprod].tb_map; + prod = nprod; + sc->sc_txbuf[prod].tb_map = map; + } sc->sc_txbuf[prod].tb_m = m; + prod = MVNETA_TX_RING_NEXT(prod); free -= map->dm_nsegs; -- 2.20.1