2 * Atheros AR71xx built-in ethernet mac driver
4 * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
7 * Based on Atheros' AG7100 driver
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License version 2 as published
11 * by the Free Software Foundation.
16 static int ag71xx_ethtool_get_settings(struct net_device *dev,
17 struct ethtool_cmd *cmd)
19 struct ag71xx *ag = netdev_priv(dev);
20 struct phy_device *phydev = ag->phy_dev;
25 return phy_ethtool_gset(phydev, cmd);
28 static int ag71xx_ethtool_set_settings(struct net_device *dev,
29 struct ethtool_cmd *cmd)
31 struct ag71xx *ag = netdev_priv(dev);
32 struct phy_device *phydev = ag->phy_dev;
37 return phy_ethtool_sset(phydev, cmd);
40 static void ag71xx_ethtool_get_drvinfo(struct net_device *dev,
41 struct ethtool_drvinfo *info)
43 struct ag71xx *ag = netdev_priv(dev);
45 strcpy(info->driver, ag->pdev->dev.driver->name);
46 strcpy(info->version, AG71XX_DRV_VERSION);
47 strcpy(info->bus_info, dev_name(&ag->pdev->dev));
50 static u32 ag71xx_ethtool_get_msglevel(struct net_device *dev)
52 struct ag71xx *ag = netdev_priv(dev);
54 return ag->msg_enable;
57 static void ag71xx_ethtool_set_msglevel(struct net_device *dev, u32 msg_level)
59 struct ag71xx *ag = netdev_priv(dev);
61 ag->msg_enable = msg_level;
64 static void ag71xx_ethtool_get_ringparam(struct net_device *dev,
65 struct ethtool_ringparam *er)
67 struct ag71xx *ag = netdev_priv(dev);
69 er->tx_max_pending = AG71XX_TX_RING_SIZE_MAX;
70 er->rx_max_pending = AG71XX_RX_RING_SIZE_MAX;
71 er->rx_mini_max_pending = 0;
72 er->rx_jumbo_max_pending = 0;
74 er->tx_pending = BIT(ag->tx_ring.order);
75 er->rx_pending = BIT(ag->rx_ring.order);
76 er->rx_mini_pending = 0;
77 er->rx_jumbo_pending = 0;
79 if (ag->tx_ring.desc_split)
80 er->tx_pending /= AG71XX_TX_RING_DS_PER_PKT;
83 static int ag71xx_ethtool_set_ringparam(struct net_device *dev,
84 struct ethtool_ringparam *er)
86 struct ag71xx *ag = netdev_priv(dev);
91 if (er->rx_mini_pending != 0||
92 er->rx_jumbo_pending != 0 ||
93 er->rx_pending == 0 ||
97 tx_size = er->tx_pending < AG71XX_TX_RING_SIZE_MAX ?
98 er->tx_pending : AG71XX_TX_RING_SIZE_MAX;
100 rx_size = er->rx_pending < AG71XX_RX_RING_SIZE_MAX ?
101 er->rx_pending : AG71XX_RX_RING_SIZE_MAX;
103 if (netif_running(dev)) {
104 err = dev->netdev_ops->ndo_stop(dev);
109 if (ag->tx_ring.desc_split)
110 tx_size *= AG71XX_TX_RING_DS_PER_PKT;
112 ag->tx_ring.order = ag71xx_ring_size_order(tx_size);
113 ag->rx_ring.order = ag71xx_ring_size_order(rx_size);
115 if (netif_running(dev))
116 err = dev->netdev_ops->ndo_open(dev);
121 struct ethtool_ops ag71xx_ethtool_ops = {
122 .set_settings = ag71xx_ethtool_set_settings,
123 .get_settings = ag71xx_ethtool_get_settings,
124 .get_drvinfo = ag71xx_ethtool_get_drvinfo,
125 .get_msglevel = ag71xx_ethtool_get_msglevel,
126 .set_msglevel = ag71xx_ethtool_set_msglevel,
127 .get_ringparam = ag71xx_ethtool_get_ringparam,
128 .set_ringparam = ag71xx_ethtool_set_ringparam,
129 .get_link = ethtool_op_get_link,