diff options
Diffstat (limited to 'drivers/net')
38 files changed, 2228 insertions, 1767 deletions
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c index 807e6992e614..e970e64bf966 100644 --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c | |||
@@ -26,7 +26,6 @@ | |||
26 | 26 | ||
27 | TODO: | 27 | TODO: |
28 | * Test Tx checksumming thoroughly | 28 | * Test Tx checksumming thoroughly |
29 | * Implement dev->tx_timeout | ||
30 | 29 | ||
31 | Low priority TODO: | 30 | Low priority TODO: |
32 | * Complete reset on PciErr | 31 | * Complete reset on PciErr |
@@ -1218,6 +1217,30 @@ static int cp_close (struct net_device *dev) | |||
1218 | return 0; | 1217 | return 0; |
1219 | } | 1218 | } |
1220 | 1219 | ||
1220 | static void cp_tx_timeout(struct net_device *dev) | ||
1221 | { | ||
1222 | struct cp_private *cp = netdev_priv(dev); | ||
1223 | unsigned long flags; | ||
1224 | int rc; | ||
1225 | |||
1226 | printk(KERN_WARNING "%s: Transmit timeout, status %2x %4x %4x %4x\n", | ||
1227 | dev->name, cpr8(Cmd), cpr16(CpCmd), | ||
1228 | cpr16(IntrStatus), cpr16(IntrMask)); | ||
1229 | |||
1230 | spin_lock_irqsave(&cp->lock, flags); | ||
1231 | |||
1232 | cp_stop_hw(cp); | ||
1233 | cp_clean_rings(cp); | ||
1234 | rc = cp_init_rings(cp); | ||
1235 | cp_start_hw(cp); | ||
1236 | |||
1237 | netif_wake_queue(dev); | ||
1238 | |||
1239 | spin_unlock_irqrestore(&cp->lock, flags); | ||
1240 | |||
1241 | return; | ||
1242 | } | ||
1243 | |||
1221 | #ifdef BROKEN | 1244 | #ifdef BROKEN |
1222 | static int cp_change_mtu(struct net_device *dev, int new_mtu) | 1245 | static int cp_change_mtu(struct net_device *dev, int new_mtu) |
1223 | { | 1246 | { |
@@ -1920,10 +1943,8 @@ static int cp_init_one (struct pci_dev *pdev, const struct pci_device_id *ent) | |||
1920 | dev->change_mtu = cp_change_mtu; | 1943 | dev->change_mtu = cp_change_mtu; |
1921 | #endif | 1944 | #endif |
1922 | dev->ethtool_ops = &cp_ethtool_ops; | 1945 | dev->ethtool_ops = &cp_ethtool_ops; |
1923 | #if 0 | ||
1924 | dev->tx_timeout = cp_tx_timeout; | 1946 | dev->tx_timeout = cp_tx_timeout; |
1925 | dev->watchdog_timeo = TX_TIMEOUT; | 1947 | dev->watchdog_timeo = TX_TIMEOUT; |
1926 | #endif | ||
1927 | 1948 | ||
1928 | #if CP_VLAN_TAG_USED | 1949 | #if CP_VLAN_TAG_USED |
1929 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; | 1950 | dev->features |= NETIF_F_HW_VLAN_TX | NETIF_F_HW_VLAN_RX; |
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 713ab05a87c0..43d03178064d 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig | |||
@@ -205,7 +205,7 @@ config MII | |||
205 | config MACB | 205 | config MACB |
206 | tristate "Atmel MACB support" | 206 | tristate "Atmel MACB support" |
207 | depends on AVR32 || ARCH_AT91SAM9260 || ARCH_AT91SAM9263 | 207 | depends on AVR32 || ARCH_AT91SAM9260 || ARCH_AT91SAM9263 |
208 | select MII | 208 | select PHYLIB |
209 | help | 209 | help |
210 | The Atmel MACB ethernet interface is found on many AT32 and AT91 | 210 | The Atmel MACB ethernet interface is found on many AT32 and AT91 |
211 | parts. Say Y to include support for the MACB chip. | 211 | parts. Say Y to include support for the MACB chip. |
diff --git a/drivers/net/arm/Kconfig b/drivers/net/arm/Kconfig index 5bf2d33887ac..f9cc2b621fe2 100644 --- a/drivers/net/arm/Kconfig +++ b/drivers/net/arm/Kconfig | |||
@@ -43,6 +43,7 @@ config ARM_AT91_ETHER | |||
43 | config EP93XX_ETH | 43 | config EP93XX_ETH |
44 | tristate "EP93xx Ethernet support" | 44 | tristate "EP93xx Ethernet support" |
45 | depends on ARM && ARCH_EP93XX | 45 | depends on ARM && ARCH_EP93XX |
46 | select MII | ||
46 | help | 47 | help |
47 | This is a driver for the ethernet hardware included in EP93xx CPUs. | 48 | This is a driver for the ethernet hardware included in EP93xx CPUs. |
48 | Say Y if you are building a kernel for EP93xx based devices. | 49 | Say Y if you are building a kernel for EP93xx based devices. |
diff --git a/drivers/net/atl1/atl1.h b/drivers/net/atl1/atl1.h index df4c1a0071aa..ff4765f6c3de 100644 --- a/drivers/net/atl1/atl1.h +++ b/drivers/net/atl1/atl1.h | |||
@@ -43,6 +43,7 @@ extern const struct ethtool_ops atl1_ethtool_ops; | |||
43 | struct atl1_adapter; | 43 | struct atl1_adapter; |
44 | 44 | ||
45 | #define ATL1_MAX_INTR 3 | 45 | #define ATL1_MAX_INTR 3 |
46 | #define ATL1_MAX_TX_BUF_LEN 0x3000 /* 12288 bytes */ | ||
46 | 47 | ||
47 | #define ATL1_DEFAULT_TPD 256 | 48 | #define ATL1_DEFAULT_TPD 256 |
48 | #define ATL1_MAX_TPD 1024 | 49 | #define ATL1_MAX_TPD 1024 |
@@ -57,29 +58,45 @@ struct atl1_adapter; | |||
57 | #define ATL1_RRD_DESC(R, i) ATL1_GET_DESC(R, i, struct rx_return_desc) | 58 | #define ATL1_RRD_DESC(R, i) ATL1_GET_DESC(R, i, struct rx_return_desc) |
58 | 59 | ||
59 | /* | 60 | /* |
61 | * This detached comment is preserved for documentation purposes only. | ||
62 | * It was originally attached to some code that got deleted, but seems | ||
63 | * important enough to keep around... | ||
64 | * | ||
65 | * <begin detached comment> | ||
60 | * Some workarounds require millisecond delays and are run during interrupt | 66 | * Some workarounds require millisecond delays and are run during interrupt |
61 | * context. Most notably, when establishing link, the phy may need tweaking | 67 | * context. Most notably, when establishing link, the phy may need tweaking |
62 | * but cannot process phy register reads/writes faster than millisecond | 68 | * but cannot process phy register reads/writes faster than millisecond |
63 | * intervals...and we establish link due to a "link status change" interrupt. | 69 | * intervals...and we establish link due to a "link status change" interrupt. |
70 | * <end detached comment> | ||
71 | */ | ||
72 | |||
73 | /* | ||
74 | * atl1_ring_header represents a single, contiguous block of DMA space | ||
75 | * mapped for the three descriptor rings (tpd, rfd, rrd) and the two | ||
76 | * message blocks (cmb, smb) described below | ||
64 | */ | 77 | */ |
78 | struct atl1_ring_header { | ||
79 | void *desc; /* virtual address */ | ||
80 | dma_addr_t dma; /* physical address*/ | ||
81 | unsigned int size; /* length in bytes */ | ||
82 | }; | ||
65 | 83 | ||
66 | /* | 84 | /* |
67 | * wrapper around a pointer to a socket buffer, | 85 | * atl1_buffer is wrapper around a pointer to a socket buffer |
68 | * so a DMA handle can be stored along with the buffer | 86 | * so a DMA handle can be stored along with the skb |
69 | */ | 87 | */ |
70 | struct atl1_buffer { | 88 | struct atl1_buffer { |
71 | struct sk_buff *skb; | 89 | struct sk_buff *skb; /* socket buffer */ |
72 | u16 length; | 90 | u16 length; /* rx buffer length */ |
73 | u16 alloced; | 91 | u16 alloced; /* 1 if skb allocated */ |
74 | dma_addr_t dma; | 92 | dma_addr_t dma; |
75 | }; | 93 | }; |
76 | 94 | ||
77 | #define MAX_TX_BUF_LEN 0x3000 /* 12KB */ | 95 | /* transmit packet descriptor (tpd) ring */ |
78 | |||
79 | struct atl1_tpd_ring { | 96 | struct atl1_tpd_ring { |
80 | void *desc; /* pointer to the descriptor ring memory */ | 97 | void *desc; /* descriptor ring virtual address */ |
81 | dma_addr_t dma; /* physical adress of the descriptor ring */ | 98 | dma_addr_t dma; /* descriptor ring physical address */ |
82 | u16 size; /* length of descriptor ring in bytes */ | 99 | u16 size; /* descriptor ring length in bytes */ |
83 | u16 count; /* number of descriptors in the ring */ | 100 | u16 count; /* number of descriptors in the ring */ |
84 | u16 hw_idx; /* hardware index */ | 101 | u16 hw_idx; /* hardware index */ |
85 | atomic_t next_to_clean; | 102 | atomic_t next_to_clean; |
@@ -87,36 +104,34 @@ struct atl1_tpd_ring { | |||
87 | struct atl1_buffer *buffer_info; | 104 | struct atl1_buffer *buffer_info; |
88 | }; | 105 | }; |
89 | 106 | ||
107 | /* receive free descriptor (rfd) ring */ | ||
90 | struct atl1_rfd_ring { | 108 | struct atl1_rfd_ring { |
91 | void *desc; | 109 | void *desc; /* descriptor ring virtual address */ |
92 | dma_addr_t dma; | 110 | dma_addr_t dma; /* descriptor ring physical address */ |
93 | u16 size; | 111 | u16 size; /* descriptor ring length in bytes */ |
94 | u16 count; | 112 | u16 count; /* number of descriptors in the ring */ |
95 | atomic_t next_to_use; | 113 | atomic_t next_to_use; |
96 | u16 next_to_clean; | 114 | u16 next_to_clean; |
97 | struct atl1_buffer *buffer_info; | 115 | struct atl1_buffer *buffer_info; |
98 | }; | 116 | }; |
99 | 117 | ||
118 | /* receive return descriptor (rrd) ring */ | ||
100 | struct atl1_rrd_ring { | 119 | struct atl1_rrd_ring { |
101 | void *desc; | 120 | void *desc; /* descriptor ring virtual address */ |
102 | dma_addr_t dma; | 121 | dma_addr_t dma; /* descriptor ring physical address */ |
103 | unsigned int size; | 122 | unsigned int size; /* descriptor ring length in bytes */ |
104 | u16 count; | 123 | u16 count; /* number of descriptors in the ring */ |
105 | u16 next_to_use; | 124 | u16 next_to_use; |
106 | atomic_t next_to_clean; | 125 | atomic_t next_to_clean; |
107 | }; | 126 | }; |
108 | 127 | ||
109 | struct atl1_ring_header { | 128 | /* coalescing message block (cmb) */ |
110 | void *desc; /* pointer to the descriptor ring memory */ | ||
111 | dma_addr_t dma; /* physical adress of the descriptor ring */ | ||
112 | unsigned int size; /* length of descriptor ring in bytes */ | ||
113 | }; | ||
114 | |||
115 | struct atl1_cmb { | 129 | struct atl1_cmb { |
116 | struct coals_msg_block *cmb; | 130 | struct coals_msg_block *cmb; |
117 | dma_addr_t dma; | 131 | dma_addr_t dma; |
118 | }; | 132 | }; |
119 | 133 | ||
134 | /* statistics message block (smb) */ | ||
120 | struct atl1_smb { | 135 | struct atl1_smb { |
121 | struct stats_msg_block *smb; | 136 | struct stats_msg_block *smb; |
122 | dma_addr_t dma; | 137 | dma_addr_t dma; |
@@ -141,24 +156,26 @@ struct atl1_sft_stats { | |||
141 | u64 tx_aborted_errors; | 156 | u64 tx_aborted_errors; |
142 | u64 tx_window_errors; | 157 | u64 tx_window_errors; |
143 | u64 tx_carrier_errors; | 158 | u64 tx_carrier_errors; |
144 | 159 | u64 tx_pause; /* num pause packets transmitted. */ | |
145 | u64 tx_pause; /* num Pause packet transmitted. */ | 160 | u64 excecol; /* num tx packets w/ excessive collisions. */ |
146 | u64 excecol; /* num tx packets aborted due to excessive collisions. */ | 161 | u64 deffer; /* num tx packets deferred */ |
147 | u64 deffer; /* num deferred tx packets */ | 162 | u64 scc; /* num packets subsequently transmitted |
148 | u64 scc; /* num packets subsequently transmitted successfully w/ single prior collision. */ | 163 | * successfully w/ single prior collision. */ |
149 | u64 mcc; /* num packets subsequently transmitted successfully w/ multiple prior collisions. */ | 164 | u64 mcc; /* num packets subsequently transmitted |
165 | * successfully w/ multiple prior collisions. */ | ||
150 | u64 latecol; /* num tx packets w/ late collisions. */ | 166 | u64 latecol; /* num tx packets w/ late collisions. */ |
151 | u64 tx_underun; /* num tx packets aborted due to transmit FIFO underrun, or TRD FIFO underrun */ | 167 | u64 tx_underun; /* num tx packets aborted due to transmit |
152 | u64 tx_trunc; /* num tx packets truncated due to size exceeding MTU, regardless whether truncated by Selene or not. (The name doesn't really reflect the meaning in this case.) */ | 168 | * FIFO underrun, or TRD FIFO underrun */ |
169 | u64 tx_trunc; /* num tx packets truncated due to size | ||
170 | * exceeding MTU, regardless whether truncated | ||
171 | * by the chip or not. (The name doesn't really | ||
172 | * reflect the meaning in this case.) */ | ||
153 | u64 rx_pause; /* num Pause packets received. */ | 173 | u64 rx_pause; /* num Pause packets received. */ |
154 | u64 rx_rrd_ov; | 174 | u64 rx_rrd_ov; |
155 | u64 rx_trunc; | 175 | u64 rx_trunc; |
156 | }; | 176 | }; |
157 | 177 | ||
158 | /* board specific private data structure */ | 178 | /* hardware structure */ |
159 | #define ATL1_REGS_LEN 8 | ||
160 | |||
161 | /* Structure containing variables used by the shared code */ | ||
162 | struct atl1_hw { | 179 | struct atl1_hw { |
163 | u8 __iomem *hw_addr; | 180 | u8 __iomem *hw_addr; |
164 | struct atl1_adapter *back; | 181 | struct atl1_adapter *back; |
@@ -167,24 +184,35 @@ struct atl1_hw { | |||
167 | enum atl1_dma_req_block dmar_block; | 184 | enum atl1_dma_req_block dmar_block; |
168 | enum atl1_dma_req_block dmaw_block; | 185 | enum atl1_dma_req_block dmaw_block; |
169 | u8 preamble_len; | 186 | u8 preamble_len; |
170 | u8 max_retry; /* Retransmission maximum, after which the packet will be discarded */ | 187 | u8 max_retry; /* Retransmission maximum, after which the |
171 | u8 jam_ipg; /* IPG to start JAM for collision based flow control in half-duplex mode. In units of 8-bit time */ | 188 | * packet will be discarded */ |
172 | u8 ipgt; /* Desired back to back inter-packet gap. The default is 96-bit time */ | 189 | u8 jam_ipg; /* IPG to start JAM for collision based flow |
173 | u8 min_ifg; /* Minimum number of IFG to enforce in between RX frames. Frame gap below such IFP is dropped */ | 190 | * control in half-duplex mode. In units of |
191 | * 8-bit time */ | ||
192 | u8 ipgt; /* Desired back to back inter-packet gap. | ||
193 | * The default is 96-bit time */ | ||
194 | u8 min_ifg; /* Minimum number of IFG to enforce in between | ||
195 | * receive frames. Frame gap below such IFP | ||
196 | * is dropped */ | ||
174 | u8 ipgr1; /* 64bit Carrier-Sense window */ | 197 | u8 ipgr1; /* 64bit Carrier-Sense window */ |
175 | u8 ipgr2; /* 96-bit IPG window */ | 198 | u8 ipgr2; /* 96-bit IPG window */ |
176 | u8 tpd_burst; /* Number of TPD to prefetch in cache-aligned burst. Each TPD is 16 bytes long */ | 199 | u8 tpd_burst; /* Number of TPD to prefetch in cache-aligned |
177 | u8 rfd_burst; /* Number of RFD to prefetch in cache-aligned burst. Each RFD is 12 bytes long */ | 200 | * burst. Each TPD is 16 bytes long */ |
201 | u8 rfd_burst; /* Number of RFD to prefetch in cache-aligned | ||
202 | * burst. Each RFD is 12 bytes long */ | ||
178 | u8 rfd_fetch_gap; | 203 | u8 rfd_fetch_gap; |
179 | u8 rrd_burst; /* Threshold number of RRDs that can be retired in a burst. Each RRD is 16 bytes long */ | 204 | u8 rrd_burst; /* Threshold number of RRDs that can be retired |
205 | * in a burst. Each RRD is 16 bytes long */ | ||
180 | u8 tpd_fetch_th; | 206 | u8 tpd_fetch_th; |
181 | u8 tpd_fetch_gap; | 207 | u8 tpd_fetch_gap; |
182 | u16 tx_jumbo_task_th; | 208 | u16 tx_jumbo_task_th; |
183 | u16 txf_burst; /* Number of data bytes to read in a cache-aligned burst. Each SRAM entry is | 209 | u16 txf_burst; /* Number of data bytes to read in a cache- |
184 | 8 bytes long */ | 210 | * aligned burst. Each SRAM entry is 8 bytes */ |
185 | u16 rx_jumbo_th; /* Jumbo packet size for non-VLAN packet. VLAN packets should add 4 bytes */ | 211 | u16 rx_jumbo_th; /* Jumbo packet size for non-VLAN packet. VLAN |
212 | * packets should add 4 bytes */ | ||
186 | u16 rx_jumbo_lkah; | 213 | u16 rx_jumbo_lkah; |
187 | u16 rrd_ret_timer; /* RRD retirement timer. Decrement by 1 after every 512ns passes. */ | 214 | u16 rrd_ret_timer; /* RRD retirement timer. Decrement by 1 after |
215 | * every 512ns passes. */ | ||
188 | u16 lcol; /* Collision Window */ | 216 | u16 lcol; /* Collision Window */ |
189 | 217 | ||
190 | u16 cmb_tpd; | 218 | u16 cmb_tpd; |
@@ -194,48 +222,35 @@ struct atl1_hw { | |||
194 | u32 smb_timer; | 222 | u32 smb_timer; |
195 | u16 media_type; | 223 | u16 media_type; |
196 | u16 autoneg_advertised; | 224 | u16 autoneg_advertised; |
197 | u16 pci_cmd_word; | ||
198 | 225 | ||
199 | u16 mii_autoneg_adv_reg; | 226 | u16 mii_autoneg_adv_reg; |
200 | u16 mii_1000t_ctrl_reg; | 227 | u16 mii_1000t_ctrl_reg; |
201 | 228 | ||
202 | u32 mem_rang; | ||
203 | u32 txcw; | ||
204 | u32 max_frame_size; | 229 | u32 max_frame_size; |
205 | u32 min_frame_size; | 230 | u32 min_frame_size; |
206 | u32 mc_filter_type; | ||
207 | u32 num_mc_addrs; | ||
208 | u32 collision_delta; | ||
209 | u32 tx_packet_delta; | ||
210 | u16 phy_spd_default; | ||
211 | 231 | ||
212 | u16 dev_rev; | 232 | u16 dev_rev; |
213 | 233 | ||
214 | /* spi flash */ | 234 | /* spi flash */ |
215 | u8 flash_vendor; | 235 | u8 flash_vendor; |
216 | 236 | ||
217 | u8 dma_fairness; | ||
218 | u8 mac_addr[ETH_ALEN]; | 237 | u8 mac_addr[ETH_ALEN]; |
219 | u8 perm_mac_addr[ETH_ALEN]; | 238 | u8 perm_mac_addr[ETH_ALEN]; |
220 | 239 | ||
221 | /* bool phy_preamble_sup; */ | ||
222 | bool phy_configured; | 240 | bool phy_configured; |
223 | }; | 241 | }; |
224 | 242 | ||
225 | struct atl1_adapter { | 243 | struct atl1_adapter { |
226 | /* OS defined structs */ | ||
227 | struct net_device *netdev; | 244 | struct net_device *netdev; |
228 | struct pci_dev *pdev; | 245 | struct pci_dev *pdev; |
229 | struct net_device_stats net_stats; | 246 | struct net_device_stats net_stats; |
230 | struct atl1_sft_stats soft_stats; | 247 | struct atl1_sft_stats soft_stats; |
231 | |||
232 | struct vlan_group *vlgrp; | 248 | struct vlan_group *vlgrp; |
233 | u32 rx_buffer_len; | 249 | u32 rx_buffer_len; |
234 | u32 wol; | 250 | u32 wol; |
235 | u16 link_speed; | 251 | u16 link_speed; |
236 | u16 link_duplex; | 252 | u16 link_duplex; |
237 | spinlock_t lock; | 253 | spinlock_t lock; |
238 | atomic_t irq_sem; | ||
239 | struct work_struct tx_timeout_task; | 254 | struct work_struct tx_timeout_task; |
240 | struct work_struct link_chg_task; | 255 | struct work_struct link_chg_task; |
241 | struct work_struct pcie_dma_to_rst_task; | 256 | struct work_struct pcie_dma_to_rst_task; |
@@ -243,9 +258,7 @@ struct atl1_adapter { | |||
243 | struct timer_list phy_config_timer; | 258 | struct timer_list phy_config_timer; |
244 | bool phy_timer_pending; | 259 | bool phy_timer_pending; |
245 | 260 | ||
246 | bool mac_disabled; | 261 | /* all descriptor rings' memory */ |
247 | |||
248 | /* All descriptor rings' memory */ | ||
249 | struct atl1_ring_header ring_header; | 262 | struct atl1_ring_header ring_header; |
250 | 263 | ||
251 | /* TX */ | 264 | /* TX */ |
@@ -258,25 +271,16 @@ struct atl1_adapter { | |||
258 | u64 hw_csum_err; | 271 | u64 hw_csum_err; |
259 | u64 hw_csum_good; | 272 | u64 hw_csum_good; |
260 | 273 | ||
261 | u32 gorcl; | 274 | u16 imt; /* interrupt moderator timer (2us resolution */ |
262 | u64 gorcl_old; | 275 | u16 ict; /* interrupt clear timer (2us resolution */ |
263 | 276 | struct mii_if_info mii; /* MII interface info */ | |
264 | /* Interrupt Moderator timer ( 2us resolution) */ | ||
265 | u16 imt; | ||
266 | /* Interrupt Clear timer (2us resolution) */ | ||
267 | u16 ict; | ||
268 | |||
269 | /* MII interface info */ | ||
270 | struct mii_if_info mii; | ||
271 | 277 | ||
272 | /* structs defined in atl1_hw.h */ | 278 | /* structs defined in atl1_hw.h */ |
273 | u32 bd_number; /* board number */ | 279 | u32 bd_number; /* board number */ |
274 | bool pci_using_64; | 280 | bool pci_using_64; |
275 | struct atl1_hw hw; | 281 | struct atl1_hw hw; |
276 | struct atl1_smb smb; | 282 | struct atl1_smb smb; |
277 | struct atl1_cmb cmb; | 283 | struct atl1_cmb cmb; |
278 | |||
279 | u32 pci_state[16]; | ||
280 | }; | 284 | }; |
281 | 285 | ||
282 | #endif /* _ATL1_H_ */ | 286 | #endif /* _ATL1_H_ */ |
diff --git a/drivers/net/atl1/atl1_main.c b/drivers/net/atl1/atl1_main.c index 501919eb7f5e..4a18b881ae9a 100644 --- a/drivers/net/atl1/atl1_main.c +++ b/drivers/net/atl1/atl1_main.c | |||
@@ -38,7 +38,7 @@ | |||
38 | * TODO: | 38 | * TODO: |
39 | * Fix TSO; tx performance is horrible with TSO enabled. | 39 | * Fix TSO; tx performance is horrible with TSO enabled. |
40 | * Wake on LAN. | 40 | * Wake on LAN. |
41 | * Add more ethtool functions, including set ring parameters. | 41 | * Add more ethtool functions. |
42 | * Fix abstruse irq enable/disable condition described here: | 42 | * Fix abstruse irq enable/disable condition described here: |
43 | * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2 | 43 | * http://marc.theaimsgroup.com/?l=linux-netdev&m=116398508500553&w=2 |
44 | * | 44 | * |
@@ -158,13 +158,70 @@ static int __devinit atl1_sw_init(struct atl1_adapter *adapter) | |||
158 | hw->cmb_tx_timer = 1; /* about 2us */ | 158 | hw->cmb_tx_timer = 1; /* about 2us */ |
159 | hw->smb_timer = 100000; /* about 200ms */ | 159 | hw->smb_timer = 100000; /* about 200ms */ |
160 | 160 | ||
161 | atomic_set(&adapter->irq_sem, 0); | ||
162 | spin_lock_init(&adapter->lock); | 161 | spin_lock_init(&adapter->lock); |
163 | spin_lock_init(&adapter->mb_lock); | 162 | spin_lock_init(&adapter->mb_lock); |
164 | 163 | ||
165 | return 0; | 164 | return 0; |
166 | } | 165 | } |
167 | 166 | ||
167 | static int mdio_read(struct net_device *netdev, int phy_id, int reg_num) | ||
168 | { | ||
169 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
170 | u16 result; | ||
171 | |||
172 | atl1_read_phy_reg(&adapter->hw, reg_num & 0x1f, &result); | ||
173 | |||
174 | return result; | ||
175 | } | ||
176 | |||
177 | static void mdio_write(struct net_device *netdev, int phy_id, int reg_num, | ||
178 | int val) | ||
179 | { | ||
180 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
181 | |||
182 | atl1_write_phy_reg(&adapter->hw, reg_num, val); | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | * atl1_mii_ioctl - | ||
187 | * @netdev: | ||
188 | * @ifreq: | ||
189 | * @cmd: | ||
190 | */ | ||
191 | static int atl1_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | ||
192 | { | ||
193 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
194 | unsigned long flags; | ||
195 | int retval; | ||
196 | |||
197 | if (!netif_running(netdev)) | ||
198 | return -EINVAL; | ||
199 | |||
200 | spin_lock_irqsave(&adapter->lock, flags); | ||
201 | retval = generic_mii_ioctl(&adapter->mii, if_mii(ifr), cmd, NULL); | ||
202 | spin_unlock_irqrestore(&adapter->lock, flags); | ||
203 | |||
204 | return retval; | ||
205 | } | ||
206 | |||
207 | /* | ||
208 | * atl1_ioctl - | ||
209 | * @netdev: | ||
210 | * @ifreq: | ||
211 | * @cmd: | ||
212 | */ | ||
213 | static int atl1_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | ||
214 | { | ||
215 | switch (cmd) { | ||
216 | case SIOCGMIIPHY: | ||
217 | case SIOCGMIIREG: | ||
218 | case SIOCSMIIREG: | ||
219 | return atl1_mii_ioctl(netdev, ifr, cmd); | ||
220 | default: | ||
221 | return -EOPNOTSUPP; | ||
222 | } | ||
223 | } | ||
224 | |||
168 | /* | 225 | /* |
169 | * atl1_setup_mem_resources - allocate Tx / RX descriptor resources | 226 | * atl1_setup_mem_resources - allocate Tx / RX descriptor resources |
170 | * @adapter: board private structure | 227 | * @adapter: board private structure |
@@ -188,19 +245,22 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) | |||
188 | goto err_nomem; | 245 | goto err_nomem; |
189 | } | 246 | } |
190 | rfd_ring->buffer_info = | 247 | rfd_ring->buffer_info = |
191 | (struct atl1_buffer *)(tpd_ring->buffer_info + tpd_ring->count); | 248 | (struct atl1_buffer *)(tpd_ring->buffer_info + tpd_ring->count); |
192 | 249 | ||
193 | /* real ring DMA buffer */ | 250 | /* real ring DMA buffer |
194 | ring_header->size = size = sizeof(struct tx_packet_desc) * | 251 | * each ring/block may need up to 8 bytes for alignment, hence the |
195 | tpd_ring->count | 252 | * additional 40 bytes tacked onto the end. |
196 | + sizeof(struct rx_free_desc) * rfd_ring->count | 253 | */ |
197 | + sizeof(struct rx_return_desc) * rrd_ring->count | 254 | ring_header->size = size = |
198 | + sizeof(struct coals_msg_block) | 255 | sizeof(struct tx_packet_desc) * tpd_ring->count |
199 | + sizeof(struct stats_msg_block) | 256 | + sizeof(struct rx_free_desc) * rfd_ring->count |
200 | + 40; /* "40: for 8 bytes align" huh? -- CHS */ | 257 | + sizeof(struct rx_return_desc) * rrd_ring->count |
258 | + sizeof(struct coals_msg_block) | ||
259 | + sizeof(struct stats_msg_block) | ||
260 | + 40; | ||
201 | 261 | ||
202 | ring_header->desc = pci_alloc_consistent(pdev, ring_header->size, | 262 | ring_header->desc = pci_alloc_consistent(pdev, ring_header->size, |
203 | &ring_header->dma); | 263 | &ring_header->dma); |
204 | if (unlikely(!ring_header->desc)) { | 264 | if (unlikely(!ring_header->desc)) { |
205 | dev_err(&pdev->dev, "pci_alloc_consistent failed\n"); | 265 | dev_err(&pdev->dev, "pci_alloc_consistent failed\n"); |
206 | goto err_nomem; | 266 | goto err_nomem; |
@@ -214,8 +274,6 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) | |||
214 | tpd_ring->dma += offset; | 274 | tpd_ring->dma += offset; |
215 | tpd_ring->desc = (u8 *) ring_header->desc + offset; | 275 | tpd_ring->desc = (u8 *) ring_header->desc + offset; |
216 | tpd_ring->size = sizeof(struct tx_packet_desc) * tpd_ring->count; | 276 | tpd_ring->size = sizeof(struct tx_packet_desc) * tpd_ring->count; |
217 | atomic_set(&tpd_ring->next_to_use, 0); | ||
218 | atomic_set(&tpd_ring->next_to_clean, 0); | ||
219 | 277 | ||
220 | /* init RFD ring */ | 278 | /* init RFD ring */ |
221 | rfd_ring->dma = tpd_ring->dma + tpd_ring->size; | 279 | rfd_ring->dma = tpd_ring->dma + tpd_ring->size; |
@@ -223,9 +281,7 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) | |||
223 | rfd_ring->dma += offset; | 281 | rfd_ring->dma += offset; |
224 | rfd_ring->desc = (u8 *) tpd_ring->desc + (tpd_ring->size + offset); | 282 | rfd_ring->desc = (u8 *) tpd_ring->desc + (tpd_ring->size + offset); |
225 | rfd_ring->size = sizeof(struct rx_free_desc) * rfd_ring->count; | 283 | rfd_ring->size = sizeof(struct rx_free_desc) * rfd_ring->count; |
226 | rfd_ring->next_to_clean = 0; | 284 | |
227 | /* rfd_ring->next_to_use = rfd_ring->count - 1; */ | ||
228 | atomic_set(&rfd_ring->next_to_use, 0); | ||
229 | 285 | ||
230 | /* init RRD ring */ | 286 | /* init RRD ring */ |
231 | rrd_ring->dma = rfd_ring->dma + rfd_ring->size; | 287 | rrd_ring->dma = rfd_ring->dma + rfd_ring->size; |
@@ -233,23 +289,22 @@ s32 atl1_setup_ring_resources(struct atl1_adapter *adapter) | |||
233 | rrd_ring->dma += offset; | 289 | rrd_ring->dma += offset; |
234 | rrd_ring->desc = (u8 *) rfd_ring->desc + (rfd_ring->size + offset); | 290 | rrd_ring->desc = (u8 *) rfd_ring->desc + (rfd_ring->size + offset); |
235 | rrd_ring->size = sizeof(struct rx_return_desc) * rrd_ring->count; | 291 | rrd_ring->size = sizeof(struct rx_return_desc) * rrd_ring->count; |
236 | rrd_ring->next_to_use = 0; | 292 | |
237 | atomic_set(&rrd_ring->next_to_clean, 0); | ||
238 | 293 | ||
239 | /* init CMB */ | 294 | /* init CMB */ |
240 | adapter->cmb.dma = rrd_ring->dma + rrd_ring->size; | 295 | adapter->cmb.dma = rrd_ring->dma + rrd_ring->size; |
241 | offset = (adapter->cmb.dma & 0x7) ? (8 - (adapter->cmb.dma & 0x7)) : 0; | 296 | offset = (adapter->cmb.dma & 0x7) ? (8 - (adapter->cmb.dma & 0x7)) : 0; |
242 | adapter->cmb.dma += offset; | 297 | adapter->cmb.dma += offset; |
243 | adapter->cmb.cmb = | 298 | adapter->cmb.cmb = (struct coals_msg_block *) |
244 | (struct coals_msg_block *) ((u8 *) rrd_ring->desc + | 299 | ((u8 *) rrd_ring->desc + (rrd_ring->size + offset)); |
245 | (rrd_ring->size + offset)); | ||
246 | 300 | ||
247 | /* init SMB */ | 301 | /* init SMB */ |
248 | adapter->smb.dma = adapter->cmb.dma + sizeof(struct coals_msg_block); | 302 | adapter->smb.dma = adapter->cmb.dma + sizeof(struct coals_msg_block); |
249 | offset = (adapter->smb.dma & 0x7) ? (8 - (adapter->smb.dma & 0x7)) : 0; | 303 | offset = (adapter->smb.dma & 0x7) ? (8 - (adapter->smb.dma & 0x7)) : 0; |
250 | adapter->smb.dma += offset; | 304 | adapter->smb.dma += offset; |
251 | adapter->smb.smb = (struct stats_msg_block *) | 305 | adapter->smb.smb = (struct stats_msg_block *) |
252 | ((u8 *) adapter->cmb.cmb + (sizeof(struct coals_msg_block) + offset)); | 306 | ((u8 *) adapter->cmb.cmb + |
307 | (sizeof(struct coals_msg_block) + offset)); | ||
253 | 308 | ||
254 | return ATL1_SUCCESS; | 309 | return ATL1_SUCCESS; |
255 | 310 | ||
@@ -258,559 +313,133 @@ err_nomem: | |||
258 | return -ENOMEM; | 313 | return -ENOMEM; |
259 | } | 314 | } |
260 | 315 | ||
261 | /* | 316 | void atl1_init_ring_ptrs(struct atl1_adapter *adapter) |
262 | * atl1_irq_enable - Enable default interrupt generation settings | ||
263 | * @adapter: board private structure | ||
264 | */ | ||
265 | static void atl1_irq_enable(struct atl1_adapter *adapter) | ||
266 | { | ||
267 | if (likely(!atomic_dec_and_test(&adapter->irq_sem))) | ||
268 | iowrite32(IMR_NORMAL_MASK, adapter->hw.hw_addr + REG_IMR); | ||
269 | } | ||
270 | |||
271 | static void atl1_clear_phy_int(struct atl1_adapter *adapter) | ||
272 | { | ||
273 | u16 phy_data; | ||
274 | unsigned long flags; | ||
275 | |||
276 | spin_lock_irqsave(&adapter->lock, flags); | ||
277 | atl1_read_phy_reg(&adapter->hw, 19, &phy_data); | ||
278 | spin_unlock_irqrestore(&adapter->lock, flags); | ||
279 | } | ||
280 | |||
281 | static void atl1_inc_smb(struct atl1_adapter *adapter) | ||
282 | { | ||
283 | struct stats_msg_block *smb = adapter->smb.smb; | ||
284 | |||
285 | /* Fill out the OS statistics structure */ | ||
286 | adapter->soft_stats.rx_packets += smb->rx_ok; | ||
287 | adapter->soft_stats.tx_packets += smb->tx_ok; | ||
288 | adapter->soft_stats.rx_bytes += smb->rx_byte_cnt; | ||
289 | adapter->soft_stats.tx_bytes += smb->tx_byte_cnt; | ||
290 | adapter->soft_stats.multicast += smb->rx_mcast; | ||
291 | adapter->soft_stats.collisions += (smb->tx_1_col + | ||
292 | smb->tx_2_col * 2 + | ||
293 | smb->tx_late_col + | ||
294 | smb->tx_abort_col * | ||
295 | adapter->hw.max_retry); | ||
296 | |||
297 | /* Rx Errors */ | ||
298 | adapter->soft_stats.rx_errors += (smb->rx_frag + | ||
299 | smb->rx_fcs_err + | ||
300 | smb->rx_len_err + | ||
301 | smb->rx_sz_ov + | ||
302 | smb->rx_rxf_ov + | ||
303 | smb->rx_rrd_ov + smb->rx_align_err); | ||
304 | adapter->soft_stats.rx_fifo_errors += smb->rx_rxf_ov; | ||
305 | adapter->soft_stats.rx_length_errors += smb->rx_len_err; | ||
306 | adapter->soft_stats.rx_crc_errors += smb->rx_fcs_err; | ||
307 | adapter->soft_stats.rx_frame_errors += smb->rx_align_err; | ||
308 | adapter->soft_stats.rx_missed_errors += (smb->rx_rrd_ov + | ||
309 | smb->rx_rxf_ov); | ||
310 | |||
311 | adapter->soft_stats.rx_pause += smb->rx_pause; | ||
312 | adapter->soft_stats.rx_rrd_ov += smb->rx_rrd_ov; | ||
313 | adapter->soft_stats.rx_trunc += smb->rx_sz_ov; | ||
314 | |||
315 | /* Tx Errors */ | ||
316 | adapter->soft_stats.tx_errors += (smb->tx_late_col + | ||
317 | smb->tx_abort_col + | ||
318 | smb->tx_underrun + smb->tx_trunc); | ||
319 | adapter->soft_stats.tx_fifo_errors += smb->tx_underrun; | ||
320 | adapter->soft_stats.tx_aborted_errors += smb->tx_abort_col; | ||
321 | adapter->soft_stats.tx_window_errors += smb->tx_late_col; | ||
322 | |||
323 | adapter->soft_stats.excecol += smb->tx_abort_col; | ||
324 | adapter->soft_stats.deffer += smb->tx_defer; | ||
325 | adapter->soft_stats.scc += smb->tx_1_col; | ||
326 | adapter->soft_stats.mcc += smb->tx_2_col; | ||
327 | adapter->soft_stats.latecol += smb->tx_late_col; | ||
328 | adapter->soft_stats.tx_underun += smb->tx_underrun; | ||
329 | adapter->soft_stats.tx_trunc += smb->tx_trunc; | ||
330 | adapter->soft_stats.tx_pause += smb->tx_pause; | ||
331 | |||
332 | adapter->net_stats.rx_packets = adapter->soft_stats.rx_packets; | ||
333 | adapter->net_stats.tx_packets = adapter->soft_stats.tx_packets; | ||
334 | adapter->net_stats.rx_bytes = adapter->soft_stats.rx_bytes; | ||
335 | adapter->net_stats.tx_bytes = adapter->soft_stats.tx_bytes; | ||
336 | adapter->net_stats.multicast = adapter->soft_stats.multicast; | ||
337 | adapter->net_stats.collisions = adapter->soft_stats.collisions; | ||
338 | adapter->net_stats.rx_errors = adapter->soft_stats.rx_errors; | ||
339 | adapter->net_stats.rx_over_errors = | ||
340 | adapter->soft_stats.rx_missed_errors; | ||
341 | adapter->net_stats.rx_length_errors = | ||
342 | adapter->soft_stats.rx_length_errors; | ||
343 | adapter->net_stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors; | ||
344 | adapter->net_stats.rx_frame_errors = | ||
345 | adapter->soft_stats.rx_frame_errors; | ||
346 | adapter->net_stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors; | ||
347 | adapter->net_stats.rx_missed_errors = | ||
348 | adapter->soft_stats.rx_missed_errors; | ||
349 | adapter->net_stats.tx_errors = adapter->soft_stats.tx_errors; | ||
350 | adapter->net_stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors; | ||
351 | adapter->net_stats.tx_aborted_errors = | ||
352 | adapter->soft_stats.tx_aborted_errors; | ||
353 | adapter->net_stats.tx_window_errors = | ||
354 | adapter->soft_stats.tx_window_errors; | ||
355 | adapter->net_stats.tx_carrier_errors = | ||
356 | adapter->soft_stats.tx_carrier_errors; | ||
357 | } | ||
358 | |||
359 | static void atl1_rx_checksum(struct atl1_adapter *adapter, | ||
360 | struct rx_return_desc *rrd, | ||
361 | struct sk_buff *skb) | ||
362 | { | 317 | { |
363 | skb->ip_summed = CHECKSUM_NONE; | 318 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; |
364 | 319 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | |
365 | if (unlikely(rrd->pkt_flg & PACKET_FLAG_ERR)) { | 320 | struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring; |
366 | if (rrd->err_flg & (ERR_FLAG_CRC | ERR_FLAG_TRUNC | | ||
367 | ERR_FLAG_CODE | ERR_FLAG_OV)) { | ||
368 | adapter->hw_csum_err++; | ||
369 | dev_dbg(&adapter->pdev->dev, "rx checksum error\n"); | ||
370 | return; | ||
371 | } | ||
372 | } | ||
373 | 321 | ||
374 | /* not IPv4 */ | 322 | atomic_set(&tpd_ring->next_to_use, 0); |
375 | if (!(rrd->pkt_flg & PACKET_FLAG_IPV4)) | 323 | atomic_set(&tpd_ring->next_to_clean, 0); |
376 | /* checksum is invalid, but it's not an IPv4 pkt, so ok */ | ||
377 | return; | ||
378 | 324 | ||
379 | /* IPv4 packet */ | 325 | rfd_ring->next_to_clean = 0; |
380 | if (likely(!(rrd->err_flg & | 326 | atomic_set(&rfd_ring->next_to_use, 0); |
381 | (ERR_FLAG_IP_CHKSUM | ERR_FLAG_L4_CHKSUM)))) { | ||
382 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
383 | adapter->hw_csum_good++; | ||
384 | return; | ||
385 | } | ||
386 | 327 | ||
387 | /* IPv4, but hardware thinks its checksum is wrong */ | 328 | rrd_ring->next_to_use = 0; |
388 | dev_dbg(&adapter->pdev->dev, | 329 | atomic_set(&rrd_ring->next_to_clean, 0); |
389 | "hw csum wrong, pkt_flag:%x, err_flag:%x\n", | ||
390 | rrd->pkt_flg, rrd->err_flg); | ||
391 | skb->ip_summed = CHECKSUM_COMPLETE; | ||
392 | skb->csum = htons(rrd->xsz.xsum_sz.rx_chksum); | ||
393 | adapter->hw_csum_err++; | ||
394 | return; | ||
395 | } | 330 | } |
396 | 331 | ||
397 | /* | 332 | /* |
398 | * atl1_alloc_rx_buffers - Replace used receive buffers | 333 | * atl1_clean_rx_ring - Free RFD Buffers |
399 | * @adapter: address of board private structure | 334 | * @adapter: board private structure |
400 | */ | 335 | */ |
401 | static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter) | 336 | static void atl1_clean_rx_ring(struct atl1_adapter *adapter) |
402 | { | ||
403 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | ||
404 | struct pci_dev *pdev = adapter->pdev; | ||
405 | struct page *page; | ||
406 | unsigned long offset; | ||
407 | struct atl1_buffer *buffer_info, *next_info; | ||
408 | struct sk_buff *skb; | ||
409 | u16 num_alloc = 0; | ||
410 | u16 rfd_next_to_use, next_next; | ||
411 | struct rx_free_desc *rfd_desc; | ||
412 | |||
413 | next_next = rfd_next_to_use = atomic_read(&rfd_ring->next_to_use); | ||
414 | if (++next_next == rfd_ring->count) | ||
415 | next_next = 0; | ||
416 | buffer_info = &rfd_ring->buffer_info[rfd_next_to_use]; | ||
417 | next_info = &rfd_ring->buffer_info[next_next]; | ||
418 | |||
419 | while (!buffer_info->alloced && !next_info->alloced) { | ||
420 | if (buffer_info->skb) { | ||
421 | buffer_info->alloced = 1; | ||
422 | goto next; | ||
423 | } | ||
424 | |||
425 | rfd_desc = ATL1_RFD_DESC(rfd_ring, rfd_next_to_use); | ||
426 | |||
427 | skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN); | ||
428 | if (unlikely(!skb)) { /* Better luck next round */ | ||
429 | adapter->net_stats.rx_dropped++; | ||
430 | break; | ||
431 | } | ||
432 | |||
433 | /* | ||
434 | * Make buffer alignment 2 beyond a 16 byte boundary | ||
435 | * this will result in a 16 byte aligned IP header after | ||
436 | * the 14 byte MAC header is removed | ||
437 | */ | ||
438 | skb_reserve(skb, NET_IP_ALIGN); | ||
439 | |||
440 | buffer_info->alloced = 1; | ||
441 | buffer_info->skb = skb; | ||
442 | buffer_info->length = (u16) adapter->rx_buffer_len; | ||
443 | page = virt_to_page(skb->data); | ||
444 | offset = (unsigned long)skb->data & ~PAGE_MASK; | ||
445 | buffer_info->dma = pci_map_page(pdev, page, offset, | ||
446 | adapter->rx_buffer_len, | ||
447 | PCI_DMA_FROMDEVICE); | ||
448 | rfd_desc->buffer_addr = cpu_to_le64(buffer_info->dma); | ||
449 | rfd_desc->buf_len = cpu_to_le16(adapter->rx_buffer_len); | ||
450 | rfd_desc->coalese = 0; | ||
451 | |||
452 | next: | ||
453 | rfd_next_to_use = next_next; | ||
454 | if (unlikely(++next_next == rfd_ring->count)) | ||
455 | next_next = 0; | ||
456 | |||
457 | buffer_info = &rfd_ring->buffer_info[rfd_next_to_use]; | ||
458 | next_info = &rfd_ring->buffer_info[next_next]; | ||
459 | num_alloc++; | ||
460 | } | ||
461 | |||
462 | if (num_alloc) { | ||
463 | /* | ||
464 | * Force memory writes to complete before letting h/w | ||
465 | * know there are new descriptors to fetch. (Only | ||
466 | * applicable for weak-ordered memory model archs, | ||
467 | * such as IA-64). | ||
468 | */ | ||
469 | wmb(); | ||
470 | atomic_set(&rfd_ring->next_to_use, (int)rfd_next_to_use); | ||
471 | } | ||
472 | return num_alloc; | ||
473 | } | ||
474 | |||
475 | static void atl1_intr_rx(struct atl1_adapter *adapter) | ||
476 | { | 337 | { |
477 | int i, count; | ||
478 | u16 length; | ||
479 | u16 rrd_next_to_clean; | ||
480 | u32 value; | ||
481 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | 338 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; |
482 | struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring; | 339 | struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring; |
483 | struct atl1_buffer *buffer_info; | 340 | struct atl1_buffer *buffer_info; |
484 | struct rx_return_desc *rrd; | 341 | struct pci_dev *pdev = adapter->pdev; |
485 | struct sk_buff *skb; | 342 | unsigned long size; |
486 | 343 | unsigned int i; | |
487 | count = 0; | ||
488 | |||
489 | rrd_next_to_clean = atomic_read(&rrd_ring->next_to_clean); | ||
490 | |||
491 | while (1) { | ||
492 | rrd = ATL1_RRD_DESC(rrd_ring, rrd_next_to_clean); | ||
493 | i = 1; | ||
494 | if (likely(rrd->xsz.valid)) { /* packet valid */ | ||
495 | chk_rrd: | ||
496 | /* check rrd status */ | ||
497 | if (likely(rrd->num_buf == 1)) | ||
498 | goto rrd_ok; | ||
499 | |||
500 | /* rrd seems to be bad */ | ||
501 | if (unlikely(i-- > 0)) { | ||
502 | /* rrd may not be DMAed completely */ | ||
503 | dev_dbg(&adapter->pdev->dev, | ||
504 | "incomplete RRD DMA transfer\n"); | ||
505 | udelay(1); | ||
506 | goto chk_rrd; | ||
507 | } | ||
508 | /* bad rrd */ | ||
509 | dev_dbg(&adapter->pdev->dev, "bad RRD\n"); | ||
510 | /* see if update RFD index */ | ||
511 | if (rrd->num_buf > 1) { | ||
512 | u16 num_buf; | ||
513 | num_buf = | ||
514 | (rrd->xsz.xsum_sz.pkt_size + | ||
515 | adapter->rx_buffer_len - | ||
516 | 1) / adapter->rx_buffer_len; | ||
517 | if (rrd->num_buf == num_buf) { | ||
518 | /* clean alloc flag for bad rrd */ | ||
519 | while (rfd_ring->next_to_clean != | ||
520 | (rrd->buf_indx + num_buf)) { | ||
521 | rfd_ring->buffer_info[rfd_ring-> | ||
522 | next_to_clean].alloced = 0; | ||
523 | if (++rfd_ring->next_to_clean == | ||
524 | rfd_ring->count) { | ||
525 | rfd_ring-> | ||
526 | next_to_clean = 0; | ||
527 | } | ||
528 | } | ||
529 | } | ||
530 | } | ||
531 | |||
532 | /* update rrd */ | ||
533 | rrd->xsz.valid = 0; | ||
534 | if (++rrd_next_to_clean == rrd_ring->count) | ||
535 | rrd_next_to_clean = 0; | ||
536 | count++; | ||
537 | continue; | ||
538 | } else { /* current rrd still not be updated */ | ||
539 | 344 | ||
540 | break; | 345 | /* Free all the Rx ring sk_buffs */ |
541 | } | 346 | for (i = 0; i < rfd_ring->count; i++) { |
542 | rrd_ok: | 347 | buffer_info = &rfd_ring->buffer_info[i]; |
543 | /* clean alloc flag for bad rrd */ | 348 | if (buffer_info->dma) { |
544 | while (rfd_ring->next_to_clean != rrd->buf_indx) { | 349 | pci_unmap_page(pdev, buffer_info->dma, |
545 | rfd_ring->buffer_info[rfd_ring->next_to_clean].alloced = | 350 | buffer_info->length, PCI_DMA_FROMDEVICE); |
546 | 0; | 351 | buffer_info->dma = 0; |
547 | if (++rfd_ring->next_to_clean == rfd_ring->count) | ||
548 | rfd_ring->next_to_clean = 0; | ||
549 | } | 352 | } |
550 | 353 | if (buffer_info->skb) { | |
551 | buffer_info = &rfd_ring->buffer_info[rrd->buf_indx]; | 354 | dev_kfree_skb(buffer_info->skb); |
552 | if (++rfd_ring->next_to_clean == rfd_ring->count) | 355 | buffer_info->skb = NULL; |
553 | rfd_ring->next_to_clean = 0; | ||
554 | |||
555 | /* update rrd next to clean */ | ||
556 | if (++rrd_next_to_clean == rrd_ring->count) | ||
557 | rrd_next_to_clean = 0; | ||
558 | count++; | ||
559 | |||
560 | if (unlikely(rrd->pkt_flg & PACKET_FLAG_ERR)) { | ||
561 | if (!(rrd->err_flg & | ||
562 | (ERR_FLAG_IP_CHKSUM | ERR_FLAG_L4_CHKSUM | ||
563 | | ERR_FLAG_LEN))) { | ||
564 | /* packet error, don't need upstream */ | ||
565 | buffer_info->alloced = 0; | ||
566 | rrd->xsz.valid = 0; | ||
567 | continue; | ||
568 | } | ||
569 | } | 356 | } |
570 | |||
571 | /* Good Receive */ | ||
572 | pci_unmap_page(adapter->pdev, buffer_info->dma, | ||
573 | buffer_info->length, PCI_DMA_FROMDEVICE); | ||
574 | skb = buffer_info->skb; | ||
575 | length = le16_to_cpu(rrd->xsz.xsum_sz.pkt_size); | ||
576 | |||
577 | skb_put(skb, length - ETHERNET_FCS_SIZE); | ||
578 | |||
579 | /* Receive Checksum Offload */ | ||
580 | atl1_rx_checksum(adapter, rrd, skb); | ||
581 | skb->protocol = eth_type_trans(skb, adapter->netdev); | ||
582 | |||
583 | if (adapter->vlgrp && (rrd->pkt_flg & PACKET_FLAG_VLAN_INS)) { | ||
584 | u16 vlan_tag = (rrd->vlan_tag >> 4) | | ||
585 | ((rrd->vlan_tag & 7) << 13) | | ||
586 | ((rrd->vlan_tag & 8) << 9); | ||
587 | vlan_hwaccel_rx(skb, adapter->vlgrp, vlan_tag); | ||
588 | } else | ||
589 | netif_rx(skb); | ||
590 | |||
591 | /* let protocol layer free skb */ | ||
592 | buffer_info->skb = NULL; | ||
593 | buffer_info->alloced = 0; | ||
594 | rrd->xsz.valid = 0; | ||
595 | |||
596 | adapter->netdev->last_rx = jiffies; | ||
597 | } | 357 | } |
598 | 358 | ||
599 | atomic_set(&rrd_ring->next_to_clean, rrd_next_to_clean); | 359 | size = sizeof(struct atl1_buffer) * rfd_ring->count; |
600 | 360 | memset(rfd_ring->buffer_info, 0, size); | |
601 | atl1_alloc_rx_buffers(adapter); | ||
602 | 361 | ||
603 | /* update mailbox ? */ | 362 | /* Zero out the descriptor ring */ |
604 | if (count) { | 363 | memset(rfd_ring->desc, 0, rfd_ring->size); |
605 | u32 tpd_next_to_use; | ||
606 | u32 rfd_next_to_use; | ||
607 | u32 rrd_next_to_clean; | ||
608 | 364 | ||
609 | spin_lock(&adapter->mb_lock); | 365 | rfd_ring->next_to_clean = 0; |
366 | atomic_set(&rfd_ring->next_to_use, 0); | ||
610 | 367 | ||
611 | tpd_next_to_use = atomic_read(&adapter->tpd_ring.next_to_use); | 368 | rrd_ring->next_to_use = 0; |
612 | rfd_next_to_use = | 369 | atomic_set(&rrd_ring->next_to_clean, 0); |
613 | atomic_read(&adapter->rfd_ring.next_to_use); | ||
614 | rrd_next_to_clean = | ||
615 | atomic_read(&adapter->rrd_ring.next_to_clean); | ||
616 | value = ((rfd_next_to_use & MB_RFD_PROD_INDX_MASK) << | ||
617 | MB_RFD_PROD_INDX_SHIFT) | | ||
618 | ((rrd_next_to_clean & MB_RRD_CONS_INDX_MASK) << | ||
619 | MB_RRD_CONS_INDX_SHIFT) | | ||
620 | ((tpd_next_to_use & MB_TPD_PROD_INDX_MASK) << | ||
621 | MB_TPD_PROD_INDX_SHIFT); | ||
622 | iowrite32(value, adapter->hw.hw_addr + REG_MAILBOX); | ||
623 | spin_unlock(&adapter->mb_lock); | ||
624 | } | ||
625 | } | 370 | } |
626 | 371 | ||
627 | static void atl1_intr_tx(struct atl1_adapter *adapter) | 372 | /* |
373 | * atl1_clean_tx_ring - Free Tx Buffers | ||
374 | * @adapter: board private structure | ||
375 | */ | ||
376 | static void atl1_clean_tx_ring(struct atl1_adapter *adapter) | ||
628 | { | 377 | { |
629 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; | 378 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; |
630 | struct atl1_buffer *buffer_info; | 379 | struct atl1_buffer *buffer_info; |
631 | u16 sw_tpd_next_to_clean; | 380 | struct pci_dev *pdev = adapter->pdev; |
632 | u16 cmb_tpd_next_to_clean; | 381 | unsigned long size; |
633 | 382 | unsigned int i; | |
634 | sw_tpd_next_to_clean = atomic_read(&tpd_ring->next_to_clean); | ||
635 | cmb_tpd_next_to_clean = le16_to_cpu(adapter->cmb.cmb->tpd_cons_idx); | ||
636 | |||
637 | while (cmb_tpd_next_to_clean != sw_tpd_next_to_clean) { | ||
638 | struct tx_packet_desc *tpd; | ||
639 | 383 | ||
640 | tpd = ATL1_TPD_DESC(tpd_ring, sw_tpd_next_to_clean); | 384 | /* Free all the Tx ring sk_buffs */ |
641 | buffer_info = &tpd_ring->buffer_info[sw_tpd_next_to_clean]; | 385 | for (i = 0; i < tpd_ring->count; i++) { |
386 | buffer_info = &tpd_ring->buffer_info[i]; | ||
642 | if (buffer_info->dma) { | 387 | if (buffer_info->dma) { |
643 | pci_unmap_page(adapter->pdev, buffer_info->dma, | 388 | pci_unmap_page(pdev, buffer_info->dma, |
644 | buffer_info->length, PCI_DMA_TODEVICE); | 389 | buffer_info->length, PCI_DMA_TODEVICE); |
645 | buffer_info->dma = 0; | 390 | buffer_info->dma = 0; |
646 | } | 391 | } |
392 | } | ||
647 | 393 | ||
394 | for (i = 0; i < tpd_ring->count; i++) { | ||
395 | buffer_info = &tpd_ring->buffer_info[i]; | ||
648 | if (buffer_info->skb) { | 396 | if (buffer_info->skb) { |
649 | dev_kfree_skb_irq(buffer_info->skb); | 397 | dev_kfree_skb_any(buffer_info->skb); |
650 | buffer_info->skb = NULL; | 398 | buffer_info->skb = NULL; |
651 | } | 399 | } |
652 | tpd->buffer_addr = 0; | ||
653 | tpd->desc.data = 0; | ||
654 | |||
655 | if (++sw_tpd_next_to_clean == tpd_ring->count) | ||
656 | sw_tpd_next_to_clean = 0; | ||
657 | } | 400 | } |
658 | atomic_set(&tpd_ring->next_to_clean, sw_tpd_next_to_clean); | ||
659 | |||
660 | if (netif_queue_stopped(adapter->netdev) | ||
661 | && netif_carrier_ok(adapter->netdev)) | ||
662 | netif_wake_queue(adapter->netdev); | ||
663 | } | ||
664 | 401 | ||
665 | static void atl1_check_for_link(struct atl1_adapter *adapter) | 402 | size = sizeof(struct atl1_buffer) * tpd_ring->count; |
666 | { | 403 | memset(tpd_ring->buffer_info, 0, size); |
667 | struct net_device *netdev = adapter->netdev; | ||
668 | u16 phy_data = 0; | ||
669 | |||
670 | spin_lock(&adapter->lock); | ||
671 | adapter->phy_timer_pending = false; | ||
672 | atl1_read_phy_reg(&adapter->hw, MII_BMSR, &phy_data); | ||
673 | atl1_read_phy_reg(&adapter->hw, MII_BMSR, &phy_data); | ||
674 | spin_unlock(&adapter->lock); | ||
675 | |||
676 | /* notify upper layer link down ASAP */ | ||
677 | if (!(phy_data & BMSR_LSTATUS)) { /* Link Down */ | ||
678 | if (netif_carrier_ok(netdev)) { /* old link state: Up */ | ||
679 | dev_info(&adapter->pdev->dev, "%s link is down\n", | ||
680 | netdev->name); | ||
681 | adapter->link_speed = SPEED_0; | ||
682 | netif_carrier_off(netdev); | ||
683 | netif_stop_queue(netdev); | ||
684 | } | ||
685 | } | ||
686 | schedule_work(&adapter->link_chg_task); | ||
687 | } | ||
688 | |||
689 | /* | ||
690 | * atl1_intr - Interrupt Handler | ||
691 | * @irq: interrupt number | ||
692 | * @data: pointer to a network interface device structure | ||
693 | * @pt_regs: CPU registers structure | ||
694 | */ | ||
695 | static irqreturn_t atl1_intr(int irq, void *data) | ||
696 | { | ||
697 | /*struct atl1_adapter *adapter = ((struct net_device *)data)->priv;*/ | ||
698 | struct atl1_adapter *adapter = netdev_priv(data); | ||
699 | u32 status; | ||
700 | u8 update_rx; | ||
701 | int max_ints = 10; | ||
702 | |||
703 | status = adapter->cmb.cmb->int_stats; | ||
704 | if (!status) | ||
705 | return IRQ_NONE; | ||
706 | |||
707 | update_rx = 0; | ||
708 | |||
709 | do { | ||
710 | /* clear CMB interrupt status at once */ | ||
711 | adapter->cmb.cmb->int_stats = 0; | ||
712 | |||
713 | if (status & ISR_GPHY) /* clear phy status */ | ||
714 | atl1_clear_phy_int(adapter); | ||
715 | |||
716 | /* clear ISR status, and Enable CMB DMA/Disable Interrupt */ | ||
717 | iowrite32(status | ISR_DIS_INT, adapter->hw.hw_addr + REG_ISR); | ||
718 | |||
719 | /* check if SMB intr */ | ||
720 | if (status & ISR_SMB) | ||
721 | atl1_inc_smb(adapter); | ||
722 | |||
723 | /* check if PCIE PHY Link down */ | ||
724 | if (status & ISR_PHY_LINKDOWN) { | ||
725 | dev_dbg(&adapter->pdev->dev, "pcie phy link down %x\n", | ||
726 | status); | ||
727 | if (netif_running(adapter->netdev)) { /* reset MAC */ | ||
728 | iowrite32(0, adapter->hw.hw_addr + REG_IMR); | ||
729 | schedule_work(&adapter->pcie_dma_to_rst_task); | ||
730 | return IRQ_HANDLED; | ||
731 | } | ||
732 | } | ||
733 | |||
734 | /* check if DMA read/write error ? */ | ||
735 | if (status & (ISR_DMAR_TO_RST | ISR_DMAW_TO_RST)) { | ||
736 | dev_dbg(&adapter->pdev->dev, | ||
737 | "pcie DMA r/w error (status = 0x%x)\n", | ||
738 | status); | ||
739 | iowrite32(0, adapter->hw.hw_addr + REG_IMR); | ||
740 | schedule_work(&adapter->pcie_dma_to_rst_task); | ||
741 | return IRQ_HANDLED; | ||
742 | } | ||
743 | |||
744 | /* link event */ | ||
745 | if (status & ISR_GPHY) { | ||
746 | adapter->soft_stats.tx_carrier_errors++; | ||
747 | atl1_check_for_link(adapter); | ||
748 | } | ||
749 | |||
750 | /* transmit event */ | ||
751 | if (status & ISR_CMB_TX) | ||
752 | atl1_intr_tx(adapter); | ||
753 | |||
754 | /* rx exception */ | ||
755 | if (unlikely(status & (ISR_RXF_OV | ISR_RFD_UNRUN | | ||
756 | ISR_RRD_OV | ISR_HOST_RFD_UNRUN | | ||
757 | ISR_HOST_RRD_OV | ISR_CMB_RX))) { | ||
758 | if (status & (ISR_RXF_OV | ISR_RFD_UNRUN | | ||
759 | ISR_RRD_OV | ISR_HOST_RFD_UNRUN | | ||
760 | ISR_HOST_RRD_OV)) | ||
761 | dev_dbg(&adapter->pdev->dev, | ||
762 | "rx exception, ISR = 0x%x\n", status); | ||
763 | atl1_intr_rx(adapter); | ||
764 | } | ||
765 | |||
766 | if (--max_ints < 0) | ||
767 | break; | ||
768 | 404 | ||
769 | } while ((status = adapter->cmb.cmb->int_stats)); | 405 | /* Zero out the descriptor ring */ |
406 | memset(tpd_ring->desc, 0, tpd_ring->size); | ||
770 | 407 | ||
771 | /* re-enable Interrupt */ | 408 | atomic_set(&tpd_ring->next_to_use, 0); |
772 | iowrite32(ISR_DIS_SMB | ISR_DIS_DMA, adapter->hw.hw_addr + REG_ISR); | 409 | atomic_set(&tpd_ring->next_to_clean, 0); |
773 | return IRQ_HANDLED; | ||
774 | } | 410 | } |
775 | 411 | ||
776 | /* | 412 | /* |
777 | * atl1_set_multi - Multicast and Promiscuous mode set | 413 | * atl1_free_ring_resources - Free Tx / RX descriptor Resources |
778 | * @netdev: network interface device structure | 414 | * @adapter: board private structure |
779 | * | 415 | * |
780 | * The set_multi entry point is called whenever the multicast address | 416 | * Free all transmit software resources |
781 | * list or the network interface flags are updated. This routine is | ||
782 | * responsible for configuring the hardware for proper multicast, | ||
783 | * promiscuous mode, and all-multi behavior. | ||
784 | */ | 417 | */ |
785 | static void atl1_set_multi(struct net_device *netdev) | 418 | void atl1_free_ring_resources(struct atl1_adapter *adapter) |
786 | { | 419 | { |
787 | struct atl1_adapter *adapter = netdev_priv(netdev); | 420 | struct pci_dev *pdev = adapter->pdev; |
788 | struct atl1_hw *hw = &adapter->hw; | 421 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; |
789 | struct dev_mc_list *mc_ptr; | 422 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; |
790 | u32 rctl; | 423 | struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring; |
791 | u32 hash_value; | 424 | struct atl1_ring_header *ring_header = &adapter->ring_header; |
792 | 425 | ||
793 | /* Check for Promiscuous and All Multicast modes */ | 426 | atl1_clean_tx_ring(adapter); |
794 | rctl = ioread32(hw->hw_addr + REG_MAC_CTRL); | 427 | atl1_clean_rx_ring(adapter); |
795 | if (netdev->flags & IFF_PROMISC) | ||
796 | rctl |= MAC_CTRL_PROMIS_EN; | ||
797 | else if (netdev->flags & IFF_ALLMULTI) { | ||
798 | rctl |= MAC_CTRL_MC_ALL_EN; | ||
799 | rctl &= ~MAC_CTRL_PROMIS_EN; | ||
800 | } else | ||
801 | rctl &= ~(MAC_CTRL_PROMIS_EN | MAC_CTRL_MC_ALL_EN); | ||
802 | 428 | ||
803 | iowrite32(rctl, hw->hw_addr + REG_MAC_CTRL); | 429 | kfree(tpd_ring->buffer_info); |
430 | pci_free_consistent(pdev, ring_header->size, ring_header->desc, | ||
431 | ring_header->dma); | ||
804 | 432 | ||
805 | /* clear the old settings from the multicast hash table */ | 433 | tpd_ring->buffer_info = NULL; |
806 | iowrite32(0, hw->hw_addr + REG_RX_HASH_TABLE); | 434 | tpd_ring->desc = NULL; |
807 | iowrite32(0, (hw->hw_addr + REG_RX_HASH_TABLE) + (1 << 2)); | 435 | tpd_ring->dma = 0; |
808 | 436 | ||
809 | /* compute mc addresses' hash value ,and put it into hash table */ | 437 | rfd_ring->buffer_info = NULL; |
810 | for (mc_ptr = netdev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) { | 438 | rfd_ring->desc = NULL; |
811 | hash_value = atl1_hash_mc_addr(hw, mc_ptr->dmi_addr); | 439 | rfd_ring->dma = 0; |
812 | atl1_hash_set(hw, hash_value); | 440 | |
813 | } | 441 | rrd_ring->desc = NULL; |
442 | rrd_ring->dma = 0; | ||
814 | } | 443 | } |
815 | 444 | ||
816 | static void atl1_setup_mac_ctrl(struct atl1_adapter *adapter) | 445 | static void atl1_setup_mac_ctrl(struct atl1_adapter *adapter) |
@@ -851,6 +480,31 @@ static void atl1_setup_mac_ctrl(struct atl1_adapter *adapter) | |||
851 | iowrite32(value, hw->hw_addr + REG_MAC_CTRL); | 480 | iowrite32(value, hw->hw_addr + REG_MAC_CTRL); |
852 | } | 481 | } |
853 | 482 | ||
483 | /* | ||
484 | * atl1_set_mac - Change the Ethernet Address of the NIC | ||
485 | * @netdev: network interface device structure | ||
486 | * @p: pointer to an address structure | ||
487 | * | ||
488 | * Returns 0 on success, negative on failure | ||
489 | */ | ||
490 | static int atl1_set_mac(struct net_device *netdev, void *p) | ||
491 | { | ||
492 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
493 | struct sockaddr *addr = p; | ||
494 | |||
495 | if (netif_running(netdev)) | ||
496 | return -EBUSY; | ||
497 | |||
498 | if (!is_valid_ether_addr(addr->sa_data)) | ||
499 | return -EADDRNOTAVAIL; | ||
500 | |||
501 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); | ||
502 | memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len); | ||
503 | |||
504 | atl1_set_mac_addr(&adapter->hw); | ||
505 | return 0; | ||
506 | } | ||
507 | |||
854 | static u32 atl1_check_link(struct atl1_adapter *adapter) | 508 | static u32 atl1_check_link(struct atl1_adapter *adapter) |
855 | { | 509 | { |
856 | struct atl1_hw *hw = &adapter->hw; | 510 | struct atl1_hw *hw = &adapter->hw; |
@@ -958,6 +612,103 @@ static u32 atl1_check_link(struct atl1_adapter *adapter) | |||
958 | return ATL1_SUCCESS; | 612 | return ATL1_SUCCESS; |
959 | } | 613 | } |
960 | 614 | ||
615 | static void atl1_check_for_link(struct atl1_adapter *adapter) | ||
616 | { | ||
617 | struct net_device *netdev = adapter->netdev; | ||
618 | u16 phy_data = 0; | ||
619 | |||
620 | spin_lock(&adapter->lock); | ||
621 | adapter->phy_timer_pending = false; | ||
622 | atl1_read_phy_reg(&adapter->hw, MII_BMSR, &phy_data); | ||
623 | atl1_read_phy_reg(&adapter->hw, MII_BMSR, &phy_data); | ||
624 | spin_unlock(&adapter->lock); | ||
625 | |||
626 | /* notify upper layer link down ASAP */ | ||
627 | if (!(phy_data & BMSR_LSTATUS)) { /* Link Down */ | ||
628 | if (netif_carrier_ok(netdev)) { /* old link state: Up */ | ||
629 | dev_info(&adapter->pdev->dev, "%s link is down\n", | ||
630 | netdev->name); | ||
631 | adapter->link_speed = SPEED_0; | ||
632 | netif_carrier_off(netdev); | ||
633 | netif_stop_queue(netdev); | ||
634 | } | ||
635 | } | ||
636 | schedule_work(&adapter->link_chg_task); | ||
637 | } | ||
638 | |||
639 | /* | ||
640 | * atl1_set_multi - Multicast and Promiscuous mode set | ||
641 | * @netdev: network interface device structure | ||
642 | * | ||
643 | * The set_multi entry point is called whenever the multicast address | ||
644 | * list or the network interface flags are updated. This routine is | ||
645 | * responsible for configuring the hardware for proper multicast, | ||
646 | * promiscuous mode, and all-multi behavior. | ||
647 | */ | ||
648 | static void atl1_set_multi(struct net_device *netdev) | ||
649 | { | ||
650 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
651 | struct atl1_hw *hw = &adapter->hw; | ||
652 | struct dev_mc_list *mc_ptr; | ||
653 | u32 rctl; | ||
654 | u32 hash_value; | ||
655 | |||
656 | /* Check for Promiscuous and All Multicast modes */ | ||
657 | rctl = ioread32(hw->hw_addr + REG_MAC_CTRL); | ||
658 | if (netdev->flags & IFF_PROMISC) | ||
659 | rctl |= MAC_CTRL_PROMIS_EN; | ||
660 | else if (netdev->flags & IFF_ALLMULTI) { | ||
661 | rctl |= MAC_CTRL_MC_ALL_EN; | ||
662 | rctl &= ~MAC_CTRL_PROMIS_EN; | ||
663 | } else | ||
664 | rctl &= ~(MAC_CTRL_PROMIS_EN | MAC_CTRL_MC_ALL_EN); | ||
665 | |||
666 | iowrite32(rctl, hw->hw_addr + REG_MAC_CTRL); | ||
667 | |||
668 | /* clear the old settings from the multicast hash table */ | ||
669 | iowrite32(0, hw->hw_addr + REG_RX_HASH_TABLE); | ||
670 | iowrite32(0, (hw->hw_addr + REG_RX_HASH_TABLE) + (1 << 2)); | ||
671 | |||
672 | /* compute mc addresses' hash value ,and put it into hash table */ | ||
673 | for (mc_ptr = netdev->mc_list; mc_ptr; mc_ptr = mc_ptr->next) { | ||
674 | hash_value = atl1_hash_mc_addr(hw, mc_ptr->dmi_addr); | ||
675 | atl1_hash_set(hw, hash_value); | ||
676 | } | ||
677 | } | ||
678 | |||
679 | /* | ||
680 | * atl1_change_mtu - Change the Maximum Transfer Unit | ||
681 | * @netdev: network interface device structure | ||
682 | * @new_mtu: new value for maximum frame size | ||
683 | * | ||
684 | * Returns 0 on success, negative on failure | ||
685 | */ | ||
686 | static int atl1_change_mtu(struct net_device *netdev, int new_mtu) | ||
687 | { | ||
688 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
689 | int old_mtu = netdev->mtu; | ||
690 | int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; | ||
691 | |||
692 | if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) || | ||
693 | (max_frame > MAX_JUMBO_FRAME_SIZE)) { | ||
694 | dev_warn(&adapter->pdev->dev, "invalid MTU setting\n"); | ||
695 | return -EINVAL; | ||
696 | } | ||
697 | |||
698 | adapter->hw.max_frame_size = max_frame; | ||
699 | adapter->hw.tx_jumbo_task_th = (max_frame + 7) >> 3; | ||
700 | adapter->rx_buffer_len = (max_frame + 7) & ~7; | ||
701 | adapter->hw.rx_jumbo_th = adapter->rx_buffer_len / 8; | ||
702 | |||
703 | netdev->mtu = new_mtu; | ||
704 | if ((old_mtu != new_mtu) && netif_running(netdev)) { | ||
705 | atl1_down(adapter); | ||
706 | atl1_up(adapter); | ||
707 | } | ||
708 | |||
709 | return 0; | ||
710 | } | ||
711 | |||
961 | static void set_flow_ctrl_old(struct atl1_adapter *adapter) | 712 | static void set_flow_ctrl_old(struct atl1_adapter *adapter) |
962 | { | 713 | { |
963 | u32 hi, lo, value; | 714 | u32 hi, lo, value; |
@@ -970,7 +721,7 @@ static void set_flow_ctrl_old(struct atl1_adapter *adapter) | |||
970 | lo = value * 7 / 8; | 721 | lo = value * 7 / 8; |
971 | 722 | ||
972 | value = ((hi & RXQ_RXF_PAUSE_TH_HI_MASK) << RXQ_RXF_PAUSE_TH_HI_SHIFT) | | 723 | value = ((hi & RXQ_RXF_PAUSE_TH_HI_MASK) << RXQ_RXF_PAUSE_TH_HI_SHIFT) | |
973 | ((lo & RXQ_RXF_PAUSE_TH_LO_MASK) << RXQ_RXF_PAUSE_TH_LO_SHIFT); | 724 | ((lo & RXQ_RXF_PAUSE_TH_LO_MASK) << RXQ_RXF_PAUSE_TH_LO_SHIFT); |
974 | iowrite32(value, adapter->hw.hw_addr + REG_RXQ_RXF_PAUSE_THRESH); | 725 | iowrite32(value, adapter->hw.hw_addr + REG_RXQ_RXF_PAUSE_THRESH); |
975 | 726 | ||
976 | /* RRD Flow Control */ | 727 | /* RRD Flow Control */ |
@@ -980,7 +731,7 @@ static void set_flow_ctrl_old(struct atl1_adapter *adapter) | |||
980 | if (lo < 2) | 731 | if (lo < 2) |
981 | lo = 2; | 732 | lo = 2; |
982 | value = ((hi & RXQ_RRD_PAUSE_TH_HI_MASK) << RXQ_RRD_PAUSE_TH_HI_SHIFT) | | 733 | value = ((hi & RXQ_RRD_PAUSE_TH_HI_MASK) << RXQ_RRD_PAUSE_TH_HI_SHIFT) | |
983 | ((lo & RXQ_RRD_PAUSE_TH_LO_MASK) << RXQ_RRD_PAUSE_TH_LO_SHIFT); | 734 | ((lo & RXQ_RRD_PAUSE_TH_LO_MASK) << RXQ_RRD_PAUSE_TH_LO_SHIFT); |
984 | iowrite32(value, adapter->hw.hw_addr + REG_RXQ_RRD_PAUSE_THRESH); | 735 | iowrite32(value, adapter->hw.hw_addr + REG_RXQ_RRD_PAUSE_THRESH); |
985 | } | 736 | } |
986 | 737 | ||
@@ -997,7 +748,7 @@ static void set_flow_ctrl_new(struct atl1_hw *hw) | |||
997 | if (hi < lo) | 748 | if (hi < lo) |
998 | hi = lo + 16; | 749 | hi = lo + 16; |
999 | value = ((hi & RXQ_RXF_PAUSE_TH_HI_MASK) << RXQ_RXF_PAUSE_TH_HI_SHIFT) | | 750 | value = ((hi & RXQ_RXF_PAUSE_TH_HI_MASK) << RXQ_RXF_PAUSE_TH_HI_SHIFT) | |
1000 | ((lo & RXQ_RXF_PAUSE_TH_LO_MASK) << RXQ_RXF_PAUSE_TH_LO_SHIFT); | 751 | ((lo & RXQ_RXF_PAUSE_TH_LO_MASK) << RXQ_RXF_PAUSE_TH_LO_SHIFT); |
1001 | iowrite32(value, hw->hw_addr + REG_RXQ_RXF_PAUSE_THRESH); | 752 | iowrite32(value, hw->hw_addr + REG_RXQ_RXF_PAUSE_THRESH); |
1002 | 753 | ||
1003 | /* RRD Flow Control */ | 754 | /* RRD Flow Control */ |
@@ -1009,7 +760,7 @@ static void set_flow_ctrl_new(struct atl1_hw *hw) | |||
1009 | if (hi < lo) | 760 | if (hi < lo) |
1010 | hi = lo + 3; | 761 | hi = lo + 3; |
1011 | value = ((hi & RXQ_RRD_PAUSE_TH_HI_MASK) << RXQ_RRD_PAUSE_TH_HI_SHIFT) | | 762 | value = ((hi & RXQ_RRD_PAUSE_TH_HI_MASK) << RXQ_RRD_PAUSE_TH_HI_SHIFT) | |
1012 | ((lo & RXQ_RRD_PAUSE_TH_LO_MASK) << RXQ_RRD_PAUSE_TH_LO_SHIFT); | 763 | ((lo & RXQ_RRD_PAUSE_TH_LO_MASK) << RXQ_RRD_PAUSE_TH_LO_SHIFT); |
1013 | iowrite32(value, hw->hw_addr + REG_RXQ_RRD_PAUSE_THRESH); | 764 | iowrite32(value, hw->hw_addr + REG_RXQ_RRD_PAUSE_THRESH); |
1014 | } | 765 | } |
1015 | 766 | ||
@@ -1058,7 +809,8 @@ static u32 atl1_configure(struct atl1_adapter *adapter) | |||
1058 | value <<= 16; | 809 | value <<= 16; |
1059 | value += adapter->rfd_ring.count; | 810 | value += adapter->rfd_ring.count; |
1060 | iowrite32(value, hw->hw_addr + REG_DESC_RFD_RRD_RING_SIZE); | 811 | iowrite32(value, hw->hw_addr + REG_DESC_RFD_RRD_RING_SIZE); |
1061 | iowrite32(adapter->tpd_ring.count, hw->hw_addr + REG_DESC_TPD_RING_SIZE); | 812 | iowrite32(adapter->tpd_ring.count, hw->hw_addr + |
813 | REG_DESC_TPD_RING_SIZE); | ||
1062 | 814 | ||
1063 | /* Load Ptr */ | 815 | /* Load Ptr */ |
1064 | iowrite32(1, hw->hw_addr + REG_LOAD_PTR); | 816 | iowrite32(1, hw->hw_addr + REG_LOAD_PTR); |
@@ -1066,31 +818,31 @@ static u32 atl1_configure(struct atl1_adapter *adapter) | |||
1066 | /* config Mailbox */ | 818 | /* config Mailbox */ |
1067 | value = ((atomic_read(&adapter->tpd_ring.next_to_use) | 819 | value = ((atomic_read(&adapter->tpd_ring.next_to_use) |
1068 | & MB_TPD_PROD_INDX_MASK) << MB_TPD_PROD_INDX_SHIFT) | | 820 | & MB_TPD_PROD_INDX_MASK) << MB_TPD_PROD_INDX_SHIFT) | |
1069 | ((atomic_read(&adapter->rrd_ring.next_to_clean) | 821 | ((atomic_read(&adapter->rrd_ring.next_to_clean) |
1070 | & MB_RRD_CONS_INDX_MASK) << MB_RRD_CONS_INDX_SHIFT) | | 822 | & MB_RRD_CONS_INDX_MASK) << MB_RRD_CONS_INDX_SHIFT) | |
1071 | ((atomic_read(&adapter->rfd_ring.next_to_use) | 823 | ((atomic_read(&adapter->rfd_ring.next_to_use) |
1072 | & MB_RFD_PROD_INDX_MASK) << MB_RFD_PROD_INDX_SHIFT); | 824 | & MB_RFD_PROD_INDX_MASK) << MB_RFD_PROD_INDX_SHIFT); |
1073 | iowrite32(value, hw->hw_addr + REG_MAILBOX); | 825 | iowrite32(value, hw->hw_addr + REG_MAILBOX); |
1074 | 826 | ||
1075 | /* config IPG/IFG */ | 827 | /* config IPG/IFG */ |
1076 | value = (((u32) hw->ipgt & MAC_IPG_IFG_IPGT_MASK) | 828 | value = (((u32) hw->ipgt & MAC_IPG_IFG_IPGT_MASK) |
1077 | << MAC_IPG_IFG_IPGT_SHIFT) | | 829 | << MAC_IPG_IFG_IPGT_SHIFT) | |
1078 | (((u32) hw->min_ifg & MAC_IPG_IFG_MIFG_MASK) | 830 | (((u32) hw->min_ifg & MAC_IPG_IFG_MIFG_MASK) |
1079 | << MAC_IPG_IFG_MIFG_SHIFT) | | 831 | << MAC_IPG_IFG_MIFG_SHIFT) | |
1080 | (((u32) hw->ipgr1 & MAC_IPG_IFG_IPGR1_MASK) | 832 | (((u32) hw->ipgr1 & MAC_IPG_IFG_IPGR1_MASK) |
1081 | << MAC_IPG_IFG_IPGR1_SHIFT) | | 833 | << MAC_IPG_IFG_IPGR1_SHIFT) | |
1082 | (((u32) hw->ipgr2 & MAC_IPG_IFG_IPGR2_MASK) | 834 | (((u32) hw->ipgr2 & MAC_IPG_IFG_IPGR2_MASK) |
1083 | << MAC_IPG_IFG_IPGR2_SHIFT); | 835 | << MAC_IPG_IFG_IPGR2_SHIFT); |
1084 | iowrite32(value, hw->hw_addr + REG_MAC_IPG_IFG); | 836 | iowrite32(value, hw->hw_addr + REG_MAC_IPG_IFG); |
1085 | 837 | ||
1086 | /* config Half-Duplex Control */ | 838 | /* config Half-Duplex Control */ |
1087 | value = ((u32) hw->lcol & MAC_HALF_DUPLX_CTRL_LCOL_MASK) | | 839 | value = ((u32) hw->lcol & MAC_HALF_DUPLX_CTRL_LCOL_MASK) | |
1088 | (((u32) hw->max_retry & MAC_HALF_DUPLX_CTRL_RETRY_MASK) | 840 | (((u32) hw->max_retry & MAC_HALF_DUPLX_CTRL_RETRY_MASK) |
1089 | << MAC_HALF_DUPLX_CTRL_RETRY_SHIFT) | | 841 | << MAC_HALF_DUPLX_CTRL_RETRY_SHIFT) | |
1090 | MAC_HALF_DUPLX_CTRL_EXC_DEF_EN | | 842 | MAC_HALF_DUPLX_CTRL_EXC_DEF_EN | |
1091 | (0xa << MAC_HALF_DUPLX_CTRL_ABEBT_SHIFT) | | 843 | (0xa << MAC_HALF_DUPLX_CTRL_ABEBT_SHIFT) | |
1092 | (((u32) hw->jam_ipg & MAC_HALF_DUPLX_CTRL_JAMIPG_MASK) | 844 | (((u32) hw->jam_ipg & MAC_HALF_DUPLX_CTRL_JAMIPG_MASK) |
1093 | << MAC_HALF_DUPLX_CTRL_JAMIPG_SHIFT); | 845 | << MAC_HALF_DUPLX_CTRL_JAMIPG_SHIFT); |
1094 | iowrite32(value, hw->hw_addr + REG_MAC_HALF_DUPLX_CTRL); | 846 | iowrite32(value, hw->hw_addr + REG_MAC_HALF_DUPLX_CTRL); |
1095 | 847 | ||
1096 | /* set Interrupt Moderator Timer */ | 848 | /* set Interrupt Moderator Timer */ |
@@ -1106,10 +858,10 @@ static u32 atl1_configure(struct atl1_adapter *adapter) | |||
1106 | /* jumbo size & rrd retirement timer */ | 858 | /* jumbo size & rrd retirement timer */ |
1107 | value = (((u32) hw->rx_jumbo_th & RXQ_JMBOSZ_TH_MASK) | 859 | value = (((u32) hw->rx_jumbo_th & RXQ_JMBOSZ_TH_MASK) |
1108 | << RXQ_JMBOSZ_TH_SHIFT) | | 860 | << RXQ_JMBOSZ_TH_SHIFT) | |
1109 | (((u32) hw->rx_jumbo_lkah & RXQ_JMBO_LKAH_MASK) | 861 | (((u32) hw->rx_jumbo_lkah & RXQ_JMBO_LKAH_MASK) |
1110 | << RXQ_JMBO_LKAH_SHIFT) | | 862 | << RXQ_JMBO_LKAH_SHIFT) | |
1111 | (((u32) hw->rrd_ret_timer & RXQ_RRD_TIMER_MASK) | 863 | (((u32) hw->rrd_ret_timer & RXQ_RRD_TIMER_MASK) |
1112 | << RXQ_RRD_TIMER_SHIFT); | 864 | << RXQ_RRD_TIMER_SHIFT); |
1113 | iowrite32(value, hw->hw_addr + REG_RXQ_JMBOSZ_RRDTIM); | 865 | iowrite32(value, hw->hw_addr + REG_RXQ_JMBOSZ_RRDTIM); |
1114 | 866 | ||
1115 | /* Flow Control */ | 867 | /* Flow Control */ |
@@ -1128,35 +880,36 @@ static u32 atl1_configure(struct atl1_adapter *adapter) | |||
1128 | /* config TXQ */ | 880 | /* config TXQ */ |
1129 | value = (((u32) hw->tpd_burst & TXQ_CTRL_TPD_BURST_NUM_MASK) | 881 | value = (((u32) hw->tpd_burst & TXQ_CTRL_TPD_BURST_NUM_MASK) |
1130 | << TXQ_CTRL_TPD_BURST_NUM_SHIFT) | | 882 | << TXQ_CTRL_TPD_BURST_NUM_SHIFT) | |
1131 | (((u32) hw->txf_burst & TXQ_CTRL_TXF_BURST_NUM_MASK) | 883 | (((u32) hw->txf_burst & TXQ_CTRL_TXF_BURST_NUM_MASK) |
1132 | << TXQ_CTRL_TXF_BURST_NUM_SHIFT) | | 884 | << TXQ_CTRL_TXF_BURST_NUM_SHIFT) | |
1133 | (((u32) hw->tpd_fetch_th & TXQ_CTRL_TPD_FETCH_TH_MASK) | 885 | (((u32) hw->tpd_fetch_th & TXQ_CTRL_TPD_FETCH_TH_MASK) |
1134 | << TXQ_CTRL_TPD_FETCH_TH_SHIFT) | TXQ_CTRL_ENH_MODE | TXQ_CTRL_EN; | 886 | << TXQ_CTRL_TPD_FETCH_TH_SHIFT) | TXQ_CTRL_ENH_MODE | |
887 | TXQ_CTRL_EN; | ||
1135 | iowrite32(value, hw->hw_addr + REG_TXQ_CTRL); | 888 | iowrite32(value, hw->hw_addr + REG_TXQ_CTRL); |
1136 | 889 | ||
1137 | /* min tpd fetch gap & tx jumbo packet size threshold for taskoffload */ | 890 | /* min tpd fetch gap & tx jumbo packet size threshold for taskoffload */ |
1138 | value = (((u32) hw->tx_jumbo_task_th & TX_JUMBO_TASK_TH_MASK) | 891 | value = (((u32) hw->tx_jumbo_task_th & TX_JUMBO_TASK_TH_MASK) |
1139 | << TX_JUMBO_TASK_TH_SHIFT) | | 892 | << TX_JUMBO_TASK_TH_SHIFT) | |
1140 | (((u32) hw->tpd_fetch_gap & TX_TPD_MIN_IPG_MASK) | 893 | (((u32) hw->tpd_fetch_gap & TX_TPD_MIN_IPG_MASK) |
1141 | << TX_TPD_MIN_IPG_SHIFT); | 894 | << TX_TPD_MIN_IPG_SHIFT); |
1142 | iowrite32(value, hw->hw_addr + REG_TX_JUMBO_TASK_TH_TPD_IPG); | 895 | iowrite32(value, hw->hw_addr + REG_TX_JUMBO_TASK_TH_TPD_IPG); |
1143 | 896 | ||
1144 | /* config RXQ */ | 897 | /* config RXQ */ |
1145 | value = (((u32) hw->rfd_burst & RXQ_CTRL_RFD_BURST_NUM_MASK) | 898 | value = (((u32) hw->rfd_burst & RXQ_CTRL_RFD_BURST_NUM_MASK) |
1146 | << RXQ_CTRL_RFD_BURST_NUM_SHIFT) | | 899 | << RXQ_CTRL_RFD_BURST_NUM_SHIFT) | |
1147 | (((u32) hw->rrd_burst & RXQ_CTRL_RRD_BURST_THRESH_MASK) | 900 | (((u32) hw->rrd_burst & RXQ_CTRL_RRD_BURST_THRESH_MASK) |
1148 | << RXQ_CTRL_RRD_BURST_THRESH_SHIFT) | | 901 | << RXQ_CTRL_RRD_BURST_THRESH_SHIFT) | |
1149 | (((u32) hw->rfd_fetch_gap & RXQ_CTRL_RFD_PREF_MIN_IPG_MASK) | 902 | (((u32) hw->rfd_fetch_gap & RXQ_CTRL_RFD_PREF_MIN_IPG_MASK) |
1150 | << RXQ_CTRL_RFD_PREF_MIN_IPG_SHIFT) | | 903 | << RXQ_CTRL_RFD_PREF_MIN_IPG_SHIFT) | RXQ_CTRL_CUT_THRU_EN | |
1151 | RXQ_CTRL_CUT_THRU_EN | RXQ_CTRL_EN; | 904 | RXQ_CTRL_EN; |
1152 | iowrite32(value, hw->hw_addr + REG_RXQ_CTRL); | 905 | iowrite32(value, hw->hw_addr + REG_RXQ_CTRL); |
1153 | 906 | ||
1154 | /* config DMA Engine */ | 907 | /* config DMA Engine */ |
1155 | value = ((((u32) hw->dmar_block) & DMA_CTRL_DMAR_BURST_LEN_MASK) | 908 | value = ((((u32) hw->dmar_block) & DMA_CTRL_DMAR_BURST_LEN_MASK) |
1156 | << DMA_CTRL_DMAR_BURST_LEN_SHIFT) | | 909 | << DMA_CTRL_DMAR_BURST_LEN_SHIFT) | |
1157 | ((((u32) hw->dmaw_block) & DMA_CTRL_DMAR_BURST_LEN_MASK) | 910 | ((((u32) hw->dmaw_block) & DMA_CTRL_DMAR_BURST_LEN_MASK) |
1158 | << DMA_CTRL_DMAR_BURST_LEN_SHIFT) | | 911 | << DMA_CTRL_DMAR_BURST_LEN_SHIFT) | DMA_CTRL_DMAR_EN | |
1159 | DMA_CTRL_DMAR_EN | DMA_CTRL_DMAW_EN; | 912 | DMA_CTRL_DMAW_EN; |
1160 | value |= (u32) hw->dma_ord; | 913 | value |= (u32) hw->dma_ord; |
1161 | if (atl1_rcb_128 == hw->rcb_value) | 914 | if (atl1_rcb_128 == hw->rcb_value) |
1162 | value |= DMA_CTRL_RCB_VALUE; | 915 | value |= DMA_CTRL_RCB_VALUE; |
@@ -1186,56 +939,495 @@ static u32 atl1_configure(struct atl1_adapter *adapter) | |||
1186 | } | 939 | } |
1187 | 940 | ||
1188 | /* | 941 | /* |
942 | * atl1_pcie_patch - Patch for PCIE module | ||
943 | */ | ||
944 | static void atl1_pcie_patch(struct atl1_adapter *adapter) | ||
945 | { | ||
946 | u32 value; | ||
947 | |||
948 | /* much vendor magic here */ | ||
949 | value = 0x6500; | ||
950 | iowrite32(value, adapter->hw.hw_addr + 0x12FC); | ||
951 | /* pcie flow control mode change */ | ||
952 | value = ioread32(adapter->hw.hw_addr + 0x1008); | ||
953 | value |= 0x8000; | ||
954 | iowrite32(value, adapter->hw.hw_addr + 0x1008); | ||
955 | } | ||
956 | |||
957 | /* | ||
958 | * When ACPI resume on some VIA MotherBoard, the Interrupt Disable bit/0x400 | ||
959 | * on PCI Command register is disable. | ||
960 | * The function enable this bit. | ||
961 | * Brackett, 2006/03/15 | ||
962 | */ | ||
963 | static void atl1_via_workaround(struct atl1_adapter *adapter) | ||
964 | { | ||
965 | unsigned long value; | ||
966 | |||
967 | value = ioread16(adapter->hw.hw_addr + PCI_COMMAND); | ||
968 | if (value & PCI_COMMAND_INTX_DISABLE) | ||
969 | value &= ~PCI_COMMAND_INTX_DISABLE; | ||
970 | iowrite32(value, adapter->hw.hw_addr + PCI_COMMAND); | ||
971 | } | ||
972 | |||
973 | /* | ||
974 | * atl1_irq_enable - Enable default interrupt generation settings | ||
975 | * @adapter: board private structure | ||
976 | */ | ||
977 | static void atl1_irq_enable(struct atl1_adapter *adapter) | ||
978 | { | ||
979 | iowrite32(IMR_NORMAL_MASK, adapter->hw.hw_addr + REG_IMR); | ||
980 | ioread32(adapter->hw.hw_addr + REG_IMR); | ||
981 | } | ||
982 | |||
983 | /* | ||
1189 | * atl1_irq_disable - Mask off interrupt generation on the NIC | 984 | * atl1_irq_disable - Mask off interrupt generation on the NIC |
1190 | * @adapter: board private structure | 985 | * @adapter: board private structure |
1191 | */ | 986 | */ |
1192 | static void atl1_irq_disable(struct atl1_adapter *adapter) | 987 | static void atl1_irq_disable(struct atl1_adapter *adapter) |
1193 | { | 988 | { |
1194 | atomic_inc(&adapter->irq_sem); | ||
1195 | iowrite32(0, adapter->hw.hw_addr + REG_IMR); | 989 | iowrite32(0, adapter->hw.hw_addr + REG_IMR); |
1196 | ioread32(adapter->hw.hw_addr + REG_IMR); | 990 | ioread32(adapter->hw.hw_addr + REG_IMR); |
1197 | synchronize_irq(adapter->pdev->irq); | 991 | synchronize_irq(adapter->pdev->irq); |
1198 | } | 992 | } |
1199 | 993 | ||
1200 | static void atl1_vlan_rx_register(struct net_device *netdev, | 994 | static void atl1_clear_phy_int(struct atl1_adapter *adapter) |
1201 | struct vlan_group *grp) | ||
1202 | { | 995 | { |
1203 | struct atl1_adapter *adapter = netdev_priv(netdev); | 996 | u16 phy_data; |
1204 | unsigned long flags; | 997 | unsigned long flags; |
1205 | u32 ctrl; | ||
1206 | 998 | ||
1207 | spin_lock_irqsave(&adapter->lock, flags); | 999 | spin_lock_irqsave(&adapter->lock, flags); |
1208 | /* atl1_irq_disable(adapter); */ | 1000 | atl1_read_phy_reg(&adapter->hw, 19, &phy_data); |
1209 | adapter->vlgrp = grp; | 1001 | spin_unlock_irqrestore(&adapter->lock, flags); |
1002 | } | ||
1210 | 1003 | ||
1211 | if (grp) { | 1004 | static void atl1_inc_smb(struct atl1_adapter *adapter) |
1212 | /* enable VLAN tag insert/strip */ | 1005 | { |
1213 | ctrl = ioread32(adapter->hw.hw_addr + REG_MAC_CTRL); | 1006 | struct stats_msg_block *smb = adapter->smb.smb; |
1214 | ctrl |= MAC_CTRL_RMV_VLAN; | 1007 | |
1215 | iowrite32(ctrl, adapter->hw.hw_addr + REG_MAC_CTRL); | 1008 | /* Fill out the OS statistics structure */ |
1216 | } else { | 1009 | adapter->soft_stats.rx_packets += smb->rx_ok; |
1217 | /* disable VLAN tag insert/strip */ | 1010 | adapter->soft_stats.tx_packets += smb->tx_ok; |
1218 | ctrl = ioread32(adapter->hw.hw_addr + REG_MAC_CTRL); | 1011 | adapter->soft_stats.rx_bytes += smb->rx_byte_cnt; |
1219 | ctrl &= ~MAC_CTRL_RMV_VLAN; | 1012 | adapter->soft_stats.tx_bytes += smb->tx_byte_cnt; |
1220 | iowrite32(ctrl, adapter->hw.hw_addr + REG_MAC_CTRL); | 1013 | adapter->soft_stats.multicast += smb->rx_mcast; |
1014 | adapter->soft_stats.collisions += (smb->tx_1_col + smb->tx_2_col * 2 + | ||
1015 | smb->tx_late_col + smb->tx_abort_col * adapter->hw.max_retry); | ||
1016 | |||
1017 | /* Rx Errors */ | ||
1018 | adapter->soft_stats.rx_errors += (smb->rx_frag + smb->rx_fcs_err + | ||
1019 | smb->rx_len_err + smb->rx_sz_ov + smb->rx_rxf_ov + | ||
1020 | smb->rx_rrd_ov + smb->rx_align_err); | ||
1021 | adapter->soft_stats.rx_fifo_errors += smb->rx_rxf_ov; | ||
1022 | adapter->soft_stats.rx_length_errors += smb->rx_len_err; | ||
1023 | adapter->soft_stats.rx_crc_errors += smb->rx_fcs_err; | ||
1024 | adapter->soft_stats.rx_frame_errors += smb->rx_align_err; | ||
1025 | adapter->soft_stats.rx_missed_errors += (smb->rx_rrd_ov + | ||
1026 | smb->rx_rxf_ov); | ||
1027 | |||
1028 | adapter->soft_stats.rx_pause += smb->rx_pause; | ||
1029 | adapter->soft_stats.rx_rrd_ov += smb->rx_rrd_ov; | ||
1030 | adapter->soft_stats.rx_trunc += smb->rx_sz_ov; | ||
1031 | |||
1032 | /* Tx Errors */ | ||
1033 | adapter->soft_stats.tx_errors += (smb->tx_late_col + | ||
1034 | smb->tx_abort_col + smb->tx_underrun + smb->tx_trunc); | ||
1035 | adapter->soft_stats.tx_fifo_errors += smb->tx_underrun; | ||
1036 | adapter->soft_stats.tx_aborted_errors += smb->tx_abort_col; | ||
1037 | adapter->soft_stats.tx_window_errors += smb->tx_late_col; | ||
1038 | |||
1039 | adapter->soft_stats.excecol += smb->tx_abort_col; | ||
1040 | adapter->soft_stats.deffer += smb->tx_defer; | ||
1041 | adapter->soft_stats.scc += smb->tx_1_col; | ||
1042 | adapter->soft_stats.mcc += smb->tx_2_col; | ||
1043 | adapter->soft_stats.latecol += smb->tx_late_col; | ||
1044 | adapter->soft_stats.tx_underun += smb->tx_underrun; | ||
1045 | adapter->soft_stats.tx_trunc += smb->tx_trunc; | ||
1046 | adapter->soft_stats.tx_pause += smb->tx_pause; | ||
1047 | |||
1048 | adapter->net_stats.rx_packets = adapter->soft_stats.rx_packets; | ||
1049 | adapter->net_stats.tx_packets = adapter->soft_stats.tx_packets; | ||
1050 | adapter->net_stats.rx_bytes = adapter->soft_stats.rx_bytes; | ||
1051 | adapter->net_stats.tx_bytes = adapter->soft_stats.tx_bytes; | ||
1052 | adapter->net_stats.multicast = adapter->soft_stats.multicast; | ||
1053 | adapter->net_stats.collisions = adapter->soft_stats.collisions; | ||
1054 | adapter->net_stats.rx_errors = adapter->soft_stats.rx_errors; | ||
1055 | adapter->net_stats.rx_over_errors = | ||
1056 | adapter->soft_stats.rx_missed_errors; | ||
1057 | adapter->net_stats.rx_length_errors = | ||
1058 | adapter->soft_stats.rx_length_errors; | ||
1059 | adapter->net_stats.rx_crc_errors = adapter->soft_stats.rx_crc_errors; | ||
1060 | adapter->net_stats.rx_frame_errors = | ||
1061 | adapter->soft_stats.rx_frame_errors; | ||
1062 | adapter->net_stats.rx_fifo_errors = adapter->soft_stats.rx_fifo_errors; | ||
1063 | adapter->net_stats.rx_missed_errors = | ||
1064 | adapter->soft_stats.rx_missed_errors; | ||
1065 | adapter->net_stats.tx_errors = adapter->soft_stats.tx_errors; | ||
1066 | adapter->net_stats.tx_fifo_errors = adapter->soft_stats.tx_fifo_errors; | ||
1067 | adapter->net_stats.tx_aborted_errors = | ||
1068 | adapter->soft_stats.tx_aborted_errors; | ||
1069 | adapter->net_stats.tx_window_errors = | ||
1070 | adapter->soft_stats.tx_window_errors; | ||
1071 | adapter->net_stats.tx_carrier_errors = | ||
1072 | adapter->soft_stats.tx_carrier_errors; | ||
1073 | } | ||
1074 | |||
1075 | /* | ||
1076 | * atl1_get_stats - Get System Network Statistics | ||
1077 | * @netdev: network interface device structure | ||
1078 | * | ||
1079 | * Returns the address of the device statistics structure. | ||
1080 | * The statistics are actually updated from the timer callback. | ||
1081 | */ | ||
1082 | static struct net_device_stats *atl1_get_stats(struct net_device *netdev) | ||
1083 | { | ||
1084 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
1085 | return &adapter->net_stats; | ||
1086 | } | ||
1087 | |||
1088 | static void atl1_update_mailbox(struct atl1_adapter *adapter) | ||
1089 | { | ||
1090 | unsigned long flags; | ||
1091 | u32 tpd_next_to_use; | ||
1092 | u32 rfd_next_to_use; | ||
1093 | u32 rrd_next_to_clean; | ||
1094 | u32 value; | ||
1095 | |||
1096 | spin_lock_irqsave(&adapter->mb_lock, flags); | ||
1097 | |||
1098 | tpd_next_to_use = atomic_read(&adapter->tpd_ring.next_to_use); | ||
1099 | rfd_next_to_use = atomic_read(&adapter->rfd_ring.next_to_use); | ||
1100 | rrd_next_to_clean = atomic_read(&adapter->rrd_ring.next_to_clean); | ||
1101 | |||
1102 | value = ((rfd_next_to_use & MB_RFD_PROD_INDX_MASK) << | ||
1103 | MB_RFD_PROD_INDX_SHIFT) | | ||
1104 | ((rrd_next_to_clean & MB_RRD_CONS_INDX_MASK) << | ||
1105 | MB_RRD_CONS_INDX_SHIFT) | | ||
1106 | ((tpd_next_to_use & MB_TPD_PROD_INDX_MASK) << | ||
1107 | MB_TPD_PROD_INDX_SHIFT); | ||
1108 | iowrite32(value, adapter->hw.hw_addr + REG_MAILBOX); | ||
1109 | |||
1110 | spin_unlock_irqrestore(&adapter->mb_lock, flags); | ||
1111 | } | ||
1112 | |||
1113 | static void atl1_clean_alloc_flag(struct atl1_adapter *adapter, | ||
1114 | struct rx_return_desc *rrd, u16 offset) | ||
1115 | { | ||
1116 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | ||
1117 | |||
1118 | while (rfd_ring->next_to_clean != (rrd->buf_indx + offset)) { | ||
1119 | rfd_ring->buffer_info[rfd_ring->next_to_clean].alloced = 0; | ||
1120 | if (++rfd_ring->next_to_clean == rfd_ring->count) { | ||
1121 | rfd_ring->next_to_clean = 0; | ||
1122 | } | ||
1221 | } | 1123 | } |
1124 | } | ||
1222 | 1125 | ||
1223 | /* atl1_irq_enable(adapter); */ | 1126 | static void atl1_update_rfd_index(struct atl1_adapter *adapter, |
1224 | spin_unlock_irqrestore(&adapter->lock, flags); | 1127 | struct rx_return_desc *rrd) |
1128 | { | ||
1129 | u16 num_buf; | ||
1130 | |||
1131 | num_buf = (rrd->xsz.xsum_sz.pkt_size + adapter->rx_buffer_len - 1) / | ||
1132 | adapter->rx_buffer_len; | ||
1133 | if (rrd->num_buf == num_buf) | ||
1134 | /* clean alloc flag for bad rrd */ | ||
1135 | atl1_clean_alloc_flag(adapter, rrd, num_buf); | ||
1225 | } | 1136 | } |
1226 | 1137 | ||
1227 | static void atl1_restore_vlan(struct atl1_adapter *adapter) | 1138 | static void atl1_rx_checksum(struct atl1_adapter *adapter, |
1139 | struct rx_return_desc *rrd, struct sk_buff *skb) | ||
1228 | { | 1140 | { |
1229 | atl1_vlan_rx_register(adapter->netdev, adapter->vlgrp); | 1141 | struct pci_dev *pdev = adapter->pdev; |
1142 | |||
1143 | skb->ip_summed = CHECKSUM_NONE; | ||
1144 | |||
1145 | if (unlikely(rrd->pkt_flg & PACKET_FLAG_ERR)) { | ||
1146 | if (rrd->err_flg & (ERR_FLAG_CRC | ERR_FLAG_TRUNC | | ||
1147 | ERR_FLAG_CODE | ERR_FLAG_OV)) { | ||
1148 | adapter->hw_csum_err++; | ||
1149 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
1150 | "rx checksum error\n"); | ||
1151 | return; | ||
1152 | } | ||
1153 | } | ||
1154 | |||
1155 | /* not IPv4 */ | ||
1156 | if (!(rrd->pkt_flg & PACKET_FLAG_IPV4)) | ||
1157 | /* checksum is invalid, but it's not an IPv4 pkt, so ok */ | ||
1158 | return; | ||
1159 | |||
1160 | /* IPv4 packet */ | ||
1161 | if (likely(!(rrd->err_flg & | ||
1162 | (ERR_FLAG_IP_CHKSUM | ERR_FLAG_L4_CHKSUM)))) { | ||
1163 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
1164 | adapter->hw_csum_good++; | ||
1165 | return; | ||
1166 | } | ||
1167 | |||
1168 | /* IPv4, but hardware thinks its checksum is wrong */ | ||
1169 | dev_printk(KERN_DEBUG, &pdev->dev, | ||
1170 | "hw csum wrong, pkt_flag:%x, err_flag:%x\n", | ||
1171 | rrd->pkt_flg, rrd->err_flg); | ||
1172 | skb->ip_summed = CHECKSUM_COMPLETE; | ||
1173 | skb->csum = htons(rrd->xsz.xsum_sz.rx_chksum); | ||
1174 | adapter->hw_csum_err++; | ||
1175 | return; | ||
1176 | } | ||
1177 | |||
1178 | /* | ||
1179 | * atl1_alloc_rx_buffers - Replace used receive buffers | ||
1180 | * @adapter: address of board private structure | ||
1181 | */ | ||
1182 | static u16 atl1_alloc_rx_buffers(struct atl1_adapter *adapter) | ||
1183 | { | ||
1184 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | ||
1185 | struct pci_dev *pdev = adapter->pdev; | ||
1186 | struct page *page; | ||
1187 | unsigned long offset; | ||
1188 | struct atl1_buffer *buffer_info, *next_info; | ||
1189 | struct sk_buff *skb; | ||
1190 | u16 num_alloc = 0; | ||
1191 | u16 rfd_next_to_use, next_next; | ||
1192 | struct rx_free_desc *rfd_desc; | ||
1193 | |||
1194 | next_next = rfd_next_to_use = atomic_read(&rfd_ring->next_to_use); | ||
1195 | if (++next_next == rfd_ring->count) | ||
1196 | next_next = 0; | ||
1197 | buffer_info = &rfd_ring->buffer_info[rfd_next_to_use]; | ||
1198 | next_info = &rfd_ring->buffer_info[next_next]; | ||
1199 | |||
1200 | while (!buffer_info->alloced && !next_info->alloced) { | ||
1201 | if (buffer_info->skb) { | ||
1202 | buffer_info->alloced = 1; | ||
1203 | goto next; | ||
1204 | } | ||
1205 | |||
1206 | rfd_desc = ATL1_RFD_DESC(rfd_ring, rfd_next_to_use); | ||
1207 | |||
1208 | skb = dev_alloc_skb(adapter->rx_buffer_len + NET_IP_ALIGN); | ||
1209 | if (unlikely(!skb)) { /* Better luck next round */ | ||
1210 | adapter->net_stats.rx_dropped++; | ||
1211 | break; | ||
1212 | } | ||
1213 | |||
1214 | /* | ||
1215 | * Make buffer alignment 2 beyond a 16 byte boundary | ||
1216 | * this will result in a 16 byte aligned IP header after | ||
1217 | * the 14 byte MAC header is removed | ||
1218 | */ | ||
1219 | skb_reserve(skb, NET_IP_ALIGN); | ||
1220 | |||
1221 | buffer_info->alloced = 1; | ||
1222 | buffer_info->skb = skb; | ||
1223 | buffer_info->length = (u16) adapter->rx_buffer_len; | ||
1224 | page = virt_to_page(skb->data); | ||
1225 | offset = (unsigned long)skb->data & ~PAGE_MASK; | ||
1226 | buffer_info->dma = pci_map_page(pdev, page, offset, | ||
1227 | adapter->rx_buffer_len, | ||
1228 | PCI_DMA_FROMDEVICE); | ||
1229 | rfd_desc->buffer_addr = cpu_to_le64(buffer_info->dma); | ||
1230 | rfd_desc->buf_len = cpu_to_le16(adapter->rx_buffer_len); | ||
1231 | rfd_desc->coalese = 0; | ||
1232 | |||
1233 | next: | ||
1234 | rfd_next_to_use = next_next; | ||
1235 | if (unlikely(++next_next == rfd_ring->count)) | ||
1236 | next_next = 0; | ||
1237 | |||
1238 | buffer_info = &rfd_ring->buffer_info[rfd_next_to_use]; | ||
1239 | next_info = &rfd_ring->buffer_info[next_next]; | ||
1240 | num_alloc++; | ||
1241 | } | ||
1242 | |||
1243 | if (num_alloc) { | ||
1244 | /* | ||
1245 | * Force memory writes to complete before letting h/w | ||
1246 | * know there are new descriptors to fetch. (Only | ||
1247 | * applicable for weak-ordered memory model archs, | ||
1248 | * such as IA-64). | ||
1249 | */ | ||
1250 | wmb(); | ||
1251 | atomic_set(&rfd_ring->next_to_use, (int)rfd_next_to_use); | ||
1252 | } | ||
1253 | return num_alloc; | ||
1254 | } | ||
1255 | |||
1256 | static void atl1_intr_rx(struct atl1_adapter *adapter) | ||
1257 | { | ||
1258 | int i, count; | ||
1259 | u16 length; | ||
1260 | u16 rrd_next_to_clean; | ||
1261 | u32 value; | ||
1262 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | ||
1263 | struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring; | ||
1264 | struct atl1_buffer *buffer_info; | ||
1265 | struct rx_return_desc *rrd; | ||
1266 | struct sk_buff *skb; | ||
1267 | |||
1268 | count = 0; | ||
1269 | |||
1270 | rrd_next_to_clean = atomic_read(&rrd_ring->next_to_clean); | ||
1271 | |||
1272 | while (1) { | ||
1273 | rrd = ATL1_RRD_DESC(rrd_ring, rrd_next_to_clean); | ||
1274 | i = 1; | ||
1275 | if (likely(rrd->xsz.valid)) { /* packet valid */ | ||
1276 | chk_rrd: | ||
1277 | /* check rrd status */ | ||
1278 | if (likely(rrd->num_buf == 1)) | ||
1279 | goto rrd_ok; | ||
1280 | |||
1281 | /* rrd seems to be bad */ | ||
1282 | if (unlikely(i-- > 0)) { | ||
1283 | /* rrd may not be DMAed completely */ | ||
1284 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, | ||
1285 | "incomplete RRD DMA transfer\n"); | ||
1286 | udelay(1); | ||
1287 | goto chk_rrd; | ||
1288 | } | ||
1289 | /* bad rrd */ | ||
1290 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, | ||
1291 | "bad RRD\n"); | ||
1292 | /* see if update RFD index */ | ||
1293 | if (rrd->num_buf > 1) | ||
1294 | atl1_update_rfd_index(adapter, rrd); | ||
1295 | |||
1296 | /* update rrd */ | ||
1297 | rrd->xsz.valid = 0; | ||
1298 | if (++rrd_next_to_clean == rrd_ring->count) | ||
1299 | rrd_next_to_clean = 0; | ||
1300 | count++; | ||
1301 | continue; | ||
1302 | } else { /* current rrd still not be updated */ | ||
1303 | |||
1304 | break; | ||
1305 | } | ||
1306 | rrd_ok: | ||
1307 | /* clean alloc flag for bad rrd */ | ||
1308 | atl1_clean_alloc_flag(adapter, rrd, 0); | ||
1309 | |||
1310 | buffer_info = &rfd_ring->buffer_info[rrd->buf_indx]; | ||
1311 | if (++rfd_ring->next_to_clean == rfd_ring->count) | ||
1312 | rfd_ring->next_to_clean = 0; | ||
1313 | |||
1314 | /* update rrd next to clean */ | ||
1315 | if (++rrd_next_to_clean == rrd_ring->count) | ||
1316 | rrd_next_to_clean = 0; | ||
1317 | count++; | ||
1318 | |||
1319 | if (unlikely(rrd->pkt_flg & PACKET_FLAG_ERR)) { | ||
1320 | if (!(rrd->err_flg & | ||
1321 | (ERR_FLAG_IP_CHKSUM | ERR_FLAG_L4_CHKSUM | ||
1322 | | ERR_FLAG_LEN))) { | ||
1323 | /* packet error, don't need upstream */ | ||
1324 | buffer_info->alloced = 0; | ||
1325 | rrd->xsz.valid = 0; | ||
1326 | continue; | ||
1327 | } | ||
1328 | } | ||
1329 | |||
1330 | /* Good Receive */ | ||
1331 | pci_unmap_page(adapter->pdev, buffer_info->dma, | ||
1332 | buffer_info->length, PCI_DMA_FROMDEVICE); | ||
1333 | skb = buffer_info->skb; | ||
1334 | length = le16_to_cpu(rrd->xsz.xsum_sz.pkt_size); | ||
1335 | |||
1336 | skb_put(skb, length - ETHERNET_FCS_SIZE); | ||
1337 | |||
1338 | /* Receive Checksum Offload */ | ||
1339 | atl1_rx_checksum(adapter, rrd, skb); | ||
1340 | skb->protocol = eth_type_trans(skb, adapter->netdev); | ||
1341 | |||
1342 | if (adapter->vlgrp && (rrd->pkt_flg & PACKET_FLAG_VLAN_INS)) { | ||
1343 | u16 vlan_tag = (rrd->vlan_tag >> 4) | | ||
1344 | ((rrd->vlan_tag & 7) << 13) | | ||
1345 | ((rrd->vlan_tag & 8) << 9); | ||
1346 | vlan_hwaccel_rx(skb, adapter->vlgrp, vlan_tag); | ||
1347 | } else | ||
1348 | netif_rx(skb); | ||
1349 | |||
1350 | /* let protocol layer free skb */ | ||
1351 | buffer_info->skb = NULL; | ||
1352 | buffer_info->alloced = 0; | ||
1353 | rrd->xsz.valid = 0; | ||
1354 | |||
1355 | adapter->netdev->last_rx = jiffies; | ||
1356 | } | ||
1357 | |||
1358 | atomic_set(&rrd_ring->next_to_clean, rrd_next_to_clean); | ||
1359 | |||
1360 | atl1_alloc_rx_buffers(adapter); | ||
1361 | |||
1362 | /* update mailbox ? */ | ||
1363 | if (count) { | ||
1364 | u32 tpd_next_to_use; | ||
1365 | u32 rfd_next_to_use; | ||
1366 | u32 rrd_next_to_clean; | ||
1367 | |||
1368 | spin_lock(&adapter->mb_lock); | ||
1369 | |||
1370 | tpd_next_to_use = atomic_read(&adapter->tpd_ring.next_to_use); | ||
1371 | rfd_next_to_use = | ||
1372 | atomic_read(&adapter->rfd_ring.next_to_use); | ||
1373 | rrd_next_to_clean = | ||
1374 | atomic_read(&adapter->rrd_ring.next_to_clean); | ||
1375 | value = ((rfd_next_to_use & MB_RFD_PROD_INDX_MASK) << | ||
1376 | MB_RFD_PROD_INDX_SHIFT) | | ||
1377 | ((rrd_next_to_clean & MB_RRD_CONS_INDX_MASK) << | ||
1378 | MB_RRD_CONS_INDX_SHIFT) | | ||
1379 | ((tpd_next_to_use & MB_TPD_PROD_INDX_MASK) << | ||
1380 | MB_TPD_PROD_INDX_SHIFT); | ||
1381 | iowrite32(value, adapter->hw.hw_addr + REG_MAILBOX); | ||
1382 | spin_unlock(&adapter->mb_lock); | ||
1383 | } | ||
1384 | } | ||
1385 | |||
1386 | static void atl1_intr_tx(struct atl1_adapter *adapter) | ||
1387 | { | ||
1388 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; | ||
1389 | struct atl1_buffer *buffer_info; | ||
1390 | u16 sw_tpd_next_to_clean; | ||
1391 | u16 cmb_tpd_next_to_clean; | ||
1392 | |||
1393 | sw_tpd_next_to_clean = atomic_read(&tpd_ring->next_to_clean); | ||
1394 | cmb_tpd_next_to_clean = le16_to_cpu(adapter->cmb.cmb->tpd_cons_idx); | ||
1395 | |||
1396 | while (cmb_tpd_next_to_clean != sw_tpd_next_to_clean) { | ||
1397 | struct tx_packet_desc *tpd; | ||
1398 | |||
1399 | tpd = ATL1_TPD_DESC(tpd_ring, sw_tpd_next_to_clean); | ||
1400 | buffer_info = &tpd_ring->buffer_info[sw_tpd_next_to_clean]; | ||
1401 | if (buffer_info->dma) { | ||
1402 | pci_unmap_page(adapter->pdev, buffer_info->dma, | ||
1403 | buffer_info->length, PCI_DMA_TODEVICE); | ||
1404 | buffer_info->dma = 0; | ||
1405 | } | ||
1406 | |||
1407 | if (buffer_info->skb) { | ||
1408 | dev_kfree_skb_irq(buffer_info->skb); | ||
1409 | buffer_info->skb = NULL; | ||
1410 | } | ||
1411 | tpd->buffer_addr = 0; | ||
1412 | tpd->desc.data = 0; | ||
1413 | |||
1414 | if (++sw_tpd_next_to_clean == tpd_ring->count) | ||
1415 | sw_tpd_next_to_clean = 0; | ||
1416 | } | ||
1417 | atomic_set(&tpd_ring->next_to_clean, sw_tpd_next_to_clean); | ||
1418 | |||
1419 | if (netif_queue_stopped(adapter->netdev) | ||
1420 | && netif_carrier_ok(adapter->netdev)) | ||
1421 | netif_wake_queue(adapter->netdev); | ||
1230 | } | 1422 | } |
1231 | 1423 | ||
1232 | static u16 tpd_avail(struct atl1_tpd_ring *tpd_ring) | 1424 | static u16 tpd_avail(struct atl1_tpd_ring *tpd_ring) |
1233 | { | 1425 | { |
1234 | u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean); | 1426 | u16 next_to_clean = atomic_read(&tpd_ring->next_to_clean); |
1235 | u16 next_to_use = atomic_read(&tpd_ring->next_to_use); | 1427 | u16 next_to_use = atomic_read(&tpd_ring->next_to_use); |
1236 | return ((next_to_clean > | 1428 | return ((next_to_clean > next_to_use) ? |
1237 | next_to_use) ? next_to_clean - next_to_use - | 1429 | next_to_clean - next_to_use - 1 : |
1238 | 1 : tpd_ring->count + next_to_clean - next_to_use - 1); | 1430 | tpd_ring->count + next_to_clean - next_to_use - 1); |
1239 | } | 1431 | } |
1240 | 1432 | ||
1241 | static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb, | 1433 | static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb, |
@@ -1258,9 +1450,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb, | |||
1258 | iph->tot_len = 0; | 1450 | iph->tot_len = 0; |
1259 | iph->check = 0; | 1451 | iph->check = 0; |
1260 | tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, | 1452 | tcp_hdr(skb)->check = ~csum_tcpudp_magic(iph->saddr, |
1261 | iph->daddr, 0, | 1453 | iph->daddr, 0, IPPROTO_TCP, 0); |
1262 | IPPROTO_TCP, | ||
1263 | 0); | ||
1264 | ipofst = skb_network_offset(skb); | 1454 | ipofst = skb_network_offset(skb); |
1265 | if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */ | 1455 | if (ipofst != ENET_HEADER_SIZE) /* 802.3 frame */ |
1266 | tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT; | 1456 | tso->tsopl |= 1 << TSO_PARAM_ETHTYPE_SHIFT; |
@@ -1268,7 +1458,8 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb, | |||
1268 | tso->tsopl |= (iph->ihl & | 1458 | tso->tsopl |= (iph->ihl & |
1269 | CSUM_PARAM_IPHL_MASK) << CSUM_PARAM_IPHL_SHIFT; | 1459 | CSUM_PARAM_IPHL_MASK) << CSUM_PARAM_IPHL_SHIFT; |
1270 | tso->tsopl |= (tcp_hdrlen(skb) & | 1460 | tso->tsopl |= (tcp_hdrlen(skb) & |
1271 | TSO_PARAM_TCPHDRLEN_MASK) << TSO_PARAM_TCPHDRLEN_SHIFT; | 1461 | TSO_PARAM_TCPHDRLEN_MASK) << |
1462 | TSO_PARAM_TCPHDRLEN_SHIFT; | ||
1272 | tso->tsopl |= (skb_shinfo(skb)->gso_size & | 1463 | tso->tsopl |= (skb_shinfo(skb)->gso_size & |
1273 | TSO_PARAM_MSS_MASK) << TSO_PARAM_MSS_SHIFT; | 1464 | TSO_PARAM_MSS_MASK) << TSO_PARAM_MSS_SHIFT; |
1274 | tso->tsopl |= 1 << TSO_PARAM_IPCKSUM_SHIFT; | 1465 | tso->tsopl |= 1 << TSO_PARAM_IPCKSUM_SHIFT; |
@@ -1281,7 +1472,7 @@ static int atl1_tso(struct atl1_adapter *adapter, struct sk_buff *skb, | |||
1281 | } | 1472 | } |
1282 | 1473 | ||
1283 | static int atl1_tx_csum(struct atl1_adapter *adapter, struct sk_buff *skb, | 1474 | static int atl1_tx_csum(struct atl1_adapter *adapter, struct sk_buff *skb, |
1284 | struct csum_param *csum) | 1475 | struct csum_param *csum) |
1285 | { | 1476 | { |
1286 | u8 css, cso; | 1477 | u8 css, cso; |
1287 | 1478 | ||
@@ -1289,7 +1480,7 @@ static int atl1_tx_csum(struct atl1_adapter *adapter, struct sk_buff *skb, | |||
1289 | cso = skb_transport_offset(skb); | 1480 | cso = skb_transport_offset(skb); |
1290 | css = cso + skb->csum_offset; | 1481 | css = cso + skb->csum_offset; |
1291 | if (unlikely(cso & 0x1)) { | 1482 | if (unlikely(cso & 0x1)) { |
1292 | dev_dbg(&adapter->pdev->dev, | 1483 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, |
1293 | "payload offset not an even number\n"); | 1484 | "payload offset not an even number\n"); |
1294 | return -1; | 1485 | return -1; |
1295 | } | 1486 | } |
@@ -1304,8 +1495,8 @@ static int atl1_tx_csum(struct atl1_adapter *adapter, struct sk_buff *skb, | |||
1304 | return true; | 1495 | return true; |
1305 | } | 1496 | } |
1306 | 1497 | ||
1307 | static void atl1_tx_map(struct atl1_adapter *adapter, | 1498 | static void atl1_tx_map(struct atl1_adapter *adapter, struct sk_buff *skb, |
1308 | struct sk_buff *skb, bool tcp_seg) | 1499 | bool tcp_seg) |
1309 | { | 1500 | { |
1310 | /* We enter this function holding a spinlock. */ | 1501 | /* We enter this function holding a spinlock. */ |
1311 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; | 1502 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; |
@@ -1342,26 +1533,25 @@ static void atl1_tx_map(struct atl1_adapter *adapter, | |||
1342 | 1533 | ||
1343 | if (first_buf_len > proto_hdr_len) { | 1534 | if (first_buf_len > proto_hdr_len) { |
1344 | len12 = first_buf_len - proto_hdr_len; | 1535 | len12 = first_buf_len - proto_hdr_len; |
1345 | m = (len12 + MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN; | 1536 | m = (len12 + ATL1_MAX_TX_BUF_LEN - 1) / |
1537 | ATL1_MAX_TX_BUF_LEN; | ||
1346 | for (i = 0; i < m; i++) { | 1538 | for (i = 0; i < m; i++) { |
1347 | buffer_info = | 1539 | buffer_info = |
1348 | &tpd_ring->buffer_info[tpd_next_to_use]; | 1540 | &tpd_ring->buffer_info[tpd_next_to_use]; |
1349 | buffer_info->skb = NULL; | 1541 | buffer_info->skb = NULL; |
1350 | buffer_info->length = | 1542 | buffer_info->length = |
1351 | (MAX_TX_BUF_LEN >= | 1543 | (ATL1_MAX_TX_BUF_LEN >= |
1352 | len12) ? MAX_TX_BUF_LEN : len12; | 1544 | len12) ? ATL1_MAX_TX_BUF_LEN : len12; |
1353 | len12 -= buffer_info->length; | 1545 | len12 -= buffer_info->length; |
1354 | page = virt_to_page(skb->data + | 1546 | page = virt_to_page(skb->data + |
1355 | (proto_hdr_len + | 1547 | (proto_hdr_len + |
1356 | i * MAX_TX_BUF_LEN)); | 1548 | i * ATL1_MAX_TX_BUF_LEN)); |
1357 | offset = (unsigned long)(skb->data + | 1549 | offset = (unsigned long)(skb->data + |
1358 | (proto_hdr_len + | 1550 | (proto_hdr_len + |
1359 | i * MAX_TX_BUF_LEN)) & | 1551 | i * ATL1_MAX_TX_BUF_LEN)) & ~PAGE_MASK; |
1360 | ~PAGE_MASK; | 1552 | buffer_info->dma = pci_map_page(adapter->pdev, |
1361 | buffer_info->dma = | 1553 | page, offset, buffer_info->length, |
1362 | pci_map_page(adapter->pdev, page, offset, | 1554 | PCI_DMA_TODEVICE); |
1363 | buffer_info->length, | ||
1364 | PCI_DMA_TODEVICE); | ||
1365 | if (++tpd_next_to_use == tpd_ring->count) | 1555 | if (++tpd_next_to_use == tpd_ring->count) |
1366 | tpd_next_to_use = 0; | 1556 | tpd_next_to_use = 0; |
1367 | } | 1557 | } |
@@ -1372,8 +1562,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, | |||
1372 | page = virt_to_page(skb->data); | 1562 | page = virt_to_page(skb->data); |
1373 | offset = (unsigned long)skb->data & ~PAGE_MASK; | 1563 | offset = (unsigned long)skb->data & ~PAGE_MASK; |
1374 | buffer_info->dma = pci_map_page(adapter->pdev, page, | 1564 | buffer_info->dma = pci_map_page(adapter->pdev, page, |
1375 | offset, first_buf_len, | 1565 | offset, first_buf_len, PCI_DMA_TODEVICE); |
1376 | PCI_DMA_TODEVICE); | ||
1377 | if (++tpd_next_to_use == tpd_ring->count) | 1566 | if (++tpd_next_to_use == tpd_ring->count) |
1378 | tpd_next_to_use = 0; | 1567 | tpd_next_to_use = 0; |
1379 | } | 1568 | } |
@@ -1385,19 +1574,19 @@ static void atl1_tx_map(struct atl1_adapter *adapter, | |||
1385 | frag = &skb_shinfo(skb)->frags[f]; | 1574 | frag = &skb_shinfo(skb)->frags[f]; |
1386 | lenf = frag->size; | 1575 | lenf = frag->size; |
1387 | 1576 | ||
1388 | m = (lenf + MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN; | 1577 | m = (lenf + ATL1_MAX_TX_BUF_LEN - 1) / ATL1_MAX_TX_BUF_LEN; |
1389 | for (i = 0; i < m; i++) { | 1578 | for (i = 0; i < m; i++) { |
1390 | buffer_info = &tpd_ring->buffer_info[tpd_next_to_use]; | 1579 | buffer_info = &tpd_ring->buffer_info[tpd_next_to_use]; |
1391 | if (unlikely(buffer_info->skb)) | 1580 | if (unlikely(buffer_info->skb)) |
1392 | BUG(); | 1581 | BUG(); |
1393 | buffer_info->skb = NULL; | 1582 | buffer_info->skb = NULL; |
1394 | buffer_info->length = | 1583 | buffer_info->length = (lenf > ATL1_MAX_TX_BUF_LEN) ? |
1395 | (lenf > MAX_TX_BUF_LEN) ? MAX_TX_BUF_LEN : lenf; | 1584 | ATL1_MAX_TX_BUF_LEN : lenf; |
1396 | lenf -= buffer_info->length; | 1585 | lenf -= buffer_info->length; |
1397 | buffer_info->dma = | 1586 | buffer_info->dma = pci_map_page(adapter->pdev, |
1398 | pci_map_page(adapter->pdev, frag->page, | 1587 | frag->page, |
1399 | frag->page_offset + i * MAX_TX_BUF_LEN, | 1588 | frag->page_offset + (i * ATL1_MAX_TX_BUF_LEN), |
1400 | buffer_info->length, PCI_DMA_TODEVICE); | 1589 | buffer_info->length, PCI_DMA_TODEVICE); |
1401 | 1590 | ||
1402 | if (++tpd_next_to_use == tpd_ring->count) | 1591 | if (++tpd_next_to_use == tpd_ring->count) |
1403 | tpd_next_to_use = 0; | 1592 | tpd_next_to_use = 0; |
@@ -1409,7 +1598,7 @@ static void atl1_tx_map(struct atl1_adapter *adapter, | |||
1409 | } | 1598 | } |
1410 | 1599 | ||
1411 | static void atl1_tx_queue(struct atl1_adapter *adapter, int count, | 1600 | static void atl1_tx_queue(struct atl1_adapter *adapter, int count, |
1412 | union tpd_descr *descr) | 1601 | union tpd_descr *descr) |
1413 | { | 1602 | { |
1414 | /* We enter this function holding a spinlock. */ | 1603 | /* We enter this function holding a spinlock. */ |
1415 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; | 1604 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; |
@@ -1453,31 +1642,6 @@ static void atl1_tx_queue(struct atl1_adapter *adapter, int count, | |||
1453 | atomic_set(&tpd_ring->next_to_use, (int)tpd_next_to_use); | 1642 | atomic_set(&tpd_ring->next_to_use, (int)tpd_next_to_use); |
1454 | } | 1643 | } |
1455 | 1644 | ||
1456 | static void atl1_update_mailbox(struct atl1_adapter *adapter) | ||
1457 | { | ||
1458 | unsigned long flags; | ||
1459 | u32 tpd_next_to_use; | ||
1460 | u32 rfd_next_to_use; | ||
1461 | u32 rrd_next_to_clean; | ||
1462 | u32 value; | ||
1463 | |||
1464 | spin_lock_irqsave(&adapter->mb_lock, flags); | ||
1465 | |||
1466 | tpd_next_to_use = atomic_read(&adapter->tpd_ring.next_to_use); | ||
1467 | rfd_next_to_use = atomic_read(&adapter->rfd_ring.next_to_use); | ||
1468 | rrd_next_to_clean = atomic_read(&adapter->rrd_ring.next_to_clean); | ||
1469 | |||
1470 | value = ((rfd_next_to_use & MB_RFD_PROD_INDX_MASK) << | ||
1471 | MB_RFD_PROD_INDX_SHIFT) | | ||
1472 | ((rrd_next_to_clean & MB_RRD_CONS_INDX_MASK) << | ||
1473 | MB_RRD_CONS_INDX_SHIFT) | | ||
1474 | ((tpd_next_to_use & MB_TPD_PROD_INDX_MASK) << | ||
1475 | MB_TPD_PROD_INDX_SHIFT); | ||
1476 | iowrite32(value, adapter->hw.hw_addr + REG_MAILBOX); | ||
1477 | |||
1478 | spin_unlock_irqrestore(&adapter->mb_lock, flags); | ||
1479 | } | ||
1480 | |||
1481 | static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | 1645 | static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev) |
1482 | { | 1646 | { |
1483 | struct atl1_adapter *adapter = netdev_priv(netdev); | 1647 | struct atl1_adapter *adapter = netdev_priv(netdev); |
@@ -1513,8 +1677,8 @@ static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1513 | for (f = 0; f < nr_frags; f++) { | 1677 | for (f = 0; f < nr_frags; f++) { |
1514 | frag_size = skb_shinfo(skb)->frags[f].size; | 1678 | frag_size = skb_shinfo(skb)->frags[f].size; |
1515 | if (frag_size) | 1679 | if (frag_size) |
1516 | count += | 1680 | count += (frag_size + ATL1_MAX_TX_BUF_LEN - 1) / |
1517 | (frag_size + MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN; | 1681 | ATL1_MAX_TX_BUF_LEN; |
1518 | } | 1682 | } |
1519 | 1683 | ||
1520 | /* mss will be nonzero if we're doing segment offload (TSO/GSO) */ | 1684 | /* mss will be nonzero if we're doing segment offload (TSO/GSO) */ |
@@ -1530,7 +1694,8 @@ static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1530 | /* need additional TPD ? */ | 1694 | /* need additional TPD ? */ |
1531 | if (proto_hdr_len != len) | 1695 | if (proto_hdr_len != len) |
1532 | count += (len - proto_hdr_len + | 1696 | count += (len - proto_hdr_len + |
1533 | MAX_TX_BUF_LEN - 1) / MAX_TX_BUF_LEN; | 1697 | ATL1_MAX_TX_BUF_LEN - 1) / |
1698 | ATL1_MAX_TX_BUF_LEN; | ||
1534 | } | 1699 | } |
1535 | } | 1700 | } |
1536 | 1701 | ||
@@ -1538,7 +1703,7 @@ static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1538 | if (!spin_trylock(&adapter->lock)) { | 1703 | if (!spin_trylock(&adapter->lock)) { |
1539 | /* Can't get lock - tell upper layer to requeue */ | 1704 | /* Can't get lock - tell upper layer to requeue */ |
1540 | local_irq_restore(flags); | 1705 | local_irq_restore(flags); |
1541 | dev_dbg(&adapter->pdev->dev, "tx locked\n"); | 1706 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, "tx locked\n"); |
1542 | return NETDEV_TX_LOCKED; | 1707 | return NETDEV_TX_LOCKED; |
1543 | } | 1708 | } |
1544 | 1709 | ||
@@ -1546,7 +1711,7 @@ static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1546 | /* not enough descriptors */ | 1711 | /* not enough descriptors */ |
1547 | netif_stop_queue(netdev); | 1712 | netif_stop_queue(netdev); |
1548 | spin_unlock_irqrestore(&adapter->lock, flags); | 1713 | spin_unlock_irqrestore(&adapter->lock, flags); |
1549 | dev_dbg(&adapter->pdev->dev, "tx busy\n"); | 1714 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, "tx busy\n"); |
1550 | return NETDEV_TX_BUSY; | 1715 | return NETDEV_TX_BUSY; |
1551 | } | 1716 | } |
1552 | 1717 | ||
@@ -1588,131 +1753,208 @@ static int atl1_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1588 | } | 1753 | } |
1589 | 1754 | ||
1590 | /* | 1755 | /* |
1591 | * atl1_get_stats - Get System Network Statistics | 1756 | * atl1_intr - Interrupt Handler |
1592 | * @netdev: network interface device structure | 1757 | * @irq: interrupt number |
1593 | * | 1758 | * @data: pointer to a network interface device structure |
1594 | * Returns the address of the device statistics structure. | 1759 | * @pt_regs: CPU registers structure |
1595 | * The statistics are actually updated from the timer callback. | ||
1596 | */ | 1760 | */ |
1597 | static struct net_device_stats *atl1_get_stats(struct net_device *netdev) | 1761 | static irqreturn_t atl1_intr(int irq, void *data) |
1598 | { | 1762 | { |
1599 | struct atl1_adapter *adapter = netdev_priv(netdev); | 1763 | struct atl1_adapter *adapter = netdev_priv(data); |
1600 | return &adapter->net_stats; | 1764 | u32 status; |
1601 | } | 1765 | u8 update_rx; |
1766 | int max_ints = 10; | ||
1602 | 1767 | ||
1603 | /* | 1768 | status = adapter->cmb.cmb->int_stats; |
1604 | * atl1_clean_rx_ring - Free RFD Buffers | 1769 | if (!status) |
1605 | * @adapter: board private structure | 1770 | return IRQ_NONE; |
1606 | */ | ||
1607 | static void atl1_clean_rx_ring(struct atl1_adapter *adapter) | ||
1608 | { | ||
1609 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | ||
1610 | struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring; | ||
1611 | struct atl1_buffer *buffer_info; | ||
1612 | struct pci_dev *pdev = adapter->pdev; | ||
1613 | unsigned long size; | ||
1614 | unsigned int i; | ||
1615 | 1771 | ||
1616 | /* Free all the Rx ring sk_buffs */ | 1772 | update_rx = 0; |
1617 | for (i = 0; i < rfd_ring->count; i++) { | 1773 | |
1618 | buffer_info = &rfd_ring->buffer_info[i]; | 1774 | do { |
1619 | if (buffer_info->dma) { | 1775 | /* clear CMB interrupt status at once */ |
1620 | pci_unmap_page(pdev, | 1776 | adapter->cmb.cmb->int_stats = 0; |
1621 | buffer_info->dma, | 1777 | |
1622 | buffer_info->length, | 1778 | if (status & ISR_GPHY) /* clear phy status */ |
1623 | PCI_DMA_FROMDEVICE); | 1779 | atl1_clear_phy_int(adapter); |
1624 | buffer_info->dma = 0; | 1780 | |
1781 | /* clear ISR status, and Enable CMB DMA/Disable Interrupt */ | ||
1782 | iowrite32(status | ISR_DIS_INT, adapter->hw.hw_addr + REG_ISR); | ||
1783 | |||
1784 | /* check if SMB intr */ | ||
1785 | if (status & ISR_SMB) | ||
1786 | atl1_inc_smb(adapter); | ||
1787 | |||
1788 | /* check if PCIE PHY Link down */ | ||
1789 | if (status & ISR_PHY_LINKDOWN) { | ||
1790 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, | ||
1791 | "pcie phy link down %x\n", status); | ||
1792 | if (netif_running(adapter->netdev)) { /* reset MAC */ | ||
1793 | iowrite32(0, adapter->hw.hw_addr + REG_IMR); | ||
1794 | schedule_work(&adapter->pcie_dma_to_rst_task); | ||
1795 | return IRQ_HANDLED; | ||
1796 | } | ||
1625 | } | 1797 | } |
1626 | if (buffer_info->skb) { | 1798 | |
1627 | dev_kfree_skb(buffer_info->skb); | 1799 | /* check if DMA read/write error ? */ |
1628 | buffer_info->skb = NULL; | 1800 | if (status & (ISR_DMAR_TO_RST | ISR_DMAW_TO_RST)) { |
1801 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, | ||
1802 | "pcie DMA r/w error (status = 0x%x)\n", | ||
1803 | status); | ||
1804 | iowrite32(0, adapter->hw.hw_addr + REG_IMR); | ||
1805 | schedule_work(&adapter->pcie_dma_to_rst_task); | ||
1806 | return IRQ_HANDLED; | ||
1629 | } | 1807 | } |
1630 | } | ||
1631 | 1808 | ||
1632 | size = sizeof(struct atl1_buffer) * rfd_ring->count; | 1809 | /* link event */ |
1633 | memset(rfd_ring->buffer_info, 0, size); | 1810 | if (status & ISR_GPHY) { |
1811 | adapter->soft_stats.tx_carrier_errors++; | ||
1812 | atl1_check_for_link(adapter); | ||
1813 | } | ||
1634 | 1814 | ||
1635 | /* Zero out the descriptor ring */ | 1815 | /* transmit event */ |
1636 | memset(rfd_ring->desc, 0, rfd_ring->size); | 1816 | if (status & ISR_CMB_TX) |
1817 | atl1_intr_tx(adapter); | ||
1637 | 1818 | ||
1638 | rfd_ring->next_to_clean = 0; | 1819 | /* rx exception */ |
1639 | atomic_set(&rfd_ring->next_to_use, 0); | 1820 | if (unlikely(status & (ISR_RXF_OV | ISR_RFD_UNRUN | |
1821 | ISR_RRD_OV | ISR_HOST_RFD_UNRUN | | ||
1822 | ISR_HOST_RRD_OV | ISR_CMB_RX))) { | ||
1823 | if (status & (ISR_RXF_OV | ISR_RFD_UNRUN | | ||
1824 | ISR_RRD_OV | ISR_HOST_RFD_UNRUN | | ||
1825 | ISR_HOST_RRD_OV)) | ||
1826 | dev_printk(KERN_DEBUG, &adapter->pdev->dev, | ||
1827 | "rx exception, ISR = 0x%x\n", status); | ||
1828 | atl1_intr_rx(adapter); | ||
1829 | } | ||
1640 | 1830 | ||
1641 | rrd_ring->next_to_use = 0; | 1831 | if (--max_ints < 0) |
1642 | atomic_set(&rrd_ring->next_to_clean, 0); | 1832 | break; |
1833 | |||
1834 | } while ((status = adapter->cmb.cmb->int_stats)); | ||
1835 | |||
1836 | /* re-enable Interrupt */ | ||
1837 | iowrite32(ISR_DIS_SMB | ISR_DIS_DMA, adapter->hw.hw_addr + REG_ISR); | ||
1838 | return IRQ_HANDLED; | ||
1643 | } | 1839 | } |
1644 | 1840 | ||
1645 | /* | 1841 | /* |
1646 | * atl1_clean_tx_ring - Free Tx Buffers | 1842 | * atl1_watchdog - Timer Call-back |
1647 | * @adapter: board private structure | 1843 | * @data: pointer to netdev cast into an unsigned long |
1648 | */ | 1844 | */ |
1649 | static void atl1_clean_tx_ring(struct atl1_adapter *adapter) | 1845 | static void atl1_watchdog(unsigned long data) |
1650 | { | 1846 | { |
1651 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; | 1847 | struct atl1_adapter *adapter = (struct atl1_adapter *)data; |
1652 | struct atl1_buffer *buffer_info; | ||
1653 | struct pci_dev *pdev = adapter->pdev; | ||
1654 | unsigned long size; | ||
1655 | unsigned int i; | ||
1656 | 1848 | ||
1657 | /* Free all the Tx ring sk_buffs */ | 1849 | /* Reset the timer */ |
1658 | for (i = 0; i < tpd_ring->count; i++) { | 1850 | mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); |
1659 | buffer_info = &tpd_ring->buffer_info[i]; | 1851 | } |
1660 | if (buffer_info->dma) { | ||
1661 | pci_unmap_page(pdev, buffer_info->dma, | ||
1662 | buffer_info->length, PCI_DMA_TODEVICE); | ||
1663 | buffer_info->dma = 0; | ||
1664 | } | ||
1665 | } | ||
1666 | 1852 | ||
1667 | for (i = 0; i < tpd_ring->count; i++) { | 1853 | /* |
1668 | buffer_info = &tpd_ring->buffer_info[i]; | 1854 | * atl1_phy_config - Timer Call-back |
1669 | if (buffer_info->skb) { | 1855 | * @data: pointer to netdev cast into an unsigned long |
1670 | dev_kfree_skb_any(buffer_info->skb); | 1856 | */ |
1671 | buffer_info->skb = NULL; | 1857 | static void atl1_phy_config(unsigned long data) |
1672 | } | 1858 | { |
1673 | } | 1859 | struct atl1_adapter *adapter = (struct atl1_adapter *)data; |
1860 | struct atl1_hw *hw = &adapter->hw; | ||
1861 | unsigned long flags; | ||
1674 | 1862 | ||
1675 | size = sizeof(struct atl1_buffer) * tpd_ring->count; | 1863 | spin_lock_irqsave(&adapter->lock, flags); |
1676 | memset(tpd_ring->buffer_info, 0, size); | 1864 | adapter->phy_timer_pending = false; |
1865 | atl1_write_phy_reg(hw, MII_ADVERTISE, hw->mii_autoneg_adv_reg); | ||
1866 | atl1_write_phy_reg(hw, MII_AT001_CR, hw->mii_1000t_ctrl_reg); | ||
1867 | atl1_write_phy_reg(hw, MII_BMCR, MII_CR_RESET | MII_CR_AUTO_NEG_EN); | ||
1868 | spin_unlock_irqrestore(&adapter->lock, flags); | ||
1869 | } | ||
1677 | 1870 | ||
1678 | /* Zero out the descriptor ring */ | 1871 | /* |
1679 | memset(tpd_ring->desc, 0, tpd_ring->size); | 1872 | * atl1_tx_timeout - Respond to a Tx Hang |
1873 | * @netdev: network interface device structure | ||
1874 | */ | ||
1875 | static void atl1_tx_timeout(struct net_device *netdev) | ||
1876 | { | ||
1877 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
1878 | /* Do the reset outside of interrupt context */ | ||
1879 | schedule_work(&adapter->tx_timeout_task); | ||
1880 | } | ||
1680 | 1881 | ||
1681 | atomic_set(&tpd_ring->next_to_use, 0); | 1882 | /* |
1682 | atomic_set(&tpd_ring->next_to_clean, 0); | 1883 | * Orphaned vendor comment left intact here: |
1884 | * <vendor comment> | ||
1885 | * If TPD Buffer size equal to 0, PCIE DMAR_TO_INT | ||
1886 | * will assert. We do soft reset <0x1400=1> according | ||
1887 | * with the SPEC. BUT, it seemes that PCIE or DMA | ||
1888 | * state-machine will not be reset. DMAR_TO_INT will | ||
1889 | * assert again and again. | ||
1890 | * </vendor comment> | ||
1891 | */ | ||
1892 | static void atl1_tx_timeout_task(struct work_struct *work) | ||
1893 | { | ||
1894 | struct atl1_adapter *adapter = | ||
1895 | container_of(work, struct atl1_adapter, tx_timeout_task); | ||
1896 | struct net_device *netdev = adapter->netdev; | ||
1897 | |||
1898 | netif_device_detach(netdev); | ||
1899 | atl1_down(adapter); | ||
1900 | atl1_up(adapter); | ||
1901 | netif_device_attach(netdev); | ||
1683 | } | 1902 | } |
1684 | 1903 | ||
1685 | /* | 1904 | /* |
1686 | * atl1_free_ring_resources - Free Tx / RX descriptor Resources | 1905 | * atl1_link_chg_task - deal with link change event Out of interrupt context |
1687 | * @adapter: board private structure | ||
1688 | * | ||
1689 | * Free all transmit software resources | ||
1690 | */ | 1906 | */ |
1691 | void atl1_free_ring_resources(struct atl1_adapter *adapter) | 1907 | static void atl1_link_chg_task(struct work_struct *work) |
1692 | { | 1908 | { |
1693 | struct pci_dev *pdev = adapter->pdev; | 1909 | struct atl1_adapter *adapter = |
1694 | struct atl1_tpd_ring *tpd_ring = &adapter->tpd_ring; | 1910 | container_of(work, struct atl1_adapter, link_chg_task); |
1695 | struct atl1_rfd_ring *rfd_ring = &adapter->rfd_ring; | 1911 | unsigned long flags; |
1696 | struct atl1_rrd_ring *rrd_ring = &adapter->rrd_ring; | ||
1697 | struct atl1_ring_header *ring_header = &adapter->ring_header; | ||
1698 | 1912 | ||
1699 | atl1_clean_tx_ring(adapter); | 1913 | spin_lock_irqsave(&adapter->lock, flags); |
1700 | atl1_clean_rx_ring(adapter); | 1914 | atl1_check_link(adapter); |
1915 | spin_unlock_irqrestore(&adapter->lock, flags); | ||
1916 | } | ||
1701 | 1917 | ||
1702 | kfree(tpd_ring->buffer_info); | 1918 | static void atl1_vlan_rx_register(struct net_device *netdev, |
1703 | pci_free_consistent(pdev, ring_header->size, ring_header->desc, | 1919 | struct vlan_group *grp) |
1704 | ring_header->dma); | 1920 | { |
1921 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
1922 | unsigned long flags; | ||
1923 | u32 ctrl; | ||
1705 | 1924 | ||
1706 | tpd_ring->buffer_info = NULL; | 1925 | spin_lock_irqsave(&adapter->lock, flags); |
1707 | tpd_ring->desc = NULL; | 1926 | /* atl1_irq_disable(adapter); */ |
1708 | tpd_ring->dma = 0; | 1927 | adapter->vlgrp = grp; |
1709 | 1928 | ||
1710 | rfd_ring->buffer_info = NULL; | 1929 | if (grp) { |
1711 | rfd_ring->desc = NULL; | 1930 | /* enable VLAN tag insert/strip */ |
1712 | rfd_ring->dma = 0; | 1931 | ctrl = ioread32(adapter->hw.hw_addr + REG_MAC_CTRL); |
1932 | ctrl |= MAC_CTRL_RMV_VLAN; | ||
1933 | iowrite32(ctrl, adapter->hw.hw_addr + REG_MAC_CTRL); | ||
1934 | } else { | ||
1935 | /* disable VLAN tag insert/strip */ | ||
1936 | ctrl = ioread32(adapter->hw.hw_addr + REG_MAC_CTRL); | ||
1937 | ctrl &= ~MAC_CTRL_RMV_VLAN; | ||
1938 | iowrite32(ctrl, adapter->hw.hw_addr + REG_MAC_CTRL); | ||
1939 | } | ||
1713 | 1940 | ||
1714 | rrd_ring->desc = NULL; | 1941 | /* atl1_irq_enable(adapter); */ |
1715 | rrd_ring->dma = 0; | 1942 | spin_unlock_irqrestore(&adapter->lock, flags); |
1943 | } | ||
1944 | |||
1945 | static void atl1_restore_vlan(struct atl1_adapter *adapter) | ||
1946 | { | ||
1947 | atl1_vlan_rx_register(adapter->netdev, adapter->vlgrp); | ||
1948 | } | ||
1949 | |||
1950 | int atl1_reset(struct atl1_adapter *adapter) | ||
1951 | { | ||
1952 | int ret; | ||
1953 | |||
1954 | ret = atl1_reset_hw(&adapter->hw); | ||
1955 | if (ret != ATL1_SUCCESS) | ||
1956 | return ret; | ||
1957 | return atl1_init_hw(&adapter->hw); | ||
1716 | } | 1958 | } |
1717 | 1959 | ||
1718 | s32 atl1_up(struct atl1_adapter *adapter) | 1960 | s32 atl1_up(struct atl1_adapter *adapter) |
@@ -1723,6 +1965,7 @@ s32 atl1_up(struct atl1_adapter *adapter) | |||
1723 | 1965 | ||
1724 | /* hardware has been reset, we need to reload some things */ | 1966 | /* hardware has been reset, we need to reload some things */ |
1725 | atl1_set_multi(netdev); | 1967 | atl1_set_multi(netdev); |
1968 | atl1_init_ring_ptrs(adapter); | ||
1726 | atl1_restore_vlan(adapter); | 1969 | atl1_restore_vlan(adapter); |
1727 | err = atl1_alloc_rx_buffers(adapter); | 1970 | err = atl1_alloc_rx_buffers(adapter); |
1728 | if (unlikely(!err)) /* no RX BUFFER allocated */ | 1971 | if (unlikely(!err)) /* no RX BUFFER allocated */ |
@@ -1750,11 +1993,6 @@ s32 atl1_up(struct atl1_adapter *adapter) | |||
1750 | atl1_check_link(adapter); | 1993 | atl1_check_link(adapter); |
1751 | return 0; | 1994 | return 0; |
1752 | 1995 | ||
1753 | /* FIXME: unreachable code! -- CHS */ | ||
1754 | /* free irq disable any interrupt */ | ||
1755 | iowrite32(0, adapter->hw.hw_addr + REG_IMR); | ||
1756 | free_irq(adapter->pdev->irq, netdev); | ||
1757 | |||
1758 | err_up: | 1996 | err_up: |
1759 | pci_disable_msi(adapter->pdev); | 1997 | pci_disable_msi(adapter->pdev); |
1760 | /* free rx_buffers */ | 1998 | /* free rx_buffers */ |
@@ -1786,172 +2024,6 @@ void atl1_down(struct atl1_adapter *adapter) | |||
1786 | } | 2024 | } |
1787 | 2025 | ||
1788 | /* | 2026 | /* |
1789 | * atl1_change_mtu - Change the Maximum Transfer Unit | ||
1790 | * @netdev: network interface device structure | ||
1791 | * @new_mtu: new value for maximum frame size | ||
1792 | * | ||
1793 | * Returns 0 on success, negative on failure | ||
1794 | */ | ||
1795 | static int atl1_change_mtu(struct net_device *netdev, int new_mtu) | ||
1796 | { | ||
1797 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
1798 | int old_mtu = netdev->mtu; | ||
1799 | int max_frame = new_mtu + ENET_HEADER_SIZE + ETHERNET_FCS_SIZE; | ||
1800 | |||
1801 | if ((max_frame < MINIMUM_ETHERNET_FRAME_SIZE) || | ||
1802 | (max_frame > MAX_JUMBO_FRAME_SIZE)) { | ||
1803 | dev_warn(&adapter->pdev->dev, "invalid MTU setting\n"); | ||
1804 | return -EINVAL; | ||
1805 | } | ||
1806 | |||
1807 | adapter->hw.max_frame_size = max_frame; | ||
1808 | adapter->hw.tx_jumbo_task_th = (max_frame + 7) >> 3; | ||
1809 | adapter->rx_buffer_len = (max_frame + 7) & ~7; | ||
1810 | adapter->hw.rx_jumbo_th = adapter->rx_buffer_len / 8; | ||
1811 | |||
1812 | netdev->mtu = new_mtu; | ||
1813 | if ((old_mtu != new_mtu) && netif_running(netdev)) { | ||
1814 | atl1_down(adapter); | ||
1815 | atl1_up(adapter); | ||
1816 | } | ||
1817 | |||
1818 | return 0; | ||
1819 | } | ||
1820 | |||
1821 | /* | ||
1822 | * atl1_set_mac - Change the Ethernet Address of the NIC | ||
1823 | * @netdev: network interface device structure | ||
1824 | * @p: pointer to an address structure | ||
1825 | * | ||
1826 | * Returns 0 on success, negative on failure | ||
1827 | */ | ||
1828 | static int atl1_set_mac(struct net_device *netdev, void *p) | ||
1829 | { | ||
1830 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
1831 | struct sockaddr *addr = p; | ||
1832 | |||
1833 | if (netif_running(netdev)) | ||
1834 | return -EBUSY; | ||
1835 | |||
1836 | if (!is_valid_ether_addr(addr->sa_data)) | ||
1837 | return -EADDRNOTAVAIL; | ||
1838 | |||
1839 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); | ||
1840 | memcpy(adapter->hw.mac_addr, addr->sa_data, netdev->addr_len); | ||
1841 | |||
1842 | atl1_set_mac_addr(&adapter->hw); | ||
1843 | return 0; | ||
1844 | } | ||
1845 | |||
1846 | /* | ||
1847 | * atl1_watchdog - Timer Call-back | ||
1848 | * @data: pointer to netdev cast into an unsigned long | ||
1849 | */ | ||
1850 | static void atl1_watchdog(unsigned long data) | ||
1851 | { | ||
1852 | struct atl1_adapter *adapter = (struct atl1_adapter *)data; | ||
1853 | |||
1854 | /* Reset the timer */ | ||
1855 | mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); | ||
1856 | } | ||
1857 | |||
1858 | static int mdio_read(struct net_device *netdev, int phy_id, int reg_num) | ||
1859 | { | ||
1860 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
1861 | u16 result; | ||
1862 | |||
1863 | atl1_read_phy_reg(&adapter->hw, reg_num & 0x1f, &result); | ||
1864 | |||
1865 | return result; | ||
1866 | } | ||
1867 | |||
1868 | static void mdio_write(struct net_device *netdev, int phy_id, int reg_num, int val) | ||
1869 | { | ||
1870 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
1871 | |||
1872 | atl1_write_phy_reg(&adapter->hw, reg_num, val); | ||
1873 | } | ||
1874 | |||
1875 | /* | ||
1876 | * atl1_mii_ioctl - | ||
1877 | * @netdev: | ||
1878 | * @ifreq: | ||
1879 | * @cmd: | ||
1880 | */ | ||
1881 | static int atl1_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | ||
1882 | { | ||
1883 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
1884 | unsigned long flags; | ||
1885 | int retval; | ||
1886 | |||
1887 | if (!netif_running(netdev)) | ||
1888 | return -EINVAL; | ||
1889 | |||
1890 | spin_lock_irqsave(&adapter->lock, flags); | ||
1891 | retval = generic_mii_ioctl(&adapter->mii, if_mii(ifr), cmd, NULL); | ||
1892 | spin_unlock_irqrestore(&adapter->lock, flags); | ||
1893 | |||
1894 | return retval; | ||
1895 | } | ||
1896 | |||
1897 | /* | ||
1898 | * atl1_ioctl - | ||
1899 | * @netdev: | ||
1900 | * @ifreq: | ||
1901 | * @cmd: | ||
1902 | */ | ||
1903 | static int atl1_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | ||
1904 | { | ||
1905 | switch (cmd) { | ||
1906 | case SIOCGMIIPHY: | ||
1907 | case SIOCGMIIREG: | ||
1908 | case SIOCSMIIREG: | ||
1909 | return atl1_mii_ioctl(netdev, ifr, cmd); | ||
1910 | default: | ||
1911 | return -EOPNOTSUPP; | ||
1912 | } | ||
1913 | } | ||
1914 | |||
1915 | /* | ||
1916 | * atl1_tx_timeout - Respond to a Tx Hang | ||
1917 | * @netdev: network interface device structure | ||
1918 | */ | ||
1919 | static void atl1_tx_timeout(struct net_device *netdev) | ||
1920 | { | ||
1921 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
1922 | /* Do the reset outside of interrupt context */ | ||
1923 | schedule_work(&adapter->tx_timeout_task); | ||
1924 | } | ||
1925 | |||
1926 | /* | ||
1927 | * atl1_phy_config - Timer Call-back | ||
1928 | * @data: pointer to netdev cast into an unsigned long | ||
1929 | */ | ||
1930 | static void atl1_phy_config(unsigned long data) | ||
1931 | { | ||
1932 | struct atl1_adapter *adapter = (struct atl1_adapter *)data; | ||
1933 | struct atl1_hw *hw = &adapter->hw; | ||
1934 | unsigned long flags; | ||
1935 | |||
1936 | spin_lock_irqsave(&adapter->lock, flags); | ||
1937 | adapter->phy_timer_pending = false; | ||
1938 | atl1_write_phy_reg(hw, MII_ADVERTISE, hw->mii_autoneg_adv_reg); | ||
1939 | atl1_write_phy_reg(hw, MII_AT001_CR, hw->mii_1000t_ctrl_reg); | ||
1940 | atl1_write_phy_reg(hw, MII_BMCR, MII_CR_RESET | MII_CR_AUTO_NEG_EN); | ||
1941 | spin_unlock_irqrestore(&adapter->lock, flags); | ||
1942 | } | ||
1943 | |||
1944 | int atl1_reset(struct atl1_adapter *adapter) | ||
1945 | { | ||
1946 | int ret; | ||
1947 | |||
1948 | ret = atl1_reset_hw(&adapter->hw); | ||
1949 | if (ret != ATL1_SUCCESS) | ||
1950 | return ret; | ||
1951 | return atl1_init_hw(&adapter->hw); | ||
1952 | } | ||
1953 | |||
1954 | /* | ||
1955 | * atl1_open - Called when a network interface is made active | 2027 | * atl1_open - Called when a network interface is made active |
1956 | * @netdev: network interface device structure | 2028 | * @netdev: network interface device structure |
1957 | * | 2029 | * |
@@ -2003,77 +2075,113 @@ static int atl1_close(struct net_device *netdev) | |||
2003 | return 0; | 2075 | return 0; |
2004 | } | 2076 | } |
2005 | 2077 | ||
2006 | #ifdef CONFIG_NET_POLL_CONTROLLER | 2078 | #ifdef CONFIG_PM |
2007 | static void atl1_poll_controller(struct net_device *netdev) | 2079 | static int atl1_suspend(struct pci_dev *pdev, pm_message_t state) |
2008 | { | ||
2009 | disable_irq(netdev->irq); | ||
2010 | atl1_intr(netdev->irq, netdev); | ||
2011 | enable_irq(netdev->irq); | ||
2012 | } | ||
2013 | #endif | ||
2014 | |||
2015 | /* | ||
2016 | * If TPD Buffer size equal to 0, PCIE DMAR_TO_INT | ||
2017 | * will assert. We do soft reset <0x1400=1> according | ||
2018 | * with the SPEC. BUT, it seemes that PCIE or DMA | ||
2019 | * state-machine will not be reset. DMAR_TO_INT will | ||
2020 | * assert again and again. | ||
2021 | */ | ||
2022 | static void atl1_tx_timeout_task(struct work_struct *work) | ||
2023 | { | 2080 | { |
2024 | struct atl1_adapter *adapter = | 2081 | struct net_device *netdev = pci_get_drvdata(pdev); |
2025 | container_of(work, struct atl1_adapter, tx_timeout_task); | 2082 | struct atl1_adapter *adapter = netdev_priv(netdev); |
2026 | struct net_device *netdev = adapter->netdev; | 2083 | struct atl1_hw *hw = &adapter->hw; |
2084 | u32 ctrl = 0; | ||
2085 | u32 wufc = adapter->wol; | ||
2027 | 2086 | ||
2028 | netif_device_detach(netdev); | 2087 | netif_device_detach(netdev); |
2029 | atl1_down(adapter); | 2088 | if (netif_running(netdev)) |
2030 | atl1_up(adapter); | 2089 | atl1_down(adapter); |
2031 | netif_device_attach(netdev); | ||
2032 | } | ||
2033 | 2090 | ||
2034 | /* | 2091 | atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); |
2035 | * atl1_link_chg_task - deal with link change event Out of interrupt context | 2092 | atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); |
2036 | */ | 2093 | if (ctrl & BMSR_LSTATUS) |
2037 | static void atl1_link_chg_task(struct work_struct *work) | 2094 | wufc &= ~ATL1_WUFC_LNKC; |
2038 | { | ||
2039 | struct atl1_adapter *adapter = | ||
2040 | container_of(work, struct atl1_adapter, link_chg_task); | ||
2041 | unsigned long flags; | ||
2042 | 2095 | ||
2043 | spin_lock_irqsave(&adapter->lock, flags); | 2096 | /* reduce speed to 10/100M */ |
2044 | atl1_check_link(adapter); | 2097 | if (wufc) { |
2045 | spin_unlock_irqrestore(&adapter->lock, flags); | 2098 | atl1_phy_enter_power_saving(hw); |
2099 | /* if resume, let driver to re- setup link */ | ||
2100 | hw->phy_configured = false; | ||
2101 | atl1_set_mac_addr(hw); | ||
2102 | atl1_set_multi(netdev); | ||
2103 | |||
2104 | ctrl = 0; | ||
2105 | /* turn on magic packet wol */ | ||
2106 | if (wufc & ATL1_WUFC_MAG) | ||
2107 | ctrl = WOL_MAGIC_EN | WOL_MAGIC_PME_EN; | ||
2108 | |||
2109 | /* turn on Link change WOL */ | ||
2110 | if (wufc & ATL1_WUFC_LNKC) | ||
2111 | ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN); | ||
2112 | iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL); | ||
2113 | |||
2114 | /* turn on all-multi mode if wake on multicast is enabled */ | ||
2115 | ctrl = ioread32(hw->hw_addr + REG_MAC_CTRL); | ||
2116 | ctrl &= ~MAC_CTRL_DBG; | ||
2117 | ctrl &= ~MAC_CTRL_PROMIS_EN; | ||
2118 | if (wufc & ATL1_WUFC_MC) | ||
2119 | ctrl |= MAC_CTRL_MC_ALL_EN; | ||
2120 | else | ||
2121 | ctrl &= ~MAC_CTRL_MC_ALL_EN; | ||
2122 | |||
2123 | /* turn on broadcast mode if wake on-BC is enabled */ | ||
2124 | if (wufc & ATL1_WUFC_BC) | ||
2125 | ctrl |= MAC_CTRL_BC_EN; | ||
2126 | else | ||
2127 | ctrl &= ~MAC_CTRL_BC_EN; | ||
2128 | |||
2129 | /* enable RX */ | ||
2130 | ctrl |= MAC_CTRL_RX_EN; | ||
2131 | iowrite32(ctrl, hw->hw_addr + REG_MAC_CTRL); | ||
2132 | pci_enable_wake(pdev, PCI_D3hot, 1); | ||
2133 | pci_enable_wake(pdev, PCI_D3cold, 1); | ||
2134 | } else { | ||
2135 | iowrite32(0, hw->hw_addr + REG_WOL_CTRL); | ||
2136 | pci_enable_wake(pdev, PCI_D3hot, 0); | ||
2137 | pci_enable_wake(pdev, PCI_D3cold, 0); | ||
2138 | } | ||
2139 | |||
2140 | pci_save_state(pdev); | ||
2141 | pci_disable_device(pdev); | ||
2142 | |||
2143 | pci_set_power_state(pdev, PCI_D3hot); | ||
2144 | |||
2145 | return 0; | ||
2046 | } | 2146 | } |
2047 | 2147 | ||
2048 | /* | 2148 | static int atl1_resume(struct pci_dev *pdev) |
2049 | * atl1_pcie_patch - Patch for PCIE module | ||
2050 | */ | ||
2051 | static void atl1_pcie_patch(struct atl1_adapter *adapter) | ||
2052 | { | 2149 | { |
2053 | u32 value; | 2150 | struct net_device *netdev = pci_get_drvdata(pdev); |
2054 | value = 0x6500; | 2151 | struct atl1_adapter *adapter = netdev_priv(netdev); |
2055 | iowrite32(value, adapter->hw.hw_addr + 0x12FC); | 2152 | u32 ret_val; |
2056 | /* pcie flow control mode change */ | 2153 | |
2057 | value = ioread32(adapter->hw.hw_addr + 0x1008); | 2154 | pci_set_power_state(pdev, 0); |
2058 | value |= 0x8000; | 2155 | pci_restore_state(pdev); |
2059 | iowrite32(value, adapter->hw.hw_addr + 0x1008); | 2156 | |
2157 | ret_val = pci_enable_device(pdev); | ||
2158 | pci_enable_wake(pdev, PCI_D3hot, 0); | ||
2159 | pci_enable_wake(pdev, PCI_D3cold, 0); | ||
2160 | |||
2161 | iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL); | ||
2162 | atl1_reset(adapter); | ||
2163 | |||
2164 | if (netif_running(netdev)) | ||
2165 | atl1_up(adapter); | ||
2166 | netif_device_attach(netdev); | ||
2167 | |||
2168 | atl1_via_workaround(adapter); | ||
2169 | |||
2170 | return 0; | ||
2060 | } | 2171 | } |
2172 | #else | ||
2173 | #define atl1_suspend NULL | ||
2174 | #define atl1_resume NULL | ||
2175 | #endif | ||
2061 | 2176 | ||
2062 | /* | 2177 | #ifdef CONFIG_NET_POLL_CONTROLLER |
2063 | * When ACPI resume on some VIA MotherBoard, the Interrupt Disable bit/0x400 | 2178 | static void atl1_poll_controller(struct net_device *netdev) |
2064 | * on PCI Command register is disable. | ||
2065 | * The function enable this bit. | ||
2066 | * Brackett, 2006/03/15 | ||
2067 | */ | ||
2068 | static void atl1_via_workaround(struct atl1_adapter *adapter) | ||
2069 | { | 2179 | { |
2070 | unsigned long value; | 2180 | disable_irq(netdev->irq); |
2071 | 2181 | atl1_intr(netdev->irq, netdev); | |
2072 | value = ioread16(adapter->hw.hw_addr + PCI_COMMAND); | 2182 | enable_irq(netdev->irq); |
2073 | if (value & PCI_COMMAND_INTX_DISABLE) | ||
2074 | value &= ~PCI_COMMAND_INTX_DISABLE; | ||
2075 | iowrite32(value, adapter->hw.hw_addr + PCI_COMMAND); | ||
2076 | } | 2183 | } |
2184 | #endif | ||
2077 | 2185 | ||
2078 | /* | 2186 | /* |
2079 | * atl1_probe - Device Initialization Routine | 2187 | * atl1_probe - Device Initialization Routine |
@@ -2087,7 +2195,7 @@ static void atl1_via_workaround(struct atl1_adapter *adapter) | |||
2087 | * and a hardware reset occur. | 2195 | * and a hardware reset occur. |
2088 | */ | 2196 | */ |
2089 | static int __devinit atl1_probe(struct pci_dev *pdev, | 2197 | static int __devinit atl1_probe(struct pci_dev *pdev, |
2090 | const struct pci_device_id *ent) | 2198 | const struct pci_device_id *ent) |
2091 | { | 2199 | { |
2092 | struct net_device *netdev; | 2200 | struct net_device *netdev; |
2093 | struct atl1_adapter *adapter; | 2201 | struct atl1_adapter *adapter; |
@@ -2141,7 +2249,7 @@ static int __devinit atl1_probe(struct pci_dev *pdev, | |||
2141 | } | 2249 | } |
2142 | /* get device revision number */ | 2250 | /* get device revision number */ |
2143 | adapter->hw.dev_rev = ioread16(adapter->hw.hw_addr + | 2251 | adapter->hw.dev_rev = ioread16(adapter->hw.hw_addr + |
2144 | (REG_MASTER_CTRL + 2)); | 2252 | (REG_MASTER_CTRL + 2)); |
2145 | dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION); | 2253 | dev_info(&pdev->dev, "version %s\n", DRIVER_VERSION); |
2146 | 2254 | ||
2147 | /* set default ring resource counts */ | 2255 | /* set default ring resource counts */ |
@@ -2294,7 +2402,8 @@ static void __devexit atl1_remove(struct pci_dev *pdev) | |||
2294 | * address, we need to save the permanent one. | 2402 | * address, we need to save the permanent one. |
2295 | */ | 2403 | */ |
2296 | if (memcmp(adapter->hw.mac_addr, adapter->hw.perm_mac_addr, ETH_ALEN)) { | 2404 | if (memcmp(adapter->hw.mac_addr, adapter->hw.perm_mac_addr, ETH_ALEN)) { |
2297 | memcpy(adapter->hw.mac_addr, adapter->hw.perm_mac_addr, ETH_ALEN); | 2405 | memcpy(adapter->hw.mac_addr, adapter->hw.perm_mac_addr, |
2406 | ETH_ALEN); | ||
2298 | atl1_set_mac_addr(&adapter->hw); | 2407 | atl1_set_mac_addr(&adapter->hw); |
2299 | } | 2408 | } |
2300 | 2409 | ||
@@ -2306,112 +2415,11 @@ static void __devexit atl1_remove(struct pci_dev *pdev) | |||
2306 | pci_disable_device(pdev); | 2415 | pci_disable_device(pdev); |
2307 | } | 2416 | } |
2308 | 2417 | ||
2309 | #ifdef CONFIG_PM | ||
2310 | static int atl1_suspend(struct pci_dev *pdev, pm_message_t state) | ||
2311 | { | ||
2312 | struct net_device *netdev = pci_get_drvdata(pdev); | ||
2313 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
2314 | struct atl1_hw *hw = &adapter->hw; | ||
2315 | u32 ctrl = 0; | ||
2316 | u32 wufc = adapter->wol; | ||
2317 | |||
2318 | netif_device_detach(netdev); | ||
2319 | if (netif_running(netdev)) | ||
2320 | atl1_down(adapter); | ||
2321 | |||
2322 | atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); | ||
2323 | atl1_read_phy_reg(hw, MII_BMSR, (u16 *) & ctrl); | ||
2324 | if (ctrl & BMSR_LSTATUS) | ||
2325 | wufc &= ~ATL1_WUFC_LNKC; | ||
2326 | |||
2327 | /* reduce speed to 10/100M */ | ||
2328 | if (wufc) { | ||
2329 | atl1_phy_enter_power_saving(hw); | ||
2330 | /* if resume, let driver to re- setup link */ | ||
2331 | hw->phy_configured = false; | ||
2332 | atl1_set_mac_addr(hw); | ||
2333 | atl1_set_multi(netdev); | ||
2334 | |||
2335 | ctrl = 0; | ||
2336 | /* turn on magic packet wol */ | ||
2337 | if (wufc & ATL1_WUFC_MAG) | ||
2338 | ctrl = WOL_MAGIC_EN | WOL_MAGIC_PME_EN; | ||
2339 | |||
2340 | /* turn on Link change WOL */ | ||
2341 | if (wufc & ATL1_WUFC_LNKC) | ||
2342 | ctrl |= (WOL_LINK_CHG_EN | WOL_LINK_CHG_PME_EN); | ||
2343 | iowrite32(ctrl, hw->hw_addr + REG_WOL_CTRL); | ||
2344 | |||
2345 | /* turn on all-multi mode if wake on multicast is enabled */ | ||
2346 | ctrl = ioread32(hw->hw_addr + REG_MAC_CTRL); | ||
2347 | ctrl &= ~MAC_CTRL_DBG; | ||
2348 | ctrl &= ~MAC_CTRL_PROMIS_EN; | ||
2349 | if (wufc & ATL1_WUFC_MC) | ||
2350 | ctrl |= MAC_CTRL_MC_ALL_EN; | ||
2351 | else | ||
2352 | ctrl &= ~MAC_CTRL_MC_ALL_EN; | ||
2353 | |||
2354 | /* turn on broadcast mode if wake on-BC is enabled */ | ||
2355 | if (wufc & ATL1_WUFC_BC) | ||
2356 | ctrl |= MAC_CTRL_BC_EN; | ||
2357 | else | ||
2358 | ctrl &= ~MAC_CTRL_BC_EN; | ||
2359 | |||
2360 | /* enable RX */ | ||
2361 | ctrl |= MAC_CTRL_RX_EN; | ||
2362 | iowrite32(ctrl, hw->hw_addr + REG_MAC_CTRL); | ||
2363 | pci_enable_wake(pdev, PCI_D3hot, 1); | ||
2364 | pci_enable_wake(pdev, PCI_D3cold, 1); /* 4 == D3 cold */ | ||
2365 | } else { | ||
2366 | iowrite32(0, hw->hw_addr + REG_WOL_CTRL); | ||
2367 | pci_enable_wake(pdev, PCI_D3hot, 0); | ||
2368 | pci_enable_wake(pdev, PCI_D3cold, 0); /* 4 == D3 cold */ | ||
2369 | } | ||
2370 | |||
2371 | pci_save_state(pdev); | ||
2372 | pci_disable_device(pdev); | ||
2373 | |||
2374 | pci_set_power_state(pdev, PCI_D3hot); | ||
2375 | |||
2376 | return 0; | ||
2377 | } | ||
2378 | |||
2379 | static int atl1_resume(struct pci_dev *pdev) | ||
2380 | { | ||
2381 | struct net_device *netdev = pci_get_drvdata(pdev); | ||
2382 | struct atl1_adapter *adapter = netdev_priv(netdev); | ||
2383 | u32 ret_val; | ||
2384 | |||
2385 | pci_set_power_state(pdev, 0); | ||
2386 | pci_restore_state(pdev); | ||
2387 | |||
2388 | ret_val = pci_enable_device(pdev); | ||
2389 | pci_enable_wake(pdev, PCI_D3hot, 0); | ||
2390 | pci_enable_wake(pdev, PCI_D3cold, 0); | ||
2391 | |||
2392 | iowrite32(0, adapter->hw.hw_addr + REG_WOL_CTRL); | ||
2393 | atl1_reset(adapter); | ||
2394 | |||
2395 | if (netif_running(netdev)) | ||
2396 | atl1_up(adapter); | ||
2397 | netif_device_attach(netdev); | ||
2398 | |||
2399 | atl1_via_workaround(adapter); | ||
2400 | |||
2401 | return 0; | ||
2402 | } | ||
2403 | #else | ||
2404 | #define atl1_suspend NULL | ||
2405 | #define atl1_resume NULL | ||
2406 | #endif | ||
2407 | |||
2408 | static struct pci_driver atl1_driver = { | 2418 | static struct pci_driver atl1_driver = { |
2409 | .name = atl1_driver_name, | 2419 | .name = atl1_driver_name, |
2410 | .id_table = atl1_pci_tbl, | 2420 | .id_table = atl1_pci_tbl, |
2411 | .probe = atl1_probe, | 2421 | .probe = atl1_probe, |
2412 | .remove = __devexit_p(atl1_remove), | 2422 | .remove = __devexit_p(atl1_remove), |
2413 | /* Power Managment Hooks */ | ||
2414 | /* probably broken right now -- CHS */ | ||
2415 | .suspend = atl1_suspend, | 2423 | .suspend = atl1_suspend, |
2416 | .resume = atl1_resume | 2424 | .resume = atl1_resume |
2417 | }; | 2425 | }; |
diff --git a/drivers/net/ehea/ehea.h b/drivers/net/ehea/ehea.h index f03f070451de..6628fa622e2c 100644 --- a/drivers/net/ehea/ehea.h +++ b/drivers/net/ehea/ehea.h | |||
@@ -39,13 +39,13 @@ | |||
39 | #include <asm/io.h> | 39 | #include <asm/io.h> |
40 | 40 | ||
41 | #define DRV_NAME "ehea" | 41 | #define DRV_NAME "ehea" |
42 | #define DRV_VERSION "EHEA_0067" | 42 | #define DRV_VERSION "EHEA_0070" |
43 | 43 | ||
44 | /* EHEA capability flags */ | 44 | /* eHEA capability flags */ |
45 | #define DLPAR_PORT_ADD_REM 1 | 45 | #define DLPAR_PORT_ADD_REM 1 |
46 | #define DLPAR_MEM_ADD 2 | 46 | #define DLPAR_MEM_ADD 2 |
47 | #define DLPAR_MEM_REM 4 | 47 | #define DLPAR_MEM_REM 4 |
48 | #define EHEA_CAPABILITIES (DLPAR_PORT_ADD_REM) | 48 | #define EHEA_CAPABILITIES (DLPAR_PORT_ADD_REM) |
49 | 49 | ||
50 | #define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ | 50 | #define EHEA_MSG_DEFAULT (NETIF_MSG_LINK | NETIF_MSG_TIMER \ |
51 | | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) | 51 | | NETIF_MSG_RX_ERR | NETIF_MSG_TX_ERR) |
@@ -113,6 +113,8 @@ | |||
113 | /* Memory Regions */ | 113 | /* Memory Regions */ |
114 | #define EHEA_MR_ACC_CTRL 0x00800000 | 114 | #define EHEA_MR_ACC_CTRL 0x00800000 |
115 | 115 | ||
116 | #define EHEA_BUSMAP_START 0x8000000000000000ULL | ||
117 | |||
116 | #define EHEA_WATCH_DOG_TIMEOUT 10*HZ | 118 | #define EHEA_WATCH_DOG_TIMEOUT 10*HZ |
117 | 119 | ||
118 | /* utility functions */ | 120 | /* utility functions */ |
@@ -186,6 +188,12 @@ struct h_epas { | |||
186 | set to 0 if unused */ | 188 | set to 0 if unused */ |
187 | }; | 189 | }; |
188 | 190 | ||
191 | struct ehea_busmap { | ||
192 | unsigned int entries; /* total number of entries */ | ||
193 | unsigned int valid_sections; /* number of valid sections */ | ||
194 | u64 *vaddr; | ||
195 | }; | ||
196 | |||
189 | struct ehea_qp; | 197 | struct ehea_qp; |
190 | struct ehea_cq; | 198 | struct ehea_cq; |
191 | struct ehea_eq; | 199 | struct ehea_eq; |
@@ -382,6 +390,8 @@ struct ehea_adapter { | |||
382 | struct ehea_mr mr; | 390 | struct ehea_mr mr; |
383 | u32 pd; /* protection domain */ | 391 | u32 pd; /* protection domain */ |
384 | u64 max_mc_mac; /* max number of multicast mac addresses */ | 392 | u64 max_mc_mac; /* max number of multicast mac addresses */ |
393 | int active_ports; | ||
394 | struct list_head list; | ||
385 | }; | 395 | }; |
386 | 396 | ||
387 | 397 | ||
@@ -431,6 +441,9 @@ struct port_res_cfg { | |||
431 | int max_entries_rq3; | 441 | int max_entries_rq3; |
432 | }; | 442 | }; |
433 | 443 | ||
444 | enum ehea_flag_bits { | ||
445 | __EHEA_STOP_XFER | ||
446 | }; | ||
434 | 447 | ||
435 | void ehea_set_ethtool_ops(struct net_device *netdev); | 448 | void ehea_set_ethtool_ops(struct net_device *netdev); |
436 | int ehea_sense_port_attr(struct ehea_port *port); | 449 | int ehea_sense_port_attr(struct ehea_port *port); |
diff --git a/drivers/net/ehea/ehea_main.c b/drivers/net/ehea/ehea_main.c index 383144db4d18..1d1571cf322e 100644 --- a/drivers/net/ehea/ehea_main.c +++ b/drivers/net/ehea/ehea_main.c | |||
@@ -79,6 +79,11 @@ MODULE_PARM_DESC(sq_entries, " Number of entries for the Send Queue " | |||
79 | MODULE_PARM_DESC(use_mcs, " 0:NAPI, 1:Multiple receive queues, Default = 1 "); | 79 | MODULE_PARM_DESC(use_mcs, " 0:NAPI, 1:Multiple receive queues, Default = 1 "); |
80 | 80 | ||
81 | static int port_name_cnt = 0; | 81 | static int port_name_cnt = 0; |
82 | static LIST_HEAD(adapter_list); | ||
83 | u64 ehea_driver_flags = 0; | ||
84 | struct workqueue_struct *ehea_driver_wq; | ||
85 | struct work_struct ehea_rereg_mr_task; | ||
86 | |||
82 | 87 | ||
83 | static int __devinit ehea_probe_adapter(struct ibmebus_dev *dev, | 88 | static int __devinit ehea_probe_adapter(struct ibmebus_dev *dev, |
84 | const struct of_device_id *id); | 89 | const struct of_device_id *id); |
@@ -238,13 +243,17 @@ static int ehea_refill_rq_def(struct ehea_port_res *pr, | |||
238 | rwqe->wr_id = EHEA_BMASK_SET(EHEA_WR_ID_TYPE, wqe_type) | 243 | rwqe->wr_id = EHEA_BMASK_SET(EHEA_WR_ID_TYPE, wqe_type) |
239 | | EHEA_BMASK_SET(EHEA_WR_ID_INDEX, index); | 244 | | EHEA_BMASK_SET(EHEA_WR_ID_INDEX, index); |
240 | rwqe->sg_list[0].l_key = pr->recv_mr.lkey; | 245 | rwqe->sg_list[0].l_key = pr->recv_mr.lkey; |
241 | rwqe->sg_list[0].vaddr = (u64)skb->data; | 246 | rwqe->sg_list[0].vaddr = ehea_map_vaddr(skb->data); |
242 | rwqe->sg_list[0].len = packet_size; | 247 | rwqe->sg_list[0].len = packet_size; |
243 | rwqe->data_segments = 1; | 248 | rwqe->data_segments = 1; |
244 | 249 | ||
245 | index++; | 250 | index++; |
246 | index &= max_index_mask; | 251 | index &= max_index_mask; |
252 | |||
253 | if (unlikely(test_bit(__EHEA_STOP_XFER, &ehea_driver_flags))) | ||
254 | goto out; | ||
247 | } | 255 | } |
256 | |||
248 | q_skba->index = index; | 257 | q_skba->index = index; |
249 | 258 | ||
250 | /* Ring doorbell */ | 259 | /* Ring doorbell */ |
@@ -253,7 +262,7 @@ static int ehea_refill_rq_def(struct ehea_port_res *pr, | |||
253 | ehea_update_rq2a(pr->qp, i); | 262 | ehea_update_rq2a(pr->qp, i); |
254 | else | 263 | else |
255 | ehea_update_rq3a(pr->qp, i); | 264 | ehea_update_rq3a(pr->qp, i); |
256 | 265 | out: | |
257 | return ret; | 266 | return ret; |
258 | } | 267 | } |
259 | 268 | ||
@@ -1321,7 +1330,7 @@ static void write_swqe2_TSO(struct sk_buff *skb, | |||
1321 | sg1entry->len = skb_data_size - headersize; | 1330 | sg1entry->len = skb_data_size - headersize; |
1322 | 1331 | ||
1323 | tmp_addr = (u64)(skb->data + headersize); | 1332 | tmp_addr = (u64)(skb->data + headersize); |
1324 | sg1entry->vaddr = tmp_addr; | 1333 | sg1entry->vaddr = ehea_map_vaddr(tmp_addr); |
1325 | swqe->descriptors++; | 1334 | swqe->descriptors++; |
1326 | } | 1335 | } |
1327 | } else | 1336 | } else |
@@ -1352,7 +1361,7 @@ static void write_swqe2_nonTSO(struct sk_buff *skb, | |||
1352 | sg1entry->l_key = lkey; | 1361 | sg1entry->l_key = lkey; |
1353 | sg1entry->len = skb_data_size - SWQE2_MAX_IMM; | 1362 | sg1entry->len = skb_data_size - SWQE2_MAX_IMM; |
1354 | tmp_addr = (u64)(skb->data + SWQE2_MAX_IMM); | 1363 | tmp_addr = (u64)(skb->data + SWQE2_MAX_IMM); |
1355 | sg1entry->vaddr = tmp_addr; | 1364 | sg1entry->vaddr = ehea_map_vaddr(tmp_addr); |
1356 | swqe->descriptors++; | 1365 | swqe->descriptors++; |
1357 | } | 1366 | } |
1358 | } else { | 1367 | } else { |
@@ -1391,7 +1400,7 @@ static inline void write_swqe2_data(struct sk_buff *skb, struct net_device *dev, | |||
1391 | sg1entry->len = frag->size; | 1400 | sg1entry->len = frag->size; |
1392 | tmp_addr = (u64)(page_address(frag->page) | 1401 | tmp_addr = (u64)(page_address(frag->page) |
1393 | + frag->page_offset); | 1402 | + frag->page_offset); |
1394 | sg1entry->vaddr = tmp_addr; | 1403 | sg1entry->vaddr = ehea_map_vaddr(tmp_addr); |
1395 | swqe->descriptors++; | 1404 | swqe->descriptors++; |
1396 | sg1entry_contains_frag_data = 1; | 1405 | sg1entry_contains_frag_data = 1; |
1397 | } | 1406 | } |
@@ -1406,7 +1415,7 @@ static inline void write_swqe2_data(struct sk_buff *skb, struct net_device *dev, | |||
1406 | 1415 | ||
1407 | tmp_addr = (u64)(page_address(frag->page) | 1416 | tmp_addr = (u64)(page_address(frag->page) |
1408 | + frag->page_offset); | 1417 | + frag->page_offset); |
1409 | sgentry->vaddr = tmp_addr; | 1418 | sgentry->vaddr = ehea_map_vaddr(tmp_addr); |
1410 | swqe->descriptors++; | 1419 | swqe->descriptors++; |
1411 | } | 1420 | } |
1412 | } | 1421 | } |
@@ -1878,6 +1887,9 @@ static int ehea_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1878 | ehea_dump(swqe, 512, "swqe"); | 1887 | ehea_dump(swqe, 512, "swqe"); |
1879 | } | 1888 | } |
1880 | 1889 | ||
1890 | if (unlikely(test_bit(__EHEA_STOP_XFER, &ehea_driver_flags))) | ||
1891 | goto out; | ||
1892 | |||
1881 | ehea_post_swqe(pr->qp, swqe); | 1893 | ehea_post_swqe(pr->qp, swqe); |
1882 | pr->tx_packets++; | 1894 | pr->tx_packets++; |
1883 | 1895 | ||
@@ -1892,7 +1904,7 @@ static int ehea_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1892 | } | 1904 | } |
1893 | dev->trans_start = jiffies; | 1905 | dev->trans_start = jiffies; |
1894 | spin_unlock(&pr->xmit_lock); | 1906 | spin_unlock(&pr->xmit_lock); |
1895 | 1907 | out: | |
1896 | return NETDEV_TX_OK; | 1908 | return NETDEV_TX_OK; |
1897 | } | 1909 | } |
1898 | 1910 | ||
@@ -2220,6 +2232,9 @@ out_dereg_bc: | |||
2220 | out_clean_pr: | 2232 | out_clean_pr: |
2221 | ehea_clean_all_portres(port); | 2233 | ehea_clean_all_portres(port); |
2222 | out: | 2234 | out: |
2235 | if (ret) | ||
2236 | ehea_info("Failed starting %s. ret=%i", dev->name, ret); | ||
2237 | |||
2223 | return ret; | 2238 | return ret; |
2224 | } | 2239 | } |
2225 | 2240 | ||
@@ -2259,8 +2274,13 @@ static int ehea_down(struct net_device *dev) | |||
2259 | msleep(1); | 2274 | msleep(1); |
2260 | 2275 | ||
2261 | ehea_broadcast_reg_helper(port, H_DEREG_BCMC); | 2276 | ehea_broadcast_reg_helper(port, H_DEREG_BCMC); |
2262 | ret = ehea_clean_all_portres(port); | ||
2263 | port->state = EHEA_PORT_DOWN; | 2277 | port->state = EHEA_PORT_DOWN; |
2278 | |||
2279 | ret = ehea_clean_all_portres(port); | ||
2280 | if (ret) | ||
2281 | ehea_info("Failed freeing resources for %s. ret=%i", | ||
2282 | dev->name, ret); | ||
2283 | |||
2264 | return ret; | 2284 | return ret; |
2265 | } | 2285 | } |
2266 | 2286 | ||
@@ -2292,15 +2312,11 @@ static void ehea_reset_port(struct work_struct *work) | |||
2292 | netif_stop_queue(dev); | 2312 | netif_stop_queue(dev); |
2293 | netif_poll_disable(dev); | 2313 | netif_poll_disable(dev); |
2294 | 2314 | ||
2295 | ret = ehea_down(dev); | 2315 | ehea_down(dev); |
2296 | if (ret) | ||
2297 | ehea_error("ehea_down failed. not all resources are freed"); | ||
2298 | 2316 | ||
2299 | ret = ehea_up(dev); | 2317 | ret = ehea_up(dev); |
2300 | if (ret) { | 2318 | if (ret) |
2301 | ehea_error("Reset device %s failed: ret=%d", dev->name, ret); | ||
2302 | goto out; | 2319 | goto out; |
2303 | } | ||
2304 | 2320 | ||
2305 | if (netif_msg_timer(port)) | 2321 | if (netif_msg_timer(port)) |
2306 | ehea_info("Device %s resetted successfully", dev->name); | 2322 | ehea_info("Device %s resetted successfully", dev->name); |
@@ -2312,6 +2328,88 @@ out: | |||
2312 | return; | 2328 | return; |
2313 | } | 2329 | } |
2314 | 2330 | ||
2331 | static void ehea_rereg_mrs(struct work_struct *work) | ||
2332 | { | ||
2333 | int ret, i; | ||
2334 | struct ehea_adapter *adapter; | ||
2335 | |||
2336 | ehea_info("LPAR memory enlarged - re-initializing driver"); | ||
2337 | |||
2338 | list_for_each_entry(adapter, &adapter_list, list) | ||
2339 | if (adapter->active_ports) { | ||
2340 | /* Shutdown all ports */ | ||
2341 | for (i = 0; i < EHEA_MAX_PORTS; i++) { | ||
2342 | struct ehea_port *port = adapter->port[i]; | ||
2343 | |||
2344 | if (port) { | ||
2345 | struct net_device *dev = port->netdev; | ||
2346 | |||
2347 | if (dev->flags & IFF_UP) { | ||
2348 | ehea_info("stopping %s", | ||
2349 | dev->name); | ||
2350 | down(&port->port_lock); | ||
2351 | netif_stop_queue(dev); | ||
2352 | netif_poll_disable(dev); | ||
2353 | ehea_down(dev); | ||
2354 | up(&port->port_lock); | ||
2355 | } | ||
2356 | } | ||
2357 | } | ||
2358 | |||
2359 | /* Unregister old memory region */ | ||
2360 | ret = ehea_rem_mr(&adapter->mr); | ||
2361 | if (ret) { | ||
2362 | ehea_error("unregister MR failed - driver" | ||
2363 | " inoperable!"); | ||
2364 | goto out; | ||
2365 | } | ||
2366 | } | ||
2367 | |||
2368 | ehea_destroy_busmap(); | ||
2369 | |||
2370 | ret = ehea_create_busmap(); | ||
2371 | if (ret) | ||
2372 | goto out; | ||
2373 | |||
2374 | clear_bit(__EHEA_STOP_XFER, &ehea_driver_flags); | ||
2375 | |||
2376 | list_for_each_entry(adapter, &adapter_list, list) | ||
2377 | if (adapter->active_ports) { | ||
2378 | /* Register new memory region */ | ||
2379 | ret = ehea_reg_kernel_mr(adapter, &adapter->mr); | ||
2380 | if (ret) { | ||
2381 | ehea_error("register MR failed - driver" | ||
2382 | " inoperable!"); | ||
2383 | goto out; | ||
2384 | } | ||
2385 | |||
2386 | /* Restart all ports */ | ||
2387 | for (i = 0; i < EHEA_MAX_PORTS; i++) { | ||
2388 | struct ehea_port *port = adapter->port[i]; | ||
2389 | |||
2390 | if (port) { | ||
2391 | struct net_device *dev = port->netdev; | ||
2392 | |||
2393 | if (dev->flags & IFF_UP) { | ||
2394 | ehea_info("restarting %s", | ||
2395 | dev->name); | ||
2396 | down(&port->port_lock); | ||
2397 | |||
2398 | ret = ehea_up(dev); | ||
2399 | if (!ret) { | ||
2400 | netif_poll_enable(dev); | ||
2401 | netif_wake_queue(dev); | ||
2402 | } | ||
2403 | |||
2404 | up(&port->port_lock); | ||
2405 | } | ||
2406 | } | ||
2407 | } | ||
2408 | } | ||
2409 | out: | ||
2410 | return; | ||
2411 | } | ||
2412 | |||
2315 | static void ehea_tx_watchdog(struct net_device *dev) | 2413 | static void ehea_tx_watchdog(struct net_device *dev) |
2316 | { | 2414 | { |
2317 | struct ehea_port *port = netdev_priv(dev); | 2415 | struct ehea_port *port = netdev_priv(dev); |
@@ -2573,6 +2671,8 @@ struct ehea_port *ehea_setup_single_port(struct ehea_adapter *adapter, | |||
2573 | ehea_info("%s: Jumbo frames are %sabled", dev->name, | 2671 | ehea_info("%s: Jumbo frames are %sabled", dev->name, |
2574 | jumbo == 1 ? "en" : "dis"); | 2672 | jumbo == 1 ? "en" : "dis"); |
2575 | 2673 | ||
2674 | adapter->active_ports++; | ||
2675 | |||
2576 | return port; | 2676 | return port; |
2577 | 2677 | ||
2578 | out_unreg_port: | 2678 | out_unreg_port: |
@@ -2596,6 +2696,7 @@ static void ehea_shutdown_single_port(struct ehea_port *port) | |||
2596 | ehea_unregister_port(port); | 2696 | ehea_unregister_port(port); |
2597 | kfree(port->mc_list); | 2697 | kfree(port->mc_list); |
2598 | free_netdev(port->netdev); | 2698 | free_netdev(port->netdev); |
2699 | port->adapter->active_ports--; | ||
2599 | } | 2700 | } |
2600 | 2701 | ||
2601 | static int ehea_setup_ports(struct ehea_adapter *adapter) | 2702 | static int ehea_setup_ports(struct ehea_adapter *adapter) |
@@ -2788,6 +2889,8 @@ static int __devinit ehea_probe_adapter(struct ibmebus_dev *dev, | |||
2788 | goto out; | 2889 | goto out; |
2789 | } | 2890 | } |
2790 | 2891 | ||
2892 | list_add(&adapter->list, &adapter_list); | ||
2893 | |||
2791 | adapter->ebus_dev = dev; | 2894 | adapter->ebus_dev = dev; |
2792 | 2895 | ||
2793 | adapter_handle = of_get_property(dev->ofdev.node, "ibm,hea-handle", | 2896 | adapter_handle = of_get_property(dev->ofdev.node, "ibm,hea-handle", |
@@ -2891,7 +2994,10 @@ static int __devexit ehea_remove(struct ibmebus_dev *dev) | |||
2891 | 2994 | ||
2892 | ehea_destroy_eq(adapter->neq); | 2995 | ehea_destroy_eq(adapter->neq); |
2893 | ehea_remove_adapter_mr(adapter); | 2996 | ehea_remove_adapter_mr(adapter); |
2997 | list_del(&adapter->list); | ||
2998 | |||
2894 | kfree(adapter); | 2999 | kfree(adapter); |
3000 | |||
2895 | return 0; | 3001 | return 0; |
2896 | } | 3002 | } |
2897 | 3003 | ||
@@ -2939,9 +3045,18 @@ int __init ehea_module_init(void) | |||
2939 | printk(KERN_INFO "IBM eHEA ethernet device driver (Release %s)\n", | 3045 | printk(KERN_INFO "IBM eHEA ethernet device driver (Release %s)\n", |
2940 | DRV_VERSION); | 3046 | DRV_VERSION); |
2941 | 3047 | ||
3048 | ehea_driver_wq = create_workqueue("ehea_driver_wq"); | ||
3049 | |||
3050 | INIT_WORK(&ehea_rereg_mr_task, ehea_rereg_mrs); | ||
3051 | |||
2942 | ret = check_module_parm(); | 3052 | ret = check_module_parm(); |
2943 | if (ret) | 3053 | if (ret) |
2944 | goto out; | 3054 | goto out; |
3055 | |||
3056 | ret = ehea_create_busmap(); | ||
3057 | if (ret) | ||
3058 | goto out; | ||
3059 | |||
2945 | ret = ibmebus_register_driver(&ehea_driver); | 3060 | ret = ibmebus_register_driver(&ehea_driver); |
2946 | if (ret) { | 3061 | if (ret) { |
2947 | ehea_error("failed registering eHEA device driver on ebus"); | 3062 | ehea_error("failed registering eHEA device driver on ebus"); |
@@ -2965,6 +3080,7 @@ static void __exit ehea_module_exit(void) | |||
2965 | { | 3080 | { |
2966 | driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities); | 3081 | driver_remove_file(&ehea_driver.driver, &driver_attr_capabilities); |
2967 | ibmebus_unregister_driver(&ehea_driver); | 3082 | ibmebus_unregister_driver(&ehea_driver); |
3083 | ehea_destroy_busmap(); | ||
2968 | } | 3084 | } |
2969 | 3085 | ||
2970 | module_init(ehea_module_init); | 3086 | module_init(ehea_module_init); |
diff --git a/drivers/net/ehea/ehea_phyp.h b/drivers/net/ehea/ehea_phyp.h index d17a45a7e717..89b63531ff26 100644 --- a/drivers/net/ehea/ehea_phyp.h +++ b/drivers/net/ehea/ehea_phyp.h | |||
@@ -60,6 +60,9 @@ static inline u32 get_longbusy_msecs(int long_busy_ret_code) | |||
60 | } | 60 | } |
61 | } | 61 | } |
62 | 62 | ||
63 | /* Number of pages which can be registered at once by H_REGISTER_HEA_RPAGES */ | ||
64 | #define EHEA_MAX_RPAGE 512 | ||
65 | |||
63 | /* Notification Event Queue (NEQ) Entry bit masks */ | 66 | /* Notification Event Queue (NEQ) Entry bit masks */ |
64 | #define NEQE_EVENT_CODE EHEA_BMASK_IBM(2, 7) | 67 | #define NEQE_EVENT_CODE EHEA_BMASK_IBM(2, 7) |
65 | #define NEQE_PORTNUM EHEA_BMASK_IBM(32, 47) | 68 | #define NEQE_PORTNUM EHEA_BMASK_IBM(32, 47) |
diff --git a/drivers/net/ehea/ehea_qmr.c b/drivers/net/ehea/ehea_qmr.c index 29eaa46948b0..a36fa6c23fdf 100644 --- a/drivers/net/ehea/ehea_qmr.c +++ b/drivers/net/ehea/ehea_qmr.c | |||
@@ -31,6 +31,13 @@ | |||
31 | #include "ehea_phyp.h" | 31 | #include "ehea_phyp.h" |
32 | #include "ehea_qmr.h" | 32 | #include "ehea_qmr.h" |
33 | 33 | ||
34 | |||
35 | struct ehea_busmap ehea_bmap = { 0, 0, NULL }; | ||
36 | extern u64 ehea_driver_flags; | ||
37 | extern struct workqueue_struct *ehea_driver_wq; | ||
38 | extern struct work_struct ehea_rereg_mr_task; | ||
39 | |||
40 | |||
34 | static void *hw_qpageit_get_inc(struct hw_queue *queue) | 41 | static void *hw_qpageit_get_inc(struct hw_queue *queue) |
35 | { | 42 | { |
36 | void *retvalue = hw_qeit_get(queue); | 43 | void *retvalue = hw_qeit_get(queue); |
@@ -547,18 +554,84 @@ int ehea_destroy_qp(struct ehea_qp *qp) | |||
547 | return 0; | 554 | return 0; |
548 | } | 555 | } |
549 | 556 | ||
557 | int ehea_create_busmap( void ) | ||
558 | { | ||
559 | u64 vaddr = EHEA_BUSMAP_START; | ||
560 | unsigned long abs_max_pfn = 0; | ||
561 | unsigned long sec_max_pfn; | ||
562 | int i; | ||
563 | |||
564 | /* | ||
565 | * Sections are not in ascending order -> Loop over all sections and | ||
566 | * find the highest PFN to compute the required map size. | ||
567 | */ | ||
568 | ehea_bmap.valid_sections = 0; | ||
569 | |||
570 | for (i = 0; i < NR_MEM_SECTIONS; i++) | ||
571 | if (valid_section_nr(i)) { | ||
572 | sec_max_pfn = section_nr_to_pfn(i); | ||
573 | if (sec_max_pfn > abs_max_pfn) | ||
574 | abs_max_pfn = sec_max_pfn; | ||
575 | ehea_bmap.valid_sections++; | ||
576 | } | ||
577 | |||
578 | ehea_bmap.entries = abs_max_pfn / EHEA_PAGES_PER_SECTION + 1; | ||
579 | ehea_bmap.vaddr = vmalloc(ehea_bmap.entries * sizeof(*ehea_bmap.vaddr)); | ||
580 | |||
581 | if (!ehea_bmap.vaddr) | ||
582 | return -ENOMEM; | ||
583 | |||
584 | for (i = 0 ; i < ehea_bmap.entries; i++) { | ||
585 | unsigned long pfn = section_nr_to_pfn(i); | ||
586 | |||
587 | if (pfn_valid(pfn)) { | ||
588 | ehea_bmap.vaddr[i] = vaddr; | ||
589 | vaddr += EHEA_SECTSIZE; | ||
590 | } else | ||
591 | ehea_bmap.vaddr[i] = 0; | ||
592 | } | ||
593 | |||
594 | return 0; | ||
595 | } | ||
596 | |||
597 | void ehea_destroy_busmap( void ) | ||
598 | { | ||
599 | vfree(ehea_bmap.vaddr); | ||
600 | } | ||
601 | |||
602 | u64 ehea_map_vaddr(void *caddr) | ||
603 | { | ||
604 | u64 mapped_addr; | ||
605 | unsigned long index = __pa(caddr) >> SECTION_SIZE_BITS; | ||
606 | |||
607 | if (likely(index < ehea_bmap.entries)) { | ||
608 | mapped_addr = ehea_bmap.vaddr[index]; | ||
609 | if (likely(mapped_addr)) | ||
610 | mapped_addr |= (((unsigned long)caddr) | ||
611 | & (EHEA_SECTSIZE - 1)); | ||
612 | else | ||
613 | mapped_addr = -1; | ||
614 | } else | ||
615 | mapped_addr = -1; | ||
616 | |||
617 | if (unlikely(mapped_addr == -1)) | ||
618 | if (!test_and_set_bit(__EHEA_STOP_XFER, &ehea_driver_flags)) | ||
619 | queue_work(ehea_driver_wq, &ehea_rereg_mr_task); | ||
620 | |||
621 | return mapped_addr; | ||
622 | } | ||
623 | |||
550 | int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr) | 624 | int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr) |
551 | { | 625 | { |
552 | int i, k, ret; | 626 | int ret; |
553 | u64 hret, pt_abs, start, end, nr_pages; | ||
554 | u32 acc_ctrl = EHEA_MR_ACC_CTRL; | ||
555 | u64 *pt; | 627 | u64 *pt; |
628 | void *pg; | ||
629 | u64 hret, pt_abs, i, j, m, mr_len; | ||
630 | u32 acc_ctrl = EHEA_MR_ACC_CTRL; | ||
556 | 631 | ||
557 | start = KERNELBASE; | 632 | mr_len = ehea_bmap.valid_sections * EHEA_SECTSIZE; |
558 | end = (u64)high_memory; | ||
559 | nr_pages = (end - start) / EHEA_PAGESIZE; | ||
560 | 633 | ||
561 | pt = kzalloc(PAGE_SIZE, GFP_KERNEL); | 634 | pt = kzalloc(EHEA_MAX_RPAGE * sizeof(u64), GFP_KERNEL); |
562 | if (!pt) { | 635 | if (!pt) { |
563 | ehea_error("no mem"); | 636 | ehea_error("no mem"); |
564 | ret = -ENOMEM; | 637 | ret = -ENOMEM; |
@@ -566,7 +639,8 @@ int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr) | |||
566 | } | 639 | } |
567 | pt_abs = virt_to_abs(pt); | 640 | pt_abs = virt_to_abs(pt); |
568 | 641 | ||
569 | hret = ehea_h_alloc_resource_mr(adapter->handle, start, end - start, | 642 | hret = ehea_h_alloc_resource_mr(adapter->handle, |
643 | EHEA_BUSMAP_START, mr_len, | ||
570 | acc_ctrl, adapter->pd, | 644 | acc_ctrl, adapter->pd, |
571 | &mr->handle, &mr->lkey); | 645 | &mr->handle, &mr->lkey); |
572 | if (hret != H_SUCCESS) { | 646 | if (hret != H_SUCCESS) { |
@@ -575,49 +649,43 @@ int ehea_reg_kernel_mr(struct ehea_adapter *adapter, struct ehea_mr *mr) | |||
575 | goto out; | 649 | goto out; |
576 | } | 650 | } |
577 | 651 | ||
578 | mr->vaddr = KERNELBASE; | 652 | for (i = 0 ; i < ehea_bmap.entries; i++) |
579 | k = 0; | 653 | if (ehea_bmap.vaddr[i]) { |
580 | 654 | void *sectbase = __va(i << SECTION_SIZE_BITS); | |
581 | while (nr_pages > 0) { | 655 | unsigned long k = 0; |
582 | if (nr_pages > 1) { | 656 | |
583 | u64 num_pages = min(nr_pages, (u64)512); | 657 | for (j = 0; j < (PAGES_PER_SECTION / EHEA_MAX_RPAGE); |
584 | for (i = 0; i < num_pages; i++) | 658 | j++) { |
585 | pt[i] = virt_to_abs((void*)(((u64)start) + | 659 | |
586 | ((k++) * | 660 | for (m = 0; m < EHEA_MAX_RPAGE; m++) { |
587 | EHEA_PAGESIZE))); | 661 | pg = sectbase + ((k++) * EHEA_PAGESIZE); |
588 | 662 | pt[m] = virt_to_abs(pg); | |
589 | hret = ehea_h_register_rpage_mr(adapter->handle, | 663 | } |
590 | mr->handle, 0, | 664 | |
591 | 0, (u64)pt_abs, | 665 | hret = ehea_h_register_rpage_mr(adapter->handle, |
592 | num_pages); | 666 | mr->handle, |
593 | nr_pages -= num_pages; | 667 | 0, 0, pt_abs, |
594 | } else { | 668 | EHEA_MAX_RPAGE); |
595 | u64 abs_adr = virt_to_abs((void*)(((u64)start) + | 669 | if ((hret != H_SUCCESS) |
596 | (k * EHEA_PAGESIZE))); | 670 | && (hret != H_PAGE_REGISTERED)) { |
597 | 671 | ehea_h_free_resource(adapter->handle, | |
598 | hret = ehea_h_register_rpage_mr(adapter->handle, | 672 | mr->handle, |
599 | mr->handle, 0, | 673 | FORCE_FREE); |
600 | 0, abs_adr,1); | 674 | ehea_error("register_rpage_mr failed"); |
601 | nr_pages--; | 675 | ret = -EIO; |
602 | } | 676 | goto out; |
603 | 677 | } | |
604 | if ((hret != H_SUCCESS) && (hret != H_PAGE_REGISTERED)) { | 678 | } |
605 | ehea_h_free_resource(adapter->handle, | ||
606 | mr->handle, FORCE_FREE); | ||
607 | ehea_error("register_rpage_mr failed"); | ||
608 | ret = -EIO; | ||
609 | goto out; | ||
610 | } | 679 | } |
611 | } | ||
612 | 680 | ||
613 | if (hret != H_SUCCESS) { | 681 | if (hret != H_SUCCESS) { |
614 | ehea_h_free_resource(adapter->handle, mr->handle, | 682 | ehea_h_free_resource(adapter->handle, mr->handle, FORCE_FREE); |
615 | FORCE_FREE); | 683 | ehea_error("registering mr failed"); |
616 | ehea_error("register_rpage failed for last page"); | ||
617 | ret = -EIO; | 684 | ret = -EIO; |
618 | goto out; | 685 | goto out; |
619 | } | 686 | } |
620 | 687 | ||
688 | mr->vaddr = EHEA_BUSMAP_START; | ||
621 | mr->adapter = adapter; | 689 | mr->adapter = adapter; |
622 | ret = 0; | 690 | ret = 0; |
623 | out: | 691 | out: |
diff --git a/drivers/net/ehea/ehea_qmr.h b/drivers/net/ehea/ehea_qmr.h index c0eb3e03a102..b71f8452a5e3 100644 --- a/drivers/net/ehea/ehea_qmr.h +++ b/drivers/net/ehea/ehea_qmr.h | |||
@@ -36,8 +36,14 @@ | |||
36 | * page size of ehea hardware queues | 36 | * page size of ehea hardware queues |
37 | */ | 37 | */ |
38 | 38 | ||
39 | #define EHEA_PAGESHIFT 12 | 39 | #define EHEA_PAGESHIFT 12 |
40 | #define EHEA_PAGESIZE 4096UL | 40 | #define EHEA_PAGESIZE (1UL << EHEA_PAGESHIFT) |
41 | #define EHEA_SECTSIZE (1UL << 24) | ||
42 | #define EHEA_PAGES_PER_SECTION (EHEA_SECTSIZE >> PAGE_SHIFT) | ||
43 | |||
44 | #if (1UL << SECTION_SIZE_BITS) < EHEA_SECTSIZE | ||
45 | #error eHEA module can't work if kernel sectionsize < ehea sectionsize | ||
46 | #endif | ||
41 | 47 | ||
42 | /* Some abbreviations used here: | 48 | /* Some abbreviations used here: |
43 | * | 49 | * |
@@ -372,4 +378,8 @@ int ehea_rem_mr(struct ehea_mr *mr); | |||
372 | 378 | ||
373 | void ehea_error_data(struct ehea_adapter *adapter, u64 res_handle); | 379 | void ehea_error_data(struct ehea_adapter *adapter, u64 res_handle); |
374 | 380 | ||
381 | int ehea_create_busmap( void ); | ||
382 | void ehea_destroy_busmap( void ); | ||
383 | u64 ehea_map_vaddr(void *caddr); | ||
384 | |||
375 | #endif /* __EHEA_QMR_H__ */ | 385 | #endif /* __EHEA_QMR_H__ */ |
diff --git a/drivers/net/forcedeth.c b/drivers/net/forcedeth.c index 67046e8c21eb..136827f8dc2e 100644 --- a/drivers/net/forcedeth.c +++ b/drivers/net/forcedeth.c | |||
@@ -550,6 +550,8 @@ union ring_type { | |||
550 | /* PHY defines */ | 550 | /* PHY defines */ |
551 | #define PHY_OUI_MARVELL 0x5043 | 551 | #define PHY_OUI_MARVELL 0x5043 |
552 | #define PHY_OUI_CICADA 0x03f1 | 552 | #define PHY_OUI_CICADA 0x03f1 |
553 | #define PHY_OUI_VITESSE 0x01c1 | ||
554 | #define PHY_OUI_REALTEK 0x01c1 | ||
553 | #define PHYID1_OUI_MASK 0x03ff | 555 | #define PHYID1_OUI_MASK 0x03ff |
554 | #define PHYID1_OUI_SHFT 6 | 556 | #define PHYID1_OUI_SHFT 6 |
555 | #define PHYID2_OUI_MASK 0xfc00 | 557 | #define PHYID2_OUI_MASK 0xfc00 |
@@ -557,12 +559,36 @@ union ring_type { | |||
557 | #define PHYID2_MODEL_MASK 0x03f0 | 559 | #define PHYID2_MODEL_MASK 0x03f0 |
558 | #define PHY_MODEL_MARVELL_E3016 0x220 | 560 | #define PHY_MODEL_MARVELL_E3016 0x220 |
559 | #define PHY_MARVELL_E3016_INITMASK 0x0300 | 561 | #define PHY_MARVELL_E3016_INITMASK 0x0300 |
560 | #define PHY_INIT1 0x0f000 | 562 | #define PHY_CICADA_INIT1 0x0f000 |
561 | #define PHY_INIT2 0x0e00 | 563 | #define PHY_CICADA_INIT2 0x0e00 |
562 | #define PHY_INIT3 0x01000 | 564 | #define PHY_CICADA_INIT3 0x01000 |
563 | #define PHY_INIT4 0x0200 | 565 | #define PHY_CICADA_INIT4 0x0200 |
564 | #define PHY_INIT5 0x0004 | 566 | #define PHY_CICADA_INIT5 0x0004 |
565 | #define PHY_INIT6 0x02000 | 567 | #define PHY_CICADA_INIT6 0x02000 |
568 | #define PHY_VITESSE_INIT_REG1 0x1f | ||
569 | #define PHY_VITESSE_INIT_REG2 0x10 | ||
570 | #define PHY_VITESSE_INIT_REG3 0x11 | ||
571 | #define PHY_VITESSE_INIT_REG4 0x12 | ||
572 | #define PHY_VITESSE_INIT_MSK1 0xc | ||
573 | #define PHY_VITESSE_INIT_MSK2 0x0180 | ||
574 | #define PHY_VITESSE_INIT1 0x52b5 | ||
575 | #define PHY_VITESSE_INIT2 0xaf8a | ||
576 | #define PHY_VITESSE_INIT3 0x8 | ||
577 | #define PHY_VITESSE_INIT4 0x8f8a | ||
578 | #define PHY_VITESSE_INIT5 0xaf86 | ||
579 | #define PHY_VITESSE_INIT6 0x8f86 | ||
580 | #define PHY_VITESSE_INIT7 0xaf82 | ||
581 | #define PHY_VITESSE_INIT8 0x0100 | ||
582 | #define PHY_VITESSE_INIT9 0x8f82 | ||
583 | #define PHY_VITESSE_INIT10 0x0 | ||
584 | #define PHY_REALTEK_INIT_REG1 0x1f | ||
585 | #define PHY_REALTEK_INIT_REG2 0x19 | ||
586 | #define PHY_REALTEK_INIT_REG3 0x13 | ||
587 | #define PHY_REALTEK_INIT1 0x0000 | ||
588 | #define PHY_REALTEK_INIT2 0x8e00 | ||
589 | #define PHY_REALTEK_INIT3 0x0001 | ||
590 | #define PHY_REALTEK_INIT4 0xad17 | ||
591 | |||
566 | #define PHY_GIGABIT 0x0100 | 592 | #define PHY_GIGABIT 0x0100 |
567 | 593 | ||
568 | #define PHY_TIMEOUT 0x1 | 594 | #define PHY_TIMEOUT 0x1 |
@@ -1096,6 +1122,28 @@ static int phy_init(struct net_device *dev) | |||
1096 | return PHY_ERROR; | 1122 | return PHY_ERROR; |
1097 | } | 1123 | } |
1098 | } | 1124 | } |
1125 | if (np->phy_oui == PHY_OUI_REALTEK) { | ||
1126 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT1)) { | ||
1127 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1128 | return PHY_ERROR; | ||
1129 | } | ||
1130 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG2, PHY_REALTEK_INIT2)) { | ||
1131 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1132 | return PHY_ERROR; | ||
1133 | } | ||
1134 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT3)) { | ||
1135 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1136 | return PHY_ERROR; | ||
1137 | } | ||
1138 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG3, PHY_REALTEK_INIT4)) { | ||
1139 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1140 | return PHY_ERROR; | ||
1141 | } | ||
1142 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT1)) { | ||
1143 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1144 | return PHY_ERROR; | ||
1145 | } | ||
1146 | } | ||
1099 | 1147 | ||
1100 | /* set advertise register */ | 1148 | /* set advertise register */ |
1101 | reg = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); | 1149 | reg = mii_rw(dev, np->phyaddr, MII_ADVERTISE, MII_READ); |
@@ -1141,14 +1189,14 @@ static int phy_init(struct net_device *dev) | |||
1141 | /* phy vendor specific configuration */ | 1189 | /* phy vendor specific configuration */ |
1142 | if ((np->phy_oui == PHY_OUI_CICADA) && (phyinterface & PHY_RGMII) ) { | 1190 | if ((np->phy_oui == PHY_OUI_CICADA) && (phyinterface & PHY_RGMII) ) { |
1143 | phy_reserved = mii_rw(dev, np->phyaddr, MII_RESV1, MII_READ); | 1191 | phy_reserved = mii_rw(dev, np->phyaddr, MII_RESV1, MII_READ); |
1144 | phy_reserved &= ~(PHY_INIT1 | PHY_INIT2); | 1192 | phy_reserved &= ~(PHY_CICADA_INIT1 | PHY_CICADA_INIT2); |
1145 | phy_reserved |= (PHY_INIT3 | PHY_INIT4); | 1193 | phy_reserved |= (PHY_CICADA_INIT3 | PHY_CICADA_INIT4); |
1146 | if (mii_rw(dev, np->phyaddr, MII_RESV1, phy_reserved)) { | 1194 | if (mii_rw(dev, np->phyaddr, MII_RESV1, phy_reserved)) { |
1147 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | 1195 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); |
1148 | return PHY_ERROR; | 1196 | return PHY_ERROR; |
1149 | } | 1197 | } |
1150 | phy_reserved = mii_rw(dev, np->phyaddr, MII_NCONFIG, MII_READ); | 1198 | phy_reserved = mii_rw(dev, np->phyaddr, MII_NCONFIG, MII_READ); |
1151 | phy_reserved |= PHY_INIT5; | 1199 | phy_reserved |= PHY_CICADA_INIT5; |
1152 | if (mii_rw(dev, np->phyaddr, MII_NCONFIG, phy_reserved)) { | 1200 | if (mii_rw(dev, np->phyaddr, MII_NCONFIG, phy_reserved)) { |
1153 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | 1201 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); |
1154 | return PHY_ERROR; | 1202 | return PHY_ERROR; |
@@ -1156,12 +1204,106 @@ static int phy_init(struct net_device *dev) | |||
1156 | } | 1204 | } |
1157 | if (np->phy_oui == PHY_OUI_CICADA) { | 1205 | if (np->phy_oui == PHY_OUI_CICADA) { |
1158 | phy_reserved = mii_rw(dev, np->phyaddr, MII_SREVISION, MII_READ); | 1206 | phy_reserved = mii_rw(dev, np->phyaddr, MII_SREVISION, MII_READ); |
1159 | phy_reserved |= PHY_INIT6; | 1207 | phy_reserved |= PHY_CICADA_INIT6; |
1160 | if (mii_rw(dev, np->phyaddr, MII_SREVISION, phy_reserved)) { | 1208 | if (mii_rw(dev, np->phyaddr, MII_SREVISION, phy_reserved)) { |
1161 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | 1209 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); |
1162 | return PHY_ERROR; | 1210 | return PHY_ERROR; |
1163 | } | 1211 | } |
1164 | } | 1212 | } |
1213 | if (np->phy_oui == PHY_OUI_VITESSE) { | ||
1214 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG1, PHY_VITESSE_INIT1)) { | ||
1215 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1216 | return PHY_ERROR; | ||
1217 | } | ||
1218 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG2, PHY_VITESSE_INIT2)) { | ||
1219 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1220 | return PHY_ERROR; | ||
1221 | } | ||
1222 | phy_reserved = mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG4, MII_READ); | ||
1223 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG4, phy_reserved)) { | ||
1224 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1225 | return PHY_ERROR; | ||
1226 | } | ||
1227 | phy_reserved = mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG3, MII_READ); | ||
1228 | phy_reserved &= ~PHY_VITESSE_INIT_MSK1; | ||
1229 | phy_reserved |= PHY_VITESSE_INIT3; | ||
1230 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG3, phy_reserved)) { | ||
1231 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1232 | return PHY_ERROR; | ||
1233 | } | ||
1234 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG2, PHY_VITESSE_INIT4)) { | ||
1235 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1236 | return PHY_ERROR; | ||
1237 | } | ||
1238 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG2, PHY_VITESSE_INIT5)) { | ||
1239 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1240 | return PHY_ERROR; | ||
1241 | } | ||
1242 | phy_reserved = mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG4, MII_READ); | ||
1243 | phy_reserved &= ~PHY_VITESSE_INIT_MSK1; | ||
1244 | phy_reserved |= PHY_VITESSE_INIT3; | ||
1245 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG4, phy_reserved)) { | ||
1246 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1247 | return PHY_ERROR; | ||
1248 | } | ||
1249 | phy_reserved = mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG3, MII_READ); | ||
1250 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG3, phy_reserved)) { | ||
1251 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1252 | return PHY_ERROR; | ||
1253 | } | ||
1254 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG2, PHY_VITESSE_INIT6)) { | ||
1255 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1256 | return PHY_ERROR; | ||
1257 | } | ||
1258 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG2, PHY_VITESSE_INIT7)) { | ||
1259 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1260 | return PHY_ERROR; | ||
1261 | } | ||
1262 | phy_reserved = mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG4, MII_READ); | ||
1263 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG4, phy_reserved)) { | ||
1264 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1265 | return PHY_ERROR; | ||
1266 | } | ||
1267 | phy_reserved = mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG3, MII_READ); | ||
1268 | phy_reserved &= ~PHY_VITESSE_INIT_MSK2; | ||
1269 | phy_reserved |= PHY_VITESSE_INIT8; | ||
1270 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG3, phy_reserved)) { | ||
1271 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1272 | return PHY_ERROR; | ||
1273 | } | ||
1274 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG2, PHY_VITESSE_INIT9)) { | ||
1275 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1276 | return PHY_ERROR; | ||
1277 | } | ||
1278 | if (mii_rw(dev, np->phyaddr, PHY_VITESSE_INIT_REG1, PHY_VITESSE_INIT10)) { | ||
1279 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1280 | return PHY_ERROR; | ||
1281 | } | ||
1282 | } | ||
1283 | if (np->phy_oui == PHY_OUI_REALTEK) { | ||
1284 | /* reset could have cleared these out, set them back */ | ||
1285 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT1)) { | ||
1286 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1287 | return PHY_ERROR; | ||
1288 | } | ||
1289 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG2, PHY_REALTEK_INIT2)) { | ||
1290 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1291 | return PHY_ERROR; | ||
1292 | } | ||
1293 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT3)) { | ||
1294 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1295 | return PHY_ERROR; | ||
1296 | } | ||
1297 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG3, PHY_REALTEK_INIT4)) { | ||
1298 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1299 | return PHY_ERROR; | ||
1300 | } | ||
1301 | if (mii_rw(dev, np->phyaddr, PHY_REALTEK_INIT_REG1, PHY_REALTEK_INIT1)) { | ||
1302 | printk(KERN_INFO "%s: phy init failed.\n", pci_name(np->pci_dev)); | ||
1303 | return PHY_ERROR; | ||
1304 | } | ||
1305 | } | ||
1306 | |||
1165 | /* some phys clear out pause advertisment on reset, set it back */ | 1307 | /* some phys clear out pause advertisment on reset, set it back */ |
1166 | mii_rw(dev, np->phyaddr, MII_ADVERTISE, reg); | 1308 | mii_rw(dev, np->phyaddr, MII_ADVERTISE, reg); |
1167 | 1309 | ||
diff --git a/drivers/net/gianfar_mii.c b/drivers/net/gianfar_mii.c index 5dd34a1a7b89..ac3596f45dd8 100644 --- a/drivers/net/gianfar_mii.c +++ b/drivers/net/gianfar_mii.c | |||
@@ -31,7 +31,6 @@ | |||
31 | #include <linux/mm.h> | 31 | #include <linux/mm.h> |
32 | #include <linux/module.h> | 32 | #include <linux/module.h> |
33 | #include <linux/platform_device.h> | 33 | #include <linux/platform_device.h> |
34 | #include <asm/ocp.h> | ||
35 | #include <linux/crc32.h> | 34 | #include <linux/crc32.h> |
36 | #include <linux/mii.h> | 35 | #include <linux/mii.h> |
37 | #include <linux/phy.h> | 36 | #include <linux/phy.h> |
diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 0e04f7ac3f2e..a4bb0264180a 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c | |||
@@ -17,13 +17,12 @@ | |||
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/netdevice.h> | 18 | #include <linux/netdevice.h> |
19 | #include <linux/etherdevice.h> | 19 | #include <linux/etherdevice.h> |
20 | #include <linux/mii.h> | ||
21 | #include <linux/mutex.h> | ||
22 | #include <linux/dma-mapping.h> | 20 | #include <linux/dma-mapping.h> |
23 | #include <linux/ethtool.h> | ||
24 | #include <linux/platform_device.h> | 21 | #include <linux/platform_device.h> |
22 | #include <linux/phy.h> | ||
25 | 23 | ||
26 | #include <asm/arch/board.h> | 24 | #include <asm/arch/board.h> |
25 | #include <asm/arch/cpu.h> | ||
27 | 26 | ||
28 | #include "macb.h" | 27 | #include "macb.h" |
29 | 28 | ||
@@ -85,172 +84,202 @@ static void __init macb_get_hwaddr(struct macb *bp) | |||
85 | memcpy(bp->dev->dev_addr, addr, sizeof(addr)); | 84 | memcpy(bp->dev->dev_addr, addr, sizeof(addr)); |
86 | } | 85 | } |
87 | 86 | ||
88 | static void macb_enable_mdio(struct macb *bp) | 87 | static int macb_mdio_read(struct mii_bus *bus, int mii_id, int regnum) |
89 | { | 88 | { |
90 | unsigned long flags; | 89 | struct macb *bp = bus->priv; |
91 | u32 reg; | ||
92 | |||
93 | spin_lock_irqsave(&bp->lock, flags); | ||
94 | reg = macb_readl(bp, NCR); | ||
95 | reg |= MACB_BIT(MPE); | ||
96 | macb_writel(bp, NCR, reg); | ||
97 | macb_writel(bp, IER, MACB_BIT(MFD)); | ||
98 | spin_unlock_irqrestore(&bp->lock, flags); | ||
99 | } | ||
100 | |||
101 | static void macb_disable_mdio(struct macb *bp) | ||
102 | { | ||
103 | unsigned long flags; | ||
104 | u32 reg; | ||
105 | |||
106 | spin_lock_irqsave(&bp->lock, flags); | ||
107 | reg = macb_readl(bp, NCR); | ||
108 | reg &= ~MACB_BIT(MPE); | ||
109 | macb_writel(bp, NCR, reg); | ||
110 | macb_writel(bp, IDR, MACB_BIT(MFD)); | ||
111 | spin_unlock_irqrestore(&bp->lock, flags); | ||
112 | } | ||
113 | |||
114 | static int macb_mdio_read(struct net_device *dev, int phy_id, int location) | ||
115 | { | ||
116 | struct macb *bp = netdev_priv(dev); | ||
117 | int value; | 90 | int value; |
118 | 91 | ||
119 | mutex_lock(&bp->mdio_mutex); | ||
120 | |||
121 | macb_enable_mdio(bp); | ||
122 | macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF) | 92 | macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF) |
123 | | MACB_BF(RW, MACB_MAN_READ) | 93 | | MACB_BF(RW, MACB_MAN_READ) |
124 | | MACB_BF(PHYA, phy_id) | 94 | | MACB_BF(PHYA, mii_id) |
125 | | MACB_BF(REGA, location) | 95 | | MACB_BF(REGA, regnum) |
126 | | MACB_BF(CODE, MACB_MAN_CODE))); | 96 | | MACB_BF(CODE, MACB_MAN_CODE))); |
127 | 97 | ||
128 | wait_for_completion(&bp->mdio_complete); | 98 | /* wait for end of transfer */ |
99 | while (!MACB_BFEXT(IDLE, macb_readl(bp, NSR))) | ||
100 | cpu_relax(); | ||
129 | 101 | ||
130 | value = MACB_BFEXT(DATA, macb_readl(bp, MAN)); | 102 | value = MACB_BFEXT(DATA, macb_readl(bp, MAN)); |
131 | macb_disable_mdio(bp); | ||
132 | mutex_unlock(&bp->mdio_mutex); | ||
133 | 103 | ||
134 | return value; | 104 | return value; |
135 | } | 105 | } |
136 | 106 | ||
137 | static void macb_mdio_write(struct net_device *dev, int phy_id, | 107 | static int macb_mdio_write(struct mii_bus *bus, int mii_id, int regnum, |
138 | int location, int val) | 108 | u16 value) |
139 | { | 109 | { |
140 | struct macb *bp = netdev_priv(dev); | 110 | struct macb *bp = bus->priv; |
141 | |||
142 | dev_dbg(&bp->pdev->dev, "mdio_write %02x:%02x <- %04x\n", | ||
143 | phy_id, location, val); | ||
144 | |||
145 | mutex_lock(&bp->mdio_mutex); | ||
146 | macb_enable_mdio(bp); | ||
147 | 111 | ||
148 | macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF) | 112 | macb_writel(bp, MAN, (MACB_BF(SOF, MACB_MAN_SOF) |
149 | | MACB_BF(RW, MACB_MAN_WRITE) | 113 | | MACB_BF(RW, MACB_MAN_WRITE) |
150 | | MACB_BF(PHYA, phy_id) | 114 | | MACB_BF(PHYA, mii_id) |
151 | | MACB_BF(REGA, location) | 115 | | MACB_BF(REGA, regnum) |
152 | | MACB_BF(CODE, MACB_MAN_CODE) | 116 | | MACB_BF(CODE, MACB_MAN_CODE) |
153 | | MACB_BF(DATA, val))); | 117 | | MACB_BF(DATA, value))); |
154 | 118 | ||
155 | wait_for_completion(&bp->mdio_complete); | 119 | /* wait for end of transfer */ |
120 | while (!MACB_BFEXT(IDLE, macb_readl(bp, NSR))) | ||
121 | cpu_relax(); | ||
156 | 122 | ||
157 | macb_disable_mdio(bp); | 123 | return 0; |
158 | mutex_unlock(&bp->mdio_mutex); | ||
159 | } | 124 | } |
160 | 125 | ||
161 | static int macb_phy_probe(struct macb *bp) | 126 | static int macb_mdio_reset(struct mii_bus *bus) |
162 | { | 127 | { |
163 | int phy_address; | 128 | return 0; |
164 | u16 phyid1, phyid2; | 129 | } |
165 | 130 | ||
166 | for (phy_address = 0; phy_address < 32; phy_address++) { | 131 | static void macb_handle_link_change(struct net_device *dev) |
167 | phyid1 = macb_mdio_read(bp->dev, phy_address, MII_PHYSID1); | 132 | { |
168 | phyid2 = macb_mdio_read(bp->dev, phy_address, MII_PHYSID2); | 133 | struct macb *bp = netdev_priv(dev); |
134 | struct phy_device *phydev = bp->phy_dev; | ||
135 | unsigned long flags; | ||
169 | 136 | ||
170 | if (phyid1 != 0xffff && phyid1 != 0x0000 | 137 | int status_change = 0; |
171 | && phyid2 != 0xffff && phyid2 != 0x0000) | 138 | |
172 | break; | 139 | spin_lock_irqsave(&bp->lock, flags); |
140 | |||
141 | if (phydev->link) { | ||
142 | if ((bp->speed != phydev->speed) || | ||
143 | (bp->duplex != phydev->duplex)) { | ||
144 | u32 reg; | ||
145 | |||
146 | reg = macb_readl(bp, NCFGR); | ||
147 | reg &= ~(MACB_BIT(SPD) | MACB_BIT(FD)); | ||
148 | |||
149 | if (phydev->duplex) | ||
150 | reg |= MACB_BIT(FD); | ||
151 | if (phydev->speed) | ||
152 | reg |= MACB_BIT(SPD); | ||
153 | |||
154 | macb_writel(bp, NCFGR, reg); | ||
155 | |||
156 | bp->speed = phydev->speed; | ||
157 | bp->duplex = phydev->duplex; | ||
158 | status_change = 1; | ||
159 | } | ||
173 | } | 160 | } |
174 | 161 | ||
175 | if (phy_address == 32) | 162 | if (phydev->link != bp->link) { |
176 | return -ENODEV; | 163 | if (phydev->link) |
164 | netif_schedule(dev); | ||
165 | else { | ||
166 | bp->speed = 0; | ||
167 | bp->duplex = -1; | ||
168 | } | ||
169 | bp->link = phydev->link; | ||
177 | 170 | ||
178 | dev_info(&bp->pdev->dev, | 171 | status_change = 1; |
179 | "detected PHY at address %d (ID %04x:%04x)\n", | 172 | } |
180 | phy_address, phyid1, phyid2); | ||
181 | 173 | ||
182 | bp->mii.phy_id = phy_address; | 174 | spin_unlock_irqrestore(&bp->lock, flags); |
183 | return 0; | 175 | |
176 | if (status_change) { | ||
177 | if (phydev->link) | ||
178 | printk(KERN_INFO "%s: link up (%d/%s)\n", | ||
179 | dev->name, phydev->speed, | ||
180 | DUPLEX_FULL == phydev->duplex ? "Full":"Half"); | ||
181 | else | ||
182 | printk(KERN_INFO "%s: link down\n", dev->name); | ||
183 | } | ||
184 | } | 184 | } |
185 | 185 | ||
186 | static void macb_set_media(struct macb *bp, int media) | 186 | /* based on au1000_eth. c*/ |
187 | static int macb_mii_probe(struct net_device *dev) | ||
187 | { | 188 | { |
188 | u32 reg; | 189 | struct macb *bp = netdev_priv(dev); |
190 | struct phy_device *phydev = NULL; | ||
191 | struct eth_platform_data *pdata; | ||
192 | int phy_addr; | ||
189 | 193 | ||
190 | spin_lock_irq(&bp->lock); | 194 | /* find the first phy */ |
191 | reg = macb_readl(bp, NCFGR); | 195 | for (phy_addr = 0; phy_addr < PHY_MAX_ADDR; phy_addr++) { |
192 | reg &= ~(MACB_BIT(SPD) | MACB_BIT(FD)); | 196 | if (bp->mii_bus.phy_map[phy_addr]) { |
193 | if (media & (ADVERTISE_100HALF | ADVERTISE_100FULL)) | 197 | phydev = bp->mii_bus.phy_map[phy_addr]; |
194 | reg |= MACB_BIT(SPD); | 198 | break; |
195 | if (media & ADVERTISE_FULL) | 199 | } |
196 | reg |= MACB_BIT(FD); | 200 | } |
197 | macb_writel(bp, NCFGR, reg); | 201 | |
198 | spin_unlock_irq(&bp->lock); | 202 | if (!phydev) { |
203 | printk (KERN_ERR "%s: no PHY found\n", dev->name); | ||
204 | return -1; | ||
205 | } | ||
206 | |||
207 | pdata = bp->pdev->dev.platform_data; | ||
208 | /* TODO : add pin_irq */ | ||
209 | |||
210 | /* attach the mac to the phy */ | ||
211 | if (pdata && pdata->is_rmii) { | ||
212 | phydev = phy_connect(dev, phydev->dev.bus_id, | ||
213 | &macb_handle_link_change, 0, PHY_INTERFACE_MODE_RMII); | ||
214 | } else { | ||
215 | phydev = phy_connect(dev, phydev->dev.bus_id, | ||
216 | &macb_handle_link_change, 0, PHY_INTERFACE_MODE_MII); | ||
217 | } | ||
218 | |||
219 | if (IS_ERR(phydev)) { | ||
220 | printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name); | ||
221 | return PTR_ERR(phydev); | ||
222 | } | ||
223 | |||
224 | /* mask with MAC supported features */ | ||
225 | phydev->supported &= PHY_BASIC_FEATURES; | ||
226 | |||
227 | phydev->advertising = phydev->supported; | ||
228 | |||
229 | bp->link = 0; | ||
230 | bp->speed = 0; | ||
231 | bp->duplex = -1; | ||
232 | bp->phy_dev = phydev; | ||
233 | |||
234 | return 0; | ||
199 | } | 235 | } |
200 | 236 | ||
201 | static void macb_check_media(struct macb *bp, int ok_to_print, int init_media) | 237 | static int macb_mii_init(struct macb *bp) |
202 | { | 238 | { |
203 | struct mii_if_info *mii = &bp->mii; | 239 | struct eth_platform_data *pdata; |
204 | unsigned int old_carrier, new_carrier; | 240 | int err = -ENXIO, i; |
205 | int advertise, lpa, media, duplex; | ||
206 | 241 | ||
207 | /* if forced media, go no further */ | 242 | /* Enable managment port */ |
208 | if (mii->force_media) | 243 | macb_writel(bp, NCR, MACB_BIT(MPE)); |
209 | return; | ||
210 | 244 | ||
211 | /* check current and old link status */ | 245 | bp->mii_bus.name = "MACB_mii_bus", |
212 | old_carrier = netif_carrier_ok(mii->dev) ? 1 : 0; | 246 | bp->mii_bus.read = &macb_mdio_read, |
213 | new_carrier = (unsigned int) mii_link_ok(mii); | 247 | bp->mii_bus.write = &macb_mdio_write, |
248 | bp->mii_bus.reset = &macb_mdio_reset, | ||
249 | bp->mii_bus.id = bp->pdev->id, | ||
250 | bp->mii_bus.priv = bp, | ||
251 | bp->mii_bus.dev = &bp->dev->dev; | ||
252 | pdata = bp->pdev->dev.platform_data; | ||
214 | 253 | ||
215 | /* if carrier state did not change, assume nothing else did */ | 254 | if (pdata) |
216 | if (!init_media && old_carrier == new_carrier) | 255 | bp->mii_bus.phy_mask = pdata->phy_mask; |
217 | return; | ||
218 | 256 | ||
219 | /* no carrier, nothing much to do */ | 257 | bp->mii_bus.irq = kmalloc(sizeof(int)*PHY_MAX_ADDR, GFP_KERNEL); |
220 | if (!new_carrier) { | 258 | if (!bp->mii_bus.irq) { |
221 | netif_carrier_off(mii->dev); | 259 | err = -ENOMEM; |
222 | printk(KERN_INFO "%s: link down\n", mii->dev->name); | 260 | goto err_out; |
223 | return; | ||
224 | } | 261 | } |
225 | 262 | ||
226 | /* | 263 | for (i = 0; i < PHY_MAX_ADDR; i++) |
227 | * we have carrier, see who's on the other end | 264 | bp->mii_bus.irq[i] = PHY_POLL; |
228 | */ | ||
229 | netif_carrier_on(mii->dev); | ||
230 | 265 | ||
231 | /* get MII advertise and LPA values */ | 266 | platform_set_drvdata(bp->dev, &bp->mii_bus); |
232 | if (!init_media && mii->advertising) { | ||
233 | advertise = mii->advertising; | ||
234 | } else { | ||
235 | advertise = mii->mdio_read(mii->dev, mii->phy_id, MII_ADVERTISE); | ||
236 | mii->advertising = advertise; | ||
237 | } | ||
238 | lpa = mii->mdio_read(mii->dev, mii->phy_id, MII_LPA); | ||
239 | 267 | ||
240 | /* figure out media and duplex from advertise and LPA values */ | 268 | if (mdiobus_register(&bp->mii_bus)) |
241 | media = mii_nway_result(lpa & advertise); | 269 | goto err_out_free_mdio_irq; |
242 | duplex = (media & ADVERTISE_FULL) ? 1 : 0; | ||
243 | 270 | ||
244 | if (ok_to_print) | 271 | if (macb_mii_probe(bp->dev) != 0) { |
245 | printk(KERN_INFO "%s: link up, %sMbps, %s-duplex, lpa 0x%04X\n", | 272 | goto err_out_unregister_bus; |
246 | mii->dev->name, | 273 | } |
247 | media & (ADVERTISE_100FULL | ADVERTISE_100HALF) ? "100" : "10", | ||
248 | duplex ? "full" : "half", lpa); | ||
249 | 274 | ||
250 | mii->full_duplex = duplex; | 275 | return 0; |
251 | 276 | ||
252 | /* Let the MAC know about the new link state */ | 277 | err_out_unregister_bus: |
253 | macb_set_media(bp, media); | 278 | mdiobus_unregister(&bp->mii_bus); |
279 | err_out_free_mdio_irq: | ||
280 | kfree(bp->mii_bus.irq); | ||
281 | err_out: | ||
282 | return err; | ||
254 | } | 283 | } |
255 | 284 | ||
256 | static void macb_update_stats(struct macb *bp) | 285 | static void macb_update_stats(struct macb *bp) |
@@ -265,16 +294,6 @@ static void macb_update_stats(struct macb *bp) | |||
265 | *p += __raw_readl(reg); | 294 | *p += __raw_readl(reg); |
266 | } | 295 | } |
267 | 296 | ||
268 | static void macb_periodic_task(struct work_struct *work) | ||
269 | { | ||
270 | struct macb *bp = container_of(work, struct macb, periodic_task.work); | ||
271 | |||
272 | macb_update_stats(bp); | ||
273 | macb_check_media(bp, 1, 0); | ||
274 | |||
275 | schedule_delayed_work(&bp->periodic_task, HZ); | ||
276 | } | ||
277 | |||
278 | static void macb_tx(struct macb *bp) | 297 | static void macb_tx(struct macb *bp) |
279 | { | 298 | { |
280 | unsigned int tail; | 299 | unsigned int tail; |
@@ -519,9 +538,6 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) | |||
519 | spin_lock(&bp->lock); | 538 | spin_lock(&bp->lock); |
520 | 539 | ||
521 | while (status) { | 540 | while (status) { |
522 | if (status & MACB_BIT(MFD)) | ||
523 | complete(&bp->mdio_complete); | ||
524 | |||
525 | /* close possible race with dev_close */ | 541 | /* close possible race with dev_close */ |
526 | if (unlikely(!netif_running(dev))) { | 542 | if (unlikely(!netif_running(dev))) { |
527 | macb_writel(bp, IDR, ~0UL); | 543 | macb_writel(bp, IDR, ~0UL); |
@@ -535,7 +551,8 @@ static irqreturn_t macb_interrupt(int irq, void *dev_id) | |||
535 | * until we have processed the buffers | 551 | * until we have processed the buffers |
536 | */ | 552 | */ |
537 | macb_writel(bp, IDR, MACB_RX_INT_FLAGS); | 553 | macb_writel(bp, IDR, MACB_RX_INT_FLAGS); |
538 | dev_dbg(&bp->pdev->dev, "scheduling RX softirq\n"); | 554 | dev_dbg(&bp->pdev->dev, |
555 | "scheduling RX softirq\n"); | ||
539 | __netif_rx_schedule(dev); | 556 | __netif_rx_schedule(dev); |
540 | } | 557 | } |
541 | } | 558 | } |
@@ -765,7 +782,7 @@ static void macb_init_hw(struct macb *bp) | |||
765 | macb_writel(bp, TBQP, bp->tx_ring_dma); | 782 | macb_writel(bp, TBQP, bp->tx_ring_dma); |
766 | 783 | ||
767 | /* Enable TX and RX */ | 784 | /* Enable TX and RX */ |
768 | macb_writel(bp, NCR, MACB_BIT(RE) | MACB_BIT(TE)); | 785 | macb_writel(bp, NCR, MACB_BIT(RE) | MACB_BIT(TE) | MACB_BIT(MPE)); |
769 | 786 | ||
770 | /* Enable interrupts */ | 787 | /* Enable interrupts */ |
771 | macb_writel(bp, IER, (MACB_BIT(RCOMP) | 788 | macb_writel(bp, IER, (MACB_BIT(RCOMP) |
@@ -776,18 +793,126 @@ static void macb_init_hw(struct macb *bp) | |||
776 | | MACB_BIT(TCOMP) | 793 | | MACB_BIT(TCOMP) |
777 | | MACB_BIT(ISR_ROVR) | 794 | | MACB_BIT(ISR_ROVR) |
778 | | MACB_BIT(HRESP))); | 795 | | MACB_BIT(HRESP))); |
796 | |||
779 | } | 797 | } |
780 | 798 | ||
781 | static void macb_init_phy(struct net_device *dev) | 799 | /* |
800 | * The hash address register is 64 bits long and takes up two | ||
801 | * locations in the memory map. The least significant bits are stored | ||
802 | * in EMAC_HSL and the most significant bits in EMAC_HSH. | ||
803 | * | ||
804 | * The unicast hash enable and the multicast hash enable bits in the | ||
805 | * network configuration register enable the reception of hash matched | ||
806 | * frames. The destination address is reduced to a 6 bit index into | ||
807 | * the 64 bit hash register using the following hash function. The | ||
808 | * hash function is an exclusive or of every sixth bit of the | ||
809 | * destination address. | ||
810 | * | ||
811 | * hi[5] = da[5] ^ da[11] ^ da[17] ^ da[23] ^ da[29] ^ da[35] ^ da[41] ^ da[47] | ||
812 | * hi[4] = da[4] ^ da[10] ^ da[16] ^ da[22] ^ da[28] ^ da[34] ^ da[40] ^ da[46] | ||
813 | * hi[3] = da[3] ^ da[09] ^ da[15] ^ da[21] ^ da[27] ^ da[33] ^ da[39] ^ da[45] | ||
814 | * hi[2] = da[2] ^ da[08] ^ da[14] ^ da[20] ^ da[26] ^ da[32] ^ da[38] ^ da[44] | ||
815 | * hi[1] = da[1] ^ da[07] ^ da[13] ^ da[19] ^ da[25] ^ da[31] ^ da[37] ^ da[43] | ||
816 | * hi[0] = da[0] ^ da[06] ^ da[12] ^ da[18] ^ da[24] ^ da[30] ^ da[36] ^ da[42] | ||
817 | * | ||
818 | * da[0] represents the least significant bit of the first byte | ||
819 | * received, that is, the multicast/unicast indicator, and da[47] | ||
820 | * represents the most significant bit of the last byte received. If | ||
821 | * the hash index, hi[n], points to a bit that is set in the hash | ||
822 | * register then the frame will be matched according to whether the | ||
823 | * frame is multicast or unicast. A multicast match will be signalled | ||
824 | * if the multicast hash enable bit is set, da[0] is 1 and the hash | ||
825 | * index points to a bit set in the hash register. A unicast match | ||
826 | * will be signalled if the unicast hash enable bit is set, da[0] is 0 | ||
827 | * and the hash index points to a bit set in the hash register. To | ||
828 | * receive all multicast frames, the hash register should be set with | ||
829 | * all ones and the multicast hash enable bit should be set in the | ||
830 | * network configuration register. | ||
831 | */ | ||
832 | |||
833 | static inline int hash_bit_value(int bitnr, __u8 *addr) | ||
782 | { | 834 | { |
835 | if (addr[bitnr / 8] & (1 << (bitnr % 8))) | ||
836 | return 1; | ||
837 | return 0; | ||
838 | } | ||
839 | |||
840 | /* | ||
841 | * Return the hash index value for the specified address. | ||
842 | */ | ||
843 | static int hash_get_index(__u8 *addr) | ||
844 | { | ||
845 | int i, j, bitval; | ||
846 | int hash_index = 0; | ||
847 | |||
848 | for (j = 0; j < 6; j++) { | ||
849 | for (i = 0, bitval = 0; i < 8; i++) | ||
850 | bitval ^= hash_bit_value(i*6 + j, addr); | ||
851 | |||
852 | hash_index |= (bitval << j); | ||
853 | } | ||
854 | |||
855 | return hash_index; | ||
856 | } | ||
857 | |||
858 | /* | ||
859 | * Add multicast addresses to the internal multicast-hash table. | ||
860 | */ | ||
861 | static void macb_sethashtable(struct net_device *dev) | ||
862 | { | ||
863 | struct dev_mc_list *curr; | ||
864 | unsigned long mc_filter[2]; | ||
865 | unsigned int i, bitnr; | ||
866 | struct macb *bp = netdev_priv(dev); | ||
867 | |||
868 | mc_filter[0] = mc_filter[1] = 0; | ||
869 | |||
870 | curr = dev->mc_list; | ||
871 | for (i = 0; i < dev->mc_count; i++, curr = curr->next) { | ||
872 | if (!curr) break; /* unexpected end of list */ | ||
873 | |||
874 | bitnr = hash_get_index(curr->dmi_addr); | ||
875 | mc_filter[bitnr >> 5] |= 1 << (bitnr & 31); | ||
876 | } | ||
877 | |||
878 | macb_writel(bp, HRB, mc_filter[0]); | ||
879 | macb_writel(bp, HRT, mc_filter[1]); | ||
880 | } | ||
881 | |||
882 | /* | ||
883 | * Enable/Disable promiscuous and multicast modes. | ||
884 | */ | ||
885 | static void macb_set_rx_mode(struct net_device *dev) | ||
886 | { | ||
887 | unsigned long cfg; | ||
783 | struct macb *bp = netdev_priv(dev); | 888 | struct macb *bp = netdev_priv(dev); |
784 | 889 | ||
785 | /* Set some reasonable default settings */ | 890 | cfg = macb_readl(bp, NCFGR); |
786 | macb_mdio_write(dev, bp->mii.phy_id, MII_ADVERTISE, | 891 | |
787 | ADVERTISE_CSMA | ADVERTISE_ALL); | 892 | if (dev->flags & IFF_PROMISC) |
788 | macb_mdio_write(dev, bp->mii.phy_id, MII_BMCR, | 893 | /* Enable promiscuous mode */ |
789 | (BMCR_SPEED100 | BMCR_ANENABLE | 894 | cfg |= MACB_BIT(CAF); |
790 | | BMCR_ANRESTART | BMCR_FULLDPLX)); | 895 | else if (dev->flags & (~IFF_PROMISC)) |
896 | /* Disable promiscuous mode */ | ||
897 | cfg &= ~MACB_BIT(CAF); | ||
898 | |||
899 | if (dev->flags & IFF_ALLMULTI) { | ||
900 | /* Enable all multicast mode */ | ||
901 | macb_writel(bp, HRB, -1); | ||
902 | macb_writel(bp, HRT, -1); | ||
903 | cfg |= MACB_BIT(NCFGR_MTI); | ||
904 | } else if (dev->mc_count > 0) { | ||
905 | /* Enable specific multicasts */ | ||
906 | macb_sethashtable(dev); | ||
907 | cfg |= MACB_BIT(NCFGR_MTI); | ||
908 | } else if (dev->flags & (~IFF_ALLMULTI)) { | ||
909 | /* Disable all multicast mode */ | ||
910 | macb_writel(bp, HRB, 0); | ||
911 | macb_writel(bp, HRT, 0); | ||
912 | cfg &= ~MACB_BIT(NCFGR_MTI); | ||
913 | } | ||
914 | |||
915 | macb_writel(bp, NCFGR, cfg); | ||
791 | } | 916 | } |
792 | 917 | ||
793 | static int macb_open(struct net_device *dev) | 918 | static int macb_open(struct net_device *dev) |
@@ -797,6 +922,10 @@ static int macb_open(struct net_device *dev) | |||
797 | 922 | ||
798 | dev_dbg(&bp->pdev->dev, "open\n"); | 923 | dev_dbg(&bp->pdev->dev, "open\n"); |
799 | 924 | ||
925 | /* if the phy is not yet register, retry later*/ | ||
926 | if (!bp->phy_dev) | ||
927 | return -EAGAIN; | ||
928 | |||
800 | if (!is_valid_ether_addr(dev->dev_addr)) | 929 | if (!is_valid_ether_addr(dev->dev_addr)) |
801 | return -EADDRNOTAVAIL; | 930 | return -EADDRNOTAVAIL; |
802 | 931 | ||
@@ -810,12 +939,11 @@ static int macb_open(struct net_device *dev) | |||
810 | 939 | ||
811 | macb_init_rings(bp); | 940 | macb_init_rings(bp); |
812 | macb_init_hw(bp); | 941 | macb_init_hw(bp); |
813 | macb_init_phy(dev); | ||
814 | 942 | ||
815 | macb_check_media(bp, 1, 1); | 943 | /* schedule a link state check */ |
816 | netif_start_queue(dev); | 944 | phy_start(bp->phy_dev); |
817 | 945 | ||
818 | schedule_delayed_work(&bp->periodic_task, HZ); | 946 | netif_start_queue(dev); |
819 | 947 | ||
820 | return 0; | 948 | return 0; |
821 | } | 949 | } |
@@ -825,10 +953,11 @@ static int macb_close(struct net_device *dev) | |||
825 | struct macb *bp = netdev_priv(dev); | 953 | struct macb *bp = netdev_priv(dev); |
826 | unsigned long flags; | 954 | unsigned long flags; |
827 | 955 | ||
828 | cancel_rearming_delayed_work(&bp->periodic_task); | ||
829 | |||
830 | netif_stop_queue(dev); | 956 | netif_stop_queue(dev); |
831 | 957 | ||
958 | if (bp->phy_dev) | ||
959 | phy_stop(bp->phy_dev); | ||
960 | |||
832 | spin_lock_irqsave(&bp->lock, flags); | 961 | spin_lock_irqsave(&bp->lock, flags); |
833 | macb_reset_hw(bp); | 962 | macb_reset_hw(bp); |
834 | netif_carrier_off(dev); | 963 | netif_carrier_off(dev); |
@@ -845,6 +974,9 @@ static struct net_device_stats *macb_get_stats(struct net_device *dev) | |||
845 | struct net_device_stats *nstat = &bp->stats; | 974 | struct net_device_stats *nstat = &bp->stats; |
846 | struct macb_stats *hwstat = &bp->hw_stats; | 975 | struct macb_stats *hwstat = &bp->hw_stats; |
847 | 976 | ||
977 | /* read stats from hardware */ | ||
978 | macb_update_stats(bp); | ||
979 | |||
848 | /* Convert HW stats into netdevice stats */ | 980 | /* Convert HW stats into netdevice stats */ |
849 | nstat->rx_errors = (hwstat->rx_fcs_errors + | 981 | nstat->rx_errors = (hwstat->rx_fcs_errors + |
850 | hwstat->rx_align_errors + | 982 | hwstat->rx_align_errors + |
@@ -882,18 +1014,27 @@ static struct net_device_stats *macb_get_stats(struct net_device *dev) | |||
882 | static int macb_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1014 | static int macb_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
883 | { | 1015 | { |
884 | struct macb *bp = netdev_priv(dev); | 1016 | struct macb *bp = netdev_priv(dev); |
1017 | struct phy_device *phydev = bp->phy_dev; | ||
885 | 1018 | ||
886 | return mii_ethtool_gset(&bp->mii, cmd); | 1019 | if (!phydev) |
1020 | return -ENODEV; | ||
1021 | |||
1022 | return phy_ethtool_gset(phydev, cmd); | ||
887 | } | 1023 | } |
888 | 1024 | ||
889 | static int macb_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 1025 | static int macb_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
890 | { | 1026 | { |
891 | struct macb *bp = netdev_priv(dev); | 1027 | struct macb *bp = netdev_priv(dev); |
1028 | struct phy_device *phydev = bp->phy_dev; | ||
1029 | |||
1030 | if (!phydev) | ||
1031 | return -ENODEV; | ||
892 | 1032 | ||
893 | return mii_ethtool_sset(&bp->mii, cmd); | 1033 | return phy_ethtool_sset(phydev, cmd); |
894 | } | 1034 | } |
895 | 1035 | ||
896 | static void macb_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info) | 1036 | static void macb_get_drvinfo(struct net_device *dev, |
1037 | struct ethtool_drvinfo *info) | ||
897 | { | 1038 | { |
898 | struct macb *bp = netdev_priv(dev); | 1039 | struct macb *bp = netdev_priv(dev); |
899 | 1040 | ||
@@ -902,104 +1043,34 @@ static void macb_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *inf | |||
902 | strcpy(info->bus_info, bp->pdev->dev.bus_id); | 1043 | strcpy(info->bus_info, bp->pdev->dev.bus_id); |
903 | } | 1044 | } |
904 | 1045 | ||
905 | static int macb_nway_reset(struct net_device *dev) | ||
906 | { | ||
907 | struct macb *bp = netdev_priv(dev); | ||
908 | return mii_nway_restart(&bp->mii); | ||
909 | } | ||
910 | |||
911 | static struct ethtool_ops macb_ethtool_ops = { | 1046 | static struct ethtool_ops macb_ethtool_ops = { |
912 | .get_settings = macb_get_settings, | 1047 | .get_settings = macb_get_settings, |
913 | .set_settings = macb_set_settings, | 1048 | .set_settings = macb_set_settings, |
914 | .get_drvinfo = macb_get_drvinfo, | 1049 | .get_drvinfo = macb_get_drvinfo, |
915 | .nway_reset = macb_nway_reset, | ||
916 | .get_link = ethtool_op_get_link, | 1050 | .get_link = ethtool_op_get_link, |
917 | }; | 1051 | }; |
918 | 1052 | ||
919 | static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | 1053 | static int macb_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
920 | { | 1054 | { |
921 | struct macb *bp = netdev_priv(dev); | 1055 | struct macb *bp = netdev_priv(dev); |
1056 | struct phy_device *phydev = bp->phy_dev; | ||
922 | 1057 | ||
923 | if (!netif_running(dev)) | 1058 | if (!netif_running(dev)) |
924 | return -EINVAL; | 1059 | return -EINVAL; |
925 | 1060 | ||
926 | return generic_mii_ioctl(&bp->mii, if_mii(rq), cmd, NULL); | 1061 | if (!phydev) |
927 | } | 1062 | return -ENODEV; |
928 | |||
929 | static ssize_t macb_mii_show(const struct device *_dev, char *buf, | ||
930 | unsigned long addr) | ||
931 | { | ||
932 | struct net_device *dev = to_net_dev(_dev); | ||
933 | struct macb *bp = netdev_priv(dev); | ||
934 | ssize_t ret = -EINVAL; | ||
935 | |||
936 | if (netif_running(dev)) { | ||
937 | int value; | ||
938 | value = macb_mdio_read(dev, bp->mii.phy_id, addr); | ||
939 | ret = sprintf(buf, "0x%04x\n", (uint16_t)value); | ||
940 | } | ||
941 | |||
942 | return ret; | ||
943 | } | ||
944 | |||
945 | #define MII_ENTRY(name, addr) \ | ||
946 | static ssize_t show_##name(struct device *_dev, \ | ||
947 | struct device_attribute *attr, \ | ||
948 | char *buf) \ | ||
949 | { \ | ||
950 | return macb_mii_show(_dev, buf, addr); \ | ||
951 | } \ | ||
952 | static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) | ||
953 | |||
954 | MII_ENTRY(bmcr, MII_BMCR); | ||
955 | MII_ENTRY(bmsr, MII_BMSR); | ||
956 | MII_ENTRY(physid1, MII_PHYSID1); | ||
957 | MII_ENTRY(physid2, MII_PHYSID2); | ||
958 | MII_ENTRY(advertise, MII_ADVERTISE); | ||
959 | MII_ENTRY(lpa, MII_LPA); | ||
960 | MII_ENTRY(expansion, MII_EXPANSION); | ||
961 | |||
962 | static struct attribute *macb_mii_attrs[] = { | ||
963 | &dev_attr_bmcr.attr, | ||
964 | &dev_attr_bmsr.attr, | ||
965 | &dev_attr_physid1.attr, | ||
966 | &dev_attr_physid2.attr, | ||
967 | &dev_attr_advertise.attr, | ||
968 | &dev_attr_lpa.attr, | ||
969 | &dev_attr_expansion.attr, | ||
970 | NULL, | ||
971 | }; | ||
972 | |||
973 | static struct attribute_group macb_mii_group = { | ||
974 | .name = "mii", | ||
975 | .attrs = macb_mii_attrs, | ||
976 | }; | ||
977 | |||
978 | static void macb_unregister_sysfs(struct net_device *net) | ||
979 | { | ||
980 | struct device *_dev = &net->dev; | ||
981 | 1063 | ||
982 | sysfs_remove_group(&_dev->kobj, &macb_mii_group); | 1064 | return phy_mii_ioctl(phydev, if_mii(rq), cmd); |
983 | } | 1065 | } |
984 | 1066 | ||
985 | static int macb_register_sysfs(struct net_device *net) | ||
986 | { | ||
987 | struct device *_dev = &net->dev; | ||
988 | int ret; | ||
989 | |||
990 | ret = sysfs_create_group(&_dev->kobj, &macb_mii_group); | ||
991 | if (ret) | ||
992 | printk(KERN_WARNING | ||
993 | "%s: sysfs mii attribute registration failed: %d\n", | ||
994 | net->name, ret); | ||
995 | return ret; | ||
996 | } | ||
997 | static int __devinit macb_probe(struct platform_device *pdev) | 1067 | static int __devinit macb_probe(struct platform_device *pdev) |
998 | { | 1068 | { |
999 | struct eth_platform_data *pdata; | 1069 | struct eth_platform_data *pdata; |
1000 | struct resource *regs; | 1070 | struct resource *regs; |
1001 | struct net_device *dev; | 1071 | struct net_device *dev; |
1002 | struct macb *bp; | 1072 | struct macb *bp; |
1073 | struct phy_device *phydev; | ||
1003 | unsigned long pclk_hz; | 1074 | unsigned long pclk_hz; |
1004 | u32 config; | 1075 | u32 config; |
1005 | int err = -ENXIO; | 1076 | int err = -ENXIO; |
@@ -1073,6 +1144,7 @@ static int __devinit macb_probe(struct platform_device *pdev) | |||
1073 | dev->stop = macb_close; | 1144 | dev->stop = macb_close; |
1074 | dev->hard_start_xmit = macb_start_xmit; | 1145 | dev->hard_start_xmit = macb_start_xmit; |
1075 | dev->get_stats = macb_get_stats; | 1146 | dev->get_stats = macb_get_stats; |
1147 | dev->set_multicast_list = macb_set_rx_mode; | ||
1076 | dev->do_ioctl = macb_ioctl; | 1148 | dev->do_ioctl = macb_ioctl; |
1077 | dev->poll = macb_poll; | 1149 | dev->poll = macb_poll; |
1078 | dev->weight = 64; | 1150 | dev->weight = 64; |
@@ -1080,10 +1152,6 @@ static int __devinit macb_probe(struct platform_device *pdev) | |||
1080 | 1152 | ||
1081 | dev->base_addr = regs->start; | 1153 | dev->base_addr = regs->start; |
1082 | 1154 | ||
1083 | INIT_DELAYED_WORK(&bp->periodic_task, macb_periodic_task); | ||
1084 | mutex_init(&bp->mdio_mutex); | ||
1085 | init_completion(&bp->mdio_complete); | ||
1086 | |||
1087 | /* Set MII management clock divider */ | 1155 | /* Set MII management clock divider */ |
1088 | pclk_hz = clk_get_rate(bp->pclk); | 1156 | pclk_hz = clk_get_rate(bp->pclk); |
1089 | if (pclk_hz <= 20000000) | 1157 | if (pclk_hz <= 20000000) |
@@ -1096,20 +1164,9 @@ static int __devinit macb_probe(struct platform_device *pdev) | |||
1096 | config = MACB_BF(CLK, MACB_CLK_DIV64); | 1164 | config = MACB_BF(CLK, MACB_CLK_DIV64); |
1097 | macb_writel(bp, NCFGR, config); | 1165 | macb_writel(bp, NCFGR, config); |
1098 | 1166 | ||
1099 | bp->mii.dev = dev; | ||
1100 | bp->mii.mdio_read = macb_mdio_read; | ||
1101 | bp->mii.mdio_write = macb_mdio_write; | ||
1102 | bp->mii.phy_id_mask = 0x1f; | ||
1103 | bp->mii.reg_num_mask = 0x1f; | ||
1104 | |||
1105 | macb_get_hwaddr(bp); | 1167 | macb_get_hwaddr(bp); |
1106 | err = macb_phy_probe(bp); | ||
1107 | if (err) { | ||
1108 | dev_err(&pdev->dev, "Failed to detect PHY, aborting.\n"); | ||
1109 | goto err_out_free_irq; | ||
1110 | } | ||
1111 | |||
1112 | pdata = pdev->dev.platform_data; | 1168 | pdata = pdev->dev.platform_data; |
1169 | |||
1113 | if (pdata && pdata->is_rmii) | 1170 | if (pdata && pdata->is_rmii) |
1114 | #if defined(CONFIG_ARCH_AT91) | 1171 | #if defined(CONFIG_ARCH_AT91) |
1115 | macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)) ); | 1172 | macb_writel(bp, USRIO, (MACB_BIT(RMII) | MACB_BIT(CLKEN)) ); |
@@ -1131,9 +1188,11 @@ static int __devinit macb_probe(struct platform_device *pdev) | |||
1131 | goto err_out_free_irq; | 1188 | goto err_out_free_irq; |
1132 | } | 1189 | } |
1133 | 1190 | ||
1134 | platform_set_drvdata(pdev, dev); | 1191 | if (macb_mii_init(bp) != 0) { |
1192 | goto err_out_unregister_netdev; | ||
1193 | } | ||
1135 | 1194 | ||
1136 | macb_register_sysfs(dev); | 1195 | platform_set_drvdata(pdev, dev); |
1137 | 1196 | ||
1138 | printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d " | 1197 | printk(KERN_INFO "%s: Atmel MACB at 0x%08lx irq %d " |
1139 | "(%02x:%02x:%02x:%02x:%02x:%02x)\n", | 1198 | "(%02x:%02x:%02x:%02x:%02x:%02x)\n", |
@@ -1141,8 +1200,15 @@ static int __devinit macb_probe(struct platform_device *pdev) | |||
1141 | dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], | 1200 | dev->dev_addr[0], dev->dev_addr[1], dev->dev_addr[2], |
1142 | dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); | 1201 | dev->dev_addr[3], dev->dev_addr[4], dev->dev_addr[5]); |
1143 | 1202 | ||
1203 | phydev = bp->phy_dev; | ||
1204 | printk(KERN_INFO "%s: attached PHY driver [%s] " | ||
1205 | "(mii_bus:phy_addr=%s, irq=%d)\n", | ||
1206 | dev->name, phydev->drv->name, phydev->dev.bus_id, phydev->irq); | ||
1207 | |||
1144 | return 0; | 1208 | return 0; |
1145 | 1209 | ||
1210 | err_out_unregister_netdev: | ||
1211 | unregister_netdev(dev); | ||
1146 | err_out_free_irq: | 1212 | err_out_free_irq: |
1147 | free_irq(dev->irq, dev); | 1213 | free_irq(dev->irq, dev); |
1148 | err_out_iounmap: | 1214 | err_out_iounmap: |
@@ -1153,7 +1219,9 @@ err_out_disable_clocks: | |||
1153 | clk_put(bp->hclk); | 1219 | clk_put(bp->hclk); |
1154 | #endif | 1220 | #endif |
1155 | clk_disable(bp->pclk); | 1221 | clk_disable(bp->pclk); |
1222 | #ifndef CONFIG_ARCH_AT91 | ||
1156 | err_out_put_pclk: | 1223 | err_out_put_pclk: |
1224 | #endif | ||
1157 | clk_put(bp->pclk); | 1225 | clk_put(bp->pclk); |
1158 | err_out_free_dev: | 1226 | err_out_free_dev: |
1159 | free_netdev(dev); | 1227 | free_netdev(dev); |
@@ -1171,7 +1239,8 @@ static int __devexit macb_remove(struct platform_device *pdev) | |||
1171 | 1239 | ||
1172 | if (dev) { | 1240 | if (dev) { |
1173 | bp = netdev_priv(dev); | 1241 | bp = netdev_priv(dev); |
1174 | macb_unregister_sysfs(dev); | 1242 | mdiobus_unregister(&bp->mii_bus); |
1243 | kfree(bp->mii_bus.irq); | ||
1175 | unregister_netdev(dev); | 1244 | unregister_netdev(dev); |
1176 | free_irq(dev->irq, dev); | 1245 | free_irq(dev->irq, dev); |
1177 | iounmap(bp->regs); | 1246 | iounmap(bp->regs); |
diff --git a/drivers/net/macb.h b/drivers/net/macb.h index b3bb2182edd1..4e3283ebd97c 100644 --- a/drivers/net/macb.h +++ b/drivers/net/macb.h | |||
@@ -383,11 +383,11 @@ struct macb { | |||
383 | 383 | ||
384 | unsigned int rx_pending, tx_pending; | 384 | unsigned int rx_pending, tx_pending; |
385 | 385 | ||
386 | struct delayed_work periodic_task; | 386 | struct mii_bus mii_bus; |
387 | 387 | struct phy_device *phy_dev; | |
388 | struct mutex mdio_mutex; | 388 | unsigned int link; |
389 | struct completion mdio_complete; | 389 | unsigned int speed; |
390 | struct mii_if_info mii; | 390 | unsigned int duplex; |
391 | }; | 391 | }; |
392 | 392 | ||
393 | #endif /* _MACB_H */ | 393 | #endif /* _MACB_H */ |
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index e1732c164a40..deca65330b0f 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -1060,7 +1060,6 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index) | |||
1060 | struct myri10ge_tx_buf *tx = &mgp->tx; | 1060 | struct myri10ge_tx_buf *tx = &mgp->tx; |
1061 | struct sk_buff *skb; | 1061 | struct sk_buff *skb; |
1062 | int idx, len; | 1062 | int idx, len; |
1063 | int limit = 0; | ||
1064 | 1063 | ||
1065 | while (tx->pkt_done != mcp_index) { | 1064 | while (tx->pkt_done != mcp_index) { |
1066 | idx = tx->done & tx->mask; | 1065 | idx = tx->done & tx->mask; |
@@ -1091,11 +1090,6 @@ static inline void myri10ge_tx_done(struct myri10ge_priv *mgp, int mcp_index) | |||
1091 | bus), len, | 1090 | bus), len, |
1092 | PCI_DMA_TODEVICE); | 1091 | PCI_DMA_TODEVICE); |
1093 | } | 1092 | } |
1094 | |||
1095 | /* limit potential for livelock by only handling | ||
1096 | * 2 full tx rings per call */ | ||
1097 | if (unlikely(++limit > 2 * tx->mask)) | ||
1098 | break; | ||
1099 | } | 1093 | } |
1100 | /* start the queue if we've stopped it */ | 1094 | /* start the queue if we've stopped it */ |
1101 | if (netif_queue_stopped(mgp->dev) | 1095 | if (netif_queue_stopped(mgp->dev) |
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 58bbfdd4f901..afef6c0c59fe 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -796,12 +796,14 @@ static void free_shared_mem(struct s2io_nic *nic) | |||
796 | struct mac_info *mac_control; | 796 | struct mac_info *mac_control; |
797 | struct config_param *config; | 797 | struct config_param *config; |
798 | int lst_size, lst_per_page; | 798 | int lst_size, lst_per_page; |
799 | struct net_device *dev = nic->dev; | 799 | struct net_device *dev; |
800 | int page_num = 0; | 800 | int page_num = 0; |
801 | 801 | ||
802 | if (!nic) | 802 | if (!nic) |
803 | return; | 803 | return; |
804 | 804 | ||
805 | dev = nic->dev; | ||
806 | |||
805 | mac_control = &nic->mac_control; | 807 | mac_control = &nic->mac_control; |
806 | config = &nic->config; | 808 | config = &nic->config; |
807 | 809 | ||
diff --git a/drivers/net/usb/cdc_subset.c b/drivers/net/usb/cdc_subset.c index bc62b012602b..943988ed01d8 100644 --- a/drivers/net/usb/cdc_subset.c +++ b/drivers/net/usb/cdc_subset.c | |||
@@ -305,6 +305,9 @@ static const struct usb_device_id products [] = { | |||
305 | USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader | 305 | USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader |
306 | .driver_info = (unsigned long) &blob_info, | 306 | .driver_info = (unsigned long) &blob_info, |
307 | }, { | 307 | }, { |
308 | USB_DEVICE (0x1286, 0x8001), // "blob" bootloader | ||
309 | .driver_info = (unsigned long) &blob_info, | ||
310 | }, { | ||
308 | // Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config | 311 | // Linux Ethernet/RNDIS gadget on pxa210/25x/26x, second config |
309 | // e.g. Gumstix, current OpenZaurus, ... | 312 | // e.g. Gumstix, current OpenZaurus, ... |
310 | USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), | 313 | USB_DEVICE_VER (0x0525, 0xa4a2, 0x0203, 0x0203), |
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 2d3a180dada0..1c54908fdc4c 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -52,6 +52,8 @@ | |||
52 | 52 | ||
53 | #include "airo.h" | 53 | #include "airo.h" |
54 | 54 | ||
55 | #define DRV_NAME "airo" | ||
56 | |||
55 | #ifdef CONFIG_PCI | 57 | #ifdef CONFIG_PCI |
56 | static struct pci_device_id card_ids[] = { | 58 | static struct pci_device_id card_ids[] = { |
57 | { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, }, | 59 | { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, }, |
@@ -71,7 +73,7 @@ static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state); | |||
71 | static int airo_pci_resume(struct pci_dev *pdev); | 73 | static int airo_pci_resume(struct pci_dev *pdev); |
72 | 74 | ||
73 | static struct pci_driver airo_driver = { | 75 | static struct pci_driver airo_driver = { |
74 | .name = "airo", | 76 | .name = DRV_NAME, |
75 | .id_table = card_ids, | 77 | .id_table = card_ids, |
76 | .probe = airo_pci_probe, | 78 | .probe = airo_pci_probe, |
77 | .remove = __devexit_p(airo_pci_remove), | 79 | .remove = __devexit_p(airo_pci_remove), |
@@ -1092,7 +1094,7 @@ static int get_dec_u16( char *buffer, int *start, int limit ); | |||
1092 | static void OUT4500( struct airo_info *, u16 register, u16 value ); | 1094 | static void OUT4500( struct airo_info *, u16 register, u16 value ); |
1093 | static unsigned short IN4500( struct airo_info *, u16 register ); | 1095 | static unsigned short IN4500( struct airo_info *, u16 register ); |
1094 | static u16 setup_card(struct airo_info*, u8 *mac, int lock); | 1096 | static u16 setup_card(struct airo_info*, u8 *mac, int lock); |
1095 | static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ); | 1097 | static int enable_MAC(struct airo_info *ai, int lock); |
1096 | static void disable_MAC(struct airo_info *ai, int lock); | 1098 | static void disable_MAC(struct airo_info *ai, int lock); |
1097 | static void enable_interrupts(struct airo_info*); | 1099 | static void enable_interrupts(struct airo_info*); |
1098 | static void disable_interrupts(struct airo_info*); | 1100 | static void disable_interrupts(struct airo_info*); |
@@ -1250,7 +1252,7 @@ static int flashputbuf(struct airo_info *ai); | |||
1250 | static int flashrestart(struct airo_info *ai,struct net_device *dev); | 1252 | static int flashrestart(struct airo_info *ai,struct net_device *dev); |
1251 | 1253 | ||
1252 | #define airo_print(type, name, fmt, args...) \ | 1254 | #define airo_print(type, name, fmt, args...) \ |
1253 | { printk(type "airo(%s): " fmt "\n", name, ##args); } | 1255 | printk(type DRV_NAME "(%s): " fmt "\n", name, ##args) |
1254 | 1256 | ||
1255 | #define airo_print_info(name, fmt, args...) \ | 1257 | #define airo_print_info(name, fmt, args...) \ |
1256 | airo_print(KERN_INFO, name, fmt, ##args) | 1258 | airo_print(KERN_INFO, name, fmt, ##args) |
@@ -1926,28 +1928,54 @@ static int readStatsRid(struct airo_info*ai, StatsRid *sr, int rid, int lock) { | |||
1926 | return rc; | 1928 | return rc; |
1927 | } | 1929 | } |
1928 | 1930 | ||
1931 | static void try_auto_wep(struct airo_info *ai) | ||
1932 | { | ||
1933 | if (auto_wep && !(ai->flags & FLAG_RADIO_DOWN)) { | ||
1934 | ai->expires = RUN_AT(3*HZ); | ||
1935 | wake_up_interruptible(&ai->thr_wait); | ||
1936 | } | ||
1937 | } | ||
1938 | |||
1929 | static int airo_open(struct net_device *dev) { | 1939 | static int airo_open(struct net_device *dev) { |
1930 | struct airo_info *info = dev->priv; | 1940 | struct airo_info *ai = dev->priv; |
1931 | Resp rsp; | 1941 | int rc = 0; |
1932 | 1942 | ||
1933 | if (test_bit(FLAG_FLASHING, &info->flags)) | 1943 | if (test_bit(FLAG_FLASHING, &ai->flags)) |
1934 | return -EIO; | 1944 | return -EIO; |
1935 | 1945 | ||
1936 | /* Make sure the card is configured. | 1946 | /* Make sure the card is configured. |
1937 | * Wireless Extensions may postpone config changes until the card | 1947 | * Wireless Extensions may postpone config changes until the card |
1938 | * is open (to pipeline changes and speed-up card setup). If | 1948 | * is open (to pipeline changes and speed-up card setup). If |
1939 | * those changes are not yet commited, do it now - Jean II */ | 1949 | * those changes are not yet commited, do it now - Jean II */ |
1940 | if (test_bit (FLAG_COMMIT, &info->flags)) { | 1950 | if (test_bit(FLAG_COMMIT, &ai->flags)) { |
1941 | disable_MAC(info, 1); | 1951 | disable_MAC(ai, 1); |
1942 | writeConfigRid(info, 1); | 1952 | writeConfigRid(ai, 1); |
1943 | } | 1953 | } |
1944 | 1954 | ||
1945 | if (info->wifidev != dev) { | 1955 | if (ai->wifidev != dev) { |
1956 | clear_bit(JOB_DIE, &ai->jobs); | ||
1957 | ai->airo_thread_task = kthread_run(airo_thread, dev, dev->name); | ||
1958 | if (IS_ERR(ai->airo_thread_task)) | ||
1959 | return (int)PTR_ERR(ai->airo_thread_task); | ||
1960 | |||
1961 | rc = request_irq(dev->irq, airo_interrupt, IRQF_SHARED, | ||
1962 | dev->name, dev); | ||
1963 | if (rc) { | ||
1964 | airo_print_err(dev->name, | ||
1965 | "register interrupt %d failed, rc %d", | ||
1966 | dev->irq, rc); | ||
1967 | set_bit(JOB_DIE, &ai->jobs); | ||
1968 | kthread_stop(ai->airo_thread_task); | ||
1969 | return rc; | ||
1970 | } | ||
1971 | |||
1946 | /* Power on the MAC controller (which may have been disabled) */ | 1972 | /* Power on the MAC controller (which may have been disabled) */ |
1947 | clear_bit(FLAG_RADIO_DOWN, &info->flags); | 1973 | clear_bit(FLAG_RADIO_DOWN, &ai->flags); |
1948 | enable_interrupts(info); | 1974 | enable_interrupts(ai); |
1975 | |||
1976 | try_auto_wep(ai); | ||
1949 | } | 1977 | } |
1950 | enable_MAC(info, &rsp, 1); | 1978 | enable_MAC(ai, 1); |
1951 | 1979 | ||
1952 | netif_start_queue(dev); | 1980 | netif_start_queue(dev); |
1953 | return 0; | 1981 | return 0; |
@@ -2338,14 +2366,13 @@ static int airo_set_mac_address(struct net_device *dev, void *p) | |||
2338 | { | 2366 | { |
2339 | struct airo_info *ai = dev->priv; | 2367 | struct airo_info *ai = dev->priv; |
2340 | struct sockaddr *addr = p; | 2368 | struct sockaddr *addr = p; |
2341 | Resp rsp; | ||
2342 | 2369 | ||
2343 | readConfigRid(ai, 1); | 2370 | readConfigRid(ai, 1); |
2344 | memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len); | 2371 | memcpy (ai->config.macAddr, addr->sa_data, dev->addr_len); |
2345 | set_bit (FLAG_COMMIT, &ai->flags); | 2372 | set_bit (FLAG_COMMIT, &ai->flags); |
2346 | disable_MAC(ai, 1); | 2373 | disable_MAC(ai, 1); |
2347 | writeConfigRid (ai, 1); | 2374 | writeConfigRid (ai, 1); |
2348 | enable_MAC(ai, &rsp, 1); | 2375 | enable_MAC(ai, 1); |
2349 | memcpy (ai->dev->dev_addr, addr->sa_data, dev->addr_len); | 2376 | memcpy (ai->dev->dev_addr, addr->sa_data, dev->addr_len); |
2350 | if (ai->wifidev) | 2377 | if (ai->wifidev) |
2351 | memcpy (ai->wifidev->dev_addr, addr->sa_data, dev->addr_len); | 2378 | memcpy (ai->wifidev->dev_addr, addr->sa_data, dev->addr_len); |
@@ -2392,6 +2419,11 @@ static int airo_close(struct net_device *dev) { | |||
2392 | disable_MAC(ai, 1); | 2419 | disable_MAC(ai, 1); |
2393 | #endif | 2420 | #endif |
2394 | disable_interrupts( ai ); | 2421 | disable_interrupts( ai ); |
2422 | |||
2423 | free_irq(dev->irq, dev); | ||
2424 | |||
2425 | set_bit(JOB_DIE, &ai->jobs); | ||
2426 | kthread_stop(ai->airo_thread_task); | ||
2395 | } | 2427 | } |
2396 | return 0; | 2428 | return 0; |
2397 | } | 2429 | } |
@@ -2403,7 +2435,6 @@ void stop_airo_card( struct net_device *dev, int freeres ) | |||
2403 | set_bit(FLAG_RADIO_DOWN, &ai->flags); | 2435 | set_bit(FLAG_RADIO_DOWN, &ai->flags); |
2404 | disable_MAC(ai, 1); | 2436 | disable_MAC(ai, 1); |
2405 | disable_interrupts(ai); | 2437 | disable_interrupts(ai); |
2406 | free_irq( dev->irq, dev ); | ||
2407 | takedown_proc_entry( dev, ai ); | 2438 | takedown_proc_entry( dev, ai ); |
2408 | if (test_bit(FLAG_REGISTERED, &ai->flags)) { | 2439 | if (test_bit(FLAG_REGISTERED, &ai->flags)) { |
2409 | unregister_netdev( dev ); | 2440 | unregister_netdev( dev ); |
@@ -2414,9 +2445,6 @@ void stop_airo_card( struct net_device *dev, int freeres ) | |||
2414 | } | 2445 | } |
2415 | clear_bit(FLAG_REGISTERED, &ai->flags); | 2446 | clear_bit(FLAG_REGISTERED, &ai->flags); |
2416 | } | 2447 | } |
2417 | set_bit(JOB_DIE, &ai->jobs); | ||
2418 | kthread_stop(ai->airo_thread_task); | ||
2419 | |||
2420 | /* | 2448 | /* |
2421 | * Clean out tx queue | 2449 | * Clean out tx queue |
2422 | */ | 2450 | */ |
@@ -2554,8 +2582,7 @@ static int mpi_init_descriptors (struct airo_info *ai) | |||
2554 | * 2) Map PCI memory for issueing commands. | 2582 | * 2) Map PCI memory for issueing commands. |
2555 | * 3) Allocate memory (shared) to send and receive ethernet frames. | 2583 | * 3) Allocate memory (shared) to send and receive ethernet frames. |
2556 | */ | 2584 | */ |
2557 | static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci, | 2585 | static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci) |
2558 | const char *name) | ||
2559 | { | 2586 | { |
2560 | unsigned long mem_start, mem_len, aux_start, aux_len; | 2587 | unsigned long mem_start, mem_len, aux_start, aux_len; |
2561 | int rc = -1; | 2588 | int rc = -1; |
@@ -2569,35 +2596,35 @@ static int mpi_map_card(struct airo_info *ai, struct pci_dev *pci, | |||
2569 | aux_start = pci_resource_start(pci, 2); | 2596 | aux_start = pci_resource_start(pci, 2); |
2570 | aux_len = AUXMEMSIZE; | 2597 | aux_len = AUXMEMSIZE; |
2571 | 2598 | ||
2572 | if (!request_mem_region(mem_start, mem_len, name)) { | 2599 | if (!request_mem_region(mem_start, mem_len, DRV_NAME)) { |
2573 | airo_print_err(ai->dev->name, "Couldn't get region %x[%x] for %s", | 2600 | airo_print_err("", "Couldn't get region %x[%x]", |
2574 | (int)mem_start, (int)mem_len, name); | 2601 | (int)mem_start, (int)mem_len); |
2575 | goto out; | 2602 | goto out; |
2576 | } | 2603 | } |
2577 | if (!request_mem_region(aux_start, aux_len, name)) { | 2604 | if (!request_mem_region(aux_start, aux_len, DRV_NAME)) { |
2578 | airo_print_err(ai->dev->name, "Couldn't get region %x[%x] for %s", | 2605 | airo_print_err("", "Couldn't get region %x[%x]", |
2579 | (int)aux_start, (int)aux_len, name); | 2606 | (int)aux_start, (int)aux_len); |
2580 | goto free_region1; | 2607 | goto free_region1; |
2581 | } | 2608 | } |
2582 | 2609 | ||
2583 | ai->pcimem = ioremap(mem_start, mem_len); | 2610 | ai->pcimem = ioremap(mem_start, mem_len); |
2584 | if (!ai->pcimem) { | 2611 | if (!ai->pcimem) { |
2585 | airo_print_err(ai->dev->name, "Couldn't map region %x[%x] for %s", | 2612 | airo_print_err("", "Couldn't map region %x[%x]", |
2586 | (int)mem_start, (int)mem_len, name); | 2613 | (int)mem_start, (int)mem_len); |
2587 | goto free_region2; | 2614 | goto free_region2; |
2588 | } | 2615 | } |
2589 | ai->pciaux = ioremap(aux_start, aux_len); | 2616 | ai->pciaux = ioremap(aux_start, aux_len); |
2590 | if (!ai->pciaux) { | 2617 | if (!ai->pciaux) { |
2591 | airo_print_err(ai->dev->name, "Couldn't map region %x[%x] for %s", | 2618 | airo_print_err("", "Couldn't map region %x[%x]", |
2592 | (int)aux_start, (int)aux_len, name); | 2619 | (int)aux_start, (int)aux_len); |
2593 | goto free_memmap; | 2620 | goto free_memmap; |
2594 | } | 2621 | } |
2595 | 2622 | ||
2596 | /* Reserve PKTSIZE for each fid and 2K for the Rids */ | 2623 | /* Reserve PKTSIZE for each fid and 2K for the Rids */ |
2597 | ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma); | 2624 | ai->shared = pci_alloc_consistent(pci, PCI_SHARED_LEN, &ai->shared_dma); |
2598 | if (!ai->shared) { | 2625 | if (!ai->shared) { |
2599 | airo_print_err(ai->dev->name, "Couldn't alloc_consistent %d", | 2626 | airo_print_err("", "Couldn't alloc_consistent %d", |
2600 | PCI_SHARED_LEN); | 2627 | PCI_SHARED_LEN); |
2601 | goto free_auxmap; | 2628 | goto free_auxmap; |
2602 | } | 2629 | } |
2603 | 2630 | ||
@@ -2742,7 +2769,7 @@ static int airo_networks_allocate(struct airo_info *ai) | |||
2742 | kzalloc(AIRO_MAX_NETWORK_COUNT * sizeof(BSSListElement), | 2769 | kzalloc(AIRO_MAX_NETWORK_COUNT * sizeof(BSSListElement), |
2743 | GFP_KERNEL); | 2770 | GFP_KERNEL); |
2744 | if (!ai->networks) { | 2771 | if (!ai->networks) { |
2745 | airo_print_warn(ai->dev->name, "Out of memory allocating beacons"); | 2772 | airo_print_warn("", "Out of memory allocating beacons"); |
2746 | return -ENOMEM; | 2773 | return -ENOMEM; |
2747 | } | 2774 | } |
2748 | 2775 | ||
@@ -2770,7 +2797,6 @@ static int airo_test_wpa_capable(struct airo_info *ai) | |||
2770 | { | 2797 | { |
2771 | int status; | 2798 | int status; |
2772 | CapabilityRid cap_rid; | 2799 | CapabilityRid cap_rid; |
2773 | const char *name = ai->dev->name; | ||
2774 | 2800 | ||
2775 | status = readCapabilityRid(ai, &cap_rid, 1); | 2801 | status = readCapabilityRid(ai, &cap_rid, 1); |
2776 | if (status != SUCCESS) return 0; | 2802 | if (status != SUCCESS) return 0; |
@@ -2778,12 +2804,12 @@ static int airo_test_wpa_capable(struct airo_info *ai) | |||
2778 | /* Only firmware versions 5.30.17 or better can do WPA */ | 2804 | /* Only firmware versions 5.30.17 or better can do WPA */ |
2779 | if ((cap_rid.softVer > 0x530) | 2805 | if ((cap_rid.softVer > 0x530) |
2780 | || ((cap_rid.softVer == 0x530) && (cap_rid.softSubVer >= 17))) { | 2806 | || ((cap_rid.softVer == 0x530) && (cap_rid.softSubVer >= 17))) { |
2781 | airo_print_info(name, "WPA is supported."); | 2807 | airo_print_info("", "WPA is supported."); |
2782 | return 1; | 2808 | return 1; |
2783 | } | 2809 | } |
2784 | 2810 | ||
2785 | /* No WPA support */ | 2811 | /* No WPA support */ |
2786 | airo_print_info(name, "WPA unsupported (only firmware versions 5.30.17" | 2812 | airo_print_info("", "WPA unsupported (only firmware versions 5.30.17" |
2787 | " and greater support WPA. Detected %s)", cap_rid.prodVer); | 2813 | " and greater support WPA. Detected %s)", cap_rid.prodVer); |
2788 | return 0; | 2814 | return 0; |
2789 | } | 2815 | } |
@@ -2797,23 +2823,19 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2797 | int i, rc; | 2823 | int i, rc; |
2798 | 2824 | ||
2799 | /* Create the network device object. */ | 2825 | /* Create the network device object. */ |
2800 | dev = alloc_etherdev(sizeof(*ai)); | 2826 | dev = alloc_netdev(sizeof(*ai), "", ether_setup); |
2801 | if (!dev) { | 2827 | if (!dev) { |
2802 | airo_print_err("", "Couldn't alloc_etherdev"); | 2828 | airo_print_err("", "Couldn't alloc_etherdev"); |
2803 | return NULL; | 2829 | return NULL; |
2804 | } | ||
2805 | if (dev_alloc_name(dev, dev->name) < 0) { | ||
2806 | airo_print_err("", "Couldn't get name!"); | ||
2807 | goto err_out_free; | ||
2808 | } | 2830 | } |
2809 | 2831 | ||
2810 | ai = dev->priv; | 2832 | ai = dev->priv; |
2811 | ai->wifidev = NULL; | 2833 | ai->wifidev = NULL; |
2812 | ai->flags = 0; | 2834 | ai->flags = 1 << FLAG_RADIO_DOWN; |
2813 | ai->jobs = 0; | 2835 | ai->jobs = 0; |
2814 | ai->dev = dev; | 2836 | ai->dev = dev; |
2815 | if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { | 2837 | if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { |
2816 | airo_print_dbg(dev->name, "Found an MPI350 card"); | 2838 | airo_print_dbg("", "Found an MPI350 card"); |
2817 | set_bit(FLAG_MPI, &ai->flags); | 2839 | set_bit(FLAG_MPI, &ai->flags); |
2818 | } | 2840 | } |
2819 | spin_lock_init(&ai->aux_lock); | 2841 | spin_lock_init(&ai->aux_lock); |
@@ -2821,14 +2843,11 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2821 | ai->config.len = 0; | 2843 | ai->config.len = 0; |
2822 | ai->pci = pci; | 2844 | ai->pci = pci; |
2823 | init_waitqueue_head (&ai->thr_wait); | 2845 | init_waitqueue_head (&ai->thr_wait); |
2824 | ai->airo_thread_task = kthread_run(airo_thread, dev, dev->name); | ||
2825 | if (IS_ERR(ai->airo_thread_task)) | ||
2826 | goto err_out_free; | ||
2827 | ai->tfm = NULL; | 2846 | ai->tfm = NULL; |
2828 | add_airo_dev(ai); | 2847 | add_airo_dev(ai); |
2829 | 2848 | ||
2830 | if (airo_networks_allocate (ai)) | 2849 | if (airo_networks_allocate (ai)) |
2831 | goto err_out_thr; | 2850 | goto err_out_free; |
2832 | airo_networks_initialize (ai); | 2851 | airo_networks_initialize (ai); |
2833 | 2852 | ||
2834 | /* The Airo-specific entries in the device structure. */ | 2853 | /* The Airo-specific entries in the device structure. */ |
@@ -2851,27 +2870,22 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2851 | dev->base_addr = port; | 2870 | dev->base_addr = port; |
2852 | 2871 | ||
2853 | SET_NETDEV_DEV(dev, dmdev); | 2872 | SET_NETDEV_DEV(dev, dmdev); |
2873 | SET_MODULE_OWNER(dev); | ||
2854 | 2874 | ||
2855 | reset_card (dev, 1); | 2875 | reset_card (dev, 1); |
2856 | msleep(400); | 2876 | msleep(400); |
2857 | 2877 | ||
2858 | rc = request_irq( dev->irq, airo_interrupt, IRQF_SHARED, dev->name, dev ); | ||
2859 | if (rc) { | ||
2860 | airo_print_err(dev->name, "register interrupt %d failed, rc %d", | ||
2861 | irq, rc); | ||
2862 | goto err_out_nets; | ||
2863 | } | ||
2864 | if (!is_pcmcia) { | 2878 | if (!is_pcmcia) { |
2865 | if (!request_region( dev->base_addr, 64, dev->name )) { | 2879 | if (!request_region(dev->base_addr, 64, DRV_NAME)) { |
2866 | rc = -EBUSY; | 2880 | rc = -EBUSY; |
2867 | airo_print_err(dev->name, "Couldn't request region"); | 2881 | airo_print_err(dev->name, "Couldn't request region"); |
2868 | goto err_out_irq; | 2882 | goto err_out_nets; |
2869 | } | 2883 | } |
2870 | } | 2884 | } |
2871 | 2885 | ||
2872 | if (test_bit(FLAG_MPI,&ai->flags)) { | 2886 | if (test_bit(FLAG_MPI,&ai->flags)) { |
2873 | if (mpi_map_card(ai, pci, dev->name)) { | 2887 | if (mpi_map_card(ai, pci)) { |
2874 | airo_print_err(dev->name, "Could not map memory"); | 2888 | airo_print_err("", "Could not map memory"); |
2875 | goto err_out_res; | 2889 | goto err_out_res; |
2876 | } | 2890 | } |
2877 | } | 2891 | } |
@@ -2899,6 +2913,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2899 | ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra); | 2913 | ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra); |
2900 | } | 2914 | } |
2901 | 2915 | ||
2916 | strcpy(dev->name, "eth%d"); | ||
2902 | rc = register_netdev(dev); | 2917 | rc = register_netdev(dev); |
2903 | if (rc) { | 2918 | if (rc) { |
2904 | airo_print_err(dev->name, "Couldn't register_netdev"); | 2919 | airo_print_err(dev->name, "Couldn't register_netdev"); |
@@ -2921,8 +2936,6 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2921 | if (setup_proc_entry(dev, dev->priv) < 0) | 2936 | if (setup_proc_entry(dev, dev->priv) < 0) |
2922 | goto err_out_wifi; | 2937 | goto err_out_wifi; |
2923 | 2938 | ||
2924 | netif_start_queue(dev); | ||
2925 | SET_MODULE_OWNER(dev); | ||
2926 | return dev; | 2939 | return dev; |
2927 | 2940 | ||
2928 | err_out_wifi: | 2941 | err_out_wifi: |
@@ -2940,14 +2953,9 @@ err_out_map: | |||
2940 | err_out_res: | 2953 | err_out_res: |
2941 | if (!is_pcmcia) | 2954 | if (!is_pcmcia) |
2942 | release_region( dev->base_addr, 64 ); | 2955 | release_region( dev->base_addr, 64 ); |
2943 | err_out_irq: | ||
2944 | free_irq(dev->irq, dev); | ||
2945 | err_out_nets: | 2956 | err_out_nets: |
2946 | airo_networks_free(ai); | 2957 | airo_networks_free(ai); |
2947 | err_out_thr: | ||
2948 | del_airo_dev(ai); | 2958 | del_airo_dev(ai); |
2949 | set_bit(JOB_DIE, &ai->jobs); | ||
2950 | kthread_stop(ai->airo_thread_task); | ||
2951 | err_out_free: | 2959 | err_out_free: |
2952 | free_netdev(dev); | 2960 | free_netdev(dev); |
2953 | return NULL; | 2961 | return NULL; |
@@ -3529,9 +3537,11 @@ static u16 IN4500( struct airo_info *ai, u16 reg ) { | |||
3529 | return rc; | 3537 | return rc; |
3530 | } | 3538 | } |
3531 | 3539 | ||
3532 | static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ) { | 3540 | static int enable_MAC(struct airo_info *ai, int lock) |
3541 | { | ||
3533 | int rc; | 3542 | int rc; |
3534 | Cmd cmd; | 3543 | Cmd cmd; |
3544 | Resp rsp; | ||
3535 | 3545 | ||
3536 | /* FLAG_RADIO_OFF : Radio disabled via /proc or Wireless Extensions | 3546 | /* FLAG_RADIO_OFF : Radio disabled via /proc or Wireless Extensions |
3537 | * FLAG_RADIO_DOWN : Radio disabled via "ifconfig ethX down" | 3547 | * FLAG_RADIO_DOWN : Radio disabled via "ifconfig ethX down" |
@@ -3547,7 +3557,7 @@ static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ) { | |||
3547 | if (!test_bit(FLAG_ENABLED, &ai->flags)) { | 3557 | if (!test_bit(FLAG_ENABLED, &ai->flags)) { |
3548 | memset(&cmd, 0, sizeof(cmd)); | 3558 | memset(&cmd, 0, sizeof(cmd)); |
3549 | cmd.cmd = MAC_ENABLE; | 3559 | cmd.cmd = MAC_ENABLE; |
3550 | rc = issuecommand(ai, &cmd, rsp); | 3560 | rc = issuecommand(ai, &cmd, &rsp); |
3551 | if (rc == SUCCESS) | 3561 | if (rc == SUCCESS) |
3552 | set_bit(FLAG_ENABLED, &ai->flags); | 3562 | set_bit(FLAG_ENABLED, &ai->flags); |
3553 | } else | 3563 | } else |
@@ -3557,8 +3567,12 @@ static int enable_MAC( struct airo_info *ai, Resp *rsp, int lock ) { | |||
3557 | up(&ai->sem); | 3567 | up(&ai->sem); |
3558 | 3568 | ||
3559 | if (rc) | 3569 | if (rc) |
3560 | airo_print_err(ai->dev->name, "%s: Cannot enable MAC, err=%d", | 3570 | airo_print_err(ai->dev->name, "Cannot enable MAC"); |
3561 | __FUNCTION__, rc); | 3571 | else if ((rsp.status & 0xFF00) != 0) { |
3572 | airo_print_err(ai->dev->name, "Bad MAC enable reason=%x, " | ||
3573 | "rid=%x, offset=%d", rsp.rsp0, rsp.rsp1, rsp.rsp2); | ||
3574 | rc = ERROR; | ||
3575 | } | ||
3562 | return rc; | 3576 | return rc; |
3563 | } | 3577 | } |
3564 | 3578 | ||
@@ -3902,12 +3916,9 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) | |||
3902 | if ( status != SUCCESS ) return ERROR; | 3916 | if ( status != SUCCESS ) return ERROR; |
3903 | } | 3917 | } |
3904 | 3918 | ||
3905 | status = enable_MAC(ai, &rsp, lock); | 3919 | status = enable_MAC(ai, lock); |
3906 | if ( status != SUCCESS || (rsp.status & 0xFF00) != 0) { | 3920 | if (status != SUCCESS) |
3907 | airo_print_err(ai->dev->name, "Bad MAC enable reason = %x, rid = %x," | ||
3908 | " offset = %d", rsp.rsp0, rsp.rsp1, rsp.rsp2 ); | ||
3909 | return ERROR; | 3921 | return ERROR; |
3910 | } | ||
3911 | 3922 | ||
3912 | /* Grab the initial wep key, we gotta save it for auto_wep */ | 3923 | /* Grab the initial wep key, we gotta save it for auto_wep */ |
3913 | rc = readWepKeyRid(ai, &wkr, 1, lock); | 3924 | rc = readWepKeyRid(ai, &wkr, 1, lock); |
@@ -3919,10 +3930,7 @@ static u16 setup_card(struct airo_info *ai, u8 *mac, int lock) | |||
3919 | rc = readWepKeyRid(ai, &wkr, 0, lock); | 3930 | rc = readWepKeyRid(ai, &wkr, 0, lock); |
3920 | } while(lastindex != wkr.kindex); | 3931 | } while(lastindex != wkr.kindex); |
3921 | 3932 | ||
3922 | if (auto_wep) { | 3933 | try_auto_wep(ai); |
3923 | ai->expires = RUN_AT(3*HZ); | ||
3924 | wake_up_interruptible(&ai->thr_wait); | ||
3925 | } | ||
3926 | 3934 | ||
3927 | return SUCCESS; | 3935 | return SUCCESS; |
3928 | } | 3936 | } |
@@ -4004,7 +4012,7 @@ static int bap_setup(struct airo_info *ai, u16 rid, u16 offset, int whichbap ) | |||
4004 | } | 4012 | } |
4005 | if ( !(max_tries--) ) { | 4013 | if ( !(max_tries--) ) { |
4006 | airo_print_err(ai->dev->name, | 4014 | airo_print_err(ai->dev->name, |
4007 | "airo: BAP setup error too many retries\n"); | 4015 | "BAP setup error too many retries\n"); |
4008 | return ERROR; | 4016 | return ERROR; |
4009 | } | 4017 | } |
4010 | // -- PC4500 missed it, try again | 4018 | // -- PC4500 missed it, try again |
@@ -5152,7 +5160,6 @@ static void proc_SSID_on_close( struct inode *inode, struct file *file ) { | |||
5152 | struct net_device *dev = dp->data; | 5160 | struct net_device *dev = dp->data; |
5153 | struct airo_info *ai = dev->priv; | 5161 | struct airo_info *ai = dev->priv; |
5154 | SsidRid SSID_rid; | 5162 | SsidRid SSID_rid; |
5155 | Resp rsp; | ||
5156 | int i; | 5163 | int i; |
5157 | int offset = 0; | 5164 | int offset = 0; |
5158 | 5165 | ||
@@ -5177,7 +5184,7 @@ static void proc_SSID_on_close( struct inode *inode, struct file *file ) { | |||
5177 | SSID_rid.len = sizeof(SSID_rid); | 5184 | SSID_rid.len = sizeof(SSID_rid); |
5178 | disable_MAC(ai, 1); | 5185 | disable_MAC(ai, 1); |
5179 | writeSsidRid(ai, &SSID_rid, 1); | 5186 | writeSsidRid(ai, &SSID_rid, 1); |
5180 | enable_MAC(ai, &rsp, 1); | 5187 | enable_MAC(ai, 1); |
5181 | } | 5188 | } |
5182 | 5189 | ||
5183 | static inline u8 hexVal(char c) { | 5190 | static inline u8 hexVal(char c) { |
@@ -5193,7 +5200,6 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) { | |||
5193 | struct net_device *dev = dp->data; | 5200 | struct net_device *dev = dp->data; |
5194 | struct airo_info *ai = dev->priv; | 5201 | struct airo_info *ai = dev->priv; |
5195 | APListRid APList_rid; | 5202 | APListRid APList_rid; |
5196 | Resp rsp; | ||
5197 | int i; | 5203 | int i; |
5198 | 5204 | ||
5199 | if ( !data->writelen ) return; | 5205 | if ( !data->writelen ) return; |
@@ -5218,18 +5224,17 @@ static void proc_APList_on_close( struct inode *inode, struct file *file ) { | |||
5218 | } | 5224 | } |
5219 | disable_MAC(ai, 1); | 5225 | disable_MAC(ai, 1); |
5220 | writeAPListRid(ai, &APList_rid, 1); | 5226 | writeAPListRid(ai, &APList_rid, 1); |
5221 | enable_MAC(ai, &rsp, 1); | 5227 | enable_MAC(ai, 1); |
5222 | } | 5228 | } |
5223 | 5229 | ||
5224 | /* This function wraps PC4500_writerid with a MAC disable */ | 5230 | /* This function wraps PC4500_writerid with a MAC disable */ |
5225 | static int do_writerid( struct airo_info *ai, u16 rid, const void *rid_data, | 5231 | static int do_writerid( struct airo_info *ai, u16 rid, const void *rid_data, |
5226 | int len, int dummy ) { | 5232 | int len, int dummy ) { |
5227 | int rc; | 5233 | int rc; |
5228 | Resp rsp; | ||
5229 | 5234 | ||
5230 | disable_MAC(ai, 1); | 5235 | disable_MAC(ai, 1); |
5231 | rc = PC4500_writerid(ai, rid, rid_data, len, 1); | 5236 | rc = PC4500_writerid(ai, rid, rid_data, len, 1); |
5232 | enable_MAC(ai, &rsp, 1); | 5237 | enable_MAC(ai, 1); |
5233 | return rc; | 5238 | return rc; |
5234 | } | 5239 | } |
5235 | 5240 | ||
@@ -5260,7 +5265,6 @@ static int set_wep_key(struct airo_info *ai, u16 index, | |||
5260 | const char *key, u16 keylen, int perm, int lock ) { | 5265 | const char *key, u16 keylen, int perm, int lock ) { |
5261 | static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; | 5266 | static const unsigned char macaddr[ETH_ALEN] = { 0x01, 0, 0, 0, 0, 0 }; |
5262 | WepKeyRid wkr; | 5267 | WepKeyRid wkr; |
5263 | Resp rsp; | ||
5264 | 5268 | ||
5265 | memset(&wkr, 0, sizeof(wkr)); | 5269 | memset(&wkr, 0, sizeof(wkr)); |
5266 | if (keylen == 0) { | 5270 | if (keylen == 0) { |
@@ -5280,7 +5284,7 @@ static int set_wep_key(struct airo_info *ai, u16 index, | |||
5280 | 5284 | ||
5281 | if (perm) disable_MAC(ai, lock); | 5285 | if (perm) disable_MAC(ai, lock); |
5282 | writeWepKeyRid(ai, &wkr, perm, lock); | 5286 | writeWepKeyRid(ai, &wkr, perm, lock); |
5283 | if (perm) enable_MAC(ai, &rsp, lock); | 5287 | if (perm) enable_MAC(ai, lock); |
5284 | return 0; | 5288 | return 0; |
5285 | } | 5289 | } |
5286 | 5290 | ||
@@ -5548,7 +5552,6 @@ static int proc_close( struct inode *inode, struct file *file ) | |||
5548 | changed. */ | 5552 | changed. */ |
5549 | static void timer_func( struct net_device *dev ) { | 5553 | static void timer_func( struct net_device *dev ) { |
5550 | struct airo_info *apriv = dev->priv; | 5554 | struct airo_info *apriv = dev->priv; |
5551 | Resp rsp; | ||
5552 | 5555 | ||
5553 | /* We don't have a link so try changing the authtype */ | 5556 | /* We don't have a link so try changing the authtype */ |
5554 | readConfigRid(apriv, 0); | 5557 | readConfigRid(apriv, 0); |
@@ -5575,7 +5578,7 @@ static void timer_func( struct net_device *dev ) { | |||
5575 | } | 5578 | } |
5576 | set_bit (FLAG_COMMIT, &apriv->flags); | 5579 | set_bit (FLAG_COMMIT, &apriv->flags); |
5577 | writeConfigRid(apriv, 0); | 5580 | writeConfigRid(apriv, 0); |
5578 | enable_MAC(apriv, &rsp, 0); | 5581 | enable_MAC(apriv, 0); |
5579 | up(&apriv->sem); | 5582 | up(&apriv->sem); |
5580 | 5583 | ||
5581 | /* Schedule check to see if the change worked */ | 5584 | /* Schedule check to see if the change worked */ |
@@ -5597,8 +5600,10 @@ static int __devinit airo_pci_probe(struct pci_dev *pdev, | |||
5597 | dev = _init_airo_card(pdev->irq, pdev->resource[0].start, 0, pdev, &pdev->dev); | 5600 | dev = _init_airo_card(pdev->irq, pdev->resource[0].start, 0, pdev, &pdev->dev); |
5598 | else | 5601 | else |
5599 | dev = _init_airo_card(pdev->irq, pdev->resource[2].start, 0, pdev, &pdev->dev); | 5602 | dev = _init_airo_card(pdev->irq, pdev->resource[2].start, 0, pdev, &pdev->dev); |
5600 | if (!dev) | 5603 | if (!dev) { |
5604 | pci_disable_device(pdev); | ||
5601 | return -ENODEV; | 5605 | return -ENODEV; |
5606 | } | ||
5602 | 5607 | ||
5603 | pci_set_drvdata(pdev, dev); | 5608 | pci_set_drvdata(pdev, dev); |
5604 | return 0; | 5609 | return 0; |
@@ -5610,6 +5615,8 @@ static void __devexit airo_pci_remove(struct pci_dev *pdev) | |||
5610 | 5615 | ||
5611 | airo_print_info(dev->name, "Unregistering..."); | 5616 | airo_print_info(dev->name, "Unregistering..."); |
5612 | stop_airo_card(dev, 1); | 5617 | stop_airo_card(dev, 1); |
5618 | pci_disable_device(pdev); | ||
5619 | pci_set_drvdata(pdev, NULL); | ||
5613 | } | 5620 | } |
5614 | 5621 | ||
5615 | static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state) | 5622 | static int airo_pci_suspend(struct pci_dev *pdev, pm_message_t state) |
@@ -5646,7 +5653,6 @@ static int airo_pci_resume(struct pci_dev *pdev) | |||
5646 | { | 5653 | { |
5647 | struct net_device *dev = pci_get_drvdata(pdev); | 5654 | struct net_device *dev = pci_get_drvdata(pdev); |
5648 | struct airo_info *ai = dev->priv; | 5655 | struct airo_info *ai = dev->priv; |
5649 | Resp rsp; | ||
5650 | pci_power_t prev_state = pdev->current_state; | 5656 | pci_power_t prev_state = pdev->current_state; |
5651 | 5657 | ||
5652 | pci_set_power_state(pdev, PCI_D0); | 5658 | pci_set_power_state(pdev, PCI_D0); |
@@ -5679,7 +5685,7 @@ static int airo_pci_resume(struct pci_dev *pdev) | |||
5679 | ai->APList = NULL; | 5685 | ai->APList = NULL; |
5680 | } | 5686 | } |
5681 | writeConfigRid(ai, 0); | 5687 | writeConfigRid(ai, 0); |
5682 | enable_MAC(ai, &rsp, 0); | 5688 | enable_MAC(ai, 0); |
5683 | ai->power = PMSG_ON; | 5689 | ai->power = PMSG_ON; |
5684 | netif_device_attach(dev); | 5690 | netif_device_attach(dev); |
5685 | netif_wake_queue(dev); | 5691 | netif_wake_queue(dev); |
@@ -5903,7 +5909,6 @@ static int airo_set_essid(struct net_device *dev, | |||
5903 | char *extra) | 5909 | char *extra) |
5904 | { | 5910 | { |
5905 | struct airo_info *local = dev->priv; | 5911 | struct airo_info *local = dev->priv; |
5906 | Resp rsp; | ||
5907 | SsidRid SSID_rid; /* SSIDs */ | 5912 | SsidRid SSID_rid; /* SSIDs */ |
5908 | 5913 | ||
5909 | /* Reload the list of current SSID */ | 5914 | /* Reload the list of current SSID */ |
@@ -5935,7 +5940,7 @@ static int airo_set_essid(struct net_device *dev, | |||
5935 | /* Write it to the card */ | 5940 | /* Write it to the card */ |
5936 | disable_MAC(local, 1); | 5941 | disable_MAC(local, 1); |
5937 | writeSsidRid(local, &SSID_rid, 1); | 5942 | writeSsidRid(local, &SSID_rid, 1); |
5938 | enable_MAC(local, &rsp, 1); | 5943 | enable_MAC(local, 1); |
5939 | 5944 | ||
5940 | return 0; | 5945 | return 0; |
5941 | } | 5946 | } |
@@ -6000,7 +6005,7 @@ static int airo_set_wap(struct net_device *dev, | |||
6000 | memcpy(APList_rid.ap[0], awrq->sa_data, ETH_ALEN); | 6005 | memcpy(APList_rid.ap[0], awrq->sa_data, ETH_ALEN); |
6001 | disable_MAC(local, 1); | 6006 | disable_MAC(local, 1); |
6002 | writeAPListRid(local, &APList_rid, 1); | 6007 | writeAPListRid(local, &APList_rid, 1); |
6003 | enable_MAC(local, &rsp, 1); | 6008 | enable_MAC(local, 1); |
6004 | } | 6009 | } |
6005 | return 0; | 6010 | return 0; |
6006 | } | 6011 | } |
@@ -7454,7 +7459,6 @@ static int airo_config_commit(struct net_device *dev, | |||
7454 | char *extra) /* NULL */ | 7459 | char *extra) /* NULL */ |
7455 | { | 7460 | { |
7456 | struct airo_info *local = dev->priv; | 7461 | struct airo_info *local = dev->priv; |
7457 | Resp rsp; | ||
7458 | 7462 | ||
7459 | if (!test_bit (FLAG_COMMIT, &local->flags)) | 7463 | if (!test_bit (FLAG_COMMIT, &local->flags)) |
7460 | return 0; | 7464 | return 0; |
@@ -7479,7 +7483,7 @@ static int airo_config_commit(struct net_device *dev, | |||
7479 | if (down_interruptible(&local->sem)) | 7483 | if (down_interruptible(&local->sem)) |
7480 | return -ERESTARTSYS; | 7484 | return -ERESTARTSYS; |
7481 | writeConfigRid(local, 0); | 7485 | writeConfigRid(local, 0); |
7482 | enable_MAC(local, &rsp, 0); | 7486 | enable_MAC(local, 0); |
7483 | if (test_bit (FLAG_RESET, &local->flags)) | 7487 | if (test_bit (FLAG_RESET, &local->flags)) |
7484 | airo_set_promisc(local); | 7488 | airo_set_promisc(local); |
7485 | else | 7489 | else |
@@ -7746,7 +7750,6 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { | |||
7746 | unsigned char *iobuf; | 7750 | unsigned char *iobuf; |
7747 | int len; | 7751 | int len; |
7748 | struct airo_info *ai = dev->priv; | 7752 | struct airo_info *ai = dev->priv; |
7749 | Resp rsp; | ||
7750 | 7753 | ||
7751 | if (test_bit(FLAG_FLASHING, &ai->flags)) | 7754 | if (test_bit(FLAG_FLASHING, &ai->flags)) |
7752 | return -EIO; | 7755 | return -EIO; |
@@ -7758,7 +7761,7 @@ static int readrids(struct net_device *dev, aironet_ioctl *comp) { | |||
7758 | if (test_bit(FLAG_COMMIT, &ai->flags)) { | 7761 | if (test_bit(FLAG_COMMIT, &ai->flags)) { |
7759 | disable_MAC (ai, 1); | 7762 | disable_MAC (ai, 1); |
7760 | writeConfigRid (ai, 1); | 7763 | writeConfigRid (ai, 1); |
7761 | enable_MAC (ai, &rsp, 1); | 7764 | enable_MAC(ai, 1); |
7762 | } | 7765 | } |
7763 | break; | 7766 | break; |
7764 | case AIROGSLIST: ridcode = RID_SSID; break; | 7767 | case AIROGSLIST: ridcode = RID_SSID; break; |
@@ -7815,7 +7818,6 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { | |||
7815 | struct airo_info *ai = dev->priv; | 7818 | struct airo_info *ai = dev->priv; |
7816 | int ridcode; | 7819 | int ridcode; |
7817 | int enabled; | 7820 | int enabled; |
7818 | Resp rsp; | ||
7819 | static int (* writer)(struct airo_info *, u16 rid, const void *, int, int); | 7821 | static int (* writer)(struct airo_info *, u16 rid, const void *, int, int); |
7820 | unsigned char *iobuf; | 7822 | unsigned char *iobuf; |
7821 | 7823 | ||
@@ -7849,7 +7851,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) { | |||
7849 | * same with MAC off | 7851 | * same with MAC off |
7850 | */ | 7852 | */ |
7851 | case AIROPMACON: | 7853 | case AIROPMACON: |
7852 | if (enable_MAC(ai, &rsp, 1) != 0) | 7854 | if (enable_MAC(ai, 1) != 0) |
7853 | return -EIO; | 7855 | return -EIO; |
7854 | return 0; | 7856 | return 0; |
7855 | 7857 | ||
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c index d51daf87450f..072ede71e575 100644 --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c | |||
@@ -1768,7 +1768,8 @@ static int ipw2100_up(struct ipw2100_priv *priv, int deferred) | |||
1768 | 1768 | ||
1769 | if (priv->stop_rf_kill) { | 1769 | if (priv->stop_rf_kill) { |
1770 | priv->stop_rf_kill = 0; | 1770 | priv->stop_rf_kill = 0; |
1771 | queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ); | 1771 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
1772 | round_jiffies(HZ)); | ||
1772 | } | 1773 | } |
1773 | 1774 | ||
1774 | deferred = 1; | 1775 | deferred = 1; |
@@ -2098,7 +2099,7 @@ static void isr_indicate_rf_kill(struct ipw2100_priv *priv, u32 status) | |||
2098 | /* Make sure the RF Kill check timer is running */ | 2099 | /* Make sure the RF Kill check timer is running */ |
2099 | priv->stop_rf_kill = 0; | 2100 | priv->stop_rf_kill = 0; |
2100 | cancel_delayed_work(&priv->rf_kill); | 2101 | cancel_delayed_work(&priv->rf_kill); |
2101 | queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ); | 2102 | queue_delayed_work(priv->workqueue, &priv->rf_kill, round_jiffies(HZ)); |
2102 | } | 2103 | } |
2103 | 2104 | ||
2104 | static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) | 2105 | static void isr_scan_complete(struct ipw2100_priv *priv, u32 status) |
@@ -4233,7 +4234,8 @@ static int ipw_radio_kill_sw(struct ipw2100_priv *priv, int disable_radio) | |||
4233 | /* Make sure the RF_KILL check timer is running */ | 4234 | /* Make sure the RF_KILL check timer is running */ |
4234 | priv->stop_rf_kill = 0; | 4235 | priv->stop_rf_kill = 0; |
4235 | cancel_delayed_work(&priv->rf_kill); | 4236 | cancel_delayed_work(&priv->rf_kill); |
4236 | queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ); | 4237 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
4238 | round_jiffies(HZ)); | ||
4237 | } else | 4239 | } else |
4238 | schedule_reset(priv); | 4240 | schedule_reset(priv); |
4239 | } | 4241 | } |
@@ -5969,7 +5971,8 @@ static void ipw2100_rf_kill(struct work_struct *work) | |||
5969 | if (rf_kill_active(priv)) { | 5971 | if (rf_kill_active(priv)) { |
5970 | IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n"); | 5972 | IPW_DEBUG_RF_KILL("RF Kill active, rescheduling GPIO check\n"); |
5971 | if (!priv->stop_rf_kill) | 5973 | if (!priv->stop_rf_kill) |
5972 | queue_delayed_work(priv->workqueue, &priv->rf_kill, HZ); | 5974 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
5975 | round_jiffies(HZ)); | ||
5973 | goto exit_unlock; | 5976 | goto exit_unlock; |
5974 | } | 5977 | } |
5975 | 5978 | ||
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index 7cb2052a55a5..aa32a97380ec 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c | |||
@@ -1751,7 +1751,7 @@ static int ipw_radio_kill_sw(struct ipw_priv *priv, int disable_radio) | |||
1751 | /* Make sure the RF_KILL check timer is running */ | 1751 | /* Make sure the RF_KILL check timer is running */ |
1752 | cancel_delayed_work(&priv->rf_kill); | 1752 | cancel_delayed_work(&priv->rf_kill); |
1753 | queue_delayed_work(priv->workqueue, &priv->rf_kill, | 1753 | queue_delayed_work(priv->workqueue, &priv->rf_kill, |
1754 | 2 * HZ); | 1754 | round_jiffies(2 * HZ)); |
1755 | } else | 1755 | } else |
1756 | queue_work(priv->workqueue, &priv->up); | 1756 | queue_work(priv->workqueue, &priv->up); |
1757 | } | 1757 | } |
@@ -4690,7 +4690,8 @@ static void ipw_rx_notification(struct ipw_priv *priv, | |||
4690 | else if (priv->config & CFG_BACKGROUND_SCAN | 4690 | else if (priv->config & CFG_BACKGROUND_SCAN |
4691 | && priv->status & STATUS_ASSOCIATED) | 4691 | && priv->status & STATUS_ASSOCIATED) |
4692 | queue_delayed_work(priv->workqueue, | 4692 | queue_delayed_work(priv->workqueue, |
4693 | &priv->request_scan, HZ); | 4693 | &priv->request_scan, |
4694 | round_jiffies(HZ)); | ||
4694 | 4695 | ||
4695 | /* Send an empty event to user space. | 4696 | /* Send an empty event to user space. |
4696 | * We don't send the received data on the event because | 4697 | * We don't send the received data on the event because |
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c index 13f6528abb00..4a8f5dc70239 100644 --- a/drivers/net/wireless/libertas/cmd.c +++ b/drivers/net/wireless/libertas/cmd.c | |||
@@ -240,7 +240,7 @@ static int wlan_cmd_802_11_enable_rsn(wlan_private * priv, | |||
240 | if (*enable) | 240 | if (*enable) |
241 | penableRSN->enable = cpu_to_le16(cmd_enable_rsn); | 241 | penableRSN->enable = cpu_to_le16(cmd_enable_rsn); |
242 | else | 242 | else |
243 | penableRSN->enable = cpu_to_le16(cmd_enable_rsn); | 243 | penableRSN->enable = cpu_to_le16(cmd_disable_rsn); |
244 | } | 244 | } |
245 | 245 | ||
246 | lbs_deb_leave(LBS_DEB_CMD); | 246 | lbs_deb_leave(LBS_DEB_CMD); |
diff --git a/drivers/net/wireless/libertas/rx.c b/drivers/net/wireless/libertas/rx.c index 88d9d2d787d5..769c86fb9509 100644 --- a/drivers/net/wireless/libertas/rx.c +++ b/drivers/net/wireless/libertas/rx.c | |||
@@ -439,7 +439,6 @@ static int process_rxed_802_11_packet(wlan_private * priv, struct sk_buff *skb) | |||
439 | ret = 0; | 439 | ret = 0; |
440 | 440 | ||
441 | done: | 441 | done: |
442 | skb->protocol = __constant_htons(0x0019); /* ETH_P_80211_RAW */ | ||
443 | lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret); | 442 | lbs_deb_leave_args(LBS_DEB_RX, "ret %d", ret); |
444 | return ret; | 443 | return ret; |
445 | } | 444 | } |
diff --git a/drivers/net/wireless/libertas/version.h b/drivers/net/wireless/libertas/version.h deleted file mode 100644 index 8b137891791f..000000000000 --- a/drivers/net/wireless/libertas/version.h +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | |||
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c index f42b796b5e47..2fcc3bf21081 100644 --- a/drivers/net/wireless/libertas/wext.c +++ b/drivers/net/wireless/libertas/wext.c | |||
@@ -1719,9 +1719,6 @@ static int wlan_set_encodeext(struct net_device *dev, | |||
1719 | pkey->type = KEY_TYPE_ID_TKIP; | 1719 | pkey->type = KEY_TYPE_ID_TKIP; |
1720 | } else if (alg == IW_ENCODE_ALG_CCMP) { | 1720 | } else if (alg == IW_ENCODE_ALG_CCMP) { |
1721 | pkey->type = KEY_TYPE_ID_AES; | 1721 | pkey->type = KEY_TYPE_ID_AES; |
1722 | } else { | ||
1723 | ret = -EINVAL; | ||
1724 | goto out; | ||
1725 | } | 1722 | } |
1726 | 1723 | ||
1727 | /* If WPA isn't enabled yet, do that now */ | 1724 | /* If WPA isn't enabled yet, do that now */ |
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index 283be4a70524..585f5996d292 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c | |||
@@ -1853,7 +1853,6 @@ prism54_del_mac(struct net_device *ndev, struct iw_request_info *info, | |||
1853 | islpci_private *priv = netdev_priv(ndev); | 1853 | islpci_private *priv = netdev_priv(ndev); |
1854 | struct islpci_acl *acl = &priv->acl; | 1854 | struct islpci_acl *acl = &priv->acl; |
1855 | struct mac_entry *entry; | 1855 | struct mac_entry *entry; |
1856 | struct list_head *ptr; | ||
1857 | struct sockaddr *addr = (struct sockaddr *) extra; | 1856 | struct sockaddr *addr = (struct sockaddr *) extra; |
1858 | 1857 | ||
1859 | if (addr->sa_family != ARPHRD_ETHER) | 1858 | if (addr->sa_family != ARPHRD_ETHER) |
@@ -1861,11 +1860,9 @@ prism54_del_mac(struct net_device *ndev, struct iw_request_info *info, | |||
1861 | 1860 | ||
1862 | if (down_interruptible(&acl->sem)) | 1861 | if (down_interruptible(&acl->sem)) |
1863 | return -ERESTARTSYS; | 1862 | return -ERESTARTSYS; |
1864 | for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) { | 1863 | list_for_each_entry(entry, &acl->mac_list, _list) { |
1865 | entry = list_entry(ptr, struct mac_entry, _list); | ||
1866 | |||
1867 | if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) { | 1864 | if (memcmp(entry->addr, addr->sa_data, ETH_ALEN) == 0) { |
1868 | list_del(ptr); | 1865 | list_del(&entry->_list); |
1869 | acl->size--; | 1866 | acl->size--; |
1870 | kfree(entry); | 1867 | kfree(entry); |
1871 | up(&acl->sem); | 1868 | up(&acl->sem); |
@@ -1883,7 +1880,6 @@ prism54_get_mac(struct net_device *ndev, struct iw_request_info *info, | |||
1883 | islpci_private *priv = netdev_priv(ndev); | 1880 | islpci_private *priv = netdev_priv(ndev); |
1884 | struct islpci_acl *acl = &priv->acl; | 1881 | struct islpci_acl *acl = &priv->acl; |
1885 | struct mac_entry *entry; | 1882 | struct mac_entry *entry; |
1886 | struct list_head *ptr; | ||
1887 | struct sockaddr *dst = (struct sockaddr *) extra; | 1883 | struct sockaddr *dst = (struct sockaddr *) extra; |
1888 | 1884 | ||
1889 | dwrq->length = 0; | 1885 | dwrq->length = 0; |
@@ -1891,9 +1887,7 @@ prism54_get_mac(struct net_device *ndev, struct iw_request_info *info, | |||
1891 | if (down_interruptible(&acl->sem)) | 1887 | if (down_interruptible(&acl->sem)) |
1892 | return -ERESTARTSYS; | 1888 | return -ERESTARTSYS; |
1893 | 1889 | ||
1894 | for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) { | 1890 | list_for_each_entry(entry, &acl->mac_list, _list) { |
1895 | entry = list_entry(ptr, struct mac_entry, _list); | ||
1896 | |||
1897 | memcpy(dst->sa_data, entry->addr, ETH_ALEN); | 1891 | memcpy(dst->sa_data, entry->addr, ETH_ALEN); |
1898 | dst->sa_family = ARPHRD_ETHER; | 1892 | dst->sa_family = ARPHRD_ETHER; |
1899 | dwrq->length++; | 1893 | dwrq->length++; |
@@ -1960,7 +1954,6 @@ prism54_get_policy(struct net_device *ndev, struct iw_request_info *info, | |||
1960 | static int | 1954 | static int |
1961 | prism54_mac_accept(struct islpci_acl *acl, char *mac) | 1955 | prism54_mac_accept(struct islpci_acl *acl, char *mac) |
1962 | { | 1956 | { |
1963 | struct list_head *ptr; | ||
1964 | struct mac_entry *entry; | 1957 | struct mac_entry *entry; |
1965 | int res = 0; | 1958 | int res = 0; |
1966 | 1959 | ||
@@ -1972,8 +1965,7 @@ prism54_mac_accept(struct islpci_acl *acl, char *mac) | |||
1972 | return 1; | 1965 | return 1; |
1973 | } | 1966 | } |
1974 | 1967 | ||
1975 | for (ptr = acl->mac_list.next; ptr != &acl->mac_list; ptr = ptr->next) { | 1968 | list_for_each_entry(entry, &acl->mac_list, _list) { |
1976 | entry = list_entry(ptr, struct mac_entry, _list); | ||
1977 | if (memcmp(entry->addr, mac, ETH_ALEN) == 0) { | 1969 | if (memcmp(entry->addr, mac, ETH_ALEN) == 0) { |
1978 | res = 1; | 1970 | res = 1; |
1979 | break; | 1971 | break; |
@@ -2216,11 +2208,9 @@ prism54_wpa_bss_ie_init(islpci_private *priv) | |||
2216 | void | 2208 | void |
2217 | prism54_wpa_bss_ie_clean(islpci_private *priv) | 2209 | prism54_wpa_bss_ie_clean(islpci_private *priv) |
2218 | { | 2210 | { |
2219 | struct list_head *ptr, *n; | 2211 | struct islpci_bss_wpa_ie *bss, *n; |
2220 | 2212 | ||
2221 | list_for_each_safe(ptr, n, &priv->bss_wpa_list) { | 2213 | list_for_each_entry_safe(bss, n, &priv->bss_wpa_list, list) { |
2222 | struct islpci_bss_wpa_ie *bss; | ||
2223 | bss = list_entry(ptr, struct islpci_bss_wpa_ie, list); | ||
2224 | kfree(bss); | 2214 | kfree(bss); |
2225 | } | 2215 | } |
2226 | } | 2216 | } |
diff --git a/drivers/net/wireless/rtl8187_rtl8225.c b/drivers/net/wireless/rtl8187_rtl8225.c index e25a09f1b068..efc41207780e 100644 --- a/drivers/net/wireless/rtl8187_rtl8225.c +++ b/drivers/net/wireless/rtl8187_rtl8225.c | |||
@@ -67,7 +67,7 @@ static void rtl8225_write_bitbang(struct ieee80211_hw *dev, u8 addr, u16 data) | |||
67 | msleep(2); | 67 | msleep(2); |
68 | } | 68 | } |
69 | 69 | ||
70 | static void rtl8225_write_8051(struct ieee80211_hw *dev, u8 addr, u16 data) | 70 | static void rtl8225_write_8051(struct ieee80211_hw *dev, u8 addr, __le16 data) |
71 | { | 71 | { |
72 | struct rtl8187_priv *priv = dev->priv; | 72 | struct rtl8187_priv *priv = dev->priv; |
73 | u16 reg80, reg82, reg84; | 73 | u16 reg80, reg82, reg84; |
@@ -106,7 +106,7 @@ void rtl8225_write(struct ieee80211_hw *dev, u8 addr, u16 data) | |||
106 | struct rtl8187_priv *priv = dev->priv; | 106 | struct rtl8187_priv *priv = dev->priv; |
107 | 107 | ||
108 | if (priv->asic_rev) | 108 | if (priv->asic_rev) |
109 | rtl8225_write_8051(dev, addr, data); | 109 | rtl8225_write_8051(dev, addr, cpu_to_le16(data)); |
110 | else | 110 | else |
111 | rtl8225_write_bitbang(dev, addr, data); | 111 | rtl8225_write_bitbang(dev, addr, data); |
112 | } | 112 | } |
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index 5b624bfc01a6..c39f1984b84d 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/drivers/net/wireless/zd1211rw/zd_chip.c | |||
@@ -49,8 +49,9 @@ void zd_chip_clear(struct zd_chip *chip) | |||
49 | ZD_MEMCLEAR(chip, sizeof(*chip)); | 49 | ZD_MEMCLEAR(chip, sizeof(*chip)); |
50 | } | 50 | } |
51 | 51 | ||
52 | static int scnprint_mac_oui(const u8 *addr, char *buffer, size_t size) | 52 | static int scnprint_mac_oui(struct zd_chip *chip, char *buffer, size_t size) |
53 | { | 53 | { |
54 | u8 *addr = zd_usb_to_netdev(&chip->usb)->dev_addr; | ||
54 | return scnprintf(buffer, size, "%02x-%02x-%02x", | 55 | return scnprintf(buffer, size, "%02x-%02x-%02x", |
55 | addr[0], addr[1], addr[2]); | 56 | addr[0], addr[1], addr[2]); |
56 | } | 57 | } |
@@ -61,10 +62,10 @@ static int scnprint_id(struct zd_chip *chip, char *buffer, size_t size) | |||
61 | int i = 0; | 62 | int i = 0; |
62 | 63 | ||
63 | i = scnprintf(buffer, size, "zd1211%s chip ", | 64 | i = scnprintf(buffer, size, "zd1211%s chip ", |
64 | chip->is_zd1211b ? "b" : ""); | 65 | zd_chip_is_zd1211b(chip) ? "b" : ""); |
65 | i += zd_usb_scnprint_id(&chip->usb, buffer+i, size-i); | 66 | i += zd_usb_scnprint_id(&chip->usb, buffer+i, size-i); |
66 | i += scnprintf(buffer+i, size-i, " "); | 67 | i += scnprintf(buffer+i, size-i, " "); |
67 | i += scnprint_mac_oui(chip->e2p_mac, buffer+i, size-i); | 68 | i += scnprint_mac_oui(chip, buffer+i, size-i); |
68 | i += scnprintf(buffer+i, size-i, " "); | 69 | i += scnprintf(buffer+i, size-i, " "); |
69 | i += zd_rf_scnprint_id(&chip->rf, buffer+i, size-i); | 70 | i += zd_rf_scnprint_id(&chip->rf, buffer+i, size-i); |
70 | i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c%c%c", chip->pa_type, | 71 | i += scnprintf(buffer+i, size-i, " pa%1x %c%c%c%c%c", chip->pa_type, |
@@ -366,64 +367,9 @@ error: | |||
366 | return r; | 367 | return r; |
367 | } | 368 | } |
368 | 369 | ||
369 | static int _read_mac_addr(struct zd_chip *chip, u8 *mac_addr, | ||
370 | const zd_addr_t *addr) | ||
371 | { | ||
372 | int r; | ||
373 | u32 parts[2]; | ||
374 | |||
375 | r = zd_ioread32v_locked(chip, parts, (const zd_addr_t *)addr, 2); | ||
376 | if (r) { | ||
377 | dev_dbg_f(zd_chip_dev(chip), | ||
378 | "error: couldn't read e2p macs. Error number %d\n", r); | ||
379 | return r; | ||
380 | } | ||
381 | |||
382 | mac_addr[0] = parts[0]; | ||
383 | mac_addr[1] = parts[0] >> 8; | ||
384 | mac_addr[2] = parts[0] >> 16; | ||
385 | mac_addr[3] = parts[0] >> 24; | ||
386 | mac_addr[4] = parts[1]; | ||
387 | mac_addr[5] = parts[1] >> 8; | ||
388 | |||
389 | return 0; | ||
390 | } | ||
391 | |||
392 | static int read_e2p_mac_addr(struct zd_chip *chip) | ||
393 | { | ||
394 | static const zd_addr_t addr[2] = { E2P_MAC_ADDR_P1, E2P_MAC_ADDR_P2 }; | ||
395 | |||
396 | ZD_ASSERT(mutex_is_locked(&chip->mutex)); | ||
397 | return _read_mac_addr(chip, chip->e2p_mac, (const zd_addr_t *)addr); | ||
398 | } | ||
399 | |||
400 | /* MAC address: if custom mac addresses are to to be used CR_MAC_ADDR_P1 and | 370 | /* MAC address: if custom mac addresses are to to be used CR_MAC_ADDR_P1 and |
401 | * CR_MAC_ADDR_P2 must be overwritten | 371 | * CR_MAC_ADDR_P2 must be overwritten |
402 | */ | 372 | */ |
403 | void zd_get_e2p_mac_addr(struct zd_chip *chip, u8 *mac_addr) | ||
404 | { | ||
405 | mutex_lock(&chip->mutex); | ||
406 | memcpy(mac_addr, chip->e2p_mac, ETH_ALEN); | ||
407 | mutex_unlock(&chip->mutex); | ||
408 | } | ||
409 | |||
410 | static int read_mac_addr(struct zd_chip *chip, u8 *mac_addr) | ||
411 | { | ||
412 | static const zd_addr_t addr[2] = { CR_MAC_ADDR_P1, CR_MAC_ADDR_P2 }; | ||
413 | return _read_mac_addr(chip, mac_addr, (const zd_addr_t *)addr); | ||
414 | } | ||
415 | |||
416 | int zd_read_mac_addr(struct zd_chip *chip, u8 *mac_addr) | ||
417 | { | ||
418 | int r; | ||
419 | |||
420 | dev_dbg_f(zd_chip_dev(chip), "\n"); | ||
421 | mutex_lock(&chip->mutex); | ||
422 | r = read_mac_addr(chip, mac_addr); | ||
423 | mutex_unlock(&chip->mutex); | ||
424 | return r; | ||
425 | } | ||
426 | |||
427 | int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr) | 373 | int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr) |
428 | { | 374 | { |
429 | int r; | 375 | int r; |
@@ -444,12 +390,6 @@ int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr) | |||
444 | 390 | ||
445 | mutex_lock(&chip->mutex); | 391 | mutex_lock(&chip->mutex); |
446 | r = zd_iowrite32a_locked(chip, reqs, ARRAY_SIZE(reqs)); | 392 | r = zd_iowrite32a_locked(chip, reqs, ARRAY_SIZE(reqs)); |
447 | #ifdef DEBUG | ||
448 | { | ||
449 | u8 tmp[ETH_ALEN]; | ||
450 | read_mac_addr(chip, tmp); | ||
451 | } | ||
452 | #endif /* DEBUG */ | ||
453 | mutex_unlock(&chip->mutex); | 393 | mutex_unlock(&chip->mutex); |
454 | return r; | 394 | return r; |
455 | } | 395 | } |
@@ -809,7 +749,7 @@ out: | |||
809 | 749 | ||
810 | static int hw_reset_phy(struct zd_chip *chip) | 750 | static int hw_reset_phy(struct zd_chip *chip) |
811 | { | 751 | { |
812 | return chip->is_zd1211b ? zd1211b_hw_reset_phy(chip) : | 752 | return zd_chip_is_zd1211b(chip) ? zd1211b_hw_reset_phy(chip) : |
813 | zd1211_hw_reset_phy(chip); | 753 | zd1211_hw_reset_phy(chip); |
814 | } | 754 | } |
815 | 755 | ||
@@ -874,7 +814,7 @@ static int hw_init_hmac(struct zd_chip *chip) | |||
874 | if (r) | 814 | if (r) |
875 | return r; | 815 | return r; |
876 | 816 | ||
877 | return chip->is_zd1211b ? | 817 | return zd_chip_is_zd1211b(chip) ? |
878 | zd1211b_hw_init_hmac(chip) : zd1211_hw_init_hmac(chip); | 818 | zd1211b_hw_init_hmac(chip) : zd1211_hw_init_hmac(chip); |
879 | } | 819 | } |
880 | 820 | ||
@@ -1136,8 +1076,15 @@ static int read_fw_regs_offset(struct zd_chip *chip) | |||
1136 | return 0; | 1076 | return 0; |
1137 | } | 1077 | } |
1138 | 1078 | ||
1079 | /* Read mac address using pre-firmware interface */ | ||
1080 | int zd_chip_read_mac_addr_fw(struct zd_chip *chip, u8 *addr) | ||
1081 | { | ||
1082 | dev_dbg_f(zd_chip_dev(chip), "\n"); | ||
1083 | return zd_usb_read_fw(&chip->usb, E2P_MAC_ADDR_P1, addr, | ||
1084 | ETH_ALEN); | ||
1085 | } | ||
1139 | 1086 | ||
1140 | int zd_chip_init_hw(struct zd_chip *chip, u8 device_type) | 1087 | int zd_chip_init_hw(struct zd_chip *chip) |
1141 | { | 1088 | { |
1142 | int r; | 1089 | int r; |
1143 | u8 rf_type; | 1090 | u8 rf_type; |
@@ -1145,7 +1092,6 @@ int zd_chip_init_hw(struct zd_chip *chip, u8 device_type) | |||
1145 | dev_dbg_f(zd_chip_dev(chip), "\n"); | 1092 | dev_dbg_f(zd_chip_dev(chip), "\n"); |
1146 | 1093 | ||
1147 | mutex_lock(&chip->mutex); | 1094 | mutex_lock(&chip->mutex); |
1148 | chip->is_zd1211b = (device_type == DEVICE_ZD1211B) != 0; | ||
1149 | 1095 | ||
1150 | #ifdef DEBUG | 1096 | #ifdef DEBUG |
1151 | r = test_init(chip); | 1097 | r = test_init(chip); |
@@ -1201,10 +1147,6 @@ int zd_chip_init_hw(struct zd_chip *chip, u8 device_type) | |||
1201 | goto out; | 1147 | goto out; |
1202 | #endif /* DEBUG */ | 1148 | #endif /* DEBUG */ |
1203 | 1149 | ||
1204 | r = read_e2p_mac_addr(chip); | ||
1205 | if (r) | ||
1206 | goto out; | ||
1207 | |||
1208 | r = read_cal_int_tables(chip); | 1150 | r = read_cal_int_tables(chip); |
1209 | if (r) | 1151 | if (r) |
1210 | goto out; | 1152 | goto out; |
@@ -1259,7 +1201,7 @@ static int update_channel_integration_and_calibration(struct zd_chip *chip, | |||
1259 | r = update_pwr_int(chip, channel); | 1201 | r = update_pwr_int(chip, channel); |
1260 | if (r) | 1202 | if (r) |
1261 | return r; | 1203 | return r; |
1262 | if (chip->is_zd1211b) { | 1204 | if (zd_chip_is_zd1211b(chip)) { |
1263 | static const struct zd_ioreq16 ioreqs[] = { | 1205 | static const struct zd_ioreq16 ioreqs[] = { |
1264 | { CR69, 0x28 }, | 1206 | { CR69, 0x28 }, |
1265 | {}, | 1207 | {}, |
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h index 79d0288c193a..f4698576ab71 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.h +++ b/drivers/net/wireless/zd1211rw/zd_chip.h | |||
@@ -704,7 +704,6 @@ struct zd_chip { | |||
704 | struct mutex mutex; | 704 | struct mutex mutex; |
705 | /* Base address of FW_REG_ registers */ | 705 | /* Base address of FW_REG_ registers */ |
706 | zd_addr_t fw_regs_base; | 706 | zd_addr_t fw_regs_base; |
707 | u8 e2p_mac[ETH_ALEN]; | ||
708 | /* EepSetPoint in the vendor driver */ | 707 | /* EepSetPoint in the vendor driver */ |
709 | u8 pwr_cal_values[E2P_CHANNEL_COUNT]; | 708 | u8 pwr_cal_values[E2P_CHANNEL_COUNT]; |
710 | /* integration values in the vendor driver */ | 709 | /* integration values in the vendor driver */ |
@@ -715,7 +714,7 @@ struct zd_chip { | |||
715 | unsigned int pa_type:4, | 714 | unsigned int pa_type:4, |
716 | patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1, | 715 | patch_cck_gain:1, patch_cr157:1, patch_6m_band_edge:1, |
717 | new_phy_layout:1, al2230s_bit:1, | 716 | new_phy_layout:1, al2230s_bit:1, |
718 | is_zd1211b:1, supports_tx_led:1; | 717 | supports_tx_led:1; |
719 | }; | 718 | }; |
720 | 719 | ||
721 | static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb) | 720 | static inline struct zd_chip *zd_usb_to_chip(struct zd_usb *usb) |
@@ -734,9 +733,15 @@ void zd_chip_init(struct zd_chip *chip, | |||
734 | struct net_device *netdev, | 733 | struct net_device *netdev, |
735 | struct usb_interface *intf); | 734 | struct usb_interface *intf); |
736 | void zd_chip_clear(struct zd_chip *chip); | 735 | void zd_chip_clear(struct zd_chip *chip); |
737 | int zd_chip_init_hw(struct zd_chip *chip, u8 device_type); | 736 | int zd_chip_read_mac_addr_fw(struct zd_chip *chip, u8 *addr); |
737 | int zd_chip_init_hw(struct zd_chip *chip); | ||
738 | int zd_chip_reset(struct zd_chip *chip); | 738 | int zd_chip_reset(struct zd_chip *chip); |
739 | 739 | ||
740 | static inline int zd_chip_is_zd1211b(struct zd_chip *chip) | ||
741 | { | ||
742 | return chip->usb.is_zd1211b; | ||
743 | } | ||
744 | |||
740 | static inline int zd_ioread16v_locked(struct zd_chip *chip, u16 *values, | 745 | static inline int zd_ioread16v_locked(struct zd_chip *chip, u16 *values, |
741 | const zd_addr_t *addresses, | 746 | const zd_addr_t *addresses, |
742 | unsigned int count) | 747 | unsigned int count) |
@@ -825,8 +830,6 @@ static inline u8 _zd_chip_get_channel(struct zd_chip *chip) | |||
825 | } | 830 | } |
826 | u8 zd_chip_get_channel(struct zd_chip *chip); | 831 | u8 zd_chip_get_channel(struct zd_chip *chip); |
827 | int zd_read_regdomain(struct zd_chip *chip, u8 *regdomain); | 832 | int zd_read_regdomain(struct zd_chip *chip, u8 *regdomain); |
828 | void zd_get_e2p_mac_addr(struct zd_chip *chip, u8 *mac_addr); | ||
829 | int zd_read_mac_addr(struct zd_chip *chip, u8 *mac_addr); | ||
830 | int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr); | 833 | int zd_write_mac_addr(struct zd_chip *chip, const u8 *mac_addr); |
831 | int zd_chip_switch_radio_on(struct zd_chip *chip); | 834 | int zd_chip_switch_radio_on(struct zd_chip *chip); |
832 | int zd_chip_switch_radio_off(struct zd_chip *chip); | 835 | int zd_chip_switch_radio_off(struct zd_chip *chip); |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index 6753d240c168..f6c487aa8246 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c | |||
@@ -86,38 +86,46 @@ out: | |||
86 | return r; | 86 | return r; |
87 | } | 87 | } |
88 | 88 | ||
89 | int zd_mac_init_hw(struct zd_mac *mac, u8 device_type) | 89 | int zd_mac_preinit_hw(struct zd_mac *mac) |
90 | { | 90 | { |
91 | int r; | 91 | int r; |
92 | struct zd_chip *chip = &mac->chip; | ||
93 | u8 addr[ETH_ALEN]; | 92 | u8 addr[ETH_ALEN]; |
93 | |||
94 | r = zd_chip_read_mac_addr_fw(&mac->chip, addr); | ||
95 | if (r) | ||
96 | return r; | ||
97 | |||
98 | memcpy(mac->netdev->dev_addr, addr, ETH_ALEN); | ||
99 | return 0; | ||
100 | } | ||
101 | |||
102 | int zd_mac_init_hw(struct zd_mac *mac) | ||
103 | { | ||
104 | int r; | ||
105 | struct zd_chip *chip = &mac->chip; | ||
94 | u8 default_regdomain; | 106 | u8 default_regdomain; |
95 | 107 | ||
96 | r = zd_chip_enable_int(chip); | 108 | r = zd_chip_enable_int(chip); |
97 | if (r) | 109 | if (r) |
98 | goto out; | 110 | goto out; |
99 | r = zd_chip_init_hw(chip, device_type); | 111 | r = zd_chip_init_hw(chip); |
100 | if (r) | 112 | if (r) |
101 | goto disable_int; | 113 | goto disable_int; |
102 | 114 | ||
103 | zd_get_e2p_mac_addr(chip, addr); | ||
104 | r = zd_write_mac_addr(chip, addr); | ||
105 | if (r) | ||
106 | goto disable_int; | ||
107 | ZD_ASSERT(!irqs_disabled()); | 115 | ZD_ASSERT(!irqs_disabled()); |
108 | spin_lock_irq(&mac->lock); | ||
109 | memcpy(mac->netdev->dev_addr, addr, ETH_ALEN); | ||
110 | spin_unlock_irq(&mac->lock); | ||
111 | 116 | ||
112 | r = zd_read_regdomain(chip, &default_regdomain); | 117 | r = zd_read_regdomain(chip, &default_regdomain); |
113 | if (r) | 118 | if (r) |
114 | goto disable_int; | 119 | goto disable_int; |
115 | if (!zd_regdomain_supported(default_regdomain)) { | 120 | if (!zd_regdomain_supported(default_regdomain)) { |
116 | dev_dbg_f(zd_mac_dev(mac), | 121 | /* The vendor driver overrides the regulatory domain and |
117 | "Regulatory Domain %#04x is not supported.\n", | 122 | * allowed channel registers and unconditionally restricts |
118 | default_regdomain); | 123 | * available channels to 1-11 everywhere. Match their |
119 | r = -EINVAL; | 124 | * questionable behaviour only for regdomains which we don't |
120 | goto disable_int; | 125 | * recognise. */ |
126 | dev_warn(zd_mac_dev(mac), "Unrecognised regulatory domain: " | ||
127 | "%#04x. Defaulting to FCC.\n", default_regdomain); | ||
128 | default_regdomain = ZD_REGDOMAIN_FCC; | ||
121 | } | 129 | } |
122 | spin_lock_irq(&mac->lock); | 130 | spin_lock_irq(&mac->lock); |
123 | mac->regdomain = mac->default_regdomain = default_regdomain; | 131 | mac->regdomain = mac->default_regdomain = default_regdomain; |
@@ -164,14 +172,25 @@ int zd_mac_open(struct net_device *netdev) | |||
164 | { | 172 | { |
165 | struct zd_mac *mac = zd_netdev_mac(netdev); | 173 | struct zd_mac *mac = zd_netdev_mac(netdev); |
166 | struct zd_chip *chip = &mac->chip; | 174 | struct zd_chip *chip = &mac->chip; |
175 | struct zd_usb *usb = &chip->usb; | ||
167 | int r; | 176 | int r; |
168 | 177 | ||
178 | if (!usb->initialized) { | ||
179 | r = zd_usb_init_hw(usb); | ||
180 | if (r) | ||
181 | goto out; | ||
182 | } | ||
183 | |||
169 | tasklet_enable(&mac->rx_tasklet); | 184 | tasklet_enable(&mac->rx_tasklet); |
170 | 185 | ||
171 | r = zd_chip_enable_int(chip); | 186 | r = zd_chip_enable_int(chip); |
172 | if (r < 0) | 187 | if (r < 0) |
173 | goto out; | 188 | goto out; |
174 | 189 | ||
190 | r = zd_write_mac_addr(chip, netdev->dev_addr); | ||
191 | if (r) | ||
192 | goto disable_int; | ||
193 | |||
175 | r = zd_chip_set_basic_rates(chip, CR_RATES_80211B | CR_RATES_80211G); | 194 | r = zd_chip_set_basic_rates(chip, CR_RATES_80211B | CR_RATES_80211G); |
176 | if (r < 0) | 195 | if (r < 0) |
177 | goto disable_int; | 196 | goto disable_int; |
@@ -251,9 +270,11 @@ int zd_mac_set_mac_address(struct net_device *netdev, void *p) | |||
251 | dev_dbg_f(zd_mac_dev(mac), | 270 | dev_dbg_f(zd_mac_dev(mac), |
252 | "Setting MAC to " MAC_FMT "\n", MAC_ARG(addr->sa_data)); | 271 | "Setting MAC to " MAC_FMT "\n", MAC_ARG(addr->sa_data)); |
253 | 272 | ||
254 | r = zd_write_mac_addr(chip, addr->sa_data); | 273 | if (netdev->flags & IFF_UP) { |
255 | if (r) | 274 | r = zd_write_mac_addr(chip, addr->sa_data); |
256 | return r; | 275 | if (r) |
276 | return r; | ||
277 | } | ||
257 | 278 | ||
258 | spin_lock_irqsave(&mac->lock, flags); | 279 | spin_lock_irqsave(&mac->lock, flags); |
259 | memcpy(netdev->dev_addr, addr->sa_data, ETH_ALEN); | 280 | memcpy(netdev->dev_addr, addr->sa_data, ETH_ALEN); |
@@ -855,7 +876,7 @@ static int fill_ctrlset(struct zd_mac *mac, | |||
855 | /* ZD1211B: Computing the length difference this way, gives us | 876 | /* ZD1211B: Computing the length difference this way, gives us |
856 | * flexibility to compute the packet length. | 877 | * flexibility to compute the packet length. |
857 | */ | 878 | */ |
858 | cs->packet_length = cpu_to_le16(mac->chip.is_zd1211b ? | 879 | cs->packet_length = cpu_to_le16(zd_chip_is_zd1211b(&mac->chip) ? |
859 | packet_length - frag_len : packet_length); | 880 | packet_length - frag_len : packet_length); |
860 | 881 | ||
861 | /* | 882 | /* |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h index faf4c7828d4e..9f9344eb50f9 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.h +++ b/drivers/net/wireless/zd1211rw/zd_mac.h | |||
@@ -189,7 +189,8 @@ int zd_mac_init(struct zd_mac *mac, | |||
189 | struct usb_interface *intf); | 189 | struct usb_interface *intf); |
190 | void zd_mac_clear(struct zd_mac *mac); | 190 | void zd_mac_clear(struct zd_mac *mac); |
191 | 191 | ||
192 | int zd_mac_init_hw(struct zd_mac *mac, u8 device_type); | 192 | int zd_mac_preinit_hw(struct zd_mac *mac); |
193 | int zd_mac_init_hw(struct zd_mac *mac); | ||
193 | 194 | ||
194 | int zd_mac_open(struct net_device *netdev); | 195 | int zd_mac_open(struct net_device *netdev); |
195 | int zd_mac_stop(struct net_device *netdev); | 196 | int zd_mac_stop(struct net_device *netdev); |
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.c b/drivers/net/wireless/zd1211rw/zd_rf.c index 7407409b60b1..abe5d38f7f4d 100644 --- a/drivers/net/wireless/zd1211rw/zd_rf.c +++ b/drivers/net/wireless/zd1211rw/zd_rf.c | |||
@@ -34,7 +34,7 @@ static const char * const rfs[] = { | |||
34 | [AL2210_RF] = "AL2210_RF", | 34 | [AL2210_RF] = "AL2210_RF", |
35 | [MAXIM_NEW_RF] = "MAXIM_NEW_RF", | 35 | [MAXIM_NEW_RF] = "MAXIM_NEW_RF", |
36 | [UW2453_RF] = "UW2453_RF", | 36 | [UW2453_RF] = "UW2453_RF", |
37 | [UNKNOWN_A_RF] = "UNKNOWN_A_RF", | 37 | [AL2230S_RF] = "AL2230S_RF", |
38 | [RALINK_RF] = "RALINK_RF", | 38 | [RALINK_RF] = "RALINK_RF", |
39 | [INTERSIL_RF] = "INTERSIL_RF", | 39 | [INTERSIL_RF] = "INTERSIL_RF", |
40 | [RF2959_RF] = "RF2959_RF", | 40 | [RF2959_RF] = "RF2959_RF", |
@@ -77,6 +77,7 @@ int zd_rf_init_hw(struct zd_rf *rf, u8 type) | |||
77 | r = zd_rf_init_rf2959(rf); | 77 | r = zd_rf_init_rf2959(rf); |
78 | break; | 78 | break; |
79 | case AL2230_RF: | 79 | case AL2230_RF: |
80 | case AL2230S_RF: | ||
80 | r = zd_rf_init_al2230(rf); | 81 | r = zd_rf_init_al2230(rf); |
81 | break; | 82 | break; |
82 | case AL7230B_RF: | 83 | case AL7230B_RF: |
diff --git a/drivers/net/wireless/zd1211rw/zd_rf.h b/drivers/net/wireless/zd1211rw/zd_rf.h index c6dfd8227f6e..30502f26b71c 100644 --- a/drivers/net/wireless/zd1211rw/zd_rf.h +++ b/drivers/net/wireless/zd1211rw/zd_rf.h | |||
@@ -26,7 +26,7 @@ | |||
26 | #define AL2210_RF 0x7 | 26 | #define AL2210_RF 0x7 |
27 | #define MAXIM_NEW_RF 0x8 | 27 | #define MAXIM_NEW_RF 0x8 |
28 | #define UW2453_RF 0x9 | 28 | #define UW2453_RF 0x9 |
29 | #define UNKNOWN_A_RF 0xa | 29 | #define AL2230S_RF 0xa |
30 | #define RALINK_RF 0xb | 30 | #define RALINK_RF 0xb |
31 | #define INTERSIL_RF 0xc | 31 | #define INTERSIL_RF 0xc |
32 | #define RF2959_RF 0xd | 32 | #define RF2959_RF 0xd |
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_al2230.c b/drivers/net/wireless/zd1211rw/zd_rf_al2230.c index e7a4ecf7b6e2..006774de3202 100644 --- a/drivers/net/wireless/zd1211rw/zd_rf_al2230.c +++ b/drivers/net/wireless/zd1211rw/zd_rf_al2230.c | |||
@@ -21,6 +21,8 @@ | |||
21 | #include "zd_usb.h" | 21 | #include "zd_usb.h" |
22 | #include "zd_chip.h" | 22 | #include "zd_chip.h" |
23 | 23 | ||
24 | #define IS_AL2230S(chip) ((chip)->al2230s_bit || (chip)->rf.type == AL2230S_RF) | ||
25 | |||
24 | static const u32 zd1211_al2230_table[][3] = { | 26 | static const u32 zd1211_al2230_table[][3] = { |
25 | RF_CHANNEL( 1) = { 0x03f790, 0x033331, 0x00000d, }, | 27 | RF_CHANNEL( 1) = { 0x03f790, 0x033331, 0x00000d, }, |
26 | RF_CHANNEL( 2) = { 0x03f790, 0x0b3331, 0x00000d, }, | 28 | RF_CHANNEL( 2) = { 0x03f790, 0x0b3331, 0x00000d, }, |
@@ -176,7 +178,7 @@ static int zd1211_al2230_init_hw(struct zd_rf *rf) | |||
176 | if (r) | 178 | if (r) |
177 | return r; | 179 | return r; |
178 | 180 | ||
179 | if (chip->al2230s_bit) { | 181 | if (IS_AL2230S(chip)) { |
180 | r = zd_iowrite16a_locked(chip, ioreqs_init_al2230s, | 182 | r = zd_iowrite16a_locked(chip, ioreqs_init_al2230s, |
181 | ARRAY_SIZE(ioreqs_init_al2230s)); | 183 | ARRAY_SIZE(ioreqs_init_al2230s)); |
182 | if (r) | 184 | if (r) |
@@ -188,7 +190,7 @@ static int zd1211_al2230_init_hw(struct zd_rf *rf) | |||
188 | return r; | 190 | return r; |
189 | 191 | ||
190 | /* improve band edge for AL2230S */ | 192 | /* improve band edge for AL2230S */ |
191 | if (chip->al2230s_bit) | 193 | if (IS_AL2230S(chip)) |
192 | r = zd_rfwrite_locked(chip, 0x000824, RF_RV_BITS); | 194 | r = zd_rfwrite_locked(chip, 0x000824, RF_RV_BITS); |
193 | else | 195 | else |
194 | r = zd_rfwrite_locked(chip, 0x0005a4, RF_RV_BITS); | 196 | r = zd_rfwrite_locked(chip, 0x0005a4, RF_RV_BITS); |
@@ -314,7 +316,7 @@ static int zd1211b_al2230_init_hw(struct zd_rf *rf) | |||
314 | if (r) | 316 | if (r) |
315 | return r; | 317 | return r; |
316 | 318 | ||
317 | if (chip->al2230s_bit) { | 319 | if (IS_AL2230S(chip)) { |
318 | r = zd_iowrite16a_locked(chip, ioreqs_init_al2230s, | 320 | r = zd_iowrite16a_locked(chip, ioreqs_init_al2230s, |
319 | ARRAY_SIZE(ioreqs_init_al2230s)); | 321 | ARRAY_SIZE(ioreqs_init_al2230s)); |
320 | if (r) | 322 | if (r) |
@@ -328,7 +330,7 @@ static int zd1211b_al2230_init_hw(struct zd_rf *rf) | |||
328 | if (r) | 330 | if (r) |
329 | return r; | 331 | return r; |
330 | 332 | ||
331 | if (chip->al2230s_bit) | 333 | if (IS_AL2230S(chip)) |
332 | r = zd_rfwrite_locked(chip, 0x241000, RF_RV_BITS); | 334 | r = zd_rfwrite_locked(chip, 0x241000, RF_RV_BITS); |
333 | else | 335 | else |
334 | r = zd_rfwrite_locked(chip, 0x25a000, RF_RV_BITS); | 336 | r = zd_rfwrite_locked(chip, 0x25a000, RF_RV_BITS); |
@@ -422,7 +424,7 @@ int zd_rf_init_al2230(struct zd_rf *rf) | |||
422 | struct zd_chip *chip = zd_rf_to_chip(rf); | 424 | struct zd_chip *chip = zd_rf_to_chip(rf); |
423 | 425 | ||
424 | rf->switch_radio_off = al2230_switch_radio_off; | 426 | rf->switch_radio_off = al2230_switch_radio_off; |
425 | if (chip->is_zd1211b) { | 427 | if (zd_chip_is_zd1211b(chip)) { |
426 | rf->init_hw = zd1211b_al2230_init_hw; | 428 | rf->init_hw = zd1211b_al2230_init_hw; |
427 | rf->set_channel = zd1211b_al2230_set_channel; | 429 | rf->set_channel = zd1211b_al2230_set_channel; |
428 | rf->switch_radio_on = zd1211b_al2230_switch_radio_on; | 430 | rf->switch_radio_on = zd1211b_al2230_switch_radio_on; |
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c b/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c index f4e8b6ada854..73d0bb26f810 100644 --- a/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c +++ b/drivers/net/wireless/zd1211rw/zd_rf_al7230b.c | |||
@@ -473,7 +473,7 @@ int zd_rf_init_al7230b(struct zd_rf *rf) | |||
473 | { | 473 | { |
474 | struct zd_chip *chip = zd_rf_to_chip(rf); | 474 | struct zd_chip *chip = zd_rf_to_chip(rf); |
475 | 475 | ||
476 | if (chip->is_zd1211b) { | 476 | if (zd_chip_is_zd1211b(chip)) { |
477 | rf->init_hw = zd1211b_al7230b_init_hw; | 477 | rf->init_hw = zd1211b_al7230b_init_hw; |
478 | rf->switch_radio_on = zd1211b_al7230b_switch_radio_on; | 478 | rf->switch_radio_on = zd1211b_al7230b_switch_radio_on; |
479 | rf->set_channel = zd1211b_al7230b_set_channel; | 479 | rf->set_channel = zd1211b_al7230b_set_channel; |
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_rf2959.c b/drivers/net/wireless/zd1211rw/zd_rf_rf2959.c index 2d736bdf707c..cc70d40684ea 100644 --- a/drivers/net/wireless/zd1211rw/zd_rf_rf2959.c +++ b/drivers/net/wireless/zd1211rw/zd_rf_rf2959.c | |||
@@ -265,7 +265,7 @@ int zd_rf_init_rf2959(struct zd_rf *rf) | |||
265 | { | 265 | { |
266 | struct zd_chip *chip = zd_rf_to_chip(rf); | 266 | struct zd_chip *chip = zd_rf_to_chip(rf); |
267 | 267 | ||
268 | if (chip->is_zd1211b) { | 268 | if (zd_chip_is_zd1211b(chip)) { |
269 | dev_err(zd_chip_dev(chip), | 269 | dev_err(zd_chip_dev(chip), |
270 | "RF2959 is currently not supported for ZD1211B" | 270 | "RF2959 is currently not supported for ZD1211B" |
271 | " devices\n"); | 271 | " devices\n"); |
diff --git a/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c b/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c index 414e40d571ab..857dcf3eae61 100644 --- a/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c +++ b/drivers/net/wireless/zd1211rw/zd_rf_uw2453.c | |||
@@ -486,7 +486,7 @@ static int uw2453_switch_radio_on(struct zd_rf *rf) | |||
486 | if (r) | 486 | if (r) |
487 | return r; | 487 | return r; |
488 | 488 | ||
489 | if (chip->is_zd1211b) | 489 | if (zd_chip_is_zd1211b(chip)) |
490 | ioreqs[1].value = 0x7f; | 490 | ioreqs[1].value = 0x7f; |
491 | 491 | ||
492 | return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); | 492 | return zd_iowrite16a_locked(chip, ioreqs, ARRAY_SIZE(ioreqs)); |
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c index ca24299a26c6..28d41a29d7b1 100644 --- a/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zd1211rw/zd_usb.c | |||
@@ -71,6 +71,7 @@ static struct usb_device_id usb_ids[] = { | |||
71 | { USB_DEVICE(0x0586, 0x3412), .driver_info = DEVICE_ZD1211B }, | 71 | { USB_DEVICE(0x0586, 0x3412), .driver_info = DEVICE_ZD1211B }, |
72 | { USB_DEVICE(0x0586, 0x3413), .driver_info = DEVICE_ZD1211B }, | 72 | { USB_DEVICE(0x0586, 0x3413), .driver_info = DEVICE_ZD1211B }, |
73 | { USB_DEVICE(0x0053, 0x5301), .driver_info = DEVICE_ZD1211B }, | 73 | { USB_DEVICE(0x0053, 0x5301), .driver_info = DEVICE_ZD1211B }, |
74 | { USB_DEVICE(0x0411, 0x00da), .driver_info = DEVICE_ZD1211B }, | ||
74 | /* "Driverless" devices that need ejecting */ | 75 | /* "Driverless" devices that need ejecting */ |
75 | { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, | 76 | { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, |
76 | { USB_DEVICE(0x0ace, 0x20ff), .driver_info = DEVICE_INSTALLER }, | 77 | { USB_DEVICE(0x0ace, 0x20ff), .driver_info = DEVICE_INSTALLER }, |
@@ -195,26 +196,27 @@ static u16 get_word(const void *data, u16 offset) | |||
195 | return le16_to_cpu(p[offset]); | 196 | return le16_to_cpu(p[offset]); |
196 | } | 197 | } |
197 | 198 | ||
198 | static char *get_fw_name(char *buffer, size_t size, u8 device_type, | 199 | static char *get_fw_name(struct zd_usb *usb, char *buffer, size_t size, |
199 | const char* postfix) | 200 | const char* postfix) |
200 | { | 201 | { |
201 | scnprintf(buffer, size, "%s%s", | 202 | scnprintf(buffer, size, "%s%s", |
202 | device_type == DEVICE_ZD1211B ? | 203 | usb->is_zd1211b ? |
203 | FW_ZD1211B_PREFIX : FW_ZD1211_PREFIX, | 204 | FW_ZD1211B_PREFIX : FW_ZD1211_PREFIX, |
204 | postfix); | 205 | postfix); |
205 | return buffer; | 206 | return buffer; |
206 | } | 207 | } |
207 | 208 | ||
208 | static int handle_version_mismatch(struct usb_device *udev, u8 device_type, | 209 | static int handle_version_mismatch(struct zd_usb *usb, |
209 | const struct firmware *ub_fw) | 210 | const struct firmware *ub_fw) |
210 | { | 211 | { |
212 | struct usb_device *udev = zd_usb_to_usbdev(usb); | ||
211 | const struct firmware *ur_fw = NULL; | 213 | const struct firmware *ur_fw = NULL; |
212 | int offset; | 214 | int offset; |
213 | int r = 0; | 215 | int r = 0; |
214 | char fw_name[128]; | 216 | char fw_name[128]; |
215 | 217 | ||
216 | r = request_fw_file(&ur_fw, | 218 | r = request_fw_file(&ur_fw, |
217 | get_fw_name(fw_name, sizeof(fw_name), device_type, "ur"), | 219 | get_fw_name(usb, fw_name, sizeof(fw_name), "ur"), |
218 | &udev->dev); | 220 | &udev->dev); |
219 | if (r) | 221 | if (r) |
220 | goto error; | 222 | goto error; |
@@ -237,11 +239,12 @@ error: | |||
237 | return r; | 239 | return r; |
238 | } | 240 | } |
239 | 241 | ||
240 | static int upload_firmware(struct usb_device *udev, u8 device_type) | 242 | static int upload_firmware(struct zd_usb *usb) |
241 | { | 243 | { |
242 | int r; | 244 | int r; |
243 | u16 fw_bcdDevice; | 245 | u16 fw_bcdDevice; |
244 | u16 bcdDevice; | 246 | u16 bcdDevice; |
247 | struct usb_device *udev = zd_usb_to_usbdev(usb); | ||
245 | const struct firmware *ub_fw = NULL; | 248 | const struct firmware *ub_fw = NULL; |
246 | const struct firmware *uph_fw = NULL; | 249 | const struct firmware *uph_fw = NULL; |
247 | char fw_name[128]; | 250 | char fw_name[128]; |
@@ -249,7 +252,7 @@ static int upload_firmware(struct usb_device *udev, u8 device_type) | |||
249 | bcdDevice = get_bcdDevice(udev); | 252 | bcdDevice = get_bcdDevice(udev); |
250 | 253 | ||
251 | r = request_fw_file(&ub_fw, | 254 | r = request_fw_file(&ub_fw, |
252 | get_fw_name(fw_name, sizeof(fw_name), device_type, "ub"), | 255 | get_fw_name(usb, fw_name, sizeof(fw_name), "ub"), |
253 | &udev->dev); | 256 | &udev->dev); |
254 | if (r) | 257 | if (r) |
255 | goto error; | 258 | goto error; |
@@ -264,7 +267,7 @@ static int upload_firmware(struct usb_device *udev, u8 device_type) | |||
264 | dev_warn(&udev->dev, "device has old bootcode, please " | 267 | dev_warn(&udev->dev, "device has old bootcode, please " |
265 | "report success or failure\n"); | 268 | "report success or failure\n"); |
266 | 269 | ||
267 | r = handle_version_mismatch(udev, device_type, ub_fw); | 270 | r = handle_version_mismatch(usb, ub_fw); |
268 | if (r) | 271 | if (r) |
269 | goto error; | 272 | goto error; |
270 | } else { | 273 | } else { |
@@ -275,7 +278,7 @@ static int upload_firmware(struct usb_device *udev, u8 device_type) | |||
275 | 278 | ||
276 | 279 | ||
277 | r = request_fw_file(&uph_fw, | 280 | r = request_fw_file(&uph_fw, |
278 | get_fw_name(fw_name, sizeof(fw_name), device_type, "uphr"), | 281 | get_fw_name(usb, fw_name, sizeof(fw_name), "uphr"), |
279 | &udev->dev); | 282 | &udev->dev); |
280 | if (r) | 283 | if (r) |
281 | goto error; | 284 | goto error; |
@@ -294,6 +297,30 @@ error: | |||
294 | return r; | 297 | return r; |
295 | } | 298 | } |
296 | 299 | ||
300 | /* Read data from device address space using "firmware interface" which does | ||
301 | * not require firmware to be loaded. */ | ||
302 | int zd_usb_read_fw(struct zd_usb *usb, zd_addr_t addr, u8 *data, u16 len) | ||
303 | { | ||
304 | int r; | ||
305 | struct usb_device *udev = zd_usb_to_usbdev(usb); | ||
306 | |||
307 | r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), | ||
308 | USB_REQ_FIRMWARE_READ_DATA, USB_DIR_IN | 0x40, addr, 0, | ||
309 | data, len, 5000); | ||
310 | if (r < 0) { | ||
311 | dev_err(&udev->dev, | ||
312 | "read over firmware interface failed: %d\n", r); | ||
313 | return r; | ||
314 | } else if (r != len) { | ||
315 | dev_err(&udev->dev, | ||
316 | "incomplete read over firmware interface: %d/%d\n", | ||
317 | r, len); | ||
318 | return -EIO; | ||
319 | } | ||
320 | |||
321 | return 0; | ||
322 | } | ||
323 | |||
297 | #define urb_dev(urb) (&(urb)->dev->dev) | 324 | #define urb_dev(urb) (&(urb)->dev->dev) |
298 | 325 | ||
299 | static inline void handle_regs_int(struct urb *urb) | 326 | static inline void handle_regs_int(struct urb *urb) |
@@ -920,9 +947,42 @@ static int eject_installer(struct usb_interface *intf) | |||
920 | return 0; | 947 | return 0; |
921 | } | 948 | } |
922 | 949 | ||
950 | int zd_usb_init_hw(struct zd_usb *usb) | ||
951 | { | ||
952 | int r; | ||
953 | struct zd_mac *mac = zd_usb_to_mac(usb); | ||
954 | |||
955 | dev_dbg_f(zd_usb_dev(usb), "\n"); | ||
956 | |||
957 | r = upload_firmware(usb); | ||
958 | if (r) { | ||
959 | dev_err(zd_usb_dev(usb), | ||
960 | "couldn't load firmware. Error number %d\n", r); | ||
961 | return r; | ||
962 | } | ||
963 | |||
964 | r = usb_reset_configuration(zd_usb_to_usbdev(usb)); | ||
965 | if (r) { | ||
966 | dev_dbg_f(zd_usb_dev(usb), | ||
967 | "couldn't reset configuration. Error number %d\n", r); | ||
968 | return r; | ||
969 | } | ||
970 | |||
971 | r = zd_mac_init_hw(mac); | ||
972 | if (r) { | ||
973 | dev_dbg_f(zd_usb_dev(usb), | ||
974 | "couldn't initialize mac. Error number %d\n", r); | ||
975 | return r; | ||
976 | } | ||
977 | |||
978 | usb->initialized = 1; | ||
979 | return 0; | ||
980 | } | ||
981 | |||
923 | static int probe(struct usb_interface *intf, const struct usb_device_id *id) | 982 | static int probe(struct usb_interface *intf, const struct usb_device_id *id) |
924 | { | 983 | { |
925 | int r; | 984 | int r; |
985 | struct zd_usb *usb; | ||
926 | struct usb_device *udev = interface_to_usbdev(intf); | 986 | struct usb_device *udev = interface_to_usbdev(intf); |
927 | struct net_device *netdev = NULL; | 987 | struct net_device *netdev = NULL; |
928 | 988 | ||
@@ -950,26 +1010,10 @@ static int probe(struct usb_interface *intf, const struct usb_device_id *id) | |||
950 | goto error; | 1010 | goto error; |
951 | } | 1011 | } |
952 | 1012 | ||
953 | r = upload_firmware(udev, id->driver_info); | 1013 | usb = &zd_netdev_mac(netdev)->chip.usb; |
954 | if (r) { | 1014 | usb->is_zd1211b = (id->driver_info == DEVICE_ZD1211B) != 0; |
955 | dev_err(&intf->dev, | ||
956 | "couldn't load firmware. Error number %d\n", r); | ||
957 | goto error; | ||
958 | } | ||
959 | 1015 | ||
960 | r = usb_reset_configuration(udev); | 1016 | r = zd_mac_preinit_hw(zd_netdev_mac(netdev)); |
961 | if (r) { | ||
962 | dev_dbg_f(&intf->dev, | ||
963 | "couldn't reset configuration. Error number %d\n", r); | ||
964 | goto error; | ||
965 | } | ||
966 | |||
967 | /* At this point the interrupt endpoint is not generally enabled. We | ||
968 | * save the USB bandwidth until the network device is opened. But | ||
969 | * notify that the initialization of the MAC will require the | ||
970 | * interrupts to be temporary enabled. | ||
971 | */ | ||
972 | r = zd_mac_init_hw(zd_netdev_mac(netdev), id->driver_info); | ||
973 | if (r) { | 1017 | if (r) { |
974 | dev_dbg_f(&intf->dev, | 1018 | dev_dbg_f(&intf->dev, |
975 | "couldn't initialize mac. Error number %d\n", r); | 1019 | "couldn't initialize mac. Error number %d\n", r); |
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.h b/drivers/net/wireless/zd1211rw/zd_usb.h index 506ea6a74393..961a7a12ad68 100644 --- a/drivers/net/wireless/zd1211rw/zd_usb.h +++ b/drivers/net/wireless/zd1211rw/zd_usb.h | |||
@@ -188,6 +188,7 @@ struct zd_usb { | |||
188 | struct zd_usb_rx rx; | 188 | struct zd_usb_rx rx; |
189 | struct zd_usb_tx tx; | 189 | struct zd_usb_tx tx; |
190 | struct usb_interface *intf; | 190 | struct usb_interface *intf; |
191 | u8 is_zd1211b:1, initialized:1; | ||
191 | }; | 192 | }; |
192 | 193 | ||
193 | #define zd_usb_dev(usb) (&usb->intf->dev) | 194 | #define zd_usb_dev(usb) (&usb->intf->dev) |
@@ -236,6 +237,8 @@ int zd_usb_iowrite16v(struct zd_usb *usb, const struct zd_ioreq16 *ioreqs, | |||
236 | 237 | ||
237 | int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits); | 238 | int zd_usb_rfwrite(struct zd_usb *usb, u32 value, u8 bits); |
238 | 239 | ||
240 | int zd_usb_read_fw(struct zd_usb *usb, zd_addr_t addr, u8 *data, u16 len); | ||
241 | |||
239 | extern struct workqueue_struct *zd_workqueue; | 242 | extern struct workqueue_struct *zd_workqueue; |
240 | 243 | ||
241 | #endif /* _ZD_USB_H */ | 244 | #endif /* _ZD_USB_H */ |