Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1 | /* |
Vasundhara Volam | 4026382 | 2014-02-12 16:09:07 +0530 | [diff] [blame] | 2 | * Copyright (C) 2005 - 2014 Emulex |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 3 | * All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License version 2 |
| 7 | * as published by the Free Software Foundation. The full GNU General |
| 8 | * Public License is included in this distribution in the file called COPYING. |
| 9 | * |
| 10 | * Contact Information: |
Ajit Khaparde | d2145cd | 2011-03-16 08:20:46 +0000 | [diff] [blame] | 11 | * linux-drivers@emulex.com |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 12 | * |
Ajit Khaparde | d2145cd | 2011-03-16 08:20:46 +0000 | [diff] [blame] | 13 | * Emulex |
| 14 | * 3333 Susan Street |
| 15 | * Costa Mesa, CA 92626 |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 16 | */ |
| 17 | |
| 18 | #include "be.h" |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 19 | #include "be_cmds.h" |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 20 | #include <linux/ethtool.h> |
| 21 | |
| 22 | struct be_ethtool_stat { |
| 23 | char desc[ETH_GSTRING_LEN]; |
| 24 | int type; |
| 25 | int size; |
| 26 | int offset; |
| 27 | }; |
| 28 | |
Sathya Perla | ac124ff | 2011-07-25 19:10:14 +0000 | [diff] [blame] | 29 | enum {DRVSTAT_TX, DRVSTAT_RX, DRVSTAT}; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 30 | #define FIELDINFO(_struct, field) FIELD_SIZEOF(_struct, field), \ |
| 31 | offsetof(_struct, field) |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 32 | #define DRVSTAT_TX_INFO(field) #field, DRVSTAT_TX,\ |
| 33 | FIELDINFO(struct be_tx_stats, field) |
| 34 | #define DRVSTAT_RX_INFO(field) #field, DRVSTAT_RX,\ |
| 35 | FIELDINFO(struct be_rx_stats, field) |
Ajit Khaparde | 609ff3b | 2011-02-20 11:42:07 +0000 | [diff] [blame] | 36 | #define DRVSTAT_INFO(field) #field, DRVSTAT,\ |
Sathya Perla | ac124ff | 2011-07-25 19:10:14 +0000 | [diff] [blame] | 37 | FIELDINFO(struct be_drv_stats, field) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 38 | |
| 39 | static const struct be_ethtool_stat et_stats[] = { |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 40 | {DRVSTAT_INFO(rx_crc_errors)}, |
| 41 | {DRVSTAT_INFO(rx_alignment_symbol_errors)}, |
| 42 | {DRVSTAT_INFO(rx_pause_frames)}, |
| 43 | {DRVSTAT_INFO(rx_control_frames)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 44 | /* Received packets dropped when the Ethernet length field |
| 45 | * is not equal to the actual Ethernet data length. |
| 46 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 47 | {DRVSTAT_INFO(rx_in_range_errors)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 48 | /* Received packets dropped when their length field is >= 1501 bytes |
| 49 | * and <= 1535 bytes. |
| 50 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 51 | {DRVSTAT_INFO(rx_out_range_errors)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 52 | /* Received packets dropped when they are longer than 9216 bytes */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 53 | {DRVSTAT_INFO(rx_frame_too_long)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 54 | /* Received packets dropped when they don't pass the unicast or |
| 55 | * multicast address filtering. |
| 56 | */ |
Suresh Reddy | 18fb06a | 2013-04-25 23:03:21 +0000 | [diff] [blame] | 57 | {DRVSTAT_INFO(rx_address_filtered)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 58 | /* Received packets dropped when IP packet length field is less than |
| 59 | * the IP header length field. |
| 60 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 61 | {DRVSTAT_INFO(rx_dropped_too_small)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 62 | /* Received packets dropped when IP length field is greater than |
| 63 | * the actual packet length. |
| 64 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 65 | {DRVSTAT_INFO(rx_dropped_too_short)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 66 | /* Received packets dropped when the IP header length field is less |
| 67 | * than 5. |
| 68 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 69 | {DRVSTAT_INFO(rx_dropped_header_too_small)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 70 | /* Received packets dropped when the TCP header length field is less |
| 71 | * than 5 or the TCP header length + IP header length is more |
| 72 | * than IP packet length. |
| 73 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 74 | {DRVSTAT_INFO(rx_dropped_tcp_length)}, |
| 75 | {DRVSTAT_INFO(rx_dropped_runt)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 76 | /* Number of received packets dropped when a fifo for descriptors going |
| 77 | * into the packet demux block overflows. In normal operation, this |
| 78 | * fifo must never overflow. |
| 79 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 80 | {DRVSTAT_INFO(rxpp_fifo_overflow_drop)}, |
| 81 | {DRVSTAT_INFO(rx_input_fifo_overflow_drop)}, |
| 82 | {DRVSTAT_INFO(rx_ip_checksum_errs)}, |
| 83 | {DRVSTAT_INFO(rx_tcp_checksum_errs)}, |
| 84 | {DRVSTAT_INFO(rx_udp_checksum_errs)}, |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 85 | {DRVSTAT_INFO(tx_pauseframes)}, |
| 86 | {DRVSTAT_INFO(tx_controlframes)}, |
| 87 | {DRVSTAT_INFO(rx_priority_pause_frames)}, |
Ajit Khaparde | b5adffc4 | 2013-05-01 09:38:00 +0000 | [diff] [blame] | 88 | {DRVSTAT_INFO(tx_priority_pauseframes)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 89 | /* Received packets dropped when an internal fifo going into |
| 90 | * main packet buffer tank (PMEM) overflows. |
| 91 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 92 | {DRVSTAT_INFO(pmem_fifo_overflow_drop)}, |
| 93 | {DRVSTAT_INFO(jabber_events)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 94 | /* Received packets dropped due to lack of available HW packet buffers |
| 95 | * used to temporarily hold the received packets. |
| 96 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 97 | {DRVSTAT_INFO(rx_drops_no_pbuf)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 98 | /* Received packets dropped due to input receive buffer |
| 99 | * descriptor fifo overflowing. |
| 100 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 101 | {DRVSTAT_INFO(rx_drops_no_erx_descr)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 102 | /* Packets dropped because the internal FIFO to the offloaded TCP |
| 103 | * receive processing block is full. This could happen only for |
| 104 | * offloaded iSCSI or FCoE trarffic. |
| 105 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 106 | {DRVSTAT_INFO(rx_drops_no_tpre_descr)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 107 | /* Received packets dropped when they need more than 8 |
| 108 | * receive buffers. This cannot happen as the driver configures |
| 109 | * 2048 byte receive buffers. |
| 110 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 111 | {DRVSTAT_INFO(rx_drops_too_many_frags)}, |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 112 | {DRVSTAT_INFO(forwarded_packets)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 113 | /* Received packets dropped when the frame length |
| 114 | * is more than 9018 bytes |
| 115 | */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 116 | {DRVSTAT_INFO(rx_drops_mtu)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 117 | /* Number of packets dropped due to random early drop function */ |
Ajit Khaparde | 89a88ab | 2011-05-16 07:36:18 +0000 | [diff] [blame] | 118 | {DRVSTAT_INFO(eth_red_drops)}, |
Ajit Khaparde | 461ae37 | 2013-10-03 16:16:50 -0500 | [diff] [blame] | 119 | {DRVSTAT_INFO(be_on_die_temperature)}, |
| 120 | {DRVSTAT_INFO(rx_roce_bytes_lsd)}, |
| 121 | {DRVSTAT_INFO(rx_roce_bytes_msd)}, |
| 122 | {DRVSTAT_INFO(rx_roce_frames)}, |
| 123 | {DRVSTAT_INFO(roce_drops_payload_len)}, |
| 124 | {DRVSTAT_INFO(roce_drops_crc)} |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 125 | }; |
| 126 | #define ETHTOOL_STATS_NUM ARRAY_SIZE(et_stats) |
| 127 | |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 128 | /* Stats related to multi RX queues: get_stats routine assumes bytes, pkts |
| 129 | * are first and second members respectively. |
| 130 | */ |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 131 | static const struct be_ethtool_stat et_rx_stats[] = { |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 132 | {DRVSTAT_RX_INFO(rx_bytes)},/* If moving this member see above note */ |
| 133 | {DRVSTAT_RX_INFO(rx_pkts)}, /* If moving this member see above note */ |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 134 | {DRVSTAT_RX_INFO(rx_compl)}, |
Kalesh AP | 5c29c09 | 2014-05-09 13:29:18 +0530 | [diff] [blame] | 135 | {DRVSTAT_RX_INFO(rx_compl_err)}, |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 136 | {DRVSTAT_RX_INFO(rx_mcast_pkts)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 137 | /* Number of page allocation failures while posting receive buffers |
| 138 | * to HW. |
| 139 | */ |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 140 | {DRVSTAT_RX_INFO(rx_post_fail)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 141 | /* Recevied packets dropped due to skb allocation failure */ |
Sathya Perla | ac124ff | 2011-07-25 19:10:14 +0000 | [diff] [blame] | 142 | {DRVSTAT_RX_INFO(rx_drops_no_skbs)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 143 | /* Received packets dropped due to lack of available fetched buffers |
| 144 | * posted by the driver. |
| 145 | */ |
Sathya Perla | ac124ff | 2011-07-25 19:10:14 +0000 | [diff] [blame] | 146 | {DRVSTAT_RX_INFO(rx_drops_no_frags)} |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 147 | }; |
| 148 | #define ETHTOOL_RXSTATS_NUM (ARRAY_SIZE(et_rx_stats)) |
| 149 | |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 150 | /* Stats related to multi TX queues: get_stats routine assumes compl is the |
| 151 | * first member |
| 152 | */ |
Sathya Perla | 3c8def9 | 2011-06-12 20:01:58 +0000 | [diff] [blame] | 153 | static const struct be_ethtool_stat et_tx_stats[] = { |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 154 | {DRVSTAT_TX_INFO(tx_compl)}, /* If moving this member see above note */ |
Sathya Perla | ac124ff | 2011-07-25 19:10:14 +0000 | [diff] [blame] | 155 | {DRVSTAT_TX_INFO(tx_bytes)}, |
| 156 | {DRVSTAT_TX_INFO(tx_pkts)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 157 | /* Number of skbs queued for trasmission by the driver */ |
Sathya Perla | ac124ff | 2011-07-25 19:10:14 +0000 | [diff] [blame] | 158 | {DRVSTAT_TX_INFO(tx_reqs)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 159 | /* Number of TX work request blocks DMAed to HW */ |
Sathya Perla | ac124ff | 2011-07-25 19:10:14 +0000 | [diff] [blame] | 160 | {DRVSTAT_TX_INFO(tx_wrbs)}, |
Sathya Perla | d45b9d3 | 2012-01-29 20:17:39 +0000 | [diff] [blame] | 161 | /* Number of times the TX queue was stopped due to lack |
| 162 | * of spaces in the TXQ. |
| 163 | */ |
Sathya Perla | bc61752 | 2013-10-01 16:00:01 +0530 | [diff] [blame] | 164 | {DRVSTAT_TX_INFO(tx_stops)}, |
| 165 | /* Pkts dropped in the driver's transmit path */ |
| 166 | {DRVSTAT_TX_INFO(tx_drv_drops)} |
Sathya Perla | 3c8def9 | 2011-06-12 20:01:58 +0000 | [diff] [blame] | 167 | }; |
| 168 | #define ETHTOOL_TXSTATS_NUM (ARRAY_SIZE(et_tx_stats)) |
| 169 | |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 170 | static const char et_self_tests[][ETH_GSTRING_LEN] = { |
| 171 | "MAC Loopback test", |
| 172 | "PHY Loopback test", |
| 173 | "External Loopback test", |
Ajit Khaparde | 4ee7721 | 2011-02-20 11:41:20 +0000 | [diff] [blame] | 174 | "DDR DMA test", |
Sarveshwar Bandi | 4276e47 | 2010-01-19 05:15:36 +0000 | [diff] [blame] | 175 | "Link test" |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 176 | }; |
| 177 | |
| 178 | #define ETHTOOL_TESTS_NUM ARRAY_SIZE(et_self_tests) |
| 179 | #define BE_MAC_LOOPBACK 0x0 |
| 180 | #define BE_PHY_LOOPBACK 0x1 |
| 181 | #define BE_ONE_PORT_EXT_LOOPBACK 0x2 |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 182 | #define BE_NO_LOOPBACK 0xff |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 183 | |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 184 | static void be_get_drvinfo(struct net_device *netdev, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 185 | struct ethtool_drvinfo *drvinfo) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 186 | { |
| 187 | struct be_adapter *adapter = netdev_priv(netdev); |
| 188 | |
Rick Jones | 68aad78 | 2011-11-07 13:29:27 +0000 | [diff] [blame] | 189 | strlcpy(drvinfo->driver, DRV_NAME, sizeof(drvinfo->driver)); |
| 190 | strlcpy(drvinfo->version, DRV_VER, sizeof(drvinfo->version)); |
Somnath Kotur | eeb65ce | 2013-05-26 21:08:36 +0000 | [diff] [blame] | 191 | if (!memcmp(adapter->fw_ver, adapter->fw_on_flash, FW_VER_LEN)) |
Jiri Pirko | 7826d43 | 2013-01-06 00:44:26 +0000 | [diff] [blame] | 192 | strlcpy(drvinfo->fw_version, adapter->fw_ver, |
| 193 | sizeof(drvinfo->fw_version)); |
| 194 | else |
| 195 | snprintf(drvinfo->fw_version, sizeof(drvinfo->fw_version), |
Somnath Kotur | eeb65ce | 2013-05-26 21:08:36 +0000 | [diff] [blame] | 196 | "%s [%s]", adapter->fw_ver, adapter->fw_on_flash); |
Sathya Perla | 04b7117 | 2011-09-27 13:30:27 -0400 | [diff] [blame] | 197 | |
Rick Jones | 68aad78 | 2011-11-07 13:29:27 +0000 | [diff] [blame] | 198 | strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), |
| 199 | sizeof(drvinfo->bus_info)); |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 200 | drvinfo->testinfo_len = 0; |
| 201 | drvinfo->regdump_len = 0; |
| 202 | drvinfo->eedump_len = 0; |
| 203 | } |
| 204 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 205 | static u32 lancer_cmd_get_file_len(struct be_adapter *adapter, u8 *file_name) |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 206 | { |
| 207 | u32 data_read = 0, eof; |
| 208 | u8 addn_status; |
| 209 | struct be_dma_mem data_len_cmd; |
| 210 | int status; |
| 211 | |
| 212 | memset(&data_len_cmd, 0, sizeof(data_len_cmd)); |
| 213 | /* data_offset and data_size should be 0 to get reg len */ |
| 214 | status = lancer_cmd_read_object(adapter, &data_len_cmd, 0, 0, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 215 | file_name, &data_read, &eof, |
| 216 | &addn_status); |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 217 | |
| 218 | return data_read; |
| 219 | } |
| 220 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 221 | static int lancer_cmd_read_file(struct be_adapter *adapter, u8 *file_name, |
| 222 | u32 buf_len, void *buf) |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 223 | { |
| 224 | struct be_dma_mem read_cmd; |
| 225 | u32 read_len = 0, total_read_len = 0, chunk_size; |
| 226 | u32 eof = 0; |
| 227 | u8 addn_status; |
| 228 | int status = 0; |
| 229 | |
| 230 | read_cmd.size = LANCER_READ_FILE_CHUNK; |
| 231 | read_cmd.va = pci_alloc_consistent(adapter->pdev, read_cmd.size, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 232 | &read_cmd.dma); |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 233 | |
| 234 | if (!read_cmd.va) { |
| 235 | dev_err(&adapter->pdev->dev, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 236 | "Memory allocation failure while reading dump\n"); |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 237 | return -ENOMEM; |
| 238 | } |
| 239 | |
| 240 | while ((total_read_len < buf_len) && !eof) { |
| 241 | chunk_size = min_t(u32, (buf_len - total_read_len), |
| 242 | LANCER_READ_FILE_CHUNK); |
| 243 | chunk_size = ALIGN(chunk_size, 4); |
| 244 | status = lancer_cmd_read_object(adapter, &read_cmd, chunk_size, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 245 | total_read_len, file_name, |
| 246 | &read_len, &eof, &addn_status); |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 247 | if (!status) { |
| 248 | memcpy(buf + total_read_len, read_cmd.va, read_len); |
| 249 | total_read_len += read_len; |
| 250 | eof &= LANCER_READ_FILE_EOF_MASK; |
| 251 | } else { |
| 252 | status = -EIO; |
| 253 | break; |
| 254 | } |
| 255 | } |
| 256 | pci_free_consistent(adapter->pdev, read_cmd.size, read_cmd.va, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 257 | read_cmd.dma); |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 258 | |
| 259 | return status; |
| 260 | } |
| 261 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 262 | static int be_get_reg_len(struct net_device *netdev) |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 263 | { |
| 264 | struct be_adapter *adapter = netdev_priv(netdev); |
| 265 | u32 log_size = 0; |
| 266 | |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 267 | if (!check_privilege(adapter, MAX_PRIVILEGES)) |
| 268 | return 0; |
| 269 | |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 270 | if (be_physfn(adapter)) { |
| 271 | if (lancer_chip(adapter)) |
| 272 | log_size = lancer_cmd_get_file_len(adapter, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 273 | LANCER_FW_DUMP_FILE); |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 274 | else |
| 275 | be_cmd_get_reg_len(adapter, &log_size); |
| 276 | } |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 277 | return log_size; |
| 278 | } |
| 279 | |
| 280 | static void |
| 281 | be_get_regs(struct net_device *netdev, struct ethtool_regs *regs, void *buf) |
| 282 | { |
| 283 | struct be_adapter *adapter = netdev_priv(netdev); |
| 284 | |
Ajit Khaparde | 16a871e | 2011-04-19 12:10:43 +0000 | [diff] [blame] | 285 | if (be_physfn(adapter)) { |
| 286 | memset(buf, 0, regs->len); |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 287 | if (lancer_chip(adapter)) |
| 288 | lancer_cmd_read_file(adapter, LANCER_FW_DUMP_FILE, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 289 | regs->len, buf); |
Padmanabh Ratnakar | de49bd5 | 2011-11-16 02:02:43 +0000 | [diff] [blame] | 290 | else |
| 291 | be_cmd_get_regs(adapter, regs->len, buf); |
Ajit Khaparde | 16a871e | 2011-04-19 12:10:43 +0000 | [diff] [blame] | 292 | } |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 295 | static int be_get_coalesce(struct net_device *netdev, |
| 296 | struct ethtool_coalesce *et) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 297 | { |
| 298 | struct be_adapter *adapter = netdev_priv(netdev); |
Sathya Perla | 2632baf | 2013-10-01 16:00:00 +0530 | [diff] [blame] | 299 | struct be_aic_obj *aic = &adapter->aic_obj[0]; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 300 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 301 | |
Sathya Perla | 2632baf | 2013-10-01 16:00:00 +0530 | [diff] [blame] | 302 | et->rx_coalesce_usecs = aic->prev_eqd; |
| 303 | et->rx_coalesce_usecs_high = aic->max_eqd; |
| 304 | et->rx_coalesce_usecs_low = aic->min_eqd; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 305 | |
Sathya Perla | 2632baf | 2013-10-01 16:00:00 +0530 | [diff] [blame] | 306 | et->tx_coalesce_usecs = aic->prev_eqd; |
| 307 | et->tx_coalesce_usecs_high = aic->max_eqd; |
| 308 | et->tx_coalesce_usecs_low = aic->min_eqd; |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 309 | |
Sathya Perla | 2632baf | 2013-10-01 16:00:00 +0530 | [diff] [blame] | 310 | et->use_adaptive_rx_coalesce = aic->enable; |
| 311 | et->use_adaptive_tx_coalesce = aic->enable; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 312 | |
| 313 | return 0; |
| 314 | } |
| 315 | |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 316 | /* TX attributes are ignored. Only RX attributes are considered |
| 317 | * eqd cmd is issued in the worker thread. |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 318 | */ |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 319 | static int be_set_coalesce(struct net_device *netdev, |
| 320 | struct ethtool_coalesce *et) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 321 | { |
| 322 | struct be_adapter *adapter = netdev_priv(netdev); |
Sathya Perla | 2632baf | 2013-10-01 16:00:00 +0530 | [diff] [blame] | 323 | struct be_aic_obj *aic = &adapter->aic_obj[0]; |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 324 | struct be_eq_obj *eqo; |
| 325 | int i; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 326 | |
Sathya Perla | 10ef9ab | 2012-02-09 18:05:27 +0000 | [diff] [blame] | 327 | for_all_evt_queues(adapter, eqo, i) { |
Sathya Perla | 2632baf | 2013-10-01 16:00:00 +0530 | [diff] [blame] | 328 | aic->enable = et->use_adaptive_rx_coalesce; |
| 329 | aic->max_eqd = min(et->rx_coalesce_usecs_high, BE_MAX_EQD); |
| 330 | aic->min_eqd = min(et->rx_coalesce_usecs_low, aic->max_eqd); |
| 331 | aic->et_eqd = min(et->rx_coalesce_usecs, aic->max_eqd); |
| 332 | aic->et_eqd = max(aic->et_eqd, aic->min_eqd); |
| 333 | aic++; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 334 | } |
| 335 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 336 | return 0; |
| 337 | } |
| 338 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 339 | static void be_get_ethtool_stats(struct net_device *netdev, |
| 340 | struct ethtool_stats *stats, uint64_t *data) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 341 | { |
| 342 | struct be_adapter *adapter = netdev_priv(netdev); |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 343 | struct be_rx_obj *rxo; |
Sathya Perla | 3c8def9 | 2011-06-12 20:01:58 +0000 | [diff] [blame] | 344 | struct be_tx_obj *txo; |
Sathya Perla | ac124ff | 2011-07-25 19:10:14 +0000 | [diff] [blame] | 345 | void *p; |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 346 | unsigned int i, j, base = 0, start; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 347 | |
| 348 | for (i = 0; i < ETHTOOL_STATS_NUM; i++) { |
Sathya Perla | ac124ff | 2011-07-25 19:10:14 +0000 | [diff] [blame] | 349 | p = (u8 *)&adapter->drv_stats + et_stats[i].offset; |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 350 | data[i] = *(u32 *)p; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 351 | } |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 352 | base += ETHTOOL_STATS_NUM; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 353 | |
| 354 | for_all_rx_queues(adapter, rxo, j) { |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 355 | struct be_rx_stats *stats = rx_stats(rxo); |
| 356 | |
| 357 | do { |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 358 | start = u64_stats_fetch_begin_irq(&stats->sync); |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 359 | data[base] = stats->rx_bytes; |
| 360 | data[base + 1] = stats->rx_pkts; |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 361 | } while (u64_stats_fetch_retry_irq(&stats->sync, start)); |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 362 | |
| 363 | for (i = 2; i < ETHTOOL_RXSTATS_NUM; i++) { |
| 364 | p = (u8 *)stats + et_rx_stats[i].offset; |
| 365 | data[base + i] = *(u32 *)p; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 366 | } |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 367 | base += ETHTOOL_RXSTATS_NUM; |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 368 | } |
Sathya Perla | 3c8def9 | 2011-06-12 20:01:58 +0000 | [diff] [blame] | 369 | |
Sathya Perla | 3c8def9 | 2011-06-12 20:01:58 +0000 | [diff] [blame] | 370 | for_all_tx_queues(adapter, txo, j) { |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 371 | struct be_tx_stats *stats = tx_stats(txo); |
| 372 | |
| 373 | do { |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 374 | start = u64_stats_fetch_begin_irq(&stats->sync_compl); |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 375 | data[base] = stats->tx_compl; |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 376 | } while (u64_stats_fetch_retry_irq(&stats->sync_compl, start)); |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 377 | |
| 378 | do { |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 379 | start = u64_stats_fetch_begin_irq(&stats->sync); |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 380 | for (i = 1; i < ETHTOOL_TXSTATS_NUM; i++) { |
| 381 | p = (u8 *)stats + et_tx_stats[i].offset; |
| 382 | data[base + i] = |
| 383 | (et_tx_stats[i].size == sizeof(u64)) ? |
| 384 | *(u64 *)p : *(u32 *)p; |
| 385 | } |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 386 | } while (u64_stats_fetch_retry_irq(&stats->sync, start)); |
Sathya Perla | ab1594e | 2011-07-25 19:10:15 +0000 | [diff] [blame] | 387 | base += ETHTOOL_TXSTATS_NUM; |
Sathya Perla | 3c8def9 | 2011-06-12 20:01:58 +0000 | [diff] [blame] | 388 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 391 | static void be_get_stat_strings(struct net_device *netdev, uint32_t stringset, |
| 392 | uint8_t *data) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 393 | { |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 394 | struct be_adapter *adapter = netdev_priv(netdev); |
| 395 | int i, j; |
| 396 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 397 | switch (stringset) { |
| 398 | case ETH_SS_STATS: |
| 399 | for (i = 0; i < ETHTOOL_STATS_NUM; i++) { |
| 400 | memcpy(data, et_stats[i].desc, ETH_GSTRING_LEN); |
| 401 | data += ETH_GSTRING_LEN; |
| 402 | } |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 403 | for (i = 0; i < adapter->num_rx_qs; i++) { |
| 404 | for (j = 0; j < ETHTOOL_RXSTATS_NUM; j++) { |
| 405 | sprintf(data, "rxq%d: %s", i, |
| 406 | et_rx_stats[j].desc); |
| 407 | data += ETH_GSTRING_LEN; |
| 408 | } |
| 409 | } |
Sathya Perla | 3c8def9 | 2011-06-12 20:01:58 +0000 | [diff] [blame] | 410 | for (i = 0; i < adapter->num_tx_qs; i++) { |
| 411 | for (j = 0; j < ETHTOOL_TXSTATS_NUM; j++) { |
| 412 | sprintf(data, "txq%d: %s", i, |
| 413 | et_tx_stats[j].desc); |
| 414 | data += ETH_GSTRING_LEN; |
| 415 | } |
| 416 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 417 | break; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 418 | case ETH_SS_TEST: |
| 419 | for (i = 0; i < ETHTOOL_TESTS_NUM; i++) { |
| 420 | memcpy(data, et_self_tests[i], ETH_GSTRING_LEN); |
| 421 | data += ETH_GSTRING_LEN; |
| 422 | } |
| 423 | break; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 424 | } |
| 425 | } |
| 426 | |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 427 | static int be_get_sset_count(struct net_device *netdev, int stringset) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 428 | { |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 429 | struct be_adapter *adapter = netdev_priv(netdev); |
| 430 | |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 431 | switch (stringset) { |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 432 | case ETH_SS_TEST: |
| 433 | return ETHTOOL_TESTS_NUM; |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 434 | case ETH_SS_STATS: |
Sathya Perla | 3abcded | 2010-10-03 22:12:27 -0700 | [diff] [blame] | 435 | return ETHTOOL_STATS_NUM + |
Sathya Perla | 3c8def9 | 2011-06-12 20:01:58 +0000 | [diff] [blame] | 436 | adapter->num_rx_qs * ETHTOOL_RXSTATS_NUM + |
| 437 | adapter->num_tx_qs * ETHTOOL_TXSTATS_NUM; |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 438 | default: |
| 439 | return -EINVAL; |
| 440 | } |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 441 | } |
| 442 | |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 443 | static u32 be_get_port_type(u32 phy_type, u32 dac_cable_len) |
| 444 | { |
| 445 | u32 port; |
| 446 | |
| 447 | switch (phy_type) { |
| 448 | case PHY_TYPE_BASET_1GB: |
| 449 | case PHY_TYPE_BASEX_1GB: |
| 450 | case PHY_TYPE_SGMII: |
| 451 | port = PORT_TP; |
| 452 | break; |
| 453 | case PHY_TYPE_SFP_PLUS_10GB: |
| 454 | port = dac_cable_len ? PORT_DA : PORT_FIBRE; |
| 455 | break; |
| 456 | case PHY_TYPE_XFP_10GB: |
| 457 | case PHY_TYPE_SFP_1GB: |
| 458 | port = PORT_FIBRE; |
| 459 | break; |
| 460 | case PHY_TYPE_BASET_10GB: |
| 461 | port = PORT_TP; |
| 462 | break; |
| 463 | default: |
| 464 | port = PORT_OTHER; |
| 465 | } |
| 466 | |
| 467 | return port; |
| 468 | } |
| 469 | |
| 470 | static u32 convert_to_et_setting(u32 if_type, u32 if_speeds) |
| 471 | { |
| 472 | u32 val = 0; |
| 473 | |
| 474 | switch (if_type) { |
| 475 | case PHY_TYPE_BASET_1GB: |
| 476 | case PHY_TYPE_BASEX_1GB: |
| 477 | case PHY_TYPE_SGMII: |
| 478 | val |= SUPPORTED_TP; |
| 479 | if (if_speeds & BE_SUPPORTED_SPEED_1GBPS) |
| 480 | val |= SUPPORTED_1000baseT_Full; |
| 481 | if (if_speeds & BE_SUPPORTED_SPEED_100MBPS) |
| 482 | val |= SUPPORTED_100baseT_Full; |
| 483 | if (if_speeds & BE_SUPPORTED_SPEED_10MBPS) |
| 484 | val |= SUPPORTED_10baseT_Full; |
| 485 | break; |
| 486 | case PHY_TYPE_KX4_10GB: |
| 487 | val |= SUPPORTED_Backplane; |
| 488 | if (if_speeds & BE_SUPPORTED_SPEED_1GBPS) |
| 489 | val |= SUPPORTED_1000baseKX_Full; |
| 490 | if (if_speeds & BE_SUPPORTED_SPEED_10GBPS) |
| 491 | val |= SUPPORTED_10000baseKX4_Full; |
| 492 | break; |
| 493 | case PHY_TYPE_KR_10GB: |
| 494 | val |= SUPPORTED_Backplane | |
| 495 | SUPPORTED_10000baseKR_Full; |
| 496 | break; |
| 497 | case PHY_TYPE_SFP_PLUS_10GB: |
| 498 | case PHY_TYPE_XFP_10GB: |
| 499 | case PHY_TYPE_SFP_1GB: |
| 500 | val |= SUPPORTED_FIBRE; |
| 501 | if (if_speeds & BE_SUPPORTED_SPEED_10GBPS) |
| 502 | val |= SUPPORTED_10000baseT_Full; |
| 503 | if (if_speeds & BE_SUPPORTED_SPEED_1GBPS) |
| 504 | val |= SUPPORTED_1000baseT_Full; |
| 505 | break; |
| 506 | case PHY_TYPE_BASET_10GB: |
| 507 | val |= SUPPORTED_TP; |
| 508 | if (if_speeds & BE_SUPPORTED_SPEED_10GBPS) |
| 509 | val |= SUPPORTED_10000baseT_Full; |
| 510 | if (if_speeds & BE_SUPPORTED_SPEED_1GBPS) |
| 511 | val |= SUPPORTED_1000baseT_Full; |
| 512 | if (if_speeds & BE_SUPPORTED_SPEED_100MBPS) |
| 513 | val |= SUPPORTED_100baseT_Full; |
| 514 | break; |
| 515 | default: |
| 516 | val |= SUPPORTED_TP; |
| 517 | } |
| 518 | |
| 519 | return val; |
| 520 | } |
| 521 | |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 522 | bool be_pause_supported(struct be_adapter *adapter) |
| 523 | { |
| 524 | return (adapter->phy.interface_type == PHY_TYPE_SFP_PLUS_10GB || |
| 525 | adapter->phy.interface_type == PHY_TYPE_XFP_10GB) ? |
| 526 | false : true; |
| 527 | } |
| 528 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 529 | static int be_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) |
| 530 | { |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 531 | struct be_adapter *adapter = netdev_priv(netdev); |
Ajit Khaparde | b236916a | 2011-12-30 12:15:40 +0000 | [diff] [blame] | 532 | u8 link_status; |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 533 | u16 link_speed = 0; |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 534 | int status; |
Padmanabh Ratnakar | db15dfa | 2012-10-20 06:03:04 +0000 | [diff] [blame] | 535 | u32 auto_speeds; |
| 536 | u32 fixed_speeds; |
| 537 | u32 dac_cable_len; |
| 538 | u16 interface_type; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 539 | |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 540 | if (adapter->phy.link_speed < 0) { |
| 541 | status = be_cmd_link_status_query(adapter, &link_speed, |
| 542 | &link_status, 0); |
| 543 | if (!status) |
| 544 | be_link_status_update(adapter, link_status); |
| 545 | ethtool_cmd_speed_set(ecmd, link_speed); |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 546 | |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 547 | status = be_cmd_get_phy_info(adapter); |
Padmanabh Ratnakar | db15dfa | 2012-10-20 06:03:04 +0000 | [diff] [blame] | 548 | if (!status) { |
| 549 | interface_type = adapter->phy.interface_type; |
| 550 | auto_speeds = adapter->phy.auto_speeds_supported; |
| 551 | fixed_speeds = adapter->phy.fixed_speeds_supported; |
| 552 | dac_cable_len = adapter->phy.dac_cable_len; |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 553 | |
Padmanabh Ratnakar | db15dfa | 2012-10-20 06:03:04 +0000 | [diff] [blame] | 554 | ecmd->supported = |
| 555 | convert_to_et_setting(interface_type, |
| 556 | auto_speeds | |
| 557 | fixed_speeds); |
| 558 | ecmd->advertising = |
| 559 | convert_to_et_setting(interface_type, |
| 560 | auto_speeds); |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 561 | |
Padmanabh Ratnakar | db15dfa | 2012-10-20 06:03:04 +0000 | [diff] [blame] | 562 | ecmd->port = be_get_port_type(interface_type, |
| 563 | dac_cable_len); |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 564 | |
Padmanabh Ratnakar | db15dfa | 2012-10-20 06:03:04 +0000 | [diff] [blame] | 565 | if (adapter->phy.auto_speeds_supported) { |
| 566 | ecmd->supported |= SUPPORTED_Autoneg; |
| 567 | ecmd->autoneg = AUTONEG_ENABLE; |
| 568 | ecmd->advertising |= ADVERTISED_Autoneg; |
| 569 | } |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 570 | |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 571 | ecmd->supported |= SUPPORTED_Pause; |
Padmanabh Ratnakar | db15dfa | 2012-10-20 06:03:04 +0000 | [diff] [blame] | 572 | if (be_pause_supported(adapter)) |
| 573 | ecmd->advertising |= ADVERTISED_Pause; |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 574 | |
Padmanabh Ratnakar | db15dfa | 2012-10-20 06:03:04 +0000 | [diff] [blame] | 575 | switch (adapter->phy.interface_type) { |
| 576 | case PHY_TYPE_KR_10GB: |
| 577 | case PHY_TYPE_KX4_10GB: |
| 578 | ecmd->transceiver = XCVR_INTERNAL; |
| 579 | break; |
| 580 | default: |
| 581 | ecmd->transceiver = XCVR_EXTERNAL; |
| 582 | break; |
| 583 | } |
| 584 | } else { |
| 585 | ecmd->port = PORT_OTHER; |
| 586 | ecmd->autoneg = AUTONEG_DISABLE; |
| 587 | ecmd->transceiver = XCVR_DUMMY1; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 588 | } |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 589 | |
| 590 | /* Save for future use */ |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 591 | adapter->phy.link_speed = ethtool_cmd_speed(ecmd); |
| 592 | adapter->phy.port_type = ecmd->port; |
| 593 | adapter->phy.transceiver = ecmd->transceiver; |
| 594 | adapter->phy.autoneg = ecmd->autoneg; |
| 595 | adapter->phy.advertising = ecmd->advertising; |
| 596 | adapter->phy.supported = ecmd->supported; |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 597 | } else { |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 598 | ethtool_cmd_speed_set(ecmd, adapter->phy.link_speed); |
| 599 | ecmd->port = adapter->phy.port_type; |
| 600 | ecmd->transceiver = adapter->phy.transceiver; |
| 601 | ecmd->autoneg = adapter->phy.autoneg; |
| 602 | ecmd->advertising = adapter->phy.advertising; |
| 603 | ecmd->supported = adapter->phy.supported; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 604 | } |
Ajit Khaparde | 0dffc83 | 2009-11-29 17:57:46 +0000 | [diff] [blame] | 605 | |
Somnath Kotur | 682256d | 2012-05-02 03:40:32 +0000 | [diff] [blame] | 606 | ecmd->duplex = netif_carrier_ok(netdev) ? DUPLEX_FULL : DUPLEX_UNKNOWN; |
Sarveshwar Bandi | 0388f25 | 2009-10-28 04:15:20 -0700 | [diff] [blame] | 607 | ecmd->phy_address = adapter->port_num; |
Ajit Khaparde | ee3cb62 | 2010-07-01 03:51:00 +0000 | [diff] [blame] | 608 | |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 609 | return 0; |
| 610 | } |
| 611 | |
Sathya Perla | 110b82b | 2011-12-13 00:58:49 +0000 | [diff] [blame] | 612 | static void be_get_ringparam(struct net_device *netdev, |
| 613 | struct ethtool_ringparam *ring) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 614 | { |
| 615 | struct be_adapter *adapter = netdev_priv(netdev); |
| 616 | |
Sathya Perla | 110b82b | 2011-12-13 00:58:49 +0000 | [diff] [blame] | 617 | ring->rx_max_pending = ring->rx_pending = adapter->rx_obj[0].q.len; |
| 618 | ring->tx_max_pending = ring->tx_pending = adapter->tx_obj[0].q.len; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | static void |
| 622 | be_get_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd) |
| 623 | { |
| 624 | struct be_adapter *adapter = netdev_priv(netdev); |
| 625 | |
Sathya Perla | 8788fdc | 2009-07-27 22:52:03 +0000 | [diff] [blame] | 626 | be_cmd_get_flow_control(adapter, &ecmd->tx_pause, &ecmd->rx_pause); |
Ajit Khaparde | 42f11cf | 2012-04-21 18:53:22 +0000 | [diff] [blame] | 627 | ecmd->autoneg = adapter->phy.fc_autoneg; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 628 | } |
| 629 | |
| 630 | static int |
| 631 | be_set_pauseparam(struct net_device *netdev, struct ethtool_pauseparam *ecmd) |
| 632 | { |
| 633 | struct be_adapter *adapter = netdev_priv(netdev); |
| 634 | int status; |
| 635 | |
Padmanabh Ratnakar | c871c5f | 2012-07-12 03:56:11 +0000 | [diff] [blame] | 636 | if (ecmd->autoneg != adapter->phy.fc_autoneg) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 637 | return -EINVAL; |
Ajit Khaparde | 9e90c96 | 2009-11-06 02:06:59 +0000 | [diff] [blame] | 638 | adapter->tx_fc = ecmd->tx_pause; |
| 639 | adapter->rx_fc = ecmd->rx_pause; |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 640 | |
Ajit Khaparde | 9e90c96 | 2009-11-06 02:06:59 +0000 | [diff] [blame] | 641 | status = be_cmd_set_flow_control(adapter, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 642 | adapter->tx_fc, adapter->rx_fc); |
Ajit Khaparde | 9e90c96 | 2009-11-06 02:06:59 +0000 | [diff] [blame] | 643 | if (status) |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 644 | dev_warn(&adapter->pdev->dev, "Pause param set failed.\n"); |
| 645 | |
| 646 | return status; |
| 647 | } |
| 648 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 649 | static int be_set_phys_id(struct net_device *netdev, |
| 650 | enum ethtool_phys_id_state state) |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 651 | { |
| 652 | struct be_adapter *adapter = netdev_priv(netdev); |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 653 | |
stephen hemminger | 1a64246 | 2011-04-04 11:06:40 +0000 | [diff] [blame] | 654 | switch (state) { |
| 655 | case ETHTOOL_ID_ACTIVE: |
| 656 | be_cmd_get_beacon_state(adapter, adapter->hba_port_num, |
| 657 | &adapter->beacon_state); |
Allan, Bruce W | fce5592 | 2011-04-13 13:09:10 +0000 | [diff] [blame] | 658 | return 1; /* cycle on/off once per second */ |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 659 | |
stephen hemminger | 1a64246 | 2011-04-04 11:06:40 +0000 | [diff] [blame] | 660 | case ETHTOOL_ID_ON: |
| 661 | be_cmd_set_beacon_state(adapter, adapter->hba_port_num, 0, 0, |
| 662 | BEACON_STATE_ENABLED); |
| 663 | break; |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 664 | |
stephen hemminger | 1a64246 | 2011-04-04 11:06:40 +0000 | [diff] [blame] | 665 | case ETHTOOL_ID_OFF: |
| 666 | be_cmd_set_beacon_state(adapter, adapter->hba_port_num, 0, 0, |
| 667 | BEACON_STATE_DISABLED); |
| 668 | break; |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 669 | |
stephen hemminger | 1a64246 | 2011-04-04 11:06:40 +0000 | [diff] [blame] | 670 | case ETHTOOL_ID_INACTIVE: |
| 671 | be_cmd_set_beacon_state(adapter, adapter->hba_port_num, 0, 0, |
| 672 | adapter->beacon_state); |
| 673 | } |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 674 | |
stephen hemminger | 1a64246 | 2011-04-04 11:06:40 +0000 | [diff] [blame] | 675 | return 0; |
Sarveshwar Bandi | fad9ab2 | 2009-10-12 04:23:15 -0700 | [diff] [blame] | 676 | } |
| 677 | |
Somnath Kotur | 5c51081 | 2013-05-30 02:52:23 +0000 | [diff] [blame] | 678 | static int be_set_dump(struct net_device *netdev, struct ethtool_dump *dump) |
| 679 | { |
| 680 | struct be_adapter *adapter = netdev_priv(netdev); |
| 681 | struct device *dev = &adapter->pdev->dev; |
| 682 | int status; |
| 683 | |
| 684 | if (!lancer_chip(adapter)) { |
| 685 | dev_err(dev, "FW dump not supported\n"); |
| 686 | return -EOPNOTSUPP; |
| 687 | } |
| 688 | |
| 689 | if (dump_present(adapter)) { |
| 690 | dev_err(dev, "Previous dump not cleared, not forcing dump\n"); |
| 691 | return 0; |
| 692 | } |
| 693 | |
| 694 | switch (dump->flag) { |
| 695 | case LANCER_INITIATE_FW_DUMP: |
| 696 | status = lancer_initiate_dump(adapter); |
| 697 | if (!status) |
| 698 | dev_info(dev, "F/w dump initiated successfully\n"); |
| 699 | break; |
| 700 | default: |
| 701 | dev_err(dev, "Invalid dump level: 0x%x\n", dump->flag); |
| 702 | return -EINVAL; |
| 703 | } |
| 704 | return status; |
| 705 | } |
Ajit Khaparde | dcf96f1 | 2011-02-11 13:39:30 +0000 | [diff] [blame] | 706 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 707 | static void be_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 708 | { |
| 709 | struct be_adapter *adapter = netdev_priv(netdev); |
| 710 | |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 711 | if (adapter->wol_cap & BE_WOL_CAP) { |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 712 | wol->supported |= WAKE_MAGIC; |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 713 | if (adapter->wol_en) |
Sarveshwar Bandi | b424332 | 2013-04-25 00:56:56 +0000 | [diff] [blame] | 714 | wol->wolopts |= WAKE_MAGIC; |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 715 | } else { |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 716 | wol->wolopts = 0; |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 717 | } |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 718 | memset(&wol->sopass, 0, sizeof(wol->sopass)); |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 719 | } |
| 720 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 721 | static int be_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 722 | { |
| 723 | struct be_adapter *adapter = netdev_priv(netdev); |
| 724 | |
| 725 | if (wol->wolopts & ~WAKE_MAGIC) |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 726 | return -EOPNOTSUPP; |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 727 | |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 728 | if (!(adapter->wol_cap & BE_WOL_CAP)) { |
Ajit Khaparde | 4762f6c | 2012-03-18 06:23:11 +0000 | [diff] [blame] | 729 | dev_warn(&adapter->pdev->dev, "WOL not supported\n"); |
| 730 | return -EOPNOTSUPP; |
| 731 | } |
| 732 | |
| 733 | if (wol->wolopts & WAKE_MAGIC) |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 734 | adapter->wol_en = true; |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 735 | else |
Suresh Reddy | 76a9e08 | 2014-01-15 13:23:40 +0530 | [diff] [blame] | 736 | adapter->wol_en = false; |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 737 | |
| 738 | return 0; |
| 739 | } |
| 740 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 741 | static int be_test_ddr_dma(struct be_adapter *adapter) |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 742 | { |
| 743 | int ret, i; |
| 744 | struct be_dma_mem ddrdma_cmd; |
Joe Perches | 215faf9 | 2010-12-21 02:16:10 -0800 | [diff] [blame] | 745 | static const u64 pattern[2] = { |
| 746 | 0x5a5a5a5a5a5a5a5aULL, 0xa5a5a5a5a5a5a5a5ULL |
| 747 | }; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 748 | |
| 749 | ddrdma_cmd.size = sizeof(struct be_cmd_req_ddrdma_test); |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 750 | ddrdma_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, ddrdma_cmd.size, |
| 751 | &ddrdma_cmd.dma, GFP_KERNEL); |
Joe Perches | d0320f7 | 2013-03-14 13:07:21 +0000 | [diff] [blame] | 752 | if (!ddrdma_cmd.va) |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 753 | return -ENOMEM; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 754 | |
| 755 | for (i = 0; i < 2; i++) { |
| 756 | ret = be_cmd_ddr_dma_test(adapter, pattern[i], |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 757 | 4096, &ddrdma_cmd); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 758 | if (ret != 0) |
| 759 | goto err; |
| 760 | } |
| 761 | |
| 762 | err: |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 763 | dma_free_coherent(&adapter->pdev->dev, ddrdma_cmd.size, ddrdma_cmd.va, |
| 764 | ddrdma_cmd.dma); |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 765 | return ret; |
| 766 | } |
| 767 | |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 768 | static u64 be_loopback_test(struct be_adapter *adapter, u8 loopback_type, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 769 | u64 *status) |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 770 | { |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 771 | be_cmd_set_loopback(adapter, adapter->hba_port_num, loopback_type, 1); |
Ajit Khaparde | 9e1453c | 2011-02-20 11:42:22 +0000 | [diff] [blame] | 772 | *status = be_cmd_loopback_test(adapter, adapter->hba_port_num, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 773 | loopback_type, 1500, 2, 0xabc); |
| 774 | be_cmd_set_loopback(adapter, adapter->hba_port_num, BE_NO_LOOPBACK, 1); |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 775 | return *status; |
| 776 | } |
| 777 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 778 | static void be_self_test(struct net_device *netdev, struct ethtool_test *test, |
| 779 | u64 *data) |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 780 | { |
| 781 | struct be_adapter *adapter = netdev_priv(netdev); |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 782 | int status; |
| 783 | u8 link_status = 0; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 784 | |
Suresh Reddy | 78d0b11 | 2013-04-25 23:03:22 +0000 | [diff] [blame] | 785 | if (adapter->function_caps & BE_FUNCTION_CAPS_SUPER_NIC) { |
| 786 | dev_err(&adapter->pdev->dev, "Self test not supported\n"); |
| 787 | test->flags |= ETH_TEST_FL_FAILED; |
| 788 | return; |
| 789 | } |
| 790 | |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 791 | memset(data, 0, sizeof(u64) * ETHTOOL_TESTS_NUM); |
| 792 | |
| 793 | if (test->flags & ETH_TEST_FL_OFFLINE) { |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 794 | if (be_loopback_test(adapter, BE_MAC_LOOPBACK, &data[0]) != 0) |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 795 | test->flags |= ETH_TEST_FL_FAILED; |
Ivan Vecera | 5a8a1ab | 2014-03-05 11:54:05 +0100 | [diff] [blame] | 796 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 797 | if (be_loopback_test(adapter, BE_PHY_LOOPBACK, &data[1]) != 0) |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 798 | test->flags |= ETH_TEST_FL_FAILED; |
Ivan Vecera | 5a8a1ab | 2014-03-05 11:54:05 +0100 | [diff] [blame] | 799 | |
| 800 | if (test->flags & ETH_TEST_FL_EXTERNAL_LB) { |
| 801 | if (be_loopback_test(adapter, BE_ONE_PORT_EXT_LOOPBACK, |
| 802 | &data[2]) != 0) |
| 803 | test->flags |= ETH_TEST_FL_FAILED; |
| 804 | test->flags |= ETH_TEST_FL_EXTERNAL_LB_DONE; |
Sarveshwar Bandi | fced999 | 2009-12-23 04:41:44 +0000 | [diff] [blame] | 805 | } |
Sarveshwar Bandi | 8f47afe | 2010-01-19 05:15:00 +0000 | [diff] [blame] | 806 | } |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 807 | |
Padmanabh Ratnakar | a704739 | 2012-04-25 01:46:28 +0000 | [diff] [blame] | 808 | if (!lancer_chip(adapter) && be_test_ddr_dma(adapter) != 0) { |
Sarveshwar Bandi | 8f47afe | 2010-01-19 05:15:00 +0000 | [diff] [blame] | 809 | data[3] = 1; |
| 810 | test->flags |= ETH_TEST_FL_FAILED; |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 811 | } |
| 812 | |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 813 | status = be_cmd_link_status_query(adapter, NULL, &link_status, 0); |
| 814 | if (status) { |
Sarveshwar Bandi | 4276e47 | 2010-01-19 05:15:36 +0000 | [diff] [blame] | 815 | test->flags |= ETH_TEST_FL_FAILED; |
| 816 | data[4] = -1; |
Sathya Perla | 323ff71 | 2012-09-28 04:39:43 +0000 | [diff] [blame] | 817 | } else if (!link_status) { |
Ajit Khaparde | 4ee7721 | 2011-02-20 11:41:20 +0000 | [diff] [blame] | 818 | test->flags |= ETH_TEST_FL_FAILED; |
Sarveshwar Bandi | 4276e47 | 2010-01-19 05:15:36 +0000 | [diff] [blame] | 819 | data[4] = 1; |
| 820 | } |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 821 | } |
| 822 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 823 | static int be_do_flash(struct net_device *netdev, struct ethtool_flash *efl) |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 824 | { |
| 825 | struct be_adapter *adapter = netdev_priv(netdev); |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 826 | |
Ben Hutchings | 786f528 | 2012-02-01 09:32:25 +0000 | [diff] [blame] | 827 | return be_load_fw(adapter, efl->data); |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 828 | } |
| 829 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 830 | static int be_get_eeprom_len(struct net_device *netdev) |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 831 | { |
Padmanabh Ratnakar | af5875b | 2011-11-16 02:03:07 +0000 | [diff] [blame] | 832 | struct be_adapter *adapter = netdev_priv(netdev); |
Padmanabh Ratnakar | f25b119 | 2012-10-20 06:02:52 +0000 | [diff] [blame] | 833 | |
| 834 | if (!check_privilege(adapter, MAX_PRIVILEGES)) |
| 835 | return 0; |
| 836 | |
Padmanabh Ratnakar | af5875b | 2011-11-16 02:03:07 +0000 | [diff] [blame] | 837 | if (lancer_chip(adapter)) { |
| 838 | if (be_physfn(adapter)) |
| 839 | return lancer_cmd_get_file_len(adapter, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 840 | LANCER_VPD_PF_FILE); |
Padmanabh Ratnakar | af5875b | 2011-11-16 02:03:07 +0000 | [diff] [blame] | 841 | else |
| 842 | return lancer_cmd_get_file_len(adapter, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 843 | LANCER_VPD_VF_FILE); |
Padmanabh Ratnakar | af5875b | 2011-11-16 02:03:07 +0000 | [diff] [blame] | 844 | } else { |
| 845 | return BE_READ_SEEPROM_LEN; |
| 846 | } |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 847 | } |
| 848 | |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 849 | static int be_read_eeprom(struct net_device *netdev, |
| 850 | struct ethtool_eeprom *eeprom, uint8_t *data) |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 851 | { |
| 852 | struct be_adapter *adapter = netdev_priv(netdev); |
| 853 | struct be_dma_mem eeprom_cmd; |
| 854 | struct be_cmd_resp_seeprom_read *resp; |
| 855 | int status; |
| 856 | |
| 857 | if (!eeprom->len) |
| 858 | return -EINVAL; |
| 859 | |
Padmanabh Ratnakar | af5875b | 2011-11-16 02:03:07 +0000 | [diff] [blame] | 860 | if (lancer_chip(adapter)) { |
| 861 | if (be_physfn(adapter)) |
| 862 | return lancer_cmd_read_file(adapter, LANCER_VPD_PF_FILE, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 863 | eeprom->len, data); |
Padmanabh Ratnakar | af5875b | 2011-11-16 02:03:07 +0000 | [diff] [blame] | 864 | else |
| 865 | return lancer_cmd_read_file(adapter, LANCER_VPD_VF_FILE, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 866 | eeprom->len, data); |
Padmanabh Ratnakar | af5875b | 2011-11-16 02:03:07 +0000 | [diff] [blame] | 867 | } |
| 868 | |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 869 | eeprom->magic = BE_VENDOR_ID | (adapter->pdev->device<<16); |
| 870 | |
| 871 | memset(&eeprom_cmd, 0, sizeof(struct be_dma_mem)); |
| 872 | eeprom_cmd.size = sizeof(struct be_cmd_req_seeprom_read); |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 873 | eeprom_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, eeprom_cmd.size, |
| 874 | &eeprom_cmd.dma, GFP_KERNEL); |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 875 | |
Joe Perches | d0320f7 | 2013-03-14 13:07:21 +0000 | [diff] [blame] | 876 | if (!eeprom_cmd.va) |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 877 | return -ENOMEM; |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 878 | |
| 879 | status = be_cmd_get_seeprom_data(adapter, &eeprom_cmd); |
| 880 | |
| 881 | if (!status) { |
Joe Perches | 43d620c | 2011-06-16 19:08:06 +0000 | [diff] [blame] | 882 | resp = eeprom_cmd.va; |
Ajit Khaparde | c0ad984 | 2010-02-08 17:51:26 +0000 | [diff] [blame] | 883 | memcpy(data, resp->seeprom_data + eeprom->offset, eeprom->len); |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 884 | } |
Ivan Vecera | 2b7bceb | 2011-02-02 08:05:12 +0000 | [diff] [blame] | 885 | dma_free_coherent(&adapter->pdev->dev, eeprom_cmd.size, eeprom_cmd.va, |
| 886 | eeprom_cmd.dma); |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 887 | |
| 888 | return status; |
| 889 | } |
| 890 | |
Somnath Kotur | 941a77d | 2012-05-17 22:59:03 +0000 | [diff] [blame] | 891 | static u32 be_get_msg_level(struct net_device *netdev) |
| 892 | { |
| 893 | struct be_adapter *adapter = netdev_priv(netdev); |
| 894 | |
Somnath Kotur | 941a77d | 2012-05-17 22:59:03 +0000 | [diff] [blame] | 895 | return adapter->msg_enable; |
| 896 | } |
| 897 | |
Somnath Kotur | 941a77d | 2012-05-17 22:59:03 +0000 | [diff] [blame] | 898 | static void be_set_msg_level(struct net_device *netdev, u32 level) |
| 899 | { |
| 900 | struct be_adapter *adapter = netdev_priv(netdev); |
| 901 | |
Somnath Kotur | 941a77d | 2012-05-17 22:59:03 +0000 | [diff] [blame] | 902 | if (adapter->msg_enable == level) |
| 903 | return; |
| 904 | |
| 905 | if ((level & NETIF_MSG_HW) != (adapter->msg_enable & NETIF_MSG_HW)) |
Vasundhara Volam | baaa08d | 2014-01-15 13:23:34 +0530 | [diff] [blame] | 906 | if (BEx_chip(adapter)) |
| 907 | be_cmd_set_fw_log_level(adapter, level & NETIF_MSG_HW ? |
| 908 | FW_LOG_LEVEL_DEFAULT : |
| 909 | FW_LOG_LEVEL_FATAL); |
Somnath Kotur | 941a77d | 2012-05-17 22:59:03 +0000 | [diff] [blame] | 910 | adapter->msg_enable = level; |
| 911 | |
| 912 | return; |
| 913 | } |
| 914 | |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 915 | static u64 be_get_rss_hash_opts(struct be_adapter *adapter, u64 flow_type) |
| 916 | { |
| 917 | u64 data = 0; |
| 918 | |
| 919 | switch (flow_type) { |
| 920 | case TCP_V4_FLOW: |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 921 | if (adapter->rss_info.rss_flags & RSS_ENABLE_IPV4) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 922 | data |= RXH_IP_DST | RXH_IP_SRC; |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 923 | if (adapter->rss_info.rss_flags & RSS_ENABLE_TCP_IPV4) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 924 | data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 925 | break; |
| 926 | case UDP_V4_FLOW: |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 927 | if (adapter->rss_info.rss_flags & RSS_ENABLE_IPV4) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 928 | data |= RXH_IP_DST | RXH_IP_SRC; |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 929 | if (adapter->rss_info.rss_flags & RSS_ENABLE_UDP_IPV4) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 930 | data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 931 | break; |
| 932 | case TCP_V6_FLOW: |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 933 | if (adapter->rss_info.rss_flags & RSS_ENABLE_IPV6) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 934 | data |= RXH_IP_DST | RXH_IP_SRC; |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 935 | if (adapter->rss_info.rss_flags & RSS_ENABLE_TCP_IPV6) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 936 | data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 937 | break; |
| 938 | case UDP_V6_FLOW: |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 939 | if (adapter->rss_info.rss_flags & RSS_ENABLE_IPV6) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 940 | data |= RXH_IP_DST | RXH_IP_SRC; |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 941 | if (adapter->rss_info.rss_flags & RSS_ENABLE_UDP_IPV6) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 942 | data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 943 | break; |
| 944 | } |
| 945 | |
| 946 | return data; |
| 947 | } |
| 948 | |
| 949 | static int be_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, |
Sathya Perla | 05e4c6a | 2014-05-09 13:29:15 +0530 | [diff] [blame] | 950 | u32 *rule_locs) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 951 | { |
| 952 | struct be_adapter *adapter = netdev_priv(netdev); |
| 953 | |
| 954 | if (!be_multi_rxq(adapter)) { |
| 955 | dev_info(&adapter->pdev->dev, |
| 956 | "ethtool::get_rxnfc: RX flow hashing is disabled\n"); |
| 957 | return -EINVAL; |
| 958 | } |
| 959 | |
| 960 | switch (cmd->cmd) { |
| 961 | case ETHTOOL_GRXFH: |
| 962 | cmd->data = be_get_rss_hash_opts(adapter, cmd->flow_type); |
| 963 | break; |
| 964 | case ETHTOOL_GRXRINGS: |
| 965 | cmd->data = adapter->num_rx_qs - 1; |
| 966 | break; |
| 967 | default: |
| 968 | return -EINVAL; |
| 969 | } |
| 970 | |
| 971 | return 0; |
| 972 | } |
| 973 | |
| 974 | static int be_set_rss_hash_opts(struct be_adapter *adapter, |
| 975 | struct ethtool_rxnfc *cmd) |
| 976 | { |
| 977 | struct be_rx_obj *rxo; |
| 978 | int status = 0, i, j; |
| 979 | u8 rsstable[128]; |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 980 | u32 rss_flags = adapter->rss_info.rss_flags; |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 981 | |
| 982 | if (cmd->data != L3_RSS_FLAGS && |
| 983 | cmd->data != (L3_RSS_FLAGS | L4_RSS_FLAGS)) |
| 984 | return -EINVAL; |
| 985 | |
| 986 | switch (cmd->flow_type) { |
| 987 | case TCP_V4_FLOW: |
| 988 | if (cmd->data == L3_RSS_FLAGS) |
| 989 | rss_flags &= ~RSS_ENABLE_TCP_IPV4; |
| 990 | else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) |
| 991 | rss_flags |= RSS_ENABLE_IPV4 | |
| 992 | RSS_ENABLE_TCP_IPV4; |
| 993 | break; |
| 994 | case TCP_V6_FLOW: |
| 995 | if (cmd->data == L3_RSS_FLAGS) |
| 996 | rss_flags &= ~RSS_ENABLE_TCP_IPV6; |
| 997 | else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) |
| 998 | rss_flags |= RSS_ENABLE_IPV6 | |
| 999 | RSS_ENABLE_TCP_IPV6; |
| 1000 | break; |
| 1001 | case UDP_V4_FLOW: |
| 1002 | if ((cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) && |
| 1003 | BEx_chip(adapter)) |
| 1004 | return -EINVAL; |
| 1005 | |
| 1006 | if (cmd->data == L3_RSS_FLAGS) |
| 1007 | rss_flags &= ~RSS_ENABLE_UDP_IPV4; |
| 1008 | else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) |
| 1009 | rss_flags |= RSS_ENABLE_IPV4 | |
| 1010 | RSS_ENABLE_UDP_IPV4; |
| 1011 | break; |
| 1012 | case UDP_V6_FLOW: |
| 1013 | if ((cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) && |
| 1014 | BEx_chip(adapter)) |
| 1015 | return -EINVAL; |
| 1016 | |
| 1017 | if (cmd->data == L3_RSS_FLAGS) |
| 1018 | rss_flags &= ~RSS_ENABLE_UDP_IPV6; |
| 1019 | else if (cmd->data == (L3_RSS_FLAGS | L4_RSS_FLAGS)) |
| 1020 | rss_flags |= RSS_ENABLE_IPV6 | |
| 1021 | RSS_ENABLE_UDP_IPV6; |
| 1022 | break; |
| 1023 | default: |
| 1024 | return -EINVAL; |
| 1025 | } |
| 1026 | |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 1027 | if (rss_flags == adapter->rss_info.rss_flags) |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 1028 | return status; |
| 1029 | |
| 1030 | if (be_multi_rxq(adapter)) { |
| 1031 | for (j = 0; j < 128; j += adapter->num_rx_qs - 1) { |
| 1032 | for_all_rss_queues(adapter, rxo, i) { |
| 1033 | if ((j + i) >= 128) |
| 1034 | break; |
| 1035 | rsstable[j + i] = rxo->rss_id; |
| 1036 | } |
| 1037 | } |
| 1038 | } |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 1039 | |
| 1040 | status = be_cmd_rss_config(adapter, adapter->rss_info.rsstable, |
| 1041 | rss_flags, 128, adapter->rss_info.rss_hkey); |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 1042 | if (!status) |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 1043 | adapter->rss_info.rss_flags = rss_flags; |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 1044 | |
| 1045 | return status; |
| 1046 | } |
| 1047 | |
| 1048 | static int be_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd) |
| 1049 | { |
| 1050 | struct be_adapter *adapter = netdev_priv(netdev); |
| 1051 | int status = 0; |
| 1052 | |
| 1053 | if (!be_multi_rxq(adapter)) { |
| 1054 | dev_err(&adapter->pdev->dev, |
| 1055 | "ethtool::set_rxnfc: RX flow hashing is disabled\n"); |
| 1056 | return -EINVAL; |
| 1057 | } |
| 1058 | |
| 1059 | switch (cmd->cmd) { |
| 1060 | case ETHTOOL_SRXFH: |
| 1061 | status = be_set_rss_hash_opts(adapter, cmd); |
| 1062 | break; |
| 1063 | default: |
| 1064 | return -EINVAL; |
| 1065 | } |
| 1066 | |
| 1067 | return status; |
| 1068 | } |
| 1069 | |
Sathya Perla | 68d7bdc | 2013-08-27 16:57:35 +0530 | [diff] [blame] | 1070 | static void be_get_channels(struct net_device *netdev, |
| 1071 | struct ethtool_channels *ch) |
| 1072 | { |
| 1073 | struct be_adapter *adapter = netdev_priv(netdev); |
| 1074 | |
| 1075 | ch->combined_count = adapter->num_evt_qs; |
| 1076 | ch->max_combined = be_max_qs(adapter); |
| 1077 | } |
| 1078 | |
| 1079 | static int be_set_channels(struct net_device *netdev, |
| 1080 | struct ethtool_channels *ch) |
| 1081 | { |
| 1082 | struct be_adapter *adapter = netdev_priv(netdev); |
| 1083 | |
| 1084 | if (ch->rx_count || ch->tx_count || ch->other_count || |
| 1085 | !ch->combined_count || ch->combined_count > be_max_qs(adapter)) |
| 1086 | return -EINVAL; |
| 1087 | |
| 1088 | adapter->cfg_num_qs = ch->combined_count; |
| 1089 | |
| 1090 | return be_update_queues(adapter); |
| 1091 | } |
| 1092 | |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 1093 | static u32 be_get_rxfh_indir_size(struct net_device *netdev) |
| 1094 | { |
| 1095 | return RSS_INDIR_TABLE_LEN; |
| 1096 | } |
| 1097 | |
| 1098 | static u32 be_get_rxfh_key_size(struct net_device *netdev) |
| 1099 | { |
| 1100 | return RSS_HASH_KEY_LEN; |
| 1101 | } |
| 1102 | |
| 1103 | static int be_get_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey) |
| 1104 | { |
| 1105 | struct be_adapter *adapter = netdev_priv(netdev); |
| 1106 | int i; |
| 1107 | struct rss_info *rss = &adapter->rss_info; |
| 1108 | |
| 1109 | if (indir) { |
| 1110 | for (i = 0; i < RSS_INDIR_TABLE_LEN; i++) |
| 1111 | indir[i] = rss->rss_queue[i]; |
| 1112 | } |
| 1113 | |
| 1114 | if (hkey) |
| 1115 | memcpy(hkey, rss->rss_hkey, RSS_HASH_KEY_LEN); |
| 1116 | |
| 1117 | return 0; |
| 1118 | } |
| 1119 | |
| 1120 | static int be_set_rxfh(struct net_device *netdev, u32 *indir, u8 *hkey) |
| 1121 | { |
| 1122 | int rc = 0, i, j; |
| 1123 | struct be_adapter *adapter = netdev_priv(netdev); |
| 1124 | u8 rsstable[RSS_INDIR_TABLE_LEN]; |
| 1125 | |
| 1126 | if (indir) { |
| 1127 | struct be_rx_obj *rxo; |
| 1128 | for (i = 0; i < RSS_INDIR_TABLE_LEN; i++) { |
| 1129 | j = indir[i]; |
| 1130 | rxo = &adapter->rx_obj[j]; |
| 1131 | rsstable[i] = rxo->rss_id; |
| 1132 | adapter->rss_info.rss_queue[i] = j; |
| 1133 | } |
| 1134 | } else { |
| 1135 | memcpy(rsstable, adapter->rss_info.rsstable, |
| 1136 | RSS_INDIR_TABLE_LEN); |
| 1137 | } |
| 1138 | |
| 1139 | if (!hkey) |
| 1140 | hkey = adapter->rss_info.rss_hkey; |
| 1141 | |
| 1142 | rc = be_cmd_rss_config(adapter, rsstable, |
| 1143 | adapter->rss_info.rss_flags, |
| 1144 | RSS_INDIR_TABLE_LEN, hkey); |
| 1145 | if (rc) { |
| 1146 | adapter->rss_info.rss_flags = RSS_ENABLE_NONE; |
| 1147 | return -EIO; |
| 1148 | } |
| 1149 | memcpy(adapter->rss_info.rss_hkey, hkey, RSS_HASH_KEY_LEN); |
| 1150 | memcpy(adapter->rss_info.rsstable, rsstable, |
| 1151 | RSS_INDIR_TABLE_LEN); |
| 1152 | return 0; |
| 1153 | } |
| 1154 | |
Stephen Hemminger | 0fc0b73 | 2009-09-02 01:03:33 -0700 | [diff] [blame] | 1155 | const struct ethtool_ops be_ethtool_ops = { |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1156 | .get_settings = be_get_settings, |
| 1157 | .get_drvinfo = be_get_drvinfo, |
Ajit Khaparde | 71d8d1b | 2009-12-03 06:16:59 +0000 | [diff] [blame] | 1158 | .get_wol = be_get_wol, |
| 1159 | .set_wol = be_set_wol, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1160 | .get_link = ethtool_op_get_link, |
Sarveshwar Bandi | 368c0ca | 2010-01-08 00:07:27 -0800 | [diff] [blame] | 1161 | .get_eeprom_len = be_get_eeprom_len, |
| 1162 | .get_eeprom = be_read_eeprom, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1163 | .get_coalesce = be_get_coalesce, |
| 1164 | .set_coalesce = be_set_coalesce, |
| 1165 | .get_ringparam = be_get_ringparam, |
| 1166 | .get_pauseparam = be_get_pauseparam, |
| 1167 | .set_pauseparam = be_set_pauseparam, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1168 | .get_strings = be_get_stat_strings, |
stephen hemminger | 1a64246 | 2011-04-04 11:06:40 +0000 | [diff] [blame] | 1169 | .set_phys_id = be_set_phys_id, |
Somnath Kotur | 5c51081 | 2013-05-30 02:52:23 +0000 | [diff] [blame] | 1170 | .set_dump = be_set_dump, |
Somnath Kotur | 941a77d | 2012-05-17 22:59:03 +0000 | [diff] [blame] | 1171 | .get_msglevel = be_get_msg_level, |
| 1172 | .set_msglevel = be_set_msg_level, |
Ben Hutchings | 15f0a39 | 2009-10-01 11:58:24 +0000 | [diff] [blame] | 1173 | .get_sset_count = be_get_sset_count, |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1174 | .get_ethtool_stats = be_get_ethtool_stats, |
Somnath Kotur | 311fddc | 2011-03-16 21:22:43 +0000 | [diff] [blame] | 1175 | .get_regs_len = be_get_reg_len, |
| 1176 | .get_regs = be_get_regs, |
Ajit Khaparde | 8451748 | 2009-09-04 03:12:16 +0000 | [diff] [blame] | 1177 | .flash_device = be_do_flash, |
Suresh R | ff33a6e | 2009-12-03 16:15:52 -0800 | [diff] [blame] | 1178 | .self_test = be_self_test, |
Suresh Reddy | 594ad54 | 2013-04-25 23:03:20 +0000 | [diff] [blame] | 1179 | .get_rxnfc = be_get_rxnfc, |
| 1180 | .set_rxnfc = be_set_rxnfc, |
Venkata Duvvuru | e255787 | 2014-04-21 15:38:00 +0530 | [diff] [blame] | 1181 | .get_rxfh_indir_size = be_get_rxfh_indir_size, |
| 1182 | .get_rxfh_key_size = be_get_rxfh_key_size, |
| 1183 | .get_rxfh = be_get_rxfh, |
| 1184 | .set_rxfh = be_set_rxfh, |
Sathya Perla | 68d7bdc | 2013-08-27 16:57:35 +0530 | [diff] [blame] | 1185 | .get_channels = be_get_channels, |
| 1186 | .set_channels = be_set_channels |
Sathya Perla | 6b7c5b9 | 2009-03-11 23:32:03 -0700 | [diff] [blame] | 1187 | }; |