diff options
author | David Woodhouse <dwmw2@infradead.org> | 2007-12-14 00:47:05 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:07:27 -0500 |
commit | eae86bf378de981696697426831bd9db68930740 (patch) | |
tree | 36ddcb42add91bb2f52ff57e1abe929129f413a6 /drivers/net/wireless/libertas/if_usb.c | |
parent | b926d6b31e2dd8f1bc21a9576aff0e486e21d32a (diff) |
libertas: clean up if_usb driver
It was just getting on my tits, really.
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/if_usb.c')
-rw-r--r-- | drivers/net/wireless/libertas/if_usb.c | 428 |
1 files changed, 181 insertions, 247 deletions
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index 25925bd761d8..9cb9e031040d 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c | |||
@@ -16,6 +16,9 @@ | |||
16 | #include "cmd.h" | 16 | #include "cmd.h" |
17 | #include "if_usb.h" | 17 | #include "if_usb.h" |
18 | 18 | ||
19 | #define INSANEDEBUG 0 | ||
20 | #define lbs_deb_usb2(...) do { if (INSANEDEBUG) lbs_deb_usbd(__VA_ARGS__); } while (0) | ||
21 | |||
19 | #define MESSAGE_HEADER_LEN 4 | 22 | #define MESSAGE_HEADER_LEN 4 |
20 | 23 | ||
21 | static char *lbs_fw_name = "usb8388.bin"; | 24 | static char *lbs_fw_name = "usb8388.bin"; |
@@ -32,17 +35,16 @@ MODULE_DEVICE_TABLE(usb, if_usb_table); | |||
32 | 35 | ||
33 | static void if_usb_receive(struct urb *urb); | 36 | static void if_usb_receive(struct urb *urb); |
34 | static void if_usb_receive_fwload(struct urb *urb); | 37 | static void if_usb_receive_fwload(struct urb *urb); |
35 | static int if_usb_prog_firmware(struct usb_card_rec *cardp); | 38 | static int if_usb_prog_firmware(struct if_usb_card *cardp); |
36 | static int if_usb_host_to_card(struct lbs_private *priv, | 39 | static int if_usb_host_to_card(struct lbs_private *priv, uint8_t type, |
37 | u8 type, | 40 | uint8_t *payload, uint16_t nb); |
38 | u8 *payload, | 41 | static int if_usb_get_int_status(struct lbs_private *priv, uint8_t *); |
39 | u16 nb); | ||
40 | static int if_usb_get_int_status(struct lbs_private *priv, u8 *); | ||
41 | static int if_usb_read_event_cause(struct lbs_private *); | 42 | static int if_usb_read_event_cause(struct lbs_private *); |
42 | static int usb_tx_block(struct usb_card_rec *cardp, u8 *payload, u16 nb); | 43 | static int usb_tx_block(struct if_usb_card *cardp, uint8_t *payload, |
43 | static void if_usb_free(struct usb_card_rec *cardp); | 44 | uint16_t nb); |
44 | static int if_usb_submit_rx_urb(struct usb_card_rec *cardp); | 45 | static void if_usb_free(struct if_usb_card *cardp); |
45 | static int if_usb_reset_device(struct usb_card_rec *cardp); | 46 | static int if_usb_submit_rx_urb(struct if_usb_card *cardp); |
47 | static int if_usb_reset_device(struct if_usb_card *cardp); | ||
46 | 48 | ||
47 | /** | 49 | /** |
48 | * @brief call back function to handle the status of the URB | 50 | * @brief call back function to handle the status of the URB |
@@ -51,18 +53,16 @@ static int if_usb_reset_device(struct usb_card_rec *cardp); | |||
51 | */ | 53 | */ |
52 | static void if_usb_write_bulk_callback(struct urb *urb) | 54 | static void if_usb_write_bulk_callback(struct urb *urb) |
53 | { | 55 | { |
54 | struct usb_card_rec *cardp = (struct usb_card_rec *) urb->context; | 56 | struct if_usb_card *cardp = (struct if_usb_card *) urb->context; |
55 | 57 | ||
56 | /* handle the transmission complete validations */ | 58 | /* handle the transmission complete validations */ |
57 | 59 | ||
58 | if (urb->status == 0) { | 60 | if (urb->status == 0) { |
59 | struct lbs_private *priv = cardp->priv; | 61 | struct lbs_private *priv = cardp->priv; |
60 | 62 | ||
61 | /* | 63 | lbs_deb_usb2(&urb->dev->dev, "URB status is successful\n"); |
62 | lbs_deb_usbd(&urb->dev->dev, "URB status is successfull\n"); | 64 | lbs_deb_usb2(&urb->dev->dev, "Actual length transmitted %d\n", |
63 | lbs_deb_usbd(&urb->dev->dev, "Actual length transmitted %d\n", | 65 | urb->actual_length); |
64 | urb->actual_length); | ||
65 | */ | ||
66 | 66 | ||
67 | /* Used for both firmware TX and regular TX. priv isn't | 67 | /* Used for both firmware TX and regular TX. priv isn't |
68 | * valid at firmware load time. | 68 | * valid at firmware load time. |
@@ -79,10 +79,10 @@ static void if_usb_write_bulk_callback(struct urb *urb) | |||
79 | 79 | ||
80 | /** | 80 | /** |
81 | * @brief free tx/rx urb, skb and rx buffer | 81 | * @brief free tx/rx urb, skb and rx buffer |
82 | * @param cardp pointer usb_card_rec | 82 | * @param cardp pointer if_usb_card |
83 | * @return N/A | 83 | * @return N/A |
84 | */ | 84 | */ |
85 | static void if_usb_free(struct usb_card_rec *cardp) | 85 | static void if_usb_free(struct if_usb_card *cardp) |
86 | { | 86 | { |
87 | lbs_deb_enter(LBS_DEB_USB); | 87 | lbs_deb_enter(LBS_DEB_USB); |
88 | 88 | ||
@@ -96,8 +96,8 @@ static void if_usb_free(struct usb_card_rec *cardp) | |||
96 | usb_free_urb(cardp->rx_urb); | 96 | usb_free_urb(cardp->rx_urb); |
97 | cardp->rx_urb = NULL; | 97 | cardp->rx_urb = NULL; |
98 | 98 | ||
99 | kfree(cardp->bulk_out_buffer); | 99 | kfree(cardp->ep_out_buf); |
100 | cardp->bulk_out_buffer = NULL; | 100 | cardp->ep_out_buf = NULL; |
101 | 101 | ||
102 | lbs_deb_leave(LBS_DEB_USB); | 102 | lbs_deb_leave(LBS_DEB_USB); |
103 | } | 103 | } |
@@ -115,7 +115,7 @@ static void if_usb_set_boot2_ver(struct lbs_private *priv) | |||
115 | 115 | ||
116 | static void if_usb_fw_timeo(unsigned long priv) | 116 | static void if_usb_fw_timeo(unsigned long priv) |
117 | { | 117 | { |
118 | struct usb_card_rec *cardp = (void *)priv; | 118 | struct if_usb_card *cardp = (void *)priv; |
119 | 119 | ||
120 | if (cardp->fwdnldover) { | 120 | if (cardp->fwdnldover) { |
121 | lbs_deb_usb("Download complete, no event. Assuming success\n"); | 121 | lbs_deb_usb("Download complete, no event. Assuming success\n"); |
@@ -125,6 +125,7 @@ static void if_usb_fw_timeo(unsigned long priv) | |||
125 | } | 125 | } |
126 | wake_up(&cardp->fw_wq); | 126 | wake_up(&cardp->fw_wq); |
127 | } | 127 | } |
128 | |||
128 | /** | 129 | /** |
129 | * @brief sets the configuration values | 130 | * @brief sets the configuration values |
130 | * @param ifnum interface number | 131 | * @param ifnum interface number |
@@ -138,12 +139,12 @@ static int if_usb_probe(struct usb_interface *intf, | |||
138 | struct usb_host_interface *iface_desc; | 139 | struct usb_host_interface *iface_desc; |
139 | struct usb_endpoint_descriptor *endpoint; | 140 | struct usb_endpoint_descriptor *endpoint; |
140 | struct lbs_private *priv; | 141 | struct lbs_private *priv; |
141 | struct usb_card_rec *cardp; | 142 | struct if_usb_card *cardp; |
142 | int i; | 143 | int i; |
143 | 144 | ||
144 | udev = interface_to_usbdev(intf); | 145 | udev = interface_to_usbdev(intf); |
145 | 146 | ||
146 | cardp = kzalloc(sizeof(struct usb_card_rec), GFP_KERNEL); | 147 | cardp = kzalloc(sizeof(struct if_usb_card), GFP_KERNEL); |
147 | if (!cardp) { | 148 | if (!cardp) { |
148 | lbs_pr_err("Out of memory allocating private data.\n"); | 149 | lbs_pr_err("Out of memory allocating private data.\n"); |
149 | goto error; | 150 | goto error; |
@@ -156,7 +157,7 @@ static int if_usb_probe(struct usb_interface *intf, | |||
156 | iface_desc = intf->cur_altsetting; | 157 | iface_desc = intf->cur_altsetting; |
157 | 158 | ||
158 | lbs_deb_usbd(&udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X" | 159 | lbs_deb_usbd(&udev->dev, "bcdUSB = 0x%X bDeviceClass = 0x%X" |
159 | " bDeviceSubClass = 0x%X, bDeviceProtocol = 0x%X\n", | 160 | " bDeviceSubClass = 0x%X, bDeviceProtocol = 0x%X\n", |
160 | le16_to_cpu(udev->descriptor.bcdUSB), | 161 | le16_to_cpu(udev->descriptor.bcdUSB), |
161 | udev->descriptor.bDeviceClass, | 162 | udev->descriptor.bDeviceClass, |
162 | udev->descriptor.bDeviceSubClass, | 163 | udev->descriptor.bDeviceSubClass, |
@@ -164,61 +165,40 @@ static int if_usb_probe(struct usb_interface *intf, | |||
164 | 165 | ||
165 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { | 166 | for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { |
166 | endpoint = &iface_desc->endpoint[i].desc; | 167 | endpoint = &iface_desc->endpoint[i].desc; |
167 | if ((endpoint->bEndpointAddress & USB_ENDPOINT_DIR_MASK) | 168 | if (usb_endpoint_is_bulk_in(endpoint)) { |
168 | && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | 169 | cardp->ep_in_size = le16_to_cpu(endpoint->wMaxPacketSize); |
169 | USB_ENDPOINT_XFER_BULK)) { | 170 | cardp->ep_in = usb_endpoint_num(endpoint); |
170 | /* we found a bulk in endpoint */ | ||
171 | lbs_deb_usbd(&udev->dev, "Bulk in size is %d\n", | ||
172 | le16_to_cpu(endpoint->wMaxPacketSize)); | ||
173 | if (!(cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL))) { | ||
174 | lbs_deb_usbd(&udev->dev, | ||
175 | "Rx URB allocation failed\n"); | ||
176 | goto dealloc; | ||
177 | } | ||
178 | cardp->bulk_in_size = | ||
179 | le16_to_cpu(endpoint->wMaxPacketSize); | ||
180 | cardp->bulk_in_endpointAddr = | ||
181 | (endpoint-> | ||
182 | bEndpointAddress & USB_ENDPOINT_NUMBER_MASK); | ||
183 | lbs_deb_usbd(&udev->dev, "in_endpoint = %d\n", | ||
184 | endpoint->bEndpointAddress); | ||
185 | } | ||
186 | 171 | ||
187 | if (((endpoint-> | 172 | lbs_deb_usbd(&udev->dev, "in_endpoint = %d\n", cardp->ep_in); |
188 | bEndpointAddress & USB_ENDPOINT_DIR_MASK) == | 173 | lbs_deb_usbd(&udev->dev, "Bulk in size is %d\n", cardp->ep_in_size); |
189 | USB_DIR_OUT) | ||
190 | && ((endpoint->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
191 | USB_ENDPOINT_XFER_BULK)) { | ||
192 | /* We found bulk out endpoint */ | ||
193 | if (!(cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL))) { | ||
194 | lbs_deb_usbd(&udev->dev, | ||
195 | "Tx URB allocation failed\n"); | ||
196 | goto dealloc; | ||
197 | } | ||
198 | 174 | ||
199 | cardp->bulk_out_size = | 175 | } else if (usb_endpoint_is_bulk_out(endpoint)) { |
200 | le16_to_cpu(endpoint->wMaxPacketSize); | 176 | cardp->ep_out_size = le16_to_cpu(endpoint->wMaxPacketSize); |
201 | lbs_deb_usbd(&udev->dev, | 177 | cardp->ep_out = usb_endpoint_num(endpoint); |
202 | "Bulk out size is %d\n", | 178 | |
203 | le16_to_cpu(endpoint->wMaxPacketSize)); | 179 | lbs_deb_usbd(&udev->dev, "out_endpoint = %d\n", cardp->ep_out); |
204 | cardp->bulk_out_endpointAddr = | 180 | lbs_deb_usbd(&udev->dev, "Bulk out size is %d\n", cardp->ep_out_size); |
205 | endpoint->bEndpointAddress; | ||
206 | lbs_deb_usbd(&udev->dev, "out_endpoint = %d\n", | ||
207 | endpoint->bEndpointAddress); | ||
208 | cardp->bulk_out_buffer = | ||
209 | kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE, | ||
210 | GFP_KERNEL); | ||
211 | |||
212 | if (!cardp->bulk_out_buffer) { | ||
213 | lbs_deb_usbd(&udev->dev, | ||
214 | "Could not allocate buffer\n"); | ||
215 | goto dealloc; | ||
216 | } | ||
217 | } | 181 | } |
218 | } | 182 | } |
183 | if (!cardp->ep_out_size || !cardp->ep_in_size) { | ||
184 | lbs_deb_usbd(&udev->dev, "Endpoints not found\n"); | ||
185 | goto dealloc; | ||
186 | } | ||
187 | if (!(cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL))) { | ||
188 | lbs_deb_usbd(&udev->dev, "Rx URB allocation failed\n"); | ||
189 | goto dealloc; | ||
190 | } | ||
191 | if (!(cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL))) { | ||
192 | lbs_deb_usbd(&udev->dev, "Tx URB allocation failed\n"); | ||
193 | goto dealloc; | ||
194 | } | ||
195 | cardp->ep_out_buf = kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE, GFP_KERNEL); | ||
196 | if (!cardp->ep_out_buf) { | ||
197 | lbs_deb_usbd(&udev->dev, "Could not allocate buffer\n"); | ||
198 | goto dealloc; | ||
199 | } | ||
219 | 200 | ||
220 | /* Upload firmware */ | 201 | /* Upload firmware */ |
221 | cardp->rinfo.cardp = cardp; | ||
222 | if (if_usb_prog_firmware(cardp)) { | 202 | if (if_usb_prog_firmware(cardp)) { |
223 | lbs_deb_usbd(&udev->dev, "FW upload failed\n"); | 203 | lbs_deb_usbd(&udev->dev, "FW upload failed\n"); |
224 | goto err_prog_firmware; | 204 | goto err_prog_firmware; |
@@ -269,12 +249,11 @@ error: | |||
269 | */ | 249 | */ |
270 | static void if_usb_disconnect(struct usb_interface *intf) | 250 | static void if_usb_disconnect(struct usb_interface *intf) |
271 | { | 251 | { |
272 | struct usb_card_rec *cardp = usb_get_intfdata(intf); | 252 | struct if_usb_card *cardp = usb_get_intfdata(intf); |
273 | struct lbs_private *priv = (struct lbs_private *) cardp->priv; | 253 | struct lbs_private *priv = (struct lbs_private *) cardp->priv; |
274 | 254 | ||
275 | lbs_deb_enter(LBS_DEB_MAIN); | 255 | lbs_deb_enter(LBS_DEB_MAIN); |
276 | 256 | ||
277 | /* Update Surprise removed to TRUE */ | ||
278 | cardp->surprise_removed = 1; | 257 | cardp->surprise_removed = 1; |
279 | 258 | ||
280 | if (priv) { | 259 | if (priv) { |
@@ -297,98 +276,75 @@ static void if_usb_disconnect(struct usb_interface *intf) | |||
297 | * @param priv pointer to struct lbs_private | 276 | * @param priv pointer to struct lbs_private |
298 | * @return 0 | 277 | * @return 0 |
299 | */ | 278 | */ |
300 | static int if_usb_send_fw_pkt(struct usb_card_rec *cardp) | 279 | static int if_usb_send_fw_pkt(struct if_usb_card *cardp) |
301 | { | 280 | { |
302 | struct FWData *fwdata; | 281 | struct fwdata *fwdata = cardp->ep_out_buf; |
303 | struct fwheader *fwheader; | 282 | uint8_t *firmware = cardp->fw->data; |
304 | u8 *firmware = cardp->fw->data; | ||
305 | |||
306 | fwdata = kmalloc(sizeof(struct FWData), GFP_ATOMIC); | ||
307 | |||
308 | if (!fwdata) | ||
309 | return -1; | ||
310 | |||
311 | fwheader = &fwdata->fwheader; | ||
312 | 283 | ||
284 | /* If we got a CRC failure on the last block, back | ||
285 | up and retry it */ | ||
313 | if (!cardp->CRC_OK) { | 286 | if (!cardp->CRC_OK) { |
314 | cardp->totalbytes = cardp->fwlastblksent; | 287 | cardp->totalbytes = cardp->fwlastblksent; |
315 | cardp->fwseqnum = cardp->lastseqnum - 1; | 288 | cardp->fwseqnum--; |
316 | } | 289 | } |
317 | 290 | ||
318 | /* | 291 | lbs_deb_usb2(&cardp->udev->dev, "totalbytes = %d\n", |
319 | lbs_deb_usbd(&cardp->udev->dev, "totalbytes = %d\n", | 292 | cardp->totalbytes); |
320 | cardp->totalbytes); | ||
321 | */ | ||
322 | 293 | ||
323 | memcpy(fwheader, &firmware[cardp->totalbytes], | 294 | /* struct fwdata (which we sent to the card) has an |
295 | extra __le32 field in between the header and the data, | ||
296 | which is not in the struct fwheader in the actual | ||
297 | firmware binary. Insert the seqnum in the middle... */ | ||
298 | memcpy(&fwdata->hdr, &firmware[cardp->totalbytes], | ||
324 | sizeof(struct fwheader)); | 299 | sizeof(struct fwheader)); |
325 | 300 | ||
326 | cardp->fwlastblksent = cardp->totalbytes; | 301 | cardp->fwlastblksent = cardp->totalbytes; |
327 | cardp->totalbytes += sizeof(struct fwheader); | 302 | cardp->totalbytes += sizeof(struct fwheader); |
328 | 303 | ||
329 | /* lbs_deb_usbd(&cardp->udev->dev,"Copy Data\n"); */ | ||
330 | memcpy(fwdata->data, &firmware[cardp->totalbytes], | 304 | memcpy(fwdata->data, &firmware[cardp->totalbytes], |
331 | le32_to_cpu(fwdata->fwheader.datalength)); | 305 | le32_to_cpu(fwdata->hdr.datalength)); |
332 | 306 | ||
333 | /* | 307 | lbs_deb_usb2(&cardp->udev->dev, "Data length = %d\n", |
334 | lbs_deb_usbd(&cardp->udev->dev, | 308 | le32_to_cpu(fwdata->hdr.datalength)); |
335 | "Data length = %d\n", le32_to_cpu(fwdata->fwheader.datalength)); | ||
336 | */ | ||
337 | 309 | ||
338 | cardp->fwseqnum = cardp->fwseqnum + 1; | 310 | fwdata->seqnum = cpu_to_le32(++cardp->fwseqnum); |
311 | cardp->totalbytes += le32_to_cpu(fwdata->hdr.datalength); | ||
339 | 312 | ||
340 | fwdata->seqnum = cpu_to_le32(cardp->fwseqnum); | 313 | usb_tx_block(cardp, cardp->ep_out_buf, sizeof(struct fwdata) + |
341 | cardp->lastseqnum = cardp->fwseqnum; | 314 | le32_to_cpu(fwdata->hdr.datalength)); |
342 | cardp->totalbytes += le32_to_cpu(fwdata->fwheader.datalength); | 315 | |
316 | if (fwdata->hdr.dnldcmd == cpu_to_le32(FW_HAS_DATA_TO_RECV)) { | ||
317 | lbs_deb_usb2(&cardp->udev->dev, "There are data to follow\n"); | ||
318 | lbs_deb_usb2(&cardp->udev->dev, "seqnum = %d totalbytes = %d\n", | ||
319 | cardp->fwseqnum, cardp->totalbytes); | ||
320 | } else if (fwdata->hdr.dnldcmd == cpu_to_le32(FW_HAS_LAST_BLOCK)) { | ||
321 | lbs_deb_usb2(&cardp->udev->dev, "Host has finished FW downloading\n"); | ||
322 | lbs_deb_usb2(&cardp->udev->dev, "Donwloading FW JUMP BLOCK\n"); | ||
343 | 323 | ||
344 | if (fwheader->dnldcmd == cpu_to_le32(FW_HAS_DATA_TO_RECV)) { | ||
345 | /* | ||
346 | lbs_deb_usbd(&cardp->udev->dev, "There are data to follow\n"); | ||
347 | lbs_deb_usbd(&cardp->udev->dev, | ||
348 | "seqnum = %d totalbytes = %d\n", cardp->fwseqnum, | ||
349 | cardp->totalbytes); | ||
350 | */ | ||
351 | memcpy(cardp->bulk_out_buffer, fwheader, FW_DATA_XMIT_SIZE); | ||
352 | usb_tx_block(cardp, cardp->bulk_out_buffer, FW_DATA_XMIT_SIZE); | ||
353 | |||
354 | } else if (fwdata->fwheader.dnldcmd == cpu_to_le32(FW_HAS_LAST_BLOCK)) { | ||
355 | /* | ||
356 | lbs_deb_usbd(&cardp->udev->dev, | ||
357 | "Host has finished FW downloading\n"); | ||
358 | lbs_deb_usbd(&cardp->udev->dev, | ||
359 | "Donwloading FW JUMP BLOCK\n"); | ||
360 | */ | ||
361 | memcpy(cardp->bulk_out_buffer, fwheader, FW_DATA_XMIT_SIZE); | ||
362 | usb_tx_block(cardp, cardp->bulk_out_buffer, FW_DATA_XMIT_SIZE); | ||
363 | cardp->fwfinalblk = 1; | 324 | cardp->fwfinalblk = 1; |
364 | } | 325 | } |
365 | 326 | ||
366 | /* | 327 | lbs_deb_usb2(&cardp->udev->dev, "Firmware download done; size %d\n", |
367 | lbs_deb_usbd(&cardp->udev->dev, | 328 | cardp->totalbytes); |
368 | "The firmware download is done size is %d\n", | ||
369 | cardp->totalbytes); | ||
370 | */ | ||
371 | |||
372 | kfree(fwdata); | ||
373 | 329 | ||
374 | return 0; | 330 | return 0; |
375 | } | 331 | } |
376 | 332 | ||
377 | static int if_usb_reset_device(struct usb_card_rec *cardp) | 333 | static int if_usb_reset_device(struct if_usb_card *cardp) |
378 | { | 334 | { |
379 | struct cmd_ds_command *cmd = (void *)&cardp->bulk_out_buffer[4]; | 335 | struct cmd_ds_command *cmd = cardp->ep_out_buf + 4; |
380 | int ret; | 336 | int ret; |
381 | 337 | ||
382 | lbs_deb_enter(LBS_DEB_USB); | 338 | lbs_deb_enter(LBS_DEB_USB); |
383 | 339 | ||
384 | *(__le32 *)cardp->bulk_out_buffer = cpu_to_le32(CMD_TYPE_REQUEST); | 340 | *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_REQUEST); |
385 | 341 | ||
386 | cmd->command = cpu_to_le16(CMD_802_11_RESET); | 342 | cmd->command = cpu_to_le16(CMD_802_11_RESET); |
387 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_reset) + S_DS_GEN); | 343 | cmd->size = cpu_to_le16(sizeof(struct cmd_ds_802_11_reset) + S_DS_GEN); |
388 | cmd->result = cpu_to_le16(0); | 344 | cmd->result = cpu_to_le16(0); |
389 | cmd->seqnum = cpu_to_le16(0x5a5a); | 345 | cmd->seqnum = cpu_to_le16(0x5a5a); |
390 | cmd->params.reset.action = cpu_to_le16(CMD_ACT_HALT); | 346 | cmd->params.reset.action = cpu_to_le16(CMD_ACT_HALT); |
391 | usb_tx_block(cardp, cardp->bulk_out_buffer, 4 + S_DS_GEN + sizeof(struct cmd_ds_802_11_reset)); | 347 | usb_tx_block(cardp, cardp->ep_out_buf, 4 + S_DS_GEN + sizeof(struct cmd_ds_802_11_reset)); |
392 | 348 | ||
393 | msleep(100); | 349 | msleep(100); |
394 | ret = usb_reset_device(cardp->udev); | 350 | ret = usb_reset_device(cardp->udev); |
@@ -406,7 +362,7 @@ static int if_usb_reset_device(struct usb_card_rec *cardp) | |||
406 | * @param nb data length | 362 | * @param nb data length |
407 | * @return 0 or -1 | 363 | * @return 0 or -1 |
408 | */ | 364 | */ |
409 | static int usb_tx_block(struct usb_card_rec *cardp, u8 * payload, u16 nb) | 365 | static int usb_tx_block(struct if_usb_card *cardp, uint8_t *payload, uint16_t nb) |
410 | { | 366 | { |
411 | int ret = -1; | 367 | int ret = -1; |
412 | 368 | ||
@@ -418,17 +374,16 @@ static int usb_tx_block(struct usb_card_rec *cardp, u8 * payload, u16 nb) | |||
418 | 374 | ||
419 | usb_fill_bulk_urb(cardp->tx_urb, cardp->udev, | 375 | usb_fill_bulk_urb(cardp->tx_urb, cardp->udev, |
420 | usb_sndbulkpipe(cardp->udev, | 376 | usb_sndbulkpipe(cardp->udev, |
421 | cardp->bulk_out_endpointAddr), | 377 | cardp->ep_out), |
422 | payload, nb, if_usb_write_bulk_callback, cardp); | 378 | payload, nb, if_usb_write_bulk_callback, cardp); |
423 | 379 | ||
424 | cardp->tx_urb->transfer_flags |= URB_ZERO_PACKET; | 380 | cardp->tx_urb->transfer_flags |= URB_ZERO_PACKET; |
425 | 381 | ||
426 | if ((ret = usb_submit_urb(cardp->tx_urb, GFP_ATOMIC))) { | 382 | if ((ret = usb_submit_urb(cardp->tx_urb, GFP_ATOMIC))) { |
427 | /* transfer failed */ | ||
428 | lbs_deb_usbd(&cardp->udev->dev, "usb_submit_urb failed: %d\n", ret); | 383 | lbs_deb_usbd(&cardp->udev->dev, "usb_submit_urb failed: %d\n", ret); |
429 | ret = -1; | 384 | ret = -1; |
430 | } else { | 385 | } else { |
431 | /* lbs_deb_usbd(&cardp->udev->dev, "usb_submit_urb success\n"); */ | 386 | lbs_deb_usb2(&cardp->udev->dev, "usb_submit_urb success\n"); |
432 | ret = 0; | 387 | ret = 0; |
433 | } | 388 | } |
434 | 389 | ||
@@ -436,11 +391,10 @@ tx_ret: | |||
436 | return ret; | 391 | return ret; |
437 | } | 392 | } |
438 | 393 | ||
439 | static int __if_usb_submit_rx_urb(struct usb_card_rec *cardp, | 394 | static int __if_usb_submit_rx_urb(struct if_usb_card *cardp, |
440 | void (*callbackfn)(struct urb *urb)) | 395 | void (*callbackfn)(struct urb *urb)) |
441 | { | 396 | { |
442 | struct sk_buff *skb; | 397 | struct sk_buff *skb; |
443 | struct read_cb_info *rinfo = &cardp->rinfo; | ||
444 | int ret = -1; | 398 | int ret = -1; |
445 | 399 | ||
446 | if (!(skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE))) { | 400 | if (!(skb = dev_alloc_skb(MRVDRV_ETH_RX_PACKET_BUFFER_SIZE))) { |
@@ -448,27 +402,25 @@ static int __if_usb_submit_rx_urb(struct usb_card_rec *cardp, | |||
448 | goto rx_ret; | 402 | goto rx_ret; |
449 | } | 403 | } |
450 | 404 | ||
451 | rinfo->skb = skb; | 405 | cardp->rx_skb = skb; |
452 | 406 | ||
453 | /* Fill the receive configuration URB and initialise the Rx call back */ | 407 | /* Fill the receive configuration URB and initialise the Rx call back */ |
454 | usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, | 408 | usb_fill_bulk_urb(cardp->rx_urb, cardp->udev, |
455 | usb_rcvbulkpipe(cardp->udev, | 409 | usb_rcvbulkpipe(cardp->udev, cardp->ep_in), |
456 | cardp->bulk_in_endpointAddr), | ||
457 | (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET), | 410 | (void *) (skb->tail + (size_t) IPFIELD_ALIGN_OFFSET), |
458 | MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, | 411 | MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, |
459 | rinfo); | 412 | cardp); |
460 | 413 | ||
461 | cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET; | 414 | cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET; |
462 | 415 | ||
463 | /* lbs_deb_usbd(&cardp->udev->dev, "Pointer for rx_urb %p\n", cardp->rx_urb); */ | 416 | lbs_deb_usb2(&cardp->udev->dev, "Pointer for rx_urb %p\n", cardp->rx_urb); |
464 | if ((ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC))) { | 417 | if ((ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC))) { |
465 | /* handle failure conditions */ | ||
466 | lbs_deb_usbd(&cardp->udev->dev, "Submit Rx URB failed: %d\n", ret); | 418 | lbs_deb_usbd(&cardp->udev->dev, "Submit Rx URB failed: %d\n", ret); |
467 | kfree_skb(skb); | 419 | kfree_skb(skb); |
468 | rinfo->skb = NULL; | 420 | cardp->rx_skb = NULL; |
469 | ret = -1; | 421 | ret = -1; |
470 | } else { | 422 | } else { |
471 | /* lbs_deb_usbd(&cardp->udev->dev, "Submit Rx URB success\n"); */ | 423 | lbs_deb_usb2(&cardp->udev->dev, "Submit Rx URB success\n"); |
472 | ret = 0; | 424 | ret = 0; |
473 | } | 425 | } |
474 | 426 | ||
@@ -476,27 +428,26 @@ rx_ret: | |||
476 | return ret; | 428 | return ret; |
477 | } | 429 | } |
478 | 430 | ||
479 | static int if_usb_submit_rx_urb_fwload(struct usb_card_rec *cardp) | 431 | static int if_usb_submit_rx_urb_fwload(struct if_usb_card *cardp) |
480 | { | 432 | { |
481 | return __if_usb_submit_rx_urb(cardp, &if_usb_receive_fwload); | 433 | return __if_usb_submit_rx_urb(cardp, &if_usb_receive_fwload); |
482 | } | 434 | } |
483 | 435 | ||
484 | static int if_usb_submit_rx_urb(struct usb_card_rec *cardp) | 436 | static int if_usb_submit_rx_urb(struct if_usb_card *cardp) |
485 | { | 437 | { |
486 | return __if_usb_submit_rx_urb(cardp, &if_usb_receive); | 438 | return __if_usb_submit_rx_urb(cardp, &if_usb_receive); |
487 | } | 439 | } |
488 | 440 | ||
489 | static void if_usb_receive_fwload(struct urb *urb) | 441 | static void if_usb_receive_fwload(struct urb *urb) |
490 | { | 442 | { |
491 | struct read_cb_info *rinfo = (struct read_cb_info *)urb->context; | 443 | struct if_usb_card *cardp = urb->context; |
492 | struct sk_buff *skb = rinfo->skb; | 444 | struct sk_buff *skb = cardp->rx_skb; |
493 | struct usb_card_rec *cardp = (struct usb_card_rec *)rinfo->cardp; | ||
494 | struct fwsyncheader *syncfwheader; | 445 | struct fwsyncheader *syncfwheader; |
495 | struct bootcmdrespStr bootcmdresp; | 446 | struct bootcmdresp bootcmdresp; |
496 | 447 | ||
497 | if (urb->status) { | 448 | if (urb->status) { |
498 | lbs_deb_usbd(&cardp->udev->dev, | 449 | lbs_deb_usbd(&cardp->udev->dev, |
499 | "URB status is failed during fw load\n"); | 450 | "URB status is failed during fw load\n"); |
500 | kfree_skb(skb); | 451 | kfree_skb(skb); |
501 | return; | 452 | return; |
502 | } | 453 | } |
@@ -509,8 +460,8 @@ static void if_usb_receive_fwload(struct urb *urb) | |||
509 | lbs_pr_info("Firmware ready event received\n"); | 460 | lbs_pr_info("Firmware ready event received\n"); |
510 | wake_up(&cardp->fw_wq); | 461 | wake_up(&cardp->fw_wq); |
511 | } else { | 462 | } else { |
512 | lbs_deb_usb("Waiting for confirmation; got %x %x\n", le32_to_cpu(tmp[0]), | 463 | lbs_deb_usb("Waiting for confirmation; got %x %x\n", |
513 | le32_to_cpu(tmp[1])); | 464 | le32_to_cpu(tmp[0]), le32_to_cpu(tmp[1])); |
514 | if_usb_submit_rx_urb_fwload(cardp); | 465 | if_usb_submit_rx_urb_fwload(cardp); |
515 | } | 466 | } |
516 | kfree_skb(skb); | 467 | kfree_skb(skb); |
@@ -519,37 +470,36 @@ static void if_usb_receive_fwload(struct urb *urb) | |||
519 | if (cardp->bootcmdresp <= 0) { | 470 | if (cardp->bootcmdresp <= 0) { |
520 | memcpy (&bootcmdresp, skb->data + IPFIELD_ALIGN_OFFSET, | 471 | memcpy (&bootcmdresp, skb->data + IPFIELD_ALIGN_OFFSET, |
521 | sizeof(bootcmdresp)); | 472 | sizeof(bootcmdresp)); |
473 | |||
522 | if (le16_to_cpu(cardp->udev->descriptor.bcdDevice) < 0x3106) { | 474 | if (le16_to_cpu(cardp->udev->descriptor.bcdDevice) < 0x3106) { |
523 | kfree_skb(skb); | 475 | kfree_skb(skb); |
524 | if_usb_submit_rx_urb_fwload(cardp); | 476 | if_usb_submit_rx_urb_fwload(cardp); |
525 | cardp->bootcmdresp = 1; | 477 | cardp->bootcmdresp = 1; |
526 | lbs_deb_usbd(&cardp->udev->dev, | 478 | lbs_deb_usbd(&cardp->udev->dev, |
527 | "Received valid boot command response\n"); | 479 | "Received valid boot command response\n"); |
528 | return; | 480 | return; |
529 | } | 481 | } |
530 | if (bootcmdresp.u32magicnumber != cpu_to_le32(BOOT_CMD_MAGIC_NUMBER)) { | 482 | if (bootcmdresp.magic != cpu_to_le32(BOOT_CMD_MAGIC_NUMBER)) { |
531 | if (bootcmdresp.u32magicnumber == cpu_to_le32(CMD_TYPE_REQUEST) || | 483 | if (bootcmdresp.magic == cpu_to_le32(CMD_TYPE_REQUEST) || |
532 | bootcmdresp.u32magicnumber == cpu_to_le32(CMD_TYPE_DATA) || | 484 | bootcmdresp.magic == cpu_to_le32(CMD_TYPE_DATA) || |
533 | bootcmdresp.u32magicnumber == cpu_to_le32(CMD_TYPE_INDICATION)) { | 485 | bootcmdresp.magic == cpu_to_le32(CMD_TYPE_INDICATION)) { |
534 | if (!cardp->bootcmdresp) | 486 | if (!cardp->bootcmdresp) |
535 | lbs_pr_info("Firmware already seems alive; resetting\n"); | 487 | lbs_pr_info("Firmware already seems alive; resetting\n"); |
536 | cardp->bootcmdresp = -1; | 488 | cardp->bootcmdresp = -1; |
537 | } else { | 489 | } else { |
538 | lbs_pr_info("boot cmd response wrong magic number (0x%x)\n", | 490 | lbs_pr_info("boot cmd response wrong magic number (0x%x)\n", |
539 | le32_to_cpu(bootcmdresp.u32magicnumber)); | 491 | le32_to_cpu(bootcmdresp.magic)); |
540 | } | 492 | } |
541 | } else if (bootcmdresp.u8cmd_tag != BOOT_CMD_FW_BY_USB) { | 493 | } else if (bootcmdresp.cmd != BOOT_CMD_FW_BY_USB) { |
542 | lbs_pr_info( | 494 | lbs_pr_info("boot cmd response cmd_tag error (%d)\n", |
543 | "boot cmd response cmd_tag error (%d)\n", | 495 | bootcmdresp.cmd); |
544 | bootcmdresp.u8cmd_tag); | 496 | } else if (bootcmdresp.result != BOOT_CMD_RESP_OK) { |
545 | } else if (bootcmdresp.u8result != BOOT_CMD_RESP_OK) { | 497 | lbs_pr_info("boot cmd response result error (%d)\n", |
546 | lbs_pr_info( | 498 | bootcmdresp.result); |
547 | "boot cmd response result error (%d)\n", | ||
548 | bootcmdresp.u8result); | ||
549 | } else { | 499 | } else { |
550 | cardp->bootcmdresp = 1; | 500 | cardp->bootcmdresp = 1; |
551 | lbs_deb_usbd(&cardp->udev->dev, | 501 | lbs_deb_usbd(&cardp->udev->dev, |
552 | "Received valid boot command response\n"); | 502 | "Received valid boot command response\n"); |
553 | } | 503 | } |
554 | kfree_skb(skb); | 504 | kfree_skb(skb); |
555 | if_usb_submit_rx_urb_fwload(cardp); | 505 | if_usb_submit_rx_urb_fwload(cardp); |
@@ -564,20 +514,15 @@ static void if_usb_receive_fwload(struct urb *urb) | |||
564 | } | 514 | } |
565 | 515 | ||
566 | memcpy(syncfwheader, skb->data + IPFIELD_ALIGN_OFFSET, | 516 | memcpy(syncfwheader, skb->data + IPFIELD_ALIGN_OFFSET, |
567 | sizeof(struct fwsyncheader)); | 517 | sizeof(struct fwsyncheader)); |
568 | 518 | ||
569 | if (!syncfwheader->cmd) { | 519 | if (!syncfwheader->cmd) { |
570 | /* | 520 | lbs_deb_usb2(&cardp->udev->dev, "FW received Blk with correct CRC\n"); |
571 | lbs_deb_usbd(&cardp->udev->dev, | 521 | lbs_deb_usb2(&cardp->udev->dev, "FW received Blk seqnum = %d\n", |
572 | "FW received Blk with correct CRC\n"); | 522 | le32_to_cpu(syncfwheader->seqnum)); |
573 | lbs_deb_usbd(&cardp->udev->dev, | ||
574 | "FW received Blk seqnum = %d\n", | ||
575 | syncfwheader->seqnum); | ||
576 | */ | ||
577 | cardp->CRC_OK = 1; | 523 | cardp->CRC_OK = 1; |
578 | } else { | 524 | } else { |
579 | lbs_deb_usbd(&cardp->udev->dev, | 525 | lbs_deb_usbd(&cardp->udev->dev, "FW received Blk with CRC error\n"); |
580 | "FW received Blk with CRC error\n"); | ||
581 | cardp->CRC_OK = 0; | 526 | cardp->CRC_OK = 0; |
582 | } | 527 | } |
583 | 528 | ||
@@ -604,13 +549,12 @@ static void if_usb_receive_fwload(struct urb *urb) | |||
604 | #define MRVDRV_MIN_PKT_LEN 30 | 549 | #define MRVDRV_MIN_PKT_LEN 30 |
605 | 550 | ||
606 | static inline void process_cmdtypedata(int recvlength, struct sk_buff *skb, | 551 | static inline void process_cmdtypedata(int recvlength, struct sk_buff *skb, |
607 | struct usb_card_rec *cardp, | 552 | struct if_usb_card *cardp, |
608 | struct lbs_private *priv) | 553 | struct lbs_private *priv) |
609 | { | 554 | { |
610 | if (recvlength > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE + | 555 | if (recvlength > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE + MESSAGE_HEADER_LEN |
611 | MESSAGE_HEADER_LEN || recvlength < MRVDRV_MIN_PKT_LEN) { | 556 | || recvlength < MRVDRV_MIN_PKT_LEN) { |
612 | lbs_deb_usbd(&cardp->udev->dev, | 557 | lbs_deb_usbd(&cardp->udev->dev, "Packet length is Invalid\n"); |
613 | "Packet length is Invalid\n"); | ||
614 | kfree_skb(skb); | 558 | kfree_skb(skb); |
615 | return; | 559 | return; |
616 | } | 560 | } |
@@ -618,19 +562,21 @@ static inline void process_cmdtypedata(int recvlength, struct sk_buff *skb, | |||
618 | skb_reserve(skb, IPFIELD_ALIGN_OFFSET); | 562 | skb_reserve(skb, IPFIELD_ALIGN_OFFSET); |
619 | skb_put(skb, recvlength); | 563 | skb_put(skb, recvlength); |
620 | skb_pull(skb, MESSAGE_HEADER_LEN); | 564 | skb_pull(skb, MESSAGE_HEADER_LEN); |
565 | |||
621 | lbs_process_rxed_packet(priv, skb); | 566 | lbs_process_rxed_packet(priv, skb); |
622 | priv->upld_len = (recvlength - MESSAGE_HEADER_LEN); | 567 | priv->upld_len = (recvlength - MESSAGE_HEADER_LEN); |
623 | } | 568 | } |
624 | 569 | ||
625 | static inline void process_cmdrequest(int recvlength, u8 *recvbuff, | 570 | static inline void process_cmdrequest(int recvlength, uint8_t *recvbuff, |
626 | struct sk_buff *skb, | 571 | struct sk_buff *skb, |
627 | struct usb_card_rec *cardp, | 572 | struct if_usb_card *cardp, |
628 | struct lbs_private *priv) | 573 | struct lbs_private *priv) |
629 | { | 574 | { |
630 | u8 *cmdbuf; | 575 | uint8_t *cmdbuf; |
576 | |||
631 | if (recvlength > LBS_CMD_BUFFER_SIZE) { | 577 | if (recvlength > LBS_CMD_BUFFER_SIZE) { |
632 | lbs_deb_usbd(&cardp->udev->dev, | 578 | lbs_deb_usbd(&cardp->udev->dev, |
633 | "The receive buffer is too large\n"); | 579 | "The receive buffer is too large\n"); |
634 | kfree_skb(skb); | 580 | kfree_skb(skb); |
635 | return; | 581 | return; |
636 | } | 582 | } |
@@ -642,16 +588,16 @@ static inline void process_cmdrequest(int recvlength, u8 *recvbuff, | |||
642 | /* take care of cur_cmd = NULL case by reading the | 588 | /* take care of cur_cmd = NULL case by reading the |
643 | * data to clear the interrupt */ | 589 | * data to clear the interrupt */ |
644 | if (!priv->cur_cmd) { | 590 | if (!priv->cur_cmd) { |
645 | lbs_deb_hex(LBS_DEB_HOST, "Unsolicited CMD_RESP", (void *) recvbuff + MESSAGE_HEADER_LEN, priv->upld_len); | 591 | lbs_deb_hex(LBS_DEB_HOST, "Unsolicited CMD_RESP", |
592 | (void *) recvbuff + MESSAGE_HEADER_LEN, priv->upld_len); | ||
646 | cmdbuf = priv->upld_buf; | 593 | cmdbuf = priv->upld_buf; |
647 | priv->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY; | 594 | priv->hisregcpy &= ~MRVDRV_CMD_UPLD_RDY; |
648 | } else | 595 | } else |
649 | cmdbuf = (u8 *) priv->cur_cmd->cmdbuf; | 596 | cmdbuf = (uint8_t *) priv->cur_cmd->cmdbuf; |
650 | 597 | ||
651 | cardp->usb_int_cause |= MRVDRV_CMD_UPLD_RDY; | 598 | cardp->usb_int_cause |= MRVDRV_CMD_UPLD_RDY; |
652 | priv->upld_len = (recvlength - MESSAGE_HEADER_LEN); | 599 | priv->upld_len = (recvlength - MESSAGE_HEADER_LEN); |
653 | memcpy(cmdbuf, recvbuff + MESSAGE_HEADER_LEN, | 600 | memcpy(cmdbuf, recvbuff + MESSAGE_HEADER_LEN, priv->upld_len); |
654 | priv->upld_len); | ||
655 | 601 | ||
656 | kfree_skb(skb); | 602 | kfree_skb(skb); |
657 | lbs_interrupt(priv); | 603 | lbs_interrupt(priv); |
@@ -659,8 +605,6 @@ static inline void process_cmdrequest(int recvlength, u8 *recvbuff, | |||
659 | 605 | ||
660 | lbs_deb_usbd(&cardp->udev->dev, | 606 | lbs_deb_usbd(&cardp->udev->dev, |
661 | "Wake up main thread to handle cmd response\n"); | 607 | "Wake up main thread to handle cmd response\n"); |
662 | |||
663 | return; | ||
664 | } | 608 | } |
665 | 609 | ||
666 | /** | 610 | /** |
@@ -672,30 +616,26 @@ static inline void process_cmdrequest(int recvlength, u8 *recvbuff, | |||
672 | */ | 616 | */ |
673 | static void if_usb_receive(struct urb *urb) | 617 | static void if_usb_receive(struct urb *urb) |
674 | { | 618 | { |
675 | struct read_cb_info *rinfo = (struct read_cb_info *)urb->context; | 619 | struct if_usb_card *cardp = urb->context; |
676 | struct sk_buff *skb = rinfo->skb; | 620 | struct sk_buff *skb = cardp->rx_skb; |
677 | struct usb_card_rec *cardp = (struct usb_card_rec *) rinfo->cardp; | ||
678 | struct lbs_private *priv = cardp->priv; | 621 | struct lbs_private *priv = cardp->priv; |
679 | |||
680 | int recvlength = urb->actual_length; | 622 | int recvlength = urb->actual_length; |
681 | u8 *recvbuff = NULL; | 623 | uint8_t *recvbuff = NULL; |
682 | u32 recvtype = 0; | 624 | uint32_t recvtype = 0; |
625 | __le32 *pkt = (__le32 *)(skb->data + IPFIELD_ALIGN_OFFSET); | ||
683 | 626 | ||
684 | lbs_deb_enter(LBS_DEB_USB); | 627 | lbs_deb_enter(LBS_DEB_USB); |
685 | 628 | ||
686 | if (recvlength) { | 629 | if (recvlength) { |
687 | __le32 tmp; | ||
688 | |||
689 | if (urb->status) { | 630 | if (urb->status) { |
690 | lbs_deb_usbd(&cardp->udev->dev, | 631 | lbs_deb_usbd(&cardp->udev->dev, "RX URB failed: %d\n", |
691 | "URB status is failed\n"); | 632 | urb->status); |
692 | kfree_skb(skb); | 633 | kfree_skb(skb); |
693 | goto setup_for_next; | 634 | goto setup_for_next; |
694 | } | 635 | } |
695 | 636 | ||
696 | recvbuff = skb->data + IPFIELD_ALIGN_OFFSET; | 637 | recvbuff = skb->data + IPFIELD_ALIGN_OFFSET; |
697 | memcpy(&tmp, recvbuff, sizeof(u32)); | 638 | recvtype = le32_to_cpu(pkt[0]); |
698 | recvtype = le32_to_cpu(tmp); | ||
699 | lbs_deb_usbd(&cardp->udev->dev, | 639 | lbs_deb_usbd(&cardp->udev->dev, |
700 | "Recv length = 0x%x, Recv type = 0x%X\n", | 640 | "Recv length = 0x%x, Recv type = 0x%X\n", |
701 | recvlength, recvtype); | 641 | recvlength, recvtype); |
@@ -716,9 +656,13 @@ static void if_usb_receive(struct urb *urb) | |||
716 | case CMD_TYPE_INDICATION: | 656 | case CMD_TYPE_INDICATION: |
717 | /* Event cause handling */ | 657 | /* Event cause handling */ |
718 | spin_lock(&priv->driver_lock); | 658 | spin_lock(&priv->driver_lock); |
719 | cardp->usb_event_cause = le32_to_cpu(*(__le32 *) (recvbuff + MESSAGE_HEADER_LEN)); | 659 | |
660 | cardp->usb_event_cause = le32_to_cpu(pkt[1]); | ||
661 | |||
720 | lbs_deb_usbd(&cardp->udev->dev,"**EVENT** 0x%X\n", | 662 | lbs_deb_usbd(&cardp->udev->dev,"**EVENT** 0x%X\n", |
721 | cardp->usb_event_cause); | 663 | cardp->usb_event_cause); |
664 | |||
665 | /* Icky undocumented magic special case */ | ||
722 | if (cardp->usb_event_cause & 0xffff0000) { | 666 | if (cardp->usb_event_cause & 0xffff0000) { |
723 | lbs_send_tx_feedback(priv); | 667 | lbs_send_tx_feedback(priv); |
724 | spin_unlock(&priv->driver_lock); | 668 | spin_unlock(&priv->driver_lock); |
@@ -732,7 +676,7 @@ static void if_usb_receive(struct urb *urb) | |||
732 | goto rx_exit; | 676 | goto rx_exit; |
733 | default: | 677 | default: |
734 | lbs_deb_usbd(&cardp->udev->dev, "Unknown command type 0x%X\n", | 678 | lbs_deb_usbd(&cardp->udev->dev, "Unknown command type 0x%X\n", |
735 | recvtype); | 679 | recvtype); |
736 | kfree_skb(skb); | 680 | kfree_skb(skb); |
737 | break; | 681 | break; |
738 | } | 682 | } |
@@ -751,55 +695,48 @@ rx_exit: | |||
751 | * @param len number of bytes | 695 | * @param len number of bytes |
752 | * @return 0 or -1 | 696 | * @return 0 or -1 |
753 | */ | 697 | */ |
754 | static int if_usb_host_to_card(struct lbs_private *priv, | 698 | static int if_usb_host_to_card(struct lbs_private *priv, uint8_t type, |
755 | u8 type, | 699 | uint8_t *payload, uint16_t nb) |
756 | u8 *payload, | ||
757 | u16 nb) | ||
758 | { | 700 | { |
759 | struct usb_card_rec *cardp = (struct usb_card_rec *)priv->card; | 701 | struct if_usb_card *cardp = priv->card; |
760 | 702 | ||
761 | lbs_deb_usbd(&cardp->udev->dev,"*** type = %u\n", type); | 703 | lbs_deb_usbd(&cardp->udev->dev,"*** type = %u\n", type); |
762 | lbs_deb_usbd(&cardp->udev->dev,"size after = %d\n", nb); | 704 | lbs_deb_usbd(&cardp->udev->dev,"size after = %d\n", nb); |
763 | 705 | ||
764 | if (type == MVMS_CMD) { | 706 | if (type == MVMS_CMD) { |
765 | __le32 tmp = cpu_to_le32(CMD_TYPE_REQUEST); | 707 | *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_REQUEST); |
766 | priv->dnld_sent = DNLD_CMD_SENT; | 708 | priv->dnld_sent = DNLD_CMD_SENT; |
767 | memcpy(cardp->bulk_out_buffer, (u8 *) & tmp, | ||
768 | MESSAGE_HEADER_LEN); | ||
769 | |||
770 | } else { | 709 | } else { |
771 | __le32 tmp = cpu_to_le32(CMD_TYPE_DATA); | 710 | *(__le32 *)cardp->ep_out_buf = cpu_to_le32(CMD_TYPE_DATA); |
772 | priv->dnld_sent = DNLD_DATA_SENT; | 711 | priv->dnld_sent = DNLD_DATA_SENT; |
773 | memcpy(cardp->bulk_out_buffer, (u8 *) & tmp, | ||
774 | MESSAGE_HEADER_LEN); | ||
775 | } | 712 | } |
776 | 713 | ||
777 | memcpy((cardp->bulk_out_buffer + MESSAGE_HEADER_LEN), payload, nb); | 714 | memcpy((cardp->ep_out_buf + MESSAGE_HEADER_LEN), payload, nb); |
778 | 715 | ||
779 | return usb_tx_block(cardp, cardp->bulk_out_buffer, | 716 | return usb_tx_block(cardp, cardp->ep_out_buf, nb + MESSAGE_HEADER_LEN); |
780 | nb + MESSAGE_HEADER_LEN); | ||
781 | } | 717 | } |
782 | 718 | ||
783 | /* called with priv->driver_lock held */ | 719 | /* called with priv->driver_lock held */ |
784 | static int if_usb_get_int_status(struct lbs_private *priv, u8 *ireg) | 720 | static int if_usb_get_int_status(struct lbs_private *priv, uint8_t *ireg) |
785 | { | 721 | { |
786 | struct usb_card_rec *cardp = priv->card; | 722 | struct if_usb_card *cardp = priv->card; |
787 | 723 | ||
788 | *ireg = cardp->usb_int_cause; | 724 | *ireg = cardp->usb_int_cause; |
789 | cardp->usb_int_cause = 0; | 725 | cardp->usb_int_cause = 0; |
790 | 726 | ||
791 | lbs_deb_usbd(&cardp->udev->dev,"Int cause is 0x%X\n", *ireg); | 727 | lbs_deb_usbd(&cardp->udev->dev, "Int cause is 0x%X\n", *ireg); |
792 | 728 | ||
793 | return 0; | 729 | return 0; |
794 | } | 730 | } |
795 | 731 | ||
796 | static int if_usb_read_event_cause(struct lbs_private *priv) | 732 | static int if_usb_read_event_cause(struct lbs_private *priv) |
797 | { | 733 | { |
798 | struct usb_card_rec *cardp = priv->card; | 734 | struct if_usb_card *cardp = priv->card; |
799 | 735 | ||
800 | priv->eventcause = cardp->usb_event_cause; | 736 | priv->eventcause = cardp->usb_event_cause; |
801 | /* Re-submit rx urb here to avoid event lost issue */ | 737 | /* Re-submit rx urb here to avoid event lost issue */ |
802 | if_usb_submit_rx_urb(cardp); | 738 | if_usb_submit_rx_urb(cardp); |
739 | |||
803 | return 0; | 740 | return 0; |
804 | } | 741 | } |
805 | 742 | ||
@@ -809,20 +746,17 @@ static int if_usb_read_event_cause(struct lbs_private *priv) | |||
809 | * 2:Boot from FW in EEPROM | 746 | * 2:Boot from FW in EEPROM |
810 | * @return 0 | 747 | * @return 0 |
811 | */ | 748 | */ |
812 | static int if_usb_issue_boot_command(struct usb_card_rec *cardp, int ivalue) | 749 | static int if_usb_issue_boot_command(struct if_usb_card *cardp, int ivalue) |
813 | { | 750 | { |
814 | struct bootcmdstr sbootcmd; | 751 | struct bootcmd *bootcmd = cardp->ep_out_buf; |
815 | int i; | ||
816 | 752 | ||
817 | /* Prepare command */ | 753 | /* Prepare command */ |
818 | sbootcmd.u32magicnumber = cpu_to_le32(BOOT_CMD_MAGIC_NUMBER); | 754 | bootcmd->magic = cpu_to_le32(BOOT_CMD_MAGIC_NUMBER); |
819 | sbootcmd.u8cmd_tag = ivalue; | 755 | bootcmd->cmd = ivalue; |
820 | for (i=0; i<11; i++) | 756 | memset(bootcmd->pad, 0, sizeof(bootcmd->pad)); |
821 | sbootcmd.au8dumy[i]=0x00; | ||
822 | memcpy(cardp->bulk_out_buffer, &sbootcmd, sizeof(struct bootcmdstr)); | ||
823 | 757 | ||
824 | /* Issue command */ | 758 | /* Issue command */ |
825 | usb_tx_block(cardp, cardp->bulk_out_buffer, sizeof(struct bootcmdstr)); | 759 | usb_tx_block(cardp, cardp->ep_out_buf, sizeof(*bootcmd)); |
826 | 760 | ||
827 | return 0; | 761 | return 0; |
828 | } | 762 | } |
@@ -835,10 +769,10 @@ static int if_usb_issue_boot_command(struct usb_card_rec *cardp, int ivalue) | |||
835 | * len image length | 769 | * len image length |
836 | * @return 0 or -1 | 770 | * @return 0 or -1 |
837 | */ | 771 | */ |
838 | static int check_fwfile_format(u8 *data, u32 totlen) | 772 | static int check_fwfile_format(uint8_t *data, uint32_t totlen) |
839 | { | 773 | { |
840 | u32 bincmd, exit; | 774 | uint32_t bincmd, exit; |
841 | u32 blksize, offset, len; | 775 | uint32_t blksize, offset, len; |
842 | int ret; | 776 | int ret; |
843 | 777 | ||
844 | ret = 1; | 778 | ret = 1; |
@@ -876,7 +810,7 @@ static int check_fwfile_format(u8 *data, u32 totlen) | |||
876 | } | 810 | } |
877 | 811 | ||
878 | 812 | ||
879 | static int if_usb_prog_firmware(struct usb_card_rec *cardp) | 813 | static int if_usb_prog_firmware(struct if_usb_card *cardp) |
880 | { | 814 | { |
881 | int i = 0; | 815 | int i = 0; |
882 | static int reset_count = 10; | 816 | static int reset_count = 10; |
@@ -953,11 +887,11 @@ restart: | |||
953 | goto release_fw; | 887 | goto release_fw; |
954 | } | 888 | } |
955 | 889 | ||
956 | release_fw: | 890 | release_fw: |
957 | release_firmware(cardp->fw); | 891 | release_firmware(cardp->fw); |
958 | cardp->fw = NULL; | 892 | cardp->fw = NULL; |
959 | 893 | ||
960 | done: | 894 | done: |
961 | lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); | 895 | lbs_deb_leave_args(LBS_DEB_USB, "ret %d", ret); |
962 | return ret; | 896 | return ret; |
963 | } | 897 | } |
@@ -966,7 +900,7 @@ done: | |||
966 | #ifdef CONFIG_PM | 900 | #ifdef CONFIG_PM |
967 | static int if_usb_suspend(struct usb_interface *intf, pm_message_t message) | 901 | static int if_usb_suspend(struct usb_interface *intf, pm_message_t message) |
968 | { | 902 | { |
969 | struct usb_card_rec *cardp = usb_get_intfdata(intf); | 903 | struct if_usb_card *cardp = usb_get_intfdata(intf); |
970 | struct lbs_private *priv = cardp->priv; | 904 | struct lbs_private *priv = cardp->priv; |
971 | int ret; | 905 | int ret; |
972 | 906 | ||
@@ -990,7 +924,7 @@ static int if_usb_suspend(struct usb_interface *intf, pm_message_t message) | |||
990 | 924 | ||
991 | static int if_usb_resume(struct usb_interface *intf) | 925 | static int if_usb_resume(struct usb_interface *intf) |
992 | { | 926 | { |
993 | struct usb_card_rec *cardp = usb_get_intfdata(intf); | 927 | struct if_usb_card *cardp = usb_get_intfdata(intf); |
994 | struct lbs_private *priv = cardp->priv; | 928 | struct lbs_private *priv = cardp->priv; |
995 | 929 | ||
996 | lbs_deb_enter(LBS_DEB_USB); | 930 | lbs_deb_enter(LBS_DEB_USB); |
@@ -1041,5 +975,5 @@ module_init(if_usb_init_module); | |||
1041 | module_exit(if_usb_exit_module); | 975 | module_exit(if_usb_exit_module); |
1042 | 976 | ||
1043 | MODULE_DESCRIPTION("8388 USB WLAN Driver"); | 977 | MODULE_DESCRIPTION("8388 USB WLAN Driver"); |
1044 | MODULE_AUTHOR("Marvell International Ltd."); | 978 | MODULE_AUTHOR("Marvell International Ltd. and Red Hat, Inc."); |
1045 | MODULE_LICENSE("GPL"); | 979 | MODULE_LICENSE("GPL"); |