diff options
Diffstat (limited to 'drivers/net/sfc/falcon_gmac.c')
-rw-r--r-- | drivers/net/sfc/falcon_gmac.c | 123 |
1 files changed, 62 insertions, 61 deletions
diff --git a/drivers/net/sfc/falcon_gmac.c b/drivers/net/sfc/falcon_gmac.c index 8865eae20ac5..7dadfcbd6ce7 100644 --- a/drivers/net/sfc/falcon_gmac.c +++ b/drivers/net/sfc/falcon_gmac.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | * Driver for Solarflare Solarstorm network controllers and boards | 2 | * Driver for Solarflare Solarstorm network controllers and boards |
3 | * Copyright 2005-2006 Fen Systems Ltd. | 3 | * Copyright 2005-2006 Fen Systems Ltd. |
4 | * Copyright 2006-2008 Solarflare Communications Inc. | 4 | * Copyright 2006-2009 Solarflare Communications Inc. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms of the GNU General Public License version 2 as published | 7 | * under the terms of the GNU General Public License version 2 as published |
@@ -11,11 +11,10 @@ | |||
11 | #include <linux/delay.h> | 11 | #include <linux/delay.h> |
12 | #include "net_driver.h" | 12 | #include "net_driver.h" |
13 | #include "efx.h" | 13 | #include "efx.h" |
14 | #include "falcon.h" | 14 | #include "nic.h" |
15 | #include "mac.h" | 15 | #include "mac.h" |
16 | #include "falcon_hwdefs.h" | 16 | #include "regs.h" |
17 | #include "falcon_io.h" | 17 | #include "io.h" |
18 | #include "gmii.h" | ||
19 | 18 | ||
20 | /************************************************************************** | 19 | /************************************************************************** |
21 | * | 20 | * |
@@ -23,106 +22,109 @@ | |||
23 | * | 22 | * |
24 | *************************************************************************/ | 23 | *************************************************************************/ |
25 | 24 | ||
26 | static void falcon_reconfigure_gmac(struct efx_nic *efx) | 25 | static int falcon_reconfigure_gmac(struct efx_nic *efx) |
27 | { | 26 | { |
27 | struct efx_link_state *link_state = &efx->link_state; | ||
28 | bool loopback, tx_fc, rx_fc, bytemode; | 28 | bool loopback, tx_fc, rx_fc, bytemode; |
29 | int if_mode; | 29 | int if_mode; |
30 | unsigned int max_frame_len; | 30 | unsigned int max_frame_len; |
31 | efx_oword_t reg; | 31 | efx_oword_t reg; |
32 | 32 | ||
33 | /* Configuration register 1 */ | 33 | /* Configuration register 1 */ |
34 | tx_fc = (efx->link_fc & EFX_FC_TX) || !efx->link_fd; | 34 | tx_fc = (link_state->fc & EFX_FC_TX) || !link_state->fd; |
35 | rx_fc = !!(efx->link_fc & EFX_FC_RX); | 35 | rx_fc = !!(link_state->fc & EFX_FC_RX); |
36 | loopback = (efx->loopback_mode == LOOPBACK_GMAC); | 36 | loopback = (efx->loopback_mode == LOOPBACK_GMAC); |
37 | bytemode = (efx->link_speed == 1000); | 37 | bytemode = (link_state->speed == 1000); |
38 | 38 | ||
39 | EFX_POPULATE_OWORD_5(reg, | 39 | EFX_POPULATE_OWORD_5(reg, |
40 | GM_LOOP, loopback, | 40 | FRF_AB_GM_LOOP, loopback, |
41 | GM_TX_EN, 1, | 41 | FRF_AB_GM_TX_EN, 1, |
42 | GM_TX_FC_EN, tx_fc, | 42 | FRF_AB_GM_TX_FC_EN, tx_fc, |
43 | GM_RX_EN, 1, | 43 | FRF_AB_GM_RX_EN, 1, |
44 | GM_RX_FC_EN, rx_fc); | 44 | FRF_AB_GM_RX_FC_EN, rx_fc); |
45 | falcon_write(efx, ®, GM_CFG1_REG); | 45 | efx_writeo(efx, ®, FR_AB_GM_CFG1); |
46 | udelay(10); | 46 | udelay(10); |
47 | 47 | ||
48 | /* Configuration register 2 */ | 48 | /* Configuration register 2 */ |
49 | if_mode = (bytemode) ? 2 : 1; | 49 | if_mode = (bytemode) ? 2 : 1; |
50 | EFX_POPULATE_OWORD_5(reg, | 50 | EFX_POPULATE_OWORD_5(reg, |
51 | GM_IF_MODE, if_mode, | 51 | FRF_AB_GM_IF_MODE, if_mode, |
52 | GM_PAD_CRC_EN, 1, | 52 | FRF_AB_GM_PAD_CRC_EN, 1, |
53 | GM_LEN_CHK, 1, | 53 | FRF_AB_GM_LEN_CHK, 1, |
54 | GM_FD, efx->link_fd, | 54 | FRF_AB_GM_FD, link_state->fd, |
55 | GM_PAMBL_LEN, 0x7/*datasheet recommended */); | 55 | FRF_AB_GM_PAMBL_LEN, 0x7/*datasheet recommended */); |
56 | 56 | ||
57 | falcon_write(efx, ®, GM_CFG2_REG); | 57 | efx_writeo(efx, ®, FR_AB_GM_CFG2); |
58 | udelay(10); | 58 | udelay(10); |
59 | 59 | ||
60 | /* Max frame len register */ | 60 | /* Max frame len register */ |
61 | max_frame_len = EFX_MAX_FRAME_LEN(efx->net_dev->mtu); | 61 | max_frame_len = EFX_MAX_FRAME_LEN(efx->net_dev->mtu); |
62 | EFX_POPULATE_OWORD_1(reg, GM_MAX_FLEN, max_frame_len); | 62 | EFX_POPULATE_OWORD_1(reg, FRF_AB_GM_MAX_FLEN, max_frame_len); |
63 | falcon_write(efx, ®, GM_MAX_FLEN_REG); | 63 | efx_writeo(efx, ®, FR_AB_GM_MAX_FLEN); |
64 | udelay(10); | 64 | udelay(10); |
65 | 65 | ||
66 | /* FIFO configuration register 0 */ | 66 | /* FIFO configuration register 0 */ |
67 | EFX_POPULATE_OWORD_5(reg, | 67 | EFX_POPULATE_OWORD_5(reg, |
68 | GMF_FTFENREQ, 1, | 68 | FRF_AB_GMF_FTFENREQ, 1, |
69 | GMF_STFENREQ, 1, | 69 | FRF_AB_GMF_STFENREQ, 1, |
70 | GMF_FRFENREQ, 1, | 70 | FRF_AB_GMF_FRFENREQ, 1, |
71 | GMF_SRFENREQ, 1, | 71 | FRF_AB_GMF_SRFENREQ, 1, |
72 | GMF_WTMENREQ, 1); | 72 | FRF_AB_GMF_WTMENREQ, 1); |
73 | falcon_write(efx, ®, GMF_CFG0_REG); | 73 | efx_writeo(efx, ®, FR_AB_GMF_CFG0); |
74 | udelay(10); | 74 | udelay(10); |
75 | 75 | ||
76 | /* FIFO configuration register 1 */ | 76 | /* FIFO configuration register 1 */ |
77 | EFX_POPULATE_OWORD_2(reg, | 77 | EFX_POPULATE_OWORD_2(reg, |
78 | GMF_CFGFRTH, 0x12, | 78 | FRF_AB_GMF_CFGFRTH, 0x12, |
79 | GMF_CFGXOFFRTX, 0xffff); | 79 | FRF_AB_GMF_CFGXOFFRTX, 0xffff); |
80 | falcon_write(efx, ®, GMF_CFG1_REG); | 80 | efx_writeo(efx, ®, FR_AB_GMF_CFG1); |
81 | udelay(10); | 81 | udelay(10); |
82 | 82 | ||
83 | /* FIFO configuration register 2 */ | 83 | /* FIFO configuration register 2 */ |
84 | EFX_POPULATE_OWORD_2(reg, | 84 | EFX_POPULATE_OWORD_2(reg, |
85 | GMF_CFGHWM, 0x3f, | 85 | FRF_AB_GMF_CFGHWM, 0x3f, |
86 | GMF_CFGLWM, 0xa); | 86 | FRF_AB_GMF_CFGLWM, 0xa); |
87 | falcon_write(efx, ®, GMF_CFG2_REG); | 87 | efx_writeo(efx, ®, FR_AB_GMF_CFG2); |
88 | udelay(10); | 88 | udelay(10); |
89 | 89 | ||
90 | /* FIFO configuration register 3 */ | 90 | /* FIFO configuration register 3 */ |
91 | EFX_POPULATE_OWORD_2(reg, | 91 | EFX_POPULATE_OWORD_2(reg, |
92 | GMF_CFGHWMFT, 0x1c, | 92 | FRF_AB_GMF_CFGHWMFT, 0x1c, |
93 | GMF_CFGFTTH, 0x08); | 93 | FRF_AB_GMF_CFGFTTH, 0x08); |
94 | falcon_write(efx, ®, GMF_CFG3_REG); | 94 | efx_writeo(efx, ®, FR_AB_GMF_CFG3); |
95 | udelay(10); | 95 | udelay(10); |
96 | 96 | ||
97 | /* FIFO configuration register 4 */ | 97 | /* FIFO configuration register 4 */ |
98 | EFX_POPULATE_OWORD_1(reg, GMF_HSTFLTRFRM_PAUSE, 1); | 98 | EFX_POPULATE_OWORD_1(reg, FRF_AB_GMF_HSTFLTRFRM_PAUSE, 1); |
99 | falcon_write(efx, ®, GMF_CFG4_REG); | 99 | efx_writeo(efx, ®, FR_AB_GMF_CFG4); |
100 | udelay(10); | 100 | udelay(10); |
101 | 101 | ||
102 | /* FIFO configuration register 5 */ | 102 | /* FIFO configuration register 5 */ |
103 | falcon_read(efx, ®, GMF_CFG5_REG); | 103 | efx_reado(efx, ®, FR_AB_GMF_CFG5); |
104 | EFX_SET_OWORD_FIELD(reg, GMF_CFGBYTMODE, bytemode); | 104 | EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_CFGBYTMODE, bytemode); |
105 | EFX_SET_OWORD_FIELD(reg, GMF_CFGHDPLX, !efx->link_fd); | 105 | EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_CFGHDPLX, !link_state->fd); |
106 | EFX_SET_OWORD_FIELD(reg, GMF_HSTDRPLT64, !efx->link_fd); | 106 | EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_HSTDRPLT64, !link_state->fd); |
107 | EFX_SET_OWORD_FIELD(reg, GMF_HSTFLTRFRMDC_PAUSE, 0); | 107 | EFX_SET_OWORD_FIELD(reg, FRF_AB_GMF_HSTFLTRFRMDC_PAUSE, 0); |
108 | falcon_write(efx, ®, GMF_CFG5_REG); | 108 | efx_writeo(efx, ®, FR_AB_GMF_CFG5); |
109 | udelay(10); | 109 | udelay(10); |
110 | 110 | ||
111 | /* MAC address */ | 111 | /* MAC address */ |
112 | EFX_POPULATE_OWORD_4(reg, | 112 | EFX_POPULATE_OWORD_4(reg, |
113 | GM_HWADDR_5, efx->net_dev->dev_addr[5], | 113 | FRF_AB_GM_ADR_B0, efx->net_dev->dev_addr[5], |
114 | GM_HWADDR_4, efx->net_dev->dev_addr[4], | 114 | FRF_AB_GM_ADR_B1, efx->net_dev->dev_addr[4], |
115 | GM_HWADDR_3, efx->net_dev->dev_addr[3], | 115 | FRF_AB_GM_ADR_B2, efx->net_dev->dev_addr[3], |
116 | GM_HWADDR_2, efx->net_dev->dev_addr[2]); | 116 | FRF_AB_GM_ADR_B3, efx->net_dev->dev_addr[2]); |
117 | falcon_write(efx, ®, GM_ADR1_REG); | 117 | efx_writeo(efx, ®, FR_AB_GM_ADR1); |
118 | udelay(10); | 118 | udelay(10); |
119 | EFX_POPULATE_OWORD_2(reg, | 119 | EFX_POPULATE_OWORD_2(reg, |
120 | GM_HWADDR_1, efx->net_dev->dev_addr[1], | 120 | FRF_AB_GM_ADR_B4, efx->net_dev->dev_addr[1], |
121 | GM_HWADDR_0, efx->net_dev->dev_addr[0]); | 121 | FRF_AB_GM_ADR_B5, efx->net_dev->dev_addr[0]); |
122 | falcon_write(efx, ®, GM_ADR2_REG); | 122 | efx_writeo(efx, ®, FR_AB_GM_ADR2); |
123 | udelay(10); | 123 | udelay(10); |
124 | 124 | ||
125 | falcon_reconfigure_mac_wrapper(efx); | 125 | falcon_reconfigure_mac_wrapper(efx); |
126 | |||
127 | return 0; | ||
126 | } | 128 | } |
127 | 129 | ||
128 | static void falcon_update_stats_gmac(struct efx_nic *efx) | 130 | static void falcon_update_stats_gmac(struct efx_nic *efx) |
@@ -130,11 +132,6 @@ static void falcon_update_stats_gmac(struct efx_nic *efx) | |||
130 | struct efx_mac_stats *mac_stats = &efx->mac_stats; | 132 | struct efx_mac_stats *mac_stats = &efx->mac_stats; |
131 | unsigned long old_rx_pause, old_tx_pause; | 133 | unsigned long old_rx_pause, old_tx_pause; |
132 | unsigned long new_rx_pause, new_tx_pause; | 134 | unsigned long new_rx_pause, new_tx_pause; |
133 | int rc; | ||
134 | |||
135 | rc = falcon_dma_stats(efx, GDmaDone_offset); | ||
136 | if (rc) | ||
137 | return; | ||
138 | 135 | ||
139 | /* Pause frames are erroneously counted as errors (SFC bug 3269) */ | 136 | /* Pause frames are erroneously counted as errors (SFC bug 3269) */ |
140 | old_rx_pause = mac_stats->rx_pause; | 137 | old_rx_pause = mac_stats->rx_pause; |
@@ -221,9 +218,13 @@ static void falcon_update_stats_gmac(struct efx_nic *efx) | |||
221 | mac_stats->rx_lt64 = mac_stats->rx_good_lt64 + mac_stats->rx_bad_lt64; | 218 | mac_stats->rx_lt64 = mac_stats->rx_good_lt64 + mac_stats->rx_bad_lt64; |
222 | } | 219 | } |
223 | 220 | ||
221 | static bool falcon_gmac_check_fault(struct efx_nic *efx) | ||
222 | { | ||
223 | return false; | ||
224 | } | ||
225 | |||
224 | struct efx_mac_operations falcon_gmac_operations = { | 226 | struct efx_mac_operations falcon_gmac_operations = { |
225 | .reconfigure = falcon_reconfigure_gmac, | 227 | .reconfigure = falcon_reconfigure_gmac, |
226 | .update_stats = falcon_update_stats_gmac, | 228 | .update_stats = falcon_update_stats_gmac, |
227 | .irq = efx_port_dummy_op_void, | 229 | .check_fault = falcon_gmac_check_fault, |
228 | .poll = efx_port_dummy_op_void, | ||
229 | }; | 230 | }; |