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