Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * |
| 3 | * Intel Ethernet Controller XL710 Family Linux Driver |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 4 | * Copyright(c) 2013 - 2015 Intel Corporation. |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms and conditions of the GNU General Public License, |
| 8 | * version 2, as published by the Free Software Foundation. |
| 9 | * |
| 10 | * This program is distributed in the hope it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 13 | * more details. |
| 14 | * |
Greg Rose | dc641b7 | 2013-12-18 13:45:51 +0000 | [diff] [blame] | 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program. If not, see <http://www.gnu.org/licenses/>. |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 17 | * |
| 18 | * The full GNU General Public License is included in this distribution in |
| 19 | * the file called "COPYING". |
| 20 | * |
| 21 | * Contact Information: |
| 22 | * e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> |
| 23 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 24 | * |
| 25 | ******************************************************************************/ |
| 26 | |
| 27 | /* ethtool support for i40e */ |
| 28 | |
| 29 | #include "i40e.h" |
| 30 | #include "i40e_diag.h" |
| 31 | |
| 32 | struct i40e_stats { |
| 33 | char stat_string[ETH_GSTRING_LEN]; |
| 34 | int sizeof_stat; |
| 35 | int stat_offset; |
| 36 | }; |
| 37 | |
| 38 | #define I40E_STAT(_type, _name, _stat) { \ |
| 39 | .stat_string = _name, \ |
| 40 | .sizeof_stat = FIELD_SIZEOF(_type, _stat), \ |
| 41 | .stat_offset = offsetof(_type, _stat) \ |
| 42 | } |
Shannon Nelson | fad177d | 2014-11-11 20:07:27 +0000 | [diff] [blame] | 43 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 44 | #define I40E_NETDEV_STAT(_net_stat) \ |
Shannon Nelson | fad177d | 2014-11-11 20:07:27 +0000 | [diff] [blame] | 45 | I40E_STAT(struct rtnl_link_stats64, #_net_stat, _net_stat) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 46 | #define I40E_PF_STAT(_name, _stat) \ |
| 47 | I40E_STAT(struct i40e_pf, _name, _stat) |
| 48 | #define I40E_VSI_STAT(_name, _stat) \ |
| 49 | I40E_STAT(struct i40e_vsi, _name, _stat) |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 50 | #define I40E_VEB_STAT(_name, _stat) \ |
| 51 | I40E_STAT(struct i40e_veb, _name, _stat) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 52 | |
| 53 | static const struct i40e_stats i40e_gstrings_net_stats[] = { |
| 54 | I40E_NETDEV_STAT(rx_packets), |
| 55 | I40E_NETDEV_STAT(tx_packets), |
| 56 | I40E_NETDEV_STAT(rx_bytes), |
| 57 | I40E_NETDEV_STAT(tx_bytes), |
| 58 | I40E_NETDEV_STAT(rx_errors), |
| 59 | I40E_NETDEV_STAT(tx_errors), |
| 60 | I40E_NETDEV_STAT(rx_dropped), |
| 61 | I40E_NETDEV_STAT(tx_dropped), |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 62 | I40E_NETDEV_STAT(collisions), |
| 63 | I40E_NETDEV_STAT(rx_length_errors), |
| 64 | I40E_NETDEV_STAT(rx_crc_errors), |
| 65 | }; |
| 66 | |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 67 | static const struct i40e_stats i40e_gstrings_veb_stats[] = { |
| 68 | I40E_VEB_STAT("rx_bytes", stats.rx_bytes), |
| 69 | I40E_VEB_STAT("tx_bytes", stats.tx_bytes), |
| 70 | I40E_VEB_STAT("rx_unicast", stats.rx_unicast), |
| 71 | I40E_VEB_STAT("tx_unicast", stats.tx_unicast), |
| 72 | I40E_VEB_STAT("rx_multicast", stats.rx_multicast), |
| 73 | I40E_VEB_STAT("tx_multicast", stats.tx_multicast), |
| 74 | I40E_VEB_STAT("rx_broadcast", stats.rx_broadcast), |
| 75 | I40E_VEB_STAT("tx_broadcast", stats.tx_broadcast), |
| 76 | I40E_VEB_STAT("rx_discards", stats.rx_discards), |
| 77 | I40E_VEB_STAT("tx_discards", stats.tx_discards), |
| 78 | I40E_VEB_STAT("tx_errors", stats.tx_errors), |
| 79 | I40E_VEB_STAT("rx_unknown_protocol", stats.rx_unknown_protocol), |
| 80 | }; |
| 81 | |
Shannon Nelson | 41a9e55 | 2014-04-23 04:50:20 +0000 | [diff] [blame] | 82 | static const struct i40e_stats i40e_gstrings_misc_stats[] = { |
Shannon Nelson | 418631d | 2014-04-23 04:50:07 +0000 | [diff] [blame] | 83 | I40E_VSI_STAT("rx_unicast", eth_stats.rx_unicast), |
| 84 | I40E_VSI_STAT("tx_unicast", eth_stats.tx_unicast), |
| 85 | I40E_VSI_STAT("rx_multicast", eth_stats.rx_multicast), |
| 86 | I40E_VSI_STAT("tx_multicast", eth_stats.tx_multicast), |
Shannon Nelson | 41a9e55 | 2014-04-23 04:50:20 +0000 | [diff] [blame] | 87 | I40E_VSI_STAT("rx_broadcast", eth_stats.rx_broadcast), |
| 88 | I40E_VSI_STAT("tx_broadcast", eth_stats.tx_broadcast), |
Shannon Nelson | 418631d | 2014-04-23 04:50:07 +0000 | [diff] [blame] | 89 | I40E_VSI_STAT("rx_unknown_protocol", eth_stats.rx_unknown_protocol), |
Anjali Singhai Jain | 2fc3d71 | 2015-08-27 11:42:29 -0400 | [diff] [blame] | 90 | I40E_VSI_STAT("tx_linearize", tx_linearize), |
Shannon Nelson | 41a9e55 | 2014-04-23 04:50:20 +0000 | [diff] [blame] | 91 | }; |
| 92 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 93 | /* These PF_STATs might look like duplicates of some NETDEV_STATs, |
| 94 | * but they are separate. This device supports Virtualization, and |
| 95 | * as such might have several netdevs supporting VMDq and FCoE going |
| 96 | * through a single port. The NETDEV_STATs are for individual netdevs |
| 97 | * seen at the top of the stack, and the PF_STATs are for the physical |
| 98 | * function at the bottom of the stack hosting those netdevs. |
| 99 | * |
| 100 | * The PF_STATs are appended to the netdev stats only when ethtool -S |
| 101 | * is queried on the base PF netdev, not on the VMDq or FCoE netdev. |
| 102 | */ |
| 103 | static struct i40e_stats i40e_gstrings_stats[] = { |
| 104 | I40E_PF_STAT("rx_bytes", stats.eth.rx_bytes), |
| 105 | I40E_PF_STAT("tx_bytes", stats.eth.tx_bytes), |
Shannon Nelson | 532d283 | 2014-04-23 04:50:09 +0000 | [diff] [blame] | 106 | I40E_PF_STAT("rx_unicast", stats.eth.rx_unicast), |
| 107 | I40E_PF_STAT("tx_unicast", stats.eth.tx_unicast), |
| 108 | I40E_PF_STAT("rx_multicast", stats.eth.rx_multicast), |
| 109 | I40E_PF_STAT("tx_multicast", stats.eth.tx_multicast), |
| 110 | I40E_PF_STAT("rx_broadcast", stats.eth.rx_broadcast), |
| 111 | I40E_PF_STAT("tx_broadcast", stats.eth.tx_broadcast), |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 112 | I40E_PF_STAT("tx_errors", stats.eth.tx_errors), |
| 113 | I40E_PF_STAT("rx_dropped", stats.eth.rx_discards), |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 114 | I40E_PF_STAT("tx_dropped_link_down", stats.tx_dropped_link_down), |
Shannon Nelson | 9f7c944 | 2015-07-10 19:35:57 -0400 | [diff] [blame] | 115 | I40E_PF_STAT("rx_crc_errors", stats.crc_errors), |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 116 | I40E_PF_STAT("illegal_bytes", stats.illegal_bytes), |
| 117 | I40E_PF_STAT("mac_local_faults", stats.mac_local_faults), |
| 118 | I40E_PF_STAT("mac_remote_faults", stats.mac_remote_faults), |
Jesse Brandeburg | a47a15f | 2014-02-06 05:51:09 +0000 | [diff] [blame] | 119 | I40E_PF_STAT("tx_timeout", tx_timeout_count), |
Jesse Brandeburg | 8a3c91c | 2014-05-20 08:01:43 +0000 | [diff] [blame] | 120 | I40E_PF_STAT("rx_csum_bad", hw_csum_rx_error), |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 121 | I40E_PF_STAT("rx_length_errors", stats.rx_length_errors), |
| 122 | I40E_PF_STAT("link_xon_rx", stats.link_xon_rx), |
| 123 | I40E_PF_STAT("link_xoff_rx", stats.link_xoff_rx), |
| 124 | I40E_PF_STAT("link_xon_tx", stats.link_xon_tx), |
| 125 | I40E_PF_STAT("link_xoff_tx", stats.link_xoff_tx), |
| 126 | I40E_PF_STAT("rx_size_64", stats.rx_size_64), |
| 127 | I40E_PF_STAT("rx_size_127", stats.rx_size_127), |
| 128 | I40E_PF_STAT("rx_size_255", stats.rx_size_255), |
| 129 | I40E_PF_STAT("rx_size_511", stats.rx_size_511), |
| 130 | I40E_PF_STAT("rx_size_1023", stats.rx_size_1023), |
| 131 | I40E_PF_STAT("rx_size_1522", stats.rx_size_1522), |
| 132 | I40E_PF_STAT("rx_size_big", stats.rx_size_big), |
| 133 | I40E_PF_STAT("tx_size_64", stats.tx_size_64), |
| 134 | I40E_PF_STAT("tx_size_127", stats.tx_size_127), |
| 135 | I40E_PF_STAT("tx_size_255", stats.tx_size_255), |
| 136 | I40E_PF_STAT("tx_size_511", stats.tx_size_511), |
| 137 | I40E_PF_STAT("tx_size_1023", stats.tx_size_1023), |
| 138 | I40E_PF_STAT("tx_size_1522", stats.tx_size_1522), |
| 139 | I40E_PF_STAT("tx_size_big", stats.tx_size_big), |
| 140 | I40E_PF_STAT("rx_undersize", stats.rx_undersize), |
| 141 | I40E_PF_STAT("rx_fragments", stats.rx_fragments), |
| 142 | I40E_PF_STAT("rx_oversize", stats.rx_oversize), |
| 143 | I40E_PF_STAT("rx_jabber", stats.rx_jabber), |
| 144 | I40E_PF_STAT("VF_admin_queue_requests", vf_aq_requests), |
Jacob Keller | beb0dff | 2014-01-11 05:43:19 +0000 | [diff] [blame] | 145 | I40E_PF_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared), |
Anjali Singhai Jain | 60793f4a | 2014-07-09 07:46:23 +0000 | [diff] [blame] | 146 | I40E_PF_STAT("fdir_flush_cnt", fd_flush_cnt), |
Anjali Singhai Jain | 433c47d | 2014-05-22 06:32:17 +0000 | [diff] [blame] | 147 | I40E_PF_STAT("fdir_atr_match", stats.fd_atr_match), |
Anjali Singhai Jain | 60ccd45 | 2015-04-16 20:06:01 -0400 | [diff] [blame] | 148 | I40E_PF_STAT("fdir_atr_tunnel_match", stats.fd_atr_tunnel_match), |
Anjali Singhai Jain | d0389e5 | 2015-04-22 19:34:05 -0400 | [diff] [blame] | 149 | I40E_PF_STAT("fdir_atr_status", stats.fd_atr_status), |
Anjali Singhai Jain | 433c47d | 2014-05-22 06:32:17 +0000 | [diff] [blame] | 150 | I40E_PF_STAT("fdir_sb_match", stats.fd_sb_match), |
Anjali Singhai Jain | d0389e5 | 2015-04-22 19:34:05 -0400 | [diff] [blame] | 151 | I40E_PF_STAT("fdir_sb_status", stats.fd_sb_status), |
Anjali Singhai Jain | 433c47d | 2014-05-22 06:32:17 +0000 | [diff] [blame] | 152 | |
Anjali Singhai Jain | bee5af7 | 2014-03-06 08:59:50 +0000 | [diff] [blame] | 153 | /* LPI stats */ |
| 154 | I40E_PF_STAT("tx_lpi_status", stats.tx_lpi_status), |
| 155 | I40E_PF_STAT("rx_lpi_status", stats.rx_lpi_status), |
| 156 | I40E_PF_STAT("tx_lpi_count", stats.tx_lpi_count), |
| 157 | I40E_PF_STAT("rx_lpi_count", stats.rx_lpi_count), |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
Vasu Dev | 38e0043 | 2014-08-01 13:27:03 -0700 | [diff] [blame] | 160 | #ifdef I40E_FCOE |
| 161 | static const struct i40e_stats i40e_gstrings_fcoe_stats[] = { |
| 162 | I40E_VSI_STAT("fcoe_bad_fccrc", fcoe_stats.fcoe_bad_fccrc), |
| 163 | I40E_VSI_STAT("rx_fcoe_dropped", fcoe_stats.rx_fcoe_dropped), |
| 164 | I40E_VSI_STAT("rx_fcoe_packets", fcoe_stats.rx_fcoe_packets), |
| 165 | I40E_VSI_STAT("rx_fcoe_dwords", fcoe_stats.rx_fcoe_dwords), |
| 166 | I40E_VSI_STAT("fcoe_ddp_count", fcoe_stats.fcoe_ddp_count), |
| 167 | I40E_VSI_STAT("fcoe_last_error", fcoe_stats.fcoe_last_error), |
| 168 | I40E_VSI_STAT("tx_fcoe_packets", fcoe_stats.tx_fcoe_packets), |
| 169 | I40E_VSI_STAT("tx_fcoe_dwords", fcoe_stats.tx_fcoe_dwords), |
| 170 | }; |
| 171 | |
| 172 | #endif /* I40E_FCOE */ |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 173 | #define I40E_QUEUE_STATS_LEN(n) \ |
Shannon Nelson | 31cd840 | 2014-04-04 04:43:12 +0000 | [diff] [blame] | 174 | (((struct i40e_netdev_priv *)netdev_priv((n)))->vsi->num_queue_pairs \ |
| 175 | * 2 /* Tx and Rx together */ \ |
| 176 | * (sizeof(struct i40e_queue_stats) / sizeof(u64))) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 177 | #define I40E_GLOBAL_STATS_LEN ARRAY_SIZE(i40e_gstrings_stats) |
| 178 | #define I40E_NETDEV_STATS_LEN ARRAY_SIZE(i40e_gstrings_net_stats) |
Shannon Nelson | 41a9e55 | 2014-04-23 04:50:20 +0000 | [diff] [blame] | 179 | #define I40E_MISC_STATS_LEN ARRAY_SIZE(i40e_gstrings_misc_stats) |
Vasu Dev | 38e0043 | 2014-08-01 13:27:03 -0700 | [diff] [blame] | 180 | #ifdef I40E_FCOE |
| 181 | #define I40E_FCOE_STATS_LEN ARRAY_SIZE(i40e_gstrings_fcoe_stats) |
| 182 | #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \ |
| 183 | I40E_FCOE_STATS_LEN + \ |
| 184 | I40E_MISC_STATS_LEN + \ |
| 185 | I40E_QUEUE_STATS_LEN((n))) |
| 186 | #else |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 187 | #define I40E_VSI_STATS_LEN(n) (I40E_NETDEV_STATS_LEN + \ |
Shannon Nelson | 41a9e55 | 2014-04-23 04:50:20 +0000 | [diff] [blame] | 188 | I40E_MISC_STATS_LEN + \ |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 189 | I40E_QUEUE_STATS_LEN((n))) |
Vasu Dev | 38e0043 | 2014-08-01 13:27:03 -0700 | [diff] [blame] | 190 | #endif /* I40E_FCOE */ |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 191 | #define I40E_PFC_STATS_LEN ( \ |
| 192 | (FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_rx) + \ |
| 193 | FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_rx) + \ |
| 194 | FIELD_SIZEOF(struct i40e_pf, stats.priority_xoff_tx) + \ |
| 195 | FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_tx) + \ |
| 196 | FIELD_SIZEOF(struct i40e_pf, stats.priority_xon_2_xoff)) \ |
| 197 | / sizeof(u64)) |
Neerav Parikh | fe860af | 2015-07-10 19:36:02 -0400 | [diff] [blame] | 198 | #define I40E_VEB_TC_STATS_LEN ( \ |
| 199 | (FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_rx_packets) + \ |
| 200 | FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_rx_bytes) + \ |
| 201 | FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_tx_packets) + \ |
| 202 | FIELD_SIZEOF(struct i40e_veb, tc_stats.tc_tx_bytes)) \ |
| 203 | / sizeof(u64)) |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 204 | #define I40E_VEB_STATS_LEN ARRAY_SIZE(i40e_gstrings_veb_stats) |
Neerav Parikh | fe860af | 2015-07-10 19:36:02 -0400 | [diff] [blame] | 205 | #define I40E_VEB_STATS_TOTAL (I40E_VEB_STATS_LEN + I40E_VEB_TC_STATS_LEN) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 206 | #define I40E_PF_STATS_LEN(n) (I40E_GLOBAL_STATS_LEN + \ |
| 207 | I40E_PFC_STATS_LEN + \ |
| 208 | I40E_VSI_STATS_LEN((n))) |
| 209 | |
| 210 | enum i40e_ethtool_test_id { |
| 211 | I40E_ETH_TEST_REG = 0, |
| 212 | I40E_ETH_TEST_EEPROM, |
| 213 | I40E_ETH_TEST_INTR, |
| 214 | I40E_ETH_TEST_LOOPBACK, |
| 215 | I40E_ETH_TEST_LINK, |
| 216 | }; |
| 217 | |
| 218 | static const char i40e_gstrings_test[][ETH_GSTRING_LEN] = { |
| 219 | "Register test (offline)", |
| 220 | "Eeprom test (offline)", |
| 221 | "Interrupt test (offline)", |
| 222 | "Loopback test (offline)", |
| 223 | "Link test (on/offline)" |
| 224 | }; |
| 225 | |
| 226 | #define I40E_TEST_LEN (sizeof(i40e_gstrings_test) / ETH_GSTRING_LEN) |
| 227 | |
Greg Rose | 7e45ab4 | 2015-02-06 08:52:19 +0000 | [diff] [blame] | 228 | static const char i40e_priv_flags_strings[][ETH_GSTRING_LEN] = { |
| 229 | "NPAR", |
Shannon Nelson | 9ac7726 | 2015-08-27 11:42:40 -0400 | [diff] [blame] | 230 | "LinkPolling", |
Jesse Brandeburg | ef17178 | 2015-09-03 17:18:49 -0400 | [diff] [blame] | 231 | "flow-director-atr", |
Greg Rose | 7e45ab4 | 2015-02-06 08:52:19 +0000 | [diff] [blame] | 232 | }; |
| 233 | |
Shannon Nelson | 9ac7726 | 2015-08-27 11:42:40 -0400 | [diff] [blame] | 234 | #define I40E_PRIV_FLAGS_STR_LEN ARRAY_SIZE(i40e_priv_flags_strings) |
Greg Rose | 7e45ab4 | 2015-02-06 08:52:19 +0000 | [diff] [blame] | 235 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 236 | /** |
Shannon Nelson | f0d8c73 | 2014-12-11 07:06:32 +0000 | [diff] [blame] | 237 | * i40e_partition_setting_complaint - generic complaint for MFP restriction |
| 238 | * @pf: the PF struct |
| 239 | **/ |
| 240 | static void i40e_partition_setting_complaint(struct i40e_pf *pf) |
| 241 | { |
| 242 | dev_info(&pf->pdev->dev, |
| 243 | "The link settings are allowed to be changed only from the first partition of a given port. Please switch to the first partition in order to change the setting.\n"); |
| 244 | } |
| 245 | |
| 246 | /** |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 247 | * i40e_get_settings_link_up - Get the Link settings for when link is up |
| 248 | * @hw: hw structure |
| 249 | * @ecmd: ethtool command to fill in |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 250 | * @netdev: network interface device structure |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 251 | * |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 252 | **/ |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 253 | static void i40e_get_settings_link_up(struct i40e_hw *hw, |
| 254 | struct ethtool_cmd *ecmd, |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 255 | struct net_device *netdev, |
| 256 | struct i40e_pf *pf) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 257 | { |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 258 | struct i40e_link_status *hw_link_info = &hw->phy.link_info; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 259 | u32 link_speed = hw_link_info->link_speed; |
| 260 | |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 261 | /* Initialize supported and advertised settings based on phy settings */ |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 262 | switch (hw_link_info->phy_type) { |
| 263 | case I40E_PHY_TYPE_40GBASE_CR4: |
| 264 | case I40E_PHY_TYPE_40GBASE_CR4_CU: |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 265 | ecmd->supported = SUPPORTED_Autoneg | |
| 266 | SUPPORTED_40000baseCR4_Full; |
| 267 | ecmd->advertising = ADVERTISED_Autoneg | |
| 268 | ADVERTISED_40000baseCR4_Full; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 269 | break; |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 270 | case I40E_PHY_TYPE_XLAUI: |
| 271 | case I40E_PHY_TYPE_XLPPI: |
Catherine Sullivan | 180204c | 2015-02-26 16:14:58 +0000 | [diff] [blame] | 272 | case I40E_PHY_TYPE_40GBASE_AOC: |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 273 | ecmd->supported = SUPPORTED_40000baseCR4_Full; |
| 274 | break; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 275 | case I40E_PHY_TYPE_40GBASE_SR4: |
| 276 | ecmd->supported = SUPPORTED_40000baseSR4_Full; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 277 | break; |
| 278 | case I40E_PHY_TYPE_40GBASE_LR4: |
| 279 | ecmd->supported = SUPPORTED_40000baseLR4_Full; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 280 | break; |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 281 | case I40E_PHY_TYPE_10GBASE_SR: |
| 282 | case I40E_PHY_TYPE_10GBASE_LR: |
Catherine Sullivan | 124ed15 | 2014-07-12 07:28:12 +0000 | [diff] [blame] | 283 | case I40E_PHY_TYPE_1000BASE_SX: |
| 284 | case I40E_PHY_TYPE_1000BASE_LX: |
Catherine Sullivan | 0a862b4 | 2015-08-31 19:54:53 -0400 | [diff] [blame] | 285 | ecmd->supported = SUPPORTED_10000baseT_Full; |
| 286 | if (hw_link_info->module_type[2] & |
| 287 | I40E_MODULE_TYPE_1000BASE_SX || |
| 288 | hw_link_info->module_type[2] & |
| 289 | I40E_MODULE_TYPE_1000BASE_LX) { |
| 290 | ecmd->supported |= SUPPORTED_1000baseT_Full; |
| 291 | if (hw_link_info->requested_speeds & |
| 292 | I40E_LINK_SPEED_1GB) |
| 293 | ecmd->advertising |= ADVERTISED_1000baseT_Full; |
| 294 | } |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 295 | if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) |
| 296 | ecmd->advertising |= ADVERTISED_10000baseT_Full; |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 297 | break; |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 298 | case I40E_PHY_TYPE_10GBASE_T: |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 299 | case I40E_PHY_TYPE_1000BASE_T: |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 300 | ecmd->supported = SUPPORTED_Autoneg | |
Mitch Williams | 5960d33 | 2014-09-13 07:40:47 +0000 | [diff] [blame] | 301 | SUPPORTED_10000baseT_Full | |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 302 | SUPPORTED_1000baseT_Full; |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 303 | ecmd->advertising = ADVERTISED_Autoneg; |
| 304 | if (hw_link_info->requested_speeds & I40E_LINK_SPEED_10GB) |
| 305 | ecmd->advertising |= ADVERTISED_10000baseT_Full; |
| 306 | if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) |
| 307 | ecmd->advertising |= ADVERTISED_1000baseT_Full; |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 308 | break; |
| 309 | case I40E_PHY_TYPE_100BASE_TX: |
| 310 | ecmd->supported = SUPPORTED_Autoneg | |
| 311 | SUPPORTED_100baseT_Full; |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 312 | if (hw_link_info->requested_speeds & I40E_LINK_SPEED_100MB) |
| 313 | ecmd->advertising |= ADVERTISED_100baseT_Full; |
| 314 | break; |
| 315 | case I40E_PHY_TYPE_10GBASE_CR1_CU: |
| 316 | case I40E_PHY_TYPE_10GBASE_CR1: |
| 317 | ecmd->supported = SUPPORTED_Autoneg | |
| 318 | SUPPORTED_10000baseT_Full; |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 319 | ecmd->advertising = ADVERTISED_Autoneg | |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 320 | ADVERTISED_10000baseT_Full; |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 321 | break; |
| 322 | case I40E_PHY_TYPE_XAUI: |
| 323 | case I40E_PHY_TYPE_XFI: |
| 324 | case I40E_PHY_TYPE_SFI: |
| 325 | case I40E_PHY_TYPE_10GBASE_SFPP_CU: |
Catherine Sullivan | 180204c | 2015-02-26 16:14:58 +0000 | [diff] [blame] | 326 | case I40E_PHY_TYPE_10GBASE_AOC: |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 327 | ecmd->supported = SUPPORTED_10000baseT_Full; |
| 328 | break; |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 329 | case I40E_PHY_TYPE_SGMII: |
| 330 | ecmd->supported = SUPPORTED_Autoneg | |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 331 | SUPPORTED_1000baseT_Full; |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 332 | if (hw_link_info->requested_speeds & I40E_LINK_SPEED_1GB) |
| 333 | ecmd->advertising |= ADVERTISED_1000baseT_Full; |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 334 | if (pf->hw.mac.type == I40E_MAC_X722) { |
| 335 | ecmd->supported |= SUPPORTED_100baseT_Full; |
| 336 | if (hw_link_info->requested_speeds & |
| 337 | I40E_LINK_SPEED_100MB) |
| 338 | ecmd->advertising |= ADVERTISED_100baseT_Full; |
| 339 | } |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 340 | break; |
Catherine Sullivan | fc72dbc | 2015-09-01 11:36:30 -0400 | [diff] [blame] | 341 | /* Backplane is set based on supported phy types in get_settings |
| 342 | * so don't set anything here but don't warn either |
| 343 | */ |
| 344 | case I40E_PHY_TYPE_40GBASE_KR4: |
| 345 | case I40E_PHY_TYPE_20GBASE_KR2: |
| 346 | case I40E_PHY_TYPE_10GBASE_KR: |
| 347 | case I40E_PHY_TYPE_10GBASE_KX4: |
| 348 | case I40E_PHY_TYPE_1000BASE_KX: |
| 349 | break; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 350 | default: |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 351 | /* if we got here and link is up something bad is afoot */ |
Catherine Sullivan | 124ed15 | 2014-07-12 07:28:12 +0000 | [diff] [blame] | 352 | netdev_info(netdev, "WARNING: Link is up but PHY type 0x%x is not recognized.\n", |
| 353 | hw_link_info->phy_type); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 354 | } |
| 355 | |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 356 | /* Set speed and duplex */ |
| 357 | switch (link_speed) { |
| 358 | case I40E_LINK_SPEED_40GB: |
Greg Rose | edf5cff | 2015-04-07 19:45:41 -0400 | [diff] [blame] | 359 | ethtool_cmd_speed_set(ecmd, SPEED_40000); |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 360 | break; |
Jesse Brandeburg | ae24b40 | 2015-03-27 00:12:09 -0700 | [diff] [blame] | 361 | case I40E_LINK_SPEED_20GB: |
| 362 | ethtool_cmd_speed_set(ecmd, SPEED_20000); |
| 363 | break; |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 364 | case I40E_LINK_SPEED_10GB: |
| 365 | ethtool_cmd_speed_set(ecmd, SPEED_10000); |
| 366 | break; |
| 367 | case I40E_LINK_SPEED_1GB: |
| 368 | ethtool_cmd_speed_set(ecmd, SPEED_1000); |
| 369 | break; |
| 370 | case I40E_LINK_SPEED_100MB: |
| 371 | ethtool_cmd_speed_set(ecmd, SPEED_100); |
| 372 | break; |
| 373 | default: |
| 374 | break; |
| 375 | } |
| 376 | ecmd->duplex = DUPLEX_FULL; |
| 377 | } |
| 378 | |
| 379 | /** |
| 380 | * i40e_get_settings_link_down - Get the Link settings for when link is down |
| 381 | * @hw: hw structure |
| 382 | * @ecmd: ethtool command to fill in |
| 383 | * |
| 384 | * Reports link settings that can be determined when link is down |
| 385 | **/ |
| 386 | static void i40e_get_settings_link_down(struct i40e_hw *hw, |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 387 | struct ethtool_cmd *ecmd, |
| 388 | struct i40e_pf *pf) |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 389 | { |
Catherine Sullivan | fc72dbc | 2015-09-01 11:36:30 -0400 | [diff] [blame] | 390 | enum i40e_aq_capabilities_phy_type phy_types = hw->phy.phy_types; |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 391 | |
| 392 | /* link is down and the driver needs to fall back on |
Catherine Sullivan | fc72dbc | 2015-09-01 11:36:30 -0400 | [diff] [blame] | 393 | * supported phy types to figure out what info to display |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 394 | */ |
Catherine Sullivan | fc72dbc | 2015-09-01 11:36:30 -0400 | [diff] [blame] | 395 | ecmd->supported = 0x0; |
| 396 | ecmd->advertising = 0x0; |
| 397 | if (phy_types & I40E_CAP_PHY_TYPE_SGMII) { |
| 398 | ecmd->supported |= SUPPORTED_Autoneg | |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 399 | SUPPORTED_1000baseT_Full; |
Catherine Sullivan | fc72dbc | 2015-09-01 11:36:30 -0400 | [diff] [blame] | 400 | ecmd->advertising |= ADVERTISED_Autoneg | |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 401 | ADVERTISED_1000baseT_Full; |
| 402 | if (pf->hw.mac.type == I40E_MAC_X722) { |
| 403 | ecmd->supported |= SUPPORTED_100baseT_Full; |
| 404 | ecmd->advertising |= ADVERTISED_100baseT_Full; |
| 405 | } |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 406 | } |
Catherine Sullivan | fc72dbc | 2015-09-01 11:36:30 -0400 | [diff] [blame] | 407 | if (phy_types & I40E_CAP_PHY_TYPE_XAUI || |
| 408 | phy_types & I40E_CAP_PHY_TYPE_XFI || |
| 409 | phy_types & I40E_CAP_PHY_TYPE_SFI || |
| 410 | phy_types & I40E_CAP_PHY_TYPE_10GBASE_SFPP_CU || |
| 411 | phy_types & I40E_CAP_PHY_TYPE_10GBASE_AOC) |
| 412 | ecmd->supported |= SUPPORTED_10000baseT_Full; |
| 413 | if (phy_types & I40E_CAP_PHY_TYPE_10GBASE_CR1_CU || |
| 414 | phy_types & I40E_CAP_PHY_TYPE_10GBASE_CR1 || |
| 415 | phy_types & I40E_CAP_PHY_TYPE_10GBASE_T || |
| 416 | phy_types & I40E_CAP_PHY_TYPE_10GBASE_SR || |
| 417 | phy_types & I40E_CAP_PHY_TYPE_10GBASE_LR) { |
| 418 | ecmd->supported |= SUPPORTED_Autoneg | |
| 419 | SUPPORTED_10000baseT_Full; |
| 420 | ecmd->advertising |= ADVERTISED_Autoneg | |
| 421 | ADVERTISED_10000baseT_Full; |
| 422 | } |
| 423 | if (phy_types & I40E_CAP_PHY_TYPE_XLAUI || |
| 424 | phy_types & I40E_CAP_PHY_TYPE_XLPPI || |
| 425 | phy_types & I40E_CAP_PHY_TYPE_40GBASE_AOC) |
| 426 | ecmd->supported |= SUPPORTED_40000baseCR4_Full; |
| 427 | if (phy_types & I40E_CAP_PHY_TYPE_40GBASE_CR4_CU || |
| 428 | phy_types & I40E_CAP_PHY_TYPE_40GBASE_CR4) { |
| 429 | ecmd->supported |= SUPPORTED_Autoneg | |
| 430 | SUPPORTED_40000baseCR4_Full; |
| 431 | ecmd->advertising |= ADVERTISED_Autoneg | |
| 432 | ADVERTISED_40000baseCR4_Full; |
| 433 | } |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 434 | if ((phy_types & I40E_CAP_PHY_TYPE_100BASE_TX) && |
| 435 | !(phy_types & I40E_CAP_PHY_TYPE_1000BASE_T)) { |
Catherine Sullivan | fc72dbc | 2015-09-01 11:36:30 -0400 | [diff] [blame] | 436 | ecmd->supported |= SUPPORTED_Autoneg | |
| 437 | SUPPORTED_100baseT_Full; |
| 438 | ecmd->advertising |= ADVERTISED_Autoneg | |
| 439 | ADVERTISED_100baseT_Full; |
| 440 | } |
| 441 | if (phy_types & I40E_CAP_PHY_TYPE_1000BASE_T || |
| 442 | phy_types & I40E_CAP_PHY_TYPE_1000BASE_SX || |
| 443 | phy_types & I40E_CAP_PHY_TYPE_1000BASE_LX || |
| 444 | phy_types & I40E_CAP_PHY_TYPE_1000BASE_T_OPTICAL) { |
| 445 | ecmd->supported |= SUPPORTED_Autoneg | |
| 446 | SUPPORTED_1000baseT_Full; |
| 447 | ecmd->advertising |= ADVERTISED_Autoneg | |
| 448 | ADVERTISED_1000baseT_Full; |
| 449 | } |
| 450 | if (phy_types & I40E_CAP_PHY_TYPE_40GBASE_SR4) |
| 451 | ecmd->supported |= SUPPORTED_40000baseSR4_Full; |
| 452 | if (phy_types & I40E_CAP_PHY_TYPE_40GBASE_LR4) |
| 453 | ecmd->supported |= SUPPORTED_40000baseLR4_Full; |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 454 | |
| 455 | /* With no link speed and duplex are unknown */ |
| 456 | ethtool_cmd_speed_set(ecmd, SPEED_UNKNOWN); |
| 457 | ecmd->duplex = DUPLEX_UNKNOWN; |
| 458 | } |
| 459 | |
| 460 | /** |
| 461 | * i40e_get_settings - Get Link Speed and Duplex settings |
| 462 | * @netdev: network interface device structure |
| 463 | * @ecmd: ethtool command |
| 464 | * |
| 465 | * Reports speed/duplex settings based on media_type |
| 466 | **/ |
| 467 | static int i40e_get_settings(struct net_device *netdev, |
| 468 | struct ethtool_cmd *ecmd) |
| 469 | { |
| 470 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 471 | struct i40e_pf *pf = np->vsi->back; |
| 472 | struct i40e_hw *hw = &pf->hw; |
| 473 | struct i40e_link_status *hw_link_info = &hw->phy.link_info; |
| 474 | bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP; |
| 475 | |
| 476 | if (link_up) |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 477 | i40e_get_settings_link_up(hw, ecmd, netdev, pf); |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 478 | else |
Catherine Sullivan | 3b6c217 | 2015-09-03 17:18:52 -0400 | [diff] [blame] | 479 | i40e_get_settings_link_down(hw, ecmd, pf); |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 480 | |
| 481 | /* Now set the settings that don't rely on link being up/down */ |
| 482 | |
Catherine Sullivan | fc72dbc | 2015-09-01 11:36:30 -0400 | [diff] [blame] | 483 | /* For backplane, supported and advertised are only reliant on the |
| 484 | * phy types the NVM specifies are supported. |
| 485 | */ |
| 486 | if (hw->device_id == I40E_DEV_ID_KX_B || |
| 487 | hw->device_id == I40E_DEV_ID_KX_C || |
| 488 | hw->device_id == I40E_DEV_ID_20G_KR2 || |
| 489 | hw->device_id == I40E_DEV_ID_20G_KR2_A) { |
| 490 | ecmd->supported = SUPPORTED_Autoneg; |
| 491 | ecmd->advertising = ADVERTISED_Autoneg; |
| 492 | if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_40GBASE_KR4) { |
| 493 | ecmd->supported |= SUPPORTED_40000baseKR4_Full; |
| 494 | ecmd->advertising |= ADVERTISED_40000baseKR4_Full; |
| 495 | } |
| 496 | if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_20GBASE_KR2) { |
| 497 | ecmd->supported |= SUPPORTED_20000baseKR2_Full; |
| 498 | ecmd->advertising |= ADVERTISED_20000baseKR2_Full; |
| 499 | } |
| 500 | if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_10GBASE_KR) { |
| 501 | ecmd->supported |= SUPPORTED_10000baseKR_Full; |
| 502 | ecmd->advertising |= ADVERTISED_10000baseKR_Full; |
| 503 | } |
| 504 | if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_10GBASE_KX4) { |
| 505 | ecmd->supported |= SUPPORTED_10000baseKX4_Full; |
| 506 | ecmd->advertising |= ADVERTISED_10000baseKX4_Full; |
| 507 | } |
| 508 | if (hw->phy.phy_types & I40E_CAP_PHY_TYPE_1000BASE_KX) { |
| 509 | ecmd->supported |= SUPPORTED_1000baseKX_Full; |
| 510 | ecmd->advertising |= ADVERTISED_1000baseKX_Full; |
| 511 | } |
| 512 | } |
| 513 | |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 514 | /* Set autoneg settings */ |
Jesse Brandeburg | c9a3d47 | 2013-11-26 10:49:10 +0000 | [diff] [blame] | 515 | ecmd->autoneg = ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? |
| 516 | AUTONEG_ENABLE : AUTONEG_DISABLE); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 517 | |
Jesse Brandeburg | c9a3d47 | 2013-11-26 10:49:10 +0000 | [diff] [blame] | 518 | switch (hw->phy.media_type) { |
| 519 | case I40E_MEDIA_TYPE_BACKPLANE: |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 520 | ecmd->supported |= SUPPORTED_Autoneg | |
| 521 | SUPPORTED_Backplane; |
| 522 | ecmd->advertising |= ADVERTISED_Autoneg | |
| 523 | ADVERTISED_Backplane; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 524 | ecmd->port = PORT_NONE; |
Jesse Brandeburg | c9a3d47 | 2013-11-26 10:49:10 +0000 | [diff] [blame] | 525 | break; |
| 526 | case I40E_MEDIA_TYPE_BASET: |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 527 | ecmd->supported |= SUPPORTED_TP; |
| 528 | ecmd->advertising |= ADVERTISED_TP; |
| 529 | ecmd->port = PORT_TP; |
Jesse Brandeburg | c9a3d47 | 2013-11-26 10:49:10 +0000 | [diff] [blame] | 530 | break; |
| 531 | case I40E_MEDIA_TYPE_DA: |
| 532 | case I40E_MEDIA_TYPE_CX4: |
Jesse Brandeburg | be405eb | 2013-11-20 10:02:50 +0000 | [diff] [blame] | 533 | ecmd->supported |= SUPPORTED_FIBRE; |
| 534 | ecmd->advertising |= ADVERTISED_FIBRE; |
| 535 | ecmd->port = PORT_DA; |
Jesse Brandeburg | c9a3d47 | 2013-11-26 10:49:10 +0000 | [diff] [blame] | 536 | break; |
| 537 | case I40E_MEDIA_TYPE_FIBER: |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 538 | ecmd->supported |= SUPPORTED_FIBRE; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 539 | ecmd->port = PORT_FIBRE; |
Jesse Brandeburg | c9a3d47 | 2013-11-26 10:49:10 +0000 | [diff] [blame] | 540 | break; |
| 541 | case I40E_MEDIA_TYPE_UNKNOWN: |
| 542 | default: |
| 543 | ecmd->port = PORT_OTHER; |
| 544 | break; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 545 | } |
| 546 | |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 547 | /* Set transceiver */ |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 548 | ecmd->transceiver = XCVR_EXTERNAL; |
| 549 | |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 550 | /* Set flow control settings */ |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 551 | ecmd->supported |= SUPPORTED_Pause; |
| 552 | |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 553 | switch (hw->fc.requested_mode) { |
Jesse Brandeburg | 4e91bcd | 2014-06-04 08:45:23 +0000 | [diff] [blame] | 554 | case I40E_FC_FULL: |
| 555 | ecmd->advertising |= ADVERTISED_Pause; |
| 556 | break; |
| 557 | case I40E_FC_TX_PAUSE: |
| 558 | ecmd->advertising |= ADVERTISED_Asym_Pause; |
| 559 | break; |
| 560 | case I40E_FC_RX_PAUSE: |
| 561 | ecmd->advertising |= (ADVERTISED_Pause | |
| 562 | ADVERTISED_Asym_Pause); |
| 563 | break; |
| 564 | default: |
| 565 | ecmd->advertising &= ~(ADVERTISED_Pause | |
| 566 | ADVERTISED_Asym_Pause); |
| 567 | break; |
| 568 | } |
| 569 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 570 | return 0; |
| 571 | } |
| 572 | |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 573 | /** |
| 574 | * i40e_set_settings - Set Speed and Duplex |
| 575 | * @netdev: network interface device structure |
| 576 | * @ecmd: ethtool command |
| 577 | * |
| 578 | * Set speed/duplex per media_types advertised/forced |
| 579 | **/ |
| 580 | static int i40e_set_settings(struct net_device *netdev, |
| 581 | struct ethtool_cmd *ecmd) |
| 582 | { |
| 583 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 584 | struct i40e_aq_get_phy_abilities_resp abilities; |
| 585 | struct i40e_aq_set_phy_config config; |
| 586 | struct i40e_pf *pf = np->vsi->back; |
| 587 | struct i40e_vsi *vsi = np->vsi; |
| 588 | struct i40e_hw *hw = &pf->hw; |
| 589 | struct ethtool_cmd safe_ecmd; |
| 590 | i40e_status status = 0; |
| 591 | bool change = false; |
| 592 | int err = 0; |
| 593 | u8 autoneg; |
| 594 | u32 advertise; |
| 595 | |
Shannon Nelson | f0d8c73 | 2014-12-11 07:06:32 +0000 | [diff] [blame] | 596 | /* Changing port settings is not supported if this isn't the |
| 597 | * port's controlling PF |
| 598 | */ |
| 599 | if (hw->partition_id != 1) { |
| 600 | i40e_partition_setting_complaint(pf); |
| 601 | return -EOPNOTSUPP; |
| 602 | } |
| 603 | |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 604 | if (vsi != pf->vsi[pf->lan_vsi]) |
| 605 | return -EOPNOTSUPP; |
| 606 | |
| 607 | if (hw->phy.media_type != I40E_MEDIA_TYPE_BASET && |
| 608 | hw->phy.media_type != I40E_MEDIA_TYPE_FIBER && |
Catherine Sullivan | c57e9f1 | 2014-07-12 07:28:13 +0000 | [diff] [blame] | 609 | hw->phy.media_type != I40E_MEDIA_TYPE_BACKPLANE && |
| 610 | hw->phy.link_info.link_info & I40E_AQ_LINK_UP) |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 611 | return -EOPNOTSUPP; |
| 612 | |
Catherine Sullivan | fc72dbc | 2015-09-01 11:36:30 -0400 | [diff] [blame] | 613 | if (hw->device_id == I40E_DEV_ID_KX_B || |
| 614 | hw->device_id == I40E_DEV_ID_KX_C || |
| 615 | hw->device_id == I40E_DEV_ID_20G_KR2 || |
| 616 | hw->device_id == I40E_DEV_ID_20G_KR2_A) { |
| 617 | netdev_info(netdev, "Changing settings is not supported on backplane.\n"); |
| 618 | return -EOPNOTSUPP; |
| 619 | } |
| 620 | |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 621 | /* get our own copy of the bits to check against */ |
| 622 | memset(&safe_ecmd, 0, sizeof(struct ethtool_cmd)); |
| 623 | i40e_get_settings(netdev, &safe_ecmd); |
| 624 | |
| 625 | /* save autoneg and speed out of ecmd */ |
| 626 | autoneg = ecmd->autoneg; |
| 627 | advertise = ecmd->advertising; |
| 628 | |
| 629 | /* set autoneg and speed back to what they currently are */ |
| 630 | ecmd->autoneg = safe_ecmd.autoneg; |
| 631 | ecmd->advertising = safe_ecmd.advertising; |
| 632 | |
| 633 | ecmd->cmd = safe_ecmd.cmd; |
| 634 | /* If ecmd and safe_ecmd are not the same now, then they are |
| 635 | * trying to set something that we do not support |
| 636 | */ |
| 637 | if (memcmp(ecmd, &safe_ecmd, sizeof(struct ethtool_cmd))) |
| 638 | return -EOPNOTSUPP; |
| 639 | |
| 640 | while (test_bit(__I40E_CONFIG_BUSY, &vsi->state)) |
| 641 | usleep_range(1000, 2000); |
| 642 | |
| 643 | /* Get the current phy config */ |
| 644 | status = i40e_aq_get_phy_capabilities(hw, false, false, &abilities, |
| 645 | NULL); |
| 646 | if (status) |
| 647 | return -EAGAIN; |
| 648 | |
Catherine Sullivan | 124ed15 | 2014-07-12 07:28:12 +0000 | [diff] [blame] | 649 | /* Copy abilities to config in case autoneg is not |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 650 | * set below |
| 651 | */ |
| 652 | memset(&config, 0, sizeof(struct i40e_aq_set_phy_config)); |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 653 | config.abilities = abilities.abilities; |
| 654 | |
| 655 | /* Check autoneg */ |
| 656 | if (autoneg == AUTONEG_ENABLE) { |
| 657 | /* If autoneg is not supported, return error */ |
| 658 | if (!(safe_ecmd.supported & SUPPORTED_Autoneg)) { |
| 659 | netdev_info(netdev, "Autoneg not supported on this phy\n"); |
| 660 | return -EINVAL; |
| 661 | } |
| 662 | /* If autoneg was not already enabled */ |
| 663 | if (!(hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED)) { |
| 664 | config.abilities = abilities.abilities | |
| 665 | I40E_AQ_PHY_ENABLE_AN; |
| 666 | change = true; |
| 667 | } |
| 668 | } else { |
| 669 | /* If autoneg is supported 10GBASE_T is the only phy that |
| 670 | * can disable it, so otherwise return error |
| 671 | */ |
| 672 | if (safe_ecmd.supported & SUPPORTED_Autoneg && |
| 673 | hw->phy.link_info.phy_type != I40E_PHY_TYPE_10GBASE_T) { |
| 674 | netdev_info(netdev, "Autoneg cannot be disabled on this phy\n"); |
| 675 | return -EINVAL; |
| 676 | } |
| 677 | /* If autoneg is currently enabled */ |
| 678 | if (hw->phy.link_info.an_info & I40E_AQ_AN_COMPLETED) { |
Mitch Williams | 5960d33 | 2014-09-13 07:40:47 +0000 | [diff] [blame] | 679 | config.abilities = abilities.abilities & |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 680 | ~I40E_AQ_PHY_ENABLE_AN; |
| 681 | change = true; |
| 682 | } |
| 683 | } |
| 684 | |
| 685 | if (advertise & ~safe_ecmd.supported) |
| 686 | return -EINVAL; |
| 687 | |
| 688 | if (advertise & ADVERTISED_100baseT_Full) |
Catherine Sullivan | 124ed15 | 2014-07-12 07:28:12 +0000 | [diff] [blame] | 689 | config.link_speed |= I40E_LINK_SPEED_100MB; |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 690 | if (advertise & ADVERTISED_1000baseT_Full || |
| 691 | advertise & ADVERTISED_1000baseKX_Full) |
Catherine Sullivan | 124ed15 | 2014-07-12 07:28:12 +0000 | [diff] [blame] | 692 | config.link_speed |= I40E_LINK_SPEED_1GB; |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 693 | if (advertise & ADVERTISED_10000baseT_Full || |
| 694 | advertise & ADVERTISED_10000baseKX4_Full || |
| 695 | advertise & ADVERTISED_10000baseKR_Full) |
Catherine Sullivan | 124ed15 | 2014-07-12 07:28:12 +0000 | [diff] [blame] | 696 | config.link_speed |= I40E_LINK_SPEED_10GB; |
Jesse Brandeburg | ae24b40 | 2015-03-27 00:12:09 -0700 | [diff] [blame] | 697 | if (advertise & ADVERTISED_20000baseKR2_Full) |
| 698 | config.link_speed |= I40E_LINK_SPEED_20GB; |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 699 | if (advertise & ADVERTISED_40000baseKR4_Full || |
| 700 | advertise & ADVERTISED_40000baseCR4_Full || |
| 701 | advertise & ADVERTISED_40000baseSR4_Full || |
| 702 | advertise & ADVERTISED_40000baseLR4_Full) |
Catherine Sullivan | 124ed15 | 2014-07-12 07:28:12 +0000 | [diff] [blame] | 703 | config.link_speed |= I40E_LINK_SPEED_40GB; |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 704 | |
Catherine Sullivan | 0002e11 | 2015-08-26 15:14:16 -0400 | [diff] [blame] | 705 | /* If speed didn't get set, set it to what it currently is. |
| 706 | * This is needed because if advertise is 0 (as it is when autoneg |
| 707 | * is disabled) then speed won't get set. |
| 708 | */ |
| 709 | if (!config.link_speed) |
| 710 | config.link_speed = abilities.link_speed; |
| 711 | |
Catherine Sullivan | 124ed15 | 2014-07-12 07:28:12 +0000 | [diff] [blame] | 712 | if (change || (abilities.link_speed != config.link_speed)) { |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 713 | /* copy over the rest of the abilities */ |
| 714 | config.phy_type = abilities.phy_type; |
| 715 | config.eee_capability = abilities.eee_capability; |
| 716 | config.eeer = abilities.eeer_val; |
| 717 | config.low_power_ctrl = abilities.d3_lpan; |
| 718 | |
Catherine Sullivan | e827845 | 2015-02-06 08:52:08 +0000 | [diff] [blame] | 719 | /* save the requested speeds */ |
| 720 | hw->phy.link_info.requested_speeds = config.link_speed; |
Catherine Sullivan | 9412851 | 2014-07-12 07:28:16 +0000 | [diff] [blame] | 721 | /* set link and auto negotiation so changes take effect */ |
| 722 | config.abilities |= I40E_AQ_PHY_ENABLE_ATOMIC_LINK; |
| 723 | /* If link is up put link down */ |
| 724 | if (hw->phy.link_info.link_info & I40E_AQ_LINK_UP) { |
| 725 | /* Tell the OS link is going down, the link will go |
| 726 | * back up when fw says it is ready asynchronously |
| 727 | */ |
Matt Jared | c156f85 | 2015-08-27 11:42:39 -0400 | [diff] [blame] | 728 | i40e_print_link_message(vsi, false); |
Catherine Sullivan | 9412851 | 2014-07-12 07:28:16 +0000 | [diff] [blame] | 729 | netif_carrier_off(netdev); |
| 730 | netif_tx_stop_all_queues(netdev); |
| 731 | } |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 732 | |
| 733 | /* make the aq call */ |
| 734 | status = i40e_aq_set_phy_config(hw, &config, NULL); |
| 735 | if (status) { |
Shannon Nelson | f1c7e72 | 2015-06-04 16:24:01 -0400 | [diff] [blame] | 736 | netdev_info(netdev, "Set phy config failed, err %s aq_err %s\n", |
| 737 | i40e_stat_str(hw, status), |
| 738 | i40e_aq_str(hw, hw->aq.asq_last_status)); |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 739 | return -EAGAIN; |
| 740 | } |
| 741 | |
Catherine Sullivan | 0a862b4 | 2015-08-31 19:54:53 -0400 | [diff] [blame] | 742 | status = i40e_update_link_info(hw); |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 743 | if (status) |
Shannon Nelson | f1c7e72 | 2015-06-04 16:24:01 -0400 | [diff] [blame] | 744 | netdev_info(netdev, "Updating link info failed with err %s aq_err %s\n", |
| 745 | i40e_stat_str(hw, status), |
| 746 | i40e_aq_str(hw, hw->aq.asq_last_status)); |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 747 | |
| 748 | } else { |
| 749 | netdev_info(netdev, "Nothing changed, exiting without setting anything.\n"); |
| 750 | } |
| 751 | |
| 752 | return err; |
| 753 | } |
| 754 | |
Jesse Brandeburg | a659972 | 2014-06-04 08:45:25 +0000 | [diff] [blame] | 755 | static int i40e_nway_reset(struct net_device *netdev) |
| 756 | { |
| 757 | /* restart autonegotiation */ |
| 758 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 759 | struct i40e_pf *pf = np->vsi->back; |
| 760 | struct i40e_hw *hw = &pf->hw; |
| 761 | bool link_up = hw->phy.link_info.link_info & I40E_AQ_LINK_UP; |
| 762 | i40e_status ret = 0; |
| 763 | |
| 764 | ret = i40e_aq_set_link_restart_an(hw, link_up, NULL); |
| 765 | if (ret) { |
Shannon Nelson | f1c7e72 | 2015-06-04 16:24:01 -0400 | [diff] [blame] | 766 | netdev_info(netdev, "link restart failed, err %s aq_err %s\n", |
| 767 | i40e_stat_str(hw, ret), |
| 768 | i40e_aq_str(hw, hw->aq.asq_last_status)); |
Jesse Brandeburg | a659972 | 2014-06-04 08:45:25 +0000 | [diff] [blame] | 769 | return -EIO; |
| 770 | } |
| 771 | |
| 772 | return 0; |
| 773 | } |
| 774 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 775 | /** |
| 776 | * i40e_get_pauseparam - Get Flow Control status |
| 777 | * Return tx/rx-pause status |
| 778 | **/ |
| 779 | static void i40e_get_pauseparam(struct net_device *netdev, |
| 780 | struct ethtool_pauseparam *pause) |
| 781 | { |
| 782 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 783 | struct i40e_pf *pf = np->vsi->back; |
| 784 | struct i40e_hw *hw = &pf->hw; |
| 785 | struct i40e_link_status *hw_link_info = &hw->phy.link_info; |
Neerav Parikh | 4b7698c | 2014-11-12 00:18:57 +0000 | [diff] [blame] | 786 | struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 787 | |
| 788 | pause->autoneg = |
| 789 | ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? |
| 790 | AUTONEG_ENABLE : AUTONEG_DISABLE); |
| 791 | |
Neerav Parikh | 4b7698c | 2014-11-12 00:18:57 +0000 | [diff] [blame] | 792 | /* PFC enabled so report LFC as off */ |
| 793 | if (dcbx_cfg->pfc.pfcenable) { |
| 794 | pause->rx_pause = 0; |
| 795 | pause->tx_pause = 0; |
| 796 | return; |
| 797 | } |
| 798 | |
Jesse Brandeburg | d52c20b | 2013-11-26 10:49:15 +0000 | [diff] [blame] | 799 | if (hw->fc.current_mode == I40E_FC_RX_PAUSE) { |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 800 | pause->rx_pause = 1; |
Jesse Brandeburg | d52c20b | 2013-11-26 10:49:15 +0000 | [diff] [blame] | 801 | } else if (hw->fc.current_mode == I40E_FC_TX_PAUSE) { |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 802 | pause->tx_pause = 1; |
Jesse Brandeburg | d52c20b | 2013-11-26 10:49:15 +0000 | [diff] [blame] | 803 | } else if (hw->fc.current_mode == I40E_FC_FULL) { |
| 804 | pause->rx_pause = 1; |
| 805 | pause->tx_pause = 1; |
| 806 | } |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 807 | } |
| 808 | |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 809 | /** |
| 810 | * i40e_set_pauseparam - Set Flow Control parameter |
| 811 | * @netdev: network interface device structure |
| 812 | * @pause: return tx/rx flow control status |
| 813 | **/ |
| 814 | static int i40e_set_pauseparam(struct net_device *netdev, |
| 815 | struct ethtool_pauseparam *pause) |
| 816 | { |
| 817 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 818 | struct i40e_pf *pf = np->vsi->back; |
| 819 | struct i40e_vsi *vsi = np->vsi; |
| 820 | struct i40e_hw *hw = &pf->hw; |
| 821 | struct i40e_link_status *hw_link_info = &hw->phy.link_info; |
Neerav Parikh | 4b7698c | 2014-11-12 00:18:57 +0000 | [diff] [blame] | 822 | struct i40e_dcbx_config *dcbx_cfg = &hw->local_dcbx_config; |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 823 | bool link_up = hw_link_info->link_info & I40E_AQ_LINK_UP; |
| 824 | i40e_status status; |
| 825 | u8 aq_failures; |
Catherine Sullivan | 7d62dac | 2014-07-09 07:46:18 +0000 | [diff] [blame] | 826 | int err = 0; |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 827 | |
Shannon Nelson | f0d8c73 | 2014-12-11 07:06:32 +0000 | [diff] [blame] | 828 | /* Changing the port's flow control is not supported if this isn't the |
| 829 | * port's controlling PF |
| 830 | */ |
| 831 | if (hw->partition_id != 1) { |
| 832 | i40e_partition_setting_complaint(pf); |
| 833 | return -EOPNOTSUPP; |
| 834 | } |
| 835 | |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 836 | if (vsi != pf->vsi[pf->lan_vsi]) |
| 837 | return -EOPNOTSUPP; |
| 838 | |
| 839 | if (pause->autoneg != ((hw_link_info->an_info & I40E_AQ_AN_COMPLETED) ? |
| 840 | AUTONEG_ENABLE : AUTONEG_DISABLE)) { |
| 841 | netdev_info(netdev, "To change autoneg please use: ethtool -s <dev> autoneg <on|off>\n"); |
| 842 | return -EOPNOTSUPP; |
| 843 | } |
| 844 | |
| 845 | /* If we have link and don't have autoneg */ |
| 846 | if (!test_bit(__I40E_DOWN, &pf->state) && |
| 847 | !(hw_link_info->an_info & I40E_AQ_AN_COMPLETED)) { |
| 848 | /* Send message that it might not necessarily work*/ |
| 849 | netdev_info(netdev, "Autoneg did not complete so changing settings may not result in an actual change.\n"); |
| 850 | } |
| 851 | |
Neerav Parikh | 4b7698c | 2014-11-12 00:18:57 +0000 | [diff] [blame] | 852 | if (dcbx_cfg->pfc.pfcenable) { |
| 853 | netdev_info(netdev, |
| 854 | "Priority flow control enabled. Cannot set link flow control.\n"); |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 855 | return -EOPNOTSUPP; |
| 856 | } |
| 857 | |
| 858 | if (pause->rx_pause && pause->tx_pause) |
| 859 | hw->fc.requested_mode = I40E_FC_FULL; |
| 860 | else if (pause->rx_pause && !pause->tx_pause) |
| 861 | hw->fc.requested_mode = I40E_FC_RX_PAUSE; |
| 862 | else if (!pause->rx_pause && pause->tx_pause) |
| 863 | hw->fc.requested_mode = I40E_FC_TX_PAUSE; |
| 864 | else if (!pause->rx_pause && !pause->tx_pause) |
| 865 | hw->fc.requested_mode = I40E_FC_NONE; |
| 866 | else |
| 867 | return -EINVAL; |
| 868 | |
Catherine Sullivan | 9412851 | 2014-07-12 07:28:16 +0000 | [diff] [blame] | 869 | /* Tell the OS link is going down, the link will go back up when fw |
| 870 | * says it is ready asynchronously |
| 871 | */ |
Matt Jared | c156f85 | 2015-08-27 11:42:39 -0400 | [diff] [blame] | 872 | i40e_print_link_message(vsi, false); |
Catherine Sullivan | 9412851 | 2014-07-12 07:28:16 +0000 | [diff] [blame] | 873 | netif_carrier_off(netdev); |
| 874 | netif_tx_stop_all_queues(netdev); |
| 875 | |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 876 | /* Set the fc mode and only restart an if link is up*/ |
| 877 | status = i40e_set_fc(hw, &aq_failures, link_up); |
| 878 | |
| 879 | if (aq_failures & I40E_SET_FC_AQ_FAIL_GET) { |
Shannon Nelson | f1c7e72 | 2015-06-04 16:24:01 -0400 | [diff] [blame] | 880 | netdev_info(netdev, "Set fc failed on the get_phy_capabilities call with err %s aq_err %s\n", |
| 881 | i40e_stat_str(hw, status), |
| 882 | i40e_aq_str(hw, hw->aq.asq_last_status)); |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 883 | err = -EAGAIN; |
| 884 | } |
| 885 | if (aq_failures & I40E_SET_FC_AQ_FAIL_SET) { |
Shannon Nelson | f1c7e72 | 2015-06-04 16:24:01 -0400 | [diff] [blame] | 886 | netdev_info(netdev, "Set fc failed on the set_phy_config call with err %s aq_err %s\n", |
| 887 | i40e_stat_str(hw, status), |
| 888 | i40e_aq_str(hw, hw->aq.asq_last_status)); |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 889 | err = -EAGAIN; |
| 890 | } |
| 891 | if (aq_failures & I40E_SET_FC_AQ_FAIL_UPDATE) { |
Shannon Nelson | f1c7e72 | 2015-06-04 16:24:01 -0400 | [diff] [blame] | 892 | netdev_info(netdev, "Set fc failed on the get_link_info call with err %s aq_err %s\n", |
| 893 | i40e_stat_str(hw, status), |
| 894 | i40e_aq_str(hw, hw->aq.asq_last_status)); |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 895 | err = -EAGAIN; |
| 896 | } |
| 897 | |
Catherine Sullivan | 7d62dac | 2014-07-09 07:46:18 +0000 | [diff] [blame] | 898 | if (!test_bit(__I40E_DOWN, &pf->state)) { |
| 899 | /* Give it a little more time to try to come back */ |
| 900 | msleep(75); |
| 901 | if (!test_bit(__I40E_DOWN, &pf->state)) |
| 902 | return i40e_nway_reset(netdev); |
| 903 | } |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 904 | |
| 905 | return err; |
| 906 | } |
| 907 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 908 | static u32 i40e_get_msglevel(struct net_device *netdev) |
| 909 | { |
| 910 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 911 | struct i40e_pf *pf = np->vsi->back; |
| 912 | |
| 913 | return pf->msg_enable; |
| 914 | } |
| 915 | |
| 916 | static void i40e_set_msglevel(struct net_device *netdev, u32 data) |
| 917 | { |
| 918 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 919 | struct i40e_pf *pf = np->vsi->back; |
| 920 | |
| 921 | if (I40E_DEBUG_USER & data) |
| 922 | pf->hw.debug_mask = data; |
| 923 | pf->msg_enable = data; |
| 924 | } |
| 925 | |
| 926 | static int i40e_get_regs_len(struct net_device *netdev) |
| 927 | { |
| 928 | int reg_count = 0; |
| 929 | int i; |
| 930 | |
| 931 | for (i = 0; i40e_reg_list[i].offset != 0; i++) |
| 932 | reg_count += i40e_reg_list[i].elements; |
| 933 | |
| 934 | return reg_count * sizeof(u32); |
| 935 | } |
| 936 | |
| 937 | static void i40e_get_regs(struct net_device *netdev, struct ethtool_regs *regs, |
| 938 | void *p) |
| 939 | { |
| 940 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 941 | struct i40e_pf *pf = np->vsi->back; |
| 942 | struct i40e_hw *hw = &pf->hw; |
| 943 | u32 *reg_buf = p; |
| 944 | int i, j, ri; |
| 945 | u32 reg; |
| 946 | |
| 947 | /* Tell ethtool which driver-version-specific regs output we have. |
| 948 | * |
| 949 | * At some point, if we have ethtool doing special formatting of |
| 950 | * this data, it will rely on this version number to know how to |
| 951 | * interpret things. Hence, this needs to be updated if/when the |
| 952 | * diags register table is changed. |
| 953 | */ |
| 954 | regs->version = 1; |
| 955 | |
| 956 | /* loop through the diags reg table for what to print */ |
| 957 | ri = 0; |
| 958 | for (i = 0; i40e_reg_list[i].offset != 0; i++) { |
| 959 | for (j = 0; j < i40e_reg_list[i].elements; j++) { |
| 960 | reg = i40e_reg_list[i].offset |
| 961 | + (j * i40e_reg_list[i].stride); |
| 962 | reg_buf[ri++] = rd32(hw, reg); |
| 963 | } |
| 964 | } |
| 965 | |
| 966 | } |
| 967 | |
| 968 | static int i40e_get_eeprom(struct net_device *netdev, |
| 969 | struct ethtool_eeprom *eeprom, u8 *bytes) |
| 970 | { |
| 971 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 972 | struct i40e_hw *hw = &np->vsi->back->hw; |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 973 | struct i40e_pf *pf = np->vsi->back; |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 974 | int ret_val = 0, len, offset; |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 975 | u8 *eeprom_buff; |
| 976 | u16 i, sectors; |
| 977 | bool last; |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 978 | u32 magic; |
| 979 | |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 980 | #define I40E_NVM_SECTOR_SIZE 4096 |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 981 | if (eeprom->len == 0) |
| 982 | return -EINVAL; |
| 983 | |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 984 | /* check for NVMUpdate access method */ |
| 985 | magic = hw->vendor_id | (hw->device_id << 16); |
| 986 | if (eeprom->magic && eeprom->magic != magic) { |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 987 | struct i40e_nvm_access *cmd; |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 988 | int errno; |
| 989 | |
| 990 | /* make sure it is the right magic for NVMUpdate */ |
| 991 | if ((eeprom->magic >> 16) != hw->device_id) |
| 992 | return -EINVAL; |
| 993 | |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 994 | cmd = (struct i40e_nvm_access *)eeprom; |
| 995 | ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno); |
Shannon Nelson | 29a0645 | 2015-02-27 09:18:33 +0000 | [diff] [blame] | 996 | if (ret_val && |
| 997 | ((hw->aq.asq_last_status != I40E_AQ_RC_EACCES) || |
| 998 | (hw->debug_mask & I40E_DEBUG_NVM))) |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 999 | dev_info(&pf->pdev->dev, |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 1000 | "NVMUpdate read failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n", |
| 1001 | ret_val, hw->aq.asq_last_status, errno, |
| 1002 | (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK), |
| 1003 | cmd->offset, cmd->data_size); |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 1004 | |
| 1005 | return errno; |
| 1006 | } |
| 1007 | |
| 1008 | /* normal ethtool get_eeprom support */ |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1009 | eeprom->magic = hw->vendor_id | (hw->device_id << 16); |
| 1010 | |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1011 | eeprom_buff = kzalloc(eeprom->len, GFP_KERNEL); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1012 | if (!eeprom_buff) |
| 1013 | return -ENOMEM; |
| 1014 | |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1015 | ret_val = i40e_acquire_nvm(hw, I40E_RESOURCE_READ); |
| 1016 | if (ret_val) { |
| 1017 | dev_info(&pf->pdev->dev, |
| 1018 | "Failed Acquiring NVM resource for read err=%d status=0x%x\n", |
| 1019 | ret_val, hw->aq.asq_last_status); |
| 1020 | goto free_buff; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1021 | } |
| 1022 | |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1023 | sectors = eeprom->len / I40E_NVM_SECTOR_SIZE; |
| 1024 | sectors += (eeprom->len % I40E_NVM_SECTOR_SIZE) ? 1 : 0; |
| 1025 | len = I40E_NVM_SECTOR_SIZE; |
| 1026 | last = false; |
| 1027 | for (i = 0; i < sectors; i++) { |
| 1028 | if (i == (sectors - 1)) { |
| 1029 | len = eeprom->len - (I40E_NVM_SECTOR_SIZE * i); |
| 1030 | last = true; |
| 1031 | } |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 1032 | offset = eeprom->offset + (I40E_NVM_SECTOR_SIZE * i), |
| 1033 | ret_val = i40e_aq_read_nvm(hw, 0x0, offset, len, |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 1034 | (u8 *)eeprom_buff + (I40E_NVM_SECTOR_SIZE * i), |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1035 | last, NULL); |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 1036 | if (ret_val && hw->aq.asq_last_status == I40E_AQ_RC_EPERM) { |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1037 | dev_info(&pf->pdev->dev, |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 1038 | "read NVM failed, invalid offset 0x%x\n", |
| 1039 | offset); |
| 1040 | break; |
| 1041 | } else if (ret_val && |
| 1042 | hw->aq.asq_last_status == I40E_AQ_RC_EACCES) { |
| 1043 | dev_info(&pf->pdev->dev, |
| 1044 | "read NVM failed, access, offset 0x%x\n", |
| 1045 | offset); |
| 1046 | break; |
| 1047 | } else if (ret_val) { |
| 1048 | dev_info(&pf->pdev->dev, |
| 1049 | "read NVM failed offset %d err=%d status=0x%x\n", |
| 1050 | offset, ret_val, hw->aq.asq_last_status); |
| 1051 | break; |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1052 | } |
| 1053 | } |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1054 | |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1055 | i40e_release_nvm(hw); |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 1056 | memcpy(bytes, (u8 *)eeprom_buff, eeprom->len); |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1057 | free_buff: |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1058 | kfree(eeprom_buff); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1059 | return ret_val; |
| 1060 | } |
| 1061 | |
| 1062 | static int i40e_get_eeprom_len(struct net_device *netdev) |
| 1063 | { |
| 1064 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1065 | struct i40e_hw *hw = &np->vsi->back->hw; |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1066 | u32 val; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1067 | |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1068 | val = (rd32(hw, I40E_GLPCI_LBARCTRL) |
| 1069 | & I40E_GLPCI_LBARCTRL_FL_SIZE_MASK) |
| 1070 | >> I40E_GLPCI_LBARCTRL_FL_SIZE_SHIFT; |
| 1071 | /* register returns value in power of 2, 64Kbyte chunks. */ |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 1072 | val = (64 * 1024) * BIT(val); |
Anjali Singhai Jain | e5e0a5d | 2013-11-28 06:39:28 +0000 | [diff] [blame] | 1073 | return val; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1074 | } |
| 1075 | |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 1076 | static int i40e_set_eeprom(struct net_device *netdev, |
| 1077 | struct ethtool_eeprom *eeprom, u8 *bytes) |
| 1078 | { |
| 1079 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1080 | struct i40e_hw *hw = &np->vsi->back->hw; |
| 1081 | struct i40e_pf *pf = np->vsi->back; |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 1082 | struct i40e_nvm_access *cmd; |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 1083 | int ret_val = 0; |
| 1084 | int errno; |
| 1085 | u32 magic; |
| 1086 | |
| 1087 | /* normal ethtool set_eeprom is not supported */ |
| 1088 | magic = hw->vendor_id | (hw->device_id << 16); |
| 1089 | if (eeprom->magic == magic) |
| 1090 | return -EOPNOTSUPP; |
| 1091 | |
| 1092 | /* check for NVMUpdate access method */ |
| 1093 | if (!eeprom->magic || (eeprom->magic >> 16) != hw->device_id) |
| 1094 | return -EINVAL; |
| 1095 | |
| 1096 | if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) || |
| 1097 | test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state)) |
| 1098 | return -EBUSY; |
| 1099 | |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 1100 | cmd = (struct i40e_nvm_access *)eeprom; |
| 1101 | ret_val = i40e_nvmupd_command(hw, cmd, bytes, &errno); |
Shannon Nelson | 29a0645 | 2015-02-27 09:18:33 +0000 | [diff] [blame] | 1102 | if (ret_val && |
| 1103 | ((hw->aq.asq_last_status != I40E_AQ_RC_EPERM && |
| 1104 | hw->aq.asq_last_status != I40E_AQ_RC_EBUSY) || |
| 1105 | (hw->debug_mask & I40E_DEBUG_NVM))) |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 1106 | dev_info(&pf->pdev->dev, |
Shannon Nelson | c150a50 | 2014-11-13 08:23:13 +0000 | [diff] [blame] | 1107 | "NVMUpdate write failed err=%d status=0x%x errno=%d module=%d offset=0x%x size=%d\n", |
| 1108 | ret_val, hw->aq.asq_last_status, errno, |
| 1109 | (u8)(cmd->config & I40E_NVM_MOD_PNT_MASK), |
| 1110 | cmd->offset, cmd->data_size); |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 1111 | |
| 1112 | return errno; |
| 1113 | } |
| 1114 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1115 | static void i40e_get_drvinfo(struct net_device *netdev, |
| 1116 | struct ethtool_drvinfo *drvinfo) |
| 1117 | { |
| 1118 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1119 | struct i40e_vsi *vsi = np->vsi; |
| 1120 | struct i40e_pf *pf = vsi->back; |
| 1121 | |
| 1122 | strlcpy(drvinfo->driver, i40e_driver_name, sizeof(drvinfo->driver)); |
| 1123 | strlcpy(drvinfo->version, i40e_driver_version_str, |
| 1124 | sizeof(drvinfo->version)); |
Shannon Nelson | 6dec101 | 2015-09-28 14:12:30 -0400 | [diff] [blame] | 1125 | strlcpy(drvinfo->fw_version, i40e_nvm_version_str(&pf->hw), |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1126 | sizeof(drvinfo->fw_version)); |
| 1127 | strlcpy(drvinfo->bus_info, pci_name(pf->pdev), |
| 1128 | sizeof(drvinfo->bus_info)); |
| 1129 | } |
| 1130 | |
| 1131 | static void i40e_get_ringparam(struct net_device *netdev, |
| 1132 | struct ethtool_ringparam *ring) |
| 1133 | { |
| 1134 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1135 | struct i40e_pf *pf = np->vsi->back; |
| 1136 | struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; |
| 1137 | |
| 1138 | ring->rx_max_pending = I40E_MAX_NUM_DESCRIPTORS; |
| 1139 | ring->tx_max_pending = I40E_MAX_NUM_DESCRIPTORS; |
| 1140 | ring->rx_mini_max_pending = 0; |
| 1141 | ring->rx_jumbo_max_pending = 0; |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1142 | ring->rx_pending = vsi->rx_rings[0]->count; |
| 1143 | ring->tx_pending = vsi->tx_rings[0]->count; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1144 | ring->rx_mini_pending = 0; |
| 1145 | ring->rx_jumbo_pending = 0; |
| 1146 | } |
| 1147 | |
| 1148 | static int i40e_set_ringparam(struct net_device *netdev, |
| 1149 | struct ethtool_ringparam *ring) |
| 1150 | { |
| 1151 | struct i40e_ring *tx_rings = NULL, *rx_rings = NULL; |
| 1152 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1153 | struct i40e_vsi *vsi = np->vsi; |
| 1154 | struct i40e_pf *pf = vsi->back; |
| 1155 | u32 new_rx_count, new_tx_count; |
| 1156 | int i, err = 0; |
| 1157 | |
| 1158 | if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) |
| 1159 | return -EINVAL; |
| 1160 | |
Shannon Nelson | 1fa1837 | 2013-11-20 10:03:08 +0000 | [diff] [blame] | 1161 | if (ring->tx_pending > I40E_MAX_NUM_DESCRIPTORS || |
| 1162 | ring->tx_pending < I40E_MIN_NUM_DESCRIPTORS || |
| 1163 | ring->rx_pending > I40E_MAX_NUM_DESCRIPTORS || |
| 1164 | ring->rx_pending < I40E_MIN_NUM_DESCRIPTORS) { |
| 1165 | netdev_info(netdev, |
| 1166 | "Descriptors requested (Tx: %d / Rx: %d) out of range [%d-%d]\n", |
| 1167 | ring->tx_pending, ring->rx_pending, |
| 1168 | I40E_MIN_NUM_DESCRIPTORS, I40E_MAX_NUM_DESCRIPTORS); |
| 1169 | return -EINVAL; |
| 1170 | } |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1171 | |
Shannon Nelson | 1fa1837 | 2013-11-20 10:03:08 +0000 | [diff] [blame] | 1172 | new_tx_count = ALIGN(ring->tx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); |
| 1173 | new_rx_count = ALIGN(ring->rx_pending, I40E_REQ_DESCRIPTOR_MULTIPLE); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1174 | |
| 1175 | /* if nothing to do return success */ |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1176 | if ((new_tx_count == vsi->tx_rings[0]->count) && |
| 1177 | (new_rx_count == vsi->rx_rings[0]->count)) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1178 | return 0; |
| 1179 | |
| 1180 | while (test_and_set_bit(__I40E_CONFIG_BUSY, &pf->state)) |
| 1181 | usleep_range(1000, 2000); |
| 1182 | |
| 1183 | if (!netif_running(vsi->netdev)) { |
| 1184 | /* simple case - set for the next time the netdev is started */ |
| 1185 | for (i = 0; i < vsi->num_queue_pairs; i++) { |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1186 | vsi->tx_rings[i]->count = new_tx_count; |
| 1187 | vsi->rx_rings[i]->count = new_rx_count; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1188 | } |
| 1189 | goto done; |
| 1190 | } |
| 1191 | |
| 1192 | /* We can't just free everything and then setup again, |
| 1193 | * because the ISRs in MSI-X mode get passed pointers |
| 1194 | * to the Tx and Rx ring structs. |
| 1195 | */ |
| 1196 | |
| 1197 | /* alloc updated Tx resources */ |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1198 | if (new_tx_count != vsi->tx_rings[0]->count) { |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1199 | netdev_info(netdev, |
| 1200 | "Changing Tx descriptor count from %d to %d.\n", |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1201 | vsi->tx_rings[0]->count, new_tx_count); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1202 | tx_rings = kcalloc(vsi->alloc_queue_pairs, |
| 1203 | sizeof(struct i40e_ring), GFP_KERNEL); |
| 1204 | if (!tx_rings) { |
| 1205 | err = -ENOMEM; |
| 1206 | goto done; |
| 1207 | } |
| 1208 | |
| 1209 | for (i = 0; i < vsi->num_queue_pairs; i++) { |
| 1210 | /* clone ring and setup updated count */ |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1211 | tx_rings[i] = *vsi->tx_rings[i]; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1212 | tx_rings[i].count = new_tx_count; |
Jesse Brandeburg | 1e8efb4 | 2015-08-27 11:42:33 -0400 | [diff] [blame] | 1213 | /* the desc and bi pointers will be reallocated in the |
| 1214 | * setup call |
| 1215 | */ |
| 1216 | tx_rings[i].desc = NULL; |
| 1217 | tx_rings[i].rx_bi = NULL; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1218 | err = i40e_setup_tx_descriptors(&tx_rings[i]); |
| 1219 | if (err) { |
| 1220 | while (i) { |
| 1221 | i--; |
| 1222 | i40e_free_tx_resources(&tx_rings[i]); |
| 1223 | } |
| 1224 | kfree(tx_rings); |
| 1225 | tx_rings = NULL; |
| 1226 | |
| 1227 | goto done; |
| 1228 | } |
| 1229 | } |
| 1230 | } |
| 1231 | |
| 1232 | /* alloc updated Rx resources */ |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1233 | if (new_rx_count != vsi->rx_rings[0]->count) { |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1234 | netdev_info(netdev, |
| 1235 | "Changing Rx descriptor count from %d to %d\n", |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1236 | vsi->rx_rings[0]->count, new_rx_count); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1237 | rx_rings = kcalloc(vsi->alloc_queue_pairs, |
| 1238 | sizeof(struct i40e_ring), GFP_KERNEL); |
| 1239 | if (!rx_rings) { |
| 1240 | err = -ENOMEM; |
| 1241 | goto free_tx; |
| 1242 | } |
| 1243 | |
| 1244 | for (i = 0; i < vsi->num_queue_pairs; i++) { |
| 1245 | /* clone ring and setup updated count */ |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1246 | rx_rings[i] = *vsi->rx_rings[i]; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1247 | rx_rings[i].count = new_rx_count; |
Jesse Brandeburg | 1e8efb4 | 2015-08-27 11:42:33 -0400 | [diff] [blame] | 1248 | /* the desc and bi pointers will be reallocated in the |
| 1249 | * setup call |
| 1250 | */ |
| 1251 | rx_rings[i].desc = NULL; |
| 1252 | rx_rings[i].rx_bi = NULL; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1253 | err = i40e_setup_rx_descriptors(&rx_rings[i]); |
| 1254 | if (err) { |
| 1255 | while (i) { |
| 1256 | i--; |
| 1257 | i40e_free_rx_resources(&rx_rings[i]); |
| 1258 | } |
| 1259 | kfree(rx_rings); |
| 1260 | rx_rings = NULL; |
| 1261 | |
| 1262 | goto free_tx; |
| 1263 | } |
| 1264 | } |
| 1265 | } |
| 1266 | |
| 1267 | /* Bring interface down, copy in the new ring info, |
| 1268 | * then restore the interface |
| 1269 | */ |
| 1270 | i40e_down(vsi); |
| 1271 | |
| 1272 | if (tx_rings) { |
| 1273 | for (i = 0; i < vsi->num_queue_pairs; i++) { |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1274 | i40e_free_tx_resources(vsi->tx_rings[i]); |
| 1275 | *vsi->tx_rings[i] = tx_rings[i]; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1276 | } |
| 1277 | kfree(tx_rings); |
| 1278 | tx_rings = NULL; |
| 1279 | } |
| 1280 | |
| 1281 | if (rx_rings) { |
| 1282 | for (i = 0; i < vsi->num_queue_pairs; i++) { |
Alexander Duyck | 9f65e15 | 2013-09-28 06:00:58 +0000 | [diff] [blame] | 1283 | i40e_free_rx_resources(vsi->rx_rings[i]); |
| 1284 | *vsi->rx_rings[i] = rx_rings[i]; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1285 | } |
| 1286 | kfree(rx_rings); |
| 1287 | rx_rings = NULL; |
| 1288 | } |
| 1289 | |
| 1290 | i40e_up(vsi); |
| 1291 | |
| 1292 | free_tx: |
| 1293 | /* error cleanup if the Rx allocations failed after getting Tx */ |
| 1294 | if (tx_rings) { |
| 1295 | for (i = 0; i < vsi->num_queue_pairs; i++) |
| 1296 | i40e_free_tx_resources(&tx_rings[i]); |
| 1297 | kfree(tx_rings); |
| 1298 | tx_rings = NULL; |
| 1299 | } |
| 1300 | |
| 1301 | done: |
| 1302 | clear_bit(__I40E_CONFIG_BUSY, &pf->state); |
| 1303 | |
| 1304 | return err; |
| 1305 | } |
| 1306 | |
| 1307 | static int i40e_get_sset_count(struct net_device *netdev, int sset) |
| 1308 | { |
| 1309 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1310 | struct i40e_vsi *vsi = np->vsi; |
| 1311 | struct i40e_pf *pf = vsi->back; |
| 1312 | |
| 1313 | switch (sset) { |
| 1314 | case ETH_SS_TEST: |
| 1315 | return I40E_TEST_LEN; |
| 1316 | case ETH_SS_STATS: |
Shannon Nelson | 58ce517 | 2015-02-27 09:15:26 +0000 | [diff] [blame] | 1317 | if (vsi == pf->vsi[pf->lan_vsi] && pf->hw.partition_id == 1) { |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1318 | int len = I40E_PF_STATS_LEN(netdev); |
| 1319 | |
Anjali Singhai Jain | d1a8d27 | 2015-07-23 16:54:40 -0400 | [diff] [blame] | 1320 | if ((pf->lan_veb != I40E_NO_VEB) && |
| 1321 | (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) |
Neerav Parikh | fe860af | 2015-07-10 19:36:02 -0400 | [diff] [blame] | 1322 | len += I40E_VEB_STATS_TOTAL; |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1323 | return len; |
| 1324 | } else { |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1325 | return I40E_VSI_STATS_LEN(netdev); |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1326 | } |
Greg Rose | 7e45ab4 | 2015-02-06 08:52:19 +0000 | [diff] [blame] | 1327 | case ETH_SS_PRIV_FLAGS: |
| 1328 | return I40E_PRIV_FLAGS_STR_LEN; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1329 | default: |
| 1330 | return -EOPNOTSUPP; |
| 1331 | } |
| 1332 | } |
| 1333 | |
| 1334 | static void i40e_get_ethtool_stats(struct net_device *netdev, |
| 1335 | struct ethtool_stats *stats, u64 *data) |
| 1336 | { |
| 1337 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
Akeem G Abodunrin | e7046ee | 2014-04-09 05:58:58 +0000 | [diff] [blame] | 1338 | struct i40e_ring *tx_ring, *rx_ring; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1339 | struct i40e_vsi *vsi = np->vsi; |
| 1340 | struct i40e_pf *pf = vsi->back; |
| 1341 | int i = 0; |
| 1342 | char *p; |
| 1343 | int j; |
| 1344 | struct rtnl_link_stats64 *net_stats = i40e_get_vsi_stats_struct(vsi); |
Alexander Duyck | 980e9b1 | 2013-09-28 06:01:03 +0000 | [diff] [blame] | 1345 | unsigned int start; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1346 | |
| 1347 | i40e_update_stats(vsi); |
| 1348 | |
| 1349 | for (j = 0; j < I40E_NETDEV_STATS_LEN; j++) { |
| 1350 | p = (char *)net_stats + i40e_gstrings_net_stats[j].stat_offset; |
| 1351 | data[i++] = (i40e_gstrings_net_stats[j].sizeof_stat == |
| 1352 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
| 1353 | } |
Shannon Nelson | 41a9e55 | 2014-04-23 04:50:20 +0000 | [diff] [blame] | 1354 | for (j = 0; j < I40E_MISC_STATS_LEN; j++) { |
| 1355 | p = (char *)vsi + i40e_gstrings_misc_stats[j].stat_offset; |
| 1356 | data[i++] = (i40e_gstrings_misc_stats[j].sizeof_stat == |
| 1357 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
| 1358 | } |
Vasu Dev | 38e0043 | 2014-08-01 13:27:03 -0700 | [diff] [blame] | 1359 | #ifdef I40E_FCOE |
| 1360 | for (j = 0; j < I40E_FCOE_STATS_LEN; j++) { |
| 1361 | p = (char *)vsi + i40e_gstrings_fcoe_stats[j].stat_offset; |
| 1362 | data[i++] = (i40e_gstrings_fcoe_stats[j].sizeof_stat == |
| 1363 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
| 1364 | } |
| 1365 | #endif |
Alexander Duyck | 980e9b1 | 2013-09-28 06:01:03 +0000 | [diff] [blame] | 1366 | rcu_read_lock(); |
Catherine Sullivan | 99c472a | 2014-03-14 07:32:30 +0000 | [diff] [blame] | 1367 | for (j = 0; j < vsi->num_queue_pairs; j++) { |
Akeem G Abodunrin | e7046ee | 2014-04-09 05:58:58 +0000 | [diff] [blame] | 1368 | tx_ring = ACCESS_ONCE(vsi->tx_rings[j]); |
Alexander Duyck | 980e9b1 | 2013-09-28 06:01:03 +0000 | [diff] [blame] | 1369 | |
| 1370 | if (!tx_ring) |
| 1371 | continue; |
| 1372 | |
| 1373 | /* process Tx ring statistics */ |
| 1374 | do { |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 1375 | start = u64_stats_fetch_begin_irq(&tx_ring->syncp); |
Alexander Duyck | 980e9b1 | 2013-09-28 06:01:03 +0000 | [diff] [blame] | 1376 | data[i] = tx_ring->stats.packets; |
| 1377 | data[i + 1] = tx_ring->stats.bytes; |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 1378 | } while (u64_stats_fetch_retry_irq(&tx_ring->syncp, start)); |
Catherine Sullivan | 99c472a | 2014-03-14 07:32:30 +0000 | [diff] [blame] | 1379 | i += 2; |
Alexander Duyck | 980e9b1 | 2013-09-28 06:01:03 +0000 | [diff] [blame] | 1380 | |
| 1381 | /* Rx ring is the 2nd half of the queue pair */ |
| 1382 | rx_ring = &tx_ring[1]; |
| 1383 | do { |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 1384 | start = u64_stats_fetch_begin_irq(&rx_ring->syncp); |
Catherine Sullivan | 99c472a | 2014-03-14 07:32:30 +0000 | [diff] [blame] | 1385 | data[i] = rx_ring->stats.packets; |
| 1386 | data[i + 1] = rx_ring->stats.bytes; |
Eric W. Biederman | 57a7744 | 2014-03-13 21:26:42 -0700 | [diff] [blame] | 1387 | } while (u64_stats_fetch_retry_irq(&rx_ring->syncp, start)); |
Catherine Sullivan | 99c472a | 2014-03-14 07:32:30 +0000 | [diff] [blame] | 1388 | i += 2; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1389 | } |
Alexander Duyck | 980e9b1 | 2013-09-28 06:01:03 +0000 | [diff] [blame] | 1390 | rcu_read_unlock(); |
Shannon Nelson | 58ce517 | 2015-02-27 09:15:26 +0000 | [diff] [blame] | 1391 | if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1) |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1392 | return; |
| 1393 | |
Anjali Singhai Jain | d1a8d27 | 2015-07-23 16:54:40 -0400 | [diff] [blame] | 1394 | if ((pf->lan_veb != I40E_NO_VEB) && |
| 1395 | (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) { |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1396 | struct i40e_veb *veb = pf->veb[pf->lan_veb]; |
Jesse Brandeburg | 6995b36 | 2015-08-28 17:55:54 -0400 | [diff] [blame] | 1397 | |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1398 | for (j = 0; j < I40E_VEB_STATS_LEN; j++) { |
| 1399 | p = (char *)veb; |
| 1400 | p += i40e_gstrings_veb_stats[j].stat_offset; |
| 1401 | data[i++] = (i40e_gstrings_veb_stats[j].sizeof_stat == |
| 1402 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1403 | } |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1404 | } |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1405 | for (j = 0; j < I40E_GLOBAL_STATS_LEN; j++) { |
| 1406 | p = (char *)pf + i40e_gstrings_stats[j].stat_offset; |
| 1407 | data[i++] = (i40e_gstrings_stats[j].sizeof_stat == |
| 1408 | sizeof(u64)) ? *(u64 *)p : *(u32 *)p; |
| 1409 | } |
| 1410 | for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) { |
| 1411 | data[i++] = pf->stats.priority_xon_tx[j]; |
| 1412 | data[i++] = pf->stats.priority_xoff_tx[j]; |
| 1413 | } |
| 1414 | for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) { |
| 1415 | data[i++] = pf->stats.priority_xon_rx[j]; |
| 1416 | data[i++] = pf->stats.priority_xoff_rx[j]; |
| 1417 | } |
| 1418 | for (j = 0; j < I40E_MAX_USER_PRIORITY; j++) |
| 1419 | data[i++] = pf->stats.priority_xon_2_xoff[j]; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1420 | } |
| 1421 | |
| 1422 | static void i40e_get_strings(struct net_device *netdev, u32 stringset, |
| 1423 | u8 *data) |
| 1424 | { |
| 1425 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1426 | struct i40e_vsi *vsi = np->vsi; |
| 1427 | struct i40e_pf *pf = vsi->back; |
| 1428 | char *p = (char *)data; |
| 1429 | int i; |
| 1430 | |
| 1431 | switch (stringset) { |
| 1432 | case ETH_SS_TEST: |
| 1433 | for (i = 0; i < I40E_TEST_LEN; i++) { |
| 1434 | memcpy(data, i40e_gstrings_test[i], ETH_GSTRING_LEN); |
| 1435 | data += ETH_GSTRING_LEN; |
| 1436 | } |
| 1437 | break; |
| 1438 | case ETH_SS_STATS: |
| 1439 | for (i = 0; i < I40E_NETDEV_STATS_LEN; i++) { |
| 1440 | snprintf(p, ETH_GSTRING_LEN, "%s", |
| 1441 | i40e_gstrings_net_stats[i].stat_string); |
| 1442 | p += ETH_GSTRING_LEN; |
| 1443 | } |
Shannon Nelson | 41a9e55 | 2014-04-23 04:50:20 +0000 | [diff] [blame] | 1444 | for (i = 0; i < I40E_MISC_STATS_LEN; i++) { |
| 1445 | snprintf(p, ETH_GSTRING_LEN, "%s", |
| 1446 | i40e_gstrings_misc_stats[i].stat_string); |
| 1447 | p += ETH_GSTRING_LEN; |
| 1448 | } |
Vasu Dev | 38e0043 | 2014-08-01 13:27:03 -0700 | [diff] [blame] | 1449 | #ifdef I40E_FCOE |
| 1450 | for (i = 0; i < I40E_FCOE_STATS_LEN; i++) { |
| 1451 | snprintf(p, ETH_GSTRING_LEN, "%s", |
| 1452 | i40e_gstrings_fcoe_stats[i].stat_string); |
| 1453 | p += ETH_GSTRING_LEN; |
| 1454 | } |
| 1455 | #endif |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1456 | for (i = 0; i < vsi->num_queue_pairs; i++) { |
| 1457 | snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_packets", i); |
| 1458 | p += ETH_GSTRING_LEN; |
| 1459 | snprintf(p, ETH_GSTRING_LEN, "tx-%u.tx_bytes", i); |
| 1460 | p += ETH_GSTRING_LEN; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1461 | snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_packets", i); |
| 1462 | p += ETH_GSTRING_LEN; |
| 1463 | snprintf(p, ETH_GSTRING_LEN, "rx-%u.rx_bytes", i); |
| 1464 | p += ETH_GSTRING_LEN; |
| 1465 | } |
Shannon Nelson | 58ce517 | 2015-02-27 09:15:26 +0000 | [diff] [blame] | 1466 | if (vsi != pf->vsi[pf->lan_vsi] || pf->hw.partition_id != 1) |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1467 | return; |
| 1468 | |
Anjali Singhai Jain | d1a8d27 | 2015-07-23 16:54:40 -0400 | [diff] [blame] | 1469 | if ((pf->lan_veb != I40E_NO_VEB) && |
| 1470 | (pf->flags & I40E_FLAG_VEB_STATS_ENABLED)) { |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1471 | for (i = 0; i < I40E_VEB_STATS_LEN; i++) { |
| 1472 | snprintf(p, ETH_GSTRING_LEN, "veb.%s", |
| 1473 | i40e_gstrings_veb_stats[i].stat_string); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1474 | p += ETH_GSTRING_LEN; |
| 1475 | } |
Neerav Parikh | fe860af | 2015-07-10 19:36:02 -0400 | [diff] [blame] | 1476 | for (i = 0; i < I40E_MAX_TRAFFIC_CLASS; i++) { |
| 1477 | snprintf(p, ETH_GSTRING_LEN, |
| 1478 | "veb.tc_%u_tx_packets", i); |
| 1479 | p += ETH_GSTRING_LEN; |
| 1480 | snprintf(p, ETH_GSTRING_LEN, |
| 1481 | "veb.tc_%u_tx_bytes", i); |
| 1482 | p += ETH_GSTRING_LEN; |
| 1483 | snprintf(p, ETH_GSTRING_LEN, |
| 1484 | "veb.tc_%u_rx_packets", i); |
| 1485 | p += ETH_GSTRING_LEN; |
| 1486 | snprintf(p, ETH_GSTRING_LEN, |
| 1487 | "veb.tc_%u_rx_bytes", i); |
| 1488 | p += ETH_GSTRING_LEN; |
| 1489 | } |
Shannon Nelson | 8eab9cf | 2014-04-23 04:49:55 +0000 | [diff] [blame] | 1490 | } |
| 1491 | for (i = 0; i < I40E_GLOBAL_STATS_LEN; i++) { |
| 1492 | snprintf(p, ETH_GSTRING_LEN, "port.%s", |
| 1493 | i40e_gstrings_stats[i].stat_string); |
| 1494 | p += ETH_GSTRING_LEN; |
| 1495 | } |
| 1496 | for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) { |
| 1497 | snprintf(p, ETH_GSTRING_LEN, |
| 1498 | "port.tx_priority_%u_xon", i); |
| 1499 | p += ETH_GSTRING_LEN; |
| 1500 | snprintf(p, ETH_GSTRING_LEN, |
| 1501 | "port.tx_priority_%u_xoff", i); |
| 1502 | p += ETH_GSTRING_LEN; |
| 1503 | } |
| 1504 | for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) { |
| 1505 | snprintf(p, ETH_GSTRING_LEN, |
| 1506 | "port.rx_priority_%u_xon", i); |
| 1507 | p += ETH_GSTRING_LEN; |
| 1508 | snprintf(p, ETH_GSTRING_LEN, |
| 1509 | "port.rx_priority_%u_xoff", i); |
| 1510 | p += ETH_GSTRING_LEN; |
| 1511 | } |
| 1512 | for (i = 0; i < I40E_MAX_USER_PRIORITY; i++) { |
| 1513 | snprintf(p, ETH_GSTRING_LEN, |
| 1514 | "port.rx_priority_%u_xon_2_xoff", i); |
| 1515 | p += ETH_GSTRING_LEN; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1516 | } |
| 1517 | /* BUG_ON(p - data != I40E_STATS_LEN * ETH_GSTRING_LEN); */ |
| 1518 | break; |
Greg Rose | 7e45ab4 | 2015-02-06 08:52:19 +0000 | [diff] [blame] | 1519 | case ETH_SS_PRIV_FLAGS: |
| 1520 | for (i = 0; i < I40E_PRIV_FLAGS_STR_LEN; i++) { |
| 1521 | memcpy(data, i40e_priv_flags_strings[i], |
| 1522 | ETH_GSTRING_LEN); |
| 1523 | data += ETH_GSTRING_LEN; |
| 1524 | } |
| 1525 | break; |
Akeem G Abodunrin | 579b23d | 2015-02-24 06:58:42 +0000 | [diff] [blame] | 1526 | default: |
| 1527 | break; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1528 | } |
| 1529 | } |
| 1530 | |
| 1531 | static int i40e_get_ts_info(struct net_device *dev, |
| 1532 | struct ethtool_ts_info *info) |
| 1533 | { |
Jacob Keller | beb0dff | 2014-01-11 05:43:19 +0000 | [diff] [blame] | 1534 | struct i40e_pf *pf = i40e_netdev_to_pf(dev); |
| 1535 | |
Jacob Keller | fe88bda | 2014-11-11 20:05:58 +0000 | [diff] [blame] | 1536 | /* only report HW timestamping if PTP is enabled */ |
| 1537 | if (!(pf->flags & I40E_FLAG_PTP)) |
| 1538 | return ethtool_op_get_ts_info(dev, info); |
| 1539 | |
Jacob Keller | beb0dff | 2014-01-11 05:43:19 +0000 | [diff] [blame] | 1540 | info->so_timestamping = SOF_TIMESTAMPING_TX_SOFTWARE | |
| 1541 | SOF_TIMESTAMPING_RX_SOFTWARE | |
| 1542 | SOF_TIMESTAMPING_SOFTWARE | |
| 1543 | SOF_TIMESTAMPING_TX_HARDWARE | |
| 1544 | SOF_TIMESTAMPING_RX_HARDWARE | |
| 1545 | SOF_TIMESTAMPING_RAW_HARDWARE; |
| 1546 | |
| 1547 | if (pf->ptp_clock) |
| 1548 | info->phc_index = ptp_clock_index(pf->ptp_clock); |
| 1549 | else |
| 1550 | info->phc_index = -1; |
| 1551 | |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 1552 | info->tx_types = BIT(HWTSTAMP_TX_OFF) | BIT(HWTSTAMP_TX_ON); |
Jacob Keller | beb0dff | 2014-01-11 05:43:19 +0000 | [diff] [blame] | 1553 | |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 1554 | info->rx_filters = BIT(HWTSTAMP_FILTER_NONE) | |
| 1555 | BIT(HWTSTAMP_FILTER_PTP_V1_L4_EVENT) | |
| 1556 | BIT(HWTSTAMP_FILTER_PTP_V2_EVENT); |
Jacob Keller | beb0dff | 2014-01-11 05:43:19 +0000 | [diff] [blame] | 1557 | |
| 1558 | return 0; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1559 | } |
| 1560 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1561 | static int i40e_link_test(struct net_device *netdev, u64 *data) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1562 | { |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1563 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1564 | struct i40e_pf *pf = np->vsi->back; |
Jesse Brandeburg | a72a5abc | 2015-08-26 15:14:19 -0400 | [diff] [blame] | 1565 | i40e_status status; |
| 1566 | bool link_up = false; |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1567 | |
Shannon Nelson | b03aaa9 | 2013-11-20 10:03:06 +0000 | [diff] [blame] | 1568 | netif_info(pf, hw, netdev, "link test\n"); |
Jesse Brandeburg | a72a5abc | 2015-08-26 15:14:19 -0400 | [diff] [blame] | 1569 | status = i40e_get_link_status(&pf->hw, &link_up); |
| 1570 | if (status) { |
| 1571 | netif_err(pf, drv, netdev, "link query timed out, please retry test\n"); |
| 1572 | *data = 1; |
| 1573 | return *data; |
| 1574 | } |
| 1575 | |
| 1576 | if (link_up) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1577 | *data = 0; |
| 1578 | else |
| 1579 | *data = 1; |
| 1580 | |
| 1581 | return *data; |
| 1582 | } |
| 1583 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1584 | static int i40e_reg_test(struct net_device *netdev, u64 *data) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1585 | { |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1586 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1587 | struct i40e_pf *pf = np->vsi->back; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1588 | |
Shannon Nelson | b03aaa9 | 2013-11-20 10:03:06 +0000 | [diff] [blame] | 1589 | netif_info(pf, hw, netdev, "register test\n"); |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1590 | *data = i40e_diag_reg_test(&pf->hw); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1591 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1592 | return *data; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1593 | } |
| 1594 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1595 | static int i40e_eeprom_test(struct net_device *netdev, u64 *data) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1596 | { |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1597 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1598 | struct i40e_pf *pf = np->vsi->back; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1599 | |
Shannon Nelson | b03aaa9 | 2013-11-20 10:03:06 +0000 | [diff] [blame] | 1600 | netif_info(pf, hw, netdev, "eeprom test\n"); |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1601 | *data = i40e_diag_eeprom_test(&pf->hw); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1602 | |
Shannon Nelson | 4443ec9 | 2014-11-13 08:23:12 +0000 | [diff] [blame] | 1603 | /* forcebly clear the NVM Update state machine */ |
| 1604 | pf->hw.nvmupd_state = I40E_NVMUPD_STATE_INIT; |
| 1605 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1606 | return *data; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1607 | } |
| 1608 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1609 | static int i40e_intr_test(struct net_device *netdev, u64 *data) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1610 | { |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1611 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1612 | struct i40e_pf *pf = np->vsi->back; |
Shannon Nelson | cd92e72 | 2013-11-16 10:00:44 +0000 | [diff] [blame] | 1613 | u16 swc_old = pf->sw_int_count; |
| 1614 | |
Shannon Nelson | b03aaa9 | 2013-11-20 10:03:06 +0000 | [diff] [blame] | 1615 | netif_info(pf, hw, netdev, "interrupt test\n"); |
Shannon Nelson | cd92e72 | 2013-11-16 10:00:44 +0000 | [diff] [blame] | 1616 | wr32(&pf->hw, I40E_PFINT_DYN_CTL0, |
| 1617 | (I40E_PFINT_DYN_CTL0_INTENA_MASK | |
Shannon Nelson | 5d1ff106 | 2014-11-11 20:04:35 +0000 | [diff] [blame] | 1618 | I40E_PFINT_DYN_CTL0_SWINT_TRIG_MASK | |
| 1619 | I40E_PFINT_DYN_CTL0_ITR_INDX_MASK | |
| 1620 | I40E_PFINT_DYN_CTL0_SW_ITR_INDX_ENA_MASK | |
| 1621 | I40E_PFINT_DYN_CTL0_SW_ITR_INDX_MASK)); |
Shannon Nelson | cd92e72 | 2013-11-16 10:00:44 +0000 | [diff] [blame] | 1622 | usleep_range(1000, 2000); |
| 1623 | *data = (swc_old == pf->sw_int_count); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1624 | |
| 1625 | return *data; |
| 1626 | } |
| 1627 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1628 | static int i40e_loopback_test(struct net_device *netdev, u64 *data) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1629 | { |
Shannon Nelson | b03aaa9 | 2013-11-20 10:03:06 +0000 | [diff] [blame] | 1630 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1631 | struct i40e_pf *pf = np->vsi->back; |
| 1632 | |
| 1633 | netif_info(pf, hw, netdev, "loopback test not implemented\n"); |
Shannon Nelson | cd92e72 | 2013-11-16 10:00:44 +0000 | [diff] [blame] | 1634 | *data = 0; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1635 | |
| 1636 | return *data; |
| 1637 | } |
| 1638 | |
Greg Rose | e17bc41 | 2015-04-16 20:05:59 -0400 | [diff] [blame] | 1639 | static inline bool i40e_active_vfs(struct i40e_pf *pf) |
| 1640 | { |
| 1641 | struct i40e_vf *vfs = pf->vf; |
| 1642 | int i; |
| 1643 | |
| 1644 | for (i = 0; i < pf->num_alloc_vfs; i++) |
Jesse Brandeburg | 6995b36 | 2015-08-28 17:55:54 -0400 | [diff] [blame] | 1645 | if (test_bit(I40E_VF_STAT_ACTIVE, &vfs[i].vf_states)) |
Greg Rose | e17bc41 | 2015-04-16 20:05:59 -0400 | [diff] [blame] | 1646 | return true; |
| 1647 | return false; |
| 1648 | } |
| 1649 | |
Greg Rose | 510efb2 | 2015-07-10 19:36:01 -0400 | [diff] [blame] | 1650 | static inline bool i40e_active_vmdqs(struct i40e_pf *pf) |
| 1651 | { |
| 1652 | struct i40e_vsi **vsi = pf->vsi; |
| 1653 | int i; |
| 1654 | |
| 1655 | for (i = 0; i < pf->num_alloc_vsi; i++) { |
| 1656 | if (!vsi[i]) |
| 1657 | continue; |
| 1658 | if (vsi[i]->type == I40E_VSI_VMDQ2) |
| 1659 | return true; |
| 1660 | } |
| 1661 | |
| 1662 | return false; |
| 1663 | } |
| 1664 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1665 | static void i40e_diag_test(struct net_device *netdev, |
| 1666 | struct ethtool_test *eth_test, u64 *data) |
| 1667 | { |
| 1668 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
Greg Rose | 5b86c5c | 2015-02-26 16:14:35 +0000 | [diff] [blame] | 1669 | bool if_running = netif_running(netdev); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1670 | struct i40e_pf *pf = np->vsi->back; |
| 1671 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1672 | if (eth_test->flags == ETH_TEST_FL_OFFLINE) { |
| 1673 | /* Offline tests */ |
Shannon Nelson | b03aaa9 | 2013-11-20 10:03:06 +0000 | [diff] [blame] | 1674 | netif_info(pf, drv, netdev, "offline testing starting\n"); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1675 | |
Shannon Nelson | f551b43 | 2013-11-26 10:49:12 +0000 | [diff] [blame] | 1676 | set_bit(__I40E_TESTING, &pf->state); |
Greg Rose | e17bc41 | 2015-04-16 20:05:59 -0400 | [diff] [blame] | 1677 | |
Greg Rose | 510efb2 | 2015-07-10 19:36:01 -0400 | [diff] [blame] | 1678 | if (i40e_active_vfs(pf) || i40e_active_vmdqs(pf)) { |
Greg Rose | e17bc41 | 2015-04-16 20:05:59 -0400 | [diff] [blame] | 1679 | dev_warn(&pf->pdev->dev, |
Greg Rose | 510efb2 | 2015-07-10 19:36:01 -0400 | [diff] [blame] | 1680 | "Please take active VFs and Netqueues offline and restart the adapter before running NIC diagnostics\n"); |
Greg Rose | e17bc41 | 2015-04-16 20:05:59 -0400 | [diff] [blame] | 1681 | data[I40E_ETH_TEST_REG] = 1; |
| 1682 | data[I40E_ETH_TEST_EEPROM] = 1; |
| 1683 | data[I40E_ETH_TEST_INTR] = 1; |
| 1684 | data[I40E_ETH_TEST_LOOPBACK] = 1; |
| 1685 | data[I40E_ETH_TEST_LINK] = 1; |
| 1686 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1687 | clear_bit(__I40E_TESTING, &pf->state); |
| 1688 | goto skip_ol_tests; |
| 1689 | } |
| 1690 | |
Greg Rose | 5b86c5c | 2015-02-26 16:14:35 +0000 | [diff] [blame] | 1691 | /* If the device is online then take it offline */ |
| 1692 | if (if_running) |
| 1693 | /* indicate we're in test mode */ |
| 1694 | dev_close(netdev); |
| 1695 | else |
Greg Rose | b4e53f0 | 2015-07-10 19:36:03 -0400 | [diff] [blame] | 1696 | /* This reset does not affect link - if it is |
| 1697 | * changed to a type of reset that does affect |
| 1698 | * link then the following link test would have |
| 1699 | * to be moved to before the reset |
| 1700 | */ |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 1701 | i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED)); |
Shannon Nelson | f551b43 | 2013-11-26 10:49:12 +0000 | [diff] [blame] | 1702 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1703 | if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK])) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1704 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1705 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1706 | if (i40e_eeprom_test(netdev, &data[I40E_ETH_TEST_EEPROM])) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1707 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1708 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1709 | if (i40e_intr_test(netdev, &data[I40E_ETH_TEST_INTR])) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1710 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1711 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1712 | if (i40e_loopback_test(netdev, &data[I40E_ETH_TEST_LOOPBACK])) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1713 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1714 | |
Shannon Nelson | f551b43 | 2013-11-26 10:49:12 +0000 | [diff] [blame] | 1715 | /* run reg test last, a reset is required after it */ |
| 1716 | if (i40e_reg_test(netdev, &data[I40E_ETH_TEST_REG])) |
| 1717 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1718 | |
| 1719 | clear_bit(__I40E_TESTING, &pf->state); |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 1720 | i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED)); |
Greg Rose | 5b86c5c | 2015-02-26 16:14:35 +0000 | [diff] [blame] | 1721 | |
| 1722 | if (if_running) |
| 1723 | dev_open(netdev); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1724 | } else { |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1725 | /* Online tests */ |
Shannon Nelson | b03aaa9 | 2013-11-20 10:03:06 +0000 | [diff] [blame] | 1726 | netif_info(pf, drv, netdev, "online testing starting\n"); |
| 1727 | |
Shannon Nelson | 7b08639 | 2013-11-20 10:02:59 +0000 | [diff] [blame] | 1728 | if (i40e_link_test(netdev, &data[I40E_ETH_TEST_LINK])) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1729 | eth_test->flags |= ETH_TEST_FL_FAILED; |
| 1730 | |
| 1731 | /* Offline only tests, not run in online; pass by default */ |
| 1732 | data[I40E_ETH_TEST_REG] = 0; |
| 1733 | data[I40E_ETH_TEST_EEPROM] = 0; |
| 1734 | data[I40E_ETH_TEST_INTR] = 0; |
| 1735 | data[I40E_ETH_TEST_LOOPBACK] = 0; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1736 | } |
Shannon Nelson | c140c17 | 2013-11-20 10:02:58 +0000 | [diff] [blame] | 1737 | |
Greg Rose | e17bc41 | 2015-04-16 20:05:59 -0400 | [diff] [blame] | 1738 | skip_ol_tests: |
| 1739 | |
Shannon Nelson | b03aaa9 | 2013-11-20 10:03:06 +0000 | [diff] [blame] | 1740 | netif_info(pf, drv, netdev, "testing finished\n"); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1741 | } |
| 1742 | |
| 1743 | static void i40e_get_wol(struct net_device *netdev, |
| 1744 | struct ethtool_wolinfo *wol) |
| 1745 | { |
Shannon Nelson | 8e2773a | 2013-11-28 06:39:22 +0000 | [diff] [blame] | 1746 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1747 | struct i40e_pf *pf = np->vsi->back; |
| 1748 | struct i40e_hw *hw = &pf->hw; |
| 1749 | u16 wol_nvm_bits; |
| 1750 | |
| 1751 | /* NVM bit on means WoL disabled for the port */ |
| 1752 | i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits); |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 1753 | if ((BIT(hw->port) & wol_nvm_bits) || (hw->partition_id != 1)) { |
Shannon Nelson | 8e2773a | 2013-11-28 06:39:22 +0000 | [diff] [blame] | 1754 | wol->supported = 0; |
| 1755 | wol->wolopts = 0; |
| 1756 | } else { |
| 1757 | wol->supported = WAKE_MAGIC; |
| 1758 | wol->wolopts = (pf->wol_en ? WAKE_MAGIC : 0); |
| 1759 | } |
| 1760 | } |
| 1761 | |
Shannon Nelson | f0d8c73 | 2014-12-11 07:06:32 +0000 | [diff] [blame] | 1762 | /** |
| 1763 | * i40e_set_wol - set the WakeOnLAN configuration |
| 1764 | * @netdev: the netdev in question |
| 1765 | * @wol: the ethtool WoL setting data |
| 1766 | **/ |
Shannon Nelson | 8e2773a | 2013-11-28 06:39:22 +0000 | [diff] [blame] | 1767 | static int i40e_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol) |
| 1768 | { |
| 1769 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1770 | struct i40e_pf *pf = np->vsi->back; |
Shannon Nelson | f0d8c73 | 2014-12-11 07:06:32 +0000 | [diff] [blame] | 1771 | struct i40e_vsi *vsi = np->vsi; |
Shannon Nelson | 8e2773a | 2013-11-28 06:39:22 +0000 | [diff] [blame] | 1772 | struct i40e_hw *hw = &pf->hw; |
| 1773 | u16 wol_nvm_bits; |
| 1774 | |
Shannon Nelson | f0d8c73 | 2014-12-11 07:06:32 +0000 | [diff] [blame] | 1775 | /* WoL not supported if this isn't the controlling PF on the port */ |
| 1776 | if (hw->partition_id != 1) { |
| 1777 | i40e_partition_setting_complaint(pf); |
| 1778 | return -EOPNOTSUPP; |
| 1779 | } |
| 1780 | |
| 1781 | if (vsi != pf->vsi[pf->lan_vsi]) |
| 1782 | return -EOPNOTSUPP; |
| 1783 | |
Shannon Nelson | 8e2773a | 2013-11-28 06:39:22 +0000 | [diff] [blame] | 1784 | /* NVM bit on means WoL disabled for the port */ |
| 1785 | i40e_read_nvm_word(hw, I40E_SR_NVM_WAKE_ON_LAN, &wol_nvm_bits); |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 1786 | if (BIT(hw->port) & wol_nvm_bits) |
Shannon Nelson | 8e2773a | 2013-11-28 06:39:22 +0000 | [diff] [blame] | 1787 | return -EOPNOTSUPP; |
| 1788 | |
| 1789 | /* only magic packet is supported */ |
| 1790 | if (wol->wolopts && (wol->wolopts != WAKE_MAGIC)) |
| 1791 | return -EOPNOTSUPP; |
| 1792 | |
| 1793 | /* is this a new value? */ |
| 1794 | if (pf->wol_en != !!wol->wolopts) { |
| 1795 | pf->wol_en = !!wol->wolopts; |
| 1796 | device_set_wakeup_enable(&pf->pdev->dev, pf->wol_en); |
| 1797 | } |
| 1798 | |
| 1799 | return 0; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1800 | } |
| 1801 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1802 | static int i40e_set_phys_id(struct net_device *netdev, |
| 1803 | enum ethtool_phys_id_state state) |
| 1804 | { |
| 1805 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1806 | struct i40e_pf *pf = np->vsi->back; |
| 1807 | struct i40e_hw *hw = &pf->hw; |
| 1808 | int blink_freq = 2; |
| 1809 | |
| 1810 | switch (state) { |
| 1811 | case ETHTOOL_ID_ACTIVE: |
| 1812 | pf->led_status = i40e_led_get(hw); |
| 1813 | return blink_freq; |
| 1814 | case ETHTOOL_ID_ON: |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1815 | i40e_led_set(hw, 0xF, false); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1816 | break; |
| 1817 | case ETHTOOL_ID_OFF: |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1818 | i40e_led_set(hw, 0x0, false); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1819 | break; |
| 1820 | case ETHTOOL_ID_INACTIVE: |
Jesse Brandeburg | 0556a9e | 2013-11-28 06:39:33 +0000 | [diff] [blame] | 1821 | i40e_led_set(hw, pf->led_status, false); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1822 | break; |
Akeem G Abodunrin | 579b23d | 2015-02-24 06:58:42 +0000 | [diff] [blame] | 1823 | default: |
| 1824 | break; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1825 | } |
| 1826 | |
| 1827 | return 0; |
| 1828 | } |
| 1829 | |
| 1830 | /* NOTE: i40e hardware uses a conversion factor of 2 for Interrupt |
| 1831 | * Throttle Rate (ITR) ie. ITR(1) = 2us ITR(10) = 20 us, and also |
| 1832 | * 125us (8000 interrupts per second) == ITR(62) |
| 1833 | */ |
| 1834 | |
| 1835 | static int i40e_get_coalesce(struct net_device *netdev, |
| 1836 | struct ethtool_coalesce *ec) |
| 1837 | { |
| 1838 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1839 | struct i40e_vsi *vsi = np->vsi; |
| 1840 | |
| 1841 | ec->tx_max_coalesced_frames_irq = vsi->work_limit; |
| 1842 | ec->rx_max_coalesced_frames_irq = vsi->work_limit; |
| 1843 | |
| 1844 | if (ITR_IS_DYNAMIC(vsi->rx_itr_setting)) |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 1845 | ec->use_adaptive_rx_coalesce = 1; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1846 | |
| 1847 | if (ITR_IS_DYNAMIC(vsi->tx_itr_setting)) |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 1848 | ec->use_adaptive_tx_coalesce = 1; |
| 1849 | |
| 1850 | ec->rx_coalesce_usecs = vsi->rx_itr_setting & ~I40E_ITR_DYNAMIC; |
| 1851 | ec->tx_coalesce_usecs = vsi->tx_itr_setting & ~I40E_ITR_DYNAMIC; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1852 | |
| 1853 | return 0; |
| 1854 | } |
| 1855 | |
| 1856 | static int i40e_set_coalesce(struct net_device *netdev, |
| 1857 | struct ethtool_coalesce *ec) |
| 1858 | { |
| 1859 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 1860 | struct i40e_q_vector *q_vector; |
| 1861 | struct i40e_vsi *vsi = np->vsi; |
| 1862 | struct i40e_pf *pf = vsi->back; |
| 1863 | struct i40e_hw *hw = &pf->hw; |
| 1864 | u16 vector; |
| 1865 | int i; |
| 1866 | |
| 1867 | if (ec->tx_max_coalesced_frames_irq || ec->rx_max_coalesced_frames_irq) |
| 1868 | vsi->work_limit = ec->tx_max_coalesced_frames_irq; |
| 1869 | |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1870 | vector = vsi->base_vector; |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 1871 | if ((ec->rx_coalesce_usecs >= (I40E_MIN_ITR << 1)) && |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1872 | (ec->rx_coalesce_usecs <= (I40E_MAX_ITR << 1))) { |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1873 | vsi->rx_itr_setting = ec->rx_coalesce_usecs; |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1874 | } else if (ec->rx_coalesce_usecs == 0) { |
| 1875 | vsi->rx_itr_setting = ec->rx_coalesce_usecs; |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1876 | if (ec->use_adaptive_rx_coalesce) |
Jesse Brandeburg | 79442d3 | 2014-10-25 03:24:32 +0000 | [diff] [blame] | 1877 | netif_info(pf, drv, netdev, "rx-usecs=0, need to disable adaptive-rx for a complete disable\n"); |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1878 | } else { |
Jesse Brandeburg | 79442d3 | 2014-10-25 03:24:32 +0000 | [diff] [blame] | 1879 | netif_info(pf, drv, netdev, "Invalid value, rx-usecs range is 0-8160\n"); |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 1880 | return -EINVAL; |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1881 | } |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1882 | |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 1883 | if ((ec->tx_coalesce_usecs >= (I40E_MIN_ITR << 1)) && |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1884 | (ec->tx_coalesce_usecs <= (I40E_MAX_ITR << 1))) { |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1885 | vsi->tx_itr_setting = ec->tx_coalesce_usecs; |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1886 | } else if (ec->tx_coalesce_usecs == 0) { |
| 1887 | vsi->tx_itr_setting = ec->tx_coalesce_usecs; |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1888 | if (ec->use_adaptive_tx_coalesce) |
Jesse Brandeburg | 79442d3 | 2014-10-25 03:24:32 +0000 | [diff] [blame] | 1889 | netif_info(pf, drv, netdev, "tx-usecs=0, need to disable adaptive-tx for a complete disable\n"); |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1890 | } else { |
| 1891 | netif_info(pf, drv, netdev, |
Jesse Brandeburg | 79442d3 | 2014-10-25 03:24:32 +0000 | [diff] [blame] | 1892 | "Invalid value, tx-usecs range is 0-8160\n"); |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 1893 | return -EINVAL; |
Carolyn Wyborny | 5c2cebd | 2014-06-04 01:23:18 +0000 | [diff] [blame] | 1894 | } |
Mitch Williams | 32f5f54 | 2014-04-04 04:43:10 +0000 | [diff] [blame] | 1895 | |
| 1896 | if (ec->use_adaptive_rx_coalesce) |
| 1897 | vsi->rx_itr_setting |= I40E_ITR_DYNAMIC; |
| 1898 | else |
| 1899 | vsi->rx_itr_setting &= ~I40E_ITR_DYNAMIC; |
| 1900 | |
| 1901 | if (ec->use_adaptive_tx_coalesce) |
| 1902 | vsi->tx_itr_setting |= I40E_ITR_DYNAMIC; |
| 1903 | else |
| 1904 | vsi->tx_itr_setting &= ~I40E_ITR_DYNAMIC; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1905 | |
Alexander Duyck | 493fb30 | 2013-09-28 07:01:44 +0000 | [diff] [blame] | 1906 | for (i = 0; i < vsi->num_q_vectors; i++, vector++) { |
| 1907 | q_vector = vsi->q_vectors[i]; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1908 | q_vector->rx.itr = ITR_TO_REG(vsi->rx_itr_setting); |
| 1909 | wr32(hw, I40E_PFINT_ITRN(0, vector - 1), q_vector->rx.itr); |
| 1910 | q_vector->tx.itr = ITR_TO_REG(vsi->tx_itr_setting); |
| 1911 | wr32(hw, I40E_PFINT_ITRN(1, vector - 1), q_vector->tx.itr); |
| 1912 | i40e_flush(hw); |
| 1913 | } |
| 1914 | |
| 1915 | return 0; |
| 1916 | } |
| 1917 | |
| 1918 | /** |
| 1919 | * i40e_get_rss_hash_opts - Get RSS hash Input Set for each flow type |
| 1920 | * @pf: pointer to the physical function struct |
| 1921 | * @cmd: ethtool rxnfc command |
| 1922 | * |
| 1923 | * Returns Success if the flow is supported, else Invalid Input. |
| 1924 | **/ |
| 1925 | static int i40e_get_rss_hash_opts(struct i40e_pf *pf, struct ethtool_rxnfc *cmd) |
| 1926 | { |
| 1927 | cmd->data = 0; |
| 1928 | |
Carolyn Wyborny | 88eee9b | 2015-02-06 08:52:09 +0000 | [diff] [blame] | 1929 | if (pf->vsi[pf->lan_vsi]->rxnfc.data != 0) { |
| 1930 | cmd->data = pf->vsi[pf->lan_vsi]->rxnfc.data; |
| 1931 | cmd->flow_type = pf->vsi[pf->lan_vsi]->rxnfc.flow_type; |
| 1932 | return 0; |
| 1933 | } |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 1934 | /* Report default options for RSS on i40e */ |
| 1935 | switch (cmd->flow_type) { |
| 1936 | case TCP_V4_FLOW: |
| 1937 | case UDP_V4_FLOW: |
| 1938 | cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 1939 | /* fall through to add IP fields */ |
| 1940 | case SCTP_V4_FLOW: |
| 1941 | case AH_ESP_V4_FLOW: |
| 1942 | case AH_V4_FLOW: |
| 1943 | case ESP_V4_FLOW: |
| 1944 | case IPV4_FLOW: |
| 1945 | cmd->data |= RXH_IP_SRC | RXH_IP_DST; |
| 1946 | break; |
| 1947 | case TCP_V6_FLOW: |
| 1948 | case UDP_V6_FLOW: |
| 1949 | cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; |
| 1950 | /* fall through to add IP fields */ |
| 1951 | case SCTP_V6_FLOW: |
| 1952 | case AH_ESP_V6_FLOW: |
| 1953 | case AH_V6_FLOW: |
| 1954 | case ESP_V6_FLOW: |
| 1955 | case IPV6_FLOW: |
| 1956 | cmd->data |= RXH_IP_SRC | RXH_IP_DST; |
| 1957 | break; |
| 1958 | default: |
| 1959 | return -EINVAL; |
| 1960 | } |
| 1961 | |
| 1962 | return 0; |
| 1963 | } |
| 1964 | |
| 1965 | /** |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 1966 | * i40e_get_ethtool_fdir_all - Populates the rule count of a command |
| 1967 | * @pf: Pointer to the physical function struct |
| 1968 | * @cmd: The command to get or set Rx flow classification rules |
| 1969 | * @rule_locs: Array of used rule locations |
| 1970 | * |
| 1971 | * This function populates both the total and actual rule count of |
| 1972 | * the ethtool flow classification command |
| 1973 | * |
| 1974 | * Returns 0 on success or -EMSGSIZE if entry not found |
| 1975 | **/ |
| 1976 | static int i40e_get_ethtool_fdir_all(struct i40e_pf *pf, |
| 1977 | struct ethtool_rxnfc *cmd, |
| 1978 | u32 *rule_locs) |
| 1979 | { |
| 1980 | struct i40e_fdir_filter *rule; |
| 1981 | struct hlist_node *node2; |
| 1982 | int cnt = 0; |
| 1983 | |
| 1984 | /* report total rule count */ |
Anjali Singhai Jain | 082def1 | 2014-04-09 05:59:00 +0000 | [diff] [blame] | 1985 | cmd->data = i40e_get_fd_cnt_all(pf); |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 1986 | |
| 1987 | hlist_for_each_entry_safe(rule, node2, |
| 1988 | &pf->fdir_filter_list, fdir_node) { |
| 1989 | if (cnt == cmd->rule_cnt) |
| 1990 | return -EMSGSIZE; |
| 1991 | |
| 1992 | rule_locs[cnt] = rule->fd_id; |
| 1993 | cnt++; |
| 1994 | } |
| 1995 | |
| 1996 | cmd->rule_cnt = cnt; |
| 1997 | |
| 1998 | return 0; |
| 1999 | } |
| 2000 | |
| 2001 | /** |
| 2002 | * i40e_get_ethtool_fdir_entry - Look up a filter based on Rx flow |
| 2003 | * @pf: Pointer to the physical function struct |
| 2004 | * @cmd: The command to get or set Rx flow classification rules |
| 2005 | * |
| 2006 | * This function looks up a filter based on the Rx flow classification |
| 2007 | * command and fills the flow spec info for it if found |
| 2008 | * |
| 2009 | * Returns 0 on success or -EINVAL if filter not found |
| 2010 | **/ |
| 2011 | static int i40e_get_ethtool_fdir_entry(struct i40e_pf *pf, |
| 2012 | struct ethtool_rxnfc *cmd) |
| 2013 | { |
| 2014 | struct ethtool_rx_flow_spec *fsp = |
| 2015 | (struct ethtool_rx_flow_spec *)&cmd->fs; |
| 2016 | struct i40e_fdir_filter *rule = NULL; |
| 2017 | struct hlist_node *node2; |
| 2018 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2019 | hlist_for_each_entry_safe(rule, node2, |
| 2020 | &pf->fdir_filter_list, fdir_node) { |
| 2021 | if (fsp->location <= rule->fd_id) |
| 2022 | break; |
| 2023 | } |
| 2024 | |
| 2025 | if (!rule || fsp->location != rule->fd_id) |
| 2026 | return -EINVAL; |
| 2027 | |
| 2028 | fsp->flow_type = rule->flow_type; |
Anjali Singhai Jain | 7d54eb2 | 2014-03-14 07:32:21 +0000 | [diff] [blame] | 2029 | if (fsp->flow_type == IP_USER_FLOW) { |
| 2030 | fsp->h_u.usr_ip4_spec.ip_ver = ETH_RX_NFC_IP4; |
| 2031 | fsp->h_u.usr_ip4_spec.proto = 0; |
| 2032 | fsp->m_u.usr_ip4_spec.proto = 0; |
| 2033 | } |
| 2034 | |
Anjali Singhai Jain | 04b73bd | 2014-05-22 06:31:41 +0000 | [diff] [blame] | 2035 | /* Reverse the src and dest notion, since the HW views them from |
| 2036 | * Tx perspective where as the user expects it from Rx filter view. |
| 2037 | */ |
| 2038 | fsp->h_u.tcp_ip4_spec.psrc = rule->dst_port; |
| 2039 | fsp->h_u.tcp_ip4_spec.pdst = rule->src_port; |
| 2040 | fsp->h_u.tcp_ip4_spec.ip4src = rule->dst_ip[0]; |
| 2041 | fsp->h_u.tcp_ip4_spec.ip4dst = rule->src_ip[0]; |
Anjali Singhai Jain | 387ce1a | 2014-05-22 06:32:23 +0000 | [diff] [blame] | 2042 | |
| 2043 | if (rule->dest_ctl == I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET) |
| 2044 | fsp->ring_cookie = RX_CLS_FLOW_DISC; |
| 2045 | else |
| 2046 | fsp->ring_cookie = rule->q_index; |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2047 | |
Anjali Singhai Jain | e7c8c60 | 2015-04-07 19:45:31 -0400 | [diff] [blame] | 2048 | if (rule->dest_vsi != pf->vsi[pf->lan_vsi]->id) { |
| 2049 | struct i40e_vsi *vsi; |
| 2050 | |
| 2051 | vsi = i40e_find_vsi_from_id(pf, rule->dest_vsi); |
| 2052 | if (vsi && vsi->type == I40E_VSI_SRIOV) { |
| 2053 | fsp->h_ext.data[1] = htonl(vsi->vf_id); |
| 2054 | fsp->m_ext.data[1] = htonl(0x1); |
| 2055 | } |
| 2056 | } |
| 2057 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2058 | return 0; |
| 2059 | } |
| 2060 | |
| 2061 | /** |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2062 | * i40e_get_rxnfc - command to get RX flow classification rules |
| 2063 | * @netdev: network interface device structure |
| 2064 | * @cmd: ethtool rxnfc command |
| 2065 | * |
| 2066 | * Returns Success if the command is supported. |
| 2067 | **/ |
| 2068 | static int i40e_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, |
| 2069 | u32 *rule_locs) |
| 2070 | { |
| 2071 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 2072 | struct i40e_vsi *vsi = np->vsi; |
| 2073 | struct i40e_pf *pf = vsi->back; |
| 2074 | int ret = -EOPNOTSUPP; |
| 2075 | |
| 2076 | switch (cmd->cmd) { |
| 2077 | case ETHTOOL_GRXRINGS: |
| 2078 | cmd->data = vsi->alloc_queue_pairs; |
| 2079 | ret = 0; |
| 2080 | break; |
| 2081 | case ETHTOOL_GRXFH: |
| 2082 | ret = i40e_get_rss_hash_opts(pf, cmd); |
| 2083 | break; |
| 2084 | case ETHTOOL_GRXCLSRLCNT: |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2085 | cmd->rule_cnt = pf->fdir_pf_active_filters; |
Anjali Singhai Jain | 082def1 | 2014-04-09 05:59:00 +0000 | [diff] [blame] | 2086 | /* report total rule count */ |
| 2087 | cmd->data = i40e_get_fd_cnt_all(pf); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2088 | ret = 0; |
| 2089 | break; |
| 2090 | case ETHTOOL_GRXCLSRULE: |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2091 | ret = i40e_get_ethtool_fdir_entry(pf, cmd); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2092 | break; |
| 2093 | case ETHTOOL_GRXCLSRLALL: |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2094 | ret = i40e_get_ethtool_fdir_all(pf, cmd, rule_locs); |
| 2095 | break; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2096 | default: |
| 2097 | break; |
| 2098 | } |
| 2099 | |
| 2100 | return ret; |
| 2101 | } |
| 2102 | |
| 2103 | /** |
| 2104 | * i40e_set_rss_hash_opt - Enable/Disable flow types for RSS hash |
| 2105 | * @pf: pointer to the physical function struct |
| 2106 | * @cmd: ethtool rxnfc command |
| 2107 | * |
| 2108 | * Returns Success if the flow input set is supported. |
| 2109 | **/ |
| 2110 | static int i40e_set_rss_hash_opt(struct i40e_pf *pf, struct ethtool_rxnfc *nfc) |
| 2111 | { |
| 2112 | struct i40e_hw *hw = &pf->hw; |
| 2113 | u64 hena = (u64)rd32(hw, I40E_PFQF_HENA(0)) | |
| 2114 | ((u64)rd32(hw, I40E_PFQF_HENA(1)) << 32); |
| 2115 | |
| 2116 | /* RSS does not support anything other than hashing |
| 2117 | * to queues on src and dst IPs and ports |
| 2118 | */ |
| 2119 | if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | |
| 2120 | RXH_L4_B_0_1 | RXH_L4_B_2_3)) |
| 2121 | return -EINVAL; |
| 2122 | |
| 2123 | /* We need at least the IP SRC and DEST fields for hashing */ |
| 2124 | if (!(nfc->data & RXH_IP_SRC) || |
| 2125 | !(nfc->data & RXH_IP_DST)) |
| 2126 | return -EINVAL; |
| 2127 | |
| 2128 | switch (nfc->flow_type) { |
| 2129 | case TCP_V4_FLOW: |
| 2130 | switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { |
| 2131 | case 0: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2132 | hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2133 | break; |
| 2134 | case (RXH_L4_B_0_1 | RXH_L4_B_2_3): |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2135 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_TCP); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2136 | break; |
| 2137 | default: |
| 2138 | return -EINVAL; |
| 2139 | } |
| 2140 | break; |
| 2141 | case TCP_V6_FLOW: |
| 2142 | switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { |
| 2143 | case 0: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2144 | hena &= ~BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2145 | break; |
| 2146 | case (RXH_L4_B_0_1 | RXH_L4_B_2_3): |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2147 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_TCP); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2148 | break; |
| 2149 | default: |
| 2150 | return -EINVAL; |
| 2151 | } |
| 2152 | break; |
| 2153 | case UDP_V4_FLOW: |
| 2154 | switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { |
| 2155 | case 0: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2156 | hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | |
| 2157 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4)); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2158 | break; |
| 2159 | case (RXH_L4_B_0_1 | RXH_L4_B_2_3): |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2160 | hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_UDP) | |
| 2161 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4)); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2162 | break; |
| 2163 | default: |
| 2164 | return -EINVAL; |
| 2165 | } |
| 2166 | break; |
| 2167 | case UDP_V6_FLOW: |
| 2168 | switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { |
| 2169 | case 0: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2170 | hena &= ~(BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | |
| 2171 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6)); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2172 | break; |
| 2173 | case (RXH_L4_B_0_1 | RXH_L4_B_2_3): |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2174 | hena |= (BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_UDP) | |
| 2175 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6)); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2176 | break; |
| 2177 | default: |
| 2178 | return -EINVAL; |
| 2179 | } |
| 2180 | break; |
| 2181 | case AH_ESP_V4_FLOW: |
| 2182 | case AH_V4_FLOW: |
| 2183 | case ESP_V4_FLOW: |
| 2184 | case SCTP_V4_FLOW: |
| 2185 | if ((nfc->data & RXH_L4_B_0_1) || |
| 2186 | (nfc->data & RXH_L4_B_2_3)) |
| 2187 | return -EINVAL; |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2188 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2189 | break; |
| 2190 | case AH_ESP_V6_FLOW: |
| 2191 | case AH_V6_FLOW: |
| 2192 | case ESP_V6_FLOW: |
| 2193 | case SCTP_V6_FLOW: |
| 2194 | if ((nfc->data & RXH_L4_B_0_1) || |
| 2195 | (nfc->data & RXH_L4_B_2_3)) |
| 2196 | return -EINVAL; |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2197 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2198 | break; |
| 2199 | case IPV4_FLOW: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2200 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV4_OTHER) | |
| 2201 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV4); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2202 | break; |
| 2203 | case IPV6_FLOW: |
Jesse Brandeburg | 41a1d04 | 2015-06-04 16:24:02 -0400 | [diff] [blame] | 2204 | hena |= BIT_ULL(I40E_FILTER_PCTYPE_NONF_IPV6_OTHER) | |
| 2205 | BIT_ULL(I40E_FILTER_PCTYPE_FRAG_IPV6); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2206 | break; |
| 2207 | default: |
| 2208 | return -EINVAL; |
| 2209 | } |
| 2210 | |
| 2211 | wr32(hw, I40E_PFQF_HENA(0), (u32)hena); |
| 2212 | wr32(hw, I40E_PFQF_HENA(1), (u32)(hena >> 32)); |
| 2213 | i40e_flush(hw); |
| 2214 | |
Carolyn Wyborny | 88eee9b | 2015-02-06 08:52:09 +0000 | [diff] [blame] | 2215 | /* Save setting for future output/update */ |
| 2216 | pf->vsi[pf->lan_vsi]->rxnfc = *nfc; |
| 2217 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2218 | return 0; |
| 2219 | } |
| 2220 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2221 | /** |
Anjali Singhai Jain | 43fddb7 | 2014-02-11 08:24:09 +0000 | [diff] [blame] | 2222 | * i40e_match_fdir_input_set - Match a new filter against an existing one |
| 2223 | * @rule: The filter already added |
| 2224 | * @input: The new filter to comapre against |
| 2225 | * |
| 2226 | * Returns true if the two input set match |
| 2227 | **/ |
| 2228 | static bool i40e_match_fdir_input_set(struct i40e_fdir_filter *rule, |
| 2229 | struct i40e_fdir_filter *input) |
| 2230 | { |
| 2231 | if ((rule->dst_ip[0] != input->dst_ip[0]) || |
| 2232 | (rule->src_ip[0] != input->src_ip[0]) || |
| 2233 | (rule->dst_port != input->dst_port) || |
| 2234 | (rule->src_port != input->src_port)) |
| 2235 | return false; |
| 2236 | return true; |
| 2237 | } |
| 2238 | |
| 2239 | /** |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2240 | * i40e_update_ethtool_fdir_entry - Updates the fdir filter entry |
| 2241 | * @vsi: Pointer to the targeted VSI |
| 2242 | * @input: The filter to update or NULL to indicate deletion |
| 2243 | * @sw_idx: Software index to the filter |
| 2244 | * @cmd: The command to get or set Rx flow classification rules |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2245 | * |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2246 | * This function updates (or deletes) a Flow Director entry from |
| 2247 | * the hlist of the corresponding PF |
| 2248 | * |
| 2249 | * Returns 0 on success |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2250 | **/ |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2251 | static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi, |
| 2252 | struct i40e_fdir_filter *input, |
| 2253 | u16 sw_idx, |
| 2254 | struct ethtool_rxnfc *cmd) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2255 | { |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2256 | struct i40e_fdir_filter *rule, *parent; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2257 | struct i40e_pf *pf = vsi->back; |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2258 | struct hlist_node *node2; |
| 2259 | int err = -EINVAL; |
Jesse Brandeburg | c35a1d7 | 2013-12-18 13:46:02 +0000 | [diff] [blame] | 2260 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2261 | parent = NULL; |
| 2262 | rule = NULL; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2263 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2264 | hlist_for_each_entry_safe(rule, node2, |
| 2265 | &pf->fdir_filter_list, fdir_node) { |
| 2266 | /* hash found, or no matching entry */ |
| 2267 | if (rule->fd_id >= sw_idx) |
| 2268 | break; |
| 2269 | parent = rule; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2270 | } |
| 2271 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2272 | /* if there is an old rule occupying our place remove it */ |
| 2273 | if (rule && (rule->fd_id == sw_idx)) { |
Anjali Singhai Jain | 43fddb7 | 2014-02-11 08:24:09 +0000 | [diff] [blame] | 2274 | if (input && !i40e_match_fdir_input_set(rule, input)) |
| 2275 | err = i40e_add_del_fdir(vsi, rule, false); |
| 2276 | else if (!input) |
| 2277 | err = i40e_add_del_fdir(vsi, rule, false); |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2278 | hlist_del(&rule->fdir_node); |
| 2279 | kfree(rule); |
| 2280 | pf->fdir_pf_active_filters--; |
| 2281 | } |
| 2282 | |
| 2283 | /* If no input this was a delete, err should be 0 if a rule was |
| 2284 | * successfully found and removed from the list else -EINVAL |
| 2285 | */ |
| 2286 | if (!input) |
| 2287 | return err; |
| 2288 | |
| 2289 | /* initialize node and set software index */ |
| 2290 | INIT_HLIST_NODE(&input->fdir_node); |
| 2291 | |
| 2292 | /* add filter to the list */ |
| 2293 | if (parent) |
Ken Helias | 1d02328 | 2014-08-06 16:09:16 -0700 | [diff] [blame] | 2294 | hlist_add_behind(&input->fdir_node, &parent->fdir_node); |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2295 | else |
| 2296 | hlist_add_head(&input->fdir_node, |
| 2297 | &pf->fdir_filter_list); |
| 2298 | |
| 2299 | /* update counts */ |
| 2300 | pf->fdir_pf_active_filters++; |
| 2301 | |
| 2302 | return 0; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2303 | } |
| 2304 | |
| 2305 | /** |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2306 | * i40e_del_fdir_entry - Deletes a Flow Director filter entry |
| 2307 | * @vsi: Pointer to the targeted VSI |
| 2308 | * @cmd: The command to get or set Rx flow classification rules |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2309 | * |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2310 | * The function removes a Flow Director filter entry from the |
| 2311 | * hlist of the corresponding PF |
| 2312 | * |
| 2313 | * Returns 0 on success |
| 2314 | */ |
| 2315 | static int i40e_del_fdir_entry(struct i40e_vsi *vsi, |
| 2316 | struct ethtool_rxnfc *cmd) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2317 | { |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2318 | struct ethtool_rx_flow_spec *fsp = |
| 2319 | (struct ethtool_rx_flow_spec *)&cmd->fs; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2320 | struct i40e_pf *pf = vsi->back; |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2321 | int ret = 0; |
Jesse Brandeburg | c35a1d7 | 2013-12-18 13:46:02 +0000 | [diff] [blame] | 2322 | |
Anjali Singhai Jain | 60793f4a | 2014-07-09 07:46:23 +0000 | [diff] [blame] | 2323 | if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) || |
| 2324 | test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state)) |
| 2325 | return -EBUSY; |
| 2326 | |
Anjali Singhai Jain | 1e1be8f | 2014-07-10 08:03:26 +0000 | [diff] [blame] | 2327 | if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state)) |
| 2328 | return -EBUSY; |
| 2329 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2330 | ret = i40e_update_ethtool_fdir_entry(vsi, NULL, fsp->location, cmd); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2331 | |
Anjali Singhai Jain | 55a5e60 | 2014-02-12 06:33:25 +0000 | [diff] [blame] | 2332 | i40e_fdir_check_and_reenable(pf); |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2333 | return ret; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2334 | } |
| 2335 | |
| 2336 | /** |
Anjali Singhai Jain | 1eaa384 | 2014-03-06 08:59:59 +0000 | [diff] [blame] | 2337 | * i40e_add_fdir_ethtool - Add/Remove Flow Director filters |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2338 | * @vsi: pointer to the targeted VSI |
| 2339 | * @cmd: command to get or set RX flow classification rules |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2340 | * |
Anjali Singhai Jain | 1eaa384 | 2014-03-06 08:59:59 +0000 | [diff] [blame] | 2341 | * Add Flow Director filters for a specific flow spec based on their |
| 2342 | * protocol. Returns 0 if the filters were successfully added. |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2343 | **/ |
Anjali Singhai Jain | 1eaa384 | 2014-03-06 08:59:59 +0000 | [diff] [blame] | 2344 | static int i40e_add_fdir_ethtool(struct i40e_vsi *vsi, |
| 2345 | struct ethtool_rxnfc *cmd) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2346 | { |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2347 | struct ethtool_rx_flow_spec *fsp; |
| 2348 | struct i40e_fdir_filter *input; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2349 | struct i40e_pf *pf; |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2350 | int ret = -EINVAL; |
Anjali Singhai Jain | e7c8c60 | 2015-04-07 19:45:31 -0400 | [diff] [blame] | 2351 | u16 vf_id; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2352 | |
| 2353 | if (!vsi) |
| 2354 | return -EINVAL; |
| 2355 | |
| 2356 | pf = vsi->back; |
| 2357 | |
Anjali Singhai Jain | 55a5e60 | 2014-02-12 06:33:25 +0000 | [diff] [blame] | 2358 | if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED)) |
| 2359 | return -EOPNOTSUPP; |
| 2360 | |
Anjali Singhai Jain | 1eaa384 | 2014-03-06 08:59:59 +0000 | [diff] [blame] | 2361 | if (pf->auto_disable_flags & I40E_FLAG_FD_SB_ENABLED) |
Anjali Singhai Jain | 55a5e60 | 2014-02-12 06:33:25 +0000 | [diff] [blame] | 2362 | return -ENOSPC; |
| 2363 | |
Anjali Singhai Jain | 60793f4a | 2014-07-09 07:46:23 +0000 | [diff] [blame] | 2364 | if (test_bit(__I40E_RESET_RECOVERY_PENDING, &pf->state) || |
| 2365 | test_bit(__I40E_RESET_INTR_RECEIVED, &pf->state)) |
| 2366 | return -EBUSY; |
| 2367 | |
Anjali Singhai Jain | 1e1be8f | 2014-07-10 08:03:26 +0000 | [diff] [blame] | 2368 | if (test_bit(__I40E_FD_FLUSH_REQUESTED, &pf->state)) |
| 2369 | return -EBUSY; |
| 2370 | |
Anjali Singhai Jain | 55a5e60 | 2014-02-12 06:33:25 +0000 | [diff] [blame] | 2371 | fsp = (struct ethtool_rx_flow_spec *)&cmd->fs; |
| 2372 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2373 | if (fsp->location >= (pf->hw.func_caps.fd_filters_best_effort + |
| 2374 | pf->hw.func_caps.fd_filters_guaranteed)) { |
| 2375 | return -EINVAL; |
| 2376 | } |
| 2377 | |
Anjali Singhai Jain | 387ce1a | 2014-05-22 06:32:23 +0000 | [diff] [blame] | 2378 | if ((fsp->ring_cookie != RX_CLS_FLOW_DISC) && |
| 2379 | (fsp->ring_cookie >= vsi->num_queue_pairs)) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2380 | return -EINVAL; |
| 2381 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2382 | input = kzalloc(sizeof(*input), GFP_KERNEL); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2383 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2384 | if (!input) |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2385 | return -ENOMEM; |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2386 | |
| 2387 | input->fd_id = fsp->location; |
| 2388 | |
Anjali Singhai Jain | 35a91fd | 2014-03-06 09:00:00 +0000 | [diff] [blame] | 2389 | if (fsp->ring_cookie == RX_CLS_FLOW_DISC) |
| 2390 | input->dest_ctl = I40E_FILTER_PROGRAM_DESC_DEST_DROP_PACKET; |
| 2391 | else |
| 2392 | input->dest_ctl = |
| 2393 | I40E_FILTER_PROGRAM_DESC_DEST_DIRECT_PACKET_QINDEX; |
| 2394 | |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2395 | input->q_index = fsp->ring_cookie; |
| 2396 | input->flex_off = 0; |
| 2397 | input->pctype = 0; |
| 2398 | input->dest_vsi = vsi->id; |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2399 | input->fd_status = I40E_FILTER_PROGRAM_DESC_FD_STATUS_FD_ID; |
Anjali Singhai Jain | 0bf4b1b | 2015-04-16 20:06:02 -0400 | [diff] [blame] | 2400 | input->cnt_index = I40E_FD_SB_STAT_IDX(pf->hw.pf_id); |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2401 | input->flow_type = fsp->flow_type; |
| 2402 | input->ip4_proto = fsp->h_u.usr_ip4_spec.proto; |
Anjali Singhai Jain | 04b73bd | 2014-05-22 06:31:41 +0000 | [diff] [blame] | 2403 | |
| 2404 | /* Reverse the src and dest notion, since the HW expects them to be from |
| 2405 | * Tx perspective where as the input from user is from Rx filter view. |
| 2406 | */ |
| 2407 | input->dst_port = fsp->h_u.tcp_ip4_spec.psrc; |
| 2408 | input->src_port = fsp->h_u.tcp_ip4_spec.pdst; |
| 2409 | input->dst_ip[0] = fsp->h_u.tcp_ip4_spec.ip4src; |
| 2410 | input->src_ip[0] = fsp->h_u.tcp_ip4_spec.ip4dst; |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2411 | |
Anjali Singhai Jain | e7c8c60 | 2015-04-07 19:45:31 -0400 | [diff] [blame] | 2412 | if (ntohl(fsp->m_ext.data[1])) { |
| 2413 | if (ntohl(fsp->h_ext.data[1]) >= pf->num_alloc_vfs) { |
| 2414 | netif_info(pf, drv, vsi->netdev, "Invalid VF id\n"); |
| 2415 | goto free_input; |
| 2416 | } |
| 2417 | vf_id = ntohl(fsp->h_ext.data[1]); |
| 2418 | /* Find vsi id from vf id and override dest vsi */ |
| 2419 | input->dest_vsi = pf->vf[vf_id].lan_vsi_id; |
| 2420 | if (input->q_index >= pf->vf[vf_id].num_queue_pairs) { |
| 2421 | netif_info(pf, drv, vsi->netdev, "Invalid queue id\n"); |
| 2422 | goto free_input; |
| 2423 | } |
| 2424 | } |
| 2425 | |
Anjali Singhai Jain | 1eaa384 | 2014-03-06 08:59:59 +0000 | [diff] [blame] | 2426 | ret = i40e_add_del_fdir(vsi, input, true); |
Anjali Singhai Jain | e7c8c60 | 2015-04-07 19:45:31 -0400 | [diff] [blame] | 2427 | free_input: |
Anjali Singhai Jain | 1eaa384 | 2014-03-06 08:59:59 +0000 | [diff] [blame] | 2428 | if (ret) |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2429 | kfree(input); |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2430 | else |
Anjali Singhai Jain | 1eaa384 | 2014-03-06 08:59:59 +0000 | [diff] [blame] | 2431 | i40e_update_ethtool_fdir_entry(vsi, input, fsp->location, NULL); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2432 | |
| 2433 | return ret; |
| 2434 | } |
Jesse Brandeburg | 8fb905b | 2014-01-17 15:36:33 -0800 | [diff] [blame] | 2435 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2436 | /** |
| 2437 | * i40e_set_rxnfc - command to set RX flow classification rules |
| 2438 | * @netdev: network interface device structure |
| 2439 | * @cmd: ethtool rxnfc command |
| 2440 | * |
| 2441 | * Returns Success if the command is supported. |
| 2442 | **/ |
| 2443 | static int i40e_set_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd) |
| 2444 | { |
| 2445 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 2446 | struct i40e_vsi *vsi = np->vsi; |
| 2447 | struct i40e_pf *pf = vsi->back; |
| 2448 | int ret = -EOPNOTSUPP; |
| 2449 | |
| 2450 | switch (cmd->cmd) { |
| 2451 | case ETHTOOL_SRXFH: |
| 2452 | ret = i40e_set_rss_hash_opt(pf, cmd); |
| 2453 | break; |
| 2454 | case ETHTOOL_SRXCLSRLINS: |
Anjali Singhai Jain | 1eaa384 | 2014-03-06 08:59:59 +0000 | [diff] [blame] | 2455 | ret = i40e_add_fdir_ethtool(vsi, cmd); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2456 | break; |
| 2457 | case ETHTOOL_SRXCLSRLDEL: |
Joseph Gasparakis | 17a73f6 | 2014-02-12 01:45:30 +0000 | [diff] [blame] | 2458 | ret = i40e_del_fdir_entry(vsi, cmd); |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2459 | break; |
| 2460 | default: |
| 2461 | break; |
| 2462 | } |
| 2463 | |
| 2464 | return ret; |
| 2465 | } |
| 2466 | |
Anjali Singhai Jain | 4b7820c | 2013-11-26 11:59:30 +0000 | [diff] [blame] | 2467 | /** |
| 2468 | * i40e_max_channels - get Max number of combined channels supported |
| 2469 | * @vsi: vsi pointer |
| 2470 | **/ |
| 2471 | static unsigned int i40e_max_channels(struct i40e_vsi *vsi) |
| 2472 | { |
| 2473 | /* TODO: This code assumes DCB and FD is disabled for now. */ |
| 2474 | return vsi->alloc_queue_pairs; |
| 2475 | } |
| 2476 | |
| 2477 | /** |
| 2478 | * i40e_get_channels - Get the current channels enabled and max supported etc. |
| 2479 | * @netdev: network interface device structure |
| 2480 | * @ch: ethtool channels structure |
| 2481 | * |
| 2482 | * We don't support separate tx and rx queues as channels. The other count |
| 2483 | * represents how many queues are being used for control. max_combined counts |
| 2484 | * how many queue pairs we can support. They may not be mapped 1 to 1 with |
| 2485 | * q_vectors since we support a lot more queue pairs than q_vectors. |
| 2486 | **/ |
| 2487 | static void i40e_get_channels(struct net_device *dev, |
| 2488 | struct ethtool_channels *ch) |
| 2489 | { |
| 2490 | struct i40e_netdev_priv *np = netdev_priv(dev); |
| 2491 | struct i40e_vsi *vsi = np->vsi; |
| 2492 | struct i40e_pf *pf = vsi->back; |
| 2493 | |
| 2494 | /* report maximum channels */ |
| 2495 | ch->max_combined = i40e_max_channels(vsi); |
| 2496 | |
| 2497 | /* report info for other vector */ |
Jesse Brandeburg | 60ea5f8 | 2014-01-17 15:36:34 -0800 | [diff] [blame] | 2498 | ch->other_count = (pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0; |
Anjali Singhai Jain | 4b7820c | 2013-11-26 11:59:30 +0000 | [diff] [blame] | 2499 | ch->max_other = ch->other_count; |
| 2500 | |
| 2501 | /* Note: This code assumes DCB is disabled for now. */ |
| 2502 | ch->combined_count = vsi->num_queue_pairs; |
| 2503 | } |
| 2504 | |
| 2505 | /** |
| 2506 | * i40e_set_channels - Set the new channels count. |
| 2507 | * @netdev: network interface device structure |
| 2508 | * @ch: ethtool channels structure |
| 2509 | * |
| 2510 | * The new channels count may not be the same as requested by the user |
| 2511 | * since it gets rounded down to a power of 2 value. |
| 2512 | **/ |
| 2513 | static int i40e_set_channels(struct net_device *dev, |
| 2514 | struct ethtool_channels *ch) |
| 2515 | { |
| 2516 | struct i40e_netdev_priv *np = netdev_priv(dev); |
| 2517 | unsigned int count = ch->combined_count; |
| 2518 | struct i40e_vsi *vsi = np->vsi; |
| 2519 | struct i40e_pf *pf = vsi->back; |
| 2520 | int new_count; |
| 2521 | |
| 2522 | /* We do not support setting channels for any other VSI at present */ |
| 2523 | if (vsi->type != I40E_VSI_MAIN) |
| 2524 | return -EINVAL; |
| 2525 | |
| 2526 | /* verify they are not requesting separate vectors */ |
| 2527 | if (!count || ch->rx_count || ch->tx_count) |
| 2528 | return -EINVAL; |
| 2529 | |
| 2530 | /* verify other_count has not changed */ |
Jesse Brandeburg | 60ea5f8 | 2014-01-17 15:36:34 -0800 | [diff] [blame] | 2531 | if (ch->other_count != ((pf->flags & I40E_FLAG_FD_SB_ENABLED) ? 1 : 0)) |
Anjali Singhai Jain | 4b7820c | 2013-11-26 11:59:30 +0000 | [diff] [blame] | 2532 | return -EINVAL; |
| 2533 | |
| 2534 | /* verify the number of channels does not exceed hardware limits */ |
| 2535 | if (count > i40e_max_channels(vsi)) |
| 2536 | return -EINVAL; |
| 2537 | |
| 2538 | /* update feature limits from largest to smallest supported values */ |
| 2539 | /* TODO: Flow director limit, DCB etc */ |
| 2540 | |
Anjali Singhai Jain | 4b7820c | 2013-11-26 11:59:30 +0000 | [diff] [blame] | 2541 | /* use rss_reconfig to rebuild with new queue count and update traffic |
| 2542 | * class queue mapping |
| 2543 | */ |
| 2544 | new_count = i40e_reconfig_rss_queues(pf, count); |
Anjali Singhai Jain | 5f90f42 | 2013-12-21 05:44:43 +0000 | [diff] [blame] | 2545 | if (new_count > 0) |
Anjali Singhai Jain | 4b7820c | 2013-11-26 11:59:30 +0000 | [diff] [blame] | 2546 | return 0; |
| 2547 | else |
| 2548 | return -EINVAL; |
| 2549 | } |
| 2550 | |
Mitch A Williams | b29e13b | 2015-03-05 04:14:40 +0000 | [diff] [blame] | 2551 | #define I40E_HLUT_ARRAY_SIZE ((I40E_PFQF_HLUT_MAX_INDEX + 1) * 4) |
| 2552 | /** |
| 2553 | * i40e_get_rxfh_key_size - get the RSS hash key size |
| 2554 | * @netdev: network interface device structure |
| 2555 | * |
| 2556 | * Returns the table size. |
| 2557 | **/ |
| 2558 | static u32 i40e_get_rxfh_key_size(struct net_device *netdev) |
| 2559 | { |
| 2560 | return I40E_HKEY_ARRAY_SIZE; |
| 2561 | } |
| 2562 | |
| 2563 | /** |
| 2564 | * i40e_get_rxfh_indir_size - get the rx flow hash indirection table size |
| 2565 | * @netdev: network interface device structure |
| 2566 | * |
| 2567 | * Returns the table size. |
| 2568 | **/ |
| 2569 | static u32 i40e_get_rxfh_indir_size(struct net_device *netdev) |
| 2570 | { |
| 2571 | return I40E_HLUT_ARRAY_SIZE; |
| 2572 | } |
| 2573 | |
| 2574 | static int i40e_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key, |
| 2575 | u8 *hfunc) |
| 2576 | { |
| 2577 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 2578 | struct i40e_vsi *vsi = np->vsi; |
| 2579 | struct i40e_pf *pf = vsi->back; |
| 2580 | struct i40e_hw *hw = &pf->hw; |
| 2581 | u32 reg_val; |
| 2582 | int i, j; |
| 2583 | |
| 2584 | if (hfunc) |
| 2585 | *hfunc = ETH_RSS_HASH_TOP; |
| 2586 | |
| 2587 | if (!indir) |
| 2588 | return 0; |
| 2589 | |
| 2590 | for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) { |
| 2591 | reg_val = rd32(hw, I40E_PFQF_HLUT(i)); |
| 2592 | indir[j++] = reg_val & 0xff; |
| 2593 | indir[j++] = (reg_val >> 8) & 0xff; |
| 2594 | indir[j++] = (reg_val >> 16) & 0xff; |
| 2595 | indir[j++] = (reg_val >> 24) & 0xff; |
| 2596 | } |
| 2597 | |
| 2598 | if (key) { |
| 2599 | for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) { |
| 2600 | reg_val = rd32(hw, I40E_PFQF_HKEY(i)); |
| 2601 | key[j++] = (u8)(reg_val & 0xff); |
| 2602 | key[j++] = (u8)((reg_val >> 8) & 0xff); |
| 2603 | key[j++] = (u8)((reg_val >> 16) & 0xff); |
| 2604 | key[j++] = (u8)((reg_val >> 24) & 0xff); |
| 2605 | } |
| 2606 | } |
| 2607 | return 0; |
| 2608 | } |
| 2609 | |
| 2610 | /** |
| 2611 | * i40e_set_rxfh - set the rx flow hash indirection table |
| 2612 | * @netdev: network interface device structure |
| 2613 | * @indir: indirection table |
| 2614 | * @key: hash key |
| 2615 | * |
Mitch Williams | cd494fb | 2015-07-10 19:36:04 -0400 | [diff] [blame] | 2616 | * Returns -EINVAL if the table specifies an invalid queue id, otherwise |
Mitch A Williams | b29e13b | 2015-03-05 04:14:40 +0000 | [diff] [blame] | 2617 | * returns 0 after programming the table. |
| 2618 | **/ |
| 2619 | static int i40e_set_rxfh(struct net_device *netdev, const u32 *indir, |
| 2620 | const u8 *key, const u8 hfunc) |
| 2621 | { |
| 2622 | struct i40e_netdev_priv *np = netdev_priv(netdev); |
| 2623 | struct i40e_vsi *vsi = np->vsi; |
| 2624 | struct i40e_pf *pf = vsi->back; |
| 2625 | struct i40e_hw *hw = &pf->hw; |
| 2626 | u32 reg_val; |
| 2627 | int i, j; |
| 2628 | |
| 2629 | if (hfunc != ETH_RSS_HASH_NO_CHANGE && hfunc != ETH_RSS_HASH_TOP) |
| 2630 | return -EOPNOTSUPP; |
| 2631 | |
| 2632 | if (!indir) |
| 2633 | return 0; |
| 2634 | |
| 2635 | for (i = 0, j = 0; i <= I40E_PFQF_HLUT_MAX_INDEX; i++) { |
| 2636 | reg_val = indir[j++]; |
| 2637 | reg_val |= indir[j++] << 8; |
| 2638 | reg_val |= indir[j++] << 16; |
| 2639 | reg_val |= indir[j++] << 24; |
| 2640 | wr32(hw, I40E_PFQF_HLUT(i), reg_val); |
| 2641 | } |
| 2642 | |
| 2643 | if (key) { |
| 2644 | for (i = 0, j = 0; i <= I40E_PFQF_HKEY_MAX_INDEX; i++) { |
| 2645 | reg_val = key[j++]; |
| 2646 | reg_val |= key[j++] << 8; |
| 2647 | reg_val |= key[j++] << 16; |
| 2648 | reg_val |= key[j++] << 24; |
| 2649 | wr32(hw, I40E_PFQF_HKEY(i), reg_val); |
| 2650 | } |
| 2651 | } |
| 2652 | return 0; |
| 2653 | } |
| 2654 | |
Greg Rose | 7e45ab4 | 2015-02-06 08:52:19 +0000 | [diff] [blame] | 2655 | /** |
| 2656 | * i40e_get_priv_flags - report device private flags |
| 2657 | * @dev: network interface device structure |
| 2658 | * |
| 2659 | * The get string set count and the string set should be matched for each |
| 2660 | * flag returned. Add new strings for each flag to the i40e_priv_flags_strings |
| 2661 | * array. |
| 2662 | * |
| 2663 | * Returns a u32 bitmap of flags. |
| 2664 | **/ |
Jesse Brandeburg | 5bbc330 | 2015-02-26 16:15:20 +0000 | [diff] [blame] | 2665 | static u32 i40e_get_priv_flags(struct net_device *dev) |
Greg Rose | 7e45ab4 | 2015-02-06 08:52:19 +0000 | [diff] [blame] | 2666 | { |
| 2667 | struct i40e_netdev_priv *np = netdev_priv(dev); |
| 2668 | struct i40e_vsi *vsi = np->vsi; |
| 2669 | struct i40e_pf *pf = vsi->back; |
| 2670 | u32 ret_flags = 0; |
| 2671 | |
| 2672 | ret_flags |= pf->hw.func_caps.npar_enable ? |
| 2673 | I40E_PRIV_FLAGS_NPAR_FLAG : 0; |
Shannon Nelson | 9ac7726 | 2015-08-27 11:42:40 -0400 | [diff] [blame] | 2674 | ret_flags |= pf->flags & I40E_FLAG_LINK_POLLING_ENABLED ? |
| 2675 | I40E_PRIV_FLAGS_LINKPOLL_FLAG : 0; |
Jesse Brandeburg | ef17178 | 2015-09-03 17:18:49 -0400 | [diff] [blame] | 2676 | ret_flags |= pf->flags & I40E_FLAG_FD_ATR_ENABLED ? |
| 2677 | I40E_PRIV_FLAGS_FD_ATR : 0; |
Greg Rose | 7e45ab4 | 2015-02-06 08:52:19 +0000 | [diff] [blame] | 2678 | |
| 2679 | return ret_flags; |
| 2680 | } |
| 2681 | |
Shannon Nelson | 9ac7726 | 2015-08-27 11:42:40 -0400 | [diff] [blame] | 2682 | /** |
| 2683 | * i40e_set_priv_flags - set private flags |
| 2684 | * @dev: network interface device structure |
| 2685 | * @flags: bit flags to be set |
| 2686 | **/ |
| 2687 | static int i40e_set_priv_flags(struct net_device *dev, u32 flags) |
| 2688 | { |
| 2689 | struct i40e_netdev_priv *np = netdev_priv(dev); |
| 2690 | struct i40e_vsi *vsi = np->vsi; |
| 2691 | struct i40e_pf *pf = vsi->back; |
| 2692 | |
| 2693 | if (flags & I40E_PRIV_FLAGS_LINKPOLL_FLAG) |
| 2694 | pf->flags |= I40E_FLAG_LINK_POLLING_ENABLED; |
| 2695 | else |
| 2696 | pf->flags &= ~I40E_FLAG_LINK_POLLING_ENABLED; |
| 2697 | |
Jesse Brandeburg | ef17178 | 2015-09-03 17:18:49 -0400 | [diff] [blame] | 2698 | /* allow the user to control the state of the Flow |
| 2699 | * Director ATR (Application Targeted Routing) feature |
| 2700 | * of the driver |
| 2701 | */ |
| 2702 | if (flags & I40E_PRIV_FLAGS_FD_ATR) { |
| 2703 | pf->flags |= I40E_FLAG_FD_ATR_ENABLED; |
| 2704 | } else { |
| 2705 | pf->flags &= ~I40E_FLAG_FD_ATR_ENABLED; |
| 2706 | pf->auto_disable_flags |= I40E_FLAG_FD_ATR_ENABLED; |
| 2707 | } |
| 2708 | |
Shannon Nelson | 9ac7726 | 2015-08-27 11:42:40 -0400 | [diff] [blame] | 2709 | return 0; |
| 2710 | } |
| 2711 | |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2712 | static const struct ethtool_ops i40e_ethtool_ops = { |
| 2713 | .get_settings = i40e_get_settings, |
Catherine Sullivan | bf9c714 | 2014-06-04 08:45:28 +0000 | [diff] [blame] | 2714 | .set_settings = i40e_set_settings, |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2715 | .get_drvinfo = i40e_get_drvinfo, |
| 2716 | .get_regs_len = i40e_get_regs_len, |
| 2717 | .get_regs = i40e_get_regs, |
| 2718 | .nway_reset = i40e_nway_reset, |
| 2719 | .get_link = ethtool_op_get_link, |
| 2720 | .get_wol = i40e_get_wol, |
Shannon Nelson | 8e2773a | 2013-11-28 06:39:22 +0000 | [diff] [blame] | 2721 | .set_wol = i40e_set_wol, |
Shannon Nelson | cd552cb | 2014-07-09 07:46:09 +0000 | [diff] [blame] | 2722 | .set_eeprom = i40e_set_eeprom, |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2723 | .get_eeprom_len = i40e_get_eeprom_len, |
| 2724 | .get_eeprom = i40e_get_eeprom, |
| 2725 | .get_ringparam = i40e_get_ringparam, |
| 2726 | .set_ringparam = i40e_set_ringparam, |
| 2727 | .get_pauseparam = i40e_get_pauseparam, |
Catherine Sullivan | 2becc35 | 2014-06-04 08:45:27 +0000 | [diff] [blame] | 2728 | .set_pauseparam = i40e_set_pauseparam, |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2729 | .get_msglevel = i40e_get_msglevel, |
| 2730 | .set_msglevel = i40e_set_msglevel, |
| 2731 | .get_rxnfc = i40e_get_rxnfc, |
| 2732 | .set_rxnfc = i40e_set_rxnfc, |
| 2733 | .self_test = i40e_diag_test, |
| 2734 | .get_strings = i40e_get_strings, |
| 2735 | .set_phys_id = i40e_set_phys_id, |
| 2736 | .get_sset_count = i40e_get_sset_count, |
| 2737 | .get_ethtool_stats = i40e_get_ethtool_stats, |
| 2738 | .get_coalesce = i40e_get_coalesce, |
| 2739 | .set_coalesce = i40e_set_coalesce, |
Mitch A Williams | b29e13b | 2015-03-05 04:14:40 +0000 | [diff] [blame] | 2740 | .get_rxfh_key_size = i40e_get_rxfh_key_size, |
| 2741 | .get_rxfh_indir_size = i40e_get_rxfh_indir_size, |
| 2742 | .get_rxfh = i40e_get_rxfh, |
| 2743 | .set_rxfh = i40e_set_rxfh, |
Anjali Singhai Jain | 4b7820c | 2013-11-26 11:59:30 +0000 | [diff] [blame] | 2744 | .get_channels = i40e_get_channels, |
| 2745 | .set_channels = i40e_set_channels, |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2746 | .get_ts_info = i40e_get_ts_info, |
Greg Rose | 7e45ab4 | 2015-02-06 08:52:19 +0000 | [diff] [blame] | 2747 | .get_priv_flags = i40e_get_priv_flags, |
Shannon Nelson | 9ac7726 | 2015-08-27 11:42:40 -0400 | [diff] [blame] | 2748 | .set_priv_flags = i40e_set_priv_flags, |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2749 | }; |
| 2750 | |
| 2751 | void i40e_set_ethtool_ops(struct net_device *netdev) |
| 2752 | { |
Wilfried Klaebe | 7ad24ea | 2014-05-11 00:12:32 +0000 | [diff] [blame] | 2753 | netdev->ethtool_ops = &i40e_ethtool_ops; |
Jesse Brandeburg | c7d05ca | 2013-09-11 08:39:56 +0000 | [diff] [blame] | 2754 | } |