Lines Matching +full:mac +full:- +full:wol
1 // SPDX-License-Identifier: GPL-2.0
117 ((((struct igc_adapter *)netdev_priv(netdev))->num_rx_queues * \
119 (((struct igc_adapter *)netdev_priv(netdev))->num_tx_queues * \
126 "legacy-rx",
135 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_drvinfo()
139 strscpy(drvinfo->driver, igc_driver_name, sizeof(drvinfo->driver)); in igc_ethtool_get_drvinfo()
142 hw->nvm.ops.read(hw, IGC_NVM_DEV_STARTER, 1, &nvm_version); in igc_ethtool_get_drvinfo()
147 scnprintf(adapter->fw_version, in igc_ethtool_get_drvinfo()
148 sizeof(adapter->fw_version), in igc_ethtool_get_drvinfo()
153 strscpy(drvinfo->fw_version, adapter->fw_version, in igc_ethtool_get_drvinfo()
154 sizeof(drvinfo->fw_version)); in igc_ethtool_get_drvinfo()
156 strscpy(drvinfo->bus_info, pci_name(adapter->pdev), in igc_ethtool_get_drvinfo()
157 sizeof(drvinfo->bus_info)); in igc_ethtool_get_drvinfo()
159 drvinfo->n_priv_flags = IGC_PRIV_FLAGS_STR_LEN; in igc_ethtool_get_drvinfo()
171 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_regs()
177 regs->version = (2u << 24) | (hw->revision_id << 16) | hw->device_id; in igc_ethtool_get_regs()
229 /* MAC */ in igc_ethtool_get_regs()
232 regs_buff[30] = adapter->stats.crcerrs; in igc_ethtool_get_regs()
233 regs_buff[31] = adapter->stats.algnerrc; in igc_ethtool_get_regs()
234 regs_buff[32] = adapter->stats.symerrs; in igc_ethtool_get_regs()
235 regs_buff[33] = adapter->stats.rxerrc; in igc_ethtool_get_regs()
236 regs_buff[34] = adapter->stats.mpc; in igc_ethtool_get_regs()
237 regs_buff[35] = adapter->stats.scc; in igc_ethtool_get_regs()
238 regs_buff[36] = adapter->stats.ecol; in igc_ethtool_get_regs()
239 regs_buff[37] = adapter->stats.mcc; in igc_ethtool_get_regs()
240 regs_buff[38] = adapter->stats.latecol; in igc_ethtool_get_regs()
241 regs_buff[39] = adapter->stats.colc; in igc_ethtool_get_regs()
242 regs_buff[40] = adapter->stats.dc; in igc_ethtool_get_regs()
243 regs_buff[41] = adapter->stats.tncrs; in igc_ethtool_get_regs()
244 regs_buff[42] = adapter->stats.sec; in igc_ethtool_get_regs()
245 regs_buff[43] = adapter->stats.htdpmc; in igc_ethtool_get_regs()
246 regs_buff[44] = adapter->stats.rlec; in igc_ethtool_get_regs()
247 regs_buff[45] = adapter->stats.xonrxc; in igc_ethtool_get_regs()
248 regs_buff[46] = adapter->stats.xontxc; in igc_ethtool_get_regs()
249 regs_buff[47] = adapter->stats.xoffrxc; in igc_ethtool_get_regs()
250 regs_buff[48] = adapter->stats.xofftxc; in igc_ethtool_get_regs()
251 regs_buff[49] = adapter->stats.fcruc; in igc_ethtool_get_regs()
252 regs_buff[50] = adapter->stats.prc64; in igc_ethtool_get_regs()
253 regs_buff[51] = adapter->stats.prc127; in igc_ethtool_get_regs()
254 regs_buff[52] = adapter->stats.prc255; in igc_ethtool_get_regs()
255 regs_buff[53] = adapter->stats.prc511; in igc_ethtool_get_regs()
256 regs_buff[54] = adapter->stats.prc1023; in igc_ethtool_get_regs()
257 regs_buff[55] = adapter->stats.prc1522; in igc_ethtool_get_regs()
258 regs_buff[56] = adapter->stats.gprc; in igc_ethtool_get_regs()
259 regs_buff[57] = adapter->stats.bprc; in igc_ethtool_get_regs()
260 regs_buff[58] = adapter->stats.mprc; in igc_ethtool_get_regs()
261 regs_buff[59] = adapter->stats.gptc; in igc_ethtool_get_regs()
262 regs_buff[60] = adapter->stats.gorc; in igc_ethtool_get_regs()
263 regs_buff[61] = adapter->stats.gotc; in igc_ethtool_get_regs()
264 regs_buff[62] = adapter->stats.rnbc; in igc_ethtool_get_regs()
265 regs_buff[63] = adapter->stats.ruc; in igc_ethtool_get_regs()
266 regs_buff[64] = adapter->stats.rfc; in igc_ethtool_get_regs()
267 regs_buff[65] = adapter->stats.roc; in igc_ethtool_get_regs()
268 regs_buff[66] = adapter->stats.rjc; in igc_ethtool_get_regs()
269 regs_buff[67] = adapter->stats.mgprc; in igc_ethtool_get_regs()
270 regs_buff[68] = adapter->stats.mgpdc; in igc_ethtool_get_regs()
271 regs_buff[69] = adapter->stats.mgptc; in igc_ethtool_get_regs()
272 regs_buff[70] = adapter->stats.tor; in igc_ethtool_get_regs()
273 regs_buff[71] = adapter->stats.tot; in igc_ethtool_get_regs()
274 regs_buff[72] = adapter->stats.tpr; in igc_ethtool_get_regs()
275 regs_buff[73] = adapter->stats.tpt; in igc_ethtool_get_regs()
276 regs_buff[74] = adapter->stats.ptc64; in igc_ethtool_get_regs()
277 regs_buff[75] = adapter->stats.ptc127; in igc_ethtool_get_regs()
278 regs_buff[76] = adapter->stats.ptc255; in igc_ethtool_get_regs()
279 regs_buff[77] = adapter->stats.ptc511; in igc_ethtool_get_regs()
280 regs_buff[78] = adapter->stats.ptc1023; in igc_ethtool_get_regs()
281 regs_buff[79] = adapter->stats.ptc1522; in igc_ethtool_get_regs()
282 regs_buff[80] = adapter->stats.mptc; in igc_ethtool_get_regs()
283 regs_buff[81] = adapter->stats.bptc; in igc_ethtool_get_regs()
284 regs_buff[82] = adapter->stats.tsctc; in igc_ethtool_get_regs()
285 regs_buff[83] = adapter->stats.iac; in igc_ethtool_get_regs()
286 regs_buff[84] = adapter->stats.rpthc; in igc_ethtool_get_regs()
287 regs_buff[85] = adapter->stats.hgptc; in igc_ethtool_get_regs()
288 regs_buff[86] = adapter->stats.hgorc; in igc_ethtool_get_regs()
289 regs_buff[87] = adapter->stats.hgotc; in igc_ethtool_get_regs()
290 regs_buff[88] = adapter->stats.lenerrs; in igc_ethtool_get_regs()
291 regs_buff[89] = adapter->stats.scvpc; in igc_ethtool_get_regs()
292 regs_buff[90] = adapter->stats.hrmpc; in igc_ethtool_get_regs()
345 regs_buff[213] = adapter->stats.tlpic; in igc_ethtool_get_regs()
346 regs_buff[214] = adapter->stats.rlpic; in igc_ethtool_get_regs()
350 struct ethtool_wolinfo *wol) in igc_ethtool_get_wol() argument
354 wol->wolopts = 0; in igc_ethtool_get_wol()
356 if (!(adapter->flags & IGC_FLAG_WOL_SUPPORTED)) in igc_ethtool_get_wol()
359 wol->supported = WAKE_UCAST | WAKE_MCAST | in igc_ethtool_get_wol()
364 switch (adapter->hw.device_id) { in igc_ethtool_get_wol()
369 if (adapter->wol & IGC_WUFC_EX) in igc_ethtool_get_wol()
370 wol->wolopts |= WAKE_UCAST; in igc_ethtool_get_wol()
371 if (adapter->wol & IGC_WUFC_MC) in igc_ethtool_get_wol()
372 wol->wolopts |= WAKE_MCAST; in igc_ethtool_get_wol()
373 if (adapter->wol & IGC_WUFC_BC) in igc_ethtool_get_wol()
374 wol->wolopts |= WAKE_BCAST; in igc_ethtool_get_wol()
375 if (adapter->wol & IGC_WUFC_MAG) in igc_ethtool_get_wol()
376 wol->wolopts |= WAKE_MAGIC; in igc_ethtool_get_wol()
377 if (adapter->wol & IGC_WUFC_LNKC) in igc_ethtool_get_wol()
378 wol->wolopts |= WAKE_PHY; in igc_ethtool_get_wol()
382 struct ethtool_wolinfo *wol) in igc_ethtool_set_wol() argument
386 if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE | WAKE_FILTER)) in igc_ethtool_set_wol()
387 return -EOPNOTSUPP; in igc_ethtool_set_wol()
389 if (!(adapter->flags & IGC_FLAG_WOL_SUPPORTED)) in igc_ethtool_set_wol()
390 return wol->wolopts ? -EOPNOTSUPP : 0; in igc_ethtool_set_wol()
393 adapter->wol = 0; in igc_ethtool_set_wol()
395 if (wol->wolopts & WAKE_UCAST) in igc_ethtool_set_wol()
396 adapter->wol |= IGC_WUFC_EX; in igc_ethtool_set_wol()
397 if (wol->wolopts & WAKE_MCAST) in igc_ethtool_set_wol()
398 adapter->wol |= IGC_WUFC_MC; in igc_ethtool_set_wol()
399 if (wol->wolopts & WAKE_BCAST) in igc_ethtool_set_wol()
400 adapter->wol |= IGC_WUFC_BC; in igc_ethtool_set_wol()
401 if (wol->wolopts & WAKE_MAGIC) in igc_ethtool_set_wol()
402 adapter->wol |= IGC_WUFC_MAG; in igc_ethtool_set_wol()
403 if (wol->wolopts & WAKE_PHY) in igc_ethtool_set_wol()
404 adapter->wol |= IGC_WUFC_LNKC; in igc_ethtool_set_wol()
405 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); in igc_ethtool_set_wol()
414 return adapter->msg_enable; in igc_ethtool_get_msglevel()
421 adapter->msg_enable = data; in igc_ethtool_set_msglevel()
436 struct igc_mac_info *mac = &adapter->hw.mac; in igc_ethtool_get_link() local
445 mac->get_link_status = 1; in igc_ethtool_get_link()
454 return adapter->hw.nvm.word_size * 2; in igc_ethtool_get_eeprom_len()
461 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_eeprom()
467 if (eeprom->len == 0) in igc_ethtool_get_eeprom()
468 return -EINVAL; in igc_ethtool_get_eeprom()
470 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in igc_ethtool_get_eeprom()
472 first_word = eeprom->offset >> 1; in igc_ethtool_get_eeprom()
473 last_word = (eeprom->offset + eeprom->len - 1) >> 1; in igc_ethtool_get_eeprom()
475 eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), in igc_ethtool_get_eeprom()
478 return -ENOMEM; in igc_ethtool_get_eeprom()
480 if (hw->nvm.type == igc_nvm_eeprom_spi) { in igc_ethtool_get_eeprom()
481 ret_val = hw->nvm.ops.read(hw, first_word, in igc_ethtool_get_eeprom()
482 last_word - first_word + 1, in igc_ethtool_get_eeprom()
485 for (i = 0; i < last_word - first_word + 1; i++) { in igc_ethtool_get_eeprom()
486 ret_val = hw->nvm.ops.read(hw, first_word + i, 1, in igc_ethtool_get_eeprom()
493 /* Device's eeprom is always little-endian, word addressable */ in igc_ethtool_get_eeprom()
494 for (i = 0; i < last_word - first_word + 1; i++) in igc_ethtool_get_eeprom()
497 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), in igc_ethtool_get_eeprom()
498 eeprom->len); in igc_ethtool_get_eeprom()
508 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_eeprom()
514 if (eeprom->len == 0) in igc_ethtool_set_eeprom()
515 return -EOPNOTSUPP; in igc_ethtool_set_eeprom()
517 if (hw->mac.type >= igc_i225 && in igc_ethtool_set_eeprom()
519 return -EOPNOTSUPP; in igc_ethtool_set_eeprom()
522 if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16))) in igc_ethtool_set_eeprom()
523 return -EFAULT; in igc_ethtool_set_eeprom()
525 max_len = hw->nvm.word_size * 2; in igc_ethtool_set_eeprom()
527 first_word = eeprom->offset >> 1; in igc_ethtool_set_eeprom()
528 last_word = (eeprom->offset + eeprom->len - 1) >> 1; in igc_ethtool_set_eeprom()
531 return -ENOMEM; in igc_ethtool_set_eeprom()
535 if (eeprom->offset & 1) { in igc_ethtool_set_eeprom()
539 ret_val = hw->nvm.ops.read(hw, first_word, 1, in igc_ethtool_set_eeprom()
543 if (((eeprom->offset + eeprom->len) & 1) && ret_val == 0) { in igc_ethtool_set_eeprom()
547 ret_val = hw->nvm.ops.read(hw, last_word, 1, in igc_ethtool_set_eeprom()
548 &eeprom_buff[last_word - first_word]); in igc_ethtool_set_eeprom()
551 /* Device's eeprom is always little-endian, word addressable */ in igc_ethtool_set_eeprom()
552 for (i = 0; i < last_word - first_word + 1; i++) in igc_ethtool_set_eeprom()
555 memcpy(ptr, bytes, eeprom->len); in igc_ethtool_set_eeprom()
557 for (i = 0; i < last_word - first_word + 1; i++) in igc_ethtool_set_eeprom()
560 ret_val = hw->nvm.ops.write(hw, first_word, in igc_ethtool_set_eeprom()
561 last_word - first_word + 1, eeprom_buff); in igc_ethtool_set_eeprom()
565 hw->nvm.ops.update(hw); in igc_ethtool_set_eeprom()
579 ring->rx_max_pending = IGC_MAX_RXD; in igc_ethtool_get_ringparam()
580 ring->tx_max_pending = IGC_MAX_TXD; in igc_ethtool_get_ringparam()
581 ring->rx_pending = adapter->rx_ring_count; in igc_ethtool_get_ringparam()
582 ring->tx_pending = adapter->tx_ring_count; in igc_ethtool_get_ringparam()
596 if (ring->rx_mini_pending || ring->rx_jumbo_pending) in igc_ethtool_set_ringparam()
597 return -EINVAL; in igc_ethtool_set_ringparam()
599 new_rx_count = min_t(u32, ring->rx_pending, IGC_MAX_RXD); in igc_ethtool_set_ringparam()
603 new_tx_count = min_t(u32, ring->tx_pending, IGC_MAX_TXD); in igc_ethtool_set_ringparam()
607 if (new_tx_count == adapter->tx_ring_count && in igc_ethtool_set_ringparam()
608 new_rx_count == adapter->rx_ring_count) { in igc_ethtool_set_ringparam()
613 while (test_and_set_bit(__IGC_RESETTING, &adapter->state)) in igc_ethtool_set_ringparam()
616 if (!netif_running(adapter->netdev)) { in igc_ethtool_set_ringparam()
617 for (i = 0; i < adapter->num_tx_queues; i++) in igc_ethtool_set_ringparam()
618 adapter->tx_ring[i]->count = new_tx_count; in igc_ethtool_set_ringparam()
619 for (i = 0; i < adapter->num_rx_queues; i++) in igc_ethtool_set_ringparam()
620 adapter->rx_ring[i]->count = new_rx_count; in igc_ethtool_set_ringparam()
621 adapter->tx_ring_count = new_tx_count; in igc_ethtool_set_ringparam()
622 adapter->rx_ring_count = new_rx_count; in igc_ethtool_set_ringparam()
626 if (adapter->num_tx_queues > adapter->num_rx_queues) in igc_ethtool_set_ringparam()
628 adapter->num_tx_queues)); in igc_ethtool_set_ringparam()
631 adapter->num_rx_queues)); in igc_ethtool_set_ringparam()
634 err = -ENOMEM; in igc_ethtool_set_ringparam()
641 * because the ISRs in MSI-X mode get passed pointers in igc_ethtool_set_ringparam()
644 if (new_tx_count != adapter->tx_ring_count) { in igc_ethtool_set_ringparam()
645 for (i = 0; i < adapter->num_tx_queues; i++) { in igc_ethtool_set_ringparam()
646 memcpy(&temp_ring[i], adapter->tx_ring[i], in igc_ethtool_set_ringparam()
653 i--; in igc_ethtool_set_ringparam()
660 for (i = 0; i < adapter->num_tx_queues; i++) { in igc_ethtool_set_ringparam()
661 igc_free_tx_resources(adapter->tx_ring[i]); in igc_ethtool_set_ringparam()
663 memcpy(adapter->tx_ring[i], &temp_ring[i], in igc_ethtool_set_ringparam()
667 adapter->tx_ring_count = new_tx_count; in igc_ethtool_set_ringparam()
670 if (new_rx_count != adapter->rx_ring_count) { in igc_ethtool_set_ringparam()
671 for (i = 0; i < adapter->num_rx_queues; i++) { in igc_ethtool_set_ringparam()
672 memcpy(&temp_ring[i], adapter->rx_ring[i], in igc_ethtool_set_ringparam()
679 i--; in igc_ethtool_set_ringparam()
686 for (i = 0; i < adapter->num_rx_queues; i++) { in igc_ethtool_set_ringparam()
687 igc_free_rx_resources(adapter->rx_ring[i]); in igc_ethtool_set_ringparam()
689 memcpy(adapter->rx_ring[i], &temp_ring[i], in igc_ethtool_set_ringparam()
693 adapter->rx_ring_count = new_rx_count; in igc_ethtool_set_ringparam()
699 clear_bit(__IGC_RESETTING, &adapter->state); in igc_ethtool_set_ringparam()
707 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_pauseparam()
709 pause->autoneg = in igc_ethtool_get_pauseparam()
710 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); in igc_ethtool_get_pauseparam()
712 if (hw->fc.current_mode == igc_fc_rx_pause) { in igc_ethtool_get_pauseparam()
713 pause->rx_pause = 1; in igc_ethtool_get_pauseparam()
714 } else if (hw->fc.current_mode == igc_fc_tx_pause) { in igc_ethtool_get_pauseparam()
715 pause->tx_pause = 1; in igc_ethtool_get_pauseparam()
716 } else if (hw->fc.current_mode == igc_fc_full) { in igc_ethtool_get_pauseparam()
717 pause->rx_pause = 1; in igc_ethtool_get_pauseparam()
718 pause->tx_pause = 1; in igc_ethtool_get_pauseparam()
726 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_pauseparam()
729 adapter->fc_autoneg = pause->autoneg; in igc_ethtool_set_pauseparam()
731 while (test_and_set_bit(__IGC_RESETTING, &adapter->state)) in igc_ethtool_set_pauseparam()
734 if (adapter->fc_autoneg == AUTONEG_ENABLE) { in igc_ethtool_set_pauseparam()
735 hw->fc.requested_mode = igc_fc_default; in igc_ethtool_set_pauseparam()
736 if (netif_running(adapter->netdev)) { in igc_ethtool_set_pauseparam()
743 if (pause->rx_pause && pause->tx_pause) in igc_ethtool_set_pauseparam()
744 hw->fc.requested_mode = igc_fc_full; in igc_ethtool_set_pauseparam()
745 else if (pause->rx_pause && !pause->tx_pause) in igc_ethtool_set_pauseparam()
746 hw->fc.requested_mode = igc_fc_rx_pause; in igc_ethtool_set_pauseparam()
747 else if (!pause->rx_pause && pause->tx_pause) in igc_ethtool_set_pauseparam()
748 hw->fc.requested_mode = igc_fc_tx_pause; in igc_ethtool_set_pauseparam()
749 else if (!pause->rx_pause && !pause->tx_pause) in igc_ethtool_set_pauseparam()
750 hw->fc.requested_mode = igc_fc_none; in igc_ethtool_set_pauseparam()
752 hw->fc.current_mode = hw->fc.requested_mode; in igc_ethtool_set_pauseparam()
754 retval = ((hw->phy.media_type == igc_media_type_copper) ? in igc_ethtool_set_pauseparam()
758 clear_bit(__IGC_RESETTING, &adapter->state); in igc_ethtool_set_pauseparam()
779 for (i = 0; i < adapter->num_tx_queues; i++) { in igc_ethtool_get_strings()
784 for (i = 0; i < adapter->num_rx_queues; i++) { in igc_ethtool_get_strings()
791 /* BUG_ON(p - data != IGC_STATS_LEN * ETH_GSTRING_LEN); */ in igc_ethtool_get_strings()
810 return -ENOTSUPP; in igc_ethtool_get_sset_count()
818 struct rtnl_link_stats64 *net_stats = &adapter->stats64; in igc_ethtool_get_stats()
824 spin_lock(&adapter->stats64_lock); in igc_ethtool_get_stats()
837 for (j = 0; j < adapter->num_tx_queues; j++) { in igc_ethtool_get_stats()
840 ring = adapter->tx_ring[j]; in igc_ethtool_get_stats()
842 start = u64_stats_fetch_begin(&ring->tx_syncp); in igc_ethtool_get_stats()
843 data[i] = ring->tx_stats.packets; in igc_ethtool_get_stats()
844 data[i + 1] = ring->tx_stats.bytes; in igc_ethtool_get_stats()
845 data[i + 2] = ring->tx_stats.restart_queue; in igc_ethtool_get_stats()
846 } while (u64_stats_fetch_retry(&ring->tx_syncp, start)); in igc_ethtool_get_stats()
848 start = u64_stats_fetch_begin(&ring->tx_syncp2); in igc_ethtool_get_stats()
849 restart2 = ring->tx_stats.restart_queue2; in igc_ethtool_get_stats()
850 } while (u64_stats_fetch_retry(&ring->tx_syncp2, start)); in igc_ethtool_get_stats()
855 for (j = 0; j < adapter->num_rx_queues; j++) { in igc_ethtool_get_stats()
856 ring = adapter->rx_ring[j]; in igc_ethtool_get_stats()
858 start = u64_stats_fetch_begin(&ring->rx_syncp); in igc_ethtool_get_stats()
859 data[i] = ring->rx_stats.packets; in igc_ethtool_get_stats()
860 data[i + 1] = ring->rx_stats.bytes; in igc_ethtool_get_stats()
861 data[i + 2] = ring->rx_stats.drops; in igc_ethtool_get_stats()
862 data[i + 3] = ring->rx_stats.csum_err; in igc_ethtool_get_stats()
863 data[i + 4] = ring->rx_stats.alloc_failed; in igc_ethtool_get_stats()
864 } while (u64_stats_fetch_retry(&ring->rx_syncp, start)); in igc_ethtool_get_stats()
867 spin_unlock(&adapter->stats64_lock); in igc_ethtool_get_stats()
872 return (adapter->rx_itr_setting <= 3) ? in igc_ethtool_get_previous_rx_coalesce()
873 adapter->rx_itr_setting : adapter->rx_itr_setting >> 2; in igc_ethtool_get_previous_rx_coalesce()
878 return (adapter->tx_itr_setting <= 3) ? in igc_ethtool_get_previous_tx_coalesce()
879 adapter->tx_itr_setting : adapter->tx_itr_setting >> 2; in igc_ethtool_get_previous_tx_coalesce()
889 ec->rx_coalesce_usecs = igc_ethtool_get_previous_rx_coalesce(adapter); in igc_ethtool_get_coalesce()
890 ec->tx_coalesce_usecs = igc_ethtool_get_previous_tx_coalesce(adapter); in igc_ethtool_get_coalesce()
903 if (ec->rx_coalesce_usecs > IGC_MAX_ITR_USECS || in igc_ethtool_set_coalesce()
904 (ec->rx_coalesce_usecs > 3 && in igc_ethtool_set_coalesce()
905 ec->rx_coalesce_usecs < IGC_MIN_ITR_USECS) || in igc_ethtool_set_coalesce()
906 ec->rx_coalesce_usecs == 2) in igc_ethtool_set_coalesce()
907 return -EINVAL; in igc_ethtool_set_coalesce()
909 if (ec->tx_coalesce_usecs > IGC_MAX_ITR_USECS || in igc_ethtool_set_coalesce()
910 (ec->tx_coalesce_usecs > 3 && in igc_ethtool_set_coalesce()
911 ec->tx_coalesce_usecs < IGC_MIN_ITR_USECS) || in igc_ethtool_set_coalesce()
912 ec->tx_coalesce_usecs == 2) in igc_ethtool_set_coalesce()
913 return -EINVAL; in igc_ethtool_set_coalesce()
915 if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) && in igc_ethtool_set_coalesce()
916 ec->tx_coalesce_usecs != igc_ethtool_get_previous_tx_coalesce(adapter)) { in igc_ethtool_set_coalesce()
918 "Queue Pair mode enabled, both Rx and Tx coalescing controlled by rx-usecs"); in igc_ethtool_set_coalesce()
919 return -EINVAL; in igc_ethtool_set_coalesce()
923 if (ec->rx_coalesce_usecs == 0) { in igc_ethtool_set_coalesce()
924 if (adapter->flags & IGC_FLAG_DMAC) in igc_ethtool_set_coalesce()
925 adapter->flags &= ~IGC_FLAG_DMAC; in igc_ethtool_set_coalesce()
929 if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) in igc_ethtool_set_coalesce()
930 adapter->rx_itr_setting = ec->rx_coalesce_usecs; in igc_ethtool_set_coalesce()
932 adapter->rx_itr_setting = ec->rx_coalesce_usecs << 2; in igc_ethtool_set_coalesce()
935 if (adapter->flags & IGC_FLAG_QUEUE_PAIRS) in igc_ethtool_set_coalesce()
936 adapter->tx_itr_setting = adapter->rx_itr_setting; in igc_ethtool_set_coalesce()
937 else if (ec->tx_coalesce_usecs && ec->tx_coalesce_usecs <= 3) in igc_ethtool_set_coalesce()
938 adapter->tx_itr_setting = ec->tx_coalesce_usecs; in igc_ethtool_set_coalesce()
940 adapter->tx_itr_setting = ec->tx_coalesce_usecs << 2; in igc_ethtool_set_coalesce()
942 for (i = 0; i < adapter->num_q_vectors; i++) { in igc_ethtool_set_coalesce()
943 struct igc_q_vector *q_vector = adapter->q_vector[i]; in igc_ethtool_set_coalesce()
945 q_vector->tx.work_limit = adapter->tx_work_limit; in igc_ethtool_set_coalesce()
946 if (q_vector->rx.ring) in igc_ethtool_set_coalesce()
947 q_vector->itr_val = adapter->rx_itr_setting; in igc_ethtool_set_coalesce()
949 q_vector->itr_val = adapter->tx_itr_setting; in igc_ethtool_set_coalesce()
950 if (q_vector->itr_val && q_vector->itr_val <= 3) in igc_ethtool_set_coalesce()
951 q_vector->itr_val = IGC_START_ITR; in igc_ethtool_set_coalesce()
952 q_vector->set_itr = 1; in igc_ethtool_set_coalesce()
963 struct ethtool_rx_flow_spec *fsp = &cmd->fs; in igc_ethtool_get_nfc_rule()
966 cmd->data = IGC_MAX_RXNFC_RULES; in igc_ethtool_get_nfc_rule()
968 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rule()
970 rule = igc_get_nfc_rule(adapter, fsp->location); in igc_ethtool_get_nfc_rule()
974 fsp->flow_type = ETHER_FLOW; in igc_ethtool_get_nfc_rule()
975 fsp->ring_cookie = rule->action; in igc_ethtool_get_nfc_rule()
977 if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { in igc_ethtool_get_nfc_rule()
978 fsp->h_u.ether_spec.h_proto = htons(rule->filter.etype); in igc_ethtool_get_nfc_rule()
979 fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK; in igc_ethtool_get_nfc_rule()
982 if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) { in igc_ethtool_get_nfc_rule()
983 fsp->flow_type |= FLOW_EXT; in igc_ethtool_get_nfc_rule()
984 fsp->h_ext.vlan_etype = htons(rule->filter.vlan_etype); in igc_ethtool_get_nfc_rule()
985 fsp->m_ext.vlan_etype = ETHER_TYPE_FULL_MASK; in igc_ethtool_get_nfc_rule()
988 if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { in igc_ethtool_get_nfc_rule()
989 fsp->flow_type |= FLOW_EXT; in igc_ethtool_get_nfc_rule()
990 fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci); in igc_ethtool_get_nfc_rule()
991 fsp->m_ext.vlan_tci = htons(rule->filter.vlan_tci_mask); in igc_ethtool_get_nfc_rule()
994 if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { in igc_ethtool_get_nfc_rule()
995 ether_addr_copy(fsp->h_u.ether_spec.h_dest, in igc_ethtool_get_nfc_rule()
996 rule->filter.dst_addr); in igc_ethtool_get_nfc_rule()
997 eth_broadcast_addr(fsp->m_u.ether_spec.h_dest); in igc_ethtool_get_nfc_rule()
1000 if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { in igc_ethtool_get_nfc_rule()
1001 ether_addr_copy(fsp->h_u.ether_spec.h_source, in igc_ethtool_get_nfc_rule()
1002 rule->filter.src_addr); in igc_ethtool_get_nfc_rule()
1003 eth_broadcast_addr(fsp->m_u.ether_spec.h_source); in igc_ethtool_get_nfc_rule()
1006 if (rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) { in igc_ethtool_get_nfc_rule()
1007 fsp->flow_type |= FLOW_EXT; in igc_ethtool_get_nfc_rule()
1008 memcpy(fsp->h_ext.data, rule->filter.user_data, sizeof(fsp->h_ext.data)); in igc_ethtool_get_nfc_rule()
1009 memcpy(fsp->m_ext.data, rule->filter.user_mask, sizeof(fsp->m_ext.data)); in igc_ethtool_get_nfc_rule()
1012 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rule()
1016 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rule()
1017 return -EINVAL; in igc_ethtool_get_nfc_rule()
1027 cmd->data = IGC_MAX_RXNFC_RULES; in igc_ethtool_get_nfc_rules()
1029 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rules()
1031 list_for_each_entry(rule, &adapter->nfc_rule_list, list) { in igc_ethtool_get_nfc_rules()
1032 if (cnt == cmd->rule_cnt) { in igc_ethtool_get_nfc_rules()
1033 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rules()
1034 return -EMSGSIZE; in igc_ethtool_get_nfc_rules()
1036 rule_locs[cnt] = rule->location; in igc_ethtool_get_nfc_rules()
1040 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rules()
1042 cmd->rule_cnt = cnt; in igc_ethtool_get_nfc_rules()
1050 cmd->data = 0; in igc_ethtool_get_rss_hash_opts()
1053 switch (cmd->flow_type) { in igc_ethtool_get_rss_hash_opts()
1055 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rss_hash_opts()
1058 if (adapter->flags & IGC_FLAG_RSS_FIELD_IPV4_UDP) in igc_ethtool_get_rss_hash_opts()
1059 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rss_hash_opts()
1066 cmd->data |= RXH_IP_SRC | RXH_IP_DST; in igc_ethtool_get_rss_hash_opts()
1069 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rss_hash_opts()
1072 if (adapter->flags & IGC_FLAG_RSS_FIELD_IPV6_UDP) in igc_ethtool_get_rss_hash_opts()
1073 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rss_hash_opts()
1080 cmd->data |= RXH_IP_SRC | RXH_IP_DST; in igc_ethtool_get_rss_hash_opts()
1083 return -EINVAL; in igc_ethtool_get_rss_hash_opts()
1094 switch (cmd->cmd) { in igc_ethtool_get_rxnfc()
1096 cmd->data = adapter->num_rx_queues; in igc_ethtool_get_rxnfc()
1099 cmd->rule_cnt = adapter->nfc_rule_count; in igc_ethtool_get_rxnfc()
1108 return -EOPNOTSUPP; in igc_ethtool_get_rxnfc()
1117 u32 flags = adapter->flags; in igc_ethtool_set_rss_hash_opt()
1122 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | in igc_ethtool_set_rss_hash_opt()
1124 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1126 switch (nfc->flow_type) { in igc_ethtool_set_rss_hash_opt()
1129 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rss_hash_opt()
1130 !(nfc->data & RXH_IP_DST) || in igc_ethtool_set_rss_hash_opt()
1131 !(nfc->data & RXH_L4_B_0_1) || in igc_ethtool_set_rss_hash_opt()
1132 !(nfc->data & RXH_L4_B_2_3)) in igc_ethtool_set_rss_hash_opt()
1133 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1136 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rss_hash_opt()
1137 !(nfc->data & RXH_IP_DST)) in igc_ethtool_set_rss_hash_opt()
1138 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1139 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { in igc_ethtool_set_rss_hash_opt()
1147 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1151 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rss_hash_opt()
1152 !(nfc->data & RXH_IP_DST)) in igc_ethtool_set_rss_hash_opt()
1153 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1154 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { in igc_ethtool_set_rss_hash_opt()
1162 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1173 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rss_hash_opt()
1174 !(nfc->data & RXH_IP_DST) || in igc_ethtool_set_rss_hash_opt()
1175 (nfc->data & RXH_L4_B_0_1) || in igc_ethtool_set_rss_hash_opt()
1176 (nfc->data & RXH_L4_B_2_3)) in igc_ethtool_set_rss_hash_opt()
1177 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1180 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1184 if (flags != adapter->flags) { in igc_ethtool_set_rss_hash_opt()
1185 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_rss_hash_opt()
1189 !(adapter->flags & UDP_RSS_FLAGS)) in igc_ethtool_set_rss_hash_opt()
1190 netdev_err(adapter->netdev, in igc_ethtool_set_rss_hash_opt()
1193 adapter->flags = flags; in igc_ethtool_set_rss_hash_opt()
1219 INIT_LIST_HEAD(&rule->list); in igc_ethtool_init_nfc_rule()
1221 rule->action = fsp->ring_cookie; in igc_ethtool_init_nfc_rule()
1222 rule->location = fsp->location; in igc_ethtool_init_nfc_rule()
1224 if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) { in igc_ethtool_init_nfc_rule()
1225 rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci); in igc_ethtool_init_nfc_rule()
1226 rule->filter.vlan_tci_mask = ntohs(fsp->m_ext.vlan_tci); in igc_ethtool_init_nfc_rule()
1227 rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI; in igc_ethtool_init_nfc_rule()
1230 if (fsp->m_u.ether_spec.h_proto == ETHER_TYPE_FULL_MASK) { in igc_ethtool_init_nfc_rule()
1231 rule->filter.etype = ntohs(fsp->h_u.ether_spec.h_proto); in igc_ethtool_init_nfc_rule()
1232 rule->filter.match_flags = IGC_FILTER_FLAG_ETHER_TYPE; in igc_ethtool_init_nfc_rule()
1238 if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_source)) { in igc_ethtool_init_nfc_rule()
1239 rule->filter.match_flags |= IGC_FILTER_FLAG_SRC_MAC_ADDR; in igc_ethtool_init_nfc_rule()
1240 ether_addr_copy(rule->filter.src_addr, in igc_ethtool_init_nfc_rule()
1241 fsp->h_u.ether_spec.h_source); in igc_ethtool_init_nfc_rule()
1244 if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_dest)) { in igc_ethtool_init_nfc_rule()
1245 rule->filter.match_flags |= IGC_FILTER_FLAG_DST_MAC_ADDR; in igc_ethtool_init_nfc_rule()
1246 ether_addr_copy(rule->filter.dst_addr, in igc_ethtool_init_nfc_rule()
1247 fsp->h_u.ether_spec.h_dest); in igc_ethtool_init_nfc_rule()
1251 if ((fsp->flow_type & FLOW_EXT) && fsp->h_ext.vlan_etype) { in igc_ethtool_init_nfc_rule()
1252 rule->filter.vlan_etype = ntohs(fsp->h_ext.vlan_etype); in igc_ethtool_init_nfc_rule()
1253 rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_ETYPE; in igc_ethtool_init_nfc_rule()
1257 if ((fsp->flow_type & FLOW_EXT) && in igc_ethtool_init_nfc_rule()
1258 (fsp->h_ext.data[0] || fsp->h_ext.data[1])) { in igc_ethtool_init_nfc_rule()
1259 rule->filter.match_flags |= IGC_FILTER_FLAG_USER_DATA; in igc_ethtool_init_nfc_rule()
1260 memcpy(rule->filter.user_data, fsp->h_ext.data, sizeof(fsp->h_ext.data)); in igc_ethtool_init_nfc_rule()
1261 memcpy(rule->filter.user_mask, fsp->m_ext.data, sizeof(fsp->m_ext.data)); in igc_ethtool_init_nfc_rule()
1271 * Otherwise, use the simple MAC, VLAN PRIO or EtherType filters. in igc_ethtool_init_nfc_rule()
1273 if ((rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) || in igc_ethtool_init_nfc_rule()
1274 (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) || in igc_ethtool_init_nfc_rule()
1275 ((rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) && in igc_ethtool_init_nfc_rule()
1276 rule->filter.vlan_tci_mask == ntohs(VLAN_TCI_FULL_MASK)) || in igc_ethtool_init_nfc_rule()
1277 (rule->filter.match_flags & (rule->filter.match_flags - 1))) in igc_ethtool_init_nfc_rule()
1278 rule->flex = true; in igc_ethtool_init_nfc_rule()
1280 rule->flex = false; in igc_ethtool_init_nfc_rule()
1284 * igc_ethtool_check_nfc_rule() - Check if NFC rule is valid
1294 * Context: Expects adapter->nfc_rule_lock to be held by caller.
1301 struct net_device *dev = adapter->netdev; in igc_ethtool_check_nfc_rule()
1302 u8 flags = rule->filter.match_flags; in igc_ethtool_check_nfc_rule()
1307 return -EINVAL; in igc_ethtool_check_nfc_rule()
1310 list_for_each_entry(tmp, &adapter->nfc_rule_list, list) { in igc_ethtool_check_nfc_rule()
1311 if (!memcmp(&rule->filter, &tmp->filter, in igc_ethtool_check_nfc_rule()
1312 sizeof(rule->filter)) && in igc_ethtool_check_nfc_rule()
1313 tmp->location != rule->location) { in igc_ethtool_check_nfc_rule()
1315 return -EEXIST; in igc_ethtool_check_nfc_rule()
1325 struct net_device *netdev = adapter->netdev; in igc_ethtool_add_nfc_rule()
1327 (struct ethtool_rx_flow_spec *)&cmd->fs; in igc_ethtool_add_nfc_rule()
1331 if (!(netdev->hw_features & NETIF_F_NTUPLE)) { in igc_ethtool_add_nfc_rule()
1332 netdev_dbg(netdev, "N-tuple filters disabled\n"); in igc_ethtool_add_nfc_rule()
1333 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1336 if ((fsp->flow_type & ~FLOW_EXT) != ETHER_FLOW) { in igc_ethtool_add_nfc_rule()
1338 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1341 if (fsp->ring_cookie >= adapter->num_rx_queues) { in igc_ethtool_add_nfc_rule()
1343 return -EINVAL; in igc_ethtool_add_nfc_rule()
1350 if ((fsp->flow_type & FLOW_EXT) && in igc_ethtool_add_nfc_rule()
1351 fsp->m_ext.vlan_tci && in igc_ethtool_add_nfc_rule()
1352 fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK) && in igc_ethtool_add_nfc_rule()
1353 fsp->m_ext.vlan_tci != VLAN_TCI_FULL_MASK) { in igc_ethtool_add_nfc_rule()
1355 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1359 if ((fsp->flow_type & FLOW_EXT) && in igc_ethtool_add_nfc_rule()
1360 fsp->m_ext.vlan_etype && in igc_ethtool_add_nfc_rule()
1361 fsp->m_ext.vlan_etype != ETHER_TYPE_FULL_MASK) { in igc_ethtool_add_nfc_rule()
1363 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1366 if (fsp->location >= IGC_MAX_RXNFC_RULES) { in igc_ethtool_add_nfc_rule()
1368 return -EINVAL; in igc_ethtool_add_nfc_rule()
1373 return -ENOMEM; in igc_ethtool_add_nfc_rule()
1377 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_add_nfc_rule()
1383 old_rule = igc_get_nfc_rule(adapter, fsp->location); in igc_ethtool_add_nfc_rule()
1391 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_add_nfc_rule()
1395 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_add_nfc_rule()
1404 (struct ethtool_rx_flow_spec *)&cmd->fs; in igc_ethtool_del_nfc_rule()
1407 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_del_nfc_rule()
1409 rule = igc_get_nfc_rule(adapter, fsp->location); in igc_ethtool_del_nfc_rule()
1411 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_del_nfc_rule()
1412 return -EINVAL; in igc_ethtool_del_nfc_rule()
1417 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_del_nfc_rule()
1426 switch (cmd->cmd) { in igc_ethtool_set_rxnfc()
1434 return -EOPNOTSUPP; in igc_ethtool_set_rxnfc()
1440 struct igc_hw *hw = &adapter->hw; in igc_write_rss_indir_tbl()
1449 for (j = 3; j >= 0; j--) { in igc_write_rss_indir_tbl()
1451 val |= adapter->rss_indir_tbl[i + j]; in igc_write_rss_indir_tbl()
1471 rxfh->hfunc = ETH_RSS_HASH_TOP; in igc_ethtool_get_rxfh()
1472 if (!rxfh->indir) in igc_ethtool_get_rxfh()
1475 rxfh->indir[i] = adapter->rss_indir_tbl[i]; in igc_ethtool_get_rxfh()
1489 if (rxfh->key || in igc_ethtool_set_rxfh()
1490 (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && in igc_ethtool_set_rxfh()
1491 rxfh->hfunc != ETH_RSS_HASH_TOP)) in igc_ethtool_set_rxfh()
1492 return -EOPNOTSUPP; in igc_ethtool_set_rxfh()
1493 if (!rxfh->indir) in igc_ethtool_set_rxfh()
1496 num_queues = adapter->rss_queues; in igc_ethtool_set_rxfh()
1500 if (rxfh->indir[i] >= num_queues) in igc_ethtool_set_rxfh()
1501 return -EINVAL; in igc_ethtool_set_rxfh()
1504 adapter->rss_indir_tbl[i] = rxfh->indir[i]; in igc_ethtool_set_rxfh()
1517 ch->max_combined = igc_get_max_rss_queues(adapter); in igc_ethtool_get_channels()
1520 if (adapter->flags & IGC_FLAG_HAS_MSIX) { in igc_ethtool_get_channels()
1521 ch->max_other = NON_Q_VECTORS; in igc_ethtool_get_channels()
1522 ch->other_count = NON_Q_VECTORS; in igc_ethtool_get_channels()
1525 ch->combined_count = adapter->rss_queues; in igc_ethtool_get_channels()
1532 unsigned int count = ch->combined_count; in igc_ethtool_set_channels()
1536 if (!count || ch->rx_count || ch->tx_count) in igc_ethtool_set_channels()
1537 return -EINVAL; in igc_ethtool_set_channels()
1540 if (ch->other_count != NON_Q_VECTORS) in igc_ethtool_set_channels()
1541 return -EINVAL; in igc_ethtool_set_channels()
1544 if (adapter->strict_priority_enable) in igc_ethtool_set_channels()
1545 return -EINVAL; in igc_ethtool_set_channels()
1550 return -EINVAL; in igc_ethtool_set_channels()
1552 if (count != adapter->rss_queues) { in igc_ethtool_set_channels()
1553 adapter->rss_queues = count; in igc_ethtool_set_channels()
1570 if (adapter->ptp_clock) in igc_ethtool_get_ts_info()
1571 info->phc_index = ptp_clock_index(adapter->ptp_clock); in igc_ethtool_get_ts_info()
1573 switch (adapter->hw.mac.type) { in igc_ethtool_get_ts_info()
1575 info->so_timestamping = in igc_ethtool_get_ts_info()
1581 info->tx_types = in igc_ethtool_get_ts_info()
1585 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE); in igc_ethtool_get_ts_info()
1586 info->rx_filters |= BIT(HWTSTAMP_FILTER_ALL); in igc_ethtool_get_ts_info()
1590 return -EOPNOTSUPP; in igc_ethtool_get_ts_info()
1599 if (adapter->flags & IGC_FLAG_RX_LEGACY) in igc_ethtool_get_priv_flags()
1608 unsigned int flags = adapter->flags; in igc_ethtool_set_priv_flags()
1614 if (flags != adapter->flags) { in igc_ethtool_set_priv_flags()
1615 adapter->flags = flags; in igc_ethtool_set_priv_flags()
1629 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_eee()
1630 struct igc_phy_info *phy = &hw->phy; in igc_ethtool_get_eee()
1636 edata->supported); in igc_ethtool_get_eee()
1638 edata->supported); in igc_ethtool_get_eee()
1640 edata->supported); in igc_ethtool_get_eee()
1642 /* EEE Advertisement 1 - reg 7.60 */ in igc_ethtool_get_eee()
1643 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << in igc_ethtool_get_eee()
1648 netdev_err(adapter->netdev, in igc_ethtool_get_eee()
1650 return -EINVAL; in igc_ethtool_get_eee()
1655 edata->advertised); in igc_ethtool_get_eee()
1659 edata->advertised); in igc_ethtool_get_eee()
1661 /* EEE Advertisement 2 - reg 7.62 */ in igc_ethtool_get_eee()
1662 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << in igc_ethtool_get_eee()
1667 netdev_err(adapter->netdev, in igc_ethtool_get_eee()
1669 return -EINVAL; in igc_ethtool_get_eee()
1674 edata->advertised); in igc_ethtool_get_eee()
1676 /* EEE Link-Partner Ability 1 - reg 7.61 */ in igc_ethtool_get_eee()
1677 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << in igc_ethtool_get_eee()
1682 netdev_err(adapter->netdev, in igc_ethtool_get_eee()
1684 return -EINVAL; in igc_ethtool_get_eee()
1689 edata->lp_advertised); in igc_ethtool_get_eee()
1693 edata->lp_advertised); in igc_ethtool_get_eee()
1695 /* EEE Link-Partner Ability 2 - reg 7.63 */ in igc_ethtool_get_eee()
1696 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << in igc_ethtool_get_eee()
1701 netdev_err(adapter->netdev, in igc_ethtool_get_eee()
1703 return -EINVAL; in igc_ethtool_get_eee()
1708 edata->lp_advertised); in igc_ethtool_get_eee()
1714 edata->eee_active = true; in igc_ethtool_get_eee()
1717 edata->tx_lpi_enabled = true; in igc_ethtool_get_eee()
1719 edata->eee_enabled = hw->dev_spec._base.eee_enable; in igc_ethtool_get_eee()
1722 * wrongly report EEE at half-duplex in igc_ethtool_get_eee()
1724 if (adapter->link_duplex == HALF_DUPLEX) { in igc_ethtool_get_eee()
1725 edata->eee_enabled = false; in igc_ethtool_get_eee()
1726 edata->eee_active = false; in igc_ethtool_get_eee()
1727 edata->tx_lpi_enabled = false; in igc_ethtool_get_eee()
1728 linkmode_zero(edata->advertised); in igc_ethtool_get_eee()
1738 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_eee()
1748 return -EINVAL; in igc_ethtool_set_eee()
1752 if (eee_curr.tx_lpi_enabled != edata->tx_lpi_enabled) { in igc_ethtool_set_eee()
1754 "Setting EEE tx-lpi is not supported\n"); in igc_ethtool_set_eee()
1755 return -EINVAL; in igc_ethtool_set_eee()
1759 if (edata->tx_lpi_timer) { in igc_ethtool_set_eee()
1762 return -EINVAL; in igc_ethtool_set_eee()
1764 } else if (!edata->eee_enabled) { in igc_ethtool_set_eee()
1767 return -EINVAL; in igc_ethtool_set_eee()
1770 if (hw->dev_spec._base.eee_enable != edata->eee_enabled) { in igc_ethtool_set_eee()
1771 hw->dev_spec._base.eee_enable = edata->eee_enabled; in igc_ethtool_set_eee()
1772 adapter->flags |= IGC_FLAG_EEE; in igc_ethtool_set_eee()
1788 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_link_ksettings()
1804 cmd->base.port = PORT_TP; in igc_ethtool_get_link_ksettings()
1805 cmd->base.phy_address = hw->phy.addr; in igc_ethtool_get_link_ksettings()
1810 if (hw->phy.autoneg_advertised & ADVERTISE_10_HALF) in igc_ethtool_get_link_ksettings()
1812 if (hw->phy.autoneg_advertised & ADVERTISE_10_FULL) in igc_ethtool_get_link_ksettings()
1814 if (hw->phy.autoneg_advertised & ADVERTISE_100_HALF) in igc_ethtool_get_link_ksettings()
1816 if (hw->phy.autoneg_advertised & ADVERTISE_100_FULL) in igc_ethtool_get_link_ksettings()
1818 if (hw->phy.autoneg_advertised & ADVERTISE_1000_FULL) in igc_ethtool_get_link_ksettings()
1820 if (hw->phy.autoneg_advertised & ADVERTISE_2500_FULL) in igc_ethtool_get_link_ksettings()
1830 switch (hw->fc.requested_mode) { in igc_ethtool_get_link_ksettings()
1847 status = pm_runtime_suspended(&adapter->pdev->dev) ? in igc_ethtool_get_link_ksettings()
1857 if (hw->mac.type == igc_i225 && in igc_ethtool_get_link_ksettings()
1869 hw->phy.media_type != igc_media_type_copper) in igc_ethtool_get_link_ksettings()
1870 cmd->base.duplex = DUPLEX_FULL; in igc_ethtool_get_link_ksettings()
1872 cmd->base.duplex = DUPLEX_HALF; in igc_ethtool_get_link_ksettings()
1875 cmd->base.duplex = DUPLEX_UNKNOWN; in igc_ethtool_get_link_ksettings()
1877 cmd->base.speed = speed; in igc_ethtool_get_link_ksettings()
1878 cmd->base.autoneg = AUTONEG_ENABLE; in igc_ethtool_get_link_ksettings()
1880 /* MDI-X => 2; MDI =>1; Invalid =>0 */ in igc_ethtool_get_link_ksettings()
1881 if (hw->phy.media_type == igc_media_type_copper) in igc_ethtool_get_link_ksettings()
1882 cmd->base.eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X : in igc_ethtool_get_link_ksettings()
1885 cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID; in igc_ethtool_get_link_ksettings()
1887 if (hw->phy.mdix == AUTO_ALL_MODES) in igc_ethtool_get_link_ksettings()
1888 cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO; in igc_ethtool_get_link_ksettings()
1890 cmd->base.eth_tp_mdix_ctrl = hw->phy.mdix; in igc_ethtool_get_link_ksettings()
1900 struct net_device *dev = adapter->netdev; in igc_ethtool_set_link_ksettings()
1901 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_link_ksettings()
1909 return -EINVAL; in igc_ethtool_set_link_ksettings()
1916 if (cmd->base.eth_tp_mdix_ctrl) { in igc_ethtool_set_link_ksettings()
1917 if (cmd->base.eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO && in igc_ethtool_set_link_ksettings()
1918 cmd->base.autoneg != AUTONEG_ENABLE) { in igc_ethtool_set_link_ksettings()
1919 …netdev_err(dev, "Forcing MDI/MDI-X state is not supported when link speed and/or duplex are forced… in igc_ethtool_set_link_ksettings()
1920 return -EINVAL; in igc_ethtool_set_link_ksettings()
1924 while (test_and_set_bit(__IGC_RESETTING, &adapter->state)) in igc_ethtool_set_link_ksettings()
1951 if (cmd->base.autoneg == AUTONEG_ENABLE) { in igc_ethtool_set_link_ksettings()
1952 hw->phy.autoneg_advertised = advertised; in igc_ethtool_set_link_ksettings()
1953 if (adapter->fc_autoneg) in igc_ethtool_set_link_ksettings()
1954 hw->fc.requested_mode = igc_fc_default; in igc_ethtool_set_link_ksettings()
1959 /* MDI-X => 2; MDI => 1; Auto => 3 */ in igc_ethtool_set_link_ksettings()
1960 if (cmd->base.eth_tp_mdix_ctrl) { in igc_ethtool_set_link_ksettings()
1964 if (cmd->base.eth_tp_mdix_ctrl == ETH_TP_MDI_AUTO) in igc_ethtool_set_link_ksettings()
1965 hw->phy.mdix = AUTO_ALL_MODES; in igc_ethtool_set_link_ksettings()
1967 hw->phy.mdix = cmd->base.eth_tp_mdix_ctrl; in igc_ethtool_set_link_ksettings()
1971 if (netif_running(adapter->netdev)) { in igc_ethtool_set_link_ksettings()
1978 clear_bit(__IGC_RESETTING, &adapter->state); in igc_ethtool_set_link_ksettings()
1989 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in igc_ethtool_diag_test()
1990 netdev_info(adapter->netdev, "Offline testing starting"); in igc_ethtool_diag_test()
1991 set_bit(__IGC_TESTING, &adapter->state); in igc_ethtool_diag_test()
1997 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
2004 netdev_info(adapter->netdev, "Register testing starting"); in igc_ethtool_diag_test()
2006 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
2010 netdev_info(adapter->netdev, "EEPROM testing starting"); in igc_ethtool_diag_test()
2012 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
2022 clear_bit(__IGC_TESTING, &adapter->state); in igc_ethtool_diag_test()
2026 netdev_info(adapter->netdev, "Online testing starting"); in igc_ethtool_diag_test()
2035 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
2083 netdev->ethtool_ops = &igc_ethtool_ops; in igc_ethtool_set_ops()