Author: arybchik
Date: Tue Nov 27 14:16:14 2018
New Revision: 341066
URL: https://svnweb.freebsd.org/changeset/base/341066

Log:
  sfxge(4): remove MAC stats size define
  
  Submitted by:   Andy Moreton <amoreton at solarflare.com>
  Sponsored by:   Solarflare Communications, Inc.
  Differential Revision:  https://reviews.freebsd.org/D18180

Modified:
  head/sys/dev/sfxge/common/efx.h
  head/sys/dev/sfxge/common/siena_mac.c
  head/sys/dev/sfxge/sfxge_port.c

Modified: head/sys/dev/sfxge/common/efx.h
==============================================================================
--- head/sys/dev/sfxge/common/efx.h     Tue Nov 27 14:16:03 2018        
(r341065)
+++ head/sys/dev/sfxge/common/efx.h     Tue Nov 27 14:16:14 2018        
(r341066)
@@ -589,7 +589,6 @@ efx_mac_stats_get_mask(
        ((_mask)[(_stat) / EFX_MAC_STATS_MASK_BITS_PER_PAGE] &  \
            (1ULL << ((_stat) & (EFX_MAC_STATS_MASK_BITS_PER_PAGE - 1))))
 
-#define        EFX_MAC_STATS_SIZE 0x400
 
 extern __checkReturn                   efx_rc_t
 efx_mac_stats_clear(
@@ -598,8 +597,8 @@ efx_mac_stats_clear(
 /*
  * Upload mac statistics supported by the hardware into the given buffer.
  *
- * The reference buffer must be at least %EFX_MAC_STATS_SIZE bytes,
- * and page aligned.
+ * The DMA buffer must be 4Kbyte aligned and sized to hold at least
+ * efx_nic_cfg_t::enc_mac_stats_nstats 64bit counters.
  *
  * The hardware will only DMA statistics that it understands (of course).
  * Drivers should not make any assumptions about which statistics are

Modified: head/sys/dev/sfxge/common/siena_mac.c
==============================================================================
--- head/sys/dev/sfxge/common/siena_mac.c       Tue Nov 27 14:16:03 2018        
(r341065)
+++ head/sys/dev/sfxge/common/siena_mac.c       Tue Nov 27 14:16:14 2018        
(r341066)
@@ -463,7 +463,7 @@ siena_mac_stats_update(
        SIENA_MAC_STAT_READ(esmp, MC_CMD_MAC_RX_NODESC_DROPS, &value);
        EFSYS_STAT_SET_QWORD(&(stat[EFX_MAC_RX_NODESC_DROP_CNT]), &value);
 
-       EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFX_MAC_STATS_SIZE);
+       EFSYS_DMA_SYNC_FOR_KERNEL(esmp, 0, EFSYS_MEM_SIZE(esmp));
        EFSYS_MEM_READ_BARRIER();
        SIENA_MAC_STAT_READ(esmp, MC_CMD_MAC_GENERATION_START,
                            &generation_start);

Modified: head/sys/dev/sfxge/sfxge_port.c
==============================================================================
--- head/sys/dev/sfxge/sfxge_port.c     Tue Nov 27 14:16:03 2018        
(r341065)
+++ head/sys/dev/sfxge/sfxge_port.c     Tue Nov 27 14:16:14 2018        
(r341066)
@@ -753,6 +753,8 @@ sfxge_port_init(struct sfxge_softc *sc)
        struct sysctl_ctx_list *sysctl_ctx;
        struct sysctl_oid *sysctl_tree;
        efsys_mem_t *mac_stats_buf, *phy_stats_buf;
+       uint32_t mac_nstats;
+       size_t mac_stats_size;
        int rc;
 
        port = &sc->port;
@@ -792,7 +794,9 @@ sfxge_port_init(struct sfxge_softc *sc)
        DBGPRINT(sc->dev, "alloc MAC stats");
        port->mac_stats.decode_buf = malloc(EFX_MAC_NSTATS * sizeof(uint64_t),
                                            M_SFXGE, M_WAITOK | M_ZERO);
-       if ((rc = sfxge_dma_alloc(sc, EFX_MAC_STATS_SIZE, mac_stats_buf)) != 0)
+       mac_nstats = efx_nic_cfg_get(sc->enp)->enc_mac_stats_nstats;
+       mac_stats_size = P2ROUNDUP(mac_nstats * sizeof(uint64_t), EFX_BUF_SIZE);
+       if ((rc = sfxge_dma_alloc(sc, mac_stats_size, mac_stats_buf)) != 0)
                goto fail2;
        port->stats_update_period_ms = sfxge_port_stats_update_period_ms(sc);
        sfxge_mac_stat_init(sc);
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to