Lines Matching +full:75 +full:- +full:ec

1 // SPDX-License-Identifier: GPL-2.0
118 ((((struct igc_adapter *)netdev_priv(netdev))->num_rx_queues * \
120 (((struct igc_adapter *)netdev_priv(netdev))->num_tx_queues * \
128 "legacy-rx",
129 "reverse-tsn-txq-prio",
138 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_drvinfo()
142 strscpy(drvinfo->driver, igc_driver_name, sizeof(drvinfo->driver)); in igc_ethtool_get_drvinfo()
145 hw->nvm.ops.read(hw, IGC_NVM_DEV_STARTER, 1, &nvm_version); in igc_ethtool_get_drvinfo()
150 scnprintf(adapter->fw_version, in igc_ethtool_get_drvinfo()
151 sizeof(adapter->fw_version), in igc_ethtool_get_drvinfo()
156 strscpy(drvinfo->fw_version, adapter->fw_version, in igc_ethtool_get_drvinfo()
157 sizeof(drvinfo->fw_version)); in igc_ethtool_get_drvinfo()
159 strscpy(drvinfo->bus_info, pci_name(adapter->pdev), in igc_ethtool_get_drvinfo()
160 sizeof(drvinfo->bus_info)); in igc_ethtool_get_drvinfo()
162 drvinfo->n_priv_flags = IGC_PRIV_FLAGS_STR_LEN; in igc_ethtool_get_drvinfo()
174 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_regs()
180 regs->version = (2u << 24) | (hw->revision_id << 16) | hw->device_id; in igc_ethtool_get_regs()
235 regs_buff[30] = adapter->stats.crcerrs; in igc_ethtool_get_regs()
236 regs_buff[31] = adapter->stats.algnerrc; in igc_ethtool_get_regs()
237 regs_buff[32] = adapter->stats.symerrs; in igc_ethtool_get_regs()
238 regs_buff[33] = adapter->stats.rxerrc; in igc_ethtool_get_regs()
239 regs_buff[34] = adapter->stats.mpc; in igc_ethtool_get_regs()
240 regs_buff[35] = adapter->stats.scc; in igc_ethtool_get_regs()
241 regs_buff[36] = adapter->stats.ecol; in igc_ethtool_get_regs()
242 regs_buff[37] = adapter->stats.mcc; in igc_ethtool_get_regs()
243 regs_buff[38] = adapter->stats.latecol; in igc_ethtool_get_regs()
244 regs_buff[39] = adapter->stats.colc; in igc_ethtool_get_regs()
245 regs_buff[40] = adapter->stats.dc; in igc_ethtool_get_regs()
246 regs_buff[41] = adapter->stats.tncrs; in igc_ethtool_get_regs()
247 regs_buff[42] = adapter->stats.sec; in igc_ethtool_get_regs()
248 regs_buff[43] = adapter->stats.htdpmc; in igc_ethtool_get_regs()
249 regs_buff[44] = adapter->stats.rlec; in igc_ethtool_get_regs()
250 regs_buff[45] = adapter->stats.xonrxc; in igc_ethtool_get_regs()
251 regs_buff[46] = adapter->stats.xontxc; in igc_ethtool_get_regs()
252 regs_buff[47] = adapter->stats.xoffrxc; in igc_ethtool_get_regs()
253 regs_buff[48] = adapter->stats.xofftxc; in igc_ethtool_get_regs()
254 regs_buff[49] = adapter->stats.fcruc; in igc_ethtool_get_regs()
255 regs_buff[50] = adapter->stats.prc64; in igc_ethtool_get_regs()
256 regs_buff[51] = adapter->stats.prc127; in igc_ethtool_get_regs()
257 regs_buff[52] = adapter->stats.prc255; in igc_ethtool_get_regs()
258 regs_buff[53] = adapter->stats.prc511; in igc_ethtool_get_regs()
259 regs_buff[54] = adapter->stats.prc1023; in igc_ethtool_get_regs()
260 regs_buff[55] = adapter->stats.prc1522; in igc_ethtool_get_regs()
261 regs_buff[56] = adapter->stats.gprc; in igc_ethtool_get_regs()
262 regs_buff[57] = adapter->stats.bprc; in igc_ethtool_get_regs()
263 regs_buff[58] = adapter->stats.mprc; in igc_ethtool_get_regs()
264 regs_buff[59] = adapter->stats.gptc; in igc_ethtool_get_regs()
265 regs_buff[60] = adapter->stats.gorc; in igc_ethtool_get_regs()
266 regs_buff[61] = adapter->stats.gotc; in igc_ethtool_get_regs()
267 regs_buff[62] = adapter->stats.rnbc; in igc_ethtool_get_regs()
268 regs_buff[63] = adapter->stats.ruc; in igc_ethtool_get_regs()
269 regs_buff[64] = adapter->stats.rfc; in igc_ethtool_get_regs()
270 regs_buff[65] = adapter->stats.roc; in igc_ethtool_get_regs()
271 regs_buff[66] = adapter->stats.rjc; in igc_ethtool_get_regs()
272 regs_buff[67] = adapter->stats.mgprc; in igc_ethtool_get_regs()
273 regs_buff[68] = adapter->stats.mgpdc; in igc_ethtool_get_regs()
274 regs_buff[69] = adapter->stats.mgptc; in igc_ethtool_get_regs()
275 regs_buff[70] = adapter->stats.tor; in igc_ethtool_get_regs()
276 regs_buff[71] = adapter->stats.tot; in igc_ethtool_get_regs()
277 regs_buff[72] = adapter->stats.tpr; in igc_ethtool_get_regs()
278 regs_buff[73] = adapter->stats.tpt; in igc_ethtool_get_regs()
279 regs_buff[74] = adapter->stats.ptc64; in igc_ethtool_get_regs()
280 regs_buff[75] = adapter->stats.ptc127; in igc_ethtool_get_regs()
281 regs_buff[76] = adapter->stats.ptc255; in igc_ethtool_get_regs()
282 regs_buff[77] = adapter->stats.ptc511; in igc_ethtool_get_regs()
283 regs_buff[78] = adapter->stats.ptc1023; in igc_ethtool_get_regs()
284 regs_buff[79] = adapter->stats.ptc1522; in igc_ethtool_get_regs()
285 regs_buff[80] = adapter->stats.mptc; in igc_ethtool_get_regs()
286 regs_buff[81] = adapter->stats.bptc; in igc_ethtool_get_regs()
287 regs_buff[82] = adapter->stats.tsctc; in igc_ethtool_get_regs()
288 regs_buff[83] = adapter->stats.iac; in igc_ethtool_get_regs()
289 regs_buff[84] = adapter->stats.rpthc; in igc_ethtool_get_regs()
290 regs_buff[85] = adapter->stats.hgptc; in igc_ethtool_get_regs()
291 regs_buff[86] = adapter->stats.hgorc; in igc_ethtool_get_regs()
292 regs_buff[87] = adapter->stats.hgotc; in igc_ethtool_get_regs()
293 regs_buff[88] = adapter->stats.lenerrs; in igc_ethtool_get_regs()
294 regs_buff[89] = adapter->stats.scvpc; in igc_ethtool_get_regs()
295 regs_buff[90] = adapter->stats.hrmpc; in igc_ethtool_get_regs()
348 regs_buff[213] = adapter->stats.tlpic; in igc_ethtool_get_regs()
349 regs_buff[214] = adapter->stats.rlpic; in igc_ethtool_get_regs()
357 wol->wolopts = 0; in igc_ethtool_get_wol()
359 if (!(adapter->flags & IGC_FLAG_WOL_SUPPORTED)) in igc_ethtool_get_wol()
362 wol->supported = WAKE_UCAST | WAKE_MCAST | in igc_ethtool_get_wol()
367 switch (adapter->hw.device_id) { in igc_ethtool_get_wol()
372 if (adapter->wol & IGC_WUFC_EX) in igc_ethtool_get_wol()
373 wol->wolopts |= WAKE_UCAST; in igc_ethtool_get_wol()
374 if (adapter->wol & IGC_WUFC_MC) in igc_ethtool_get_wol()
375 wol->wolopts |= WAKE_MCAST; in igc_ethtool_get_wol()
376 if (adapter->wol & IGC_WUFC_BC) in igc_ethtool_get_wol()
377 wol->wolopts |= WAKE_BCAST; in igc_ethtool_get_wol()
378 if (adapter->wol & IGC_WUFC_MAG) in igc_ethtool_get_wol()
379 wol->wolopts |= WAKE_MAGIC; in igc_ethtool_get_wol()
380 if (adapter->wol & IGC_WUFC_LNKC) in igc_ethtool_get_wol()
381 wol->wolopts |= WAKE_PHY; in igc_ethtool_get_wol()
389 if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE | WAKE_FILTER)) in igc_ethtool_set_wol()
390 return -EOPNOTSUPP; in igc_ethtool_set_wol()
392 if (!(adapter->flags & IGC_FLAG_WOL_SUPPORTED)) in igc_ethtool_set_wol()
393 return wol->wolopts ? -EOPNOTSUPP : 0; in igc_ethtool_set_wol()
396 adapter->wol = 0; in igc_ethtool_set_wol()
398 if (wol->wolopts & WAKE_UCAST) in igc_ethtool_set_wol()
399 adapter->wol |= IGC_WUFC_EX; in igc_ethtool_set_wol()
400 if (wol->wolopts & WAKE_MCAST) in igc_ethtool_set_wol()
401 adapter->wol |= IGC_WUFC_MC; in igc_ethtool_set_wol()
402 if (wol->wolopts & WAKE_BCAST) in igc_ethtool_set_wol()
403 adapter->wol |= IGC_WUFC_BC; in igc_ethtool_set_wol()
404 if (wol->wolopts & WAKE_MAGIC) in igc_ethtool_set_wol()
405 adapter->wol |= IGC_WUFC_MAG; in igc_ethtool_set_wol()
406 if (wol->wolopts & WAKE_PHY) in igc_ethtool_set_wol()
407 adapter->wol |= IGC_WUFC_LNKC; in igc_ethtool_set_wol()
408 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); in igc_ethtool_set_wol()
417 return adapter->msg_enable; in igc_ethtool_get_msglevel()
424 adapter->msg_enable = data; in igc_ethtool_set_msglevel()
439 struct igc_mac_info *mac = &adapter->hw.mac; in igc_ethtool_get_link()
448 mac->get_link_status = 1; in igc_ethtool_get_link()
457 return adapter->hw.nvm.word_size * 2; in igc_ethtool_get_eeprom_len()
464 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_eeprom()
470 if (eeprom->len == 0) in igc_ethtool_get_eeprom()
471 return -EINVAL; in igc_ethtool_get_eeprom()
473 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in igc_ethtool_get_eeprom()
475 first_word = eeprom->offset >> 1; in igc_ethtool_get_eeprom()
476 last_word = (eeprom->offset + eeprom->len - 1) >> 1; in igc_ethtool_get_eeprom()
478 eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), in igc_ethtool_get_eeprom()
481 return -ENOMEM; in igc_ethtool_get_eeprom()
483 if (hw->nvm.type == igc_nvm_eeprom_spi) { in igc_ethtool_get_eeprom()
484 ret_val = hw->nvm.ops.read(hw, first_word, in igc_ethtool_get_eeprom()
485 last_word - first_word + 1, in igc_ethtool_get_eeprom()
488 for (i = 0; i < last_word - first_word + 1; i++) { in igc_ethtool_get_eeprom()
489 ret_val = hw->nvm.ops.read(hw, first_word + i, 1, in igc_ethtool_get_eeprom()
496 /* Device's eeprom is always little-endian, word addressable */ in igc_ethtool_get_eeprom()
497 for (i = 0; i < last_word - first_word + 1; i++) in igc_ethtool_get_eeprom()
500 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), in igc_ethtool_get_eeprom()
501 eeprom->len); in igc_ethtool_get_eeprom()
511 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_eeprom()
517 if (eeprom->len == 0) in igc_ethtool_set_eeprom()
518 return -EOPNOTSUPP; in igc_ethtool_set_eeprom()
520 if (hw->mac.type >= igc_i225 && in igc_ethtool_set_eeprom()
522 return -EOPNOTSUPP; in igc_ethtool_set_eeprom()
525 if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16))) in igc_ethtool_set_eeprom()
526 return -EFAULT; in igc_ethtool_set_eeprom()
528 max_len = hw->nvm.word_size * 2; in igc_ethtool_set_eeprom()
530 first_word = eeprom->offset >> 1; in igc_ethtool_set_eeprom()
531 last_word = (eeprom->offset + eeprom->len - 1) >> 1; in igc_ethtool_set_eeprom()
534 return -ENOMEM; in igc_ethtool_set_eeprom()
538 if (eeprom->offset & 1) { in igc_ethtool_set_eeprom()
542 ret_val = hw->nvm.ops.read(hw, first_word, 1, in igc_ethtool_set_eeprom()
546 if (((eeprom->offset + eeprom->len) & 1) && ret_val == 0) { in igc_ethtool_set_eeprom()
550 ret_val = hw->nvm.ops.read(hw, last_word, 1, in igc_ethtool_set_eeprom()
551 &eeprom_buff[last_word - first_word]); in igc_ethtool_set_eeprom()
554 /* Device's eeprom is always little-endian, word addressable */ in igc_ethtool_set_eeprom()
555 for (i = 0; i < last_word - first_word + 1; i++) in igc_ethtool_set_eeprom()
558 memcpy(ptr, bytes, eeprom->len); in igc_ethtool_set_eeprom()
560 for (i = 0; i < last_word - first_word + 1; i++) in igc_ethtool_set_eeprom()
563 ret_val = hw->nvm.ops.write(hw, first_word, in igc_ethtool_set_eeprom()
564 last_word - first_word + 1, eeprom_buff); in igc_ethtool_set_eeprom()
568 hw->nvm.ops.update(hw); in igc_ethtool_set_eeprom()
582 ring->rx_max_pending = IGC_MAX_RXD; in igc_ethtool_get_ringparam()
583 ring->tx_max_pending = IGC_MAX_TXD; in igc_ethtool_get_ringparam()
584 ring->rx_pending = adapter->rx_ring_count; in igc_ethtool_get_ringparam()
585 ring->tx_pending = adapter->tx_ring_count; in igc_ethtool_get_ringparam()
599 if (ring->rx_mini_pending || ring->rx_jumbo_pending) in igc_ethtool_set_ringparam()
600 return -EINVAL; in igc_ethtool_set_ringparam()
602 new_rx_count = min_t(u32, ring->rx_pending, IGC_MAX_RXD); in igc_ethtool_set_ringparam()
606 new_tx_count = min_t(u32, ring->tx_pending, IGC_MAX_TXD); in igc_ethtool_set_ringparam()
610 if (new_tx_count == adapter->tx_ring_count && in igc_ethtool_set_ringparam()
611 new_rx_count == adapter->rx_ring_count) { in igc_ethtool_set_ringparam()
616 while (test_and_set_bit(__IGC_RESETTING, &adapter->state)) in igc_ethtool_set_ringparam()
619 if (!netif_running(adapter->netdev)) { in igc_ethtool_set_ringparam()
620 for (i = 0; i < adapter->num_tx_queues; i++) in igc_ethtool_set_ringparam()
621 adapter->tx_ring[i]->count = new_tx_count; in igc_ethtool_set_ringparam()
622 for (i = 0; i < adapter->num_rx_queues; i++) in igc_ethtool_set_ringparam()
623 adapter->rx_ring[i]->count = new_rx_count; in igc_ethtool_set_ringparam()
624 adapter->tx_ring_count = new_tx_count; in igc_ethtool_set_ringparam()
625 adapter->rx_ring_count = new_rx_count; in igc_ethtool_set_ringparam()
629 if (adapter->num_tx_queues > adapter->num_rx_queues) in igc_ethtool_set_ringparam()
630 temp_ring = vmalloc_array(adapter->num_tx_queues, in igc_ethtool_set_ringparam()
633 temp_ring = vmalloc_array(adapter->num_rx_queues, in igc_ethtool_set_ringparam()
637 err = -ENOMEM; in igc_ethtool_set_ringparam()
644 * because the ISRs in MSI-X mode get passed pointers in igc_ethtool_set_ringparam()
647 if (new_tx_count != adapter->tx_ring_count) { in igc_ethtool_set_ringparam()
648 for (i = 0; i < adapter->num_tx_queues; i++) { in igc_ethtool_set_ringparam()
649 memcpy(&temp_ring[i], adapter->tx_ring[i], in igc_ethtool_set_ringparam()
656 i--; in igc_ethtool_set_ringparam()
663 for (i = 0; i < adapter->num_tx_queues; i++) { in igc_ethtool_set_ringparam()
664 igc_free_tx_resources(adapter->tx_ring[i]); in igc_ethtool_set_ringparam()
666 memcpy(adapter->tx_ring[i], &temp_ring[i], in igc_ethtool_set_ringparam()
670 adapter->tx_ring_count = new_tx_count; in igc_ethtool_set_ringparam()
673 if (new_rx_count != adapter->rx_ring_count) { in igc_ethtool_set_ringparam()
674 for (i = 0; i < adapter->num_rx_queues; i++) { in igc_ethtool_set_ringparam()
675 memcpy(&temp_ring[i], adapter->rx_ring[i], in igc_ethtool_set_ringparam()
682 i--; in igc_ethtool_set_ringparam()
689 for (i = 0; i < adapter->num_rx_queues; i++) { in igc_ethtool_set_ringparam()
690 igc_free_rx_resources(adapter->rx_ring[i]); in igc_ethtool_set_ringparam()
692 memcpy(adapter->rx_ring[i], &temp_ring[i], in igc_ethtool_set_ringparam()
696 adapter->rx_ring_count = new_rx_count; in igc_ethtool_set_ringparam()
702 clear_bit(__IGC_RESETTING, &adapter->state); in igc_ethtool_set_ringparam()
710 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_pauseparam()
712 pause->autoneg = in igc_ethtool_get_pauseparam()
713 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); in igc_ethtool_get_pauseparam()
715 if (hw->fc.current_mode == igc_fc_rx_pause) { in igc_ethtool_get_pauseparam()
716 pause->rx_pause = 1; in igc_ethtool_get_pauseparam()
717 } else if (hw->fc.current_mode == igc_fc_tx_pause) { in igc_ethtool_get_pauseparam()
718 pause->tx_pause = 1; in igc_ethtool_get_pauseparam()
719 } else if (hw->fc.current_mode == igc_fc_full) { in igc_ethtool_get_pauseparam()
720 pause->rx_pause = 1; in igc_ethtool_get_pauseparam()
721 pause->tx_pause = 1; in igc_ethtool_get_pauseparam()
729 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_pauseparam()
732 adapter->fc_autoneg = pause->autoneg; in igc_ethtool_set_pauseparam()
734 while (test_and_set_bit(__IGC_RESETTING, &adapter->state)) in igc_ethtool_set_pauseparam()
737 if (adapter->fc_autoneg == AUTONEG_ENABLE) { in igc_ethtool_set_pauseparam()
738 hw->fc.requested_mode = igc_fc_default; in igc_ethtool_set_pauseparam()
739 if (netif_running(adapter->netdev)) { in igc_ethtool_set_pauseparam()
746 if (pause->rx_pause && pause->tx_pause) in igc_ethtool_set_pauseparam()
747 hw->fc.requested_mode = igc_fc_full; in igc_ethtool_set_pauseparam()
748 else if (pause->rx_pause && !pause->tx_pause) in igc_ethtool_set_pauseparam()
749 hw->fc.requested_mode = igc_fc_rx_pause; in igc_ethtool_set_pauseparam()
750 else if (!pause->rx_pause && pause->tx_pause) in igc_ethtool_set_pauseparam()
751 hw->fc.requested_mode = igc_fc_tx_pause; in igc_ethtool_set_pauseparam()
752 else if (!pause->rx_pause && !pause->tx_pause) in igc_ethtool_set_pauseparam()
753 hw->fc.requested_mode = igc_fc_none; in igc_ethtool_set_pauseparam()
755 hw->fc.current_mode = hw->fc.requested_mode; in igc_ethtool_set_pauseparam()
757 retval = ((hw->phy.media_type == igc_media_type_copper) ? in igc_ethtool_set_pauseparam()
761 clear_bit(__IGC_RESETTING, &adapter->state); in igc_ethtool_set_pauseparam()
782 for (i = 0; i < adapter->num_tx_queues; i++) { in igc_ethtool_get_strings()
787 for (i = 0; i < adapter->num_rx_queues; i++) { in igc_ethtool_get_strings()
794 /* BUG_ON(p - data != IGC_STATS_LEN * ETH_GSTRING_LEN); */ in igc_ethtool_get_strings()
813 return -EOPNOTSUPP; in igc_ethtool_get_sset_count()
821 struct rtnl_link_stats64 *net_stats = &adapter->stats64; in igc_ethtool_get_stats()
827 spin_lock(&adapter->stats64_lock); in igc_ethtool_get_stats()
840 for (j = 0; j < adapter->num_tx_queues; j++) { in igc_ethtool_get_stats()
843 ring = adapter->tx_ring[j]; in igc_ethtool_get_stats()
845 start = u64_stats_fetch_begin(&ring->tx_syncp); in igc_ethtool_get_stats()
846 data[i] = ring->tx_stats.packets; in igc_ethtool_get_stats()
847 data[i + 1] = ring->tx_stats.bytes; in igc_ethtool_get_stats()
848 data[i + 2] = ring->tx_stats.restart_queue; in igc_ethtool_get_stats()
849 } while (u64_stats_fetch_retry(&ring->tx_syncp, start)); in igc_ethtool_get_stats()
851 start = u64_stats_fetch_begin(&ring->tx_syncp2); in igc_ethtool_get_stats()
852 restart2 = ring->tx_stats.restart_queue2; in igc_ethtool_get_stats()
853 } while (u64_stats_fetch_retry(&ring->tx_syncp2, start)); in igc_ethtool_get_stats()
858 for (j = 0; j < adapter->num_rx_queues; j++) { in igc_ethtool_get_stats()
859 ring = adapter->rx_ring[j]; in igc_ethtool_get_stats()
861 start = u64_stats_fetch_begin(&ring->rx_syncp); in igc_ethtool_get_stats()
862 data[i] = ring->rx_stats.packets; in igc_ethtool_get_stats()
863 data[i + 1] = ring->rx_stats.bytes; in igc_ethtool_get_stats()
864 data[i + 2] = ring->rx_stats.drops; in igc_ethtool_get_stats()
865 data[i + 3] = ring->rx_stats.csum_err; in igc_ethtool_get_stats()
866 data[i + 4] = ring->rx_stats.alloc_failed; in igc_ethtool_get_stats()
867 } while (u64_stats_fetch_retry(&ring->rx_syncp, start)); in igc_ethtool_get_stats()
870 spin_unlock(&adapter->stats64_lock); in igc_ethtool_get_stats()
875 return (adapter->rx_itr_setting <= 3) ? in igc_ethtool_get_previous_rx_coalesce()
876 adapter->rx_itr_setting : adapter->rx_itr_setting >> 2; in igc_ethtool_get_previous_rx_coalesce()
881 return (adapter->tx_itr_setting <= 3) ? in igc_ethtool_get_previous_tx_coalesce()
882 adapter->tx_itr_setting : adapter->tx_itr_setting >> 2; in igc_ethtool_get_previous_tx_coalesce()
886 struct ethtool_coalesce *ec, in igc_ethtool_get_coalesce() argument
892 ec->rx_coalesce_usecs = igc_ethtool_get_previous_rx_coalesce(adapter); in igc_ethtool_get_coalesce()
893 ec->tx_coalesce_usecs = igc_ethtool_get_previous_tx_coalesce(adapter); in igc_ethtool_get_coalesce()
899 struct ethtool_coalesce *ec, in igc_ethtool_set_coalesce() argument
906 if (ec->rx_coalesce_usecs > IGC_MAX_ITR_USECS || in igc_ethtool_set_coalesce()
907 (ec->rx_coalesce_usecs > 3 && in igc_ethtool_set_coalesce()
908 ec->rx_coalesce_usecs < IGC_MIN_ITR_USECS) || in igc_ethtool_set_coalesce()
909 ec->rx_coalesce_usecs == 2) in igc_ethtool_set_coalesce()
910 return -EINVAL; in igc_ethtool_set_coalesce()
912 if (ec->tx_coalesce_usecs > IGC_MAX_ITR_USECS || in igc_ethtool_set_coalesce()
913 (ec->tx_coalesce_usecs > 3 && in igc_ethtool_set_coalesce()
914 ec->tx_coalesce_usecs < IGC_MIN_ITR_USECS) || in igc_ethtool_set_coalesce()
915 ec->tx_coalesce_usecs == 2) in igc_ethtool_set_coalesce()
916 return -EINVAL; in igc_ethtool_set_coalesce()
918 if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) && in igc_ethtool_set_coalesce()
919 ec->tx_coalesce_usecs != igc_ethtool_get_previous_tx_coalesce(adapter)) { in igc_ethtool_set_coalesce()
921 "Queue Pair mode enabled, both Rx and Tx coalescing controlled by rx-usecs"); in igc_ethtool_set_coalesce()
922 return -EINVAL; in igc_ethtool_set_coalesce()
926 if (ec->rx_coalesce_usecs == 0) { in igc_ethtool_set_coalesce()
927 if (adapter->flags & IGC_FLAG_DMAC) in igc_ethtool_set_coalesce()
928 adapter->flags &= ~IGC_FLAG_DMAC; in igc_ethtool_set_coalesce()
932 if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) in igc_ethtool_set_coalesce()
933 adapter->rx_itr_setting = ec->rx_coalesce_usecs; in igc_ethtool_set_coalesce()
935 adapter->rx_itr_setting = ec->rx_coalesce_usecs << 2; in igc_ethtool_set_coalesce()
938 if (adapter->flags & IGC_FLAG_QUEUE_PAIRS) in igc_ethtool_set_coalesce()
939 adapter->tx_itr_setting = adapter->rx_itr_setting; in igc_ethtool_set_coalesce()
940 else if (ec->tx_coalesce_usecs && ec->tx_coalesce_usecs <= 3) in igc_ethtool_set_coalesce()
941 adapter->tx_itr_setting = ec->tx_coalesce_usecs; in igc_ethtool_set_coalesce()
943 adapter->tx_itr_setting = ec->tx_coalesce_usecs << 2; in igc_ethtool_set_coalesce()
945 for (i = 0; i < adapter->num_q_vectors; i++) { in igc_ethtool_set_coalesce()
946 struct igc_q_vector *q_vector = adapter->q_vector[i]; in igc_ethtool_set_coalesce()
948 q_vector->tx.work_limit = adapter->tx_work_limit; in igc_ethtool_set_coalesce()
949 if (q_vector->rx.ring) in igc_ethtool_set_coalesce()
950 q_vector->itr_val = adapter->rx_itr_setting; in igc_ethtool_set_coalesce()
952 q_vector->itr_val = adapter->tx_itr_setting; in igc_ethtool_set_coalesce()
953 if (q_vector->itr_val && q_vector->itr_val <= 3) in igc_ethtool_set_coalesce()
954 q_vector->itr_val = IGC_START_ITR; in igc_ethtool_set_coalesce()
955 q_vector->set_itr = 1; in igc_ethtool_set_coalesce()
966 struct ethtool_rx_flow_spec *fsp = &cmd->fs; in igc_ethtool_get_nfc_rule()
969 cmd->data = IGC_MAX_RXNFC_RULES; in igc_ethtool_get_nfc_rule()
971 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rule()
973 rule = igc_get_nfc_rule(adapter, fsp->location); in igc_ethtool_get_nfc_rule()
977 fsp->flow_type = ETHER_FLOW; in igc_ethtool_get_nfc_rule()
978 fsp->ring_cookie = rule->action; in igc_ethtool_get_nfc_rule()
980 if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { in igc_ethtool_get_nfc_rule()
981 fsp->h_u.ether_spec.h_proto = htons(rule->filter.etype); in igc_ethtool_get_nfc_rule()
982 fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK; in igc_ethtool_get_nfc_rule()
985 if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) { in igc_ethtool_get_nfc_rule()
986 fsp->flow_type |= FLOW_EXT; in igc_ethtool_get_nfc_rule()
987 fsp->h_ext.vlan_etype = htons(rule->filter.vlan_etype); in igc_ethtool_get_nfc_rule()
988 fsp->m_ext.vlan_etype = ETHER_TYPE_FULL_MASK; in igc_ethtool_get_nfc_rule()
991 if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { in igc_ethtool_get_nfc_rule()
992 fsp->flow_type |= FLOW_EXT; in igc_ethtool_get_nfc_rule()
993 fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci); in igc_ethtool_get_nfc_rule()
994 fsp->m_ext.vlan_tci = htons(rule->filter.vlan_tci_mask); in igc_ethtool_get_nfc_rule()
997 if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { in igc_ethtool_get_nfc_rule()
998 ether_addr_copy(fsp->h_u.ether_spec.h_dest, in igc_ethtool_get_nfc_rule()
999 rule->filter.dst_addr); in igc_ethtool_get_nfc_rule()
1000 eth_broadcast_addr(fsp->m_u.ether_spec.h_dest); in igc_ethtool_get_nfc_rule()
1003 if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { in igc_ethtool_get_nfc_rule()
1004 ether_addr_copy(fsp->h_u.ether_spec.h_source, in igc_ethtool_get_nfc_rule()
1005 rule->filter.src_addr); in igc_ethtool_get_nfc_rule()
1006 eth_broadcast_addr(fsp->m_u.ether_spec.h_source); in igc_ethtool_get_nfc_rule()
1009 if (rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) { in igc_ethtool_get_nfc_rule()
1010 fsp->flow_type |= FLOW_EXT; in igc_ethtool_get_nfc_rule()
1011 memcpy(fsp->h_ext.data, rule->filter.user_data, sizeof(fsp->h_ext.data)); in igc_ethtool_get_nfc_rule()
1012 memcpy(fsp->m_ext.data, rule->filter.user_mask, sizeof(fsp->m_ext.data)); in igc_ethtool_get_nfc_rule()
1015 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rule()
1019 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rule()
1020 return -EINVAL; in igc_ethtool_get_nfc_rule()
1030 cmd->data = IGC_MAX_RXNFC_RULES; in igc_ethtool_get_nfc_rules()
1032 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rules()
1034 list_for_each_entry(rule, &adapter->nfc_rule_list, list) { in igc_ethtool_get_nfc_rules()
1035 if (cnt == cmd->rule_cnt) { in igc_ethtool_get_nfc_rules()
1036 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rules()
1037 return -EMSGSIZE; in igc_ethtool_get_nfc_rules()
1039 rule_locs[cnt] = rule->location; in igc_ethtool_get_nfc_rules()
1043 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rules()
1045 cmd->rule_cnt = cnt; in igc_ethtool_get_nfc_rules()
1055 cmd->data = 0; in igc_ethtool_get_rxfh_fields()
1058 switch (cmd->flow_type) { in igc_ethtool_get_rxfh_fields()
1060 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rxfh_fields()
1063 if (adapter->flags & IGC_FLAG_RSS_FIELD_IPV4_UDP) in igc_ethtool_get_rxfh_fields()
1064 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rxfh_fields()
1071 cmd->data |= RXH_IP_SRC | RXH_IP_DST; in igc_ethtool_get_rxfh_fields()
1074 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rxfh_fields()
1077 if (adapter->flags & IGC_FLAG_RSS_FIELD_IPV6_UDP) in igc_ethtool_get_rxfh_fields()
1078 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rxfh_fields()
1085 cmd->data |= RXH_IP_SRC | RXH_IP_DST; in igc_ethtool_get_rxfh_fields()
1088 return -EINVAL; in igc_ethtool_get_rxfh_fields()
1099 switch (cmd->cmd) { in igc_ethtool_get_rxnfc()
1101 cmd->data = adapter->num_rx_queues; in igc_ethtool_get_rxnfc()
1104 cmd->rule_cnt = adapter->nfc_rule_count; in igc_ethtool_get_rxnfc()
1111 return -EOPNOTSUPP; in igc_ethtool_get_rxnfc()
1122 u32 flags = adapter->flags; in igc_ethtool_set_rxfh_fields()
1127 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | in igc_ethtool_set_rxfh_fields()
1129 return -EINVAL; in igc_ethtool_set_rxfh_fields()
1131 switch (nfc->flow_type) { in igc_ethtool_set_rxfh_fields()
1134 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rxfh_fields()
1135 !(nfc->data & RXH_IP_DST) || in igc_ethtool_set_rxfh_fields()
1136 !(nfc->data & RXH_L4_B_0_1) || in igc_ethtool_set_rxfh_fields()
1137 !(nfc->data & RXH_L4_B_2_3)) in igc_ethtool_set_rxfh_fields()
1138 return -EINVAL; in igc_ethtool_set_rxfh_fields()
1141 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rxfh_fields()
1142 !(nfc->data & RXH_IP_DST)) in igc_ethtool_set_rxfh_fields()
1143 return -EINVAL; in igc_ethtool_set_rxfh_fields()
1144 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { in igc_ethtool_set_rxfh_fields()
1152 return -EINVAL; in igc_ethtool_set_rxfh_fields()
1156 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rxfh_fields()
1157 !(nfc->data & RXH_IP_DST)) in igc_ethtool_set_rxfh_fields()
1158 return -EINVAL; in igc_ethtool_set_rxfh_fields()
1159 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { in igc_ethtool_set_rxfh_fields()
1167 return -EINVAL; in igc_ethtool_set_rxfh_fields()
1178 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rxfh_fields()
1179 !(nfc->data & RXH_IP_DST) || in igc_ethtool_set_rxfh_fields()
1180 (nfc->data & RXH_L4_B_0_1) || in igc_ethtool_set_rxfh_fields()
1181 (nfc->data & RXH_L4_B_2_3)) in igc_ethtool_set_rxfh_fields()
1182 return -EINVAL; in igc_ethtool_set_rxfh_fields()
1185 return -EINVAL; in igc_ethtool_set_rxfh_fields()
1189 if (flags != adapter->flags) { in igc_ethtool_set_rxfh_fields()
1190 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_rxfh_fields()
1194 !(adapter->flags & UDP_RSS_FLAGS)) in igc_ethtool_set_rxfh_fields()
1195 netdev_err(adapter->netdev, in igc_ethtool_set_rxfh_fields()
1198 adapter->flags = flags; in igc_ethtool_set_rxfh_fields()
1224 INIT_LIST_HEAD(&rule->list); in igc_ethtool_init_nfc_rule()
1226 rule->action = fsp->ring_cookie; in igc_ethtool_init_nfc_rule()
1227 rule->location = fsp->location; in igc_ethtool_init_nfc_rule()
1229 if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) { in igc_ethtool_init_nfc_rule()
1230 rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci); in igc_ethtool_init_nfc_rule()
1231 rule->filter.vlan_tci_mask = ntohs(fsp->m_ext.vlan_tci); in igc_ethtool_init_nfc_rule()
1232 rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI; in igc_ethtool_init_nfc_rule()
1235 if (fsp->m_u.ether_spec.h_proto == ETHER_TYPE_FULL_MASK) { in igc_ethtool_init_nfc_rule()
1236 rule->filter.etype = ntohs(fsp->h_u.ether_spec.h_proto); in igc_ethtool_init_nfc_rule()
1237 rule->filter.match_flags = IGC_FILTER_FLAG_ETHER_TYPE; in igc_ethtool_init_nfc_rule()
1243 if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_source)) { in igc_ethtool_init_nfc_rule()
1244 rule->filter.match_flags |= IGC_FILTER_FLAG_SRC_MAC_ADDR; in igc_ethtool_init_nfc_rule()
1245 ether_addr_copy(rule->filter.src_addr, in igc_ethtool_init_nfc_rule()
1246 fsp->h_u.ether_spec.h_source); in igc_ethtool_init_nfc_rule()
1249 if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_dest)) { in igc_ethtool_init_nfc_rule()
1250 rule->filter.match_flags |= IGC_FILTER_FLAG_DST_MAC_ADDR; in igc_ethtool_init_nfc_rule()
1251 ether_addr_copy(rule->filter.dst_addr, in igc_ethtool_init_nfc_rule()
1252 fsp->h_u.ether_spec.h_dest); in igc_ethtool_init_nfc_rule()
1256 if ((fsp->flow_type & FLOW_EXT) && fsp->h_ext.vlan_etype) { in igc_ethtool_init_nfc_rule()
1257 rule->filter.vlan_etype = ntohs(fsp->h_ext.vlan_etype); in igc_ethtool_init_nfc_rule()
1258 rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_ETYPE; in igc_ethtool_init_nfc_rule()
1262 if ((fsp->flow_type & FLOW_EXT) && in igc_ethtool_init_nfc_rule()
1263 (fsp->h_ext.data[0] || fsp->h_ext.data[1])) { in igc_ethtool_init_nfc_rule()
1264 rule->filter.match_flags |= IGC_FILTER_FLAG_USER_DATA; in igc_ethtool_init_nfc_rule()
1265 memcpy(rule->filter.user_data, fsp->h_ext.data, sizeof(fsp->h_ext.data)); in igc_ethtool_init_nfc_rule()
1266 memcpy(rule->filter.user_mask, fsp->m_ext.data, sizeof(fsp->m_ext.data)); in igc_ethtool_init_nfc_rule()
1278 if ((rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) || in igc_ethtool_init_nfc_rule()
1279 (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) || in igc_ethtool_init_nfc_rule()
1280 ((rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) && in igc_ethtool_init_nfc_rule()
1281 rule->filter.vlan_tci_mask == ntohs(VLAN_TCI_FULL_MASK)) || in igc_ethtool_init_nfc_rule()
1282 (rule->filter.match_flags & (rule->filter.match_flags - 1))) in igc_ethtool_init_nfc_rule()
1283 rule->flex = true; in igc_ethtool_init_nfc_rule()
1285 rule->flex = false; in igc_ethtool_init_nfc_rule()
1298 if (!rule->filter.match_flags && in igc_ethtool_init_nfc_rule()
1299 fsp->flow_type == ETHER_FLOW && in igc_ethtool_init_nfc_rule()
1300 is_zero_ether_addr(fsp->m_u.ether_spec.h_source) && in igc_ethtool_init_nfc_rule()
1301 is_zero_ether_addr(fsp->m_u.ether_spec.h_dest) && in igc_ethtool_init_nfc_rule()
1302 !fsp->m_u.ether_spec.h_proto) in igc_ethtool_init_nfc_rule()
1303 rule->filter.match_flags = IGC_FILTER_FLAG_DEFAULT_QUEUE; in igc_ethtool_init_nfc_rule()
1307 * igc_ethtool_check_nfc_rule() - Check if NFC rule is valid
1317 * Context: Expects adapter->nfc_rule_lock to be held by caller.
1324 struct net_device *dev = adapter->netdev; in igc_ethtool_check_nfc_rule()
1325 u8 flags = rule->filter.match_flags; in igc_ethtool_check_nfc_rule()
1330 return -EINVAL; in igc_ethtool_check_nfc_rule()
1333 list_for_each_entry(tmp, &adapter->nfc_rule_list, list) { in igc_ethtool_check_nfc_rule()
1334 if (!memcmp(&rule->filter, &tmp->filter, in igc_ethtool_check_nfc_rule()
1335 sizeof(rule->filter)) && in igc_ethtool_check_nfc_rule()
1336 tmp->location != rule->location) { in igc_ethtool_check_nfc_rule()
1338 return -EEXIST; in igc_ethtool_check_nfc_rule()
1348 struct net_device *netdev = adapter->netdev; in igc_ethtool_add_nfc_rule()
1350 (struct ethtool_rx_flow_spec *)&cmd->fs; in igc_ethtool_add_nfc_rule()
1354 if (!(netdev->hw_features & NETIF_F_NTUPLE)) { in igc_ethtool_add_nfc_rule()
1355 netdev_dbg(netdev, "N-tuple filters disabled\n"); in igc_ethtool_add_nfc_rule()
1356 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1359 if ((fsp->flow_type & ~FLOW_EXT) != ETHER_FLOW) { in igc_ethtool_add_nfc_rule()
1361 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1364 if (fsp->ring_cookie >= adapter->num_rx_queues) { in igc_ethtool_add_nfc_rule()
1366 return -EINVAL; in igc_ethtool_add_nfc_rule()
1373 if ((fsp->flow_type & FLOW_EXT) && in igc_ethtool_add_nfc_rule()
1374 fsp->m_ext.vlan_tci && in igc_ethtool_add_nfc_rule()
1375 fsp->m_ext.vlan_tci != htons(VLAN_PRIO_MASK) && in igc_ethtool_add_nfc_rule()
1376 fsp->m_ext.vlan_tci != VLAN_TCI_FULL_MASK) { in igc_ethtool_add_nfc_rule()
1378 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1382 if ((fsp->flow_type & FLOW_EXT) && in igc_ethtool_add_nfc_rule()
1383 fsp->m_ext.vlan_etype && in igc_ethtool_add_nfc_rule()
1384 fsp->m_ext.vlan_etype != ETHER_TYPE_FULL_MASK) { in igc_ethtool_add_nfc_rule()
1386 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1389 if (fsp->location >= IGC_MAX_RXNFC_RULES) { in igc_ethtool_add_nfc_rule()
1391 return -EINVAL; in igc_ethtool_add_nfc_rule()
1396 return -ENOMEM; in igc_ethtool_add_nfc_rule()
1400 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_add_nfc_rule()
1406 old_rule = igc_get_nfc_rule(adapter, fsp->location); in igc_ethtool_add_nfc_rule()
1414 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_add_nfc_rule()
1418 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_add_nfc_rule()
1427 (struct ethtool_rx_flow_spec *)&cmd->fs; in igc_ethtool_del_nfc_rule()
1430 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_del_nfc_rule()
1432 rule = igc_get_nfc_rule(adapter, fsp->location); in igc_ethtool_del_nfc_rule()
1434 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_del_nfc_rule()
1435 return -EINVAL; in igc_ethtool_del_nfc_rule()
1440 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_del_nfc_rule()
1449 switch (cmd->cmd) { in igc_ethtool_set_rxnfc()
1455 return -EOPNOTSUPP; in igc_ethtool_set_rxnfc()
1461 struct igc_hw *hw = &adapter->hw; in igc_write_rss_indir_tbl()
1470 for (j = 3; j >= 0; j--) { in igc_write_rss_indir_tbl()
1472 val |= adapter->rss_indir_tbl[i + j]; in igc_write_rss_indir_tbl()
1492 rxfh->hfunc = ETH_RSS_HASH_TOP; in igc_ethtool_get_rxfh()
1493 if (!rxfh->indir) in igc_ethtool_get_rxfh()
1496 rxfh->indir[i] = adapter->rss_indir_tbl[i]; in igc_ethtool_get_rxfh()
1510 if (rxfh->key || in igc_ethtool_set_rxfh()
1511 (rxfh->hfunc != ETH_RSS_HASH_NO_CHANGE && in igc_ethtool_set_rxfh()
1512 rxfh->hfunc != ETH_RSS_HASH_TOP)) in igc_ethtool_set_rxfh()
1513 return -EOPNOTSUPP; in igc_ethtool_set_rxfh()
1514 if (!rxfh->indir) in igc_ethtool_set_rxfh()
1517 num_queues = adapter->rss_queues; in igc_ethtool_set_rxfh()
1521 if (rxfh->indir[i] >= num_queues) in igc_ethtool_set_rxfh()
1522 return -EINVAL; in igc_ethtool_set_rxfh()
1525 adapter->rss_indir_tbl[i] = rxfh->indir[i]; in igc_ethtool_set_rxfh()
1538 ch->max_combined = igc_get_max_rss_queues(adapter); in igc_ethtool_get_channels()
1541 if (adapter->flags & IGC_FLAG_HAS_MSIX) { in igc_ethtool_get_channels()
1542 ch->max_other = NON_Q_VECTORS; in igc_ethtool_get_channels()
1543 ch->other_count = NON_Q_VECTORS; in igc_ethtool_get_channels()
1546 ch->combined_count = adapter->rss_queues; in igc_ethtool_get_channels()
1553 unsigned int count = ch->combined_count; in igc_ethtool_set_channels()
1557 if (!count || ch->rx_count || ch->tx_count) in igc_ethtool_set_channels()
1558 return -EINVAL; in igc_ethtool_set_channels()
1561 if (ch->other_count != NON_Q_VECTORS) in igc_ethtool_set_channels()
1562 return -EINVAL; in igc_ethtool_set_channels()
1565 if (adapter->strict_priority_enable) in igc_ethtool_set_channels()
1566 return -EINVAL; in igc_ethtool_set_channels()
1571 return -EINVAL; in igc_ethtool_set_channels()
1573 if (count != adapter->rss_queues) { in igc_ethtool_set_channels()
1574 adapter->rss_queues = count; in igc_ethtool_set_channels()
1591 if (adapter->ptp_clock) in igc_ethtool_get_ts_info()
1592 info->phc_index = ptp_clock_index(adapter->ptp_clock); in igc_ethtool_get_ts_info()
1594 switch (adapter->hw.mac.type) { in igc_ethtool_get_ts_info()
1596 info->so_timestamping = in igc_ethtool_get_ts_info()
1602 info->tx_types = in igc_ethtool_get_ts_info()
1606 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE); in igc_ethtool_get_ts_info()
1607 info->rx_filters |= BIT(HWTSTAMP_FILTER_ALL); in igc_ethtool_get_ts_info()
1611 return -EOPNOTSUPP; in igc_ethtool_get_ts_info()
1620 if (adapter->flags & IGC_FLAG_RX_LEGACY) in igc_ethtool_get_priv_flags()
1623 if (adapter->flags & IGC_FLAG_TSN_REVERSE_TXQ_PRIO) in igc_ethtool_get_priv_flags()
1632 unsigned int flags = adapter->flags; in igc_ethtool_set_priv_flags()
1641 if (flags != adapter->flags) { in igc_ethtool_set_priv_flags()
1642 adapter->flags = flags; in igc_ethtool_set_priv_flags()
1656 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_eee()
1657 struct igc_phy_info *phy = &hw->phy; in igc_ethtool_get_eee()
1663 edata->supported); in igc_ethtool_get_eee()
1665 edata->supported); in igc_ethtool_get_eee()
1667 edata->supported); in igc_ethtool_get_eee()
1669 /* EEE Advertisement 1 - reg 7.60 */ in igc_ethtool_get_eee()
1670 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << in igc_ethtool_get_eee()
1675 netdev_err(adapter->netdev, in igc_ethtool_get_eee()
1677 return -EINVAL; in igc_ethtool_get_eee()
1682 edata->advertised); in igc_ethtool_get_eee()
1686 edata->advertised); in igc_ethtool_get_eee()
1688 /* EEE Advertisement 2 - reg 7.62 */ in igc_ethtool_get_eee()
1689 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << in igc_ethtool_get_eee()
1694 netdev_err(adapter->netdev, in igc_ethtool_get_eee()
1696 return -EINVAL; in igc_ethtool_get_eee()
1701 edata->advertised); in igc_ethtool_get_eee()
1703 /* EEE Link-Partner Ability 1 - reg 7.61 */ in igc_ethtool_get_eee()
1704 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << in igc_ethtool_get_eee()
1709 netdev_err(adapter->netdev, in igc_ethtool_get_eee()
1711 return -EINVAL; in igc_ethtool_get_eee()
1716 edata->lp_advertised); in igc_ethtool_get_eee()
1720 edata->lp_advertised); in igc_ethtool_get_eee()
1722 /* EEE Link-Partner Ability 2 - reg 7.63 */ in igc_ethtool_get_eee()
1723 ret_val = phy->ops.read_reg(hw, (STANDARD_AN_REG_MASK << in igc_ethtool_get_eee()
1728 netdev_err(adapter->netdev, in igc_ethtool_get_eee()
1730 return -EINVAL; in igc_ethtool_get_eee()
1735 edata->lp_advertised); in igc_ethtool_get_eee()
1741 edata->eee_active = true; in igc_ethtool_get_eee()
1744 edata->tx_lpi_enabled = true; in igc_ethtool_get_eee()
1746 edata->eee_enabled = hw->dev_spec._base.eee_enable; in igc_ethtool_get_eee()
1749 * wrongly report EEE at half-duplex in igc_ethtool_get_eee()
1751 if (adapter->link_duplex == HALF_DUPLEX) { in igc_ethtool_get_eee()
1752 edata->eee_enabled = false; in igc_ethtool_get_eee()
1753 edata->eee_active = false; in igc_ethtool_get_eee()
1754 edata->tx_lpi_enabled = false; in igc_ethtool_get_eee()
1755 linkmode_zero(edata->advertised); in igc_ethtool_get_eee()
1765 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_eee()
1775 return -EINVAL; in igc_ethtool_set_eee()
1779 if (eee_curr.tx_lpi_enabled != edata->tx_lpi_enabled) { in igc_ethtool_set_eee()
1781 "Setting EEE tx-lpi is not supported\n"); in igc_ethtool_set_eee()
1782 return -EINVAL; in igc_ethtool_set_eee()
1786 if (edata->tx_lpi_timer) { in igc_ethtool_set_eee()
1789 return -EINVAL; in igc_ethtool_set_eee()
1791 } else if (!edata->eee_enabled) { in igc_ethtool_set_eee()
1794 return -EINVAL; in igc_ethtool_set_eee()
1797 if (hw->dev_spec._base.eee_enable != edata->eee_enabled) { in igc_ethtool_set_eee()
1798 hw->dev_spec._base.eee_enable = edata->eee_enabled; in igc_ethtool_set_eee()
1799 adapter->flags |= IGC_FLAG_EEE; in igc_ethtool_set_eee()
1815 struct igc_fpe_t *fpe = &adapter->fpe; in igc_ethtool_get_mm()
1817 ethtool_mmsv_get_mm(&fpe->mmsv, cmd); in igc_ethtool_get_mm()
1818 cmd->tx_min_frag_size = fpe->tx_min_frag_size; in igc_ethtool_get_mm()
1819 cmd->rx_min_frag_size = IGC_RX_MIN_FRAG_SIZE; in igc_ethtool_get_mm()
1829 struct igc_fpe_t *fpe = &adapter->fpe; in igc_ethtool_set_mm()
1831 fpe->tx_min_frag_size = igc_fpe_get_supported_frag_size(cmd->tx_min_frag_size); in igc_ethtool_set_mm()
1832 if (fpe->tx_min_frag_size != cmd->tx_min_frag_size) in igc_ethtool_set_mm()
1834 … "tx-min-frag-size value set is unsupported. Rounded up to supported value (64, 128, 192, 256)"); in igc_ethtool_set_mm()
1836 if (fpe->mmsv.pmac_enabled != cmd->pmac_enabled) { in igc_ethtool_set_mm()
1837 if (cmd->pmac_enabled) in igc_ethtool_set_mm()
1843 ethtool_mmsv_set_mm(&fpe->mmsv, cmd); in igc_ethtool_set_mm()
1849 * igc_ethtool_get_frame_ass_error - Get the frame assembly error count.
1876 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_mm_stats()
1881 stats->MACMergeFrameAssErrorCount = igc_ethtool_get_frame_ass_error(reg_value); in igc_ethtool_get_mm_stats()
1882 stats->MACMergeFrameSmdErrorCount = igc_ethtool_get_frame_smd_error(reg_value); in igc_ethtool_get_mm_stats()
1883 stats->MACMergeFrameAssOkCount = rd32(IGC_PRMPTDRCNT); in igc_ethtool_get_mm_stats()
1884 stats->MACMergeFragCountRx = rd32(IGC_PRMEVNTRCNT); in igc_ethtool_get_mm_stats()
1885 stats->MACMergeFragCountTx = rd32(IGC_PRMEVNTTCNT); in igc_ethtool_get_mm_stats()
1892 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_link_ksettings()
1908 cmd->base.port = PORT_TP; in igc_ethtool_get_link_ksettings()
1909 cmd->base.phy_address = hw->phy.addr; in igc_ethtool_get_link_ksettings()
1914 if (hw->phy.autoneg_advertised & ADVERTISE_10_HALF) in igc_ethtool_get_link_ksettings()
1916 if (hw->phy.autoneg_advertised & ADVERTISE_10_FULL) in igc_ethtool_get_link_ksettings()
1918 if (hw->phy.autoneg_advertised & ADVERTISE_100_HALF) in igc_ethtool_get_link_ksettings()
1920 if (hw->phy.autoneg_advertised & ADVERTISE_100_FULL) in igc_ethtool_get_link_ksettings()
1922 if (hw->phy.autoneg_advertised & ADVERTISE_1000_FULL) in igc_ethtool_get_link_ksettings()
1924 if (hw->phy.autoneg_advertised & ADVERTISE_2500_FULL) in igc_ethtool_get_link_ksettings()
1934 switch (hw->fc.requested_mode) { in igc_ethtool_get_link_ksettings()
1951 status = pm_runtime_suspended(&adapter->pdev->dev) ? in igc_ethtool_get_link_ksettings()
1961 if (hw->mac.type == igc_i225 && in igc_ethtool_get_link_ksettings()
1973 hw->phy.media_type != igc_media_type_copper) in igc_ethtool_get_link_ksettings()
1974 cmd->base.duplex = DUPLEX_FULL; in igc_ethtool_get_link_ksettings()
1976 cmd->base.duplex = DUPLEX_HALF; in igc_ethtool_get_link_ksettings()
1979 cmd->base.duplex = DUPLEX_UNKNOWN; in igc_ethtool_get_link_ksettings()
1981 cmd->base.speed = speed; in igc_ethtool_get_link_ksettings()
1982 cmd->base.autoneg = AUTONEG_ENABLE; in igc_ethtool_get_link_ksettings()
1984 /* MDI-X => 2; MDI =>1; Invalid =>0 */ in igc_ethtool_get_link_ksettings()
1985 if (hw->phy.media_type == igc_media_type_copper) in igc_ethtool_get_link_ksettings()
1986 cmd->base.eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X : in igc_ethtool_get_link_ksettings()
1989 cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID; in igc_ethtool_get_link_ksettings()
1991 if (hw->phy.mdix == AUTO_ALL_MODES) in igc_ethtool_get_link_ksettings()
1992 cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO; in igc_ethtool_get_link_ksettings()
1994 cmd->base.eth_tp_mdix_ctrl = hw->phy.mdix; in igc_ethtool_get_link_ksettings()
2004 struct net_device *dev = adapter->netdev; in igc_ethtool_set_link_ksettings()
2005 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_link_ksettings()
2013 return -EINVAL; in igc_ethtool_set_link_ksettings()
2020 if (cmd->base.eth_tp_mdix_ctrl) { in igc_ethtool_set_link_ksettings()
2021 if (cmd->base.eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO && in igc_ethtool_set_link_ksettings()
2022 cmd->base.autoneg != AUTONEG_ENABLE) { in igc_ethtool_set_link_ksettings()
2023 …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()
2024 return -EINVAL; in igc_ethtool_set_link_ksettings()
2028 while (test_and_set_bit(__IGC_RESETTING, &adapter->state)) in igc_ethtool_set_link_ksettings()
2055 if (cmd->base.autoneg == AUTONEG_ENABLE) { in igc_ethtool_set_link_ksettings()
2056 hw->phy.autoneg_advertised = advertised; in igc_ethtool_set_link_ksettings()
2057 if (adapter->fc_autoneg) in igc_ethtool_set_link_ksettings()
2058 hw->fc.requested_mode = igc_fc_default; in igc_ethtool_set_link_ksettings()
2063 /* MDI-X => 2; MDI => 1; Auto => 3 */ in igc_ethtool_set_link_ksettings()
2064 if (cmd->base.eth_tp_mdix_ctrl) { in igc_ethtool_set_link_ksettings()
2068 if (cmd->base.eth_tp_mdix_ctrl == ETH_TP_MDI_AUTO) in igc_ethtool_set_link_ksettings()
2069 hw->phy.mdix = AUTO_ALL_MODES; in igc_ethtool_set_link_ksettings()
2071 hw->phy.mdix = cmd->base.eth_tp_mdix_ctrl; in igc_ethtool_set_link_ksettings()
2075 if (netif_running(adapter->netdev)) { in igc_ethtool_set_link_ksettings()
2082 clear_bit(__IGC_RESETTING, &adapter->state); in igc_ethtool_set_link_ksettings()
2093 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in igc_ethtool_diag_test()
2094 netdev_info(adapter->netdev, "Offline testing starting"); in igc_ethtool_diag_test()
2095 set_bit(__IGC_TESTING, &adapter->state); in igc_ethtool_diag_test()
2098 igc_power_up_phy_copper(&adapter->hw); in igc_ethtool_diag_test()
2104 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
2111 netdev_info(adapter->netdev, "Register testing starting"); in igc_ethtool_diag_test()
2113 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
2117 netdev_info(adapter->netdev, "EEPROM testing starting"); in igc_ethtool_diag_test()
2119 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
2129 clear_bit(__IGC_TESTING, &adapter->state); in igc_ethtool_diag_test()
2133 netdev_info(adapter->netdev, "Online testing starting"); in igc_ethtool_diag_test()
2142 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
2195 netdev->ethtool_ops = &igc_ethtool_ops; in igc_ethtool_set_ops()