Skip to content

Commit

Permalink
mac80211: introduce hw config change flags
Browse files Browse the repository at this point in the history
This makes mac80211 notify the driver which configuration
actually changed, e.g. channel etc.

No driver changes, this is just plumbing, driver authors are
expected to act on this if they want to.

Also remove the HW CONFIG debug printk, it's incorrect, often
we configure something else.

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Johannes Berg authored and John W. Linville committed Oct 31, 2008
1 parent 0f4ac38 commit e897558
Show file tree
Hide file tree
Showing 24 changed files with 116 additions and 60 deletions.
3 changes: 2 additions & 1 deletion drivers/net/wireless/adm8211.c
Original file line number Diff line number Diff line change
Expand Up @@ -1314,9 +1314,10 @@ static int adm8211_set_ssid(struct ieee80211_hw *dev, u8 *ssid, size_t ssid_len)
return 0;
}

static int adm8211_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
static int adm8211_config(struct ieee80211_hw *dev, u32 changed)
{
struct adm8211_priv *priv = dev->priv;
struct ieee80211_conf *conf = &dev->conf;
int channel = ieee80211_frequency_to_channel(conf->channel->center_freq);

if (channel != priv->channel) {
Expand Down
7 changes: 3 additions & 4 deletions drivers/net/wireless/ath5k/base.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ static int ath5k_add_interface(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf);
static void ath5k_remove_interface(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf);
static int ath5k_config(struct ieee80211_hw *hw,
struct ieee80211_conf *conf);
static int ath5k_config(struct ieee80211_hw *hw, u32 changed);
static int ath5k_config_interface(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf);
Expand Down Expand Up @@ -2780,10 +2779,10 @@ ath5k_remove_interface(struct ieee80211_hw *hw,
* TODO: Phy disable/diversity etc
*/
static int
ath5k_config(struct ieee80211_hw *hw,
struct ieee80211_conf *conf)
ath5k_config(struct ieee80211_hw *hw, u32 changed)
{
struct ath5k_softc *sc = hw->priv;
struct ieee80211_conf *conf = &hw->conf;

sc->bintval = conf->beacon_int;
sc->power_level = conf->power_level;
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/ath9k/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,11 +1230,11 @@ static void ath9k_remove_interface(struct ieee80211_hw *hw,
__func__, error);
}

static int ath9k_config(struct ieee80211_hw *hw,
struct ieee80211_conf *conf)
static int ath9k_config(struct ieee80211_hw *hw, u32 changed)
{
struct ath_softc *sc = hw->priv;
struct ieee80211_channel *curchan = hw->conf.channel;
struct ieee80211_conf *conf = &hw->conf;
int pos;

DPRINTF(sc, ATH_DBG_CONFIG, "%s: Set channel: %d MHz\n",
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/b43/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -3320,11 +3320,12 @@ static int b43_switch_band(struct b43_wl *wl, struct ieee80211_channel *chan)
return err;
}

static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
static int b43_op_config(struct ieee80211_hw *hw, u32 changed)
{
struct b43_wl *wl = hw_to_b43_wl(hw);
struct b43_wldev *dev;
struct b43_phy *phy;
struct ieee80211_conf *conf = &hw->conf;
unsigned long flags;
int antenna;
int err = 0;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/b43legacy/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2557,11 +2557,12 @@ static int b43legacy_switch_phymode(struct b43legacy_wl *wl,
}

static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
struct ieee80211_conf *conf)
u32 changed)
{
struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
struct b43legacy_wldev *dev;
struct b43legacy_phy *phy;
struct ieee80211_conf *conf = &hw->conf;
unsigned long flags;
unsigned int new_phymode = 0xFFFF;
int antenna_tx;
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/iwlwifi/iwl-agn.c
Original file line number Diff line number Diff line change
Expand Up @@ -2734,10 +2734,11 @@ static int iwl4965_mac_add_interface(struct ieee80211_hw *hw,
* be set inappropriately and the driver currently sets the hardware up to
* use it whenever needed.
*/
static int iwl4965_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
static int iwl4965_mac_config(struct ieee80211_hw *hw, u32 changed)
{
struct iwl_priv *priv = hw->priv;
const struct iwl_channel_info *ch_info;
struct ieee80211_conf *conf = &hw->conf;
unsigned long flags;
int ret = 0;
u16 channel;
Expand Down
7 changes: 4 additions & 3 deletions drivers/net/wireless/iwlwifi/iwl3945-base.c
Original file line number Diff line number Diff line change
Expand Up @@ -6415,7 +6415,7 @@ static void iwl3945_bg_abort_scan(struct work_struct *work)
mutex_unlock(&priv->mutex);
}

static int iwl3945_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed);

static void iwl3945_bg_scan_completed(struct work_struct *work)
{
Expand All @@ -6428,7 +6428,7 @@ static void iwl3945_bg_scan_completed(struct work_struct *work)
return;

if (test_bit(STATUS_CONF_PENDING, &priv->status))
iwl3945_mac_config(priv->hw, ieee80211_get_hw_conf(priv->hw));
iwl3945_mac_config(priv->hw, 0);

ieee80211_scan_completed(priv->hw);

Expand Down Expand Up @@ -6616,10 +6616,11 @@ static int iwl3945_mac_add_interface(struct ieee80211_hw *hw,
* be set inappropriately and the driver currently sets the hardware up to
* use it whenever needed.
*/
static int iwl3945_mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
static int iwl3945_mac_config(struct ieee80211_hw *hw, u32 changed)
{
struct iwl3945_priv *priv = hw->priv;
const struct iwl3945_channel_info *ch_info;
struct ieee80211_conf *conf = &hw->conf;
unsigned long flags;
int ret = 0;

Expand Down
4 changes: 3 additions & 1 deletion drivers/net/wireless/libertas_tf/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,11 @@ static void lbtf_op_remove_interface(struct ieee80211_hw *hw,
priv->vif = NULL;
}

static int lbtf_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
static int lbtf_op_config(struct ieee80211_hw *hw, u32 changed)
{
struct lbtf_private *priv = hw->priv;
struct ieee80211_conf *conf = &hw->conf;

if (conf->channel->center_freq != priv->cur_freq) {
priv->cur_freq = conf->channel->center_freq;
lbtf_set_channel(priv, conf->channel->hw_value);
Expand Down
4 changes: 2 additions & 2 deletions drivers/net/wireless/mac80211_hwsim.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,10 @@ static void mac80211_hwsim_beacon(unsigned long arg)
}


static int mac80211_hwsim_config(struct ieee80211_hw *hw,
struct ieee80211_conf *conf)
static int mac80211_hwsim_config(struct ieee80211_hw *hw, u32 changed)
{
struct mac80211_hwsim_data *data = hw->priv;
struct ieee80211_conf *conf = &hw->conf;

printk(KERN_DEBUG "%s:%s (freq=%d radio_enabled=%d beacon_int=%d)\n",
wiphy_name(hw->wiphy), __func__,
Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/p54/p54common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1192,10 +1192,11 @@ static void p54_remove_interface(struct ieee80211_hw *dev,
p54_set_filter(dev, 0, NULL);
}

static int p54_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
static int p54_config(struct ieee80211_hw *dev, u32 changed)
{
int ret;
struct p54_common *priv = dev->priv;
struct ieee80211_conf *conf = &dev->conf;

mutex_lock(&priv->conf_mutex);
priv->rx_antenna = 2; /* automatic */
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/rt2x00/rt2x00.h
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ int rt2x00mac_add_interface(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf);
void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf);
int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed);
int rt2x00mac_config_interface(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf);
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/rt2x00/rt2x00dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ int rt2x00lib_resume(struct rt2x00_dev *rt2x00dev)
/*
* Reconfigure device.
*/
retval = rt2x00mac_config(rt2x00dev->hw, &rt2x00dev->hw->conf);
retval = rt2x00mac_config(rt2x00dev->hw, ~0);
if (retval)
goto exit;

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/rt2x00/rt2x00mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,10 @@ void rt2x00mac_remove_interface(struct ieee80211_hw *hw,
}
EXPORT_SYMBOL_GPL(rt2x00mac_remove_interface);

int rt2x00mac_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
int rt2x00mac_config(struct ieee80211_hw *hw, u32 changed)
{
struct rt2x00_dev *rt2x00dev = hw->priv;
struct ieee80211_conf *conf = &hw->conf;
int radio_on;
int status;

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/rtl8180_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -692,9 +692,10 @@ static void rtl8180_remove_interface(struct ieee80211_hw *dev,
priv->vif = NULL;
}

static int rtl8180_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
static int rtl8180_config(struct ieee80211_hw *dev, u32 changed)
{
struct rtl8180_priv *priv = dev->priv;
struct ieee80211_conf *conf = &dev->conf;

priv->rf->set_chan(dev, conf);

Expand Down
3 changes: 2 additions & 1 deletion drivers/net/wireless/rtl8187_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,10 @@ static void rtl8187_remove_interface(struct ieee80211_hw *dev,
mutex_unlock(&priv->conf_mutex);
}

static int rtl8187_config(struct ieee80211_hw *dev, struct ieee80211_conf *conf)
static int rtl8187_config(struct ieee80211_hw *dev, u32 changed)
{
struct rtl8187_priv *priv = dev->priv;
struct ieee80211_conf *conf = &dev->conf;
u32 reg;

mutex_lock(&priv->conf_mutex);
Expand Down
4 changes: 3 additions & 1 deletion drivers/net/wireless/zd1211rw/zd_mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,11 @@ static void zd_op_remove_interface(struct ieee80211_hw *hw,
zd_write_mac_addr(&mac->chip, NULL);
}

static int zd_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
static int zd_op_config(struct ieee80211_hw *hw, u32 changed)
{
struct zd_mac *mac = zd_hw_mac(hw);
struct ieee80211_conf *conf = &hw->conf;

return zd_chip_set_channel(&mac->chip, conf->channel->hw_value);
}

Expand Down
30 changes: 25 additions & 5 deletions include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,13 +463,33 @@ static inline int __deprecated __IEEE80211_CONF_SHORT_SLOT_TIME(void)
}
#define IEEE80211_CONF_SHORT_SLOT_TIME (__IEEE80211_CONF_SHORT_SLOT_TIME())

/**
* enum ieee80211_conf_changed - denotes which configuration changed
*
* @IEEE80211_CONF_CHANGE_RADIO_ENABLED: the value of radio_enabled changed
* @IEEE80211_CONF_CHANGE_BEACON_INTERVAL: the beacon interval changed
* @IEEE80211_CONF_CHANGE_LISTEN_INTERVAL: the listen interval changed
* @IEEE80211_CONF_CHANGE_RADIOTAP: the radiotap flag changed
* @IEEE80211_CONF_CHANGE_PS: the PS flag changed
* @IEEE80211_CONF_CHANGE_POWER: the TX power changed
* @IEEE80211_CONF_CHANGE_CHANNEL: the channel changed
*/
enum ieee80211_conf_changed {
IEEE80211_CONF_CHANGE_RADIO_ENABLED = BIT(0),
IEEE80211_CONF_CHANGE_BEACON_INTERVAL = BIT(1),
IEEE80211_CONF_CHANGE_LISTEN_INTERVAL = BIT(2),
IEEE80211_CONF_CHANGE_RADIOTAP = BIT(3),
IEEE80211_CONF_CHANGE_PS = BIT(4),
IEEE80211_CONF_CHANGE_POWER = BIT(5),
IEEE80211_CONF_CHANGE_CHANNEL = BIT(6),
};

/**
* struct ieee80211_conf - configuration of the device
*
* This struct indicates how the driver shall configure the hardware.
*
* @radio_enabled: when zero, driver is required to switch off the radio.
* TODO make a flag
* @beacon_int: beacon interval (TODO make interface config)
* @listen_interval: listen interval in units of beacon interval
* @flags: configuration flags defined above
Expand All @@ -479,13 +499,13 @@ static inline int __deprecated __IEEE80211_CONF_SHORT_SLOT_TIME(void)
* @channel: the channel to tune to
*/
struct ieee80211_conf {
int radio_enabled;

int beacon_int;
u16 listen_interval;
u32 flags;
int power_level;

u16 listen_interval;
bool radio_enabled;

struct ieee80211_channel *channel;

struct ieee80211_sta_ht_cap ht_cap;
Expand Down Expand Up @@ -1214,7 +1234,7 @@ struct ieee80211_ops {
struct ieee80211_if_init_conf *conf);
void (*remove_interface)(struct ieee80211_hw *hw,
struct ieee80211_if_init_conf *conf);
int (*config)(struct ieee80211_hw *hw, struct ieee80211_conf *conf);
int (*config)(struct ieee80211_hw *hw, u32 changed);
int (*config_interface)(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_if_conf *conf);
Expand Down
3 changes: 2 additions & 1 deletion net/mac80211/cfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,8 @@ static int ieee80211_config_beacon(struct ieee80211_sub_if_data *sdata,
*/
if (params->interval) {
sdata->local->hw.conf.beacon_int = params->interval;
ieee80211_hw_config(sdata->local);
ieee80211_hw_config(sdata->local,
IEEE80211_CONF_CHANGE_BEACON_INTERVAL);
/*
* We updated some parameter so if below bails out
* it's not an error.
Expand Down
2 changes: 1 addition & 1 deletion net/mac80211/ieee80211_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ static inline int ieee80211_bssid_match(const u8 *raddr, const u8 *addr)
}


int ieee80211_hw_config(struct ieee80211_local *local);
int ieee80211_hw_config(struct ieee80211_local *local, u32 changed);
int ieee80211_if_config(struct ieee80211_sub_if_data *sdata, u32 changed);
void ieee80211_tx_set_protected(struct ieee80211_tx_data *tx);
void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata,
Expand Down
25 changes: 19 additions & 6 deletions net/mac80211/iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static int ieee80211_open(struct net_device *dev)
struct ieee80211_if_init_conf conf;
u32 changed = 0;
int res;
bool need_hw_reconfig = 0;
u32 hw_reconf_flags = 0;
u8 null_addr[ETH_ALEN] = {0};

/* fail early if user set an invalid address */
Expand Down Expand Up @@ -152,7 +152,8 @@ static int ieee80211_open(struct net_device *dev)
res = local->ops->start(local_to_hw(local));
if (res)
goto err_del_bss;
need_hw_reconfig = 1;
/* we're brought up, everything changes */
hw_reconf_flags = ~0;
ieee80211_led_radio(local, local->hw.conf.radio_enabled);
}

Expand Down Expand Up @@ -198,8 +199,10 @@ static int ieee80211_open(struct net_device *dev)

/* must be before the call to ieee80211_configure_filter */
local->monitors++;
if (local->monitors == 1)
if (local->monitors == 1) {
local->hw.conf.flags |= IEEE80211_CONF_RADIOTAP;
hw_reconf_flags |= IEEE80211_CONF_CHANGE_RADIOTAP;
}

if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
local->fif_fcsfail++;
Expand Down Expand Up @@ -279,8 +282,8 @@ static int ieee80211_open(struct net_device *dev)
atomic_inc(&local->iff_promiscs);

local->open_count++;
if (need_hw_reconfig) {
ieee80211_hw_config(local);
if (hw_reconf_flags) {
ieee80211_hw_config(local, hw_reconf_flags);
/*
* set default queue parameters so drivers don't
* need to initialise the hardware if the hardware
Expand Down Expand Up @@ -322,6 +325,7 @@ static int ieee80211_stop(struct net_device *dev)
struct ieee80211_local *local = sdata->local;
struct ieee80211_if_init_conf conf;
struct sta_info *sta;
u32 hw_reconf_flags = 0;

/*
* Stop TX on this interface first.
Expand Down Expand Up @@ -405,8 +409,10 @@ static int ieee80211_stop(struct net_device *dev)
}

local->monitors--;
if (local->monitors == 0)
if (local->monitors == 0) {
local->hw.conf.flags &= ~IEEE80211_CONF_RADIOTAP;
hw_reconf_flags |= IEEE80211_CONF_CHANGE_RADIOTAP;
}

if (sdata->u.mntr_flags & MONITOR_FLAG_FCSFAIL)
local->fif_fcsfail--;
Expand Down Expand Up @@ -504,8 +510,15 @@ static int ieee80211_stop(struct net_device *dev)

tasklet_disable(&local->tx_pending_tasklet);
tasklet_disable(&local->tasklet);

/* no reconfiguring after stop! */
hw_reconf_flags = 0;
}

/* do after stop to avoid reconfiguring when we stop anyway */
if (hw_reconf_flags)
ieee80211_hw_config(local, hw_reconf_flags);

return 0;
}

Expand Down
Loading

0 comments on commit e897558

Please sign in to comment.