Skip to content

Commit

Permalink
mac80211: power management wext hooks
Browse files Browse the repository at this point in the history
This patch implements the power management routines wireless extensions
for mac80211.
For now we only support switching PS mode between on and off.

Signed-off-by: Samuel Ortiz <sameo@openedhand.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Samuel Ortiz authored and John W. Linville committed Jul 14, 2008
1 parent 79d1638 commit 49292d5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions include/net/mac80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,11 +407,13 @@ struct ieee80211_rx_status {
* @IEEE80211_CONF_SHORT_SLOT_TIME: use 802.11g short slot time
* @IEEE80211_CONF_RADIOTAP: add radiotap header at receive time (if supported)
* @IEEE80211_CONF_SUPPORT_HT_MODE: use 802.11n HT capabilities (if supported)
* @IEEE80211_CONF_PS: Enable 802.11 power save mode
*/
enum ieee80211_conf_flags {
IEEE80211_CONF_SHORT_SLOT_TIME = (1<<0),
IEEE80211_CONF_RADIOTAP = (1<<1),
IEEE80211_CONF_SUPPORT_HT_MODE = (1<<2),
IEEE80211_CONF_PS = (1<<3),
};

/**
Expand Down
43 changes: 41 additions & 2 deletions net/mac80211/wext.c
Original file line number Diff line number Diff line change
Expand Up @@ -1009,6 +1009,45 @@ static int ieee80211_ioctl_giwencode(struct net_device *dev,
return 0;
}

static int ieee80211_ioctl_siwpower(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *wrq,
char *extra)
{
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee80211_conf *conf = &local->hw.conf;

if (wrq->disabled) {
conf->flags &= ~IEEE80211_CONF_PS;
return ieee80211_hw_config(local);
}

switch (wrq->flags & IW_POWER_MODE) {
case IW_POWER_ON: /* If not specified */
case IW_POWER_MODE: /* If set all mask */
case IW_POWER_ALL_R: /* If explicitely state all */
conf->flags |= IEEE80211_CONF_PS;
break;
default: /* Otherwise we don't support it */
return -EINVAL;
}

return ieee80211_hw_config(local);
}

static int ieee80211_ioctl_giwpower(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
char *extra)
{
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee80211_conf *conf = &local->hw.conf;

wrqu->power.disabled = !(conf->flags & IEEE80211_CONF_PS);

return 0;
}

static int ieee80211_ioctl_siwauth(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *data, char *extra)
Expand Down Expand Up @@ -1211,8 +1250,8 @@ static const iw_handler ieee80211_handler[] =
(iw_handler) ieee80211_ioctl_giwretry, /* SIOCGIWRETRY */
(iw_handler) ieee80211_ioctl_siwencode, /* SIOCSIWENCODE */
(iw_handler) ieee80211_ioctl_giwencode, /* SIOCGIWENCODE */
(iw_handler) NULL, /* SIOCSIWPOWER */
(iw_handler) NULL, /* SIOCGIWPOWER */
(iw_handler) ieee80211_ioctl_siwpower, /* SIOCSIWPOWER */
(iw_handler) ieee80211_ioctl_giwpower, /* SIOCGIWPOWER */
(iw_handler) NULL, /* -- hole -- */
(iw_handler) NULL, /* -- hole -- */
(iw_handler) ieee80211_ioctl_siwgenie, /* SIOCSIWGENIE */
Expand Down

0 comments on commit 49292d5

Please sign in to comment.