ar71xx/all0258n: fix partition layout
[openwrt.git] / target / linux / ar71xx / files / drivers / net / ag71xx / ag71xx_ethtool.c
1 /*
2 * Atheros AR71xx built-in ethernet mac driver
3 *
4 * Copyright (C) 2008-2010 Gabor Juhos <juhosg@openwrt.org>
5 * Copyright (C) 2008 Imre Kaloz <kaloz@openwrt.org>
6 *
7 * Based on Atheros' AG7100 driver
8 *
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.
12 */
13
14 #include "ag71xx.h"
15
16 static int ag71xx_ethtool_get_settings(struct net_device *dev,
17 struct ethtool_cmd *cmd)
18 {
19 struct ag71xx *ag = netdev_priv(dev);
20 struct phy_device *phydev = ag->phy_dev;
21
22 if (!phydev)
23 return -ENODEV;
24
25 return phy_ethtool_gset(phydev, cmd);
26 }
27
28 static int ag71xx_ethtool_set_settings(struct net_device *dev,
29 struct ethtool_cmd *cmd)
30 {
31 struct ag71xx *ag = netdev_priv(dev);
32 struct phy_device *phydev = ag->phy_dev;
33
34 if (!phydev)
35 return -ENODEV;
36
37 return phy_ethtool_sset(phydev, cmd);
38 }
39
40 static void ag71xx_ethtool_get_drvinfo(struct net_device *dev,
41 struct ethtool_drvinfo *info)
42 {
43 struct ag71xx *ag = netdev_priv(dev);
44
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));
48 }
49
50 static u32 ag71xx_ethtool_get_msglevel(struct net_device *dev)
51 {
52 struct ag71xx *ag = netdev_priv(dev);
53
54 return ag->msg_enable;
55 }
56
57 static void ag71xx_ethtool_set_msglevel(struct net_device *dev, u32 msg_level)
58 {
59 struct ag71xx *ag = netdev_priv(dev);
60
61 ag->msg_enable = msg_level;
62 }
63
64 static void ag71xx_ethtool_get_ringparam(struct net_device *dev,
65 struct ethtool_ringparam *er)
66 {
67 struct ag71xx *ag = netdev_priv(dev);
68
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;
73
74 er->tx_pending = ag->tx_ring.size;
75 er->rx_pending = ag->rx_ring.size;
76 er->rx_mini_pending = 0;
77 er->rx_jumbo_pending = 0;
78 }
79
80 static int ag71xx_ethtool_set_ringparam(struct net_device *dev,
81 struct ethtool_ringparam *er)
82 {
83 struct ag71xx *ag = netdev_priv(dev);
84 unsigned tx_size;
85 unsigned rx_size;
86 int err;
87
88 if (er->rx_mini_pending != 0||
89 er->rx_jumbo_pending != 0 ||
90 er->rx_pending == 0 ||
91 er->tx_pending == 0)
92 return -EINVAL;
93
94 tx_size = er->tx_pending < AG71XX_TX_RING_SIZE_MAX ?
95 er->tx_pending : AG71XX_TX_RING_SIZE_MAX;
96
97 rx_size = er->rx_pending < AG71XX_RX_RING_SIZE_MAX ?
98 er->rx_pending : AG71XX_RX_RING_SIZE_MAX;
99
100 if (netif_running(dev)) {
101 err = dev->netdev_ops->ndo_stop(dev);
102 if (err)
103 return err;
104 }
105
106 ag->tx_ring.size = tx_size;
107 ag->rx_ring.size = rx_size;
108
109 if (netif_running(dev))
110 err = dev->netdev_ops->ndo_open(dev);
111
112 return err;
113 }
114
115 struct ethtool_ops ag71xx_ethtool_ops = {
116 .set_settings = ag71xx_ethtool_set_settings,
117 .get_settings = ag71xx_ethtool_get_settings,
118 .get_drvinfo = ag71xx_ethtool_get_drvinfo,
119 .get_msglevel = ag71xx_ethtool_get_msglevel,
120 .set_msglevel = ag71xx_ethtool_set_msglevel,
121 .get_ringparam = ag71xx_ethtool_get_ringparam,
122 .set_ringparam = ag71xx_ethtool_set_ringparam,
123 .get_link = ethtool_op_get_link,
124 };
This page took 0.06035 seconds and 5 git commands to generate.