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

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 1999 - 2018 Intel Corporation. */
63 "Copyright (c) 1999-2016 Intel Corporation.";
78 /* ixgbe_pci_tbl - PCI Device ID Table
153 …"Maximum number of virtual functions to allocate per physical function - default is zero and maxim…
159 "Allow unsupported and untested SFP+ modules on 82599-based adapters");
162 static int debug = -1;
181 return dev && (dev->netdev_ops == &ixgbe_netdev_ops); in netif_is_ixgbe()
190 parent_bus = adapter->pdev->bus->parent; in ixgbe_read_pci_cfg_word_parent()
192 return -1; in ixgbe_read_pci_cfg_word_parent()
194 parent_dev = parent_bus->self; in ixgbe_read_pci_cfg_word_parent()
196 return -1; in ixgbe_read_pci_cfg_word_parent()
199 return -1; in ixgbe_read_pci_cfg_word_parent()
203 ixgbe_check_cfg_remove(&adapter->hw, parent_dev)) in ixgbe_read_pci_cfg_word_parent()
204 return -1; in ixgbe_read_pci_cfg_word_parent()
210 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_get_parent_bus_info()
214 hw->bus.type = ixgbe_bus_type_pci_express; in ixgbe_get_parent_bus_info()
225 hw->bus.width = ixgbe_convert_bus_width(link_status); in ixgbe_get_parent_bus_info()
226 hw->bus.speed = ixgbe_convert_bus_speed(link_status); in ixgbe_get_parent_bus_info()
232 * ixgbe_pcie_from_parent - Determine whether PCIe info should come from parent
235 * This function is used by probe to determine whether a device's PCI-Express
242 switch (hw->device_id) { in ixgbe_pcie_from_parent()
254 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_minimum_link()
261 if (hw->bus.type == ixgbe_bus_type_internal) in ixgbe_check_minimum_link()
265 if (ixgbe_pcie_from_parent(&adapter->hw)) in ixgbe_check_minimum_link()
266 pdev = adapter->pdev->bus->parent->self; in ixgbe_check_minimum_link()
268 pdev = adapter->pdev; in ixgbe_check_minimum_link()
275 if (!test_bit(__IXGBE_DOWN, &adapter->state) && in ixgbe_service_event_schedule()
276 !test_bit(__IXGBE_REMOVING, &adapter->state) && in ixgbe_service_event_schedule()
277 !test_and_set_bit(__IXGBE_SERVICE_SCHED, &adapter->state)) in ixgbe_service_event_schedule()
278 queue_work(ixgbe_wq, &adapter->service_task); in ixgbe_service_event_schedule()
283 struct ixgbe_adapter *adapter = hw->back; in ixgbe_remove_adapter()
285 if (!hw->hw_addr) in ixgbe_remove_adapter()
287 hw->hw_addr = NULL; in ixgbe_remove_adapter()
289 if (test_bit(__IXGBE_SERVICE_INITED, &adapter->state)) in ixgbe_remove_adapter()
299 reg_addr = READ_ONCE(hw->hw_addr); in ixgbe_check_remove()
322 * ixgbe_read_reg - Read from device register
336 u8 __iomem *reg_addr = READ_ONCE(hw->hw_addr); in ixgbe_read_reg()
341 if (unlikely(hw->phy.nw_mng_if_sel & in ixgbe_read_reg()
357 adapter = hw->back; in ixgbe_read_reg()
382 struct ixgbe_adapter *adapter = hw->back; in ixgbe_read_pci_cfg_word()
385 if (ixgbe_removed(hw->hw_addr)) in ixgbe_read_pci_cfg_word()
387 pci_read_config_word(adapter->pdev, reg, &value); in ixgbe_read_pci_cfg_word()
389 ixgbe_check_cfg_remove(hw, adapter->pdev)) in ixgbe_read_pci_cfg_word()
397 struct ixgbe_adapter *adapter = hw->back; in ixgbe_read_pci_cfg_dword()
400 if (ixgbe_removed(hw->hw_addr)) in ixgbe_read_pci_cfg_dword()
402 pci_read_config_dword(adapter->pdev, reg, &value); in ixgbe_read_pci_cfg_dword()
404 ixgbe_check_cfg_remove(hw, adapter->pdev)) in ixgbe_read_pci_cfg_dword()
412 struct ixgbe_adapter *adapter = hw->back; in ixgbe_write_pci_cfg_word()
414 if (ixgbe_removed(hw->hw_addr)) in ixgbe_write_pci_cfg_word()
416 pci_write_config_word(adapter->pdev, reg, value); in ixgbe_write_pci_cfg_word()
421 BUG_ON(!test_bit(__IXGBE_SERVICE_SCHED, &adapter->state)); in ixgbe_service_event_complete()
425 clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state); in ixgbe_service_event_complete()
467 * ixgbe_regdump - register printout routine
475 switch (reginfo->ofs) { in ixgbe_regdump()
533 pr_info("%-15s %08x\n", in ixgbe_regdump()
534 reginfo->name, IXGBE_READ_REG(hw, reginfo->ofs)); in ixgbe_regdump()
544 snprintf(rname, 16, "%s[%d-%d]", reginfo->name, i, i + 7); in ixgbe_regdump()
547 pr_err("%-15s%s\n", rname, buf); in ixgbe_regdump()
556 tx_buffer = &ring->tx_buffer_info[ring->next_to_clean]; in ixgbe_print_buffer()
558 n, ring->next_to_use, ring->next_to_clean, in ixgbe_print_buffer()
561 tx_buffer->next_to_watch, in ixgbe_print_buffer()
562 (u64)tx_buffer->time_stamp); in ixgbe_print_buffer()
566 * ixgbe_dump - Print registers, tx-rings and rx-rings
570 struct net_device *netdev = adapter->netdev; in ixgbe_dump()
571 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_dump()
588 dev_info(&adapter->pdev->dev, "Net device Info\n"); in ixgbe_dump()
591 pr_info("%-15s %016lX %016lX\n", in ixgbe_dump()
592 netdev->name, in ixgbe_dump()
593 netdev->state, in ixgbe_dump()
598 dev_info(&adapter->pdev->dev, "Register Dump\n"); in ixgbe_dump()
601 reginfo->name; reginfo++) { in ixgbe_dump()
609 dev_info(&adapter->pdev->dev, "TX Rings Summary\n"); in ixgbe_dump()
611 "Queue [NTU] [NTC] [bi(ntc)->dma ]", in ixgbe_dump()
613 for (n = 0; n < adapter->num_tx_queues; n++) { in ixgbe_dump()
614 ring = adapter->tx_ring[n]; in ixgbe_dump()
618 for (n = 0; n < adapter->num_xdp_queues; n++) { in ixgbe_dump()
619 ring = adapter->xdp_ring[n]; in ixgbe_dump()
627 dev_info(&adapter->pdev->dev, "TX Rings Dump\n"); in ixgbe_dump()
632 * +--------------------------------------------------------------+ in ixgbe_dump()
634 * +--------------------------------------------------------------+ in ixgbe_dump()
636 * +--------------------------------------------------------------+ in ixgbe_dump()
639 * 82598 Advanced Transmit Descriptor (Write-Back Format) in ixgbe_dump()
640 * +--------------------------------------------------------------+ in ixgbe_dump()
642 * +--------------------------------------------------------------+ in ixgbe_dump()
644 * +--------------------------------------------------------------+ in ixgbe_dump()
648 * +--------------------------------------------------------------+ in ixgbe_dump()
650 * +--------------------------------------------------------------+ in ixgbe_dump()
652 * +--------------------------------------------------------------+ in ixgbe_dump()
655 * 82599+ Advanced Transmit Descriptor (Write-Back Format) in ixgbe_dump()
656 * +--------------------------------------------------------------+ in ixgbe_dump()
658 * +--------------------------------------------------------------+ in ixgbe_dump()
660 * +--------------------------------------------------------------+ in ixgbe_dump()
664 for (n = 0; n < adapter->num_tx_queues; n++) { in ixgbe_dump()
665 ring = adapter->tx_ring[n]; in ixgbe_dump()
666 pr_info("------------------------------------\n"); in ixgbe_dump()
667 pr_info("TX QUEUE INDEX = %d\n", ring->queue_index); in ixgbe_dump()
668 pr_info("------------------------------------\n"); in ixgbe_dump()
671 "[PlPOIdStDDt Ln] [bi->dma ] ", in ixgbe_dump()
672 "leng", "ntw", "timestamp", "bi->skb"); in ixgbe_dump()
674 for (i = 0; ring->desc && (i < ring->count); i++) { in ixgbe_dump()
676 tx_buffer = &ring->tx_buffer_info[i]; in ixgbe_dump()
681 if (i == ring->next_to_use && in ixgbe_dump()
682 i == ring->next_to_clean) in ixgbe_dump()
684 else if (i == ring->next_to_use) in ixgbe_dump()
686 else if (i == ring->next_to_clean) in ixgbe_dump()
692 le64_to_cpu((__force __le64)u0->a), in ixgbe_dump()
693 le64_to_cpu((__force __le64)u0->b), in ixgbe_dump()
696 tx_buffer->next_to_watch, in ixgbe_dump()
697 (u64)tx_buffer->time_stamp, in ixgbe_dump()
698 tx_buffer->skb, in ixgbe_dump()
702 tx_buffer->skb) in ixgbe_dump()
705 tx_buffer->skb->data, in ixgbe_dump()
714 dev_info(&adapter->pdev->dev, "RX Rings Summary\n"); in ixgbe_dump()
716 for (n = 0; n < adapter->num_rx_queues; n++) { in ixgbe_dump()
717 rx_ring = adapter->rx_ring[n]; in ixgbe_dump()
719 n, rx_ring->next_to_use, rx_ring->next_to_clean); in ixgbe_dump()
726 dev_info(&adapter->pdev->dev, "RX Rings Dump\n"); in ixgbe_dump()
732 * +-----------------------------------------------------+ in ixgbe_dump()
734 * +----------------------------------------------+------+ in ixgbe_dump()
736 * +-----------------------------------------------------+ in ixgbe_dump()
739 * 82598 Advanced Receive Descriptor (Write-Back) Format in ixgbe_dump()
742 * +------------------------------------------------------+ in ixgbe_dump()
746 * +------------------------------------------------------+ in ixgbe_dump()
748 * +------------------------------------------------------+ in ixgbe_dump()
753 * +-----------------------------------------------------+ in ixgbe_dump()
755 * +----------------------------------------------+------+ in ixgbe_dump()
757 * +-----------------------------------------------------+ in ixgbe_dump()
760 * 82599+ Advanced Receive Descriptor (Write-Back) Format in ixgbe_dump()
763 * +------------------------------------------------------+ in ixgbe_dump()
764 * 0 |RSS / Frag Checksum|SPH| HDR_LEN |RSC- |Packet| RSS | in ixgbe_dump()
767 * +------------------------------------------------------+ in ixgbe_dump()
769 * +------------------------------------------------------+ in ixgbe_dump()
773 for (n = 0; n < adapter->num_rx_queues; n++) { in ixgbe_dump()
774 rx_ring = adapter->rx_ring[n]; in ixgbe_dump()
775 pr_info("------------------------------------\n"); in ixgbe_dump()
776 pr_info("RX QUEUE INDEX = %d\n", rx_ring->queue_index); in ixgbe_dump()
777 pr_info("------------------------------------\n"); in ixgbe_dump()
780 "[ HeadBuf DD] [bi->dma ] [bi->skb ] ", in ixgbe_dump()
781 "<-- Adv Rx Read format"); in ixgbe_dump()
784 "[vl er S cks ln] ---------------- [bi->skb ] ", in ixgbe_dump()
785 "<-- Adv Rx Write-Back format"); in ixgbe_dump()
787 for (i = 0; i < rx_ring->count; i++) { in ixgbe_dump()
790 if (i == rx_ring->next_to_use) in ixgbe_dump()
792 else if (i == rx_ring->next_to_clean) in ixgbe_dump()
797 rx_buffer_info = &rx_ring->rx_buffer_info[i]; in ixgbe_dump()
800 if (rx_desc->wb.upper.length) { in ixgbe_dump()
802 pr_info("RWB[0x%03X] %016llX %016llX ---------------- %p%s\n", in ixgbe_dump()
804 le64_to_cpu((__force __le64)u0->a), in ixgbe_dump()
805 le64_to_cpu((__force __le64)u0->b), in ixgbe_dump()
806 rx_buffer_info->skb, in ixgbe_dump()
811 le64_to_cpu((__force __le64)u0->a), in ixgbe_dump()
812 le64_to_cpu((__force __le64)u0->b), in ixgbe_dump()
813 (u64)rx_buffer_info->dma, in ixgbe_dump()
814 rx_buffer_info->skb, in ixgbe_dump()
818 rx_buffer_info->dma) { in ixgbe_dump()
821 page_address(rx_buffer_info->page) + in ixgbe_dump()
822 rx_buffer_info->page_offset, in ixgbe_dump()
835 ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT); in ixgbe_release_hw_control()
836 IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, in ixgbe_release_hw_control()
845 ctrl_ext = IXGBE_READ_REG(&adapter->hw, IXGBE_CTRL_EXT); in ixgbe_get_hw_control()
846 IXGBE_WRITE_REG(&adapter->hw, IXGBE_CTRL_EXT, in ixgbe_get_hw_control()
851 * ixgbe_set_ivar - set the IVAR registers, mapping interrupt causes to vectors
853 * @direction: 0 for Rx, 1 for Tx, -1 for other causes
862 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_ivar()
863 switch (hw->mac.type) { in ixgbe_set_ivar()
866 if (direction == -1) in ixgbe_set_ivar()
879 if (direction == -1) { in ixgbe_set_ivar()
883 ivar = IXGBE_READ_REG(&adapter->hw, IXGBE_IVAR_MISC); in ixgbe_set_ivar()
886 IXGBE_WRITE_REG(&adapter->hw, IXGBE_IVAR_MISC, ivar); in ixgbe_set_ivar()
908 switch (adapter->hw.mac.type) { in ixgbe_irq_rearm_queues()
911 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS, mask); in ixgbe_irq_rearm_queues()
919 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(0), mask); in ixgbe_irq_rearm_queues()
921 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICS_EX(1), mask); in ixgbe_irq_rearm_queues()
930 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_xoff_rx_lfc()
931 struct ixgbe_hw_stats *hwstats = &adapter->stats; in ixgbe_update_xoff_rx_lfc()
935 if ((hw->fc.current_mode != ixgbe_fc_full) && in ixgbe_update_xoff_rx_lfc()
936 (hw->fc.current_mode != ixgbe_fc_rx_pause)) in ixgbe_update_xoff_rx_lfc()
939 switch (hw->mac.type) { in ixgbe_update_xoff_rx_lfc()
946 hwstats->lxoffrxc += data; in ixgbe_update_xoff_rx_lfc()
952 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_update_xoff_rx_lfc()
954 &adapter->tx_ring[i]->state); in ixgbe_update_xoff_rx_lfc()
956 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_update_xoff_rx_lfc()
958 &adapter->xdp_ring[i]->state); in ixgbe_update_xoff_rx_lfc()
963 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_xoff_received()
964 struct ixgbe_hw_stats *hwstats = &adapter->stats; in ixgbe_update_xoff_received()
968 bool pfc_en = adapter->dcb_cfg.pfc_mode_enable; in ixgbe_update_xoff_received()
970 if (adapter->ixgbe_ieee_pfc) in ixgbe_update_xoff_received()
971 pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en); in ixgbe_update_xoff_received()
973 if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED) || !pfc_en) { in ixgbe_update_xoff_received()
982 switch (hw->mac.type) { in ixgbe_update_xoff_received()
989 hwstats->pxoffrxc[i] += pxoffrxc; in ixgbe_update_xoff_received()
991 tc = netdev_get_prio_tc_map(adapter->netdev, i); in ixgbe_update_xoff_received()
996 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_update_xoff_received()
997 struct ixgbe_ring *tx_ring = adapter->tx_ring[i]; in ixgbe_update_xoff_received()
999 tc = tx_ring->dcb_tc; in ixgbe_update_xoff_received()
1001 clear_bit(__IXGBE_HANG_CHECK_ARMED, &tx_ring->state); in ixgbe_update_xoff_received()
1004 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_update_xoff_received()
1005 struct ixgbe_ring *xdp_ring = adapter->xdp_ring[i]; in ixgbe_update_xoff_received()
1007 tc = xdp_ring->dcb_tc; in ixgbe_update_xoff_received()
1009 clear_bit(__IXGBE_HANG_CHECK_ARMED, &xdp_ring->state); in ixgbe_update_xoff_received()
1015 return ring->stats.packets; in ixgbe_get_tx_completed()
1022 head = ring->next_to_clean; in ixgbe_get_tx_pending()
1023 tail = ring->next_to_use; in ixgbe_get_tx_pending()
1025 return ((head <= tail) ? tail : tail + ring->count) - head; in ixgbe_get_tx_pending()
1031 u32 tx_done_old = tx_ring->tx_stats.tx_done_old; in ixgbe_check_tx_hang()
1051 &tx_ring->state); in ixgbe_check_tx_hang()
1053 tx_ring->tx_stats.tx_done_old = tx_done; in ixgbe_check_tx_hang()
1055 clear_bit(__IXGBE_HANG_CHECK_ARMED, &tx_ring->state); in ixgbe_check_tx_hang()
1061 * ixgbe_tx_timeout_reset - initiate reset due to Tx timeout
1068 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_tx_timeout_reset()
1069 set_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_tx_timeout_reset()
1076 * ixgbe_tx_maxrate - callback to set the maximum per-queue bitrate
1085 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_tx_maxrate()
1109 * ixgbe_update_tx_ring_stats - Update Tx ring specific counters
1119 u64_stats_update_begin(&tx_ring->syncp); in ixgbe_update_tx_ring_stats()
1120 tx_ring->stats.bytes += bytes; in ixgbe_update_tx_ring_stats()
1121 tx_ring->stats.packets += pkts; in ixgbe_update_tx_ring_stats()
1122 u64_stats_update_end(&tx_ring->syncp); in ixgbe_update_tx_ring_stats()
1123 q_vector->tx.total_bytes += bytes; in ixgbe_update_tx_ring_stats()
1124 q_vector->tx.total_packets += pkts; in ixgbe_update_tx_ring_stats()
1128 * ixgbe_update_rx_ring_stats - Update Rx ring specific counters
1138 u64_stats_update_begin(&rx_ring->syncp); in ixgbe_update_rx_ring_stats()
1139 rx_ring->stats.bytes += bytes; in ixgbe_update_rx_ring_stats()
1140 rx_ring->stats.packets += pkts; in ixgbe_update_rx_ring_stats()
1141 u64_stats_update_end(&rx_ring->syncp); in ixgbe_update_rx_ring_stats()
1142 q_vector->rx.total_bytes += bytes; in ixgbe_update_rx_ring_stats()
1143 q_vector->rx.total_packets += pkts; in ixgbe_update_rx_ring_stats()
1147 * ixgbe_clean_tx_irq - Reclaim resources after transmit completes
1155 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_clean_tx_irq()
1159 unsigned int budget = q_vector->tx.work_limit; in ixgbe_clean_tx_irq()
1160 unsigned int i = tx_ring->next_to_clean; in ixgbe_clean_tx_irq()
1163 if (test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_clean_tx_irq()
1166 tx_buffer = &tx_ring->tx_buffer_info[i]; in ixgbe_clean_tx_irq()
1168 i -= tx_ring->count; in ixgbe_clean_tx_irq()
1171 union ixgbe_adv_tx_desc *eop_desc = tx_buffer->next_to_watch; in ixgbe_clean_tx_irq()
1181 if (!(eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD))) in ixgbe_clean_tx_irq()
1185 tx_buffer->next_to_watch = NULL; in ixgbe_clean_tx_irq()
1188 total_bytes += tx_buffer->bytecount; in ixgbe_clean_tx_irq()
1189 total_packets += tx_buffer->gso_segs; in ixgbe_clean_tx_irq()
1190 if (tx_buffer->tx_flags & IXGBE_TX_FLAGS_IPSEC) in ixgbe_clean_tx_irq()
1195 xdp_return_frame(tx_buffer->xdpf); in ixgbe_clean_tx_irq()
1197 napi_consume_skb(tx_buffer->skb, napi_budget); in ixgbe_clean_tx_irq()
1200 dma_unmap_single(tx_ring->dev, in ixgbe_clean_tx_irq()
1214 i -= tx_ring->count; in ixgbe_clean_tx_irq()
1215 tx_buffer = tx_ring->tx_buffer_info; in ixgbe_clean_tx_irq()
1221 dma_unmap_page(tx_ring->dev, in ixgbe_clean_tx_irq()
1234 i -= tx_ring->count; in ixgbe_clean_tx_irq()
1235 tx_buffer = tx_ring->tx_buffer_info; in ixgbe_clean_tx_irq()
1243 budget--; in ixgbe_clean_tx_irq()
1246 i += tx_ring->count; in ixgbe_clean_tx_irq()
1247 tx_ring->next_to_clean = i; in ixgbe_clean_tx_irq()
1250 adapter->tx_ipsec += total_ipsec; in ixgbe_clean_tx_irq()
1254 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_clean_tx_irq()
1264 tx_ring->queue_index, in ixgbe_clean_tx_irq()
1265 IXGBE_READ_REG(hw, IXGBE_TDH(tx_ring->reg_idx)), in ixgbe_clean_tx_irq()
1266 IXGBE_READ_REG(hw, IXGBE_TDT(tx_ring->reg_idx)), in ixgbe_clean_tx_irq()
1267 tx_ring->next_to_use, i, in ixgbe_clean_tx_irq()
1268 tx_ring->tx_buffer_info[i].time_stamp, jiffies); in ixgbe_clean_tx_irq()
1271 netif_stop_subqueue(tx_ring->netdev, in ixgbe_clean_tx_irq()
1272 tx_ring->queue_index); in ixgbe_clean_tx_irq()
1276 adapter->tx_timeout_count + 1, tx_ring->queue_index); in ixgbe_clean_tx_irq()
1289 txq = netdev_get_tx_queue(tx_ring->netdev, tx_ring->queue_index); in ixgbe_clean_tx_irq()
1293 !netif_carrier_ok(tx_ring->netdev) || in ixgbe_clean_tx_irq()
1294 test_bit(__IXGBE_DOWN, &adapter->state))) in ixgbe_clean_tx_irq()
1295 ++tx_ring->tx_stats.restart_queue; in ixgbe_clean_tx_irq()
1303 int cpu) in ixgbe_update_tx_dca() argument
1305 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_tx_dca()
1309 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in ixgbe_update_tx_dca()
1310 txctrl = dca3_get_tag(tx_ring->dev, cpu); in ixgbe_update_tx_dca()
1312 switch (hw->mac.type) { in ixgbe_update_tx_dca()
1314 reg_offset = IXGBE_DCA_TXCTRL(tx_ring->reg_idx); in ixgbe_update_tx_dca()
1318 reg_offset = IXGBE_DCA_TXCTRL_82599(tx_ring->reg_idx); in ixgbe_update_tx_dca()
1340 int cpu) in ixgbe_update_rx_dca() argument
1342 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_rx_dca()
1344 u8 reg_idx = rx_ring->reg_idx; in ixgbe_update_rx_dca()
1346 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in ixgbe_update_rx_dca()
1347 rxctrl = dca3_get_tag(rx_ring->dev, cpu); in ixgbe_update_rx_dca()
1349 switch (hw->mac.type) { in ixgbe_update_rx_dca()
1372 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_update_dca()
1374 int cpu = get_cpu(); in ixgbe_update_dca() local
1376 if (q_vector->cpu == cpu) in ixgbe_update_dca()
1379 ixgbe_for_each_ring(ring, q_vector->tx) in ixgbe_update_dca()
1380 ixgbe_update_tx_dca(adapter, ring, cpu); in ixgbe_update_dca()
1382 ixgbe_for_each_ring(ring, q_vector->rx) in ixgbe_update_dca()
1383 ixgbe_update_rx_dca(adapter, ring, cpu); in ixgbe_update_dca()
1385 q_vector->cpu = cpu; in ixgbe_update_dca()
1395 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in ixgbe_setup_dca()
1396 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in ixgbe_setup_dca()
1399 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in ixgbe_setup_dca()
1402 for (i = 0; i < adapter->num_q_vectors; i++) { in ixgbe_setup_dca()
1403 adapter->q_vector[i]->cpu = -1; in ixgbe_setup_dca()
1404 ixgbe_update_dca(adapter->q_vector[i]); in ixgbe_setup_dca()
1413 if (!(adapter->flags & IXGBE_FLAG_DCA_CAPABLE)) in __ixgbe_notify_dca()
1419 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in __ixgbe_notify_dca()
1422 adapter->flags |= IXGBE_FLAG_DCA_ENABLED; in __ixgbe_notify_dca()
1423 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in __ixgbe_notify_dca()
1429 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) { in __ixgbe_notify_dca()
1431 adapter->flags &= ~IXGBE_FLAG_DCA_ENABLED; in __ixgbe_notify_dca()
1432 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in __ixgbe_notify_dca()
1455 if (!(ring->netdev->features & NETIF_F_RXHASH)) in ixgbe_rx_hash()
1458 rss_type = le16_to_cpu(rx_desc->wb.lower.lo_dword.hs_rss.pkt_info) & in ixgbe_rx_hash()
1464 skb_set_hash(skb, le32_to_cpu(rx_desc->wb.lower.hi_dword.rss), in ixgbe_rx_hash()
1471 * ixgbe_rx_is_fcoe - check the rx desc for incoming pkt type
1480 __le16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info; in ixgbe_rx_is_fcoe()
1482 return test_bit(__IXGBE_RX_FCOE, &ring->state) && in ixgbe_rx_is_fcoe()
1490 * ixgbe_rx_checksum - indicate in skb if hw indicated a good cksum
1499 __le16 pkt_info = rx_desc->wb.lower.lo_dword.hs_rss.pkt_info; in ixgbe_rx_checksum()
1505 if (!(ring->netdev->features & NETIF_F_RXCSUM)) in ixgbe_rx_checksum()
1511 skb->encapsulation = 1; in ixgbe_rx_checksum()
1517 ring->rx_stats.csum_err++; in ixgbe_rx_checksum()
1530 test_bit(__IXGBE_RX_CSUM_UDP_ZERO_ERR, &ring->state)) in ixgbe_rx_checksum()
1533 ring->rx_stats.csum_err++; in ixgbe_rx_checksum()
1538 skb->ip_summed = CHECKSUM_UNNECESSARY; in ixgbe_rx_checksum()
1544 skb->ip_summed = CHECKSUM_NONE; in ixgbe_rx_checksum()
1548 skb->csum_level = 1; in ixgbe_rx_checksum()
1560 struct page *page = bi->page; in ixgbe_alloc_mapped_page()
1570 rx_ring->rx_stats.alloc_rx_page_failed++; in ixgbe_alloc_mapped_page()
1575 dma = dma_map_page_attrs(rx_ring->dev, page, 0, in ixgbe_alloc_mapped_page()
1584 if (dma_mapping_error(rx_ring->dev, dma)) { in ixgbe_alloc_mapped_page()
1587 rx_ring->rx_stats.alloc_rx_page_failed++; in ixgbe_alloc_mapped_page()
1591 bi->dma = dma; in ixgbe_alloc_mapped_page()
1592 bi->page = page; in ixgbe_alloc_mapped_page()
1593 bi->page_offset = rx_ring->rx_offset; in ixgbe_alloc_mapped_page()
1594 page_ref_add(page, USHRT_MAX - 1); in ixgbe_alloc_mapped_page()
1595 bi->pagecnt_bias = USHRT_MAX; in ixgbe_alloc_mapped_page()
1596 rx_ring->rx_stats.alloc_rx_page++; in ixgbe_alloc_mapped_page()
1602 * ixgbe_alloc_rx_buffers - Replace used receive buffers
1610 u16 i = rx_ring->next_to_use; in ixgbe_alloc_rx_buffers()
1618 bi = &rx_ring->rx_buffer_info[i]; in ixgbe_alloc_rx_buffers()
1619 i -= rx_ring->count; in ixgbe_alloc_rx_buffers()
1628 dma_sync_single_range_for_device(rx_ring->dev, bi->dma, in ixgbe_alloc_rx_buffers()
1629 bi->page_offset, bufsz, in ixgbe_alloc_rx_buffers()
1634 * because each write-back erases this info. in ixgbe_alloc_rx_buffers()
1636 rx_desc->read.pkt_addr = cpu_to_le64(bi->dma + bi->page_offset); in ixgbe_alloc_rx_buffers()
1643 bi = rx_ring->rx_buffer_info; in ixgbe_alloc_rx_buffers()
1644 i -= rx_ring->count; in ixgbe_alloc_rx_buffers()
1648 rx_desc->wb.upper.length = 0; in ixgbe_alloc_rx_buffers()
1650 cleaned_count--; in ixgbe_alloc_rx_buffers()
1653 i += rx_ring->count; in ixgbe_alloc_rx_buffers()
1655 if (rx_ring->next_to_use != i) { in ixgbe_alloc_rx_buffers()
1656 rx_ring->next_to_use = i; in ixgbe_alloc_rx_buffers()
1659 rx_ring->next_to_alloc = i; in ixgbe_alloc_rx_buffers()
1663 * applicable for weak-ordered memory model archs, in ixgbe_alloc_rx_buffers()
1664 * such as IA-64). in ixgbe_alloc_rx_buffers()
1667 writel(i, rx_ring->tail); in ixgbe_alloc_rx_buffers()
1677 skb_shinfo(skb)->gso_size = DIV_ROUND_UP((skb->len - hdr_len), in ixgbe_set_rsc_gso_size()
1678 IXGBE_CB(skb)->append_cnt); in ixgbe_set_rsc_gso_size()
1679 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; in ixgbe_set_rsc_gso_size()
1686 if (!IXGBE_CB(skb)->append_cnt) in ixgbe_update_rsc_stats()
1689 rx_ring->rx_stats.rsc_count += IXGBE_CB(skb)->append_cnt; in ixgbe_update_rsc_stats()
1690 rx_ring->rx_stats.rsc_flush++; in ixgbe_update_rsc_stats()
1695 IXGBE_CB(skb)->append_cnt = 0; in ixgbe_update_rsc_stats()
1699 * ixgbe_process_skb_fields - Populate skb header fields from Rx descriptor
1712 struct net_device *dev = rx_ring->netdev; in ixgbe_process_skb_fields()
1713 u32 flags = rx_ring->q_vector->adapter->flags; in ixgbe_process_skb_fields()
1724 if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) && in ixgbe_process_skb_fields()
1726 u16 vid = le16_to_cpu(rx_desc->wb.upper.vlan); in ixgbe_process_skb_fields()
1735 skb_record_rx_queue(skb, rx_ring->queue_index); in ixgbe_process_skb_fields()
1737 macvlan_count_rx(netdev_priv(dev), skb->len + ETH_HLEN, true, in ixgbe_process_skb_fields()
1740 skb->protocol = eth_type_trans(skb, dev); in ixgbe_process_skb_fields()
1746 napi_gro_receive(&q_vector->napi, skb); in ixgbe_rx_skb()
1750 * ixgbe_is_non_eop - process handling of non-EOP buffers
1758 * that this is in fact a non-EOP buffer.
1764 u32 ntc = rx_ring->next_to_clean + 1; in ixgbe_is_non_eop()
1767 ntc = (ntc < rx_ring->count) ? ntc : 0; in ixgbe_is_non_eop()
1768 rx_ring->next_to_clean = ntc; in ixgbe_is_non_eop()
1774 __le32 rsc_enabled = rx_desc->wb.lower.lo_dword.data & in ixgbe_is_non_eop()
1781 IXGBE_CB(skb)->append_cnt += rsc_cnt - 1; in ixgbe_is_non_eop()
1784 ntc = le32_to_cpu(rx_desc->wb.upper.status_error); in ixgbe_is_non_eop()
1795 rx_ring->rx_buffer_info[ntc].skb = skb; in ixgbe_is_non_eop()
1796 rx_ring->rx_stats.non_eop_descs++; in ixgbe_is_non_eop()
1802 * ixgbe_pull_tail - ixgbe specific version of skb_pull_tail
1816 skb_frag_t *frag = &skb_shinfo(skb)->frags[0]; in ixgbe_pull_tail()
1829 * 60 bytes if the skb->len is less than 60 for skb_pad. in ixgbe_pull_tail()
1831 pull_len = eth_get_headlen(skb->dev, va, IXGBE_RX_HDR_SIZE); in ixgbe_pull_tail()
1839 skb->data_len -= pull_len; in ixgbe_pull_tail()
1840 skb->tail += pull_len; in ixgbe_pull_tail()
1844 * ixgbe_dma_sync_frag - perform DMA sync for first frag of SKB
1857 unsigned long mask = (unsigned long)ixgbe_rx_pg_size(rx_ring) - 1; in ixgbe_dma_sync_frag()
1858 unsigned long offset = (unsigned long)(skb->data) & mask; in ixgbe_dma_sync_frag()
1860 dma_sync_single_range_for_cpu(rx_ring->dev, in ixgbe_dma_sync_frag()
1861 IXGBE_CB(skb)->dma, in ixgbe_dma_sync_frag()
1866 skb_frag_t *frag = &skb_shinfo(skb)->frags[0]; in ixgbe_dma_sync_frag()
1868 dma_sync_single_range_for_cpu(rx_ring->dev, in ixgbe_dma_sync_frag()
1869 IXGBE_CB(skb)->dma, in ixgbe_dma_sync_frag()
1876 if (unlikely(IXGBE_CB(skb)->page_released)) { in ixgbe_dma_sync_frag()
1877 dma_unmap_page_attrs(rx_ring->dev, IXGBE_CB(skb)->dma, in ixgbe_dma_sync_frag()
1885 * ixgbe_cleanup_headers - Correct corrupted or empty headers
1910 struct net_device *netdev = rx_ring->netdev; in ixgbe_cleanup_headers()
1922 !(netdev->features & NETIF_F_RXALL)))) { in ixgbe_cleanup_headers()
1945 * ixgbe_reuse_rx_page - page flip buffer and store it back on the ring
1955 u16 nta = rx_ring->next_to_alloc; in ixgbe_reuse_rx_page()
1957 new_buff = &rx_ring->rx_buffer_info[nta]; in ixgbe_reuse_rx_page()
1961 rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0; in ixgbe_reuse_rx_page()
1967 new_buff->dma = old_buff->dma; in ixgbe_reuse_rx_page()
1968 new_buff->page = old_buff->page; in ixgbe_reuse_rx_page()
1969 new_buff->page_offset = old_buff->page_offset; in ixgbe_reuse_rx_page()
1970 new_buff->pagecnt_bias = old_buff->pagecnt_bias; in ixgbe_reuse_rx_page()
1976 unsigned int pagecnt_bias = rx_buffer->pagecnt_bias; in ixgbe_can_reuse_rx_page()
1977 struct page *page = rx_buffer->page; in ixgbe_can_reuse_rx_page()
1979 /* avoid re-using remote and pfmemalloc pages */ in ixgbe_can_reuse_rx_page()
1985 if (unlikely((rx_buffer_pgcnt - pagecnt_bias) > 1)) in ixgbe_can_reuse_rx_page()
1994 (SKB_WITH_OVERHEAD(PAGE_SIZE) - IXGBE_RXBUFFER_3K) in ixgbe_can_reuse_rx_page()
1995 if (rx_buffer->page_offset > IXGBE_LAST_OFFSET) in ixgbe_can_reuse_rx_page()
2004 page_ref_add(page, USHRT_MAX - 1); in ixgbe_can_reuse_rx_page()
2005 rx_buffer->pagecnt_bias = USHRT_MAX; in ixgbe_can_reuse_rx_page()
2012 * ixgbe_add_rx_frag - Add contents of Rx buffer to sk_buff
2018 * This function will add the data contained in rx_buffer->page to the skb.
2034 unsigned int truesize = rx_ring->rx_offset ? in ixgbe_add_rx_frag()
2035 SKB_DATA_ALIGN(rx_ring->rx_offset + size) : in ixgbe_add_rx_frag()
2038 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page, in ixgbe_add_rx_frag()
2039 rx_buffer->page_offset, size, truesize); in ixgbe_add_rx_frag()
2041 rx_buffer->page_offset ^= truesize; in ixgbe_add_rx_frag()
2043 rx_buffer->page_offset += truesize; in ixgbe_add_rx_frag()
2055 rx_buffer = &rx_ring->rx_buffer_info[rx_ring->next_to_clean]; in ixgbe_get_rx_buffer()
2058 page_count(rx_buffer->page); in ixgbe_get_rx_buffer()
2062 prefetchw(rx_buffer->page); in ixgbe_get_rx_buffer()
2063 *skb = rx_buffer->skb; in ixgbe_get_rx_buffer()
2077 /* we are reusing so sync this buffer for CPU use */ in ixgbe_get_rx_buffer()
2078 dma_sync_single_range_for_cpu(rx_ring->dev, in ixgbe_get_rx_buffer()
2079 rx_buffer->dma, in ixgbe_get_rx_buffer()
2080 rx_buffer->page_offset, in ixgbe_get_rx_buffer()
2084 rx_buffer->pagecnt_bias--; in ixgbe_get_rx_buffer()
2098 if (!IS_ERR(skb) && IXGBE_CB(skb)->dma == rx_buffer->dma) { in ixgbe_put_rx_buffer()
2100 IXGBE_CB(skb)->page_released = true; in ixgbe_put_rx_buffer()
2103 dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, in ixgbe_put_rx_buffer()
2108 __page_frag_cache_drain(rx_buffer->page, in ixgbe_put_rx_buffer()
2109 rx_buffer->pagecnt_bias); in ixgbe_put_rx_buffer()
2113 rx_buffer->page = NULL; in ixgbe_put_rx_buffer()
2114 rx_buffer->skb = NULL; in ixgbe_put_rx_buffer()
2122 unsigned int size = xdp->data_end - xdp->data; in ixgbe_construct_skb()
2126 unsigned int truesize = SKB_DATA_ALIGN(xdp->data_end - in ixgbe_construct_skb()
2127 xdp->data_hard_start); in ixgbe_construct_skb()
2132 net_prefetch(xdp->data); in ixgbe_construct_skb()
2134 /* Note, we get here by enabling legacy-rx via: in ixgbe_construct_skb()
2136 * ethtool --set-priv-flags <dev> legacy-rx on in ixgbe_construct_skb()
2139 * opposed to having legacy-rx off, where we process XDP in ixgbe_construct_skb()
2144 * xdp->data_meta will always point to xdp->data, since in ixgbe_construct_skb()
2146 * change in future for legacy-rx mode on, then lets also in ixgbe_construct_skb()
2147 * add xdp->data_meta handling here. in ixgbe_construct_skb()
2151 skb = napi_alloc_skb(&rx_ring->q_vector->napi, IXGBE_RX_HDR_SIZE); in ixgbe_construct_skb()
2157 IXGBE_CB(skb)->dma = rx_buffer->dma; in ixgbe_construct_skb()
2159 skb_add_rx_frag(skb, 0, rx_buffer->page, in ixgbe_construct_skb()
2160 xdp->data - page_address(rx_buffer->page), in ixgbe_construct_skb()
2163 rx_buffer->page_offset ^= truesize; in ixgbe_construct_skb()
2165 rx_buffer->page_offset += truesize; in ixgbe_construct_skb()
2169 xdp->data, ALIGN(size, sizeof(long))); in ixgbe_construct_skb()
2170 rx_buffer->pagecnt_bias++; in ixgbe_construct_skb()
2181 unsigned int metasize = xdp->data - xdp->data_meta; in ixgbe_build_skb()
2186 SKB_DATA_ALIGN(xdp->data_end - in ixgbe_build_skb()
2187 xdp->data_hard_start); in ixgbe_build_skb()
2191 /* Prefetch first cache line of first page. If xdp->data_meta in ixgbe_build_skb()
2192 * is unused, this points extactly as xdp->data, otherwise we in ixgbe_build_skb()
2196 net_prefetch(xdp->data_meta); in ixgbe_build_skb()
2199 skb = napi_build_skb(xdp->data_hard_start, truesize); in ixgbe_build_skb()
2204 skb_reserve(skb, xdp->data - xdp->data_hard_start); in ixgbe_build_skb()
2205 __skb_put(skb, xdp->data_end - xdp->data); in ixgbe_build_skb()
2211 IXGBE_CB(skb)->dma = rx_buffer->dma; in ixgbe_build_skb()
2215 rx_buffer->page_offset ^= truesize; in ixgbe_build_skb()
2217 rx_buffer->page_offset += truesize; in ixgbe_build_skb()
2233 xdp_prog = READ_ONCE(rx_ring->xdp_prog); in ixgbe_run_xdp()
2238 prefetchw(xdp->data_hard_start); /* xdp_frame write */ in ixgbe_run_xdp()
2250 spin_lock(&ring->tx_lock); in ixgbe_run_xdp()
2253 spin_unlock(&ring->tx_lock); in ixgbe_run_xdp()
2258 err = xdp_do_redirect(adapter->netdev, xdp, xdp_prog); in ixgbe_run_xdp()
2264 bpf_warn_invalid_xdp_action(rx_ring->netdev, xdp_prog, act); in ixgbe_run_xdp()
2268 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); in ixgbe_run_xdp()
2275 return ERR_PTR(-result); in ixgbe_run_xdp()
2284 truesize = ixgbe_rx_pg_size(rx_ring) / 2; /* Must be power-of-2 */ in ixgbe_rx_frame_truesize()
2286 truesize = rx_ring->rx_offset ? in ixgbe_rx_frame_truesize()
2287 SKB_DATA_ALIGN(rx_ring->rx_offset + size) + in ixgbe_rx_frame_truesize()
2300 rx_buffer->page_offset ^= truesize; in ixgbe_rx_buffer_flip()
2302 rx_buffer->page_offset += truesize; in ixgbe_rx_buffer_flip()
2307 * ixgbe_clean_rx_irq - Clean completed descriptors from Rx ring - bounce buf
2324 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_clean_rx_irq()
2330 unsigned int offset = rx_ring->rx_offset; in ixgbe_clean_rx_irq()
2338 xdp_init_buff(&xdp, frame_sz, &rx_ring->xdp_rxq); in ixgbe_clean_rx_irq()
2353 rx_desc = IXGBE_RX_DESC(rx_ring, rx_ring->next_to_clean); in ixgbe_clean_rx_irq()
2354 size = le16_to_cpu(rx_desc->wb.upper.length); in ixgbe_clean_rx_irq()
2370 hard_start = page_address(rx_buffer->page) + in ixgbe_clean_rx_irq()
2371 rx_buffer->page_offset - offset; in ixgbe_clean_rx_irq()
2382 unsigned int xdp_res = -PTR_ERR(skb); in ixgbe_clean_rx_irq()
2388 rx_buffer->pagecnt_bias++; in ixgbe_clean_rx_irq()
2404 rx_ring->rx_stats.alloc_rx_buff_failed++; in ixgbe_clean_rx_irq()
2405 rx_buffer->pagecnt_bias++; in ixgbe_clean_rx_irq()
2421 total_rx_bytes += skb->len; in ixgbe_clean_rx_irq()
2433 mss = rx_ring->netdev->mtu - in ixgbe_clean_rx_irq()
2434 sizeof(struct fcoe_hdr) - in ixgbe_clean_rx_irq()
2435 sizeof(struct fc_frame_header) - in ixgbe_clean_rx_irq()
2473 * ixgbe_configure_msix - Configure MSI-X hardware
2476 * ixgbe_configure_msix sets up the hardware to properly generate MSI-X
2486 if (adapter->num_vfs > 32) { in ixgbe_configure_msix()
2487 u32 eitrsel = BIT(adapter->num_vfs - 32) - 1; in ixgbe_configure_msix()
2488 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITRSEL, eitrsel); in ixgbe_configure_msix()
2495 for (v_idx = 0; v_idx < adapter->num_q_vectors; v_idx++) { in ixgbe_configure_msix()
2497 q_vector = adapter->q_vector[v_idx]; in ixgbe_configure_msix()
2499 ixgbe_for_each_ring(ring, q_vector->rx) in ixgbe_configure_msix()
2500 ixgbe_set_ivar(adapter, 0, ring->reg_idx, v_idx); in ixgbe_configure_msix()
2502 ixgbe_for_each_ring(ring, q_vector->tx) in ixgbe_configure_msix()
2503 ixgbe_set_ivar(adapter, 1, ring->reg_idx, v_idx); in ixgbe_configure_msix()
2508 switch (adapter->hw.mac.type) { in ixgbe_configure_msix()
2510 ixgbe_set_ivar(adapter, -1, IXGBE_IVAR_OTHER_CAUSES_INDEX, in ixgbe_configure_msix()
2518 ixgbe_set_ivar(adapter, -1, 1, v_idx); in ixgbe_configure_msix()
2523 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITR(v_idx), 1950); in ixgbe_configure_msix()
2531 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIAC, mask); in ixgbe_configure_msix()
2535 * ixgbe_update_itr - update the dynamic ITR value based on statistics
2558 if (!ring_container->ring) in ixgbe_update_itr()
2561 /* If we didn't update within up to 1 - 2 jiffies we can assume in ixgbe_update_itr()
2566 if (time_after(next_update, ring_container->next_update)) in ixgbe_update_itr()
2569 packets = ring_container->total_packets; in ixgbe_update_itr()
2580 itr = (q_vector->itr >> 2) + IXGBE_ITR_ADAPTIVE_MIN_INC; in ixgbe_update_itr()
2583 itr += ring_container->itr & IXGBE_ITR_ADAPTIVE_LATENCY; in ixgbe_update_itr()
2587 bytes = ring_container->total_bytes; in ixgbe_update_itr()
2603 itr = (q_vector->itr >> 2) + IXGBE_ITR_ADAPTIVE_MIN_INC; in ixgbe_update_itr()
2613 itr = q_vector->itr >> 2; in ixgbe_update_itr()
2622 itr = q_vector->itr >> 3; in ixgbe_update_itr()
2692 switch (q_vector->adapter->link_speed) { in ixgbe_update_itr()
2713 ring_container->itr = itr; in ixgbe_update_itr()
2716 ring_container->next_update = next_update + 1; in ixgbe_update_itr()
2718 ring_container->total_bytes = 0; in ixgbe_update_itr()
2719 ring_container->total_packets = 0; in ixgbe_update_itr()
2723 * ixgbe_write_eitr - write EITR register in hardware specific way
2732 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_write_eitr()
2733 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_write_eitr()
2734 int v_idx = q_vector->v_idx; in ixgbe_write_eitr()
2735 u32 itr_reg = q_vector->itr & IXGBE_MAX_EITR; in ixgbe_write_eitr()
2737 switch (adapter->hw.mac.type) { in ixgbe_write_eitr()
2763 ixgbe_update_itr(q_vector, &q_vector->tx); in ixgbe_set_itr()
2764 ixgbe_update_itr(q_vector, &q_vector->rx); in ixgbe_set_itr()
2767 new_itr = min(q_vector->rx.itr, q_vector->tx.itr); in ixgbe_set_itr()
2773 if (new_itr != q_vector->itr) { in ixgbe_set_itr()
2775 q_vector->itr = new_itr; in ixgbe_set_itr()
2782 * ixgbe_check_overtemp_subtask - check for over temperature
2787 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_overtemp_subtask()
2788 u32 eicr = adapter->interrupt_event; in ixgbe_check_overtemp_subtask()
2790 if (test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_check_overtemp_subtask()
2793 if (!(adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_EVENT)) in ixgbe_check_overtemp_subtask()
2796 adapter->flags2 &= ~IXGBE_FLAG2_TEMP_SENSOR_EVENT; in ixgbe_check_overtemp_subtask()
2798 switch (hw->device_id) { in ixgbe_check_overtemp_subtask()
2803 * - This interrupt wasn't for our port. in ixgbe_check_overtemp_subtask()
2804 * - We may have missed the interrupt so always have to in ixgbe_check_overtemp_subtask()
2811 if (!(eicr & IXGBE_EICR_LSC) && hw->mac.ops.check_link) { in ixgbe_check_overtemp_subtask()
2815 hw->mac.ops.check_link(hw, &speed, &link_up, false); in ixgbe_check_overtemp_subtask()
2822 if (!hw->phy.ops.check_overtemp(hw)) in ixgbe_check_overtemp_subtask()
2828 if (!hw->phy.ops.check_overtemp(hw)) in ixgbe_check_overtemp_subtask()
2832 if (adapter->hw.mac.type >= ixgbe_mac_X540) in ixgbe_check_overtemp_subtask()
2840 adapter->interrupt_event = 0; in ixgbe_check_overtemp_subtask()
2845 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_fan_failure()
2847 if ((adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) && in ixgbe_check_fan_failure()
2857 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_overtemp_event()
2859 if (!(adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE)) in ixgbe_check_overtemp_event()
2862 switch (adapter->hw.mac.type) { in ixgbe_check_overtemp_event()
2870 (!test_bit(__IXGBE_DOWN, &adapter->state))) { in ixgbe_check_overtemp_event()
2871 adapter->interrupt_event = eicr; in ixgbe_check_overtemp_event()
2872 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_EVENT; in ixgbe_check_overtemp_event()
2879 adapter->interrupt_event = eicr; in ixgbe_check_overtemp_event()
2880 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_EVENT; in ixgbe_check_overtemp_event()
2882 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, in ixgbe_check_overtemp_event()
2884 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EICR, in ixgbe_check_overtemp_event()
2902 switch (hw->mac.type) { in ixgbe_is_sfp()
2904 if (hw->phy.type == ixgbe_phy_nl) in ixgbe_is_sfp()
2910 switch (hw->mac.ops.get_media_type(hw)) { in ixgbe_is_sfp()
2924 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_sfp_event()
2931 if (hw->mac.type >= ixgbe_mac_X540) in ixgbe_check_sfp_event()
2937 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_check_sfp_event()
2938 adapter->flags2 |= IXGBE_FLAG2_SFP_NEEDS_RESET; in ixgbe_check_sfp_event()
2939 adapter->sfp_poll_time = 0; in ixgbe_check_sfp_event()
2944 if (adapter->hw.mac.type == ixgbe_mac_82599EB && in ixgbe_check_sfp_event()
2948 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_check_sfp_event()
2949 adapter->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; in ixgbe_check_sfp_event()
2957 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_lsc()
2959 adapter->lsc_int++; in ixgbe_check_lsc()
2960 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_check_lsc()
2961 adapter->link_check_timeout = jiffies; in ixgbe_check_lsc()
2962 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_check_lsc()
2972 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_irq_enable_queues()
2975 switch (hw->mac.type) { in ixgbe_irq_enable_queues()
2999 * ixgbe_irq_enable - Enable default interrupt generation settings
3007 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_irq_enable()
3011 if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE) in ixgbe_irq_enable()
3014 if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) in ixgbe_irq_enable()
3015 switch (adapter->hw.mac.type) { in ixgbe_irq_enable()
3028 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) in ixgbe_irq_enable()
3030 switch (adapter->hw.mac.type) { in ixgbe_irq_enable()
3039 if (adapter->hw.device_id == IXGBE_DEV_ID_X550EM_X_SFP || in ixgbe_irq_enable()
3040 adapter->hw.device_id == IXGBE_DEV_ID_X550EM_A_SFP || in ixgbe_irq_enable()
3041 adapter->hw.device_id == IXGBE_DEV_ID_X550EM_A_SFP_N) in ixgbe_irq_enable()
3042 mask |= IXGBE_EIMS_GPI_SDP0(&adapter->hw); in ixgbe_irq_enable()
3043 if (adapter->hw.phy.type == ixgbe_phy_x550em_ext_t) in ixgbe_irq_enable()
3052 if ((adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) && in ixgbe_irq_enable()
3053 !(adapter->flags2 & IXGBE_FLAG2_FDIR_REQUIRES_REINIT)) in ixgbe_irq_enable()
3056 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMS, mask); in ixgbe_irq_enable()
3060 IXGBE_WRITE_FLUSH(&adapter->hw); in ixgbe_irq_enable()
3066 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_msix_other()
3070 * Workaround for Silicon errata. Use clear-by-write instead in ixgbe_msix_other()
3071 * of clear-by-read. Reading with EICS will return the in ixgbe_msix_other()
3094 switch (hw->mac.type) { in ixgbe_msix_other()
3100 if (hw->phy.type == ixgbe_phy_x550em_ext_t && in ixgbe_msix_other()
3102 adapter->flags2 |= IXGBE_FLAG2_PHY_INTERRUPT; in ixgbe_msix_other()
3109 set_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_msix_other()
3117 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_msix_other()
3118 struct ixgbe_ring *ring = adapter->tx_ring[i]; in ixgbe_msix_other()
3120 &ring->state)) in ixgbe_msix_other()
3126 adapter->flags2 |= IXGBE_FLAG2_FDIR_REQUIRES_REINIT; in ixgbe_msix_other()
3142 /* re-enable the original interrupt state, no lsc, no queues */ in ixgbe_msix_other()
3143 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_msix_other()
3155 if (q_vector->rx.ring || q_vector->tx.ring) in ixgbe_msix_clean_rings()
3156 napi_schedule_irqoff(&q_vector->napi); in ixgbe_msix_clean_rings()
3162 * ixgbe_poll - NAPI Rx polling callback
3172 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_poll()
3178 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) in ixgbe_poll()
3182 ixgbe_for_each_ring(ring, q_vector->tx) { in ixgbe_poll()
3183 bool wd = ring->xsk_pool ? in ixgbe_poll()
3197 if (q_vector->rx.count > 1) in ixgbe_poll()
3198 per_ring_budget = max(budget/q_vector->rx.count, 1); in ixgbe_poll()
3202 ixgbe_for_each_ring(ring, q_vector->rx) { in ixgbe_poll()
3203 int cleaned = ring->xsk_pool ? in ixgbe_poll()
3220 if (adapter->rx_itr_setting & 1) in ixgbe_poll()
3222 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_poll()
3224 BIT_ULL(q_vector->v_idx)); in ixgbe_poll()
3227 return min(work_done, budget - 1); in ixgbe_poll()
3231 * ixgbe_request_msix_irqs - Initialize MSI-X interrupts
3234 * ixgbe_request_msix_irqs allocates MSI-X vectors and requests
3239 struct net_device *netdev = adapter->netdev; in ixgbe_request_msix_irqs()
3243 for (vector = 0; vector < adapter->num_q_vectors; vector++) { in ixgbe_request_msix_irqs()
3244 struct ixgbe_q_vector *q_vector = adapter->q_vector[vector]; in ixgbe_request_msix_irqs()
3245 struct msix_entry *entry = &adapter->msix_entries[vector]; in ixgbe_request_msix_irqs()
3247 if (q_vector->tx.ring && q_vector->rx.ring) { in ixgbe_request_msix_irqs()
3248 snprintf(q_vector->name, sizeof(q_vector->name), in ixgbe_request_msix_irqs()
3249 "%s-TxRx-%u", netdev->name, ri++); in ixgbe_request_msix_irqs()
3251 } else if (q_vector->rx.ring) { in ixgbe_request_msix_irqs()
3252 snprintf(q_vector->name, sizeof(q_vector->name), in ixgbe_request_msix_irqs()
3253 "%s-rx-%u", netdev->name, ri++); in ixgbe_request_msix_irqs()
3254 } else if (q_vector->tx.ring) { in ixgbe_request_msix_irqs()
3255 snprintf(q_vector->name, sizeof(q_vector->name), in ixgbe_request_msix_irqs()
3256 "%s-tx-%u", netdev->name, ti++); in ixgbe_request_msix_irqs()
3261 err = request_irq(entry->vector, &ixgbe_msix_clean_rings, 0, in ixgbe_request_msix_irqs()
3262 q_vector->name, q_vector); in ixgbe_request_msix_irqs()
3269 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { in ixgbe_request_msix_irqs()
3271 irq_update_affinity_hint(entry->vector, in ixgbe_request_msix_irqs()
3272 &q_vector->affinity_mask); in ixgbe_request_msix_irqs()
3276 err = request_irq(adapter->msix_entries[vector].vector, in ixgbe_request_msix_irqs()
3277 ixgbe_msix_other, 0, netdev->name, adapter); in ixgbe_request_msix_irqs()
3287 vector--; in ixgbe_request_msix_irqs()
3288 irq_update_affinity_hint(adapter->msix_entries[vector].vector, in ixgbe_request_msix_irqs()
3290 free_irq(adapter->msix_entries[vector].vector, in ixgbe_request_msix_irqs()
3291 adapter->q_vector[vector]); in ixgbe_request_msix_irqs()
3293 adapter->flags &= ~IXGBE_FLAG_MSIX_ENABLED; in ixgbe_request_msix_irqs()
3294 pci_disable_msix(adapter->pdev); in ixgbe_request_msix_irqs()
3295 kfree(adapter->msix_entries); in ixgbe_request_msix_irqs()
3296 adapter->msix_entries = NULL; in ixgbe_request_msix_irqs()
3301 * ixgbe_intr - legacy mode Interrupt Handler
3308 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_intr()
3309 struct ixgbe_q_vector *q_vector = adapter->q_vector[0]; in ixgbe_intr()
3318 /* for NAPI, using EIAM to auto-mask tx/rx interrupt bits on read in ixgbe_intr()
3329 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_intr()
3337 switch (hw->mac.type) { in ixgbe_intr()
3347 set_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_intr()
3362 napi_schedule_irqoff(&q_vector->napi); in ixgbe_intr()
3365 * re-enable link(maybe) and non-queue interrupts, no flush. in ixgbe_intr()
3366 * ixgbe_poll will re-enable the queue interrupts in ixgbe_intr()
3368 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_intr()
3375 * ixgbe_request_irq - initialize interrupts
3383 struct net_device *netdev = adapter->netdev; in ixgbe_request_irq()
3386 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) in ixgbe_request_irq()
3388 else if (adapter->flags & IXGBE_FLAG_MSI_ENABLED) in ixgbe_request_irq()
3389 err = request_irq(adapter->pdev->irq, ixgbe_intr, 0, in ixgbe_request_irq()
3390 netdev->name, adapter); in ixgbe_request_irq()
3392 err = request_irq(adapter->pdev->irq, ixgbe_intr, IRQF_SHARED, in ixgbe_request_irq()
3393 netdev->name, adapter); in ixgbe_request_irq()
3405 if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) { in ixgbe_free_irq()
3406 free_irq(adapter->pdev->irq, adapter); in ixgbe_free_irq()
3410 if (!adapter->msix_entries) in ixgbe_free_irq()
3413 for (vector = 0; vector < adapter->num_q_vectors; vector++) { in ixgbe_free_irq()
3414 struct ixgbe_q_vector *q_vector = adapter->q_vector[vector]; in ixgbe_free_irq()
3415 struct msix_entry *entry = &adapter->msix_entries[vector]; in ixgbe_free_irq()
3418 if (!q_vector->rx.ring && !q_vector->tx.ring) in ixgbe_free_irq()
3422 irq_update_affinity_hint(entry->vector, NULL); in ixgbe_free_irq()
3424 free_irq(entry->vector, q_vector); in ixgbe_free_irq()
3427 free_irq(adapter->msix_entries[vector].vector, adapter); in ixgbe_free_irq()
3431 * ixgbe_irq_disable - Mask off interrupt generation on the NIC
3436 switch (adapter->hw.mac.type) { in ixgbe_irq_disable()
3438 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, ~0); in ixgbe_irq_disable()
3445 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, 0xFFFF0000); in ixgbe_irq_disable()
3446 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(0), ~0); in ixgbe_irq_disable()
3447 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC_EX(1), ~0); in ixgbe_irq_disable()
3452 IXGBE_WRITE_FLUSH(&adapter->hw); in ixgbe_irq_disable()
3453 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { in ixgbe_irq_disable()
3456 for (vector = 0; vector < adapter->num_q_vectors; vector++) in ixgbe_irq_disable()
3457 synchronize_irq(adapter->msix_entries[vector].vector); in ixgbe_irq_disable()
3459 synchronize_irq(adapter->msix_entries[vector++].vector); in ixgbe_irq_disable()
3461 synchronize_irq(adapter->pdev->irq); in ixgbe_irq_disable()
3466 * ixgbe_configure_msi_and_legacy - Initialize PIN (INTA...) and MSI interrupts
3472 struct ixgbe_q_vector *q_vector = adapter->q_vector[0]; in ixgbe_configure_msi_and_legacy()
3483 * ixgbe_configure_tx_ring - Configure 8259x Tx ring after Reset
3492 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_tx_ring()
3493 u64 tdba = ring->dma; in ixgbe_configure_tx_ring()
3496 u8 reg_idx = ring->reg_idx; in ixgbe_configure_tx_ring()
3498 ring->xsk_pool = NULL; in ixgbe_configure_tx_ring()
3500 ring->xsk_pool = ixgbe_xsk_pool(adapter, ring); in ixgbe_configure_tx_ring()
3510 ring->count * sizeof(union ixgbe_adv_tx_desc)); in ixgbe_configure_tx_ring()
3513 ring->tail = adapter->io_addr + IXGBE_TDT(reg_idx); in ixgbe_configure_tx_ring()
3518 * - ITR is 0 as it could cause false TX hangs in ixgbe_configure_tx_ring()
3519 * - ITR is set to > 100k int/sec and BQL is enabled in ixgbe_configure_tx_ring()
3525 if (!ring->q_vector || (ring->q_vector->itr < IXGBE_100K_ITR)) in ixgbe_configure_tx_ring()
3538 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { in ixgbe_configure_tx_ring()
3539 ring->atr_sample_rate = adapter->atr_sample_rate; in ixgbe_configure_tx_ring()
3540 ring->atr_count = 0; in ixgbe_configure_tx_ring()
3541 set_bit(__IXGBE_TX_FDIR_INIT_DONE, &ring->state); in ixgbe_configure_tx_ring()
3543 ring->atr_sample_rate = 0; in ixgbe_configure_tx_ring()
3547 if (!test_and_set_bit(__IXGBE_TX_XPS_INIT_DONE, &ring->state)) { in ixgbe_configure_tx_ring()
3548 struct ixgbe_q_vector *q_vector = ring->q_vector; in ixgbe_configure_tx_ring()
3551 netif_set_xps_queue(ring->netdev, in ixgbe_configure_tx_ring()
3552 &q_vector->affinity_mask, in ixgbe_configure_tx_ring()
3553 ring->queue_index); in ixgbe_configure_tx_ring()
3556 clear_bit(__IXGBE_HANG_CHECK_ARMED, &ring->state); in ixgbe_configure_tx_ring()
3559 memset(ring->tx_buffer_info, 0, in ixgbe_configure_tx_ring()
3560 sizeof(struct ixgbe_tx_buffer) * ring->count); in ixgbe_configure_tx_ring()
3566 if (hw->mac.type == ixgbe_mac_82598EB && in ixgbe_configure_tx_ring()
3574 } while (--wait_loop && !(txdctl & IXGBE_TXDCTL_ENABLE)); in ixgbe_configure_tx_ring()
3581 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_mtqc()
3583 u8 tcs = adapter->hw_tcs; in ixgbe_setup_mtqc()
3585 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_setup_mtqc()
3594 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { in ixgbe_setup_mtqc()
3600 else if (adapter->ring_feature[RING_F_VMDQ].mask == in ixgbe_setup_mtqc()
3611 u8 max_txq = adapter->num_tx_queues + in ixgbe_setup_mtqc()
3612 adapter->num_xdp_queues; in ixgbe_setup_mtqc()
3629 /* re-enable the arbiter */ in ixgbe_setup_mtqc()
3635 * ixgbe_configure_tx - Configure 8259x Transmit Unit after Reset
3642 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_tx()
3648 if (hw->mac.type != ixgbe_mac_82598EB) { in ixgbe_configure_tx()
3656 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_configure_tx()
3657 ixgbe_configure_tx_ring(adapter, adapter->tx_ring[i]); in ixgbe_configure_tx()
3658 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_configure_tx()
3659 ixgbe_configure_tx_ring(adapter, adapter->xdp_ring[i]); in ixgbe_configure_tx()
3665 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_enable_rx_drop()
3666 u8 reg_idx = ring->reg_idx; in ixgbe_enable_rx_drop()
3677 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_rx_drop()
3678 u8 reg_idx = ring->reg_idx; in ixgbe_disable_rx_drop()
3693 bool pfc_en = adapter->dcb_cfg.pfc_mode_enable; in ixgbe_set_rx_drop_en()
3695 if (adapter->ixgbe_ieee_pfc) in ixgbe_set_rx_drop_en()
3696 pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en); in ixgbe_set_rx_drop_en()
3700 * SR-IOV is enabled in ixgbe_set_rx_drop_en()
3707 if (adapter->num_vfs || (adapter->num_rx_queues > 1 && in ixgbe_set_rx_drop_en()
3708 !(adapter->hw.fc.current_mode & ixgbe_fc_tx_pause) && !pfc_en)) { in ixgbe_set_rx_drop_en()
3709 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_set_rx_drop_en()
3710 ixgbe_enable_rx_drop(adapter, adapter->rx_ring[i]); in ixgbe_set_rx_drop_en()
3712 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_set_rx_drop_en()
3713 ixgbe_disable_rx_drop(adapter, adapter->rx_ring[i]); in ixgbe_set_rx_drop_en()
3722 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_srrctl()
3724 u8 reg_idx = rx_ring->reg_idx; in ixgbe_configure_srrctl()
3726 if (hw->mac.type == ixgbe_mac_82598EB) { in ixgbe_configure_srrctl()
3727 u16 mask = adapter->ring_feature[RING_F_RSS].mask; in ixgbe_configure_srrctl()
3740 if (rx_ring->xsk_pool) { in ixgbe_configure_srrctl()
3741 u32 xsk_buf_len = xsk_pool_get_rx_frame_size(rx_ring->xsk_pool); in ixgbe_configure_srrctl()
3748 * the UMEM buffer size viewed in a 1k resolution will in ixgbe_configure_srrctl()
3751 if (hw->mac.type != ixgbe_mac_82599EB) in ixgbe_configure_srrctl()
3755 } else if (test_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state)) { in ixgbe_configure_srrctl()
3768 * ixgbe_rss_indir_tbl_entries - Return RSS indirection table entries
3771 * - 82598/82599/X540: 128
3772 * - X550(non-SRIOV mode): 512
3773 * - X550(SRIOV mode): 64
3777 if (adapter->hw.mac.type < ixgbe_mac_X550) in ixgbe_rss_indir_tbl_entries()
3779 else if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_rss_indir_tbl_entries()
3786 * ixgbe_store_key - Write the RSS key to HW
3793 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_store_key()
3797 IXGBE_WRITE_REG(hw, IXGBE_RSSRK(i), adapter->rss_key[i]); in ixgbe_store_key()
3801 * ixgbe_init_rss_key - Initialize adapter RSS key
3810 if (!adapter->rss_key) { in ixgbe_init_rss_key()
3813 return -ENOMEM; in ixgbe_init_rss_key()
3816 adapter->rss_key = rss_key; in ixgbe_init_rss_key()
3823 * ixgbe_store_reta - Write the RETA table to HW
3831 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_store_reta()
3834 u8 *indir_tbl = adapter->rss_indir_tbl; in ixgbe_store_reta()
3837 * - 82598: 8 bit wide entries containing pair of 4 bit RSS in ixgbe_store_reta()
3839 * - 82599/X540: 8 bit wide entries containing 4 bit RSS index in ixgbe_store_reta()
3840 * - X550: 8 bit wide entries containing 6 bit RSS index in ixgbe_store_reta()
3842 if (adapter->hw.mac.type == ixgbe_mac_82598EB) in ixgbe_store_reta()
3854 IXGBE_WRITE_REG(hw, IXGBE_ERETA((i >> 2) - 32), in ixgbe_store_reta()
3862 * ixgbe_store_vfreta - Write the RETA table to HW (x550 devices in SRIOV mode)
3870 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_store_vfreta()
3875 u16 pool = adapter->num_rx_pools; in ixgbe_store_vfreta()
3877 vfreta |= (u32)adapter->rss_indir_tbl[i] << (i & 0x3) * 8; in ixgbe_store_vfreta()
3881 while (pool--) in ixgbe_store_vfreta()
3893 u16 rss_i = adapter->ring_feature[RING_F_RSS].indices; in ixgbe_setup_reta()
3895 /* Program table for at least 4 queues w/ SR-IOV so that VFs can in ixgbe_setup_reta()
3899 if ((adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) && (rss_i < 4)) in ixgbe_setup_reta()
3906 memset(adapter->rss_indir_tbl, 0, sizeof(adapter->rss_indir_tbl)); in ixgbe_setup_reta()
3912 adapter->rss_indir_tbl[i] = j; in ixgbe_setup_reta()
3920 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_vfreta()
3921 u16 rss_i = adapter->ring_feature[RING_F_RSS].indices; in ixgbe_setup_vfreta()
3926 u16 pool = adapter->num_rx_pools; in ixgbe_setup_vfreta()
3928 while (pool--) in ixgbe_setup_vfreta()
3931 *(adapter->rss_key + i)); in ixgbe_setup_vfreta()
3939 adapter->rss_indir_tbl[i] = j; in ixgbe_setup_vfreta()
3947 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_mrqc()
3956 if (adapter->hw.mac.type == ixgbe_mac_82598EB) { in ixgbe_setup_mrqc()
3957 if (adapter->ring_feature[RING_F_RSS].mask) in ixgbe_setup_mrqc()
3960 u8 tcs = adapter->hw_tcs; in ixgbe_setup_mrqc()
3962 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { in ixgbe_setup_mrqc()
3967 else if (adapter->ring_feature[RING_F_VMDQ].mask == in ixgbe_setup_mrqc()
3976 if (hw->mac.type >= ixgbe_mac_X550) in ixgbe_setup_mrqc()
3994 if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV4_UDP) in ixgbe_setup_mrqc()
3996 if (adapter->flags2 & IXGBE_FLAG2_RSS_FIELD_IPV6_UDP) in ixgbe_setup_mrqc()
3999 if ((hw->mac.type >= ixgbe_mac_X550) && in ixgbe_setup_mrqc()
4000 (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) { in ixgbe_setup_mrqc()
4001 u16 pool = adapter->num_rx_pools; in ixgbe_setup_mrqc()
4012 while (pool--) in ixgbe_setup_mrqc()
4024 * ixgbe_configure_rscctl - enable RSC for the indicated ring
4031 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_rscctl()
4033 u8 reg_idx = ring->reg_idx; in ixgbe_configure_rscctl()
4053 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_rx_desc_queue_enable()
4056 u8 reg_idx = ring->reg_idx; in ixgbe_rx_desc_queue_enable()
4058 if (ixgbe_removed(hw->hw_addr)) in ixgbe_rx_desc_queue_enable()
4061 if (hw->mac.type == ixgbe_mac_82598EB && in ixgbe_rx_desc_queue_enable()
4068 } while (--wait_loop && !(rxdctl & IXGBE_RXDCTL_ENABLE)); in ixgbe_rx_desc_queue_enable()
4079 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_rx_ring()
4081 u64 rdba = ring->dma; in ixgbe_configure_rx_ring()
4083 u8 reg_idx = ring->reg_idx; in ixgbe_configure_rx_ring()
4085 xdp_rxq_info_unreg_mem_model(&ring->xdp_rxq); in ixgbe_configure_rx_ring()
4086 ring->xsk_pool = ixgbe_xsk_pool(adapter, ring); in ixgbe_configure_rx_ring()
4087 if (ring->xsk_pool) { in ixgbe_configure_rx_ring()
4088 WARN_ON(xdp_rxq_info_reg_mem_model(&ring->xdp_rxq, in ixgbe_configure_rx_ring()
4091 xsk_pool_set_rxq_info(ring->xsk_pool, &ring->xdp_rxq); in ixgbe_configure_rx_ring()
4093 WARN_ON(xdp_rxq_info_reg_mem_model(&ring->xdp_rxq, in ixgbe_configure_rx_ring()
4108 ring->count * sizeof(union ixgbe_adv_rx_desc)); in ixgbe_configure_rx_ring()
4114 ring->tail = adapter->io_addr + IXGBE_RDT(reg_idx); in ixgbe_configure_rx_ring()
4119 if (hw->mac.type == ixgbe_mac_82598EB) { in ixgbe_configure_rx_ring()
4131 } else if (hw->mac.type != ixgbe_mac_82599EB) { in ixgbe_configure_rx_ring()
4140 !test_bit(__IXGBE_RX_3K_BUFFER, &ring->state)) in ixgbe_configure_rx_ring()
4146 ring->rx_offset = ixgbe_rx_offset(ring); in ixgbe_configure_rx_ring()
4148 if (ring->xsk_pool && hw->mac.type != ixgbe_mac_82599EB) { in ixgbe_configure_rx_ring()
4149 u32 xsk_buf_len = xsk_pool_get_rx_frame_size(ring->xsk_pool); in ixgbe_configure_rx_ring()
4155 ring->rx_buf_len = xsk_buf_len; in ixgbe_configure_rx_ring()
4159 memset(ring->rx_buffer_info, 0, in ixgbe_configure_rx_ring()
4160 sizeof(struct ixgbe_rx_buffer) * ring->count); in ixgbe_configure_rx_ring()
4164 rx_desc->wb.upper.length = 0; in ixgbe_configure_rx_ring()
4171 if (ring->xsk_pool) in ixgbe_configure_rx_ring()
4179 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_psrtype()
4180 int rss_i = adapter->ring_feature[RING_F_RSS].indices; in ixgbe_setup_psrtype()
4181 u16 pool = adapter->num_rx_pools; in ixgbe_setup_psrtype()
4190 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_setup_psrtype()
4198 while (pool--) in ixgbe_setup_psrtype()
4204 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_virtualization()
4205 u16 pool = adapter->num_rx_pools; in ixgbe_configure_virtualization()
4210 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) in ixgbe_configure_virtualization()
4224 while (pool--) in ixgbe_configure_virtualization()
4232 IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset ^ 1), reg_offset - 1); in ixgbe_configure_virtualization()
4234 IXGBE_WRITE_REG(hw, IXGBE_VFTE(reg_offset ^ 1), reg_offset - 1); in ixgbe_configure_virtualization()
4235 if (adapter->bridge_mode == BRIDGE_MODE_VEB) in ixgbe_configure_virtualization()
4239 hw->mac.ops.set_vmdq(hw, 0, VMDQ_P(0)); in ixgbe_configure_virtualization()
4242 adapter->flags2 &= ~IXGBE_FLAG2_VLAN_PROMISC; in ixgbe_configure_virtualization()
4246 * i.e. 32 or 64 VFs for SR-IOV in ixgbe_configure_virtualization()
4248 switch (adapter->ring_feature[RING_F_VMDQ].mask) { in ixgbe_configure_virtualization()
4262 for (i = 0; i < adapter->num_vfs; i++) { in ixgbe_configure_virtualization()
4264 ixgbe_ndo_set_vf_spoofchk(adapter->netdev, i, in ixgbe_configure_virtualization()
4265 adapter->vfinfo[i].spoofchk_enabled); in ixgbe_configure_virtualization()
4268 ixgbe_ndo_set_vf_rss_query_en(adapter->netdev, i, in ixgbe_configure_virtualization()
4269 adapter->vfinfo[i].rss_query_enabled); in ixgbe_configure_virtualization()
4275 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_rx_buffer_len()
4276 struct net_device *netdev = adapter->netdev; in ixgbe_set_rx_buffer_len()
4277 int max_frame = netdev->mtu + ETH_HLEN + ETH_FCS_LEN; in ixgbe_set_rx_buffer_len()
4284 if ((adapter->flags & IXGBE_FLAG_FCOE_ENABLED) && in ixgbe_set_rx_buffer_len()
4311 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_set_rx_buffer_len()
4312 rx_ring = adapter->rx_ring[i]; in ixgbe_set_rx_buffer_len()
4315 clear_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4316 clear_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4318 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) in ixgbe_set_rx_buffer_len()
4321 if (test_bit(__IXGBE_RX_FCOE, &rx_ring->state)) in ixgbe_set_rx_buffer_len()
4322 set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4324 if (adapter->flags2 & IXGBE_FLAG2_RX_LEGACY) in ixgbe_set_rx_buffer_len()
4327 set_bit(__IXGBE_RX_BUILD_SKB_ENABLED, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4330 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) in ixgbe_set_rx_buffer_len()
4331 set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4335 set_bit(__IXGBE_RX_3K_BUFFER, &rx_ring->state); in ixgbe_set_rx_buffer_len()
4342 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_rdrxctl()
4345 switch (hw->mac.type) { in ixgbe_setup_rdrxctl()
4362 if (adapter->num_vfs) in ixgbe_setup_rdrxctl()
4384 * ixgbe_configure_rx - Configure 8259x Receive Unit after Reset
4391 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_rx()
4396 hw->mac.ops.disable_rx(hw); in ixgbe_configure_rx()
4404 if (!(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) in ixgbe_configure_rx()
4421 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_configure_rx()
4422 ixgbe_configure_rx_ring(adapter, adapter->rx_ring[i]); in ixgbe_configure_rx()
4426 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_configure_rx()
4431 hw->mac.ops.enable_rx_dma(hw, rxctrl); in ixgbe_configure_rx()
4438 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_rx_add_vid()
4441 if (!vid || !(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC)) in ixgbe_vlan_rx_add_vid()
4442 hw->mac.ops.set_vfta(&adapter->hw, vid, VMDQ_P(0), true, !!vid); in ixgbe_vlan_rx_add_vid()
4444 set_bit(vid, adapter->active_vlans); in ixgbe_vlan_rx_add_vid()
4459 for (idx = IXGBE_VLVF_ENTRIES; --idx;) { in ixgbe_find_vlvf_entry()
4470 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_pf_promisc_vlvf()
4487 if (!(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC)) in ixgbe_update_pf_promisc_vlvf()
4497 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_rx_kill_vid()
4500 if (vid && !(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC)) in ixgbe_vlan_rx_kill_vid()
4501 hw->mac.ops.set_vfta(hw, vid, VMDQ_P(0), false, true); in ixgbe_vlan_rx_kill_vid()
4503 clear_bit(vid, adapter->active_vlans); in ixgbe_vlan_rx_kill_vid()
4509 * ixgbe_vlan_strip_disable - helper to disable hw vlan stripping
4514 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_strip_disable()
4518 switch (hw->mac.type) { in ixgbe_vlan_strip_disable()
4529 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_vlan_strip_disable()
4530 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_vlan_strip_disable()
4532 if (!netif_is_ixgbe(ring->netdev)) in ixgbe_vlan_strip_disable()
4535 j = ring->reg_idx; in ixgbe_vlan_strip_disable()
4547 * ixgbe_vlan_strip_enable - helper to enable hw vlan stripping
4552 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_strip_enable()
4556 switch (hw->mac.type) { in ixgbe_vlan_strip_enable()
4567 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_vlan_strip_enable()
4568 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_vlan_strip_enable()
4570 if (!netif_is_ixgbe(ring->netdev)) in ixgbe_vlan_strip_enable()
4573 j = ring->reg_idx; in ixgbe_vlan_strip_enable()
4586 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_promisc_enable()
4591 if (adapter->flags & IXGBE_FLAG_VMDQ_ENABLED) { in ixgbe_vlan_promisc_enable()
4592 /* For VMDq and SR-IOV we must leave VLAN filtering enabled */ in ixgbe_vlan_promisc_enable()
4602 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_vlan_promisc_enable()
4606 if (adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC) in ixgbe_vlan_promisc_enable()
4610 adapter->flags2 |= IXGBE_FLAG2_VLAN_PROMISC; in ixgbe_vlan_promisc_enable()
4613 for (i = IXGBE_VLVF_ENTRIES; --i;) { in ixgbe_vlan_promisc_enable()
4622 for (i = hw->mac.vft_size; i--;) in ixgbe_vlan_promisc_enable()
4629 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_scrub_vfta()
4635 for (i = IXGBE_VLVF_ENTRIES; --i;) { in ixgbe_scrub_vfta()
4647 vfta[(vid - vid_start) / 32] |= BIT(vid % 32); in ixgbe_scrub_vfta()
4650 if (test_bit(vid, adapter->active_vlans)) in ixgbe_scrub_vfta()
4662 for (i = VFTA_BLOCK_SIZE; i--;) { in ixgbe_scrub_vfta()
4667 vfta[i] |= adapter->active_vlans[word] >> bits; in ixgbe_scrub_vfta()
4675 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vlan_promisc_disable()
4683 if (!(adapter->flags & IXGBE_FLAG_VMDQ_ENABLED) || in ixgbe_vlan_promisc_disable()
4684 hw->mac.type == ixgbe_mac_82598EB) in ixgbe_vlan_promisc_disable()
4688 if (!(adapter->flags2 & IXGBE_FLAG2_VLAN_PROMISC)) in ixgbe_vlan_promisc_disable()
4692 adapter->flags2 &= ~IXGBE_FLAG2_VLAN_PROMISC; in ixgbe_vlan_promisc_disable()
4694 for (i = 0; i < hw->mac.vft_size; i += VFTA_BLOCK_SIZE) in ixgbe_vlan_promisc_disable()
4702 ixgbe_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), 0); in ixgbe_restore_vlan()
4704 for_each_set_bit_from(vid, adapter->active_vlans, VLAN_N_VID) in ixgbe_restore_vlan()
4705 ixgbe_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid); in ixgbe_restore_vlan()
4709 * ixgbe_write_mc_addr_list - write multicast addresses to MTA
4713 * Returns: -ENOMEM on failure
4720 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_write_mc_addr_list()
4725 if (hw->mac.ops.update_mc_addr_list) in ixgbe_write_mc_addr_list()
4726 hw->mac.ops.update_mc_addr_list(hw, netdev); in ixgbe_write_mc_addr_list()
4728 return -ENOMEM; in ixgbe_write_mc_addr_list()
4740 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_full_sync_mac_table()
4741 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_full_sync_mac_table()
4744 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_full_sync_mac_table()
4745 mac_table->state &= ~IXGBE_MAC_STATE_MODIFIED; in ixgbe_full_sync_mac_table()
4747 if (mac_table->state & IXGBE_MAC_STATE_IN_USE) in ixgbe_full_sync_mac_table()
4748 hw->mac.ops.set_rar(hw, i, in ixgbe_full_sync_mac_table()
4749 mac_table->addr, in ixgbe_full_sync_mac_table()
4750 mac_table->pool, in ixgbe_full_sync_mac_table()
4753 hw->mac.ops.clear_rar(hw, i); in ixgbe_full_sync_mac_table()
4760 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_sync_mac_table()
4761 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_sync_mac_table()
4764 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_sync_mac_table()
4765 if (!(mac_table->state & IXGBE_MAC_STATE_MODIFIED)) in ixgbe_sync_mac_table()
4768 mac_table->state &= ~IXGBE_MAC_STATE_MODIFIED; in ixgbe_sync_mac_table()
4770 if (mac_table->state & IXGBE_MAC_STATE_IN_USE) in ixgbe_sync_mac_table()
4771 hw->mac.ops.set_rar(hw, i, in ixgbe_sync_mac_table()
4772 mac_table->addr, in ixgbe_sync_mac_table()
4773 mac_table->pool, in ixgbe_sync_mac_table()
4776 hw->mac.ops.clear_rar(hw, i); in ixgbe_sync_mac_table()
4782 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_flush_sw_mac_table()
4783 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_flush_sw_mac_table()
4786 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_flush_sw_mac_table()
4787 mac_table->state |= IXGBE_MAC_STATE_MODIFIED; in ixgbe_flush_sw_mac_table()
4788 mac_table->state &= ~IXGBE_MAC_STATE_IN_USE; in ixgbe_flush_sw_mac_table()
4796 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_available_rars()
4797 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_available_rars()
4800 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_available_rars()
4802 if (mac_table->state & IXGBE_MAC_STATE_DEFAULT) in ixgbe_available_rars()
4806 if (mac_table->state & IXGBE_MAC_STATE_IN_USE) { in ixgbe_available_rars()
4807 if (mac_table->pool != pool) in ixgbe_available_rars()
4820 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_mac_set_default_filter()
4821 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_mac_set_default_filter()
4823 memcpy(&mac_table->addr, hw->mac.addr, ETH_ALEN); in ixgbe_mac_set_default_filter()
4824 mac_table->pool = VMDQ_P(0); in ixgbe_mac_set_default_filter()
4826 mac_table->state = IXGBE_MAC_STATE_DEFAULT | IXGBE_MAC_STATE_IN_USE; in ixgbe_mac_set_default_filter()
4828 hw->mac.ops.set_rar(hw, 0, mac_table->addr, mac_table->pool, in ixgbe_mac_set_default_filter()
4835 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_add_mac_filter()
4836 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_add_mac_filter()
4840 return -EINVAL; in ixgbe_add_mac_filter()
4842 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_add_mac_filter()
4843 if (mac_table->state & IXGBE_MAC_STATE_IN_USE) in ixgbe_add_mac_filter()
4846 ether_addr_copy(mac_table->addr, addr); in ixgbe_add_mac_filter()
4847 mac_table->pool = pool; in ixgbe_add_mac_filter()
4849 mac_table->state |= IXGBE_MAC_STATE_MODIFIED | in ixgbe_add_mac_filter()
4857 return -ENOMEM; in ixgbe_add_mac_filter()
4863 struct ixgbe_mac_addr *mac_table = &adapter->mac_table[0]; in ixgbe_del_mac_filter()
4864 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_del_mac_filter()
4868 return -EINVAL; in ixgbe_del_mac_filter()
4871 for (i = 0; i < hw->mac.num_rar_entries; i++, mac_table++) { in ixgbe_del_mac_filter()
4873 if (!(mac_table->state & IXGBE_MAC_STATE_IN_USE)) in ixgbe_del_mac_filter()
4876 if (mac_table->pool != pool) in ixgbe_del_mac_filter()
4879 if (!ether_addr_equal(addr, mac_table->addr)) in ixgbe_del_mac_filter()
4882 mac_table->state |= IXGBE_MAC_STATE_MODIFIED; in ixgbe_del_mac_filter()
4883 mac_table->state &= ~IXGBE_MAC_STATE_IN_USE; in ixgbe_del_mac_filter()
4890 return -ENOMEM; in ixgbe_del_mac_filter()
4913 * ixgbe_set_rx_mode - Unicast, Multicast and Promiscuous mode set
4924 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_rx_mode()
4926 netdev_features_t features = netdev->features; in ixgbe_set_rx_mode()
4933 fctrl &= ~IXGBE_FCTRL_SBP; /* disable store-bad-packets */ in ixgbe_set_rx_mode()
4940 if (netdev->flags & IFF_PROMISC) { in ixgbe_set_rx_mode()
4941 hw->addr_ctrl.user_set_promisc = true; in ixgbe_set_rx_mode()
4946 if (netdev->flags & IFF_ALLMULTI) { in ixgbe_set_rx_mode()
4950 hw->addr_ctrl.user_set_promisc = false; in ixgbe_set_rx_mode()
4975 if (hw->mac.type != ixgbe_mac_82598EB) { in ixgbe_set_rx_mode()
5011 for (q_idx = 0; q_idx < adapter->num_q_vectors; q_idx++) in ixgbe_napi_enable_all()
5012 napi_enable(&adapter->q_vector[q_idx]->napi); in ixgbe_napi_enable_all()
5019 for (q_idx = 0; q_idx < adapter->num_q_vectors; q_idx++) in ixgbe_napi_disable_all()
5020 napi_disable(&adapter->q_vector[q_idx]->napi); in ixgbe_napi_disable_all()
5026 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_udp_tunnel_sync()
5031 adapter->vxlan_port = ti.port; in ixgbe_udp_tunnel_sync()
5033 adapter->geneve_port = ti.port; in ixgbe_udp_tunnel_sync()
5036 ntohs(adapter->vxlan_port) | in ixgbe_udp_tunnel_sync()
5037 ntohs(adapter->geneve_port) << in ixgbe_udp_tunnel_sync()
5061 * ixgbe_configure_dcb - Configure DCB hardware
5070 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_dcb()
5071 int max_frame = adapter->netdev->mtu + ETH_HLEN + ETH_FCS_LEN; in ixgbe_configure_dcb()
5073 if (!(adapter->flags & IXGBE_FLAG_DCB_ENABLED)) { in ixgbe_configure_dcb()
5074 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_configure_dcb()
5075 netif_set_tso_max_size(adapter->netdev, 65536); in ixgbe_configure_dcb()
5079 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_configure_dcb()
5080 netif_set_tso_max_size(adapter->netdev, 32768); in ixgbe_configure_dcb()
5083 if (adapter->netdev->fcoe_mtu) in ixgbe_configure_dcb()
5088 if (adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE) { in ixgbe_configure_dcb()
5089 ixgbe_dcb_calculate_tc_credits(hw, &adapter->dcb_cfg, max_frame, in ixgbe_configure_dcb()
5091 ixgbe_dcb_calculate_tc_credits(hw, &adapter->dcb_cfg, max_frame, in ixgbe_configure_dcb()
5093 ixgbe_dcb_hw_config(hw, &adapter->dcb_cfg); in ixgbe_configure_dcb()
5094 } else if (adapter->ixgbe_ieee_ets && adapter->ixgbe_ieee_pfc) { in ixgbe_configure_dcb()
5095 ixgbe_dcb_hw_ets(&adapter->hw, in ixgbe_configure_dcb()
5096 adapter->ixgbe_ieee_ets, in ixgbe_configure_dcb()
5098 ixgbe_dcb_hw_pfc_config(&adapter->hw, in ixgbe_configure_dcb()
5099 adapter->ixgbe_ieee_pfc->pfc_en, in ixgbe_configure_dcb()
5100 adapter->ixgbe_ieee_ets->prio_tc); in ixgbe_configure_dcb()
5104 if (hw->mac.type != ixgbe_mac_82598EB) { in ixgbe_configure_dcb()
5106 u16 rss_i = adapter->ring_feature[RING_F_RSS].indices - 1; in ixgbe_configure_dcb()
5123 * ixgbe_hpbthresh - calculate high water mark for flow control
5130 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_hpbthresh()
5131 struct net_device *dev = adapter->netdev; in ixgbe_hpbthresh()
5136 tc = link = dev->mtu + ETH_HLEN + ETH_FCS_LEN + IXGBE_ETH_FRAMING; in ixgbe_hpbthresh()
5140 if (dev->fcoe_mtu && tc < IXGBE_FCOE_JUMBO_FRAME_SIZE && in ixgbe_hpbthresh()
5146 switch (hw->mac.type) { in ixgbe_hpbthresh()
5159 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_hpbthresh()
5166 marker = rx_pba - kb; in ixgbe_hpbthresh()
5183 * ixgbe_lpbthresh - calculate low water mark for flow control
5190 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_lpbthresh()
5191 struct net_device *dev = adapter->netdev; in ixgbe_lpbthresh()
5196 tc = dev->mtu + ETH_HLEN + ETH_FCS_LEN; in ixgbe_lpbthresh()
5200 if (dev->fcoe_mtu && tc < IXGBE_FCOE_JUMBO_FRAME_SIZE && in ixgbe_lpbthresh()
5201 (pb == netdev_get_prio_tc_map(dev, adapter->fcoe.up))) in ixgbe_lpbthresh()
5206 switch (hw->mac.type) { in ixgbe_lpbthresh()
5223 * ixgbe_pbthresh_setup - calculate and setup high low water marks
5227 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_pbthresh_setup()
5228 int num_tc = adapter->hw_tcs; in ixgbe_pbthresh_setup()
5235 hw->fc.high_water[i] = ixgbe_hpbthresh(adapter, i); in ixgbe_pbthresh_setup()
5236 hw->fc.low_water[i] = ixgbe_lpbthresh(adapter, i); in ixgbe_pbthresh_setup()
5239 if (hw->fc.low_water[i] > hw->fc.high_water[i]) in ixgbe_pbthresh_setup()
5240 hw->fc.low_water[i] = 0; in ixgbe_pbthresh_setup()
5244 hw->fc.high_water[i] = 0; in ixgbe_pbthresh_setup()
5249 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_pb()
5251 u8 tc = adapter->hw_tcs; in ixgbe_configure_pb()
5253 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE || in ixgbe_configure_pb()
5254 adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) in ixgbe_configure_pb()
5255 hdrm = 32 << adapter->fdir_pballoc; in ixgbe_configure_pb()
5259 hw->mac.ops.set_rxpba(hw, tc, hdrm, PBA_STRATEGY_EQUAL); in ixgbe_configure_pb()
5265 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_fdir_filter_restore()
5270 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_fdir_filter_restore()
5272 if (!hlist_empty(&adapter->fdir_filter_list)) in ixgbe_fdir_filter_restore()
5273 ixgbe_fdir_set_input_mask_82599(hw, &adapter->fdir_mask); in ixgbe_fdir_filter_restore()
5276 &adapter->fdir_filter_list, fdir_node) { in ixgbe_fdir_filter_restore()
5277 if (filter->action == IXGBE_FDIR_DROP_QUEUE) { in ixgbe_fdir_filter_restore()
5280 u32 ring = ethtool_get_flow_spec_ring(filter->action); in ixgbe_fdir_filter_restore()
5281 u8 vf = ethtool_get_flow_spec_ring_vf(filter->action); in ixgbe_fdir_filter_restore()
5283 if (!vf && (ring >= adapter->num_rx_queues)) { in ixgbe_fdir_filter_restore()
5288 ((vf > adapter->num_vfs) || in ixgbe_fdir_filter_restore()
5289 ring >= adapter->num_rx_queues_per_pool)) { in ixgbe_fdir_filter_restore()
5297 queue = adapter->rx_ring[ring]->reg_idx; in ixgbe_fdir_filter_restore()
5299 queue = ((vf - 1) * in ixgbe_fdir_filter_restore()
5300 adapter->num_rx_queues_per_pool) + ring; in ixgbe_fdir_filter_restore()
5304 &filter->filter, filter->sw_idx, queue); in ixgbe_fdir_filter_restore()
5307 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_fdir_filter_restore()
5311 * ixgbe_clean_rx_ring - Free Rx Buffers per Queue
5316 u16 i = rx_ring->next_to_clean; in ixgbe_clean_rx_ring()
5317 struct ixgbe_rx_buffer *rx_buffer = &rx_ring->rx_buffer_info[i]; in ixgbe_clean_rx_ring()
5319 if (rx_ring->xsk_pool) { in ixgbe_clean_rx_ring()
5325 while (i != rx_ring->next_to_alloc) { in ixgbe_clean_rx_ring()
5326 if (rx_buffer->skb) { in ixgbe_clean_rx_ring()
5327 struct sk_buff *skb = rx_buffer->skb; in ixgbe_clean_rx_ring()
5328 if (IXGBE_CB(skb)->page_released) in ixgbe_clean_rx_ring()
5329 dma_unmap_page_attrs(rx_ring->dev, in ixgbe_clean_rx_ring()
5330 IXGBE_CB(skb)->dma, in ixgbe_clean_rx_ring()
5340 dma_sync_single_range_for_cpu(rx_ring->dev, in ixgbe_clean_rx_ring()
5341 rx_buffer->dma, in ixgbe_clean_rx_ring()
5342 rx_buffer->page_offset, in ixgbe_clean_rx_ring()
5347 dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, in ixgbe_clean_rx_ring()
5351 __page_frag_cache_drain(rx_buffer->page, in ixgbe_clean_rx_ring()
5352 rx_buffer->pagecnt_bias); in ixgbe_clean_rx_ring()
5356 if (i == rx_ring->count) { in ixgbe_clean_rx_ring()
5358 rx_buffer = rx_ring->rx_buffer_info; in ixgbe_clean_rx_ring()
5363 rx_ring->next_to_alloc = 0; in ixgbe_clean_rx_ring()
5364 rx_ring->next_to_clean = 0; in ixgbe_clean_rx_ring()
5365 rx_ring->next_to_use = 0; in ixgbe_clean_rx_ring()
5371 u16 rss_i = adapter->ring_feature[RING_F_RSS].indices; in ixgbe_fwd_ring_up()
5372 int num_tc = netdev_get_num_tc(adapter->netdev); in ixgbe_fwd_ring_up()
5373 struct net_device *vdev = accel->netdev; in ixgbe_fwd_ring_up()
5376 baseq = accel->pool * adapter->num_rx_queues_per_pool; in ixgbe_fwd_ring_up()
5378 accel->pool, adapter->num_rx_pools, in ixgbe_fwd_ring_up()
5379 baseq, baseq + adapter->num_rx_queues_per_pool); in ixgbe_fwd_ring_up()
5381 accel->rx_base_queue = baseq; in ixgbe_fwd_ring_up()
5382 accel->tx_base_queue = baseq; in ixgbe_fwd_ring_up()
5386 netdev_bind_sb_channel_queue(adapter->netdev, vdev, 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 = vdev; in ixgbe_fwd_ring_up()
5400 err = ixgbe_add_mac_filter(adapter, vdev->dev_addr, in ixgbe_fwd_ring_up()
5401 VMDQ_P(accel->pool)); in ixgbe_fwd_ring_up()
5408 for (i = 0; i < adapter->num_rx_queues_per_pool; i++) in ixgbe_fwd_ring_up()
5409 adapter->rx_ring[baseq + i]->netdev = NULL; in ixgbe_fwd_ring_up()
5414 netdev_unbind_sb_channel(adapter->netdev, vdev); in ixgbe_fwd_ring_up()
5417 clear_bit(accel->pool, adapter->fwd_bitmask); in ixgbe_fwd_ring_up()
5426 struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)priv->data; in ixgbe_macvlan_up()
5447 netdev_walk_all_upper_dev_rcu(adapter->netdev, in ixgbe_configure_dfwd()
5453 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure()
5465 ixgbe_set_rx_mode(adapter->netdev); in ixgbe_configure()
5469 switch (hw->mac.type) { in ixgbe_configure()
5472 hw->mac.ops.disable_rx_buff(hw); in ixgbe_configure()
5478 if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { in ixgbe_configure()
5479 ixgbe_init_fdir_signature_82599(&adapter->hw, in ixgbe_configure()
5480 adapter->fdir_pballoc); in ixgbe_configure()
5481 } else if (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) { in ixgbe_configure()
5482 ixgbe_init_fdir_perfect_82599(&adapter->hw, in ixgbe_configure()
5483 adapter->fdir_pballoc); in ixgbe_configure()
5487 switch (hw->mac.type) { in ixgbe_configure()
5490 hw->mac.ops.enable_rx_buff(hw); in ixgbe_configure()
5498 if (adapter->flags & IXGBE_FLAG_DCA_CAPABLE) in ixgbe_configure()
5513 * ixgbe_sfp_link_config - set up SFP+ link
5524 if (adapter->hw.mac.type == ixgbe_mac_82598EB) in ixgbe_sfp_link_config()
5525 adapter->flags2 |= IXGBE_FLAG2_SEARCH_FOR_SFP; in ixgbe_sfp_link_config()
5527 adapter->flags2 |= IXGBE_FLAG2_SFP_NEEDS_RESET; in ixgbe_sfp_link_config()
5528 adapter->sfp_poll_time = 0; in ixgbe_sfp_link_config()
5532 * ixgbe_non_sfp_link_config - set up non-SFP+ link
5541 int ret = -EIO; in ixgbe_non_sfp_link_config()
5543 if (hw->mac.ops.check_link) in ixgbe_non_sfp_link_config()
5544 ret = hw->mac.ops.check_link(hw, &speed, &link_up, false); in ixgbe_non_sfp_link_config()
5549 speed = hw->phy.autoneg_advertised; in ixgbe_non_sfp_link_config()
5550 if (!speed && hw->mac.ops.get_link_capabilities) { in ixgbe_non_sfp_link_config()
5551 ret = hw->mac.ops.get_link_capabilities(hw, &speed, in ixgbe_non_sfp_link_config()
5553 /* remove NBASE-T speeds from default autonegotiation in ixgbe_non_sfp_link_config()
5555 * which cannot cope with advertised NBASE-T speeds in ixgbe_non_sfp_link_config()
5564 if (hw->mac.ops.setup_link) in ixgbe_non_sfp_link_config()
5565 ret = hw->mac.ops.setup_link(hw, speed, link_up); in ixgbe_non_sfp_link_config()
5571 * ixgbe_clear_vf_stats_counters - Clear out VF stats after reset
5579 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_clear_vf_stats_counters()
5582 for (i = 0; i < adapter->num_vfs; i++) { in ixgbe_clear_vf_stats_counters()
5583 adapter->vfinfo[i].last_vfstats.gprc = in ixgbe_clear_vf_stats_counters()
5585 adapter->vfinfo[i].saved_rst_vfstats.gprc += in ixgbe_clear_vf_stats_counters()
5586 adapter->vfinfo[i].vfstats.gprc; in ixgbe_clear_vf_stats_counters()
5587 adapter->vfinfo[i].vfstats.gprc = 0; in ixgbe_clear_vf_stats_counters()
5588 adapter->vfinfo[i].last_vfstats.gptc = in ixgbe_clear_vf_stats_counters()
5590 adapter->vfinfo[i].saved_rst_vfstats.gptc += in ixgbe_clear_vf_stats_counters()
5591 adapter->vfinfo[i].vfstats.gptc; in ixgbe_clear_vf_stats_counters()
5592 adapter->vfinfo[i].vfstats.gptc = 0; in ixgbe_clear_vf_stats_counters()
5593 adapter->vfinfo[i].last_vfstats.gorc = in ixgbe_clear_vf_stats_counters()
5595 adapter->vfinfo[i].saved_rst_vfstats.gorc += in ixgbe_clear_vf_stats_counters()
5596 adapter->vfinfo[i].vfstats.gorc; in ixgbe_clear_vf_stats_counters()
5597 adapter->vfinfo[i].vfstats.gorc = 0; in ixgbe_clear_vf_stats_counters()
5598 adapter->vfinfo[i].last_vfstats.gotc = in ixgbe_clear_vf_stats_counters()
5600 adapter->vfinfo[i].saved_rst_vfstats.gotc += in ixgbe_clear_vf_stats_counters()
5601 adapter->vfinfo[i].vfstats.gotc; in ixgbe_clear_vf_stats_counters()
5602 adapter->vfinfo[i].vfstats.gotc = 0; in ixgbe_clear_vf_stats_counters()
5603 adapter->vfinfo[i].last_vfstats.mprc = in ixgbe_clear_vf_stats_counters()
5605 adapter->vfinfo[i].saved_rst_vfstats.mprc += in ixgbe_clear_vf_stats_counters()
5606 adapter->vfinfo[i].vfstats.mprc; in ixgbe_clear_vf_stats_counters()
5607 adapter->vfinfo[i].vfstats.mprc = 0; in ixgbe_clear_vf_stats_counters()
5613 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_gpie()
5616 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { in ixgbe_setup_gpie()
5621 * use EIAM to auto-mask when MSI-X interrupt is asserted in ixgbe_setup_gpie()
5624 switch (hw->mac.type) { in ixgbe_setup_gpie()
5639 /* legacy interrupts, use EIAM to auto-mask when reading EICR, in ixgbe_setup_gpie()
5647 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { in ixgbe_setup_gpie()
5650 switch (adapter->ring_feature[RING_F_VMDQ].mask) { in ixgbe_setup_gpie()
5664 if (adapter->flags2 & IXGBE_FLAG2_TEMP_SENSOR_CAPABLE) { in ixgbe_setup_gpie()
5665 switch (adapter->hw.mac.type) { in ixgbe_setup_gpie()
5675 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) in ixgbe_setup_gpie()
5678 switch (hw->mac.type) { in ixgbe_setup_gpie()
5695 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_up_complete()
5702 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) in ixgbe_up_complete()
5708 if (hw->mac.ops.enable_tx_laser) in ixgbe_up_complete()
5709 hw->mac.ops.enable_tx_laser(hw); in ixgbe_up_complete()
5711 if (hw->phy.ops.set_phy_power) in ixgbe_up_complete()
5712 hw->phy.ops.set_phy_power(hw, true); in ixgbe_up_complete()
5715 clear_bit(__IXGBE_DOWN, &adapter->state); in ixgbe_up_complete()
5734 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) { in ixgbe_up_complete()
5742 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_up_complete()
5743 adapter->link_check_timeout = jiffies; in ixgbe_up_complete()
5744 mod_timer(&adapter->service_timer, jiffies); in ixgbe_up_complete()
5759 netif_trans_update(adapter->netdev); in ixgbe_reinit_locked()
5761 while (test_and_set_bit(__IXGBE_RESETTING, &adapter->state)) in ixgbe_reinit_locked()
5763 if (adapter->hw.phy.type == ixgbe_phy_fw) in ixgbe_reinit_locked()
5767 * If SR-IOV enabled then wait a bit before bringing the adapter in ixgbe_reinit_locked()
5772 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_reinit_locked()
5775 clear_bit(__IXGBE_RESETTING, &adapter->state); in ixgbe_reinit_locked()
5790 pcie_capability_read_word(adapter->pdev, PCI_EXP_DEVCTL2, &devctl2); in ixgbe_get_completion_timeout()
5826 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_rx()
5831 hw->mac.ops.disable_rx(hw); in ixgbe_disable_rx()
5833 if (ixgbe_removed(hw->hw_addr)) in ixgbe_disable_rx()
5837 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_disable_rx()
5838 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_disable_rx()
5839 u8 reg_idx = ring->reg_idx; in ixgbe_disable_rx()
5850 if (hw->mac.type == ixgbe_mac_82598EB && in ixgbe_disable_rx()
5870 while (wait_loop--) { in ixgbe_disable_rx()
5880 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_disable_rx()
5881 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_disable_rx()
5882 u8 reg_idx = ring->reg_idx; in ixgbe_disable_rx()
5898 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_tx()
5902 if (ixgbe_removed(hw->hw_addr)) in ixgbe_disable_tx()
5906 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_disable_tx()
5907 struct ixgbe_ring *ring = adapter->tx_ring[i]; in ixgbe_disable_tx()
5908 u8 reg_idx = ring->reg_idx; in ixgbe_disable_tx()
5914 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_disable_tx()
5915 struct ixgbe_ring *ring = adapter->xdp_ring[i]; in ixgbe_disable_tx()
5916 u8 reg_idx = ring->reg_idx; in ixgbe_disable_tx()
5945 while (wait_loop--) { in ixgbe_disable_tx()
5955 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_disable_tx()
5956 struct ixgbe_ring *ring = adapter->tx_ring[i]; in ixgbe_disable_tx()
5957 u8 reg_idx = ring->reg_idx; in ixgbe_disable_tx()
5961 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_disable_tx()
5962 struct ixgbe_ring *ring = adapter->xdp_ring[i]; in ixgbe_disable_tx()
5963 u8 reg_idx = ring->reg_idx; in ixgbe_disable_tx()
5977 switch (hw->mac.type) { in ixgbe_disable_tx()
5994 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_reset()
5995 struct net_device *netdev = adapter->netdev; in ixgbe_reset()
5998 if (ixgbe_removed(hw->hw_addr)) in ixgbe_reset()
6001 while (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state)) in ixgbe_reset()
6005 adapter->flags2 &= ~(IXGBE_FLAG2_SEARCH_FOR_SFP | in ixgbe_reset()
6007 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; in ixgbe_reset()
6009 err = hw->mac.ops.init_hw(hw); in ixgbe_reset()
6012 case -ENOENT: in ixgbe_reset()
6013 case -EOPNOTSUPP: in ixgbe_reset()
6015 case -EALREADY: in ixgbe_reset()
6018 case -EACCES: in ixgbe_reset()
6019 /* We are running on a pre-production device, log a warning */ in ixgbe_reset()
6020 e_dev_warn("This device is a pre-production adapter/LOM. " in ixgbe_reset()
6031 clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state); in ixgbe_reset()
6041 if (hw->mac.san_mac_rar_index) in ixgbe_reset()
6042 hw->mac.ops.set_vmdq_san_mac(hw, VMDQ_P(0)); in ixgbe_reset()
6044 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) in ixgbe_reset()
6047 if (hw->phy.ops.set_phy_power) { in ixgbe_reset()
6048 if (!netif_running(adapter->netdev) && !adapter->wol) in ixgbe_reset()
6049 hw->phy.ops.set_phy_power(hw, false); in ixgbe_reset()
6051 hw->phy.ops.set_phy_power(hw, true); in ixgbe_reset()
6056 * ixgbe_clean_tx_ring - Free Tx Buffers
6061 u16 i = tx_ring->next_to_clean; in ixgbe_clean_tx_ring()
6062 struct ixgbe_tx_buffer *tx_buffer = &tx_ring->tx_buffer_info[i]; in ixgbe_clean_tx_ring()
6064 if (tx_ring->xsk_pool) { in ixgbe_clean_tx_ring()
6069 while (i != tx_ring->next_to_use) { in ixgbe_clean_tx_ring()
6074 xdp_return_frame(tx_buffer->xdpf); in ixgbe_clean_tx_ring()
6076 dev_kfree_skb_any(tx_buffer->skb); in ixgbe_clean_tx_ring()
6079 dma_unmap_single(tx_ring->dev, in ixgbe_clean_tx_ring()
6085 eop_desc = tx_buffer->next_to_watch; in ixgbe_clean_tx_ring()
6093 if (unlikely(i == tx_ring->count)) { in ixgbe_clean_tx_ring()
6095 tx_buffer = tx_ring->tx_buffer_info; in ixgbe_clean_tx_ring()
6101 dma_unmap_page(tx_ring->dev, in ixgbe_clean_tx_ring()
6110 if (unlikely(i == tx_ring->count)) { in ixgbe_clean_tx_ring()
6112 tx_buffer = tx_ring->tx_buffer_info; in ixgbe_clean_tx_ring()
6122 tx_ring->next_to_use = 0; in ixgbe_clean_tx_ring()
6123 tx_ring->next_to_clean = 0; in ixgbe_clean_tx_ring()
6127 * ixgbe_clean_all_rx_rings - Free Rx Buffers for all queues
6134 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_clean_all_rx_rings()
6135 ixgbe_clean_rx_ring(adapter->rx_ring[i]); in ixgbe_clean_all_rx_rings()
6139 * ixgbe_clean_all_tx_rings - Free Tx Buffers for all queues
6146 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_clean_all_tx_rings()
6147 ixgbe_clean_tx_ring(adapter->tx_ring[i]); in ixgbe_clean_all_tx_rings()
6148 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_clean_all_tx_rings()
6149 ixgbe_clean_tx_ring(adapter->xdp_ring[i]); in ixgbe_clean_all_tx_rings()
6157 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_fdir_filter_exit()
6160 &adapter->fdir_filter_list, fdir_node) { in ixgbe_fdir_filter_exit()
6161 hlist_del(&filter->fdir_node); in ixgbe_fdir_filter_exit()
6164 adapter->fdir_filter_count = 0; in ixgbe_fdir_filter_exit()
6166 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_fdir_filter_exit()
6171 struct net_device *netdev = adapter->netdev; in ixgbe_down()
6172 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_down()
6176 if (test_and_set_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_down()
6190 if (adapter->xdp_ring[0]) in ixgbe_down()
6197 clear_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_down()
6198 adapter->flags2 &= ~IXGBE_FLAG2_FDIR_REQUIRES_REINIT; in ixgbe_down()
6199 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_down()
6201 del_timer_sync(&adapter->service_timer); in ixgbe_down()
6203 if (adapter->num_vfs) { in ixgbe_down()
6205 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EITRSEL, 0); in ixgbe_down()
6208 for (i = 0 ; i < adapter->num_vfs; i++) in ixgbe_down()
6209 adapter->vfinfo[i].clear_to_send = false; in ixgbe_down()
6218 if (!pci_channel_offline(adapter->pdev)) in ixgbe_down()
6222 if (hw->mac.ops.disable_tx_laser) in ixgbe_down()
6223 hw->mac.ops.disable_tx_laser(hw); in ixgbe_down()
6230 * ixgbe_set_eee_capable - helper function to determine EEE support on X550
6235 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_eee_capable()
6237 switch (hw->device_id) { in ixgbe_set_eee_capable()
6240 if (!hw->phy.eee_speeds_supported) in ixgbe_set_eee_capable()
6242 adapter->flags2 |= IXGBE_FLAG2_EEE_CAPABLE; in ixgbe_set_eee_capable()
6243 if (!hw->phy.eee_speeds_advertised) in ixgbe_set_eee_capable()
6245 adapter->flags2 |= IXGBE_FLAG2_EEE_ENABLED; in ixgbe_set_eee_capable()
6248 adapter->flags2 &= ~IXGBE_FLAG2_EEE_CAPABLE; in ixgbe_set_eee_capable()
6249 adapter->flags2 &= ~IXGBE_FLAG2_EEE_ENABLED; in ixgbe_set_eee_capable()
6255 * ixgbe_tx_timeout - Respond to a Tx Hang
6270 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_init_dcb()
6274 switch (hw->mac.type) { in ixgbe_init_dcb()
6277 adapter->dcb_cfg.num_tcs.pg_tcs = MAX_TRAFFIC_CLASS; in ixgbe_init_dcb()
6278 adapter->dcb_cfg.num_tcs.pfc_tcs = MAX_TRAFFIC_CLASS; in ixgbe_init_dcb()
6282 adapter->dcb_cfg.num_tcs.pg_tcs = X540_TRAFFIC_CLASS; in ixgbe_init_dcb()
6283 adapter->dcb_cfg.num_tcs.pfc_tcs = X540_TRAFFIC_CLASS; in ixgbe_init_dcb()
6288 adapter->dcb_cfg.num_tcs.pg_tcs = DEF_TRAFFIC_CLASS; in ixgbe_init_dcb()
6289 adapter->dcb_cfg.num_tcs.pfc_tcs = DEF_TRAFFIC_CLASS; in ixgbe_init_dcb()
6295 tc = &adapter->dcb_cfg.tc_config[j]; in ixgbe_init_dcb()
6296 tc->path[DCB_TX_CONFIG].bwg_id = 0; in ixgbe_init_dcb()
6297 tc->path[DCB_TX_CONFIG].bwg_percent = 12 + (j & 1); in ixgbe_init_dcb()
6298 tc->path[DCB_RX_CONFIG].bwg_id = 0; in ixgbe_init_dcb()
6299 tc->path[DCB_RX_CONFIG].bwg_percent = 12 + (j & 1); in ixgbe_init_dcb()
6300 tc->dcb_pfc = pfc_disabled; in ixgbe_init_dcb()
6303 /* Initialize default user to priority mapping, UPx->TC0 */ in ixgbe_init_dcb()
6304 tc = &adapter->dcb_cfg.tc_config[0]; in ixgbe_init_dcb()
6305 tc->path[DCB_TX_CONFIG].up_to_tc_bitmap = 0xFF; in ixgbe_init_dcb()
6306 tc->path[DCB_RX_CONFIG].up_to_tc_bitmap = 0xFF; in ixgbe_init_dcb()
6308 adapter->dcb_cfg.bw_percentage[DCB_TX_CONFIG][0] = 100; in ixgbe_init_dcb()
6309 adapter->dcb_cfg.bw_percentage[DCB_RX_CONFIG][0] = 100; in ixgbe_init_dcb()
6310 adapter->dcb_cfg.pfc_mode_enable = false; in ixgbe_init_dcb()
6311 adapter->dcb_set_bitmap = 0x00; in ixgbe_init_dcb()
6312 if (adapter->flags & IXGBE_FLAG_DCB_CAPABLE) in ixgbe_init_dcb()
6313 adapter->dcbx_cap = DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_CEE; in ixgbe_init_dcb()
6314 memcpy(&adapter->temp_dcb_cfg, &adapter->dcb_cfg, in ixgbe_init_dcb()
6315 sizeof(adapter->temp_dcb_cfg)); in ixgbe_init_dcb()
6320 * ixgbe_sw_init - Initialize general software structures (struct ixgbe_adapter)
6331 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_sw_init()
6332 struct pci_dev *pdev = adapter->pdev; in ixgbe_sw_init()
6339 hw->vendor_id = pdev->vendor; in ixgbe_sw_init()
6340 hw->device_id = pdev->device; in ixgbe_sw_init()
6341 hw->revision_id = pdev->revision; in ixgbe_sw_init()
6342 hw->subsystem_vendor_id = pdev->subsystem_vendor; in ixgbe_sw_init()
6343 hw->subsystem_device_id = pdev->subsystem_device; in ixgbe_sw_init()
6346 ii->get_invariants(hw); in ixgbe_sw_init()
6350 adapter->ring_feature[RING_F_RSS].limit = rss; in ixgbe_sw_init()
6351 adapter->flags2 |= IXGBE_FLAG2_RSC_CAPABLE; in ixgbe_sw_init()
6352 adapter->max_q_vectors = MAX_Q_VECTORS_82599; in ixgbe_sw_init()
6353 adapter->atr_sample_rate = 20; in ixgbe_sw_init()
6355 adapter->ring_feature[RING_F_FDIR].limit = fdir; in ixgbe_sw_init()
6356 adapter->fdir_pballoc = IXGBE_FDIR_PBALLOC_64K; in ixgbe_sw_init()
6357 adapter->ring_feature[RING_F_VMDQ].limit = 1; in ixgbe_sw_init()
6359 adapter->flags |= IXGBE_FLAG_DCA_CAPABLE; in ixgbe_sw_init()
6362 adapter->flags |= IXGBE_FLAG_DCB_CAPABLE; in ixgbe_sw_init()
6363 adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; in ixgbe_sw_init()
6366 adapter->flags |= IXGBE_FLAG_FCOE_CAPABLE; in ixgbe_sw_init()
6367 adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; in ixgbe_sw_init()
6370 adapter->fcoe.up = IXGBE_FCOE_DEFTC; in ixgbe_sw_init()
6375 adapter->jump_tables[0] = kzalloc(sizeof(*adapter->jump_tables[0]), in ixgbe_sw_init()
6377 if (!adapter->jump_tables[0]) in ixgbe_sw_init()
6378 return -ENOMEM; in ixgbe_sw_init()
6379 adapter->jump_tables[0]->mat = ixgbe_ipv4_fields; in ixgbe_sw_init()
6382 adapter->jump_tables[i] = NULL; in ixgbe_sw_init()
6384 adapter->mac_table = kcalloc(hw->mac.num_rar_entries, in ixgbe_sw_init()
6387 if (!adapter->mac_table) in ixgbe_sw_init()
6388 return -ENOMEM; in ixgbe_sw_init()
6391 return -ENOMEM; in ixgbe_sw_init()
6393 adapter->af_xdp_zc_qps = bitmap_zalloc(IXGBE_MAX_XDP_QS, GFP_KERNEL); in ixgbe_sw_init()
6394 if (!adapter->af_xdp_zc_qps) in ixgbe_sw_init()
6395 return -ENOMEM; in ixgbe_sw_init()
6398 switch (hw->mac.type) { in ixgbe_sw_init()
6400 adapter->flags2 &= ~IXGBE_FLAG2_RSC_CAPABLE; in ixgbe_sw_init()
6402 if (hw->device_id == IXGBE_DEV_ID_82598AT) in ixgbe_sw_init()
6403 adapter->flags |= IXGBE_FLAG_FAN_FAIL_CAPABLE; in ixgbe_sw_init()
6405 adapter->max_q_vectors = MAX_Q_VECTORS_82598; in ixgbe_sw_init()
6406 adapter->ring_feature[RING_F_FDIR].limit = 0; in ixgbe_sw_init()
6407 adapter->atr_sample_rate = 0; in ixgbe_sw_init()
6408 adapter->fdir_pballoc = 0; in ixgbe_sw_init()
6410 adapter->flags &= ~IXGBE_FLAG_FCOE_CAPABLE; in ixgbe_sw_init()
6411 adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; in ixgbe_sw_init()
6413 adapter->fcoe.up = 0; in ixgbe_sw_init()
6418 if (hw->device_id == IXGBE_DEV_ID_82599_T3_LOM) in ixgbe_sw_init()
6419 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; in ixgbe_sw_init()
6424 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; in ixgbe_sw_init()
6427 switch (hw->device_id) { in ixgbe_sw_init()
6430 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; in ixgbe_sw_init()
6438 adapter->flags &= ~IXGBE_FLAG_DCB_CAPABLE; in ixgbe_sw_init()
6441 adapter->flags &= ~IXGBE_FLAG_FCOE_CAPABLE; in ixgbe_sw_init()
6443 adapter->fcoe.up = 0; in ixgbe_sw_init()
6448 if (hw->mac.type == ixgbe_mac_X550) in ixgbe_sw_init()
6449 adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; in ixgbe_sw_init()
6451 adapter->flags &= ~IXGBE_FLAG_DCA_CAPABLE; in ixgbe_sw_init()
6460 spin_lock_init(&adapter->fcoe.lock); in ixgbe_sw_init()
6463 /* n-tuple support exists, always init our spinlock */ in ixgbe_sw_init()
6464 spin_lock_init(&adapter->fdir_perfect_lock); in ixgbe_sw_init()
6467 spin_lock_init(&adapter->vfs_lock); in ixgbe_sw_init()
6475 hw->fc.requested_mode = ixgbe_fc_full; in ixgbe_sw_init()
6476 hw->fc.current_mode = ixgbe_fc_full; /* init for ethtool output */ in ixgbe_sw_init()
6478 hw->fc.pause_time = IXGBE_DEFAULT_FCPAUSE; in ixgbe_sw_init()
6479 hw->fc.send_xon = true; in ixgbe_sw_init()
6480 hw->fc.disable_fc_autoneg = ixgbe_device_supports_autoneg_fc(hw); in ixgbe_sw_init()
6484 …e_dev_warn("Enabling SR-IOV VFs using the max_vfs module parameter is deprecated - please use the … in ixgbe_sw_init()
6486 /* assign number of SR-IOV VFs */ in ixgbe_sw_init()
6487 if (hw->mac.type != ixgbe_mac_82598EB) { in ixgbe_sw_init()
6490 e_dev_warn("max_vfs parameter out of range. Not assigning any SR-IOV VFs\n"); in ixgbe_sw_init()
6496 adapter->rx_itr_setting = 1; in ixgbe_sw_init()
6497 adapter->tx_itr_setting = 1; in ixgbe_sw_init()
6500 adapter->tx_ring_count = IXGBE_DEFAULT_TXD; in ixgbe_sw_init()
6501 adapter->rx_ring_count = IXGBE_DEFAULT_RXD; in ixgbe_sw_init()
6504 adapter->tx_work_limit = IXGBE_DEFAULT_TX_WORK; in ixgbe_sw_init()
6509 return -EIO; in ixgbe_sw_init()
6513 set_bit(0, adapter->fwd_bitmask); in ixgbe_sw_init()
6514 set_bit(__IXGBE_DOWN, &adapter->state); in ixgbe_sw_init()
6524 * ixgbe_setup_tx_resources - allocate Tx resources (Descriptors)
6531 struct device *dev = tx_ring->dev; in ixgbe_setup_tx_resources()
6536 size = sizeof(struct ixgbe_tx_buffer) * tx_ring->count; in ixgbe_setup_tx_resources()
6538 if (tx_ring->q_vector) in ixgbe_setup_tx_resources()
6539 ring_node = tx_ring->q_vector->numa_node; in ixgbe_setup_tx_resources()
6541 tx_ring->tx_buffer_info = vmalloc_node(size, ring_node); in ixgbe_setup_tx_resources()
6542 if (!tx_ring->tx_buffer_info) in ixgbe_setup_tx_resources()
6543 tx_ring->tx_buffer_info = vmalloc(size); in ixgbe_setup_tx_resources()
6544 if (!tx_ring->tx_buffer_info) in ixgbe_setup_tx_resources()
6548 tx_ring->size = tx_ring->count * sizeof(union ixgbe_adv_tx_desc); in ixgbe_setup_tx_resources()
6549 tx_ring->size = ALIGN(tx_ring->size, 4096); in ixgbe_setup_tx_resources()
6552 tx_ring->desc = dma_alloc_coherent(dev, in ixgbe_setup_tx_resources()
6553 tx_ring->size, in ixgbe_setup_tx_resources()
6554 &tx_ring->dma, in ixgbe_setup_tx_resources()
6557 if (!tx_ring->desc) in ixgbe_setup_tx_resources()
6558 tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size, in ixgbe_setup_tx_resources()
6559 &tx_ring->dma, GFP_KERNEL); in ixgbe_setup_tx_resources()
6560 if (!tx_ring->desc) in ixgbe_setup_tx_resources()
6563 tx_ring->next_to_use = 0; in ixgbe_setup_tx_resources()
6564 tx_ring->next_to_clean = 0; in ixgbe_setup_tx_resources()
6568 vfree(tx_ring->tx_buffer_info); in ixgbe_setup_tx_resources()
6569 tx_ring->tx_buffer_info = NULL; in ixgbe_setup_tx_resources()
6571 return -ENOMEM; in ixgbe_setup_tx_resources()
6575 * ixgbe_setup_all_tx_resources - allocate all queues Tx resources
6588 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_setup_all_tx_resources()
6589 err = ixgbe_setup_tx_resources(adapter->tx_ring[i]); in ixgbe_setup_all_tx_resources()
6596 for (j = 0; j < adapter->num_xdp_queues; j++) { in ixgbe_setup_all_tx_resources()
6597 err = ixgbe_setup_tx_resources(adapter->xdp_ring[j]); in ixgbe_setup_all_tx_resources()
6608 while (j--) in ixgbe_setup_all_tx_resources()
6609 ixgbe_free_tx_resources(adapter->xdp_ring[j]); in ixgbe_setup_all_tx_resources()
6610 while (i--) in ixgbe_setup_all_tx_resources()
6611 ixgbe_free_tx_resources(adapter->tx_ring[i]); in ixgbe_setup_all_tx_resources()
6617 struct ixgbe_q_vector *q_vector = rx_ring->q_vector; in ixgbe_rx_napi_id()
6619 return q_vector ? q_vector->napi.napi_id : 0; in ixgbe_rx_napi_id()
6623 * ixgbe_setup_rx_resources - allocate Rx resources (Descriptors)
6632 struct device *dev = rx_ring->dev; in ixgbe_setup_rx_resources()
6637 size = sizeof(struct ixgbe_rx_buffer) * rx_ring->count; in ixgbe_setup_rx_resources()
6639 if (rx_ring->q_vector) in ixgbe_setup_rx_resources()
6640 ring_node = rx_ring->q_vector->numa_node; in ixgbe_setup_rx_resources()
6642 rx_ring->rx_buffer_info = vmalloc_node(size, ring_node); in ixgbe_setup_rx_resources()
6643 if (!rx_ring->rx_buffer_info) in ixgbe_setup_rx_resources()
6644 rx_ring->rx_buffer_info = vmalloc(size); in ixgbe_setup_rx_resources()
6645 if (!rx_ring->rx_buffer_info) in ixgbe_setup_rx_resources()
6649 rx_ring->size = rx_ring->count * sizeof(union ixgbe_adv_rx_desc); in ixgbe_setup_rx_resources()
6650 rx_ring->size = ALIGN(rx_ring->size, 4096); in ixgbe_setup_rx_resources()
6653 rx_ring->desc = dma_alloc_coherent(dev, in ixgbe_setup_rx_resources()
6654 rx_ring->size, in ixgbe_setup_rx_resources()
6655 &rx_ring->dma, in ixgbe_setup_rx_resources()
6658 if (!rx_ring->desc) in ixgbe_setup_rx_resources()
6659 rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size, in ixgbe_setup_rx_resources()
6660 &rx_ring->dma, GFP_KERNEL); in ixgbe_setup_rx_resources()
6661 if (!rx_ring->desc) in ixgbe_setup_rx_resources()
6664 rx_ring->next_to_clean = 0; in ixgbe_setup_rx_resources()
6665 rx_ring->next_to_use = 0; in ixgbe_setup_rx_resources()
6667 /* XDP RX-queue info */ in ixgbe_setup_rx_resources()
6668 if (xdp_rxq_info_reg(&rx_ring->xdp_rxq, adapter->netdev, in ixgbe_setup_rx_resources()
6669 rx_ring->queue_index, ixgbe_rx_napi_id(rx_ring)) < 0) in ixgbe_setup_rx_resources()
6672 WRITE_ONCE(rx_ring->xdp_prog, adapter->xdp_prog); in ixgbe_setup_rx_resources()
6676 vfree(rx_ring->rx_buffer_info); in ixgbe_setup_rx_resources()
6677 rx_ring->rx_buffer_info = NULL; in ixgbe_setup_rx_resources()
6679 return -ENOMEM; in ixgbe_setup_rx_resources()
6683 * ixgbe_setup_all_rx_resources - allocate all queues Rx resources
6696 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_setup_all_rx_resources()
6697 err = ixgbe_setup_rx_resources(adapter, adapter->rx_ring[i]); in ixgbe_setup_all_rx_resources()
6712 while (i--) in ixgbe_setup_all_rx_resources()
6713 ixgbe_free_rx_resources(adapter->rx_ring[i]); in ixgbe_setup_all_rx_resources()
6718 * ixgbe_free_tx_resources - Free Tx Resources per Queue
6727 vfree(tx_ring->tx_buffer_info); in ixgbe_free_tx_resources()
6728 tx_ring->tx_buffer_info = NULL; in ixgbe_free_tx_resources()
6731 if (!tx_ring->desc) in ixgbe_free_tx_resources()
6734 dma_free_coherent(tx_ring->dev, tx_ring->size, in ixgbe_free_tx_resources()
6735 tx_ring->desc, tx_ring->dma); in ixgbe_free_tx_resources()
6737 tx_ring->desc = NULL; in ixgbe_free_tx_resources()
6741 * ixgbe_free_all_tx_resources - Free Tx Resources for All Queues
6750 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_free_all_tx_resources()
6751 if (adapter->tx_ring[i]->desc) in ixgbe_free_all_tx_resources()
6752 ixgbe_free_tx_resources(adapter->tx_ring[i]); in ixgbe_free_all_tx_resources()
6753 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_free_all_tx_resources()
6754 if (adapter->xdp_ring[i]->desc) in ixgbe_free_all_tx_resources()
6755 ixgbe_free_tx_resources(adapter->xdp_ring[i]); in ixgbe_free_all_tx_resources()
6759 * ixgbe_free_rx_resources - Free Rx Resources
6768 rx_ring->xdp_prog = NULL; in ixgbe_free_rx_resources()
6769 xdp_rxq_info_unreg(&rx_ring->xdp_rxq); in ixgbe_free_rx_resources()
6770 vfree(rx_ring->rx_buffer_info); in ixgbe_free_rx_resources()
6771 rx_ring->rx_buffer_info = NULL; in ixgbe_free_rx_resources()
6774 if (!rx_ring->desc) in ixgbe_free_rx_resources()
6777 dma_free_coherent(rx_ring->dev, rx_ring->size, in ixgbe_free_rx_resources()
6778 rx_ring->desc, rx_ring->dma); in ixgbe_free_rx_resources()
6780 rx_ring->desc = NULL; in ixgbe_free_rx_resources()
6784 * ixgbe_free_all_rx_resources - Free Rx Resources for All Queues
6797 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_free_all_rx_resources()
6798 if (adapter->rx_ring[i]->desc) in ixgbe_free_all_rx_resources()
6799 ixgbe_free_rx_resources(adapter->rx_ring[i]); in ixgbe_free_all_rx_resources()
6803 * ixgbe_max_xdp_frame_size - returns the maximum allowed frame size for XDP
6808 if (PAGE_SIZE >= 8192 || adapter->flags2 & IXGBE_FLAG2_RX_LEGACY) in ixgbe_max_xdp_frame_size()
6815 * ixgbe_change_mtu - Change the Maximum Transfer Unit
6830 return -EINVAL; in ixgbe_change_mtu()
6839 if ((adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) && in ixgbe_change_mtu()
6840 (adapter->hw.mac.type == ixgbe_mac_82599EB) && in ixgbe_change_mtu()
6845 netdev->mtu, new_mtu); in ixgbe_change_mtu()
6848 WRITE_ONCE(netdev->mtu, new_mtu); in ixgbe_change_mtu()
6857 * ixgbe_open - Called when a network interface is made active
6871 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_open()
6875 if (test_bit(__IXGBE_TESTING, &adapter->state)) in ixgbe_open()
6876 return -EBUSY; in ixgbe_open()
6897 queues = adapter->num_tx_queues; in ixgbe_open()
6902 queues = adapter->num_rx_queues; in ixgbe_open()
6919 if (hw->phy.ops.set_phy_power && !adapter->wol) in ixgbe_open()
6920 hw->phy.ops.set_phy_power(&adapter->hw, false); in ixgbe_open()
6933 if (adapter->hw.phy.ops.enter_lplu) { in ixgbe_close_suspend()
6934 adapter->hw.phy.reset_disable = true; in ixgbe_close_suspend()
6936 adapter->hw.phy.ops.enter_lplu(&adapter->hw); in ixgbe_close_suspend()
6937 adapter->hw.phy.reset_disable = false; in ixgbe_close_suspend()
6949 * ixgbe_close - Disables a network interface
6954 * The close entry point is called when an interface is de-activated
6979 struct net_device *netdev = adapter->netdev; in ixgbe_resume()
6982 adapter->hw.hw_addr = adapter->io_addr; in ixgbe_resume()
6990 clear_bit(__IXGBE_DISABLED, &adapter->state); in ixgbe_resume()
6997 IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0); in ixgbe_resume()
7015 struct net_device *netdev = adapter->netdev; in __ixgbe_shutdown()
7016 struct ixgbe_hw *hw = &adapter->hw; in __ixgbe_shutdown()
7018 u32 wufc = adapter->wol; in __ixgbe_shutdown()
7029 if (hw->mac.ops.stop_link_on_d3) in __ixgbe_shutdown()
7030 hw->mac.ops.stop_link_on_d3(hw); in __ixgbe_shutdown()
7038 if (hw->mac.ops.enable_tx_laser) in __ixgbe_shutdown()
7039 hw->mac.ops.enable_tx_laser(hw); in __ixgbe_shutdown()
7056 switch (hw->mac.type) { in __ixgbe_shutdown()
7072 if (hw->phy.ops.set_phy_power && !*enable_wake) in __ixgbe_shutdown()
7073 hw->phy.ops.set_phy_power(hw, false); in __ixgbe_shutdown()
7077 if (!test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) in __ixgbe_shutdown()
7109 * ixgbe_update_stats - Update the board statistics counters.
7114 struct net_device *netdev = adapter->netdev; in ixgbe_update_stats()
7115 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_update_stats()
7116 struct ixgbe_hw_stats *hwstats = &adapter->stats; in ixgbe_update_stats()
7124 if (test_bit(__IXGBE_DOWN, &adapter->state) || in ixgbe_update_stats()
7125 test_bit(__IXGBE_RESETTING, &adapter->state)) in ixgbe_update_stats()
7128 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) { in ixgbe_update_stats()
7131 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_update_stats()
7132 rsc_count += adapter->rx_ring[i]->rx_stats.rsc_count; in ixgbe_update_stats()
7133 rsc_flush += adapter->rx_ring[i]->rx_stats.rsc_flush; in ixgbe_update_stats()
7135 adapter->rsc_total_count = rsc_count; in ixgbe_update_stats()
7136 adapter->rsc_total_flush = rsc_flush; in ixgbe_update_stats()
7139 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_update_stats()
7140 struct ixgbe_ring *rx_ring = READ_ONCE(adapter->rx_ring[i]); in ixgbe_update_stats()
7144 non_eop_descs += rx_ring->rx_stats.non_eop_descs; in ixgbe_update_stats()
7145 alloc_rx_page += rx_ring->rx_stats.alloc_rx_page; in ixgbe_update_stats()
7146 alloc_rx_page_failed += rx_ring->rx_stats.alloc_rx_page_failed; in ixgbe_update_stats()
7147 alloc_rx_buff_failed += rx_ring->rx_stats.alloc_rx_buff_failed; in ixgbe_update_stats()
7148 hw_csum_rx_error += rx_ring->rx_stats.csum_err; in ixgbe_update_stats()
7149 bytes += rx_ring->stats.bytes; in ixgbe_update_stats()
7150 packets += rx_ring->stats.packets; in ixgbe_update_stats()
7152 adapter->non_eop_descs = non_eop_descs; in ixgbe_update_stats()
7153 adapter->alloc_rx_page = alloc_rx_page; in ixgbe_update_stats()
7154 adapter->alloc_rx_page_failed = alloc_rx_page_failed; in ixgbe_update_stats()
7155 adapter->alloc_rx_buff_failed = alloc_rx_buff_failed; in ixgbe_update_stats()
7156 adapter->hw_csum_rx_error = hw_csum_rx_error; in ixgbe_update_stats()
7157 netdev->stats.rx_bytes = bytes; in ixgbe_update_stats()
7158 netdev->stats.rx_packets = packets; in ixgbe_update_stats()
7163 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_update_stats()
7164 struct ixgbe_ring *tx_ring = READ_ONCE(adapter->tx_ring[i]); in ixgbe_update_stats()
7168 restart_queue += tx_ring->tx_stats.restart_queue; in ixgbe_update_stats()
7169 tx_busy += tx_ring->tx_stats.tx_busy; in ixgbe_update_stats()
7170 bytes += tx_ring->stats.bytes; in ixgbe_update_stats()
7171 packets += tx_ring->stats.packets; in ixgbe_update_stats()
7173 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_update_stats()
7174 struct ixgbe_ring *xdp_ring = READ_ONCE(adapter->xdp_ring[i]); in ixgbe_update_stats()
7178 restart_queue += xdp_ring->tx_stats.restart_queue; in ixgbe_update_stats()
7179 tx_busy += xdp_ring->tx_stats.tx_busy; in ixgbe_update_stats()
7180 bytes += xdp_ring->stats.bytes; in ixgbe_update_stats()
7181 packets += xdp_ring->stats.packets; in ixgbe_update_stats()
7183 adapter->restart_queue = restart_queue; in ixgbe_update_stats()
7184 adapter->tx_busy = tx_busy; in ixgbe_update_stats()
7185 netdev->stats.tx_bytes = bytes; in ixgbe_update_stats()
7186 netdev->stats.tx_packets = packets; in ixgbe_update_stats()
7188 hwstats->crcerrs += IXGBE_READ_REG(hw, IXGBE_CRCERRS); in ixgbe_update_stats()
7195 hwstats->mpc[i] += mpc; in ixgbe_update_stats()
7196 total_mpc += hwstats->mpc[i]; in ixgbe_update_stats()
7197 hwstats->pxontxc[i] += IXGBE_READ_REG(hw, IXGBE_PXONTXC(i)); in ixgbe_update_stats()
7198 hwstats->pxofftxc[i] += IXGBE_READ_REG(hw, IXGBE_PXOFFTXC(i)); in ixgbe_update_stats()
7199 switch (hw->mac.type) { in ixgbe_update_stats()
7201 hwstats->rnbc[i] += IXGBE_READ_REG(hw, IXGBE_RNBC(i)); in ixgbe_update_stats()
7202 hwstats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC(i)); in ixgbe_update_stats()
7203 hwstats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC(i)); in ixgbe_update_stats()
7204 hwstats->pxonrxc[i] += in ixgbe_update_stats()
7212 hwstats->pxonrxc[i] += in ixgbe_update_stats()
7222 hwstats->qptc[i] += IXGBE_READ_REG(hw, IXGBE_QPTC(i)); in ixgbe_update_stats()
7223 hwstats->qprc[i] += IXGBE_READ_REG(hw, IXGBE_QPRC(i)); in ixgbe_update_stats()
7224 if ((hw->mac.type == ixgbe_mac_82599EB) || in ixgbe_update_stats()
7225 (hw->mac.type == ixgbe_mac_X540) || in ixgbe_update_stats()
7226 (hw->mac.type == ixgbe_mac_X550) || in ixgbe_update_stats()
7227 (hw->mac.type == ixgbe_mac_X550EM_x) || in ixgbe_update_stats()
7228 (hw->mac.type == ixgbe_mac_x550em_a)) { in ixgbe_update_stats()
7229 hwstats->qbtc[i] += IXGBE_READ_REG(hw, IXGBE_QBTC_L(i)); in ixgbe_update_stats()
7231 hwstats->qbrc[i] += IXGBE_READ_REG(hw, IXGBE_QBRC_L(i)); in ixgbe_update_stats()
7236 hwstats->gprc += IXGBE_READ_REG(hw, IXGBE_GPRC); in ixgbe_update_stats()
7238 hwstats->gprc -= missed_rx; in ixgbe_update_stats()
7243 switch (hw->mac.type) { in ixgbe_update_stats()
7245 hwstats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXC); in ixgbe_update_stats()
7246 hwstats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCH); in ixgbe_update_stats()
7247 hwstats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCH); in ixgbe_update_stats()
7248 hwstats->tor += IXGBE_READ_REG(hw, IXGBE_TORH); in ixgbe_update_stats()
7255 hwstats->o2bgptc += IXGBE_READ_REG(hw, IXGBE_O2BGPTC); in ixgbe_update_stats()
7256 hwstats->o2bspc += IXGBE_READ_REG(hw, IXGBE_O2BSPC); in ixgbe_update_stats()
7257 hwstats->b2ospc += IXGBE_READ_REG(hw, IXGBE_B2OSPC); in ixgbe_update_stats()
7258 hwstats->b2ogprc += IXGBE_READ_REG(hw, IXGBE_B2OGPRC); in ixgbe_update_stats()
7262 adapter->hw_rx_no_dma_resources += in ixgbe_update_stats()
7264 hwstats->gorc += IXGBE_READ_REG(hw, IXGBE_GORCL); in ixgbe_update_stats()
7266 hwstats->gotc += IXGBE_READ_REG(hw, IXGBE_GOTCL); in ixgbe_update_stats()
7268 hwstats->tor += IXGBE_READ_REG(hw, IXGBE_TORL); in ixgbe_update_stats()
7270 hwstats->lxonrxc += IXGBE_READ_REG(hw, IXGBE_LXONRXCNT); in ixgbe_update_stats()
7271 hwstats->fdirmatch += IXGBE_READ_REG(hw, IXGBE_FDIRMATCH); in ixgbe_update_stats()
7272 hwstats->fdirmiss += IXGBE_READ_REG(hw, IXGBE_FDIRMISS); in ixgbe_update_stats()
7274 hwstats->fccrc += IXGBE_READ_REG(hw, IXGBE_FCCRC); in ixgbe_update_stats()
7275 hwstats->fcoerpdc += IXGBE_READ_REG(hw, IXGBE_FCOERPDC); in ixgbe_update_stats()
7276 hwstats->fcoeprc += IXGBE_READ_REG(hw, IXGBE_FCOEPRC); in ixgbe_update_stats()
7277 hwstats->fcoeptc += IXGBE_READ_REG(hw, IXGBE_FCOEPTC); in ixgbe_update_stats()
7278 hwstats->fcoedwrc += IXGBE_READ_REG(hw, IXGBE_FCOEDWRC); in ixgbe_update_stats()
7279 hwstats->fcoedwtc += IXGBE_READ_REG(hw, IXGBE_FCOEDWTC); in ixgbe_update_stats()
7280 /* Add up per cpu counters for total ddp aloc fail */ in ixgbe_update_stats()
7281 if (adapter->fcoe.ddp_pool) { in ixgbe_update_stats()
7282 struct ixgbe_fcoe *fcoe = &adapter->fcoe; in ixgbe_update_stats()
7284 unsigned int cpu; in ixgbe_update_stats() local
7286 for_each_possible_cpu(cpu) { in ixgbe_update_stats()
7287 ddp_pool = per_cpu_ptr(fcoe->ddp_pool, cpu); in ixgbe_update_stats()
7288 noddp += ddp_pool->noddp; in ixgbe_update_stats()
7289 noddp_ext_buff += ddp_pool->noddp_ext_buff; in ixgbe_update_stats()
7291 hwstats->fcoe_noddp = noddp; in ixgbe_update_stats()
7292 hwstats->fcoe_noddp_ext_buff = noddp_ext_buff; in ixgbe_update_stats()
7300 hwstats->bprc += bprc; in ixgbe_update_stats()
7301 hwstats->mprc += IXGBE_READ_REG(hw, IXGBE_MPRC); in ixgbe_update_stats()
7302 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_update_stats()
7303 hwstats->mprc -= bprc; in ixgbe_update_stats()
7304 hwstats->roc += IXGBE_READ_REG(hw, IXGBE_ROC); in ixgbe_update_stats()
7305 hwstats->prc64 += IXGBE_READ_REG(hw, IXGBE_PRC64); in ixgbe_update_stats()
7306 hwstats->prc127 += IXGBE_READ_REG(hw, IXGBE_PRC127); in ixgbe_update_stats()
7307 hwstats->prc255 += IXGBE_READ_REG(hw, IXGBE_PRC255); in ixgbe_update_stats()
7308 hwstats->prc511 += IXGBE_READ_REG(hw, IXGBE_PRC511); in ixgbe_update_stats()
7309 hwstats->prc1023 += IXGBE_READ_REG(hw, IXGBE_PRC1023); in ixgbe_update_stats()
7310 hwstats->prc1522 += IXGBE_READ_REG(hw, IXGBE_PRC1522); in ixgbe_update_stats()
7311 hwstats->rlec += IXGBE_READ_REG(hw, IXGBE_RLEC); in ixgbe_update_stats()
7313 hwstats->lxontxc += lxon; in ixgbe_update_stats()
7315 hwstats->lxofftxc += lxoff; in ixgbe_update_stats()
7316 hwstats->gptc += IXGBE_READ_REG(hw, IXGBE_GPTC); in ixgbe_update_stats()
7317 hwstats->mptc += IXGBE_READ_REG(hw, IXGBE_MPTC); in ixgbe_update_stats()
7319 * 82598 errata - tx of flow control packets is included in tx counters in ixgbe_update_stats()
7322 hwstats->gptc -= xon_off_tot; in ixgbe_update_stats()
7323 hwstats->mptc -= xon_off_tot; in ixgbe_update_stats()
7324 hwstats->gotc -= (xon_off_tot * (ETH_ZLEN + ETH_FCS_LEN)); in ixgbe_update_stats()
7325 hwstats->ruc += IXGBE_READ_REG(hw, IXGBE_RUC); in ixgbe_update_stats()
7326 hwstats->rfc += IXGBE_READ_REG(hw, IXGBE_RFC); in ixgbe_update_stats()
7327 hwstats->rjc += IXGBE_READ_REG(hw, IXGBE_RJC); in ixgbe_update_stats()
7328 hwstats->tpr += IXGBE_READ_REG(hw, IXGBE_TPR); in ixgbe_update_stats()
7329 hwstats->ptc64 += IXGBE_READ_REG(hw, IXGBE_PTC64); in ixgbe_update_stats()
7330 hwstats->ptc64 -= xon_off_tot; in ixgbe_update_stats()
7331 hwstats->ptc127 += IXGBE_READ_REG(hw, IXGBE_PTC127); in ixgbe_update_stats()
7332 hwstats->ptc255 += IXGBE_READ_REG(hw, IXGBE_PTC255); in ixgbe_update_stats()
7333 hwstats->ptc511 += IXGBE_READ_REG(hw, IXGBE_PTC511); in ixgbe_update_stats()
7334 hwstats->ptc1023 += IXGBE_READ_REG(hw, IXGBE_PTC1023); in ixgbe_update_stats()
7335 hwstats->ptc1522 += IXGBE_READ_REG(hw, IXGBE_PTC1522); in ixgbe_update_stats()
7336 hwstats->bptc += IXGBE_READ_REG(hw, IXGBE_BPTC); in ixgbe_update_stats()
7339 netdev->stats.multicast = hwstats->mprc; in ixgbe_update_stats()
7342 netdev->stats.rx_errors = hwstats->crcerrs + hwstats->rlec; in ixgbe_update_stats()
7343 netdev->stats.rx_dropped = 0; in ixgbe_update_stats()
7344 netdev->stats.rx_length_errors = hwstats->rlec; in ixgbe_update_stats()
7345 netdev->stats.rx_crc_errors = hwstats->crcerrs; in ixgbe_update_stats()
7346 netdev->stats.rx_missed_errors = total_mpc; in ixgbe_update_stats()
7348 /* VF Stats Collection - skip while resetting because these in ixgbe_update_stats()
7352 if (!test_bit(__IXGBE_RESETTING, &adapter->state)) { in ixgbe_update_stats()
7353 for (i = 0; i < adapter->num_vfs; i++) { in ixgbe_update_stats()
7355 adapter->vfinfo[i].last_vfstats.gprc, in ixgbe_update_stats()
7356 adapter->vfinfo[i].vfstats.gprc); in ixgbe_update_stats()
7358 adapter->vfinfo[i].last_vfstats.gptc, in ixgbe_update_stats()
7359 adapter->vfinfo[i].vfstats.gptc); in ixgbe_update_stats()
7362 adapter->vfinfo[i].last_vfstats.gorc, in ixgbe_update_stats()
7363 adapter->vfinfo[i].vfstats.gorc); in ixgbe_update_stats()
7366 adapter->vfinfo[i].last_vfstats.gotc, in ixgbe_update_stats()
7367 adapter->vfinfo[i].vfstats.gotc); in ixgbe_update_stats()
7369 adapter->vfinfo[i].last_vfstats.mprc, in ixgbe_update_stats()
7370 adapter->vfinfo[i].vfstats.mprc); in ixgbe_update_stats()
7376 * ixgbe_fdir_reinit_subtask - worker thread to reinit FDIR filter table
7381 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_fdir_reinit_subtask()
7384 if (!(adapter->flags2 & IXGBE_FLAG2_FDIR_REQUIRES_REINIT)) in ixgbe_fdir_reinit_subtask()
7387 adapter->flags2 &= ~IXGBE_FLAG2_FDIR_REQUIRES_REINIT; in ixgbe_fdir_reinit_subtask()
7390 if (test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_fdir_reinit_subtask()
7394 if (!(adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE)) in ixgbe_fdir_reinit_subtask()
7397 adapter->fdir_overflow++; in ixgbe_fdir_reinit_subtask()
7400 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_fdir_reinit_subtask()
7402 &(adapter->tx_ring[i]->state)); in ixgbe_fdir_reinit_subtask()
7403 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_fdir_reinit_subtask()
7405 &adapter->xdp_ring[i]->state); in ixgbe_fdir_reinit_subtask()
7406 /* re-enable flow director interrupts */ in ixgbe_fdir_reinit_subtask()
7409 e_err(probe, "failed to finish FDIR re-initialization, " in ixgbe_fdir_reinit_subtask()
7415 * ixgbe_check_hang_subtask - check for hung queues and dropped interrupts
7425 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_hang_subtask()
7430 if (test_bit(__IXGBE_DOWN, &adapter->state) || in ixgbe_check_hang_subtask()
7431 test_bit(__IXGBE_REMOVING, &adapter->state) || in ixgbe_check_hang_subtask()
7432 test_bit(__IXGBE_RESETTING, &adapter->state)) in ixgbe_check_hang_subtask()
7436 if (netif_carrier_ok(adapter->netdev)) { in ixgbe_check_hang_subtask()
7437 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_check_hang_subtask()
7438 set_check_for_tx_hang(adapter->tx_ring[i]); in ixgbe_check_hang_subtask()
7439 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_check_hang_subtask()
7440 set_check_for_tx_hang(adapter->xdp_ring[i]); in ixgbe_check_hang_subtask()
7443 if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) { in ixgbe_check_hang_subtask()
7453 for (i = 0; i < adapter->num_q_vectors; i++) { in ixgbe_check_hang_subtask()
7454 struct ixgbe_q_vector *qv = adapter->q_vector[i]; in ixgbe_check_hang_subtask()
7455 if (qv->rx.ring || qv->tx.ring) in ixgbe_check_hang_subtask()
7465 * ixgbe_watchdog_update_link - update the link status
7470 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_watchdog_update_link()
7471 u32 link_speed = adapter->link_speed; in ixgbe_watchdog_update_link()
7472 bool link_up = adapter->link_up; in ixgbe_watchdog_update_link()
7473 bool pfc_en = adapter->dcb_cfg.pfc_mode_enable; in ixgbe_watchdog_update_link()
7475 if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE)) in ixgbe_watchdog_update_link()
7478 if (hw->mac.ops.check_link) { in ixgbe_watchdog_update_link()
7479 hw->mac.ops.check_link(hw, &link_speed, &link_up, false); in ixgbe_watchdog_update_link()
7486 if (adapter->ixgbe_ieee_pfc) in ixgbe_watchdog_update_link()
7487 pfc_en |= !!(adapter->ixgbe_ieee_pfc->pfc_en); in ixgbe_watchdog_update_link()
7489 if (link_up && !((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && pfc_en)) { in ixgbe_watchdog_update_link()
7490 hw->mac.ops.fc_enable(hw); in ixgbe_watchdog_update_link()
7495 time_after(jiffies, (adapter->link_check_timeout + in ixgbe_watchdog_update_link()
7497 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_watchdog_update_link()
7502 adapter->link_up = link_up; in ixgbe_watchdog_update_link()
7503 adapter->link_speed = link_speed; in ixgbe_watchdog_update_link()
7509 struct net_device *netdev = adapter->netdev; in ixgbe_update_default_up()
7516 if (adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE) in ixgbe_update_default_up()
7519 adapter->default_up = (up > 1) ? (ffs(up) - 1) : 0; in ixgbe_update_default_up()
7524 * ixgbe_watchdog_link_is_up - update netif_carrier status and
7530 struct net_device *netdev = adapter->netdev; in ixgbe_watchdog_link_is_up()
7531 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_watchdog_link_is_up()
7532 u32 link_speed = adapter->link_speed; in ixgbe_watchdog_link_is_up()
7540 adapter->flags2 &= ~IXGBE_FLAG2_SEARCH_FOR_SFP; in ixgbe_watchdog_link_is_up()
7542 switch (hw->mac.type) { in ixgbe_watchdog_link_is_up()
7567 adapter->last_rx_ptp_check = jiffies; in ixgbe_watchdog_link_is_up()
7569 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) in ixgbe_watchdog_link_is_up()
7604 netif_tx_wake_all_queues(adapter->netdev); in ixgbe_watchdog_link_is_up()
7614 * ixgbe_watchdog_link_is_down - update netif_carrier status and
7620 struct net_device *netdev = adapter->netdev; in ixgbe_watchdog_link_is_down()
7621 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_watchdog_link_is_down()
7623 adapter->link_up = false; in ixgbe_watchdog_link_is_down()
7624 adapter->link_speed = 0; in ixgbe_watchdog_link_is_down()
7631 if (ixgbe_is_sfp(hw) && hw->mac.type == ixgbe_mac_82598EB) in ixgbe_watchdog_link_is_down()
7632 adapter->flags2 |= IXGBE_FLAG2_SEARCH_FOR_SFP; in ixgbe_watchdog_link_is_down()
7634 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) in ixgbe_watchdog_link_is_down()
7648 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_ring_tx_pending()
7649 struct ixgbe_ring *tx_ring = adapter->tx_ring[i]; in ixgbe_ring_tx_pending()
7651 if (tx_ring->next_to_use != tx_ring->next_to_clean) in ixgbe_ring_tx_pending()
7655 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_ring_tx_pending()
7656 struct ixgbe_ring *ring = adapter->xdp_ring[i]; in ixgbe_ring_tx_pending()
7658 if (ring->next_to_use != ring->next_to_clean) in ixgbe_ring_tx_pending()
7667 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_vf_tx_pending()
7668 struct ixgbe_ring_feature *vmdq = &adapter->ring_feature[RING_F_VMDQ]; in ixgbe_vf_tx_pending()
7669 u32 q_per_pool = __ALIGN_MASK(1, ~vmdq->mask); in ixgbe_vf_tx_pending()
7673 if (!adapter->num_vfs) in ixgbe_vf_tx_pending()
7677 if (hw->mac.type >= ixgbe_mac_X550) in ixgbe_vf_tx_pending()
7680 for (i = 0; i < adapter->num_vfs; i++) { in ixgbe_vf_tx_pending()
7696 * ixgbe_watchdog_flush_tx - flush queues on link down
7701 if (!netif_carrier_ok(adapter->netdev)) { in ixgbe_watchdog_flush_tx()
7710 set_bit(__IXGBE_RESET_REQUESTED, &adapter->state); in ixgbe_watchdog_flush_tx()
7718 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_bad_vf_abort()
7720 if (adapter->hw.mac.type == ixgbe_mac_82599EB && in ixgbe_bad_vf_abort()
7721 adapter->flags2 & IXGBE_FLAG2_AUTO_DISABLE_VF) { in ixgbe_bad_vf_abort()
7722 adapter->vfinfo[vf].primary_abort_count++; in ixgbe_bad_vf_abort()
7723 if (adapter->vfinfo[vf].primary_abort_count == in ixgbe_bad_vf_abort()
7727 adapter->vfinfo[vf].primary_abort_count = 0; in ixgbe_bad_vf_abort()
7730 "Malicious Driver Detection event detected on PF %d VF %d MAC: %pM mdd-disable-vf=on", in ixgbe_bad_vf_abort()
7731 hw->bus.func, vf, in ixgbe_bad_vf_abort()
7732 adapter->vfinfo[vf].vf_mac_addresses); in ixgbe_bad_vf_abort()
7739 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_for_bad_vf()
7740 struct pci_dev *pdev = adapter->pdev; in ixgbe_check_for_bad_vf()
7744 if (!(netif_carrier_ok(adapter->netdev))) in ixgbe_check_for_bad_vf()
7760 for (vf = 0; vf < adapter->num_vfs; ++vf) { in ixgbe_check_for_bad_vf()
7761 struct pci_dev *vfdev = adapter->vfinfo[vf].vfdev; in ixgbe_check_for_bad_vf()
7780 if (adapter->hw.mac.type == ixgbe_mac_82598EB || in ixgbe_spoof_check()
7781 adapter->num_vfs == 0) in ixgbe_spoof_check()
7784 ssvpc = IXGBE_READ_REG(&adapter->hw, IXGBE_SSVPC); in ixgbe_spoof_check()
7808 * ixgbe_watchdog_subtask - check and bring link up
7814 if (test_bit(__IXGBE_DOWN, &adapter->state) || in ixgbe_watchdog_subtask()
7815 test_bit(__IXGBE_REMOVING, &adapter->state) || in ixgbe_watchdog_subtask()
7816 test_bit(__IXGBE_RESETTING, &adapter->state)) in ixgbe_watchdog_subtask()
7821 if (adapter->link_up) in ixgbe_watchdog_subtask()
7834 * ixgbe_sfp_detection_subtask - poll for SFP+ cable
7839 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_sfp_detection_subtask()
7843 if (!(adapter->flags2 & IXGBE_FLAG2_SEARCH_FOR_SFP) && in ixgbe_sfp_detection_subtask()
7844 !(adapter->flags2 & IXGBE_FLAG2_SFP_NEEDS_RESET)) in ixgbe_sfp_detection_subtask()
7847 if (adapter->sfp_poll_time && in ixgbe_sfp_detection_subtask()
7848 time_after(adapter->sfp_poll_time, jiffies)) in ixgbe_sfp_detection_subtask()
7852 if (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state)) in ixgbe_sfp_detection_subtask()
7855 adapter->sfp_poll_time = jiffies + IXGBE_SFP_POLL_JIFFIES - 1; in ixgbe_sfp_detection_subtask()
7857 err = hw->phy.ops.identify_sfp(hw); in ixgbe_sfp_detection_subtask()
7858 if (err == -EOPNOTSUPP) in ixgbe_sfp_detection_subtask()
7861 if (err == -ENOENT) { in ixgbe_sfp_detection_subtask()
7864 adapter->flags2 |= IXGBE_FLAG2_SFP_NEEDS_RESET; in ixgbe_sfp_detection_subtask()
7872 if (!(adapter->flags2 & IXGBE_FLAG2_SFP_NEEDS_RESET)) in ixgbe_sfp_detection_subtask()
7875 adapter->flags2 &= ~IXGBE_FLAG2_SFP_NEEDS_RESET; in ixgbe_sfp_detection_subtask()
7882 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_sfp_detection_subtask()
7883 err = hw->phy.ops.reset(hw); in ixgbe_sfp_detection_subtask()
7885 err = hw->mac.ops.setup_sfp(hw); in ixgbe_sfp_detection_subtask()
7887 if (err == -EOPNOTSUPP) in ixgbe_sfp_detection_subtask()
7890 adapter->flags |= IXGBE_FLAG_NEED_LINK_CONFIG; in ixgbe_sfp_detection_subtask()
7891 e_info(probe, "detected SFP+: %d\n", hw->phy.sfp_type); in ixgbe_sfp_detection_subtask()
7894 clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state); in ixgbe_sfp_detection_subtask()
7896 if (err == -EOPNOTSUPP && in ixgbe_sfp_detection_subtask()
7897 adapter->netdev->reg_state == NETREG_REGISTERED) { in ixgbe_sfp_detection_subtask()
7902 unregister_netdev(adapter->netdev); in ixgbe_sfp_detection_subtask()
7907 * ixgbe_sfp_link_config_subtask - set up link SFP after module install
7912 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_sfp_link_config_subtask()
7917 if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_CONFIG)) in ixgbe_sfp_link_config_subtask()
7921 if (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state)) in ixgbe_sfp_link_config_subtask()
7924 adapter->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; in ixgbe_sfp_link_config_subtask()
7926 hw->mac.ops.get_link_capabilities(hw, &cap_speed, &autoneg); in ixgbe_sfp_link_config_subtask()
7935 if (hw->mac.ops.setup_link) in ixgbe_sfp_link_config_subtask()
7936 hw->mac.ops.setup_link(hw, speed, true); in ixgbe_sfp_link_config_subtask()
7938 adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE; in ixgbe_sfp_link_config_subtask()
7939 adapter->link_check_timeout = jiffies; in ixgbe_sfp_link_config_subtask()
7940 clear_bit(__IXGBE_IN_SFP_INIT, &adapter->state); in ixgbe_sfp_link_config_subtask()
7944 * ixgbe_service_timer - Timer Call-back
7953 if (adapter->flags & IXGBE_FLAG_NEED_LINK_UPDATE) in ixgbe_service_timer()
7959 mod_timer(&adapter->service_timer, next_event_offset + jiffies); in ixgbe_service_timer()
7966 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_phy_interrupt_subtask()
7969 if (!(adapter->flags2 & IXGBE_FLAG2_PHY_INTERRUPT)) in ixgbe_phy_interrupt_subtask()
7972 adapter->flags2 &= ~IXGBE_FLAG2_PHY_INTERRUPT; in ixgbe_phy_interrupt_subtask()
7974 if (!hw->phy.ops.handle_lasi) in ixgbe_phy_interrupt_subtask()
7977 hw->phy.ops.handle_lasi(&adapter->hw, &overtemp); in ixgbe_phy_interrupt_subtask()
7984 if (!test_and_clear_bit(__IXGBE_RESET_REQUESTED, &adapter->state)) in ixgbe_reset_subtask()
7989 if (test_bit(__IXGBE_DOWN, &adapter->state) || in ixgbe_reset_subtask()
7990 test_bit(__IXGBE_REMOVING, &adapter->state) || in ixgbe_reset_subtask()
7991 test_bit(__IXGBE_RESETTING, &adapter->state)) { in ixgbe_reset_subtask()
7997 netdev_err(adapter->netdev, "Reset adapter\n"); in ixgbe_reset_subtask()
7998 adapter->tx_timeout_count++; in ixgbe_reset_subtask()
8005 * ixgbe_check_fw_error - Check firmware for errors
8012 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_check_fw_error()
8023 if (hw->mac.ops.fw_recovery_mode && hw->mac.ops.fw_recovery_mode(hw)) { in ixgbe_check_fw_error()
8032 * ixgbe_service_task - manages and runs subtasks
8040 if (ixgbe_removed(adapter->hw.hw_addr)) { in ixgbe_service_task()
8041 if (!test_bit(__IXGBE_DOWN, &adapter->state)) { in ixgbe_service_task()
8050 if (!test_bit(__IXGBE_DOWN, &adapter->state)) in ixgbe_service_task()
8051 unregister_netdev(adapter->netdev); in ixgbe_service_task()
8064 if (test_bit(__IXGBE_PTP_RUNNING, &adapter->state)) { in ixgbe_service_task()
8066 if (adapter->flags & IXGBE_FLAG_RX_HWTSTAMP_IN_REGISTER) in ixgbe_service_task()
8080 struct sk_buff *skb = first->skb; in ixgbe_tso()
8095 if (skb->ip_summed != CHECKSUM_PARTIAL) in ixgbe_tso()
8105 if (eth_p_mpls(first->protocol)) in ixgbe_tso()
8112 type_tucmd = (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) ? in ixgbe_tso()
8116 if (ip.v4->version == 4) { in ixgbe_tso()
8118 unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); in ixgbe_tso()
8119 int len = csum_start - trans_start; in ixgbe_tso()
8125 ip.v4->check = (skb_shinfo(skb)->gso_type & SKB_GSO_PARTIAL) ? in ixgbe_tso()
8130 ip.v4->tot_len = 0; in ixgbe_tso()
8131 first->tx_flags |= IXGBE_TX_FLAGS_TSO | in ixgbe_tso()
8135 ip.v6->payload_len = 0; in ixgbe_tso()
8136 first->tx_flags |= IXGBE_TX_FLAGS_TSO | in ixgbe_tso()
8141 l4_offset = l4.hdr - skb->data; in ixgbe_tso()
8144 paylen = skb->len - l4_offset; in ixgbe_tso()
8148 *hdr_len = (l4.tcp->doff * 4) + l4_offset; in ixgbe_tso()
8149 csum_replace_by_diff(&l4.tcp->check, in ixgbe_tso()
8154 csum_replace_by_diff(&l4.udp->check, in ixgbe_tso()
8159 first->gso_segs = skb_shinfo(skb)->gso_segs; in ixgbe_tso()
8160 first->bytecount += (first->gso_segs - 1) * *hdr_len; in ixgbe_tso()
8163 mss_l4len_idx = (*hdr_len - l4_offset) << IXGBE_ADVTXD_L4LEN_SHIFT; in ixgbe_tso()
8164 mss_l4len_idx |= skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT; in ixgbe_tso()
8166 fceof_saidx |= itd->sa_idx; in ixgbe_tso()
8167 type_tucmd |= itd->flags | itd->trailer_len; in ixgbe_tso()
8170 vlan_macip_lens = l4.hdr - ip.hdr; in ixgbe_tso()
8171 vlan_macip_lens |= (ip.hdr - skb->data) << IXGBE_ADVTXD_MACLEN_SHIFT; in ixgbe_tso()
8172 vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; in ixgbe_tso()
8184 struct sk_buff *skb = first->skb; in ixgbe_tx_csum()
8189 if (skb->ip_summed != CHECKSUM_PARTIAL) { in ixgbe_tx_csum()
8191 if (!(first->tx_flags & (IXGBE_TX_FLAGS_HW_VLAN | in ixgbe_tx_csum()
8197 switch (skb->csum_offset) { in ixgbe_tx_csum()
8216 first->tx_flags |= IXGBE_TX_FLAGS_CSUM; in ixgbe_tx_csum()
8217 vlan_macip_lens = skb_checksum_start_offset(skb) - in ixgbe_tx_csum()
8222 vlan_macip_lens |= first->tx_flags & IXGBE_TX_FLAGS_VLAN_MASK; in ixgbe_tx_csum()
8224 fceof_saidx |= itd->sa_idx; in ixgbe_tx_csum()
8225 type_tucmd |= itd->flags | itd->trailer_len; in ixgbe_tx_csum()
8255 cmd_type ^= IXGBE_SET_FLAG(skb->no_fcs, 1, IXGBE_ADVTXD_DCMD_IFCS); in ixgbe_tx_cmd_type()
8288 tx_desc->read.olinfo_status = cpu_to_le32(olinfo_status); in ixgbe_tx_olinfo_status()
8293 if (!netif_subqueue_try_stop(tx_ring->netdev, tx_ring->queue_index, in __ixgbe_maybe_stop_tx()
8295 return -EBUSY; in __ixgbe_maybe_stop_tx()
8297 ++tx_ring->tx_stats.restart_queue; in __ixgbe_maybe_stop_tx()
8313 struct sk_buff *skb = first->skb; in ixgbe_tx_map()
8319 u32 tx_flags = first->tx_flags; in ixgbe_tx_map()
8321 u16 i = tx_ring->next_to_use; in ixgbe_tx_map()
8325 ixgbe_tx_olinfo_status(tx_desc, tx_flags, skb->len - hdr_len); in ixgbe_tx_map()
8328 data_len = skb->data_len; in ixgbe_tx_map()
8333 size -= sizeof(struct fcoe_crc_eof) - data_len; in ixgbe_tx_map()
8336 data_len -= sizeof(struct fcoe_crc_eof); in ixgbe_tx_map()
8341 dma = dma_map_single(tx_ring->dev, skb->data, size, DMA_TO_DEVICE); in ixgbe_tx_map()
8345 for (frag = &skb_shinfo(skb)->frags[0];; frag++) { in ixgbe_tx_map()
8346 if (dma_mapping_error(tx_ring->dev, dma)) in ixgbe_tx_map()
8353 tx_desc->read.buffer_addr = cpu_to_le64(dma); in ixgbe_tx_map()
8356 tx_desc->read.cmd_type_len = in ixgbe_tx_map()
8361 if (i == tx_ring->count) { in ixgbe_tx_map()
8365 tx_desc->read.olinfo_status = 0; in ixgbe_tx_map()
8368 size -= IXGBE_MAX_DATA_PER_TXD; in ixgbe_tx_map()
8370 tx_desc->read.buffer_addr = cpu_to_le64(dma); in ixgbe_tx_map()
8376 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type ^ size); in ixgbe_tx_map()
8380 if (i == tx_ring->count) { in ixgbe_tx_map()
8384 tx_desc->read.olinfo_status = 0; in ixgbe_tx_map()
8391 data_len -= size; in ixgbe_tx_map()
8393 dma = skb_frag_dma_map(tx_ring->dev, frag, 0, size, in ixgbe_tx_map()
8396 tx_buffer = &tx_ring->tx_buffer_info[i]; in ixgbe_tx_map()
8401 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type); in ixgbe_tx_map()
8403 netdev_tx_sent_queue(txring_txq(tx_ring), first->bytecount); in ixgbe_tx_map()
8406 first->time_stamp = jiffies; in ixgbe_tx_map()
8412 * are new descriptors to fetch. (Only applicable for weak-ordered in ixgbe_tx_map()
8413 * memory model archs, such as IA-64). in ixgbe_tx_map()
8421 first->next_to_watch = tx_desc; in ixgbe_tx_map()
8424 if (i == tx_ring->count) in ixgbe_tx_map()
8427 tx_ring->next_to_use = i; in ixgbe_tx_map()
8432 writel(i, tx_ring->tail); in ixgbe_tx_map()
8437 dev_err(tx_ring->dev, "TX DMA map failed\n"); in ixgbe_tx_map()
8441 tx_buffer = &tx_ring->tx_buffer_info[i]; in ixgbe_tx_map()
8443 dma_unmap_page(tx_ring->dev, in ixgbe_tx_map()
8451 i += tx_ring->count; in ixgbe_tx_map()
8452 i--; in ixgbe_tx_map()
8455 dev_kfree_skb_any(first->skb); in ixgbe_tx_map()
8456 first->skb = NULL; in ixgbe_tx_map()
8458 tx_ring->next_to_use = i; in ixgbe_tx_map()
8460 return -1; in ixgbe_tx_map()
8466 struct ixgbe_q_vector *q_vector = ring->q_vector; in ixgbe_atr()
8485 if (!ring->atr_sample_rate) in ixgbe_atr()
8488 ring->atr_count++; in ixgbe_atr()
8491 if ((first->protocol != htons(ETH_P_IP)) && in ixgbe_atr()
8492 (first->protocol != htons(ETH_P_IPV6))) in ixgbe_atr()
8496 skb = first->skb; in ixgbe_atr()
8498 if (unlikely(hdr.network <= skb->data)) in ixgbe_atr()
8500 if (skb->encapsulation && in ixgbe_atr()
8501 first->protocol == htons(ETH_P_IP) && in ixgbe_atr()
8502 hdr.ipv4->protocol == IPPROTO_UDP) { in ixgbe_atr()
8503 struct ixgbe_adapter *adapter = q_vector->adapter; in ixgbe_atr()
8510 if (adapter->vxlan_port && in ixgbe_atr()
8511 udp_hdr(skb)->dest == adapter->vxlan_port) in ixgbe_atr()
8514 if (adapter->geneve_port && in ixgbe_atr()
8515 udp_hdr(skb)->dest == adapter->geneve_port) in ixgbe_atr()
8526 switch (hdr.ipv4->version) { in ixgbe_atr()
8530 l4_proto = hdr.ipv4->protocol; in ixgbe_atr()
8533 hlen = hdr.network - skb->data; in ixgbe_atr()
8535 hlen -= hdr.network - skb->data; in ixgbe_atr()
8551 if (th->fin) in ixgbe_atr()
8555 if (!th->syn && (ring->atr_count < ring->atr_sample_rate)) in ixgbe_atr()
8559 ring->atr_count = 0; in ixgbe_atr()
8561 vlan_id = htons(first->tx_flags >> IXGBE_TX_FLAGS_VLAN_SHIFT); in ixgbe_atr()
8566 * The input is broken into two sections, a non-compressed section in ixgbe_atr()
8576 if (first->tx_flags & (IXGBE_TX_FLAGS_SW_VLAN | IXGBE_TX_FLAGS_HW_VLAN)) in ixgbe_atr()
8577 common.port.src ^= th->dest ^ htons(ETH_P_8021Q); in ixgbe_atr()
8579 common.port.src ^= th->dest ^ first->protocol; in ixgbe_atr()
8580 common.port.dst ^= th->source; in ixgbe_atr()
8582 switch (hdr.ipv4->version) { in ixgbe_atr()
8585 common.ip ^= hdr.ipv4->saddr ^ hdr.ipv4->daddr; in ixgbe_atr()
8589 common.ip ^= hdr.ipv6->saddr.s6_addr32[0] ^ in ixgbe_atr()
8590 hdr.ipv6->saddr.s6_addr32[1] ^ in ixgbe_atr()
8591 hdr.ipv6->saddr.s6_addr32[2] ^ in ixgbe_atr()
8592 hdr.ipv6->saddr.s6_addr32[3] ^ in ixgbe_atr()
8593 hdr.ipv6->daddr.s6_addr32[0] ^ in ixgbe_atr()
8594 hdr.ipv6->daddr.s6_addr32[1] ^ in ixgbe_atr()
8595 hdr.ipv6->daddr.s6_addr32[2] ^ in ixgbe_atr()
8596 hdr.ipv6->daddr.s6_addr32[3]; in ixgbe_atr()
8605 /* This assumes the Rx queue and Tx queue are bound to the same CPU */ in ixgbe_atr()
8606 ixgbe_fdir_add_signature_filter_82599(&q_vector->adapter->hw, in ixgbe_atr()
8607 input, common, ring->queue_index); in ixgbe_atr()
8619 u8 tc = netdev_get_prio_tc_map(dev, skb->priority); in ixgbe_select_queue()
8622 txq = vdev->tc_to_txq[tc].offset; in ixgbe_select_queue()
8624 vdev->tc_to_txq[tc].count); in ixgbe_select_queue()
8638 if (!sb_dev && (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) in ixgbe_select_queue()
8645 f = &adapter->ring_feature[RING_F_FCOE]; in ixgbe_select_queue()
8650 while (txq >= f->indices) in ixgbe_select_queue()
8651 txq -= f->indices; in ixgbe_select_queue()
8653 return txq + f->offset; in ixgbe_select_queue()
8661 u8 nr_frags = unlikely(xdp_frame_has_frags(xdpf)) ? sinfo->nr_frags : 0; in ixgbe_xmit_xdp_ring()
8662 u16 i = 0, index = ring->next_to_use; in ixgbe_xmit_xdp_ring()
8663 struct ixgbe_tx_buffer *tx_head = &ring->tx_buffer_info[index]; in ixgbe_xmit_xdp_ring()
8666 u32 cmd_type, len = xdpf->len; in ixgbe_xmit_xdp_ring()
8667 void *data = xdpf->data; in ixgbe_xmit_xdp_ring()
8672 tx_head->bytecount = xdp_get_frame_len(xdpf); in ixgbe_xmit_xdp_ring()
8673 tx_head->gso_segs = 1; in ixgbe_xmit_xdp_ring()
8674 tx_head->xdpf = xdpf; in ixgbe_xmit_xdp_ring()
8676 tx_desc->read.olinfo_status = in ixgbe_xmit_xdp_ring()
8677 cpu_to_le32(tx_head->bytecount << IXGBE_ADVTXD_PAYLEN_SHIFT); in ixgbe_xmit_xdp_ring()
8682 dma = dma_map_single(ring->dev, data, len, DMA_TO_DEVICE); in ixgbe_xmit_xdp_ring()
8683 if (dma_mapping_error(ring->dev, dma)) in ixgbe_xmit_xdp_ring()
8691 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type); in ixgbe_xmit_xdp_ring()
8692 tx_desc->read.buffer_addr = cpu_to_le64(dma); in ixgbe_xmit_xdp_ring()
8693 tx_buff->protocol = 0; in ixgbe_xmit_xdp_ring()
8695 if (++index == ring->count) in ixgbe_xmit_xdp_ring()
8701 tx_buff = &ring->tx_buffer_info[index]; in ixgbe_xmit_xdp_ring()
8703 tx_desc->read.olinfo_status = 0; in ixgbe_xmit_xdp_ring()
8705 data = skb_frag_address(&sinfo->frags[i]); in ixgbe_xmit_xdp_ring()
8706 len = skb_frag_size(&sinfo->frags[i]); in ixgbe_xmit_xdp_ring()
8710 tx_desc->read.cmd_type_len |= cpu_to_le32(IXGBE_TXD_CMD); in ixgbe_xmit_xdp_ring()
8715 tx_head->next_to_watch = tx_desc; in ixgbe_xmit_xdp_ring()
8716 ring->next_to_use = index; in ixgbe_xmit_xdp_ring()
8722 tx_buff = &ring->tx_buffer_info[index]; in ixgbe_xmit_xdp_ring()
8724 dma_unmap_page(ring->dev, dma_unmap_addr(tx_buff, dma), in ixgbe_xmit_xdp_ring()
8732 index += ring->count; in ixgbe_xmit_xdp_ring()
8733 index--; in ixgbe_xmit_xdp_ring()
8749 __be16 protocol = skb->protocol; in ixgbe_xmit_frame_ring()
8759 for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) in ixgbe_xmit_frame_ring()
8761 &skb_shinfo(skb)->frags[f])); in ixgbe_xmit_frame_ring()
8764 tx_ring->tx_stats.tx_busy++; in ixgbe_xmit_frame_ring()
8769 first = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; in ixgbe_xmit_frame_ring()
8770 first->skb = skb; in ixgbe_xmit_frame_ring()
8771 first->bytecount = skb->len; in ixgbe_xmit_frame_ring()
8772 first->gso_segs = 1; in ixgbe_xmit_frame_ring()
8785 tx_flags |= ntohs(vhdr->h_vlan_TCI) << in ixgbe_xmit_frame_ring()
8791 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && in ixgbe_xmit_frame_ring()
8792 adapter->ptp_clock) { in ixgbe_xmit_frame_ring()
8793 if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON && in ixgbe_xmit_frame_ring()
8795 &adapter->state)) { in ixgbe_xmit_frame_ring()
8796 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in ixgbe_xmit_frame_ring()
8800 adapter->ptp_tx_skb = skb_get(skb); in ixgbe_xmit_frame_ring()
8801 adapter->ptp_tx_start = jiffies; in ixgbe_xmit_frame_ring()
8802 schedule_work(&adapter->ptp_tx_work); in ixgbe_xmit_frame_ring()
8804 adapter->tx_hwtstamp_skipped++; in ixgbe_xmit_frame_ring()
8810 * Use the l2switch_enable flag - would be false if the DMA in ixgbe_xmit_frame_ring()
8813 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_xmit_frame_ring()
8817 /* DCB maps skb priorities 0-7 onto 3 bit PCP of VLAN tag. */ in ixgbe_xmit_frame_ring()
8818 if ((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && in ixgbe_xmit_frame_ring()
8820 (skb->priority != TC_PRIO_CONTROL))) { in ixgbe_xmit_frame_ring()
8822 tx_flags |= (skb->priority & 0x7) << in ixgbe_xmit_frame_ring()
8830 vhdr->h_vlan_TCI = htons(tx_flags >> in ixgbe_xmit_frame_ring()
8838 first->tx_flags = tx_flags; in ixgbe_xmit_frame_ring()
8839 first->protocol = protocol; in ixgbe_xmit_frame_ring()
8844 (tx_ring->netdev->features & (NETIF_F_FSO | NETIF_F_FCOE_CRC))) { in ixgbe_xmit_frame_ring()
8866 if (test_bit(__IXGBE_TX_FDIR_INIT_DONE, &tx_ring->state)) in ixgbe_xmit_frame_ring()
8878 dev_kfree_skb_any(first->skb); in ixgbe_xmit_frame_ring()
8879 first->skb = NULL; in ixgbe_xmit_frame_ring()
8882 dev_kfree_skb_any(adapter->ptp_tx_skb); in ixgbe_xmit_frame_ring()
8883 adapter->ptp_tx_skb = NULL; in ixgbe_xmit_frame_ring()
8884 cancel_work_sync(&adapter->ptp_tx_work); in ixgbe_xmit_frame_ring()
8885 clear_bit_unlock(__IXGBE_PTP_TX_IN_PROGRESS, &adapter->state); in ixgbe_xmit_frame_ring()
8905 tx_ring = ring ? ring : adapter->tx_ring[skb_get_queue_mapping(skb)]; in __ixgbe_xmit_frame()
8906 if (unlikely(test_bit(__IXGBE_TX_DISABLED, &tx_ring->state))) in __ixgbe_xmit_frame()
8919 * ixgbe_set_mac - Change the Ethernet Address of the NIC
8928 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_mac()
8931 if (!is_valid_ether_addr(addr->sa_data)) in ixgbe_set_mac()
8932 return -EADDRNOTAVAIL; in ixgbe_set_mac()
8934 eth_hw_addr_set(netdev, addr->sa_data); in ixgbe_set_mac()
8935 memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len); in ixgbe_set_mac()
8946 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_mdio_read()
8950 if (adapter->mii_bus) { in ixgbe_mdio_read()
8954 return mdiobus_c45_read(adapter->mii_bus, prtad, in ixgbe_mdio_read()
8957 return mdiobus_read(adapter->mii_bus, prtad, regnum); in ixgbe_mdio_read()
8960 if (prtad != hw->phy.mdio.prtad) in ixgbe_mdio_read()
8961 return -EINVAL; in ixgbe_mdio_read()
8962 rc = hw->phy.ops.read_reg(hw, addr, devad, &value); in ixgbe_mdio_read()
8972 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_mdio_write()
8974 if (adapter->mii_bus) { in ixgbe_mdio_write()
8978 return mdiobus_c45_write(adapter->mii_bus, prtad, devad, in ixgbe_mdio_write()
8981 return mdiobus_write(adapter->mii_bus, prtad, regnum, value); in ixgbe_mdio_write()
8984 if (prtad != hw->phy.mdio.prtad) in ixgbe_mdio_write()
8985 return -EINVAL; in ixgbe_mdio_write()
8986 return hw->phy.ops.write_reg(hw, addr, devad, value); in ixgbe_mdio_write()
8999 if (!adapter->hw.phy.ops.read_reg) in ixgbe_ioctl()
9000 return -EOPNOTSUPP; in ixgbe_ioctl()
9003 return mdio_mii_ioctl(&adapter->hw.phy.mdio, if_mii(req), cmd); in ixgbe_ioctl()
9008 * ixgbe_add_sanmac_netdev - Add the SAN MAC address to the corresponding
9009 * netdev->dev_addrs
9012 * Returns non-zero on failure
9018 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_add_sanmac_netdev()
9020 if (is_valid_ether_addr(hw->mac.san_addr)) { in ixgbe_add_sanmac_netdev()
9022 err = dev_addr_add(dev, hw->mac.san_addr, NETDEV_HW_ADDR_T_SAN); in ixgbe_add_sanmac_netdev()
9026 hw->mac.ops.set_vmdq_san_mac(hw, VMDQ_P(0)); in ixgbe_add_sanmac_netdev()
9032 * ixgbe_del_sanmac_netdev - Removes the SAN MAC address to the corresponding
9033 * netdev->dev_addrs
9036 * Returns non-zero on failure
9042 struct ixgbe_mac_info *mac = &adapter->hw.mac; in ixgbe_del_sanmac_netdev()
9044 if (is_valid_ether_addr(mac->san_addr)) { in ixgbe_del_sanmac_netdev()
9046 err = dev_addr_del(dev, mac->san_addr, NETDEV_HW_ADDR_T_SAN); in ixgbe_del_sanmac_netdev()
9060 start = u64_stats_fetch_begin(&ring->syncp); in ixgbe_get_ring_stats64()
9061 packets = ring->stats.packets; in ixgbe_get_ring_stats64()
9062 bytes = ring->stats.bytes; in ixgbe_get_ring_stats64()
9063 } while (u64_stats_fetch_retry(&ring->syncp, start)); in ixgbe_get_ring_stats64()
9064 stats->tx_packets += packets; in ixgbe_get_ring_stats64()
9065 stats->tx_bytes += bytes; in ixgbe_get_ring_stats64()
9076 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_get_stats64()
9077 struct ixgbe_ring *ring = READ_ONCE(adapter->rx_ring[i]); in ixgbe_get_stats64()
9083 start = u64_stats_fetch_begin(&ring->syncp); in ixgbe_get_stats64()
9084 packets = ring->stats.packets; in ixgbe_get_stats64()
9085 bytes = ring->stats.bytes; in ixgbe_get_stats64()
9086 } while (u64_stats_fetch_retry(&ring->syncp, start)); in ixgbe_get_stats64()
9087 stats->rx_packets += packets; in ixgbe_get_stats64()
9088 stats->rx_bytes += bytes; in ixgbe_get_stats64()
9092 for (i = 0; i < adapter->num_tx_queues; i++) { in ixgbe_get_stats64()
9093 struct ixgbe_ring *ring = READ_ONCE(adapter->tx_ring[i]); in ixgbe_get_stats64()
9097 for (i = 0; i < adapter->num_xdp_queues; i++) { in ixgbe_get_stats64()
9098 struct ixgbe_ring *ring = READ_ONCE(adapter->xdp_ring[i]); in ixgbe_get_stats64()
9105 stats->multicast = netdev->stats.multicast; in ixgbe_get_stats64()
9106 stats->rx_errors = netdev->stats.rx_errors; in ixgbe_get_stats64()
9107 stats->rx_length_errors = netdev->stats.rx_length_errors; in ixgbe_get_stats64()
9108 stats->rx_crc_errors = netdev->stats.rx_crc_errors; in ixgbe_get_stats64()
9109 stats->rx_missed_errors = netdev->stats.rx_missed_errors; in ixgbe_get_stats64()
9117 if (vf < 0 || vf >= adapter->num_vfs) in ixgbe_ndo_get_vf_stats()
9118 return -EINVAL; in ixgbe_ndo_get_vf_stats()
9120 vf_stats->rx_packets = adapter->vfinfo[vf].vfstats.gprc; in ixgbe_ndo_get_vf_stats()
9121 vf_stats->rx_bytes = adapter->vfinfo[vf].vfstats.gorc; in ixgbe_ndo_get_vf_stats()
9122 vf_stats->tx_packets = adapter->vfinfo[vf].vfstats.gptc; in ixgbe_ndo_get_vf_stats()
9123 vf_stats->tx_bytes = adapter->vfinfo[vf].vfstats.gotc; in ixgbe_ndo_get_vf_stats()
9124 vf_stats->multicast = adapter->vfinfo[vf].vfstats.mprc; in ixgbe_ndo_get_vf_stats()
9131 * ixgbe_validate_rtr - verify 802.1Qp to Rx packet buffer mapping is valid.
9140 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_validate_rtr()
9147 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_validate_rtr()
9168 * ixgbe_set_prio_tc_map - Configure netdev prio tc map
9175 struct net_device *dev = adapter->netdev; in ixgbe_set_prio_tc_map()
9176 struct ixgbe_dcb_config *dcb_cfg = &adapter->dcb_cfg; in ixgbe_set_prio_tc_map()
9177 struct ieee_ets *ets = adapter->ixgbe_ieee_ets; in ixgbe_set_prio_tc_map()
9183 if (adapter->dcbx_cap & DCB_CAP_DCBX_VER_CEE) in ixgbe_set_prio_tc_map()
9186 tc = ets->prio_tc[prio]; in ixgbe_set_prio_tc_map()
9196 struct ixgbe_adapter *adapter = (struct ixgbe_adapter *)priv->data; in ixgbe_reassign_macvlan_pool()
9210 pool = find_first_zero_bit(adapter->fwd_bitmask, adapter->num_rx_pools); in ixgbe_reassign_macvlan_pool()
9211 if (pool < adapter->num_rx_pools) { in ixgbe_reassign_macvlan_pool()
9212 set_bit(pool, adapter->fwd_bitmask); in ixgbe_reassign_macvlan_pool()
9213 accel->pool = pool; in ixgbe_reassign_macvlan_pool()
9222 netdev_unbind_sb_channel(adapter->netdev, vdev); in ixgbe_reassign_macvlan_pool()
9238 bitmap_clear(adapter->fwd_bitmask, 1, 63); in ixgbe_defrag_macvlan_pools()
9246 * ixgbe_setup_tc - configure net_device for multiple traffic classes
9254 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_setup_tc()
9257 if (tc > adapter->dcb_cfg.num_tcs.pg_tcs) in ixgbe_setup_tc()
9258 return -EINVAL; in ixgbe_setup_tc()
9260 if (hw->mac.type == ixgbe_mac_82598EB && tc && tc < MAX_TRAFFIC_CLASS) in ixgbe_setup_tc()
9261 return -EINVAL; in ixgbe_setup_tc()
9276 if (adapter->xdp_prog) { in ixgbe_setup_tc()
9282 return -EINVAL; in ixgbe_setup_tc()
9288 adapter->hw_tcs = tc; in ixgbe_setup_tc()
9289 adapter->flags |= IXGBE_FLAG_DCB_ENABLED; in ixgbe_setup_tc()
9291 if (adapter->hw.mac.type == ixgbe_mac_82598EB) { in ixgbe_setup_tc()
9292 adapter->last_lfc_mode = adapter->hw.fc.requested_mode; in ixgbe_setup_tc()
9293 adapter->hw.fc.requested_mode = ixgbe_fc_none; in ixgbe_setup_tc()
9298 if (adapter->hw.mac.type == ixgbe_mac_82598EB) in ixgbe_setup_tc()
9299 adapter->hw.fc.requested_mode = adapter->last_lfc_mode; in ixgbe_setup_tc()
9301 adapter->flags &= ~IXGBE_FLAG_DCB_ENABLED; in ixgbe_setup_tc()
9302 adapter->hw_tcs = tc; in ixgbe_setup_tc()
9304 adapter->temp_dcb_cfg.pfc_mode_enable = false; in ixgbe_setup_tc()
9305 adapter->dcb_cfg.pfc_mode_enable = false; in ixgbe_setup_tc()
9324 u32 hdl = cls->knode.handle; in ixgbe_delete_clsu32()
9325 u32 uhtid = TC_U32_USERHTID(cls->knode.handle); in ixgbe_delete_clsu32()
9326 u32 loc = cls->knode.handle & 0xfffff; in ixgbe_delete_clsu32()
9331 return -EINVAL; in ixgbe_delete_clsu32()
9334 return -EINVAL; in ixgbe_delete_clsu32()
9338 jump = adapter->jump_tables[uhtid]; in ixgbe_delete_clsu32()
9340 return -EINVAL; in ixgbe_delete_clsu32()
9341 if (!test_bit(loc - 1, jump->child_loc_map)) in ixgbe_delete_clsu32()
9342 return -EINVAL; in ixgbe_delete_clsu32()
9343 clear_bit(loc - 1, jump->child_loc_map); in ixgbe_delete_clsu32()
9348 jump = adapter->jump_tables[i]; in ixgbe_delete_clsu32()
9349 if (jump && jump->link_hdl == hdl) { in ixgbe_delete_clsu32()
9354 if (!test_bit(j, jump->child_loc_map)) in ixgbe_delete_clsu32()
9356 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_delete_clsu32()
9360 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_delete_clsu32()
9361 clear_bit(j, jump->child_loc_map); in ixgbe_delete_clsu32()
9364 kfree(jump->input); in ixgbe_delete_clsu32()
9365 kfree(jump->mask); in ixgbe_delete_clsu32()
9367 adapter->jump_tables[i] = NULL; in ixgbe_delete_clsu32()
9372 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_delete_clsu32()
9374 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_delete_clsu32()
9381 u32 uhtid = TC_U32_USERHTID(cls->hnode.handle); in ixgbe_configure_clsu32_add_hnode()
9384 return -EINVAL; in ixgbe_configure_clsu32_add_hnode()
9389 if (cls->hnode.divisor > 0) in ixgbe_configure_clsu32_add_hnode()
9390 return -EINVAL; in ixgbe_configure_clsu32_add_hnode()
9392 set_bit(uhtid - 1, &adapter->tables); in ixgbe_configure_clsu32_add_hnode()
9399 u32 uhtid = TC_U32_USERHTID(cls->hnode.handle); in ixgbe_configure_clsu32_del_hnode()
9402 return -EINVAL; in ixgbe_configure_clsu32_del_hnode()
9404 clear_bit(uhtid - 1, &adapter->tables); in ixgbe_configure_clsu32_del_hnode()
9425 data = (struct upper_walk_data *)priv->data; in get_macvlan_queue()
9426 ifindex = data->ifindex; in get_macvlan_queue()
9427 adapter = data->adapter; in get_macvlan_queue()
9428 if (vadapter && upper->ifindex == ifindex) { in get_macvlan_queue()
9429 data->queue = adapter->rx_ring[vadapter->rx_base_queue]->reg_idx; in get_macvlan_queue()
9430 data->action = data->queue; in get_macvlan_queue()
9441 struct ixgbe_ring_feature *vmdq = &adapter->ring_feature[RING_F_VMDQ]; in handle_redirect_action()
9442 unsigned int num_vfs = adapter->num_vfs, vf; in handle_redirect_action()
9449 upper = pci_get_drvdata(adapter->vfinfo[vf].vfdev); in handle_redirect_action()
9450 if (upper->ifindex == ifindex) { in handle_redirect_action()
9451 *queue = vf * __ALIGN_MASK(1, ~vmdq->mask); in handle_redirect_action()
9464 if (netdev_walk_all_upper_dev_rcu(adapter->netdev, in handle_redirect_action()
9472 return -EINVAL; in handle_redirect_action()
9482 return -EINVAL; in parse_tc_actions()
9497 return -EINVAL; in parse_tc_actions()
9498 return handle_redirect_action(adapter, dev->ifindex, in parse_tc_actions()
9502 return -EINVAL; in parse_tc_actions()
9505 return -EINVAL; in parse_tc_actions()
9511 return -EINVAL; in parse_tc_actions()
9525 for (i = 0; i < cls->knode.sel->nkeys; i++) { in ixgbe_clsu32_build_input()
9526 off = cls->knode.sel->keys[i].off; in ixgbe_clsu32_build_input()
9527 val = cls->knode.sel->keys[i].val; in ixgbe_clsu32_build_input()
9528 m = cls->knode.sel->keys[i].mask; in ixgbe_clsu32_build_input()
9534 input->filter.formatted.flow_type |= in ixgbe_clsu32_build_input()
9541 if (nexthdr->off == cls->knode.sel->keys[i].off && in ixgbe_clsu32_build_input()
9542 nexthdr->val == in ixgbe_clsu32_build_input()
9543 (__force u32)cls->knode.sel->keys[i].val && in ixgbe_clsu32_build_input()
9544 nexthdr->mask == in ixgbe_clsu32_build_input()
9545 (__force u32)cls->knode.sel->keys[i].mask) in ixgbe_clsu32_build_input()
9553 return -EINVAL; in ixgbe_clsu32_build_input()
9558 mask->formatted.flow_type = IXGBE_ATR_L4TYPE_IPV6_MASK | in ixgbe_clsu32_build_input()
9561 if (input->filter.formatted.flow_type == IXGBE_ATR_FLOW_TYPE_IPV4) in ixgbe_clsu32_build_input()
9562 mask->formatted.flow_type &= IXGBE_ATR_L4TYPE_IPV6_MASK; in ixgbe_clsu32_build_input()
9570 __be16 protocol = cls->common.protocol; in ixgbe_configure_clsu32()
9571 u32 loc = cls->knode.handle & 0xfffff; in ixgbe_configure_clsu32()
9572 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_clsu32()
9577 int i, err = -EINVAL; in ixgbe_configure_clsu32()
9581 uhtid = TC_U32_USERHTID(cls->knode.handle); in ixgbe_configure_clsu32()
9582 link_uhtid = TC_U32_USERHTID(cls->knode.link_handle); in ixgbe_configure_clsu32()
9594 if (loc >= ((1024 << adapter->fdir_pballoc) - 2)) { in ixgbe_configure_clsu32()
9607 field_ptr = (adapter->jump_tables[0])->mat; in ixgbe_configure_clsu32()
9611 if (!adapter->jump_tables[uhtid]) in ixgbe_configure_clsu32()
9613 field_ptr = (adapter->jump_tables[uhtid])->mat; in ixgbe_configure_clsu32()
9631 if (!test_bit(link_uhtid - 1, &adapter->tables)) in ixgbe_configure_clsu32()
9639 if (adapter->jump_tables[link_uhtid] && in ixgbe_configure_clsu32()
9640 (adapter->jump_tables[link_uhtid])->link_hdl) { in ixgbe_configure_clsu32()
9647 if (nexthdr[i].o != cls->knode.sel->offoff || in ixgbe_configure_clsu32()
9648 nexthdr[i].s != cls->knode.sel->offshift || in ixgbe_configure_clsu32()
9650 (__force u32)cls->knode.sel->offmask) in ixgbe_configure_clsu32()
9655 return -ENOMEM; in ixgbe_configure_clsu32()
9658 err = -ENOMEM; in ixgbe_configure_clsu32()
9663 err = -ENOMEM; in ixgbe_configure_clsu32()
9666 jump->input = input; in ixgbe_configure_clsu32()
9667 jump->mask = mask; in ixgbe_configure_clsu32()
9668 jump->link_hdl = cls->knode.handle; in ixgbe_configure_clsu32()
9673 jump->mat = nexthdr[i].jump; in ixgbe_configure_clsu32()
9674 adapter->jump_tables[link_uhtid] = jump; in ixgbe_configure_clsu32()
9687 return -ENOMEM; in ixgbe_configure_clsu32()
9690 err = -ENOMEM; in ixgbe_configure_clsu32()
9694 if ((uhtid != 0x800) && (adapter->jump_tables[uhtid])) { in ixgbe_configure_clsu32()
9695 if ((adapter->jump_tables[uhtid])->input) in ixgbe_configure_clsu32()
9696 memcpy(input, (adapter->jump_tables[uhtid])->input, in ixgbe_configure_clsu32()
9698 if ((adapter->jump_tables[uhtid])->mask) in ixgbe_configure_clsu32()
9699 memcpy(mask, (adapter->jump_tables[uhtid])->mask, in ixgbe_configure_clsu32()
9706 struct ixgbe_jump_table *link = adapter->jump_tables[i]; in ixgbe_configure_clsu32()
9708 if (link && (test_bit(loc - 1, link->child_loc_map))) { in ixgbe_configure_clsu32()
9711 err = -EINVAL; in ixgbe_configure_clsu32()
9720 err = parse_tc_actions(adapter, cls->knode.exts, &input->action, in ixgbe_configure_clsu32()
9725 input->sw_idx = loc; in ixgbe_configure_clsu32()
9727 spin_lock(&adapter->fdir_perfect_lock); in ixgbe_configure_clsu32()
9729 if (hlist_empty(&adapter->fdir_filter_list)) { in ixgbe_configure_clsu32()
9730 memcpy(&adapter->fdir_mask, mask, sizeof(*mask)); in ixgbe_configure_clsu32()
9734 } else if (memcmp(&adapter->fdir_mask, mask, sizeof(*mask))) { in ixgbe_configure_clsu32()
9735 err = -EINVAL; in ixgbe_configure_clsu32()
9739 ixgbe_atr_compute_perfect_hash_82599(&input->filter, mask); in ixgbe_configure_clsu32()
9740 err = ixgbe_fdir_write_perfect_filter_82599(hw, &input->filter, in ixgbe_configure_clsu32()
9741 input->sw_idx, queue); in ixgbe_configure_clsu32()
9745 ixgbe_update_ethtool_fdir_entry(adapter, input, input->sw_idx); in ixgbe_configure_clsu32()
9746 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_configure_clsu32()
9748 if ((uhtid != 0x800) && (adapter->jump_tables[uhtid])) in ixgbe_configure_clsu32()
9749 set_bit(loc - 1, (adapter->jump_tables[uhtid])->child_loc_map); in ixgbe_configure_clsu32()
9754 spin_unlock(&adapter->fdir_perfect_lock); in ixgbe_configure_clsu32()
9767 switch (cls_u32->command) { in ixgbe_setup_tc_cls_u32()
9779 return -EOPNOTSUPP; in ixgbe_setup_tc_cls_u32()
9788 if (!tc_cls_can_offload_and_chain0(adapter->netdev, type_data)) in ixgbe_setup_tc_block_cb()
9789 return -EOPNOTSUPP; in ixgbe_setup_tc_block_cb()
9795 return -EOPNOTSUPP; in ixgbe_setup_tc_block_cb()
9802 mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS; in ixgbe_setup_tc_mqprio()
9803 return ixgbe_setup_tc(dev, mqprio->num_tc); in ixgbe_setup_tc_mqprio()
9822 return -EOPNOTSUPP; in __ixgbe_setup_tc()
9829 struct net_device *netdev = adapter->netdev; in ixgbe_sriov_reinit()
9832 ixgbe_setup_tc(netdev, adapter->hw_tcs); in ixgbe_sriov_reinit()
9857 if (!(adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)) in ixgbe_fix_features()
9860 if (adapter->xdp_prog && (features & NETIF_F_LRO)) { in ixgbe_fix_features()
9873 /* go back to full RSS if we're not running SR-IOV */ in ixgbe_reset_l2fw_offload()
9874 if (!adapter->ring_feature[RING_F_VMDQ].offset) in ixgbe_reset_l2fw_offload()
9875 adapter->flags &= ~(IXGBE_FLAG_VMDQ_ENABLED | in ixgbe_reset_l2fw_offload()
9878 adapter->ring_feature[RING_F_RSS].limit = rss; in ixgbe_reset_l2fw_offload()
9879 adapter->ring_feature[RING_F_VMDQ].limit = 1; in ixgbe_reset_l2fw_offload()
9881 ixgbe_setup_tc(adapter->netdev, adapter->hw_tcs); in ixgbe_reset_l2fw_offload()
9888 netdev_features_t changed = netdev->features ^ features; in ixgbe_set_features()
9893 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) in ixgbe_set_features()
9895 adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED; in ixgbe_set_features()
9896 } else if ((adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) && in ixgbe_set_features()
9897 !(adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)) { in ixgbe_set_features()
9898 if (adapter->rx_itr_setting == 1 || in ixgbe_set_features()
9899 adapter->rx_itr_setting > IXGBE_MIN_RSC_ITR) { in ixgbe_set_features()
9900 adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; in ixgbe_set_features()
9903 e_info(probe, "rx-usecs set too low, " in ixgbe_set_features()
9909 * Check if Flow Director n-tuple support or hw_tc support was in ixgbe_set_features()
9914 if (!(adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE)) in ixgbe_set_features()
9917 adapter->flags &= ~IXGBE_FLAG_FDIR_HASH_CAPABLE; in ixgbe_set_features()
9918 adapter->flags |= IXGBE_FLAG_FDIR_PERFECT_CAPABLE; in ixgbe_set_features()
9921 if (adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE) in ixgbe_set_features()
9924 adapter->flags &= ~IXGBE_FLAG_FDIR_PERFECT_CAPABLE; in ixgbe_set_features()
9926 /* We cannot enable ATR if SR-IOV is enabled */ in ixgbe_set_features()
9927 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED || in ixgbe_set_features()
9929 (adapter->hw_tcs > 1) || in ixgbe_set_features()
9931 (adapter->ring_feature[RING_F_RSS].limit <= 1) || in ixgbe_set_features()
9933 (!adapter->atr_sample_rate)) in ixgbe_set_features()
9936 adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE; in ixgbe_set_features()
9942 netdev->features = features; in ixgbe_set_features()
9944 if ((changed & NETIF_F_HW_L2FW_DOFFLOAD) && adapter->num_rx_pools > 1) in ixgbe_set_features()
9967 return -ENOMEM; in ixgbe_ndo_fdb_add()
9974 * ixgbe_configure_bridge_mode - set various bridge modes
9983 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_configure_bridge_mode()
9990 IXGBE_WRITE_REG(&adapter->hw, IXGBE_PFDTXGSWC, 0); in ixgbe_configure_bridge_mode()
10003 num_pools = adapter->num_vfs + adapter->num_rx_pools; in ixgbe_configure_bridge_mode()
10005 if (hw->mac.ops.set_source_address_pruning) in ixgbe_configure_bridge_mode()
10006 hw->mac.ops.set_source_address_pruning(hw, in ixgbe_configure_bridge_mode()
10013 IXGBE_WRITE_REG(&adapter->hw, IXGBE_PFDTXGSWC, in ixgbe_configure_bridge_mode()
10016 /* disable Rx switching replication unless we have SR-IOV in ixgbe_configure_bridge_mode()
10020 if (!adapter->num_vfs) in ixgbe_configure_bridge_mode()
10027 num_pools = adapter->num_vfs + adapter->num_rx_pools; in ixgbe_configure_bridge_mode()
10029 if (hw->mac.ops.set_source_address_pruning) in ixgbe_configure_bridge_mode()
10030 hw->mac.ops.set_source_address_pruning(hw, in ixgbe_configure_bridge_mode()
10036 return -EINVAL; in ixgbe_configure_bridge_mode()
10039 adapter->bridge_mode = mode; in ixgbe_configure_bridge_mode()
10055 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) in ixgbe_ndo_bridge_setlink()
10056 return -EOPNOTSUPP; in ixgbe_ndo_bridge_setlink()
10060 return -EINVAL; in ixgbe_ndo_bridge_setlink()
10081 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) in ixgbe_ndo_bridge_getlink()
10085 adapter->bridge_mode, 0, 0, nlflags, in ixgbe_ndo_bridge_getlink()
10093 int tcs = adapter->hw_tcs ? : 1; in ixgbe_fwd_add()
10096 if (adapter->xdp_prog) { in ixgbe_fwd_add()
10098 return ERR_PTR(-EINVAL); in ixgbe_fwd_add()
10106 return ERR_PTR(-EMEDIUMTYPE); in ixgbe_fwd_add()
10113 return ERR_PTR(-ERANGE); in ixgbe_fwd_add()
10115 pool = find_first_zero_bit(adapter->fwd_bitmask, adapter->num_rx_pools); in ixgbe_fwd_add()
10116 if (pool == adapter->num_rx_pools) { in ixgbe_fwd_add()
10117 u16 used_pools = adapter->num_vfs + adapter->num_rx_pools; in ixgbe_fwd_add()
10120 if (((adapter->flags & IXGBE_FLAG_DCB_ENABLED) && in ixgbe_fwd_add()
10121 adapter->num_rx_pools >= (MAX_TX_QUEUES / tcs)) || in ixgbe_fwd_add()
10122 adapter->num_rx_pools > IXGBE_MAX_MACVLANS) in ixgbe_fwd_add()
10123 return ERR_PTR(-EBUSY); in ixgbe_fwd_add()
10130 return ERR_PTR(-EBUSY); in ixgbe_fwd_add()
10133 adapter->flags |= IXGBE_FLAG_VMDQ_ENABLED | in ixgbe_fwd_add()
10140 if (used_pools < 32 && adapter->num_rx_pools < 16) in ixgbe_fwd_add()
10142 32 - used_pools, in ixgbe_fwd_add()
10143 16 - adapter->num_rx_pools); in ixgbe_fwd_add()
10144 else if (adapter->num_rx_pools < 32) in ixgbe_fwd_add()
10146 64 - used_pools, in ixgbe_fwd_add()
10147 32 - adapter->num_rx_pools); in ixgbe_fwd_add()
10149 reserved_pools = 64 - used_pools; in ixgbe_fwd_add()
10153 return ERR_PTR(-EBUSY); in ixgbe_fwd_add()
10155 adapter->ring_feature[RING_F_VMDQ].limit += reserved_pools; in ixgbe_fwd_add()
10158 err = ixgbe_setup_tc(pdev, adapter->hw_tcs); in ixgbe_fwd_add()
10162 if (pool >= adapter->num_rx_pools) in ixgbe_fwd_add()
10163 return ERR_PTR(-ENOMEM); in ixgbe_fwd_add()
10168 return ERR_PTR(-ENOMEM); in ixgbe_fwd_add()
10170 set_bit(pool, adapter->fwd_bitmask); in ixgbe_fwd_add()
10172 accel->pool = pool; in ixgbe_fwd_add()
10173 accel->netdev = vdev; in ixgbe_fwd_add()
10189 unsigned int rxbase = accel->rx_base_queue; in ixgbe_fwd_del()
10193 ixgbe_del_mac_filter(adapter, accel->netdev->dev_addr, in ixgbe_fwd_del()
10194 VMDQ_P(accel->pool)); in ixgbe_fwd_del()
10201 for (i = 0; i < adapter->num_rx_queues_per_pool; i++) { in ixgbe_fwd_del()
10202 struct ixgbe_ring *ring = adapter->rx_ring[rxbase + i]; in ixgbe_fwd_del()
10203 struct ixgbe_q_vector *qv = ring->q_vector; in ixgbe_fwd_del()
10208 if (netif_running(adapter->netdev)) in ixgbe_fwd_del()
10209 napi_synchronize(&qv->napi); in ixgbe_fwd_del()
10210 ring->netdev = NULL; in ixgbe_fwd_del()
10214 netdev_unbind_sb_channel(pdev, accel->netdev); in ixgbe_fwd_del()
10215 netdev_set_sb_channel(accel->netdev, 0); in ixgbe_fwd_del()
10217 clear_bit(accel->pool, adapter->fwd_bitmask); in ixgbe_fwd_del()
10240 network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb); in ixgbe_features_check()
10250 * IPsec offoad sets skb->encapsulation but still can handle in ixgbe_features_check()
10253 if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) { in ixgbe_features_check()
10265 int i, frame_size = dev->mtu + ETH_HLEN + ETH_FCS_LEN + VLAN_HLEN; in ixgbe_xdp_setup()
10271 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) in ixgbe_xdp_setup()
10272 return -EINVAL; in ixgbe_xdp_setup()
10274 if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) in ixgbe_xdp_setup()
10275 return -EINVAL; in ixgbe_xdp_setup()
10278 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_xdp_setup()
10279 struct ixgbe_ring *ring = adapter->rx_ring[i]; in ixgbe_xdp_setup()
10282 return -EINVAL; in ixgbe_xdp_setup()
10285 return -EINVAL; in ixgbe_xdp_setup()
10292 return -ENOMEM; in ixgbe_xdp_setup()
10294 old_prog = xchg(&adapter->xdp_prog, prog); in ixgbe_xdp_setup()
10304 err = ixgbe_setup_tc(dev, adapter->hw_tcs); in ixgbe_xdp_setup()
10307 return -EINVAL; in ixgbe_xdp_setup()
10311 for (i = 0; i < adapter->num_rx_queues; i++) { in ixgbe_xdp_setup()
10312 WRITE_ONCE(adapter->rx_ring[i]->xdp_prog, in ixgbe_xdp_setup()
10313 adapter->xdp_prog); in ixgbe_xdp_setup()
10324 num_queues = min_t(int, adapter->num_rx_queues, in ixgbe_xdp_setup()
10325 adapter->num_xdp_queues); in ixgbe_xdp_setup()
10327 if (adapter->xdp_ring[i]->xsk_pool) in ixgbe_xdp_setup()
10328 (void)ixgbe_xsk_wakeup(adapter->netdev, i, in ixgbe_xdp_setup()
10340 switch (xdp->command) { in ixgbe_xdp()
10342 return ixgbe_xdp_setup(dev, xdp->prog); in ixgbe_xdp()
10344 return ixgbe_xsk_pool_setup(adapter, xdp->xsk.pool, in ixgbe_xdp()
10345 xdp->xsk.queue_id); in ixgbe_xdp()
10348 return -EINVAL; in ixgbe_xdp()
10358 writel(ring->next_to_use, ring->tail); in ixgbe_xdp_ring_update_tail()
10364 spin_lock(&ring->tx_lock); in ixgbe_xdp_ring_update_tail_locked()
10367 spin_unlock(&ring->tx_lock); in ixgbe_xdp_ring_update_tail_locked()
10378 if (unlikely(test_bit(__IXGBE_DOWN, &adapter->state))) in ixgbe_xdp_xmit()
10379 return -ENETDOWN; in ixgbe_xdp_xmit()
10382 return -EINVAL; in ixgbe_xdp_xmit()
10384 /* During program transitions its possible adapter->xdp_prog is assigned in ixgbe_xdp_xmit()
10387 ring = adapter->xdp_prog ? ixgbe_determine_xdp_ring(adapter) : NULL; in ixgbe_xdp_xmit()
10389 return -ENXIO; in ixgbe_xdp_xmit()
10391 if (unlikely(test_bit(__IXGBE_TX_DISABLED, &ring->state))) in ixgbe_xdp_xmit()
10392 return -ENXIO; in ixgbe_xdp_xmit()
10395 spin_lock(&ring->tx_lock); in ixgbe_xdp_xmit()
10411 spin_unlock(&ring->tx_lock); in ixgbe_xdp_xmit()
10467 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_txr_hw()
10468 u8 reg_idx = tx_ring->reg_idx; in ixgbe_disable_txr_hw()
10480 while (wait_loop--) { in ixgbe_disable_txr_hw()
10495 set_bit(__IXGBE_TX_DISABLED, &tx_ring->state); in ixgbe_disable_txr()
10503 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_disable_rxr_hw()
10504 u8 reg_idx = rx_ring->reg_idx; in ixgbe_disable_rxr_hw()
10516 if (hw->mac.type == ixgbe_mac_82598EB && in ixgbe_disable_rxr_hw()
10526 while (wait_loop--) { in ixgbe_disable_rxr_hw()
10540 memset(&tx_ring->stats, 0, sizeof(tx_ring->stats)); in ixgbe_reset_txr_stats()
10541 memset(&tx_ring->tx_stats, 0, sizeof(tx_ring->tx_stats)); in ixgbe_reset_txr_stats()
10546 memset(&rx_ring->stats, 0, sizeof(rx_ring->stats)); in ixgbe_reset_rxr_stats()
10547 memset(&rx_ring->rx_stats, 0, sizeof(rx_ring->rx_stats)); in ixgbe_reset_rxr_stats()
10551 * ixgbe_irq_disable_single - Disable single IRQ vector
10557 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_irq_disable_single()
10561 switch (adapter->hw.mac.type) { in ixgbe_irq_disable_single()
10564 IXGBE_WRITE_REG(&adapter->hw, IXGBE_EIMC, mask); in ixgbe_irq_disable_single()
10581 IXGBE_WRITE_FLUSH(&adapter->hw); in ixgbe_irq_disable_single()
10582 if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) in ixgbe_irq_disable_single()
10583 synchronize_irq(adapter->msix_entries[ring].vector); in ixgbe_irq_disable_single()
10585 synchronize_irq(adapter->pdev->irq); in ixgbe_irq_disable_single()
10589 * ixgbe_txrx_ring_disable - Disable Rx/Tx/XDP Tx rings
10600 rx_ring = adapter->rx_ring[ring]; in ixgbe_txrx_ring_disable()
10601 tx_ring = adapter->tx_ring[ring]; in ixgbe_txrx_ring_disable()
10602 xdp_ring = adapter->xdp_ring[ring]; in ixgbe_txrx_ring_disable()
10607 napi_disable(&rx_ring->q_vector->napi); in ixgbe_txrx_ring_disable()
10629 * ixgbe_txrx_ring_enable - Enable Rx/Tx/XDP Tx rings
10640 rx_ring = adapter->rx_ring[ring]; in ixgbe_txrx_ring_enable()
10641 tx_ring = adapter->tx_ring[ring]; in ixgbe_txrx_ring_enable()
10642 xdp_ring = adapter->xdp_ring[ring]; in ixgbe_txrx_ring_enable()
10649 clear_bit(__IXGBE_TX_DISABLED, &tx_ring->state); in ixgbe_txrx_ring_enable()
10651 clear_bit(__IXGBE_TX_DISABLED, &xdp_ring->state); in ixgbe_txrx_ring_enable()
10654 napi_enable(&rx_ring->q_vector->napi); in ixgbe_txrx_ring_enable()
10656 IXGBE_WRITE_FLUSH(&adapter->hw); in ixgbe_txrx_ring_enable()
10660 * ixgbe_enumerate_functions - Get the number of ports this device has
10663 * This function enumerates the phsyical functions co-located on a single slot,
10670 struct pci_dev *entry, *pdev = adapter->pdev; in ixgbe_enumerate_functions()
10677 if (ixgbe_pcie_from_parent(&adapter->hw)) in ixgbe_enumerate_functions()
10680 list_for_each_entry(entry, &adapter->pdev->bus->devices, bus_list) { in ixgbe_enumerate_functions()
10682 if (entry->is_virtfn) in ixgbe_enumerate_functions()
10688 * attached to a virtual machine using VT-d, for example. In in ixgbe_enumerate_functions()
10689 * this case, simply return -1 to indicate this. in ixgbe_enumerate_functions()
10691 if ((entry->vendor != pdev->vendor) || in ixgbe_enumerate_functions()
10692 (entry->device != pdev->device)) in ixgbe_enumerate_functions()
10693 return -1; in ixgbe_enumerate_functions()
10702 * ixgbe_wol_supported - Check whether device supports WoL
10714 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_wol_supported()
10715 u16 wol_cap = adapter->eeprom_cap & IXGBE_DEVICE_CAPS_WOL_MASK; in ixgbe_wol_supported()
10718 if (hw->mac.type == ixgbe_mac_82598EB) in ixgbe_wol_supported()
10722 if (hw->mac.type >= ixgbe_mac_X540) { in ixgbe_wol_supported()
10725 (hw->bus.func == 0))) in ixgbe_wol_supported()
10739 if (hw->bus.func != 0) in ixgbe_wol_supported()
10774 * ixgbe_set_fw_version - Set FW version
10782 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_set_fw_version()
10787 snprintf(adapter->eeprom_id, sizeof(adapter->eeprom_id), in ixgbe_set_fw_version()
10797 snprintf(adapter->eeprom_id, sizeof(adapter->eeprom_id), in ixgbe_set_fw_version()
10804 snprintf(adapter->eeprom_id, sizeof(adapter->eeprom_id), in ixgbe_set_fw_version()
10809 * ixgbe_probe - Device Initialization Routine
10824 const struct ixgbe_info *ii = ixgbe_info_tbl[ent->driver_data]; in ixgbe_probe()
10835 * the PCIe SR-IOV capability. in ixgbe_probe()
10837 if (pdev->is_virtfn) { in ixgbe_probe()
10839 pci_name(pdev), pdev->vendor, pdev->device); in ixgbe_probe()
10840 return -EINVAL; in ixgbe_probe()
10847 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in ixgbe_probe()
10849 dev_err(&pdev->dev, in ixgbe_probe()
10856 dev_err(&pdev->dev, in ixgbe_probe()
10864 if (ii->mac == ixgbe_mac_82598EB) { in ixgbe_probe()
10875 err = -ENOMEM; in ixgbe_probe()
10879 SET_NETDEV_DEV(netdev, &pdev->dev); in ixgbe_probe()
10883 adapter->netdev = netdev; in ixgbe_probe()
10884 adapter->pdev = pdev; in ixgbe_probe()
10885 hw = &adapter->hw; in ixgbe_probe()
10886 hw->back = adapter; in ixgbe_probe()
10887 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); in ixgbe_probe()
10889 hw->hw_addr = ioremap(pci_resource_start(pdev, 0), in ixgbe_probe()
10891 adapter->io_addr = hw->hw_addr; in ixgbe_probe()
10892 if (!hw->hw_addr) { in ixgbe_probe()
10893 err = -EIO; in ixgbe_probe()
10897 netdev->netdev_ops = &ixgbe_netdev_ops; in ixgbe_probe()
10899 netdev->watchdog_timeo = 5 * HZ; in ixgbe_probe()
10900 strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name)); in ixgbe_probe()
10903 hw->mac.ops = *ii->mac_ops; in ixgbe_probe()
10904 hw->mac.type = ii->mac; in ixgbe_probe()
10905 hw->mvals = ii->mvals; in ixgbe_probe()
10906 if (ii->link_ops) in ixgbe_probe()
10907 hw->link.ops = *ii->link_ops; in ixgbe_probe()
10910 hw->eeprom.ops = *ii->eeprom_ops; in ixgbe_probe()
10912 if (ixgbe_removed(hw->hw_addr)) { in ixgbe_probe()
10913 err = -EIO; in ixgbe_probe()
10918 hw->eeprom.ops.read = &ixgbe_read_eeprom_bit_bang_generic; in ixgbe_probe()
10921 hw->phy.ops = *ii->phy_ops; in ixgbe_probe()
10922 hw->phy.sfp_type = ixgbe_sfp_type_unknown; in ixgbe_probe()
10924 hw->phy.mdio.prtad = MDIO_PRTAD_NONE; in ixgbe_probe()
10925 hw->phy.mdio.mmds = 0; in ixgbe_probe()
10926 hw->phy.mdio.mode_support = MDIO_SUPPORTS_C45 | MDIO_EMULATE_C22; in ixgbe_probe()
10927 hw->phy.mdio.dev = netdev; in ixgbe_probe()
10928 hw->phy.mdio.mdio_read = ixgbe_mdio_read; in ixgbe_probe()
10929 hw->phy.mdio.mdio_write = ixgbe_mdio_write; in ixgbe_probe()
10936 if (adapter->hw.mac.type == ixgbe_mac_82599EB) in ixgbe_probe()
10937 adapter->flags2 |= IXGBE_FLAG2_AUTO_DISABLE_VF; in ixgbe_probe()
10939 switch (adapter->hw.mac.type) { in ixgbe_probe()
10942 netdev->udp_tunnel_nic_info = &ixgbe_udp_tunnels_x550; in ixgbe_probe()
10945 netdev->udp_tunnel_nic_info = &ixgbe_udp_tunnels_x550em_a; in ixgbe_probe()
10952 if (hw->mac.ops.init_swfw_sync) in ixgbe_probe()
10953 hw->mac.ops.init_swfw_sync(hw); in ixgbe_probe()
10956 switch (adapter->hw.mac.type) { in ixgbe_probe()
10962 IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0); in ixgbe_probe()
10972 if (adapter->flags & IXGBE_FLAG_FAN_FAIL_CAPABLE) { in ixgbe_probe()
10979 hw->allow_unsupported_sfp = allow_unsupported_sfp; in ixgbe_probe()
10982 hw->phy.reset_if_overtemp = true; in ixgbe_probe()
10983 err = hw->mac.ops.reset_hw(hw); in ixgbe_probe()
10984 hw->phy.reset_if_overtemp = false; in ixgbe_probe()
10986 if (err == -ENOENT) { in ixgbe_probe()
10988 } else if (err == -EOPNOTSUPP) { in ixgbe_probe()
10998 /* SR-IOV not supported on the 82598 */ in ixgbe_probe()
10999 if (adapter->hw.mac.type == ixgbe_mac_82598EB) in ixgbe_probe()
11003 hw->mbx.ops = ii->mbx_ops; in ixgbe_probe()
11009 netdev->features = NETIF_F_SG | in ixgbe_probe()
11023 netdev->gso_partial_features = IXGBE_GSO_PARTIAL_FEATURES; in ixgbe_probe()
11024 netdev->features |= NETIF_F_GSO_PARTIAL | in ixgbe_probe()
11027 if (hw->mac.type >= ixgbe_mac_82599EB) in ixgbe_probe()
11028 netdev->features |= NETIF_F_SCTP_CRC | NETIF_F_GSO_UDP_L4; in ixgbe_probe()
11035 if (adapter->ipsec) in ixgbe_probe()
11036 netdev->features |= IXGBE_ESP_FEATURES; in ixgbe_probe()
11039 netdev->hw_features |= netdev->features | in ixgbe_probe()
11046 if (hw->mac.type >= ixgbe_mac_82599EB) in ixgbe_probe()
11047 netdev->hw_features |= NETIF_F_NTUPLE | in ixgbe_probe()
11050 netdev->features |= NETIF_F_HIGHDMA; in ixgbe_probe()
11052 netdev->vlan_features |= netdev->features | NETIF_F_TSO_MANGLEID; in ixgbe_probe()
11053 netdev->hw_enc_features |= netdev->vlan_features; in ixgbe_probe()
11054 netdev->mpls_features |= NETIF_F_SG | in ixgbe_probe()
11058 netdev->mpls_features |= IXGBE_GSO_PARTIAL_FEATURES; in ixgbe_probe()
11061 netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | in ixgbe_probe()
11065 netdev->priv_flags |= IFF_UNICAST_FLT; in ixgbe_probe()
11066 netdev->priv_flags |= IFF_SUPP_NOFCS; in ixgbe_probe()
11068 netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT | in ixgbe_probe()
11071 /* MTU range: 68 - 9710 */ in ixgbe_probe()
11072 netdev->min_mtu = ETH_MIN_MTU; in ixgbe_probe()
11073 netdev->max_mtu = IXGBE_MAX_JUMBO_FRAME_SIZE - (ETH_HLEN + ETH_FCS_LEN); in ixgbe_probe()
11076 if (adapter->flags & IXGBE_FLAG_DCB_CAPABLE) in ixgbe_probe()
11077 netdev->dcbnl_ops = &ixgbe_dcbnl_ops; in ixgbe_probe()
11081 if (adapter->flags & IXGBE_FLAG_FCOE_CAPABLE) { in ixgbe_probe()
11084 if (hw->mac.ops.get_device_caps) { in ixgbe_probe()
11085 hw->mac.ops.get_device_caps(hw, &device_caps); in ixgbe_probe()
11087 adapter->flags &= ~IXGBE_FLAG_FCOE_CAPABLE; in ixgbe_probe()
11092 adapter->ring_feature[RING_F_FCOE].limit = fcoe_l; in ixgbe_probe()
11094 netdev->features |= NETIF_F_FSO | in ixgbe_probe()
11097 netdev->vlan_features |= NETIF_F_FSO | in ixgbe_probe()
11101 if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE) in ixgbe_probe()
11102 netdev->hw_features |= NETIF_F_LRO; in ixgbe_probe()
11103 if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED) in ixgbe_probe()
11104 netdev->features |= NETIF_F_LRO; in ixgbe_probe()
11107 err = -EIO; in ixgbe_probe()
11112 if (hw->eeprom.ops.validate_checksum(hw, NULL) < 0) { in ixgbe_probe()
11114 err = -EIO; in ixgbe_probe()
11118 eth_platform_get_mac_address(&adapter->pdev->dev, in ixgbe_probe()
11119 adapter->hw.mac.perm_addr); in ixgbe_probe()
11121 eth_hw_addr_set(netdev, hw->mac.perm_addr); in ixgbe_probe()
11123 if (!is_valid_ether_addr(netdev->dev_addr)) { in ixgbe_probe()
11125 err = -EIO; in ixgbe_probe()
11129 /* Set hw->mac.addr to permanent MAC address */ in ixgbe_probe()
11130 ether_addr_copy(hw->mac.addr, hw->mac.perm_addr); in ixgbe_probe()
11133 timer_setup(&adapter->service_timer, ixgbe_service_timer, 0); in ixgbe_probe()
11135 if (ixgbe_removed(hw->hw_addr)) { in ixgbe_probe()
11136 err = -EIO; in ixgbe_probe()
11139 INIT_WORK(&adapter->service_task, ixgbe_service_task); in ixgbe_probe()
11140 set_bit(__IXGBE_SERVICE_INITED, &adapter->state); in ixgbe_probe()
11141 clear_bit(__IXGBE_SERVICE_SCHED, &adapter->state); in ixgbe_probe()
11147 for (i = 0; i < adapter->num_rx_queues; i++) in ixgbe_probe()
11148 u64_stats_init(&adapter->rx_ring[i]->syncp); in ixgbe_probe()
11149 for (i = 0; i < adapter->num_tx_queues; i++) in ixgbe_probe()
11150 u64_stats_init(&adapter->tx_ring[i]->syncp); in ixgbe_probe()
11151 for (i = 0; i < adapter->num_xdp_queues; i++) in ixgbe_probe()
11152 u64_stats_init(&adapter->xdp_ring[i]->syncp); in ixgbe_probe()
11155 adapter->wol = 0; in ixgbe_probe()
11156 hw->eeprom.ops.read(hw, 0x2c, &adapter->eeprom_cap); in ixgbe_probe()
11157 hw->wol_enabled = ixgbe_wol_supported(adapter, pdev->device, in ixgbe_probe()
11158 pdev->subsystem_device); in ixgbe_probe()
11159 if (hw->wol_enabled) in ixgbe_probe()
11160 adapter->wol = IXGBE_WUFC_MAG; in ixgbe_probe()
11162 device_set_wakeup_enable(&adapter->pdev->dev, adapter->wol); in ixgbe_probe()
11171 hw->mac.ops.get_bus_info(hw); in ixgbe_probe()
11178 switch (hw->mac.type) { in ixgbe_probe()
11194 if (ixgbe_is_sfp(hw) && hw->phy.sfp_type != ixgbe_sfp_type_not_present) in ixgbe_probe()
11196 hw->mac.type, hw->phy.type, hw->phy.sfp_type, in ixgbe_probe()
11200 hw->mac.type, hw->phy.type, part_str); in ixgbe_probe()
11202 e_dev_info("%pM\n", netdev->dev_addr); in ixgbe_probe()
11205 err = hw->mac.ops.start_hw(hw); in ixgbe_probe()
11206 if (err == -EACCES) { in ixgbe_probe()
11207 /* We are running on a pre-production device, log a warning */ in ixgbe_probe()
11208 e_dev_warn("This device is a pre-production adapter/LOM. " in ixgbe_probe()
11215 strcpy(netdev->name, "eth%d"); in ixgbe_probe()
11223 if (hw->mac.ops.disable_tx_laser) in ixgbe_probe()
11224 hw->mac.ops.disable_tx_laser(hw); in ixgbe_probe()
11230 if (dca_add_requester(&pdev->dev) == 0) { in ixgbe_probe()
11231 adapter->flags |= IXGBE_FLAG_DCA_ENABLED; in ixgbe_probe()
11235 if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { in ixgbe_probe()
11236 e_info(probe, "IOV is enabled with %d VFs\n", adapter->num_vfs); in ixgbe_probe()
11237 for (i = 0; i < adapter->num_vfs; i++) in ixgbe_probe()
11244 if (hw->mac.ops.set_fw_drv_ver) in ixgbe_probe()
11245 hw->mac.ops.set_fw_drv_ver(hw, 0xFF, 0xFF, 0xFF, 0xFF, in ixgbe_probe()
11246 sizeof(UTS_RELEASE) - 1, in ixgbe_probe()
11262 if (ixgbe_mng_enabled(hw) && ixgbe_is_sfp(hw) && hw->mac.ops.setup_link) in ixgbe_probe()
11263 hw->mac.ops.setup_link(hw, in ixgbe_probe()
11280 adapter->flags2 &= ~IXGBE_FLAG2_SEARCH_FOR_SFP; in ixgbe_probe()
11281 iounmap(adapter->io_addr); in ixgbe_probe()
11282 kfree(adapter->jump_tables[0]); in ixgbe_probe()
11283 kfree(adapter->mac_table); in ixgbe_probe()
11284 kfree(adapter->rss_key); in ixgbe_probe()
11285 bitmap_free(adapter->af_xdp_zc_qps); in ixgbe_probe()
11287 disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state); in ixgbe_probe()
11299 * ixgbe_remove - Device Removal Routine
11304 * Hot-Plug event, or because the driver is going to be removed from
11318 netdev = adapter->netdev; in ixgbe_remove()
11321 set_bit(__IXGBE_REMOVING, &adapter->state); in ixgbe_remove()
11322 cancel_work_sync(&adapter->service_task); in ixgbe_remove()
11324 if (adapter->mii_bus) in ixgbe_remove()
11325 mdiobus_unregister(adapter->mii_bus); in ixgbe_remove()
11328 if (adapter->flags & IXGBE_FLAG_DCA_ENABLED) { in ixgbe_remove()
11329 adapter->flags &= ~IXGBE_FLAG_DCA_ENABLED; in ixgbe_remove()
11330 dca_remove_requester(&pdev->dev); in ixgbe_remove()
11331 IXGBE_WRITE_REG(&adapter->hw, IXGBE_DCA_CTRL, in ixgbe_remove()
11346 if (netdev->reg_state == NETREG_REGISTERED) in ixgbe_remove()
11355 kfree(adapter->ixgbe_ieee_pfc); in ixgbe_remove()
11356 kfree(adapter->ixgbe_ieee_ets); in ixgbe_remove()
11359 iounmap(adapter->io_addr); in ixgbe_remove()
11365 if (adapter->jump_tables[i]) { in ixgbe_remove()
11366 kfree(adapter->jump_tables[i]->input); in ixgbe_remove()
11367 kfree(adapter->jump_tables[i]->mask); in ixgbe_remove()
11369 kfree(adapter->jump_tables[i]); in ixgbe_remove()
11372 kfree(adapter->mac_table); in ixgbe_remove()
11373 kfree(adapter->rss_key); in ixgbe_remove()
11374 bitmap_free(adapter->af_xdp_zc_qps); in ixgbe_remove()
11375 disable_dev = !test_and_set_bit(__IXGBE_DISABLED, &adapter->state); in ixgbe_remove()
11383 * ixgbe_io_error_detected - called when PCI error is detected
11394 struct net_device *netdev = adapter->netdev; in ixgbe_io_error_detected()
11397 struct ixgbe_hw *hw = &adapter->hw; in ixgbe_io_error_detected()
11403 if (adapter->hw.mac.type == ixgbe_mac_82598EB || in ixgbe_io_error_detected()
11404 adapter->num_vfs == 0) in ixgbe_io_error_detected()
11407 bdev = pdev->bus->self; in ixgbe_io_error_detected()
11409 bdev = bdev->bus->self; in ixgbe_io_error_detected()
11422 if (ixgbe_removed(hw->hw_addr)) in ixgbe_io_error_detected()
11431 if ((pf_func & 1) == (pdev->devfn & 1)) { in ixgbe_io_error_detected()
11439 switch (adapter->hw.mac.type) { in ixgbe_io_error_detected()
11463 if (vfdev->devfn == (req_id & 0xFF)) in ixgbe_io_error_detected()
11486 adapter->vferr_refcount++; in ixgbe_io_error_detected()
11492 if (!test_bit(__IXGBE_SERVICE_INITED, &adapter->state)) in ixgbe_io_error_detected()
11509 if (!test_and_set_bit(__IXGBE_DISABLED, &adapter->state)) in ixgbe_io_error_detected()
11518 * ixgbe_io_slot_reset - called after the pci bus has been reset.
11521 * Restart the card from scratch, as if from a cold-boot.
11529 e_err(probe, "Cannot re-enable PCI device after reset.\n"); in ixgbe_io_slot_reset()
11533 clear_bit(__IXGBE_DISABLED, &adapter->state); in ixgbe_io_slot_reset()
11534 adapter->hw.hw_addr = adapter->io_addr; in ixgbe_io_slot_reset()
11542 IXGBE_WRITE_REG(&adapter->hw, IXGBE_WUS, ~0); in ixgbe_io_slot_reset()
11550 * ixgbe_io_resume - called when traffic can start flowing again.
11559 struct net_device *netdev = adapter->netdev; in ixgbe_io_resume()
11562 if (adapter->vferr_refcount) { in ixgbe_io_resume()
11564 adapter->vferr_refcount--; in ixgbe_io_resume()
11597 * ixgbe_init_module - Driver Registration Routine
11611 return -ENOMEM; in ixgbe_init_module()
11633 * ixgbe_exit_module - Driver Exit Cleanup Routine