1 /*=============================================================================
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
8 * Copyright (c) 1998 Corey Thomas (corey@world.std.com)
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.
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.
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
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
28 * Daniele Bellucci <bellucda@tiscali.it> - 07/10/2003
29 * - Audit copy_to_user in ioctl(SIOCGIWESSID)
31 =============================================================================*/
33 #include <linux/module.h>
34 #include <linux/kernel.h>
35 #include <linux/proc_fs.h>
36 #include <linux/ptrace.h>
37 #include <linux/seq_file.h>
38 #include <linux/string.h>
39 #include <linux/timer.h>
40 #include <linux/init.h>
41 #include <linux/netdevice.h>
42 #include <linux/etherdevice.h>
43 #include <linux/if_arp.h>
44 #include <linux/ioport.h>
45 #include <linux/skbuff.h>
46 #include <linux/ethtool.h>
47 #include <linux/ieee80211.h>
49 #include <pcmcia/cs.h>
50 #include <pcmcia/cistpl.h>
51 #include <pcmcia/cisreg.h>
52 #include <pcmcia/ds.h>
54 #include <linux/wireless.h>
55 #include <net/iw_handler.h>
58 #include <asm/system.h>
59 #include <asm/byteorder.h>
60 #include <asm/uaccess.h>
62 /* Warning : these stuff will slow down the driver... */
63 #define WIRELESS_SPY /* Enable spying addresses */
64 /* Definitions we need for spy */
65 typedef struct iw_statistics iw_stats;
66 typedef u_char mac_addr[ETH_ALEN]; /* Hardware address */
72 /** Prototypes based on PCMCIA skeleton driver *******************************/
73 static int ray_config(struct pcmcia_device *link);
74 static void ray_release(struct pcmcia_device *link);
75 static void ray_detach(struct pcmcia_device *p_dev);
77 /***** Prototypes indicated by device structure ******************************/
78 static int ray_dev_close(struct net_device *dev);
79 static int ray_dev_config(struct net_device *dev, struct ifmap *map);
80 static struct net_device_stats *ray_get_stats(struct net_device *dev);
81 static int ray_dev_init(struct net_device *dev);
83 static const struct ethtool_ops netdev_ethtool_ops;
85 static int ray_open(struct net_device *dev);
86 static netdev_tx_t ray_dev_start_xmit(struct sk_buff *skb,
87 struct net_device *dev);
88 static void set_multicast_list(struct net_device *dev);
89 static void ray_update_multi_list(struct net_device *dev, int all);
90 static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
91 unsigned char *data, int len);
92 static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
93 UCHAR msg_type, unsigned char *data);
94 static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len);
95 static iw_stats *ray_get_wireless_stats(struct net_device *dev);
96 static const struct iw_handler_def ray_handler_def;
98 /***** Prototypes for raylink functions **************************************/
99 static void authenticate(ray_dev_t *local);
100 static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type);
101 static void authenticate_timeout(u_long);
102 static int get_free_ccs(ray_dev_t *local);
103 static int get_free_tx_ccs(ray_dev_t *local);
104 static void init_startup_params(ray_dev_t *local);
105 static int parse_addr(char *in_str, UCHAR *out);
106 static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev, UCHAR type);
107 static int ray_init(struct net_device *dev);
108 static int interrupt_ecf(ray_dev_t *local, int ccs);
109 static void ray_reset(struct net_device *dev);
110 static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len);
111 static void verify_dl_startup(u_long);
113 /* Prototypes for interrpt time functions **********************************/
114 static irqreturn_t ray_interrupt(int reg, void *dev_id);
115 static void clear_interrupt(ray_dev_t *local);
116 static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
117 unsigned int pkt_addr, int rx_len);
118 static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr, int len);
119 static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem *prcs);
120 static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs);
121 static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
122 unsigned int pkt_addr, int rx_len);
123 static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
124 unsigned int pkt_addr, int rx_len);
125 static void associate(ray_dev_t *local);
127 /* Card command functions */
128 static int dl_startup_params(struct net_device *dev);
129 static void join_net(u_long local);
130 static void start_net(u_long local);
131 /* void start_net(ray_dev_t *local); */
133 /*===========================================================================*/
134 /* Parameters that can be set with 'insmod' */
136 /* ADHOC=0, Infrastructure=1 */
137 static int net_type = ADHOC;
139 /* Hop dwell time in Kus (1024 us units defined by 802.11) */
140 static int hop_dwell = 128;
142 /* Beacon period in Kus */
143 static int beacon_period = 256;
145 /* power save mode (0 = off, 1 = save power) */
148 /* String for network's Extended Service Set ID. 32 Characters max */
151 /* Default to encapsulation unless translation requested */
152 static int translate = 1;
154 static int country = USA;
160 /* 48 bit physical card address if overriding card's real physical
161 * address is required. Since IEEE 802.11 addresses are 48 bits
162 * like ethernet, an int can't be used, so a string is used. To
163 * allow use of addresses starting with a decimal digit, the first
164 * character must be a letter and will be ignored. This letter is
165 * followed by up to 12 hex digits which are the address. If less
166 * than 12 digits are used, the address will be left filled with 0's.
167 * Note that bit 0 of the first byte is the broadcast bit, and evil
168 * things will happen if it is not 0 in a card address.
170 static char *phy_addr = NULL;
173 /* A struct pcmcia_device structure has fields for most things that are needed
174 to keep track of a socket, but there will usually be some device
175 specific information that also needs to be kept track of. The
176 'priv' pointer in a struct pcmcia_device structure can be used to point to
177 a device-specific private data structure, like this.
179 static unsigned int ray_mem_speed = 500;
181 /* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */
182 static struct pcmcia_device *this_device = NULL;
184 MODULE_AUTHOR("Corey Thomas <corey@world.std.com>");
185 MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver");
186 MODULE_LICENSE("GPL");
188 module_param(net_type, int, 0);
189 module_param(hop_dwell, int, 0);
190 module_param(beacon_period, int, 0);
191 module_param(psm, int, 0);
192 module_param(essid, charp, 0);
193 module_param(translate, int, 0);
194 module_param(country, int, 0);
195 module_param(sniffer, int, 0);
196 module_param(bc, int, 0);
197 module_param(phy_addr, charp, 0);
198 module_param(ray_mem_speed, int, 0);
200 static UCHAR b5_default_startup_parms[] = {
201 0, 0, /* Adhoc station */
202 'L', 'I', 'N', 'U', 'X', 0, 0, 0, /* 32 char ESSID */
203 0, 0, 0, 0, 0, 0, 0, 0,
204 0, 0, 0, 0, 0, 0, 0, 0,
205 0, 0, 0, 0, 0, 0, 0, 0,
206 1, 0, /* Active scan, CA Mode */
207 0, 0, 0, 0, 0, 0, /* No default MAC addr */
208 0x7f, 0xff, /* Frag threshold */
209 0x00, 0x80, /* Hop time 128 Kus */
210 0x01, 0x00, /* Beacon period 256 Kus */
211 0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout */
212 0x1d, 0x82, 0x4e, /* SIFS, DIFS, PIFS */
213 0x7f, 0xff, /* RTS threshold */
214 0x04, 0xe2, 0x38, 0xA4, /* scan_dwell, max_scan_dwell */
215 0x05, /* assoc resp timeout thresh */
216 0x08, 0x02, 0x08, /* adhoc, infra, super cycle max */
217 0, /* Promiscuous mode */
218 0x0c, 0x0bd, /* Unique word */
219 0x32, /* Slot time */
220 0xff, 0xff, /* roam-low snr, low snr count */
221 0x05, 0xff, /* Infra, adhoc missed bcn thresh */
222 0x01, 0x0b, 0x4f, /* USA, hop pattern, hop pat length */
223 /* b4 - b5 differences start here */
224 0x00, 0x3f, /* CW max */
225 0x00, 0x0f, /* CW min */
226 0x04, 0x08, /* Noise gain, limit offset */
227 0x28, 0x28, /* det rssi, med busy offsets */
228 7, /* det sync thresh */
229 0, 2, 2, /* test mode, min, max */
230 0, /* allow broadcast SSID probe resp */
231 0, 0, /* privacy must start, can join */
232 2, 0, 0, 0, 0, 0, 0, 0 /* basic rate set */
235 static UCHAR b4_default_startup_parms[] = {
236 0, 0, /* Adhoc station */
237 'L', 'I', 'N', 'U', 'X', 0, 0, 0, /* 32 char ESSID */
238 0, 0, 0, 0, 0, 0, 0, 0,
239 0, 0, 0, 0, 0, 0, 0, 0,
240 0, 0, 0, 0, 0, 0, 0, 0,
241 1, 0, /* Active scan, CA Mode */
242 0, 0, 0, 0, 0, 0, /* No default MAC addr */
243 0x7f, 0xff, /* Frag threshold */
244 0x02, 0x00, /* Hop time */
245 0x00, 0x01, /* Beacon period */
246 0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout */
247 0x1d, 0x82, 0xce, /* SIFS, DIFS, PIFS */
248 0x7f, 0xff, /* RTS threshold */
249 0xfb, 0x1e, 0xc7, 0x5c, /* scan_dwell, max_scan_dwell */
250 0x05, /* assoc resp timeout thresh */
251 0x04, 0x02, 0x4, /* adhoc, infra, super cycle max */
252 0, /* Promiscuous mode */
253 0x0c, 0x0bd, /* Unique word */
254 0x4e, /* Slot time (TBD seems wrong) */
255 0xff, 0xff, /* roam-low snr, low snr count */
256 0x05, 0xff, /* Infra, adhoc missed bcn thresh */
257 0x01, 0x0b, 0x4e, /* USA, hop pattern, hop pat length */
258 /* b4 - b5 differences start here */
259 0x3f, 0x0f, /* CW max, min */
260 0x04, 0x08, /* Noise gain, limit offset */
261 0x28, 0x28, /* det rssi, med busy offsets */
262 7, /* det sync thresh */
263 0, 2, 2 /* test mode, min, max */
266 /*===========================================================================*/
267 static unsigned char eth2_llc[] = { 0xaa, 0xaa, 3, 0, 0, 0 };
269 static char hop_pattern_length[] = { 1,
270 USA_HOP_MOD, EUROPE_HOP_MOD,
271 JAPAN_HOP_MOD, KOREA_HOP_MOD,
272 SPAIN_HOP_MOD, FRANCE_HOP_MOD,
273 ISRAEL_HOP_MOD, AUSTRALIA_HOP_MOD,
277 static char rcsid[] =
278 "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.std.com>";
280 static const struct net_device_ops ray_netdev_ops = {
281 .ndo_init = ray_dev_init,
282 .ndo_open = ray_open,
283 .ndo_stop = ray_dev_close,
284 .ndo_start_xmit = ray_dev_start_xmit,
285 .ndo_set_config = ray_dev_config,
286 .ndo_get_stats = ray_get_stats,
287 .ndo_set_multicast_list = set_multicast_list,
288 .ndo_change_mtu = eth_change_mtu,
289 .ndo_set_mac_address = eth_mac_addr,
290 .ndo_validate_addr = eth_validate_addr,
293 /*=============================================================================
294 ray_attach() creates an "instance" of the driver, allocating
295 local data structures for one device. The device is registered
297 The dev_link structure is initialized, but we don't actually
298 configure the card at this point -- we wait until we receive a
299 card insertion event.
300 =============================================================================*/
301 static int ray_probe(struct pcmcia_device *p_dev)
304 struct net_device *dev;
306 dev_dbg(&p_dev->dev, "ray_attach()\n");
308 /* Allocate space for private device-specific data */
309 dev = alloc_etherdev(sizeof(ray_dev_t));
313 local = netdev_priv(dev);
314 local->finder = p_dev;
316 /* The io structure describes IO port mapping. None used here */
317 p_dev->resource[0]->end = 0;
318 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
320 /* General socket configuration */
321 p_dev->conf.Attributes = CONF_ENABLE_IRQ;
322 p_dev->conf.IntType = INT_MEMORY_AND_IO;
323 p_dev->conf.ConfigIndex = 1;
327 local->finder = p_dev;
328 local->card_status = CARD_INSERTED;
329 local->authentication_state = UNAUTHENTICATED;
330 local->num_multi = 0;
331 dev_dbg(&p_dev->dev, "ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
332 p_dev, dev, local, &ray_interrupt);
334 /* Raylink entries in the device structure */
335 dev->netdev_ops = &ray_netdev_ops;
336 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
337 dev->wireless_handlers = &ray_handler_def;
339 local->wireless_data.spy_data = &local->spy_data;
340 dev->wireless_data = &local->wireless_data;
341 #endif /* WIRELESS_SPY */
344 dev_dbg(&p_dev->dev, "ray_cs ray_attach calling ether_setup.)\n");
345 netif_stop_queue(dev);
347 init_timer(&local->timer);
350 return ray_config(p_dev);
356 /*=============================================================================
357 This deletes a driver "instance". The device is de-registered
358 with Card Services. If it has been released, all local data
359 structures are freed. Otherwise, the structures will be freed
360 when the device is released.
361 =============================================================================*/
362 static void ray_detach(struct pcmcia_device *link)
364 struct net_device *dev;
367 dev_dbg(&link->dev, "ray_detach\n");
374 local = netdev_priv(dev);
375 del_timer(&local->timer);
378 unregister_netdev(dev);
381 dev_dbg(&link->dev, "ray_cs ray_detach ending\n");
384 /*=============================================================================
385 ray_config() is run after a CARD_INSERTION event
386 is received, to configure the PCMCIA socket, and to make the
387 ethernet device available to the system.
388 =============================================================================*/
389 #define MAX_TUPLE_SIZE 128
390 static int ray_config(struct pcmcia_device *link)
395 struct net_device *dev = (struct net_device *)link->priv;
396 ray_dev_t *local = netdev_priv(dev);
398 dev_dbg(&link->dev, "ray_config\n");
400 /* Determine card type and firmware version */
401 printk(KERN_INFO "ray_cs Detected: %s%s%s%s\n",
402 link->prod_id[0] ? link->prod_id[0] : " ",
403 link->prod_id[1] ? link->prod_id[1] : " ",
404 link->prod_id[2] ? link->prod_id[2] : " ",
405 link->prod_id[3] ? link->prod_id[3] : " ");
407 /* Now allocate an interrupt line. Note that this does not
408 actually assign a handler to the interrupt.
410 ret = pcmcia_request_irq(link, ray_interrupt);
413 dev->irq = link->irq;
415 /* This actually configures the PCMCIA socket -- setting up
416 the I/O windows and the interrupt mapping.
418 ret = pcmcia_request_configuration(link, &link->conf);
422 /*** Set up 32k window for shared memory (transmit and control) ************/
424 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
427 req.AccessSpeed = ray_mem_speed;
428 ret = pcmcia_request_window(link, &req, &link->win);
431 ret = pcmcia_map_mem_page(link, link->win, 0);
434 local->sram = ioremap(req.Base, req.Size);
436 /*** Set up 16k window for shared memory (receive buffer) ***************/
438 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
441 req.AccessSpeed = ray_mem_speed;
442 ret = pcmcia_request_window(link, &req, &local->rmem_handle);
445 ret = pcmcia_map_mem_page(link, local->rmem_handle, 0x8000);
448 local->rmem = ioremap(req.Base, req.Size);
450 /*** Set up window for attribute memory ***********************************/
452 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT;
455 req.AccessSpeed = ray_mem_speed;
456 ret = pcmcia_request_window(link, &req, &local->amem_handle);
459 ret = pcmcia_map_mem_page(link, local->amem_handle, 0);
462 local->amem = ioremap(req.Base, req.Size);
464 dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram);
465 dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem);
466 dev_dbg(&link->dev, "ray_config amem=%p\n", local->amem);
467 if (ray_init(dev) < 0) {
472 SET_NETDEV_DEV(dev, &link->dev);
473 i = register_netdev(dev);
475 printk("ray_config register_netdev() failed\n");
480 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr %pM\n",
481 dev->name, dev->irq, dev->dev_addr);
490 static inline struct ccs __iomem *ccs_base(ray_dev_t *dev)
492 return dev->sram + CCS_BASE;
495 static inline struct rcs __iomem *rcs_base(ray_dev_t *dev)
498 * This looks nonsensical, since there is a separate
499 * RCS_BASE. But the difference between a "struct rcs"
500 * and a "struct ccs" ends up being in the _index_ off
501 * the base, so the base pointer is the same for both
504 return dev->sram + CCS_BASE;
507 /*===========================================================================*/
508 static int ray_init(struct net_device *dev)
512 struct ccs __iomem *pccs;
513 ray_dev_t *local = netdev_priv(dev);
514 struct pcmcia_device *link = local->finder;
515 dev_dbg(&link->dev, "ray_init(0x%p)\n", dev);
516 if (!(pcmcia_dev_present(link))) {
517 dev_dbg(&link->dev, "ray_init - device not present\n");
521 local->net_type = net_type;
522 local->sta_type = TYPE_STA;
524 /* Copy the startup results to local memory */
525 memcpy_fromio(&local->startup_res, local->sram + ECF_TO_HOST_BASE,
526 sizeof(struct startup_res_6));
528 /* Check Power up test status and get mac address from card */
529 if (local->startup_res.startup_word != 0x80) {
530 printk(KERN_INFO "ray_init ERROR card status = %2x\n",
531 local->startup_res.startup_word);
532 local->card_status = CARD_INIT_ERROR;
536 local->fw_ver = local->startup_res.firmware_version[0];
537 local->fw_bld = local->startup_res.firmware_version[1];
538 local->fw_var = local->startup_res.firmware_version[2];
539 dev_dbg(&link->dev, "ray_init firmware version %d.%d\n", local->fw_ver,
542 local->tib_length = 0x20;
543 if ((local->fw_ver == 5) && (local->fw_bld >= 30))
544 local->tib_length = local->startup_res.tib_length;
545 dev_dbg(&link->dev, "ray_init tib_length = 0x%02x\n", local->tib_length);
546 /* Initialize CCS's to buffer free state */
547 pccs = ccs_base(local);
548 for (i = 0; i < NUMBER_OF_CCS; i++) {
549 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
551 init_startup_params(local);
553 /* copy mac address to startup parameters */
554 if (parse_addr(phy_addr, local->sparm.b4.a_mac_addr)) {
555 p = local->sparm.b4.a_mac_addr;
557 memcpy(&local->sparm.b4.a_mac_addr,
558 &local->startup_res.station_addr, ADDRLEN);
559 p = local->sparm.b4.a_mac_addr;
562 clear_interrupt(local); /* Clear any interrupt from the card */
563 local->card_status = CARD_AWAITING_PARAM;
564 dev_dbg(&link->dev, "ray_init ending\n");
568 /*===========================================================================*/
569 /* Download startup parameters to the card and command it to read them */
570 static int dl_startup_params(struct net_device *dev)
573 ray_dev_t *local = netdev_priv(dev);
574 struct ccs __iomem *pccs;
575 struct pcmcia_device *link = local->finder;
577 dev_dbg(&link->dev, "dl_startup_params entered\n");
578 if (!(pcmcia_dev_present(link))) {
579 dev_dbg(&link->dev, "ray_cs dl_startup_params - device not present\n");
583 /* Copy parameters to host to ECF area */
584 if (local->fw_ver == 0x55)
585 memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b4,
586 sizeof(struct b4_startup_params));
588 memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b5,
589 sizeof(struct b5_startup_params));
591 /* Fill in the CCS fields for the ECF */
592 if ((ccsindex = get_free_ccs(local)) < 0)
594 local->dl_param_ccs = ccsindex;
595 pccs = ccs_base(local) + ccsindex;
596 writeb(CCS_DOWNLOAD_STARTUP_PARAMS, &pccs->cmd);
597 dev_dbg(&link->dev, "dl_startup_params start ccsindex = %d\n",
598 local->dl_param_ccs);
599 /* Interrupt the firmware to process the command */
600 if (interrupt_ecf(local, ccsindex)) {
601 printk(KERN_INFO "ray dl_startup_params failed - "
602 "ECF not ready for intr\n");
603 local->card_status = CARD_DL_PARAM_ERROR;
604 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
607 local->card_status = CARD_DL_PARAM;
608 /* Start kernel timer to wait for dl startup to complete. */
609 local->timer.expires = jiffies + HZ / 2;
610 local->timer.data = (long)local;
611 local->timer.function = &verify_dl_startup;
612 add_timer(&local->timer);
614 "ray_cs dl_startup_params started timer for verify_dl_startup\n");
616 } /* dl_startup_params */
618 /*===========================================================================*/
619 static void init_startup_params(ray_dev_t *local)
623 if (country > JAPAN_TEST)
625 else if (country < USA)
627 /* structure for hop time and beacon period is defined here using
628 * New 802.11D6.1 format. Card firmware is still using old format
631 * a_hop_time ms byte a_hop_time ms byte
632 * a_hop_time 2s byte a_hop_time ls byte
633 * a_hop_time ls byte a_beacon_period ms byte
634 * a_beacon_period a_beacon_period ls byte
636 * a_hop_time = uS a_hop_time = KuS
637 * a_beacon_period = hops a_beacon_period = KuS
638 *//* 64ms = 010000 */
639 if (local->fw_ver == 0x55) {
640 memcpy((UCHAR *) &local->sparm.b4, b4_default_startup_parms,
641 sizeof(struct b4_startup_params));
642 /* Translate sane kus input values to old build 4/5 format */
643 /* i = hop time in uS truncated to 3 bytes */
644 i = (hop_dwell * 1024) & 0xffffff;
645 local->sparm.b4.a_hop_time[0] = (i >> 16) & 0xff;
646 local->sparm.b4.a_hop_time[1] = (i >> 8) & 0xff;
647 local->sparm.b4.a_beacon_period[0] = 0;
648 local->sparm.b4.a_beacon_period[1] =
649 ((beacon_period / hop_dwell) - 1) & 0xff;
650 local->sparm.b4.a_curr_country_code = country;
651 local->sparm.b4.a_hop_pattern_length =
652 hop_pattern_length[(int)country] - 1;
654 local->sparm.b4.a_ack_timeout = 0x50;
655 local->sparm.b4.a_sifs = 0x3f;
657 } else { /* Version 5 uses real kus values */
658 memcpy((UCHAR *) &local->sparm.b5, b5_default_startup_parms,
659 sizeof(struct b5_startup_params));
661 local->sparm.b5.a_hop_time[0] = (hop_dwell >> 8) & 0xff;
662 local->sparm.b5.a_hop_time[1] = hop_dwell & 0xff;
663 local->sparm.b5.a_beacon_period[0] =
664 (beacon_period >> 8) & 0xff;
665 local->sparm.b5.a_beacon_period[1] = beacon_period & 0xff;
667 local->sparm.b5.a_power_mgt_state = 1;
668 local->sparm.b5.a_curr_country_code = country;
669 local->sparm.b5.a_hop_pattern_length =
670 hop_pattern_length[(int)country];
673 local->sparm.b4.a_network_type = net_type & 0x01;
674 local->sparm.b4.a_acting_as_ap_status = TYPE_STA;
677 strncpy(local->sparm.b4.a_current_ess_id, essid, ESSID_SIZE);
678 } /* init_startup_params */
680 /*===========================================================================*/
681 static void verify_dl_startup(u_long data)
683 ray_dev_t *local = (ray_dev_t *) data;
684 struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs;
686 struct pcmcia_device *link = local->finder;
688 if (!(pcmcia_dev_present(link))) {
689 dev_dbg(&link->dev, "ray_cs verify_dl_startup - device not present\n");
696 "verify_dl_startup parameters sent via ccs %d:\n",
697 local->dl_param_ccs);
698 for (i = 0; i < sizeof(struct b5_startup_params); i++) {
700 (unsigned int)readb(local->sram +
701 HOST_TO_ECF_BASE + i));
707 status = readb(&pccs->buffer_status);
708 if (status != CCS_BUFFER_FREE) {
710 "Download startup params failed. Status = %d\n",
712 local->card_status = CARD_DL_PARAM_ERROR;
715 if (local->sparm.b4.a_network_type == ADHOC)
716 start_net((u_long) local);
718 join_net((u_long) local);
719 } /* end verify_dl_startup */
721 /*===========================================================================*/
722 /* Command card to start a network */
723 static void start_net(u_long data)
725 ray_dev_t *local = (ray_dev_t *) data;
726 struct ccs __iomem *pccs;
728 struct pcmcia_device *link = local->finder;
729 if (!(pcmcia_dev_present(link))) {
730 dev_dbg(&link->dev, "ray_cs start_net - device not present\n");
733 /* Fill in the CCS fields for the ECF */
734 if ((ccsindex = get_free_ccs(local)) < 0)
736 pccs = ccs_base(local) + ccsindex;
737 writeb(CCS_START_NETWORK, &pccs->cmd);
738 writeb(0, &pccs->var.start_network.update_param);
739 /* Interrupt the firmware to process the command */
740 if (interrupt_ecf(local, ccsindex)) {
741 dev_dbg(&link->dev, "ray start net failed - card not ready for intr\n");
742 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
745 local->card_status = CARD_DOING_ACQ;
746 } /* end start_net */
748 /*===========================================================================*/
749 /* Command card to join a network */
750 static void join_net(u_long data)
752 ray_dev_t *local = (ray_dev_t *) data;
754 struct ccs __iomem *pccs;
756 struct pcmcia_device *link = local->finder;
758 if (!(pcmcia_dev_present(link))) {
759 dev_dbg(&link->dev, "ray_cs join_net - device not present\n");
762 /* Fill in the CCS fields for the ECF */
763 if ((ccsindex = get_free_ccs(local)) < 0)
765 pccs = ccs_base(local) + ccsindex;
766 writeb(CCS_JOIN_NETWORK, &pccs->cmd);
767 writeb(0, &pccs->var.join_network.update_param);
768 writeb(0, &pccs->var.join_network.net_initiated);
769 /* Interrupt the firmware to process the command */
770 if (interrupt_ecf(local, ccsindex)) {
771 dev_dbg(&link->dev, "ray join net failed - card not ready for intr\n");
772 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
775 local->card_status = CARD_DOING_ACQ;
778 /*============================================================================
779 After a card is removed, ray_release() will unregister the net
780 device, and release the PCMCIA configuration. If the device is
781 still open, this will be postponed until it is closed.
782 =============================================================================*/
783 static void ray_release(struct pcmcia_device *link)
785 struct net_device *dev = link->priv;
786 ray_dev_t *local = netdev_priv(dev);
788 dev_dbg(&link->dev, "ray_release\n");
790 del_timer(&local->timer);
792 iounmap(local->sram);
793 iounmap(local->rmem);
794 iounmap(local->amem);
795 pcmcia_disable_device(link);
797 dev_dbg(&link->dev, "ray_release ending\n");
800 static int ray_suspend(struct pcmcia_device *link)
802 struct net_device *dev = link->priv;
805 netif_device_detach(dev);
810 static int ray_resume(struct pcmcia_device *link)
812 struct net_device *dev = link->priv;
816 netif_device_attach(dev);
822 /*===========================================================================*/
823 static int ray_dev_init(struct net_device *dev)
825 #ifdef RAY_IMMEDIATE_INIT
827 #endif /* RAY_IMMEDIATE_INIT */
828 ray_dev_t *local = netdev_priv(dev);
829 struct pcmcia_device *link = local->finder;
831 dev_dbg(&link->dev, "ray_dev_init(dev=%p)\n", dev);
832 if (!(pcmcia_dev_present(link))) {
833 dev_dbg(&link->dev, "ray_dev_init - device not present\n");
836 #ifdef RAY_IMMEDIATE_INIT
837 /* Download startup parameters */
838 if ((i = dl_startup_params(dev)) < 0) {
839 printk(KERN_INFO "ray_dev_init dl_startup_params failed - "
840 "returns 0x%x\n", i);
843 #else /* RAY_IMMEDIATE_INIT */
844 /* Postpone the card init so that we can still configure the card,
845 * for example using the Wireless Extensions. The init will happen
846 * in ray_open() - Jean II */
848 "ray_dev_init: postponing card init to ray_open() ; Status = %d\n",
850 #endif /* RAY_IMMEDIATE_INIT */
852 /* copy mac and broadcast addresses to linux device */
853 memcpy(dev->dev_addr, &local->sparm.b4.a_mac_addr, ADDRLEN);
854 memset(dev->broadcast, 0xff, ETH_ALEN);
856 dev_dbg(&link->dev, "ray_dev_init ending\n");
860 /*===========================================================================*/
861 static int ray_dev_config(struct net_device *dev, struct ifmap *map)
863 ray_dev_t *local = netdev_priv(dev);
864 struct pcmcia_device *link = local->finder;
865 /* Dummy routine to satisfy device structure */
866 dev_dbg(&link->dev, "ray_dev_config(dev=%p,ifmap=%p)\n", dev, map);
867 if (!(pcmcia_dev_present(link))) {
868 dev_dbg(&link->dev, "ray_dev_config - device not present\n");
875 /*===========================================================================*/
876 static netdev_tx_t ray_dev_start_xmit(struct sk_buff *skb,
877 struct net_device *dev)
879 ray_dev_t *local = netdev_priv(dev);
880 struct pcmcia_device *link = local->finder;
881 short length = skb->len;
883 if (!pcmcia_dev_present(link)) {
884 dev_dbg(&link->dev, "ray_dev_start_xmit - device not present\n");
889 dev_dbg(&link->dev, "ray_dev_start_xmit(skb=%p, dev=%p)\n", skb, dev);
890 if (local->authentication_state == NEED_TO_AUTH) {
891 dev_dbg(&link->dev, "ray_cs Sending authentication request.\n");
892 if (!build_auth_frame(local, local->auth_id, OPEN_AUTH_REQUEST)) {
893 local->authentication_state = AUTHENTICATED;
894 netif_stop_queue(dev);
895 return NETDEV_TX_BUSY;
899 if (length < ETH_ZLEN) {
900 if (skb_padto(skb, ETH_ZLEN))
904 switch (ray_hw_xmit(skb->data, length, dev, DATA_TYPE)) {
907 netif_stop_queue(dev);
908 return NETDEV_TX_BUSY;
917 } /* ray_dev_start_xmit */
919 /*===========================================================================*/
920 static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev,
923 ray_dev_t *local = netdev_priv(dev);
924 struct ccs __iomem *pccs;
927 struct tx_msg __iomem *ptx; /* Address of xmit buffer in PC space */
928 short int addr; /* Address of xmit buffer in card space */
930 pr_debug("ray_hw_xmit(data=%p, len=%d, dev=%p)\n", data, len, dev);
931 if (len + TX_HEADER_LENGTH > TX_BUF_SIZE) {
932 printk(KERN_INFO "ray_hw_xmit packet too large: %d bytes\n",
936 switch (ccsindex = get_free_tx_ccs(local)) {
938 pr_debug("ray_hw_xmit tx_ccs table busy\n");
940 pr_debug("ray_hw_xmit No free tx ccs\n");
942 netif_stop_queue(dev);
947 addr = TX_BUF_BASE + (ccsindex << 11);
949 if (msg_type == DATA_TYPE) {
950 local->stats.tx_bytes += len;
951 local->stats.tx_packets++;
954 ptx = local->sram + addr;
956 ray_build_header(local, ptx, msg_type, data);
958 offset = translate_frame(local, ptx, data, len);
959 } else { /* Encapsulate frame */
960 /* TBD TIB length will move address of ptx->var */
961 memcpy_toio(&ptx->var, data, len);
965 /* fill in the CCS */
966 pccs = ccs_base(local) + ccsindex;
967 len += TX_HEADER_LENGTH + offset;
968 writeb(CCS_TX_REQUEST, &pccs->cmd);
969 writeb(addr >> 8, &pccs->var.tx_request.tx_data_ptr[0]);
970 writeb(local->tib_length, &pccs->var.tx_request.tx_data_ptr[1]);
971 writeb(len >> 8, &pccs->var.tx_request.tx_data_length[0]);
972 writeb(len & 0xff, &pccs->var.tx_request.tx_data_length[1]);
973 /* TBD still need psm_cam? */
974 writeb(PSM_CAM, &pccs->var.tx_request.pow_sav_mode);
975 writeb(local->net_default_tx_rate, &pccs->var.tx_request.tx_rate);
976 writeb(0, &pccs->var.tx_request.antenna);
977 pr_debug("ray_hw_xmit default_tx_rate = 0x%x\n",
978 local->net_default_tx_rate);
980 /* Interrupt the firmware to process the command */
981 if (interrupt_ecf(local, ccsindex)) {
982 pr_debug("ray_hw_xmit failed - ECF not ready for intr\n");
983 /* TBD very inefficient to copy packet to buffer, and then not
984 send it, but the alternative is to queue the messages and that
985 won't be done for a while. Maybe set tbusy until a CCS is free?
987 writeb(CCS_BUFFER_FREE, &pccs->buffer_status);
991 } /* end ray_hw_xmit */
993 /*===========================================================================*/
994 static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
995 unsigned char *data, int len)
997 __be16 proto = ((struct ethhdr *)data)->h_proto;
998 if (ntohs(proto) >= 1536) { /* DIX II ethernet frame */
999 pr_debug("ray_cs translate_frame DIX II\n");
1000 /* Copy LLC header to card buffer */
1001 memcpy_toio(&ptx->var, eth2_llc, sizeof(eth2_llc));
1002 memcpy_toio(((void __iomem *)&ptx->var) + sizeof(eth2_llc),
1003 (UCHAR *) &proto, 2);
1004 if (proto == htons(ETH_P_AARP) || proto == htons(ETH_P_IPX)) {
1005 /* This is the selective translation table, only 2 entries */
1007 &((struct snaphdr_t __iomem *)ptx->var)->org[3]);
1009 /* Copy body of ethernet packet without ethernet header */
1010 memcpy_toio((void __iomem *)&ptx->var +
1011 sizeof(struct snaphdr_t), data + ETH_HLEN,
1013 return (int)sizeof(struct snaphdr_t) - ETH_HLEN;
1014 } else { /* already 802 type, and proto is length */
1015 pr_debug("ray_cs translate_frame 802\n");
1016 if (proto == htons(0xffff)) { /* evil netware IPX 802.3 without LLC */
1017 pr_debug("ray_cs translate_frame evil IPX\n");
1018 memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
1019 return 0 - ETH_HLEN;
1021 memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
1022 return 0 - ETH_HLEN;
1024 /* TBD do other frame types */
1025 } /* end translate_frame */
1027 /*===========================================================================*/
1028 static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
1029 UCHAR msg_type, unsigned char *data)
1031 writeb(PROTOCOL_VER | msg_type, &ptx->mac.frame_ctl_1);
1032 /*** IEEE 802.11 Address field assignments *************
1033 TODS FROMDS addr_1 addr_2 addr_3 addr_4
1034 Adhoc 0 0 dest src (terminal) BSSID N/A
1035 AP to Terminal 0 1 dest AP(BSSID) source N/A
1036 Terminal to AP 1 0 AP(BSSID) src (terminal) dest N/A
1037 AP to AP 1 1 dest AP src AP dest source
1038 *******************************************************/
1039 if (local->net_type == ADHOC) {
1040 writeb(0, &ptx->mac.frame_ctl_2);
1041 memcpy_toio(ptx->mac.addr_1, ((struct ethhdr *)data)->h_dest,
1043 memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN);
1044 } else { /* infrastructure */
1046 if (local->sparm.b4.a_acting_as_ap_status) {
1047 writeb(FC2_FROM_DS, &ptx->mac.frame_ctl_2);
1048 memcpy_toio(ptx->mac.addr_1,
1049 ((struct ethhdr *)data)->h_dest, ADDRLEN);
1050 memcpy_toio(ptx->mac.addr_2, local->bss_id, 6);
1051 memcpy_toio(ptx->mac.addr_3,
1052 ((struct ethhdr *)data)->h_source, ADDRLEN);
1053 } else { /* Terminal */
1055 writeb(FC2_TO_DS, &ptx->mac.frame_ctl_2);
1056 memcpy_toio(ptx->mac.addr_1, local->bss_id, ADDRLEN);
1057 memcpy_toio(ptx->mac.addr_2,
1058 ((struct ethhdr *)data)->h_source, ADDRLEN);
1059 memcpy_toio(ptx->mac.addr_3,
1060 ((struct ethhdr *)data)->h_dest, ADDRLEN);
1063 } /* end encapsulate_frame */
1065 /*===========================================================================*/
1067 static void netdev_get_drvinfo(struct net_device *dev,
1068 struct ethtool_drvinfo *info)
1070 strcpy(info->driver, "ray_cs");
1073 static const struct ethtool_ops netdev_ethtool_ops = {
1074 .get_drvinfo = netdev_get_drvinfo,
1077 /*====================================================================*/
1079 /*------------------------------------------------------------------*/
1081 * Wireless Handler : get protocol name
1083 static int ray_get_name(struct net_device *dev, struct iw_request_info *info,
1084 union iwreq_data *wrqu, char *extra)
1086 strcpy(wrqu->name, "IEEE 802.11-FH");
1090 /*------------------------------------------------------------------*/
1092 * Wireless Handler : set frequency
1094 static int ray_set_freq(struct net_device *dev, struct iw_request_info *info,
1095 union iwreq_data *wrqu, char *extra)
1097 ray_dev_t *local = netdev_priv(dev);
1098 int err = -EINPROGRESS; /* Call commit handler */
1100 /* Reject if card is already initialised */
1101 if (local->card_status != CARD_AWAITING_PARAM)
1104 /* Setting by channel number */
1105 if ((wrqu->freq.m > USA_HOP_MOD) || (wrqu->freq.e > 0))
1108 local->sparm.b5.a_hop_pattern = wrqu->freq.m;
1113 /*------------------------------------------------------------------*/
1115 * Wireless Handler : get frequency
1117 static int ray_get_freq(struct net_device *dev, struct iw_request_info *info,
1118 union iwreq_data *wrqu, char *extra)
1120 ray_dev_t *local = netdev_priv(dev);
1122 wrqu->freq.m = local->sparm.b5.a_hop_pattern;
1127 /*------------------------------------------------------------------*/
1129 * Wireless Handler : set ESSID
1131 static int ray_set_essid(struct net_device *dev, struct iw_request_info *info,
1132 union iwreq_data *wrqu, char *extra)
1134 ray_dev_t *local = netdev_priv(dev);
1136 /* Reject if card is already initialised */
1137 if (local->card_status != CARD_AWAITING_PARAM)
1140 /* Check if we asked for `any' */
1141 if (wrqu->essid.flags == 0)
1142 /* Corey : can you do that ? */
1145 /* Check the size of the string */
1146 if (wrqu->essid.length > IW_ESSID_MAX_SIZE)
1149 /* Set the ESSID in the card */
1150 memset(local->sparm.b5.a_current_ess_id, 0, IW_ESSID_MAX_SIZE);
1151 memcpy(local->sparm.b5.a_current_ess_id, extra, wrqu->essid.length);
1153 return -EINPROGRESS; /* Call commit handler */
1156 /*------------------------------------------------------------------*/
1158 * Wireless Handler : get ESSID
1160 static int ray_get_essid(struct net_device *dev, struct iw_request_info *info,
1161 union iwreq_data *wrqu, char *extra)
1163 ray_dev_t *local = netdev_priv(dev);
1165 /* Get the essid that was set */
1166 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);
1169 wrqu->essid.length = strlen(extra);
1170 wrqu->essid.flags = 1; /* active */
1175 /*------------------------------------------------------------------*/
1177 * Wireless Handler : get AP address
1179 static int ray_get_wap(struct net_device *dev, struct iw_request_info *info,
1180 union iwreq_data *wrqu, char *extra)
1182 ray_dev_t *local = netdev_priv(dev);
1184 memcpy(wrqu->ap_addr.sa_data, local->bss_id, ETH_ALEN);
1185 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
1190 /*------------------------------------------------------------------*/
1192 * Wireless Handler : set Bit-Rate
1194 static int ray_set_rate(struct net_device *dev, struct iw_request_info *info,
1195 union iwreq_data *wrqu, char *extra)
1197 ray_dev_t *local = netdev_priv(dev);
1199 /* Reject if card is already initialised */
1200 if (local->card_status != CARD_AWAITING_PARAM)
1203 /* Check if rate is in range */
1204 if ((wrqu->bitrate.value != 1000000) && (wrqu->bitrate.value != 2000000))
1207 /* Hack for 1.5 Mb/s instead of 2 Mb/s */
1208 if ((local->fw_ver == 0x55) && /* Please check */
1209 (wrqu->bitrate.value == 2000000))
1210 local->net_default_tx_rate = 3;
1212 local->net_default_tx_rate = wrqu->bitrate.value / 500000;
1217 /*------------------------------------------------------------------*/
1219 * Wireless Handler : get Bit-Rate
1221 static int ray_get_rate(struct net_device *dev, struct iw_request_info *info,
1222 union iwreq_data *wrqu, char *extra)
1224 ray_dev_t *local = netdev_priv(dev);
1226 if (local->net_default_tx_rate == 3)
1227 wrqu->bitrate.value = 2000000; /* Hum... */
1229 wrqu->bitrate.value = local->net_default_tx_rate * 500000;
1230 wrqu->bitrate.fixed = 0; /* We are in auto mode */
1235 /*------------------------------------------------------------------*/
1237 * Wireless Handler : set RTS threshold
1239 static int ray_set_rts(struct net_device *dev, struct iw_request_info *info,
1240 union iwreq_data *wrqu, char *extra)
1242 ray_dev_t *local = netdev_priv(dev);
1243 int rthr = wrqu->rts.value;
1245 /* Reject if card is already initialised */
1246 if (local->card_status != CARD_AWAITING_PARAM)
1249 /* if(wrq->u.rts.fixed == 0) we should complain */
1250 if (wrqu->rts.disabled)
1253 if ((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */
1256 local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF;
1257 local->sparm.b5.a_rts_threshold[1] = rthr & 0xFF;
1259 return -EINPROGRESS; /* Call commit handler */
1262 /*------------------------------------------------------------------*/
1264 * Wireless Handler : get RTS threshold
1266 static int ray_get_rts(struct net_device *dev, struct iw_request_info *info,
1267 union iwreq_data *wrqu, char *extra)
1269 ray_dev_t *local = netdev_priv(dev);
1271 wrqu->rts.value = (local->sparm.b5.a_rts_threshold[0] << 8)
1272 + local->sparm.b5.a_rts_threshold[1];
1273 wrqu->rts.disabled = (wrqu->rts.value == 32767);
1274 wrqu->rts.fixed = 1;
1279 /*------------------------------------------------------------------*/
1281 * Wireless Handler : set Fragmentation threshold
1283 static int ray_set_frag(struct net_device *dev, struct iw_request_info *info,
1284 union iwreq_data *wrqu, char *extra)
1286 ray_dev_t *local = netdev_priv(dev);
1287 int fthr = wrqu->frag.value;
1289 /* Reject if card is already initialised */
1290 if (local->card_status != CARD_AWAITING_PARAM)
1293 /* if(wrq->u.frag.fixed == 0) should complain */
1294 if (wrqu->frag.disabled)
1297 if ((fthr < 256) || (fthr > 2347)) /* To check out ! */
1300 local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF;
1301 local->sparm.b5.a_frag_threshold[1] = fthr & 0xFF;
1303 return -EINPROGRESS; /* Call commit handler */
1306 /*------------------------------------------------------------------*/
1308 * Wireless Handler : get Fragmentation threshold
1310 static int ray_get_frag(struct net_device *dev, struct iw_request_info *info,
1311 union iwreq_data *wrqu, char *extra)
1313 ray_dev_t *local = netdev_priv(dev);
1315 wrqu->frag.value = (local->sparm.b5.a_frag_threshold[0] << 8)
1316 + local->sparm.b5.a_frag_threshold[1];
1317 wrqu->frag.disabled = (wrqu->frag.value == 32767);
1318 wrqu->frag.fixed = 1;
1323 /*------------------------------------------------------------------*/
1325 * Wireless Handler : set Mode of Operation
1327 static int ray_set_mode(struct net_device *dev, struct iw_request_info *info,
1328 union iwreq_data *wrqu, char *extra)
1330 ray_dev_t *local = netdev_priv(dev);
1331 int err = -EINPROGRESS; /* Call commit handler */
1334 /* Reject if card is already initialised */
1335 if (local->card_status != CARD_AWAITING_PARAM)
1338 switch (wrqu->mode) {
1343 local->sparm.b5.a_network_type = card_mode;
1352 /*------------------------------------------------------------------*/
1354 * Wireless Handler : get Mode of Operation
1356 static int ray_get_mode(struct net_device *dev, struct iw_request_info *info,
1357 union iwreq_data *wrqu, char *extra)
1359 ray_dev_t *local = netdev_priv(dev);
1361 if (local->sparm.b5.a_network_type)
1362 wrqu->mode = IW_MODE_INFRA;
1364 wrqu->mode = IW_MODE_ADHOC;
1369 /*------------------------------------------------------------------*/
1371 * Wireless Handler : get range info
1373 static int ray_get_range(struct net_device *dev, struct iw_request_info *info,
1374 union iwreq_data *wrqu, char *extra)
1376 struct iw_range *range = (struct iw_range *)extra;
1378 memset(range, 0, sizeof(struct iw_range));
1380 /* Set the length (very important for backward compatibility) */
1381 wrqu->data.length = sizeof(struct iw_range);
1383 /* Set the Wireless Extension versions */
1384 range->we_version_compiled = WIRELESS_EXT;
1385 range->we_version_source = 9;
1387 /* Set information in the range struct */
1388 range->throughput = 1.1 * 1000 * 1000; /* Put the right number here */
1389 range->num_channels = hop_pattern_length[(int)country];
1390 range->num_frequency = 0;
1391 range->max_qual.qual = 0;
1392 range->max_qual.level = 255; /* What's the correct value ? */
1393 range->max_qual.noise = 255; /* Idem */
1394 range->num_bitrates = 2;
1395 range->bitrate[0] = 1000000; /* 1 Mb/s */
1396 range->bitrate[1] = 2000000; /* 2 Mb/s */
1400 /*------------------------------------------------------------------*/
1402 * Wireless Private Handler : set framing mode
1404 static int ray_set_framing(struct net_device *dev, struct iw_request_info *info,
1405 union iwreq_data *wrqu, char *extra)
1407 translate = *(extra); /* Set framing mode */
1412 /*------------------------------------------------------------------*/
1414 * Wireless Private Handler : get framing mode
1416 static int ray_get_framing(struct net_device *dev, struct iw_request_info *info,
1417 union iwreq_data *wrqu, char *extra)
1419 *(extra) = translate;
1424 /*------------------------------------------------------------------*/
1426 * Wireless Private Handler : get country
1428 static int ray_get_country(struct net_device *dev, struct iw_request_info *info,
1429 union iwreq_data *wrqu, char *extra)
1436 /*------------------------------------------------------------------*/
1438 * Commit handler : called after a bunch of SET operations
1440 static int ray_commit(struct net_device *dev, struct iw_request_info *info,
1441 union iwreq_data *wrqu, char *extra)
1446 /*------------------------------------------------------------------*/
1448 * Stats handler : return Wireless Stats
1450 static iw_stats *ray_get_wireless_stats(struct net_device *dev)
1452 ray_dev_t *local = netdev_priv(dev);
1453 struct pcmcia_device *link = local->finder;
1454 struct status __iomem *p = local->sram + STATUS_BASE;
1456 local->wstats.status = local->card_status;
1458 if ((local->spy_data.spy_number > 0)
1459 && (local->sparm.b5.a_network_type == 0)) {
1460 /* Get it from the first node in spy list */
1461 local->wstats.qual.qual = local->spy_data.spy_stat[0].qual;
1462 local->wstats.qual.level = local->spy_data.spy_stat[0].level;
1463 local->wstats.qual.noise = local->spy_data.spy_stat[0].noise;
1464 local->wstats.qual.updated =
1465 local->spy_data.spy_stat[0].updated;
1467 #endif /* WIRELESS_SPY */
1469 if (pcmcia_dev_present(link)) {
1470 local->wstats.qual.noise = readb(&p->rxnoise);
1471 local->wstats.qual.updated |= 4;
1474 return &local->wstats;
1475 } /* end ray_get_wireless_stats */
1477 /*------------------------------------------------------------------*/
1479 * Structures to export the Wireless Handlers
1482 static const iw_handler ray_handler[] = {
1483 IW_HANDLER(SIOCSIWCOMMIT, ray_commit),
1484 IW_HANDLER(SIOCGIWNAME, ray_get_name),
1485 IW_HANDLER(SIOCSIWFREQ, ray_set_freq),
1486 IW_HANDLER(SIOCGIWFREQ, ray_get_freq),
1487 IW_HANDLER(SIOCSIWMODE, ray_set_mode),
1488 IW_HANDLER(SIOCGIWMODE, ray_get_mode),
1489 IW_HANDLER(SIOCGIWRANGE, ray_get_range),
1491 IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
1492 IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
1493 IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
1494 IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
1495 #endif /* WIRELESS_SPY */
1496 IW_HANDLER(SIOCGIWAP, ray_get_wap),
1497 IW_HANDLER(SIOCSIWESSID, ray_set_essid),
1498 IW_HANDLER(SIOCGIWESSID, ray_get_essid),
1499 IW_HANDLER(SIOCSIWRATE, ray_set_rate),
1500 IW_HANDLER(SIOCGIWRATE, ray_get_rate),
1501 IW_HANDLER(SIOCSIWRTS, ray_set_rts),
1502 IW_HANDLER(SIOCGIWRTS, ray_get_rts),
1503 IW_HANDLER(SIOCSIWFRAG, ray_set_frag),
1504 IW_HANDLER(SIOCGIWFRAG, ray_get_frag),
1507 #define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */
1508 #define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1 /* Get framing mode */
1509 #define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */
1511 static const iw_handler ray_private_handler[] = {
1512 [0] = ray_set_framing,
1513 [1] = ray_get_framing,
1514 [3] = ray_get_country,
1517 static const struct iw_priv_args ray_private_args[] = {
1518 /* cmd, set_args, get_args, name */
1519 {SIOCSIPFRAMING, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0,
1521 {SIOCGIPFRAMING, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
1523 {SIOCGIPCOUNTRY, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
1527 static const struct iw_handler_def ray_handler_def = {
1528 .num_standard = ARRAY_SIZE(ray_handler),
1529 .num_private = ARRAY_SIZE(ray_private_handler),
1530 .num_private_args = ARRAY_SIZE(ray_private_args),
1531 .standard = ray_handler,
1532 .private = ray_private_handler,
1533 .private_args = ray_private_args,
1534 .get_wireless_stats = ray_get_wireless_stats,
1537 /*===========================================================================*/
1538 static int ray_open(struct net_device *dev)
1540 ray_dev_t *local = netdev_priv(dev);
1541 struct pcmcia_device *link;
1542 link = local->finder;
1544 dev_dbg(&link->dev, "ray_open('%s')\n", dev->name);
1546 if (link->open == 0)
1547 local->num_multi = 0;
1550 /* If the card is not started, time to start it ! - Jean II */
1551 if (local->card_status == CARD_AWAITING_PARAM) {
1554 dev_dbg(&link->dev, "ray_open: doing init now !\n");
1556 /* Download startup parameters */
1557 if ((i = dl_startup_params(dev)) < 0) {
1559 "ray_dev_init dl_startup_params failed - "
1560 "returns 0x%x\n", i);
1566 netif_stop_queue(dev);
1568 netif_start_queue(dev);
1570 dev_dbg(&link->dev, "ray_open ending\n");
1572 } /* end ray_open */
1574 /*===========================================================================*/
1575 static int ray_dev_close(struct net_device *dev)
1577 ray_dev_t *local = netdev_priv(dev);
1578 struct pcmcia_device *link;
1579 link = local->finder;
1581 dev_dbg(&link->dev, "ray_dev_close('%s')\n", dev->name);
1584 netif_stop_queue(dev);
1586 /* In here, we should stop the hardware (stop card from beeing active)
1587 * and set local->card_status to CARD_AWAITING_PARAM, so that while the
1588 * card is closed we can chage its configuration.
1589 * Probably also need a COR reset to get sane state - Jean II */
1592 } /* end ray_dev_close */
1594 /*===========================================================================*/
1595 static void ray_reset(struct net_device *dev)
1597 pr_debug("ray_reset entered\n");
1600 /*===========================================================================*/
1601 /* Cause a firmware interrupt if it is ready for one */
1602 /* Return nonzero if not ready */
1603 static int interrupt_ecf(ray_dev_t *local, int ccs)
1606 struct pcmcia_device *link = local->finder;
1608 if (!(pcmcia_dev_present(link))) {
1609 dev_dbg(&link->dev, "ray_cs interrupt_ecf - device not present\n");
1612 dev_dbg(&link->dev, "interrupt_ecf(local=%p, ccs = 0x%x\n", local, ccs);
1615 (readb(local->amem + CIS_OFFSET + ECF_INTR_OFFSET) &
1619 dev_dbg(&link->dev, "ray_cs interrupt_ecf card not ready for interrupt\n");
1622 /* Fill the mailbox, then kick the card */
1623 writeb(ccs, local->sram + SCB_BASE);
1624 writeb(ECF_INTR_SET, local->amem + CIS_OFFSET + ECF_INTR_OFFSET);
1626 } /* interrupt_ecf */
1628 /*===========================================================================*/
1629 /* Get next free transmit CCS */
1630 /* Return - index of current tx ccs */
1631 static int get_free_tx_ccs(ray_dev_t *local)
1634 struct ccs __iomem *pccs = ccs_base(local);
1635 struct pcmcia_device *link = local->finder;
1637 if (!(pcmcia_dev_present(link))) {
1638 dev_dbg(&link->dev, "ray_cs get_free_tx_ccs - device not present\n");
1642 if (test_and_set_bit(0, &local->tx_ccs_lock)) {
1643 dev_dbg(&link->dev, "ray_cs tx_ccs_lock busy\n");
1647 for (i = 0; i < NUMBER_OF_TX_CCS; i++) {
1648 if (readb(&(pccs + i)->buffer_status) == CCS_BUFFER_FREE) {
1649 writeb(CCS_BUFFER_BUSY, &(pccs + i)->buffer_status);
1650 writeb(CCS_END_LIST, &(pccs + i)->link);
1651 local->tx_ccs_lock = 0;
1655 local->tx_ccs_lock = 0;
1656 dev_dbg(&link->dev, "ray_cs ERROR no free tx CCS for raylink card\n");
1658 } /* get_free_tx_ccs */
1660 /*===========================================================================*/
1661 /* Get next free CCS */
1662 /* Return - index of current ccs */
1663 static int get_free_ccs(ray_dev_t *local)
1666 struct ccs __iomem *pccs = ccs_base(local);
1667 struct pcmcia_device *link = local->finder;
1669 if (!(pcmcia_dev_present(link))) {
1670 dev_dbg(&link->dev, "ray_cs get_free_ccs - device not present\n");
1673 if (test_and_set_bit(0, &local->ccs_lock)) {
1674 dev_dbg(&link->dev, "ray_cs ccs_lock busy\n");
1678 for (i = NUMBER_OF_TX_CCS; i < NUMBER_OF_CCS; i++) {
1679 if (readb(&(pccs + i)->buffer_status) == CCS_BUFFER_FREE) {
1680 writeb(CCS_BUFFER_BUSY, &(pccs + i)->buffer_status);
1681 writeb(CCS_END_LIST, &(pccs + i)->link);
1682 local->ccs_lock = 0;
1686 local->ccs_lock = 0;
1687 dev_dbg(&link->dev, "ray_cs ERROR no free CCS for raylink card\n");
1689 } /* get_free_ccs */
1691 /*===========================================================================*/
1692 static void authenticate_timeout(u_long data)
1694 ray_dev_t *local = (ray_dev_t *) data;
1695 del_timer(&local->timer);
1696 printk(KERN_INFO "ray_cs Authentication with access point failed"
1698 join_net((u_long) local);
1701 /*===========================================================================*/
1702 static int parse_addr(char *in_str, UCHAR *out)
1710 if ((len = strlen(in_str)) < 2)
1712 memset(out, 0, ADDRLEN);
1721 if ((k = hex_to_bin(in_str[j--])) != -1)
1728 if ((k = hex_to_bin(in_str[j--])) != -1)
1738 /*===========================================================================*/
1739 static struct net_device_stats *ray_get_stats(struct net_device *dev)
1741 ray_dev_t *local = netdev_priv(dev);
1742 struct pcmcia_device *link = local->finder;
1743 struct status __iomem *p = local->sram + STATUS_BASE;
1744 if (!(pcmcia_dev_present(link))) {
1745 dev_dbg(&link->dev, "ray_cs net_device_stats - device not present\n");
1746 return &local->stats;
1748 if (readb(&p->mrx_overflow_for_host)) {
1749 local->stats.rx_over_errors += swab16(readw(&p->mrx_overflow));
1750 writeb(0, &p->mrx_overflow);
1751 writeb(0, &p->mrx_overflow_for_host);
1753 if (readb(&p->mrx_checksum_error_for_host)) {
1754 local->stats.rx_crc_errors +=
1755 swab16(readw(&p->mrx_checksum_error));
1756 writeb(0, &p->mrx_checksum_error);
1757 writeb(0, &p->mrx_checksum_error_for_host);
1759 if (readb(&p->rx_hec_error_for_host)) {
1760 local->stats.rx_frame_errors += swab16(readw(&p->rx_hec_error));
1761 writeb(0, &p->rx_hec_error);
1762 writeb(0, &p->rx_hec_error_for_host);
1764 return &local->stats;
1767 /*===========================================================================*/
1768 static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value,
1771 ray_dev_t *local = netdev_priv(dev);
1772 struct pcmcia_device *link = local->finder;
1775 struct ccs __iomem *pccs;
1777 if (!(pcmcia_dev_present(link))) {
1778 dev_dbg(&link->dev, "ray_update_parm - device not present\n");
1782 if ((ccsindex = get_free_ccs(local)) < 0) {
1783 dev_dbg(&link->dev, "ray_update_parm - No free ccs\n");
1786 pccs = ccs_base(local) + ccsindex;
1787 writeb(CCS_UPDATE_PARAMS, &pccs->cmd);
1788 writeb(objid, &pccs->var.update_param.object_id);
1789 writeb(1, &pccs->var.update_param.number_objects);
1790 writeb(0, &pccs->var.update_param.failure_cause);
1791 for (i = 0; i < len; i++) {
1792 writeb(value[i], local->sram + HOST_TO_ECF_BASE);
1794 /* Interrupt the firmware to process the command */
1795 if (interrupt_ecf(local, ccsindex)) {
1796 dev_dbg(&link->dev, "ray_cs associate failed - ECF not ready for intr\n");
1797 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
1801 /*===========================================================================*/
1802 static void ray_update_multi_list(struct net_device *dev, int all)
1805 struct ccs __iomem *pccs;
1806 ray_dev_t *local = netdev_priv(dev);
1807 struct pcmcia_device *link = local->finder;
1808 void __iomem *p = local->sram + HOST_TO_ECF_BASE;
1810 if (!(pcmcia_dev_present(link))) {
1811 dev_dbg(&link->dev, "ray_update_multi_list - device not present\n");
1814 dev_dbg(&link->dev, "ray_update_multi_list(%p)\n", dev);
1815 if ((ccsindex = get_free_ccs(local)) < 0) {
1816 dev_dbg(&link->dev, "ray_update_multi - No free ccs\n");
1819 pccs = ccs_base(local) + ccsindex;
1820 writeb(CCS_UPDATE_MULTICAST_LIST, &pccs->cmd);
1823 writeb(0xff, &pccs->var);
1824 local->num_multi = 0xff;
1826 struct netdev_hw_addr *ha;
1829 /* Copy the kernel's list of MC addresses to card */
1830 netdev_for_each_mc_addr(ha, dev) {
1831 memcpy_toio(p, ha->addr, ETH_ALEN);
1833 "ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n",
1834 ha->addr[0], ha->addr[1],
1835 ha->addr[2], ha->addr[3],
1836 ha->addr[4], ha->addr[5]);
1840 if (i > 256 / ADDRLEN)
1842 writeb((UCHAR) i, &pccs->var);
1843 dev_dbg(&link->dev, "ray_cs update_multi %d addresses in list\n", i);
1844 /* Interrupt the firmware to process the command */
1845 local->num_multi = i;
1847 if (interrupt_ecf(local, ccsindex)) {
1849 "ray_cs update_multi failed - ECF not ready for intr\n");
1850 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
1852 } /* end ray_update_multi_list */
1854 /*===========================================================================*/
1855 static void set_multicast_list(struct net_device *dev)
1857 ray_dev_t *local = netdev_priv(dev);
1860 pr_debug("ray_cs set_multicast_list(%p)\n", dev);
1862 if (dev->flags & IFF_PROMISC) {
1863 if (local->sparm.b5.a_promiscuous_mode == 0) {
1864 pr_debug("ray_cs set_multicast_list promisc on\n");
1865 local->sparm.b5.a_promiscuous_mode = 1;
1867 ray_update_parm(dev, OBJID_promiscuous_mode,
1868 &promisc, sizeof(promisc));
1871 if (local->sparm.b5.a_promiscuous_mode == 1) {
1872 pr_debug("ray_cs set_multicast_list promisc off\n");
1873 local->sparm.b5.a_promiscuous_mode = 0;
1875 ray_update_parm(dev, OBJID_promiscuous_mode,
1876 &promisc, sizeof(promisc));
1880 if (dev->flags & IFF_ALLMULTI)
1881 ray_update_multi_list(dev, 1);
1883 if (local->num_multi != netdev_mc_count(dev))
1884 ray_update_multi_list(dev, 0);
1886 } /* end set_multicast_list */
1888 /*=============================================================================
1889 * All routines below here are run at interrupt time.
1890 =============================================================================*/
1891 static irqreturn_t ray_interrupt(int irq, void *dev_id)
1893 struct net_device *dev = (struct net_device *)dev_id;
1894 struct pcmcia_device *link;
1896 struct ccs __iomem *pccs;
1897 struct rcs __iomem *prcs;
1903 if (dev == NULL) /* Note that we want interrupts with dev->start == 0 */
1906 pr_debug("ray_cs: interrupt for *dev=%p\n", dev);
1908 local = netdev_priv(dev);
1909 link = (struct pcmcia_device *)local->finder;
1910 if (!pcmcia_dev_present(link)) {
1912 "ray_cs interrupt from device not present or suspended.\n");
1915 rcsindex = readb(&((struct scb __iomem *)(local->sram))->rcs_index);
1917 if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
1918 dev_dbg(&link->dev, "ray_cs interrupt bad rcsindex = 0x%x\n", rcsindex);
1919 clear_interrupt(local);
1922 if (rcsindex < NUMBER_OF_CCS) { /* If it's a returned CCS */
1923 pccs = ccs_base(local) + rcsindex;
1924 cmd = readb(&pccs->cmd);
1925 status = readb(&pccs->buffer_status);
1927 case CCS_DOWNLOAD_STARTUP_PARAMS: /* Happens in firmware someday */
1928 del_timer(&local->timer);
1929 if (status == CCS_COMMAND_COMPLETE) {
1931 "ray_cs interrupt download_startup_parameters OK\n");
1934 "ray_cs interrupt download_startup_parameters fail\n");
1937 case CCS_UPDATE_PARAMS:
1938 dev_dbg(&link->dev, "ray_cs interrupt update params done\n");
1939 if (status != CCS_COMMAND_COMPLETE) {
1941 readb(&pccs->var.update_param.
1944 "ray_cs interrupt update params failed - reason %d\n",
1948 case CCS_REPORT_PARAMS:
1949 dev_dbg(&link->dev, "ray_cs interrupt report params done\n");
1951 case CCS_UPDATE_MULTICAST_LIST: /* Note that this CCS isn't returned */
1953 "ray_cs interrupt CCS Update Multicast List done\n");
1955 case CCS_UPDATE_POWER_SAVINGS_MODE:
1957 "ray_cs interrupt update power save mode done\n");
1959 case CCS_START_NETWORK:
1960 case CCS_JOIN_NETWORK:
1961 if (status == CCS_COMMAND_COMPLETE) {
1963 (&pccs->var.start_network.net_initiated) ==
1966 "ray_cs interrupt network \"%s\" started\n",
1967 local->sparm.b4.a_current_ess_id);
1970 "ray_cs interrupt network \"%s\" joined\n",
1971 local->sparm.b4.a_current_ess_id);
1973 memcpy_fromio(&local->bss_id,
1974 pccs->var.start_network.bssid,
1977 if (local->fw_ver == 0x55)
1978 local->net_default_tx_rate = 3;
1980 local->net_default_tx_rate =
1981 readb(&pccs->var.start_network.
1982 net_default_tx_rate);
1984 readb(&pccs->var.start_network.encryption);
1985 if (!sniffer && (local->net_type == INFRA)
1986 && !(local->sparm.b4.a_acting_as_ap_status)) {
1987 authenticate(local);
1989 local->card_status = CARD_ACQ_COMPLETE;
1991 local->card_status = CARD_ACQ_FAILED;
1993 del_timer(&local->timer);
1994 local->timer.expires = jiffies + HZ * 5;
1995 local->timer.data = (long)local;
1996 if (status == CCS_START_NETWORK) {
1998 "ray_cs interrupt network \"%s\" start failed\n",
1999 local->sparm.b4.a_current_ess_id);
2000 local->timer.function = &start_net;
2003 "ray_cs interrupt network \"%s\" join failed\n",
2004 local->sparm.b4.a_current_ess_id);
2005 local->timer.function = &join_net;
2007 add_timer(&local->timer);
2010 case CCS_START_ASSOCIATION:
2011 if (status == CCS_COMMAND_COMPLETE) {
2012 local->card_status = CARD_ASSOC_COMPLETE;
2013 dev_dbg(&link->dev, "ray_cs association successful\n");
2015 dev_dbg(&link->dev, "ray_cs association failed,\n");
2016 local->card_status = CARD_ASSOC_FAILED;
2017 join_net((u_long) local);
2020 case CCS_TX_REQUEST:
2021 if (status == CCS_COMMAND_COMPLETE) {
2023 "ray_cs interrupt tx request complete\n");
2026 "ray_cs interrupt tx request failed\n");
2029 netif_start_queue(dev);
2030 netif_wake_queue(dev);
2032 case CCS_TEST_MEMORY:
2033 dev_dbg(&link->dev, "ray_cs interrupt mem test done\n");
2037 "ray_cs interrupt Unexpected CCS returned - Shutdown\n");
2039 case CCS_DUMP_MEMORY:
2040 dev_dbg(&link->dev, "ray_cs interrupt dump memory done\n");
2042 case CCS_START_TIMER:
2044 "ray_cs interrupt DING - raylink timer expired\n");
2048 "ray_cs interrupt Unexpected CCS 0x%x returned 0x%x\n",
2051 writeb(CCS_BUFFER_FREE, &pccs->buffer_status);
2052 } else { /* It's an RCS */
2054 prcs = rcs_base(local) + rcsindex;
2056 switch (readb(&prcs->interrupt_id)) {
2057 case PROCESS_RX_PACKET:
2058 ray_rx(dev, local, prcs);
2060 case REJOIN_NET_COMPLETE:
2061 dev_dbg(&link->dev, "ray_cs interrupt rejoin net complete\n");
2062 local->card_status = CARD_ACQ_COMPLETE;
2063 /* do we need to clear tx buffers CCS's? */
2064 if (local->sparm.b4.a_network_type == ADHOC) {
2066 netif_start_queue(dev);
2068 memcpy_fromio(&local->bss_id,
2069 prcs->var.rejoin_net_complete.
2072 "ray_cs new BSSID = %02x%02x%02x%02x%02x%02x\n",
2073 local->bss_id[0], local->bss_id[1],
2074 local->bss_id[2], local->bss_id[3],
2075 local->bss_id[4], local->bss_id[5]);
2077 authenticate(local);
2080 case ROAMING_INITIATED:
2081 dev_dbg(&link->dev, "ray_cs interrupt roaming initiated\n");
2082 netif_stop_queue(dev);
2083 local->card_status = CARD_DOING_ACQ;
2085 case JAPAN_CALL_SIGN_RXD:
2086 dev_dbg(&link->dev, "ray_cs interrupt japan call sign rx\n");
2090 "ray_cs Unexpected interrupt for RCS 0x%x cmd = 0x%x\n",
2092 (unsigned int)readb(&prcs->interrupt_id));
2095 writeb(CCS_BUFFER_FREE, &prcs->buffer_status);
2097 clear_interrupt(local);
2099 } /* ray_interrupt */
2101 /*===========================================================================*/
2102 static void ray_rx(struct net_device *dev, ray_dev_t *local,
2103 struct rcs __iomem *prcs)
2106 unsigned int pkt_addr;
2108 pr_debug("ray_rx process rx packet\n");
2110 /* Calculate address of packet within Rx buffer */
2111 pkt_addr = ((readb(&prcs->var.rx_packet.rx_data_ptr[0]) << 8)
2112 + readb(&prcs->var.rx_packet.rx_data_ptr[1])) & RX_BUFF_END;
2113 /* Length of first packet fragment */
2114 rx_len = (readb(&prcs->var.rx_packet.rx_data_length[0]) << 8)
2115 + readb(&prcs->var.rx_packet.rx_data_length[1]);
2117 local->last_rsl = readb(&prcs->var.rx_packet.rx_sig_lev);
2118 pmsg = local->rmem + pkt_addr;
2119 switch (readb(pmsg)) {
2121 pr_debug("ray_rx data type\n");
2122 rx_data(dev, prcs, pkt_addr, rx_len);
2124 case AUTHENTIC_TYPE:
2125 pr_debug("ray_rx authentic type\n");
2127 rx_data(dev, prcs, pkt_addr, rx_len);
2129 rx_authenticate(local, prcs, pkt_addr, rx_len);
2131 case DEAUTHENTIC_TYPE:
2132 pr_debug("ray_rx deauth type\n");
2134 rx_data(dev, prcs, pkt_addr, rx_len);
2136 rx_deauthenticate(local, prcs, pkt_addr, rx_len);
2139 pr_debug("ray_cs rx NULL msg\n");
2142 pr_debug("ray_rx beacon type\n");
2144 rx_data(dev, prcs, pkt_addr, rx_len);
2146 copy_from_rx_buff(local, (UCHAR *) &local->last_bcn, pkt_addr,
2147 rx_len < sizeof(struct beacon_rx) ?
2148 rx_len : sizeof(struct beacon_rx));
2150 local->beacon_rxed = 1;
2151 /* Get the statistics so the card counters never overflow */
2155 pr_debug("ray_cs unknown pkt type %2x\n",
2156 (unsigned int)readb(pmsg));
2162 /*===========================================================================*/
2163 static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
2164 unsigned int pkt_addr, int rx_len)
2166 struct sk_buff *skb = NULL;
2167 struct rcs __iomem *prcslink = prcs;
2168 ray_dev_t *local = netdev_priv(dev);
2173 int siglev = local->last_rsl;
2174 u_char linksrcaddr[ETH_ALEN]; /* Other end of the wireless link */
2179 /* TBD length needs fixing for translated header */
2180 if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
2182 (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
2185 "ray_cs invalid packet length %d received\n",
2189 } else { /* encapsulated ethernet */
2191 if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
2193 (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
2196 "ray_cs invalid packet length %d received\n",
2202 pr_debug("ray_cs rx_data packet\n");
2203 /* If fragmented packet, verify sizes of fragments add up */
2204 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
2205 pr_debug("ray_cs rx'ed fragment\n");
2206 tmp = (readb(&prcs->var.rx_packet.totalpacketlength[0]) << 8)
2207 + readb(&prcs->var.rx_packet.totalpacketlength[1]);
2212 (readb(&prcslink->var.rx_packet.rx_data_length[0])
2214 + readb(&prcslink->var.rx_packet.rx_data_length[1]);
2215 if (readb(&prcslink->var.rx_packet.next_frag_rcs_index)
2218 prcslink = rcs_base(local)
2219 + readb(&prcslink->link_field);
2224 "ray_cs rx_data fragment lengths don't add up\n");
2225 local->stats.rx_dropped++;
2226 release_frag_chain(local, prcs);
2229 } else { /* Single unfragmented packet */
2233 skb = dev_alloc_skb(total_len + 5);
2235 pr_debug("ray_cs rx_data could not allocate skb\n");
2236 local->stats.rx_dropped++;
2237 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF)
2238 release_frag_chain(local, prcs);
2241 skb_reserve(skb, 2); /* Align IP on 16 byte (TBD check this) */
2243 pr_debug("ray_cs rx_data total_len = %x, rx_len = %x\n", total_len,
2246 /************************/
2247 /* Reserve enough room for the whole damn packet. */
2248 rx_ptr = skb_put(skb, total_len);
2249 /* Copy the whole packet to sk_buff */
2251 copy_from_rx_buff(local, rx_ptr, pkt_addr & RX_BUFF_END, rx_len);
2252 /* Get source address */
2254 skb_copy_from_linear_data_offset(skb,
2255 offsetof(struct mac_header, addr_2),
2256 linksrcaddr, ETH_ALEN);
2258 /* Now, deal with encapsulation/translation/sniffer */
2261 /* Encapsulated ethernet, so just lop off 802.11 MAC header */
2262 /* TBD reserve skb_reserve( skb, RX_MAC_HEADER_LENGTH); */
2263 skb_pull(skb, RX_MAC_HEADER_LENGTH);
2265 /* Do translation */
2266 untranslate(local, skb, total_len);
2268 } else { /* sniffer mode, so just pass whole packet */
2271 /************************/
2272 /* Now pick up the rest of the fragments if any */
2274 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
2276 pr_debug("ray_cs rx_data in fragment loop\n");
2278 prcslink = rcs_base(local)
2280 readb(&prcslink->var.rx_packet.next_frag_rcs_index);
2282 ((readb(&prcslink->var.rx_packet.rx_data_length[0])
2285 readb(&prcslink->var.rx_packet.rx_data_length[1]))
2288 ((readb(&prcslink->var.rx_packet.rx_data_ptr[0]) <<
2290 + readb(&prcslink->var.rx_packet.rx_data_ptr[1]))
2294 copy_from_rx_buff(local, rx_ptr, pkt_addr, rx_len);
2297 readb(&prcslink->var.rx_packet.next_frag_rcs_index) !=
2299 release_frag_chain(local, prcs);
2302 skb->protocol = eth_type_trans(skb, dev);
2304 local->stats.rx_packets++;
2305 local->stats.rx_bytes += total_len;
2307 /* Gather signal strength per address */
2309 /* For the Access Point or the node having started the ad-hoc net
2310 * note : ad-hoc work only in some specific configurations, but we
2311 * kludge in ray_get_wireless_stats... */
2312 if (!memcmp(linksrcaddr, local->bss_id, ETH_ALEN)) {
2313 /* Update statistics */
2314 /*local->wstats.qual.qual = none ? */
2315 local->wstats.qual.level = siglev;
2316 /*local->wstats.qual.noise = none ? */
2317 local->wstats.qual.updated = 0x2;
2319 /* Now, update the spy stuff */
2321 struct iw_quality wstats;
2322 wstats.level = siglev;
2323 /* wstats.noise = none ? */
2324 /* wstats.qual = none ? */
2325 wstats.updated = 0x2;
2326 /* Update spy records */
2327 wireless_spy_update(dev, linksrcaddr, &wstats);
2329 #endif /* WIRELESS_SPY */
2332 /*===========================================================================*/
2333 static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
2335 snaphdr_t *psnap = (snaphdr_t *) (skb->data + RX_MAC_HEADER_LENGTH);
2336 struct ieee80211_hdr *pmac = (struct ieee80211_hdr *)skb->data;
2337 __be16 type = *(__be16 *) psnap->ethertype;
2339 struct ethhdr *peth;
2340 UCHAR srcaddr[ADDRLEN];
2341 UCHAR destaddr[ADDRLEN];
2342 static UCHAR org_bridge[3] = { 0, 0, 0xf8 };
2343 static UCHAR org_1042[3] = { 0, 0, 0 };
2345 memcpy(destaddr, ieee80211_get_DA(pmac), ADDRLEN);
2346 memcpy(srcaddr, ieee80211_get_SA(pmac), ADDRLEN);
2350 print_hex_dump(KERN_DEBUG, "skb->data before untranslate: ",
2351 DUMP_PREFIX_NONE, 16, 1,
2352 skb->data, 64, true);
2354 "type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n",
2355 ntohs(type), psnap->dsap, psnap->ssap, psnap->ctrl,
2356 psnap->org[0], psnap->org[1], psnap->org[2]);
2357 printk(KERN_DEBUG "untranslate skb->data = %p\n", skb->data);
2361 if (psnap->dsap != 0xaa || psnap->ssap != 0xaa || psnap->ctrl != 3) {
2362 /* not a snap type so leave it alone */
2363 pr_debug("ray_cs untranslate NOT SNAP %02x %02x %02x\n",
2364 psnap->dsap, psnap->ssap, psnap->ctrl);
2366 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
2367 peth = (struct ethhdr *)(skb->data + delta);
2368 peth->h_proto = htons(len - RX_MAC_HEADER_LENGTH);
2369 } else { /* Its a SNAP */
2370 if (memcmp(psnap->org, org_bridge, 3) == 0) {
2371 /* EtherII and nuke the LLC */
2372 pr_debug("ray_cs untranslate Bridge encap\n");
2373 delta = RX_MAC_HEADER_LENGTH
2374 + sizeof(struct snaphdr_t) - ETH_HLEN;
2375 peth = (struct ethhdr *)(skb->data + delta);
2376 peth->h_proto = type;
2377 } else if (memcmp(psnap->org, org_1042, 3) == 0) {
2378 switch (ntohs(type)) {
2381 pr_debug("ray_cs untranslate RFC IPX/AARP\n");
2382 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
2383 peth = (struct ethhdr *)(skb->data + delta);
2385 htons(len - RX_MAC_HEADER_LENGTH);
2388 pr_debug("ray_cs untranslate RFC default\n");
2389 delta = RX_MAC_HEADER_LENGTH +
2390 sizeof(struct snaphdr_t) - ETH_HLEN;
2391 peth = (struct ethhdr *)(skb->data + delta);
2392 peth->h_proto = type;
2396 printk("ray_cs untranslate very confused by packet\n");
2397 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
2398 peth = (struct ethhdr *)(skb->data + delta);
2399 peth->h_proto = type;
2402 /* TBD reserve skb_reserve(skb, delta); */
2403 skb_pull(skb, delta);
2404 pr_debug("untranslate after skb_pull(%d), skb->data = %p\n", delta,
2406 memcpy(peth->h_dest, destaddr, ADDRLEN);
2407 memcpy(peth->h_source, srcaddr, ADDRLEN);
2411 printk(KERN_DEBUG "skb->data after untranslate:");
2412 for (i = 0; i < 64; i++)
2413 printk("%02x ", skb->data[i]);
2417 } /* end untranslate */
2419 /*===========================================================================*/
2420 /* Copy data from circular receive buffer to PC memory.
2421 * dest = destination address in PC memory
2422 * pkt_addr = source address in receive buffer
2423 * len = length of packet to copy
2425 static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr,
2428 int wrap_bytes = (pkt_addr + length) - (RX_BUFF_END + 1);
2429 if (wrap_bytes <= 0) {
2430 memcpy_fromio(dest, local->rmem + pkt_addr, length);
2431 } else { /* Packet wrapped in circular buffer */
2433 memcpy_fromio(dest, local->rmem + pkt_addr,
2434 length - wrap_bytes);
2435 memcpy_fromio(dest + length - wrap_bytes, local->rmem,
2441 /*===========================================================================*/
2442 static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs)
2444 struct rcs __iomem *prcslink = prcs;
2446 unsigned rcsindex = readb(&prcs->var.rx_packet.next_frag_rcs_index);
2449 writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
2450 if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
2451 pr_debug("ray_cs interrupt bad rcsindex = 0x%x\n",
2455 prcslink = rcs_base(local) + rcsindex;
2456 rcsindex = readb(&prcslink->var.rx_packet.next_frag_rcs_index);
2458 writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
2461 /*===========================================================================*/
2462 static void authenticate(ray_dev_t *local)
2464 struct pcmcia_device *link = local->finder;
2465 dev_dbg(&link->dev, "ray_cs Starting authentication.\n");
2466 if (!(pcmcia_dev_present(link))) {
2467 dev_dbg(&link->dev, "ray_cs authenticate - device not present\n");
2471 del_timer(&local->timer);
2472 if (build_auth_frame(local, local->bss_id, OPEN_AUTH_REQUEST)) {
2473 local->timer.function = &join_net;
2475 local->timer.function = &authenticate_timeout;
2477 local->timer.expires = jiffies + HZ * 2;
2478 local->timer.data = (long)local;
2479 add_timer(&local->timer);
2480 local->authentication_state = AWAITING_RESPONSE;
2481 } /* end authenticate */
2483 /*===========================================================================*/
2484 static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
2485 unsigned int pkt_addr, int rx_len)
2488 struct rx_msg *msg = (struct rx_msg *)buff;
2490 del_timer(&local->timer);
2492 copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
2493 /* if we are trying to get authenticated */
2494 if (local->sparm.b4.a_network_type == ADHOC) {
2495 pr_debug("ray_cs rx_auth var= %02x %02x %02x %02x %02x %02x\n",
2496 msg->var[0], msg->var[1], msg->var[2], msg->var[3],
2497 msg->var[4], msg->var[5]);
2498 if (msg->var[2] == 1) {
2499 pr_debug("ray_cs Sending authentication response.\n");
2500 if (!build_auth_frame
2501 (local, msg->mac.addr_2, OPEN_AUTH_RESPONSE)) {
2502 local->authentication_state = NEED_TO_AUTH;
2503 memcpy(local->auth_id, msg->mac.addr_2,
2507 } else { /* Infrastructure network */
2509 if (local->authentication_state == AWAITING_RESPONSE) {
2510 /* Verify authentication sequence #2 and success */
2511 if (msg->var[2] == 2) {
2512 if ((msg->var[3] | msg->var[4]) == 0) {
2513 pr_debug("Authentication successful\n");
2514 local->card_status = CARD_AUTH_COMPLETE;
2516 local->authentication_state =
2519 pr_debug("Authentication refused\n");
2520 local->card_status = CARD_AUTH_REFUSED;
2521 join_net((u_long) local);
2522 local->authentication_state =
2529 } /* end rx_authenticate */
2531 /*===========================================================================*/
2532 static void associate(ray_dev_t *local)
2534 struct ccs __iomem *pccs;
2535 struct pcmcia_device *link = local->finder;
2536 struct net_device *dev = link->priv;
2538 if (!(pcmcia_dev_present(link))) {
2539 dev_dbg(&link->dev, "ray_cs associate - device not present\n");
2542 /* If no tx buffers available, return */
2543 if ((ccsindex = get_free_ccs(local)) < 0) {
2544 /* TBD should never be here but... what if we are? */
2545 dev_dbg(&link->dev, "ray_cs associate - No free ccs\n");
2548 dev_dbg(&link->dev, "ray_cs Starting association with access point\n");
2549 pccs = ccs_base(local) + ccsindex;
2550 /* fill in the CCS */
2551 writeb(CCS_START_ASSOCIATION, &pccs->cmd);
2552 /* Interrupt the firmware to process the command */
2553 if (interrupt_ecf(local, ccsindex)) {
2554 dev_dbg(&link->dev, "ray_cs associate failed - ECF not ready for intr\n");
2555 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
2557 del_timer(&local->timer);
2558 local->timer.expires = jiffies + HZ * 2;
2559 local->timer.data = (long)local;
2560 local->timer.function = &join_net;
2561 add_timer(&local->timer);
2562 local->card_status = CARD_ASSOC_FAILED;
2566 netif_start_queue(dev);
2568 } /* end associate */
2570 /*===========================================================================*/
2571 static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
2572 unsigned int pkt_addr, int rx_len)
2575 struct rx_msg *msg = (struct rx_msg *)buff;
2577 pr_debug("Deauthentication frame received\n");
2578 local->authentication_state = UNAUTHENTICATED;
2579 /* Need to reauthenticate or rejoin depending on reason code */
2580 /* copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
2584 /*===========================================================================*/
2585 static void clear_interrupt(ray_dev_t *local)
2587 writeb(0, local->amem + CIS_OFFSET + HCS_INTR_OFFSET);
2590 /*===========================================================================*/
2591 #ifdef CONFIG_PROC_FS
2592 #define MAXDATA (PAGE_SIZE - 80)
2594 static char *card_status[] = {
2595 "Card inserted - uninitialized", /* 0 */
2596 "Card not downloaded", /* 1 */
2597 "Waiting for download parameters", /* 2 */
2598 "Card doing acquisition", /* 3 */
2599 "Acquisition complete", /* 4 */
2600 "Authentication complete", /* 5 */
2601 "Association complete", /* 6 */
2602 "???", "???", "???", "???", /* 7 8 9 10 undefined */
2603 "Card init error", /* 11 */
2604 "Download parameters error", /* 12 */
2606 "Acquisition failed", /* 14 */
2607 "Authentication refused", /* 15 */
2608 "Association failed" /* 16 */
2611 static char *nettype[] = { "Adhoc", "Infra " };
2612 static char *framing[] = { "Encapsulation", "Translation" }
2615 /*===========================================================================*/
2616 static int ray_cs_proc_show(struct seq_file *m, void *v)
2618 /* Print current values which are not available via other means
2622 struct pcmcia_device *link;
2623 struct net_device *dev;
2626 struct freq_hop_element *pfh;
2632 dev = (struct net_device *)link->priv;
2635 local = netdev_priv(dev);
2639 seq_puts(m, "Raylink Wireless LAN driver status\n");
2640 seq_printf(m, "%s\n", rcsid);
2641 /* build 4 does not report version, and field is 0x55 after memtest */
2642 seq_puts(m, "Firmware version = ");
2643 if (local->fw_ver == 0x55)
2644 seq_puts(m, "4 - Use dump_cis for more details\n");
2646 seq_printf(m, "%2d.%02d.%02d\n",
2647 local->fw_ver, local->fw_bld, local->fw_var);
2649 for (i = 0; i < 32; i++)
2650 c[i] = local->sparm.b5.a_current_ess_id[i];
2652 seq_printf(m, "%s network ESSID = \"%s\"\n",
2653 nettype[local->sparm.b5.a_network_type], c);
2656 seq_printf(m, "BSSID = %pM\n", p);
2658 seq_printf(m, "Country code = %d\n",
2659 local->sparm.b5.a_curr_country_code);
2661 i = local->card_status;
2666 seq_printf(m, "Card status = %s\n", card_status[i]);
2668 seq_printf(m, "Framing mode = %s\n", framing[translate]);
2670 seq_printf(m, "Last pkt signal lvl = %d\n", local->last_rsl);
2672 if (local->beacon_rxed) {
2673 /* Pull some fields out of last beacon received */
2674 seq_printf(m, "Beacon Interval = %d Kus\n",
2675 local->last_bcn.beacon_intvl[0]
2676 + 256 * local->last_bcn.beacon_intvl[1]);
2678 p = local->last_bcn.elements;
2679 if (p[0] == C_ESSID_ELEMENT_ID)
2683 "Parse beacon failed at essid element id = %d\n",
2688 if (p[0] == C_SUPPORTED_RATES_ELEMENT_ID) {
2689 seq_puts(m, "Supported rate codes = ");
2690 for (i = 2; i < p[1] + 2; i++)
2691 seq_printf(m, "0x%02x ", p[i]);
2695 seq_puts(m, "Parse beacon failed at rates element\n");
2699 if (p[0] == C_FH_PARAM_SET_ELEMENT_ID) {
2700 pfh = (struct freq_hop_element *)p;
2701 seq_printf(m, "Hop dwell = %d Kus\n",
2702 pfh->dwell_time[0] +
2703 256 * pfh->dwell_time[1]);
2704 seq_printf(m, "Hop set = %d\n",
2706 seq_printf(m, "Hop pattern = %d\n",
2708 seq_printf(m, "Hop index = %d\n",
2713 "Parse beacon failed at FH param element\n");
2717 seq_puts(m, "No beacons received\n");
2722 static int ray_cs_proc_open(struct inode *inode, struct file *file)
2724 return single_open(file, ray_cs_proc_show, NULL);
2727 static const struct file_operations ray_cs_proc_fops = {
2728 .owner = THIS_MODULE,
2729 .open = ray_cs_proc_open,
2731 .llseek = seq_lseek,
2732 .release = single_release,
2735 /*===========================================================================*/
2736 static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
2739 struct ccs __iomem *pccs;
2740 struct tx_msg __iomem *ptx;
2743 /* If no tx buffers available, return */
2744 if ((ccsindex = get_free_tx_ccs(local)) < 0) {
2745 pr_debug("ray_cs send authenticate - No free tx ccs\n");
2749 pccs = ccs_base(local) + ccsindex;
2751 /* Address in card space */
2752 addr = TX_BUF_BASE + (ccsindex << 11);
2753 /* fill in the CCS */
2754 writeb(CCS_TX_REQUEST, &pccs->cmd);
2755 writeb(addr >> 8, pccs->var.tx_request.tx_data_ptr);
2756 writeb(0x20, pccs->var.tx_request.tx_data_ptr + 1);
2757 writeb(TX_AUTHENTICATE_LENGTH_MSB, pccs->var.tx_request.tx_data_length);
2758 writeb(TX_AUTHENTICATE_LENGTH_LSB,
2759 pccs->var.tx_request.tx_data_length + 1);
2760 writeb(0, &pccs->var.tx_request.pow_sav_mode);
2762 ptx = local->sram + addr;
2763 /* fill in the mac header */
2764 writeb(PROTOCOL_VER | AUTHENTIC_TYPE, &ptx->mac.frame_ctl_1);
2765 writeb(0, &ptx->mac.frame_ctl_2);
2767 memcpy_toio(ptx->mac.addr_1, dest, ADDRLEN);
2768 memcpy_toio(ptx->mac.addr_2, local->sparm.b4.a_mac_addr, ADDRLEN);
2769 memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN);
2771 /* Fill in msg body with protocol 00 00, sequence 01 00 ,status 00 00 */
2772 memset_io(ptx->var, 0, 6);
2773 writeb(auth_type & 0xff, ptx->var + 2);
2775 /* Interrupt the firmware to process the command */
2776 if (interrupt_ecf(local, ccsindex)) {
2778 "ray_cs send authentication request failed - ECF not ready for intr\n");
2779 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
2783 } /* End build_auth_frame */
2785 /*===========================================================================*/
2786 #ifdef CONFIG_PROC_FS
2787 static ssize_t ray_cs_essid_proc_write(struct file *file,
2788 const char __user *buffer, size_t count, loff_t *pos)
2790 static char proc_essid[33];
2791 unsigned int len = count;
2795 memset(proc_essid, 0, 33);
2796 if (copy_from_user(proc_essid, buffer, len))
2802 static const struct file_operations ray_cs_essid_proc_fops = {
2803 .owner = THIS_MODULE,
2804 .write = ray_cs_essid_proc_write,
2807 static ssize_t int_proc_write(struct file *file, const char __user *buffer,
2808 size_t count, loff_t *pos)
2810 static char proc_number[10];
2819 if (copy_from_user(proc_number, buffer, count))
2825 unsigned int c = *p - '0';
2831 *(int *)PDE(file->f_path.dentry->d_inode)->data = nr;
2835 static const struct file_operations int_proc_fops = {
2836 .owner = THIS_MODULE,
2837 .write = int_proc_write,
2841 static struct pcmcia_device_id ray_ids[] = {
2842 PCMCIA_DEVICE_MANF_CARD(0x01a6, 0x0000),
2846 MODULE_DEVICE_TABLE(pcmcia, ray_ids);
2848 static struct pcmcia_driver ray_driver = {
2849 .owner = THIS_MODULE,
2854 .remove = ray_detach,
2855 .id_table = ray_ids,
2856 .suspend = ray_suspend,
2857 .resume = ray_resume,
2860 static int __init init_ray_cs(void)
2864 pr_debug("%s\n", rcsid);
2865 rc = pcmcia_register_driver(&ray_driver);
2866 pr_debug("raylink init_module register_pcmcia_driver returns 0x%x\n",
2869 #ifdef CONFIG_PROC_FS
2870 proc_mkdir("driver/ray_cs", NULL);
2872 proc_create("driver/ray_cs/ray_cs", 0, NULL, &ray_cs_proc_fops);
2873 proc_create("driver/ray_cs/essid", S_IWUSR, NULL, &ray_cs_essid_proc_fops);
2874 proc_create_data("driver/ray_cs/net_type", S_IWUSR, NULL, &int_proc_fops, &net_type);
2875 proc_create_data("driver/ray_cs/translate", S_IWUSR, NULL, &int_proc_fops, &translate);
2882 /*===========================================================================*/
2884 static void __exit exit_ray_cs(void)
2886 pr_debug("ray_cs: cleanup_module\n");
2888 #ifdef CONFIG_PROC_FS
2889 remove_proc_entry("driver/ray_cs/ray_cs", NULL);
2890 remove_proc_entry("driver/ray_cs/essid", NULL);
2891 remove_proc_entry("driver/ray_cs/net_type", NULL);
2892 remove_proc_entry("driver/ray_cs/translate", NULL);
2893 remove_proc_entry("driver/ray_cs", NULL);
2896 pcmcia_unregister_driver(&ray_driver);
2899 module_init(init_ray_cs);
2900 module_exit(exit_ray_cs);
2902 /*===========================================================================*/