26 #include <linux/ethtool.h>
28 #include <linux/mii.h>
35 #define REG_SPACE_SIZE 0x1054
36 #define MAC100_ETHTOOL_NAME "st_mac100"
37 #define GMAC_ETHTOOL_NAME "st_gmac"
45 #define STMMAC_STAT(m) \
46 { #m, FIELD_SIZEOF(struct stmmac_extra_stats, m), \
47 offsetof(struct stmmac_priv, xstats.m)}
49 static const struct stmmac_stats stmmac_gstrings_stats[] = {
107 #define STMMAC_STATS_LEN ARRAY_SIZE(stmmac_gstrings_stats)
110 #define STMMAC_MMC_STAT(m) \
111 { #m, FIELD_SIZEOF(struct stmmac_counters, m), \
112 offsetof(struct stmmac_priv, mmc.m)}
195 #define STMMAC_MMC_STATS_LEN ARRAY_SIZE(stmmac_mmc)
197 static void stmmac_ethtool_getdrvinfo(
struct net_device *
dev,
202 if (priv->
plat->has_gmac)
212 static int stmmac_ethtool_getsettings(
struct net_device *
dev,
219 pr_err(
"%s: %s: PHY is not registered\n",
220 __func__, dev->
name);
223 if (!netif_running(dev)) {
224 pr_err(
"%s: interface is disabled: we cannot track "
225 "link speed / duplex setting\n", dev->
name);
229 spin_lock_irq(&priv->
lock);
231 spin_unlock_irq(&priv->
lock);
235 static int stmmac_ethtool_setsettings(
struct net_device *dev,
242 spin_lock(&priv->
lock);
244 spin_unlock(&priv->
lock);
249 static u32 stmmac_ethtool_getmsglevel(
struct net_device *dev)
262 static int stmmac_check_if_running(
struct net_device *dev)
264 if (!netif_running(dev))
269 static int stmmac_ethtool_get_regs_len(
struct net_device *dev)
274 static void stmmac_ethtool_gregs(
struct net_device *dev,
278 u32 *reg_space = (
u32 *) space;
284 if (!priv->
plat->has_gmac) {
286 for (i = 0; i < 12; i++)
289 for (i = 0; i < 9; i++)
296 for (i = 0; i < 55; i++)
299 for (i = 0; i < 22; i++)
306 stmmac_get_pauseparam(
struct net_device *netdev,
311 spin_lock(&priv->
lock);
322 spin_unlock(&priv->
lock);
326 stmmac_set_pauseparam(
struct net_device *netdev,
334 spin_lock(&priv->
lock);
345 if (netif_running(netdev))
350 spin_unlock(&priv->
lock);
354 static void stmmac_get_ethtool_stats(
struct net_device *dev,
361 if (!priv->
plat->has_gmac)
362 priv->
hw->dma->dma_diagnostic_fr(&dev->
stats,
372 p = (
char *)priv + stmmac_mmc[i].stat_offset;
375 sizeof(
u64)) ? (*(
u64 *)p) :
382 priv->
xstats.phy_eee_wakeup_error_n =
val;
386 char *
p = (
char *)priv + stmmac_gstrings_stats[i].stat_offset;
388 sizeof(
u64)) ? (*(
u64 *)p) : (*(
u32 *)p);
392 static int stmmac_get_sset_count(
struct net_device *netdev,
int sset)
410 static void stmmac_get_strings(
struct net_device *dev,
u32 stringset,
u8 *data)
420 memcpy(p, stmmac_mmc[i].stat_string,
425 memcpy(p, stmmac_gstrings_stats[i].stat_string,
441 spin_lock_irq(&priv->
lock);
442 if (device_can_wakeup(priv->
device)) {
446 spin_unlock_irq(&priv->
lock);
460 if (!device_can_wakeup(priv->
device))
467 pr_info(
"stmmac: wakeup enable\n");
469 enable_irq_wake(priv->
wol_irq);
472 disable_irq_wake(priv->
wol_irq);
475 spin_lock_irq(&priv->
lock);
477 spin_unlock_irq(&priv->
lock);
482 static int stmmac_ethtool_op_get_eee(
struct net_device *dev,
497 static int stmmac_ethtool_op_set_eee(
struct net_device *dev,
522 static const struct ethtool_ops stmmac_ethtool_ops = {
523 .begin = stmmac_check_if_running,
524 .get_drvinfo = stmmac_ethtool_getdrvinfo,
525 .get_settings = stmmac_ethtool_getsettings,
526 .set_settings = stmmac_ethtool_setsettings,
527 .get_msglevel = stmmac_ethtool_getmsglevel,
528 .set_msglevel = stmmac_ethtool_setmsglevel,
529 .get_regs = stmmac_ethtool_gregs,
530 .get_regs_len = stmmac_ethtool_get_regs_len,
532 .get_pauseparam = stmmac_get_pauseparam,
533 .set_pauseparam = stmmac_set_pauseparam,
534 .get_ethtool_stats = stmmac_get_ethtool_stats,
535 .get_strings = stmmac_get_strings,
536 .get_wol = stmmac_get_wol,
537 .set_wol = stmmac_set_wol,
538 .get_eee = stmmac_ethtool_op_get_eee,
539 .set_eee = stmmac_ethtool_op_set_eee,
540 .get_sset_count = stmmac_get_sset_count,