Tue Apr 23 15:34:07 2024 UTC (16d)
Sync the statistics DMA memory correctly before it is accessed.


(hans)
diff -r1.113 -r1.114 src/sys/dev/pci/if_bnx.c

cvs diff -r1.113 -r1.114 src/sys/dev/pci/if_bnx.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_bnx.c 2024/02/09 22:08:35 1.113
+++ src/sys/dev/pci/if_bnx.c 2024/04/23 15:34:07 1.114
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_bnx.c,v 1.113 2024/02/09 22:08:35 andvar Exp $ */ 1/* $NetBSD: if_bnx.c,v 1.114 2024/04/23 15:34:07 hans Exp $ */
2/* $OpenBSD: if_bnx.c,v 1.101 2013/03/28 17:21:44 brad Exp $ */ 2/* $OpenBSD: if_bnx.c,v 1.101 2013/03/28 17:21:44 brad Exp $ */
3 3
4/*- 4/*-
5 * Copyright (c) 2006-2010 Broadcom Corporation 5 * Copyright (c) 2006-2010 Broadcom Corporation
6 * David Christensen <davidch@broadcom.com>. All rights reserved. 6 * David Christensen <davidch@broadcom.com>. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 11 *
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
31 * THE POSSIBILITY OF SUCH DAMAGE. 31 * THE POSSIBILITY OF SUCH DAMAGE.
32 */ 32 */
33 33
34#include <sys/cdefs.h> 34#include <sys/cdefs.h>
35#if 0 35#if 0
36__FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.3 2006/04/13 14:12:26 ru Exp $"); 36__FBSDID("$FreeBSD: src/sys/dev/bce/if_bce.c,v 1.3 2006/04/13 14:12:26 ru Exp $");
37#endif 37#endif
38__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.113 2024/02/09 22:08:35 andvar Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: if_bnx.c,v 1.114 2024/04/23 15:34:07 hans Exp $");
39 39
40/* 40/*
41 * The following controllers are supported by this driver: 41 * The following controllers are supported by this driver:
42 * BCM5706C A2, A3 42 * BCM5706C A2, A3
43 * BCM5706S A2, A3 43 * BCM5706S A2, A3
44 * BCM5708C B1, B2 44 * BCM5708C B1, B2
45 * BCM5708S B1, B2 45 * BCM5708S B1, B2
46 * BCM5709C A1, C0 46 * BCM5709C A1, C0
47 * BCM5709S A1, C0 47 * BCM5709S A1, C0
48 * BCM5716 C0 48 * BCM5716 C0
49 * 49 *
50 * The following controllers are not supported by this driver: 50 * The following controllers are not supported by this driver:
51 * BCM5706C A0, A1 51 * BCM5706C A0, A1
@@ -5657,27 +5657,27 @@ allmulti: @@ -5657,27 +5657,27 @@ allmulti:
5657/* Called periodically to updates statistics from the controllers */ 5657/* Called periodically to updates statistics from the controllers */
5658/* statistics block. */ 5658/* statistics block. */
5659/* */ 5659/* */
5660/* Returns: */ 5660/* Returns: */
5661/* Nothing. */ 5661/* Nothing. */
5662/****************************************************************************/ 5662/****************************************************************************/
5663void 5663void
5664bnx_stats_update(struct bnx_softc *sc) 5664bnx_stats_update(struct bnx_softc *sc)
5665{ 5665{
5666 struct ifnet *ifp = &sc->bnx_ec.ec_if; 5666 struct ifnet *ifp = &sc->bnx_ec.ec_if;
5667 struct statistics_block *stats; 5667 struct statistics_block *stats;
5668 5668
5669 DBPRINT(sc, BNX_EXCESSIVE, "Entering %s()\n", __func__); 5669 DBPRINT(sc, BNX_EXCESSIVE, "Entering %s()\n", __func__);
5670 bus_dmamap_sync(sc->bnx_dmatag, sc->status_map, 0, BNX_STATUS_BLK_SZ, 5670 bus_dmamap_sync(sc->bnx_dmatag, sc->stats_map, 0, BNX_STATS_BLK_SZ,
5671 BUS_DMASYNC_POSTREAD); 5671 BUS_DMASYNC_POSTREAD);
5672 5672
5673 stats = (struct statistics_block *)sc->stats_block; 5673 stats = (struct statistics_block *)sc->stats_block;
5674 5674
5675 net_stat_ref_t nsr = IF_STAT_GETREF(ifp); 5675 net_stat_ref_t nsr = IF_STAT_GETREF(ifp);
5676 uint64_t value; 5676 uint64_t value;
5677 5677
5678 /* 5678 /*
5679 * Update the interface statistics from the 5679 * Update the interface statistics from the
5680 * hardware statistics. 5680 * hardware statistics.
5681 */ 5681 */
5682 value = (u_long)stats->stat_EtherStatsCollisions; 5682 value = (u_long)stats->stat_EtherStatsCollisions;
5683 if_statadd_ref(nsr, if_collisions, value - sc->if_stat_collisions); 5683 if_statadd_ref(nsr, if_collisions, value - sc->if_stat_collisions);
@@ -6247,27 +6247,27 @@ bnx_dump_status_block(struct bnx_softc * @@ -6247,27 +6247,27 @@ bnx_dump_status_block(struct bnx_softc *
6247 sblk->status_cmd_consumer_index); 6247 sblk->status_cmd_consumer_index);
6248 6248
6249 device_printf(sc->bnx_dev, "-------------------------------------------" 6249 device_printf(sc->bnx_dev, "-------------------------------------------"
6250 "-----------------------------\n"); 6250 "-----------------------------\n");
6251} 6251}
6252 6252
6253/* 6253/*
6254 * This routine prints the statistics block. 6254 * This routine prints the statistics block.
6255 */ 6255 */
6256void 6256void
6257bnx_dump_stats_block(struct bnx_softc *sc) 6257bnx_dump_stats_block(struct bnx_softc *sc)
6258{ 6258{
6259 struct statistics_block *sblk; 6259 struct statistics_block *sblk;
6260 bus_dmamap_sync(sc->bnx_dmatag, sc->status_map, 0, BNX_STATUS_BLK_SZ, 6260 bus_dmamap_sync(sc->bnx_dmatag, sc->stats_map, 0, BNX_STATS_BLK_SZ,
6261 BUS_DMASYNC_POSTREAD); 6261 BUS_DMASYNC_POSTREAD);
6262 6262
6263 sblk = sc->stats_block; 6263 sblk = sc->stats_block;
6264 6264
6265 device_printf(sc->bnx_dev, "" 6265 device_printf(sc->bnx_dev, ""
6266 "-----------------------------" 6266 "-----------------------------"
6267 " Stats Block " 6267 " Stats Block "
6268 "-----------------------------\n"); 6268 "-----------------------------\n");
6269 6269
6270 BNX_PRINTF(sc, "IfHcInOctets = 0x%08X:%08X, " 6270 BNX_PRINTF(sc, "IfHcInOctets = 0x%08X:%08X, "
6271 "IfHcInBadOctets = 0x%08X:%08X\n", 6271 "IfHcInBadOctets = 0x%08X:%08X\n",
6272 sblk->stat_IfHCInOctets_hi, sblk->stat_IfHCInOctets_lo, 6272 sblk->stat_IfHCInOctets_hi, sblk->stat_IfHCInOctets_lo,
6273 sblk->stat_IfHCInBadOctets_hi, sblk->stat_IfHCInBadOctets_lo); 6273 sblk->stat_IfHCInBadOctets_hi, sblk->stat_IfHCInBadOctets_lo);