diff options
| author | Giuseppe CAVALLARO <peppe.cavallaro@st.com> | 2011-10-17 20:01:23 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2011-10-19 19:24:17 -0400 |
| commit | 38fe7a93fc734357c4811f1c710b1906a87d315c (patch) | |
| tree | 3b3fff1fcbbf9f39cb766ba004290976c99b0912 /drivers/net/ethernet/stmicro/stmmac | |
| parent | 1db123fbe974f9b5eeb6a7083d7430e99fbd9ac1 (diff) | |
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>
Diffstat (limited to 'drivers/net/ethernet/stmicro/stmmac')
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | 24 | ||||
| -rw-r--r-- | drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 |
2 files changed, 16 insertions, 11 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c index aedff9a90ebc..406404f6e321 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ethtool.c | |||
| @@ -96,7 +96,7 @@ static const struct stmmac_stats stmmac_gstrings_stats[] = { | |||
| 96 | { #m, FIELD_SIZEOF(struct stmmac_counters, m), \ | 96 | { #m, FIELD_SIZEOF(struct stmmac_counters, m), \ |
| 97 | offsetof(struct stmmac_priv, mmc.m)} | 97 | offsetof(struct stmmac_priv, mmc.m)} |
| 98 | 98 | ||
| 99 | static const struct stmmac_stats stmmac_gstr_mmc[] = { | 99 | static const struct stmmac_stats stmmac_mmc[] = { |
| 100 | STMMAC_MMC_STAT(mmc_tx_octetcount_gb), | 100 | STMMAC_MMC_STAT(mmc_tx_octetcount_gb), |
| 101 | STMMAC_MMC_STAT(mmc_tx_framecount_gb), | 101 | STMMAC_MMC_STAT(mmc_tx_framecount_gb), |
| 102 | STMMAC_MMC_STAT(mmc_tx_broadcastframe_g), | 102 | STMMAC_MMC_STAT(mmc_tx_broadcastframe_g), |
| @@ -177,7 +177,7 @@ static const struct stmmac_stats stmmac_gstr_mmc[] = { | |||
| 177 | STMMAC_MMC_STAT(mmc_rx_icmp_gd_octets), | 177 | STMMAC_MMC_STAT(mmc_rx_icmp_gd_octets), |
| 178 | STMMAC_MMC_STAT(mmc_rx_icmp_err_octets), | 178 | STMMAC_MMC_STAT(mmc_rx_icmp_err_octets), |
| 179 | }; | 179 | }; |
| 180 | #define STMMAC_MMC_STATS_LEN ARRAY_SIZE(stmmac_gstr_mmc) | 180 | #define STMMAC_MMC_STATS_LEN ARRAY_SIZE(stmmac_mmc) |
| 181 | 181 | ||
| 182 | static void stmmac_ethtool_getdrvinfo(struct net_device *dev, | 182 | static void stmmac_ethtool_getdrvinfo(struct net_device *dev, |
| 183 | struct ethtool_drvinfo *info) | 183 | struct ethtool_drvinfo *info) |
| @@ -348,13 +348,17 @@ static void stmmac_get_ethtool_stats(struct net_device *dev, | |||
| 348 | priv->ioaddr); | 348 | priv->ioaddr); |
| 349 | else { | 349 | else { |
| 350 | /* If supported, for new GMAC chips expose the MMC counters */ | 350 | /* 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); | ||
| 352 | 353 | ||
| 353 | for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) { | 354 | for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) { |
| 354 | char *p = (char *)priv + stmmac_gstr_mmc[i].stat_offset; | 355 | char *p; |
| 356 | p = (char *)priv + stmmac_mmc[i].stat_offset; | ||
| 355 | 357 | ||
| 356 | data[j++] = (stmmac_gstr_mmc[i].sizeof_stat == | 358 | data[j++] = (stmmac_mmc[i].sizeof_stat == |
| 357 | sizeof(u64)) ? (*(u64 *)p) : (*(u32 *)p); | 359 | sizeof(u64)) ? (*(u64 *)p) : |
| 360 | (*(u32 *)p); | ||
| 361 | } | ||
| 358 | } | 362 | } |
| 359 | } | 363 | } |
| 360 | for (i = 0; i < STMMAC_STATS_LEN; i++) { | 364 | for (i = 0; i < STMMAC_STATS_LEN; i++) { |
| @@ -373,7 +377,7 @@ static int stmmac_get_sset_count(struct net_device *netdev, int sset) | |||
| 373 | case ETH_SS_STATS: | 377 | case ETH_SS_STATS: |
| 374 | len = STMMAC_STATS_LEN; | 378 | len = STMMAC_STATS_LEN; |
| 375 | 379 | ||
| 376 | if (priv->plat->has_gmac) | 380 | if (priv->dma_cap.rmon) |
| 377 | len += STMMAC_MMC_STATS_LEN; | 381 | len += STMMAC_MMC_STATS_LEN; |
| 378 | 382 | ||
| 379 | return len; | 383 | return len; |
| @@ -390,9 +394,9 @@ static void stmmac_get_strings(struct net_device *dev, u32 stringset, u8 *data) | |||
| 390 | 394 | ||
| 391 | switch (stringset) { | 395 | switch (stringset) { |
| 392 | case ETH_SS_STATS: | 396 | case ETH_SS_STATS: |
| 393 | if (priv->plat->has_gmac) | 397 | if (priv->dma_cap.rmon) |
| 394 | for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) { | 398 | 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, |
| 396 | ETH_GSTRING_LEN); | 400 | ETH_GSTRING_LEN); |
| 397 | p += ETH_GSTRING_LEN; | 401 | p += ETH_GSTRING_LEN; |
| 398 | } | 402 | } |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index c88dc358f9b0..bf895cb75785 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | |||
| @@ -946,7 +946,8 @@ static int stmmac_open(struct net_device *dev) | |||
| 946 | memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats)); | 946 | memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats)); |
| 947 | priv->xstats.threshold = tc; | 947 | priv->xstats.threshold = tc; |
| 948 | 948 | ||
| 949 | stmmac_mmc_setup(priv); | 949 | if (priv->dma_cap.rmon) |
| 950 | stmmac_mmc_setup(priv); | ||
| 950 | 951 | ||
| 951 | /* Start the ball rolling... */ | 952 | /* Start the ball rolling... */ |
| 952 | DBG(probe, DEBUG, "%s: DMA RX/TX processes started...\n", dev->name); | 953 | DBG(probe, DEBUG, "%s: DMA RX/TX processes started...\n", dev->name); |
