diff options
author | John W. Linville <linville@tuxdriver.com> | 2010-07-13 15:57:29 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-07-13 15:57:29 -0400 |
commit | e300d955debdadf599c36e47eb0bc16f5976215c (patch) | |
tree | 8fafcc789dc06e90665e6eee6388af228bbd2fd7 /drivers/net/wireless/wl12xx/wl1271_cmd.c | |
parent | 242647bcf8464860f173f3d4d4ab3490d3558518 (diff) | |
parent | 815868e7b5c207ba42d5b317ccc51f8112732268 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6 into for-davem
Conflicts:
drivers/net/wireless/wl12xx/wl1271_cmd.h
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_cmd.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_cmd.c | 248 |
1 files changed, 4 insertions, 244 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_cmd.c b/drivers/net/wireless/wl12xx/wl1271_cmd.c index 530678e45a13..ce503ddd5a41 100644 --- a/drivers/net/wireless/wl12xx/wl1271_cmd.c +++ b/drivers/net/wireless/wl12xx/wl1271_cmd.c | |||
@@ -104,100 +104,6 @@ out: | |||
104 | return ret; | 104 | return ret; |
105 | } | 105 | } |
106 | 106 | ||
107 | static int wl1271_cmd_cal_channel_tune(struct wl1271 *wl) | ||
108 | { | ||
109 | struct wl1271_cmd_cal_channel_tune *cmd; | ||
110 | int ret = 0; | ||
111 | |||
112 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
113 | if (!cmd) | ||
114 | return -ENOMEM; | ||
115 | |||
116 | cmd->test.id = TEST_CMD_CHANNEL_TUNE; | ||
117 | |||
118 | cmd->band = WL1271_CHANNEL_TUNE_BAND_2_4; | ||
119 | /* set up any channel, 7 is in the middle of the range */ | ||
120 | cmd->channel = 7; | ||
121 | |||
122 | ret = wl1271_cmd_test(wl, cmd, sizeof(*cmd), 0); | ||
123 | if (ret < 0) | ||
124 | wl1271_warning("TEST_CMD_CHANNEL_TUNE failed"); | ||
125 | |||
126 | kfree(cmd); | ||
127 | return ret; | ||
128 | } | ||
129 | |||
130 | static int wl1271_cmd_cal_update_ref_point(struct wl1271 *wl) | ||
131 | { | ||
132 | struct wl1271_cmd_cal_update_ref_point *cmd; | ||
133 | int ret = 0; | ||
134 | |||
135 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
136 | if (!cmd) | ||
137 | return -ENOMEM; | ||
138 | |||
139 | cmd->test.id = TEST_CMD_UPDATE_PD_REFERENCE_POINT; | ||
140 | |||
141 | /* FIXME: still waiting for the correct values */ | ||
142 | cmd->ref_power = 0; | ||
143 | cmd->ref_detector = 0; | ||
144 | |||
145 | cmd->sub_band = WL1271_PD_REFERENCE_POINT_BAND_B_G; | ||
146 | |||
147 | ret = wl1271_cmd_test(wl, cmd, sizeof(*cmd), 0); | ||
148 | if (ret < 0) | ||
149 | wl1271_warning("TEST_CMD_UPDATE_PD_REFERENCE_POINT failed"); | ||
150 | |||
151 | kfree(cmd); | ||
152 | return ret; | ||
153 | } | ||
154 | |||
155 | static int wl1271_cmd_cal_p2g(struct wl1271 *wl) | ||
156 | { | ||
157 | struct wl1271_cmd_cal_p2g *cmd; | ||
158 | int ret = 0; | ||
159 | |||
160 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
161 | if (!cmd) | ||
162 | return -ENOMEM; | ||
163 | |||
164 | cmd->test.id = TEST_CMD_P2G_CAL; | ||
165 | |||
166 | cmd->sub_band_mask = WL1271_CAL_P2G_BAND_B_G; | ||
167 | |||
168 | ret = wl1271_cmd_test(wl, cmd, sizeof(*cmd), 0); | ||
169 | if (ret < 0) | ||
170 | wl1271_warning("TEST_CMD_P2G_CAL failed"); | ||
171 | |||
172 | kfree(cmd); | ||
173 | return ret; | ||
174 | } | ||
175 | |||
176 | static int wl1271_cmd_cal(struct wl1271 *wl) | ||
177 | { | ||
178 | /* | ||
179 | * FIXME: we must make sure that we're not sleeping when calibration | ||
180 | * is done | ||
181 | */ | ||
182 | int ret; | ||
183 | |||
184 | wl1271_notice("performing tx calibration"); | ||
185 | |||
186 | ret = wl1271_cmd_cal_channel_tune(wl); | ||
187 | if (ret < 0) | ||
188 | return ret; | ||
189 | |||
190 | ret = wl1271_cmd_cal_update_ref_point(wl); | ||
191 | if (ret < 0) | ||
192 | return ret; | ||
193 | |||
194 | ret = wl1271_cmd_cal_p2g(wl); | ||
195 | if (ret < 0) | ||
196 | return ret; | ||
197 | |||
198 | return ret; | ||
199 | } | ||
200 | |||
201 | int wl1271_cmd_general_parms(struct wl1271 *wl) | 107 | int wl1271_cmd_general_parms(struct wl1271 *wl) |
202 | { | 108 | { |
203 | struct wl1271_general_parms_cmd *gen_parms; | 109 | struct wl1271_general_parms_cmd *gen_parms; |
@@ -226,7 +132,7 @@ int wl1271_cmd_general_parms(struct wl1271 *wl) | |||
226 | int wl1271_cmd_radio_parms(struct wl1271 *wl) | 132 | int wl1271_cmd_radio_parms(struct wl1271 *wl) |
227 | { | 133 | { |
228 | struct wl1271_radio_parms_cmd *radio_parms; | 134 | struct wl1271_radio_parms_cmd *radio_parms; |
229 | struct conf_radio_parms *rparam = &wl->conf.init.radioparam; | 135 | struct wl1271_ini_general_params *gp = &wl->nvs->general_params; |
230 | int ret; | 136 | int ret; |
231 | 137 | ||
232 | if (!wl->nvs) | 138 | if (!wl->nvs) |
@@ -242,7 +148,7 @@ int wl1271_cmd_radio_parms(struct wl1271 *wl) | |||
242 | memcpy(&radio_parms->static_params_2, &wl->nvs->stat_radio_params_2, | 148 | memcpy(&radio_parms->static_params_2, &wl->nvs->stat_radio_params_2, |
243 | sizeof(struct wl1271_ini_band_params_2)); | 149 | sizeof(struct wl1271_ini_band_params_2)); |
244 | memcpy(&radio_parms->dyn_params_2, | 150 | memcpy(&radio_parms->dyn_params_2, |
245 | &wl->nvs->dyn_radio_params_2[rparam->fem].params, | 151 | &wl->nvs->dyn_radio_params_2[gp->tx_bip_fem_manufacturer].params, |
246 | sizeof(struct wl1271_ini_fem_params_2)); | 152 | sizeof(struct wl1271_ini_fem_params_2)); |
247 | 153 | ||
248 | /* 5GHz parameters */ | 154 | /* 5GHz parameters */ |
@@ -250,7 +156,7 @@ int wl1271_cmd_radio_parms(struct wl1271 *wl) | |||
250 | &wl->nvs->stat_radio_params_5, | 156 | &wl->nvs->stat_radio_params_5, |
251 | sizeof(struct wl1271_ini_band_params_5)); | 157 | sizeof(struct wl1271_ini_band_params_5)); |
252 | memcpy(&radio_parms->dyn_params_5, | 158 | memcpy(&radio_parms->dyn_params_5, |
253 | &wl->nvs->dyn_radio_params_5[rparam->fem].params, | 159 | &wl->nvs->dyn_radio_params_5[gp->tx_bip_fem_manufacturer].params, |
254 | sizeof(struct wl1271_ini_fem_params_5)); | 160 | sizeof(struct wl1271_ini_fem_params_5)); |
255 | 161 | ||
256 | wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_RADIO_PARAM: ", | 162 | wl1271_dump(DEBUG_CMD, "TEST_CMD_INI_FILE_RADIO_PARAM: ", |
@@ -295,20 +201,10 @@ static int wl1271_cmd_wait_for_event(struct wl1271 *wl, u32 mask) | |||
295 | 201 | ||
296 | int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type) | 202 | int wl1271_cmd_join(struct wl1271 *wl, u8 bss_type) |
297 | { | 203 | { |
298 | static bool do_cal = true; | ||
299 | struct wl1271_cmd_join *join; | 204 | struct wl1271_cmd_join *join; |
300 | int ret, i; | 205 | int ret, i; |
301 | u8 *bssid; | 206 | u8 *bssid; |
302 | 207 | ||
303 | /* FIXME: remove when we get calibration from the factory */ | ||
304 | if (do_cal) { | ||
305 | ret = wl1271_cmd_cal(wl); | ||
306 | if (ret < 0) | ||
307 | wl1271_warning("couldn't calibrate"); | ||
308 | else | ||
309 | do_cal = false; | ||
310 | } | ||
311 | |||
312 | join = kzalloc(sizeof(*join), GFP_KERNEL); | 208 | join = kzalloc(sizeof(*join), GFP_KERNEL); |
313 | if (!join) { | 209 | if (!join) { |
314 | ret = -ENOMEM; | 210 | ret = -ENOMEM; |
@@ -567,142 +463,6 @@ out: | |||
567 | return ret; | 463 | return ret; |
568 | } | 464 | } |
569 | 465 | ||
570 | int wl1271_cmd_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len, | ||
571 | struct cfg80211_scan_request *req, u8 active_scan, | ||
572 | u8 high_prio, u8 band, u8 probe_requests) | ||
573 | { | ||
574 | |||
575 | struct wl1271_cmd_trigger_scan_to *trigger = NULL; | ||
576 | struct wl1271_cmd_scan *params = NULL; | ||
577 | struct ieee80211_channel *channels; | ||
578 | u32 rate; | ||
579 | int i, j, n_ch, ret; | ||
580 | u16 scan_options = 0; | ||
581 | u8 ieee_band; | ||
582 | |||
583 | if (band == WL1271_SCAN_BAND_2_4_GHZ) { | ||
584 | ieee_band = IEEE80211_BAND_2GHZ; | ||
585 | rate = wl->conf.tx.basic_rate; | ||
586 | } else if (band == WL1271_SCAN_BAND_DUAL && wl1271_11a_enabled()) { | ||
587 | ieee_band = IEEE80211_BAND_2GHZ; | ||
588 | rate = wl->conf.tx.basic_rate; | ||
589 | } else if (band == WL1271_SCAN_BAND_5_GHZ && wl1271_11a_enabled()) { | ||
590 | ieee_band = IEEE80211_BAND_5GHZ; | ||
591 | rate = wl->conf.tx.basic_rate_5; | ||
592 | } else | ||
593 | return -EINVAL; | ||
594 | |||
595 | if (wl->hw->wiphy->bands[ieee_band]->channels == NULL) | ||
596 | return -EINVAL; | ||
597 | |||
598 | channels = wl->hw->wiphy->bands[ieee_band]->channels; | ||
599 | n_ch = wl->hw->wiphy->bands[ieee_band]->n_channels; | ||
600 | |||
601 | if (test_bit(WL1271_FLAG_SCANNING, &wl->flags)) | ||
602 | return -EINVAL; | ||
603 | |||
604 | params = kzalloc(sizeof(*params), GFP_KERNEL); | ||
605 | if (!params) | ||
606 | return -ENOMEM; | ||
607 | |||
608 | params->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD); | ||
609 | params->params.rx_filter_options = | ||
610 | cpu_to_le32(CFG_RX_PRSP_EN | CFG_RX_MGMT_EN | CFG_RX_BCN_EN); | ||
611 | |||
612 | if (!active_scan) | ||
613 | scan_options |= WL1271_SCAN_OPT_PASSIVE; | ||
614 | if (high_prio) | ||
615 | scan_options |= WL1271_SCAN_OPT_PRIORITY_HIGH; | ||
616 | params->params.scan_options = cpu_to_le16(scan_options); | ||
617 | |||
618 | params->params.num_probe_requests = probe_requests; | ||
619 | params->params.tx_rate = cpu_to_le32(rate); | ||
620 | params->params.tid_trigger = 0; | ||
621 | params->params.scan_tag = WL1271_SCAN_DEFAULT_TAG; | ||
622 | |||
623 | if (band == WL1271_SCAN_BAND_DUAL) | ||
624 | params->params.band = WL1271_SCAN_BAND_2_4_GHZ; | ||
625 | else | ||
626 | params->params.band = band; | ||
627 | |||
628 | for (i = 0, j = 0; i < n_ch && i < WL1271_SCAN_MAX_CHANNELS; i++) { | ||
629 | if (!(channels[i].flags & IEEE80211_CHAN_DISABLED)) { | ||
630 | params->channels[j].min_duration = | ||
631 | cpu_to_le32(WL1271_SCAN_CHAN_MIN_DURATION); | ||
632 | params->channels[j].max_duration = | ||
633 | cpu_to_le32(WL1271_SCAN_CHAN_MAX_DURATION); | ||
634 | memset(¶ms->channels[j].bssid_lsb, 0xff, 4); | ||
635 | memset(¶ms->channels[j].bssid_msb, 0xff, 2); | ||
636 | params->channels[j].early_termination = 0; | ||
637 | params->channels[j].tx_power_att = | ||
638 | WL1271_SCAN_CURRENT_TX_PWR; | ||
639 | params->channels[j].channel = channels[i].hw_value; | ||
640 | j++; | ||
641 | } | ||
642 | } | ||
643 | |||
644 | params->params.num_channels = j; | ||
645 | |||
646 | if (ssid_len && ssid) { | ||
647 | params->params.ssid_len = ssid_len; | ||
648 | memcpy(params->params.ssid, ssid, ssid_len); | ||
649 | } | ||
650 | |||
651 | ret = wl1271_cmd_build_probe_req(wl, ssid, ssid_len, | ||
652 | req->ie, req->ie_len, ieee_band); | ||
653 | if (ret < 0) { | ||
654 | wl1271_error("PROBE request template failed"); | ||
655 | goto out; | ||
656 | } | ||
657 | |||
658 | trigger = kzalloc(sizeof(*trigger), GFP_KERNEL); | ||
659 | if (!trigger) { | ||
660 | ret = -ENOMEM; | ||
661 | goto out; | ||
662 | } | ||
663 | |||
664 | /* disable the timeout */ | ||
665 | trigger->timeout = 0; | ||
666 | |||
667 | ret = wl1271_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger, | ||
668 | sizeof(*trigger), 0); | ||
669 | if (ret < 0) { | ||
670 | wl1271_error("trigger scan to failed for hw scan"); | ||
671 | goto out; | ||
672 | } | ||
673 | |||
674 | wl1271_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params)); | ||
675 | |||
676 | set_bit(WL1271_FLAG_SCANNING, &wl->flags); | ||
677 | if (wl1271_11a_enabled()) { | ||
678 | wl->scan.state = band; | ||
679 | if (band == WL1271_SCAN_BAND_DUAL) { | ||
680 | wl->scan.active = active_scan; | ||
681 | wl->scan.high_prio = high_prio; | ||
682 | wl->scan.probe_requests = probe_requests; | ||
683 | if (ssid_len && ssid) { | ||
684 | wl->scan.ssid_len = ssid_len; | ||
685 | memcpy(wl->scan.ssid, ssid, ssid_len); | ||
686 | } else | ||
687 | wl->scan.ssid_len = 0; | ||
688 | wl->scan.req = req; | ||
689 | } else | ||
690 | wl->scan.req = NULL; | ||
691 | } | ||
692 | |||
693 | ret = wl1271_cmd_send(wl, CMD_SCAN, params, sizeof(*params), 0); | ||
694 | if (ret < 0) { | ||
695 | wl1271_error("SCAN failed"); | ||
696 | clear_bit(WL1271_FLAG_SCANNING, &wl->flags); | ||
697 | goto out; | ||
698 | } | ||
699 | |||
700 | out: | ||
701 | kfree(params); | ||
702 | kfree(trigger); | ||
703 | return ret; | ||
704 | } | ||
705 | |||
706 | int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, | 466 | int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id, |
707 | void *buf, size_t buf_len, int index, u32 rates) | 467 | void *buf, size_t buf_len, int index, u32 rates) |
708 | { | 468 | { |
@@ -807,7 +567,7 @@ int wl1271_cmd_build_ps_poll(struct wl1271 *wl, u16 aid) | |||
807 | goto out; | 567 | goto out; |
808 | 568 | ||
809 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data, | 569 | ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data, |
810 | skb->len, 0, wl->basic_rate); | 570 | skb->len, 0, wl->basic_rate_set); |
811 | 571 | ||
812 | out: | 572 | out: |
813 | dev_kfree_skb(skb); | 573 | dev_kfree_skb(skb); |