Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-2.6

+675 -406
+16 -4
Documentation/rfkill.txt
··· 390 390 rfkill input line is active. Only if none of the rfkill input lines are 391 391 active, will it return RFKILL_STATE_UNBLOCKED. 392 392 393 - If it doesn't implement the get_state() hook, it must make sure that its calls 394 - to rfkill_force_state() are enough to keep the status always up-to-date, and it 395 - must do a rfkill_force_state() on resume from sleep. 393 + Since the device has a hardware rfkill line, it IS subject to state changes 394 + external to rfkill. Therefore, the driver must make sure that it calls 395 + rfkill_force_state() to keep the status always up-to-date, and it must do a 396 + rfkill_force_state() on resume from sleep. 396 397 397 398 Every time the driver gets a notification from the card that one of its rfkill 398 399 lines changed state (polling might be needed on badly designed cards that don't ··· 423 422 about its current state). 424 423 425 424 The rfkill class will call the get_state hook of a device every time it needs 426 - to know the *real* current state of the hardware. This can happen often. 425 + to know the *real* current state of the hardware. This can happen often, but 426 + it does not do any polling, so it is not enough on hardware that is subject 427 + to state changes outside of the rfkill subsystem. 428 + 429 + Therefore, calling rfkill_force_state() when a state change happens is 430 + mandatory when the device has a hardware rfkill line, or when something else 431 + like the firmware could cause its state to be changed without going through the 432 + rfkill class. 427 433 428 434 Some hardware provides events when its status changes. In these cases, it is 429 435 best for the driver to not provide a get_state hook, and instead register the 430 436 rfkill class *already* with the correct status, and keep it updated using 431 437 rfkill_force_state() when it gets an event from the hardware. 438 + 439 + rfkill_force_state() must be used on the device resume handlers to update the 440 + rfkill status, should there be any chance of the device status changing during 441 + the sleep. 432 442 433 443 There is no provision for a statically-allocated rfkill struct. You must 434 444 use rfkill_allocate() to allocate one.
+6 -6
drivers/net/ps3_gelic_wireless.c
··· 1024 1024 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev)); 1025 1025 struct iw_point *enc = &data->encoding; 1026 1026 __u16 flags; 1027 - unsigned int irqflag; 1027 + unsigned long irqflag; 1028 1028 int key_index, index_specified; 1029 1029 int ret = 0; 1030 1030 ··· 1097 1097 { 1098 1098 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev)); 1099 1099 struct iw_point *enc = &data->encoding; 1100 - unsigned int irqflag; 1100 + unsigned long irqflag; 1101 1101 unsigned int key_index, index_specified; 1102 1102 int ret = 0; 1103 1103 ··· 1215 1215 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1216 1216 __u16 alg; 1217 1217 __u16 flags; 1218 - unsigned int irqflag; 1218 + unsigned long irqflag; 1219 1219 int key_index; 1220 1220 int ret = 0; 1221 1221 ··· 1303 1303 struct gelic_wl_info *wl = port_wl(netdev_priv(netdev)); 1304 1304 struct iw_point *enc = &data->encoding; 1305 1305 struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; 1306 - unsigned int irqflag; 1306 + unsigned long irqflag; 1307 1307 int key_index; 1308 1308 int ret = 0; 1309 1309 int max_key_len; ··· 1426 1426 { 1427 1427 struct gelic_wl_info *wl = port_wl(netdev_priv(net_dev)); 1428 1428 unsigned int len; 1429 - unsigned int irqflag; 1429 + unsigned long irqflag; 1430 1430 int ret = 0; 1431 1431 1432 1432 pr_debug("%s:<- len=%d\n", __func__, data->data.length); ··· 1467 1467 { 1468 1468 struct gelic_wl_info *wl = port_wl(netdev_priv(net_dev)); 1469 1469 char *p; 1470 - unsigned int irqflag; 1470 + unsigned long irqflag; 1471 1471 unsigned int i; 1472 1472 1473 1473 pr_debug("%s:<-\n", __func__);
+63 -36
drivers/net/wireless/ath5k/base.c
··· 43 43 #include <linux/version.h> 44 44 #include <linux/module.h> 45 45 #include <linux/delay.h> 46 + #include <linux/hardirq.h> 46 47 #include <linux/if.h> 48 + #include <linux/io.h> 47 49 #include <linux/netdevice.h> 48 50 #include <linux/cache.h> 49 51 #include <linux/pci.h> ··· 473 471 /* Set private data */ 474 472 pci_set_drvdata(pdev, hw); 475 473 476 - /* Enable msi for devices that support it */ 477 - pci_enable_msi(pdev); 478 - 479 474 /* Setup interrupt handler */ 480 475 ret = request_irq(pdev->irq, ath5k_intr, IRQF_SHARED, "ath", sc); 481 476 if (ret) { ··· 550 551 err_irq: 551 552 free_irq(pdev->irq, sc); 552 553 err_free: 553 - pci_disable_msi(pdev); 554 554 ieee80211_free_hw(hw); 555 555 err_map: 556 556 pci_iounmap(pdev, mem); ··· 571 573 ath5k_detach(pdev, hw); 572 574 ath5k_hw_detach(sc->ah); 573 575 free_irq(pdev->irq, sc); 574 - pci_disable_msi(pdev); 575 576 pci_iounmap(pdev, sc->iobase); 576 577 pci_release_region(pdev, 0); 577 578 pci_disable_device(pdev); ··· 587 590 ath5k_led_off(sc); 588 591 589 592 ath5k_stop_hw(sc); 593 + 594 + free_irq(pdev->irq, sc); 595 + pci_disable_msi(pdev); 590 596 pci_save_state(pdev); 591 597 pci_disable_device(pdev); 592 598 pci_set_power_state(pdev, PCI_D3hot); ··· 605 605 struct ath5k_hw *ah = sc->ah; 606 606 int i, err; 607 607 608 - err = pci_set_power_state(pdev, PCI_D0); 609 - if (err) 610 - return err; 608 + pci_restore_state(pdev); 611 609 612 610 err = pci_enable_device(pdev); 613 611 if (err) 614 612 return err; 615 613 616 - pci_restore_state(pdev); 617 614 /* 618 615 * Suspend/Resume resets the PCI configuration space, so we have to 619 616 * re-disable the RETRY_TIMEOUT register (0x41) to keep ··· 618 621 */ 619 622 pci_write_config_byte(pdev, 0x41, 0); 620 623 621 - ath5k_init(sc); 624 + pci_enable_msi(pdev); 625 + 626 + err = request_irq(pdev->irq, ath5k_intr, IRQF_SHARED, "ath", sc); 627 + if (err) { 628 + ATH5K_ERR(sc, "request_irq failed\n"); 629 + goto err_msi; 630 + } 631 + 632 + err = ath5k_init(sc); 633 + if (err) 634 + goto err_irq; 622 635 ath5k_led_enable(sc); 623 636 624 637 /* ··· 642 635 ath5k_hw_reset_key(ah, i); 643 636 644 637 return 0; 638 + err_irq: 639 + free_irq(pdev->irq, sc); 640 + err_msi: 641 + pci_disable_msi(pdev); 642 + pci_disable_device(pdev); 643 + return err; 645 644 } 646 645 #endif /* CONFIG_PM */ 647 646 ··· 1237 1224 1238 1225 pktlen = skb->len; 1239 1226 1240 - if (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)) { 1227 + if (info->control.hw_key) { 1241 1228 keyidx = info->control.hw_key->hw_key_idx; 1242 1229 pktlen += info->control.icv_len; 1243 1230 } ··· 1262 1249 1263 1250 txq->link = &ds->ds_link; 1264 1251 ath5k_hw_tx_start(ah, txq->qnum); 1252 + mmiowb(); 1265 1253 spin_unlock_bh(&txq->lock); 1266 1254 1267 1255 return 0; ··· 1597 1583 ath5k_hw_stop_pcu_recv(ah); /* disable PCU */ 1598 1584 ath5k_hw_set_rx_filter(ah, 0); /* clear recv filter */ 1599 1585 ath5k_hw_stop_rx_dma(ah); /* disable DMA engine */ 1600 - mdelay(3); /* 3ms is long enough for 1 frame */ 1601 1586 1602 1587 ath5k_debug_printrxbuffs(sc, ah); 1603 1588 ··· 1695 1682 struct ath5k_rx_status rs = {}; 1696 1683 struct sk_buff *skb; 1697 1684 struct ath5k_softc *sc = (void *)data; 1698 - struct ath5k_buf *bf; 1685 + struct ath5k_buf *bf, *bf_last; 1699 1686 struct ath5k_desc *ds; 1700 1687 int ret; 1701 1688 int hdrlen; 1702 1689 int pad; 1703 1690 1704 1691 spin_lock(&sc->rxbuflock); 1692 + if (list_empty(&sc->rxbuf)) { 1693 + ATH5K_WARN(sc, "empty rx buf pool\n"); 1694 + goto unlock; 1695 + } 1696 + bf_last = list_entry(sc->rxbuf.prev, struct ath5k_buf, list); 1705 1697 do { 1706 1698 rxs.flag = 0; 1707 1699 1708 - if (unlikely(list_empty(&sc->rxbuf))) { 1709 - ATH5K_WARN(sc, "empty rx buf pool\n"); 1710 - break; 1711 - } 1712 1700 bf = list_first_entry(&sc->rxbuf, struct ath5k_buf, list); 1713 1701 BUG_ON(bf->skb == NULL); 1714 1702 skb = bf->skb; 1715 1703 ds = bf->desc; 1716 1704 1717 - /* TODO only one segment */ 1718 - pci_dma_sync_single_for_cpu(sc->pdev, sc->desc_daddr, 1719 - sc->desc_len, PCI_DMA_FROMDEVICE); 1720 - 1721 - if (unlikely(ds->ds_link == bf->daddr)) /* this is the end */ 1722 - break; 1705 + /* 1706 + * last buffer must not be freed to ensure proper hardware 1707 + * function. When the hardware finishes also a packet next to 1708 + * it, we are sure, it doesn't use it anymore and we can go on. 1709 + */ 1710 + if (bf_last == bf) 1711 + bf->flags |= 1; 1712 + if (bf->flags) { 1713 + struct ath5k_buf *bf_next = list_entry(bf->list.next, 1714 + struct ath5k_buf, list); 1715 + ret = sc->ah->ah_proc_rx_desc(sc->ah, bf_next->desc, 1716 + &rs); 1717 + if (ret) 1718 + break; 1719 + bf->flags &= ~1; 1720 + /* skip the overwritten one (even status is martian) */ 1721 + goto next; 1722 + } 1723 1723 1724 1724 ret = sc->ah->ah_proc_rx_desc(sc->ah, ds, &rs); 1725 1725 if (unlikely(ret == -EINPROGRESS)) ··· 1778 1752 goto next; 1779 1753 } 1780 1754 accept: 1781 - pci_dma_sync_single_for_cpu(sc->pdev, bf->skbaddr, 1782 - rs.rs_datalen, PCI_DMA_FROMDEVICE); 1783 1755 pci_unmap_single(sc->pdev, bf->skbaddr, sc->rxbufsize, 1784 1756 PCI_DMA_FROMDEVICE); 1785 1757 bf->skb = NULL; ··· 1840 1816 next: 1841 1817 list_move_tail(&bf->list, &sc->rxbuf); 1842 1818 } while (ath5k_rxbuf_setup(sc, bf) == 0); 1819 + unlock: 1843 1820 spin_unlock(&sc->rxbuflock); 1844 1821 } 1845 1822 ··· 1865 1840 list_for_each_entry_safe(bf, bf0, &txq->q, list) { 1866 1841 ds = bf->desc; 1867 1842 1868 - /* TODO only one segment */ 1869 - pci_dma_sync_single_for_cpu(sc->pdev, sc->desc_daddr, 1870 - sc->desc_len, PCI_DMA_FROMDEVICE); 1871 1843 ret = sc->ah->ah_proc_tx_desc(sc->ah, ds, &ts); 1872 1844 if (unlikely(ret == -EINPROGRESS)) 1873 1845 break; ··· 2037 2015 ATH5K_WARN(sc, "beacon queue %u didn't stop?\n", sc->bhalq); 2038 2016 /* NB: hw still stops DMA, so proceed */ 2039 2017 } 2040 - pci_dma_sync_single_for_cpu(sc->pdev, bf->skbaddr, bf->skb->len, 2041 - PCI_DMA_TODEVICE); 2042 2018 2043 2019 ath5k_hw_put_tx_buf(ah, sc->bhalq, bf->daddr); 2044 2020 ath5k_hw_tx_start(ah, sc->bhalq); ··· 2260 2240 2261 2241 ret = 0; 2262 2242 done: 2243 + mmiowb(); 2263 2244 mutex_unlock(&sc->lock); 2264 2245 return ret; 2265 2246 } ··· 2293 2272 if (!test_bit(ATH_STAT_INVALID, sc->status)) { 2294 2273 ath5k_led_off(sc); 2295 2274 ath5k_hw_set_intr(ah, 0); 2275 + synchronize_irq(sc->pdev->irq); 2296 2276 } 2297 2277 ath5k_txq_cleanup(sc); 2298 2278 if (!test_bit(ATH_STAT_INVALID, sc->status)) { ··· 2343 2321 } 2344 2322 } 2345 2323 ath5k_txbuf_free(sc, sc->bbuf); 2324 + mmiowb(); 2346 2325 mutex_unlock(&sc->lock); 2347 2326 2348 2327 del_timer_sync(&sc->calib_tim); 2328 + tasklet_kill(&sc->rxtq); 2329 + tasklet_kill(&sc->txtq); 2330 + tasklet_kill(&sc->restq); 2349 2331 2350 2332 return ret; 2351 2333 } ··· 2576 2550 struct pci_dev *pdev = sc->pdev; 2577 2551 char name[ATH5K_LED_MAX_NAME_LEN + 1]; 2578 2552 2579 - sc->led_on = 0; /* active low */ 2580 - 2581 2553 /* 2582 2554 * Auto-enable soft led processing for IBM cards and for 2583 2555 * 5211 minipci cards. ··· 2584 2560 pdev->device == PCI_DEVICE_ID_ATHEROS_AR5211) { 2585 2561 __set_bit(ATH_STAT_LEDSOFT, sc->status); 2586 2562 sc->led_pin = 0; 2563 + sc->led_on = 0; /* active low */ 2587 2564 } 2588 2565 /* Enable softled on PIN1 on HP Compaq nc6xx, nc4000 & nx5000 laptops */ 2589 2566 if (pdev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ) { 2590 2567 __set_bit(ATH_STAT_LEDSOFT, sc->status); 2591 2568 sc->led_pin = 1; 2569 + sc->led_on = 1; /* active high */ 2592 2570 } 2593 2571 if (!test_bit(ATH_STAT_LEDSOFT, sc->status)) 2594 2572 goto out; ··· 2809 2783 /* XXX: assoc id is set to 0 for now, mac80211 doesn't have 2810 2784 * a clean way of letting us retrieve this yet. */ 2811 2785 ath5k_hw_set_associd(ah, ah->ah_bssid, 0); 2786 + mmiowb(); 2812 2787 } 2813 2788 2814 2789 if (conf->changed & IEEE80211_IFCC_BEACON && ··· 2998 2971 } 2999 2972 3000 2973 unlock: 2974 + mmiowb(); 3001 2975 mutex_unlock(&sc->lock); 3002 2976 return ret; 3003 2977 } ··· 3060 3032 3061 3033 ath5k_debug_dump_skb(sc, skb, "BC ", 1); 3062 3034 3063 - mutex_lock(&sc->lock); 3064 - 3065 3035 if (sc->opmode != IEEE80211_IF_TYPE_IBSS) { 3066 3036 ret = -EIO; 3067 3037 goto end; ··· 3070 3044 ret = ath5k_beacon_setup(sc, sc->bbuf); 3071 3045 if (ret) 3072 3046 sc->bbuf->skb = NULL; 3073 - else 3047 + else { 3074 3048 ath5k_beacon_config(sc); 3049 + mmiowb(); 3050 + } 3075 3051 3076 3052 end: 3077 - mutex_unlock(&sc->lock); 3078 3053 return ret; 3079 3054 } 3080 3055
+1 -1
drivers/net/wireless/ath5k/base.h
··· 56 56 57 57 struct ath5k_buf { 58 58 struct list_head list; 59 - unsigned int flags; /* tx descriptor flags */ 59 + unsigned int flags; /* rx descriptor flags */ 60 60 struct ath5k_desc *desc; /* virtual addr of desc */ 61 61 dma_addr_t daddr; /* physical addr of desc */ 62 62 struct sk_buff *skb; /* skbuff for buf */
+4
drivers/net/wireless/ath5k/hw.c
··· 1440 1440 1441 1441 /* Stop queue */ 1442 1442 ath5k_hw_reg_write(ah, tx_queue, AR5K_CR); 1443 + ath5k_hw_reg_read(ah, AR5K_CR); 1443 1444 } else { 1444 1445 /* 1445 1446 * Schedule TX disable and wait until queue is empty ··· 1457 1456 1458 1457 /* Clear register */ 1459 1458 ath5k_hw_reg_write(ah, 0, AR5K_QCU_TXD); 1459 + if (pending) 1460 + return -EBUSY; 1460 1461 } 1461 1462 1462 1463 /* TODO: Check for success else return error */ ··· 1719 1716 1720 1717 /* ..re-enable interrupts */ 1721 1718 ath5k_hw_reg_write(ah, AR5K_IER_ENABLE, AR5K_IER); 1719 + ath5k_hw_reg_read(ah, AR5K_IER); 1722 1720 1723 1721 return old_mask; 1724 1722 }
+1 -2
drivers/net/wireless/b43/main.c
··· 4645 4645 } 4646 4646 4647 4647 /* fill hw info */ 4648 - hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 4649 - IEEE80211_HW_RX_INCLUDES_FCS | 4648 + hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 4650 4649 IEEE80211_HW_SIGNAL_DBM | 4651 4650 IEEE80211_HW_NOISE_DBM; 4652 4651
+1 -1
drivers/net/wireless/b43/xmit.c
··· 192 192 const struct b43_phy *phy = &dev->phy; 193 193 const struct ieee80211_hdr *wlhdr = 194 194 (const struct ieee80211_hdr *)fragment_data; 195 - int use_encryption = (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)); 195 + int use_encryption = !!info->control.hw_key; 196 196 __le16 fctl = wlhdr->frame_control; 197 197 struct ieee80211_rate *fbrate; 198 198 u8 rate, rate_fb;
+2 -3
drivers/net/wireless/b43legacy/main.c
··· 3702 3702 } 3703 3703 3704 3704 /* fill hw info */ 3705 - hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 3706 - IEEE80211_HW_RX_INCLUDES_FCS | 3705 + hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 3707 3706 IEEE80211_HW_SIGNAL_DBM | 3708 3707 IEEE80211_HW_NOISE_DBM; 3709 3708 hw->queues = 1; /* FIXME: hardware has more queues */ ··· 3845 3846 goto out; 3846 3847 } 3847 3848 } 3848 - mutex_unlock(&wl->mutex); 3849 3849 3850 3850 b43legacydbg(wl, "Device resumed.\n"); 3851 3851 out: 3852 + mutex_unlock(&wl->mutex); 3852 3853 return err; 3853 3854 } 3854 3855
+1 -1
drivers/net/wireless/b43legacy/xmit.c
··· 192 192 u16 cookie) 193 193 { 194 194 const struct ieee80211_hdr *wlhdr; 195 - int use_encryption = (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)); 195 + int use_encryption = !!info->control.hw_key; 196 196 u16 fctl; 197 197 u8 rate; 198 198 struct ieee80211_rate *rate_fb;
+2 -1
drivers/net/wireless/ipw2100.c
··· 6442 6442 if (err) { 6443 6443 printk(KERN_ERR "%s: pci_enable_device failed on resume\n", 6444 6444 dev->name); 6445 + mutex_unlock(&priv->action_mutex); 6445 6446 return err; 6446 6447 } 6447 6448 pci_restore_state(pci_dev); ··· 7147 7146 err = ipw2100_get_ordinal(priv, IPW_ORD_CURRENT_TX_RATE, &val, &len); 7148 7147 if (err) { 7149 7148 IPW_DEBUG_WX("failed querying ordinals.\n"); 7150 - return err; 7149 + goto done; 7151 7150 } 7152 7151 7153 7152 switch (val & TX_RATE_MASK) {
+2
drivers/net/wireless/iwlwifi/iwl-3945.c
··· 630 630 struct ieee80211_rx_status *stats) 631 631 { 632 632 struct iwl3945_rx_packet *pkt = (struct iwl3945_rx_packet *)rxb->skb->data; 633 + #ifdef CONFIG_IWL3945_LEDS 633 634 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)IWL_RX_DATA(pkt); 635 + #endif 634 636 struct iwl3945_rx_frame_hdr *rx_hdr = IWL_RX_HDR(pkt); 635 637 struct iwl3945_rx_frame_end *rx_end = IWL_RX_END(pkt); 636 638 short len = le16_to_cpu(rx_hdr->len);
+1 -2
drivers/net/wireless/iwlwifi/iwl-core.c
··· 818 818 hw->rate_control_algorithm = "iwl-4965-rs"; 819 819 820 820 /* Tell mac80211 our characteristics */ 821 - hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 822 - IEEE80211_HW_SIGNAL_DBM | 821 + hw->flags = IEEE80211_HW_SIGNAL_DBM | 823 822 IEEE80211_HW_NOISE_DBM; 824 823 /* Default value; 4 EDCA QOS priorities */ 825 824 hw->queues = 4;
+2 -6
drivers/net/wireless/iwlwifi/iwl-debug.h
··· 68 68 #endif 69 69 70 70 #else 71 - static inline void IWL_DEBUG(int level, const char *fmt, ...) 72 - { 73 - } 74 - static inline void IWL_DEBUG_LIMIT(int level, const char *fmt, ...) 75 - { 76 - } 71 + #define IWL_DEBUG(level, fmt, args...) 72 + #define IWL_DEBUG_LIMIT(level, fmt, args...) 77 73 #endif /* CONFIG_IWLWIFI_DEBUG */ 78 74 79 75
+3 -1
drivers/net/wireless/iwlwifi/iwl-led.c
··· 268 268 if (tpt < 0) /* wrapparound */ 269 269 tpt = -tpt; 270 270 271 - IWL_DEBUG_LED("tpt %lld current_tpt %lld\n", tpt, current_tpt); 271 + IWL_DEBUG_LED("tpt %lld current_tpt %llu\n", 272 + (long long)tpt, 273 + (unsigned long long)current_tpt); 272 274 priv->led_tpt = current_tpt; 273 275 274 276 if (!priv->allow_blinking)
+2
drivers/net/wireless/iwlwifi/iwl-scan.c
··· 270 270 static void iwl_rx_scan_complete_notif(struct iwl_priv *priv, 271 271 struct iwl_rx_mem_buffer *rxb) 272 272 { 273 + #ifdef CONFIG_IWLWIFI_DEBUG 273 274 struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 274 275 struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; 275 276 ··· 278 277 scan_notif->scanned_channels, 279 278 scan_notif->tsf_low, 280 279 scan_notif->tsf_high, scan_notif->status); 280 + #endif 281 281 282 282 /* The HW is no longer scanning */ 283 283 clear_bit(STATUS_SCAN_HW, &priv->status);
+1 -1
drivers/net/wireless/iwlwifi/iwl-tx.c
··· 906 906 * first entry */ 907 907 iwl_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len); 908 908 909 - if (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)) 909 + if (info->control.hw_key) 910 910 iwl_tx_cmd_build_hwcrypto(priv, info, tx_cmd, skb, sta_id); 911 911 912 912 /* Set up TFD's 2nd entry to point directly to remainder of skb,
+2 -3
drivers/net/wireless/iwlwifi/iwl3945-base.c
··· 2667 2667 * first entry */ 2668 2668 iwl3945_hw_txq_attach_buf_to_tfd(priv, tfd, txcmd_phys, len); 2669 2669 2670 - if (!(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)) 2670 + if (info->control.hw_key) 2671 2671 iwl3945_build_tx_cmd_hwcrypto(priv, info, out_cmd, skb, 0); 2672 2672 2673 2673 /* Set up TFD's 2nd entry to point directly to remainder of skb, ··· 7899 7899 priv->ibss_beacon = NULL; 7900 7900 7901 7901 /* Tell mac80211 our characteristics */ 7902 - hw->flags = IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 7903 - IEEE80211_HW_SIGNAL_DBM | 7902 + hw->flags = IEEE80211_HW_SIGNAL_DBM | 7904 7903 IEEE80211_HW_NOISE_DBM; 7905 7904 7906 7905 /* 4 EDCA QOS priorities */
+15 -15
drivers/net/wireless/libertas/persistcfg.c
··· 48 48 if (ret) 49 49 return ret; 50 50 51 - return snprintf(buf, 12, "0x%x\n", le32_to_cpu(defs.bootflag)); 51 + return snprintf(buf, 12, "%d\n", le32_to_cpu(defs.bootflag)); 52 52 } 53 53 54 54 /** ··· 63 63 int ret; 64 64 65 65 memset(&cmd, 0, sizeof(cmd)); 66 - ret = sscanf(buf, "%x", &datum); 67 - if (ret != 1) 66 + ret = sscanf(buf, "%d", &datum); 67 + if ((ret != 1) || (datum > 1)) 68 68 return -EINVAL; 69 69 70 70 *((__le32 *)&cmd.data[0]) = cpu_to_le32(!!datum); ··· 91 91 if (ret) 92 92 return ret; 93 93 94 - return snprintf(buf, 12, "0x%x\n", defs.boottime); 94 + return snprintf(buf, 12, "%d\n", defs.boottime); 95 95 } 96 96 97 97 /** ··· 106 106 int ret; 107 107 108 108 memset(&cmd, 0, sizeof(cmd)); 109 - ret = sscanf(buf, "%x", &datum); 110 - if (ret != 1) 109 + ret = sscanf(buf, "%d", &datum); 110 + if ((ret != 1) || (datum > 255)) 111 111 return -EINVAL; 112 112 113 113 /* A too small boot time will result in the device booting into ··· 143 143 if (ret) 144 144 return ret; 145 145 146 - return snprintf(buf, 12, "0x%x\n", le16_to_cpu(defs.channel)); 146 + return snprintf(buf, 12, "%d\n", le16_to_cpu(defs.channel)); 147 147 } 148 148 149 149 /** ··· 154 154 { 155 155 struct lbs_private *priv = to_net_dev(dev)->priv; 156 156 struct cmd_ds_mesh_config cmd; 157 - uint16_t datum; 157 + uint32_t datum; 158 158 int ret; 159 159 160 160 memset(&cmd, 0, sizeof(cmd)); 161 - ret = sscanf(buf, "%hx", &datum); 161 + ret = sscanf(buf, "%d", &datum); 162 162 if (ret != 1 || datum < 1 || datum > 11) 163 163 return -EINVAL; 164 164 ··· 274 274 int ret; 275 275 276 276 memset(&cmd, 0, sizeof(cmd)); 277 - ret = sscanf(buf, "%x", &datum); 278 - if (ret != 1) 277 + ret = sscanf(buf, "%d", &datum); 278 + if ((ret != 1) || (datum > 255)) 279 279 return -EINVAL; 280 280 281 281 /* fetch all other Information Element parameters */ ··· 328 328 int ret; 329 329 330 330 memset(&cmd, 0, sizeof(cmd)); 331 - ret = sscanf(buf, "%x", &datum); 332 - if (ret != 1) 331 + ret = sscanf(buf, "%d", &datum); 332 + if ((ret != 1) || (datum > 255)) 333 333 return -EINVAL; 334 334 335 335 /* fetch all other Information Element parameters */ ··· 382 382 int ret; 383 383 384 384 memset(&cmd, 0, sizeof(cmd)); 385 - ret = sscanf(buf, "%x", &datum); 386 - if (ret != 1) 385 + ret = sscanf(buf, "%d", &datum); 386 + if ((ret != 1) || (datum > 255)) 387 387 return -EINVAL; 388 388 389 389 /* fetch all other Information Element parameters */
+1 -1
drivers/net/wireless/mac80211_hwsim.c
··· 500 500 device_unregister(data->dev); 501 501 failed_drvdata: 502 502 ieee80211_free_hw(hw); 503 - hwsim_radios[i] = 0; 503 + hwsim_radios[i] = NULL; 504 504 failed: 505 505 mac80211_hwsim_free(); 506 506 return err;
+12 -1
drivers/net/wireless/rt2x00/rt2500usb.c
··· 1121 1121 int pipe = usb_sndbulkpipe(usb_dev, 1); 1122 1122 int length; 1123 1123 u16 reg; 1124 + u32 word, len; 1124 1125 1125 1126 /* 1126 1127 * Add the descriptor in front of the skb. ··· 1129 1128 skb_push(entry->skb, entry->queue->desc_size); 1130 1129 memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len); 1131 1130 skbdesc->desc = entry->skb->data; 1131 + 1132 + /* 1133 + * Adjust the beacon databyte count. The current number is 1134 + * calculated before this function gets called, but falsely 1135 + * assumes that the descriptor was already present in the SKB. 1136 + */ 1137 + rt2x00_desc_read(skbdesc->desc, 0, &word); 1138 + len = rt2x00_get_field32(word, TXD_W0_DATABYTE_COUNT); 1139 + len += skbdesc->desc_len; 1140 + rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, len); 1141 + rt2x00_desc_write(skbdesc->desc, 0, word); 1132 1142 1133 1143 /* 1134 1144 * Disable beaconing while we are reloading the beacon data, ··· 1662 1650 * Initialize all hw fields. 1663 1651 */ 1664 1652 rt2x00dev->hw->flags = 1665 - IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 1666 1653 IEEE80211_HW_RX_INCLUDES_FCS | 1667 1654 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 1668 1655 IEEE80211_HW_SIGNAL_DBM;
+5 -1
drivers/net/wireless/rt2x00/rt2x00.h
··· 108 108 #define SHORT_PIFS ( SIFS + SHORT_SLOT_TIME ) 109 109 #define DIFS ( PIFS + SLOT_TIME ) 110 110 #define SHORT_DIFS ( SHORT_PIFS + SHORT_SLOT_TIME ) 111 - #define EIFS ( SIFS + (8 * (IEEE80211_HEADER + ACK_SIZE)) ) 111 + #define EIFS ( SIFS + DIFS + \ 112 + (8 * (IEEE80211_HEADER + ACK_SIZE)) ) 113 + #define SHORT_EIFS ( SIFS + SHORT_DIFS + \ 114 + (8 * (IEEE80211_HEADER + ACK_SIZE)) ) 112 115 113 116 /* 114 117 * Chipset identification ··· 600 597 DEVICE_STARTED_SUSPEND, 601 598 DEVICE_ENABLED_RADIO, 602 599 DEVICE_DISABLED_RADIO_HW, 600 + DEVICE_DIRTY_CONFIG, 603 601 604 602 /* 605 603 * Driver features
+1 -1
drivers/net/wireless/rt2x00/rt2x00config.c
··· 271 271 libconf.sifs = SIFS; 272 272 libconf.pifs = short_slot_time ? SHORT_PIFS : PIFS; 273 273 libconf.difs = short_slot_time ? SHORT_DIFS : DIFS; 274 - libconf.eifs = EIFS; 274 + libconf.eifs = short_slot_time ? SHORT_EIFS : EIFS; 275 275 } 276 276 277 277 libconf.conf = conf;
+4 -3
drivers/net/wireless/rt2x00/rt2x00dev.c
··· 1013 1013 rt2x00dev->intf_associated = 0; 1014 1014 1015 1015 __set_bit(DEVICE_STARTED, &rt2x00dev->flags); 1016 + __set_bit(DEVICE_DIRTY_CONFIG, &rt2x00dev->flags); 1016 1017 1017 1018 return 0; 1018 1019 } ··· 1238 1237 /* 1239 1238 * Reconfigure device. 1240 1239 */ 1241 - rt2x00lib_config(rt2x00dev, &rt2x00dev->hw->conf, 1); 1242 - if (!rt2x00dev->hw->conf.radio_enabled) 1243 - rt2x00lib_disable_radio(rt2x00dev); 1240 + retval = rt2x00mac_config(rt2x00dev->hw, &rt2x00dev->hw->conf); 1241 + if (retval) 1242 + goto exit; 1244 1243 1245 1244 /* 1246 1245 * Iterator over each active interface to
-7
drivers/net/wireless/rt2x00/rt2x00lib.h
··· 125 125 void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb); 126 126 127 127 /** 128 - * rt2x00queue_free_skb - free a skb 129 - * @rt2x00dev: Pointer to &struct rt2x00_dev. 130 - * @skb: The skb to free. 131 - */ 132 - void rt2x00queue_free_skb(struct rt2x00_dev *rt2x00dev, struct sk_buff *skb); 133 - 134 - /** 135 128 * rt2x00queue_write_tx_frame - Write TX frame to hardware 136 129 * @queue: Queue over which the frame should be send 137 130 * @skb: The skb to send
+14 -15
drivers/net/wireless/rt2x00/rt2x00mac.c
··· 63 63 */ 64 64 memcpy(skb->cb, frag_skb->cb, sizeof(skb->cb)); 65 65 rts_info = IEEE80211_SKB_CB(skb); 66 - rts_info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; 66 + rts_info->control.hw_key = NULL; 67 67 rts_info->flags &= ~IEEE80211_TX_CTL_USE_RTS_CTS; 68 68 rts_info->flags &= ~IEEE80211_TX_CTL_USE_CTS_PROTECT; 69 69 rts_info->flags &= ~IEEE80211_TX_CTL_REQ_TX_STATUS; ··· 83 83 (struct ieee80211_rts *)(skb->data)); 84 84 85 85 if (rt2x00queue_write_tx_frame(queue, skb)) { 86 + dev_kfree_skb_any(skb); 86 87 WARNING(rt2x00dev, "Failed to send RTS/CTS frame.\n"); 87 88 return NETDEV_TX_BUSY; 88 89 } ··· 97 96 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(skb); 98 97 struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data; 99 98 enum data_queue_qid qid = skb_get_queue_mapping(skb); 100 - struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); 101 99 struct data_queue *queue; 102 100 u16 frame_control; 103 101 ··· 150 150 ieee80211_stop_queue(rt2x00dev->hw, qid); 151 151 return NETDEV_TX_BUSY; 152 152 } 153 - } 154 - 155 - /* 156 - * XXX: This is as wrong as the old mac80211 code was, 157 - * due to beacons not getting sequence numbers assigned 158 - * properly. 159 - */ 160 - if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { 161 - if (tx_info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) 162 - intf->seqno += 0x10; 163 - ieee80211hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); 164 - ieee80211hdr->seq_ctrl |= cpu_to_le16(intf->seqno); 165 153 } 166 154 167 155 if (rt2x00queue_write_tx_frame(queue, skb)) { ··· 310 322 int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf) 311 323 { 312 324 struct rt2x00_dev *rt2x00dev = hw->priv; 325 + int force_reconfig; 313 326 314 327 /* 315 328 * Mac80211 might be calling this function while we are trying ··· 330 341 rt2x00lib_toggle_rx(rt2x00dev, STATE_RADIO_RX_OFF); 331 342 } 332 343 333 - rt2x00lib_config(rt2x00dev, conf, 0); 344 + /* 345 + * When the DEVICE_DIRTY_CONFIG flag is set, the device has recently 346 + * been started and the configuration must be forced upon the hardware. 347 + * Otherwise registers will not be intialized correctly and could 348 + * result in non-working hardware because essential registers aren't 349 + * initialized. 350 + */ 351 + force_reconfig = 352 + __test_and_clear_bit(DEVICE_DIRTY_CONFIG, &rt2x00dev->flags); 353 + 354 + rt2x00lib_config(rt2x00dev, conf, force_reconfig); 334 355 335 356 /* 336 357 * Reenable RX only if the radio should be on.
+34 -2
drivers/net/wireless/rt2x00/rt2x00queue.c
··· 120 120 { 121 121 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; 122 122 struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); 123 + struct rt2x00_intf *intf = vif_to_intf(tx_info->control.vif); 123 124 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)entry->skb->data; 124 125 struct ieee80211_rate *rate = 125 126 ieee80211_get_tx_rate(rt2x00dev->hw, tx_info); ··· 198 197 txdesc->ifs = IFS_BACKOFF; 199 198 } else { 200 199 txdesc->ifs = IFS_SIFS; 200 + } 201 + 202 + /* 203 + * Hardware should insert sequence counter. 204 + * FIXME: We insert a software sequence counter first for 205 + * hardware that doesn't support hardware sequence counting. 206 + * 207 + * This is wrong because beacons are not getting sequence 208 + * numbers assigned properly. 209 + * 210 + * A secondary problem exists for drivers that cannot toggle 211 + * sequence counting per-frame, since those will override the 212 + * sequence counter given by mac80211. 213 + */ 214 + if (tx_info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { 215 + spin_lock(&intf->lock); 216 + 217 + if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)) 218 + intf->seqno += 0x10; 219 + hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); 220 + hdr->seq_ctrl |= cpu_to_le16(intf->seqno); 221 + 222 + spin_unlock(&intf->lock); 223 + 224 + __set_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags); 201 225 } 202 226 203 227 /* ··· 492 466 if (!rt2x00dev->ops->lib->init_rxentry) 493 467 return; 494 468 495 - for (i = 0; i < queue->limit; i++) 469 + for (i = 0; i < queue->limit; i++) { 470 + queue->entries[i].flags = 0; 471 + 496 472 rt2x00dev->ops->lib->init_rxentry(rt2x00dev, 497 473 &queue->entries[i]); 474 + } 498 475 } 499 476 500 477 void rt2x00queue_init_tx(struct rt2x00_dev *rt2x00dev) ··· 511 482 if (!rt2x00dev->ops->lib->init_txentry) 512 483 continue; 513 484 514 - for (i = 0; i < queue->limit; i++) 485 + for (i = 0; i < queue->limit; i++) { 486 + queue->entries[i].flags = 0; 487 + 515 488 rt2x00dev->ops->lib->init_txentry(rt2x00dev, 516 489 &queue->entries[i]); 490 + } 517 491 } 518 492 } 519 493
+2
drivers/net/wireless/rt2x00/rt2x00queue.h
··· 199 199 * @ENTRY_TXD_RTS_FRAME: This frame is a RTS frame. 200 200 * @ENTRY_TXD_CTS_FRAME: This frame is a CTS-to-self frame. 201 201 * @ENTRY_TXD_OFDM_RATE: This frame is send out with an OFDM rate. 202 + * @ENTRY_TXD_GENERATE_SEQ: This frame requires sequence counter. 202 203 * @ENTRY_TXD_FIRST_FRAGMENT: This is the first frame. 203 204 * @ENTRY_TXD_MORE_FRAG: This frame is followed by another fragment. 204 205 * @ENTRY_TXD_REQ_TIMESTAMP: Require timestamp to be inserted. ··· 211 210 ENTRY_TXD_RTS_FRAME, 212 211 ENTRY_TXD_CTS_FRAME, 213 212 ENTRY_TXD_OFDM_RATE, 213 + ENTRY_TXD_GENERATE_SEQ, 214 214 ENTRY_TXD_FIRST_FRAGMENT, 215 215 ENTRY_TXD_MORE_FRAG, 216 216 ENTRY_TXD_REQ_TIMESTAMP,
+32
drivers/net/wireless/rt2x00/rt2x00usb.c
··· 122 122 } 123 123 EXPORT_SYMBOL_GPL(rt2x00usb_vendor_request_buff); 124 124 125 + int rt2x00usb_vendor_request_large_buff(struct rt2x00_dev *rt2x00dev, 126 + const u8 request, const u8 requesttype, 127 + const u16 offset, void *buffer, 128 + const u16 buffer_length, 129 + const int timeout) 130 + { 131 + int status = 0; 132 + unsigned char *tb; 133 + u16 off, len, bsize; 134 + 135 + mutex_lock(&rt2x00dev->usb_cache_mutex); 136 + 137 + tb = buffer; 138 + off = offset; 139 + len = buffer_length; 140 + while (len && !status) { 141 + bsize = min_t(u16, CSR_CACHE_SIZE, len); 142 + status = rt2x00usb_vendor_req_buff_lock(rt2x00dev, request, 143 + requesttype, off, tb, 144 + bsize, timeout); 145 + 146 + tb += bsize; 147 + len -= bsize; 148 + off += bsize; 149 + } 150 + 151 + mutex_unlock(&rt2x00dev->usb_cache_mutex); 152 + 153 + return status; 154 + } 155 + EXPORT_SYMBOL_GPL(rt2x00usb_vendor_request_large_buff); 156 + 125 157 /* 126 158 * TX data handlers. 127 159 */
+20 -2
drivers/net/wireless/rt2x00/rt2x00usb.h
··· 70 70 /* 71 71 * Cache size 72 72 */ 73 - #define CSR_CACHE_SIZE 8 74 - #define CSR_CACHE_SIZE_FIRMWARE 64 73 + #define CSR_CACHE_SIZE 64 75 74 76 75 /* 77 76 * USB request types. ··· 169 170 const u8 request, const u8 requesttype, 170 171 const u16 offset, void *buffer, 171 172 const u16 buffer_length, const int timeout); 173 + 174 + /** 175 + * rt2x00usb_vendor_request_large_buff - Send register command to device (buffered) 176 + * @rt2x00dev: Pointer to &struct rt2x00_dev 177 + * @request: USB vendor command (See &enum rt2x00usb_vendor_request) 178 + * @requesttype: Request type &USB_VENDOR_REQUEST_* 179 + * @offset: Register start offset to perform action on 180 + * @buffer: Buffer where information will be read/written to by device 181 + * @buffer_length: Size of &buffer 182 + * @timeout: Operation timeout 183 + * 184 + * This function is used to transfer register data in blocks larger 185 + * then CSR_CACHE_SIZE. Use for firmware upload, keys and beacons. 186 + */ 187 + int rt2x00usb_vendor_request_large_buff(struct rt2x00_dev *rt2x00dev, 188 + const u8 request, const u8 requesttype, 189 + const u16 offset, void *buffer, 190 + const u16 buffer_length, 191 + const int timeout); 172 192 173 193 /** 174 194 * rt2x00usb_vendor_request_sw - Send single register command to device
+2 -2
drivers/net/wireless/rt2x00/rt61pci.c
··· 1544 1544 rt2x00_set_field32(&word, TXD_W1_CWMIN, txdesc->cw_min); 1545 1545 rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max); 1546 1546 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, IEEE80211_HEADER); 1547 - rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1); 1547 + rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1548 + test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags)); 1548 1549 rt2x00_set_field32(&word, TXD_W1_BUFFER_COUNT, 1); 1549 1550 rt2x00_desc_write(txd, 1, word); 1550 1551 ··· 2279 2278 * Initialize all hw fields. 2280 2279 */ 2281 2280 rt2x00dev->hw->flags = 2282 - IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 2283 2281 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 2284 2282 IEEE80211_HW_SIGNAL_DBM; 2285 2283 rt2x00dev->hw->extra_tx_headroom = 0;
+23 -33
drivers/net/wireless/rt2x00/rt73usb.c
··· 890 890 unsigned int i; 891 891 int status; 892 892 u32 reg; 893 - const char *ptr = data; 894 - char *cache; 895 - int buflen; 896 893 897 894 /* 898 895 * Wait for stable hardware. ··· 908 911 909 912 /* 910 913 * Write firmware to device. 911 - * We setup a seperate cache for this action, 912 - * since we are going to write larger chunks of data 913 - * then normally used cache size. 914 914 */ 915 - cache = kmalloc(CSR_CACHE_SIZE_FIRMWARE, GFP_KERNEL); 916 - if (!cache) { 917 - ERROR(rt2x00dev, "Failed to allocate firmware cache.\n"); 918 - return -ENOMEM; 919 - } 920 - 921 - for (i = 0; i < len; i += CSR_CACHE_SIZE_FIRMWARE) { 922 - buflen = min_t(int, len - i, CSR_CACHE_SIZE_FIRMWARE); 923 - 924 - memcpy(cache, ptr, buflen); 925 - 926 - rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE, 927 - USB_VENDOR_REQUEST_OUT, 928 - FIRMWARE_IMAGE_BASE + i, 0, 929 - cache, buflen, 930 - REGISTER_TIMEOUT32(buflen)); 931 - 932 - ptr += buflen; 933 - } 934 - 935 - kfree(cache); 915 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE, 916 + USB_VENDOR_REQUEST_OUT, 917 + FIRMWARE_IMAGE_BASE, 918 + data, len, 919 + REGISTER_TIMEOUT32(len)); 936 920 937 921 /* 938 922 * Send firmware request to device to load firmware, ··· 1281 1303 rt2x00_set_field32(&word, TXD_W1_CWMIN, txdesc->cw_min); 1282 1304 rt2x00_set_field32(&word, TXD_W1_CWMAX, txdesc->cw_max); 1283 1305 rt2x00_set_field32(&word, TXD_W1_IV_OFFSET, IEEE80211_HEADER); 1284 - rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1); 1306 + rt2x00_set_field32(&word, TXD_W1_HW_SEQUENCE, 1307 + test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags)); 1285 1308 rt2x00_desc_write(txd, 1, word); 1286 1309 1287 1310 rt2x00_desc_read(txd, 2, &word); ··· 1331 1352 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 1332 1353 unsigned int beacon_base; 1333 1354 u32 reg; 1355 + u32 word, len; 1334 1356 1335 1357 /* 1336 1358 * Add the descriptor in front of the skb. ··· 1339 1359 skb_push(entry->skb, entry->queue->desc_size); 1340 1360 memcpy(entry->skb->data, skbdesc->desc, skbdesc->desc_len); 1341 1361 skbdesc->desc = entry->skb->data; 1362 + 1363 + /* 1364 + * Adjust the beacon databyte count. The current number is 1365 + * calculated before this function gets called, but falsely 1366 + * assumes that the descriptor was already present in the SKB. 1367 + */ 1368 + rt2x00_desc_read(skbdesc->desc, 0, &word); 1369 + len = rt2x00_get_field32(word, TXD_W0_DATABYTE_COUNT); 1370 + len += skbdesc->desc_len; 1371 + rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, len); 1372 + rt2x00_desc_write(skbdesc->desc, 0, word); 1342 1373 1343 1374 /* 1344 1375 * Disable beaconing while we are reloading the beacon data, ··· 1365 1374 * Write entire beacon with descriptor to register. 1366 1375 */ 1367 1376 beacon_base = HW_BEACON_OFFSET(entry->entry_idx); 1368 - rt2x00usb_vendor_request(rt2x00dev, USB_MULTI_WRITE, 1369 - USB_VENDOR_REQUEST_OUT, beacon_base, 0, 1370 - entry->skb->data, entry->skb->len, 1371 - REGISTER_TIMEOUT32(entry->skb->len)); 1377 + rt2x00usb_vendor_request_large_buff(rt2x00dev, USB_MULTI_WRITE, 1378 + USB_VENDOR_REQUEST_OUT, beacon_base, 1379 + entry->skb->data, entry->skb->len, 1380 + REGISTER_TIMEOUT32(entry->skb->len)); 1372 1381 1373 1382 /* 1374 1383 * Clean up the beacon skb. ··· 1862 1871 * Initialize all hw fields. 1863 1872 */ 1864 1873 rt2x00dev->hw->flags = 1865 - IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 1866 1874 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 1867 1875 IEEE80211_HW_SIGNAL_DBM; 1868 1876 rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;
+7 -4
drivers/net/wireless/rtl8187.h
··· 47 47 struct rtl8187b_rx_hdr { 48 48 __le32 flags; 49 49 __le64 mac_time; 50 - u8 noise; 51 - u8 signal; 50 + u8 sq; 51 + u8 rssi; 52 52 u8 agc; 53 - u8 reserved; 54 - __le32 unused; 53 + u8 flags2; 54 + __le16 snr_long2end; 55 + s8 pwdb_g12; 56 + u8 fot; 55 57 } __attribute__((packed)); 56 58 57 59 /* {rtl8187,rtl8187b}_tx_info is in skb */ ··· 102 100 struct usb_device *udev; 103 101 u32 rx_conf; 104 102 u16 txpwr_base; 103 + u16 seqno; 105 104 u8 asic_rev; 106 105 u8 is_rtl8187b; 107 106 enum {
+63 -30
drivers/net/wireless/rtl8187_dev.c
··· 169 169 { 170 170 struct rtl8187_priv *priv = dev->priv; 171 171 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 172 + struct ieee80211_hdr *ieee80211hdr = (struct ieee80211_hdr *)skb->data; 172 173 unsigned int ep; 173 174 void *buf; 174 175 struct urb *urb; ··· 235 234 ep = epmap[skb_get_queue_mapping(skb)]; 236 235 } 237 236 237 + /* FIXME: The sequence that follows is needed for this driver to 238 + * work with mac80211 since "mac80211: fix TX sequence numbers". 239 + * As with the temporary code in rt2x00, changes will be needed 240 + * to get proper sequence numbers on beacons. In addition, this 241 + * patch places the sequence number in the hardware state, which 242 + * limits us to a single virtual state. 243 + */ 244 + if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) { 245 + if (info->flags & IEEE80211_TX_CTL_FIRST_FRAGMENT) 246 + priv->seqno += 0x10; 247 + ieee80211hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); 248 + ieee80211hdr->seq_ctrl |= cpu_to_le16(priv->seqno); 249 + } 250 + 238 251 info->driver_data[0] = dev; 239 252 info->driver_data[1] = urb; 240 253 ··· 272 257 struct ieee80211_rx_status rx_status = { 0 }; 273 258 int rate, signal; 274 259 u32 flags; 260 + u32 quality; 275 261 276 262 spin_lock(&priv->rx_queue.lock); 277 263 if (skb->next) ··· 296 280 flags = le32_to_cpu(hdr->flags); 297 281 signal = hdr->signal & 0x7f; 298 282 rx_status.antenna = (hdr->signal >> 7) & 1; 299 - rx_status.signal = signal; 300 283 rx_status.noise = hdr->noise; 301 284 rx_status.mactime = le64_to_cpu(hdr->mac_time); 302 - priv->signal = signal; 303 285 priv->quality = signal; 286 + rx_status.qual = priv->quality; 304 287 priv->noise = hdr->noise; 288 + rate = (flags >> 20) & 0xF; 289 + if (rate > 3) { /* OFDM rate */ 290 + if (signal > 90) 291 + signal = 90; 292 + else if (signal < 25) 293 + signal = 25; 294 + signal = 90 - signal; 295 + } else { /* CCK rate */ 296 + if (signal > 95) 297 + signal = 95; 298 + else if (signal < 30) 299 + signal = 30; 300 + signal = 95 - signal; 301 + } 302 + rx_status.signal = signal; 303 + priv->signal = signal; 305 304 } else { 306 305 struct rtl8187b_rx_hdr *hdr = 307 306 (typeof(hdr))(skb_tail_pointer(skb) - sizeof(*hdr)); 307 + /* The Realtek datasheet for the RTL8187B shows that the RX 308 + * header contains the following quantities: signal quality, 309 + * RSSI, AGC, the received power in dB, and the measured SNR. 310 + * In testing, none of these quantities show qualitative 311 + * agreement with AP signal strength, except for the AGC, 312 + * which is inversely proportional to the strength of the 313 + * signal. In the following, the quality and signal strength 314 + * are derived from the AGC. The arbitrary scaling constants 315 + * are chosen to make the results close to the values obtained 316 + * for a BCM4312 using b43 as the driver. The noise is ignored 317 + * for now. 318 + */ 308 319 flags = le32_to_cpu(hdr->flags); 309 - signal = hdr->agc >> 1; 310 - rx_status.antenna = (hdr->signal >> 7) & 1; 311 - rx_status.signal = 64 - min(hdr->noise, (u8)64); 312 - rx_status.noise = hdr->noise; 320 + quality = 170 - hdr->agc; 321 + if (quality > 100) 322 + quality = 100; 323 + signal = 14 - hdr->agc / 2; 324 + rx_status.qual = quality; 325 + priv->quality = quality; 326 + rx_status.signal = signal; 327 + priv->signal = signal; 328 + rx_status.antenna = (hdr->rssi >> 7) & 1; 313 329 rx_status.mactime = le64_to_cpu(hdr->mac_time); 314 - priv->signal = hdr->signal; 315 - priv->quality = hdr->agc >> 1; 316 - priv->noise = hdr->noise; 330 + rate = (flags >> 20) & 0xF; 317 331 } 318 332 319 333 skb_trim(skb, flags & 0x0FFF); 320 - rate = (flags >> 20) & 0xF; 321 - if (rate > 3) { /* OFDM rate */ 322 - if (signal > 90) 323 - signal = 90; 324 - else if (signal < 25) 325 - signal = 25; 326 - signal = 90 - signal; 327 - } else { /* CCK rate */ 328 - if (signal > 95) 329 - signal = 95; 330 - else if (signal < 30) 331 - signal = 30; 332 - signal = 95 - signal; 333 - } 334 - 335 - rx_status.qual = priv->quality; 336 - rx_status.signal = signal; 337 334 rx_status.rate_idx = rate; 338 335 rx_status.freq = dev->conf.channel->center_freq; 339 336 rx_status.band = dev->conf.channel->band; ··· 1044 1015 1045 1016 priv->mode = IEEE80211_IF_TYPE_MNTR; 1046 1017 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 1047 - IEEE80211_HW_RX_INCLUDES_FCS | 1048 - IEEE80211_HW_SIGNAL_UNSPEC; 1049 - dev->max_signal = 65; 1018 + IEEE80211_HW_RX_INCLUDES_FCS; 1050 1019 1051 1020 eeprom.data = dev; 1052 1021 eeprom.register_read = rtl8187_eeprom_register_read; ··· 1159 1132 (*channel++).hw_value = txpwr >> 8; 1160 1133 } 1161 1134 1162 - if (priv->is_rtl8187b) 1135 + if (priv->is_rtl8187b) { 1163 1136 printk(KERN_WARNING "rtl8187: 8187B chip detected. Support " 1164 1137 "is EXPERIMENTAL, and could damage your\n" 1165 1138 " hardware, use at your own risk\n"); 1139 + dev->flags |= IEEE80211_HW_SIGNAL_DBM; 1140 + } else { 1141 + dev->flags |= IEEE80211_HW_SIGNAL_UNSPEC; 1142 + dev->max_signal = 65; 1143 + } 1144 + 1166 1145 if ((id->driver_info == DEVICE_RTL8187) && priv->is_rtl8187b) 1167 1146 printk(KERN_INFO "rtl8187: inconsistency between id with OEM" 1168 1147 " info!\n");
-1
drivers/net/wireless/zd1211rw/zd_mac.c
··· 935 935 hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &mac->band; 936 936 937 937 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 938 - IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE | 939 938 IEEE80211_HW_SIGNAL_DB; 940 939 941 940 hw->max_signal = 100;
+5 -3
include/linux/rfkill.h
··· 68 68 * @user_claim_unsupported: Whether the hardware supports exclusive 69 69 * RF-kill control by userspace. Set this before registering. 70 70 * @user_claim: Set when the switch is controlled exlusively by userspace. 71 - * @mutex: Guards switch state transitions 71 + * @mutex: Guards switch state transitions. It serializes callbacks 72 + * and also protects the state. 72 73 * @data: Pointer to the RF button drivers private data which will be 73 74 * passed along when toggling radio state. 74 75 * @toggle_radio(): Mandatory handler to control state of the radio. ··· 90 89 const char *name; 91 90 enum rfkill_type type; 92 91 93 - enum rfkill_state state; 94 92 bool user_claim_unsupported; 95 93 bool user_claim; 96 94 95 + /* the mutex serializes callbacks and also protects 96 + * the state */ 97 97 struct mutex mutex; 98 - 98 + enum rfkill_state state; 99 99 void *data; 100 100 int (*toggle_radio)(void *data, enum rfkill_state state); 101 101 int (*get_state)(void *data, enum rfkill_state *state);
+4 -1
include/linux/skbuff.h
··· 316 316 #ifdef CONFIG_IPV6_NDISC_NODETYPE 317 317 __u8 ndisc_nodetype:2; 318 318 #endif 319 - /* 14 bit hole */ 319 + #if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE) 320 + __u8 do_not_encrypt:1; 321 + #endif 322 + /* 0/13/14 bit hole */ 320 323 321 324 #ifdef CONFIG_NET_DMA 322 325 dma_cookie_t dma_cookie;
-7
include/net/mac80211.h
··· 206 206 * These flags are used with the @flags member of &ieee80211_tx_info. 207 207 * 208 208 * @IEEE80211_TX_CTL_REQ_TX_STATUS: request TX status callback for this frame. 209 - * @IEEE80211_TX_CTL_DO_NOT_ENCRYPT: send this frame without encryption; 210 - * e.g., for EAPOL frame 211 209 * @IEEE80211_TX_CTL_USE_RTS_CTS: use RTS-CTS before sending frame 212 210 * @IEEE80211_TX_CTL_USE_CTS_PROTECT: use CTS protection for the frame (e.g., 213 211 * for combined 802.11g / 802.11b networks) ··· 218 220 * @IEEE80211_TX_CTL_SHORT_PREAMBLE: TBD 219 221 * @IEEE80211_TX_CTL_LONG_RETRY_LIMIT: this frame should be send using the 220 222 * through set_retry_limit configured long retry value 221 - * @IEEE80211_TX_CTL_EAPOL_FRAME: internal to mac80211 222 223 * @IEEE80211_TX_CTL_SEND_AFTER_DTIM: send this frame after DTIM beacon 223 224 * @IEEE80211_TX_CTL_AMPDU: this frame should be sent as part of an A-MPDU 224 225 * @IEEE80211_TX_CTL_OFDM_HT: this frame can be sent in HT OFDM rates. number ··· 250 253 */ 251 254 enum mac80211_tx_control_flags { 252 255 IEEE80211_TX_CTL_REQ_TX_STATUS = BIT(0), 253 - IEEE80211_TX_CTL_DO_NOT_ENCRYPT = BIT(1), 254 256 IEEE80211_TX_CTL_USE_RTS_CTS = BIT(2), 255 257 IEEE80211_TX_CTL_USE_CTS_PROTECT = BIT(3), 256 258 IEEE80211_TX_CTL_NO_ACK = BIT(4), ··· 259 263 IEEE80211_TX_CTL_FIRST_FRAGMENT = BIT(8), 260 264 IEEE80211_TX_CTL_SHORT_PREAMBLE = BIT(9), 261 265 IEEE80211_TX_CTL_LONG_RETRY_LIMIT = BIT(10), 262 - IEEE80211_TX_CTL_EAPOL_FRAME = BIT(11), 263 266 IEEE80211_TX_CTL_SEND_AFTER_DTIM = BIT(12), 264 267 IEEE80211_TX_CTL_AMPDU = BIT(13), 265 268 IEEE80211_TX_CTL_OFDM_HT = BIT(14), ··· 318 323 struct ieee80211_vif *vif; 319 324 struct ieee80211_key_conf *hw_key; 320 325 unsigned long jiffies; 321 - int ifindex; 322 326 u16 aid; 323 327 s8 rts_cts_rate_idx, alt_retry_rate_idx; 324 328 u8 retry_limit; ··· 740 746 * Measurement, Channel Switch, Quieting, TPC 741 747 */ 742 748 enum ieee80211_hw_flags { 743 - IEEE80211_HW_HOST_GEN_BEACON_TEMPLATE = 1<<0, 744 749 IEEE80211_HW_RX_INCLUDES_FCS = 1<<1, 745 750 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING = 1<<2, 746 751 IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE = 1<<3,
+3
net/core/skbuff.c
··· 485 485 C(head); 486 486 C(data); 487 487 C(truesize); 488 + #if defined(CONFIG_MAC80211) || defined(CONFIG_MAC80211_MODULE) 489 + C(do_not_encrypt); 490 + #endif 488 491 atomic_set(&n->users, 1); 489 492 490 493 atomic_inc(&(skb_shinfo(skb)->dataref));
+88 -15
net/mac80211/cfg.c
··· 81 81 enum nl80211_iftype type, u32 *flags, 82 82 struct vif_params *params) 83 83 { 84 + struct ieee80211_local *local = wiphy_priv(wiphy); 84 85 struct net_device *dev; 85 86 enum ieee80211_if_types itype; 86 87 struct ieee80211_sub_if_data *sdata; ··· 95 94 itype = nl80211_type_to_mac80211_type(type); 96 95 if (itype == IEEE80211_IF_TYPE_INVALID) 97 96 return -EINVAL; 97 + 98 + if (dev == local->mdev) 99 + return -EOPNOTSUPP; 98 100 99 101 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 100 102 ··· 121 117 u8 key_idx, u8 *mac_addr, 122 118 struct key_params *params) 123 119 { 120 + struct ieee80211_local *local = wiphy_priv(wiphy); 124 121 struct ieee80211_sub_if_data *sdata; 125 122 struct sta_info *sta = NULL; 126 123 enum ieee80211_key_alg alg; 127 124 struct ieee80211_key *key; 128 125 int err; 126 + 127 + if (dev == local->mdev) 128 + return -EOPNOTSUPP; 129 129 130 130 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 131 131 ··· 175 167 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev, 176 168 u8 key_idx, u8 *mac_addr) 177 169 { 170 + struct ieee80211_local *local = wiphy_priv(wiphy); 178 171 struct ieee80211_sub_if_data *sdata; 179 172 struct sta_info *sta; 180 173 int ret; 174 + 175 + if (dev == local->mdev) 176 + return -EOPNOTSUPP; 181 177 182 178 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 183 179 ··· 223 211 void (*callback)(void *cookie, 224 212 struct key_params *params)) 225 213 { 226 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 214 + struct ieee80211_local *local = wiphy_priv(wiphy); 215 + struct ieee80211_sub_if_data *sdata; 227 216 struct sta_info *sta = NULL; 228 217 u8 seq[6] = {0}; 229 218 struct key_params params; ··· 232 219 u32 iv32; 233 220 u16 iv16; 234 221 int err = -ENOENT; 222 + 223 + if (dev == local->mdev) 224 + return -EOPNOTSUPP; 225 + 226 + sdata = IEEE80211_DEV_TO_SUB_IF(dev); 235 227 236 228 rcu_read_lock(); 237 229 ··· 311 293 struct net_device *dev, 312 294 u8 key_idx) 313 295 { 296 + struct ieee80211_local *local = wiphy_priv(wiphy); 314 297 struct ieee80211_sub_if_data *sdata; 298 + 299 + if (dev == local->mdev) 300 + return -EOPNOTSUPP; 315 301 316 302 rcu_read_lock(); 317 303 ··· 497 475 static int ieee80211_add_beacon(struct wiphy *wiphy, struct net_device *dev, 498 476 struct beacon_parameters *params) 499 477 { 500 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 478 + struct ieee80211_local *local = wiphy_priv(wiphy); 479 + struct ieee80211_sub_if_data *sdata; 501 480 struct beacon_data *old; 481 + 482 + if (dev == local->mdev) 483 + return -EOPNOTSUPP; 484 + 485 + sdata = IEEE80211_DEV_TO_SUB_IF(dev); 502 486 503 487 if (sdata->vif.type != IEEE80211_IF_TYPE_AP) 504 488 return -EINVAL; ··· 520 492 static int ieee80211_set_beacon(struct wiphy *wiphy, struct net_device *dev, 521 493 struct beacon_parameters *params) 522 494 { 523 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 495 + struct ieee80211_local *local = wiphy_priv(wiphy); 496 + struct ieee80211_sub_if_data *sdata; 524 497 struct beacon_data *old; 498 + 499 + if (dev == local->mdev) 500 + return -EOPNOTSUPP; 501 + 502 + sdata = IEEE80211_DEV_TO_SUB_IF(dev); 525 503 526 504 if (sdata->vif.type != IEEE80211_IF_TYPE_AP) 527 505 return -EINVAL; ··· 542 508 543 509 static int ieee80211_del_beacon(struct wiphy *wiphy, struct net_device *dev) 544 510 { 545 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 511 + struct ieee80211_local *local = wiphy_priv(wiphy); 512 + struct ieee80211_sub_if_data *sdata; 546 513 struct beacon_data *old; 514 + 515 + if (dev == local->mdev) 516 + return -EOPNOTSUPP; 517 + 518 + sdata = IEEE80211_DEV_TO_SUB_IF(dev); 547 519 548 520 if (sdata->vif.type != IEEE80211_IF_TYPE_AP) 549 521 return -EINVAL; ··· 686 646 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev, 687 647 u8 *mac, struct station_parameters *params) 688 648 { 689 - struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 649 + struct ieee80211_local *local = wiphy_priv(wiphy); 690 650 struct sta_info *sta; 691 651 struct ieee80211_sub_if_data *sdata; 692 652 int err; 653 + 654 + if (dev == local->mdev || params->vlan == local->mdev) 655 + return -EOPNOTSUPP; 693 656 694 657 /* Prevent a race with changing the rate control algorithm */ 695 658 if (!netif_running(dev)) ··· 744 701 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev, 745 702 u8 *mac) 746 703 { 747 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 748 - struct ieee80211_local *local = sdata->local; 704 + struct ieee80211_local *local = wiphy_priv(wiphy); 705 + struct ieee80211_sub_if_data *sdata; 749 706 struct sta_info *sta; 707 + 708 + if (dev == local->mdev) 709 + return -EOPNOTSUPP; 710 + 711 + sdata = IEEE80211_DEV_TO_SUB_IF(dev); 750 712 751 713 if (mac) { 752 714 rcu_read_lock(); ··· 778 730 u8 *mac, 779 731 struct station_parameters *params) 780 732 { 781 - struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 733 + struct ieee80211_local *local = wiphy_priv(wiphy); 782 734 struct sta_info *sta; 783 735 struct ieee80211_sub_if_data *vlansdata; 736 + 737 + if (dev == local->mdev || params->vlan == local->mdev) 738 + return -EOPNOTSUPP; 784 739 785 740 rcu_read_lock(); 786 741 ··· 803 752 return -EINVAL; 804 753 } 805 754 806 - sta->sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan); 755 + sta->sdata = vlansdata; 807 756 ieee80211_send_layer2_update(sta); 808 757 } 809 758 ··· 818 767 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev, 819 768 u8 *dst, u8 *next_hop) 820 769 { 821 - struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 822 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 770 + struct ieee80211_local *local = wiphy_priv(wiphy); 771 + struct ieee80211_sub_if_data *sdata; 823 772 struct mesh_path *mpath; 824 773 struct sta_info *sta; 825 774 int err; 826 775 776 + if (dev == local->mdev) 777 + return -EOPNOTSUPP; 778 + 827 779 if (!netif_running(dev)) 828 780 return -ENETDOWN; 781 + 782 + sdata = IEEE80211_DEV_TO_SUB_IF(dev); 829 783 830 784 if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) 831 785 return -ENOTSUPP; ··· 873 817 struct net_device *dev, 874 818 u8 *dst, u8 *next_hop) 875 819 { 876 - struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 877 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 820 + struct ieee80211_local *local = wiphy_priv(wiphy); 821 + struct ieee80211_sub_if_data *sdata; 878 822 struct mesh_path *mpath; 879 823 struct sta_info *sta; 880 824 825 + if (dev == local->mdev) 826 + return -EOPNOTSUPP; 827 + 881 828 if (!netif_running(dev)) 882 829 return -ENETDOWN; 830 + 831 + sdata = IEEE80211_DEV_TO_SUB_IF(dev); 883 832 884 833 if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) 885 834 return -ENOTSUPP; ··· 952 891 u8 *dst, u8 *next_hop, struct mpath_info *pinfo) 953 892 954 893 { 955 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 894 + struct ieee80211_local *local = wiphy_priv(wiphy); 895 + struct ieee80211_sub_if_data *sdata; 956 896 struct mesh_path *mpath; 897 + 898 + if (dev == local->mdev) 899 + return -EOPNOTSUPP; 900 + 901 + sdata = IEEE80211_DEV_TO_SUB_IF(dev); 957 902 958 903 if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) 959 904 return -ENOTSUPP; ··· 980 913 int idx, u8 *dst, u8 *next_hop, 981 914 struct mpath_info *pinfo) 982 915 { 983 - struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 916 + struct ieee80211_local *local = wiphy_priv(wiphy); 917 + struct ieee80211_sub_if_data *sdata; 984 918 struct mesh_path *mpath; 919 + 920 + if (dev == local->mdev) 921 + return -EOPNOTSUPP; 922 + 923 + sdata = IEEE80211_DEV_TO_SUB_IF(dev); 985 924 986 925 if (sdata->vif.type != IEEE80211_IF_TYPE_MESH_POINT) 987 926 return -ENOTSUPP;
+3 -9
net/mac80211/main.c
··· 1233 1233 /* Remove added headers (e.g., QoS control), encryption header/MIC, etc. to 1234 1234 * make a prepared TX frame (one that has been given to hw) to look like brand 1235 1235 * new IEEE 802.11 frame that is ready to go through TX processing again. 1236 - * Also, tx_packet_data in cb is restored from tx_control. */ 1236 + */ 1237 1237 static void ieee80211_remove_tx_extra(struct ieee80211_local *local, 1238 1238 struct ieee80211_key *key, 1239 1239 struct sk_buff *skb) 1240 1240 { 1241 1241 int hdrlen, iv_len, mic_len; 1242 - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1243 - 1244 - info->flags &= IEEE80211_TX_CTL_REQ_TX_STATUS | 1245 - IEEE80211_TX_CTL_DO_NOT_ENCRYPT | 1246 - IEEE80211_TX_CTL_REQUEUE | 1247 - IEEE80211_TX_CTL_EAPOL_FRAME; 1248 1242 1249 1243 hdrlen = ieee80211_get_hdrlen_from_skb(skb); 1250 1244 ··· 1725 1731 result = ieee80211_wep_init(local); 1726 1732 1727 1733 if (result < 0) { 1728 - printk(KERN_DEBUG "%s: Failed to initialize wep\n", 1729 - wiphy_name(local->hw.wiphy)); 1734 + printk(KERN_DEBUG "%s: Failed to initialize wep: %d\n", 1735 + wiphy_name(local->hw.wiphy), result); 1730 1736 goto fail_wep; 1731 1737 } 1732 1738
+3 -6
net/mac80211/mlme.c
··· 606 606 int encrypt) 607 607 { 608 608 struct ieee80211_sub_if_data *sdata; 609 - struct ieee80211_tx_info *info; 610 609 611 610 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 612 611 skb->dev = sdata->local->mdev; ··· 613 614 skb_set_network_header(skb, 0); 614 615 skb_set_transport_header(skb, 0); 615 616 616 - info = IEEE80211_SKB_CB(skb); 617 - memset(info, 0, sizeof(struct ieee80211_tx_info)); 618 - info->control.ifindex = sdata->dev->ifindex; 619 - if (!encrypt) 620 - info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; 617 + skb->iif = sdata->dev->ifindex; 618 + skb->do_not_encrypt = !encrypt; 621 619 622 620 dev_queue_xmit(skb); 623 621 } ··· 3299 3303 ifsta = &sdata->u.sta; 3300 3304 ifsta->state = IEEE80211_MESH_UP; 3301 3305 ieee80211_sta_timer((unsigned long)sdata); 3306 + ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON); 3302 3307 } 3303 3308 #endif 3304 3309
+25 -30
net/mac80211/tx.c
··· 305 305 rcu_read_unlock(); 306 306 307 307 local->total_ps_buffered = total; 308 - #ifdef MAC80211_VERBOSE_PS_DEBUG 308 + #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 309 309 printk(KERN_DEBUG "%s: PS buffers full - purged %d frames\n", 310 310 wiphy_name(local->hw.wiphy), purged); 311 311 #endif ··· 342 342 purge_old_ps_buffers(tx->local); 343 343 if (skb_queue_len(&tx->sdata->bss->ps_bc_buf) >= 344 344 AP_MAX_BC_BUFFER) { 345 - #ifdef MAC80211_VERBOSE_PS_DEBUG 345 + #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 346 346 if (net_ratelimit()) { 347 347 printk(KERN_DEBUG "%s: BC TX buffer full - " 348 348 "dropping the oldest frame\n", ··· 389 389 purge_old_ps_buffers(tx->local); 390 390 if (skb_queue_len(&sta->ps_tx_buf) >= STA_MAX_TX_BUFFER) { 391 391 struct sk_buff *old = skb_dequeue(&sta->ps_tx_buf); 392 - #ifdef MAC80211_VERBOSE_PS_DEBUG 392 + #ifdef CONFIG_MAC80211_VERBOSE_PS_DEBUG 393 393 if (net_ratelimit()) { 394 394 printk(KERN_DEBUG "%s: STA %s TX " 395 395 "buffer full - dropping oldest frame\n", ··· 439 439 struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); 440 440 u16 fc = tx->fc; 441 441 442 - if (unlikely(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT)) 442 + if (unlikely(tx->skb->do_not_encrypt)) 443 443 tx->key = NULL; 444 444 else if (tx->sta && (key = rcu_dereference(tx->sta->key))) 445 445 tx->key = key; 446 446 else if ((key = rcu_dereference(tx->sdata->default_key))) 447 447 tx->key = key; 448 448 else if (tx->sdata->drop_unencrypted && 449 - !(info->flags & IEEE80211_TX_CTL_EAPOL_FRAME) && 449 + (tx->skb->protocol != cpu_to_be16(ETH_P_PAE)) && 450 450 !(info->flags & IEEE80211_TX_CTL_INJECTED)) { 451 451 I802_DEBUG_INC(tx->local->tx_handlers_drop_unencrypted); 452 452 return TX_DROP; ··· 476 476 } 477 477 478 478 if (!tx->key || !(tx->key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)) 479 - info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; 479 + tx->skb->do_not_encrypt = 1; 480 480 481 481 return TX_CONTINUE; 482 482 } ··· 732 732 memcpy(skb_put(frag, copylen), pos, copylen); 733 733 memcpy(frag->cb, first->cb, sizeof(frag->cb)); 734 734 skb_copy_queue_mapping(frag, first); 735 + frag->do_not_encrypt = first->do_not_encrypt; 735 736 736 737 pos += copylen; 737 738 left -= copylen; ··· 853 852 854 853 sband = tx->local->hw.wiphy->bands[tx->channel->band]; 855 854 856 - info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; 855 + skb->do_not_encrypt = 1; 857 856 info->flags |= IEEE80211_TX_CTL_INJECTED; 858 857 tx->flags &= ~IEEE80211_TX_FRAGMENTED; 859 858 ··· 926 925 skb_trim(skb, skb->len - FCS_LEN); 927 926 } 928 927 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_WEP) 929 - info->flags &= 930 - ~IEEE80211_TX_CTL_DO_NOT_ENCRYPT; 928 + tx->skb->do_not_encrypt = 0; 931 929 if (*iterator.this_arg & IEEE80211_RADIOTAP_F_FRAG) 932 930 tx->flags |= IEEE80211_TX_FRAGMENTED; 933 931 break; ··· 1042 1042 struct sk_buff *skb, 1043 1043 struct net_device *mdev) 1044 1044 { 1045 - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1046 1045 struct net_device *dev; 1047 1046 1048 - dev = dev_get_by_index(&init_net, info->control.ifindex); 1047 + dev = dev_get_by_index(&init_net, skb->iif); 1049 1048 if (unlikely(dev && !is_ieee80211_device(dev, mdev))) { 1050 1049 dev_put(dev); 1051 1050 dev = NULL; ··· 1305 1306 bool may_encrypt; 1306 1307 int ret; 1307 1308 1308 - if (info->control.ifindex) 1309 - odev = dev_get_by_index(&init_net, info->control.ifindex); 1309 + if (skb->iif) 1310 + odev = dev_get_by_index(&init_net, skb->iif); 1310 1311 if (unlikely(odev && !is_ieee80211_device(odev, dev))) { 1311 1312 dev_put(odev); 1312 1313 odev = NULL; ··· 1320 1321 return 0; 1321 1322 } 1322 1323 1324 + memset(info, 0, sizeof(*info)); 1325 + 1326 + info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; 1327 + 1323 1328 osdata = IEEE80211_DEV_TO_SUB_IF(odev); 1324 1329 1325 - may_encrypt = !(info->flags & IEEE80211_TX_CTL_DO_NOT_ENCRYPT); 1330 + may_encrypt = !skb->do_not_encrypt; 1326 1331 1327 1332 headroom = osdata->local->tx_headroom; 1328 1333 if (may_encrypt) ··· 1351 1348 struct net_device *dev) 1352 1349 { 1353 1350 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1354 - struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1355 1351 struct ieee80211_radiotap_header *prthdr = 1356 1352 (struct ieee80211_radiotap_header *)skb->data; 1357 1353 u16 len_rthdr; ··· 1373 1371 skb->dev = local->mdev; 1374 1372 1375 1373 /* needed because we set skb device to master */ 1376 - info->control.ifindex = dev->ifindex; 1374 + skb->iif = dev->ifindex; 1377 1375 1378 - info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; 1379 - /* Interfaces should always request a status report */ 1380 - info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; 1376 + /* sometimes we do encrypt injected frames, will be fixed 1377 + * up in radiotap parser if not wanted */ 1378 + skb->do_not_encrypt = 0; 1381 1379 1382 1380 /* 1383 1381 * fix up the pointers accounting for the radiotap ··· 1421 1419 struct net_device *dev) 1422 1420 { 1423 1421 struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 1424 - struct ieee80211_tx_info *info; 1425 1422 struct ieee80211_sub_if_data *sdata; 1426 1423 int ret = 1, head_need; 1427 1424 u16 ethertype, hdrlen, meshhdrlen = 0; ··· 1646 1645 nh_pos += hdrlen; 1647 1646 h_pos += hdrlen; 1648 1647 1649 - info = IEEE80211_SKB_CB(skb); 1650 - memset(info, 0, sizeof(*info)); 1651 - info->control.ifindex = dev->ifindex; 1652 - if (ethertype == ETH_P_PAE) 1653 - info->flags |= IEEE80211_TX_CTL_EAPOL_FRAME; 1654 - 1655 - /* Interfaces should always request a status report */ 1656 - info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS; 1648 + skb->iif = dev->ifindex; 1657 1649 1658 1650 skb->dev = local->mdev; 1659 1651 dev->stats.tx_packets++; ··· 1916 1922 1917 1923 info = IEEE80211_SKB_CB(skb); 1918 1924 1925 + skb->do_not_encrypt = 1; 1926 + 1919 1927 info->band = band; 1920 1928 rate_control_get_rate(local->mdev, sband, skb, &rsel); 1921 1929 ··· 1927 1931 "no rate found\n", 1928 1932 wiphy_name(local->hw.wiphy)); 1929 1933 } 1930 - dev_kfree_skb(skb); 1934 + dev_kfree_skb_any(skb); 1931 1935 skb = NULL; 1932 1936 goto out; 1933 1937 } ··· 1936 1940 info->tx_rate_idx = rsel.rate_idx; 1937 1941 1938 1942 info->flags |= IEEE80211_TX_CTL_NO_ACK; 1939 - info->flags |= IEEE80211_TX_CTL_DO_NOT_ENCRYPT; 1940 1943 info->flags |= IEEE80211_TX_CTL_CLEAR_PS_FILT; 1941 1944 info->flags |= IEEE80211_TX_CTL_ASSIGN_SEQ; 1942 1945 if (sdata->bss_conf.use_short_preamble &&
+2 -2
net/mac80211/wep.c
··· 31 31 local->wep_tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, 32 32 CRYPTO_ALG_ASYNC); 33 33 if (IS_ERR(local->wep_tx_tfm)) 34 - return -ENOMEM; 34 + return PTR_ERR(local->wep_tx_tfm); 35 35 36 36 local->wep_rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, 37 37 CRYPTO_ALG_ASYNC); 38 38 if (IS_ERR(local->wep_rx_tfm)) { 39 39 crypto_free_blkcipher(local->wep_tx_tfm); 40 - return -ENOMEM; 40 + return PTR_ERR(local->wep_rx_tfm); 41 41 } 42 42 43 43 return 0;
+3
net/mac80211/wme.c
··· 188 188 { 189 189 int i; 190 190 191 + /* XXX: currently broken due to cb/requeue use */ 192 + return -EPERM; 193 + 191 194 /* prepare the filter and save it for the SW queue 192 195 * matching the received HW queue */ 193 196
+39 -23
net/rfkill/rfkill.c
··· 130 130 131 131 /** 132 132 * rfkill_toggle_radio - wrapper for toggle_radio hook 133 - * 134 133 * @rfkill: the rfkill struct to use 135 134 * @force: calls toggle_radio even if cache says it is not needed, 136 135 * and also makes sure notifications of the state will be ··· 140 141 * calls and handling all the red tape such as issuing notifications 141 142 * if the call is successful. 142 143 * 143 - * Note that @force cannot override a (possibly cached) state of 144 - * RFKILL_STATE_HARD_BLOCKED. Any device making use of 144 + * Note that the @force parameter cannot override a (possibly cached) 145 + * state of RFKILL_STATE_HARD_BLOCKED. Any device making use of 145 146 * RFKILL_STATE_HARD_BLOCKED implements either get_state() or 146 147 * rfkill_force_state(), so the cache either is bypassed or valid. 147 148 * ··· 149 150 * even if the radio is in RFKILL_STATE_HARD_BLOCKED state, so as to 150 151 * give the driver a hint that it should double-BLOCK the transmitter. 151 152 * 152 - * Caller must have aquired rfkill_mutex. 153 + * Caller must have acquired rfkill->mutex. 153 154 */ 154 155 static int rfkill_toggle_radio(struct rfkill *rfkill, 155 156 enum rfkill_state state, ··· 199 200 200 201 /** 201 202 * rfkill_switch_all - Toggle state of all switches of given type 202 - * @type: type of interfaces to be affeceted 203 + * @type: type of interfaces to be affected 203 204 * @state: the new state 204 205 * 205 - * This function toggles state of all switches of given type unless 206 - * a specific switch is claimed by userspace in which case it is 207 - * left alone. 206 + * This function toggles the state of all switches of given type, 207 + * unless a specific switch is claimed by userspace (in which case, 208 + * that switch is left alone). 208 209 */ 209 210 void rfkill_switch_all(enum rfkill_type type, enum rfkill_state state) 210 211 { ··· 215 216 rfkill_states[type] = state; 216 217 217 218 list_for_each_entry(rfkill, &rfkill_list, node) { 218 - if ((!rfkill->user_claim) && (rfkill->type == type)) 219 + if ((!rfkill->user_claim) && (rfkill->type == type)) { 220 + mutex_lock(&rfkill->mutex); 219 221 rfkill_toggle_radio(rfkill, state, 0); 222 + mutex_unlock(&rfkill->mutex); 223 + } 220 224 } 221 225 222 226 mutex_unlock(&rfkill_mutex); ··· 230 228 * rfkill_epo - emergency power off all transmitters 231 229 * 232 230 * This kicks all rfkill devices to RFKILL_STATE_SOFT_BLOCKED, ignoring 233 - * everything in its path but rfkill_mutex. 231 + * everything in its path but rfkill_mutex and rfkill->mutex. 234 232 */ 235 233 void rfkill_epo(void) 236 234 { ··· 238 236 239 237 mutex_lock(&rfkill_mutex); 240 238 list_for_each_entry(rfkill, &rfkill_list, node) { 239 + mutex_lock(&rfkill->mutex); 241 240 rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); 241 + mutex_unlock(&rfkill->mutex); 242 242 } 243 243 mutex_unlock(&rfkill_mutex); 244 244 } ··· 256 252 * a notification by the firmware/hardware of the current *real* 257 253 * state of the radio rfkill switch. 258 254 * 259 - * It may not be called from an atomic context. 255 + * Devices which are subject to external changes on their rfkill 256 + * state (such as those caused by a hardware rfkill line) MUST 257 + * have their driver arrange to call rfkill_force_state() as soon 258 + * as possible after such a change. 259 + * 260 + * This function may not be called from an atomic context. 260 261 */ 261 262 int rfkill_force_state(struct rfkill *rfkill, enum rfkill_state state) 262 263 { ··· 376 367 if (!capable(CAP_NET_ADMIN)) 377 368 return -EPERM; 378 369 370 + if (rfkill->user_claim_unsupported) 371 + return -EOPNOTSUPP; 372 + 379 373 /* 380 374 * Take the global lock to make sure the kernel is not in 381 375 * the middle of rfkill_switch_all ··· 387 375 if (error) 388 376 return error; 389 377 390 - if (rfkill->user_claim_unsupported) { 391 - error = -EOPNOTSUPP; 392 - goto out_unlock; 393 - } 394 378 if (rfkill->user_claim != claim) { 395 - if (!claim) 379 + if (!claim) { 380 + mutex_lock(&rfkill->mutex); 396 381 rfkill_toggle_radio(rfkill, 397 382 rfkill_states[rfkill->type], 398 383 0); 384 + mutex_unlock(&rfkill->mutex); 385 + } 399 386 rfkill->user_claim = claim; 400 387 } 401 388 402 - out_unlock: 403 389 mutex_unlock(&rfkill_mutex); 404 390 405 391 return error ? error : count; ··· 526 516 { 527 517 mutex_lock(&rfkill_mutex); 528 518 list_del_init(&rfkill->node); 529 - rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); 530 519 mutex_unlock(&rfkill_mutex); 520 + 521 + mutex_lock(&rfkill->mutex); 522 + rfkill_toggle_radio(rfkill, RFKILL_STATE_SOFT_BLOCKED, 1); 523 + mutex_unlock(&rfkill->mutex); 531 524 } 532 525 533 526 /** ··· 539 526 * @type: type of the switch (RFKILL_TYPE_*) 540 527 * 541 528 * This function should be called by the network driver when it needs 542 - * rfkill structure. Once the structure is allocated the driver shoud 543 - * finish its initialization by setting name, private data, enable_radio 529 + * rfkill structure. Once the structure is allocated the driver should 530 + * finish its initialization by setting the name, private data, enable_radio 544 531 * and disable_radio methods and then register it with rfkill_register(). 532 + * 545 533 * NOTE: If registration fails the structure shoudl be freed by calling 546 534 * rfkill_free() otherwise rfkill_unregister() should be used. 547 535 */ ··· 574 560 * rfkill_free - Mark rfkill structure for deletion 575 561 * @rfkill: rfkill structure to be destroyed 576 562 * 577 - * Decrements reference count of rfkill structure so it is destroyed. 563 + * Decrements reference count of the rfkill structure so it is destroyed. 578 564 * Note that rfkill_free() should _not_ be called after rfkill_unregister(). 579 565 */ 580 566 void rfkill_free(struct rfkill *rfkill) ··· 599 585 static void rfkill_led_trigger_unregister(struct rfkill *rfkill) 600 586 { 601 587 #ifdef CONFIG_RFKILL_LEDS 602 - if (rfkill->led_trigger.name) 588 + if (rfkill->led_trigger.name) { 603 589 led_trigger_unregister(&rfkill->led_trigger); 590 + rfkill->led_trigger.name = NULL; 591 + } 604 592 #endif 605 593 } 606 594 ··· 638 622 639 623 error = device_add(dev); 640 624 if (error) { 641 - rfkill_led_trigger_unregister(rfkill); 642 625 rfkill_remove_switch(rfkill); 626 + rfkill_led_trigger_unregister(rfkill); 643 627 return error; 644 628 } 645 629
+155 -124
net/wireless/nl80211.c
··· 29 29 }; 30 30 31 31 /* internal helper: get drv and dev */ 32 - static int get_drv_dev_by_info_ifindex(struct genl_info *info, 32 + static int get_drv_dev_by_info_ifindex(struct nlattr **attrs, 33 33 struct cfg80211_registered_device **drv, 34 34 struct net_device **dev) 35 35 { 36 36 int ifindex; 37 37 38 - if (!info->attrs[NL80211_ATTR_IFINDEX]) 38 + if (!attrs[NL80211_ATTR_IFINDEX]) 39 39 return -EINVAL; 40 40 41 - ifindex = nla_get_u32(info->attrs[NL80211_ATTR_IFINDEX]); 41 + ifindex = nla_get_u32(attrs[NL80211_ATTR_IFINDEX]); 42 42 *dev = dev_get_by_index(&init_net, ifindex); 43 43 if (!*dev) 44 44 return -ENODEV; ··· 291 291 292 292 mutex_lock(&cfg80211_drv_mutex); 293 293 list_for_each_entry(dev, &cfg80211_drv_list, list) { 294 - if (++wp_idx < wp_start) 294 + if (wp_idx < wp_start) { 295 + wp_idx++; 295 296 continue; 297 + } 296 298 if_idx = 0; 297 299 298 300 mutex_lock(&dev->devlist_mtx); 299 301 list_for_each_entry(wdev, &dev->netdev_list, list) { 300 - if (++if_idx < if_start) 302 + if (if_idx < if_start) { 303 + if_idx++; 301 304 continue; 305 + } 302 306 if (nl80211_send_iface(skb, NETLINK_CB(cb->skb).pid, 303 307 cb->nlh->nlmsg_seq, NLM_F_MULTI, 304 - wdev->netdev) < 0) 305 - break; 308 + wdev->netdev) < 0) { 309 + mutex_unlock(&dev->devlist_mtx); 310 + goto out; 311 + } 312 + if_idx++; 306 313 } 307 314 mutex_unlock(&dev->devlist_mtx); 315 + 316 + wp_idx++; 308 317 } 318 + out: 309 319 mutex_unlock(&cfg80211_drv_mutex); 310 320 311 321 cb->args[0] = wp_idx; ··· 331 321 struct net_device *netdev; 332 322 int err; 333 323 334 - err = get_drv_dev_by_info_ifindex(info, &dev, &netdev); 324 + err = get_drv_dev_by_info_ifindex(info->attrs, &dev, &netdev); 335 325 if (err) 336 326 return err; 337 327 ··· 402 392 } else 403 393 return -EINVAL; 404 394 405 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 395 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 406 396 if (err) 407 397 return err; 408 398 ifindex = dev->ifindex; ··· 487 477 int ifindex, err; 488 478 struct net_device *dev; 489 479 490 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 480 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 491 481 if (err) 492 482 return err; 493 483 ifindex = dev->ifindex; ··· 555 545 if (info->attrs[NL80211_ATTR_MAC]) 556 546 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 557 547 558 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 548 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 559 549 if (err) 560 550 return err; 561 551 ··· 628 618 if (!info->attrs[NL80211_ATTR_KEY_DEFAULT]) 629 619 return -EINVAL; 630 620 631 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 621 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 632 622 if (err) 633 623 return err; 634 624 ··· 709 699 return -EINVAL; 710 700 } 711 701 712 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 702 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 713 703 if (err) 714 704 return err; 715 705 ··· 745 735 if (info->attrs[NL80211_ATTR_MAC]) 746 736 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 747 737 748 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 738 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 749 739 if (err) 750 740 return err; 751 741 ··· 774 764 struct beacon_parameters params; 775 765 int haveinfo = 0; 776 766 777 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 767 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 778 768 if (err) 779 769 return err; 780 770 ··· 853 843 int err; 854 844 struct net_device *dev; 855 845 856 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 846 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 857 847 if (err) 858 848 return err; 859 849 ··· 947 937 } 948 938 949 939 static int nl80211_dump_station(struct sk_buff *skb, 950 - struct netlink_callback *cb) 940 + struct netlink_callback *cb) 951 941 { 952 - int wp_idx = 0; 953 - int if_idx = 0; 954 - int sta_idx = cb->args[2]; 955 - int wp_start = cb->args[0]; 956 - int if_start = cb->args[1]; 957 942 struct station_info sinfo; 958 943 struct cfg80211_registered_device *dev; 959 - struct wireless_dev *wdev; 944 + struct net_device *netdev; 960 945 u8 mac_addr[ETH_ALEN]; 946 + int ifidx = cb->args[0]; 947 + int sta_idx = cb->args[1]; 961 948 int err; 962 - int exit = 0; 963 949 964 - /* TODO: filter by device */ 965 - mutex_lock(&cfg80211_drv_mutex); 966 - list_for_each_entry(dev, &cfg80211_drv_list, list) { 967 - if (exit) 968 - break; 969 - if (++wp_idx < wp_start) 970 - continue; 971 - if_idx = 0; 950 + if (!ifidx) { 951 + err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, 952 + nl80211_fam.attrbuf, nl80211_fam.maxattr, 953 + nl80211_policy); 954 + if (err) 955 + return err; 972 956 973 - mutex_lock(&dev->devlist_mtx); 974 - list_for_each_entry(wdev, &dev->netdev_list, list) { 975 - if (exit) 976 - break; 977 - if (++if_idx < if_start) 978 - continue; 979 - if (!dev->ops->dump_station) 980 - continue; 957 + if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]) 958 + return -EINVAL; 981 959 982 - for (;; ++sta_idx) { 983 - rtnl_lock(); 984 - err = dev->ops->dump_station(&dev->wiphy, 985 - wdev->netdev, sta_idx, mac_addr, 986 - &sinfo); 987 - rtnl_unlock(); 988 - if (err) { 989 - sta_idx = 0; 990 - break; 991 - } 992 - if (nl80211_send_station(skb, 993 - NETLINK_CB(cb->skb).pid, 994 - cb->nlh->nlmsg_seq, NLM_F_MULTI, 995 - wdev->netdev, mac_addr, 996 - &sinfo) < 0) { 997 - exit = 1; 998 - break; 999 - } 1000 - } 1001 - } 1002 - mutex_unlock(&dev->devlist_mtx); 960 + ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]); 961 + if (!ifidx) 962 + return -EINVAL; 1003 963 } 1004 - mutex_unlock(&cfg80211_drv_mutex); 1005 964 1006 - cb->args[0] = wp_idx; 1007 - cb->args[1] = if_idx; 1008 - cb->args[2] = sta_idx; 965 + netdev = dev_get_by_index(&init_net, ifidx); 966 + if (!netdev) 967 + return -ENODEV; 1009 968 1010 - return skb->len; 969 + dev = cfg80211_get_dev_from_ifindex(ifidx); 970 + if (IS_ERR(dev)) { 971 + err = PTR_ERR(dev); 972 + goto out_put_netdev; 973 + } 974 + 975 + if (!dev->ops->dump_station) { 976 + err = -ENOSYS; 977 + goto out_err; 978 + } 979 + 980 + rtnl_lock(); 981 + 982 + while (1) { 983 + err = dev->ops->dump_station(&dev->wiphy, netdev, sta_idx, 984 + mac_addr, &sinfo); 985 + if (err == -ENOENT) 986 + break; 987 + if (err) 988 + goto out_err_rtnl; 989 + 990 + if (nl80211_send_station(skb, 991 + NETLINK_CB(cb->skb).pid, 992 + cb->nlh->nlmsg_seq, NLM_F_MULTI, 993 + netdev, mac_addr, 994 + &sinfo) < 0) 995 + goto out; 996 + 997 + sta_idx++; 998 + } 999 + 1000 + 1001 + out: 1002 + cb->args[1] = sta_idx; 1003 + err = skb->len; 1004 + out_err_rtnl: 1005 + rtnl_unlock(); 1006 + out_err: 1007 + cfg80211_put_dev(dev); 1008 + out_put_netdev: 1009 + dev_put(netdev); 1010 + 1011 + return err; 1011 1012 } 1012 1013 1013 1014 static int nl80211_get_station(struct sk_buff *skb, struct genl_info *info) ··· 1037 1016 1038 1017 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 1039 1018 1040 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 1019 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1041 1020 if (err) 1042 1021 return err; 1043 1022 ··· 1133 1112 params.plink_action = 1134 1113 nla_get_u8(info->attrs[NL80211_ATTR_STA_PLINK_ACTION]); 1135 1114 1136 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 1115 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1137 1116 if (err) 1138 1117 return err; 1139 1118 ··· 1193 1172 &params.station_flags)) 1194 1173 return -EINVAL; 1195 1174 1196 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 1175 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1197 1176 if (err) 1198 1177 return err; 1199 1178 ··· 1228 1207 if (info->attrs[NL80211_ATTR_MAC]) 1229 1208 mac_addr = nla_data(info->attrs[NL80211_ATTR_MAC]); 1230 1209 1231 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 1210 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1232 1211 if (err) 1233 1212 return err; 1234 1213 ··· 1298 1277 } 1299 1278 1300 1279 static int nl80211_dump_mpath(struct sk_buff *skb, 1301 - struct netlink_callback *cb) 1280 + struct netlink_callback *cb) 1302 1281 { 1303 - int wp_idx = 0; 1304 - int if_idx = 0; 1305 - int sta_idx = cb->args[2]; 1306 - int wp_start = cb->args[0]; 1307 - int if_start = cb->args[1]; 1308 1282 struct mpath_info pinfo; 1309 1283 struct cfg80211_registered_device *dev; 1310 - struct wireless_dev *wdev; 1284 + struct net_device *netdev; 1311 1285 u8 dst[ETH_ALEN]; 1312 1286 u8 next_hop[ETH_ALEN]; 1287 + int ifidx = cb->args[0]; 1288 + int path_idx = cb->args[1]; 1313 1289 int err; 1314 - int exit = 0; 1315 1290 1316 - /* TODO: filter by device */ 1317 - mutex_lock(&cfg80211_drv_mutex); 1318 - list_for_each_entry(dev, &cfg80211_drv_list, list) { 1319 - if (exit) 1320 - break; 1321 - if (++wp_idx < wp_start) 1322 - continue; 1323 - if_idx = 0; 1291 + if (!ifidx) { 1292 + err = nlmsg_parse(cb->nlh, GENL_HDRLEN + nl80211_fam.hdrsize, 1293 + nl80211_fam.attrbuf, nl80211_fam.maxattr, 1294 + nl80211_policy); 1295 + if (err) 1296 + return err; 1324 1297 1325 - mutex_lock(&dev->devlist_mtx); 1326 - list_for_each_entry(wdev, &dev->netdev_list, list) { 1327 - if (exit) 1328 - break; 1329 - if (++if_idx < if_start) 1330 - continue; 1331 - if (!dev->ops->dump_mpath) 1332 - continue; 1298 + if (!nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]) 1299 + return -EINVAL; 1333 1300 1334 - for (;; ++sta_idx) { 1335 - rtnl_lock(); 1336 - err = dev->ops->dump_mpath(&dev->wiphy, 1337 - wdev->netdev, sta_idx, dst, 1338 - next_hop, &pinfo); 1339 - rtnl_unlock(); 1340 - if (err) { 1341 - sta_idx = 0; 1342 - break; 1343 - } 1344 - if (nl80211_send_mpath(skb, 1345 - NETLINK_CB(cb->skb).pid, 1346 - cb->nlh->nlmsg_seq, NLM_F_MULTI, 1347 - wdev->netdev, dst, next_hop, 1348 - &pinfo) < 0) { 1349 - exit = 1; 1350 - break; 1351 - } 1352 - } 1353 - } 1354 - mutex_unlock(&dev->devlist_mtx); 1301 + ifidx = nla_get_u32(nl80211_fam.attrbuf[NL80211_ATTR_IFINDEX]); 1302 + if (!ifidx) 1303 + return -EINVAL; 1355 1304 } 1356 - mutex_unlock(&cfg80211_drv_mutex); 1357 1305 1358 - cb->args[0] = wp_idx; 1359 - cb->args[1] = if_idx; 1360 - cb->args[2] = sta_idx; 1306 + netdev = dev_get_by_index(&init_net, ifidx); 1307 + if (!netdev) 1308 + return -ENODEV; 1361 1309 1362 - return skb->len; 1310 + dev = cfg80211_get_dev_from_ifindex(ifidx); 1311 + if (IS_ERR(dev)) { 1312 + err = PTR_ERR(dev); 1313 + goto out_put_netdev; 1314 + } 1315 + 1316 + if (!dev->ops->dump_mpath) { 1317 + err = -ENOSYS; 1318 + goto out_err; 1319 + } 1320 + 1321 + rtnl_lock(); 1322 + 1323 + while (1) { 1324 + err = dev->ops->dump_mpath(&dev->wiphy, netdev, path_idx, 1325 + dst, next_hop, &pinfo); 1326 + if (err == -ENOENT) 1327 + break; 1328 + if (err) 1329 + goto out_err_rtnl; 1330 + 1331 + if (nl80211_send_mpath(skb, NETLINK_CB(cb->skb).pid, 1332 + cb->nlh->nlmsg_seq, NLM_F_MULTI, 1333 + netdev, dst, next_hop, 1334 + &pinfo) < 0) 1335 + goto out; 1336 + 1337 + path_idx++; 1338 + } 1339 + 1340 + 1341 + out: 1342 + cb->args[1] = path_idx; 1343 + err = skb->len; 1344 + out_err_rtnl: 1345 + rtnl_unlock(); 1346 + out_err: 1347 + cfg80211_put_dev(dev); 1348 + out_put_netdev: 1349 + dev_put(netdev); 1350 + 1351 + return err; 1363 1352 } 1364 1353 1365 1354 static int nl80211_get_mpath(struct sk_buff *skb, struct genl_info *info) ··· 1389 1358 1390 1359 dst = nla_data(info->attrs[NL80211_ATTR_MAC]); 1391 1360 1392 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 1361 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1393 1362 if (err) 1394 1363 return err; 1395 1364 ··· 1442 1411 dst = nla_data(info->attrs[NL80211_ATTR_MAC]); 1443 1412 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]); 1444 1413 1445 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 1414 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1446 1415 if (err) 1447 1416 return err; 1448 1417 ··· 1477 1446 dst = nla_data(info->attrs[NL80211_ATTR_MAC]); 1478 1447 next_hop = nla_data(info->attrs[NL80211_ATTR_MPATH_NEXT_HOP]); 1479 1448 1480 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 1449 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1481 1450 if (err) 1482 1451 return err; 1483 1452 ··· 1506 1475 if (info->attrs[NL80211_ATTR_MAC]) 1507 1476 dst = nla_data(info->attrs[NL80211_ATTR_MAC]); 1508 1477 1509 - err = get_drv_dev_by_info_ifindex(info, &drv, &dev); 1478 + err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 1510 1479 if (err) 1511 1480 return err; 1512 1481