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