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