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/cistpl.h>
50 #include <pcmcia/cisreg.h>
51 #include <pcmcia/ds.h>
53 #include <linux/wireless.h>
54 #include <net/iw_handler.h>
57 #include <asm/system.h>
58 #include <asm/byteorder.h>
59 #include <asm/uaccess.h>
61 /* Warning : these stuff will slow down the driver... */
62 #define WIRELESS_SPY /* Enable spying addresses */
63 /* Definitions we need for spy */
64 typedef struct iw_statistics iw_stats;
65 typedef u_char mac_addr[ETH_ALEN]; /* Hardware address */
71 /** Prototypes based on PCMCIA skeleton driver *******************************/
72 static int ray_config(struct pcmcia_device *link);
73 static void ray_release(struct pcmcia_device *link);
74 static void ray_detach(struct pcmcia_device *p_dev);
76 /***** Prototypes indicated by device structure ******************************/
77 static int ray_dev_close(struct net_device *dev);
78 static int ray_dev_config(struct net_device *dev, struct ifmap *map);
79 static struct net_device_stats *ray_get_stats(struct net_device *dev);
80 static int ray_dev_init(struct net_device *dev);
82 static const struct ethtool_ops netdev_ethtool_ops;
84 static int ray_open(struct net_device *dev);
85 static netdev_tx_t ray_dev_start_xmit(struct sk_buff *skb,
86 struct net_device *dev);
87 static void set_multicast_list(struct net_device *dev);
88 static void ray_update_multi_list(struct net_device *dev, int all);
89 static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
90 unsigned char *data, int len);
91 static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
92 UCHAR msg_type, unsigned char *data);
93 static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len);
94 static iw_stats *ray_get_wireless_stats(struct net_device *dev);
95 static const struct iw_handler_def ray_handler_def;
97 /***** Prototypes for raylink functions **************************************/
98 static void authenticate(ray_dev_t *local);
99 static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type);
100 static void authenticate_timeout(u_long);
101 static int get_free_ccs(ray_dev_t *local);
102 static int get_free_tx_ccs(ray_dev_t *local);
103 static void init_startup_params(ray_dev_t *local);
104 static int parse_addr(char *in_str, UCHAR *out);
105 static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev, UCHAR type);
106 static int ray_init(struct net_device *dev);
107 static int interrupt_ecf(ray_dev_t *local, int ccs);
108 static void ray_reset(struct net_device *dev);
109 static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value, int len);
110 static void verify_dl_startup(u_long);
112 /* Prototypes for interrpt time functions **********************************/
113 static irqreturn_t ray_interrupt(int reg, void *dev_id);
114 static void clear_interrupt(ray_dev_t *local);
115 static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
116 unsigned int pkt_addr, int rx_len);
117 static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr, int len);
118 static void ray_rx(struct net_device *dev, ray_dev_t *local, struct rcs __iomem *prcs);
119 static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs);
120 static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
121 unsigned int pkt_addr, int rx_len);
122 static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
123 unsigned int pkt_addr, int rx_len);
124 static void associate(ray_dev_t *local);
126 /* Card command functions */
127 static int dl_startup_params(struct net_device *dev);
128 static void join_net(u_long local);
129 static void start_net(u_long local);
130 /* void start_net(ray_dev_t *local); */
132 /*===========================================================================*/
133 /* Parameters that can be set with 'insmod' */
135 /* ADHOC=0, Infrastructure=1 */
136 static int net_type = ADHOC;
138 /* Hop dwell time in Kus (1024 us units defined by 802.11) */
139 static int hop_dwell = 128;
141 /* Beacon period in Kus */
142 static int beacon_period = 256;
144 /* power save mode (0 = off, 1 = save power) */
147 /* String for network's Extended Service Set ID. 32 Characters max */
150 /* Default to encapsulation unless translation requested */
151 static int translate = 1;
153 static int country = USA;
159 /* 48 bit physical card address if overriding card's real physical
160 * address is required. Since IEEE 802.11 addresses are 48 bits
161 * like ethernet, an int can't be used, so a string is used. To
162 * allow use of addresses starting with a decimal digit, the first
163 * character must be a letter and will be ignored. This letter is
164 * followed by up to 12 hex digits which are the address. If less
165 * than 12 digits are used, the address will be left filled with 0's.
166 * Note that bit 0 of the first byte is the broadcast bit, and evil
167 * things will happen if it is not 0 in a card address.
169 static char *phy_addr = NULL;
171 static unsigned int ray_mem_speed = 500;
173 /* WARNING: THIS DRIVER IS NOT CAPABLE OF HANDLING MULTIPLE DEVICES! */
174 static struct pcmcia_device *this_device = NULL;
176 MODULE_AUTHOR("Corey Thomas <corey@world.std.com>");
177 MODULE_DESCRIPTION("Raylink/WebGear wireless LAN driver");
178 MODULE_LICENSE("GPL");
180 module_param(net_type, int, 0);
181 module_param(hop_dwell, int, 0);
182 module_param(beacon_period, int, 0);
183 module_param(psm, int, 0);
184 module_param(essid, charp, 0);
185 module_param(translate, int, 0);
186 module_param(country, int, 0);
187 module_param(sniffer, int, 0);
188 module_param(bc, int, 0);
189 module_param(phy_addr, charp, 0);
190 module_param(ray_mem_speed, int, 0);
192 static UCHAR b5_default_startup_parms[] = {
193 0, 0, /* Adhoc station */
194 'L', 'I', 'N', 'U', 'X', 0, 0, 0, /* 32 char ESSID */
195 0, 0, 0, 0, 0, 0, 0, 0,
196 0, 0, 0, 0, 0, 0, 0, 0,
197 0, 0, 0, 0, 0, 0, 0, 0,
198 1, 0, /* Active scan, CA Mode */
199 0, 0, 0, 0, 0, 0, /* No default MAC addr */
200 0x7f, 0xff, /* Frag threshold */
201 0x00, 0x80, /* Hop time 128 Kus */
202 0x01, 0x00, /* Beacon period 256 Kus */
203 0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout */
204 0x1d, 0x82, 0x4e, /* SIFS, DIFS, PIFS */
205 0x7f, 0xff, /* RTS threshold */
206 0x04, 0xe2, 0x38, 0xA4, /* scan_dwell, max_scan_dwell */
207 0x05, /* assoc resp timeout thresh */
208 0x08, 0x02, 0x08, /* adhoc, infra, super cycle max */
209 0, /* Promiscuous mode */
210 0x0c, 0x0bd, /* Unique word */
211 0x32, /* Slot time */
212 0xff, 0xff, /* roam-low snr, low snr count */
213 0x05, 0xff, /* Infra, adhoc missed bcn thresh */
214 0x01, 0x0b, 0x4f, /* USA, hop pattern, hop pat length */
215 /* b4 - b5 differences start here */
216 0x00, 0x3f, /* CW max */
217 0x00, 0x0f, /* CW min */
218 0x04, 0x08, /* Noise gain, limit offset */
219 0x28, 0x28, /* det rssi, med busy offsets */
220 7, /* det sync thresh */
221 0, 2, 2, /* test mode, min, max */
222 0, /* allow broadcast SSID probe resp */
223 0, 0, /* privacy must start, can join */
224 2, 0, 0, 0, 0, 0, 0, 0 /* basic rate set */
227 static UCHAR b4_default_startup_parms[] = {
228 0, 0, /* Adhoc station */
229 'L', 'I', 'N', 'U', 'X', 0, 0, 0, /* 32 char ESSID */
230 0, 0, 0, 0, 0, 0, 0, 0,
231 0, 0, 0, 0, 0, 0, 0, 0,
232 0, 0, 0, 0, 0, 0, 0, 0,
233 1, 0, /* Active scan, CA Mode */
234 0, 0, 0, 0, 0, 0, /* No default MAC addr */
235 0x7f, 0xff, /* Frag threshold */
236 0x02, 0x00, /* Hop time */
237 0x00, 0x01, /* Beacon period */
238 0x01, 0x07, 0xa3, /* DTIM, retries, ack timeout */
239 0x1d, 0x82, 0xce, /* SIFS, DIFS, PIFS */
240 0x7f, 0xff, /* RTS threshold */
241 0xfb, 0x1e, 0xc7, 0x5c, /* scan_dwell, max_scan_dwell */
242 0x05, /* assoc resp timeout thresh */
243 0x04, 0x02, 0x4, /* adhoc, infra, super cycle max */
244 0, /* Promiscuous mode */
245 0x0c, 0x0bd, /* Unique word */
246 0x4e, /* Slot time (TBD seems wrong) */
247 0xff, 0xff, /* roam-low snr, low snr count */
248 0x05, 0xff, /* Infra, adhoc missed bcn thresh */
249 0x01, 0x0b, 0x4e, /* USA, hop pattern, hop pat length */
250 /* b4 - b5 differences start here */
251 0x3f, 0x0f, /* CW max, min */
252 0x04, 0x08, /* Noise gain, limit offset */
253 0x28, 0x28, /* det rssi, med busy offsets */
254 7, /* det sync thresh */
255 0, 2, 2 /* test mode, min, max */
258 /*===========================================================================*/
259 static unsigned char eth2_llc[] = { 0xaa, 0xaa, 3, 0, 0, 0 };
261 static char hop_pattern_length[] = { 1,
262 USA_HOP_MOD, EUROPE_HOP_MOD,
263 JAPAN_HOP_MOD, KOREA_HOP_MOD,
264 SPAIN_HOP_MOD, FRANCE_HOP_MOD,
265 ISRAEL_HOP_MOD, AUSTRALIA_HOP_MOD,
269 static char rcsid[] =
270 "Raylink/WebGear wireless LAN - Corey <Thomas corey@world.std.com>";
272 static const struct net_device_ops ray_netdev_ops = {
273 .ndo_init = ray_dev_init,
274 .ndo_open = ray_open,
275 .ndo_stop = ray_dev_close,
276 .ndo_start_xmit = ray_dev_start_xmit,
277 .ndo_set_config = ray_dev_config,
278 .ndo_get_stats = ray_get_stats,
279 .ndo_set_multicast_list = set_multicast_list,
280 .ndo_change_mtu = eth_change_mtu,
281 .ndo_set_mac_address = eth_mac_addr,
282 .ndo_validate_addr = eth_validate_addr,
285 static int ray_probe(struct pcmcia_device *p_dev)
288 struct net_device *dev;
290 dev_dbg(&p_dev->dev, "ray_attach()\n");
292 /* Allocate space for private device-specific data */
293 dev = alloc_etherdev(sizeof(ray_dev_t));
297 local = netdev_priv(dev);
298 local->finder = p_dev;
300 /* The io structure describes IO port mapping. None used here */
301 p_dev->resource[0]->end = 0;
302 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
304 /* General socket configuration */
305 p_dev->config_flags |= CONF_ENABLE_IRQ;
306 p_dev->config_index = 1;
310 local->finder = p_dev;
311 local->card_status = CARD_INSERTED;
312 local->authentication_state = UNAUTHENTICATED;
313 local->num_multi = 0;
314 dev_dbg(&p_dev->dev, "ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
315 p_dev, dev, local, &ray_interrupt);
317 /* Raylink entries in the device structure */
318 dev->netdev_ops = &ray_netdev_ops;
319 SET_ETHTOOL_OPS(dev, &netdev_ethtool_ops);
320 dev->wireless_handlers = &ray_handler_def;
322 local->wireless_data.spy_data = &local->spy_data;
323 dev->wireless_data = &local->wireless_data;
324 #endif /* WIRELESS_SPY */
327 dev_dbg(&p_dev->dev, "ray_cs ray_attach calling ether_setup.)\n");
328 netif_stop_queue(dev);
330 init_timer(&local->timer);
333 return ray_config(p_dev);
339 static void ray_detach(struct pcmcia_device *link)
341 struct net_device *dev;
344 dev_dbg(&link->dev, "ray_detach\n");
351 local = netdev_priv(dev);
352 del_timer(&local->timer);
355 unregister_netdev(dev);
358 dev_dbg(&link->dev, "ray_cs ray_detach ending\n");
361 #define MAX_TUPLE_SIZE 128
362 static int ray_config(struct pcmcia_device *link)
366 struct net_device *dev = (struct net_device *)link->priv;
367 ray_dev_t *local = netdev_priv(dev);
369 dev_dbg(&link->dev, "ray_config\n");
371 /* Determine card type and firmware version */
372 printk(KERN_INFO "ray_cs Detected: %s%s%s%s\n",
373 link->prod_id[0] ? link->prod_id[0] : " ",
374 link->prod_id[1] ? link->prod_id[1] : " ",
375 link->prod_id[2] ? link->prod_id[2] : " ",
376 link->prod_id[3] ? link->prod_id[3] : " ");
378 /* Now allocate an interrupt line. Note that this does not
379 actually assign a handler to the interrupt.
381 ret = pcmcia_request_irq(link, ray_interrupt);
384 dev->irq = link->irq;
386 ret = pcmcia_enable_device(link);
390 /*** Set up 32k window for shared memory (transmit and control) ************/
391 link->resource[2]->flags |= WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
392 link->resource[2]->start = 0;
393 link->resource[2]->end = 0x8000;
394 ret = pcmcia_request_window(link, link->resource[2], ray_mem_speed);
397 ret = pcmcia_map_mem_page(link, link->resource[2], 0);
400 local->sram = ioremap(link->resource[2]->start,
401 resource_size(link->resource[2]));
403 /*** Set up 16k window for shared memory (receive buffer) ***************/
404 link->resource[3]->flags |=
405 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM | WIN_ENABLE | WIN_USE_WAIT;
406 link->resource[3]->start = 0;
407 link->resource[3]->end = 0x4000;
408 ret = pcmcia_request_window(link, link->resource[3], ray_mem_speed);
411 ret = pcmcia_map_mem_page(link, link->resource[3], 0x8000);
414 local->rmem = ioremap(link->resource[3]->start,
415 resource_size(link->resource[3]));
417 /*** Set up window for attribute memory ***********************************/
418 link->resource[4]->flags |=
419 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM | WIN_ENABLE | WIN_USE_WAIT;
420 link->resource[4]->start = 0;
421 link->resource[4]->end = 0x1000;
422 ret = pcmcia_request_window(link, link->resource[4], ray_mem_speed);
425 ret = pcmcia_map_mem_page(link, link->resource[4], 0);
428 local->amem = ioremap(link->resource[4]->start,
429 resource_size(link->resource[4]));
431 dev_dbg(&link->dev, "ray_config sram=%p\n", local->sram);
432 dev_dbg(&link->dev, "ray_config rmem=%p\n", local->rmem);
433 dev_dbg(&link->dev, "ray_config amem=%p\n", local->amem);
434 if (ray_init(dev) < 0) {
439 SET_NETDEV_DEV(dev, &link->dev);
440 i = register_netdev(dev);
442 printk("ray_config register_netdev() failed\n");
447 printk(KERN_INFO "%s: RayLink, irq %d, hw_addr %pM\n",
448 dev->name, dev->irq, dev->dev_addr);
457 static inline struct ccs __iomem *ccs_base(ray_dev_t *dev)
459 return dev->sram + CCS_BASE;
462 static inline struct rcs __iomem *rcs_base(ray_dev_t *dev)
465 * This looks nonsensical, since there is a separate
466 * RCS_BASE. But the difference between a "struct rcs"
467 * and a "struct ccs" ends up being in the _index_ off
468 * the base, so the base pointer is the same for both
471 return dev->sram + CCS_BASE;
474 /*===========================================================================*/
475 static int ray_init(struct net_device *dev)
479 struct ccs __iomem *pccs;
480 ray_dev_t *local = netdev_priv(dev);
481 struct pcmcia_device *link = local->finder;
482 dev_dbg(&link->dev, "ray_init(0x%p)\n", dev);
483 if (!(pcmcia_dev_present(link))) {
484 dev_dbg(&link->dev, "ray_init - device not present\n");
488 local->net_type = net_type;
489 local->sta_type = TYPE_STA;
491 /* Copy the startup results to local memory */
492 memcpy_fromio(&local->startup_res, local->sram + ECF_TO_HOST_BASE,
493 sizeof(struct startup_res_6));
495 /* Check Power up test status and get mac address from card */
496 if (local->startup_res.startup_word != 0x80) {
497 printk(KERN_INFO "ray_init ERROR card status = %2x\n",
498 local->startup_res.startup_word);
499 local->card_status = CARD_INIT_ERROR;
503 local->fw_ver = local->startup_res.firmware_version[0];
504 local->fw_bld = local->startup_res.firmware_version[1];
505 local->fw_var = local->startup_res.firmware_version[2];
506 dev_dbg(&link->dev, "ray_init firmware version %d.%d\n", local->fw_ver,
509 local->tib_length = 0x20;
510 if ((local->fw_ver == 5) && (local->fw_bld >= 30))
511 local->tib_length = local->startup_res.tib_length;
512 dev_dbg(&link->dev, "ray_init tib_length = 0x%02x\n", local->tib_length);
513 /* Initialize CCS's to buffer free state */
514 pccs = ccs_base(local);
515 for (i = 0; i < NUMBER_OF_CCS; i++) {
516 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
518 init_startup_params(local);
520 /* copy mac address to startup parameters */
521 if (parse_addr(phy_addr, local->sparm.b4.a_mac_addr)) {
522 p = local->sparm.b4.a_mac_addr;
524 memcpy(&local->sparm.b4.a_mac_addr,
525 &local->startup_res.station_addr, ADDRLEN);
526 p = local->sparm.b4.a_mac_addr;
529 clear_interrupt(local); /* Clear any interrupt from the card */
530 local->card_status = CARD_AWAITING_PARAM;
531 dev_dbg(&link->dev, "ray_init ending\n");
535 /*===========================================================================*/
536 /* Download startup parameters to the card and command it to read them */
537 static int dl_startup_params(struct net_device *dev)
540 ray_dev_t *local = netdev_priv(dev);
541 struct ccs __iomem *pccs;
542 struct pcmcia_device *link = local->finder;
544 dev_dbg(&link->dev, "dl_startup_params entered\n");
545 if (!(pcmcia_dev_present(link))) {
546 dev_dbg(&link->dev, "ray_cs dl_startup_params - device not present\n");
550 /* Copy parameters to host to ECF area */
551 if (local->fw_ver == 0x55)
552 memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b4,
553 sizeof(struct b4_startup_params));
555 memcpy_toio(local->sram + HOST_TO_ECF_BASE, &local->sparm.b5,
556 sizeof(struct b5_startup_params));
558 /* Fill in the CCS fields for the ECF */
559 if ((ccsindex = get_free_ccs(local)) < 0)
561 local->dl_param_ccs = ccsindex;
562 pccs = ccs_base(local) + ccsindex;
563 writeb(CCS_DOWNLOAD_STARTUP_PARAMS, &pccs->cmd);
564 dev_dbg(&link->dev, "dl_startup_params start ccsindex = %d\n",
565 local->dl_param_ccs);
566 /* Interrupt the firmware to process the command */
567 if (interrupt_ecf(local, ccsindex)) {
568 printk(KERN_INFO "ray dl_startup_params failed - "
569 "ECF not ready for intr\n");
570 local->card_status = CARD_DL_PARAM_ERROR;
571 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
574 local->card_status = CARD_DL_PARAM;
575 /* Start kernel timer to wait for dl startup to complete. */
576 local->timer.expires = jiffies + HZ / 2;
577 local->timer.data = (long)local;
578 local->timer.function = &verify_dl_startup;
579 add_timer(&local->timer);
581 "ray_cs dl_startup_params started timer for verify_dl_startup\n");
583 } /* dl_startup_params */
585 /*===========================================================================*/
586 static void init_startup_params(ray_dev_t *local)
590 if (country > JAPAN_TEST)
592 else if (country < USA)
594 /* structure for hop time and beacon period is defined here using
595 * New 802.11D6.1 format. Card firmware is still using old format
598 * a_hop_time ms byte a_hop_time ms byte
599 * a_hop_time 2s byte a_hop_time ls byte
600 * a_hop_time ls byte a_beacon_period ms byte
601 * a_beacon_period a_beacon_period ls byte
603 * a_hop_time = uS a_hop_time = KuS
604 * a_beacon_period = hops a_beacon_period = KuS
605 *//* 64ms = 010000 */
606 if (local->fw_ver == 0x55) {
607 memcpy((UCHAR *) &local->sparm.b4, b4_default_startup_parms,
608 sizeof(struct b4_startup_params));
609 /* Translate sane kus input values to old build 4/5 format */
610 /* i = hop time in uS truncated to 3 bytes */
611 i = (hop_dwell * 1024) & 0xffffff;
612 local->sparm.b4.a_hop_time[0] = (i >> 16) & 0xff;
613 local->sparm.b4.a_hop_time[1] = (i >> 8) & 0xff;
614 local->sparm.b4.a_beacon_period[0] = 0;
615 local->sparm.b4.a_beacon_period[1] =
616 ((beacon_period / hop_dwell) - 1) & 0xff;
617 local->sparm.b4.a_curr_country_code = country;
618 local->sparm.b4.a_hop_pattern_length =
619 hop_pattern_length[(int)country] - 1;
621 local->sparm.b4.a_ack_timeout = 0x50;
622 local->sparm.b4.a_sifs = 0x3f;
624 } else { /* Version 5 uses real kus values */
625 memcpy((UCHAR *) &local->sparm.b5, b5_default_startup_parms,
626 sizeof(struct b5_startup_params));
628 local->sparm.b5.a_hop_time[0] = (hop_dwell >> 8) & 0xff;
629 local->sparm.b5.a_hop_time[1] = hop_dwell & 0xff;
630 local->sparm.b5.a_beacon_period[0] =
631 (beacon_period >> 8) & 0xff;
632 local->sparm.b5.a_beacon_period[1] = beacon_period & 0xff;
634 local->sparm.b5.a_power_mgt_state = 1;
635 local->sparm.b5.a_curr_country_code = country;
636 local->sparm.b5.a_hop_pattern_length =
637 hop_pattern_length[(int)country];
640 local->sparm.b4.a_network_type = net_type & 0x01;
641 local->sparm.b4.a_acting_as_ap_status = TYPE_STA;
644 strncpy(local->sparm.b4.a_current_ess_id, essid, ESSID_SIZE);
645 } /* init_startup_params */
647 /*===========================================================================*/
648 static void verify_dl_startup(u_long data)
650 ray_dev_t *local = (ray_dev_t *) data;
651 struct ccs __iomem *pccs = ccs_base(local) + local->dl_param_ccs;
653 struct pcmcia_device *link = local->finder;
655 if (!(pcmcia_dev_present(link))) {
656 dev_dbg(&link->dev, "ray_cs verify_dl_startup - device not present\n");
663 "verify_dl_startup parameters sent via ccs %d:\n",
664 local->dl_param_ccs);
665 for (i = 0; i < sizeof(struct b5_startup_params); i++) {
667 (unsigned int)readb(local->sram +
668 HOST_TO_ECF_BASE + i));
674 status = readb(&pccs->buffer_status);
675 if (status != CCS_BUFFER_FREE) {
677 "Download startup params failed. Status = %d\n",
679 local->card_status = CARD_DL_PARAM_ERROR;
682 if (local->sparm.b4.a_network_type == ADHOC)
683 start_net((u_long) local);
685 join_net((u_long) local);
686 } /* end verify_dl_startup */
688 /*===========================================================================*/
689 /* Command card to start a network */
690 static void start_net(u_long data)
692 ray_dev_t *local = (ray_dev_t *) data;
693 struct ccs __iomem *pccs;
695 struct pcmcia_device *link = local->finder;
696 if (!(pcmcia_dev_present(link))) {
697 dev_dbg(&link->dev, "ray_cs start_net - device not present\n");
700 /* Fill in the CCS fields for the ECF */
701 if ((ccsindex = get_free_ccs(local)) < 0)
703 pccs = ccs_base(local) + ccsindex;
704 writeb(CCS_START_NETWORK, &pccs->cmd);
705 writeb(0, &pccs->var.start_network.update_param);
706 /* Interrupt the firmware to process the command */
707 if (interrupt_ecf(local, ccsindex)) {
708 dev_dbg(&link->dev, "ray start net failed - card not ready for intr\n");
709 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
712 local->card_status = CARD_DOING_ACQ;
713 } /* end start_net */
715 /*===========================================================================*/
716 /* Command card to join a network */
717 static void join_net(u_long data)
719 ray_dev_t *local = (ray_dev_t *) data;
721 struct ccs __iomem *pccs;
723 struct pcmcia_device *link = local->finder;
725 if (!(pcmcia_dev_present(link))) {
726 dev_dbg(&link->dev, "ray_cs join_net - device not present\n");
729 /* Fill in the CCS fields for the ECF */
730 if ((ccsindex = get_free_ccs(local)) < 0)
732 pccs = ccs_base(local) + ccsindex;
733 writeb(CCS_JOIN_NETWORK, &pccs->cmd);
734 writeb(0, &pccs->var.join_network.update_param);
735 writeb(0, &pccs->var.join_network.net_initiated);
736 /* Interrupt the firmware to process the command */
737 if (interrupt_ecf(local, ccsindex)) {
738 dev_dbg(&link->dev, "ray join net failed - card not ready for intr\n");
739 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
742 local->card_status = CARD_DOING_ACQ;
746 static void ray_release(struct pcmcia_device *link)
748 struct net_device *dev = link->priv;
749 ray_dev_t *local = netdev_priv(dev);
751 dev_dbg(&link->dev, "ray_release\n");
753 del_timer(&local->timer);
755 iounmap(local->sram);
756 iounmap(local->rmem);
757 iounmap(local->amem);
758 pcmcia_disable_device(link);
760 dev_dbg(&link->dev, "ray_release ending\n");
763 static int ray_suspend(struct pcmcia_device *link)
765 struct net_device *dev = link->priv;
768 netif_device_detach(dev);
773 static int ray_resume(struct pcmcia_device *link)
775 struct net_device *dev = link->priv;
779 netif_device_attach(dev);
785 /*===========================================================================*/
786 static int ray_dev_init(struct net_device *dev)
788 #ifdef RAY_IMMEDIATE_INIT
790 #endif /* RAY_IMMEDIATE_INIT */
791 ray_dev_t *local = netdev_priv(dev);
792 struct pcmcia_device *link = local->finder;
794 dev_dbg(&link->dev, "ray_dev_init(dev=%p)\n", dev);
795 if (!(pcmcia_dev_present(link))) {
796 dev_dbg(&link->dev, "ray_dev_init - device not present\n");
799 #ifdef RAY_IMMEDIATE_INIT
800 /* Download startup parameters */
801 if ((i = dl_startup_params(dev)) < 0) {
802 printk(KERN_INFO "ray_dev_init dl_startup_params failed - "
803 "returns 0x%x\n", i);
806 #else /* RAY_IMMEDIATE_INIT */
807 /* Postpone the card init so that we can still configure the card,
808 * for example using the Wireless Extensions. The init will happen
809 * in ray_open() - Jean II */
811 "ray_dev_init: postponing card init to ray_open() ; Status = %d\n",
813 #endif /* RAY_IMMEDIATE_INIT */
815 /* copy mac and broadcast addresses to linux device */
816 memcpy(dev->dev_addr, &local->sparm.b4.a_mac_addr, ADDRLEN);
817 memset(dev->broadcast, 0xff, ETH_ALEN);
819 dev_dbg(&link->dev, "ray_dev_init ending\n");
823 /*===========================================================================*/
824 static int ray_dev_config(struct net_device *dev, struct ifmap *map)
826 ray_dev_t *local = netdev_priv(dev);
827 struct pcmcia_device *link = local->finder;
828 /* Dummy routine to satisfy device structure */
829 dev_dbg(&link->dev, "ray_dev_config(dev=%p,ifmap=%p)\n", dev, map);
830 if (!(pcmcia_dev_present(link))) {
831 dev_dbg(&link->dev, "ray_dev_config - device not present\n");
838 /*===========================================================================*/
839 static netdev_tx_t ray_dev_start_xmit(struct sk_buff *skb,
840 struct net_device *dev)
842 ray_dev_t *local = netdev_priv(dev);
843 struct pcmcia_device *link = local->finder;
844 short length = skb->len;
846 if (!pcmcia_dev_present(link)) {
847 dev_dbg(&link->dev, "ray_dev_start_xmit - device not present\n");
852 dev_dbg(&link->dev, "ray_dev_start_xmit(skb=%p, dev=%p)\n", skb, dev);
853 if (local->authentication_state == NEED_TO_AUTH) {
854 dev_dbg(&link->dev, "ray_cs Sending authentication request.\n");
855 if (!build_auth_frame(local, local->auth_id, OPEN_AUTH_REQUEST)) {
856 local->authentication_state = AUTHENTICATED;
857 netif_stop_queue(dev);
858 return NETDEV_TX_BUSY;
862 if (length < ETH_ZLEN) {
863 if (skb_padto(skb, ETH_ZLEN))
867 switch (ray_hw_xmit(skb->data, length, dev, DATA_TYPE)) {
870 netif_stop_queue(dev);
871 return NETDEV_TX_BUSY;
880 } /* ray_dev_start_xmit */
882 /*===========================================================================*/
883 static int ray_hw_xmit(unsigned char *data, int len, struct net_device *dev,
886 ray_dev_t *local = netdev_priv(dev);
887 struct ccs __iomem *pccs;
890 struct tx_msg __iomem *ptx; /* Address of xmit buffer in PC space */
891 short int addr; /* Address of xmit buffer in card space */
893 pr_debug("ray_hw_xmit(data=%p, len=%d, dev=%p)\n", data, len, dev);
894 if (len + TX_HEADER_LENGTH > TX_BUF_SIZE) {
895 printk(KERN_INFO "ray_hw_xmit packet too large: %d bytes\n",
899 switch (ccsindex = get_free_tx_ccs(local)) {
901 pr_debug("ray_hw_xmit tx_ccs table busy\n");
903 pr_debug("ray_hw_xmit No free tx ccs\n");
905 netif_stop_queue(dev);
910 addr = TX_BUF_BASE + (ccsindex << 11);
912 if (msg_type == DATA_TYPE) {
913 local->stats.tx_bytes += len;
914 local->stats.tx_packets++;
917 ptx = local->sram + addr;
919 ray_build_header(local, ptx, msg_type, data);
921 offset = translate_frame(local, ptx, data, len);
922 } else { /* Encapsulate frame */
923 /* TBD TIB length will move address of ptx->var */
924 memcpy_toio(&ptx->var, data, len);
928 /* fill in the CCS */
929 pccs = ccs_base(local) + ccsindex;
930 len += TX_HEADER_LENGTH + offset;
931 writeb(CCS_TX_REQUEST, &pccs->cmd);
932 writeb(addr >> 8, &pccs->var.tx_request.tx_data_ptr[0]);
933 writeb(local->tib_length, &pccs->var.tx_request.tx_data_ptr[1]);
934 writeb(len >> 8, &pccs->var.tx_request.tx_data_length[0]);
935 writeb(len & 0xff, &pccs->var.tx_request.tx_data_length[1]);
936 /* TBD still need psm_cam? */
937 writeb(PSM_CAM, &pccs->var.tx_request.pow_sav_mode);
938 writeb(local->net_default_tx_rate, &pccs->var.tx_request.tx_rate);
939 writeb(0, &pccs->var.tx_request.antenna);
940 pr_debug("ray_hw_xmit default_tx_rate = 0x%x\n",
941 local->net_default_tx_rate);
943 /* Interrupt the firmware to process the command */
944 if (interrupt_ecf(local, ccsindex)) {
945 pr_debug("ray_hw_xmit failed - ECF not ready for intr\n");
946 /* TBD very inefficient to copy packet to buffer, and then not
947 send it, but the alternative is to queue the messages and that
948 won't be done for a while. Maybe set tbusy until a CCS is free?
950 writeb(CCS_BUFFER_FREE, &pccs->buffer_status);
954 } /* end ray_hw_xmit */
956 /*===========================================================================*/
957 static int translate_frame(ray_dev_t *local, struct tx_msg __iomem *ptx,
958 unsigned char *data, int len)
960 __be16 proto = ((struct ethhdr *)data)->h_proto;
961 if (ntohs(proto) >= 1536) { /* DIX II ethernet frame */
962 pr_debug("ray_cs translate_frame DIX II\n");
963 /* Copy LLC header to card buffer */
964 memcpy_toio(&ptx->var, eth2_llc, sizeof(eth2_llc));
965 memcpy_toio(((void __iomem *)&ptx->var) + sizeof(eth2_llc),
966 (UCHAR *) &proto, 2);
967 if (proto == htons(ETH_P_AARP) || proto == htons(ETH_P_IPX)) {
968 /* This is the selective translation table, only 2 entries */
970 &((struct snaphdr_t __iomem *)ptx->var)->org[3]);
972 /* Copy body of ethernet packet without ethernet header */
973 memcpy_toio((void __iomem *)&ptx->var +
974 sizeof(struct snaphdr_t), data + ETH_HLEN,
976 return (int)sizeof(struct snaphdr_t) - ETH_HLEN;
977 } else { /* already 802 type, and proto is length */
978 pr_debug("ray_cs translate_frame 802\n");
979 if (proto == htons(0xffff)) { /* evil netware IPX 802.3 without LLC */
980 pr_debug("ray_cs translate_frame evil IPX\n");
981 memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
984 memcpy_toio(&ptx->var, data + ETH_HLEN, len - ETH_HLEN);
987 /* TBD do other frame types */
988 } /* end translate_frame */
990 /*===========================================================================*/
991 static void ray_build_header(ray_dev_t *local, struct tx_msg __iomem *ptx,
992 UCHAR msg_type, unsigned char *data)
994 writeb(PROTOCOL_VER | msg_type, &ptx->mac.frame_ctl_1);
995 /*** IEEE 802.11 Address field assignments *************
996 TODS FROMDS addr_1 addr_2 addr_3 addr_4
997 Adhoc 0 0 dest src (terminal) BSSID N/A
998 AP to Terminal 0 1 dest AP(BSSID) source N/A
999 Terminal to AP 1 0 AP(BSSID) src (terminal) dest N/A
1000 AP to AP 1 1 dest AP src AP dest source
1001 *******************************************************/
1002 if (local->net_type == ADHOC) {
1003 writeb(0, &ptx->mac.frame_ctl_2);
1004 memcpy_toio(ptx->mac.addr_1, ((struct ethhdr *)data)->h_dest,
1006 memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN);
1007 } else { /* infrastructure */
1009 if (local->sparm.b4.a_acting_as_ap_status) {
1010 writeb(FC2_FROM_DS, &ptx->mac.frame_ctl_2);
1011 memcpy_toio(ptx->mac.addr_1,
1012 ((struct ethhdr *)data)->h_dest, ADDRLEN);
1013 memcpy_toio(ptx->mac.addr_2, local->bss_id, 6);
1014 memcpy_toio(ptx->mac.addr_3,
1015 ((struct ethhdr *)data)->h_source, ADDRLEN);
1016 } else { /* Terminal */
1018 writeb(FC2_TO_DS, &ptx->mac.frame_ctl_2);
1019 memcpy_toio(ptx->mac.addr_1, local->bss_id, ADDRLEN);
1020 memcpy_toio(ptx->mac.addr_2,
1021 ((struct ethhdr *)data)->h_source, ADDRLEN);
1022 memcpy_toio(ptx->mac.addr_3,
1023 ((struct ethhdr *)data)->h_dest, ADDRLEN);
1026 } /* end encapsulate_frame */
1028 /*===========================================================================*/
1030 static void netdev_get_drvinfo(struct net_device *dev,
1031 struct ethtool_drvinfo *info)
1033 strcpy(info->driver, "ray_cs");
1036 static const struct ethtool_ops netdev_ethtool_ops = {
1037 .get_drvinfo = netdev_get_drvinfo,
1040 /*====================================================================*/
1042 /*------------------------------------------------------------------*/
1044 * Wireless Handler : get protocol name
1046 static int ray_get_name(struct net_device *dev, struct iw_request_info *info,
1047 union iwreq_data *wrqu, char *extra)
1049 strcpy(wrqu->name, "IEEE 802.11-FH");
1053 /*------------------------------------------------------------------*/
1055 * Wireless Handler : set frequency
1057 static int ray_set_freq(struct net_device *dev, struct iw_request_info *info,
1058 union iwreq_data *wrqu, char *extra)
1060 ray_dev_t *local = netdev_priv(dev);
1061 int err = -EINPROGRESS; /* Call commit handler */
1063 /* Reject if card is already initialised */
1064 if (local->card_status != CARD_AWAITING_PARAM)
1067 /* Setting by channel number */
1068 if ((wrqu->freq.m > USA_HOP_MOD) || (wrqu->freq.e > 0))
1071 local->sparm.b5.a_hop_pattern = wrqu->freq.m;
1076 /*------------------------------------------------------------------*/
1078 * Wireless Handler : get frequency
1080 static int ray_get_freq(struct net_device *dev, struct iw_request_info *info,
1081 union iwreq_data *wrqu, char *extra)
1083 ray_dev_t *local = netdev_priv(dev);
1085 wrqu->freq.m = local->sparm.b5.a_hop_pattern;
1090 /*------------------------------------------------------------------*/
1092 * Wireless Handler : set ESSID
1094 static int ray_set_essid(struct net_device *dev, struct iw_request_info *info,
1095 union iwreq_data *wrqu, char *extra)
1097 ray_dev_t *local = netdev_priv(dev);
1099 /* Reject if card is already initialised */
1100 if (local->card_status != CARD_AWAITING_PARAM)
1103 /* Check if we asked for `any' */
1104 if (wrqu->essid.flags == 0)
1105 /* Corey : can you do that ? */
1108 /* Check the size of the string */
1109 if (wrqu->essid.length > IW_ESSID_MAX_SIZE)
1112 /* Set the ESSID in the card */
1113 memset(local->sparm.b5.a_current_ess_id, 0, IW_ESSID_MAX_SIZE);
1114 memcpy(local->sparm.b5.a_current_ess_id, extra, wrqu->essid.length);
1116 return -EINPROGRESS; /* Call commit handler */
1119 /*------------------------------------------------------------------*/
1121 * Wireless Handler : get ESSID
1123 static int ray_get_essid(struct net_device *dev, struct iw_request_info *info,
1124 union iwreq_data *wrqu, char *extra)
1126 ray_dev_t *local = netdev_priv(dev);
1128 /* Get the essid that was set */
1129 memcpy(extra, local->sparm.b5.a_current_ess_id, IW_ESSID_MAX_SIZE);
1132 wrqu->essid.length = strlen(extra);
1133 wrqu->essid.flags = 1; /* active */
1138 /*------------------------------------------------------------------*/
1140 * Wireless Handler : get AP address
1142 static int ray_get_wap(struct net_device *dev, struct iw_request_info *info,
1143 union iwreq_data *wrqu, char *extra)
1145 ray_dev_t *local = netdev_priv(dev);
1147 memcpy(wrqu->ap_addr.sa_data, local->bss_id, ETH_ALEN);
1148 wrqu->ap_addr.sa_family = ARPHRD_ETHER;
1153 /*------------------------------------------------------------------*/
1155 * Wireless Handler : set Bit-Rate
1157 static int ray_set_rate(struct net_device *dev, struct iw_request_info *info,
1158 union iwreq_data *wrqu, char *extra)
1160 ray_dev_t *local = netdev_priv(dev);
1162 /* Reject if card is already initialised */
1163 if (local->card_status != CARD_AWAITING_PARAM)
1166 /* Check if rate is in range */
1167 if ((wrqu->bitrate.value != 1000000) && (wrqu->bitrate.value != 2000000))
1170 /* Hack for 1.5 Mb/s instead of 2 Mb/s */
1171 if ((local->fw_ver == 0x55) && /* Please check */
1172 (wrqu->bitrate.value == 2000000))
1173 local->net_default_tx_rate = 3;
1175 local->net_default_tx_rate = wrqu->bitrate.value / 500000;
1180 /*------------------------------------------------------------------*/
1182 * Wireless Handler : get Bit-Rate
1184 static int ray_get_rate(struct net_device *dev, struct iw_request_info *info,
1185 union iwreq_data *wrqu, char *extra)
1187 ray_dev_t *local = netdev_priv(dev);
1189 if (local->net_default_tx_rate == 3)
1190 wrqu->bitrate.value = 2000000; /* Hum... */
1192 wrqu->bitrate.value = local->net_default_tx_rate * 500000;
1193 wrqu->bitrate.fixed = 0; /* We are in auto mode */
1198 /*------------------------------------------------------------------*/
1200 * Wireless Handler : set RTS threshold
1202 static int ray_set_rts(struct net_device *dev, struct iw_request_info *info,
1203 union iwreq_data *wrqu, char *extra)
1205 ray_dev_t *local = netdev_priv(dev);
1206 int rthr = wrqu->rts.value;
1208 /* Reject if card is already initialised */
1209 if (local->card_status != CARD_AWAITING_PARAM)
1212 /* if(wrq->u.rts.fixed == 0) we should complain */
1213 if (wrqu->rts.disabled)
1216 if ((rthr < 0) || (rthr > 2347)) /* What's the max packet size ??? */
1219 local->sparm.b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF;
1220 local->sparm.b5.a_rts_threshold[1] = rthr & 0xFF;
1222 return -EINPROGRESS; /* Call commit handler */
1225 /*------------------------------------------------------------------*/
1227 * Wireless Handler : get RTS threshold
1229 static int ray_get_rts(struct net_device *dev, struct iw_request_info *info,
1230 union iwreq_data *wrqu, char *extra)
1232 ray_dev_t *local = netdev_priv(dev);
1234 wrqu->rts.value = (local->sparm.b5.a_rts_threshold[0] << 8)
1235 + local->sparm.b5.a_rts_threshold[1];
1236 wrqu->rts.disabled = (wrqu->rts.value == 32767);
1237 wrqu->rts.fixed = 1;
1242 /*------------------------------------------------------------------*/
1244 * Wireless Handler : set Fragmentation threshold
1246 static int ray_set_frag(struct net_device *dev, struct iw_request_info *info,
1247 union iwreq_data *wrqu, char *extra)
1249 ray_dev_t *local = netdev_priv(dev);
1250 int fthr = wrqu->frag.value;
1252 /* Reject if card is already initialised */
1253 if (local->card_status != CARD_AWAITING_PARAM)
1256 /* if(wrq->u.frag.fixed == 0) should complain */
1257 if (wrqu->frag.disabled)
1260 if ((fthr < 256) || (fthr > 2347)) /* To check out ! */
1263 local->sparm.b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF;
1264 local->sparm.b5.a_frag_threshold[1] = fthr & 0xFF;
1266 return -EINPROGRESS; /* Call commit handler */
1269 /*------------------------------------------------------------------*/
1271 * Wireless Handler : get Fragmentation threshold
1273 static int ray_get_frag(struct net_device *dev, struct iw_request_info *info,
1274 union iwreq_data *wrqu, char *extra)
1276 ray_dev_t *local = netdev_priv(dev);
1278 wrqu->frag.value = (local->sparm.b5.a_frag_threshold[0] << 8)
1279 + local->sparm.b5.a_frag_threshold[1];
1280 wrqu->frag.disabled = (wrqu->frag.value == 32767);
1281 wrqu->frag.fixed = 1;
1286 /*------------------------------------------------------------------*/
1288 * Wireless Handler : set Mode of Operation
1290 static int ray_set_mode(struct net_device *dev, struct iw_request_info *info,
1291 union iwreq_data *wrqu, char *extra)
1293 ray_dev_t *local = netdev_priv(dev);
1294 int err = -EINPROGRESS; /* Call commit handler */
1297 /* Reject if card is already initialised */
1298 if (local->card_status != CARD_AWAITING_PARAM)
1301 switch (wrqu->mode) {
1306 local->sparm.b5.a_network_type = card_mode;
1315 /*------------------------------------------------------------------*/
1317 * Wireless Handler : get Mode of Operation
1319 static int ray_get_mode(struct net_device *dev, struct iw_request_info *info,
1320 union iwreq_data *wrqu, char *extra)
1322 ray_dev_t *local = netdev_priv(dev);
1324 if (local->sparm.b5.a_network_type)
1325 wrqu->mode = IW_MODE_INFRA;
1327 wrqu->mode = IW_MODE_ADHOC;
1332 /*------------------------------------------------------------------*/
1334 * Wireless Handler : get range info
1336 static int ray_get_range(struct net_device *dev, struct iw_request_info *info,
1337 union iwreq_data *wrqu, char *extra)
1339 struct iw_range *range = (struct iw_range *)extra;
1341 memset(range, 0, sizeof(struct iw_range));
1343 /* Set the length (very important for backward compatibility) */
1344 wrqu->data.length = sizeof(struct iw_range);
1346 /* Set the Wireless Extension versions */
1347 range->we_version_compiled = WIRELESS_EXT;
1348 range->we_version_source = 9;
1350 /* Set information in the range struct */
1351 range->throughput = 1.1 * 1000 * 1000; /* Put the right number here */
1352 range->num_channels = hop_pattern_length[(int)country];
1353 range->num_frequency = 0;
1354 range->max_qual.qual = 0;
1355 range->max_qual.level = 255; /* What's the correct value ? */
1356 range->max_qual.noise = 255; /* Idem */
1357 range->num_bitrates = 2;
1358 range->bitrate[0] = 1000000; /* 1 Mb/s */
1359 range->bitrate[1] = 2000000; /* 2 Mb/s */
1363 /*------------------------------------------------------------------*/
1365 * Wireless Private Handler : set framing mode
1367 static int ray_set_framing(struct net_device *dev, struct iw_request_info *info,
1368 union iwreq_data *wrqu, char *extra)
1370 translate = *(extra); /* Set framing mode */
1375 /*------------------------------------------------------------------*/
1377 * Wireless Private Handler : get framing mode
1379 static int ray_get_framing(struct net_device *dev, struct iw_request_info *info,
1380 union iwreq_data *wrqu, char *extra)
1382 *(extra) = translate;
1387 /*------------------------------------------------------------------*/
1389 * Wireless Private Handler : get country
1391 static int ray_get_country(struct net_device *dev, struct iw_request_info *info,
1392 union iwreq_data *wrqu, char *extra)
1399 /*------------------------------------------------------------------*/
1401 * Commit handler : called after a bunch of SET operations
1403 static int ray_commit(struct net_device *dev, struct iw_request_info *info,
1404 union iwreq_data *wrqu, char *extra)
1409 /*------------------------------------------------------------------*/
1411 * Stats handler : return Wireless Stats
1413 static iw_stats *ray_get_wireless_stats(struct net_device *dev)
1415 ray_dev_t *local = netdev_priv(dev);
1416 struct pcmcia_device *link = local->finder;
1417 struct status __iomem *p = local->sram + STATUS_BASE;
1419 local->wstats.status = local->card_status;
1421 if ((local->spy_data.spy_number > 0)
1422 && (local->sparm.b5.a_network_type == 0)) {
1423 /* Get it from the first node in spy list */
1424 local->wstats.qual.qual = local->spy_data.spy_stat[0].qual;
1425 local->wstats.qual.level = local->spy_data.spy_stat[0].level;
1426 local->wstats.qual.noise = local->spy_data.spy_stat[0].noise;
1427 local->wstats.qual.updated =
1428 local->spy_data.spy_stat[0].updated;
1430 #endif /* WIRELESS_SPY */
1432 if (pcmcia_dev_present(link)) {
1433 local->wstats.qual.noise = readb(&p->rxnoise);
1434 local->wstats.qual.updated |= 4;
1437 return &local->wstats;
1438 } /* end ray_get_wireless_stats */
1440 /*------------------------------------------------------------------*/
1442 * Structures to export the Wireless Handlers
1445 static const iw_handler ray_handler[] = {
1446 IW_HANDLER(SIOCSIWCOMMIT, ray_commit),
1447 IW_HANDLER(SIOCGIWNAME, ray_get_name),
1448 IW_HANDLER(SIOCSIWFREQ, ray_set_freq),
1449 IW_HANDLER(SIOCGIWFREQ, ray_get_freq),
1450 IW_HANDLER(SIOCSIWMODE, ray_set_mode),
1451 IW_HANDLER(SIOCGIWMODE, ray_get_mode),
1452 IW_HANDLER(SIOCGIWRANGE, ray_get_range),
1454 IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy),
1455 IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy),
1456 IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy),
1457 IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy),
1458 #endif /* WIRELESS_SPY */
1459 IW_HANDLER(SIOCGIWAP, ray_get_wap),
1460 IW_HANDLER(SIOCSIWESSID, ray_set_essid),
1461 IW_HANDLER(SIOCGIWESSID, ray_get_essid),
1462 IW_HANDLER(SIOCSIWRATE, ray_set_rate),
1463 IW_HANDLER(SIOCGIWRATE, ray_get_rate),
1464 IW_HANDLER(SIOCSIWRTS, ray_set_rts),
1465 IW_HANDLER(SIOCGIWRTS, ray_get_rts),
1466 IW_HANDLER(SIOCSIWFRAG, ray_set_frag),
1467 IW_HANDLER(SIOCGIWFRAG, ray_get_frag),
1470 #define SIOCSIPFRAMING SIOCIWFIRSTPRIV /* Set framing mode */
1471 #define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1 /* Get framing mode */
1472 #define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3 /* Get country code */
1474 static const iw_handler ray_private_handler[] = {
1475 [0] = ray_set_framing,
1476 [1] = ray_get_framing,
1477 [3] = ray_get_country,
1480 static const struct iw_priv_args ray_private_args[] = {
1481 /* cmd, set_args, get_args, name */
1482 {SIOCSIPFRAMING, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1, 0,
1484 {SIOCGIPFRAMING, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
1486 {SIOCGIPCOUNTRY, 0, IW_PRIV_TYPE_BYTE | IW_PRIV_SIZE_FIXED | 1,
1490 static const struct iw_handler_def ray_handler_def = {
1491 .num_standard = ARRAY_SIZE(ray_handler),
1492 .num_private = ARRAY_SIZE(ray_private_handler),
1493 .num_private_args = ARRAY_SIZE(ray_private_args),
1494 .standard = ray_handler,
1495 .private = ray_private_handler,
1496 .private_args = ray_private_args,
1497 .get_wireless_stats = ray_get_wireless_stats,
1500 /*===========================================================================*/
1501 static int ray_open(struct net_device *dev)
1503 ray_dev_t *local = netdev_priv(dev);
1504 struct pcmcia_device *link;
1505 link = local->finder;
1507 dev_dbg(&link->dev, "ray_open('%s')\n", dev->name);
1509 if (link->open == 0)
1510 local->num_multi = 0;
1513 /* If the card is not started, time to start it ! - Jean II */
1514 if (local->card_status == CARD_AWAITING_PARAM) {
1517 dev_dbg(&link->dev, "ray_open: doing init now !\n");
1519 /* Download startup parameters */
1520 if ((i = dl_startup_params(dev)) < 0) {
1522 "ray_dev_init dl_startup_params failed - "
1523 "returns 0x%x\n", i);
1529 netif_stop_queue(dev);
1531 netif_start_queue(dev);
1533 dev_dbg(&link->dev, "ray_open ending\n");
1535 } /* end ray_open */
1537 /*===========================================================================*/
1538 static int ray_dev_close(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_dev_close('%s')\n", dev->name);
1547 netif_stop_queue(dev);
1549 /* In here, we should stop the hardware (stop card from beeing active)
1550 * and set local->card_status to CARD_AWAITING_PARAM, so that while the
1551 * card is closed we can chage its configuration.
1552 * Probably also need a COR reset to get sane state - Jean II */
1555 } /* end ray_dev_close */
1557 /*===========================================================================*/
1558 static void ray_reset(struct net_device *dev)
1560 pr_debug("ray_reset entered\n");
1563 /*===========================================================================*/
1564 /* Cause a firmware interrupt if it is ready for one */
1565 /* Return nonzero if not ready */
1566 static int interrupt_ecf(ray_dev_t *local, int ccs)
1569 struct pcmcia_device *link = local->finder;
1571 if (!(pcmcia_dev_present(link))) {
1572 dev_dbg(&link->dev, "ray_cs interrupt_ecf - device not present\n");
1575 dev_dbg(&link->dev, "interrupt_ecf(local=%p, ccs = 0x%x\n", local, ccs);
1578 (readb(local->amem + CIS_OFFSET + ECF_INTR_OFFSET) &
1582 dev_dbg(&link->dev, "ray_cs interrupt_ecf card not ready for interrupt\n");
1585 /* Fill the mailbox, then kick the card */
1586 writeb(ccs, local->sram + SCB_BASE);
1587 writeb(ECF_INTR_SET, local->amem + CIS_OFFSET + ECF_INTR_OFFSET);
1589 } /* interrupt_ecf */
1591 /*===========================================================================*/
1592 /* Get next free transmit CCS */
1593 /* Return - index of current tx ccs */
1594 static int get_free_tx_ccs(ray_dev_t *local)
1597 struct ccs __iomem *pccs = ccs_base(local);
1598 struct pcmcia_device *link = local->finder;
1600 if (!(pcmcia_dev_present(link))) {
1601 dev_dbg(&link->dev, "ray_cs get_free_tx_ccs - device not present\n");
1605 if (test_and_set_bit(0, &local->tx_ccs_lock)) {
1606 dev_dbg(&link->dev, "ray_cs tx_ccs_lock busy\n");
1610 for (i = 0; i < NUMBER_OF_TX_CCS; i++) {
1611 if (readb(&(pccs + i)->buffer_status) == CCS_BUFFER_FREE) {
1612 writeb(CCS_BUFFER_BUSY, &(pccs + i)->buffer_status);
1613 writeb(CCS_END_LIST, &(pccs + i)->link);
1614 local->tx_ccs_lock = 0;
1618 local->tx_ccs_lock = 0;
1619 dev_dbg(&link->dev, "ray_cs ERROR no free tx CCS for raylink card\n");
1621 } /* get_free_tx_ccs */
1623 /*===========================================================================*/
1624 /* Get next free CCS */
1625 /* Return - index of current ccs */
1626 static int get_free_ccs(ray_dev_t *local)
1629 struct ccs __iomem *pccs = ccs_base(local);
1630 struct pcmcia_device *link = local->finder;
1632 if (!(pcmcia_dev_present(link))) {
1633 dev_dbg(&link->dev, "ray_cs get_free_ccs - device not present\n");
1636 if (test_and_set_bit(0, &local->ccs_lock)) {
1637 dev_dbg(&link->dev, "ray_cs ccs_lock busy\n");
1641 for (i = NUMBER_OF_TX_CCS; i < NUMBER_OF_CCS; i++) {
1642 if (readb(&(pccs + i)->buffer_status) == CCS_BUFFER_FREE) {
1643 writeb(CCS_BUFFER_BUSY, &(pccs + i)->buffer_status);
1644 writeb(CCS_END_LIST, &(pccs + i)->link);
1645 local->ccs_lock = 0;
1649 local->ccs_lock = 0;
1650 dev_dbg(&link->dev, "ray_cs ERROR no free CCS for raylink card\n");
1652 } /* get_free_ccs */
1654 /*===========================================================================*/
1655 static void authenticate_timeout(u_long data)
1657 ray_dev_t *local = (ray_dev_t *) data;
1658 del_timer(&local->timer);
1659 printk(KERN_INFO "ray_cs Authentication with access point failed"
1661 join_net((u_long) local);
1664 /*===========================================================================*/
1665 static int parse_addr(char *in_str, UCHAR *out)
1673 if ((len = strlen(in_str)) < 2)
1675 memset(out, 0, ADDRLEN);
1684 if ((k = hex_to_bin(in_str[j--])) != -1)
1691 if ((k = hex_to_bin(in_str[j--])) != -1)
1701 /*===========================================================================*/
1702 static struct net_device_stats *ray_get_stats(struct net_device *dev)
1704 ray_dev_t *local = netdev_priv(dev);
1705 struct pcmcia_device *link = local->finder;
1706 struct status __iomem *p = local->sram + STATUS_BASE;
1707 if (!(pcmcia_dev_present(link))) {
1708 dev_dbg(&link->dev, "ray_cs net_device_stats - device not present\n");
1709 return &local->stats;
1711 if (readb(&p->mrx_overflow_for_host)) {
1712 local->stats.rx_over_errors += swab16(readw(&p->mrx_overflow));
1713 writeb(0, &p->mrx_overflow);
1714 writeb(0, &p->mrx_overflow_for_host);
1716 if (readb(&p->mrx_checksum_error_for_host)) {
1717 local->stats.rx_crc_errors +=
1718 swab16(readw(&p->mrx_checksum_error));
1719 writeb(0, &p->mrx_checksum_error);
1720 writeb(0, &p->mrx_checksum_error_for_host);
1722 if (readb(&p->rx_hec_error_for_host)) {
1723 local->stats.rx_frame_errors += swab16(readw(&p->rx_hec_error));
1724 writeb(0, &p->rx_hec_error);
1725 writeb(0, &p->rx_hec_error_for_host);
1727 return &local->stats;
1730 /*===========================================================================*/
1731 static void ray_update_parm(struct net_device *dev, UCHAR objid, UCHAR *value,
1734 ray_dev_t *local = netdev_priv(dev);
1735 struct pcmcia_device *link = local->finder;
1738 struct ccs __iomem *pccs;
1740 if (!(pcmcia_dev_present(link))) {
1741 dev_dbg(&link->dev, "ray_update_parm - device not present\n");
1745 if ((ccsindex = get_free_ccs(local)) < 0) {
1746 dev_dbg(&link->dev, "ray_update_parm - No free ccs\n");
1749 pccs = ccs_base(local) + ccsindex;
1750 writeb(CCS_UPDATE_PARAMS, &pccs->cmd);
1751 writeb(objid, &pccs->var.update_param.object_id);
1752 writeb(1, &pccs->var.update_param.number_objects);
1753 writeb(0, &pccs->var.update_param.failure_cause);
1754 for (i = 0; i < len; i++) {
1755 writeb(value[i], local->sram + HOST_TO_ECF_BASE);
1757 /* Interrupt the firmware to process the command */
1758 if (interrupt_ecf(local, ccsindex)) {
1759 dev_dbg(&link->dev, "ray_cs associate failed - ECF not ready for intr\n");
1760 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
1764 /*===========================================================================*/
1765 static void ray_update_multi_list(struct net_device *dev, int all)
1768 struct ccs __iomem *pccs;
1769 ray_dev_t *local = netdev_priv(dev);
1770 struct pcmcia_device *link = local->finder;
1771 void __iomem *p = local->sram + HOST_TO_ECF_BASE;
1773 if (!(pcmcia_dev_present(link))) {
1774 dev_dbg(&link->dev, "ray_update_multi_list - device not present\n");
1777 dev_dbg(&link->dev, "ray_update_multi_list(%p)\n", dev);
1778 if ((ccsindex = get_free_ccs(local)) < 0) {
1779 dev_dbg(&link->dev, "ray_update_multi - No free ccs\n");
1782 pccs = ccs_base(local) + ccsindex;
1783 writeb(CCS_UPDATE_MULTICAST_LIST, &pccs->cmd);
1786 writeb(0xff, &pccs->var);
1787 local->num_multi = 0xff;
1789 struct netdev_hw_addr *ha;
1792 /* Copy the kernel's list of MC addresses to card */
1793 netdev_for_each_mc_addr(ha, dev) {
1794 memcpy_toio(p, ha->addr, ETH_ALEN);
1796 "ray_update_multi add addr %02x%02x%02x%02x%02x%02x\n",
1797 ha->addr[0], ha->addr[1],
1798 ha->addr[2], ha->addr[3],
1799 ha->addr[4], ha->addr[5]);
1803 if (i > 256 / ADDRLEN)
1805 writeb((UCHAR) i, &pccs->var);
1806 dev_dbg(&link->dev, "ray_cs update_multi %d addresses in list\n", i);
1807 /* Interrupt the firmware to process the command */
1808 local->num_multi = i;
1810 if (interrupt_ecf(local, ccsindex)) {
1812 "ray_cs update_multi failed - ECF not ready for intr\n");
1813 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
1815 } /* end ray_update_multi_list */
1817 /*===========================================================================*/
1818 static void set_multicast_list(struct net_device *dev)
1820 ray_dev_t *local = netdev_priv(dev);
1823 pr_debug("ray_cs set_multicast_list(%p)\n", dev);
1825 if (dev->flags & IFF_PROMISC) {
1826 if (local->sparm.b5.a_promiscuous_mode == 0) {
1827 pr_debug("ray_cs set_multicast_list promisc on\n");
1828 local->sparm.b5.a_promiscuous_mode = 1;
1830 ray_update_parm(dev, OBJID_promiscuous_mode,
1831 &promisc, sizeof(promisc));
1834 if (local->sparm.b5.a_promiscuous_mode == 1) {
1835 pr_debug("ray_cs set_multicast_list promisc off\n");
1836 local->sparm.b5.a_promiscuous_mode = 0;
1838 ray_update_parm(dev, OBJID_promiscuous_mode,
1839 &promisc, sizeof(promisc));
1843 if (dev->flags & IFF_ALLMULTI)
1844 ray_update_multi_list(dev, 1);
1846 if (local->num_multi != netdev_mc_count(dev))
1847 ray_update_multi_list(dev, 0);
1849 } /* end set_multicast_list */
1851 /*=============================================================================
1852 * All routines below here are run at interrupt time.
1853 =============================================================================*/
1854 static irqreturn_t ray_interrupt(int irq, void *dev_id)
1856 struct net_device *dev = (struct net_device *)dev_id;
1857 struct pcmcia_device *link;
1859 struct ccs __iomem *pccs;
1860 struct rcs __iomem *prcs;
1866 if (dev == NULL) /* Note that we want interrupts with dev->start == 0 */
1869 pr_debug("ray_cs: interrupt for *dev=%p\n", dev);
1871 local = netdev_priv(dev);
1872 link = (struct pcmcia_device *)local->finder;
1873 if (!pcmcia_dev_present(link)) {
1875 "ray_cs interrupt from device not present or suspended.\n");
1878 rcsindex = readb(&((struct scb __iomem *)(local->sram))->rcs_index);
1880 if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
1881 dev_dbg(&link->dev, "ray_cs interrupt bad rcsindex = 0x%x\n", rcsindex);
1882 clear_interrupt(local);
1885 if (rcsindex < NUMBER_OF_CCS) { /* If it's a returned CCS */
1886 pccs = ccs_base(local) + rcsindex;
1887 cmd = readb(&pccs->cmd);
1888 status = readb(&pccs->buffer_status);
1890 case CCS_DOWNLOAD_STARTUP_PARAMS: /* Happens in firmware someday */
1891 del_timer(&local->timer);
1892 if (status == CCS_COMMAND_COMPLETE) {
1894 "ray_cs interrupt download_startup_parameters OK\n");
1897 "ray_cs interrupt download_startup_parameters fail\n");
1900 case CCS_UPDATE_PARAMS:
1901 dev_dbg(&link->dev, "ray_cs interrupt update params done\n");
1902 if (status != CCS_COMMAND_COMPLETE) {
1904 readb(&pccs->var.update_param.
1907 "ray_cs interrupt update params failed - reason %d\n",
1911 case CCS_REPORT_PARAMS:
1912 dev_dbg(&link->dev, "ray_cs interrupt report params done\n");
1914 case CCS_UPDATE_MULTICAST_LIST: /* Note that this CCS isn't returned */
1916 "ray_cs interrupt CCS Update Multicast List done\n");
1918 case CCS_UPDATE_POWER_SAVINGS_MODE:
1920 "ray_cs interrupt update power save mode done\n");
1922 case CCS_START_NETWORK:
1923 case CCS_JOIN_NETWORK:
1924 if (status == CCS_COMMAND_COMPLETE) {
1926 (&pccs->var.start_network.net_initiated) ==
1929 "ray_cs interrupt network \"%s\" started\n",
1930 local->sparm.b4.a_current_ess_id);
1933 "ray_cs interrupt network \"%s\" joined\n",
1934 local->sparm.b4.a_current_ess_id);
1936 memcpy_fromio(&local->bss_id,
1937 pccs->var.start_network.bssid,
1940 if (local->fw_ver == 0x55)
1941 local->net_default_tx_rate = 3;
1943 local->net_default_tx_rate =
1944 readb(&pccs->var.start_network.
1945 net_default_tx_rate);
1947 readb(&pccs->var.start_network.encryption);
1948 if (!sniffer && (local->net_type == INFRA)
1949 && !(local->sparm.b4.a_acting_as_ap_status)) {
1950 authenticate(local);
1952 local->card_status = CARD_ACQ_COMPLETE;
1954 local->card_status = CARD_ACQ_FAILED;
1956 del_timer(&local->timer);
1957 local->timer.expires = jiffies + HZ * 5;
1958 local->timer.data = (long)local;
1959 if (status == CCS_START_NETWORK) {
1961 "ray_cs interrupt network \"%s\" start failed\n",
1962 local->sparm.b4.a_current_ess_id);
1963 local->timer.function = &start_net;
1966 "ray_cs interrupt network \"%s\" join failed\n",
1967 local->sparm.b4.a_current_ess_id);
1968 local->timer.function = &join_net;
1970 add_timer(&local->timer);
1973 case CCS_START_ASSOCIATION:
1974 if (status == CCS_COMMAND_COMPLETE) {
1975 local->card_status = CARD_ASSOC_COMPLETE;
1976 dev_dbg(&link->dev, "ray_cs association successful\n");
1978 dev_dbg(&link->dev, "ray_cs association failed,\n");
1979 local->card_status = CARD_ASSOC_FAILED;
1980 join_net((u_long) local);
1983 case CCS_TX_REQUEST:
1984 if (status == CCS_COMMAND_COMPLETE) {
1986 "ray_cs interrupt tx request complete\n");
1989 "ray_cs interrupt tx request failed\n");
1992 netif_start_queue(dev);
1993 netif_wake_queue(dev);
1995 case CCS_TEST_MEMORY:
1996 dev_dbg(&link->dev, "ray_cs interrupt mem test done\n");
2000 "ray_cs interrupt Unexpected CCS returned - Shutdown\n");
2002 case CCS_DUMP_MEMORY:
2003 dev_dbg(&link->dev, "ray_cs interrupt dump memory done\n");
2005 case CCS_START_TIMER:
2007 "ray_cs interrupt DING - raylink timer expired\n");
2011 "ray_cs interrupt Unexpected CCS 0x%x returned 0x%x\n",
2014 writeb(CCS_BUFFER_FREE, &pccs->buffer_status);
2015 } else { /* It's an RCS */
2017 prcs = rcs_base(local) + rcsindex;
2019 switch (readb(&prcs->interrupt_id)) {
2020 case PROCESS_RX_PACKET:
2021 ray_rx(dev, local, prcs);
2023 case REJOIN_NET_COMPLETE:
2024 dev_dbg(&link->dev, "ray_cs interrupt rejoin net complete\n");
2025 local->card_status = CARD_ACQ_COMPLETE;
2026 /* do we need to clear tx buffers CCS's? */
2027 if (local->sparm.b4.a_network_type == ADHOC) {
2029 netif_start_queue(dev);
2031 memcpy_fromio(&local->bss_id,
2032 prcs->var.rejoin_net_complete.
2035 "ray_cs new BSSID = %02x%02x%02x%02x%02x%02x\n",
2036 local->bss_id[0], local->bss_id[1],
2037 local->bss_id[2], local->bss_id[3],
2038 local->bss_id[4], local->bss_id[5]);
2040 authenticate(local);
2043 case ROAMING_INITIATED:
2044 dev_dbg(&link->dev, "ray_cs interrupt roaming initiated\n");
2045 netif_stop_queue(dev);
2046 local->card_status = CARD_DOING_ACQ;
2048 case JAPAN_CALL_SIGN_RXD:
2049 dev_dbg(&link->dev, "ray_cs interrupt japan call sign rx\n");
2053 "ray_cs Unexpected interrupt for RCS 0x%x cmd = 0x%x\n",
2055 (unsigned int)readb(&prcs->interrupt_id));
2058 writeb(CCS_BUFFER_FREE, &prcs->buffer_status);
2060 clear_interrupt(local);
2062 } /* ray_interrupt */
2064 /*===========================================================================*/
2065 static void ray_rx(struct net_device *dev, ray_dev_t *local,
2066 struct rcs __iomem *prcs)
2069 unsigned int pkt_addr;
2071 pr_debug("ray_rx process rx packet\n");
2073 /* Calculate address of packet within Rx buffer */
2074 pkt_addr = ((readb(&prcs->var.rx_packet.rx_data_ptr[0]) << 8)
2075 + readb(&prcs->var.rx_packet.rx_data_ptr[1])) & RX_BUFF_END;
2076 /* Length of first packet fragment */
2077 rx_len = (readb(&prcs->var.rx_packet.rx_data_length[0]) << 8)
2078 + readb(&prcs->var.rx_packet.rx_data_length[1]);
2080 local->last_rsl = readb(&prcs->var.rx_packet.rx_sig_lev);
2081 pmsg = local->rmem + pkt_addr;
2082 switch (readb(pmsg)) {
2084 pr_debug("ray_rx data type\n");
2085 rx_data(dev, prcs, pkt_addr, rx_len);
2087 case AUTHENTIC_TYPE:
2088 pr_debug("ray_rx authentic type\n");
2090 rx_data(dev, prcs, pkt_addr, rx_len);
2092 rx_authenticate(local, prcs, pkt_addr, rx_len);
2094 case DEAUTHENTIC_TYPE:
2095 pr_debug("ray_rx deauth type\n");
2097 rx_data(dev, prcs, pkt_addr, rx_len);
2099 rx_deauthenticate(local, prcs, pkt_addr, rx_len);
2102 pr_debug("ray_cs rx NULL msg\n");
2105 pr_debug("ray_rx beacon type\n");
2107 rx_data(dev, prcs, pkt_addr, rx_len);
2109 copy_from_rx_buff(local, (UCHAR *) &local->last_bcn, pkt_addr,
2110 rx_len < sizeof(struct beacon_rx) ?
2111 rx_len : sizeof(struct beacon_rx));
2113 local->beacon_rxed = 1;
2114 /* Get the statistics so the card counters never overflow */
2118 pr_debug("ray_cs unknown pkt type %2x\n",
2119 (unsigned int)readb(pmsg));
2125 /*===========================================================================*/
2126 static void rx_data(struct net_device *dev, struct rcs __iomem *prcs,
2127 unsigned int pkt_addr, int rx_len)
2129 struct sk_buff *skb = NULL;
2130 struct rcs __iomem *prcslink = prcs;
2131 ray_dev_t *local = netdev_priv(dev);
2136 int siglev = local->last_rsl;
2137 u_char linksrcaddr[ETH_ALEN]; /* Other end of the wireless link */
2142 /* TBD length needs fixing for translated header */
2143 if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
2145 (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
2148 "ray_cs invalid packet length %d received\n",
2152 } else { /* encapsulated ethernet */
2154 if (rx_len < (ETH_HLEN + RX_MAC_HEADER_LENGTH) ||
2156 (dev->mtu + RX_MAC_HEADER_LENGTH + ETH_HLEN +
2159 "ray_cs invalid packet length %d received\n",
2165 pr_debug("ray_cs rx_data packet\n");
2166 /* If fragmented packet, verify sizes of fragments add up */
2167 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
2168 pr_debug("ray_cs rx'ed fragment\n");
2169 tmp = (readb(&prcs->var.rx_packet.totalpacketlength[0]) << 8)
2170 + readb(&prcs->var.rx_packet.totalpacketlength[1]);
2175 (readb(&prcslink->var.rx_packet.rx_data_length[0])
2177 + readb(&prcslink->var.rx_packet.rx_data_length[1]);
2178 if (readb(&prcslink->var.rx_packet.next_frag_rcs_index)
2181 prcslink = rcs_base(local)
2182 + readb(&prcslink->link_field);
2187 "ray_cs rx_data fragment lengths don't add up\n");
2188 local->stats.rx_dropped++;
2189 release_frag_chain(local, prcs);
2192 } else { /* Single unfragmented packet */
2196 skb = dev_alloc_skb(total_len + 5);
2198 pr_debug("ray_cs rx_data could not allocate skb\n");
2199 local->stats.rx_dropped++;
2200 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF)
2201 release_frag_chain(local, prcs);
2204 skb_reserve(skb, 2); /* Align IP on 16 byte (TBD check this) */
2206 pr_debug("ray_cs rx_data total_len = %x, rx_len = %x\n", total_len,
2209 /************************/
2210 /* Reserve enough room for the whole damn packet. */
2211 rx_ptr = skb_put(skb, total_len);
2212 /* Copy the whole packet to sk_buff */
2214 copy_from_rx_buff(local, rx_ptr, pkt_addr & RX_BUFF_END, rx_len);
2215 /* Get source address */
2217 skb_copy_from_linear_data_offset(skb,
2218 offsetof(struct mac_header, addr_2),
2219 linksrcaddr, ETH_ALEN);
2221 /* Now, deal with encapsulation/translation/sniffer */
2224 /* Encapsulated ethernet, so just lop off 802.11 MAC header */
2225 /* TBD reserve skb_reserve( skb, RX_MAC_HEADER_LENGTH); */
2226 skb_pull(skb, RX_MAC_HEADER_LENGTH);
2228 /* Do translation */
2229 untranslate(local, skb, total_len);
2231 } else { /* sniffer mode, so just pass whole packet */
2234 /************************/
2235 /* Now pick up the rest of the fragments if any */
2237 if (readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
2239 pr_debug("ray_cs rx_data in fragment loop\n");
2241 prcslink = rcs_base(local)
2243 readb(&prcslink->var.rx_packet.next_frag_rcs_index);
2245 ((readb(&prcslink->var.rx_packet.rx_data_length[0])
2248 readb(&prcslink->var.rx_packet.rx_data_length[1]))
2251 ((readb(&prcslink->var.rx_packet.rx_data_ptr[0]) <<
2253 + readb(&prcslink->var.rx_packet.rx_data_ptr[1]))
2257 copy_from_rx_buff(local, rx_ptr, pkt_addr, rx_len);
2260 readb(&prcslink->var.rx_packet.next_frag_rcs_index) !=
2262 release_frag_chain(local, prcs);
2265 skb->protocol = eth_type_trans(skb, dev);
2267 local->stats.rx_packets++;
2268 local->stats.rx_bytes += total_len;
2270 /* Gather signal strength per address */
2272 /* For the Access Point or the node having started the ad-hoc net
2273 * note : ad-hoc work only in some specific configurations, but we
2274 * kludge in ray_get_wireless_stats... */
2275 if (!memcmp(linksrcaddr, local->bss_id, ETH_ALEN)) {
2276 /* Update statistics */
2277 /*local->wstats.qual.qual = none ? */
2278 local->wstats.qual.level = siglev;
2279 /*local->wstats.qual.noise = none ? */
2280 local->wstats.qual.updated = 0x2;
2282 /* Now, update the spy stuff */
2284 struct iw_quality wstats;
2285 wstats.level = siglev;
2286 /* wstats.noise = none ? */
2287 /* wstats.qual = none ? */
2288 wstats.updated = 0x2;
2289 /* Update spy records */
2290 wireless_spy_update(dev, linksrcaddr, &wstats);
2292 #endif /* WIRELESS_SPY */
2295 /*===========================================================================*/
2296 static void untranslate(ray_dev_t *local, struct sk_buff *skb, int len)
2298 snaphdr_t *psnap = (snaphdr_t *) (skb->data + RX_MAC_HEADER_LENGTH);
2299 struct ieee80211_hdr *pmac = (struct ieee80211_hdr *)skb->data;
2300 __be16 type = *(__be16 *) psnap->ethertype;
2302 struct ethhdr *peth;
2303 UCHAR srcaddr[ADDRLEN];
2304 UCHAR destaddr[ADDRLEN];
2305 static UCHAR org_bridge[3] = { 0, 0, 0xf8 };
2306 static UCHAR org_1042[3] = { 0, 0, 0 };
2308 memcpy(destaddr, ieee80211_get_DA(pmac), ADDRLEN);
2309 memcpy(srcaddr, ieee80211_get_SA(pmac), ADDRLEN);
2313 print_hex_dump(KERN_DEBUG, "skb->data before untranslate: ",
2314 DUMP_PREFIX_NONE, 16, 1,
2315 skb->data, 64, true);
2317 "type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n",
2318 ntohs(type), psnap->dsap, psnap->ssap, psnap->ctrl,
2319 psnap->org[0], psnap->org[1], psnap->org[2]);
2320 printk(KERN_DEBUG "untranslate skb->data = %p\n", skb->data);
2324 if (psnap->dsap != 0xaa || psnap->ssap != 0xaa || psnap->ctrl != 3) {
2325 /* not a snap type so leave it alone */
2326 pr_debug("ray_cs untranslate NOT SNAP %02x %02x %02x\n",
2327 psnap->dsap, psnap->ssap, psnap->ctrl);
2329 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
2330 peth = (struct ethhdr *)(skb->data + delta);
2331 peth->h_proto = htons(len - RX_MAC_HEADER_LENGTH);
2332 } else { /* Its a SNAP */
2333 if (memcmp(psnap->org, org_bridge, 3) == 0) {
2334 /* EtherII and nuke the LLC */
2335 pr_debug("ray_cs untranslate Bridge encap\n");
2336 delta = RX_MAC_HEADER_LENGTH
2337 + sizeof(struct snaphdr_t) - ETH_HLEN;
2338 peth = (struct ethhdr *)(skb->data + delta);
2339 peth->h_proto = type;
2340 } else if (memcmp(psnap->org, org_1042, 3) == 0) {
2341 switch (ntohs(type)) {
2344 pr_debug("ray_cs untranslate RFC IPX/AARP\n");
2345 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
2346 peth = (struct ethhdr *)(skb->data + delta);
2348 htons(len - RX_MAC_HEADER_LENGTH);
2351 pr_debug("ray_cs untranslate RFC default\n");
2352 delta = RX_MAC_HEADER_LENGTH +
2353 sizeof(struct snaphdr_t) - ETH_HLEN;
2354 peth = (struct ethhdr *)(skb->data + delta);
2355 peth->h_proto = type;
2359 printk("ray_cs untranslate very confused by packet\n");
2360 delta = RX_MAC_HEADER_LENGTH - ETH_HLEN;
2361 peth = (struct ethhdr *)(skb->data + delta);
2362 peth->h_proto = type;
2365 /* TBD reserve skb_reserve(skb, delta); */
2366 skb_pull(skb, delta);
2367 pr_debug("untranslate after skb_pull(%d), skb->data = %p\n", delta,
2369 memcpy(peth->h_dest, destaddr, ADDRLEN);
2370 memcpy(peth->h_source, srcaddr, ADDRLEN);
2374 printk(KERN_DEBUG "skb->data after untranslate:");
2375 for (i = 0; i < 64; i++)
2376 printk("%02x ", skb->data[i]);
2380 } /* end untranslate */
2382 /*===========================================================================*/
2383 /* Copy data from circular receive buffer to PC memory.
2384 * dest = destination address in PC memory
2385 * pkt_addr = source address in receive buffer
2386 * len = length of packet to copy
2388 static int copy_from_rx_buff(ray_dev_t *local, UCHAR *dest, int pkt_addr,
2391 int wrap_bytes = (pkt_addr + length) - (RX_BUFF_END + 1);
2392 if (wrap_bytes <= 0) {
2393 memcpy_fromio(dest, local->rmem + pkt_addr, length);
2394 } else { /* Packet wrapped in circular buffer */
2396 memcpy_fromio(dest, local->rmem + pkt_addr,
2397 length - wrap_bytes);
2398 memcpy_fromio(dest + length - wrap_bytes, local->rmem,
2404 /*===========================================================================*/
2405 static void release_frag_chain(ray_dev_t *local, struct rcs __iomem *prcs)
2407 struct rcs __iomem *prcslink = prcs;
2409 unsigned rcsindex = readb(&prcs->var.rx_packet.next_frag_rcs_index);
2412 writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
2413 if (rcsindex >= (NUMBER_OF_CCS + NUMBER_OF_RCS)) {
2414 pr_debug("ray_cs interrupt bad rcsindex = 0x%x\n",
2418 prcslink = rcs_base(local) + rcsindex;
2419 rcsindex = readb(&prcslink->var.rx_packet.next_frag_rcs_index);
2421 writeb(CCS_BUFFER_FREE, &prcslink->buffer_status);
2424 /*===========================================================================*/
2425 static void authenticate(ray_dev_t *local)
2427 struct pcmcia_device *link = local->finder;
2428 dev_dbg(&link->dev, "ray_cs Starting authentication.\n");
2429 if (!(pcmcia_dev_present(link))) {
2430 dev_dbg(&link->dev, "ray_cs authenticate - device not present\n");
2434 del_timer(&local->timer);
2435 if (build_auth_frame(local, local->bss_id, OPEN_AUTH_REQUEST)) {
2436 local->timer.function = &join_net;
2438 local->timer.function = &authenticate_timeout;
2440 local->timer.expires = jiffies + HZ * 2;
2441 local->timer.data = (long)local;
2442 add_timer(&local->timer);
2443 local->authentication_state = AWAITING_RESPONSE;
2444 } /* end authenticate */
2446 /*===========================================================================*/
2447 static void rx_authenticate(ray_dev_t *local, struct rcs __iomem *prcs,
2448 unsigned int pkt_addr, int rx_len)
2451 struct rx_msg *msg = (struct rx_msg *)buff;
2453 del_timer(&local->timer);
2455 copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
2456 /* if we are trying to get authenticated */
2457 if (local->sparm.b4.a_network_type == ADHOC) {
2458 pr_debug("ray_cs rx_auth var= %02x %02x %02x %02x %02x %02x\n",
2459 msg->var[0], msg->var[1], msg->var[2], msg->var[3],
2460 msg->var[4], msg->var[5]);
2461 if (msg->var[2] == 1) {
2462 pr_debug("ray_cs Sending authentication response.\n");
2463 if (!build_auth_frame
2464 (local, msg->mac.addr_2, OPEN_AUTH_RESPONSE)) {
2465 local->authentication_state = NEED_TO_AUTH;
2466 memcpy(local->auth_id, msg->mac.addr_2,
2470 } else { /* Infrastructure network */
2472 if (local->authentication_state == AWAITING_RESPONSE) {
2473 /* Verify authentication sequence #2 and success */
2474 if (msg->var[2] == 2) {
2475 if ((msg->var[3] | msg->var[4]) == 0) {
2476 pr_debug("Authentication successful\n");
2477 local->card_status = CARD_AUTH_COMPLETE;
2479 local->authentication_state =
2482 pr_debug("Authentication refused\n");
2483 local->card_status = CARD_AUTH_REFUSED;
2484 join_net((u_long) local);
2485 local->authentication_state =
2492 } /* end rx_authenticate */
2494 /*===========================================================================*/
2495 static void associate(ray_dev_t *local)
2497 struct ccs __iomem *pccs;
2498 struct pcmcia_device *link = local->finder;
2499 struct net_device *dev = link->priv;
2501 if (!(pcmcia_dev_present(link))) {
2502 dev_dbg(&link->dev, "ray_cs associate - device not present\n");
2505 /* If no tx buffers available, return */
2506 if ((ccsindex = get_free_ccs(local)) < 0) {
2507 /* TBD should never be here but... what if we are? */
2508 dev_dbg(&link->dev, "ray_cs associate - No free ccs\n");
2511 dev_dbg(&link->dev, "ray_cs Starting association with access point\n");
2512 pccs = ccs_base(local) + ccsindex;
2513 /* fill in the CCS */
2514 writeb(CCS_START_ASSOCIATION, &pccs->cmd);
2515 /* Interrupt the firmware to process the command */
2516 if (interrupt_ecf(local, ccsindex)) {
2517 dev_dbg(&link->dev, "ray_cs associate failed - ECF not ready for intr\n");
2518 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
2520 del_timer(&local->timer);
2521 local->timer.expires = jiffies + HZ * 2;
2522 local->timer.data = (long)local;
2523 local->timer.function = &join_net;
2524 add_timer(&local->timer);
2525 local->card_status = CARD_ASSOC_FAILED;
2529 netif_start_queue(dev);
2531 } /* end associate */
2533 /*===========================================================================*/
2534 static void rx_deauthenticate(ray_dev_t *local, struct rcs __iomem *prcs,
2535 unsigned int pkt_addr, int rx_len)
2538 struct rx_msg *msg = (struct rx_msg *)buff;
2540 pr_debug("Deauthentication frame received\n");
2541 local->authentication_state = UNAUTHENTICATED;
2542 /* Need to reauthenticate or rejoin depending on reason code */
2543 /* copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
2547 /*===========================================================================*/
2548 static void clear_interrupt(ray_dev_t *local)
2550 writeb(0, local->amem + CIS_OFFSET + HCS_INTR_OFFSET);
2553 /*===========================================================================*/
2554 #ifdef CONFIG_PROC_FS
2555 #define MAXDATA (PAGE_SIZE - 80)
2557 static char *card_status[] = {
2558 "Card inserted - uninitialized", /* 0 */
2559 "Card not downloaded", /* 1 */
2560 "Waiting for download parameters", /* 2 */
2561 "Card doing acquisition", /* 3 */
2562 "Acquisition complete", /* 4 */
2563 "Authentication complete", /* 5 */
2564 "Association complete", /* 6 */
2565 "???", "???", "???", "???", /* 7 8 9 10 undefined */
2566 "Card init error", /* 11 */
2567 "Download parameters error", /* 12 */
2569 "Acquisition failed", /* 14 */
2570 "Authentication refused", /* 15 */
2571 "Association failed" /* 16 */
2574 static char *nettype[] = { "Adhoc", "Infra " };
2575 static char *framing[] = { "Encapsulation", "Translation" }
2578 /*===========================================================================*/
2579 static int ray_cs_proc_show(struct seq_file *m, void *v)
2581 /* Print current values which are not available via other means
2585 struct pcmcia_device *link;
2586 struct net_device *dev;
2589 struct freq_hop_element *pfh;
2595 dev = (struct net_device *)link->priv;
2598 local = netdev_priv(dev);
2602 seq_puts(m, "Raylink Wireless LAN driver status\n");
2603 seq_printf(m, "%s\n", rcsid);
2604 /* build 4 does not report version, and field is 0x55 after memtest */
2605 seq_puts(m, "Firmware version = ");
2606 if (local->fw_ver == 0x55)
2607 seq_puts(m, "4 - Use dump_cis for more details\n");
2609 seq_printf(m, "%2d.%02d.%02d\n",
2610 local->fw_ver, local->fw_bld, local->fw_var);
2612 for (i = 0; i < 32; i++)
2613 c[i] = local->sparm.b5.a_current_ess_id[i];
2615 seq_printf(m, "%s network ESSID = \"%s\"\n",
2616 nettype[local->sparm.b5.a_network_type], c);
2619 seq_printf(m, "BSSID = %pM\n", p);
2621 seq_printf(m, "Country code = %d\n",
2622 local->sparm.b5.a_curr_country_code);
2624 i = local->card_status;
2629 seq_printf(m, "Card status = %s\n", card_status[i]);
2631 seq_printf(m, "Framing mode = %s\n", framing[translate]);
2633 seq_printf(m, "Last pkt signal lvl = %d\n", local->last_rsl);
2635 if (local->beacon_rxed) {
2636 /* Pull some fields out of last beacon received */
2637 seq_printf(m, "Beacon Interval = %d Kus\n",
2638 local->last_bcn.beacon_intvl[0]
2639 + 256 * local->last_bcn.beacon_intvl[1]);
2641 p = local->last_bcn.elements;
2642 if (p[0] == C_ESSID_ELEMENT_ID)
2646 "Parse beacon failed at essid element id = %d\n",
2651 if (p[0] == C_SUPPORTED_RATES_ELEMENT_ID) {
2652 seq_puts(m, "Supported rate codes = ");
2653 for (i = 2; i < p[1] + 2; i++)
2654 seq_printf(m, "0x%02x ", p[i]);
2658 seq_puts(m, "Parse beacon failed at rates element\n");
2662 if (p[0] == C_FH_PARAM_SET_ELEMENT_ID) {
2663 pfh = (struct freq_hop_element *)p;
2664 seq_printf(m, "Hop dwell = %d Kus\n",
2665 pfh->dwell_time[0] +
2666 256 * pfh->dwell_time[1]);
2667 seq_printf(m, "Hop set = %d\n",
2669 seq_printf(m, "Hop pattern = %d\n",
2671 seq_printf(m, "Hop index = %d\n",
2676 "Parse beacon failed at FH param element\n");
2680 seq_puts(m, "No beacons received\n");
2685 static int ray_cs_proc_open(struct inode *inode, struct file *file)
2687 return single_open(file, ray_cs_proc_show, NULL);
2690 static const struct file_operations ray_cs_proc_fops = {
2691 .owner = THIS_MODULE,
2692 .open = ray_cs_proc_open,
2694 .llseek = seq_lseek,
2695 .release = single_release,
2698 /*===========================================================================*/
2699 static int build_auth_frame(ray_dev_t *local, UCHAR *dest, int auth_type)
2702 struct ccs __iomem *pccs;
2703 struct tx_msg __iomem *ptx;
2706 /* If no tx buffers available, return */
2707 if ((ccsindex = get_free_tx_ccs(local)) < 0) {
2708 pr_debug("ray_cs send authenticate - No free tx ccs\n");
2712 pccs = ccs_base(local) + ccsindex;
2714 /* Address in card space */
2715 addr = TX_BUF_BASE + (ccsindex << 11);
2716 /* fill in the CCS */
2717 writeb(CCS_TX_REQUEST, &pccs->cmd);
2718 writeb(addr >> 8, pccs->var.tx_request.tx_data_ptr);
2719 writeb(0x20, pccs->var.tx_request.tx_data_ptr + 1);
2720 writeb(TX_AUTHENTICATE_LENGTH_MSB, pccs->var.tx_request.tx_data_length);
2721 writeb(TX_AUTHENTICATE_LENGTH_LSB,
2722 pccs->var.tx_request.tx_data_length + 1);
2723 writeb(0, &pccs->var.tx_request.pow_sav_mode);
2725 ptx = local->sram + addr;
2726 /* fill in the mac header */
2727 writeb(PROTOCOL_VER | AUTHENTIC_TYPE, &ptx->mac.frame_ctl_1);
2728 writeb(0, &ptx->mac.frame_ctl_2);
2730 memcpy_toio(ptx->mac.addr_1, dest, ADDRLEN);
2731 memcpy_toio(ptx->mac.addr_2, local->sparm.b4.a_mac_addr, ADDRLEN);
2732 memcpy_toio(ptx->mac.addr_3, local->bss_id, ADDRLEN);
2734 /* Fill in msg body with protocol 00 00, sequence 01 00 ,status 00 00 */
2735 memset_io(ptx->var, 0, 6);
2736 writeb(auth_type & 0xff, ptx->var + 2);
2738 /* Interrupt the firmware to process the command */
2739 if (interrupt_ecf(local, ccsindex)) {
2741 "ray_cs send authentication request failed - ECF not ready for intr\n");
2742 writeb(CCS_BUFFER_FREE, &(pccs++)->buffer_status);
2746 } /* End build_auth_frame */
2748 /*===========================================================================*/
2749 #ifdef CONFIG_PROC_FS
2750 static ssize_t ray_cs_essid_proc_write(struct file *file,
2751 const char __user *buffer, size_t count, loff_t *pos)
2753 static char proc_essid[33];
2754 unsigned int len = count;
2758 memset(proc_essid, 0, 33);
2759 if (copy_from_user(proc_essid, buffer, len))
2765 static const struct file_operations ray_cs_essid_proc_fops = {
2766 .owner = THIS_MODULE,
2767 .write = ray_cs_essid_proc_write,
2768 .llseek = noop_llseek,
2771 static ssize_t int_proc_write(struct file *file, const char __user *buffer,
2772 size_t count, loff_t *pos)
2774 static char proc_number[10];
2783 if (copy_from_user(proc_number, buffer, count))
2789 unsigned int c = *p - '0';
2795 *(int *)PDE(file->f_path.dentry->d_inode)->data = nr;
2799 static const struct file_operations int_proc_fops = {
2800 .owner = THIS_MODULE,
2801 .write = int_proc_write,
2802 .llseek = noop_llseek,
2806 static struct pcmcia_device_id ray_ids[] = {
2807 PCMCIA_DEVICE_MANF_CARD(0x01a6, 0x0000),
2811 MODULE_DEVICE_TABLE(pcmcia, ray_ids);
2813 static struct pcmcia_driver ray_driver = {
2814 .owner = THIS_MODULE,
2817 .remove = ray_detach,
2818 .id_table = ray_ids,
2819 .suspend = ray_suspend,
2820 .resume = ray_resume,
2823 static int __init init_ray_cs(void)
2827 pr_debug("%s\n", rcsid);
2828 rc = pcmcia_register_driver(&ray_driver);
2829 pr_debug("raylink init_module register_pcmcia_driver returns 0x%x\n",
2832 #ifdef CONFIG_PROC_FS
2833 proc_mkdir("driver/ray_cs", NULL);
2835 proc_create("driver/ray_cs/ray_cs", 0, NULL, &ray_cs_proc_fops);
2836 proc_create("driver/ray_cs/essid", S_IWUSR, NULL, &ray_cs_essid_proc_fops);
2837 proc_create_data("driver/ray_cs/net_type", S_IWUSR, NULL, &int_proc_fops, &net_type);
2838 proc_create_data("driver/ray_cs/translate", S_IWUSR, NULL, &int_proc_fops, &translate);
2845 /*===========================================================================*/
2847 static void __exit exit_ray_cs(void)
2849 pr_debug("ray_cs: cleanup_module\n");
2851 #ifdef CONFIG_PROC_FS
2852 remove_proc_entry("driver/ray_cs/ray_cs", NULL);
2853 remove_proc_entry("driver/ray_cs/essid", NULL);
2854 remove_proc_entry("driver/ray_cs/net_type", NULL);
2855 remove_proc_entry("driver/ray_cs/translate", NULL);
2856 remove_proc_entry("driver/ray_cs", NULL);
2859 pcmcia_unregister_driver(&ray_driver);
2862 module_init(init_ray_cs);
2863 module_exit(exit_ray_cs);
2865 /*===========================================================================*/