aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/zd1211rw
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/zd1211rw')
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.c268
-rw-r--r--drivers/net/wireless/zd1211rw/zd_mac.h16
-rw-r--r--drivers/net/wireless/zd1211rw/zd_usb.c29
3 files changed, 134 insertions, 179 deletions
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c
index 694e95d35fd4..feaf43d17249 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.c
+++ b/drivers/net/wireless/zd1211rw/zd_mac.c
@@ -224,36 +224,6 @@ out:
224 return r; 224 return r;
225} 225}
226 226
227/**
228 * clear_tx_skb_control_block - clears the control block of tx skbuffs
229 * @skb: a &struct sk_buff pointer
230 *
231 * This clears the control block of skbuff buffers, which were transmitted to
232 * the device. Notify that the function is not thread-safe, so prevent
233 * multiple calls.
234 */
235static void clear_tx_skb_control_block(struct sk_buff *skb)
236{
237 struct zd_tx_skb_control_block *cb =
238 (struct zd_tx_skb_control_block *)skb->cb;
239
240 kfree(cb->control);
241 cb->control = NULL;
242}
243
244/**
245 * kfree_tx_skb - frees a tx skbuff
246 * @skb: a &struct sk_buff pointer
247 *
248 * Frees the tx skbuff. Frees also the allocated control structure in the
249 * control block if necessary.
250 */
251static void kfree_tx_skb(struct sk_buff *skb)
252{
253 clear_tx_skb_control_block(skb);
254 dev_kfree_skb_any(skb);
255}
256
257static void zd_op_stop(struct ieee80211_hw *hw) 227static void zd_op_stop(struct ieee80211_hw *hw)
258{ 228{
259 struct zd_mac *mac = zd_hw_mac(hw); 229 struct zd_mac *mac = zd_hw_mac(hw);
@@ -276,40 +246,15 @@ static void zd_op_stop(struct ieee80211_hw *hw)
276 246
277 247
278 while ((skb = skb_dequeue(ack_wait_queue))) 248 while ((skb = skb_dequeue(ack_wait_queue)))
279 kfree_tx_skb(skb); 249 dev_kfree_skb_any(skb);
280}
281
282/**
283 * init_tx_skb_control_block - initializes skb control block
284 * @skb: a &sk_buff pointer
285 * @dev: pointer to the mac80221 device
286 * @control: mac80211 tx control applying for the frame in @skb
287 *
288 * Initializes the control block of the skbuff to be transmitted.
289 */
290static int init_tx_skb_control_block(struct sk_buff *skb,
291 struct ieee80211_hw *hw,
292 struct ieee80211_tx_control *control)
293{
294 struct zd_tx_skb_control_block *cb =
295 (struct zd_tx_skb_control_block *)skb->cb;
296
297 ZD_ASSERT(sizeof(*cb) <= sizeof(skb->cb));
298 memset(cb, 0, sizeof(*cb));
299 cb->hw= hw;
300 cb->control = kmalloc(sizeof(*control), GFP_ATOMIC);
301 if (cb->control == NULL)
302 return -ENOMEM;
303 memcpy(cb->control, control, sizeof(*control));
304
305 return 0;
306} 250}
307 251
308/** 252/**
309 * tx_status - reports tx status of a packet if required 253 * tx_status - reports tx status of a packet if required
310 * @hw - a &struct ieee80211_hw pointer 254 * @hw - a &struct ieee80211_hw pointer
311 * @skb - a sk-buffer 255 * @skb - a sk-buffer
312 * @status - the tx status of the packet without control information 256 * @flags: extra flags to set in the TX status info
257 * @ackssi: ACK signal strength
313 * @success - True for successfull transmission of the frame 258 * @success - True for successfull transmission of the frame
314 * 259 *
315 * This information calls ieee80211_tx_status_irqsafe() if required by the 260 * This information calls ieee80211_tx_status_irqsafe() if required by the
@@ -319,18 +264,17 @@ static int init_tx_skb_control_block(struct sk_buff *skb,
319 * If no status information has been requested, the skb is freed. 264 * If no status information has been requested, the skb is freed.
320 */ 265 */
321static void tx_status(struct ieee80211_hw *hw, struct sk_buff *skb, 266static void tx_status(struct ieee80211_hw *hw, struct sk_buff *skb,
322 struct ieee80211_tx_status *status, 267 u32 flags, int ackssi, bool success)
323 bool success)
324{ 268{
325 struct zd_tx_skb_control_block *cb = (struct zd_tx_skb_control_block *) 269 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
326 skb->cb; 270
271 memset(&info->status, 0, sizeof(info->status));
327 272
328 ZD_ASSERT(cb->control != NULL);
329 memcpy(&status->control, cb->control, sizeof(status->control));
330 if (!success) 273 if (!success)
331 status->excessive_retries = 1; 274 info->status.excessive_retries = 1;
332 clear_tx_skb_control_block(skb); 275 info->flags |= flags;
333 ieee80211_tx_status_irqsafe(hw, skb, status); 276 info->status.ack_signal = ackssi;
277 ieee80211_tx_status_irqsafe(hw, skb);
334} 278}
335 279
336/** 280/**
@@ -345,15 +289,12 @@ void zd_mac_tx_failed(struct ieee80211_hw *hw)
345{ 289{
346 struct sk_buff_head *q = &zd_hw_mac(hw)->ack_wait_queue; 290 struct sk_buff_head *q = &zd_hw_mac(hw)->ack_wait_queue;
347 struct sk_buff *skb; 291 struct sk_buff *skb;
348 struct ieee80211_tx_status status;
349 292
350 skb = skb_dequeue(q); 293 skb = skb_dequeue(q);
351 if (skb == NULL) 294 if (skb == NULL)
352 return; 295 return;
353 296
354 memset(&status, 0, sizeof(status)); 297 tx_status(hw, skb, 0, 0, 0);
355
356 tx_status(hw, skb, &status, 0);
357} 298}
358 299
359/** 300/**
@@ -368,28 +309,20 @@ void zd_mac_tx_failed(struct ieee80211_hw *hw)
368 */ 309 */
369void zd_mac_tx_to_dev(struct sk_buff *skb, int error) 310void zd_mac_tx_to_dev(struct sk_buff *skb, int error)
370{ 311{
371 struct zd_tx_skb_control_block *cb = 312 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
372 (struct zd_tx_skb_control_block *)skb->cb; 313 struct ieee80211_hw *hw = info->driver_data[0];
373 struct ieee80211_hw *hw = cb->hw;
374
375 if (likely(cb->control)) {
376 skb_pull(skb, sizeof(struct zd_ctrlset));
377 if (unlikely(error ||
378 (cb->control->flags & IEEE80211_TXCTL_NO_ACK)))
379 {
380 struct ieee80211_tx_status status;
381 memset(&status, 0, sizeof(status));
382 tx_status(hw, skb, &status, !error);
383 } else {
384 struct sk_buff_head *q =
385 &zd_hw_mac(hw)->ack_wait_queue;
386 314
387 skb_queue_tail(q, skb); 315 skb_pull(skb, sizeof(struct zd_ctrlset));
388 while (skb_queue_len(q) > ZD_MAC_MAX_ACK_WAITERS) 316 if (unlikely(error ||
389 zd_mac_tx_failed(hw); 317 (info->flags & IEEE80211_TX_CTL_NO_ACK))) {
390 } 318 tx_status(hw, skb, 0, 0, !error);
391 } else { 319 } else {
392 kfree_tx_skb(skb); 320 struct sk_buff_head *q =
321 &zd_hw_mac(hw)->ack_wait_queue;
322
323 skb_queue_tail(q, skb);
324 while (skb_queue_len(q) > ZD_MAC_MAX_ACK_WAITERS)
325 zd_mac_tx_failed(hw);
393 } 326 }
394} 327}
395 328
@@ -443,8 +376,6 @@ static int zd_calc_tx_length_us(u8 *service, u8 zd_rate, u16 tx_length)
443static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs, 376static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
444 struct ieee80211_hdr *header, u32 flags) 377 struct ieee80211_hdr *header, u32 flags)
445{ 378{
446 u16 fctl = le16_to_cpu(header->frame_control);
447
448 /* 379 /*
449 * CONTROL TODO: 380 * CONTROL TODO:
450 * - if backoff needed, enable bit 0 381 * - if backoff needed, enable bit 0
@@ -454,7 +385,7 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
454 cs->control = 0; 385 cs->control = 0;
455 386
456 /* First fragment */ 387 /* First fragment */
457 if (flags & IEEE80211_TXCTL_FIRST_FRAGMENT) 388 if (flags & IEEE80211_TX_CTL_FIRST_FRAGMENT)
458 cs->control |= ZD_CS_NEED_RANDOM_BACKOFF; 389 cs->control |= ZD_CS_NEED_RANDOM_BACKOFF;
459 390
460 /* Multicast */ 391 /* Multicast */
@@ -462,79 +393,104 @@ static void cs_set_control(struct zd_mac *mac, struct zd_ctrlset *cs,
462 cs->control |= ZD_CS_MULTICAST; 393 cs->control |= ZD_CS_MULTICAST;
463 394
464 /* PS-POLL */ 395 /* PS-POLL */
465 if ((fctl & (IEEE80211_FCTL_FTYPE|IEEE80211_FCTL_STYPE)) == 396 if (ieee80211_is_pspoll(header->frame_control))
466 (IEEE80211_FTYPE_CTL|IEEE80211_STYPE_PSPOLL))
467 cs->control |= ZD_CS_PS_POLL_FRAME; 397 cs->control |= ZD_CS_PS_POLL_FRAME;
468 398
469 if (flags & IEEE80211_TXCTL_USE_RTS_CTS) 399 if (flags & IEEE80211_TX_CTL_USE_RTS_CTS)
470 cs->control |= ZD_CS_RTS; 400 cs->control |= ZD_CS_RTS;
471 401
472 if (flags & IEEE80211_TXCTL_USE_CTS_PROTECT) 402 if (flags & IEEE80211_TX_CTL_USE_CTS_PROTECT)
473 cs->control |= ZD_CS_SELF_CTS; 403 cs->control |= ZD_CS_SELF_CTS;
474 404
475 /* FIXME: Management frame? */ 405 /* FIXME: Management frame? */
476} 406}
477 407
478void zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon) 408static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon)
479{ 409{
480 struct zd_mac *mac = zd_hw_mac(hw); 410 struct zd_mac *mac = zd_hw_mac(hw);
411 int r;
481 u32 tmp, j = 0; 412 u32 tmp, j = 0;
482 /* 4 more bytes for tail CRC */ 413 /* 4 more bytes for tail CRC */
483 u32 full_len = beacon->len + 4; 414 u32 full_len = beacon->len + 4;
484 zd_iowrite32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, 0); 415
485 zd_ioread32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, &tmp); 416 r = zd_iowrite32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, 0);
417 if (r < 0)
418 return r;
419 r = zd_ioread32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, &tmp);
420 if (r < 0)
421 return r;
422
486 while (tmp & 0x2) { 423 while (tmp & 0x2) {
487 zd_ioread32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, &tmp); 424 r = zd_ioread32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, &tmp);
425 if (r < 0)
426 return r;
488 if ((++j % 100) == 0) { 427 if ((++j % 100) == 0) {
489 printk(KERN_ERR "CR_BCN_FIFO_SEMAPHORE not ready\n"); 428 printk(KERN_ERR "CR_BCN_FIFO_SEMAPHORE not ready\n");
490 if (j >= 500) { 429 if (j >= 500) {
491 printk(KERN_ERR "Giving up beacon config.\n"); 430 printk(KERN_ERR "Giving up beacon config.\n");
492 return; 431 return -ETIMEDOUT;
493 } 432 }
494 } 433 }
495 msleep(1); 434 msleep(1);
496 } 435 }
497 436
498 zd_iowrite32(&mac->chip, CR_BCN_FIFO, full_len - 1); 437 r = zd_iowrite32(&mac->chip, CR_BCN_FIFO, full_len - 1);
499 if (zd_chip_is_zd1211b(&mac->chip)) 438 if (r < 0)
500 zd_iowrite32(&mac->chip, CR_BCN_LENGTH, full_len - 1); 439 return r;
440 if (zd_chip_is_zd1211b(&mac->chip)) {
441 r = zd_iowrite32(&mac->chip, CR_BCN_LENGTH, full_len - 1);
442 if (r < 0)
443 return r;
444 }
501 445
502 for (j = 0 ; j < beacon->len; j++) 446 for (j = 0 ; j < beacon->len; j++) {
503 zd_iowrite32(&mac->chip, CR_BCN_FIFO, 447 r = zd_iowrite32(&mac->chip, CR_BCN_FIFO,
504 *((u8 *)(beacon->data + j))); 448 *((u8 *)(beacon->data + j)));
449 if (r < 0)
450 return r;
451 }
452
453 for (j = 0; j < 4; j++) {
454 r = zd_iowrite32(&mac->chip, CR_BCN_FIFO, 0x0);
455 if (r < 0)
456 return r;
457 }
505 458
506 for (j = 0; j < 4; j++) 459 r = zd_iowrite32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, 1);
507 zd_iowrite32(&mac->chip, CR_BCN_FIFO, 0x0); 460 if (r < 0)
461 return r;
508 462
509 zd_iowrite32(&mac->chip, CR_BCN_FIFO_SEMAPHORE, 1);
510 /* 802.11b/g 2.4G CCK 1Mb 463 /* 802.11b/g 2.4G CCK 1Mb
511 * 802.11a, not yet implemented, uses different values (see GPL vendor 464 * 802.11a, not yet implemented, uses different values (see GPL vendor
512 * driver) 465 * driver)
513 */ 466 */
514 zd_iowrite32(&mac->chip, CR_BCN_PLCP_CFG, 0x00000400 | 467 return zd_iowrite32(&mac->chip, CR_BCN_PLCP_CFG, 0x00000400 |
515 (full_len << 19)); 468 (full_len << 19));
516} 469}
517 470
518static int fill_ctrlset(struct zd_mac *mac, 471static int fill_ctrlset(struct zd_mac *mac,
519 struct sk_buff *skb, 472 struct sk_buff *skb)
520 struct ieee80211_tx_control *control)
521{ 473{
522 int r; 474 int r;
523 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 475 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
524 unsigned int frag_len = skb->len + FCS_LEN; 476 unsigned int frag_len = skb->len + FCS_LEN;
525 unsigned int packet_length; 477 unsigned int packet_length;
478 struct ieee80211_rate *txrate;
526 struct zd_ctrlset *cs = (struct zd_ctrlset *) 479 struct zd_ctrlset *cs = (struct zd_ctrlset *)
527 skb_push(skb, sizeof(struct zd_ctrlset)); 480 skb_push(skb, sizeof(struct zd_ctrlset));
481 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
528 482
529 ZD_ASSERT(frag_len <= 0xffff); 483 ZD_ASSERT(frag_len <= 0xffff);
530 484
531 cs->modulation = control->tx_rate->hw_value; 485 txrate = ieee80211_get_tx_rate(mac->hw, info);
532 if (control->flags & IEEE80211_TXCTL_SHORT_PREAMBLE) 486
533 cs->modulation = control->tx_rate->hw_value_short; 487 cs->modulation = txrate->hw_value;
488 if (info->flags & IEEE80211_TX_CTL_SHORT_PREAMBLE)
489 cs->modulation = txrate->hw_value_short;
534 490
535 cs->tx_length = cpu_to_le16(frag_len); 491 cs->tx_length = cpu_to_le16(frag_len);
536 492
537 cs_set_control(mac, cs, hdr, control->flags); 493 cs_set_control(mac, cs, hdr, info->flags);
538 494
539 packet_length = frag_len + sizeof(struct zd_ctrlset) + 10; 495 packet_length = frag_len + sizeof(struct zd_ctrlset) + 10;
540 ZD_ASSERT(packet_length <= 0xffff); 496 ZD_ASSERT(packet_length <= 0xffff);
@@ -579,24 +535,21 @@ static int fill_ctrlset(struct zd_mac *mac,
579 * control block of the skbuff will be initialized. If necessary the incoming 535 * control block of the skbuff will be initialized. If necessary the incoming
580 * mac80211 queues will be stopped. 536 * mac80211 queues will be stopped.
581 */ 537 */
582static int zd_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb, 538static int zd_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb)
583 struct ieee80211_tx_control *control)
584{ 539{
585 struct zd_mac *mac = zd_hw_mac(hw); 540 struct zd_mac *mac = zd_hw_mac(hw);
541 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
586 int r; 542 int r;
587 543
588 r = fill_ctrlset(mac, skb, control); 544 r = fill_ctrlset(mac, skb);
589 if (r) 545 if (r)
590 return r; 546 return r;
591 547
592 r = init_tx_skb_control_block(skb, hw, control); 548 info->driver_data[0] = hw;
593 if (r) 549
594 return r;
595 r = zd_usb_tx(&mac->chip.usb, skb); 550 r = zd_usb_tx(&mac->chip.usb, skb);
596 if (r) { 551 if (r)
597 clear_tx_skb_control_block(skb);
598 return r; 552 return r;
599 }
600 return 0; 553 return 0;
601} 554}
602 555
@@ -617,13 +570,11 @@ static int zd_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb,
617static int filter_ack(struct ieee80211_hw *hw, struct ieee80211_hdr *rx_hdr, 570static int filter_ack(struct ieee80211_hw *hw, struct ieee80211_hdr *rx_hdr,
618 struct ieee80211_rx_status *stats) 571 struct ieee80211_rx_status *stats)
619{ 572{
620 u16 fc = le16_to_cpu(rx_hdr->frame_control);
621 struct sk_buff *skb; 573 struct sk_buff *skb;
622 struct sk_buff_head *q; 574 struct sk_buff_head *q;
623 unsigned long flags; 575 unsigned long flags;
624 576
625 if ((fc & (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) != 577 if (!ieee80211_is_ack(rx_hdr->frame_control))
626 (IEEE80211_FTYPE_CTL | IEEE80211_STYPE_ACK))
627 return 0; 578 return 0;
628 579
629 q = &zd_hw_mac(hw)->ack_wait_queue; 580 q = &zd_hw_mac(hw)->ack_wait_queue;
@@ -634,13 +585,8 @@ static int filter_ack(struct ieee80211_hw *hw, struct ieee80211_hdr *rx_hdr,
634 tx_hdr = (struct ieee80211_hdr *)skb->data; 585 tx_hdr = (struct ieee80211_hdr *)skb->data;
635 if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1))) 586 if (likely(!compare_ether_addr(tx_hdr->addr2, rx_hdr->addr1)))
636 { 587 {
637 struct ieee80211_tx_status status;
638
639 memset(&status, 0, sizeof(status));
640 status.flags = IEEE80211_TX_STATUS_ACK;
641 status.ack_signal = stats->ssi;
642 __skb_unlink(skb, q); 588 __skb_unlink(skb, q);
643 tx_status(hw, skb, &status, 1); 589 tx_status(hw, skb, IEEE80211_TX_STAT_ACK, stats->signal, 1);
644 goto out; 590 goto out;
645 } 591 }
646 } 592 }
@@ -656,8 +602,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length)
656 const struct rx_status *status; 602 const struct rx_status *status;
657 struct sk_buff *skb; 603 struct sk_buff *skb;
658 int bad_frame = 0; 604 int bad_frame = 0;
659 u16 fc; 605 __le16 fc;
660 bool is_qos, is_4addr, need_padding; 606 int need_padding;
661 int i; 607 int i;
662 u8 rate; 608 u8 rate;
663 609
@@ -691,8 +637,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length)
691 637
692 stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq; 638 stats.freq = zd_channels[_zd_chip_get_channel(&mac->chip) - 1].center_freq;
693 stats.band = IEEE80211_BAND_2GHZ; 639 stats.band = IEEE80211_BAND_2GHZ;
694 stats.ssi = status->signal_strength; 640 stats.signal = status->signal_strength;
695 stats.signal = zd_rx_qual_percent(buffer, 641 stats.qual = zd_rx_qual_percent(buffer,
696 length - sizeof(struct rx_status), 642 length - sizeof(struct rx_status),
697 status); 643 status);
698 644
@@ -716,13 +662,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length)
716 && !mac->pass_ctrl) 662 && !mac->pass_ctrl)
717 return 0; 663 return 0;
718 664
719 fc = le16_to_cpu(*((__le16 *) buffer)); 665 fc = *(__le16 *)buffer;
720 666 need_padding = ieee80211_is_data_qos(fc) ^ ieee80211_has_a4(fc);
721 is_qos = ((fc & IEEE80211_FCTL_FTYPE) == IEEE80211_FTYPE_DATA) &&
722 (fc & IEEE80211_STYPE_QOS_DATA);
723 is_4addr = (fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) ==
724 (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS);
725 need_padding = is_qos ^ is_4addr;
726 667
727 skb = dev_alloc_skb(length + (need_padding ? 2 : 0)); 668 skb = dev_alloc_skb(length + (need_padding ? 2 : 0));
728 if (skb == NULL) 669 if (skb == NULL)
@@ -751,6 +692,7 @@ static int zd_op_add_interface(struct ieee80211_hw *hw,
751 case IEEE80211_IF_TYPE_MNTR: 692 case IEEE80211_IF_TYPE_MNTR:
752 case IEEE80211_IF_TYPE_MESH_POINT: 693 case IEEE80211_IF_TYPE_MESH_POINT:
753 case IEEE80211_IF_TYPE_STA: 694 case IEEE80211_IF_TYPE_STA:
695 case IEEE80211_IF_TYPE_IBSS:
754 mac->type = conf->type; 696 mac->type = conf->type;
755 break; 697 break;
756 default: 698 default:
@@ -781,14 +723,20 @@ static int zd_op_config_interface(struct ieee80211_hw *hw,
781{ 723{
782 struct zd_mac *mac = zd_hw_mac(hw); 724 struct zd_mac *mac = zd_hw_mac(hw);
783 int associated; 725 int associated;
726 int r;
784 727
785 if (mac->type == IEEE80211_IF_TYPE_MESH_POINT) { 728 if (mac->type == IEEE80211_IF_TYPE_MESH_POINT ||
729 mac->type == IEEE80211_IF_TYPE_IBSS) {
786 associated = true; 730 associated = true;
787 if (conf->beacon) { 731 if (conf->beacon) {
788 zd_mac_config_beacon(hw, conf->beacon); 732 r = zd_mac_config_beacon(hw, conf->beacon);
789 kfree_skb(conf->beacon); 733 if (r < 0)
790 zd_set_beacon_interval(&mac->chip, BCN_MODE_IBSS | 734 return r;
735 r = zd_set_beacon_interval(&mac->chip, BCN_MODE_IBSS |
791 hw->conf.beacon_int); 736 hw->conf.beacon_int);
737 if (r < 0)
738 return r;
739 kfree_skb(conf->beacon);
792 } 740 }
793 } else 741 } else
794 associated = is_valid_ether_addr(conf->bssid); 742 associated = is_valid_ether_addr(conf->bssid);
@@ -942,6 +890,17 @@ static void zd_op_bss_info_changed(struct ieee80211_hw *hw,
942 } 890 }
943} 891}
944 892
893static int zd_op_beacon_update(struct ieee80211_hw *hw,
894 struct sk_buff *skb)
895{
896 struct zd_mac *mac = zd_hw_mac(hw);
897 zd_mac_config_beacon(hw, skb);
898 kfree_skb(skb);
899 zd_set_beacon_interval(&mac->chip, BCN_MODE_IBSS |
900 hw->conf.beacon_int);
901 return 0;
902}
903
945static const struct ieee80211_ops zd_ops = { 904static const struct ieee80211_ops zd_ops = {
946 .tx = zd_op_tx, 905 .tx = zd_op_tx,
947 .start = zd_op_start, 906 .start = zd_op_start,
@@ -952,6 +911,7 @@ static const struct ieee80211_ops zd_ops = {
952 .config_interface = zd_op_config_interface, 911 .config_interface = zd_op_config_interface,
953 .configure_filter = zd_op_configure_filter, 912 .configure_filter = zd_op_configure_filter,
954 .bss_info_changed = zd_op_bss_info_changed, 913 .bss_info_changed = zd_op_bss_info_changed,
914 .beacon_update = zd_op_beacon_update,
955}; 915};
956 916
957struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf) 917struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)
@@ -983,10 +943,10 @@ struct ieee80211_hw *zd_mac_alloc_hw(struct usb_interface *intf)
983 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; 943 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band;
984 944
985 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 945 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
986 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE; 946 IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE |
987 hw->max_rssi = 100; 947 IEEE80211_HW_SIGNAL_DB;
988 hw->max_signal = 100;
989 948
949 hw->max_signal = 100;
990 hw->queues = 1; 950 hw->queues = 1;
991 hw->extra_tx_headroom = sizeof(struct zd_ctrlset); 951 hw->extra_tx_headroom = sizeof(struct zd_ctrlset);
992 952
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h
index 71170244d2c9..18c1d56d3dd7 100644
--- a/drivers/net/wireless/zd1211rw/zd_mac.h
+++ b/drivers/net/wireless/zd1211rw/zd_mac.h
@@ -149,22 +149,6 @@ struct housekeeping {
149 struct delayed_work link_led_work; 149 struct delayed_work link_led_work;
150}; 150};
151 151
152/**
153 * struct zd_tx_skb_control_block - control block for tx skbuffs
154 * @control: &struct ieee80211_tx_control pointer
155 * @context: context pointer
156 *
157 * This structure is used to fill the cb field in an &sk_buff to transmit.
158 * The control field is NULL, if there is no requirement from the mac80211
159 * stack to report about the packet ACK. This is the case if the flag
160 * IEEE80211_TXCTL_NO_ACK is not set in &struct ieee80211_tx_control.
161 */
162struct zd_tx_skb_control_block {
163 struct ieee80211_tx_control *control;
164 struct ieee80211_hw *hw;
165 void *context;
166};
167
168#define ZD_MAC_STATS_BUFFER_SIZE 16 152#define ZD_MAC_STATS_BUFFER_SIZE 16
169 153
170#define ZD_MAC_MAX_ACK_WAITERS 10 154#define ZD_MAC_MAX_ACK_WAITERS 10
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
index 6cdad9764604..da8b7433e3a6 100644
--- a/drivers/net/wireless/zd1211rw/zd_usb.c
+++ b/drivers/net/wireless/zd1211rw/zd_usb.c
@@ -170,10 +170,11 @@ static int upload_code(struct usb_device *udev,
170 if (flags & REBOOT) { 170 if (flags & REBOOT) {
171 u8 ret; 171 u8 ret;
172 172
173 /* Use "DMA-aware" buffer. */
173 r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 174 r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
174 USB_REQ_FIRMWARE_CONFIRM, 175 USB_REQ_FIRMWARE_CONFIRM,
175 USB_DIR_IN | USB_TYPE_VENDOR, 176 USB_DIR_IN | USB_TYPE_VENDOR,
176 0, 0, &ret, sizeof(ret), 5000 /* ms */); 177 0, 0, p, sizeof(ret), 5000 /* ms */);
177 if (r != sizeof(ret)) { 178 if (r != sizeof(ret)) {
178 dev_err(&udev->dev, 179 dev_err(&udev->dev,
179 "control request firmeware confirmation failed." 180 "control request firmeware confirmation failed."
@@ -182,6 +183,7 @@ static int upload_code(struct usb_device *udev,
182 r = -ENODEV; 183 r = -ENODEV;
183 goto error; 184 goto error;
184 } 185 }
186 ret = p[0];
185 if (ret & 0x80) { 187 if (ret & 0x80) {
186 dev_err(&udev->dev, 188 dev_err(&udev->dev,
187 "Internal error while downloading." 189 "Internal error while downloading."
@@ -313,22 +315,31 @@ int zd_usb_read_fw(struct zd_usb *usb, zd_addr_t addr, u8 *data, u16 len)
313{ 315{
314 int r; 316 int r;
315 struct usb_device *udev = zd_usb_to_usbdev(usb); 317 struct usb_device *udev = zd_usb_to_usbdev(usb);
318 u8 *buf;
316 319
320 /* Use "DMA-aware" buffer. */
321 buf = kmalloc(len, GFP_KERNEL);
322 if (!buf)
323 return -ENOMEM;
317 r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 324 r = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0),
318 USB_REQ_FIRMWARE_READ_DATA, USB_DIR_IN | 0x40, addr, 0, 325 USB_REQ_FIRMWARE_READ_DATA, USB_DIR_IN | 0x40, addr, 0,
319 data, len, 5000); 326 buf, len, 5000);
320 if (r < 0) { 327 if (r < 0) {
321 dev_err(&udev->dev, 328 dev_err(&udev->dev,
322 "read over firmware interface failed: %d\n", r); 329 "read over firmware interface failed: %d\n", r);
323 return r; 330 goto exit;
324 } else if (r != len) { 331 } else if (r != len) {
325 dev_err(&udev->dev, 332 dev_err(&udev->dev,
326 "incomplete read over firmware interface: %d/%d\n", 333 "incomplete read over firmware interface: %d/%d\n",
327 r, len); 334 r, len);
328 return -EIO; 335 r = -EIO;
336 goto exit;
329 } 337 }
330 338 r = 0;
331 return 0; 339 memcpy(data, buf, len);
340exit:
341 kfree(buf);
342 return r;
332} 343}
333 344
334#define urb_dev(urb) (&(urb)->dev->dev) 345#define urb_dev(urb) (&(urb)->dev->dev)
@@ -870,7 +881,7 @@ static void tx_urb_complete(struct urb *urb)
870{ 881{
871 int r; 882 int r;
872 struct sk_buff *skb; 883 struct sk_buff *skb;
873 struct zd_tx_skb_control_block *cb; 884 struct ieee80211_tx_info *info;
874 struct zd_usb *usb; 885 struct zd_usb *usb;
875 886
876 switch (urb->status) { 887 switch (urb->status) {
@@ -894,8 +905,8 @@ free_urb:
894 * grab 'usb' pointer before handing off the skb (since 905 * grab 'usb' pointer before handing off the skb (since
895 * it might be freed by zd_mac_tx_to_dev or mac80211) 906 * it might be freed by zd_mac_tx_to_dev or mac80211)
896 */ 907 */
897 cb = (struct zd_tx_skb_control_block *)skb->cb; 908 info = IEEE80211_SKB_CB(skb);
898 usb = &zd_hw_mac(cb->hw)->chip.usb; 909 usb = &zd_hw_mac(info->driver_data[0])->chip.usb;
899 zd_mac_tx_to_dev(skb, urb->status); 910 zd_mac_tx_to_dev(skb, urb->status);
900 free_tx_urb(usb, urb); 911 free_tx_urb(usb, urb);
901 tx_dec_submitted_urbs(usb); 912 tx_dec_submitted_urbs(usb);