diff options
author | Dan Williams <dcbw@redhat.com> | 2006-04-15 12:26:18 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2006-04-24 16:26:14 -0400 |
commit | 3c304956755fa63ee80ca51ce38078fe1c4e8818 (patch) | |
tree | 4225b87cdf197139e47f931b28fa897dc21f56d5 /drivers | |
parent | 921a91ef6adffe066ce80823350b982c647033e7 (diff) |
[PATCH] wireless/airo: minimal WPA awareness
airo cards with firmware versions of 5.30.17 and higher support WPA.
This patch recognizes WPA-capable firmware versions and adds support for
retrieving the WPA and RSN information elements from the card's scan
results. The JOB and FLAG fields are now independent, since there was
no space left in the FLAG field for FLAG_WPA_CAPABLE.
Signed-off-by: matthieu castet <castet.matthieu@free.fr>
Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/airo.c | 271 |
1 files changed, 194 insertions, 77 deletions
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index 00764ddd74d8..7f2dacf634ee 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -47,6 +47,7 @@ | |||
47 | #include <linux/ioport.h> | 47 | #include <linux/ioport.h> |
48 | #include <linux/pci.h> | 48 | #include <linux/pci.h> |
49 | #include <asm/uaccess.h> | 49 | #include <asm/uaccess.h> |
50 | #include <net/ieee80211.h> | ||
50 | 51 | ||
51 | #include "airo.h" | 52 | #include "airo.h" |
52 | 53 | ||
@@ -467,6 +468,8 @@ static int do8bitIO = 0; | |||
467 | #define RID_ECHOTEST_RESULTS 0xFF71 | 468 | #define RID_ECHOTEST_RESULTS 0xFF71 |
468 | #define RID_BSSLISTFIRST 0xFF72 | 469 | #define RID_BSSLISTFIRST 0xFF72 |
469 | #define RID_BSSLISTNEXT 0xFF73 | 470 | #define RID_BSSLISTNEXT 0xFF73 |
471 | #define RID_WPA_BSSLISTFIRST 0xFF74 | ||
472 | #define RID_WPA_BSSLISTNEXT 0xFF75 | ||
470 | 473 | ||
471 | typedef struct { | 474 | typedef struct { |
472 | u16 cmd; | 475 | u16 cmd; |
@@ -739,6 +742,14 @@ typedef struct { | |||
739 | u16 extSoftCap; | 742 | u16 extSoftCap; |
740 | } CapabilityRid; | 743 | } CapabilityRid; |
741 | 744 | ||
745 | |||
746 | /* Only present on firmware >= 5.30.17 */ | ||
747 | typedef struct { | ||
748 | u16 unknown[4]; | ||
749 | u8 fixed[12]; /* WLAN management frame */ | ||
750 | u8 iep[624]; | ||
751 | } BSSListRidExtra; | ||
752 | |||
742 | typedef struct { | 753 | typedef struct { |
743 | u16 len; | 754 | u16 len; |
744 | u16 index; /* First is 0 and 0xffff means end of list */ | 755 | u16 index; /* First is 0 and 0xffff means end of list */ |
@@ -767,6 +778,9 @@ typedef struct { | |||
767 | } fh; | 778 | } fh; |
768 | u16 dsChannel; | 779 | u16 dsChannel; |
769 | u16 atimWindow; | 780 | u16 atimWindow; |
781 | |||
782 | /* Only present on firmware >= 5.30.17 */ | ||
783 | BSSListRidExtra extra; | ||
770 | } BSSListRid; | 784 | } BSSListRid; |
771 | 785 | ||
772 | typedef struct { | 786 | typedef struct { |
@@ -1140,8 +1154,6 @@ struct airo_info { | |||
1140 | char defindex; // Used with auto wep | 1154 | char defindex; // Used with auto wep |
1141 | struct proc_dir_entry *proc_entry; | 1155 | struct proc_dir_entry *proc_entry; |
1142 | spinlock_t aux_lock; | 1156 | spinlock_t aux_lock; |
1143 | unsigned long flags; | ||
1144 | #define FLAG_PROMISC 8 /* IFF_PROMISC 0x100 - include/linux/if.h */ | ||
1145 | #define FLAG_RADIO_OFF 0 /* User disabling of MAC */ | 1157 | #define FLAG_RADIO_OFF 0 /* User disabling of MAC */ |
1146 | #define FLAG_RADIO_DOWN 1 /* ifup/ifdown disabling of MAC */ | 1158 | #define FLAG_RADIO_DOWN 1 /* ifup/ifdown disabling of MAC */ |
1147 | #define FLAG_RADIO_MASK 0x03 | 1159 | #define FLAG_RADIO_MASK 0x03 |
@@ -1151,6 +1163,7 @@ struct airo_info { | |||
1151 | #define FLAG_UPDATE_MULTI 5 | 1163 | #define FLAG_UPDATE_MULTI 5 |
1152 | #define FLAG_UPDATE_UNI 6 | 1164 | #define FLAG_UPDATE_UNI 6 |
1153 | #define FLAG_802_11 7 | 1165 | #define FLAG_802_11 7 |
1166 | #define FLAG_PROMISC 8 /* IFF_PROMISC 0x100 - include/linux/if.h */ | ||
1154 | #define FLAG_PENDING_XMIT 9 | 1167 | #define FLAG_PENDING_XMIT 9 |
1155 | #define FLAG_PENDING_XMIT11 10 | 1168 | #define FLAG_PENDING_XMIT11 10 |
1156 | #define FLAG_MPI 11 | 1169 | #define FLAG_MPI 11 |
@@ -1158,17 +1171,19 @@ struct airo_info { | |||
1158 | #define FLAG_COMMIT 13 | 1171 | #define FLAG_COMMIT 13 |
1159 | #define FLAG_RESET 14 | 1172 | #define FLAG_RESET 14 |
1160 | #define FLAG_FLASHING 15 | 1173 | #define FLAG_FLASHING 15 |
1161 | #define JOB_MASK 0x2ff0000 | 1174 | #define FLAG_WPA_CAPABLE 16 |
1162 | #define JOB_DIE 16 | 1175 | unsigned long flags; |
1163 | #define JOB_XMIT 17 | 1176 | #define JOB_DIE 0 |
1164 | #define JOB_XMIT11 18 | 1177 | #define JOB_XMIT 1 |
1165 | #define JOB_STATS 19 | 1178 | #define JOB_XMIT11 2 |
1166 | #define JOB_PROMISC 20 | 1179 | #define JOB_STATS 3 |
1167 | #define JOB_MIC 21 | 1180 | #define JOB_PROMISC 4 |
1168 | #define JOB_EVENT 22 | 1181 | #define JOB_MIC 5 |
1169 | #define JOB_AUTOWEP 23 | 1182 | #define JOB_EVENT 6 |
1170 | #define JOB_WSTATS 24 | 1183 | #define JOB_AUTOWEP 7 |
1171 | #define JOB_SCAN_RESULTS 25 | 1184 | #define JOB_WSTATS 8 |
1185 | #define JOB_SCAN_RESULTS 9 | ||
1186 | unsigned long jobs; | ||
1172 | int (*bap_read)(struct airo_info*, u16 *pu16Dst, int bytelen, | 1187 | int (*bap_read)(struct airo_info*, u16 *pu16Dst, int bytelen, |
1173 | int whichbap); | 1188 | int whichbap); |
1174 | unsigned short *flash; | 1189 | unsigned short *flash; |
@@ -1208,6 +1223,11 @@ struct airo_info { | |||
1208 | #define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE | 1223 | #define PCI_SHARED_LEN 2*MPI_MAX_FIDS*PKTSIZE+RIDSIZE |
1209 | char proc_name[IFNAMSIZ]; | 1224 | char proc_name[IFNAMSIZ]; |
1210 | 1225 | ||
1226 | /* WPA-related stuff */ | ||
1227 | unsigned int bssListFirst; | ||
1228 | unsigned int bssListNext; | ||
1229 | unsigned int bssListRidLen; | ||
1230 | |||
1211 | struct list_head network_list; | 1231 | struct list_head network_list; |
1212 | struct list_head network_free_list; | 1232 | struct list_head network_free_list; |
1213 | BSSListElement *networks; | 1233 | BSSListElement *networks; |
@@ -1264,7 +1284,7 @@ static void micinit(struct airo_info *ai) | |||
1264 | { | 1284 | { |
1265 | MICRid mic_rid; | 1285 | MICRid mic_rid; |
1266 | 1286 | ||
1267 | clear_bit(JOB_MIC, &ai->flags); | 1287 | clear_bit(JOB_MIC, &ai->jobs); |
1268 | PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0); | 1288 | PC4500_readrid(ai, RID_MIC, &mic_rid, sizeof(mic_rid), 0); |
1269 | up(&ai->sem); | 1289 | up(&ai->sem); |
1270 | 1290 | ||
@@ -1705,24 +1725,24 @@ static void emmh32_final(emmh32_context *context, u8 digest[4]) | |||
1705 | static int readBSSListRid(struct airo_info *ai, int first, | 1725 | static int readBSSListRid(struct airo_info *ai, int first, |
1706 | BSSListRid *list) { | 1726 | BSSListRid *list) { |
1707 | int rc; | 1727 | int rc; |
1708 | Cmd cmd; | 1728 | Cmd cmd; |
1709 | Resp rsp; | 1729 | Resp rsp; |
1710 | 1730 | ||
1711 | if (first == 1) { | 1731 | if (first == 1) { |
1712 | if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; | 1732 | if (ai->flags & FLAG_RADIO_MASK) return -ENETDOWN; |
1713 | memset(&cmd, 0, sizeof(cmd)); | 1733 | memset(&cmd, 0, sizeof(cmd)); |
1714 | cmd.cmd=CMD_LISTBSS; | 1734 | cmd.cmd=CMD_LISTBSS; |
1715 | if (down_interruptible(&ai->sem)) | 1735 | if (down_interruptible(&ai->sem)) |
1716 | return -ERESTARTSYS; | 1736 | return -ERESTARTSYS; |
1717 | issuecommand(ai, &cmd, &rsp); | 1737 | issuecommand(ai, &cmd, &rsp); |
1718 | up(&ai->sem); | 1738 | up(&ai->sem); |
1719 | /* Let the command take effect */ | 1739 | /* Let the command take effect */ |
1720 | ai->task = current; | 1740 | ai->task = current; |
1721 | ssleep(3); | 1741 | ssleep(3); |
1722 | ai->task = NULL; | 1742 | ai->task = NULL; |
1723 | } | 1743 | } |
1724 | rc = PC4500_readrid(ai, first ? RID_BSSLISTFIRST : RID_BSSLISTNEXT, | 1744 | rc = PC4500_readrid(ai, first ? ai->bssListFirst : ai->bssListNext, |
1725 | list, sizeof(*list), 1); | 1745 | list, ai->bssListRidLen, 1); |
1726 | 1746 | ||
1727 | list->len = le16_to_cpu(list->len); | 1747 | list->len = le16_to_cpu(list->len); |
1728 | list->index = le16_to_cpu(list->index); | 1748 | list->index = le16_to_cpu(list->index); |
@@ -2112,7 +2132,7 @@ static void airo_end_xmit(struct net_device *dev) { | |||
2112 | int fid = priv->xmit.fid; | 2132 | int fid = priv->xmit.fid; |
2113 | u32 *fids = priv->fids; | 2133 | u32 *fids = priv->fids; |
2114 | 2134 | ||
2115 | clear_bit(JOB_XMIT, &priv->flags); | 2135 | clear_bit(JOB_XMIT, &priv->jobs); |
2116 | clear_bit(FLAG_PENDING_XMIT, &priv->flags); | 2136 | clear_bit(FLAG_PENDING_XMIT, &priv->flags); |
2117 | status = transmit_802_3_packet (priv, fids[fid], skb->data); | 2137 | status = transmit_802_3_packet (priv, fids[fid], skb->data); |
2118 | up(&priv->sem); | 2138 | up(&priv->sem); |
@@ -2162,7 +2182,7 @@ static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) { | |||
2162 | if (down_trylock(&priv->sem) != 0) { | 2182 | if (down_trylock(&priv->sem) != 0) { |
2163 | set_bit(FLAG_PENDING_XMIT, &priv->flags); | 2183 | set_bit(FLAG_PENDING_XMIT, &priv->flags); |
2164 | netif_stop_queue(dev); | 2184 | netif_stop_queue(dev); |
2165 | set_bit(JOB_XMIT, &priv->flags); | 2185 | set_bit(JOB_XMIT, &priv->jobs); |
2166 | wake_up_interruptible(&priv->thr_wait); | 2186 | wake_up_interruptible(&priv->thr_wait); |
2167 | } else | 2187 | } else |
2168 | airo_end_xmit(dev); | 2188 | airo_end_xmit(dev); |
@@ -2177,7 +2197,7 @@ static void airo_end_xmit11(struct net_device *dev) { | |||
2177 | int fid = priv->xmit11.fid; | 2197 | int fid = priv->xmit11.fid; |
2178 | u32 *fids = priv->fids; | 2198 | u32 *fids = priv->fids; |
2179 | 2199 | ||
2180 | clear_bit(JOB_XMIT11, &priv->flags); | 2200 | clear_bit(JOB_XMIT11, &priv->jobs); |
2181 | clear_bit(FLAG_PENDING_XMIT11, &priv->flags); | 2201 | clear_bit(FLAG_PENDING_XMIT11, &priv->flags); |
2182 | status = transmit_802_11_packet (priv, fids[fid], skb->data); | 2202 | status = transmit_802_11_packet (priv, fids[fid], skb->data); |
2183 | up(&priv->sem); | 2203 | up(&priv->sem); |
@@ -2233,7 +2253,7 @@ static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) { | |||
2233 | if (down_trylock(&priv->sem) != 0) { | 2253 | if (down_trylock(&priv->sem) != 0) { |
2234 | set_bit(FLAG_PENDING_XMIT11, &priv->flags); | 2254 | set_bit(FLAG_PENDING_XMIT11, &priv->flags); |
2235 | netif_stop_queue(dev); | 2255 | netif_stop_queue(dev); |
2236 | set_bit(JOB_XMIT11, &priv->flags); | 2256 | set_bit(JOB_XMIT11, &priv->jobs); |
2237 | wake_up_interruptible(&priv->thr_wait); | 2257 | wake_up_interruptible(&priv->thr_wait); |
2238 | } else | 2258 | } else |
2239 | airo_end_xmit11(dev); | 2259 | airo_end_xmit11(dev); |
@@ -2244,7 +2264,7 @@ static void airo_read_stats(struct airo_info *ai) { | |||
2244 | StatsRid stats_rid; | 2264 | StatsRid stats_rid; |
2245 | u32 *vals = stats_rid.vals; | 2265 | u32 *vals = stats_rid.vals; |
2246 | 2266 | ||
2247 | clear_bit(JOB_STATS, &ai->flags); | 2267 | clear_bit(JOB_STATS, &ai->jobs); |
2248 | if (ai->power.event) { | 2268 | if (ai->power.event) { |
2249 | up(&ai->sem); | 2269 | up(&ai->sem); |
2250 | return; | 2270 | return; |
@@ -2272,10 +2292,10 @@ static struct net_device_stats *airo_get_stats(struct net_device *dev) | |||
2272 | { | 2292 | { |
2273 | struct airo_info *local = dev->priv; | 2293 | struct airo_info *local = dev->priv; |
2274 | 2294 | ||
2275 | if (!test_bit(JOB_STATS, &local->flags)) { | 2295 | if (!test_bit(JOB_STATS, &local->jobs)) { |
2276 | /* Get stats out of the card if available */ | 2296 | /* Get stats out of the card if available */ |
2277 | if (down_trylock(&local->sem) != 0) { | 2297 | if (down_trylock(&local->sem) != 0) { |
2278 | set_bit(JOB_STATS, &local->flags); | 2298 | set_bit(JOB_STATS, &local->jobs); |
2279 | wake_up_interruptible(&local->thr_wait); | 2299 | wake_up_interruptible(&local->thr_wait); |
2280 | } else | 2300 | } else |
2281 | airo_read_stats(local); | 2301 | airo_read_stats(local); |
@@ -2290,7 +2310,7 @@ static void airo_set_promisc(struct airo_info *ai) { | |||
2290 | 2310 | ||
2291 | memset(&cmd, 0, sizeof(cmd)); | 2311 | memset(&cmd, 0, sizeof(cmd)); |
2292 | cmd.cmd=CMD_SETMODE; | 2312 | cmd.cmd=CMD_SETMODE; |
2293 | clear_bit(JOB_PROMISC, &ai->flags); | 2313 | clear_bit(JOB_PROMISC, &ai->jobs); |
2294 | cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; | 2314 | cmd.parm0=(ai->flags&IFF_PROMISC) ? PROMISC : NOPROMISC; |
2295 | issuecommand(ai, &cmd, &rsp); | 2315 | issuecommand(ai, &cmd, &rsp); |
2296 | up(&ai->sem); | 2316 | up(&ai->sem); |
@@ -2302,7 +2322,7 @@ static void airo_set_multicast_list(struct net_device *dev) { | |||
2302 | if ((dev->flags ^ ai->flags) & IFF_PROMISC) { | 2322 | if ((dev->flags ^ ai->flags) & IFF_PROMISC) { |
2303 | change_bit(FLAG_PROMISC, &ai->flags); | 2323 | change_bit(FLAG_PROMISC, &ai->flags); |
2304 | if (down_trylock(&ai->sem) != 0) { | 2324 | if (down_trylock(&ai->sem) != 0) { |
2305 | set_bit(JOB_PROMISC, &ai->flags); | 2325 | set_bit(JOB_PROMISC, &ai->jobs); |
2306 | wake_up_interruptible(&ai->thr_wait); | 2326 | wake_up_interruptible(&ai->thr_wait); |
2307 | } else | 2327 | } else |
2308 | airo_set_promisc(ai); | 2328 | airo_set_promisc(ai); |
@@ -2380,7 +2400,7 @@ void stop_airo_card( struct net_device *dev, int freeres ) | |||
2380 | } | 2400 | } |
2381 | clear_bit(FLAG_REGISTERED, &ai->flags); | 2401 | clear_bit(FLAG_REGISTERED, &ai->flags); |
2382 | } | 2402 | } |
2383 | set_bit(JOB_DIE, &ai->flags); | 2403 | set_bit(JOB_DIE, &ai->jobs); |
2384 | kill_proc(ai->thr_pid, SIGTERM, 1); | 2404 | kill_proc(ai->thr_pid, SIGTERM, 1); |
2385 | wait_for_completion(&ai->thr_exited); | 2405 | wait_for_completion(&ai->thr_exited); |
2386 | 2406 | ||
@@ -2701,14 +2721,14 @@ static int reset_card( struct net_device *dev , int lock) { | |||
2701 | return 0; | 2721 | return 0; |
2702 | } | 2722 | } |
2703 | 2723 | ||
2704 | #define MAX_NETWORK_COUNT 64 | 2724 | #define AIRO_MAX_NETWORK_COUNT 64 |
2705 | static int airo_networks_allocate(struct airo_info *ai) | 2725 | static int airo_networks_allocate(struct airo_info *ai) |
2706 | { | 2726 | { |
2707 | if (ai->networks) | 2727 | if (ai->networks) |
2708 | return 0; | 2728 | return 0; |
2709 | 2729 | ||
2710 | ai->networks = | 2730 | ai->networks = |
2711 | kzalloc(MAX_NETWORK_COUNT * sizeof(BSSListElement), | 2731 | kzalloc(AIRO_MAX_NETWORK_COUNT * sizeof(BSSListElement), |
2712 | GFP_KERNEL); | 2732 | GFP_KERNEL); |
2713 | if (!ai->networks) { | 2733 | if (!ai->networks) { |
2714 | airo_print_warn(ai->dev->name, "Out of memory allocating beacons"); | 2734 | airo_print_warn(ai->dev->name, "Out of memory allocating beacons"); |
@@ -2732,11 +2752,33 @@ static void airo_networks_initialize(struct airo_info *ai) | |||
2732 | 2752 | ||
2733 | INIT_LIST_HEAD(&ai->network_free_list); | 2753 | INIT_LIST_HEAD(&ai->network_free_list); |
2734 | INIT_LIST_HEAD(&ai->network_list); | 2754 | INIT_LIST_HEAD(&ai->network_list); |
2735 | for (i = 0; i < MAX_NETWORK_COUNT; i++) | 2755 | for (i = 0; i < AIRO_MAX_NETWORK_COUNT; i++) |
2736 | list_add_tail(&ai->networks[i].list, | 2756 | list_add_tail(&ai->networks[i].list, |
2737 | &ai->network_free_list); | 2757 | &ai->network_free_list); |
2738 | } | 2758 | } |
2739 | 2759 | ||
2760 | static int airo_test_wpa_capable(struct airo_info *ai) | ||
2761 | { | ||
2762 | int status; | ||
2763 | CapabilityRid cap_rid; | ||
2764 | const char *name = ai->dev->name; | ||
2765 | |||
2766 | status = readCapabilityRid(ai, &cap_rid, 1); | ||
2767 | if (status != SUCCESS) return 0; | ||
2768 | |||
2769 | /* Only firmware versions 5.30.17 or better can do WPA */ | ||
2770 | if ((cap_rid.softVer > 0x530) | ||
2771 | || ((cap_rid.softVer == 0x530) && (cap_rid.softSubVer >= 0x17))) { | ||
2772 | airo_print_info(name, "WPA is supported."); | ||
2773 | return 1; | ||
2774 | } | ||
2775 | |||
2776 | /* No WPA support */ | ||
2777 | airo_print_info(name, "WPA unsupported (only firmware versions 5.30.17" | ||
2778 | " and greater support WPA. Detected %s)", cap_rid.prodVer); | ||
2779 | return 0; | ||
2780 | } | ||
2781 | |||
2740 | static struct net_device *_init_airo_card( unsigned short irq, int port, | 2782 | static struct net_device *_init_airo_card( unsigned short irq, int port, |
2741 | int is_pcmcia, struct pci_dev *pci, | 2783 | int is_pcmcia, struct pci_dev *pci, |
2742 | struct device *dmdev ) | 2784 | struct device *dmdev ) |
@@ -2759,6 +2801,7 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2759 | ai = dev->priv; | 2801 | ai = dev->priv; |
2760 | ai->wifidev = NULL; | 2802 | ai->wifidev = NULL; |
2761 | ai->flags = 0; | 2803 | ai->flags = 0; |
2804 | ai->jobs = 0; | ||
2762 | ai->dev = dev; | 2805 | ai->dev = dev; |
2763 | if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { | 2806 | if (pci && (pci->device == 0x5000 || pci->device == 0xa504)) { |
2764 | airo_print_dbg(dev->name, "Found an MPI350 card"); | 2807 | airo_print_dbg(dev->name, "Found an MPI350 card"); |
@@ -2838,6 +2881,18 @@ static struct net_device *_init_airo_card( unsigned short irq, int port, | |||
2838 | set_bit(FLAG_FLASHING, &ai->flags); | 2881 | set_bit(FLAG_FLASHING, &ai->flags); |
2839 | } | 2882 | } |
2840 | 2883 | ||
2884 | /* Test for WPA support */ | ||
2885 | if (airo_test_wpa_capable(ai)) { | ||
2886 | set_bit(FLAG_WPA_CAPABLE, &ai->flags); | ||
2887 | ai->bssListFirst = RID_WPA_BSSLISTFIRST; | ||
2888 | ai->bssListNext = RID_WPA_BSSLISTNEXT; | ||
2889 | ai->bssListRidLen = sizeof(BSSListRid); | ||
2890 | } else { | ||
2891 | ai->bssListFirst = RID_BSSLISTFIRST; | ||
2892 | ai->bssListNext = RID_BSSLISTNEXT; | ||
2893 | ai->bssListRidLen = sizeof(BSSListRid) - sizeof(BSSListRidExtra); | ||
2894 | } | ||
2895 | |||
2841 | rc = register_netdev(dev); | 2896 | rc = register_netdev(dev); |
2842 | if (rc) { | 2897 | if (rc) { |
2843 | airo_print_err(dev->name, "Couldn't register_netdev"); | 2898 | airo_print_err(dev->name, "Couldn't register_netdev"); |
@@ -2875,7 +2930,7 @@ err_out_irq: | |||
2875 | err_out_unlink: | 2930 | err_out_unlink: |
2876 | del_airo_dev(dev); | 2931 | del_airo_dev(dev); |
2877 | err_out_thr: | 2932 | err_out_thr: |
2878 | set_bit(JOB_DIE, &ai->flags); | 2933 | set_bit(JOB_DIE, &ai->jobs); |
2879 | kill_proc(ai->thr_pid, SIGTERM, 1); | 2934 | kill_proc(ai->thr_pid, SIGTERM, 1); |
2880 | wait_for_completion(&ai->thr_exited); | 2935 | wait_for_completion(&ai->thr_exited); |
2881 | err_out_free: | 2936 | err_out_free: |
@@ -2933,7 +2988,7 @@ static void airo_send_event(struct net_device *dev) { | |||
2933 | union iwreq_data wrqu; | 2988 | union iwreq_data wrqu; |
2934 | StatusRid status_rid; | 2989 | StatusRid status_rid; |
2935 | 2990 | ||
2936 | clear_bit(JOB_EVENT, &ai->flags); | 2991 | clear_bit(JOB_EVENT, &ai->jobs); |
2937 | PC4500_readrid(ai, RID_STATUS, &status_rid, sizeof(status_rid), 0); | 2992 | PC4500_readrid(ai, RID_STATUS, &status_rid, sizeof(status_rid), 0); |
2938 | up(&ai->sem); | 2993 | up(&ai->sem); |
2939 | wrqu.data.length = 0; | 2994 | wrqu.data.length = 0; |
@@ -2947,7 +3002,7 @@ static void airo_send_event(struct net_device *dev) { | |||
2947 | 3002 | ||
2948 | static void airo_process_scan_results (struct airo_info *ai) { | 3003 | static void airo_process_scan_results (struct airo_info *ai) { |
2949 | union iwreq_data wrqu; | 3004 | union iwreq_data wrqu; |
2950 | BSSListRid BSSList; | 3005 | BSSListRid bss; |
2951 | int rc; | 3006 | int rc; |
2952 | BSSListElement * loop_net; | 3007 | BSSListElement * loop_net; |
2953 | BSSListElement * tmp_net; | 3008 | BSSListElement * tmp_net; |
@@ -2960,15 +3015,15 @@ static void airo_process_scan_results (struct airo_info *ai) { | |||
2960 | } | 3015 | } |
2961 | 3016 | ||
2962 | /* Try to read the first entry of the scan result */ | 3017 | /* Try to read the first entry of the scan result */ |
2963 | rc = PC4500_readrid(ai, RID_BSSLISTFIRST, &BSSList, sizeof(BSSList), 0); | 3018 | rc = PC4500_readrid(ai, ai->bssListFirst, &bss, ai->bssListRidLen, 0); |
2964 | if((rc) || (BSSList.index == 0xffff)) { | 3019 | if((rc) || (bss.index == 0xffff)) { |
2965 | /* No scan results */ | 3020 | /* No scan results */ |
2966 | goto out; | 3021 | goto out; |
2967 | } | 3022 | } |
2968 | 3023 | ||
2969 | /* Read and parse all entries */ | 3024 | /* Read and parse all entries */ |
2970 | tmp_net = NULL; | 3025 | tmp_net = NULL; |
2971 | while((!rc) && (BSSList.index != 0xffff)) { | 3026 | while((!rc) && (bss.index != 0xffff)) { |
2972 | /* Grab a network off the free list */ | 3027 | /* Grab a network off the free list */ |
2973 | if (!list_empty(&ai->network_free_list)) { | 3028 | if (!list_empty(&ai->network_free_list)) { |
2974 | tmp_net = list_entry(ai->network_free_list.next, | 3029 | tmp_net = list_entry(ai->network_free_list.next, |
@@ -2977,19 +3032,19 @@ static void airo_process_scan_results (struct airo_info *ai) { | |||
2977 | } | 3032 | } |
2978 | 3033 | ||
2979 | if (tmp_net != NULL) { | 3034 | if (tmp_net != NULL) { |
2980 | memcpy(tmp_net, &BSSList, sizeof(tmp_net->bss)); | 3035 | memcpy(tmp_net, &bss, sizeof(tmp_net->bss)); |
2981 | list_add_tail(&tmp_net->list, &ai->network_list); | 3036 | list_add_tail(&tmp_net->list, &ai->network_list); |
2982 | tmp_net = NULL; | 3037 | tmp_net = NULL; |
2983 | } | 3038 | } |
2984 | 3039 | ||
2985 | /* Read next entry */ | 3040 | /* Read next entry */ |
2986 | rc = PC4500_readrid(ai, RID_BSSLISTNEXT, | 3041 | rc = PC4500_readrid(ai, ai->bssListNext, |
2987 | &BSSList, sizeof(BSSList), 0); | 3042 | &bss, ai->bssListRidLen, 0); |
2988 | } | 3043 | } |
2989 | 3044 | ||
2990 | out: | 3045 | out: |
2991 | ai->scan_timeout = 0; | 3046 | ai->scan_timeout = 0; |
2992 | clear_bit(JOB_SCAN_RESULTS, &ai->flags); | 3047 | clear_bit(JOB_SCAN_RESULTS, &ai->jobs); |
2993 | up(&ai->sem); | 3048 | up(&ai->sem); |
2994 | 3049 | ||
2995 | /* Send an empty event to user space. | 3050 | /* Send an empty event to user space. |
@@ -3019,10 +3074,10 @@ static int airo_thread(void *data) { | |||
3019 | /* make swsusp happy with our thread */ | 3074 | /* make swsusp happy with our thread */ |
3020 | try_to_freeze(); | 3075 | try_to_freeze(); |
3021 | 3076 | ||
3022 | if (test_bit(JOB_DIE, &ai->flags)) | 3077 | if (test_bit(JOB_DIE, &ai->jobs)) |
3023 | break; | 3078 | break; |
3024 | 3079 | ||
3025 | if (ai->flags & JOB_MASK) { | 3080 | if (ai->jobs) { |
3026 | locked = down_interruptible(&ai->sem); | 3081 | locked = down_interruptible(&ai->sem); |
3027 | } else { | 3082 | } else { |
3028 | wait_queue_t wait; | 3083 | wait_queue_t wait; |
@@ -3031,16 +3086,16 @@ static int airo_thread(void *data) { | |||
3031 | add_wait_queue(&ai->thr_wait, &wait); | 3086 | add_wait_queue(&ai->thr_wait, &wait); |
3032 | for (;;) { | 3087 | for (;;) { |
3033 | set_current_state(TASK_INTERRUPTIBLE); | 3088 | set_current_state(TASK_INTERRUPTIBLE); |
3034 | if (ai->flags & JOB_MASK) | 3089 | if (ai->jobs) |
3035 | break; | 3090 | break; |
3036 | if (ai->expires || ai->scan_timeout) { | 3091 | if (ai->expires || ai->scan_timeout) { |
3037 | if (ai->scan_timeout && | 3092 | if (ai->scan_timeout && |
3038 | time_after_eq(jiffies,ai->scan_timeout)){ | 3093 | time_after_eq(jiffies,ai->scan_timeout)){ |
3039 | set_bit(JOB_SCAN_RESULTS,&ai->flags); | 3094 | set_bit(JOB_SCAN_RESULTS, &ai->jobs); |
3040 | break; | 3095 | break; |
3041 | } else if (ai->expires && | 3096 | } else if (ai->expires && |
3042 | time_after_eq(jiffies,ai->expires)){ | 3097 | time_after_eq(jiffies,ai->expires)){ |
3043 | set_bit(JOB_AUTOWEP,&ai->flags); | 3098 | set_bit(JOB_AUTOWEP, &ai->jobs); |
3044 | break; | 3099 | break; |
3045 | } | 3100 | } |
3046 | if (!signal_pending(current)) { | 3101 | if (!signal_pending(current)) { |
@@ -3069,7 +3124,7 @@ static int airo_thread(void *data) { | |||
3069 | if (locked) | 3124 | if (locked) |
3070 | continue; | 3125 | continue; |
3071 | 3126 | ||
3072 | if (test_bit(JOB_DIE, &ai->flags)) { | 3127 | if (test_bit(JOB_DIE, &ai->jobs)) { |
3073 | up(&ai->sem); | 3128 | up(&ai->sem); |
3074 | break; | 3129 | break; |
3075 | } | 3130 | } |
@@ -3079,23 +3134,23 @@ static int airo_thread(void *data) { | |||
3079 | continue; | 3134 | continue; |
3080 | } | 3135 | } |
3081 | 3136 | ||
3082 | if (test_bit(JOB_XMIT, &ai->flags)) | 3137 | if (test_bit(JOB_XMIT, &ai->jobs)) |
3083 | airo_end_xmit(dev); | 3138 | airo_end_xmit(dev); |
3084 | else if (test_bit(JOB_XMIT11, &ai->flags)) | 3139 | else if (test_bit(JOB_XMIT11, &ai->jobs)) |
3085 | airo_end_xmit11(dev); | 3140 | airo_end_xmit11(dev); |
3086 | else if (test_bit(JOB_STATS, &ai->flags)) | 3141 | else if (test_bit(JOB_STATS, &ai->jobs)) |
3087 | airo_read_stats(ai); | 3142 | airo_read_stats(ai); |
3088 | else if (test_bit(JOB_WSTATS, &ai->flags)) | 3143 | else if (test_bit(JOB_WSTATS, &ai->jobs)) |
3089 | airo_read_wireless_stats(ai); | 3144 | airo_read_wireless_stats(ai); |
3090 | else if (test_bit(JOB_PROMISC, &ai->flags)) | 3145 | else if (test_bit(JOB_PROMISC, &ai->jobs)) |
3091 | airo_set_promisc(ai); | 3146 | airo_set_promisc(ai); |
3092 | else if (test_bit(JOB_MIC, &ai->flags)) | 3147 | else if (test_bit(JOB_MIC, &ai->jobs)) |
3093 | micinit(ai); | 3148 | micinit(ai); |
3094 | else if (test_bit(JOB_EVENT, &ai->flags)) | 3149 | else if (test_bit(JOB_EVENT, &ai->jobs)) |
3095 | airo_send_event(dev); | 3150 | airo_send_event(dev); |
3096 | else if (test_bit(JOB_AUTOWEP, &ai->flags)) | 3151 | else if (test_bit(JOB_AUTOWEP, &ai->jobs)) |
3097 | timer_func(dev); | 3152 | timer_func(dev); |
3098 | else if (test_bit(JOB_SCAN_RESULTS, &ai->flags)) | 3153 | else if (test_bit(JOB_SCAN_RESULTS, &ai->jobs)) |
3099 | airo_process_scan_results(ai); | 3154 | airo_process_scan_results(ai); |
3100 | else /* Shouldn't get here, but we make sure to unlock */ | 3155 | else /* Shouldn't get here, but we make sure to unlock */ |
3101 | up(&ai->sem); | 3156 | up(&ai->sem); |
@@ -3133,7 +3188,7 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs) | |||
3133 | if ( status & EV_MIC ) { | 3188 | if ( status & EV_MIC ) { |
3134 | OUT4500( apriv, EVACK, EV_MIC ); | 3189 | OUT4500( apriv, EVACK, EV_MIC ); |
3135 | if (test_bit(FLAG_MIC_CAPABLE, &apriv->flags)) { | 3190 | if (test_bit(FLAG_MIC_CAPABLE, &apriv->flags)) { |
3136 | set_bit(JOB_MIC, &apriv->flags); | 3191 | set_bit(JOB_MIC, &apriv->jobs); |
3137 | wake_up_interruptible(&apriv->thr_wait); | 3192 | wake_up_interruptible(&apriv->thr_wait); |
3138 | } | 3193 | } |
3139 | } | 3194 | } |
@@ -3187,7 +3242,7 @@ static irqreturn_t airo_interrupt ( int irq, void* dev_id, struct pt_regs *regs) | |||
3187 | set_bit(FLAG_UPDATE_MULTI, &apriv->flags); | 3242 | set_bit(FLAG_UPDATE_MULTI, &apriv->flags); |
3188 | 3243 | ||
3189 | if (down_trylock(&apriv->sem) != 0) { | 3244 | if (down_trylock(&apriv->sem) != 0) { |
3190 | set_bit(JOB_EVENT, &apriv->flags); | 3245 | set_bit(JOB_EVENT, &apriv->jobs); |
3191 | wake_up_interruptible(&apriv->thr_wait); | 3246 | wake_up_interruptible(&apriv->thr_wait); |
3192 | } else | 3247 | } else |
3193 | airo_send_event(dev); | 3248 | airo_send_event(dev); |
@@ -5485,7 +5540,7 @@ static void timer_func( struct net_device *dev ) { | |||
5485 | up(&apriv->sem); | 5540 | up(&apriv->sem); |
5486 | 5541 | ||
5487 | /* Schedule check to see if the change worked */ | 5542 | /* Schedule check to see if the change worked */ |
5488 | clear_bit(JOB_AUTOWEP, &apriv->flags); | 5543 | clear_bit(JOB_AUTOWEP, &apriv->jobs); |
5489 | apriv->expires = RUN_AT(HZ*3); | 5544 | apriv->expires = RUN_AT(HZ*3); |
5490 | } | 5545 | } |
5491 | 5546 | ||
@@ -6876,7 +6931,7 @@ static int airo_get_range(struct net_device *dev, | |||
6876 | } | 6931 | } |
6877 | range->num_txpower = i; | 6932 | range->num_txpower = i; |
6878 | range->txpower_capa = IW_TXPOW_MWATT; | 6933 | range->txpower_capa = IW_TXPOW_MWATT; |
6879 | range->we_version_source = 12; | 6934 | range->we_version_source = 19; |
6880 | range->we_version_compiled = WIRELESS_EXT; | 6935 | range->we_version_compiled = WIRELESS_EXT; |
6881 | range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME; | 6936 | range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME; |
6882 | range->retry_flags = IW_RETRY_LIMIT; | 6937 | range->retry_flags = IW_RETRY_LIMIT; |
@@ -7152,6 +7207,7 @@ static inline char *airo_translate_scan(struct net_device *dev, | |||
7152 | u16 capabilities; | 7207 | u16 capabilities; |
7153 | char * current_val; /* For rates */ | 7208 | char * current_val; /* For rates */ |
7154 | int i; | 7209 | int i; |
7210 | char * buf; | ||
7155 | 7211 | ||
7156 | /* First entry *MUST* be the AP MAC address */ | 7212 | /* First entry *MUST* be the AP MAC address */ |
7157 | iwe.cmd = SIOCGIWAP; | 7213 | iwe.cmd = SIOCGIWAP; |
@@ -7238,8 +7294,69 @@ static inline char *airo_translate_scan(struct net_device *dev, | |||
7238 | if((current_val - current_ev) > IW_EV_LCP_LEN) | 7294 | if((current_val - current_ev) > IW_EV_LCP_LEN) |
7239 | current_ev = current_val; | 7295 | current_ev = current_val; |
7240 | 7296 | ||
7241 | /* The other data in the scan result are not really | 7297 | /* Beacon interval */ |
7242 | * interesting, so for now drop it - Jean II */ | 7298 | buf = kmalloc(30, GFP_KERNEL); |
7299 | if (buf) { | ||
7300 | iwe.cmd = IWEVCUSTOM; | ||
7301 | sprintf(buf, "bcn_int=%d", bss->beaconInterval); | ||
7302 | iwe.u.data.length = strlen(buf); | ||
7303 | current_ev = iwe_stream_add_point(current_ev, end_buf, &iwe, buf); | ||
7304 | kfree(buf); | ||
7305 | } | ||
7306 | |||
7307 | /* Put WPA/RSN Information Elements into the event stream */ | ||
7308 | if (test_bit(FLAG_WPA_CAPABLE, &ai->flags)) { | ||
7309 | unsigned int num_null_ies = 0; | ||
7310 | u16 length = sizeof (bss->extra.iep); | ||
7311 | struct ieee80211_info_element *info_element = | ||
7312 | (struct ieee80211_info_element *) &bss->extra.iep; | ||
7313 | |||
7314 | while ((length >= sizeof(*info_element)) && (num_null_ies < 2)) { | ||
7315 | if (sizeof(*info_element) + info_element->len > length) { | ||
7316 | /* Invalid element, don't continue parsing IE */ | ||
7317 | break; | ||
7318 | } | ||
7319 | |||
7320 | switch (info_element->id) { | ||
7321 | case MFIE_TYPE_SSID: | ||
7322 | /* Two zero-length SSID elements | ||
7323 | * mean we're done parsing elements */ | ||
7324 | if (!info_element->len) | ||
7325 | num_null_ies++; | ||
7326 | break; | ||
7327 | |||
7328 | case MFIE_TYPE_GENERIC: | ||
7329 | if (info_element->len >= 4 && | ||
7330 | info_element->data[0] == 0x00 && | ||
7331 | info_element->data[1] == 0x50 && | ||
7332 | info_element->data[2] == 0xf2 && | ||
7333 | info_element->data[3] == 0x01) { | ||
7334 | iwe.cmd = IWEVGENIE; | ||
7335 | iwe.u.data.length = min(info_element->len + 2, | ||
7336 | MAX_WPA_IE_LEN); | ||
7337 | current_ev = iwe_stream_add_point(current_ev, end_buf, | ||
7338 | &iwe, (char *) info_element); | ||
7339 | } | ||
7340 | break; | ||
7341 | |||
7342 | case MFIE_TYPE_RSN: | ||
7343 | iwe.cmd = IWEVGENIE; | ||
7344 | iwe.u.data.length = min(info_element->len + 2, | ||
7345 | MAX_WPA_IE_LEN); | ||
7346 | current_ev = iwe_stream_add_point(current_ev, end_buf, | ||
7347 | &iwe, (char *) info_element); | ||
7348 | break; | ||
7349 | |||
7350 | default: | ||
7351 | break; | ||
7352 | } | ||
7353 | |||
7354 | length -= sizeof(*info_element) + info_element->len; | ||
7355 | info_element = | ||
7356 | (struct ieee80211_info_element *)&info_element-> | ||
7357 | data[info_element->len]; | ||
7358 | } | ||
7359 | } | ||
7243 | return current_ev; | 7360 | return current_ev; |
7244 | } | 7361 | } |
7245 | 7362 | ||
@@ -7521,7 +7638,7 @@ static void airo_read_wireless_stats(struct airo_info *local) | |||
7521 | u32 *vals = stats_rid.vals; | 7638 | u32 *vals = stats_rid.vals; |
7522 | 7639 | ||
7523 | /* Get stats out of the card */ | 7640 | /* Get stats out of the card */ |
7524 | clear_bit(JOB_WSTATS, &local->flags); | 7641 | clear_bit(JOB_WSTATS, &local->jobs); |
7525 | if (local->power.event) { | 7642 | if (local->power.event) { |
7526 | up(&local->sem); | 7643 | up(&local->sem); |
7527 | return; | 7644 | return; |
@@ -7565,10 +7682,10 @@ static struct iw_statistics *airo_get_wireless_stats(struct net_device *dev) | |||
7565 | { | 7682 | { |
7566 | struct airo_info *local = dev->priv; | 7683 | struct airo_info *local = dev->priv; |
7567 | 7684 | ||
7568 | if (!test_bit(JOB_WSTATS, &local->flags)) { | 7685 | if (!test_bit(JOB_WSTATS, &local->jobs)) { |
7569 | /* Get stats out of the card if available */ | 7686 | /* Get stats out of the card if available */ |
7570 | if (down_trylock(&local->sem) != 0) { | 7687 | if (down_trylock(&local->sem) != 0) { |
7571 | set_bit(JOB_WSTATS, &local->flags); | 7688 | set_bit(JOB_WSTATS, &local->jobs); |
7572 | wake_up_interruptible(&local->thr_wait); | 7689 | wake_up_interruptible(&local->thr_wait); |
7573 | } else | 7690 | } else |
7574 | airo_read_wireless_stats(local); | 7691 | airo_read_wireless_stats(local); |