aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/libertas/assoc.c
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2008-08-21 17:51:07 -0400
committerJohn W. Linville <linville@tuxdriver.com>2008-08-29 16:24:07 -0400
commitd5db2dfa660de13c3643149b89c7602dd49aa168 (patch)
treec2dbf5cbd27a83c73cba68f4285d1e51024d168f /drivers/net/wireless/libertas/assoc.c
parent191bb40e725304c5fcfabd92c57eef58799f0e25 (diff)
libertas: convert CMD_802_11_RADIO_CONTROL to a direct command
and return errors for operations like join & scan that aren't possible when the radio is turned off. Signed-off-by: Dan Williams <dcbw@redhat.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas/assoc.c')
-rw-r--r--drivers/net/wireless/libertas/assoc.c57
1 files changed, 31 insertions, 26 deletions
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c
index 5072a8917fd9..d47e4d5734cd 100644
--- a/drivers/net/wireless/libertas/assoc.c
+++ b/drivers/net/wireless/libertas/assoc.c
@@ -25,7 +25,7 @@ static const u8 bssid_off[ETH_ALEN] __attribute__ ((aligned (2))) =
25 * @brief Associate to a specific BSS discovered in a scan 25 * @brief Associate to a specific BSS discovered in a scan
26 * 26 *
27 * @param priv A pointer to struct lbs_private structure 27 * @param priv A pointer to struct lbs_private structure
28 * @param pbssdesc Pointer to the BSS descriptor to associate with. 28 * @param assoc_req The association request describing the BSS to associate with
29 * 29 *
30 * @return 0-success, otherwise fail 30 * @return 0-success, otherwise fail
31 */ 31 */
@@ -33,29 +33,29 @@ static int lbs_associate(struct lbs_private *priv,
33 struct assoc_request *assoc_req) 33 struct assoc_request *assoc_req)
34{ 34{
35 int ret; 35 int ret;
36 u8 preamble = RADIO_PREAMBLE_LONG;
36 37
37 lbs_deb_enter(LBS_DEB_ASSOC); 38 lbs_deb_enter(LBS_DEB_ASSOC);
38 39
39 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AUTHENTICATE, 40 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AUTHENTICATE,
40 0, CMD_OPTION_WAITFORRSP, 41 0, CMD_OPTION_WAITFORRSP,
41 0, assoc_req->bss.bssid); 42 0, assoc_req->bss.bssid);
42
43 if (ret) 43 if (ret)
44 goto done; 44 goto out;
45 45
46 /* set preamble to firmware */ 46 /* Use short preamble only when both the BSS and firmware support it */
47 if ((priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) && 47 if ((priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) &&
48 (assoc_req->bss.capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) 48 (assoc_req->bss.capability & WLAN_CAPABILITY_SHORT_PREAMBLE))
49 priv->preamble = CMD_TYPE_SHORT_PREAMBLE; 49 preamble = RADIO_PREAMBLE_SHORT;
50 else
51 priv->preamble = CMD_TYPE_LONG_PREAMBLE;
52 50
53 lbs_set_radio_control(priv); 51 ret = lbs_set_radio(priv, preamble, 1);
52 if (ret)
53 goto out;
54 54
55 ret = lbs_prepare_and_send_command(priv, CMD_802_11_ASSOCIATE, 55 ret = lbs_prepare_and_send_command(priv, CMD_802_11_ASSOCIATE,
56 0, CMD_OPTION_WAITFORRSP, 0, assoc_req); 56 0, CMD_OPTION_WAITFORRSP, 0, assoc_req);
57 57
58done: 58out:
59 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret); 59 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
60 return ret; 60 return ret;
61} 61}
@@ -64,8 +64,7 @@ done:
64 * @brief Join an adhoc network found in a previous scan 64 * @brief Join an adhoc network found in a previous scan
65 * 65 *
66 * @param priv A pointer to struct lbs_private structure 66 * @param priv A pointer to struct lbs_private structure
67 * @param pbssdesc Pointer to a BSS descriptor found in a previous scan 67 * @param assoc_req The association request describing the BSS to join
68 * to attempt to join
69 * 68 *
70 * @return 0--success, -1--fail 69 * @return 0--success, -1--fail
71 */ 70 */
@@ -74,6 +73,9 @@ static int lbs_join_adhoc_network(struct lbs_private *priv,
74{ 73{
75 struct bss_descriptor *bss = &assoc_req->bss; 74 struct bss_descriptor *bss = &assoc_req->bss;
76 int ret = 0; 75 int ret = 0;
76 u8 preamble = RADIO_PREAMBLE_LONG;
77
78 lbs_deb_enter(LBS_DEB_ASSOC);
77 79
78 lbs_deb_join("current SSID '%s', ssid length %u\n", 80 lbs_deb_join("current SSID '%s', ssid length %u\n",
79 escape_essid(priv->curbssparams.ssid, 81 escape_essid(priv->curbssparams.ssid,
@@ -106,18 +108,16 @@ static int lbs_join_adhoc_network(struct lbs_private *priv,
106 goto out; 108 goto out;
107 } 109 }
108 110
109 /* Use shortpreamble only when both creator and card supports 111 /* Use short preamble only when both the BSS and firmware support it */
110 short preamble */ 112 if ((priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) &&
111 if (!(bss->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) || 113 (bss->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) {
112 !(priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE)) {
113 lbs_deb_join("AdhocJoin: Long preamble\n");
114 priv->preamble = CMD_TYPE_LONG_PREAMBLE;
115 } else {
116 lbs_deb_join("AdhocJoin: Short preamble\n"); 114 lbs_deb_join("AdhocJoin: Short preamble\n");
117 priv->preamble = CMD_TYPE_SHORT_PREAMBLE; 115 preamble = RADIO_PREAMBLE_SHORT;
118 } 116 }
119 117
120 lbs_set_radio_control(priv); 118 ret = lbs_set_radio(priv, preamble, 1);
119 if (ret)
120 goto out;
121 121
122 lbs_deb_join("AdhocJoin: channel = %d\n", assoc_req->channel); 122 lbs_deb_join("AdhocJoin: channel = %d\n", assoc_req->channel);
123 lbs_deb_join("AdhocJoin: band = %c\n", assoc_req->band); 123 lbs_deb_join("AdhocJoin: band = %c\n", assoc_req->band);
@@ -129,6 +129,7 @@ static int lbs_join_adhoc_network(struct lbs_private *priv,
129 OID_802_11_SSID, assoc_req); 129 OID_802_11_SSID, assoc_req);
130 130
131out: 131out:
132 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
132 return ret; 133 return ret;
133} 134}
134 135
@@ -136,25 +137,27 @@ out:
136 * @brief Start an Adhoc Network 137 * @brief Start an Adhoc Network
137 * 138 *
138 * @param priv A pointer to struct lbs_private structure 139 * @param priv A pointer to struct lbs_private structure
139 * @param adhocssid The ssid of the Adhoc Network 140 * @param assoc_req The association request describing the BSS to start
140 * @return 0--success, -1--fail 141 * @return 0--success, -1--fail
141 */ 142 */
142static int lbs_start_adhoc_network(struct lbs_private *priv, 143static int lbs_start_adhoc_network(struct lbs_private *priv,
143 struct assoc_request *assoc_req) 144 struct assoc_request *assoc_req)
144{ 145{
145 int ret = 0; 146 int ret = 0;
147 u8 preamble = RADIO_PREAMBLE_LONG;
148
149 lbs_deb_enter(LBS_DEB_ASSOC);
146 150
147 priv->adhoccreate = 1; 151 priv->adhoccreate = 1;
148 152
149 if (priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) { 153 if (priv->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) {
150 lbs_deb_join("AdhocStart: Short preamble\n"); 154 lbs_deb_join("AdhocStart: Short preamble\n");
151 priv->preamble = CMD_TYPE_SHORT_PREAMBLE; 155 preamble = RADIO_PREAMBLE_SHORT;
152 } else {
153 lbs_deb_join("AdhocStart: Long preamble\n");
154 priv->preamble = CMD_TYPE_LONG_PREAMBLE;
155 } 156 }
156 157
157 lbs_set_radio_control(priv); 158 ret = lbs_set_radio(priv, preamble, 1);
159 if (ret)
160 goto out;
158 161
159 lbs_deb_join("AdhocStart: channel = %d\n", assoc_req->channel); 162 lbs_deb_join("AdhocStart: channel = %d\n", assoc_req->channel);
160 lbs_deb_join("AdhocStart: band = %d\n", assoc_req->band); 163 lbs_deb_join("AdhocStart: band = %d\n", assoc_req->band);
@@ -162,6 +165,8 @@ static int lbs_start_adhoc_network(struct lbs_private *priv,
162 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AD_HOC_START, 165 ret = lbs_prepare_and_send_command(priv, CMD_802_11_AD_HOC_START,
163 0, CMD_OPTION_WAITFORRSP, 0, assoc_req); 166 0, CMD_OPTION_WAITFORRSP, 0, assoc_req);
164 167
168out:
169 lbs_deb_leave_args(LBS_DEB_ASSOC, "ret %d", ret);
165 return ret; 170 return ret;
166} 171}
167 172