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