Lines Matching +full:twisted +full:- +full:pair
1 // SPDX-License-Identifier: GPL-2.0
116 ((((struct igc_adapter *)netdev_priv(netdev))->num_rx_queues * \
118 (((struct igc_adapter *)netdev_priv(netdev))->num_tx_queues * \
125 "legacy-rx",
134 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_drvinfo()
138 strscpy(drvinfo->driver, igc_driver_name, sizeof(drvinfo->driver)); in igc_ethtool_get_drvinfo()
141 hw->nvm.ops.read(hw, IGC_NVM_DEV_STARTER, 1, &nvm_version); in igc_ethtool_get_drvinfo()
146 scnprintf(adapter->fw_version, in igc_ethtool_get_drvinfo()
147 sizeof(adapter->fw_version), in igc_ethtool_get_drvinfo()
152 strscpy(drvinfo->fw_version, adapter->fw_version, in igc_ethtool_get_drvinfo()
153 sizeof(drvinfo->fw_version)); in igc_ethtool_get_drvinfo()
155 strscpy(drvinfo->bus_info, pci_name(adapter->pdev), in igc_ethtool_get_drvinfo()
156 sizeof(drvinfo->bus_info)); in igc_ethtool_get_drvinfo()
158 drvinfo->n_priv_flags = IGC_PRIV_FLAGS_STR_LEN; in igc_ethtool_get_drvinfo()
170 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_regs()
176 regs->version = (2u << 24) | (hw->revision_id << 16) | hw->device_id; in igc_ethtool_get_regs()
231 regs_buff[30] = adapter->stats.crcerrs; in igc_ethtool_get_regs()
232 regs_buff[31] = adapter->stats.algnerrc; in igc_ethtool_get_regs()
233 regs_buff[32] = adapter->stats.symerrs; in igc_ethtool_get_regs()
234 regs_buff[33] = adapter->stats.rxerrc; in igc_ethtool_get_regs()
235 regs_buff[34] = adapter->stats.mpc; in igc_ethtool_get_regs()
236 regs_buff[35] = adapter->stats.scc; in igc_ethtool_get_regs()
237 regs_buff[36] = adapter->stats.ecol; in igc_ethtool_get_regs()
238 regs_buff[37] = adapter->stats.mcc; in igc_ethtool_get_regs()
239 regs_buff[38] = adapter->stats.latecol; in igc_ethtool_get_regs()
240 regs_buff[39] = adapter->stats.colc; in igc_ethtool_get_regs()
241 regs_buff[40] = adapter->stats.dc; in igc_ethtool_get_regs()
242 regs_buff[41] = adapter->stats.tncrs; in igc_ethtool_get_regs()
243 regs_buff[42] = adapter->stats.sec; in igc_ethtool_get_regs()
244 regs_buff[43] = adapter->stats.htdpmc; in igc_ethtool_get_regs()
245 regs_buff[44] = adapter->stats.rlec; in igc_ethtool_get_regs()
246 regs_buff[45] = adapter->stats.xonrxc; in igc_ethtool_get_regs()
247 regs_buff[46] = adapter->stats.xontxc; in igc_ethtool_get_regs()
248 regs_buff[47] = adapter->stats.xoffrxc; in igc_ethtool_get_regs()
249 regs_buff[48] = adapter->stats.xofftxc; in igc_ethtool_get_regs()
250 regs_buff[49] = adapter->stats.fcruc; in igc_ethtool_get_regs()
251 regs_buff[50] = adapter->stats.prc64; in igc_ethtool_get_regs()
252 regs_buff[51] = adapter->stats.prc127; in igc_ethtool_get_regs()
253 regs_buff[52] = adapter->stats.prc255; in igc_ethtool_get_regs()
254 regs_buff[53] = adapter->stats.prc511; in igc_ethtool_get_regs()
255 regs_buff[54] = adapter->stats.prc1023; in igc_ethtool_get_regs()
256 regs_buff[55] = adapter->stats.prc1522; in igc_ethtool_get_regs()
257 regs_buff[56] = adapter->stats.gprc; in igc_ethtool_get_regs()
258 regs_buff[57] = adapter->stats.bprc; in igc_ethtool_get_regs()
259 regs_buff[58] = adapter->stats.mprc; in igc_ethtool_get_regs()
260 regs_buff[59] = adapter->stats.gptc; in igc_ethtool_get_regs()
261 regs_buff[60] = adapter->stats.gorc; in igc_ethtool_get_regs()
262 regs_buff[61] = adapter->stats.gotc; in igc_ethtool_get_regs()
263 regs_buff[62] = adapter->stats.rnbc; in igc_ethtool_get_regs()
264 regs_buff[63] = adapter->stats.ruc; in igc_ethtool_get_regs()
265 regs_buff[64] = adapter->stats.rfc; in igc_ethtool_get_regs()
266 regs_buff[65] = adapter->stats.roc; in igc_ethtool_get_regs()
267 regs_buff[66] = adapter->stats.rjc; in igc_ethtool_get_regs()
268 regs_buff[67] = adapter->stats.mgprc; in igc_ethtool_get_regs()
269 regs_buff[68] = adapter->stats.mgpdc; in igc_ethtool_get_regs()
270 regs_buff[69] = adapter->stats.mgptc; in igc_ethtool_get_regs()
271 regs_buff[70] = adapter->stats.tor; in igc_ethtool_get_regs()
272 regs_buff[71] = adapter->stats.tot; in igc_ethtool_get_regs()
273 regs_buff[72] = adapter->stats.tpr; in igc_ethtool_get_regs()
274 regs_buff[73] = adapter->stats.tpt; in igc_ethtool_get_regs()
275 regs_buff[74] = adapter->stats.ptc64; in igc_ethtool_get_regs()
276 regs_buff[75] = adapter->stats.ptc127; in igc_ethtool_get_regs()
277 regs_buff[76] = adapter->stats.ptc255; in igc_ethtool_get_regs()
278 regs_buff[77] = adapter->stats.ptc511; in igc_ethtool_get_regs()
279 regs_buff[78] = adapter->stats.ptc1023; in igc_ethtool_get_regs()
280 regs_buff[79] = adapter->stats.ptc1522; in igc_ethtool_get_regs()
281 regs_buff[80] = adapter->stats.mptc; in igc_ethtool_get_regs()
282 regs_buff[81] = adapter->stats.bptc; in igc_ethtool_get_regs()
283 regs_buff[82] = adapter->stats.tsctc; in igc_ethtool_get_regs()
284 regs_buff[83] = adapter->stats.iac; in igc_ethtool_get_regs()
285 regs_buff[84] = adapter->stats.rpthc; in igc_ethtool_get_regs()
286 regs_buff[85] = adapter->stats.hgptc; in igc_ethtool_get_regs()
287 regs_buff[86] = adapter->stats.hgorc; in igc_ethtool_get_regs()
288 regs_buff[87] = adapter->stats.hgotc; in igc_ethtool_get_regs()
289 regs_buff[88] = adapter->stats.lenerrs; in igc_ethtool_get_regs()
290 regs_buff[89] = adapter->stats.scvpc; in igc_ethtool_get_regs()
291 regs_buff[90] = adapter->stats.hrmpc; in igc_ethtool_get_regs()
344 regs_buff[213] = adapter->stats.tlpic; in igc_ethtool_get_regs()
345 regs_buff[214] = adapter->stats.rlpic; in igc_ethtool_get_regs()
353 wol->wolopts = 0; in igc_ethtool_get_wol()
355 if (!(adapter->flags & IGC_FLAG_WOL_SUPPORTED)) in igc_ethtool_get_wol()
358 wol->supported = WAKE_UCAST | WAKE_MCAST | in igc_ethtool_get_wol()
363 switch (adapter->hw.device_id) { in igc_ethtool_get_wol()
368 if (adapter->wol & IGC_WUFC_EX) in igc_ethtool_get_wol()
369 wol->wolopts |= WAKE_UCAST; in igc_ethtool_get_wol()
370 if (adapter->wol & IGC_WUFC_MC) in igc_ethtool_get_wol()
371 wol->wolopts |= WAKE_MCAST; in igc_ethtool_get_wol()
372 if (adapter->wol & IGC_WUFC_BC) in igc_ethtool_get_wol()
373 wol->wolopts |= WAKE_BCAST; in igc_ethtool_get_wol()
374 if (adapter->wol & IGC_WUFC_MAG) in igc_ethtool_get_wol()
375 wol->wolopts |= WAKE_MAGIC; in igc_ethtool_get_wol()
376 if (adapter->wol & IGC_WUFC_LNKC) in igc_ethtool_get_wol()
377 wol->wolopts |= WAKE_PHY; in igc_ethtool_get_wol()
385 if (wol->wolopts & (WAKE_ARP | WAKE_MAGICSECURE | WAKE_FILTER)) in igc_ethtool_set_wol()
386 return -EOPNOTSUPP; in igc_ethtool_set_wol()
388 if (!(adapter->flags & IGC_FLAG_WOL_SUPPORTED)) in igc_ethtool_set_wol()
389 return wol->wolopts ? -EOPNOTSUPP : 0; in igc_ethtool_set_wol()
392 adapter->wol = 0; in igc_ethtool_set_wol()
394 if (wol->wolopts & WAKE_UCAST) in igc_ethtool_set_wol()
395 adapter->wol |= IGC_WUFC_EX; in igc_ethtool_set_wol()
396 if (wol->wolopts & WAKE_MCAST) in igc_ethtool_set_wol()
397 adapter->wol |= IGC_WUFC_MC; in igc_ethtool_set_wol()
398 if (wol->wolopts & WAKE_BCAST) in igc_ethtool_set_wol()
399 adapter->wol |= IGC_WUFC_BC; in igc_ethtool_set_wol()
400 if (wol->wolopts & WAKE_MAGIC) in igc_ethtool_set_wol()
401 adapter->wol |= IGC_WUFC_MAG; in igc_ethtool_set_wol()
402 if (wol->wolopts & WAKE_PHY) in igc_ethtool_set_wol()
403 adapter->wol |= IGC_WUFC_LNKC; in igc_ethtool_set_wol()
404 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); in igc_ethtool_set_wol()
413 return adapter->msg_enable; in igc_ethtool_get_msglevel()
420 adapter->msg_enable = data; in igc_ethtool_set_msglevel()
435 struct igc_mac_info *mac = &adapter->hw.mac; in igc_ethtool_get_link()
444 mac->get_link_status = 1; in igc_ethtool_get_link()
453 return adapter->hw.nvm.word_size * 2; in igc_ethtool_get_eeprom_len()
460 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_eeprom()
466 if (eeprom->len == 0) in igc_ethtool_get_eeprom()
467 return -EINVAL; in igc_ethtool_get_eeprom()
469 eeprom->magic = hw->vendor_id | (hw->device_id << 16); in igc_ethtool_get_eeprom()
471 first_word = eeprom->offset >> 1; in igc_ethtool_get_eeprom()
472 last_word = (eeprom->offset + eeprom->len - 1) >> 1; in igc_ethtool_get_eeprom()
474 eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), in igc_ethtool_get_eeprom()
477 return -ENOMEM; in igc_ethtool_get_eeprom()
479 if (hw->nvm.type == igc_nvm_eeprom_spi) { in igc_ethtool_get_eeprom()
480 ret_val = hw->nvm.ops.read(hw, first_word, in igc_ethtool_get_eeprom()
481 last_word - first_word + 1, in igc_ethtool_get_eeprom()
484 for (i = 0; i < last_word - first_word + 1; i++) { in igc_ethtool_get_eeprom()
485 ret_val = hw->nvm.ops.read(hw, first_word + i, 1, in igc_ethtool_get_eeprom()
492 /* Device's eeprom is always little-endian, word addressable */ in igc_ethtool_get_eeprom()
493 for (i = 0; i < last_word - first_word + 1; i++) in igc_ethtool_get_eeprom()
496 memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), in igc_ethtool_get_eeprom()
497 eeprom->len); in igc_ethtool_get_eeprom()
507 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_eeprom()
513 if (eeprom->len == 0) in igc_ethtool_set_eeprom()
514 return -EOPNOTSUPP; in igc_ethtool_set_eeprom()
516 if (hw->mac.type >= igc_i225 && in igc_ethtool_set_eeprom()
518 return -EOPNOTSUPP; in igc_ethtool_set_eeprom()
521 if (eeprom->magic != (hw->vendor_id | (hw->device_id << 16))) in igc_ethtool_set_eeprom()
522 return -EFAULT; in igc_ethtool_set_eeprom()
524 max_len = hw->nvm.word_size * 2; in igc_ethtool_set_eeprom()
526 first_word = eeprom->offset >> 1; in igc_ethtool_set_eeprom()
527 last_word = (eeprom->offset + eeprom->len - 1) >> 1; in igc_ethtool_set_eeprom()
530 return -ENOMEM; in igc_ethtool_set_eeprom()
534 if (eeprom->offset & 1) { in igc_ethtool_set_eeprom()
538 ret_val = hw->nvm.ops.read(hw, first_word, 1, in igc_ethtool_set_eeprom()
542 if (((eeprom->offset + eeprom->len) & 1) && ret_val == 0) { in igc_ethtool_set_eeprom()
546 ret_val = hw->nvm.ops.read(hw, last_word, 1, in igc_ethtool_set_eeprom()
547 &eeprom_buff[last_word - first_word]); in igc_ethtool_set_eeprom()
550 /* Device's eeprom is always little-endian, word addressable */ in igc_ethtool_set_eeprom()
551 for (i = 0; i < last_word - first_word + 1; i++) in igc_ethtool_set_eeprom()
554 memcpy(ptr, bytes, eeprom->len); in igc_ethtool_set_eeprom()
556 for (i = 0; i < last_word - first_word + 1; i++) in igc_ethtool_set_eeprom()
559 ret_val = hw->nvm.ops.write(hw, first_word, in igc_ethtool_set_eeprom()
560 last_word - first_word + 1, eeprom_buff); in igc_ethtool_set_eeprom()
564 hw->nvm.ops.update(hw); in igc_ethtool_set_eeprom()
578 ring->rx_max_pending = IGC_MAX_RXD; in igc_ethtool_get_ringparam()
579 ring->tx_max_pending = IGC_MAX_TXD; in igc_ethtool_get_ringparam()
580 ring->rx_pending = adapter->rx_ring_count; in igc_ethtool_get_ringparam()
581 ring->tx_pending = adapter->tx_ring_count; in igc_ethtool_get_ringparam()
595 if (ring->rx_mini_pending || ring->rx_jumbo_pending) in igc_ethtool_set_ringparam()
596 return -EINVAL; in igc_ethtool_set_ringparam()
598 new_rx_count = min_t(u32, ring->rx_pending, IGC_MAX_RXD); in igc_ethtool_set_ringparam()
602 new_tx_count = min_t(u32, ring->tx_pending, IGC_MAX_TXD); in igc_ethtool_set_ringparam()
606 if (new_tx_count == adapter->tx_ring_count && in igc_ethtool_set_ringparam()
607 new_rx_count == adapter->rx_ring_count) { in igc_ethtool_set_ringparam()
612 while (test_and_set_bit(__IGC_RESETTING, &adapter->state)) in igc_ethtool_set_ringparam()
615 if (!netif_running(adapter->netdev)) { in igc_ethtool_set_ringparam()
616 for (i = 0; i < adapter->num_tx_queues; i++) in igc_ethtool_set_ringparam()
617 adapter->tx_ring[i]->count = new_tx_count; in igc_ethtool_set_ringparam()
618 for (i = 0; i < adapter->num_rx_queues; i++) in igc_ethtool_set_ringparam()
619 adapter->rx_ring[i]->count = new_rx_count; in igc_ethtool_set_ringparam()
620 adapter->tx_ring_count = new_tx_count; in igc_ethtool_set_ringparam()
621 adapter->rx_ring_count = new_rx_count; in igc_ethtool_set_ringparam()
625 if (adapter->num_tx_queues > adapter->num_rx_queues) in igc_ethtool_set_ringparam()
627 adapter->num_tx_queues)); in igc_ethtool_set_ringparam()
630 adapter->num_rx_queues)); in igc_ethtool_set_ringparam()
633 err = -ENOMEM; in igc_ethtool_set_ringparam()
640 * because the ISRs in MSI-X mode get passed pointers in igc_ethtool_set_ringparam()
643 if (new_tx_count != adapter->tx_ring_count) { in igc_ethtool_set_ringparam()
644 for (i = 0; i < adapter->num_tx_queues; i++) { in igc_ethtool_set_ringparam()
645 memcpy(&temp_ring[i], adapter->tx_ring[i], in igc_ethtool_set_ringparam()
652 i--; in igc_ethtool_set_ringparam()
659 for (i = 0; i < adapter->num_tx_queues; i++) { in igc_ethtool_set_ringparam()
660 igc_free_tx_resources(adapter->tx_ring[i]); in igc_ethtool_set_ringparam()
662 memcpy(adapter->tx_ring[i], &temp_ring[i], in igc_ethtool_set_ringparam()
666 adapter->tx_ring_count = new_tx_count; in igc_ethtool_set_ringparam()
669 if (new_rx_count != adapter->rx_ring_count) { in igc_ethtool_set_ringparam()
670 for (i = 0; i < adapter->num_rx_queues; i++) { in igc_ethtool_set_ringparam()
671 memcpy(&temp_ring[i], adapter->rx_ring[i], in igc_ethtool_set_ringparam()
678 i--; in igc_ethtool_set_ringparam()
685 for (i = 0; i < adapter->num_rx_queues; i++) { in igc_ethtool_set_ringparam()
686 igc_free_rx_resources(adapter->rx_ring[i]); in igc_ethtool_set_ringparam()
688 memcpy(adapter->rx_ring[i], &temp_ring[i], in igc_ethtool_set_ringparam()
692 adapter->rx_ring_count = new_rx_count; in igc_ethtool_set_ringparam()
698 clear_bit(__IGC_RESETTING, &adapter->state); in igc_ethtool_set_ringparam()
706 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_pauseparam()
708 pause->autoneg = in igc_ethtool_get_pauseparam()
709 (adapter->fc_autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE); in igc_ethtool_get_pauseparam()
711 if (hw->fc.current_mode == igc_fc_rx_pause) { in igc_ethtool_get_pauseparam()
712 pause->rx_pause = 1; in igc_ethtool_get_pauseparam()
713 } else if (hw->fc.current_mode == igc_fc_tx_pause) { in igc_ethtool_get_pauseparam()
714 pause->tx_pause = 1; in igc_ethtool_get_pauseparam()
715 } else if (hw->fc.current_mode == igc_fc_full) { in igc_ethtool_get_pauseparam()
716 pause->rx_pause = 1; in igc_ethtool_get_pauseparam()
717 pause->tx_pause = 1; in igc_ethtool_get_pauseparam()
725 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_pauseparam()
728 adapter->fc_autoneg = pause->autoneg; in igc_ethtool_set_pauseparam()
730 while (test_and_set_bit(__IGC_RESETTING, &adapter->state)) in igc_ethtool_set_pauseparam()
733 if (adapter->fc_autoneg == AUTONEG_ENABLE) { in igc_ethtool_set_pauseparam()
734 hw->fc.requested_mode = igc_fc_default; in igc_ethtool_set_pauseparam()
735 if (netif_running(adapter->netdev)) { in igc_ethtool_set_pauseparam()
742 if (pause->rx_pause && pause->tx_pause) in igc_ethtool_set_pauseparam()
743 hw->fc.requested_mode = igc_fc_full; in igc_ethtool_set_pauseparam()
744 else if (pause->rx_pause && !pause->tx_pause) in igc_ethtool_set_pauseparam()
745 hw->fc.requested_mode = igc_fc_rx_pause; in igc_ethtool_set_pauseparam()
746 else if (!pause->rx_pause && pause->tx_pause) in igc_ethtool_set_pauseparam()
747 hw->fc.requested_mode = igc_fc_tx_pause; 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_none; in igc_ethtool_set_pauseparam()
751 hw->fc.current_mode = hw->fc.requested_mode; in igc_ethtool_set_pauseparam()
753 retval = ((hw->phy.media_type == igc_media_type_copper) ? in igc_ethtool_set_pauseparam()
757 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_irq(&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_irq(&ring->tx_syncp, start)); in igc_ethtool_get_stats()
848 start = u64_stats_fetch_begin_irq(&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_irq(&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_irq(&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_irq(&ring->rx_syncp, start)); in igc_ethtool_get_stats()
867 spin_unlock(&adapter->stats64_lock); in igc_ethtool_get_stats()
877 if (adapter->rx_itr_setting <= 3) in igc_ethtool_get_coalesce()
878 ec->rx_coalesce_usecs = adapter->rx_itr_setting; in igc_ethtool_get_coalesce()
880 ec->rx_coalesce_usecs = adapter->rx_itr_setting >> 2; in igc_ethtool_get_coalesce()
882 if (!(adapter->flags & IGC_FLAG_QUEUE_PAIRS)) { in igc_ethtool_get_coalesce()
883 if (adapter->tx_itr_setting <= 3) in igc_ethtool_get_coalesce()
884 ec->tx_coalesce_usecs = adapter->tx_itr_setting; in igc_ethtool_get_coalesce()
886 ec->tx_coalesce_usecs = adapter->tx_itr_setting >> 2; in igc_ethtool_get_coalesce()
900 if (ec->rx_coalesce_usecs > IGC_MAX_ITR_USECS || in igc_ethtool_set_coalesce()
901 (ec->rx_coalesce_usecs > 3 && in igc_ethtool_set_coalesce()
902 ec->rx_coalesce_usecs < IGC_MIN_ITR_USECS) || in igc_ethtool_set_coalesce()
903 ec->rx_coalesce_usecs == 2) in igc_ethtool_set_coalesce()
904 return -EINVAL; in igc_ethtool_set_coalesce()
906 if (ec->tx_coalesce_usecs > IGC_MAX_ITR_USECS || in igc_ethtool_set_coalesce()
907 (ec->tx_coalesce_usecs > 3 && in igc_ethtool_set_coalesce()
908 ec->tx_coalesce_usecs < IGC_MIN_ITR_USECS) || in igc_ethtool_set_coalesce()
909 ec->tx_coalesce_usecs == 2) in igc_ethtool_set_coalesce()
910 return -EINVAL; in igc_ethtool_set_coalesce()
912 if ((adapter->flags & IGC_FLAG_QUEUE_PAIRS) && ec->tx_coalesce_usecs) in igc_ethtool_set_coalesce()
913 return -EINVAL; in igc_ethtool_set_coalesce()
916 if (ec->rx_coalesce_usecs == 0) { in igc_ethtool_set_coalesce()
917 if (adapter->flags & IGC_FLAG_DMAC) in igc_ethtool_set_coalesce()
918 adapter->flags &= ~IGC_FLAG_DMAC; in igc_ethtool_set_coalesce()
922 if (ec->rx_coalesce_usecs && ec->rx_coalesce_usecs <= 3) in igc_ethtool_set_coalesce()
923 adapter->rx_itr_setting = ec->rx_coalesce_usecs; in igc_ethtool_set_coalesce()
925 adapter->rx_itr_setting = ec->rx_coalesce_usecs << 2; in igc_ethtool_set_coalesce()
928 if (adapter->flags & IGC_FLAG_QUEUE_PAIRS) in igc_ethtool_set_coalesce()
929 adapter->tx_itr_setting = adapter->rx_itr_setting; in igc_ethtool_set_coalesce()
930 else if (ec->tx_coalesce_usecs && ec->tx_coalesce_usecs <= 3) in igc_ethtool_set_coalesce()
931 adapter->tx_itr_setting = ec->tx_coalesce_usecs; in igc_ethtool_set_coalesce()
933 adapter->tx_itr_setting = ec->tx_coalesce_usecs << 2; in igc_ethtool_set_coalesce()
935 for (i = 0; i < adapter->num_q_vectors; i++) { in igc_ethtool_set_coalesce()
936 struct igc_q_vector *q_vector = adapter->q_vector[i]; in igc_ethtool_set_coalesce()
938 q_vector->tx.work_limit = adapter->tx_work_limit; in igc_ethtool_set_coalesce()
939 if (q_vector->rx.ring) in igc_ethtool_set_coalesce()
940 q_vector->itr_val = adapter->rx_itr_setting; in igc_ethtool_set_coalesce()
942 q_vector->itr_val = adapter->tx_itr_setting; in igc_ethtool_set_coalesce()
943 if (q_vector->itr_val && q_vector->itr_val <= 3) in igc_ethtool_set_coalesce()
944 q_vector->itr_val = IGC_START_ITR; in igc_ethtool_set_coalesce()
945 q_vector->set_itr = 1; in igc_ethtool_set_coalesce()
955 struct ethtool_rx_flow_spec *fsp = &cmd->fs; in igc_ethtool_get_nfc_rule()
958 cmd->data = IGC_MAX_RXNFC_RULES; in igc_ethtool_get_nfc_rule()
960 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rule()
962 rule = igc_get_nfc_rule(adapter, fsp->location); in igc_ethtool_get_nfc_rule()
966 fsp->flow_type = ETHER_FLOW; in igc_ethtool_get_nfc_rule()
967 fsp->ring_cookie = rule->action; in igc_ethtool_get_nfc_rule()
969 if (rule->filter.match_flags & IGC_FILTER_FLAG_ETHER_TYPE) { in igc_ethtool_get_nfc_rule()
970 fsp->h_u.ether_spec.h_proto = htons(rule->filter.etype); in igc_ethtool_get_nfc_rule()
971 fsp->m_u.ether_spec.h_proto = ETHER_TYPE_FULL_MASK; in igc_ethtool_get_nfc_rule()
974 if (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_TCI) { in igc_ethtool_get_nfc_rule()
975 fsp->flow_type |= FLOW_EXT; in igc_ethtool_get_nfc_rule()
976 fsp->h_ext.vlan_tci = htons(rule->filter.vlan_tci); in igc_ethtool_get_nfc_rule()
977 fsp->m_ext.vlan_tci = htons(VLAN_PRIO_MASK); in igc_ethtool_get_nfc_rule()
980 if (rule->filter.match_flags & IGC_FILTER_FLAG_DST_MAC_ADDR) { in igc_ethtool_get_nfc_rule()
981 ether_addr_copy(fsp->h_u.ether_spec.h_dest, in igc_ethtool_get_nfc_rule()
982 rule->filter.dst_addr); in igc_ethtool_get_nfc_rule()
983 eth_broadcast_addr(fsp->m_u.ether_spec.h_dest); in igc_ethtool_get_nfc_rule()
986 if (rule->filter.match_flags & IGC_FILTER_FLAG_SRC_MAC_ADDR) { in igc_ethtool_get_nfc_rule()
987 ether_addr_copy(fsp->h_u.ether_spec.h_source, in igc_ethtool_get_nfc_rule()
988 rule->filter.src_addr); in igc_ethtool_get_nfc_rule()
989 eth_broadcast_addr(fsp->m_u.ether_spec.h_source); in igc_ethtool_get_nfc_rule()
992 if (rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) { in igc_ethtool_get_nfc_rule()
993 fsp->flow_type |= FLOW_EXT; in igc_ethtool_get_nfc_rule()
994 memcpy(fsp->h_ext.data, rule->filter.user_data, sizeof(fsp->h_ext.data)); in igc_ethtool_get_nfc_rule()
995 memcpy(fsp->m_ext.data, rule->filter.user_mask, sizeof(fsp->m_ext.data)); in igc_ethtool_get_nfc_rule()
998 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rule()
1002 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rule()
1003 return -EINVAL; in igc_ethtool_get_nfc_rule()
1013 cmd->data = IGC_MAX_RXNFC_RULES; in igc_ethtool_get_nfc_rules()
1015 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rules()
1017 list_for_each_entry(rule, &adapter->nfc_rule_list, list) { in igc_ethtool_get_nfc_rules()
1018 if (cnt == cmd->rule_cnt) { in igc_ethtool_get_nfc_rules()
1019 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rules()
1020 return -EMSGSIZE; in igc_ethtool_get_nfc_rules()
1022 rule_locs[cnt] = rule->location; in igc_ethtool_get_nfc_rules()
1026 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_get_nfc_rules()
1028 cmd->rule_cnt = cnt; in igc_ethtool_get_nfc_rules()
1036 cmd->data = 0; in igc_ethtool_get_rss_hash_opts()
1039 switch (cmd->flow_type) { in igc_ethtool_get_rss_hash_opts()
1041 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rss_hash_opts()
1044 if (adapter->flags & IGC_FLAG_RSS_FIELD_IPV4_UDP) in igc_ethtool_get_rss_hash_opts()
1045 cmd->data |= RXH_L4_B_0_1 | RXH_L4_B_2_3; in igc_ethtool_get_rss_hash_opts()
1052 cmd->data |= RXH_IP_SRC | RXH_IP_DST; 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_IPV6_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 return -EINVAL; in igc_ethtool_get_rss_hash_opts()
1080 switch (cmd->cmd) { in igc_ethtool_get_rxnfc()
1082 cmd->data = adapter->num_rx_queues; in igc_ethtool_get_rxnfc()
1085 cmd->rule_cnt = adapter->nfc_rule_count; in igc_ethtool_get_rxnfc()
1094 return -EOPNOTSUPP; in igc_ethtool_get_rxnfc()
1103 u32 flags = adapter->flags; in igc_ethtool_set_rss_hash_opt()
1108 if (nfc->data & ~(RXH_IP_SRC | RXH_IP_DST | in igc_ethtool_set_rss_hash_opt()
1110 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1112 switch (nfc->flow_type) { in igc_ethtool_set_rss_hash_opt()
1115 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rss_hash_opt()
1116 !(nfc->data & RXH_IP_DST) || in igc_ethtool_set_rss_hash_opt()
1117 !(nfc->data & RXH_L4_B_0_1) || in igc_ethtool_set_rss_hash_opt()
1118 !(nfc->data & RXH_L4_B_2_3)) in igc_ethtool_set_rss_hash_opt()
1119 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1122 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rss_hash_opt()
1123 !(nfc->data & RXH_IP_DST)) in igc_ethtool_set_rss_hash_opt()
1124 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1125 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { in igc_ethtool_set_rss_hash_opt()
1133 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1137 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rss_hash_opt()
1138 !(nfc->data & RXH_IP_DST)) in igc_ethtool_set_rss_hash_opt()
1139 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1140 switch (nfc->data & (RXH_L4_B_0_1 | RXH_L4_B_2_3)) { in igc_ethtool_set_rss_hash_opt()
1148 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1159 if (!(nfc->data & RXH_IP_SRC) || in igc_ethtool_set_rss_hash_opt()
1160 !(nfc->data & RXH_IP_DST) || in igc_ethtool_set_rss_hash_opt()
1161 (nfc->data & RXH_L4_B_0_1) || in igc_ethtool_set_rss_hash_opt()
1162 (nfc->data & RXH_L4_B_2_3)) in igc_ethtool_set_rss_hash_opt()
1163 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1166 return -EINVAL; in igc_ethtool_set_rss_hash_opt()
1170 if (flags != adapter->flags) { in igc_ethtool_set_rss_hash_opt()
1171 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_rss_hash_opt()
1175 !(adapter->flags & UDP_RSS_FLAGS)) in igc_ethtool_set_rss_hash_opt()
1176 netdev_err(adapter->netdev, in igc_ethtool_set_rss_hash_opt()
1179 adapter->flags = flags; in igc_ethtool_set_rss_hash_opt()
1205 INIT_LIST_HEAD(&rule->list); in igc_ethtool_init_nfc_rule()
1207 rule->action = fsp->ring_cookie; in igc_ethtool_init_nfc_rule()
1208 rule->location = fsp->location; in igc_ethtool_init_nfc_rule()
1210 if ((fsp->flow_type & FLOW_EXT) && fsp->m_ext.vlan_tci) { in igc_ethtool_init_nfc_rule()
1211 rule->filter.vlan_tci = ntohs(fsp->h_ext.vlan_tci); in igc_ethtool_init_nfc_rule()
1212 rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_TCI; in igc_ethtool_init_nfc_rule()
1215 if (fsp->m_u.ether_spec.h_proto == ETHER_TYPE_FULL_MASK) { in igc_ethtool_init_nfc_rule()
1216 rule->filter.etype = ntohs(fsp->h_u.ether_spec.h_proto); in igc_ethtool_init_nfc_rule()
1217 rule->filter.match_flags = IGC_FILTER_FLAG_ETHER_TYPE; in igc_ethtool_init_nfc_rule()
1223 if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_source)) { in igc_ethtool_init_nfc_rule()
1224 rule->filter.match_flags |= IGC_FILTER_FLAG_SRC_MAC_ADDR; in igc_ethtool_init_nfc_rule()
1225 ether_addr_copy(rule->filter.src_addr, in igc_ethtool_init_nfc_rule()
1226 fsp->h_u.ether_spec.h_source); in igc_ethtool_init_nfc_rule()
1229 if (is_broadcast_ether_addr(fsp->m_u.ether_spec.h_dest)) { in igc_ethtool_init_nfc_rule()
1230 rule->filter.match_flags |= IGC_FILTER_FLAG_DST_MAC_ADDR; in igc_ethtool_init_nfc_rule()
1231 ether_addr_copy(rule->filter.dst_addr, in igc_ethtool_init_nfc_rule()
1232 fsp->h_u.ether_spec.h_dest); in igc_ethtool_init_nfc_rule()
1236 if ((fsp->flow_type & FLOW_EXT) && fsp->h_ext.vlan_etype) { in igc_ethtool_init_nfc_rule()
1237 rule->filter.vlan_etype = fsp->h_ext.vlan_etype; in igc_ethtool_init_nfc_rule()
1238 rule->filter.match_flags |= IGC_FILTER_FLAG_VLAN_ETYPE; in igc_ethtool_init_nfc_rule()
1242 if ((fsp->flow_type & FLOW_EXT) && in igc_ethtool_init_nfc_rule()
1243 (fsp->h_ext.data[0] || fsp->h_ext.data[1])) { in igc_ethtool_init_nfc_rule()
1244 rule->filter.match_flags |= IGC_FILTER_FLAG_USER_DATA; in igc_ethtool_init_nfc_rule()
1245 memcpy(rule->filter.user_data, fsp->h_ext.data, sizeof(fsp->h_ext.data)); in igc_ethtool_init_nfc_rule()
1246 memcpy(rule->filter.user_mask, fsp->m_ext.data, sizeof(fsp->m_ext.data)); in igc_ethtool_init_nfc_rule()
1252 if ((rule->filter.match_flags & IGC_FILTER_FLAG_USER_DATA) || in igc_ethtool_init_nfc_rule()
1253 (rule->filter.match_flags & IGC_FILTER_FLAG_VLAN_ETYPE) || in igc_ethtool_init_nfc_rule()
1254 (rule->filter.match_flags & (rule->filter.match_flags - 1))) in igc_ethtool_init_nfc_rule()
1255 rule->flex = true; in igc_ethtool_init_nfc_rule()
1257 rule->flex = false; in igc_ethtool_init_nfc_rule()
1261 * igc_ethtool_check_nfc_rule() - Check if NFC rule is valid
1271 * Context: Expects adapter->nfc_rule_lock to be held by caller.
1278 struct net_device *dev = adapter->netdev; in igc_ethtool_check_nfc_rule()
1279 u8 flags = rule->filter.match_flags; in igc_ethtool_check_nfc_rule()
1284 return -EINVAL; in igc_ethtool_check_nfc_rule()
1287 list_for_each_entry(tmp, &adapter->nfc_rule_list, list) { in igc_ethtool_check_nfc_rule()
1288 if (!memcmp(&rule->filter, &tmp->filter, in igc_ethtool_check_nfc_rule()
1289 sizeof(rule->filter)) && in igc_ethtool_check_nfc_rule()
1290 tmp->location != rule->location) { in igc_ethtool_check_nfc_rule()
1292 return -EEXIST; in igc_ethtool_check_nfc_rule()
1302 struct net_device *netdev = adapter->netdev; in igc_ethtool_add_nfc_rule()
1304 (struct ethtool_rx_flow_spec *)&cmd->fs; in igc_ethtool_add_nfc_rule()
1308 if (!(netdev->hw_features & NETIF_F_NTUPLE)) { in igc_ethtool_add_nfc_rule()
1309 netdev_dbg(netdev, "N-tuple filters disabled\n"); in igc_ethtool_add_nfc_rule()
1310 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1313 if ((fsp->flow_type & ~FLOW_EXT) != ETHER_FLOW) { in igc_ethtool_add_nfc_rule()
1315 return -EOPNOTSUPP; in igc_ethtool_add_nfc_rule()
1318 if (fsp->ring_cookie >= adapter->num_rx_queues) { in igc_ethtool_add_nfc_rule()
1320 return -EINVAL; in igc_ethtool_add_nfc_rule()
1323 if (fsp->location >= IGC_MAX_RXNFC_RULES) { in igc_ethtool_add_nfc_rule()
1325 return -EINVAL; in igc_ethtool_add_nfc_rule()
1330 return -ENOMEM; in igc_ethtool_add_nfc_rule()
1334 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_add_nfc_rule()
1340 old_rule = igc_get_nfc_rule(adapter, fsp->location); in igc_ethtool_add_nfc_rule()
1348 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_add_nfc_rule()
1352 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_add_nfc_rule()
1361 (struct ethtool_rx_flow_spec *)&cmd->fs; in igc_ethtool_del_nfc_rule()
1364 mutex_lock(&adapter->nfc_rule_lock); in igc_ethtool_del_nfc_rule()
1366 rule = igc_get_nfc_rule(adapter, fsp->location); in igc_ethtool_del_nfc_rule()
1368 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_del_nfc_rule()
1369 return -EINVAL; in igc_ethtool_del_nfc_rule()
1374 mutex_unlock(&adapter->nfc_rule_lock); in igc_ethtool_del_nfc_rule()
1383 switch (cmd->cmd) { in igc_ethtool_set_rxnfc()
1391 return -EOPNOTSUPP; in igc_ethtool_set_rxnfc()
1397 struct igc_hw *hw = &adapter->hw; in igc_write_rss_indir_tbl()
1406 for (j = 3; j >= 0; j--) { in igc_write_rss_indir_tbl()
1408 val |= adapter->rss_indir_tbl[i + j]; in igc_write_rss_indir_tbl()
1433 indir[i] = adapter->rss_indir_tbl[i]; in igc_ethtool_get_rxfh()
1448 return -EOPNOTSUPP; in igc_ethtool_set_rxfh()
1452 num_queues = adapter->rss_queues; in igc_ethtool_set_rxfh()
1457 return -EINVAL; in igc_ethtool_set_rxfh()
1460 adapter->rss_indir_tbl[i] = indir[i]; in igc_ethtool_set_rxfh()
1473 ch->max_combined = igc_get_max_rss_queues(adapter); in igc_ethtool_get_channels()
1476 if (adapter->flags & IGC_FLAG_HAS_MSIX) { in igc_ethtool_get_channels()
1477 ch->max_other = NON_Q_VECTORS; in igc_ethtool_get_channels()
1478 ch->other_count = NON_Q_VECTORS; in igc_ethtool_get_channels()
1481 ch->combined_count = adapter->rss_queues; in igc_ethtool_get_channels()
1488 unsigned int count = ch->combined_count; in igc_ethtool_set_channels()
1492 if (!count || ch->rx_count || ch->tx_count) in igc_ethtool_set_channels()
1493 return -EINVAL; in igc_ethtool_set_channels()
1496 if (ch->other_count != NON_Q_VECTORS) in igc_ethtool_set_channels()
1497 return -EINVAL; in igc_ethtool_set_channels()
1502 return -EINVAL; in igc_ethtool_set_channels()
1504 if (count != adapter->rss_queues) { in igc_ethtool_set_channels()
1505 adapter->rss_queues = count; in igc_ethtool_set_channels()
1522 if (adapter->ptp_clock) in igc_ethtool_get_ts_info()
1523 info->phc_index = ptp_clock_index(adapter->ptp_clock); in igc_ethtool_get_ts_info()
1525 info->phc_index = -1; in igc_ethtool_get_ts_info()
1527 switch (adapter->hw.mac.type) { in igc_ethtool_get_ts_info()
1529 info->so_timestamping = in igc_ethtool_get_ts_info()
1537 info->tx_types = in igc_ethtool_get_ts_info()
1541 info->rx_filters = BIT(HWTSTAMP_FILTER_NONE); in igc_ethtool_get_ts_info()
1542 info->rx_filters |= BIT(HWTSTAMP_FILTER_ALL); in igc_ethtool_get_ts_info()
1546 return -EOPNOTSUPP; in igc_ethtool_get_ts_info()
1555 if (adapter->flags & IGC_FLAG_RX_LEGACY) in igc_ethtool_get_priv_flags()
1564 unsigned int flags = adapter->flags; in igc_ethtool_set_priv_flags()
1570 if (flags != adapter->flags) { in igc_ethtool_set_priv_flags()
1571 adapter->flags = flags; in igc_ethtool_set_priv_flags()
1585 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_eee()
1588 if (hw->dev_spec._base.eee_enable) in igc_ethtool_get_eee()
1589 edata->advertised = in igc_ethtool_get_eee()
1590 mmd_eee_adv_to_ethtool_adv_t(adapter->eee_advert); in igc_ethtool_get_eee()
1592 *edata = adapter->eee; in igc_ethtool_get_eee()
1593 edata->supported = SUPPORTED_Autoneg; in igc_ethtool_get_eee()
1599 edata->eee_active = true; in igc_ethtool_get_eee()
1602 edata->tx_lpi_enabled = true; in igc_ethtool_get_eee()
1604 edata->eee_enabled = hw->dev_spec._base.eee_enable; in igc_ethtool_get_eee()
1606 edata->advertised = SUPPORTED_Autoneg; in igc_ethtool_get_eee()
1607 edata->lp_advertised = SUPPORTED_Autoneg; in igc_ethtool_get_eee()
1610 * wrongly report EEE at half-duplex in igc_ethtool_get_eee()
1612 if (adapter->link_duplex == HALF_DUPLEX) { in igc_ethtool_get_eee()
1613 edata->eee_enabled = false; in igc_ethtool_get_eee()
1614 edata->eee_active = false; in igc_ethtool_get_eee()
1615 edata->tx_lpi_enabled = false; in igc_ethtool_get_eee()
1616 edata->advertised &= ~edata->advertised; in igc_ethtool_get_eee()
1626 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_eee()
1636 return -EINVAL; in igc_ethtool_set_eee()
1640 if (eee_curr.tx_lpi_enabled != edata->tx_lpi_enabled) { in igc_ethtool_set_eee()
1642 "Setting EEE tx-lpi is not supported\n"); in igc_ethtool_set_eee()
1643 return -EINVAL; in igc_ethtool_set_eee()
1647 if (edata->tx_lpi_timer) { in igc_ethtool_set_eee()
1650 return -EINVAL; in igc_ethtool_set_eee()
1652 } else if (!edata->eee_enabled) { in igc_ethtool_set_eee()
1655 return -EINVAL; in igc_ethtool_set_eee()
1658 adapter->eee_advert = ethtool_adv_to_mmd_eee_adv_t(edata->advertised); in igc_ethtool_set_eee()
1659 if (hw->dev_spec._base.eee_enable != edata->eee_enabled) { in igc_ethtool_set_eee()
1660 hw->dev_spec._base.eee_enable = edata->eee_enabled; in igc_ethtool_set_eee()
1661 adapter->flags |= IGC_FLAG_EEE; in igc_ethtool_set_eee()
1677 pm_runtime_get_sync(&adapter->pdev->dev); in igc_ethtool_begin()
1685 pm_runtime_put(&adapter->pdev->dev); in igc_ethtool_complete()
1692 struct igc_hw *hw = &adapter->hw; in igc_ethtool_get_link_ksettings()
1707 /* twisted pair */ in igc_ethtool_get_link_ksettings()
1708 cmd->base.port = PORT_TP; in igc_ethtool_get_link_ksettings()
1709 cmd->base.phy_address = hw->phy.addr; in igc_ethtool_get_link_ksettings()
1712 if (hw->phy.autoneg_advertised & ADVERTISE_10_HALF) in igc_ethtool_get_link_ksettings()
1714 if (hw->phy.autoneg_advertised & ADVERTISE_10_FULL) in igc_ethtool_get_link_ksettings()
1716 if (hw->phy.autoneg_advertised & ADVERTISE_100_HALF) in igc_ethtool_get_link_ksettings()
1718 if (hw->phy.autoneg_advertised & ADVERTISE_100_FULL) in igc_ethtool_get_link_ksettings()
1720 if (hw->phy.autoneg_advertised & ADVERTISE_1000_FULL) in igc_ethtool_get_link_ksettings()
1722 if (hw->phy.autoneg_advertised & ADVERTISE_2500_FULL) in igc_ethtool_get_link_ksettings()
1726 if (hw->mac.autoneg == 1) { in igc_ethtool_get_link_ksettings()
1735 switch (hw->fc.requested_mode) { in igc_ethtool_get_link_ksettings()
1752 status = pm_runtime_suspended(&adapter->pdev->dev) ? in igc_ethtool_get_link_ksettings()
1762 if (hw->mac.type == igc_i225 && in igc_ethtool_get_link_ksettings()
1774 hw->phy.media_type != igc_media_type_copper) in igc_ethtool_get_link_ksettings()
1775 cmd->base.duplex = DUPLEX_FULL; in igc_ethtool_get_link_ksettings()
1777 cmd->base.duplex = DUPLEX_HALF; in igc_ethtool_get_link_ksettings()
1780 cmd->base.duplex = DUPLEX_UNKNOWN; in igc_ethtool_get_link_ksettings()
1782 cmd->base.speed = speed; in igc_ethtool_get_link_ksettings()
1783 if (hw->mac.autoneg) in igc_ethtool_get_link_ksettings()
1784 cmd->base.autoneg = AUTONEG_ENABLE; in igc_ethtool_get_link_ksettings()
1786 cmd->base.autoneg = AUTONEG_DISABLE; in igc_ethtool_get_link_ksettings()
1788 /* MDI-X => 2; MDI =>1; Invalid =>0 */ in igc_ethtool_get_link_ksettings()
1789 if (hw->phy.media_type == igc_media_type_copper) in igc_ethtool_get_link_ksettings()
1790 cmd->base.eth_tp_mdix = hw->phy.is_mdix ? ETH_TP_MDI_X : in igc_ethtool_get_link_ksettings()
1793 cmd->base.eth_tp_mdix = ETH_TP_MDI_INVALID; in igc_ethtool_get_link_ksettings()
1795 if (hw->phy.mdix == AUTO_ALL_MODES) in igc_ethtool_get_link_ksettings()
1796 cmd->base.eth_tp_mdix_ctrl = ETH_TP_MDI_AUTO; in igc_ethtool_get_link_ksettings()
1798 cmd->base.eth_tp_mdix_ctrl = hw->phy.mdix; in igc_ethtool_get_link_ksettings()
1808 struct net_device *dev = adapter->netdev; in igc_ethtool_set_link_ksettings()
1809 struct igc_hw *hw = &adapter->hw; in igc_ethtool_set_link_ksettings()
1817 return -EINVAL; in igc_ethtool_set_link_ksettings()
1824 if (cmd->base.eth_tp_mdix_ctrl) { in igc_ethtool_set_link_ksettings()
1825 if (cmd->base.eth_tp_mdix_ctrl != ETH_TP_MDI_AUTO && in igc_ethtool_set_link_ksettings()
1826 cmd->base.autoneg != AUTONEG_ENABLE) { in igc_ethtool_set_link_ksettings()
1827 …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()
1828 return -EINVAL; in igc_ethtool_set_link_ksettings()
1832 while (test_and_set_bit(__IGC_RESETTING, &adapter->state)) in igc_ethtool_set_link_ksettings()
1836 cmd->link_modes.advertising); in igc_ethtool_set_link_ksettings()
1844 if (cmd->base.autoneg == AUTONEG_ENABLE) { in igc_ethtool_set_link_ksettings()
1845 hw->mac.autoneg = 1; in igc_ethtool_set_link_ksettings()
1846 hw->phy.autoneg_advertised = advertising; in igc_ethtool_set_link_ksettings()
1847 if (adapter->fc_autoneg) in igc_ethtool_set_link_ksettings()
1848 hw->fc.requested_mode = igc_fc_default; in igc_ethtool_set_link_ksettings()
1853 /* MDI-X => 2; MDI => 1; Auto => 3 */ in igc_ethtool_set_link_ksettings()
1854 if (cmd->base.eth_tp_mdix_ctrl) { in igc_ethtool_set_link_ksettings()
1858 if (cmd->base.eth_tp_mdix_ctrl == ETH_TP_MDI_AUTO) in igc_ethtool_set_link_ksettings()
1859 hw->phy.mdix = AUTO_ALL_MODES; in igc_ethtool_set_link_ksettings()
1861 hw->phy.mdix = cmd->base.eth_tp_mdix_ctrl; in igc_ethtool_set_link_ksettings()
1865 if (netif_running(adapter->netdev)) { in igc_ethtool_set_link_ksettings()
1872 clear_bit(__IGC_RESETTING, &adapter->state); in igc_ethtool_set_link_ksettings()
1883 if (eth_test->flags == ETH_TEST_FL_OFFLINE) { in igc_ethtool_diag_test()
1884 netdev_info(adapter->netdev, "Offline testing starting"); in igc_ethtool_diag_test()
1885 set_bit(__IGC_TESTING, &adapter->state); in igc_ethtool_diag_test()
1891 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
1898 netdev_info(adapter->netdev, "Register testing starting"); in igc_ethtool_diag_test()
1900 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
1904 netdev_info(adapter->netdev, "EEPROM testing starting"); in igc_ethtool_diag_test()
1906 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
1916 clear_bit(__IGC_TESTING, &adapter->state); in igc_ethtool_diag_test()
1920 netdev_info(adapter->netdev, "Online testing starting"); in igc_ethtool_diag_test()
1929 eth_test->flags |= ETH_TEST_FL_FAILED; in igc_ethtool_diag_test()
1979 netdev->ethtool_ops = &igc_ethtool_ops; in igc_ethtool_set_ops()