Date: Tue, 27 Nov 2018 14:15:08 +0000 (UTC) From: Andrew Rybchenko <arybchik@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r341060 - head/sys/dev/sfxge/common Message-ID: <201811271415.wAREF8r3060911@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: arybchik Date: Tue Nov 27 14:15:08 2018 New Revision: 341060 URL: https://svnweb.freebsd.org/changeset/base/341060 Log: sfxge(4): improve robustness of MAC stats get via MCDI Previously the code relied on the callers of efx_mcdi_mac_stats to provide a DMA buffer or NULL depending on the action. Fix this so that the DMA buffer is only passed in the request when needed, and that an error is reported for a missing DMA buffer. Submitted by: Andy Moreton <amoreton at solarflare.com> Sponsored by: Solarflare Communications, Inc. Differential Revision: https://reviews.freebsd.org/D18174 Modified: head/sys/dev/sfxge/common/efx_mcdi.c Modified: head/sys/dev/sfxge/common/efx_mcdi.c ============================================================================== --- head/sys/dev/sfxge/common/efx_mcdi.c Tue Nov 27 14:14:57 2018 (r341059) +++ head/sys/dev/sfxge/common/efx_mcdi.c Tue Nov 27 14:15:08 2018 (r341060) @@ -1843,9 +1843,15 @@ efx_mcdi_mac_stats( MAC_STATS_IN_PERIODIC_NOEVENT, !events, MAC_STATS_IN_PERIOD_MS, (enable | events) ? period_ms : 0); - if (esmp != NULL) { + if (enable || events || upload) { uint32_t bytes = MC_CMD_MAC_NSTATS * sizeof (uint64_t); + /* Periodic stats or stats upload require a DMA buffer */ + if (esmp == NULL) { + rc = EINVAL; + goto fail1; + } + EFX_STATIC_ASSERT(MC_CMD_MAC_NSTATS * sizeof (uint64_t) <= EFX_MAC_STATS_SIZE); @@ -1856,8 +1862,6 @@ efx_mcdi_mac_stats( MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_ADDR_HI, EFSYS_MEM_ADDR(esmp) >> 32); MCDI_IN_SET_DWORD(req, MAC_STATS_IN_DMA_LEN, bytes); - } else { - EFSYS_ASSERT(!upload && !enable && !events); } /* @@ -1875,12 +1879,14 @@ efx_mcdi_mac_stats( if ((req.emr_rc != ENOENT) || (enp->en_rx_qcount + enp->en_tx_qcount != 0)) { rc = req.emr_rc; - goto fail1; + goto fail2; } } return (0); +fail2: + EFSYS_PROBE(fail2); fail1: EFSYS_PROBE1(fail1, efx_rc_t, rc);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811271415.wAREF8r3060911>