aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEliad Peller <eliad@wizery.com>2011-10-05 05:55:41 -0400
committerLuciano Coelho <coelho@ti.com>2011-10-07 01:32:33 -0400
commit87fbcb0f8c5c8fd57a4e3e7e638977c04ce1e0ca (patch)
tree7c4198319bbb1dc6bbcd5b4b683d4a023a635875
parent92c77c734f958474ac73af670834bc32cb833e54 (diff)
wl12xx: define wl12xx_vif
Define a per-vif data struct. This struct holds all the vif-specifc data, which is currently being hold by the global wl struct. Start by moving the basic_rate_set field into it. NOTE: in order to make the patches a bit smaller, start by using wl->vif in some functions, instead of changing all the function prototypes at once. finally, wl->vif will be removed altogether. Signed-off-by: Eliad Peller <eliad@wizery.com> Signed-off-by: Luciano Coelho <coelho@ti.com>
-rw-r--r--drivers/net/wireless/wl12xx/cmd.c21
-rw-r--r--drivers/net/wireless/wl12xx/cmd.h9
-rw-r--r--drivers/net/wireless/wl12xx/debugfs.c1
-rw-r--r--drivers/net/wireless/wl12xx/init.c34
-rw-r--r--drivers/net/wireless/wl12xx/init.h2
-rw-r--r--drivers/net/wireless/wl12xx/main.c70
-rw-r--r--drivers/net/wireless/wl12xx/wl12xx.h16
7 files changed, 96 insertions, 57 deletions
diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c
index bee44c7d67fd..c99fc61113d1 100644
--- a/drivers/net/wireless/wl12xx/cmd.c
+++ b/drivers/net/wireless/wl12xx/cmd.c
@@ -555,7 +555,7 @@ out:
555 return ret; 555 return ret;
556} 556}
557 557
558int wl12xx_cmd_role_start_sta(struct wl1271 *wl) 558int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif)
559{ 559{
560 struct wl12xx_cmd_role_start *cmd; 560 struct wl12xx_cmd_role_start *cmd;
561 int ret; 561 int ret;
@@ -572,7 +572,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl)
572 if (wl->band == IEEE80211_BAND_5GHZ) 572 if (wl->band == IEEE80211_BAND_5GHZ)
573 cmd->band = WL12XX_BAND_5GHZ; 573 cmd->band = WL12XX_BAND_5GHZ;
574 cmd->channel = wl->channel; 574 cmd->channel = wl->channel;
575 cmd->sta.basic_rate_set = cpu_to_le32(wl->basic_rate_set); 575 cmd->sta.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set);
576 cmd->sta.beacon_interval = cpu_to_le16(wl->beacon_int); 576 cmd->sta.beacon_interval = cpu_to_le16(wl->beacon_int);
577 cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY; 577 cmd->sta.ssid_type = WL12XX_SSID_TYPE_ANY;
578 cmd->sta.ssid_len = wl->ssid_len; 578 cmd->sta.ssid_len = wl->ssid_len;
@@ -592,7 +592,7 @@ int wl12xx_cmd_role_start_sta(struct wl1271 *wl)
592 wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " 592 wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d "
593 "basic_rate_set: 0x%x, remote_rates: 0x%x", 593 "basic_rate_set: 0x%x, remote_rates: 0x%x",
594 wl->role_id, cmd->sta.hlid, cmd->sta.session, 594 wl->role_id, cmd->sta.hlid, cmd->sta.session,
595 wl->basic_rate_set, wl->rate_set); 595 wlvif->basic_rate_set, wl->rate_set);
596 596
597 ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0); 597 ret = wl1271_cmd_send(wl, CMD_ROLE_START, cmd, sizeof(*cmd), 0);
598 if (ret < 0) { 598 if (ret < 0) {
@@ -649,7 +649,7 @@ out:
649 return ret; 649 return ret;
650} 650}
651 651
652int wl12xx_cmd_role_start_ap(struct wl1271 *wl) 652int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif)
653{ 653{
654 struct wl12xx_cmd_role_start *cmd; 654 struct wl12xx_cmd_role_start *cmd;
655 struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; 655 struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf;
@@ -683,7 +683,7 @@ int wl12xx_cmd_role_start_ap(struct wl1271 *wl)
683 cmd->ap.bss_index = WL1271_AP_BSS_INDEX; 683 cmd->ap.bss_index = WL1271_AP_BSS_INDEX;
684 cmd->ap.global_hlid = wl->ap_global_hlid; 684 cmd->ap.global_hlid = wl->ap_global_hlid;
685 cmd->ap.broadcast_hlid = wl->ap_bcast_hlid; 685 cmd->ap.broadcast_hlid = wl->ap_bcast_hlid;
686 cmd->ap.basic_rate_set = cpu_to_le32(wl->basic_rate_set); 686 cmd->ap.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set);
687 cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int); 687 cmd->ap.beacon_interval = cpu_to_le16(wl->beacon_int);
688 cmd->ap.dtim_interval = bss_conf->dtim_period; 688 cmd->ap.dtim_interval = bss_conf->dtim_period;
689 cmd->ap.beacon_expiry = WL1271_AP_DEF_BEACON_EXP; 689 cmd->ap.beacon_expiry = WL1271_AP_DEF_BEACON_EXP;
@@ -767,7 +767,7 @@ out:
767 return ret; 767 return ret;
768} 768}
769 769
770int wl12xx_cmd_role_start_ibss(struct wl1271 *wl) 770int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif)
771{ 771{
772 struct wl12xx_cmd_role_start *cmd; 772 struct wl12xx_cmd_role_start *cmd;
773 struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf; 773 struct ieee80211_bss_conf *bss_conf = &wl->vif->bss_conf;
@@ -785,7 +785,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl)
785 if (wl->band == IEEE80211_BAND_5GHZ) 785 if (wl->band == IEEE80211_BAND_5GHZ)
786 cmd->band = WL12XX_BAND_5GHZ; 786 cmd->band = WL12XX_BAND_5GHZ;
787 cmd->channel = wl->channel; 787 cmd->channel = wl->channel;
788 cmd->ibss.basic_rate_set = cpu_to_le32(wl->basic_rate_set); 788 cmd->ibss.basic_rate_set = cpu_to_le32(wlvif->basic_rate_set);
789 cmd->ibss.beacon_interval = cpu_to_le16(wl->beacon_int); 789 cmd->ibss.beacon_interval = cpu_to_le16(wl->beacon_int);
790 cmd->ibss.dtim_interval = bss_conf->dtim_period; 790 cmd->ibss.dtim_interval = bss_conf->dtim_period;
791 cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY; 791 cmd->ibss.ssid_type = WL12XX_SSID_TYPE_ANY;
@@ -805,7 +805,7 @@ int wl12xx_cmd_role_start_ibss(struct wl1271 *wl)
805 wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d " 805 wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d "
806 "basic_rate_set: 0x%x, remote_rates: 0x%x", 806 "basic_rate_set: 0x%x, remote_rates: 0x%x",
807 wl->role_id, cmd->sta.hlid, cmd->sta.session, 807 wl->role_id, cmd->sta.hlid, cmd->sta.session,
808 wl->basic_rate_set, wl->rate_set); 808 wlvif->basic_rate_set, wl->rate_set);
809 809
810 wl1271_debug(DEBUG_CMD, "wl->bssid = %pM", wl->bssid); 810 wl1271_debug(DEBUG_CMD, "wl->bssid = %pM", wl->bssid);
811 811
@@ -1085,7 +1085,8 @@ out:
1085 1085
1086} 1086}
1087 1087
1088int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid) 1088int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1089 u16 aid)
1089{ 1090{
1090 struct sk_buff *skb; 1091 struct sk_buff *skb;
1091 int ret = 0; 1092 int ret = 0;
@@ -1095,7 +1096,7 @@ int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid)
1095 goto out; 1096 goto out;
1096 1097
1097 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data, 1098 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data,
1098 skb->len, 0, wl->basic_rate_set); 1099 skb->len, 0, wlvif->basic_rate_set);
1099 1100
1100out: 1101out:
1101 dev_kfree_skb(skb); 1102 dev_kfree_skb(skb);
diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/cmd.h
index 1ae949f00c14..234a8dc90559 100644
--- a/drivers/net/wireless/wl12xx/cmd.h
+++ b/drivers/net/wireless/wl12xx/cmd.h
@@ -41,11 +41,11 @@ int wl12xx_cmd_role_enable(struct wl1271 *wl, u8 *addr, u8 role_type,
41int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id); 41int wl12xx_cmd_role_disable(struct wl1271 *wl, u8 *role_id);
42int wl12xx_cmd_role_start_dev(struct wl1271 *wl); 42int wl12xx_cmd_role_start_dev(struct wl1271 *wl);
43int wl12xx_cmd_role_stop_dev(struct wl1271 *wl); 43int wl12xx_cmd_role_stop_dev(struct wl1271 *wl);
44int wl12xx_cmd_role_start_sta(struct wl1271 *wl); 44int wl12xx_cmd_role_start_sta(struct wl1271 *wl, struct wl12xx_vif *wlvif);
45int wl12xx_cmd_role_stop_sta(struct wl1271 *wl); 45int wl12xx_cmd_role_stop_sta(struct wl1271 *wl);
46int wl12xx_cmd_role_start_ap(struct wl1271 *wl); 46int wl12xx_cmd_role_start_ap(struct wl1271 *wl, struct wl12xx_vif *wlvif);
47int wl12xx_cmd_role_stop_ap(struct wl1271 *wl); 47int wl12xx_cmd_role_stop_ap(struct wl1271 *wl);
48int wl12xx_cmd_role_start_ibss(struct wl1271 *wl); 48int wl12xx_cmd_role_start_ibss(struct wl1271 *wl, struct wl12xx_vif *wlvif);
49int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer); 49int wl1271_cmd_test(struct wl1271 *wl, void *buf, size_t buf_len, u8 answer);
50int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len); 50int wl1271_cmd_interrogate(struct wl1271 *wl, u16 id, void *buf, size_t len);
51int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len); 51int wl1271_cmd_configure(struct wl1271 *wl, u16 id, void *buf, size_t len);
@@ -56,7 +56,8 @@ int wl1271_cmd_read_memory(struct wl1271 *wl, u32 addr, void *answer,
56int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, 56int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
57 void *buf, size_t buf_len, int index, u32 rates); 57 void *buf, size_t buf_len, int index, u32 rates);
58int wl1271_cmd_build_null_data(struct wl1271 *wl); 58int wl1271_cmd_build_null_data(struct wl1271 *wl);
59int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid); 59int wl1271_cmd_build_ps_poll(struct wl1271 *wl, struct wl12xx_vif *wlvif,
60 u16 aid);
60int wl1271_cmd_build_probe_req(struct wl1271 *wl, 61int wl1271_cmd_build_probe_req(struct wl1271 *wl,
61 const u8 *ssid, size_t ssid_len, 62 const u8 *ssid, size_t ssid_len,
62 const u8 *ie, size_t ie_len, u8 band); 63 const u8 *ie, size_t ie_len, u8 band);
diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/debugfs.c
index 3999fd528302..0419aafe5c57 100644
--- a/drivers/net/wireless/wl12xx/debugfs.c
+++ b/drivers/net/wireless/wl12xx/debugfs.c
@@ -353,7 +353,6 @@ static ssize_t driver_state_read(struct file *file, char __user *user_buf,
353 DRIVER_STATE_PRINT_INT(bss_type); 353 DRIVER_STATE_PRINT_INT(bss_type);
354 DRIVER_STATE_PRINT_INT(channel); 354 DRIVER_STATE_PRINT_INT(channel);
355 DRIVER_STATE_PRINT_HEX(rate_set); 355 DRIVER_STATE_PRINT_HEX(rate_set);
356 DRIVER_STATE_PRINT_HEX(basic_rate_set);
357 DRIVER_STATE_PRINT_HEX(basic_rate); 356 DRIVER_STATE_PRINT_HEX(basic_rate);
358 DRIVER_STATE_PRINT_INT(band); 357 DRIVER_STATE_PRINT_INT(band);
359 DRIVER_STATE_PRINT_INT(beacon_int); 358 DRIVER_STATE_PRINT_INT(beacon_int);
diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/init.c
index 145601dddab0..c00bdf8a3584 100644
--- a/drivers/net/wireless/wl12xx/init.c
+++ b/drivers/net/wireless/wl12xx/init.c
@@ -122,7 +122,8 @@ int wl1271_init_templates_config(struct wl1271 *wl)
122 return 0; 122 return 0;
123} 123}
124 124
125static int wl1271_ap_init_deauth_template(struct wl1271 *wl) 125static int wl1271_ap_init_deauth_template(struct wl1271 *wl,
126 struct wl12xx_vif *wlvif)
126{ 127{
127 struct wl12xx_disconn_template *tmpl; 128 struct wl12xx_disconn_template *tmpl;
128 int ret; 129 int ret;
@@ -137,7 +138,7 @@ static int wl1271_ap_init_deauth_template(struct wl1271 *wl)
137 tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT | 138 tmpl->header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_MGMT |
138 IEEE80211_STYPE_DEAUTH); 139 IEEE80211_STYPE_DEAUTH);
139 140
140 rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 141 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
141 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP, 142 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_DEAUTH_AP,
142 tmpl, sizeof(*tmpl), 0, rate); 143 tmpl, sizeof(*tmpl), 0, rate);
143 144
@@ -149,6 +150,7 @@ out:
149static int wl1271_ap_init_null_template(struct wl1271 *wl, 150static int wl1271_ap_init_null_template(struct wl1271 *wl,
150 struct ieee80211_vif *vif) 151 struct ieee80211_vif *vif)
151{ 152{
153 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
152 struct ieee80211_hdr_3addr *nullfunc; 154 struct ieee80211_hdr_3addr *nullfunc;
153 int ret; 155 int ret;
154 u32 rate; 156 u32 rate;
@@ -168,7 +170,7 @@ static int wl1271_ap_init_null_template(struct wl1271 *wl,
168 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN); 170 memcpy(nullfunc->addr2, vif->addr, ETH_ALEN);
169 memcpy(nullfunc->addr3, vif->addr, ETH_ALEN); 171 memcpy(nullfunc->addr3, vif->addr, ETH_ALEN);
170 172
171 rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 173 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
172 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc, 174 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, nullfunc,
173 sizeof(*nullfunc), 0, rate); 175 sizeof(*nullfunc), 0, rate);
174 176
@@ -180,6 +182,7 @@ out:
180static int wl1271_ap_init_qos_null_template(struct wl1271 *wl, 182static int wl1271_ap_init_qos_null_template(struct wl1271 *wl,
181 struct ieee80211_vif *vif) 183 struct ieee80211_vif *vif)
182{ 184{
185 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
183 struct ieee80211_qos_hdr *qosnull; 186 struct ieee80211_qos_hdr *qosnull;
184 int ret; 187 int ret;
185 u32 rate; 188 u32 rate;
@@ -199,7 +202,7 @@ static int wl1271_ap_init_qos_null_template(struct wl1271 *wl,
199 memcpy(qosnull->addr2, vif->addr, ETH_ALEN); 202 memcpy(qosnull->addr2, vif->addr, ETH_ALEN);
200 memcpy(qosnull->addr3, vif->addr, ETH_ALEN); 203 memcpy(qosnull->addr3, vif->addr, ETH_ALEN);
201 204
202 rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 205 rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
203 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull, 206 ret = wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, qosnull,
204 sizeof(*qosnull), 0, rate); 207 sizeof(*qosnull), 0, rate);
205 208
@@ -370,7 +373,7 @@ static int wl1271_sta_hw_init_post_mem(struct wl1271 *wl)
370} 373}
371 374
372/* generic ap initialization (non vif-specific) */ 375/* generic ap initialization (non vif-specific) */
373static int wl1271_ap_hw_init(struct wl1271 *wl) 376static int wl1271_ap_hw_init(struct wl1271 *wl, struct wl12xx_vif *wlvif)
374{ 377{
375 int ret; 378 int ret;
376 379
@@ -379,7 +382,7 @@ static int wl1271_ap_hw_init(struct wl1271 *wl)
379 if (ret < 0) 382 if (ret < 0)
380 return ret; 383 return ret;
381 384
382 ret = wl1271_init_ap_rates(wl); 385 ret = wl1271_init_ap_rates(wl, wlvif);
383 if (ret < 0) 386 if (ret < 0)
384 return ret; 387 return ret;
385 388
@@ -388,9 +391,10 @@ static int wl1271_ap_hw_init(struct wl1271 *wl)
388 391
389int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif) 392int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif)
390{ 393{
394 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
391 int ret; 395 int ret;
392 396
393 ret = wl1271_ap_init_deauth_template(wl); 397 ret = wl1271_ap_init_deauth_template(wl, wlvif);
394 if (ret < 0) 398 if (ret < 0)
395 return ret; 399 return ret;
396 400
@@ -419,18 +423,19 @@ static int wl1271_ap_hw_init_post_mem(struct wl1271 *wl,
419 return wl1271_ap_init_templates(wl, vif); 423 return wl1271_ap_init_templates(wl, vif);
420} 424}
421 425
422int wl1271_init_ap_rates(struct wl1271 *wl) 426int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif)
423{ 427{
424 int i, ret; 428 int i, ret;
425 struct conf_tx_rate_class rc; 429 struct conf_tx_rate_class rc;
426 u32 supported_rates; 430 u32 supported_rates;
427 431
428 wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x", wl->basic_rate_set); 432 wl1271_debug(DEBUG_AP, "AP basic rate set: 0x%x",
433 wlvif->basic_rate_set);
429 434
430 if (wl->basic_rate_set == 0) 435 if (wlvif->basic_rate_set == 0)
431 return -EINVAL; 436 return -EINVAL;
432 437
433 rc.enabled_rates = wl->basic_rate_set; 438 rc.enabled_rates = wlvif->basic_rate_set;
434 rc.long_retry_limit = 10; 439 rc.long_retry_limit = 10;
435 rc.short_retry_limit = 10; 440 rc.short_retry_limit = 10;
436 rc.aflags = 0; 441 rc.aflags = 0;
@@ -439,7 +444,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl)
439 return ret; 444 return ret;
440 445
441 /* use the min basic rate for AP broadcast/multicast */ 446 /* use the min basic rate for AP broadcast/multicast */
442 rc.enabled_rates = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 447 rc.enabled_rates = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
443 rc.short_retry_limit = 10; 448 rc.short_retry_limit = 10;
444 rc.long_retry_limit = 10; 449 rc.long_retry_limit = 10;
445 rc.aflags = 0; 450 rc.aflags = 0;
@@ -451,7 +456,7 @@ int wl1271_init_ap_rates(struct wl1271 *wl)
451 * If the basic rates contain OFDM rates, use OFDM only 456 * If the basic rates contain OFDM rates, use OFDM only
452 * rates for unicast TX as well. Else use all supported rates. 457 * rates for unicast TX as well. Else use all supported rates.
453 */ 458 */
454 if ((wl->basic_rate_set & CONF_TX_OFDM_RATES)) 459 if ((wlvif->basic_rate_set & CONF_TX_OFDM_RATES))
455 supported_rates = CONF_TX_OFDM_RATES; 460 supported_rates = CONF_TX_OFDM_RATES;
456 else 461 else
457 supported_rates = CONF_TX_AP_ENABLED_RATES; 462 supported_rates = CONF_TX_AP_ENABLED_RATES;
@@ -564,6 +569,7 @@ static int wl12xx_init_ap_role(struct wl1271 *wl, struct ieee80211_vif *vif)
564 569
565int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif) 570int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif)
566{ 571{
572 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
567 struct conf_tx_ac_category *conf_ac; 573 struct conf_tx_ac_category *conf_ac;
568 struct conf_tx_tid *conf_tid; 574 struct conf_tx_tid *conf_tid;
569 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); 575 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
@@ -572,7 +578,7 @@ int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif)
572 578
573 /* Mode specific init */ 579 /* Mode specific init */
574 if (is_ap) { 580 if (is_ap) {
575 ret = wl1271_ap_hw_init(wl); 581 ret = wl1271_ap_hw_init(wl, wlvif);
576 if (ret < 0) 582 if (ret < 0)
577 return ret; 583 return ret;
578 584
diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/init.h
index 64320c0224ca..81140b81f654 100644
--- a/drivers/net/wireless/wl12xx/init.h
+++ b/drivers/net/wireless/wl12xx/init.h
@@ -34,7 +34,7 @@ int wl1271_init_energy_detection(struct wl1271 *wl);
34int wl1271_chip_specific_init(struct wl1271 *wl); 34int wl1271_chip_specific_init(struct wl1271 *wl);
35int wl1271_hw_init(struct wl1271 *wl); 35int wl1271_hw_init(struct wl1271 *wl);
36int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif); 36int wl1271_init_vif_specific(struct wl1271 *wl, struct ieee80211_vif *vif);
37int wl1271_init_ap_rates(struct wl1271 *wl); 37int wl1271_init_ap_rates(struct wl1271 *wl, struct wl12xx_vif *wlvif);
38int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif); 38int wl1271_ap_init_templates(struct wl1271 *wl, struct ieee80211_vif *vif);
39 39
40#endif 40#endif
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/main.c
index 901e43a8334b..0c43cf55f9bf 100644
--- a/drivers/net/wireless/wl12xx/main.c
+++ b/drivers/net/wireless/wl12xx/main.c
@@ -1837,6 +1837,11 @@ static u8 wl12xx_get_role_type(struct wl1271 *wl)
1837 return WL12XX_INVALID_ROLE_TYPE; 1837 return WL12XX_INVALID_ROLE_TYPE;
1838} 1838}
1839 1839
1840static void wl12xx_init_vif_data(struct wl12xx_vif *wlvif)
1841{
1842 wlvif->basic_rate_set = CONF_TX_RATE_MASK_BASIC;
1843}
1844
1840static int wl1271_op_add_interface(struct ieee80211_hw *hw, 1845static int wl1271_op_add_interface(struct ieee80211_hw *hw,
1841 struct ieee80211_vif *vif) 1846 struct ieee80211_vif *vif)
1842{ 1847{
@@ -1857,6 +1862,7 @@ static int wl1271_op_add_interface(struct ieee80211_hw *hw,
1857 ret = -EBUSY; 1862 ret = -EBUSY;
1858 goto out; 1863 goto out;
1859 } 1864 }
1865 wl12xx_init_vif_data(wl12xx_vif_to_data(vif));
1860 1866
1861 /* 1867 /*
1862 * in some very corner case HW recovery scenarios its possible to 1868 * in some very corner case HW recovery scenarios its possible to
@@ -2163,7 +2169,8 @@ static void wl1271_op_remove_interface(struct ieee80211_hw *hw,
2163 cancel_work_sync(&wl->recovery_work); 2169 cancel_work_sync(&wl->recovery_work);
2164} 2170}
2165 2171
2166static int wl1271_join(struct wl1271 *wl, bool set_assoc) 2172static int wl1271_join(struct wl1271 *wl, struct wl12xx_vif *wlvif,
2173 bool set_assoc)
2167{ 2174{
2168 int ret; 2175 int ret;
2169 bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); 2176 bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS);
@@ -2184,9 +2191,9 @@ static int wl1271_join(struct wl1271 *wl, bool set_assoc)
2184 set_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags); 2191 set_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags);
2185 2192
2186 if (is_ibss) 2193 if (is_ibss)
2187 ret = wl12xx_cmd_role_start_ibss(wl); 2194 ret = wl12xx_cmd_role_start_ibss(wl, wlvif);
2188 else 2195 else
2189 ret = wl12xx_cmd_role_start_sta(wl); 2196 ret = wl12xx_cmd_role_start_sta(wl, wlvif);
2190 if (ret < 0) 2197 if (ret < 0)
2191 goto out; 2198 goto out;
2192 2199
@@ -2244,10 +2251,10 @@ out:
2244 return ret; 2251 return ret;
2245} 2252}
2246 2253
2247static void wl1271_set_band_rate(struct wl1271 *wl) 2254static void wl1271_set_band_rate(struct wl1271 *wl, struct wl12xx_vif *wlvif)
2248{ 2255{
2249 wl->basic_rate_set = wl->bitrate_masks[wl->band]; 2256 wlvif->basic_rate_set = wl->bitrate_masks[wl->band];
2250 wl->rate_set = wl->basic_rate_set; 2257 wl->rate_set = wlvif->basic_rate_set;
2251} 2258}
2252 2259
2253static bool wl12xx_is_roc(struct wl1271 *wl) 2260static bool wl12xx_is_roc(struct wl1271 *wl)
@@ -2261,7 +2268,8 @@ static bool wl12xx_is_roc(struct wl1271 *wl)
2261 return true; 2268 return true;
2262} 2269}
2263 2270
2264static int wl1271_sta_handle_idle(struct wl1271 *wl, bool idle) 2271static int wl1271_sta_handle_idle(struct wl1271 *wl, struct wl12xx_vif *wlvif,
2272 bool idle)
2265{ 2273{
2266 int ret; 2274 int ret;
2267 2275
@@ -2276,7 +2284,8 @@ static int wl1271_sta_handle_idle(struct wl1271 *wl, bool idle)
2276 if (ret < 0) 2284 if (ret < 0)
2277 goto out; 2285 goto out;
2278 } 2286 }
2279 wl->rate_set = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 2287 wl->rate_set = wl1271_tx_min_rate_get(wl,
2288 wlvif->basic_rate_set);
2280 ret = wl1271_acx_sta_rate_policies(wl); 2289 ret = wl1271_acx_sta_rate_policies(wl);
2281 if (ret < 0) 2290 if (ret < 0)
2282 goto out; 2291 goto out;
@@ -2310,6 +2319,8 @@ out:
2310static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed) 2319static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
2311{ 2320{
2312 struct wl1271 *wl = hw->priv; 2321 struct wl1271 *wl = hw->priv;
2322 struct ieee80211_vif *vif = wl->vif; /* TODO: reconfig all vifs */
2323 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
2313 struct ieee80211_conf *conf = &hw->conf; 2324 struct ieee80211_conf *conf = &hw->conf;
2314 int channel, ret = 0; 2325 int channel, ret = 0;
2315 bool is_ap; 2326 bool is_ap;
@@ -2371,10 +2382,11 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
2371 * association frames and other control messages. 2382 * association frames and other control messages.
2372 */ 2383 */
2373 if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) 2384 if (!test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags))
2374 wl1271_set_band_rate(wl); 2385 wl1271_set_band_rate(wl, wlvif);
2375 2386
2376 wl->basic_rate = 2387 wl->basic_rate =
2377 wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 2388 wl1271_tx_min_rate_get(wl,
2389 wlvif->basic_rate_set);
2378 ret = wl1271_acx_sta_rate_policies(wl); 2390 ret = wl1271_acx_sta_rate_policies(wl);
2379 if (ret < 0) 2391 if (ret < 0)
2380 wl1271_warning("rate policy for channel " 2392 wl1271_warning("rate policy for channel "
@@ -2387,7 +2399,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
2387 if (ret < 0) 2399 if (ret < 0)
2388 goto out_sleep; 2400 goto out_sleep;
2389 } 2401 }
2390 ret = wl1271_join(wl, false); 2402 ret = wl1271_join(wl, wlvif, false);
2391 if (ret < 0) 2403 if (ret < 0)
2392 wl1271_warning("cmd join on channel " 2404 wl1271_warning("cmd join on channel "
2393 "failed %d", ret); 2405 "failed %d", ret);
@@ -2413,7 +2425,7 @@ static int wl1271_op_config(struct ieee80211_hw *hw, u32 changed)
2413 } 2425 }
2414 2426
2415 if (changed & IEEE80211_CONF_CHANGE_IDLE && !is_ap) { 2427 if (changed & IEEE80211_CONF_CHANGE_IDLE && !is_ap) {
2416 ret = wl1271_sta_handle_idle(wl, 2428 ret = wl1271_sta_handle_idle(wl, wlvif,
2417 conf->flags & IEEE80211_CONF_IDLE); 2429 conf->flags & IEEE80211_CONF_IDLE);
2418 if (ret < 0) 2430 if (ret < 0)
2419 wl1271_warning("idle mode change failed %d", ret); 2431 wl1271_warning("idle mode change failed %d", ret);
@@ -3207,6 +3219,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl,
3207 struct ieee80211_bss_conf *bss_conf, 3219 struct ieee80211_bss_conf *bss_conf,
3208 u32 changed) 3220 u32 changed)
3209{ 3221{
3222 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3210 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS); 3223 bool is_ap = (wl->bss_type == BSS_TYPE_AP_BSS);
3211 int ret = 0; 3224 int ret = 0;
3212 3225
@@ -3235,7 +3248,7 @@ static int wl1271_bss_beacon_info_changed(struct wl1271 *wl,
3235 dev_kfree_skb(beacon); 3248 dev_kfree_skb(beacon);
3236 goto out; 3249 goto out;
3237 } 3250 }
3238 min_rate = wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 3251 min_rate = wl1271_tx_min_rate_get(wl, wlvif->basic_rate_set);
3239 tmpl_id = is_ap ? CMD_TEMPL_AP_BEACON : 3252 tmpl_id = is_ap ? CMD_TEMPL_AP_BEACON :
3240 CMD_TEMPL_BEACON; 3253 CMD_TEMPL_BEACON;
3241 ret = wl1271_cmd_template_set(wl, tmpl_id, 3254 ret = wl1271_cmd_template_set(wl, tmpl_id,
@@ -3290,17 +3303,18 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl,
3290 struct ieee80211_bss_conf *bss_conf, 3303 struct ieee80211_bss_conf *bss_conf,
3291 u32 changed) 3304 u32 changed)
3292{ 3305{
3306 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3293 int ret = 0; 3307 int ret = 0;
3294 3308
3295 if ((changed & BSS_CHANGED_BASIC_RATES)) { 3309 if ((changed & BSS_CHANGED_BASIC_RATES)) {
3296 u32 rates = bss_conf->basic_rates; 3310 u32 rates = bss_conf->basic_rates;
3297 3311
3298 wl->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates, 3312 wlvif->basic_rate_set = wl1271_tx_enabled_rates_get(wl, rates,
3299 wl->band); 3313 wl->band);
3300 wl->basic_rate = wl1271_tx_min_rate_get(wl, 3314 wl->basic_rate = wl1271_tx_min_rate_get(wl,
3301 wl->basic_rate_set); 3315 wlvif->basic_rate_set);
3302 3316
3303 ret = wl1271_init_ap_rates(wl); 3317 ret = wl1271_init_ap_rates(wl, wlvif);
3304 if (ret < 0) { 3318 if (ret < 0) {
3305 wl1271_error("AP rate policy change failed %d", ret); 3319 wl1271_error("AP rate policy change failed %d", ret);
3306 goto out; 3320 goto out;
@@ -3318,7 +3332,7 @@ static void wl1271_bss_info_changed_ap(struct wl1271 *wl,
3318 if ((changed & BSS_CHANGED_BEACON_ENABLED)) { 3332 if ((changed & BSS_CHANGED_BEACON_ENABLED)) {
3319 if (bss_conf->enable_beacon) { 3333 if (bss_conf->enable_beacon) {
3320 if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) { 3334 if (!test_bit(WL1271_FLAG_AP_STARTED, &wl->flags)) {
3321 ret = wl12xx_cmd_role_start_ap(wl); 3335 ret = wl12xx_cmd_role_start_ap(wl, wlvif);
3322 if (ret < 0) 3336 if (ret < 0)
3323 goto out; 3337 goto out;
3324 3338
@@ -3366,6 +3380,7 @@ static void wl1271_bss_info_changed_sta(struct wl1271 *wl,
3366 struct ieee80211_bss_conf *bss_conf, 3380 struct ieee80211_bss_conf *bss_conf,
3367 u32 changed) 3381 u32 changed)
3368{ 3382{
3383 struct wl12xx_vif *wlvif = wl12xx_vif_to_data(vif);
3369 bool do_join = false, set_assoc = false; 3384 bool do_join = false, set_assoc = false;
3370 bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS); 3385 bool is_ibss = (wl->bss_type == BSS_TYPE_IBSS);
3371 bool ibss_joined = false; 3386 bool ibss_joined = false;
@@ -3480,11 +3495,12 @@ sta_not_found:
3480 * to use with control frames. 3495 * to use with control frames.
3481 */ 3496 */
3482 rates = bss_conf->basic_rates; 3497 rates = bss_conf->basic_rates;
3483 wl->basic_rate_set = 3498 wlvif->basic_rate_set =
3484 wl1271_tx_enabled_rates_get(wl, rates, 3499 wl1271_tx_enabled_rates_get(wl, rates,
3485 wl->band); 3500 wl->band);
3486 wl->basic_rate = 3501 wl->basic_rate =
3487 wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 3502 wl1271_tx_min_rate_get(wl,
3503 wlvif->basic_rate_set);
3488 if (sta_rate_set) 3504 if (sta_rate_set)
3489 wl->rate_set = wl1271_tx_enabled_rates_get(wl, 3505 wl->rate_set = wl1271_tx_enabled_rates_get(wl,
3490 sta_rate_set, 3506 sta_rate_set,
@@ -3499,7 +3515,7 @@ sta_not_found:
3499 * updates it by itself when the first beacon is 3515 * updates it by itself when the first beacon is
3500 * received after a join. 3516 * received after a join.
3501 */ 3517 */
3502 ret = wl1271_cmd_build_ps_poll(wl, wl->aid); 3518 ret = wl1271_cmd_build_ps_poll(wl, wlvif, wl->aid);
3503 if (ret < 0) 3519 if (ret < 0)
3504 goto out; 3520 goto out;
3505 3521
@@ -3534,9 +3550,10 @@ sta_not_found:
3534 ieee80211_enable_dyn_ps(wl->vif); 3550 ieee80211_enable_dyn_ps(wl->vif);
3535 3551
3536 /* revert back to minimum rates for the current band */ 3552 /* revert back to minimum rates for the current band */
3537 wl1271_set_band_rate(wl); 3553 wl1271_set_band_rate(wl, wlvif);
3538 wl->basic_rate = 3554 wl->basic_rate =
3539 wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 3555 wl1271_tx_min_rate_get(wl,
3556 wlvif->basic_rate_set);
3540 ret = wl1271_acx_sta_rate_policies(wl); 3557 ret = wl1271_acx_sta_rate_policies(wl);
3541 if (ret < 0) 3558 if (ret < 0)
3542 goto out; 3559 goto out;
@@ -3587,11 +3604,12 @@ sta_not_found:
3587 3604
3588 if (bss_conf->ibss_joined) { 3605 if (bss_conf->ibss_joined) {
3589 u32 rates = bss_conf->basic_rates; 3606 u32 rates = bss_conf->basic_rates;
3590 wl->basic_rate_set = 3607 wlvif->basic_rate_set =
3591 wl1271_tx_enabled_rates_get(wl, rates, 3608 wl1271_tx_enabled_rates_get(wl, rates,
3592 wl->band); 3609 wl->band);
3593 wl->basic_rate = 3610 wl->basic_rate =
3594 wl1271_tx_min_rate_get(wl, wl->basic_rate_set); 3611 wl1271_tx_min_rate_get(wl,
3612 wlvif->basic_rate_set);
3595 3613
3596 /* by default, use 11b + OFDM rates */ 3614 /* by default, use 11b + OFDM rates */
3597 wl->rate_set = CONF_TX_IBSS_DEFAULT_RATES; 3615 wl->rate_set = CONF_TX_IBSS_DEFAULT_RATES;
@@ -3634,7 +3652,7 @@ sta_not_found:
3634 } 3652 }
3635 3653
3636 if (do_join) { 3654 if (do_join) {
3637 ret = wl1271_join(wl, set_assoc); 3655 ret = wl1271_join(wl, wlvif, set_assoc);
3638 if (ret < 0) { 3656 if (ret < 0) {
3639 wl1271_warning("cmd join failed %d", ret); 3657 wl1271_warning("cmd join failed %d", ret);
3640 goto out; 3658 goto out;
@@ -4750,6 +4768,7 @@ int wl1271_init_ieee80211(struct wl1271 *wl)
4750 SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl)); 4768 SET_IEEE80211_DEV(wl->hw, wl1271_wl_to_dev(wl));
4751 4769
4752 wl->hw->sta_data_size = sizeof(struct wl1271_station); 4770 wl->hw->sta_data_size = sizeof(struct wl1271_station);
4771 wl->hw->vif_data_size = sizeof(struct wl12xx_vif);
4753 4772
4754 wl->hw->max_rx_aggregation_subframes = 8; 4773 wl->hw->max_rx_aggregation_subframes = 8;
4755 4774
@@ -4824,7 +4843,6 @@ struct ieee80211_hw *wl1271_alloc_hw(void)
4824 wl->rx_counter = 0; 4843 wl->rx_counter = 0;
4825 wl->psm_entry_retry = 0; 4844 wl->psm_entry_retry = 0;
4826 wl->power_level = WL1271_DEFAULT_POWER_LEVEL; 4845 wl->power_level = WL1271_DEFAULT_POWER_LEVEL;
4827 wl->basic_rate_set = CONF_TX_RATE_MASK_BASIC;
4828 wl->basic_rate = CONF_TX_RATE_MASK_BASIC; 4846 wl->basic_rate = CONF_TX_RATE_MASK_BASIC;
4829 wl->rate_set = CONF_TX_RATE_MASK_BASIC; 4847 wl->rate_set = CONF_TX_RATE_MASK_BASIC;
4830 wl->band = IEEE80211_BAND_2GHZ; 4848 wl->band = IEEE80211_BAND_2GHZ;
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h
index b8de2f5e052b..7e30dd53cb88 100644
--- a/drivers/net/wireless/wl12xx/wl12xx.h
+++ b/drivers/net/wireless/wl12xx/wl12xx.h
@@ -525,7 +525,6 @@ struct wl1271 {
525 * bits 16-23 - 802.11n MCS index mask 525 * bits 16-23 - 802.11n MCS index mask
526 * support only 1 stream, thus only 8 bits for the MCS rates (0-7). 526 * support only 1 stream, thus only 8 bits for the MCS rates (0-7).
527 */ 527 */
528 u32 basic_rate_set;
529 u32 basic_rate; 528 u32 basic_rate;
530 u32 rate_set; 529 u32 rate_set;
531 u32 bitrate_masks[IEEE80211_NUM_BANDS]; 530 u32 bitrate_masks[IEEE80211_NUM_BANDS];
@@ -639,6 +638,21 @@ struct wl1271_station {
639 u8 hlid; 638 u8 hlid;
640}; 639};
641 640
641struct wl12xx_vif {
642 u32 basic_rate_set;
643};
644
645static inline struct wl12xx_vif *wl12xx_vif_to_data(struct ieee80211_vif *vif)
646{
647 return (struct wl12xx_vif *)vif->drv_priv;
648}
649
650static inline
651struct ieee80211_vif *wl12xx_wlvif_to_vif(struct wl12xx_vif *wlvif)
652{
653 return container_of((void *)wlvif, struct ieee80211_vif, drv_priv);
654}
655
642int wl1271_plt_start(struct wl1271 *wl); 656int wl1271_plt_start(struct wl1271 *wl);
643int wl1271_plt_stop(struct wl1271 *wl); 657int wl1271_plt_stop(struct wl1271 *wl);
644int wl1271_recalc_rx_streaming(struct wl1271 *wl); 658int wl1271_recalc_rx_streaming(struct wl1271 *wl);