Thomas Gleixner | 2874c5f | 2019-05-27 08:55:01 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2007 Freescale Semiconductor, Inc. All rights reserved. |
| 4 | * |
| 5 | * Description: QE UCC Gigabit Ethernet Ethtool API Set |
| 6 | * |
| 7 | * Author: Li Yang <leoli@freescale.com> |
| 8 | * |
Jeff Garzik | 7d2e3cb | 2008-05-13 01:41:58 -0400 | [diff] [blame] | 9 | * Limitation: |
Justin P. Mattock | 70f23fd | 2011-05-10 10:16:21 +0200 | [diff] [blame] | 10 | * Can only get/set settings of the first queue. |
Martin Olsson | 98a1708 | 2009-04-22 18:21:29 +0200 | [diff] [blame] | 11 | * Need to re-open the interface manually after changing some parameters. |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 12 | */ |
| 13 | |
| 14 | #include <linux/kernel.h> |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 15 | #include <linux/errno.h> |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 16 | #include <linux/stddef.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/netdevice.h> |
| 19 | #include <linux/etherdevice.h> |
| 20 | #include <linux/skbuff.h> |
| 21 | #include <linux/spinlock.h> |
| 22 | #include <linux/mm.h> |
| 23 | #include <linux/delay.h> |
| 24 | #include <linux/dma-mapping.h> |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 25 | #include <linux/ethtool.h> |
| 26 | #include <linux/mii.h> |
| 27 | #include <linux/phy.h> |
| 28 | |
| 29 | #include <asm/io.h> |
| 30 | #include <asm/irq.h> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 31 | #include <linux/uaccess.h> |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 32 | #include <asm/types.h> |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 33 | |
| 34 | #include "ucc_geth.h" |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 35 | |
Joe Perches | c84d805 | 2013-04-13 19:03:19 +0000 | [diff] [blame] | 36 | static const char hw_stat_gstrings[][ETH_GSTRING_LEN] = { |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 37 | "tx-64-frames", |
| 38 | "tx-65-127-frames", |
| 39 | "tx-128-255-frames", |
| 40 | "rx-64-frames", |
| 41 | "rx-65-127-frames", |
| 42 | "rx-128-255-frames", |
| 43 | "tx-bytes-ok", |
| 44 | "tx-pause-frames", |
| 45 | "tx-multicast-frames", |
| 46 | "tx-broadcast-frames", |
| 47 | "rx-frames", |
| 48 | "rx-bytes-ok", |
| 49 | "rx-bytes-all", |
| 50 | "rx-multicast-frames", |
| 51 | "rx-broadcast-frames", |
| 52 | "stats-counter-carry", |
| 53 | "stats-counter-mask", |
| 54 | "rx-dropped-frames", |
| 55 | }; |
| 56 | |
Joe Perches | c84d805 | 2013-04-13 19:03:19 +0000 | [diff] [blame] | 57 | static const char tx_fw_stat_gstrings[][ETH_GSTRING_LEN] = { |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 58 | "tx-single-collision", |
| 59 | "tx-multiple-collision", |
Colin Ian King | f944ad1 | 2018-04-28 10:57:07 +0100 | [diff] [blame] | 60 | "tx-late-collision", |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 61 | "tx-aborted-frames", |
| 62 | "tx-lost-frames", |
| 63 | "tx-carrier-sense-errors", |
| 64 | "tx-frames-ok", |
| 65 | "tx-excessive-differ-frames", |
| 66 | "tx-256-511-frames", |
Li Yang | 08722bc | 2008-05-23 18:11:27 +0800 | [diff] [blame] | 67 | "tx-512-1023-frames", |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 68 | "tx-1024-1518-frames", |
| 69 | "tx-jumbo-frames", |
| 70 | }; |
| 71 | |
Joe Perches | c84d805 | 2013-04-13 19:03:19 +0000 | [diff] [blame] | 72 | static const char rx_fw_stat_gstrings[][ETH_GSTRING_LEN] = { |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 73 | "rx-crc-errors", |
| 74 | "rx-alignment-errors", |
| 75 | "rx-in-range-length-errors", |
| 76 | "rx-out-of-range-length-errors", |
| 77 | "rx-too-long-frames", |
| 78 | "rx-runt", |
| 79 | "rx-very-long-event", |
| 80 | "rx-symbol-errors", |
| 81 | "rx-busy-drop-frames", |
| 82 | "reserved", |
| 83 | "reserved", |
| 84 | "rx-mismatch-drop-frames", |
| 85 | "rx-small-than-64", |
| 86 | "rx-256-511-frames", |
| 87 | "rx-512-1023-frames", |
| 88 | "rx-1024-1518-frames", |
| 89 | "rx-jumbo-frames", |
| 90 | "rx-mac-error-loss", |
| 91 | "rx-pause-frames", |
| 92 | "reserved", |
| 93 | "rx-vlan-removed", |
| 94 | "rx-vlan-replaced", |
| 95 | "rx-vlan-inserted", |
| 96 | "rx-ip-checksum-errors", |
| 97 | }; |
| 98 | |
| 99 | #define UEC_HW_STATS_LEN ARRAY_SIZE(hw_stat_gstrings) |
| 100 | #define UEC_TX_FW_STATS_LEN ARRAY_SIZE(tx_fw_stat_gstrings) |
| 101 | #define UEC_RX_FW_STATS_LEN ARRAY_SIZE(rx_fw_stat_gstrings) |
| 102 | |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 103 | static int |
Philippe Reynes | 5e74bf2d9 | 2016-05-01 17:08:09 +0200 | [diff] [blame] | 104 | uec_get_ksettings(struct net_device *netdev, struct ethtool_link_ksettings *cmd) |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 105 | { |
| 106 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 107 | struct phy_device *phydev = ugeth->phydev; |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 108 | |
| 109 | if (!phydev) |
| 110 | return -ENODEV; |
| 111 | |
yuval.shaia@oracle.com | 5514174 | 2017-06-13 10:09:46 +0300 | [diff] [blame] | 112 | phy_ethtool_ksettings_get(phydev, cmd); |
| 113 | |
| 114 | return 0; |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | static int |
Philippe Reynes | 5e74bf2d9 | 2016-05-01 17:08:09 +0200 | [diff] [blame] | 118 | uec_set_ksettings(struct net_device *netdev, |
| 119 | const struct ethtool_link_ksettings *cmd) |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 120 | { |
| 121 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 122 | struct phy_device *phydev = ugeth->phydev; |
| 123 | |
| 124 | if (!phydev) |
| 125 | return -ENODEV; |
| 126 | |
Philippe Reynes | 5e74bf2d9 | 2016-05-01 17:08:09 +0200 | [diff] [blame] | 127 | return phy_ethtool_ksettings_set(phydev, cmd); |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | static void |
| 131 | uec_get_pauseparam(struct net_device *netdev, |
| 132 | struct ethtool_pauseparam *pause) |
| 133 | { |
| 134 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 135 | |
| 136 | pause->autoneg = ugeth->phydev->autoneg; |
| 137 | |
| 138 | if (ugeth->ug_info->receiveFlowControl) |
| 139 | pause->rx_pause = 1; |
| 140 | if (ugeth->ug_info->transmitFlowControl) |
| 141 | pause->tx_pause = 1; |
| 142 | } |
| 143 | |
| 144 | static int |
| 145 | uec_set_pauseparam(struct net_device *netdev, |
| 146 | struct ethtool_pauseparam *pause) |
| 147 | { |
| 148 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 149 | int ret = 0; |
| 150 | |
| 151 | ugeth->ug_info->receiveFlowControl = pause->rx_pause; |
| 152 | ugeth->ug_info->transmitFlowControl = pause->tx_pause; |
Jeff Garzik | 7d2e3cb | 2008-05-13 01:41:58 -0400 | [diff] [blame] | 153 | |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 154 | if (ugeth->phydev->autoneg) { |
| 155 | if (netif_running(netdev)) { |
| 156 | /* FIXME: automatically restart */ |
Joe Perches | c84d805 | 2013-04-13 19:03:19 +0000 | [diff] [blame] | 157 | netdev_info(netdev, "Please re-open the interface\n"); |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 158 | } |
| 159 | } else { |
| 160 | struct ucc_geth_info *ug_info = ugeth->ug_info; |
| 161 | |
| 162 | ret = init_flow_control_params(ug_info->aufc, |
| 163 | ug_info->receiveFlowControl, |
| 164 | ug_info->transmitFlowControl, |
| 165 | ug_info->pausePeriod, |
| 166 | ug_info->extensionField, |
| 167 | &ugeth->uccf->uf_regs->upsmr, |
| 168 | &ugeth->ug_regs->uempr, |
| 169 | &ugeth->ug_regs->maccfg1); |
| 170 | } |
| 171 | |
| 172 | return ret; |
| 173 | } |
| 174 | |
| 175 | static uint32_t |
| 176 | uec_get_msglevel(struct net_device *netdev) |
| 177 | { |
| 178 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 179 | return ugeth->msg_enable; |
| 180 | } |
| 181 | |
| 182 | static void |
| 183 | uec_set_msglevel(struct net_device *netdev, uint32_t data) |
| 184 | { |
| 185 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 186 | ugeth->msg_enable = data; |
| 187 | } |
| 188 | |
| 189 | static int |
| 190 | uec_get_regs_len(struct net_device *netdev) |
| 191 | { |
| 192 | return sizeof(struct ucc_geth); |
| 193 | } |
| 194 | |
| 195 | static void |
| 196 | uec_get_regs(struct net_device *netdev, |
| 197 | struct ethtool_regs *regs, void *p) |
| 198 | { |
| 199 | int i; |
| 200 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 201 | u32 __iomem *ug_regs = (u32 __iomem *)ugeth->ug_regs; |
| 202 | u32 *buff = p; |
| 203 | |
| 204 | for (i = 0; i < sizeof(struct ucc_geth) / sizeof(u32); i++) |
| 205 | buff[i] = in_be32(&ug_regs[i]); |
| 206 | } |
| 207 | |
| 208 | static void |
| 209 | uec_get_ringparam(struct net_device *netdev, |
| 210 | struct ethtool_ringparam *ring) |
| 211 | { |
| 212 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 213 | struct ucc_geth_info *ug_info = ugeth->ug_info; |
| 214 | int queue = 0; |
| 215 | |
| 216 | ring->rx_max_pending = UCC_GETH_BD_RING_SIZE_MAX; |
| 217 | ring->rx_mini_max_pending = UCC_GETH_BD_RING_SIZE_MAX; |
| 218 | ring->rx_jumbo_max_pending = UCC_GETH_BD_RING_SIZE_MAX; |
| 219 | ring->tx_max_pending = UCC_GETH_BD_RING_SIZE_MAX; |
| 220 | |
| 221 | ring->rx_pending = ug_info->bdRingLenRx[queue]; |
| 222 | ring->rx_mini_pending = ug_info->bdRingLenRx[queue]; |
| 223 | ring->rx_jumbo_pending = ug_info->bdRingLenRx[queue]; |
| 224 | ring->tx_pending = ug_info->bdRingLenTx[queue]; |
| 225 | } |
| 226 | |
| 227 | static int |
| 228 | uec_set_ringparam(struct net_device *netdev, |
| 229 | struct ethtool_ringparam *ring) |
| 230 | { |
| 231 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 232 | struct ucc_geth_info *ug_info = ugeth->ug_info; |
| 233 | int queue = 0, ret = 0; |
| 234 | |
| 235 | if (ring->rx_pending < UCC_GETH_RX_BD_RING_SIZE_MIN) { |
Joe Perches | c84d805 | 2013-04-13 19:03:19 +0000 | [diff] [blame] | 236 | netdev_info(netdev, "RxBD ring size must be no smaller than %d\n", |
| 237 | UCC_GETH_RX_BD_RING_SIZE_MIN); |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 238 | return -EINVAL; |
| 239 | } |
| 240 | if (ring->rx_pending % UCC_GETH_RX_BD_RING_SIZE_ALIGNMENT) { |
Joe Perches | c84d805 | 2013-04-13 19:03:19 +0000 | [diff] [blame] | 241 | netdev_info(netdev, "RxBD ring size must be multiple of %d\n", |
| 242 | UCC_GETH_RX_BD_RING_SIZE_ALIGNMENT); |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 243 | return -EINVAL; |
| 244 | } |
| 245 | if (ring->tx_pending < UCC_GETH_TX_BD_RING_SIZE_MIN) { |
Joe Perches | c84d805 | 2013-04-13 19:03:19 +0000 | [diff] [blame] | 246 | netdev_info(netdev, "TxBD ring size must be no smaller than %d\n", |
| 247 | UCC_GETH_TX_BD_RING_SIZE_MIN); |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 248 | return -EINVAL; |
| 249 | } |
| 250 | |
Christophe Leroy | ee0df19 | 2019-05-03 13:33:23 +0000 | [diff] [blame] | 251 | if (netif_running(netdev)) |
| 252 | return -EBUSY; |
| 253 | |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 254 | ug_info->bdRingLenRx[queue] = ring->rx_pending; |
| 255 | ug_info->bdRingLenTx[queue] = ring->tx_pending; |
| 256 | |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 257 | return ret; |
| 258 | } |
| 259 | |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 260 | static int uec_get_sset_count(struct net_device *netdev, int sset) |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 261 | { |
| 262 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 263 | u32 stats_mode = ugeth->ug_info->statisticsMode; |
| 264 | int len = 0; |
| 265 | |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 266 | switch (sset) { |
| 267 | case ETH_SS_STATS: |
| 268 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) |
| 269 | len += UEC_HW_STATS_LEN; |
| 270 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) |
| 271 | len += UEC_TX_FW_STATS_LEN; |
| 272 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) |
| 273 | len += UEC_RX_FW_STATS_LEN; |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 274 | |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 275 | return len; |
| 276 | |
| 277 | default: |
| 278 | return -EOPNOTSUPP; |
| 279 | } |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | static void uec_get_strings(struct net_device *netdev, u32 stringset, u8 *buf) |
| 283 | { |
| 284 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 285 | u32 stats_mode = ugeth->ug_info->statisticsMode; |
| 286 | |
| 287 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) { |
| 288 | memcpy(buf, hw_stat_gstrings, UEC_HW_STATS_LEN * |
| 289 | ETH_GSTRING_LEN); |
| 290 | buf += UEC_HW_STATS_LEN * ETH_GSTRING_LEN; |
| 291 | } |
| 292 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) { |
| 293 | memcpy(buf, tx_fw_stat_gstrings, UEC_TX_FW_STATS_LEN * |
| 294 | ETH_GSTRING_LEN); |
| 295 | buf += UEC_TX_FW_STATS_LEN * ETH_GSTRING_LEN; |
| 296 | } |
| 297 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) |
Joakim Tjernlund | 25f03dc | 2008-05-23 18:11:26 +0800 | [diff] [blame] | 298 | memcpy(buf, rx_fw_stat_gstrings, UEC_RX_FW_STATS_LEN * |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 299 | ETH_GSTRING_LEN); |
| 300 | } |
| 301 | |
| 302 | static void uec_get_ethtool_stats(struct net_device *netdev, |
| 303 | struct ethtool_stats *stats, uint64_t *data) |
| 304 | { |
| 305 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 306 | u32 stats_mode = ugeth->ug_info->statisticsMode; |
| 307 | u32 __iomem *base; |
| 308 | int i, j = 0; |
| 309 | |
| 310 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_HARDWARE) { |
Anton Vorontsov | e0ad2cd | 2009-08-27 07:35:47 +0000 | [diff] [blame] | 311 | if (ugeth->ug_regs) |
| 312 | base = (u32 __iomem *)&ugeth->ug_regs->tx64; |
| 313 | else |
| 314 | base = NULL; |
| 315 | |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 316 | for (i = 0; i < UEC_HW_STATS_LEN; i++) |
Anton Vorontsov | e0ad2cd | 2009-08-27 07:35:47 +0000 | [diff] [blame] | 317 | data[j++] = base ? in_be32(&base[i]) : 0; |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 318 | } |
| 319 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_TX) { |
| 320 | base = (u32 __iomem *)ugeth->p_tx_fw_statistics_pram; |
| 321 | for (i = 0; i < UEC_TX_FW_STATS_LEN; i++) |
Anton Vorontsov | 18acfa2 | 2008-11-13 21:26:27 +0300 | [diff] [blame] | 322 | data[j++] = base ? in_be32(&base[i]) : 0; |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 323 | } |
| 324 | if (stats_mode & UCC_GETH_STATISTICS_GATHERING_MODE_FIRMWARE_RX) { |
| 325 | base = (u32 __iomem *)ugeth->p_rx_fw_statistics_pram; |
| 326 | for (i = 0; i < UEC_RX_FW_STATS_LEN; i++) |
Anton Vorontsov | 18acfa2 | 2008-11-13 21:26:27 +0300 | [diff] [blame] | 327 | data[j++] = base ? in_be32(&base[i]) : 0; |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 328 | } |
| 329 | } |
| 330 | |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 331 | /* Report driver information */ |
| 332 | static void |
| 333 | uec_get_drvinfo(struct net_device *netdev, |
| 334 | struct ethtool_drvinfo *drvinfo) |
| 335 | { |
Jiri Pirko | 7826d43 | 2013-01-06 00:44:26 +0000 | [diff] [blame] | 336 | strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); |
Jiri Pirko | 7826d43 | 2013-01-06 00:44:26 +0000 | [diff] [blame] | 337 | strlcpy(drvinfo->bus_info, "QUICC ENGINE", sizeof(drvinfo->bus_info)); |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 338 | } |
| 339 | |
Anton Vorontsov | 2394905 | 2009-08-27 07:35:57 +0000 | [diff] [blame] | 340 | #ifdef CONFIG_PM |
| 341 | |
| 342 | static void uec_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) |
| 343 | { |
| 344 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 345 | struct phy_device *phydev = ugeth->phydev; |
| 346 | |
| 347 | if (phydev && phydev->irq) |
| 348 | wol->supported |= WAKE_PHY; |
| 349 | if (qe_alive_during_sleep()) |
| 350 | wol->supported |= WAKE_MAGIC; |
| 351 | |
| 352 | wol->wolopts = ugeth->wol_en; |
| 353 | } |
| 354 | |
| 355 | static int uec_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) |
| 356 | { |
| 357 | struct ucc_geth_private *ugeth = netdev_priv(netdev); |
| 358 | struct phy_device *phydev = ugeth->phydev; |
| 359 | |
| 360 | if (wol->wolopts & ~(WAKE_PHY | WAKE_MAGIC)) |
| 361 | return -EINVAL; |
| 362 | else if (wol->wolopts & WAKE_PHY && (!phydev || !phydev->irq)) |
| 363 | return -EINVAL; |
| 364 | else if (wol->wolopts & WAKE_MAGIC && !qe_alive_during_sleep()) |
| 365 | return -EINVAL; |
| 366 | |
| 367 | ugeth->wol_en = wol->wolopts; |
| 368 | device_set_wakeup_enable(&netdev->dev, ugeth->wol_en); |
| 369 | |
| 370 | return 0; |
| 371 | } |
| 372 | |
| 373 | #else |
| 374 | #define uec_get_wol NULL |
| 375 | #define uec_set_wol NULL |
| 376 | #endif /* CONFIG_PM */ |
| 377 | |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 378 | static const struct ethtool_ops uec_ethtool_ops = { |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 379 | .get_drvinfo = uec_get_drvinfo, |
| 380 | .get_regs_len = uec_get_regs_len, |
| 381 | .get_regs = uec_get_regs, |
| 382 | .get_msglevel = uec_get_msglevel, |
| 383 | .set_msglevel = uec_set_msglevel, |
Florian Fainelli | e06986f | 2016-11-15 10:06:41 -0800 | [diff] [blame] | 384 | .nway_reset = phy_ethtool_nway_reset, |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 385 | .get_link = ethtool_op_get_link, |
| 386 | .get_ringparam = uec_get_ringparam, |
| 387 | .set_ringparam = uec_set_ringparam, |
| 388 | .get_pauseparam = uec_get_pauseparam, |
| 389 | .set_pauseparam = uec_set_pauseparam, |
Jeff Garzik | b9f2c04 | 2007-10-03 18:07:32 -0700 | [diff] [blame] | 390 | .get_sset_count = uec_get_sset_count, |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 391 | .get_strings = uec_get_strings, |
| 392 | .get_ethtool_stats = uec_get_ethtool_stats, |
Anton Vorontsov | 2394905 | 2009-08-27 07:35:57 +0000 | [diff] [blame] | 393 | .get_wol = uec_get_wol, |
| 394 | .set_wol = uec_set_wol, |
Richard Cochran | e117d6d | 2012-04-03 22:59:40 +0000 | [diff] [blame] | 395 | .get_ts_info = ethtool_op_get_ts_info, |
Philippe Reynes | 5e74bf2d9 | 2016-05-01 17:08:09 +0200 | [diff] [blame] | 396 | .get_link_ksettings = uec_get_ksettings, |
| 397 | .set_link_ksettings = uec_set_ksettings, |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 398 | }; |
| 399 | |
| 400 | void uec_set_ethtool_ops(struct net_device *netdev) |
| 401 | { |
Wilfried Klaebe | 7ad24ea | 2014-05-11 00:12:32 +0000 | [diff] [blame] | 402 | netdev->ethtool_ops = &uec_ethtool_ops; |
Li Yang | ac42185 | 2007-07-19 11:47:47 +0800 | [diff] [blame] | 403 | } |