From 189462ca0b20347b52edfca6647235c4bb078b66 Mon Sep 17 00:00:00 2001 From: noz Date: Mon, 25 Jun 2007 19:52:20 +0000 Subject: Merge mac80211 driver from tree at bu3sch.de, pulled 24/6 git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7733 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/mac80211/src/mac80211/Makefile | 1 + package/mac80211/src/mac80211/debugfs_netdev.c | 71 ++++++----- package/mac80211/src/mac80211/debugfs_sta.c | 2 +- package/mac80211/src/mac80211/ieee80211.c | 5 +- package/mac80211/src/mac80211/ieee80211_cfg.c | 2 +- package/mac80211/src/mac80211/ieee80211_i.h | 11 +- package/mac80211/src/mac80211/ieee80211_iface.c | 8 ++ package/mac80211/src/mac80211/ieee80211_ioctl.c | 133 -------------------- package/mac80211/src/mac80211/ieee80211_sta.c | 32 ++--- package/mac80211/src/mac80211/rc80211_simple.c | 3 +- package/mac80211/src/mac80211/regdomain.c | 157 ++++++++++++++++++++++++ package/mac80211/src/wireless/nl80211.c | 4 +- 12 files changed, 235 insertions(+), 194 deletions(-) create mode 100644 package/mac80211/src/mac80211/regdomain.c (limited to 'package/mac80211/src') diff --git a/package/mac80211/src/mac80211/Makefile b/package/mac80211/src/mac80211/Makefile index 40fe07c03..0a88dd312 100644 --- a/package/mac80211/src/mac80211/Makefile +++ b/package/mac80211/src/mac80211/Makefile @@ -13,6 +13,7 @@ mac80211-objs := \ ieee80211_iface.o \ ieee80211_rate.o \ michael.o \ + regdomain.o \ tkip.o \ aes_ccm.o \ wme.o \ diff --git a/package/mac80211/src/mac80211/debugfs_netdev.c b/package/mac80211/src/mac80211/debugfs_netdev.c index b9409eead..52a32e4f6 100644 --- a/package/mac80211/src/mac80211/debugfs_netdev.c +++ b/package/mac80211/src/mac80211/debugfs_netdev.c @@ -87,16 +87,6 @@ static const struct file_operations name##_ops = { \ IEEE80211_IF_FMT_##format(name, field) \ __IEEE80211_IF_FILE(name) -static struct ieee80211_elem_tspec _tspec = { - .nominal_msdu_size = 200, - .inactivity_interval = 40, - .mean_data_rate = 40000, - .min_phy_rate = 6000000, - .surplus_band_allow = 8192, - .medium_time = 30, -}; -static u8 _dls_mac[ETH_ALEN]; - #define DEBUGFS_QOS_FILE(name, f) \ static ssize_t qos_ ##name## _write(struct file *file, \ const char __user *userbuf, \ @@ -104,7 +94,7 @@ static ssize_t qos_ ##name## _write(struct file *file, \ { \ struct ieee80211_sub_if_data *sdata = file->private_data; \ \ - f(sdata->dev, &sdata->u.sta, &_tspec); \ + f(sdata->dev, &sdata->u.sta, &sdata->u.sta.tspec); \ \ return count; \ } \ @@ -132,7 +122,8 @@ DEBUGFS_QOS_FILE(delts_wmm, wmm_send_delts); static ssize_t qos_if_dls_mac(const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) { - return scnprintf(buf, buflen, MAC_FMT "\n", MAC_ARG(_dls_mac)); + return scnprintf(buf, buflen, MAC_FMT "\n", + MAC_ARG(sdata->u.sta.dls_mac)); } static ssize_t qos_dls_mac_read(struct file *file, @@ -163,7 +154,7 @@ static ssize_t qos_dls_mac_write(struct file *file, const char __user *userbuf, printk(KERN_ERR "%s: sscanf input error\n", sdata->dev->name); return -EINVAL; } - memcpy(_dls_mac, m, ETH_ALEN); + memcpy(sdata->u.sta.dls_mac, m, ETH_ALEN); return count; } @@ -207,10 +198,12 @@ static ssize_t qos_dls_op_write(struct file *file, const char __user *userbuf, } switch (opt) { case 1: - ieee80211_send_dls_req(sdata->dev, &sdata->u.sta, _dls_mac, 0); + ieee80211_send_dls_req(sdata->dev, &sdata->u.sta, + sdata->u.sta.dls_mac, 0); break; case 2: - ieee80211_send_dls_teardown(sdata->dev, &sdata->u.sta, _dls_mac, + ieee80211_send_dls_teardown(sdata->dev, &sdata->u.sta, + sdata->u.sta.dls_mac, WLAN_REASON_QSTA_NOT_USE); break; default: @@ -232,8 +225,9 @@ static ssize_t tsinfo_ ##_name## _read(struct file *file, \ size_t count, loff_t *ppos) \ { \ char buf[20]; \ + struct ieee80211_sub_if_data *sdata = file->private_data; \ int res = scnprintf(buf, count, "%u\n", \ - IEEE80211_TSINFO_## _name (_tspec.ts_info)); \ + IEEE80211_TSINFO_## _name (sdata->u.sta.tspec.ts_info));\ return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ } \ \ @@ -244,6 +238,7 @@ static ssize_t tsinfo_ ##_name## _write(struct file *file, \ char buf[20]; \ size_t size; \ int val; \ + struct ieee80211_sub_if_data *sdata = file->private_data; \ \ size = min(sizeof(buf) - 1, count); \ buf[size] = '\0'; \ @@ -252,12 +247,11 @@ static ssize_t tsinfo_ ##_name## _write(struct file *file, \ \ val = simple_strtoul(buf, NULL, 0); \ if ((val < min_val) || (val > max_val)) { \ - struct ieee80211_sub_if_data *sdata = file->private_data;\ printk(KERN_ERR "%s: set value (%u) out of range " \ "[%u, %u]\n",sdata->dev->name,val,min_val,max_val);\ return -EINVAL; \ } \ - SET_TSINFO_ ##_name (_tspec.ts_info, val); \ + IEEE80211_SET_TSINFO_ ##_name (sdata->u.sta.tspec.ts_info, val);\ return count; \ } \ \ @@ -292,13 +286,15 @@ DEBUGFS_TSINFO_FILE(TSID, 8, 15); DEBUGFS_TSINFO_FILE(DIR, 0, 3); DEBUGFS_TSINFO_FILE(UP, 0, 7); -#define DEBUGFS_TSPEC_FILE(name) \ +#define DEBUGFS_TSPEC_FILE(name, format_string, endian_f1, endian_f2) \ static ssize_t tspec_ ##name## _read(struct file *file, \ char __user *userbuf, \ size_t count, loff_t *ppos) \ { \ char buf[20]; \ - int res = scnprintf(buf, count, "%u\n", _tspec.name); \ + struct ieee80211_sub_if_data *sdata = file->private_data; \ + int res = scnprintf(buf, count, format_string "\n", \ + endian_f1(sdata->u.sta.tspec.name)); \ return simple_read_from_buffer(userbuf, count, ppos, buf, res); \ } \ \ @@ -308,13 +304,14 @@ static ssize_t tspec_ ##name## _write(struct file *file, \ { \ char buf[20]; \ size_t size; \ + struct ieee80211_sub_if_data *sdata = file->private_data; \ \ size = min(sizeof(buf) - 1, count); \ buf[size] = '\0'; \ if (copy_from_user(buf, userbuf, size)) \ return -EFAULT; \ \ - _tspec.name = simple_strtoul(buf, NULL, 0); \ + sdata->u.sta.tspec.name = endian_f2(simple_strtoul(buf, NULL, 0));\ return count; \ } \ \ @@ -334,21 +331,21 @@ static const struct file_operations tspec_ ##name## _ops = { \ sdata->debugfs.sta.tspec.name = NULL; \ } while (0) -DEBUGFS_TSPEC_FILE(nominal_msdu_size); -DEBUGFS_TSPEC_FILE(max_msdu_size); -DEBUGFS_TSPEC_FILE(min_service_interval); -DEBUGFS_TSPEC_FILE(max_service_interval); -DEBUGFS_TSPEC_FILE(inactivity_interval); -DEBUGFS_TSPEC_FILE(suspension_interval); -DEBUGFS_TSPEC_FILE(service_start_time); -DEBUGFS_TSPEC_FILE(min_data_rate); -DEBUGFS_TSPEC_FILE(mean_data_rate); -DEBUGFS_TSPEC_FILE(peak_data_rate); -DEBUGFS_TSPEC_FILE(burst_size); -DEBUGFS_TSPEC_FILE(delay_bound); -DEBUGFS_TSPEC_FILE(min_phy_rate); -DEBUGFS_TSPEC_FILE(surplus_band_allow); -DEBUGFS_TSPEC_FILE(medium_time); +DEBUGFS_TSPEC_FILE(nominal_msdu_size, "%hu", le16_to_cpu, cpu_to_le16); +DEBUGFS_TSPEC_FILE(max_msdu_size, "%hu", le16_to_cpu, cpu_to_le16); +DEBUGFS_TSPEC_FILE(min_service_interval, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(max_service_interval, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(inactivity_interval, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(suspension_interval, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(service_start_time, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(min_data_rate, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(mean_data_rate, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(peak_data_rate, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(burst_size, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(delay_bound, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(min_phy_rate, "%u", le32_to_cpu, cpu_to_le32); +DEBUGFS_TSPEC_FILE(surplus_band_allow, "%hu", le16_to_cpu, cpu_to_le16); +DEBUGFS_TSPEC_FILE(medium_time, "%hu", le16_to_cpu, cpu_to_le16); /* common attributes */ @@ -737,7 +734,9 @@ static int netdev_notify(struct notifier_block * nb, void *ndev) { struct net_device *dev = ndev; + /* TODO char buf[10+IFNAMSIZ]; + */ if (state != NETDEV_CHANGENAME) return 0; diff --git a/package/mac80211/src/mac80211/debugfs_sta.c b/package/mac80211/src/mac80211/debugfs_sta.c index fc1a024e2..6cfe35a99 100644 --- a/package/mac80211/src/mac80211/debugfs_sta.c +++ b/package/mac80211/src/mac80211/debugfs_sta.c @@ -158,7 +158,7 @@ static ssize_t sta_last_seq_ctrl_read(struct file *file, char __user *userbuf, struct sta_info *sta = file->private_data; for (i = 0; i < NUM_RX_DATA_QUEUES; i++) p += scnprintf(p, sizeof(buf)+buf-p, "%x ", - sta->last_seq_ctrl[i]); + le16_to_cpu(sta->last_seq_ctrl[i])); p += scnprintf(p, sizeof(buf)+buf-p, "\n"); return simple_read_from_buffer(userbuf, count, ppos, buf, p - buf); } diff --git a/package/mac80211/src/mac80211/ieee80211.c b/package/mac80211/src/mac80211/ieee80211.c index e903197ac..5202c487a 100644 --- a/package/mac80211/src/mac80211/ieee80211.c +++ b/package/mac80211/src/mac80211/ieee80211.c @@ -1557,7 +1557,7 @@ static int ieee80211_subif_start_xmit(struct sk_buff *skb, memcpy(hdr.addr4, skb->data + ETH_ALEN, ETH_ALEN); hdrlen = 30; } else if (sdata->type == IEEE80211_IF_TYPE_STA) { - if (dls_link_status(local, skb->data) == DLS_STATUS_OK){ + if (dls_link_status(local, skb->data) == DLS_STATUS_OK) { /* DA SA BSSID */ memcpy(hdr.addr1, skb->data, ETH_ALEN); memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); @@ -4962,7 +4962,7 @@ int ieee80211_register_hwmode(struct ieee80211_hw *hw, } if (!(hw->flags & IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED)) - ieee80211_init_client(local->mdev); + ieee80211_set_default_regdomain(mode); return 0; } @@ -5113,6 +5113,7 @@ static int __init ieee80211_init(void) } ieee80211_debugfs_netdev_init(); + ieee80211_regdomain_init(); return 0; } diff --git a/package/mac80211/src/mac80211/ieee80211_cfg.c b/package/mac80211/src/mac80211/ieee80211_cfg.c index 006982671..8f85bc273 100644 --- a/package/mac80211/src/mac80211/ieee80211_cfg.c +++ b/package/mac80211/src/mac80211/ieee80211_cfg.c @@ -13,7 +13,7 @@ #include "ieee80211_cfg.h" static int ieee80211_add_iface(struct wiphy *wiphy, char *name, - unsigned int type) + enum nl80211_iftype type) { struct ieee80211_local *local = wiphy_priv(wiphy); int itype; diff --git a/package/mac80211/src/mac80211/ieee80211_i.h b/package/mac80211/src/mac80211/ieee80211_i.h index 2bb34ffe0..880a73075 100644 --- a/package/mac80211/src/mac80211/ieee80211_i.h +++ b/package/mac80211/src/mac80211/ieee80211_i.h @@ -296,6 +296,10 @@ struct ieee80211_if_sta { #define STA_TSDIR_NUM 2 /* EDCA: 0~7, HCCA: 8~15 */ struct sta_ts_data ts_data[STA_TSID_NUM][STA_TSDIR_NUM]; +#ifdef CONFIG_MAC80211_DEBUGFS + struct ieee80211_elem_tspec tspec; + u8 dls_mac[ETH_ALEN]; +#endif }; @@ -833,7 +837,6 @@ void ieee80211_update_default_wep_only(struct ieee80211_local *local); /* ieee80211_ioctl.c */ int ieee80211_set_compression(struct ieee80211_local *local, struct net_device *dev, struct sta_info *sta); -int ieee80211_init_client(struct net_device *dev); int ieee80211_set_channel(struct ieee80211_local *local, int channel, int freq); /* ieee80211_sta.c */ void ieee80211_sta_timer(unsigned long data); @@ -873,7 +876,7 @@ void wmm_send_delts(struct net_device *dev, struct ieee80211_elem_tspec *tp); void ieee80211_send_dls_req(struct net_device *dev, struct ieee80211_if_sta *ifsta, - u8 *addr, u32 timeout); + u8 *addr, u16 timeout); void ieee80211_send_dls_teardown(struct net_device *dev, struct ieee80211_if_sta *ifsta, u8 *mac, u16 reason); @@ -895,6 +898,10 @@ void ieee80211_if_sdata_init(struct ieee80211_sub_if_data *sdata); int ieee80211_if_add_mgmt(struct ieee80211_local *local); void ieee80211_if_del_mgmt(struct ieee80211_local *local); +/* regdomain.c */ +void ieee80211_regdomain_init(void); +void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode); + /* for wiphy privid */ extern void *mac80211_wiphy_privid; diff --git a/package/mac80211/src/mac80211/ieee80211_iface.c b/package/mac80211/src/mac80211/ieee80211_iface.c index c5c8bab24..683d2751c 100644 --- a/package/mac80211/src/mac80211/ieee80211_iface.c +++ b/package/mac80211/src/mac80211/ieee80211_iface.c @@ -198,6 +198,14 @@ void ieee80211_if_set_type(struct net_device *dev, int type) /* Initialize non-AP QSTA QoS Params */ ifsta->dot11EDCAAveragingPeriod = 5; ifsta->MPDUExchangeTime = 0; +#ifdef CONFIG_MAC80211_DEBUGFS + ifsta->tspec.nominal_msdu_size = cpu_to_le16(200), + ifsta->tspec.inactivity_interval = cpu_to_le32(40), + ifsta->tspec.mean_data_rate = cpu_to_le32(40000), + ifsta->tspec.min_phy_rate = cpu_to_le32(6000000), + ifsta->tspec.surplus_band_allow = cpu_to_le16(8192), + ifsta->tspec.medium_time = cpu_to_le16(30), +#endif msdata = IEEE80211_DEV_TO_SUB_IF(sdata->local->mdev); sdata->bss = &msdata->u.ap; diff --git a/package/mac80211/src/mac80211/ieee80211_ioctl.c b/package/mac80211/src/mac80211/ieee80211_ioctl.c index 36dc32a61..fcea8b288 100644 --- a/package/mac80211/src/mac80211/ieee80211_ioctl.c +++ b/package/mac80211/src/mac80211/ieee80211_ioctl.c @@ -27,20 +27,6 @@ #include "aes_ccm.h" #include "debugfs_key.h" -static int ieee80211_regdom = 0x10; /* FCC */ -module_param(ieee80211_regdom, int, 0444); -MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK"); - -/* - * If firmware is upgraded by the vendor, additional channels can be used based - * on the new Japanese regulatory rules. This is indicated by setting - * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel - * module. - */ -static int ieee80211_japan_5ghz /* = 0 */; -module_param(ieee80211_japan_5ghz, int, 0444); -MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz"); - static int ieee80211_ioctl_set_beacon(struct net_device *dev, struct prism2_hostapd_param *param, @@ -1556,125 +1542,6 @@ static int ieee80211_ioctl_giwrange(struct net_device *dev, } -struct ieee80211_channel_range { - short start_freq; - short end_freq; - unsigned char power_level; - unsigned char antenna_max; -}; - -static const struct ieee80211_channel_range ieee80211_fcc_channels[] = { - { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */, - { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */, - { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */, - { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */, - { 0 } -}; - -static const struct ieee80211_channel_range ieee80211_mkk_channels[] = { - { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */, - { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */, - { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */, - { 0 } -}; - - -static const struct ieee80211_channel_range *channel_range = - ieee80211_fcc_channels; - - -static void ieee80211_unmask_channel(struct net_device *dev, int mode, - struct ieee80211_channel *chan) -{ - int i; - - chan->flag = 0; - - if (ieee80211_regdom == 64 && - (mode == MODE_ATHEROS_TURBO || mode == MODE_ATHEROS_TURBOG)) { - /* Do not allow Turbo modes in Japan. */ - return; - } - - for (i = 0; channel_range[i].start_freq; i++) { - const struct ieee80211_channel_range *r = &channel_range[i]; - if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) { - if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz && - chan->freq >= 5260 && chan->freq <= 5320) { - /* - * Skip new channels in Japan since the - * firmware was not marked having been upgraded - * by the vendor. - */ - continue; - } - - if (ieee80211_regdom == 0x10 && - (chan->freq == 5190 || chan->freq == 5210 || - chan->freq == 5230)) { - /* Skip MKK channels when in FCC domain. */ - continue; - } - - chan->flag |= IEEE80211_CHAN_W_SCAN | - IEEE80211_CHAN_W_ACTIVE_SCAN | - IEEE80211_CHAN_W_IBSS; - chan->power_level = r->power_level; - chan->antenna_max = r->antenna_max; - - if (ieee80211_regdom == 64 && - (chan->freq == 5170 || chan->freq == 5190 || - chan->freq == 5210 || chan->freq == 5230)) { - /* - * New regulatory rules in Japan have backwards - * compatibility with old channels in 5.15-5.25 - * GHz band, but the station is not allowed to - * use active scan on these old channels. - */ - chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN; - } - - if (ieee80211_regdom == 64 && - (chan->freq == 5260 || chan->freq == 5280 || - chan->freq == 5300 || chan->freq == 5320)) { - /* - * IBSS is not allowed on 5.25-5.35 GHz band - * due to radar detection requirements. - */ - chan->flag &= ~IEEE80211_CHAN_W_IBSS; - } - - break; - } - } -} - - -static int ieee80211_unmask_channels(struct net_device *dev) -{ - struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); - struct ieee80211_hw_mode *mode; - int c; - - list_for_each_entry(mode, &local->modes_list, list) { - for (c = 0; c < mode->num_channels; c++) { - ieee80211_unmask_channel(dev, mode->mode, - &mode->channels[c]); - } - } - return 0; -} - - -int ieee80211_init_client(struct net_device *dev) -{ - if (ieee80211_regdom == 0x40) - channel_range = ieee80211_mkk_channels; - ieee80211_unmask_channels(dev); - return 0; -} - - static int ieee80211_ioctl_siwmode(struct net_device *dev, struct iw_request_info *info, __u32 *mode, char *extra) diff --git a/package/mac80211/src/mac80211/ieee80211_sta.c b/package/mac80211/src/mac80211/ieee80211_sta.c index 9fdd2659d..0e4501db7 100644 --- a/package/mac80211/src/mac80211/ieee80211_sta.c +++ b/package/mac80211/src/mac80211/ieee80211_sta.c @@ -714,7 +714,7 @@ static void ieee80211_send_disassoc(struct net_device *dev, } -int ieee80211_ts_index(u8 direction) +static int ieee80211_ts_index(u8 direction) { if (direction == WLAN_TSINFO_DOWNLINK || direction == WLAN_TSINFO_DIRECTLINK) @@ -822,11 +822,11 @@ void ieee80211_send_delts(struct net_device *dev, struct sk_buff *skb; u8 tsid = IEEE80211_TSINFO_TSID(tp->ts_info); u8 direction = IEEE80211_TSINFO_DIR(tp->ts_info); - u32 medium_time = tp->medium_time; + u16 medium_time = le16_to_cpu(tp->medium_time); u8 index = ieee80211_ts_index(direction); if (ifsta->ts_data[tsid][index].status == TS_STATUS_UNUSED) { - printk(KERN_DEBUG "%s: Tring to delete an ACM disabled TS " + printk(KERN_DEBUG "%s: Trying to delete an ACM disabled TS " "(%u:%u)\n", dev->name, tsid, direction); return; } @@ -859,11 +859,11 @@ void ieee80211_send_delts(struct net_device *dev, memset(&mgmt->u.action.u.delts.ts_info, 0, sizeof(struct ieee80211_ts_info)); - SET_TSINFO_TSID(tp->ts_info, tsid); - SET_TSINFO_DIR(tp->ts_info, direction); - SET_TSINFO_POLICY(tp->ts_info, WLAN_TSINFO_EDCA); - SET_TSINFO_APSD(tp->ts_info, WLAN_TSINFO_PSB_LEGACY); - SET_TSINFO_UP(tp->ts_info, ifsta->ts_data[tsid][index].up); + IEEE80211_SET_TSINFO_TSID(tp->ts_info, tsid); + IEEE80211_SET_TSINFO_DIR(tp->ts_info, direction); + IEEE80211_SET_TSINFO_POLICY(tp->ts_info, WLAN_TSINFO_EDCA); + IEEE80211_SET_TSINFO_APSD(tp->ts_info, WLAN_TSINFO_PSB_LEGACY); + IEEE80211_SET_TSINFO_UP(tp->ts_info, ifsta->ts_data[tsid][index].up); ieee80211_sta_tx(dev, skb, 0); } @@ -878,7 +878,7 @@ void wmm_send_delts(struct net_device *dev, struct sk_buff *skb; u8 tsid = IEEE80211_TSINFO_TSID(tp->ts_info); u8 direction = IEEE80211_TSINFO_DIR(tp->ts_info); - u32 medium_time = tp->medium_time; + u16 medium_time = le16_to_cpu(tp->medium_time); u8 index = ieee80211_ts_index(direction); u8 *pos; @@ -930,11 +930,11 @@ void wmm_send_delts(struct net_device *dev, tspec = (struct ieee80211_elem_tspec *)pos; memset(tspec, 0, sizeof(*tspec)); - SET_TSINFO_TSID(tspec->ts_info, tsid); - SET_TSINFO_DIR(tspec->ts_info, direction); - SET_TSINFO_POLICY(tspec->ts_info, WLAN_TSINFO_EDCA); - SET_TSINFO_APSD(tspec->ts_info, WLAN_TSINFO_PSB_LEGACY); - SET_TSINFO_UP(tspec->ts_info, ifsta->ts_data[tsid][index].up); + IEEE80211_SET_TSINFO_TSID(tspec->ts_info, tsid); + IEEE80211_SET_TSINFO_DIR(tspec->ts_info, direction); + IEEE80211_SET_TSINFO_POLICY(tspec->ts_info, WLAN_TSINFO_EDCA); + IEEE80211_SET_TSINFO_APSD(tspec->ts_info, WLAN_TSINFO_PSB_LEGACY); + IEEE80211_SET_TSINFO_UP(tspec->ts_info, ifsta->ts_data[tsid][index].up); ieee80211_sta_tx(dev, skb, 0); } @@ -942,7 +942,7 @@ void wmm_send_delts(struct net_device *dev, void ieee80211_send_dls_req(struct net_device *dev, struct ieee80211_if_sta *ifsta, - u8 *addr, u32 timeout) + u8 *addr, u16 timeout) { struct ieee80211_hw_mode *mode; struct sk_buff *skb; @@ -972,7 +972,7 @@ void ieee80211_send_dls_req(struct net_device *dev, memcpy(mgmt->u.action.u.dls_req.dest, addr, ETH_ALEN); memcpy(mgmt->u.action.u.dls_req.src, dev->dev_addr, ETH_ALEN); mgmt->u.action.u.dls_req.capab_info = cpu_to_le16(ifsta->ap_capab); - mgmt->u.action.u.dls_req.timeout = timeout; + mgmt->u.action.u.dls_req.timeout = cpu_to_le16(timeout); /* Add supported rates and extended supported rates */ supp_rates = skb_put(skb, 2); diff --git a/package/mac80211/src/mac80211/rc80211_simple.c b/package/mac80211/src/mac80211/rc80211_simple.c index 8f1f351be..5ae7fc454 100644 --- a/package/mac80211/src/mac80211/rc80211_simple.c +++ b/package/mac80211/src/mac80211/rc80211_simple.c @@ -289,9 +289,10 @@ static void rate_control_simple_rate_init(void *priv, void *priv_sta, * as a workaround, */ for (i = 0; i < mode->num_rates; i++) { if ((sta->supp_rates & BIT(i)) && - (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED)) + (mode->rates[i].flags & IEEE80211_RATE_SUPPORTED)) { sta->txrate = i; break; + } } } diff --git a/package/mac80211/src/mac80211/regdomain.c b/package/mac80211/src/mac80211/regdomain.c new file mode 100644 index 000000000..32e5dca6b --- /dev/null +++ b/package/mac80211/src/mac80211/regdomain.c @@ -0,0 +1,157 @@ +/* + * Copyright 2002-2005, Instant802 Networks, Inc. + * Copyright 2005-2006, Devicescape Software, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/* + * This regulatory domain control implementation is known to be incomplete + * and confusing. mac80211 regulatory domain control will be significantly + * reworked in the not-too-distant future. + * + * For now, drivers wishing to control which channels are and aren't available + * are advised as follows: + * - set the IEEE80211_HW_DEFAULT_REG_DOMAIN_CONFIGURED flag + * - continue to include *ALL* possible channels in the modes registered + * through ieee80211_register_hwmode() + * - for each allowable ieee80211_channel structure registered in the above + * call, set the flag member to some meaningful value such as + * IEEE80211_CHAN_W_SCAN | IEEE80211_CHAN_W_ACTIVE_SCAN | + * IEEE80211_CHAN_W_IBSS. + * - leave flag as 0 for non-allowable channels + * + * The usual implementation is for a driver to read a device EEPROM to + * determine which regulatory domain it should be operating under, then + * looking up the allowable channels in a driver-local table, then performing + * the above. + */ + +#include +#include +#include + +static int ieee80211_regdom = 0x10; /* FCC */ +module_param(ieee80211_regdom, int, 0444); +MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain; 64=MKK"); + +/* + * If firmware is upgraded by the vendor, additional channels can be used based + * on the new Japanese regulatory rules. This is indicated by setting + * ieee80211_japan_5ghz module parameter to one when loading the 80211 kernel + * module. + */ +static int ieee80211_japan_5ghz /* = 0 */; +module_param(ieee80211_japan_5ghz, int, 0444); +MODULE_PARM_DESC(ieee80211_japan_5ghz, "Vendor-updated firmware for 5 GHz"); + + +struct ieee80211_channel_range { + short start_freq; + short end_freq; + unsigned char power_level; + unsigned char antenna_max; +}; + +static const struct ieee80211_channel_range ieee80211_fcc_channels[] = { + { 2412, 2462, 27, 6 } /* IEEE 802.11b/g, channels 1..11 */, + { 5180, 5240, 17, 6 } /* IEEE 802.11a, channels 36..48 */, + { 5260, 5320, 23, 6 } /* IEEE 802.11a, channels 52..64 */, + { 5745, 5825, 30, 6 } /* IEEE 802.11a, channels 149..165, outdoor */, + { 0 } +}; + +static const struct ieee80211_channel_range ieee80211_mkk_channels[] = { + { 2412, 2472, 20, 6 } /* IEEE 802.11b/g, channels 1..13 */, + { 5170, 5240, 20, 6 } /* IEEE 802.11a, channels 34..48 */, + { 5260, 5320, 20, 6 } /* IEEE 802.11a, channels 52..64 */, + { 0 } +}; + + +static const struct ieee80211_channel_range *channel_range = + ieee80211_fcc_channels; + + +static void ieee80211_unmask_channel(int mode, struct ieee80211_channel *chan) +{ + int i; + + chan->flag = 0; + + if (ieee80211_regdom == 64 && + (mode == MODE_ATHEROS_TURBO || mode == MODE_ATHEROS_TURBOG)) { + /* Do not allow Turbo modes in Japan. */ + return; + } + + for (i = 0; channel_range[i].start_freq; i++) { + const struct ieee80211_channel_range *r = &channel_range[i]; + if (r->start_freq <= chan->freq && r->end_freq >= chan->freq) { + if (ieee80211_regdom == 64 && !ieee80211_japan_5ghz && + chan->freq >= 5260 && chan->freq <= 5320) { + /* + * Skip new channels in Japan since the + * firmware was not marked having been upgraded + * by the vendor. + */ + continue; + } + + if (ieee80211_regdom == 0x10 && + (chan->freq == 5190 || chan->freq == 5210 || + chan->freq == 5230)) { + /* Skip MKK channels when in FCC domain. */ + continue; + } + + chan->flag |= IEEE80211_CHAN_W_SCAN | + IEEE80211_CHAN_W_ACTIVE_SCAN | + IEEE80211_CHAN_W_IBSS; + chan->power_level = r->power_level; + chan->antenna_max = r->antenna_max; + + if (ieee80211_regdom == 64 && + (chan->freq == 5170 || chan->freq == 5190 || + chan->freq == 5210 || chan->freq == 5230)) { + /* + * New regulatory rules in Japan have backwards + * compatibility with old channels in 5.15-5.25 + * GHz band, but the station is not allowed to + * use active scan on these old channels. + */ + chan->flag &= ~IEEE80211_CHAN_W_ACTIVE_SCAN; + } + + if (ieee80211_regdom == 64 && + (chan->freq == 5260 || chan->freq == 5280 || + chan->freq == 5300 || chan->freq == 5320)) { + /* + * IBSS is not allowed on 5.25-5.35 GHz band + * due to radar detection requirements. + */ + chan->flag &= ~IEEE80211_CHAN_W_IBSS; + } + + break; + } + } +} + + +void ieee80211_set_default_regdomain(struct ieee80211_hw_mode *mode) +{ + int c; + for (c = 0; c < mode->num_channels; c++) + ieee80211_unmask_channel(mode->mode, &mode->channels[c]); +} + + +void ieee80211_regdomain_init(void) +{ + if (ieee80211_regdom == 0x40) + channel_range = ieee80211_mkk_channels; +} + diff --git a/package/mac80211/src/wireless/nl80211.c b/package/mac80211/src/wireless/nl80211.c index d6a44a386..ffbe6288a 100644 --- a/package/mac80211/src/wireless/nl80211.c +++ b/package/mac80211/src/wireless/nl80211.c @@ -293,7 +293,7 @@ static int nl80211_add_virt_intf(struct sk_buff *skb, struct genl_info *info) { struct cfg80211_registered_device *drv; int err; - unsigned int type = NL80211_IFTYPE_UNSPECIFIED; + enum nl80211_iftype type = NL80211_IFTYPE_UNSPECIFIED; if (!info->attrs[NL80211_ATTR_IFNAME]) return -EINVAL; @@ -353,7 +353,7 @@ static int nl80211_change_virt_intf(struct sk_buff *skb, struct genl_info *info) { struct cfg80211_registered_device *drv; int err, ifindex; - unsigned int type; + enum nl80211_iftype type; struct net_device *dev; if (info->attrs[NL80211_ATTR_IFTYPE]) { -- cgit v1.2.3