diff options
author | Sasha Neftin <sasha.neftin@intel.com> | 2018-10-11 03:17:19 -0400 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2018-10-17 16:20:43 -0400 |
commit | 13b5b7fd6a4a96dffe604f25e7b64cfbd9520924 (patch) | |
tree | 43a5df47a21d4ff121a50369c033c2ca10f6f583 /drivers/net/ethernet/intel/igc/igc_base.c | |
parent | 3df25e4c1e66a69097bde99990fb095b26125c82 (diff) |
igc: Add support for Tx/Rx rings
This change adds the defines and structures necessary to support both Tx
and Rx descriptor rings.
Signed-off-by: Sasha Neftin <sasha.neftin@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet/intel/igc/igc_base.c')
-rw-r--r-- | drivers/net/ethernet/intel/igc/igc_base.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/drivers/net/ethernet/intel/igc/igc_base.c b/drivers/net/ethernet/intel/igc/igc_base.c new file mode 100644 index 000000000000..3425b7466017 --- /dev/null +++ b/drivers/net/ethernet/intel/igc/igc_base.c | |||
@@ -0,0 +1,83 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
2 | /* Copyright (c) 2018 Intel Corporation */ | ||
3 | |||
4 | #include <linux/delay.h> | ||
5 | |||
6 | #include "igc_hw.h" | ||
7 | #include "igc_i225.h" | ||
8 | |||
9 | /** | ||
10 | * igc_rx_fifo_flush_base - Clean rx fifo after Rx enable | ||
11 | * @hw: pointer to the HW structure | ||
12 | * | ||
13 | * After Rx enable, if manageability is enabled then there is likely some | ||
14 | * bad data at the start of the fifo and possibly in the DMA fifo. This | ||
15 | * function clears the fifos and flushes any packets that came in as rx was | ||
16 | * being enabled. | ||
17 | */ | ||
18 | void igc_rx_fifo_flush_base(struct igc_hw *hw) | ||
19 | { | ||
20 | u32 rctl, rlpml, rxdctl[4], rfctl, temp_rctl, rx_enabled; | ||
21 | int i, ms_wait; | ||
22 | |||
23 | /* disable IPv6 options as per hardware errata */ | ||
24 | rfctl = rd32(IGC_RFCTL); | ||
25 | rfctl |= IGC_RFCTL_IPV6_EX_DIS; | ||
26 | wr32(IGC_RFCTL, rfctl); | ||
27 | |||
28 | if (!(rd32(IGC_MANC) & IGC_MANC_RCV_TCO_EN)) | ||
29 | return; | ||
30 | |||
31 | /* Disable all Rx queues */ | ||
32 | for (i = 0; i < 4; i++) { | ||
33 | rxdctl[i] = rd32(IGC_RXDCTL(i)); | ||
34 | wr32(IGC_RXDCTL(i), | ||
35 | rxdctl[i] & ~IGC_RXDCTL_QUEUE_ENABLE); | ||
36 | } | ||
37 | /* Poll all queues to verify they have shut down */ | ||
38 | for (ms_wait = 0; ms_wait < 10; ms_wait++) { | ||
39 | usleep_range(1000, 2000); | ||
40 | rx_enabled = 0; | ||
41 | for (i = 0; i < 4; i++) | ||
42 | rx_enabled |= rd32(IGC_RXDCTL(i)); | ||
43 | if (!(rx_enabled & IGC_RXDCTL_QUEUE_ENABLE)) | ||
44 | break; | ||
45 | } | ||
46 | |||
47 | if (ms_wait == 10) | ||
48 | pr_debug("Queue disable timed out after 10ms\n"); | ||
49 | |||
50 | /* Clear RLPML, RCTL.SBP, RFCTL.LEF, and set RCTL.LPE so that all | ||
51 | * incoming packets are rejected. Set enable and wait 2ms so that | ||
52 | * any packet that was coming in as RCTL.EN was set is flushed | ||
53 | */ | ||
54 | wr32(IGC_RFCTL, rfctl & ~IGC_RFCTL_LEF); | ||
55 | |||
56 | rlpml = rd32(IGC_RLPML); | ||
57 | wr32(IGC_RLPML, 0); | ||
58 | |||
59 | rctl = rd32(IGC_RCTL); | ||
60 | temp_rctl = rctl & ~(IGC_RCTL_EN | IGC_RCTL_SBP); | ||
61 | temp_rctl |= IGC_RCTL_LPE; | ||
62 | |||
63 | wr32(IGC_RCTL, temp_rctl); | ||
64 | wr32(IGC_RCTL, temp_rctl | IGC_RCTL_EN); | ||
65 | wrfl(); | ||
66 | usleep_range(2000, 3000); | ||
67 | |||
68 | /* Enable Rx queues that were previously enabled and restore our | ||
69 | * previous state | ||
70 | */ | ||
71 | for (i = 0; i < 4; i++) | ||
72 | wr32(IGC_RXDCTL(i), rxdctl[i]); | ||
73 | wr32(IGC_RCTL, rctl); | ||
74 | wrfl(); | ||
75 | |||
76 | wr32(IGC_RLPML, rlpml); | ||
77 | wr32(IGC_RFCTL, rfctl); | ||
78 | |||
79 | /* Flush receive errors generated by workaround */ | ||
80 | rd32(IGC_ROC); | ||
81 | rd32(IGC_RNBC); | ||
82 | rd32(IGC_MPC); | ||
83 | } | ||