Skip to content

Commit 38fe7a9

Browse files
cavagiudavem330
authored andcommitted
stmmac: allow mmc usage only if feature actually available (V4)
Enable the MMC support if it is actually available from the HW capability register. Signed-off-by: Rayagond Kokatanur <rayagond@vayavyalabs.com> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 1db123f commit 38fe7a9

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ static const struct stmmac_stats stmmac_gstrings_stats[] = {
9696
{ #m, FIELD_SIZEOF(struct stmmac_counters, m), \
9797
offsetof(struct stmmac_priv, mmc.m)}
9898

99-
static const struct stmmac_stats stmmac_gstr_mmc[] = {
99+
static const struct stmmac_stats stmmac_mmc[] = {
100100
STMMAC_MMC_STAT(mmc_tx_octetcount_gb),
101101
STMMAC_MMC_STAT(mmc_tx_framecount_gb),
102102
STMMAC_MMC_STAT(mmc_tx_broadcastframe_g),
@@ -177,7 +177,7 @@ static const struct stmmac_stats stmmac_gstr_mmc[] = {
177177
STMMAC_MMC_STAT(mmc_rx_icmp_gd_octets),
178178
STMMAC_MMC_STAT(mmc_rx_icmp_err_octets),
179179
};
180-
#define STMMAC_MMC_STATS_LEN ARRAY_SIZE(stmmac_gstr_mmc)
180+
#define STMMAC_MMC_STATS_LEN ARRAY_SIZE(stmmac_mmc)
181181

182182
static void stmmac_ethtool_getdrvinfo(struct net_device *dev,
183183
struct ethtool_drvinfo *info)
@@ -348,13 +348,17 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,
348348
priv->ioaddr);
349349
else {
350350
/* If supported, for new GMAC chips expose the MMC counters */
351-
dwmac_mmc_read(priv->ioaddr, &priv->mmc);
351+
if (priv->dma_cap.rmon) {
352+
dwmac_mmc_read(priv->ioaddr, &priv->mmc);
352353

353-
for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) {
354-
char *p = (char *)priv + stmmac_gstr_mmc[i].stat_offset;
354+
for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) {
355+
char *p;
356+
p = (char *)priv + stmmac_mmc[i].stat_offset;
355357

356-
data[j++] = (stmmac_gstr_mmc[i].sizeof_stat ==
357-
sizeof(u64)) ? (*(u64 *)p) : (*(u32 *)p);
358+
data[j++] = (stmmac_mmc[i].sizeof_stat ==
359+
sizeof(u64)) ? (*(u64 *)p) :
360+
(*(u32 *)p);
361+
}
358362
}
359363
}
360364
for (i = 0; i < STMMAC_STATS_LEN; i++) {
@@ -373,7 +377,7 @@ static int stmmac_get_sset_count(struct net_device *netdev, int sset)
373377
case ETH_SS_STATS:
374378
len = STMMAC_STATS_LEN;
375379

376-
if (priv->plat->has_gmac)
380+
if (priv->dma_cap.rmon)
377381
len += STMMAC_MMC_STATS_LEN;
378382

379383
return len;
@@ -390,9 +394,9 @@ static void stmmac_get_strings(struct net_device *dev, u32 stringset, u8 *data)
390394

391395
switch (stringset) {
392396
case ETH_SS_STATS:
393-
if (priv->plat->has_gmac)
397+
if (priv->dma_cap.rmon)
394398
for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) {
395-
memcpy(p, stmmac_gstr_mmc[i].stat_string,
399+
memcpy(p, stmmac_mmc[i].stat_string,
396400
ETH_GSTRING_LEN);
397401
p += ETH_GSTRING_LEN;
398402
}

drivers/net/ethernet/stmicro/stmmac/stmmac_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -946,7 +946,8 @@ static int stmmac_open(struct net_device *dev)
946946
memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
947947
priv->xstats.threshold = tc;
948948

949-
stmmac_mmc_setup(priv);
949+
if (priv->dma_cap.rmon)
950+
stmmac_mmc_setup(priv);
950951

951952
/* Start the ball rolling... */
952953
DBG(probe, DEBUG, "%s: DMA RX/TX processes started...\n", dev->name);

0 commit comments

Comments
 (0)