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