Commit 141fa61f authored by John Daiker's avatar John Daiker Committed by John W. Linville

ray_cs: checkpatch.pl and Lindent cleanups

Before: 1099 errors, 93 warnings, 2854 lines checked
After:  19 errors, 47 warnings, 2976 lines checked

The big bulk of this is code indent and over 80 character lines
(Lindent did this part) Other changes are foo * bar spacing, and
trailing whitespace.

v2: Cleans up ill-indented comments.  Subsequently, this reduces the
number of warnings, too.  Thanks to Joe Perches for pointing this out!

v3: Ran the whole file through Lindent first... which does most of
the work for me. :) Again, thanks to Joe Perches for this.

This is my final answer!
Signed-off-by: default avatarJohn Daiker <daikerjohn@gmail.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent a66098da
......@@ -86,7 +86,7 @@ static int ray_debug;
static int pc_debug = PCMCIA_DEBUG;
module_param(pc_debug, int, 0);
/* #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args); */
#define DEBUG(n, args...) if (pc_debug>(n)) printk(args);
#define DEBUG(n, args...) if (pc_debug > (n)) printk(args);
#else
#define DEBUG(n, args...)
#endif
......@@ -109,10 +109,10 @@ 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,
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);
static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
UCHAR msg_type, unsigned char *data);
static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len);
static iw_stats * ray_get_wireless_stats(struct net_device * dev);
static iw_stats *ray_get_wireless_stats(struct net_device *dev);
static const struct iw_handler_def ray_handler_def;
/***** Prototypes for raylink functions **************************************/
......@@ -124,7 +124,7 @@ 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);
static int ray_hw_xmit(unsigned char* data, int len, struct net_device* dev, UCHAR type);
static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev, UCHAR type);
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);
......@@ -132,7 +132,7 @@ static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, i
static void verify_dl_startup(u_long);
/* Prototypes for interrpt time functions **********************************/
static irqreturn_t ray_interrupt (int reg, void *dev_id);
static irqreturn_t ray_interrupt(int reg, void *dev_id);
static void clear_interrupt(ray_dev_t *local);
static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
unsigned int pkt_addr, int rx_len);
......@@ -141,8 +141,8 @@ static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem
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,
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);
static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
unsigned int pkt_addr, int rx_len);
static void associate(ray_dev_t *local);
/* Card command functions */
......@@ -220,21 +220,21 @@ module_param(ray_mem_speed, int, 0);
static UCHAR b5_default_startup_parms[] = {
0, 0, /* Adhoc station */
'L','I','N','U','X', 0, 0, 0, /* 32 char ESSID */
'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*/
0x00, 0x80, /* Hop time 128 Kus */
0x01, 0x00, /* Beacon period 256 Kus */
0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout*/
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*/
0x08, 0x02, 0x08, /* adhoc, infra, super cycle max */
0, /* Promiscuous mode */
0x0c, 0x0bd, /* Unique word */
0x32, /* Slot time */
......@@ -255,7 +255,7 @@ static UCHAR b5_default_startup_parms[] = {
static UCHAR b4_default_startup_parms[] = {
0, 0, /* Adhoc station */
'L','I','N','U','X', 0, 0, 0, /* 32 char ESSID */
'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,
......@@ -264,15 +264,15 @@ static UCHAR b4_default_startup_parms[] = {
0x7f, 0xff, /* Frag threshold */
0x02, 0x00, /* Hop time */
0x00, 0x01, /* Beacon period */
0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout*/
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*/
0x04, 0x02, 0x4, /* adhoc, infra, super cycle max */
0, /* Promiscuous mode */
0x0c, 0x0bd, /* Unique word */
0x4e, /* Slot time (TBD seems wrong)*/
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 */
......@@ -281,10 +281,11 @@ static UCHAR b4_default_startup_parms[] = {
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, 2, 2 /* test mode, min, max */
};
/*===========================================================================*/
static unsigned char eth2_llc[] = {0xaa, 0xaa, 3, 0, 0, 0};
static unsigned char eth2_llc[] = { 0xaa, 0xaa, 3, 0, 0, 0 };
static char hop_pattern_length[] = { 1,
USA_HOP_MOD, EUROPE_HOP_MOD,
......@@ -294,7 +295,8 @@ static char hop_pattern_length[] = { 1,
JAPAN_TEST_HOP_MOD
};
static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.std.com>";
static char rcsid[] =
"Raylink/WebGear wireless LAN - Corey <Thomas corey@world.std.com>";
/*=============================================================================
ray_attach() creates an "instance" of the driver, allocating
......@@ -341,8 +343,8 @@ static int ray_probe(struct pcmcia_device *p_dev)
local->card_status = CARD_INSERTED;
local->authentication_state = UNAUTHENTICATED;
local->num_multi = 0;
DEBUG(2,"ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
p_dev,dev,local,&ray_interrupt);
DEBUG(2, "ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
p_dev, dev, local, &ray_interrupt);
/* Raylink entries in the device structure */
dev->hard_start_xmit = &ray_dev_start_xmit;
......@@ -357,7 +359,7 @@ static int ray_probe(struct pcmcia_device *p_dev)
dev->set_multicast_list = &set_multicast_list;
DEBUG(2,"ray_cs ray_attach calling ether_setup.)\n");
DEBUG(2, "ray_cs ray_attach calling ether_setup.)\n");
dev->init = &ray_dev_init;
dev->open = &ray_open;
dev->stop = &ray_dev_close;
......@@ -371,6 +373,7 @@ static int ray_probe(struct pcmcia_device *p_dev)
fail_alloc_dev:
return -ENOMEM;
} /* ray_attach */
/*=============================================================================
This deletes a driver "instance". The device is de-registered
with Card Services. If it has been released, all local data
......@@ -393,11 +396,13 @@ static void ray_detach(struct pcmcia_device *link)
del_timer(&local->timer);
if (link->priv) {
if (link->dev_node) unregister_netdev(dev);
if (link->dev_node)
unregister_netdev(dev);
free_netdev(dev);
}
DEBUG(2,"ray_cs ray_detach ending\n");
DEBUG(2, "ray_cs ray_detach ending\n");
} /* ray_detach */
/*=============================================================================
ray_config() is run after a CARD_INSERTION event
is received, to configure the PCMCIA socket, and to make the
......@@ -433,41 +438,50 @@ static int ray_config(struct pcmcia_device *link)
/* This actually configures the PCMCIA socket -- setting up
the I/O windows and the interrupt mapping.
*/
CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf));
CS_CHECK(RequestConfiguration,
pcmcia_request_configuration(link, &link->conf));
/*** Set up 32k window for shared memory (transmit and control) ************/
req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
req.Attributes =
WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
req.Base = 0;
req.Size = 0x8000;
req.AccessSpeed = ray_mem_speed;
CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win));
mem.CardOffset = 0x0000; mem.Page = 0;
mem.CardOffset = 0x0000;
mem.Page = 0;
CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
local->sram = ioremap(req.Base,req.Size);
local->sram = ioremap(req.Base, req.Size);
/*** Set up 16k window for shared memory (receive buffer) ***************/
req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
req.Attributes =
WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
req.Base = 0;
req.Size = 0x4000;
req.AccessSpeed = ray_mem_speed;
CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->rmem_handle));
mem.CardOffset = 0x8000; mem.Page = 0;
CS_CHECK(RequestWindow,
pcmcia_request_window(&link, &req, &local->rmem_handle));
mem.CardOffset = 0x8000;
mem.Page = 0;
CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem));
local->rmem = ioremap(req.Base,req.Size);
local->rmem = ioremap(req.Base, req.Size);
/*** Set up window for attribute memory ***********************************/
req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT;
req.Attributes =
WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT;
req.Base = 0;
req.Size = 0x1000;
req.AccessSpeed = ray_mem_speed;
CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->amem_handle));
mem.CardOffset = 0x0000; mem.Page = 0;
CS_CHECK(RequestWindow,
pcmcia_request_window(&link, &req, &local->amem_handle));
mem.CardOffset = 0x0000;
mem.Page = 0;
CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem));
local->amem = ioremap(req.Base,req.Size);
local->amem = ioremap(req.Base, req.Size);
DEBUG(3,"ray_config sram=%p\n",local->sram);
DEBUG(3,"ray_config rmem=%p\n",local->rmem);
DEBUG(3,"ray_config amem=%p\n",local->amem);
DEBUG(3, "ray_config sram=%p\n", local->sram);
DEBUG(3, "ray_config rmem=%p\n", local->rmem);
DEBUG(3, "ray_config amem=%p\n", local->amem);
if (ray_init(dev) < 0) {
ray_release(link);
return -ENODEV;
......@@ -523,7 +537,7 @@ static int ray_init(struct net_device *dev)
struct pcmcia_device *link = local->finder;
DEBUG(1, "ray_init(0x%p)\n", dev);
if (!(pcmcia_dev_present(link))) {
DEBUG(0,"ray_init - device not present\n");
DEBUG(0, "ray_init - device not present\n");
return -1;
}
......@@ -531,7 +545,7 @@ static int ray_init(struct net_device *dev)
local->sta_type = TYPE_STA;
/* Copy the startup results to local memory */
memcpy_fromio(&local->startup_res, local->sram + ECF_TO_HOST_BASE,\
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 */
......@@ -545,26 +559,24 @@ static int ray_init(struct net_device *dev)
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];
DEBUG(1,"ray_init firmware version %d.%d \n",local->fw_ver, local->fw_bld);
DEBUG(1, "ray_init firmware version %d.%d \n", local->fw_ver,
local->fw_bld);
local->tib_length = 0x20;
if ((local->fw_ver == 5) && (local->fw_bld >= 30))
local->tib_length = local->startup_res.tib_length;
DEBUG(2,"ray_init tib_length = 0x%02x\n", local->tib_length);
DEBUG(2, "ray_init tib_length = 0x%02x\n", local->tib_length);
/* Initialize CCS's to buffer free state */
pccs = ccs_base(local);
for (i=0; i<NUMBER_OF_CCS; i++) {
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))
{
if (parse_addr(phy_addr, local->sparm.b4.a_mac_addr)) {
p = local->sparm.b4.a_mac_addr;
}
else
{
} else {
memcpy(&local->sparm.b4.a_mac_addr,
&local->startup_res.station_addr, ADDRLEN);
p = local->sparm.b4.a_mac_addr;
......@@ -572,9 +584,10 @@ static int ray_init(struct net_device *dev)
clear_interrupt(local); /* Clear any interrupt from the card */
local->card_status = CARD_AWAITING_PARAM;
DEBUG(2,"ray_init ending\n");
DEBUG(2, "ray_init ending\n");
return 0;
} /* ray_init */
/*===========================================================================*/
/* Download startup parameters to the card and command it to read them */
static int dl_startup_params(struct net_device *dev)
......@@ -584,9 +597,9 @@ static int dl_startup_params(struct net_device *dev)
struct ccs __iomem *pccs;
struct pcmcia_device *link = local->finder;
DEBUG(1,"dl_startup_params entered\n");
DEBUG(1, "dl_startup_params entered\n");
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_cs dl_startup_params - device not present\n");
DEBUG(2, "ray_cs dl_startup_params - device not present\n");
return -1;
}
......@@ -598,13 +611,14 @@ static int dl_startup_params(struct net_device *dev)
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;
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);
DEBUG(2,"dl_startup_params start ccsindex = %d\n", local->dl_param_ccs);
DEBUG(2, "dl_startup_params start ccsindex = %d\n",
local->dl_param_ccs);
/* Interrupt the firmware to process the command */
if (interrupt_ecf(local, ccsindex)) {
printk(KERN_INFO "ray dl_startup_params failed - "
......@@ -615,21 +629,24 @@ static int dl_startup_params(struct net_device *dev)
}
local->card_status = CARD_DL_PARAM;
/* Start kernel timer to wait for dl startup to complete. */
local->timer.expires = jiffies + HZ/2;
local->timer.expires = jiffies + HZ / 2;
local->timer.data = (long)local;
local->timer.function = &verify_dl_startup;
add_timer(&local->timer);
DEBUG(2,"ray_cs dl_startup_params started timer for verify_dl_startup\n");
DEBUG(2,
"ray_cs dl_startup_params started timer for verify_dl_startup\n");
return 0;
} /* dl_startup_params */
/*===========================================================================*/
static void init_startup_params(ray_dev_t *local)
{
int i;
if (country > JAPAN_TEST) country = USA;
else
if (country < USA) country = USA;
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.
......@@ -641,9 +658,9 @@ static void init_startup_params(ray_dev_t *local)
*
* a_hop_time = uS a_hop_time = KuS
* a_beacon_period = hops a_beacon_period = KuS
*/ /* 64ms = 010000 */
*//* 64ms = 010000 */
if (local->fw_ver == 0x55) {
memcpy((UCHAR *)&local->sparm.b4, b4_default_startup_parms,
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 */
......@@ -652,23 +669,22 @@ static void init_startup_params(ray_dev_t *local)
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;
((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)
{
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,
} 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[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;
......@@ -683,100 +699,109 @@ static void init_startup_params(ray_dev_t *local)
if (essid != NULL)
strncpy(local->sparm.b4.a_current_ess_id, essid, ESSID_SIZE);
} /* init_startup_params */
/*===========================================================================*/
static void verify_dl_startup(u_long data)
{
ray_dev_t *local = (ray_dev_t *)data;
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;
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_cs verify_dl_startup - device not present\n");
DEBUG(2, "ray_cs verify_dl_startup - device not present\n");
return;
}
#ifdef PCMCIA_DEBUG
if (pc_debug > 2) {
int i;
printk(KERN_DEBUG "verify_dl_startup parameters sent via ccs %d:\n",
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));
for (i = 0; i < sizeof(struct b5_startup_params); i++) {
printk(" %2x",
(unsigned int)readb(local->sram +
HOST_TO_ECF_BASE + i));
}
printk("\n");
}
#endif
status = readb(&pccs->buffer_status);
if (status!= CCS_BUFFER_FREE)
{
printk(KERN_INFO "Download startup params failed. Status = %d\n",
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);
start_net((u_long) local);
else
join_net((u_long)local);
join_net((u_long) local);
return;
} /* end verify_dl_startup */
/*===========================================================================*/
/* Command card to start a network */
static void start_net(u_long data)
{
ray_dev_t *local = (ray_dev_t *)data;
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))) {
DEBUG(2,"ray_cs start_net - device not present\n");
DEBUG(2, "ray_cs start_net - device not present\n");
return;
}
/* Fill in the CCS fields for the ECF */
if ((ccsindex = get_free_ccs(local)) < 0) return;
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)) {
DEBUG(1,"ray start net failed - card not ready for intr\n");
DEBUG(1, "ray start net failed - card not ready for intr\n");
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
return;
}
local->card_status = CARD_DOING_ACQ;
return;
} /* end start_net */
/*===========================================================================*/
/* Command card to join a network */
static void join_net(u_long data)
{
ray_dev_t *local = (ray_dev_t *)data;
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))) {
DEBUG(2,"ray_cs join_net - device not present\n");
DEBUG(2, "ray_cs join_net - device not present\n");
return;
}
/* Fill in the CCS fields for the ECF */
if ((ccsindex = get_free_ccs(local)) < 0) return;
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)) {
DEBUG(1,"ray join net failed - card not ready for intr\n");
DEBUG(1, "ray join net failed - card not ready for intr\n");
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
return;
}
local->card_status = CARD_DOING_ACQ;
return;
}
/*============================================================================
After a card is removed, ray_release() will unregister the net
device, and release the PCMCIA configuration. If the device is
......@@ -797,12 +822,14 @@ static void ray_release(struct pcmcia_device *link)
iounmap(local->amem);
/* Do bother checking to see if these succeed or not */
i = pcmcia_release_window(local->amem_handle);
if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i);
if (i != 0)
DEBUG(0, "ReleaseWindow(local->amem) ret = %x\n", i);
i = pcmcia_release_window(local->rmem_handle);
if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i);
if (i != 0)
DEBUG(0, "ReleaseWindow(local->rmem) ret = %x\n", i);
pcmcia_disable_device(link);
DEBUG(2,"ray_release ending\n");
DEBUG(2, "ray_release ending\n");
}
static int ray_suspend(struct pcmcia_device *link)
......@@ -836,24 +863,24 @@ static int ray_dev_init(struct net_device *dev)
ray_dev_t *local = netdev_priv(dev);
struct pcmcia_device *link = local->finder;
DEBUG(1,"ray_dev_init(dev=%p)\n",dev);
DEBUG(1, "ray_dev_init(dev=%p)\n", dev);
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_dev_init - device not present\n");
DEBUG(2, "ray_dev_init - device not present\n");
return -1;
}
#ifdef RAY_IMMEDIATE_INIT
/* Download startup parameters */
if ( (i = dl_startup_params(dev)) < 0)
{
if ((i = dl_startup_params(dev)) < 0) {
printk(KERN_INFO "ray_dev_init dl_startup_params failed - "
"returns 0x%x\n",i);
"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 */
DEBUG(1,"ray_dev_init: postponing card init to ray_open() ; Status = %d\n",
DEBUG(1,
"ray_dev_init: postponing card init to ray_open() ; Status = %d\n",
local->card_status);
#endif /* RAY_IMMEDIATE_INIT */
......@@ -861,23 +888,25 @@ static int ray_dev_init(struct net_device *dev)
memcpy(&dev->dev_addr, &local->sparm.b4.a_mac_addr, ADDRLEN);
memset(dev->broadcast, 0xff, ETH_ALEN);
DEBUG(2,"ray_dev_init ending\n");
DEBUG(2, "ray_dev_init ending\n");
return 0;
}
/*===========================================================================*/
static int ray_dev_config(struct net_device *dev, struct ifmap *map)
{
ray_dev_t *local = netdev_priv(dev);
struct pcmcia_device *link = local->finder;
/* Dummy routine to satisfy device structure */
DEBUG(1,"ray_dev_config(dev=%p,ifmap=%p)\n",dev,map);
DEBUG(1, "ray_dev_config(dev=%p,ifmap=%p)\n", dev, map);
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_dev_config - device not present\n");
DEBUG(2, "ray_dev_config - device not present\n");
return -1;
}
return 0;
}
/*===========================================================================*/
static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
......@@ -886,26 +915,25 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
short length = skb->len;
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_dev_start_xmit - device not present\n");
DEBUG(2, "ray_dev_start_xmit - device not present\n");
return -1;
}
DEBUG(3,"ray_dev_start_xmit(skb=%p, dev=%p)\n",skb,dev);
DEBUG(3, "ray_dev_start_xmit(skb=%p, dev=%p)\n", skb, dev);
if (local->authentication_state == NEED_TO_AUTH) {
DEBUG(0,"ray_cs Sending authentication request.\n");
if (!build_auth_frame (local, local->auth_id, OPEN_AUTH_REQUEST)) {
DEBUG(0, "ray_cs Sending authentication request.\n");
if (!build_auth_frame(local, local->auth_id, OPEN_AUTH_REQUEST)) {
local->authentication_state = AUTHENTICATED;
netif_stop_queue(dev);
return 1;
}
}
if (length < ETH_ZLEN)
{
if (length < ETH_ZLEN) {
if (skb_padto(skb, ETH_ZLEN))
return 0;
length = ETH_ZLEN;
}
switch (ray_hw_xmit( skb->data, length, dev, DATA_TYPE)) {
switch (ray_hw_xmit(skb->data, length, dev, DATA_TYPE)) {
case XMIT_NO_CCS:
case XMIT_NEED_AUTH:
netif_stop_queue(dev);
......@@ -920,8 +948,9 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
}
return 0;
} /* ray_dev_start_xmit */
/*===========================================================================*/
static int ray_hw_xmit(unsigned char* data, int len, struct net_device* dev,
static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev,
UCHAR msg_type)
{
ray_dev_t *local = netdev_priv(dev);
......@@ -931,17 +960,17 @@ static int ray_hw_xmit(unsigned char* data, int len, struct net_device* dev,
struct tx_msg __iomem *ptx; /* Address of xmit buffer in PC space */
short int addr; /* Address of xmit buffer in card space */
DEBUG(3,"ray_hw_xmit(data=%p, len=%d, dev=%p)\n",data,len,dev);
if (len + TX_HEADER_LENGTH > TX_BUF_SIZE)
{
printk(KERN_INFO "ray_hw_xmit packet too large: %d bytes\n",len);
DEBUG(3, "ray_hw_xmit(data=%p, len=%d, dev=%p)\n", data, len, dev);
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;
}
switch (ccsindex = get_free_tx_ccs(local)) {
case ECCSBUSY:
DEBUG(2,"ray_hw_xmit tx_ccs table busy\n");
DEBUG(2, "ray_hw_xmit tx_ccs table busy\n");
case ECCSFULL:
DEBUG(2,"ray_hw_xmit No free tx ccs\n");
DEBUG(2, "ray_hw_xmit No free tx ccs\n");
case ECARDGONE:
netif_stop_queue(dev);
return XMIT_NO_CCS;
......@@ -960,8 +989,7 @@ static int ray_hw_xmit(unsigned char* data, int len, struct net_device* dev,
ray_build_header(local, ptx, msg_type, data);
if (translate) {
offset = translate_frame(local, ptx, data, len);
}
else { /* Encapsulate frame */
} else { /* Encapsulate frame */
/* TBD TIB length will move address of ptx->var */
memcpy_toio(&ptx->var, data, len);
offset = 0;
......@@ -979,12 +1007,12 @@ static int ray_hw_xmit(unsigned char* data, int len, struct net_device* dev,
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);
DEBUG(3,"ray_hw_xmit default_tx_rate = 0x%x\n",\
DEBUG(3, "ray_hw_xmit default_tx_rate = 0x%x\n",
local->net_default_tx_rate);
/* Interrupt the firmware to process the command */
if (interrupt_ecf(local, ccsindex)) {
DEBUG(2,"ray_hw_xmit failed - ECF not ready for intr\n");
DEBUG(2, "ray_hw_xmit failed - ECF not ready for intr\n");
/* 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?
......@@ -994,29 +1022,32 @@ static int ray_hw_xmit(unsigned char* data, int len, struct net_device* dev,
}
return XMIT_OK;
} /* end ray_hw_xmit */
/*===========================================================================*/
static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx, unsigned char *data,
int len)
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;
if (ntohs(proto) >= 1536) { /* DIX II ethernet frame */
DEBUG(3,"ray_cs translate_frame DIX II\n");
DEBUG(3, "ray_cs translate_frame DIX II\n");
/* 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);
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]);
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 */
DEBUG(3,"ray_cs translate_frame 802\n");
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 */
DEBUG(3, "ray_cs translate_frame 802\n");
if (proto == htons(0xffff)) { /* evil netware IPX 802.3 without LLC */
DEBUG(3,"ray_cs translate_frame evil IPX\n");
DEBUG(3, "ray_cs translate_frame evil IPX\n");
memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
return 0 - ETH_HLEN;
}
......@@ -1025,9 +1056,10 @@ static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx, unsigne
}
/* TBD do other frame types */
} /* end translate_frame */
/*===========================================================================*/
static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx, UCHAR msg_type,
unsigned char *data)
static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
UCHAR msg_type, unsigned char *data)
{
writeb(PROTOCOL_VER | msg_type, &ptx->mac.frame_ctl_1);
/*** IEEE 802.11 Address field assignments *************
......@@ -1039,29 +1071,30 @@ AP to AP 1 1 dest AP src AP dest source
*******************************************************/
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_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)
{
} 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_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 */
{
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);
memcpy_toio(ptx->mac.addr_2,
((struct ethhdr *)data)->h_source, ADDRLEN);
memcpy_toio(ptx->mac.addr_3,
((struct ethhdr *)data)->h_dest, ADDRLEN);
}
}
} /* end encapsulate_frame */
/*===========================================================================*/
static void netdev_get_drvinfo(struct net_device *dev,
......@@ -1081,9 +1114,7 @@ static const struct ethtool_ops netdev_ethtool_ops = {
* Wireless Handler : get protocol name
*/
static int ray_get_name(struct net_device *dev,
struct iw_request_info *info,
char *cwrq,
char *extra)
struct iw_request_info *info, char *cwrq, char *extra)
{
strcpy(cwrq, "IEEE 802.11-FH");
return 0;
......@@ -1095,14 +1126,13 @@ static int ray_get_name(struct net_device *dev,
*/
static int ray_set_freq(struct net_device *dev,
struct iw_request_info *info,
struct iw_freq *fwrq,
char *extra)
struct iw_freq *fwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
int err = -EINPROGRESS; /* Call commit handler */
/* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM)
if (local->card_status != CARD_AWAITING_PARAM)
return -EBUSY;
/* Setting by channel number */
......@@ -1120,8 +1150,7 @@ static int ray_set_freq(struct net_device *dev,
*/
static int ray_get_freq(struct net_device *dev,
struct iw_request_info *info,
struct iw_freq *fwrq,
char *extra)
struct iw_freq *fwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
......@@ -1136,22 +1165,21 @@ static int ray_get_freq(struct net_device *dev,
*/
static int ray_set_essid(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *dwrq,
char *extra)
struct iw_point *dwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
/* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM)
if (local->card_status != CARD_AWAITING_PARAM)
return -EBUSY;
/* Check if we asked for `any' */
if(dwrq->flags == 0) {
if (dwrq->flags == 0) {
/* Corey : can you do that ? */
return -EOPNOTSUPP;
} else {
/* Check the size of the string */
if(dwrq->length > IW_ESSID_MAX_SIZE) {
if (dwrq->length > IW_ESSID_MAX_SIZE) {
return -E2BIG;
}
......@@ -1169,8 +1197,7 @@ static int ray_set_essid(struct net_device *dev,
*/
static int ray_get_essid(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *dwrq,
char *extra)
struct iw_point *dwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
......@@ -1190,8 +1217,7 @@ static int ray_get_essid(struct net_device *dev,
*/
static int ray_get_wap(struct net_device *dev,
struct iw_request_info *info,
struct sockaddr *awrq,
char *extra)
struct sockaddr *awrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
......@@ -1207,25 +1233,24 @@ static int ray_get_wap(struct net_device *dev,
*/
static int ray_set_rate(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
struct iw_param *vwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
/* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM)
if (local->card_status != CARD_AWAITING_PARAM)
return -EBUSY;
/* Check if rate is in range */
if((vwrq->value != 1000000) && (vwrq->value != 2000000))
if ((vwrq->value != 1000000) && (vwrq->value != 2000000))
return -EINVAL;
/* Hack for 1.5 Mb/s instead of 2 Mb/s */
if((local->fw_ver == 0x55) && /* Please check */
if ((local->fw_ver == 0x55) && /* Please check */
(vwrq->value == 2000000))
local->net_default_tx_rate = 3;
else
local->net_default_tx_rate = vwrq->value/500000;
local->net_default_tx_rate = vwrq->value / 500000;
return 0;
}
......@@ -1236,12 +1261,11 @@ static int ray_set_rate(struct net_device *dev,
*/
static int ray_get_rate(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
struct iw_param *vwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
if(local->net_default_tx_rate == 3)
if (local->net_default_tx_rate == 3)
vwrq->value = 2000000; /* Hum... */
else
vwrq->value = local->net_default_tx_rate * 500000;
......@@ -1256,21 +1280,20 @@ static int ray_get_rate(struct net_device *dev,
*/
static int ray_set_rts(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
struct iw_param *vwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
int rthr = vwrq->value;
/* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM)
if (local->card_status != CARD_AWAITING_PARAM)
return -EBUSY;
/* if(wrq->u.rts.fixed == 0) we should complain */
if(vwrq->disabled)
if (vwrq->disabled)
rthr = 32767;
else {
if((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */
if ((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */
return -EINVAL;
}
local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF;
......@@ -1279,15 +1302,13 @@ static int ray_set_rts(struct net_device *dev,
return -EINPROGRESS; /* Call commit handler */
}
/*------------------------------------------------------------------*/
/*
* Wireless Handler : get RTS threshold
*/
static int ray_get_rts(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
struct iw_param *vwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
......@@ -1305,21 +1326,20 @@ static int ray_get_rts(struct net_device *dev,
*/
static int ray_set_frag(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
struct iw_param *vwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
int fthr = vwrq->value;
/* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM)
if (local->card_status != CARD_AWAITING_PARAM)
return -EBUSY;
/* if(wrq->u.frag.fixed == 0) should complain */
if(vwrq->disabled)
if (vwrq->disabled)
fthr = 32767;
else {
if((fthr < 256) || (fthr > 2347)) /* To check out ! */
if ((fthr < 256) || (fthr > 2347)) /* To check out ! */
return -EINVAL;
}
local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF;
......@@ -1334,8 +1354,7 @@ static int ray_set_frag(struct net_device *dev,
*/
static int ray_get_frag(struct net_device *dev,
struct iw_request_info *info,
struct iw_param *vwrq,
char *extra)
struct iw_param *vwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
......@@ -1352,23 +1371,20 @@ static int ray_get_frag(struct net_device *dev,
* Wireless Handler : set Mode of Operation
*/
static int ray_set_mode(struct net_device *dev,
struct iw_request_info *info,
__u32 *uwrq,
char *extra)
struct iw_request_info *info, __u32 *uwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
int err = -EINPROGRESS; /* Call commit handler */
char card_mode = 1;
/* Reject if card is already initialised */
if(local->card_status != CARD_AWAITING_PARAM)
if (local->card_status != CARD_AWAITING_PARAM)
return -EBUSY;
switch (*uwrq)
{
switch (*uwrq) {
case IW_MODE_ADHOC:
card_mode = 0;
// Fall through
/* Fall through */
case IW_MODE_INFRA:
local->sparm.b5.a_network_type = card_mode;
break;
......@@ -1384,13 +1400,11 @@ static int ray_set_mode(struct net_device *dev,
* Wireless Handler : get Mode of Operation
*/
static int ray_get_mode(struct net_device *dev,
struct iw_request_info *info,
__u32 *uwrq,
char *extra)
struct iw_request_info *info, __u32 *uwrq, char *extra)
{
ray_dev_t *local = netdev_priv(dev);
if(local->sparm.b5.a_network_type)
if (local->sparm.b5.a_network_type)
*uwrq = IW_MODE_INFRA;
else
*uwrq = IW_MODE_ADHOC;
......@@ -1404,12 +1418,11 @@ static int ray_get_mode(struct net_device *dev,
*/
static int ray_get_range(struct net_device *dev,
struct iw_request_info *info,
struct iw_point *dwrq,
char *extra)
struct iw_point *dwrq, char *extra)
{
struct iw_range *range = (struct iw_range *) extra;
struct iw_range *range = (struct iw_range *)extra;
memset((char *) range, 0, sizeof(struct iw_range));
memset((char *)range, 0, sizeof(struct iw_range));
/* Set the length (very important for backward compatibility) */
dwrq->length = sizeof(struct iw_range);
......@@ -1437,8 +1450,7 @@ static int ray_get_range(struct net_device *dev,
*/
static int ray_set_framing(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
char *extra)
union iwreq_data *wrqu, char *extra)
{
translate = *(extra); /* Set framing mode */
......@@ -1451,8 +1463,7 @@ static int ray_set_framing(struct net_device *dev,
*/
static int ray_get_framing(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
char *extra)
union iwreq_data *wrqu, char *extra)
{
*(extra) = translate;
......@@ -1465,8 +1476,7 @@ static int ray_get_framing(struct net_device *dev,
*/
static int ray_get_country(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu,
char *extra)
union iwreq_data *wrqu, char *extra)
{
*(extra) = country;
......@@ -1477,11 +1487,10 @@ static int ray_get_country(struct net_device *dev,
/*
* Commit handler : called after a bunch of SET operations
*/
static int ray_commit(struct net_device *dev,
struct iw_request_info *info, /* NULL */
static int ray_commit(struct net_device *dev, struct iw_request_info *info, /* NULL */
void *zwrq, /* NULL */
char *extra) /* NULL */
{
char *extra)
{ /* NULL */
return 0;
}
......@@ -1489,28 +1498,29 @@ static int ray_commit(struct net_device *dev,
/*
* Stats handler : return Wireless Stats
*/
static iw_stats * ray_get_wireless_stats(struct net_device * dev)
static iw_stats *ray_get_wireless_stats(struct net_device *dev)
{
ray_dev_t * local = netdev_priv(dev);
ray_dev_t *local = netdev_priv(dev);
struct pcmcia_device *link = local->finder;
struct status __iomem *p = local->sram + STATUS_BASE;
if(local == (ray_dev_t *) NULL)
if (local == (ray_dev_t *) NULL)
return (iw_stats *) NULL;
local->wstats.status = local->card_status;
#ifdef WIRELESS_SPY
if((local->spy_data.spy_number > 0) && (local->sparm.b5.a_network_type == 0))
{
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;
local->wstats.qual.updated =
local->spy_data.spy_stat[0].updated;
}
#endif /* WIRELESS_SPY */
if(pcmcia_dev_present(link)) {
if (pcmcia_dev_present(link)) {
local->wstats.qual.noise = readb(&p->rxnoise);
local->wstats.qual.updated |= 4;
}
......@@ -1524,28 +1534,28 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev)
*/
static const iw_handler ray_handler[] = {
[SIOCSIWCOMMIT-SIOCIWFIRST] = (iw_handler) ray_commit,
[SIOCGIWNAME -SIOCIWFIRST] = (iw_handler) ray_get_name,
[SIOCSIWFREQ -SIOCIWFIRST] = (iw_handler) ray_set_freq,
[SIOCGIWFREQ -SIOCIWFIRST] = (iw_handler) ray_get_freq,
[SIOCSIWMODE -SIOCIWFIRST] = (iw_handler) ray_set_mode,
[SIOCGIWMODE -SIOCIWFIRST] = (iw_handler) ray_get_mode,
[SIOCGIWRANGE -SIOCIWFIRST] = (iw_handler) ray_get_range,
[SIOCSIWCOMMIT - SIOCIWFIRST] = (iw_handler) ray_commit,
[SIOCGIWNAME - SIOCIWFIRST] = (iw_handler) ray_get_name,
[SIOCSIWFREQ - SIOCIWFIRST] = (iw_handler) ray_set_freq,
[SIOCGIWFREQ - SIOCIWFIRST] = (iw_handler) ray_get_freq,
[SIOCSIWMODE - SIOCIWFIRST] = (iw_handler) ray_set_mode,
[SIOCGIWMODE - SIOCIWFIRST] = (iw_handler) ray_get_mode,
[SIOCGIWRANGE - SIOCIWFIRST] = (iw_handler) ray_get_range,
#ifdef WIRELESS_SPY
[SIOCSIWSPY -SIOCIWFIRST] = (iw_handler) iw_handler_set_spy,
[SIOCGIWSPY -SIOCIWFIRST] = (iw_handler) iw_handler_get_spy,
[SIOCSIWTHRSPY-SIOCIWFIRST] = (iw_handler) iw_handler_set_thrspy,
[SIOCGIWTHRSPY-SIOCIWFIRST] = (iw_handler) iw_handler_get_thrspy,
[SIOCSIWSPY - SIOCIWFIRST] = (iw_handler) iw_handler_set_spy,
[SIOCGIWSPY - SIOCIWFIRST] = (iw_handler) iw_handler_get_spy,
[SIOCSIWTHRSPY - SIOCIWFIRST] = (iw_handler) iw_handler_set_thrspy,
[SIOCGIWTHRSPY - SIOCIWFIRST] = (iw_handler) iw_handler_get_thrspy,
#endif /* WIRELESS_SPY */
[SIOCGIWAP -SIOCIWFIRST] = (iw_handler) ray_get_wap,
[SIOCSIWESSID -SIOCIWFIRST] = (iw_handler) ray_set_essid,
[SIOCGIWESSID -SIOCIWFIRST] = (iw_handler) ray_get_essid,
[SIOCSIWRATE -SIOCIWFIRST] = (iw_handler) ray_set_rate,
[SIOCGIWRATE -SIOCIWFIRST] = (iw_handler) ray_get_rate,
[SIOCSIWRTS -SIOCIWFIRST] = (iw_handler) ray_set_rts,
[SIOCGIWRTS -SIOCIWFIRST] = (iw_handler) ray_get_rts,
[SIOCSIWFRAG -SIOCIWFIRST] = (iw_handler) ray_set_frag,
[SIOCGIWFRAG -SIOCIWFIRST] = (iw_handler) ray_get_frag,
[SIOCGIWAP - SIOCIWFIRST] = (iw_handler) ray_get_wap,
[SIOCSIWESSID - SIOCIWFIRST] = (iw_handler) ray_set_essid,
[SIOCGIWESSID - SIOCIWFIRST] = (iw_handler) ray_get_essid,
[SIOCSIWRATE - SIOCIWFIRST] = (iw_handler) ray_set_rate,
[SIOCGIWRATE - SIOCIWFIRST] = (iw_handler) ray_get_rate,
[SIOCSIWRTS - SIOCIWFIRST] = (iw_handler) ray_set_rts,
[SIOCGIWRTS - SIOCIWFIRST] = (iw_handler) ray_get_rts,
[SIOCSIWFRAG - SIOCIWFIRST] = (iw_handler) ray_set_frag,
[SIOCGIWFRAG - SIOCIWFIRST] = (iw_handler) ray_get_frag,
};
#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */
......@@ -1560,13 +1570,15 @@ static const iw_handler ray_private_handler[] = {
static const struct iw_priv_args ray_private_args[] = {
/* cmd, set_args, get_args, name */
{ 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" },
{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"},
};
static const struct iw_handler_def ray_handler_def =
{
static const struct iw_handler_def ray_handler_def = {
.num_standard = ARRAY_SIZE(ray_handler),
.num_private = ARRAY_SIZE(ray_private_handler),
.num_private_args = ARRAY_SIZE(ray_private_args),
......@@ -1590,26 +1602,29 @@ static int ray_open(struct net_device *dev)
link->open++;
/* If the card is not started, time to start it ! - Jean II */
if(local->card_status == CARD_AWAITING_PARAM) {
if (local->card_status == CARD_AWAITING_PARAM) {
int i;
DEBUG(1,"ray_open: doing init now !\n");
DEBUG(1, "ray_open: doing init now !\n");
/* 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);
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);
if (sniffer)
netif_stop_queue(dev);
else
netif_start_queue(dev);
DEBUG(2,"ray_open ending\n");
DEBUG(2, "ray_open ending\n");
return 0;
} /* end ray_open */
/*===========================================================================*/
static int ray_dev_close(struct net_device *dev)
{
......@@ -1629,11 +1644,14 @@ static int ray_dev_close(struct net_device *dev)
return 0;
} /* end ray_dev_close */
/*===========================================================================*/
static void ray_reset(struct net_device *dev) {
DEBUG(1,"ray_reset entered\n");
static void ray_reset(struct net_device *dev)
{
DEBUG(1, "ray_reset entered\n");
return;
}
/*===========================================================================*/
/* Cause a firmware interrupt if it is ready for one */
/* Return nonzero if not ready */
......@@ -1643,16 +1661,17 @@ static int interrupt_ecf(ray_dev_t *local, int ccs)
struct pcmcia_device *link = local->finder;
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_cs interrupt_ecf - device not present\n");
DEBUG(2, "ray_cs interrupt_ecf - device not present\n");
return -1;
}
DEBUG(2,"interrupt_ecf(local=%p, ccs = 0x%x\n",local,ccs);
DEBUG(2, "interrupt_ecf(local=%p, ccs = 0x%x\n", local, ccs);
while ( i &&
(readb(local->amem + CIS_OFFSET + ECF_INTR_OFFSET) & ECF_INTR_SET))
while (i &&
(readb(local->amem + CIS_OFFSET + ECF_INTR_OFFSET) &
ECF_INTR_SET))
i--;
if (i == 0) {
DEBUG(2,"ray_cs interrupt_ecf card not ready for interrupt\n");
DEBUG(2, "ray_cs interrupt_ecf card not ready for interrupt\n");
return -1;
}
/* Fill the mailbox, then kick the card */
......@@ -1660,6 +1679,7 @@ static int interrupt_ecf(ray_dev_t *local, int ccs)
writeb(ECF_INTR_SET, local->amem + CIS_OFFSET + ECF_INTR_OFFSET);
return 0;
} /* interrupt_ecf */
/*===========================================================================*/
/* Get next free transmit CCS */
/* Return - index of current tx ccs */
......@@ -1670,27 +1690,28 @@ static int get_free_tx_ccs(ray_dev_t *local)
struct pcmcia_device *link = local->finder;
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_cs get_free_tx_ccs - device not present\n");
DEBUG(2, "ray_cs get_free_tx_ccs - device not present\n");
return ECARDGONE;
}
if (test_and_set_bit(0,&local->tx_ccs_lock)) {
DEBUG(1,"ray_cs tx_ccs_lock busy\n");
if (test_and_set_bit(0, &local->tx_ccs_lock)) {
DEBUG(1, "ray_cs tx_ccs_lock busy\n");
return ECCSBUSY;
}
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);
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);
local->tx_ccs_lock = 0;
return i;
}
}
local->tx_ccs_lock = 0;
DEBUG(2,"ray_cs ERROR no free tx CCS for raylink card\n");
DEBUG(2, "ray_cs ERROR no free tx CCS for raylink card\n");
return ECCSFULL;
} /* get_free_tx_ccs */
/*===========================================================================*/
/* Get next free CCS */
/* Return - index of current ccs */
......@@ -1701,74 +1722,92 @@ static int get_free_ccs(ray_dev_t *local)
struct pcmcia_device *link = local->finder;
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_cs get_free_ccs - device not present\n");
DEBUG(2, "ray_cs get_free_ccs - device not present\n");
return ECARDGONE;
}
if (test_and_set_bit(0,&local->ccs_lock)) {
DEBUG(1,"ray_cs ccs_lock busy\n");
if (test_and_set_bit(0, &local->ccs_lock)) {
DEBUG(1, "ray_cs ccs_lock busy\n");
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);
if (readb(&(pccs + i)->buffer_status) == CCS_BUFFER_FREE) {
writeb(CCS_BUFFER_BUSY, &(pccs + i)->buffer_status);
writeb(CCS_END_LIST, &(pccs + i)->link);
local->ccs_lock = 0;
return i;
}
}
local->ccs_lock = 0;
DEBUG(1,"ray_cs ERROR no free CCS for raylink card\n");
DEBUG(1, "ray_cs ERROR no free CCS for raylink card\n");
return ECCSFULL;
} /* get_free_ccs */
/*===========================================================================*/
static void authenticate_timeout(u_long data)
{
ray_dev_t *local = (ray_dev_t *)data;
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);
join_net((u_long) local);
}
/*===========================================================================*/
static int asc_to_int(char a)
{
if (a < '0') return -1;
if (a <= '9') return (a - '0');
if (a < 'A') return -1;
if (a <= 'F') return (10 + a - 'A');
if (a < 'a') return -1;
if (a <= 'f') return (10 + a - 'a');
if (a < '0')
return -1;
if (a <= '9')
return (a - '0');
if (a < 'A')
return -1;
if (a <= 'F')
return (10 + a - 'A');
if (a < 'a')
return -1;
if (a <= 'f')
return (10 + a - 'a');
return -1;
}
/*===========================================================================*/
static int parse_addr(char *in_str, UCHAR *out)
{
int len;
int i,j,k;
int i, j, k;
int status;
if (in_str == NULL) return 0;
if ((len = strlen(in_str)) < 2) return 0;
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;
if (j > 12)
j = 12;
i = 5;
while (j > 0)
{
if ((k = asc_to_int(in_str[j--])) != -1) out[i] = k;
else return 0;
while (j > 0) {
if ((k = asc_to_int(in_str[j--])) != -1)
out[i] = k;
else
return 0;
if (j == 0) break;
if ((k = asc_to_int(in_str[j--])) != -1) out[i] += k << 4;
else return 0;
if (!i--) break;
if (j == 0)
break;
if ((k = asc_to_int(in_str[j--])) != -1)
out[i] += k << 4;
else
return 0;
if (!i--)
break;
}
return status;
}
/*===========================================================================*/
static struct net_device_stats *ray_get_stats(struct net_device *dev)
{
......@@ -1776,31 +1815,31 @@ static struct net_device_stats *ray_get_stats(struct net_device *dev)
struct pcmcia_device *link = local->finder;
struct status __iomem *p = local->sram + STATUS_BASE;
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_cs net_device_stats - device not present\n");
DEBUG(2, "ray_cs net_device_stats - device not present\n");
return &local->stats;
}
if (readb(&p->mrx_overflow_for_host))
{
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);
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->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))
{
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);
writeb(0, &p->rx_hec_error);
writeb(0, &p->rx_hec_error_for_host);
}
return &local->stats;
}
/*===========================================================================*/
static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len)
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;
......@@ -1809,13 +1848,12 @@ static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, i
struct ccs __iomem *pccs;
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_update_parm - device not present\n");
DEBUG(2, "ray_update_parm - device not present\n");
return;
}
if ((ccsindex = get_free_ccs(local)) < 0)
{
DEBUG(0,"ray_update_parm - No free ccs\n");
if ((ccsindex = get_free_ccs(local)) < 0) {
DEBUG(0, "ray_update_parm - No free ccs\n");
return;
}
pccs = ccs_base(local) + ccsindex;
......@@ -1823,15 +1861,16 @@ static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, i
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++) {
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)) {
DEBUG(0,"ray_cs associate failed - ECF not ready for intr\n");
DEBUG(0, "ray_cs associate failed - ECF not ready for intr\n");
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
}
}
/*===========================================================================*/
static void ray_update_multi_list(struct net_device *dev, int all)
{
......@@ -1844,14 +1883,12 @@ static void ray_update_multi_list(struct net_device *dev, int all)
void __iomem *p = local->sram + HOST_TO_ECF_BASE;
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_update_multi_list - device not present\n");
DEBUG(2, "ray_update_multi_list - device not present\n");
return;
}
else
DEBUG(2,"ray_update_multi_list(%p)\n",dev);
if ((ccsindex = get_free_ccs(local)) < 0)
{
DEBUG(1,"ray_update_multi - No free ccs\n");
} else
DEBUG(2, "ray_update_multi_list(%p)\n", dev);
if ((ccsindex = get_free_ccs(local)) < 0) {
DEBUG(1, "ray_update_multi - No free ccs\n");
return;
}
pccs = ccs_base(local) + ccsindex;
......@@ -1860,60 +1897,67 @@ static void ray_update_multi_list(struct net_device *dev, int all)
if (all) {
writeb(0xff, &pccs->var);
local->num_multi = 0xff;
}
else {
} else {
/* Copy the kernel's list of MC addresses to card */
for (dmip=&dev->mc_list; (dmi=*dmip)!=NULL; dmip=&dmi->next) {
for (dmip = &dev->mc_list; (dmi = *dmip) != NULL;
dmip = &dmi->next) {
memcpy_toio(p, dmi->dmi_addr, ETH_ALEN);
DEBUG(1,"ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n",dmi->dmi_addr[0],dmi->dmi_addr[1],dmi->dmi_addr[2],dmi->dmi_addr[3],dmi->dmi_addr[4],dmi->dmi_addr[5]);
DEBUG(1,
"ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n",
dmi->dmi_addr[0], dmi->dmi_addr[1],
dmi->dmi_addr[2], dmi->dmi_addr[3],
dmi->dmi_addr[4], dmi->dmi_addr[5]);
p += ETH_ALEN;
i++;
}
if (i > 256/ADDRLEN) i = 256/ADDRLEN;
writeb((UCHAR)i, &pccs->var);
DEBUG(1,"ray_cs update_multi %d addresses in list\n", i);
if (i > 256 / ADDRLEN)
i = 256 / ADDRLEN;
writeb((UCHAR) i, &pccs->var);
DEBUG(1, "ray_cs update_multi %d addresses in list\n", i);
/* Interrupt the firmware to process the command */
local->num_multi = i;
}
if (interrupt_ecf(local, ccsindex)) {
DEBUG(1,"ray_cs update_multi failed - ECF not ready for intr\n");
DEBUG(1,
"ray_cs update_multi failed - ECF not ready for intr\n");
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
}
} /* end ray_update_multi_list */
/*===========================================================================*/
static void set_multicast_list(struct net_device *dev)
{
ray_dev_t *local = netdev_priv(dev);
UCHAR promisc;
DEBUG(2,"ray_cs set_multicast_list(%p)\n",dev);
DEBUG(2, "ray_cs set_multicast_list(%p)\n", dev);
if (dev->flags & IFF_PROMISC)
{
if (dev->flags & IFF_PROMISC) {
if (local->sparm.b5.a_promiscuous_mode == 0) {
DEBUG(1,"ray_cs set_multicast_list promisc on\n");
DEBUG(1, "ray_cs set_multicast_list promisc on\n");
local->sparm.b5.a_promiscuous_mode = 1;
promisc = 1;
ray_update_parm(dev, OBJID_promiscuous_mode, \
ray_update_parm(dev, OBJID_promiscuous_mode,
&promisc, sizeof(promisc));
}
}
else {
} else {
if (local->sparm.b5.a_promiscuous_mode == 1) {
DEBUG(1,"ray_cs set_multicast_list promisc off\n");
DEBUG(1, "ray_cs set_multicast_list promisc off\n");
local->sparm.b5.a_promiscuous_mode = 0;
promisc = 0;
ray_update_parm(dev, OBJID_promiscuous_mode, \
ray_update_parm(dev, OBJID_promiscuous_mode,
&promisc, sizeof(promisc));
}
}
if (dev->flags & IFF_ALLMULTI) ray_update_multi_list(dev, 1);
else
{
if (local->num_multi != dev->mc_count) ray_update_multi_list(dev, 0);
if (dev->flags & IFF_ALLMULTI)
ray_update_multi_list(dev, 1);
else {
if (local->num_multi != dev->mc_count)
ray_update_multi_list(dev, 0);
}
} /* end set_multicast_list */
/*=============================================================================
* All routines below here are run at interrupt time.
=============================================================================*/
......@@ -1932,90 +1976,104 @@ static irqreturn_t ray_interrupt(int irq, void *dev_id)
if (dev == NULL) /* Note that we want interrupts with dev->start == 0 */
return IRQ_NONE;
DEBUG(4,"ray_cs: interrupt for *dev=%p\n",dev);
DEBUG(4, "ray_cs: interrupt for *dev=%p\n", dev);
local = netdev_priv(dev);
link = (struct pcmcia_device *)local->finder;
if (!pcmcia_dev_present(link)) {
DEBUG(2,"ray_cs interrupt from device not present or suspended.\n");
DEBUG(2,
"ray_cs interrupt from device not present or suspended.\n");
return IRQ_NONE;
}
rcsindex = readb(&((struct scb __iomem *)(local->sram))->rcs_index);
if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS))
{
DEBUG(1,"ray_cs interrupt bad rcsindex = 0x%x\n",rcsindex);
if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
DEBUG(1, "ray_cs interrupt bad rcsindex = 0x%x\n", rcsindex);
clear_interrupt(local);
return IRQ_HANDLED;
}
if (rcsindex < NUMBER_OF_CCS) /* If it's a returned CCS */
{
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)
{
switch (cmd) {
case CCS_DOWNLOAD_STARTUP_PARAMS: /* Happens in firmware someday */
del_timer(&local->timer);
if (status == CCS_COMMAND_COMPLETE) {
DEBUG(1,"ray_cs interrupt download_startup_parameters OK\n");
}
else {
DEBUG(1,"ray_cs interrupt download_startup_parameters fail\n");
DEBUG(1,
"ray_cs interrupt download_startup_parameters OK\n");
} else {
DEBUG(1,
"ray_cs interrupt download_startup_parameters fail\n");
}
break;
case CCS_UPDATE_PARAMS:
DEBUG(1,"ray_cs interrupt update params done\n");
DEBUG(1, "ray_cs interrupt update params done\n");
if (status != CCS_COMMAND_COMPLETE) {
tmp = readb(&pccs->var.update_param.failure_cause);
DEBUG(0,"ray_cs interrupt update params failed - reason %d\n",tmp);
tmp =
readb(&pccs->var.update_param.
failure_cause);
DEBUG(0,
"ray_cs interrupt update params failed - reason %d\n",
tmp);
}
break;
case CCS_REPORT_PARAMS:
DEBUG(1,"ray_cs interrupt report params done\n");
DEBUG(1, "ray_cs interrupt report params done\n");
break;
case CCS_UPDATE_MULTICAST_LIST: /* Note that this CCS isn't returned */
DEBUG(1,"ray_cs interrupt CCS Update Multicast List done\n");
DEBUG(1,
"ray_cs interrupt CCS Update Multicast List done\n");
break;
case CCS_UPDATE_POWER_SAVINGS_MODE:
DEBUG(1,"ray_cs interrupt update power save mode done\n");
DEBUG(1,
"ray_cs interrupt update power save mode done\n");
break;
case CCS_START_NETWORK:
case CCS_JOIN_NETWORK:
if (status == CCS_COMMAND_COMPLETE) {
if (readb(&pccs->var.start_network.net_initiated) == 1) {
DEBUG(0,"ray_cs interrupt network \"%s\" started\n",\
if (readb
(&pccs->var.start_network.net_initiated) ==
1) {
DEBUG(0,
"ray_cs interrupt network \"%s\" started\n",
local->sparm.b4.a_current_ess_id);
}
else {
DEBUG(0,"ray_cs interrupt network \"%s\" joined\n",\
} else {
DEBUG(0,
"ray_cs interrupt network \"%s\" joined\n",
local->sparm.b4.a_current_ess_id);
}
memcpy_fromio(&local->bss_id,pccs->var.start_network.bssid,ADDRLEN);
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 (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 {
} else {
local->card_status = CARD_ACQ_FAILED;
del_timer(&local->timer);
local->timer.expires = jiffies + HZ*5;
local->timer.expires = jiffies + HZ * 5;
local->timer.data = (long)local;
if (status == CCS_START_NETWORK) {
DEBUG(0,"ray_cs interrupt network \"%s\" start failed\n",\
DEBUG(0,
"ray_cs interrupt network \"%s\" start failed\n",
local->sparm.b4.a_current_ess_id);
local->timer.function = &start_net;
}
else {
DEBUG(0,"ray_cs interrupt network \"%s\" join failed\n",\
} else {
DEBUG(0,
"ray_cs interrupt network \"%s\" join failed\n",
local->sparm.b4.a_current_ess_id);
local->timer.function = &join_net;
}
......@@ -2025,78 +2083,86 @@ static irqreturn_t ray_interrupt(int irq, void *dev_id)
case CCS_START_ASSOCIATION:
if (status == CCS_COMMAND_COMPLETE) {
local->card_status = CARD_ASSOC_COMPLETE;
DEBUG(0,"ray_cs association successful\n");
}
else
{
DEBUG(0,"ray_cs association failed,\n");
DEBUG(0, "ray_cs association successful\n");
} else {
DEBUG(0, "ray_cs association failed,\n");
local->card_status = CARD_ASSOC_FAILED;
join_net((u_long)local);
join_net((u_long) local);
}
break;
case CCS_TX_REQUEST:
if (status == CCS_COMMAND_COMPLETE) {
DEBUG(3,"ray_cs interrupt tx request complete\n");
}
else {
DEBUG(1,"ray_cs interrupt tx request failed\n");
DEBUG(3,
"ray_cs interrupt tx request complete\n");
} else {
DEBUG(1,
"ray_cs interrupt tx request failed\n");
}
if (!sniffer) netif_start_queue(dev);
if (!sniffer)
netif_start_queue(dev);
netif_wake_queue(dev);
break;
case CCS_TEST_MEMORY:
DEBUG(1,"ray_cs interrupt mem test done\n");
DEBUG(1, "ray_cs interrupt mem test done\n");
break;
case CCS_SHUTDOWN:
DEBUG(1,"ray_cs interrupt Unexpected CCS returned - Shutdown\n");
DEBUG(1,
"ray_cs interrupt Unexpected CCS returned - Shutdown\n");
break;
case CCS_DUMP_MEMORY:
DEBUG(1,"ray_cs interrupt dump memory done\n");
DEBUG(1, "ray_cs interrupt dump memory done\n");
break;
case CCS_START_TIMER:
DEBUG(2,"ray_cs interrupt DING - raylink timer expired\n");
DEBUG(2,
"ray_cs interrupt DING - raylink timer expired\n");
break;
default:
DEBUG(1,"ray_cs interrupt Unexpected CCS 0x%x returned 0x%x\n",\
DEBUG(1,
"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 */
{
} else { /* It's an RCS */
prcs = rcs_base(local) + rcsindex;
switch (readb(&prcs->interrupt_id))
{
switch (readb(&prcs->interrupt_id)) {
case PROCESS_RX_PACKET:
ray_rx(dev, local, prcs);
break;
case REJOIN_NET_COMPLETE:
DEBUG(1,"ray_cs interrupt rejoin net complete\n");
DEBUG(1, "ray_cs interrupt rejoin net complete\n");
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);
DEBUG(1,"ray_cs new BSSID = %02x%02x%02x%02x%02x%02x\n",\
local->bss_id[0], local->bss_id[1], local->bss_id[2],\
local->bss_id[3], local->bss_id[4], local->bss_id[5]);
if (!sniffer) authenticate(local);
if (!sniffer)
netif_start_queue(dev);
} else {
memcpy_fromio(&local->bss_id,
prcs->var.rejoin_net_complete.
bssid, ADDRLEN);
DEBUG(1,
"ray_cs new BSSID = %02x%02x%02x%02x%02x%02x\n",
local->bss_id[0], local->bss_id[1],
local->bss_id[2], local->bss_id[3],
local->bss_id[4], local->bss_id[5]);
if (!sniffer)
authenticate(local);
}
break;
case ROAMING_INITIATED:
DEBUG(1,"ray_cs interrupt roaming initiated\n");
DEBUG(1, "ray_cs interrupt roaming initiated\n");
netif_stop_queue(dev);
local->card_status = CARD_DOING_ACQ;
break;
case JAPAN_CALL_SIGN_RXD:
DEBUG(1,"ray_cs interrupt japan call sign rx\n");
DEBUG(1, "ray_cs interrupt japan call sign rx\n");
break;
default:
DEBUG(1,"ray_cs Unexpected interrupt for RCS 0x%x cmd = 0x%x\n",\
rcsindex, (unsigned int) readb(&prcs->interrupt_id));
DEBUG(1,
"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);
......@@ -2104,13 +2170,15 @@ static irqreturn_t ray_interrupt(int irq, void *dev_id)
clear_interrupt(local);
return IRQ_HANDLED;
} /* ray_interrupt */
/*===========================================================================*/
static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem *prcs)
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;
DEBUG(4,"ray_rx process rx packet\n");
DEBUG(4, "ray_rx process rx packet\n");
/* Calculate address of packet within Rx buffer */
pkt_addr = ((readb(&prcs->var.rx_packet.rx_data_ptr[0]) << 8)
......@@ -2121,30 +2189,34 @@ static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem
local->last_rsl = readb(&prcs->var.rx_packet.rx_sig_lev);
pmsg = local->rmem + pkt_addr;
switch(readb(pmsg))
{
switch (readb(pmsg)) {
case DATA_TYPE:
DEBUG(4,"ray_rx data type\n");
DEBUG(4, "ray_rx data type\n");
rx_data(dev, prcs, pkt_addr, rx_len);
break;
case AUTHENTIC_TYPE:
DEBUG(4,"ray_rx authentic type\n");
if (sniffer) rx_data(dev, prcs, pkt_addr, rx_len);
else rx_authenticate(local, prcs, pkt_addr, rx_len);
DEBUG(4, "ray_rx authentic type\n");
if (sniffer)
rx_data(dev, prcs, pkt_addr, rx_len);
else
rx_authenticate(local, prcs, pkt_addr, rx_len);
break;
case DEAUTHENTIC_TYPE:
DEBUG(4,"ray_rx deauth type\n");
if (sniffer) rx_data(dev, prcs, pkt_addr, rx_len);
else rx_deauthenticate(local, prcs, pkt_addr, rx_len);
DEBUG(4, "ray_rx deauth type\n");
if (sniffer)
rx_data(dev, prcs, pkt_addr, rx_len);
else
rx_deauthenticate(local, prcs, pkt_addr, rx_len);
break;
case NULL_MSG_TYPE:
DEBUG(3,"ray_cs rx NULL msg\n");
DEBUG(3, "ray_cs rx NULL msg\n");
break;
case BEACON_TYPE:
DEBUG(4,"ray_rx beacon type\n");
if (sniffer) rx_data(dev, prcs, pkt_addr, rx_len);
DEBUG(4, "ray_rx beacon type\n");
if (sniffer)
rx_data(dev, prcs, pkt_addr, rx_len);
copy_from_rx_buff(local, (UCHAR *)&local->last_bcn, pkt_addr,
copy_from_rx_buff(local, (UCHAR *) &local->last_bcn, pkt_addr,
rx_len < sizeof(struct beacon_rx) ?
rx_len : sizeof(struct beacon_rx));
......@@ -2153,14 +2225,16 @@ static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem
ray_get_stats(dev);
break;
default:
DEBUG(0,"ray_cs unknown pkt type %2x\n", (unsigned int) readb(pmsg));
DEBUG(0, "ray_cs unknown pkt type %2x\n",
(unsigned int)readb(pmsg));
break;
}
} /* end ray_rx */
/*===========================================================================*/
static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, 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)
{
struct sk_buff *skb = NULL;
struct rcs __iomem *prcslink = prcs;
......@@ -2177,71 +2251,81 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned i
if (translate) {
/* TBD length needs fixing for translated header */
if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
rx_len > (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN + FCS_LEN))
{
DEBUG(0,"ray_cs invalid packet length %d received \n",rx_len);
rx_len >
(dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
FCS_LEN)) {
DEBUG(0,
"ray_cs invalid packet length %d received \n",
rx_len);
return;
}
}
else /* encapsulated ethernet */ {
} else { /* encapsulated ethernet */
if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
rx_len > (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN + FCS_LEN))
{
DEBUG(0,"ray_cs invalid packet length %d received \n",rx_len);
rx_len >
(dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
FCS_LEN)) {
DEBUG(0,
"ray_cs invalid packet length %d received \n",
rx_len);
return;
}
}
}
DEBUG(4,"ray_cs rx_data packet\n");
DEBUG(4, "ray_cs rx_data packet\n");
/* If fragmented packet, verify sizes of fragments add up */
if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
DEBUG(1,"ray_cs rx'ed fragment\n");
DEBUG(1, "ray_cs rx'ed fragment\n");
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)
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;
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)
{
DEBUG(0,"ray_cs rx_data fragment lengths don't add up\n");
if (tmp < 0) {
DEBUG(0,
"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 */
} else { /* Single unfragmented packet */
total_len = rx_len;
}
skb = dev_alloc_skb( total_len+5 );
if (skb == NULL)
{
DEBUG(0,"ray_cs rx_data could not allocate skb\n");
skb = dev_alloc_skb(total_len + 5);
if (skb == NULL) {
DEBUG(0, "ray_cs rx_data could not allocate skb\n");
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)*/
skb_reserve(skb, 2); /* Align IP on 16 byte (TBD check this) */
DEBUG(4,"ray_cs rx_data total_len = %x, rx_len = %x\n",total_len,rx_len);
DEBUG(4, "ray_cs rx_data total_len = %x, rx_len = %x\n", total_len,
rx_len);
/************************/
/* Reserve enough room for the whole damn packet. */
rx_ptr = skb_put( skb, total_len);
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);
rx_ptr +=
copy_from_rx_buff(local, rx_ptr, pkt_addr & RX_BUFF_END, rx_len);
/* Get source address */
#ifdef WIRELESS_SPY
skb_copy_from_linear_data_offset(skb, offsetof(struct mac_header, addr_2),
skb_copy_from_linear_data_offset(skb,
offsetof(struct mac_header, addr_2),
linksrcaddr, ETH_ALEN);
#endif
/* Now, deal with encapsulation/translation/sniffer */
......@@ -2249,40 +2333,46 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned i
if (!translate) {
/* Encapsulated ethernet, so just lop off 802.11 MAC header */
/* TBD reserve skb_reserve( skb, RX_MAC_HEADER_LENGTH); */
skb_pull( skb, RX_MAC_HEADER_LENGTH);
}
else {
skb_pull(skb, RX_MAC_HEADER_LENGTH);
} else {
/* Do translation */
untranslate(local, skb, total_len);
}
}
else
{ /* sniffer mode, so just pass whole packet */ };
} else { /* sniffer mode, so just pass whole packet */
};
/************************/
/* 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;
DEBUG(1,"ray_cs rx_data in fragment loop\n");
DEBUG(1, "ray_cs rx_data in fragment loop\n");
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]))
+
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)
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);
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);
readb(&prcslink->var.rx_packet.next_frag_rcs_index) !=
0xFF);
release_frag_chain(local, prcs);
}
skb->protocol = eth_type_trans(skb,dev);
skb->protocol = eth_type_trans(skb, dev);
netif_rx(skb);
local->stats.rx_packets++;
local->stats.rx_bytes += total_len;
......@@ -2292,8 +2382,7 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned i
/* 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))
{
if (!memcmp(linksrcaddr, local->bss_id, ETH_ALEN)) {
/* Update statistics */
/*local->wstats.qual.qual = none ? */
local->wstats.qual.level = siglev;
......@@ -2312,18 +2401,19 @@ static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned i
}
#endif /* WIRELESS_SPY */
} /* end rx_data */
/*===========================================================================*/
static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
{
snaphdr_t *psnap = (snaphdr_t *)(skb->data + RX_MAC_HEADER_LENGTH);
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;
__be16 type = *(__be16 *) psnap->ethertype;
int delta;
struct ethhdr *peth;
UCHAR srcaddr[ADDRLEN];
UCHAR destaddr[ADDRLEN];
static UCHAR org_bridge[3] = {0, 0, 0xf8};
static UCHAR org_1042[3] = {0, 0, 0};
static UCHAR org_bridge[3] = { 0, 0, 0xf8 };
static UCHAR org_1042[3] = { 0, 0, 0 };
memcpy(destaddr, ieee80211_get_DA(pmac), ADDRLEN);
memcpy(srcaddr, ieee80211_get_SA(pmac), ADDRLEN);
......@@ -2332,28 +2422,28 @@ static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
if (pc_debug > 3) {
int i;
printk(KERN_DEBUG "skb->data before untranslate");
for (i=0;i<64;i++)
printk("%02x ",skb->data[i]);
printk("\n" KERN_DEBUG "type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n",
ntohs(type),
psnap->dsap, psnap->ssap, psnap->ctrl,
for (i = 0; i < 64; i++)
printk("%02x ", skb->data[i]);
printk("\n" KERN_DEBUG
"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);
printk(KERN_DEBUG "untranslate skb->data = %p\n", skb->data);
}
#endif
if (psnap->dsap != 0xaa || psnap->ssap != 0xaa || psnap->ctrl != 3) {
/* not a snap type so leave it alone */
DEBUG(3,"ray_cs untranslate NOT SNAP %02x %02x %02x\n",
DEBUG(3, "ray_cs untranslate NOT SNAP %02x %02x %02x\n",
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 */
DEBUG(3,"ray_cs untranslate Bridge encap\n");
} else { /* Its a SNAP */
if (memcmp(psnap->org, org_bridge, 3) == 0) {
/* EtherII and nuke the LLC */
DEBUG(3, "ray_cs untranslate Bridge encap\n");
delta = RX_MAC_HEADER_LENGTH
+ sizeof(struct snaphdr_t) - ETH_HLEN;
peth = (struct ethhdr *)(skb->data + delta);
......@@ -2362,13 +2452,14 @@ static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
switch (ntohs(type)) {
case ETH_P_IPX:
case ETH_P_AARP:
DEBUG(3,"ray_cs untranslate RFC IPX/AARP\n");
DEBUG(3, "ray_cs untranslate RFC IPX/AARP\n");
delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
peth = (struct ethhdr *)(skb->data + delta);
peth->h_proto = htons(len - RX_MAC_HEADER_LENGTH);
peth->h_proto =
htons(len - RX_MAC_HEADER_LENGTH);
break;
default:
DEBUG(3,"ray_cs untranslate RFC default\n");
DEBUG(3, "ray_cs untranslate RFC default\n");
delta = RX_MAC_HEADER_LENGTH +
sizeof(struct snaphdr_t) - ETH_HLEN;
peth = (struct ethhdr *)(skb->data + delta);
......@@ -2384,41 +2475,45 @@ static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
}
/* TBD reserve skb_reserve(skb, delta); */
skb_pull(skb, delta);
DEBUG(3,"untranslate after skb_pull(%d), skb->data = %p\n",delta,skb->data);
DEBUG(3, "untranslate after skb_pull(%d), skb->data = %p\n", delta,
skb->data);
memcpy(peth->h_dest, destaddr, ADDRLEN);
memcpy(peth->h_source, srcaddr, ADDRLEN);
#ifdef PCMCIA_DEBUG
if (pc_debug > 3) {
int i;
printk(KERN_DEBUG "skb->data after untranslate:");
for (i=0;i<64;i++)
printk("%02x ",skb->data[i]);
for (i = 0; i < 64; i++)
printk("%02x ", skb->data[i]);
printk("\n");
}
#endif
} /* end untranslate */
/*===========================================================================*/
/* 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
*/
static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr, int length)
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);
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;
}
/*===========================================================================*/
static void release_frag_chain(ray_dev_t *local, struct rcs __iomem * prcs)
static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs)
{
struct rcs __iomem *prcslink = prcs;
int tmp = 17;
......@@ -2427,7 +2522,8 @@ static void release_frag_chain(ray_dev_t *local, struct rcs __iomem * prcs)
while (tmp--) {
writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
DEBUG(1,"ray_cs interrupt bad rcsindex = 0x%x\n",rcsindex);
DEBUG(1, "ray_cs interrupt bad rcsindex = 0x%x\n",
rcsindex);
break;
}
prcslink = rcs_base(local) + rcsindex;
......@@ -2435,28 +2531,29 @@ static void release_frag_chain(ray_dev_t *local, struct rcs __iomem * prcs)
}
writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
}
/*===========================================================================*/
static void authenticate(ray_dev_t *local)
{
struct pcmcia_device *link = local->finder;
DEBUG(0,"ray_cs Starting authentication.\n");
DEBUG(0, "ray_cs Starting authentication.\n");
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_cs authenticate - device not present\n");
DEBUG(2, "ray_cs authenticate - device not present\n");
return;
}
del_timer(&local->timer);
if (build_auth_frame(local, local->bss_id, OPEN_AUTH_REQUEST)) {
local->timer.function = &join_net;
}
else {
} else {
local->timer.function = &authenticate_timeout;
}
local->timer.expires = jiffies + HZ*2;
local->timer.expires = jiffies + HZ * 2;
local->timer.data = (long)local;
add_timer(&local->timer);
local->authentication_state = AWAITING_RESPONSE;
} /* end authenticate */
/*===========================================================================*/
static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
unsigned int pkt_addr, int rx_len)
......@@ -2469,37 +2566,42 @@ static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
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) {
DEBUG(1,"ray_cs rx_auth var= %02x %02x %02x %02x %02x %02x\n", msg->var[0],msg->var[1],msg->var[2],msg->var[3],msg->var[4],msg->var[5]);
DEBUG(1, "ray_cs rx_auth var= %02x %02x %02x %02x %02x %02x\n",
msg->var[0], msg->var[1], msg->var[2], msg->var[3],
msg->var[4], msg->var[5]);
if (msg->var[2] == 1) {
DEBUG(0,"ray_cs Sending authentication response.\n");
if (!build_auth_frame (local, msg->mac.addr_2, OPEN_AUTH_RESPONSE)) {
DEBUG(0, "ray_cs Sending authentication response.\n");
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);
memcpy(local->auth_id, msg->mac.addr_2,
ADDRLEN);
}
}
}
else /* Infrastructure network */
{
} 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) {
DEBUG(1,"Authentication successful\n");
DEBUG(1, "Authentication successful\n");
local->card_status = CARD_AUTH_COMPLETE;
associate(local);
local->authentication_state = AUTHENTICATED;
}
else {
DEBUG(0,"Authentication refused\n");
local->authentication_state =
AUTHENTICATED;
} else {
DEBUG(0, "Authentication refused\n");
local->card_status = CARD_AUTH_REFUSED;
join_net((u_long)local);
local->authentication_state = UNAUTHENTICATED;
join_net((u_long) local);
local->authentication_state =
UNAUTHENTICATED;
}
}
}
}
} /* end rx_authenticate */
/*===========================================================================*/
static void associate(ray_dev_t *local)
{
......@@ -2508,36 +2610,37 @@ static void associate(ray_dev_t *local)
struct net_device *dev = link->priv;
int ccsindex;
if (!(pcmcia_dev_present(link))) {
DEBUG(2,"ray_cs associate - device not present\n");
DEBUG(2, "ray_cs associate - device not present\n");
return;
}
/* If no tx buffers available, return*/
if ((ccsindex = get_free_ccs(local)) < 0)
{
/* If no tx buffers available, return */
if ((ccsindex = get_free_ccs(local)) < 0) {
/* TBD should never be here but... what if we are? */
DEBUG(1,"ray_cs associate - No free ccs\n");
DEBUG(1, "ray_cs associate - No free ccs\n");
return;
}
DEBUG(1,"ray_cs Starting association with access point\n");
DEBUG(1, "ray_cs Starting association with access point\n");
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)) {
DEBUG(1,"ray_cs associate failed - ECF not ready for intr\n");
DEBUG(1, "ray_cs associate failed - ECF not ready for intr\n");
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
del_timer(&local->timer);
local->timer.expires = jiffies + HZ*2;
local->timer.expires = jiffies + HZ * 2;
local->timer.data = (long)local;
local->timer.function = &join_net;
add_timer(&local->timer);
local->card_status = CARD_ASSOC_FAILED;
return;
}
if (!sniffer) netif_start_queue(dev);
if (!sniffer)
netif_start_queue(dev);
} /* end associate */
/*===========================================================================*/
static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
unsigned int pkt_addr, int rx_len)
......@@ -2545,17 +2648,19 @@ static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
/* UCHAR buff[256];
struct rx_msg *msg = (struct rx_msg *)buff;
*/
DEBUG(0,"Deauthentication frame received\n");
DEBUG(0, "Deauthentication frame received\n");
local->authentication_state = UNAUTHENTICATED;
/* Need to reauthenticate or rejoin depending on reason code */
/* copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
*/
}
/*===========================================================================*/
static void clear_interrupt(ray_dev_t *local)
{
writeb(0, local->amem + CIS_OFFSET + HCS_INTR_OFFSET);
}
/*===========================================================================*/
#ifdef CONFIG_PROC_FS
#define MAXDATA (PAGE_SIZE - 80)
......@@ -2577,8 +2682,9 @@ static char *card_status[] = {
"Association failed" /* 16 */
};
static char *nettype[] = {"Adhoc", "Infra "};
static char *framing[] = {"Encapsulation", "Translation"}
static char *nettype[] = { "Adhoc", "Infra " };
static char *framing[] = { "Encapsulation", "Translation" }
;
/*===========================================================================*/
static int ray_cs_proc_show(struct seq_file *m, void *v)
......@@ -2614,7 +2720,8 @@ static int ray_cs_proc_show(struct seq_file *m, void *v)
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];
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);
......@@ -2626,11 +2733,13 @@ static int ray_cs_proc_show(struct seq_file *m, void *v)
local->sparm.b5.a_curr_country_code);
i = local->card_status;
if (i < 0) i = 10;
if (i > 16) i = 10;
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, "Framing mode = %s\n", framing[translate]);
seq_printf(m, "Last pkt signal lvl = %d\n", local->last_rsl);
......@@ -2641,20 +2750,22 @@ static int ray_cs_proc_show(struct seq_file *m, void *v)
+ 256 * local->last_bcn.beacon_intvl[1]);
p = local->last_bcn.elements;
if (p[0] == C_ESSID_ELEMENT_ID) p += p[1] + 2;
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]);
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++)
for (i = 2; i < p[1] + 2; i++)
seq_printf(m, "0x%02x ", p[i]);
seq_putc(m, '\n');
p += p[1] + 2;
}
else {
} else {
seq_puts(m, "Parse beacon failed at rates element\n");
return 0;
}
......@@ -2662,14 +2773,18 @@ static int ray_cs_proc_show(struct seq_file *m, void *v)
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]);
seq_printf(m, "Hop set = %d \n", pfh->hop_set);
seq_printf(m, "Hop pattern = %d \n", pfh->hop_pattern);
seq_printf(m, "Hop index = %d \n", pfh->hop_index);
pfh->dwell_time[0] +
256 * pfh->dwell_time[1]);
seq_printf(m, "Hop set = %d \n",
pfh->hop_set);
seq_printf(m, "Hop pattern = %d \n",
pfh->hop_pattern);
seq_printf(m, "Hop index = %d \n",
pfh->hop_index);
p += p[1] + 2;
}
else {
seq_puts(m, "Parse beacon failed at FH param element\n");
} else {
seq_puts(m,
"Parse beacon failed at FH param element\n");
return 0;
}
} else {
......@@ -2700,9 +2815,8 @@ static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
int ccsindex;
/* If no tx buffers available, return */
if ((ccsindex = get_free_tx_ccs(local)) < 0)
{
DEBUG(1,"ray_cs send authenticate - No free tx ccs\n");
if ((ccsindex = get_free_tx_ccs(local)) < 0) {
DEBUG(1, "ray_cs send authenticate - No free tx ccs\n");
return -1;
}
......@@ -2715,7 +2829,8 @@ static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
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(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;
......@@ -2733,7 +2848,8 @@ static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
/* Interrupt the firmware to process the command */
if (interrupt_ecf(local, ccsindex)) {
DEBUG(1,"ray_cs send authentication request failed - ECF not ready for intr\n");
DEBUG(1,
"ray_cs send authentication request failed - ECF not ready for intr\n");
writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
return -1;
}
......@@ -2744,14 +2860,16 @@ static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
#ifdef CONFIG_PROC_FS
static void raycs_write(const char *name, write_proc_t *w, void *data)
{
struct proc_dir_entry * entry = create_proc_entry(name, S_IFREG | S_IWUSR, NULL);
struct proc_dir_entry *entry =
create_proc_entry(name, S_IFREG | S_IWUSR, NULL);
if (entry) {
entry->write_proc = w;
entry->data = data;
}
}
static int write_essid(struct file *file, const char __user *buffer, unsigned long count, void *data)
static int write_essid(struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
static char proc_essid[33];
int len = count;
......@@ -2765,7 +2883,8 @@ static int write_essid(struct file *file, const char __user *buffer, unsigned lo
return count;
}
static int write_int(struct file *file, const char __user *buffer, unsigned long count, void *data)
static int write_int(struct file *file, const char __user *buffer,
unsigned long count, void *data)
{
static char proc_number[10];
char *p;
......@@ -2785,7 +2904,7 @@ static int write_int(struct file *file, const char __user *buffer, unsigned long
unsigned int c = *p - '0';
if (c > 9)
return -EINVAL;
nr = nr*10 + c;
nr = nr * 10 + c;
p++;
} while (--len);
*(int *)data = nr;
......@@ -2797,6 +2916,7 @@ static struct pcmcia_device_id ray_ids[] = {
PCMCIA_DEVICE_MANF_CARD(0x01a6, 0x0000),
PCMCIA_DEVICE_NULL,
};
MODULE_DEVICE_TABLE(pcmcia, ray_ids);
static struct pcmcia_driver ray_driver = {
......@@ -2817,7 +2937,8 @@ static int __init init_ray_cs(void)
DEBUG(1, "%s\n", rcsid);
rc = pcmcia_register_driver(&ray_driver);
DEBUG(1, "raylink init_module register_pcmcia_driver returns 0x%x\n",rc);
DEBUG(1, "raylink init_module register_pcmcia_driver returns 0x%x\n",
rc);
#ifdef CONFIG_PROC_FS
proc_mkdir("driver/ray_cs", NULL);
......@@ -2827,7 +2948,8 @@ static int __init init_ray_cs(void)
raycs_write("driver/ray_cs/net_type", write_int, &net_type);
raycs_write("driver/ray_cs/translate", write_int, &translate);
#endif
if (translate != 0) translate = 1;
if (translate != 0)
translate = 1;
return 0;
} /* init_ray_cs */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment