~ubuntu-branches/debian/experimental/linux-2.6/experimental

« back to all changes in this revision

Viewing changes to drivers/net/wireless/wl12xx/cmd.c

  • Committer: Package Import Robot
  • Author(s): maximilian attems, maximilian attems, Ben Hutchings
  • Date: 2012-06-06 10:25:57 UTC
  • mfrom: (1.2.38)
  • Revision ID: package-import@ubuntu.com-20120606102557-b9j3506wcwrqrnx8
Tags: 3.4.1-1~experimental.1
* New upstream release: http://kernelnewbies.org/Linux_3.4
* New upstream stable update:
  http://www.kernel.org/pub/linux/kernel/v3.x/ChangeLog-3.4.1

[ maximilian attems ]
* Enable DM_VERITY, NF_CONNTRACK_TIMEOUT, NF_CT_NETLINK_TIMEOUT,
  IP_NF_MATCH_RPFILTER, IP6_NF_MATCH_RPFILTER, NETFILTER_NETLINK_ACCT,
  NETFILTER_XT_MATCH_NFACCT, NET_SCH_PLUG, SCSI_UFSHCD, SCSI_VIRTIO,
  NET_TEAM, ATH6KL.

[ Ben Hutchings ]
* DFSG: Remove the new vs6624 driver, which contains non-free firmware
* aufs: Update to aufs3.4-20120521
* [rt] Update to 3.4-rt8 and reenable

Show diffs side-by-side

added added

removed removed

Lines of Context:
459
459
 
460
460
int wl12xx_allocate_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid)
461
461
{
 
462
        unsigned long flags;
462
463
        u8 link = find_first_zero_bit(wl->links_map, WL12XX_MAX_LINKS);
463
464
        if (link >= WL12XX_MAX_LINKS)
464
465
                return -EBUSY;
465
466
 
 
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);
468
472
        *hlid = link;
469
473
        return 0;
470
474
}
471
475
 
472
476
void wl12xx_free_link(struct wl1271 *wl, struct wl12xx_vif *wlvif, u8 *hlid)
473
477
{
 
478
        unsigned long flags;
 
479
 
474
480
        if (*hlid == WL12XX_INVALID_LINK_ID)
475
481
                return;
476
482
 
 
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);
 
488
 
 
489
        /*
 
490
         * At this point op_tx() will not add more packets to the queues. We
 
491
         * can purge them.
 
492
         */
 
493
        wl1271_tx_reset_link_queues(wl, *hlid);
 
494
 
479
495
        *hlid = WL12XX_INVALID_LINK_ID;
480
496
}
481
497
 
515
531
                        goto out_free;
516
532
        }
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);
519
535
 
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);
566
582
                goto out_free;
567
583
        }
568
584
 
569
 
        ret = wl1271_cmd_wait_for_event(wl, DISCONNECT_EVENT_COMPLETE_ID);
 
585
        ret = wl1271_cmd_wait_for_event(wl, ROLE_STOP_COMPLETE_EVENT_ID);
570
586
        if (ret < 0) {
571
587
                wl1271_error("cmd role stop dev event completion error");
572
588
                goto out_free;
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;
719
737
 
720
738
        if (!bss_conf->hidden_ssid) {
994
1012
}
995
1013
 
996
1014
int wl1271_cmd_ps_mode(struct wl1271 *wl, struct wl12xx_vif *wlvif,
997
 
                       u8 ps_mode)
 
1015
                       u8 ps_mode, u16 auto_ps_timeout)
998
1016
{
999
1017
        struct wl1271_cmd_ps_params *ps_params = NULL;
1000
1018
        int ret = 0;
1009
1027
 
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;
1012
1031
 
1013
1032
        ret = wl1271_cmd_send(wl, CMD_SET_PS_MODE, ps_params,
1014
1033
                              sizeof(*ps_params), 0);
1022
1041
        return ret;
1023
1042
}
1024
1043
 
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)
1027
1047
{
1028
1048
        struct wl1271_cmd_template_set *cmd;
1029
1049
        int ret = 0;
1030
1050
 
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);
1032
1053
 
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);
1039
1060
                goto out;
1040
1061
        }
1041
1062
 
 
1063
        /* during initialization wlvif is NULL */
 
1064
        cmd->role_id = role_id;
1042
1065
        cmd->len = cpu_to_le16(buf_len);
1043
1066
        cmd->template_type = template_id;
1044
1067
        cmd->enabled_rates = cpu_to_le32(rates);
1082
1105
                ptr = skb->data;
1083
1106
        }
1084
1107
 
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);
1087
1111
 
1088
1112
out:
1105
1129
        if (!skb)
1106
1130
                goto out;
1107
1131
 
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);
1130
1154
        if (!skb)
1131
1155
                goto out;
1132
1156
 
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);
1135
1160
 
1136
1161
out:
1138
1163
        return ret;
