patch staging-remove-at76_usb-wireless-driver.patch added to gregkh-2.6 tree
[email protected]
AppliedThis is a note to let you know that I've just added the patch titled
Subject: Staging: remove at76_usb wireless driver.
to my gregkh-2.6 tree. Its filename is
staging-remove-at76_usb-wireless-driver.patch
This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/
Quoted 1 line
From foo@baz Thu Sep 3 11:58:09 PDT 2009
Date: Thu, 03 Sep 2009 11:58:09 -0700
To: Greg KH <[email protected]>
From: Greg Kroah-Hartman <[email protected]>
Subject: Staging: remove at76_usb wireless driver.
There is already an in-kernel driver for this hardware (since 2.6.30), at76c50x-usb, and it supports all of the same devices. So this driver can now be deleted.
--- drivers/staging/Kconfig | 2 drivers/staging/Makefile | 1 drivers/staging/at76_usb/Kconfig | 8 drivers/staging/at76_usb/Makefile | 1 drivers/staging/at76_usb/TODO | 7 drivers/staging/at76_usb/at76_usb.c | 5566 ------------------------------------ drivers/staging/at76_usb/at76_usb.h | 706 ---- 7 files changed, 6291 deletions(-)
drivers/staging/at76_usb/at76_usb.c deleted +0 -5566
@@ -1,5566 +0,0 @@ -/* -* at76c503/at76c505 USB driver -* -* Copyright (c) 2002 - 2003 Oliver Kurth -* Copyright (c) 2004 Joerg Albert <[email protected]> -* Copyright (c) 2004 Nick Jones -* Copyright (c) 2004 Balint Seeber <[email protected]> -* Copyright (c) 2007 Guido Guenther <[email protected]> -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License, or (at your option) any later version. -* -* This file is part of the Berlios driver for WLAN USB devices based on the -* Atmel AT76C503A/505/505A. -* -* Some iw_handler code was taken from airo.c, (C) 1999 Benjamin Reed -*/ - -#include <linux/init.h> -#include <linux/kernel.h> -#include <linux/sched.h> -#include <linux/errno.h> -#include <linux/slab.h> -#include <linux/module.h> -#include <linux/spinlock.h> -#include <linux/list.h> -#include <linux/usb.h> -#include <linux/netdevice.h> -#include <linux/if_arp.h> -#include <linux/etherdevice.h> -#include <linux/ethtool.h> -#include <linux/wireless.h> -#include <net/iw_handler.h> -#include <net/ieee80211_radiotap.h> -#include <linux/firmware.h> -#include <linux/leds.h> -#include <linux/ieee80211.h> - -#include "at76_usb.h" - -/* Version information */ -#define DRIVER_NAME "at76_usb" -#define DRIVER_VERSION "0.17" -#define DRIVER_DESC "Atmel at76x USB Wireless LAN Driver" - -/* at76_debug bits */ -#define DBG_PROGRESS 0x00000001/* authentication/accociation */ -#define DBG_BSS_TABLE 0x00000002/* show BSS table after scans */ -#define DBG_IOCTL 0x00000004/* ioctl calls / settings */ -#define DBG_MAC_STATE 0x00000008/* MAC state transitions */ -#define DBG_TX_DATA 0x00000010/* tx header */ -#define DBG_TX_DATA_CONTENT 0x00000020/* tx content */ -#define DBG_TX_MGMT 0x00000040/* tx management */ -#define DBG_RX_DATA 0x00000080/* rx data header */ -#define DBG_RX_DATA_CONTENT 0x00000100/* rx data content */ -#define DBG_RX_MGMT 0x00000200/* rx mgmt frame headers */ -#define DBG_RX_BEACON 0x00000400/* rx beacon */ -#define DBG_RX_CTRL 0x00000800/* rx control */ -#define DBG_RX_MGMT_CONTENT 0x00001000/* rx mgmt content */ -#define DBG_RX_FRAGS 0x00002000/* rx data fragment handling */ -#define DBG_DEVSTART 0x00004000/* fw download, device start */ -#define DBG_URB 0x00008000/* rx urb status, ... */ -#define DBG_RX_ATMEL_HDR 0x00010000/* Atmel-specific Rx headers */ -#define DBG_PROC_ENTRY 0x00020000/* procedure entries/exits */ -#define DBG_PM 0x00040000/* power management settings */ -#define DBG_BSS_MATCH 0x00080000/* BSS match failures */ -#define DBG_PARAMS 0x00100000/* show configured parameters */ -#define DBG_WAIT_COMPLETE 0x00200000/* command completion */ -#define DBG_RX_FRAGS_SKB 0x00400000/* skb header of Rx fragments */ -#define DBG_BSS_TABLE_RM 0x00800000/* purging bss table entries */ -#define DBG_MONITOR_MODE 0x01000000/* monitor mode */ -#define DBG_MIB 0x02000000/* dump all MIBs on startup */ -#define DBG_MGMT_TIMER 0x04000000/* dump mgmt_timer ops */ -#define DBG_WE_EVENTS 0x08000000/* dump wireless events */ -#define DBG_FW 0x10000000/* firmware download */ -#define DBG_DFU 0x20000000/* device firmware upgrade */ - -#define DBG_DEFAULTS 0 - -/* Use our own dbg macro */ -#define at76_dbg(bits, format, arg...) \ - do { \ - if (at76_debug & (bits)) \ - printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , ## arg); \ - } while (0) - -static int at76_debug =DBG_DEFAULTS ; - -/* Protect against concurrent firmware loading and parsing */ -static struct mutex fw_mutex; - -static struct fwentry firmwares[] = { - [0 ] = {"" }, - [BOARD_503_ISL3861 ] = {"atmel_at76c503-i3861.bin" }, - [BOARD_503_ISL3863 ] = {"atmel_at76c503-i3863.bin" }, - [BOARD_503 ] = {"atmel_at76c503-rfmd.bin" }, - [BOARD_503_ACC ] = {"atmel_at76c503-rfmd-acc.bin" }, - [BOARD_505 ] = {"atmel_at76c505-rfmd.bin" }, - [BOARD_505_2958 ] = {"atmel_at76c505-rfmd2958.bin" }, - [BOARD_505A ] = {"atmel_at76c505a-rfmd2958.bin" }, - [BOARD_505AMX ] = {"atmel_at76c505amx-rfmd.bin" }, -}; - -#define USB_DEVICE_DATA (__ops) .driver_info = (kernel_ulong_t)(__ops) - -static struct usb_device_id dev_table[] = { -/* -* at76c503-i3861 -*/ -/* Generic AT76C503/3861 device */ - {USB_DEVICE (0x03eb ,0x7603 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* Linksys WUSB11 v2.1/v2.6 */ - {USB_DEVICE (0x066b ,0x2211 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* Netgear MA101 rev. A */ - {USB_DEVICE (0x0864 ,0x4100 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* Tekram U300C / Allnet ALL0193 */ - {USB_DEVICE (0x0b3b ,0x1612 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* HP HN210W J7801A */ - {USB_DEVICE (0x03f0 ,0x011c ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* Sitecom/Z-Com/Zyxel M4Y-750 */ - {USB_DEVICE (0x0cde ,0x0001 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* Dynalink/Askey WLL013 (intersil) */ - {USB_DEVICE (0x069a ,0x0320 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* EZ connect 11Mpbs Wireless USB Adapter SMC2662W v1 */ - {USB_DEVICE (0x0d5c ,0xa001 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* BenQ AWL300 */ - {USB_DEVICE (0x04a5 ,0x9000 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* Addtron AWU-120, Compex WLU11 */ - {USB_DEVICE (0x05dd ,0xff31 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* Intel AP310 AnyPoint II USB */ - {USB_DEVICE (0x8086 ,0x0200 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* Dynalink L11U */ - {USB_DEVICE (0x0d8e ,0x7100 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* Arescom WL-210, FCC id 07J-GL2411USB */ - {USB_DEVICE (0x0d8e ,0x7110 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* I-O DATA WN-B11/USB */ - {USB_DEVICE (0x04bb ,0x0919 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* BT Voyager 1010 */ - {USB_DEVICE (0x069a ,0x0821 ),USB_DEVICE_DATA (BOARD_503_ISL3861 )}, -/* -* at76c503-i3863 -*/ -/* Generic AT76C503/3863 device */ - {USB_DEVICE (0x03eb ,0x7604 ),USB_DEVICE_DATA (BOARD_503_ISL3863 )}, -/* Samsung SWL-2100U */ - {USB_DEVICE (0x055d ,0xa000 ),USB_DEVICE_DATA (BOARD_503_ISL3863 )}, -/* -* at76c503-rfmd -*/ -/* Generic AT76C503/RFMD device */ - {USB_DEVICE (0x03eb ,0x7605 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Dynalink/Askey WLL013 (rfmd) */ - {USB_DEVICE (0x069a ,0x0321 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Linksys WUSB11 v2.6 */ - {USB_DEVICE (0x077b ,0x2219 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Network Everywhere NWU11B */ - {USB_DEVICE (0x077b ,0x2227 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Netgear MA101 rev. B */ - {USB_DEVICE (0x0864 ,0x4102 ),USB_DEVICE_DATA (BOARD_503 )}, -/* D-Link DWL-120 rev. E */ - {USB_DEVICE (0x2001 ,0x3200 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Actiontec 802UAT1, HWU01150-01UK */ - {USB_DEVICE (0x1668 ,0x7605 ),USB_DEVICE_DATA (BOARD_503 )}, -/* AirVast W-Buddie WN210 */ - {USB_DEVICE (0x03eb ,0x4102 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Dick Smith Electronics XH1153 802.11b USB adapter */ - {USB_DEVICE (0x1371 ,0x5743 ),USB_DEVICE_DATA (BOARD_503 )}, -/* CNet CNUSB611 */ - {USB_DEVICE (0x1371 ,0x0001 ),USB_DEVICE_DATA (BOARD_503 )}, -/* FiberLine FL-WL200U */ - {USB_DEVICE (0x1371 ,0x0002 ),USB_DEVICE_DATA (BOARD_503 )}, -/* BenQ AWL400 USB stick */ - {USB_DEVICE (0x04a5 ,0x9001 ),USB_DEVICE_DATA (BOARD_503 )}, -/* 3Com 3CRSHEW696 */ - {USB_DEVICE (0x0506 ,0x0a01 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Siemens Santis ADSL WLAN USB adapter WLL 013 */ - {USB_DEVICE (0x0681 ,0x001b ),USB_DEVICE_DATA (BOARD_503 )}, -/* Belkin F5D6050, version 2 */ - {USB_DEVICE (0x050d ,0x0050 ),USB_DEVICE_DATA (BOARD_503 )}, -/* iBlitzz, BWU613 (not *B or *SB) */ - {USB_DEVICE (0x07b8 ,0xb000 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Gigabyte GN-WLBM101 */ - {USB_DEVICE (0x1044 ,0x8003 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Planex GW-US11S */ - {USB_DEVICE (0x2019 ,0x3220 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Internal WLAN adapter in h5[4,5]xx series iPAQs */ - {USB_DEVICE (0x049f ,0x0032 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Corega Wireless LAN USB-11 mini */ - {USB_DEVICE (0x07aa ,0x0011 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Corega Wireless LAN USB-11 mini2 */ - {USB_DEVICE (0x07aa ,0x0018 ),USB_DEVICE_DATA (BOARD_503 )}, -/* Uniden PCW100 */ - {USB_DEVICE (0x05dd ,0xff35 ),USB_DEVICE_DATA (BOARD_503 )}, -/* -* at76c503-rfmd-acc -*/ -/* SMC2664W */ - {USB_DEVICE (0x083a ,0x3501 ),USB_DEVICE_DATA (BOARD_503_ACC )}, -/* Belkin F5D6050, SMC2662W v2, SMC2662W-AR */ - {USB_DEVICE (0x0d5c ,0xa002 ),USB_DEVICE_DATA (BOARD_503_ACC )}, -/* -* at76c505-rfmd -*/ -/* Generic AT76C505/RFMD */ - {USB_DEVICE (0x03eb ,0x7606 ),USB_DEVICE_DATA (BOARD_505 )}, -/* -* at76c505-rfmd2958 -*/ -/* Generic AT76C505/RFMD, OvisLink WL-1130USB */ - {USB_DEVICE (0x03eb ,0x7613 ),USB_DEVICE_DATA (BOARD_505_2958 )}, -/* Fiberline FL-WL240U */ - {USB_DEVICE (0x1371 ,0x0014 ),USB_DEVICE_DATA (BOARD_505_2958 )}, -/* CNet CNUSB-611G */ - {USB_DEVICE (0x1371 ,0x0013 ),USB_DEVICE_DATA (BOARD_505_2958 )}, -/* Linksys WUSB11 v2.8 */ - {USB_DEVICE (0x1915 ,0x2233 ),USB_DEVICE_DATA (BOARD_505_2958 )}, -/* Xterasys XN-2122B, IBlitzz BWU613B/BWU613SB */ - {USB_DEVICE (0x12fd ,0x1001 ),USB_DEVICE_DATA (BOARD_505_2958 )}, -/* Corega WLAN USB Stick 11 */ - {USB_DEVICE (0x07aa ,0x7613 ),USB_DEVICE_DATA (BOARD_505_2958 )}, -/* Microstar MSI Box MS6978 */ - {USB_DEVICE (0x0db0 ,0x1020 ),USB_DEVICE_DATA (BOARD_505_2958 )}, -/* -* at76c505a-rfmd2958 -*/ -/* Generic AT76C505A device */ - {USB_DEVICE (0x03eb ,0x7614 ),USB_DEVICE_DATA (BOARD_505A )}, -/* Generic AT76C505AS device */ - {USB_DEVICE (0x03eb ,0x7617 ),USB_DEVICE_DATA (BOARD_505A )}, -/* Siemens Gigaset USB WLAN Adapter 11 */ - {USB_DEVICE (0x1690 ,0x0701 ),USB_DEVICE_DATA (BOARD_505A )}, -/* OQO Model 01+ Internal Wi-Fi */ - {USB_DEVICE (0x1557 ,0x0002 ),USB_DEVICE_DATA (BOARD_505A )}, -/* -* at76c505amx-rfmd -*/ -/* Generic AT76C505AMX device */ - {USB_DEVICE (0x03eb ,0x7615 ),USB_DEVICE_DATA (BOARD_505AMX )}, - {} -}; - -MODULE_DEVICE_TABLE (usb, dev_table); - -/* Supported rates of this hardware, bit 7 marks basic rates */ -static const u8 hw_rates[] = {0x82 ,0x84 ,0x0b ,0x16 }; - -/* Frequency of each channel in MHz */ -static const long channel_frequency[] = { -2412 ,2417 ,2422 ,2427 ,2432 ,2437 ,2442 , -2447 ,2452 ,2457 ,2462 ,2467 ,2472 ,2484 -}; - -#define NUM_CHANNELS ARRAY_SIZE(channel_frequency) - -static const char *const preambles[] = {"long" ,"short" ,"auto" }; - -static const char *const mac_states[] = { - [MAC_INIT ] ="INIT" , - [MAC_SCANNING ] ="SCANNING" , - [MAC_AUTH ] ="AUTH" , - [MAC_ASSOC ] ="ASSOC" , - [MAC_JOINING ] ="JOINING" , - [MAC_CONNECTED ] ="CONNECTED" , - [MAC_OWN_IBSS ] ="OWN_IBSS" -}; - -/* Firmware download */ -/* DFU states */ -#define STATE_IDLE 0x00 -#define STATE_DETACH 0x01 -#define STATE_DFU_IDLE 0x02 -#define STATE_DFU_DOWNLOAD_SYNC 0x03 -#define STATE_DFU_DOWNLOAD_BUSY 0x04 -#define STATE_DFU_DOWNLOAD_IDLE 0x05 -#define STATE_DFU_MANIFEST_SYNC 0x06 -#define STATE_DFU_MANIFEST 0x07 -#define STATE_DFU_MANIFEST_WAIT_RESET 0x08 -#define STATE_DFU_UPLOAD_IDLE 0x09 -#define STATE_DFU_ERROR 0x0a - -/* DFU commands */ -#define DFU_DETACH 0 -#define DFU_DNLOAD 1 -#define DFU_UPLOAD 2 -#define DFU_GETSTATUS 3 -#define DFU_CLRSTATUS 4 -#define DFU_GETSTATE 5 -#define DFU_ABORT 6 - -#define FW_BLOCK_SIZE 1024 - -struct dfu_status { -unsigned char status; -unsigned char poll_timeout[3 ]; -unsigned char state; -unsigned char string; -} __attribute__((packed)); - -static inline int at76_is_intersil (enum board_type board) -{ -return (board ==BOARD_503_ISL3861 || board ==BOARD_503_ISL3863 ); -} - -static inline int at76_is_503rfmd (enum board_type board) -{ -return (board ==BOARD_503 || board ==BOARD_503_ACC ); -} - -static inline int at76_is_505a (enum board_type board) -{ -return (board ==BOARD_505A || board ==BOARD_505AMX ); -} - -/* Load a block of the first (internal) part of the firmware */ -static int at76_load_int_fw_block (struct usb_device *udev,int blockno, -void *block,int size) -{ -return usb_control_msg (udev,usb_sndctrlpipe (udev,0 ),DFU_DNLOAD , -USB_TYPE_CLASS |USB_DIR_OUT | -USB_RECIP_INTERFACE , blockno,0 , block, size, -USB_CTRL_GET_TIMEOUT ); -} - -static int at76_dfu_get_status (struct usb_device *udev, -struct dfu_status *status) -{ -int ret; - - ret =usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),DFU_GETSTATUS , -USB_TYPE_CLASS |USB_DIR_IN |USB_RECIP_INTERFACE , -0 ,0 , status,sizeof (struct dfu_status ), -USB_CTRL_GET_TIMEOUT ); -return ret; -} - -static u8 at76_dfu_get_state (struct usb_device *udev,u8 *state) -{ -int ret; - - ret =usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),DFU_GETSTATE , -USB_TYPE_CLASS |USB_DIR_IN |USB_RECIP_INTERFACE , -0 ,0 , state,1 ,USB_CTRL_GET_TIMEOUT ); -return ret; -} - -/* Convert timeout from the DFU status to jiffies */ -static inline unsigned long at76_get_timeout (struct dfu_status *s) -{ -return msecs_to_jiffies ((s->poll_timeout[2 ] <<16 ) - | (s->poll_timeout[1 ] <<8 ) - | (s->poll_timeout[0 ])); -} - -/* Load internal firmware from the buffer. If manifest_sync_timeout > 0, use -* its value in jiffies in the MANIFEST_SYNC state. */ -static int at76_usbdfu_download (struct usb_device *udev,u8 *buf,u32 size, -int manifest_sync_timeout) -{ -u8 *block; -struct dfu_status dfu_stat_buf; -int ret =0 ; -int need_dfu_state =1 ; -int is_done =0 ; -u8 dfu_state =0 ; -u32 dfu_timeout =0 ; -int bsize =0 ; -int blockno =0 ; - -at76_dbg (DBG_DFU ,"%s( %p, %u, %d)" , __func__, buf, size, - manifest_sync_timeout); - -if (!size) { -dev_printk (KERN_ERR , &udev->dev,"FW buffer length invalid!\n" ); -return -EINVAL ; - } - - block =kmalloc (FW_BLOCK_SIZE ,GFP_KERNEL ); -if (!block) -return -ENOMEM ; - -do { -if (need_dfu_state) { - ret =at76_dfu_get_state (udev, &dfu_state); -if (ret <0 ) { -dev_printk (KERN_ERR , &udev->dev, -"cannot get DFU state: %d\n" , ret); - goto exit; - } - need_dfu_state =0 ; - } - -switch (dfu_state) { -case STATE_DFU_DOWNLOAD_SYNC : -at76_dbg (DBG_DFU ,"STATE_DFU_DOWNLOAD_SYNC" ); - ret =at76_dfu_get_status (udev, &dfu_stat_buf); -if (ret >=0 ) { - dfu_state = dfu_stat_buf.state; - dfu_timeout =at76_get_timeout (&dfu_stat_buf); - need_dfu_state =0 ; - }else -dev_printk (KERN_ERR , &udev->dev, -"at76_dfu_get_status returned %d\n" , - ret); -break ; - -case STATE_DFU_DOWNLOAD_BUSY : -at76_dbg (DBG_DFU ,"STATE_DFU_DOWNLOAD_BUSY" ); - need_dfu_state =1 ; - -at76_dbg (DBG_DFU ,"DFU: Resetting device" ); -schedule_timeout_interruptible (dfu_timeout); -break ; - -case STATE_DFU_DOWNLOAD_IDLE : -at76_dbg (DBG_DFU ,"DOWNLOAD..." ); -/* fall through */ -case STATE_DFU_IDLE : -at76_dbg (DBG_DFU ,"DFU IDLE" ); - - bsize =min_t (int, size,FW_BLOCK_SIZE ); -memcpy (block, buf, bsize); -at76_dbg (DBG_DFU ,"int fw, size left = %5d, " -"bsize = %4d, blockno = %2d" , size, bsize, - blockno); - ret = -at76_load_int_fw_block (udev, blockno, block, bsize); - buf += bsize; - size -= bsize; - blockno++; - -if (ret != bsize) -dev_printk (KERN_ERR , &udev->dev, -"at76_load_int_fw_block " -"returned %d\n" , ret); - need_dfu_state =1 ; -break ; - -case STATE_DFU_MANIFEST_SYNC : -at76_dbg (DBG_DFU ,"STATE_DFU_MANIFEST_SYNC" ); - - ret =at76_dfu_get_status (udev, &dfu_stat_buf); -if (ret <0 ) -break ; - - dfu_state = dfu_stat_buf.state; - dfu_timeout =at76_get_timeout (&dfu_stat_buf); - need_dfu_state =0 ; - -/* override the timeout from the status response, -needed for AT76C505A */ -if (manifest_sync_timeout >0 ) - dfu_timeout = manifest_sync_timeout; - -at76_dbg (DBG_DFU ,"DFU: Waiting for manifest phase" ); -schedule_timeout_interruptible (dfu_timeout); -break ; - -case STATE_DFU_MANIFEST : -at76_dbg (DBG_DFU ,"STATE_DFU_MANIFEST" ); - is_done =1 ; -break ; - -case STATE_DFU_MANIFEST_WAIT_RESET : -at76_dbg (DBG_DFU ,"STATE_DFU_MANIFEST_WAIT_RESET" ); - is_done =1 ; -break ; - -case STATE_DFU_UPLOAD_IDLE : -at76_dbg (DBG_DFU ,"STATE_DFU_UPLOAD_IDLE" ); -break ; - -case STATE_DFU_ERROR : -at76_dbg (DBG_DFU ,"STATE_DFU_ERROR" ); - ret = -EPIPE ; -break ; - -default : -at76_dbg (DBG_DFU ,"DFU UNKNOWN STATE (%d)" , dfu_state); - ret = -EINVAL ; -break ; - } - }while (!is_done && (ret >=0 )); - -exit: -kfree (block); -if (ret >=0 ) - ret =0 ; - -return ret; -} - -/* Report that the scan results are ready */ -static inline void at76_iwevent_scan_complete (struct net_device *netdev) -{ -union iwreq_data wrqu; - wrqu.data.length =0 ; - wrqu.data.flags =0 ; -wireless_send_event (netdev,SIOCGIWSCAN , &wrqu,NULL ); -at76_dbg (DBG_WE_EVENTS ,"%s: SIOCGIWSCAN sent" , netdev->name); -} - -static inline void at76_iwevent_bss_connect (struct net_device *netdev, -u8 *bssid) -{ -union iwreq_data wrqu; - wrqu.data.length =0 ; - wrqu.data.flags =0 ; -memcpy (wrqu.ap_addr.sa_data, bssid,ETH_ALEN ); - wrqu.ap_addr.sa_family =ARPHRD_ETHER ; -wireless_send_event (netdev,SIOCGIWAP , &wrqu,NULL ); -at76_dbg (DBG_WE_EVENTS ,"%s: %s: SIOCGIWAP sent" , netdev->name, - __func__); -} - -static inline void at76_iwevent_bss_disconnect (struct net_device *netdev) -{ -union iwreq_data wrqu; - wrqu.data.length =0 ; - wrqu.data.flags =0 ; -memset (wrqu.ap_addr.sa_data,0 ,ETH_ALEN ); - wrqu.ap_addr.sa_family =ARPHRD_ETHER ; -wireless_send_event (netdev,SIOCGIWAP , &wrqu,NULL ); -at76_dbg (DBG_WE_EVENTS ,"%s: %s: SIOCGIWAP sent" , netdev->name, - __func__); -} - -#define HEX2STR_BUFFERS 4 -#define HEX2STR_MAX_LEN 64 -#define BIN2HEX (x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10) - -/* Convert binary data into hex string */ -static char *hex2str (void *buf,int len) -{ -static atomic_t a =ATOMIC_INIT (0 ); -static char bufs[HEX2STR_BUFFERS ][3 *HEX2STR_MAX_LEN +1 ]; -char *ret = bufs[atomic_inc_return (&a) & (HEX2STR_BUFFERS -1 )]; -char *obuf = ret; -u8 *ibuf = buf; - -if (len >HEX2STR_MAX_LEN ) - len =HEX2STR_MAX_LEN ; - -if (len <=0 ) { - ret[0 ] ='\0' ; -return ret; - } - -while (len--) { - *obuf++ =BIN2HEX (*ibuf >>4 ); - *obuf++ =BIN2HEX (*ibuf &0xf ); - *obuf++ ='-' ; - ibuf++; - } - *(--obuf) ='\0' ; - -return ret; -} - -/* LED trigger */ -static int tx_activity; -static void at76_ledtrig_tx_timerfunc (unsigned long data); -static DEFINE_TIMER(ledtrig_tx_timer, at76_ledtrig_tx_timerfunc, 0, 0); -DEFINE_LED_TRIGGER (ledtrig_tx); - -static void at76_ledtrig_tx_timerfunc (unsigned long data) -{ -static int tx_lastactivity; - -if (tx_lastactivity != tx_activity) { - tx_lastactivity = tx_activity; -led_trigger_event (ledtrig_tx,LED_FULL ); -mod_timer (&ledtrig_tx_timer, jiffies +HZ /4 ); - }else -led_trigger_event (ledtrig_tx,LED_OFF ); -} - -static void at76_ledtrig_tx_activity (void ) -{ - tx_activity++; -if (!timer_pending (&ledtrig_tx_timer)) -mod_timer (&ledtrig_tx_timer, jiffies +HZ /4 ); -} - -/* Check if the given ssid is hidden */ -static inline int at76_is_hidden_ssid (u8 *ssid,int length) -{ -static const u8 zeros[32 ]; - -if (length ==0 ) -return 1 ; - -if (length ==1 && ssid[0 ] ==' ' ) -return 1 ; - -return (memcmp (ssid, zeros, length) ==0 ); -} - -static inline void at76_free_bss_list (struct at76_priv *priv) -{ -struct list_head *next, *ptr; -unsigned long flags; - -spin_lock_irqsave (&priv->bss_list_spinlock, flags); - - priv->curr_bss =NULL ; - -list_for_each_safe (ptr, next, &priv->bss_list) { -list_del (ptr); -kfree (list_entry(ptr ,struct bss_info ,list )); - } - -spin_unlock_irqrestore (&priv->bss_list_spinlock, flags); -} - -static int at76_remap (struct usb_device *udev) -{ -int ret; - ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ),0x0a , -USB_TYPE_VENDOR |USB_DIR_OUT | -USB_RECIP_INTERFACE ,0 ,0 ,NULL ,0 , -USB_CTRL_GET_TIMEOUT ); -if (ret <0 ) -return ret; -return 0 ; -} - -static int at76_get_op_mode (struct usb_device *udev) -{ -int ret; -u8 saved; -u8 *op_mode; - - op_mode =kmalloc (1 ,GFP_NOIO ); -if (!op_mode) -return -ENOMEM ; - ret =usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),0x33 , -USB_TYPE_VENDOR |USB_DIR_IN | -USB_RECIP_INTERFACE ,0x01 ,0 , op_mode,1 , -USB_CTRL_GET_TIMEOUT ); - saved = *op_mode; -kfree (op_mode); - -if (ret <0 ) -return ret; -else if (ret <1 ) -return -EIO ; -else -return saved; -} - -/* Load a block of the second ("external") part of the firmware */ -static inline int at76_load_ext_fw_block (struct usb_device *udev,int blockno, -void *block,int size) -{ -return usb_control_msg (udev,usb_sndctrlpipe (udev,0 ),0x0e , -USB_TYPE_VENDOR |USB_DIR_OUT |USB_RECIP_DEVICE , -0x0802 , blockno, block, size, -USB_CTRL_GET_TIMEOUT ); -} - -static inline int at76_get_hw_cfg (struct usb_device *udev, -union at76_hwcfg *buf,int buf_size) -{ -return usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),0x33 , -USB_TYPE_VENDOR |USB_DIR_IN | -USB_RECIP_INTERFACE ,0x0a02 ,0 , - buf, buf_size,USB_CTRL_GET_TIMEOUT ); -} - -/* Intersil boards use a different "value" for GetHWConfig requests */ -static inline int at76_get_hw_cfg_intersil (struct usb_device *udev, -union at76_hwcfg *buf,int buf_size) -{ -return usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),0x33 , -USB_TYPE_VENDOR |USB_DIR_IN | -USB_RECIP_INTERFACE ,0x0902 ,0 , - buf, buf_size,USB_CTRL_GET_TIMEOUT ); -} - -/* Get the hardware configuration for the adapter and put it to the appropriate -* fields of 'priv' (the GetHWConfig request and interpretation of the result -* depends on the board type) */ -static int at76_get_hw_config (struct at76_priv *priv) -{ -int ret; -union at76_hwcfg *hwcfg =kmalloc (sizeof (*hwcfg),GFP_KERNEL ); - -if (!hwcfg) -return -ENOMEM ; - -if (at76_is_intersil (priv->board_type)) { - ret =at76_get_hw_cfg_intersil (priv->udev, hwcfg, -sizeof (hwcfg->i)); -if (ret <0 ) - goto exit; -memcpy (priv->mac_addr, hwcfg->i.mac_addr,ETH_ALEN ); - priv->regulatory_domain = hwcfg->i.regulatory_domain; - }else if (at76_is_503rfmd (priv->board_type)) { - ret =at76_get_hw_cfg (priv->udev, hwcfg,sizeof (hwcfg->r3)); -if (ret <0 ) - goto exit; -memcpy (priv->mac_addr, hwcfg->r3.mac_addr,ETH_ALEN ); - priv->regulatory_domain = hwcfg->r3.regulatory_domain; - }else { - ret =at76_get_hw_cfg (priv->udev, hwcfg,sizeof (hwcfg->r5)); -if (ret <0 ) - goto exit; -memcpy (priv->mac_addr, hwcfg->r5.mac_addr,ETH_ALEN ); - priv->regulatory_domain = hwcfg->r5.regulatory_domain; - } - -exit: -kfree (hwcfg); -if (ret <0 ) -printk (KERN_ERR "%s: cannot get HW Config (error %d)\n" , - priv->netdev->name, ret); - -return ret; -} - -static struct reg_domain const *at76_get_reg_domain (u16 code) -{ -int i; -static struct reg_domain const fd_tab[] = { - {0x10 ,"FCC (USA)" ,0x7ff },/* ch 1-11 */ - {0x20 ,"IC (Canada)" ,0x7ff },/* ch 1-11 */ - {0x30 ,"ETSI (most of Europe)" ,0x1fff },/* ch 1-13 */ - {0x31 ,"Spain" ,0x600 },/* ch 10-11 */ - {0x32 ,"France" ,0x1e00 },/* ch 10-13 */ - {0x40 ,"MKK (Japan)" ,0x2000 },/* ch 14 */ - {0x41 ,"MKK1 (Japan)" ,0x3fff },/* ch 1-14 */ - {0x50 ,"Israel" ,0x3fc },/* ch 3-9 */ - {0x00 ,"<unknown>" ,0xffffffff }/* ch 1-32 */ - }; - -/* Last entry is fallback for unknown domain code */ -for (i =0 ; i <ARRAY_SIZE (fd_tab) -1 ; i++) -if (code == fd_tab[i].code) -break ; - -return &fd_tab[i]; -} - -static inline int at76_get_mib (struct usb_device *udev,u16 mib,void *buf, -int buf_size) -{ -int ret; - - ret =usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),0x33 , -USB_TYPE_VENDOR |USB_DIR_IN | -USB_RECIP_INTERFACE , mib <<8 ,0 , buf, buf_size, -USB_CTRL_GET_TIMEOUT ); -if (ret >=0 && ret != buf_size) -return -EIO ; -return ret; -} - -/* Return positive number for status, negative for an error */ -static inline int at76_get_cmd_status (struct usb_device *udev,u8 cmd) -{ -u8 *stat_buf; -int ret; - - stat_buf =kmalloc (40 ,GFP_NOIO ); -if (!stat_buf) -return -ENOMEM ; - - ret =usb_control_msg (udev,usb_rcvctrlpipe (udev,0 ),0x22 , -USB_TYPE_VENDOR |USB_DIR_IN | -USB_RECIP_INTERFACE , cmd,0 , stat_buf, -40 ,USB_CTRL_GET_TIMEOUT ); -if (ret >=0 ) - ret = stat_buf[5 ]; -kfree (stat_buf); - -return ret; -} - -static int at76_set_card_command (struct usb_device *udev,u8 cmd,void *buf, -int buf_size) -{ -int ret; -struct at76_command *cmd_buf =kmalloc (sizeof (struct at76_command ) + - buf_size,GFP_KERNEL ); - -if (!cmd_buf) -return -ENOMEM ; - - cmd_buf->cmd = cmd; - cmd_buf->reserved =0 ; - cmd_buf->size =cpu_to_le16 (buf_size); -memcpy (cmd_buf->data, buf, buf_size); - - ret =usb_control_msg (udev,usb_sndctrlpipe (udev,0 ),0x0e , -USB_TYPE_VENDOR |USB_DIR_OUT |USB_RECIP_DEVICE , -0 ,0 , cmd_buf, -sizeof (struct at76_command ) + buf_size, -USB_CTRL_GET_TIMEOUT ); -kfree (cmd_buf); -return ret; -} - -#define MAKE_CMD_STATUS_CASE (c) case (c): return #c -static const char *at76_get_cmd_status_string (u8 cmd_status) -{ -switch (cmd_status) { -MAKE_CMD_STATUS_CASE (CMD_STATUS_IDLE ); -MAKE_CMD_STATUS_CASE (CMD_STATUS_COMPLETE ); -MAKE_CMD_STATUS_CASE (CMD_STATUS_UNKNOWN ); -MAKE_CMD_STATUS_CASE (CMD_STATUS_INVALID_PARAMETER ); -MAKE_CMD_STATUS_CASE (CMD_STATUS_FUNCTION_NOT_SUPPORTED ); -MAKE_CMD_STATUS_CASE (CMD_STATUS_TIME_OUT ); -MAKE_CMD_STATUS_CASE (CMD_STATUS_IN_PROGRESS ); -MAKE_CMD_STATUS_CASE (CMD_STATUS_HOST_FAILURE ); -MAKE_CMD_STATUS_CASE (CMD_STATUS_SCAN_FAILED ); - } - -return "UNKNOWN" ; -} - -/* Wait until the command is completed */ -static int at76_wait_completion (struct at76_priv *priv,int cmd) -{ -int status =0 ; -unsigned long timeout = jiffies +CMD_COMPLETION_TIMEOUT ; - -do { - status =at76_get_cmd_status (priv->udev, cmd); -if (status <0 ) { -printk (KERN_ERR "%s: at76_get_cmd_status failed: %d\n" , - priv->netdev->name, status); -break ; - } - -at76_dbg (DBG_WAIT_COMPLETE , -"%s: Waiting on cmd %d, status = %d (%s)" , - priv->netdev->name, cmd, status, -at76_get_cmd_status_string (status)); - -if (status !=CMD_STATUS_IN_PROGRESS - && status !=CMD_STATUS_IDLE ) -break ; - -schedule_timeout_interruptible (HZ /10 );/* 100 ms */ -if (time_after (jiffies, timeout)) { -printk (KERN_ERR -"%s: completion timeout for command %d\n" , - priv->netdev->name, cmd); - status = -ETIMEDOUT ; -break ; - } - }while (1 ); - -return status; -} - -static int at76_set_mib (struct at76_priv *priv,struct set_mib_buffer *buf) -{ -int ret; - - ret =at76_set_card_command (priv->udev,CMD_SET_MIB , buf, - offsetof(struct set_mib_buffer , - data) + buf->size); -if (ret <0 ) -return ret; - - ret =at76_wait_completion (priv,CMD_SET_MIB ); -if (ret !=CMD_STATUS_COMPLETE ) { -printk (KERN_INFO -"%s: set_mib: at76_wait_completion failed " -"with %d\n" , priv->netdev->name, ret); - ret = -EIO ; - } - -return ret; -} - -/* Return < 0 on error, == 0 if no command sent, == 1 if cmd sent */ -static int at76_set_radio (struct at76_priv *priv,int enable) -{ -int ret; -int cmd; - -if (priv->radio_on == enable) -return 0 ; - - cmd = enable ?CMD_RADIO_ON :CMD_RADIO_OFF ; - - ret =at76_set_card_command (priv->udev, cmd,NULL ,0 ); -if (ret <0 ) -printk (KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n" , - priv->netdev->name, cmd, ret); -else - ret =1 ; - - priv->radio_on = enable; -return ret; -} - -/* Set current power save mode (AT76_PM_OFF/AT76_PM_ON/AT76_PM_SMART) */ -static int at76_set_pm_mode (struct at76_priv *priv) -{ -int ret =0 ; - - priv->mib_buf.type =MIB_MAC_MGMT ; - priv->mib_buf.size =1 ; - priv->mib_buf.index = offsetof(struct mib_mac_mgmt , power_mgmt_mode); - priv->mib_buf.data.byte = priv->pm_mode; - - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) -printk (KERN_ERR "%s: set_mib (pm_mode) failed: %d\n" , - priv->netdev->name, ret); - -return ret; -} - -/* Set the association id for power save mode */ -static int at76_set_associd (struct at76_priv *priv,u16 id) -{ -int ret =0 ; - - priv->mib_buf.type =MIB_MAC_MGMT ; - priv->mib_buf.size =2 ; - priv->mib_buf.index = offsetof(struct mib_mac_mgmt , station_id); - priv->mib_buf.data.word =cpu_to_le16 (id); - - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) -printk (KERN_ERR "%s: set_mib (associd) failed: %d\n" , - priv->netdev->name, ret); - -return ret; -} - -/* Set the listen interval for power save mode */ -static int at76_set_listen_interval (struct at76_priv *priv,u16 interval) -{ -int ret =0 ; - - priv->mib_buf.type =MIB_MAC ; - priv->mib_buf.size =2 ; - priv->mib_buf.index = offsetof(struct mib_mac , listen_interval); - priv->mib_buf.data.word =cpu_to_le16 (interval); - - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) -printk (KERN_ERR -"%s: set_mib (listen_interval) failed: %d\n" , - priv->netdev->name, ret); - -return ret; -} - -static int at76_set_preamble (struct at76_priv *priv,u8 type) -{ -int ret =0 ; - - priv->mib_buf.type =MIB_LOCAL ; - priv->mib_buf.size =1 ; - priv->mib_buf.index = offsetof(struct mib_local , preamble_type); - priv->mib_buf.data.byte = type; - - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) -printk (KERN_ERR "%s: set_mib (preamble) failed: %d\n" , - priv->netdev->name, ret); - -return ret; -} - -static int at76_set_frag (struct at76_priv *priv,u16 size) -{ -int ret =0 ; - - priv->mib_buf.type =MIB_MAC ; - priv->mib_buf.size =2 ; - priv->mib_buf.index = offsetof(struct mib_mac , frag_threshold); - priv->mib_buf.data.word =cpu_to_le16 (size); - - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) -printk (KERN_ERR "%s: set_mib (frag threshold) failed: %d\n" , - priv->netdev->name, ret); - -return ret; -} - -static int at76_set_rts (struct at76_priv *priv,u16 size) -{ -int ret =0 ; - - priv->mib_buf.type =MIB_MAC ; - priv->mib_buf.size =2 ; - priv->mib_buf.index = offsetof(struct mib_mac , rts_threshold); - priv->mib_buf.data.word =cpu_to_le16 (size); - - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) -printk (KERN_ERR "%s: set_mib (rts) failed: %d\n" , - priv->netdev->name, ret); - -return ret; -} - -static int at76_set_autorate_fallback (struct at76_priv *priv,int onoff) -{ -int ret =0 ; - - priv->mib_buf.type =MIB_LOCAL ; - priv->mib_buf.size =1 ; - priv->mib_buf.index = offsetof(struct mib_local , txautorate_fallback); - priv->mib_buf.data.byte = onoff; - - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) -printk (KERN_ERR "%s: set_mib (autorate fallback) failed: %d\n" , - priv->netdev->name, ret); - -return ret; -} - -static int at76_add_mac_address (struct at76_priv *priv,void *addr) -{ -int ret =0 ; - - priv->mib_buf.type =MIB_MAC_ADDR ; - priv->mib_buf.size =ETH_ALEN ; - priv->mib_buf.index = offsetof(struct mib_mac_addr , mac_addr); -memcpy (priv->mib_buf.data.addr, addr,ETH_ALEN ); - - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) -printk (KERN_ERR "%s: set_mib (MAC_ADDR, mac_addr) failed: %d\n" , - priv->netdev->name, ret); - -return ret; -} - -static void at76_dump_mib_mac_addr (struct at76_priv *priv) -{ -int i; -int ret; -struct mib_mac_addr *m =kmalloc (sizeof (struct mib_mac_addr ), -GFP_KERNEL ); - -if (!m) -return ; - - ret =at76_get_mib (priv->udev,MIB_MAC_ADDR , m, -sizeof (struct mib_mac_addr )); -if (ret <0 ) { -printk (KERN_ERR "%s: at76_get_mib (MAC_ADDR) failed: %d\n" , - priv->netdev->name, ret); - goto exit; - } - -at76_dbg (DBG_MIB ,"%s: MIB MAC_ADDR: mac_addr %pM res 0x%x 0x%x" , - priv->netdev->name, m->mac_addr, m->res[0 ], m->res[1 ]); -for (i =0 ; i <ARRAY_SIZE (m->group_addr); i++) -at76_dbg (DBG_MIB ,"%s: MIB MAC_ADDR: group addr %d: %pM, " -"status %d" , priv->netdev->name, i, - m->group_addr[i], m->group_addr_status[i]); -exit: -kfree (m); -} - -static void at76_dump_mib_mac_wep (struct at76_priv *priv) -{ -int i; -int ret; -int key_len; -struct mib_mac_wep *m =kmalloc (sizeof (struct mib_mac_wep ),GFP_KERNEL ); - -if (!m) -return ; - - ret =at76_get_mib (priv->udev,MIB_MAC_WEP , m, -sizeof (struct mib_mac_wep )); -if (ret <0 ) { -printk (KERN_ERR "%s: at76_get_mib (MAC_WEP) failed: %d\n" , - priv->netdev->name, ret); - goto exit; - } - -at76_dbg (DBG_MIB ,"%s: MIB MAC_WEP: priv_invoked %u def_key_id %u " -"key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u " -"encr_level %u key %d" , priv->netdev->name, - m->privacy_invoked, m->wep_default_key_id, - m->wep_key_mapping_len, m->exclude_unencrypted, -le32_to_cpu (m->wep_icv_error_count), -le32_to_cpu (m->wep_excluded_count), m->encryption_level, - m->wep_default_key_id); - - key_len = (m->encryption_level ==1 ) ? -WEP_SMALL_KEY_LEN :WEP_LARGE_KEY_LEN ; - -for (i =0 ; i <WEP_KEYS ; i++) -at76_dbg (DBG_MIB ,"%s: MIB MAC_WEP: key %d: %s" , - priv->netdev->name, i, -hex2str (m->wep_default_keyvalue[i], key_len)); -exit: -kfree (m); -} - -static void at76_dump_mib_mac_mgmt (struct at76_priv *priv) -{ -int ret; -struct mib_mac_mgmt *m =kmalloc (sizeof (struct mib_mac_mgmt ), -GFP_KERNEL ); - -if (!m) -return ; - - ret =at76_get_mib (priv->udev,MIB_MAC_MGMT , m, -sizeof (struct mib_mac_mgmt )); -if (ret <0 ) { -printk (KERN_ERR "%s: at76_get_mib (MAC_MGMT) failed: %d\n" , - priv->netdev->name, ret); - goto exit; - } - -at76_dbg (DBG_MIB ,"%s: MIB MAC_MGMT: beacon_period %d CFP_max_duration " -"%d medium_occupancy_limit %d station_id 0x%x ATIM_window %d " -"CFP_mode %d privacy_opt_impl %d DTIM_period %d CFP_period %d " -"current_bssid %pM scurrent_essid %s current_bss_type %d " -"pm_mode %d ibss_change %d res %d " -"multi_domain_capability_implemented %d " -"international_roaming %d country_string %.3s" , - priv->netdev->name,le16_to_cpu (m->beacon_period), -le16_to_cpu (m->CFP_max_duration), -le16_to_cpu (m->medium_occupancy_limit), -le16_to_cpu (m->station_id),le16_to_cpu (m->ATIM_window), - m->CFP_mode, m->privacy_option_implemented, m->DTIM_period, - m->CFP_period, m->current_bssid, -hex2str (m->current_essid,IW_ESSID_MAX_SIZE ), - m->current_bss_type, m->power_mgmt_mode, m->ibss_change, - m->res, m->multi_domain_capability_implemented, - m->multi_domain_capability_enabled, m->country_string); -exit: -kfree (m); -} - -static void at76_dump_mib_mac (struct at76_priv *priv) -{ -int ret; -struct mib_mac *m =kmalloc (sizeof (struct mib_mac ),GFP_KERNEL ); - -if (!m) -return ; - - ret =at76_get_mib (priv->udev,MIB_MAC , m,sizeof (struct mib_mac )); -if (ret <0 ) { -printk (KERN_ERR "%s: at76_get_mib (MAC) failed: %d\n" , - priv->netdev->name, ret); - goto exit; - } - -at76_dbg (DBG_MIB ,"%s: MIB MAC: max_tx_msdu_lifetime %d " -"max_rx_lifetime %d frag_threshold %d rts_threshold %d " -"cwmin %d cwmax %d short_retry_time %d long_retry_time %d " -"scan_type %d scan_channel %d probe_delay %u " -"min_channel_time %d max_channel_time %d listen_int %d " -"desired_ssid %s desired_bssid %pM desired_bsstype %d" , - priv->netdev->name,le32_to_cpu (m->max_tx_msdu_lifetime), -le32_to_cpu (m->max_rx_lifetime), -le16_to_cpu (m->frag_threshold),le16_to_cpu (m->rts_threshold), -le16_to_cpu (m->cwmin),le16_to_cpu (m->cwmax), - m->short_retry_time, m->long_retry_time, m->scan_type, - m->scan_channel,le16_to_cpu (m->probe_delay), -le16_to_cpu (m->min_channel_time), -le16_to_cpu (m->max_channel_time), -le16_to_cpu (m->listen_interval), -hex2str (m->desired_ssid,IW_ESSID_MAX_SIZE ), - m->desired_bssid, m->desired_bsstype); -exit: -kfree (m); -} - -static void at76_dump_mib_phy (struct at76_priv *priv) -{ -int ret; -struct mib_phy *m =kmalloc (sizeof (struct mib_phy ),GFP_KERNEL ); - -if (!m) -return ; - - ret =at76_get_mib (priv->udev,MIB_PHY , m,sizeof (struct mib_phy )); -if (ret <0 ) { -printk (KERN_ERR "%s: at76_get_mib (PHY) failed: %d\n" , - priv->netdev->name, ret); - goto exit; - } - -at76_dbg (DBG_MIB ,"%s: MIB PHY: ed_threshold %d slot_time %d " -"sifs_time %d preamble_length %d plcp_header_length %d " -"mpdu_max_length %d cca_mode_supported %d operation_rate_set " -"0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d " -"phy_type %d current_reg_domain %d" , - priv->netdev->name,le32_to_cpu (m->ed_threshold), -le16_to_cpu (m->slot_time),le16_to_cpu (m->sifs_time), -le16_to_cpu (m->preamble_length), -le16_to_cpu (m->plcp_header_length), -le16_to_cpu (m->mpdu_max_length), -le16_to_cpu (m->cca_mode_supported), m->operation_rate_set[0 ], - m->operation_rate_set[1 ], m->operation_rate_set[2 ], - m->operation_rate_set[3 ], m->channel_id, m->current_cca_mode, - m->phy_type, m->current_reg_domain); -exit: -kfree (m); -} - -static void at76_dump_mib_local (struct at76_priv *priv) -{ -int ret; -struct mib_local *m =kmalloc (sizeof (struct mib_phy ),GFP_KERNEL ); - -if (!m) -return ; - - ret =at76_get_mib (priv->udev,MIB_LOCAL , m,sizeof (struct mib_local )); -if (ret <0 ) { -printk (KERN_ERR "%s: at76_get_mib (LOCAL) failed: %d\n" , - priv->netdev->name, ret); - goto exit; - } - -at76_dbg (DBG_MIB ,"%s: MIB LOCAL: beacon_enable %d " -"txautorate_fallback %d ssid_size %d promiscuous_mode %d " -"preamble_type %d" , priv->netdev->name, m->beacon_enable, - m->txautorate_fallback, m->ssid_size, m->promiscuous_mode, - m->preamble_type); -exit: -kfree (m); -} - -static void at76_dump_mib_mdomain (struct at76_priv *priv) -{ -int ret; -struct mib_mdomain *m =kmalloc (sizeof (struct mib_mdomain ),GFP_KERNEL ); - -if (!m) -return ; - - ret =at76_get_mib (priv->udev,MIB_MDOMAIN , m, -sizeof (struct mib_mdomain )); -if (ret <0 ) { -printk (KERN_ERR "%s: at76_get_mib (MDOMAIN) failed: %d\n" , - priv->netdev->name, ret); - goto exit; - } - -at76_dbg (DBG_MIB ,"%s: MIB MDOMAIN: channel_list %s" , - priv->netdev->name, -hex2str (m->channel_list,sizeof (m->channel_list))); - -at76_dbg (DBG_MIB ,"%s: MIB MDOMAIN: tx_powerlevel %s" , - priv->netdev->name, -hex2str (m->tx_powerlevel,sizeof (m->tx_powerlevel))); -exit: -kfree (m); -} - -static int at76_get_current_bssid (struct at76_priv *priv) -{ -int ret =0 ; -struct mib_mac_mgmt *mac_mgmt = -kmalloc (sizeof (struct mib_mac_mgmt ),GFP_KERNEL ); - -if (!mac_mgmt) { - ret = -ENOMEM ; - goto exit; - } - - ret =at76_get_mib (priv->udev,MIB_MAC_MGMT , mac_mgmt, -sizeof (struct mib_mac_mgmt )); -if (ret <0 ) { -printk (KERN_ERR "%s: at76_get_mib failed: %d\n" , - priv->netdev->name, ret); - goto error; - } -memcpy (priv->bssid, mac_mgmt->current_bssid,ETH_ALEN ); -printk (KERN_INFO "%s: using BSSID %pM\n" , priv->netdev->name, - priv->bssid); -error: -kfree (mac_mgmt); -exit: -return ret; -} - -static int at76_get_current_channel (struct at76_priv *priv) -{ -int ret =0 ; -struct mib_phy *phy =kmalloc (sizeof (struct mib_phy ),GFP_KERNEL ); - -if (!phy) { - ret = -ENOMEM ; - goto exit; - } - ret =at76_get_mib (priv->udev,MIB_PHY , phy,sizeof (struct mib_phy )); -if (ret <0 ) { -printk (KERN_ERR "%s: at76_get_mib(MIB_PHY) failed: %d\n" , - priv->netdev->name, ret); - goto error; - } - priv->channel = phy->channel_id; -error: -kfree (phy); -exit: -return ret; -} - -/** -* at76_start_scan - start a scan -* -* @use_essid - use the configured ESSID in non passive mode -*/ -static int at76_start_scan (struct at76_priv *priv,int use_essid) -{ -struct at76_req_scan scan; - -memset (&scan,0 ,sizeof (struct at76_req_scan )); -memset (scan.bssid,0xff ,ETH_ALEN ); - -if (use_essid) { -memcpy (scan.essid, priv->essid,IW_ESSID_MAX_SIZE ); - scan.essid_size = priv->essid_size; - }else - scan.essid_size =0 ; - -/* jal: why should we start at a certain channel? we do scan the whole -range allowed by reg domain. */ - scan.channel = priv->channel; - -/* atmelwlandriver differs between scan type 0 and 1 (active/passive) -For ad-hoc mode, it uses type 0 only. */ - scan.scan_type = priv->scan_mode; - -/* INFO: For probe_delay, not multiplying by 1024 as this will be -slightly less than min_channel_time -(per spec: probe delay < min. channel time) */ - scan.min_channel_time =cpu_to_le16 (priv->scan_min_time); - scan.max_channel_time =cpu_to_le16 (priv->scan_max_time); - scan.probe_delay =cpu_to_le16 (priv->scan_min_time *1000 ); - scan.international_scan =0 ; - -/* other values are set to 0 for type 0 */ - -at76_dbg (DBG_PROGRESS ,"%s: start_scan (use_essid = %d, intl = %d, " -"channel = %d, probe_delay = %d, scan_min_time = %d, " -"scan_max_time = %d)" , - priv->netdev->name, use_essid, - scan.international_scan, scan.channel, -le16_to_cpu (scan.probe_delay), -le16_to_cpu (scan.min_channel_time), -le16_to_cpu (scan.max_channel_time)); - -return at76_set_card_command (priv->udev,CMD_SCAN , &scan,sizeof (scan)); -} - -/* Enable monitor mode */ -static int at76_start_monitor (struct at76_priv *priv) -{ -struct at76_req_scan scan; -int ret; - -memset (&scan,0 ,sizeof (struct at76_req_scan )); -memset (scan.bssid,0xff ,ETH_ALEN ); - - scan.channel = priv->channel; - scan.scan_type =SCAN_TYPE_PASSIVE ; - scan.international_scan =0 ; - - ret =at76_set_card_command (priv->udev,CMD_SCAN , &scan,sizeof (scan)); -if (ret >=0 ) - ret =at76_get_cmd_status (priv->udev,CMD_SCAN ); - -return ret; -} - -static int at76_start_ibss (struct at76_priv *priv) -{ -struct at76_req_ibss bss; -int ret; - -WARN_ON (priv->mac_state !=MAC_OWN_IBSS ); -if (priv->mac_state !=MAC_OWN_IBSS ) -return -EBUSY ; - -memset (&bss,0 ,sizeof (struct at76_req_ibss )); -memset (bss.bssid,0xff ,ETH_ALEN ); -memcpy (bss.essid, priv->essid,IW_ESSID_MAX_SIZE ); - bss.essid_size = priv->essid_size; - bss.bss_type =ADHOC_MODE ; - bss.channel = priv->channel; - - ret =at76_set_card_command (priv->udev,CMD_START_IBSS , &bss, -sizeof (struct at76_req_ibss )); -if (ret <0 ) { -printk (KERN_ERR "%s: start_ibss failed: %d\n" , - priv->netdev->name, ret); -return ret; - } - - ret =at76_wait_completion (priv,CMD_START_IBSS ); -if (ret !=CMD_STATUS_COMPLETE ) { -printk (KERN_ERR "%s: start_ibss failed to complete, %d\n" , - priv->netdev->name, ret); -return ret; - } - - ret =at76_get_current_bssid (priv); -if (ret <0 ) -return ret; - - ret =at76_get_current_channel (priv); -if (ret <0 ) -return ret; - -/* not sure what this is good for ??? */ - priv->mib_buf.type =MIB_MAC_MGMT ; - priv->mib_buf.size =1 ; - priv->mib_buf.index = offsetof(struct mib_mac_mgmt , ibss_change); - priv->mib_buf.data.byte =0 ; - - ret =at76_set_mib (priv, &priv->mib_buf); -if (ret <0 ) { -printk (KERN_ERR "%s: set_mib (ibss change ok) failed: %d\n" , - priv->netdev->name, ret); -return ret; - } - -netif_carrier_on (priv->netdev); -netif_start_queue (priv->netdev); -return 0 ; -} - -/* Request card to join BSS in managed or ad-hoc mode */ -static int at76_join_bss (struct at76_priv *priv,struct bss_info *ptr) -{ -struct at76_req_join join; - -BUG_ON (!ptr); - -memset (&join,0 ,sizeof (struct at76_req_join )); -memcpy (join.bssid, ptr->bssid,ETH_ALEN ); -memcpy (join.essid, ptr->ssid, ptr->ssid_len); - join.essid_size = ptr->ssid_len; - join.bss_type = (priv->iw_mode ==IW_MODE_ADHOC ?1 :2 ); - join.channel = ptr->channel; - join.timeout =cpu_to_le16 (2000 ); - -at76_dbg (DBG_PROGRESS , -"%s join addr %pM ssid %s stype %d ch %d timeout %d" , - priv->netdev->name, join.bssid, join.essid, - join.bss_type, join.channel,le16_to_cpu (join.timeout)); -return at76_set_card_command (priv->udev,CMD_JOIN , &join, -sizeof (struct at76_req_join )); -} - -/* Calculate padding from txbuf->wlength (which excludes the USB TX header), -likely to compensate a flaw in the AT76C503A USB part ... */ -static inline int at76_calc_padding (int wlen) -{ -/* add the USB TX header */ - wlen +=AT76_TX_HDRLEN ; - - wlen = wlen %64 ; - -if (wlen <50 ) -return 50 - wlen; - -if (wlen >=61 ) -return 64 +50 - wlen; - -return 0 ; -} - -/* We are doing a lot of things here in an interrupt. Need -a bh handler (Watching TV with a TV card is probably -a good test: if you see flickers, we are doing too much. -Currently I do see flickers... even with our tasklet :-( ) -Maybe because the bttv driver and usb-uhci use the same interrupt -*/ -/* Or maybe because our BH handler is preempting bttv's BH handler.. BHs don't -* solve everything.. (alex) */ -static void at76_rx_callback (struct urb *urb) -{ -struct at76_priv *priv = urb->context; - - priv->rx_tasklet.data = (unsigned long )urb; -tasklet_schedule (&priv->rx_tasklet); -return ; -} - -static void at76_tx_callback (struct urb *urb) -{ -struct at76_priv *priv = urb->context; -struct net_device_stats *stats = &priv->stats; -unsigned long flags; -struct at76_tx_buffer *mgmt_buf; -int ret; - -switch (urb->status) { -case 0 : - stats->tx_packets++; -break ; -case -ENOENT : -case -ECONNRESET : -/* urb has been unlinked */ -return ; -default : -at76_dbg (DBG_URB ,"%s - nonzero tx status received: %d" , - __func__, urb->status); - stats->tx_errors++; -break ; - } - -spin_lock_irqsave (&priv->mgmt_spinlock, flags); - mgmt_buf = priv->next_mgmt_bulk; - priv->next_mgmt_bulk =NULL ; -spin_unlock_irqrestore (&priv->mgmt_spinlock, flags); - -if (!mgmt_buf) { -netif_wake_queue (priv->netdev); -return ; - } - -/* we don't copy the padding bytes, but add them -to the length */ -memcpy (priv->bulk_out_buffer, mgmt_buf, -le16_to_cpu (mgmt_buf->wlength) +AT76_TX_HDRLEN ); -usb_fill_bulk_urb (priv->tx_urb, priv->udev, priv->tx_pipe, - priv->bulk_out_buffer, -le16_to_cpu (mgmt_buf->wlength) + mgmt_buf->padding + -AT76_TX_HDRLEN , at76_tx_callback, priv); - ret =usb_submit_urb (priv->tx_urb,GFP_ATOMIC ); -if (ret) -printk (KERN_ERR "%s: error in tx submit urb: %d\n" , - priv->netdev->name, ret); - -kfree (mgmt_buf); -} - -/* Send a management frame on bulk-out. txbuf->wlength must be set */ -static int at76_tx_mgmt (struct at76_priv *priv,struct at76_tx_buffer *txbuf) -{ -unsigned long flags; -int ret; -int urb_status; -void *oldbuf =NULL ; - -netif_carrier_off (priv->netdev);/* stop netdev watchdog */ -netif_stop_queue (priv->netdev);/* stop tx data packets */ - -spin_lock_irqsave (&priv->mgmt_spinlock, flags); - - urb_status = priv->tx_urb->status; -if (urb_status == -EINPROGRESS ) { -/* cannot transmit now, put in the queue */ - oldbuf = priv->next_mgmt_bulk; - priv->next_mgmt_bulk = txbuf; - } -spin_unlock_irqrestore (&priv->mgmt_spinlock, flags); - -if (oldbuf) { -/* a data/mgmt tx is already pending in the URB - -if this is no error in some situations we must -implement a queue or silently modify the old msg */ -printk (KERN_ERR "%s: removed pending mgmt buffer %s\n" , - priv->netdev->name,hex2str (oldbuf,64 )); -kfree (oldbuf); -return 0 ; - } - - txbuf->tx_rate =TX_RATE_1MBIT ; - txbuf->padding =at76_calc_padding (le16_to_cpu (txbuf->wlength)); -memset (txbuf->reserved,0 ,sizeof (txbuf->reserved)); - -if (priv->next_mgmt_bulk) -printk (KERN_ERR "%s: URB status %d, but mgmt is pending\n" , - priv->netdev->name, urb_status); - -at76_dbg (DBG_TX_MGMT , -"%s: tx mgmt: wlen %d tx_rate %d pad %d %s" , - priv->netdev->name,le16_to_cpu (txbuf->wlength), - txbuf->tx_rate, txbuf->padding, -hex2str (txbuf->packet,le16_to_cpu (txbuf->wlength))); - -/* txbuf was not consumed above -> send mgmt msg immediately */ -memcpy (priv->bulk_out_buffer, txbuf, -le16_to_cpu (txbuf->wlength) +AT76_TX_HDRLEN ); -usb_fill_bulk_urb (priv->tx_urb, priv->udev, priv->tx_pipe, - priv->bulk_out_buffer, -le16_to_cpu (txbuf->wlength) + txbuf->padding + -AT76_TX_HDRLEN , at76_tx_callback, priv); - ret =usb_submit_urb (priv->tx_urb,GFP_ATOMIC ); -if (ret) -printk (KERN_ERR "%s: error in tx submit urb: %d\n" , - priv->netdev->name, ret); - -kfree (txbuf); - -return ret; -} - -/* Go to the next information element */ -static inline void next_ie (struct ieee80211_info_element **ie) -{ - *ie = (struct ieee80211_info_element *)(&(*ie)->data[(*ie)->len]); -} - -/* Challenge is the challenge string (in TLV format) -we got with seq_nr 2 for shared secret authentication only and -send in seq_nr 3 WEP encrypted to prove we have the correct WEP key; -otherwise it is NULL */ -static int at76_auth_req (struct at76_priv *priv,struct bss_info *bss, -int seq_nr,struct ieee80211_info_element *challenge) -{ -struct at76_tx_buffer *tx_buffer; -struct ieee80211_hdr_3addr *mgmt; -struct ieee80211_auth *req; -int buf_len = (seq_nr !=3 ?AUTH_FRAME_SIZE : -AUTH_FRAME_SIZE +1 +1 + challenge->len); - -BUG_ON (!bss); -BUG_ON (seq_nr ==3 && !challenge); - tx_buffer =kmalloc (buf_len +MAX_PADDING_SIZE ,GFP_ATOMIC ); -if (!tx_buffer) -return -ENOMEM ; - - req = (struct ieee80211_auth *)tx_buffer->packet; - mgmt = &req->header; - -/* make wireless header */ -/* first auth msg is not encrypted, only the second (seq_nr == 3) */ - mgmt->frame_ctl = -cpu_to_le16 (IEEE80211_FTYPE_MGMT |IEEE80211_STYPE_AUTH | - (seq_nr ==3 ?IEEE80211_FCTL_PROTECTED :0 )); - - mgmt->duration_id =cpu_to_le16 (0x8000 ); -memcpy (mgmt->addr1, bss->bssid,ETH_ALEN ); -memcpy (mgmt->addr2, priv->netdev->dev_addr,ETH_ALEN ); -memcpy (mgmt->addr3, bss->bssid,ETH_ALEN ); - mgmt->seq_ctl =cpu_to_le16 (0 ); - - req->algorithm =cpu_to_le16 (priv->auth_mode); - req->transaction =cpu_to_le16 (seq_nr); - req->status =cpu_to_le16 (0 ); - -if (seq_nr ==3 ) -memcpy (req->info_element, challenge,1 +1 + challenge->len); - -/* init. at76_priv tx header */ - tx_buffer->wlength =cpu_to_le16 (buf_len -AT76_TX_HDRLEN ); -at76_dbg (DBG_TX_MGMT ,"%s: AuthReq bssid %pM alg %d seq_nr %d" , - priv->netdev->name, mgmt->addr3, -le16_to_cpu (req->algorithm),le16_to_cpu (req->transaction)); -if (seq_nr ==3 ) -at76_dbg (DBG_TX_MGMT ,"%s: AuthReq challenge: %s ..." , - priv->netdev->name,hex2str (req->info_element,18 )); - -/* either send immediately (if no data tx is pending -or put it in pending list */ -return at76_tx_mgmt (priv, tx_buffer); -} - -static int at76_assoc_req (struct at76_priv *priv,struct bss_info *bss) -{ -struct at76_tx_buffer *tx_buffer; -struct ieee80211_hdr_3addr *mgmt; -struct ieee80211_assoc_request *req; -struct ieee80211_info_element *ie; -char *essid; -int essid_len; -u16 capa; - -BUG_ON (!bss); - - tx_buffer =kmalloc (ASSOCREQ_MAX_SIZE +MAX_PADDING_SIZE ,GFP_ATOMIC ); -if (!tx_buffer) -return -ENOMEM ; - - req = (struct ieee80211_assoc_request *)tx_buffer->packet; - mgmt = &req->header; - ie = req->info_element; - -/* make wireless header */ - mgmt->frame_ctl =cpu_to_le16 (IEEE80211_FTYPE_MGMT | -IEEE80211_STYPE_ASSOC_REQ ); - - mgmt->duration_id =cpu_to_le16 (0x8000 ); -memcpy (mgmt->addr1, bss->bssid,ETH_ALEN ); -memcpy (mgmt->addr2, priv->netdev->dev_addr,ETH_ALEN ); -memcpy (mgmt->addr3, bss->bssid,ETH_ALEN ); - mgmt->seq_ctl =cpu_to_le16 (0 ); - -/* we must set the Privacy bit in the capabilities to assure an -Agere-based AP with optional WEP transmits encrypted frames -to us. AP only set the Privacy bit in their capabilities -if WEP is mandatory in the BSS! */ - capa = bss->capa; -if (priv->wep_enabled) - capa |=WLAN_CAPABILITY_PRIVACY ; -if (priv->preamble_type !=PREAMBLE_TYPE_LONG ) - capa |=WLAN_CAPABILITY_SHORT_PREAMBLE ; - req->capability =cpu_to_le16 (capa); - - req->listen_interval =cpu_to_le16 (2 * bss->beacon_interval); - -/* write TLV data elements */ - - ie->id =WLAN_EID_SSID ; - ie->len = bss->ssid_len; -memcpy (ie->data, bss->ssid, bss->ssid_len); -next_ie (&ie); - - ie->id =WLAN_EID_SUPP_RATES ; - ie->len =sizeof (hw_rates); -memcpy (ie->data, hw_rates,sizeof (hw_rates)); -next_ie (&ie);/* ie points behind the supp_rates field */ - -/* init. at76_priv tx header */ - tx_buffer->wlength =cpu_to_le16 ((u8 *)ie - (u8 *)mgmt); - - ie = req->info_element; - essid = ie->data; - essid_len =min_t (int,IW_ESSID_MAX_SIZE , ie->len); - -next_ie (&ie);/* points to IE of rates now */ -at76_dbg (DBG_TX_MGMT , -"%s: AssocReq bssid %pM capa 0x%04x ssid %.*s rates %s" , - priv->netdev->name, mgmt->addr3, -le16_to_cpu (req->capability), essid_len, essid, -hex2str (ie->data, ie->len)); - -/* either send immediately (if no data tx is pending -or put it in pending list */ -return at76_tx_mgmt (priv, tx_buffer); -} - -/* We got to check the bss_list for old entries */ -static void at76_bss_list_timeout (unsigned long par) -{ -struct at76_priv *priv = (struct at76_priv *)par; -unsigned long flags; -struct list_head *lptr, *nptr; -struct bss_info *ptr; - -spin_lock_irqsave (&priv->bss_list_spinlock, flags); - -list_for_each_safe (lptr, nptr, &priv->bss_list) { - - ptr = list_entry(lptr, struct bss_info, list); - -if (ptr != priv->curr_bss - &&time_after (jiffies, ptr->last_rx +BSS_LIST_TIMEOUT )) { -at76_dbg (DBG_BSS_TABLE_RM , -"%s: bss_list: removing old BSS %pM ch %d" , - priv->netdev->name, ptr->bssid, - ptr->channel); -list_del (&ptr->list); -kfree (ptr); - } - } -spin_unlock_irqrestore (&priv->bss_list_spinlock, flags); -/* restart the timer */ -mod_timer (&priv->bss_list_timer, jiffies +BSS_LIST_TIMEOUT ); -} - -static inline void at76_set_mac_state (struct at76_priv *priv, -enum mac_state mac_state) -{ -at76_dbg (DBG_MAC_STATE ,"%s state: %s" , priv->netdev->name, - mac_states[mac_state]); - priv->mac_state = mac_state; -} - -static void at76_dump_bss_table (struct at76_priv *priv) -{ -struct bss_info *ptr; -unsigned long flags; -struct list_head *lptr; - -spin_lock_irqsave (&priv->bss_list_spinlock, flags); - -at76_dbg (DBG_BSS_TABLE ,"%s BSS table (curr=%p):" , priv->netdev->name, - priv->curr_bss); - -list_for_each (lptr, &priv->bss_list) { - ptr = list_entry(lptr, struct bss_info, list); -at76_dbg (DBG_BSS_TABLE ,"0x%p: bssid %pM channel %d ssid %.*s " -"(%s) capa 0x%04x rates %s rssi %d link %d noise %d" , - ptr, ptr->bssid, ptr->channel, ptr->ssid_len, - ptr->ssid,hex2str (ptr->ssid, ptr->ssid_len), - ptr->capa,hex2str (ptr->rates, ptr->rates_len), - ptr->rssi, ptr->link_qual, ptr->noise_level); - } -spin_unlock_irqrestore (&priv->bss_list_spinlock, flags); -} - -/* Called upon successful association to mark interface as connected */ -static void at76_work_assoc_done (struct work_struct *work) -{ - struct at76_priv *priv = container_of(work, struct at76_priv, - work_assoc_done); - -mutex_lock (&priv->mtx); - -WARN_ON (priv->mac_state !=MAC_ASSOC ); -WARN_ON (!priv->curr_bss); -if (priv->mac_state !=MAC_ASSOC || !priv->curr_bss) - goto exit; - -if (priv->iw_mode ==IW_MODE_INFRA ) { -if (priv->pm_mode !=AT76_PM_OFF ) { -/* calculate the listen interval in units of -beacon intervals of the curr_bss */ -u32 pm_period_beacon = (priv->pm_period >>10 ) / - priv->curr_bss->beacon_interval; - - pm_period_beacon =max (pm_period_beacon,2u ); - pm_period_beacon =min (pm_period_beacon,0xffffu ); - -at76_dbg (DBG_PM , -"%s: pm_mode %d assoc id 0x%x listen int %d" , - priv->netdev->name, priv->pm_mode, - priv->assoc_id, pm_period_beacon); - -at76_set_associd (priv, priv->assoc_id); -at76_set_listen_interval (priv, (u16 )pm_period_beacon); - } -schedule_delayed_work (&priv->dwork_beacon,BEACON_TIMEOUT ); - } -at76_set_pm_mode (priv); - -netif_carrier_on (priv->netdev); -netif_wake_queue (priv->netdev); -at76_set_mac_state (priv,MAC_CONNECTED ); -at76_iwevent_bss_connect (priv->netdev, priv->curr_bss->bssid); -at76_dbg (DBG_PROGRESS ,"%s: connected to BSSID %pM" , - priv->netdev->name, priv->curr_bss->bssid); - -exit: -mutex_unlock (&priv->mtx); -} - -/* We only store the new mac address in netdev struct, -it gets set when the netdev is opened. */ -static int at76_set_mac_address (struct net_device *netdev,void *addr) -{ -struct sockaddr *mac = addr; -memcpy (netdev->dev_addr, mac->sa_data,ETH_ALEN ); -return 1 ; -} - -static struct net_device_stats *at76_get_stats (struct net_device *netdev) -{ -struct at76_priv *priv =netdev_priv (netdev); -return &priv->stats; -} - -static struct iw_statistics *at76_get_wireless_stats (struct net_device *netdev) -{ -struct at76_priv *priv =netdev_priv (netdev); - -at76_dbg (DBG_IOCTL ,"RETURN qual %d level %d noise %d updated %d" , - priv->wstats.qual.qual, priv->wstats.qual.level, - priv->wstats.qual.noise, priv->wstats.qual.updated); - -return &priv->wstats; -} - -static void at76_set_multicast (struct net_device *netdev) -{ -struct at76_priv *priv =netdev_priv (netdev); -int promisc; - - promisc = ((netdev->flags &IFF_PROMISC ) !=0 ); -if (promisc != priv->promisc) { -/* This gets called in interrupt, must reschedule */ - priv->promisc = promisc; -schedule_work (&priv->work_set_promisc); - } -} - -/* Stop all network activity, flush all pending tasks */ -static void at76_quiesce (struct at76_priv *priv) -{ -unsigned long flags; - -netif_stop_queue (priv->netdev); -netif_carrier_off (priv->netdev); - -at76_set_mac_state (priv,MAC_INIT ); - -cancel_delayed_work (&priv->dwork_get_scan); -cancel_delayed_work (&priv->dwork_beacon); -cancel_delayed_work (&priv->dwork_auth); -cancel_delayed_work (&priv->dwork_assoc); -cancel_delayed_work (&priv->dwork_restart); - -spin_lock_irqsave (&priv->mgmt_spinlock, flags); -kfree (priv->next_mgmt_bulk); - priv->next_mgmt_bulk =NULL ; -spin_unlock_irqrestore (&priv->mgmt_spinlock, flags); -} - -/******************************************************************************* -* at76_priv implementations of iw_handler functions: -*/ -static int at76_iw_handler_commit (struct net_device *netdev, -struct iw_request_info *info, -void *null,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - -at76_dbg (DBG_IOCTL ,"%s %s: restarting the device" , netdev->name, - __func__); - -if (priv->mac_state !=MAC_INIT ) -at76_quiesce (priv); - -/* Wait half second before the restart to process subsequent -* requests from the same iwconfig in a single restart */ -schedule_delayed_work (&priv->dwork_restart,HZ /2 ); - -return 0 ; -} - -static int at76_iw_handler_get_name (struct net_device *netdev, -struct iw_request_info *info, -char *name,char *extra) -{ -strcpy (name,"IEEE 802.11b" ); -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWNAME - name %s" , netdev->name, name); -return 0 ; -} - -static int at76_iw_handler_set_freq (struct net_device *netdev, -struct iw_request_info *info, -struct iw_freq *freq,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int chan =-1 ; -int ret = -EIWCOMMIT ; -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWFREQ - freq.m %d freq.e %d" , - netdev->name, freq->m, freq->e); - -if ((freq->e ==0 ) && (freq->m <=1000 )) -/* Setting by channel number */ - chan = freq->m; -else { -/* Setting by frequency - search the table */ -int mult =1 ; -int i; - -for (i =0 ; i < (6 - freq->e); i++) - mult *=10 ; - -for (i =0 ; i <NUM_CHANNELS ; i++) { -if (freq->m == (channel_frequency[i] * mult)) - chan = i +1 ; - } - } - -if (chan <1 || !priv->domain) -/* non-positive channels are invalid -* we need a domain info to set the channel -* either that or an invalid frequency was -* provided by the user */ - ret = -EINVAL ; -else if (!(priv->domain->channel_map & (1 << (chan -1 )))) { -printk (KERN_INFO "%s: channel %d not allowed for domain %s\n" , - priv->netdev->name, chan, priv->domain->name); - ret = -EINVAL ; - } - -if (ret == -EIWCOMMIT ) { - priv->channel = chan; -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWFREQ - ch %d" , netdev->name, - chan); - } - -return ret; -} - -static int at76_iw_handler_get_freq (struct net_device *netdev, -struct iw_request_info *info, -struct iw_freq *freq,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - - freq->m = priv->channel; - freq->e =0 ; - -if (priv->channel) -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWFREQ - freq %ld x 10e%d" , - netdev->name, channel_frequency[priv->channel -1 ],6 ); - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWFREQ - ch %d" , netdev->name, - priv->channel); - -return 0 ; -} - -static int at76_iw_handler_set_mode (struct net_device *netdev, -struct iw_request_info *info, -__u32 *mode,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWMODE - %d" , netdev->name, *mode); - -if ((*mode !=IW_MODE_ADHOC ) && (*mode !=IW_MODE_INFRA ) && - (*mode !=IW_MODE_MONITOR )) -return -EINVAL ; - - priv->iw_mode = *mode; -if (priv->iw_mode !=IW_MODE_INFRA ) - priv->pm_mode =AT76_PM_OFF ; - -return -EIWCOMMIT ; -} - -static int at76_iw_handler_get_mode (struct net_device *netdev, -struct iw_request_info *info, -__u32 *mode,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - - *mode = priv->iw_mode; - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWMODE - %d" , netdev->name, *mode); - -return 0 ; -} - -static int at76_iw_handler_get_range (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *data,char *extra) -{ -/* inspired by atmel.c */ -struct at76_priv *priv =netdev_priv (netdev); -struct iw_range *range = (struct iw_range *)extra; -int i; - - data->length =sizeof (struct iw_range ); -memset (range,0 ,sizeof (struct iw_range )); - -/* TODO: range->throughput = xxxxxx; */ - - range->min_nwid =0x0000 ; - range->max_nwid =0x0000 ; - -/* this driver doesn't maintain sensitivity information */ - range->sensitivity =0 ; - - range->max_qual.qual =100 ; - range->max_qual.level =100 ; - range->max_qual.noise =0 ; - range->max_qual.updated =IW_QUAL_NOISE_INVALID ; - - range->avg_qual.qual =50 ; - range->avg_qual.level =50 ; - range->avg_qual.noise =0 ; - range->avg_qual.updated =IW_QUAL_NOISE_INVALID ; - - range->bitrate[0 ] =1000000 ; - range->bitrate[1 ] =2000000 ; - range->bitrate[2 ] =5500000 ; - range->bitrate[3 ] =11000000 ; - range->num_bitrates =4 ; - - range->min_rts =0 ; - range->max_rts =MAX_RTS_THRESHOLD ; - - range->min_frag =MIN_FRAG_THRESHOLD ; - range->max_frag =MAX_FRAG_THRESHOLD ; - - range->pmp_flags =IW_POWER_PERIOD ; - range->pmt_flags =IW_POWER_ON ; - range->pm_capa =IW_POWER_PERIOD |IW_POWER_ALL_R ; - - range->encoding_size[0 ] =WEP_SMALL_KEY_LEN ; - range->encoding_size[1 ] =WEP_LARGE_KEY_LEN ; - range->num_encoding_sizes =2 ; - range->max_encoding_tokens =WEP_KEYS ; - -/* both WL-240U and Linksys WUSB11 v2.6 specify 15 dBm as output power -- take this for all (ignore antenna gains) */ - range->txpower[0 ] =15 ; - range->num_txpower =1 ; - range->txpower_capa =IW_TXPOW_DBM ; - - range->we_version_source =WIRELESS_EXT ; - range->we_version_compiled =WIRELESS_EXT ; - -/* same as the values used in atmel.c */ - range->retry_capa =IW_RETRY_LIMIT ; - range->retry_flags =IW_RETRY_LIMIT ; - range->r_time_flags =0 ; - range->min_retry =1 ; - range->max_retry =255 ; - - range->num_channels =NUM_CHANNELS ; - range->num_frequency =0 ; - -for (i =0 ; i <NUM_CHANNELS ; i++) { -/* test if channel map bit is raised */ -if (priv->domain->channel_map & (0x1 << i)) { - range->num_frequency +=1 ; - - range->freq[i].i = i +1 ; - range->freq[i].m = channel_frequency[i] *100000 ; - range->freq[i].e =1 ;/* freq * 10^1 */ - } - } - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWRANGE" , netdev->name); - -return 0 ; -} - -static int at76_iw_handler_set_spy (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *data,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int ret =0 ; - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWSPY - number of addresses %d" , - netdev->name, data->length); - -spin_lock_bh (&priv->spy_spinlock); - ret =iw_handler_set_spy (priv->netdev, info, (union iwreq_data *)data, - extra); -spin_unlock_bh (&priv->spy_spinlock); - -return ret; -} - -static int at76_iw_handler_get_spy (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *data,char *extra) -{ - -struct at76_priv *priv =netdev_priv (netdev); -int ret =0 ; - -spin_lock_bh (&priv->spy_spinlock); - ret =iw_handler_get_spy (priv->netdev, info, - (union iwreq_data *)data, extra); -spin_unlock_bh (&priv->spy_spinlock); - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWSPY - number of addresses %d" , - netdev->name, data->length); - -return ret; -} - -static int at76_iw_handler_set_thrspy (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *data,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int ret; - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWTHRSPY - number of addresses %d)" , - netdev->name, data->length); - -spin_lock_bh (&priv->spy_spinlock); - ret =iw_handler_set_thrspy (netdev, info, (union iwreq_data *)data, - extra); -spin_unlock_bh (&priv->spy_spinlock); - -return ret; -} - -static int at76_iw_handler_get_thrspy (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *data,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int ret; - -spin_lock_bh (&priv->spy_spinlock); - ret =iw_handler_get_thrspy (netdev, info, (union iwreq_data *)data, - extra); -spin_unlock_bh (&priv->spy_spinlock); - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWTHRSPY - number of addresses %d)" , - netdev->name, data->length); - -return ret; -} - -static int at76_iw_handler_set_wap (struct net_device *netdev, -struct iw_request_info *info, -struct sockaddr *ap_addr,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWAP - wap/bssid %pM" , netdev->name, - ap_addr->sa_data); - -/* if the incoming address == ff:ff:ff:ff:ff:ff, the user has -chosen any or auto AP preference */ -if (is_broadcast_ether_addr (ap_addr->sa_data) - ||is_zero_ether_addr (ap_addr->sa_data)) - priv->wanted_bssid_valid =0 ; -else { -/* user wants to set a preferred AP address */ - priv->wanted_bssid_valid =1 ; -memcpy (priv->wanted_bssid, ap_addr->sa_data,ETH_ALEN ); - } - -return -EIWCOMMIT ; -} - -static int at76_iw_handler_get_wap (struct net_device *netdev, -struct iw_request_info *info, -struct sockaddr *ap_addr,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - - ap_addr->sa_family =ARPHRD_ETHER ; -memcpy (ap_addr->sa_data, priv->bssid,ETH_ALEN ); - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWAP - wap/bssid %pM" , netdev->name, - ap_addr->sa_data); - -return 0 ; -} - -static int at76_iw_handler_set_scan (struct net_device *netdev, -struct iw_request_info *info, -union iwreq_data *wrqu,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int ret =0 ; - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWSCAN" , netdev->name); - -if (mutex_lock_interruptible (&priv->mtx)) -return -EINTR ; - -if (!netif_running (netdev)) { - ret = -ENETDOWN ; - goto exit; - } - -/* jal: we don't allow "iwlist ethX scan" while we are -in monitor mode */ -if (priv->iw_mode ==IW_MODE_MONITOR ) { - ret = -EBUSY ; - goto exit; - } - -/* Discard old scan results */ -if ((jiffies - priv->last_scan) > (20 *HZ )) - priv->scan_state =SCAN_IDLE ; - priv->last_scan = jiffies; - -/* Initiate a scan command */ -if (priv->scan_state ==SCAN_IN_PROGRESS ) { - ret = -EBUSY ; - goto exit; - } - - priv->scan_state =SCAN_IN_PROGRESS ; - -at76_quiesce (priv); - -/* Try to do passive or active scan if WE asks as. */ -if (wrqu->data.length - && wrqu->data.length ==sizeof (struct iw_scan_req )) { -struct iw_scan_req *req = (struct iw_scan_req *)extra; - -if (req->scan_type ==IW_SCAN_TYPE_PASSIVE ) - priv->scan_mode =SCAN_TYPE_PASSIVE ; -else if (req->scan_type ==IW_SCAN_TYPE_ACTIVE ) - priv->scan_mode =SCAN_TYPE_ACTIVE ; - -/* Sanity check values? */ -if (req->min_channel_time >0 ) - priv->scan_min_time = req->min_channel_time; - -if (req->max_channel_time >0 ) - priv->scan_max_time = req->max_channel_time; - } - -/* change to scanning state */ -at76_set_mac_state (priv,MAC_SCANNING ); -schedule_work (&priv->work_start_scan); - -exit: -mutex_unlock (&priv->mtx); -return ret; -} - -static int at76_iw_handler_get_scan (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *data,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -unsigned long flags; -struct list_head *lptr, *nptr; -struct bss_info *curr_bss; -struct iw_event *iwe =kmalloc (sizeof (struct iw_event ),GFP_KERNEL ); -char *curr_val, *curr_pos = extra; -int i; - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWSCAN" , netdev->name); - -if (!iwe) -return -ENOMEM ; - -if (priv->scan_state !=SCAN_COMPLETED ) { -/* scan not yet finished */ -kfree (iwe); -return -EAGAIN ; - } - -spin_lock_irqsave (&priv->bss_list_spinlock, flags); - -list_for_each_safe (lptr, nptr, &priv->bss_list) { - curr_bss = list_entry(lptr, struct bss_info, list); - - iwe->cmd =SIOCGIWAP ; - iwe->u.ap_addr.sa_family =ARPHRD_ETHER ; -memcpy (iwe->u.ap_addr.sa_data, curr_bss->bssid,6 ); - curr_pos =iwe_stream_add_event (info, curr_pos, - extra +IW_SCAN_MAX_DATA , iwe, -IW_EV_ADDR_LEN ); - - iwe->u.data.length = curr_bss->ssid_len; - iwe->cmd =SIOCGIWESSID ; - iwe->u.data.flags =1 ; - - curr_pos =iwe_stream_add_point (info, curr_pos, - extra +IW_SCAN_MAX_DATA , iwe, - curr_bss->ssid); - - iwe->cmd =SIOCGIWMODE ; - iwe->u.mode = (curr_bss->capa &WLAN_CAPABILITY_IBSS ) ? -IW_MODE_ADHOC : - (curr_bss->capa &WLAN_CAPABILITY_ESS ) ? -IW_MODE_MASTER :IW_MODE_AUTO ; -/* IW_MODE_AUTO = 0 which I thought is -* the most logical value to return in this case */ - curr_pos =iwe_stream_add_event (info, curr_pos, - extra +IW_SCAN_MAX_DATA , iwe, -IW_EV_UINT_LEN ); - - iwe->cmd =SIOCGIWFREQ ; - iwe->u.freq.m = curr_bss->channel; - iwe->u.freq.e =0 ; - curr_pos =iwe_stream_add_event (info, curr_pos, - extra +IW_SCAN_MAX_DATA , iwe, -IW_EV_FREQ_LEN ); - - iwe->cmd =SIOCGIWENCODE ; -if (curr_bss->capa &WLAN_CAPABILITY_PRIVACY ) - iwe->u.data.flags =IW_ENCODE_ENABLED |IW_ENCODE_NOKEY ; -else - iwe->u.data.flags =IW_ENCODE_DISABLED ; - - iwe->u.data.length =0 ; - curr_pos =iwe_stream_add_point (info, curr_pos, - extra +IW_SCAN_MAX_DATA , iwe, -NULL ); - -/* Add quality statistics */ - iwe->cmd =IWEVQUAL ; - iwe->u.qual.noise =0 ; - iwe->u.qual.updated = -IW_QUAL_NOISE_INVALID |IW_QUAL_LEVEL_UPDATED ; - iwe->u.qual.level = (curr_bss->rssi *100 /42 ); -if (iwe->u.qual.level >100 ) - iwe->u.qual.level =100 ; -if (at76_is_intersil (priv->board_type)) - iwe->u.qual.qual = curr_bss->link_qual; -else { - iwe->u.qual.qual =0 ; - iwe->u.qual.updated |=IW_QUAL_QUAL_INVALID ; - } -/* Add new value to event */ - curr_pos =iwe_stream_add_event (info, curr_pos, - extra +IW_SCAN_MAX_DATA , iwe, -IW_EV_QUAL_LEN ); - -/* Rate: stuffing multiple values in a single event requires -* a bit more of magic - Jean II */ - curr_val = curr_pos +IW_EV_LCP_LEN ; - - iwe->cmd =SIOCGIWRATE ; -/* Those two flags are ignored... */ - iwe->u.bitrate.fixed =0 ; - iwe->u.bitrate.disabled =0 ; -/* Max 8 values */ -for (i =0 ; i < curr_bss->rates_len; i++) { -/* Bit rate given in 500 kb/s units (+ 0x80) */ - iwe->u.bitrate.value = - ((curr_bss->rates[i] &0x7f ) *500000 ); -/* Add new value to event */ - curr_val =iwe_stream_add_value (info, curr_pos, - curr_val, - extra + -IW_SCAN_MAX_DATA , iwe, -IW_EV_PARAM_LEN ); - } - -/* Check if we added any event */ -if ((curr_val - curr_pos) >IW_EV_LCP_LEN ) - curr_pos = curr_val; - -/* more information may be sent back using IWECUSTOM */ - - } - -spin_unlock_irqrestore (&priv->bss_list_spinlock, flags); - - data->length = (curr_pos - extra); - data->flags =0 ; - -kfree (iwe); -return 0 ; -} - -static int at76_iw_handler_set_essid (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *data,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWESSID - %s" , netdev->name, extra); - -if (data->flags) { -memcpy (priv->essid, extra, data->length); - priv->essid_size = data->length; - }else - priv->essid_size =0 ;/* Use any SSID */ - -return -EIWCOMMIT ; -} - -static int at76_iw_handler_get_essid (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *data,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - -if (priv->essid_size) { -/* not the ANY ssid in priv->essid */ - data->flags =1 ; - data->length = priv->essid_size; -memcpy (extra, priv->essid, data->length); - }else { -/* the ANY ssid was specified */ -if (priv->mac_state ==MAC_CONNECTED && priv->curr_bss) { -/* report the SSID we have found */ - data->flags =1 ; - data->length = priv->curr_bss->ssid_len; -memcpy (extra, priv->curr_bss->ssid, data->length); - }else { -/* report ANY back */ - data->flags =0 ; - data->length =0 ; - } - } - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWESSID - %.*s" , netdev->name, - data->length, extra); - -return 0 ; -} - -static int at76_iw_handler_set_rate (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *bitrate,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int ret = -EIWCOMMIT ; - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWRATE - %d" , netdev->name, - bitrate->value); - -switch (bitrate->value) { -case -1 : - priv->txrate =TX_RATE_AUTO ; -break ;/* auto rate */ -case 1000000 : - priv->txrate =TX_RATE_1MBIT ; -break ; -case 2000000 : - priv->txrate =TX_RATE_2MBIT ; -break ; -case 5500000 : - priv->txrate =TX_RATE_5_5MBIT ; -break ; -case 11000000 : - priv->txrate =TX_RATE_11MBIT ; -break ; -default : - ret = -EINVAL ; - } - -return ret; -} - -static int at76_iw_handler_get_rate (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *bitrate,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int ret =0 ; - -switch (priv->txrate) { -/* return max rate if RATE_AUTO */ -case TX_RATE_AUTO : - bitrate->value =11000000 ; -break ; -case TX_RATE_1MBIT : - bitrate->value =1000000 ; -break ; -case TX_RATE_2MBIT : - bitrate->value =2000000 ; -break ; -case TX_RATE_5_5MBIT : - bitrate->value =5500000 ; -break ; -case TX_RATE_11MBIT : - bitrate->value =11000000 ; -break ; -default : - ret = -EINVAL ; - } - - bitrate->fixed = (priv->txrate !=TX_RATE_AUTO ); - bitrate->disabled =0 ; - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWRATE - %d" , netdev->name, - bitrate->value); - -return ret; -} - -static int at76_iw_handler_set_rts (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *rts,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int ret = -EIWCOMMIT ; -int rthr = rts->value; - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWRTS - value %d disabled %s" , - netdev->name, rts->value, (rts->disabled) ?"true" :"false" ); - -if (rts->disabled) - rthr =MAX_RTS_THRESHOLD ; - -if ((rthr <0 ) || (rthr >MAX_RTS_THRESHOLD )) - ret = -EINVAL ; -else - priv->rts_threshold = rthr; - -return ret; -} - -static int at76_iw_handler_get_rts (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *rts,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - - rts->value = priv->rts_threshold; - rts->disabled = (rts->value >=MAX_RTS_THRESHOLD ); - rts->fixed =1 ; - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWRTS - value %d disabled %s" , - netdev->name, rts->value, (rts->disabled) ?"true" :"false" ); - -return 0 ; -} - -static int at76_iw_handler_set_frag (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *frag,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int ret = -EIWCOMMIT ; -int fthr = frag->value; - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWFRAG - value %d, disabled %s" , - netdev->name, frag->value, - (frag->disabled) ?"true" :"false" ); - -if (frag->disabled) - fthr =MAX_FRAG_THRESHOLD ; - -if ((fthr <MIN_FRAG_THRESHOLD ) || (fthr >MAX_FRAG_THRESHOLD )) - ret = -EINVAL ; -else - priv->frag_threshold = fthr & ~0x1 ;/* get an even value */ - -return ret; -} - -static int at76_iw_handler_get_frag (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *frag,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - - frag->value = priv->frag_threshold; - frag->disabled = (frag->value >=MAX_FRAG_THRESHOLD ); - frag->fixed =1 ; - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWFRAG - value %d, disabled %s" , - netdev->name, frag->value, - (frag->disabled) ?"true" :"false" ); - -return 0 ; -} - -static int at76_iw_handler_get_txpow (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *power,char *extra) -{ - power->value =15 ; - power->fixed =1 ;/* No power control */ - power->disabled =0 ; - power->flags =IW_TXPOW_DBM ; - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWTXPOW - txpow %d dBm" , netdev->name, - power->value); - -return 0 ; -} - -/* jal: short retry is handled by the firmware (at least 0.90.x), -while long retry is not (?) */ -static int at76_iw_handler_set_retry (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *retry,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int ret = -EIWCOMMIT ; - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWRETRY disabled %d flags 0x%x val %d" , - netdev->name, retry->disabled, retry->flags, retry->value); - -if (!retry->disabled && (retry->flags &IW_RETRY_LIMIT )) { -if ((retry->flags &IW_RETRY_MIN ) || - !(retry->flags &IW_RETRY_MAX )) - priv->short_retry_limit = retry->value; -else - ret = -EINVAL ; - }else - ret = -EINVAL ; - -return ret; -} - -/* Adapted (ripped) from atmel.c */ -static int at76_iw_handler_get_retry (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *retry,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWRETRY" , netdev->name); - - retry->disabled =0 ;/* Can't be disabled */ - retry->flags =IW_RETRY_LIMIT ; - retry->value = priv->short_retry_limit; - -return 0 ; -} - -static int at76_iw_handler_set_encode (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *encoding,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int index = (encoding->flags &IW_ENCODE_INDEX ) -1 ; -int len = encoding->length; - -at76_dbg (DBG_IOCTL ,"%s: SIOCSIWENCODE - enc.flags %08x " -"pointer %p len %d" , netdev->name, encoding->flags, - encoding->pointer, encoding->length); -at76_dbg (DBG_IOCTL , -"%s: SIOCSIWENCODE - old wepstate: enabled %s key_id %d " -"auth_mode %s" , netdev->name, - (priv->wep_enabled) ?"true" :"false" , priv->wep_key_id, - (priv->auth_mode == -WLAN_AUTH_SHARED_KEY ) ?"restricted" :"open" ); - -/* take the old default key if index is invalid */ -if ((index <0 ) || (index >=WEP_KEYS )) - index = priv->wep_key_id; - -if (len >0 ) { -if (len >WEP_LARGE_KEY_LEN ) - len =WEP_LARGE_KEY_LEN ; - -memset (priv->wep_keys[index],0 ,WEP_KEY_LEN ); -memcpy (priv->wep_keys[index], extra, len); - priv->wep_keys_len[index] = (len <=WEP_SMALL_KEY_LEN ) ? -WEP_SMALL_KEY_LEN :WEP_LARGE_KEY_LEN ; - priv->wep_enabled =1 ; - } - - priv->wep_key_id = index; - priv->wep_enabled = ((encoding->flags &IW_ENCODE_DISABLED ) ==0 ); - -if (encoding->flags &IW_ENCODE_RESTRICTED ) - priv->auth_mode =WLAN_AUTH_SHARED_KEY ; -if (encoding->flags &IW_ENCODE_OPEN ) - priv->auth_mode =WLAN_AUTH_OPEN ; - -at76_dbg (DBG_IOCTL , -"%s: SIOCSIWENCODE - new wepstate: enabled %s key_id %d " -"key_len %d auth_mode %s" , netdev->name, - (priv->wep_enabled) ?"true" :"false" , priv->wep_key_id +1 , - priv->wep_keys_len[priv->wep_key_id], - (priv->auth_mode == -WLAN_AUTH_SHARED_KEY ) ?"restricted" :"open" ); - -return -EIWCOMMIT ; -} - -static int at76_iw_handler_get_encode (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *encoding,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int index = (encoding->flags &IW_ENCODE_INDEX ) -1 ; - -if ((index <0 ) || (index >=WEP_KEYS )) - index = priv->wep_key_id; - - encoding->flags = - (priv->auth_mode ==WLAN_AUTH_SHARED_KEY ) ? -IW_ENCODE_RESTRICTED :IW_ENCODE_OPEN ; - -if (!priv->wep_enabled) - encoding->flags |=IW_ENCODE_DISABLED ; - -if (encoding->pointer) { - encoding->length = priv->wep_keys_len[index]; - -memcpy (extra, priv->wep_keys[index], priv->wep_keys_len[index]); - - encoding->flags |= (index +1 ); - } - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWENCODE - enc.flags %08x " -"pointer %p len %d" , netdev->name, encoding->flags, - encoding->pointer, encoding->length); -at76_dbg (DBG_IOCTL , -"%s: SIOCGIWENCODE - wepstate: enabled %s key_id %d " -"key_len %d auth_mode %s" , netdev->name, - (priv->wep_enabled) ?"true" :"false" , priv->wep_key_id +1 , - priv->wep_keys_len[priv->wep_key_id], - (priv->auth_mode == -WLAN_AUTH_SHARED_KEY ) ?"restricted" :"open" ); - -return 0 ; -} - -static int at76_iw_handler_set_power (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *prq,char *extra) -{ -int err = -EIWCOMMIT ; -struct at76_priv *priv =netdev_priv (netdev); - -at76_dbg (DBG_IOCTL , -"%s: SIOCSIWPOWER - disabled %s flags 0x%x value 0x%x" , - netdev->name, (prq->disabled) ?"true" :"false" , prq->flags, - prq->value); - -if (prq->disabled) - priv->pm_mode =AT76_PM_OFF ; -else { -switch (prq->flags &IW_POWER_MODE ) { -case IW_POWER_ALL_R : -case IW_POWER_ON : -break ; -default : - err = -EINVAL ; - goto exit; - } -if (prq->flags &IW_POWER_PERIOD ) - priv->pm_period = prq->value; - -if (prq->flags &IW_POWER_TIMEOUT ) { - err = -EINVAL ; - goto exit; - } - priv->pm_mode =AT76_PM_ON ; - } -exit: -return err; -} - -static int at76_iw_handler_get_power (struct net_device *netdev, -struct iw_request_info *info, -struct iw_param *power,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - - power->disabled = (priv->pm_mode ==AT76_PM_OFF ); -if (!power->disabled) { - power->flags =IW_POWER_PERIOD |IW_POWER_ALL_R ; - power->value = priv->pm_period; - } - -at76_dbg (DBG_IOCTL ,"%s: SIOCGIWPOWER - %s flags 0x%x value 0x%x" , - netdev->name, power->disabled ?"disabled" :"enabled" , - power->flags, power->value); - -return 0 ; -} - -/******************************************************************************* -* Private IOCTLS -*/ -static int at76_iw_set_short_preamble (struct net_device *netdev, -struct iw_request_info *info,char *name, -char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int val = *((int *)name); -int ret = -EIWCOMMIT ; - -at76_dbg (DBG_IOCTL ,"%s: AT76_SET_SHORT_PREAMBLE, %d" , - netdev->name, val); - -if (val <PREAMBLE_TYPE_LONG || val >PREAMBLE_TYPE_AUTO ) - ret = -EINVAL ; -else - priv->preamble_type = val; - -return ret; -} - -static int at76_iw_get_short_preamble (struct net_device *netdev, -struct iw_request_info *info, -union iwreq_data *wrqu,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); - -snprintf (wrqu->name,sizeof (wrqu->name),"%s (%d)" , - preambles[priv->preamble_type], priv->preamble_type); -return 0 ; -} - -static int at76_iw_set_debug (struct net_device *netdev, -struct iw_request_info *info, -struct iw_point *data,char *extra) -{ -char *ptr; -u32 val; - -if (data->length >0 ) { - val =simple_strtol (extra, &ptr,0 ); - -if (ptr == extra) - val =DBG_DEFAULTS ; - -at76_dbg (DBG_IOCTL ,"%s: AT76_SET_DEBUG input %d: %s -> 0x%x" , - netdev->name, data->length, extra, val); - }else - val =DBG_DEFAULTS ; - -at76_dbg (DBG_IOCTL ,"%s: AT76_SET_DEBUG, old 0x%x, new 0x%x" , - netdev->name, at76_debug, val); - -/* jal: some more output to pin down lockups */ -at76_dbg (DBG_IOCTL ,"%s: netif running %d queue_stopped %d " -"carrier_ok %d" , netdev->name,netif_running (netdev), -netif_queue_stopped (netdev),netif_carrier_ok (netdev)); - - at76_debug = val; - -return 0 ; -} - -static int at76_iw_get_debug (struct net_device *netdev, -struct iw_request_info *info, -union iwreq_data *wrqu,char *extra) -{ -snprintf (wrqu->name,sizeof (wrqu->name),"0x%08x" , at76_debug); -return 0 ; -} - -static int at76_iw_set_powersave_mode (struct net_device *netdev, -struct iw_request_info *info,char *name, -char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int val = *((int *)name); -int ret = -EIWCOMMIT ; - -at76_dbg (DBG_IOCTL ,"%s: AT76_SET_POWERSAVE_MODE, %d (%s)" , - netdev->name, val, - val ==AT76_PM_OFF ?"active" : val ==AT76_PM_ON ?"save" : - val ==AT76_PM_SMART ?"smart save" :"<invalid>" ); -if (val <AT76_PM_OFF || val >AT76_PM_SMART ) - ret = -EINVAL ; -else - priv->pm_mode = val; - -return ret; -} - -static int at76_iw_get_powersave_mode (struct net_device *netdev, -struct iw_request_info *info, -union iwreq_data *wrqu,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int *param = (int *)extra; - - param[0 ] = priv->pm_mode; -return 0 ; -} - -static int at76_iw_set_scan_times (struct net_device *netdev, -struct iw_request_info *info,char *name, -char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int mint = *((int *)name); -int maxt = *((int *)name +1 ); -int ret = -EIWCOMMIT ; - -at76_dbg (DBG_IOCTL ,"%s: AT76_SET_SCAN_TIMES - min %d max %d" , - netdev->name, mint, maxt); -if (mint <=0 || maxt <=0 || mint > maxt) - ret = -EINVAL ; -else { - priv->scan_min_time = mint; - priv->scan_max_time = maxt; - } - -return ret; -} - -static int at76_iw_get_scan_times (struct net_device *netdev, -struct iw_request_info *info, -union iwreq_data *wrqu,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int *param = (int *)extra; - - param[0 ] = priv->scan_min_time; - param[1 ] = priv->scan_max_time; -return 0 ; -} - -static int at76_iw_set_scan_mode (struct net_device *netdev, -struct iw_request_info *info,char *name, -char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int val = *((int *)name); -int ret = -EIWCOMMIT ; - -at76_dbg (DBG_IOCTL ,"%s: AT76_SET_SCAN_MODE - mode %s" , - netdev->name, (val =SCAN_TYPE_ACTIVE ) ?"active" : - (val =SCAN_TYPE_PASSIVE ) ?"passive" :"<invalid>" ); - -if (val !=SCAN_TYPE_ACTIVE && val !=SCAN_TYPE_PASSIVE ) - ret = -EINVAL ; -else - priv->scan_mode = val; - -return ret; -} - -static int at76_iw_get_scan_mode (struct net_device *netdev, -struct iw_request_info *info, -union iwreq_data *wrqu,char *extra) -{ -struct at76_priv *priv =netdev_priv (netdev); -int *param = (int *)extra; - - param[0 ] = priv->scan_mode; -return 0 ; -} - -#define AT76_SET_HANDLER (h, f) [h - SIOCIWFIRST] = (iw_handler) f - -/* Standard wireless handlers */ -static const iw_handler at76_handlers[] = {
Lines of this file are not shown. View the raw message.
drivers/staging/at76_usb/at76_usb.h deleted +0 -706
706 lines not on this page · raw message
drivers/staging/at76_usb/Kconfig deleted +0 -8
Lines of this file are not shown. View the raw message.
drivers/staging/at76_usb/Makefile deleted +0 -1
Lines of this file are not shown. View the raw message.
drivers/staging/at76_usb/TODO deleted +0 -7
Lines of this file are not shown. View the raw message.
drivers/staging/Kconfig +0 -2
Lines of this file are not shown. View the raw message.
drivers/staging/Makefile +0 -1
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Kalle Valo
Acked-byQuoted 10 lines · <[email protected]> writes:
From: Greg Kroah-Hartman <[email protected]>
Subject: Staging: removeat76_usbwireless driver.There is already an in-kernel driver for this hardware (since 2.6.30), at76c50x-usb, and it supports all of the same devices. So this driver can now be deleted.
Cc Kalle Valo <[email protected]>Cc linux-wireless <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>
Thanks.
Signature · 1 line
Kalle Valo
Quoted 9 lines · Kalle Valo
Quoted 7 lines · <[email protected]> writes:
From: Greg Kroah-Hartman <[email protected]>
Subject: Staging: removeat76_usbwireless driver.There is already an in-kernel driver for this hardware (since 2.6.30), at76c50x-usb, and it supports all of the same devices. So this driver can now be deleted.
Quoted 7 lines
Quoted 3 lines
Cc Kalle Valo <[email protected]>Cc linux-wireless <[email protected]>Signed-off-by Greg Kroah-Hartman <[email protected]>Thanks.
Acked-by Kalle Valo <[email protected]>
Thanks, I've added this to the patch.
greg k-h