forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/net/ethernet/intel/e1000e/netdev.c
....@@ -28,11 +28,7 @@
2828
2929 #include "e1000.h"
3030
31
-#define DRV_EXTRAVERSION "-k"
32
-
33
-#define DRV_VERSION "3.2.6" DRV_EXTRAVERSION
3431 char e1000e_driver_name[] = "e1000e";
35
-const char e1000e_driver_version[] = DRV_VERSION;
3632
3733 #define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV|NETIF_MSG_PROBE|NETIF_MSG_LINK)
3834 static int debug = -1;
....@@ -54,6 +50,7 @@
5450 [board_pch_lpt] = &e1000_pch_lpt_info,
5551 [board_pch_spt] = &e1000_pch_spt_info,
5652 [board_pch_cnp] = &e1000_pch_cnp_info,
53
+ [board_pch_tgp] = &e1000_pch_tgp_info,
5754 };
5855
5956 struct e1000_reg_info {
....@@ -466,6 +463,7 @@
466463
467464 /**
468465 * e1000_desc_unused - calculate if we have unused descriptors
466
+ * @ring: pointer to ring struct to perform calculation on
469467 **/
470468 static int e1000_desc_unused(struct e1000_ring *ring)
471469 {
....@@ -542,6 +540,7 @@
542540 /**
543541 * e1000_receive_skb - helper function to handle Rx indications
544542 * @adapter: board private structure
543
+ * @netdev: pointer to netdev struct
545544 * @staterr: descriptor extended error and status field as written by hardware
546545 * @vlan: descriptor vlan field as written by hardware (no le/be conversion)
547546 * @skb: pointer to sk_buff to be indicated to stack
....@@ -566,8 +565,7 @@
566565 * e1000_rx_checksum - Receive Checksum Offload
567566 * @adapter: board private structure
568567 * @status_err: receive descriptor status and error fields
569
- * @csum: receive descriptor csum field
570
- * @sk_buff: socket buffer with received data
568
+ * @skb: socket buffer with received data
571569 **/
572570 static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,
573571 struct sk_buff *skb)
....@@ -638,6 +636,8 @@
638636 /**
639637 * e1000_alloc_rx_buffers - Replace used receive buffers
640638 * @rx_ring: Rx descriptor ring
639
+ * @cleaned_count: number to reallocate
640
+ * @gfp: flags for allocation
641641 **/
642642 static void e1000_alloc_rx_buffers(struct e1000_ring *rx_ring,
643643 int cleaned_count, gfp_t gfp)
....@@ -706,6 +706,8 @@
706706 /**
707707 * e1000_alloc_rx_buffers_ps - Replace used receive buffers; packet split
708708 * @rx_ring: Rx descriptor ring
709
+ * @cleaned_count: number to reallocate
710
+ * @gfp: flags for allocation
709711 **/
710712 static void e1000_alloc_rx_buffers_ps(struct e1000_ring *rx_ring,
711713 int cleaned_count, gfp_t gfp)
....@@ -809,6 +811,7 @@
809811 * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers
810812 * @rx_ring: Rx descriptor ring
811813 * @cleaned_count: number of buffers to allocate this pass
814
+ * @gfp: flags for allocation
812815 **/
813816
814817 static void e1000_alloc_jumbo_rx_buffers(struct e1000_ring *rx_ring,
....@@ -898,6 +901,8 @@
898901 /**
899902 * e1000_clean_rx_irq - Send received data up the network stack
900903 * @rx_ring: Rx descriptor ring
904
+ * @work_done: output parameter for indicating completed work
905
+ * @work_to_do: how many packets we can clean
901906 *
902907 * the return value indicates whether actual cleaning was done, there
903908 * is no guarantee that everything was cleaned
....@@ -1292,6 +1297,8 @@
12921297 /**
12931298 * e1000_clean_rx_irq_ps - Send received data up the network stack; packet split
12941299 * @rx_ring: Rx descriptor ring
1300
+ * @work_done: output parameter for indicating completed work
1301
+ * @work_to_do: how many packets we can clean
12951302 *
12961303 * the return value indicates whether actual cleaning was done, there
12971304 * is no guarantee that everything was cleaned
....@@ -1482,9 +1489,6 @@
14821489 return cleaned;
14831490 }
14841491
1485
-/**
1486
- * e1000_consume_page - helper function
1487
- **/
14881492 static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb,
14891493 u16 length)
14901494 {
....@@ -1496,7 +1500,9 @@
14961500
14971501 /**
14981502 * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy
1499
- * @adapter: board private structure
1503
+ * @rx_ring: Rx descriptor ring
1504
+ * @work_done: output parameter for indicating completed work
1505
+ * @work_to_do: how many packets we can clean
15001506 *
15011507 * the return value indicates whether actual cleaning was done, there
15021508 * is no guarantee that everything was cleaned
....@@ -1959,6 +1965,7 @@
19591965
19601966 /**
19611967 * e1000_configure_msix - Configure MSI-X hardware
1968
+ * @adapter: board private structure
19621969 *
19631970 * e1000_configure_msix sets up the hardware to properly
19641971 * generate MSI-X interrupts.
....@@ -2037,6 +2044,7 @@
20372044
20382045 /**
20392046 * e1000e_set_interrupt_capability - set MSI or MSI-X if supported
2047
+ * @adapter: board private structure
20402048 *
20412049 * Attempt to configure interrupts using the best available
20422050 * capabilities of the hardware and kernel.
....@@ -2072,7 +2080,7 @@
20722080 e1000e_reset_interrupt_capability(adapter);
20732081 }
20742082 adapter->int_mode = E1000E_INT_MODE_MSI;
2075
- /* Fall through */
2083
+ fallthrough;
20762084 case E1000E_INT_MODE_MSI:
20772085 if (!pci_enable_msi(adapter->pdev)) {
20782086 adapter->flags |= FLAG_MSI_ENABLED;
....@@ -2080,7 +2088,7 @@
20802088 adapter->int_mode = E1000E_INT_MODE_LEGACY;
20812089 e_err("Failed to initialize MSI interrupts. Falling back to legacy interrupts.\n");
20822090 }
2083
- /* Fall through */
2091
+ fallthrough;
20842092 case E1000E_INT_MODE_LEGACY:
20852093 /* Don't do anything; this is the system default */
20862094 break;
....@@ -2092,6 +2100,7 @@
20922100
20932101 /**
20942102 * e1000_request_msix - Initialize MSI-X interrupts
2103
+ * @adapter: board private structure
20952104 *
20962105 * e1000_request_msix allocates MSI-X vectors and requests interrupts from the
20972106 * kernel.
....@@ -2145,6 +2154,7 @@
21452154
21462155 /**
21472156 * e1000_request_irq - initialize interrupts
2157
+ * @adapter: board private structure
21482158 *
21492159 * Attempts to configure interrupts using the best available
21502160 * capabilities of the hardware and kernel.
....@@ -2205,6 +2215,7 @@
22052215
22062216 /**
22072217 * e1000_irq_disable - Mask off interrupt generation on the NIC
2218
+ * @adapter: board private structure
22082219 **/
22092220 static void e1000_irq_disable(struct e1000_adapter *adapter)
22102221 {
....@@ -2227,6 +2238,7 @@
22272238
22282239 /**
22292240 * e1000_irq_enable - Enable default interrupt generation settings
2241
+ * @adapter: board private structure
22302242 **/
22312243 static void e1000_irq_enable(struct e1000_adapter *adapter)
22322244 {
....@@ -2297,14 +2309,16 @@
22972309
22982310 /**
22992311 * e1000_alloc_ring_dma - allocate memory for a ring structure
2312
+ * @adapter: board private structure
2313
+ * @ring: ring struct for which to allocate dma
23002314 **/
23012315 static int e1000_alloc_ring_dma(struct e1000_adapter *adapter,
23022316 struct e1000_ring *ring)
23032317 {
23042318 struct pci_dev *pdev = adapter->pdev;
23052319
2306
- ring->desc = dma_zalloc_coherent(&pdev->dev, ring->size, &ring->dma,
2307
- GFP_KERNEL);
2320
+ ring->desc = dma_alloc_coherent(&pdev->dev, ring->size, &ring->dma,
2321
+ GFP_KERNEL);
23082322 if (!ring->desc)
23092323 return -ENOMEM;
23102324
....@@ -2472,7 +2486,6 @@
24722486
24732487 /**
24742488 * e1000_update_itr - update the dynamic ITR value based on statistics
2475
- * @adapter: pointer to adapter
24762489 * @itr_setting: current adapter->itr
24772490 * @packets: the number of packets during this measurement interval
24782491 * @bytes: the number of bytes during this measurement interval
....@@ -2649,9 +2662,9 @@
26492662 /**
26502663 * e1000e_poll - NAPI Rx polling callback
26512664 * @napi: struct associated with this polling callback
2652
- * @weight: number of packets driver is allowed to process this poll
2665
+ * @budget: number of packets driver is allowed to process this poll
26532666 **/
2654
-static int e1000e_poll(struct napi_struct *napi, int weight)
2667
+static int e1000e_poll(struct napi_struct *napi, int budget)
26552668 {
26562669 struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter,
26572670 napi);
....@@ -2665,16 +2678,17 @@
26652678 (adapter->rx_ring->ims_val & adapter->tx_ring->ims_val))
26662679 tx_cleaned = e1000_clean_tx_irq(adapter->tx_ring);
26672680
2668
- adapter->clean_rx(adapter->rx_ring, &work_done, weight);
2681
+ adapter->clean_rx(adapter->rx_ring, &work_done, budget);
26692682
2670
- if (!tx_cleaned)
2671
- work_done = weight;
2683
+ if (!tx_cleaned || work_done == budget)
2684
+ return budget;
26722685
2673
- /* If weight not fully consumed, exit the polling mode */
2674
- if (work_done < weight) {
2686
+ /* Exit the polling mode, but don't re-enable interrupts if stack might
2687
+ * poll us due to busy-polling
2688
+ */
2689
+ if (likely(napi_complete_done(napi, work_done))) {
26752690 if (adapter->itr_setting & 3)
26762691 e1000_set_itr(adapter);
2677
- napi_complete_done(napi, work_done);
26782692 if (!test_bit(__E1000_DOWN, &adapter->state)) {
26792693 if (adapter->msix_entries)
26802694 ew32(IMS, adapter->rx_ring->ims_val);
....@@ -3013,12 +3027,13 @@
30133027 }
30143028 }
30153029
3030
+#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
3031
+ (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
3032
+
30163033 /**
30173034 * e1000_setup_rctl - configure the receive control registers
30183035 * @adapter: Board private structure
30193036 **/
3020
-#define PAGE_USE_COUNT(S) (((S) >> PAGE_SHIFT) + \
3021
- (((S) & (PAGE_SIZE - 1)) ? 1 : 0))
30223037 static void e1000_setup_rctl(struct e1000_adapter *adapter)
30233038 {
30243039 struct e1000_hw *hw = &adapter->hw;
....@@ -3137,10 +3152,10 @@
31373152 switch (adapter->rx_ps_pages) {
31383153 case 3:
31393154 psrctl |= PAGE_SIZE << E1000_PSRCTL_BSIZE3_SHIFT;
3140
- /* fall-through */
3155
+ fallthrough;
31413156 case 2:
31423157 psrctl |= PAGE_SIZE << E1000_PSRCTL_BSIZE2_SHIFT;
3143
- /* fall-through */
3158
+ fallthrough;
31443159 case 1:
31453160 psrctl |= PAGE_SIZE >> E1000_PSRCTL_BSIZE1_SHIFT;
31463161 break;
....@@ -3205,7 +3220,7 @@
32053220 if (!(adapter->flags2 & FLAG2_NO_DISABLE_RX))
32063221 ew32(RCTL, rctl & ~E1000_RCTL_EN);
32073222 e1e_flush();
3208
- usleep_range(10000, 20000);
3223
+ usleep_range(10000, 11000);
32093224
32103225 if (adapter->flags2 & FLAG2_DMA_BURST) {
32113226 /* set the writeback threshold (only takes effect if the RDTR
....@@ -3277,10 +3292,10 @@
32773292
32783293 dev_info(&adapter->pdev->dev,
32793294 "Some CPU C-states have been disabled in order to enable jumbo frames\n");
3280
- pm_qos_update_request(&adapter->pm_qos_req, lat);
3295
+ cpu_latency_qos_update_request(&adapter->pm_qos_req, lat);
32813296 } else {
3282
- pm_qos_update_request(&adapter->pm_qos_req,
3283
- PM_QOS_DEFAULT_VALUE);
3297
+ cpu_latency_qos_update_request(&adapter->pm_qos_req,
3298
+ PM_QOS_DEFAULT_VALUE);
32843299 }
32853300
32863301 /* Enable Receives */
....@@ -3532,6 +3547,9 @@
35323547 adapter->cc.shift = shift;
35333548 break;
35343549 case e1000_pch_cnp:
3550
+ case e1000_pch_tgp:
3551
+ case e1000_pch_adp:
3552
+ case e1000_pch_mtp:
35353553 if (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_SYSCFI) {
35363554 /* Stable 24MHz frequency */
35373555 incperiod = INCPERIOD_24MHZ;
....@@ -3567,6 +3585,7 @@
35673585 /**
35683586 * e1000e_config_hwtstamp - configure the hwtstamp registers and enable/disable
35693587 * @adapter: board private structure
3588
+ * @config: timestamp configuration
35703589 *
35713590 * Outgoing time stamping can be enabled and disabled. Play nice and
35723591 * disable it when requested, although it shouldn't cause any overhead
....@@ -3635,9 +3654,8 @@
36353654 is_l2 = true;
36363655 break;
36373656 case HWTSTAMP_FILTER_PTP_V2_L4_SYNC:
3638
- /* Hardware cannot filter just V2 L4 Sync messages;
3639
- * fall-through to V2 (both L2 and L4) Sync.
3640
- */
3657
+ /* Hardware cannot filter just V2 L4 Sync messages */
3658
+ fallthrough;
36413659 case HWTSTAMP_FILTER_PTP_V2_SYNC:
36423660 /* Also time stamps V2 Path Delay Request/Response. */
36433661 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_L4_V2;
....@@ -3646,9 +3664,8 @@
36463664 is_l4 = true;
36473665 break;
36483666 case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ:
3649
- /* Hardware cannot filter just V2 L4 Delay Request messages;
3650
- * fall-through to V2 (both L2 and L4) Delay Request.
3651
- */
3667
+ /* Hardware cannot filter just V2 L4 Delay Request messages */
3668
+ fallthrough;
36523669 case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ:
36533670 /* Also time stamps V2 Path Delay Request/Response. */
36543671 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_L4_V2;
....@@ -3658,9 +3675,8 @@
36583675 break;
36593676 case HWTSTAMP_FILTER_PTP_V2_L4_EVENT:
36603677 case HWTSTAMP_FILTER_PTP_V2_L2_EVENT:
3661
- /* Hardware cannot filter just V2 L4 or L2 Event messages;
3662
- * fall-through to all V2 (both L2 and L4) Events.
3663
- */
3678
+ /* Hardware cannot filter just V2 L4 or L2 Event messages */
3679
+ fallthrough;
36643680 case HWTSTAMP_FILTER_PTP_V2_EVENT:
36653681 tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_EVENT_V2;
36663682 config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT;
....@@ -3672,6 +3688,7 @@
36723688 * Delay Request messages but not both so fall-through to
36733689 * time stamp all packets.
36743690 */
3691
+ fallthrough;
36753692 case HWTSTAMP_FILTER_NTP_ALL:
36763693 case HWTSTAMP_FILTER_ALL:
36773694 is_l2 = true;
....@@ -3772,6 +3789,7 @@
37723789
37733790 /**
37743791 * e1000_power_down_phy - Power down the PHY
3792
+ * @adapter: board private structure
37753793 *
37763794 * Power down the PHY so no link is implied when interface is down.
37773795 * The PHY cannot be powered down if management or WoL is active.
....@@ -3784,6 +3802,7 @@
37843802
37853803 /**
37863804 * e1000_flush_tx_ring - remove all descriptors from the tx_ring
3805
+ * @adapter: board private structure
37873806 *
37883807 * We want to clear all pending descriptors from the TX ring.
37893808 * zeroing happens when the HW reads the regs. We assign the ring itself as
....@@ -3803,7 +3822,7 @@
38033822 tdt = er32(TDT(0));
38043823 BUG_ON(tdt != tx_ring->next_to_use);
38053824 tx_desc = E1000_TX_DESC(*tx_ring, tx_ring->next_to_use);
3806
- tx_desc->buffer_addr = tx_ring->dma;
3825
+ tx_desc->buffer_addr = cpu_to_le64(tx_ring->dma);
38073826
38083827 tx_desc->lower.data = cpu_to_le32(txd_lower | size);
38093828 tx_desc->upper.data = 0;
....@@ -3813,12 +3832,12 @@
38133832 if (tx_ring->next_to_use == tx_ring->count)
38143833 tx_ring->next_to_use = 0;
38153834 ew32(TDT(0), tx_ring->next_to_use);
3816
- mmiowb();
38173835 usleep_range(200, 250);
38183836 }
38193837
38203838 /**
38213839 * e1000_flush_rx_ring - remove all descriptors from the rx_ring
3840
+ * @adapter: board private structure
38223841 *
38233842 * Mark all descriptors in the RX ring as consumed and disable the rx ring
38243843 */
....@@ -3851,6 +3870,7 @@
38513870
38523871 /**
38533872 * e1000_flush_desc_rings - remove all descriptors from the descriptor rings
3873
+ * @adapter: board private structure
38543874 *
38553875 * In i219, the descriptor rings must be emptied before resetting the HW
38563876 * or before changing the device state to D3 during runtime (runtime PM).
....@@ -3933,6 +3953,7 @@
39333953
39343954 /**
39353955 * e1000e_reset - bring the hardware into a known good state
3956
+ * @adapter: board private structure
39363957 *
39373958 * This function boots the hardware and enables some settings that
39383959 * require a configuration cycle of the hardware - those cannot be
....@@ -4019,7 +4040,7 @@
40194040 fc->low_water = fc->high_water - 8;
40204041 break;
40214042 }
4022
- /* fall-through */
4043
+ fallthrough;
40234044 default:
40244045 hwm = min(((pba << 10) * 9 / 10),
40254046 ((pba << 10) - adapter->max_frame_size));
....@@ -4044,12 +4065,15 @@
40444065 case e1000_pch_lpt:
40454066 case e1000_pch_spt:
40464067 case e1000_pch_cnp:
4047
- fc->refresh_time = 0x0400;
4068
+ case e1000_pch_tgp:
4069
+ case e1000_pch_adp:
4070
+ case e1000_pch_mtp:
4071
+ fc->refresh_time = 0xFFFF;
4072
+ fc->pause_time = 0xFFFF;
40484073
40494074 if (adapter->netdev->mtu <= ETH_DATA_LEN) {
40504075 fc->high_water = 0x05C20;
40514076 fc->low_water = 0x05048;
4052
- fc->pause_time = 0x0650;
40534077 break;
40544078 }
40554079
....@@ -4270,7 +4294,7 @@
42704294
42714295 /* flush both disables and wait for them to finish */
42724296 e1e_flush();
4273
- usleep_range(10000, 20000);
4297
+ usleep_range(10000, 11000);
42744298
42754299 e1000_irq_disable(adapter);
42764300
....@@ -4308,7 +4332,7 @@
43084332 {
43094333 might_sleep();
43104334 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
4311
- usleep_range(1000, 2000);
4335
+ usleep_range(1000, 1100);
43124336 e1000e_down(adapter, true);
43134337 e1000e_up(adapter);
43144338 clear_bit(__E1000_RESETTING, &adapter->state);
....@@ -4317,13 +4341,16 @@
43174341 /**
43184342 * e1000e_sanitize_systim - sanitize raw cycle counter reads
43194343 * @hw: pointer to the HW structure
4320
- * @systim: time value read, sanitized and returned
4344
+ * @systim: PHC time value read, sanitized and returned
4345
+ * @sts: structure to hold system time before and after reading SYSTIML,
4346
+ * may be NULL
43214347 *
43224348 * Errata for 82574/82583 possible bad bits read from SYSTIMH/L:
43234349 * check to see that the time is incrementing at a reasonable
43244350 * rate and is a multiple of incvalue.
43254351 **/
4326
-static u64 e1000e_sanitize_systim(struct e1000_hw *hw, u64 systim)
4352
+static u64 e1000e_sanitize_systim(struct e1000_hw *hw, u64 systim,
4353
+ struct ptp_system_timestamp *sts)
43274354 {
43284355 u64 time_delta, rem, temp;
43294356 u64 systim_next;
....@@ -4333,7 +4360,9 @@
43334360 incvalue = er32(TIMINCA) & E1000_TIMINCA_INCVALUE_MASK;
43344361 for (i = 0; i < E1000_MAX_82574_SYSTIM_REREADS; i++) {
43354362 /* latch SYSTIMH on read of SYSTIML */
4363
+ ptp_read_system_prets(sts);
43364364 systim_next = (u64)er32(SYSTIML);
4365
+ ptp_read_system_postts(sts);
43374366 systim_next |= (u64)er32(SYSTIMH) << 32;
43384367
43394368 time_delta = systim_next - systim;
....@@ -4351,15 +4380,16 @@
43514380 }
43524381
43534382 /**
4354
- * e1000e_cyclecounter_read - read raw cycle counter (used by time counter)
4355
- * @cc: cyclecounter structure
4383
+ * e1000e_read_systim - read SYSTIM register
4384
+ * @adapter: board private structure
4385
+ * @sts: structure which will contain system time before and after reading
4386
+ * SYSTIML, may be NULL
43564387 **/
4357
-static u64 e1000e_cyclecounter_read(const struct cyclecounter *cc)
4388
+u64 e1000e_read_systim(struct e1000_adapter *adapter,
4389
+ struct ptp_system_timestamp *sts)
43584390 {
4359
- struct e1000_adapter *adapter = container_of(cc, struct e1000_adapter,
4360
- cc);
43614391 struct e1000_hw *hw = &adapter->hw;
4362
- u32 systimel, systimeh;
4392
+ u32 systimel, systimel_2, systimeh;
43634393 u64 systim;
43644394 /* SYSTIMH latching upon SYSTIML read does not work well.
43654395 * This means that if SYSTIML overflows after we read it but before
....@@ -4367,11 +4397,15 @@
43674397 * will experience a huge non linear increment in the systime value
43684398 * to fix that we test for overflow and if true, we re-read systime.
43694399 */
4400
+ ptp_read_system_prets(sts);
43704401 systimel = er32(SYSTIML);
4402
+ ptp_read_system_postts(sts);
43714403 systimeh = er32(SYSTIMH);
43724404 /* Is systimel is so large that overflow is possible? */
43734405 if (systimel >= (u32)0xffffffff - E1000_TIMINCA_INCVALUE_MASK) {
4374
- u32 systimel_2 = er32(SYSTIML);
4406
+ ptp_read_system_prets(sts);
4407
+ systimel_2 = er32(SYSTIML);
4408
+ ptp_read_system_postts(sts);
43754409 if (systimel > systimel_2) {
43764410 /* There was an overflow, read again SYSTIMH, and use
43774411 * systimel_2
....@@ -4384,9 +4418,21 @@
43844418 systim |= (u64)systimeh << 32;
43854419
43864420 if (adapter->flags2 & FLAG2_CHECK_SYSTIM_OVERFLOW)
4387
- systim = e1000e_sanitize_systim(hw, systim);
4421
+ systim = e1000e_sanitize_systim(hw, systim, sts);
43884422
43894423 return systim;
4424
+}
4425
+
4426
+/**
4427
+ * e1000e_cyclecounter_read - read raw cycle counter (used by time counter)
4428
+ * @cc: cyclecounter structure
4429
+ **/
4430
+static u64 e1000e_cyclecounter_read(const struct cyclecounter *cc)
4431
+{
4432
+ struct e1000_adapter *adapter = container_of(cc, struct e1000_adapter,
4433
+ cc);
4434
+
4435
+ return e1000e_read_systim(adapter, NULL);
43904436 }
43914437
43924438 /**
....@@ -4609,8 +4655,7 @@
46094655 e1000_update_mng_vlan(adapter);
46104656
46114657 /* DMA latency requirement to workaround jumbo issue */
4612
- pm_qos_add_request(&adapter->pm_qos_req, PM_QOS_CPU_DMA_LATENCY,
4613
- PM_QOS_DEFAULT_VALUE);
4658
+ cpu_latency_qos_add_request(&adapter->pm_qos_req, PM_QOS_DEFAULT_VALUE);
46144659
46154660 /* before we allocate an interrupt, we must be ready to handle it.
46164661 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt
....@@ -4652,7 +4697,7 @@
46524697 return 0;
46534698
46544699 err_req_irq:
4655
- pm_qos_remove_request(&adapter->pm_qos_req);
4700
+ cpu_latency_qos_remove_request(&adapter->pm_qos_req);
46564701 e1000e_release_hw_control(adapter);
46574702 e1000_power_down_phy(adapter);
46584703 e1000e_free_rx_resources(adapter->rx_ring);
....@@ -4683,18 +4728,18 @@
46834728 int count = E1000_CHECK_RESET_COUNT;
46844729
46854730 while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
4686
- usleep_range(10000, 20000);
4731
+ usleep_range(10000, 11000);
46874732
46884733 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
46894734
46904735 pm_runtime_get_sync(&pdev->dev);
46914736
4692
- if (!test_bit(__E1000_DOWN, &adapter->state)) {
4737
+ if (netif_device_present(netdev)) {
46934738 e1000e_down(adapter, true);
46944739 e1000_free_irq(adapter);
46954740
46964741 /* Link status message must follow this format */
4697
- pr_info("%s NIC Link is Down\n", adapter->netdev->name);
4742
+ netdev_info(netdev, "NIC Link is Down\n");
46984743 }
46994744
47004745 napi_disable(&adapter->napi);
....@@ -4716,7 +4761,7 @@
47164761 !test_bit(__E1000_TESTING, &adapter->state))
47174762 e1000e_release_hw_control(adapter);
47184763
4719
- pm_qos_remove_request(&adapter->pm_qos_req);
4764
+ cpu_latency_qos_remove_request(&adapter->pm_qos_req);
47204765
47214766 pm_runtime_put_sync(&pdev->dev);
47224767
....@@ -4789,7 +4834,7 @@
47894834
47904835 /**
47914836 * e1000_update_phy_info - timre call-back to update PHY info
4792
- * @data: pointer to adapter cast into an unsigned long
4837
+ * @t: pointer to timer_list containing private info adapter
47934838 *
47944839 * Need to wait a few seconds after link up to get diagnostic information from
47954840 * the phy
....@@ -5044,12 +5089,13 @@
50445089 u32 ctrl = er32(CTRL);
50455090
50465091 /* Link status message must follow this format for user tools */
5047
- pr_info("%s NIC Link is Up %d Mbps %s Duplex, Flow Control: %s\n",
5048
- adapter->netdev->name, adapter->link_speed,
5049
- adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half",
5050
- (ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE) ? "Rx/Tx" :
5051
- (ctrl & E1000_CTRL_RFCE) ? "Rx" :
5052
- (ctrl & E1000_CTRL_TFCE) ? "Tx" : "None");
5092
+ netdev_info(adapter->netdev,
5093
+ "NIC Link is Up %d Mbps %s Duplex, Flow Control: %s\n",
5094
+ adapter->link_speed,
5095
+ adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half",
5096
+ (ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE) ? "Rx/Tx" :
5097
+ (ctrl & E1000_CTRL_RFCE) ? "Rx" :
5098
+ (ctrl & E1000_CTRL_TFCE) ? "Tx" : "None");
50535099 }
50545100
50555101 static bool e1000e_has_link(struct e1000_adapter *adapter)
....@@ -5128,7 +5174,7 @@
51285174
51295175 /**
51305176 * e1000_watchdog - Timer Call-back
5131
- * @data: pointer to adapter cast into an unsigned long
5177
+ * @t: pointer to timer_list containing private info adapter
51325178 **/
51335179 static void e1000_watchdog(struct timer_list *t)
51345180 {
....@@ -5149,8 +5195,9 @@
51495195 struct e1000_mac_info *mac = &adapter->hw.mac;
51505196 struct e1000_phy_info *phy = &adapter->hw.phy;
51515197 struct e1000_ring *tx_ring = adapter->tx_ring;
5198
+ u32 dmoff_exit_timeout = 100, tries = 0;
51525199 struct e1000_hw *hw = &adapter->hw;
5153
- u32 link, tctl;
5200
+ u32 link, tctl, pcim_state;
51545201
51555202 if (test_bit(__E1000_DOWN, &adapter->state))
51565203 return;
....@@ -5174,6 +5221,23 @@
51745221
51755222 /* Cancel scheduled suspend requests. */
51765223 pm_runtime_resume(netdev->dev.parent);
5224
+
5225
+ /* Checking if MAC is in DMoff state*/
5226
+ if (er32(FWSM) & E1000_ICH_FWSM_FW_VALID) {
5227
+ pcim_state = er32(STATUS);
5228
+ while (pcim_state & E1000_STATUS_PCIM_STATE) {
5229
+ if (tries++ == dmoff_exit_timeout) {
5230
+ e_dbg("Error in exiting dmoff\n");
5231
+ break;
5232
+ }
5233
+ usleep_range(10000, 20000);
5234
+ pcim_state = er32(STATUS);
5235
+
5236
+ /* Checking if MAC exited DMoff state */
5237
+ if (!(pcim_state & E1000_STATUS_PCIM_STATE))
5238
+ e1000_phy_hw_reset(&adapter->hw);
5239
+ }
5240
+ }
51775241
51785242 /* update snapshot of PHY registers on LSC */
51795243 e1000_phy_read_status(adapter);
....@@ -5230,31 +5294,6 @@
52305294 ew32(TARC(0), tarc0);
52315295 }
52325296
5233
- /* disable TSO for pcie and 10/100 speeds, to avoid
5234
- * some hardware issues
5235
- */
5236
- if (!(adapter->flags & FLAG_TSO_FORCE)) {
5237
- switch (adapter->link_speed) {
5238
- case SPEED_10:
5239
- case SPEED_100:
5240
- e_info("10/100 speed: disabling TSO\n");
5241
- netdev->features &= ~NETIF_F_TSO;
5242
- netdev->features &= ~NETIF_F_TSO6;
5243
- break;
5244
- case SPEED_1000:
5245
- netdev->features |= NETIF_F_TSO;
5246
- netdev->features |= NETIF_F_TSO6;
5247
- break;
5248
- default:
5249
- /* oops */
5250
- break;
5251
- }
5252
- if (hw->mac.type == e1000_pch_spt) {
5253
- netdev->features &= ~NETIF_F_TSO;
5254
- netdev->features &= ~NETIF_F_TSO6;
5255
- }
5256
- }
5257
-
52585297 /* enable transmits in the hardware, need to do this
52595298 * after setting TARC(0)
52605299 */
....@@ -5280,7 +5319,7 @@
52805319 adapter->link_speed = 0;
52815320 adapter->link_duplex = 0;
52825321 /* Link status message must follow this format */
5283
- pr_info("%s NIC Link is Down\n", adapter->netdev->name);
5322
+ netdev_info(netdev, "NIC Link is Down\n");
52845323 netif_carrier_off(netdev);
52855324 netif_stop_queue(netdev);
52865325 if (!test_bit(__E1000_DOWN, &adapter->state))
....@@ -5422,10 +5461,7 @@
54225461 cmd_length = E1000_TXD_CMD_IP;
54235462 ipcse = skb_transport_offset(skb) - 1;
54245463 } else if (skb_is_gso_v6(skb)) {
5425
- ipv6_hdr(skb)->payload_len = 0;
5426
- tcp_hdr(skb)->check = ~csum_ipv6_magic(&ipv6_hdr(skb)->saddr,
5427
- &ipv6_hdr(skb)->daddr,
5428
- 0, IPPROTO_TCP, 0);
5464
+ tcp_v6_gso_csum_prep(skb);
54295465 ipcse = 0;
54305466 }
54315467 ipcss = skb_network_offset(skb);
....@@ -5554,9 +5590,8 @@
55545590 }
55555591
55565592 for (f = 0; f < nr_frags; f++) {
5557
- const struct skb_frag_struct *frag;
5593
+ const skb_frag_t *frag = &skb_shinfo(skb)->frags[f];
55585594
5559
- frag = &skb_shinfo(skb)->frags[f];
55605595 len = skb_frag_size(frag);
55615596 offset = 0;
55625597
....@@ -5877,23 +5912,17 @@
58775912 e1000_tx_queue(tx_ring, tx_flags, count);
58785913 /* Make sure there is space in the ring for the next send. */
58795914 e1000_maybe_stop_tx(tx_ring,
5880
- (MAX_SKB_FRAGS *
5915
+ ((MAX_SKB_FRAGS + 1) *
58815916 DIV_ROUND_UP(PAGE_SIZE,
5882
- adapter->tx_fifo_limit) + 2));
5917
+ adapter->tx_fifo_limit) + 4));
58835918
5884
- if (!skb->xmit_more ||
5919
+ if (!netdev_xmit_more() ||
58855920 netif_xmit_stopped(netdev_get_tx_queue(netdev, 0))) {
58865921 if (adapter->flags2 & FLAG2_PCIM2PCI_ARBITER_WA)
58875922 e1000e_update_tdt_wa(tx_ring,
58885923 tx_ring->next_to_use);
58895924 else
58905925 writel(tx_ring->next_to_use, tx_ring->tail);
5891
-
5892
- /* we need this if more than one processor can write
5893
- * to our tail at a time, it synchronizes IO on
5894
- *IA64/Altix systems
5895
- */
5896
- mmiowb();
58975926 }
58985927 } else {
58995928 dev_kfree_skb_any(skb);
....@@ -5907,8 +5936,9 @@
59075936 /**
59085937 * e1000_tx_timeout - Respond to a Tx Hang
59095938 * @netdev: network interface device structure
5939
+ * @txqueue: index of the hung queue (unused)
59105940 **/
5911
-static void e1000_tx_timeout(struct net_device *netdev)
5941
+static void e1000_tx_timeout(struct net_device *netdev, unsigned int __always_unused txqueue)
59125942 {
59135943 struct e1000_adapter *adapter = netdev_priv(netdev);
59145944
....@@ -6011,10 +6041,11 @@
60116041 }
60126042
60136043 while (test_and_set_bit(__E1000_RESETTING, &adapter->state))
6014
- usleep_range(1000, 2000);
6044
+ usleep_range(1000, 1100);
60156045 /* e1000e_down -> e1000e_reset dependent on max_frame_size & mtu */
60166046 adapter->max_frame_size = max_frame;
6017
- e_info("changing MTU from %d to %d\n", netdev->mtu, new_mtu);
6047
+ netdev_dbg(netdev, "changing MTU from %d to %d\n",
6048
+ netdev->mtu, new_mtu);
60186049 netdev->mtu = new_mtu;
60196050
60206051 pm_runtime_get_sync(netdev->dev.parent);
....@@ -6112,7 +6143,7 @@
61126143 /**
61136144 * e1000e_hwtstamp_ioctl - control hardware time stamping
61146145 * @netdev: network interface device structure
6115
- * @ifreq: interface request
6146
+ * @ifr: interface request
61166147 *
61176148 * Outgoing time stamping can be enabled and disabled. Play nice and
61186149 * disable it when requested, although it shouldn't cause any overhead
....@@ -6280,18 +6311,244 @@
62806311 pm_runtime_put_sync(netdev->dev.parent);
62816312 }
62826313
6314
+/* S0ix implementation */
6315
+static void e1000e_s0ix_entry_flow(struct e1000_adapter *adapter)
6316
+{
6317
+ struct e1000_hw *hw = &adapter->hw;
6318
+ u32 mac_data;
6319
+ u16 phy_data;
6320
+
6321
+ /* Disable the periodic inband message,
6322
+ * don't request PCIe clock in K1 page770_17[10:9] = 10b
6323
+ */
6324
+ e1e_rphy(hw, HV_PM_CTRL, &phy_data);
6325
+ phy_data &= ~HV_PM_CTRL_K1_CLK_REQ;
6326
+ phy_data |= BIT(10);
6327
+ e1e_wphy(hw, HV_PM_CTRL, phy_data);
6328
+
6329
+ /* Make sure we don't exit K1 every time a new packet arrives
6330
+ * 772_29[5] = 1 CS_Mode_Stay_In_K1
6331
+ */
6332
+ e1e_rphy(hw, I217_CGFREG, &phy_data);
6333
+ phy_data |= BIT(5);
6334
+ e1e_wphy(hw, I217_CGFREG, phy_data);
6335
+
6336
+ /* Change the MAC/PHY interface to SMBus
6337
+ * Force the SMBus in PHY page769_23[0] = 1
6338
+ * Force the SMBus in MAC CTRL_EXT[11] = 1
6339
+ */
6340
+ e1e_rphy(hw, CV_SMB_CTRL, &phy_data);
6341
+ phy_data |= CV_SMB_CTRL_FORCE_SMBUS;
6342
+ e1e_wphy(hw, CV_SMB_CTRL, phy_data);
6343
+ mac_data = er32(CTRL_EXT);
6344
+ mac_data |= E1000_CTRL_EXT_FORCE_SMBUS;
6345
+ ew32(CTRL_EXT, mac_data);
6346
+
6347
+ /* DFT control: PHY bit: page769_20[0] = 1
6348
+ * Gate PPW via EXTCNF_CTRL - set 0x0F00[7] = 1
6349
+ */
6350
+ e1e_rphy(hw, I82579_DFT_CTRL, &phy_data);
6351
+ phy_data |= BIT(0);
6352
+ e1e_wphy(hw, I82579_DFT_CTRL, phy_data);
6353
+
6354
+ mac_data = er32(EXTCNF_CTRL);
6355
+ mac_data |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
6356
+ ew32(EXTCNF_CTRL, mac_data);
6357
+
6358
+ /* Check MAC Tx/Rx packet buffer pointers.
6359
+ * Reset MAC Tx/Rx packet buffer pointers to suppress any
6360
+ * pending traffic indication that would prevent power gating.
6361
+ */
6362
+ mac_data = er32(TDFH);
6363
+ if (mac_data)
6364
+ ew32(TDFH, 0);
6365
+ mac_data = er32(TDFT);
6366
+ if (mac_data)
6367
+ ew32(TDFT, 0);
6368
+ mac_data = er32(TDFHS);
6369
+ if (mac_data)
6370
+ ew32(TDFHS, 0);
6371
+ mac_data = er32(TDFTS);
6372
+ if (mac_data)
6373
+ ew32(TDFTS, 0);
6374
+ mac_data = er32(TDFPC);
6375
+ if (mac_data)
6376
+ ew32(TDFPC, 0);
6377
+ mac_data = er32(RDFH);
6378
+ if (mac_data)
6379
+ ew32(RDFH, 0);
6380
+ mac_data = er32(RDFT);
6381
+ if (mac_data)
6382
+ ew32(RDFT, 0);
6383
+ mac_data = er32(RDFHS);
6384
+ if (mac_data)
6385
+ ew32(RDFHS, 0);
6386
+ mac_data = er32(RDFTS);
6387
+ if (mac_data)
6388
+ ew32(RDFTS, 0);
6389
+ mac_data = er32(RDFPC);
6390
+ if (mac_data)
6391
+ ew32(RDFPC, 0);
6392
+
6393
+ /* Enable the Dynamic Power Gating in the MAC */
6394
+ mac_data = er32(FEXTNVM7);
6395
+ mac_data |= BIT(22);
6396
+ ew32(FEXTNVM7, mac_data);
6397
+
6398
+ /* Disable the time synchronization clock */
6399
+ mac_data = er32(FEXTNVM7);
6400
+ mac_data |= BIT(31);
6401
+ mac_data &= ~BIT(0);
6402
+ ew32(FEXTNVM7, mac_data);
6403
+
6404
+ /* Dynamic Power Gating Enable */
6405
+ mac_data = er32(CTRL_EXT);
6406
+ mac_data |= BIT(3);
6407
+ ew32(CTRL_EXT, mac_data);
6408
+
6409
+ /* Disable disconnected cable conditioning for Power Gating */
6410
+ mac_data = er32(DPGFR);
6411
+ mac_data |= BIT(2);
6412
+ ew32(DPGFR, mac_data);
6413
+
6414
+ /* Don't wake from dynamic Power Gating with clock request */
6415
+ mac_data = er32(FEXTNVM12);
6416
+ mac_data |= BIT(12);
6417
+ ew32(FEXTNVM12, mac_data);
6418
+
6419
+ /* Ungate PGCB clock */
6420
+ mac_data = er32(FEXTNVM9);
6421
+ mac_data &= ~BIT(28);
6422
+ ew32(FEXTNVM9, mac_data);
6423
+
6424
+ /* Enable K1 off to enable mPHY Power Gating */
6425
+ mac_data = er32(FEXTNVM6);
6426
+ mac_data |= BIT(31);
6427
+ ew32(FEXTNVM6, mac_data);
6428
+
6429
+ /* Enable mPHY power gating for any link and speed */
6430
+ mac_data = er32(FEXTNVM8);
6431
+ mac_data |= BIT(9);
6432
+ ew32(FEXTNVM8, mac_data);
6433
+
6434
+ /* Enable the Dynamic Clock Gating in the DMA and MAC */
6435
+ mac_data = er32(CTRL_EXT);
6436
+ mac_data |= E1000_CTRL_EXT_DMA_DYN_CLK_EN;
6437
+ ew32(CTRL_EXT, mac_data);
6438
+
6439
+ /* No MAC DPG gating SLP_S0 in modern standby
6440
+ * Switch the logic of the lanphypc to use PMC counter
6441
+ */
6442
+ mac_data = er32(FEXTNVM5);
6443
+ mac_data |= BIT(7);
6444
+ ew32(FEXTNVM5, mac_data);
6445
+}
6446
+
6447
+static void e1000e_s0ix_exit_flow(struct e1000_adapter *adapter)
6448
+{
6449
+ struct e1000_hw *hw = &adapter->hw;
6450
+ u32 mac_data;
6451
+ u16 phy_data;
6452
+
6453
+ /* Disable the Dynamic Power Gating in the MAC */
6454
+ mac_data = er32(FEXTNVM7);
6455
+ mac_data &= 0xFFBFFFFF;
6456
+ ew32(FEXTNVM7, mac_data);
6457
+
6458
+ /* Enable the time synchronization clock */
6459
+ mac_data = er32(FEXTNVM7);
6460
+ mac_data |= BIT(0);
6461
+ ew32(FEXTNVM7, mac_data);
6462
+
6463
+ /* Disable mPHY power gating for any link and speed */
6464
+ mac_data = er32(FEXTNVM8);
6465
+ mac_data &= ~BIT(9);
6466
+ ew32(FEXTNVM8, mac_data);
6467
+
6468
+ /* Disable K1 off */
6469
+ mac_data = er32(FEXTNVM6);
6470
+ mac_data &= ~BIT(31);
6471
+ ew32(FEXTNVM6, mac_data);
6472
+
6473
+ /* Disable Ungate PGCB clock */
6474
+ mac_data = er32(FEXTNVM9);
6475
+ mac_data |= BIT(28);
6476
+ ew32(FEXTNVM9, mac_data);
6477
+
6478
+ /* Cancel not waking from dynamic
6479
+ * Power Gating with clock request
6480
+ */
6481
+ mac_data = er32(FEXTNVM12);
6482
+ mac_data &= ~BIT(12);
6483
+ ew32(FEXTNVM12, mac_data);
6484
+
6485
+ /* Cancel disable disconnected cable conditioning
6486
+ * for Power Gating
6487
+ */
6488
+ mac_data = er32(DPGFR);
6489
+ mac_data &= ~BIT(2);
6490
+ ew32(DPGFR, mac_data);
6491
+
6492
+ /* Disable Dynamic Power Gating */
6493
+ mac_data = er32(CTRL_EXT);
6494
+ mac_data &= 0xFFFFFFF7;
6495
+ ew32(CTRL_EXT, mac_data);
6496
+
6497
+ /* Disable the Dynamic Clock Gating in the DMA and MAC */
6498
+ mac_data = er32(CTRL_EXT);
6499
+ mac_data &= 0xFFF7FFFF;
6500
+ ew32(CTRL_EXT, mac_data);
6501
+
6502
+ /* Revert the lanphypc logic to use the internal Gbe counter
6503
+ * and not the PMC counter
6504
+ */
6505
+ mac_data = er32(FEXTNVM5);
6506
+ mac_data &= 0xFFFFFF7F;
6507
+ ew32(FEXTNVM5, mac_data);
6508
+
6509
+ /* Enable the periodic inband message,
6510
+ * Request PCIe clock in K1 page770_17[10:9] =01b
6511
+ */
6512
+ e1e_rphy(hw, HV_PM_CTRL, &phy_data);
6513
+ phy_data &= 0xFBFF;
6514
+ phy_data |= HV_PM_CTRL_K1_CLK_REQ;
6515
+ e1e_wphy(hw, HV_PM_CTRL, phy_data);
6516
+
6517
+ /* Return back configuration
6518
+ * 772_29[5] = 0 CS_Mode_Stay_In_K1
6519
+ */
6520
+ e1e_rphy(hw, I217_CGFREG, &phy_data);
6521
+ phy_data &= 0xFFDF;
6522
+ e1e_wphy(hw, I217_CGFREG, phy_data);
6523
+
6524
+ /* Change the MAC/PHY interface to Kumeran
6525
+ * Unforce the SMBus in PHY page769_23[0] = 0
6526
+ * Unforce the SMBus in MAC CTRL_EXT[11] = 0
6527
+ */
6528
+ e1e_rphy(hw, CV_SMB_CTRL, &phy_data);
6529
+ phy_data &= ~CV_SMB_CTRL_FORCE_SMBUS;
6530
+ e1e_wphy(hw, CV_SMB_CTRL, phy_data);
6531
+ mac_data = er32(CTRL_EXT);
6532
+ mac_data &= ~E1000_CTRL_EXT_FORCE_SMBUS;
6533
+ ew32(CTRL_EXT, mac_data);
6534
+}
6535
+
62836536 static int e1000e_pm_freeze(struct device *dev)
62846537 {
6285
- struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev));
6538
+ struct net_device *netdev = dev_get_drvdata(dev);
62866539 struct e1000_adapter *adapter = netdev_priv(netdev);
6540
+ bool present;
62876541
6542
+ rtnl_lock();
6543
+
6544
+ present = netif_device_present(netdev);
62886545 netif_device_detach(netdev);
62896546
6290
- if (netif_running(netdev)) {
6547
+ if (present && netif_running(netdev)) {
62916548 int count = E1000_CHECK_RESET_COUNT;
62926549
62936550 while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
6294
- usleep_range(10000, 20000);
6551
+ usleep_range(10000, 11000);
62956552
62966553 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
62976554
....@@ -6299,6 +6556,8 @@
62996556 e1000e_down(adapter, false);
63006557 e1000_free_irq(adapter);
63016558 }
6559
+ rtnl_unlock();
6560
+
63026561 e1000e_reset_interrupt_capability(adapter);
63036562
63046563 /* Allow time for pending master requests to run */
....@@ -6471,7 +6730,7 @@
64716730 case PCIE_LINK_STATE_L0S:
64726731 case PCIE_LINK_STATE_L0S | PCIE_LINK_STATE_L1:
64736732 aspm_dis_mask |= PCI_EXP_LNKCTL_ASPM_L0S;
6474
- /* fall-through - can't have L1 without L0s */
6733
+ fallthrough; /* can't have L1 without L0s */
64756734 case PCIE_LINK_STATE_L1:
64766735 aspm_dis_mask |= PCI_EXP_LNKCTL_ASPM_L1;
64776736 break;
....@@ -6552,7 +6811,30 @@
65526811 __e1000e_disable_aspm(pdev, state, 1);
65536812 }
65546813
6555
-#ifdef CONFIG_PM
6814
+static int e1000e_pm_thaw(struct device *dev)
6815
+{
6816
+ struct net_device *netdev = dev_get_drvdata(dev);
6817
+ struct e1000_adapter *adapter = netdev_priv(netdev);
6818
+ int rc = 0;
6819
+
6820
+ e1000e_set_interrupt_capability(adapter);
6821
+
6822
+ rtnl_lock();
6823
+ if (netif_running(netdev)) {
6824
+ rc = e1000_request_irq(adapter);
6825
+ if (rc)
6826
+ goto err_irq;
6827
+
6828
+ e1000e_up(adapter);
6829
+ }
6830
+
6831
+ netif_device_attach(netdev);
6832
+err_irq:
6833
+ rtnl_unlock();
6834
+
6835
+ return rc;
6836
+}
6837
+
65566838 static int __e1000_resume(struct pci_dev *pdev)
65576839 {
65586840 struct net_device *netdev = pci_get_drvdata(pdev);
....@@ -6618,29 +6900,10 @@
66186900 return 0;
66196901 }
66206902
6621
-#ifdef CONFIG_PM_SLEEP
6622
-static int e1000e_pm_thaw(struct device *dev)
6903
+static __maybe_unused int e1000e_pm_suspend(struct device *dev)
66236904 {
66246905 struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev));
66256906 struct e1000_adapter *adapter = netdev_priv(netdev);
6626
-
6627
- e1000e_set_interrupt_capability(adapter);
6628
- if (netif_running(netdev)) {
6629
- u32 err = e1000_request_irq(adapter);
6630
-
6631
- if (err)
6632
- return err;
6633
-
6634
- e1000e_up(adapter);
6635
- }
6636
-
6637
- netif_device_attach(netdev);
6638
-
6639
- return 0;
6640
-}
6641
-
6642
-static int e1000e_pm_suspend(struct device *dev)
6643
-{
66446907 struct pci_dev *pdev = to_pci_dev(dev);
66456908 int rc;
66466909
....@@ -6649,16 +6912,27 @@
66496912 e1000e_pm_freeze(dev);
66506913
66516914 rc = __e1000_shutdown(pdev, false);
6652
- if (rc)
6915
+ if (rc) {
66536916 e1000e_pm_thaw(dev);
6917
+ } else {
6918
+ /* Introduce S0ix implementation */
6919
+ if (adapter->flags2 & FLAG2_ENABLE_S0IX_FLOWS)
6920
+ e1000e_s0ix_entry_flow(adapter);
6921
+ }
66546922
66556923 return rc;
66566924 }
66576925
6658
-static int e1000e_pm_resume(struct device *dev)
6926
+static __maybe_unused int e1000e_pm_resume(struct device *dev)
66596927 {
6928
+ struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev));
6929
+ struct e1000_adapter *adapter = netdev_priv(netdev);
66606930 struct pci_dev *pdev = to_pci_dev(dev);
66616931 int rc;
6932
+
6933
+ /* Introduce S0ix implementation */
6934
+ if (adapter->flags2 & FLAG2_ENABLE_S0IX_FLOWS)
6935
+ e1000e_s0ix_exit_flow(adapter);
66626936
66636937 rc = __e1000_resume(pdev);
66646938 if (rc)
....@@ -6666,12 +6940,10 @@
66666940
66676941 return e1000e_pm_thaw(dev);
66686942 }
6669
-#endif /* CONFIG_PM_SLEEP */
66706943
6671
-static int e1000e_pm_runtime_idle(struct device *dev)
6944
+static __maybe_unused int e1000e_pm_runtime_idle(struct device *dev)
66726945 {
6673
- struct pci_dev *pdev = to_pci_dev(dev);
6674
- struct net_device *netdev = pci_get_drvdata(pdev);
6946
+ struct net_device *netdev = dev_get_drvdata(dev);
66756947 struct e1000_adapter *adapter = netdev_priv(netdev);
66766948 u16 eee_lp;
66776949
....@@ -6685,7 +6957,7 @@
66856957 return -EBUSY;
66866958 }
66876959
6688
-static int e1000e_pm_runtime_resume(struct device *dev)
6960
+static __maybe_unused int e1000e_pm_runtime_resume(struct device *dev)
66896961 {
66906962 struct pci_dev *pdev = to_pci_dev(dev);
66916963 struct net_device *netdev = pci_get_drvdata(pdev);
....@@ -6702,7 +6974,7 @@
67026974 return rc;
67036975 }
67046976
6705
-static int e1000e_pm_runtime_suspend(struct device *dev)
6977
+static __maybe_unused int e1000e_pm_runtime_suspend(struct device *dev)
67066978 {
67076979 struct pci_dev *pdev = to_pci_dev(dev);
67086980 struct net_device *netdev = pci_get_drvdata(pdev);
....@@ -6712,7 +6984,7 @@
67126984 int count = E1000_CHECK_RESET_COUNT;
67136985
67146986 while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
6715
- usleep_range(10000, 20000);
6987
+ usleep_range(10000, 11000);
67166988
67176989 WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
67186990
....@@ -6727,7 +6999,6 @@
67276999
67287000 return 0;
67297001 }
6730
-#endif /* CONFIG_PM */
67317002
67327003 static void e1000_shutdown(struct pci_dev *pdev)
67337004 {
....@@ -6811,16 +7082,11 @@
68117082 static pci_ers_result_t e1000_io_error_detected(struct pci_dev *pdev,
68127083 pci_channel_state_t state)
68137084 {
6814
- struct net_device *netdev = pci_get_drvdata(pdev);
6815
- struct e1000_adapter *adapter = netdev_priv(netdev);
6816
-
6817
- netif_device_detach(netdev);
7085
+ e1000e_pm_freeze(&pdev->dev);
68187086
68197087 if (state == pci_channel_io_perm_failure)
68207088 return PCI_ERS_RESULT_DISCONNECT;
68217089
6822
- if (netif_running(netdev))
6823
- e1000e_down(adapter, true);
68247090 pci_disable_device(pdev);
68257091
68267092 /* Request a slot slot reset. */
....@@ -6868,8 +7134,6 @@
68687134 result = PCI_ERS_RESULT_RECOVERED;
68697135 }
68707136
6871
- pci_cleanup_aer_uncorrect_error_status(pdev);
6872
-
68737137 return result;
68747138 }
68757139
....@@ -6888,10 +7152,7 @@
68887152
68897153 e1000_init_manageability_pt(adapter);
68907154
6891
- if (netif_running(netdev))
6892
- e1000e_up(adapter);
6893
-
6894
- netif_device_attach(netdev);
7155
+ e1000e_pm_thaw(&pdev->dev);
68957156
68967157 /* If the controller has AMT, do not set DRV_LOAD until the interface
68977158 * is up. For all other cases, let the f/w know that the h/w is now
....@@ -6999,7 +7260,7 @@
69997260 else
70007261 e1000e_reset(adapter);
70017262
7002
- return 0;
7263
+ return 1;
70037264 }
70047265
70057266 static const struct net_device_ops e1000e_netdev_ops = {
....@@ -7191,6 +7452,32 @@
71917452 NETIF_F_RXCSUM |
71927453 NETIF_F_HW_CSUM);
71937454
7455
+ /* disable TSO for pcie and 10/100 speeds to avoid
7456
+ * some hardware issues and for i219 to fix transfer
7457
+ * speed being capped at 60%
7458
+ */
7459
+ if (!(adapter->flags & FLAG_TSO_FORCE)) {
7460
+ switch (adapter->link_speed) {
7461
+ case SPEED_10:
7462
+ case SPEED_100:
7463
+ e_info("10/100 speed: disabling TSO\n");
7464
+ netdev->features &= ~NETIF_F_TSO;
7465
+ netdev->features &= ~NETIF_F_TSO6;
7466
+ break;
7467
+ case SPEED_1000:
7468
+ netdev->features |= NETIF_F_TSO;
7469
+ netdev->features |= NETIF_F_TSO6;
7470
+ break;
7471
+ default:
7472
+ /* oops */
7473
+ break;
7474
+ }
7475
+ if (hw->mac.type == e1000_pch_spt) {
7476
+ netdev->features &= ~NETIF_F_TSO;
7477
+ netdev->features &= ~NETIF_F_TSO6;
7478
+ }
7479
+ }
7480
+
71947481 /* Set user-changeable features (subset of all device features) */
71957482 netdev->hw_features = netdev->features;
71967483 netdev->hw_features |= NETIF_F_RXFCS;
....@@ -7334,6 +7621,9 @@
73347621 if (!(adapter->flags & FLAG_HAS_AMT))
73357622 e1000e_get_hw_control(adapter);
73367623
7624
+ if (hw->mac.type >= e1000_pch_cnp)
7625
+ adapter->flags2 |= FLAG2_ENABLE_S0IX_FLOWS;
7626
+
73377627 strlcpy(netdev->name, "eth%d", sizeof(netdev->name));
73387628 err = register_netdev(netdev);
73397629 if (err)
....@@ -7344,7 +7634,7 @@
73447634
73457635 e1000_print_device_info(adapter);
73467636
7347
- dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NEVER_SKIP);
7637
+ dev_pm_set_driver_flags(&pdev->dev, DPM_FLAG_NO_DIRECT_COMPLETE);
73487638
73497639 if (pci_dev_run_wake(pdev) && hw->mac.type < e1000_pch_cnp)
73507640 pm_runtime_put_noidle(&pdev->dev);
....@@ -7390,15 +7680,13 @@
73907680 {
73917681 struct net_device *netdev = pci_get_drvdata(pdev);
73927682 struct e1000_adapter *adapter = netdev_priv(netdev);
7393
- bool down = test_bit(__E1000_DOWN, &adapter->state);
73947683
73957684 e1000e_ptp_remove(adapter);
73967685
73977686 /* The timers may be rescheduled, so explicitly disable them
73987687 * from being rescheduled.
73997688 */
7400
- if (!down)
7401
- set_bit(__E1000_DOWN, &adapter->state);
7689
+ set_bit(__E1000_DOWN, &adapter->state);
74027690 del_timer_sync(&adapter->watchdog_timer);
74037691 del_timer_sync(&adapter->phy_info_timer);
74047692
....@@ -7416,9 +7704,6 @@
74167704 }
74177705 }
74187706
7419
- /* Don't lie to e1000_close() down the road. */
7420
- if (!down)
7421
- clear_bit(__E1000_DOWN, &adapter->state);
74227707 unregister_netdev(netdev);
74237708
74247709 if (pci_dev_run_wake(pdev))
....@@ -7548,6 +7833,26 @@
75487833 { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ICP_I219_V8), board_pch_cnp },
75497834 { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ICP_I219_LM9), board_pch_cnp },
75507835 { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ICP_I219_V9), board_pch_cnp },
7836
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_CMP_I219_LM10), board_pch_cnp },
7837
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_CMP_I219_V10), board_pch_cnp },
7838
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_CMP_I219_LM11), board_pch_cnp },
7839
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_CMP_I219_V11), board_pch_cnp },
7840
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_CMP_I219_LM12), board_pch_spt },
7841
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_CMP_I219_V12), board_pch_spt },
7842
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_LM13), board_pch_tgp },
7843
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_V13), board_pch_tgp },
7844
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_LM14), board_pch_tgp },
7845
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_V14), board_pch_tgp },
7846
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_LM15), board_pch_tgp },
7847
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_TGP_I219_V15), board_pch_tgp },
7848
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM16), board_pch_tgp },
7849
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V16), board_pch_tgp },
7850
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_LM17), board_pch_tgp },
7851
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_ADP_I219_V17), board_pch_tgp },
7852
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM18), board_pch_tgp },
7853
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V18), board_pch_tgp },
7854
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_LM19), board_pch_tgp },
7855
+ { PCI_VDEVICE(INTEL, E1000_DEV_ID_PCH_MTP_I219_V19), board_pch_tgp },
75517856
75527857 { 0, 0, 0, 0, 0, 0, 0 } /* terminate list */
75537858 };
....@@ -7587,8 +7892,7 @@
75877892 **/
75887893 static int __init e1000_init_module(void)
75897894 {
7590
- pr_info("Intel(R) PRO/1000 Network Driver - %s\n",
7591
- e1000e_driver_version);
7895
+ pr_info("Intel(R) PRO/1000 Network Driver\n");
75927896 pr_info("Copyright(c) 1999 - 2015 Intel Corporation.\n");
75937897
75947898 return pci_register_driver(&e1000_driver);
....@@ -7609,7 +7913,6 @@
76097913
76107914 MODULE_AUTHOR("Intel Corporation, <linux.nics@intel.com>");
76117915 MODULE_DESCRIPTION("Intel(R) PRO/1000 Network Driver");
7612
-MODULE_LICENSE("GPL");
7613
-MODULE_VERSION(DRV_VERSION);
7916
+MODULE_LICENSE("GPL v2");
76147917
76157918 /* netdev.c */