460
460
int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid)
462
463
u8 link = find_first_zero_bit(wl->links_map, WL12XX_MAX_LINKS);
463
464
if (link >= WL12XX_MAX_LINKS)
467
/* these bits are used by op_tx */
468
spin_lock_irqsave(&wl->wl_lock, flags);
466
469
__set_bit(link, wl->links_map);
467
470
__set_bit(link, wlvif->links_map);
471
spin_unlock_irqrestore(&wl->wl_lock, flags);
472
476
void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid)
474
480
if (*hlid == WL12XX_INVALID_LINK_ID)
483
/* these bits are used by op_tx */
484
spin_lock_irqsave(&wl->wl_lock, flags);
477
485
__clear_bit(*hlid, wl->links_map);
478
486
__clear_bit(*hlid, wlvif->links_map);
487
spin_unlock_irqrestore(&wl->wl_lock, flags);
490
* At this point op_tx() will not add more packets to the queues. We
493
wl1271_tx_reset_link_queues(wl, *hlid);
479
495
*hlid = WL12XX_INVALID_LINK_ID;
517
533
cmd->device.hlid = wlvif->dev_hlid;
518
cmd->device.session = wlvif->session_counter;
534
cmd->device.session = wl12xx_get_new_session_id(wl, wlvif);
520
536
wl1271_debug(DEBUG_CMD, "role start: roleid=%d, hlid=%d, session=%d",
521
537
cmd->role_id, cmd->device.hlid, cmd->device.session);
715
731
cmd->ap.beacon_interval = cpu_to_le16(wlvif->beacon_int);
716
732
cmd->ap.dtim_interval = bss_conf->dtim_period;
717
733
cmd->ap.beacon_expiry = WL1271_AP_DEF_BEACON_EXP;
734
/* FIXME: Change when adding DFS */
735
cmd->ap.reset_tsf = 1; /* By default reset AP TSF */
718
736
cmd->channel = wlvif->channel;
720
738
if (!bss_conf->hidden_ssid) {
996
1014
int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1015
u8 ps_mode, u16 auto_ps_timeout)
999
1017
struct wl1271_cmd_ps_params *ps_params = NULL;
1010
1028
ps_params->role_id = wlvif->role_id;
1011
1029
ps_params->ps_mode = ps_mode;
1030
ps_params->auto_ps_timeout = auto_ps_timeout;
1013
1032
ret = wl1271_cmd_send(wl, CMD_SET_PS_MODE, ps_params,
1014
1033
sizeof(*ps_params), 0);
1025
int wl1271_cmd_template_set(struct wl1271 *wl, u16 template_id,
1026
void *buf, size_t buf_len, int index, u32 rates)
1044
int wl1271_cmd_template_set(struct wl1271 *wl, u8 role_id,
1045
u16 template_id, void *buf, size_t buf_len,
1046
int index, u32 rates)
1028
1048
struct wl1271_cmd_template_set *cmd;
1031
wl1271_debug(DEBUG_CMD, "cmd template_set %d", template_id);
1051
wl1271_debug(DEBUG_CMD, "cmd template_set %d (role %d)",
1052
template_id, role_id);
1033
1054
WARN_ON(buf_len > WL1271_CMD_TEMPL_MAX_SIZE);
1034
1055
buf_len = min_t(size_t, buf_len, WL1271_CMD_TEMPL_MAX_SIZE);
1082
1105
ptr = skb->data;
1085
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_NULL_DATA, ptr, size, 0,
1108
ret = wl1271_cmd_template_set(wl, wlvif->role_id,
1109
CMD_TEMPL_NULL_DATA, ptr, size, 0,
1086
1110
wlvif->basic_rate);
1108
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_KLV,
1132
ret = wl1271_cmd_template_set(wl, wlvif->role_id, CMD_TEMPL_KLV,
1109
1133
skb->data, skb->len,
1110
1134
CMD_TEMPL_KLV_IDX_NULL_DATA,
1111
1135
wlvif->basic_rate);
1133
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_PS_POLL, skb->data,
1157
ret = wl1271_cmd_template_set(wl, wlvif->role_id,
1158
CMD_TEMPL_PS_POLL, skb->data,
1134
1159
skb->len, 0, wlvif->basic_rate_set);
1141
int wl1271_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1166
int wl12xx_cmd_build_probe_req(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1167
u8 role_id, u8 band,
1142
1168
const u8 *ssid, size_t ssid_len,
1143
const u8 *ie, size_t ie_len, u8 band)
1169
const u8 *ie, size_t ie_len)
1145
1171
struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
1146
1172
struct sk_buff *skb;
1159
1185
rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[band]);
1160
1186
if (band == IEEE80211_BAND_2GHZ)
1161
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4,
1187
ret = wl1271_cmd_template_set(wl, role_id,
1188
CMD_TEMPL_CFG_PROBE_REQ_2_4,
1162
1189
skb->data, skb->len, 0, rate);
1164
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
1191
ret = wl1271_cmd_template_set(wl, role_id,
1192
CMD_TEMPL_CFG_PROBE_REQ_5,
1165
1193
skb->data, skb->len, 0, rate);
1187
1215
rate = wl1271_tx_min_rate_get(wl, wlvif->bitrate_masks[wlvif->band]);
1188
1216
if (wlvif->band == IEEE80211_BAND_2GHZ)
1189
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_2_4,
1217
ret = wl1271_cmd_template_set(wl, wlvif->role_id,
1218
CMD_TEMPL_CFG_PROBE_REQ_2_4,
1190
1219
skb->data, skb->len, 0, rate);
1192
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_CFG_PROBE_REQ_5,
1221
ret = wl1271_cmd_template_set(wl, wlvif->role_id,
1222
CMD_TEMPL_CFG_PROBE_REQ_5,
1193
1223
skb->data, skb->len, 0, rate);
1202
int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1232
int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif)
1206
1236
struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
1207
struct wl12xx_arp_rsp_template tmpl;
1237
struct sk_buff *skb;
1238
struct wl12xx_arp_rsp_template *tmpl;
1208
1239
struct ieee80211_hdr_3addr *hdr;
1209
1240
struct arphdr *arp_hdr;
1211
memset(&tmpl, 0, sizeof(tmpl));
1213
/* mac80211 header */
1215
hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_DATA |
1216
IEEE80211_STYPE_DATA |
1217
IEEE80211_FCTL_TODS);
1218
memcpy(hdr->addr1, vif->bss_conf.bssid, ETH_ALEN);
1219
memcpy(hdr->addr2, vif->addr, ETH_ALEN);
1220
memset(hdr->addr3, 0xff, ETH_ALEN);
1242
skb = dev_alloc_skb(sizeof(*hdr) + sizeof(__le16) + sizeof(*tmpl) +
1243
WL1271_EXTRA_SPACE_MAX);
1245
wl1271_error("failed to allocate buffer for arp rsp template");
1249
skb_reserve(skb, sizeof(*hdr) + WL1271_EXTRA_SPACE_MAX);
1251
tmpl = (struct wl12xx_arp_rsp_template *)skb_put(skb, sizeof(*tmpl));
1252
memset(tmpl, 0, sizeof(tmpl));
1222
1254
/* llc layer */
1223
memcpy(tmpl.llc_hdr, rfc1042_header, sizeof(rfc1042_header));
1224
tmpl.llc_type = cpu_to_be16(ETH_P_ARP);
1255
memcpy(tmpl->llc_hdr, rfc1042_header, sizeof(rfc1042_header));
1256
tmpl->llc_type = cpu_to_be16(ETH_P_ARP);
1226
1258
/* arp header */
1227
arp_hdr = &tmpl.arp_hdr;
1259
arp_hdr = &tmpl->arp_hdr;
1228
1260
arp_hdr->ar_hrd = cpu_to_be16(ARPHRD_ETHER);
1229
1261
arp_hdr->ar_pro = cpu_to_be16(ETH_P_IP);
1230
1262
arp_hdr->ar_hln = ETH_ALEN;
1232
1264
arp_hdr->ar_op = cpu_to_be16(ARPOP_REPLY);
1234
1266
/* arp payload */
1235
memcpy(tmpl.sender_hw, vif->addr, ETH_ALEN);
1236
tmpl.sender_ip = ip_addr;
1238
ret = wl1271_cmd_template_set(wl, CMD_TEMPL_ARP_RSP,
1239
&tmpl, sizeof(tmpl), 0,
1267
memcpy(tmpl->sender_hw, vif->addr, ETH_ALEN);
1268
tmpl->sender_ip = wlvif->ip_addr;
1270
/* encryption space */
1271
switch (wlvif->encryption_type) {
1273
extra = WL1271_EXTRA_SPACE_TKIP;
1276
extra = WL1271_EXTRA_SPACE_AES;
1284
wl1271_warning("Unknown encryption type: %d",
1285
wlvif->encryption_type);
1291
u8 *space = skb_push(skb, extra);
1292
memset(space, 0, extra);
1295
/* QoS header - BE */
1297
memset(skb_push(skb, sizeof(__le16)), 0, sizeof(__le16));
1299
/* mac80211 header */
1300
hdr = (struct ieee80211_hdr_3addr *)skb_push(skb, sizeof(*hdr));
1301
memset(hdr, 0, sizeof(hdr));
1302
fc = IEEE80211_FTYPE_DATA | IEEE80211_FCTL_TODS;
1304
fc |= IEEE80211_STYPE_QOS_DATA;
1306
fc |= IEEE80211_STYPE_DATA;
1307
if (wlvif->encryption_type != KEY_NONE)
1308
fc |= IEEE80211_FCTL_PROTECTED;
1310
hdr->frame_control = cpu_to_le16(fc);
1311
memcpy(hdr->addr1, vif->bss_conf.bssid, ETH_ALEN);
1312
memcpy(hdr->addr2, vif->addr, ETH_ALEN);
1313
memset(hdr->addr3, 0xff, ETH_ALEN);
1315
ret = wl1271_cmd_template_set(wl, wlvif->role_id, CMD_TEMPL_ARP_RSP,
1316
skb->data, skb->len, 0,
1240
1317
wlvif->basic_rate);
1260
1338
/* FIXME: not sure what priority to use here */
1261
1339
template.qos_ctrl = cpu_to_le16(0);
1263
return wl1271_cmd_template_set(wl, CMD_TEMPL_QOS_NULL_DATA, &template,
1341
return wl1271_cmd_template_set(wl, wlvif->role_id,
1342
CMD_TEMPL_QOS_NULL_DATA, &template,
1264
1343
sizeof(template), 0,
1265
1344
wlvif->basic_rate);
1741
1820
__clear_bit(role_id, wl->roc_map);
1823
* Rearm the tx watchdog when removing the last ROC. This prevents
1824
* recoveries due to just finished ROCs - when Tx hasn't yet had
1825
* a chance to get out.
1827
if (find_first_bit(wl->roc_map, WL12XX_MAX_ROLES) >= WL12XX_MAX_ROLES)
1828
wl12xx_rearm_tx_watchdog_locked(wl);
1746
1833
int wl12xx_cmd_channel_switch(struct wl1271 *wl,
1834
struct wl12xx_vif *wlvif,
1747
1835
struct ieee80211_channel_switch *ch_switch)
1749
1837
struct wl12xx_cmd_channel_switch *cmd;
1848
cmd->role_id = wlvif->role_id;
1760
1849
cmd->channel = ch_switch->channel->hw_value;
1761
1850
cmd->switch_time = ch_switch->count;
1762
cmd->tx_suspend = ch_switch->block_tx;
1763
cmd->flush = 0; /* this value is ignored by the FW */
1851
cmd->stop_tx = ch_switch->block_tx;
1853
/* FIXME: control from mac80211 in the future */
1854
cmd->post_switch_tx_disable = 0; /* Enable TX on the target channel */
1765
1856
ret = wl1271_cmd_send(wl, CMD_CHANNEL_SWITCH, cmd, sizeof(*cmd), 0);