mac80211: sample survey implementation for mac80211 & hwsim
authorHolger Schurig <holgerschurig@gmail.com>
Mon, 19 Apr 2010 08:23:57 +0000 (10:23 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 20 Apr 2010 15:50:52 +0000 (11:50 -0400)
This adds the survey function to both mac80211 itself and to mac80211_hwsim.
For the latter driver, we simply invent some noise level.A real driver which
cannot determine the real channel noise MUST NOT report any noise, especially
not a magically conjured one :-)

Signed-off-by: Holger Schurig <holgerschurig@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/mac80211_hwsim.c
include/net/mac80211.h
net/mac80211/cfg.c
net/mac80211/driver-ops.h

index ec8b082917904f761f890819b463ef5e34def0ec..79bb8833ddb941fa72e9dc34bd3a5ae5fba43e9a 100644 (file)
@@ -829,6 +829,33 @@ static int mac80211_hwsim_conf_tx(
        return 0;
 }
 
+static int mac80211_hwsim_get_survey(
+       struct ieee80211_hw *hw, int idx,
+       struct survey_info *survey)
+{
+       struct ieee80211_conf *conf = &hw->conf;
+
+       printk(KERN_DEBUG "%s:%s (idx=%d)\n",
+              wiphy_name(hw->wiphy), __func__, idx);
+
+       if (idx != 0)
+               return -ENOENT;
+
+       /* Current channel */
+       survey->channel = conf->channel;
+
+       /*
+        * Magically conjured noise level --- this is only ok for simulated hardware.
+        *
+        * A real driver which cannot determine the real channel noise MUST NOT
+        * report any noise, especially not a magically conjured one :-)
+        */
+       survey->filled = SURVEY_INFO_NOISE_DBM;
+       survey->noise = -92;
+
+       return 0;
+}
+
 #ifdef CONFIG_NL80211_TESTMODE
 /*
  * This section contains example code for using netlink
@@ -1012,6 +1039,7 @@ static struct ieee80211_ops mac80211_hwsim_ops =
        .sta_notify = mac80211_hwsim_sta_notify,
        .set_tim = mac80211_hwsim_set_tim,
        .conf_tx = mac80211_hwsim_conf_tx,
+       .get_survey = mac80211_hwsim_get_survey,
        CFG80211_TESTMODE_CMD(mac80211_hwsim_testmode_cmd)
        .ampdu_action = mac80211_hwsim_ampdu_action,
        .sw_scan_start = mac80211_hwsim_sw_scan,
index 63e9d37e3e71296e9c8b9f29ffdec52e4a0c321e..cd9915686dd985adb3a2584bde95c064df11c978 100644 (file)
@@ -1674,7 +1674,8 @@ struct ieee80211_ops {
                            struct ieee80211_vif *vif,
                            enum ieee80211_ampdu_mlme_action action,
                            struct ieee80211_sta *sta, u16 tid, u16 *ssn);
-
+       int (*get_survey)(struct ieee80211_hw *hw, int idx,
+               struct survey_info *survey);
        void (*rfkill_poll)(struct ieee80211_hw *hw);
        void (*set_coverage_class)(struct ieee80211_hw *hw, u8 coverage_class);
 #ifdef CONFIG_NL80211_TESTMODE
index 4edd73cbf0524172fe74a2b902093468b9cf43f6..f97dda735cbb2c531a35718f9a0e5cc53ef5b72d 100644 (file)
@@ -410,6 +410,17 @@ static int ieee80211_dump_station(struct wiphy *wiphy, struct net_device *dev,
        return ret;
 }
 
+static int ieee80211_dump_survey(struct wiphy *wiphy, struct net_device *dev,
+                                int idx, struct survey_info *survey)
+{
+       struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
+
+       if (!local->ops->get_survey)
+               return -EOPNOTSUPP;
+
+       return drv_get_survey(local, idx, survey);
+}
+
 static int ieee80211_get_station(struct wiphy *wiphy, struct net_device *dev,
                                 u8 *mac, struct station_info *sinfo)
 {
@@ -1507,6 +1518,7 @@ struct cfg80211_ops mac80211_config_ops = {
        .change_station = ieee80211_change_station,
        .get_station = ieee80211_get_station,
        .dump_station = ieee80211_dump_station,
+       .dump_survey = ieee80211_dump_survey,
 #ifdef CONFIG_MAC80211_MESH
        .add_mpath = ieee80211_add_mpath,
        .del_mpath = ieee80211_del_mpath,
index c3d844093a2f9203127f1cb10ee1f1d9b97a68ae..d1f8a7c2225a50ca2384391ec2cdeadc498420cc 100644 (file)
@@ -346,6 +346,15 @@ static inline int drv_ampdu_action(struct ieee80211_local *local,
        return ret;
 }
 
+static inline int drv_get_survey(struct ieee80211_local *local, int idx,
+                               struct survey_info *survey)
+{
+       int ret = -EOPNOTSUPP;
+       if (local->ops->conf_tx)
+               ret = local->ops->get_survey(&local->hw, idx, survey);
+       /* trace_drv_get_survey(local, idx, survey, ret); */
+       return ret;
+}
 
 static inline void drv_rfkill_poll(struct ieee80211_local *local)
 {