Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | STMMAC Ethtool support |
| 3 | |
| 4 | Copyright (C) 2007-2009 STMicroelectronics Ltd |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it |
| 7 | under the terms and conditions of the GNU General Public License, |
| 8 | version 2, as published by the Free Software Foundation. |
| 9 | |
| 10 | This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | more details. |
| 14 | |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 15 | The full GNU General Public License is included in this distribution in |
| 16 | the file called "COPYING". |
| 17 | |
| 18 | Author: Giuseppe Cavallaro <peppe.cavallaro@st.com> |
| 19 | *******************************************************************************/ |
| 20 | |
| 21 | #include <linux/etherdevice.h> |
| 22 | #include <linux/ethtool.h> |
Alexey Dobriyan | a6b7a40 | 2011-06-06 10:43:46 +0000 | [diff] [blame] | 23 | #include <linux/interrupt.h> |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 24 | #include <linux/mii.h> |
| 25 | #include <linux/phy.h> |
Rayagond Kokatanur | 891434b | 2013-03-26 04:43:10 +0000 | [diff] [blame] | 26 | #include <linux/net_tstamp.h> |
Alexey Dobriyan | b7f080c | 2011-06-16 11:01:34 +0000 | [diff] [blame] | 27 | #include <asm/io.h> |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 28 | |
| 29 | #include "stmmac.h" |
Giuseppe CAVALLARO | aec7ff2 | 2010-01-06 23:07:18 +0000 | [diff] [blame] | 30 | #include "dwmac_dma.h" |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 31 | |
Thor Thayer | 77b0d36 | 2017-06-27 17:16:27 -0500 | [diff] [blame] | 32 | #define REG_SPACE_SIZE 0x1060 |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 33 | #define MAC100_ETHTOOL_NAME "st_mac100" |
| 34 | #define GMAC_ETHTOOL_NAME "st_gmac" |
| 35 | |
| 36 | struct stmmac_stats { |
| 37 | char stat_string[ETH_GSTRING_LEN]; |
| 38 | int sizeof_stat; |
| 39 | int stat_offset; |
| 40 | }; |
| 41 | |
| 42 | #define STMMAC_STAT(m) \ |
| 43 | { #m, FIELD_SIZEOF(struct stmmac_extra_stats, m), \ |
| 44 | offsetof(struct stmmac_priv, xstats.m)} |
| 45 | |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 46 | static const struct stmmac_stats stmmac_gstrings_stats[] = { |
Giuseppe CAVALLARO | 1cc5a73 | 2012-02-15 00:10:37 +0000 | [diff] [blame] | 47 | /* Transmit errors */ |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 48 | STMMAC_STAT(tx_underflow), |
| 49 | STMMAC_STAT(tx_carrier), |
| 50 | STMMAC_STAT(tx_losscarrier), |
Giuseppe CAVALLARO | 3c20f72 | 2011-10-26 19:43:09 +0000 | [diff] [blame] | 51 | STMMAC_STAT(vlan_tag), |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 52 | STMMAC_STAT(tx_deferred), |
| 53 | STMMAC_STAT(tx_vlan), |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 54 | STMMAC_STAT(tx_jabber), |
| 55 | STMMAC_STAT(tx_frame_flushed), |
| 56 | STMMAC_STAT(tx_payload_error), |
| 57 | STMMAC_STAT(tx_ip_header_error), |
Giuseppe CAVALLARO | 1cc5a73 | 2012-02-15 00:10:37 +0000 | [diff] [blame] | 58 | /* Receive errors */ |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 59 | STMMAC_STAT(rx_desc), |
Giuseppe CAVALLARO | 3c20f72 | 2011-10-26 19:43:09 +0000 | [diff] [blame] | 60 | STMMAC_STAT(sa_filter_fail), |
| 61 | STMMAC_STAT(overflow_error), |
| 62 | STMMAC_STAT(ipc_csum_error), |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 63 | STMMAC_STAT(rx_collision), |
LABBE Corentin | e0a7660 | 2017-02-08 09:31:17 +0100 | [diff] [blame] | 64 | STMMAC_STAT(rx_crc_errors), |
Giuseppe CAVALLARO | 1cc5a73 | 2012-02-15 00:10:37 +0000 | [diff] [blame] | 65 | STMMAC_STAT(dribbling_bit), |
Giuseppe Cavallaro | 1b92403 | 2010-02-04 09:33:21 -0800 | [diff] [blame] | 66 | STMMAC_STAT(rx_length), |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 67 | STMMAC_STAT(rx_mii), |
| 68 | STMMAC_STAT(rx_multicast), |
| 69 | STMMAC_STAT(rx_gmac_overflow), |
| 70 | STMMAC_STAT(rx_watchdog), |
| 71 | STMMAC_STAT(da_rx_filter_fail), |
| 72 | STMMAC_STAT(sa_rx_filter_fail), |
| 73 | STMMAC_STAT(rx_missed_cntr), |
| 74 | STMMAC_STAT(rx_overflow_cntr), |
Giuseppe CAVALLARO | 1cc5a73 | 2012-02-15 00:10:37 +0000 | [diff] [blame] | 75 | STMMAC_STAT(rx_vlan), |
Giuseppe CAVALLARO | 62a2ab9 | 2012-11-25 23:10:43 +0000 | [diff] [blame] | 76 | /* Tx/Rx IRQ error info */ |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 77 | STMMAC_STAT(tx_undeflow_irq), |
| 78 | STMMAC_STAT(tx_process_stopped_irq), |
| 79 | STMMAC_STAT(tx_jabber_irq), |
| 80 | STMMAC_STAT(rx_overflow_irq), |
| 81 | STMMAC_STAT(rx_buf_unav_irq), |
| 82 | STMMAC_STAT(rx_process_stopped_irq), |
| 83 | STMMAC_STAT(rx_watchdog_irq), |
| 84 | STMMAC_STAT(tx_early_irq), |
| 85 | STMMAC_STAT(fatal_bus_error_irq), |
Giuseppe CAVALLARO | 62a2ab9 | 2012-11-25 23:10:43 +0000 | [diff] [blame] | 86 | /* Tx/Rx IRQ Events */ |
| 87 | STMMAC_STAT(rx_early_irq), |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 88 | STMMAC_STAT(threshold), |
| 89 | STMMAC_STAT(tx_pkt_n), |
| 90 | STMMAC_STAT(rx_pkt_n), |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 91 | STMMAC_STAT(normal_irq_n), |
Giuseppe CAVALLARO | 9125cdd | 2012-11-25 23:10:42 +0000 | [diff] [blame] | 92 | STMMAC_STAT(rx_normal_irq_n), |
| 93 | STMMAC_STAT(napi_poll), |
| 94 | STMMAC_STAT(tx_normal_irq_n), |
| 95 | STMMAC_STAT(tx_clean), |
Giuseppe Cavallaro | 0e80bdc | 2016-02-29 14:27:38 +0100 | [diff] [blame] | 96 | STMMAC_STAT(tx_set_ic_bit), |
Giuseppe CAVALLARO | 62a2ab9 | 2012-11-25 23:10:43 +0000 | [diff] [blame] | 97 | STMMAC_STAT(irq_receive_pmt_irq_n), |
| 98 | /* MMC info */ |
Giuseppe CAVALLARO | d765955 | 2012-06-27 21:14:37 +0000 | [diff] [blame] | 99 | STMMAC_STAT(mmc_tx_irq_n), |
| 100 | STMMAC_STAT(mmc_rx_irq_n), |
| 101 | STMMAC_STAT(mmc_rx_csum_offload_irq_n), |
Giuseppe CAVALLARO | 62a2ab9 | 2012-11-25 23:10:43 +0000 | [diff] [blame] | 102 | /* EEE */ |
Giuseppe CAVALLARO | d765955 | 2012-06-27 21:14:37 +0000 | [diff] [blame] | 103 | STMMAC_STAT(irq_tx_path_in_lpi_mode_n), |
| 104 | STMMAC_STAT(irq_tx_path_exit_lpi_mode_n), |
| 105 | STMMAC_STAT(irq_rx_path_in_lpi_mode_n), |
| 106 | STMMAC_STAT(irq_rx_path_exit_lpi_mode_n), |
| 107 | STMMAC_STAT(phy_eee_wakeup_error_n), |
Giuseppe CAVALLARO | c24602e | 2013-03-26 04:43:06 +0000 | [diff] [blame] | 108 | /* Extended RDES status */ |
| 109 | STMMAC_STAT(ip_hdr_err), |
| 110 | STMMAC_STAT(ip_payload_err), |
| 111 | STMMAC_STAT(ip_csum_bypassed), |
| 112 | STMMAC_STAT(ipv4_pkt_rcvd), |
| 113 | STMMAC_STAT(ipv6_pkt_rcvd), |
Giuseppe CAVALLARO | ee112c1 | 2016-11-14 09:27:30 +0100 | [diff] [blame] | 114 | STMMAC_STAT(no_ptp_rx_msg_type_ext), |
| 115 | STMMAC_STAT(ptp_rx_msg_type_sync), |
| 116 | STMMAC_STAT(ptp_rx_msg_type_follow_up), |
| 117 | STMMAC_STAT(ptp_rx_msg_type_delay_req), |
| 118 | STMMAC_STAT(ptp_rx_msg_type_delay_resp), |
| 119 | STMMAC_STAT(ptp_rx_msg_type_pdelay_req), |
| 120 | STMMAC_STAT(ptp_rx_msg_type_pdelay_resp), |
| 121 | STMMAC_STAT(ptp_rx_msg_type_pdelay_follow_up), |
| 122 | STMMAC_STAT(ptp_rx_msg_type_announce), |
| 123 | STMMAC_STAT(ptp_rx_msg_type_management), |
| 124 | STMMAC_STAT(ptp_rx_msg_pkt_reserved_type), |
Giuseppe CAVALLARO | c24602e | 2013-03-26 04:43:06 +0000 | [diff] [blame] | 125 | STMMAC_STAT(ptp_frame_type), |
| 126 | STMMAC_STAT(ptp_ver), |
| 127 | STMMAC_STAT(timestamp_dropped), |
| 128 | STMMAC_STAT(av_pkt_rcvd), |
| 129 | STMMAC_STAT(av_tagged_pkt_rcvd), |
| 130 | STMMAC_STAT(vlan_tag_priority_val), |
| 131 | STMMAC_STAT(l3_filter_match), |
| 132 | STMMAC_STAT(l4_filter_match), |
| 133 | STMMAC_STAT(l3_l4_filter_no_match), |
Giuseppe CAVALLARO | 0982a0f | 2013-03-26 04:43:07 +0000 | [diff] [blame] | 134 | /* PCS */ |
| 135 | STMMAC_STAT(irq_pcs_ane_n), |
| 136 | STMMAC_STAT(irq_pcs_link_n), |
| 137 | STMMAC_STAT(irq_rgmii_n), |
Giuseppe CAVALLARO | 2f7a791 | 2015-11-30 11:33:10 +0100 | [diff] [blame] | 138 | /* DEBUG */ |
| 139 | STMMAC_STAT(mtl_tx_status_fifo_full), |
| 140 | STMMAC_STAT(mtl_tx_fifo_not_empty), |
| 141 | STMMAC_STAT(mmtl_fifo_ctrl), |
| 142 | STMMAC_STAT(mtl_tx_fifo_read_ctrl_write), |
| 143 | STMMAC_STAT(mtl_tx_fifo_read_ctrl_wait), |
| 144 | STMMAC_STAT(mtl_tx_fifo_read_ctrl_read), |
| 145 | STMMAC_STAT(mtl_tx_fifo_read_ctrl_idle), |
| 146 | STMMAC_STAT(mac_tx_in_pause), |
| 147 | STMMAC_STAT(mac_tx_frame_ctrl_xfer), |
| 148 | STMMAC_STAT(mac_tx_frame_ctrl_idle), |
| 149 | STMMAC_STAT(mac_tx_frame_ctrl_wait), |
| 150 | STMMAC_STAT(mac_tx_frame_ctrl_pause), |
| 151 | STMMAC_STAT(mac_gmii_tx_proto_engine), |
| 152 | STMMAC_STAT(mtl_rx_fifo_fill_level_full), |
| 153 | STMMAC_STAT(mtl_rx_fifo_fill_above_thresh), |
| 154 | STMMAC_STAT(mtl_rx_fifo_fill_below_thresh), |
| 155 | STMMAC_STAT(mtl_rx_fifo_fill_level_empty), |
| 156 | STMMAC_STAT(mtl_rx_fifo_read_ctrl_flush), |
| 157 | STMMAC_STAT(mtl_rx_fifo_read_ctrl_read_data), |
| 158 | STMMAC_STAT(mtl_rx_fifo_read_ctrl_status), |
| 159 | STMMAC_STAT(mtl_rx_fifo_read_ctrl_idle), |
| 160 | STMMAC_STAT(mtl_rx_fifo_ctrl_active), |
| 161 | STMMAC_STAT(mac_rx_frame_ctrl_fifo), |
| 162 | STMMAC_STAT(mac_gmii_rx_proto_engine), |
Alexandre TORGUE | f748be5 | 2016-04-01 11:37:34 +0200 | [diff] [blame] | 163 | /* TSO */ |
| 164 | STMMAC_STAT(tx_tso_frames), |
| 165 | STMMAC_STAT(tx_tso_nfrags), |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 166 | }; |
| 167 | #define STMMAC_STATS_LEN ARRAY_SIZE(stmmac_gstrings_stats) |
| 168 | |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 169 | /* HW MAC Management counters (if supported) */ |
| 170 | #define STMMAC_MMC_STAT(m) \ |
| 171 | { #m, FIELD_SIZEOF(struct stmmac_counters, m), \ |
| 172 | offsetof(struct stmmac_priv, mmc.m)} |
| 173 | |
Giuseppe CAVALLARO | 38fe7a9 | 2011-10-18 00:01:23 +0000 | [diff] [blame] | 174 | static const struct stmmac_stats stmmac_mmc[] = { |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 175 | STMMAC_MMC_STAT(mmc_tx_octetcount_gb), |
| 176 | STMMAC_MMC_STAT(mmc_tx_framecount_gb), |
| 177 | STMMAC_MMC_STAT(mmc_tx_broadcastframe_g), |
| 178 | STMMAC_MMC_STAT(mmc_tx_multicastframe_g), |
| 179 | STMMAC_MMC_STAT(mmc_tx_64_octets_gb), |
| 180 | STMMAC_MMC_STAT(mmc_tx_65_to_127_octets_gb), |
| 181 | STMMAC_MMC_STAT(mmc_tx_128_to_255_octets_gb), |
| 182 | STMMAC_MMC_STAT(mmc_tx_256_to_511_octets_gb), |
| 183 | STMMAC_MMC_STAT(mmc_tx_512_to_1023_octets_gb), |
| 184 | STMMAC_MMC_STAT(mmc_tx_1024_to_max_octets_gb), |
| 185 | STMMAC_MMC_STAT(mmc_tx_unicast_gb), |
| 186 | STMMAC_MMC_STAT(mmc_tx_multicast_gb), |
| 187 | STMMAC_MMC_STAT(mmc_tx_broadcast_gb), |
| 188 | STMMAC_MMC_STAT(mmc_tx_underflow_error), |
| 189 | STMMAC_MMC_STAT(mmc_tx_singlecol_g), |
| 190 | STMMAC_MMC_STAT(mmc_tx_multicol_g), |
| 191 | STMMAC_MMC_STAT(mmc_tx_deferred), |
| 192 | STMMAC_MMC_STAT(mmc_tx_latecol), |
| 193 | STMMAC_MMC_STAT(mmc_tx_exesscol), |
| 194 | STMMAC_MMC_STAT(mmc_tx_carrier_error), |
| 195 | STMMAC_MMC_STAT(mmc_tx_octetcount_g), |
| 196 | STMMAC_MMC_STAT(mmc_tx_framecount_g), |
| 197 | STMMAC_MMC_STAT(mmc_tx_excessdef), |
| 198 | STMMAC_MMC_STAT(mmc_tx_pause_frame), |
| 199 | STMMAC_MMC_STAT(mmc_tx_vlan_frame_g), |
| 200 | STMMAC_MMC_STAT(mmc_rx_framecount_gb), |
| 201 | STMMAC_MMC_STAT(mmc_rx_octetcount_gb), |
| 202 | STMMAC_MMC_STAT(mmc_rx_octetcount_g), |
| 203 | STMMAC_MMC_STAT(mmc_rx_broadcastframe_g), |
| 204 | STMMAC_MMC_STAT(mmc_rx_multicastframe_g), |
Giuseppe CAVALLARO | 2b78d348 | 2014-08-27 08:26:13 +0200 | [diff] [blame] | 205 | STMMAC_MMC_STAT(mmc_rx_crc_error), |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 206 | STMMAC_MMC_STAT(mmc_rx_align_error), |
| 207 | STMMAC_MMC_STAT(mmc_rx_run_error), |
| 208 | STMMAC_MMC_STAT(mmc_rx_jabber_error), |
| 209 | STMMAC_MMC_STAT(mmc_rx_undersize_g), |
| 210 | STMMAC_MMC_STAT(mmc_rx_oversize_g), |
| 211 | STMMAC_MMC_STAT(mmc_rx_64_octets_gb), |
| 212 | STMMAC_MMC_STAT(mmc_rx_65_to_127_octets_gb), |
| 213 | STMMAC_MMC_STAT(mmc_rx_128_to_255_octets_gb), |
| 214 | STMMAC_MMC_STAT(mmc_rx_256_to_511_octets_gb), |
| 215 | STMMAC_MMC_STAT(mmc_rx_512_to_1023_octets_gb), |
| 216 | STMMAC_MMC_STAT(mmc_rx_1024_to_max_octets_gb), |
| 217 | STMMAC_MMC_STAT(mmc_rx_unicast_g), |
| 218 | STMMAC_MMC_STAT(mmc_rx_length_error), |
| 219 | STMMAC_MMC_STAT(mmc_rx_autofrangetype), |
| 220 | STMMAC_MMC_STAT(mmc_rx_pause_frames), |
| 221 | STMMAC_MMC_STAT(mmc_rx_fifo_overflow), |
| 222 | STMMAC_MMC_STAT(mmc_rx_vlan_frames_gb), |
| 223 | STMMAC_MMC_STAT(mmc_rx_watchdog_error), |
| 224 | STMMAC_MMC_STAT(mmc_rx_ipc_intr_mask), |
| 225 | STMMAC_MMC_STAT(mmc_rx_ipc_intr), |
| 226 | STMMAC_MMC_STAT(mmc_rx_ipv4_gd), |
| 227 | STMMAC_MMC_STAT(mmc_rx_ipv4_hderr), |
| 228 | STMMAC_MMC_STAT(mmc_rx_ipv4_nopay), |
| 229 | STMMAC_MMC_STAT(mmc_rx_ipv4_frag), |
| 230 | STMMAC_MMC_STAT(mmc_rx_ipv4_udsbl), |
| 231 | STMMAC_MMC_STAT(mmc_rx_ipv4_gd_octets), |
| 232 | STMMAC_MMC_STAT(mmc_rx_ipv4_hderr_octets), |
| 233 | STMMAC_MMC_STAT(mmc_rx_ipv4_nopay_octets), |
| 234 | STMMAC_MMC_STAT(mmc_rx_ipv4_frag_octets), |
| 235 | STMMAC_MMC_STAT(mmc_rx_ipv4_udsbl_octets), |
| 236 | STMMAC_MMC_STAT(mmc_rx_ipv6_gd_octets), |
| 237 | STMMAC_MMC_STAT(mmc_rx_ipv6_hderr_octets), |
| 238 | STMMAC_MMC_STAT(mmc_rx_ipv6_nopay_octets), |
| 239 | STMMAC_MMC_STAT(mmc_rx_ipv6_gd), |
| 240 | STMMAC_MMC_STAT(mmc_rx_ipv6_hderr), |
| 241 | STMMAC_MMC_STAT(mmc_rx_ipv6_nopay), |
| 242 | STMMAC_MMC_STAT(mmc_rx_udp_gd), |
| 243 | STMMAC_MMC_STAT(mmc_rx_udp_err), |
| 244 | STMMAC_MMC_STAT(mmc_rx_tcp_gd), |
| 245 | STMMAC_MMC_STAT(mmc_rx_tcp_err), |
| 246 | STMMAC_MMC_STAT(mmc_rx_icmp_gd), |
| 247 | STMMAC_MMC_STAT(mmc_rx_icmp_err), |
| 248 | STMMAC_MMC_STAT(mmc_rx_udp_gd_octets), |
| 249 | STMMAC_MMC_STAT(mmc_rx_udp_err_octets), |
| 250 | STMMAC_MMC_STAT(mmc_rx_tcp_gd_octets), |
| 251 | STMMAC_MMC_STAT(mmc_rx_tcp_err_octets), |
| 252 | STMMAC_MMC_STAT(mmc_rx_icmp_gd_octets), |
| 253 | STMMAC_MMC_STAT(mmc_rx_icmp_err_octets), |
| 254 | }; |
Giuseppe CAVALLARO | 38fe7a9 | 2011-10-18 00:01:23 +0000 | [diff] [blame] | 255 | #define STMMAC_MMC_STATS_LEN ARRAY_SIZE(stmmac_mmc) |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 256 | |
stephen hemminger | 8ee17ae | 2010-10-13 14:50:31 +0000 | [diff] [blame] | 257 | static void stmmac_ethtool_getdrvinfo(struct net_device *dev, |
| 258 | struct ethtool_drvinfo *info) |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 259 | { |
| 260 | struct stmmac_priv *priv = netdev_priv(dev); |
| 261 | |
Niklas Cassel | 7cc99fd | 2016-12-07 13:41:08 +0100 | [diff] [blame] | 262 | if (priv->plat->has_gmac || priv->plat->has_gmac4) |
Rick Jones | 33a5ba1 | 2011-11-15 14:59:53 +0000 | [diff] [blame] | 263 | strlcpy(info->driver, GMAC_ETHTOOL_NAME, sizeof(info->driver)); |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 264 | else |
Rick Jones | 33a5ba1 | 2011-11-15 14:59:53 +0000 | [diff] [blame] | 265 | strlcpy(info->driver, MAC100_ETHTOOL_NAME, |
| 266 | sizeof(info->driver)); |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 267 | |
Jiri Pirko | 7826d43 | 2013-01-06 00:44:26 +0000 | [diff] [blame] | 268 | strlcpy(info->version, DRV_MODULE_VERSION, sizeof(info->version)); |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 269 | } |
| 270 | |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 271 | static int stmmac_ethtool_get_link_ksettings(struct net_device *dev, |
| 272 | struct ethtool_link_ksettings *cmd) |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 273 | { |
| 274 | struct stmmac_priv *priv = netdev_priv(dev); |
Philippe Reynes | d6d50c7 | 2016-10-03 08:28:19 +0200 | [diff] [blame] | 275 | struct phy_device *phy = dev->phydev; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 276 | |
Giuseppe CAVALLARO | 3fe5cad | 2016-06-24 15:16:25 +0200 | [diff] [blame] | 277 | if (priv->hw->pcs & STMMAC_PCS_RGMII || |
| 278 | priv->hw->pcs & STMMAC_PCS_SGMII) { |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 279 | struct rgmii_adv adv; |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 280 | u32 supported, advertising, lp_advertising; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 281 | |
| 282 | if (!priv->xstats.pcs_link) { |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 283 | cmd->base.speed = SPEED_UNKNOWN; |
| 284 | cmd->base.duplex = DUPLEX_UNKNOWN; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 285 | return 0; |
| 286 | } |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 287 | cmd->base.duplex = priv->xstats.pcs_duplex; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 288 | |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 289 | cmd->base.speed = priv->xstats.pcs_speed; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 290 | |
| 291 | /* Get and convert ADV/LP_ADV from the HW AN registers */ |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 292 | if (!priv->hw->mac->pcs_get_adv_lp) |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 293 | return -EOPNOTSUPP; /* should never happen indeed */ |
| 294 | |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 295 | priv->hw->mac->pcs_get_adv_lp(priv->ioaddr, &adv); |
Pavel Machek | a77e4ac | 2014-08-25 13:31:16 +0200 | [diff] [blame] | 296 | |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 297 | /* Encoding of PSE bits is defined in 802.3z, 37.2.1.4 */ |
| 298 | |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 299 | ethtool_convert_link_mode_to_legacy_u32( |
| 300 | &supported, cmd->link_modes.supported); |
| 301 | ethtool_convert_link_mode_to_legacy_u32( |
| 302 | &advertising, cmd->link_modes.advertising); |
| 303 | ethtool_convert_link_mode_to_legacy_u32( |
| 304 | &lp_advertising, cmd->link_modes.lp_advertising); |
| 305 | |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 306 | if (adv.pause & STMMAC_PCS_PAUSE) |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 307 | advertising |= ADVERTISED_Pause; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 308 | if (adv.pause & STMMAC_PCS_ASYM_PAUSE) |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 309 | advertising |= ADVERTISED_Asym_Pause; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 310 | if (adv.lp_pause & STMMAC_PCS_PAUSE) |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 311 | lp_advertising |= ADVERTISED_Pause; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 312 | if (adv.lp_pause & STMMAC_PCS_ASYM_PAUSE) |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 313 | lp_advertising |= ADVERTISED_Asym_Pause; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 314 | |
| 315 | /* Reg49[3] always set because ANE is always supported */ |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 316 | cmd->base.autoneg = ADVERTISED_Autoneg; |
| 317 | supported |= SUPPORTED_Autoneg; |
| 318 | advertising |= ADVERTISED_Autoneg; |
| 319 | lp_advertising |= ADVERTISED_Autoneg; |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 320 | |
| 321 | if (adv.duplex) { |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 322 | supported |= (SUPPORTED_1000baseT_Full | |
| 323 | SUPPORTED_100baseT_Full | |
| 324 | SUPPORTED_10baseT_Full); |
| 325 | advertising |= (ADVERTISED_1000baseT_Full | |
| 326 | ADVERTISED_100baseT_Full | |
| 327 | ADVERTISED_10baseT_Full); |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 328 | } else { |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 329 | supported |= (SUPPORTED_1000baseT_Half | |
| 330 | SUPPORTED_100baseT_Half | |
| 331 | SUPPORTED_10baseT_Half); |
| 332 | advertising |= (ADVERTISED_1000baseT_Half | |
| 333 | ADVERTISED_100baseT_Half | |
| 334 | ADVERTISED_10baseT_Half); |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 335 | } |
| 336 | if (adv.lp_duplex) |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 337 | lp_advertising |= (ADVERTISED_1000baseT_Full | |
| 338 | ADVERTISED_100baseT_Full | |
| 339 | ADVERTISED_10baseT_Full); |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 340 | else |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 341 | lp_advertising |= (ADVERTISED_1000baseT_Half | |
| 342 | ADVERTISED_100baseT_Half | |
| 343 | ADVERTISED_10baseT_Half); |
| 344 | cmd->base.port = PORT_OTHER; |
| 345 | |
| 346 | ethtool_convert_legacy_u32_to_link_mode( |
| 347 | cmd->link_modes.supported, supported); |
| 348 | ethtool_convert_legacy_u32_to_link_mode( |
| 349 | cmd->link_modes.advertising, advertising); |
| 350 | ethtool_convert_legacy_u32_to_link_mode( |
| 351 | cmd->link_modes.lp_advertising, lp_advertising); |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 352 | |
| 353 | return 0; |
| 354 | } |
| 355 | |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 356 | if (phy == NULL) { |
| 357 | pr_err("%s: %s: PHY is not registered\n", |
| 358 | __func__, dev->name); |
| 359 | return -ENODEV; |
| 360 | } |
| 361 | if (!netif_running(dev)) { |
| 362 | pr_err("%s: interface is disabled: we cannot track " |
| 363 | "link speed / duplex setting\n", dev->name); |
| 364 | return -EBUSY; |
| 365 | } |
yuval.shaia@oracle.com | 5514174 | 2017-06-13 10:09:46 +0300 | [diff] [blame] | 366 | phy_ethtool_ksettings_get(phy, cmd); |
| 367 | return 0; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 368 | } |
| 369 | |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 370 | static int |
| 371 | stmmac_ethtool_set_link_ksettings(struct net_device *dev, |
| 372 | const struct ethtool_link_ksettings *cmd) |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 373 | { |
| 374 | struct stmmac_priv *priv = netdev_priv(dev); |
Philippe Reynes | d6d50c7 | 2016-10-03 08:28:19 +0200 | [diff] [blame] | 375 | struct phy_device *phy = dev->phydev; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 376 | int rc; |
| 377 | |
Giuseppe CAVALLARO | 3fe5cad | 2016-06-24 15:16:25 +0200 | [diff] [blame] | 378 | if (priv->hw->pcs & STMMAC_PCS_RGMII || |
| 379 | priv->hw->pcs & STMMAC_PCS_SGMII) { |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 380 | u32 mask = ADVERTISED_Autoneg | ADVERTISED_Pause; |
| 381 | |
| 382 | /* Only support ANE */ |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 383 | if (cmd->base.autoneg != AUTONEG_ENABLE) |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 384 | return -EINVAL; |
| 385 | |
Pavel Machek | a77e4ac | 2014-08-25 13:31:16 +0200 | [diff] [blame] | 386 | mask &= (ADVERTISED_1000baseT_Half | |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 387 | ADVERTISED_1000baseT_Full | |
| 388 | ADVERTISED_100baseT_Half | |
| 389 | ADVERTISED_100baseT_Full | |
| 390 | ADVERTISED_10baseT_Half | |
| 391 | ADVERTISED_10baseT_Full); |
| 392 | |
Pavel Machek | a77e4ac | 2014-08-25 13:31:16 +0200 | [diff] [blame] | 393 | spin_lock(&priv->lock); |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 394 | |
| 395 | if (priv->hw->mac->pcs_ctrl_ane) |
Giuseppe CAVALLARO | 02e57b9 | 2016-06-24 15:16:26 +0200 | [diff] [blame] | 396 | priv->hw->mac->pcs_ctrl_ane(priv->ioaddr, 1, |
| 397 | priv->hw->ps, 0); |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 398 | |
Pavel Machek | a77e4ac | 2014-08-25 13:31:16 +0200 | [diff] [blame] | 399 | spin_unlock(&priv->lock); |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 400 | |
| 401 | return 0; |
| 402 | } |
| 403 | |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 404 | rc = phy_ethtool_ksettings_set(phy, cmd); |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 405 | |
| 406 | return rc; |
| 407 | } |
| 408 | |
stephen hemminger | 8ee17ae | 2010-10-13 14:50:31 +0000 | [diff] [blame] | 409 | static u32 stmmac_ethtool_getmsglevel(struct net_device *dev) |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 410 | { |
| 411 | struct stmmac_priv *priv = netdev_priv(dev); |
| 412 | return priv->msg_enable; |
| 413 | } |
| 414 | |
stephen hemminger | 8ee17ae | 2010-10-13 14:50:31 +0000 | [diff] [blame] | 415 | static void stmmac_ethtool_setmsglevel(struct net_device *dev, u32 level) |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 416 | { |
| 417 | struct stmmac_priv *priv = netdev_priv(dev); |
| 418 | priv->msg_enable = level; |
| 419 | |
| 420 | } |
| 421 | |
stephen hemminger | 8ee17ae | 2010-10-13 14:50:31 +0000 | [diff] [blame] | 422 | static int stmmac_check_if_running(struct net_device *dev) |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 423 | { |
| 424 | if (!netif_running(dev)) |
| 425 | return -EBUSY; |
| 426 | return 0; |
| 427 | } |
| 428 | |
stephen hemminger | 8ee17ae | 2010-10-13 14:50:31 +0000 | [diff] [blame] | 429 | static int stmmac_ethtool_get_regs_len(struct net_device *dev) |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 430 | { |
| 431 | return REG_SPACE_SIZE; |
| 432 | } |
| 433 | |
stephen hemminger | 8ee17ae | 2010-10-13 14:50:31 +0000 | [diff] [blame] | 434 | static void stmmac_ethtool_gregs(struct net_device *dev, |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 435 | struct ethtool_regs *regs, void *space) |
| 436 | { |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 437 | u32 *reg_space = (u32 *) space; |
| 438 | |
| 439 | struct stmmac_priv *priv = netdev_priv(dev); |
| 440 | |
| 441 | memset(reg_space, 0x0, REG_SPACE_SIZE); |
| 442 | |
LABBE Corentin | fbf6822 | 2017-02-23 14:12:25 +0100 | [diff] [blame] | 443 | priv->hw->mac->dump_regs(priv->hw, reg_space); |
| 444 | priv->hw->dma->dump_regs(priv->ioaddr, reg_space); |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 445 | } |
| 446 | |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 447 | static void |
| 448 | stmmac_get_pauseparam(struct net_device *netdev, |
| 449 | struct ethtool_pauseparam *pause) |
| 450 | { |
| 451 | struct stmmac_priv *priv = netdev_priv(netdev); |
| 452 | |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 453 | pause->rx_pause = 0; |
| 454 | pause->tx_pause = 0; |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 455 | |
Giuseppe CAVALLARO | 3fe5cad | 2016-06-24 15:16:25 +0200 | [diff] [blame] | 456 | if (priv->hw->pcs && priv->hw->mac->pcs_get_adv_lp) { |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 457 | struct rgmii_adv adv_lp; |
| 458 | |
| 459 | pause->autoneg = 1; |
| 460 | priv->hw->mac->pcs_get_adv_lp(priv->ioaddr, &adv_lp); |
| 461 | if (!adv_lp.pause) |
| 462 | return; |
| 463 | } else { |
Philippe Reynes | d6d50c7 | 2016-10-03 08:28:19 +0200 | [diff] [blame] | 464 | if (!(netdev->phydev->supported & SUPPORTED_Pause) || |
| 465 | !(netdev->phydev->supported & SUPPORTED_Asym_Pause)) |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 466 | return; |
| 467 | } |
| 468 | |
Philippe Reynes | d6d50c7 | 2016-10-03 08:28:19 +0200 | [diff] [blame] | 469 | pause->autoneg = netdev->phydev->autoneg; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 470 | |
| 471 | if (priv->flow_ctrl & FLOW_RX) |
| 472 | pause->rx_pause = 1; |
| 473 | if (priv->flow_ctrl & FLOW_TX) |
| 474 | pause->tx_pause = 1; |
| 475 | |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 476 | } |
| 477 | |
| 478 | static int |
| 479 | stmmac_set_pauseparam(struct net_device *netdev, |
| 480 | struct ethtool_pauseparam *pause) |
| 481 | { |
| 482 | struct stmmac_priv *priv = netdev_priv(netdev); |
Joao Pinto | 29feff3 | 2017-03-10 18:24:56 +0000 | [diff] [blame] | 483 | u32 tx_cnt = priv->plat->tx_queues_to_use; |
Philippe Reynes | d6d50c7 | 2016-10-03 08:28:19 +0200 | [diff] [blame] | 484 | struct phy_device *phy = netdev->phydev; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 485 | int new_pause = FLOW_OFF; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 486 | |
Giuseppe CAVALLARO | 3fe5cad | 2016-06-24 15:16:25 +0200 | [diff] [blame] | 487 | if (priv->hw->pcs && priv->hw->mac->pcs_get_adv_lp) { |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 488 | struct rgmii_adv adv_lp; |
| 489 | |
| 490 | pause->autoneg = 1; |
| 491 | priv->hw->mac->pcs_get_adv_lp(priv->ioaddr, &adv_lp); |
| 492 | if (!adv_lp.pause) |
| 493 | return -EOPNOTSUPP; |
| 494 | } else { |
| 495 | if (!(phy->supported & SUPPORTED_Pause) || |
| 496 | !(phy->supported & SUPPORTED_Asym_Pause)) |
| 497 | return -EOPNOTSUPP; |
| 498 | } |
Giuseppe CAVALLARO | e58bb43 | 2013-03-26 04:43:08 +0000 | [diff] [blame] | 499 | |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 500 | if (pause->rx_pause) |
| 501 | new_pause |= FLOW_RX; |
| 502 | if (pause->tx_pause) |
| 503 | new_pause |= FLOW_TX; |
| 504 | |
| 505 | priv->flow_ctrl = new_pause; |
Giuseppe CAVALLARO | 64c7f30 | 2011-05-12 20:28:05 +0000 | [diff] [blame] | 506 | phy->autoneg = pause->autoneg; |
Giuseppe CAVALLARO | 3fe5cad | 2016-06-24 15:16:25 +0200 | [diff] [blame] | 507 | |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 508 | if (phy->autoneg) { |
David Decotigny | 1334cb6 | 2011-05-12 20:28:04 +0000 | [diff] [blame] | 509 | if (netif_running(netdev)) |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 510 | return phy_start_aneg(phy); |
| 511 | } |
| 512 | |
| 513 | priv->hw->mac->flow_ctrl(priv->hw, phy->duplex, priv->flow_ctrl, |
Joao Pinto | 29feff3 | 2017-03-10 18:24:56 +0000 | [diff] [blame] | 514 | priv->pause, tx_cnt); |
Giuseppe CAVALLARO | 70523e63 | 2016-06-24 15:16:24 +0200 | [diff] [blame] | 515 | return 0; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 516 | } |
| 517 | |
| 518 | static void stmmac_get_ethtool_stats(struct net_device *dev, |
| 519 | struct ethtool_stats *dummy, u64 *data) |
| 520 | { |
| 521 | struct stmmac_priv *priv = netdev_priv(dev); |
Joao Pinto | ad5a87d | 2017-03-10 18:24:58 +0000 | [diff] [blame] | 522 | u32 rx_queues_count = priv->plat->rx_queues_to_use; |
| 523 | u32 tx_queues_count = priv->plat->tx_queues_to_use; |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 524 | int i, j = 0; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 525 | |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 526 | /* Update the DMA HW counters for dwmac10/100 */ |
Alexandre TORGUE | f748be5 | 2016-04-01 11:37:34 +0200 | [diff] [blame] | 527 | if (priv->hw->dma->dma_diagnostic_fr) |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 528 | priv->hw->dma->dma_diagnostic_fr(&dev->stats, |
| 529 | (void *) &priv->xstats, |
| 530 | priv->ioaddr); |
| 531 | else { |
| 532 | /* If supported, for new GMAC chips expose the MMC counters */ |
Giuseppe CAVALLARO | 38fe7a9 | 2011-10-18 00:01:23 +0000 | [diff] [blame] | 533 | if (priv->dma_cap.rmon) { |
Alexandre TORGUE | 36ff7c1 | 2016-04-01 11:37:32 +0200 | [diff] [blame] | 534 | dwmac_mmc_read(priv->mmcaddr, &priv->mmc); |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 535 | |
Giuseppe CAVALLARO | 38fe7a9 | 2011-10-18 00:01:23 +0000 | [diff] [blame] | 536 | for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) { |
| 537 | char *p; |
| 538 | p = (char *)priv + stmmac_mmc[i].stat_offset; |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 539 | |
Giuseppe CAVALLARO | 38fe7a9 | 2011-10-18 00:01:23 +0000 | [diff] [blame] | 540 | data[j++] = (stmmac_mmc[i].sizeof_stat == |
| 541 | sizeof(u64)) ? (*(u64 *)p) : |
| 542 | (*(u32 *)p); |
| 543 | } |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 544 | } |
Giuseppe CAVALLARO | d765955 | 2012-06-27 21:14:37 +0000 | [diff] [blame] | 545 | if (priv->eee_enabled) { |
Philippe Reynes | d6d50c7 | 2016-10-03 08:28:19 +0200 | [diff] [blame] | 546 | int val = phy_get_eee_err(dev->phydev); |
Giuseppe CAVALLARO | d765955 | 2012-06-27 21:14:37 +0000 | [diff] [blame] | 547 | if (val) |
| 548 | priv->xstats.phy_eee_wakeup_error_n = val; |
| 549 | } |
Giuseppe CAVALLARO | 2f7a791 | 2015-11-30 11:33:10 +0100 | [diff] [blame] | 550 | |
| 551 | if ((priv->hw->mac->debug) && |
| 552 | (priv->synopsys_id >= DWMAC_CORE_3_50)) |
| 553 | priv->hw->mac->debug(priv->ioaddr, |
Joao Pinto | ad5a87d | 2017-03-10 18:24:58 +0000 | [diff] [blame] | 554 | (void *)&priv->xstats, |
| 555 | rx_queues_count, tx_queues_count); |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 556 | } |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 557 | for (i = 0; i < STMMAC_STATS_LEN; i++) { |
| 558 | char *p = (char *)priv + stmmac_gstrings_stats[i].stat_offset; |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 559 | data[j++] = (stmmac_gstrings_stats[i].sizeof_stat == |
| 560 | sizeof(u64)) ? (*(u64 *)p) : (*(u32 *)p); |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 561 | } |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 562 | } |
| 563 | |
| 564 | static int stmmac_get_sset_count(struct net_device *netdev, int sset) |
| 565 | { |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 566 | struct stmmac_priv *priv = netdev_priv(netdev); |
| 567 | int len; |
| 568 | |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 569 | switch (sset) { |
| 570 | case ETH_SS_STATS: |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 571 | len = STMMAC_STATS_LEN; |
| 572 | |
Giuseppe CAVALLARO | 38fe7a9 | 2011-10-18 00:01:23 +0000 | [diff] [blame] | 573 | if (priv->dma_cap.rmon) |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 574 | len += STMMAC_MMC_STATS_LEN; |
| 575 | |
| 576 | return len; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 577 | default: |
| 578 | return -EOPNOTSUPP; |
| 579 | } |
| 580 | } |
| 581 | |
| 582 | static void stmmac_get_strings(struct net_device *dev, u32 stringset, u8 *data) |
| 583 | { |
| 584 | int i; |
| 585 | u8 *p = data; |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 586 | struct stmmac_priv *priv = netdev_priv(dev); |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 587 | |
| 588 | switch (stringset) { |
| 589 | case ETH_SS_STATS: |
Giuseppe CAVALLARO | 38fe7a9 | 2011-10-18 00:01:23 +0000 | [diff] [blame] | 590 | if (priv->dma_cap.rmon) |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 591 | for (i = 0; i < STMMAC_MMC_STATS_LEN; i++) { |
Giuseppe CAVALLARO | 38fe7a9 | 2011-10-18 00:01:23 +0000 | [diff] [blame] | 592 | memcpy(p, stmmac_mmc[i].stat_string, |
Giuseppe CAVALLARO | 1c901a4 | 2011-09-01 21:51:38 +0000 | [diff] [blame] | 593 | ETH_GSTRING_LEN); |
| 594 | p += ETH_GSTRING_LEN; |
| 595 | } |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 596 | for (i = 0; i < STMMAC_STATS_LEN; i++) { |
| 597 | memcpy(p, stmmac_gstrings_stats[i].stat_string, |
| 598 | ETH_GSTRING_LEN); |
| 599 | p += ETH_GSTRING_LEN; |
| 600 | } |
| 601 | break; |
| 602 | default: |
| 603 | WARN_ON(1); |
| 604 | break; |
| 605 | } |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | /* Currently only support WOL through Magic packet. */ |
| 609 | static void stmmac_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
| 610 | { |
| 611 | struct stmmac_priv *priv = netdev_priv(dev); |
| 612 | |
| 613 | spin_lock_irq(&priv->lock); |
Giuseppe Cavallaro | 543876c | 2010-09-24 21:27:41 -0700 | [diff] [blame] | 614 | if (device_can_wakeup(priv->device)) { |
Giuseppe Cavallaro | 74ae2fd | 2011-04-13 11:51:43 -0700 | [diff] [blame] | 615 | wol->supported = WAKE_MAGIC | WAKE_UCAST; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 616 | wol->wolopts = priv->wolopts; |
| 617 | } |
| 618 | spin_unlock_irq(&priv->lock); |
| 619 | } |
| 620 | |
| 621 | static int stmmac_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) |
| 622 | { |
| 623 | struct stmmac_priv *priv = netdev_priv(dev); |
Giuseppe Cavallaro | 74ae2fd | 2011-04-13 11:51:43 -0700 | [diff] [blame] | 624 | u32 support = WAKE_MAGIC | WAKE_UCAST; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 625 | |
Giuseppe CAVALLARO | 19e30c1 | 2011-11-16 21:58:00 +0000 | [diff] [blame] | 626 | /* By default almost all GMAC devices support the WoL via |
| 627 | * magic frame but we can disable it if the HW capability |
| 628 | * register shows no support for pmt_magic_frame. */ |
| 629 | if ((priv->hw_cap_support) && (!priv->dma_cap.pmt_magic_frame)) |
| 630 | wol->wolopts &= ~WAKE_MAGIC; |
| 631 | |
Giuseppe Cavallaro | 543876c | 2010-09-24 21:27:41 -0700 | [diff] [blame] | 632 | if (!device_can_wakeup(priv->device)) |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 633 | return -EINVAL; |
| 634 | |
| 635 | if (wol->wolopts & ~support) |
| 636 | return -EINVAL; |
| 637 | |
Giuseppe Cavallaro | 543876c | 2010-09-24 21:27:41 -0700 | [diff] [blame] | 638 | if (wol->wolopts) { |
| 639 | pr_info("stmmac: wakeup enable\n"); |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 640 | device_set_wakeup_enable(priv->device, 1); |
Deepak Sikri | 3172d3a | 2011-09-01 21:51:37 +0000 | [diff] [blame] | 641 | enable_irq_wake(priv->wol_irq); |
Giuseppe Cavallaro | 543876c | 2010-09-24 21:27:41 -0700 | [diff] [blame] | 642 | } else { |
| 643 | device_set_wakeup_enable(priv->device, 0); |
Deepak Sikri | 3172d3a | 2011-09-01 21:51:37 +0000 | [diff] [blame] | 644 | disable_irq_wake(priv->wol_irq); |
Giuseppe Cavallaro | 543876c | 2010-09-24 21:27:41 -0700 | [diff] [blame] | 645 | } |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 646 | |
| 647 | spin_lock_irq(&priv->lock); |
| 648 | priv->wolopts = wol->wolopts; |
| 649 | spin_unlock_irq(&priv->lock); |
| 650 | |
| 651 | return 0; |
| 652 | } |
| 653 | |
Giuseppe CAVALLARO | d765955 | 2012-06-27 21:14:37 +0000 | [diff] [blame] | 654 | static int stmmac_ethtool_op_get_eee(struct net_device *dev, |
| 655 | struct ethtool_eee *edata) |
| 656 | { |
| 657 | struct stmmac_priv *priv = netdev_priv(dev); |
| 658 | |
| 659 | if (!priv->dma_cap.eee) |
| 660 | return -EOPNOTSUPP; |
| 661 | |
| 662 | edata->eee_enabled = priv->eee_enabled; |
| 663 | edata->eee_active = priv->eee_active; |
| 664 | edata->tx_lpi_timer = priv->tx_lpi_timer; |
| 665 | |
Philippe Reynes | d6d50c7 | 2016-10-03 08:28:19 +0200 | [diff] [blame] | 666 | return phy_ethtool_get_eee(dev->phydev, edata); |
Giuseppe CAVALLARO | d765955 | 2012-06-27 21:14:37 +0000 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | static int stmmac_ethtool_op_set_eee(struct net_device *dev, |
| 670 | struct ethtool_eee *edata) |
| 671 | { |
| 672 | struct stmmac_priv *priv = netdev_priv(dev); |
| 673 | |
| 674 | priv->eee_enabled = edata->eee_enabled; |
| 675 | |
| 676 | if (!priv->eee_enabled) |
| 677 | stmmac_disable_eee_mode(priv); |
| 678 | else { |
| 679 | /* We are asking for enabling the EEE but it is safe |
| 680 | * to verify all by invoking the eee_init function. |
| 681 | * In case of failure it will return an error. |
| 682 | */ |
| 683 | priv->eee_enabled = stmmac_eee_init(priv); |
| 684 | if (!priv->eee_enabled) |
| 685 | return -EOPNOTSUPP; |
| 686 | |
| 687 | /* Do not change tx_lpi_timer in case of failure */ |
| 688 | priv->tx_lpi_timer = edata->tx_lpi_timer; |
| 689 | } |
| 690 | |
Philippe Reynes | d6d50c7 | 2016-10-03 08:28:19 +0200 | [diff] [blame] | 691 | return phy_ethtool_set_eee(dev->phydev, edata); |
Giuseppe CAVALLARO | d765955 | 2012-06-27 21:14:37 +0000 | [diff] [blame] | 692 | } |
| 693 | |
Giuseppe CAVALLARO | 48f44da | 2012-11-25 23:10:44 +0000 | [diff] [blame] | 694 | static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv) |
| 695 | { |
jpinto | f573c0b | 2017-01-09 12:35:09 +0000 | [diff] [blame] | 696 | unsigned long clk = clk_get_rate(priv->plat->stmmac_clk); |
Giuseppe CAVALLARO | 48f44da | 2012-11-25 23:10:44 +0000 | [diff] [blame] | 697 | |
| 698 | if (!clk) |
| 699 | return 0; |
| 700 | |
| 701 | return (usec * (clk / 1000000)) / 256; |
| 702 | } |
| 703 | |
| 704 | static u32 stmmac_riwt2usec(u32 riwt, struct stmmac_priv *priv) |
| 705 | { |
jpinto | f573c0b | 2017-01-09 12:35:09 +0000 | [diff] [blame] | 706 | unsigned long clk = clk_get_rate(priv->plat->stmmac_clk); |
Giuseppe CAVALLARO | 48f44da | 2012-11-25 23:10:44 +0000 | [diff] [blame] | 707 | |
| 708 | if (!clk) |
| 709 | return 0; |
| 710 | |
| 711 | return (riwt * 256) / (clk / 1000000); |
| 712 | } |
| 713 | |
| 714 | static int stmmac_get_coalesce(struct net_device *dev, |
| 715 | struct ethtool_coalesce *ec) |
| 716 | { |
| 717 | struct stmmac_priv *priv = netdev_priv(dev); |
| 718 | |
| 719 | ec->tx_coalesce_usecs = priv->tx_coal_timer; |
| 720 | ec->tx_max_coalesced_frames = priv->tx_coal_frames; |
| 721 | |
| 722 | if (priv->use_riwt) |
| 723 | ec->rx_coalesce_usecs = stmmac_riwt2usec(priv->rx_riwt, priv); |
| 724 | |
| 725 | return 0; |
| 726 | } |
| 727 | |
| 728 | static int stmmac_set_coalesce(struct net_device *dev, |
| 729 | struct ethtool_coalesce *ec) |
| 730 | { |
| 731 | struct stmmac_priv *priv = netdev_priv(dev); |
Joao Pinto | 3c55d4d | 2017-03-15 11:04:50 +0000 | [diff] [blame] | 732 | u32 rx_cnt = priv->plat->rx_queues_to_use; |
Giuseppe CAVALLARO | 48f44da | 2012-11-25 23:10:44 +0000 | [diff] [blame] | 733 | unsigned int rx_riwt; |
| 734 | |
| 735 | /* Check not supported parameters */ |
| 736 | if ((ec->rx_max_coalesced_frames) || (ec->rx_coalesce_usecs_irq) || |
| 737 | (ec->rx_max_coalesced_frames_irq) || (ec->tx_coalesce_usecs_irq) || |
| 738 | (ec->use_adaptive_rx_coalesce) || (ec->use_adaptive_tx_coalesce) || |
| 739 | (ec->pkt_rate_low) || (ec->rx_coalesce_usecs_low) || |
| 740 | (ec->rx_max_coalesced_frames_low) || (ec->tx_coalesce_usecs_high) || |
| 741 | (ec->tx_max_coalesced_frames_low) || (ec->pkt_rate_high) || |
| 742 | (ec->tx_coalesce_usecs_low) || (ec->rx_coalesce_usecs_high) || |
| 743 | (ec->rx_max_coalesced_frames_high) || |
| 744 | (ec->tx_max_coalesced_frames_irq) || |
| 745 | (ec->stats_block_coalesce_usecs) || |
| 746 | (ec->tx_max_coalesced_frames_high) || (ec->rate_sample_interval)) |
| 747 | return -EOPNOTSUPP; |
| 748 | |
| 749 | if (ec->rx_coalesce_usecs == 0) |
| 750 | return -EINVAL; |
| 751 | |
| 752 | if ((ec->tx_coalesce_usecs == 0) && |
| 753 | (ec->tx_max_coalesced_frames == 0)) |
| 754 | return -EINVAL; |
| 755 | |
Giuseppe CAVALLARO | 9b8d16c | 2014-12-03 12:32:58 +0100 | [diff] [blame] | 756 | if ((ec->tx_coalesce_usecs > STMMAC_MAX_COAL_TX_TICK) || |
Giuseppe CAVALLARO | 48f44da | 2012-11-25 23:10:44 +0000 | [diff] [blame] | 757 | (ec->tx_max_coalesced_frames > STMMAC_TX_MAX_FRAMES)) |
| 758 | return -EINVAL; |
| 759 | |
| 760 | rx_riwt = stmmac_usec2riwt(ec->rx_coalesce_usecs, priv); |
| 761 | |
| 762 | if ((rx_riwt > MAX_DMA_RIWT) || (rx_riwt < MIN_DMA_RIWT)) |
| 763 | return -EINVAL; |
| 764 | else if (!priv->use_riwt) |
| 765 | return -EOPNOTSUPP; |
| 766 | |
| 767 | /* Only copy relevant parameters, ignore all others. */ |
| 768 | priv->tx_coal_frames = ec->tx_max_coalesced_frames; |
| 769 | priv->tx_coal_timer = ec->tx_coalesce_usecs; |
| 770 | priv->rx_riwt = rx_riwt; |
Joao Pinto | 3c55d4d | 2017-03-15 11:04:50 +0000 | [diff] [blame] | 771 | priv->hw->dma->rx_watchdog(priv->ioaddr, priv->rx_riwt, rx_cnt); |
Giuseppe CAVALLARO | 48f44da | 2012-11-25 23:10:44 +0000 | [diff] [blame] | 772 | |
| 773 | return 0; |
| 774 | } |
| 775 | |
Rayagond Kokatanur | 891434b | 2013-03-26 04:43:10 +0000 | [diff] [blame] | 776 | static int stmmac_get_ts_info(struct net_device *dev, |
| 777 | struct ethtool_ts_info *info) |
| 778 | { |
| 779 | struct stmmac_priv *priv = netdev_priv(dev); |
| 780 | |
Phil Reid | e6dbe1e | 2015-10-30 16:43:55 +0800 | [diff] [blame] | 781 | if ((priv->dma_cap.time_stamp || priv->dma_cap.atime_stamp)) { |
Rayagond Kokatanur | 891434b | 2013-03-26 04:43:10 +0000 | [diff] [blame] | 782 | |
Phil Reid | e6dbe1e | 2015-10-30 16:43:55 +0800 | [diff] [blame] | 783 | info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | |
| 784 | SOF_TIMESTAMPING_TX_HARDWARE | |
| 785 | SOF_TIMESTAMPING_RX_SOFTWARE | |
Rayagond Kokatanur | 891434b | 2013-03-26 04:43:10 +0000 | [diff] [blame] | 786 | SOF_TIMESTAMPING_RX_HARDWARE | |
Phil Reid | e6dbe1e | 2015-10-30 16:43:55 +0800 | [diff] [blame] | 787 | SOF_TIMESTAMPING_SOFTWARE | |
Rayagond Kokatanur | 891434b | 2013-03-26 04:43:10 +0000 | [diff] [blame] | 788 | SOF_TIMESTAMPING_RAW_HARDWARE; |
| 789 | |
Rayagond Kokatanur | 92ba688 | 2013-03-26 04:43:11 +0000 | [diff] [blame] | 790 | if (priv->ptp_clock) |
| 791 | info->phc_index = ptp_clock_index(priv->ptp_clock); |
| 792 | |
Rayagond Kokatanur | 891434b | 2013-03-26 04:43:10 +0000 | [diff] [blame] | 793 | info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); |
| 794 | |
| 795 | info->rx_filters = ((1 << HWTSTAMP_FILTER_NONE) | |
| 796 | (1 << HWTSTAMP_FILTER_PTP_V1_L4_EVENT) | |
| 797 | (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) | |
| 798 | (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) | |
| 799 | (1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) | |
| 800 | (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) | |
| 801 | (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) | |
| 802 | (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) | |
| 803 | (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) | |
| 804 | (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) | |
| 805 | (1 << HWTSTAMP_FILTER_ALL)); |
| 806 | return 0; |
| 807 | } else |
| 808 | return ethtool_op_get_ts_info(dev, info); |
| 809 | } |
| 810 | |
Giuseppe Cavallaro | 22ad383 | 2016-02-29 14:27:41 +0100 | [diff] [blame] | 811 | static int stmmac_get_tunable(struct net_device *dev, |
| 812 | const struct ethtool_tunable *tuna, void *data) |
| 813 | { |
| 814 | struct stmmac_priv *priv = netdev_priv(dev); |
| 815 | int ret = 0; |
| 816 | |
| 817 | switch (tuna->id) { |
| 818 | case ETHTOOL_RX_COPYBREAK: |
| 819 | *(u32 *)data = priv->rx_copybreak; |
| 820 | break; |
| 821 | default: |
| 822 | ret = -EINVAL; |
| 823 | break; |
| 824 | } |
| 825 | |
| 826 | return ret; |
| 827 | } |
| 828 | |
| 829 | static int stmmac_set_tunable(struct net_device *dev, |
| 830 | const struct ethtool_tunable *tuna, |
| 831 | const void *data) |
| 832 | { |
| 833 | struct stmmac_priv *priv = netdev_priv(dev); |
| 834 | int ret = 0; |
| 835 | |
| 836 | switch (tuna->id) { |
| 837 | case ETHTOOL_RX_COPYBREAK: |
| 838 | priv->rx_copybreak = *(u32 *)data; |
| 839 | break; |
| 840 | default: |
| 841 | ret = -EINVAL; |
| 842 | break; |
| 843 | } |
| 844 | |
| 845 | return ret; |
| 846 | } |
| 847 | |
stephen hemminger | 9b07be4 | 2012-01-04 12:59:49 +0000 | [diff] [blame] | 848 | static const struct ethtool_ops stmmac_ethtool_ops = { |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 849 | .begin = stmmac_check_if_running, |
| 850 | .get_drvinfo = stmmac_ethtool_getdrvinfo, |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 851 | .get_msglevel = stmmac_ethtool_getmsglevel, |
| 852 | .set_msglevel = stmmac_ethtool_setmsglevel, |
| 853 | .get_regs = stmmac_ethtool_gregs, |
| 854 | .get_regs_len = stmmac_ethtool_get_regs_len, |
| 855 | .get_link = ethtool_op_get_link, |
Florian Fainelli | cab247e | 2016-11-15 11:19:45 -0800 | [diff] [blame] | 856 | .nway_reset = phy_ethtool_nway_reset, |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 857 | .get_pauseparam = stmmac_get_pauseparam, |
| 858 | .set_pauseparam = stmmac_set_pauseparam, |
| 859 | .get_ethtool_stats = stmmac_get_ethtool_stats, |
| 860 | .get_strings = stmmac_get_strings, |
| 861 | .get_wol = stmmac_get_wol, |
| 862 | .set_wol = stmmac_set_wol, |
Giuseppe CAVALLARO | d765955 | 2012-06-27 21:14:37 +0000 | [diff] [blame] | 863 | .get_eee = stmmac_ethtool_op_get_eee, |
| 864 | .set_eee = stmmac_ethtool_op_set_eee, |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 865 | .get_sset_count = stmmac_get_sset_count, |
Rayagond Kokatanur | 891434b | 2013-03-26 04:43:10 +0000 | [diff] [blame] | 866 | .get_ts_info = stmmac_get_ts_info, |
Giuseppe CAVALLARO | 48f44da | 2012-11-25 23:10:44 +0000 | [diff] [blame] | 867 | .get_coalesce = stmmac_get_coalesce, |
| 868 | .set_coalesce = stmmac_set_coalesce, |
Giuseppe Cavallaro | 22ad383 | 2016-02-29 14:27:41 +0100 | [diff] [blame] | 869 | .get_tunable = stmmac_get_tunable, |
| 870 | .set_tunable = stmmac_set_tunable, |
Philippe Reynes | 1685e78 | 2016-10-03 08:28:20 +0200 | [diff] [blame] | 871 | .get_link_ksettings = stmmac_ethtool_get_link_ksettings, |
| 872 | .set_link_ksettings = stmmac_ethtool_set_link_ksettings, |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 873 | }; |
| 874 | |
| 875 | void stmmac_set_ethtool_ops(struct net_device *netdev) |
| 876 | { |
Wilfried Klaebe | 7ad24ea | 2014-05-11 00:12:32 +0000 | [diff] [blame] | 877 | netdev->ethtool_ops = &stmmac_ethtool_ops; |
Giuseppe Cavallaro | 47dd7a5 | 2009-10-14 15:13:45 -0700 | [diff] [blame] | 878 | } |