Lines Matching +full:vl +full:- +full:supply

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright(c) 2007 - 2018 Intel Corporation. */
57 "Copyright (c) 2007-2014 Intel Corporation.";
211 static int debug = -1;
256 /* igb_regdump - register printout routine */
263 switch (reginfo->ofs) { in igb_regdump()
313 pr_info("%-15s %08x\n", reginfo->name, rd32(reginfo->ofs)); in igb_regdump()
317 snprintf(rname, 16, "%s%s", reginfo->name, "[0-3]"); in igb_regdump()
318 pr_info("%-15s %08x %08x %08x %08x\n", rname, regs[0], regs[1], in igb_regdump()
322 /* igb_dump - Print registers, Tx-rings and Rx-rings */
325 struct net_device *netdev = adapter->netdev; in igb_dump()
326 struct e1000_hw *hw = &adapter->hw; in igb_dump()
341 dev_info(&adapter->pdev->dev, "Net device Info\n"); in igb_dump()
343 pr_info("%-15s %016lX %016lX\n", netdev->name, in igb_dump()
344 netdev->state, dev_trans_start(netdev)); in igb_dump()
348 dev_info(&adapter->pdev->dev, "Register Dump\n"); in igb_dump()
351 reginfo->name; reginfo++) { in igb_dump()
359 dev_info(&adapter->pdev->dev, "TX Rings Summary\n"); in igb_dump()
360 pr_info("Queue [NTU] [NTC] [bi(ntc)->dma ] leng ntw timestamp\n"); in igb_dump()
361 for (n = 0; n < adapter->num_tx_queues; n++) { in igb_dump()
363 tx_ring = adapter->tx_ring[n]; in igb_dump()
364 buffer_info = &tx_ring->tx_buffer_info[tx_ring->next_to_clean]; in igb_dump()
366 n, tx_ring->next_to_use, tx_ring->next_to_clean, in igb_dump()
369 buffer_info->next_to_watch, in igb_dump()
370 (u64)buffer_info->time_stamp); in igb_dump()
377 dev_info(&adapter->pdev->dev, "TX Rings Dump\n"); in igb_dump()
382 * +--------------------------------------------------------------+ in igb_dump()
384 * +--------------------------------------------------------------+ in igb_dump()
386 * +--------------------------------------------------------------+ in igb_dump()
390 for (n = 0; n < adapter->num_tx_queues; n++) { in igb_dump()
391 tx_ring = adapter->tx_ring[n]; in igb_dump()
392 pr_info("------------------------------------\n"); in igb_dump()
393 pr_info("TX QUEUE INDEX = %d\n", tx_ring->queue_index); in igb_dump()
394 pr_info("------------------------------------\n"); in igb_dump()
395 …fo("T [desc] [address 63:0 ] [PlPOCIStDDM Ln] [bi->dma ] leng ntw timestamp bi- in igb_dump()
397 for (i = 0; tx_ring->desc && (i < tx_ring->count); i++) { in igb_dump()
401 buffer_info = &tx_ring->tx_buffer_info[i]; in igb_dump()
403 if (i == tx_ring->next_to_use && in igb_dump()
404 i == tx_ring->next_to_clean) in igb_dump()
406 else if (i == tx_ring->next_to_use) in igb_dump()
408 else if (i == tx_ring->next_to_clean) in igb_dump()
414 i, le64_to_cpu(u0->a), in igb_dump()
415 le64_to_cpu(u0->b), in igb_dump()
418 buffer_info->next_to_watch, in igb_dump()
419 (u64)buffer_info->time_stamp, in igb_dump()
420 buffer_info->skb, next_desc); in igb_dump()
422 if (netif_msg_pktdata(adapter) && buffer_info->skb) in igb_dump()
425 16, 1, buffer_info->skb->data, in igb_dump()
433 dev_info(&adapter->pdev->dev, "RX Rings Summary\n"); in igb_dump()
435 for (n = 0; n < adapter->num_rx_queues; n++) { in igb_dump()
436 rx_ring = adapter->rx_ring[n]; in igb_dump()
438 n, rx_ring->next_to_use, rx_ring->next_to_clean); in igb_dump()
445 dev_info(&adapter->pdev->dev, "RX Rings Dump\n"); in igb_dump()
449 * +-----------------------------------------------------+ in igb_dump()
451 * +----------------------------------------------+------+ in igb_dump()
453 * +-----------------------------------------------------+ in igb_dump()
456 * Advanced Receive Descriptor (Write-Back) Format in igb_dump()
459 * +------------------------------------------------------+ in igb_dump()
462 * +------------------------------------------------------+ in igb_dump()
464 * +------------------------------------------------------+ in igb_dump()
468 for (n = 0; n < adapter->num_rx_queues; n++) { in igb_dump()
469 rx_ring = adapter->rx_ring[n]; in igb_dump()
470 pr_info("------------------------------------\n"); in igb_dump()
471 pr_info("RX QUEUE INDEX = %d\n", rx_ring->queue_index); in igb_dump()
472 pr_info("------------------------------------\n"); in igb_dump()
473 …pr_info("R [desc] [ PktBuf A0] [ HeadBuf DD] [bi->dma ] [bi->skb] <-- Adv Rx Re… in igb_dump()
474 …pr_info("RWB[desc] [PcsmIpSHl PtRs] [vl er S cks ln] ---------------- [bi->skb] <-- Adv Rx Wr… in igb_dump()
476 for (i = 0; i < rx_ring->count; i++) { in igb_dump()
479 buffer_info = &rx_ring->rx_buffer_info[i]; in igb_dump()
482 staterr = le32_to_cpu(rx_desc->wb.upper.status_error); in igb_dump()
484 if (i == rx_ring->next_to_use) in igb_dump()
486 else if (i == rx_ring->next_to_clean) in igb_dump()
493 pr_info("%s[0x%03X] %016llX %016llX ---------------- %s\n", in igb_dump()
495 le64_to_cpu(u0->a), in igb_dump()
496 le64_to_cpu(u0->b), in igb_dump()
501 le64_to_cpu(u0->a), in igb_dump()
502 le64_to_cpu(u0->b), in igb_dump()
503 (u64)buffer_info->dma, in igb_dump()
507 buffer_info->dma && buffer_info->page) { in igb_dump()
511 page_address(buffer_info->page) + in igb_dump()
512 buffer_info->page_offset, in igb_dump()
524 * igb_get_i2c_data - Reads the I2C SDA data bit
532 struct e1000_hw *hw = &adapter->hw; in igb_get_i2c_data()
539 * igb_set_i2c_data - Sets the I2C data bit
548 struct e1000_hw *hw = &adapter->hw; in igb_set_i2c_data()
563 * igb_set_i2c_clk - Sets the I2C SCL clock
572 struct e1000_hw *hw = &adapter->hw; in igb_set_i2c_clk()
586 * igb_get_i2c_clk - Gets the I2C SCL clock state
594 struct e1000_hw *hw = &adapter->hw; in igb_get_i2c_clk()
610 * igb_get_hw_dev - return device
617 struct igb_adapter *adapter = hw->back; in igb_get_hw_dev()
618 return adapter->netdev; in igb_get_hw_dev()
624 * igb_init_module - Driver Registration Routine
646 * igb_exit_module - Driver Exit Cleanup Routine
663 * igb_cache_ring_register - Descriptor ring to register mapping
666 * Once we know the feature-set enabled for the device, we'll cache
672 u32 rbase_offset = adapter->vfs_allocated_count; in igb_cache_ring_register()
674 switch (adapter->hw.mac.type) { in igb_cache_ring_register()
681 if (adapter->vfs_allocated_count) { in igb_cache_ring_register()
682 for (; i < adapter->rss_queues; i++) in igb_cache_ring_register()
683 adapter->rx_ring[i]->reg_idx = rbase_offset + in igb_cache_ring_register()
694 for (; i < adapter->num_rx_queues; i++) in igb_cache_ring_register()
695 adapter->rx_ring[i]->reg_idx = rbase_offset + i; in igb_cache_ring_register()
696 for (; j < adapter->num_tx_queues; j++) in igb_cache_ring_register()
697 adapter->tx_ring[j]->reg_idx = rbase_offset + j; in igb_cache_ring_register()
705 u8 __iomem *hw_addr = READ_ONCE(hw->hw_addr); in igb_rd32()
715 struct net_device *netdev = igb->netdev; in igb_rd32()
716 hw->hw_addr = NULL; in igb_rd32()
718 WARN(pci_device_is_present(igb->pdev), in igb_rd32()
726 * igb_write_ivar - configure ivar for given MSI-X vector
751 #define IGB_N0_QUEUE -1
754 struct igb_adapter *adapter = q_vector->adapter; in igb_assign_vector()
755 struct e1000_hw *hw = &adapter->hw; in igb_assign_vector()
760 if (q_vector->rx.ring) in igb_assign_vector()
761 rx_queue = q_vector->rx.ring->reg_idx; in igb_assign_vector()
762 if (q_vector->tx.ring) in igb_assign_vector()
763 tx_queue = q_vector->tx.ring->reg_idx; in igb_assign_vector()
765 switch (hw->mac.type) { in igb_assign_vector()
776 if (!(adapter->flags & IGB_FLAG_HAS_MSIX) && msix_vector == 0) in igb_assign_vector()
779 q_vector->eims_value = msixbm; in igb_assign_vector()
783 * with 8 rows. The ordering is column-major so we use the in igb_assign_vector()
795 q_vector->eims_value = BIT(msix_vector); in igb_assign_vector()
803 * however instead of ordering column-major we have things in igb_assign_vector()
804 * ordered row-major. So we traverse the table by using in igb_assign_vector()
816 q_vector->eims_value = BIT(msix_vector); in igb_assign_vector()
824 adapter->eims_enable_mask |= q_vector->eims_value; in igb_assign_vector()
827 q_vector->set_itr = 1; in igb_assign_vector()
831 * igb_configure_msix - Configure MSI-X hardware
835 * generate MSI-X interrupts.
841 struct e1000_hw *hw = &adapter->hw; in igb_configure_msix()
843 adapter->eims_enable_mask = 0; in igb_configure_msix()
846 switch (hw->mac.type) { in igb_configure_msix()
849 /* enable MSI-X PBA support*/ in igb_configure_msix()
852 /* Auto-Mask interrupts upon ICR read. */ in igb_configure_msix()
860 adapter->eims_other = E1000_EIMS_OTHER; in igb_configure_msix()
870 /* Turn on MSI-X capability first, or our settings in igb_configure_msix()
878 adapter->eims_other = BIT(vector); in igb_configure_msix()
884 /* do nothing, since nothing else supports MSI-X */ in igb_configure_msix()
886 } /* switch (hw->mac.type) */ in igb_configure_msix()
888 adapter->eims_enable_mask |= adapter->eims_other; in igb_configure_msix()
890 for (i = 0; i < adapter->num_q_vectors; i++) in igb_configure_msix()
891 igb_assign_vector(adapter->q_vector[i], vector++); in igb_configure_msix()
897 * igb_request_msix - Initialize MSI-X interrupts
900 * igb_request_msix allocates MSI-X vectors and requests interrupts from the
905 unsigned int num_q_vectors = adapter->num_q_vectors; in igb_request_msix()
906 struct net_device *netdev = adapter->netdev; in igb_request_msix()
909 err = request_irq(adapter->msix_entries[vector].vector, in igb_request_msix()
910 igb_msix_other, 0, netdev->name, adapter); in igb_request_msix()
916 dev_warn(&adapter->pdev->dev, in igb_request_msix()
918 adapter->num_q_vectors, MAX_Q_VECTORS); in igb_request_msix()
921 struct igb_q_vector *q_vector = adapter->q_vector[i]; in igb_request_msix()
925 q_vector->itr_register = adapter->io_addr + E1000_EITR(vector); in igb_request_msix()
927 if (q_vector->rx.ring && q_vector->tx.ring) in igb_request_msix()
928 sprintf(q_vector->name, "%s-TxRx-%u", netdev->name, in igb_request_msix()
929 q_vector->rx.ring->queue_index); in igb_request_msix()
930 else if (q_vector->tx.ring) in igb_request_msix()
931 sprintf(q_vector->name, "%s-tx-%u", netdev->name, in igb_request_msix()
932 q_vector->tx.ring->queue_index); in igb_request_msix()
933 else if (q_vector->rx.ring) in igb_request_msix()
934 sprintf(q_vector->name, "%s-rx-%u", netdev->name, in igb_request_msix()
935 q_vector->rx.ring->queue_index); in igb_request_msix()
937 sprintf(q_vector->name, "%s-unused", netdev->name); in igb_request_msix()
939 err = request_irq(adapter->msix_entries[vector].vector, in igb_request_msix()
940 igb_msix_ring, 0, q_vector->name, in igb_request_msix()
951 free_irq(adapter->msix_entries[free_vector++].vector, adapter); in igb_request_msix()
953 vector--; in igb_request_msix()
955 free_irq(adapter->msix_entries[free_vector++].vector, in igb_request_msix()
956 adapter->q_vector[i]); in igb_request_msix()
963 * igb_free_q_vector - Free memory allocated for specific interrupt vector
971 struct igb_q_vector *q_vector = adapter->q_vector[v_idx]; in igb_free_q_vector()
973 adapter->q_vector[v_idx] = NULL; in igb_free_q_vector()
983 * igb_reset_q_vector - Reset config for interrupt vector
992 struct igb_q_vector *q_vector = adapter->q_vector[v_idx]; in igb_reset_q_vector()
1000 if (q_vector->tx.ring) in igb_reset_q_vector()
1001 adapter->tx_ring[q_vector->tx.ring->queue_index] = NULL; in igb_reset_q_vector()
1003 if (q_vector->rx.ring) in igb_reset_q_vector()
1004 adapter->rx_ring[q_vector->rx.ring->queue_index] = NULL; in igb_reset_q_vector()
1006 netif_napi_del(&q_vector->napi); in igb_reset_q_vector()
1012 int v_idx = adapter->num_q_vectors; in igb_reset_interrupt_capability()
1014 if (adapter->flags & IGB_FLAG_HAS_MSIX) in igb_reset_interrupt_capability()
1015 pci_disable_msix(adapter->pdev); in igb_reset_interrupt_capability()
1016 else if (adapter->flags & IGB_FLAG_HAS_MSI) in igb_reset_interrupt_capability()
1017 pci_disable_msi(adapter->pdev); in igb_reset_interrupt_capability()
1019 while (v_idx--) in igb_reset_interrupt_capability()
1024 * igb_free_q_vectors - Free memory allocated for interrupt vectors
1033 int v_idx = adapter->num_q_vectors; in igb_free_q_vectors()
1035 adapter->num_tx_queues = 0; in igb_free_q_vectors()
1036 adapter->num_rx_queues = 0; in igb_free_q_vectors()
1037 adapter->num_q_vectors = 0; in igb_free_q_vectors()
1039 while (v_idx--) { in igb_free_q_vectors()
1046 * igb_clear_interrupt_scheme - reset the device to a state of no interrupts
1050 * MSI-X interrupts allocated.
1059 * igb_set_interrupt_capability - set MSI or MSI-X if supported
1073 adapter->flags |= IGB_FLAG_HAS_MSIX; in igb_set_interrupt_capability()
1076 adapter->num_rx_queues = adapter->rss_queues; in igb_set_interrupt_capability()
1077 if (adapter->vfs_allocated_count) in igb_set_interrupt_capability()
1078 adapter->num_tx_queues = 1; in igb_set_interrupt_capability()
1080 adapter->num_tx_queues = adapter->rss_queues; in igb_set_interrupt_capability()
1083 numvecs = adapter->num_rx_queues; in igb_set_interrupt_capability()
1086 if (!(adapter->flags & IGB_FLAG_QUEUE_PAIRS)) in igb_set_interrupt_capability()
1087 numvecs += adapter->num_tx_queues; in igb_set_interrupt_capability()
1090 adapter->num_q_vectors = numvecs; in igb_set_interrupt_capability()
1095 adapter->msix_entries[i].entry = i; in igb_set_interrupt_capability()
1097 err = pci_enable_msix_range(adapter->pdev, in igb_set_interrupt_capability()
1098 adapter->msix_entries, in igb_set_interrupt_capability()
1106 /* If we can't do MSI-X, try MSI */ in igb_set_interrupt_capability()
1108 adapter->flags &= ~IGB_FLAG_HAS_MSIX; in igb_set_interrupt_capability()
1110 /* disable SR-IOV for non MSI-X configurations */ in igb_set_interrupt_capability()
1111 if (adapter->vf_data) { in igb_set_interrupt_capability()
1112 struct e1000_hw *hw = &adapter->hw; in igb_set_interrupt_capability()
1114 pci_disable_sriov(adapter->pdev); in igb_set_interrupt_capability()
1117 kfree(adapter->vf_mac_list); in igb_set_interrupt_capability()
1118 adapter->vf_mac_list = NULL; in igb_set_interrupt_capability()
1119 kfree(adapter->vf_data); in igb_set_interrupt_capability()
1120 adapter->vf_data = NULL; in igb_set_interrupt_capability()
1124 dev_info(&adapter->pdev->dev, "IOV Disabled\n"); in igb_set_interrupt_capability()
1127 adapter->vfs_allocated_count = 0; in igb_set_interrupt_capability()
1128 adapter->rss_queues = 1; in igb_set_interrupt_capability()
1129 adapter->flags |= IGB_FLAG_QUEUE_PAIRS; in igb_set_interrupt_capability()
1130 adapter->num_rx_queues = 1; in igb_set_interrupt_capability()
1131 adapter->num_tx_queues = 1; in igb_set_interrupt_capability()
1132 adapter->num_q_vectors = 1; in igb_set_interrupt_capability()
1133 if (!pci_enable_msi(adapter->pdev)) in igb_set_interrupt_capability()
1134 adapter->flags |= IGB_FLAG_HAS_MSI; in igb_set_interrupt_capability()
1140 head->ring = ring; in igb_add_ring()
1141 head->count++; in igb_add_ring()
1145 * igb_alloc_q_vector - Allocate memory for a single interrupt vector
1154 * We allocate one q_vector. If allocation fails we return -ENOMEM.
1168 return -ENOMEM; in igb_alloc_q_vector()
1174 q_vector = adapter->q_vector[v_idx]; in igb_alloc_q_vector()
1188 return -ENOMEM; in igb_alloc_q_vector()
1191 netif_napi_add(adapter->netdev, &q_vector->napi, igb_poll); in igb_alloc_q_vector()
1194 adapter->q_vector[v_idx] = q_vector; in igb_alloc_q_vector()
1195 q_vector->adapter = adapter; in igb_alloc_q_vector()
1198 q_vector->tx.work_limit = adapter->tx_work_limit; in igb_alloc_q_vector()
1201 q_vector->itr_register = adapter->io_addr + E1000_EITR(0); in igb_alloc_q_vector()
1202 q_vector->itr_val = IGB_START_ITR; in igb_alloc_q_vector()
1205 ring = q_vector->ring; in igb_alloc_q_vector()
1210 if (!adapter->rx_itr_setting || adapter->rx_itr_setting > 3) in igb_alloc_q_vector()
1211 q_vector->itr_val = adapter->rx_itr_setting; in igb_alloc_q_vector()
1214 if (!adapter->tx_itr_setting || adapter->tx_itr_setting > 3) in igb_alloc_q_vector()
1215 q_vector->itr_val = adapter->tx_itr_setting; in igb_alloc_q_vector()
1220 ring->dev = &adapter->pdev->dev; in igb_alloc_q_vector()
1221 ring->netdev = adapter->netdev; in igb_alloc_q_vector()
1224 ring->q_vector = q_vector; in igb_alloc_q_vector()
1227 igb_add_ring(ring, &q_vector->tx); in igb_alloc_q_vector()
1230 if (adapter->hw.mac.type == e1000_82575) in igb_alloc_q_vector()
1231 set_bit(IGB_RING_FLAG_TX_CTX_IDX, &ring->flags); in igb_alloc_q_vector()
1234 ring->count = adapter->tx_ring_count; in igb_alloc_q_vector()
1235 ring->queue_index = txr_idx; in igb_alloc_q_vector()
1237 ring->cbs_enable = false; in igb_alloc_q_vector()
1238 ring->idleslope = 0; in igb_alloc_q_vector()
1239 ring->sendslope = 0; in igb_alloc_q_vector()
1240 ring->hicredit = 0; in igb_alloc_q_vector()
1241 ring->locredit = 0; in igb_alloc_q_vector()
1243 u64_stats_init(&ring->tx_syncp); in igb_alloc_q_vector()
1244 u64_stats_init(&ring->tx_syncp2); in igb_alloc_q_vector()
1247 adapter->tx_ring[txr_idx] = ring; in igb_alloc_q_vector()
1255 ring->dev = &adapter->pdev->dev; in igb_alloc_q_vector()
1256 ring->netdev = adapter->netdev; in igb_alloc_q_vector()
1259 ring->q_vector = q_vector; in igb_alloc_q_vector()
1262 igb_add_ring(ring, &q_vector->rx); in igb_alloc_q_vector()
1265 if (adapter->hw.mac.type >= e1000_82576) in igb_alloc_q_vector()
1266 set_bit(IGB_RING_FLAG_RX_SCTP_CSUM, &ring->flags); in igb_alloc_q_vector()
1269 * have the tag byte-swapped. in igb_alloc_q_vector()
1271 if (adapter->hw.mac.type >= e1000_i350) in igb_alloc_q_vector()
1272 set_bit(IGB_RING_FLAG_RX_LB_VLAN_BSWAP, &ring->flags); in igb_alloc_q_vector()
1275 ring->count = adapter->rx_ring_count; in igb_alloc_q_vector()
1276 ring->queue_index = rxr_idx; in igb_alloc_q_vector()
1278 u64_stats_init(&ring->rx_syncp); in igb_alloc_q_vector()
1281 adapter->rx_ring[rxr_idx] = ring; in igb_alloc_q_vector()
1289 * igb_alloc_q_vectors - Allocate memory for interrupt vectors
1293 * return -ENOMEM.
1297 int q_vectors = adapter->num_q_vectors; in igb_alloc_q_vectors()
1298 int rxr_remaining = adapter->num_rx_queues; in igb_alloc_q_vectors()
1299 int txr_remaining = adapter->num_tx_queues; in igb_alloc_q_vectors()
1312 rxr_remaining--; in igb_alloc_q_vectors()
1318 int rqpv = DIV_ROUND_UP(rxr_remaining, q_vectors - v_idx); in igb_alloc_q_vectors()
1319 int tqpv = DIV_ROUND_UP(txr_remaining, q_vectors - v_idx); in igb_alloc_q_vectors()
1328 rxr_remaining -= rqpv; in igb_alloc_q_vectors()
1329 txr_remaining -= tqpv; in igb_alloc_q_vectors()
1337 adapter->num_tx_queues = 0; in igb_alloc_q_vectors()
1338 adapter->num_rx_queues = 0; in igb_alloc_q_vectors()
1339 adapter->num_q_vectors = 0; in igb_alloc_q_vectors()
1341 while (v_idx--) in igb_alloc_q_vectors()
1344 return -ENOMEM; in igb_alloc_q_vectors()
1348 * igb_init_interrupt_scheme - initialize interrupts, allocate queues/vectors
1356 struct pci_dev *pdev = adapter->pdev; in igb_init_interrupt_scheme()
1363 dev_err(&pdev->dev, "Unable to allocate memory for vectors\n"); in igb_init_interrupt_scheme()
1377 * igb_request_irq - initialize interrupts
1385 struct net_device *netdev = adapter->netdev; in igb_request_irq()
1386 struct pci_dev *pdev = adapter->pdev; in igb_request_irq()
1389 if (adapter->flags & IGB_FLAG_HAS_MSIX) { in igb_request_irq()
1407 igb_assign_vector(adapter->q_vector[0], 0); in igb_request_irq()
1409 if (adapter->flags & IGB_FLAG_HAS_MSI) { in igb_request_irq()
1410 err = request_irq(pdev->irq, igb_intr_msi, 0, in igb_request_irq()
1411 netdev->name, adapter); in igb_request_irq()
1417 adapter->flags &= ~IGB_FLAG_HAS_MSI; in igb_request_irq()
1420 err = request_irq(pdev->irq, igb_intr, IRQF_SHARED, in igb_request_irq()
1421 netdev->name, adapter); in igb_request_irq()
1424 dev_err(&pdev->dev, "Error %d getting interrupt\n", in igb_request_irq()
1433 if (adapter->flags & IGB_FLAG_HAS_MSIX) { in igb_free_irq()
1436 free_irq(adapter->msix_entries[vector++].vector, adapter); in igb_free_irq()
1438 for (i = 0; i < adapter->num_q_vectors; i++) in igb_free_irq()
1439 free_irq(adapter->msix_entries[vector++].vector, in igb_free_irq()
1440 adapter->q_vector[i]); in igb_free_irq()
1442 free_irq(adapter->pdev->irq, adapter); in igb_free_irq()
1447 * igb_irq_disable - Mask off interrupt generation on the NIC
1452 struct e1000_hw *hw = &adapter->hw; in igb_irq_disable()
1458 if (adapter->flags & IGB_FLAG_HAS_MSIX) { in igb_irq_disable()
1461 wr32(E1000_EIAM, regval & ~adapter->eims_enable_mask); in igb_irq_disable()
1462 wr32(E1000_EIMC, adapter->eims_enable_mask); in igb_irq_disable()
1464 wr32(E1000_EIAC, regval & ~adapter->eims_enable_mask); in igb_irq_disable()
1470 if (adapter->flags & IGB_FLAG_HAS_MSIX) { in igb_irq_disable()
1473 for (i = 0; i < adapter->num_q_vectors; i++) in igb_irq_disable()
1474 synchronize_irq(adapter->msix_entries[i].vector); in igb_irq_disable()
1476 synchronize_irq(adapter->pdev->irq); in igb_irq_disable()
1481 * igb_irq_enable - Enable default interrupt generation settings
1486 struct e1000_hw *hw = &adapter->hw; in igb_irq_enable()
1488 if (adapter->flags & IGB_FLAG_HAS_MSIX) { in igb_irq_enable()
1492 wr32(E1000_EIAC, regval | adapter->eims_enable_mask); in igb_irq_enable()
1494 wr32(E1000_EIAM, regval | adapter->eims_enable_mask); in igb_irq_enable()
1495 wr32(E1000_EIMS, adapter->eims_enable_mask); in igb_irq_enable()
1496 if (adapter->vfs_allocated_count) { in igb_irq_enable()
1511 struct e1000_hw *hw = &adapter->hw; in igb_update_mng_vlan()
1512 u16 pf_id = adapter->vfs_allocated_count; in igb_update_mng_vlan()
1513 u16 vid = adapter->hw.mng_cookie.vlan_id; in igb_update_mng_vlan()
1514 u16 old_vid = adapter->mng_vlan_id; in igb_update_mng_vlan()
1516 if (hw->mng_cookie.status & E1000_MNG_DHCP_COOKIE_STATUS_VLAN) { in igb_update_mng_vlan()
1519 adapter->mng_vlan_id = vid; in igb_update_mng_vlan()
1521 adapter->mng_vlan_id = IGB_MNG_VLAN_NONE; in igb_update_mng_vlan()
1526 !test_bit(old_vid, adapter->active_vlans)) { in igb_update_mng_vlan()
1533 * igb_release_hw_control - release control of the h/w to f/w
1542 struct e1000_hw *hw = &adapter->hw; in igb_release_hw_control()
1552 * igb_get_hw_control - get control of the h/w from f/w
1561 struct e1000_hw *hw = &adapter->hw; in igb_get_hw_control()
1572 struct net_device *netdev = adapter->netdev; in enable_fqtss()
1573 struct e1000_hw *hw = &adapter->hw; in enable_fqtss()
1575 WARN_ON(hw->mac.type != e1000_i210); in enable_fqtss()
1578 adapter->flags |= IGB_FLAG_FQTSS; in enable_fqtss()
1580 adapter->flags &= ~IGB_FLAG_FQTSS; in enable_fqtss()
1583 schedule_work(&adapter->reset_task); in enable_fqtss()
1588 return (adapter->flags & IGB_FLAG_FQTSS) ? true : false; in is_fqtss_enabled()
1596 WARN_ON(hw->mac.type != e1000_i210); in set_tx_desc_fetch_prio()
1613 WARN_ON(hw->mac.type != e1000_i210); in set_queue_mode()
1630 for (i = 0; i < adapter->num_tx_queues; i++) { in is_any_cbs_enabled()
1631 if (adapter->tx_ring[i]->cbs_enable) in is_any_cbs_enabled()
1642 for (i = 0; i < adapter->num_tx_queues; i++) { in is_any_txtime_enabled()
1643 if (adapter->tx_ring[i]->launchtime_enable) in is_any_txtime_enabled()
1651 * igb_config_tx_modes - Configure "Qav Tx mode" features on igb
1662 struct net_device *netdev = adapter->netdev; in igb_config_tx_modes()
1663 struct e1000_hw *hw = &adapter->hw; in igb_config_tx_modes()
1668 WARN_ON(hw->mac.type != e1000_i210); in igb_config_tx_modes()
1670 ring = adapter->tx_ring[queue]; in igb_config_tx_modes()
1676 if (ring->cbs_enable || ring->launchtime_enable) { in igb_config_tx_modes()
1685 if (ring->cbs_enable || queue == 0) { in igb_config_tx_modes()
1695 if (queue == 0 && !ring->cbs_enable) { in igb_config_tx_modes()
1697 ring->idleslope = 1000000; in igb_config_tx_modes()
1698 ring->hicredit = ETH_FRAME_LEN; in igb_config_tx_modes()
1701 /* Always set data transfer arbitration to credit-based in igb_config_tx_modes()
1722 * Note that 'link-speed' is in Mbps. in igb_config_tx_modes()
1724 * value = BW * 0x7735 * 2 * link-speed in igb_config_tx_modes()
1725 * -------------- (E3) in igb_config_tx_modes()
1734 * ----------------- (E4) in igb_config_tx_modes()
1735 * link-speed * 1000 in igb_config_tx_modes()
1741 * value = idleSlope * 0x7735 * 2 * link-speed in igb_config_tx_modes()
1742 * ----------------- -------------- (E5) in igb_config_tx_modes()
1743 * link-speed * 1000 1000 in igb_config_tx_modes()
1745 * 'link-speed' is present in both sides of the fraction so in igb_config_tx_modes()
1749 * ----------------- (E6) in igb_config_tx_modes()
1766 value = DIV_ROUND_UP_ULL(ring->idleslope * 61034ULL, 1000000); in igb_config_tx_modes()
1774 0x80000000 + ring->hicredit * 0x7735); in igb_config_tx_modes()
1797 if (ring->launchtime_enable) { in igb_config_tx_modes()
1801 * - LaunchTime will be enabled for all SR queues. in igb_config_tx_modes()
1802 * - A fixed offset can be added relative to the launch in igb_config_tx_modes()
1829 ring->cbs_enable ? "enabled" : "disabled", in igb_config_tx_modes()
1830 ring->launchtime_enable ? "enabled" : "disabled", in igb_config_tx_modes()
1832 ring->idleslope, ring->sendslope, in igb_config_tx_modes()
1833 ring->hicredit, ring->locredit); in igb_config_tx_modes()
1841 if (queue < 0 || queue > adapter->num_tx_queues) in igb_save_txtime_params()
1842 return -EINVAL; in igb_save_txtime_params()
1844 ring = adapter->tx_ring[queue]; in igb_save_txtime_params()
1845 ring->launchtime_enable = enable; in igb_save_txtime_params()
1856 if (queue < 0 || queue > adapter->num_tx_queues) in igb_save_cbs_params()
1857 return -EINVAL; in igb_save_cbs_params()
1859 ring = adapter->tx_ring[queue]; in igb_save_cbs_params()
1861 ring->cbs_enable = enable; in igb_save_cbs_params()
1862 ring->idleslope = idleslope; in igb_save_cbs_params()
1863 ring->sendslope = sendslope; in igb_save_cbs_params()
1864 ring->hicredit = hicredit; in igb_save_cbs_params()
1865 ring->locredit = locredit; in igb_save_cbs_params()
1871 * igb_setup_tx_mode - Switch to/from Qav Tx mode when applicable
1881 struct net_device *netdev = adapter->netdev; in igb_setup_tx_mode()
1882 struct e1000_hw *hw = &adapter->hw; in igb_setup_tx_mode()
1886 if (hw->mac.type != e1000_i210) in igb_setup_tx_mode()
1924 * reason, we set MAX_ TPKT_SIZE to (4kB - 1) / 64. in igb_setup_tx_mode()
1926 val = (4096 - 1) / 64; in igb_setup_tx_mode()
1934 max_queue = (adapter->num_tx_queues < I210_SR_QUEUES_NUM) ? in igb_setup_tx_mode()
1935 adapter->num_tx_queues : I210_SR_QUEUES_NUM; in igb_setup_tx_mode()
1959 * igb_configure - configure the hardware for RX and TX
1964 struct net_device *netdev = adapter->netdev; in igb_configure()
1981 igb_rx_fifo_flush_82575(&adapter->hw); in igb_configure()
1987 for (i = 0; i < adapter->num_rx_queues; i++) { in igb_configure()
1988 struct igb_ring *ring = adapter->rx_ring[i]; in igb_configure()
1994 * igb_power_up_link - Power up the phy/serdes link
1999 igb_reset_phy(&adapter->hw); in igb_power_up_link()
2001 if (adapter->hw.phy.media_type == e1000_media_type_copper) in igb_power_up_link()
2002 igb_power_up_phy_copper(&adapter->hw); in igb_power_up_link()
2004 igb_power_up_serdes_link_82575(&adapter->hw); in igb_power_up_link()
2006 igb_setup_link(&adapter->hw); in igb_power_up_link()
2010 * igb_power_down_link - Power down the phy/serdes link
2015 if (adapter->hw.phy.media_type == e1000_media_type_copper) in igb_power_down_link()
2016 igb_power_down_phy_copper_82575(&adapter->hw); in igb_power_down_link()
2018 igb_shutdown_serdes_link_82575(&adapter->hw); in igb_power_down_link()
2022 * igb_check_swap_media - Detect and switch function for Media Auto Sense
2027 struct e1000_hw *hw = &adapter->hw; in igb_check_swap_media()
2038 if ((hw->phy.media_type == e1000_media_type_copper) && in igb_check_swap_media()
2041 } else if ((hw->phy.media_type != e1000_media_type_copper) && in igb_check_swap_media()
2044 if (adapter->copper_tries < 4) { in igb_check_swap_media()
2045 adapter->copper_tries++; in igb_check_swap_media()
2050 adapter->copper_tries = 0; in igb_check_swap_media()
2063 switch (hw->phy.media_type) { in igb_check_swap_media()
2065 netdev_info(adapter->netdev, in igb_check_swap_media()
2069 adapter->flags |= IGB_FLAG_MEDIA_RESET; in igb_check_swap_media()
2070 adapter->copper_tries = 0; in igb_check_swap_media()
2074 netdev_info(adapter->netdev, in igb_check_swap_media()
2078 adapter->flags |= IGB_FLAG_MEDIA_RESET; in igb_check_swap_media()
2082 netdev_err(adapter->netdev, in igb_check_swap_media()
2090 * igb_up - Open the interface and prepare it to handle traffic
2095 struct e1000_hw *hw = &adapter->hw; in igb_up()
2101 clear_bit(__IGB_DOWN, &adapter->state); in igb_up()
2103 for (i = 0; i < adapter->num_q_vectors; i++) in igb_up()
2104 napi_enable(&(adapter->q_vector[i]->napi)); in igb_up()
2106 if (adapter->flags & IGB_FLAG_HAS_MSIX) in igb_up()
2109 igb_assign_vector(adapter->q_vector[0], 0); in igb_up()
2117 if (adapter->vfs_allocated_count) { in igb_up()
2124 netif_tx_start_all_queues(adapter->netdev); in igb_up()
2127 hw->mac.get_link_status = 1; in igb_up()
2128 schedule_work(&adapter->watchdog_task); in igb_up()
2130 if ((adapter->flags & IGB_FLAG_EEE) && in igb_up()
2131 (!hw->dev_spec._82575.eee_disable)) in igb_up()
2132 adapter->eee_advert = MDIO_EEE_100TX | MDIO_EEE_1000T; in igb_up()
2139 struct net_device *netdev = adapter->netdev; in igb_down()
2140 struct e1000_hw *hw = &adapter->hw; in igb_down()
2147 set_bit(__IGB_DOWN, &adapter->state); in igb_down()
2169 adapter->flags &= ~IGB_FLAG_NEED_LINK_UPDATE; in igb_down()
2171 for (i = 0; i < adapter->num_q_vectors; i++) { in igb_down()
2172 if (adapter->q_vector[i]) { in igb_down()
2173 napi_synchronize(&adapter->q_vector[i]->napi); in igb_down()
2174 napi_disable(&adapter->q_vector[i]->napi); in igb_down()
2178 del_timer_sync(&adapter->watchdog_timer); in igb_down()
2179 del_timer_sync(&adapter->phy_info_timer); in igb_down()
2182 spin_lock(&adapter->stats64_lock); in igb_down()
2184 spin_unlock(&adapter->stats64_lock); in igb_down()
2186 adapter->link_speed = 0; in igb_down()
2187 adapter->link_duplex = 0; in igb_down()
2189 if (!pci_channel_offline(adapter->pdev)) in igb_down()
2193 adapter->flags &= ~IGB_FLAG_VLAN_PROMISC; in igb_down()
2206 while (test_and_set_bit(__IGB_RESETTING, &adapter->state)) in igb_reinit_locked()
2210 clear_bit(__IGB_RESETTING, &adapter->state); in igb_reinit_locked()
2213 /** igb_enable_mas - Media Autosense re-enable after swap
2219 struct e1000_hw *hw = &adapter->hw; in igb_enable_mas()
2223 if ((hw->phy.media_type == e1000_media_type_copper) && in igb_enable_mas()
2234 * igb_set_i2c_bb - Init I2C interface
2258 struct pci_dev *pdev = adapter->pdev; in igb_reset()
2259 struct e1000_hw *hw = &adapter->hw; in igb_reset()
2260 struct e1000_mac_info *mac = &hw->mac; in igb_reset()
2261 struct e1000_fc_info *fc = &hw->fc; in igb_reset()
2267 switch (mac->type) { in igb_reset()
2286 if (mac->type == e1000_82575) { in igb_reset()
2306 min_tx_space = adapter->max_frame_size; in igb_reset()
2307 min_tx_space += sizeof(union e1000_adv_tx_desc) - ETH_FCS_LEN; in igb_reset()
2311 needed_tx_space = min_tx_space - (rd32(E1000_PBA) >> 16); in igb_reset()
2318 pba -= needed_tx_space; in igb_reset()
2337 * - the full Rx FIFO size minus one full Tx plus one full Rx frame in igb_reset()
2339 hwm = (pba << 10) - (adapter->max_frame_size + MAX_JUMBO_FRAME_SIZE); in igb_reset()
2341 fc->high_water = hwm & 0xFFFFFFF0; /* 16-byte granularity */ in igb_reset()
2342 fc->low_water = fc->high_water - 16; in igb_reset()
2343 fc->pause_time = 0xFFFF; in igb_reset()
2344 fc->send_xon = 1; in igb_reset()
2345 fc->current_mode = fc->requested_mode; in igb_reset()
2348 if (adapter->vfs_allocated_count) { in igb_reset()
2351 for (i = 0 ; i < adapter->vfs_allocated_count; i++) in igb_reset()
2352 adapter->vf_data[i].flags &= IGB_VF_FLAG_PF_SET_MAC; in igb_reset()
2363 hw->mac.ops.reset_hw(hw); in igb_reset()
2366 if (adapter->flags & IGB_FLAG_MEDIA_RESET) { in igb_reset()
2368 adapter->ei.get_invariants(hw); in igb_reset()
2369 adapter->flags &= ~IGB_FLAG_MEDIA_RESET; in igb_reset()
2371 if ((mac->type == e1000_82575 || mac->type == e1000_i350) && in igb_reset()
2372 (adapter->flags & IGB_FLAG_MAS_ENABLE)) { in igb_reset()
2375 if (hw->mac.ops.init_hw(hw)) in igb_reset()
2376 dev_err(&pdev->dev, "Hardware Error\n"); in igb_reset()
2380 __dev_uc_unsync(adapter->netdev, NULL); in igb_reset()
2388 if (!hw->mac.autoneg) in igb_reset()
2393 /* Re-initialize the thermal sensor on i350 devices. */ in igb_reset()
2394 if (!test_bit(__IGB_DOWN, &adapter->state)) { in igb_reset()
2395 if (mac->type == e1000_i350 && hw->bus.func == 0) { in igb_reset()
2396 /* If present, re-initialize the external thermal sensor in igb_reset()
2399 if (adapter->ets) in igb_reset()
2401 mac->ops.init_thermal_sensor_thresh(hw); in igb_reset()
2405 /* Re-establish EEE setting */ in igb_reset()
2406 if (hw->phy.media_type == e1000_media_type_copper) { in igb_reset()
2407 switch (mac->type) { in igb_reset()
2420 if (!netif_running(adapter->netdev)) in igb_reset()
2428 /* Re-enable PTP, where applicable. */ in igb_reset()
2429 if (adapter->ptp_flags & IGB_PTP_ENABLED) in igb_reset()
2452 netdev_features_t changed = netdev->features ^ features; in igb_set_features()
2465 spin_lock(&adapter->nfc_lock); in igb_set_features()
2467 &adapter->nfc_filter_list, nfc_node) { in igb_set_features()
2469 hlist_del(&rule->nfc_node); in igb_set_features()
2472 spin_unlock(&adapter->nfc_lock); in igb_set_features()
2473 adapter->nfc_filter_count = 0; in igb_set_features()
2476 netdev->features = features; in igb_set_features()
2495 int vfn = adapter->vfs_allocated_count; in igb_ndo_fdb_add()
2498 return -ENOMEM; in igb_ndo_fdb_add()
2523 network_hdr_len = skb_checksum_start(skb) - skb_network_header(skb); in igb_features_check()
2534 if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) in igb_features_check()
2556 struct e1000_hw *hw = &adapter->hw; in igb_offload_cbs()
2560 if (hw->mac.type != e1000_i210) in igb_offload_cbs()
2561 return -EOPNOTSUPP; in igb_offload_cbs()
2564 if (qopt->queue < 0 || qopt->queue > 1) in igb_offload_cbs()
2565 return -EINVAL; in igb_offload_cbs()
2567 err = igb_save_cbs_params(adapter, qopt->queue, qopt->enable, in igb_offload_cbs()
2568 qopt->idleslope, qopt->sendslope, in igb_offload_cbs()
2569 qopt->hicredit, qopt->locredit); in igb_offload_cbs()
2573 igb_offload_apply(adapter, qopt->queue); in igb_offload_cbs()
2587 struct flow_dissector *dissector = rule->match.dissector; in igb_parse_cls_flower()
2588 struct netlink_ext_ack *extack = f->common.extack; in igb_parse_cls_flower()
2590 if (dissector->used_keys & in igb_parse_cls_flower()
2597 return -EOPNOTSUPP; in igb_parse_cls_flower()
2601 return -EOPNOTSUPP; in igb_parse_cls_flower()
2607 if (!is_zero_ether_addr(match.mask->dst)) { in igb_parse_cls_flower()
2608 if (!is_broadcast_ether_addr(match.mask->dst)) { in igb_parse_cls_flower()
2610 return -EINVAL; in igb_parse_cls_flower()
2613 input->filter.match_flags |= in igb_parse_cls_flower()
2615 ether_addr_copy(input->filter.dst_addr, match.key->dst); in igb_parse_cls_flower()
2618 if (!is_zero_ether_addr(match.mask->src)) { in igb_parse_cls_flower()
2619 if (!is_broadcast_ether_addr(match.mask->src)) { in igb_parse_cls_flower()
2621 return -EINVAL; in igb_parse_cls_flower()
2624 input->filter.match_flags |= in igb_parse_cls_flower()
2626 ether_addr_copy(input->filter.src_addr, match.key->src); in igb_parse_cls_flower()
2634 if (match.mask->n_proto) { in igb_parse_cls_flower()
2635 if (match.mask->n_proto != ETHER_TYPE_FULL_MASK) { in igb_parse_cls_flower()
2637 return -EINVAL; in igb_parse_cls_flower()
2640 input->filter.match_flags |= IGB_FILTER_FLAG_ETHER_TYPE; in igb_parse_cls_flower()
2641 input->filter.etype = match.key->n_proto; in igb_parse_cls_flower()
2649 if (match.mask->vlan_priority) { in igb_parse_cls_flower()
2650 if (match.mask->vlan_priority != VLAN_PRIO_FULL_MASK) { in igb_parse_cls_flower()
2652 return -EINVAL; in igb_parse_cls_flower()
2655 input->filter.match_flags |= IGB_FILTER_FLAG_VLAN_TCI; in igb_parse_cls_flower()
2656 input->filter.vlan_tci = in igb_parse_cls_flower()
2657 (__force __be16)match.key->vlan_priority; in igb_parse_cls_flower()
2661 input->action = traffic_class; in igb_parse_cls_flower()
2662 input->cookie = f->cookie; in igb_parse_cls_flower()
2670 struct netlink_ext_ack *extack = cls_flower->common.extack; in igb_configure_clsflower()
2674 tc = tc_classid_to_hwtc(adapter->netdev, cls_flower->classid); in igb_configure_clsflower()
2677 return -EINVAL; in igb_configure_clsflower()
2682 return -ENOMEM; in igb_configure_clsflower()
2688 spin_lock(&adapter->nfc_lock); in igb_configure_clsflower()
2690 hlist_for_each_entry(f, &adapter->nfc_filter_list, nfc_node) { in igb_configure_clsflower()
2691 if (!memcmp(&f->filter, &filter->filter, sizeof(f->filter))) { in igb_configure_clsflower()
2692 err = -EEXIST; in igb_configure_clsflower()
2699 hlist_for_each_entry(f, &adapter->cls_flower_list, nfc_node) { in igb_configure_clsflower()
2700 if (!memcmp(&f->filter, &filter->filter, sizeof(f->filter))) { in igb_configure_clsflower()
2701 err = -EEXIST; in igb_configure_clsflower()
2714 hlist_add_head(&filter->nfc_node, &adapter->cls_flower_list); in igb_configure_clsflower()
2716 spin_unlock(&adapter->nfc_lock); in igb_configure_clsflower()
2721 spin_unlock(&adapter->nfc_lock); in igb_configure_clsflower()
2735 spin_lock(&adapter->nfc_lock); in igb_delete_clsflower()
2737 hlist_for_each_entry(filter, &adapter->cls_flower_list, nfc_node) in igb_delete_clsflower()
2738 if (filter->cookie == cls_flower->cookie) in igb_delete_clsflower()
2742 err = -ENOENT; in igb_delete_clsflower()
2750 hlist_del(&filter->nfc_node); in igb_delete_clsflower()
2754 spin_unlock(&adapter->nfc_lock); in igb_delete_clsflower()
2762 switch (cls_flower->command) { in igb_setup_tc_cls_flower()
2768 return -EOPNOTSUPP; in igb_setup_tc_cls_flower()
2770 return -EOPNOTSUPP; in igb_setup_tc_cls_flower()
2779 if (!tc_cls_can_offload_and_chain0(adapter->netdev, type_data)) in igb_setup_tc_block_cb()
2780 return -EOPNOTSUPP; in igb_setup_tc_block_cb()
2787 return -EOPNOTSUPP; in igb_setup_tc_block_cb()
2794 struct e1000_hw *hw = &adapter->hw; in igb_offload_txtime()
2798 if (hw->mac.type != e1000_i210) in igb_offload_txtime()
2799 return -EOPNOTSUPP; in igb_offload_txtime()
2802 if (qopt->queue < 0 || qopt->queue > 1) in igb_offload_txtime()
2803 return -EINVAL; in igb_offload_txtime()
2805 err = igb_save_txtime_params(adapter, qopt->queue, qopt->enable); in igb_offload_txtime()
2809 igb_offload_apply(adapter, qopt->queue); in igb_offload_txtime()
2817 switch (base->type) { in igb_tc_query_caps()
2819 struct tc_taprio_caps *caps = base->caps; in igb_tc_query_caps()
2821 caps->broken_mqprio = true; in igb_tc_query_caps()
2826 return -EOPNOTSUPP; in igb_tc_query_caps()
2852 return -EOPNOTSUPP; in igb_setup_tc()
2858 int i, frame_size = dev->mtu + IGB_ETH_PKT_HDR_PAD; in igb_xdp_setup()
2860 struct bpf_prog *prog = bpf->prog, *old_prog; in igb_xdp_setup()
2865 for (i = 0; i < adapter->num_rx_queues; i++) { in igb_xdp_setup()
2866 struct igb_ring *ring = adapter->rx_ring[i]; in igb_xdp_setup()
2869 NL_SET_ERR_MSG_MOD(bpf->extack, in igb_xdp_setup()
2873 return -EINVAL; in igb_xdp_setup()
2877 old_prog = xchg(&adapter->xdp_prog, prog); in igb_xdp_setup()
2884 for (i = 0; i < adapter->num_rx_queues; i++) in igb_xdp_setup()
2885 (void)xchg(&adapter->rx_ring[i]->xdp_prog, in igb_xdp_setup()
2886 adapter->xdp_prog); in igb_xdp_setup()
2910 switch (xdp->command) { in igb_xdp()
2914 return -EINVAL; in igb_xdp()
2921 lockdep_assert_held(&txring_txq(ring)->_xmit_lock); in igb_xdp_ring_update_tail()
2927 writel(ring->next_to_use, ring->tail); in igb_xdp_ring_update_tail()
2934 if (r_idx >= adapter->num_tx_queues) in igb_xdp_tx_queue_mapping()
2935 r_idx = r_idx % adapter->num_tx_queues; in igb_xdp_tx_queue_mapping()
2937 return adapter->tx_ring[r_idx]; in igb_xdp_tx_queue_mapping()
2951 /* During program transitions its possible adapter->xdp_prog is assigned in igb_xdp_xmit_back()
2954 tx_ring = adapter->xdp_prog ? igb_xdp_tx_queue_mapping(adapter) : NULL; in igb_xdp_xmit_back()
2978 if (unlikely(test_bit(__IGB_DOWN, &adapter->state))) in igb_xdp_xmit()
2979 return -ENETDOWN; in igb_xdp_xmit()
2982 return -EINVAL; in igb_xdp_xmit()
2984 /* During program transitions its possible adapter->xdp_prog is assigned in igb_xdp_xmit()
2987 tx_ring = adapter->xdp_prog ? igb_xdp_tx_queue_mapping(adapter) : NULL; in igb_xdp_xmit()
2989 return -ENXIO; in igb_xdp_xmit()
3044 * igb_set_fw_version - Configure version string for ethtool
3049 struct e1000_hw *hw = &adapter->hw; in igb_set_fw_version()
3054 switch (hw->mac.type) { in igb_set_fw_version()
3058 snprintf(adapter->fw_version, in igb_set_fw_version()
3059 sizeof(adapter->fw_version), in igb_set_fw_version()
3060 "%2d.%2d-%d", in igb_set_fw_version()
3069 snprintf(adapter->fw_version, in igb_set_fw_version()
3070 sizeof(adapter->fw_version), in igb_set_fw_version()
3076 snprintf(adapter->fw_version, in igb_set_fw_version()
3077 sizeof(adapter->fw_version), in igb_set_fw_version()
3081 snprintf(adapter->fw_version, in igb_set_fw_version()
3082 sizeof(adapter->fw_version), in igb_set_fw_version()
3091 * igb_init_mas - init Media Autosense feature if enabled in the NVM
3097 struct e1000_hw *hw = &adapter->hw; in igb_init_mas()
3100 hw->nvm.ops.read(hw, NVM_COMPAT, 1, &eeprom_data); in igb_init_mas()
3101 switch (hw->bus.func) { in igb_init_mas()
3104 adapter->flags |= IGB_FLAG_MAS_ENABLE; in igb_init_mas()
3105 netdev_info(adapter->netdev, in igb_init_mas()
3107 hw->bus.func); in igb_init_mas()
3112 adapter->flags |= IGB_FLAG_MAS_ENABLE; in igb_init_mas()
3113 netdev_info(adapter->netdev, in igb_init_mas()
3115 hw->bus.func); in igb_init_mas()
3120 adapter->flags |= IGB_FLAG_MAS_ENABLE; in igb_init_mas()
3121 netdev_info(adapter->netdev, in igb_init_mas()
3123 hw->bus.func); in igb_init_mas()
3128 adapter->flags |= IGB_FLAG_MAS_ENABLE; in igb_init_mas()
3129 netdev_info(adapter->netdev, in igb_init_mas()
3131 hw->bus.func); in igb_init_mas()
3136 netdev_err(adapter->netdev, in igb_init_mas()
3143 * igb_init_i2c - Init I2C interface
3151 if (adapter->hw.mac.type != e1000_i350) in igb_init_i2c()
3158 adapter->i2c_adap.owner = THIS_MODULE; in igb_init_i2c()
3159 adapter->i2c_algo = igb_i2c_algo; in igb_init_i2c()
3160 adapter->i2c_algo.data = adapter; in igb_init_i2c()
3161 adapter->i2c_adap.algo_data = &adapter->i2c_algo; in igb_init_i2c()
3162 adapter->i2c_adap.dev.parent = &adapter->pdev->dev; in igb_init_i2c()
3163 strscpy(adapter->i2c_adap.name, "igb BB", in igb_init_i2c()
3164 sizeof(adapter->i2c_adap.name)); in igb_init_i2c()
3165 status = i2c_bit_add_bus(&adapter->i2c_adap); in igb_init_i2c()
3170 * igb_probe - Device Initialization Routine
3188 const struct e1000_info *ei = igb_info_tbl[ent->driver_data]; in igb_probe()
3193 * the PCIe SR-IOV capability. in igb_probe()
3195 if (pdev->is_virtfn) { in igb_probe()
3197 pci_name(pdev), pdev->vendor, pdev->device); in igb_probe()
3198 return -EINVAL; in igb_probe()
3205 err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); in igb_probe()
3207 dev_err(&pdev->dev, in igb_probe()
3219 err = -ENOMEM; in igb_probe()
3225 SET_NETDEV_DEV(netdev, &pdev->dev); in igb_probe()
3229 adapter->netdev = netdev; in igb_probe()
3230 adapter->pdev = pdev; in igb_probe()
3231 hw = &adapter->hw; in igb_probe()
3232 hw->back = adapter; in igb_probe()
3233 adapter->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE); in igb_probe()
3235 err = -EIO; in igb_probe()
3236 adapter->io_addr = pci_iomap(pdev, 0, 0); in igb_probe()
3237 if (!adapter->io_addr) in igb_probe()
3239 /* hw->hw_addr can be altered, we'll use adapter->io_addr for unmap */ in igb_probe()
3240 hw->hw_addr = adapter->io_addr; in igb_probe()
3242 netdev->netdev_ops = &igb_netdev_ops; in igb_probe()
3244 netdev->watchdog_timeo = 5 * HZ; in igb_probe()
3246 strscpy(netdev->name, pci_name(pdev), sizeof(netdev->name)); in igb_probe()
3248 netdev->mem_start = pci_resource_start(pdev, 0); in igb_probe()
3249 netdev->mem_end = pci_resource_end(pdev, 0); in igb_probe()
3252 hw->vendor_id = pdev->vendor; in igb_probe()
3253 hw->device_id = pdev->device; in igb_probe()
3254 hw->revision_id = pdev->revision; in igb_probe()
3255 hw->subsystem_vendor_id = pdev->subsystem_vendor; in igb_probe()
3256 hw->subsystem_device_id = pdev->subsystem_device; in igb_probe()
3259 memcpy(&hw->mac.ops, ei->mac_ops, sizeof(hw->mac.ops)); in igb_probe()
3260 memcpy(&hw->phy.ops, ei->phy_ops, sizeof(hw->phy.ops)); in igb_probe()
3261 memcpy(&hw->nvm.ops, ei->nvm_ops, sizeof(hw->nvm.ops)); in igb_probe()
3262 /* Initialize skew-specific constants */ in igb_probe()
3263 err = ei->get_invariants(hw); in igb_probe()
3274 hw->phy.autoneg_wait_to_complete = false; in igb_probe()
3277 if (hw->phy.media_type == e1000_media_type_copper) { in igb_probe()
3278 hw->phy.mdix = AUTO_ALL_MODES; in igb_probe()
3279 hw->phy.disable_polarity_correction = false; in igb_probe()
3280 hw->phy.ms_type = e1000_ms_hw_default; in igb_probe()
3284 dev_info(&pdev->dev, in igb_probe()
3291 netdev->features |= NETIF_F_SG | in igb_probe()
3298 if (hw->mac.type >= e1000_82576) in igb_probe()
3299 netdev->features |= NETIF_F_SCTP_CRC | NETIF_F_GSO_UDP_L4; in igb_probe()
3301 if (hw->mac.type >= e1000_i350) in igb_probe()
3302 netdev->features |= NETIF_F_HW_TC; in igb_probe()
3311 netdev->gso_partial_features = IGB_GSO_PARTIAL_FEATURES; in igb_probe()
3312 netdev->features |= NETIF_F_GSO_PARTIAL | IGB_GSO_PARTIAL_FEATURES; in igb_probe()
3315 netdev->hw_features |= netdev->features | in igb_probe()
3320 if (hw->mac.type >= e1000_i350) in igb_probe()
3321 netdev->hw_features |= NETIF_F_NTUPLE; in igb_probe()
3323 netdev->features |= NETIF_F_HIGHDMA; in igb_probe()
3325 netdev->vlan_features |= netdev->features | NETIF_F_TSO_MANGLEID; in igb_probe()
3326 netdev->mpls_features |= NETIF_F_HW_CSUM; in igb_probe()
3327 netdev->hw_enc_features |= netdev->vlan_features; in igb_probe()
3330 netdev->features |= NETIF_F_HW_VLAN_CTAG_FILTER | in igb_probe()
3334 netdev->priv_flags |= IFF_SUPP_NOFCS; in igb_probe()
3336 netdev->priv_flags |= IFF_UNICAST_FLT; in igb_probe()
3337 netdev->xdp_features = NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT; in igb_probe()
3339 /* MTU range: 68 - 9216 */ in igb_probe()
3340 netdev->min_mtu = ETH_MIN_MTU; in igb_probe()
3341 netdev->max_mtu = MAX_STD_JUMBO_FRAME_SIZE; in igb_probe()
3343 adapter->en_mng_pt = igb_enable_mng_pass_thru(hw); in igb_probe()
3348 hw->mac.ops.reset_hw(hw); in igb_probe()
3353 switch (hw->mac.type) { in igb_probe()
3357 if (hw->nvm.ops.validate(hw) < 0) { in igb_probe()
3358 dev_err(&pdev->dev, in igb_probe()
3360 err = -EIO; in igb_probe()
3366 if (hw->nvm.ops.validate(hw) < 0) { in igb_probe()
3367 dev_err(&pdev->dev, "The NVM Checksum Is Not Valid\n"); in igb_probe()
3368 err = -EIO; in igb_probe()
3374 if (eth_platform_get_mac_address(&pdev->dev, hw->mac.addr)) { in igb_probe()
3376 if (hw->mac.ops.read_mac_addr(hw)) in igb_probe()
3377 dev_err(&pdev->dev, "NVM Read Error\n"); in igb_probe()
3380 eth_hw_addr_set(netdev, hw->mac.addr); in igb_probe()
3382 if (!is_valid_ether_addr(netdev->dev_addr)) { in igb_probe()
3383 dev_err(&pdev->dev, "Invalid MAC Address\n"); in igb_probe()
3384 err = -EIO; in igb_probe()
3390 /* get firmware version for ethtool -i */ in igb_probe()
3394 if (hw->mac.type == e1000_i210) { in igb_probe()
3399 timer_setup(&adapter->watchdog_timer, igb_watchdog, 0); in igb_probe()
3400 timer_setup(&adapter->phy_info_timer, igb_update_phy_info, 0); in igb_probe()
3402 INIT_WORK(&adapter->reset_task, igb_reset_task); in igb_probe()
3403 INIT_WORK(&adapter->watchdog_task, igb_watchdog_task); in igb_probe()
3405 /* Initialize link properties that are user-changeable */ in igb_probe()
3406 adapter->fc_autoneg = true; in igb_probe()
3407 hw->mac.autoneg = true; in igb_probe()
3408 hw->phy.autoneg_advertised = 0x2f; in igb_probe()
3410 hw->fc.requested_mode = e1000_fc_default; in igb_probe()
3411 hw->fc.current_mode = e1000_fc_default; in igb_probe()
3416 if (hw->bus.func == 0) in igb_probe()
3417 adapter->flags |= IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3419 /* Check the NVM for wake support on non-port A ports */ in igb_probe()
3420 if (hw->mac.type >= e1000_82580) in igb_probe()
3421 hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_A + in igb_probe()
3422 NVM_82580_LAN_FUNC_OFFSET(hw->bus.func), 1, in igb_probe()
3424 else if (hw->bus.func == 1) in igb_probe()
3425 hw->nvm.ops.read(hw, NVM_INIT_CONTROL3_PORT_B, 1, &eeprom_data); in igb_probe()
3428 adapter->flags |= IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3434 switch (pdev->device) { in igb_probe()
3436 adapter->flags &= ~IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3445 adapter->flags &= ~IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3451 adapter->flags &= ~IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3453 adapter->flags |= IGB_FLAG_QUAD_PORT_A; in igb_probe()
3460 if (!device_can_wakeup(&adapter->pdev->dev)) in igb_probe()
3461 adapter->flags &= ~IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3465 if (adapter->flags & IGB_FLAG_WOL_SUPPORTED) in igb_probe()
3466 adapter->wol |= E1000_WUFC_MAG; in igb_probe()
3469 if ((hw->mac.type == e1000_i350) && in igb_probe()
3470 (pdev->subsystem_vendor == PCI_VENDOR_ID_HP)) { in igb_probe()
3471 adapter->flags |= IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3472 adapter->wol = 0; in igb_probe()
3478 if (((hw->mac.type == e1000_i350) || in igb_probe()
3479 (hw->mac.type == e1000_i354)) && in igb_probe()
3480 (pdev->subsystem_vendor == PCI_VENDOR_ID_DELL)) { in igb_probe()
3481 adapter->flags |= IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3482 adapter->wol = 0; in igb_probe()
3484 if (hw->mac.type == e1000_i350) { in igb_probe()
3485 if (((pdev->subsystem_device == 0x5001) || in igb_probe()
3486 (pdev->subsystem_device == 0x5002)) && in igb_probe()
3487 (hw->bus.func == 0)) { in igb_probe()
3488 adapter->flags |= IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3489 adapter->wol = 0; in igb_probe()
3491 if (pdev->subsystem_device == 0x1F52) in igb_probe()
3492 adapter->flags |= IGB_FLAG_WOL_SUPPORTED; in igb_probe()
3495 device_set_wakeup_enable(&adapter->pdev->dev, in igb_probe()
3496 adapter->flags & IGB_FLAG_WOL_SUPPORTED); in igb_probe()
3504 dev_err(&pdev->dev, "failed to init i2c interface\n"); in igb_probe()
3513 strcpy(netdev->name, "eth%d"); in igb_probe()
3522 if (dca_add_requester(&pdev->dev) == 0) { in igb_probe()
3523 adapter->flags |= IGB_FLAG_DCA_ENABLED; in igb_probe()
3524 dev_info(&pdev->dev, "DCA enabled\n"); in igb_probe()
3531 if (hw->mac.type == e1000_i350 && hw->bus.func == 0) { in igb_probe()
3537 hw->nvm.ops.read(hw, NVM_ETS_CFG, 1, &ets_word); in igb_probe()
3539 adapter->ets = true; in igb_probe()
3541 adapter->ets = false; in igb_probe()
3545 if (adapter->ets) in igb_probe()
3547 hw->mac.ops.init_thermal_sensor_thresh(hw); in igb_probe()
3549 dev_err(&pdev->dev, in igb_probe()
3552 adapter->ets = false; in igb_probe()
3556 adapter->ei = *ei; in igb_probe()
3557 if (hw->dev_spec._82575.mas_capable) in igb_probe()
3563 dev_info(&pdev->dev, "Intel(R) Gigabit Ethernet Network Connection\n"); in igb_probe()
3565 if (hw->mac.type != e1000_i354) { in igb_probe()
3566 dev_info(&pdev->dev, "%s: (PCIe:%s:%s) %pM\n", in igb_probe()
3567 netdev->name, in igb_probe()
3568 ((hw->bus.speed == e1000_bus_speed_2500) ? "2.5Gb/s" : in igb_probe()
3569 (hw->bus.speed == e1000_bus_speed_5000) ? "5.0Gb/s" : in igb_probe()
3571 ((hw->bus.width == e1000_bus_width_pcie_x4) ? in igb_probe()
3573 (hw->bus.width == e1000_bus_width_pcie_x2) ? in igb_probe()
3575 (hw->bus.width == e1000_bus_width_pcie_x1) ? in igb_probe()
3576 "Width x1" : "unknown"), netdev->dev_addr); in igb_probe()
3579 if ((hw->mac.type == e1000_82576 && in igb_probe()
3581 (hw->mac.type >= e1000_i210 || in igb_probe()
3586 ret_val = -E1000_ERR_INVM_VALUE_NOT_FOUND; in igb_probe()
3591 dev_info(&pdev->dev, "%s: PBA No: %s\n", netdev->name, part_str); in igb_probe()
3592 dev_info(&pdev->dev, in igb_probe()
3594 (adapter->flags & IGB_FLAG_HAS_MSIX) ? "MSI-X" : in igb_probe()
3595 (adapter->flags & IGB_FLAG_HAS_MSI) ? "MSI" : "legacy", in igb_probe()
3596 adapter->num_rx_queues, adapter->num_tx_queues); in igb_probe()
3597 if (hw->phy.media_type == e1000_media_type_copper) { in igb_probe()
3598 switch (hw->mac.type) { in igb_probe()
3605 (!hw->dev_spec._82575.eee_disable)) { in igb_probe()
3606 adapter->eee_advert = in igb_probe()
3608 adapter->flags |= IGB_FLAG_EEE; in igb_probe()
3616 (!hw->dev_spec._82575.eee_disable)) { in igb_probe()
3617 adapter->eee_advert = in igb_probe()
3619 adapter->flags |= IGB_FLAG_EEE; in igb_probe()
3628 dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NO_DIRECT_COMPLETE); in igb_probe()
3630 pm_runtime_put_noidle(&pdev->dev); in igb_probe()
3635 memset(&adapter->i2c_adap, 0, sizeof(adapter->i2c_adap)); in igb_probe()
3640 if (hw->flash_address) in igb_probe()
3641 iounmap(hw->flash_address); in igb_probe()
3643 kfree(adapter->mac_table); in igb_probe()
3644 kfree(adapter->shadow_vfta); in igb_probe()
3649 pci_iounmap(pdev, adapter->io_addr); in igb_probe()
3665 struct pci_dev *pdev = adapter->pdev; in igb_sriov_reinit()
3680 dev_err(&pdev->dev, "Unable to allocate memory for queues\n"); in igb_sriov_reinit()
3681 return -ENOMEM; in igb_sriov_reinit()
3696 struct e1000_hw *hw = &adapter->hw; in igb_disable_sriov()
3700 if (adapter->vf_data) { in igb_disable_sriov()
3703 dev_warn(&pdev->dev, in igb_disable_sriov()
3704 …"Cannot deallocate SR-IOV virtual functions while they are assigned - VFs will not be deallocated\… in igb_disable_sriov()
3705 return -EPERM; in igb_disable_sriov()
3710 spin_lock_irqsave(&adapter->vfs_lock, flags); in igb_disable_sriov()
3711 kfree(adapter->vf_mac_list); in igb_disable_sriov()
3712 adapter->vf_mac_list = NULL; in igb_disable_sriov()
3713 kfree(adapter->vf_data); in igb_disable_sriov()
3714 adapter->vf_data = NULL; in igb_disable_sriov()
3715 adapter->vfs_allocated_count = 0; in igb_disable_sriov()
3716 spin_unlock_irqrestore(&adapter->vfs_lock, flags); in igb_disable_sriov()
3720 dev_info(&pdev->dev, "IOV Disabled\n"); in igb_disable_sriov()
3722 /* Re-enable DMA Coalescing flag since IOV is turned off */ in igb_disable_sriov()
3723 adapter->flags |= IGB_FLAG_DMAC; in igb_disable_sriov()
3738 if (!(adapter->flags & IGB_FLAG_HAS_MSIX) || num_vfs > 7) { in igb_enable_sriov()
3739 err = -EPERM; in igb_enable_sriov()
3746 dev_info(&pdev->dev, "%d pre-allocated VFs found - override max_vfs setting of %d\n", in igb_enable_sriov()
3748 adapter->vfs_allocated_count = old_vfs; in igb_enable_sriov()
3750 adapter->vfs_allocated_count = num_vfs; in igb_enable_sriov()
3752 adapter->vf_data = kcalloc(adapter->vfs_allocated_count, in igb_enable_sriov()
3755 /* if allocation failed then we do not support SR-IOV */ in igb_enable_sriov()
3756 if (!adapter->vf_data) { in igb_enable_sriov()
3757 adapter->vfs_allocated_count = 0; in igb_enable_sriov()
3758 err = -ENOMEM; in igb_enable_sriov()
3767 num_vf_mac_filters = adapter->hw.mac.rar_entry_count - in igb_enable_sriov()
3769 adapter->vfs_allocated_count); in igb_enable_sriov()
3771 adapter->vf_mac_list = kcalloc(num_vf_mac_filters, in igb_enable_sriov()
3775 mac_list = adapter->vf_mac_list; in igb_enable_sriov()
3776 INIT_LIST_HEAD(&adapter->vf_macs.l); in igb_enable_sriov()
3778 if (adapter->vf_mac_list) { in igb_enable_sriov()
3781 mac_list->vf = -1; in igb_enable_sriov()
3782 mac_list->free = true; in igb_enable_sriov()
3783 list_add(&mac_list->l, &adapter->vf_macs.l); in igb_enable_sriov()
3790 dev_err(&pdev->dev, in igb_enable_sriov()
3794 dev_info(&pdev->dev, "%d VFs allocated\n", in igb_enable_sriov()
3795 adapter->vfs_allocated_count); in igb_enable_sriov()
3796 for (i = 0; i < adapter->vfs_allocated_count; i++) in igb_enable_sriov()
3800 adapter->flags &= ~IGB_FLAG_DMAC; in igb_enable_sriov()
3810 err = pci_enable_sriov(pdev, adapter->vfs_allocated_count); in igb_enable_sriov()
3818 kfree(adapter->vf_mac_list); in igb_enable_sriov()
3819 adapter->vf_mac_list = NULL; in igb_enable_sriov()
3820 kfree(adapter->vf_data); in igb_enable_sriov()
3821 adapter->vf_data = NULL; in igb_enable_sriov()
3822 adapter->vfs_allocated_count = 0; in igb_enable_sriov()
3829 * igb_remove_i2c - Cleanup I2C interface
3835 i2c_del_adapter(&adapter->i2c_adap); in igb_remove_i2c()
3839 * igb_remove - Device Removal Routine
3844 * Hot-Plug event, or because the driver is going to be removed from
3851 struct e1000_hw *hw = &adapter->hw; in igb_remove()
3853 pm_runtime_get_noresume(&pdev->dev); in igb_remove()
3862 set_bit(__IGB_DOWN, &adapter->state); in igb_remove()
3863 del_timer_sync(&adapter->watchdog_timer); in igb_remove()
3864 del_timer_sync(&adapter->phy_info_timer); in igb_remove()
3866 cancel_work_sync(&adapter->reset_task); in igb_remove()
3867 cancel_work_sync(&adapter->watchdog_task); in igb_remove()
3870 if (adapter->flags & IGB_FLAG_DCA_ENABLED) { in igb_remove()
3871 dev_info(&pdev->dev, "DCA disabled\n"); in igb_remove()
3872 dca_remove_requester(&pdev->dev); in igb_remove()
3873 adapter->flags &= ~IGB_FLAG_DCA_ENABLED; in igb_remove()
3891 pci_iounmap(pdev, adapter->io_addr); in igb_remove()
3892 if (hw->flash_address) in igb_remove()
3893 iounmap(hw->flash_address); in igb_remove()
3896 kfree(adapter->mac_table); in igb_remove()
3897 kfree(adapter->shadow_vfta); in igb_remove()
3904 * igb_probe_vfs - Initialize vf data storage and add VFs to pci config space
3909 * mor expensive time wise to disable SR-IOV than it is to allocate and free
3915 struct pci_dev *pdev = adapter->pdev; in igb_probe_vfs()
3916 struct e1000_hw *hw = &adapter->hw; in igb_probe_vfs()
3919 if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211) || in igb_probe_vfs()
3920 (hw->mac.type == e1000_82580)) in igb_probe_vfs()
3938 struct e1000_hw *hw = &adapter->hw; in igb_get_max_rss_queues()
3942 switch (hw->mac.type) { in igb_get_max_rss_queues()
3951 /* I350 cannot do RSS and SR-IOV at the same time */ in igb_get_max_rss_queues()
3952 if (!!adapter->vfs_allocated_count) { in igb_get_max_rss_queues()
3958 if (!!adapter->vfs_allocated_count) { in igb_get_max_rss_queues()
3978 adapter->rss_queues = min_t(u32, max_rss_queues, num_online_cpus()); in igb_init_queue_configuration()
3986 struct e1000_hw *hw = &adapter->hw; in igb_set_flag_queue_pairs()
3989 switch (hw->mac.type) { in igb_set_flag_queue_pairs()
4001 * order to conserve interrupts due to limited supply. in igb_set_flag_queue_pairs()
4003 if (adapter->rss_queues > (max_rss_queues / 2)) in igb_set_flag_queue_pairs()
4004 adapter->flags |= IGB_FLAG_QUEUE_PAIRS; in igb_set_flag_queue_pairs()
4006 adapter->flags &= ~IGB_FLAG_QUEUE_PAIRS; in igb_set_flag_queue_pairs()
4012 * igb_sw_init - Initialize general software structures (struct igb_adapter)
4021 struct e1000_hw *hw = &adapter->hw; in igb_sw_init()
4022 struct net_device *netdev = adapter->netdev; in igb_sw_init()
4023 struct pci_dev *pdev = adapter->pdev; in igb_sw_init()
4025 pci_read_config_word(pdev, PCI_COMMAND, &hw->bus.pci_cmd_word); in igb_sw_init()
4028 adapter->tx_ring_count = IGB_DEFAULT_TXD; in igb_sw_init()
4029 adapter->rx_ring_count = IGB_DEFAULT_RXD; in igb_sw_init()
4032 adapter->rx_itr_setting = IGB_DEFAULT_ITR; in igb_sw_init()
4033 adapter->tx_itr_setting = IGB_DEFAULT_ITR; in igb_sw_init()
4036 adapter->tx_work_limit = IGB_DEFAULT_TX_WORK; in igb_sw_init()
4038 adapter->max_frame_size = netdev->mtu + IGB_ETH_PKT_HDR_PAD; in igb_sw_init()
4039 adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; in igb_sw_init()
4041 spin_lock_init(&adapter->nfc_lock); in igb_sw_init()
4042 spin_lock_init(&adapter->stats64_lock); in igb_sw_init()
4045 spin_lock_init(&adapter->vfs_lock); in igb_sw_init()
4047 switch (hw->mac.type) { in igb_sw_init()
4051 dev_warn(&pdev->dev, in igb_sw_init()
4053 max_vfs = adapter->vfs_allocated_count = 7; in igb_sw_init()
4055 adapter->vfs_allocated_count = max_vfs; in igb_sw_init()
4056 if (adapter->vfs_allocated_count) in igb_sw_init()
4057 dev_warn(&pdev->dev, in igb_sw_init()
4058 …"Enabling SR-IOV VFs using the module parameter is deprecated - please use the pci sysfs interface… in igb_sw_init()
4065 /* Assume MSI-X interrupts, will be checked during IRQ allocation */ in igb_sw_init()
4066 adapter->flags |= IGB_FLAG_HAS_MSIX; in igb_sw_init()
4068 adapter->mac_table = kcalloc(hw->mac.rar_entry_count, in igb_sw_init()
4071 if (!adapter->mac_table) in igb_sw_init()
4072 return -ENOMEM; in igb_sw_init()
4079 adapter->shadow_vfta = kcalloc(E1000_VLAN_FILTER_TBL_SIZE, sizeof(u32), in igb_sw_init()
4081 if (!adapter->shadow_vfta) in igb_sw_init()
4082 return -ENOMEM; in igb_sw_init()
4086 dev_err(&pdev->dev, "Unable to allocate memory for queues\n"); in igb_sw_init()
4087 return -ENOMEM; in igb_sw_init()
4093 if (hw->mac.type >= e1000_i350) in igb_sw_init()
4094 adapter->flags &= ~IGB_FLAG_DMAC; in igb_sw_init()
4096 set_bit(__IGB_DOWN, &adapter->state); in igb_sw_init()
4101 * __igb_open - Called when a network interface is made active
4116 struct e1000_hw *hw = &adapter->hw; in __igb_open()
4117 struct pci_dev *pdev = adapter->pdev; in __igb_open()
4122 if (test_bit(__IGB_TESTING, &adapter->state)) { in __igb_open()
4124 return -EBUSY; in __igb_open()
4128 pm_runtime_get_sync(&pdev->dev); in __igb_open()
4156 err = netif_set_real_num_tx_queues(adapter->netdev, in __igb_open()
4157 adapter->num_tx_queues); in __igb_open()
4161 err = netif_set_real_num_rx_queues(adapter->netdev, in __igb_open()
4162 adapter->num_rx_queues); in __igb_open()
4167 clear_bit(__IGB_DOWN, &adapter->state); in __igb_open()
4169 for (i = 0; i < adapter->num_q_vectors; i++) in __igb_open()
4170 napi_enable(&(adapter->q_vector[i]->napi)); in __igb_open()
4179 if (adapter->vfs_allocated_count) { in __igb_open()
4189 pm_runtime_put(&pdev->dev); in __igb_open()
4192 hw->mac.get_link_status = 1; in __igb_open()
4193 schedule_work(&adapter->watchdog_task); in __igb_open()
4208 pm_runtime_put(&pdev->dev); in __igb_open()
4219 * __igb_close - Disables a network interface
4225 * The close entry point is called when an interface is de-activated
4233 struct pci_dev *pdev = adapter->pdev; in __igb_close()
4235 WARN_ON(test_bit(__IGB_RESETTING, &adapter->state)); in __igb_close()
4238 pm_runtime_get_sync(&pdev->dev); in __igb_close()
4247 pm_runtime_put_sync(&pdev->dev); in __igb_close()
4253 if (netif_device_present(netdev) || netdev->dismantle) in igb_close()
4259 * igb_setup_tx_resources - allocate Tx resources (Descriptors)
4266 struct device *dev = tx_ring->dev; in igb_setup_tx_resources()
4269 size = sizeof(struct igb_tx_buffer) * tx_ring->count; in igb_setup_tx_resources()
4271 tx_ring->tx_buffer_info = vmalloc(size); in igb_setup_tx_resources()
4272 if (!tx_ring->tx_buffer_info) in igb_setup_tx_resources()
4276 tx_ring->size = tx_ring->count * sizeof(union e1000_adv_tx_desc); in igb_setup_tx_resources()
4277 tx_ring->size = ALIGN(tx_ring->size, 4096); in igb_setup_tx_resources()
4279 tx_ring->desc = dma_alloc_coherent(dev, tx_ring->size, in igb_setup_tx_resources()
4280 &tx_ring->dma, GFP_KERNEL); in igb_setup_tx_resources()
4281 if (!tx_ring->desc) in igb_setup_tx_resources()
4284 tx_ring->next_to_use = 0; in igb_setup_tx_resources()
4285 tx_ring->next_to_clean = 0; in igb_setup_tx_resources()
4290 vfree(tx_ring->tx_buffer_info); in igb_setup_tx_resources()
4291 tx_ring->tx_buffer_info = NULL; in igb_setup_tx_resources()
4293 return -ENOMEM; in igb_setup_tx_resources()
4297 * igb_setup_all_tx_resources - wrapper to allocate Tx resources
4305 struct pci_dev *pdev = adapter->pdev; in igb_setup_all_tx_resources()
4308 for (i = 0; i < adapter->num_tx_queues; i++) { in igb_setup_all_tx_resources()
4309 err = igb_setup_tx_resources(adapter->tx_ring[i]); in igb_setup_all_tx_resources()
4311 dev_err(&pdev->dev, in igb_setup_all_tx_resources()
4313 for (i--; i >= 0; i--) in igb_setup_all_tx_resources()
4314 igb_free_tx_resources(adapter->tx_ring[i]); in igb_setup_all_tx_resources()
4323 * igb_setup_tctl - configure the transmit control registers
4328 struct e1000_hw *hw = &adapter->hw; in igb_setup_tctl()
4349 * igb_configure_tx_ring - Configure transmit ring after Reset
4358 struct e1000_hw *hw = &adapter->hw; in igb_configure_tx_ring()
4360 u64 tdba = ring->dma; in igb_configure_tx_ring()
4361 int reg_idx = ring->reg_idx; in igb_configure_tx_ring()
4364 ring->count * sizeof(union e1000_adv_tx_desc)); in igb_configure_tx_ring()
4369 ring->tail = adapter->io_addr + E1000_TDT(reg_idx); in igb_configure_tx_ring()
4371 writel(0, ring->tail); in igb_configure_tx_ring()
4378 memset(ring->tx_buffer_info, 0, in igb_configure_tx_ring()
4379 sizeof(struct igb_tx_buffer) * ring->count); in igb_configure_tx_ring()
4386 * igb_configure_tx - Configure transmit Unit after Reset
4393 struct e1000_hw *hw = &adapter->hw; in igb_configure_tx()
4397 for (i = 0; i < adapter->num_tx_queues; i++) in igb_configure_tx()
4398 wr32(E1000_TXDCTL(adapter->tx_ring[i]->reg_idx), 0); in igb_configure_tx()
4403 for (i = 0; i < adapter->num_tx_queues; i++) in igb_configure_tx()
4404 igb_configure_tx_ring(adapter, adapter->tx_ring[i]); in igb_configure_tx()
4408 * igb_setup_rx_resources - allocate Rx resources (Descriptors)
4415 struct igb_adapter *adapter = netdev_priv(rx_ring->netdev); in igb_setup_rx_resources()
4416 struct device *dev = rx_ring->dev; in igb_setup_rx_resources()
4419 /* XDP RX-queue info */ in igb_setup_rx_resources()
4420 if (xdp_rxq_info_is_reg(&rx_ring->xdp_rxq)) in igb_setup_rx_resources()
4421 xdp_rxq_info_unreg(&rx_ring->xdp_rxq); in igb_setup_rx_resources()
4422 res = xdp_rxq_info_reg(&rx_ring->xdp_rxq, rx_ring->netdev, in igb_setup_rx_resources()
4423 rx_ring->queue_index, 0); in igb_setup_rx_resources()
4426 rx_ring->queue_index); in igb_setup_rx_resources()
4430 size = sizeof(struct igb_rx_buffer) * rx_ring->count; in igb_setup_rx_resources()
4432 rx_ring->rx_buffer_info = vmalloc(size); in igb_setup_rx_resources()
4433 if (!rx_ring->rx_buffer_info) in igb_setup_rx_resources()
4437 rx_ring->size = rx_ring->count * sizeof(union e1000_adv_rx_desc); in igb_setup_rx_resources()
4438 rx_ring->size = ALIGN(rx_ring->size, 4096); in igb_setup_rx_resources()
4440 rx_ring->desc = dma_alloc_coherent(dev, rx_ring->size, in igb_setup_rx_resources()
4441 &rx_ring->dma, GFP_KERNEL); in igb_setup_rx_resources()
4442 if (!rx_ring->desc) in igb_setup_rx_resources()
4445 rx_ring->next_to_alloc = 0; in igb_setup_rx_resources()
4446 rx_ring->next_to_clean = 0; in igb_setup_rx_resources()
4447 rx_ring->next_to_use = 0; in igb_setup_rx_resources()
4449 rx_ring->xdp_prog = adapter->xdp_prog; in igb_setup_rx_resources()
4454 xdp_rxq_info_unreg(&rx_ring->xdp_rxq); in igb_setup_rx_resources()
4455 vfree(rx_ring->rx_buffer_info); in igb_setup_rx_resources()
4456 rx_ring->rx_buffer_info = NULL; in igb_setup_rx_resources()
4458 return -ENOMEM; in igb_setup_rx_resources()
4462 * igb_setup_all_rx_resources - wrapper to allocate Rx resources
4470 struct pci_dev *pdev = adapter->pdev; in igb_setup_all_rx_resources()
4473 for (i = 0; i < adapter->num_rx_queues; i++) { in igb_setup_all_rx_resources()
4474 err = igb_setup_rx_resources(adapter->rx_ring[i]); in igb_setup_all_rx_resources()
4476 dev_err(&pdev->dev, in igb_setup_all_rx_resources()
4478 for (i--; i >= 0; i--) in igb_setup_all_rx_resources()
4479 igb_free_rx_resources(adapter->rx_ring[i]); in igb_setup_all_rx_resources()
4488 * igb_setup_mrqc - configure the multiple receive queue control registers
4493 struct e1000_hw *hw = &adapter->hw; in igb_setup_mrqc()
4502 num_rx_queues = adapter->rss_queues; in igb_setup_mrqc()
4504 switch (hw->mac.type) { in igb_setup_mrqc()
4506 /* 82576 supports 2 RSS queues for SR-IOV */ in igb_setup_mrqc()
4507 if (adapter->vfs_allocated_count) in igb_setup_mrqc()
4514 if (adapter->rss_indir_tbl_init != num_rx_queues) { in igb_setup_mrqc()
4516 adapter->rss_indir_tbl[j] = in igb_setup_mrqc()
4518 adapter->rss_indir_tbl_init = num_rx_queues; in igb_setup_mrqc()
4529 if (adapter->hw.mac.type >= e1000_82576) in igb_setup_mrqc()
4545 if (adapter->flags & IGB_FLAG_RSS_FIELD_IPV4_UDP) in igb_setup_mrqc()
4547 if (adapter->flags & IGB_FLAG_RSS_FIELD_IPV6_UDP) in igb_setup_mrqc()
4554 if (adapter->vfs_allocated_count) { in igb_setup_mrqc()
4555 if (hw->mac.type > e1000_82575) { in igb_setup_mrqc()
4561 vtctl |= adapter->vfs_allocated_count << in igb_setup_mrqc()
4565 if (adapter->rss_queues > 1) in igb_setup_mrqc()
4578 * igb_setup_rctl - configure the receive control registers
4583 struct e1000_hw *hw = &adapter->hw; in igb_setup_rctl()
4592 (hw->mac.mc_filter_type << E1000_RCTL_MO_SHIFT); in igb_setup_rctl()
4606 /* disable queue 0 to prevent tail write w/o re-config */ in igb_setup_rctl()
4609 /* Attention!!! For SR-IOV PF driver operations you must enable in igb_setup_rctl()
4611 * if an un-trusted VF does not provide descriptors to hardware. in igb_setup_rctl()
4613 if (adapter->vfs_allocated_count) { in igb_setup_rctl()
4619 if (adapter->netdev->features & NETIF_F_RXALL) { in igb_setup_rctl()
4640 struct e1000_hw *hw = &adapter->hw; in igb_set_vf_rlpml()
4657 struct e1000_hw *hw = &adapter->hw; in igb_set_vf_vlan_strip()
4660 if (hw->mac.type < e1000_82576) in igb_set_vf_vlan_strip()
4663 if (hw->mac.type == e1000_i350) in igb_set_vf_vlan_strip()
4679 struct e1000_hw *hw = &adapter->hw; in igb_set_vmolr()
4685 if (hw->mac.type < e1000_82576) in igb_set_vmolr()
4697 if (adapter->rss_queues > 1 && vfn == adapter->vfs_allocated_count) in igb_set_vmolr()
4702 if (vfn <= adapter->vfs_allocated_count) in igb_set_vmolr()
4709 * igb_setup_srrctl - configure the split and replication receive control
4716 struct e1000_hw *hw = &adapter->hw; in igb_setup_srrctl()
4717 int reg_idx = ring->reg_idx; in igb_setup_srrctl()
4726 if (hw->mac.type >= e1000_82580) in igb_setup_srrctl()
4731 if (adapter->vfs_allocated_count || in igb_setup_srrctl()
4732 (!(hw->fc.current_mode & e1000_fc_rx_pause) && in igb_setup_srrctl()
4733 adapter->num_rx_queues > 1)) in igb_setup_srrctl()
4740 * igb_configure_rx_ring - Configure a receive ring after Reset
4749 struct e1000_hw *hw = &adapter->hw; in igb_configure_rx_ring()
4751 u64 rdba = ring->dma; in igb_configure_rx_ring()
4752 int reg_idx = ring->reg_idx; in igb_configure_rx_ring()
4755 xdp_rxq_info_unreg_mem_model(&ring->xdp_rxq); in igb_configure_rx_ring()
4756 WARN_ON(xdp_rxq_info_reg_mem_model(&ring->xdp_rxq, in igb_configure_rx_ring()
4767 ring->count * sizeof(union e1000_adv_rx_desc)); in igb_configure_rx_ring()
4770 ring->tail = adapter->io_addr + E1000_RDT(reg_idx); in igb_configure_rx_ring()
4772 writel(0, ring->tail); in igb_configure_rx_ring()
4785 memset(ring->rx_buffer_info, 0, in igb_configure_rx_ring()
4786 sizeof(struct igb_rx_buffer) * ring->count); in igb_configure_rx_ring()
4790 rx_desc->wb.upper.length = 0; in igb_configure_rx_ring()
4801 struct e1000_hw *hw = &adapter->hw; in igb_set_rx_buffer_len()
4808 if (adapter->flags & IGB_FLAG_RX_LEGACY) in igb_set_rx_buffer_len()
4814 if (adapter->max_frame_size > IGB_MAX_FRAME_BUILD_SKB || in igb_set_rx_buffer_len()
4822 * igb_configure_rx - Configure receive Unit after Reset
4837 for (i = 0; i < adapter->num_rx_queues; i++) { in igb_configure_rx()
4838 struct igb_ring *rx_ring = adapter->rx_ring[i]; in igb_configure_rx()
4846 * igb_free_tx_resources - Free Tx Resources per Queue
4855 vfree(tx_ring->tx_buffer_info); in igb_free_tx_resources()
4856 tx_ring->tx_buffer_info = NULL; in igb_free_tx_resources()
4859 if (!tx_ring->desc) in igb_free_tx_resources()
4862 dma_free_coherent(tx_ring->dev, tx_ring->size, in igb_free_tx_resources()
4863 tx_ring->desc, tx_ring->dma); in igb_free_tx_resources()
4865 tx_ring->desc = NULL; in igb_free_tx_resources()
4869 * igb_free_all_tx_resources - Free Tx Resources for All Queues
4878 for (i = 0; i < adapter->num_tx_queues; i++) in igb_free_all_tx_resources()
4879 if (adapter->tx_ring[i]) in igb_free_all_tx_resources()
4880 igb_free_tx_resources(adapter->tx_ring[i]); in igb_free_all_tx_resources()
4884 * igb_clean_tx_ring - Free Tx Buffers
4889 u16 i = tx_ring->next_to_clean; in igb_clean_tx_ring()
4890 struct igb_tx_buffer *tx_buffer = &tx_ring->tx_buffer_info[i]; in igb_clean_tx_ring()
4892 while (i != tx_ring->next_to_use) { in igb_clean_tx_ring()
4896 if (tx_buffer->type == IGB_TYPE_SKB) in igb_clean_tx_ring()
4897 dev_kfree_skb_any(tx_buffer->skb); in igb_clean_tx_ring()
4899 xdp_return_frame(tx_buffer->xdpf); in igb_clean_tx_ring()
4902 dma_unmap_single(tx_ring->dev, in igb_clean_tx_ring()
4908 eop_desc = tx_buffer->next_to_watch; in igb_clean_tx_ring()
4916 if (unlikely(i == tx_ring->count)) { in igb_clean_tx_ring()
4918 tx_buffer = tx_ring->tx_buffer_info; in igb_clean_tx_ring()
4924 dma_unmap_page(tx_ring->dev, in igb_clean_tx_ring()
4930 tx_buffer->next_to_watch = NULL; in igb_clean_tx_ring()
4935 if (unlikely(i == tx_ring->count)) { in igb_clean_tx_ring()
4937 tx_buffer = tx_ring->tx_buffer_info; in igb_clean_tx_ring()
4945 tx_ring->next_to_use = 0; in igb_clean_tx_ring()
4946 tx_ring->next_to_clean = 0; in igb_clean_tx_ring()
4950 * igb_clean_all_tx_rings - Free Tx Buffers for all queues
4957 for (i = 0; i < adapter->num_tx_queues; i++) in igb_clean_all_tx_rings()
4958 if (adapter->tx_ring[i]) in igb_clean_all_tx_rings()
4959 igb_clean_tx_ring(adapter->tx_ring[i]); in igb_clean_all_tx_rings()
4963 * igb_free_rx_resources - Free Rx Resources
4972 rx_ring->xdp_prog = NULL; in igb_free_rx_resources()
4973 xdp_rxq_info_unreg(&rx_ring->xdp_rxq); in igb_free_rx_resources()
4974 vfree(rx_ring->rx_buffer_info); in igb_free_rx_resources()
4975 rx_ring->rx_buffer_info = NULL; in igb_free_rx_resources()
4978 if (!rx_ring->desc) in igb_free_rx_resources()
4981 dma_free_coherent(rx_ring->dev, rx_ring->size, in igb_free_rx_resources()
4982 rx_ring->desc, rx_ring->dma); in igb_free_rx_resources()
4984 rx_ring->desc = NULL; in igb_free_rx_resources()
4988 * igb_free_all_rx_resources - Free Rx Resources for All Queues
4997 for (i = 0; i < adapter->num_rx_queues; i++) in igb_free_all_rx_resources()
4998 if (adapter->rx_ring[i]) in igb_free_all_rx_resources()
4999 igb_free_rx_resources(adapter->rx_ring[i]); in igb_free_all_rx_resources()
5003 * igb_clean_rx_ring - Free Rx Buffers per Queue
5008 u16 i = rx_ring->next_to_clean; in igb_clean_rx_ring()
5010 dev_kfree_skb(rx_ring->skb); in igb_clean_rx_ring()
5011 rx_ring->skb = NULL; in igb_clean_rx_ring()
5014 while (i != rx_ring->next_to_alloc) { in igb_clean_rx_ring()
5015 struct igb_rx_buffer *buffer_info = &rx_ring->rx_buffer_info[i]; in igb_clean_rx_ring()
5020 dma_sync_single_range_for_cpu(rx_ring->dev, in igb_clean_rx_ring()
5021 buffer_info->dma, in igb_clean_rx_ring()
5022 buffer_info->page_offset, in igb_clean_rx_ring()
5027 dma_unmap_page_attrs(rx_ring->dev, in igb_clean_rx_ring()
5028 buffer_info->dma, in igb_clean_rx_ring()
5032 __page_frag_cache_drain(buffer_info->page, in igb_clean_rx_ring()
5033 buffer_info->pagecnt_bias); in igb_clean_rx_ring()
5036 if (i == rx_ring->count) in igb_clean_rx_ring()
5040 rx_ring->next_to_alloc = 0; in igb_clean_rx_ring()
5041 rx_ring->next_to_clean = 0; in igb_clean_rx_ring()
5042 rx_ring->next_to_use = 0; in igb_clean_rx_ring()
5046 * igb_clean_all_rx_rings - Free Rx Buffers for all queues
5053 for (i = 0; i < adapter->num_rx_queues; i++) in igb_clean_all_rx_rings()
5054 if (adapter->rx_ring[i]) in igb_clean_all_rx_rings()
5055 igb_clean_rx_ring(adapter->rx_ring[i]); in igb_clean_all_rx_rings()
5059 * igb_set_mac - Change the Ethernet Address of the NIC
5068 struct e1000_hw *hw = &adapter->hw; in igb_set_mac()
5071 if (!is_valid_ether_addr(addr->sa_data)) in igb_set_mac()
5072 return -EADDRNOTAVAIL; in igb_set_mac()
5074 eth_hw_addr_set(netdev, addr->sa_data); in igb_set_mac()
5075 memcpy(hw->mac.addr, addr->sa_data, netdev->addr_len); in igb_set_mac()
5084 * igb_write_mc_addr_list - write multicast addresses to MTA
5088 * Returns: -ENOMEM on failure
5095 struct e1000_hw *hw = &adapter->hw; in igb_write_mc_addr_list()
5109 return -ENOMEM; in igb_write_mc_addr_list()
5114 memcpy(mta_list + (i++ * ETH_ALEN), ha->addr, ETH_ALEN); in igb_write_mc_addr_list()
5124 struct e1000_hw *hw = &adapter->hw; in igb_vlan_promisc_enable()
5127 switch (hw->mac.type) { in igb_vlan_promisc_enable()
5132 if (adapter->netdev->features & NETIF_F_NTUPLE) in igb_vlan_promisc_enable()
5139 if (adapter->vfs_allocated_count) in igb_vlan_promisc_enable()
5147 if (adapter->flags & IGB_FLAG_VLAN_PROMISC) in igb_vlan_promisc_enable()
5150 if (!adapter->vfs_allocated_count) in igb_vlan_promisc_enable()
5154 pf_id = adapter->vfs_allocated_count + E1000_VLVF_POOLSEL_SHIFT; in igb_vlan_promisc_enable()
5156 for (i = E1000_VLVF_ARRAY_SIZE; --i;) { in igb_vlan_promisc_enable()
5165 for (i = E1000_VLAN_FILTER_TBL_SIZE; i--;) in igb_vlan_promisc_enable()
5166 hw->mac.ops.write_vfta(hw, i, ~0U); in igb_vlan_promisc_enable()
5169 adapter->flags |= IGB_FLAG_VLAN_PROMISC; in igb_vlan_promisc_enable()
5177 struct e1000_hw *hw = &adapter->hw; in igb_scrub_vfta()
5184 vid = adapter->mng_vlan_id; in igb_scrub_vfta()
5186 vfta[(vid - vid_start) / 32] |= BIT(vid % 32); in igb_scrub_vfta()
5188 if (!adapter->vfs_allocated_count) in igb_scrub_vfta()
5191 pf_id = adapter->vfs_allocated_count + E1000_VLVF_POOLSEL_SHIFT; in igb_scrub_vfta()
5193 for (i = E1000_VLVF_ARRAY_SIZE; --i;) { in igb_scrub_vfta()
5205 vfta[(vid - vid_start) / 32] |= BIT(vid % 32); in igb_scrub_vfta()
5208 if (test_bit(vid, adapter->active_vlans)) in igb_scrub_vfta()
5220 for (i = VFTA_BLOCK_SIZE; i--;) { in igb_scrub_vfta()
5225 vfta[i] |= adapter->active_vlans[word] >> bits; in igb_scrub_vfta()
5227 hw->mac.ops.write_vfta(hw, vfta_offset + i, vfta[i]); in igb_scrub_vfta()
5236 if (!(adapter->flags & IGB_FLAG_VLAN_PROMISC)) in igb_vlan_promisc_disable()
5240 adapter->flags &= ~IGB_FLAG_VLAN_PROMISC; in igb_vlan_promisc_disable()
5247 * igb_set_rx_mode - Secondary Unicast, Multicast and Promiscuous mode set
5253 * promiscuous mode, and all-multi behavior.
5258 struct e1000_hw *hw = &adapter->hw; in igb_set_rx_mode()
5259 unsigned int vfn = adapter->vfs_allocated_count; in igb_set_rx_mode()
5264 if (netdev->flags & IFF_PROMISC) { in igb_set_rx_mode()
5269 if (hw->mac.type == e1000_82576) in igb_set_rx_mode()
5272 if (netdev->flags & IFF_ALLMULTI) { in igb_set_rx_mode()
5303 if ((netdev->flags & IFF_PROMISC) || in igb_set_rx_mode()
5304 (netdev->features & NETIF_F_RXALL)) { in igb_set_rx_mode()
5318 if (!adapter->vfs_allocated_count) { in igb_set_rx_mode()
5319 if (adapter->max_frame_size <= IGB_MAX_FRAME_BUILD_SKB) in igb_set_rx_mode()
5325 /* In order to support SR-IOV and eventually VMDq it is necessary to set in igb_set_rx_mode()
5330 if ((hw->mac.type < e1000_82576) || (hw->mac.type > e1000_i350)) in igb_set_rx_mode()
5342 if (adapter->max_frame_size <= IGB_MAX_FRAME_BUILD_SKB) in igb_set_rx_mode()
5356 struct e1000_hw *hw = &adapter->hw; in igb_check_wvbr()
5359 switch (hw->mac.type) { in igb_check_wvbr()
5370 adapter->wvbr |= wvbr; in igb_check_wvbr()
5379 if (!adapter->wvbr) in igb_spoof_check()
5382 for (j = 0; j < adapter->vfs_allocated_count; j++) { in igb_spoof_check()
5383 if (adapter->wvbr & BIT(j) || in igb_spoof_check()
5384 adapter->wvbr & BIT(j + IGB_STAGGERED_QUEUE_OFFSET)) { in igb_spoof_check()
5385 dev_warn(&adapter->pdev->dev, in igb_spoof_check()
5387 adapter->wvbr &= in igb_spoof_check()
5400 igb_get_phy_info(&adapter->hw); in igb_update_phy_info()
5404 * igb_has_link - check shared code for link and determine up/down
5409 struct e1000_hw *hw = &adapter->hw; in igb_has_link()
5417 switch (hw->phy.media_type) { in igb_has_link()
5419 if (!hw->mac.get_link_status) in igb_has_link()
5423 hw->mac.ops.check_for_link(hw); in igb_has_link()
5424 link_active = !hw->mac.get_link_status; in igb_has_link()
5431 if (((hw->mac.type == e1000_i210) || in igb_has_link()
5432 (hw->mac.type == e1000_i211)) && in igb_has_link()
5433 (hw->phy.id == I210_I_PHY_ID)) { in igb_has_link()
5434 if (!netif_carrier_ok(adapter->netdev)) { in igb_has_link()
5435 adapter->flags &= ~IGB_FLAG_NEED_LINK_UPDATE; in igb_has_link()
5436 } else if (!(adapter->flags & IGB_FLAG_NEED_LINK_UPDATE)) { in igb_has_link()
5437 adapter->flags |= IGB_FLAG_NEED_LINK_UPDATE; in igb_has_link()
5438 adapter->link_check_timeout = jiffies; in igb_has_link()
5451 if (hw->mac.type == e1000_i350) { in igb_thermal_sensor_event()
5455 if ((hw->phy.media_type == e1000_media_type_copper) && in igb_thermal_sensor_event()
5464 * igb_check_lvmmc - check for malformed packets received
5470 struct e1000_hw *hw = &adapter->hw; in igb_check_lvmmc()
5476 netdev_warn(adapter->netdev, in igb_check_lvmmc()
5484 * igb_watchdog - Timer Call-back
5491 schedule_work(&adapter->watchdog_task); in igb_watchdog()
5499 struct e1000_hw *hw = &adapter->hw; in igb_watchdog_task()
5500 struct e1000_phy_info *phy = &hw->phy; in igb_watchdog_task()
5501 struct net_device *netdev = adapter->netdev; in igb_watchdog_task()
5509 if (adapter->flags & IGB_FLAG_NEED_LINK_UPDATE) { in igb_watchdog_task()
5510 if (time_after(jiffies, (adapter->link_check_timeout + HZ))) in igb_watchdog_task()
5511 adapter->flags &= ~IGB_FLAG_NEED_LINK_UPDATE; in igb_watchdog_task()
5517 if (adapter->flags & IGB_FLAG_MAS_ENABLE) { in igb_watchdog_task()
5518 if (hw->phy.media_type == e1000_media_type_copper) { in igb_watchdog_task()
5526 if (hw->dev_spec._82575.media_changed) { in igb_watchdog_task()
5527 hw->dev_spec._82575.media_changed = false; in igb_watchdog_task()
5528 adapter->flags |= IGB_FLAG_MEDIA_RESET; in igb_watchdog_task()
5532 pm_runtime_resume(netdev->dev.parent); in igb_watchdog_task()
5537 hw->mac.ops.get_speed_and_duplex(hw, in igb_watchdog_task()
5538 &adapter->link_speed, in igb_watchdog_task()
5539 &adapter->link_duplex); in igb_watchdog_task()
5545 netdev->name, in igb_watchdog_task()
5546 adapter->link_speed, in igb_watchdog_task()
5547 adapter->link_duplex == FULL_DUPLEX ? in igb_watchdog_task()
5555 if ((adapter->flags & IGB_FLAG_EEE) && in igb_watchdog_task()
5556 (adapter->link_duplex == HALF_DUPLEX)) { in igb_watchdog_task()
5557 dev_info(&adapter->pdev->dev, in igb_watchdog_task()
5558 "EEE Disabled: unsupported at half duplex. Re-enable using ethtool when at full duplex.\n"); in igb_watchdog_task()
5559 adapter->hw.dev_spec._82575.eee_disable = true; in igb_watchdog_task()
5560 adapter->flags &= ~IGB_FLAG_EEE; in igb_watchdog_task()
5565 if (phy->speed_downgraded) in igb_watchdog_task()
5574 adapter->tx_timeout_factor = 1; in igb_watchdog_task()
5575 switch (adapter->link_speed) { in igb_watchdog_task()
5577 adapter->tx_timeout_factor = 14; in igb_watchdog_task()
5584 if (adapter->link_speed != SPEED_1000 || in igb_watchdog_task()
5585 !hw->phy.ops.read_reg) in igb_watchdog_task()
5595 retry_count--; in igb_watchdog_task()
5598 dev_err(&adapter->pdev->dev, "exceed max 2 second\n"); in igb_watchdog_task()
5601 dev_err(&adapter->pdev->dev, "read 1000Base-T Status Reg\n"); in igb_watchdog_task()
5610 if (!test_bit(__IGB_DOWN, &adapter->state)) in igb_watchdog_task()
5611 mod_timer(&adapter->phy_info_timer, in igb_watchdog_task()
5616 adapter->link_speed = 0; in igb_watchdog_task()
5617 adapter->link_duplex = 0; in igb_watchdog_task()
5627 netdev->name); in igb_watchdog_task()
5633 if (!test_bit(__IGB_DOWN, &adapter->state)) in igb_watchdog_task()
5634 mod_timer(&adapter->phy_info_timer, in igb_watchdog_task()
5638 if (adapter->flags & IGB_FLAG_MAS_ENABLE) { in igb_watchdog_task()
5640 if (adapter->flags & IGB_FLAG_MEDIA_RESET) { in igb_watchdog_task()
5641 schedule_work(&adapter->reset_task); in igb_watchdog_task()
5646 pm_schedule_suspend(netdev->dev.parent, in igb_watchdog_task()
5651 (adapter->flags & IGB_FLAG_MAS_ENABLE)) { in igb_watchdog_task()
5653 if (adapter->flags & IGB_FLAG_MEDIA_RESET) { in igb_watchdog_task()
5654 schedule_work(&adapter->reset_task); in igb_watchdog_task()
5661 spin_lock(&adapter->stats64_lock); in igb_watchdog_task()
5663 spin_unlock(&adapter->stats64_lock); in igb_watchdog_task()
5665 for (i = 0; i < adapter->num_tx_queues; i++) { in igb_watchdog_task()
5666 struct igb_ring *tx_ring = adapter->tx_ring[i]; in igb_watchdog_task()
5673 if (igb_desc_unused(tx_ring) + 1 < tx_ring->count) { in igb_watchdog_task()
5674 adapter->tx_timeout_count++; in igb_watchdog_task()
5675 schedule_work(&adapter->reset_task); in igb_watchdog_task()
5682 set_bit(IGB_RING_FLAG_TX_DETECT_HANG, &tx_ring->flags); in igb_watchdog_task()
5686 if (adapter->flags & IGB_FLAG_HAS_MSIX) { in igb_watchdog_task()
5689 for (i = 0; i < adapter->num_q_vectors; i++) in igb_watchdog_task()
5690 eics |= adapter->q_vector[i]->eims_value; in igb_watchdog_task()
5701 if ((adapter->hw.mac.type == e1000_i350) || in igb_watchdog_task()
5702 (adapter->hw.mac.type == e1000_i354)) in igb_watchdog_task()
5706 if (!test_bit(__IGB_DOWN, &adapter->state)) { in igb_watchdog_task()
5707 if (adapter->flags & IGB_FLAG_NEED_LINK_UPDATE) in igb_watchdog_task()
5708 mod_timer(&adapter->watchdog_timer, in igb_watchdog_task()
5711 mod_timer(&adapter->watchdog_timer, in igb_watchdog_task()
5724 * igb_update_ring_itr - update the dynamic ITR value based on packet size
5740 int new_val = q_vector->itr_val; in igb_update_ring_itr()
5742 struct igb_adapter *adapter = q_vector->adapter; in igb_update_ring_itr()
5745 /* For non-gigabit speeds, just fix the interrupt rate at 4000 in igb_update_ring_itr()
5746 * ints/sec - ITR timer value of 120 ticks. in igb_update_ring_itr()
5748 if (adapter->link_speed != SPEED_1000) { in igb_update_ring_itr()
5753 packets = q_vector->rx.total_packets; in igb_update_ring_itr()
5755 avg_wire_size = q_vector->rx.total_bytes / packets; in igb_update_ring_itr()
5757 packets = q_vector->tx.total_packets; in igb_update_ring_itr()
5760 q_vector->tx.total_bytes / packets); in igb_update_ring_itr()
5772 /* Give a little boost to mid-size frames */ in igb_update_ring_itr()
5780 ((q_vector->rx.ring && adapter->rx_itr_setting == 3) || in igb_update_ring_itr()
5781 (!q_vector->rx.ring && adapter->tx_itr_setting == 3))) in igb_update_ring_itr()
5785 if (new_val != q_vector->itr_val) { in igb_update_ring_itr()
5786 q_vector->itr_val = new_val; in igb_update_ring_itr()
5787 q_vector->set_itr = 1; in igb_update_ring_itr()
5790 q_vector->rx.total_bytes = 0; in igb_update_ring_itr()
5791 q_vector->rx.total_packets = 0; in igb_update_ring_itr()
5792 q_vector->tx.total_bytes = 0; in igb_update_ring_itr()
5793 q_vector->tx.total_packets = 0; in igb_update_ring_itr()
5797 * igb_update_itr - update the dynamic ITR value based on statistics
5809 * NOTE: These calculations are only valid when operating in a single-
5815 unsigned int packets = ring_container->total_packets; in igb_update_itr()
5816 unsigned int bytes = ring_container->total_bytes; in igb_update_itr()
5817 u8 itrval = ring_container->itr; in igb_update_itr()
5857 ring_container->total_bytes = 0; in igb_update_itr()
5858 ring_container->total_packets = 0; in igb_update_itr()
5861 ring_container->itr = itrval; in igb_update_itr()
5866 struct igb_adapter *adapter = q_vector->adapter; in igb_set_itr()
5867 u32 new_itr = q_vector->itr_val; in igb_set_itr()
5870 /* for non-gigabit speeds, just fix the interrupt rate at 4000 */ in igb_set_itr()
5871 if (adapter->link_speed != SPEED_1000) { in igb_set_itr()
5877 igb_update_itr(q_vector, &q_vector->tx); in igb_set_itr()
5878 igb_update_itr(q_vector, &q_vector->rx); in igb_set_itr()
5880 current_itr = max(q_vector->rx.itr, q_vector->tx.itr); in igb_set_itr()
5884 ((q_vector->rx.ring && adapter->rx_itr_setting == 3) || in igb_set_itr()
5885 (!q_vector->rx.ring && adapter->tx_itr_setting == 3))) in igb_set_itr()
5904 if (new_itr != q_vector->itr_val) { in igb_set_itr()
5909 new_itr = new_itr > q_vector->itr_val ? in igb_set_itr()
5910 max((new_itr * q_vector->itr_val) / in igb_set_itr()
5911 (new_itr + (q_vector->itr_val >> 2)), in igb_set_itr()
5919 q_vector->itr_val = new_itr; in igb_set_itr()
5920 q_vector->set_itr = 1; in igb_set_itr()
5930 u16 i = tx_ring->next_to_use; in igb_tx_ctxtdesc()
5936 tx_ring->next_to_use = (i < tx_ring->count) ? i : 0; in igb_tx_ctxtdesc()
5942 if (test_bit(IGB_RING_FLAG_TX_CTX_IDX, &tx_ring->flags)) in igb_tx_ctxtdesc()
5943 mss_l4len_idx |= tx_ring->reg_idx << 4; in igb_tx_ctxtdesc()
5945 context_desc->vlan_macip_lens = cpu_to_le32(vlan_macip_lens); in igb_tx_ctxtdesc()
5946 context_desc->type_tucmd_mlhl = cpu_to_le32(type_tucmd); in igb_tx_ctxtdesc()
5947 context_desc->mss_l4len_idx = cpu_to_le32(mss_l4len_idx); in igb_tx_ctxtdesc()
5952 if (tx_ring->launchtime_enable) { in igb_tx_ctxtdesc()
5953 ts = ktime_to_timespec64(first->skb->tstamp); in igb_tx_ctxtdesc()
5954 skb_txtime_consumed(first->skb); in igb_tx_ctxtdesc()
5955 context_desc->seqnum_seed = cpu_to_le32(ts.tv_nsec / 32); in igb_tx_ctxtdesc()
5957 context_desc->seqnum_seed = 0; in igb_tx_ctxtdesc()
5966 struct sk_buff *skb = first->skb; in igb_tso()
5980 if (skb->ip_summed != CHECKSUM_PARTIAL) in igb_tso()
5994 type_tucmd = (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) ? in igb_tso()
5998 if (ip.v4->version == 4) { in igb_tso()
6000 unsigned char *trans_start = ip.hdr + (ip.v4->ihl * 4); in igb_tso()
6005 ip.v4->check = csum_fold(csum_partial(trans_start, in igb_tso()
6006 csum_start - trans_start, in igb_tso()
6010 ip.v4->tot_len = 0; in igb_tso()
6011 first->tx_flags |= IGB_TX_FLAGS_TSO | in igb_tso()
6015 ip.v6->payload_len = 0; in igb_tso()
6016 first->tx_flags |= IGB_TX_FLAGS_TSO | in igb_tso()
6021 l4_offset = l4.hdr - skb->data; in igb_tso()
6024 paylen = skb->len - l4_offset; in igb_tso()
6027 *hdr_len = (l4.tcp->doff * 4) + l4_offset; in igb_tso()
6028 csum_replace_by_diff(&l4.tcp->check, in igb_tso()
6033 csum_replace_by_diff(&l4.udp->check, in igb_tso()
6038 first->gso_segs = skb_shinfo(skb)->gso_segs; in igb_tso()
6039 first->bytecount += (first->gso_segs - 1) * *hdr_len; in igb_tso()
6042 mss_l4len_idx = (*hdr_len - l4_offset) << E1000_ADVTXD_L4LEN_SHIFT; in igb_tso()
6043 mss_l4len_idx |= skb_shinfo(skb)->gso_size << E1000_ADVTXD_MSS_SHIFT; in igb_tso()
6046 vlan_macip_lens = l4.hdr - ip.hdr; in igb_tso()
6047 vlan_macip_lens |= (ip.hdr - skb->data) << E1000_ADVTXD_MACLEN_SHIFT; in igb_tso()
6048 vlan_macip_lens |= first->tx_flags & IGB_TX_FLAGS_VLAN_MASK; in igb_tso()
6058 struct sk_buff *skb = first->skb; in igb_tx_csum()
6062 if (skb->ip_summed != CHECKSUM_PARTIAL) { in igb_tx_csum()
6064 if (!(first->tx_flags & IGB_TX_FLAGS_VLAN) && in igb_tx_csum()
6065 !tx_ring->launchtime_enable) in igb_tx_csum()
6070 switch (skb->csum_offset) { in igb_tx_csum()
6089 first->tx_flags |= IGB_TX_FLAGS_CSUM; in igb_tx_csum()
6090 vlan_macip_lens = skb_checksum_start_offset(skb) - in igb_tx_csum()
6094 vlan_macip_lens |= first->tx_flags & IGB_TX_FLAGS_VLAN_MASK; in igb_tx_csum()
6124 cmd_type ^= IGB_SET_FLAG(skb->no_fcs, 1, E1000_ADVTXD_DCMD_IFCS); in igb_tx_cmd_type()
6136 if (test_bit(IGB_RING_FLAG_TX_CTX_IDX, &tx_ring->flags)) in igb_tx_olinfo_status()
6137 olinfo_status |= tx_ring->reg_idx << 4; in igb_tx_olinfo_status()
6149 tx_desc->read.olinfo_status = cpu_to_le32(olinfo_status); in igb_tx_olinfo_status()
6154 struct net_device *netdev = tx_ring->netdev; in __igb_maybe_stop_tx()
6156 netif_stop_subqueue(netdev, tx_ring->queue_index); in __igb_maybe_stop_tx()
6168 return -EBUSY; in __igb_maybe_stop_tx()
6171 netif_wake_subqueue(netdev, tx_ring->queue_index); in __igb_maybe_stop_tx()
6173 u64_stats_update_begin(&tx_ring->tx_syncp2); in __igb_maybe_stop_tx()
6174 tx_ring->tx_stats.restart_queue2++; in __igb_maybe_stop_tx()
6175 u64_stats_update_end(&tx_ring->tx_syncp2); in __igb_maybe_stop_tx()
6191 struct sk_buff *skb = first->skb; in igb_tx_map()
6197 u32 tx_flags = first->tx_flags; in igb_tx_map()
6199 u16 i = tx_ring->next_to_use; in igb_tx_map()
6203 igb_tx_olinfo_status(tx_ring, tx_desc, tx_flags, skb->len - hdr_len); in igb_tx_map()
6206 data_len = skb->data_len; in igb_tx_map()
6208 dma = dma_map_single(tx_ring->dev, skb->data, size, DMA_TO_DEVICE); in igb_tx_map()
6212 for (frag = &skb_shinfo(skb)->frags[0];; frag++) { in igb_tx_map()
6213 if (dma_mapping_error(tx_ring->dev, dma)) in igb_tx_map()
6220 tx_desc->read.buffer_addr = cpu_to_le64(dma); in igb_tx_map()
6223 tx_desc->read.cmd_type_len = in igb_tx_map()
6228 if (i == tx_ring->count) { in igb_tx_map()
6232 tx_desc->read.olinfo_status = 0; in igb_tx_map()
6235 size -= IGB_MAX_DATA_PER_TXD; in igb_tx_map()
6237 tx_desc->read.buffer_addr = cpu_to_le64(dma); in igb_tx_map()
6243 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type ^ size); in igb_tx_map()
6247 if (i == tx_ring->count) { in igb_tx_map()
6251 tx_desc->read.olinfo_status = 0; in igb_tx_map()
6254 data_len -= size; in igb_tx_map()
6256 dma = skb_frag_dma_map(tx_ring->dev, frag, 0, in igb_tx_map()
6259 tx_buffer = &tx_ring->tx_buffer_info[i]; in igb_tx_map()
6264 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type); in igb_tx_map()
6266 netdev_tx_sent_queue(txring_txq(tx_ring), first->bytecount); in igb_tx_map()
6269 first->time_stamp = jiffies; in igb_tx_map()
6274 * are new descriptors to fetch. (Only applicable for weak-ordered in igb_tx_map()
6275 * memory model archs, such as IA-64). in igb_tx_map()
6283 first->next_to_watch = tx_desc; in igb_tx_map()
6286 if (i == tx_ring->count) in igb_tx_map()
6289 tx_ring->next_to_use = i; in igb_tx_map()
6295 writel(i, tx_ring->tail); in igb_tx_map()
6300 dev_err(tx_ring->dev, "TX DMA map failed\n"); in igb_tx_map()
6301 tx_buffer = &tx_ring->tx_buffer_info[i]; in igb_tx_map()
6306 dma_unmap_page(tx_ring->dev, in igb_tx_map()
6312 if (i-- == 0) in igb_tx_map()
6313 i += tx_ring->count; in igb_tx_map()
6314 tx_buffer = &tx_ring->tx_buffer_info[i]; in igb_tx_map()
6318 dma_unmap_single(tx_ring->dev, in igb_tx_map()
6324 dev_kfree_skb_any(tx_buffer->skb); in igb_tx_map()
6325 tx_buffer->skb = NULL; in igb_tx_map()
6327 tx_ring->next_to_use = i; in igb_tx_map()
6329 return -1; in igb_tx_map()
6337 u8 nr_frags = unlikely(xdp_frame_has_frags(xdpf)) ? sinfo->nr_frags : 0; in igb_xmit_xdp_ring()
6338 u16 count, i, index = tx_ring->next_to_use; in igb_xmit_xdp_ring()
6339 struct igb_tx_buffer *tx_head = &tx_ring->tx_buffer_info[index]; in igb_xmit_xdp_ring()
6342 u32 len = xdpf->len, cmd_type, olinfo_status; in igb_xmit_xdp_ring()
6343 void *data = xdpf->data; in igb_xmit_xdp_ring()
6347 count += TXD_USE_COUNT(skb_frag_size(&sinfo->frags[i])); in igb_xmit_xdp_ring()
6354 tx_head->bytecount = xdp_get_frame_len(xdpf); in igb_xmit_xdp_ring()
6355 tx_head->type = IGB_TYPE_XDP; in igb_xmit_xdp_ring()
6356 tx_head->gso_segs = 1; in igb_xmit_xdp_ring()
6357 tx_head->xdpf = xdpf; in igb_xmit_xdp_ring()
6359 olinfo_status = tx_head->bytecount << E1000_ADVTXD_PAYLEN_SHIFT; in igb_xmit_xdp_ring()
6361 if (test_bit(IGB_RING_FLAG_TX_CTX_IDX, &tx_ring->flags)) in igb_xmit_xdp_ring()
6362 olinfo_status |= tx_ring->reg_idx << 4; in igb_xmit_xdp_ring()
6363 tx_desc->read.olinfo_status = cpu_to_le32(olinfo_status); in igb_xmit_xdp_ring()
6368 dma = dma_map_single(tx_ring->dev, data, len, DMA_TO_DEVICE); in igb_xmit_xdp_ring()
6369 if (dma_mapping_error(tx_ring->dev, dma)) in igb_xmit_xdp_ring()
6380 tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type); in igb_xmit_xdp_ring()
6381 tx_desc->read.buffer_addr = cpu_to_le64(dma); in igb_xmit_xdp_ring()
6383 tx_buffer->protocol = 0; in igb_xmit_xdp_ring()
6385 if (++index == tx_ring->count) in igb_xmit_xdp_ring()
6391 tx_buffer = &tx_ring->tx_buffer_info[index]; in igb_xmit_xdp_ring()
6393 tx_desc->read.olinfo_status = 0; in igb_xmit_xdp_ring()
6395 data = skb_frag_address(&sinfo->frags[i]); in igb_xmit_xdp_ring()
6396 len = skb_frag_size(&sinfo->frags[i]); in igb_xmit_xdp_ring()
6399 tx_desc->read.cmd_type_len |= cpu_to_le32(IGB_TXD_DCMD); in igb_xmit_xdp_ring()
6401 netdev_tx_sent_queue(txring_txq(tx_ring), tx_head->bytecount); in igb_xmit_xdp_ring()
6403 tx_head->time_stamp = jiffies; in igb_xmit_xdp_ring()
6409 tx_head->next_to_watch = tx_desc; in igb_xmit_xdp_ring()
6410 tx_ring->next_to_use = index; in igb_xmit_xdp_ring()
6416 writel(index, tx_ring->tail); in igb_xmit_xdp_ring()
6422 tx_buffer = &tx_ring->tx_buffer_info[index]; in igb_xmit_xdp_ring()
6424 dma_unmap_page(tx_ring->dev, in igb_xmit_xdp_ring()
6433 index += tx_ring->count; in igb_xmit_xdp_ring()
6434 index--; in igb_xmit_xdp_ring()
6457 for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) in igb_xmit_frame_ring()
6459 &skb_shinfo(skb)->frags[f])); in igb_xmit_frame_ring()
6467 first = &tx_ring->tx_buffer_info[tx_ring->next_to_use]; in igb_xmit_frame_ring()
6468 first->type = IGB_TYPE_SKB; in igb_xmit_frame_ring()
6469 first->skb = skb; in igb_xmit_frame_ring()
6470 first->bytecount = skb->len; in igb_xmit_frame_ring()
6471 first->gso_segs = 1; in igb_xmit_frame_ring()
6473 if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) { in igb_xmit_frame_ring()
6474 struct igb_adapter *adapter = netdev_priv(tx_ring->netdev); in igb_xmit_frame_ring()
6476 if (adapter->tstamp_config.tx_type == HWTSTAMP_TX_ON && in igb_xmit_frame_ring()
6478 &adapter->state)) { in igb_xmit_frame_ring()
6479 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; in igb_xmit_frame_ring()
6482 adapter->ptp_tx_skb = skb_get(skb); in igb_xmit_frame_ring()
6483 adapter->ptp_tx_start = jiffies; in igb_xmit_frame_ring()
6484 if (adapter->hw.mac.type == e1000_82576) in igb_xmit_frame_ring()
6485 schedule_work(&adapter->ptp_tx_work); in igb_xmit_frame_ring()
6487 adapter->tx_hwtstamp_skipped++; in igb_xmit_frame_ring()
6497 first->tx_flags = tx_flags; in igb_xmit_frame_ring()
6498 first->protocol = protocol; in igb_xmit_frame_ring()
6512 dev_kfree_skb_any(first->skb); in igb_xmit_frame_ring()
6513 first->skb = NULL; in igb_xmit_frame_ring()
6516 struct igb_adapter *adapter = netdev_priv(tx_ring->netdev); in igb_xmit_frame_ring()
6518 dev_kfree_skb_any(adapter->ptp_tx_skb); in igb_xmit_frame_ring()
6519 adapter->ptp_tx_skb = NULL; in igb_xmit_frame_ring()
6520 if (adapter->hw.mac.type == e1000_82576) in igb_xmit_frame_ring()
6521 cancel_work_sync(&adapter->ptp_tx_work); in igb_xmit_frame_ring()
6522 clear_bit_unlock(__IGB_PTP_TX_IN_PROGRESS, &adapter->state); in igb_xmit_frame_ring()
6531 unsigned int r_idx = skb->queue_mapping; in igb_tx_queue_mapping()
6533 if (r_idx >= adapter->num_tx_queues) in igb_tx_queue_mapping()
6534 r_idx = r_idx % adapter->num_tx_queues; in igb_tx_queue_mapping()
6536 return adapter->tx_ring[r_idx]; in igb_tx_queue_mapping()
6554 * igb_tx_timeout - Respond to a Tx Hang
6561 struct e1000_hw *hw = &adapter->hw; in igb_tx_timeout()
6564 adapter->tx_timeout_count++; in igb_tx_timeout()
6566 if (hw->mac.type >= e1000_82580) in igb_tx_timeout()
6567 hw->dev_spec._82575.global_device_reset = true; in igb_tx_timeout()
6569 schedule_work(&adapter->reset_task); in igb_tx_timeout()
6571 (adapter->eims_enable_mask & ~adapter->eims_other)); in igb_tx_timeout()
6581 if (test_bit(__IGB_DOWN, &adapter->state) || in igb_reset_task()
6582 test_bit(__IGB_RESETTING, &adapter->state)) { in igb_reset_task()
6588 netdev_err(adapter->netdev, "Reset adapter\n"); in igb_reset_task()
6594 * igb_get_stats64 - Get System Network Statistics
6603 spin_lock(&adapter->stats64_lock); in igb_get_stats64()
6605 memcpy(stats, &adapter->stats64, sizeof(*stats)); in igb_get_stats64()
6606 spin_unlock(&adapter->stats64_lock); in igb_get_stats64()
6610 * igb_change_mtu - Change the Maximum Transfer Unit
6621 if (adapter->xdp_prog) { in igb_change_mtu()
6624 for (i = 0; i < adapter->num_rx_queues; i++) { in igb_change_mtu()
6625 struct igb_ring *ring = adapter->rx_ring[i]; in igb_change_mtu()
6628 netdev_warn(adapter->netdev, in igb_change_mtu()
6631 return -EINVAL; in igb_change_mtu()
6640 while (test_and_set_bit(__IGB_RESETTING, &adapter->state)) in igb_change_mtu()
6644 adapter->max_frame_size = max_frame; in igb_change_mtu()
6650 netdev->mtu, new_mtu); in igb_change_mtu()
6651 WRITE_ONCE(netdev->mtu, new_mtu); in igb_change_mtu()
6658 clear_bit(__IGB_RESETTING, &adapter->state); in igb_change_mtu()
6664 * igb_update_stats - Update the board statistics counters
6669 struct rtnl_link_stats64 *net_stats = &adapter->stats64; in igb_update_stats()
6670 struct e1000_hw *hw = &adapter->hw; in igb_update_stats()
6671 struct pci_dev *pdev = adapter->pdev; in igb_update_stats()
6681 if (adapter->link_speed == 0) in igb_update_stats()
6690 for (i = 0; i < adapter->num_rx_queues; i++) { in igb_update_stats()
6691 struct igb_ring *ring = adapter->rx_ring[i]; in igb_update_stats()
6693 if (hw->mac.type >= e1000_i210) in igb_update_stats()
6697 ring->rx_stats.drops += rqdpc; in igb_update_stats()
6698 net_stats->rx_fifo_errors += rqdpc; in igb_update_stats()
6702 start = u64_stats_fetch_begin(&ring->rx_syncp); in igb_update_stats()
6703 _bytes = ring->rx_stats.bytes; in igb_update_stats()
6704 _packets = ring->rx_stats.packets; in igb_update_stats()
6705 } while (u64_stats_fetch_retry(&ring->rx_syncp, start)); in igb_update_stats()
6710 net_stats->rx_bytes = bytes; in igb_update_stats()
6711 net_stats->rx_packets = packets; in igb_update_stats()
6715 for (i = 0; i < adapter->num_tx_queues; i++) { in igb_update_stats()
6716 struct igb_ring *ring = adapter->tx_ring[i]; in igb_update_stats()
6718 start = u64_stats_fetch_begin(&ring->tx_syncp); in igb_update_stats()
6719 _bytes = ring->tx_stats.bytes; in igb_update_stats()
6720 _packets = ring->tx_stats.packets; in igb_update_stats()
6721 } while (u64_stats_fetch_retry(&ring->tx_syncp, start)); in igb_update_stats()
6725 net_stats->tx_bytes = bytes; in igb_update_stats()
6726 net_stats->tx_packets = packets; in igb_update_stats()
6730 adapter->stats.crcerrs += rd32(E1000_CRCERRS); in igb_update_stats()
6731 adapter->stats.gprc += rd32(E1000_GPRC); in igb_update_stats()
6732 adapter->stats.gorc += rd32(E1000_GORCL); in igb_update_stats()
6734 adapter->stats.bprc += rd32(E1000_BPRC); in igb_update_stats()
6735 adapter->stats.mprc += rd32(E1000_MPRC); in igb_update_stats()
6736 adapter->stats.roc += rd32(E1000_ROC); in igb_update_stats()
6738 adapter->stats.prc64 += rd32(E1000_PRC64); in igb_update_stats()
6739 adapter->stats.prc127 += rd32(E1000_PRC127); in igb_update_stats()
6740 adapter->stats.prc255 += rd32(E1000_PRC255); in igb_update_stats()
6741 adapter->stats.prc511 += rd32(E1000_PRC511); in igb_update_stats()
6742 adapter->stats.prc1023 += rd32(E1000_PRC1023); in igb_update_stats()
6743 adapter->stats.prc1522 += rd32(E1000_PRC1522); in igb_update_stats()
6744 adapter->stats.symerrs += rd32(E1000_SYMERRS); in igb_update_stats()
6745 adapter->stats.sec += rd32(E1000_SEC); in igb_update_stats()
6748 adapter->stats.mpc += mpc; in igb_update_stats()
6749 net_stats->rx_fifo_errors += mpc; in igb_update_stats()
6750 adapter->stats.scc += rd32(E1000_SCC); in igb_update_stats()
6751 adapter->stats.ecol += rd32(E1000_ECOL); in igb_update_stats()
6752 adapter->stats.mcc += rd32(E1000_MCC); in igb_update_stats()
6753 adapter->stats.latecol += rd32(E1000_LATECOL); in igb_update_stats()
6754 adapter->stats.dc += rd32(E1000_DC); in igb_update_stats()
6755 adapter->stats.rlec += rd32(E1000_RLEC); in igb_update_stats()
6756 adapter->stats.xonrxc += rd32(E1000_XONRXC); in igb_update_stats()
6757 adapter->stats.xontxc += rd32(E1000_XONTXC); in igb_update_stats()
6758 adapter->stats.xoffrxc += rd32(E1000_XOFFRXC); in igb_update_stats()
6759 adapter->stats.xofftxc += rd32(E1000_XOFFTXC); in igb_update_stats()
6760 adapter->stats.fcruc += rd32(E1000_FCRUC); in igb_update_stats()
6761 adapter->stats.gptc += rd32(E1000_GPTC); in igb_update_stats()
6762 adapter->stats.gotc += rd32(E1000_GOTCL); in igb_update_stats()
6764 adapter->stats.rnbc += rd32(E1000_RNBC); in igb_update_stats()
6765 adapter->stats.ruc += rd32(E1000_RUC); in igb_update_stats()
6766 adapter->stats.rfc += rd32(E1000_RFC); in igb_update_stats()
6767 adapter->stats.rjc += rd32(E1000_RJC); in igb_update_stats()
6768 adapter->stats.tor += rd32(E1000_TORH); in igb_update_stats()
6769 adapter->stats.tot += rd32(E1000_TOTH); in igb_update_stats()
6770 adapter->stats.tpr += rd32(E1000_TPR); in igb_update_stats()
6772 adapter->stats.ptc64 += rd32(E1000_PTC64); in igb_update_stats()
6773 adapter->stats.ptc127 += rd32(E1000_PTC127); in igb_update_stats()
6774 adapter->stats.ptc255 += rd32(E1000_PTC255); in igb_update_stats()
6775 adapter->stats.ptc511 += rd32(E1000_PTC511); in igb_update_stats()
6776 adapter->stats.ptc1023 += rd32(E1000_PTC1023); in igb_update_stats()
6777 adapter->stats.ptc1522 += rd32(E1000_PTC1522); in igb_update_stats()
6779 adapter->stats.mptc += rd32(E1000_MPTC); in igb_update_stats()
6780 adapter->stats.bptc += rd32(E1000_BPTC); in igb_update_stats()
6782 adapter->stats.tpt += rd32(E1000_TPT); in igb_update_stats()
6783 adapter->stats.colc += rd32(E1000_COLC); in igb_update_stats()
6785 adapter->stats.algnerrc += rd32(E1000_ALGNERRC); in igb_update_stats()
6789 adapter->stats.rxerrc += rd32(E1000_RXERRC); in igb_update_stats()
6792 if ((hw->mac.type != e1000_i210) && in igb_update_stats()
6793 (hw->mac.type != e1000_i211)) in igb_update_stats()
6794 adapter->stats.tncrs += rd32(E1000_TNCRS); in igb_update_stats()
6797 adapter->stats.tsctc += rd32(E1000_TSCTC); in igb_update_stats()
6798 adapter->stats.tsctfc += rd32(E1000_TSCTFC); in igb_update_stats()
6800 adapter->stats.iac += rd32(E1000_IAC); in igb_update_stats()
6801 adapter->stats.icrxoc += rd32(E1000_ICRXOC); in igb_update_stats()
6802 adapter->stats.icrxptc += rd32(E1000_ICRXPTC); in igb_update_stats()
6803 adapter->stats.icrxatc += rd32(E1000_ICRXATC); in igb_update_stats()
6804 adapter->stats.ictxptc += rd32(E1000_ICTXPTC); in igb_update_stats()
6805 adapter->stats.ictxatc += rd32(E1000_ICTXATC); in igb_update_stats()
6806 adapter->stats.ictxqec += rd32(E1000_ICTXQEC); in igb_update_stats()
6807 adapter->stats.ictxqmtc += rd32(E1000_ICTXQMTC); in igb_update_stats()
6808 adapter->stats.icrxdmtc += rd32(E1000_ICRXDMTC); in igb_update_stats()
6811 net_stats->multicast = adapter->stats.mprc; in igb_update_stats()
6812 net_stats->collisions = adapter->stats.colc; in igb_update_stats()
6819 net_stats->rx_errors = adapter->stats.rxerrc + in igb_update_stats()
6820 adapter->stats.crcerrs + adapter->stats.algnerrc + in igb_update_stats()
6821 adapter->stats.ruc + adapter->stats.roc + in igb_update_stats()
6822 adapter->stats.cexterr; in igb_update_stats()
6823 net_stats->rx_length_errors = adapter->stats.ruc + in igb_update_stats()
6824 adapter->stats.roc; in igb_update_stats()
6825 net_stats->rx_crc_errors = adapter->stats.crcerrs; in igb_update_stats()
6826 net_stats->rx_frame_errors = adapter->stats.algnerrc; in igb_update_stats()
6827 net_stats->rx_missed_errors = adapter->stats.mpc; in igb_update_stats()
6830 net_stats->tx_errors = adapter->stats.ecol + in igb_update_stats()
6831 adapter->stats.latecol; in igb_update_stats()
6832 net_stats->tx_aborted_errors = adapter->stats.ecol; in igb_update_stats()
6833 net_stats->tx_window_errors = adapter->stats.latecol; in igb_update_stats()
6834 net_stats->tx_carrier_errors = adapter->stats.tncrs; in igb_update_stats()
6839 adapter->stats.mgptc += rd32(E1000_MGTPTC); in igb_update_stats()
6840 adapter->stats.mgprc += rd32(E1000_MGTPRC); in igb_update_stats()
6841 adapter->stats.mgpdc += rd32(E1000_MGTPDC); in igb_update_stats()
6846 adapter->stats.o2bgptc += rd32(E1000_O2BGPTC); in igb_update_stats()
6847 adapter->stats.o2bspc += rd32(E1000_O2BSPC); in igb_update_stats()
6848 adapter->stats.b2ospc += rd32(E1000_B2OSPC); in igb_update_stats()
6849 adapter->stats.b2ogprc += rd32(E1000_B2OGPRC); in igb_update_stats()
6855 int pin = ptp_find_pin(adapter->ptp_clock, PTP_PF_PEROUT, tsintr_tt); in igb_perout()
6856 struct e1000_hw *hw = &adapter->hw; in igb_perout()
6863 spin_lock(&adapter->tmreg_lock); in igb_perout()
6865 if (hw->mac.type == e1000_82580 || in igb_perout()
6866 hw->mac.type == e1000_i354 || in igb_perout()
6867 hw->mac.type == e1000_i350) { in igb_perout()
6868 s64 ns = timespec64_to_ns(&adapter->perout[tsintr_tt].period); in igb_perout()
6877 now = timecounter_cyc2time(&adapter->tc, systim); in igb_perout()
6888 systim = systim + (ns - rem); in igb_perout()
6898 adapter->sdp_config[pin].name); in igb_perout()
6906 adapter->sdp_config[pin].name); in igb_perout()
6916 ts = timespec64_add(adapter->perout[tsintr_tt].start, in igb_perout()
6917 adapter->perout[tsintr_tt].period); in igb_perout()
6926 adapter->perout[tsintr_tt].start = ts; in igb_perout()
6928 spin_unlock(&adapter->tmreg_lock); in igb_perout()
6933 int pin = ptp_find_pin(adapter->ptp_clock, PTP_PF_EXTTS, tsintr_tt); in igb_extts()
6936 struct e1000_hw *hw = &adapter->hw; in igb_extts()
6944 if (hw->mac.type == e1000_82580 || in igb_extts()
6945 hw->mac.type == e1000_i354 || in igb_extts()
6946 hw->mac.type == e1000_i350) { in igb_extts()
6950 spin_lock_irqsave(&adapter->tmreg_lock, flags); in igb_extts()
6951 ns = timecounter_cyc2time(&adapter->tc, ns); in igb_extts()
6952 spin_unlock_irqrestore(&adapter->tmreg_lock, flags); in igb_extts()
6962 ptp_clock_event(adapter->ptp_clock, &event); in igb_extts()
6970 struct e1000_hw *hw = &adapter->hw; in igb_tsync_interrupt()
6974 if (hw->mac.type == e1000_82580) { in igb_tsync_interrupt()
6983 if (adapter->ptp_caps.pps) in igb_tsync_interrupt()
6984 ptp_clock_event(adapter->ptp_clock, &event); in igb_tsync_interrupt()
6989 schedule_work(&adapter->ptp_tx_work); in igb_tsync_interrupt()
7008 struct e1000_hw *hw = &adapter->hw; in igb_msix_other()
7013 schedule_work(&adapter->reset_task); in igb_msix_other()
7017 adapter->stats.doosync++; in igb_msix_other()
7030 hw->mac.get_link_status = 1; in igb_msix_other()
7032 if (!test_bit(__IGB_DOWN, &adapter->state)) in igb_msix_other()
7033 mod_timer(&adapter->watchdog_timer, jiffies + 1); in igb_msix_other()
7039 wr32(E1000_EIMS, adapter->eims_other); in igb_msix_other()
7046 struct igb_adapter *adapter = q_vector->adapter; in igb_write_itr()
7047 u32 itr_val = q_vector->itr_val & 0x7FFC; in igb_write_itr()
7049 if (!q_vector->set_itr) in igb_write_itr()
7055 if (adapter->hw.mac.type == e1000_82575) in igb_write_itr()
7060 writel(itr_val, q_vector->itr_register); in igb_write_itr()
7061 q_vector->set_itr = 0; in igb_write_itr()
7071 napi_schedule(&q_vector->napi); in igb_msix_ring()
7081 struct e1000_hw *hw = &adapter->hw; in igb_update_tx_dca()
7082 u32 txctrl = dca3_get_tag(tx_ring->dev, cpu); in igb_update_tx_dca()
7084 if (hw->mac.type != e1000_82575) in igb_update_tx_dca()
7095 wr32(E1000_DCA_TXCTRL(tx_ring->reg_idx), txctrl); in igb_update_tx_dca()
7102 struct e1000_hw *hw = &adapter->hw; in igb_update_rx_dca()
7103 u32 rxctrl = dca3_get_tag(&adapter->pdev->dev, cpu); in igb_update_rx_dca()
7105 if (hw->mac.type != e1000_82575) in igb_update_rx_dca()
7115 wr32(E1000_DCA_RXCTRL(rx_ring->reg_idx), rxctrl); in igb_update_rx_dca()
7120 struct igb_adapter *adapter = q_vector->adapter; in igb_update_dca()
7123 if (q_vector->cpu == cpu) in igb_update_dca()
7126 if (q_vector->tx.ring) in igb_update_dca()
7127 igb_update_tx_dca(adapter, q_vector->tx.ring, cpu); in igb_update_dca()
7129 if (q_vector->rx.ring) in igb_update_dca()
7130 igb_update_rx_dca(adapter, q_vector->rx.ring, cpu); in igb_update_dca()
7132 q_vector->cpu = cpu; in igb_update_dca()
7139 struct e1000_hw *hw = &adapter->hw; in igb_setup_dca()
7142 if (!(adapter->flags & IGB_FLAG_DCA_ENABLED)) in igb_setup_dca()
7148 for (i = 0; i < adapter->num_q_vectors; i++) { in igb_setup_dca()
7149 adapter->q_vector[i]->cpu = -1; in igb_setup_dca()
7150 igb_update_dca(adapter->q_vector[i]); in igb_setup_dca()
7158 struct pci_dev *pdev = adapter->pdev; in __igb_notify_dca()
7159 struct e1000_hw *hw = &adapter->hw; in __igb_notify_dca()
7165 if (adapter->flags & IGB_FLAG_DCA_ENABLED) in __igb_notify_dca()
7168 adapter->flags |= IGB_FLAG_DCA_ENABLED; in __igb_notify_dca()
7169 dev_info(&pdev->dev, "DCA enabled\n"); in __igb_notify_dca()
7175 if (adapter->flags & IGB_FLAG_DCA_ENABLED) { in __igb_notify_dca()
7180 dev_info(&pdev->dev, "DCA disabled\n"); in __igb_notify_dca()
7181 adapter->flags &= ~IGB_FLAG_DCA_ENABLED; in __igb_notify_dca()
7211 adapter->vf_data[vf].spoofchk_enabled = true; in igb_vf_configure()
7214 adapter->vf_data[vf].trusted = false; in igb_vf_configure()
7222 struct e1000_hw *hw = &adapter->hw; in igb_ping_all_vfs()
7226 for (i = 0 ; i < adapter->vfs_allocated_count; i++) { in igb_ping_all_vfs()
7228 if (adapter->vf_data[i].flags & IGB_VF_FLAG_CTS) in igb_ping_all_vfs()
7236 struct e1000_hw *hw = &adapter->hw; in igb_set_vf_promisc()
7238 struct vf_data_storage *vf_data = &adapter->vf_data[vf]; in igb_set_vf_promisc()
7240 vf_data->flags &= ~(IGB_VF_FLAG_UNI_PROMISC | in igb_set_vf_promisc()
7246 vf_data->flags |= IGB_VF_FLAG_MULTI_PROMISC; in igb_set_vf_promisc()
7253 if (vf_data->num_vf_mc_hashes > 30) { in igb_set_vf_promisc()
7255 } else if (vf_data->num_vf_mc_hashes) { in igb_set_vf_promisc()
7259 for (j = 0; j < vf_data->num_vf_mc_hashes; j++) in igb_set_vf_promisc()
7260 igb_mta_set(hw, vf_data->vf_mc_hashes[j]); in igb_set_vf_promisc()
7268 return -EINVAL; in igb_set_vf_promisc()
7278 struct vf_data_storage *vf_data = &adapter->vf_data[vf]; in igb_set_vf_multicasts()
7285 vf_data->num_vf_mc_hashes = n; in igb_set_vf_multicasts()
7293 vf_data->vf_mc_hashes[i] = hash_list[i]; in igb_set_vf_multicasts()
7296 igb_set_rx_mode(adapter->netdev); in igb_set_vf_multicasts()
7303 struct e1000_hw *hw = &adapter->hw; in igb_restore_vf_multicasts()
7307 for (i = 0; i < adapter->vfs_allocated_count; i++) { in igb_restore_vf_multicasts()
7312 vf_data = &adapter->vf_data[i]; in igb_restore_vf_multicasts()
7314 if ((vf_data->num_vf_mc_hashes > 30) || in igb_restore_vf_multicasts()
7315 (vf_data->flags & IGB_VF_FLAG_MULTI_PROMISC)) { in igb_restore_vf_multicasts()
7317 } else if (vf_data->num_vf_mc_hashes) { in igb_restore_vf_multicasts()
7319 for (j = 0; j < vf_data->num_vf_mc_hashes; j++) in igb_restore_vf_multicasts()
7320 igb_mta_set(hw, vf_data->vf_mc_hashes[j]); in igb_restore_vf_multicasts()
7328 struct e1000_hw *hw = &adapter->hw; in igb_clear_vf_vfta()
7337 adapter->vfs_allocated_count); in igb_clear_vf_vfta()
7340 for (i = E1000_VLVF_ARRAY_SIZE; i--;) { in igb_clear_vf_vfta()
7363 vfta = adapter->shadow_vfta[vid / 32]; in igb_clear_vf_vfta()
7365 hw->mac.ops.write_vfta(hw, vid / 32, vfta ^ vfta_mask); in igb_clear_vf_vfta()
7368 if (adapter->flags & IGB_FLAG_VLAN_PROMISC) in igb_clear_vf_vfta()
7388 for (idx = E1000_VLVF_ARRAY_SIZE; --idx;) { in igb_find_vlvf_entry()
7399 struct e1000_hw *hw = &adapter->hw; in igb_update_pf_vlvf()
7410 pf_id = adapter->vfs_allocated_count + E1000_VLVF_POOLSEL_SHIFT; in igb_update_pf_vlvf()
7416 if (adapter->flags & IGB_FLAG_VLAN_PROMISC) in igb_update_pf_vlvf()
7426 int pf_id = adapter->vfs_allocated_count; in igb_set_vf_vlan()
7427 struct e1000_hw *hw = &adapter->hw; in igb_set_vf_vlan()
7435 if (add && test_bit(vid, adapter->active_vlans)) { in igb_set_vf_vlan()
7450 if (test_bit(vid, adapter->active_vlans) || in igb_set_vf_vlan()
7451 (adapter->flags & IGB_FLAG_VLAN_PROMISC)) in igb_set_vf_vlan()
7459 struct e1000_hw *hw = &adapter->hw; in igb_set_vmvir()
7480 if (vlan != adapter->vf_data[vf].pf_vlan) in igb_enable_port_vlan()
7481 igb_set_vf_vlan(adapter, adapter->vf_data[vf].pf_vlan, in igb_enable_port_vlan()
7484 adapter->vf_data[vf].pf_vlan = vlan; in igb_enable_port_vlan()
7485 adapter->vf_data[vf].pf_qos = qos; in igb_enable_port_vlan()
7487 dev_info(&adapter->pdev->dev, in igb_enable_port_vlan()
7489 if (test_bit(__IGB_DOWN, &adapter->state)) { in igb_enable_port_vlan()
7490 dev_warn(&adapter->pdev->dev, in igb_enable_port_vlan()
7492 dev_warn(&adapter->pdev->dev, in igb_enable_port_vlan()
7508 if (adapter->vf_data[vf].pf_vlan) in igb_disable_port_vlan()
7509 igb_set_vf_vlan(adapter, adapter->vf_data[vf].pf_vlan, in igb_disable_port_vlan()
7512 adapter->vf_data[vf].pf_vlan = 0; in igb_disable_port_vlan()
7513 adapter->vf_data[vf].pf_qos = 0; in igb_disable_port_vlan()
7524 if ((vf >= adapter->vfs_allocated_count) || (vlan > 4095) || (qos > 7)) in igb_ndo_set_vf_vlan()
7525 return -EINVAL; in igb_ndo_set_vf_vlan()
7528 return -EPROTONOSUPPORT; in igb_ndo_set_vf_vlan()
7540 if (adapter->vf_data[vf].pf_vlan) in igb_set_vf_vlan_msg()
7541 return -1; in igb_set_vf_vlan_msg()
7555 struct vf_data_storage *vf_data = &adapter->vf_data[vf]; in igb_vf_reset()
7557 /* clear flags - except flag that indicates PF has set the MAC */ in igb_vf_reset()
7558 vf_data->flags &= IGB_VF_FLAG_PF_SET_MAC; in igb_vf_reset()
7559 vf_data->last_nack = jiffies; in igb_vf_reset()
7563 igb_set_vf_vlan(adapter, vf_data->pf_vlan, true, vf); in igb_vf_reset()
7564 igb_set_vmvir(adapter, vf_data->pf_vlan | in igb_vf_reset()
7565 (vf_data->pf_qos << VLAN_PRIO_SHIFT), vf); in igb_vf_reset()
7566 igb_set_vmolr(adapter, vf, !vf_data->pf_vlan); in igb_vf_reset()
7567 igb_set_vf_vlan_strip(adapter, vf, !!(vf_data->pf_vlan)); in igb_vf_reset()
7570 adapter->vf_data[vf].num_vf_mc_hashes = 0; in igb_vf_reset()
7573 igb_set_rx_mode(adapter->netdev); in igb_vf_reset()
7578 unsigned char *vf_mac = adapter->vf_data[vf].vf_mac_addresses; in igb_vf_reset_event()
7581 if (!(adapter->vf_data[vf].flags & IGB_VF_FLAG_PF_SET_MAC)) in igb_vf_reset_event()
7590 struct e1000_hw *hw = &adapter->hw; in igb_vf_reset_msg()
7591 unsigned char *vf_mac = adapter->vf_data[vf].vf_mac_addresses; in igb_vf_reset_msg()
7607 adapter->vf_data[vf].flags |= IGB_VF_FLAG_CTS; in igb_vf_reset_msg()
7621 struct e1000_hw *hw = &adapter->hw; in igb_flush_mac_table()
7624 for (i = 0; i < hw->mac.rar_entry_count; i++) { in igb_flush_mac_table()
7625 adapter->mac_table[i].state &= ~IGB_MAC_STATE_IN_USE; in igb_flush_mac_table()
7626 eth_zero_addr(adapter->mac_table[i].addr); in igb_flush_mac_table()
7627 adapter->mac_table[i].queue = 0; in igb_flush_mac_table()
7634 struct e1000_hw *hw = &adapter->hw; in igb_available_rars()
7636 int rar_entries = hw->mac.rar_entry_count - in igb_available_rars()
7637 adapter->vfs_allocated_count; in igb_available_rars()
7642 if (adapter->mac_table[i].state & IGB_MAC_STATE_DEFAULT) in igb_available_rars()
7646 if ((adapter->mac_table[i].state & IGB_MAC_STATE_IN_USE) && in igb_available_rars()
7647 (adapter->mac_table[i].queue != queue)) in igb_available_rars()
7659 struct igb_mac_addr *mac_table = &adapter->mac_table[0]; in igb_set_default_mac_filter()
7661 ether_addr_copy(mac_table->addr, adapter->hw.mac.addr); in igb_set_default_mac_filter()
7662 mac_table->queue = adapter->vfs_allocated_count; in igb_set_default_mac_filter()
7663 mac_table->state = IGB_MAC_STATE_DEFAULT | IGB_MAC_STATE_IN_USE; in igb_set_default_mac_filter()
7676 if (!(entry->state & IGB_MAC_STATE_IN_USE)) in igb_mac_entry_can_be_used()
7679 if ((entry->state & IGB_MAC_STATE_SRC_ADDR) != in igb_mac_entry_can_be_used()
7683 if (!ether_addr_equal(addr, entry->addr)) in igb_mac_entry_can_be_used()
7698 struct e1000_hw *hw = &adapter->hw; in igb_add_mac_filter_flags()
7699 int rar_entries = hw->mac.rar_entry_count - in igb_add_mac_filter_flags()
7700 adapter->vfs_allocated_count; in igb_add_mac_filter_flags()
7704 return -EINVAL; in igb_add_mac_filter_flags()
7711 if (!igb_mac_entry_can_be_used(&adapter->mac_table[i], in igb_add_mac_filter_flags()
7715 ether_addr_copy(adapter->mac_table[i].addr, addr); in igb_add_mac_filter_flags()
7716 adapter->mac_table[i].queue = queue; in igb_add_mac_filter_flags()
7717 adapter->mac_table[i].state |= IGB_MAC_STATE_IN_USE | flags; in igb_add_mac_filter_flags()
7723 return -ENOSPC; in igb_add_mac_filter_flags()
7742 struct e1000_hw *hw = &adapter->hw; in igb_del_mac_filter_flags()
7743 int rar_entries = hw->mac.rar_entry_count - in igb_del_mac_filter_flags()
7744 adapter->vfs_allocated_count; in igb_del_mac_filter_flags()
7748 return -EINVAL; in igb_del_mac_filter_flags()
7755 if (!(adapter->mac_table[i].state & IGB_MAC_STATE_IN_USE)) in igb_del_mac_filter_flags()
7757 if ((adapter->mac_table[i].state & flags) != flags) in igb_del_mac_filter_flags()
7759 if (adapter->mac_table[i].queue != queue) in igb_del_mac_filter_flags()
7761 if (!ether_addr_equal(adapter->mac_table[i].addr, addr)) in igb_del_mac_filter_flags()
7767 if (adapter->mac_table[i].state & IGB_MAC_STATE_DEFAULT) { in igb_del_mac_filter_flags()
7768 adapter->mac_table[i].state = in igb_del_mac_filter_flags()
7770 adapter->mac_table[i].queue = in igb_del_mac_filter_flags()
7771 adapter->vfs_allocated_count; in igb_del_mac_filter_flags()
7773 adapter->mac_table[i].state = 0; in igb_del_mac_filter_flags()
7774 adapter->mac_table[i].queue = 0; in igb_del_mac_filter_flags()
7775 eth_zero_addr(adapter->mac_table[i].addr); in igb_del_mac_filter_flags()
7782 return -ENOENT; in igb_del_mac_filter_flags()
7794 struct e1000_hw *hw = &adapter->hw; in igb_add_mac_steering_filter()
7799 if (hw->mac.type != e1000_i210) in igb_add_mac_steering_filter()
7800 return -EOPNOTSUPP; in igb_add_mac_steering_filter()
7818 ret = igb_add_mac_filter(adapter, addr, adapter->vfs_allocated_count); in igb_uc_sync()
7827 igb_del_mac_filter(adapter, addr, adapter->vfs_allocated_count); in igb_uc_unsync()
7835 struct pci_dev *pdev = adapter->pdev; in igb_set_vf_mac_filter()
7836 struct vf_data_storage *vf_data = &adapter->vf_data[vf]; in igb_set_vf_mac_filter()
7841 if ((vf_data->flags & IGB_VF_FLAG_PF_SET_MAC) && in igb_set_vf_mac_filter()
7842 !vf_data->trusted) { in igb_set_vf_mac_filter()
7843 dev_warn(&pdev->dev, in igb_set_vf_mac_filter()
7846 return -EINVAL; in igb_set_vf_mac_filter()
7849 dev_warn(&pdev->dev, in igb_set_vf_mac_filter()
7852 return -EINVAL; in igb_set_vf_mac_filter()
7858 list_for_each_entry(entry, &adapter->vf_macs.l, l) { in igb_set_vf_mac_filter()
7859 if (entry->vf == vf) { in igb_set_vf_mac_filter()
7860 entry->vf = -1; in igb_set_vf_mac_filter()
7861 entry->free = true; in igb_set_vf_mac_filter()
7862 igb_del_mac_filter(adapter, entry->vf_mac, vf); in igb_set_vf_mac_filter()
7868 list_for_each_entry(entry, &adapter->vf_macs.l, l) { in igb_set_vf_mac_filter()
7869 if (entry->free) { in igb_set_vf_mac_filter()
7876 entry->free = false; in igb_set_vf_mac_filter()
7877 entry->vf = vf; in igb_set_vf_mac_filter()
7878 ether_addr_copy(entry->vf_mac, addr); in igb_set_vf_mac_filter()
7883 ret = -ENOSPC; in igb_set_vf_mac_filter()
7886 if (ret == -ENOSPC) in igb_set_vf_mac_filter()
7887 dev_warn(&pdev->dev, in igb_set_vf_mac_filter()
7892 ret = -EINVAL; in igb_set_vf_mac_filter()
7901 struct pci_dev *pdev = adapter->pdev; in igb_set_vf_mac_addr()
7902 struct vf_data_storage *vf_data = &adapter->vf_data[vf]; in igb_set_vf_mac_addr()
7912 if ((vf_data->flags & IGB_VF_FLAG_PF_SET_MAC) && in igb_set_vf_mac_addr()
7913 !vf_data->trusted) { in igb_set_vf_mac_addr()
7914 dev_warn(&pdev->dev, in igb_set_vf_mac_addr()
7917 return -EINVAL; in igb_set_vf_mac_addr()
7921 dev_warn(&pdev->dev, in igb_set_vf_mac_addr()
7924 return -EINVAL; in igb_set_vf_mac_addr()
7937 struct e1000_hw *hw = &adapter->hw; in igb_rcv_ack_from_vf()
7938 struct vf_data_storage *vf_data = &adapter->vf_data[vf]; in igb_rcv_ack_from_vf()
7942 if (!(vf_data->flags & IGB_VF_FLAG_CTS) && in igb_rcv_ack_from_vf()
7943 time_after(jiffies, vf_data->last_nack + (2 * HZ))) { in igb_rcv_ack_from_vf()
7945 vf_data->last_nack = jiffies; in igb_rcv_ack_from_vf()
7951 struct pci_dev *pdev = adapter->pdev; in igb_rcv_msg_from_vf()
7953 struct e1000_hw *hw = &adapter->hw; in igb_rcv_msg_from_vf()
7954 struct vf_data_storage *vf_data = &adapter->vf_data[vf]; in igb_rcv_msg_from_vf()
7961 dev_err(&pdev->dev, "Error receiving message from VF\n"); in igb_rcv_msg_from_vf()
7962 vf_data->flags &= ~IGB_VF_FLAG_CTS; in igb_rcv_msg_from_vf()
7963 if (!time_after(jiffies, vf_data->last_nack + (2 * HZ))) in igb_rcv_msg_from_vf()
7981 if (!(vf_data->flags & IGB_VF_FLAG_CTS)) { in igb_rcv_msg_from_vf()
7982 if (!time_after(jiffies, vf_data->last_nack + (2 * HZ))) in igb_rcv_msg_from_vf()
7984 retval = -1; in igb_rcv_msg_from_vf()
8002 retval = -1; in igb_rcv_msg_from_vf()
8003 if (vf_data->pf_vlan) in igb_rcv_msg_from_vf()
8004 dev_warn(&pdev->dev, in igb_rcv_msg_from_vf()
8011 dev_err(&pdev->dev, "Unhandled Msg %08x\n", msgbuf[0]); in igb_rcv_msg_from_vf()
8012 retval = -1; in igb_rcv_msg_from_vf()
8034 struct e1000_hw *hw = &adapter->hw; in igb_msg_task()
8038 spin_lock_irqsave(&adapter->vfs_lock, flags); in igb_msg_task()
8039 for (vf = 0; vf < adapter->vfs_allocated_count; vf++) { in igb_msg_task()
8052 spin_unlock_irqrestore(&adapter->vfs_lock, flags); in igb_msg_task()
8056 * igb_set_uta - Set unicast filter table address
8060 * The unicast table address is a register array of 32-bit registers.
8068 struct e1000_hw *hw = &adapter->hw; in igb_set_uta()
8073 if (!adapter->vfs_allocated_count) in igb_set_uta()
8076 for (i = hw->mac.uta_reg_count; i--;) in igb_set_uta()
8081 * igb_intr_msi - Interrupt Handler
8088 struct igb_q_vector *q_vector = adapter->q_vector[0]; in igb_intr_msi()
8089 struct e1000_hw *hw = &adapter->hw; in igb_intr_msi()
8096 schedule_work(&adapter->reset_task); in igb_intr_msi()
8100 adapter->stats.doosync++; in igb_intr_msi()
8104 hw->mac.get_link_status = 1; in igb_intr_msi()
8105 if (!test_bit(__IGB_DOWN, &adapter->state)) in igb_intr_msi()
8106 mod_timer(&adapter->watchdog_timer, jiffies + 1); in igb_intr_msi()
8112 napi_schedule(&q_vector->napi); in igb_intr_msi()
8118 * igb_intr - Legacy Interrupt Handler
8125 struct igb_q_vector *q_vector = adapter->q_vector[0]; in igb_intr()
8126 struct e1000_hw *hw = &adapter->hw; in igb_intr()
8127 /* Interrupt Auto-Mask...upon reading ICR, interrupts are masked. No in igb_intr()
8132 /* IMS will not auto-mask if INT_ASSERTED is not set, and if it is in igb_intr()
8141 schedule_work(&adapter->reset_task); in igb_intr()
8145 adapter->stats.doosync++; in igb_intr()
8149 hw->mac.get_link_status = 1; in igb_intr()
8151 if (!test_bit(__IGB_DOWN, &adapter->state)) in igb_intr()
8152 mod_timer(&adapter->watchdog_timer, jiffies + 1); in igb_intr()
8158 napi_schedule(&q_vector->napi); in igb_intr()
8165 struct igb_adapter *adapter = q_vector->adapter; in igb_ring_irq_enable()
8166 struct e1000_hw *hw = &adapter->hw; in igb_ring_irq_enable()
8168 if ((q_vector->rx.ring && (adapter->rx_itr_setting & 3)) || in igb_ring_irq_enable()
8169 (!q_vector->rx.ring && (adapter->tx_itr_setting & 3))) { in igb_ring_irq_enable()
8170 if ((adapter->num_q_vectors == 1) && !adapter->vf_data) in igb_ring_irq_enable()
8176 if (!test_bit(__IGB_DOWN, &adapter->state)) { in igb_ring_irq_enable()
8177 if (adapter->flags & IGB_FLAG_HAS_MSIX) in igb_ring_irq_enable()
8178 wr32(E1000_EIMS, q_vector->eims_value); in igb_ring_irq_enable()
8185 * igb_poll - NAPI Rx polling callback
8198 if (q_vector->adapter->flags & IGB_FLAG_DCA_ENABLED) in igb_poll()
8201 if (q_vector->tx.ring) in igb_poll()
8204 if (q_vector->rx.ring) { in igb_poll()
8216 /* Exit the polling mode, but don't re-enable interrupts if stack might in igb_poll()
8217 * poll us due to busy-polling in igb_poll()
8226 * igb_clean_tx_irq - Reclaim resources after transmit completes
8234 struct igb_adapter *adapter = q_vector->adapter; in igb_clean_tx_irq()
8235 struct igb_ring *tx_ring = q_vector->tx.ring; in igb_clean_tx_irq()
8239 unsigned int budget = q_vector->tx.work_limit; in igb_clean_tx_irq()
8240 unsigned int i = tx_ring->next_to_clean; in igb_clean_tx_irq()
8242 if (test_bit(__IGB_DOWN, &adapter->state)) in igb_clean_tx_irq()
8245 tx_buffer = &tx_ring->tx_buffer_info[i]; in igb_clean_tx_irq()
8247 i -= tx_ring->count; in igb_clean_tx_irq()
8250 union e1000_adv_tx_desc *eop_desc = tx_buffer->next_to_watch; in igb_clean_tx_irq()
8260 if (!(eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD))) in igb_clean_tx_irq()
8264 tx_buffer->next_to_watch = NULL; in igb_clean_tx_irq()
8267 total_bytes += tx_buffer->bytecount; in igb_clean_tx_irq()
8268 total_packets += tx_buffer->gso_segs; in igb_clean_tx_irq()
8271 if (tx_buffer->type == IGB_TYPE_SKB) in igb_clean_tx_irq()
8272 napi_consume_skb(tx_buffer->skb, napi_budget); in igb_clean_tx_irq()
8274 xdp_return_frame(tx_buffer->xdpf); in igb_clean_tx_irq()
8277 dma_unmap_single(tx_ring->dev, in igb_clean_tx_irq()
8291 i -= tx_ring->count; in igb_clean_tx_irq()
8292 tx_buffer = tx_ring->tx_buffer_info; in igb_clean_tx_irq()
8298 dma_unmap_page(tx_ring->dev, in igb_clean_tx_irq()
8311 i -= tx_ring->count; in igb_clean_tx_irq()
8312 tx_buffer = tx_ring->tx_buffer_info; in igb_clean_tx_irq()
8320 budget--; in igb_clean_tx_irq()
8325 i += tx_ring->count; in igb_clean_tx_irq()
8326 tx_ring->next_to_clean = i; in igb_clean_tx_irq()
8327 u64_stats_update_begin(&tx_ring->tx_syncp); in igb_clean_tx_irq()
8328 tx_ring->tx_stats.bytes += total_bytes; in igb_clean_tx_irq()
8329 tx_ring->tx_stats.packets += total_packets; in igb_clean_tx_irq()
8330 u64_stats_update_end(&tx_ring->tx_syncp); in igb_clean_tx_irq()
8331 q_vector->tx.total_bytes += total_bytes; in igb_clean_tx_irq()
8332 q_vector->tx.total_packets += total_packets; in igb_clean_tx_irq()
8334 if (test_bit(IGB_RING_FLAG_TX_DETECT_HANG, &tx_ring->flags)) { in igb_clean_tx_irq()
8335 struct e1000_hw *hw = &adapter->hw; in igb_clean_tx_irq()
8340 clear_bit(IGB_RING_FLAG_TX_DETECT_HANG, &tx_ring->flags); in igb_clean_tx_irq()
8341 if (tx_buffer->next_to_watch && in igb_clean_tx_irq()
8342 time_after(jiffies, tx_buffer->time_stamp + in igb_clean_tx_irq()
8343 (adapter->tx_timeout_factor * HZ)) && in igb_clean_tx_irq()
8347 dev_err(tx_ring->dev, in igb_clean_tx_irq()
8359 tx_ring->queue_index, in igb_clean_tx_irq()
8360 rd32(E1000_TDH(tx_ring->reg_idx)), in igb_clean_tx_irq()
8361 readl(tx_ring->tail), in igb_clean_tx_irq()
8362 tx_ring->next_to_use, in igb_clean_tx_irq()
8363 tx_ring->next_to_clean, in igb_clean_tx_irq()
8364 tx_buffer->time_stamp, in igb_clean_tx_irq()
8365 tx_buffer->next_to_watch, in igb_clean_tx_irq()
8367 tx_buffer->next_to_watch->wb.status); in igb_clean_tx_irq()
8368 netif_stop_subqueue(tx_ring->netdev, in igb_clean_tx_irq()
8369 tx_ring->queue_index); in igb_clean_tx_irq()
8378 netif_carrier_ok(tx_ring->netdev) && in igb_clean_tx_irq()
8384 if (__netif_subqueue_stopped(tx_ring->netdev, in igb_clean_tx_irq()
8385 tx_ring->queue_index) && in igb_clean_tx_irq()
8386 !(test_bit(__IGB_DOWN, &adapter->state))) { in igb_clean_tx_irq()
8387 netif_wake_subqueue(tx_ring->netdev, in igb_clean_tx_irq()
8388 tx_ring->queue_index); in igb_clean_tx_irq()
8390 u64_stats_update_begin(&tx_ring->tx_syncp); in igb_clean_tx_irq()
8391 tx_ring->tx_stats.restart_queue++; in igb_clean_tx_irq()
8392 u64_stats_update_end(&tx_ring->tx_syncp); in igb_clean_tx_irq()
8400 * igb_reuse_rx_page - page flip buffer and store it back on the ring
8410 u16 nta = rx_ring->next_to_alloc; in igb_reuse_rx_page()
8412 new_buff = &rx_ring->rx_buffer_info[nta]; in igb_reuse_rx_page()
8416 rx_ring->next_to_alloc = (nta < rx_ring->count) ? nta : 0; in igb_reuse_rx_page()
8422 new_buff->dma = old_buff->dma; in igb_reuse_rx_page()
8423 new_buff->page = old_buff->page; in igb_reuse_rx_page()
8424 new_buff->page_offset = old_buff->page_offset; in igb_reuse_rx_page()
8425 new_buff->pagecnt_bias = old_buff->pagecnt_bias; in igb_reuse_rx_page()
8431 unsigned int pagecnt_bias = rx_buffer->pagecnt_bias; in igb_can_reuse_rx_page()
8432 struct page *page = rx_buffer->page; in igb_can_reuse_rx_page()
8434 /* avoid re-using remote and pfmemalloc pages */ in igb_can_reuse_rx_page()
8440 if (unlikely((rx_buf_pgcnt - pagecnt_bias) > 1)) in igb_can_reuse_rx_page()
8444 (SKB_WITH_OVERHEAD(PAGE_SIZE) - IGB_RXBUFFER_2048) in igb_can_reuse_rx_page()
8446 if (rx_buffer->page_offset > IGB_LAST_OFFSET) in igb_can_reuse_rx_page()
8455 page_ref_add(page, USHRT_MAX - 1); in igb_can_reuse_rx_page()
8456 rx_buffer->pagecnt_bias = USHRT_MAX; in igb_can_reuse_rx_page()
8463 * igb_add_rx_frag - Add contents of Rx buffer to sk_buff
8469 * This function will add the data contained in rx_buffer->page to the skb.
8483 skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, rx_buffer->page, in igb_add_rx_frag()
8484 rx_buffer->page_offset, size, truesize); in igb_add_rx_frag()
8486 rx_buffer->page_offset ^= truesize; in igb_add_rx_frag()
8488 rx_buffer->page_offset += truesize; in igb_add_rx_frag()
8500 unsigned int truesize = SKB_DATA_ALIGN(xdp->data_end - in igb_construct_skb()
8501 xdp->data_hard_start); in igb_construct_skb()
8503 unsigned int size = xdp->data_end - xdp->data; in igb_construct_skb()
8508 net_prefetch(xdp->data); in igb_construct_skb()
8511 skb = napi_alloc_skb(&rx_ring->q_vector->napi, IGB_RX_HDR_LEN); in igb_construct_skb()
8516 skb_hwtstamps(skb)->hwtstamp = timestamp; in igb_construct_skb()
8521 headlen = eth_get_headlen(skb->dev, xdp->data, IGB_RX_HDR_LEN); in igb_construct_skb()
8524 memcpy(__skb_put(skb, headlen), xdp->data, ALIGN(headlen, sizeof(long))); in igb_construct_skb()
8527 size -= headlen; in igb_construct_skb()
8529 skb_add_rx_frag(skb, 0, rx_buffer->page, in igb_construct_skb()
8530 (xdp->data + headlen) - page_address(rx_buffer->page), in igb_construct_skb()
8533 rx_buffer->page_offset ^= truesize; in igb_construct_skb()
8535 rx_buffer->page_offset += truesize; in igb_construct_skb()
8538 rx_buffer->pagecnt_bias++; in igb_construct_skb()
8553 SKB_DATA_ALIGN(xdp->data_end - in igb_build_skb()
8554 xdp->data_hard_start); in igb_build_skb()
8556 unsigned int metasize = xdp->data - xdp->data_meta; in igb_build_skb()
8560 net_prefetch(xdp->data_meta); in igb_build_skb()
8563 skb = napi_build_skb(xdp->data_hard_start, truesize); in igb_build_skb()
8568 skb_reserve(skb, xdp->data - xdp->data_hard_start); in igb_build_skb()
8569 __skb_put(skb, xdp->data_end - xdp->data); in igb_build_skb()
8575 skb_hwtstamps(skb)->hwtstamp = timestamp; in igb_build_skb()
8579 rx_buffer->page_offset ^= truesize; in igb_build_skb()
8581 rx_buffer->page_offset += truesize; in igb_build_skb()
8595 xdp_prog = READ_ONCE(rx_ring->xdp_prog); in igb_run_xdp()
8600 prefetchw(xdp->data_hard_start); /* xdp_frame write */ in igb_run_xdp()
8612 err = xdp_do_redirect(adapter->netdev, xdp, xdp_prog); in igb_run_xdp()
8618 bpf_warn_invalid_xdp_action(adapter->netdev, xdp_prog, act); in igb_run_xdp()
8622 trace_xdp_exception(rx_ring->netdev, xdp_prog, act); in igb_run_xdp()
8629 return ERR_PTR(-result); in igb_run_xdp()
8638 truesize = igb_rx_pg_size(rx_ring) / 2; /* Must be power-of-2 */ in igb_rx_frame_truesize()
8654 rx_buffer->page_offset ^= truesize; in igb_rx_buffer_flip()
8656 rx_buffer->page_offset += truesize; in igb_rx_buffer_flip()
8671 if (!(ring->netdev->features & NETIF_F_RXCSUM)) in igb_rx_checksum()
8682 if (!((skb->len == 60) && in igb_rx_checksum()
8683 test_bit(IGB_RING_FLAG_RX_SCTP_CSUM, &ring->flags))) { in igb_rx_checksum()
8684 u64_stats_update_begin(&ring->rx_syncp); in igb_rx_checksum()
8685 ring->rx_stats.csum_err++; in igb_rx_checksum()
8686 u64_stats_update_end(&ring->rx_syncp); in igb_rx_checksum()
8694 skb->ip_summed = CHECKSUM_UNNECESSARY; in igb_rx_checksum()
8696 dev_dbg(ring->dev, "cksum success: bits %08X\n", in igb_rx_checksum()
8697 le32_to_cpu(rx_desc->wb.upper.status_error)); in igb_rx_checksum()
8704 if (ring->netdev->features & NETIF_F_RXHASH) in igb_rx_hash()
8706 le32_to_cpu(rx_desc->wb.lower.hi_dword.rss), in igb_rx_hash()
8711 * igb_is_non_eop - process handling of non-EOP buffers
8718 * that this is in fact a non-EOP buffer.
8723 u32 ntc = rx_ring->next_to_clean + 1; in igb_is_non_eop()
8726 ntc = (ntc < rx_ring->count) ? ntc : 0; in igb_is_non_eop()
8727 rx_ring->next_to_clean = ntc; in igb_is_non_eop()
8738 * igb_cleanup_headers - Correct corrupted or empty headers
8761 struct net_device *netdev = rx_ring->netdev; in igb_cleanup_headers()
8762 if (!(netdev->features & NETIF_F_RXALL)) { in igb_cleanup_headers()
8776 * igb_process_skb_fields - Populate skb header fields from Rx descriptor
8789 struct net_device *dev = rx_ring->netdev; in igb_process_skb_fields()
8797 igb_ptp_rx_rgtstamp(rx_ring->q_vector, skb); in igb_process_skb_fields()
8799 if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) && in igb_process_skb_fields()
8804 test_bit(IGB_RING_FLAG_RX_LB_VLAN_BSWAP, &rx_ring->flags)) in igb_process_skb_fields()
8805 vid = be16_to_cpu((__force __be16)rx_desc->wb.upper.vlan); in igb_process_skb_fields()
8807 vid = le16_to_cpu(rx_desc->wb.upper.vlan); in igb_process_skb_fields()
8812 skb_record_rx_queue(skb, rx_ring->queue_index); in igb_process_skb_fields()
8814 skb->protocol = eth_type_trans(skb, rx_ring->netdev); in igb_process_skb_fields()
8827 rx_buffer = &rx_ring->rx_buffer_info[rx_ring->next_to_clean]; in igb_get_rx_buffer()
8830 page_count(rx_buffer->page); in igb_get_rx_buffer()
8834 prefetchw(rx_buffer->page); in igb_get_rx_buffer()
8837 dma_sync_single_range_for_cpu(rx_ring->dev, in igb_get_rx_buffer()
8838 rx_buffer->dma, in igb_get_rx_buffer()
8839 rx_buffer->page_offset, in igb_get_rx_buffer()
8843 rx_buffer->pagecnt_bias--; in igb_get_rx_buffer()
8858 dma_unmap_page_attrs(rx_ring->dev, rx_buffer->dma, in igb_put_rx_buffer()
8861 __page_frag_cache_drain(rx_buffer->page, in igb_put_rx_buffer()
8862 rx_buffer->pagecnt_bias); in igb_put_rx_buffer()
8866 rx_buffer->page = NULL; in igb_put_rx_buffer()
8872 struct igb_adapter *adapter = q_vector->adapter; in igb_clean_rx_irq()
8873 struct igb_ring *rx_ring = q_vector->rx.ring; in igb_clean_rx_irq()
8875 struct sk_buff *skb = rx_ring->skb; in igb_clean_rx_irq()
8887 xdp_init_buff(&xdp, frame_sz, &rx_ring->xdp_rxq); in igb_clean_rx_irq()
8903 rx_desc = IGB_RX_DESC(rx_ring, rx_ring->next_to_clean); in igb_clean_rx_irq()
8904 size = le16_to_cpu(rx_desc->wb.upper.length); in igb_clean_rx_irq()
8915 pktbuf = page_address(rx_buffer->page) + rx_buffer->page_offset; in igb_clean_rx_irq()
8921 ts_hdr_len = igb_ptp_rx_pktstamp(rx_ring->q_vector, in igb_clean_rx_irq()
8925 size -= ts_hdr_len; in igb_clean_rx_irq()
8930 unsigned char *hard_start = pktbuf - igb_rx_offset(rx_ring); in igb_clean_rx_irq()
8943 unsigned int xdp_res = -PTR_ERR(skb); in igb_clean_rx_irq()
8949 rx_buffer->pagecnt_bias++; in igb_clean_rx_irq()
8964 rx_ring->rx_stats.alloc_failed++; in igb_clean_rx_irq()
8965 rx_buffer->pagecnt_bias++; in igb_clean_rx_irq()
8972 /* fetch next buffer in frame if non-eop */ in igb_clean_rx_irq()
8983 total_bytes += skb->len; in igb_clean_rx_irq()
8988 napi_gro_receive(&q_vector->napi, skb); in igb_clean_rx_irq()
8998 rx_ring->skb = skb; in igb_clean_rx_irq()
9012 u64_stats_update_begin(&rx_ring->rx_syncp); in igb_clean_rx_irq()
9013 rx_ring->rx_stats.packets += total_packets; in igb_clean_rx_irq()
9014 rx_ring->rx_stats.bytes += total_bytes; in igb_clean_rx_irq()
9015 u64_stats_update_end(&rx_ring->rx_syncp); in igb_clean_rx_irq()
9016 q_vector->rx.total_packets += total_packets; in igb_clean_rx_irq()
9017 q_vector->rx.total_bytes += total_bytes; in igb_clean_rx_irq()
9028 struct page *page = bi->page; in igb_alloc_mapped_page()
9038 rx_ring->rx_stats.alloc_failed++; in igb_alloc_mapped_page()
9043 dma = dma_map_page_attrs(rx_ring->dev, page, 0, in igb_alloc_mapped_page()
9051 if (dma_mapping_error(rx_ring->dev, dma)) { in igb_alloc_mapped_page()
9054 rx_ring->rx_stats.alloc_failed++; in igb_alloc_mapped_page()
9058 bi->dma = dma; in igb_alloc_mapped_page()
9059 bi->page = page; in igb_alloc_mapped_page()
9060 bi->page_offset = igb_rx_offset(rx_ring); in igb_alloc_mapped_page()
9061 page_ref_add(page, USHRT_MAX - 1); in igb_alloc_mapped_page()
9062 bi->pagecnt_bias = USHRT_MAX; in igb_alloc_mapped_page()
9068 * igb_alloc_rx_buffers - Replace used receive buffers
9076 u16 i = rx_ring->next_to_use; in igb_alloc_rx_buffers()
9084 bi = &rx_ring->rx_buffer_info[i]; in igb_alloc_rx_buffers()
9085 i -= rx_ring->count; in igb_alloc_rx_buffers()
9094 dma_sync_single_range_for_device(rx_ring->dev, bi->dma, in igb_alloc_rx_buffers()
9095 bi->page_offset, bufsz, in igb_alloc_rx_buffers()
9099 * because each write-back erases this info. in igb_alloc_rx_buffers()
9101 rx_desc->read.pkt_addr = cpu_to_le64(bi->dma + bi->page_offset); in igb_alloc_rx_buffers()
9108 bi = rx_ring->rx_buffer_info; in igb_alloc_rx_buffers()
9109 i -= rx_ring->count; in igb_alloc_rx_buffers()
9113 rx_desc->wb.upper.length = 0; in igb_alloc_rx_buffers()
9115 cleaned_count--; in igb_alloc_rx_buffers()
9118 i += rx_ring->count; in igb_alloc_rx_buffers()
9120 if (rx_ring->next_to_use != i) { in igb_alloc_rx_buffers()
9122 rx_ring->next_to_use = i; in igb_alloc_rx_buffers()
9125 rx_ring->next_to_alloc = i; in igb_alloc_rx_buffers()
9129 * applicable for weak-ordered memory model archs, in igb_alloc_rx_buffers()
9130 * such as IA-64). in igb_alloc_rx_buffers()
9133 writel(i, rx_ring->tail); in igb_alloc_rx_buffers()
9138 * igb_mii_ioctl -
9148 if (adapter->hw.phy.media_type != e1000_media_type_copper) in igb_mii_ioctl()
9149 return -EOPNOTSUPP; in igb_mii_ioctl()
9153 data->phy_id = adapter->hw.phy.addr; in igb_mii_ioctl()
9156 if (igb_read_phy_reg(&adapter->hw, data->reg_num & 0x1F, in igb_mii_ioctl()
9157 &data->val_out)) in igb_mii_ioctl()
9158 return -EIO; in igb_mii_ioctl()
9161 if (igb_write_phy_reg(&adapter->hw, data->reg_num & 0x1F, in igb_mii_ioctl()
9162 data->val_in)) in igb_mii_ioctl()
9163 return -EIO; in igb_mii_ioctl()
9166 return -EOPNOTSUPP; in igb_mii_ioctl()
9172 * igb_ioctl -
9189 return -EOPNOTSUPP; in igb_ioctl()
9195 struct igb_adapter *adapter = hw->back; in igb_read_pci_cfg()
9197 pci_read_config_word(adapter->pdev, reg, value); in igb_read_pci_cfg()
9202 struct igb_adapter *adapter = hw->back; in igb_write_pci_cfg()
9204 pci_write_config_word(adapter->pdev, reg, *value); in igb_write_pci_cfg()
9209 struct igb_adapter *adapter = hw->back; in igb_read_pcie_cap_reg()
9211 if (pcie_capability_read_word(adapter->pdev, reg, value)) in igb_read_pcie_cap_reg()
9212 return -E1000_ERR_CONFIG; in igb_read_pcie_cap_reg()
9219 struct igb_adapter *adapter = hw->back; in igb_write_pcie_cap_reg()
9221 if (pcie_capability_write_word(adapter->pdev, reg, *value)) in igb_write_pcie_cap_reg()
9222 return -E1000_ERR_CONFIG; in igb_write_pcie_cap_reg()
9230 struct e1000_hw *hw = &adapter->hw; in igb_vlan_mode()
9251 igb_set_vf_vlan_strip(adapter, adapter->vfs_allocated_count, enable); in igb_vlan_mode()
9258 struct e1000_hw *hw = &adapter->hw; in igb_vlan_rx_add_vid()
9259 int pf_id = adapter->vfs_allocated_count; in igb_vlan_rx_add_vid()
9262 if (!vid || !(adapter->flags & IGB_FLAG_VLAN_PROMISC)) in igb_vlan_rx_add_vid()
9265 set_bit(vid, adapter->active_vlans); in igb_vlan_rx_add_vid()
9274 int pf_id = adapter->vfs_allocated_count; in igb_vlan_rx_kill_vid()
9275 struct e1000_hw *hw = &adapter->hw; in igb_vlan_rx_kill_vid()
9278 if (vid && !(adapter->flags & IGB_FLAG_VLAN_PROMISC)) in igb_vlan_rx_kill_vid()
9281 clear_bit(vid, adapter->active_vlans); in igb_vlan_rx_kill_vid()
9290 igb_vlan_mode(adapter->netdev, adapter->netdev->features); in igb_restore_vlan()
9291 igb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), 0); in igb_restore_vlan()
9293 for_each_set_bit_from(vid, adapter->active_vlans, VLAN_N_VID) in igb_restore_vlan()
9294 igb_vlan_rx_add_vid(adapter->netdev, htons(ETH_P_8021Q), vid); in igb_restore_vlan()
9299 struct pci_dev *pdev = adapter->pdev; in igb_set_spd_dplx()
9300 struct e1000_mac_info *mac = &adapter->hw.mac; in igb_set_spd_dplx()
9302 mac->autoneg = 0; in igb_set_spd_dplx()
9313 if (adapter->hw.phy.media_type == e1000_media_type_internal_serdes) { in igb_set_spd_dplx()
9326 mac->forced_speed_duplex = ADVERTISE_10_HALF; in igb_set_spd_dplx()
9329 mac->forced_speed_duplex = ADVERTISE_10_FULL; in igb_set_spd_dplx()
9332 mac->forced_speed_duplex = ADVERTISE_100_HALF; in igb_set_spd_dplx()
9335 mac->forced_speed_duplex = ADVERTISE_100_FULL; in igb_set_spd_dplx()
9338 mac->autoneg = 1; in igb_set_spd_dplx()
9339 adapter->hw.phy.autoneg_advertised = ADVERTISE_1000_FULL; in igb_set_spd_dplx()
9346 /* clear MDI, MDI(-X) override is only allowed when autoneg enabled */ in igb_set_spd_dplx()
9347 adapter->hw.phy.mdix = AUTO_ALL_MODES; in igb_set_spd_dplx()
9352 dev_err(&pdev->dev, "Unsupported Speed/Duplex configuration\n"); in igb_set_spd_dplx()
9353 return -EINVAL; in igb_set_spd_dplx()
9361 struct e1000_hw *hw = &adapter->hw; in __igb_shutdown()
9363 u32 wufc = runtime ? E1000_WUFC_LNKC : adapter->wol; in __igb_shutdown()
9385 /* turn on all-multi mode if wake on multicast is enabled */ in __igb_shutdown()
9406 wake = wufc || adapter->en_mng_pt; in __igb_shutdown()
9428 struct e1000_hw *hw = &adapter->hw; in igb_deliver_wake_packet()
9446 /* Ensure reads are 32-bit aligned */ in igb_deliver_wake_packet()
9449 memcpy_fromio(skb->data, hw->hw_addr + E1000_WUPM_REG(0), wupl); in igb_deliver_wake_packet()
9451 skb->protocol = eth_type_trans(skb, netdev); in igb_deliver_wake_packet()
9465 struct e1000_hw *hw = &adapter->hw; in __igb_resume()
9473 return -ENODEV; in __igb_resume()
9476 dev_err(&pdev->dev, in __igb_resume()
9486 dev_err(&pdev->dev, "Unable to allocate memory for queues\n"); in __igb_resume()
9487 return -ENOMEM; in __igb_resume()
9529 return -EBUSY; in igb_runtime_idle()
9570 * igb_io_error_detected - called when PCI error is detected
9584 dev_warn(&pdev->dev, "Non-correctable non-fatal error reported.\n"); in igb_io_error_detected()
9602 * igb_io_slot_reset - called after the pci bus has been reset.
9605 * Restart the card from scratch, as if from a cold-boot. Implementation
9606 * resembles the first-half of the __igb_resume routine.
9612 struct e1000_hw *hw = &adapter->hw; in igb_io_slot_reset()
9616 dev_err(&pdev->dev, in igb_io_slot_reset()
9617 "Cannot re-enable PCI device after reset.\n"); in igb_io_slot_reset()
9628 * so we should re-assign it here. in igb_io_slot_reset()
9630 hw->hw_addr = adapter->io_addr; in igb_io_slot_reset()
9641 * igb_io_resume - called when traffic can start flowing again.
9646 * second-half of the __igb_resume routine.
9654 if (!test_bit(__IGB_DOWN, &adapter->state)) { in igb_io_resume()
9655 dev_dbg(&pdev->dev, "Resuming from non-fatal error, do nothing.\n"); in igb_io_resume()
9659 dev_err(&pdev->dev, "igb_up failed after reset\n"); in igb_io_resume()
9673 * igb_rar_set_index - Sync RAL[index] and RAH[index] registers with MAC table
9679 struct e1000_hw *hw = &adapter->hw; in igb_rar_set_index()
9681 u8 *addr = adapter->mac_table[index].addr; in igb_rar_set_index()
9692 if (adapter->mac_table[index].state & IGB_MAC_STATE_IN_USE) { in igb_rar_set_index()
9696 if (adapter->mac_table[index].state & IGB_MAC_STATE_SRC_ADDR) in igb_rar_set_index()
9699 switch (hw->mac.type) { in igb_rar_set_index()
9702 if (adapter->mac_table[index].state & in igb_rar_set_index()
9707 adapter->mac_table[index].queue; in igb_rar_set_index()
9711 adapter->mac_table[index].queue; in igb_rar_set_index()
9725 struct e1000_hw *hw = &adapter->hw; in igb_set_vf_mac()
9729 int rar_entry = hw->mac.rar_entry_count - (vf + 1); in igb_set_vf_mac()
9730 unsigned char *vf_mac_addr = adapter->vf_data[vf].vf_mac_addresses; in igb_set_vf_mac()
9733 ether_addr_copy(adapter->mac_table[rar_entry].addr, mac_addr); in igb_set_vf_mac()
9734 adapter->mac_table[rar_entry].queue = vf; in igb_set_vf_mac()
9735 adapter->mac_table[rar_entry].state |= IGB_MAC_STATE_IN_USE; in igb_set_vf_mac()
9745 if (vf >= adapter->vfs_allocated_count) in igb_ndo_set_vf_mac()
9746 return -EINVAL; in igb_ndo_set_vf_mac()
9751 * MAC after unbinding vfio-pci and reloading igbvf after shutting in igb_ndo_set_vf_mac()
9755 adapter->vf_data[vf].flags &= ~IGB_VF_FLAG_PF_SET_MAC; in igb_ndo_set_vf_mac()
9756 dev_info(&adapter->pdev->dev, in igb_ndo_set_vf_mac()
9760 adapter->vf_data[vf].flags |= IGB_VF_FLAG_PF_SET_MAC; in igb_ndo_set_vf_mac()
9761 dev_info(&adapter->pdev->dev, "setting MAC %pM on VF %d\n", in igb_ndo_set_vf_mac()
9763 dev_info(&adapter->pdev->dev, in igb_ndo_set_vf_mac()
9766 if (test_bit(__IGB_DOWN, &adapter->state)) { in igb_ndo_set_vf_mac()
9767 dev_warn(&adapter->pdev->dev, in igb_ndo_set_vf_mac()
9769 dev_warn(&adapter->pdev->dev, in igb_ndo_set_vf_mac()
9773 return -EINVAL; in igb_ndo_set_vf_mac()
9799 rf_dec = (link_speed - (rf_int * tx_rate)); in igb_set_vf_rate_limit()
9812 * register. MMW_SIZE=0x014 if 9728-byte jumbo is supported. in igb_set_vf_rate_limit()
9824 if ((adapter->vf_rate_link_speed == 0) || in igb_check_vf_rate_limit()
9825 (adapter->hw.mac.type != e1000_82576)) in igb_check_vf_rate_limit()
9828 actual_link_speed = igb_link_mbps(adapter->link_speed); in igb_check_vf_rate_limit()
9829 if (actual_link_speed != adapter->vf_rate_link_speed) { in igb_check_vf_rate_limit()
9831 adapter->vf_rate_link_speed = 0; in igb_check_vf_rate_limit()
9832 dev_info(&adapter->pdev->dev, in igb_check_vf_rate_limit()
9836 for (i = 0; i < adapter->vfs_allocated_count; i++) { in igb_check_vf_rate_limit()
9838 adapter->vf_data[i].tx_rate = 0; in igb_check_vf_rate_limit()
9840 igb_set_vf_rate_limit(&adapter->hw, i, in igb_check_vf_rate_limit()
9841 adapter->vf_data[i].tx_rate, in igb_check_vf_rate_limit()
9850 struct e1000_hw *hw = &adapter->hw; in igb_ndo_set_vf_bw()
9853 if (hw->mac.type != e1000_82576) in igb_ndo_set_vf_bw()
9854 return -EOPNOTSUPP; in igb_ndo_set_vf_bw()
9857 return -EINVAL; in igb_ndo_set_vf_bw()
9859 actual_link_speed = igb_link_mbps(adapter->link_speed); in igb_ndo_set_vf_bw()
9860 if ((vf >= adapter->vfs_allocated_count) || in igb_ndo_set_vf_bw()
9864 return -EINVAL; in igb_ndo_set_vf_bw()
9866 adapter->vf_rate_link_speed = actual_link_speed; in igb_ndo_set_vf_bw()
9867 adapter->vf_data[vf].tx_rate = (u16)max_tx_rate; in igb_ndo_set_vf_bw()
9877 struct e1000_hw *hw = &adapter->hw; in igb_ndo_set_vf_spoofchk()
9880 if (!adapter->vfs_allocated_count) in igb_ndo_set_vf_spoofchk()
9881 return -EOPNOTSUPP; in igb_ndo_set_vf_spoofchk()
9883 if (vf >= adapter->vfs_allocated_count) in igb_ndo_set_vf_spoofchk()
9884 return -EINVAL; in igb_ndo_set_vf_spoofchk()
9886 reg_offset = (hw->mac.type == e1000_82576) ? E1000_DTXSWC : E1000_TXSWC; in igb_ndo_set_vf_spoofchk()
9896 adapter->vf_data[vf].spoofchk_enabled = setting; in igb_ndo_set_vf_spoofchk()
9904 if (vf >= adapter->vfs_allocated_count) in igb_ndo_set_vf_trust()
9905 return -EINVAL; in igb_ndo_set_vf_trust()
9906 if (adapter->vf_data[vf].trusted == setting) in igb_ndo_set_vf_trust()
9909 adapter->vf_data[vf].trusted = setting; in igb_ndo_set_vf_trust()
9911 dev_info(&adapter->pdev->dev, "VF %u is %strusted\n", in igb_ndo_set_vf_trust()
9920 if (vf >= adapter->vfs_allocated_count) in igb_ndo_get_vf_config()
9921 return -EINVAL; in igb_ndo_get_vf_config()
9922 ivi->vf = vf; in igb_ndo_get_vf_config()
9923 memcpy(&ivi->mac, adapter->vf_data[vf].vf_mac_addresses, ETH_ALEN); in igb_ndo_get_vf_config()
9924 ivi->max_tx_rate = adapter->vf_data[vf].tx_rate; in igb_ndo_get_vf_config()
9925 ivi->min_tx_rate = 0; in igb_ndo_get_vf_config()
9926 ivi->vlan = adapter->vf_data[vf].pf_vlan; in igb_ndo_get_vf_config()
9927 ivi->qos = adapter->vf_data[vf].pf_qos; in igb_ndo_get_vf_config()
9928 ivi->spoofchk = adapter->vf_data[vf].spoofchk_enabled; in igb_ndo_get_vf_config()
9929 ivi->trusted = adapter->vf_data[vf].trusted; in igb_ndo_get_vf_config()
9935 struct e1000_hw *hw = &adapter->hw; in igb_vmm_control()
9938 switch (hw->mac.type) { in igb_vmm_control()
9963 if (adapter->vfs_allocated_count) { in igb_vmm_control()
9967 adapter->vfs_allocated_count); in igb_vmm_control()
9976 struct e1000_hw *hw = &adapter->hw; in igb_init_dmac()
9981 if (hw->mac.type > e1000_82580) { in igb_init_dmac()
9982 if (adapter->flags & IGB_FLAG_DMAC) { in igb_init_dmac()
9987 * than the Rx threshold. Set hwm to PBA - max frame in igb_init_dmac()
9988 * size in 16B units, capping it at PBA - 6KB. in igb_init_dmac()
9990 hwm = 64 * (pba - 6); in igb_init_dmac()
9996 /* Set the DMA Coalescing Rx threshold to PBA - 2 * max in igb_init_dmac()
9997 * frame size, capping it at PBA - 10KB. in igb_init_dmac()
9999 dmac_thr = pba - 10; in igb_init_dmac()
10007 /* watchdog timer= +-1000 usec in 32usec intervals */ in igb_init_dmac()
10010 /* Disable BMC-to-OS Watchdog Enable */ in igb_init_dmac()
10011 if (hw->mac.type != e1000_i354) in igb_init_dmac()
10016 * coalescing(smart fifb)-UTRESH=0 in igb_init_dmac()
10027 wr32(E1000_DMCTXTH, (IGB_MIN_TXPBSIZE - in igb_init_dmac()
10028 (IGB_TX_BUF_4096 + adapter->max_frame_size)) >> 6); in igb_init_dmac()
10031 if (hw->mac.type >= e1000_i210 || in igb_init_dmac()
10032 (adapter->flags & IGB_FLAG_DMAC)) { in igb_init_dmac()
10036 } /* endif adapter->dmac is not disabled */ in igb_init_dmac()
10037 } else if (hw->mac.type == e1000_82580) { in igb_init_dmac()
10046 * igb_read_i2c_byte - Reads 8 bit word over I2C
10059 struct i2c_client *this_client = adapter->i2c_client; in igb_read_i2c_byte()
10068 if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask)) in igb_read_i2c_byte()
10072 hw->mac.ops.release_swfw_sync(hw, swfw_mask); in igb_read_i2c_byte()
10083 * igb_write_i2c_byte - Writes 8 bit word over I2C
10096 struct i2c_client *this_client = adapter->i2c_client; in igb_write_i2c_byte()
10103 if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask)) in igb_write_i2c_byte()
10106 hw->mac.ops.release_swfw_sync(hw, swfw_mask); in igb_write_i2c_byte()
10117 struct net_device *netdev = adapter->netdev; in igb_reinit_queues()
10118 struct pci_dev *pdev = adapter->pdev; in igb_reinit_queues()
10127 dev_err(&pdev->dev, "Unable to allocate memory for queues\n"); in igb_reinit_queues()
10128 return -ENOMEM; in igb_reinit_queues()
10141 spin_lock(&adapter->nfc_lock); in igb_nfc_filter_exit()
10143 hlist_for_each_entry(rule, &adapter->nfc_filter_list, nfc_node) in igb_nfc_filter_exit()
10146 hlist_for_each_entry(rule, &adapter->cls_flower_list, nfc_node) in igb_nfc_filter_exit()
10149 spin_unlock(&adapter->nfc_lock); in igb_nfc_filter_exit()
10156 spin_lock(&adapter->nfc_lock); in igb_nfc_filter_restore()
10158 hlist_for_each_entry(rule, &adapter->nfc_filter_list, nfc_node) in igb_nfc_filter_restore()
10161 spin_unlock(&adapter->nfc_lock); in igb_nfc_filter_restore()