1139
1164
}
1140
1165
 
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)
1144
1170
{
1145
1171
        struct ieee80211_vif *vif = wl12xx_wlvif_to_vif(wlvif);
1146
1172
        struct sk_buff *skb;
1158
1184
 
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);
1163
1190
        else
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);
1166
1194
 
1167
1195
out:
1186
1214
 
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);
1191
1220
        else
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);
1194
1224
 
1195
1225
        if (ret < 0)
1199
1229
        return skb;
1200
1230
}
1201
1231
 
1202
 
int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif,
1203
 
                             __be32 ip_addr)
 
1232
int wl1271_cmd_build_arp_rsp(struct wl1271 *wl, struct wl12xx_vif *wlvif)
1204
1233
{
1205
 
        int ret;
 
1234
        int ret, extra;
 
1235
        u16 fc;
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;
1210
1241
 
1211
 
        memset(&tmpl, 0, sizeof(tmpl));
1212
 
 
1213
 
        /* mac80211 header */
1214
 
        hdr = &tmpl.hdr;
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);
 
1244
        if (!skb) {
 
1245
                wl1271_error("failed to allocate buffer for arp rsp template");
 
1246
                return -ENOMEM;
 
1247
        }
 
1248
 
 
1249
        skb_reserve(skb, sizeof(*hdr) + WL1271_EXTRA_SPACE_MAX);
 
1250
 
 
1251
        tmpl = (struct wl12xx_arp_rsp_template *)skb_put(skb, sizeof(*tmpl));
 
1252
        memset(tmpl, 0, sizeof(tmpl));
1221
1253
 
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);
1225
1257
 
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);
1233
1265
 
1234
1266
        /* arp payload */
1235
 
        memcpy(tmpl.sender_hw, vif->addr, ETH_ALEN);
1236
 
        tmpl.sender_ip = ip_addr;
1237
 
 
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;
 
1269
 
 
1270
        /* encryption space */
 
1271
        switch (wlvif->encryption_type) {
 
1272
        case KEY_TKIP:
 
1273
                extra = WL1271_EXTRA_SPACE_TKIP;
 
1274
                break;
 
1275
        case KEY_AES:
 
1276
                extra = WL1271_EXTRA_SPACE_AES;
 
1277
                break;
 
1278
        case KEY_NONE:
 
1279
        case KEY_WEP:
 
1280
        case KEY_GEM:
 
1281
                extra = 0;
 
1282
                break;
 
1283
        default:
 
1284
                wl1271_warning("Unknown encryption type: %d",
 
1285
                               wlvif->encryption_type);
 
1286
                ret = -EINVAL;
 
1287
                goto out;
 
1288
        }
 
1289
 
 
1290
        if (extra) {
 
1291
                u8 *space = skb_push(skb, extra);
 
1292
                memset(space, 0, extra);
 
1293
        }
 
1294
 
 
1295
        /* QoS header - BE */
 
1296
        if (wlvif->sta.qos)
 
1297
                memset(skb_push(skb, sizeof(__le16)), 0, sizeof(__le16));
 
1298
 
 
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;
 
1303
        if (wlvif->sta.qos)
 
1304
                fc |= IEEE80211_STYPE_QOS_DATA;
 
1305
        else
 
1306
                fc |= IEEE80211_STYPE_DATA;
 
1307
        if (wlvif->encryption_type != KEY_NONE)
 
1308
                fc |= IEEE80211_FCTL_PROTECTED;
 
1309
 
 
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);
 
1314
 
 
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);
1241
 
 
 
1318
out:
 
1319
        dev_kfree_skb(skb);
1242
1320
        return ret;
1243
1321
}
1244
1322
 
1260
1338
        /* FIXME: not sure what priority to use here */
1261
1339
        template.qos_ctrl = cpu_to_le16(0);
1262
1340
 
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);
1266
1345
}
1739
1818
                goto out;
1740
1819
 
1741
1820
        __clear_bit(role_id, wl->roc_map);
 
1821
 
 
1822
        /*
 
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.
 
1826
         */
 
1827
        if (find_first_bit(wl->roc_map, WL12XX_MAX_ROLES) >= WL12XX_MAX_ROLES)
 
1828
                wl12xx_rearm_tx_watchdog_locked(wl);
1742
1829
out:
1743
1830
        return ret;
1744
1831
}
1745
1832
 
1746
1833
int wl12xx_cmd_channel_switch(struct wl1271 *wl,
 
1834
                              struct wl12xx_vif *wlvif,
1747
1835
                              struct ieee80211_channel_switch *ch_switch)
1748
1836
{
1749
1837
        struct wl12xx_cmd_channel_switch *cmd;
1757
1845
                goto out;
1758
1846
        }
1759
1847
 
 
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;
 
1852
 
 
1853
        /* FIXME: control from mac80211 in the future */
 
1854
        cmd->post_switch_tx_disable = 0;  /* Enable TX on the target channel */
1764
1855
 
1765
1856
        ret = wl1271_cmd_send(wl, CMD_CHANNEL_SWITCH, cmd, sizeof(*cmd), 0);
1766
1857
        if (ret < 0) {