From patchwork Tue Nov 10 16:23:50 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Holger Schurig X-Patchwork-Id: 59091 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nAAGOUrK016208 for ; Tue, 10 Nov 2009 16:24:30 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756411AbZKJQYX (ORCPT ); Tue, 10 Nov 2009 11:24:23 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756388AbZKJQYX (ORCPT ); Tue, 10 Nov 2009 11:24:23 -0500 Received: from mx51.mymxserver.com ([85.199.173.110]:8763 "EHLO mx51.mymxserver.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756137AbZKJQYW (ORCPT ); Tue, 10 Nov 2009 11:24:22 -0500 Received: from localhost (localhost [127.0.0.1]) by localhost.mx51.mymxserver.com (Postfix) with ESMTP id E00275000A; Tue, 10 Nov 2009 17:24:27 +0100 (CET) X-Virus-Scanned: by Mittwald Mailscanner Received: from mx51.mymxserver.com ([127.0.0.1]) by localhost (mx51.mymxserver.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 862Y9aQ5-Q9a; Tue, 10 Nov 2009 17:24:27 +0100 (CET) Received: from lin01.mn-solutions.de (pD95F8B6C.dip0.t-ipconnect.de [217.95.139.108]) by mx51.mymxserver.com (Postfix) with ESMTP id A288150009; Tue, 10 Nov 2009 17:24:27 +0100 (CET) Received: by lin01.mn-solutions.de (Postfix, from userid 116) id 4C7E11E0050; Tue, 10 Nov 2009 17:24:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.1.7-deb3 (2006-10-05) on lin01.mn-logistik.de X-Spam-Level: X-Spam-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.7-deb3 Received: from schurig.mn-solutions.de (mnz66.mn-solutions.de [192.168.233.66]) by lin01.mn-solutions.de (Postfix) with ESMTP id 7D4B81E0010; Tue, 10 Nov 2009 17:24:23 +0100 (CET) From: Holger Schurig To: linux-wireless@vger.kernel.org Subject: [RFC] mac80211: sample survey implementation for mac80211_hwsim Date: Tue, 10 Nov 2009 17:23:50 +0100 User-Agent: KMail/1.9.7 Cc: Johannes Berg MIME-Version: 1.0 Content-Disposition: inline Message-Id: <200911101723.50859.holgerschurig@gmail.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org --- linux-wl.orig/include/net/mac80211.h +++ linux-wl/include/net/mac80211.h @@ -1507,7 +1507,8 @@ int (*ampdu_action)(struct ieee80211_hw *hw, 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); #ifdef CONFIG_NL80211_TESTMODE int (*testmode_cmd)(struct ieee80211_hw *hw, void *data, int len); --- linux-wl.orig/net/mac80211/cfg.c +++ linux-wl/net/mac80211/cfg.c @@ -395,6 +395,17 @@ 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) { @@ -1375,6 +1386,7 @@ .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, --- linux-wl.orig/net/mac80211/driver-ops.h +++ linux-wl/net/mac80211/driver-ops.h @@ -251,6 +251,15 @@ 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) { --- linux-wl.orig/drivers/net/wireless/mac80211_hwsim.c +++ linux-wl/drivers/net/wireless/mac80211_hwsim.c @@ -759,6 +759,28 @@ 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 */ + survey->filled = SURVEY_INFO_NOISE_DBM; + survey->noise = -92; + + return 0; +} + #ifdef CONFIG_NL80211_TESTMODE /* * This section contains example code for using netlink @@ -840,6 +862,7 @@ .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) };