2005-04-16 22:20:36 +00:00
|
|
|
/*=============================================================================
|
|
|
|
*
|
|
|
|
* A PCMCIA client driver for the Raylink wireless LAN card.
|
|
|
|
* The starting point for this module was the skeleton.c in the
|
|
|
|
* PCMCIA 2.9.12 package written by David Hinds, dahinds@users.sourceforge.net
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Copyright (c) 1998 Corey Thomas (corey@world.std.com)
|
|
|
|
*
|
|
|
|
* This driver is free software; you can redistribute it and/or modify
|
2009-03-10 13:59:54 +00:00
|
|
|
* it under the terms of version 2 only of the GNU General Public License as
|
2005-04-16 22:20:36 +00:00
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* It is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
* Arnaldo Carvalho de Melo <acme@conectiva.com.br> - 08/08/2000
|
|
|
|
* - reorganize kmallocs in ray_attach, checking all for failure
|
|
|
|
* and releasing the previous allocations if one fails
|
|
|
|
*
|
|
|
|
* Daniele Bellucci <bellucda@tiscali.it> - 07/10/2003
|
|
|
|
* - Audit copy_to_user in ioctl(SIOCGIWESSID)
|
2009-03-10 13:59:54 +00:00
|
|
|
*
|
2005-04-16 22:20:36 +00:00
|
|
|
=============================================================================*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/proc_fs.h>
|
|
|
|
#include <linux/ptrace.h>
|
2008-04-10 21:34:35 +00:00
|
|
|
#include <linux/seq_file.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/timer.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/if_arp.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/skbuff.h>
|
2007-12-29 09:55:50 +00:00
|
|
|
#include <linux/ieee80211.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <pcmcia/cistpl.h>
|
|
|
|
#include <pcmcia/cisreg.h>
|
|
|
|
#include <pcmcia/ds.h>
|
|
|
|
|
|
|
|
#include <linux/wireless.h>
|
2006-08-14 06:27:17 +00:00
|
|
|
#include <net/iw_handler.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
#include <asm/uaccess.h>
|
|
|
|
|
|
|
|
/* Warning : these stuff will slow down the driver... */
|
|
|
|
#define WIRELESS_SPY /* Enable spying addresses */
|
|
|
|
/* Definitions we need for spy */
|
2009-03-10 13:59:54 +00:00
|
|
|
typedef struct iw_statistics iw_stats;
|
|
|
|
typedef u_char mac_addr[ETH_ALEN]; /* Hardware address */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include "rayctl.h"
|
|
|
|
#include "ray_cs.h"
|
|
|
|
|
|
|
|
|
|
|
|
/** Prototypes based on PCMCIA skeleton driver *******************************/
|
2006-03-31 15:26:06 +00:00
|
|
|
static int ray_config(struct pcmcia_device *link);
|
2006-03-31 15:21:06 +00:00
|
|
|
static void ray_release(struct pcmcia_device *link);
|
2005-11-14 20:23:14 +00:00
|
|
|
static void ray_detach(struct pcmcia_device *p_dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/***** Prototypes indicated by device structure ******************************/
|
|
|
|
static int ray_dev_close(struct net_device *dev);
|
|
|
|
static int ray_dev_config(struct net_device *dev, struct ifmap *map);
|
|
|
|
static struct net_device_stats *ray_get_stats(struct net_device *dev);
|
|
|
|
static int ray_dev_init(struct net_device *dev);
|
|
|
|
|
|
|
|
static int ray_open(struct net_device *dev);
|
2009-08-31 19:50:57 +00:00
|
|
|
static netdev_tx_t ray_dev_start_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
static void set_multicast_list(struct net_device *dev);
|
|
|
|
static void ray_update_multi_list(struct net_device *dev, int all);
|
|
|
|
static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
|
2009-03-10 13:59:54 +00:00
|
|
|
unsigned char *data, int len);
|
|
|
|
static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
|
|
|
|
UCHAR msg_type, unsigned char *data);
|
2005-04-16 22:20:36 +00:00
|
|
|
static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len);
|
2009-03-10 13:59:54 +00:00
|
|
|
static iw_stats *ray_get_wireless_stats(struct net_device *dev);
|
|
|
|
static const struct iw_handler_def ray_handler_def;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/***** Prototypes for raylink functions **************************************/
|
|
|
|
static void authenticate(ray_dev_t *local);
|
|
|
|
static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type);
|
|
|
|
static void authenticate_timeout(u_long);
|
|
|
|
static int get_free_ccs(ray_dev_t *local);
|
|
|
|
static int get_free_tx_ccs(ray_dev_t *local);
|
|
|
|
static void init_startup_params(ray_dev_t *local);
|
|
|
|
static int parse_addr(char *in_str, UCHAR *out);
|
2009-03-10 13:59:54 +00:00
|
|
|
static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev, UCHAR type);
|
2005-04-16 22:20:36 +00:00
|
|
|
static int ray_init(struct net_device *dev);
|
|
|
|
static int interrupt_ecf(ray_dev_t *local, int ccs);
|
|
|
|
static void ray_reset(struct net_device *dev);
|
|
|
|
static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len);
|
|
|
|
static void verify_dl_startup(u_long);
|
|
|
|
|
|
|
|
/* Prototypes for interrpt time functions **********************************/
|
2009-03-10 13:59:54 +00:00
|
|
|
static irqreturn_t ray_interrupt(int reg, void *dev_id);
|
2005-04-16 22:20:36 +00:00
|
|
|
static void clear_interrupt(ray_dev_t *local);
|
2009-03-10 13:59:54 +00:00
|
|
|
static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
|
|
|
|
unsigned int pkt_addr, int rx_len);
|
2005-04-16 22:20:36 +00:00
|
|
|
static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr, int len);
|
|
|
|
static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem *prcs);
|
|
|
|
static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs);
|
|
|
|
static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
|
2009-03-10 13:59:54 +00:00
|
|
|
unsigned int pkt_addr, int rx_len);
|
|
|
|
static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
|
|
|
|
unsigned int pkt_addr, int rx_len);
|
2005-04-16 22:20:36 +00:00
|
|
|
static void associate(ray_dev_t *local);
|
|
|
|
|
|
|
|
/* Card command functions */
|
|
|
|
static int dl_startup_params(struct net_device *dev);
|
|
|
|
static void join_net(u_long local);
|
|
|
|
static void start_net(u_long local);
|
|
|
|
/* void start_net(ray_dev_t *local); */
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Parameters that can be set with 'insmod' */
|
|
|
|
|
|
|
|
/* ADHOC=0, Infrastructure=1 */
|
|
|
|
static int net_type = ADHOC;
|
|
|
|
|
|
|
|
/* Hop dwell time in Kus (1024 us units defined by 802.11) */
|
|
|
|
static int hop_dwell = 128;
|
|
|
|
|
|
|
|
/* Beacon period in Kus */
|
|
|
|
static int beacon_period = 256;
|
|
|
|
|
|
|
|
/* power save mode (0 = off, 1 = save power) */
|
|
|
|
static int psm;
|
|
|
|
|
|
|
|
/* String for network's Extended Service Set ID. 32 Characters max */
|
|
|
|
static char *essid;
|
|
|
|
|
|
|
|
/* Default to encapsulation unless translation requested */
|
2013-02-26 10:04:51 +00:00
|
|
|
static bool translate = 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static int country = USA;
|
|
|
|
|
|
|
|
static int sniffer;
|
|
|
|
|
|
|
|
static int bc;
|
|
|
|
|
|
|
|
/* 48 bit physical card address if overriding card's real physical
|
|
|
|
* address is required. Since IEEE 802.11 addresses are 48 bits
|
|
|
|
* like ethernet, an int can't be used, so a string is used. To
|
|
|
|
* allow use of addresses starting with a decimal digit, the first
|
|
|
|
* character must be a letter and will be ignored. This letter is
|
|
|
|
* followed by up to 12 hex digits which are the address. If less
|
|
|
|
* than 12 digits are used, the address will be left filled with 0's.
|
|
|
|
* Note that bit 0 of the first byte is the broadcast bit, and evil
|
|
|
|
* things will happen if it is not 0 in a card address.
|
|
|
|
*/
|
|
|
|
static char *phy_addr = NULL;
|
|
|
|
|
|
|
|
static unsigned int ray_mem_speed = 500;
|
|
|
|
|
2006-03-05 09:45:09 +00:00
|
|
|
/* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */
|
|
|
|
static struct pcmcia_device *this_device = NULL;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
MODULE_AUTHOR("Corey Thomas <corey@world.std.com>");
|
|
|
|
MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
module_param(net_type, int, 0);
|
|
|
|
module_param(hop_dwell, int, 0);
|
|
|
|
module_param(beacon_period, int, 0);
|
|
|
|
module_param(psm, int, 0);
|
|
|
|
module_param(essid, charp, 0);
|
2013-02-26 10:04:51 +00:00
|
|
|
module_param(translate, bool, 0);
|
2005-04-16 22:20:36 +00:00
|
|
|
module_param(country, int, 0);
|
|
|
|
module_param(sniffer, int, 0);
|
|
|
|
module_param(bc, int, 0);
|
|
|
|
module_param(phy_addr, charp, 0);
|
|
|
|
module_param(ray_mem_speed, int, 0);
|
|
|
|
|
2010-09-02 01:16:22 +00:00
|
|
|
static const UCHAR b5_default_startup_parms[] = {
|
2009-03-10 13:59:54 +00:00
|
|
|
0, 0, /* Adhoc station */
|
|
|
|
'L', 'I', 'N', 'U', 'X', 0, 0, 0, /* 32 char ESSID */
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
1, 0, /* Active scan, CA Mode */
|
|
|
|
0, 0, 0, 0, 0, 0, /* No default MAC addr */
|
|
|
|
0x7f, 0xff, /* Frag threshold */
|
|
|
|
0x00, 0x80, /* Hop time 128 Kus */
|
|
|
|
0x01, 0x00, /* Beacon period 256 Kus */
|
|
|
|
0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout */
|
|
|
|
0x1d, 0x82, 0x4e, /* SIFS, DIFS, PIFS */
|
|
|
|
0x7f, 0xff, /* RTS threshold */
|
|
|
|
0x04, 0xe2, 0x38, 0xA4, /* scan_dwell, max_scan_dwell */
|
|
|
|
0x05, /* assoc resp timeout thresh */
|
|
|
|
0x08, 0x02, 0x08, /* adhoc, infra, super cycle max */
|
|
|
|
0, /* Promiscuous mode */
|
|
|
|
0x0c, 0x0bd, /* Unique word */
|
|
|
|
0x32, /* Slot time */
|
|
|
|
0xff, 0xff, /* roam-low snr, low snr count */
|
|
|
|
0x05, 0xff, /* Infra, adhoc missed bcn thresh */
|
|
|
|
0x01, 0x0b, 0x4f, /* USA, hop pattern, hop pat length */
|
2005-04-16 22:20:36 +00:00
|
|
|
/* b4 - b5 differences start here */
|
2009-03-10 13:59:54 +00:00
|
|
|
0x00, 0x3f, /* CW max */
|
|
|
|
0x00, 0x0f, /* CW min */
|
|
|
|
0x04, 0x08, /* Noise gain, limit offset */
|
|
|
|
0x28, 0x28, /* det rssi, med busy offsets */
|
|
|
|
7, /* det sync thresh */
|
|
|
|
0, 2, 2, /* test mode, min, max */
|
|
|
|
0, /* allow broadcast SSID probe resp */
|
|
|
|
0, 0, /* privacy must start, can join */
|
|
|
|
2, 0, 0, 0, 0, 0, 0, 0 /* basic rate set */
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2010-09-02 01:16:22 +00:00
|
|
|
static const UCHAR b4_default_startup_parms[] = {
|
2009-03-10 13:59:54 +00:00
|
|
|
0, 0, /* Adhoc station */
|
|
|
|
'L', 'I', 'N', 'U', 'X', 0, 0, 0, /* 32 char ESSID */
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
0, 0, 0, 0, 0, 0, 0, 0,
|
|
|
|
1, 0, /* Active scan, CA Mode */
|
|
|
|
0, 0, 0, 0, 0, 0, /* No default MAC addr */
|
|
|
|
0x7f, 0xff, /* Frag threshold */
|
|
|
|
0x02, 0x00, /* Hop time */
|
|
|
|
0x00, 0x01, /* Beacon period */
|
|
|
|
0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout */
|
|
|
|
0x1d, 0x82, 0xce, /* SIFS, DIFS, PIFS */
|
|
|
|
0x7f, 0xff, /* RTS threshold */
|
|
|
|
0xfb, 0x1e, 0xc7, 0x5c, /* scan_dwell, max_scan_dwell */
|
|
|
|
0x05, /* assoc resp timeout thresh */
|
|
|
|
0x04, 0x02, 0x4, /* adhoc, infra, super cycle max */
|
|
|
|
0, /* Promiscuous mode */
|
|
|
|
0x0c, 0x0bd, /* Unique word */
|
|
|
|
0x4e, /* Slot time (TBD seems wrong) */
|
|
|
|
0xff, 0xff, /* roam-low snr, low snr count */
|
|
|
|
0x05, 0xff, /* Infra, adhoc missed bcn thresh */
|
|
|
|
0x01, 0x0b, 0x4e, /* USA, hop pattern, hop pat length */
|
2005-04-16 22:20:36 +00:00
|
|
|
/* b4 - b5 differences start here */
|
2009-03-10 13:59:54 +00:00
|
|
|
0x3f, 0x0f, /* CW max, min */
|
|
|
|
0x04, 0x08, /* Noise gain, limit offset */
|
|
|
|
0x28, 0x28, /* det rssi, med busy offsets */
|
|
|
|
7, /* det sync thresh */
|
|
|
|
0, 2, 2 /* test mode, min, max */
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2010-09-02 01:16:22 +00:00
|
|
|
static const u8 eth2_llc[] = { 0xaa, 0xaa, 3, 0, 0, 0 };
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-09-02 01:16:22 +00:00
|
|
|
static const char hop_pattern_length[] = { 1,
|
2009-03-10 13:59:54 +00:00
|
|
|
USA_HOP_MOD, EUROPE_HOP_MOD,
|
|
|
|
JAPAN_HOP_MOD, KOREA_HOP_MOD,
|
|
|
|
SPAIN_HOP_MOD, FRANCE_HOP_MOD,
|
|
|
|
ISRAEL_HOP_MOD, AUSTRALIA_HOP_MOD,
|
|
|
|
JAPAN_TEST_HOP_MOD
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2010-09-02 01:16:22 +00:00
|
|
|
static const char rcsid[] =
|
2009-03-10 13:59:54 +00:00
|
|
|
"Raylink/WebGear wireless LAN - Corey <Thomas corey@world.std.com>";
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-20 19:36:28 +00:00
|
|
|
static const struct net_device_ops ray_netdev_ops = {
|
|
|
|
.ndo_init = ray_dev_init,
|
|
|
|
.ndo_open = ray_open,
|
|
|
|
.ndo_stop = ray_dev_close,
|
|
|
|
.ndo_start_xmit = ray_dev_start_xmit,
|
|
|
|
.ndo_set_config = ray_dev_config,
|
|
|
|
.ndo_get_stats = ray_get_stats,
|
2011-08-16 06:29:01 +00:00
|
|
|
.ndo_set_rx_mode = set_multicast_list,
|
2009-03-20 19:36:28 +00:00
|
|
|
.ndo_change_mtu = eth_change_mtu,
|
|
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
|
|
};
|
|
|
|
|
2006-03-31 15:26:06 +00:00
|
|
|
static int ray_probe(struct pcmcia_device *p_dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local;
|
|
|
|
struct net_device *dev;
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&p_dev->dev, "ray_attach()\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
/* Allocate space for private device-specific data */
|
|
|
|
dev = alloc_etherdev(sizeof(ray_dev_t));
|
|
|
|
if (!dev)
|
|
|
|
goto fail_alloc_dev;
|
|
|
|
|
|
|
|
local = netdev_priv(dev);
|
|
|
|
local->finder = p_dev;
|
|
|
|
|
|
|
|
/* The io structure describes IO port mapping. None used here */
|
2010-07-24 15:23:51 +00:00
|
|
|
p_dev->resource[0]->end = 0;
|
|
|
|
p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
/* General socket configuration */
|
2010-07-29 17:27:09 +00:00
|
|
|
p_dev->config_flags |= CONF_ENABLE_IRQ;
|
2010-07-29 16:35:47 +00:00
|
|
|
p_dev->config_index = 1;
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
p_dev->priv = dev;
|
|
|
|
|
|
|
|
local->finder = p_dev;
|
|
|
|
local->card_status = CARD_INSERTED;
|
|
|
|
local->authentication_state = UNAUTHENTICATED;
|
|
|
|
local->num_multi = 0;
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&p_dev->dev, "ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
p_dev, dev, local, &ray_interrupt);
|
|
|
|
|
|
|
|
/* Raylink entries in the device structure */
|
2009-03-20 19:36:28 +00:00
|
|
|
dev->netdev_ops = &ray_netdev_ops;
|
2009-03-10 13:59:54 +00:00
|
|
|
dev->wireless_handlers = &ray_handler_def;
|
2005-09-02 18:40:39 +00:00
|
|
|
#ifdef WIRELESS_SPY
|
2009-03-10 13:59:54 +00:00
|
|
|
local->wireless_data.spy_data = &local->spy_data;
|
|
|
|
dev->wireless_data = &local->wireless_data;
|
|
|
|
#endif /* WIRELESS_SPY */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&p_dev->dev, "ray_cs ray_attach calling ether_setup.)\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
netif_stop_queue(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
init_timer(&local->timer);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
this_device = p_dev;
|
|
|
|
return ray_config(p_dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
fail_alloc_dev:
|
2009-03-10 13:59:54 +00:00
|
|
|
return -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* ray_attach */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2006-03-31 15:21:06 +00:00
|
|
|
static void ray_detach(struct pcmcia_device *link)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
struct net_device *dev;
|
|
|
|
ray_dev_t *local;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_detach\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
this_device = NULL;
|
|
|
|
dev = link->priv;
|
2005-11-14 20:23:14 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_release(link);
|
2005-11-14 20:23:14 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
local = netdev_priv(dev);
|
|
|
|
del_timer(&local->timer);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (link->priv) {
|
2010-03-20 18:39:26 +00:00
|
|
|
unregister_netdev(dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
free_netdev(dev);
|
|
|
|
}
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs ray_detach ending\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* ray_detach */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#define MAX_TUPLE_SIZE 128
|
2006-03-31 15:26:06 +00:00
|
|
|
static int ray_config(struct pcmcia_device *link)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-10-24 13:52:44 +00:00
|
|
|
int ret = 0;
|
2009-03-10 13:59:54 +00:00
|
|
|
int i;
|
|
|
|
struct net_device *dev = (struct net_device *)link->priv;
|
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_config\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
/* Determine card type and firmware version */
|
|
|
|
printk(KERN_INFO "ray_cs Detected: %s%s%s%s\n",
|
|
|
|
link->prod_id[0] ? link->prod_id[0] : " ",
|
|
|
|
link->prod_id[1] ? link->prod_id[1] : " ",
|
|
|
|
link->prod_id[2] ? link->prod_id[2] : " ",
|
|
|
|
link->prod_id[3] ? link->prod_id[3] : " ");
|
|
|
|
|
|
|
|
/* Now allocate an interrupt line. Note that this does not
|
|
|
|
actually assign a handler to the interrupt.
|
|
|
|
*/
|
2010-03-07 11:21:16 +00:00
|
|
|
ret = pcmcia_request_irq(link, ray_interrupt);
|
2009-10-24 13:52:44 +00:00
|
|
|
if (ret)
|
|
|
|
goto failed;
|
2010-03-07 11:21:16 +00:00
|
|
|
dev->irq = link->irq;
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2010-07-29 17:27:09 +00:00
|
|
|
ret = pcmcia_enable_device(link);
|
2009-10-24 13:52:44 +00:00
|
|
|
if (ret)
|
|
|
|
goto failed;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*** Set up 32k window for shared memory (transmit and control) ************/
|
2010-07-28 08:59:06 +00:00
|
|
|
link->resource[2]->flags |= WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
|
|
|
|
link->resource[2]->start = 0;
|
|
|
|
link->resource[2]->end = 0x8000;
|
|
|
|
ret = pcmcia_request_window(link, link->resource[2], ray_mem_speed);
|
2009-10-24 13:52:44 +00:00
|
|
|
if (ret)
|
|
|
|
goto failed;
|
2010-07-28 08:59:06 +00:00
|
|
|
ret = pcmcia_map_mem_page(link, link->resource[2], 0);
|
2009-10-24 13:52:44 +00:00
|
|
|
if (ret)
|
|
|
|
goto failed;
|
2010-07-28 08:59:06 +00:00
|
|
|
local->sram = ioremap(link->resource[2]->start,
|
|
|
|
resource_size(link->resource[2]));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*** Set up 16k window for shared memory (receive buffer) ***************/
|
2010-07-28 08:59:06 +00:00
|
|
|
link->resource[3]->flags |=
|
2009-03-10 13:59:54 +00:00
|
|
|
WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
|
2010-07-28 08:59:06 +00:00
|
|
|
link->resource[3]->start = 0;
|
|
|
|
link->resource[3]->end = 0x4000;
|
|
|
|
ret = pcmcia_request_window(link, link->resource[3], ray_mem_speed);
|
2009-10-24 13:52:44 +00:00
|
|
|
if (ret)
|
|
|
|
goto failed;
|
2010-07-28 08:59:06 +00:00
|
|
|
ret = pcmcia_map_mem_page(link, link->resource[3], 0x8000);
|
2009-10-24 13:52:44 +00:00
|
|
|
if (ret)
|
|
|
|
goto failed;
|
2010-07-28 08:59:06 +00:00
|
|
|
local->rmem = ioremap(link->resource[3]->start,
|
|
|
|
resource_size(link->resource[3]));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*** Set up window for attribute memory ***********************************/
|
2010-07-28 08:59:06 +00:00
|
|
|
link->resource[4]->flags |=
|
2009-03-10 13:59:54 +00:00
|
|
|
WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT;
|
2010-07-28 08:59:06 +00:00
|
|
|
link->resource[4]->start = 0;
|
|
|
|
link->resource[4]->end = 0x1000;
|
|
|
|
ret = pcmcia_request_window(link, link->resource[4], ray_mem_speed);
|
2009-10-24 13:52:44 +00:00
|
|
|
if (ret)
|
|
|
|
goto failed;
|
2010-07-28 08:59:06 +00:00
|
|
|
ret = pcmcia_map_mem_page(link, link->resource[4], 0);
|
2009-10-24 13:52:44 +00:00
|
|
|
if (ret)
|
|
|
|
goto failed;
|
2010-07-28 08:59:06 +00:00
|
|
|
local->amem = ioremap(link->resource[4]->start,
|
|
|
|
resource_size(link->resource[4]));
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram);
|
|
|
|
dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem);
|
|
|
|
dev_dbg(&link->dev, "ray_config amem=%p\n", local->amem);
|
2009-03-10 13:59:54 +00:00
|
|
|
if (ray_init(dev) < 0) {
|
|
|
|
ray_release(link);
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2009-11-03 09:27:34 +00:00
|
|
|
SET_NETDEV_DEV(dev, &link->dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
i = register_netdev(dev);
|
|
|
|
if (i != 0) {
|
|
|
|
printk("ray_config register_netdev() failed\n");
|
|
|
|
ray_release(link);
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
printk(KERN_INFO "%s: RayLink, irq %d, hw_addr %pM\n",
|
|
|
|
dev->name, dev->irq, dev->dev_addr);
|
|
|
|
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
failed:
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_release(link);
|
|
|
|
return -ENODEV;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* ray_config */
|
|
|
|
|
|
|
|
static inline struct ccs __iomem *ccs_base(ray_dev_t *dev)
|
|
|
|
{
|
|
|
|
return dev->sram + CCS_BASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct rcs __iomem *rcs_base(ray_dev_t *dev)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This looks nonsensical, since there is a separate
|
|
|
|
* RCS_BASE. But the difference between a "struct rcs"
|
|
|
|
* and a "struct ccs" ends up being in the _index_ off
|
|
|
|
* the base, so the base pointer is the same for both
|
|
|
|
* ccs/rcs.
|
|
|
|
*/
|
|
|
|
return dev->sram + CCS_BASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
static int ray_init(struct net_device *dev)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int i;
|
|
|
|
UCHAR *p;
|
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_init(0x%p)\n", dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_init - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
local->net_type = net_type;
|
|
|
|
local->sta_type = TYPE_STA;
|
|
|
|
|
|
|
|
/* Copy the startup results to local memory */
|
|
|
|
memcpy_fromio(&local->startup_res, local->sram + ECF_TO_HOST_BASE,
|
|
|
|
sizeof(struct startup_res_6));
|
|
|
|
|
|
|
|
/* Check Power up test status and get mac address from card */
|
|
|
|
if (local->startup_res.startup_word != 0x80) {
|
|
|
|
printk(KERN_INFO "ray_init ERROR card status = %2x\n",
|
|
|
|
local->startup_res.startup_word);
|
|
|
|
local->card_status = CARD_INIT_ERROR;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
local->fw_ver = local->startup_res.firmware_version[0];
|
|
|
|
local->fw_bld = local->startup_res.firmware_version[1];
|
|
|
|
local->fw_var = local->startup_res.firmware_version[2];
|
2010-03-24 18:46:34 +00:00
|
|
|
dev_dbg(&link->dev, "ray_init firmware version %d.%d\n", local->fw_ver,
|
2009-03-10 13:59:54 +00:00
|
|
|
local->fw_bld);
|
|
|
|
|
|
|
|
local->tib_length = 0x20;
|
|
|
|
if ((local->fw_ver == 5) && (local->fw_bld >= 30))
|
|
|
|
local->tib_length = local->startup_res.tib_length;
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_init tib_length = 0x%02x\n", local->tib_length);
|
2009-03-10 13:59:54 +00:00
|
|
|
/* Initialize CCS's to buffer free state */
|
|
|
|
pccs = ccs_base(local);
|
|
|
|
for (i = 0; i < NUMBER_OF_CCS; i++) {
|
|
|
|
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
|
|
|
|
}
|
|
|
|
init_startup_params(local);
|
|
|
|
|
|
|
|
/* copy mac address to startup parameters */
|
|
|
|
if (parse_addr(phy_addr, local->sparm.b4.a_mac_addr)) {
|
|
|
|
p = local->sparm.b4.a_mac_addr;
|
|
|
|
} else {
|
|
|
|
memcpy(&local->sparm.b4.a_mac_addr,
|
|
|
|
&local->startup_res.station_addr, ADDRLEN);
|
|
|
|
p = local->sparm.b4.a_mac_addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
clear_interrupt(local); /* Clear any interrupt from the card */
|
|
|
|
local->card_status = CARD_AWAITING_PARAM;
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_init ending\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* ray_init */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Download startup parameters to the card and command it to read them */
|
|
|
|
static int dl_startup_params(struct net_device *dev)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int ccsindex;
|
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "dl_startup_params entered\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs dl_startup_params - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy parameters to host to ECF area */
|
|
|
|
if (local->fw_ver == 0x55)
|
|
|
|
memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b4,
|
|
|
|
sizeof(struct b4_startup_params));
|
|
|
|
else
|
|
|
|
memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b5,
|
|
|
|
sizeof(struct b5_startup_params));
|
|
|
|
|
|
|
|
/* Fill in the CCS fields for the ECF */
|
|
|
|
if ((ccsindex = get_free_ccs(local)) < 0)
|
|
|
|
return -1;
|
|
|
|
local->dl_param_ccs = ccsindex;
|
|
|
|
pccs = ccs_base(local) + ccsindex;
|
|
|
|
writeb(CCS_DOWNLOAD_STARTUP_PARAMS, &pccs->cmd);
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "dl_startup_params start ccsindex = %d\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
local->dl_param_ccs);
|
|
|
|
/* Interrupt the firmware to process the command */
|
|
|
|
if (interrupt_ecf(local, ccsindex)) {
|
|
|
|
printk(KERN_INFO "ray dl_startup_params failed - "
|
|
|
|
"ECF not ready for intr\n");
|
|
|
|
local->card_status = CARD_DL_PARAM_ERROR;
|
|
|
|
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
local->card_status = CARD_DL_PARAM;
|
|
|
|
/* Start kernel timer to wait for dl startup to complete. */
|
|
|
|
local->timer.expires = jiffies + HZ / 2;
|
|
|
|
local->timer.data = (long)local;
|
2010-08-23 18:20:03 +00:00
|
|
|
local->timer.function = verify_dl_startup;
|
2009-03-10 13:59:54 +00:00
|
|
|
add_timer(&local->timer);
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs dl_startup_params started timer for verify_dl_startup\n");
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* dl_startup_params */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void init_startup_params(ray_dev_t *local)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
if (country > JAPAN_TEST)
|
|
|
|
country = USA;
|
|
|
|
else if (country < USA)
|
|
|
|
country = USA;
|
|
|
|
/* structure for hop time and beacon period is defined here using
|
|
|
|
* New 802.11D6.1 format. Card firmware is still using old format
|
|
|
|
* until version 6.
|
|
|
|
* Before After
|
|
|
|
* a_hop_time ms byte a_hop_time ms byte
|
|
|
|
* a_hop_time 2s byte a_hop_time ls byte
|
|
|
|
* a_hop_time ls byte a_beacon_period ms byte
|
|
|
|
* a_beacon_period a_beacon_period ls byte
|
|
|
|
*
|
|
|
|
* a_hop_time = uS a_hop_time = KuS
|
|
|
|
* a_beacon_period = hops a_beacon_period = KuS
|
|
|
|
*//* 64ms = 010000 */
|
|
|
|
if (local->fw_ver == 0x55) {
|
|
|
|
memcpy((UCHAR *) &local->sparm.b4, b4_default_startup_parms,
|
|
|
|
sizeof(struct b4_startup_params));
|
|
|
|
/* Translate sane kus input values to old build 4/5 format */
|
|
|
|
/* i = hop time in uS truncated to 3 bytes */
|
|
|
|
i = (hop_dwell * 1024) & 0xffffff;
|
|
|
|
local->sparm.b4.a_hop_time[0] = (i >> 16) & 0xff;
|
|
|
|
local->sparm.b4.a_hop_time[1] = (i >> 8) & 0xff;
|
|
|
|
local->sparm.b4.a_beacon_period[0] = 0;
|
|
|
|
local->sparm.b4.a_beacon_period[1] =
|
|
|
|
((beacon_period / hop_dwell) - 1) & 0xff;
|
|
|
|
local->sparm.b4.a_curr_country_code = country;
|
|
|
|
local->sparm.b4.a_hop_pattern_length =
|
|
|
|
hop_pattern_length[(int)country] - 1;
|
|
|
|
if (bc) {
|
|
|
|
local->sparm.b4.a_ack_timeout = 0x50;
|
|
|
|
local->sparm.b4.a_sifs = 0x3f;
|
|
|
|
}
|
|
|
|
} else { /* Version 5 uses real kus values */
|
|
|
|
memcpy((UCHAR *) &local->sparm.b5, b5_default_startup_parms,
|
|
|
|
sizeof(struct b5_startup_params));
|
|
|
|
|
|
|
|
local->sparm.b5.a_hop_time[0] = (hop_dwell >> 8) & 0xff;
|
|
|
|
local->sparm.b5.a_hop_time[1] = hop_dwell & 0xff;
|
|
|
|
local->sparm.b5.a_beacon_period[0] =
|
|
|
|
(beacon_period >> 8) & 0xff;
|
|
|
|
local->sparm.b5.a_beacon_period[1] = beacon_period & 0xff;
|
|
|
|
if (psm)
|
|
|
|
local->sparm.b5.a_power_mgt_state = 1;
|
|
|
|
local->sparm.b5.a_curr_country_code = country;
|
|
|
|
local->sparm.b5.a_hop_pattern_length =
|
|
|
|
hop_pattern_length[(int)country];
|
|
|
|
}
|
|
|
|
|
|
|
|
local->sparm.b4.a_network_type = net_type & 0x01;
|
|
|
|
local->sparm.b4.a_acting_as_ap_status = TYPE_STA;
|
|
|
|
|
|
|
|
if (essid != NULL)
|
|
|
|
strncpy(local->sparm.b4.a_current_ess_id, essid, ESSID_SIZE);
|
|
|
|
} /* init_startup_params */
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void verify_dl_startup(u_long data)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = (ray_dev_t *) data;
|
|
|
|
struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs;
|
|
|
|
UCHAR status;
|
|
|
|
struct pcmcia_device *link = local->finder;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs verify_dl_startup - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-10-24 13:52:44 +00:00
|
|
|
#if 0
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int i;
|
|
|
|
printk(KERN_DEBUG
|
|
|
|
"verify_dl_startup parameters sent via ccs %d:\n",
|
|
|
|
local->dl_param_ccs);
|
|
|
|
for (i = 0; i < sizeof(struct b5_startup_params); i++) {
|
|
|
|
printk(" %2x",
|
|
|
|
(unsigned int)readb(local->sram +
|
|
|
|
HOST_TO_ECF_BASE + i));
|
|
|
|
}
|
|
|
|
printk("\n");
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
status = readb(&pccs->buffer_status);
|
|
|
|
if (status != CCS_BUFFER_FREE) {
|
|
|
|
printk(KERN_INFO
|
|
|
|
"Download startup params failed. Status = %d\n",
|
|
|
|
status);
|
|
|
|
local->card_status = CARD_DL_PARAM_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (local->sparm.b4.a_network_type == ADHOC)
|
|
|
|
start_net((u_long) local);
|
|
|
|
else
|
|
|
|
join_net((u_long) local);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end verify_dl_startup */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Command card to start a network */
|
|
|
|
static void start_net(u_long data)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = (ray_dev_t *) data;
|
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
int ccsindex;
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs start_net - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Fill in the CCS fields for the ECF */
|
|
|
|
if ((ccsindex = get_free_ccs(local)) < 0)
|
|
|
|
return;
|
|
|
|
pccs = ccs_base(local) + ccsindex;
|
|
|
|
writeb(CCS_START_NETWORK, &pccs->cmd);
|
|
|
|
writeb(0, &pccs->var.start_network.update_param);
|
|
|
|
/* Interrupt the firmware to process the command */
|
|
|
|
if (interrupt_ecf(local, ccsindex)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray start net failed - card not ready for intr\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
local->card_status = CARD_DOING_ACQ;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end start_net */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Command card to join a network */
|
|
|
|
static void join_net(u_long data)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = (ray_dev_t *) data;
|
|
|
|
|
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
int ccsindex;
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
|
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs join_net - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* Fill in the CCS fields for the ECF */
|
|
|
|
if ((ccsindex = get_free_ccs(local)) < 0)
|
|
|
|
return;
|
|
|
|
pccs = ccs_base(local) + ccsindex;
|
|
|
|
writeb(CCS_JOIN_NETWORK, &pccs->cmd);
|
|
|
|
writeb(0, &pccs->var.join_network.update_param);
|
|
|
|
writeb(0, &pccs->var.join_network.net_initiated);
|
|
|
|
/* Interrupt the firmware to process the command */
|
|
|
|
if (interrupt_ecf(local, ccsindex)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray join net failed - card not ready for intr\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
local->card_status = CARD_DOING_ACQ;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2010-08-15 06:38:38 +00:00
|
|
|
|
2006-03-31 15:21:06 +00:00
|
|
|
static void ray_release(struct pcmcia_device *link)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_release\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
del_timer(&local->timer);
|
|
|
|
|
|
|
|
iounmap(local->sram);
|
|
|
|
iounmap(local->rmem);
|
|
|
|
iounmap(local->amem);
|
|
|
|
pcmcia_disable_device(link);
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_release ending\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-03-31 15:21:06 +00:00
|
|
|
static int ray_suspend(struct pcmcia_device *link)
|
2005-11-14 20:21:18 +00:00
|
|
|
{
|
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
|
2006-03-01 23:09:29 +00:00
|
|
|
if (link->open)
|
2006-03-01 23:02:33 +00:00
|
|
|
netif_device_detach(dev);
|
2005-11-14 20:21:18 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-03-31 15:21:06 +00:00
|
|
|
static int ray_resume(struct pcmcia_device *link)
|
2005-11-14 20:21:18 +00:00
|
|
|
{
|
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
|
2006-03-01 23:09:29 +00:00
|
|
|
if (link->open) {
|
2006-03-01 23:02:33 +00:00
|
|
|
ray_reset(dev);
|
|
|
|
netif_device_attach(dev);
|
|
|
|
}
|
2005-11-14 20:21:18 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2008-12-26 08:12:59 +00:00
|
|
|
static int ray_dev_init(struct net_device *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
#ifdef RAY_IMMEDIATE_INIT
|
2009-03-10 13:59:54 +00:00
|
|
|
int i;
|
|
|
|
#endif /* RAY_IMMEDIATE_INIT */
|
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_dev_init(dev=%p)\n", dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_dev_init - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef RAY_IMMEDIATE_INIT
|
2009-03-10 13:59:54 +00:00
|
|
|
/* Download startup parameters */
|
|
|
|
if ((i = dl_startup_params(dev)) < 0) {
|
|
|
|
printk(KERN_INFO "ray_dev_init dl_startup_params failed - "
|
|
|
|
"returns 0x%x\n", i);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
#else /* RAY_IMMEDIATE_INIT */
|
|
|
|
/* Postpone the card init so that we can still configure the card,
|
|
|
|
* for example using the Wireless Extensions. The init will happen
|
|
|
|
* in ray_open() - Jean II */
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_dev_init: postponing card init to ray_open() ; Status = %d\n",
|
|
|
|
local->card_status);
|
|
|
|
#endif /* RAY_IMMEDIATE_INIT */
|
|
|
|
|
|
|
|
/* copy mac and broadcast addresses to linux device */
|
2009-05-11 23:37:15 +00:00
|
|
|
memcpy(dev->dev_addr, &local->sparm.b4.a_mac_addr, ADDRLEN);
|
2009-03-10 13:59:54 +00:00
|
|
|
memset(dev->broadcast, 0xff, ETH_ALEN);
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_dev_init ending\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static int ray_dev_config(struct net_device *dev, struct ifmap *map)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
/* Dummy routine to satisfy device structure */
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_dev_config(dev=%p,ifmap=%p)\n", dev, map);
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_dev_config - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-08-31 19:50:57 +00:00
|
|
|
static netdev_tx_t ray_dev_start_xmit(struct sk_buff *skb,
|
|
|
|
struct net_device *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
short length = skb->len;
|
|
|
|
|
2009-08-31 19:50:57 +00:00
|
|
|
if (!pcmcia_dev_present(link)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_dev_start_xmit - device not present\n");
|
2009-08-31 19:50:57 +00:00
|
|
|
dev_kfree_skb(skb);
|
|
|
|
return NETDEV_TX_OK;
|
2009-03-10 13:59:54 +00:00
|
|
|
}
|
2009-08-31 19:50:57 +00:00
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_dev_start_xmit(skb=%p, dev=%p)\n", skb, dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->authentication_state == NEED_TO_AUTH) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs Sending authentication request.\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!build_auth_frame(local, local->auth_id, OPEN_AUTH_REQUEST)) {
|
|
|
|
local->authentication_state = AUTHENTICATED;
|
|
|
|
netif_stop_queue(dev);
|
2009-06-12 06:22:29 +00:00
|
|
|
return NETDEV_TX_BUSY;
|
2009-03-10 13:59:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (length < ETH_ZLEN) {
|
|
|
|
if (skb_padto(skb, ETH_ZLEN))
|
2009-06-23 06:03:08 +00:00
|
|
|
return NETDEV_TX_OK;
|
2009-03-10 13:59:54 +00:00
|
|
|
length = ETH_ZLEN;
|
|
|
|
}
|
|
|
|
switch (ray_hw_xmit(skb->data, length, dev, DATA_TYPE)) {
|
|
|
|
case XMIT_NO_CCS:
|
|
|
|
case XMIT_NEED_AUTH:
|
|
|
|
netif_stop_queue(dev);
|
2009-06-12 06:22:29 +00:00
|
|
|
return NETDEV_TX_BUSY;
|
2009-03-10 13:59:54 +00:00
|
|
|
case XMIT_NO_INTR:
|
|
|
|
case XMIT_MSG_BAD:
|
|
|
|
case XMIT_OK:
|
|
|
|
default:
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
}
|
2009-08-31 19:50:57 +00:00
|
|
|
|
2009-06-23 06:03:08 +00:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* ray_dev_start_xmit */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev,
|
|
|
|
UCHAR msg_type)
|
|
|
|
{
|
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
int ccsindex;
|
|
|
|
int offset;
|
|
|
|
struct tx_msg __iomem *ptx; /* Address of xmit buffer in PC space */
|
|
|
|
short int addr; /* Address of xmit buffer in card space */
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_hw_xmit(data=%p, len=%d, dev=%p)\n", data, len, dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
if (len + TX_HEADER_LENGTH > TX_BUF_SIZE) {
|
|
|
|
printk(KERN_INFO "ray_hw_xmit packet too large: %d bytes\n",
|
|
|
|
len);
|
|
|
|
return XMIT_MSG_BAD;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
switch (ccsindex = get_free_tx_ccs(local)) {
|
|
|
|
case ECCSBUSY:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_hw_xmit tx_ccs table busy\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
case ECCSFULL:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_hw_xmit No free tx ccs\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
case ECARDGONE:
|
2009-03-10 13:59:54 +00:00
|
|
|
netif_stop_queue(dev);
|
|
|
|
return XMIT_NO_CCS;
|
2005-04-16 22:20:36 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
addr = TX_BUF_BASE + (ccsindex << 11);
|
|
|
|
|
|
|
|
if (msg_type == DATA_TYPE) {
|
|
|
|
local->stats.tx_bytes += len;
|
|
|
|
local->stats.tx_packets++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ptx = local->sram + addr;
|
|
|
|
|
|
|
|
ray_build_header(local, ptx, msg_type, data);
|
|
|
|
if (translate) {
|
|
|
|
offset = translate_frame(local, ptx, data, len);
|
|
|
|
} else { /* Encapsulate frame */
|
|
|
|
/* TBD TIB length will move address of ptx->var */
|
|
|
|
memcpy_toio(&ptx->var, data, len);
|
|
|
|
offset = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* fill in the CCS */
|
|
|
|
pccs = ccs_base(local) + ccsindex;
|
|
|
|
len += TX_HEADER_LENGTH + offset;
|
|
|
|
writeb(CCS_TX_REQUEST, &pccs->cmd);
|
|
|
|
writeb(addr >> 8, &pccs->var.tx_request.tx_data_ptr[0]);
|
|
|
|
writeb(local->tib_length, &pccs->var.tx_request.tx_data_ptr[1]);
|
|
|
|
writeb(len >> 8, &pccs->var.tx_request.tx_data_length[0]);
|
|
|
|
writeb(len & 0xff, &pccs->var.tx_request.tx_data_length[1]);
|
2005-04-16 22:20:36 +00:00
|
|
|
/* TBD still need psm_cam? */
|
2009-03-10 13:59:54 +00:00
|
|
|
writeb(PSM_CAM, &pccs->var.tx_request.pow_sav_mode);
|
|
|
|
writeb(local->net_default_tx_rate, &pccs->var.tx_request.tx_rate);
|
|
|
|
writeb(0, &pccs->var.tx_request.antenna);
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_hw_xmit default_tx_rate = 0x%x\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
local->net_default_tx_rate);
|
|
|
|
|
|
|
|
/* Interrupt the firmware to process the command */
|
|
|
|
if (interrupt_ecf(local, ccsindex)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_hw_xmit failed - ECF not ready for intr\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
/* TBD very inefficient to copy packet to buffer, and then not
|
|
|
|
send it, but the alternative is to queue the messages and that
|
|
|
|
won't be done for a while. Maybe set tbusy until a CCS is free?
|
|
|
|
*/
|
2009-03-10 13:59:54 +00:00
|
|
|
writeb(CCS_BUFFER_FREE, &pccs->buffer_status);
|
|
|
|
return XMIT_NO_INTR;
|
|
|
|
}
|
|
|
|
return XMIT_OK;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end ray_hw_xmit */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
|
|
|
|
unsigned char *data, int len)
|
|
|
|
{
|
|
|
|
__be16 proto = ((struct ethhdr *)data)->h_proto;
|
2013-03-28 04:38:25 +00:00
|
|
|
if (ntohs(proto) >= ETH_P_802_3_MIN) { /* DIX II ethernet frame */
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs translate_frame DIX II\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
/* Copy LLC header to card buffer */
|
|
|
|
memcpy_toio(&ptx->var, eth2_llc, sizeof(eth2_llc));
|
|
|
|
memcpy_toio(((void __iomem *)&ptx->var) + sizeof(eth2_llc),
|
|
|
|
(UCHAR *) &proto, 2);
|
|
|
|
if (proto == htons(ETH_P_AARP) || proto == htons(ETH_P_IPX)) {
|
|
|
|
/* This is the selective translation table, only 2 entries */
|
|
|
|
writeb(0xf8,
|
|
|
|
&((struct snaphdr_t __iomem *)ptx->var)->org[3]);
|
|
|
|
}
|
|
|
|
/* Copy body of ethernet packet without ethernet header */
|
|
|
|
memcpy_toio((void __iomem *)&ptx->var +
|
|
|
|
sizeof(struct snaphdr_t), data + ETH_HLEN,
|
|
|
|
len - ETH_HLEN);
|
|
|
|
return (int)sizeof(struct snaphdr_t) - ETH_HLEN;
|
|
|
|
} else { /* already 802 type, and proto is length */
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs translate_frame 802\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
if (proto == htons(0xffff)) { /* evil netware IPX 802.3 without LLC */
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs translate_frame evil IPX\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
|
|
|
|
return 0 - ETH_HLEN;
|
|
|
|
}
|
|
|
|
memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
|
|
|
|
return 0 - ETH_HLEN;
|
|
|
|
}
|
|
|
|
/* TBD do other frame types */
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end translate_frame */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
|
|
|
|
UCHAR msg_type, unsigned char *data)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
writeb(PROTOCOL_VER | msg_type, &ptx->mac.frame_ctl_1);
|
2005-04-16 22:20:36 +00:00
|
|
|
/*** IEEE 802.11 Address field assignments *************
|
2009-03-10 13:59:54 +00:00
|
|
|
TODS FROMDS addr_1 addr_2 addr_3 addr_4
|
|
|
|
Adhoc 0 0 dest src (terminal) BSSID N/A
|
|
|
|
AP to Terminal 0 1 dest AP(BSSID) source N/A
|
|
|
|
Terminal to AP 1 0 AP(BSSID) src (terminal) dest N/A
|
|
|
|
AP to AP 1 1 dest AP src AP dest source
|
2005-04-16 22:20:36 +00:00
|
|
|
*******************************************************/
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->net_type == ADHOC) {
|
|
|
|
writeb(0, &ptx->mac.frame_ctl_2);
|
|
|
|
memcpy_toio(ptx->mac.addr_1, ((struct ethhdr *)data)->h_dest,
|
|
|
|
2 * ADDRLEN);
|
|
|
|
memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN);
|
|
|
|
} else { /* infrastructure */
|
|
|
|
|
|
|
|
if (local->sparm.b4.a_acting_as_ap_status) {
|
|
|
|
writeb(FC2_FROM_DS, &ptx->mac.frame_ctl_2);
|
|
|
|
memcpy_toio(ptx->mac.addr_1,
|
|
|
|
((struct ethhdr *)data)->h_dest, ADDRLEN);
|
|
|
|
memcpy_toio(ptx->mac.addr_2, local->bss_id, 6);
|
|
|
|
memcpy_toio(ptx->mac.addr_3,
|
|
|
|
((struct ethhdr *)data)->h_source, ADDRLEN);
|
|
|
|
} else { /* Terminal */
|
|
|
|
|
|
|
|
writeb(FC2_TO_DS, &ptx->mac.frame_ctl_2);
|
|
|
|
memcpy_toio(ptx->mac.addr_1, local->bss_id, ADDRLEN);
|
|
|
|
memcpy_toio(ptx->mac.addr_2,
|
|
|
|
((struct ethhdr *)data)->h_source, ADDRLEN);
|
|
|
|
memcpy_toio(ptx->mac.addr_3,
|
|
|
|
((struct ethhdr *)data)->h_dest, ADDRLEN);
|
|
|
|
}
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end encapsulate_frame */
|
|
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get protocol name
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_name(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2010-03-19 01:29:40 +00:00
|
|
|
strcpy(wrqu->name, "IEEE 802.11-FH");
|
2005-09-02 18:40:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : set frequency
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_set_freq(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
int err = -EINPROGRESS; /* Call commit handler */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/* Reject if card is already initialised */
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->card_status != CARD_AWAITING_PARAM)
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EBUSY;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/* Setting by channel number */
|
2010-03-19 01:29:40 +00:00
|
|
|
if ((wrqu->freq.m > USA_HOP_MOD) || (wrqu->freq.e > 0))
|
2005-09-02 18:40:39 +00:00
|
|
|
err = -EOPNOTSUPP;
|
|
|
|
else
|
2010-03-19 01:29:40 +00:00
|
|
|
local->sparm.b5.a_hop_pattern = wrqu->freq.m;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
return err;
|
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get frequency
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_freq(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->freq.m = local->sparm.b5.a_hop_pattern;
|
|
|
|
wrqu->freq.e = 0;
|
2005-09-02 18:40:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : set ESSID
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_set_essid(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
/* Reject if card is already initialised */
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->card_status != CARD_AWAITING_PARAM)
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
/* Check if we asked for `any' */
|
2010-03-19 01:29:40 +00:00
|
|
|
if (wrqu->essid.flags == 0)
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Corey : can you do that ? */
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EOPNOTSUPP;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-03-19 01:29:40 +00:00
|
|
|
/* Check the size of the string */
|
|
|
|
if (wrqu->essid.length > IW_ESSID_MAX_SIZE)
|
|
|
|
return -E2BIG;
|
|
|
|
|
|
|
|
/* Set the ESSID in the card */
|
|
|
|
memset(local->sparm.b5.a_current_ess_id, 0, IW_ESSID_MAX_SIZE);
|
|
|
|
memcpy(local->sparm.b5.a_current_ess_id, extra, wrqu->essid.length);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
return -EINPROGRESS; /* Call commit handler */
|
2005-09-02 18:40:39 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get ESSID
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_essid(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2013-01-08 05:33:03 +00:00
|
|
|
UCHAR tmp[IW_ESSID_MAX_SIZE + 1];
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
/* Get the essid that was set */
|
|
|
|
memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);
|
2013-01-08 05:33:03 +00:00
|
|
|
memcpy(tmp, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);
|
|
|
|
tmp[IW_ESSID_MAX_SIZE] = '\0';
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
/* Push it out ! */
|
2013-01-08 05:33:03 +00:00
|
|
|
wrqu->essid.length = strlen(tmp);
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->essid.flags = 1; /* active */
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get AP address
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_wap(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2005-09-02 18:40:39 +00:00
|
|
|
|
2010-03-19 01:29:40 +00:00
|
|
|
memcpy(wrqu->ap_addr.sa_data, local->bss_id, ETH_ALEN);
|
|
|
|
wrqu->ap_addr.sa_family = ARPHRD_ETHER;
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : set Bit-Rate
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_set_rate(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
/* Reject if card is already initialised */
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->card_status != CARD_AWAITING_PARAM)
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
/* Check if rate is in range */
|
2010-03-19 01:29:40 +00:00
|
|
|
if ((wrqu->bitrate.value != 1000000) && (wrqu->bitrate.value != 2000000))
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
/* Hack for 1.5 Mb/s instead of 2 Mb/s */
|
2009-03-10 13:59:54 +00:00
|
|
|
if ((local->fw_ver == 0x55) && /* Please check */
|
2010-03-19 01:29:40 +00:00
|
|
|
(wrqu->bitrate.value == 2000000))
|
2005-09-02 18:40:39 +00:00
|
|
|
local->net_default_tx_rate = 3;
|
2005-04-16 22:20:36 +00:00
|
|
|
else
|
2010-03-19 01:29:40 +00:00
|
|
|
local->net_default_tx_rate = wrqu->bitrate.value / 500000;
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get Bit-Rate
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_rate(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2005-09-02 18:40:39 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->net_default_tx_rate == 3)
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->bitrate.value = 2000000; /* Hum... */
|
2005-09-02 18:40:39 +00:00
|
|
|
else
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->bitrate.value = local->net_default_tx_rate * 500000;
|
|
|
|
wrqu->bitrate.fixed = 0; /* We are in auto mode */
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : set RTS threshold
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_set_rts(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2010-03-19 01:29:40 +00:00
|
|
|
int rthr = wrqu->rts.value;
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
/* Reject if card is already initialised */
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->card_status != CARD_AWAITING_PARAM)
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EBUSY;
|
|
|
|
|
|
|
|
/* if(wrq->u.rts.fixed == 0) we should complain */
|
2010-03-19 01:29:40 +00:00
|
|
|
if (wrqu->rts.disabled)
|
2005-09-02 18:40:39 +00:00
|
|
|
rthr = 32767;
|
|
|
|
else {
|
2009-03-10 13:59:54 +00:00
|
|
|
if ((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF;
|
|
|
|
local->sparm.b5.a_rts_threshold[1] = rthr & 0xFF;
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
return -EINPROGRESS; /* Call commit handler */
|
2005-09-02 18:40:39 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get RTS threshold
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_rts(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2005-09-02 18:40:39 +00:00
|
|
|
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->rts.value = (local->sparm.b5.a_rts_threshold[0] << 8)
|
2009-03-10 13:59:54 +00:00
|
|
|
+ local->sparm.b5.a_rts_threshold[1];
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->rts.disabled = (wrqu->rts.value == 32767);
|
|
|
|
wrqu->rts.fixed = 1;
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : set Fragmentation threshold
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_set_frag(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2010-03-19 01:29:40 +00:00
|
|
|
int fthr = wrqu->frag.value;
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
/* Reject if card is already initialised */
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->card_status != CARD_AWAITING_PARAM)
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EBUSY;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* if(wrq->u.frag.fixed == 0) should complain */
|
2010-03-19 01:29:40 +00:00
|
|
|
if (wrqu->frag.disabled)
|
2005-09-02 18:40:39 +00:00
|
|
|
fthr = 32767;
|
|
|
|
else {
|
2009-03-10 13:59:54 +00:00
|
|
|
if ((fthr < 256) || (fthr > 2347)) /* To check out ! */
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF;
|
|
|
|
local->sparm.b5.a_frag_threshold[1] = fthr & 0xFF;
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
return -EINPROGRESS; /* Call commit handler */
|
2005-09-02 18:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get Fragmentation threshold
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_frag(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2005-09-02 18:40:39 +00:00
|
|
|
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->frag.value = (local->sparm.b5.a_frag_threshold[0] << 8)
|
2009-03-10 13:59:54 +00:00
|
|
|
+ local->sparm.b5.a_frag_threshold[1];
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->frag.disabled = (wrqu->frag.value == 32767);
|
|
|
|
wrqu->frag.fixed = 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : set Mode of Operation
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_set_mode(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
int err = -EINPROGRESS; /* Call commit handler */
|
2005-04-16 22:20:36 +00:00
|
|
|
char card_mode = 1;
|
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/* Reject if card is already initialised */
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->card_status != CARD_AWAITING_PARAM)
|
2005-09-02 18:40:39 +00:00
|
|
|
return -EBUSY;
|
|
|
|
|
2010-03-19 01:29:40 +00:00
|
|
|
switch (wrqu->mode) {
|
2005-04-16 22:20:36 +00:00
|
|
|
case IW_MODE_ADHOC:
|
2005-09-02 18:40:39 +00:00
|
|
|
card_mode = 0;
|
2009-03-10 13:59:54 +00:00
|
|
|
/* Fall through */
|
2005-04-16 22:20:36 +00:00
|
|
|
case IW_MODE_INFRA:
|
2005-09-02 18:40:39 +00:00
|
|
|
local->sparm.b5.a_network_type = card_mode;
|
|
|
|
break;
|
2005-04-16 22:20:36 +00:00
|
|
|
default:
|
2005-09-02 18:40:39 +00:00
|
|
|
err = -EINVAL;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
return err;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get Mode of Operation
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_mode(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2007-08-03 17:37:16 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (local->sparm.b5.a_network_type)
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->mode = IW_MODE_INFRA;
|
2005-09-02 18:40:39 +00:00
|
|
|
else
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->mode = IW_MODE_ADHOC;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Handler : get range info
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_range(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
struct iw_range *range = (struct iw_range *)extra;
|
2005-09-02 18:40:39 +00:00
|
|
|
|
2010-03-19 01:29:40 +00:00
|
|
|
memset(range, 0, sizeof(struct iw_range));
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
/* Set the length (very important for backward compatibility) */
|
2010-03-19 01:29:40 +00:00
|
|
|
wrqu->data.length = sizeof(struct iw_range);
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
/* Set the Wireless Extension versions */
|
|
|
|
range->we_version_compiled = WIRELESS_EXT;
|
|
|
|
range->we_version_source = 9;
|
|
|
|
|
|
|
|
/* Set information in the range struct */
|
|
|
|
range->throughput = 1.1 * 1000 * 1000; /* Put the right number here */
|
2009-03-10 13:59:54 +00:00
|
|
|
range->num_channels = hop_pattern_length[(int)country];
|
2005-09-02 18:40:39 +00:00
|
|
|
range->num_frequency = 0;
|
|
|
|
range->max_qual.qual = 0;
|
|
|
|
range->max_qual.level = 255; /* What's the correct value ? */
|
|
|
|
range->max_qual.noise = 255; /* Idem */
|
|
|
|
range->num_bitrates = 2;
|
|
|
|
range->bitrate[0] = 1000000; /* 1 Mb/s */
|
|
|
|
range->bitrate[1] = 2000000; /* 2 Mb/s */
|
|
|
|
return 0;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Private Handler : set framing mode
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_set_framing(struct net_device *dev, struct iw_request_info *info,
|
2009-03-10 13:59:54 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
2013-02-26 10:04:51 +00:00
|
|
|
translate = !!*(extra); /* Set framing mode */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-09-02 18:40:39 +00:00
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Private Handler : get framing mode
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_framing(struct net_device *dev, struct iw_request_info *info,
|
2009-03-10 13:59:54 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
|
|
|
*(extra) = translate;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Wireless Private Handler : get country
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_get_country(struct net_device *dev, struct iw_request_info *info,
|
2009-03-10 13:59:54 +00:00
|
|
|
union iwreq_data *wrqu, char *extra)
|
2005-09-02 18:40:39 +00:00
|
|
|
{
|
|
|
|
*(extra) = country;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Commit handler : called after a bunch of SET operations
|
|
|
|
*/
|
2010-03-19 01:29:40 +00:00
|
|
|
static int ray_commit(struct net_device *dev, struct iw_request_info *info,
|
|
|
|
union iwreq_data *wrqu, char *extra)
|
|
|
|
{
|
2005-09-02 18:40:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Stats handler : return Wireless Stats
|
|
|
|
*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static iw_stats *ray_get_wireless_stats(struct net_device *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
struct status __iomem *p = local->sram + STATUS_BASE;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
local->wstats.status = local->card_status;
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef WIRELESS_SPY
|
2009-03-10 13:59:54 +00:00
|
|
|
if ((local->spy_data.spy_number > 0)
|
|
|
|
&& (local->sparm.b5.a_network_type == 0)) {
|
|
|
|
/* Get it from the first node in spy list */
|
|
|
|
local->wstats.qual.qual = local->spy_data.spy_stat[0].qual;
|
|
|
|
local->wstats.qual.level = local->spy_data.spy_stat[0].level;
|
|
|
|
local->wstats.qual.noise = local->spy_data.spy_stat[0].noise;
|
|
|
|
local->wstats.qual.updated =
|
|
|
|
local->spy_data.spy_stat[0].updated;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* WIRELESS_SPY */
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (pcmcia_dev_present(link)) {
|
|
|
|
local->wstats.qual.noise = readb(&p->rxnoise);
|
|
|
|
local->wstats.qual.updated |= 4;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
return &local->wstats;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end ray_get_wireless_stats */
|
2005-09-02 18:40:39 +00:00
|
|
|
|
|
|
|
/*------------------------------------------------------------------*/
|
|
|
|
/*
|
|
|
|
* Structures to export the Wireless Handlers
|
|
|
|
*/
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
static const iw_handler ray_handler[] = {
|
2010-03-19 01:29:40 +00:00
|
|
|
IW_HANDLER(SIOCSIWCOMMIT, ray_commit),
|
|
|
|
IW_HANDLER(SIOCGIWNAME, ray_get_name),
|
|
|
|
IW_HANDLER(SIOCSIWFREQ, ray_set_freq),
|
|
|
|
IW_HANDLER(SIOCGIWFREQ, ray_get_freq),
|
|
|
|
IW_HANDLER(SIOCSIWMODE, ray_set_mode),
|
|
|
|
IW_HANDLER(SIOCGIWMODE, ray_get_mode),
|
|
|
|
IW_HANDLER(SIOCGIWRANGE, ray_get_range),
|
2005-09-02 18:40:39 +00:00
|
|
|
#ifdef WIRELESS_SPY
|
2010-03-19 01:29:37 +00:00
|
|
|
IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
|
|
|
|
IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
|
|
|
|
IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
|
|
|
|
IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
|
2009-03-10 13:59:54 +00:00
|
|
|
#endif /* WIRELESS_SPY */
|
2010-03-19 01:29:40 +00:00
|
|
|
IW_HANDLER(SIOCGIWAP, ray_get_wap),
|
|
|
|
IW_HANDLER(SIOCSIWESSID, ray_set_essid),
|
|
|
|
IW_HANDLER(SIOCGIWESSID, ray_get_essid),
|
|
|
|
IW_HANDLER(SIOCSIWRATE, ray_set_rate),
|
|
|
|
IW_HANDLER(SIOCGIWRATE, ray_get_rate),
|
|
|
|
IW_HANDLER(SIOCSIWRTS, ray_set_rts),
|
|
|
|
IW_HANDLER(SIOCGIWRTS, ray_get_rts),
|
|
|
|
IW_HANDLER(SIOCSIWFRAG, ray_set_frag),
|
|
|
|
IW_HANDLER(SIOCGIWFRAG, ray_get_frag),
|
2005-09-02 18:40:39 +00:00
|
|
|
};
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */
|
2005-09-02 18:40:39 +00:00
|
|
|
#define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1 /* Get framing mode */
|
|
|
|
#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
static const iw_handler ray_private_handler[] = {
|
2010-03-19 01:29:40 +00:00
|
|
|
[0] = ray_set_framing,
|
|
|
|
[1] = ray_get_framing,
|
|
|
|
[3] = ray_get_country,
|
2005-09-02 18:40:39 +00:00
|
|
|
};
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
static const struct iw_priv_args ray_private_args[] = {
|
2005-09-02 18:40:39 +00:00
|
|
|
/* cmd, set_args, get_args, name */
|
2009-03-10 13:59:54 +00:00
|
|
|
{SIOCSIPFRAMING, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0,
|
|
|
|
"set_framing"},
|
|
|
|
{SIOCGIPFRAMING, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
|
|
|
|
"get_framing"},
|
|
|
|
{SIOCGIPCOUNTRY, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
|
|
|
|
"get_country"},
|
2005-09-02 18:40:39 +00:00
|
|
|
};
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
static const struct iw_handler_def ray_handler_def = {
|
|
|
|
.num_standard = ARRAY_SIZE(ray_handler),
|
|
|
|
.num_private = ARRAY_SIZE(ray_private_handler),
|
2007-09-02 10:30:18 +00:00
|
|
|
.num_private_args = ARRAY_SIZE(ray_private_args),
|
2009-03-10 13:59:54 +00:00
|
|
|
.standard = ray_handler,
|
|
|
|
.private = ray_private_handler,
|
|
|
|
.private_args = ray_private_args,
|
2005-09-02 18:40:39 +00:00
|
|
|
.get_wireless_stats = ray_get_wireless_stats,
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static int ray_open(struct net_device *dev)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link;
|
|
|
|
link = local->finder;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_open('%s')\n", dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (link->open == 0)
|
|
|
|
local->num_multi = 0;
|
|
|
|
link->open++;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
/* If the card is not started, time to start it ! - Jean II */
|
|
|
|
if (local->card_status == CARD_AWAITING_PARAM) {
|
|
|
|
int i;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_open: doing init now !\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
/* Download startup parameters */
|
|
|
|
if ((i = dl_startup_params(dev)) < 0) {
|
|
|
|
printk(KERN_INFO
|
|
|
|
"ray_dev_init dl_startup_params failed - "
|
|
|
|
"returns 0x%x\n", i);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sniffer)
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
else
|
|
|
|
netif_start_queue(dev);
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_open ending\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end ray_open */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static int ray_dev_close(struct net_device *dev)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link;
|
|
|
|
link = local->finder;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_dev_close('%s')\n", dev->name);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
link->open--;
|
|
|
|
netif_stop_queue(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
/* In here, we should stop the hardware (stop card from beeing active)
|
|
|
|
* and set local->card_status to CARD_AWAITING_PARAM, so that while the
|
|
|
|
* card is closed we can chage its configuration.
|
|
|
|
* Probably also need a COR reset to get sane state - Jean II */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end ray_dev_close */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static void ray_reset(struct net_device *dev)
|
|
|
|
{
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_reset entered\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Cause a firmware interrupt if it is ready for one */
|
|
|
|
/* Return nonzero if not ready */
|
|
|
|
static int interrupt_ecf(ray_dev_t *local, int ccs)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int i = 50;
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
|
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt_ecf - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "interrupt_ecf(local=%p, ccs = 0x%x\n", local, ccs);
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
while (i &&
|
|
|
|
(readb(local->amem + CIS_OFFSET + ECF_INTR_OFFSET) &
|
|
|
|
ECF_INTR_SET))
|
|
|
|
i--;
|
|
|
|
if (i == 0) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt_ecf card not ready for interrupt\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Fill the mailbox, then kick the card */
|
2009-03-10 13:59:54 +00:00
|
|
|
writeb(ccs, local->sram + SCB_BASE);
|
|
|
|
writeb(ECF_INTR_SET, local->amem + CIS_OFFSET + ECF_INTR_OFFSET);
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* interrupt_ecf */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Get next free transmit CCS */
|
|
|
|
/* Return - index of current tx ccs */
|
|
|
|
static int get_free_tx_ccs(ray_dev_t *local)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int i;
|
|
|
|
struct ccs __iomem *pccs = ccs_base(local);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs get_free_tx_ccs - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return ECARDGONE;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (test_and_set_bit(0, &local->tx_ccs_lock)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs tx_ccs_lock busy\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return ECCSBUSY;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
for (i = 0; i < NUMBER_OF_TX_CCS; i++) {
|
|
|
|
if (readb(&(pccs + i)->buffer_status) == CCS_BUFFER_FREE) {
|
|
|
|
writeb(CCS_BUFFER_BUSY, &(pccs + i)->buffer_status);
|
|
|
|
writeb(CCS_END_LIST, &(pccs + i)->link);
|
2005-04-16 22:20:36 +00:00
|
|
|
local->tx_ccs_lock = 0;
|
2009-03-10 13:59:54 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
local->tx_ccs_lock = 0;
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs ERROR no free tx CCS for raylink card\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return ECCSFULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* get_free_tx_ccs */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Get next free CCS */
|
|
|
|
/* Return - index of current ccs */
|
|
|
|
static int get_free_ccs(ray_dev_t *local)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int i;
|
|
|
|
struct ccs __iomem *pccs = ccs_base(local);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
|
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs get_free_ccs - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return ECARDGONE;
|
|
|
|
}
|
|
|
|
if (test_and_set_bit(0, &local->ccs_lock)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs ccs_lock busy\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return ECCSBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = NUMBER_OF_TX_CCS; i < NUMBER_OF_CCS; i++) {
|
|
|
|
if (readb(&(pccs + i)->buffer_status) == CCS_BUFFER_FREE) {
|
|
|
|
writeb(CCS_BUFFER_BUSY, &(pccs + i)->buffer_status);
|
|
|
|
writeb(CCS_END_LIST, &(pccs + i)->link);
|
2005-04-16 22:20:36 +00:00
|
|
|
local->ccs_lock = 0;
|
2009-03-10 13:59:54 +00:00
|
|
|
return i;
|
|
|
|
}
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
local->ccs_lock = 0;
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs ERROR no free CCS for raylink card\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return ECCSFULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* get_free_ccs */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void authenticate_timeout(u_long data)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = (ray_dev_t *) data;
|
|
|
|
del_timer(&local->timer);
|
|
|
|
printk(KERN_INFO "ray_cs Authentication with access point failed"
|
|
|
|
" - timeout\n");
|
|
|
|
join_net((u_long) local);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static int parse_addr(char *in_str, UCHAR *out)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int len;
|
|
|
|
int i, j, k;
|
|
|
|
int status;
|
|
|
|
|
|
|
|
if (in_str == NULL)
|
|
|
|
return 0;
|
|
|
|
if ((len = strlen(in_str)) < 2)
|
|
|
|
return 0;
|
|
|
|
memset(out, 0, ADDRLEN);
|
|
|
|
|
|
|
|
status = 1;
|
|
|
|
j = len - 1;
|
|
|
|
if (j > 12)
|
|
|
|
j = 12;
|
|
|
|
i = 5;
|
|
|
|
|
|
|
|
while (j > 0) {
|
2010-07-23 03:18:09 +00:00
|
|
|
if ((k = hex_to_bin(in_str[j--])) != -1)
|
2009-03-10 13:59:54 +00:00
|
|
|
out[i] = k;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (j == 0)
|
|
|
|
break;
|
2010-07-23 03:18:09 +00:00
|
|
|
if ((k = hex_to_bin(in_str[j--])) != -1)
|
2009-03-10 13:59:54 +00:00
|
|
|
out[i] += k << 4;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
if (!i--)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return status;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static struct net_device_stats *ray_get_stats(struct net_device *dev)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
struct status __iomem *p = local->sram + STATUS_BASE;
|
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs net_device_stats - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return &local->stats;
|
|
|
|
}
|
|
|
|
if (readb(&p->mrx_overflow_for_host)) {
|
|
|
|
local->stats.rx_over_errors += swab16(readw(&p->mrx_overflow));
|
|
|
|
writeb(0, &p->mrx_overflow);
|
|
|
|
writeb(0, &p->mrx_overflow_for_host);
|
|
|
|
}
|
|
|
|
if (readb(&p->mrx_checksum_error_for_host)) {
|
|
|
|
local->stats.rx_crc_errors +=
|
|
|
|
swab16(readw(&p->mrx_checksum_error));
|
|
|
|
writeb(0, &p->mrx_checksum_error);
|
|
|
|
writeb(0, &p->mrx_checksum_error_for_host);
|
|
|
|
}
|
|
|
|
if (readb(&p->rx_hec_error_for_host)) {
|
|
|
|
local->stats.rx_frame_errors += swab16(readw(&p->rx_hec_error));
|
|
|
|
writeb(0, &p->rx_hec_error);
|
|
|
|
writeb(0, &p->rx_hec_error_for_host);
|
|
|
|
}
|
|
|
|
return &local->stats;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value,
|
|
|
|
int len)
|
|
|
|
{
|
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
int ccsindex;
|
|
|
|
int i;
|
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
|
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_update_parm - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ccsindex = get_free_ccs(local)) < 0) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_update_parm - No free ccs\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
pccs = ccs_base(local) + ccsindex;
|
|
|
|
writeb(CCS_UPDATE_PARAMS, &pccs->cmd);
|
|
|
|
writeb(objid, &pccs->var.update_param.object_id);
|
|
|
|
writeb(1, &pccs->var.update_param.number_objects);
|
|
|
|
writeb(0, &pccs->var.update_param.failure_cause);
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
writeb(value[i], local->sram + HOST_TO_ECF_BASE);
|
|
|
|
}
|
|
|
|
/* Interrupt the firmware to process the command */
|
|
|
|
if (interrupt_ecf(local, ccsindex)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs associate failed - ECF not ready for intr\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void ray_update_multi_list(struct net_device *dev, int all)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int ccsindex;
|
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
void __iomem *p = local->sram + HOST_TO_ECF_BASE;
|
|
|
|
|
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_update_multi_list - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
} else
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_update_multi_list(%p)\n", dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
if ((ccsindex = get_free_ccs(local)) < 0) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_update_multi - No free ccs\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
pccs = ccs_base(local) + ccsindex;
|
|
|
|
writeb(CCS_UPDATE_MULTICAST_LIST, &pccs->cmd);
|
|
|
|
|
|
|
|
if (all) {
|
|
|
|
writeb(0xff, &pccs->var);
|
|
|
|
local->num_multi = 0xff;
|
|
|
|
} else {
|
2010-04-01 21:22:57 +00:00
|
|
|
struct netdev_hw_addr *ha;
|
2010-02-27 07:35:45 +00:00
|
|
|
int i = 0;
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
/* Copy the kernel's list of MC addresses to card */
|
2010-04-01 21:22:57 +00:00
|
|
|
netdev_for_each_mc_addr(ha, dev) {
|
|
|
|
memcpy_toio(p, ha->addr, ETH_ALEN);
|
2010-12-02 12:45:07 +00:00
|
|
|
dev_dbg(&link->dev, "ray_update_multi add addr %pm\n",
|
|
|
|
ha->addr);
|
2009-03-10 13:59:54 +00:00
|
|
|
p += ETH_ALEN;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (i > 256 / ADDRLEN)
|
|
|
|
i = 256 / ADDRLEN;
|
|
|
|
writeb((UCHAR) i, &pccs->var);
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs update_multi %d addresses in list\n", i);
|
2009-03-10 13:59:54 +00:00
|
|
|
/* Interrupt the firmware to process the command */
|
|
|
|
local->num_multi = i;
|
|
|
|
}
|
|
|
|
if (interrupt_ecf(local, ccsindex)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs update_multi failed - ECF not ready for intr\n");
|
|
|
|
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end ray_update_multi_list */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void set_multicast_list(struct net_device *dev)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
UCHAR promisc;
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs set_multicast_list(%p)\n", dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
if (dev->flags & IFF_PROMISC) {
|
|
|
|
if (local->sparm.b5.a_promiscuous_mode == 0) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs set_multicast_list promisc on\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
local->sparm.b5.a_promiscuous_mode = 1;
|
|
|
|
promisc = 1;
|
|
|
|
ray_update_parm(dev, OBJID_promiscuous_mode,
|
|
|
|
&promisc, sizeof(promisc));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (local->sparm.b5.a_promiscuous_mode == 1) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs set_multicast_list promisc off\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
local->sparm.b5.a_promiscuous_mode = 0;
|
|
|
|
promisc = 0;
|
|
|
|
ray_update_parm(dev, OBJID_promiscuous_mode,
|
|
|
|
&promisc, sizeof(promisc));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dev->flags & IFF_ALLMULTI)
|
|
|
|
ray_update_multi_list(dev, 1);
|
|
|
|
else {
|
2010-02-08 04:30:35 +00:00
|
|
|
if (local->num_multi != netdev_mc_count(dev))
|
2009-03-10 13:59:54 +00:00
|
|
|
ray_update_multi_list(dev, 0);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end set_multicast_list */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*=============================================================================
|
|
|
|
* All routines below here are run at interrupt time.
|
|
|
|
=============================================================================*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t ray_interrupt(int irq, void *dev_id)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
struct net_device *dev = (struct net_device *)dev_id;
|
|
|
|
struct pcmcia_device *link;
|
|
|
|
ray_dev_t *local;
|
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
struct rcs __iomem *prcs;
|
|
|
|
UCHAR rcsindex;
|
|
|
|
UCHAR tmp;
|
|
|
|
UCHAR cmd;
|
|
|
|
UCHAR status;
|
2013-01-08 05:33:03 +00:00
|
|
|
UCHAR memtmp[ESSID_SIZE + 1];
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
if (dev == NULL) /* Note that we want interrupts with dev->start == 0 */
|
|
|
|
return IRQ_NONE;
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs: interrupt for *dev=%p\n", dev);
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
local = netdev_priv(dev);
|
2012-06-04 12:44:17 +00:00
|
|
|
link = local->finder;
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!pcmcia_dev_present(link)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug(
|
|
|
|
"ray_cs interrupt from device not present or suspended.\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return IRQ_NONE;
|
|
|
|
}
|
|
|
|
rcsindex = readb(&((struct scb __iomem *)(local->sram))->rcs_index);
|
|
|
|
|
|
|
|
if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt bad rcsindex = 0x%x\n", rcsindex);
|
2009-03-10 13:59:54 +00:00
|
|
|
clear_interrupt(local);
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
if (rcsindex < NUMBER_OF_CCS) { /* If it's a returned CCS */
|
|
|
|
pccs = ccs_base(local) + rcsindex;
|
|
|
|
cmd = readb(&pccs->cmd);
|
|
|
|
status = readb(&pccs->buffer_status);
|
|
|
|
switch (cmd) {
|
|
|
|
case CCS_DOWNLOAD_STARTUP_PARAMS: /* Happens in firmware someday */
|
|
|
|
del_timer(&local->timer);
|
|
|
|
if (status == CCS_COMMAND_COMPLETE) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt download_startup_parameters OK\n");
|
|
|
|
} else {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt download_startup_parameters fail\n");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CCS_UPDATE_PARAMS:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt update params done\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
if (status != CCS_COMMAND_COMPLETE) {
|
|
|
|
tmp =
|
|
|
|
readb(&pccs->var.update_param.
|
|
|
|
failure_cause);
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt update params failed - reason %d\n",
|
|
|
|
tmp);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CCS_REPORT_PARAMS:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt report params done\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
break;
|
|
|
|
case CCS_UPDATE_MULTICAST_LIST: /* Note that this CCS isn't returned */
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt CCS Update Multicast List done\n");
|
|
|
|
break;
|
|
|
|
case CCS_UPDATE_POWER_SAVINGS_MODE:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt update power save mode done\n");
|
|
|
|
break;
|
|
|
|
case CCS_START_NETWORK:
|
|
|
|
case CCS_JOIN_NETWORK:
|
2013-01-08 05:33:03 +00:00
|
|
|
memcpy(memtmp, local->sparm.b4.a_current_ess_id,
|
|
|
|
ESSID_SIZE);
|
|
|
|
memtmp[ESSID_SIZE] = '\0';
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (status == CCS_COMMAND_COMPLETE) {
|
|
|
|
if (readb
|
|
|
|
(&pccs->var.start_network.net_initiated) ==
|
|
|
|
1) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt network \"%s\" started\n",
|
2013-01-08 05:33:03 +00:00
|
|
|
memtmp);
|
2009-03-10 13:59:54 +00:00
|
|
|
} else {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt network \"%s\" joined\n",
|
2013-01-08 05:33:03 +00:00
|
|
|
memtmp);
|
2009-03-10 13:59:54 +00:00
|
|
|
}
|
|
|
|
memcpy_fromio(&local->bss_id,
|
|
|
|
pccs->var.start_network.bssid,
|
|
|
|
ADDRLEN);
|
|
|
|
|
|
|
|
if (local->fw_ver == 0x55)
|
|
|
|
local->net_default_tx_rate = 3;
|
|
|
|
else
|
|
|
|
local->net_default_tx_rate =
|
|
|
|
readb(&pccs->var.start_network.
|
|
|
|
net_default_tx_rate);
|
|
|
|
local->encryption =
|
|
|
|
readb(&pccs->var.start_network.encryption);
|
|
|
|
if (!sniffer && (local->net_type == INFRA)
|
|
|
|
&& !(local->sparm.b4.a_acting_as_ap_status)) {
|
|
|
|
authenticate(local);
|
|
|
|
}
|
|
|
|
local->card_status = CARD_ACQ_COMPLETE;
|
|
|
|
} else {
|
|
|
|
local->card_status = CARD_ACQ_FAILED;
|
|
|
|
|
|
|
|
del_timer(&local->timer);
|
|
|
|
local->timer.expires = jiffies + HZ * 5;
|
|
|
|
local->timer.data = (long)local;
|
|
|
|
if (status == CCS_START_NETWORK) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt network \"%s\" start failed\n",
|
2013-01-08 05:33:03 +00:00
|
|
|
memtmp);
|
2010-08-23 18:20:03 +00:00
|
|
|
local->timer.function = start_net;
|
2009-03-10 13:59:54 +00:00
|
|
|
} else {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt network \"%s\" join failed\n",
|
2013-01-08 05:33:03 +00:00
|
|
|
memtmp);
|
2010-08-23 18:20:03 +00:00
|
|
|
local->timer.function = join_net;
|
2009-03-10 13:59:54 +00:00
|
|
|
}
|
|
|
|
add_timer(&local->timer);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CCS_START_ASSOCIATION:
|
|
|
|
if (status == CCS_COMMAND_COMPLETE) {
|
|
|
|
local->card_status = CARD_ASSOC_COMPLETE;
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs association successful\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
} else {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs association failed,\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
local->card_status = CARD_ASSOC_FAILED;
|
|
|
|
join_net((u_long) local);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case CCS_TX_REQUEST:
|
|
|
|
if (status == CCS_COMMAND_COMPLETE) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt tx request complete\n");
|
|
|
|
} else {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt tx request failed\n");
|
|
|
|
}
|
|
|
|
if (!sniffer)
|
|
|
|
netif_start_queue(dev);
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
break;
|
|
|
|
case CCS_TEST_MEMORY:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt mem test done\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
break;
|
|
|
|
case CCS_SHUTDOWN:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt Unexpected CCS returned - Shutdown\n");
|
|
|
|
break;
|
|
|
|
case CCS_DUMP_MEMORY:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt dump memory done\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
break;
|
|
|
|
case CCS_START_TIMER:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt DING - raylink timer expired\n");
|
|
|
|
break;
|
|
|
|
default:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs interrupt Unexpected CCS 0x%x returned 0x%x\n",
|
|
|
|
rcsindex, cmd);
|
|
|
|
}
|
|
|
|
writeb(CCS_BUFFER_FREE, &pccs->buffer_status);
|
|
|
|
} else { /* It's an RCS */
|
|
|
|
|
|
|
|
prcs = rcs_base(local) + rcsindex;
|
|
|
|
|
|
|
|
switch (readb(&prcs->interrupt_id)) {
|
|
|
|
case PROCESS_RX_PACKET:
|
|
|
|
ray_rx(dev, local, prcs);
|
|
|
|
break;
|
|
|
|
case REJOIN_NET_COMPLETE:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt rejoin net complete\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
local->card_status = CARD_ACQ_COMPLETE;
|
|
|
|
/* do we need to clear tx buffers CCS's? */
|
|
|
|
if (local->sparm.b4.a_network_type == ADHOC) {
|
|
|
|
if (!sniffer)
|
|
|
|
netif_start_queue(dev);
|
|
|
|
} else {
|
|
|
|
memcpy_fromio(&local->bss_id,
|
|
|
|
prcs->var.rejoin_net_complete.
|
|
|
|
bssid, ADDRLEN);
|
2010-12-02 12:45:07 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs new BSSID = %pm\n",
|
|
|
|
local->bss_id);
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!sniffer)
|
|
|
|
authenticate(local);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ROAMING_INITIATED:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt roaming initiated\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
netif_stop_queue(dev);
|
|
|
|
local->card_status = CARD_DOING_ACQ;
|
|
|
|
break;
|
|
|
|
case JAPAN_CALL_SIGN_RXD:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs interrupt japan call sign rx\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
break;
|
|
|
|
default:
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev,
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs Unexpected interrupt for RCS 0x%x cmd = 0x%x\n",
|
|
|
|
rcsindex,
|
|
|
|
(unsigned int)readb(&prcs->interrupt_id));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
writeb(CCS_BUFFER_FREE, &prcs->buffer_status);
|
|
|
|
}
|
|
|
|
clear_interrupt(local);
|
|
|
|
return IRQ_HANDLED;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* ray_interrupt */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static void ray_rx(struct net_device *dev, ray_dev_t *local,
|
|
|
|
struct rcs __iomem *prcs)
|
|
|
|
{
|
|
|
|
int rx_len;
|
|
|
|
unsigned int pkt_addr;
|
|
|
|
void __iomem *pmsg;
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_rx process rx packet\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
/* Calculate address of packet within Rx buffer */
|
|
|
|
pkt_addr = ((readb(&prcs->var.rx_packet.rx_data_ptr[0]) << 8)
|
|
|
|
+ readb(&prcs->var.rx_packet.rx_data_ptr[1])) & RX_BUFF_END;
|
|
|
|
/* Length of first packet fragment */
|
|
|
|
rx_len = (readb(&prcs->var.rx_packet.rx_data_length[0]) << 8)
|
|
|
|
+ readb(&prcs->var.rx_packet.rx_data_length[1]);
|
|
|
|
|
|
|
|
local->last_rsl = readb(&prcs->var.rx_packet.rx_sig_lev);
|
|
|
|
pmsg = local->rmem + pkt_addr;
|
|
|
|
switch (readb(pmsg)) {
|
|
|
|
case DATA_TYPE:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_rx data type\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
rx_data(dev, prcs, pkt_addr, rx_len);
|
|
|
|
break;
|
|
|
|
case AUTHENTIC_TYPE:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_rx authentic type\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
if (sniffer)
|
|
|
|
rx_data(dev, prcs, pkt_addr, rx_len);
|
|
|
|
else
|
|
|
|
rx_authenticate(local, prcs, pkt_addr, rx_len);
|
|
|
|
break;
|
|
|
|
case DEAUTHENTIC_TYPE:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_rx deauth type\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
if (sniffer)
|
|
|
|
rx_data(dev, prcs, pkt_addr, rx_len);
|
|
|
|
else
|
|
|
|
rx_deauthenticate(local, prcs, pkt_addr, rx_len);
|
|
|
|
break;
|
|
|
|
case NULL_MSG_TYPE:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs rx NULL msg\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
break;
|
|
|
|
case BEACON_TYPE:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_rx beacon type\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
if (sniffer)
|
|
|
|
rx_data(dev, prcs, pkt_addr, rx_len);
|
|
|
|
|
|
|
|
copy_from_rx_buff(local, (UCHAR *) &local->last_bcn, pkt_addr,
|
|
|
|
rx_len < sizeof(struct beacon_rx) ?
|
|
|
|
rx_len : sizeof(struct beacon_rx));
|
|
|
|
|
|
|
|
local->beacon_rxed = 1;
|
|
|
|
/* Get the statistics so the card counters never overflow */
|
|
|
|
ray_get_stats(dev);
|
|
|
|
break;
|
|
|
|
default:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs unknown pkt type %2x\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
(unsigned int)readb(pmsg));
|
|
|
|
break;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
} /* end ray_rx */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
|
|
|
|
unsigned int pkt_addr, int rx_len)
|
|
|
|
{
|
|
|
|
struct sk_buff *skb = NULL;
|
|
|
|
struct rcs __iomem *prcslink = prcs;
|
|
|
|
ray_dev_t *local = netdev_priv(dev);
|
|
|
|
UCHAR *rx_ptr;
|
|
|
|
int total_len;
|
|
|
|
int tmp;
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef WIRELESS_SPY
|
2009-03-10 13:59:54 +00:00
|
|
|
int siglev = local->last_rsl;
|
|
|
|
u_char linksrcaddr[ETH_ALEN]; /* Other end of the wireless link */
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!sniffer) {
|
|
|
|
if (translate) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/* TBD length needs fixing for translated header */
|
2009-03-10 13:59:54 +00:00
|
|
|
if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
|
|
|
|
rx_len >
|
|
|
|
(dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
|
|
|
|
FCS_LEN)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug(
|
2010-03-24 18:46:34 +00:00
|
|
|
"ray_cs invalid packet length %d received\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
rx_len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else { /* encapsulated ethernet */
|
|
|
|
|
|
|
|
if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
|
|
|
|
rx_len >
|
|
|
|
(dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
|
|
|
|
FCS_LEN)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug(
|
2010-03-24 18:46:34 +00:00
|
|
|
"ray_cs invalid packet length %d received\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
rx_len);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs rx_data packet\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
/* If fragmented packet, verify sizes of fragments add up */
|
|
|
|
if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs rx'ed fragment\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
tmp = (readb(&prcs->var.rx_packet.totalpacketlength[0]) << 8)
|
|
|
|
+ readb(&prcs->var.rx_packet.totalpacketlength[1]);
|
|
|
|
total_len = tmp;
|
|
|
|
prcslink = prcs;
|
|
|
|
do {
|
|
|
|
tmp -=
|
|
|
|
(readb(&prcslink->var.rx_packet.rx_data_length[0])
|
|
|
|
<< 8)
|
|
|
|
+ readb(&prcslink->var.rx_packet.rx_data_length[1]);
|
|
|
|
if (readb(&prcslink->var.rx_packet.next_frag_rcs_index)
|
|
|
|
== 0xFF || tmp < 0)
|
|
|
|
break;
|
|
|
|
prcslink = rcs_base(local)
|
|
|
|
+ readb(&prcslink->link_field);
|
|
|
|
} while (1);
|
|
|
|
|
|
|
|
if (tmp < 0) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug(
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs rx_data fragment lengths don't add up\n");
|
|
|
|
local->stats.rx_dropped++;
|
|
|
|
release_frag_chain(local, prcs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else { /* Single unfragmented packet */
|
|
|
|
total_len = rx_len;
|
|
|
|
}
|
|
|
|
|
|
|
|
skb = dev_alloc_skb(total_len + 5);
|
|
|
|
if (skb == NULL) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs rx_data could not allocate skb\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
local->stats.rx_dropped++;
|
|
|
|
if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF)
|
|
|
|
release_frag_chain(local, prcs);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
skb_reserve(skb, 2); /* Align IP on 16 byte (TBD check this) */
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs rx_data total_len = %x, rx_len = %x\n", total_len,
|
2009-03-10 13:59:54 +00:00
|
|
|
rx_len);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/************************/
|
2009-03-10 13:59:54 +00:00
|
|
|
/* Reserve enough room for the whole damn packet. */
|
|
|
|
rx_ptr = skb_put(skb, total_len);
|
|
|
|
/* Copy the whole packet to sk_buff */
|
|
|
|
rx_ptr +=
|
|
|
|
copy_from_rx_buff(local, rx_ptr, pkt_addr & RX_BUFF_END, rx_len);
|
|
|
|
/* Get source address */
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef WIRELESS_SPY
|
2009-03-10 13:59:54 +00:00
|
|
|
skb_copy_from_linear_data_offset(skb,
|
|
|
|
offsetof(struct mac_header, addr_2),
|
|
|
|
linksrcaddr, ETH_ALEN);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2009-03-10 13:59:54 +00:00
|
|
|
/* Now, deal with encapsulation/translation/sniffer */
|
|
|
|
if (!sniffer) {
|
|
|
|
if (!translate) {
|
|
|
|
/* Encapsulated ethernet, so just lop off 802.11 MAC header */
|
2005-04-16 22:20:36 +00:00
|
|
|
/* TBD reserve skb_reserve( skb, RX_MAC_HEADER_LENGTH); */
|
2009-03-10 13:59:54 +00:00
|
|
|
skb_pull(skb, RX_MAC_HEADER_LENGTH);
|
|
|
|
} else {
|
|
|
|
/* Do translation */
|
|
|
|
untranslate(local, skb, total_len);
|
|
|
|
}
|
|
|
|
} else { /* sniffer mode, so just pass whole packet */
|
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/************************/
|
2009-03-10 13:59:54 +00:00
|
|
|
/* Now pick up the rest of the fragments if any */
|
|
|
|
tmp = 17;
|
|
|
|
if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
|
|
|
|
prcslink = prcs;
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs rx_data in fragment loop\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
do {
|
|
|
|
prcslink = rcs_base(local)
|
|
|
|
+
|
|
|
|
readb(&prcslink->var.rx_packet.next_frag_rcs_index);
|
|
|
|
rx_len =
|
|
|
|
((readb(&prcslink->var.rx_packet.rx_data_length[0])
|
|
|
|
<< 8)
|
|
|
|
+
|
|
|
|
readb(&prcslink->var.rx_packet.rx_data_length[1]))
|
|
|
|
& RX_BUFF_END;
|
|
|
|
pkt_addr =
|
|
|
|
((readb(&prcslink->var.rx_packet.rx_data_ptr[0]) <<
|
|
|
|
8)
|
|
|
|
+ readb(&prcslink->var.rx_packet.rx_data_ptr[1]))
|
|
|
|
& RX_BUFF_END;
|
|
|
|
|
|
|
|
rx_ptr +=
|
|
|
|
copy_from_rx_buff(local, rx_ptr, pkt_addr, rx_len);
|
|
|
|
|
|
|
|
} while (tmp-- &&
|
|
|
|
readb(&prcslink->var.rx_packet.next_frag_rcs_index) !=
|
|
|
|
0xFF);
|
|
|
|
release_frag_chain(local, prcs);
|
|
|
|
}
|
|
|
|
|
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
|
|
|
netif_rx(skb);
|
|
|
|
local->stats.rx_packets++;
|
|
|
|
local->stats.rx_bytes += total_len;
|
|
|
|
|
|
|
|
/* Gather signal strength per address */
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifdef WIRELESS_SPY
|
2009-03-10 13:59:54 +00:00
|
|
|
/* For the Access Point or the node having started the ad-hoc net
|
|
|
|
* note : ad-hoc work only in some specific configurations, but we
|
|
|
|
* kludge in ray_get_wireless_stats... */
|
|
|
|
if (!memcmp(linksrcaddr, local->bss_id, ETH_ALEN)) {
|
|
|
|
/* Update statistics */
|
|
|
|
/*local->wstats.qual.qual = none ? */
|
|
|
|
local->wstats.qual.level = siglev;
|
|
|
|
/*local->wstats.qual.noise = none ? */
|
|
|
|
local->wstats.qual.updated = 0x2;
|
|
|
|
}
|
|
|
|
/* Now, update the spy stuff */
|
|
|
|
{
|
|
|
|
struct iw_quality wstats;
|
|
|
|
wstats.level = siglev;
|
|
|
|
/* wstats.noise = none ? */
|
|
|
|
/* wstats.qual = none ? */
|
|
|
|
wstats.updated = 0x2;
|
|
|
|
/* Update spy records */
|
|
|
|
wireless_spy_update(dev, linksrcaddr, &wstats);
|
|
|
|
}
|
|
|
|
#endif /* WIRELESS_SPY */
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end rx_data */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
snaphdr_t *psnap = (snaphdr_t *) (skb->data + RX_MAC_HEADER_LENGTH);
|
|
|
|
struct ieee80211_hdr *pmac = (struct ieee80211_hdr *)skb->data;
|
|
|
|
__be16 type = *(__be16 *) psnap->ethertype;
|
|
|
|
int delta;
|
|
|
|
struct ethhdr *peth;
|
|
|
|
UCHAR srcaddr[ADDRLEN];
|
|
|
|
UCHAR destaddr[ADDRLEN];
|
2010-11-21 02:38:59 +00:00
|
|
|
static const UCHAR org_bridge[3] = { 0, 0, 0xf8 };
|
|
|
|
static const UCHAR org_1042[3] = { 0, 0, 0 };
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
memcpy(destaddr, ieee80211_get_DA(pmac), ADDRLEN);
|
|
|
|
memcpy(srcaddr, ieee80211_get_SA(pmac), ADDRLEN);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
#if 0
|
|
|
|
if {
|
2009-07-06 20:05:40 +00:00
|
|
|
print_hex_dump(KERN_DEBUG, "skb->data before untranslate: ",
|
|
|
|
DUMP_PREFIX_NONE, 16, 1,
|
|
|
|
skb->data, 64, true);
|
|
|
|
printk(KERN_DEBUG
|
2009-03-10 13:59:54 +00:00
|
|
|
"type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n",
|
|
|
|
ntohs(type), psnap->dsap, psnap->ssap, psnap->ctrl,
|
|
|
|
psnap->org[0], psnap->org[1], psnap->org[2]);
|
|
|
|
printk(KERN_DEBUG "untranslate skb->data = %p\n", skb->data);
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
if (psnap->dsap != 0xaa || psnap->ssap != 0xaa || psnap->ctrl != 3) {
|
|
|
|
/* not a snap type so leave it alone */
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs untranslate NOT SNAP %02x %02x %02x\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
psnap->dsap, psnap->ssap, psnap->ctrl);
|
|
|
|
|
|
|
|
delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
|
|
|
|
peth = (struct ethhdr *)(skb->data + delta);
|
|
|
|
peth->h_proto = htons(len - RX_MAC_HEADER_LENGTH);
|
|
|
|
} else { /* Its a SNAP */
|
|
|
|
if (memcmp(psnap->org, org_bridge, 3) == 0) {
|
|
|
|
/* EtherII and nuke the LLC */
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs untranslate Bridge encap\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
delta = RX_MAC_HEADER_LENGTH
|
|
|
|
+ sizeof(struct snaphdr_t) - ETH_HLEN;
|
|
|
|
peth = (struct ethhdr *)(skb->data + delta);
|
|
|
|
peth->h_proto = type;
|
|
|
|
} else if (memcmp(psnap->org, org_1042, 3) == 0) {
|
|
|
|
switch (ntohs(type)) {
|
|
|
|
case ETH_P_IPX:
|
|
|
|
case ETH_P_AARP:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs untranslate RFC IPX/AARP\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
|
|
|
|
peth = (struct ethhdr *)(skb->data + delta);
|
|
|
|
peth->h_proto =
|
|
|
|
htons(len - RX_MAC_HEADER_LENGTH);
|
|
|
|
break;
|
|
|
|
default:
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs untranslate RFC default\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
delta = RX_MAC_HEADER_LENGTH +
|
|
|
|
sizeof(struct snaphdr_t) - ETH_HLEN;
|
|
|
|
peth = (struct ethhdr *)(skb->data + delta);
|
|
|
|
peth->h_proto = type;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printk("ray_cs untranslate very confused by packet\n");
|
|
|
|
delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
|
|
|
|
peth = (struct ethhdr *)(skb->data + delta);
|
|
|
|
peth->h_proto = type;
|
|
|
|
}
|
2007-12-29 09:55:50 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
/* TBD reserve skb_reserve(skb, delta); */
|
2009-03-10 13:59:54 +00:00
|
|
|
skb_pull(skb, delta);
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("untranslate after skb_pull(%d), skb->data = %p\n", delta,
|
2009-03-10 13:59:54 +00:00
|
|
|
skb->data);
|
|
|
|
memcpy(peth->h_dest, destaddr, ADDRLEN);
|
|
|
|
memcpy(peth->h_source, srcaddr, ADDRLEN);
|
2009-10-24 13:52:44 +00:00
|
|
|
#if 0
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int i;
|
|
|
|
printk(KERN_DEBUG "skb->data after untranslate:");
|
|
|
|
for (i = 0; i < 64; i++)
|
|
|
|
printk("%02x ", skb->data[i]);
|
|
|
|
printk("\n");
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
} /* end untranslate */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Copy data from circular receive buffer to PC memory.
|
|
|
|
* dest = destination address in PC memory
|
|
|
|
* pkt_addr = source address in receive buffer
|
|
|
|
* len = length of packet to copy
|
|
|
|
*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr,
|
|
|
|
int length)
|
|
|
|
{
|
|
|
|
int wrap_bytes = (pkt_addr + length) - (RX_BUFF_END + 1);
|
|
|
|
if (wrap_bytes <= 0) {
|
|
|
|
memcpy_fromio(dest, local->rmem + pkt_addr, length);
|
|
|
|
} else { /* Packet wrapped in circular buffer */
|
|
|
|
|
|
|
|
memcpy_fromio(dest, local->rmem + pkt_addr,
|
|
|
|
length - wrap_bytes);
|
|
|
|
memcpy_fromio(dest + length - wrap_bytes, local->rmem,
|
|
|
|
wrap_bytes);
|
|
|
|
}
|
|
|
|
return length;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs)
|
|
|
|
{
|
|
|
|
struct rcs __iomem *prcslink = prcs;
|
|
|
|
int tmp = 17;
|
|
|
|
unsigned rcsindex = readb(&prcs->var.rx_packet.next_frag_rcs_index);
|
|
|
|
|
|
|
|
while (tmp--) {
|
|
|
|
writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
|
|
|
|
if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs interrupt bad rcsindex = 0x%x\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
rcsindex);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
prcslink = rcs_base(local) + rcsindex;
|
|
|
|
rcsindex = readb(&prcslink->var.rx_packet.next_frag_rcs_index);
|
|
|
|
}
|
|
|
|
writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void authenticate(ray_dev_t *local)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
struct pcmcia_device *link = local->finder;
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs Starting authentication.\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs authenticate - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
del_timer(&local->timer);
|
|
|
|
if (build_auth_frame(local, local->bss_id, OPEN_AUTH_REQUEST)) {
|
2010-08-23 18:20:03 +00:00
|
|
|
local->timer.function = join_net;
|
2009-03-10 13:59:54 +00:00
|
|
|
} else {
|
2010-08-23 18:20:03 +00:00
|
|
|
local->timer.function = authenticate_timeout;
|
2009-03-10 13:59:54 +00:00
|
|
|
}
|
|
|
|
local->timer.expires = jiffies + HZ * 2;
|
|
|
|
local->timer.data = (long)local;
|
|
|
|
add_timer(&local->timer);
|
|
|
|
local->authentication_state = AWAITING_RESPONSE;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* end authenticate */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
|
2009-03-10 13:59:54 +00:00
|
|
|
unsigned int pkt_addr, int rx_len)
|
|
|
|
{
|
|
|
|
UCHAR buff[256];
|
2011-11-26 20:41:29 +00:00
|
|
|
struct ray_rx_msg *msg = (struct ray_rx_msg *) buff;
|
2009-03-10 13:59:54 +00:00
|
|
|
|
|
|
|
del_timer(&local->timer);
|
|
|
|
|
|
|
|
copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
|
|
|
|
/* if we are trying to get authenticated */
|
|
|
|
if (local->sparm.b4.a_network_type == ADHOC) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs rx_auth var= %02x %02x %02x %02x %02x %02x\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
msg->var[0], msg->var[1], msg->var[2], msg->var[3],
|
|
|
|
msg->var[4], msg->var[5]);
|
|
|
|
if (msg->var[2] == 1) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs Sending authentication response.\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
if (!build_auth_frame
|
|
|
|
(local, msg->mac.addr_2, OPEN_AUTH_RESPONSE)) {
|
|
|
|
local->authentication_state = NEED_TO_AUTH;
|
|
|
|
memcpy(local->auth_id, msg->mac.addr_2,
|
|
|
|
ADDRLEN);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { /* Infrastructure network */
|
|
|
|
|
|
|
|
if (local->authentication_state == AWAITING_RESPONSE) {
|
|
|
|
/* Verify authentication sequence #2 and success */
|
|
|
|
if (msg->var[2] == 2) {
|
|
|
|
if ((msg->var[3] | msg->var[4]) == 0) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("Authentication successful\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
local->card_status = CARD_AUTH_COMPLETE;
|
|
|
|
associate(local);
|
|
|
|
local->authentication_state =
|
|
|
|
AUTHENTICATED;
|
|
|
|
} else {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("Authentication refused\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
local->card_status = CARD_AUTH_REFUSED;
|
|
|
|
join_net((u_long) local);
|
|
|
|
local->authentication_state =
|
|
|
|
UNAUTHENTICATED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
} /* end rx_authenticate */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void associate(ray_dev_t *local)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
struct pcmcia_device *link = local->finder;
|
|
|
|
struct net_device *dev = link->priv;
|
|
|
|
int ccsindex;
|
|
|
|
if (!(pcmcia_dev_present(link))) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs associate - device not present\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
/* If no tx buffers available, return */
|
|
|
|
if ((ccsindex = get_free_ccs(local)) < 0) {
|
2005-04-16 22:20:36 +00:00
|
|
|
/* TBD should never be here but... what if we are? */
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs associate - No free ccs\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs Starting association with access point\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
pccs = ccs_base(local) + ccsindex;
|
|
|
|
/* fill in the CCS */
|
|
|
|
writeb(CCS_START_ASSOCIATION, &pccs->cmd);
|
|
|
|
/* Interrupt the firmware to process the command */
|
|
|
|
if (interrupt_ecf(local, ccsindex)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
dev_dbg(&link->dev, "ray_cs associate failed - ECF not ready for intr\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
|
|
|
|
|
|
|
|
del_timer(&local->timer);
|
|
|
|
local->timer.expires = jiffies + HZ * 2;
|
|
|
|
local->timer.data = (long)local;
|
2010-08-23 18:20:03 +00:00
|
|
|
local->timer.function = join_net;
|
2009-03-10 13:59:54 +00:00
|
|
|
add_timer(&local->timer);
|
|
|
|
local->card_status = CARD_ASSOC_FAILED;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!sniffer)
|
|
|
|
netif_start_queue(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
} /* end associate */
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
2009-03-10 13:59:54 +00:00
|
|
|
static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
|
|
|
|
unsigned int pkt_addr, int rx_len)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
/* UCHAR buff[256];
|
2011-11-26 20:41:29 +00:00
|
|
|
struct ray_rx_msg *msg = (struct ray_rx_msg *) buff;
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("Deauthentication frame received\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
local->authentication_state = UNAUTHENTICATED;
|
|
|
|
/* Need to reauthenticate or rejoin depending on reason code */
|
2005-04-16 22:20:36 +00:00
|
|
|
/* copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
|
|
|
|
*/
|
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
static void clear_interrupt(ray_dev_t *local)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
writeb(0, local->amem + CIS_OFFSET + HCS_INTR_OFFSET);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
#ifdef CONFIG_PROC_FS
|
|
|
|
#define MAXDATA (PAGE_SIZE - 80)
|
|
|
|
|
2010-09-02 01:16:22 +00:00
|
|
|
static const char *card_status[] = {
|
2009-03-10 13:59:54 +00:00
|
|
|
"Card inserted - uninitialized", /* 0 */
|
|
|
|
"Card not downloaded", /* 1 */
|
|
|
|
"Waiting for download parameters", /* 2 */
|
|
|
|
"Card doing acquisition", /* 3 */
|
|
|
|
"Acquisition complete", /* 4 */
|
|
|
|
"Authentication complete", /* 5 */
|
|
|
|
"Association complete", /* 6 */
|
|
|
|
"???", "???", "???", "???", /* 7 8 9 10 undefined */
|
|
|
|
"Card init error", /* 11 */
|
|
|
|
"Download parameters error", /* 12 */
|
|
|
|
"???", /* 13 */
|
|
|
|
"Acquisition failed", /* 14 */
|
|
|
|
"Authentication refused", /* 15 */
|
|
|
|
"Association failed" /* 16 */
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2010-09-02 01:16:22 +00:00
|
|
|
static const char *nettype[] = { "Adhoc", "Infra " };
|
|
|
|
static const char *framing[] = { "Encapsulation", "Translation" }
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
;
|
|
|
|
/*===========================================================================*/
|
2008-04-10 21:34:35 +00:00
|
|
|
static int ray_cs_proc_show(struct seq_file *m, void *v)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
/* Print current values which are not available via other means
|
2009-03-10 13:59:54 +00:00
|
|
|
* eg ifconfig
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2009-03-10 13:59:54 +00:00
|
|
|
int i;
|
|
|
|
struct pcmcia_device *link;
|
|
|
|
struct net_device *dev;
|
|
|
|
ray_dev_t *local;
|
|
|
|
UCHAR *p;
|
|
|
|
struct freq_hop_element *pfh;
|
|
|
|
UCHAR c[33];
|
|
|
|
|
|
|
|
link = this_device;
|
|
|
|
if (!link)
|
|
|
|
return 0;
|
|
|
|
dev = (struct net_device *)link->priv;
|
|
|
|
if (!dev)
|
|
|
|
return 0;
|
|
|
|
local = netdev_priv(dev);
|
|
|
|
if (!local)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
seq_puts(m, "Raylink Wireless LAN driver status\n");
|
|
|
|
seq_printf(m, "%s\n", rcsid);
|
|
|
|
/* build 4 does not report version, and field is 0x55 after memtest */
|
|
|
|
seq_puts(m, "Firmware version = ");
|
|
|
|
if (local->fw_ver == 0x55)
|
|
|
|
seq_puts(m, "4 - Use dump_cis for more details\n");
|
|
|
|
else
|
|
|
|
seq_printf(m, "%2d.%02d.%02d\n",
|
|
|
|
local->fw_ver, local->fw_bld, local->fw_var);
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++)
|
|
|
|
c[i] = local->sparm.b5.a_current_ess_id[i];
|
|
|
|
c[32] = 0;
|
|
|
|
seq_printf(m, "%s network ESSID = \"%s\"\n",
|
|
|
|
nettype[local->sparm.b5.a_network_type], c);
|
|
|
|
|
|
|
|
p = local->bss_id;
|
|
|
|
seq_printf(m, "BSSID = %pM\n", p);
|
|
|
|
|
|
|
|
seq_printf(m, "Country code = %d\n",
|
|
|
|
local->sparm.b5.a_curr_country_code);
|
|
|
|
|
|
|
|
i = local->card_status;
|
|
|
|
if (i < 0)
|
|
|
|
i = 10;
|
|
|
|
if (i > 16)
|
|
|
|
i = 10;
|
|
|
|
seq_printf(m, "Card status = %s\n", card_status[i]);
|
|
|
|
|
|
|
|
seq_printf(m, "Framing mode = %s\n", framing[translate]);
|
|
|
|
|
|
|
|
seq_printf(m, "Last pkt signal lvl = %d\n", local->last_rsl);
|
|
|
|
|
|
|
|
if (local->beacon_rxed) {
|
|
|
|
/* Pull some fields out of last beacon received */
|
|
|
|
seq_printf(m, "Beacon Interval = %d Kus\n",
|
|
|
|
local->last_bcn.beacon_intvl[0]
|
|
|
|
+ 256 * local->last_bcn.beacon_intvl[1]);
|
|
|
|
|
|
|
|
p = local->last_bcn.elements;
|
|
|
|
if (p[0] == C_ESSID_ELEMENT_ID)
|
|
|
|
p += p[1] + 2;
|
|
|
|
else {
|
|
|
|
seq_printf(m,
|
|
|
|
"Parse beacon failed at essid element id = %d\n",
|
|
|
|
p[0]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p[0] == C_SUPPORTED_RATES_ELEMENT_ID) {
|
|
|
|
seq_puts(m, "Supported rate codes = ");
|
|
|
|
for (i = 2; i < p[1] + 2; i++)
|
|
|
|
seq_printf(m, "0x%02x ", p[i]);
|
|
|
|
seq_putc(m, '\n');
|
|
|
|
p += p[1] + 2;
|
|
|
|
} else {
|
|
|
|
seq_puts(m, "Parse beacon failed at rates element\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (p[0] == C_FH_PARAM_SET_ELEMENT_ID) {
|
|
|
|
pfh = (struct freq_hop_element *)p;
|
|
|
|
seq_printf(m, "Hop dwell = %d Kus\n",
|
|
|
|
pfh->dwell_time[0] +
|
|
|
|
256 * pfh->dwell_time[1]);
|
2010-03-24 18:46:34 +00:00
|
|
|
seq_printf(m, "Hop set = %d\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
pfh->hop_set);
|
2010-03-24 18:46:34 +00:00
|
|
|
seq_printf(m, "Hop pattern = %d\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
pfh->hop_pattern);
|
2010-03-24 18:46:34 +00:00
|
|
|
seq_printf(m, "Hop index = %d\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
pfh->hop_index);
|
|
|
|
p += p[1] + 2;
|
|
|
|
} else {
|
|
|
|
seq_puts(m,
|
|
|
|
"Parse beacon failed at FH param element\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
seq_puts(m, "No beacons received\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2009-03-10 13:59:54 +00:00
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-04-10 21:34:35 +00:00
|
|
|
static int ray_cs_proc_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
|
|
|
return single_open(file, ray_cs_proc_show, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations ray_cs_proc_fops = {
|
2009-03-10 13:59:54 +00:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = ray_cs_proc_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
|
|
|
.release = single_release,
|
2008-04-10 21:34:35 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
/*===========================================================================*/
|
|
|
|
static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int addr;
|
|
|
|
struct ccs __iomem *pccs;
|
|
|
|
struct tx_msg __iomem *ptx;
|
|
|
|
int ccsindex;
|
|
|
|
|
|
|
|
/* If no tx buffers available, return */
|
|
|
|
if ((ccsindex = get_free_tx_ccs(local)) < 0) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs send authenticate - No free tx ccs\n");
|
2009-03-10 13:59:54 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
pccs = ccs_base(local) + ccsindex;
|
|
|
|
|
|
|
|
/* Address in card space */
|
|
|
|
addr = TX_BUF_BASE + (ccsindex << 11);
|
|
|
|
/* fill in the CCS */
|
|
|
|
writeb(CCS_TX_REQUEST, &pccs->cmd);
|
|
|
|
writeb(addr >> 8, pccs->var.tx_request.tx_data_ptr);
|
|
|
|
writeb(0x20, pccs->var.tx_request.tx_data_ptr + 1);
|
|
|
|
writeb(TX_AUTHENTICATE_LENGTH_MSB, pccs->var.tx_request.tx_data_length);
|
|
|
|
writeb(TX_AUTHENTICATE_LENGTH_LSB,
|
|
|
|
pccs->var.tx_request.tx_data_length + 1);
|
|
|
|
writeb(0, &pccs->var.tx_request.pow_sav_mode);
|
|
|
|
|
|
|
|
ptx = local->sram + addr;
|
|
|
|
/* fill in the mac header */
|
|
|
|
writeb(PROTOCOL_VER | AUTHENTIC_TYPE, &ptx->mac.frame_ctl_1);
|
|
|
|
writeb(0, &ptx->mac.frame_ctl_2);
|
|
|
|
|
|
|
|
memcpy_toio(ptx->mac.addr_1, dest, ADDRLEN);
|
|
|
|
memcpy_toio(ptx->mac.addr_2, local->sparm.b4.a_mac_addr, ADDRLEN);
|
|
|
|
memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN);
|
|
|
|
|
|
|
|
/* Fill in msg body with protocol 00 00, sequence 01 00 ,status 00 00 */
|
|
|
|
memset_io(ptx->var, 0, 6);
|
|
|
|
writeb(auth_type & 0xff, ptx->var + 2);
|
|
|
|
|
|
|
|
/* Interrupt the firmware to process the command */
|
|
|
|
if (interrupt_ecf(local, ccsindex)) {
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug(
|
2009-03-10 13:59:54 +00:00
|
|
|
"ray_cs send authentication request failed - ECF not ready for intr\n");
|
|
|
|
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* End build_auth_frame */
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
#ifdef CONFIG_PROC_FS
|
2009-11-25 07:12:20 +00:00
|
|
|
static ssize_t ray_cs_essid_proc_write(struct file *file,
|
|
|
|
const char __user *buffer, size_t count, loff_t *pos)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
static char proc_essid[33];
|
2009-10-27 15:35:55 +00:00
|
|
|
unsigned int len = count;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (len > 32)
|
|
|
|
len = 32;
|
|
|
|
memset(proc_essid, 0, 33);
|
|
|
|
if (copy_from_user(proc_essid, buffer, len))
|
|
|
|
return -EFAULT;
|
|
|
|
essid = proc_essid;
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
2009-11-25 07:12:20 +00:00
|
|
|
static const struct file_operations ray_cs_essid_proc_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.write = ray_cs_essid_proc_write,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 16:52:59 +00:00
|
|
|
.llseek = noop_llseek,
|
2009-11-25 07:12:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static ssize_t int_proc_write(struct file *file, const char __user *buffer,
|
|
|
|
size_t count, loff_t *pos)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
static char proc_number[10];
|
|
|
|
char *p;
|
|
|
|
int nr, len;
|
|
|
|
|
|
|
|
if (!count)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (count > 9)
|
|
|
|
return -EINVAL;
|
|
|
|
if (copy_from_user(proc_number, buffer, count))
|
|
|
|
return -EFAULT;
|
|
|
|
p = proc_number;
|
|
|
|
nr = 0;
|
|
|
|
len = count;
|
|
|
|
do {
|
|
|
|
unsigned int c = *p - '0';
|
|
|
|
if (c > 9)
|
|
|
|
return -EINVAL;
|
2009-03-10 13:59:54 +00:00
|
|
|
nr = nr * 10 + c;
|
2005-04-16 22:20:36 +00:00
|
|
|
p++;
|
|
|
|
} while (--len);
|
2013-03-31 22:16:14 +00:00
|
|
|
*(int *)PDE_DATA(file_inode(file)) = nr;
|
2005-04-16 22:20:36 +00:00
|
|
|
return count;
|
|
|
|
}
|
2009-11-25 07:12:20 +00:00
|
|
|
|
|
|
|
static const struct file_operations int_proc_fops = {
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.write = int_proc_write,
|
llseek: automatically add .llseek fop
All file_operations should get a .llseek operation so we can make
nonseekable_open the default for future file operations without a
.llseek pointer.
The three cases that we can automatically detect are no_llseek, seq_lseek
and default_llseek. For cases where we can we can automatically prove that
the file offset is always ignored, we use noop_llseek, which maintains
the current behavior of not returning an error from a seek.
New drivers should normally not use noop_llseek but instead use no_llseek
and call nonseekable_open at open time. Existing drivers can be converted
to do the same when the maintainer knows for certain that no user code
relies on calling seek on the device file.
The generated code is often incorrectly indented and right now contains
comments that clarify for each added line why a specific variant was
chosen. In the version that gets submitted upstream, the comments will
be gone and I will manually fix the indentation, because there does not
seem to be a way to do that using coccinelle.
Some amount of new code is currently sitting in linux-next that should get
the same modifications, which I will do at the end of the merge window.
Many thanks to Julia Lawall for helping me learn to write a semantic
patch that does all this.
===== begin semantic patch =====
// This adds an llseek= method to all file operations,
// as a preparation for making no_llseek the default.
//
// The rules are
// - use no_llseek explicitly if we do nonseekable_open
// - use seq_lseek for sequential files
// - use default_llseek if we know we access f_pos
// - use noop_llseek if we know we don't access f_pos,
// but we still want to allow users to call lseek
//
@ open1 exists @
identifier nested_open;
@@
nested_open(...)
{
<+...
nonseekable_open(...)
...+>
}
@ open exists@
identifier open_f;
identifier i, f;
identifier open1.nested_open;
@@
int open_f(struct inode *i, struct file *f)
{
<+...
(
nonseekable_open(...)
|
nested_open(...)
)
...+>
}
@ read disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ read_no_fpos disable optional_qualifier exists @
identifier read_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t read_f(struct file *f, char *p, size_t s, loff_t *off)
{
... when != off
}
@ write @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
expression E;
identifier func;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
<+...
(
*off = E
|
*off += E
|
func(..., off, ...)
|
E = *off
)
...+>
}
@ write_no_fpos @
identifier write_f;
identifier f, p, s, off;
type ssize_t, size_t, loff_t;
@@
ssize_t write_f(struct file *f, const char *p, size_t s, loff_t *off)
{
... when != off
}
@ fops0 @
identifier fops;
@@
struct file_operations fops = {
...
};
@ has_llseek depends on fops0 @
identifier fops0.fops;
identifier llseek_f;
@@
struct file_operations fops = {
...
.llseek = llseek_f,
...
};
@ has_read depends on fops0 @
identifier fops0.fops;
identifier read_f;
@@
struct file_operations fops = {
...
.read = read_f,
...
};
@ has_write depends on fops0 @
identifier fops0.fops;
identifier write_f;
@@
struct file_operations fops = {
...
.write = write_f,
...
};
@ has_open depends on fops0 @
identifier fops0.fops;
identifier open_f;
@@
struct file_operations fops = {
...
.open = open_f,
...
};
// use no_llseek if we call nonseekable_open
////////////////////////////////////////////
@ nonseekable1 depends on !has_llseek && has_open @
identifier fops0.fops;
identifier nso ~= "nonseekable_open";
@@
struct file_operations fops = {
... .open = nso, ...
+.llseek = no_llseek, /* nonseekable */
};
@ nonseekable2 depends on !has_llseek @
identifier fops0.fops;
identifier open.open_f;
@@
struct file_operations fops = {
... .open = open_f, ...
+.llseek = no_llseek, /* open uses nonseekable */
};
// use seq_lseek for sequential files
/////////////////////////////////////
@ seq depends on !has_llseek @
identifier fops0.fops;
identifier sr ~= "seq_read";
@@
struct file_operations fops = {
... .read = sr, ...
+.llseek = seq_lseek, /* we have seq_read */
};
// use default_llseek if there is a readdir
///////////////////////////////////////////
@ fops1 depends on !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier readdir_e;
@@
// any other fop is used that changes pos
struct file_operations fops = {
... .readdir = readdir_e, ...
+.llseek = default_llseek, /* readdir is present */
};
// use default_llseek if at least one of read/write touches f_pos
/////////////////////////////////////////////////////////////////
@ fops2 depends on !fops1 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read.read_f;
@@
// read fops use offset
struct file_operations fops = {
... .read = read_f, ...
+.llseek = default_llseek, /* read accesses f_pos */
};
@ fops3 depends on !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write.write_f;
@@
// write fops use offset
struct file_operations fops = {
... .write = write_f, ...
+ .llseek = default_llseek, /* write accesses f_pos */
};
// Use noop_llseek if neither read nor write accesses f_pos
///////////////////////////////////////////////////////////
@ fops4 depends on !fops1 && !fops2 && !fops3 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
identifier write_no_fpos.write_f;
@@
// write fops use offset
struct file_operations fops = {
...
.write = write_f,
.read = read_f,
...
+.llseek = noop_llseek, /* read and write both use no f_pos */
};
@ depends on has_write && !has_read && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier write_no_fpos.write_f;
@@
struct file_operations fops = {
... .write = write_f, ...
+.llseek = noop_llseek, /* write uses no f_pos */
};
@ depends on has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
identifier read_no_fpos.read_f;
@@
struct file_operations fops = {
... .read = read_f, ...
+.llseek = noop_llseek, /* read uses no f_pos */
};
@ depends on !has_read && !has_write && !fops1 && !fops2 && !has_llseek && !nonseekable1 && !nonseekable2 && !seq @
identifier fops0.fops;
@@
struct file_operations fops = {
...
+.llseek = noop_llseek, /* no read or write fn */
};
===== End semantic patch =====
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Julia Lawall <julia@diku.dk>
Cc: Christoph Hellwig <hch@infradead.org>
2010-08-15 16:52:59 +00:00
|
|
|
.llseek = noop_llseek,
|
2009-11-25 07:12:20 +00:00
|
|
|
};
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2011-05-04 02:29:01 +00:00
|
|
|
static const struct pcmcia_device_id ray_ids[] = {
|
2005-06-27 23:28:24 +00:00
|
|
|
PCMCIA_DEVICE_MANF_CARD(0x01a6, 0x0000),
|
|
|
|
PCMCIA_DEVICE_NULL,
|
|
|
|
};
|
2009-03-10 13:59:54 +00:00
|
|
|
|
2005-06-27 23:28:24 +00:00
|
|
|
MODULE_DEVICE_TABLE(pcmcia, ray_ids);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct pcmcia_driver ray_driver = {
|
2009-03-10 13:59:54 +00:00
|
|
|
.owner = THIS_MODULE,
|
2010-08-08 09:36:26 +00:00
|
|
|
.name = "ray_cs",
|
2009-03-10 13:59:54 +00:00
|
|
|
.probe = ray_probe,
|
|
|
|
.remove = ray_detach,
|
|
|
|
.id_table = ray_ids,
|
|
|
|
.suspend = ray_suspend,
|
|
|
|
.resume = ray_resume,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init init_ray_cs(void)
|
|
|
|
{
|
2009-03-10 13:59:54 +00:00
|
|
|
int rc;
|
|
|
|
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("%s\n", rcsid);
|
2009-03-10 13:59:54 +00:00
|
|
|
rc = pcmcia_register_driver(&ray_driver);
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("raylink init_module register_pcmcia_driver returns 0x%x\n",
|
2009-03-10 13:59:54 +00:00
|
|
|
rc);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_PROC_FS
|
2009-03-10 13:59:54 +00:00
|
|
|
proc_mkdir("driver/ray_cs", NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
proc_create("driver/ray_cs/ray_cs", 0, NULL, &ray_cs_proc_fops);
|
2009-11-25 07:12:20 +00:00
|
|
|
proc_create("driver/ray_cs/essid", S_IWUSR, NULL, &ray_cs_essid_proc_fops);
|
|
|
|
proc_create_data("driver/ray_cs/net_type", S_IWUSR, NULL, &int_proc_fops, &net_type);
|
|
|
|
proc_create_data("driver/ray_cs/translate", S_IWUSR, NULL, &int_proc_fops, &translate);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
2009-03-10 13:59:54 +00:00
|
|
|
if (translate != 0)
|
|
|
|
translate = 1;
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* init_ray_cs */
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
static void __exit exit_ray_cs(void)
|
|
|
|
{
|
2009-10-24 13:52:44 +00:00
|
|
|
pr_debug("ray_cs: cleanup_module\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_PROC_FS
|
2009-03-10 13:59:54 +00:00
|
|
|
remove_proc_entry("driver/ray_cs/ray_cs", NULL);
|
|
|
|
remove_proc_entry("driver/ray_cs/essid", NULL);
|
|
|
|
remove_proc_entry("driver/ray_cs/net_type", NULL);
|
|
|
|
remove_proc_entry("driver/ray_cs/translate", NULL);
|
|
|
|
remove_proc_entry("driver/ray_cs", NULL);
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif
|
|
|
|
|
2009-03-10 13:59:54 +00:00
|
|
|
pcmcia_unregister_driver(&ray_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* exit_ray_cs */
|
|
|
|
|
|
|
|
module_init(init_ray_cs);
|
|
|
|
module_exit(exit_ray_cs);
|
|
|
|
|
|
|
|
/*===========================================================================*/
|