cfg.c
Go to the documentation of this file.
00001 /*
00002  * mac80211 configuration hooks for cfg80211
00003  *
00004  * Copyright 2006-2010  Johannes Berg <johannes@sipsolutions.net>
00005  *
00006  * This file is GPLv2 as found in COPYING.
00007  */
00008 
00009 #include <linux/ieee80211.h>
00010 #include <linux/nl80211.h>
00011 #include <linux/rtnetlink.h>
00012 #include <linux/slab.h>
00013 #include <net/net_namespace.h>
00014 #include <linux/rcupdate.h>
00015 #include <linux/if_ether.h>
00016 #include <net/cfg80211.h>
00017 #include "ieee80211_i.h"
00018 #include "driver-ops.h"
00019 #include "cfg.h"
00020 #include "rate.h"
00021 #include "mesh.h"
00022 
00023 static struct net_device *ieee80211_add_iface(struct wiphy *wiphy, char *name,
00024                                               enum nl80211_iftype type,
00025                                               u32 *flags,
00026                                               struct vif_params *params)
00027 {
00028         struct ieee80211_local *local = wiphy_priv(wiphy);
00029         struct net_device *dev;
00030         struct ieee80211_sub_if_data *sdata;
00031         int err;
00032 
00033         err = ieee80211_if_add(local, name, &dev, type, params);
00034         if (err)
00035                 return ERR_PTR(err);
00036 
00037         if (type == NL80211_IFTYPE_MONITOR && flags) {
00038                 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00039                 sdata->u.mntr_flags = *flags;
00040         }
00041 
00042         return dev;
00043 }
00044 
00045 static int ieee80211_del_iface(struct wiphy *wiphy, struct net_device *dev)
00046 {
00047         ieee80211_if_remove(IEEE80211_DEV_TO_SUB_IF(dev));
00048 
00049         return 0;
00050 }
00051 
00052 static int ieee80211_change_iface(struct wiphy *wiphy,
00053                                   struct net_device *dev,
00054                                   enum nl80211_iftype type, u32 *flags,
00055                                   struct vif_params *params)
00056 {
00057         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00058         int ret;
00059 
00060         ret = ieee80211_if_change_type(sdata, type);
00061         if (ret)
00062                 return ret;
00063 
00064         if (type == NL80211_IFTYPE_AP_VLAN &&
00065             params && params->use_4addr == 0)
00066                 RCU_INIT_POINTER(sdata->u.vlan.sta, NULL);
00067         else if (type == NL80211_IFTYPE_STATION &&
00068                  params && params->use_4addr >= 0)
00069                 sdata->u.mgd.use_4addr = params->use_4addr;
00070 
00071         if (sdata->vif.type == NL80211_IFTYPE_MONITOR && flags) {
00072                 struct ieee80211_local *local = sdata->local;
00073 
00074                 if (ieee80211_sdata_running(sdata)) {
00075                         /*
00076                          * Prohibit MONITOR_FLAG_COOK_FRAMES to be
00077                          * changed while the interface is up.
00078                          * Else we would need to add a lot of cruft
00079                          * to update everything:
00080                          *      cooked_mntrs, monitor and all fif_* counters
00081                          *      reconfigure hardware
00082                          */
00083                         if ((*flags & MONITOR_FLAG_COOK_FRAMES) !=
00084                             (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES))
00085                                 return -EBUSY;
00086 
00087                         ieee80211_adjust_monitor_flags(sdata, -1);
00088                         sdata->u.mntr_flags = *flags;
00089                         ieee80211_adjust_monitor_flags(sdata, 1);
00090 
00091                         ieee80211_configure_filter(local);
00092                 } else {
00093                         /*
00094                          * Because the interface is down, ieee80211_do_stop
00095                          * and ieee80211_do_open take care of "everything"
00096                          * mentioned in the comment above.
00097                          */
00098                         sdata->u.mntr_flags = *flags;
00099                 }
00100         }
00101 
00102         return 0;
00103 }
00104 
00105 static int ieee80211_set_noack_map(struct wiphy *wiphy,
00106                                   struct net_device *dev,
00107                                   u16 noack_map)
00108 {
00109         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00110 
00111         sdata->noack_map = noack_map;
00112         return 0;
00113 }
00114 
00115 static int ieee80211_add_key(struct wiphy *wiphy, struct net_device *dev,
00116                              u8 key_idx, bool pairwise, const u8 *mac_addr,
00117                              struct key_params *params)
00118 {
00119         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00120         struct sta_info *sta = NULL;
00121         struct ieee80211_key *key;
00122         int err;
00123 
00124         if (!ieee80211_sdata_running(sdata))
00125                 return -ENETDOWN;
00126 
00127         /* reject WEP and TKIP keys if WEP failed to initialize */
00128         switch (params->cipher) {
00129         case WLAN_CIPHER_SUITE_WEP40:
00130         case WLAN_CIPHER_SUITE_TKIP:
00131         case WLAN_CIPHER_SUITE_WEP104:
00132                 if (IS_ERR(sdata->local->wep_tx_tfm))
00133                         return -EINVAL;
00134                 break;
00135         default:
00136                 break;
00137         }
00138 
00139         key = ieee80211_key_alloc(params->cipher, key_idx, params->key_len,
00140                                   params->key, params->seq_len, params->seq);
00141         if (IS_ERR(key))
00142                 return PTR_ERR(key);
00143 
00144         if (pairwise)
00145                 key->conf.flags |= IEEE80211_KEY_FLAG_PAIRWISE;
00146 
00147         mutex_lock(&sdata->local->sta_mtx);
00148 
00149         if (mac_addr) {
00150                 if (ieee80211_vif_is_mesh(&sdata->vif))
00151                         sta = sta_info_get(sdata, mac_addr);
00152                 else
00153                         sta = sta_info_get_bss(sdata, mac_addr);
00154                 if (!sta) {
00155                         ieee80211_key_free(sdata->local, key);
00156                         err = -ENOENT;
00157                         goto out_unlock;
00158                 }
00159         }
00160 
00161         err = ieee80211_key_link(key, sdata, sta);
00162         if (err)
00163                 ieee80211_key_free(sdata->local, key);
00164 
00165  out_unlock:
00166         mutex_unlock(&sdata->local->sta_mtx);
00167 
00168         return err;
00169 }
00170 
00171 static int ieee80211_del_key(struct wiphy *wiphy, struct net_device *dev,
00172                              u8 key_idx, bool pairwise, const u8 *mac_addr)
00173 {
00174         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00175         struct ieee80211_local *local = sdata->local;
00176         struct sta_info *sta;
00177         struct ieee80211_key *key = NULL;
00178         int ret;
00179 
00180         mutex_lock(&local->sta_mtx);
00181         mutex_lock(&local->key_mtx);
00182 
00183         if (mac_addr) {
00184                 ret = -ENOENT;
00185 
00186                 sta = sta_info_get_bss(sdata, mac_addr);
00187                 if (!sta)
00188                         goto out_unlock;
00189 
00190                 if (pairwise)
00191                         key = key_mtx_dereference(local, sta->ptk);
00192                 else
00193                         key = key_mtx_dereference(local, sta->gtk[key_idx]);
00194         } else
00195                 key = key_mtx_dereference(local, sdata->keys[key_idx]);
00196 
00197         if (!key) {
00198                 ret = -ENOENT;
00199                 goto out_unlock;
00200         }
00201 
00202         __ieee80211_key_free(key);
00203 
00204         ret = 0;
00205  out_unlock:
00206         mutex_unlock(&local->key_mtx);
00207         mutex_unlock(&local->sta_mtx);
00208 
00209         return ret;
00210 }
00211 
00212 static int ieee80211_get_key(struct wiphy *wiphy, struct net_device *dev,
00213                              u8 key_idx, bool pairwise, const u8 *mac_addr,
00214                              void *cookie,
00215                              void (*callback)(void *cookie,
00216                                               struct key_params *params))
00217 {
00218         struct ieee80211_sub_if_data *sdata;
00219         struct sta_info *sta = NULL;
00220         u8 seq[6] = {0};
00221         struct key_params params;
00222         struct ieee80211_key *key = NULL;
00223         u64 pn64;
00224         u32 iv32;
00225         u16 iv16;
00226         int err = -ENOENT;
00227 
00228         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00229 
00230         rcu_read_lock();
00231 
00232         if (mac_addr) {
00233                 sta = sta_info_get_bss(sdata, mac_addr);
00234                 if (!sta)
00235                         goto out;
00236 
00237                 if (pairwise)
00238                         key = rcu_dereference(sta->ptk);
00239                 else if (key_idx < NUM_DEFAULT_KEYS)
00240                         key = rcu_dereference(sta->gtk[key_idx]);
00241         } else
00242                 key = rcu_dereference(sdata->keys[key_idx]);
00243 
00244         if (!key)
00245                 goto out;
00246 
00247         memset(&params, 0, sizeof(params));
00248 
00249         params.cipher = key->conf.cipher;
00250 
00251         switch (key->conf.cipher) {
00252         case WLAN_CIPHER_SUITE_TKIP:
00253                 iv32 = key->u.tkip.tx.iv32;
00254                 iv16 = key->u.tkip.tx.iv16;
00255 
00256                 if (key->flags & KEY_FLAG_UPLOADED_TO_HARDWARE)
00257                         drv_get_tkip_seq(sdata->local,
00258                                          key->conf.hw_key_idx,
00259                                          &iv32, &iv16);
00260 
00261                 seq[0] = iv16 & 0xff;
00262                 seq[1] = (iv16 >> 8) & 0xff;
00263                 seq[2] = iv32 & 0xff;
00264                 seq[3] = (iv32 >> 8) & 0xff;
00265                 seq[4] = (iv32 >> 16) & 0xff;
00266                 seq[5] = (iv32 >> 24) & 0xff;
00267                 params.seq = seq;
00268                 params.seq_len = 6;
00269                 break;
00270         case WLAN_CIPHER_SUITE_CCMP:
00271                 pn64 = atomic64_read(&key->u.ccmp.tx_pn);
00272                 seq[0] = pn64;
00273                 seq[1] = pn64 >> 8;
00274                 seq[2] = pn64 >> 16;
00275                 seq[3] = pn64 >> 24;
00276                 seq[4] = pn64 >> 32;
00277                 seq[5] = pn64 >> 40;
00278                 params.seq = seq;
00279                 params.seq_len = 6;
00280                 break;
00281         case WLAN_CIPHER_SUITE_AES_CMAC:
00282                 pn64 = atomic64_read(&key->u.aes_cmac.tx_pn);
00283                 seq[0] = pn64;
00284                 seq[1] = pn64 >> 8;
00285                 seq[2] = pn64 >> 16;
00286                 seq[3] = pn64 >> 24;
00287                 seq[4] = pn64 >> 32;
00288                 seq[5] = pn64 >> 40;
00289                 params.seq = seq;
00290                 params.seq_len = 6;
00291                 break;
00292         }
00293 
00294         params.key = key->conf.key;
00295         params.key_len = key->conf.keylen;
00296 
00297         callback(cookie, &params);
00298         err = 0;
00299 
00300  out:
00301         rcu_read_unlock();
00302         return err;
00303 }
00304 
00305 static int ieee80211_config_default_key(struct wiphy *wiphy,
00306                                         struct net_device *dev,
00307                                         u8 key_idx, bool uni,
00308                                         bool multi)
00309 {
00310         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00311 
00312         ieee80211_set_default_key(sdata, key_idx, uni, multi);
00313 
00314         return 0;
00315 }
00316 
00317 static int ieee80211_config_default_mgmt_key(struct wiphy *wiphy,
00318                                              struct net_device *dev,
00319                                              u8 key_idx)
00320 {
00321         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00322 
00323         ieee80211_set_default_mgmt_key(sdata, key_idx);
00324 
00325         return 0;
00326 }
00327 
00328 static void rate_idx_to_bitrate(struct rate_info *rate, struct sta_info *sta, int idx)
00329 {
00330         if (!(rate->flags & RATE_INFO_FLAGS_MCS)) {
00331                 struct ieee80211_supported_band *sband;
00332                 sband = sta->local->hw.wiphy->bands[
00333                                 sta->local->hw.conf.channel->band];
00334                 rate->legacy = sband->bitrates[idx].bitrate;
00335         } else
00336                 rate->mcs = idx;
00337 }
00338 
00339 void sta_set_rate_info_tx(struct sta_info *sta,
00340                           const struct ieee80211_tx_rate *rate,
00341                           struct rate_info *rinfo)
00342 {
00343         rinfo->flags = 0;
00344         if (rate->flags & IEEE80211_TX_RC_MCS)
00345                 rinfo->flags |= RATE_INFO_FLAGS_MCS;
00346         if (rate->flags & IEEE80211_TX_RC_40_MHZ_WIDTH)
00347                 rinfo->flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
00348         if (rate->flags & IEEE80211_TX_RC_SHORT_GI)
00349                 rinfo->flags |= RATE_INFO_FLAGS_SHORT_GI;
00350         rate_idx_to_bitrate(rinfo, sta, rate->idx);
00351 }
00352 
00353 static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo)
00354 {
00355         struct ieee80211_sub_if_data *sdata = sta->sdata;
00356         struct timespec uptime;
00357 
00358         sinfo->generation = sdata->local->sta_generation;
00359 
00360         sinfo->filled = STATION_INFO_INACTIVE_TIME |
00361                         STATION_INFO_RX_BYTES |
00362                         STATION_INFO_TX_BYTES |
00363                         STATION_INFO_RX_PACKETS |
00364                         STATION_INFO_TX_PACKETS |
00365                         STATION_INFO_TX_RETRIES |
00366                         STATION_INFO_TX_FAILED |
00367                         STATION_INFO_TX_BITRATE |
00368                         STATION_INFO_RX_BITRATE |
00369                         STATION_INFO_RX_DROP_MISC |
00370                         STATION_INFO_BSS_PARAM |
00371                         STATION_INFO_CONNECTED_TIME |
00372                         STATION_INFO_STA_FLAGS |
00373                         STATION_INFO_BEACON_LOSS_COUNT;
00374 
00375         do_posix_clock_monotonic_gettime(&uptime);
00376         sinfo->connected_time = uptime.tv_sec - sta->last_connected;
00377 
00378         sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx);
00379         sinfo->rx_bytes = sta->rx_bytes;
00380         sinfo->tx_bytes = sta->tx_bytes;
00381         sinfo->rx_packets = sta->rx_packets;
00382         sinfo->tx_packets = sta->tx_packets;
00383         sinfo->tx_retries = sta->tx_retry_count;
00384         sinfo->tx_failed = sta->tx_retry_failed;
00385         sinfo->rx_dropped_misc = sta->rx_dropped;
00386         sinfo->beacon_loss_count = sta->beacon_loss_count;
00387 
00388         if ((sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) ||
00389             (sta->local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC)) {
00390                 sinfo->filled |= STATION_INFO_SIGNAL | STATION_INFO_SIGNAL_AVG;
00391                 sinfo->signal = (s8)sta->last_signal;
00392                 sinfo->signal_avg = (s8) -ewma_read(&sta->avg_signal);
00393         }
00394 
00395         sta_set_rate_info_tx(sta, &sta->last_tx_rate, &sinfo->txrate);
00396 
00397         sinfo->rxrate.flags = 0;
00398         if (sta->last_rx_rate_flag & RX_FLAG_HT)
00399                 sinfo->rxrate.flags |= RATE_INFO_FLAGS_MCS;
00400         if (sta->last_rx_rate_flag & RX_FLAG_40MHZ)
00401                 sinfo->rxrate.flags |= RATE_INFO_FLAGS_40_MHZ_WIDTH;
00402         if (sta->last_rx_rate_flag & RX_FLAG_SHORT_GI)
00403                 sinfo->rxrate.flags |= RATE_INFO_FLAGS_SHORT_GI;
00404         rate_idx_to_bitrate(&sinfo->rxrate, sta, sta->last_rx_rate_idx);
00405 
00406         if (ieee80211_vif_is_mesh(&sdata->vif)) {
00407 #ifdef CONFIG_MAC80211_MESH
00408                 sinfo->filled |= STATION_INFO_LLID |
00409                                  STATION_INFO_PLID |
00410                                  STATION_INFO_PLINK_STATE;
00411 
00412                 sinfo->llid = le16_to_cpu(sta->llid);
00413                 sinfo->plid = le16_to_cpu(sta->plid);
00414                 sinfo->plink_state = sta->plink_state;
00415                 if (test_sta_flag(sta, WLAN_STA_TOFFSET_KNOWN)) {
00416                         sinfo->filled |= STATION_INFO_T_OFFSET;
00417                         sinfo->t_offset = sta->t_offset;
00418                 }
00419 #endif
00420         }
00421 
00422         sinfo->bss_param.flags = 0;
00423         if (sdata->vif.bss_conf.use_cts_prot)
00424                 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_CTS_PROT;
00425         if (sdata->vif.bss_conf.use_short_preamble)
00426                 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_PREAMBLE;
00427         if (sdata->vif.bss_conf.use_short_slot)
00428                 sinfo->bss_param.flags |= BSS_PARAM_FLAGS_SHORT_SLOT_TIME;
00429         sinfo->bss_param.dtim_period = sdata->local->hw.conf.ps_dtim_period;
00430         sinfo->bss_param.beacon_interval = sdata->vif.bss_conf.beacon_int;
00431 
00432         sinfo->sta_flags.set = 0;
00433         sinfo->sta_flags.mask = BIT(NL80211_STA_FLAG_AUTHORIZED) |
00434                                 BIT(NL80211_STA_FLAG_SHORT_PREAMBLE) |
00435                                 BIT(NL80211_STA_FLAG_WME) |
00436                                 BIT(NL80211_STA_FLAG_MFP) |
00437                                 BIT(NL80211_STA_FLAG_AUTHENTICATED) |
00438                                 BIT(NL80211_STA_FLAG_TDLS_PEER);
00439         if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
00440                 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHORIZED);
00441         if (test_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE))
00442                 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_SHORT_PREAMBLE);
00443         if (test_sta_flag(sta, WLAN_STA_WME))
00444                 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_WME);
00445         if (test_sta_flag(sta, WLAN_STA_MFP))
00446                 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_MFP);
00447         if (test_sta_flag(sta, WLAN_STA_AUTH))
00448                 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_AUTHENTICATED);
00449         if (test_sta_flag(sta, WLAN_STA_TDLS_PEER))
00450                 sinfo->sta_flags.set |= BIT(NL80211_STA_FLAG_TDLS_PEER);
00451 }
00452 
00453 static const char ieee80211_gstrings_sta_stats[][ETH_GSTRING_LEN] = {
00454         "rx_packets", "rx_bytes", "wep_weak_iv_count",
00455         "rx_duplicates", "rx_fragments", "rx_dropped",
00456         "tx_packets", "tx_bytes", "tx_fragments",
00457         "tx_filtered", "tx_retry_failed", "tx_retries",
00458         "beacon_loss", "sta_state", "txrate", "rxrate", "signal",
00459         "channel", "noise", "ch_time", "ch_time_busy",
00460         "ch_time_ext_busy", "ch_time_rx", "ch_time_tx"
00461 };
00462 #define STA_STATS_LEN   ARRAY_SIZE(ieee80211_gstrings_sta_stats)
00463 
00464 static int ieee80211_get_et_sset_count(struct wiphy *wiphy,
00465                                        struct net_device *dev,
00466                                        int sset)
00467 {
00468         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00469         int rv = 0;
00470 
00471         if (sset == ETH_SS_STATS)
00472                 rv += STA_STATS_LEN;
00473 
00474         rv += drv_get_et_sset_count(sdata, sset);
00475 
00476         if (rv == 0)
00477                 return -EOPNOTSUPP;
00478         return rv;
00479 }
00480 
00481 static void ieee80211_get_et_stats(struct wiphy *wiphy,
00482                                    struct net_device *dev,
00483                                    struct ethtool_stats *stats,
00484                                    u64 *data)
00485 {
00486         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00487         struct sta_info *sta;
00488         struct ieee80211_local *local = sdata->local;
00489         struct station_info sinfo;
00490         struct survey_info survey;
00491         int i, q;
00492 #define STA_STATS_SURVEY_LEN 7
00493 
00494         memset(data, 0, sizeof(u64) * STA_STATS_LEN);
00495 
00496 #define ADD_STA_STATS(sta)                              \
00497         do {                                            \
00498                 data[i++] += sta->rx_packets;           \
00499                 data[i++] += sta->rx_bytes;             \
00500                 data[i++] += sta->wep_weak_iv_count;    \
00501                 data[i++] += sta->num_duplicates;       \
00502                 data[i++] += sta->rx_fragments;         \
00503                 data[i++] += sta->rx_dropped;           \
00504                                                         \
00505                 data[i++] += sta->tx_packets;           \
00506                 data[i++] += sta->tx_bytes;             \
00507                 data[i++] += sta->tx_fragments;         \
00508                 data[i++] += sta->tx_filtered_count;    \
00509                 data[i++] += sta->tx_retry_failed;      \
00510                 data[i++] += sta->tx_retry_count;       \
00511                 data[i++] += sta->beacon_loss_count;    \
00512         } while (0)
00513 
00514         /* For Managed stations, find the single station based on BSSID
00515          * and use that.  For interface types, iterate through all available
00516          * stations and add stats for any station that is assigned to this
00517          * network device.
00518          */
00519 
00520         rcu_read_lock();
00521 
00522         if (sdata->vif.type == NL80211_IFTYPE_STATION) {
00523                 sta = sta_info_get_bss(sdata, sdata->u.mgd.bssid);
00524 
00525                 if (!(sta && !WARN_ON(sta->sdata->dev != dev)))
00526                         goto do_survey;
00527 
00528                 i = 0;
00529                 ADD_STA_STATS(sta);
00530 
00531                 data[i++] = sta->sta_state;
00532 
00533                 sinfo.filled = 0;
00534                 sta_set_sinfo(sta, &sinfo);
00535 
00536                 if (sinfo.filled & STATION_INFO_TX_BITRATE)
00537                         data[i] = 100000 *
00538                                 cfg80211_calculate_bitrate(&sinfo.txrate);
00539                 i++;
00540                 if (sinfo.filled & STATION_INFO_RX_BITRATE)
00541                         data[i] = 100000 *
00542                                 cfg80211_calculate_bitrate(&sinfo.rxrate);
00543                 i++;
00544 
00545                 if (sinfo.filled & STATION_INFO_SIGNAL_AVG)
00546                         data[i] = (u8)sinfo.signal_avg;
00547                 i++;
00548         } else {
00549                 list_for_each_entry_rcu(sta, &local->sta_list, list) {
00550                         /* Make sure this station belongs to the proper dev */
00551                         if (sta->sdata->dev != dev)
00552                                 continue;
00553 
00554                         i = 0;
00555                         ADD_STA_STATS(sta);
00556                 }
00557         }
00558 
00559 do_survey:
00560         i = STA_STATS_LEN - STA_STATS_SURVEY_LEN;
00561         /* Get survey stats for current channel */
00562         q = 0;
00563         while (true) {
00564                 survey.filled = 0;
00565                 if (drv_get_survey(local, q, &survey) != 0) {
00566                         survey.filled = 0;
00567                         break;
00568                 }
00569 
00570                 if (survey.channel &&
00571                     (local->oper_channel->center_freq ==
00572                      survey.channel->center_freq))
00573                         break;
00574                 q++;
00575         }
00576 
00577         if (survey.filled)
00578                 data[i++] = survey.channel->center_freq;
00579         else
00580                 data[i++] = 0;
00581         if (survey.filled & SURVEY_INFO_NOISE_DBM)
00582                 data[i++] = (u8)survey.noise;
00583         else
00584                 data[i++] = -1LL;
00585         if (survey.filled & SURVEY_INFO_CHANNEL_TIME)
00586                 data[i++] = survey.channel_time;
00587         else
00588                 data[i++] = -1LL;
00589         if (survey.filled & SURVEY_INFO_CHANNEL_TIME_BUSY)
00590                 data[i++] = survey.channel_time_busy;
00591         else
00592                 data[i++] = -1LL;
00593         if (survey.filled & SURVEY_INFO_CHANNEL_TIME_EXT_BUSY)
00594                 data[i++] = survey.channel_time_ext_busy;
00595         else
00596                 data[i++] = -1LL;
00597         if (survey.filled & SURVEY_INFO_CHANNEL_TIME_RX)
00598                 data[i++] = survey.channel_time_rx;
00599         else
00600                 data[i++] = -1LL;
00601         if (survey.filled & SURVEY_INFO_CHANNEL_TIME_TX)
00602                 data[i++] = survey.channel_time_tx;
00603         else
00604                 data[i++] = -1LL;
00605 
00606         rcu_read_unlock();
00607 
00608         if (WARN_ON(i != STA_STATS_LEN))
00609                 return;
00610 
00611         drv_get_et_stats(sdata, stats, &(data[STA_STATS_LEN]));
00612 }
00613 
00614 static void ieee80211_get_et_strings(struct wiphy *wiphy,
00615                                      struct net_device *dev,
00616                                      u32 sset, u8 *data)
00617 {
00618         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00619         int sz_sta_stats = 0;
00620 
00621         if (sset == ETH_SS_STATS) {
00622                 sz_sta_stats = sizeof(ieee80211_gstrings_sta_stats);
00623                 memcpy(data, *ieee80211_gstrings_sta_stats, sz_sta_stats);
00624         }
00625         drv_get_et_strings(sdata, sset, &(data[sz_sta_stats]));
00626 }
00627 
00628 static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
00629                                  int idx, u8 *mac, struct station_info *sinfo)
00630 {
00631         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00632         struct sta_info *sta;
00633         int ret = -ENOENT;
00634 
00635         rcu_read_lock();
00636 
00637         sta = sta_info_get_by_idx(sdata, idx);
00638         if (sta) {
00639                 ret = 0;
00640                 memcpy(mac, sta->sta.addr, ETH_ALEN);
00641                 sta_set_sinfo(sta, sinfo);
00642         }
00643 
00644         rcu_read_unlock();
00645 
00646         return ret;
00647 }
00648 
00649 static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
00650                                  int idx, struct survey_info *survey)
00651 {
00652         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
00653 
00654         return drv_get_survey(local, idx, survey);
00655 }
00656 
00657 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
00658                                  u8 *mac, struct station_info *sinfo)
00659 {
00660         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00661         struct sta_info *sta;
00662         int ret = -ENOENT;
00663 
00664         rcu_read_lock();
00665 
00666         sta = sta_info_get_bss(sdata, mac);
00667         if (sta) {
00668                 ret = 0;
00669                 sta_set_sinfo(sta, sinfo);
00670         }
00671 
00672         rcu_read_unlock();
00673 
00674         return ret;
00675 }
00676 
00677 static int ieee80211_set_probe_resp(struct ieee80211_sub_if_data *sdata,
00678                                     const u8 *resp, size_t resp_len)
00679 {
00680         struct sk_buff *new, *old;
00681 
00682         if (!resp || !resp_len)
00683                 return 1;
00684 
00685         old = rtnl_dereference(sdata->u.ap.probe_resp);
00686 
00687         new = dev_alloc_skb(resp_len);
00688         if (!new)
00689                 return -ENOMEM;
00690 
00691         memcpy(skb_put(new, resp_len), resp, resp_len);
00692 
00693         rcu_assign_pointer(sdata->u.ap.probe_resp, new);
00694         if (old) {
00695                 /* TODO: use call_rcu() */
00696                 synchronize_rcu();
00697                 dev_kfree_skb(old);
00698         }
00699 
00700         return 0;
00701 }
00702 
00703 static int ieee80211_assign_beacon(struct ieee80211_sub_if_data *sdata,
00704                                    struct cfg80211_beacon_data *params)
00705 {
00706         struct beacon_data *new, *old;
00707         int new_head_len, new_tail_len;
00708         int size, err;
00709         u32 changed = BSS_CHANGED_BEACON;
00710 
00711         old = rtnl_dereference(sdata->u.ap.beacon);
00712 
00713         /* Need to have a beacon head if we don't have one yet */
00714         if (!params->head && !old)
00715                 return -EINVAL;
00716 
00717         /* new or old head? */
00718         if (params->head)
00719                 new_head_len = params->head_len;
00720         else
00721                 new_head_len = old->head_len;
00722 
00723         /* new or old tail? */
00724         if (params->tail || !old)
00725                 /* params->tail_len will be zero for !params->tail */
00726                 new_tail_len = params->tail_len;
00727         else
00728                 new_tail_len = old->tail_len;
00729 
00730         size = sizeof(*new) + new_head_len + new_tail_len;
00731 
00732         new = kzalloc(size, GFP_KERNEL);
00733         if (!new)
00734                 return -ENOMEM;
00735 
00736         /* start filling the new info now */
00737 
00738         /*
00739          * pointers go into the block we allocated,
00740          * memory is | beacon_data | head | tail |
00741          */
00742         new->head = ((u8 *) new) + sizeof(*new);
00743         new->tail = new->head + new_head_len;
00744         new->head_len = new_head_len;
00745         new->tail_len = new_tail_len;
00746 
00747         /* copy in head */
00748         if (params->head)
00749                 memcpy(new->head, params->head, new_head_len);
00750         else
00751                 memcpy(new->head, old->head, new_head_len);
00752 
00753         /* copy in optional tail */
00754         if (params->tail)
00755                 memcpy(new->tail, params->tail, new_tail_len);
00756         else
00757                 if (old)
00758                         memcpy(new->tail, old->tail, new_tail_len);
00759 
00760         err = ieee80211_set_probe_resp(sdata, params->probe_resp,
00761                                        params->probe_resp_len);
00762         if (err < 0)
00763                 return err;
00764         if (err == 0)
00765                 changed |= BSS_CHANGED_AP_PROBE_RESP;
00766 
00767         rcu_assign_pointer(sdata->u.ap.beacon, new);
00768 
00769         if (old)
00770                 kfree_rcu(old, rcu_head);
00771 
00772         return changed;
00773 }
00774 
00775 static int ieee80211_start_ap(struct wiphy *wiphy, struct net_device *dev,
00776                               struct cfg80211_ap_settings *params)
00777 {
00778         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00779         struct beacon_data *old;
00780         struct ieee80211_sub_if_data *vlan;
00781         u32 changed = BSS_CHANGED_BEACON_INT |
00782                       BSS_CHANGED_BEACON_ENABLED |
00783                       BSS_CHANGED_BEACON |
00784                       BSS_CHANGED_SSID;
00785         int err;
00786 
00787         old = rtnl_dereference(sdata->u.ap.beacon);
00788         if (old)
00789                 return -EALREADY;
00790 
00791         /*
00792          * Apply control port protocol, this allows us to
00793          * not encrypt dynamic WEP control frames.
00794          */
00795         sdata->control_port_protocol = params->crypto.control_port_ethertype;
00796         sdata->control_port_no_encrypt = params->crypto.control_port_no_encrypt;
00797         list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list) {
00798                 vlan->control_port_protocol =
00799                         params->crypto.control_port_ethertype;
00800                 vlan->control_port_no_encrypt =
00801                         params->crypto.control_port_no_encrypt;
00802         }
00803 
00804         sdata->vif.bss_conf.beacon_int = params->beacon_interval;
00805         sdata->vif.bss_conf.dtim_period = params->dtim_period;
00806 
00807         sdata->vif.bss_conf.ssid_len = params->ssid_len;
00808         if (params->ssid_len)
00809                 memcpy(sdata->vif.bss_conf.ssid, params->ssid,
00810                        params->ssid_len);
00811         sdata->vif.bss_conf.hidden_ssid =
00812                 (params->hidden_ssid != NL80211_HIDDEN_SSID_NOT_IN_USE);
00813 
00814         err = ieee80211_assign_beacon(sdata, &params->beacon);
00815         if (err < 0)
00816                 return err;
00817         changed |= err;
00818 
00819         ieee80211_bss_info_change_notify(sdata, changed);
00820 
00821         netif_carrier_on(dev);
00822         list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
00823                 netif_carrier_on(vlan->dev);
00824 
00825         return 0;
00826 }
00827 
00828 static int ieee80211_change_beacon(struct wiphy *wiphy, struct net_device *dev,
00829                                    struct cfg80211_beacon_data *params)
00830 {
00831         struct ieee80211_sub_if_data *sdata;
00832         struct beacon_data *old;
00833         int err;
00834 
00835         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00836 
00837         old = rtnl_dereference(sdata->u.ap.beacon);
00838         if (!old)
00839                 return -ENOENT;
00840 
00841         err = ieee80211_assign_beacon(sdata, params);
00842         if (err < 0)
00843                 return err;
00844         ieee80211_bss_info_change_notify(sdata, err);
00845         return 0;
00846 }
00847 
00848 static int ieee80211_stop_ap(struct wiphy *wiphy, struct net_device *dev)
00849 {
00850         struct ieee80211_sub_if_data *sdata, *vlan;
00851         struct beacon_data *old;
00852 
00853         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
00854 
00855         old = rtnl_dereference(sdata->u.ap.beacon);
00856         if (!old)
00857                 return -ENOENT;
00858 
00859         list_for_each_entry(vlan, &sdata->u.ap.vlans, u.vlan.list)
00860                 netif_carrier_off(vlan->dev);
00861         netif_carrier_off(dev);
00862 
00863         RCU_INIT_POINTER(sdata->u.ap.beacon, NULL);
00864 
00865         kfree_rcu(old, rcu_head);
00866 
00867         ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_BEACON_ENABLED);
00868 
00869         return 0;
00870 }
00871 
00872 /* Layer 2 Update frame (802.2 Type 1 LLC XID Update response) */
00873 struct iapp_layer2_update {
00874         u8 da[ETH_ALEN];        /* broadcast */
00875         u8 sa[ETH_ALEN];        /* STA addr */
00876         __be16 len;             /* 6 */
00877         u8 dsap;                /* 0 */
00878         u8 ssap;                /* 0 */
00879         u8 control;
00880         u8 xid_info[3];
00881 } __packed;
00882 
00883 static void ieee80211_send_layer2_update(struct sta_info *sta)
00884 {
00885         struct iapp_layer2_update *msg;
00886         struct sk_buff *skb;
00887 
00888         /* Send Level 2 Update Frame to update forwarding tables in layer 2
00889          * bridge devices */
00890 
00891         skb = dev_alloc_skb(sizeof(*msg));
00892         if (!skb)
00893                 return;
00894         msg = (struct iapp_layer2_update *)skb_put(skb, sizeof(*msg));
00895 
00896         /* 802.2 Type 1 Logical Link Control (LLC) Exchange Identifier (XID)
00897          * Update response frame; IEEE Std 802.2-1998, 5.4.1.2.1 */
00898 
00899         memset(msg->da, 0xff, ETH_ALEN);
00900         memcpy(msg->sa, sta->sta.addr, ETH_ALEN);
00901         msg->len = htons(6);
00902         msg->dsap = 0;
00903         msg->ssap = 0x01;       /* NULL LSAP, CR Bit: Response */
00904         msg->control = 0xaf;    /* XID response lsb.1111F101.
00905                                  * F=0 (no poll command; unsolicited frame) */
00906         msg->xid_info[0] = 0x81;        /* XID format identifier */
00907         msg->xid_info[1] = 1;   /* LLC types/classes: Type 1 LLC */
00908         msg->xid_info[2] = 0;   /* XID sender's receive window size (RW) */
00909 
00910         skb->dev = sta->sdata->dev;
00911         skb->protocol = eth_type_trans(skb, sta->sdata->dev);
00912         memset(skb->cb, 0, sizeof(skb->cb));
00913         netif_rx_ni(skb);
00914 }
00915 
00916 static int sta_apply_parameters(struct ieee80211_local *local,
00917                                 struct sta_info *sta,
00918                                 struct station_parameters *params)
00919 {
00920         int ret = 0;
00921         u32 rates;
00922         int i, j;
00923         struct ieee80211_supported_band *sband;
00924         struct ieee80211_sub_if_data *sdata = sta->sdata;
00925         u32 mask, set;
00926 
00927         sband = local->hw.wiphy->bands[local->oper_channel->band];
00928 
00929         mask = params->sta_flags_mask;
00930         set = params->sta_flags_set;
00931 
00932         /*
00933          * In mesh mode, we can clear AUTHENTICATED flag but must
00934          * also make ASSOCIATED follow appropriately for the driver
00935          * API. See also below, after AUTHORIZED changes.
00936          */
00937         if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
00938                 /* cfg80211 should not allow this in non-mesh modes */
00939                 if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif)))
00940                         return -EINVAL;
00941 
00942                 if (set & BIT(NL80211_STA_FLAG_AUTHENTICATED) &&
00943                     !test_sta_flag(sta, WLAN_STA_AUTH)) {
00944                         ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
00945                         if (ret)
00946                                 return ret;
00947                         ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
00948                         if (ret)
00949                                 return ret;
00950                 }
00951         }
00952 
00953         if (mask & BIT(NL80211_STA_FLAG_AUTHORIZED)) {
00954                 if (set & BIT(NL80211_STA_FLAG_AUTHORIZED))
00955                         ret = sta_info_move_state(sta, IEEE80211_STA_AUTHORIZED);
00956                 else if (test_sta_flag(sta, WLAN_STA_AUTHORIZED))
00957                         ret = sta_info_move_state(sta, IEEE80211_STA_ASSOC);
00958                 if (ret)
00959                         return ret;
00960         }
00961 
00962         if (mask & BIT(NL80211_STA_FLAG_AUTHENTICATED)) {
00963                 /* cfg80211 should not allow this in non-mesh modes */
00964                 if (WARN_ON(!ieee80211_vif_is_mesh(&sdata->vif)))
00965                         return -EINVAL;
00966 
00967                 if (!(set & BIT(NL80211_STA_FLAG_AUTHENTICATED)) &&
00968                     test_sta_flag(sta, WLAN_STA_AUTH)) {
00969                         ret = sta_info_move_state(sta, IEEE80211_STA_AUTH);
00970                         if (ret)
00971                                 return ret;
00972                         ret = sta_info_move_state(sta, IEEE80211_STA_NONE);
00973                         if (ret)
00974                                 return ret;
00975                 }
00976         }
00977 
00978 
00979         if (mask & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE)) {
00980                 if (set & BIT(NL80211_STA_FLAG_SHORT_PREAMBLE))
00981                         set_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
00982                 else
00983                         clear_sta_flag(sta, WLAN_STA_SHORT_PREAMBLE);
00984         }
00985 
00986         if (mask & BIT(NL80211_STA_FLAG_WME)) {
00987                 if (set & BIT(NL80211_STA_FLAG_WME)) {
00988                         set_sta_flag(sta, WLAN_STA_WME);
00989                         sta->sta.wme = true;
00990                 } else {
00991                         clear_sta_flag(sta, WLAN_STA_WME);
00992                         sta->sta.wme = false;
00993                 }
00994         }
00995 
00996         if (mask & BIT(NL80211_STA_FLAG_MFP)) {
00997                 if (set & BIT(NL80211_STA_FLAG_MFP))
00998                         set_sta_flag(sta, WLAN_STA_MFP);
00999                 else
01000                         clear_sta_flag(sta, WLAN_STA_MFP);
01001         }
01002 
01003         if (mask & BIT(NL80211_STA_FLAG_TDLS_PEER)) {
01004                 if (set & BIT(NL80211_STA_FLAG_TDLS_PEER))
01005                         set_sta_flag(sta, WLAN_STA_TDLS_PEER);
01006                 else
01007                         clear_sta_flag(sta, WLAN_STA_TDLS_PEER);
01008         }
01009 
01010         if (params->sta_modify_mask & STATION_PARAM_APPLY_UAPSD) {
01011                 sta->sta.uapsd_queues = params->uapsd_queues;
01012                 sta->sta.max_sp = params->max_sp;
01013         }
01014 
01015         /*
01016          * cfg80211 validates this (1-2007) and allows setting the AID
01017          * only when creating a new station entry
01018          */
01019         if (params->aid)
01020                 sta->sta.aid = params->aid;
01021 
01022         /*
01023          * FIXME: updating the following information is racy when this
01024          *        function is called from ieee80211_change_station().
01025          *        However, all this information should be static so
01026          *        maybe we should just reject attemps to change it.
01027          */
01028 
01029         if (params->listen_interval >= 0)
01030                 sta->listen_interval = params->listen_interval;
01031 
01032         if (params->supported_rates) {
01033                 rates = 0;
01034 
01035                 for (i = 0; i < params->supported_rates_len; i++) {
01036                         int rate = (params->supported_rates[i] & 0x7f) * 5;
01037                         for (j = 0; j < sband->n_bitrates; j++) {
01038                                 if (sband->bitrates[j].bitrate == rate)
01039                                         rates |= BIT(j);
01040                         }
01041                 }
01042                 sta->sta.supp_rates[local->oper_channel->band] = rates;
01043         }
01044 
01045         if (params->ht_capa)
01046                 ieee80211_ht_cap_ie_to_sta_ht_cap(sdata, sband,
01047                                                   params->ht_capa,
01048                                                   &sta->sta.ht_cap);
01049 
01050         if (ieee80211_vif_is_mesh(&sdata->vif)) {
01051 #ifdef CONFIG_MAC80211_MESH
01052                 if (sdata->u.mesh.security & IEEE80211_MESH_SEC_SECURED)
01053                         switch (params->plink_state) {
01054                         case NL80211_PLINK_LISTEN:
01055                         case NL80211_PLINK_ESTAB:
01056                         case NL80211_PLINK_BLOCKED:
01057                                 sta->plink_state = params->plink_state;
01058                                 break;
01059                         default:
01060                                 /*  nothing  */
01061                                 break;
01062                         }
01063                 else
01064                         switch (params->plink_action) {
01065                         case PLINK_ACTION_OPEN:
01066                                 mesh_plink_open(sta);
01067                                 break;
01068                         case PLINK_ACTION_BLOCK:
01069                                 mesh_plink_block(sta);
01070                                 break;
01071                         }
01072 #endif
01073         }
01074 
01075         return 0;
01076 }
01077 
01078 static int ieee80211_add_station(struct wiphy *wiphy, struct net_device *dev,
01079                                  u8 *mac, struct station_parameters *params)
01080 {
01081         struct ieee80211_local *local = wiphy_priv(wiphy);
01082         struct sta_info *sta;
01083         struct ieee80211_sub_if_data *sdata;
01084         int err;
01085         int layer2_update;
01086 
01087         if (params->vlan) {
01088                 sdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
01089 
01090                 if (sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
01091                     sdata->vif.type != NL80211_IFTYPE_AP)
01092                         return -EINVAL;
01093         } else
01094                 sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01095 
01096         if (ether_addr_equal(mac, sdata->vif.addr))
01097                 return -EINVAL;
01098 
01099         if (is_multicast_ether_addr(mac))
01100                 return -EINVAL;
01101 
01102         sta = sta_info_alloc(sdata, mac, GFP_KERNEL);
01103         if (!sta)
01104                 return -ENOMEM;
01105 
01106         sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
01107         sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
01108 
01109         err = sta_apply_parameters(local, sta, params);
01110         if (err) {
01111                 sta_info_free(local, sta);
01112                 return err;
01113         }
01114 
01115         /*
01116          * for TDLS, rate control should be initialized only when supported
01117          * rates are known.
01118          */
01119         if (!test_sta_flag(sta, WLAN_STA_TDLS_PEER))
01120                 rate_control_rate_init(sta);
01121 
01122         layer2_update = sdata->vif.type == NL80211_IFTYPE_AP_VLAN ||
01123                 sdata->vif.type == NL80211_IFTYPE_AP;
01124 
01125         err = sta_info_insert_rcu(sta);
01126         if (err) {
01127                 rcu_read_unlock();
01128                 return err;
01129         }
01130 
01131         if (layer2_update)
01132                 ieee80211_send_layer2_update(sta);
01133 
01134         rcu_read_unlock();
01135 
01136         return 0;
01137 }
01138 
01139 static int ieee80211_del_station(struct wiphy *wiphy, struct net_device *dev,
01140                                  u8 *mac)
01141 {
01142         struct ieee80211_local *local = wiphy_priv(wiphy);
01143         struct ieee80211_sub_if_data *sdata;
01144 
01145         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01146 
01147         if (mac)
01148                 return sta_info_destroy_addr_bss(sdata, mac);
01149 
01150         sta_info_flush(local, sdata);
01151         return 0;
01152 }
01153 
01154 static int ieee80211_change_station(struct wiphy *wiphy,
01155                                     struct net_device *dev,
01156                                     u8 *mac,
01157                                     struct station_parameters *params)
01158 {
01159         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01160         struct ieee80211_local *local = wiphy_priv(wiphy);
01161         struct sta_info *sta;
01162         struct ieee80211_sub_if_data *vlansdata;
01163         int err;
01164 
01165         mutex_lock(&local->sta_mtx);
01166 
01167         sta = sta_info_get_bss(sdata, mac);
01168         if (!sta) {
01169                 mutex_unlock(&local->sta_mtx);
01170                 return -ENOENT;
01171         }
01172 
01173         /* in station mode, supported rates are only valid with TDLS */
01174         if (sdata->vif.type == NL80211_IFTYPE_STATION &&
01175             params->supported_rates &&
01176             !test_sta_flag(sta, WLAN_STA_TDLS_PEER)) {
01177                 mutex_unlock(&local->sta_mtx);
01178                 return -EINVAL;
01179         }
01180 
01181         if (params->vlan && params->vlan != sta->sdata->dev) {
01182                 bool prev_4addr = false;
01183                 bool new_4addr = false;
01184 
01185                 vlansdata = IEEE80211_DEV_TO_SUB_IF(params->vlan);
01186 
01187                 if (vlansdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
01188                     vlansdata->vif.type != NL80211_IFTYPE_AP) {
01189                         mutex_unlock(&local->sta_mtx);
01190                         return -EINVAL;
01191                 }
01192 
01193                 if (params->vlan->ieee80211_ptr->use_4addr) {
01194                         if (vlansdata->u.vlan.sta) {
01195                                 mutex_unlock(&local->sta_mtx);
01196                                 return -EBUSY;
01197                         }
01198 
01199                         rcu_assign_pointer(vlansdata->u.vlan.sta, sta);
01200                         new_4addr = true;
01201                 }
01202 
01203                 if (sta->sdata->vif.type == NL80211_IFTYPE_AP_VLAN &&
01204                     sta->sdata->u.vlan.sta) {
01205                         rcu_assign_pointer(sta->sdata->u.vlan.sta, NULL);
01206                         prev_4addr = true;
01207                 }
01208 
01209                 sta->sdata = vlansdata;
01210 
01211                 if (sta->sta_state == IEEE80211_STA_AUTHORIZED &&
01212                     prev_4addr != new_4addr) {
01213                         if (new_4addr)
01214                                 atomic_dec(&sta->sdata->bss->num_mcast_sta);
01215                         else
01216                                 atomic_inc(&sta->sdata->bss->num_mcast_sta);
01217                 }
01218 
01219                 ieee80211_send_layer2_update(sta);
01220         }
01221 
01222         err = sta_apply_parameters(local, sta, params);
01223         if (err) {
01224                 mutex_unlock(&local->sta_mtx);
01225                 return err;
01226         }
01227 
01228         if (test_sta_flag(sta, WLAN_STA_TDLS_PEER) && params->supported_rates)
01229                 rate_control_rate_init(sta);
01230 
01231         mutex_unlock(&local->sta_mtx);
01232 
01233         if (sdata->vif.type == NL80211_IFTYPE_STATION &&
01234             params->sta_flags_mask & BIT(NL80211_STA_FLAG_AUTHORIZED))
01235                 ieee80211_recalc_ps(local, -1);
01236 
01237         return 0;
01238 }
01239 
01240 #ifdef CONFIG_MAC80211_MESH
01241 static int ieee80211_add_mpath(struct wiphy *wiphy, struct net_device *dev,
01242                                  u8 *dst, u8 *next_hop)
01243 {
01244         struct ieee80211_sub_if_data *sdata;
01245         struct mesh_path *mpath;
01246         struct sta_info *sta;
01247         int err;
01248 
01249         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01250 
01251         rcu_read_lock();
01252         sta = sta_info_get(sdata, next_hop);
01253         if (!sta) {
01254                 rcu_read_unlock();
01255                 return -ENOENT;
01256         }
01257 
01258         err = mesh_path_add(dst, sdata);
01259         if (err) {
01260                 rcu_read_unlock();
01261                 return err;
01262         }
01263 
01264         mpath = mesh_path_lookup(dst, sdata);
01265         if (!mpath) {
01266                 rcu_read_unlock();
01267                 return -ENXIO;
01268         }
01269         mesh_path_fix_nexthop(mpath, sta);
01270 
01271         rcu_read_unlock();
01272         return 0;
01273 }
01274 
01275 static int ieee80211_del_mpath(struct wiphy *wiphy, struct net_device *dev,
01276                                  u8 *dst)
01277 {
01278         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01279 
01280         if (dst)
01281                 return mesh_path_del(dst, sdata);
01282 
01283         mesh_path_flush_by_iface(sdata);
01284         return 0;
01285 }
01286 
01287 static int ieee80211_change_mpath(struct wiphy *wiphy,
01288                                     struct net_device *dev,
01289                                     u8 *dst, u8 *next_hop)
01290 {
01291         struct ieee80211_sub_if_data *sdata;
01292         struct mesh_path *mpath;
01293         struct sta_info *sta;
01294 
01295         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01296 
01297         rcu_read_lock();
01298 
01299         sta = sta_info_get(sdata, next_hop);
01300         if (!sta) {
01301                 rcu_read_unlock();
01302                 return -ENOENT;
01303         }
01304 
01305         mpath = mesh_path_lookup(dst, sdata);
01306         if (!mpath) {
01307                 rcu_read_unlock();
01308                 return -ENOENT;
01309         }
01310 
01311         mesh_path_fix_nexthop(mpath, sta);
01312 
01313         rcu_read_unlock();
01314         return 0;
01315 }
01316 
01317 static void mpath_set_pinfo(struct mesh_path *mpath, u8 *next_hop,
01318                             struct mpath_info *pinfo)
01319 {
01320         struct sta_info *next_hop_sta = rcu_dereference(mpath->next_hop);
01321 
01322         if (next_hop_sta)
01323                 memcpy(next_hop, next_hop_sta->sta.addr, ETH_ALEN);
01324         else
01325                 memset(next_hop, 0, ETH_ALEN);
01326 
01327         pinfo->generation = mesh_paths_generation;
01328 
01329         pinfo->filled = MPATH_INFO_FRAME_QLEN |
01330                         MPATH_INFO_SN |
01331                         MPATH_INFO_METRIC |
01332                         MPATH_INFO_EXPTIME |
01333                         MPATH_INFO_DISCOVERY_TIMEOUT |
01334                         MPATH_INFO_DISCOVERY_RETRIES |
01335                         MPATH_INFO_FLAGS;
01336 
01337         pinfo->frame_qlen = mpath->frame_queue.qlen;
01338         pinfo->sn = mpath->sn;
01339         pinfo->metric = mpath->metric;
01340         if (time_before(jiffies, mpath->exp_time))
01341                 pinfo->exptime = jiffies_to_msecs(mpath->exp_time - jiffies);
01342         pinfo->discovery_timeout =
01343                         jiffies_to_msecs(mpath->discovery_timeout);
01344         pinfo->discovery_retries = mpath->discovery_retries;
01345         pinfo->flags = 0;
01346         if (mpath->flags & MESH_PATH_ACTIVE)
01347                 pinfo->flags |= NL80211_MPATH_FLAG_ACTIVE;
01348         if (mpath->flags & MESH_PATH_RESOLVING)
01349                 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
01350         if (mpath->flags & MESH_PATH_SN_VALID)
01351                 pinfo->flags |= NL80211_MPATH_FLAG_SN_VALID;
01352         if (mpath->flags & MESH_PATH_FIXED)
01353                 pinfo->flags |= NL80211_MPATH_FLAG_FIXED;
01354         if (mpath->flags & MESH_PATH_RESOLVING)
01355                 pinfo->flags |= NL80211_MPATH_FLAG_RESOLVING;
01356 
01357         pinfo->flags = mpath->flags;
01358 }
01359 
01360 static int ieee80211_get_mpath(struct wiphy *wiphy, struct net_device *dev,
01361                                u8 *dst, u8 *next_hop, struct mpath_info *pinfo)
01362 
01363 {
01364         struct ieee80211_sub_if_data *sdata;
01365         struct mesh_path *mpath;
01366 
01367         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01368 
01369         rcu_read_lock();
01370         mpath = mesh_path_lookup(dst, sdata);
01371         if (!mpath) {
01372                 rcu_read_unlock();
01373                 return -ENOENT;
01374         }
01375         memcpy(dst, mpath->dst, ETH_ALEN);
01376         mpath_set_pinfo(mpath, next_hop, pinfo);
01377         rcu_read_unlock();
01378         return 0;
01379 }
01380 
01381 static int ieee80211_dump_mpath(struct wiphy *wiphy, struct net_device *dev,
01382                                  int idx, u8 *dst, u8 *next_hop,
01383                                  struct mpath_info *pinfo)
01384 {
01385         struct ieee80211_sub_if_data *sdata;
01386         struct mesh_path *mpath;
01387 
01388         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01389 
01390         rcu_read_lock();
01391         mpath = mesh_path_lookup_by_idx(idx, sdata);
01392         if (!mpath) {
01393                 rcu_read_unlock();
01394                 return -ENOENT;
01395         }
01396         memcpy(dst, mpath->dst, ETH_ALEN);
01397         mpath_set_pinfo(mpath, next_hop, pinfo);
01398         rcu_read_unlock();
01399         return 0;
01400 }
01401 
01402 static int ieee80211_get_mesh_config(struct wiphy *wiphy,
01403                                 struct net_device *dev,
01404                                 struct mesh_config *conf)
01405 {
01406         struct ieee80211_sub_if_data *sdata;
01407         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01408 
01409         memcpy(conf, &(sdata->u.mesh.mshcfg), sizeof(struct mesh_config));
01410         return 0;
01411 }
01412 
01413 static inline bool _chg_mesh_attr(enum nl80211_meshconf_params parm, u32 mask)
01414 {
01415         return (mask >> (parm-1)) & 0x1;
01416 }
01417 
01418 static int copy_mesh_setup(struct ieee80211_if_mesh *ifmsh,
01419                 const struct mesh_setup *setup)
01420 {
01421         u8 *new_ie;
01422         const u8 *old_ie;
01423         struct ieee80211_sub_if_data *sdata = container_of(ifmsh,
01424                                         struct ieee80211_sub_if_data, u.mesh);
01425 
01426         /* allocate information elements */
01427         new_ie = NULL;
01428         old_ie = ifmsh->ie;
01429 
01430         if (setup->ie_len) {
01431                 new_ie = kmemdup(setup->ie, setup->ie_len,
01432                                 GFP_KERNEL);
01433                 if (!new_ie)
01434                         return -ENOMEM;
01435         }
01436         ifmsh->ie_len = setup->ie_len;
01437         ifmsh->ie = new_ie;
01438         kfree(old_ie);
01439 
01440         /* now copy the rest of the setup parameters */
01441         ifmsh->mesh_id_len = setup->mesh_id_len;
01442         memcpy(ifmsh->mesh_id, setup->mesh_id, ifmsh->mesh_id_len);
01443         ifmsh->mesh_sp_id = setup->sync_method;
01444         ifmsh->mesh_pp_id = setup->path_sel_proto;
01445         ifmsh->mesh_pm_id = setup->path_metric;
01446         ifmsh->security = IEEE80211_MESH_SEC_NONE;
01447         if (setup->is_authenticated)
01448                 ifmsh->security |= IEEE80211_MESH_SEC_AUTHED;
01449         if (setup->is_secure)
01450                 ifmsh->security |= IEEE80211_MESH_SEC_SECURED;
01451 
01452         /* mcast rate setting in Mesh Node */
01453         memcpy(sdata->vif.bss_conf.mcast_rate, setup->mcast_rate,
01454                                                 sizeof(setup->mcast_rate));
01455 
01456         return 0;
01457 }
01458 
01459 static int ieee80211_update_mesh_config(struct wiphy *wiphy,
01460                                         struct net_device *dev, u32 mask,
01461                                         const struct mesh_config *nconf)
01462 {
01463         struct mesh_config *conf;
01464         struct ieee80211_sub_if_data *sdata;
01465         struct ieee80211_if_mesh *ifmsh;
01466 
01467         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01468         ifmsh = &sdata->u.mesh;
01469 
01470         /* Set the config options which we are interested in setting */
01471         conf = &(sdata->u.mesh.mshcfg);
01472         if (_chg_mesh_attr(NL80211_MESHCONF_RETRY_TIMEOUT, mask))
01473                 conf->dot11MeshRetryTimeout = nconf->dot11MeshRetryTimeout;
01474         if (_chg_mesh_attr(NL80211_MESHCONF_CONFIRM_TIMEOUT, mask))
01475                 conf->dot11MeshConfirmTimeout = nconf->dot11MeshConfirmTimeout;
01476         if (_chg_mesh_attr(NL80211_MESHCONF_HOLDING_TIMEOUT, mask))
01477                 conf->dot11MeshHoldingTimeout = nconf->dot11MeshHoldingTimeout;
01478         if (_chg_mesh_attr(NL80211_MESHCONF_MAX_PEER_LINKS, mask))
01479                 conf->dot11MeshMaxPeerLinks = nconf->dot11MeshMaxPeerLinks;
01480         if (_chg_mesh_attr(NL80211_MESHCONF_MAX_RETRIES, mask))
01481                 conf->dot11MeshMaxRetries = nconf->dot11MeshMaxRetries;
01482         if (_chg_mesh_attr(NL80211_MESHCONF_TTL, mask))
01483                 conf->dot11MeshTTL = nconf->dot11MeshTTL;
01484         if (_chg_mesh_attr(NL80211_MESHCONF_ELEMENT_TTL, mask))
01485                 conf->dot11MeshTTL = nconf->element_ttl;
01486         if (_chg_mesh_attr(NL80211_MESHCONF_AUTO_OPEN_PLINKS, mask))
01487                 conf->auto_open_plinks = nconf->auto_open_plinks;
01488         if (_chg_mesh_attr(NL80211_MESHCONF_SYNC_OFFSET_MAX_NEIGHBOR, mask))
01489                 conf->dot11MeshNbrOffsetMaxNeighbor =
01490                         nconf->dot11MeshNbrOffsetMaxNeighbor;
01491         if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_MAX_PREQ_RETRIES, mask))
01492                 conf->dot11MeshHWMPmaxPREQretries =
01493                         nconf->dot11MeshHWMPmaxPREQretries;
01494         if (_chg_mesh_attr(NL80211_MESHCONF_PATH_REFRESH_TIME, mask))
01495                 conf->path_refresh_time = nconf->path_refresh_time;
01496         if (_chg_mesh_attr(NL80211_MESHCONF_MIN_DISCOVERY_TIMEOUT, mask))
01497                 conf->min_discovery_timeout = nconf->min_discovery_timeout;
01498         if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ACTIVE_PATH_TIMEOUT, mask))
01499                 conf->dot11MeshHWMPactivePathTimeout =
01500                         nconf->dot11MeshHWMPactivePathTimeout;
01501         if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PREQ_MIN_INTERVAL, mask))
01502                 conf->dot11MeshHWMPpreqMinInterval =
01503                         nconf->dot11MeshHWMPpreqMinInterval;
01504         if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_PERR_MIN_INTERVAL, mask))
01505                 conf->dot11MeshHWMPperrMinInterval =
01506                         nconf->dot11MeshHWMPperrMinInterval;
01507         if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_NET_DIAM_TRVS_TIME,
01508                            mask))
01509                 conf->dot11MeshHWMPnetDiameterTraversalTime =
01510                         nconf->dot11MeshHWMPnetDiameterTraversalTime;
01511         if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_ROOTMODE, mask)) {
01512                 conf->dot11MeshHWMPRootMode = nconf->dot11MeshHWMPRootMode;
01513                 ieee80211_mesh_root_setup(ifmsh);
01514         }
01515         if (_chg_mesh_attr(NL80211_MESHCONF_GATE_ANNOUNCEMENTS, mask)) {
01516                 /* our current gate announcement implementation rides on root
01517                  * announcements, so require this ifmsh to also be a root node
01518                  * */
01519                 if (nconf->dot11MeshGateAnnouncementProtocol &&
01520                     !conf->dot11MeshHWMPRootMode) {
01521                         conf->dot11MeshHWMPRootMode = 1;
01522                         ieee80211_mesh_root_setup(ifmsh);
01523                 }
01524                 conf->dot11MeshGateAnnouncementProtocol =
01525                         nconf->dot11MeshGateAnnouncementProtocol;
01526         }
01527         if (_chg_mesh_attr(NL80211_MESHCONF_HWMP_RANN_INTERVAL, mask)) {
01528                 conf->dot11MeshHWMPRannInterval =
01529                         nconf->dot11MeshHWMPRannInterval;
01530         }
01531         if (_chg_mesh_attr(NL80211_MESHCONF_FORWARDING, mask))
01532                 conf->dot11MeshForwarding = nconf->dot11MeshForwarding;
01533         if (_chg_mesh_attr(NL80211_MESHCONF_RSSI_THRESHOLD, mask)) {
01534                 /* our RSSI threshold implementation is supported only for
01535                  * devices that report signal in dBm.
01536                  */
01537                 if (!(sdata->local->hw.flags & IEEE80211_HW_SIGNAL_DBM))
01538                         return -ENOTSUPP;
01539                 conf->rssi_threshold = nconf->rssi_threshold;
01540         }
01541         if (_chg_mesh_attr(NL80211_MESHCONF_HT_OPMODE, mask)) {
01542                 conf->ht_opmode = nconf->ht_opmode;
01543                 sdata->vif.bss_conf.ht_operation_mode = nconf->ht_opmode;
01544                 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
01545         }
01546         return 0;
01547 }
01548 
01549 static int ieee80211_join_mesh(struct wiphy *wiphy, struct net_device *dev,
01550                                const struct mesh_config *conf,
01551                                const struct mesh_setup *setup)
01552 {
01553         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01554         struct ieee80211_if_mesh *ifmsh = &sdata->u.mesh;
01555         int err;
01556 
01557         memcpy(&ifmsh->mshcfg, conf, sizeof(struct mesh_config));
01558         err = copy_mesh_setup(ifmsh, setup);
01559         if (err)
01560                 return err;
01561         ieee80211_start_mesh(sdata);
01562 
01563         return 0;
01564 }
01565 
01566 static int ieee80211_leave_mesh(struct wiphy *wiphy, struct net_device *dev)
01567 {
01568         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01569 
01570         ieee80211_stop_mesh(sdata);
01571 
01572         return 0;
01573 }
01574 #endif
01575 
01576 static int ieee80211_change_bss(struct wiphy *wiphy,
01577                                 struct net_device *dev,
01578                                 struct bss_parameters *params)
01579 {
01580         struct ieee80211_sub_if_data *sdata;
01581         u32 changed = 0;
01582 
01583         sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01584 
01585         if (params->use_cts_prot >= 0) {
01586                 sdata->vif.bss_conf.use_cts_prot = params->use_cts_prot;
01587                 changed |= BSS_CHANGED_ERP_CTS_PROT;
01588         }
01589         if (params->use_short_preamble >= 0) {
01590                 sdata->vif.bss_conf.use_short_preamble =
01591                         params->use_short_preamble;
01592                 changed |= BSS_CHANGED_ERP_PREAMBLE;
01593         }
01594 
01595         if (!sdata->vif.bss_conf.use_short_slot &&
01596             sdata->local->hw.conf.channel->band == IEEE80211_BAND_5GHZ) {
01597                 sdata->vif.bss_conf.use_short_slot = true;
01598                 changed |= BSS_CHANGED_ERP_SLOT;
01599         }
01600 
01601         if (params->use_short_slot_time >= 0) {
01602                 sdata->vif.bss_conf.use_short_slot =
01603                         params->use_short_slot_time;
01604                 changed |= BSS_CHANGED_ERP_SLOT;
01605         }
01606 
01607         if (params->basic_rates) {
01608                 int i, j;
01609                 u32 rates = 0;
01610                 struct ieee80211_local *local = wiphy_priv(wiphy);
01611                 struct ieee80211_supported_band *sband =
01612                         wiphy->bands[local->oper_channel->band];
01613 
01614                 for (i = 0; i < params->basic_rates_len; i++) {
01615                         int rate = (params->basic_rates[i] & 0x7f) * 5;
01616                         for (j = 0; j < sband->n_bitrates; j++) {
01617                                 if (sband->bitrates[j].bitrate == rate)
01618                                         rates |= BIT(j);
01619                         }
01620                 }
01621                 sdata->vif.bss_conf.basic_rates = rates;
01622                 changed |= BSS_CHANGED_BASIC_RATES;
01623         }
01624 
01625         if (params->ap_isolate >= 0) {
01626                 if (params->ap_isolate)
01627                         sdata->flags |= IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
01628                 else
01629                         sdata->flags &= ~IEEE80211_SDATA_DONT_BRIDGE_PACKETS;
01630         }
01631 
01632         if (params->ht_opmode >= 0) {
01633                 sdata->vif.bss_conf.ht_operation_mode =
01634                         (u16) params->ht_opmode;
01635                 changed |= BSS_CHANGED_HT;
01636         }
01637 
01638         ieee80211_bss_info_change_notify(sdata, changed);
01639 
01640         return 0;
01641 }
01642 
01643 static int ieee80211_set_txq_params(struct wiphy *wiphy,
01644                                     struct net_device *dev,
01645                                     struct ieee80211_txq_params *params)
01646 {
01647         struct ieee80211_local *local = wiphy_priv(wiphy);
01648         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01649         struct ieee80211_tx_queue_params p;
01650 
01651         if (!local->ops->conf_tx)
01652                 return -EOPNOTSUPP;
01653 
01654         if (local->hw.queues < IEEE80211_NUM_ACS)
01655                 return -EOPNOTSUPP;
01656 
01657         memset(&p, 0, sizeof(p));
01658         p.aifs = params->aifs;
01659         p.cw_max = params->cwmax;
01660         p.cw_min = params->cwmin;
01661         p.txop = params->txop;
01662 
01663         /*
01664          * Setting tx queue params disables u-apsd because it's only
01665          * called in master mode.
01666          */
01667         p.uapsd = false;
01668 
01669         sdata->tx_conf[params->ac] = p;
01670         if (drv_conf_tx(local, sdata, params->ac, &p)) {
01671                 wiphy_debug(local->hw.wiphy,
01672                             "failed to set TX queue parameters for AC %d\n",
01673                             params->ac);
01674                 return -EINVAL;
01675         }
01676 
01677         return 0;
01678 }
01679 
01680 static int ieee80211_set_channel(struct wiphy *wiphy,
01681                                  struct net_device *netdev,
01682                                  struct ieee80211_channel *chan,
01683                                  enum nl80211_channel_type channel_type)
01684 {
01685         struct ieee80211_local *local = wiphy_priv(wiphy);
01686         struct ieee80211_sub_if_data *sdata = NULL;
01687         struct ieee80211_channel *old_oper;
01688         enum nl80211_channel_type old_oper_type;
01689         enum nl80211_channel_type old_vif_oper_type= NL80211_CHAN_NO_HT;
01690 
01691         if (netdev)
01692                 sdata = IEEE80211_DEV_TO_SUB_IF(netdev);
01693 
01694         switch (ieee80211_get_channel_mode(local, NULL)) {
01695         case CHAN_MODE_HOPPING:
01696                 return -EBUSY;
01697         case CHAN_MODE_FIXED:
01698                 if (local->oper_channel != chan)
01699                         return -EBUSY;
01700                 if (!sdata && local->_oper_channel_type == channel_type)
01701                         return 0;
01702                 break;
01703         case CHAN_MODE_UNDEFINED:
01704                 break;
01705         }
01706 
01707         if (sdata)
01708                 old_vif_oper_type = sdata->vif.bss_conf.channel_type;
01709         old_oper_type = local->_oper_channel_type;
01710 
01711         if (!ieee80211_set_channel_type(local, sdata, channel_type))
01712                 return -EBUSY;
01713 
01714         old_oper = local->oper_channel;
01715         local->oper_channel = chan;
01716 
01717         /* Update driver if changes were actually made. */
01718         if ((old_oper != local->oper_channel) ||
01719             (old_oper_type != local->_oper_channel_type))
01720                 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_CHANNEL);
01721 
01722         if (sdata && sdata->vif.type != NL80211_IFTYPE_MONITOR &&
01723             old_vif_oper_type != sdata->vif.bss_conf.channel_type)
01724                 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_HT);
01725 
01726         return 0;
01727 }
01728 
01729 #ifdef CONFIG_PM
01730 static int ieee80211_suspend(struct wiphy *wiphy,
01731                              struct cfg80211_wowlan *wowlan)
01732 {
01733         return __ieee80211_suspend(wiphy_priv(wiphy), wowlan);
01734 }
01735 
01736 static int ieee80211_resume(struct wiphy *wiphy)
01737 {
01738         return __ieee80211_resume(wiphy_priv(wiphy));
01739 }
01740 #else
01741 #define ieee80211_suspend NULL
01742 #define ieee80211_resume NULL
01743 #endif
01744 
01745 static int ieee80211_scan(struct wiphy *wiphy,
01746                           struct net_device *dev,
01747                           struct cfg80211_scan_request *req)
01748 {
01749         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01750 
01751         switch (ieee80211_vif_type_p2p(&sdata->vif)) {
01752         case NL80211_IFTYPE_STATION:
01753         case NL80211_IFTYPE_ADHOC:
01754         case NL80211_IFTYPE_MESH_POINT:
01755         case NL80211_IFTYPE_P2P_CLIENT:
01756                 break;
01757         case NL80211_IFTYPE_P2P_GO:
01758                 if (sdata->local->ops->hw_scan)
01759                         break;
01760                 /*
01761                  * FIXME: implement NoA while scanning in software,
01762                  * for now fall through to allow scanning only when
01763                  * beaconing hasn't been configured yet
01764                  */
01765         case NL80211_IFTYPE_AP:
01766                 if (sdata->u.ap.beacon)
01767                         return -EOPNOTSUPP;
01768                 break;
01769         default:
01770                 return -EOPNOTSUPP;
01771         }
01772 
01773         return ieee80211_request_scan(sdata, req);
01774 }
01775 
01776 static int
01777 ieee80211_sched_scan_start(struct wiphy *wiphy,
01778                            struct net_device *dev,
01779                            struct cfg80211_sched_scan_request *req)
01780 {
01781         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01782 
01783         if (!sdata->local->ops->sched_scan_start)
01784                 return -EOPNOTSUPP;
01785 
01786         return ieee80211_request_sched_scan_start(sdata, req);
01787 }
01788 
01789 static int
01790 ieee80211_sched_scan_stop(struct wiphy *wiphy, struct net_device *dev)
01791 {
01792         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01793 
01794         if (!sdata->local->ops->sched_scan_stop)
01795                 return -EOPNOTSUPP;
01796 
01797         return ieee80211_request_sched_scan_stop(sdata);
01798 }
01799 
01800 static int ieee80211_auth(struct wiphy *wiphy, struct net_device *dev,
01801                           struct cfg80211_auth_request *req)
01802 {
01803         return ieee80211_mgd_auth(IEEE80211_DEV_TO_SUB_IF(dev), req);
01804 }
01805 
01806 static int ieee80211_assoc(struct wiphy *wiphy, struct net_device *dev,
01807                            struct cfg80211_assoc_request *req)
01808 {
01809         struct ieee80211_local *local = wiphy_priv(wiphy);
01810         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01811 
01812         switch (ieee80211_get_channel_mode(local, sdata)) {
01813         case CHAN_MODE_HOPPING:
01814                 return -EBUSY;
01815         case CHAN_MODE_FIXED:
01816                 if (local->oper_channel == req->bss->channel)
01817                         break;
01818                 return -EBUSY;
01819         case CHAN_MODE_UNDEFINED:
01820                 break;
01821         }
01822 
01823         return ieee80211_mgd_assoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
01824 }
01825 
01826 static int ieee80211_deauth(struct wiphy *wiphy, struct net_device *dev,
01827                             struct cfg80211_deauth_request *req)
01828 {
01829         return ieee80211_mgd_deauth(IEEE80211_DEV_TO_SUB_IF(dev), req);
01830 }
01831 
01832 static int ieee80211_disassoc(struct wiphy *wiphy, struct net_device *dev,
01833                               struct cfg80211_disassoc_request *req)
01834 {
01835         return ieee80211_mgd_disassoc(IEEE80211_DEV_TO_SUB_IF(dev), req);
01836 }
01837 
01838 static int ieee80211_join_ibss(struct wiphy *wiphy, struct net_device *dev,
01839                                struct cfg80211_ibss_params *params)
01840 {
01841         struct ieee80211_local *local = wiphy_priv(wiphy);
01842         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01843 
01844         switch (ieee80211_get_channel_mode(local, sdata)) {
01845         case CHAN_MODE_HOPPING:
01846                 return -EBUSY;
01847         case CHAN_MODE_FIXED:
01848                 if (!params->channel_fixed)
01849                         return -EBUSY;
01850                 if (local->oper_channel == params->channel)
01851                         break;
01852                 return -EBUSY;
01853         case CHAN_MODE_UNDEFINED:
01854                 break;
01855         }
01856 
01857         return ieee80211_ibss_join(sdata, params);
01858 }
01859 
01860 static int ieee80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev)
01861 {
01862         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01863 
01864         return ieee80211_ibss_leave(sdata);
01865 }
01866 
01867 static int ieee80211_set_wiphy_params(struct wiphy *wiphy, u32 changed)
01868 {
01869         struct ieee80211_local *local = wiphy_priv(wiphy);
01870         int err;
01871 
01872         if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
01873                 err = drv_set_frag_threshold(local, wiphy->frag_threshold);
01874 
01875                 if (err)
01876                         return err;
01877         }
01878 
01879         if (changed & WIPHY_PARAM_COVERAGE_CLASS) {
01880                 err = drv_set_coverage_class(local, wiphy->coverage_class);
01881 
01882                 if (err)
01883                         return err;
01884         }
01885 
01886         if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
01887                 err = drv_set_rts_threshold(local, wiphy->rts_threshold);
01888 
01889                 if (err)
01890                         return err;
01891         }
01892 
01893         if (changed & WIPHY_PARAM_RETRY_SHORT)
01894                 local->hw.conf.short_frame_max_tx_count = wiphy->retry_short;
01895         if (changed & WIPHY_PARAM_RETRY_LONG)
01896                 local->hw.conf.long_frame_max_tx_count = wiphy->retry_long;
01897         if (changed &
01898             (WIPHY_PARAM_RETRY_SHORT | WIPHY_PARAM_RETRY_LONG))
01899                 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_RETRY_LIMITS);
01900 
01901         return 0;
01902 }
01903 
01904 static int ieee80211_set_tx_power(struct wiphy *wiphy,
01905                                   enum nl80211_tx_power_setting type, int mbm)
01906 {
01907         struct ieee80211_local *local = wiphy_priv(wiphy);
01908         struct ieee80211_channel *chan = local->hw.conf.channel;
01909         u32 changes = 0;
01910 
01911         switch (type) {
01912         case NL80211_TX_POWER_AUTOMATIC:
01913                 local->user_power_level = -1;
01914                 break;
01915         case NL80211_TX_POWER_LIMITED:
01916                 if (mbm < 0 || (mbm % 100))
01917                         return -EOPNOTSUPP;
01918                 local->user_power_level = MBM_TO_DBM(mbm);
01919                 break;
01920         case NL80211_TX_POWER_FIXED:
01921                 if (mbm < 0 || (mbm % 100))
01922                         return -EOPNOTSUPP;
01923                 /* TODO: move to cfg80211 when it knows the channel */
01924                 if (MBM_TO_DBM(mbm) > chan->max_power)
01925                         return -EINVAL;
01926                 local->user_power_level = MBM_TO_DBM(mbm);
01927                 break;
01928         }
01929 
01930         ieee80211_hw_config(local, changes);
01931 
01932         return 0;
01933 }
01934 
01935 static int ieee80211_get_tx_power(struct wiphy *wiphy, int *dbm)
01936 {
01937         struct ieee80211_local *local = wiphy_priv(wiphy);
01938 
01939         *dbm = local->hw.conf.power_level;
01940 
01941         return 0;
01942 }
01943 
01944 static int ieee80211_set_wds_peer(struct wiphy *wiphy, struct net_device *dev,
01945                                   const u8 *addr)
01946 {
01947         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
01948 
01949         memcpy(&sdata->u.wds.remote_addr, addr, ETH_ALEN);
01950 
01951         return 0;
01952 }
01953 
01954 static void ieee80211_rfkill_poll(struct wiphy *wiphy)
01955 {
01956         struct ieee80211_local *local = wiphy_priv(wiphy);
01957 
01958         drv_rfkill_poll(local);
01959 }
01960 
01961 #ifdef CONFIG_NL80211_TESTMODE
01962 static int ieee80211_testmode_cmd(struct wiphy *wiphy, void *data, int len)
01963 {
01964         struct ieee80211_local *local = wiphy_priv(wiphy);
01965 
01966         if (!local->ops->testmode_cmd)
01967                 return -EOPNOTSUPP;
01968 
01969         return local->ops->testmode_cmd(&local->hw, data, len);
01970 }
01971 
01972 static int ieee80211_testmode_dump(struct wiphy *wiphy,
01973                                    struct sk_buff *skb,
01974                                    struct netlink_callback *cb,
01975                                    void *data, int len)
01976 {
01977         struct ieee80211_local *local = wiphy_priv(wiphy);
01978 
01979         if (!local->ops->testmode_dump)
01980                 return -EOPNOTSUPP;
01981 
01982         return local->ops->testmode_dump(&local->hw, skb, cb, data, len);
01983 }
01984 #endif
01985 
01986 int __ieee80211_request_smps(struct ieee80211_sub_if_data *sdata,
01987                              enum ieee80211_smps_mode smps_mode)
01988 {
01989         const u8 *ap;
01990         enum ieee80211_smps_mode old_req;
01991         int err;
01992 
01993         lockdep_assert_held(&sdata->u.mgd.mtx);
01994 
01995         old_req = sdata->u.mgd.req_smps;
01996         sdata->u.mgd.req_smps = smps_mode;
01997 
01998         if (old_req == smps_mode &&
01999             smps_mode != IEEE80211_SMPS_AUTOMATIC)
02000                 return 0;
02001 
02002         /*
02003          * If not associated, or current association is not an HT
02004          * association, there's no need to send an action frame.
02005          */
02006         if (!sdata->u.mgd.associated ||
02007             sdata->vif.bss_conf.channel_type == NL80211_CHAN_NO_HT) {
02008                 mutex_lock(&sdata->local->iflist_mtx);
02009                 ieee80211_recalc_smps(sdata->local);
02010                 mutex_unlock(&sdata->local->iflist_mtx);
02011                 return 0;
02012         }
02013 
02014         ap = sdata->u.mgd.associated->bssid;
02015 
02016         if (smps_mode == IEEE80211_SMPS_AUTOMATIC) {
02017                 if (sdata->u.mgd.powersave)
02018                         smps_mode = IEEE80211_SMPS_DYNAMIC;
02019                 else
02020                         smps_mode = IEEE80211_SMPS_OFF;
02021         }
02022 
02023         /* send SM PS frame to AP */
02024         err = ieee80211_send_smps_action(sdata, smps_mode,
02025                                          ap, ap);
02026         if (err)
02027                 sdata->u.mgd.req_smps = old_req;
02028 
02029         return err;
02030 }
02031 
02032 static int ieee80211_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
02033                                     bool enabled, int timeout)
02034 {
02035         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02036         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
02037 
02038         if (sdata->vif.type != NL80211_IFTYPE_STATION)
02039                 return -EOPNOTSUPP;
02040 
02041         if (!(local->hw.flags & IEEE80211_HW_SUPPORTS_PS))
02042                 return -EOPNOTSUPP;
02043 
02044         if (enabled == sdata->u.mgd.powersave &&
02045             timeout == local->dynamic_ps_forced_timeout)
02046                 return 0;
02047 
02048         sdata->u.mgd.powersave = enabled;
02049         local->dynamic_ps_forced_timeout = timeout;
02050 
02051         /* no change, but if automatic follow powersave */
02052         mutex_lock(&sdata->u.mgd.mtx);
02053         __ieee80211_request_smps(sdata, sdata->u.mgd.req_smps);
02054         mutex_unlock(&sdata->u.mgd.mtx);
02055 
02056         if (local->hw.flags & IEEE80211_HW_SUPPORTS_DYNAMIC_PS)
02057                 ieee80211_hw_config(local, IEEE80211_CONF_CHANGE_PS);
02058 
02059         ieee80211_recalc_ps(local, -1);
02060 
02061         return 0;
02062 }
02063 
02064 static int ieee80211_set_cqm_rssi_config(struct wiphy *wiphy,
02065                                          struct net_device *dev,
02066                                          s32 rssi_thold, u32 rssi_hyst)
02067 {
02068         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02069         struct ieee80211_vif *vif = &sdata->vif;
02070         struct ieee80211_bss_conf *bss_conf = &vif->bss_conf;
02071 
02072         if (rssi_thold == bss_conf->cqm_rssi_thold &&
02073             rssi_hyst == bss_conf->cqm_rssi_hyst)
02074                 return 0;
02075 
02076         bss_conf->cqm_rssi_thold = rssi_thold;
02077         bss_conf->cqm_rssi_hyst = rssi_hyst;
02078 
02079         /* tell the driver upon association, unless already associated */
02080         if (sdata->u.mgd.associated &&
02081             sdata->vif.driver_flags & IEEE80211_VIF_SUPPORTS_CQM_RSSI)
02082                 ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_CQM);
02083 
02084         return 0;
02085 }
02086 
02087 static int ieee80211_set_bitrate_mask(struct wiphy *wiphy,
02088                                       struct net_device *dev,
02089                                       const u8 *addr,
02090                                       const struct cfg80211_bitrate_mask *mask)
02091 {
02092         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02093         struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
02094         int i, ret;
02095 
02096         if (!ieee80211_sdata_running(sdata))
02097                 return -ENETDOWN;
02098 
02099         if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
02100                 ret = drv_set_bitrate_mask(local, sdata, mask);
02101                 if (ret)
02102                         return ret;
02103         }
02104 
02105         for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
02106                 sdata->rc_rateidx_mask[i] = mask->control[i].legacy;
02107                 memcpy(sdata->rc_rateidx_mcs_mask[i], mask->control[i].mcs,
02108                        sizeof(mask->control[i].mcs));
02109         }
02110 
02111         return 0;
02112 }
02113 
02114 static int ieee80211_remain_on_channel_hw(struct ieee80211_local *local,
02115                                           struct net_device *dev,
02116                                           struct ieee80211_channel *chan,
02117                                           enum nl80211_channel_type chantype,
02118                                           unsigned int duration, u64 *cookie)
02119 {
02120         int ret;
02121         u32 random_cookie;
02122 
02123         lockdep_assert_held(&local->mtx);
02124 
02125         if (local->hw_roc_cookie)
02126                 return -EBUSY;
02127         /* must be nonzero */
02128         random_cookie = random32() | 1;
02129 
02130         *cookie = random_cookie;
02131         local->hw_roc_dev = dev;
02132         local->hw_roc_cookie = random_cookie;
02133         local->hw_roc_channel = chan;
02134         local->hw_roc_channel_type = chantype;
02135         local->hw_roc_duration = duration;
02136         ret = drv_remain_on_channel(local, chan, chantype, duration);
02137         if (ret) {
02138                 local->hw_roc_channel = NULL;
02139                 local->hw_roc_cookie = 0;
02140         }
02141 
02142         return ret;
02143 }
02144 
02145 static int ieee80211_remain_on_channel(struct wiphy *wiphy,
02146                                        struct net_device *dev,
02147                                        struct ieee80211_channel *chan,
02148                                        enum nl80211_channel_type channel_type,
02149                                        unsigned int duration,
02150                                        u64 *cookie)
02151 {
02152         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02153         struct ieee80211_local *local = sdata->local;
02154 
02155         if (local->ops->remain_on_channel) {
02156                 int ret;
02157 
02158                 mutex_lock(&local->mtx);
02159                 ret = ieee80211_remain_on_channel_hw(local, dev,
02160                                                      chan, channel_type,
02161                                                      duration, cookie);
02162                 local->hw_roc_for_tx = false;
02163                 mutex_unlock(&local->mtx);
02164 
02165                 return ret;
02166         }
02167 
02168         return ieee80211_wk_remain_on_channel(sdata, chan, channel_type,
02169                                               duration, cookie);
02170 }
02171 
02172 static int ieee80211_cancel_remain_on_channel_hw(struct ieee80211_local *local,
02173                                                  u64 cookie)
02174 {
02175         int ret;
02176 
02177         lockdep_assert_held(&local->mtx);
02178 
02179         if (local->hw_roc_cookie != cookie)
02180                 return -ENOENT;
02181 
02182         ret = drv_cancel_remain_on_channel(local);
02183         if (ret)
02184                 return ret;
02185 
02186         local->hw_roc_cookie = 0;
02187         local->hw_roc_channel = NULL;
02188 
02189         ieee80211_recalc_idle(local);
02190 
02191         return 0;
02192 }
02193 
02194 static int ieee80211_cancel_remain_on_channel(struct wiphy *wiphy,
02195                                               struct net_device *dev,
02196                                               u64 cookie)
02197 {
02198         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02199         struct ieee80211_local *local = sdata->local;
02200 
02201         if (local->ops->cancel_remain_on_channel) {
02202                 int ret;
02203 
02204                 mutex_lock(&local->mtx);
02205                 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
02206                 mutex_unlock(&local->mtx);
02207 
02208                 return ret;
02209         }
02210 
02211         return ieee80211_wk_cancel_remain_on_channel(sdata, cookie);
02212 }
02213 
02214 static enum work_done_result
02215 ieee80211_offchan_tx_done(struct ieee80211_work *wk, struct sk_buff *skb)
02216 {
02217         /*
02218          * Use the data embedded in the work struct for reporting
02219          * here so if the driver mangled the SKB before dropping
02220          * it (which is the only way we really should get here)
02221          * then we don't report mangled data.
02222          *
02223          * If there was no wait time, then by the time we get here
02224          * the driver will likely not have reported the status yet,
02225          * so in that case userspace will have to deal with it.
02226          */
02227 
02228         if (wk->offchan_tx.wait && !wk->offchan_tx.status)
02229                 cfg80211_mgmt_tx_status(wk->sdata->dev,
02230                                         (unsigned long) wk->offchan_tx.frame,
02231                                         wk->data, wk->data_len, false, GFP_KERNEL);
02232 
02233         return WORK_DONE_DESTROY;
02234 }
02235 
02236 static int ieee80211_mgmt_tx(struct wiphy *wiphy, struct net_device *dev,
02237                              struct ieee80211_channel *chan, bool offchan,
02238                              enum nl80211_channel_type channel_type,
02239                              bool channel_type_valid, unsigned int wait,
02240                              const u8 *buf, size_t len, bool no_cck,
02241                              bool dont_wait_for_ack, u64 *cookie)
02242 {
02243         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02244         struct ieee80211_local *local = sdata->local;
02245         struct sk_buff *skb;
02246         struct sta_info *sta;
02247         struct ieee80211_work *wk;
02248         const struct ieee80211_mgmt *mgmt = (void *)buf;
02249         u32 flags;
02250         bool is_offchan = false;
02251 
02252         if (dont_wait_for_ack)
02253                 flags = IEEE80211_TX_CTL_NO_ACK;
02254         else
02255                 flags = IEEE80211_TX_INTFL_NL80211_FRAME_TX |
02256                         IEEE80211_TX_CTL_REQ_TX_STATUS;
02257 
02258         /* Check that we are on the requested channel for transmission */
02259         if (chan != local->tmp_channel &&
02260             chan != local->oper_channel)
02261                 is_offchan = true;
02262         if (channel_type_valid &&
02263             (channel_type != local->tmp_channel_type &&
02264              channel_type != local->_oper_channel_type))
02265                 is_offchan = true;
02266 
02267         if (chan == local->hw_roc_channel) {
02268                 /* TODO: check channel type? */
02269                 is_offchan = false;
02270                 flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
02271         }
02272 
02273         if (no_cck)
02274                 flags |= IEEE80211_TX_CTL_NO_CCK_RATE;
02275 
02276         if (is_offchan && !offchan)
02277                 return -EBUSY;
02278 
02279         switch (sdata->vif.type) {
02280         case NL80211_IFTYPE_ADHOC:
02281         case NL80211_IFTYPE_AP:
02282         case NL80211_IFTYPE_AP_VLAN:
02283         case NL80211_IFTYPE_P2P_GO:
02284         case NL80211_IFTYPE_MESH_POINT:
02285                 if (!ieee80211_is_action(mgmt->frame_control) ||
02286                     mgmt->u.action.category == WLAN_CATEGORY_PUBLIC)
02287                         break;
02288                 rcu_read_lock();
02289                 sta = sta_info_get(sdata, mgmt->da);
02290                 rcu_read_unlock();
02291                 if (!sta)
02292                         return -ENOLINK;
02293                 break;
02294         case NL80211_IFTYPE_STATION:
02295         case NL80211_IFTYPE_P2P_CLIENT:
02296                 break;
02297         default:
02298                 return -EOPNOTSUPP;
02299         }
02300 
02301         skb = dev_alloc_skb(local->hw.extra_tx_headroom + len);
02302         if (!skb)
02303                 return -ENOMEM;
02304         skb_reserve(skb, local->hw.extra_tx_headroom);
02305 
02306         memcpy(skb_put(skb, len), buf, len);
02307 
02308         IEEE80211_SKB_CB(skb)->flags = flags;
02309 
02310         if (flags & IEEE80211_TX_CTL_TX_OFFCHAN)
02311                 IEEE80211_SKB_CB(skb)->hw_queue =
02312                         local->hw.offchannel_tx_hw_queue;
02313 
02314         skb->dev = sdata->dev;
02315 
02316         *cookie = (unsigned long) skb;
02317 
02318         if (is_offchan && local->ops->remain_on_channel) {
02319                 unsigned int duration;
02320                 int ret;
02321 
02322                 mutex_lock(&local->mtx);
02323                 /*
02324                  * If the duration is zero, then the driver
02325                  * wouldn't actually do anything. Set it to
02326                  * 100 for now.
02327                  *
02328                  * TODO: cancel the off-channel operation
02329                  *       when we get the SKB's TX status and
02330                  *       the wait time was zero before.
02331                  */
02332                 duration = 100;
02333                 if (wait)
02334                         duration = wait;
02335                 ret = ieee80211_remain_on_channel_hw(local, dev, chan,
02336                                                      channel_type,
02337                                                      duration, cookie);
02338                 if (ret) {
02339                         kfree_skb(skb);
02340                         mutex_unlock(&local->mtx);
02341                         return ret;
02342                 }
02343 
02344                 local->hw_roc_for_tx = true;
02345                 local->hw_roc_duration = wait;
02346 
02347                 /*
02348                  * queue up frame for transmission after
02349                  * ieee80211_ready_on_channel call
02350                  */
02351 
02352                 /* modify cookie to prevent API mismatches */
02353                 *cookie ^= 2;
02354                 IEEE80211_SKB_CB(skb)->flags |= IEEE80211_TX_CTL_TX_OFFCHAN;
02355                 IEEE80211_SKB_CB(skb)->hw_queue =
02356                         local->hw.offchannel_tx_hw_queue;
02357                 local->hw_roc_skb = skb;
02358                 local->hw_roc_skb_for_status = skb;
02359                 mutex_unlock(&local->mtx);
02360 
02361                 return 0;
02362         }
02363 
02364         /*
02365          * Can transmit right away if the channel was the
02366          * right one and there's no wait involved... If a
02367          * wait is involved, we might otherwise not be on
02368          * the right channel for long enough!
02369          */
02370         if (!is_offchan && !wait && !sdata->vif.bss_conf.idle) {
02371                 ieee80211_tx_skb(sdata, skb);
02372                 return 0;
02373         }
02374 
02375         wk = kzalloc(sizeof(*wk) + len, GFP_KERNEL);
02376         if (!wk) {
02377                 kfree_skb(skb);
02378                 return -ENOMEM;
02379         }
02380 
02381         wk->type = IEEE80211_WORK_OFFCHANNEL_TX;
02382         wk->chan = chan;
02383         wk->chan_type = channel_type;
02384         wk->sdata = sdata;
02385         wk->done = ieee80211_offchan_tx_done;
02386         wk->offchan_tx.frame = skb;
02387         wk->offchan_tx.wait = wait;
02388         wk->data_len = len;
02389         memcpy(wk->data, buf, len);
02390 
02391         ieee80211_add_work(wk);
02392         return 0;
02393 }
02394 
02395 static int ieee80211_mgmt_tx_cancel_wait(struct wiphy *wiphy,
02396                                          struct net_device *dev,
02397                                          u64 cookie)
02398 {
02399         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02400         struct ieee80211_local *local = sdata->local;
02401         struct ieee80211_work *wk;
02402         int ret = -ENOENT;
02403 
02404         mutex_lock(&local->mtx);
02405 
02406         if (local->ops->cancel_remain_on_channel) {
02407                 cookie ^= 2;
02408                 ret = ieee80211_cancel_remain_on_channel_hw(local, cookie);
02409 
02410                 if (ret == 0) {
02411                         kfree_skb(local->hw_roc_skb);
02412                         local->hw_roc_skb = NULL;
02413                         local->hw_roc_skb_for_status = NULL;
02414                 }
02415 
02416                 mutex_unlock(&local->mtx);
02417 
02418                 return ret;
02419         }
02420 
02421         list_for_each_entry(wk, &local->work_list, list) {
02422                 if (wk->sdata != sdata)
02423                         continue;
02424 
02425                 if (wk->type != IEEE80211_WORK_OFFCHANNEL_TX)
02426                         continue;
02427 
02428                 if (cookie != (unsigned long) wk->offchan_tx.frame)
02429                         continue;
02430 
02431                 wk->timeout = jiffies;
02432 
02433                 ieee80211_queue_work(&local->hw, &local->work_work);
02434                 ret = 0;
02435                 break;
02436         }
02437         mutex_unlock(&local->mtx);
02438 
02439         return ret;
02440 }
02441 
02442 static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
02443                                           struct net_device *dev,
02444                                           u16 frame_type, bool reg)
02445 {
02446         struct ieee80211_local *local = wiphy_priv(wiphy);
02447 
02448         if (frame_type != (IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_REQ))
02449                 return;
02450 
02451         if (reg)
02452                 local->probe_req_reg++;
02453         else
02454                 local->probe_req_reg--;
02455 
02456         ieee80211_queue_work(&local->hw, &local->reconfig_filter);
02457 }
02458 
02459 static int ieee80211_set_antenna(struct wiphy *wiphy, u32 tx_ant, u32 rx_ant)
02460 {
02461         struct ieee80211_local *local = wiphy_priv(wiphy);
02462 
02463         if (local->started)
02464                 return -EOPNOTSUPP;
02465 
02466         return drv_set_antenna(local, tx_ant, rx_ant);
02467 }
02468 
02469 static int ieee80211_get_antenna(struct wiphy *wiphy, u32 *tx_ant, u32 *rx_ant)
02470 {
02471         struct ieee80211_local *local = wiphy_priv(wiphy);
02472 
02473         return drv_get_antenna(local, tx_ant, rx_ant);
02474 }
02475 
02476 static int ieee80211_set_ringparam(struct wiphy *wiphy, u32 tx, u32 rx)
02477 {
02478         struct ieee80211_local *local = wiphy_priv(wiphy);
02479 
02480         return drv_set_ringparam(local, tx, rx);
02481 }
02482 
02483 static void ieee80211_get_ringparam(struct wiphy *wiphy,
02484                                     u32 *tx, u32 *tx_max, u32 *rx, u32 *rx_max)
02485 {
02486         struct ieee80211_local *local = wiphy_priv(wiphy);
02487 
02488         drv_get_ringparam(local, tx, tx_max, rx, rx_max);
02489 }
02490 
02491 static int ieee80211_set_rekey_data(struct wiphy *wiphy,
02492                                     struct net_device *dev,
02493                                     struct cfg80211_gtk_rekey_data *data)
02494 {
02495         struct ieee80211_local *local = wiphy_priv(wiphy);
02496         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02497 
02498         if (!local->ops->set_rekey_data)
02499                 return -EOPNOTSUPP;
02500 
02501         drv_set_rekey_data(local, sdata, data);
02502 
02503         return 0;
02504 }
02505 
02506 static void ieee80211_tdls_add_ext_capab(struct sk_buff *skb)
02507 {
02508         u8 *pos = (void *)skb_put(skb, 7);
02509 
02510         *pos++ = WLAN_EID_EXT_CAPABILITY;
02511         *pos++ = 5; /* len */
02512         *pos++ = 0x0;
02513         *pos++ = 0x0;
02514         *pos++ = 0x0;
02515         *pos++ = 0x0;
02516         *pos++ = WLAN_EXT_CAPA5_TDLS_ENABLED;
02517 }
02518 
02519 static u16 ieee80211_get_tdls_sta_capab(struct ieee80211_sub_if_data *sdata)
02520 {
02521         struct ieee80211_local *local = sdata->local;
02522         u16 capab;
02523 
02524         capab = 0;
02525         if (local->oper_channel->band != IEEE80211_BAND_2GHZ)
02526                 return capab;
02527 
02528         if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE))
02529                 capab |= WLAN_CAPABILITY_SHORT_SLOT_TIME;
02530         if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_PREAMBLE_INCAPABLE))
02531                 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE;
02532 
02533         return capab;
02534 }
02535 
02536 static void ieee80211_tdls_add_link_ie(struct sk_buff *skb, u8 *src_addr,
02537                                        u8 *peer, u8 *bssid)
02538 {
02539         struct ieee80211_tdls_lnkie *lnkid;
02540 
02541         lnkid = (void *)skb_put(skb, sizeof(struct ieee80211_tdls_lnkie));
02542 
02543         lnkid->ie_type = WLAN_EID_LINK_ID;
02544         lnkid->ie_len = sizeof(struct ieee80211_tdls_lnkie) - 2;
02545 
02546         memcpy(lnkid->bssid, bssid, ETH_ALEN);
02547         memcpy(lnkid->init_sta, src_addr, ETH_ALEN);
02548         memcpy(lnkid->resp_sta, peer, ETH_ALEN);
02549 }
02550 
02551 static int
02552 ieee80211_prep_tdls_encap_data(struct wiphy *wiphy, struct net_device *dev,
02553                                u8 *peer, u8 action_code, u8 dialog_token,
02554                                u16 status_code, struct sk_buff *skb)
02555 {
02556         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02557         struct ieee80211_tdls_data *tf;
02558 
02559         tf = (void *)skb_put(skb, offsetof(struct ieee80211_tdls_data, u));
02560 
02561         memcpy(tf->da, peer, ETH_ALEN);
02562         memcpy(tf->sa, sdata->vif.addr, ETH_ALEN);
02563         tf->ether_type = cpu_to_be16(ETH_P_TDLS);
02564         tf->payload_type = WLAN_TDLS_SNAP_RFTYPE;
02565 
02566         switch (action_code) {
02567         case WLAN_TDLS_SETUP_REQUEST:
02568                 tf->category = WLAN_CATEGORY_TDLS;
02569                 tf->action_code = WLAN_TDLS_SETUP_REQUEST;
02570 
02571                 skb_put(skb, sizeof(tf->u.setup_req));
02572                 tf->u.setup_req.dialog_token = dialog_token;
02573                 tf->u.setup_req.capability =
02574                         cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
02575 
02576                 ieee80211_add_srates_ie(&sdata->vif, skb, false);
02577                 ieee80211_add_ext_srates_ie(&sdata->vif, skb, false);
02578                 ieee80211_tdls_add_ext_capab(skb);
02579                 break;
02580         case WLAN_TDLS_SETUP_RESPONSE:
02581                 tf->category = WLAN_CATEGORY_TDLS;
02582                 tf->action_code = WLAN_TDLS_SETUP_RESPONSE;
02583 
02584                 skb_put(skb, sizeof(tf->u.setup_resp));
02585                 tf->u.setup_resp.status_code = cpu_to_le16(status_code);
02586                 tf->u.setup_resp.dialog_token = dialog_token;
02587                 tf->u.setup_resp.capability =
02588                         cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
02589 
02590                 ieee80211_add_srates_ie(&sdata->vif, skb, false);
02591                 ieee80211_add_ext_srates_ie(&sdata->vif, skb, false);
02592                 ieee80211_tdls_add_ext_capab(skb);
02593                 break;
02594         case WLAN_TDLS_SETUP_CONFIRM:
02595                 tf->category = WLAN_CATEGORY_TDLS;
02596                 tf->action_code = WLAN_TDLS_SETUP_CONFIRM;
02597 
02598                 skb_put(skb, sizeof(tf->u.setup_cfm));
02599                 tf->u.setup_cfm.status_code = cpu_to_le16(status_code);
02600                 tf->u.setup_cfm.dialog_token = dialog_token;
02601                 break;
02602         case WLAN_TDLS_TEARDOWN:
02603                 tf->category = WLAN_CATEGORY_TDLS;
02604                 tf->action_code = WLAN_TDLS_TEARDOWN;
02605 
02606                 skb_put(skb, sizeof(tf->u.teardown));
02607                 tf->u.teardown.reason_code = cpu_to_le16(status_code);
02608                 break;
02609         case WLAN_TDLS_DISCOVERY_REQUEST:
02610                 tf->category = WLAN_CATEGORY_TDLS;
02611                 tf->action_code = WLAN_TDLS_DISCOVERY_REQUEST;
02612 
02613                 skb_put(skb, sizeof(tf->u.discover_req));
02614                 tf->u.discover_req.dialog_token = dialog_token;
02615                 break;
02616         default:
02617                 return -EINVAL;
02618         }
02619 
02620         return 0;
02621 }
02622 
02623 static int
02624 ieee80211_prep_tdls_direct(struct wiphy *wiphy, struct net_device *dev,
02625                            u8 *peer, u8 action_code, u8 dialog_token,
02626                            u16 status_code, struct sk_buff *skb)
02627 {
02628         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02629         struct ieee80211_mgmt *mgmt;
02630 
02631         mgmt = (void *)skb_put(skb, 24);
02632         memset(mgmt, 0, 24);
02633         memcpy(mgmt->da, peer, ETH_ALEN);
02634         memcpy(mgmt->sa, sdata->vif.addr, ETH_ALEN);
02635         memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN);
02636 
02637         mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
02638                                           IEEE80211_STYPE_ACTION);
02639 
02640         switch (action_code) {
02641         case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
02642                 skb_put(skb, 1 + sizeof(mgmt->u.action.u.tdls_discover_resp));
02643                 mgmt->u.action.category = WLAN_CATEGORY_PUBLIC;
02644                 mgmt->u.action.u.tdls_discover_resp.action_code =
02645                         WLAN_PUB_ACTION_TDLS_DISCOVER_RES;
02646                 mgmt->u.action.u.tdls_discover_resp.dialog_token =
02647                         dialog_token;
02648                 mgmt->u.action.u.tdls_discover_resp.capability =
02649                         cpu_to_le16(ieee80211_get_tdls_sta_capab(sdata));
02650 
02651                 ieee80211_add_srates_ie(&sdata->vif, skb, false);
02652                 ieee80211_add_ext_srates_ie(&sdata->vif, skb, false);
02653                 ieee80211_tdls_add_ext_capab(skb);
02654                 break;
02655         default:
02656                 return -EINVAL;
02657         }
02658 
02659         return 0;
02660 }
02661 
02662 static int ieee80211_tdls_mgmt(struct wiphy *wiphy, struct net_device *dev,
02663                                u8 *peer, u8 action_code, u8 dialog_token,
02664                                u16 status_code, const u8 *extra_ies,
02665                                size_t extra_ies_len)
02666 {
02667         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02668         struct ieee80211_local *local = sdata->local;
02669         struct ieee80211_tx_info *info;
02670         struct sk_buff *skb = NULL;
02671         bool send_direct;
02672         int ret;
02673 
02674         if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
02675                 return -ENOTSUPP;
02676 
02677         /* make sure we are in managed mode, and associated */
02678         if (sdata->vif.type != NL80211_IFTYPE_STATION ||
02679             !sdata->u.mgd.associated)
02680                 return -EINVAL;
02681 
02682 #ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
02683         printk(KERN_DEBUG "TDLS mgmt action %d peer %pM\n", action_code, peer);
02684 #endif
02685 
02686         skb = dev_alloc_skb(local->hw.extra_tx_headroom +
02687                             max(sizeof(struct ieee80211_mgmt),
02688                                 sizeof(struct ieee80211_tdls_data)) +
02689                             50 + /* supported rates */
02690                             7 + /* ext capab */
02691                             extra_ies_len +
02692                             sizeof(struct ieee80211_tdls_lnkie));
02693         if (!skb)
02694                 return -ENOMEM;
02695 
02696         info = IEEE80211_SKB_CB(skb);
02697         skb_reserve(skb, local->hw.extra_tx_headroom);
02698 
02699         switch (action_code) {
02700         case WLAN_TDLS_SETUP_REQUEST:
02701         case WLAN_TDLS_SETUP_RESPONSE:
02702         case WLAN_TDLS_SETUP_CONFIRM:
02703         case WLAN_TDLS_TEARDOWN:
02704         case WLAN_TDLS_DISCOVERY_REQUEST:
02705                 ret = ieee80211_prep_tdls_encap_data(wiphy, dev, peer,
02706                                                      action_code, dialog_token,
02707                                                      status_code, skb);
02708                 send_direct = false;
02709                 break;
02710         case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
02711                 ret = ieee80211_prep_tdls_direct(wiphy, dev, peer, action_code,
02712                                                  dialog_token, status_code,
02713                                                  skb);
02714                 send_direct = true;
02715                 break;
02716         default:
02717                 ret = -ENOTSUPP;
02718                 break;
02719         }
02720 
02721         if (ret < 0)
02722                 goto fail;
02723 
02724         if (extra_ies_len)
02725                 memcpy(skb_put(skb, extra_ies_len), extra_ies, extra_ies_len);
02726 
02727         /* the TDLS link IE is always added last */
02728         switch (action_code) {
02729         case WLAN_TDLS_SETUP_REQUEST:
02730         case WLAN_TDLS_SETUP_CONFIRM:
02731         case WLAN_TDLS_TEARDOWN:
02732         case WLAN_TDLS_DISCOVERY_REQUEST:
02733                 /* we are the initiator */
02734                 ieee80211_tdls_add_link_ie(skb, sdata->vif.addr, peer,
02735                                            sdata->u.mgd.bssid);
02736                 break;
02737         case WLAN_TDLS_SETUP_RESPONSE:
02738         case WLAN_PUB_ACTION_TDLS_DISCOVER_RES:
02739                 /* we are the responder */
02740                 ieee80211_tdls_add_link_ie(skb, peer, sdata->vif.addr,
02741                                            sdata->u.mgd.bssid);
02742                 break;
02743         default:
02744                 ret = -ENOTSUPP;
02745                 goto fail;
02746         }
02747 
02748         if (send_direct) {
02749                 ieee80211_tx_skb(sdata, skb);
02750                 return 0;
02751         }
02752 
02753         /*
02754          * According to 802.11z: Setup req/resp are sent in AC_BK, otherwise
02755          * we should default to AC_VI.
02756          */
02757         switch (action_code) {
02758         case WLAN_TDLS_SETUP_REQUEST:
02759         case WLAN_TDLS_SETUP_RESPONSE:
02760                 skb_set_queue_mapping(skb, IEEE80211_AC_BK);
02761                 skb->priority = 2;
02762                 break;
02763         default:
02764                 skb_set_queue_mapping(skb, IEEE80211_AC_VI);
02765                 skb->priority = 5;
02766                 break;
02767         }
02768 
02769         /* disable bottom halves when entering the Tx path */
02770         local_bh_disable();
02771         ret = ieee80211_subif_start_xmit(skb, dev);
02772         local_bh_enable();
02773 
02774         return ret;
02775 
02776 fail:
02777         dev_kfree_skb(skb);
02778         return ret;
02779 }
02780 
02781 static int ieee80211_tdls_oper(struct wiphy *wiphy, struct net_device *dev,
02782                                u8 *peer, enum nl80211_tdls_operation oper)
02783 {
02784         struct sta_info *sta;
02785         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02786 
02787         if (!(wiphy->flags & WIPHY_FLAG_SUPPORTS_TDLS))
02788                 return -ENOTSUPP;
02789 
02790         if (sdata->vif.type != NL80211_IFTYPE_STATION)
02791                 return -EINVAL;
02792 
02793 #ifdef CONFIG_MAC80211_VERBOSE_TDLS_DEBUG
02794         printk(KERN_DEBUG "TDLS oper %d peer %pM\n", oper, peer);
02795 #endif
02796 
02797         switch (oper) {
02798         case NL80211_TDLS_ENABLE_LINK:
02799                 rcu_read_lock();
02800                 sta = sta_info_get(sdata, peer);
02801                 if (!sta) {
02802                         rcu_read_unlock();
02803                         return -ENOLINK;
02804                 }
02805 
02806                 set_sta_flag(sta, WLAN_STA_TDLS_PEER_AUTH);
02807                 rcu_read_unlock();
02808                 break;
02809         case NL80211_TDLS_DISABLE_LINK:
02810                 return sta_info_destroy_addr(sdata, peer);
02811         case NL80211_TDLS_TEARDOWN:
02812         case NL80211_TDLS_SETUP:
02813         case NL80211_TDLS_DISCOVERY_REQ:
02814                 /* We don't support in-driver setup/teardown/discovery */
02815                 return -ENOTSUPP;
02816         default:
02817                 return -ENOTSUPP;
02818         }
02819 
02820         return 0;
02821 }
02822 
02823 static int ieee80211_probe_client(struct wiphy *wiphy, struct net_device *dev,
02824                                   const u8 *peer, u64 *cookie)
02825 {
02826         struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
02827         struct ieee80211_local *local = sdata->local;
02828         struct ieee80211_qos_hdr *nullfunc;
02829         struct sk_buff *skb;
02830         int size = sizeof(*nullfunc);
02831         __le16 fc;
02832         bool qos;
02833         struct ieee80211_tx_info *info;
02834         struct sta_info *sta;
02835 
02836         rcu_read_lock();
02837         sta = sta_info_get(sdata, peer);
02838         if (sta) {
02839                 qos = test_sta_flag(sta, WLAN_STA_WME);
02840                 rcu_read_unlock();
02841         } else {
02842                 rcu_read_unlock();
02843                 return -ENOLINK;
02844         }
02845 
02846         if (qos) {
02847                 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
02848                                  IEEE80211_STYPE_QOS_NULLFUNC |
02849                                  IEEE80211_FCTL_FROMDS);
02850         } else {
02851                 size -= 2;
02852                 fc = cpu_to_le16(IEEE80211_FTYPE_DATA |
02853                                  IEEE80211_STYPE_NULLFUNC |
02854                                  IEEE80211_FCTL_FROMDS);
02855         }
02856 
02857         skb = dev_alloc_skb(local->hw.extra_tx_headroom + size);
02858         if (!skb)
02859                 return -ENOMEM;
02860 
02861         skb->dev = dev;
02862 
02863         skb_reserve(skb, local->hw.extra_tx_headroom);
02864 
02865         nullfunc = (void *) skb_put(skb, size);
02866         nullfunc->frame_control = fc;
02867         nullfunc->duration_id = 0;
02868         memcpy(nullfunc->addr1, sta->sta.addr, ETH_ALEN);
02869         memcpy(nullfunc->addr2, sdata->vif.addr, ETH_ALEN);
02870         memcpy(nullfunc->addr3, sdata->vif.addr, ETH_ALEN);
02871         nullfunc->seq_ctrl = 0;
02872 
02873         info = IEEE80211_SKB_CB(skb);
02874 
02875         info->flags |= IEEE80211_TX_CTL_REQ_TX_STATUS |
02876                        IEEE80211_TX_INTFL_NL80211_FRAME_TX;
02877 
02878         skb_set_queue_mapping(skb, IEEE80211_AC_VO);
02879         skb->priority = 7;
02880         if (qos)
02881                 nullfunc->qos_ctrl = cpu_to_le16(7);
02882 
02883         local_bh_disable();
02884         ieee80211_xmit(sdata, skb);
02885         local_bh_enable();
02886 
02887         *cookie = (unsigned long) skb;
02888         return 0;
02889 }
02890 
02891 static struct ieee80211_channel *
02892 ieee80211_wiphy_get_channel(struct wiphy *wiphy,
02893                             enum nl80211_channel_type *type)
02894 {
02895         struct ieee80211_local *local = wiphy_priv(wiphy);
02896 
02897         *type = local->_oper_channel_type;
02898         return local->oper_channel;
02899 }
02900 
02901 #ifdef CONFIG_PM
02902 static void ieee80211_set_wakeup(struct wiphy *wiphy, bool enabled)
02903 {
02904         drv_set_wakeup(wiphy_priv(wiphy), enabled);
02905 }
02906 #endif
02907 
02908 struct cfg80211_ops mac80211_config_ops = {
02909         .add_virtual_intf = ieee80211_add_iface,
02910         .del_virtual_intf = ieee80211_del_iface,
02911         .change_virtual_intf = ieee80211_change_iface,
02912         .add_key = ieee80211_add_key,
02913         .del_key = ieee80211_del_key,
02914         .get_key = ieee80211_get_key,
02915         .set_default_key = ieee80211_config_default_key,
02916         .set_default_mgmt_key = ieee80211_config_default_mgmt_key,
02917         .start_ap = ieee80211_start_ap,
02918         .change_beacon = ieee80211_change_beacon,
02919         .stop_ap = ieee80211_stop_ap,
02920         .add_station = ieee80211_add_station,
02921         .del_station = ieee80211_del_station,
02922         .change_station = ieee80211_change_station,
02923         .get_station = ieee80211_get_station,
02924         .dump_station = ieee80211_dump_station,
02925         .dump_survey = ieee80211_dump_survey,
02926 #ifdef CONFIG_MAC80211_MESH
02927         .add_mpath = ieee80211_add_mpath,
02928         .del_mpath = ieee80211_del_mpath,
02929         .change_mpath = ieee80211_change_mpath,
02930         .get_mpath = ieee80211_get_mpath,
02931         .dump_mpath = ieee80211_dump_mpath,
02932         .update_mesh_config = ieee80211_update_mesh_config,
02933         .get_mesh_config = ieee80211_get_mesh_config,
02934         .join_mesh = ieee80211_join_mesh,
02935         .leave_mesh = ieee80211_leave_mesh,
02936 #endif
02937         .change_bss = ieee80211_change_bss,
02938         .set_txq_params = ieee80211_set_txq_params,
02939         .set_channel = ieee80211_set_channel,
02940         .suspend = ieee80211_suspend,
02941         .resume = ieee80211_resume,
02942         .scan = ieee80211_scan,
02943         .sched_scan_start = ieee80211_sched_scan_start,
02944         .sched_scan_stop = ieee80211_sched_scan_stop,
02945         .auth = ieee80211_auth,
02946         .assoc = ieee80211_assoc,
02947         .deauth = ieee80211_deauth,
02948         .disassoc = ieee80211_disassoc,
02949         .join_ibss = ieee80211_join_ibss,
02950         .leave_ibss = ieee80211_leave_ibss,
02951         .set_wiphy_params = ieee80211_set_wiphy_params,
02952         .set_tx_power = ieee80211_set_tx_power,
02953         .get_tx_power = ieee80211_get_tx_power,
02954         .set_wds_peer = ieee80211_set_wds_peer,
02955         .rfkill_poll = ieee80211_rfkill_poll,
02956         CFG80211_TESTMODE_CMD(ieee80211_testmode_cmd)
02957         CFG80211_TESTMODE_DUMP(ieee80211_testmode_dump)
02958         .set_power_mgmt = ieee80211_set_power_mgmt,
02959         .set_bitrate_mask = ieee80211_set_bitrate_mask,
02960         .remain_on_channel = ieee80211_remain_on_channel,
02961         .cancel_remain_on_channel = ieee80211_cancel_remain_on_channel,
02962         .mgmt_tx = ieee80211_mgmt_tx,
02963         .mgmt_tx_cancel_wait = ieee80211_mgmt_tx_cancel_wait,
02964         .set_cqm_rssi_config = ieee80211_set_cqm_rssi_config,
02965         .mgmt_frame_register = ieee80211_mgmt_frame_register,
02966         .set_antenna = ieee80211_set_antenna,
02967         .get_antenna = ieee80211_get_antenna,
02968         .set_ringparam = ieee80211_set_ringparam,
02969         .get_ringparam = ieee80211_get_ringparam,
02970         .set_rekey_data = ieee80211_set_rekey_data,
02971         .tdls_oper = ieee80211_tdls_oper,
02972         .tdls_mgmt = ieee80211_tdls_mgmt,
02973         .probe_client = ieee80211_probe_client,
02974         .get_channel = ieee80211_wiphy_get_channel,
02975         .set_noack_map = ieee80211_set_noack_map,
02976 #ifdef CONFIG_PM
02977         .set_wakeup = ieee80211_set_wakeup,
02978 #endif
02979         .get_et_sset_count = ieee80211_get_et_sset_count,
02980         .get_et_stats = ieee80211_get_et_stats,
02981         .get_et_strings = ieee80211_get_et_strings,
02982 };


ros_rt_wmp
Author(s): Danilo Tardioli, dantard@unizar.es
autogenerated on Mon Oct 6 2014 08:27:09