Merge tag 'mac80211-next-for-john-2014-11-04' of git://git.kernel.org/pub/scm/linux...
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / mwifiex / cfg80211.c
index 0dd672954ad10316bec599a0f2eeb56b70e66c75..f63abfd8acd71433bc65fc7bf0eef75ece5d8653 100644 (file)
@@ -992,6 +992,52 @@ mwifiex_cfg80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
        return mwifiex_dump_station_info(priv, sinfo);
 }
 
+static int
+mwifiex_cfg80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
+                            int idx, struct survey_info *survey)
+{
+       struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
+       struct mwifiex_chan_stats *pchan_stats = priv->adapter->chan_stats;
+       enum ieee80211_band band;
+
+       dev_dbg(priv->adapter->dev, "dump_survey idx=%d\n", idx);
+
+       memset(survey, 0, sizeof(struct survey_info));
+
+       if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
+           priv->media_connected && idx == 0) {
+                       u8 curr_bss_band = priv->curr_bss_params.band;
+                       u32 chan = priv->curr_bss_params.bss_descriptor.channel;
+
+                       band = mwifiex_band_to_radio_type(curr_bss_band);
+                       survey->channel = ieee80211_get_channel(wiphy,
+                               ieee80211_channel_to_frequency(chan, band));
+
+                       if (priv->bcn_nf_last) {
+                               survey->filled = SURVEY_INFO_NOISE_DBM;
+                               survey->noise = priv->bcn_nf_last;
+                       }
+                       return 0;
+       }
+
+       if (idx >= priv->adapter->num_in_chan_stats)
+               return -ENOENT;
+
+       if (!pchan_stats[idx].cca_scan_dur)
+               return 0;
+
+       band = pchan_stats[idx].bandcfg;
+       survey->channel = ieee80211_get_channel(wiphy,
+           ieee80211_channel_to_frequency(pchan_stats[idx].chan_num, band));
+       survey->filled = SURVEY_INFO_NOISE_DBM |
+               SURVEY_INFO_CHANNEL_TIME | SURVEY_INFO_CHANNEL_TIME_BUSY;
+       survey->noise = pchan_stats[idx].noise;
+       survey->channel_time = pchan_stats[idx].cca_scan_dur;
+       survey->channel_time_busy = pchan_stats[idx].cca_busy_dur;
+
+       return 0;
+}
+
 /* Supported rates to be advertised to the cfg80211 */
 static struct ieee80211_rate mwifiex_rates[] = {
        {.bitrate = 10, .hw_value = 2, },
@@ -1239,7 +1285,7 @@ static int mwifiex_cfg80211_change_beacon(struct wiphy *wiphy,
  */
 static int
 mwifiex_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev,
-                            const u8 *mac)
+                            struct station_del_parameters *params)
 {
        struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
        struct mwifiex_sta_node *sta_node;
@@ -1248,7 +1294,7 @@ mwifiex_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev,
        if (list_empty(&priv->sta_list) || !priv->bss_started)
                return 0;
 
-       if (!mac || is_broadcast_ether_addr(mac)) {
+       if (!params->mac || is_broadcast_ether_addr(params->mac)) {
                wiphy_dbg(wiphy, "%s: NULL/broadcast mac address\n", __func__);
                list_for_each_entry(sta_node, &priv->sta_list, list) {
                        if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_STA_DEAUTH,
@@ -1258,9 +1304,10 @@ mwifiex_cfg80211_del_station(struct wiphy *wiphy, struct net_device *dev,
                        mwifiex_uap_del_sta_data(priv, sta_node);
                }
        } else {
-               wiphy_dbg(wiphy, "%s: mac address %pM\n", __func__, mac);
+               wiphy_dbg(wiphy, "%s: mac address %pM\n", __func__,
+                         params->mac);
                spin_lock_irqsave(&priv->sta_list_spinlock, flags);
-               sta_node = mwifiex_get_sta_entry(priv, mac);
+               sta_node = mwifiex_get_sta_entry(priv, params->mac);
                spin_unlock_irqrestore(&priv->sta_list_spinlock, flags);
                if (sta_node) {
                        if (mwifiex_send_cmd(priv, HostCmd_CMD_UAP_STA_DEAUTH,
@@ -2779,6 +2826,7 @@ static struct cfg80211_ops mwifiex_cfg80211_ops = {
        .disconnect = mwifiex_cfg80211_disconnect,
        .get_station = mwifiex_cfg80211_get_station,
        .dump_station = mwifiex_cfg80211_dump_station,
+       .dump_survey = mwifiex_cfg80211_dump_survey,
        .set_wiphy_params = mwifiex_cfg80211_set_wiphy_params,
        .join_ibss = mwifiex_cfg80211_join_ibss,
        .leave_ibss = mwifiex_cfg80211_leave_ibss,
@@ -2840,6 +2888,25 @@ static const struct wiphy_coalesce_support mwifiex_coalesce_support = {
        .max_pkt_offset = MWIFIEX_MAX_OFFSET_LEN,
 };
 
+int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter)
+{
+       u32 n_channels_bg, n_channels_a = 0;
+
+       n_channels_bg = mwifiex_band_2ghz.n_channels;
+
+       if (adapter->config_bands & BAND_A)
+               n_channels_a = mwifiex_band_5ghz.n_channels;
+
+       adapter->num_in_chan_stats = max_t(u32, n_channels_bg, n_channels_a);
+       adapter->chan_stats = vmalloc(sizeof(*adapter->chan_stats) *
+                                     adapter->num_in_chan_stats);
+
+       if (!adapter->chan_stats)
+               return -ENOMEM;
+
+       return 0;
+}
+
 /*
  * This function registers the device with CFG802.11 subsystem.
  *