Lines Matching +full:cpu +full:- +full:viewed

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2018 Intel Corporation. */
61 "Copyright (c) 1999-2016 Intel Corporation.";
76 /* ixgbe_pci_tbl - PCI Device ID Table
151 …"Maximum number of virtual functions to allocate per physical function - default is zero and maxim…
157 "Allow unsupported and untested SFP+ modules on 82599-based adapters");
160 static int debug = -1;
177 return dev && (dev->netdev_ops == &ixgbe_netdev_ops); in netif_is_ixgbe()
186 parent_bus = adapter->pdev->bus->parent; in ixgbe_read_pci_cfg_word_parent()
188 return -1; in ixgbe_read_pci_cfg_word_parent()
190 parent_dev = parent_bus->self; in ixgbe_read_pci_cfg_word_parent()
192 return -1; in ixgbe_read_pci_cfg_word_parent()
195 return -1; in ixgbe_read_pci_cfg_word_parent()
199 ixgbe_check_cfg_remove(&adapter->hw, parent_dev)) in ixgbe_read_pci_cfg_word_parent()
200 return -1; in ixgbe_read_pci_cfg_word_parent()
206 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_get_parent_bus_info()
210 hw->bus.type = ixgbe_bus_type_pci_express; in ixgbe_get_parent_bus_info()
221 hw->bus.width = ixgbe_convert_bus_width(link_status); in ixgbe_get_parent_bus_info()
222 hw->bus.speed = ixgbe_convert_bus_speed(link_status); in ixgbe_get_parent_bus_info()
228 * ixgbe_check_from_parent - Determine whether PCIe info should come from parent
231 * This function is used by probe to determine whether a device's PCI-Express
238 switch (hw->device_id) { in ixgbe_pcie_from_parent()
250 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_minimum_link()
257 if (hw->bus.type == ixgbe_bus_type_internal) in ixgbe_check_minimum_link()
261 if (ixgbe_pcie_from_parent(&adapter->hw)) in ixgbe_check_minimum_link()
262 pdev = adapter->pdev->bus->parent->self; in ixgbe_check_minimum_link()
264 pdev = adapter->pdev; in ixgbe_check_minimum_link()
271 if (!test_bit(__IXGBE_DOWN, &adapter->state) && in ixgbe_service_event_schedule()
272 !test_bit(__IXGBE_REMOVING, &adapter->state) && in ixgbe_service_event_schedule()
273 !test_and_set_bit(__IXGBE_SERVICE_SCHED, &adapter->state)) in ixgbe_service_event_schedule()
274 queue_work(ixgbe_wq, &adapter->service_task); in ixgbe_service_event_schedule()
279 struct ixgbe_adapter *adapter = hw->back; in ixgbe_remove_adapter()
281 if (!hw->hw_addr) in ixgbe_remove_adapter()
283 hw->hw_addr = NULL; in ixgbe_remove_adapter()
285 if (test_bit(__IXGBE_SERVICE_INITED, &adapter->state)) in ixgbe_remove_adapter()
295 reg_addr = READ_ONCE(hw->hw_addr); in ixgbe_check_remove()
318 * ixgbe_read_reg - Read from device register
332 u8 __iomem *reg_addr = READ_ONCE(hw->hw_addr); in ixgbe_read_reg()
337 if (unlikely(hw->phy.nw_mng_if_sel & in ixgbe_read_reg()
353 adapter = hw->back; in ixgbe_read_reg()
378 struct ixgbe_adapter *adapter = hw->back; in ixgbe_read_pci_cfg_word()
381 if (ixgbe_removed(hw->hw_addr)) in ixgbe_read_pci_cfg_word()
383 pci_read_config_word(adapter->pdev, reg, &value); in ixgbe_read_pci_cfg_word()
385 ixgbe_check_cfg_remove(hw, adapter->pdev)) in ixgbe_read_pci_cfg_word()
393 struct ixgbe_adapter *adapter = hw->back; in ixgbe_read_pci_cfg_dword()
396 if (ixgbe_removed(hw->hw_addr)) in ixgbe_read_pci_cfg_dword()
398 pci_read_config_dword(adapter->pdev, reg, &value); in ixgbe_read_pci_cfg_dword()
400 ixgbe_check_cfg_remove(hw, adapter->pdev)) in ixgbe_read_pci_cfg_dword()
408 struct ixgbe_adapter *adapter = hw->back; in ixgbe_write_pci_cfg_word()
410 if (ixgbe_removed(hw->hw_addr)) in ixgbe_write_pci_cfg_word()
412 pci_write_config_word(adapter->pdev, reg, value); in ixgbe_write_pci_cfg_word()
417 BUG_ON(!test_bit(__IXGBE_SERVICE_SCHED, &adapter->state)); in ixgbe_service_event_complete()
421 clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state); in ixgbe_service_event_complete()
463 * ixgbe_regdump - register printout routine
471 switch (reginfo->ofs) { in ixgbe_regdump()
529 pr_info("%-15s %08x\n", in ixgbe_regdump()
530 reginfo->name, IXGBE_READ_REG(hw, reginfo->ofs)); in ixgbe_regdump()
540 snprintf(rname, 16, "%s[%d-%d]", reginfo->name, i, i + 7); in ixgbe_regdump()
543 pr_err("%-15s%s\n", rname, buf); in ixgbe_regdump()
552 tx_buffer = &ring->tx_buffer_info[ring->next_to_clean]; in ixgbe_print_buffer()
554 n, ring->next_to_use, ring->next_to_clean, in ixgbe_print_buffer()
557 tx_buffer->next_to_watch, in ixgbe_print_buffer()
558 (u64)tx_buffer->time_stamp); in ixgbe_print_buffer()
562 * ixgbe_dump - Print registers, tx-rings and rx-rings
566 struct net_device *netdev = adapter->netdev; in ixgbe_dump()
567 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_dump()
584 dev_info(&adapter->pdev->dev, "Net device Info\n"); in ixgbe_dump()
587 pr_info("%-15s %016lX %016lX\n", in ixgbe_dump()
588 netdev->name, in ixgbe_dump()
589 netdev->state, in ixgbe_dump()
594 dev_info(&adapter->pdev->dev, "Register Dump\n"); in ixgbe_dump()
597 reginfo->name; reginfo++) { in ixgbe_dump()
605 dev_info(&adapter->pdev->dev, "TX Rings Summary\n"); in ixgbe_dump()
607 "Queue [NTU] [NTC] [bi(ntc)->dma ]", in ixgbe_dump()
609 for (n = 0; n < adapter->num_tx_queues; n++) { in ixgbe_dump()
610 ring = adapter->tx_ring[n]; in ixgbe_dump()
614 for (n = 0; n < adapter->num_xdp_queues; n++) { in ixgbe_dump()
615 ring = adapter->xdp_ring[n]; in ixgbe_dump()
623 dev_info(&adapter->pdev->dev, "TX Rings Dump\n"); in ixgbe_dump()
628 * +--------------------------------------------------------------+ in ixgbe_dump()
630 * +--------------------------------------------------------------+ in ixgbe_dump()
632 * +--------------------------------------------------------------+ in ixgbe_dump()
635 * 82598 Advanced Transmit Descriptor (Write-Back Format) in ixgbe_dump()
636 * +--------------------------------------------------------------+ in ixgbe_dump()
638 * +--------------------------------------------------------------+ in ixgbe_dump()
640 * +--------------------------------------------------------------+ in ixgbe_dump()
644 * +--------------------------------------------------------------+ in ixgbe_dump()
646 * +--------------------------------------------------------------+ in ixgbe_dump()
648 * +--------------------------------------------------------------+ in ixgbe_dump()
651 * 82599+ Advanced Transmit Descriptor (Write-Back Format) in ixgbe_dump()
652 * +--------------------------------------------------------------+ in ixgbe_dump()
654 * +--------------------------------------------------------------+ in ixgbe_dump()
656 * +--------------------------------------------------------------+ in ixgbe_dump()
660 for (n = 0; n < adapter->num_tx_queues; n++) { in ixgbe_dump()
661 ring = adapter->tx_ring[n]; in ixgbe_dump()
662 pr_info("------------------------------------\n"); in ixgbe_dump()
663 pr_info("TX QUEUE INDEX = %d\n", ring->queue_index); in ixgbe_dump()
664 pr_info("------------------------------------\n"); in ixgbe_dump()
667 "[PlPOIdStDDt Ln] [bi->dma ] ", in ixgbe_dump()
668 "leng", "ntw", "timestamp", "bi->skb"); in ixgbe_dump()
670 for (i = 0; ring->desc && (i < ring->count); i++) { in ixgbe_dump()
672 tx_buffer = &ring->tx_buffer_info[i]; in ixgbe_dump()
677 if (i == ring->next_to_use && in ixgbe_dump()
678 i == ring->next_to_clean) in ixgbe_dump()
680 else if (i == ring->next_to_use) in ixgbe_dump()
682 else if (i == ring->next_to_clean) in ixgbe_dump()
688 le64_to_cpu((__force __le64)u0->a), in ixgbe_dump()
689 le64_to_cpu((__force __le64)u0->b), in ixgbe_dump()
692 tx_buffer->next_to_watch, in ixgbe_dump()
693 (u64)tx_buffer->time_stamp, in ixgbe_dump()
694 tx_buffer->skb, in ixgbe_dump()
698 tx_buffer->skb) in ixgbe_dump()
701 tx_buffer->skb->data, in ixgbe_dump()
710 dev_info(&adapter->pdev->dev, "RX Rings Summary\n"); in ixgbe_dump()
712 for (n = 0; n < adapter->num_rx_queues; n++) { in ixgbe_dump()
713 rx_ring = adapter->rx_ring[n]; in ixgbe_dump()
715 n, rx_ring->next_to_use, rx_ring->next_to_clean); in ixgbe_dump()
722 dev_info(&adapter->pdev->dev, "RX Rings Dump\n"); in ixgbe_dump()
728 * +-----------------------------------------------------+ in ixgbe_dump()
730 * +----------------------------------------------+------+ in ixgbe_dump()
732 * +-----------------------------------------------------+ in ixgbe_dump()
735 * 82598 Advanced Receive Descriptor (Write-Back) Format in ixgbe_dump()
738 * +------------------------------------------------------+ in ixgbe_dump()
742 * +------------------------------------------------------+ in ixgbe_dump()
744 * +------------------------------------------------------+ in ixgbe_dump()
749 * +-----------------------------------------------------+ in ixgbe_dump()
751 * +----------------------------------------------+------+ in ixgbe_dump()
753 * +-----------------------------------------------------+ in ixgbe_dump()
756 * 82599+ Advanced Receive Descriptor (Write-Back) Format in ixgbe_dump()
759 * +------------------------------------------------------+ in ixgbe_dump()
760 * 0 |RSS / Frag Checksum|SPH| HDR_LEN |RSC- |Packet| RSS | in ixgbe_dump()
763 * +------------------------------------------------------+ in ixgbe_dump()
765 * +------------------------------------------------------+ in ixgbe_dump()
769 for (n = 0; n < adapter->num_rx_queues; n++) { in ixgbe_dump()
770 rx_ring = adapter->rx_ring[n]; in ixgbe_dump()
771 pr_info("------------------------------------\n"); in ixgbe_dump()
772 pr_info("RX QUEUE INDEX = %d\n", rx_ring->queue_index); in ixgbe_dump()
773 pr_info("------------------------------------\n"); in ixgbe_dump()
776 "[ HeadBuf DD] [bi->dma ] [bi->skb ] ", in ixgbe_dump()
777 "<-- Adv Rx Read format"); in ixgbe_dump()
780 "[vl er S cks ln] ---------------- [bi->skb ] ", in ixgbe_dump()
781 "<-- Adv Rx Write-Back format"); in ixgbe_dump()
783 for (i = 0; i < rx_ring->count; i++) { in ixgbe_dump()
786 if (i == rx_ring->next_to_use) in ixgbe_dump()
788 else if (i == rx_ring->next_to_clean) in ixgbe_dump()
793 rx_buffer_info = &rx_ring->rx_buffer_info[i]; in ixgbe_dump()
796 if (rx_desc->wb.upper.length) { in ixgbe_dump()
798 pr_info("RWB[0x%03X] %016llX %016llX ---------------- %p%s\n", in ixgbe_dump()
800 le64_to_cpu((__force __le64)u0->a), in ixgbe_dump()
801 le64_to_cpu((__force __le64)u0->b), in ixgbe_dump()
802 rx_buffer_info->skb, in ixgbe_dump()
807 le64_to_cpu((__force __le64)u0->a), in ixgbe_dump()
808 le64_to_cpu((__force __le64)u0->b), in ixgbe_dump()
809 (u64)rx_buffer_info->dma, in ixgbe_dump()
810 rx_buffer_info->skb, in ixgbe_dump()
814 rx_buffer_info->dma) { in ixgbe_dump()
817 page_address(rx_buffer_info->page) + in ixgbe_dump()
818 rx_buffer_info->page_offset, in ixgbe_dump()
831 ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT); in ixgbe_release_hw_control()
832 IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, in ixgbe_release_hw_control()
841 ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT); in ixgbe_get_hw_control()
842 IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, in ixgbe_get_hw_control()
847 * ixgbe_set_ivar - set the IVAR registers, mapping interrupt causes to vectors
849 * @direction: 0 for Rx, 1 for Tx, -1 for other causes
858 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_ivar()
859 switch (hw->mac.type) { in ixgbe_set_ivar()
862 if (direction == -1) in ixgbe_set_ivar()
875 if (direction == -1) { in ixgbe_set_ivar()
879 ivar = IXGBE_READ_REG(&adapter->hw, IXGBE_IVAR_MISC); in ixgbe_set_ivar()
882 IXGBE_WRITE_REG(&adapter->hw, IXGBE_IVAR_MISC, ivar); in ixgbe_set_ivar()
904 switch (adapter->hw.mac.type) { in ixgbe_irq_rearm_queues()
907 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS, mask); in ixgbe_irq_rearm_queues()
915 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0), mask); in ixgbe_irq_rearm_queues()
917 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1), mask); in ixgbe_irq_rearm_queues()
926 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_xoff_rx_lfc()
927 struct ixgbe_hw_stats *hwstats = &adapter->stats; in ixgbe_update_xoff_rx_lfc()
931 if ((hw->fc.current_mode != ixgbe_fc_full) && in ixgbe_update_xoff_rx_lfc()
932 (hw->fc.current_mode != ixgbe_fc_rx_pause)) in ixgbe_update_xoff_rx_lfc()
935 switch (hw->mac.type) { in ixgbe_update_xoff_rx_lfc()
942 hwstats->lxoffrxc += data; in ixgbe_update_xoff_rx_lfc()
948 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_update_xoff_rx_lfc()
950 &adapter->tx_ring[i]->state); in ixgbe_update_xoff_rx_lfc()
952 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_update_xoff_rx_lfc()
954 &adapter->xdp_ring[i]->state); in ixgbe_update_xoff_rx_lfc()
959 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_xoff_received()
960 struct ixgbe_hw_stats *hwstats = &adapter->stats; in ixgbe_update_xoff_received()
964 bool pfc_en = adapter->dcb_cfg.pfc_mode_enable; in ixgbe_update_xoff_received()
966 if (adapter->ixgbe_ieee_pfc) in ixgbe_update_xoff_received()
967 pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en); in ixgbe_update_xoff_received()
969 if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED) || !pfc_en) { in ixgbe_update_xoff_received()
978 switch (hw->mac.type) { in ixgbe_update_xoff_received()
985 hwstats->pxoffrxc[i] += pxoffrxc; in ixgbe_update_xoff_received()
987 tc = netdev_get_prio_tc_map(adapter->netdev, i); in ixgbe_update_xoff_received()
992 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_update_xoff_received()
993 struct ixgbe_ring *tx_ring = adapter->tx_ring[i]; in ixgbe_update_xoff_received()
995 tc = tx_ring->dcb_tc; in ixgbe_update_xoff_received()
997 clear_bit(__IXGBE_HANG_CHECK_ARMED, &tx_ring->state); in ixgbe_update_xoff_received()
1000 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_update_xoff_received()
1001 struct ixgbe_ring *xdp_ring = adapter->xdp_ring[i]; in ixgbe_update_xoff_received()
1003 tc = xdp_ring->dcb_tc; in ixgbe_update_xoff_received()
1005 clear_bit(__IXGBE_HANG_CHECK_ARMED, &xdp_ring->state); in ixgbe_update_xoff_received()
1011 return ring->stats.packets; in ixgbe_get_tx_completed()
1018 head = ring->next_to_clean; in ixgbe_get_tx_pending()
1019 tail = ring->next_to_use; in ixgbe_get_tx_pending()
1021 return ((head <= tail) ? tail : tail + ring->count) - head; in ixgbe_get_tx_pending()
1027 u32 tx_done_old = tx_ring->tx_stats.tx_done_old; in ixgbe_check_tx_hang()
1047 &tx_ring->state); in ixgbe_check_tx_hang()
1049 tx_ring->tx_stats.tx_done_old = tx_done; in ixgbe_check_tx_hang()
1051 clear_bit(__IXGBE_HANG_CHECK_ARMED, &tx_ring->state); in ixgbe_check_tx_hang()
1057 * ixgbe_tx_timeout_reset - initiate reset due to Tx timeout
1064 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_tx_timeout_reset()
1065 set_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_tx_timeout_reset()
1072 * ixgbe_tx_maxrate - callback to set the maximum per-queue bitrate
1081 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_tx_maxrate()
1105 * ixgbe_clean_tx_irq - Reclaim resources after transmit completes
1113 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_clean_tx_irq()
1117 unsigned int budget = q_vector->tx.work_limit; in ixgbe_clean_tx_irq()
1118 unsigned int i = tx_ring->next_to_clean; in ixgbe_clean_tx_irq()
1120 if (test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_clean_tx_irq()
1123 tx_buffer = &tx_ring->tx_buffer_info[i]; in ixgbe_clean_tx_irq()
1125 i -= tx_ring->count; in ixgbe_clean_tx_irq()
1128 union ixgbe_adv_tx_desc *eop_desc = tx_buffer->next_to_watch; in ixgbe_clean_tx_irq()
1138 if (!(eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD))) in ixgbe_clean_tx_irq()
1142 tx_buffer->next_to_watch = NULL; in ixgbe_clean_tx_irq()
1145 total_bytes += tx_buffer->bytecount; in ixgbe_clean_tx_irq()
1146 total_packets += tx_buffer->gso_segs; in ixgbe_clean_tx_irq()
1147 if (tx_buffer->tx_flags & IXGBE_TX_FLAGS_IPSEC) in ixgbe_clean_tx_irq()
1152 xdp_return_frame(tx_buffer->xdpf); in ixgbe_clean_tx_irq()
1154 napi_consume_skb(tx_buffer->skb, napi_budget); in ixgbe_clean_tx_irq()
1157 dma_unmap_single(tx_ring->dev, in ixgbe_clean_tx_irq()
1171 i -= tx_ring->count; in ixgbe_clean_tx_irq()
1172 tx_buffer = tx_ring->tx_buffer_info; in ixgbe_clean_tx_irq()
1178 dma_unmap_page(tx_ring->dev, in ixgbe_clean_tx_irq()
1191 i -= tx_ring->count; in ixgbe_clean_tx_irq()
1192 tx_buffer = tx_ring->tx_buffer_info; in ixgbe_clean_tx_irq()
1200 budget--; in ixgbe_clean_tx_irq()
1203 i += tx_ring->count; in ixgbe_clean_tx_irq()
1204 tx_ring->next_to_clean = i; in ixgbe_clean_tx_irq()
1205 u64_stats_update_begin(&tx_ring->syncp); in ixgbe_clean_tx_irq()
1206 tx_ring->stats.bytes += total_bytes; in ixgbe_clean_tx_irq()
1207 tx_ring->stats.packets += total_packets; in ixgbe_clean_tx_irq()
1208 u64_stats_update_end(&tx_ring->syncp); in ixgbe_clean_tx_irq()
1209 q_vector->tx.total_bytes += total_bytes; in ixgbe_clean_tx_irq()
1210 q_vector->tx.total_packets += total_packets; in ixgbe_clean_tx_irq()
1211 adapter->tx_ipsec += total_ipsec; in ixgbe_clean_tx_irq()
1215 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_clean_tx_irq()
1225 tx_ring->queue_index, in ixgbe_clean_tx_irq()
1226 IXGBE_READ_REG(hw, IXGBE_TDH(tx_ring->reg_idx)), in ixgbe_clean_tx_irq()
1227 IXGBE_READ_REG(hw, IXGBE_TDT(tx_ring->reg_idx)), in ixgbe_clean_tx_irq()
1228 tx_ring->next_to_use, i, in ixgbe_clean_tx_irq()
1229 tx_ring->tx_buffer_info[i].time_stamp, jiffies); in ixgbe_clean_tx_irq()
1232 netif_stop_subqueue(tx_ring->netdev, in ixgbe_clean_tx_irq()
1233 tx_ring->queue_index); in ixgbe_clean_tx_irq()
1237 adapter->tx_timeout_count + 1, tx_ring->queue_index); in ixgbe_clean_tx_irq()
1253 if (unlikely(total_packets && netif_carrier_ok(tx_ring->netdev) && in ixgbe_clean_tx_irq()
1259 if (__netif_subqueue_stopped(tx_ring->netdev, in ixgbe_clean_tx_irq()
1260 tx_ring->queue_index) in ixgbe_clean_tx_irq()
1261 && !test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_clean_tx_irq()
1262 netif_wake_subqueue(tx_ring->netdev, in ixgbe_clean_tx_irq()
1263 tx_ring->queue_index); in ixgbe_clean_tx_irq()
1264 ++tx_ring->tx_stats.restart_queue; in ixgbe_clean_tx_irq()
1274 int cpu) in ixgbe_update_tx_dca() argument
1276 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_tx_dca()
1280 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in ixgbe_update_tx_dca()
1281 txctrl = dca3_get_tag(tx_ring->dev, cpu); in ixgbe_update_tx_dca()
1283 switch (hw->mac.type) { in ixgbe_update_tx_dca()
1285 reg_offset = IXGBE_DCA_TXCTRL(tx_ring->reg_idx); in ixgbe_update_tx_dca()
1289 reg_offset = IXGBE_DCA_TXCTRL_82599(tx_ring->reg_idx); in ixgbe_update_tx_dca()
1311 int cpu) in ixgbe_update_rx_dca() argument
1313 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_rx_dca()
1315 u8 reg_idx = rx_ring->reg_idx; in ixgbe_update_rx_dca()
1317 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in ixgbe_update_rx_dca()
1318 rxctrl = dca3_get_tag(rx_ring->dev, cpu); in ixgbe_update_rx_dca()
1320 switch (hw->mac.type) { in ixgbe_update_rx_dca()
1343 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_update_dca()
1345 int cpu = get_cpu(); in ixgbe_update_dca() local
1347 if (q_vector->cpu == cpu) in ixgbe_update_dca()
1350 ixgbe_for_each_ring(ring, q_vector->tx) in ixgbe_update_dca()
1351 ixgbe_update_tx_dca(adapter, ring, cpu); in ixgbe_update_dca()
1353 ixgbe_for_each_ring(ring, q_vector->rx) in ixgbe_update_dca()
1354 ixgbe_update_rx_dca(adapter, ring, cpu); in ixgbe_update_dca()
1356 q_vector->cpu = cpu; in ixgbe_update_dca()
1366 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in ixgbe_setup_dca()
1367 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in ixgbe_setup_dca()
1370 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in ixgbe_setup_dca()
1373 for (i = 0; i < adapter->num_q_vectors; i++) { in ixgbe_setup_dca()
1374 adapter->q_vector[i]->cpu = -1; in ixgbe_setup_dca()
1375 ixgbe_update_dca(adapter->q_vector[i]); in ixgbe_setup_dca()
1384 if (!(adapter->flags & IXGBE_FLAG_DCA_CAPABLE)) in __ixgbe_notify_dca()
1390 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in __ixgbe_notify_dca()
1393 adapter->flags |= IXGBE_FLAG_DCA_ENABLED; in __ixgbe_notify_dca()
1394 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in __ixgbe_notify_dca()
1400 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) { in __ixgbe_notify_dca()
1402 adapter->flags &= ~IXGBE_FLAG_DCA_ENABLED; in __ixgbe_notify_dca()
1403 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in __ixgbe_notify_dca()
1426 if (!(ring->netdev->features & NETIF_F_RXHASH)) in ixgbe_rx_hash()
1429 rss_type = le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.pkt_info) & in ixgbe_rx_hash()
1435 skb_set_hash(skb, le32_to_cpu(rx_desc->wb.lower.hi_dword.rss), in ixgbe_rx_hash()
1442 * ixgbe_rx_is_fcoe - check the rx desc for incoming pkt type
1451 __le16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info; in ixgbe_rx_is_fcoe()
1453 return test_bit(__IXGBE_RX_FCOE, &ring->state) && in ixgbe_rx_is_fcoe()
1461 * ixgbe_rx_checksum - indicate in skb if hw indicated a good cksum
1470 __le16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info; in ixgbe_rx_checksum()
1476 if (!(ring->netdev->features & NETIF_F_RXCSUM)) in ixgbe_rx_checksum()
1482 skb->encapsulation = 1; in ixgbe_rx_checksum()
1488 ring->rx_stats.csum_err++; in ixgbe_rx_checksum()
1501 test_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state)) in ixgbe_rx_checksum()
1504 ring->rx_stats.csum_err++; in ixgbe_rx_checksum()
1509 skb->ip_summed = CHECKSUM_UNNECESSARY; in ixgbe_rx_checksum()
1515 skb->ip_summed = CHECKSUM_NONE; in ixgbe_rx_checksum()
1519 skb->csum_level = 1; in ixgbe_rx_checksum()
1531 struct page *page = bi->page; in ixgbe_alloc_mapped_page()
1541 rx_ring->rx_stats.alloc_rx_page_failed++; in ixgbe_alloc_mapped_page()
1546 dma = dma_map_page_attrs(rx_ring->dev, page, 0, in ixgbe_alloc_mapped_page()
1555 if (dma_mapping_error(rx_ring->dev, dma)) { in ixgbe_alloc_mapped_page()
1558 rx_ring->rx_stats.alloc_rx_page_failed++; in ixgbe_alloc_mapped_page()
1562 bi->dma = dma; in ixgbe_alloc_mapped_page()
1563 bi->page = page; in ixgbe_alloc_mapped_page()
1564 bi->page_offset = ixgbe_rx_offset(rx_ring); in ixgbe_alloc_mapped_page()
1565 page_ref_add(page, USHRT_MAX - 1); in ixgbe_alloc_mapped_page()
1566 bi->pagecnt_bias = USHRT_MAX; in ixgbe_alloc_mapped_page()
1567 rx_ring->rx_stats.alloc_rx_page++; in ixgbe_alloc_mapped_page()
1573 * ixgbe_alloc_rx_buffers - Replace used receive buffers
1581 u16 i = rx_ring->next_to_use; in ixgbe_alloc_rx_buffers()
1589 bi = &rx_ring->rx_buffer_info[i]; in ixgbe_alloc_rx_buffers()
1590 i -= rx_ring->count; in ixgbe_alloc_rx_buffers()
1599 dma_sync_single_range_for_device(rx_ring->dev, bi->dma, in ixgbe_alloc_rx_buffers()
1600 bi->page_offset, bufsz, in ixgbe_alloc_rx_buffers()
1605 * because each write-back erases this info. in ixgbe_alloc_rx_buffers()
1607 rx_desc->read.pkt_addr = cpu_to_le64(bi->dma + bi->page_offset); in ixgbe_alloc_rx_buffers()
1614 bi = rx_ring->rx_buffer_info; in ixgbe_alloc_rx_buffers()
1615 i -= rx_ring->count; in ixgbe_alloc_rx_buffers()
1619 rx_desc->wb.upper.length = 0; in ixgbe_alloc_rx_buffers()
1621 cleaned_count--; in ixgbe_alloc_rx_buffers()
1624 i += rx_ring->count; in ixgbe_alloc_rx_buffers()
1626 if (rx_ring->next_to_use != i) { in ixgbe_alloc_rx_buffers()
1627 rx_ring->next_to_use = i; in ixgbe_alloc_rx_buffers()
1630 rx_ring->next_to_alloc = i; in ixgbe_alloc_rx_buffers()
1634 * applicable for weak-ordered memory model archs, in ixgbe_alloc_rx_buffers()
1635 * such as IA-64). in ixgbe_alloc_rx_buffers()
1638 writel(i, rx_ring->tail); in ixgbe_alloc_rx_buffers()
1648 skb_shinfo(skb)->gso_size = DIV_ROUND_UP((skb->len - hdr_len), in ixgbe_set_rsc_gso_size()
1649 IXGBE_CB(skb)->append_cnt); in ixgbe_set_rsc_gso_size()
1650 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; in ixgbe_set_rsc_gso_size()
1657 if (!IXGBE_CB(skb)->append_cnt) in ixgbe_update_rsc_stats()
1660 rx_ring->rx_stats.rsc_count += IXGBE_CB(skb)->append_cnt; in ixgbe_update_rsc_stats()
1661 rx_ring->rx_stats.rsc_flush++; in ixgbe_update_rsc_stats()
1666 IXGBE_CB(skb)->append_cnt = 0; in ixgbe_update_rsc_stats()
1670 * ixgbe_process_skb_fields - Populate skb header fields from Rx descriptor
1683 struct net_device *dev = rx_ring->netdev; in ixgbe_process_skb_fields()
1684 u32 flags = rx_ring->q_vector->adapter->flags; in ixgbe_process_skb_fields()
1695 if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) && in ixgbe_process_skb_fields()
1697 u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); in ixgbe_process_skb_fields()
1706 skb_record_rx_queue(skb, rx_ring->queue_index); in ixgbe_process_skb_fields()
1708 macvlan_count_rx(netdev_priv(dev), skb->len + ETH_HLEN, true, in ixgbe_process_skb_fields()
1711 skb->protocol = eth_type_trans(skb, dev); in ixgbe_process_skb_fields()
1717 napi_gro_receive(&q_vector->napi, skb); in ixgbe_rx_skb()
1721 * ixgbe_is_non_eop - process handling of non-EOP buffers
1729 * that this is in fact a non-EOP buffer.
1735 u32 ntc = rx_ring->next_to_clean + 1; in ixgbe_is_non_eop()
1738 ntc = (ntc < rx_ring->count) ? ntc : 0; in ixgbe_is_non_eop()
1739 rx_ring->next_to_clean = ntc; in ixgbe_is_non_eop()
1745 __le32 rsc_enabled = rx_desc->wb.lower.lo_dword.data & in ixgbe_is_non_eop()
1752 IXGBE_CB(skb)->append_cnt += rsc_cnt - 1; in ixgbe_is_non_eop()
1755 ntc = le32_to_cpu(rx_desc->wb.upper.status_error); in ixgbe_is_non_eop()
1766 rx_ring->rx_buffer_info[ntc].skb = skb; in ixgbe_is_non_eop()
1767 rx_ring->rx_stats.non_eop_descs++; in ixgbe_is_non_eop()
1773 * ixgbe_pull_tail - ixgbe specific version of skb_pull_tail
1787 skb_frag_t *frag = &skb_shinfo(skb)->frags[0]; in ixgbe_pull_tail()
1800 * 60 bytes if the skb->len is less than 60 for skb_pad. in ixgbe_pull_tail()
1802 pull_len = eth_get_headlen(skb->dev, va, IXGBE_RX_HDR_SIZE); in ixgbe_pull_tail()
1810 skb->data_len -= pull_len; in ixgbe_pull_tail()
1811 skb->tail += pull_len; in ixgbe_pull_tail()
1815 * ixgbe_dma_sync_frag - perform DMA sync for first frag of SKB
1828 unsigned long offset = (unsigned long)(skb->data) & ~PAGE_MASK; in ixgbe_dma_sync_frag()
1830 dma_sync_single_range_for_cpu(rx_ring->dev, in ixgbe_dma_sync_frag()
1831 IXGBE_CB(skb)->dma, in ixgbe_dma_sync_frag()
1836 skb_frag_t *frag = &skb_shinfo(skb)->frags[0]; in ixgbe_dma_sync_frag()
1838 dma_sync_single_range_for_cpu(rx_ring->dev, in ixgbe_dma_sync_frag()
1839 IXGBE_CB(skb)->dma, in ixgbe_dma_sync_frag()
1846 if (unlikely(IXGBE_CB(skb)->page_released)) { in ixgbe_dma_sync_frag()
1847 dma_unmap_page_attrs(rx_ring->dev, IXGBE_CB(skb)->dma, in ixgbe_dma_sync_frag()
1855 * ixgbe_cleanup_headers - Correct corrupted or empty headers
1880 struct net_device *netdev = rx_ring->netdev; in ixgbe_cleanup_headers()
1892 !(netdev->features & NETIF_F_RXALL)))) { in ixgbe_cleanup_headers()
1915 * ixgbe_reuse_rx_page - page flip buffer and store it back on the ring
1925 u16 nta = rx_ring->next_to_alloc; in ixgbe_reuse_rx_page()
1927 new_buff = &rx_ring->rx_buffer_info[nta]; in ixgbe_reuse_rx_page()
1931 rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0; in ixgbe_reuse_rx_page()
1937 new_buff->dma = old_buff->dma; in ixgbe_reuse_rx_page()
1938 new_buff->page = old_buff->page; in ixgbe_reuse_rx_page()
1939 new_buff->page_offset = old_buff->page_offset; in ixgbe_reuse_rx_page()
1940 new_buff->pagecnt_bias = old_buff->pagecnt_bias; in ixgbe_reuse_rx_page()
1951 unsigned int pagecnt_bias = rx_buffer->pagecnt_bias; in ixgbe_can_reuse_rx_page()
1952 struct page *page = rx_buffer->page; in ixgbe_can_reuse_rx_page()
1954 /* avoid re-using remote pages */ in ixgbe_can_reuse_rx_page()
1960 if (unlikely((rx_buffer_pgcnt - pagecnt_bias) > 1)) in ixgbe_can_reuse_rx_page()
1969 (SKB_WITH_OVERHEAD(PAGE_SIZE) - IXGBE_RXBUFFER_3K) in ixgbe_can_reuse_rx_page()
1970 if (rx_buffer->page_offset > IXGBE_LAST_OFFSET) in ixgbe_can_reuse_rx_page()
1979 page_ref_add(page, USHRT_MAX - 1); in ixgbe_can_reuse_rx_page()
1980 rx_buffer->pagecnt_bias = USHRT_MAX; in ixgbe_can_reuse_rx_page()
1987 * ixgbe_add_rx_frag - Add contents of Rx buffer to sk_buff
1993 * This function will add the data contained in rx_buffer->page to the skb.
2013 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page, in ixgbe_add_rx_frag()
2014 rx_buffer->page_offset, size, truesize); in ixgbe_add_rx_frag()
2016 rx_buffer->page_offset ^= truesize; in ixgbe_add_rx_frag()
2018 rx_buffer->page_offset += truesize; in ixgbe_add_rx_frag()
2030 rx_buffer = &rx_ring->rx_buffer_info[rx_ring->next_to_clean]; in ixgbe_get_rx_buffer()
2033 page_count(rx_buffer->page); in ixgbe_get_rx_buffer()
2037 prefetchw(rx_buffer->page); in ixgbe_get_rx_buffer()
2038 *skb = rx_buffer->skb; in ixgbe_get_rx_buffer()
2052 /* we are reusing so sync this buffer for CPU use */ in ixgbe_get_rx_buffer()
2053 dma_sync_single_range_for_cpu(rx_ring->dev, in ixgbe_get_rx_buffer()
2054 rx_buffer->dma, in ixgbe_get_rx_buffer()
2055 rx_buffer->page_offset, in ixgbe_get_rx_buffer()
2059 rx_buffer->pagecnt_bias--; in ixgbe_get_rx_buffer()
2073 if (!IS_ERR(skb) && IXGBE_CB(skb)->dma == rx_buffer->dma) { in ixgbe_put_rx_buffer()
2075 IXGBE_CB(skb)->page_released = true; in ixgbe_put_rx_buffer()
2078 dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, in ixgbe_put_rx_buffer()
2083 __page_frag_cache_drain(rx_buffer->page, in ixgbe_put_rx_buffer()
2084 rx_buffer->pagecnt_bias); in ixgbe_put_rx_buffer()
2088 rx_buffer->page = NULL; in ixgbe_put_rx_buffer()
2089 rx_buffer->skb = NULL; in ixgbe_put_rx_buffer()
2097 unsigned int size = xdp->data_end - xdp->data; in ixgbe_construct_skb()
2101 unsigned int truesize = SKB_DATA_ALIGN(xdp->data_end - in ixgbe_construct_skb()
2102 xdp->data_hard_start); in ixgbe_construct_skb()
2107 net_prefetch(xdp->data); in ixgbe_construct_skb()
2109 /* Note, we get here by enabling legacy-rx via: in ixgbe_construct_skb()
2111 * ethtool --set-priv-flags <dev> legacy-rx on in ixgbe_construct_skb()
2114 * opposed to having legacy-rx off, where we process XDP in ixgbe_construct_skb()
2119 * xdp->data_meta will always point to xdp->data, since in ixgbe_construct_skb()
2121 * change in future for legacy-rx mode on, then lets also in ixgbe_construct_skb()
2122 * add xdp->data_meta handling here. in ixgbe_construct_skb()
2126 skb = napi_alloc_skb(&rx_ring->q_vector->napi, IXGBE_RX_HDR_SIZE); in ixgbe_construct_skb()
2132 IXGBE_CB(skb)->dma = rx_buffer->dma; in ixgbe_construct_skb()
2134 skb_add_rx_frag(skb, 0, rx_buffer->page, in ixgbe_construct_skb()
2135 xdp->data - page_address(rx_buffer->page), in ixgbe_construct_skb()
2138 rx_buffer->page_offset ^= truesize; in ixgbe_construct_skb()
2140 rx_buffer->page_offset += truesize; in ixgbe_construct_skb()
2144 xdp->data, ALIGN(size, sizeof(long))); in ixgbe_construct_skb()
2145 rx_buffer->pagecnt_bias++; in ixgbe_construct_skb()
2156 unsigned int metasize = xdp->data - xdp->data_meta; in ixgbe_build_skb()
2161 SKB_DATA_ALIGN(xdp->data_end - in ixgbe_build_skb()
2162 xdp->data_hard_start); in ixgbe_build_skb()
2166 /* Prefetch first cache line of first page. If xdp->data_meta in ixgbe_build_skb()
2167 * is unused, this points extactly as xdp->data, otherwise we in ixgbe_build_skb()
2171 net_prefetch(xdp->data_meta); in ixgbe_build_skb()
2174 skb = build_skb(xdp->data_hard_start, truesize); in ixgbe_build_skb()
2179 skb_reserve(skb, xdp->data - xdp->data_hard_start); in ixgbe_build_skb()
2180 __skb_put(skb, xdp->data_end - xdp->data); in ixgbe_build_skb()
2186 IXGBE_CB(skb)->dma = rx_buffer->dma; in ixgbe_build_skb()
2190 rx_buffer->page_offset ^= truesize; in ixgbe_build_skb()
2192 rx_buffer->page_offset += truesize; in ixgbe_build_skb()
2208 xdp_prog = READ_ONCE(rx_ring->xdp_prog); in ixgbe_run_xdp()
2213 prefetchw(xdp->data_hard_start); /* xdp_frame write */ in ixgbe_run_xdp()
2228 err = xdp_do_redirect(adapter->netdev, xdp, xdp_prog); in ixgbe_run_xdp()
2238 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); in ixgbe_run_xdp()
2246 return ERR_PTR(-result); in ixgbe_run_xdp()
2255 truesize = ixgbe_rx_pg_size(rx_ring) / 2; /* Must be power-of-2 */ in ixgbe_rx_frame_truesize()
2271 rx_buffer->page_offset ^= truesize; in ixgbe_rx_buffer_flip()
2273 rx_buffer->page_offset += truesize; in ixgbe_rx_buffer_flip()
2278 * ixgbe_clean_rx_irq - Clean completed descriptors from Rx ring - bounce buf
2295 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_clean_rx_irq()
2304 xdp.rxq = &rx_ring->xdp_rxq; in ixgbe_clean_rx_irq()
2324 rx_desc = IXGBE_RX_DESC(rx_ring, rx_ring->next_to_clean); in ixgbe_clean_rx_irq()
2325 size = le16_to_cpu(rx_desc->wb.upper.length); in ixgbe_clean_rx_irq()
2339 xdp.data = page_address(rx_buffer->page) + in ixgbe_clean_rx_irq()
2340 rx_buffer->page_offset; in ixgbe_clean_rx_irq()
2342 xdp.data_hard_start = xdp.data - in ixgbe_clean_rx_irq()
2353 unsigned int xdp_res = -PTR_ERR(skb); in ixgbe_clean_rx_irq()
2359 rx_buffer->pagecnt_bias++; in ixgbe_clean_rx_irq()
2375 rx_ring->rx_stats.alloc_rx_buff_failed++; in ixgbe_clean_rx_irq()
2376 rx_buffer->pagecnt_bias++; in ixgbe_clean_rx_irq()
2392 total_rx_bytes += skb->len; in ixgbe_clean_rx_irq()
2404 mss = rx_ring->netdev->mtu - in ixgbe_clean_rx_irq()
2405 sizeof(struct fcoe_hdr) - in ixgbe_clean_rx_irq()
2406 sizeof(struct fc_frame_header) - in ixgbe_clean_rx_irq()
2432 struct ixgbe_ring *ring = adapter->xdp_ring[smp_processor_id()]; in ixgbe_clean_rx_irq()
2438 writel(ring->next_to_use, ring->tail); in ixgbe_clean_rx_irq()
2441 u64_stats_update_begin(&rx_ring->syncp); in ixgbe_clean_rx_irq()
2442 rx_ring->stats.packets += total_rx_packets; in ixgbe_clean_rx_irq()
2443 rx_ring->stats.bytes += total_rx_bytes; in ixgbe_clean_rx_irq()
2444 u64_stats_update_end(&rx_ring->syncp); in ixgbe_clean_rx_irq()
2445 q_vector->rx.total_packets += total_rx_packets; in ixgbe_clean_rx_irq()
2446 q_vector->rx.total_bytes += total_rx_bytes; in ixgbe_clean_rx_irq()
2452 * ixgbe_configure_msix - Configure MSI-X hardware
2455 * ixgbe_configure_msix sets up the hardware to properly generate MSI-X
2465 if (adapter->num_vfs > 32) { in ixgbe_configure_msix()
2466 u32 eitrsel = BIT(adapter->num_vfs - 32) - 1; in ixgbe_configure_msix()
2467 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITRSEL, eitrsel); in ixgbe_configure_msix()
2474 for (v_idx = 0; v_idx < adapter->num_q_vectors; v_idx++) { in ixgbe_configure_msix()
2476 q_vector = adapter->q_vector[v_idx]; in ixgbe_configure_msix()
2478 ixgbe_for_each_ring(ring, q_vector->rx) in ixgbe_configure_msix()
2479 ixgbe_set_ivar(adapter, 0, ring->reg_idx, v_idx); in ixgbe_configure_msix()
2481 ixgbe_for_each_ring(ring, q_vector->tx) in ixgbe_configure_msix()
2482 ixgbe_set_ivar(adapter, 1, ring->reg_idx, v_idx); in ixgbe_configure_msix()
2487 switch (adapter->hw.mac.type) { in ixgbe_configure_msix()
2489 ixgbe_set_ivar(adapter, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX, in ixgbe_configure_msix()
2497 ixgbe_set_ivar(adapter, -1, 1, v_idx); in ixgbe_configure_msix()
2502 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITR(v_idx), 1950); in ixgbe_configure_msix()
2510 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIAC, mask); in ixgbe_configure_msix()
2514 * ixgbe_update_itr - update the dynamic ITR value based on statistics
2537 if (!ring_container->ring) in ixgbe_update_itr()
2540 /* If we didn't update within up to 1 - 2 jiffies we can assume in ixgbe_update_itr()
2545 if (time_after(next_update, ring_container->next_update)) in ixgbe_update_itr()
2548 packets = ring_container->total_packets; in ixgbe_update_itr()
2559 itr = (q_vector->itr >> 2) + IXGBE_ITR_ADAPTIVE_MIN_INC; in ixgbe_update_itr()
2562 itr += ring_container->itr & IXGBE_ITR_ADAPTIVE_LATENCY; in ixgbe_update_itr()
2566 bytes = ring_container->total_bytes; in ixgbe_update_itr()
2582 itr = (q_vector->itr >> 2) + IXGBE_ITR_ADAPTIVE_MIN_INC; in ixgbe_update_itr()
2592 itr = q_vector->itr >> 2; in ixgbe_update_itr()
2601 itr = q_vector->itr >> 3; in ixgbe_update_itr()
2671 switch (q_vector->adapter->link_speed) { in ixgbe_update_itr()
2692 ring_container->itr = itr; in ixgbe_update_itr()
2695 ring_container->next_update = next_update + 1; in ixgbe_update_itr()
2697 ring_container->total_bytes = 0; in ixgbe_update_itr()
2698 ring_container->total_packets = 0; in ixgbe_update_itr()
2702 * ixgbe_write_eitr - write EITR register in hardware specific way
2711 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_write_eitr()
2712 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_write_eitr()
2713 int v_idx = q_vector->v_idx; in ixgbe_write_eitr()
2714 u32 itr_reg = q_vector->itr & IXGBE_MAX_EITR; in ixgbe_write_eitr()
2716 switch (adapter->hw.mac.type) { in ixgbe_write_eitr()
2742 ixgbe_update_itr(q_vector, &q_vector->tx); in ixgbe_set_itr()
2743 ixgbe_update_itr(q_vector, &q_vector->rx); in ixgbe_set_itr()
2746 new_itr = min(q_vector->rx.itr, q_vector->tx.itr); in ixgbe_set_itr()
2752 if (new_itr != q_vector->itr) { in ixgbe_set_itr()
2754 q_vector->itr = new_itr; in ixgbe_set_itr()
2761 * ixgbe_check_overtemp_subtask - check for over temperature
2766 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_overtemp_subtask()
2767 u32 eicr = adapter->interrupt_event; in ixgbe_check_overtemp_subtask()
2770 if (test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_check_overtemp_subtask()
2773 if (!(adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_EVENT)) in ixgbe_check_overtemp_subtask()
2776 adapter->flags2 &= ~IXGBE_FLAG2_TEMP_SENSOR_EVENT; in ixgbe_check_overtemp_subtask()
2778 switch (hw->device_id) { in ixgbe_check_overtemp_subtask()
2783 * - This interrupt wasn't for our port. in ixgbe_check_overtemp_subtask()
2784 * - We may have missed the interrupt so always have to in ixgbe_check_overtemp_subtask()
2791 if (!(eicr & IXGBE_EICR_LSC) && hw->mac.ops.check_link) { in ixgbe_check_overtemp_subtask()
2795 hw->mac.ops.check_link(hw, &speed, &link_up, false); in ixgbe_check_overtemp_subtask()
2802 if (hw->phy.ops.check_overtemp(hw) != IXGBE_ERR_OVERTEMP) in ixgbe_check_overtemp_subtask()
2808 rc = hw->phy.ops.check_overtemp(hw); in ixgbe_check_overtemp_subtask()
2813 if (adapter->hw.mac.type >= ixgbe_mac_X540) in ixgbe_check_overtemp_subtask()
2821 adapter->interrupt_event = 0; in ixgbe_check_overtemp_subtask()
2826 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_fan_failure()
2828 if ((adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) && in ixgbe_check_fan_failure()
2838 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_overtemp_event()
2840 if (!(adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE)) in ixgbe_check_overtemp_event()
2843 switch (adapter->hw.mac.type) { in ixgbe_check_overtemp_event()
2851 (!test_bit(__IXGBE_DOWN, &adapter->state))) { in ixgbe_check_overtemp_event()
2852 adapter->interrupt_event = eicr; in ixgbe_check_overtemp_event()
2853 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_EVENT; in ixgbe_check_overtemp_event()
2860 adapter->interrupt_event = eicr; in ixgbe_check_overtemp_event()
2861 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_EVENT; in ixgbe_check_overtemp_event()
2863 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, in ixgbe_check_overtemp_event()
2865 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICR, in ixgbe_check_overtemp_event()
2883 switch (hw->mac.type) { in ixgbe_is_sfp()
2885 if (hw->phy.type == ixgbe_phy_nl) in ixgbe_is_sfp()
2891 switch (hw->mac.ops.get_media_type(hw)) { in ixgbe_is_sfp()
2905 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_sfp_event()
2912 if (hw->mac.type >= ixgbe_mac_X540) in ixgbe_check_sfp_event()
2918 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_check_sfp_event()
2919 adapter->flags2 |= IXGBE_FLAG2_SFP_NEEDS_RESET; in ixgbe_check_sfp_event()
2920 adapter->sfp_poll_time = 0; in ixgbe_check_sfp_event()
2925 if (adapter->hw.mac.type == ixgbe_mac_82599EB && in ixgbe_check_sfp_event()
2929 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_check_sfp_event()
2930 adapter->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; in ixgbe_check_sfp_event()
2938 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_lsc()
2940 adapter->lsc_int++; in ixgbe_check_lsc()
2941 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_check_lsc()
2942 adapter->link_check_timeout = jiffies; in ixgbe_check_lsc()
2943 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_check_lsc()
2954 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_irq_enable_queues()
2956 switch (hw->mac.type) { in ixgbe_irq_enable_queues()
2980 * ixgbe_irq_enable - Enable default interrupt generation settings
2988 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_irq_enable()
2992 if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE) in ixgbe_irq_enable()
2995 if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) in ixgbe_irq_enable()
2996 switch (adapter->hw.mac.type) { in ixgbe_irq_enable()
3009 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) in ixgbe_irq_enable()
3011 switch (adapter->hw.mac.type) { in ixgbe_irq_enable()
3020 if (adapter->hw.device_id == IXGBE_DEV_ID_X550EM_X_SFP || in ixgbe_irq_enable()
3021 adapter->hw.device_id == IXGBE_DEV_ID_X550EM_A_SFP || in ixgbe_irq_enable()
3022 adapter->hw.device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) in ixgbe_irq_enable()
3023 mask |= IXGBE_EIMS_GPI_SDP0(&adapter->hw); in ixgbe_irq_enable()
3024 if (adapter->hw.phy.type == ixgbe_phy_x550em_ext_t) in ixgbe_irq_enable()
3033 if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) && in ixgbe_irq_enable()
3034 !(adapter->flags2 & IXGBE_FLAG2_FDIR_REQUIRES_REINIT)) in ixgbe_irq_enable()
3037 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask); in ixgbe_irq_enable()
3041 IXGBE_WRITE_FLUSH(&adapter->hw); in ixgbe_irq_enable()
3047 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_msix_other()
3051 * Workaround for Silicon errata. Use clear-by-write instead in ixgbe_msix_other()
3052 * of clear-by-read. Reading with EICS will return the in ixgbe_msix_other()
3075 switch (hw->mac.type) { in ixgbe_msix_other()
3081 if (hw->phy.type == ixgbe_phy_x550em_ext_t && in ixgbe_msix_other()
3083 adapter->flags2 |= IXGBE_FLAG2_PHY_INTERRUPT; in ixgbe_msix_other()
3090 set_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_msix_other()
3098 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_msix_other()
3099 struct ixgbe_ring *ring = adapter->tx_ring[i]; in ixgbe_msix_other()
3101 &ring->state)) in ixgbe_msix_other()
3107 adapter->flags2 |= IXGBE_FLAG2_FDIR_REQUIRES_REINIT; in ixgbe_msix_other()
3123 /* re-enable the original interrupt state, no lsc, no queues */ in ixgbe_msix_other()
3124 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_msix_other()
3136 if (q_vector->rx.ring || q_vector->tx.ring) in ixgbe_msix_clean_rings()
3137 napi_schedule_irqoff(&q_vector->napi); in ixgbe_msix_clean_rings()
3143 * ixgbe_poll - NAPI Rx polling callback
3153 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_poll()
3159 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in ixgbe_poll()
3163 ixgbe_for_each_ring(ring, q_vector->tx) { in ixgbe_poll()
3164 bool wd = ring->xsk_pool ? in ixgbe_poll()
3178 if (q_vector->rx.count > 1) in ixgbe_poll()
3179 per_ring_budget = max(budget/q_vector->rx.count, 1); in ixgbe_poll()
3183 ixgbe_for_each_ring(ring, q_vector->rx) { in ixgbe_poll()
3184 int cleaned = ring->xsk_pool ? in ixgbe_poll()
3201 if (adapter->rx_itr_setting & 1) in ixgbe_poll()
3203 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_poll()
3205 BIT_ULL(q_vector->v_idx)); in ixgbe_poll()
3208 return min(work_done, budget - 1); in ixgbe_poll()
3212 * ixgbe_request_msix_irqs - Initialize MSI-X interrupts
3215 * ixgbe_request_msix_irqs allocates MSI-X vectors and requests
3220 struct net_device *netdev = adapter->netdev; in ixgbe_request_msix_irqs()
3224 for (vector = 0; vector < adapter->num_q_vectors; vector++) { in ixgbe_request_msix_irqs()
3225 struct ixgbe_q_vector *q_vector = adapter->q_vector[vector]; in ixgbe_request_msix_irqs()
3226 struct msix_entry *entry = &adapter->msix_entries[vector]; in ixgbe_request_msix_irqs()
3228 if (q_vector->tx.ring && q_vector->rx.ring) { in ixgbe_request_msix_irqs()
3229 snprintf(q_vector->name, sizeof(q_vector->name), in ixgbe_request_msix_irqs()
3230 "%s-TxRx-%u", netdev->name, ri++); in ixgbe_request_msix_irqs()
3232 } else if (q_vector->rx.ring) { in ixgbe_request_msix_irqs()
3233 snprintf(q_vector->name, sizeof(q_vector->name), in ixgbe_request_msix_irqs()
3234 "%s-rx-%u", netdev->name, ri++); in ixgbe_request_msix_irqs()
3235 } else if (q_vector->tx.ring) { in ixgbe_request_msix_irqs()
3236 snprintf(q_vector->name, sizeof(q_vector->name), in ixgbe_request_msix_irqs()
3237 "%s-tx-%u", netdev->name, ti++); in ixgbe_request_msix_irqs()
3242 err = request_irq(entry->vector, &ixgbe_msix_clean_rings, 0, in ixgbe_request_msix_irqs()
3243 q_vector->name, q_vector); in ixgbe_request_msix_irqs()
3250 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { in ixgbe_request_msix_irqs()
3252 irq_set_affinity_hint(entry->vector, in ixgbe_request_msix_irqs()
3253 &q_vector->affinity_mask); in ixgbe_request_msix_irqs()
3257 err = request_irq(adapter->msix_entries[vector].vector, in ixgbe_request_msix_irqs()
3258 ixgbe_msix_other, 0, netdev->name, adapter); in ixgbe_request_msix_irqs()
3268 vector--; in ixgbe_request_msix_irqs()
3269 irq_set_affinity_hint(adapter->msix_entries[vector].vector, in ixgbe_request_msix_irqs()
3271 free_irq(adapter->msix_entries[vector].vector, in ixgbe_request_msix_irqs()
3272 adapter->q_vector[vector]); in ixgbe_request_msix_irqs()
3274 adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED; in ixgbe_request_msix_irqs()
3275 pci_disable_msix(adapter->pdev); in ixgbe_request_msix_irqs()
3276 kfree(adapter->msix_entries); in ixgbe_request_msix_irqs()
3277 adapter->msix_entries = NULL; in ixgbe_request_msix_irqs()
3282 * ixgbe_intr - legacy mode Interrupt Handler
3289 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_intr()
3290 struct ixgbe_q_vector *q_vector = adapter->q_vector[0]; in ixgbe_intr()
3299 /* for NAPI, using EIAM to auto-mask tx/rx interrupt bits on read in ixgbe_intr()
3310 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_intr()
3318 switch (hw->mac.type) { in ixgbe_intr()
3328 set_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_intr()
3343 napi_schedule_irqoff(&q_vector->napi); in ixgbe_intr()
3346 * re-enable link(maybe) and non-queue interrupts, no flush. in ixgbe_intr()
3347 * ixgbe_poll will re-enable the queue interrupts in ixgbe_intr()
3349 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_intr()
3356 * ixgbe_request_irq - initialize interrupts
3364 struct net_device *netdev = adapter->netdev; in ixgbe_request_irq()
3367 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) in ixgbe_request_irq()
3369 else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) in ixgbe_request_irq()
3370 err = request_irq(adapter->pdev->irq, ixgbe_intr, 0, in ixgbe_request_irq()
3371 netdev->name, adapter); in ixgbe_request_irq()
3373 err = request_irq(adapter->pdev->irq, ixgbe_intr, IRQF_SHARED, in ixgbe_request_irq()
3374 netdev->name, adapter); in ixgbe_request_irq()
3386 if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) { in ixgbe_free_irq()
3387 free_irq(adapter->pdev->irq, adapter); in ixgbe_free_irq()
3391 if (!adapter->msix_entries) in ixgbe_free_irq()
3394 for (vector = 0; vector < adapter->num_q_vectors; vector++) { in ixgbe_free_irq()
3395 struct ixgbe_q_vector *q_vector = adapter->q_vector[vector]; in ixgbe_free_irq()
3396 struct msix_entry *entry = &adapter->msix_entries[vector]; in ixgbe_free_irq()
3399 if (!q_vector->rx.ring && !q_vector->tx.ring) in ixgbe_free_irq()
3403 irq_set_affinity_hint(entry->vector, NULL); in ixgbe_free_irq()
3405 free_irq(entry->vector, q_vector); in ixgbe_free_irq()
3408 free_irq(adapter->msix_entries[vector].vector, adapter); in ixgbe_free_irq()
3412 * ixgbe_irq_disable - Mask off interrupt generation on the NIC
3417 switch (adapter->hw.mac.type) { in ixgbe_irq_disable()
3419 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0); in ixgbe_irq_disable()
3426 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, 0xFFFF0000); in ixgbe_irq_disable()
3427 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(0), ~0); in ixgbe_irq_disable()
3428 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(1), ~0); in ixgbe_irq_disable()
3433 IXGBE_WRITE_FLUSH(&adapter->hw); in ixgbe_irq_disable()
3434 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { in ixgbe_irq_disable()
3437 for (vector = 0; vector < adapter->num_q_vectors; vector++) in ixgbe_irq_disable()
3438 synchronize_irq(adapter->msix_entries[vector].vector); in ixgbe_irq_disable()
3440 synchronize_irq(adapter->msix_entries[vector++].vector); in ixgbe_irq_disable()
3442 synchronize_irq(adapter->pdev->irq); in ixgbe_irq_disable()
3447 * ixgbe_configure_msi_and_legacy - Initialize PIN (INTA...) and MSI interrupts
3453 struct ixgbe_q_vector *q_vector = adapter->q_vector[0]; in ixgbe_configure_msi_and_legacy()
3464 * ixgbe_configure_tx_ring - Configure 8259x Tx ring after Reset
3473 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_tx_ring()
3474 u64 tdba = ring->dma; in ixgbe_configure_tx_ring()
3477 u8 reg_idx = ring->reg_idx; in ixgbe_configure_tx_ring()
3479 ring->xsk_pool = NULL; in ixgbe_configure_tx_ring()
3481 ring->xsk_pool = ixgbe_xsk_pool(adapter, ring); in ixgbe_configure_tx_ring()
3491 ring->count * sizeof(union ixgbe_adv_tx_desc)); in ixgbe_configure_tx_ring()
3494 ring->tail = adapter->io_addr + IXGBE_TDT(reg_idx); in ixgbe_configure_tx_ring()
3499 * - ITR is 0 as it could cause false TX hangs in ixgbe_configure_tx_ring()
3500 * - ITR is set to > 100k int/sec and BQL is enabled in ixgbe_configure_tx_ring()
3506 if (!ring->q_vector || (ring->q_vector->itr < IXGBE_100K_ITR)) in ixgbe_configure_tx_ring()
3519 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { in ixgbe_configure_tx_ring()
3520 ring->atr_sample_rate = adapter->atr_sample_rate; in ixgbe_configure_tx_ring()
3521 ring->atr_count = 0; in ixgbe_configure_tx_ring()
3522 set_bit(__IXGBE_TX_FDIR_INIT_DONE, &ring->state); in ixgbe_configure_tx_ring()
3524 ring->atr_sample_rate = 0; in ixgbe_configure_tx_ring()
3528 if (!test_and_set_bit(__IXGBE_TX_XPS_INIT_DONE, &ring->state)) { in ixgbe_configure_tx_ring()
3529 struct ixgbe_q_vector *q_vector = ring->q_vector; in ixgbe_configure_tx_ring()
3532 netif_set_xps_queue(ring->netdev, in ixgbe_configure_tx_ring()
3533 &q_vector->affinity_mask, in ixgbe_configure_tx_ring()
3534 ring->queue_index); in ixgbe_configure_tx_ring()
3537 clear_bit(__IXGBE_HANG_CHECK_ARMED, &ring->state); in ixgbe_configure_tx_ring()
3540 memset(ring->tx_buffer_info, 0, in ixgbe_configure_tx_ring()
3541 sizeof(struct ixgbe_tx_buffer) * ring->count); in ixgbe_configure_tx_ring()
3547 if (hw->mac.type == ixgbe_mac_82598EB && in ixgbe_configure_tx_ring()
3555 } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); in ixgbe_configure_tx_ring()
3562 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_mtqc()
3564 u8 tcs = adapter->hw_tcs; in ixgbe_setup_mtqc()
3566 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_setup_mtqc()
3575 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { in ixgbe_setup_mtqc()
3581 else if (adapter->ring_feature[RING_F_VMDQ].mask == in ixgbe_setup_mtqc()
3592 u8 max_txq = adapter->num_tx_queues + in ixgbe_setup_mtqc()
3593 adapter->num_xdp_queues; in ixgbe_setup_mtqc()
3610 /* re-enable the arbiter */ in ixgbe_setup_mtqc()
3616 * ixgbe_configure_tx - Configure 8259x Transmit Unit after Reset
3623 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_tx()
3629 if (hw->mac.type != ixgbe_mac_82598EB) { in ixgbe_configure_tx()
3637 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_configure_tx()
3638 ixgbe_configure_tx_ring(adapter, adapter->tx_ring[i]); in ixgbe_configure_tx()
3639 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_configure_tx()
3640 ixgbe_configure_tx_ring(adapter, adapter->xdp_ring[i]); in ixgbe_configure_tx()
3646 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_enable_rx_drop()
3647 u8 reg_idx = ring->reg_idx; in ixgbe_enable_rx_drop()
3658 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_rx_drop()
3659 u8 reg_idx = ring->reg_idx; in ixgbe_disable_rx_drop()
3674 bool pfc_en = adapter->dcb_cfg.pfc_mode_enable; in ixgbe_set_rx_drop_en()
3676 if (adapter->ixgbe_ieee_pfc) in ixgbe_set_rx_drop_en()
3677 pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en); in ixgbe_set_rx_drop_en()
3681 * SR-IOV is enabled in ixgbe_set_rx_drop_en()
3688 if (adapter->num_vfs || (adapter->num_rx_queues > 1 && in ixgbe_set_rx_drop_en()
3689 !(adapter->hw.fc.current_mode & ixgbe_fc_tx_pause) && !pfc_en)) { in ixgbe_set_rx_drop_en()
3690 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_set_rx_drop_en()
3691 ixgbe_enable_rx_drop(adapter, adapter->rx_ring[i]); in ixgbe_set_rx_drop_en()
3693 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_set_rx_drop_en()
3694 ixgbe_disable_rx_drop(adapter, adapter->rx_ring[i]); in ixgbe_set_rx_drop_en()
3703 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_srrctl()
3705 u8 reg_idx = rx_ring->reg_idx; in ixgbe_configure_srrctl()
3707 if (hw->mac.type == ixgbe_mac_82598EB) { in ixgbe_configure_srrctl()
3708 u16 mask = adapter->ring_feature[RING_F_RSS].mask; in ixgbe_configure_srrctl()
3721 if (rx_ring->xsk_pool) { in ixgbe_configure_srrctl()
3722 u32 xsk_buf_len = xsk_pool_get_rx_frame_size(rx_ring->xsk_pool); in ixgbe_configure_srrctl()
3729 * the UMEM buffer size viewed in a 1k resolution will in ixgbe_configure_srrctl()
3732 if (hw->mac.type != ixgbe_mac_82599EB) in ixgbe_configure_srrctl()
3736 } else if (test_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state)) { in ixgbe_configure_srrctl()
3749 * ixgbe_rss_indir_tbl_entries - Return RSS indirection table entries
3752 * - 82598/82599/X540: 128
3753 * - X550(non-SRIOV mode): 512
3754 * - X550(SRIOV mode): 64
3758 if (adapter->hw.mac.type < ixgbe_mac_X550) in ixgbe_rss_indir_tbl_entries()
3760 else if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_rss_indir_tbl_entries()
3767 * ixgbe_store_key - Write the RSS key to HW
3774 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_store_key()
3778 IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), adapter->rss_key[i]); in ixgbe_store_key()
3782 * ixgbe_init_rss_key - Initialize adapter RSS key
3791 if (!adapter->rss_key) { in ixgbe_init_rss_key()
3794 return -ENOMEM; in ixgbe_init_rss_key()
3797 adapter->rss_key = rss_key; in ixgbe_init_rss_key()
3804 * ixgbe_store_reta - Write the RETA table to HW
3812 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_store_reta()
3815 u8 *indir_tbl = adapter->rss_indir_tbl; in ixgbe_store_reta()
3818 * - 82598: 8 bit wide entries containing pair of 4 bit RSS in ixgbe_store_reta()
3820 * - 82599/X540: 8 bit wide entries containing 4 bit RSS index in ixgbe_store_reta()
3821 * - X550: 8 bit wide entries containing 6 bit RSS index in ixgbe_store_reta()
3823 if (adapter->hw.mac.type == ixgbe_mac_82598EB) in ixgbe_store_reta()
3835 IXGBE_WRITE_REG(hw, IXGBE_ERETA((i >> 2) - 32), in ixgbe_store_reta()
3843 * ixgbe_store_vfreta - Write the RETA table to HW (x550 devices in SRIOV mode)
3851 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_store_vfreta()
3856 u16 pool = adapter->num_rx_pools; in ixgbe_store_vfreta()
3858 vfreta |= (u32)adapter->rss_indir_tbl[i] << (i & 0x3) * 8; in ixgbe_store_vfreta()
3862 while (pool--) in ixgbe_store_vfreta()
3874 u16 rss_i = adapter->ring_feature[RING_F_RSS].indices; in ixgbe_setup_reta()
3876 /* Program table for at least 4 queues w/ SR-IOV so that VFs can in ixgbe_setup_reta()
3880 if ((adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) && (rss_i < 4)) in ixgbe_setup_reta()
3887 memset(adapter->rss_indir_tbl, 0, sizeof(adapter->rss_indir_tbl)); in ixgbe_setup_reta()
3893 adapter->rss_indir_tbl[i] = j; in ixgbe_setup_reta()
3901 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_vfreta()
3902 u16 rss_i = adapter->ring_feature[RING_F_RSS].indices; in ixgbe_setup_vfreta()
3907 u16 pool = adapter->num_rx_pools; in ixgbe_setup_vfreta()
3909 while (pool--) in ixgbe_setup_vfreta()
3912 *(adapter->rss_key + i)); in ixgbe_setup_vfreta()
3920 adapter->rss_indir_tbl[i] = j; in ixgbe_setup_vfreta()
3928 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_mrqc()
3937 if (adapter->hw.mac.type == ixgbe_mac_82598EB) { in ixgbe_setup_mrqc()
3938 if (adapter->ring_feature[RING_F_RSS].mask) in ixgbe_setup_mrqc()
3941 u8 tcs = adapter->hw_tcs; in ixgbe_setup_mrqc()
3943 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { in ixgbe_setup_mrqc()
3948 else if (adapter->ring_feature[RING_F_VMDQ].mask == in ixgbe_setup_mrqc()
3957 if (hw->mac.type >= ixgbe_mac_X550) in ixgbe_setup_mrqc()
3975 if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV4_UDP) in ixgbe_setup_mrqc()
3977 if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV6_UDP) in ixgbe_setup_mrqc()
3980 if ((hw->mac.type >= ixgbe_mac_X550) && in ixgbe_setup_mrqc()
3981 (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) { in ixgbe_setup_mrqc()
3982 u16 pool = adapter->num_rx_pools; in ixgbe_setup_mrqc()
3993 while (pool--) in ixgbe_setup_mrqc()
4005 * ixgbe_configure_rscctl - enable RSC for the indicated ring
4012 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_rscctl()
4014 u8 reg_idx = ring->reg_idx; in ixgbe_configure_rscctl()
4034 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_rx_desc_queue_enable()
4037 u8 reg_idx = ring->reg_idx; in ixgbe_rx_desc_queue_enable()
4039 if (ixgbe_removed(hw->hw_addr)) in ixgbe_rx_desc_queue_enable()
4042 if (hw->mac.type == ixgbe_mac_82598EB && in ixgbe_rx_desc_queue_enable()
4049 } while (--wait_loop && !(rxdctl & IXGBE_RXDCTL_ENABLE)); in ixgbe_rx_desc_queue_enable()
4060 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_rx_ring()
4062 u64 rdba = ring->dma; in ixgbe_configure_rx_ring()
4064 u8 reg_idx = ring->reg_idx; in ixgbe_configure_rx_ring()
4066 xdp_rxq_info_unreg_mem_model(&ring->xdp_rxq); in ixgbe_configure_rx_ring()
4067 ring->xsk_pool = ixgbe_xsk_pool(adapter, ring); in ixgbe_configure_rx_ring()
4068 if (ring->xsk_pool) { in ixgbe_configure_rx_ring()
4069 WARN_ON(xdp_rxq_info_reg_mem_model(&ring->xdp_rxq, in ixgbe_configure_rx_ring()
4072 xsk_pool_set_rxq_info(ring->xsk_pool, &ring->xdp_rxq); in ixgbe_configure_rx_ring()
4074 WARN_ON(xdp_rxq_info_reg_mem_model(&ring->xdp_rxq, in ixgbe_configure_rx_ring()
4089 ring->count * sizeof(union ixgbe_adv_rx_desc)); in ixgbe_configure_rx_ring()
4095 ring->tail = adapter->io_addr + IXGBE_RDT(reg_idx); in ixgbe_configure_rx_ring()
4100 if (hw->mac.type == ixgbe_mac_82598EB) { in ixgbe_configure_rx_ring()
4112 } else if (hw->mac.type != ixgbe_mac_82599EB) { in ixgbe_configure_rx_ring()
4121 !test_bit(__IXGBE_RX_3K_BUFFER, &ring->state)) in ixgbe_configure_rx_ring()
4127 if (ring->xsk_pool && hw->mac.type != ixgbe_mac_82599EB) { in ixgbe_configure_rx_ring()
4128 u32 xsk_buf_len = xsk_pool_get_rx_frame_size(ring->xsk_pool); in ixgbe_configure_rx_ring()
4134 ring->rx_buf_len = xsk_buf_len; in ixgbe_configure_rx_ring()
4138 memset(ring->rx_buffer_info, 0, in ixgbe_configure_rx_ring()
4139 sizeof(struct ixgbe_rx_buffer) * ring->count); in ixgbe_configure_rx_ring()
4143 rx_desc->wb.upper.length = 0; in ixgbe_configure_rx_ring()
4150 if (ring->xsk_pool) in ixgbe_configure_rx_ring()
4158 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_psrtype()
4159 int rss_i = adapter->ring_feature[RING_F_RSS].indices; in ixgbe_setup_psrtype()
4160 u16 pool = adapter->num_rx_pools; in ixgbe_setup_psrtype()
4169 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_setup_psrtype()
4177 while (pool--) in ixgbe_setup_psrtype()
4183 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_virtualization()
4184 u16 pool = adapter->num_rx_pools; in ixgbe_configure_virtualization()
4189 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) in ixgbe_configure_virtualization()
4203 while (pool--) in ixgbe_configure_virtualization()
4211 IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset ^ 1), reg_offset - 1); in ixgbe_configure_virtualization()
4213 IXGBE_WRITE_REG(hw, IXGBE_VFTE(reg_offset ^ 1), reg_offset - 1); in ixgbe_configure_virtualization()
4214 if (adapter->bridge_mode == BRIDGE_MODE_VEB) in ixgbe_configure_virtualization()
4218 hw->mac.ops.set_vmdq(hw, 0, VMDQ_P(0)); in ixgbe_configure_virtualization()
4221 adapter->flags2 &= ~IXGBE_FLAG2_VLAN_PROMISC; in ixgbe_configure_virtualization()
4225 * i.e. 32 or 64 VFs for SR-IOV in ixgbe_configure_virtualization()
4227 switch (adapter->ring_feature[RING_F_VMDQ].mask) { in ixgbe_configure_virtualization()
4241 for (i = 0; i < adapter->num_vfs; i++) { in ixgbe_configure_virtualization()
4243 ixgbe_ndo_set_vf_spoofchk(adapter->netdev, i, in ixgbe_configure_virtualization()
4244 adapter->vfinfo[i].spoofchk_enabled); in ixgbe_configure_virtualization()
4247 ixgbe_ndo_set_vf_rss_query_en(adapter->netdev, i, in ixgbe_configure_virtualization()
4248 adapter->vfinfo[i].rss_query_enabled); in ixgbe_configure_virtualization()
4254 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_rx_buffer_len()
4255 struct net_device *netdev = adapter->netdev; in ixgbe_set_rx_buffer_len()
4256 int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; in ixgbe_set_rx_buffer_len()
4263 if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) && in ixgbe_set_rx_buffer_len()
4290 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_set_rx_buffer_len()
4291 rx_ring = adapter->rx_ring[i]; in ixgbe_set_rx_buffer_len()
4294 clear_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4295 clear_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4297 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) in ixgbe_set_rx_buffer_len()
4300 if (test_bit(__IXGBE_RX_FCOE, &rx_ring->state)) in ixgbe_set_rx_buffer_len()
4301 set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4303 if (adapter->flags2 & IXGBE_FLAG2_RX_LEGACY) in ixgbe_set_rx_buffer_len()
4306 set_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4309 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) in ixgbe_set_rx_buffer_len()
4310 set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4314 set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4321 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_rdrxctl()
4324 switch (hw->mac.type) { in ixgbe_setup_rdrxctl()
4341 if (adapter->num_vfs) in ixgbe_setup_rdrxctl()
4363 * ixgbe_configure_rx - Configure 8259x Receive Unit after Reset
4370 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_rx()
4375 hw->mac.ops.disable_rx(hw); in ixgbe_configure_rx()
4383 if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) in ixgbe_configure_rx()
4400 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_configure_rx()
4401 ixgbe_configure_rx_ring(adapter, adapter->rx_ring[i]); in ixgbe_configure_rx()
4405 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_configure_rx()
4410 hw->mac.ops.enable_rx_dma(hw, rxctrl); in ixgbe_configure_rx()
4417 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_rx_add_vid()
4420 if (!vid || !(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC)) in ixgbe_vlan_rx_add_vid()
4421 hw->mac.ops.set_vfta(&adapter->hw, vid, VMDQ_P(0), true, !!vid); in ixgbe_vlan_rx_add_vid()
4423 set_bit(vid, adapter->active_vlans); in ixgbe_vlan_rx_add_vid()
4438 for (idx = IXGBE_VLVF_ENTRIES; --idx;) { in ixgbe_find_vlvf_entry()
4449 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_pf_promisc_vlvf()
4466 if (!(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC)) in ixgbe_update_pf_promisc_vlvf()
4476 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_rx_kill_vid()
4479 if (vid && !(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC)) in ixgbe_vlan_rx_kill_vid()
4480 hw->mac.ops.set_vfta(hw, vid, VMDQ_P(0), false, true); in ixgbe_vlan_rx_kill_vid()
4482 clear_bit(vid, adapter->active_vlans); in ixgbe_vlan_rx_kill_vid()
4488 * ixgbe_vlan_strip_disable - helper to disable hw vlan stripping
4493 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_strip_disable()
4497 switch (hw->mac.type) { in ixgbe_vlan_strip_disable()
4508 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_vlan_strip_disable()
4509 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_vlan_strip_disable()
4511 if (!netif_is_ixgbe(ring->netdev)) in ixgbe_vlan_strip_disable()
4514 j = ring->reg_idx; in ixgbe_vlan_strip_disable()
4526 * ixgbe_vlan_strip_enable - helper to enable hw vlan stripping
4531 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_strip_enable()
4535 switch (hw->mac.type) { in ixgbe_vlan_strip_enable()
4546 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_vlan_strip_enable()
4547 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_vlan_strip_enable()
4549 if (!netif_is_ixgbe(ring->netdev)) in ixgbe_vlan_strip_enable()
4552 j = ring->reg_idx; in ixgbe_vlan_strip_enable()
4565 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_promisc_enable()
4570 if (adapter->flags & IXGBE_FLAG_VMDQ_ENABLED) { in ixgbe_vlan_promisc_enable()
4571 /* For VMDq and SR-IOV we must leave VLAN filtering enabled */ in ixgbe_vlan_promisc_enable()
4581 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_vlan_promisc_enable()
4585 if (adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC) in ixgbe_vlan_promisc_enable()
4589 adapter->flags2 |= IXGBE_FLAG2_VLAN_PROMISC; in ixgbe_vlan_promisc_enable()
4592 for (i = IXGBE_VLVF_ENTRIES; --i;) { in ixgbe_vlan_promisc_enable()
4601 for (i = hw->mac.vft_size; i--;) in ixgbe_vlan_promisc_enable()
4608 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_scrub_vfta()
4614 for (i = IXGBE_VLVF_ENTRIES; --i;) { in ixgbe_scrub_vfta()
4626 vfta[(vid - vid_start) / 32] |= BIT(vid % 32); in ixgbe_scrub_vfta()
4629 if (test_bit(vid, adapter->active_vlans)) in ixgbe_scrub_vfta()
4641 for (i = VFTA_BLOCK_SIZE; i--;) { in ixgbe_scrub_vfta()
4646 vfta[i] |= adapter->active_vlans[word] >> bits; in ixgbe_scrub_vfta()
4654 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_promisc_disable()
4662 if (!(adapter->flags & IXGBE_FLAG_VMDQ_ENABLED) || in ixgbe_vlan_promisc_disable()
4663 hw->mac.type == ixgbe_mac_82598EB) in ixgbe_vlan_promisc_disable()
4667 if (!(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC)) in ixgbe_vlan_promisc_disable()
4671 adapter->flags2 &= ~IXGBE_FLAG2_VLAN_PROMISC; in ixgbe_vlan_promisc_disable()
4673 for (i = 0; i < hw->mac.vft_size; i += VFTA_BLOCK_SIZE) in ixgbe_vlan_promisc_disable()
4681 ixgbe_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), 0); in ixgbe_restore_vlan()
4683 for_each_set_bit_from(vid, adapter->active_vlans, VLAN_N_VID) in ixgbe_restore_vlan()
4684 ixgbe_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid); in ixgbe_restore_vlan()
4688 * ixgbe_write_mc_addr_list - write multicast addresses to MTA
4692 * Returns: -ENOMEM on failure
4699 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_write_mc_addr_list()
4704 if (hw->mac.ops.update_mc_addr_list) in ixgbe_write_mc_addr_list()
4705 hw->mac.ops.update_mc_addr_list(hw, netdev); in ixgbe_write_mc_addr_list()
4707 return -ENOMEM; in ixgbe_write_mc_addr_list()
4719 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_full_sync_mac_table()
4720 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_full_sync_mac_table()
4723 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_full_sync_mac_table()
4724 mac_table->state &= ~IXGBE_MAC_STATE_MODIFIED; in ixgbe_full_sync_mac_table()
4726 if (mac_table->state & IXGBE_MAC_STATE_IN_USE) in ixgbe_full_sync_mac_table()
4727 hw->mac.ops.set_rar(hw, i, in ixgbe_full_sync_mac_table()
4728 mac_table->addr, in ixgbe_full_sync_mac_table()
4729 mac_table->pool, in ixgbe_full_sync_mac_table()
4732 hw->mac.ops.clear_rar(hw, i); in ixgbe_full_sync_mac_table()
4739 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_sync_mac_table()
4740 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_sync_mac_table()
4743 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_sync_mac_table()
4744 if (!(mac_table->state & IXGBE_MAC_STATE_MODIFIED)) in ixgbe_sync_mac_table()
4747 mac_table->state &= ~IXGBE_MAC_STATE_MODIFIED; in ixgbe_sync_mac_table()
4749 if (mac_table->state & IXGBE_MAC_STATE_IN_USE) in ixgbe_sync_mac_table()
4750 hw->mac.ops.set_rar(hw, i, in ixgbe_sync_mac_table()
4751 mac_table->addr, in ixgbe_sync_mac_table()
4752 mac_table->pool, in ixgbe_sync_mac_table()
4755 hw->mac.ops.clear_rar(hw, i); in ixgbe_sync_mac_table()
4761 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_flush_sw_mac_table()
4762 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_flush_sw_mac_table()
4765 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_flush_sw_mac_table()
4766 mac_table->state |= IXGBE_MAC_STATE_MODIFIED; in ixgbe_flush_sw_mac_table()
4767 mac_table->state &= ~IXGBE_MAC_STATE_IN_USE; in ixgbe_flush_sw_mac_table()
4775 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_available_rars()
4776 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_available_rars()
4779 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_available_rars()
4781 if (mac_table->state & IXGBE_MAC_STATE_DEFAULT) in ixgbe_available_rars()
4785 if (mac_table->state & IXGBE_MAC_STATE_IN_USE) { in ixgbe_available_rars()
4786 if (mac_table->pool != pool) in ixgbe_available_rars()
4799 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_mac_set_default_filter()
4800 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_mac_set_default_filter()
4802 memcpy(&mac_table->addr, hw->mac.addr, ETH_ALEN); in ixgbe_mac_set_default_filter()
4803 mac_table->pool = VMDQ_P(0); in ixgbe_mac_set_default_filter()
4805 mac_table->state = IXGBE_MAC_STATE_DEFAULT | IXGBE_MAC_STATE_IN_USE; in ixgbe_mac_set_default_filter()
4807 hw->mac.ops.set_rar(hw, 0, mac_table->addr, mac_table->pool, in ixgbe_mac_set_default_filter()
4814 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_add_mac_filter()
4815 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_add_mac_filter()
4819 return -EINVAL; in ixgbe_add_mac_filter()
4821 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_add_mac_filter()
4822 if (mac_table->state & IXGBE_MAC_STATE_IN_USE) in ixgbe_add_mac_filter()
4825 ether_addr_copy(mac_table->addr, addr); in ixgbe_add_mac_filter()
4826 mac_table->pool = pool; in ixgbe_add_mac_filter()
4828 mac_table->state |= IXGBE_MAC_STATE_MODIFIED | in ixgbe_add_mac_filter()
4836 return -ENOMEM; in ixgbe_add_mac_filter()
4842 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_del_mac_filter()
4843 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_del_mac_filter()
4847 return -EINVAL; in ixgbe_del_mac_filter()
4850 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_del_mac_filter()
4852 if (!(mac_table->state & IXGBE_MAC_STATE_IN_USE)) in ixgbe_del_mac_filter()
4855 if (mac_table->pool != pool) in ixgbe_del_mac_filter()
4858 if (!ether_addr_equal(addr, mac_table->addr)) in ixgbe_del_mac_filter()
4861 mac_table->state |= IXGBE_MAC_STATE_MODIFIED; in ixgbe_del_mac_filter()
4862 mac_table->state &= ~IXGBE_MAC_STATE_IN_USE; in ixgbe_del_mac_filter()
4869 return -ENOMEM; in ixgbe_del_mac_filter()
4892 * ixgbe_set_rx_mode - Unicast, Multicast and Promiscuous mode set
4903 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_rx_mode()
4905 netdev_features_t features = netdev->features; in ixgbe_set_rx_mode()
4912 fctrl &= ~IXGBE_FCTRL_SBP; /* disable store-bad-packets */ in ixgbe_set_rx_mode()
4919 if (netdev->flags & IFF_PROMISC) { in ixgbe_set_rx_mode()
4920 hw->addr_ctrl.user_set_promisc = true; in ixgbe_set_rx_mode()
4925 if (netdev->flags & IFF_ALLMULTI) { in ixgbe_set_rx_mode()
4929 hw->addr_ctrl.user_set_promisc = false; in ixgbe_set_rx_mode()
4954 if (hw->mac.type != ixgbe_mac_82598EB) { in ixgbe_set_rx_mode()
4990 for (q_idx = 0; q_idx < adapter->num_q_vectors; q_idx++) in ixgbe_napi_enable_all()
4991 napi_enable(&adapter->q_vector[q_idx]->napi); in ixgbe_napi_enable_all()
4998 for (q_idx = 0; q_idx < adapter->num_q_vectors; q_idx++) in ixgbe_napi_disable_all()
4999 napi_disable(&adapter->q_vector[q_idx]->napi); in ixgbe_napi_disable_all()
5005 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_udp_tunnel_sync()
5010 adapter->vxlan_port = ti.port; in ixgbe_udp_tunnel_sync()
5012 adapter->geneve_port = ti.port; in ixgbe_udp_tunnel_sync()
5015 ntohs(adapter->vxlan_port) | in ixgbe_udp_tunnel_sync()
5016 ntohs(adapter->geneve_port) << in ixgbe_udp_tunnel_sync()
5040 * ixgbe_configure_dcb - Configure DCB hardware
5049 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_dcb()
5050 int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN; in ixgbe_configure_dcb()
5052 if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED)) { in ixgbe_configure_dcb()
5053 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_configure_dcb()
5054 netif_set_gso_max_size(adapter->netdev, 65536); in ixgbe_configure_dcb()
5058 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_configure_dcb()
5059 netif_set_gso_max_size(adapter->netdev, 32768); in ixgbe_configure_dcb()
5062 if (adapter->netdev->features & NETIF_F_FCOE_MTU) in ixgbe_configure_dcb()
5067 if (adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE) { in ixgbe_configure_dcb()
5068 ixgbe_dcb_calculate_tc_credits(hw, &adapter->dcb_cfg, max_frame, in ixgbe_configure_dcb()
5070 ixgbe_dcb_calculate_tc_credits(hw, &adapter->dcb_cfg, max_frame, in ixgbe_configure_dcb()
5072 ixgbe_dcb_hw_config(hw, &adapter->dcb_cfg); in ixgbe_configure_dcb()
5073 } else if (adapter->ixgbe_ieee_ets && adapter->ixgbe_ieee_pfc) { in ixgbe_configure_dcb()
5074 ixgbe_dcb_hw_ets(&adapter->hw, in ixgbe_configure_dcb()
5075 adapter->ixgbe_ieee_ets, in ixgbe_configure_dcb()
5077 ixgbe_dcb_hw_pfc_config(&adapter->hw, in ixgbe_configure_dcb()
5078 adapter->ixgbe_ieee_pfc->pfc_en, in ixgbe_configure_dcb()
5079 adapter->ixgbe_ieee_ets->prio_tc); in ixgbe_configure_dcb()
5083 if (hw->mac.type != ixgbe_mac_82598EB) { in ixgbe_configure_dcb()
5085 u16 rss_i = adapter->ring_feature[RING_F_RSS].indices - 1; in ixgbe_configure_dcb()
5102 * ixgbe_hpbthresh - calculate high water mark for flow control
5109 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_hpbthresh()
5110 struct net_device *dev = adapter->netdev; in ixgbe_hpbthresh()
5115 tc = link = dev->mtu + ETH_HLEN + ETH_FCS_LEN + IXGBE_ETH_FRAMING; in ixgbe_hpbthresh()
5119 if ((dev->features & NETIF_F_FCOE_MTU) && in ixgbe_hpbthresh()
5126 switch (hw->mac.type) { in ixgbe_hpbthresh()
5139 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_hpbthresh()
5146 marker = rx_pba - kb; in ixgbe_hpbthresh()
5163 * ixgbe_lpbthresh - calculate low water mark for for flow control
5170 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_lpbthresh()
5171 struct net_device *dev = adapter->netdev; in ixgbe_lpbthresh()
5176 tc = dev->mtu + ETH_HLEN + ETH_FCS_LEN; in ixgbe_lpbthresh()
5180 if ((dev->features & NETIF_F_FCOE_MTU) && in ixgbe_lpbthresh()
5182 (pb == netdev_get_prio_tc_map(dev, adapter->fcoe.up))) in ixgbe_lpbthresh()
5187 switch (hw->mac.type) { in ixgbe_lpbthresh()
5204 * ixgbe_pbthresh_setup - calculate and setup high low water marks
5208 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_pbthresh_setup()
5209 int num_tc = adapter->hw_tcs; in ixgbe_pbthresh_setup()
5216 hw->fc.high_water[i] = ixgbe_hpbthresh(adapter, i); in ixgbe_pbthresh_setup()
5217 hw->fc.low_water[i] = ixgbe_lpbthresh(adapter, i); in ixgbe_pbthresh_setup()
5220 if (hw->fc.low_water[i] > hw->fc.high_water[i]) in ixgbe_pbthresh_setup()
5221 hw->fc.low_water[i] = 0; in ixgbe_pbthresh_setup()
5225 hw->fc.high_water[i] = 0; in ixgbe_pbthresh_setup()
5230 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_pb()
5232 u8 tc = adapter->hw_tcs; in ixgbe_configure_pb()
5234 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || in ixgbe_configure_pb()
5235 adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) in ixgbe_configure_pb()
5236 hdrm = 32 << adapter->fdir_pballoc; in ixgbe_configure_pb()
5240 hw->mac.ops.set_rxpba(hw, tc, hdrm, PBA_STRATEGY_EQUAL); in ixgbe_configure_pb()
5246 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_fdir_filter_restore()
5251 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_fdir_filter_restore()
5253 if (!hlist_empty(&adapter->fdir_filter_list)) in ixgbe_fdir_filter_restore()
5254 ixgbe_fdir_set_input_mask_82599(hw, &adapter->fdir_mask); in ixgbe_fdir_filter_restore()
5257 &adapter->fdir_filter_list, fdir_node) { in ixgbe_fdir_filter_restore()
5258 if (filter->action == IXGBE_FDIR_DROP_QUEUE) { in ixgbe_fdir_filter_restore()
5261 u32 ring = ethtool_get_flow_spec_ring(filter->action); in ixgbe_fdir_filter_restore()
5262 u8 vf = ethtool_get_flow_spec_ring_vf(filter->action); in ixgbe_fdir_filter_restore()
5264 if (!vf && (ring >= adapter->num_rx_queues)) { in ixgbe_fdir_filter_restore()
5269 ((vf > adapter->num_vfs) || in ixgbe_fdir_filter_restore()
5270 ring >= adapter->num_rx_queues_per_pool)) { in ixgbe_fdir_filter_restore()
5278 queue = adapter->rx_ring[ring]->reg_idx; in ixgbe_fdir_filter_restore()
5280 queue = ((vf - 1) * in ixgbe_fdir_filter_restore()
5281 adapter->num_rx_queues_per_pool) + ring; in ixgbe_fdir_filter_restore()
5285 &filter->filter, filter->sw_idx, queue); in ixgbe_fdir_filter_restore()
5288 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_fdir_filter_restore()
5292 * ixgbe_clean_rx_ring - Free Rx Buffers per Queue
5297 u16 i = rx_ring->next_to_clean; in ixgbe_clean_rx_ring()
5298 struct ixgbe_rx_buffer *rx_buffer = &rx_ring->rx_buffer_info[i]; in ixgbe_clean_rx_ring()
5300 if (rx_ring->xsk_pool) { in ixgbe_clean_rx_ring()
5306 while (i != rx_ring->next_to_alloc) { in ixgbe_clean_rx_ring()
5307 if (rx_buffer->skb) { in ixgbe_clean_rx_ring()
5308 struct sk_buff *skb = rx_buffer->skb; in ixgbe_clean_rx_ring()
5309 if (IXGBE_CB(skb)->page_released) in ixgbe_clean_rx_ring()
5310 dma_unmap_page_attrs(rx_ring->dev, in ixgbe_clean_rx_ring()
5311 IXGBE_CB(skb)->dma, in ixgbe_clean_rx_ring()
5321 dma_sync_single_range_for_cpu(rx_ring->dev, in ixgbe_clean_rx_ring()
5322 rx_buffer->dma, in ixgbe_clean_rx_ring()
5323 rx_buffer->page_offset, in ixgbe_clean_rx_ring()
5328 dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, in ixgbe_clean_rx_ring()
5332 __page_frag_cache_drain(rx_buffer->page, in ixgbe_clean_rx_ring()
5333 rx_buffer->pagecnt_bias); in ixgbe_clean_rx_ring()
5337 if (i == rx_ring->count) { in ixgbe_clean_rx_ring()
5339 rx_buffer = rx_ring->rx_buffer_info; in ixgbe_clean_rx_ring()
5344 rx_ring->next_to_alloc = 0; in ixgbe_clean_rx_ring()
5345 rx_ring->next_to_clean = 0; in ixgbe_clean_rx_ring()
5346 rx_ring->next_to_use = 0; in ixgbe_clean_rx_ring()
5352 u16 rss_i = adapter->ring_feature[RING_F_RSS].indices; in ixgbe_fwd_ring_up()
5353 int num_tc = netdev_get_num_tc(adapter->netdev); in ixgbe_fwd_ring_up()
5354 struct net_device *vdev = accel->netdev; in ixgbe_fwd_ring_up()
5357 baseq = accel->pool * adapter->num_rx_queues_per_pool; in ixgbe_fwd_ring_up()
5359 accel->pool, adapter->num_rx_pools, in ixgbe_fwd_ring_up()
5360 baseq, baseq + adapter->num_rx_queues_per_pool); in ixgbe_fwd_ring_up()
5362 accel->rx_base_queue = baseq; in ixgbe_fwd_ring_up()
5363 accel->tx_base_queue = baseq; in ixgbe_fwd_ring_up()
5367 netdev_bind_sb_channel_queue(adapter->netdev, vdev, in ixgbe_fwd_ring_up()
5370 for (i = 0; i < adapter->num_rx_queues_per_pool; i++) in ixgbe_fwd_ring_up()
5371 adapter->rx_ring[baseq + i]->netdev = vdev; in ixgbe_fwd_ring_up()
5381 err = ixgbe_add_mac_filter(adapter, vdev->dev_addr, in ixgbe_fwd_ring_up()
5382 VMDQ_P(accel->pool)); in ixgbe_fwd_ring_up()
5389 for (i = 0; i < adapter->num_rx_queues_per_pool; i++) in ixgbe_fwd_ring_up()
5390 adapter->rx_ring[baseq + i]->netdev = NULL; in ixgbe_fwd_ring_up()
5395 netdev_unbind_sb_channel(adapter->netdev, vdev); in ixgbe_fwd_ring_up()
5398 clear_bit(accel->pool, adapter->fwd_bitmask); in ixgbe_fwd_ring_up()
5407 struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)priv->data; in ixgbe_macvlan_up()
5428 netdev_walk_all_upper_dev_rcu(adapter->netdev, in ixgbe_configure_dfwd()
5434 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure()
5446 ixgbe_set_rx_mode(adapter->netdev); in ixgbe_configure()
5450 switch (hw->mac.type) { in ixgbe_configure()
5453 hw->mac.ops.disable_rx_buff(hw); in ixgbe_configure()
5459 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { in ixgbe_configure()
5460 ixgbe_init_fdir_signature_82599(&adapter->hw, in ixgbe_configure()
5461 adapter->fdir_pballoc); in ixgbe_configure()
5462 } else if (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) { in ixgbe_configure()
5463 ixgbe_init_fdir_perfect_82599(&adapter->hw, in ixgbe_configure()
5464 adapter->fdir_pballoc); in ixgbe_configure()
5468 switch (hw->mac.type) { in ixgbe_configure()
5471 hw->mac.ops.enable_rx_buff(hw); in ixgbe_configure()
5479 if (adapter->flags & IXGBE_FLAG_DCA_CAPABLE) in ixgbe_configure()
5494 * ixgbe_sfp_link_config - set up SFP+ link
5505 if (adapter->hw.mac.type == ixgbe_mac_82598EB) in ixgbe_sfp_link_config()
5506 adapter->flags2 |= IXGBE_FLAG2_SEARCH_FOR_SFP; in ixgbe_sfp_link_config()
5508 adapter->flags2 |= IXGBE_FLAG2_SFP_NEEDS_RESET; in ixgbe_sfp_link_config()
5509 adapter->sfp_poll_time = 0; in ixgbe_sfp_link_config()
5513 * ixgbe_non_sfp_link_config - set up non-SFP+ link
5524 if (hw->mac.ops.check_link) in ixgbe_non_sfp_link_config()
5525 ret = hw->mac.ops.check_link(hw, &speed, &link_up, false); in ixgbe_non_sfp_link_config()
5530 speed = hw->phy.autoneg_advertised; in ixgbe_non_sfp_link_config()
5531 if (!speed && hw->mac.ops.get_link_capabilities) { in ixgbe_non_sfp_link_config()
5532 ret = hw->mac.ops.get_link_capabilities(hw, &speed, in ixgbe_non_sfp_link_config()
5541 if (hw->mac.ops.setup_link) in ixgbe_non_sfp_link_config()
5542 ret = hw->mac.ops.setup_link(hw, speed, link_up); in ixgbe_non_sfp_link_config()
5549 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_gpie()
5552 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { in ixgbe_setup_gpie()
5557 * use EIAM to auto-mask when MSI-X interrupt is asserted in ixgbe_setup_gpie()
5560 switch (hw->mac.type) { in ixgbe_setup_gpie()
5575 /* legacy interrupts, use EIAM to auto-mask when reading EICR, in ixgbe_setup_gpie()
5583 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { in ixgbe_setup_gpie()
5586 switch (adapter->ring_feature[RING_F_VMDQ].mask) { in ixgbe_setup_gpie()
5600 if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) { in ixgbe_setup_gpie()
5601 switch (adapter->hw.mac.type) { in ixgbe_setup_gpie()
5611 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) in ixgbe_setup_gpie()
5614 switch (hw->mac.type) { in ixgbe_setup_gpie()
5631 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_up_complete()
5638 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) in ixgbe_up_complete()
5644 if (hw->mac.ops.enable_tx_laser) in ixgbe_up_complete()
5645 hw->mac.ops.enable_tx_laser(hw); in ixgbe_up_complete()
5647 if (hw->phy.ops.set_phy_power) in ixgbe_up_complete()
5648 hw->phy.ops.set_phy_power(hw, true); in ixgbe_up_complete()
5651 clear_bit(__IXGBE_DOWN, &adapter->state); in ixgbe_up_complete()
5670 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) { in ixgbe_up_complete()
5678 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_up_complete()
5679 adapter->link_check_timeout = jiffies; in ixgbe_up_complete()
5680 mod_timer(&adapter->service_timer, jiffies); in ixgbe_up_complete()
5691 netif_trans_update(adapter->netdev); in ixgbe_reinit_locked()
5693 while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) in ixgbe_reinit_locked()
5695 if (adapter->hw.phy.type == ixgbe_phy_fw) in ixgbe_reinit_locked()
5699 * If SR-IOV enabled then wait a bit before bringing the adapter in ixgbe_reinit_locked()
5704 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_reinit_locked()
5707 clear_bit(__IXGBE_RESETTING, &adapter->state); in ixgbe_reinit_locked()
5722 pcie_capability_read_word(adapter->pdev, PCI_EXP_DEVCTL2, &devctl2); in ixgbe_get_completion_timeout()
5758 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_rx()
5763 hw->mac.ops.disable_rx(hw); in ixgbe_disable_rx()
5765 if (ixgbe_removed(hw->hw_addr)) in ixgbe_disable_rx()
5769 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_disable_rx()
5770 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_disable_rx()
5771 u8 reg_idx = ring->reg_idx; in ixgbe_disable_rx()
5782 if (hw->mac.type == ixgbe_mac_82598EB && in ixgbe_disable_rx()
5802 while (wait_loop--) { in ixgbe_disable_rx()
5812 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_disable_rx()
5813 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_disable_rx()
5814 u8 reg_idx = ring->reg_idx; in ixgbe_disable_rx()
5830 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_tx()
5834 if (ixgbe_removed(hw->hw_addr)) in ixgbe_disable_tx()
5838 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_disable_tx()
5839 struct ixgbe_ring *ring = adapter->tx_ring[i]; in ixgbe_disable_tx()
5840 u8 reg_idx = ring->reg_idx; in ixgbe_disable_tx()
5846 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_disable_tx()
5847 struct ixgbe_ring *ring = adapter->xdp_ring[i]; in ixgbe_disable_tx()
5848 u8 reg_idx = ring->reg_idx; in ixgbe_disable_tx()
5877 while (wait_loop--) { in ixgbe_disable_tx()
5887 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_disable_tx()
5888 struct ixgbe_ring *ring = adapter->tx_ring[i]; in ixgbe_disable_tx()
5889 u8 reg_idx = ring->reg_idx; in ixgbe_disable_tx()
5893 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_disable_tx()
5894 struct ixgbe_ring *ring = adapter->xdp_ring[i]; in ixgbe_disable_tx()
5895 u8 reg_idx = ring->reg_idx; in ixgbe_disable_tx()
5909 switch (hw->mac.type) { in ixgbe_disable_tx()
5926 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_reset()
5927 struct net_device *netdev = adapter->netdev; in ixgbe_reset()
5930 if (ixgbe_removed(hw->hw_addr)) in ixgbe_reset()
5933 while (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state)) in ixgbe_reset()
5937 adapter->flags2 &= ~(IXGBE_FLAG2_SEARCH_FOR_SFP | in ixgbe_reset()
5939 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; in ixgbe_reset()
5941 err = hw->mac.ops.init_hw(hw); in ixgbe_reset()
5951 /* We are running on a pre-production device, log a warning */ in ixgbe_reset()
5952 e_dev_warn("This device is a pre-production adapter/LOM. " in ixgbe_reset()
5963 clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state); in ixgbe_reset()
5973 if (hw->mac.san_mac_rar_index) in ixgbe_reset()
5974 hw->mac.ops.set_vmdq_san_mac(hw, VMDQ_P(0)); in ixgbe_reset()
5976 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) in ixgbe_reset()
5979 if (hw->phy.ops.set_phy_power) { in ixgbe_reset()
5980 if (!netif_running(adapter->netdev) && !adapter->wol) in ixgbe_reset()
5981 hw->phy.ops.set_phy_power(hw, false); in ixgbe_reset()
5983 hw->phy.ops.set_phy_power(hw, true); in ixgbe_reset()
5988 * ixgbe_clean_tx_ring - Free Tx Buffers
5993 u16 i = tx_ring->next_to_clean; in ixgbe_clean_tx_ring()
5994 struct ixgbe_tx_buffer *tx_buffer = &tx_ring->tx_buffer_info[i]; in ixgbe_clean_tx_ring()
5996 if (tx_ring->xsk_pool) { in ixgbe_clean_tx_ring()
6001 while (i != tx_ring->next_to_use) { in ixgbe_clean_tx_ring()
6006 xdp_return_frame(tx_buffer->xdpf); in ixgbe_clean_tx_ring()
6008 dev_kfree_skb_any(tx_buffer->skb); in ixgbe_clean_tx_ring()
6011 dma_unmap_single(tx_ring->dev, in ixgbe_clean_tx_ring()
6017 eop_desc = tx_buffer->next_to_watch; in ixgbe_clean_tx_ring()
6025 if (unlikely(i == tx_ring->count)) { in ixgbe_clean_tx_ring()
6027 tx_buffer = tx_ring->tx_buffer_info; in ixgbe_clean_tx_ring()
6033 dma_unmap_page(tx_ring->dev, in ixgbe_clean_tx_ring()
6042 if (unlikely(i == tx_ring->count)) { in ixgbe_clean_tx_ring()
6044 tx_buffer = tx_ring->tx_buffer_info; in ixgbe_clean_tx_ring()
6054 tx_ring->next_to_use = 0; in ixgbe_clean_tx_ring()
6055 tx_ring->next_to_clean = 0; in ixgbe_clean_tx_ring()
6059 * ixgbe_clean_all_rx_rings - Free Rx Buffers for all queues
6066 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_clean_all_rx_rings()
6067 ixgbe_clean_rx_ring(adapter->rx_ring[i]); in ixgbe_clean_all_rx_rings()
6071 * ixgbe_clean_all_tx_rings - Free Tx Buffers for all queues
6078 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_clean_all_tx_rings()
6079 ixgbe_clean_tx_ring(adapter->tx_ring[i]); in ixgbe_clean_all_tx_rings()
6080 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_clean_all_tx_rings()
6081 ixgbe_clean_tx_ring(adapter->xdp_ring[i]); in ixgbe_clean_all_tx_rings()
6089 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_fdir_filter_exit()
6092 &adapter->fdir_filter_list, fdir_node) { in ixgbe_fdir_filter_exit()
6093 hlist_del(&filter->fdir_node); in ixgbe_fdir_filter_exit()
6096 adapter->fdir_filter_count = 0; in ixgbe_fdir_filter_exit()
6098 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_fdir_filter_exit()
6103 struct net_device *netdev = adapter->netdev; in ixgbe_down()
6104 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_down()
6108 if (test_and_set_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_down()
6122 if (adapter->xdp_ring[0]) in ixgbe_down()
6129 clear_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_down()
6130 adapter->flags2 &= ~IXGBE_FLAG2_FDIR_REQUIRES_REINIT; in ixgbe_down()
6131 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_down()
6133 del_timer_sync(&adapter->service_timer); in ixgbe_down()
6135 if (adapter->num_vfs) { in ixgbe_down()
6137 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITRSEL, 0); in ixgbe_down()
6140 for (i = 0 ; i < adapter->num_vfs; i++) in ixgbe_down()
6141 adapter->vfinfo[i].clear_to_send = false; in ixgbe_down()
6153 if (!pci_channel_offline(adapter->pdev)) in ixgbe_down()
6157 if (hw->mac.ops.disable_tx_laser) in ixgbe_down()
6158 hw->mac.ops.disable_tx_laser(hw); in ixgbe_down()
6165 * ixgbe_eee_capable - helper function to determine EEE support on X550
6170 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_eee_capable()
6172 switch (hw->device_id) { in ixgbe_set_eee_capable()
6175 if (!hw->phy.eee_speeds_supported) in ixgbe_set_eee_capable()
6177 adapter->flags2 |= IXGBE_FLAG2_EEE_CAPABLE; in ixgbe_set_eee_capable()
6178 if (!hw->phy.eee_speeds_advertised) in ixgbe_set_eee_capable()
6180 adapter->flags2 |= IXGBE_FLAG2_EEE_ENABLED; in ixgbe_set_eee_capable()
6183 adapter->flags2 &= ~IXGBE_FLAG2_EEE_CAPABLE; in ixgbe_set_eee_capable()
6184 adapter->flags2 &= ~IXGBE_FLAG2_EEE_ENABLED; in ixgbe_set_eee_capable()
6190 * ixgbe_tx_timeout - Respond to a Tx Hang
6205 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_init_dcb()
6209 switch (hw->mac.type) { in ixgbe_init_dcb()
6212 adapter->dcb_cfg.num_tcs.pg_tcs = MAX_TRAFFIC_CLASS; in ixgbe_init_dcb()
6213 adapter->dcb_cfg.num_tcs.pfc_tcs = MAX_TRAFFIC_CLASS; in ixgbe_init_dcb()
6217 adapter->dcb_cfg.num_tcs.pg_tcs = X540_TRAFFIC_CLASS; in ixgbe_init_dcb()
6218 adapter->dcb_cfg.num_tcs.pfc_tcs = X540_TRAFFIC_CLASS; in ixgbe_init_dcb()
6223 adapter->dcb_cfg.num_tcs.pg_tcs = DEF_TRAFFIC_CLASS; in ixgbe_init_dcb()
6224 adapter->dcb_cfg.num_tcs.pfc_tcs = DEF_TRAFFIC_CLASS; in ixgbe_init_dcb()
6230 tc = &adapter->dcb_cfg.tc_config[j]; in ixgbe_init_dcb()
6231 tc->path[DCB_TX_CONFIG].bwg_id = 0; in ixgbe_init_dcb()
6232 tc->path[DCB_TX_CONFIG].bwg_percent = 12 + (j & 1); in ixgbe_init_dcb()
6233 tc->path[DCB_RX_CONFIG].bwg_id = 0; in ixgbe_init_dcb()
6234 tc->path[DCB_RX_CONFIG].bwg_percent = 12 + (j & 1); in ixgbe_init_dcb()
6235 tc->dcb_pfc = pfc_disabled; in ixgbe_init_dcb()
6238 /* Initialize default user to priority mapping, UPx->TC0 */ in ixgbe_init_dcb()
6239 tc = &adapter->dcb_cfg.tc_config[0]; in ixgbe_init_dcb()
6240 tc->path[DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF; in ixgbe_init_dcb()
6241 tc->path[DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF; in ixgbe_init_dcb()
6243 adapter->dcb_cfg.bw_percentage[DCB_TX_CONFIG][0] = 100; in ixgbe_init_dcb()
6244 adapter->dcb_cfg.bw_percentage[DCB_RX_CONFIG][0] = 100; in ixgbe_init_dcb()
6245 adapter->dcb_cfg.pfc_mode_enable = false; in ixgbe_init_dcb()
6246 adapter->dcb_set_bitmap = 0x00; in ixgbe_init_dcb()
6247 if (adapter->flags & IXGBE_FLAG_DCB_CAPABLE) in ixgbe_init_dcb()
6248 adapter->dcbx_cap = DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_CEE; in ixgbe_init_dcb()
6249 memcpy(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, in ixgbe_init_dcb()
6250 sizeof(adapter->temp_dcb_cfg)); in ixgbe_init_dcb()
6255 * ixgbe_sw_init - Initialize general software structures (struct ixgbe_adapter)
6266 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_sw_init()
6267 struct pci_dev *pdev = adapter->pdev; in ixgbe_sw_init()
6274 hw->vendor_id = pdev->vendor; in ixgbe_sw_init()
6275 hw->device_id = pdev->device; in ixgbe_sw_init()
6276 hw->revision_id = pdev->revision; in ixgbe_sw_init()
6277 hw->subsystem_vendor_id = pdev->subsystem_vendor; in ixgbe_sw_init()
6278 hw->subsystem_device_id = pdev->subsystem_device; in ixgbe_sw_init()
6281 ii->get_invariants(hw); in ixgbe_sw_init()
6285 adapter->ring_feature[RING_F_RSS].limit = rss; in ixgbe_sw_init()
6286 adapter->flags2 |= IXGBE_FLAG2_RSC_CAPABLE; in ixgbe_sw_init()
6287 adapter->max_q_vectors = MAX_Q_VECTORS_82599; in ixgbe_sw_init()
6288 adapter->atr_sample_rate = 20; in ixgbe_sw_init()
6290 adapter->ring_feature[RING_F_FDIR].limit = fdir; in ixgbe_sw_init()
6291 adapter->fdir_pballoc = IXGBE_FDIR_PBALLOC_64K; in ixgbe_sw_init()
6292 adapter->ring_feature[RING_F_VMDQ].limit = 1; in ixgbe_sw_init()
6294 adapter->flags |= IXGBE_FLAG_DCA_CAPABLE; in ixgbe_sw_init()
6297 adapter->flags |= IXGBE_FLAG_DCB_CAPABLE; in ixgbe_sw_init()
6298 adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; in ixgbe_sw_init()
6301 adapter->flags |= IXGBE_FLAG_FCOE_CAPABLE; in ixgbe_sw_init()
6302 adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; in ixgbe_sw_init()
6305 adapter->fcoe.up = IXGBE_FCOE_DEFTC; in ixgbe_sw_init()
6310 adapter->jump_tables[0] = kzalloc(sizeof(*adapter->jump_tables[0]), in ixgbe_sw_init()
6312 if (!adapter->jump_tables[0]) in ixgbe_sw_init()
6313 return -ENOMEM; in ixgbe_sw_init()
6314 adapter->jump_tables[0]->mat = ixgbe_ipv4_fields; in ixgbe_sw_init()
6317 adapter->jump_tables[i] = NULL; in ixgbe_sw_init()
6319 adapter->mac_table = kcalloc(hw->mac.num_rar_entries, in ixgbe_sw_init()
6322 if (!adapter->mac_table) in ixgbe_sw_init()
6323 return -ENOMEM; in ixgbe_sw_init()
6326 return -ENOMEM; in ixgbe_sw_init()
6328 adapter->af_xdp_zc_qps = bitmap_zalloc(MAX_XDP_QUEUES, GFP_KERNEL); in ixgbe_sw_init()
6329 if (!adapter->af_xdp_zc_qps) in ixgbe_sw_init()
6330 return -ENOMEM; in ixgbe_sw_init()
6333 switch (hw->mac.type) { in ixgbe_sw_init()
6335 adapter->flags2 &= ~IXGBE_FLAG2_RSC_CAPABLE; in ixgbe_sw_init()
6337 if (hw->device_id == IXGBE_DEV_ID_82598AT) in ixgbe_sw_init()
6338 adapter->flags |= IXGBE_FLAG_FAN_FAIL_CAPABLE; in ixgbe_sw_init()
6340 adapter->max_q_vectors = MAX_Q_VECTORS_82598; in ixgbe_sw_init()
6341 adapter->ring_feature[RING_F_FDIR].limit = 0; in ixgbe_sw_init()
6342 adapter->atr_sample_rate = 0; in ixgbe_sw_init()
6343 adapter->fdir_pballoc = 0; in ixgbe_sw_init()
6345 adapter->flags &= ~IXGBE_FLAG_FCOE_CAPABLE; in ixgbe_sw_init()
6346 adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; in ixgbe_sw_init()
6348 adapter->fcoe.up = 0; in ixgbe_sw_init()
6353 if (hw->device_id == IXGBE_DEV_ID_82599_T3_LOM) in ixgbe_sw_init()
6354 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; in ixgbe_sw_init()
6359 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; in ixgbe_sw_init()
6362 switch (hw->device_id) { in ixgbe_sw_init()
6365 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; in ixgbe_sw_init()
6373 adapter->flags &= ~IXGBE_FLAG_DCB_CAPABLE; in ixgbe_sw_init()
6376 adapter->flags &= ~IXGBE_FLAG_FCOE_CAPABLE; in ixgbe_sw_init()
6378 adapter->fcoe.up = 0; in ixgbe_sw_init()
6383 if (hw->mac.type == ixgbe_mac_X550) in ixgbe_sw_init()
6384 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; in ixgbe_sw_init()
6386 adapter->flags &= ~IXGBE_FLAG_DCA_CAPABLE; in ixgbe_sw_init()
6395 spin_lock_init(&adapter->fcoe.lock); in ixgbe_sw_init()
6398 /* n-tuple support exists, always init our spinlock */ in ixgbe_sw_init()
6399 spin_lock_init(&adapter->fdir_perfect_lock); in ixgbe_sw_init()
6407 hw->fc.requested_mode = ixgbe_fc_full; in ixgbe_sw_init()
6408 hw->fc.current_mode = ixgbe_fc_full; /* init for ethtool output */ in ixgbe_sw_init()
6410 hw->fc.pause_time = IXGBE_DEFAULT_FCPAUSE; in ixgbe_sw_init()
6411 hw->fc.send_xon = true; in ixgbe_sw_init()
6412 hw->fc.disable_fc_autoneg = ixgbe_device_supports_autoneg_fc(hw); in ixgbe_sw_init()
6416 …e_dev_warn("Enabling SR-IOV VFs using the max_vfs module parameter is deprecated - please use the … in ixgbe_sw_init()
6418 /* assign number of SR-IOV VFs */ in ixgbe_sw_init()
6419 if (hw->mac.type != ixgbe_mac_82598EB) { in ixgbe_sw_init()
6422 e_dev_warn("max_vfs parameter out of range. Not assigning any SR-IOV VFs\n"); in ixgbe_sw_init()
6428 adapter->rx_itr_setting = 1; in ixgbe_sw_init()
6429 adapter->tx_itr_setting = 1; in ixgbe_sw_init()
6432 adapter->tx_ring_count = IXGBE_DEFAULT_TXD; in ixgbe_sw_init()
6433 adapter->rx_ring_count = IXGBE_DEFAULT_RXD; in ixgbe_sw_init()
6436 adapter->tx_work_limit = IXGBE_DEFAULT_TX_WORK; in ixgbe_sw_init()
6441 return -EIO; in ixgbe_sw_init()
6445 set_bit(0, adapter->fwd_bitmask); in ixgbe_sw_init()
6446 set_bit(__IXGBE_DOWN, &adapter->state); in ixgbe_sw_init()
6452 * ixgbe_setup_tx_resources - allocate Tx resources (Descriptors)
6459 struct device *dev = tx_ring->dev; in ixgbe_setup_tx_resources()
6464 size = sizeof(struct ixgbe_tx_buffer) * tx_ring->count; in ixgbe_setup_tx_resources()
6466 if (tx_ring->q_vector) in ixgbe_setup_tx_resources()
6467 ring_node = tx_ring->q_vector->numa_node; in ixgbe_setup_tx_resources()
6469 tx_ring->tx_buffer_info = vmalloc_node(size, ring_node); in ixgbe_setup_tx_resources()
6470 if (!tx_ring->tx_buffer_info) in ixgbe_setup_tx_resources()
6471 tx_ring->tx_buffer_info = vmalloc(size); in ixgbe_setup_tx_resources()
6472 if (!tx_ring->tx_buffer_info) in ixgbe_setup_tx_resources()
6476 tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc); in ixgbe_setup_tx_resources()
6477 tx_ring->size = ALIGN(tx_ring->size, 4096); in ixgbe_setup_tx_resources()
6480 tx_ring->desc = dma_alloc_coherent(dev, in ixgbe_setup_tx_resources()
6481 tx_ring->size, in ixgbe_setup_tx_resources()
6482 &tx_ring->dma, in ixgbe_setup_tx_resources()
6485 if (!tx_ring->desc) in ixgbe_setup_tx_resources()
6486 tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size, in ixgbe_setup_tx_resources()
6487 &tx_ring->dma, GFP_KERNEL); in ixgbe_setup_tx_resources()
6488 if (!tx_ring->desc) in ixgbe_setup_tx_resources()
6491 tx_ring->next_to_use = 0; in ixgbe_setup_tx_resources()
6492 tx_ring->next_to_clean = 0; in ixgbe_setup_tx_resources()
6496 vfree(tx_ring->tx_buffer_info); in ixgbe_setup_tx_resources()
6497 tx_ring->tx_buffer_info = NULL; in ixgbe_setup_tx_resources()
6499 return -ENOMEM; in ixgbe_setup_tx_resources()
6503 * ixgbe_setup_all_tx_resources - allocate all queues Tx resources
6516 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_setup_all_tx_resources()
6517 err = ixgbe_setup_tx_resources(adapter->tx_ring[i]); in ixgbe_setup_all_tx_resources()
6524 for (j = 0; j < adapter->num_xdp_queues; j++) { in ixgbe_setup_all_tx_resources()
6525 err = ixgbe_setup_tx_resources(adapter->xdp_ring[j]); in ixgbe_setup_all_tx_resources()
6536 while (j--) in ixgbe_setup_all_tx_resources()
6537 ixgbe_free_tx_resources(adapter->xdp_ring[j]); in ixgbe_setup_all_tx_resources()
6538 while (i--) in ixgbe_setup_all_tx_resources()
6539 ixgbe_free_tx_resources(adapter->tx_ring[i]); in ixgbe_setup_all_tx_resources()
6544 * ixgbe_setup_rx_resources - allocate Rx resources (Descriptors)
6553 struct device *dev = rx_ring->dev; in ixgbe_setup_rx_resources()
6558 size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count; in ixgbe_setup_rx_resources()
6560 if (rx_ring->q_vector) in ixgbe_setup_rx_resources()
6561 ring_node = rx_ring->q_vector->numa_node; in ixgbe_setup_rx_resources()
6563 rx_ring->rx_buffer_info = vmalloc_node(size, ring_node); in ixgbe_setup_rx_resources()
6564 if (!rx_ring->rx_buffer_info) in ixgbe_setup_rx_resources()
6565 rx_ring->rx_buffer_info = vmalloc(size); in ixgbe_setup_rx_resources()
6566 if (!rx_ring->rx_buffer_info) in ixgbe_setup_rx_resources()
6570 rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc); in ixgbe_setup_rx_resources()
6571 rx_ring->size = ALIGN(rx_ring->size, 4096); in ixgbe_setup_rx_resources()
6574 rx_ring->desc = dma_alloc_coherent(dev, in ixgbe_setup_rx_resources()
6575 rx_ring->size, in ixgbe_setup_rx_resources()
6576 &rx_ring->dma, in ixgbe_setup_rx_resources()
6579 if (!rx_ring->desc) in ixgbe_setup_rx_resources()
6580 rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size, in ixgbe_setup_rx_resources()
6581 &rx_ring->dma, GFP_KERNEL); in ixgbe_setup_rx_resources()
6582 if (!rx_ring->desc) in ixgbe_setup_rx_resources()
6585 rx_ring->next_to_clean = 0; in ixgbe_setup_rx_resources()
6586 rx_ring->next_to_use = 0; in ixgbe_setup_rx_resources()
6588 /* XDP RX-queue info */ in ixgbe_setup_rx_resources()
6589 if (xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev, in ixgbe_setup_rx_resources()
6590 rx_ring->queue_index) < 0) in ixgbe_setup_rx_resources()
6593 rx_ring->xdp_prog = adapter->xdp_prog; in ixgbe_setup_rx_resources()
6597 vfree(rx_ring->rx_buffer_info); in ixgbe_setup_rx_resources()
6598 rx_ring->rx_buffer_info = NULL; in ixgbe_setup_rx_resources()
6600 return -ENOMEM; in ixgbe_setup_rx_resources()
6604 * ixgbe_setup_all_rx_resources - allocate all queues Rx resources
6617 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_setup_all_rx_resources()
6618 err = ixgbe_setup_rx_resources(adapter, adapter->rx_ring[i]); in ixgbe_setup_all_rx_resources()
6633 while (i--) in ixgbe_setup_all_rx_resources()
6634 ixgbe_free_rx_resources(adapter->rx_ring[i]); in ixgbe_setup_all_rx_resources()
6639 * ixgbe_free_tx_resources - Free Tx Resources per Queue
6648 vfree(tx_ring->tx_buffer_info); in ixgbe_free_tx_resources()
6649 tx_ring->tx_buffer_info = NULL; in ixgbe_free_tx_resources()
6652 if (!tx_ring->desc) in ixgbe_free_tx_resources()
6655 dma_free_coherent(tx_ring->dev, tx_ring->size, in ixgbe_free_tx_resources()
6656 tx_ring->desc, tx_ring->dma); in ixgbe_free_tx_resources()
6658 tx_ring->desc = NULL; in ixgbe_free_tx_resources()
6662 * ixgbe_free_all_tx_resources - Free Tx Resources for All Queues
6671 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_free_all_tx_resources()
6672 if (adapter->tx_ring[i]->desc) in ixgbe_free_all_tx_resources()
6673 ixgbe_free_tx_resources(adapter->tx_ring[i]); in ixgbe_free_all_tx_resources()
6674 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_free_all_tx_resources()
6675 if (adapter->xdp_ring[i]->desc) in ixgbe_free_all_tx_resources()
6676 ixgbe_free_tx_resources(adapter->xdp_ring[i]); in ixgbe_free_all_tx_resources()
6680 * ixgbe_free_rx_resources - Free Rx Resources
6689 rx_ring->xdp_prog = NULL; in ixgbe_free_rx_resources()
6690 xdp_rxq_info_unreg(&rx_ring->xdp_rxq); in ixgbe_free_rx_resources()
6691 vfree(rx_ring->rx_buffer_info); in ixgbe_free_rx_resources()
6692 rx_ring->rx_buffer_info = NULL; in ixgbe_free_rx_resources()
6695 if (!rx_ring->desc) in ixgbe_free_rx_resources()
6698 dma_free_coherent(rx_ring->dev, rx_ring->size, in ixgbe_free_rx_resources()
6699 rx_ring->desc, rx_ring->dma); in ixgbe_free_rx_resources()
6701 rx_ring->desc = NULL; in ixgbe_free_rx_resources()
6705 * ixgbe_free_all_rx_resources - Free Rx Resources for All Queues
6718 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_free_all_rx_resources()
6719 if (adapter->rx_ring[i]->desc) in ixgbe_free_all_rx_resources()
6720 ixgbe_free_rx_resources(adapter->rx_ring[i]); in ixgbe_free_all_rx_resources()
6724 * ixgbe_change_mtu - Change the Maximum Transfer Unit
6734 if (adapter->xdp_prog) { in ixgbe_change_mtu()
6739 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_change_mtu()
6740 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_change_mtu()
6744 return -EINVAL; in ixgbe_change_mtu()
6754 if ((adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) && in ixgbe_change_mtu()
6755 (adapter->hw.mac.type == ixgbe_mac_82599EB) && in ixgbe_change_mtu()
6760 netdev->mtu, new_mtu); in ixgbe_change_mtu()
6763 netdev->mtu = new_mtu; in ixgbe_change_mtu()
6772 * ixgbe_open - Called when a network interface is made active
6786 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_open()
6790 if (test_bit(__IXGBE_TESTING, &adapter->state)) in ixgbe_open()
6791 return -EBUSY; in ixgbe_open()
6812 queues = adapter->num_tx_queues; in ixgbe_open()
6817 queues = adapter->num_rx_queues; in ixgbe_open()
6834 if (hw->phy.ops.set_phy_power && !adapter->wol) in ixgbe_open()
6835 hw->phy.ops.set_phy_power(&adapter->hw, false); in ixgbe_open()
6848 if (adapter->hw.phy.ops.enter_lplu) { in ixgbe_close_suspend()
6849 adapter->hw.phy.reset_disable = true; in ixgbe_close_suspend()
6851 adapter->hw.phy.ops.enter_lplu(&adapter->hw); in ixgbe_close_suspend()
6852 adapter->hw.phy.reset_disable = false; in ixgbe_close_suspend()
6864 * ixgbe_close - Disables a network interface
6869 * The close entry point is called when an interface is de-activated
6894 struct net_device *netdev = adapter->netdev; in ixgbe_resume()
6897 adapter->hw.hw_addr = adapter->io_addr; in ixgbe_resume()
6900 clear_bit(__IXGBE_DISABLED, &adapter->state); in ixgbe_resume()
6907 IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0); in ixgbe_resume()
6925 struct net_device *netdev = adapter->netdev; in __ixgbe_shutdown()
6926 struct ixgbe_hw *hw = &adapter->hw; in __ixgbe_shutdown()
6928 u32 wufc = adapter->wol; in __ixgbe_shutdown()
6939 if (hw->mac.ops.stop_link_on_d3) in __ixgbe_shutdown()
6940 hw->mac.ops.stop_link_on_d3(hw); in __ixgbe_shutdown()
6948 if (hw->mac.ops.enable_tx_laser) in __ixgbe_shutdown()
6949 hw->mac.ops.enable_tx_laser(hw); in __ixgbe_shutdown()
6966 switch (hw->mac.type) { in __ixgbe_shutdown()
6982 if (hw->phy.ops.set_phy_power && !*enable_wake) in __ixgbe_shutdown()
6983 hw->phy.ops.set_phy_power(hw, false); in __ixgbe_shutdown()
6987 if (!test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) in __ixgbe_shutdown()
7019 * ixgbe_update_stats - Update the board statistics counters.
7024 struct net_device *netdev = adapter->netdev; in ixgbe_update_stats()
7025 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_stats()
7026 struct ixgbe_hw_stats *hwstats = &adapter->stats; in ixgbe_update_stats()
7034 if (test_bit(__IXGBE_DOWN, &adapter->state) || in ixgbe_update_stats()
7035 test_bit(__IXGBE_RESETTING, &adapter->state)) in ixgbe_update_stats()
7038 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { in ixgbe_update_stats()
7041 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_update_stats()
7042 rsc_count += adapter->rx_ring[i]->rx_stats.rsc_count; in ixgbe_update_stats()
7043 rsc_flush += adapter->rx_ring[i]->rx_stats.rsc_flush; in ixgbe_update_stats()
7045 adapter->rsc_total_count = rsc_count; in ixgbe_update_stats()
7046 adapter->rsc_total_flush = rsc_flush; in ixgbe_update_stats()
7049 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_update_stats()
7050 struct ixgbe_ring *rx_ring = READ_ONCE(adapter->rx_ring[i]); in ixgbe_update_stats()
7054 non_eop_descs += rx_ring->rx_stats.non_eop_descs; in ixgbe_update_stats()
7055 alloc_rx_page += rx_ring->rx_stats.alloc_rx_page; in ixgbe_update_stats()
7056 alloc_rx_page_failed += rx_ring->rx_stats.alloc_rx_page_failed; in ixgbe_update_stats()
7057 alloc_rx_buff_failed += rx_ring->rx_stats.alloc_rx_buff_failed; in ixgbe_update_stats()
7058 hw_csum_rx_error += rx_ring->rx_stats.csum_err; in ixgbe_update_stats()
7059 bytes += rx_ring->stats.bytes; in ixgbe_update_stats()
7060 packets += rx_ring->stats.packets; in ixgbe_update_stats()
7062 adapter->non_eop_descs = non_eop_descs; in ixgbe_update_stats()
7063 adapter->alloc_rx_page = alloc_rx_page; in ixgbe_update_stats()
7064 adapter->alloc_rx_page_failed = alloc_rx_page_failed; in ixgbe_update_stats()
7065 adapter->alloc_rx_buff_failed = alloc_rx_buff_failed; in ixgbe_update_stats()
7066 adapter->hw_csum_rx_error = hw_csum_rx_error; in ixgbe_update_stats()
7067 netdev->stats.rx_bytes = bytes; in ixgbe_update_stats()
7068 netdev->stats.rx_packets = packets; in ixgbe_update_stats()
7073 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_update_stats()
7074 struct ixgbe_ring *tx_ring = READ_ONCE(adapter->tx_ring[i]); in ixgbe_update_stats()
7078 restart_queue += tx_ring->tx_stats.restart_queue; in ixgbe_update_stats()
7079 tx_busy += tx_ring->tx_stats.tx_busy; in ixgbe_update_stats()
7080 bytes += tx_ring->stats.bytes; in ixgbe_update_stats()
7081 packets += tx_ring->stats.packets; in ixgbe_update_stats()
7083 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_update_stats()
7084 struct ixgbe_ring *xdp_ring = READ_ONCE(adapter->xdp_ring[i]); in ixgbe_update_stats()
7088 restart_queue += xdp_ring->tx_stats.restart_queue; in ixgbe_update_stats()
7089 tx_busy += xdp_ring->tx_stats.tx_busy; in ixgbe_update_stats()
7090 bytes += xdp_ring->stats.bytes; in ixgbe_update_stats()
7091 packets += xdp_ring->stats.packets; in ixgbe_update_stats()
7093 adapter->restart_queue = restart_queue; in ixgbe_update_stats()
7094 adapter->tx_busy = tx_busy; in ixgbe_update_stats()
7095 netdev->stats.tx_bytes = bytes; in ixgbe_update_stats()
7096 netdev->stats.tx_packets = packets; in ixgbe_update_stats()
7098 hwstats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS); in ixgbe_update_stats()
7105 hwstats->mpc[i] += mpc; in ixgbe_update_stats()
7106 total_mpc += hwstats->mpc[i]; in ixgbe_update_stats()
7107 hwstats->pxontxc[i] += IXGBE_READ_REG(hw, IXGBE_PXONTXC(i)); in ixgbe_update_stats()
7108 hwstats->pxofftxc[i] += IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i)); in ixgbe_update_stats()
7109 switch (hw->mac.type) { in ixgbe_update_stats()
7111 hwstats->rnbc[i] += IXGBE_READ_REG(hw, IXGBE_RNBC(i)); in ixgbe_update_stats()
7112 hwstats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC(i)); in ixgbe_update_stats()
7113 hwstats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC(i)); in ixgbe_update_stats()
7114 hwstats->pxonrxc[i] += in ixgbe_update_stats()
7122 hwstats->pxonrxc[i] += in ixgbe_update_stats()
7132 hwstats->qptc[i] += IXGBE_READ_REG(hw, IXGBE_QPTC(i)); in ixgbe_update_stats()
7133 hwstats->qprc[i] += IXGBE_READ_REG(hw, IXGBE_QPRC(i)); in ixgbe_update_stats()
7134 if ((hw->mac.type == ixgbe_mac_82599EB) || in ixgbe_update_stats()
7135 (hw->mac.type == ixgbe_mac_X540) || in ixgbe_update_stats()
7136 (hw->mac.type == ixgbe_mac_X550) || in ixgbe_update_stats()
7137 (hw->mac.type == ixgbe_mac_X550EM_x) || in ixgbe_update_stats()
7138 (hw->mac.type == ixgbe_mac_x550em_a)) { in ixgbe_update_stats()
7139 hwstats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i)); in ixgbe_update_stats()
7141 hwstats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i)); in ixgbe_update_stats()
7146 hwstats->gprc += IXGBE_READ_REG(hw, IXGBE_GPRC); in ixgbe_update_stats()
7148 hwstats->gprc -= missed_rx; in ixgbe_update_stats()
7153 switch (hw->mac.type) { in ixgbe_update_stats()
7155 hwstats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC); in ixgbe_update_stats()
7156 hwstats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH); in ixgbe_update_stats()
7157 hwstats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH); in ixgbe_update_stats()
7158 hwstats->tor += IXGBE_READ_REG(hw, IXGBE_TORH); in ixgbe_update_stats()
7165 hwstats->o2bgptc += IXGBE_READ_REG(hw, IXGBE_O2BGPTC); in ixgbe_update_stats()
7166 hwstats->o2bspc += IXGBE_READ_REG(hw, IXGBE_O2BSPC); in ixgbe_update_stats()
7167 hwstats->b2ospc += IXGBE_READ_REG(hw, IXGBE_B2OSPC); in ixgbe_update_stats()
7168 hwstats->b2ogprc += IXGBE_READ_REG(hw, IXGBE_B2OGPRC); in ixgbe_update_stats()
7172 adapter->hw_rx_no_dma_resources += in ixgbe_update_stats()
7174 hwstats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL); in ixgbe_update_stats()
7176 hwstats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL); in ixgbe_update_stats()
7178 hwstats->tor += IXGBE_READ_REG(hw, IXGBE_TORL); in ixgbe_update_stats()
7180 hwstats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT); in ixgbe_update_stats()
7181 hwstats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH); in ixgbe_update_stats()
7182 hwstats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS); in ixgbe_update_stats()
7184 hwstats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC); in ixgbe_update_stats()
7185 hwstats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC); in ixgbe_update_stats()
7186 hwstats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC); in ixgbe_update_stats()
7187 hwstats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC); in ixgbe_update_stats()
7188 hwstats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC); in ixgbe_update_stats()
7189 hwstats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC); in ixgbe_update_stats()
7190 /* Add up per cpu counters for total ddp aloc fail */ in ixgbe_update_stats()
7191 if (adapter->fcoe.ddp_pool) { in ixgbe_update_stats()
7192 struct ixgbe_fcoe *fcoe = &adapter->fcoe; in ixgbe_update_stats()
7194 unsigned int cpu; in ixgbe_update_stats() local
7196 for_each_possible_cpu(cpu) { in ixgbe_update_stats()
7197 ddp_pool = per_cpu_ptr(fcoe->ddp_pool, cpu); in ixgbe_update_stats()
7198 noddp += ddp_pool->noddp; in ixgbe_update_stats()
7199 noddp_ext_buff += ddp_pool->noddp_ext_buff; in ixgbe_update_stats()
7201 hwstats->fcoe_noddp = noddp; in ixgbe_update_stats()
7202 hwstats->fcoe_noddp_ext_buff = noddp_ext_buff; in ixgbe_update_stats()
7210 hwstats->bprc += bprc; in ixgbe_update_stats()
7211 hwstats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC); in ixgbe_update_stats()
7212 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_update_stats()
7213 hwstats->mprc -= bprc; in ixgbe_update_stats()
7214 hwstats->roc += IXGBE_READ_REG(hw, IXGBE_ROC); in ixgbe_update_stats()
7215 hwstats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64); in ixgbe_update_stats()
7216 hwstats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127); in ixgbe_update_stats()
7217 hwstats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255); in ixgbe_update_stats()
7218 hwstats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511); in ixgbe_update_stats()
7219 hwstats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023); in ixgbe_update_stats()
7220 hwstats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522); in ixgbe_update_stats()
7221 hwstats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC); in ixgbe_update_stats()
7223 hwstats->lxontxc += lxon; in ixgbe_update_stats()
7225 hwstats->lxofftxc += lxoff; in ixgbe_update_stats()
7226 hwstats->gptc += IXGBE_READ_REG(hw, IXGBE_GPTC); in ixgbe_update_stats()
7227 hwstats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC); in ixgbe_update_stats()
7229 * 82598 errata - tx of flow control packets is included in tx counters in ixgbe_update_stats()
7232 hwstats->gptc -= xon_off_tot; in ixgbe_update_stats()
7233 hwstats->mptc -= xon_off_tot; in ixgbe_update_stats()
7234 hwstats->gotc -= (xon_off_tot * (ETH_ZLEN + ETH_FCS_LEN)); in ixgbe_update_stats()
7235 hwstats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC); in ixgbe_update_stats()
7236 hwstats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC); in ixgbe_update_stats()
7237 hwstats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC); in ixgbe_update_stats()
7238 hwstats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR); in ixgbe_update_stats()
7239 hwstats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64); in ixgbe_update_stats()
7240 hwstats->ptc64 -= xon_off_tot; in ixgbe_update_stats()
7241 hwstats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127); in ixgbe_update_stats()
7242 hwstats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255); in ixgbe_update_stats()
7243 hwstats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511); in ixgbe_update_stats()
7244 hwstats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023); in ixgbe_update_stats()
7245 hwstats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522); in ixgbe_update_stats()
7246 hwstats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC); in ixgbe_update_stats()
7249 netdev->stats.multicast = hwstats->mprc; in ixgbe_update_stats()
7252 netdev->stats.rx_errors = hwstats->crcerrs + hwstats->rlec; in ixgbe_update_stats()
7253 netdev->stats.rx_dropped = 0; in ixgbe_update_stats()
7254 netdev->stats.rx_length_errors = hwstats->rlec; in ixgbe_update_stats()
7255 netdev->stats.rx_crc_errors = hwstats->crcerrs; in ixgbe_update_stats()
7256 netdev->stats.rx_missed_errors = total_mpc; in ixgbe_update_stats()
7260 * ixgbe_fdir_reinit_subtask - worker thread to reinit FDIR filter table
7265 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_fdir_reinit_subtask()
7268 if (!(adapter->flags2 & IXGBE_FLAG2_FDIR_REQUIRES_REINIT)) in ixgbe_fdir_reinit_subtask()
7271 adapter->flags2 &= ~IXGBE_FLAG2_FDIR_REQUIRES_REINIT; in ixgbe_fdir_reinit_subtask()
7274 if (test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_fdir_reinit_subtask()
7278 if (!(adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE)) in ixgbe_fdir_reinit_subtask()
7281 adapter->fdir_overflow++; in ixgbe_fdir_reinit_subtask()
7284 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_fdir_reinit_subtask()
7286 &(adapter->tx_ring[i]->state)); in ixgbe_fdir_reinit_subtask()
7287 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_fdir_reinit_subtask()
7289 &adapter->xdp_ring[i]->state); in ixgbe_fdir_reinit_subtask()
7290 /* re-enable flow director interrupts */ in ixgbe_fdir_reinit_subtask()
7293 e_err(probe, "failed to finish FDIR re-initialization, " in ixgbe_fdir_reinit_subtask()
7299 * ixgbe_check_hang_subtask - check for hung queues and dropped interrupts
7309 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_hang_subtask()
7314 if (test_bit(__IXGBE_DOWN, &adapter->state) || in ixgbe_check_hang_subtask()
7315 test_bit(__IXGBE_REMOVING, &adapter->state) || in ixgbe_check_hang_subtask()
7316 test_bit(__IXGBE_RESETTING, &adapter->state)) in ixgbe_check_hang_subtask()
7320 if (netif_carrier_ok(adapter->netdev)) { in ixgbe_check_hang_subtask()
7321 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_check_hang_subtask()
7322 set_check_for_tx_hang(adapter->tx_ring[i]); in ixgbe_check_hang_subtask()
7323 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_check_hang_subtask()
7324 set_check_for_tx_hang(adapter->xdp_ring[i]); in ixgbe_check_hang_subtask()
7327 if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) { in ixgbe_check_hang_subtask()
7337 for (i = 0; i < adapter->num_q_vectors; i++) { in ixgbe_check_hang_subtask()
7338 struct ixgbe_q_vector *qv = adapter->q_vector[i]; in ixgbe_check_hang_subtask()
7339 if (qv->rx.ring || qv->tx.ring) in ixgbe_check_hang_subtask()
7349 * ixgbe_watchdog_update_link - update the link status
7354 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_watchdog_update_link()
7355 u32 link_speed = adapter->link_speed; in ixgbe_watchdog_update_link()
7356 bool link_up = adapter->link_up; in ixgbe_watchdog_update_link()
7357 bool pfc_en = adapter->dcb_cfg.pfc_mode_enable; in ixgbe_watchdog_update_link()
7359 if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE)) in ixgbe_watchdog_update_link()
7362 if (hw->mac.ops.check_link) { in ixgbe_watchdog_update_link()
7363 hw->mac.ops.check_link(hw, &link_speed, &link_up, false); in ixgbe_watchdog_update_link()
7370 if (adapter->ixgbe_ieee_pfc) in ixgbe_watchdog_update_link()
7371 pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en); in ixgbe_watchdog_update_link()
7373 if (link_up && !((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && pfc_en)) { in ixgbe_watchdog_update_link()
7374 hw->mac.ops.fc_enable(hw); in ixgbe_watchdog_update_link()
7379 time_after(jiffies, (adapter->link_check_timeout + in ixgbe_watchdog_update_link()
7381 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_watchdog_update_link()
7386 adapter->link_up = link_up; in ixgbe_watchdog_update_link()
7387 adapter->link_speed = link_speed; in ixgbe_watchdog_update_link()
7393 struct net_device *netdev = adapter->netdev; in ixgbe_update_default_up()
7400 if (adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) in ixgbe_update_default_up()
7403 adapter->default_up = (up > 1) ? (ffs(up) - 1) : 0; in ixgbe_update_default_up()
7408 * ixgbe_watchdog_link_is_up - update netif_carrier status and
7414 struct net_device *netdev = adapter->netdev; in ixgbe_watchdog_link_is_up()
7415 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_watchdog_link_is_up()
7416 u32 link_speed = adapter->link_speed; in ixgbe_watchdog_link_is_up()
7424 adapter->flags2 &= ~IXGBE_FLAG2_SEARCH_FOR_SFP; in ixgbe_watchdog_link_is_up()
7426 switch (hw->mac.type) { in ixgbe_watchdog_link_is_up()
7451 adapter->last_rx_ptp_check = jiffies; in ixgbe_watchdog_link_is_up()
7453 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) in ixgbe_watchdog_link_is_up()
7488 netif_tx_wake_all_queues(adapter->netdev); in ixgbe_watchdog_link_is_up()
7498 * ixgbe_watchdog_link_is_down - update netif_carrier status and
7504 struct net_device *netdev = adapter->netdev; in ixgbe_watchdog_link_is_down()
7505 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_watchdog_link_is_down()
7507 adapter->link_up = false; in ixgbe_watchdog_link_is_down()
7508 adapter->link_speed = 0; in ixgbe_watchdog_link_is_down()
7515 if (ixgbe_is_sfp(hw) && hw->mac.type == ixgbe_mac_82598EB) in ixgbe_watchdog_link_is_down()
7516 adapter->flags2 |= IXGBE_FLAG2_SEARCH_FOR_SFP; in ixgbe_watchdog_link_is_down()
7518 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) in ixgbe_watchdog_link_is_down()
7532 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_ring_tx_pending()
7533 struct ixgbe_ring *tx_ring = adapter->tx_ring[i]; in ixgbe_ring_tx_pending()
7535 if (tx_ring->next_to_use != tx_ring->next_to_clean) in ixgbe_ring_tx_pending()
7539 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_ring_tx_pending()
7540 struct ixgbe_ring *ring = adapter->xdp_ring[i]; in ixgbe_ring_tx_pending()
7542 if (ring->next_to_use != ring->next_to_clean) in ixgbe_ring_tx_pending()
7551 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vf_tx_pending()
7552 struct ixgbe_ring_feature *vmdq = &adapter->ring_feature[RING_F_VMDQ]; in ixgbe_vf_tx_pending()
7553 u32 q_per_pool = __ALIGN_MASK(1, ~vmdq->mask); in ixgbe_vf_tx_pending()
7557 if (!adapter->num_vfs) in ixgbe_vf_tx_pending()
7561 if (hw->mac.type >= ixgbe_mac_X550) in ixgbe_vf_tx_pending()
7564 for (i = 0; i < adapter->num_vfs; i++) { in ixgbe_vf_tx_pending()
7580 * ixgbe_watchdog_flush_tx - flush queues on link down
7585 if (!netif_carrier_ok(adapter->netdev)) { in ixgbe_watchdog_flush_tx()
7594 set_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_watchdog_flush_tx()
7602 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_for_bad_vf()
7603 struct pci_dev *pdev = adapter->pdev; in ixgbe_check_for_bad_vf()
7607 if (!(netif_carrier_ok(adapter->netdev))) in ixgbe_check_for_bad_vf()
7623 for (vf = 0; vf < adapter->num_vfs; ++vf) { in ixgbe_check_for_bad_vf()
7624 struct pci_dev *vfdev = adapter->vfinfo[vf].vfdev; in ixgbe_check_for_bad_vf()
7641 if (adapter->hw.mac.type == ixgbe_mac_82598EB || in ixgbe_spoof_check()
7642 adapter->num_vfs == 0) in ixgbe_spoof_check()
7645 ssvpc = IXGBE_READ_REG(&adapter->hw, IXGBE_SSVPC); in ixgbe_spoof_check()
7669 * ixgbe_watchdog_subtask - check and bring link up
7675 if (test_bit(__IXGBE_DOWN, &adapter->state) || in ixgbe_watchdog_subtask()
7676 test_bit(__IXGBE_REMOVING, &adapter->state) || in ixgbe_watchdog_subtask()
7677 test_bit(__IXGBE_RESETTING, &adapter->state)) in ixgbe_watchdog_subtask()
7682 if (adapter->link_up) in ixgbe_watchdog_subtask()
7695 * ixgbe_sfp_detection_subtask - poll for SFP+ cable
7700 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_sfp_detection_subtask()
7704 if (!(adapter->flags2 & IXGBE_FLAG2_SEARCH_FOR_SFP) && in ixgbe_sfp_detection_subtask()
7705 !(adapter->flags2 & IXGBE_FLAG2_SFP_NEEDS_RESET)) in ixgbe_sfp_detection_subtask()
7708 if (adapter->sfp_poll_time && in ixgbe_sfp_detection_subtask()
7709 time_after(adapter->sfp_poll_time, jiffies)) in ixgbe_sfp_detection_subtask()
7713 if (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state)) in ixgbe_sfp_detection_subtask()
7716 adapter->sfp_poll_time = jiffies + IXGBE_SFP_POLL_JIFFIES - 1; in ixgbe_sfp_detection_subtask()
7718 err = hw->phy.ops.identify_sfp(hw); in ixgbe_sfp_detection_subtask()
7725 adapter->flags2 |= IXGBE_FLAG2_SFP_NEEDS_RESET; in ixgbe_sfp_detection_subtask()
7733 if (!(adapter->flags2 & IXGBE_FLAG2_SFP_NEEDS_RESET)) in ixgbe_sfp_detection_subtask()
7736 adapter->flags2 &= ~IXGBE_FLAG2_SFP_NEEDS_RESET; in ixgbe_sfp_detection_subtask()
7743 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_sfp_detection_subtask()
7744 err = hw->phy.ops.reset(hw); in ixgbe_sfp_detection_subtask()
7746 err = hw->mac.ops.setup_sfp(hw); in ixgbe_sfp_detection_subtask()
7751 adapter->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; in ixgbe_sfp_detection_subtask()
7752 e_info(probe, "detected SFP+: %d\n", hw->phy.sfp_type); in ixgbe_sfp_detection_subtask()
7755 clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state); in ixgbe_sfp_detection_subtask()
7758 (adapter->netdev->reg_state == NETREG_REGISTERED)) { in ixgbe_sfp_detection_subtask()
7763 unregister_netdev(adapter->netdev); in ixgbe_sfp_detection_subtask()
7768 * ixgbe_sfp_link_config_subtask - set up link SFP after module install
7773 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_sfp_link_config_subtask()
7778 if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_CONFIG)) in ixgbe_sfp_link_config_subtask()
7782 if (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state)) in ixgbe_sfp_link_config_subtask()
7785 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; in ixgbe_sfp_link_config_subtask()
7787 hw->mac.ops.get_link_capabilities(hw, &cap_speed, &autoneg); in ixgbe_sfp_link_config_subtask()
7796 if (hw->mac.ops.setup_link) in ixgbe_sfp_link_config_subtask()
7797 hw->mac.ops.setup_link(hw, speed, true); in ixgbe_sfp_link_config_subtask()
7799 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_sfp_link_config_subtask()
7800 adapter->link_check_timeout = jiffies; in ixgbe_sfp_link_config_subtask()
7801 clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state); in ixgbe_sfp_link_config_subtask()
7805 * ixgbe_service_timer - Timer Call-back
7814 if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE) in ixgbe_service_timer()
7820 mod_timer(&adapter->service_timer, next_event_offset + jiffies); in ixgbe_service_timer()
7827 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_phy_interrupt_subtask()
7830 if (!(adapter->flags2 & IXGBE_FLAG2_PHY_INTERRUPT)) in ixgbe_phy_interrupt_subtask()
7833 adapter->flags2 &= ~IXGBE_FLAG2_PHY_INTERRUPT; in ixgbe_phy_interrupt_subtask()
7835 if (!hw->phy.ops.handle_lasi) in ixgbe_phy_interrupt_subtask()
7838 status = hw->phy.ops.handle_lasi(&adapter->hw); in ixgbe_phy_interrupt_subtask()
7847 if (!test_and_clear_bit(__IXGBE_RESET_REQUESTED, &adapter->state)) in ixgbe_reset_subtask()
7852 if (test_bit(__IXGBE_DOWN, &adapter->state) || in ixgbe_reset_subtask()
7853 test_bit(__IXGBE_REMOVING, &adapter->state) || in ixgbe_reset_subtask()
7854 test_bit(__IXGBE_RESETTING, &adapter->state)) { in ixgbe_reset_subtask()
7860 netdev_err(adapter->netdev, "Reset adapter\n"); in ixgbe_reset_subtask()
7861 adapter->tx_timeout_count++; in ixgbe_reset_subtask()
7868 * ixgbe_check_fw_error - Check firmware for errors
7875 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_fw_error()
7886 if (hw->mac.ops.fw_recovery_mode && hw->mac.ops.fw_recovery_mode(hw)) { in ixgbe_check_fw_error()
7895 * ixgbe_service_task - manages and runs subtasks
7903 if (ixgbe_removed(adapter->hw.hw_addr)) { in ixgbe_service_task()
7904 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_service_task()
7913 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_service_task()
7914 unregister_netdev(adapter->netdev); in ixgbe_service_task()
7927 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) { in ixgbe_service_task()
7929 if (adapter->flags & IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER) in ixgbe_service_task()
7943 struct sk_buff *skb = first->skb; in ixgbe_tso()
7958 if (skb->ip_summed != CHECKSUM_PARTIAL) in ixgbe_tso()
7968 if (eth_p_mpls(first->protocol)) in ixgbe_tso()
7975 type_tucmd = (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) ? in ixgbe_tso()
7979 if (ip.v4->version == 4) { in ixgbe_tso()
7981 unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); in ixgbe_tso()
7982 int len = csum_start - trans_start; in ixgbe_tso()
7988 ip.v4->check = (skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) ? in ixgbe_tso()
7993 ip.v4->tot_len = 0; in ixgbe_tso()
7994 first->tx_flags |= IXGBE_TX_FLAGS_TSO | in ixgbe_tso()
7998 ip.v6->payload_len = 0; in ixgbe_tso()
7999 first->tx_flags |= IXGBE_TX_FLAGS_TSO | in ixgbe_tso()
8004 l4_offset = l4.hdr - skb->data; in ixgbe_tso()
8007 paylen = skb->len - l4_offset; in ixgbe_tso()
8011 *hdr_len = (l4.tcp->doff * 4) + l4_offset; in ixgbe_tso()
8012 csum_replace_by_diff(&l4.tcp->check, in ixgbe_tso()
8017 csum_replace_by_diff(&l4.udp->check, in ixgbe_tso()
8022 first->gso_segs = skb_shinfo(skb)->gso_segs; in ixgbe_tso()
8023 first->bytecount += (first->gso_segs - 1) * *hdr_len; in ixgbe_tso()
8026 mss_l4len_idx = (*hdr_len - l4_offset) << IXGBE_ADVTXD_L4LEN_SHIFT; in ixgbe_tso()
8027 mss_l4len_idx |= skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT; in ixgbe_tso()
8029 fceof_saidx |= itd->sa_idx; in ixgbe_tso()
8030 type_tucmd |= itd->flags | itd->trailer_len; in ixgbe_tso()
8033 vlan_macip_lens = l4.hdr - ip.hdr; in ixgbe_tso()
8034 vlan_macip_lens |= (ip.hdr - skb->data) << IXGBE_ADVTXD_MACLEN_SHIFT; in ixgbe_tso()
8035 vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; in ixgbe_tso()
8056 struct sk_buff *skb = first->skb; in ixgbe_tx_csum()
8061 if (skb->ip_summed != CHECKSUM_PARTIAL) { in ixgbe_tx_csum()
8063 if (!(first->tx_flags & (IXGBE_TX_FLAGS_HW_VLAN | in ixgbe_tx_csum()
8069 switch (skb->csum_offset) { in ixgbe_tx_csum()
8077 if (((first->protocol == htons(ETH_P_IP)) && in ixgbe_tx_csum()
8078 (ip_hdr(skb)->protocol == IPPROTO_SCTP)) || in ixgbe_tx_csum()
8079 ((first->protocol == htons(ETH_P_IPV6)) && in ixgbe_tx_csum()
8091 first->tx_flags |= IXGBE_TX_FLAGS_CSUM; in ixgbe_tx_csum()
8092 vlan_macip_lens = skb_checksum_start_offset(skb) - in ixgbe_tx_csum()
8097 vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; in ixgbe_tx_csum()
8099 fceof_saidx |= itd->sa_idx; in ixgbe_tx_csum()
8100 type_tucmd |= itd->flags | itd->trailer_len; in ixgbe_tx_csum()
8130 cmd_type ^= IXGBE_SET_FLAG(skb->no_fcs, 1, IXGBE_ADVTXD_DCMD_IFCS); in ixgbe_tx_cmd_type()
8163 tx_desc->read.olinfo_status = cpu_to_le32(olinfo_status); in ixgbe_tx_olinfo_status()
8168 netif_stop_subqueue(tx_ring->netdev, tx_ring->queue_index); in __ixgbe_maybe_stop_tx()
8176 /* We need to check again in a case another CPU has just in __ixgbe_maybe_stop_tx()
8180 return -EBUSY; in __ixgbe_maybe_stop_tx()
8182 /* A reprieve! - use start_queue because it doesn't call schedule */ in __ixgbe_maybe_stop_tx()
8183 netif_start_subqueue(tx_ring->netdev, tx_ring->queue_index); in __ixgbe_maybe_stop_tx()
8184 ++tx_ring->tx_stats.restart_queue; in __ixgbe_maybe_stop_tx()
8200 struct sk_buff *skb = first->skb; in ixgbe_tx_map()
8206 u32 tx_flags = first->tx_flags; in ixgbe_tx_map()
8208 u16 i = tx_ring->next_to_use; in ixgbe_tx_map()
8212 ixgbe_tx_olinfo_status(tx_desc, tx_flags, skb->len - hdr_len); in ixgbe_tx_map()
8215 data_len = skb->data_len; in ixgbe_tx_map()
8220 size -= sizeof(struct fcoe_crc_eof) - data_len; in ixgbe_tx_map()
8223 data_len -= sizeof(struct fcoe_crc_eof); in ixgbe_tx_map()
8228 dma = dma_map_single(tx_ring->dev, skb->data, size, DMA_TO_DEVICE); in ixgbe_tx_map()
8232 for (frag = &skb_shinfo(skb)->frags[0];; frag++) { in ixgbe_tx_map()
8233 if (dma_mapping_error(tx_ring->dev, dma)) in ixgbe_tx_map()
8240 tx_desc->read.buffer_addr = cpu_to_le64(dma); in ixgbe_tx_map()
8243 tx_desc->read.cmd_type_len = in ixgbe_tx_map()
8248 if (i == tx_ring->count) { in ixgbe_tx_map()
8252 tx_desc->read.olinfo_status = 0; in ixgbe_tx_map()
8255 size -= IXGBE_MAX_DATA_PER_TXD; in ixgbe_tx_map()
8257 tx_desc->read.buffer_addr = cpu_to_le64(dma); in ixgbe_tx_map()
8263 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type ^ size); in ixgbe_tx_map()
8267 if (i == tx_ring->count) { in ixgbe_tx_map()
8271 tx_desc->read.olinfo_status = 0; in ixgbe_tx_map()
8278 data_len -= size; in ixgbe_tx_map()
8280 dma = skb_frag_dma_map(tx_ring->dev, frag, 0, size, in ixgbe_tx_map()
8283 tx_buffer = &tx_ring->tx_buffer_info[i]; in ixgbe_tx_map()
8288 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type); in ixgbe_tx_map()
8290 netdev_tx_sent_queue(txring_txq(tx_ring), first->bytecount); in ixgbe_tx_map()
8293 first->time_stamp = jiffies; in ixgbe_tx_map()
8299 * are new descriptors to fetch. (Only applicable for weak-ordered in ixgbe_tx_map()
8300 * memory model archs, such as IA-64). in ixgbe_tx_map()
8308 first->next_to_watch = tx_desc; in ixgbe_tx_map()
8311 if (i == tx_ring->count) in ixgbe_tx_map()
8314 tx_ring->next_to_use = i; in ixgbe_tx_map()
8319 writel(i, tx_ring->tail); in ixgbe_tx_map()
8324 dev_err(tx_ring->dev, "TX DMA map failed\n"); in ixgbe_tx_map()
8328 tx_buffer = &tx_ring->tx_buffer_info[i]; in ixgbe_tx_map()
8330 dma_unmap_page(tx_ring->dev, in ixgbe_tx_map()
8338 i += tx_ring->count; in ixgbe_tx_map()
8339 i--; in ixgbe_tx_map()
8342 dev_kfree_skb_any(first->skb); in ixgbe_tx_map()
8343 first->skb = NULL; in ixgbe_tx_map()
8345 tx_ring->next_to_use = i; in ixgbe_tx_map()
8347 return -1; in ixgbe_tx_map()
8353 struct ixgbe_q_vector *q_vector = ring->q_vector; in ixgbe_atr()
8372 if (!ring->atr_sample_rate) in ixgbe_atr()
8375 ring->atr_count++; in ixgbe_atr()
8378 if ((first->protocol != htons(ETH_P_IP)) && in ixgbe_atr()
8379 (first->protocol != htons(ETH_P_IPV6))) in ixgbe_atr()
8383 skb = first->skb; in ixgbe_atr()
8385 if (unlikely(hdr.network <= skb->data)) in ixgbe_atr()
8387 if (skb->encapsulation && in ixgbe_atr()
8388 first->protocol == htons(ETH_P_IP) && in ixgbe_atr()
8389 hdr.ipv4->protocol == IPPROTO_UDP) { in ixgbe_atr()
8390 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_atr()
8397 if (adapter->vxlan_port && in ixgbe_atr()
8398 udp_hdr(skb)->dest == adapter->vxlan_port) in ixgbe_atr()
8401 if (adapter->geneve_port && in ixgbe_atr()
8402 udp_hdr(skb)->dest == adapter->geneve_port) in ixgbe_atr()
8413 switch (hdr.ipv4->version) { in ixgbe_atr()
8417 l4_proto = hdr.ipv4->protocol; in ixgbe_atr()
8420 hlen = hdr.network - skb->data; in ixgbe_atr()
8422 hlen -= hdr.network - skb->data; in ixgbe_atr()
8438 if (th->fin) in ixgbe_atr()
8442 if (!th->syn && (ring->atr_count < ring->atr_sample_rate)) in ixgbe_atr()
8446 ring->atr_count = 0; in ixgbe_atr()
8448 vlan_id = htons(first->tx_flags >> IXGBE_TX_FLAGS_VLAN_SHIFT); in ixgbe_atr()
8453 * The input is broken into two sections, a non-compressed section in ixgbe_atr()
8463 if (first->tx_flags & (IXGBE_TX_FLAGS_SW_VLAN | IXGBE_TX_FLAGS_HW_VLAN)) in ixgbe_atr()
8464 common.port.src ^= th->dest ^ htons(ETH_P_8021Q); in ixgbe_atr()
8466 common.port.src ^= th->dest ^ first->protocol; in ixgbe_atr()
8467 common.port.dst ^= th->source; in ixgbe_atr()
8469 switch (hdr.ipv4->version) { in ixgbe_atr()
8472 common.ip ^= hdr.ipv4->saddr ^ hdr.ipv4->daddr; in ixgbe_atr()
8476 common.ip ^= hdr.ipv6->saddr.s6_addr32[0] ^ in ixgbe_atr()
8477 hdr.ipv6->saddr.s6_addr32[1] ^ in ixgbe_atr()
8478 hdr.ipv6->saddr.s6_addr32[2] ^ in ixgbe_atr()
8479 hdr.ipv6->saddr.s6_addr32[3] ^ in ixgbe_atr()
8480 hdr.ipv6->daddr.s6_addr32[0] ^ in ixgbe_atr()
8481 hdr.ipv6->daddr.s6_addr32[1] ^ in ixgbe_atr()
8482 hdr.ipv6->daddr.s6_addr32[2] ^ in ixgbe_atr()
8483 hdr.ipv6->daddr.s6_addr32[3]; in ixgbe_atr()
8492 /* This assumes the Rx queue and Tx queue are bound to the same CPU */ in ixgbe_atr()
8493 ixgbe_fdir_add_signature_filter_82599(&q_vector->adapter->hw, in ixgbe_atr()
8494 input, common, ring->queue_index); in ixgbe_atr()
8506 u8 tc = netdev_get_prio_tc_map(dev, skb->priority); in ixgbe_select_queue()
8509 txq = vdev->tc_to_txq[tc].offset; in ixgbe_select_queue()
8511 vdev->tc_to_txq[tc].count); in ixgbe_select_queue()
8525 if (!sb_dev && (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) in ixgbe_select_queue()
8532 f = &adapter->ring_feature[RING_F_FCOE]; in ixgbe_select_queue()
8537 while (txq >= f->indices) in ixgbe_select_queue()
8538 txq -= f->indices; in ixgbe_select_queue()
8540 return txq + f->offset; in ixgbe_select_queue()
8547 struct ixgbe_ring *ring = adapter->xdp_ring[smp_processor_id()]; in ixgbe_xmit_xdp_ring()
8554 len = xdpf->len; in ixgbe_xmit_xdp_ring()
8559 dma = dma_map_single(ring->dev, xdpf->data, len, DMA_TO_DEVICE); in ixgbe_xmit_xdp_ring()
8560 if (dma_mapping_error(ring->dev, dma)) in ixgbe_xmit_xdp_ring()
8564 tx_buffer = &ring->tx_buffer_info[ring->next_to_use]; in ixgbe_xmit_xdp_ring()
8565 tx_buffer->bytecount = len; in ixgbe_xmit_xdp_ring()
8566 tx_buffer->gso_segs = 1; in ixgbe_xmit_xdp_ring()
8567 tx_buffer->protocol = 0; in ixgbe_xmit_xdp_ring()
8569 i = ring->next_to_use; in ixgbe_xmit_xdp_ring()
8574 tx_buffer->xdpf = xdpf; in ixgbe_xmit_xdp_ring()
8576 tx_desc->read.buffer_addr = cpu_to_le64(dma); in ixgbe_xmit_xdp_ring()
8583 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type); in ixgbe_xmit_xdp_ring()
8584 tx_desc->read.olinfo_status = in ixgbe_xmit_xdp_ring()
8592 if (i == ring->count) in ixgbe_xmit_xdp_ring()
8595 tx_buffer->next_to_watch = tx_desc; in ixgbe_xmit_xdp_ring()
8596 ring->next_to_use = i; in ixgbe_xmit_xdp_ring()
8611 __be16 protocol = skb->protocol; in ixgbe_xmit_frame_ring()
8621 for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) in ixgbe_xmit_frame_ring()
8623 &skb_shinfo(skb)->frags[f])); in ixgbe_xmit_frame_ring()
8626 tx_ring->tx_stats.tx_busy++; in ixgbe_xmit_frame_ring()
8631 first = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; in ixgbe_xmit_frame_ring()
8632 first->skb = skb; in ixgbe_xmit_frame_ring()
8633 first->bytecount = skb->len; in ixgbe_xmit_frame_ring()
8634 first->gso_segs = 1; in ixgbe_xmit_frame_ring()
8647 tx_flags |= ntohs(vhdr->h_vlan_TCI) << in ixgbe_xmit_frame_ring()
8653 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && in ixgbe_xmit_frame_ring()
8654 adapter->ptp_clock) { in ixgbe_xmit_frame_ring()
8655 if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON && in ixgbe_xmit_frame_ring()
8657 &adapter->state)) { in ixgbe_xmit_frame_ring()
8658 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in ixgbe_xmit_frame_ring()
8662 adapter->ptp_tx_skb = skb_get(skb); in ixgbe_xmit_frame_ring()
8663 adapter->ptp_tx_start = jiffies; in ixgbe_xmit_frame_ring()
8664 schedule_work(&adapter->ptp_tx_work); in ixgbe_xmit_frame_ring()
8666 adapter->tx_hwtstamp_skipped++; in ixgbe_xmit_frame_ring()
8672 * Use the l2switch_enable flag - would be false if the DMA in ixgbe_xmit_frame_ring()
8675 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_xmit_frame_ring()
8679 /* DCB maps skb priorities 0-7 onto 3 bit PCP of VLAN tag. */ in ixgbe_xmit_frame_ring()
8680 if ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && in ixgbe_xmit_frame_ring()
8682 (skb->priority != TC_PRIO_CONTROL))) { in ixgbe_xmit_frame_ring()
8684 tx_flags |= (skb->priority & 0x7) << in ixgbe_xmit_frame_ring()
8691 vhdr = (struct vlan_ethhdr *)skb->data; in ixgbe_xmit_frame_ring()
8692 vhdr->h_vlan_TCI = htons(tx_flags >> in ixgbe_xmit_frame_ring()
8700 first->tx_flags = tx_flags; in ixgbe_xmit_frame_ring()
8701 first->protocol = protocol; in ixgbe_xmit_frame_ring()
8706 (tx_ring->netdev->features & (NETIF_F_FSO | NETIF_F_FCOE_CRC))) { in ixgbe_xmit_frame_ring()
8728 if (test_bit(__IXGBE_TX_FDIR_INIT_DONE, &tx_ring->state)) in ixgbe_xmit_frame_ring()
8740 dev_kfree_skb_any(first->skb); in ixgbe_xmit_frame_ring()
8741 first->skb = NULL; in ixgbe_xmit_frame_ring()
8744 dev_kfree_skb_any(adapter->ptp_tx_skb); in ixgbe_xmit_frame_ring()
8745 adapter->ptp_tx_skb = NULL; in ixgbe_xmit_frame_ring()
8746 cancel_work_sync(&adapter->ptp_tx_work); in ixgbe_xmit_frame_ring()
8747 clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); in ixgbe_xmit_frame_ring()
8767 tx_ring = ring ? ring : adapter->tx_ring[skb_get_queue_mapping(skb)]; in __ixgbe_xmit_frame()
8768 if (unlikely(test_bit(__IXGBE_TX_DISABLED, &tx_ring->state))) in __ixgbe_xmit_frame()
8781 * ixgbe_set_mac - Change the Ethernet Address of the NIC
8790 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_mac()
8793 if (!is_valid_ether_addr(addr->sa_data)) in ixgbe_set_mac()
8794 return -EADDRNOTAVAIL; in ixgbe_set_mac()
8796 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); in ixgbe_set_mac()
8797 memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len); in ixgbe_set_mac()
8808 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_mdio_read()
8812 if (adapter->mii_bus) { in ixgbe_mdio_read()
8818 return mdiobus_read(adapter->mii_bus, prtad, regnum); in ixgbe_mdio_read()
8821 if (prtad != hw->phy.mdio.prtad) in ixgbe_mdio_read()
8822 return -EINVAL; in ixgbe_mdio_read()
8823 rc = hw->phy.ops.read_reg(hw, addr, devad, &value); in ixgbe_mdio_read()
8833 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_mdio_write()
8835 if (adapter->mii_bus) { in ixgbe_mdio_write()
8841 return mdiobus_write(adapter->mii_bus, prtad, regnum, value); in ixgbe_mdio_write()
8844 if (prtad != hw->phy.mdio.prtad) in ixgbe_mdio_write()
8845 return -EINVAL; in ixgbe_mdio_write()
8846 return hw->phy.ops.write_reg(hw, addr, devad, value); in ixgbe_mdio_write()
8859 if (!adapter->hw.phy.ops.read_reg) in ixgbe_ioctl()
8860 return -EOPNOTSUPP; in ixgbe_ioctl()
8863 return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd); in ixgbe_ioctl()
8868 * ixgbe_add_sanmac_netdev - Add the SAN MAC address to the corresponding
8869 * netdev->dev_addrs
8872 * Returns non-zero on failure
8878 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_add_sanmac_netdev()
8880 if (is_valid_ether_addr(hw->mac.san_addr)) { in ixgbe_add_sanmac_netdev()
8882 err = dev_addr_add(dev, hw->mac.san_addr, NETDEV_HW_ADDR_T_SAN); in ixgbe_add_sanmac_netdev()
8886 hw->mac.ops.set_vmdq_san_mac(hw, VMDQ_P(0)); in ixgbe_add_sanmac_netdev()
8892 * ixgbe_del_sanmac_netdev - Removes the SAN MAC address to the corresponding
8893 * netdev->dev_addrs
8896 * Returns non-zero on failure
8902 struct ixgbe_mac_info *mac = &adapter->hw.mac; in ixgbe_del_sanmac_netdev()
8904 if (is_valid_ether_addr(mac->san_addr)) { in ixgbe_del_sanmac_netdev()
8906 err = dev_addr_del(dev, mac->san_addr, NETDEV_HW_ADDR_T_SAN); in ixgbe_del_sanmac_netdev()
8920 start = u64_stats_fetch_begin_irq(&ring->syncp); in ixgbe_get_ring_stats64()
8921 packets = ring->stats.packets; in ixgbe_get_ring_stats64()
8922 bytes = ring->stats.bytes; in ixgbe_get_ring_stats64()
8923 } while (u64_stats_fetch_retry_irq(&ring->syncp, start)); in ixgbe_get_ring_stats64()
8924 stats->tx_packets += packets; in ixgbe_get_ring_stats64()
8925 stats->tx_bytes += bytes; in ixgbe_get_ring_stats64()
8936 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_get_stats64()
8937 struct ixgbe_ring *ring = READ_ONCE(adapter->rx_ring[i]); in ixgbe_get_stats64()
8943 start = u64_stats_fetch_begin_irq(&ring->syncp); in ixgbe_get_stats64()
8944 packets = ring->stats.packets; in ixgbe_get_stats64()
8945 bytes = ring->stats.bytes; in ixgbe_get_stats64()
8946 } while (u64_stats_fetch_retry_irq(&ring->syncp, start)); in ixgbe_get_stats64()
8947 stats->rx_packets += packets; in ixgbe_get_stats64()
8948 stats->rx_bytes += bytes; in ixgbe_get_stats64()
8952 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_get_stats64()
8953 struct ixgbe_ring *ring = READ_ONCE(adapter->tx_ring[i]); in ixgbe_get_stats64()
8957 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_get_stats64()
8958 struct ixgbe_ring *ring = READ_ONCE(adapter->xdp_ring[i]); in ixgbe_get_stats64()
8965 stats->multicast = netdev->stats.multicast; in ixgbe_get_stats64()
8966 stats->rx_errors = netdev->stats.rx_errors; in ixgbe_get_stats64()
8967 stats->rx_length_errors = netdev->stats.rx_length_errors; in ixgbe_get_stats64()
8968 stats->rx_crc_errors = netdev->stats.rx_crc_errors; in ixgbe_get_stats64()
8969 stats->rx_missed_errors = netdev->stats.rx_missed_errors; in ixgbe_get_stats64()
8974 * ixgbe_validate_rtr - verify 802.1Qp to Rx packet buffer mapping is valid.
8983 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_validate_rtr()
8990 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_validate_rtr()
9011 * ixgbe_set_prio_tc_map - Configure netdev prio tc map
9018 struct net_device *dev = adapter->netdev; in ixgbe_set_prio_tc_map()
9019 struct ixgbe_dcb_config *dcb_cfg = &adapter->dcb_cfg; in ixgbe_set_prio_tc_map()
9020 struct ieee_ets *ets = adapter->ixgbe_ieee_ets; in ixgbe_set_prio_tc_map()
9026 if (adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE) in ixgbe_set_prio_tc_map()
9029 tc = ets->prio_tc[prio]; in ixgbe_set_prio_tc_map()
9039 struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)priv->data; in ixgbe_reassign_macvlan_pool()
9053 pool = find_first_zero_bit(adapter->fwd_bitmask, adapter->num_rx_pools); in ixgbe_reassign_macvlan_pool()
9054 if (pool < adapter->num_rx_pools) { in ixgbe_reassign_macvlan_pool()
9055 set_bit(pool, adapter->fwd_bitmask); in ixgbe_reassign_macvlan_pool()
9056 accel->pool = pool; in ixgbe_reassign_macvlan_pool()
9065 netdev_unbind_sb_channel(adapter->netdev, vdev); in ixgbe_reassign_macvlan_pool()
9081 bitmap_clear(adapter->fwd_bitmask, 1, 63); in ixgbe_defrag_macvlan_pools()
9089 * ixgbe_setup_tc - configure net_device for multiple traffic classes
9097 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_tc()
9100 if (tc > adapter->dcb_cfg.num_tcs.pg_tcs) in ixgbe_setup_tc()
9101 return -EINVAL; in ixgbe_setup_tc()
9103 if (hw->mac.type == ixgbe_mac_82598EB && tc && tc < MAX_TRAFFIC_CLASS) in ixgbe_setup_tc()
9104 return -EINVAL; in ixgbe_setup_tc()
9119 if (adapter->xdp_prog) { in ixgbe_setup_tc()
9125 return -EINVAL; in ixgbe_setup_tc()
9131 adapter->hw_tcs = tc; in ixgbe_setup_tc()
9132 adapter->flags |= IXGBE_FLAG_DCB_ENABLED; in ixgbe_setup_tc()
9134 if (adapter->hw.mac.type == ixgbe_mac_82598EB) { in ixgbe_setup_tc()
9135 adapter->last_lfc_mode = adapter->hw.fc.requested_mode; in ixgbe_setup_tc()
9136 adapter->hw.fc.requested_mode = ixgbe_fc_none; in ixgbe_setup_tc()
9141 if (adapter->hw.mac.type == ixgbe_mac_82598EB) in ixgbe_setup_tc()
9142 adapter->hw.fc.requested_mode = adapter->last_lfc_mode; in ixgbe_setup_tc()
9144 adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; in ixgbe_setup_tc()
9145 adapter->hw_tcs = tc; in ixgbe_setup_tc()
9147 adapter->temp_dcb_cfg.pfc_mode_enable = false; in ixgbe_setup_tc()
9148 adapter->dcb_cfg.pfc_mode_enable = false; in ixgbe_setup_tc()
9167 u32 hdl = cls->knode.handle; in ixgbe_delete_clsu32()
9168 u32 uhtid = TC_U32_USERHTID(cls->knode.handle); in ixgbe_delete_clsu32()
9169 u32 loc = cls->knode.handle & 0xfffff; in ixgbe_delete_clsu32()
9174 return -EINVAL; in ixgbe_delete_clsu32()
9177 return -EINVAL; in ixgbe_delete_clsu32()
9181 jump = adapter->jump_tables[uhtid]; in ixgbe_delete_clsu32()
9183 return -EINVAL; in ixgbe_delete_clsu32()
9184 if (!test_bit(loc - 1, jump->child_loc_map)) in ixgbe_delete_clsu32()
9185 return -EINVAL; in ixgbe_delete_clsu32()
9186 clear_bit(loc - 1, jump->child_loc_map); in ixgbe_delete_clsu32()
9191 jump = adapter->jump_tables[i]; in ixgbe_delete_clsu32()
9192 if (jump && jump->link_hdl == hdl) { in ixgbe_delete_clsu32()
9197 if (!test_bit(j, jump->child_loc_map)) in ixgbe_delete_clsu32()
9199 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_delete_clsu32()
9203 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_delete_clsu32()
9204 clear_bit(j, jump->child_loc_map); in ixgbe_delete_clsu32()
9207 kfree(jump->input); in ixgbe_delete_clsu32()
9208 kfree(jump->mask); in ixgbe_delete_clsu32()
9210 adapter->jump_tables[i] = NULL; in ixgbe_delete_clsu32()
9215 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_delete_clsu32()
9217 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_delete_clsu32()
9224 u32 uhtid = TC_U32_USERHTID(cls->hnode.handle); in ixgbe_configure_clsu32_add_hnode()
9227 return -EINVAL; in ixgbe_configure_clsu32_add_hnode()
9232 if (cls->hnode.divisor > 0) in ixgbe_configure_clsu32_add_hnode()
9233 return -EINVAL; in ixgbe_configure_clsu32_add_hnode()
9235 set_bit(uhtid - 1, &adapter->tables); in ixgbe_configure_clsu32_add_hnode()
9242 u32 uhtid = TC_U32_USERHTID(cls->hnode.handle); in ixgbe_configure_clsu32_del_hnode()
9245 return -EINVAL; in ixgbe_configure_clsu32_del_hnode()
9247 clear_bit(uhtid - 1, &adapter->tables); in ixgbe_configure_clsu32_del_hnode()
9268 data = (struct upper_walk_data *)priv->data; in get_macvlan_queue()
9269 ifindex = data->ifindex; in get_macvlan_queue()
9270 adapter = data->adapter; in get_macvlan_queue()
9271 if (vadapter && upper->ifindex == ifindex) { in get_macvlan_queue()
9272 data->queue = adapter->rx_ring[vadapter->rx_base_queue]->reg_idx; in get_macvlan_queue()
9273 data->action = data->queue; in get_macvlan_queue()
9284 struct ixgbe_ring_feature *vmdq = &adapter->ring_feature[RING_F_VMDQ]; in handle_redirect_action()
9285 unsigned int num_vfs = adapter->num_vfs, vf; in handle_redirect_action()
9292 upper = pci_get_drvdata(adapter->vfinfo[vf].vfdev); in handle_redirect_action()
9293 if (upper->ifindex == ifindex) { in handle_redirect_action()
9294 *queue = vf * __ALIGN_MASK(1, ~vmdq->mask); in handle_redirect_action()
9307 if (netdev_walk_all_upper_dev_rcu(adapter->netdev, in handle_redirect_action()
9315 return -EINVAL; in handle_redirect_action()
9325 return -EINVAL; in parse_tc_actions()
9340 return -EINVAL; in parse_tc_actions()
9341 return handle_redirect_action(adapter, dev->ifindex, in parse_tc_actions()
9345 return -EINVAL; in parse_tc_actions()
9348 return -EINVAL; in parse_tc_actions()
9354 return -EINVAL; in parse_tc_actions()
9368 for (i = 0; i < cls->knode.sel->nkeys; i++) { in ixgbe_clsu32_build_input()
9369 off = cls->knode.sel->keys[i].off; in ixgbe_clsu32_build_input()
9370 val = cls->knode.sel->keys[i].val; in ixgbe_clsu32_build_input()
9371 m = cls->knode.sel->keys[i].mask; in ixgbe_clsu32_build_input()
9377 input->filter.formatted.flow_type |= in ixgbe_clsu32_build_input()
9384 if (nexthdr->off == cls->knode.sel->keys[i].off && in ixgbe_clsu32_build_input()
9385 nexthdr->val == in ixgbe_clsu32_build_input()
9386 (__force u32)cls->knode.sel->keys[i].val && in ixgbe_clsu32_build_input()
9387 nexthdr->mask == in ixgbe_clsu32_build_input()
9388 (__force u32)cls->knode.sel->keys[i].mask) in ixgbe_clsu32_build_input()
9396 return -EINVAL; in ixgbe_clsu32_build_input()
9401 mask->formatted.flow_type = IXGBE_ATR_L4TYPE_IPV6_MASK | in ixgbe_clsu32_build_input()
9404 if (input->filter.formatted.flow_type == IXGBE_ATR_FLOW_TYPE_IPV4) in ixgbe_clsu32_build_input()
9405 mask->formatted.flow_type &= IXGBE_ATR_L4TYPE_IPV6_MASK; in ixgbe_clsu32_build_input()
9413 __be16 protocol = cls->common.protocol; in ixgbe_configure_clsu32()
9414 u32 loc = cls->knode.handle & 0xfffff; in ixgbe_configure_clsu32()
9415 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_clsu32()
9420 int i, err = -EINVAL; in ixgbe_configure_clsu32()
9424 uhtid = TC_U32_USERHTID(cls->knode.handle); in ixgbe_configure_clsu32()
9425 link_uhtid = TC_U32_USERHTID(cls->knode.link_handle); in ixgbe_configure_clsu32()
9437 if (loc >= ((1024 << adapter->fdir_pballoc) - 2)) { in ixgbe_configure_clsu32()
9450 field_ptr = (adapter->jump_tables[0])->mat; in ixgbe_configure_clsu32()
9454 if (!adapter->jump_tables[uhtid]) in ixgbe_configure_clsu32()
9456 field_ptr = (adapter->jump_tables[uhtid])->mat; in ixgbe_configure_clsu32()
9474 if (!test_bit(link_uhtid - 1, &adapter->tables)) in ixgbe_configure_clsu32()
9482 if (adapter->jump_tables[link_uhtid] && in ixgbe_configure_clsu32()
9483 (adapter->jump_tables[link_uhtid])->link_hdl) { in ixgbe_configure_clsu32()
9490 if (nexthdr[i].o != cls->knode.sel->offoff || in ixgbe_configure_clsu32()
9491 nexthdr[i].s != cls->knode.sel->offshift || in ixgbe_configure_clsu32()
9493 (__force u32)cls->knode.sel->offmask) in ixgbe_configure_clsu32()
9498 return -ENOMEM; in ixgbe_configure_clsu32()
9501 err = -ENOMEM; in ixgbe_configure_clsu32()
9506 err = -ENOMEM; in ixgbe_configure_clsu32()
9509 jump->input = input; in ixgbe_configure_clsu32()
9510 jump->mask = mask; in ixgbe_configure_clsu32()
9511 jump->link_hdl = cls->knode.handle; in ixgbe_configure_clsu32()
9516 jump->mat = nexthdr[i].jump; in ixgbe_configure_clsu32()
9517 adapter->jump_tables[link_uhtid] = jump; in ixgbe_configure_clsu32()
9530 return -ENOMEM; in ixgbe_configure_clsu32()
9533 err = -ENOMEM; in ixgbe_configure_clsu32()
9537 if ((uhtid != 0x800) && (adapter->jump_tables[uhtid])) { in ixgbe_configure_clsu32()
9538 if ((adapter->jump_tables[uhtid])->input) in ixgbe_configure_clsu32()
9539 memcpy(input, (adapter->jump_tables[uhtid])->input, in ixgbe_configure_clsu32()
9541 if ((adapter->jump_tables[uhtid])->mask) in ixgbe_configure_clsu32()
9542 memcpy(mask, (adapter->jump_tables[uhtid])->mask, in ixgbe_configure_clsu32()
9549 struct ixgbe_jump_table *link = adapter->jump_tables[i]; in ixgbe_configure_clsu32()
9551 if (link && (test_bit(loc - 1, link->child_loc_map))) { in ixgbe_configure_clsu32()
9554 err = -EINVAL; in ixgbe_configure_clsu32()
9563 err = parse_tc_actions(adapter, cls->knode.exts, &input->action, in ixgbe_configure_clsu32()
9568 input->sw_idx = loc; in ixgbe_configure_clsu32()
9570 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_configure_clsu32()
9572 if (hlist_empty(&adapter->fdir_filter_list)) { in ixgbe_configure_clsu32()
9573 memcpy(&adapter->fdir_mask, mask, sizeof(*mask)); in ixgbe_configure_clsu32()
9577 } else if (memcmp(&adapter->fdir_mask, mask, sizeof(*mask))) { in ixgbe_configure_clsu32()
9578 err = -EINVAL; in ixgbe_configure_clsu32()
9582 ixgbe_atr_compute_perfect_hash_82599(&input->filter, mask); in ixgbe_configure_clsu32()
9583 err = ixgbe_fdir_write_perfect_filter_82599(hw, &input->filter, in ixgbe_configure_clsu32()
9584 input->sw_idx, queue); in ixgbe_configure_clsu32()
9586 ixgbe_update_ethtool_fdir_entry(adapter, input, input->sw_idx); in ixgbe_configure_clsu32()
9587 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_configure_clsu32()
9589 if ((uhtid != 0x800) && (adapter->jump_tables[uhtid])) in ixgbe_configure_clsu32()
9590 set_bit(loc - 1, (adapter->jump_tables[uhtid])->child_loc_map); in ixgbe_configure_clsu32()
9595 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_configure_clsu32()
9608 switch (cls_u32->command) { in ixgbe_setup_tc_cls_u32()
9620 return -EOPNOTSUPP; in ixgbe_setup_tc_cls_u32()
9629 if (!tc_cls_can_offload_and_chain0(adapter->netdev, type_data)) in ixgbe_setup_tc_block_cb()
9630 return -EOPNOTSUPP; in ixgbe_setup_tc_block_cb()
9636 return -EOPNOTSUPP; in ixgbe_setup_tc_block_cb()
9643 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; in ixgbe_setup_tc_mqprio()
9644 return ixgbe_setup_tc(dev, mqprio->num_tc); in ixgbe_setup_tc_mqprio()
9663 return -EOPNOTSUPP; in __ixgbe_setup_tc()
9670 struct net_device *netdev = adapter->netdev; in ixgbe_sriov_reinit()
9673 ixgbe_setup_tc(netdev, adapter->hw_tcs); in ixgbe_sriov_reinit()
9698 if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) in ixgbe_fix_features()
9701 if (adapter->xdp_prog && (features & NETIF_F_LRO)) { in ixgbe_fix_features()
9714 /* go back to full RSS if we're not running SR-IOV */ in ixgbe_reset_l2fw_offload()
9715 if (!adapter->ring_feature[RING_F_VMDQ].offset) in ixgbe_reset_l2fw_offload()
9716 adapter->flags &= ~(IXGBE_FLAG_VMDQ_ENABLED | in ixgbe_reset_l2fw_offload()
9719 adapter->ring_feature[RING_F_RSS].limit = rss; in ixgbe_reset_l2fw_offload()
9720 adapter->ring_feature[RING_F_VMDQ].limit = 1; in ixgbe_reset_l2fw_offload()
9722 ixgbe_setup_tc(adapter->netdev, adapter->hw_tcs); in ixgbe_reset_l2fw_offload()
9729 netdev_features_t changed = netdev->features ^ features; in ixgbe_set_features()
9734 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) in ixgbe_set_features()
9736 adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED; in ixgbe_set_features()
9737 } else if ((adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) && in ixgbe_set_features()
9738 !(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) { in ixgbe_set_features()
9739 if (adapter->rx_itr_setting == 1 || in ixgbe_set_features()
9740 adapter->rx_itr_setting > IXGBE_MIN_RSC_ITR) { in ixgbe_set_features()
9741 adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; in ixgbe_set_features()
9744 e_info(probe, "rx-usecs set too low, " in ixgbe_set_features()
9750 * Check if Flow Director n-tuple support or hw_tc support was in ixgbe_set_features()
9755 if (!(adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)) in ixgbe_set_features()
9758 adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; in ixgbe_set_features()
9759 adapter->flags |= IXGBE_FLAG_FDIR_PERFECT_CAPABLE; in ixgbe_set_features()
9762 if (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) in ixgbe_set_features()
9765 adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE; in ixgbe_set_features()
9767 /* We cannot enable ATR if SR-IOV is enabled */ in ixgbe_set_features()
9768 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED || in ixgbe_set_features()
9770 (adapter->hw_tcs > 1) || in ixgbe_set_features()
9772 (adapter->ring_feature[RING_F_RSS].limit <= 1) || in ixgbe_set_features()
9774 (!adapter->atr_sample_rate)) in ixgbe_set_features()
9777 adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE; in ixgbe_set_features()
9783 netdev->features = features; in ixgbe_set_features()
9785 if ((changed & NETIF_F_HW_L2FW_DOFFLOAD) && adapter->num_rx_pools > 1) in ixgbe_set_features()
9808 return -ENOMEM; in ixgbe_ndo_fdb_add()
9815 * ixgbe_configure_bridge_mode - set various bridge modes
9824 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_bridge_mode()
9831 IXGBE_WRITE_REG(&adapter->hw, IXGBE_PFDTXGSWC, 0); in ixgbe_configure_bridge_mode()
9844 num_pools = adapter->num_vfs + adapter->num_rx_pools; in ixgbe_configure_bridge_mode()
9846 if (hw->mac.ops.set_source_address_pruning) in ixgbe_configure_bridge_mode()
9847 hw->mac.ops.set_source_address_pruning(hw, in ixgbe_configure_bridge_mode()
9854 IXGBE_WRITE_REG(&adapter->hw, IXGBE_PFDTXGSWC, in ixgbe_configure_bridge_mode()
9857 /* disable Rx switching replication unless we have SR-IOV in ixgbe_configure_bridge_mode()
9861 if (!adapter->num_vfs) in ixgbe_configure_bridge_mode()
9868 num_pools = adapter->num_vfs + adapter->num_rx_pools; in ixgbe_configure_bridge_mode()
9870 if (hw->mac.ops.set_source_address_pruning) in ixgbe_configure_bridge_mode()
9871 hw->mac.ops.set_source_address_pruning(hw, in ixgbe_configure_bridge_mode()
9877 return -EINVAL; in ixgbe_configure_bridge_mode()
9880 adapter->bridge_mode = mode; in ixgbe_configure_bridge_mode()
9896 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) in ixgbe_ndo_bridge_setlink()
9897 return -EOPNOTSUPP; in ixgbe_ndo_bridge_setlink()
9901 return -EINVAL; in ixgbe_ndo_bridge_setlink()
9911 return -EINVAL; in ixgbe_ndo_bridge_setlink()
9930 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) in ixgbe_ndo_bridge_getlink()
9934 adapter->bridge_mode, 0, 0, nlflags, in ixgbe_ndo_bridge_getlink()
9942 int tcs = adapter->hw_tcs ? : 1; in ixgbe_fwd_add()
9945 if (adapter->xdp_prog) { in ixgbe_fwd_add()
9947 return ERR_PTR(-EINVAL); in ixgbe_fwd_add()
9955 return ERR_PTR(-EMEDIUMTYPE); in ixgbe_fwd_add()
9962 return ERR_PTR(-ERANGE); in ixgbe_fwd_add()
9964 pool = find_first_zero_bit(adapter->fwd_bitmask, adapter->num_rx_pools); in ixgbe_fwd_add()
9965 if (pool == adapter->num_rx_pools) { in ixgbe_fwd_add()
9966 u16 used_pools = adapter->num_vfs + adapter->num_rx_pools; in ixgbe_fwd_add()
9969 if (((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && in ixgbe_fwd_add()
9970 adapter->num_rx_pools >= (MAX_TX_QUEUES / tcs)) || in ixgbe_fwd_add()
9971 adapter->num_rx_pools > IXGBE_MAX_MACVLANS) in ixgbe_fwd_add()
9972 return ERR_PTR(-EBUSY); in ixgbe_fwd_add()
9979 return ERR_PTR(-EBUSY); in ixgbe_fwd_add()
9982 adapter->flags |= IXGBE_FLAG_VMDQ_ENABLED | in ixgbe_fwd_add()
9989 if (used_pools < 32 && adapter->num_rx_pools < 16) in ixgbe_fwd_add()
9991 32 - used_pools, in ixgbe_fwd_add()
9992 16 - adapter->num_rx_pools); in ixgbe_fwd_add()
9993 else if (adapter->num_rx_pools < 32) in ixgbe_fwd_add()
9995 64 - used_pools, in ixgbe_fwd_add()
9996 32 - adapter->num_rx_pools); in ixgbe_fwd_add()
9998 reserved_pools = 64 - used_pools; in ixgbe_fwd_add()
10002 return ERR_PTR(-EBUSY); in ixgbe_fwd_add()
10004 adapter->ring_feature[RING_F_VMDQ].limit += reserved_pools; in ixgbe_fwd_add()
10007 err = ixgbe_setup_tc(pdev, adapter->hw_tcs); in ixgbe_fwd_add()
10011 if (pool >= adapter->num_rx_pools) in ixgbe_fwd_add()
10012 return ERR_PTR(-ENOMEM); in ixgbe_fwd_add()
10017 return ERR_PTR(-ENOMEM); in ixgbe_fwd_add()
10019 set_bit(pool, adapter->fwd_bitmask); in ixgbe_fwd_add()
10021 accel->pool = pool; in ixgbe_fwd_add()
10022 accel->netdev = vdev; in ixgbe_fwd_add()
10038 unsigned int rxbase = accel->rx_base_queue; in ixgbe_fwd_del()
10042 ixgbe_del_mac_filter(adapter, accel->netdev->dev_addr, in ixgbe_fwd_del()
10043 VMDQ_P(accel->pool)); in ixgbe_fwd_del()
10050 for (i = 0; i < adapter->num_rx_queues_per_pool; i++) { in ixgbe_fwd_del()
10051 struct ixgbe_ring *ring = adapter->rx_ring[rxbase + i]; in ixgbe_fwd_del()
10052 struct ixgbe_q_vector *qv = ring->q_vector; in ixgbe_fwd_del()
10057 if (netif_running(adapter->netdev)) in ixgbe_fwd_del()
10058 napi_synchronize(&qv->napi); in ixgbe_fwd_del()
10059 ring->netdev = NULL; in ixgbe_fwd_del()
10063 netdev_unbind_sb_channel(pdev, accel->netdev); in ixgbe_fwd_del()
10064 netdev_set_sb_channel(accel->netdev, 0); in ixgbe_fwd_del()
10066 clear_bit(accel->pool, adapter->fwd_bitmask); in ixgbe_fwd_del()
10080 mac_hdr_len = skb_network_header(skb) - skb->data; in ixgbe_features_check()
10089 network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb); in ixgbe_features_check()
10099 * IPsec offoad sets skb->encapsulation but still can handle in ixgbe_features_check()
10102 if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) { in ixgbe_features_check()
10114 int i, frame_size = dev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; in ixgbe_xdp_setup()
10119 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_xdp_setup()
10120 return -EINVAL; in ixgbe_xdp_setup()
10122 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) in ixgbe_xdp_setup()
10123 return -EINVAL; in ixgbe_xdp_setup()
10126 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_xdp_setup()
10127 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_xdp_setup()
10130 return -EINVAL; in ixgbe_xdp_setup()
10133 return -EINVAL; in ixgbe_xdp_setup()
10137 return -ENOMEM; in ixgbe_xdp_setup()
10139 old_prog = xchg(&adapter->xdp_prog, prog); in ixgbe_xdp_setup()
10149 err = ixgbe_setup_tc(dev, adapter->hw_tcs); in ixgbe_xdp_setup()
10152 rcu_assign_pointer(adapter->xdp_prog, old_prog); in ixgbe_xdp_setup()
10153 return -EINVAL; in ixgbe_xdp_setup()
10156 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_xdp_setup()
10157 (void)xchg(&adapter->rx_ring[i]->xdp_prog, in ixgbe_xdp_setup()
10158 adapter->xdp_prog); in ixgbe_xdp_setup()
10168 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_xdp_setup()
10169 if (adapter->xdp_ring[i]->xsk_pool) in ixgbe_xdp_setup()
10170 (void)ixgbe_xsk_wakeup(adapter->netdev, i, in ixgbe_xdp_setup()
10180 switch (xdp->command) { in ixgbe_xdp()
10182 return ixgbe_xdp_setup(dev, xdp->prog); in ixgbe_xdp()
10184 return ixgbe_xsk_pool_setup(adapter, xdp->xsk.pool, in ixgbe_xdp()
10185 xdp->xsk.queue_id); in ixgbe_xdp()
10188 return -EINVAL; in ixgbe_xdp()
10198 writel(ring->next_to_use, ring->tail); in ixgbe_xdp_ring_update_tail()
10209 if (unlikely(test_bit(__IXGBE_DOWN, &adapter->state))) in ixgbe_xdp_xmit()
10210 return -ENETDOWN; in ixgbe_xdp_xmit()
10213 return -EINVAL; in ixgbe_xdp_xmit()
10215 /* During program transitions its possible adapter->xdp_prog is assigned in ixgbe_xdp_xmit()
10218 ring = adapter->xdp_prog ? adapter->xdp_ring[smp_processor_id()] : NULL; in ixgbe_xdp_xmit()
10220 return -ENXIO; in ixgbe_xdp_xmit()
10222 if (unlikely(test_bit(__IXGBE_TX_DISABLED, &ring->state))) in ixgbe_xdp_xmit()
10223 return -ENXIO; in ixgbe_xdp_xmit()
10239 return n - drops; in ixgbe_xdp_xmit()
10293 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_txr_hw()
10294 u8 reg_idx = tx_ring->reg_idx; in ixgbe_disable_txr_hw()
10306 while (wait_loop--) { in ixgbe_disable_txr_hw()
10321 set_bit(__IXGBE_TX_DISABLED, &tx_ring->state); in ixgbe_disable_txr()
10329 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_rxr_hw()
10330 u8 reg_idx = rx_ring->reg_idx; in ixgbe_disable_rxr_hw()
10342 if (hw->mac.type == ixgbe_mac_82598EB && in ixgbe_disable_rxr_hw()
10352 while (wait_loop--) { in ixgbe_disable_rxr_hw()
10366 memset(&tx_ring->stats, 0, sizeof(tx_ring->stats)); in ixgbe_reset_txr_stats()
10367 memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats)); in ixgbe_reset_txr_stats()
10372 memset(&rx_ring->stats, 0, sizeof(rx_ring->stats)); in ixgbe_reset_rxr_stats()
10373 memset(&rx_ring->rx_stats, 0, sizeof(rx_ring->rx_stats)); in ixgbe_reset_rxr_stats()
10377 * ixgbe_txrx_ring_disable - Disable Rx/Tx/XDP Tx rings
10388 rx_ring = adapter->rx_ring[ring]; in ixgbe_txrx_ring_disable()
10389 tx_ring = adapter->tx_ring[ring]; in ixgbe_txrx_ring_disable()
10390 xdp_ring = adapter->xdp_ring[ring]; in ixgbe_txrx_ring_disable()
10401 napi_disable(&rx_ring->q_vector->napi); in ixgbe_txrx_ring_disable()
10415 * ixgbe_txrx_ring_enable - Enable Rx/Tx/XDP Tx rings
10426 rx_ring = adapter->rx_ring[ring]; in ixgbe_txrx_ring_enable()
10427 tx_ring = adapter->tx_ring[ring]; in ixgbe_txrx_ring_enable()
10428 xdp_ring = adapter->xdp_ring[ring]; in ixgbe_txrx_ring_enable()
10431 napi_enable(&rx_ring->q_vector->napi); in ixgbe_txrx_ring_enable()
10438 clear_bit(__IXGBE_TX_DISABLED, &tx_ring->state); in ixgbe_txrx_ring_enable()
10440 clear_bit(__IXGBE_TX_DISABLED, &xdp_ring->state); in ixgbe_txrx_ring_enable()
10444 * ixgbe_enumerate_functions - Get the number of ports this device has
10447 * This function enumerates the phsyical functions co-located on a single slot,
10454 struct pci_dev *entry, *pdev = adapter->pdev; in ixgbe_enumerate_functions()
10461 if (ixgbe_pcie_from_parent(&adapter->hw)) in ixgbe_enumerate_functions()
10464 list_for_each_entry(entry, &adapter->pdev->bus->devices, bus_list) { in ixgbe_enumerate_functions()
10466 if (entry->is_virtfn) in ixgbe_enumerate_functions()
10472 * attached to a virtual machine using VT-d, for example. In in ixgbe_enumerate_functions()
10473 * this case, simply return -1 to indicate this. in ixgbe_enumerate_functions()
10475 if ((entry->vendor != pdev->vendor) || in ixgbe_enumerate_functions()
10476 (entry->device != pdev->device)) in ixgbe_enumerate_functions()
10477 return -1; in ixgbe_enumerate_functions()
10486 * ixgbe_wol_supported - Check whether device supports WoL
10498 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_wol_supported()
10499 u16 wol_cap = adapter->eeprom_cap & IXGBE_DEVICE_CAPS_WOL_MASK; in ixgbe_wol_supported()
10502 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_wol_supported()
10506 if (hw->mac.type >= ixgbe_mac_X540) { in ixgbe_wol_supported()
10509 (hw->bus.func == 0))) in ixgbe_wol_supported()
10523 if (hw->bus.func != 0) in ixgbe_wol_supported()
10558 * ixgbe_set_fw_version - Set FW version
10566 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_fw_version()
10571 snprintf(adapter->eeprom_id, sizeof(adapter->eeprom_id), in ixgbe_set_fw_version()
10581 snprintf(adapter->eeprom_id, sizeof(adapter->eeprom_id), in ixgbe_set_fw_version()
10588 snprintf(adapter->eeprom_id, sizeof(adapter->eeprom_id), in ixgbe_set_fw_version()
10593 * ixgbe_probe - Device Initialization Routine
10608 const struct ixgbe_info *ii = ixgbe_info_tbl[ent->driver_data]; in ixgbe_probe()
10619 * the PCIe SR-IOV capability. in ixgbe_probe()
10621 if (pdev->is_virtfn) { in ixgbe_probe()
10623 pci_name(pdev), pdev->vendor, pdev->device); in ixgbe_probe()
10624 return -EINVAL; in ixgbe_probe()
10631 if (!dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64))) { in ixgbe_probe()
10634 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in ixgbe_probe()
10636 dev_err(&pdev->dev, in ixgbe_probe()
10645 dev_err(&pdev->dev, in ixgbe_probe()
10655 if (ii->mac == ixgbe_mac_82598EB) { in ixgbe_probe()
10666 err = -ENOMEM; in ixgbe_probe()
10670 SET_NETDEV_DEV(netdev, &pdev->dev); in ixgbe_probe()
10674 adapter->netdev = netdev; in ixgbe_probe()
10675 adapter->pdev = pdev; in ixgbe_probe()
10676 hw = &adapter->hw; in ixgbe_probe()
10677 hw->back = adapter; in ixgbe_probe()
10678 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); in ixgbe_probe()
10680 hw->hw_addr = ioremap(pci_resource_start(pdev, 0), in ixgbe_probe()
10682 adapter->io_addr = hw->hw_addr; in ixgbe_probe()
10683 if (!hw->hw_addr) { in ixgbe_probe()
10684 err = -EIO; in ixgbe_probe()
10688 netdev->netdev_ops = &ixgbe_netdev_ops; in ixgbe_probe()
10690 netdev->watchdog_timeo = 5 * HZ; in ixgbe_probe()
10691 strlcpy(netdev->name, pci_name(pdev), sizeof(netdev->name)); in ixgbe_probe()
10694 hw->mac.ops = *ii->mac_ops; in ixgbe_probe()
10695 hw->mac.type = ii->mac; in ixgbe_probe()
10696 hw->mvals = ii->mvals; in ixgbe_probe()
10697 if (ii->link_ops) in ixgbe_probe()
10698 hw->link.ops = *ii->link_ops; in ixgbe_probe()
10701 hw->eeprom.ops = *ii->eeprom_ops; in ixgbe_probe()
10703 if (ixgbe_removed(hw->hw_addr)) { in ixgbe_probe()
10704 err = -EIO; in ixgbe_probe()
10709 hw->eeprom.ops.read = &ixgbe_read_eeprom_bit_bang_generic; in ixgbe_probe()
10712 hw->phy.ops = *ii->phy_ops; in ixgbe_probe()
10713 hw->phy.sfp_type = ixgbe_sfp_type_unknown; in ixgbe_probe()
10715 hw->phy.mdio.prtad = MDIO_PRTAD_NONE; in ixgbe_probe()
10716 hw->phy.mdio.mmds = 0; in ixgbe_probe()
10717 hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; in ixgbe_probe()
10718 hw->phy.mdio.dev = netdev; in ixgbe_probe()
10719 hw->phy.mdio.mdio_read = ixgbe_mdio_read; in ixgbe_probe()
10720 hw->phy.mdio.mdio_write = ixgbe_mdio_write; in ixgbe_probe()
10727 switch (adapter->hw.mac.type) { in ixgbe_probe()
10730 netdev->udp_tunnel_nic_info = &ixgbe_udp_tunnels_x550; in ixgbe_probe()
10733 netdev->udp_tunnel_nic_info = &ixgbe_udp_tunnels_x550em_a; in ixgbe_probe()
10740 if (hw->mac.ops.init_swfw_sync) in ixgbe_probe()
10741 hw->mac.ops.init_swfw_sync(hw); in ixgbe_probe()
10744 switch (adapter->hw.mac.type) { in ixgbe_probe()
10750 IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0); in ixgbe_probe()
10760 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) { in ixgbe_probe()
10767 hw->allow_unsupported_sfp = allow_unsupported_sfp; in ixgbe_probe()
10770 hw->phy.reset_if_overtemp = true; in ixgbe_probe()
10771 err = hw->mac.ops.reset_hw(hw); in ixgbe_probe()
10772 hw->phy.reset_if_overtemp = false; in ixgbe_probe()
10786 /* SR-IOV not supported on the 82598 */ in ixgbe_probe()
10787 if (adapter->hw.mac.type == ixgbe_mac_82598EB) in ixgbe_probe()
10791 hw->mbx.ops = ii->mbx_ops; in ixgbe_probe()
10797 netdev->features = NETIF_F_SG | in ixgbe_probe()
10811 netdev->gso_partial_features = IXGBE_GSO_PARTIAL_FEATURES; in ixgbe_probe()
10812 netdev->features |= NETIF_F_GSO_PARTIAL | in ixgbe_probe()
10815 if (hw->mac.type >= ixgbe_mac_82599EB) in ixgbe_probe()
10816 netdev->features |= NETIF_F_SCTP_CRC | NETIF_F_GSO_UDP_L4; in ixgbe_probe()
10823 if (adapter->ipsec) in ixgbe_probe()
10824 netdev->features |= IXGBE_ESP_FEATURES; in ixgbe_probe()
10827 netdev->hw_features |= netdev->features | in ixgbe_probe()
10834 if (hw->mac.type >= ixgbe_mac_82599EB) in ixgbe_probe()
10835 netdev->hw_features |= NETIF_F_NTUPLE | in ixgbe_probe()
10839 netdev->features |= NETIF_F_HIGHDMA; in ixgbe_probe()
10841 netdev->vlan_features |= netdev->features | NETIF_F_TSO_MANGLEID; in ixgbe_probe()
10842 netdev->hw_enc_features |= netdev->vlan_features; in ixgbe_probe()
10843 netdev->mpls_features |= NETIF_F_SG | in ixgbe_probe()
10847 netdev->mpls_features |= IXGBE_GSO_PARTIAL_FEATURES; in ixgbe_probe()
10850 netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | in ixgbe_probe()
10854 netdev->priv_flags |= IFF_UNICAST_FLT; in ixgbe_probe()
10855 netdev->priv_flags |= IFF_SUPP_NOFCS; in ixgbe_probe()
10857 /* MTU range: 68 - 9710 */ in ixgbe_probe()
10858 netdev->min_mtu = ETH_MIN_MTU; in ixgbe_probe()
10859 netdev->max_mtu = IXGBE_MAX_JUMBO_FRAME_SIZE - (ETH_HLEN + ETH_FCS_LEN); in ixgbe_probe()
10862 if (adapter->flags & IXGBE_FLAG_DCB_CAPABLE) in ixgbe_probe()
10863 netdev->dcbnl_ops = &ixgbe_dcbnl_ops; in ixgbe_probe()
10867 if (adapter->flags & IXGBE_FLAG_FCOE_CAPABLE) { in ixgbe_probe()
10870 if (hw->mac.ops.get_device_caps) { in ixgbe_probe()
10871 hw->mac.ops.get_device_caps(hw, &device_caps); in ixgbe_probe()
10873 adapter->flags &= ~IXGBE_FLAG_FCOE_CAPABLE; in ixgbe_probe()
10878 adapter->ring_feature[RING_F_FCOE].limit = fcoe_l; in ixgbe_probe()
10880 netdev->features |= NETIF_F_FSO | in ixgbe_probe()
10883 netdev->vlan_features |= NETIF_F_FSO | in ixgbe_probe()
10888 if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) in ixgbe_probe()
10889 netdev->hw_features |= NETIF_F_LRO; in ixgbe_probe()
10890 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) in ixgbe_probe()
10891 netdev->features |= NETIF_F_LRO; in ixgbe_probe()
10894 err = -EIO; in ixgbe_probe()
10899 if (hw->eeprom.ops.validate_checksum(hw, NULL) < 0) { in ixgbe_probe()
10901 err = -EIO; in ixgbe_probe()
10905 eth_platform_get_mac_address(&adapter->pdev->dev, in ixgbe_probe()
10906 adapter->hw.mac.perm_addr); in ixgbe_probe()
10908 memcpy(netdev->dev_addr, hw->mac.perm_addr, netdev->addr_len); in ixgbe_probe()
10910 if (!is_valid_ether_addr(netdev->dev_addr)) { in ixgbe_probe()
10912 err = -EIO; in ixgbe_probe()
10916 /* Set hw->mac.addr to permanent MAC address */ in ixgbe_probe()
10917 ether_addr_copy(hw->mac.addr, hw->mac.perm_addr); in ixgbe_probe()
10920 timer_setup(&adapter->service_timer, ixgbe_service_timer, 0); in ixgbe_probe()
10922 if (ixgbe_removed(hw->hw_addr)) { in ixgbe_probe()
10923 err = -EIO; in ixgbe_probe()
10926 INIT_WORK(&adapter->service_task, ixgbe_service_task); in ixgbe_probe()
10927 set_bit(__IXGBE_SERVICE_INITED, &adapter->state); in ixgbe_probe()
10928 clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state); in ixgbe_probe()
10934 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_probe()
10935 u64_stats_init(&adapter->rx_ring[i]->syncp); in ixgbe_probe()
10936 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_probe()
10937 u64_stats_init(&adapter->tx_ring[i]->syncp); in ixgbe_probe()
10938 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_probe()
10939 u64_stats_init(&adapter->xdp_ring[i]->syncp); in ixgbe_probe()
10942 adapter->wol = 0; in ixgbe_probe()
10943 hw->eeprom.ops.read(hw, 0x2c, &adapter->eeprom_cap); in ixgbe_probe()
10944 hw->wol_enabled = ixgbe_wol_supported(adapter, pdev->device, in ixgbe_probe()
10945 pdev->subsystem_device); in ixgbe_probe()
10946 if (hw->wol_enabled) in ixgbe_probe()
10947 adapter->wol = IXGBE_WUFC_MAG; in ixgbe_probe()
10949 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); in ixgbe_probe()
10958 hw->mac.ops.get_bus_info(hw); in ixgbe_probe()
10965 switch (hw->mac.type) { in ixgbe_probe()
10981 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present) in ixgbe_probe()
10983 hw->mac.type, hw->phy.type, hw->phy.sfp_type, in ixgbe_probe()
10987 hw->mac.type, hw->phy.type, part_str); in ixgbe_probe()
10989 e_dev_info("%pM\n", netdev->dev_addr); in ixgbe_probe()
10992 err = hw->mac.ops.start_hw(hw); in ixgbe_probe()
10994 /* We are running on a pre-production device, log a warning */ in ixgbe_probe()
10995 e_dev_warn("This device is a pre-production adapter/LOM. " in ixgbe_probe()
11002 strcpy(netdev->name, "eth%d"); in ixgbe_probe()
11010 if (hw->mac.ops.disable_tx_laser) in ixgbe_probe()
11011 hw->mac.ops.disable_tx_laser(hw); in ixgbe_probe()
11017 if (dca_add_requester(&pdev->dev) == 0) { in ixgbe_probe()
11018 adapter->flags |= IXGBE_FLAG_DCA_ENABLED; in ixgbe_probe()
11022 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { in ixgbe_probe()
11023 e_info(probe, "IOV is enabled with %d VFs\n", adapter->num_vfs); in ixgbe_probe()
11024 for (i = 0; i < adapter->num_vfs; i++) in ixgbe_probe()
11031 if (hw->mac.ops.set_fw_drv_ver) in ixgbe_probe()
11032 hw->mac.ops.set_fw_drv_ver(hw, 0xFF, 0xFF, 0xFF, 0xFF, in ixgbe_probe()
11033 sizeof(UTS_RELEASE) - 1, in ixgbe_probe()
11049 if (ixgbe_mng_enabled(hw) && ixgbe_is_sfp(hw) && hw->mac.ops.setup_link) in ixgbe_probe()
11050 hw->mac.ops.setup_link(hw, in ixgbe_probe()
11067 adapter->flags2 &= ~IXGBE_FLAG2_SEARCH_FOR_SFP; in ixgbe_probe()
11068 iounmap(adapter->io_addr); in ixgbe_probe()
11069 kfree(adapter->jump_tables[0]); in ixgbe_probe()
11070 kfree(adapter->mac_table); in ixgbe_probe()
11071 kfree(adapter->rss_key); in ixgbe_probe()
11072 bitmap_free(adapter->af_xdp_zc_qps); in ixgbe_probe()
11074 disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state); in ixgbe_probe()
11086 * ixgbe_remove - Device Removal Routine
11091 * Hot-Plug event, or because the driver is going to be removed from
11105 netdev = adapter->netdev; in ixgbe_remove()
11108 set_bit(__IXGBE_REMOVING, &adapter->state); in ixgbe_remove()
11109 cancel_work_sync(&adapter->service_task); in ixgbe_remove()
11111 if (adapter->mii_bus) in ixgbe_remove()
11112 mdiobus_unregister(adapter->mii_bus); in ixgbe_remove()
11115 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) { in ixgbe_remove()
11116 adapter->flags &= ~IXGBE_FLAG_DCA_ENABLED; in ixgbe_remove()
11117 dca_remove_requester(&pdev->dev); in ixgbe_remove()
11118 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in ixgbe_remove()
11133 if (netdev->reg_state == NETREG_REGISTERED) in ixgbe_remove()
11142 kfree(adapter->ixgbe_ieee_pfc); in ixgbe_remove()
11143 kfree(adapter->ixgbe_ieee_ets); in ixgbe_remove()
11146 iounmap(adapter->io_addr); in ixgbe_remove()
11152 if (adapter->jump_tables[i]) { in ixgbe_remove()
11153 kfree(adapter->jump_tables[i]->input); in ixgbe_remove()
11154 kfree(adapter->jump_tables[i]->mask); in ixgbe_remove()
11156 kfree(adapter->jump_tables[i]); in ixgbe_remove()
11159 kfree(adapter->mac_table); in ixgbe_remove()
11160 kfree(adapter->rss_key); in ixgbe_remove()
11161 bitmap_free(adapter->af_xdp_zc_qps); in ixgbe_remove()
11162 disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state); in ixgbe_remove()
11172 * ixgbe_io_error_detected - called when PCI error is detected
11183 struct net_device *netdev = adapter->netdev; in ixgbe_io_error_detected()
11186 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_io_error_detected()
11192 if (adapter->hw.mac.type == ixgbe_mac_82598EB || in ixgbe_io_error_detected()
11193 adapter->num_vfs == 0) in ixgbe_io_error_detected()
11196 bdev = pdev->bus->self; in ixgbe_io_error_detected()
11198 bdev = bdev->bus->self; in ixgbe_io_error_detected()
11211 if (ixgbe_removed(hw->hw_addr)) in ixgbe_io_error_detected()
11220 if ((pf_func & 1) == (pdev->devfn & 1)) { in ixgbe_io_error_detected()
11228 switch (adapter->hw.mac.type) { in ixgbe_io_error_detected()
11252 if (vfdev->devfn == (req_id & 0xFF)) in ixgbe_io_error_detected()
11275 adapter->vferr_refcount++; in ixgbe_io_error_detected()
11281 if (!test_bit(__IXGBE_SERVICE_INITED, &adapter->state)) in ixgbe_io_error_detected()
11298 if (!test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) in ixgbe_io_error_detected()
11307 * ixgbe_io_slot_reset - called after the pci bus has been reset.
11310 * Restart the card from scratch, as if from a cold-boot.
11318 e_err(probe, "Cannot re-enable PCI device after reset.\n"); in ixgbe_io_slot_reset()
11322 clear_bit(__IXGBE_DISABLED, &adapter->state); in ixgbe_io_slot_reset()
11323 adapter->hw.hw_addr = adapter->io_addr; in ixgbe_io_slot_reset()
11331 IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0); in ixgbe_io_slot_reset()
11339 * ixgbe_io_resume - called when traffic can start flowing again.
11348 struct net_device *netdev = adapter->netdev; in ixgbe_io_resume()
11351 if (adapter->vferr_refcount) { in ixgbe_io_resume()
11353 adapter->vferr_refcount--; in ixgbe_io_resume()
11386 * ixgbe_init_module - Driver Registration Routine
11400 return -ENOMEM; in ixgbe_init_module()
11422 * ixgbe_exit_module - Driver Exit Cleanup Routine