aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ray_cs.c
diff options
context:
space:
mode:
authorJohn Daiker <daikerjohn@gmail.com>2009-03-10 09:59:54 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-03-16 18:09:43 -0400
commit141fa61f10c419cb9b47a042eed79df621db75c6 (patch)
tree1c1a63d4a9968d968639312ee8e62183db7d745e /drivers/net/wireless/ray_cs.c
parenta66098daacee2f354dab311b58011e7076aa248c (diff)
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: John Daiker <daikerjohn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ray_cs.c')
-rw-r--r--drivers/net/wireless/ray_cs.c3808
1 files changed, 1965 insertions, 1843 deletions
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
index 99ec7d622518..7370edb4e0ce 100644
--- a/drivers/net/wireless/ray_cs.c
+++ b/drivers/net/wireless/ray_cs.c
@@ -8,7 +8,7 @@
8 * Copyright (c) 1998 Corey Thomas (corey@world.std.com) 8 * Copyright (c) 1998 Corey Thomas (corey@world.std.com)
9 * 9 *
10 * This driver is free software; you can redistribute it and/or modify 10 * This driver is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 only of the GNU General Public License as 11 * it under the terms of version 2 only of the GNU General Public License as
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 * 13 *
14 * It is distributed in the hope that it will be useful, 14 * It is distributed in the hope that it will be useful,
@@ -27,7 +27,7 @@
27 * 27 *
28 * Daniele Bellucci <bellucda@tiscali.it> - 07/10/2003 28 * Daniele Bellucci <bellucda@tiscali.it> - 07/10/2003
29 * - Audit copy_to_user in ioctl(SIOCGIWESSID) 29 * - Audit copy_to_user in ioctl(SIOCGIWESSID)
30 * 30 *
31=============================================================================*/ 31=============================================================================*/
32 32
33#include <linux/module.h> 33#include <linux/module.h>
@@ -65,8 +65,8 @@
65/* Warning : these stuff will slow down the driver... */ 65/* Warning : these stuff will slow down the driver... */
66#define WIRELESS_SPY /* Enable spying addresses */ 66#define WIRELESS_SPY /* Enable spying addresses */
67/* Definitions we need for spy */ 67/* Definitions we need for spy */
68typedef struct iw_statistics iw_stats; 68typedef struct iw_statistics iw_stats;
69typedef u_char mac_addr[ETH_ALEN]; /* Hardware address */ 69typedef u_char mac_addr[ETH_ALEN]; /* Hardware address */
70 70
71#include "rayctl.h" 71#include "rayctl.h"
72#include "ray_cs.h" 72#include "ray_cs.h"
@@ -86,7 +86,7 @@ static int ray_debug;
86static int pc_debug = PCMCIA_DEBUG; 86static int pc_debug = PCMCIA_DEBUG;
87module_param(pc_debug, int, 0); 87module_param(pc_debug, int, 0);
88/* #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args); */ 88/* #define DEBUG(n, args...) if (pc_debug>(n)) printk(KERN_DEBUG args); */
89#define DEBUG(n, args...) if (pc_debug>(n)) printk(args); 89#define DEBUG(n, args...) if (pc_debug > (n)) printk(args);
90#else 90#else
91#define DEBUG(n, args...) 91#define DEBUG(n, args...)
92#endif 92#endif
@@ -108,12 +108,12 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev);
108static void set_multicast_list(struct net_device *dev); 108static void set_multicast_list(struct net_device *dev);
109static void ray_update_multi_list(struct net_device *dev, int all); 109static void ray_update_multi_list(struct net_device *dev, int all);
110static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx, 110static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
111 unsigned char *data, int len); 111 unsigned char *data, int len);
112static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx, UCHAR msg_type, 112static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
113 unsigned char *data); 113 UCHAR msg_type, unsigned char *data);
114static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len); 114static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len);
115static iw_stats * ray_get_wireless_stats(struct net_device * dev); 115static iw_stats *ray_get_wireless_stats(struct net_device *dev);
116static const struct iw_handler_def ray_handler_def; 116static const struct iw_handler_def ray_handler_def;
117 117
118/***** Prototypes for raylink functions **************************************/ 118/***** Prototypes for raylink functions **************************************/
119static int asc_to_int(char a); 119static int asc_to_int(char a);
@@ -124,7 +124,7 @@ static int get_free_ccs(ray_dev_t *local);
124static int get_free_tx_ccs(ray_dev_t *local); 124static int get_free_tx_ccs(ray_dev_t *local);
125static void init_startup_params(ray_dev_t *local); 125static void init_startup_params(ray_dev_t *local);
126static int parse_addr(char *in_str, UCHAR *out); 126static int parse_addr(char *in_str, UCHAR *out);
127static int ray_hw_xmit(unsigned char* data, int len, struct net_device* dev, UCHAR type); 127static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev, UCHAR type);
128static int ray_init(struct net_device *dev); 128static int ray_init(struct net_device *dev);
129static int interrupt_ecf(ray_dev_t *local, int ccs); 129static int interrupt_ecf(ray_dev_t *local, int ccs);
130static void ray_reset(struct net_device *dev); 130static void ray_reset(struct net_device *dev);
@@ -132,17 +132,17 @@ static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, i
132static void verify_dl_startup(u_long); 132static void verify_dl_startup(u_long);
133 133
134/* Prototypes for interrpt time functions **********************************/ 134/* Prototypes for interrpt time functions **********************************/
135static irqreturn_t ray_interrupt (int reg, void *dev_id); 135static irqreturn_t ray_interrupt(int reg, void *dev_id);
136static void clear_interrupt(ray_dev_t *local); 136static void clear_interrupt(ray_dev_t *local);
137static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs, 137static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
138 unsigned int pkt_addr, int rx_len); 138 unsigned int pkt_addr, int rx_len);
139static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr, int len); 139static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr, int len);
140static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem *prcs); 140static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem *prcs);
141static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs); 141static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs);
142static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs, 142static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
143 unsigned int pkt_addr, int rx_len); 143 unsigned int pkt_addr, int rx_len);
144static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned int pkt_addr, 144static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
145 int rx_len); 145 unsigned int pkt_addr, int rx_len);
146static void associate(ray_dev_t *local); 146static void associate(ray_dev_t *local);
147 147
148/* Card command functions */ 148/* Card command functions */
@@ -219,82 +219,84 @@ module_param(phy_addr, charp, 0);
219module_param(ray_mem_speed, int, 0); 219module_param(ray_mem_speed, int, 0);
220 220
221static UCHAR b5_default_startup_parms[] = { 221static UCHAR b5_default_startup_parms[] = {
222 0, 0, /* Adhoc station */ 222 0, 0, /* Adhoc station */
223 'L','I','N','U','X', 0, 0, 0, /* 32 char ESSID */ 223 'L', 'I', 'N', 'U', 'X', 0, 0, 0, /* 32 char ESSID */
224 0, 0, 0, 0, 0, 0, 0, 0, 224 0, 0, 0, 0, 0, 0, 0, 0,
225 0, 0, 0, 0, 0, 0, 0, 0, 225 0, 0, 0, 0, 0, 0, 0, 0,
226 0, 0, 0, 0, 0, 0, 0, 0, 226 0, 0, 0, 0, 0, 0, 0, 0,
227 1, 0, /* Active scan, CA Mode */ 227 1, 0, /* Active scan, CA Mode */
228 0, 0, 0, 0, 0, 0, /* No default MAC addr */ 228 0, 0, 0, 0, 0, 0, /* No default MAC addr */
229 0x7f, 0xff, /* Frag threshold */ 229 0x7f, 0xff, /* Frag threshold */
230 0x00, 0x80, /* Hop time 128 Kus*/ 230 0x00, 0x80, /* Hop time 128 Kus */
231 0x01, 0x00, /* Beacon period 256 Kus */ 231 0x01, 0x00, /* Beacon period 256 Kus */
232 0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout*/ 232 0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout */
233 0x1d, 0x82, 0x4e, /* SIFS, DIFS, PIFS */ 233 0x1d, 0x82, 0x4e, /* SIFS, DIFS, PIFS */
234 0x7f, 0xff, /* RTS threshold */ 234 0x7f, 0xff, /* RTS threshold */
235 0x04, 0xe2, 0x38, 0xA4, /* scan_dwell, max_scan_dwell */ 235 0x04, 0xe2, 0x38, 0xA4, /* scan_dwell, max_scan_dwell */
236 0x05, /* assoc resp timeout thresh */ 236 0x05, /* assoc resp timeout thresh */
237 0x08, 0x02, 0x08, /* adhoc, infra, super cycle max*/ 237 0x08, 0x02, 0x08, /* adhoc, infra, super cycle max */
238 0, /* Promiscuous mode */ 238 0, /* Promiscuous mode */
239 0x0c, 0x0bd, /* Unique word */ 239 0x0c, 0x0bd, /* Unique word */
240 0x32, /* Slot time */ 240 0x32, /* Slot time */
241 0xff, 0xff, /* roam-low snr, low snr count */ 241 0xff, 0xff, /* roam-low snr, low snr count */
242 0x05, 0xff, /* Infra, adhoc missed bcn thresh */ 242 0x05, 0xff, /* Infra, adhoc missed bcn thresh */
243 0x01, 0x0b, 0x4f, /* USA, hop pattern, hop pat length */ 243 0x01, 0x0b, 0x4f, /* USA, hop pattern, hop pat length */
244/* b4 - b5 differences start here */ 244/* b4 - b5 differences start here */
245 0x00, 0x3f, /* CW max */ 245 0x00, 0x3f, /* CW max */
246 0x00, 0x0f, /* CW min */ 246 0x00, 0x0f, /* CW min */
247 0x04, 0x08, /* Noise gain, limit offset */ 247 0x04, 0x08, /* Noise gain, limit offset */
248 0x28, 0x28, /* det rssi, med busy offsets */ 248 0x28, 0x28, /* det rssi, med busy offsets */
249 7, /* det sync thresh */ 249 7, /* det sync thresh */
250 0, 2, 2, /* test mode, min, max */ 250 0, 2, 2, /* test mode, min, max */
251 0, /* allow broadcast SSID probe resp */ 251 0, /* allow broadcast SSID probe resp */
252 0, 0, /* privacy must start, can join */ 252 0, 0, /* privacy must start, can join */
253 2, 0, 0, 0, 0, 0, 0, 0 /* basic rate set */ 253 2, 0, 0, 0, 0, 0, 0, 0 /* basic rate set */
254}; 254};
255 255
256static UCHAR b4_default_startup_parms[] = { 256static UCHAR b4_default_startup_parms[] = {
257 0, 0, /* Adhoc station */ 257 0, 0, /* Adhoc station */
258 'L','I','N','U','X', 0, 0, 0, /* 32 char ESSID */ 258 'L', 'I', 'N', 'U', 'X', 0, 0, 0, /* 32 char ESSID */
259 0, 0, 0, 0, 0, 0, 0, 0, 259 0, 0, 0, 0, 0, 0, 0, 0,
260 0, 0, 0, 0, 0, 0, 0, 0, 260 0, 0, 0, 0, 0, 0, 0, 0,
261 0, 0, 0, 0, 0, 0, 0, 0, 261 0, 0, 0, 0, 0, 0, 0, 0,
262 1, 0, /* Active scan, CA Mode */ 262 1, 0, /* Active scan, CA Mode */
263 0, 0, 0, 0, 0, 0, /* No default MAC addr */ 263 0, 0, 0, 0, 0, 0, /* No default MAC addr */
264 0x7f, 0xff, /* Frag threshold */ 264 0x7f, 0xff, /* Frag threshold */
265 0x02, 0x00, /* Hop time */ 265 0x02, 0x00, /* Hop time */
266 0x00, 0x01, /* Beacon period */ 266 0x00, 0x01, /* Beacon period */
267 0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout*/ 267 0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout */
268 0x1d, 0x82, 0xce, /* SIFS, DIFS, PIFS */ 268 0x1d, 0x82, 0xce, /* SIFS, DIFS, PIFS */
269 0x7f, 0xff, /* RTS threshold */ 269 0x7f, 0xff, /* RTS threshold */
270 0xfb, 0x1e, 0xc7, 0x5c, /* scan_dwell, max_scan_dwell */ 270 0xfb, 0x1e, 0xc7, 0x5c, /* scan_dwell, max_scan_dwell */
271 0x05, /* assoc resp timeout thresh */ 271 0x05, /* assoc resp timeout thresh */
272 0x04, 0x02, 0x4, /* adhoc, infra, super cycle max*/ 272 0x04, 0x02, 0x4, /* adhoc, infra, super cycle max */
273 0, /* Promiscuous mode */ 273 0, /* Promiscuous mode */
274 0x0c, 0x0bd, /* Unique word */ 274 0x0c, 0x0bd, /* Unique word */
275 0x4e, /* Slot time (TBD seems wrong)*/ 275 0x4e, /* Slot time (TBD seems wrong) */
276 0xff, 0xff, /* roam-low snr, low snr count */ 276 0xff, 0xff, /* roam-low snr, low snr count */
277 0x05, 0xff, /* Infra, adhoc missed bcn thresh */ 277 0x05, 0xff, /* Infra, adhoc missed bcn thresh */
278 0x01, 0x0b, 0x4e, /* USA, hop pattern, hop pat length */ 278 0x01, 0x0b, 0x4e, /* USA, hop pattern, hop pat length */
279/* b4 - b5 differences start here */ 279/* b4 - b5 differences start here */
280 0x3f, 0x0f, /* CW max, min */ 280 0x3f, 0x0f, /* CW max, min */
281 0x04, 0x08, /* Noise gain, limit offset */ 281 0x04, 0x08, /* Noise gain, limit offset */
282 0x28, 0x28, /* det rssi, med busy offsets */ 282 0x28, 0x28, /* det rssi, med busy offsets */
283 7, /* det sync thresh */ 283 7, /* det sync thresh */
284 0, 2, 2 /* test mode, min, max*/ 284 0, 2, 2 /* test mode, min, max */
285}; 285};
286
286/*===========================================================================*/ 287/*===========================================================================*/
287static unsigned char eth2_llc[] = {0xaa, 0xaa, 3, 0, 0, 0}; 288static unsigned char eth2_llc[] = { 0xaa, 0xaa, 3, 0, 0, 0 };
288 289
289static char hop_pattern_length[] = { 1, 290static char hop_pattern_length[] = { 1,
290 USA_HOP_MOD, EUROPE_HOP_MOD, 291 USA_HOP_MOD, EUROPE_HOP_MOD,
291 JAPAN_HOP_MOD, KOREA_HOP_MOD, 292 JAPAN_HOP_MOD, KOREA_HOP_MOD,
292 SPAIN_HOP_MOD, FRANCE_HOP_MOD, 293 SPAIN_HOP_MOD, FRANCE_HOP_MOD,
293 ISRAEL_HOP_MOD, AUSTRALIA_HOP_MOD, 294 ISRAEL_HOP_MOD, AUSTRALIA_HOP_MOD,
294 JAPAN_TEST_HOP_MOD 295 JAPAN_TEST_HOP_MOD
295}; 296};
296 297
297static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.std.com>"; 298static char rcsid[] =
299 "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.std.com>";
298 300
299/*============================================================================= 301/*=============================================================================
300 ray_attach() creates an "instance" of the driver, allocating 302 ray_attach() creates an "instance" of the driver, allocating
@@ -306,71 +308,72 @@ static char rcsid[] = "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.
306=============================================================================*/ 308=============================================================================*/
307static int ray_probe(struct pcmcia_device *p_dev) 309static int ray_probe(struct pcmcia_device *p_dev)
308{ 310{
309 ray_dev_t *local; 311 ray_dev_t *local;
310 struct net_device *dev; 312 struct net_device *dev;
311 313
312 DEBUG(1, "ray_attach()\n"); 314 DEBUG(1, "ray_attach()\n");
313 315
314 /* Allocate space for private device-specific data */ 316 /* Allocate space for private device-specific data */
315 dev = alloc_etherdev(sizeof(ray_dev_t)); 317 dev = alloc_etherdev(sizeof(ray_dev_t));
316 if (!dev) 318 if (!dev)
317 goto fail_alloc_dev; 319 goto fail_alloc_dev;
318 320
319 local = netdev_priv(dev); 321 local = netdev_priv(dev);
320 local->finder = p_dev; 322 local->finder = p_dev;
321 323
322 /* The io structure describes IO port mapping. None used here */ 324 /* The io structure describes IO port mapping. None used here */
323 p_dev->io.NumPorts1 = 0; 325 p_dev->io.NumPorts1 = 0;
324 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8; 326 p_dev->io.Attributes1 = IO_DATA_PATH_WIDTH_8;
325 p_dev->io.IOAddrLines = 5; 327 p_dev->io.IOAddrLines = 5;
326 328
327 /* Interrupt setup. For PCMCIA, driver takes what's given */ 329 /* Interrupt setup. For PCMCIA, driver takes what's given */
328 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; 330 p_dev->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT;
329 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID; 331 p_dev->irq.IRQInfo1 = IRQ_LEVEL_ID;
330 p_dev->irq.Handler = &ray_interrupt; 332 p_dev->irq.Handler = &ray_interrupt;
331 333
332 /* General socket configuration */ 334 /* General socket configuration */
333 p_dev->conf.Attributes = CONF_ENABLE_IRQ; 335 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
334 p_dev->conf.IntType = INT_MEMORY_AND_IO; 336 p_dev->conf.IntType = INT_MEMORY_AND_IO;
335 p_dev->conf.ConfigIndex = 1; 337 p_dev->conf.ConfigIndex = 1;
336 338
337 p_dev->priv = dev; 339 p_dev->priv = dev;
338 p_dev->irq.Instance = dev; 340 p_dev->irq.Instance = dev;
339 341
340 local->finder = p_dev; 342 local->finder = p_dev;
341 local->card_status = CARD_INSERTED; 343 local->card_status = CARD_INSERTED;
342 local->authentication_state = UNAUTHENTICATED; 344 local->authentication_state = UNAUTHENTICATED;
343 local->num_multi = 0; 345 local->num_multi = 0;
344 DEBUG(2,"ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n", 346 DEBUG(2, "ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
345 p_dev,dev,local,&ray_interrupt); 347 p_dev, dev, local, &ray_interrupt);
346 348
347 /* Raylink entries in the device structure */ 349 /* Raylink entries in the device structure */
348 dev->hard_start_xmit = &ray_dev_start_xmit; 350 dev->hard_start_xmit = &ray_dev_start_xmit;
349 dev->set_config = &ray_dev_config; 351 dev->set_config = &ray_dev_config;
350 dev->get_stats = &ray_get_stats; 352 dev->get_stats = &ray_get_stats;
351 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops); 353 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
352 dev->wireless_handlers = &ray_handler_def; 354 dev->wireless_handlers = &ray_handler_def;
353#ifdef WIRELESS_SPY 355#ifdef WIRELESS_SPY
354 local->wireless_data.spy_data = &local->spy_data; 356 local->wireless_data.spy_data = &local->spy_data;
355 dev->wireless_data = &local->wireless_data; 357 dev->wireless_data = &local->wireless_data;
356#endif /* WIRELESS_SPY */ 358#endif /* WIRELESS_SPY */
357 359
358 dev->set_multicast_list = &set_multicast_list; 360 dev->set_multicast_list = &set_multicast_list;
359 361
360 DEBUG(2,"ray_cs ray_attach calling ether_setup.)\n"); 362 DEBUG(2, "ray_cs ray_attach calling ether_setup.)\n");
361 dev->init = &ray_dev_init; 363 dev->init = &ray_dev_init;
362 dev->open = &ray_open; 364 dev->open = &ray_open;
363 dev->stop = &ray_dev_close; 365 dev->stop = &ray_dev_close;
364 netif_stop_queue(dev); 366 netif_stop_queue(dev);
365 367
366 init_timer(&local->timer); 368 init_timer(&local->timer);
367 369
368 this_device = p_dev; 370 this_device = p_dev;
369 return ray_config(p_dev); 371 return ray_config(p_dev);
370 372
371fail_alloc_dev: 373fail_alloc_dev:
372 return -ENOMEM; 374 return -ENOMEM;
373} /* ray_attach */ 375} /* ray_attach */
376
374/*============================================================================= 377/*=============================================================================
375 This deletes a driver "instance". The device is de-registered 378 This deletes a driver "instance". The device is de-registered
376 with Card Services. If it has been released, all local data 379 with Card Services. If it has been released, all local data
@@ -379,25 +382,27 @@ fail_alloc_dev:
379=============================================================================*/ 382=============================================================================*/
380static void ray_detach(struct pcmcia_device *link) 383static void ray_detach(struct pcmcia_device *link)
381{ 384{
382 struct net_device *dev; 385 struct net_device *dev;
383 ray_dev_t *local; 386 ray_dev_t *local;
384 387
385 DEBUG(1, "ray_detach(0x%p)\n", link); 388 DEBUG(1, "ray_detach(0x%p)\n", link);
386 389
387 this_device = NULL; 390 this_device = NULL;
388 dev = link->priv; 391 dev = link->priv;
389 392
390 ray_release(link); 393 ray_release(link);
391 394
392 local = netdev_priv(dev); 395 local = netdev_priv(dev);
393 del_timer(&local->timer); 396 del_timer(&local->timer);
394 397
395 if (link->priv) { 398 if (link->priv) {
396 if (link->dev_node) unregister_netdev(dev); 399 if (link->dev_node)
397 free_netdev(dev); 400 unregister_netdev(dev);
398 } 401 free_netdev(dev);
399 DEBUG(2,"ray_cs ray_detach ending\n"); 402 }
403 DEBUG(2, "ray_cs ray_detach ending\n");
400} /* ray_detach */ 404} /* ray_detach */
405
401/*============================================================================= 406/*=============================================================================
402 ray_config() is run after a CARD_INSERTION event 407 ray_config() is run after a CARD_INSERTION event
403 is received, to configure the PCMCIA socket, and to make the 408 is received, to configure the PCMCIA socket, and to make the
@@ -408,92 +413,101 @@ do { last_fn = (fn); if ((last_ret = (ret)) != 0) goto cs_failed; } while (0)
408#define MAX_TUPLE_SIZE 128 413#define MAX_TUPLE_SIZE 128
409static int ray_config(struct pcmcia_device *link) 414static int ray_config(struct pcmcia_device *link)
410{ 415{
411 int last_fn = 0, last_ret = 0; 416 int last_fn = 0, last_ret = 0;
412 int i; 417 int i;
413 win_req_t req; 418 win_req_t req;
414 memreq_t mem; 419 memreq_t mem;
415 struct net_device *dev = (struct net_device *)link->priv; 420 struct net_device *dev = (struct net_device *)link->priv;
416 ray_dev_t *local = netdev_priv(dev); 421 ray_dev_t *local = netdev_priv(dev);
417 422
418 DEBUG(1, "ray_config(0x%p)\n", link); 423 DEBUG(1, "ray_config(0x%p)\n", link);
419 424
420 /* Determine card type and firmware version */ 425 /* Determine card type and firmware version */
421 printk(KERN_INFO "ray_cs Detected: %s%s%s%s\n", 426 printk(KERN_INFO "ray_cs Detected: %s%s%s%s\n",
422 link->prod_id[0] ? link->prod_id[0] : " ", 427 link->prod_id[0] ? link->prod_id[0] : " ",
423 link->prod_id[1] ? link->prod_id[1] : " ", 428 link->prod_id[1] ? link->prod_id[1] : " ",
424 link->prod_id[2] ? link->prod_id[2] : " ", 429 link->prod_id[2] ? link->prod_id[2] : " ",
425 link->prod_id[3] ? link->prod_id[3] : " "); 430 link->prod_id[3] ? link->prod_id[3] : " ");
426 431
427 /* Now allocate an interrupt line. Note that this does not 432 /* Now allocate an interrupt line. Note that this does not
428 actually assign a handler to the interrupt. 433 actually assign a handler to the interrupt.
429 */ 434 */
430 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); 435 CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq));
431 dev->irq = link->irq.AssignedIRQ; 436 dev->irq = link->irq.AssignedIRQ;
432 437
433 /* This actually configures the PCMCIA socket -- setting up 438 /* This actually configures the PCMCIA socket -- setting up
434 the I/O windows and the interrupt mapping. 439 the I/O windows and the interrupt mapping.
435 */ 440 */
436 CS_CHECK(RequestConfiguration, pcmcia_request_configuration(link, &link->conf)); 441 CS_CHECK(RequestConfiguration,
442 pcmcia_request_configuration(link, &link->conf));
437 443
438/*** Set up 32k window for shared memory (transmit and control) ************/ 444/*** Set up 32k window for shared memory (transmit and control) ************/
439 req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT; 445 req.Attributes =
440 req.Base = 0; 446 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
441 req.Size = 0x8000; 447 req.Base = 0;
442 req.AccessSpeed = ray_mem_speed; 448 req.Size = 0x8000;
443 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win)); 449 req.AccessSpeed = ray_mem_speed;
444 mem.CardOffset = 0x0000; mem.Page = 0; 450 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &link->win));
445 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem)); 451 mem.CardOffset = 0x0000;
446 local->sram = ioremap(req.Base,req.Size); 452 mem.Page = 0;
453 CS_CHECK(MapMemPage, pcmcia_map_mem_page(link->win, &mem));
454 local->sram = ioremap(req.Base, req.Size);
447 455
448/*** Set up 16k window for shared memory (receive buffer) ***************/ 456/*** Set up 16k window for shared memory (receive buffer) ***************/
449 req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT; 457 req.Attributes =
450 req.Base = 0; 458 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
451 req.Size = 0x4000; 459 req.Base = 0;
452 req.AccessSpeed = ray_mem_speed; 460 req.Size = 0x4000;
453 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->rmem_handle)); 461 req.AccessSpeed = ray_mem_speed;
454 mem.CardOffset = 0x8000; mem.Page = 0; 462 CS_CHECK(RequestWindow,
455 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem)); 463 pcmcia_request_window(&link, &req, &local->rmem_handle));
456 local->rmem = ioremap(req.Base,req.Size); 464 mem.CardOffset = 0x8000;
465 mem.Page = 0;
466 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->rmem_handle, &mem));
467 local->rmem = ioremap(req.Base, req.Size);
457 468
458/*** Set up window for attribute memory ***********************************/ 469/*** Set up window for attribute memory ***********************************/
459 req.Attributes = WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT; 470 req.Attributes =
460 req.Base = 0; 471 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT;
461 req.Size = 0x1000; 472 req.Base = 0;
462 req.AccessSpeed = ray_mem_speed; 473 req.Size = 0x1000;
463 CS_CHECK(RequestWindow, pcmcia_request_window(&link, &req, &local->amem_handle)); 474 req.AccessSpeed = ray_mem_speed;
464 mem.CardOffset = 0x0000; mem.Page = 0; 475 CS_CHECK(RequestWindow,
465 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem)); 476 pcmcia_request_window(&link, &req, &local->amem_handle));
466 local->amem = ioremap(req.Base,req.Size); 477 mem.CardOffset = 0x0000;
467 478 mem.Page = 0;
468 DEBUG(3,"ray_config sram=%p\n",local->sram); 479 CS_CHECK(MapMemPage, pcmcia_map_mem_page(local->amem_handle, &mem));
469 DEBUG(3,"ray_config rmem=%p\n",local->rmem); 480 local->amem = ioremap(req.Base, req.Size);
470 DEBUG(3,"ray_config amem=%p\n",local->amem); 481
471 if (ray_init(dev) < 0) { 482 DEBUG(3, "ray_config sram=%p\n", local->sram);
472 ray_release(link); 483 DEBUG(3, "ray_config rmem=%p\n", local->rmem);
473 return -ENODEV; 484 DEBUG(3, "ray_config amem=%p\n", local->amem);
474 } 485 if (ray_init(dev) < 0) {
475 486 ray_release(link);
476 SET_NETDEV_DEV(dev, &handle_to_dev(link)); 487 return -ENODEV;
477 i = register_netdev(dev); 488 }
478 if (i != 0) { 489
479 printk("ray_config register_netdev() failed\n"); 490 SET_NETDEV_DEV(dev, &handle_to_dev(link));
480 ray_release(link); 491 i = register_netdev(dev);
481 return i; 492 if (i != 0) {
482 } 493 printk("ray_config register_netdev() failed\n");
483 494 ray_release(link);
484 strcpy(local->node.dev_name, dev->name); 495 return i;
485 link->dev_node = &local->node; 496 }
486 497
487 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr %pM\n", 498 strcpy(local->node.dev_name, dev->name);
488 dev->name, dev->irq, dev->dev_addr); 499 link->dev_node = &local->node;
489 500
490 return 0; 501 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr %pM\n",
502 dev->name, dev->irq, dev->dev_addr);
503
504 return 0;
491 505
492cs_failed: 506cs_failed:
493 cs_error(link, last_fn, last_ret); 507 cs_error(link, last_fn, last_ret);
494 508
495 ray_release(link); 509 ray_release(link);
496 return -ENODEV; 510 return -ENODEV;
497} /* ray_config */ 511} /* ray_config */
498 512
499static inline struct ccs __iomem *ccs_base(ray_dev_t *dev) 513static inline struct ccs __iomem *ccs_base(ray_dev_t *dev)
@@ -516,267 +530,278 @@ static inline struct rcs __iomem *rcs_base(ray_dev_t *dev)
516/*===========================================================================*/ 530/*===========================================================================*/
517static int ray_init(struct net_device *dev) 531static int ray_init(struct net_device *dev)
518{ 532{
519 int i; 533 int i;
520 UCHAR *p; 534 UCHAR *p;
521 struct ccs __iomem *pccs; 535 struct ccs __iomem *pccs;
522 ray_dev_t *local = netdev_priv(dev); 536 ray_dev_t *local = netdev_priv(dev);
523 struct pcmcia_device *link = local->finder; 537 struct pcmcia_device *link = local->finder;
524 DEBUG(1, "ray_init(0x%p)\n", dev); 538 DEBUG(1, "ray_init(0x%p)\n", dev);
525 if (!(pcmcia_dev_present(link))) { 539 if (!(pcmcia_dev_present(link))) {
526 DEBUG(0,"ray_init - device not present\n"); 540 DEBUG(0, "ray_init - device not present\n");
527 return -1; 541 return -1;
528 } 542 }
529 543
530 local->net_type = net_type; 544 local->net_type = net_type;
531 local->sta_type = TYPE_STA; 545 local->sta_type = TYPE_STA;
532 546
533 /* Copy the startup results to local memory */ 547 /* Copy the startup results to local memory */
534 memcpy_fromio(&local->startup_res, local->sram + ECF_TO_HOST_BASE,\ 548 memcpy_fromio(&local->startup_res, local->sram + ECF_TO_HOST_BASE,
535 sizeof(struct startup_res_6)); 549 sizeof(struct startup_res_6));
536 550
537 /* Check Power up test status and get mac address from card */ 551 /* Check Power up test status and get mac address from card */
538 if (local->startup_res.startup_word != 0x80) { 552 if (local->startup_res.startup_word != 0x80) {
539 printk(KERN_INFO "ray_init ERROR card status = %2x\n", 553 printk(KERN_INFO "ray_init ERROR card status = %2x\n",
540 local->startup_res.startup_word); 554 local->startup_res.startup_word);
541 local->card_status = CARD_INIT_ERROR; 555 local->card_status = CARD_INIT_ERROR;
542 return -1; 556 return -1;
543 } 557 }
544 558
545 local->fw_ver = local->startup_res.firmware_version[0]; 559 local->fw_ver = local->startup_res.firmware_version[0];
546 local->fw_bld = local->startup_res.firmware_version[1]; 560 local->fw_bld = local->startup_res.firmware_version[1];
547 local->fw_var = local->startup_res.firmware_version[2]; 561 local->fw_var = local->startup_res.firmware_version[2];
548 DEBUG(1,"ray_init firmware version %d.%d \n",local->fw_ver, local->fw_bld); 562 DEBUG(1, "ray_init firmware version %d.%d \n", local->fw_ver,
549 563 local->fw_bld);
550 local->tib_length = 0x20; 564
551 if ((local->fw_ver == 5) && (local->fw_bld >= 30)) 565 local->tib_length = 0x20;
552 local->tib_length = local->startup_res.tib_length; 566 if ((local->fw_ver == 5) && (local->fw_bld >= 30))
553 DEBUG(2,"ray_init tib_length = 0x%02x\n", local->tib_length); 567 local->tib_length = local->startup_res.tib_length;
554 /* Initialize CCS's to buffer free state */ 568 DEBUG(2, "ray_init tib_length = 0x%02x\n", local->tib_length);
555 pccs = ccs_base(local); 569 /* Initialize CCS's to buffer free state */
556 for (i=0; i<NUMBER_OF_CCS; i++) { 570 pccs = ccs_base(local);
557 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status); 571 for (i = 0; i < NUMBER_OF_CCS; i++) {
558 } 572 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
559 init_startup_params(local); 573 }
560 574 init_startup_params(local);
561 /* copy mac address to startup parameters */ 575
562 if (parse_addr(phy_addr, local->sparm.b4.a_mac_addr)) 576 /* copy mac address to startup parameters */
563 { 577 if (parse_addr(phy_addr, local->sparm.b4.a_mac_addr)) {
564 p = local->sparm.b4.a_mac_addr; 578 p = local->sparm.b4.a_mac_addr;
565 } 579 } else {
566 else 580 memcpy(&local->sparm.b4.a_mac_addr,
567 { 581 &local->startup_res.station_addr, ADDRLEN);
568 memcpy(&local->sparm.b4.a_mac_addr, 582 p = local->sparm.b4.a_mac_addr;
569 &local->startup_res.station_addr, ADDRLEN); 583 }
570 p = local->sparm.b4.a_mac_addr; 584
571 } 585 clear_interrupt(local); /* Clear any interrupt from the card */
572 586 local->card_status = CARD_AWAITING_PARAM;
573 clear_interrupt(local); /* Clear any interrupt from the card */ 587 DEBUG(2, "ray_init ending\n");
574 local->card_status = CARD_AWAITING_PARAM; 588 return 0;
575 DEBUG(2,"ray_init ending\n");
576 return 0;
577} /* ray_init */ 589} /* ray_init */
590
578/*===========================================================================*/ 591/*===========================================================================*/
579/* Download startup parameters to the card and command it to read them */ 592/* Download startup parameters to the card and command it to read them */
580static int dl_startup_params(struct net_device *dev) 593static int dl_startup_params(struct net_device *dev)
581{ 594{
582 int ccsindex; 595 int ccsindex;
583 ray_dev_t *local = netdev_priv(dev); 596 ray_dev_t *local = netdev_priv(dev);
584 struct ccs __iomem *pccs; 597 struct ccs __iomem *pccs;
585 struct pcmcia_device *link = local->finder; 598 struct pcmcia_device *link = local->finder;
586 599
587 DEBUG(1,"dl_startup_params entered\n"); 600 DEBUG(1, "dl_startup_params entered\n");
588 if (!(pcmcia_dev_present(link))) { 601 if (!(pcmcia_dev_present(link))) {
589 DEBUG(2,"ray_cs dl_startup_params - device not present\n"); 602 DEBUG(2, "ray_cs dl_startup_params - device not present\n");
590 return -1; 603 return -1;
591 } 604 }
592 605
593 /* Copy parameters to host to ECF area */ 606 /* Copy parameters to host to ECF area */
594 if (local->fw_ver == 0x55) 607 if (local->fw_ver == 0x55)
595 memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b4, 608 memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b4,
596 sizeof(struct b4_startup_params)); 609 sizeof(struct b4_startup_params));
597 else 610 else
598 memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b5, 611 memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b5,
599 sizeof(struct b5_startup_params)); 612 sizeof(struct b5_startup_params));
600 613
601 614 /* Fill in the CCS fields for the ECF */
602 /* Fill in the CCS fields for the ECF */ 615 if ((ccsindex = get_free_ccs(local)) < 0)
603 if ((ccsindex = get_free_ccs(local)) < 0) return -1; 616 return -1;
604 local->dl_param_ccs = ccsindex; 617 local->dl_param_ccs = ccsindex;
605 pccs = ccs_base(local) + ccsindex; 618 pccs = ccs_base(local) + ccsindex;
606 writeb(CCS_DOWNLOAD_STARTUP_PARAMS, &pccs->cmd); 619 writeb(CCS_DOWNLOAD_STARTUP_PARAMS, &pccs->cmd);
607 DEBUG(2,"dl_startup_params start ccsindex = %d\n", local->dl_param_ccs); 620 DEBUG(2, "dl_startup_params start ccsindex = %d\n",
608 /* Interrupt the firmware to process the command */ 621 local->dl_param_ccs);
609 if (interrupt_ecf(local, ccsindex)) { 622 /* Interrupt the firmware to process the command */
610 printk(KERN_INFO "ray dl_startup_params failed - " 623 if (interrupt_ecf(local, ccsindex)) {
611 "ECF not ready for intr\n"); 624 printk(KERN_INFO "ray dl_startup_params failed - "
612 local->card_status = CARD_DL_PARAM_ERROR; 625 "ECF not ready for intr\n");
613 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status); 626 local->card_status = CARD_DL_PARAM_ERROR;
614 return -2; 627 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
615 } 628 return -2;
616 local->card_status = CARD_DL_PARAM; 629 }
617 /* Start kernel timer to wait for dl startup to complete. */ 630 local->card_status = CARD_DL_PARAM;
618 local->timer.expires = jiffies + HZ/2; 631 /* Start kernel timer to wait for dl startup to complete. */
619 local->timer.data = (long)local; 632 local->timer.expires = jiffies + HZ / 2;
620 local->timer.function = &verify_dl_startup; 633 local->timer.data = (long)local;
621 add_timer(&local->timer); 634 local->timer.function = &verify_dl_startup;
622 DEBUG(2,"ray_cs dl_startup_params started timer for verify_dl_startup\n"); 635 add_timer(&local->timer);
623 return 0; 636 DEBUG(2,
637 "ray_cs dl_startup_params started timer for verify_dl_startup\n");
638 return 0;
624} /* dl_startup_params */ 639} /* dl_startup_params */
640
625/*===========================================================================*/ 641/*===========================================================================*/
626static void init_startup_params(ray_dev_t *local) 642static void init_startup_params(ray_dev_t *local)
627{ 643{
628 int i; 644 int i;
629 645
630 if (country > JAPAN_TEST) country = USA; 646 if (country > JAPAN_TEST)
631 else 647 country = USA;
632 if (country < USA) country = USA; 648 else if (country < USA)
633 /* structure for hop time and beacon period is defined here using 649 country = USA;
634 * New 802.11D6.1 format. Card firmware is still using old format 650 /* structure for hop time and beacon period is defined here using
635 * until version 6. 651 * New 802.11D6.1 format. Card firmware is still using old format
636 * Before After 652 * until version 6.
637 * a_hop_time ms byte a_hop_time ms byte 653 * Before After
638 * a_hop_time 2s byte a_hop_time ls byte 654 * a_hop_time ms byte a_hop_time ms byte
639 * a_hop_time ls byte a_beacon_period ms byte 655 * a_hop_time 2s byte a_hop_time ls byte
640 * a_beacon_period a_beacon_period ls byte 656 * a_hop_time ls byte a_beacon_period ms byte
641 * 657 * a_beacon_period a_beacon_period ls byte
642 * a_hop_time = uS a_hop_time = KuS 658 *
643 * a_beacon_period = hops a_beacon_period = KuS 659 * a_hop_time = uS a_hop_time = KuS
644 */ /* 64ms = 010000 */ 660 * a_beacon_period = hops a_beacon_period = KuS
645 if (local->fw_ver == 0x55) { 661 *//* 64ms = 010000 */
646 memcpy((UCHAR *)&local->sparm.b4, b4_default_startup_parms, 662 if (local->fw_ver == 0x55) {
647 sizeof(struct b4_startup_params)); 663 memcpy((UCHAR *) &local->sparm.b4, b4_default_startup_parms,
648 /* Translate sane kus input values to old build 4/5 format */ 664 sizeof(struct b4_startup_params));
649 /* i = hop time in uS truncated to 3 bytes */ 665 /* Translate sane kus input values to old build 4/5 format */
650 i = (hop_dwell * 1024) & 0xffffff; 666 /* i = hop time in uS truncated to 3 bytes */
651 local->sparm.b4.a_hop_time[0] = (i >> 16) & 0xff; 667 i = (hop_dwell * 1024) & 0xffffff;
652 local->sparm.b4.a_hop_time[1] = (i >> 8) & 0xff; 668 local->sparm.b4.a_hop_time[0] = (i >> 16) & 0xff;
653 local->sparm.b4.a_beacon_period[0] = 0; 669 local->sparm.b4.a_hop_time[1] = (i >> 8) & 0xff;
654 local->sparm.b4.a_beacon_period[1] = 670 local->sparm.b4.a_beacon_period[0] = 0;
655 ((beacon_period/hop_dwell) - 1) & 0xff; 671 local->sparm.b4.a_beacon_period[1] =
656 local->sparm.b4.a_curr_country_code = country; 672 ((beacon_period / hop_dwell) - 1) & 0xff;
657 local->sparm.b4.a_hop_pattern_length = 673 local->sparm.b4.a_curr_country_code = country;
658 hop_pattern_length[(int)country] - 1; 674 local->sparm.b4.a_hop_pattern_length =
659 if (bc) 675 hop_pattern_length[(int)country] - 1;
660 { 676 if (bc) {
661 local->sparm.b4.a_ack_timeout = 0x50; 677 local->sparm.b4.a_ack_timeout = 0x50;
662 local->sparm.b4.a_sifs = 0x3f; 678 local->sparm.b4.a_sifs = 0x3f;
663 } 679 }
664 } 680 } else { /* Version 5 uses real kus values */
665 else { /* Version 5 uses real kus values */ 681 memcpy((UCHAR *) &local->sparm.b5, b5_default_startup_parms,
666 memcpy((UCHAR *)&local->sparm.b5, b5_default_startup_parms, 682 sizeof(struct b5_startup_params));
667 sizeof(struct b5_startup_params)); 683
668 684 local->sparm.b5.a_hop_time[0] = (hop_dwell >> 8) & 0xff;
669 local->sparm.b5.a_hop_time[0] = (hop_dwell >> 8) & 0xff; 685 local->sparm.b5.a_hop_time[1] = hop_dwell & 0xff;
670 local->sparm.b5.a_hop_time[1] = hop_dwell & 0xff; 686 local->sparm.b5.a_beacon_period[0] =
671 local->sparm.b5.a_beacon_period[0] = (beacon_period >> 8) & 0xff; 687 (beacon_period >> 8) & 0xff;
672 local->sparm.b5.a_beacon_period[1] = beacon_period & 0xff; 688 local->sparm.b5.a_beacon_period[1] = beacon_period & 0xff;
673 if (psm) 689 if (psm)
674 local->sparm.b5.a_power_mgt_state = 1; 690 local->sparm.b5.a_power_mgt_state = 1;
675 local->sparm.b5.a_curr_country_code = country; 691 local->sparm.b5.a_curr_country_code = country;
676 local->sparm.b5.a_hop_pattern_length = 692 local->sparm.b5.a_hop_pattern_length =
677 hop_pattern_length[(int)country]; 693 hop_pattern_length[(int)country];
678 } 694 }
679 695
680 local->sparm.b4.a_network_type = net_type & 0x01; 696 local->sparm.b4.a_network_type = net_type & 0x01;
681 local->sparm.b4.a_acting_as_ap_status = TYPE_STA; 697 local->sparm.b4.a_acting_as_ap_status = TYPE_STA;
682 698
683 if (essid != NULL) 699 if (essid != NULL)
684 strncpy(local->sparm.b4.a_current_ess_id, essid, ESSID_SIZE); 700 strncpy(local->sparm.b4.a_current_ess_id, essid, ESSID_SIZE);
685} /* init_startup_params */ 701} /* init_startup_params */
702
686/*===========================================================================*/ 703/*===========================================================================*/
687static void verify_dl_startup(u_long data) 704static void verify_dl_startup(u_long data)
688{ 705{
689 ray_dev_t *local = (ray_dev_t *)data; 706 ray_dev_t *local = (ray_dev_t *) data;
690 struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs; 707 struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs;
691 UCHAR status; 708 UCHAR status;
692 struct pcmcia_device *link = local->finder; 709 struct pcmcia_device *link = local->finder;
693 710
694 if (!(pcmcia_dev_present(link))) { 711 if (!(pcmcia_dev_present(link))) {
695 DEBUG(2,"ray_cs verify_dl_startup - device not present\n"); 712 DEBUG(2, "ray_cs verify_dl_startup - device not present\n");
696 return; 713 return;
697 } 714 }
698#ifdef PCMCIA_DEBUG 715#ifdef PCMCIA_DEBUG
699 if (pc_debug > 2) { 716 if (pc_debug > 2) {
700 int i; 717 int i;
701 printk(KERN_DEBUG "verify_dl_startup parameters sent via ccs %d:\n", 718 printk(KERN_DEBUG
702 local->dl_param_ccs); 719 "verify_dl_startup parameters sent via ccs %d:\n",
703 for (i=0; i<sizeof(struct b5_startup_params); i++) { 720 local->dl_param_ccs);
704 printk(" %2x", (unsigned int) readb(local->sram + HOST_TO_ECF_BASE + i)); 721 for (i = 0; i < sizeof(struct b5_startup_params); i++) {
705 } 722 printk(" %2x",
706 printk("\n"); 723 (unsigned int)readb(local->sram +
707 } 724 HOST_TO_ECF_BASE + i));
725 }
726 printk("\n");
727 }
708#endif 728#endif
709 729
710 status = readb(&pccs->buffer_status); 730 status = readb(&pccs->buffer_status);
711 if (status!= CCS_BUFFER_FREE) 731 if (status != CCS_BUFFER_FREE) {
712 { 732 printk(KERN_INFO
713 printk(KERN_INFO "Download startup params failed. Status = %d\n", 733 "Download startup params failed. Status = %d\n",
714 status); 734 status);
715 local->card_status = CARD_DL_PARAM_ERROR; 735 local->card_status = CARD_DL_PARAM_ERROR;
716 return; 736 return;
717 } 737 }
718 if (local->sparm.b4.a_network_type == ADHOC) 738 if (local->sparm.b4.a_network_type == ADHOC)
719 start_net((u_long)local); 739 start_net((u_long) local);
720 else 740 else
721 join_net((u_long)local); 741 join_net((u_long) local);
722 742
723 return; 743 return;
724} /* end verify_dl_startup */ 744} /* end verify_dl_startup */
745
725/*===========================================================================*/ 746/*===========================================================================*/
726/* Command card to start a network */ 747/* Command card to start a network */
727static void start_net(u_long data) 748static void start_net(u_long data)
728{ 749{
729 ray_dev_t *local = (ray_dev_t *)data; 750 ray_dev_t *local = (ray_dev_t *) data;
730 struct ccs __iomem *pccs; 751 struct ccs __iomem *pccs;
731 int ccsindex; 752 int ccsindex;
732 struct pcmcia_device *link = local->finder; 753 struct pcmcia_device *link = local->finder;
733 if (!(pcmcia_dev_present(link))) { 754 if (!(pcmcia_dev_present(link))) {
734 DEBUG(2,"ray_cs start_net - device not present\n"); 755 DEBUG(2, "ray_cs start_net - device not present\n");
735 return; 756 return;
736 } 757 }
737 /* Fill in the CCS fields for the ECF */ 758 /* Fill in the CCS fields for the ECF */
738 if ((ccsindex = get_free_ccs(local)) < 0) return; 759 if ((ccsindex = get_free_ccs(local)) < 0)
739 pccs = ccs_base(local) + ccsindex; 760 return;
740 writeb(CCS_START_NETWORK, &pccs->cmd); 761 pccs = ccs_base(local) + ccsindex;
741 writeb(0, &pccs->var.start_network.update_param); 762 writeb(CCS_START_NETWORK, &pccs->cmd);
742 /* Interrupt the firmware to process the command */ 763 writeb(0, &pccs->var.start_network.update_param);
743 if (interrupt_ecf(local, ccsindex)) { 764 /* Interrupt the firmware to process the command */
744 DEBUG(1,"ray start net failed - card not ready for intr\n"); 765 if (interrupt_ecf(local, ccsindex)) {
745 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status); 766 DEBUG(1, "ray start net failed - card not ready for intr\n");
746 return; 767 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
747 } 768 return;
748 local->card_status = CARD_DOING_ACQ; 769 }
749 return; 770 local->card_status = CARD_DOING_ACQ;
771 return;
750} /* end start_net */ 772} /* end start_net */
773
751/*===========================================================================*/ 774/*===========================================================================*/
752/* Command card to join a network */ 775/* Command card to join a network */
753static void join_net(u_long data) 776static void join_net(u_long data)
754{ 777{
755 ray_dev_t *local = (ray_dev_t *)data; 778 ray_dev_t *local = (ray_dev_t *) data;
756 779
757 struct ccs __iomem *pccs; 780 struct ccs __iomem *pccs;
758 int ccsindex; 781 int ccsindex;
759 struct pcmcia_device *link = local->finder; 782 struct pcmcia_device *link = local->finder;
760 783
761 if (!(pcmcia_dev_present(link))) { 784 if (!(pcmcia_dev_present(link))) {
762 DEBUG(2,"ray_cs join_net - device not present\n"); 785 DEBUG(2, "ray_cs join_net - device not present\n");
763 return; 786 return;
764 } 787 }
765 /* Fill in the CCS fields for the ECF */ 788 /* Fill in the CCS fields for the ECF */
766 if ((ccsindex = get_free_ccs(local)) < 0) return; 789 if ((ccsindex = get_free_ccs(local)) < 0)
767 pccs = ccs_base(local) + ccsindex; 790 return;
768 writeb(CCS_JOIN_NETWORK, &pccs->cmd); 791 pccs = ccs_base(local) + ccsindex;
769 writeb(0, &pccs->var.join_network.update_param); 792 writeb(CCS_JOIN_NETWORK, &pccs->cmd);
770 writeb(0, &pccs->var.join_network.net_initiated); 793 writeb(0, &pccs->var.join_network.update_param);
771 /* Interrupt the firmware to process the command */ 794 writeb(0, &pccs->var.join_network.net_initiated);
772 if (interrupt_ecf(local, ccsindex)) { 795 /* Interrupt the firmware to process the command */
773 DEBUG(1,"ray join net failed - card not ready for intr\n"); 796 if (interrupt_ecf(local, ccsindex)) {
774 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status); 797 DEBUG(1, "ray join net failed - card not ready for intr\n");
775 return; 798 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
776 } 799 return;
777 local->card_status = CARD_DOING_ACQ; 800 }
778 return; 801 local->card_status = CARD_DOING_ACQ;
802 return;
779} 803}
804
780/*============================================================================ 805/*============================================================================
781 After a card is removed, ray_release() will unregister the net 806 After a card is removed, ray_release() will unregister the net
782 device, and release the PCMCIA configuration. If the device is 807 device, and release the PCMCIA configuration. If the device is
@@ -784,25 +809,27 @@ static void join_net(u_long data)
784=============================================================================*/ 809=============================================================================*/
785static void ray_release(struct pcmcia_device *link) 810static void ray_release(struct pcmcia_device *link)
786{ 811{
787 struct net_device *dev = link->priv; 812 struct net_device *dev = link->priv;
788 ray_dev_t *local = netdev_priv(dev); 813 ray_dev_t *local = netdev_priv(dev);
789 int i; 814 int i;
790 815
791 DEBUG(1, "ray_release(0x%p)\n", link); 816 DEBUG(1, "ray_release(0x%p)\n", link);
792 817
793 del_timer(&local->timer); 818 del_timer(&local->timer);
794 819
795 iounmap(local->sram); 820 iounmap(local->sram);
796 iounmap(local->rmem); 821 iounmap(local->rmem);
797 iounmap(local->amem); 822 iounmap(local->amem);
798 /* Do bother checking to see if these succeed or not */ 823 /* Do bother checking to see if these succeed or not */
799 i = pcmcia_release_window(local->amem_handle); 824 i = pcmcia_release_window(local->amem_handle);
800 if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->amem) ret = %x\n",i); 825 if (i != 0)
801 i = pcmcia_release_window(local->rmem_handle); 826 DEBUG(0, "ReleaseWindow(local->amem) ret = %x\n", i);
802 if ( i != 0 ) DEBUG(0,"ReleaseWindow(local->rmem) ret = %x\n",i); 827 i = pcmcia_release_window(local->rmem_handle);
803 pcmcia_disable_device(link); 828 if (i != 0)
804 829 DEBUG(0, "ReleaseWindow(local->rmem) ret = %x\n", i);
805 DEBUG(2,"ray_release ending\n"); 830 pcmcia_disable_device(link);
831
832 DEBUG(2, "ray_release ending\n");
806} 833}
807 834
808static int ray_suspend(struct pcmcia_device *link) 835static int ray_suspend(struct pcmcia_device *link)
@@ -831,237 +858,243 @@ static int ray_resume(struct pcmcia_device *link)
831static int ray_dev_init(struct net_device *dev) 858static int ray_dev_init(struct net_device *dev)
832{ 859{
833#ifdef RAY_IMMEDIATE_INIT 860#ifdef RAY_IMMEDIATE_INIT
834 int i; 861 int i;
835#endif /* RAY_IMMEDIATE_INIT */ 862#endif /* RAY_IMMEDIATE_INIT */
836 ray_dev_t *local = netdev_priv(dev); 863 ray_dev_t *local = netdev_priv(dev);
837 struct pcmcia_device *link = local->finder; 864 struct pcmcia_device *link = local->finder;
838 865
839 DEBUG(1,"ray_dev_init(dev=%p)\n",dev); 866 DEBUG(1, "ray_dev_init(dev=%p)\n", dev);
840 if (!(pcmcia_dev_present(link))) { 867 if (!(pcmcia_dev_present(link))) {
841 DEBUG(2,"ray_dev_init - device not present\n"); 868 DEBUG(2, "ray_dev_init - device not present\n");
842 return -1; 869 return -1;
843 } 870 }
844#ifdef RAY_IMMEDIATE_INIT 871#ifdef RAY_IMMEDIATE_INIT
845 /* Download startup parameters */ 872 /* Download startup parameters */
846 if ( (i = dl_startup_params(dev)) < 0) 873 if ((i = dl_startup_params(dev)) < 0) {
847 { 874 printk(KERN_INFO "ray_dev_init dl_startup_params failed - "
848 printk(KERN_INFO "ray_dev_init dl_startup_params failed - " 875 "returns 0x%x\n", i);
849 "returns 0x%x\n",i); 876 return -1;
850 return -1; 877 }
851 } 878#else /* RAY_IMMEDIATE_INIT */
852#else /* RAY_IMMEDIATE_INIT */ 879 /* Postpone the card init so that we can still configure the card,
853 /* Postpone the card init so that we can still configure the card, 880 * for example using the Wireless Extensions. The init will happen
854 * for example using the Wireless Extensions. The init will happen 881 * in ray_open() - Jean II */
855 * in ray_open() - Jean II */ 882 DEBUG(1,
856 DEBUG(1,"ray_dev_init: postponing card init to ray_open() ; Status = %d\n", 883 "ray_dev_init: postponing card init to ray_open() ; Status = %d\n",
857 local->card_status); 884 local->card_status);
858#endif /* RAY_IMMEDIATE_INIT */ 885#endif /* RAY_IMMEDIATE_INIT */
859 886
860 /* copy mac and broadcast addresses to linux device */ 887 /* copy mac and broadcast addresses to linux device */
861 memcpy(&dev->dev_addr, &local->sparm.b4.a_mac_addr, ADDRLEN); 888 memcpy(&dev->dev_addr, &local->sparm.b4.a_mac_addr, ADDRLEN);
862 memset(dev->broadcast, 0xff, ETH_ALEN); 889 memset(dev->broadcast, 0xff, ETH_ALEN);
863 890
864 DEBUG(2,"ray_dev_init ending\n"); 891 DEBUG(2, "ray_dev_init ending\n");
865 return 0; 892 return 0;
866} 893}
894
867/*===========================================================================*/ 895/*===========================================================================*/
868static int ray_dev_config(struct net_device *dev, struct ifmap *map) 896static int ray_dev_config(struct net_device *dev, struct ifmap *map)
869{ 897{
870 ray_dev_t *local = netdev_priv(dev); 898 ray_dev_t *local = netdev_priv(dev);
871 struct pcmcia_device *link = local->finder; 899 struct pcmcia_device *link = local->finder;
872 /* Dummy routine to satisfy device structure */ 900 /* Dummy routine to satisfy device structure */
873 DEBUG(1,"ray_dev_config(dev=%p,ifmap=%p)\n",dev,map); 901 DEBUG(1, "ray_dev_config(dev=%p,ifmap=%p)\n", dev, map);
874 if (!(pcmcia_dev_present(link))) { 902 if (!(pcmcia_dev_present(link))) {
875 DEBUG(2,"ray_dev_config - device not present\n"); 903 DEBUG(2, "ray_dev_config - device not present\n");
876 return -1; 904 return -1;
877 } 905 }
878 906
879 return 0; 907 return 0;
880} 908}
909
881/*===========================================================================*/ 910/*===========================================================================*/
882static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev) 911static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev)
883{ 912{
884 ray_dev_t *local = netdev_priv(dev); 913 ray_dev_t *local = netdev_priv(dev);
885 struct pcmcia_device *link = local->finder; 914 struct pcmcia_device *link = local->finder;
886 short length = skb->len; 915 short length = skb->len;
887 916
888 if (!(pcmcia_dev_present(link))) { 917 if (!(pcmcia_dev_present(link))) {
889 DEBUG(2,"ray_dev_start_xmit - device not present\n"); 918 DEBUG(2, "ray_dev_start_xmit - device not present\n");
890 return -1; 919 return -1;
891 } 920 }
892 DEBUG(3,"ray_dev_start_xmit(skb=%p, dev=%p)\n",skb,dev); 921 DEBUG(3, "ray_dev_start_xmit(skb=%p, dev=%p)\n", skb, dev);
893 if (local->authentication_state == NEED_TO_AUTH) { 922 if (local->authentication_state == NEED_TO_AUTH) {
894 DEBUG(0,"ray_cs Sending authentication request.\n"); 923 DEBUG(0, "ray_cs Sending authentication request.\n");
895 if (!build_auth_frame (local, local->auth_id, OPEN_AUTH_REQUEST)) { 924 if (!build_auth_frame(local, local->auth_id, OPEN_AUTH_REQUEST)) {
896 local->authentication_state = AUTHENTICATED; 925 local->authentication_state = AUTHENTICATED;
897 netif_stop_queue(dev); 926 netif_stop_queue(dev);
898 return 1; 927 return 1;
899 } 928 }
900 } 929 }
901 930
902 if (length < ETH_ZLEN) 931 if (length < ETH_ZLEN) {
903 { 932 if (skb_padto(skb, ETH_ZLEN))
904 if (skb_padto(skb, ETH_ZLEN)) 933 return 0;
905 return 0; 934 length = ETH_ZLEN;
906 length = ETH_ZLEN; 935 }
907 } 936 switch (ray_hw_xmit(skb->data, length, dev, DATA_TYPE)) {
908 switch (ray_hw_xmit( skb->data, length, dev, DATA_TYPE)) { 937 case XMIT_NO_CCS:
909 case XMIT_NO_CCS: 938 case XMIT_NEED_AUTH:
910 case XMIT_NEED_AUTH: 939 netif_stop_queue(dev);
911 netif_stop_queue(dev); 940 return 1;
912 return 1; 941 case XMIT_NO_INTR:
913 case XMIT_NO_INTR: 942 case XMIT_MSG_BAD:
914 case XMIT_MSG_BAD: 943 case XMIT_OK:
915 case XMIT_OK: 944 default:
916 default: 945 dev->trans_start = jiffies;
917 dev->trans_start = jiffies; 946 dev_kfree_skb(skb);
918 dev_kfree_skb(skb); 947 return 0;
919 return 0; 948 }
920 } 949 return 0;
921 return 0;
922} /* ray_dev_start_xmit */ 950} /* ray_dev_start_xmit */
951
923/*===========================================================================*/ 952/*===========================================================================*/
924static int ray_hw_xmit(unsigned char* data, int len, struct net_device* dev, 953static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev,
925 UCHAR msg_type) 954 UCHAR msg_type)
926{ 955{
927 ray_dev_t *local = netdev_priv(dev); 956 ray_dev_t *local = netdev_priv(dev);
928 struct ccs __iomem *pccs; 957 struct ccs __iomem *pccs;
929 int ccsindex; 958 int ccsindex;
930 int offset; 959 int offset;
931 struct tx_msg __iomem *ptx; /* Address of xmit buffer in PC space */ 960 struct tx_msg __iomem *ptx; /* Address of xmit buffer in PC space */
932 short int addr; /* Address of xmit buffer in card space */ 961 short int addr; /* Address of xmit buffer in card space */
933 962
934 DEBUG(3,"ray_hw_xmit(data=%p, len=%d, dev=%p)\n",data,len,dev); 963 DEBUG(3, "ray_hw_xmit(data=%p, len=%d, dev=%p)\n", data, len, dev);
935 if (len + TX_HEADER_LENGTH > TX_BUF_SIZE) 964 if (len + TX_HEADER_LENGTH > TX_BUF_SIZE) {
936 { 965 printk(KERN_INFO "ray_hw_xmit packet too large: %d bytes\n",
937 printk(KERN_INFO "ray_hw_xmit packet too large: %d bytes\n",len); 966 len);
938 return XMIT_MSG_BAD; 967 return XMIT_MSG_BAD;
939 } 968 }
940 switch (ccsindex = get_free_tx_ccs(local)) { 969 switch (ccsindex = get_free_tx_ccs(local)) {
941 case ECCSBUSY: 970 case ECCSBUSY:
942 DEBUG(2,"ray_hw_xmit tx_ccs table busy\n"); 971 DEBUG(2, "ray_hw_xmit tx_ccs table busy\n");
943 case ECCSFULL: 972 case ECCSFULL:
944 DEBUG(2,"ray_hw_xmit No free tx ccs\n"); 973 DEBUG(2, "ray_hw_xmit No free tx ccs\n");
945 case ECARDGONE: 974 case ECARDGONE:
946 netif_stop_queue(dev); 975 netif_stop_queue(dev);
947 return XMIT_NO_CCS; 976 return XMIT_NO_CCS;
948 default: 977 default:
949 break; 978 break;
950 } 979 }
951 addr = TX_BUF_BASE + (ccsindex << 11); 980 addr = TX_BUF_BASE + (ccsindex << 11);
952 981
953 if (msg_type == DATA_TYPE) { 982 if (msg_type == DATA_TYPE) {
954 local->stats.tx_bytes += len; 983 local->stats.tx_bytes += len;
955 local->stats.tx_packets++; 984 local->stats.tx_packets++;
956 } 985 }
957 986
958 ptx = local->sram + addr; 987 ptx = local->sram + addr;
959 988
960 ray_build_header(local, ptx, msg_type, data); 989 ray_build_header(local, ptx, msg_type, data);
961 if (translate) { 990 if (translate) {
962 offset = translate_frame(local, ptx, data, len); 991 offset = translate_frame(local, ptx, data, len);
963 } 992 } else { /* Encapsulate frame */
964 else { /* Encapsulate frame */ 993 /* TBD TIB length will move address of ptx->var */
965 /* TBD TIB length will move address of ptx->var */ 994 memcpy_toio(&ptx->var, data, len);
966 memcpy_toio(&ptx->var, data, len); 995 offset = 0;
967 offset = 0; 996 }
968 } 997
969 998 /* fill in the CCS */
970 /* fill in the CCS */ 999 pccs = ccs_base(local) + ccsindex;
971 pccs = ccs_base(local) + ccsindex; 1000 len += TX_HEADER_LENGTH + offset;
972 len += TX_HEADER_LENGTH + offset; 1001 writeb(CCS_TX_REQUEST, &pccs->cmd);
973 writeb(CCS_TX_REQUEST, &pccs->cmd); 1002 writeb(addr >> 8, &pccs->var.tx_request.tx_data_ptr[0]);
974 writeb(addr >> 8, &pccs->var.tx_request.tx_data_ptr[0]); 1003 writeb(local->tib_length, &pccs->var.tx_request.tx_data_ptr[1]);
975 writeb(local->tib_length, &pccs->var.tx_request.tx_data_ptr[1]); 1004 writeb(len >> 8, &pccs->var.tx_request.tx_data_length[0]);
976 writeb(len >> 8, &pccs->var.tx_request.tx_data_length[0]); 1005 writeb(len & 0xff, &pccs->var.tx_request.tx_data_length[1]);
977 writeb(len & 0xff, &pccs->var.tx_request.tx_data_length[1]);
978/* TBD still need psm_cam? */ 1006/* TBD still need psm_cam? */
979 writeb(PSM_CAM, &pccs->var.tx_request.pow_sav_mode); 1007 writeb(PSM_CAM, &pccs->var.tx_request.pow_sav_mode);
980 writeb(local->net_default_tx_rate, &pccs->var.tx_request.tx_rate); 1008 writeb(local->net_default_tx_rate, &pccs->var.tx_request.tx_rate);
981 writeb(0, &pccs->var.tx_request.antenna); 1009 writeb(0, &pccs->var.tx_request.antenna);
982 DEBUG(3,"ray_hw_xmit default_tx_rate = 0x%x\n",\ 1010 DEBUG(3, "ray_hw_xmit default_tx_rate = 0x%x\n",
983 local->net_default_tx_rate); 1011 local->net_default_tx_rate);
984 1012
985 /* Interrupt the firmware to process the command */ 1013 /* Interrupt the firmware to process the command */
986 if (interrupt_ecf(local, ccsindex)) { 1014 if (interrupt_ecf(local, ccsindex)) {
987 DEBUG(2,"ray_hw_xmit failed - ECF not ready for intr\n"); 1015 DEBUG(2, "ray_hw_xmit failed - ECF not ready for intr\n");
988/* TBD very inefficient to copy packet to buffer, and then not 1016/* TBD very inefficient to copy packet to buffer, and then not
989 send it, but the alternative is to queue the messages and that 1017 send it, but the alternative is to queue the messages and that
990 won't be done for a while. Maybe set tbusy until a CCS is free? 1018 won't be done for a while. Maybe set tbusy until a CCS is free?
991*/ 1019*/
992 writeb(CCS_BUFFER_FREE, &pccs->buffer_status); 1020 writeb(CCS_BUFFER_FREE, &pccs->buffer_status);
993 return XMIT_NO_INTR; 1021 return XMIT_NO_INTR;
994 } 1022 }
995 return XMIT_OK; 1023 return XMIT_OK;
996} /* end ray_hw_xmit */ 1024} /* end ray_hw_xmit */
1025
997/*===========================================================================*/ 1026/*===========================================================================*/
998static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx, unsigned char *data, 1027static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
999 int len) 1028 unsigned char *data, int len)
1000{ 1029{
1001 __be16 proto = ((struct ethhdr *)data)->h_proto; 1030 __be16 proto = ((struct ethhdr *)data)->h_proto;
1002 if (ntohs(proto) >= 1536) { /* DIX II ethernet frame */ 1031 if (ntohs(proto) >= 1536) { /* DIX II ethernet frame */
1003 DEBUG(3,"ray_cs translate_frame DIX II\n"); 1032 DEBUG(3, "ray_cs translate_frame DIX II\n");
1004 /* Copy LLC header to card buffer */ 1033 /* Copy LLC header to card buffer */
1005 memcpy_toio(&ptx->var, eth2_llc, sizeof(eth2_llc)); 1034 memcpy_toio(&ptx->var, eth2_llc, sizeof(eth2_llc));
1006 memcpy_toio( ((void __iomem *)&ptx->var) + sizeof(eth2_llc), (UCHAR *)&proto, 2); 1035 memcpy_toio(((void __iomem *)&ptx->var) + sizeof(eth2_llc),
1007 if (proto == htons(ETH_P_AARP) || proto == htons(ETH_P_IPX)) { 1036 (UCHAR *) &proto, 2);
1008 /* This is the selective translation table, only 2 entries */ 1037 if (proto == htons(ETH_P_AARP) || proto == htons(ETH_P_IPX)) {
1009 writeb(0xf8, &((struct snaphdr_t __iomem *)ptx->var)->org[3]); 1038 /* This is the selective translation table, only 2 entries */
1010 } 1039 writeb(0xf8,
1011 /* Copy body of ethernet packet without ethernet header */ 1040 &((struct snaphdr_t __iomem *)ptx->var)->org[3]);
1012 memcpy_toio((void __iomem *)&ptx->var + sizeof(struct snaphdr_t), \ 1041 }
1013 data + ETH_HLEN, len - ETH_HLEN); 1042 /* Copy body of ethernet packet without ethernet header */
1014 return (int) sizeof(struct snaphdr_t) - ETH_HLEN; 1043 memcpy_toio((void __iomem *)&ptx->var +
1015 } 1044 sizeof(struct snaphdr_t), data + ETH_HLEN,
1016 else { /* already 802 type, and proto is length */ 1045 len - ETH_HLEN);
1017 DEBUG(3,"ray_cs translate_frame 802\n"); 1046 return (int)sizeof(struct snaphdr_t) - ETH_HLEN;
1018 if (proto == htons(0xffff)) { /* evil netware IPX 802.3 without LLC */ 1047 } else { /* already 802 type, and proto is length */
1019 DEBUG(3,"ray_cs translate_frame evil IPX\n"); 1048 DEBUG(3, "ray_cs translate_frame 802\n");
1020 memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN); 1049 if (proto == htons(0xffff)) { /* evil netware IPX 802.3 without LLC */
1021 return 0 - ETH_HLEN; 1050 DEBUG(3, "ray_cs translate_frame evil IPX\n");
1022 } 1051 memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
1023 memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN); 1052 return 0 - ETH_HLEN;
1024 return 0 - ETH_HLEN; 1053 }
1025 } 1054 memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
1026 /* TBD do other frame types */ 1055 return 0 - ETH_HLEN;
1056 }
1057 /* TBD do other frame types */
1027} /* end translate_frame */ 1058} /* end translate_frame */
1059
1028/*===========================================================================*/ 1060/*===========================================================================*/
1029static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx, UCHAR msg_type, 1061static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
1030 unsigned char *data) 1062 UCHAR msg_type, unsigned char *data)
1031{ 1063{
1032 writeb(PROTOCOL_VER | msg_type, &ptx->mac.frame_ctl_1); 1064 writeb(PROTOCOL_VER | msg_type, &ptx->mac.frame_ctl_1);
1033/*** IEEE 802.11 Address field assignments ************* 1065/*** IEEE 802.11 Address field assignments *************
1034 TODS FROMDS addr_1 addr_2 addr_3 addr_4 1066 TODS FROMDS addr_1 addr_2 addr_3 addr_4
1035Adhoc 0 0 dest src (terminal) BSSID N/A 1067Adhoc 0 0 dest src (terminal) BSSID N/A
1036AP to Terminal 0 1 dest AP(BSSID) source N/A 1068AP to Terminal 0 1 dest AP(BSSID) source N/A
1037Terminal to AP 1 0 AP(BSSID) src (terminal) dest N/A 1069Terminal to AP 1 0 AP(BSSID) src (terminal) dest N/A
1038AP to AP 1 1 dest AP src AP dest source 1070AP to AP 1 1 dest AP src AP dest source
1039*******************************************************/ 1071*******************************************************/
1040 if (local->net_type == ADHOC) { 1072 if (local->net_type == ADHOC) {
1041 writeb(0, &ptx->mac.frame_ctl_2); 1073 writeb(0, &ptx->mac.frame_ctl_2);
1042 memcpy_toio(ptx->mac.addr_1, ((struct ethhdr *)data)->h_dest, 2 * ADDRLEN); 1074 memcpy_toio(ptx->mac.addr_1, ((struct ethhdr *)data)->h_dest,
1043 memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN); 1075 2 * ADDRLEN);
1044 } 1076 memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN);
1045 else /* infrastructure */ 1077 } else { /* infrastructure */
1046 { 1078
1047 if (local->sparm.b4.a_acting_as_ap_status) 1079 if (local->sparm.b4.a_acting_as_ap_status) {
1048 { 1080 writeb(FC2_FROM_DS, &ptx->mac.frame_ctl_2);
1049 writeb(FC2_FROM_DS, &ptx->mac.frame_ctl_2); 1081 memcpy_toio(ptx->mac.addr_1,
1050 memcpy_toio(ptx->mac.addr_1, ((struct ethhdr *)data)->h_dest, ADDRLEN); 1082 ((struct ethhdr *)data)->h_dest, ADDRLEN);
1051 memcpy_toio(ptx->mac.addr_2, local->bss_id, 6); 1083 memcpy_toio(ptx->mac.addr_2, local->bss_id, 6);
1052 memcpy_toio(ptx->mac.addr_3, ((struct ethhdr *)data)->h_source, ADDRLEN); 1084 memcpy_toio(ptx->mac.addr_3,
1053 } 1085 ((struct ethhdr *)data)->h_source, ADDRLEN);
1054 else /* Terminal */ 1086 } else { /* Terminal */
1055 { 1087
1056 writeb(FC2_TO_DS, &ptx->mac.frame_ctl_2); 1088 writeb(FC2_TO_DS, &ptx->mac.frame_ctl_2);
1057 memcpy_toio(ptx->mac.addr_1, local->bss_id, ADDRLEN); 1089 memcpy_toio(ptx->mac.addr_1, local->bss_id, ADDRLEN);
1058 memcpy_toio(ptx->mac.addr_2, ((struct ethhdr *)data)->h_source, ADDRLEN); 1090 memcpy_toio(ptx->mac.addr_2,
1059 memcpy_toio(ptx->mac.addr_3, ((struct ethhdr *)data)->h_dest, ADDRLEN); 1091 ((struct ethhdr *)data)->h_source, ADDRLEN);
1060 } 1092 memcpy_toio(ptx->mac.addr_3,
1061 } 1093 ((struct ethhdr *)data)->h_dest, ADDRLEN);
1094 }
1095 }
1062} /* end encapsulate_frame */ 1096} /* end encapsulate_frame */
1063 1097
1064
1065/*===========================================================================*/ 1098/*===========================================================================*/
1066 1099
1067static void netdev_get_drvinfo(struct net_device *dev, 1100static void netdev_get_drvinfo(struct net_device *dev,
@@ -1071,7 +1104,7 @@ static void netdev_get_drvinfo(struct net_device *dev,
1071} 1104}
1072 1105
1073static const struct ethtool_ops netdev_ethtool_ops = { 1106static const struct ethtool_ops netdev_ethtool_ops = {
1074 .get_drvinfo = netdev_get_drvinfo, 1107 .get_drvinfo = netdev_get_drvinfo,
1075}; 1108};
1076 1109
1077/*====================================================================*/ 1110/*====================================================================*/
@@ -1081,9 +1114,7 @@ static const struct ethtool_ops netdev_ethtool_ops = {
1081 * Wireless Handler : get protocol name 1114 * Wireless Handler : get protocol name
1082 */ 1115 */
1083static int ray_get_name(struct net_device *dev, 1116static int ray_get_name(struct net_device *dev,
1084 struct iw_request_info *info, 1117 struct iw_request_info *info, char *cwrq, char *extra)
1085 char *cwrq,
1086 char *extra)
1087{ 1118{
1088 strcpy(cwrq, "IEEE 802.11-FH"); 1119 strcpy(cwrq, "IEEE 802.11-FH");
1089 return 0; 1120 return 0;
@@ -1095,14 +1126,13 @@ static int ray_get_name(struct net_device *dev,
1095 */ 1126 */
1096static int ray_set_freq(struct net_device *dev, 1127static int ray_set_freq(struct net_device *dev,
1097 struct iw_request_info *info, 1128 struct iw_request_info *info,
1098 struct iw_freq *fwrq, 1129 struct iw_freq *fwrq, char *extra)
1099 char *extra)
1100{ 1130{
1101 ray_dev_t *local = netdev_priv(dev); 1131 ray_dev_t *local = netdev_priv(dev);
1102 int err = -EINPROGRESS; /* Call commit handler */ 1132 int err = -EINPROGRESS; /* Call commit handler */
1103 1133
1104 /* Reject if card is already initialised */ 1134 /* Reject if card is already initialised */
1105 if(local->card_status != CARD_AWAITING_PARAM) 1135 if (local->card_status != CARD_AWAITING_PARAM)
1106 return -EBUSY; 1136 return -EBUSY;
1107 1137
1108 /* Setting by channel number */ 1138 /* Setting by channel number */
@@ -1113,15 +1143,14 @@ static int ray_set_freq(struct net_device *dev,
1113 1143
1114 return err; 1144 return err;
1115} 1145}
1116 1146
1117/*------------------------------------------------------------------*/ 1147/*------------------------------------------------------------------*/
1118/* 1148/*
1119 * Wireless Handler : get frequency 1149 * Wireless Handler : get frequency
1120 */ 1150 */
1121static int ray_get_freq(struct net_device *dev, 1151static int ray_get_freq(struct net_device *dev,
1122 struct iw_request_info *info, 1152 struct iw_request_info *info,
1123 struct iw_freq *fwrq, 1153 struct iw_freq *fwrq, char *extra)
1124 char *extra)
1125{ 1154{
1126 ray_dev_t *local = netdev_priv(dev); 1155 ray_dev_t *local = netdev_priv(dev);
1127 1156
@@ -1136,22 +1165,21 @@ static int ray_get_freq(struct net_device *dev,
1136 */ 1165 */
1137static int ray_set_essid(struct net_device *dev, 1166static int ray_set_essid(struct net_device *dev,
1138 struct iw_request_info *info, 1167 struct iw_request_info *info,
1139 struct iw_point *dwrq, 1168 struct iw_point *dwrq, char *extra)
1140 char *extra)
1141{ 1169{
1142 ray_dev_t *local = netdev_priv(dev); 1170 ray_dev_t *local = netdev_priv(dev);
1143 1171
1144 /* Reject if card is already initialised */ 1172 /* Reject if card is already initialised */
1145 if(local->card_status != CARD_AWAITING_PARAM) 1173 if (local->card_status != CARD_AWAITING_PARAM)
1146 return -EBUSY; 1174 return -EBUSY;
1147 1175
1148 /* Check if we asked for `any' */ 1176 /* Check if we asked for `any' */
1149 if(dwrq->flags == 0) { 1177 if (dwrq->flags == 0) {
1150 /* Corey : can you do that ? */ 1178 /* Corey : can you do that ? */
1151 return -EOPNOTSUPP; 1179 return -EOPNOTSUPP;
1152 } else { 1180 } else {
1153 /* Check the size of the string */ 1181 /* Check the size of the string */
1154 if(dwrq->length > IW_ESSID_MAX_SIZE) { 1182 if (dwrq->length > IW_ESSID_MAX_SIZE) {
1155 return -E2BIG; 1183 return -E2BIG;
1156 } 1184 }
1157 1185
@@ -1160,7 +1188,7 @@ static int ray_set_essid(struct net_device *dev,
1160 memcpy(local->sparm.b5.a_current_ess_id, extra, dwrq->length); 1188 memcpy(local->sparm.b5.a_current_ess_id, extra, dwrq->length);
1161 } 1189 }
1162 1190
1163 return -EINPROGRESS; /* Call commit handler */ 1191 return -EINPROGRESS; /* Call commit handler */
1164} 1192}
1165 1193
1166/*------------------------------------------------------------------*/ 1194/*------------------------------------------------------------------*/
@@ -1169,8 +1197,7 @@ static int ray_set_essid(struct net_device *dev,
1169 */ 1197 */
1170static int ray_get_essid(struct net_device *dev, 1198static int ray_get_essid(struct net_device *dev,
1171 struct iw_request_info *info, 1199 struct iw_request_info *info,
1172 struct iw_point *dwrq, 1200 struct iw_point *dwrq, char *extra)
1173 char *extra)
1174{ 1201{
1175 ray_dev_t *local = netdev_priv(dev); 1202 ray_dev_t *local = netdev_priv(dev);
1176 1203
@@ -1179,7 +1206,7 @@ static int ray_get_essid(struct net_device *dev,
1179 1206
1180 /* Push it out ! */ 1207 /* Push it out ! */
1181 dwrq->length = strlen(extra); 1208 dwrq->length = strlen(extra);
1182 dwrq->flags = 1; /* active */ 1209 dwrq->flags = 1; /* active */
1183 1210
1184 return 0; 1211 return 0;
1185} 1212}
@@ -1189,9 +1216,8 @@ static int ray_get_essid(struct net_device *dev,
1189 * Wireless Handler : get AP address 1216 * Wireless Handler : get AP address
1190 */ 1217 */
1191static int ray_get_wap(struct net_device *dev, 1218static int ray_get_wap(struct net_device *dev,
1192 struct iw_request_info *info, 1219 struct iw_request_info *info,
1193 struct sockaddr *awrq, 1220 struct sockaddr *awrq, char *extra)
1194 char *extra)
1195{ 1221{
1196 ray_dev_t *local = netdev_priv(dev); 1222 ray_dev_t *local = netdev_priv(dev);
1197 1223
@@ -1207,25 +1233,24 @@ static int ray_get_wap(struct net_device *dev,
1207 */ 1233 */
1208static int ray_set_rate(struct net_device *dev, 1234static int ray_set_rate(struct net_device *dev,
1209 struct iw_request_info *info, 1235 struct iw_request_info *info,
1210 struct iw_param *vwrq, 1236 struct iw_param *vwrq, char *extra)
1211 char *extra)
1212{ 1237{
1213 ray_dev_t *local = netdev_priv(dev); 1238 ray_dev_t *local = netdev_priv(dev);
1214 1239
1215 /* Reject if card is already initialised */ 1240 /* Reject if card is already initialised */
1216 if(local->card_status != CARD_AWAITING_PARAM) 1241 if (local->card_status != CARD_AWAITING_PARAM)
1217 return -EBUSY; 1242 return -EBUSY;
1218 1243
1219 /* Check if rate is in range */ 1244 /* Check if rate is in range */
1220 if((vwrq->value != 1000000) && (vwrq->value != 2000000)) 1245 if ((vwrq->value != 1000000) && (vwrq->value != 2000000))
1221 return -EINVAL; 1246 return -EINVAL;
1222 1247
1223 /* Hack for 1.5 Mb/s instead of 2 Mb/s */ 1248 /* Hack for 1.5 Mb/s instead of 2 Mb/s */
1224 if((local->fw_ver == 0x55) && /* Please check */ 1249 if ((local->fw_ver == 0x55) && /* Please check */
1225 (vwrq->value == 2000000)) 1250 (vwrq->value == 2000000))
1226 local->net_default_tx_rate = 3; 1251 local->net_default_tx_rate = 3;
1227 else 1252 else
1228 local->net_default_tx_rate = vwrq->value/500000; 1253 local->net_default_tx_rate = vwrq->value / 500000;
1229 1254
1230 return 0; 1255 return 0;
1231} 1256}
@@ -1236,16 +1261,15 @@ static int ray_set_rate(struct net_device *dev,
1236 */ 1261 */
1237static int ray_get_rate(struct net_device *dev, 1262static int ray_get_rate(struct net_device *dev,
1238 struct iw_request_info *info, 1263 struct iw_request_info *info,
1239 struct iw_param *vwrq, 1264 struct iw_param *vwrq, char *extra)
1240 char *extra)
1241{ 1265{
1242 ray_dev_t *local = netdev_priv(dev); 1266 ray_dev_t *local = netdev_priv(dev);
1243 1267
1244 if(local->net_default_tx_rate == 3) 1268 if (local->net_default_tx_rate == 3)
1245 vwrq->value = 2000000; /* Hum... */ 1269 vwrq->value = 2000000; /* Hum... */
1246 else 1270 else
1247 vwrq->value = local->net_default_tx_rate * 500000; 1271 vwrq->value = local->net_default_tx_rate * 500000;
1248 vwrq->fixed = 0; /* We are in auto mode */ 1272 vwrq->fixed = 0; /* We are in auto mode */
1249 1273
1250 return 0; 1274 return 0;
1251} 1275}
@@ -1256,43 +1280,40 @@ static int ray_get_rate(struct net_device *dev,
1256 */ 1280 */
1257static int ray_set_rts(struct net_device *dev, 1281static int ray_set_rts(struct net_device *dev,
1258 struct iw_request_info *info, 1282 struct iw_request_info *info,
1259 struct iw_param *vwrq, 1283 struct iw_param *vwrq, char *extra)
1260 char *extra)
1261{ 1284{
1262 ray_dev_t *local = netdev_priv(dev); 1285 ray_dev_t *local = netdev_priv(dev);
1263 int rthr = vwrq->value; 1286 int rthr = vwrq->value;
1264 1287
1265 /* Reject if card is already initialised */ 1288 /* Reject if card is already initialised */
1266 if(local->card_status != CARD_AWAITING_PARAM) 1289 if (local->card_status != CARD_AWAITING_PARAM)
1267 return -EBUSY; 1290 return -EBUSY;
1268 1291
1269 /* if(wrq->u.rts.fixed == 0) we should complain */ 1292 /* if(wrq->u.rts.fixed == 0) we should complain */
1270 if(vwrq->disabled) 1293 if (vwrq->disabled)
1271 rthr = 32767; 1294 rthr = 32767;
1272 else { 1295 else {
1273 if((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */ 1296 if ((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */
1274 return -EINVAL; 1297 return -EINVAL;
1275 } 1298 }
1276 local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF; 1299 local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF;
1277 local->sparm.b5.a_rts_threshold[1] = rthr & 0xFF; 1300 local->sparm.b5.a_rts_threshold[1] = rthr & 0xFF;
1278 1301
1279 return -EINPROGRESS; /* Call commit handler */ 1302 return -EINPROGRESS; /* Call commit handler */
1280} 1303}
1281 1304
1282
1283/*------------------------------------------------------------------*/ 1305/*------------------------------------------------------------------*/
1284/* 1306/*
1285 * Wireless Handler : get RTS threshold 1307 * Wireless Handler : get RTS threshold
1286 */ 1308 */
1287static int ray_get_rts(struct net_device *dev, 1309static int ray_get_rts(struct net_device *dev,
1288 struct iw_request_info *info, 1310 struct iw_request_info *info,
1289 struct iw_param *vwrq, 1311 struct iw_param *vwrq, char *extra)
1290 char *extra)
1291{ 1312{
1292 ray_dev_t *local = netdev_priv(dev); 1313 ray_dev_t *local = netdev_priv(dev);
1293 1314
1294 vwrq->value = (local->sparm.b5.a_rts_threshold[0] << 8) 1315 vwrq->value = (local->sparm.b5.a_rts_threshold[0] << 8)
1295 + local->sparm.b5.a_rts_threshold[1]; 1316 + local->sparm.b5.a_rts_threshold[1];
1296 vwrq->disabled = (vwrq->value == 32767); 1317 vwrq->disabled = (vwrq->value == 32767);
1297 vwrq->fixed = 1; 1318 vwrq->fixed = 1;
1298 1319
@@ -1305,27 +1326,26 @@ static int ray_get_rts(struct net_device *dev,
1305 */ 1326 */
1306static int ray_set_frag(struct net_device *dev, 1327static int ray_set_frag(struct net_device *dev,
1307 struct iw_request_info *info, 1328 struct iw_request_info *info,
1308 struct iw_param *vwrq, 1329 struct iw_param *vwrq, char *extra)
1309 char *extra)
1310{ 1330{
1311 ray_dev_t *local = netdev_priv(dev); 1331 ray_dev_t *local = netdev_priv(dev);
1312 int fthr = vwrq->value; 1332 int fthr = vwrq->value;
1313 1333
1314 /* Reject if card is already initialised */ 1334 /* Reject if card is already initialised */
1315 if(local->card_status != CARD_AWAITING_PARAM) 1335 if (local->card_status != CARD_AWAITING_PARAM)
1316 return -EBUSY; 1336 return -EBUSY;
1317 1337
1318 /* if(wrq->u.frag.fixed == 0) should complain */ 1338 /* if(wrq->u.frag.fixed == 0) should complain */
1319 if(vwrq->disabled) 1339 if (vwrq->disabled)
1320 fthr = 32767; 1340 fthr = 32767;
1321 else { 1341 else {
1322 if((fthr < 256) || (fthr > 2347)) /* To check out ! */ 1342 if ((fthr < 256) || (fthr > 2347)) /* To check out ! */
1323 return -EINVAL; 1343 return -EINVAL;
1324 } 1344 }
1325 local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF; 1345 local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF;
1326 local->sparm.b5.a_frag_threshold[1] = fthr & 0xFF; 1346 local->sparm.b5.a_frag_threshold[1] = fthr & 0xFF;
1327 1347
1328 return -EINPROGRESS; /* Call commit handler */ 1348 return -EINPROGRESS; /* Call commit handler */
1329} 1349}
1330 1350
1331/*------------------------------------------------------------------*/ 1351/*------------------------------------------------------------------*/
@@ -1334,13 +1354,12 @@ static int ray_set_frag(struct net_device *dev,
1334 */ 1354 */
1335static int ray_get_frag(struct net_device *dev, 1355static int ray_get_frag(struct net_device *dev,
1336 struct iw_request_info *info, 1356 struct iw_request_info *info,
1337 struct iw_param *vwrq, 1357 struct iw_param *vwrq, char *extra)
1338 char *extra)
1339{ 1358{
1340 ray_dev_t *local = netdev_priv(dev); 1359 ray_dev_t *local = netdev_priv(dev);
1341 1360
1342 vwrq->value = (local->sparm.b5.a_frag_threshold[0] << 8) 1361 vwrq->value = (local->sparm.b5.a_frag_threshold[0] << 8)
1343 + local->sparm.b5.a_frag_threshold[1]; 1362 + local->sparm.b5.a_frag_threshold[1];
1344 vwrq->disabled = (vwrq->value == 32767); 1363 vwrq->disabled = (vwrq->value == 32767);
1345 vwrq->fixed = 1; 1364 vwrq->fixed = 1;
1346 1365
@@ -1352,23 +1371,20 @@ static int ray_get_frag(struct net_device *dev,
1352 * Wireless Handler : set Mode of Operation 1371 * Wireless Handler : set Mode of Operation
1353 */ 1372 */
1354static int ray_set_mode(struct net_device *dev, 1373static int ray_set_mode(struct net_device *dev,
1355 struct iw_request_info *info, 1374 struct iw_request_info *info, __u32 *uwrq, char *extra)
1356 __u32 *uwrq,
1357 char *extra)
1358{ 1375{
1359 ray_dev_t *local = netdev_priv(dev); 1376 ray_dev_t *local = netdev_priv(dev);
1360 int err = -EINPROGRESS; /* Call commit handler */ 1377 int err = -EINPROGRESS; /* Call commit handler */
1361 char card_mode = 1; 1378 char card_mode = 1;
1362 1379
1363 /* Reject if card is already initialised */ 1380 /* Reject if card is already initialised */
1364 if(local->card_status != CARD_AWAITING_PARAM) 1381 if (local->card_status != CARD_AWAITING_PARAM)
1365 return -EBUSY; 1382 return -EBUSY;
1366 1383
1367 switch (*uwrq) 1384 switch (*uwrq) {
1368 {
1369 case IW_MODE_ADHOC: 1385 case IW_MODE_ADHOC:
1370 card_mode = 0; 1386 card_mode = 0;
1371 // Fall through 1387 /* Fall through */
1372 case IW_MODE_INFRA: 1388 case IW_MODE_INFRA:
1373 local->sparm.b5.a_network_type = card_mode; 1389 local->sparm.b5.a_network_type = card_mode;
1374 break; 1390 break;
@@ -1384,13 +1400,11 @@ static int ray_set_mode(struct net_device *dev,
1384 * Wireless Handler : get Mode of Operation 1400 * Wireless Handler : get Mode of Operation
1385 */ 1401 */
1386static int ray_get_mode(struct net_device *dev, 1402static int ray_get_mode(struct net_device *dev,
1387 struct iw_request_info *info, 1403 struct iw_request_info *info, __u32 *uwrq, char *extra)
1388 __u32 *uwrq,
1389 char *extra)
1390{ 1404{
1391 ray_dev_t *local = netdev_priv(dev); 1405 ray_dev_t *local = netdev_priv(dev);
1392 1406
1393 if(local->sparm.b5.a_network_type) 1407 if (local->sparm.b5.a_network_type)
1394 *uwrq = IW_MODE_INFRA; 1408 *uwrq = IW_MODE_INFRA;
1395 else 1409 else
1396 *uwrq = IW_MODE_ADHOC; 1410 *uwrq = IW_MODE_ADHOC;
@@ -1404,12 +1418,11 @@ static int ray_get_mode(struct net_device *dev,
1404 */ 1418 */
1405static int ray_get_range(struct net_device *dev, 1419static int ray_get_range(struct net_device *dev,
1406 struct iw_request_info *info, 1420 struct iw_request_info *info,
1407 struct iw_point *dwrq, 1421 struct iw_point *dwrq, char *extra)
1408 char *extra)
1409{ 1422{
1410 struct iw_range *range = (struct iw_range *) extra; 1423 struct iw_range *range = (struct iw_range *)extra;
1411 1424
1412 memset((char *) range, 0, sizeof(struct iw_range)); 1425 memset((char *)range, 0, sizeof(struct iw_range));
1413 1426
1414 /* Set the length (very important for backward compatibility) */ 1427 /* Set the length (very important for backward compatibility) */
1415 dwrq->length = sizeof(struct iw_range); 1428 dwrq->length = sizeof(struct iw_range);
@@ -1420,7 +1433,7 @@ static int ray_get_range(struct net_device *dev,
1420 1433
1421 /* Set information in the range struct */ 1434 /* Set information in the range struct */
1422 range->throughput = 1.1 * 1000 * 1000; /* Put the right number here */ 1435 range->throughput = 1.1 * 1000 * 1000; /* Put the right number here */
1423 range->num_channels = hop_pattern_length[(int)country]; 1436 range->num_channels = hop_pattern_length[(int)country];
1424 range->num_frequency = 0; 1437 range->num_frequency = 0;
1425 range->max_qual.qual = 0; 1438 range->max_qual.qual = 0;
1426 range->max_qual.level = 255; /* What's the correct value ? */ 1439 range->max_qual.level = 255; /* What's the correct value ? */
@@ -1437,8 +1450,7 @@ static int ray_get_range(struct net_device *dev,
1437 */ 1450 */
1438static int ray_set_framing(struct net_device *dev, 1451static int ray_set_framing(struct net_device *dev,
1439 struct iw_request_info *info, 1452 struct iw_request_info *info,
1440 union iwreq_data *wrqu, 1453 union iwreq_data *wrqu, char *extra)
1441 char *extra)
1442{ 1454{
1443 translate = *(extra); /* Set framing mode */ 1455 translate = *(extra); /* Set framing mode */
1444 1456
@@ -1451,8 +1463,7 @@ static int ray_set_framing(struct net_device *dev,
1451 */ 1463 */
1452static int ray_get_framing(struct net_device *dev, 1464static int ray_get_framing(struct net_device *dev,
1453 struct iw_request_info *info, 1465 struct iw_request_info *info,
1454 union iwreq_data *wrqu, 1466 union iwreq_data *wrqu, char *extra)
1455 char *extra)
1456{ 1467{
1457 *(extra) = translate; 1468 *(extra) = translate;
1458 1469
@@ -1465,8 +1476,7 @@ static int ray_get_framing(struct net_device *dev,
1465 */ 1476 */
1466static int ray_get_country(struct net_device *dev, 1477static int ray_get_country(struct net_device *dev,
1467 struct iw_request_info *info, 1478 struct iw_request_info *info,
1468 union iwreq_data *wrqu, 1479 union iwreq_data *wrqu, char *extra)
1469 char *extra)
1470{ 1480{
1471 *(extra) = country; 1481 *(extra) = country;
1472 1482
@@ -1477,11 +1487,10 @@ static int ray_get_country(struct net_device *dev,
1477/* 1487/*
1478 * Commit handler : called after a bunch of SET operations 1488 * Commit handler : called after a bunch of SET operations
1479 */ 1489 */
1480static int ray_commit(struct net_device *dev, 1490static int ray_commit(struct net_device *dev, struct iw_request_info *info, /* NULL */
1481 struct iw_request_info *info, /* NULL */ 1491 void *zwrq, /* NULL */
1482 void *zwrq, /* NULL */ 1492 char *extra)
1483 char *extra) /* NULL */ 1493{ /* NULL */
1484{
1485 return 0; 1494 return 0;
1486} 1495}
1487 1496
@@ -1489,33 +1498,34 @@ static int ray_commit(struct net_device *dev,
1489/* 1498/*
1490 * Stats handler : return Wireless Stats 1499 * Stats handler : return Wireless Stats
1491 */ 1500 */
1492static iw_stats * ray_get_wireless_stats(struct net_device * dev) 1501static iw_stats *ray_get_wireless_stats(struct net_device *dev)
1493{ 1502{
1494 ray_dev_t * local = netdev_priv(dev); 1503 ray_dev_t *local = netdev_priv(dev);
1495 struct pcmcia_device *link = local->finder; 1504 struct pcmcia_device *link = local->finder;
1496 struct status __iomem *p = local->sram + STATUS_BASE; 1505 struct status __iomem *p = local->sram + STATUS_BASE;
1497 1506
1498 if(local == (ray_dev_t *) NULL) 1507 if (local == (ray_dev_t *) NULL)
1499 return (iw_stats *) NULL; 1508 return (iw_stats *) NULL;
1500 1509
1501 local->wstats.status = local->card_status; 1510 local->wstats.status = local->card_status;
1502#ifdef WIRELESS_SPY 1511#ifdef WIRELESS_SPY
1503 if((local->spy_data.spy_number > 0) && (local->sparm.b5.a_network_type == 0)) 1512 if ((local->spy_data.spy_number > 0)
1504 { 1513 && (local->sparm.b5.a_network_type == 0)) {
1505 /* Get it from the first node in spy list */ 1514 /* Get it from the first node in spy list */
1506 local->wstats.qual.qual = local->spy_data.spy_stat[0].qual; 1515 local->wstats.qual.qual = local->spy_data.spy_stat[0].qual;
1507 local->wstats.qual.level = local->spy_data.spy_stat[0].level; 1516 local->wstats.qual.level = local->spy_data.spy_stat[0].level;
1508 local->wstats.qual.noise = local->spy_data.spy_stat[0].noise; 1517 local->wstats.qual.noise = local->spy_data.spy_stat[0].noise;
1509 local->wstats.qual.updated = local->spy_data.spy_stat[0].updated; 1518 local->wstats.qual.updated =
1510 } 1519 local->spy_data.spy_stat[0].updated;
1520 }
1511#endif /* WIRELESS_SPY */ 1521#endif /* WIRELESS_SPY */
1512 1522
1513 if(pcmcia_dev_present(link)) { 1523 if (pcmcia_dev_present(link)) {
1514 local->wstats.qual.noise = readb(&p->rxnoise); 1524 local->wstats.qual.noise = readb(&p->rxnoise);
1515 local->wstats.qual.updated |= 4; 1525 local->wstats.qual.updated |= 4;
1516 } 1526 }
1517 1527
1518 return &local->wstats; 1528 return &local->wstats;
1519} /* end ray_get_wireless_stats */ 1529} /* end ray_get_wireless_stats */
1520 1530
1521/*------------------------------------------------------------------*/ 1531/*------------------------------------------------------------------*/
@@ -1523,1159 +1533,1264 @@ static iw_stats * ray_get_wireless_stats(struct net_device * dev)
1523 * Structures to export the Wireless Handlers 1533 * Structures to export the Wireless Handlers
1524 */ 1534 */
1525 1535
1526static const iw_handler ray_handler[] = { 1536static const iw_handler ray_handler[] = {
1527 [SIOCSIWCOMMIT-SIOCIWFIRST] = (iw_handler) ray_commit, 1537 [SIOCSIWCOMMIT - SIOCIWFIRST] = (iw_handler) ray_commit,
1528 [SIOCGIWNAME -SIOCIWFIRST] = (iw_handler) ray_get_name, 1538 [SIOCGIWNAME - SIOCIWFIRST] = (iw_handler) ray_get_name,
1529 [SIOCSIWFREQ -SIOCIWFIRST] = (iw_handler) ray_set_freq, 1539 [SIOCSIWFREQ - SIOCIWFIRST] = (iw_handler) ray_set_freq,
1530 [SIOCGIWFREQ -SIOCIWFIRST] = (iw_handler) ray_get_freq, 1540 [SIOCGIWFREQ - SIOCIWFIRST] = (iw_handler) ray_get_freq,
1531 [SIOCSIWMODE -SIOCIWFIRST] = (iw_handler) ray_set_mode, 1541 [SIOCSIWMODE - SIOCIWFIRST] = (iw_handler) ray_set_mode,
1532 [SIOCGIWMODE -SIOCIWFIRST] = (iw_handler) ray_get_mode, 1542 [SIOCGIWMODE - SIOCIWFIRST] = (iw_handler) ray_get_mode,
1533 [SIOCGIWRANGE -SIOCIWFIRST] = (iw_handler) ray_get_range, 1543 [SIOCGIWRANGE - SIOCIWFIRST] = (iw_handler) ray_get_range,
1534#ifdef WIRELESS_SPY 1544#ifdef WIRELESS_SPY
1535 [SIOCSIWSPY -SIOCIWFIRST] = (iw_handler) iw_handler_set_spy, 1545 [SIOCSIWSPY - SIOCIWFIRST] = (iw_handler) iw_handler_set_spy,
1536 [SIOCGIWSPY -SIOCIWFIRST] = (iw_handler) iw_handler_get_spy, 1546 [SIOCGIWSPY - SIOCIWFIRST] = (iw_handler) iw_handler_get_spy,
1537 [SIOCSIWTHRSPY-SIOCIWFIRST] = (iw_handler) iw_handler_set_thrspy, 1547 [SIOCSIWTHRSPY - SIOCIWFIRST] = (iw_handler) iw_handler_set_thrspy,
1538 [SIOCGIWTHRSPY-SIOCIWFIRST] = (iw_handler) iw_handler_get_thrspy, 1548 [SIOCGIWTHRSPY - SIOCIWFIRST] = (iw_handler) iw_handler_get_thrspy,
1539#endif /* WIRELESS_SPY */ 1549#endif /* WIRELESS_SPY */
1540 [SIOCGIWAP -SIOCIWFIRST] = (iw_handler) ray_get_wap, 1550 [SIOCGIWAP - SIOCIWFIRST] = (iw_handler) ray_get_wap,
1541 [SIOCSIWESSID -SIOCIWFIRST] = (iw_handler) ray_set_essid, 1551 [SIOCSIWESSID - SIOCIWFIRST] = (iw_handler) ray_set_essid,
1542 [SIOCGIWESSID -SIOCIWFIRST] = (iw_handler) ray_get_essid, 1552 [SIOCGIWESSID - SIOCIWFIRST] = (iw_handler) ray_get_essid,
1543 [SIOCSIWRATE -SIOCIWFIRST] = (iw_handler) ray_set_rate, 1553 [SIOCSIWRATE - SIOCIWFIRST] = (iw_handler) ray_set_rate,
1544 [SIOCGIWRATE -SIOCIWFIRST] = (iw_handler) ray_get_rate, 1554 [SIOCGIWRATE - SIOCIWFIRST] = (iw_handler) ray_get_rate,
1545 [SIOCSIWRTS -SIOCIWFIRST] = (iw_handler) ray_set_rts, 1555 [SIOCSIWRTS - SIOCIWFIRST] = (iw_handler) ray_set_rts,
1546 [SIOCGIWRTS -SIOCIWFIRST] = (iw_handler) ray_get_rts, 1556 [SIOCGIWRTS - SIOCIWFIRST] = (iw_handler) ray_get_rts,
1547 [SIOCSIWFRAG -SIOCIWFIRST] = (iw_handler) ray_set_frag, 1557 [SIOCSIWFRAG - SIOCIWFIRST] = (iw_handler) ray_set_frag,
1548 [SIOCGIWFRAG -SIOCIWFIRST] = (iw_handler) ray_get_frag, 1558 [SIOCGIWFRAG - SIOCIWFIRST] = (iw_handler) ray_get_frag,
1549}; 1559};
1550 1560
1551#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */ 1561#define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */
1552#define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1 /* Get framing mode */ 1562#define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1 /* Get framing mode */
1553#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */ 1563#define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */
1554 1564
1555static const iw_handler ray_private_handler[] = { 1565static const iw_handler ray_private_handler[] = {
1556 [0] = (iw_handler) ray_set_framing, 1566 [0] = (iw_handler) ray_set_framing,
1557 [1] = (iw_handler) ray_get_framing, 1567 [1] = (iw_handler) ray_get_framing,
1558 [3] = (iw_handler) ray_get_country, 1568 [3] = (iw_handler) ray_get_country,
1559}; 1569};
1560 1570
1561static const struct iw_priv_args ray_private_args[] = { 1571static const struct iw_priv_args ray_private_args[] = {
1562/* cmd, set_args, get_args, name */ 1572/* cmd, set_args, get_args, name */
1563{ SIOCSIPFRAMING, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0, "set_framing" }, 1573 {SIOCSIPFRAMING, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0,
1564{ SIOCGIPFRAMING, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_framing" }, 1574 "set_framing"},
1565{ SIOCGIPCOUNTRY, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, "get_country" }, 1575 {SIOCGIPFRAMING, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
1576 "get_framing"},
1577 {SIOCGIPCOUNTRY, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
1578 "get_country"},
1566}; 1579};
1567 1580
1568static const struct iw_handler_def ray_handler_def = 1581static const struct iw_handler_def ray_handler_def = {
1569{ 1582 .num_standard = ARRAY_SIZE(ray_handler),
1570 .num_standard = ARRAY_SIZE(ray_handler), 1583 .num_private = ARRAY_SIZE(ray_private_handler),
1571 .num_private = ARRAY_SIZE(ray_private_handler),
1572 .num_private_args = ARRAY_SIZE(ray_private_args), 1584 .num_private_args = ARRAY_SIZE(ray_private_args),
1573 .standard = ray_handler, 1585 .standard = ray_handler,
1574 .private = ray_private_handler, 1586 .private = ray_private_handler,
1575 .private_args = ray_private_args, 1587 .private_args = ray_private_args,
1576 .get_wireless_stats = ray_get_wireless_stats, 1588 .get_wireless_stats = ray_get_wireless_stats,
1577}; 1589};
1578 1590
1579/*===========================================================================*/ 1591/*===========================================================================*/
1580static int ray_open(struct net_device *dev) 1592static int ray_open(struct net_device *dev)
1581{ 1593{
1582 ray_dev_t *local = netdev_priv(dev); 1594 ray_dev_t *local = netdev_priv(dev);
1583 struct pcmcia_device *link; 1595 struct pcmcia_device *link;
1584 link = local->finder; 1596 link = local->finder;
1585
1586 DEBUG(1, "ray_open('%s')\n", dev->name);
1587 1597
1588 if (link->open == 0) 1598 DEBUG(1, "ray_open('%s')\n", dev->name);
1589 local->num_multi = 0;
1590 link->open++;
1591 1599
1592 /* If the card is not started, time to start it ! - Jean II */ 1600 if (link->open == 0)
1593 if(local->card_status == CARD_AWAITING_PARAM) { 1601 local->num_multi = 0;
1594 int i; 1602 link->open++;
1595 1603
1596 DEBUG(1,"ray_open: doing init now !\n"); 1604 /* If the card is not started, time to start it ! - Jean II */
1605 if (local->card_status == CARD_AWAITING_PARAM) {
1606 int i;
1597 1607
1598 /* Download startup parameters */ 1608 DEBUG(1, "ray_open: doing init now !\n");
1599 if ( (i = dl_startup_params(dev)) < 0) 1609
1600 { 1610 /* Download startup parameters */
1601 printk(KERN_INFO "ray_dev_init dl_startup_params failed - " 1611 if ((i = dl_startup_params(dev)) < 0) {
1602 "returns 0x%x\n",i); 1612 printk(KERN_INFO
1603 return -1; 1613 "ray_dev_init dl_startup_params failed - "
1604 } 1614 "returns 0x%x\n", i);
1605 } 1615 return -1;
1606 1616 }
1607 if (sniffer) netif_stop_queue(dev); 1617 }
1608 else netif_start_queue(dev); 1618
1609 1619 if (sniffer)
1610 DEBUG(2,"ray_open ending\n"); 1620 netif_stop_queue(dev);
1611 return 0; 1621 else
1622 netif_start_queue(dev);
1623
1624 DEBUG(2, "ray_open ending\n");
1625 return 0;
1612} /* end ray_open */ 1626} /* end ray_open */
1627
1613/*===========================================================================*/ 1628/*===========================================================================*/
1614static int ray_dev_close(struct net_device *dev) 1629static int ray_dev_close(struct net_device *dev)
1615{ 1630{
1616 ray_dev_t *local = netdev_priv(dev); 1631 ray_dev_t *local = netdev_priv(dev);
1617 struct pcmcia_device *link; 1632 struct pcmcia_device *link;
1618 link = local->finder; 1633 link = local->finder;
1619 1634
1620 DEBUG(1, "ray_dev_close('%s')\n", dev->name); 1635 DEBUG(1, "ray_dev_close('%s')\n", dev->name);
1621 1636
1622 link->open--; 1637 link->open--;
1623 netif_stop_queue(dev); 1638 netif_stop_queue(dev);
1624 1639
1625 /* In here, we should stop the hardware (stop card from beeing active) 1640 /* In here, we should stop the hardware (stop card from beeing active)
1626 * and set local->card_status to CARD_AWAITING_PARAM, so that while the 1641 * and set local->card_status to CARD_AWAITING_PARAM, so that while the
1627 * card is closed we can chage its configuration. 1642 * card is closed we can chage its configuration.
1628 * Probably also need a COR reset to get sane state - Jean II */ 1643 * Probably also need a COR reset to get sane state - Jean II */
1629 1644
1630 return 0; 1645 return 0;
1631} /* end ray_dev_close */ 1646} /* end ray_dev_close */
1647
1632/*===========================================================================*/ 1648/*===========================================================================*/
1633static void ray_reset(struct net_device *dev) { 1649static void ray_reset(struct net_device *dev)
1634 DEBUG(1,"ray_reset entered\n"); 1650{
1635 return; 1651 DEBUG(1, "ray_reset entered\n");
1652 return;
1636} 1653}
1654
1637/*===========================================================================*/ 1655/*===========================================================================*/
1638/* Cause a firmware interrupt if it is ready for one */ 1656/* Cause a firmware interrupt if it is ready for one */
1639/* Return nonzero if not ready */ 1657/* Return nonzero if not ready */
1640static int interrupt_ecf(ray_dev_t *local, int ccs) 1658static int interrupt_ecf(ray_dev_t *local, int ccs)
1641{ 1659{
1642 int i = 50; 1660 int i = 50;
1643 struct pcmcia_device *link = local->finder; 1661 struct pcmcia_device *link = local->finder;
1644 1662
1645 if (!(pcmcia_dev_present(link))) { 1663 if (!(pcmcia_dev_present(link))) {
1646 DEBUG(2,"ray_cs interrupt_ecf - device not present\n"); 1664 DEBUG(2, "ray_cs interrupt_ecf - device not present\n");
1647 return -1; 1665 return -1;
1648 } 1666 }
1649 DEBUG(2,"interrupt_ecf(local=%p, ccs = 0x%x\n",local,ccs); 1667 DEBUG(2, "interrupt_ecf(local=%p, ccs = 0x%x\n", local, ccs);
1650 1668
1651 while ( i && 1669 while (i &&
1652 (readb(local->amem + CIS_OFFSET + ECF_INTR_OFFSET) & ECF_INTR_SET)) 1670 (readb(local->amem + CIS_OFFSET + ECF_INTR_OFFSET) &
1653 i--; 1671 ECF_INTR_SET))
1654 if (i == 0) { 1672 i--;
1655 DEBUG(2,"ray_cs interrupt_ecf card not ready for interrupt\n"); 1673 if (i == 0) {
1656 return -1; 1674 DEBUG(2, "ray_cs interrupt_ecf card not ready for interrupt\n");
1657 } 1675 return -1;
1676 }
1658 /* Fill the mailbox, then kick the card */ 1677 /* Fill the mailbox, then kick the card */
1659 writeb(ccs, local->sram + SCB_BASE); 1678 writeb(ccs, local->sram + SCB_BASE);
1660 writeb(ECF_INTR_SET, local->amem + CIS_OFFSET + ECF_INTR_OFFSET); 1679 writeb(ECF_INTR_SET, local->amem + CIS_OFFSET + ECF_INTR_OFFSET);
1661 return 0; 1680 return 0;
1662} /* interrupt_ecf */ 1681} /* interrupt_ecf */
1682
1663/*===========================================================================*/ 1683/*===========================================================================*/
1664/* Get next free transmit CCS */ 1684/* Get next free transmit CCS */
1665/* Return - index of current tx ccs */ 1685/* Return - index of current tx ccs */
1666static int get_free_tx_ccs(ray_dev_t *local) 1686static int get_free_tx_ccs(ray_dev_t *local)
1667{ 1687{
1668 int i; 1688 int i;
1669 struct ccs __iomem *pccs = ccs_base(local); 1689 struct ccs __iomem *pccs = ccs_base(local);
1670 struct pcmcia_device *link = local->finder; 1690 struct pcmcia_device *link = local->finder;
1671 1691
1672 if (!(pcmcia_dev_present(link))) { 1692 if (!(pcmcia_dev_present(link))) {
1673 DEBUG(2,"ray_cs get_free_tx_ccs - device not present\n"); 1693 DEBUG(2, "ray_cs get_free_tx_ccs - device not present\n");
1674 return ECARDGONE; 1694 return ECARDGONE;
1675 } 1695 }
1676 1696
1677 if (test_and_set_bit(0,&local->tx_ccs_lock)) { 1697 if (test_and_set_bit(0, &local->tx_ccs_lock)) {
1678 DEBUG(1,"ray_cs tx_ccs_lock busy\n"); 1698 DEBUG(1, "ray_cs tx_ccs_lock busy\n");
1679 return ECCSBUSY; 1699 return ECCSBUSY;
1680 } 1700 }
1681 1701
1682 for (i=0; i < NUMBER_OF_TX_CCS; i++) { 1702 for (i = 0; i < NUMBER_OF_TX_CCS; i++) {
1683 if (readb(&(pccs+i)->buffer_status) == CCS_BUFFER_FREE) { 1703 if (readb(&(pccs + i)->buffer_status) == CCS_BUFFER_FREE) {
1684 writeb(CCS_BUFFER_BUSY, &(pccs+i)->buffer_status); 1704 writeb(CCS_BUFFER_BUSY, &(pccs + i)->buffer_status);
1685 writeb(CCS_END_LIST, &(pccs+i)->link); 1705 writeb(CCS_END_LIST, &(pccs + i)->link);
1686 local->tx_ccs_lock = 0; 1706 local->tx_ccs_lock = 0;
1687 return i; 1707 return i;
1688 } 1708 }
1689 } 1709 }
1690 local->tx_ccs_lock = 0; 1710 local->tx_ccs_lock = 0;
1691 DEBUG(2,"ray_cs ERROR no free tx CCS for raylink card\n"); 1711 DEBUG(2, "ray_cs ERROR no free tx CCS for raylink card\n");
1692 return ECCSFULL; 1712 return ECCSFULL;
1693} /* get_free_tx_ccs */ 1713} /* get_free_tx_ccs */
1714
1694/*===========================================================================*/ 1715/*===========================================================================*/
1695/* Get next free CCS */ 1716/* Get next free CCS */
1696/* Return - index of current ccs */ 1717/* Return - index of current ccs */
1697static int get_free_ccs(ray_dev_t *local) 1718static int get_free_ccs(ray_dev_t *local)
1698{ 1719{
1699 int i; 1720 int i;
1700 struct ccs __iomem *pccs = ccs_base(local); 1721 struct ccs __iomem *pccs = ccs_base(local);
1701 struct pcmcia_device *link = local->finder; 1722 struct pcmcia_device *link = local->finder;
1702 1723
1703 if (!(pcmcia_dev_present(link))) { 1724 if (!(pcmcia_dev_present(link))) {
1704 DEBUG(2,"ray_cs get_free_ccs - device not present\n"); 1725 DEBUG(2, "ray_cs get_free_ccs - device not present\n");
1705 return ECARDGONE; 1726 return ECARDGONE;
1706 } 1727 }
1707 if (test_and_set_bit(0,&local->ccs_lock)) { 1728 if (test_and_set_bit(0, &local->ccs_lock)) {
1708 DEBUG(1,"ray_cs ccs_lock busy\n"); 1729 DEBUG(1, "ray_cs ccs_lock busy\n");
1709 return ECCSBUSY; 1730 return ECCSBUSY;
1710 } 1731 }
1711 1732
1712 for (i = NUMBER_OF_TX_CCS; i < NUMBER_OF_CCS; i++) { 1733 for (i = NUMBER_OF_TX_CCS; i < NUMBER_OF_CCS; i++) {
1713 if (readb(&(pccs+i)->buffer_status) == CCS_BUFFER_FREE) { 1734 if (readb(&(pccs + i)->buffer_status) == CCS_BUFFER_FREE) {
1714 writeb(CCS_BUFFER_BUSY, &(pccs+i)->buffer_status); 1735 writeb(CCS_BUFFER_BUSY, &(pccs + i)->buffer_status);
1715 writeb(CCS_END_LIST, &(pccs+i)->link); 1736 writeb(CCS_END_LIST, &(pccs + i)->link);
1716 local->ccs_lock = 0; 1737 local->ccs_lock = 0;
1717 return i; 1738 return i;
1718 } 1739 }
1719 } 1740 }
1720 local->ccs_lock = 0; 1741 local->ccs_lock = 0;
1721 DEBUG(1,"ray_cs ERROR no free CCS for raylink card\n"); 1742 DEBUG(1, "ray_cs ERROR no free CCS for raylink card\n");
1722 return ECCSFULL; 1743 return ECCSFULL;
1723} /* get_free_ccs */ 1744} /* get_free_ccs */
1745
1724/*===========================================================================*/ 1746/*===========================================================================*/
1725static void authenticate_timeout(u_long data) 1747static void authenticate_timeout(u_long data)
1726{ 1748{
1727 ray_dev_t *local = (ray_dev_t *)data; 1749 ray_dev_t *local = (ray_dev_t *) data;
1728 del_timer(&local->timer); 1750 del_timer(&local->timer);
1729 printk(KERN_INFO "ray_cs Authentication with access point failed" 1751 printk(KERN_INFO "ray_cs Authentication with access point failed"
1730 " - timeout\n"); 1752 " - timeout\n");
1731 join_net((u_long)local); 1753 join_net((u_long) local);
1732} 1754}
1755
1733/*===========================================================================*/ 1756/*===========================================================================*/
1734static int asc_to_int(char a) 1757static int asc_to_int(char a)
1735{ 1758{
1736 if (a < '0') return -1; 1759 if (a < '0')
1737 if (a <= '9') return (a - '0'); 1760 return -1;
1738 if (a < 'A') return -1; 1761 if (a <= '9')
1739 if (a <= 'F') return (10 + a - 'A'); 1762 return (a - '0');
1740 if (a < 'a') return -1; 1763 if (a < 'A')
1741 if (a <= 'f') return (10 + a - 'a'); 1764 return -1;
1742 return -1; 1765 if (a <= 'F')
1766 return (10 + a - 'A');
1767 if (a < 'a')
1768 return -1;
1769 if (a <= 'f')
1770 return (10 + a - 'a');
1771 return -1;
1743} 1772}
1773
1744/*===========================================================================*/ 1774/*===========================================================================*/
1745static int parse_addr(char *in_str, UCHAR *out) 1775static int parse_addr(char *in_str, UCHAR *out)
1746{ 1776{
1747 int len; 1777 int len;
1748 int i,j,k; 1778 int i, j, k;
1749 int status; 1779 int status;
1750 1780
1751 if (in_str == NULL) return 0; 1781 if (in_str == NULL)
1752 if ((len = strlen(in_str)) < 2) return 0; 1782 return 0;
1753 memset(out, 0, ADDRLEN); 1783 if ((len = strlen(in_str)) < 2)
1754 1784 return 0;
1755 status = 1; 1785 memset(out, 0, ADDRLEN);
1756 j = len - 1; 1786
1757 if (j > 12) j = 12; 1787 status = 1;
1758 i = 5; 1788 j = len - 1;
1759 1789 if (j > 12)
1760 while (j > 0) 1790 j = 12;
1761 { 1791 i = 5;
1762 if ((k = asc_to_int(in_str[j--])) != -1) out[i] = k; 1792
1763 else return 0; 1793 while (j > 0) {
1764 1794 if ((k = asc_to_int(in_str[j--])) != -1)
1765 if (j == 0) break; 1795 out[i] = k;
1766 if ((k = asc_to_int(in_str[j--])) != -1) out[i] += k << 4; 1796 else
1767 else return 0; 1797 return 0;
1768 if (!i--) break; 1798
1769 } 1799 if (j == 0)
1770 return status; 1800 break;
1801 if ((k = asc_to_int(in_str[j--])) != -1)
1802 out[i] += k << 4;
1803 else
1804 return 0;
1805 if (!i--)
1806 break;
1807 }
1808 return status;
1771} 1809}
1810
1772/*===========================================================================*/ 1811/*===========================================================================*/
1773static struct net_device_stats *ray_get_stats(struct net_device *dev) 1812static struct net_device_stats *ray_get_stats(struct net_device *dev)
1774{ 1813{
1775 ray_dev_t *local = netdev_priv(dev); 1814 ray_dev_t *local = netdev_priv(dev);
1776 struct pcmcia_device *link = local->finder; 1815 struct pcmcia_device *link = local->finder;
1777 struct status __iomem *p = local->sram + STATUS_BASE; 1816 struct status __iomem *p = local->sram + STATUS_BASE;
1778 if (!(pcmcia_dev_present(link))) { 1817 if (!(pcmcia_dev_present(link))) {
1779 DEBUG(2,"ray_cs net_device_stats - device not present\n"); 1818 DEBUG(2, "ray_cs net_device_stats - device not present\n");
1780 return &local->stats; 1819 return &local->stats;
1781 } 1820 }
1782 if (readb(&p->mrx_overflow_for_host)) 1821 if (readb(&p->mrx_overflow_for_host)) {
1783 { 1822 local->stats.rx_over_errors += swab16(readw(&p->mrx_overflow));
1784 local->stats.rx_over_errors += swab16(readw(&p->mrx_overflow)); 1823 writeb(0, &p->mrx_overflow);
1785 writeb(0,&p->mrx_overflow); 1824 writeb(0, &p->mrx_overflow_for_host);
1786 writeb(0,&p->mrx_overflow_for_host); 1825 }
1787 } 1826 if (readb(&p->mrx_checksum_error_for_host)) {
1788 if (readb(&p->mrx_checksum_error_for_host)) 1827 local->stats.rx_crc_errors +=
1789 { 1828 swab16(readw(&p->mrx_checksum_error));
1790 local->stats.rx_crc_errors += swab16(readw(&p->mrx_checksum_error)); 1829 writeb(0, &p->mrx_checksum_error);
1791 writeb(0,&p->mrx_checksum_error); 1830 writeb(0, &p->mrx_checksum_error_for_host);
1792 writeb(0,&p->mrx_checksum_error_for_host); 1831 }
1793 } 1832 if (readb(&p->rx_hec_error_for_host)) {
1794 if (readb(&p->rx_hec_error_for_host)) 1833 local->stats.rx_frame_errors += swab16(readw(&p->rx_hec_error));
1795 { 1834 writeb(0, &p->rx_hec_error);
1796 local->stats.rx_frame_errors += swab16(readw(&p->rx_hec_error)); 1835 writeb(0, &p->rx_hec_error_for_host);
1797 writeb(0,&p->rx_hec_error); 1836 }
1798 writeb(0,&p->rx_hec_error_for_host); 1837 return &local->stats;
1799 }
1800 return &local->stats;
1801} 1838}
1839
1802/*===========================================================================*/ 1840/*===========================================================================*/
1803static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len) 1841static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value,
1804{ 1842 int len)
1805 ray_dev_t *local = netdev_priv(dev); 1843{
1806 struct pcmcia_device *link = local->finder; 1844 ray_dev_t *local = netdev_priv(dev);
1807 int ccsindex; 1845 struct pcmcia_device *link = local->finder;
1808 int i; 1846 int ccsindex;
1809 struct ccs __iomem *pccs; 1847 int i;
1810 1848 struct ccs __iomem *pccs;
1811 if (!(pcmcia_dev_present(link))) { 1849
1812 DEBUG(2,"ray_update_parm - device not present\n"); 1850 if (!(pcmcia_dev_present(link))) {
1813 return; 1851 DEBUG(2, "ray_update_parm - device not present\n");
1814 } 1852 return;
1815 1853 }
1816 if ((ccsindex = get_free_ccs(local)) < 0) 1854
1817 { 1855 if ((ccsindex = get_free_ccs(local)) < 0) {
1818 DEBUG(0,"ray_update_parm - No free ccs\n"); 1856 DEBUG(0, "ray_update_parm - No free ccs\n");
1819 return; 1857 return;
1820 } 1858 }
1821 pccs = ccs_base(local) + ccsindex; 1859 pccs = ccs_base(local) + ccsindex;
1822 writeb(CCS_UPDATE_PARAMS, &pccs->cmd); 1860 writeb(CCS_UPDATE_PARAMS, &pccs->cmd);
1823 writeb(objid, &pccs->var.update_param.object_id); 1861 writeb(objid, &pccs->var.update_param.object_id);
1824 writeb(1, &pccs->var.update_param.number_objects); 1862 writeb(1, &pccs->var.update_param.number_objects);
1825 writeb(0, &pccs->var.update_param.failure_cause); 1863 writeb(0, &pccs->var.update_param.failure_cause);
1826 for (i=0; i<len; i++) { 1864 for (i = 0; i < len; i++) {
1827 writeb(value[i], local->sram + HOST_TO_ECF_BASE); 1865 writeb(value[i], local->sram + HOST_TO_ECF_BASE);
1828 } 1866 }
1829 /* Interrupt the firmware to process the command */ 1867 /* Interrupt the firmware to process the command */
1830 if (interrupt_ecf(local, ccsindex)) { 1868 if (interrupt_ecf(local, ccsindex)) {
1831 DEBUG(0,"ray_cs associate failed - ECF not ready for intr\n"); 1869 DEBUG(0, "ray_cs associate failed - ECF not ready for intr\n");
1832 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status); 1870 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
1833 } 1871 }
1834} 1872}
1873
1835/*===========================================================================*/ 1874/*===========================================================================*/
1836static void ray_update_multi_list(struct net_device *dev, int all) 1875static void ray_update_multi_list(struct net_device *dev, int all)
1837{ 1876{
1838 struct dev_mc_list *dmi, **dmip; 1877 struct dev_mc_list *dmi, **dmip;
1839 int ccsindex; 1878 int ccsindex;
1840 struct ccs __iomem *pccs; 1879 struct ccs __iomem *pccs;
1841 int i = 0; 1880 int i = 0;
1842 ray_dev_t *local = netdev_priv(dev); 1881 ray_dev_t *local = netdev_priv(dev);
1843 struct pcmcia_device *link = local->finder; 1882 struct pcmcia_device *link = local->finder;
1844 void __iomem *p = local->sram + HOST_TO_ECF_BASE; 1883 void __iomem *p = local->sram + HOST_TO_ECF_BASE;
1845 1884
1846 if (!(pcmcia_dev_present(link))) { 1885 if (!(pcmcia_dev_present(link))) {
1847 DEBUG(2,"ray_update_multi_list - device not present\n"); 1886 DEBUG(2, "ray_update_multi_list - device not present\n");
1848 return; 1887 return;
1849 } 1888 } else
1850 else 1889 DEBUG(2, "ray_update_multi_list(%p)\n", dev);
1851 DEBUG(2,"ray_update_multi_list(%p)\n",dev); 1890 if ((ccsindex = get_free_ccs(local)) < 0) {
1852 if ((ccsindex = get_free_ccs(local)) < 0) 1891 DEBUG(1, "ray_update_multi - No free ccs\n");
1853 { 1892 return;
1854 DEBUG(1,"ray_update_multi - No free ccs\n"); 1893 }
1855 return; 1894 pccs = ccs_base(local) + ccsindex;
1856 } 1895 writeb(CCS_UPDATE_MULTICAST_LIST, &pccs->cmd);
1857 pccs = ccs_base(local) + ccsindex; 1896
1858 writeb(CCS_UPDATE_MULTICAST_LIST, &pccs->cmd); 1897 if (all) {
1859 1898 writeb(0xff, &pccs->var);
1860 if (all) { 1899 local->num_multi = 0xff;
1861 writeb(0xff, &pccs->var); 1900 } else {
1862 local->num_multi = 0xff; 1901 /* Copy the kernel's list of MC addresses to card */
1863 } 1902 for (dmip = &dev->mc_list; (dmi = *dmip) != NULL;
1864 else { 1903 dmip = &dmi->next) {
1865 /* Copy the kernel's list of MC addresses to card */ 1904 memcpy_toio(p, dmi->dmi_addr, ETH_ALEN);
1866 for (dmip=&dev->mc_list; (dmi=*dmip)!=NULL; dmip=&dmi->next) { 1905 DEBUG(1,
1867 memcpy_toio(p, dmi->dmi_addr, ETH_ALEN); 1906 "ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n",
1868 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]); 1907 dmi->dmi_addr[0], dmi->dmi_addr[1],
1869 p += ETH_ALEN; 1908 dmi->dmi_addr[2], dmi->dmi_addr[3],
1870 i++; 1909 dmi->dmi_addr[4], dmi->dmi_addr[5]);
1871 } 1910 p += ETH_ALEN;
1872 if (i > 256/ADDRLEN) i = 256/ADDRLEN; 1911 i++;
1873 writeb((UCHAR)i, &pccs->var); 1912 }
1874 DEBUG(1,"ray_cs update_multi %d addresses in list\n", i); 1913 if (i > 256 / ADDRLEN)
1875 /* Interrupt the firmware to process the command */ 1914 i = 256 / ADDRLEN;
1876 local->num_multi = i; 1915 writeb((UCHAR) i, &pccs->var);
1877 } 1916 DEBUG(1, "ray_cs update_multi %d addresses in list\n", i);
1878 if (interrupt_ecf(local, ccsindex)) { 1917 /* Interrupt the firmware to process the command */
1879 DEBUG(1,"ray_cs update_multi failed - ECF not ready for intr\n"); 1918 local->num_multi = i;
1880 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status); 1919 }
1881 } 1920 if (interrupt_ecf(local, ccsindex)) {
1921 DEBUG(1,
1922 "ray_cs update_multi failed - ECF not ready for intr\n");
1923 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
1924 }
1882} /* end ray_update_multi_list */ 1925} /* end ray_update_multi_list */
1926
1883/*===========================================================================*/ 1927/*===========================================================================*/
1884static void set_multicast_list(struct net_device *dev) 1928static void set_multicast_list(struct net_device *dev)
1885{ 1929{
1886 ray_dev_t *local = netdev_priv(dev); 1930 ray_dev_t *local = netdev_priv(dev);
1887 UCHAR promisc; 1931 UCHAR promisc;
1888 1932
1889 DEBUG(2,"ray_cs set_multicast_list(%p)\n",dev); 1933 DEBUG(2, "ray_cs set_multicast_list(%p)\n", dev);
1890 1934
1891 if (dev->flags & IFF_PROMISC) 1935 if (dev->flags & IFF_PROMISC) {
1892 { 1936 if (local->sparm.b5.a_promiscuous_mode == 0) {
1893 if (local->sparm.b5.a_promiscuous_mode == 0) { 1937 DEBUG(1, "ray_cs set_multicast_list promisc on\n");
1894 DEBUG(1,"ray_cs set_multicast_list promisc on\n"); 1938 local->sparm.b5.a_promiscuous_mode = 1;
1895 local->sparm.b5.a_promiscuous_mode = 1; 1939 promisc = 1;
1896 promisc = 1; 1940 ray_update_parm(dev, OBJID_promiscuous_mode,
1897 ray_update_parm(dev, OBJID_promiscuous_mode, \ 1941 &promisc, sizeof(promisc));
1898 &promisc, sizeof(promisc)); 1942 }
1899 } 1943 } else {
1900 } 1944 if (local->sparm.b5.a_promiscuous_mode == 1) {
1901 else { 1945 DEBUG(1, "ray_cs set_multicast_list promisc off\n");
1902 if (local->sparm.b5.a_promiscuous_mode == 1) { 1946 local->sparm.b5.a_promiscuous_mode = 0;
1903 DEBUG(1,"ray_cs set_multicast_list promisc off\n"); 1947 promisc = 0;
1904 local->sparm.b5.a_promiscuous_mode = 0; 1948 ray_update_parm(dev, OBJID_promiscuous_mode,
1905 promisc = 0; 1949 &promisc, sizeof(promisc));
1906 ray_update_parm(dev, OBJID_promiscuous_mode, \ 1950 }
1907 &promisc, sizeof(promisc)); 1951 }
1908 } 1952
1909 } 1953 if (dev->flags & IFF_ALLMULTI)
1910 1954 ray_update_multi_list(dev, 1);
1911 if (dev->flags & IFF_ALLMULTI) ray_update_multi_list(dev, 1); 1955 else {
1912 else 1956 if (local->num_multi != dev->mc_count)
1913 { 1957 ray_update_multi_list(dev, 0);
1914 if (local->num_multi != dev->mc_count) ray_update_multi_list(dev, 0); 1958 }
1915 }
1916} /* end set_multicast_list */ 1959} /* end set_multicast_list */
1960
1917/*============================================================================= 1961/*=============================================================================
1918 * All routines below here are run at interrupt time. 1962 * All routines below here are run at interrupt time.
1919=============================================================================*/ 1963=============================================================================*/
1920static irqreturn_t ray_interrupt(int irq, void *dev_id) 1964static irqreturn_t ray_interrupt(int irq, void *dev_id)
1921{ 1965{
1922 struct net_device *dev = (struct net_device *)dev_id; 1966 struct net_device *dev = (struct net_device *)dev_id;
1923 struct pcmcia_device *link; 1967 struct pcmcia_device *link;
1924 ray_dev_t *local; 1968 ray_dev_t *local;
1925 struct ccs __iomem *pccs; 1969 struct ccs __iomem *pccs;
1926 struct rcs __iomem *prcs; 1970 struct rcs __iomem *prcs;
1927 UCHAR rcsindex; 1971 UCHAR rcsindex;
1928 UCHAR tmp; 1972 UCHAR tmp;
1929 UCHAR cmd; 1973 UCHAR cmd;
1930 UCHAR status; 1974 UCHAR status;
1931 1975
1932 if (dev == NULL) /* Note that we want interrupts with dev->start == 0 */ 1976 if (dev == NULL) /* Note that we want interrupts with dev->start == 0 */
1933 return IRQ_NONE; 1977 return IRQ_NONE;
1934 1978
1935 DEBUG(4,"ray_cs: interrupt for *dev=%p\n",dev); 1979 DEBUG(4, "ray_cs: interrupt for *dev=%p\n", dev);
1936 1980
1937 local = netdev_priv(dev); 1981 local = netdev_priv(dev);
1938 link = (struct pcmcia_device *)local->finder; 1982 link = (struct pcmcia_device *)local->finder;
1939 if (!pcmcia_dev_present(link)) { 1983 if (!pcmcia_dev_present(link)) {
1940 DEBUG(2,"ray_cs interrupt from device not present or suspended.\n"); 1984 DEBUG(2,
1941 return IRQ_NONE; 1985 "ray_cs interrupt from device not present or suspended.\n");
1942 } 1986 return IRQ_NONE;
1943 rcsindex = readb(&((struct scb __iomem *)(local->sram))->rcs_index); 1987 }
1944 1988 rcsindex = readb(&((struct scb __iomem *)(local->sram))->rcs_index);
1945 if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) 1989
1946 { 1990 if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
1947 DEBUG(1,"ray_cs interrupt bad rcsindex = 0x%x\n",rcsindex); 1991 DEBUG(1, "ray_cs interrupt bad rcsindex = 0x%x\n", rcsindex);
1948 clear_interrupt(local); 1992 clear_interrupt(local);
1949 return IRQ_HANDLED; 1993 return IRQ_HANDLED;
1950 } 1994 }
1951 if (rcsindex < NUMBER_OF_CCS) /* If it's a returned CCS */ 1995 if (rcsindex < NUMBER_OF_CCS) { /* If it's a returned CCS */
1952 { 1996 pccs = ccs_base(local) + rcsindex;
1953 pccs = ccs_base(local) + rcsindex; 1997 cmd = readb(&pccs->cmd);
1954 cmd = readb(&pccs->cmd); 1998 status = readb(&pccs->buffer_status);
1955 status = readb(&pccs->buffer_status); 1999 switch (cmd) {
1956 switch (cmd) 2000 case CCS_DOWNLOAD_STARTUP_PARAMS: /* Happens in firmware someday */
1957 { 2001 del_timer(&local->timer);
1958 case CCS_DOWNLOAD_STARTUP_PARAMS: /* Happens in firmware someday */ 2002 if (status == CCS_COMMAND_COMPLETE) {
1959 del_timer(&local->timer); 2003 DEBUG(1,
1960 if (status == CCS_COMMAND_COMPLETE) { 2004 "ray_cs interrupt download_startup_parameters OK\n");
1961 DEBUG(1,"ray_cs interrupt download_startup_parameters OK\n"); 2005 } else {
1962 } 2006 DEBUG(1,
1963 else { 2007 "ray_cs interrupt download_startup_parameters fail\n");
1964 DEBUG(1,"ray_cs interrupt download_startup_parameters fail\n"); 2008 }
1965 } 2009 break;
1966 break; 2010 case CCS_UPDATE_PARAMS:
1967 case CCS_UPDATE_PARAMS: 2011 DEBUG(1, "ray_cs interrupt update params done\n");
1968 DEBUG(1,"ray_cs interrupt update params done\n"); 2012 if (status != CCS_COMMAND_COMPLETE) {
1969 if (status != CCS_COMMAND_COMPLETE) { 2013 tmp =
1970 tmp = readb(&pccs->var.update_param.failure_cause); 2014 readb(&pccs->var.update_param.
1971 DEBUG(0,"ray_cs interrupt update params failed - reason %d\n",tmp); 2015 failure_cause);
1972 } 2016 DEBUG(0,
1973 break; 2017 "ray_cs interrupt update params failed - reason %d\n",
1974 case CCS_REPORT_PARAMS: 2018 tmp);
1975 DEBUG(1,"ray_cs interrupt report params done\n"); 2019 }
1976 break; 2020 break;
1977 case CCS_UPDATE_MULTICAST_LIST: /* Note that this CCS isn't returned */ 2021 case CCS_REPORT_PARAMS:
1978 DEBUG(1,"ray_cs interrupt CCS Update Multicast List done\n"); 2022 DEBUG(1, "ray_cs interrupt report params done\n");
1979 break; 2023 break;
1980 case CCS_UPDATE_POWER_SAVINGS_MODE: 2024 case CCS_UPDATE_MULTICAST_LIST: /* Note that this CCS isn't returned */
1981 DEBUG(1,"ray_cs interrupt update power save mode done\n"); 2025 DEBUG(1,
1982 break; 2026 "ray_cs interrupt CCS Update Multicast List done\n");
1983 case CCS_START_NETWORK: 2027 break;
1984 case CCS_JOIN_NETWORK: 2028 case CCS_UPDATE_POWER_SAVINGS_MODE:
1985 if (status == CCS_COMMAND_COMPLETE) { 2029 DEBUG(1,
1986 if (readb(&pccs->var.start_network.net_initiated) == 1) { 2030 "ray_cs interrupt update power save mode done\n");
1987 DEBUG(0,"ray_cs interrupt network \"%s\" started\n",\ 2031 break;
1988 local->sparm.b4.a_current_ess_id); 2032 case CCS_START_NETWORK:
1989 } 2033 case CCS_JOIN_NETWORK:
1990 else { 2034 if (status == CCS_COMMAND_COMPLETE) {
1991 DEBUG(0,"ray_cs interrupt network \"%s\" joined\n",\ 2035 if (readb
1992 local->sparm.b4.a_current_ess_id); 2036 (&pccs->var.start_network.net_initiated) ==
1993 } 2037 1) {
1994 memcpy_fromio(&local->bss_id,pccs->var.start_network.bssid,ADDRLEN); 2038 DEBUG(0,
1995 2039 "ray_cs interrupt network \"%s\" started\n",
1996 if (local->fw_ver == 0x55) local->net_default_tx_rate = 3; 2040 local->sparm.b4.a_current_ess_id);
1997 else local->net_default_tx_rate = 2041 } else {
1998 readb(&pccs->var.start_network.net_default_tx_rate); 2042 DEBUG(0,
1999 local->encryption = readb(&pccs->var.start_network.encryption); 2043 "ray_cs interrupt network \"%s\" joined\n",
2000 if (!sniffer && (local->net_type == INFRA) 2044 local->sparm.b4.a_current_ess_id);
2001 && !(local->sparm.b4.a_acting_as_ap_status)) { 2045 }
2002 authenticate(local); 2046 memcpy_fromio(&local->bss_id,
2003 } 2047 pccs->var.start_network.bssid,
2004 local->card_status = CARD_ACQ_COMPLETE; 2048 ADDRLEN);
2005 } 2049
2006 else { 2050 if (local->fw_ver == 0x55)
2007 local->card_status = CARD_ACQ_FAILED; 2051 local->net_default_tx_rate = 3;
2008 2052 else
2009 del_timer(&local->timer); 2053 local->net_default_tx_rate =
2010 local->timer.expires = jiffies + HZ*5; 2054 readb(&pccs->var.start_network.
2011 local->timer.data = (long)local; 2055 net_default_tx_rate);
2012 if (status == CCS_START_NETWORK) { 2056 local->encryption =
2013 DEBUG(0,"ray_cs interrupt network \"%s\" start failed\n",\ 2057 readb(&pccs->var.start_network.encryption);
2014 local->sparm.b4.a_current_ess_id); 2058 if (!sniffer && (local->net_type == INFRA)
2015 local->timer.function = &start_net; 2059 && !(local->sparm.b4.a_acting_as_ap_status)) {
2016 } 2060 authenticate(local);
2017 else { 2061 }
2018 DEBUG(0,"ray_cs interrupt network \"%s\" join failed\n",\ 2062 local->card_status = CARD_ACQ_COMPLETE;
2019 local->sparm.b4.a_current_ess_id); 2063 } else {
2020 local->timer.function = &join_net; 2064 local->card_status = CARD_ACQ_FAILED;
2021 } 2065
2022 add_timer(&local->timer); 2066 del_timer(&local->timer);
2023 } 2067 local->timer.expires = jiffies + HZ * 5;
2024 break; 2068 local->timer.data = (long)local;
2025 case CCS_START_ASSOCIATION: 2069 if (status == CCS_START_NETWORK) {
2026 if (status == CCS_COMMAND_COMPLETE) { 2070 DEBUG(0,
2027 local->card_status = CARD_ASSOC_COMPLETE; 2071 "ray_cs interrupt network \"%s\" start failed\n",
2028 DEBUG(0,"ray_cs association successful\n"); 2072 local->sparm.b4.a_current_ess_id);
2029 } 2073 local->timer.function = &start_net;
2030 else 2074 } else {
2031 { 2075 DEBUG(0,
2032 DEBUG(0,"ray_cs association failed,\n"); 2076 "ray_cs interrupt network \"%s\" join failed\n",
2033 local->card_status = CARD_ASSOC_FAILED; 2077 local->sparm.b4.a_current_ess_id);
2034 join_net((u_long)local); 2078 local->timer.function = &join_net;
2035 } 2079 }
2036 break; 2080 add_timer(&local->timer);
2037 case CCS_TX_REQUEST: 2081 }
2038 if (status == CCS_COMMAND_COMPLETE) { 2082 break;
2039 DEBUG(3,"ray_cs interrupt tx request complete\n"); 2083 case CCS_START_ASSOCIATION:
2040 } 2084 if (status == CCS_COMMAND_COMPLETE) {
2041 else { 2085 local->card_status = CARD_ASSOC_COMPLETE;
2042 DEBUG(1,"ray_cs interrupt tx request failed\n"); 2086 DEBUG(0, "ray_cs association successful\n");
2043 } 2087 } else {
2044 if (!sniffer) netif_start_queue(dev); 2088 DEBUG(0, "ray_cs association failed,\n");
2045 netif_wake_queue(dev); 2089 local->card_status = CARD_ASSOC_FAILED;
2046 break; 2090 join_net((u_long) local);
2047 case CCS_TEST_MEMORY: 2091 }
2048 DEBUG(1,"ray_cs interrupt mem test done\n"); 2092 break;
2049 break; 2093 case CCS_TX_REQUEST:
2050 case CCS_SHUTDOWN: 2094 if (status == CCS_COMMAND_COMPLETE) {
2051 DEBUG(1,"ray_cs interrupt Unexpected CCS returned - Shutdown\n"); 2095 DEBUG(3,
2052 break; 2096 "ray_cs interrupt tx request complete\n");
2053 case CCS_DUMP_MEMORY: 2097 } else {
2054 DEBUG(1,"ray_cs interrupt dump memory done\n"); 2098 DEBUG(1,
2055 break; 2099 "ray_cs interrupt tx request failed\n");
2056 case CCS_START_TIMER: 2100 }
2057 DEBUG(2,"ray_cs interrupt DING - raylink timer expired\n"); 2101 if (!sniffer)
2058 break; 2102 netif_start_queue(dev);
2059 default: 2103 netif_wake_queue(dev);
2060 DEBUG(1,"ray_cs interrupt Unexpected CCS 0x%x returned 0x%x\n",\ 2104 break;
2061 rcsindex, cmd); 2105 case CCS_TEST_MEMORY:
2062 } 2106 DEBUG(1, "ray_cs interrupt mem test done\n");
2063 writeb(CCS_BUFFER_FREE, &pccs->buffer_status); 2107 break;
2064 } 2108 case CCS_SHUTDOWN:
2065 else /* It's an RCS */ 2109 DEBUG(1,
2066 { 2110 "ray_cs interrupt Unexpected CCS returned - Shutdown\n");
2067 prcs = rcs_base(local) + rcsindex; 2111 break;
2068 2112 case CCS_DUMP_MEMORY:
2069 switch (readb(&prcs->interrupt_id)) 2113 DEBUG(1, "ray_cs interrupt dump memory done\n");
2070 { 2114 break;
2071 case PROCESS_RX_PACKET: 2115 case CCS_START_TIMER:
2072 ray_rx(dev, local, prcs); 2116 DEBUG(2,
2073 break; 2117 "ray_cs interrupt DING - raylink timer expired\n");
2074 case REJOIN_NET_COMPLETE: 2118 break;
2075 DEBUG(1,"ray_cs interrupt rejoin net complete\n"); 2119 default:
2076 local->card_status = CARD_ACQ_COMPLETE; 2120 DEBUG(1,
2077 /* do we need to clear tx buffers CCS's? */ 2121 "ray_cs interrupt Unexpected CCS 0x%x returned 0x%x\n",
2078 if (local->sparm.b4.a_network_type == ADHOC) { 2122 rcsindex, cmd);
2079 if (!sniffer) netif_start_queue(dev); 2123 }
2080 } 2124 writeb(CCS_BUFFER_FREE, &pccs->buffer_status);
2081 else { 2125 } else { /* It's an RCS */
2082 memcpy_fromio(&local->bss_id, prcs->var.rejoin_net_complete.bssid, ADDRLEN); 2126
2083 DEBUG(1,"ray_cs new BSSID = %02x%02x%02x%02x%02x%02x\n",\ 2127 prcs = rcs_base(local) + rcsindex;
2084 local->bss_id[0], local->bss_id[1], local->bss_id[2],\ 2128
2085 local->bss_id[3], local->bss_id[4], local->bss_id[5]); 2129 switch (readb(&prcs->interrupt_id)) {
2086 if (!sniffer) authenticate(local); 2130 case PROCESS_RX_PACKET:
2087 } 2131 ray_rx(dev, local, prcs);
2088 break; 2132 break;
2089 case ROAMING_INITIATED: 2133 case REJOIN_NET_COMPLETE:
2090 DEBUG(1,"ray_cs interrupt roaming initiated\n"); 2134 DEBUG(1, "ray_cs interrupt rejoin net complete\n");
2091 netif_stop_queue(dev); 2135 local->card_status = CARD_ACQ_COMPLETE;
2092 local->card_status = CARD_DOING_ACQ; 2136 /* do we need to clear tx buffers CCS's? */
2093 break; 2137 if (local->sparm.b4.a_network_type == ADHOC) {
2094 case JAPAN_CALL_SIGN_RXD: 2138 if (!sniffer)
2095 DEBUG(1,"ray_cs interrupt japan call sign rx\n"); 2139 netif_start_queue(dev);
2096 break; 2140 } else {
2097 default: 2141 memcpy_fromio(&local->bss_id,
2098 DEBUG(1,"ray_cs Unexpected interrupt for RCS 0x%x cmd = 0x%x\n",\ 2142 prcs->var.rejoin_net_complete.
2099 rcsindex, (unsigned int) readb(&prcs->interrupt_id)); 2143 bssid, ADDRLEN);
2100 break; 2144 DEBUG(1,
2101 } 2145 "ray_cs new BSSID = %02x%02x%02x%02x%02x%02x\n",
2102 writeb(CCS_BUFFER_FREE, &prcs->buffer_status); 2146 local->bss_id[0], local->bss_id[1],
2103 } 2147 local->bss_id[2], local->bss_id[3],
2104 clear_interrupt(local); 2148 local->bss_id[4], local->bss_id[5]);
2105 return IRQ_HANDLED; 2149 if (!sniffer)
2150 authenticate(local);
2151 }
2152 break;
2153 case ROAMING_INITIATED:
2154 DEBUG(1, "ray_cs interrupt roaming initiated\n");
2155 netif_stop_queue(dev);
2156 local->card_status = CARD_DOING_ACQ;
2157 break;
2158 case JAPAN_CALL_SIGN_RXD:
2159 DEBUG(1, "ray_cs interrupt japan call sign rx\n");
2160 break;
2161 default:
2162 DEBUG(1,
2163 "ray_cs Unexpected interrupt for RCS 0x%x cmd = 0x%x\n",
2164 rcsindex,
2165 (unsigned int)readb(&prcs->interrupt_id));
2166 break;
2167 }
2168 writeb(CCS_BUFFER_FREE, &prcs->buffer_status);
2169 }
2170 clear_interrupt(local);
2171 return IRQ_HANDLED;
2106} /* ray_interrupt */ 2172} /* ray_interrupt */
2173
2107/*===========================================================================*/ 2174/*===========================================================================*/
2108static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem *prcs) 2175static void ray_rx(struct net_device *dev, ray_dev_t *local,
2109{ 2176 struct rcs __iomem *prcs)
2110 int rx_len; 2177{
2111 unsigned int pkt_addr; 2178 int rx_len;
2112 void __iomem *pmsg; 2179 unsigned int pkt_addr;
2113 DEBUG(4,"ray_rx process rx packet\n"); 2180 void __iomem *pmsg;
2114 2181 DEBUG(4, "ray_rx process rx packet\n");
2115 /* Calculate address of packet within Rx buffer */ 2182
2116 pkt_addr = ((readb(&prcs->var.rx_packet.rx_data_ptr[0]) << 8) 2183 /* Calculate address of packet within Rx buffer */
2117 + readb(&prcs->var.rx_packet.rx_data_ptr[1])) & RX_BUFF_END; 2184 pkt_addr = ((readb(&prcs->var.rx_packet.rx_data_ptr[0]) << 8)
2118 /* Length of first packet fragment */ 2185 + readb(&prcs->var.rx_packet.rx_data_ptr[1])) & RX_BUFF_END;
2119 rx_len = (readb(&prcs->var.rx_packet.rx_data_length[0]) << 8) 2186 /* Length of first packet fragment */
2120 + readb(&prcs->var.rx_packet.rx_data_length[1]); 2187 rx_len = (readb(&prcs->var.rx_packet.rx_data_length[0]) << 8)
2121 2188 + readb(&prcs->var.rx_packet.rx_data_length[1]);
2122 local->last_rsl = readb(&prcs->var.rx_packet.rx_sig_lev); 2189
2123 pmsg = local->rmem + pkt_addr; 2190 local->last_rsl = readb(&prcs->var.rx_packet.rx_sig_lev);
2124 switch(readb(pmsg)) 2191 pmsg = local->rmem + pkt_addr;
2125 { 2192 switch (readb(pmsg)) {
2126 case DATA_TYPE: 2193 case DATA_TYPE:
2127 DEBUG(4,"ray_rx data type\n"); 2194 DEBUG(4, "ray_rx data type\n");
2128 rx_data(dev, prcs, pkt_addr, rx_len); 2195 rx_data(dev, prcs, pkt_addr, rx_len);
2129 break; 2196 break;
2130 case AUTHENTIC_TYPE: 2197 case AUTHENTIC_TYPE:
2131 DEBUG(4,"ray_rx authentic type\n"); 2198 DEBUG(4, "ray_rx authentic type\n");
2132 if (sniffer) rx_data(dev, prcs, pkt_addr, rx_len); 2199 if (sniffer)
2133 else rx_authenticate(local, prcs, pkt_addr, rx_len); 2200 rx_data(dev, prcs, pkt_addr, rx_len);
2134 break; 2201 else
2135 case DEAUTHENTIC_TYPE: 2202 rx_authenticate(local, prcs, pkt_addr, rx_len);
2136 DEBUG(4,"ray_rx deauth type\n"); 2203 break;
2137 if (sniffer) rx_data(dev, prcs, pkt_addr, rx_len); 2204 case DEAUTHENTIC_TYPE:
2138 else rx_deauthenticate(local, prcs, pkt_addr, rx_len); 2205 DEBUG(4, "ray_rx deauth type\n");
2139 break; 2206 if (sniffer)
2140 case NULL_MSG_TYPE: 2207 rx_data(dev, prcs, pkt_addr, rx_len);
2141 DEBUG(3,"ray_cs rx NULL msg\n"); 2208 else
2142 break; 2209 rx_deauthenticate(local, prcs, pkt_addr, rx_len);
2143 case BEACON_TYPE: 2210 break;
2144 DEBUG(4,"ray_rx beacon type\n"); 2211 case NULL_MSG_TYPE:
2145 if (sniffer) rx_data(dev, prcs, pkt_addr, rx_len); 2212 DEBUG(3, "ray_cs rx NULL msg\n");
2146 2213 break;
2147 copy_from_rx_buff(local, (UCHAR *)&local->last_bcn, pkt_addr, 2214 case BEACON_TYPE:
2148 rx_len < sizeof(struct beacon_rx) ? 2215 DEBUG(4, "ray_rx beacon type\n");
2149 rx_len : sizeof(struct beacon_rx)); 2216 if (sniffer)
2150 2217 rx_data(dev, prcs, pkt_addr, rx_len);
2151 local->beacon_rxed = 1; 2218
2152 /* Get the statistics so the card counters never overflow */ 2219 copy_from_rx_buff(local, (UCHAR *) &local->last_bcn, pkt_addr,
2153 ray_get_stats(dev); 2220 rx_len < sizeof(struct beacon_rx) ?
2154 break; 2221 rx_len : sizeof(struct beacon_rx));
2155 default: 2222
2156 DEBUG(0,"ray_cs unknown pkt type %2x\n", (unsigned int) readb(pmsg)); 2223 local->beacon_rxed = 1;
2157 break; 2224 /* Get the statistics so the card counters never overflow */
2158 } 2225 ray_get_stats(dev);
2226 break;
2227 default:
2228 DEBUG(0, "ray_cs unknown pkt type %2x\n",
2229 (unsigned int)readb(pmsg));
2230 break;
2231 }
2159 2232
2160} /* end ray_rx */ 2233} /* end ray_rx */
2234
2161/*===========================================================================*/ 2235/*===========================================================================*/
2162static void rx_data(struct net_device *dev, struct rcs __iomem *prcs, unsigned int pkt_addr, 2236static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
2163 int rx_len) 2237 unsigned int pkt_addr, int rx_len)
2164{ 2238{
2165 struct sk_buff *skb = NULL; 2239 struct sk_buff *skb = NULL;
2166 struct rcs __iomem *prcslink = prcs; 2240 struct rcs __iomem *prcslink = prcs;
2167 ray_dev_t *local = netdev_priv(dev); 2241 ray_dev_t *local = netdev_priv(dev);
2168 UCHAR *rx_ptr; 2242 UCHAR *rx_ptr;
2169 int total_len; 2243 int total_len;
2170 int tmp; 2244 int tmp;
2171#ifdef WIRELESS_SPY 2245#ifdef WIRELESS_SPY
2172 int siglev = local->last_rsl; 2246 int siglev = local->last_rsl;
2173 u_char linksrcaddr[ETH_ALEN]; /* Other end of the wireless link */ 2247 u_char linksrcaddr[ETH_ALEN]; /* Other end of the wireless link */
2174#endif 2248#endif
2175 2249
2176 if (!sniffer) { 2250 if (!sniffer) {
2177 if (translate) { 2251 if (translate) {
2178/* TBD length needs fixing for translated header */ 2252/* TBD length needs fixing for translated header */
2179 if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) || 2253 if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
2180 rx_len > (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN + FCS_LEN)) 2254 rx_len >
2181 { 2255 (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
2182 DEBUG(0,"ray_cs invalid packet length %d received \n",rx_len); 2256 FCS_LEN)) {
2183 return; 2257 DEBUG(0,
2184 } 2258 "ray_cs invalid packet length %d received \n",
2185 } 2259 rx_len);
2186 else /* encapsulated ethernet */ { 2260 return;
2187 if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) || 2261 }
2188 rx_len > (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN + FCS_LEN)) 2262 } else { /* encapsulated ethernet */
2189 { 2263
2190 DEBUG(0,"ray_cs invalid packet length %d received \n",rx_len); 2264 if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
2191 return; 2265 rx_len >
2192 } 2266 (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
2193 } 2267 FCS_LEN)) {
2194 } 2268 DEBUG(0,
2195 DEBUG(4,"ray_cs rx_data packet\n"); 2269 "ray_cs invalid packet length %d received \n",
2196 /* If fragmented packet, verify sizes of fragments add up */ 2270 rx_len);
2197 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) { 2271 return;
2198 DEBUG(1,"ray_cs rx'ed fragment\n"); 2272 }
2199 tmp = (readb(&prcs->var.rx_packet.totalpacketlength[0]) << 8) 2273 }
2200 + readb(&prcs->var.rx_packet.totalpacketlength[1]); 2274 }
2201 total_len = tmp; 2275 DEBUG(4, "ray_cs rx_data packet\n");
2202 prcslink = prcs; 2276 /* If fragmented packet, verify sizes of fragments add up */
2203 do { 2277 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
2204 tmp -= (readb(&prcslink->var.rx_packet.rx_data_length[0]) << 8) 2278 DEBUG(1, "ray_cs rx'ed fragment\n");
2205 + readb(&prcslink->var.rx_packet.rx_data_length[1]); 2279 tmp = (readb(&prcs->var.rx_packet.totalpacketlength[0]) << 8)
2206 if (readb(&prcslink->var.rx_packet.next_frag_rcs_index) == 0xFF 2280 + readb(&prcs->var.rx_packet.totalpacketlength[1]);
2207 || tmp < 0) break; 2281 total_len = tmp;
2208 prcslink = rcs_base(local) 2282 prcslink = prcs;
2209 + readb(&prcslink->link_field); 2283 do {
2210 } while (1); 2284 tmp -=
2211 2285 (readb(&prcslink->var.rx_packet.rx_data_length[0])
2212 if (tmp < 0) 2286 << 8)
2213 { 2287 + readb(&prcslink->var.rx_packet.rx_data_length[1]);
2214 DEBUG(0,"ray_cs rx_data fragment lengths don't add up\n"); 2288 if (readb(&prcslink->var.rx_packet.next_frag_rcs_index)
2215 local->stats.rx_dropped++; 2289 == 0xFF || tmp < 0)
2216 release_frag_chain(local, prcs); 2290 break;
2217 return; 2291 prcslink = rcs_base(local)
2218 } 2292 + readb(&prcslink->link_field);
2219 } 2293 } while (1);
2220 else { /* Single unfragmented packet */ 2294
2221 total_len = rx_len; 2295 if (tmp < 0) {
2222 } 2296 DEBUG(0,
2223 2297 "ray_cs rx_data fragment lengths don't add up\n");
2224 skb = dev_alloc_skb( total_len+5 ); 2298 local->stats.rx_dropped++;
2225 if (skb == NULL) 2299 release_frag_chain(local, prcs);
2226 { 2300 return;
2227 DEBUG(0,"ray_cs rx_data could not allocate skb\n"); 2301 }
2228 local->stats.rx_dropped++; 2302 } else { /* Single unfragmented packet */
2229 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) 2303 total_len = rx_len;
2230 release_frag_chain(local, prcs); 2304 }
2231 return; 2305
2232 } 2306 skb = dev_alloc_skb(total_len + 5);
2233 skb_reserve( skb, 2); /* Align IP on 16 byte (TBD check this)*/ 2307 if (skb == NULL) {
2234 2308 DEBUG(0, "ray_cs rx_data could not allocate skb\n");
2235 DEBUG(4,"ray_cs rx_data total_len = %x, rx_len = %x\n",total_len,rx_len); 2309 local->stats.rx_dropped++;
2310 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF)
2311 release_frag_chain(local, prcs);
2312 return;
2313 }
2314 skb_reserve(skb, 2); /* Align IP on 16 byte (TBD check this) */
2315
2316 DEBUG(4, "ray_cs rx_data total_len = %x, rx_len = %x\n", total_len,
2317 rx_len);
2236 2318
2237/************************/ 2319/************************/
2238 /* Reserve enough room for the whole damn packet. */ 2320 /* Reserve enough room for the whole damn packet. */
2239 rx_ptr = skb_put( skb, total_len); 2321 rx_ptr = skb_put(skb, total_len);
2240 /* Copy the whole packet to sk_buff */ 2322 /* Copy the whole packet to sk_buff */
2241 rx_ptr += copy_from_rx_buff(local, rx_ptr, pkt_addr & RX_BUFF_END, rx_len); 2323 rx_ptr +=
2242 /* Get source address */ 2324 copy_from_rx_buff(local, rx_ptr, pkt_addr & RX_BUFF_END, rx_len);
2325 /* Get source address */
2243#ifdef WIRELESS_SPY 2326#ifdef WIRELESS_SPY
2244 skb_copy_from_linear_data_offset(skb, offsetof(struct mac_header, addr_2), 2327 skb_copy_from_linear_data_offset(skb,
2245 linksrcaddr, ETH_ALEN); 2328 offsetof(struct mac_header, addr_2),
2329 linksrcaddr, ETH_ALEN);
2246#endif 2330#endif
2247 /* Now, deal with encapsulation/translation/sniffer */ 2331 /* Now, deal with encapsulation/translation/sniffer */
2248 if (!sniffer) { 2332 if (!sniffer) {
2249 if (!translate) { 2333 if (!translate) {
2250 /* Encapsulated ethernet, so just lop off 802.11 MAC header */ 2334 /* Encapsulated ethernet, so just lop off 802.11 MAC header */
2251/* TBD reserve skb_reserve( skb, RX_MAC_HEADER_LENGTH); */ 2335/* TBD reserve skb_reserve( skb, RX_MAC_HEADER_LENGTH); */
2252 skb_pull( skb, RX_MAC_HEADER_LENGTH); 2336 skb_pull(skb, RX_MAC_HEADER_LENGTH);
2253 } 2337 } else {
2254 else { 2338 /* Do translation */
2255 /* Do translation */ 2339 untranslate(local, skb, total_len);
2256 untranslate(local, skb, total_len); 2340 }
2257 } 2341 } else { /* sniffer mode, so just pass whole packet */
2258 } 2342 };
2259 else
2260 { /* sniffer mode, so just pass whole packet */ };
2261 2343
2262/************************/ 2344/************************/
2263 /* Now pick up the rest of the fragments if any */ 2345 /* Now pick up the rest of the fragments if any */
2264 tmp = 17; 2346 tmp = 17;
2265 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) { 2347 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
2266 prcslink = prcs; 2348 prcslink = prcs;
2267 DEBUG(1,"ray_cs rx_data in fragment loop\n"); 2349 DEBUG(1, "ray_cs rx_data in fragment loop\n");
2268 do { 2350 do {
2269 prcslink = rcs_base(local) 2351 prcslink = rcs_base(local)
2270 + readb(&prcslink->var.rx_packet.next_frag_rcs_index); 2352 +
2271 rx_len = (( readb(&prcslink->var.rx_packet.rx_data_length[0]) << 8) 2353 readb(&prcslink->var.rx_packet.next_frag_rcs_index);
2272 + readb(&prcslink->var.rx_packet.rx_data_length[1])) 2354 rx_len =
2273 & RX_BUFF_END; 2355 ((readb(&prcslink->var.rx_packet.rx_data_length[0])
2274 pkt_addr = (( readb(&prcslink->var.rx_packet.rx_data_ptr[0]) << 8) 2356 << 8)
2275 + readb(&prcslink->var.rx_packet.rx_data_ptr[1])) 2357 +
2276 & RX_BUFF_END; 2358 readb(&prcslink->var.rx_packet.rx_data_length[1]))
2277 2359 & RX_BUFF_END;
2278 rx_ptr += copy_from_rx_buff(local, rx_ptr, pkt_addr, rx_len); 2360 pkt_addr =
2279 2361 ((readb(&prcslink->var.rx_packet.rx_data_ptr[0]) <<
2280 } while (tmp-- && 2362 8)
2281 readb(&prcslink->var.rx_packet.next_frag_rcs_index) != 0xFF); 2363 + readb(&prcslink->var.rx_packet.rx_data_ptr[1]))
2282 release_frag_chain(local, prcs); 2364 & RX_BUFF_END;
2283 } 2365
2284 2366 rx_ptr +=
2285 skb->protocol = eth_type_trans(skb,dev); 2367 copy_from_rx_buff(local, rx_ptr, pkt_addr, rx_len);
2286 netif_rx(skb); 2368
2287 local->stats.rx_packets++; 2369 } while (tmp-- &&
2288 local->stats.rx_bytes += total_len; 2370 readb(&prcslink->var.rx_packet.next_frag_rcs_index) !=
2289 2371 0xFF);
2290 /* Gather signal strength per address */ 2372 release_frag_chain(local, prcs);
2373 }
2374
2375 skb->protocol = eth_type_trans(skb, dev);
2376 netif_rx(skb);
2377 local->stats.rx_packets++;
2378 local->stats.rx_bytes += total_len;
2379
2380 /* Gather signal strength per address */
2291#ifdef WIRELESS_SPY 2381#ifdef WIRELESS_SPY
2292 /* For the Access Point or the node having started the ad-hoc net 2382 /* For the Access Point or the node having started the ad-hoc net
2293 * note : ad-hoc work only in some specific configurations, but we 2383 * note : ad-hoc work only in some specific configurations, but we
2294 * kludge in ray_get_wireless_stats... */ 2384 * kludge in ray_get_wireless_stats... */
2295 if(!memcmp(linksrcaddr, local->bss_id, ETH_ALEN)) 2385 if (!memcmp(linksrcaddr, local->bss_id, ETH_ALEN)) {
2296 { 2386 /* Update statistics */
2297 /* Update statistics */ 2387 /*local->wstats.qual.qual = none ? */
2298 /*local->wstats.qual.qual = none ? */ 2388 local->wstats.qual.level = siglev;
2299 local->wstats.qual.level = siglev; 2389 /*local->wstats.qual.noise = none ? */
2300 /*local->wstats.qual.noise = none ? */ 2390 local->wstats.qual.updated = 0x2;
2301 local->wstats.qual.updated = 0x2; 2391 }
2302 } 2392 /* Now, update the spy stuff */
2303 /* Now, update the spy stuff */ 2393 {
2304 { 2394 struct iw_quality wstats;
2305 struct iw_quality wstats; 2395 wstats.level = siglev;
2306 wstats.level = siglev; 2396 /* wstats.noise = none ? */
2307 /* wstats.noise = none ? */ 2397 /* wstats.qual = none ? */
2308 /* wstats.qual = none ? */ 2398 wstats.updated = 0x2;
2309 wstats.updated = 0x2; 2399 /* Update spy records */
2310 /* Update spy records */ 2400 wireless_spy_update(dev, linksrcaddr, &wstats);
2311 wireless_spy_update(dev, linksrcaddr, &wstats); 2401 }
2312 } 2402#endif /* WIRELESS_SPY */
2313#endif /* WIRELESS_SPY */
2314} /* end rx_data */ 2403} /* end rx_data */
2404
2315/*===========================================================================*/ 2405/*===========================================================================*/
2316static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len) 2406static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
2317{ 2407{
2318 snaphdr_t *psnap = (snaphdr_t *)(skb->data + RX_MAC_HEADER_LENGTH); 2408 snaphdr_t *psnap = (snaphdr_t *) (skb->data + RX_MAC_HEADER_LENGTH);
2319 struct ieee80211_hdr *pmac = (struct ieee80211_hdr *)skb->data; 2409 struct ieee80211_hdr *pmac = (struct ieee80211_hdr *)skb->data;
2320 __be16 type = *(__be16 *)psnap->ethertype; 2410 __be16 type = *(__be16 *) psnap->ethertype;
2321 int delta; 2411 int delta;
2322 struct ethhdr *peth; 2412 struct ethhdr *peth;
2323 UCHAR srcaddr[ADDRLEN]; 2413 UCHAR srcaddr[ADDRLEN];
2324 UCHAR destaddr[ADDRLEN]; 2414 UCHAR destaddr[ADDRLEN];
2325 static UCHAR org_bridge[3] = {0, 0, 0xf8}; 2415 static UCHAR org_bridge[3] = { 0, 0, 0xf8 };
2326 static UCHAR org_1042[3] = {0, 0, 0}; 2416 static UCHAR org_1042[3] = { 0, 0, 0 };
2327 2417
2328 memcpy(destaddr, ieee80211_get_DA(pmac), ADDRLEN); 2418 memcpy(destaddr, ieee80211_get_DA(pmac), ADDRLEN);
2329 memcpy(srcaddr, ieee80211_get_SA(pmac), ADDRLEN); 2419 memcpy(srcaddr, ieee80211_get_SA(pmac), ADDRLEN);
2330 2420
2331#ifdef PCMCIA_DEBUG 2421#ifdef PCMCIA_DEBUG
2332 if (pc_debug > 3) { 2422 if (pc_debug > 3) {
2333 int i; 2423 int i;
2334 printk(KERN_DEBUG "skb->data before untranslate"); 2424 printk(KERN_DEBUG "skb->data before untranslate");
2335 for (i=0;i<64;i++) 2425 for (i = 0; i < 64; i++)
2336 printk("%02x ",skb->data[i]); 2426 printk("%02x ", skb->data[i]);
2337 printk("\n" KERN_DEBUG "type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n", 2427 printk("\n" KERN_DEBUG
2338 ntohs(type), 2428 "type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n",
2339 psnap->dsap, psnap->ssap, psnap->ctrl, 2429 ntohs(type), psnap->dsap, psnap->ssap, psnap->ctrl,
2340 psnap->org[0], psnap->org[1], psnap->org[2]); 2430 psnap->org[0], psnap->org[1], psnap->org[2]);
2341 printk(KERN_DEBUG "untranslate skb->data = %p\n",skb->data); 2431 printk(KERN_DEBUG "untranslate skb->data = %p\n", skb->data);
2342 } 2432 }
2343#endif 2433#endif
2344 2434
2345 if (psnap->dsap != 0xaa || psnap->ssap != 0xaa || psnap->ctrl != 3) { 2435 if (psnap->dsap != 0xaa || psnap->ssap != 0xaa || psnap->ctrl != 3) {
2346 /* not a snap type so leave it alone */ 2436 /* not a snap type so leave it alone */
2347 DEBUG(3,"ray_cs untranslate NOT SNAP %02x %02x %02x\n", 2437 DEBUG(3, "ray_cs untranslate NOT SNAP %02x %02x %02x\n",
2348 psnap->dsap, psnap->ssap, psnap->ctrl); 2438 psnap->dsap, psnap->ssap, psnap->ctrl);
2349 2439
2350 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN; 2440 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
2351 peth = (struct ethhdr *)(skb->data + delta); 2441 peth = (struct ethhdr *)(skb->data + delta);
2352 peth->h_proto = htons(len - RX_MAC_HEADER_LENGTH); 2442 peth->h_proto = htons(len - RX_MAC_HEADER_LENGTH);
2353 } 2443 } else { /* Its a SNAP */
2354 else { /* Its a SNAP */ 2444 if (memcmp(psnap->org, org_bridge, 3) == 0) {
2355 if (memcmp(psnap->org, org_bridge, 3) == 0) { /* EtherII and nuke the LLC */ 2445 /* EtherII and nuke the LLC */
2356 DEBUG(3,"ray_cs untranslate Bridge encap\n"); 2446 DEBUG(3, "ray_cs untranslate Bridge encap\n");
2357 delta = RX_MAC_HEADER_LENGTH 2447 delta = RX_MAC_HEADER_LENGTH
2358 + sizeof(struct snaphdr_t) - ETH_HLEN; 2448 + sizeof(struct snaphdr_t) - ETH_HLEN;
2359 peth = (struct ethhdr *)(skb->data + delta); 2449 peth = (struct ethhdr *)(skb->data + delta);
2360 peth->h_proto = type; 2450 peth->h_proto = type;
2361 } else if (memcmp(psnap->org, org_1042, 3) == 0) { 2451 } else if (memcmp(psnap->org, org_1042, 3) == 0) {
2362 switch (ntohs(type)) { 2452 switch (ntohs(type)) {
2363 case ETH_P_IPX: 2453 case ETH_P_IPX:
2364 case ETH_P_AARP: 2454 case ETH_P_AARP:
2365 DEBUG(3,"ray_cs untranslate RFC IPX/AARP\n"); 2455 DEBUG(3, "ray_cs untranslate RFC IPX/AARP\n");
2366 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN; 2456 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
2367 peth = (struct ethhdr *)(skb->data + delta); 2457 peth = (struct ethhdr *)(skb->data + delta);
2368 peth->h_proto = htons(len - RX_MAC_HEADER_LENGTH); 2458 peth->h_proto =
2369 break; 2459 htons(len - RX_MAC_HEADER_LENGTH);
2370 default: 2460 break;
2371 DEBUG(3,"ray_cs untranslate RFC default\n"); 2461 default:
2372 delta = RX_MAC_HEADER_LENGTH + 2462 DEBUG(3, "ray_cs untranslate RFC default\n");
2373 sizeof(struct snaphdr_t) - ETH_HLEN; 2463 delta = RX_MAC_HEADER_LENGTH +
2374 peth = (struct ethhdr *)(skb->data + delta); 2464 sizeof(struct snaphdr_t) - ETH_HLEN;
2375 peth->h_proto = type; 2465 peth = (struct ethhdr *)(skb->data + delta);
2376 break; 2466 peth->h_proto = type;
2377 } 2467 break;
2378 } else { 2468 }
2379 printk("ray_cs untranslate very confused by packet\n"); 2469 } else {
2380 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN; 2470 printk("ray_cs untranslate very confused by packet\n");
2381 peth = (struct ethhdr *)(skb->data + delta); 2471 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
2382 peth->h_proto = type; 2472 peth = (struct ethhdr *)(skb->data + delta);
2473 peth->h_proto = type;
2474 }
2383 } 2475 }
2384 }
2385/* TBD reserve skb_reserve(skb, delta); */ 2476/* TBD reserve skb_reserve(skb, delta); */
2386 skb_pull(skb, delta); 2477 skb_pull(skb, delta);
2387 DEBUG(3,"untranslate after skb_pull(%d), skb->data = %p\n",delta,skb->data); 2478 DEBUG(3, "untranslate after skb_pull(%d), skb->data = %p\n", delta,
2388 memcpy(peth->h_dest, destaddr, ADDRLEN); 2479 skb->data);
2389 memcpy(peth->h_source, srcaddr, ADDRLEN); 2480 memcpy(peth->h_dest, destaddr, ADDRLEN);
2481 memcpy(peth->h_source, srcaddr, ADDRLEN);
2390#ifdef PCMCIA_DEBUG 2482#ifdef PCMCIA_DEBUG
2391 if (pc_debug > 3) { 2483 if (pc_debug > 3) {
2392 int i; 2484 int i;
2393 printk(KERN_DEBUG "skb->data after untranslate:"); 2485 printk(KERN_DEBUG "skb->data after untranslate:");
2394 for (i=0;i<64;i++) 2486 for (i = 0; i < 64; i++)
2395 printk("%02x ",skb->data[i]); 2487 printk("%02x ", skb->data[i]);
2396 printk("\n"); 2488 printk("\n");
2397 } 2489 }
2398#endif 2490#endif
2399} /* end untranslate */ 2491} /* end untranslate */
2492
2400/*===========================================================================*/ 2493/*===========================================================================*/
2401/* Copy data from circular receive buffer to PC memory. 2494/* Copy data from circular receive buffer to PC memory.
2402 * dest = destination address in PC memory 2495 * dest = destination address in PC memory
2403 * pkt_addr = source address in receive buffer 2496 * pkt_addr = source address in receive buffer
2404 * len = length of packet to copy 2497 * len = length of packet to copy
2405 */ 2498 */
2406static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr, int length) 2499static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr,
2407{ 2500 int length)
2408 int wrap_bytes = (pkt_addr + length) - (RX_BUFF_END + 1); 2501{
2409 if (wrap_bytes <= 0) 2502 int wrap_bytes = (pkt_addr + length) - (RX_BUFF_END + 1);
2410 { 2503 if (wrap_bytes <= 0) {
2411 memcpy_fromio(dest,local->rmem + pkt_addr,length); 2504 memcpy_fromio(dest, local->rmem + pkt_addr, length);
2412 } 2505 } else { /* Packet wrapped in circular buffer */
2413 else /* Packet wrapped in circular buffer */ 2506
2414 { 2507 memcpy_fromio(dest, local->rmem + pkt_addr,
2415 memcpy_fromio(dest,local->rmem+pkt_addr,length - wrap_bytes); 2508 length - wrap_bytes);
2416 memcpy_fromio(dest + length - wrap_bytes, local->rmem, wrap_bytes); 2509 memcpy_fromio(dest + length - wrap_bytes, local->rmem,
2417 } 2510 wrap_bytes);
2418 return length; 2511 }
2512 return length;
2419} 2513}
2514
2420/*===========================================================================*/ 2515/*===========================================================================*/
2421static void release_frag_chain(ray_dev_t *local, struct rcs __iomem * prcs) 2516static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs)
2422{ 2517{
2423 struct rcs __iomem *prcslink = prcs; 2518 struct rcs __iomem *prcslink = prcs;
2424 int tmp = 17; 2519 int tmp = 17;
2425 unsigned rcsindex = readb(&prcs->var.rx_packet.next_frag_rcs_index); 2520 unsigned rcsindex = readb(&prcs->var.rx_packet.next_frag_rcs_index);
2426 2521
2427 while (tmp--) { 2522 while (tmp--) {
2428 writeb(CCS_BUFFER_FREE, &prcslink->buffer_status); 2523 writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
2429 if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) { 2524 if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
2430 DEBUG(1,"ray_cs interrupt bad rcsindex = 0x%x\n",rcsindex); 2525 DEBUG(1, "ray_cs interrupt bad rcsindex = 0x%x\n",
2431 break; 2526 rcsindex);
2432 } 2527 break;
2433 prcslink = rcs_base(local) + rcsindex; 2528 }
2434 rcsindex = readb(&prcslink->var.rx_packet.next_frag_rcs_index); 2529 prcslink = rcs_base(local) + rcsindex;
2435 } 2530 rcsindex = readb(&prcslink->var.rx_packet.next_frag_rcs_index);
2436 writeb(CCS_BUFFER_FREE, &prcslink->buffer_status); 2531 }
2532 writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
2437} 2533}
2534
2438/*===========================================================================*/ 2535/*===========================================================================*/
2439static void authenticate(ray_dev_t *local) 2536static void authenticate(ray_dev_t *local)
2440{ 2537{
2441 struct pcmcia_device *link = local->finder; 2538 struct pcmcia_device *link = local->finder;
2442 DEBUG(0,"ray_cs Starting authentication.\n"); 2539 DEBUG(0, "ray_cs Starting authentication.\n");
2443 if (!(pcmcia_dev_present(link))) { 2540 if (!(pcmcia_dev_present(link))) {
2444 DEBUG(2,"ray_cs authenticate - device not present\n"); 2541 DEBUG(2, "ray_cs authenticate - device not present\n");
2445 return; 2542 return;
2446 } 2543 }
2447 2544
2448 del_timer(&local->timer); 2545 del_timer(&local->timer);
2449 if (build_auth_frame(local, local->bss_id, OPEN_AUTH_REQUEST)) { 2546 if (build_auth_frame(local, local->bss_id, OPEN_AUTH_REQUEST)) {
2450 local->timer.function = &join_net; 2547 local->timer.function = &join_net;
2451 } 2548 } else {
2452 else { 2549 local->timer.function = &authenticate_timeout;
2453 local->timer.function = &authenticate_timeout; 2550 }
2454 } 2551 local->timer.expires = jiffies + HZ * 2;
2455 local->timer.expires = jiffies + HZ*2; 2552 local->timer.data = (long)local;
2456 local->timer.data = (long)local; 2553 add_timer(&local->timer);
2457 add_timer(&local->timer); 2554 local->authentication_state = AWAITING_RESPONSE;
2458 local->authentication_state = AWAITING_RESPONSE;
2459} /* end authenticate */ 2555} /* end authenticate */
2556
2460/*===========================================================================*/ 2557/*===========================================================================*/
2461static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs, 2558static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
2462 unsigned int pkt_addr, int rx_len) 2559 unsigned int pkt_addr, int rx_len)
2463{ 2560{
2464 UCHAR buff[256]; 2561 UCHAR buff[256];
2465 struct rx_msg *msg = (struct rx_msg *)buff; 2562 struct rx_msg *msg = (struct rx_msg *)buff;
2466 2563
2467 del_timer(&local->timer); 2564 del_timer(&local->timer);
2468 2565
2469 copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff); 2566 copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
2470 /* if we are trying to get authenticated */ 2567 /* if we are trying to get authenticated */
2471 if (local->sparm.b4.a_network_type == ADHOC) { 2568 if (local->sparm.b4.a_network_type == ADHOC) {
2472 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]); 2569 DEBUG(1, "ray_cs rx_auth var= %02x %02x %02x %02x %02x %02x\n",
2473 if (msg->var[2] == 1) { 2570 msg->var[0], msg->var[1], msg->var[2], msg->var[3],
2474 DEBUG(0,"ray_cs Sending authentication response.\n"); 2571 msg->var[4], msg->var[5]);
2475 if (!build_auth_frame (local, msg->mac.addr_2, OPEN_AUTH_RESPONSE)) { 2572 if (msg->var[2] == 1) {
2476 local->authentication_state = NEED_TO_AUTH; 2573 DEBUG(0, "ray_cs Sending authentication response.\n");
2477 memcpy(local->auth_id, msg->mac.addr_2, ADDRLEN); 2574 if (!build_auth_frame
2478 } 2575 (local, msg->mac.addr_2, OPEN_AUTH_RESPONSE)) {
2479 } 2576 local->authentication_state = NEED_TO_AUTH;
2480 } 2577 memcpy(local->auth_id, msg->mac.addr_2,
2481 else /* Infrastructure network */ 2578 ADDRLEN);
2482 { 2579 }
2483 if (local->authentication_state == AWAITING_RESPONSE) { 2580 }
2484 /* Verify authentication sequence #2 and success */ 2581 } else { /* Infrastructure network */
2485 if (msg->var[2] == 2) { 2582
2486 if ((msg->var[3] | msg->var[4]) == 0) { 2583 if (local->authentication_state == AWAITING_RESPONSE) {
2487 DEBUG(1,"Authentication successful\n"); 2584 /* Verify authentication sequence #2 and success */
2488 local->card_status = CARD_AUTH_COMPLETE; 2585 if (msg->var[2] == 2) {
2489 associate(local); 2586 if ((msg->var[3] | msg->var[4]) == 0) {
2490 local->authentication_state = AUTHENTICATED; 2587 DEBUG(1, "Authentication successful\n");
2491 } 2588 local->card_status = CARD_AUTH_COMPLETE;
2492 else { 2589 associate(local);
2493 DEBUG(0,"Authentication refused\n"); 2590 local->authentication_state =
2494 local->card_status = CARD_AUTH_REFUSED; 2591 AUTHENTICATED;
2495 join_net((u_long)local); 2592 } else {
2496 local->authentication_state = UNAUTHENTICATED; 2593 DEBUG(0, "Authentication refused\n");
2497 } 2594 local->card_status = CARD_AUTH_REFUSED;
2498 } 2595 join_net((u_long) local);
2499 } 2596 local->authentication_state =
2500 } 2597 UNAUTHENTICATED;
2598 }
2599 }
2600 }
2601 }
2501 2602
2502} /* end rx_authenticate */ 2603} /* end rx_authenticate */
2604
2503/*===========================================================================*/ 2605/*===========================================================================*/
2504static void associate(ray_dev_t *local) 2606static void associate(ray_dev_t *local)
2505{ 2607{
2506 struct ccs __iomem *pccs; 2608 struct ccs __iomem *pccs;
2507 struct pcmcia_device *link = local->finder; 2609 struct pcmcia_device *link = local->finder;
2508 struct net_device *dev = link->priv; 2610 struct net_device *dev = link->priv;
2509 int ccsindex; 2611 int ccsindex;
2510 if (!(pcmcia_dev_present(link))) { 2612 if (!(pcmcia_dev_present(link))) {
2511 DEBUG(2,"ray_cs associate - device not present\n"); 2613 DEBUG(2, "ray_cs associate - device not present\n");
2512 return; 2614 return;
2513 } 2615 }
2514 /* If no tx buffers available, return*/ 2616 /* If no tx buffers available, return */
2515 if ((ccsindex = get_free_ccs(local)) < 0) 2617 if ((ccsindex = get_free_ccs(local)) < 0) {
2516 {
2517/* TBD should never be here but... what if we are? */ 2618/* TBD should never be here but... what if we are? */
2518 DEBUG(1,"ray_cs associate - No free ccs\n"); 2619 DEBUG(1, "ray_cs associate - No free ccs\n");
2519 return; 2620 return;
2520 } 2621 }
2521 DEBUG(1,"ray_cs Starting association with access point\n"); 2622 DEBUG(1, "ray_cs Starting association with access point\n");
2522 pccs = ccs_base(local) + ccsindex; 2623 pccs = ccs_base(local) + ccsindex;
2523 /* fill in the CCS */ 2624 /* fill in the CCS */
2524 writeb(CCS_START_ASSOCIATION, &pccs->cmd); 2625 writeb(CCS_START_ASSOCIATION, &pccs->cmd);
2525 /* Interrupt the firmware to process the command */ 2626 /* Interrupt the firmware to process the command */
2526 if (interrupt_ecf(local, ccsindex)) { 2627 if (interrupt_ecf(local, ccsindex)) {
2527 DEBUG(1,"ray_cs associate failed - ECF not ready for intr\n"); 2628 DEBUG(1, "ray_cs associate failed - ECF not ready for intr\n");
2528 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status); 2629 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
2529 2630
2530 del_timer(&local->timer); 2631 del_timer(&local->timer);
2531 local->timer.expires = jiffies + HZ*2; 2632 local->timer.expires = jiffies + HZ * 2;
2532 local->timer.data = (long)local; 2633 local->timer.data = (long)local;
2533 local->timer.function = &join_net; 2634 local->timer.function = &join_net;
2534 add_timer(&local->timer); 2635 add_timer(&local->timer);
2535 local->card_status = CARD_ASSOC_FAILED; 2636 local->card_status = CARD_ASSOC_FAILED;
2536 return; 2637 return;
2537 } 2638 }
2538 if (!sniffer) netif_start_queue(dev); 2639 if (!sniffer)
2640 netif_start_queue(dev);
2539 2641
2540} /* end associate */ 2642} /* end associate */
2643
2541/*===========================================================================*/ 2644/*===========================================================================*/
2542static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs, 2645static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
2543 unsigned int pkt_addr, int rx_len) 2646 unsigned int pkt_addr, int rx_len)
2544{ 2647{
2545/* UCHAR buff[256]; 2648/* UCHAR buff[256];
2546 struct rx_msg *msg = (struct rx_msg *)buff; 2649 struct rx_msg *msg = (struct rx_msg *)buff;
2547*/ 2650*/
2548 DEBUG(0,"Deauthentication frame received\n"); 2651 DEBUG(0, "Deauthentication frame received\n");
2549 local->authentication_state = UNAUTHENTICATED; 2652 local->authentication_state = UNAUTHENTICATED;
2550 /* Need to reauthenticate or rejoin depending on reason code */ 2653 /* Need to reauthenticate or rejoin depending on reason code */
2551/* copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff); 2654/* copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
2552 */ 2655 */
2553} 2656}
2657
2554/*===========================================================================*/ 2658/*===========================================================================*/
2555static void clear_interrupt(ray_dev_t *local) 2659static void clear_interrupt(ray_dev_t *local)
2556{ 2660{
2557 writeb(0, local->amem + CIS_OFFSET + HCS_INTR_OFFSET); 2661 writeb(0, local->amem + CIS_OFFSET + HCS_INTR_OFFSET);
2558} 2662}
2663
2559/*===========================================================================*/ 2664/*===========================================================================*/
2560#ifdef CONFIG_PROC_FS 2665#ifdef CONFIG_PROC_FS
2561#define MAXDATA (PAGE_SIZE - 80) 2666#define MAXDATA (PAGE_SIZE - 80)
2562 2667
2563static char *card_status[] = { 2668static char *card_status[] = {
2564 "Card inserted - uninitialized", /* 0 */ 2669 "Card inserted - uninitialized", /* 0 */
2565 "Card not downloaded", /* 1 */ 2670 "Card not downloaded", /* 1 */
2566 "Waiting for download parameters", /* 2 */ 2671 "Waiting for download parameters", /* 2 */
2567 "Card doing acquisition", /* 3 */ 2672 "Card doing acquisition", /* 3 */
2568 "Acquisition complete", /* 4 */ 2673 "Acquisition complete", /* 4 */
2569 "Authentication complete", /* 5 */ 2674 "Authentication complete", /* 5 */
2570 "Association complete", /* 6 */ 2675 "Association complete", /* 6 */
2571 "???", "???", "???", "???", /* 7 8 9 10 undefined */ 2676 "???", "???", "???", "???", /* 7 8 9 10 undefined */
2572 "Card init error", /* 11 */ 2677 "Card init error", /* 11 */
2573 "Download parameters error", /* 12 */ 2678 "Download parameters error", /* 12 */
2574 "???", /* 13 */ 2679 "???", /* 13 */
2575 "Acquisition failed", /* 14 */ 2680 "Acquisition failed", /* 14 */
2576 "Authentication refused", /* 15 */ 2681 "Authentication refused", /* 15 */
2577 "Association failed" /* 16 */ 2682 "Association failed" /* 16 */
2578}; 2683};
2579 2684
2580static char *nettype[] = {"Adhoc", "Infra "}; 2685static char *nettype[] = { "Adhoc", "Infra " };
2581static char *framing[] = {"Encapsulation", "Translation"} 2686static char *framing[] = { "Encapsulation", "Translation" }
2687
2582; 2688;
2583/*===========================================================================*/ 2689/*===========================================================================*/
2584static int ray_cs_proc_show(struct seq_file *m, void *v) 2690static int ray_cs_proc_show(struct seq_file *m, void *v)
2585{ 2691{
2586/* Print current values which are not available via other means 2692/* Print current values which are not available via other means
2587 * eg ifconfig 2693 * eg ifconfig
2588 */ 2694 */
2589 int i; 2695 int i;
2590 struct pcmcia_device *link; 2696 struct pcmcia_device *link;
2591 struct net_device *dev; 2697 struct net_device *dev;
2592 ray_dev_t *local; 2698 ray_dev_t *local;
2593 UCHAR *p; 2699 UCHAR *p;
2594 struct freq_hop_element *pfh; 2700 struct freq_hop_element *pfh;
2595 UCHAR c[33]; 2701 UCHAR c[33];
2596 2702
2597 link = this_device; 2703 link = this_device;
2598 if (!link) 2704 if (!link)
2599 return 0; 2705 return 0;
2600 dev = (struct net_device *)link->priv; 2706 dev = (struct net_device *)link->priv;
2601 if (!dev) 2707 if (!dev)
2602 return 0; 2708 return 0;
2603 local = netdev_priv(dev); 2709 local = netdev_priv(dev);
2604 if (!local) 2710 if (!local)
2605 return 0; 2711 return 0;
2606 2712
2607 seq_puts(m, "Raylink Wireless LAN driver status\n"); 2713 seq_puts(m, "Raylink Wireless LAN driver status\n");
2608 seq_printf(m, "%s\n", rcsid); 2714 seq_printf(m, "%s\n", rcsid);
2609 /* build 4 does not report version, and field is 0x55 after memtest */ 2715 /* build 4 does not report version, and field is 0x55 after memtest */
2610 seq_puts(m, "Firmware version = "); 2716 seq_puts(m, "Firmware version = ");
2611 if (local->fw_ver == 0x55) 2717 if (local->fw_ver == 0x55)
2612 seq_puts(m, "4 - Use dump_cis for more details\n"); 2718 seq_puts(m, "4 - Use dump_cis for more details\n");
2613 else 2719 else
2614 seq_printf(m, "%2d.%02d.%02d\n", 2720 seq_printf(m, "%2d.%02d.%02d\n",
2615 local->fw_ver, local->fw_bld, local->fw_var); 2721 local->fw_ver, local->fw_bld, local->fw_var);
2616 2722
2617 for (i=0; i<32; i++) c[i] = local->sparm.b5.a_current_ess_id[i]; 2723 for (i = 0; i < 32; i++)
2618 c[32] = 0; 2724 c[i] = local->sparm.b5.a_current_ess_id[i];
2619 seq_printf(m, "%s network ESSID = \"%s\"\n", 2725 c[32] = 0;
2620 nettype[local->sparm.b5.a_network_type], c); 2726 seq_printf(m, "%s network ESSID = \"%s\"\n",
2621 2727 nettype[local->sparm.b5.a_network_type], c);
2622 p = local->bss_id; 2728
2623 seq_printf(m, "BSSID = %pM\n", p); 2729 p = local->bss_id;
2624 2730 seq_printf(m, "BSSID = %pM\n", p);
2625 seq_printf(m, "Country code = %d\n", 2731
2626 local->sparm.b5.a_curr_country_code); 2732 seq_printf(m, "Country code = %d\n",
2627 2733 local->sparm.b5.a_curr_country_code);
2628 i = local->card_status; 2734
2629 if (i < 0) i = 10; 2735 i = local->card_status;
2630 if (i > 16) i = 10; 2736 if (i < 0)
2631 seq_printf(m, "Card status = %s\n", card_status[i]); 2737 i = 10;
2632 2738 if (i > 16)
2633 seq_printf(m, "Framing mode = %s\n",framing[translate]); 2739 i = 10;
2634 2740 seq_printf(m, "Card status = %s\n", card_status[i]);
2635 seq_printf(m, "Last pkt signal lvl = %d\n", local->last_rsl); 2741
2636 2742 seq_printf(m, "Framing mode = %s\n", framing[translate]);
2637 if (local->beacon_rxed) { 2743
2638 /* Pull some fields out of last beacon received */ 2744 seq_printf(m, "Last pkt signal lvl = %d\n", local->last_rsl);
2639 seq_printf(m, "Beacon Interval = %d Kus\n", 2745
2640 local->last_bcn.beacon_intvl[0] 2746 if (local->beacon_rxed) {
2641 + 256 * local->last_bcn.beacon_intvl[1]); 2747 /* Pull some fields out of last beacon received */
2642 2748 seq_printf(m, "Beacon Interval = %d Kus\n",
2643 p = local->last_bcn.elements; 2749 local->last_bcn.beacon_intvl[0]
2644 if (p[0] == C_ESSID_ELEMENT_ID) p += p[1] + 2; 2750 + 256 * local->last_bcn.beacon_intvl[1]);
2645 else { 2751
2646 seq_printf(m, "Parse beacon failed at essid element id = %d\n",p[0]); 2752 p = local->last_bcn.elements;
2647 return 0; 2753 if (p[0] == C_ESSID_ELEMENT_ID)
2648 } 2754 p += p[1] + 2;
2649 2755 else {
2650 if (p[0] == C_SUPPORTED_RATES_ELEMENT_ID) { 2756 seq_printf(m,
2651 seq_puts(m, "Supported rate codes = "); 2757 "Parse beacon failed at essid element id = %d\n",
2652 for (i=2; i<p[1] + 2; i++) 2758 p[0]);
2653 seq_printf(m, "0x%02x ", p[i]); 2759 return 0;
2654 seq_putc(m, '\n'); 2760 }
2655 p += p[1] + 2; 2761
2656 } 2762 if (p[0] == C_SUPPORTED_RATES_ELEMENT_ID) {
2657 else { 2763 seq_puts(m, "Supported rate codes = ");
2658 seq_puts(m, "Parse beacon failed at rates element\n"); 2764 for (i = 2; i < p[1] + 2; i++)
2659 return 0; 2765 seq_printf(m, "0x%02x ", p[i]);
2660 } 2766 seq_putc(m, '\n');
2661 2767 p += p[1] + 2;
2662 if (p[0] == C_FH_PARAM_SET_ELEMENT_ID) { 2768 } else {
2663 pfh = (struct freq_hop_element *)p; 2769 seq_puts(m, "Parse beacon failed at rates element\n");
2664 seq_printf(m, "Hop dwell = %d Kus\n", 2770 return 0;
2665 pfh->dwell_time[0] + 256 * pfh->dwell_time[1]); 2771 }
2666 seq_printf(m, "Hop set = %d \n", pfh->hop_set); 2772
2667 seq_printf(m, "Hop pattern = %d \n", pfh->hop_pattern); 2773 if (p[0] == C_FH_PARAM_SET_ELEMENT_ID) {
2668 seq_printf(m, "Hop index = %d \n", pfh->hop_index); 2774 pfh = (struct freq_hop_element *)p;
2669 p += p[1] + 2; 2775 seq_printf(m, "Hop dwell = %d Kus\n",
2670 } 2776 pfh->dwell_time[0] +
2671 else { 2777 256 * pfh->dwell_time[1]);
2672 seq_puts(m, "Parse beacon failed at FH param element\n"); 2778 seq_printf(m, "Hop set = %d \n",
2673 return 0; 2779 pfh->hop_set);
2780 seq_printf(m, "Hop pattern = %d \n",
2781 pfh->hop_pattern);
2782 seq_printf(m, "Hop index = %d \n",
2783 pfh->hop_index);
2784 p += p[1] + 2;
2785 } else {
2786 seq_puts(m,
2787 "Parse beacon failed at FH param element\n");
2788 return 0;
2789 }
2790 } else {
2791 seq_puts(m, "No beacons received\n");
2674 } 2792 }
2675 } else { 2793 return 0;
2676 seq_puts(m, "No beacons received\n");
2677 }
2678 return 0;
2679} 2794}
2680 2795
2681static int ray_cs_proc_open(struct inode *inode, struct file *file) 2796static int ray_cs_proc_open(struct inode *inode, struct file *file)
@@ -2684,74 +2799,77 @@ static int ray_cs_proc_open(struct inode *inode, struct file *file)
2684} 2799}
2685 2800
2686static const struct file_operations ray_cs_proc_fops = { 2801static const struct file_operations ray_cs_proc_fops = {
2687 .owner = THIS_MODULE, 2802 .owner = THIS_MODULE,
2688 .open = ray_cs_proc_open, 2803 .open = ray_cs_proc_open,
2689 .read = seq_read, 2804 .read = seq_read,
2690 .llseek = seq_lseek, 2805 .llseek = seq_lseek,
2691 .release = single_release, 2806 .release = single_release,
2692}; 2807};
2693#endif 2808#endif
2694/*===========================================================================*/ 2809/*===========================================================================*/
2695static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type) 2810static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
2696{ 2811{
2697 int addr; 2812 int addr;
2698 struct ccs __iomem *pccs; 2813 struct ccs __iomem *pccs;
2699 struct tx_msg __iomem *ptx; 2814 struct tx_msg __iomem *ptx;
2700 int ccsindex; 2815 int ccsindex;
2701 2816
2702 /* If no tx buffers available, return */ 2817 /* If no tx buffers available, return */
2703 if ((ccsindex = get_free_tx_ccs(local)) < 0) 2818 if ((ccsindex = get_free_tx_ccs(local)) < 0) {
2704 { 2819 DEBUG(1, "ray_cs send authenticate - No free tx ccs\n");
2705 DEBUG(1,"ray_cs send authenticate - No free tx ccs\n"); 2820 return -1;
2706 return -1; 2821 }
2707 } 2822
2708 2823 pccs = ccs_base(local) + ccsindex;
2709 pccs = ccs_base(local) + ccsindex; 2824
2710 2825 /* Address in card space */
2711 /* Address in card space */ 2826 addr = TX_BUF_BASE + (ccsindex << 11);
2712 addr = TX_BUF_BASE + (ccsindex << 11); 2827 /* fill in the CCS */
2713 /* fill in the CCS */ 2828 writeb(CCS_TX_REQUEST, &pccs->cmd);
2714 writeb(CCS_TX_REQUEST, &pccs->cmd); 2829 writeb(addr >> 8, pccs->var.tx_request.tx_data_ptr);
2715 writeb(addr >> 8, pccs->var.tx_request.tx_data_ptr); 2830 writeb(0x20, pccs->var.tx_request.tx_data_ptr + 1);
2716 writeb(0x20, pccs->var.tx_request.tx_data_ptr + 1); 2831 writeb(TX_AUTHENTICATE_LENGTH_MSB, pccs->var.tx_request.tx_data_length);
2717 writeb(TX_AUTHENTICATE_LENGTH_MSB, pccs->var.tx_request.tx_data_length); 2832 writeb(TX_AUTHENTICATE_LENGTH_LSB,
2718 writeb(TX_AUTHENTICATE_LENGTH_LSB,pccs->var.tx_request.tx_data_length + 1); 2833 pccs->var.tx_request.tx_data_length + 1);
2719 writeb(0, &pccs->var.tx_request.pow_sav_mode); 2834 writeb(0, &pccs->var.tx_request.pow_sav_mode);
2720 2835
2721 ptx = local->sram + addr; 2836 ptx = local->sram + addr;
2722 /* fill in the mac header */ 2837 /* fill in the mac header */
2723 writeb(PROTOCOL_VER | AUTHENTIC_TYPE, &ptx->mac.frame_ctl_1); 2838 writeb(PROTOCOL_VER | AUTHENTIC_TYPE, &ptx->mac.frame_ctl_1);
2724 writeb(0, &ptx->mac.frame_ctl_2); 2839 writeb(0, &ptx->mac.frame_ctl_2);
2725 2840
2726 memcpy_toio(ptx->mac.addr_1, dest, ADDRLEN); 2841 memcpy_toio(ptx->mac.addr_1, dest, ADDRLEN);
2727 memcpy_toio(ptx->mac.addr_2, local->sparm.b4.a_mac_addr, ADDRLEN); 2842 memcpy_toio(ptx->mac.addr_2, local->sparm.b4.a_mac_addr, ADDRLEN);
2728 memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN); 2843 memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN);
2729 2844
2730 /* Fill in msg body with protocol 00 00, sequence 01 00 ,status 00 00 */ 2845 /* Fill in msg body with protocol 00 00, sequence 01 00 ,status 00 00 */
2731 memset_io(ptx->var, 0, 6); 2846 memset_io(ptx->var, 0, 6);
2732 writeb(auth_type & 0xff, ptx->var + 2); 2847 writeb(auth_type & 0xff, ptx->var + 2);
2733 2848
2734 /* Interrupt the firmware to process the command */ 2849 /* Interrupt the firmware to process the command */
2735 if (interrupt_ecf(local, ccsindex)) { 2850 if (interrupt_ecf(local, ccsindex)) {
2736 DEBUG(1,"ray_cs send authentication request failed - ECF not ready for intr\n"); 2851 DEBUG(1,
2737 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status); 2852 "ray_cs send authentication request failed - ECF not ready for intr\n");
2738 return -1; 2853 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
2739 } 2854 return -1;
2740 return 0; 2855 }
2856 return 0;
2741} /* End build_auth_frame */ 2857} /* End build_auth_frame */
2742 2858
2743/*===========================================================================*/ 2859/*===========================================================================*/
2744#ifdef CONFIG_PROC_FS 2860#ifdef CONFIG_PROC_FS
2745static void raycs_write(const char *name, write_proc_t *w, void *data) 2861static void raycs_write(const char *name, write_proc_t *w, void *data)
2746{ 2862{
2747 struct proc_dir_entry * entry = create_proc_entry(name, S_IFREG | S_IWUSR, NULL); 2863 struct proc_dir_entry *entry =
2864 create_proc_entry(name, S_IFREG | S_IWUSR, NULL);
2748 if (entry) { 2865 if (entry) {
2749 entry->write_proc = w; 2866 entry->write_proc = w;
2750 entry->data = data; 2867 entry->data = data;
2751 } 2868 }
2752} 2869}
2753 2870
2754static int write_essid(struct file *file, const char __user *buffer, unsigned long count, void *data) 2871static int write_essid(struct file *file, const char __user *buffer,
2872 unsigned long count, void *data)
2755{ 2873{
2756 static char proc_essid[33]; 2874 static char proc_essid[33];
2757 int len = count; 2875 int len = count;
@@ -2765,7 +2883,8 @@ static int write_essid(struct file *file, const char __user *buffer, unsigned lo
2765 return count; 2883 return count;
2766} 2884}
2767 2885
2768static int write_int(struct file *file, const char __user *buffer, unsigned long count, void *data) 2886static int write_int(struct file *file, const char __user *buffer,
2887 unsigned long count, void *data)
2769{ 2888{
2770 static char proc_number[10]; 2889 static char proc_number[10];
2771 char *p; 2890 char *p;
@@ -2785,7 +2904,7 @@ static int write_int(struct file *file, const char __user *buffer, unsigned long
2785 unsigned int c = *p - '0'; 2904 unsigned int c = *p - '0';
2786 if (c > 9) 2905 if (c > 9)
2787 return -EINVAL; 2906 return -EINVAL;
2788 nr = nr*10 + c; 2907 nr = nr * 10 + c;
2789 p++; 2908 p++;
2790 } while (--len); 2909 } while (--len);
2791 *(int *)data = nr; 2910 *(int *)data = nr;
@@ -2797,55 +2916,58 @@ static struct pcmcia_device_id ray_ids[] = {
2797 PCMCIA_DEVICE_MANF_CARD(0x01a6, 0x0000), 2916 PCMCIA_DEVICE_MANF_CARD(0x01a6, 0x0000),
2798 PCMCIA_DEVICE_NULL, 2917 PCMCIA_DEVICE_NULL,
2799}; 2918};
2919
2800MODULE_DEVICE_TABLE(pcmcia, ray_ids); 2920MODULE_DEVICE_TABLE(pcmcia, ray_ids);
2801 2921
2802static struct pcmcia_driver ray_driver = { 2922static struct pcmcia_driver ray_driver = {
2803 .owner = THIS_MODULE, 2923 .owner = THIS_MODULE,
2804 .drv = { 2924 .drv = {
2805 .name = "ray_cs", 2925 .name = "ray_cs",
2806 }, 2926 },
2807 .probe = ray_probe, 2927 .probe = ray_probe,
2808 .remove = ray_detach, 2928 .remove = ray_detach,
2809 .id_table = ray_ids, 2929 .id_table = ray_ids,
2810 .suspend = ray_suspend, 2930 .suspend = ray_suspend,
2811 .resume = ray_resume, 2931 .resume = ray_resume,
2812}; 2932};
2813 2933
2814static int __init init_ray_cs(void) 2934static int __init init_ray_cs(void)
2815{ 2935{
2816 int rc; 2936 int rc;
2817 2937
2818 DEBUG(1, "%s\n", rcsid); 2938 DEBUG(1, "%s\n", rcsid);
2819 rc = pcmcia_register_driver(&ray_driver); 2939 rc = pcmcia_register_driver(&ray_driver);
2820 DEBUG(1, "raylink init_module register_pcmcia_driver returns 0x%x\n",rc); 2940 DEBUG(1, "raylink init_module register_pcmcia_driver returns 0x%x\n",
2941 rc);
2821 2942
2822#ifdef CONFIG_PROC_FS 2943#ifdef CONFIG_PROC_FS
2823 proc_mkdir("driver/ray_cs", NULL); 2944 proc_mkdir("driver/ray_cs", NULL);
2824 2945
2825 proc_create("driver/ray_cs/ray_cs", 0, NULL, &ray_cs_proc_fops); 2946 proc_create("driver/ray_cs/ray_cs", 0, NULL, &ray_cs_proc_fops);
2826 raycs_write("driver/ray_cs/essid", write_essid, NULL); 2947 raycs_write("driver/ray_cs/essid", write_essid, NULL);
2827 raycs_write("driver/ray_cs/net_type", write_int, &net_type); 2948 raycs_write("driver/ray_cs/net_type", write_int, &net_type);
2828 raycs_write("driver/ray_cs/translate", write_int, &translate); 2949 raycs_write("driver/ray_cs/translate", write_int, &translate);
2829#endif 2950#endif
2830 if (translate != 0) translate = 1; 2951 if (translate != 0)
2831 return 0; 2952 translate = 1;
2953 return 0;
2832} /* init_ray_cs */ 2954} /* init_ray_cs */
2833 2955
2834/*===========================================================================*/ 2956/*===========================================================================*/
2835 2957
2836static void __exit exit_ray_cs(void) 2958static void __exit exit_ray_cs(void)
2837{ 2959{
2838 DEBUG(0, "ray_cs: cleanup_module\n"); 2960 DEBUG(0, "ray_cs: cleanup_module\n");
2839 2961
2840#ifdef CONFIG_PROC_FS 2962#ifdef CONFIG_PROC_FS
2841 remove_proc_entry("driver/ray_cs/ray_cs", NULL); 2963 remove_proc_entry("driver/ray_cs/ray_cs", NULL);
2842 remove_proc_entry("driver/ray_cs/essid", NULL); 2964 remove_proc_entry("driver/ray_cs/essid", NULL);
2843 remove_proc_entry("driver/ray_cs/net_type", NULL); 2965 remove_proc_entry("driver/ray_cs/net_type", NULL);
2844 remove_proc_entry("driver/ray_cs/translate", NULL); 2966 remove_proc_entry("driver/ray_cs/translate", NULL);
2845 remove_proc_entry("driver/ray_cs", NULL); 2967 remove_proc_entry("driver/ray_cs", NULL);
2846#endif 2968#endif
2847 2969
2848 pcmcia_unregister_driver(&ray_driver); 2970 pcmcia_unregister_driver(&ray_driver);
2849} /* exit_ray_cs */ 2971} /* exit_ray_cs */
2850 2972
2851module_init(init_ray_cs); 2973module_init(init_ray_cs);