33 #include <linux/module.h>
34 #include <linux/kernel.h>
36 #include <linux/ptrace.h>
38 #include <linux/string.h>
41 #include <linux/netdevice.h>
43 #include <linux/if_arp.h>
52 #include <linux/wireless.h>
56 #include <asm/byteorder.h>
57 #include <asm/uaccess.h>
70 static int ray_config(
struct pcmcia_device *
link);
71 static void ray_release(
struct pcmcia_device *
link);
72 static void ray_detach(
struct pcmcia_device *p_dev);
84 static void ray_update_multi_list(
struct net_device *
dev,
int all);
86 unsigned char *
data,
int len);
94 static void authenticate(
ray_dev_t *local);
96 static void authenticate_timeout(
u_long);
97 static int get_free_ccs(
ray_dev_t *local);
98 static int get_free_tx_ccs(
ray_dev_t *local);
99 static void init_startup_params(
ray_dev_t *local);
100 static int parse_addr(
char *in_str,
UCHAR *
out);
106 static void verify_dl_startup(
u_long);
110 static void clear_interrupt(
ray_dev_t *local);
112 unsigned int pkt_addr,
int rx_len);
117 unsigned int pkt_addr,
int rx_len);
119 unsigned int pkt_addr,
int rx_len);
124 static void join_net(
u_long local);
125 static void start_net(
u_long local);
132 static int net_type =
ADHOC;
135 static int hop_dwell = 128;
138 static int beacon_period = 256;
147 static int translate = 1;
165 static char *phy_addr =
NULL;
167 static unsigned int ray_mem_speed = 500;
170 static struct pcmcia_device *this_device =
NULL;
188 static const UCHAR b5_default_startup_parms[] = {
190 'L',
'I',
'N',
'U',
'X', 0, 0, 0,
191 0, 0, 0, 0, 0, 0, 0, 0,
192 0, 0, 0, 0, 0, 0, 0, 0,
193 0, 0, 0, 0, 0, 0, 0, 0,
202 0x04, 0xe2, 0x38, 0xA4,
220 2, 0, 0, 0, 0, 0, 0, 0
223 static const UCHAR b4_default_startup_parms[] = {
225 'L',
'I',
'N',
'U',
'X', 0, 0, 0,
226 0, 0, 0, 0, 0, 0, 0, 0,
227 0, 0, 0, 0, 0, 0, 0, 0,
228 0, 0, 0, 0, 0, 0, 0, 0,
237 0xfb, 0x1e, 0xc7, 0x5c,
255 static const u8 eth2_llc[] = { 0xaa, 0xaa, 3, 0, 0, 0 };
257 static const char hop_pattern_length[] = { 1,
265 static const char rcsid[] =
269 .ndo_init = ray_dev_init,
270 .ndo_open = ray_open,
271 .ndo_stop = ray_dev_close,
272 .ndo_start_xmit = ray_dev_start_xmit,
273 .ndo_set_config = ray_dev_config,
274 .ndo_get_stats = ray_get_stats,
275 .ndo_set_rx_mode = set_multicast_list,
281 static int ray_probe(
struct pcmcia_device *p_dev)
286 dev_dbg(&p_dev->dev,
"ray_attach()\n");
293 local = netdev_priv(dev);
297 p_dev->resource[0]->end = 0;
298 p_dev->resource[0]->flags |= IO_DATA_PATH_WIDTH_8;
301 p_dev->config_flags |= CONF_ENABLE_IRQ;
302 p_dev->config_index = 1;
310 dev_dbg(&p_dev->dev,
"ray_attach p_dev = %p, dev = %p, local = %p, intr = %p\n",
311 p_dev, dev, local, &ray_interrupt);
315 dev->wireless_handlers = &ray_handler_def;
317 local->wireless_data.spy_data = &local->spy_data;
318 dev->wireless_data = &local->wireless_data;
322 dev_dbg(&p_dev->dev,
"ray_cs ray_attach calling ether_setup.)\n");
323 netif_stop_queue(dev);
328 return ray_config(p_dev);
334 static void ray_detach(
struct pcmcia_device *
link)
339 dev_dbg(&link->dev,
"ray_detach\n");
346 local = netdev_priv(dev);
353 dev_dbg(&link->dev,
"ray_cs ray_detach ending\n");
356 #define MAX_TUPLE_SIZE 128
357 static int ray_config(
struct pcmcia_device *link)
364 dev_dbg(&link->dev,
"ray_config\n");
368 link->prod_id[0] ? link->prod_id[0] :
" ",
369 link->prod_id[1] ? link->prod_id[1] :
" ",
370 link->prod_id[2] ? link->prod_id[2] :
" ",
371 link->prod_id[3] ? link->prod_id[3] :
" ");
379 dev->
irq = link->irq;
386 link->resource[2]->flags |= WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM |
WIN_ENABLE | WIN_USE_WAIT;
387 link->resource[2]->start = 0;
388 link->resource[2]->end = 0x8000;
396 resource_size(link->resource[2]));
399 link->resource[3]->flags |=
400 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_CM |
WIN_ENABLE | WIN_USE_WAIT;
401 link->resource[3]->start = 0;
402 link->resource[3]->end = 0x4000;
410 resource_size(link->resource[3]));
413 link->resource[4]->flags |=
414 WIN_DATA_WIDTH_8 | WIN_MEMORY_TYPE_AM |
WIN_ENABLE | WIN_USE_WAIT;
415 link->resource[4]->start = 0;
416 link->resource[4]->end = 0x1000;
424 resource_size(link->resource[4]));
426 dev_dbg(&link->dev,
"ray_config sram=%p\n", local->
sram);
427 dev_dbg(&link->dev,
"ray_config rmem=%p\n", local->
rmem);
428 dev_dbg(&link->dev,
"ray_config amem=%p\n", local->
amem);
429 if (ray_init(dev) < 0) {
437 printk(
"ray_config register_netdev() failed\n");
476 struct pcmcia_device *link = local->
finder;
477 dev_dbg(&link->dev,
"ray_init(0x%p)\n", dev);
479 dev_dbg(&link->dev,
"ray_init - device not present\n");
501 dev_dbg(&link->dev,
"ray_init firmware version %d.%d\n", local->
fw_ver,
509 pccs = ccs_base(local);
513 init_startup_params(local);
516 if (parse_addr(phy_addr, local->
sparm.
b4.a_mac_addr)) {
517 p = local->
sparm.
b4.a_mac_addr;
521 p = local->
sparm.
b4.a_mac_addr;
524 clear_interrupt(local);
526 dev_dbg(&link->dev,
"ray_init ending\n");
532 static int dl_startup_params(
struct net_device *dev)
537 struct pcmcia_device *link = local->
finder;
539 dev_dbg(&link->dev,
"dl_startup_params entered\n");
541 dev_dbg(&link->dev,
"ray_cs dl_startup_params - device not present\n");
546 if (local->
fw_ver == 0x55)
554 if ((ccsindex = get_free_ccs(local)) < 0)
557 pccs = ccs_base(local) + ccsindex;
559 dev_dbg(&link->dev,
"dl_startup_params start ccsindex = %d\n",
562 if (interrupt_ecf(local, ccsindex)) {
564 "ECF not ready for intr\n");
573 local->
timer.function = verify_dl_startup;
576 "ray_cs dl_startup_params started timer for verify_dl_startup\n");
581 static void init_startup_params(
ray_dev_t *local)
601 if (local->
fw_ver == 0x55) {
606 i = (hop_dwell * 1024) & 0xffffff;
607 local->
sparm.
b4.a_hop_time[0] = (i >> 16) & 0xff;
608 local->
sparm.
b4.a_hop_time[1] = (i >> 8) & 0xff;
609 local->
sparm.
b4.a_beacon_period[0] = 0;
610 local->
sparm.
b4.a_beacon_period[1] =
611 ((beacon_period / hop_dwell) - 1) & 0xff;
613 local->
sparm.
b4.a_hop_pattern_length =
616 local->
sparm.
b4.a_ack_timeout = 0x50;
623 local->
sparm.
b5.a_hop_time[0] = (hop_dwell >> 8) & 0xff;
624 local->
sparm.
b5.a_hop_time[1] = hop_dwell & 0xff;
625 local->
sparm.
b5.a_beacon_period[0] =
626 (beacon_period >> 8) & 0xff;
627 local->
sparm.
b5.a_beacon_period[1] = beacon_period & 0xff;
629 local->
sparm.
b5.a_power_mgt_state = 1;
631 local->
sparm.
b5.a_hop_pattern_length =
635 local->
sparm.
b4.a_network_type = net_type & 0x01;
648 struct pcmcia_device *link = local->
finder;
651 dev_dbg(&link->dev,
"ray_cs verify_dl_startup - device not present\n");
658 "verify_dl_startup parameters sent via ccs %d:\n",
672 "Download startup params failed. Status = %d\n",
678 start_net((
u_long) local);
685 static void start_net(
u_long data)
690 struct pcmcia_device *link = local->
finder;
692 dev_dbg(&link->dev,
"ray_cs start_net - device not present\n");
696 if ((ccsindex = get_free_ccs(local)) < 0)
698 pccs = ccs_base(local) + ccsindex;
702 if (interrupt_ecf(local, ccsindex)) {
703 dev_dbg(&link->dev,
"ray start net failed - card not ready for intr\n");
712 static void join_net(
u_long data)
718 struct pcmcia_device *link = local->
finder;
721 dev_dbg(&link->dev,
"ray_cs join_net - device not present\n");
725 if ((ccsindex = get_free_ccs(local)) < 0)
727 pccs = ccs_base(local) + ccsindex;
732 if (interrupt_ecf(local, ccsindex)) {
733 dev_dbg(&link->dev,
"ray join net failed - card not ready for intr\n");
741 static void ray_release(
struct pcmcia_device *link)
746 dev_dbg(&link->dev,
"ray_release\n");
755 dev_dbg(&link->dev,
"ray_release ending\n");
758 static int ray_suspend(
struct pcmcia_device *link)
768 static int ray_resume(
struct pcmcia_device *link)
781 static int ray_dev_init(
struct net_device *dev)
783 #ifdef RAY_IMMEDIATE_INIT
787 struct pcmcia_device *link = local->
finder;
789 dev_dbg(&link->dev,
"ray_dev_init(dev=%p)\n", dev);
791 dev_dbg(&link->dev,
"ray_dev_init - device not present\n");
794 #ifdef RAY_IMMEDIATE_INIT
796 if ((i = dl_startup_params(dev)) < 0) {
798 "returns 0x%x\n", i);
806 "ray_dev_init: postponing card init to ray_open() ; Status = %d\n",
814 dev_dbg(&link->dev,
"ray_dev_init ending\n");
822 struct pcmcia_device *link = local->
finder;
824 dev_dbg(&link->dev,
"ray_dev_config(dev=%p,ifmap=%p)\n", dev, map);
826 dev_dbg(&link->dev,
"ray_dev_config - device not present\n");
838 struct pcmcia_device *link = local->
finder;
842 dev_dbg(&link->dev,
"ray_dev_start_xmit - device not present\n");
847 dev_dbg(&link->dev,
"ray_dev_start_xmit(skb=%p, dev=%p)\n", skb, dev);
849 dev_dbg(&link->dev,
"ray_cs Sending authentication request.\n");
852 netif_stop_queue(dev);
865 netif_stop_queue(dev);
878 static int ray_hw_xmit(
unsigned char *data,
int len,
struct net_device *dev,
888 pr_debug(
"ray_hw_xmit(data=%p, len=%d, dev=%p)\n", data, len, dev);
894 switch (ccsindex = get_free_tx_ccs(local)) {
896 pr_debug(
"ray_hw_xmit tx_ccs table busy\n");
898 pr_debug(
"ray_hw_xmit No free tx ccs\n");
900 netif_stop_queue(dev);
909 local->
stats.tx_packets++;
914 ray_build_header(local, ptx, msg_type, data);
916 offset = translate_frame(local, ptx, data, len);
924 pccs = ccs_base(local) + ccsindex;
935 pr_debug(
"ray_hw_xmit default_tx_rate = 0x%x\n",
939 if (interrupt_ecf(local, ccsindex)) {
940 pr_debug(
"ray_hw_xmit failed - ECF not ready for intr\n");
953 unsigned char *data,
int len)
956 if (
ntohs(proto) >= 1536) {
957 pr_debug(
"ray_cs translate_frame DIX II\n");
959 memcpy_toio(&ptx->var, eth2_llc,
sizeof(eth2_llc));
961 (
UCHAR *) &proto, 2);
973 pr_debug(
"ray_cs translate_frame 802\n");
974 if (proto ==
htons(0xffff)) {
975 pr_debug(
"ray_cs translate_frame evil IPX\n");
987 UCHAR msg_type,
unsigned char *data)
998 writeb(0, &ptx->mac.frame_ctl_2);
1004 if (local->
sparm.
b4.a_acting_as_ap_status) {
1087 if (wrqu->
essid.flags == 0)
1116 wrqu->
essid.flags = 1;
1150 if ((wrqu->
bitrate.value != 1000000) && (wrqu->
bitrate.value != 2000000))
1154 if ((local->
fw_ver == 0x55) &&
1155 (wrqu->
bitrate.value == 2000000))
1173 wrqu->
bitrate.value = 2000000;
1189 int rthr = wrqu->
rts.value;
1196 if (wrqu->
rts.disabled)
1199 if ((rthr < 0) || (rthr > 2347))
1202 local->
sparm.
b5.a_rts_threshold[0] = (rthr >> 8) & 0xFF;
1203 local->
sparm.
b5.a_rts_threshold[1] = rthr & 0xFF;
1217 wrqu->
rts.value = (local->
sparm.
b5.a_rts_threshold[0] << 8)
1218 + local->
sparm.
b5.a_rts_threshold[1];
1219 wrqu->
rts.disabled = (wrqu->
rts.value == 32767);
1220 wrqu->
rts.fixed = 1;
1233 int fthr = wrqu->
frag.value;
1240 if (wrqu->
frag.disabled)
1243 if ((fthr < 256) || (fthr > 2347))
1246 local->
sparm.
b5.a_frag_threshold[0] = (fthr >> 8) & 0xFF;
1247 local->
sparm.
b5.a_frag_threshold[1] = fthr & 0xFF;
1261 wrqu->
frag.value = (local->
sparm.
b5.a_frag_threshold[0] << 8)
1262 + local->
sparm.
b5.a_frag_threshold[1];
1263 wrqu->
frag.disabled = (wrqu->
frag.value == 32767);
1264 wrqu->
frag.fixed = 1;
1284 switch (wrqu->
mode) {
1289 local->
sparm.
b5.a_network_type = card_mode;
1307 if (local->
sparm.
b5.a_network_type)
1353 translate = *(
extra);
1365 *(
extra) = translate;
1399 struct pcmcia_device *link = local->
finder;
1404 if ((local->spy_data.spy_number > 0)
1405 && (local->
sparm.
b5.a_network_type == 0)) {
1407 local->
wstats.
qual.qual = local->spy_data.spy_stat[0].qual;
1408 local->
wstats.
qual.level = local->spy_data.spy_stat[0].level;
1409 local->
wstats.
qual.noise = local->spy_data.spy_stat[0].noise;
1411 local->spy_data.spy_stat[0].updated;
1453 #define SIOCSIPFRAMING SIOCIWFIRSTPRIV
1454 #define SIOCGIPFRAMING SIOCIWFIRSTPRIV + 1
1455 #define SIOCGIPCOUNTRY SIOCIWFIRSTPRIV + 3
1457 static const iw_handler ray_private_handler[] = {
1458 [0] = ray_set_framing,
1459 [1] = ray_get_framing,
1460 [3] = ray_get_country,
1463 static const struct iw_priv_args ray_private_args[] = {
1475 .num_private =
ARRAY_SIZE(ray_private_handler),
1476 .num_private_args =
ARRAY_SIZE(ray_private_args),
1477 .standard = ray_handler,
1478 .private = ray_private_handler,
1479 .private_args = ray_private_args,
1480 .get_wireless_stats = ray_get_wireless_stats,
1487 struct pcmcia_device *
link;
1490 dev_dbg(&link->dev,
"ray_open('%s')\n", dev->
name);
1492 if (link->open == 0)
1500 dev_dbg(&link->dev,
"ray_open: doing init now !\n");
1503 if ((i = dl_startup_params(dev)) < 0) {
1505 "ray_dev_init dl_startup_params failed - "
1506 "returns 0x%x\n", i);
1512 netif_stop_queue(dev);
1514 netif_start_queue(dev);
1516 dev_dbg(&link->dev,
"ray_open ending\n");
1521 static int ray_dev_close(
struct net_device *dev)
1524 struct pcmcia_device *
link;
1527 dev_dbg(&link->dev,
"ray_dev_close('%s')\n", dev->
name);
1530 netif_stop_queue(dev);
1541 static void ray_reset(
struct net_device *dev)
1552 struct pcmcia_device *link = local->
finder;
1555 dev_dbg(&link->dev,
"ray_cs interrupt_ecf - device not present\n");
1558 dev_dbg(&link->dev,
"interrupt_ecf(local=%p, ccs = 0x%x\n", local, ccs);
1565 dev_dbg(&link->dev,
"ray_cs interrupt_ecf card not ready for interrupt\n");
1577 static int get_free_tx_ccs(
ray_dev_t *local)
1580 struct ccs
__iomem *pccs = ccs_base(local);
1581 struct pcmcia_device *link = local->
finder;
1584 dev_dbg(&link->dev,
"ray_cs get_free_tx_ccs - device not present\n");
1589 dev_dbg(&link->dev,
"ray_cs tx_ccs_lock busy\n");
1602 dev_dbg(&link->dev,
"ray_cs ERROR no free tx CCS for raylink card\n");
1609 static int get_free_ccs(
ray_dev_t *local)
1612 struct ccs
__iomem *pccs = ccs_base(local);
1613 struct pcmcia_device *link = local->
finder;
1616 dev_dbg(&link->dev,
"ray_cs get_free_ccs - device not present\n");
1620 dev_dbg(&link->dev,
"ray_cs ccs_lock busy\n");
1633 dev_dbg(&link->dev,
"ray_cs ERROR no free CCS for raylink card\n");
1638 static void authenticate_timeout(
u_long data)
1644 join_net((
u_long) local);
1648 static int parse_addr(
char *in_str,
UCHAR *
out)
1656 if ((len =
strlen(in_str)) < 2)
1688 struct pcmcia_device *link = local->
finder;
1691 dev_dbg(&link->dev,
"ray_cs net_device_stats - device not present\n");
1692 return &local->
stats;
1700 local->
stats.rx_crc_errors +=
1710 return &local->
stats;
1718 struct pcmcia_device *link = local->
finder;
1724 dev_dbg(&link->dev,
"ray_update_parm - device not present\n");
1728 if ((ccsindex = get_free_ccs(local)) < 0) {
1729 dev_dbg(&link->dev,
"ray_update_parm - No free ccs\n");
1732 pccs = ccs_base(local) + ccsindex;
1737 for (i = 0; i < len; i++) {
1741 if (interrupt_ecf(local, ccsindex)) {
1742 dev_dbg(&link->dev,
"ray_cs associate failed - ECF not ready for intr\n");
1748 static void ray_update_multi_list(
struct net_device *dev,
int all)
1753 struct pcmcia_device *link = local->
finder;
1757 dev_dbg(&link->dev,
"ray_update_multi_list - device not present\n");
1760 dev_dbg(&link->dev,
"ray_update_multi_list(%p)\n", dev);
1761 if ((ccsindex = get_free_ccs(local)) < 0) {
1762 dev_dbg(&link->dev,
"ray_update_multi - No free ccs\n");
1765 pccs = ccs_base(local) + ccsindex;
1778 dev_dbg(&link->dev,
"ray_update_multi add addr %pm\n",
1786 dev_dbg(&link->dev,
"ray_cs update_multi %d addresses in list\n", i);
1790 if (interrupt_ecf(local, ccsindex)) {
1792 "ray_cs update_multi failed - ECF not ready for intr\n");
1798 static void set_multicast_list(
struct net_device *dev)
1803 pr_debug(
"ray_cs set_multicast_list(%p)\n", dev);
1806 if (local->
sparm.
b5.a_promiscuous_mode == 0) {
1807 pr_debug(
"ray_cs set_multicast_list promisc on\n");
1808 local->
sparm.
b5.a_promiscuous_mode = 1;
1811 &promisc,
sizeof(promisc));
1814 if (local->
sparm.
b5.a_promiscuous_mode == 1) {
1815 pr_debug(
"ray_cs set_multicast_list promisc off\n");
1816 local->
sparm.
b5.a_promiscuous_mode = 0;
1819 &promisc,
sizeof(promisc));
1824 ray_update_multi_list(dev, 1);
1827 ray_update_multi_list(dev, 0);
1837 struct pcmcia_device *
link;
1849 pr_debug(
"ray_cs: interrupt for *dev=%p\n", dev);
1851 local = netdev_priv(dev);
1855 "ray_cs interrupt from device not present or suspended.\n");
1861 dev_dbg(&link->dev,
"ray_cs interrupt bad rcsindex = 0x%x\n", rcsindex);
1862 clear_interrupt(local);
1865 if (rcsindex < NUMBER_OF_CCS) {
1866 pccs = ccs_base(local) + rcsindex;
1874 "ray_cs interrupt download_startup_parameters OK\n");
1877 "ray_cs interrupt download_startup_parameters fail\n");
1881 dev_dbg(&link->dev,
"ray_cs interrupt update params done\n");
1887 "ray_cs interrupt update params failed - reason %d\n",
1892 dev_dbg(&link->dev,
"ray_cs interrupt report params done\n");
1896 "ray_cs interrupt CCS Update Multicast List done\n");
1900 "ray_cs interrupt update power save mode done\n");
1909 "ray_cs interrupt network \"%s\" started\n",
1910 local->
sparm.
b4.a_current_ess_id);
1913 "ray_cs interrupt network \"%s\" joined\n",
1914 local->
sparm.
b4.a_current_ess_id);
1920 if (local->
fw_ver == 0x55)
1925 net_default_tx_rate);
1929 && !(local->
sparm.
b4.a_acting_as_ap_status)) {
1930 authenticate(local);
1941 "ray_cs interrupt network \"%s\" start failed\n",
1942 local->
sparm.
b4.a_current_ess_id);
1943 local->
timer.function = start_net;
1946 "ray_cs interrupt network \"%s\" join failed\n",
1947 local->
sparm.
b4.a_current_ess_id);
1948 local->
timer.function = join_net;
1956 dev_dbg(&link->dev,
"ray_cs association successful\n");
1958 dev_dbg(&link->dev,
"ray_cs association failed,\n");
1960 join_net((
u_long) local);
1966 "ray_cs interrupt tx request complete\n");
1969 "ray_cs interrupt tx request failed\n");
1972 netif_start_queue(dev);
1973 netif_wake_queue(dev);
1976 dev_dbg(&link->dev,
"ray_cs interrupt mem test done\n");
1980 "ray_cs interrupt Unexpected CCS returned - Shutdown\n");
1983 dev_dbg(&link->dev,
"ray_cs interrupt dump memory done\n");
1987 "ray_cs interrupt DING - raylink timer expired\n");
1991 "ray_cs interrupt Unexpected CCS 0x%x returned 0x%x\n",
1997 prcs = rcs_base(local) + rcsindex;
2001 ray_rx(dev, local, prcs);
2004 dev_dbg(&link->dev,
"ray_cs interrupt rejoin net complete\n");
2009 netif_start_queue(dev);
2014 dev_dbg(&link->dev,
"ray_cs new BSSID = %pm\n",
2017 authenticate(local);
2021 dev_dbg(&link->dev,
"ray_cs interrupt roaming initiated\n");
2022 netif_stop_queue(dev);
2026 dev_dbg(&link->dev,
"ray_cs interrupt japan call sign rx\n");
2030 "ray_cs Unexpected interrupt for RCS 0x%x cmd = 0x%x\n",
2037 clear_interrupt(local);
2046 unsigned int pkt_addr;
2048 pr_debug(
"ray_rx process rx packet\n");
2051 pkt_addr = ((
readb(&prcs->var.rx_packet.rx_data_ptr[0]) << 8)
2054 rx_len = (
readb(&prcs->var.rx_packet.rx_data_length[0]) << 8)
2055 +
readb(&prcs->var.rx_packet.rx_data_length[1]);
2058 pmsg = local->
rmem + pkt_addr;
2059 switch (
readb(pmsg)) {
2062 rx_data(dev, prcs, pkt_addr, rx_len);
2065 pr_debug(
"ray_rx authentic type\n");
2067 rx_data(dev, prcs, pkt_addr, rx_len);
2069 rx_authenticate(local, prcs, pkt_addr, rx_len);
2074 rx_data(dev, prcs, pkt_addr, rx_len);
2076 rx_deauthenticate(local, prcs, pkt_addr, rx_len);
2084 rx_data(dev, prcs, pkt_addr, rx_len);
2086 copy_from_rx_buff(local, (
UCHAR *) &local->
last_bcn, pkt_addr,
2095 pr_debug(
"ray_cs unknown pkt type %2x\n",
2096 (
unsigned int)
readb(pmsg));
2104 unsigned int pkt_addr,
int rx_len)
2125 "ray_cs invalid packet length %d received\n",
2136 "ray_cs invalid packet length %d received\n",
2142 pr_debug(
"ray_cs rx_data packet\n");
2144 if (
readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
2145 pr_debug(
"ray_cs rx'ed fragment\n");
2146 tmp = (
readb(&prcs->var.rx_packet.totalpacketlength[0]) << 8)
2147 +
readb(&prcs->var.rx_packet.totalpacketlength[1]);
2158 prcslink = rcs_base(local)
2164 "ray_cs rx_data fragment lengths don't add up\n");
2165 local->
stats.rx_dropped++;
2166 release_frag_chain(local, prcs);
2173 skb = dev_alloc_skb(total_len + 5);
2175 pr_debug(
"ray_cs rx_data could not allocate skb\n");
2176 local->
stats.rx_dropped++;
2177 if (
readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF)
2178 release_frag_chain(local, prcs);
2181 skb_reserve(skb, 2);
2183 pr_debug(
"ray_cs rx_data total_len = %x, rx_len = %x\n", total_len,
2188 rx_ptr =
skb_put(skb, total_len);
2191 copy_from_rx_buff(local, rx_ptr, pkt_addr &
RX_BUFF_END, rx_len);
2194 skb_copy_from_linear_data_offset(skb,
2206 untranslate(local, skb, total_len);
2214 if (
readb(&prcs->var.rx_packet.next_frag_rcs_index) != 0xFF) {
2216 pr_debug(
"ray_cs rx_data in fragment loop\n");
2218 prcslink = rcs_base(local)
2234 copy_from_rx_buff(local, rx_ptr, pkt_addr, rx_len);
2239 release_frag_chain(local, prcs);
2244 local->
stats.rx_packets++;
2262 wstats.
level = siglev;
2265 wstats.updated = 0x2;
2282 static const UCHAR org_bridge[3] = { 0, 0, 0xf8 };
2283 static const UCHAR org_1042[3] = { 0, 0, 0 };
2290 print_hex_dump(
KERN_DEBUG,
"skb->data before untranslate: ",
2292 skb->
data, 64,
true);
2294 "type = %08x, xsap = %02x%02x%02x, org = %02x02x02x\n",
2296 psnap->
org[0], psnap->
org[1], psnap->
org[2]);
2301 if (psnap->
dsap != 0xaa || psnap->
ssap != 0xaa || psnap->
ctrl != 3) {
2303 pr_debug(
"ray_cs untranslate NOT SNAP %02x %02x %02x\n",
2310 if (
memcmp(psnap->
org, org_bridge, 3) == 0) {
2312 pr_debug(
"ray_cs untranslate Bridge encap\n");
2317 }
else if (
memcmp(psnap->
org, org_1042, 3) == 0) {
2321 pr_debug(
"ray_cs untranslate RFC IPX/AARP\n");
2328 pr_debug(
"ray_cs untranslate RFC default\n");
2332 peth->h_proto =
type;
2336 printk(
"ray_cs untranslate very confused by packet\n");
2339 peth->h_proto =
type;
2344 pr_debug(
"untranslate after skb_pull(%d), skb->data = %p\n", delta,
2352 for (i = 0; i < 64; i++)
2369 if (wrap_bytes <= 0) {
2374 length - wrap_bytes);
2386 unsigned rcsindex =
readb(&prcs->var.rx_packet.next_frag_rcs_index);
2391 pr_debug(
"ray_cs interrupt bad rcsindex = 0x%x\n",
2395 prcslink = rcs_base(local) + rcsindex;
2402 static void authenticate(
ray_dev_t *local)
2404 struct pcmcia_device *link = local->
finder;
2405 dev_dbg(&link->dev,
"ray_cs Starting authentication.\n");
2407 dev_dbg(&link->dev,
"ray_cs authenticate - device not present\n");
2413 local->
timer.function = join_net;
2415 local->
timer.function = authenticate_timeout;
2425 unsigned int pkt_addr,
int rx_len)
2432 copy_from_rx_buff(local, buff, pkt_addr, rx_len & 0xff);
2435 pr_debug(
"ray_cs rx_auth var= %02x %02x %02x %02x %02x %02x\n",
2437 msg->
var[4], msg->
var[5]);
2438 if (msg->
var[2] == 1) {
2439 pr_debug(
"ray_cs Sending authentication response.\n");
2440 if (!build_auth_frame
2451 if (msg->
var[2] == 2) {
2452 if ((msg->
var[3] | msg->
var[4]) == 0) {
2453 pr_debug(
"Authentication successful\n");
2459 pr_debug(
"Authentication refused\n");
2461 join_net((
u_long) local);
2475 struct pcmcia_device *link = local->
finder;
2479 dev_dbg(&link->dev,
"ray_cs associate - device not present\n");
2483 if ((ccsindex = get_free_ccs(local)) < 0) {
2485 dev_dbg(&link->dev,
"ray_cs associate - No free ccs\n");
2488 dev_dbg(&link->dev,
"ray_cs Starting association with access point\n");
2489 pccs = ccs_base(local) + ccsindex;
2493 if (interrupt_ecf(local, ccsindex)) {
2494 dev_dbg(&link->dev,
"ray_cs associate failed - ECF not ready for intr\n");
2500 local->
timer.function = join_net;
2506 netif_start_queue(dev);
2512 unsigned int pkt_addr,
int rx_len)
2517 pr_debug(
"Deauthentication frame received\n");
2525 static void clear_interrupt(
ray_dev_t *local)
2531 #ifdef CONFIG_PROC_FS
2532 #define MAXDATA (PAGE_SIZE - 80)
2534 static const char *card_status[] = {
2535 "Card inserted - uninitialized",
2536 "Card not downloaded",
2537 "Waiting for download parameters",
2538 "Card doing acquisition",
2539 "Acquisition complete",
2540 "Authentication complete",
2541 "Association complete",
2542 "???",
"???",
"???",
"???",
2544 "Download parameters error",
2546 "Acquisition failed",
2547 "Authentication refused",
2548 "Association failed"
2551 static const char *
nettype[] = {
"Adhoc",
"Infra " };
2552 static const char *framing[] = {
"Encapsulation",
"Translation" }
2556 static int ray_cs_proc_show(
struct seq_file *
m,
void *
v)
2562 struct pcmcia_device *
link;
2575 local = netdev_priv(dev);
2579 seq_puts(m,
"Raylink Wireless LAN driver status\n");
2582 seq_puts(m,
"Firmware version = ");
2583 if (local->
fw_ver == 0x55)
2584 seq_puts(m,
"4 - Use dump_cis for more details\n");
2589 for (i = 0; i < 32; i++)
2590 c[i] = local->
sparm.
b5.a_current_ess_id[i];
2593 nettype[local->
sparm.
b5.a_network_type], c);
2599 local->
sparm.
b5.a_curr_country_code);
2606 seq_printf(m,
"Card status = %s\n", card_status[i]);
2608 seq_printf(m,
"Framing mode = %s\n", framing[translate]);
2616 + 256 * local->
last_bcn.beacon_intvl[1]);
2623 "Parse beacon failed at essid element id = %d\n",
2629 seq_puts(m,
"Supported rate codes = ");
2630 for (i = 2; i < p[1] + 2; i++)
2635 seq_puts(m,
"Parse beacon failed at rates element\n");
2653 "Parse beacon failed at FH param element\n");
2657 seq_puts(m,
"No beacons received\n");
2669 .open = ray_cs_proc_open,
2676 static int build_auth_frame(
ray_dev_t *local,
UCHAR *dest,
int auth_type)
2684 if ((ccsindex = get_free_tx_ccs(local)) < 0) {
2685 pr_debug(
"ray_cs send authenticate - No free tx ccs\n");
2689 pccs = ccs_base(local) + ccsindex;
2716 if (interrupt_ecf(local, ccsindex)) {
2718 "ray_cs send authentication request failed - ECF not ready for intr\n");
2726 #ifdef CONFIG_PROC_FS
2730 static char proc_essid[33];
2731 unsigned int len =
count;
2735 memset(proc_essid, 0, 33);
2744 .write = ray_cs_essid_proc_write,
2748 static ssize_t int_proc_write(
struct file *file,
const char __user *buffer,
2749 size_t count, loff_t *pos)
2751 static char proc_number[10];
2766 unsigned int c = *p -
'0';
2772 *(
int *)PDE(file->
f_path.dentry->d_inode)->data =
nr;
2778 .write = int_proc_write,
2784 PCMCIA_DEVICE_MANF_CARD(0x01a6, 0x0000),
2790 static struct pcmcia_driver ray_driver = {
2794 .remove = ray_detach,
2795 .id_table = ray_ids,
2796 .suspend = ray_suspend,
2797 .resume = ray_resume,
2800 static int __init init_ray_cs(
void)
2806 pr_debug(
"raylink init_module register_pcmcia_driver returns 0x%x\n",
2809 #ifdef CONFIG_PROC_FS
2812 proc_create(
"driver/ray_cs/ray_cs", 0,
NULL, &ray_cs_proc_fops);
2813 proc_create(
"driver/ray_cs/essid",
S_IWUSR,
NULL, &ray_cs_essid_proc_fops);
2824 static void __exit exit_ray_cs(
void)
2826 pr_debug(
"ray_cs: cleanup_module\n");
2828 #ifdef CONFIG_PROC_FS