aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/wireless/ath9k/main.c2
-rw-r--r--drivers/net/wireless/b43/b43.h7
-rw-r--r--drivers/net/wireless/b43/main.c119
-rw-r--r--drivers/net/wireless/b43/phy_g.c1
-rw-r--r--drivers/net/wireless/b43legacy/phy.c32
-rw-r--r--drivers/net/wireless/b43legacy/xmit.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-3945.c14
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-4965.c5
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.c163
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-rs.h29
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.c12
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-calib.c15
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.c66
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-core.h10
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-dev.h62
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.c34
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-power.h4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-tx.c9
-rw-r--r--drivers/net/wireless/libertas/cmd.c64
-rw-r--r--drivers/net/wireless/libertas/cmd.h6
-rw-r--r--drivers/net/wireless/libertas/defs.h9
-rw-r--r--drivers/net/wireless/libertas/host.h1
-rw-r--r--drivers/net/wireless/libertas/hostcmd.h24
-rw-r--r--drivers/net/wireless/libertas/main.c20
-rw-r--r--drivers/net/wireless/libertas/wext.c31
-rw-r--r--drivers/net/wireless/p54/p54.h9
-rw-r--r--drivers/net/wireless/p54/p54common.c256
-rw-r--r--drivers/net/wireless/p54/p54common.h23
-rw-r--r--drivers/net/wireless/rt2x00/Kconfig75
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c16
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c16
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c20
-rw-r--r--drivers/net/wireless/rt2x00/rt2x00rfkill.c50
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c20
-rw-r--r--drivers/net/wireless/rt2x00/rt73usb.c20
37 files changed, 801 insertions, 456 deletions
diff --git a/drivers/net/wireless/ath9k/main.c b/drivers/net/wireless/ath9k/main.c
index 245b7308a9ad..57d7cc87cb0f 100644
--- a/drivers/net/wireless/ath9k/main.c
+++ b/drivers/net/wireless/ath9k/main.c
@@ -224,7 +224,7 @@ static void setup_ht_cap(struct ieee80211_ht_info *ht_info)
224 224
225 ht_info->ht_supported = 1; 225 ht_info->ht_supported = 1;
226 ht_info->cap = (u16)IEEE80211_HT_CAP_SUP_WIDTH 226 ht_info->cap = (u16)IEEE80211_HT_CAP_SUP_WIDTH
227 |(u16)IEEE80211_HT_CAP_MIMO_PS 227 |(u16)IEEE80211_HT_CAP_SM_PS
228 |(u16)IEEE80211_HT_CAP_SGI_40 228 |(u16)IEEE80211_HT_CAP_SGI_40
229 |(u16)IEEE80211_HT_CAP_DSSSCCK40; 229 |(u16)IEEE80211_HT_CAP_DSSSCCK40;
230 230
diff --git a/drivers/net/wireless/b43/b43.h b/drivers/net/wireless/b43/b43.h
index f9c8161671d9..07d2825458ab 100644
--- a/drivers/net/wireless/b43/b43.h
+++ b/drivers/net/wireless/b43/b43.h
@@ -585,8 +585,6 @@ enum {
585struct b43_qos_params { 585struct b43_qos_params {
586 /* The QOS parameters */ 586 /* The QOS parameters */
587 struct ieee80211_tx_queue_params p; 587 struct ieee80211_tx_queue_params p;
588 /* Does this need to get uploaded to hardware? */
589 bool need_hw_update;
590}; 588};
591 589
592struct b43_wldev; 590struct b43_wldev;
@@ -648,11 +646,8 @@ struct b43_wl {
648 bool beacon_templates_virgin; /* Never wrote the templates? */ 646 bool beacon_templates_virgin; /* Never wrote the templates? */
649 struct work_struct beacon_update_trigger; 647 struct work_struct beacon_update_trigger;
650 648
651 /* The current QOS parameters for the 4 queues. 649 /* The current QOS parameters for the 4 queues. */
652 * This is protected by the irq_lock. */
653 struct b43_qos_params qos_params[4]; 650 struct b43_qos_params qos_params[4];
654 /* Workqueue for updating QOS parameters in hardware. */
655 struct work_struct qos_update_work;
656 651
657 /* Work for adjustment of the transmission power. 652 /* Work for adjustment of the transmission power.
658 * This is scheduled when we determine that the actual TX output 653 * This is scheduled when we determine that the actual TX output
diff --git a/drivers/net/wireless/b43/main.c b/drivers/net/wireless/b43/main.c
index c836beceb10d..d4a356b11636 100644
--- a/drivers/net/wireless/b43/main.c
+++ b/drivers/net/wireless/b43/main.c
@@ -3059,36 +3059,31 @@ static void b43_qos_params_upload(struct b43_wldev *dev,
3059 } 3059 }
3060} 3060}
3061 3061
3062/* Update the QOS parameters in hardware. */ 3062/* Mapping of mac80211 queue numbers to b43 QoS SHM offsets. */
3063static void b43_qos_update(struct b43_wldev *dev) 3063static const u16 b43_qos_shm_offsets[] = {
3064 /* [mac80211-queue-nr] = SHM_OFFSET, */
3065 [0] = B43_QOS_VOICE,
3066 [1] = B43_QOS_VIDEO,
3067 [2] = B43_QOS_BESTEFFORT,
3068 [3] = B43_QOS_BACKGROUND,
3069};
3070
3071/* Update all QOS parameters in hardware. */
3072static void b43_qos_upload_all(struct b43_wldev *dev)
3064{ 3073{
3065 struct b43_wl *wl = dev->wl; 3074 struct b43_wl *wl = dev->wl;
3066 struct b43_qos_params *params; 3075 struct b43_qos_params *params;
3067 unsigned long flags;
3068 unsigned int i; 3076 unsigned int i;
3069 3077
3070 /* Mapping of mac80211 queues to b43 SHM offsets. */ 3078 BUILD_BUG_ON(ARRAY_SIZE(b43_qos_shm_offsets) !=
3071 static const u16 qos_shm_offsets[] = { 3079 ARRAY_SIZE(wl->qos_params));
3072 [0] = B43_QOS_VOICE,
3073 [1] = B43_QOS_VIDEO,
3074 [2] = B43_QOS_BESTEFFORT,
3075 [3] = B43_QOS_BACKGROUND,
3076 };
3077 BUILD_BUG_ON(ARRAY_SIZE(qos_shm_offsets) != ARRAY_SIZE(wl->qos_params));
3078 3080
3079 b43_mac_suspend(dev); 3081 b43_mac_suspend(dev);
3080 spin_lock_irqsave(&wl->irq_lock, flags);
3081
3082 for (i = 0; i < ARRAY_SIZE(wl->qos_params); i++) { 3082 for (i = 0; i < ARRAY_SIZE(wl->qos_params); i++) {
3083 params = &(wl->qos_params[i]); 3083 params = &(wl->qos_params[i]);
3084 if (params->need_hw_update) { 3084 b43_qos_params_upload(dev, &(params->p),
3085 b43_qos_params_upload(dev, &(params->p), 3085 b43_qos_shm_offsets[i]);
3086 qos_shm_offsets[i]);
3087 params->need_hw_update = 0;
3088 }
3089 } 3086 }
3090
3091 spin_unlock_irqrestore(&wl->irq_lock, flags);
3092 b43_mac_enable(dev); 3087 b43_mac_enable(dev);
3093} 3088}
3094 3089
@@ -3097,25 +3092,50 @@ static void b43_qos_clear(struct b43_wl *wl)
3097 struct b43_qos_params *params; 3092 struct b43_qos_params *params;
3098 unsigned int i; 3093 unsigned int i;
3099 3094
3095 /* Initialize QoS parameters to sane defaults. */
3096
3097 BUILD_BUG_ON(ARRAY_SIZE(b43_qos_shm_offsets) !=
3098 ARRAY_SIZE(wl->qos_params));
3099
3100 for (i = 0; i < ARRAY_SIZE(wl->qos_params); i++) { 3100 for (i = 0; i < ARRAY_SIZE(wl->qos_params); i++) {
3101 params = &(wl->qos_params[i]); 3101 params = &(wl->qos_params[i]);
3102 3102
3103 memset(&(params->p), 0, sizeof(params->p)); 3103 switch (b43_qos_shm_offsets[i]) {
3104 params->p.aifs = -1; 3104 case B43_QOS_VOICE:
3105 params->need_hw_update = 1; 3105 params->p.txop = 0;
3106 params->p.aifs = 2;
3107 params->p.cw_min = 0x0001;
3108 params->p.cw_max = 0x0001;
3109 break;
3110 case B43_QOS_VIDEO:
3111 params->p.txop = 0;
3112 params->p.aifs = 2;
3113 params->p.cw_min = 0x0001;
3114 params->p.cw_max = 0x0001;
3115 break;
3116 case B43_QOS_BESTEFFORT:
3117 params->p.txop = 0;
3118 params->p.aifs = 3;
3119 params->p.cw_min = 0x0001;
3120 params->p.cw_max = 0x03FF;
3121 break;
3122 case B43_QOS_BACKGROUND:
3123 params->p.txop = 0;
3124 params->p.aifs = 7;
3125 params->p.cw_min = 0x0001;
3126 params->p.cw_max = 0x03FF;
3127 break;
3128 default:
3129 B43_WARN_ON(1);
3130 }
3106 } 3131 }
3107} 3132}
3108 3133
3109/* Initialize the core's QOS capabilities */ 3134/* Initialize the core's QOS capabilities */
3110static void b43_qos_init(struct b43_wldev *dev) 3135static void b43_qos_init(struct b43_wldev *dev)
3111{ 3136{
3112 struct b43_wl *wl = dev->wl;
3113 unsigned int i;
3114
3115 /* Upload the current QOS parameters. */ 3137 /* Upload the current QOS parameters. */
3116 for (i = 0; i < ARRAY_SIZE(wl->qos_params); i++) 3138 b43_qos_upload_all(dev);
3117 wl->qos_params[i].need_hw_update = 1;
3118 b43_qos_update(dev);
3119 3139
3120 /* Enable QOS support. */ 3140 /* Enable QOS support. */
3121 b43_hf_write(dev, b43_hf_read(dev) | B43_HF_EDCF); 3141 b43_hf_write(dev, b43_hf_read(dev) | B43_HF_EDCF);
@@ -3124,25 +3144,13 @@ static void b43_qos_init(struct b43_wldev *dev)
3124 | B43_MMIO_IFSCTL_USE_EDCF); 3144 | B43_MMIO_IFSCTL_USE_EDCF);
3125} 3145}
3126 3146
3127static void b43_qos_update_work(struct work_struct *work)
3128{
3129 struct b43_wl *wl = container_of(work, struct b43_wl, qos_update_work);
3130 struct b43_wldev *dev;
3131
3132 mutex_lock(&wl->mutex);
3133 dev = wl->current_dev;
3134 if (likely(dev && (b43_status(dev) >= B43_STAT_INITIALIZED)))
3135 b43_qos_update(dev);
3136 mutex_unlock(&wl->mutex);
3137}
3138
3139static int b43_op_conf_tx(struct ieee80211_hw *hw, u16 _queue, 3147static int b43_op_conf_tx(struct ieee80211_hw *hw, u16 _queue,
3140 const struct ieee80211_tx_queue_params *params) 3148 const struct ieee80211_tx_queue_params *params)
3141{ 3149{
3142 struct b43_wl *wl = hw_to_b43_wl(hw); 3150 struct b43_wl *wl = hw_to_b43_wl(hw);
3143 unsigned long flags; 3151 struct b43_wldev *dev;
3144 unsigned int queue = (unsigned int)_queue; 3152 unsigned int queue = (unsigned int)_queue;
3145 struct b43_qos_params *p; 3153 int err = -ENODEV;
3146 3154
3147 if (queue >= ARRAY_SIZE(wl->qos_params)) { 3155 if (queue >= ARRAY_SIZE(wl->qos_params)) {
3148 /* Queue not available or don't support setting 3156 /* Queue not available or don't support setting
@@ -3150,16 +3158,25 @@ static int b43_op_conf_tx(struct ieee80211_hw *hw, u16 _queue,
3150 * confuse mac80211. */ 3158 * confuse mac80211. */
3151 return 0; 3159 return 0;
3152 } 3160 }
3161 BUILD_BUG_ON(ARRAY_SIZE(b43_qos_shm_offsets) !=
3162 ARRAY_SIZE(wl->qos_params));
3153 3163
3154 spin_lock_irqsave(&wl->irq_lock, flags); 3164 mutex_lock(&wl->mutex);
3155 p = &(wl->qos_params[queue]); 3165 dev = wl->current_dev;
3156 memcpy(&(p->p), params, sizeof(p->p)); 3166 if (unlikely(!dev || (b43_status(dev) < B43_STAT_INITIALIZED)))
3157 p->need_hw_update = 1; 3167 goto out_unlock;
3158 spin_unlock_irqrestore(&wl->irq_lock, flags);
3159 3168
3160 queue_work(hw->workqueue, &wl->qos_update_work); 3169 memcpy(&(wl->qos_params[queue].p), params, sizeof(*params));
3170 b43_mac_suspend(dev);
3171 b43_qos_params_upload(dev, &(wl->qos_params[queue].p),
3172 b43_qos_shm_offsets[queue]);
3173 b43_mac_enable(dev);
3174 err = 0;
3161 3175
3162 return 0; 3176out_unlock:
3177 mutex_unlock(&wl->mutex);
3178
3179 return err;
3163} 3180}
3164 3181
3165static int b43_op_get_tx_stats(struct ieee80211_hw *hw, 3182static int b43_op_get_tx_stats(struct ieee80211_hw *hw,
@@ -4186,7 +4203,6 @@ static void b43_op_stop(struct ieee80211_hw *hw)
4186 struct b43_wldev *dev = wl->current_dev; 4203 struct b43_wldev *dev = wl->current_dev;
4187 4204
4188 b43_rfkill_exit(dev); 4205 b43_rfkill_exit(dev);
4189 cancel_work_sync(&(wl->qos_update_work));
4190 cancel_work_sync(&(wl->beacon_update_trigger)); 4206 cancel_work_sync(&(wl->beacon_update_trigger));
4191 4207
4192 mutex_lock(&wl->mutex); 4208 mutex_lock(&wl->mutex);
@@ -4585,7 +4601,6 @@ static int b43_wireless_init(struct ssb_device *dev)
4585 spin_lock_init(&wl->shm_lock); 4601 spin_lock_init(&wl->shm_lock);
4586 mutex_init(&wl->mutex); 4602 mutex_init(&wl->mutex);
4587 INIT_LIST_HEAD(&wl->devlist); 4603 INIT_LIST_HEAD(&wl->devlist);
4588 INIT_WORK(&wl->qos_update_work, b43_qos_update_work);
4589 INIT_WORK(&wl->beacon_update_trigger, b43_beacon_update_trigger_work); 4604 INIT_WORK(&wl->beacon_update_trigger, b43_beacon_update_trigger_work);
4590 INIT_WORK(&wl->txpower_adjust_work, b43_phy_txpower_adjust_work); 4605 INIT_WORK(&wl->txpower_adjust_work, b43_phy_txpower_adjust_work);
4591 4606
diff --git a/drivers/net/wireless/b43/phy_g.c b/drivers/net/wireless/b43/phy_g.c
index e8c012c9abb0..232181f6333c 100644
--- a/drivers/net/wireless/b43/phy_g.c
+++ b/drivers/net/wireless/b43/phy_g.c
@@ -386,7 +386,6 @@ static void b43_set_original_gains(struct b43_wldev *dev)
386void b43_nrssi_hw_write(struct b43_wldev *dev, u16 offset, s16 val) 386void b43_nrssi_hw_write(struct b43_wldev *dev, u16 offset, s16 val)
387{ 387{
388 b43_phy_write(dev, B43_PHY_NRSSILT_CTRL, offset); 388 b43_phy_write(dev, B43_PHY_NRSSILT_CTRL, offset);
389 mmiowb();
390 b43_phy_write(dev, B43_PHY_NRSSILT_DATA, (u16) val); 389 b43_phy_write(dev, B43_PHY_NRSSILT_DATA, (u16) val);
391} 390}
392 391
diff --git a/drivers/net/wireless/b43legacy/phy.c b/drivers/net/wireless/b43legacy/phy.c
index 768cccb9b1ba..bed67a54250c 100644
--- a/drivers/net/wireless/b43legacy/phy.c
+++ b/drivers/net/wireless/b43legacy/phy.c
@@ -595,12 +595,14 @@ static void b43legacy_phy_initb5(struct b43legacy_wldev *dev)
595 0x0035) & 0xFFC0) | 0x0064); 595 0x0035) & 0xFFC0) | 0x0064);
596 b43legacy_phy_write(dev, 0x005D, (b43legacy_phy_read(dev, 596 b43legacy_phy_write(dev, 0x005D, (b43legacy_phy_read(dev,
597 0x005D) & 0xFF80) | 0x000A); 597 0x005D) & 0xFF80) | 0x000A);
598 b43legacy_phy_write(dev, 0x5B, 0x0000);
599 b43legacy_phy_write(dev, 0x5C, 0x0000);
598 } 600 }
599 601
600 if (dev->bad_frames_preempt) 602 if (dev->bad_frames_preempt)
601 b43legacy_phy_write(dev, B43legacy_PHY_RADIO_BITFIELD, 603 b43legacy_phy_write(dev, B43legacy_PHY_RADIO_BITFIELD,
602 b43legacy_phy_read(dev, 604 b43legacy_phy_read(dev,
603 B43legacy_PHY_RADIO_BITFIELD) | (1 << 11)); 605 B43legacy_PHY_RADIO_BITFIELD) | (1 << 12));
604 606
605 if (phy->analog == 1) { 607 if (phy->analog == 1) {
606 b43legacy_phy_write(dev, 0x0026, 0xCE00); 608 b43legacy_phy_write(dev, 0x0026, 0xCE00);
@@ -753,7 +755,7 @@ static void b43legacy_phy_initb6(struct b43legacy_wldev *dev)
753 b43legacy_radio_write16(dev, 0x0050, 0x0020); 755 b43legacy_radio_write16(dev, 0x0050, 0x0020);
754 } 756 }
755 if (phy->radio_rev <= 2) { 757 if (phy->radio_rev <= 2) {
756 b43legacy_radio_write16(dev, 0x007C, 0x0020); 758 b43legacy_radio_write16(dev, 0x0050, 0x0020);
757 b43legacy_radio_write16(dev, 0x005A, 0x0070); 759 b43legacy_radio_write16(dev, 0x005A, 0x0070);
758 b43legacy_radio_write16(dev, 0x005B, 0x007B); 760 b43legacy_radio_write16(dev, 0x005B, 0x007B);
759 b43legacy_radio_write16(dev, 0x005C, 0x00B0); 761 b43legacy_radio_write16(dev, 0x005C, 0x00B0);
@@ -771,7 +773,7 @@ static void b43legacy_phy_initb6(struct b43legacy_wldev *dev)
771 b43legacy_phy_write(dev, 0x002A, 0x8AC0); 773 b43legacy_phy_write(dev, 0x002A, 0x8AC0);
772 b43legacy_phy_write(dev, 0x0038, 0x0668); 774 b43legacy_phy_write(dev, 0x0038, 0x0668);
773 b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF); 775 b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF);
774 if (phy->radio_rev <= 5) 776 if (phy->radio_rev == 4 || phy->radio_rev == 5)
775 b43legacy_phy_write(dev, 0x005D, (b43legacy_phy_read(dev, 777 b43legacy_phy_write(dev, 0x005D, (b43legacy_phy_read(dev,
776 0x005D) & 0xFF80) | 0x0003); 778 0x005D) & 0xFF80) | 0x0003);
777 if (phy->radio_rev <= 2) 779 if (phy->radio_rev <= 2)
@@ -1010,7 +1012,7 @@ static void b43legacy_phy_initg(struct b43legacy_wldev *dev)
1010 b43legacy_phy_initb5(dev); 1012 b43legacy_phy_initb5(dev);
1011 else 1013 else
1012 b43legacy_phy_initb6(dev); 1014 b43legacy_phy_initb6(dev);
1013 if (phy->rev >= 2 || phy->gmode) 1015 if (phy->rev >= 2 && phy->gmode)
1014 b43legacy_phy_inita(dev); 1016 b43legacy_phy_inita(dev);
1015 1017
1016 if (phy->rev >= 2) { 1018 if (phy->rev >= 2) {
@@ -1025,18 +1027,22 @@ static void b43legacy_phy_initg(struct b43legacy_wldev *dev)
1025 b43legacy_phy_write(dev, 0x0811, 0x0400); 1027 b43legacy_phy_write(dev, 0x0811, 0x0400);
1026 b43legacy_phy_write(dev, 0x0015, 0x00C0); 1028 b43legacy_phy_write(dev, 0x0015, 0x00C0);
1027 } 1029 }
1028 if (phy->rev >= 2 || phy->gmode) { 1030 if (phy->gmode) {
1029 tmp = b43legacy_phy_read(dev, 0x0400) & 0xFF; 1031 tmp = b43legacy_phy_read(dev, 0x0400) & 0xFF;
1030 if (tmp == 3 || tmp == 5) { 1032 if (tmp == 3) {
1033 b43legacy_phy_write(dev, 0x04C2, 0x1816);
1034 b43legacy_phy_write(dev, 0x04C3, 0x8606);
1035 }
1036 if (tmp == 4 || tmp == 5) {
1031 b43legacy_phy_write(dev, 0x04C2, 0x1816); 1037 b43legacy_phy_write(dev, 0x04C2, 0x1816);
1032 b43legacy_phy_write(dev, 0x04C3, 0x8006); 1038 b43legacy_phy_write(dev, 0x04C3, 0x8006);
1033 if (tmp == 5) 1039 b43legacy_phy_write(dev, 0x04CC,
1034 b43legacy_phy_write(dev, 0x04CC, 1040 (b43legacy_phy_read(dev,
1035 (b43legacy_phy_read(dev, 1041 0x04CC) & 0x00FF) |
1036 0x04CC) & 0x00FF) | 1042 0x1F00);
1037 0x1F00);
1038 } 1043 }
1039 b43legacy_phy_write(dev, 0x047E, 0x0078); 1044 if (phy->rev >= 2)
1045 b43legacy_phy_write(dev, 0x047E, 0x0078);
1040 } 1046 }
1041 if (phy->radio_rev == 8) { 1047 if (phy->radio_rev == 8) {
1042 b43legacy_phy_write(dev, 0x0801, b43legacy_phy_read(dev, 0x0801) 1048 b43legacy_phy_write(dev, 0x0801, b43legacy_phy_read(dev, 0x0801)
@@ -1078,7 +1084,7 @@ static void b43legacy_phy_initg(struct b43legacy_wldev *dev)
1078 else 1084 else
1079 b43legacy_phy_write(dev, 0x002F, 0x0202); 1085 b43legacy_phy_write(dev, 0x002F, 0x0202);
1080 } 1086 }
1081 if (phy->gmode || phy->rev >= 2) { 1087 if (phy->gmode) {
1082 b43legacy_phy_lo_adjust(dev, 0); 1088 b43legacy_phy_lo_adjust(dev, 0);
1083 b43legacy_phy_write(dev, 0x080F, 0x8078); 1089 b43legacy_phy_write(dev, 0x080F, 0x8078);
1084 } 1090 }
diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c
index c5ca72aa59e7..6835064758fb 100644
--- a/drivers/net/wireless/b43legacy/xmit.c
+++ b/drivers/net/wireless/b43legacy/xmit.c
@@ -624,7 +624,7 @@ void b43legacy_handle_hwtxstatus(struct b43legacy_wldev *dev,
624 tmp = hw->count; 624 tmp = hw->count;
625 status.frame_count = (tmp >> 4); 625 status.frame_count = (tmp >> 4);
626 status.rts_count = (tmp & 0x0F); 626 status.rts_count = (tmp & 0x0F);
627 tmp = hw->flags; 627 tmp = hw->flags << 1;
628 status.supp_reason = ((tmp & 0x1C) >> 2); 628 status.supp_reason = ((tmp & 0x1C) >> 2);
629 status.pm_indicated = !!(tmp & 0x80); 629 status.pm_indicated = !!(tmp & 0x80);
630 status.intermediate = !!(tmp & 0x40); 630 status.intermediate = !!(tmp & 0x40);
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c
index 1377c8190ecb..3d100e898249 100644
--- a/drivers/net/wireless/iwlwifi/iwl-3945.c
+++ b/drivers/net/wireless/iwlwifi/iwl-3945.c
@@ -681,19 +681,7 @@ static void iwl3945_rx_reply_rx(struct iwl3945_priv *priv,
681 priv->last_rx_noise = rx_status.noise; 681 priv->last_rx_noise = rx_status.noise;
682 } 682 }
683 683
684 if (priv->iw_mode == IEEE80211_IF_TYPE_MNTR) { 684 iwl3945_pass_packet_to_mac80211(priv, rxb, &rx_status);
685 iwl3945_pass_packet_to_mac80211(priv, rxb, &rx_status);
686 return;
687 }
688
689 switch (le16_to_cpu(header->frame_control) & IEEE80211_FCTL_FTYPE) {
690 case IEEE80211_FTYPE_MGMT:
691 case IEEE80211_FTYPE_DATA:
692 /* fall through */
693 default:
694 iwl3945_pass_packet_to_mac80211(priv, rxb, &rx_status);
695 break;
696 }
697} 685}
698 686
699int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl3945_priv *priv, void *ptr, 687int iwl3945_hw_txq_attach_buf_to_tfd(struct iwl3945_priv *priv, void *ptr,
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c
index d9c4fdbf7f77..9838de5f4369 100644
--- a/drivers/net/wireless/iwlwifi/iwl-4965.c
+++ b/drivers/net/wireless/iwlwifi/iwl-4965.c
@@ -1607,8 +1607,8 @@ static int iwl4965_send_rxon_assoc(struct iwl_priv *priv)
1607 return ret; 1607 return ret;
1608} 1608}
1609 1609
1610 1610#ifdef IEEE80211_CONF_CHANNEL_SWITCH
1611int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel) 1611static int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel)
1612{ 1612{
1613 int rc; 1613 int rc;
1614 u8 band = 0; 1614 u8 band = 0;
@@ -1648,6 +1648,7 @@ int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel)
1648 rc = iwl_send_cmd_pdu(priv, REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd); 1648 rc = iwl_send_cmd_pdu(priv, REPLY_CHANNEL_SWITCH, sizeof(cmd), &cmd);
1649 return rc; 1649 return rc;
1650} 1650}
1651#endif
1651 1652
1652static int iwl4965_shared_mem_rx_idx(struct iwl_priv *priv) 1653static int iwl4965_shared_mem_rx_idx(struct iwl_priv *priv)
1653{ 1654{
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
index 98f2c843b99e..c293e5b6cbb5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.c
@@ -436,7 +436,7 @@ static int rs_collect_tx_data(struct iwl_rate_scale_data *windows,
436 /* Shift bitmap by one frame (throw away oldest history), 436 /* Shift bitmap by one frame (throw away oldest history),
437 * OR in "1", and increment "success" if this 437 * OR in "1", and increment "success" if this
438 * frame was successful. */ 438 * frame was successful. */
439 window->data <<= 1;; 439 window->data <<= 1;
440 if (successes > 0) { 440 if (successes > 0) {
441 window->success_counter++; 441 window->success_counter++;
442 window->data |= 0x1; 442 window->data |= 0x1;
@@ -1128,6 +1128,7 @@ static s32 rs_get_best_rate(struct iwl_priv *priv,
1128 1128
1129 /* Higher rate not available, use the original */ 1129 /* Higher rate not available, use the original */
1130 } else { 1130 } else {
1131 new_rate = rate;
1131 break; 1132 break;
1132 } 1133 }
1133 } 1134 }
@@ -1153,8 +1154,8 @@ static int rs_switch_to_mimo2(struct iwl_priv *priv,
1153 !sta->ht_info.ht_supported) 1154 !sta->ht_info.ht_supported)
1154 return -1; 1155 return -1;
1155 1156
1156 if (((sta->ht_info.cap & IEEE80211_HT_CAP_MIMO_PS) >> 2) 1157 if (((sta->ht_info.cap & IEEE80211_HT_CAP_SM_PS) >> 2)
1157 == IWL_MIMO_PS_STATIC) 1158 == WLAN_HT_CAP_SM_PS_STATIC)
1158 return -1; 1159 return -1;
1159 1160
1160 /* Need both Tx chains/antennas to support MIMO */ 1161 /* Need both Tx chains/antennas to support MIMO */
@@ -1281,15 +1282,23 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1281 (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); 1282 (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT));
1282 u8 start_action = tbl->action; 1283 u8 start_action = tbl->action;
1283 u8 valid_tx_ant = priv->hw_params.valid_tx_ant; 1284 u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
1285 u8 tx_chains_num = priv->hw_params.tx_chains_num;
1284 int ret = 0; 1286 int ret = 0;
1285 1287
1286 for (; ;) { 1288 for (; ;) {
1287 switch (tbl->action) { 1289 switch (tbl->action) {
1288 case IWL_LEGACY_SWITCH_ANTENNA: 1290 case IWL_LEGACY_SWITCH_ANTENNA1:
1291 case IWL_LEGACY_SWITCH_ANTENNA2:
1289 IWL_DEBUG_RATE("LQ: Legacy toggle Antenna\n"); 1292 IWL_DEBUG_RATE("LQ: Legacy toggle Antenna\n");
1290 1293
1291 lq_sta->action_counter++; 1294 lq_sta->action_counter++;
1292 1295
1296 if ((tbl->action == IWL_LEGACY_SWITCH_ANTENNA1 &&
1297 tx_chains_num <= 1) ||
1298 (tbl->action == IWL_LEGACY_SWITCH_ANTENNA2 &&
1299 tx_chains_num <= 2))
1300 break;
1301
1293 /* Don't change antenna if success has been great */ 1302 /* Don't change antenna if success has been great */
1294 if (window->success_ratio >= IWL_RS_GOOD_RATIO) 1303 if (window->success_ratio >= IWL_RS_GOOD_RATIO)
1295 break; 1304 break;
@@ -1299,7 +1308,7 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1299 1308
1300 if (rs_toggle_antenna(valid_tx_ant, 1309 if (rs_toggle_antenna(valid_tx_ant,
1301 &search_tbl->current_rate, search_tbl)) { 1310 &search_tbl->current_rate, search_tbl)) {
1302 lq_sta->search_better_tbl = 1; 1311 rs_set_expected_tpt_table(lq_sta, search_tbl);
1303 goto out; 1312 goto out;
1304 } 1313 }
1305 break; 1314 break;
@@ -1312,43 +1321,54 @@ static int rs_move_legacy_other(struct iwl_priv *priv,
1312 ret = rs_switch_to_siso(priv, lq_sta, conf, sta, 1321 ret = rs_switch_to_siso(priv, lq_sta, conf, sta,
1313 search_tbl, index); 1322 search_tbl, index);
1314 if (!ret) { 1323 if (!ret) {
1315 lq_sta->search_better_tbl = 1;
1316 lq_sta->action_counter = 0; 1324 lq_sta->action_counter = 0;
1317 goto out; 1325 goto out;
1318 } 1326 }
1319 1327
1320 break; 1328 break;
1321 case IWL_LEGACY_SWITCH_MIMO2: 1329 case IWL_LEGACY_SWITCH_MIMO2_AB:
1330 case IWL_LEGACY_SWITCH_MIMO2_AC:
1331 case IWL_LEGACY_SWITCH_MIMO2_BC:
1322 IWL_DEBUG_RATE("LQ: Legacy switch to MIMO2\n"); 1332 IWL_DEBUG_RATE("LQ: Legacy switch to MIMO2\n");
1323 1333
1324 /* Set up search table to try MIMO */ 1334 /* Set up search table to try MIMO */
1325 memcpy(search_tbl, tbl, sz); 1335 memcpy(search_tbl, tbl, sz);
1326 search_tbl->is_SGI = 0; 1336 search_tbl->is_SGI = 0;
1327 search_tbl->ant_type = ANT_AB;/*FIXME:RS*/ 1337
1328 /*FIXME:RS:need to check ant validity*/ 1338 if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AB)
1339 search_tbl->ant_type = ANT_AB;
1340 else if (tbl->action == IWL_LEGACY_SWITCH_MIMO2_AC)
1341 search_tbl->ant_type = ANT_AC;
1342 else
1343 search_tbl->ant_type = ANT_BC;
1344
1345 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type))
1346 break;
1347
1329 ret = rs_switch_to_mimo2(priv, lq_sta, conf, sta, 1348 ret = rs_switch_to_mimo2(priv, lq_sta, conf, sta,
1330 search_tbl, index); 1349 search_tbl, index);
1331 if (!ret) { 1350 if (!ret) {
1332 lq_sta->search_better_tbl = 1;
1333 lq_sta->action_counter = 0; 1351 lq_sta->action_counter = 0;
1334 goto out; 1352 goto out;
1335 } 1353 }
1336 break; 1354 break;
1337 } 1355 }
1338 tbl->action++; 1356 tbl->action++;
1339 if (tbl->action > IWL_LEGACY_SWITCH_MIMO2) 1357 if (tbl->action > IWL_LEGACY_SWITCH_MIMO2_BC)
1340 tbl->action = IWL_LEGACY_SWITCH_ANTENNA; 1358 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1;
1341 1359
1342 if (tbl->action == start_action) 1360 if (tbl->action == start_action)
1343 break; 1361 break;
1344 1362
1345 } 1363 }
1364 search_tbl->lq_type = LQ_NONE;
1346 return 0; 1365 return 0;
1347 1366
1348 out: 1367out:
1368 lq_sta->search_better_tbl = 1;
1349 tbl->action++; 1369 tbl->action++;
1350 if (tbl->action > IWL_LEGACY_SWITCH_MIMO2) 1370 if (tbl->action > IWL_LEGACY_SWITCH_MIMO2_BC)
1351 tbl->action = IWL_LEGACY_SWITCH_ANTENNA; 1371 tbl->action = IWL_LEGACY_SWITCH_ANTENNA1;
1352 return 0; 1372 return 0;
1353 1373
1354} 1374}
@@ -1370,34 +1390,51 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1370 (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); 1390 (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT));
1371 u8 start_action = tbl->action; 1391 u8 start_action = tbl->action;
1372 u8 valid_tx_ant = priv->hw_params.valid_tx_ant; 1392 u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
1393 u8 tx_chains_num = priv->hw_params.tx_chains_num;
1373 int ret; 1394 int ret;
1374 1395
1375 for (;;) { 1396 for (;;) {
1376 lq_sta->action_counter++; 1397 lq_sta->action_counter++;
1377 switch (tbl->action) { 1398 switch (tbl->action) {
1378 case IWL_SISO_SWITCH_ANTENNA: 1399 case IWL_SISO_SWITCH_ANTENNA1:
1400 case IWL_SISO_SWITCH_ANTENNA2:
1379 IWL_DEBUG_RATE("LQ: SISO toggle Antenna\n"); 1401 IWL_DEBUG_RATE("LQ: SISO toggle Antenna\n");
1402
1403 if ((tbl->action == IWL_SISO_SWITCH_ANTENNA1 &&
1404 tx_chains_num <= 1) ||
1405 (tbl->action == IWL_SISO_SWITCH_ANTENNA2 &&
1406 tx_chains_num <= 2))
1407 break;
1408
1380 if (window->success_ratio >= IWL_RS_GOOD_RATIO) 1409 if (window->success_ratio >= IWL_RS_GOOD_RATIO)
1381 break; 1410 break;
1382 1411
1383 memcpy(search_tbl, tbl, sz); 1412 memcpy(search_tbl, tbl, sz);
1384 if (rs_toggle_antenna(valid_tx_ant, 1413 if (rs_toggle_antenna(valid_tx_ant,
1385 &search_tbl->current_rate, search_tbl)) { 1414 &search_tbl->current_rate, search_tbl))
1386 lq_sta->search_better_tbl = 1;
1387 goto out; 1415 goto out;
1388 }
1389 break; 1416 break;
1390 case IWL_SISO_SWITCH_MIMO2: 1417 case IWL_SISO_SWITCH_MIMO2_AB:
1418 case IWL_SISO_SWITCH_MIMO2_AC:
1419 case IWL_SISO_SWITCH_MIMO2_BC:
1391 IWL_DEBUG_RATE("LQ: SISO switch to MIMO2\n"); 1420 IWL_DEBUG_RATE("LQ: SISO switch to MIMO2\n");
1392 memcpy(search_tbl, tbl, sz); 1421 memcpy(search_tbl, tbl, sz);
1393 search_tbl->is_SGI = 0; 1422 search_tbl->is_SGI = 0;
1394 search_tbl->ant_type = ANT_AB; /*FIXME:RS*/ 1423
1424 if (tbl->action == IWL_SISO_SWITCH_MIMO2_AB)
1425 search_tbl->ant_type = ANT_AB;
1426 else if (tbl->action == IWL_SISO_SWITCH_MIMO2_AC)
1427 search_tbl->ant_type = ANT_AC;
1428 else
1429 search_tbl->ant_type = ANT_BC;
1430
1431 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type))
1432 break;
1433
1395 ret = rs_switch_to_mimo2(priv, lq_sta, conf, sta, 1434 ret = rs_switch_to_mimo2(priv, lq_sta, conf, sta,
1396 search_tbl, index); 1435 search_tbl, index);
1397 if (!ret) { 1436 if (!ret)
1398 lq_sta->search_better_tbl = 1;
1399 goto out; 1437 goto out;
1400 }
1401 break; 1438 break;
1402 case IWL_SISO_SWITCH_GI: 1439 case IWL_SISO_SWITCH_GI:
1403 if (!tbl->is_fat && 1440 if (!tbl->is_fat &&
@@ -1427,22 +1464,23 @@ static int rs_move_siso_to_other(struct iwl_priv *priv,
1427 } 1464 }
1428 search_tbl->current_rate = rate_n_flags_from_tbl( 1465 search_tbl->current_rate = rate_n_flags_from_tbl(
1429 search_tbl, index, is_green); 1466 search_tbl, index, is_green);
1430 lq_sta->search_better_tbl = 1;
1431 goto out; 1467 goto out;
1432 } 1468 }
1433 tbl->action++; 1469 tbl->action++;
1434 if (tbl->action > IWL_SISO_SWITCH_GI) 1470 if (tbl->action > IWL_SISO_SWITCH_GI)
1435 tbl->action = IWL_SISO_SWITCH_ANTENNA; 1471 tbl->action = IWL_SISO_SWITCH_ANTENNA1;
1436 1472
1437 if (tbl->action == start_action) 1473 if (tbl->action == start_action)
1438 break; 1474 break;
1439 } 1475 }
1476 search_tbl->lq_type = LQ_NONE;
1440 return 0; 1477 return 0;
1441 1478
1442 out: 1479 out:
1480 lq_sta->search_better_tbl = 1;
1443 tbl->action++; 1481 tbl->action++;
1444 if (tbl->action > IWL_SISO_SWITCH_GI) 1482 if (tbl->action > IWL_SISO_SWITCH_GI)
1445 tbl->action = IWL_SISO_SWITCH_ANTENNA; 1483 tbl->action = IWL_SISO_SWITCH_ANTENNA1;
1446 return 0; 1484 return 0;
1447} 1485}
1448 1486
@@ -1458,37 +1496,58 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
1458 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]); 1496 struct iwl_scale_tbl_info *tbl = &(lq_sta->lq_info[lq_sta->active_tbl]);
1459 struct iwl_scale_tbl_info *search_tbl = 1497 struct iwl_scale_tbl_info *search_tbl =
1460 &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]); 1498 &(lq_sta->lq_info[(1 - lq_sta->active_tbl)]);
1499 struct iwl_rate_scale_data *window = &(tbl->win[index]);
1461 u32 sz = (sizeof(struct iwl_scale_tbl_info) - 1500 u32 sz = (sizeof(struct iwl_scale_tbl_info) -
1462 (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT)); 1501 (sizeof(struct iwl_rate_scale_data) * IWL_RATE_COUNT));
1463 u8 start_action = tbl->action; 1502 u8 start_action = tbl->action;
1464 /*u8 valid_tx_ant = priv->hw_params.valid_tx_ant;*/ 1503 u8 valid_tx_ant = priv->hw_params.valid_tx_ant;
1504 u8 tx_chains_num = priv->hw_params.tx_chains_num;
1465 int ret; 1505 int ret;
1466 1506
1467 for (;;) { 1507 for (;;) {
1468 lq_sta->action_counter++; 1508 lq_sta->action_counter++;
1469 switch (tbl->action) { 1509 switch (tbl->action) {
1470 case IWL_MIMO_SWITCH_ANTENNA_A: 1510 case IWL_MIMO2_SWITCH_ANTENNA1:
1471 case IWL_MIMO_SWITCH_ANTENNA_B: 1511 case IWL_MIMO2_SWITCH_ANTENNA2:
1512 IWL_DEBUG_RATE("LQ: MIMO toggle Antennas\n");
1513
1514 if (tx_chains_num <= 2)
1515 break;
1516
1517 if (window->success_ratio >= IWL_RS_GOOD_RATIO)
1518 break;
1519
1520 memcpy(search_tbl, tbl, sz);
1521 if (rs_toggle_antenna(valid_tx_ant,
1522 &search_tbl->current_rate, search_tbl))
1523 goto out;
1524 break;
1525 case IWL_MIMO2_SWITCH_SISO_A:
1526 case IWL_MIMO2_SWITCH_SISO_B:
1527 case IWL_MIMO2_SWITCH_SISO_C:
1472 IWL_DEBUG_RATE("LQ: MIMO2 switch to SISO\n"); 1528 IWL_DEBUG_RATE("LQ: MIMO2 switch to SISO\n");
1473 1529
1474 /* Set up new search table for SISO */ 1530 /* Set up new search table for SISO */
1475 memcpy(search_tbl, tbl, sz); 1531 memcpy(search_tbl, tbl, sz);
1476 1532
1477 /*FIXME:RS:need to check ant validity + C*/ 1533 if (tbl->action == IWL_MIMO2_SWITCH_SISO_A)
1478 if (tbl->action == IWL_MIMO_SWITCH_ANTENNA_A)
1479 search_tbl->ant_type = ANT_A; 1534 search_tbl->ant_type = ANT_A;
1480 else 1535 else if (tbl->action == IWL_MIMO2_SWITCH_SISO_B)
1481 search_tbl->ant_type = ANT_B; 1536 search_tbl->ant_type = ANT_B;
1537 else
1538 search_tbl->ant_type = ANT_C;
1539
1540 if (!rs_is_valid_ant(valid_tx_ant, search_tbl->ant_type))
1541 break;
1482 1542
1483 ret = rs_switch_to_siso(priv, lq_sta, conf, sta, 1543 ret = rs_switch_to_siso(priv, lq_sta, conf, sta,
1484 search_tbl, index); 1544 search_tbl, index);
1485 if (!ret) { 1545 if (!ret)
1486 lq_sta->search_better_tbl = 1;
1487 goto out; 1546 goto out;
1488 } 1547
1489 break; 1548 break;
1490 1549
1491 case IWL_MIMO_SWITCH_GI: 1550 case IWL_MIMO2_SWITCH_GI:
1492 if (!tbl->is_fat && 1551 if (!tbl->is_fat &&
1493 !(priv->current_ht_config.sgf & 1552 !(priv->current_ht_config.sgf &
1494 HT_SHORT_GI_20MHZ)) 1553 HT_SHORT_GI_20MHZ))
@@ -1517,23 +1576,23 @@ static int rs_move_mimo_to_other(struct iwl_priv *priv,
1517 } 1576 }
1518 search_tbl->current_rate = rate_n_flags_from_tbl( 1577 search_tbl->current_rate = rate_n_flags_from_tbl(
1519 search_tbl, index, is_green); 1578 search_tbl, index, is_green);
1520 lq_sta->search_better_tbl = 1;
1521 goto out; 1579 goto out;
1522 1580
1523 } 1581 }
1524 tbl->action++; 1582 tbl->action++;
1525 if (tbl->action > IWL_MIMO_SWITCH_GI) 1583 if (tbl->action > IWL_MIMO2_SWITCH_GI)
1526 tbl->action = IWL_MIMO_SWITCH_ANTENNA_A; 1584 tbl->action = IWL_MIMO2_SWITCH_ANTENNA1;
1527 1585
1528 if (tbl->action == start_action) 1586 if (tbl->action == start_action)
1529 break; 1587 break;
1530 } 1588 }
1531 1589 search_tbl->lq_type = LQ_NONE;
1532 return 0; 1590 return 0;
1533 out: 1591 out:
1592 lq_sta->search_better_tbl = 1;
1534 tbl->action++; 1593 tbl->action++;
1535 if (tbl->action > IWL_MIMO_SWITCH_GI) 1594 if (tbl->action > IWL_MIMO2_SWITCH_GI)
1536 tbl->action = IWL_MIMO_SWITCH_ANTENNA_A; 1595 tbl->action = IWL_MIMO2_SWITCH_ANTENNA1;
1537 return 0; 1596 return 0;
1538 1597
1539} 1598}
@@ -1748,19 +1807,13 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1748 rs_stay_in_table(lq_sta); 1807 rs_stay_in_table(lq_sta);
1749 1808
1750 goto out; 1809 goto out;
1810 }
1751 1811
1752 /* Else we have enough samples; calculate estimate of 1812 /* Else we have enough samples; calculate estimate of
1753 * actual average throughput */ 1813 * actual average throughput */
1754 } else { 1814
1755 /*FIXME:RS remove this else if we don't get this error*/ 1815 BUG_ON(window->average_tpt != ((window->success_ratio *
1756 if (window->average_tpt != ((window->success_ratio * 1816 tbl->expected_tpt[index] + 64) / 128));
1757 tbl->expected_tpt[index] + 64) / 128)) {
1758 IWL_ERROR("expected_tpt should have been calculated"
1759 " by now\n");
1760 window->average_tpt = ((window->success_ratio *
1761 tbl->expected_tpt[index] + 64) / 128);
1762 }
1763 }
1764 1817
1765 /* If we are searching for better modulation mode, check success. */ 1818 /* If we are searching for better modulation mode, check success. */
1766 if (lq_sta->search_better_tbl) { 1819 if (lq_sta->search_better_tbl) {
@@ -1770,7 +1823,7 @@ static void rs_rate_scale_perform(struct iwl_priv *priv,
1770 * continuing to use the setup that we've been trying. */ 1823 * continuing to use the setup that we've been trying. */
1771 if (window->average_tpt > lq_sta->last_tpt) { 1824 if (window->average_tpt > lq_sta->last_tpt) {
1772 1825
1773 IWL_DEBUG_RATE("LQ: SWITCHING TO CURRENT TABLE " 1826 IWL_DEBUG_RATE("LQ: SWITCHING TO NEW TABLE "
1774 "suc=%d cur-tpt=%d old-tpt=%d\n", 1827 "suc=%d cur-tpt=%d old-tpt=%d\n",
1775 window->success_ratio, 1828 window->success_ratio,
1776 window->average_tpt, 1829 window->average_tpt,
@@ -2183,7 +2236,7 @@ static void rs_rate_init(void *priv_rate, void *priv_sta,
2183 for (i = 0; i < IWL_RATE_COUNT; i++) 2236 for (i = 0; i < IWL_RATE_COUNT; i++)
2184 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]); 2237 rs_rate_scale_clear_window(&lq_sta->lq_info[j].win[i]);
2185 2238
2186 IWL_DEBUG_RATE("LQ: *** rate scale global init ***\n"); 2239 IWL_DEBUG_RATE("LQ: *** rate scale station global init ***\n");
2187 /* TODO: what is a good starting rate for STA? About middle? Maybe not 2240 /* TODO: what is a good starting rate for STA? About middle? Maybe not
2188 * the lowest or the highest rate.. Could consider using RSSI from 2241 * the lowest or the highest rate.. Could consider using RSSI from
2189 * previous packets? Need to have IEEE 802.1X auth succeed immediately 2242 * previous packets? Need to have IEEE 802.1X auth succeed immediately
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
index 84d4d1e33755..d148d73635eb 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-rs.h
@@ -206,21 +206,28 @@ enum {
206#define IWL_RATE_DECREASE_TH 1920 /* 15% */ 206#define IWL_RATE_DECREASE_TH 1920 /* 15% */
207 207
208/* possible actions when in legacy mode */ 208/* possible actions when in legacy mode */
209#define IWL_LEGACY_SWITCH_ANTENNA 0 209#define IWL_LEGACY_SWITCH_ANTENNA1 0
210#define IWL_LEGACY_SWITCH_SISO 1 210#define IWL_LEGACY_SWITCH_ANTENNA2 1
211#define IWL_LEGACY_SWITCH_MIMO2 2 211#define IWL_LEGACY_SWITCH_SISO 2
212#define IWL_LEGACY_SWITCH_MIMO2_AB 3
213#define IWL_LEGACY_SWITCH_MIMO2_AC 4
214#define IWL_LEGACY_SWITCH_MIMO2_BC 5
212 215
213/* possible actions when in siso mode */ 216/* possible actions when in siso mode */
214#define IWL_SISO_SWITCH_ANTENNA 0 217#define IWL_SISO_SWITCH_ANTENNA1 0
215#define IWL_SISO_SWITCH_MIMO2 1 218#define IWL_SISO_SWITCH_ANTENNA2 1
216#define IWL_SISO_SWITCH_GI 2 219#define IWL_SISO_SWITCH_MIMO2_AB 2
220#define IWL_SISO_SWITCH_MIMO2_AC 3
221#define IWL_SISO_SWITCH_MIMO2_BC 4
222#define IWL_SISO_SWITCH_GI 5
217 223
218/* possible actions when in mimo mode */ 224/* possible actions when in mimo mode */
219#define IWL_MIMO_SWITCH_ANTENNA_A 0 225#define IWL_MIMO2_SWITCH_ANTENNA1 0
220#define IWL_MIMO_SWITCH_ANTENNA_B 1 226#define IWL_MIMO2_SWITCH_ANTENNA2 1
221#define IWL_MIMO_SWITCH_GI 2 227#define IWL_MIMO2_SWITCH_SISO_A 2
222 228#define IWL_MIMO2_SWITCH_SISO_B 3
223/*FIXME:RS:separate MIMO2/3 transitions*/ 229#define IWL_MIMO2_SWITCH_SISO_C 4
230#define IWL_MIMO2_SWITCH_GI 5
224 231
225/*FIXME:RS:add posible acctions for MIMO3*/ 232/*FIXME:RS:add posible acctions for MIMO3*/
226 233
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c
index 1547122e66fa..31ea28858896 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.c
@@ -485,7 +485,7 @@ static u8 iwl4965_rate_get_lowest_plcp(struct iwl_priv *priv)
485 return IWL_RATE_6M_PLCP; 485 return IWL_RATE_6M_PLCP;
486} 486}
487 487
488unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv, 488static unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
489 struct iwl_frame *frame, u8 rate) 489 struct iwl_frame *frame, u8 rate)
490{ 490{
491 struct iwl_tx_beacon_cmd *tx_beacon_cmd; 491 struct iwl_tx_beacon_cmd *tx_beacon_cmd;
@@ -564,8 +564,6 @@ static void iwl4965_ht_conf(struct iwl_priv *priv,
564 if (!iwl_conf->is_ht) 564 if (!iwl_conf->is_ht)
565 return; 565 return;
566 566
567 priv->ps_mode = (u8)((ht_conf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2);
568
569 if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20) 567 if (ht_conf->cap & IEEE80211_HT_CAP_SGI_20)
570 iwl_conf->sgf |= HT_SHORT_GI_20MHZ; 568 iwl_conf->sgf |= HT_SHORT_GI_20MHZ;
571 if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40) 569 if (ht_conf->cap & IEEE80211_HT_CAP_SGI_40)
@@ -586,6 +584,8 @@ static void iwl4965_ht_conf(struct iwl_priv *priv,
586 iwl_conf->supported_chan_width = 0; 584 iwl_conf->supported_chan_width = 0;
587 } 585 }
588 586
587 iwl_conf->sm_ps = (u8)((ht_conf->cap & IEEE80211_HT_CAP_SM_PS) >> 2);
588
589 memcpy(iwl_conf->supp_mcs_set, ht_conf->supp_mcs_set, 16); 589 memcpy(iwl_conf->supp_mcs_set, ht_conf->supp_mcs_set, 16);
590 590
591 iwl_conf->control_channel = ht_bss_conf->primary_channel; 591 iwl_conf->control_channel = ht_bss_conf->primary_channel;
@@ -2558,7 +2558,11 @@ static void iwl4965_post_associate(struct iwl_priv *priv)
2558 iwl_activate_qos(priv, 0); 2558 iwl_activate_qos(priv, 0);
2559 spin_unlock_irqrestore(&priv->lock, flags); 2559 spin_unlock_irqrestore(&priv->lock, flags);
2560 2560
2561 iwl_power_enable_management(priv); 2561 /* the chain noise calibration will enabled PM upon completion
2562 * If chain noise has already been run, then we need to enable
2563 * power management here */
2564 if (priv->chain_noise_data.state == IWL_CHAIN_NOISE_DONE)
2565 iwl_power_enable_management(priv);
2562 2566
2563 /* Enable Rx differential gain and sensitivity calibrations */ 2567 /* Enable Rx differential gain and sensitivity calibrations */
2564 iwl_chain_noise_reset(priv); 2568 iwl_chain_noise_reset(priv);
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c
index 35fb4a4f737d..72fbf47229db 100644
--- a/drivers/net/wireless/iwlwifi/iwl-calib.c
+++ b/drivers/net/wireless/iwlwifi/iwl-calib.c
@@ -808,13 +808,11 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
808 } 808 }
809 } 809 }
810 810
811 /* Save for use within RXON, TX, SCAN commands, etc. */
812 priv->chain_noise_data.active_chains = active_chains;
811 IWL_DEBUG_CALIB("active_chains (bitwise) = 0x%x\n", 813 IWL_DEBUG_CALIB("active_chains (bitwise) = 0x%x\n",
812 active_chains); 814 active_chains);
813 815
814 /* Save for use within RXON, TX, SCAN commands, etc. */
815 /*priv->valid_antenna = active_chains;*/
816 /*FIXME: should be reflected in RX chains in RXON */
817
818 /* Analyze noise for rx balance */ 816 /* Analyze noise for rx balance */
819 average_noise[0] = ((data->chain_noise_a)/CAL_NUM_OF_BEACONS); 817 average_noise[0] = ((data->chain_noise_a)/CAL_NUM_OF_BEACONS);
820 average_noise[1] = ((data->chain_noise_b)/CAL_NUM_OF_BEACONS); 818 average_noise[1] = ((data->chain_noise_b)/CAL_NUM_OF_BEACONS);
@@ -839,6 +837,15 @@ void iwl_chain_noise_calibration(struct iwl_priv *priv,
839 837
840 priv->cfg->ops->utils->gain_computation(priv, average_noise, 838 priv->cfg->ops->utils->gain_computation(priv, average_noise,
841 min_average_noise_antenna_i, min_average_noise); 839 min_average_noise_antenna_i, min_average_noise);
840
841 /* Some power changes may have been made during the calibration.
842 * Update and commit the RXON
843 */
844 if (priv->cfg->ops->lib->update_chain_flags)
845 priv->cfg->ops->lib->update_chain_flags(priv);
846
847 data->state = IWL_CHAIN_NOISE_DONE;
848 iwl_power_enable_management(priv);
842} 849}
843EXPORT_SYMBOL(iwl_chain_noise_calibration); 850EXPORT_SYMBOL(iwl_chain_noise_calibration);
844 851
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c
index a0b86af25c83..36d08b0eec43 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.c
+++ b/drivers/net/wireless/iwlwifi/iwl-core.c
@@ -399,8 +399,8 @@ static void iwlcore_init_ht_hw_capab(const struct iwl_priv *priv,
399 399
400 ht_info->cap |= (u16)IEEE80211_HT_CAP_GRN_FLD; 400 ht_info->cap |= (u16)IEEE80211_HT_CAP_GRN_FLD;
401 ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_20; 401 ht_info->cap |= (u16)IEEE80211_HT_CAP_SGI_20;
402 ht_info->cap |= (u16)(IEEE80211_HT_CAP_MIMO_PS & 402 ht_info->cap |= (u16)(IEEE80211_HT_CAP_SM_PS &
403 (IWL_MIMO_PS_NONE << 2)); 403 (WLAN_HT_CAP_SM_PS_DISABLED << 2));
404 404
405 max_bit_rate = MAX_BIT_RATE_20_MHZ; 405 max_bit_rate = MAX_BIT_RATE_20_MHZ;
406 if (priv->hw_params.fat_channel & BIT(band)) { 406 if (priv->hw_params.fat_channel & BIT(band)) {
@@ -709,7 +709,8 @@ static int iwl_get_active_rx_chain_count(struct iwl_priv *priv)
709 bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); 709 bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status);
710 710
711 /* # of Rx chains to use when expecting MIMO. */ 711 /* # of Rx chains to use when expecting MIMO. */
712 if (is_single || (!is_cam && (priv->ps_mode == IWL_MIMO_PS_STATIC))) 712 if (is_single || (!is_cam && (priv->current_ht_config.sm_ps ==
713 WLAN_HT_CAP_SM_PS_STATIC)))
713 return 2; 714 return 2;
714 else 715 else
715 return 3; 716 return 3;
@@ -720,17 +721,18 @@ static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt)
720 int idle_cnt; 721 int idle_cnt;
721 bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); 722 bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status);
722 /* # Rx chains when idling and maybe trying to save power */ 723 /* # Rx chains when idling and maybe trying to save power */
723 switch (priv->ps_mode) { 724 switch (priv->current_ht_config.sm_ps) {
724 case IWL_MIMO_PS_STATIC: 725 case WLAN_HT_CAP_SM_PS_STATIC:
725 case IWL_MIMO_PS_DYNAMIC: 726 case WLAN_HT_CAP_SM_PS_DYNAMIC:
726 idle_cnt = (is_cam) ? 2 : 1; 727 idle_cnt = (is_cam) ? 2 : 1;
727 break; 728 break;
728 case IWL_MIMO_PS_NONE: 729 case WLAN_HT_CAP_SM_PS_DISABLED:
729 idle_cnt = (is_cam) ? active_cnt : 1; 730 idle_cnt = (is_cam) ? active_cnt : 1;
730 break; 731 break;
731 case IWL_MIMO_PS_INVALID: 732 case WLAN_HT_CAP_SM_PS_INVALID:
732 default: 733 default:
733 IWL_ERROR("invalide mimo ps mode %d\n", priv->ps_mode); 734 IWL_ERROR("invalide mimo ps mode %d\n",
735 priv->current_ht_config.sm_ps);
734 WARN_ON(1); 736 WARN_ON(1);
735 idle_cnt = -1; 737 idle_cnt = -1;
736 break; 738 break;
@@ -738,6 +740,17 @@ static int iwl_get_idle_rx_chain_count(struct iwl_priv *priv, int active_cnt)
738 return idle_cnt; 740 return idle_cnt;
739} 741}
740 742
743/* up to 4 chains */
744static u8 iwl_count_chain_bitmap(u32 chain_bitmap)
745{
746 u8 res;
747 res = (chain_bitmap & BIT(0)) >> 0;
748 res += (chain_bitmap & BIT(1)) >> 1;
749 res += (chain_bitmap & BIT(2)) >> 2;
750 res += (chain_bitmap & BIT(4)) >> 4;
751 return res;
752}
753
741/** 754/**
742 * iwl_set_rxon_chain - Set up Rx chain usage in "staging" RXON image 755 * iwl_set_rxon_chain - Set up Rx chain usage in "staging" RXON image
743 * 756 *
@@ -748,25 +761,35 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
748{ 761{
749 bool is_single = is_single_rx_stream(priv); 762 bool is_single = is_single_rx_stream(priv);
750 bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status); 763 bool is_cam = !test_bit(STATUS_POWER_PMI, &priv->status);
751 u8 idle_rx_cnt, active_rx_cnt; 764 u8 idle_rx_cnt, active_rx_cnt, valid_rx_cnt;
765 u32 active_chains;
752 u16 rx_chain; 766 u16 rx_chain;
753 767
754 /* Tell uCode which antennas are actually connected. 768 /* Tell uCode which antennas are actually connected.
755 * Before first association, we assume all antennas are connected. 769 * Before first association, we assume all antennas are connected.
756 * Just after first association, iwl_chain_noise_calibration() 770 * Just after first association, iwl_chain_noise_calibration()
757 * checks which antennas actually *are* connected. */ 771 * checks which antennas actually *are* connected. */
758 rx_chain = priv->hw_params.valid_rx_ant << RXON_RX_CHAIN_VALID_POS; 772 if (priv->chain_noise_data.active_chains)
773 active_chains = priv->chain_noise_data.active_chains;
774 else
775 active_chains = priv->hw_params.valid_rx_ant;
776
777 rx_chain = active_chains << RXON_RX_CHAIN_VALID_POS;
759 778
760 /* How many receivers should we use? */ 779 /* How many receivers should we use? */
761 active_rx_cnt = iwl_get_active_rx_chain_count(priv); 780 active_rx_cnt = iwl_get_active_rx_chain_count(priv);
762 idle_rx_cnt = iwl_get_idle_rx_chain_count(priv, active_rx_cnt); 781 idle_rx_cnt = iwl_get_idle_rx_chain_count(priv, active_rx_cnt);
763 782
764 /* correct rx chain count accoridng hw settings */
765 if (priv->hw_params.rx_chains_num < active_rx_cnt)
766 active_rx_cnt = priv->hw_params.rx_chains_num;
767 783
768 if (priv->hw_params.rx_chains_num < idle_rx_cnt) 784 /* correct rx chain count according hw settings
769 idle_rx_cnt = priv->hw_params.rx_chains_num; 785 * and chain noise calibration
786 */
787 valid_rx_cnt = iwl_count_chain_bitmap(active_chains);
788 if (valid_rx_cnt < active_rx_cnt)
789 active_rx_cnt = valid_rx_cnt;
790
791 if (valid_rx_cnt < idle_rx_cnt)
792 idle_rx_cnt = valid_rx_cnt;
770 793
771 rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS; 794 rx_chain |= active_rx_cnt << RXON_RX_CHAIN_MIMO_CNT_POS;
772 rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS; 795 rx_chain |= idle_rx_cnt << RXON_RX_CHAIN_CNT_POS;
@@ -778,7 +801,7 @@ void iwl_set_rxon_chain(struct iwl_priv *priv)
778 else 801 else
779 priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; 802 priv->staging_rxon.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK;
780 803
781 IWL_DEBUG_ASSOC("rx_chain=0x%Xi active=%d idle=%d\n", 804 IWL_DEBUG_ASSOC("rx_chain=0x%X active=%d idle=%d\n",
782 priv->staging_rxon.rx_chain, 805 priv->staging_rxon.rx_chain,
783 active_rx_cnt, idle_rx_cnt); 806 active_rx_cnt, idle_rx_cnt);
784 807
@@ -912,7 +935,7 @@ int iwl_init_drv(struct iwl_priv *priv)
912 priv->iw_mode = IEEE80211_IF_TYPE_STA; 935 priv->iw_mode = IEEE80211_IF_TYPE_STA;
913 936
914 priv->use_ant_b_for_management_frame = 1; /* start with ant B */ 937 priv->use_ant_b_for_management_frame = 1; /* start with ant B */
915 priv->ps_mode = IWL_MIMO_PS_NONE; 938 priv->current_ht_config.sm_ps = WLAN_HT_CAP_SM_PS_DISABLED;
916 939
917 /* Choose which receivers/antennas to use */ 940 /* Choose which receivers/antennas to use */
918 iwl_set_rxon_chain(priv); 941 iwl_set_rxon_chain(priv);
@@ -1135,7 +1158,6 @@ int iwl_verify_ucode(struct iwl_priv *priv)
1135} 1158}
1136EXPORT_SYMBOL(iwl_verify_ucode); 1159EXPORT_SYMBOL(iwl_verify_ucode);
1137 1160
1138
1139static const char *desc_lookup(int i) 1161static const char *desc_lookup(int i)
1140{ 1162{
1141 switch (i) { 1163 switch (i) {
@@ -1216,9 +1238,9 @@ EXPORT_SYMBOL(iwl_dump_nic_error_log);
1216/** 1238/**
1217 * iwl_print_event_log - Dump error event log to syslog 1239 * iwl_print_event_log - Dump error event log to syslog
1218 * 1240 *
1219 * NOTE: Must be called with iwl4965_grab_nic_access() already obtained! 1241 * NOTE: Must be called with iwl_grab_nic_access() already obtained!
1220 */ 1242 */
1221void iwl_print_event_log(struct iwl_priv *priv, u32 start_idx, 1243static void iwl_print_event_log(struct iwl_priv *priv, u32 start_idx,
1222 u32 num_events, u32 mode) 1244 u32 num_events, u32 mode)
1223{ 1245{
1224 u32 i; 1246 u32 i;
@@ -1259,8 +1281,6 @@ void iwl_print_event_log(struct iwl_priv *priv, u32 start_idx,
1259 } 1281 }
1260 } 1282 }
1261} 1283}
1262EXPORT_SYMBOL(iwl_print_event_log);
1263
1264 1284
1265void iwl_dump_nic_event_log(struct iwl_priv *priv) 1285void iwl_dump_nic_event_log(struct iwl_priv *priv)
1266{ 1286{
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h
index b5db050b22d1..55a4b584ce07 100644
--- a/drivers/net/wireless/iwlwifi/iwl-core.h
+++ b/drivers/net/wireless/iwlwifi/iwl-core.h
@@ -184,7 +184,6 @@ struct iwl_cfg {
184struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg, 184struct ieee80211_hw *iwl_alloc_all(struct iwl_cfg *cfg,
185 struct ieee80211_ops *hw_ops); 185 struct ieee80211_ops *hw_ops);
186void iwl_hw_detect(struct iwl_priv *priv); 186void iwl_hw_detect(struct iwl_priv *priv);
187
188void iwl_clear_stations_table(struct iwl_priv *priv); 187void iwl_clear_stations_table(struct iwl_priv *priv);
189void iwl_reset_qos(struct iwl_priv *priv); 188void iwl_reset_qos(struct iwl_priv *priv);
190void iwl_set_rxon_chain(struct iwl_priv *priv); 189void iwl_set_rxon_chain(struct iwl_priv *priv);
@@ -215,7 +214,6 @@ void iwl_rx_replenish(struct iwl_priv *priv);
215int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq); 214int iwl_rx_init(struct iwl_priv *priv, struct iwl_rx_queue *rxq);
216int iwl_rx_agg_start(struct iwl_priv *priv, const u8 *addr, int tid, u16 ssn); 215int iwl_rx_agg_start(struct iwl_priv *priv, const u8 *addr, int tid, u16 ssn);
217int iwl_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid); 216int iwl_rx_agg_stop(struct iwl_priv *priv, const u8 *addr, int tid);
218/* FIXME: remove when TX is moved to iwl core */
219int iwl_rx_queue_restock(struct iwl_priv *priv); 217int iwl_rx_queue_restock(struct iwl_priv *priv);
220int iwl_rx_queue_space(const struct iwl_rx_queue *q); 218int iwl_rx_queue_space(const struct iwl_rx_queue *q);
221void iwl_rx_allocate(struct iwl_priv *priv); 219void iwl_rx_allocate(struct iwl_priv *priv);
@@ -234,11 +232,7 @@ void iwl_rx_statistics(struct iwl_priv *priv,
234******************************************************/ 232******************************************************/
235int iwl_txq_ctx_reset(struct iwl_priv *priv); 233int iwl_txq_ctx_reset(struct iwl_priv *priv);
236int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb); 234int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb);
237/* FIXME: remove when free Tx is fully merged into iwlcore */
238int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq);
239void iwl_hw_txq_ctx_free(struct iwl_priv *priv); 235void iwl_hw_txq_ctx_free(struct iwl_priv *priv);
240int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *tfd,
241 dma_addr_t addr, u16 len);
242int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq); 236int iwl_txq_update_write_ptr(struct iwl_priv *priv, struct iwl_tx_queue *txq);
243int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn); 237int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn);
244int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid); 238int iwl_tx_agg_stop(struct iwl_priv *priv , const u8 *ra, u16 tid);
@@ -253,6 +247,7 @@ int iwl_set_tx_power(struct iwl_priv *priv, s8 tx_power, bool force);
253 * RF -Kill - here and not in iwl-rfkill.h to be available when 247 * RF -Kill - here and not in iwl-rfkill.h to be available when
254 * RF-kill subsystem is not compiled. 248 * RF-kill subsystem is not compiled.
255 ****************************************************/ 249 ****************************************************/
250void iwl_rf_kill(struct iwl_priv *priv);
256void iwl_radio_kill_sw_disable_radio(struct iwl_priv *priv); 251void iwl_radio_kill_sw_disable_radio(struct iwl_priv *priv);
257int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv); 252int iwl_radio_kill_sw_enable_radio(struct iwl_priv *priv);
258 253
@@ -283,7 +278,6 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags)
283void iwl_init_scan_params(struct iwl_priv *priv); 278void iwl_init_scan_params(struct iwl_priv *priv);
284int iwl_scan_cancel(struct iwl_priv *priv); 279int iwl_scan_cancel(struct iwl_priv *priv);
285int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 280int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms);
286const char *iwl_escape_essid(const char *essid, u8 essid_len);
287int iwl_scan_initiate(struct iwl_priv *priv); 281int iwl_scan_initiate(struct iwl_priv *priv);
288void iwl_setup_rx_scan_handlers(struct iwl_priv *priv); 282void iwl_setup_rx_scan_handlers(struct iwl_priv *priv);
289void iwl_setup_scan_deferred_work(struct iwl_priv *priv); 283void iwl_setup_scan_deferred_work(struct iwl_priv *priv);
@@ -316,8 +310,6 @@ int iwl_enqueue_hcmd(struct iwl_priv *priv, struct iwl_host_cmd *cmd);
316/***************************************************** 310/*****************************************************
317* Error Handling Debugging 311* Error Handling Debugging
318******************************************************/ 312******************************************************/
319void iwl_print_event_log(struct iwl_priv *priv, u32 start_idx,
320 u32 num_events, u32 mode);
321void iwl_dump_nic_error_log(struct iwl_priv *priv); 313void iwl_dump_nic_error_log(struct iwl_priv *priv);
322void iwl_dump_nic_event_log(struct iwl_priv *priv); 314void iwl_dump_nic_event_log(struct iwl_priv *priv);
323 315
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h
index 640ceea913c7..1823687e5820 100644
--- a/drivers/net/wireless/iwlwifi/iwl-dev.h
+++ b/drivers/net/wireless/iwlwifi/iwl-dev.h
@@ -406,6 +406,7 @@ struct iwl_ht_info {
406 /* self configuration data */ 406 /* self configuration data */
407 u8 is_ht; 407 u8 is_ht;
408 u8 supported_chan_width; 408 u8 supported_chan_width;
409 u8 sm_ps;
409 u8 is_green_field; 410 u8 is_green_field;
410 u8 sgf; /* HT_SHORT_GI_* short guard interval */ 411 u8 sgf; /* HT_SHORT_GI_* short guard interval */
411 u8 max_amsdu_size; 412 u8 max_amsdu_size;
@@ -564,50 +565,31 @@ struct iwl_hw_params {
564#define IWL_RX_STATS(x) (&x->u.rx_frame.stats) 565#define IWL_RX_STATS(x) (&x->u.rx_frame.stats)
565#define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload) 566#define IWL_RX_DATA(x) (IWL_RX_HDR(x)->payload)
566 567
567
568/******************************************************************************
569 *
570 * Functions implemented in iwl-base.c which are forward declared here
571 * for use by iwl-*.c
572 *
573 *****************************************************************************/
574struct iwl_addsta_cmd;
575extern int iwl_send_add_sta(struct iwl_priv *priv,
576 struct iwl_addsta_cmd *sta, u8 flags);
577u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr, int is_ap,
578 u8 flags, struct ieee80211_ht_info *ht_info);
579extern unsigned int iwl4965_fill_beacon_frame(struct iwl_priv *priv,
580 struct ieee80211_hdr *hdr,
581 const u8 *dest, int left);
582extern void iwl4965_update_chain_flags(struct iwl_priv *priv);
583int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
584extern int iwl4965_set_power(struct iwl_priv *priv, void *cmd);
585
586extern const u8 iwl_bcast_addr[ETH_ALEN];
587
588/****************************************************************************** 568/******************************************************************************
589 * 569 *
590 * Functions implemented in iwl-[34]*.c which are forward declared here 570 * Functions implemented in core module which are forward declared here
591 * for use by iwl-base.c 571 * for use by iwl-[4-5].c
592 * 572 *
593 * NOTE: The implementation of these functions are hardware specific 573 * NOTE: The implementation of these functions are not hardware specific
594 * which is why they are in the hardware specific files (vs. iwl-base.c) 574 * which is why they are in the core module files.
595 * 575 *
596 * Naming convention -- 576 * Naming convention --
597 * iwl4965_ <-- Its part of iwlwifi (should be changed to iwl4965_) 577 * iwl_ <-- Is part of iwlwifi
598 * iwl4965_hw_ <-- Hardware specific (implemented in iwl-XXXX.c by all HW)
599 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX) 578 * iwlXXXX_ <-- Hardware specific (implemented in iwl-XXXX.c for XXXX)
600 * iwl4965_bg_ <-- Called from work queue context 579 * iwl4965_bg_ <-- Called from work queue context
601 * iwl4965_mac_ <-- mac80211 callback 580 * iwl4965_mac_ <-- mac80211 callback
602 * 581 *
603 ****************************************************************************/ 582 ****************************************************************************/
583struct iwl_addsta_cmd;
584extern int iwl_send_add_sta(struct iwl_priv *priv,
585 struct iwl_addsta_cmd *sta, u8 flags);
586extern u8 iwl_add_station_flags(struct iwl_priv *priv, const u8 *addr,
587 int is_ap, u8 flags, struct ieee80211_ht_info *ht_info);
588extern void iwl4965_update_chain_flags(struct iwl_priv *priv);
589extern int iwl4965_set_pwr_src(struct iwl_priv *priv, enum iwl_pwr_src src);
590extern const u8 iwl_bcast_addr[ETH_ALEN];
604extern int iwl_rxq_stop(struct iwl_priv *priv); 591extern int iwl_rxq_stop(struct iwl_priv *priv);
605extern void iwl_txq_ctx_stop(struct iwl_priv *priv); 592extern void iwl_txq_ctx_stop(struct iwl_priv *priv);
606extern unsigned int iwl4965_hw_get_beacon_cmd(struct iwl_priv *priv,
607 struct iwl_frame *frame, u8 rate);
608extern void iwl4965_disable_events(struct iwl_priv *priv);
609
610extern int iwl4965_hw_channel_switch(struct iwl_priv *priv, u16 channel);
611extern int iwl_queue_space(const struct iwl_queue *q); 593extern int iwl_queue_space(const struct iwl_queue *q);
612static inline int iwl_queue_used(const struct iwl_queue *q, int i) 594static inline int iwl_queue_used(const struct iwl_queue *q, int i)
613{ 595{
@@ -644,11 +626,6 @@ struct iwl_kw {
644#define IWL_CHANNEL_WIDTH_20MHZ 0 626#define IWL_CHANNEL_WIDTH_20MHZ 0
645#define IWL_CHANNEL_WIDTH_40MHZ 1 627#define IWL_CHANNEL_WIDTH_40MHZ 1
646 628
647#define IWL_MIMO_PS_STATIC 0
648#define IWL_MIMO_PS_NONE 3
649#define IWL_MIMO_PS_DYNAMIC 1
650#define IWL_MIMO_PS_INVALID 2
651
652#define IWL_OPERATION_MODE_AUTO 0 629#define IWL_OPERATION_MODE_AUTO 0
653#define IWL_OPERATION_MODE_HT_ONLY 1 630#define IWL_OPERATION_MODE_HT_ONLY 1
654#define IWL_OPERATION_MODE_MIXED 2 631#define IWL_OPERATION_MODE_MIXED 2
@@ -703,8 +680,9 @@ enum iwl4965_false_alarm_state {
703 680
704enum iwl4965_chain_noise_state { 681enum iwl4965_chain_noise_state {
705 IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */ 682 IWL_CHAIN_NOISE_ALIVE = 0, /* must be 0 */
706 IWL_CHAIN_NOISE_ACCUMULATE = 1, 683 IWL_CHAIN_NOISE_ACCUMULATE,
707 IWL_CHAIN_NOISE_CALIBRATED = 2, 684 IWL_CHAIN_NOISE_CALIBRATED,
685 IWL_CHAIN_NOISE_DONE,
708}; 686};
709 687
710enum iwl4965_calib_enabled_state { 688enum iwl4965_calib_enabled_state {
@@ -762,17 +740,18 @@ struct iwl_sensitivity_data {
762 740
763/* Chain noise (differential Rx gain) calib data */ 741/* Chain noise (differential Rx gain) calib data */
764struct iwl_chain_noise_data { 742struct iwl_chain_noise_data {
765 u8 state; 743 u32 active_chains;
766 u16 beacon_count;
767 u32 chain_noise_a; 744 u32 chain_noise_a;
768 u32 chain_noise_b; 745 u32 chain_noise_b;
769 u32 chain_noise_c; 746 u32 chain_noise_c;
770 u32 chain_signal_a; 747 u32 chain_signal_a;
771 u32 chain_signal_b; 748 u32 chain_signal_b;
772 u32 chain_signal_c; 749 u32 chain_signal_c;
750 u16 beacon_count;
773 u8 disconn_array[NUM_RX_CHAINS]; 751 u8 disconn_array[NUM_RX_CHAINS];
774 u8 delta_gain_code[NUM_RX_CHAINS]; 752 u8 delta_gain_code[NUM_RX_CHAINS];
775 u8 radio_write; 753 u8 radio_write;
754 u8 state;
776}; 755};
777 756
778#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */ 757#define EEPROM_SEM_TIMEOUT 10 /* milliseconds */
@@ -995,7 +974,6 @@ struct iwl_priv {
995 * hardware */ 974 * hardware */
996 u16 assoc_id; 975 u16 assoc_id;
997 u16 assoc_capability; 976 u16 assoc_capability;
998 u8 ps_mode;
999 977
1000 struct iwl_qos_info qos_data; 978 struct iwl_qos_info qos_data;
1001 979
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.c b/drivers/net/wireless/iwlwifi/iwl-power.c
index 16f834d0c486..55ec31ec9e15 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.c
+++ b/drivers/net/wireless/iwlwifi/iwl-power.c
@@ -250,17 +250,26 @@ static int iwl_update_power_command(struct iwl_priv *priv,
250 250
251 251
252/* 252/*
253 * calucaute the final power mode index 253 * compute the final power mode index
254 */ 254 */
255int iwl_power_update_mode(struct iwl_priv *priv, u8 refresh) 255int iwl_power_update_mode(struct iwl_priv *priv, bool force)
256{ 256{
257 struct iwl_power_mgr *setting = &(priv->power_data); 257 struct iwl_power_mgr *setting = &(priv->power_data);
258 int ret = 0; 258 int ret = 0;
259 u16 uninitialized_var(final_mode); 259 u16 uninitialized_var(final_mode);
260 260
261 /* If on battery, set to 3, 261 /* Don't update the RX chain when chain noise calibration is running */
262 * if plugged into AC power, set to CAM ("continuously aware mode"), 262 if (priv->chain_noise_data.state != IWL_CHAIN_NOISE_DONE &&
263 * else user level */ 263 priv->chain_noise_data.state != IWL_CHAIN_NOISE_ALIVE) {
264 IWL_DEBUG_POWER("Cannot update the power, chain noise "
265 "calibration running: %d\n",
266 priv->chain_noise_data.state);
267 return -EAGAIN;
268 }
269
270 /* If on battery, set to 3,
271 * if plugged into AC power, set to CAM ("continuously aware mode"),
272 * else user level */
264 273
265 switch (setting->system_power_setting) { 274 switch (setting->system_power_setting) {
266 case IWL_POWER_SYS_AUTO: 275 case IWL_POWER_SYS_AUTO:
@@ -285,7 +294,7 @@ int iwl_power_update_mode(struct iwl_priv *priv, u8 refresh)
285 final_mode = IWL_POWER_MODE_CAM; 294 final_mode = IWL_POWER_MODE_CAM;
286 295
287 if (!iwl_is_rfkill(priv) && !setting->power_disabled && 296 if (!iwl_is_rfkill(priv) && !setting->power_disabled &&
288 ((setting->power_mode != final_mode) || refresh)) { 297 ((setting->power_mode != final_mode) || force)) {
289 struct iwl_powertable_cmd cmd; 298 struct iwl_powertable_cmd cmd;
290 299
291 if (final_mode != IWL_POWER_MODE_CAM) 300 if (final_mode != IWL_POWER_MODE_CAM)
@@ -359,35 +368,26 @@ EXPORT_SYMBOL(iwl_power_enable_management);
359/* set user_power_setting */ 368/* set user_power_setting */
360int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode) 369int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode)
361{ 370{
362 int ret = 0;
363
364 if (mode > IWL_POWER_LIMIT) 371 if (mode > IWL_POWER_LIMIT)
365 return -EINVAL; 372 return -EINVAL;
366 373
367 priv->power_data.user_power_setting = mode; 374 priv->power_data.user_power_setting = mode;
368 375
369 ret = iwl_power_update_mode(priv, 0); 376 return iwl_power_update_mode(priv, 0);
370
371 return ret;
372} 377}
373EXPORT_SYMBOL(iwl_power_set_user_mode); 378EXPORT_SYMBOL(iwl_power_set_user_mode);
374 379
375
376/* set system_power_setting. This should be set by over all 380/* set system_power_setting. This should be set by over all
377 * PM application. 381 * PM application.
378 */ 382 */
379int iwl_power_set_system_mode(struct iwl_priv *priv, u16 mode) 383int iwl_power_set_system_mode(struct iwl_priv *priv, u16 mode)
380{ 384{
381 int ret = 0;
382
383 if (mode > IWL_POWER_LIMIT) 385 if (mode > IWL_POWER_LIMIT)
384 return -EINVAL; 386 return -EINVAL;
385 387
386 priv->power_data.system_power_setting = mode; 388 priv->power_data.system_power_setting = mode;
387 389
388 ret = iwl_power_update_mode(priv, 0); 390 return iwl_power_update_mode(priv, 0);
389
390 return ret;
391} 391}
392EXPORT_SYMBOL(iwl_power_set_system_mode); 392EXPORT_SYMBOL(iwl_power_set_system_mode);
393 393
diff --git a/drivers/net/wireless/iwlwifi/iwl-power.h b/drivers/net/wireless/iwlwifi/iwl-power.h
index aa99f3647def..df484a90ae64 100644
--- a/drivers/net/wireless/iwlwifi/iwl-power.h
+++ b/drivers/net/wireless/iwlwifi/iwl-power.h
@@ -72,7 +72,7 @@ struct iwl_power_mgr {
72 /* final power level that used to calculate final power command */ 72 /* final power level that used to calculate final power command */
73 u8 power_mode; 73 u8 power_mode;
74 u8 user_power_setting; /* set by user through mac80211 or sysfs */ 74 u8 user_power_setting; /* set by user through mac80211 or sysfs */
75 u8 system_power_setting; /* set by kernel syatem tools */ 75 u8 system_power_setting; /* set by kernel system tools */
76 u8 critical_power_setting; /* set if driver over heated */ 76 u8 critical_power_setting; /* set if driver over heated */
77 u8 is_battery_active; /* DC/AC power */ 77 u8 is_battery_active; /* DC/AC power */
78 u8 power_disabled; /* flag to disable using power saving level */ 78 u8 power_disabled; /* flag to disable using power saving level */
@@ -80,7 +80,7 @@ struct iwl_power_mgr {
80 80
81void iwl_setup_power_deferred_work(struct iwl_priv *priv); 81void iwl_setup_power_deferred_work(struct iwl_priv *priv);
82void iwl_power_cancel_timeout(struct iwl_priv *priv); 82void iwl_power_cancel_timeout(struct iwl_priv *priv);
83int iwl_power_update_mode(struct iwl_priv *priv, u8 refresh); 83int iwl_power_update_mode(struct iwl_priv *priv, bool force);
84int iwl_power_disable_management(struct iwl_priv *priv, u32 ms); 84int iwl_power_disable_management(struct iwl_priv *priv, u32 ms);
85int iwl_power_enable_management(struct iwl_priv *priv); 85int iwl_power_enable_management(struct iwl_priv *priv);
86int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode); 86int iwl_power_set_user_mode(struct iwl_priv *priv, u16 mode);
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index 6c8ac3a87d54..d026aaf62335 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -88,7 +88,7 @@ static int iwl_is_empty_essid(const char *essid, int essid_len)
88 88
89 89
90 90
91const char *iwl_escape_essid(const char *essid, u8 essid_len) 91static const char *iwl_escape_essid(const char *essid, u8 essid_len)
92{ 92{
93 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1]; 93 static char escaped[IW_ESSID_MAX_SIZE * 2 + 1];
94 const char *s = essid; 94 const char *s = essid;
@@ -111,7 +111,6 @@ const char *iwl_escape_essid(const char *essid, u8 essid_len)
111 *d = '\0'; 111 *d = '\0';
112 return escaped; 112 return escaped;
113} 113}
114EXPORT_SYMBOL(iwl_escape_essid);
115 114
116/** 115/**
117 * iwl_scan_cancel - Cancel any currently executing HW scan 116 * iwl_scan_cancel - Cancel any currently executing HW scan
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c
index 5b7b05c8773f..a72569f1acb5 100644
--- a/drivers/net/wireless/iwlwifi/iwl-sta.c
+++ b/drivers/net/wireless/iwlwifi/iwl-sta.c
@@ -191,20 +191,20 @@ static void iwl_set_ht_add_station(struct iwl_priv *priv, u8 index,
191 if (!sta_ht_inf || !sta_ht_inf->ht_supported) 191 if (!sta_ht_inf || !sta_ht_inf->ht_supported)
192 goto done; 192 goto done;
193 193
194 mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_MIMO_PS) >> 2; 194 mimo_ps_mode = (sta_ht_inf->cap & IEEE80211_HT_CAP_SM_PS) >> 2;
195 195
196 sta_flags = priv->stations[index].sta.station_flags; 196 sta_flags = priv->stations[index].sta.station_flags;
197 197
198 sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK); 198 sta_flags &= ~(STA_FLG_RTS_MIMO_PROT_MSK | STA_FLG_MIMO_DIS_MSK);
199 199
200 switch (mimo_ps_mode) { 200 switch (mimo_ps_mode) {
201 case WLAN_HT_CAP_MIMO_PS_STATIC: 201 case WLAN_HT_CAP_SM_PS_STATIC:
202 sta_flags |= STA_FLG_MIMO_DIS_MSK; 202 sta_flags |= STA_FLG_MIMO_DIS_MSK;
203 break; 203 break;
204 case WLAN_HT_CAP_MIMO_PS_DYNAMIC: 204 case WLAN_HT_CAP_SM_PS_DYNAMIC:
205 sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK; 205 sta_flags |= STA_FLG_RTS_MIMO_PROT_MSK;
206 break; 206 break;
207 case WLAN_HT_CAP_MIMO_PS_DISABLED: 207 case WLAN_HT_CAP_SM_PS_DISABLED:
208 break; 208 break;
209 default: 209 default:
210 IWL_WARNING("Invalid MIMO PS mode %d\n", mimo_ps_mode); 210 IWL_WARNING("Invalid MIMO PS mode %d\n", mimo_ps_mode);
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c
index 9d485aadef96..9d5bcf46cbe9 100644
--- a/drivers/net/wireless/iwlwifi/iwl-tx.c
+++ b/drivers/net/wireless/iwlwifi/iwl-tx.c
@@ -63,7 +63,7 @@ static const u16 default_tid_to_tx_fifo[] = {
63 * Does NOT advance any TFD circular buffer read/write indexes 63 * Does NOT advance any TFD circular buffer read/write indexes
64 * Does NOT free the TFD itself (which is within circular buffer) 64 * Does NOT free the TFD itself (which is within circular buffer)
65 */ 65 */
66int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq) 66static int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
67{ 67{
68 struct iwl_tfd_frame *bd_tmp = (struct iwl_tfd_frame *)&txq->bd[0]; 68 struct iwl_tfd_frame *bd_tmp = (struct iwl_tfd_frame *)&txq->bd[0];
69 struct iwl_tfd_frame *bd = &bd_tmp[txq->q.read_ptr]; 69 struct iwl_tfd_frame *bd = &bd_tmp[txq->q.read_ptr];
@@ -115,10 +115,8 @@ int iwl_hw_txq_free_tfd(struct iwl_priv *priv, struct iwl_tx_queue *txq)
115 } 115 }
116 return 0; 116 return 0;
117} 117}
118EXPORT_SYMBOL(iwl_hw_txq_free_tfd);
119 118
120 119static int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *ptr,
121int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *ptr,
122 dma_addr_t addr, u16 len) 120 dma_addr_t addr, u16 len)
123{ 121{
124 int index, is_odd; 122 int index, is_odd;
@@ -151,7 +149,6 @@ int iwl_hw_txq_attach_buf_to_tfd(struct iwl_priv *priv, void *ptr,
151 149
152 return 0; 150 return 0;
153} 151}
154EXPORT_SYMBOL(iwl_hw_txq_attach_buf_to_tfd);
155 152
156/** 153/**
157 * iwl_txq_update_write_ptr - Send new write index to hardware 154 * iwl_txq_update_write_ptr - Send new write index to hardware
@@ -478,7 +475,6 @@ void iwl_hw_txq_ctx_free(struct iwl_priv *priv)
478} 475}
479EXPORT_SYMBOL(iwl_hw_txq_ctx_free); 476EXPORT_SYMBOL(iwl_hw_txq_ctx_free);
480 477
481
482/** 478/**
483 * iwl_txq_ctx_reset - Reset TX queue context 479 * iwl_txq_ctx_reset - Reset TX queue context
484 * Destroys all DMA structures and initialise them again 480 * Destroys all DMA structures and initialise them again
@@ -545,6 +541,7 @@ int iwl_txq_ctx_reset(struct iwl_priv *priv)
545 error_kw: 541 error_kw:
546 return ret; 542 return ret;
547} 543}
544
548/** 545/**
549 * iwl_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory 546 * iwl_txq_ctx_stop - Stop all Tx DMA channels, free Tx queue memory
550 */ 547 */
diff --git a/drivers/net/wireless/libertas/cmd.c b/drivers/net/wireless/libertas/cmd.c
index 802547e79671..5fef05f3cd00 100644
--- a/drivers/net/wireless/libertas/cmd.c
+++ b/drivers/net/wireless/libertas/cmd.c
@@ -1971,6 +1971,70 @@ void lbs_ps_confirm_sleep(struct lbs_private *priv)
1971} 1971}
1972 1972
1973 1973
1974/**
1975 * @brief Configures the transmission power control functionality.
1976 *
1977 * @param priv A pointer to struct lbs_private structure
1978 * @param enable Transmission power control enable
1979 * @param p0 Power level when link quality is good (dBm).
1980 * @param p1 Power level when link quality is fair (dBm).
1981 * @param p2 Power level when link quality is poor (dBm).
1982 * @param usesnr Use Signal to Noise Ratio in TPC
1983 *
1984 * @return 0 on success
1985 */
1986int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1,
1987 int8_t p2, int usesnr)
1988{
1989 struct cmd_ds_802_11_tpc_cfg cmd;
1990 int ret;
1991
1992 memset(&cmd, 0, sizeof(cmd));
1993 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
1994 cmd.action = cpu_to_le16(CMD_ACT_SET);
1995 cmd.enable = !!enable;
1996 cmd.usesnr = !!enable;
1997 cmd.P0 = p0;
1998 cmd.P1 = p1;
1999 cmd.P2 = p2;
2000
2001 ret = lbs_cmd_with_response(priv, CMD_802_11_TPC_CFG, &cmd);
2002
2003 return ret;
2004}
2005
2006/**
2007 * @brief Configures the power adaptation settings.
2008 *
2009 * @param priv A pointer to struct lbs_private structure
2010 * @param enable Power adaptation enable
2011 * @param p0 Power level for 1, 2, 5.5 and 11 Mbps (dBm).
2012 * @param p1 Power level for 6, 9, 12, 18, 22, 24 and 36 Mbps (dBm).
2013 * @param p2 Power level for 48 and 54 Mbps (dBm).
2014 *
2015 * @return 0 on Success
2016 */
2017
2018int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0,
2019 int8_t p1, int8_t p2)
2020{
2021 struct cmd_ds_802_11_pa_cfg cmd;
2022 int ret;
2023
2024 memset(&cmd, 0, sizeof(cmd));
2025 cmd.hdr.size = cpu_to_le16(sizeof(cmd));
2026 cmd.action = cpu_to_le16(CMD_ACT_SET);
2027 cmd.enable = !!enable;
2028 cmd.P0 = p0;
2029 cmd.P1 = p1;
2030 cmd.P2 = p2;
2031
2032 ret = lbs_cmd_with_response(priv, CMD_802_11_PA_CFG , &cmd);
2033
2034 return ret;
2035}
2036
2037
1974static struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv, 2038static struct cmd_ctrl_node *__lbs_cmd_async(struct lbs_private *priv,
1975 uint16_t command, struct cmd_header *in_cmd, int in_cmd_size, 2039 uint16_t command, struct cmd_header *in_cmd, int in_cmd_size,
1976 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), 2040 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
diff --git a/drivers/net/wireless/libertas/cmd.h b/drivers/net/wireless/libertas/cmd.h
index 11ac996e895e..336a181d857a 100644
--- a/drivers/net/wireless/libertas/cmd.h
+++ b/drivers/net/wireless/libertas/cmd.h
@@ -26,6 +26,12 @@ int __lbs_cmd(struct lbs_private *priv, uint16_t command,
26 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *), 26 int (*callback)(struct lbs_private *, unsigned long, struct cmd_header *),
27 unsigned long callback_arg); 27 unsigned long callback_arg);
28 28
29int lbs_set_power_adapt_cfg(struct lbs_private *priv, int enable, int8_t p0,
30 int8_t p1, int8_t p2);
31
32int lbs_set_tpc_cfg(struct lbs_private *priv, int enable, int8_t p0, int8_t p1,
33 int8_t p2, int usesnr);
34
29int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra, 35int lbs_cmd_copyback(struct lbs_private *priv, unsigned long extra,
30 struct cmd_header *resp); 36 struct cmd_header *resp);
31 37
diff --git a/drivers/net/wireless/libertas/defs.h b/drivers/net/wireless/libertas/defs.h
index 4b2428ac2223..c89d7a1041a8 100644
--- a/drivers/net/wireless/libertas/defs.h
+++ b/drivers/net/wireless/libertas/defs.h
@@ -189,6 +189,15 @@ static inline void lbs_deb_hex(unsigned int grp, const char *prompt, u8 *buf, in
189#define MRVDRV_CMD_UPLD_RDY 0x0008 189#define MRVDRV_CMD_UPLD_RDY 0x0008
190#define MRVDRV_CARDEVENT 0x0010 190#define MRVDRV_CARDEVENT 0x0010
191 191
192
193/* Automatic TX control default levels */
194#define POW_ADAPT_DEFAULT_P0 13
195#define POW_ADAPT_DEFAULT_P1 15
196#define POW_ADAPT_DEFAULT_P2 18
197#define TPC_DEFAULT_P0 5
198#define TPC_DEFAULT_P1 10
199#define TPC_DEFAULT_P2 13
200
192/** TxPD status */ 201/** TxPD status */
193 202
194/* Station firmware use TxPD status field to report final Tx transmit 203/* Station firmware use TxPD status field to report final Tx transmit
diff --git a/drivers/net/wireless/libertas/host.h b/drivers/net/wireless/libertas/host.h
index da618fc997ce..a916bb9bd5da 100644
--- a/drivers/net/wireless/libertas/host.h
+++ b/drivers/net/wireless/libertas/host.h
@@ -83,6 +83,7 @@
83#define CMD_802_11_INACTIVITY_TIMEOUT 0x0067 83#define CMD_802_11_INACTIVITY_TIMEOUT 0x0067
84#define CMD_802_11_SLEEP_PERIOD 0x0068 84#define CMD_802_11_SLEEP_PERIOD 0x0068
85#define CMD_802_11_TPC_CFG 0x0072 85#define CMD_802_11_TPC_CFG 0x0072
86#define CMD_802_11_PA_CFG 0x0073
86#define CMD_802_11_FW_WAKE_METHOD 0x0074 87#define CMD_802_11_FW_WAKE_METHOD 0x0074
87#define CMD_802_11_SUBSCRIBE_EVENT 0x0075 88#define CMD_802_11_SUBSCRIBE_EVENT 0x0075
88#define CMD_802_11_RATE_ADAPT_RATESET 0x0076 89#define CMD_802_11_RATE_ADAPT_RATESET 0x0076
diff --git a/drivers/net/wireless/libertas/hostcmd.h b/drivers/net/wireless/libertas/hostcmd.h
index d27c276b2191..630b79967560 100644
--- a/drivers/net/wireless/libertas/hostcmd.h
+++ b/drivers/net/wireless/libertas/hostcmd.h
@@ -607,14 +607,28 @@ struct cmd_ds_802_11_eeprom_access {
607} __attribute__ ((packed)); 607} __attribute__ ((packed));
608 608
609struct cmd_ds_802_11_tpc_cfg { 609struct cmd_ds_802_11_tpc_cfg {
610 struct cmd_header hdr;
611
610 __le16 action; 612 __le16 action;
611 u8 enable; 613 uint8_t enable;
612 s8 P0; 614 int8_t P0;
613 s8 P1; 615 int8_t P1;
614 s8 P2; 616 int8_t P2;
615 u8 usesnr; 617 uint8_t usesnr;
616} __attribute__ ((packed)); 618} __attribute__ ((packed));
617 619
620
621struct cmd_ds_802_11_pa_cfg {
622 struct cmd_header hdr;
623
624 __le16 action;
625 uint8_t enable;
626 int8_t P0;
627 int8_t P1;
628 int8_t P2;
629} __attribute__ ((packed));
630
631
618struct cmd_ds_802_11_led_ctrl { 632struct cmd_ds_802_11_led_ctrl {
619 __le16 action; 633 __le16 action;
620 __le16 numled; 634 __le16 numled;
diff --git a/drivers/net/wireless/libertas/main.c b/drivers/net/wireless/libertas/main.c
index 2436634b6b7e..73dc8c72402a 100644
--- a/drivers/net/wireless/libertas/main.c
+++ b/drivers/net/wireless/libertas/main.c
@@ -1205,7 +1205,13 @@ void lbs_remove_card(struct lbs_private *priv)
1205 cancel_delayed_work_sync(&priv->scan_work); 1205 cancel_delayed_work_sync(&priv->scan_work);
1206 cancel_delayed_work_sync(&priv->assoc_work); 1206 cancel_delayed_work_sync(&priv->assoc_work);
1207 cancel_work_sync(&priv->mcast_work); 1207 cancel_work_sync(&priv->mcast_work);
1208
1209 /* worker thread destruction blocks on the in-flight command which
1210 * should have been cleared already in lbs_stop_card().
1211 */
1212 lbs_deb_main("destroying worker thread\n");
1208 destroy_workqueue(priv->work_thread); 1213 destroy_workqueue(priv->work_thread);
1214 lbs_deb_main("done destroying worker thread\n");
1209 1215
1210 if (priv->psmode == LBS802_11POWERMODEMAX_PSP) { 1216 if (priv->psmode == LBS802_11POWERMODEMAX_PSP) {
1211 priv->psmode = LBS802_11POWERMODECAM; 1217 priv->psmode = LBS802_11POWERMODECAM;
@@ -1323,14 +1329,26 @@ void lbs_stop_card(struct lbs_private *priv)
1323 device_remove_file(&dev->dev, &dev_attr_lbs_rtap); 1329 device_remove_file(&dev->dev, &dev_attr_lbs_rtap);
1324 } 1330 }
1325 1331
1326 /* Flush pending command nodes */ 1332 /* Delete the timeout of the currently processing command */
1327 del_timer_sync(&priv->command_timer); 1333 del_timer_sync(&priv->command_timer);
1334
1335 /* Flush pending command nodes */
1328 spin_lock_irqsave(&priv->driver_lock, flags); 1336 spin_lock_irqsave(&priv->driver_lock, flags);
1337 lbs_deb_main("clearing pending commands\n");
1329 list_for_each_entry(cmdnode, &priv->cmdpendingq, list) { 1338 list_for_each_entry(cmdnode, &priv->cmdpendingq, list) {
1330 cmdnode->result = -ENOENT; 1339 cmdnode->result = -ENOENT;
1331 cmdnode->cmdwaitqwoken = 1; 1340 cmdnode->cmdwaitqwoken = 1;
1332 wake_up_interruptible(&cmdnode->cmdwait_q); 1341 wake_up_interruptible(&cmdnode->cmdwait_q);
1333 } 1342 }
1343
1344 /* Flush the command the card is currently processing */
1345 if (priv->cur_cmd) {
1346 lbs_deb_main("clearing current command\n");
1347 priv->cur_cmd->result = -ENOENT;
1348 priv->cur_cmd->cmdwaitqwoken = 1;
1349 wake_up_interruptible(&priv->cur_cmd->cmdwait_q);
1350 }
1351 lbs_deb_main("done clearing commands\n");
1334 spin_unlock_irqrestore(&priv->driver_lock, flags); 1352 spin_unlock_irqrestore(&priv->driver_lock, flags);
1335 1353
1336 unregister_netdev(dev); 1354 unregister_netdev(dev);
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c
index 426f1fe3bb42..e8cadad2c863 100644
--- a/drivers/net/wireless/libertas/wext.c
+++ b/drivers/net/wireless/libertas/wext.c
@@ -1820,7 +1820,21 @@ static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
1820 } 1820 }
1821 1821
1822 if (vwrq->fixed == 0) { 1822 if (vwrq->fixed == 0) {
1823 /* Auto power control */ 1823 /* User requests automatic tx power control, however there are
1824 * many auto tx settings. For now use firmware defaults until
1825 * we come up with a good way to expose these to the user. */
1826 if (priv->fwrelease < 0x09000000) {
1827 ret = lbs_set_power_adapt_cfg(priv, 1,
1828 POW_ADAPT_DEFAULT_P0,
1829 POW_ADAPT_DEFAULT_P1,
1830 POW_ADAPT_DEFAULT_P2);
1831 if (ret)
1832 goto out;
1833 }
1834 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1835 TPC_DEFAULT_P2, 1);
1836 if (ret)
1837 goto out;
1824 dbm = priv->txpower_max; 1838 dbm = priv->txpower_max;
1825 } else { 1839 } else {
1826 /* Userspace check in iwrange if it should use dBm or mW, 1840 /* Userspace check in iwrange if it should use dBm or mW,
@@ -1830,7 +1844,8 @@ static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
1830 goto out; 1844 goto out;
1831 } 1845 }
1832 1846
1833 /* Validate requested power level against firmware allowed levels */ 1847 /* Validate requested power level against firmware allowed
1848 * levels */
1834 if (priv->txpower_min && (dbm < priv->txpower_min)) { 1849 if (priv->txpower_min && (dbm < priv->txpower_min)) {
1835 ret = -EINVAL; 1850 ret = -EINVAL;
1836 goto out; 1851 goto out;
@@ -1840,6 +1855,18 @@ static int lbs_set_txpow(struct net_device *dev, struct iw_request_info *info,
1840 ret = -EINVAL; 1855 ret = -EINVAL;
1841 goto out; 1856 goto out;
1842 } 1857 }
1858 if (priv->fwrelease < 0x09000000) {
1859 ret = lbs_set_power_adapt_cfg(priv, 0,
1860 POW_ADAPT_DEFAULT_P0,
1861 POW_ADAPT_DEFAULT_P1,
1862 POW_ADAPT_DEFAULT_P2);
1863 if (ret)
1864 goto out;
1865 }
1866 ret = lbs_set_tpc_cfg(priv, 0, TPC_DEFAULT_P0, TPC_DEFAULT_P1,
1867 TPC_DEFAULT_P2, 1);
1868 if (ret)
1869 goto out;
1843 } 1870 }
1844 1871
1845 /* If the radio was off, turn it on */ 1872 /* If the radio was off, turn it on */
diff --git a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h
index 98d4f8e7d84d..1d0704fe146f 100644
--- a/drivers/net/wireless/p54/p54.h
+++ b/drivers/net/wireless/p54/p54.h
@@ -80,6 +80,7 @@ struct p54_common {
80 struct pda_channel_output_limit *output_limit; 80 struct pda_channel_output_limit *output_limit;
81 unsigned int output_limit_len; 81 unsigned int output_limit_len;
82 struct pda_pa_curve_data *curve_data; 82 struct pda_pa_curve_data *curve_data;
83 unsigned int filter_flags;
83 u16 rxhw; 84 u16 rxhw;
84 u8 version; 85 u8 version;
85 u8 rx_antenna; 86 u8 rx_antenna;
@@ -87,7 +88,15 @@ struct p54_common {
87 void *cached_vdcf; 88 void *cached_vdcf;
88 unsigned int fw_var; 89 unsigned int fw_var;
89 unsigned int fw_interface; 90 unsigned int fw_interface;
91 unsigned int output_power;
92 u32 tsf_low32;
93 u32 tsf_high32;
90 struct ieee80211_tx_queue_stats tx_stats[8]; 94 struct ieee80211_tx_queue_stats tx_stats[8];
95 struct ieee80211_low_level_stats stats;
96 struct timer_list stats_timer;
97 struct completion stats_comp;
98 void *cached_stats;
99 int noise;
91 void *eeprom; 100 void *eeprom;
92 struct completion eeprom_comp; 101 struct completion eeprom_comp;
93}; 102};
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c
index f96f7c7e6af5..da51786254dc 100644
--- a/drivers/net/wireless/p54/p54common.c
+++ b/drivers/net/wireless/p54/p54common.c
@@ -27,7 +27,7 @@ MODULE_DESCRIPTION("Softmac Prism54 common code");
27MODULE_LICENSE("GPL"); 27MODULE_LICENSE("GPL");
28MODULE_ALIAS("prism54common"); 28MODULE_ALIAS("prism54common");
29 29
30static struct ieee80211_rate p54_rates[] = { 30static struct ieee80211_rate p54_bgrates[] = {
31 { .bitrate = 10, .hw_value = 0, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 31 { .bitrate = 10, .hw_value = 0, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
32 { .bitrate = 20, .hw_value = 1, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 32 { .bitrate = 20, .hw_value = 1, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
33 { .bitrate = 55, .hw_value = 2, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, 33 { .bitrate = 55, .hw_value = 2, .flags = IEEE80211_RATE_SHORT_PREAMBLE },
@@ -42,7 +42,7 @@ static struct ieee80211_rate p54_rates[] = {
42 { .bitrate = 540, .hw_value = 11, }, 42 { .bitrate = 540, .hw_value = 11, },
43}; 43};
44 44
45static struct ieee80211_channel p54_channels[] = { 45static struct ieee80211_channel p54_bgchannels[] = {
46 { .center_freq = 2412, .hw_value = 1, }, 46 { .center_freq = 2412, .hw_value = 1, },
47 { .center_freq = 2417, .hw_value = 2, }, 47 { .center_freq = 2417, .hw_value = 2, },
48 { .center_freq = 2422, .hw_value = 3, }, 48 { .center_freq = 2422, .hw_value = 3, },
@@ -60,10 +60,66 @@ static struct ieee80211_channel p54_channels[] = {
60}; 60};
61 61
62static struct ieee80211_supported_band band_2GHz = { 62static struct ieee80211_supported_band band_2GHz = {
63 .channels = p54_channels, 63 .channels = p54_bgchannels,
64 .n_channels = ARRAY_SIZE(p54_channels), 64 .n_channels = ARRAY_SIZE(p54_bgchannels),
65 .bitrates = p54_rates, 65 .bitrates = p54_bgrates,
66 .n_bitrates = ARRAY_SIZE(p54_rates), 66 .n_bitrates = ARRAY_SIZE(p54_bgrates),
67};
68
69static struct ieee80211_rate p54_arates[] = {
70 { .bitrate = 60, .hw_value = 4, },
71 { .bitrate = 90, .hw_value = 5, },
72 { .bitrate = 120, .hw_value = 6, },
73 { .bitrate = 180, .hw_value = 7, },
74 { .bitrate = 240, .hw_value = 8, },
75 { .bitrate = 360, .hw_value = 9, },
76 { .bitrate = 480, .hw_value = 10, },
77 { .bitrate = 540, .hw_value = 11, },
78};
79
80static struct ieee80211_channel p54_achannels[] = {
81 { .center_freq = 4920 },
82 { .center_freq = 4940 },
83 { .center_freq = 4960 },
84 { .center_freq = 4980 },
85 { .center_freq = 5040 },
86 { .center_freq = 5060 },
87 { .center_freq = 5080 },
88 { .center_freq = 5170 },
89 { .center_freq = 5180 },
90 { .center_freq = 5190 },
91 { .center_freq = 5200 },
92 { .center_freq = 5210 },
93 { .center_freq = 5220 },
94 { .center_freq = 5230 },
95 { .center_freq = 5240 },
96 { .center_freq = 5260 },
97 { .center_freq = 5280 },
98 { .center_freq = 5300 },
99 { .center_freq = 5320 },
100 { .center_freq = 5500 },
101 { .center_freq = 5520 },
102 { .center_freq = 5540 },
103 { .center_freq = 5560 },
104 { .center_freq = 5580 },
105 { .center_freq = 5600 },
106 { .center_freq = 5620 },
107 { .center_freq = 5640 },
108 { .center_freq = 5660 },
109 { .center_freq = 5680 },
110 { .center_freq = 5700 },
111 { .center_freq = 5745 },
112 { .center_freq = 5765 },
113 { .center_freq = 5785 },
114 { .center_freq = 5805 },
115 { .center_freq = 5825 },
116};
117
118static struct ieee80211_supported_band band_5GHz = {
119 .channels = p54_achannels,
120 .n_channels = ARRAY_SIZE(p54_achannels),
121 .bitrates = p54_arates,
122 .n_bitrates = ARRAY_SIZE(p54_arates),
67}; 123};
68 124
69int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw) 125int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw)
@@ -252,6 +308,7 @@ static int p54_convert_rev1(struct ieee80211_hw *dev,
252 308
253const char* p54_rf_chips[] = { "NULL", "Indigo?", "Duette", 309const char* p54_rf_chips[] = { "NULL", "Indigo?", "Duette",
254 "Frisbee", "Xbow", "Longbow" }; 310 "Frisbee", "Xbow", "Longbow" };
311static int p54_init_xbow_synth(struct ieee80211_hw *dev);
255 312
256int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len) 313int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
257{ 314{
@@ -371,20 +428,20 @@ int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
371 } 428 }
372 429
373 switch (priv->rxhw) { 430 switch (priv->rxhw) {
374 case 4: /* XBow */ 431 case 4: /* XBow */
375 case 1: /* Indigo? */ 432 p54_init_xbow_synth(dev);
376 case 2: /* Duette */ 433 case 1: /* Indigo? */
377 /* TODO: 5GHz initialization goes here */ 434 case 2: /* Duette */
378 435 dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz;
379 case 3: /* Frisbee */ 436 case 3: /* Frisbee */
380 case 5: /* Longbow */ 437 case 5: /* Longbow */
381 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz; 438 dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz;
382 break; 439 break;
383 default: 440 default:
384 printk(KERN_ERR "%s: unsupported RF-Chip\n", 441 printk(KERN_ERR "%s: unsupported RF-Chip\n",
385 wiphy_name(dev->wiphy)); 442 wiphy_name(dev->wiphy));
386 err = -EINVAL; 443 err = -EINVAL;
387 goto err; 444 goto err;
388 } 445 }
389 446
390 if (!is_valid_ether_addr(dev->wiphy->perm_addr)) { 447 if (!is_valid_ether_addr(dev->wiphy->perm_addr)) {
@@ -424,21 +481,43 @@ int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len)
424} 481}
425EXPORT_SYMBOL_GPL(p54_parse_eeprom); 482EXPORT_SYMBOL_GPL(p54_parse_eeprom);
426 483
484static int p54_rssi_to_dbm(struct ieee80211_hw *dev, int rssi)
485{
486 /* TODO: get the rssi_add & rssi_mul data from the eeprom */
487 return ((rssi * 0x83) / 64 - 400) / 4;
488}
489
427static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb) 490static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb)
428{ 491{
492 struct p54_common *priv = dev->priv;
429 struct p54_rx_hdr *hdr = (struct p54_rx_hdr *) skb->data; 493 struct p54_rx_hdr *hdr = (struct p54_rx_hdr *) skb->data;
430 struct ieee80211_rx_status rx_status = {0}; 494 struct ieee80211_rx_status rx_status = {0};
431 u16 freq = le16_to_cpu(hdr->freq); 495 u16 freq = le16_to_cpu(hdr->freq);
432 size_t header_len = sizeof(*hdr); 496 size_t header_len = sizeof(*hdr);
497 u32 tsf32;
433 498
434 rx_status.signal = hdr->rssi; 499 if (!(hdr->magic & cpu_to_le16(0x0001))) {
500 if (priv->filter_flags & FIF_FCSFAIL)
501 rx_status.flag |= RX_FLAG_FAILED_FCS_CRC;
502 else
503 return 0;
504 }
505
506 rx_status.signal = p54_rssi_to_dbm(dev, hdr->rssi);
507 rx_status.noise = priv->noise;
435 /* XX correct? */ 508 /* XX correct? */
436 rx_status.qual = (100 * hdr->rssi) / 127; 509 rx_status.qual = (100 * hdr->rssi) / 127;
437 rx_status.rate_idx = hdr->rate & 0xf; 510 rx_status.rate_idx = hdr->rate & 0xf;
438 rx_status.freq = freq; 511 rx_status.freq = freq;
439 rx_status.band = IEEE80211_BAND_2GHZ; 512 rx_status.band = IEEE80211_BAND_2GHZ;
440 rx_status.antenna = hdr->antenna; 513 rx_status.antenna = hdr->antenna;
441 rx_status.mactime = le64_to_cpu(hdr->timestamp); 514
515 tsf32 = le32_to_cpu(hdr->tsf32);
516 if (tsf32 < priv->tsf_low32)
517 priv->tsf_high32++;
518 rx_status.mactime = ((u64)priv->tsf_high32) << 32 | tsf32;
519 priv->tsf_low32 = tsf32;
520
442 rx_status.flag |= RX_FLAG_TSFT; 521 rx_status.flag |= RX_FLAG_TSFT;
443 522
444 if (hdr->magic & cpu_to_le16(0x4000)) 523 if (hdr->magic & cpu_to_le16(0x4000))
@@ -511,7 +590,8 @@ static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb)
511 info->status.excessive_retries = 1; 590 info->status.excessive_retries = 1;
512 } 591 }
513 info->status.retry_count = payload->retries - 1; 592 info->status.retry_count = payload->retries - 1;
514 info->status.ack_signal = le16_to_cpu(payload->ack_rssi); 593 info->status.ack_signal = p54_rssi_to_dbm(dev,
594 le16_to_cpu(payload->ack_rssi));
515 skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data)); 595 skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data));
516 ieee80211_tx_status_irqsafe(dev, entry); 596 ieee80211_tx_status_irqsafe(dev, entry);
517 goto out; 597 goto out;
@@ -542,6 +622,27 @@ static void p54_rx_eeprom_readback(struct ieee80211_hw *dev,
542 complete(&priv->eeprom_comp); 622 complete(&priv->eeprom_comp);
543} 623}
544 624
625static void p54_rx_stats(struct ieee80211_hw *dev, struct sk_buff *skb)
626{
627 struct p54_common *priv = dev->priv;
628 struct p54_control_hdr *hdr = (struct p54_control_hdr *) skb->data;
629 struct p54_statistics *stats = (struct p54_statistics *) hdr->data;
630 u32 tsf32 = le32_to_cpu(stats->tsf32);
631
632 if (tsf32 < priv->tsf_low32)
633 priv->tsf_high32++;
634 priv->tsf_low32 = tsf32;
635
636 priv->stats.dot11RTSFailureCount = le32_to_cpu(stats->rts_fail);
637 priv->stats.dot11RTSSuccessCount = le32_to_cpu(stats->rts_success);
638 priv->stats.dot11FCSErrorCount = le32_to_cpu(stats->rx_bad_fcs);
639
640 priv->noise = p54_rssi_to_dbm(dev, le32_to_cpu(stats->noise));
641 complete(&priv->stats_comp);
642
643 mod_timer(&priv->stats_timer, jiffies + 5 * HZ);
644}
645
545static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *skb) 646static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *skb)
546{ 647{
547 struct p54_control_hdr *hdr = (struct p54_control_hdr *) skb->data; 648 struct p54_control_hdr *hdr = (struct p54_control_hdr *) skb->data;
@@ -552,6 +653,9 @@ static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *skb)
552 break; 653 break;
553 case P54_CONTROL_TYPE_BBP: 654 case P54_CONTROL_TYPE_BBP:
554 break; 655 break;
656 case P54_CONTROL_TYPE_STAT_READBACK:
657 p54_rx_stats(dev, skb);
658 break;
555 case P54_CONTROL_TYPE_EEPROM_READBACK: 659 case P54_CONTROL_TYPE_EEPROM_READBACK:
556 p54_rx_eeprom_readback(dev, skb); 660 p54_rx_eeprom_readback(dev, skb);
557 break; 661 break;
@@ -753,7 +857,7 @@ static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb)
753 txhdr->hw_queue = skb_get_queue_mapping(skb) + 4; 857 txhdr->hw_queue = skb_get_queue_mapping(skb) + 4;
754 txhdr->tx_antenna = (info->antenna_sel_tx == 0) ? 858 txhdr->tx_antenna = (info->antenna_sel_tx == 0) ?
755 2 : info->antenna_sel_tx - 1; 859 2 : info->antenna_sel_tx - 1;
756 txhdr->output_power = 0x7f; // HW Maximum 860 txhdr->output_power = priv->output_power;
757 txhdr->cts_rate = (info->flags & IEEE80211_TX_CTL_NO_ACK) ? 861 txhdr->cts_rate = (info->flags & IEEE80211_TX_CTL_NO_ACK) ?
758 0 : cts_rate; 862 0 : cts_rate;
759 if (padding) 863 if (padding)
@@ -1021,12 +1125,25 @@ static int p54_start(struct ieee80211_hw *dev)
1021 return -ENOMEM; 1125 return -ENOMEM;
1022 } 1126 }
1023 1127
1128 if (!priv->cached_stats) {
1129 priv->cached_stats = kzalloc(sizeof(struct p54_statistics) +
1130 priv->tx_hdr_len + sizeof(struct p54_control_hdr),
1131 GFP_KERNEL);
1132
1133 if (!priv->cached_stats) {
1134 kfree(priv->cached_vdcf);
1135 priv->cached_vdcf = NULL;
1136 return -ENOMEM;
1137 }
1138 }
1139
1024 err = priv->open(dev); 1140 err = priv->open(dev);
1025 if (!err) 1141 if (!err)
1026 priv->mode = IEEE80211_IF_TYPE_MNTR; 1142 priv->mode = IEEE80211_IF_TYPE_MNTR;
1027 1143
1028 p54_init_vdcf(dev); 1144 p54_init_vdcf(dev);
1029 1145
1146 mod_timer(&priv->stats_timer, jiffies + HZ);
1030 return err; 1147 return err;
1031} 1148}
1032 1149
@@ -1034,9 +1151,12 @@ static void p54_stop(struct ieee80211_hw *dev)
1034{ 1151{
1035 struct p54_common *priv = dev->priv; 1152 struct p54_common *priv = dev->priv;
1036 struct sk_buff *skb; 1153 struct sk_buff *skb;
1154
1155 del_timer(&priv->stats_timer);
1037 while ((skb = skb_dequeue(&priv->tx_queue))) 1156 while ((skb = skb_dequeue(&priv->tx_queue)))
1038 kfree_skb(skb); 1157 kfree_skb(skb);
1039 priv->stop(dev); 1158 priv->stop(dev);
1159 priv->tsf_high32 = priv->tsf_low32 = 0;
1040 priv->mode = IEEE80211_IF_TYPE_INVALID; 1160 priv->mode = IEEE80211_IF_TYPE_INVALID;
1041} 1161}
1042 1162
@@ -1091,6 +1211,7 @@ static int p54_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
1091 mutex_lock(&priv->conf_mutex); 1211 mutex_lock(&priv->conf_mutex);
1092 priv->rx_antenna = (conf->antenna_sel_rx == 0) ? 1212 priv->rx_antenna = (conf->antenna_sel_rx == 0) ?
1093 2 : conf->antenna_sel_tx - 1; 1213 2 : conf->antenna_sel_tx - 1;
1214 priv->output_power = conf->power_level << 2;
1094 ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq)); 1215 ret = p54_set_freq(dev, cpu_to_le16(conf->channel->center_freq));
1095 p54_set_vdcf(dev); 1216 p54_set_vdcf(dev);
1096 mutex_unlock(&priv->conf_mutex); 1217 mutex_unlock(&priv->conf_mutex);
@@ -1118,13 +1239,26 @@ static void p54_configure_filter(struct ieee80211_hw *dev,
1118{ 1239{
1119 struct p54_common *priv = dev->priv; 1240 struct p54_common *priv = dev->priv;
1120 1241
1121 *total_flags &= FIF_BCN_PRBRESP_PROMISC; 1242 *total_flags &= FIF_BCN_PRBRESP_PROMISC |
1243 FIF_PROMISC_IN_BSS |
1244 FIF_FCSFAIL;
1245
1246 priv->filter_flags = *total_flags;
1122 1247
1123 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) { 1248 if (changed_flags & FIF_BCN_PRBRESP_PROMISC) {
1124 if (*total_flags & FIF_BCN_PRBRESP_PROMISC) 1249 if (*total_flags & FIF_BCN_PRBRESP_PROMISC)
1125 p54_set_filter(dev, 0, NULL); 1250 p54_set_filter(dev, priv->filter_type, NULL);
1126 else 1251 else
1127 p54_set_filter(dev, 0, priv->bssid); 1252 p54_set_filter(dev, priv->filter_type, priv->bssid);
1253 }
1254
1255 if (changed_flags & FIF_PROMISC_IN_BSS) {
1256 if (*total_flags & FIF_PROMISC_IN_BSS)
1257 p54_set_filter(dev, priv->filter_type |
1258 cpu_to_le16(0x8), NULL);
1259 else
1260 p54_set_filter(dev, priv->filter_type &
1261 ~cpu_to_le16(0x8), priv->bssid);
1128 } 1262 }
1129} 1263}
1130 1264
@@ -1148,10 +1282,67 @@ static int p54_conf_tx(struct ieee80211_hw *dev, u16 queue,
1148 return 0; 1282 return 0;
1149} 1283}
1150 1284
1285static int p54_init_xbow_synth(struct ieee80211_hw *dev)
1286{
1287 struct p54_common *priv = dev->priv;
1288 struct p54_control_hdr *hdr;
1289 struct p54_tx_control_xbow_synth *xbow;
1290
1291 hdr = kzalloc(sizeof(*hdr) + sizeof(*xbow) +
1292 priv->tx_hdr_len, GFP_KERNEL);
1293 if (!hdr)
1294 return -ENOMEM;
1295
1296 hdr = (void *)hdr + priv->tx_hdr_len;
1297 hdr->magic1 = cpu_to_le16(0x8001);
1298 hdr->len = cpu_to_le16(sizeof(*xbow));
1299 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_XBOW_SYNTH_CFG);
1300 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*xbow));
1301
1302 xbow = (struct p54_tx_control_xbow_synth *) hdr->data;
1303 xbow->magic1 = cpu_to_le16(0x1);
1304 xbow->magic2 = cpu_to_le16(0x2);
1305 xbow->freq = cpu_to_le16(5390);
1306
1307 priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*xbow), 1);
1308
1309 return 0;
1310}
1311
1312static void p54_statistics_timer(unsigned long data)
1313{
1314 struct ieee80211_hw *dev = (struct ieee80211_hw *) data;
1315 struct p54_common *priv = dev->priv;
1316 struct p54_control_hdr *hdr;
1317 struct p54_statistics *stats;
1318
1319 BUG_ON(!priv->cached_stats);
1320
1321 hdr = (void *)priv->cached_stats + priv->tx_hdr_len;
1322 hdr->magic1 = cpu_to_le16(0x8000);
1323 hdr->len = cpu_to_le16(sizeof(*stats));
1324 hdr->type = cpu_to_le16(P54_CONTROL_TYPE_STAT_READBACK);
1325 p54_assign_address(dev, NULL, hdr, sizeof(*hdr) + sizeof(*stats));
1326
1327 priv->tx(dev, hdr, sizeof(*hdr) + sizeof(*stats), 0);
1328}
1329
1151static int p54_get_stats(struct ieee80211_hw *dev, 1330static int p54_get_stats(struct ieee80211_hw *dev,
1152 struct ieee80211_low_level_stats *stats) 1331 struct ieee80211_low_level_stats *stats)
1153{ 1332{
1154 /* TODO */ 1333 struct p54_common *priv = dev->priv;
1334
1335 del_timer(&priv->stats_timer);
1336 p54_statistics_timer((unsigned long)dev);
1337
1338 if (!wait_for_completion_interruptible_timeout(&priv->stats_comp, HZ)) {
1339 printk(KERN_ERR "%s: device does not respond!\n",
1340 wiphy_name(dev->wiphy));
1341 return -EBUSY;
1342 }
1343
1344 memcpy(stats, &priv->stats, sizeof(*stats));
1345
1155 return 0; 1346 return 0;
1156} 1347}
1157 1348
@@ -1193,12 +1384,12 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
1193 skb_queue_head_init(&priv->tx_queue); 1384 skb_queue_head_init(&priv->tx_queue);
1194 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */ 1385 dev->flags = IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | /* not sure */
1195 IEEE80211_HW_RX_INCLUDES_FCS | 1386 IEEE80211_HW_RX_INCLUDES_FCS |
1196 IEEE80211_HW_SIGNAL_UNSPEC; 1387 IEEE80211_HW_SIGNAL_DBM |
1388 IEEE80211_HW_NOISE_DBM;
1197 1389
1198 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 1390 dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION);
1199 1391
1200 dev->channel_change_time = 1000; /* TODO: find actual value */ 1392 dev->channel_change_time = 1000; /* TODO: find actual value */
1201 dev->max_signal = 127;
1202 1393
1203 priv->tx_stats[0].limit = 1; 1394 priv->tx_stats[0].limit = 1;
1204 priv->tx_stats[1].limit = 1; 1395 priv->tx_stats[1].limit = 1;
@@ -1206,11 +1397,15 @@ struct ieee80211_hw *p54_init_common(size_t priv_data_len)
1206 priv->tx_stats[3].limit = 1; 1397 priv->tx_stats[3].limit = 1;
1207 priv->tx_stats[4].limit = 5; 1398 priv->tx_stats[4].limit = 5;
1208 dev->queues = 1; 1399 dev->queues = 1;
1400 priv->noise = -94;
1209 dev->extra_tx_headroom = sizeof(struct p54_control_hdr) + 4 + 1401 dev->extra_tx_headroom = sizeof(struct p54_control_hdr) + 4 +
1210 sizeof(struct p54_tx_control_allocdata); 1402 sizeof(struct p54_tx_control_allocdata);
1211 1403
1212 mutex_init(&priv->conf_mutex); 1404 mutex_init(&priv->conf_mutex);
1213 init_completion(&priv->eeprom_comp); 1405 init_completion(&priv->eeprom_comp);
1406 init_completion(&priv->stats_comp);
1407 setup_timer(&priv->stats_timer, p54_statistics_timer,
1408 (unsigned long)dev);
1214 1409
1215 return dev; 1410 return dev;
1216} 1411}
@@ -1219,6 +1414,7 @@ EXPORT_SYMBOL_GPL(p54_init_common);
1219void p54_free_common(struct ieee80211_hw *dev) 1414void p54_free_common(struct ieee80211_hw *dev)
1220{ 1415{
1221 struct p54_common *priv = dev->priv; 1416 struct p54_common *priv = dev->priv;
1417 kfree(priv->cached_stats);
1222 kfree(priv->iq_autocal); 1418 kfree(priv->iq_autocal);
1223 kfree(priv->output_limit); 1419 kfree(priv->output_limit);
1224 kfree(priv->curve_data); 1420 kfree(priv->curve_data);
diff --git a/drivers/net/wireless/p54/p54common.h b/drivers/net/wireless/p54/p54common.h
index 73a9a2c923dd..4da736c789ac 100644
--- a/drivers/net/wireless/p54/p54common.h
+++ b/drivers/net/wireless/p54/p54common.h
@@ -185,7 +185,8 @@ struct p54_rx_hdr {
185 u8 rssi; 185 u8 rssi;
186 u8 quality; 186 u8 quality;
187 u16 unknown2; 187 u16 unknown2;
188 __le64 timestamp; 188 __le32 tsf32;
189 __le32 unalloc0;
189 u8 align[0]; 190 u8 align[0];
190} __attribute__ ((packed)); 191} __attribute__ ((packed));
191 192
@@ -300,4 +301,24 @@ struct p54_tx_control_vdcf {
300 __le16 frameburst; 301 __le16 frameburst;
301} __attribute__ ((packed)); 302} __attribute__ ((packed));
302 303
304struct p54_statistics {
305 __le32 rx_success;
306 __le32 rx_bad_fcs;
307 __le32 rx_abort;
308 __le32 rx_abort_phy;
309 __le32 rts_success;
310 __le32 rts_fail;
311 __le32 tsf32;
312 __le32 airtime;
313 __le32 noise;
314 __le32 unkn[10]; /* CCE / CCA / RADAR */
315} __attribute__ ((packed));
316
317struct p54_tx_control_xbow_synth {
318 __le16 magic1;
319 __le16 magic2;
320 __le16 freq;
321 u32 padding[5];
322} __attribute__ ((packed));
323
303#endif /* P54COMMON_H */ 324#endif /* P54COMMON_H */
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig
index 11f590d63aff..b686dc45483e 100644
--- a/drivers/net/wireless/rt2x00/Kconfig
+++ b/drivers/net/wireless/rt2x00/Kconfig
@@ -40,11 +40,15 @@ config RT2X00_LIB_CRYPTO
40config RT2X00_LIB_RFKILL 40config RT2X00_LIB_RFKILL
41 boolean 41 boolean
42 depends on RT2X00_LIB 42 depends on RT2X00_LIB
43 select RFKILL 43 depends on RFKILL
44 default y
44 45
45config RT2X00_LIB_LEDS 46config RT2X00_LIB_LEDS
46 boolean 47 boolean
47 depends on RT2X00_LIB && NEW_LEDS 48 depends on RT2X00_LIB
49 depends on NEW_LEDS
50 depends on LEDS_CLASS
51 default y
48 52
49config RT2400PCI 53config RT2400PCI
50 tristate "Ralink rt2400 (PCI/PCMCIA) support" 54 tristate "Ralink rt2400 (PCI/PCMCIA) support"
@@ -57,23 +61,6 @@ config RT2400PCI
57 61
58 When compiled as a module, this driver will be called "rt2400pci.ko". 62 When compiled as a module, this driver will be called "rt2400pci.ko".
59 63
60config RT2400PCI_RFKILL
61 bool "Ralink rt2400 rfkill support"
62 depends on RT2400PCI
63 select RT2X00_LIB_RFKILL
64 ---help---
65 This adds support for integrated rt2400 hardware that features a
66 hardware button to control the radio state.
67 This feature depends on the RF switch subsystem rfkill.
68
69config RT2400PCI_LEDS
70 bool "Ralink rt2400 leds support"
71 depends on RT2400PCI && NEW_LEDS
72 select LEDS_CLASS
73 select RT2X00_LIB_LEDS
74 ---help---
75 This adds support for led triggers provided my mac80211.
76
77config RT2500PCI 64config RT2500PCI
78 tristate "Ralink rt2500 (PCI/PCMCIA) support" 65 tristate "Ralink rt2500 (PCI/PCMCIA) support"
79 depends on PCI 66 depends on PCI
@@ -85,23 +72,6 @@ config RT2500PCI
85 72
86 When compiled as a module, this driver will be called "rt2500pci.ko". 73 When compiled as a module, this driver will be called "rt2500pci.ko".
87 74
88config RT2500PCI_RFKILL
89 bool "Ralink rt2500 rfkill support"
90 depends on RT2500PCI
91 select RT2X00_LIB_RFKILL
92 ---help---
93 This adds support for integrated rt2500 hardware that features a
94 hardware button to control the radio state.
95 This feature depends on the RF switch subsystem rfkill.
96
97config RT2500PCI_LEDS
98 bool "Ralink rt2500 leds support"
99 depends on RT2500PCI && NEW_LEDS
100 select LEDS_CLASS
101 select RT2X00_LIB_LEDS
102 ---help---
103 This adds support for led triggers provided my mac80211.
104
105config RT61PCI 75config RT61PCI
106 tristate "Ralink rt2501/rt61 (PCI/PCMCIA) support" 76 tristate "Ralink rt2501/rt61 (PCI/PCMCIA) support"
107 depends on PCI 77 depends on PCI
@@ -116,23 +86,6 @@ config RT61PCI
116 86
117 When compiled as a module, this driver will be called "rt61pci.ko". 87 When compiled as a module, this driver will be called "rt61pci.ko".
118 88
119config RT61PCI_RFKILL
120 bool "Ralink rt2501/rt61 rfkill support"
121 depends on RT61PCI
122 select RT2X00_LIB_RFKILL
123 ---help---
124 This adds support for integrated rt61 hardware that features a
125 hardware button to control the radio state.
126 This feature depends on the RF switch subsystem rfkill.
127
128config RT61PCI_LEDS
129 bool "Ralink rt2501/rt61 leds support"
130 depends on RT61PCI && NEW_LEDS
131 select LEDS_CLASS
132 select RT2X00_LIB_LEDS
133 ---help---
134 This adds support for led triggers provided my mac80211.
135
136config RT2500USB 89config RT2500USB
137 tristate "Ralink rt2500 (USB) support" 90 tristate "Ralink rt2500 (USB) support"
138 depends on USB 91 depends on USB
@@ -143,14 +96,6 @@ config RT2500USB
143 96
144 When compiled as a module, this driver will be called "rt2500usb.ko". 97 When compiled as a module, this driver will be called "rt2500usb.ko".
145 98
146config RT2500USB_LEDS
147 bool "Ralink rt2500 leds support"
148 depends on RT2500USB && NEW_LEDS
149 select LEDS_CLASS
150 select RT2X00_LIB_LEDS
151 ---help---
152 This adds support for led triggers provided my mac80211.
153
154config RT73USB 99config RT73USB
155 tristate "Ralink rt2501/rt73 (USB) support" 100 tristate "Ralink rt2501/rt73 (USB) support"
156 depends on USB 101 depends on USB
@@ -164,14 +109,6 @@ config RT73USB
164 109
165 When compiled as a module, this driver will be called "rt73usb.ko". 110 When compiled as a module, this driver will be called "rt73usb.ko".
166 111
167config RT73USB_LEDS
168 bool "Ralink rt2501/rt73 leds support"
169 depends on RT73USB && NEW_LEDS
170 select LEDS_CLASS
171 select RT2X00_LIB_LEDS
172 ---help---
173 This adds support for led triggers provided my mac80211.
174
175config RT2X00_LIB_DEBUGFS 112config RT2X00_LIB_DEBUGFS
176 bool "Ralink debugfs support" 113 bool "Ralink debugfs support"
177 depends on RT2X00_LIB && MAC80211_DEBUGFS 114 depends on RT2X00_LIB && MAC80211_DEBUGFS
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 18b703c3fc2c..08cb9eec16a6 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -231,7 +231,7 @@ static const struct rt2x00debug rt2400pci_rt2x00debug = {
231}; 231};
232#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 232#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
233 233
234#ifdef CONFIG_RT2400PCI_RFKILL 234#ifdef CONFIG_RT2X00_LIB_RFKILL
235static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) 235static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
236{ 236{
237 u32 reg; 237 u32 reg;
@@ -241,9 +241,9 @@ static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
241} 241}
242#else 242#else
243#define rt2400pci_rfkill_poll NULL 243#define rt2400pci_rfkill_poll NULL
244#endif /* CONFIG_RT2400PCI_RFKILL */ 244#endif /* CONFIG_RT2X00_LIB_RFKILL */
245 245
246#ifdef CONFIG_RT2400PCI_LEDS 246#ifdef CONFIG_RT2X00_LIB_LEDS
247static void rt2400pci_brightness_set(struct led_classdev *led_cdev, 247static void rt2400pci_brightness_set(struct led_classdev *led_cdev,
248 enum led_brightness brightness) 248 enum led_brightness brightness)
249{ 249{
@@ -288,7 +288,7 @@ static void rt2400pci_init_led(struct rt2x00_dev *rt2x00dev,
288 led->led_dev.blink_set = rt2400pci_blink_set; 288 led->led_dev.blink_set = rt2400pci_blink_set;
289 led->flags = LED_INITIALIZED; 289 led->flags = LED_INITIALIZED;
290} 290}
291#endif /* CONFIG_RT2400PCI_LEDS */ 291#endif /* CONFIG_RT2X00_LIB_LEDS */
292 292
293/* 293/*
294 * Configuration handlers. 294 * Configuration handlers.
@@ -1374,22 +1374,22 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
1374 /* 1374 /*
1375 * Store led mode, for correct led behaviour. 1375 * Store led mode, for correct led behaviour.
1376 */ 1376 */
1377#ifdef CONFIG_RT2400PCI_LEDS 1377#ifdef CONFIG_RT2X00_LIB_LEDS
1378 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1378 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
1379 1379
1380 rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); 1380 rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1381 if (value == LED_MODE_TXRX_ACTIVITY) 1381 if (value == LED_MODE_TXRX_ACTIVITY)
1382 rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_qual, 1382 rt2400pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
1383 LED_TYPE_ACTIVITY); 1383 LED_TYPE_ACTIVITY);
1384#endif /* CONFIG_RT2400PCI_LEDS */ 1384#endif /* CONFIG_RT2X00_LIB_LEDS */
1385 1385
1386 /* 1386 /*
1387 * Detect if this device has an hardware controlled radio. 1387 * Detect if this device has an hardware controlled radio.
1388 */ 1388 */
1389#ifdef CONFIG_RT2400PCI_RFKILL 1389#ifdef CONFIG_RT2X00_LIB_RFKILL
1390 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) 1390 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
1391 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); 1391 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
1392#endif /* CONFIG_RT2400PCI_RFKILL */ 1392#endif /* CONFIG_RT2X00_LIB_RFKILL */
1393 1393
1394 /* 1394 /*
1395 * Check if the BBP tuning should be enabled. 1395 * Check if the BBP tuning should be enabled.
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index 2a96a011f2ad..ef42cc04a2d7 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -231,7 +231,7 @@ static const struct rt2x00debug rt2500pci_rt2x00debug = {
231}; 231};
232#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 232#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
233 233
234#ifdef CONFIG_RT2500PCI_RFKILL 234#ifdef CONFIG_RT2X00_LIB_RFKILL
235static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) 235static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
236{ 236{
237 u32 reg; 237 u32 reg;
@@ -241,9 +241,9 @@ static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
241} 241}
242#else 242#else
243#define rt2500pci_rfkill_poll NULL 243#define rt2500pci_rfkill_poll NULL
244#endif /* CONFIG_RT2500PCI_RFKILL */ 244#endif /* CONFIG_RT2X00_LIB_RFKILL */
245 245
246#ifdef CONFIG_RT2500PCI_LEDS 246#ifdef CONFIG_RT2X00_LIB_LEDS
247static void rt2500pci_brightness_set(struct led_classdev *led_cdev, 247static void rt2500pci_brightness_set(struct led_classdev *led_cdev,
248 enum led_brightness brightness) 248 enum led_brightness brightness)
249{ 249{
@@ -288,7 +288,7 @@ static void rt2500pci_init_led(struct rt2x00_dev *rt2x00dev,
288 led->led_dev.blink_set = rt2500pci_blink_set; 288 led->led_dev.blink_set = rt2500pci_blink_set;
289 led->flags = LED_INITIALIZED; 289 led->flags = LED_INITIALIZED;
290} 290}
291#endif /* CONFIG_RT2500PCI_LEDS */ 291#endif /* CONFIG_RT2X00_LIB_LEDS */
292 292
293/* 293/*
294 * Configuration handlers. 294 * Configuration handlers.
@@ -1533,22 +1533,22 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
1533 /* 1533 /*
1534 * Store led mode, for correct led behaviour. 1534 * Store led mode, for correct led behaviour.
1535 */ 1535 */
1536#ifdef CONFIG_RT2500PCI_LEDS 1536#ifdef CONFIG_RT2X00_LIB_LEDS
1537 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1537 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
1538 1538
1539 rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); 1539 rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1540 if (value == LED_MODE_TXRX_ACTIVITY) 1540 if (value == LED_MODE_TXRX_ACTIVITY)
1541 rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_qual, 1541 rt2500pci_init_led(rt2x00dev, &rt2x00dev->led_qual,
1542 LED_TYPE_ACTIVITY); 1542 LED_TYPE_ACTIVITY);
1543#endif /* CONFIG_RT2500PCI_LEDS */ 1543#endif /* CONFIG_RT2X00_LIB_LEDS */
1544 1544
1545 /* 1545 /*
1546 * Detect if this device has an hardware controlled radio. 1546 * Detect if this device has an hardware controlled radio.
1547 */ 1547 */
1548#ifdef CONFIG_RT2500PCI_RFKILL 1548#ifdef CONFIG_RT2X00_LIB_RFKILL
1549 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) 1549 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
1550 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); 1550 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
1551#endif /* CONFIG_RT2500PCI_RFKILL */ 1551#endif /* CONFIG_RT2X00_LIB_RFKILL */
1552 1552
1553 /* 1553 /*
1554 * Check if the BBP tuning should be enabled. 1554 * Check if the BBP tuning should be enabled.
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 0e008b606f70..cb5f2d01a9c3 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -288,7 +288,7 @@ static const struct rt2x00debug rt2500usb_rt2x00debug = {
288}; 288};
289#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 289#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
290 290
291#ifdef CONFIG_RT2500USB_LEDS 291#ifdef CONFIG_RT2X00_LIB_LEDS
292static void rt2500usb_brightness_set(struct led_classdev *led_cdev, 292static void rt2500usb_brightness_set(struct led_classdev *led_cdev,
293 enum led_brightness brightness) 293 enum led_brightness brightness)
294{ 294{
@@ -333,7 +333,7 @@ static void rt2500usb_init_led(struct rt2x00_dev *rt2x00dev,
333 led->led_dev.blink_set = rt2500usb_blink_set; 333 led->led_dev.blink_set = rt2500usb_blink_set;
334 led->flags = LED_INITIALIZED; 334 led->flags = LED_INITIALIZED;
335} 335}
336#endif /* CONFIG_RT2500USB_LEDS */ 336#endif /* CONFIG_RT2X00_LIB_LEDS */
337 337
338/* 338/*
339 * Configuration handlers. 339 * Configuration handlers.
@@ -1133,7 +1133,6 @@ static void rt2500usb_write_beacon(struct queue_entry *entry)
1133 int pipe = usb_sndbulkpipe(usb_dev, 1); 1133 int pipe = usb_sndbulkpipe(usb_dev, 1);
1134 int length; 1134 int length;
1135 u16 reg; 1135 u16 reg;
1136 u32 word, len;
1137 1136
1138 /* 1137 /*
1139 * Add the descriptor in front of the skb. 1138 * Add the descriptor in front of the skb.
@@ -1143,17 +1142,6 @@ static void rt2500usb_write_beacon(struct queue_entry *entry)
1143 skbdesc->desc = entry->skb->data; 1142 skbdesc->desc = entry->skb->data;
1144 1143
1145 /* 1144 /*
1146 * Adjust the beacon databyte count. The current number is
1147 * calculated before this function gets called, but falsely
1148 * assumes that the descriptor was already present in the SKB.
1149 */
1150 rt2x00_desc_read(skbdesc->desc, 0, &word);
1151 len = rt2x00_get_field32(word, TXD_W0_DATABYTE_COUNT);
1152 len += skbdesc->desc_len;
1153 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, len);
1154 rt2x00_desc_write(skbdesc->desc, 0, word);
1155
1156 /*
1157 * Disable beaconing while we are reloading the beacon data, 1145 * Disable beaconing while we are reloading the beacon data,
1158 * otherwise we might be sending out invalid data. 1146 * otherwise we might be sending out invalid data.
1159 */ 1147 */
@@ -1485,14 +1473,14 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1485 /* 1473 /*
1486 * Store led mode, for correct led behaviour. 1474 * Store led mode, for correct led behaviour.
1487 */ 1475 */
1488#ifdef CONFIG_RT2500USB_LEDS 1476#ifdef CONFIG_RT2X00_LIB_LEDS
1489 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE); 1477 value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_LED_MODE);
1490 1478
1491 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); 1479 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
1492 if (value == LED_MODE_TXRX_ACTIVITY) 1480 if (value == LED_MODE_TXRX_ACTIVITY)
1493 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_qual, 1481 rt2500usb_init_led(rt2x00dev, &rt2x00dev->led_qual,
1494 LED_TYPE_ACTIVITY); 1482 LED_TYPE_ACTIVITY);
1495#endif /* CONFIG_RT2500USB_LEDS */ 1483#endif /* CONFIG_RT2X00_LIB_LEDS */
1496 1484
1497 /* 1485 /*
1498 * Check if the BBP tuning should be disabled. 1486 * Check if the BBP tuning should be disabled.
diff --git a/drivers/net/wireless/rt2x00/rt2x00rfkill.c b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
index 8a2fefb365b7..55eff58f1889 100644
--- a/drivers/net/wireless/rt2x00/rt2x00rfkill.c
+++ b/drivers/net/wireless/rt2x00/rt2x00rfkill.c
@@ -45,16 +45,15 @@ static int rt2x00rfkill_toggle_radio(void *data, enum rfkill_state state)
45 return 0; 45 return 0;
46 46
47 if (state == RFKILL_STATE_UNBLOCKED) { 47 if (state == RFKILL_STATE_UNBLOCKED) {
48 INFO(rt2x00dev, "Hardware button pressed, enabling radio.\n"); 48 INFO(rt2x00dev, "RFKILL event: enabling radio.\n");
49 clear_bit(DEVICE_STATE_DISABLED_RADIO_HW, &rt2x00dev->flags); 49 clear_bit(DEVICE_STATE_DISABLED_RADIO_HW, &rt2x00dev->flags);
50 retval = rt2x00lib_enable_radio(rt2x00dev); 50 retval = rt2x00lib_enable_radio(rt2x00dev);
51 } else if (state == RFKILL_STATE_SOFT_BLOCKED) { 51 } else if (state == RFKILL_STATE_SOFT_BLOCKED) {
52 INFO(rt2x00dev, "Hardware button pressed, disabling radio.\n"); 52 INFO(rt2x00dev, "RFKILL event: disabling radio.\n");
53 set_bit(DEVICE_STATE_DISABLED_RADIO_HW, &rt2x00dev->flags); 53 set_bit(DEVICE_STATE_DISABLED_RADIO_HW, &rt2x00dev->flags);
54 rt2x00lib_disable_radio(rt2x00dev); 54 rt2x00lib_disable_radio(rt2x00dev);
55 } else { 55 } else {
56 WARNING(rt2x00dev, "Received unexpected rfkill state %d.\n", 56 WARNING(rt2x00dev, "RFKILL event: unknown state %d.\n", state);
57 state);
58 } 57 }
59 58
60 return retval; 59 return retval;
@@ -64,7 +63,12 @@ static int rt2x00rfkill_get_state(void *data, enum rfkill_state *state)
64{ 63{
65 struct rt2x00_dev *rt2x00dev = data; 64 struct rt2x00_dev *rt2x00dev = data;
66 65
67 *state = rt2x00dev->rfkill->state; 66 /*
67 * rfkill_poll reports 1 when the key has been pressed and the
68 * radio should be blocked.
69 */
70 *state = rt2x00dev->ops->lib->rfkill_poll(rt2x00dev) ?
71 RFKILL_STATE_SOFT_BLOCKED : RFKILL_STATE_UNBLOCKED;
68 72
69 return 0; 73 return 0;
70} 74}
@@ -73,19 +77,18 @@ static void rt2x00rfkill_poll(struct work_struct *work)
73{ 77{
74 struct rt2x00_dev *rt2x00dev = 78 struct rt2x00_dev *rt2x00dev =
75 container_of(work, struct rt2x00_dev, rfkill_work.work); 79 container_of(work, struct rt2x00_dev, rfkill_work.work);
76 int state; 80 enum rfkill_state state;
77 81
78 if (!test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state)) 82 if (!test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state) ||
83 !test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags))
79 return; 84 return;
80 85
81 /* 86 /*
82 * rfkill_poll reports 1 when the key has been pressed and the 87 * Poll latest state and report it to rfkill who should sort
83 * radio should be blocked. 88 * out if the state should be toggled or not.
84 */ 89 */
85 state = !rt2x00dev->ops->lib->rfkill_poll(rt2x00dev) ? 90 if (!rt2x00rfkill_get_state(rt2x00dev, &state))
86 RFKILL_STATE_UNBLOCKED : RFKILL_STATE_SOFT_BLOCKED; 91 rfkill_force_state(rt2x00dev->rfkill, state);
87
88 rfkill_force_state(rt2x00dev->rfkill, state);
89 92
90 queue_delayed_work(rt2x00dev->hw->workqueue, 93 queue_delayed_work(rt2x00dev->hw->workqueue,
91 &rt2x00dev->rfkill_work, RFKILL_POLL_INTERVAL); 94 &rt2x00dev->rfkill_work, RFKILL_POLL_INTERVAL);
@@ -93,8 +96,8 @@ static void rt2x00rfkill_poll(struct work_struct *work)
93 96
94void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) 97void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
95{ 98{
96 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) || 99 if (!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state) ||
97 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state)) 100 test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
98 return; 101 return;
99 102
100 if (rfkill_register(rt2x00dev->rfkill)) { 103 if (rfkill_register(rt2x00dev->rfkill)) {
@@ -114,7 +117,7 @@ void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev)
114 117
115void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev) 118void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
116{ 119{
117 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) || 120 if (!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state) ||
118 !test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state)) 121 !test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state))
119 return; 122 return;
120 123
@@ -127,21 +130,25 @@ void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev)
127 130
128void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev) 131void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
129{ 132{
130 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) 133 struct device *dev = wiphy_dev(rt2x00dev->hw->wiphy);
134
135 if (test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
131 return; 136 return;
132 137
133 rt2x00dev->rfkill = 138 rt2x00dev->rfkill = rfkill_allocate(dev, RFKILL_TYPE_WLAN);
134 rfkill_allocate(wiphy_dev(rt2x00dev->hw->wiphy), RFKILL_TYPE_WLAN);
135 if (!rt2x00dev->rfkill) { 139 if (!rt2x00dev->rfkill) {
136 ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n"); 140 ERROR(rt2x00dev, "Failed to allocate rfkill handler.\n");
137 return; 141 return;
138 } 142 }
139 143
144 __set_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state);
145
140 rt2x00dev->rfkill->name = rt2x00dev->ops->name; 146 rt2x00dev->rfkill->name = rt2x00dev->ops->name;
141 rt2x00dev->rfkill->data = rt2x00dev; 147 rt2x00dev->rfkill->data = rt2x00dev;
142 rt2x00dev->rfkill->state = -1; 148 rt2x00dev->rfkill->state = -1;
143 rt2x00dev->rfkill->toggle_radio = rt2x00rfkill_toggle_radio; 149 rt2x00dev->rfkill->toggle_radio = rt2x00rfkill_toggle_radio;
144 rt2x00dev->rfkill->get_state = rt2x00rfkill_get_state; 150 if (test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags))
151 rt2x00dev->rfkill->get_state = rt2x00rfkill_get_state;
145 152
146 INIT_DELAYED_WORK(&rt2x00dev->rfkill_work, rt2x00rfkill_poll); 153 INIT_DELAYED_WORK(&rt2x00dev->rfkill_work, rt2x00rfkill_poll);
147 154
@@ -150,8 +157,7 @@ void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev)
150 157
151void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) 158void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev)
152{ 159{
153 if (!test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags) || 160 if (!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->flags))
154 !test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state))
155 return; 161 return;
156 162
157 cancel_delayed_work_sync(&rt2x00dev->rfkill_work); 163 cancel_delayed_work_sync(&rt2x00dev->rfkill_work);
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index d740f560ccd0..2c36b91ff4c7 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -163,7 +163,7 @@ rf_write:
163 rt2x00_rf_write(rt2x00dev, word, value); 163 rt2x00_rf_write(rt2x00dev, word, value);
164} 164}
165 165
166#ifdef CONFIG_RT61PCI_LEDS 166#ifdef CONFIG_RT2X00_LIB_LEDS
167/* 167/*
168 * This function is only called from rt61pci_led_brightness() 168 * This function is only called from rt61pci_led_brightness()
169 * make gcc happy by placing this function inside the 169 * make gcc happy by placing this function inside the
@@ -195,7 +195,7 @@ static void rt61pci_mcu_request(struct rt2x00_dev *rt2x00dev,
195 rt2x00_set_field32(&reg, HOST_CMD_CSR_INTERRUPT_MCU, 1); 195 rt2x00_set_field32(&reg, HOST_CMD_CSR_INTERRUPT_MCU, 1);
196 rt2x00pci_register_write(rt2x00dev, HOST_CMD_CSR, reg); 196 rt2x00pci_register_write(rt2x00dev, HOST_CMD_CSR, reg);
197} 197}
198#endif /* CONFIG_RT61PCI_LEDS */ 198#endif /* CONFIG_RT2X00_LIB_LEDS */
199 199
200static void rt61pci_eepromregister_read(struct eeprom_93cx6 *eeprom) 200static void rt61pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
201{ 201{
@@ -271,7 +271,7 @@ static const struct rt2x00debug rt61pci_rt2x00debug = {
271}; 271};
272#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 272#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
273 273
274#ifdef CONFIG_RT61PCI_RFKILL 274#ifdef CONFIG_RT2X00_LIB_RFKILL
275static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) 275static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
276{ 276{
277 u32 reg; 277 u32 reg;
@@ -281,9 +281,9 @@ static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev)
281} 281}
282#else 282#else
283#define rt61pci_rfkill_poll NULL 283#define rt61pci_rfkill_poll NULL
284#endif /* CONFIG_RT61PCI_RFKILL */ 284#endif /* CONFIG_RT2X00_LIB_RFKILL */
285 285
286#ifdef CONFIG_RT61PCI_LEDS 286#ifdef CONFIG_RT2X00_LIB_LEDS
287static void rt61pci_brightness_set(struct led_classdev *led_cdev, 287static void rt61pci_brightness_set(struct led_classdev *led_cdev,
288 enum led_brightness brightness) 288 enum led_brightness brightness)
289{ 289{
@@ -348,7 +348,7 @@ static void rt61pci_init_led(struct rt2x00_dev *rt2x00dev,
348 led->led_dev.blink_set = rt61pci_blink_set; 348 led->led_dev.blink_set = rt61pci_blink_set;
349 led->flags = LED_INITIALIZED; 349 led->flags = LED_INITIALIZED;
350} 350}
351#endif /* CONFIG_RT61PCI_LEDS */ 351#endif /* CONFIG_RT2X00_LIB_LEDS */
352 352
353/* 353/*
354 * Configuration handlers. 354 * Configuration handlers.
@@ -2313,10 +2313,10 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
2313 /* 2313 /*
2314 * Detect if this device has an hardware controlled radio. 2314 * Detect if this device has an hardware controlled radio.
2315 */ 2315 */
2316#ifdef CONFIG_RT61PCI_RFKILL 2316#ifdef CONFIG_RT2X00_LIB_RFKILL
2317 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) 2317 if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO))
2318 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); 2318 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
2319#endif /* CONFIG_RT61PCI_RFKILL */ 2319#endif /* CONFIG_RT2X00_LIB_RFKILL */
2320 2320
2321 /* 2321 /*
2322 * Read frequency offset and RF programming sequence. 2322 * Read frequency offset and RF programming sequence.
@@ -2374,7 +2374,7 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
2374 * If the eeprom value is invalid, 2374 * If the eeprom value is invalid,
2375 * switch to default led mode. 2375 * switch to default led mode.
2376 */ 2376 */
2377#ifdef CONFIG_RT61PCI_LEDS 2377#ifdef CONFIG_RT2X00_LIB_LEDS
2378 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom); 2378 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom);
2379 value = rt2x00_get_field16(eeprom, EEPROM_LED_LED_MODE); 2379 value = rt2x00_get_field16(eeprom, EEPROM_LED_LED_MODE);
2380 2380
@@ -2408,7 +2408,7 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
2408 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_READY_A, 2408 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_READY_A,
2409 rt2x00_get_field16(eeprom, 2409 rt2x00_get_field16(eeprom,
2410 EEPROM_LED_POLARITY_RDY_A)); 2410 EEPROM_LED_POLARITY_RDY_A));
2411#endif /* CONFIG_RT61PCI_LEDS */ 2411#endif /* CONFIG_RT2X00_LIB_LEDS */
2412 2412
2413 return 0; 2413 return 0;
2414} 2414}
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c
index e698ae0efbce..27dde3e34603 100644
--- a/drivers/net/wireless/rt2x00/rt73usb.c
+++ b/drivers/net/wireless/rt2x00/rt73usb.c
@@ -292,7 +292,7 @@ static const struct rt2x00debug rt73usb_rt2x00debug = {
292}; 292};
293#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 293#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
294 294
295#ifdef CONFIG_RT73USB_LEDS 295#ifdef CONFIG_RT2X00_LIB_LEDS
296static void rt73usb_brightness_set(struct led_classdev *led_cdev, 296static void rt73usb_brightness_set(struct led_classdev *led_cdev,
297 enum led_brightness brightness) 297 enum led_brightness brightness)
298{ 298{
@@ -359,7 +359,7 @@ static void rt73usb_init_led(struct rt2x00_dev *rt2x00dev,
359 led->led_dev.blink_set = rt73usb_blink_set; 359 led->led_dev.blink_set = rt73usb_blink_set;
360 led->flags = LED_INITIALIZED; 360 led->flags = LED_INITIALIZED;
361} 361}
362#endif /* CONFIG_RT73USB_LEDS */ 362#endif /* CONFIG_RT2X00_LIB_LEDS */
363 363
364/* 364/*
365 * Configuration handlers. 365 * Configuration handlers.
@@ -1572,7 +1572,6 @@ static void rt73usb_write_beacon(struct queue_entry *entry)
1572 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); 1572 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb);
1573 unsigned int beacon_base; 1573 unsigned int beacon_base;
1574 u32 reg; 1574 u32 reg;
1575 u32 word, len;
1576 1575
1577 /* 1576 /*
1578 * Add the descriptor in front of the skb. 1577 * Add the descriptor in front of the skb.
@@ -1582,17 +1581,6 @@ static void rt73usb_write_beacon(struct queue_entry *entry)
1582 skbdesc->desc = entry->skb->data; 1581 skbdesc->desc = entry->skb->data;
1583 1582
1584 /* 1583 /*
1585 * Adjust the beacon databyte count. The current number is
1586 * calculated before this function gets called, but falsely
1587 * assumes that the descriptor was already present in the SKB.
1588 */
1589 rt2x00_desc_read(skbdesc->desc, 0, &word);
1590 len = rt2x00_get_field32(word, TXD_W0_DATABYTE_COUNT);
1591 len += skbdesc->desc_len;
1592 rt2x00_set_field32(&word, TXD_W0_DATABYTE_COUNT, len);
1593 rt2x00_desc_write(skbdesc->desc, 0, word);
1594
1595 /*
1596 * Disable beaconing while we are reloading the beacon data, 1584 * Disable beaconing while we are reloading the beacon data,
1597 * otherwise we might be sending out invalid data. 1585 * otherwise we might be sending out invalid data.
1598 */ 1586 */
@@ -1944,7 +1932,7 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1944 /* 1932 /*
1945 * Store led settings, for correct led behaviour. 1933 * Store led settings, for correct led behaviour.
1946 */ 1934 */
1947#ifdef CONFIG_RT73USB_LEDS 1935#ifdef CONFIG_RT2X00_LIB_LEDS
1948 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom); 1936 rt2x00_eeprom_read(rt2x00dev, EEPROM_LED, &eeprom);
1949 1937
1950 rt73usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); 1938 rt73usb_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO);
@@ -1977,7 +1965,7 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1977 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_READY_A, 1965 rt2x00_set_field16(&rt2x00dev->led_mcu_reg, MCU_LEDCS_POLARITY_READY_A,
1978 rt2x00_get_field16(eeprom, 1966 rt2x00_get_field16(eeprom,
1979 EEPROM_LED_POLARITY_RDY_A)); 1967 EEPROM_LED_POLARITY_RDY_A));
1980#endif /* CONFIG_RT73USB_LEDS */ 1968#endif /* CONFIG_RT2X00_LIB_LEDS */
1981 1969
1982 return 0; 1970 return 0;
1983} 1971}