Deleted Added
full compact
if_an.c (173975) if_an.c (175445)
1/*-
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 24 unchanged lines hidden (view full) ---

33 * Aironet 4500/4800 802.11 PCMCIA/ISA/PCI driver for FreeBSD.
34 *
35 * Written by Bill Paul <wpaul@ctr.columbia.edu>
36 * Electrical Engineering Department
37 * Columbia University, New York City
38 */
39
40#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1997, 1998, 1999
3 * Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 24 unchanged lines hidden (view full) ---

33 * Aironet 4500/4800 802.11 PCMCIA/ISA/PCI driver for FreeBSD.
34 *
35 * Written by Bill Paul <wpaul@ctr.columbia.edu>
36 * Electrical Engineering Department
37 * Columbia University, New York City
38 */
39
40#include <sys/cdefs.h>
41__FBSDID("$FreeBSD: head/sys/dev/an/if_an.c 173975 2007-11-27 08:29:24Z avatar $");
41__FBSDID("$FreeBSD: head/sys/dev/an/if_an.c 175445 2008-01-18 16:31:24Z ambrisko $");
42
43/*
44 * The Aironet 4500/4800 series cards come in PCMCIA, ISA and PCI form.
45 * This driver supports all three device types (PCI devices are supported
46 * through an extra PCI shim: /sys/dev/an/if_an_pci.c). ISA devices can be
47 * supported either using hard-coded IO port/IRQ settings or via Plug
48 * and Play. The 4500 series devices support 1Mbps and 2Mbps data rates.
49 * The 4800 devices support 1, 2, 5.5 and 11Mbps rates.

--- 228 unchanged lines hidden (view full) ---

278 case 2:
279 strcpy(an_conf_cache, "raw");
280 break;
281 default:
282 strcpy(an_conf_cache, "dbm");
283 break;
284 }
285
42
43/*
44 * The Aironet 4500/4800 series cards come in PCMCIA, ISA and PCI form.
45 * This driver supports all three device types (PCI devices are supported
46 * through an extra PCI shim: /sys/dev/an/if_an_pci.c). ISA devices can be
47 * supported either using hard-coded IO port/IRQ settings or via Plug
48 * and Play. The 4500 series devices support 1Mbps and 2Mbps data rates.
49 * The 4800 devices support 1, 2, 5.5 and 11Mbps rates.

--- 228 unchanged lines hidden (view full) ---

278 case 2:
279 strcpy(an_conf_cache, "raw");
280 break;
281 default:
282 strcpy(an_conf_cache, "dbm");
283 break;
284 }
285
286 error = sysctl_handle_string(oidp, an_conf_cache,
286 error = sysctl_handle_string(oidp, an_conf_cache,
287 sizeof(an_conf_cache), req);
288
289 if (strncmp(an_conf_cache,"dbm", 3) == 0) {
290 an_cache_mode = 0;
291 }
292 if (strncmp(an_conf_cache,"per", 3) == 0) {
293 an_cache_mode = 1;
294 }
295 if (strncmp(an_conf_cache,"raw", 3) == 0) {
296 an_cache_mode = 2;
297 }
298
299 return error;
300}
301
302SYSCTL_PROC(_hw_an, OID_AUTO, an_cache_mode, CTLTYPE_STRING | CTLFLAG_RW,
303 0, sizeof(an_conf_cache), sysctl_an_cache_mode, "A", "");
304
305/*
287 sizeof(an_conf_cache), req);
288
289 if (strncmp(an_conf_cache,"dbm", 3) == 0) {
290 an_cache_mode = 0;
291 }
292 if (strncmp(an_conf_cache,"per", 3) == 0) {
293 an_cache_mode = 1;
294 }
295 if (strncmp(an_conf_cache,"raw", 3) == 0) {
296 an_cache_mode = 2;
297 }
298
299 return error;
300}
301
302SYSCTL_PROC(_hw_an, OID_AUTO, an_cache_mode, CTLTYPE_STRING | CTLFLAG_RW,
303 0, sizeof(an_conf_cache), sysctl_an_cache_mode, "A", "");
304
305/*
306 * Setup the lock for PCI attachment since it skips the an_probe
307 * function. We need to setup the lock in an_probe since some
308 * operations need the lock. So we might as well create the
309 * lock in the probe.
310 */
311int
312an_pci_probe(device_t dev)
313{
314 struct an_softc *sc = device_get_softc(dev);
315
316 mtx_init(&sc->an_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
317 MTX_DEF | MTX_RECURSE);
318
319 return(0);
320}
321
322/*
306 * We probe for an Aironet 4500/4800 card by attempting to
307 * read the default SSID list. On reset, the first entry in
308 * the SSID list will contain the name "tsunami." If we don't
309 * find this, then there's no card present.
310 */
311int
312an_probe(device_t dev)
313{

--- 23 unchanged lines hidden (view full) ---

337 ssid.an_len = sizeof(ssid);
338 ssid.an_type = AN_RID_SSIDLIST;
339
340 /* Make sure interrupts are disabled. */
341 sc->mpi350 = 0;
342 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
343 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), 0xFFFF);
344
323 * We probe for an Aironet 4500/4800 card by attempting to
324 * read the default SSID list. On reset, the first entry in
325 * the SSID list will contain the name "tsunami." If we don't
326 * find this, then there's no card present.
327 */
328int
329an_probe(device_t dev)
330{

--- 23 unchanged lines hidden (view full) ---

354 ssid.an_len = sizeof(ssid);
355 ssid.an_type = AN_RID_SSIDLIST;
356
357 /* Make sure interrupts are disabled. */
358 sc->mpi350 = 0;
359 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
360 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), 0xFFFF);
361
362 mtx_init(&sc->an_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
363 MTX_DEF | MTX_RECURSE);
364 AN_LOCK(sc);
345 an_reset(sc);
346
365 an_reset(sc);
366
347 if (an_cmd(sc, AN_CMD_READCFG, 0))
348 return(0);
367 if (an_cmd(sc, AN_CMD_READCFG, 0)) {
368 AN_UNLOCK(sc);
369 goto fail;
370 }
349
371
350 if (an_read_record(sc, (struct an_ltv_gen *)&ssid))
351 return(0);
372 if (an_read_record(sc, (struct an_ltv_gen *)&ssid)) {
373 AN_UNLOCK(sc);
374 goto fail;
375 }
352
353 /* See if the ssid matches what we expect ... but doesn't have to */
376
377 /* See if the ssid matches what we expect ... but doesn't have to */
354 if (strcmp(ssid.an_entry[0].an_ssid, AN_DEF_SSID))
355 return(0);
378 if (strcmp(ssid.an_entry[0].an_ssid, AN_DEF_SSID)) {
379 AN_UNLOCK(sc);
380 goto fail;
381 }
356
382
383 AN_UNLOCK(sc);
357 return(AN_IOSIZ);
384 return(AN_IOSIZ);
385fail:
386 mtx_destroy(&sc->an_mtx);
387 return(0);
358}
359
360/*
361 * Allocate a port resource with the given resource id.
362 */
363int
364an_alloc_port(device_t dev, int rid, int size)
365{

--- 177 unchanged lines hidden (view full) ---

543{
544 struct an_command cmd_struct;
545 struct an_reply reply;
546 struct an_card_rid_desc an_rid_desc;
547 struct an_card_rx_desc an_rx_desc;
548 struct an_card_tx_desc an_tx_desc;
549 int i, desc;
550
388}
389
390/*
391 * Allocate a port resource with the given resource id.
392 */
393int
394an_alloc_port(device_t dev, int rid, int size)
395{

--- 177 unchanged lines hidden (view full) ---

573{
574 struct an_command cmd_struct;
575 struct an_reply reply;
576 struct an_card_rid_desc an_rid_desc;
577 struct an_card_rx_desc an_rx_desc;
578 struct an_card_tx_desc an_tx_desc;
579 int i, desc;
580
581 AN_LOCK_ASSERT(sc);
551 if(!sc->an_rid_buffer.an_dma_paddr)
552 an_dma_malloc(sc, AN_RID_BUFFER_SIZE,
553 &sc->an_rid_buffer, 0);
554 for (i = 0; i < AN_MAX_RX_DESC; i++)
555 if(!sc->an_rx_buffer[i].an_dma_paddr)
556 an_dma_malloc(sc, AN_RX_BUFFER_SIZE,
557 &sc->an_rx_buffer[i], 0);
558 for (i = 0; i < AN_MAX_TX_DESC; i++)

--- 5 unchanged lines hidden (view full) ---

564 * Allocate RX descriptor
565 */
566 bzero(&reply,sizeof(reply));
567 cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
568 cmd_struct.an_parm0 = AN_DESCRIPTOR_RX;
569 cmd_struct.an_parm1 = AN_RX_DESC_OFFSET;
570 cmd_struct.an_parm2 = AN_MAX_RX_DESC;
571 if (an_cmd_struct(sc, &cmd_struct, &reply)) {
582 if(!sc->an_rid_buffer.an_dma_paddr)
583 an_dma_malloc(sc, AN_RID_BUFFER_SIZE,
584 &sc->an_rid_buffer, 0);
585 for (i = 0; i < AN_MAX_RX_DESC; i++)
586 if(!sc->an_rx_buffer[i].an_dma_paddr)
587 an_dma_malloc(sc, AN_RX_BUFFER_SIZE,
588 &sc->an_rx_buffer[i], 0);
589 for (i = 0; i < AN_MAX_TX_DESC; i++)

--- 5 unchanged lines hidden (view full) ---

595 * Allocate RX descriptor
596 */
597 bzero(&reply,sizeof(reply));
598 cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
599 cmd_struct.an_parm0 = AN_DESCRIPTOR_RX;
600 cmd_struct.an_parm1 = AN_RX_DESC_OFFSET;
601 cmd_struct.an_parm2 = AN_MAX_RX_DESC;
602 if (an_cmd_struct(sc, &cmd_struct, &reply)) {
572 printf("an%d: failed to allocate RX descriptor\n",
603 printf("an%d: failed to allocate RX descriptor\n",
573 sc->an_unit);
574 return(EIO);
575 }
576
577 for (desc = 0; desc < AN_MAX_RX_DESC; desc++) {
578 bzero(&an_rx_desc, sizeof(an_rx_desc));
579 an_rx_desc.an_valid = 1;
580 an_rx_desc.an_len = AN_RX_BUFFER_SIZE;

--- 12 unchanged lines hidden (view full) ---

593 */
594
595 bzero(&reply,sizeof(reply));
596 cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
597 cmd_struct.an_parm0 = AN_DESCRIPTOR_TX;
598 cmd_struct.an_parm1 = AN_TX_DESC_OFFSET;
599 cmd_struct.an_parm2 = AN_MAX_TX_DESC;
600 if (an_cmd_struct(sc, &cmd_struct, &reply)) {
604 sc->an_unit);
605 return(EIO);
606 }
607
608 for (desc = 0; desc < AN_MAX_RX_DESC; desc++) {
609 bzero(&an_rx_desc, sizeof(an_rx_desc));
610 an_rx_desc.an_valid = 1;
611 an_rx_desc.an_len = AN_RX_BUFFER_SIZE;

--- 12 unchanged lines hidden (view full) ---

624 */
625
626 bzero(&reply,sizeof(reply));
627 cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
628 cmd_struct.an_parm0 = AN_DESCRIPTOR_TX;
629 cmd_struct.an_parm1 = AN_TX_DESC_OFFSET;
630 cmd_struct.an_parm2 = AN_MAX_TX_DESC;
631 if (an_cmd_struct(sc, &cmd_struct, &reply)) {
601 printf("an%d: failed to allocate TX descriptor\n",
632 printf("an%d: failed to allocate TX descriptor\n",
602 sc->an_unit);
603 return(EIO);
604 }
605
606 for (desc = 0; desc < AN_MAX_TX_DESC; desc++) {
607 bzero(&an_tx_desc, sizeof(an_tx_desc));
608 an_tx_desc.an_offset = 0;
609 an_tx_desc.an_eoc = 0;

--- 13 unchanged lines hidden (view full) ---

623 */
624
625 bzero(&reply,sizeof(reply));
626 cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
627 cmd_struct.an_parm0 = AN_DESCRIPTOR_HOSTRW;
628 cmd_struct.an_parm1 = AN_HOST_DESC_OFFSET;
629 cmd_struct.an_parm2 = 1;
630 if (an_cmd_struct(sc, &cmd_struct, &reply)) {
633 sc->an_unit);
634 return(EIO);
635 }
636
637 for (desc = 0; desc < AN_MAX_TX_DESC; desc++) {
638 bzero(&an_tx_desc, sizeof(an_tx_desc));
639 an_tx_desc.an_offset = 0;
640 an_tx_desc.an_eoc = 0;

--- 13 unchanged lines hidden (view full) ---

654 */
655
656 bzero(&reply,sizeof(reply));
657 cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
658 cmd_struct.an_parm0 = AN_DESCRIPTOR_HOSTRW;
659 cmd_struct.an_parm1 = AN_HOST_DESC_OFFSET;
660 cmd_struct.an_parm2 = 1;
661 if (an_cmd_struct(sc, &cmd_struct, &reply)) {
631 printf("an%d: failed to allocate host descriptor\n",
662 printf("an%d: failed to allocate host descriptor\n",
632 sc->an_unit);
633 return(EIO);
634 }
635
636 bzero(&an_rid_desc, sizeof(an_rid_desc));
637 an_rid_desc.an_valid = 1;
638 an_rid_desc.an_len = AN_RID_BUFFER_SIZE;
639 an_rid_desc.an_rid = 0;
640 an_rid_desc.an_phys = sc->an_rid_buffer.an_dma_paddr;
641
642 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
663 sc->an_unit);
664 return(EIO);
665 }
666
667 bzero(&an_rid_desc, sizeof(an_rid_desc));
668 an_rid_desc.an_valid = 1;
669 an_rid_desc.an_len = AN_RID_BUFFER_SIZE;
670 an_rid_desc.an_rid = 0;
671 an_rid_desc.an_phys = sc->an_rid_buffer.an_dma_paddr;
672
673 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
643 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
674 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
644 ((u_int32_t *)(void *)&an_rid_desc)[i]);
645
646 return(0);
647}
648
649int
650an_attach(struct an_softc *sc, int unit, int flags)
651{
652 struct ifnet *ifp;
653 int error = EIO;
654 int i, nrate, mword;
655 u_int8_t r;
656
675 ((u_int32_t *)(void *)&an_rid_desc)[i]);
676
677 return(0);
678}
679
680int
681an_attach(struct an_softc *sc, int unit, int flags)
682{
683 struct ifnet *ifp;
684 int error = EIO;
685 int i, nrate, mword;
686 u_int8_t r;
687
657 mtx_init(&sc->an_mtx, device_get_nameunit(sc->an_dev), MTX_NETWORK_LOCK,
658 MTX_DEF | MTX_RECURSE);
659 ifp = sc->an_ifp = if_alloc(IFT_ETHER);
660 if (ifp == NULL) {
661 printf("an%d: can not if_alloc()\n", sc->an_unit);
662 goto fail;
663 }
688 ifp = sc->an_ifp = if_alloc(IFT_ETHER);
689 if (ifp == NULL) {
690 printf("an%d: can not if_alloc()\n", sc->an_unit);
691 goto fail;
692 }
664
693
665 sc->an_gone = 0;
666 sc->an_associated = 0;
667 sc->an_monitor = 0;
668 sc->an_was_monitor = 0;
669 sc->an_flash_buffer = NULL;
670
671 /* Reset the NIC. */
694 sc->an_gone = 0;
695 sc->an_associated = 0;
696 sc->an_monitor = 0;
697 sc->an_was_monitor = 0;
698 sc->an_flash_buffer = NULL;
699
700 /* Reset the NIC. */
701 AN_LOCK(sc);
672 an_reset(sc);
673 if (sc->mpi350) {
674 error = an_init_mpi350_desc(sc);
675 if (error)
676 goto fail;
677 }
678
679 /* Load factory config */

--- 45 unchanged lines hidden (view full) ---

725 } else {
726 printf("an%d: got RSSI <-> dBM map\n", sc->an_unit);
727 sc->an_have_rssimap = 1;
728 }
729 } else {
730 printf("an%d: no RSSI <-> dBM map\n", sc->an_unit);
731 }
732#endif
702 an_reset(sc);
703 if (sc->mpi350) {
704 error = an_init_mpi350_desc(sc);
705 if (error)
706 goto fail;
707 }
708
709 /* Load factory config */

--- 45 unchanged lines hidden (view full) ---

755 } else {
756 printf("an%d: got RSSI <-> dBM map\n", sc->an_unit);
757 sc->an_have_rssimap = 1;
758 }
759 } else {
760 printf("an%d: no RSSI <-> dBM map\n", sc->an_unit);
761 }
762#endif
763 AN_UNLOCK(sc);
733
734 ifp->if_softc = sc;
735 sc->an_unit = unit;
736 if_initname(ifp, device_get_name(sc->an_dev),
737 device_get_unit(sc->an_dev));
738 ifp->if_mtu = ETHERMTU;
739 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
740 ifp->if_ioctl = an_ioctl;

--- 35 unchanged lines hidden (view full) ---

776 if (mword == 0)
777 continue;
778 printf("%s%d%sMbps", (i != 0 ? " " : ""),
779 (r & IEEE80211_RATE_VAL) / 2, ((r & 0x1) != 0 ? ".5" : ""));
780 ADD(mword, 0);
781 ADD(mword, IFM_IEEE80211_ADHOC);
782 }
783 printf("\n");
764
765 ifp->if_softc = sc;
766 sc->an_unit = unit;
767 if_initname(ifp, device_get_name(sc->an_dev),
768 device_get_unit(sc->an_dev));
769 ifp->if_mtu = ETHERMTU;
770 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
771 ifp->if_ioctl = an_ioctl;

--- 35 unchanged lines hidden (view full) ---

807 if (mword == 0)
808 continue;
809 printf("%s%d%sMbps", (i != 0 ? " " : ""),
810 (r & IEEE80211_RATE_VAL) / 2, ((r & 0x1) != 0 ? ".5" : ""));
811 ADD(mword, 0);
812 ADD(mword, IFM_IEEE80211_ADHOC);
813 }
814 printf("\n");
784 ifmedia_set(&sc->an_ifmedia, IFM_MAKEWORD(IFM_IEEE80211,
815 ifmedia_set(&sc->an_ifmedia, IFM_MAKEWORD(IFM_IEEE80211,
785 IFM_AUTO, 0, 0));
786#undef ADD
787
788 /*
789 * Call MI attach routine.
790 */
791
792 ether_ifattach(ifp, sc->an_caps.an_oemaddr);
793 callout_init_mtx(&sc->an_stat_ch, &sc->an_mtx, 0);
794
795 return(0);
816 IFM_AUTO, 0, 0));
817#undef ADD
818
819 /*
820 * Call MI attach routine.
821 */
822
823 ether_ifattach(ifp, sc->an_caps.an_oemaddr);
824 callout_init_mtx(&sc->an_stat_ch, &sc->an_mtx, 0);
825
826 return(0);
796fail:;
827fail:
828 AN_UNLOCK(sc);
797 mtx_destroy(&sc->an_mtx);
798 if (ifp != NULL)
799 if_free(ifp);
800 return(error);
801}
802
803int
804an_detach(device_t dev)

--- 80 unchanged lines hidden (view full) ---

885 bcopy((char *)&rx_frame,
886 bpf_buf, sizeof(rx_frame));
887
888 error = an_read_data(sc, id, sizeof(rx_frame),
889 (caddr_t)bpf_buf+sizeof(rx_frame),
890 rx_frame.an_rx_payload_len);
891 } else {
892 fc1=rx_frame.an_frame_ctl >> 8;
829 mtx_destroy(&sc->an_mtx);
830 if (ifp != NULL)
831 if_free(ifp);
832 return(error);
833}
834
835int
836an_detach(device_t dev)

--- 80 unchanged lines hidden (view full) ---

917 bcopy((char *)&rx_frame,
918 bpf_buf, sizeof(rx_frame));
919
920 error = an_read_data(sc, id, sizeof(rx_frame),
921 (caddr_t)bpf_buf+sizeof(rx_frame),
922 rx_frame.an_rx_payload_len);
923 } else {
924 fc1=rx_frame.an_frame_ctl >> 8;
893 ieee80211_header_len =
925 ieee80211_header_len =
894 sizeof(struct ieee80211_frame);
895 if ((fc1 & IEEE80211_FC1_DIR_TODS) &&
896 (fc1 & IEEE80211_FC1_DIR_FROMDS)) {
897 ieee80211_header_len += ETHER_ADDR_LEN;
898 }
899
900 len = rx_frame.an_rx_payload_len
901 + ieee80211_header_len;

--- 30 unchanged lines hidden (view full) ---

932 ifp->if_ierrors++;
933 return;
934 }
935 m->m_pkthdr.rcvif = ifp;
936 /* Read Ethernet encapsulated packet */
937
938#ifdef ANCACHE
939 /* Read NIC frame header */
926 sizeof(struct ieee80211_frame);
927 if ((fc1 & IEEE80211_FC1_DIR_TODS) &&
928 (fc1 & IEEE80211_FC1_DIR_FROMDS)) {
929 ieee80211_header_len += ETHER_ADDR_LEN;
930 }
931
932 len = rx_frame.an_rx_payload_len
933 + ieee80211_header_len;

--- 30 unchanged lines hidden (view full) ---

964 ifp->if_ierrors++;
965 return;
966 }
967 m->m_pkthdr.rcvif = ifp;
968 /* Read Ethernet encapsulated packet */
969
970#ifdef ANCACHE
971 /* Read NIC frame header */
940 if (an_read_data(sc, id, 0, (caddr_t)&rx_frame,
972 if (an_read_data(sc, id, 0, (caddr_t)&rx_frame,
941 sizeof(rx_frame))) {
942 m_freem(m);
943 ifp->if_ierrors++;
944 return;
945 }
946#endif
947 /* Read in the 802_3 frame header */
973 sizeof(rx_frame))) {
974 m_freem(m);
975 ifp->if_ierrors++;
976 return;
977 }
978#endif
979 /* Read in the 802_3 frame header */
948 if (an_read_data(sc, id, 0x34,
980 if (an_read_data(sc, id, 0x34,
949 (caddr_t)&rx_frame_802_3,
950 sizeof(rx_frame_802_3))) {
951 m_freem(m);
952 ifp->if_ierrors++;
953 return;
954 }
955 if (rx_frame_802_3.an_rx_802_3_status != 0) {
956 m_freem(m);

--- 16 unchanged lines hidden (view full) ---

973 eh = mtod(m, struct ether_header *);
974
975 bcopy((char *)&rx_frame_802_3.an_rx_dst_addr,
976 (char *)&eh->ether_dhost, ETHER_ADDR_LEN);
977 bcopy((char *)&rx_frame_802_3.an_rx_src_addr,
978 (char *)&eh->ether_shost, ETHER_ADDR_LEN);
979
980 /* in mbuf header type is just before payload */
981 (caddr_t)&rx_frame_802_3,
982 sizeof(rx_frame_802_3))) {
983 m_freem(m);
984 ifp->if_ierrors++;
985 return;
986 }
987 if (rx_frame_802_3.an_rx_802_3_status != 0) {
988 m_freem(m);

--- 16 unchanged lines hidden (view full) ---

1005 eh = mtod(m, struct ether_header *);
1006
1007 bcopy((char *)&rx_frame_802_3.an_rx_dst_addr,
1008 (char *)&eh->ether_dhost, ETHER_ADDR_LEN);
1009 bcopy((char *)&rx_frame_802_3.an_rx_src_addr,
1010 (char *)&eh->ether_shost, ETHER_ADDR_LEN);
1011
1012 /* in mbuf header type is just before payload */
981 error = an_read_data(sc, id, 0x44,
1013 error = an_read_data(sc, id, 0x44,
982 (caddr_t)&(eh->ether_type),
983 rx_frame_802_3.an_rx_802_3_payload_len);
984
985 if (error) {
986 m_freem(m);
987 ifp->if_ierrors++;
988 return;
989 }
990 ifp->if_ipackets++;
991
992 /* Receive packet. */
993#ifdef ANCACHE
1014 (caddr_t)&(eh->ether_type),
1015 rx_frame_802_3.an_rx_802_3_payload_len);
1016
1017 if (error) {
1018 m_freem(m);
1019 ifp->if_ierrors++;
1020 return;
1021 }
1022 ifp->if_ipackets++;
1023
1024 /* Receive packet. */
1025#ifdef ANCACHE
994 an_cache_store(sc, eh, m,
1026 an_cache_store(sc, eh, m,
995 rx_frame.an_rx_signal_strength,
996 rx_frame.an_rsvd0);
997#endif
998 AN_UNLOCK(sc);
999 (*ifp->if_input)(ifp, m);
1000 AN_LOCK(sc);
1001 }
1002
1003 } else { /* MPI-350 */
1004 for (count = 0; count < AN_MAX_RX_DESC; count++){
1005 for (i = 0; i < sizeof(an_rx_desc) / 4; i++)
1027 rx_frame.an_rx_signal_strength,
1028 rx_frame.an_rsvd0);
1029#endif
1030 AN_UNLOCK(sc);
1031 (*ifp->if_input)(ifp, m);
1032 AN_LOCK(sc);
1033 }
1034
1035 } else { /* MPI-350 */
1036 for (count = 0; count < AN_MAX_RX_DESC; count++){
1037 for (i = 0; i < sizeof(an_rx_desc) / 4; i++)
1006 ((u_int32_t *)(void *)&an_rx_desc)[i]
1007 = CSR_MEM_AUX_READ_4(sc,
1008 AN_RX_DESC_OFFSET
1038 ((u_int32_t *)(void *)&an_rx_desc)[i]
1039 = CSR_MEM_AUX_READ_4(sc,
1040 AN_RX_DESC_OFFSET
1009 + (count * sizeof(an_rx_desc))
1010 + (i * 4));
1011
1012 if (an_rx_desc.an_done && !an_rx_desc.an_valid) {
1013 buf = sc->an_rx_buffer[count].an_dma_vaddr;
1014
1015 MGETHDR(m, M_DONTWAIT, MT_DATA);
1016 if (m == NULL) {

--- 4 unchanged lines hidden (view full) ---

1021 if (!(m->m_flags & M_EXT)) {
1022 m_freem(m);
1023 ifp->if_ierrors++;
1024 return;
1025 }
1026 m->m_pkthdr.rcvif = ifp;
1027 /* Read Ethernet encapsulated packet */
1028
1041 + (count * sizeof(an_rx_desc))
1042 + (i * 4));
1043
1044 if (an_rx_desc.an_done && !an_rx_desc.an_valid) {
1045 buf = sc->an_rx_buffer[count].an_dma_vaddr;
1046
1047 MGETHDR(m, M_DONTWAIT, MT_DATA);
1048 if (m == NULL) {

--- 4 unchanged lines hidden (view full) ---

1053 if (!(m->m_flags & M_EXT)) {
1054 m_freem(m);
1055 ifp->if_ierrors++;
1056 return;
1057 }
1058 m->m_pkthdr.rcvif = ifp;
1059 /* Read Ethernet encapsulated packet */
1060
1029 /*
1061 /*
1030 * No ANCACHE support since we just get back
1031 * an Ethernet packet no 802.11 info
1032 */
1033#if 0
1034#ifdef ANCACHE
1035 /* Read NIC frame header */
1062 * No ANCACHE support since we just get back
1063 * an Ethernet packet no 802.11 info
1064 */
1065#if 0
1066#ifdef ANCACHE
1067 /* Read NIC frame header */
1036 bcopy(buf, (caddr_t)&rx_frame,
1068 bcopy(buf, (caddr_t)&rx_frame,
1037 sizeof(rx_frame));
1038#endif
1039#endif
1040 /* Check for insane frame length */
1041 len = an_rx_desc.an_len + 12;
1042 if (len > MCLBYTES) {
1043 m_freem(m);
1044 printf("an%d: oversized packet "
1045 "received (%d, %d)\n",
1046 sc->an_unit, len, MCLBYTES);
1047 ifp->if_ierrors++;
1048 return;
1049 }
1050
1051 m->m_pkthdr.len = m->m_len =
1052 an_rx_desc.an_len + 12;
1069 sizeof(rx_frame));
1070#endif
1071#endif
1072 /* Check for insane frame length */
1073 len = an_rx_desc.an_len + 12;
1074 if (len > MCLBYTES) {
1075 m_freem(m);
1076 printf("an%d: oversized packet "
1077 "received (%d, %d)\n",
1078 sc->an_unit, len, MCLBYTES);
1079 ifp->if_ierrors++;
1080 return;
1081 }
1082
1083 m->m_pkthdr.len = m->m_len =
1084 an_rx_desc.an_len + 12;
1053
1085
1054 eh = mtod(m, struct ether_header *);
1086 eh = mtod(m, struct ether_header *);
1055
1087
1056 bcopy(buf, (char *)eh,
1057 m->m_pkthdr.len);
1088 bcopy(buf, (char *)eh,
1089 m->m_pkthdr.len);
1058
1090
1059 ifp->if_ipackets++;
1091 ifp->if_ipackets++;
1060
1092
1061 /* Receive packet. */
1062#if 0
1063#ifdef ANCACHE
1093 /* Receive packet. */
1094#if 0
1095#ifdef ANCACHE
1064 an_cache_store(sc, eh, m,
1096 an_cache_store(sc, eh, m,
1065 rx_frame.an_rx_signal_strength,
1066 rx_frame.an_rsvd0);
1067#endif
1068#endif
1069 AN_UNLOCK(sc);
1070 (*ifp->if_input)(ifp, m);
1071 AN_LOCK(sc);
1072
1073 an_rx_desc.an_valid = 1;
1074 an_rx_desc.an_len = AN_RX_BUFFER_SIZE;
1075 an_rx_desc.an_done = 0;
1097 rx_frame.an_rx_signal_strength,
1098 rx_frame.an_rsvd0);
1099#endif
1100#endif
1101 AN_UNLOCK(sc);
1102 (*ifp->if_input)(ifp, m);
1103 AN_LOCK(sc);
1104
1105 an_rx_desc.an_valid = 1;
1106 an_rx_desc.an_len = AN_RX_BUFFER_SIZE;
1107 an_rx_desc.an_done = 0;
1076 an_rx_desc.an_phys =
1108 an_rx_desc.an_phys =
1077 sc->an_rx_buffer[count].an_dma_paddr;
1109 sc->an_rx_buffer[count].an_dma_paddr;
1078
1110
1079 for (i = 0; i < sizeof(an_rx_desc) / 4; i++)
1111 for (i = 0; i < sizeof(an_rx_desc) / 4; i++)
1080 CSR_MEM_AUX_WRITE_4(sc,
1081 AN_RX_DESC_OFFSET
1112 CSR_MEM_AUX_WRITE_4(sc,
1113 AN_RX_DESC_OFFSET
1082 + (count * sizeof(an_rx_desc))
1083 + (i * 4),
1084 ((u_int32_t *)(void *)&an_rx_desc)[i]);
1114 + (count * sizeof(an_rx_desc))
1115 + (i * 4),
1116 ((u_int32_t *)(void *)&an_rx_desc)[i]);
1085
1117
1086 } else {
1087 printf("an%d: Didn't get valid RX packet "
1088 "%x %x %d\n",
1089 sc->an_unit,
1090 an_rx_desc.an_done,
1091 an_rx_desc.an_valid, an_rx_desc.an_len);
1092 }
1093 }
1094 }
1095}
1096
1097static void
1098an_txeof(struct an_softc *sc, int status)
1099{
1100 struct ifnet *ifp;
1101 int id, i;
1102
1118 } else {
1119 printf("an%d: Didn't get valid RX packet "
1120 "%x %x %d\n",
1121 sc->an_unit,
1122 an_rx_desc.an_done,
1123 an_rx_desc.an_valid, an_rx_desc.an_len);
1124 }
1125 }
1126 }
1127}
1128
1129static void
1130an_txeof(struct an_softc *sc, int status)
1131{
1132 struct ifnet *ifp;
1133 int id, i;
1134
1135 AN_LOCK_ASSERT(sc);
1103 ifp = sc->an_ifp;
1104
1105 ifp->if_timer = 0;
1106 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1107
1108 if (!sc->mpi350) {
1109 id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350));
1110

--- 95 unchanged lines hidden (view full) ---

1206 status = CSR_READ_2(sc, AN_EVENT_STAT(sc->mpi350));
1207 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), ~AN_INTRS(sc->mpi350));
1208
1209 if (status & AN_EV_MIC) {
1210 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_MIC);
1211 }
1212
1213 if (status & AN_EV_LINKSTAT) {
1136 ifp = sc->an_ifp;
1137
1138 ifp->if_timer = 0;
1139 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1140
1141 if (!sc->mpi350) {
1142 id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350));
1143

--- 95 unchanged lines hidden (view full) ---

1239 status = CSR_READ_2(sc, AN_EVENT_STAT(sc->mpi350));
1240 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), ~AN_INTRS(sc->mpi350));
1241
1242 if (status & AN_EV_MIC) {
1243 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_MIC);
1244 }
1245
1246 if (status & AN_EV_LINKSTAT) {
1214 if (CSR_READ_2(sc, AN_LINKSTAT(sc->mpi350))
1247 if (CSR_READ_2(sc, AN_LINKSTAT(sc->mpi350))
1215 == AN_LINKSTAT_ASSOCIATED)
1216 sc->an_associated = 1;
1217 else
1218 sc->an_associated = 0;
1219 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_LINKSTAT);
1220 }
1221
1222 if (status & AN_EV_RX) {

--- 32 unchanged lines hidden (view full) ---

1255
1256
1257static int
1258an_cmd_struct(struct an_softc *sc, struct an_command *cmd,
1259 struct an_reply *reply)
1260{
1261 int i;
1262
1248 == AN_LINKSTAT_ASSOCIATED)
1249 sc->an_associated = 1;
1250 else
1251 sc->an_associated = 0;
1252 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_LINKSTAT);
1253 }
1254
1255 if (status & AN_EV_RX) {

--- 32 unchanged lines hidden (view full) ---

1288
1289
1290static int
1291an_cmd_struct(struct an_softc *sc, struct an_command *cmd,
1292 struct an_reply *reply)
1293{
1294 int i;
1295
1296 AN_LOCK_ASSERT(sc);
1263 for (i = 0; i != AN_TIMEOUT; i++) {
1264 if (CSR_READ_2(sc, AN_COMMAND(sc->mpi350)) & AN_CMD_BUSY) {
1265 DELAY(1000);
1266 } else
1267 break;
1268 }
1269
1270 if( i == AN_TIMEOUT) {

--- 13 unchanged lines hidden (view full) ---

1284 }
1285
1286 reply->an_resp0 = CSR_READ_2(sc, AN_RESP0(sc->mpi350));
1287 reply->an_resp1 = CSR_READ_2(sc, AN_RESP1(sc->mpi350));
1288 reply->an_resp2 = CSR_READ_2(sc, AN_RESP2(sc->mpi350));
1289 reply->an_status = CSR_READ_2(sc, AN_STATUS(sc->mpi350));
1290
1291 if (CSR_READ_2(sc, AN_COMMAND(sc->mpi350)) & AN_CMD_BUSY)
1297 for (i = 0; i != AN_TIMEOUT; i++) {
1298 if (CSR_READ_2(sc, AN_COMMAND(sc->mpi350)) & AN_CMD_BUSY) {
1299 DELAY(1000);
1300 } else
1301 break;
1302 }
1303
1304 if( i == AN_TIMEOUT) {

--- 13 unchanged lines hidden (view full) ---

1318 }
1319
1320 reply->an_resp0 = CSR_READ_2(sc, AN_RESP0(sc->mpi350));
1321 reply->an_resp1 = CSR_READ_2(sc, AN_RESP1(sc->mpi350));
1322 reply->an_resp2 = CSR_READ_2(sc, AN_RESP2(sc->mpi350));
1323 reply->an_status = CSR_READ_2(sc, AN_STATUS(sc->mpi350));
1324
1325 if (CSR_READ_2(sc, AN_COMMAND(sc->mpi350)) & AN_CMD_BUSY)
1292 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350),
1326 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350),
1293 AN_EV_CLR_STUCK_BUSY);
1294
1295 /* Ack the command */
1296 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_CMD);
1297
1298 if (i == AN_TIMEOUT)
1299 return(ETIMEDOUT);
1300
1301 return(0);
1302}
1303
1304static int
1305an_cmd(struct an_softc *sc, int cmd, int val)
1306{
1307 int i, s = 0;
1308
1327 AN_EV_CLR_STUCK_BUSY);
1328
1329 /* Ack the command */
1330 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_CMD);
1331
1332 if (i == AN_TIMEOUT)
1333 return(ETIMEDOUT);
1334
1335 return(0);
1336}
1337
1338static int
1339an_cmd(struct an_softc *sc, int cmd, int val)
1340{
1341 int i, s = 0;
1342
1343 AN_LOCK_ASSERT(sc);
1309 CSR_WRITE_2(sc, AN_PARAM0(sc->mpi350), val);
1310 CSR_WRITE_2(sc, AN_PARAM1(sc->mpi350), 0);
1311 CSR_WRITE_2(sc, AN_PARAM2(sc->mpi350), 0);
1312 CSR_WRITE_2(sc, AN_COMMAND(sc->mpi350), cmd);
1313
1314 for (i = 0; i < AN_TIMEOUT; i++) {
1315 if (CSR_READ_2(sc, AN_EVENT_STAT(sc->mpi350)) & AN_EV_CMD)
1316 break;

--- 30 unchanged lines hidden (view full) ---

1347 * head and force it to reboot correctly.
1348 */
1349static void
1350an_reset(struct an_softc *sc)
1351{
1352 if (sc->an_gone)
1353 return;
1354
1344 CSR_WRITE_2(sc, AN_PARAM0(sc->mpi350), val);
1345 CSR_WRITE_2(sc, AN_PARAM1(sc->mpi350), 0);
1346 CSR_WRITE_2(sc, AN_PARAM2(sc->mpi350), 0);
1347 CSR_WRITE_2(sc, AN_COMMAND(sc->mpi350), cmd);
1348
1349 for (i = 0; i < AN_TIMEOUT; i++) {
1350 if (CSR_READ_2(sc, AN_EVENT_STAT(sc->mpi350)) & AN_EV_CMD)
1351 break;

--- 30 unchanged lines hidden (view full) ---

1382 * head and force it to reboot correctly.
1383 */
1384static void
1385an_reset(struct an_softc *sc)
1386{
1387 if (sc->an_gone)
1388 return;
1389
1390 AN_LOCK_ASSERT(sc);
1355 an_cmd(sc, AN_CMD_ENABLE, 0);
1356 an_cmd(sc, AN_CMD_FW_RESTART, 0);
1357 an_cmd(sc, AN_CMD_NOOP2, 0);
1358
1359 if (an_cmd(sc, AN_CMD_FORCE_SYNCLOSS, 0) == ETIMEDOUT)
1360 printf("an%d: reset failed\n", sc->an_unit);
1361
1362 an_cmd(sc, AN_CMD_DISABLE, 0);

--- 10 unchanged lines hidden (view full) ---

1373 struct an_ltv_gen *an_ltv;
1374 struct an_card_rid_desc an_rid_desc;
1375 struct an_command cmd;
1376 struct an_reply reply;
1377 u_int16_t *ptr;
1378 u_int8_t *ptr2;
1379 int i, len;
1380
1391 an_cmd(sc, AN_CMD_ENABLE, 0);
1392 an_cmd(sc, AN_CMD_FW_RESTART, 0);
1393 an_cmd(sc, AN_CMD_NOOP2, 0);
1394
1395 if (an_cmd(sc, AN_CMD_FORCE_SYNCLOSS, 0) == ETIMEDOUT)
1396 printf("an%d: reset failed\n", sc->an_unit);
1397
1398 an_cmd(sc, AN_CMD_DISABLE, 0);

--- 10 unchanged lines hidden (view full) ---

1409 struct an_ltv_gen *an_ltv;
1410 struct an_card_rid_desc an_rid_desc;
1411 struct an_command cmd;
1412 struct an_reply reply;
1413 u_int16_t *ptr;
1414 u_int8_t *ptr2;
1415 int i, len;
1416
1417 AN_LOCK_ASSERT(sc);
1381 if (ltv->an_len < 4 || ltv->an_type == 0)
1382 return(EINVAL);
1383
1384 if (!sc->mpi350){
1385 /* Tell the NIC to enter record read mode. */
1386 if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_READ, ltv->an_type)) {
1387 printf("an%d: RID access failed\n", sc->an_unit);
1388 return(EIO);

--- 40 unchanged lines hidden (view full) ---

1429 bzero(sc->an_rid_buffer.an_dma_vaddr, AN_RID_BUFFER_SIZE);
1430
1431 bzero(&cmd, sizeof(cmd));
1432 bzero(&reply, sizeof(reply));
1433 cmd.an_cmd = AN_CMD_ACCESS|AN_ACCESS_READ;
1434 cmd.an_parm0 = ltv->an_type;
1435
1436 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
1418 if (ltv->an_len < 4 || ltv->an_type == 0)
1419 return(EINVAL);
1420
1421 if (!sc->mpi350){
1422 /* Tell the NIC to enter record read mode. */
1423 if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_READ, ltv->an_type)) {
1424 printf("an%d: RID access failed\n", sc->an_unit);
1425 return(EIO);

--- 40 unchanged lines hidden (view full) ---

1466 bzero(sc->an_rid_buffer.an_dma_vaddr, AN_RID_BUFFER_SIZE);
1467
1468 bzero(&cmd, sizeof(cmd));
1469 bzero(&reply, sizeof(reply));
1470 cmd.an_cmd = AN_CMD_ACCESS|AN_ACCESS_READ;
1471 cmd.an_parm0 = ltv->an_type;
1472
1473 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
1437 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
1474 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
1438 ((u_int32_t *)(void *)&an_rid_desc)[i]);
1439
1440 if (an_cmd_struct(sc, &cmd, &reply)
1441 || reply.an_status & AN_CMD_QUAL_MASK) {
1475 ((u_int32_t *)(void *)&an_rid_desc)[i]);
1476
1477 if (an_cmd_struct(sc, &cmd, &reply)
1478 || reply.an_status & AN_CMD_QUAL_MASK) {
1442 printf("an%d: failed to read RID %x %x %x %x %x, %d\n",
1443 sc->an_unit, ltv->an_type,
1479 printf("an%d: failed to read RID %x %x %x %x %x, %d\n",
1480 sc->an_unit, ltv->an_type,
1444 reply.an_status,
1445 reply.an_resp0,
1446 reply.an_resp1,
1447 reply.an_resp2,
1448 i);
1449 return(EIO);
1450 }
1451

--- 7 unchanged lines hidden (view full) ---

1459 printf("an%d: record length mismatch -- expected %d, "
1460 "got %d for Rid %x\n", sc->an_unit,
1461 ltv->an_len - 2, len, ltv->an_type);
1462 len = ltv->an_len - 2;
1463 } else {
1464 ltv->an_len = len + 2;
1465 }
1466 bcopy(&an_ltv->an_type,
1481 reply.an_status,
1482 reply.an_resp0,
1483 reply.an_resp1,
1484 reply.an_resp2,
1485 i);
1486 return(EIO);
1487 }
1488

--- 7 unchanged lines hidden (view full) ---

1496 printf("an%d: record length mismatch -- expected %d, "
1497 "got %d for Rid %x\n", sc->an_unit,
1498 ltv->an_len - 2, len, ltv->an_type);
1499 len = ltv->an_len - 2;
1500 } else {
1501 ltv->an_len = len + 2;
1502 }
1503 bcopy(&an_ltv->an_type,
1467 &ltv->an_val,
1504 <v->an_val,
1468 len);
1469 }
1470
1471 if (an_dump)
1472 an_dump_record(sc, ltv, "Read");
1473
1474 return(0);
1475}

--- 6 unchanged lines hidden (view full) ---

1482{
1483 struct an_card_rid_desc an_rid_desc;
1484 struct an_command cmd;
1485 struct an_reply reply;
1486 u_int16_t *ptr;
1487 u_int8_t *ptr2;
1488 int i, len;
1489
1505 len);
1506 }
1507
1508 if (an_dump)
1509 an_dump_record(sc, ltv, "Read");
1510
1511 return(0);
1512}

--- 6 unchanged lines hidden (view full) ---

1519{
1520 struct an_card_rid_desc an_rid_desc;
1521 struct an_command cmd;
1522 struct an_reply reply;
1523 u_int16_t *ptr;
1524 u_int8_t *ptr2;
1525 int i, len;
1526
1527 AN_LOCK_ASSERT(sc);
1490 if (an_dump)
1491 an_dump_record(sc, ltv, "Write");
1492
1493 if (!sc->mpi350){
1494 if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_READ, ltv->an_type))
1495 return(EIO);
1496
1497 if (an_seek(sc, ltv->an_type, 0, AN_BAP1))

--- 11 unchanged lines hidden (view full) ---

1509 CSR_WRITE_2(sc, AN_DATA1, *ptr++);
1510 if (i) {
1511 ptr2 = (u_int8_t *)ptr;
1512 CSR_WRITE_1(sc, AN_DATA0, *ptr2);
1513 }
1514
1515 if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_WRITE, ltv->an_type))
1516 return(EIO);
1528 if (an_dump)
1529 an_dump_record(sc, ltv, "Write");
1530
1531 if (!sc->mpi350){
1532 if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_READ, ltv->an_type))
1533 return(EIO);
1534
1535 if (an_seek(sc, ltv->an_type, 0, AN_BAP1))

--- 11 unchanged lines hidden (view full) ---

1547 CSR_WRITE_2(sc, AN_DATA1, *ptr++);
1548 if (i) {
1549 ptr2 = (u_int8_t *)ptr;
1550 CSR_WRITE_1(sc, AN_DATA0, *ptr2);
1551 }
1552
1553 if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_WRITE, ltv->an_type))
1554 return(EIO);
1517 } else {
1555 } else {
1518 /* MPI-350 */
1519
1520 for (i = 0; i != AN_TIMEOUT; i++) {
1556 /* MPI-350 */
1557
1558 for (i = 0; i != AN_TIMEOUT; i++) {
1521 if (CSR_READ_2(sc, AN_COMMAND(sc->mpi350))
1559 if (CSR_READ_2(sc, AN_COMMAND(sc->mpi350))
1522 & AN_CMD_BUSY) {
1523 DELAY(10);
1524 } else
1525 break;
1526 }
1527 if (i == AN_TIMEOUT) {
1528 printf("BUSY\n");
1529 }

--- 7 unchanged lines hidden (view full) ---

1537 an_rid_desc.an_len);
1538
1539 bzero(&cmd,sizeof(cmd));
1540 bzero(&reply,sizeof(reply));
1541 cmd.an_cmd = AN_CMD_ACCESS|AN_ACCESS_WRITE;
1542 cmd.an_parm0 = ltv->an_type;
1543
1544 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
1560 & AN_CMD_BUSY) {
1561 DELAY(10);
1562 } else
1563 break;
1564 }
1565 if (i == AN_TIMEOUT) {
1566 printf("BUSY\n");
1567 }

--- 7 unchanged lines hidden (view full) ---

1575 an_rid_desc.an_len);
1576
1577 bzero(&cmd,sizeof(cmd));
1578 bzero(&reply,sizeof(reply));
1579 cmd.an_cmd = AN_CMD_ACCESS|AN_ACCESS_WRITE;
1580 cmd.an_parm0 = ltv->an_type;
1581
1582 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
1545 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
1583 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
1546 ((u_int32_t *)(void *)&an_rid_desc)[i]);
1547
1548 DELAY(100000);
1549
1550 if ((i = an_cmd_struct(sc, &cmd, &reply))) {
1584 ((u_int32_t *)(void *)&an_rid_desc)[i]);
1585
1586 DELAY(100000);
1587
1588 if ((i = an_cmd_struct(sc, &cmd, &reply))) {
1551 printf("an%d: failed to write RID 1 %x %x %x %x %x, %d\n",
1552 sc->an_unit, ltv->an_type,
1589 printf("an%d: failed to write RID 1 %x %x %x %x %x, %d\n",
1590 sc->an_unit, ltv->an_type,
1553 reply.an_status,
1554 reply.an_resp0,
1555 reply.an_resp1,
1556 reply.an_resp2,
1557 i);
1558 return(EIO);
1559 }
1560
1561
1562 if (reply.an_status & AN_CMD_QUAL_MASK) {
1591 reply.an_status,
1592 reply.an_resp0,
1593 reply.an_resp1,
1594 reply.an_resp2,
1595 i);
1596 return(EIO);
1597 }
1598
1599
1600 if (reply.an_status & AN_CMD_QUAL_MASK) {
1563 printf("an%d: failed to write RID 2 %x %x %x %x %x, %d\n",
1564 sc->an_unit, ltv->an_type,
1601 printf("an%d: failed to write RID 2 %x %x %x %x %x, %d\n",
1602 sc->an_unit, ltv->an_type,
1565 reply.an_status,
1566 reply.an_resp0,
1567 reply.an_resp1,
1568 reply.an_resp2,
1569 i);
1570 return(EIO);
1571 }
1572 DELAY(100000);

--- 163 unchanged lines hidden (view full) ---

1736 struct ifnet *ifp;
1737 struct an_ltv_genconfig *cfg;
1738 struct an_ltv_ssidlist_new *ssid;
1739 struct an_ltv_aplist *ap;
1740 struct an_ltv_gen *sp;
1741
1742 ifp = sc->an_ifp;
1743
1603 reply.an_status,
1604 reply.an_resp0,
1605 reply.an_resp1,
1606 reply.an_resp2,
1607 i);
1608 return(EIO);
1609 }
1610 DELAY(100000);

--- 163 unchanged lines hidden (view full) ---

1774 struct ifnet *ifp;
1775 struct an_ltv_genconfig *cfg;
1776 struct an_ltv_ssidlist_new *ssid;
1777 struct an_ltv_aplist *ap;
1778 struct an_ltv_gen *sp;
1779
1780 ifp = sc->an_ifp;
1781
1782 AN_LOCK_ASSERT(sc);
1744 switch (areq->an_type) {
1745 case AN_RID_GENCONFIG:
1746 cfg = (struct an_ltv_genconfig *)areq;
1747
1748 bcopy((char *)&cfg->an_macaddr, IF_LLADDR(sc->an_ifp),
1749 ETHER_ADDR_LEN);
1750
1751 bcopy((char *)cfg, (char *)&sc->an_config,

--- 24 unchanged lines hidden (view full) ---

1776 cfg->an_rates[0] = sc->an_tx_rate;
1777
1778 /* Save the new rate */
1779 sc->an_config.an_type = AN_RID_GENCONFIG;
1780 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
1781 break;
1782 case AN_RID_WEP_TEMP:
1783 /* Cache the temp keys */
1783 switch (areq->an_type) {
1784 case AN_RID_GENCONFIG:
1785 cfg = (struct an_ltv_genconfig *)areq;
1786
1787 bcopy((char *)&cfg->an_macaddr, IF_LLADDR(sc->an_ifp),
1788 ETHER_ADDR_LEN);
1789
1790 bcopy((char *)cfg, (char *)&sc->an_config,

--- 24 unchanged lines hidden (view full) ---

1815 cfg->an_rates[0] = sc->an_tx_rate;
1816
1817 /* Save the new rate */
1818 sc->an_config.an_type = AN_RID_GENCONFIG;
1819 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
1820 break;
1821 case AN_RID_WEP_TEMP:
1822 /* Cache the temp keys */
1784 bcopy(areq,
1785 &sc->an_temp_keys[((struct an_ltv_key *)areq)->kindex],
1823 bcopy(areq,
1824 &sc->an_temp_keys[((struct an_ltv_key *)areq)->kindex],
1786 sizeof(struct an_ltv_key));
1787 case AN_RID_WEP_PERM:
1788 case AN_RID_LEAPUSERNAME:
1789 case AN_RID_LEAPPASSWORD:
1825 sizeof(struct an_ltv_key));
1826 case AN_RID_WEP_PERM:
1827 case AN_RID_LEAPUSERNAME:
1828 case AN_RID_LEAPPASSWORD:
1829 AN_UNLOCK(sc);
1790 an_init(sc);
1830 an_init(sc);
1831 AN_LOCK(sc);
1791
1792 /* Disable the MAC. */
1793 an_cmd(sc, AN_CMD_DISABLE, 0);
1794
1795 /* Write the key */
1796 an_write_record(sc, (struct an_ltv_gen *)areq);
1797
1798 /* Turn the MAC back on. */

--- 24 unchanged lines hidden (view full) ---

1823 break;
1824 default:
1825 printf("an%d: unknown RID: %x\n", sc->an_unit, areq->an_type);
1826 return;
1827 }
1828
1829
1830 /* Reinitialize the card. */
1832
1833 /* Disable the MAC. */
1834 an_cmd(sc, AN_CMD_DISABLE, 0);
1835
1836 /* Write the key */
1837 an_write_record(sc, (struct an_ltv_gen *)areq);
1838
1839 /* Turn the MAC back on. */

--- 24 unchanged lines hidden (view full) ---

1864 break;
1865 default:
1866 printf("an%d: unknown RID: %x\n", sc->an_unit, areq->an_type);
1867 return;
1868 }
1869
1870
1871 /* Reinitialize the card. */
1831 if (ifp->if_flags)
1872 if (ifp->if_flags) {
1873 AN_UNLOCK(sc);
1832 an_init(sc);
1874 an_init(sc);
1875 AN_LOCK(sc);
1876 }
1833
1834 return;
1835}
1836
1837/*
1838 * Derived from Linux driver to enable promiscious mode.
1839 */
1840
1841static void
1842an_promisc(struct an_softc *sc, int promisc)
1843{
1877
1878 return;
1879}
1880
1881/*
1882 * Derived from Linux driver to enable promiscious mode.
1883 */
1884
1885static void
1886an_promisc(struct an_softc *sc, int promisc)
1887{
1888 AN_LOCK_ASSERT(sc);
1844 if (sc->an_was_monitor) {
1845 an_reset(sc);
1846 if (sc->mpi350)
1889 if (sc->an_was_monitor) {
1890 an_reset(sc);
1891 if (sc->mpi350)
1847 an_init_mpi350_desc(sc);
1892 an_init_mpi350_desc(sc);
1848 }
1893 }
1849 if (sc->an_monitor || sc->an_was_monitor)
1894 if (sc->an_monitor || sc->an_was_monitor) {
1895 AN_UNLOCK(sc);
1850 an_init(sc);
1896 an_init(sc);
1897 AN_LOCK(sc);
1898 }
1851
1852 sc->an_was_monitor = sc->an_monitor;
1853 an_cmd(sc, AN_CMD_SET_MODE, promisc ? 0xffff : 0);
1854
1855 return;
1856}
1857
1858static int

--- 12 unchanged lines hidden (view full) ---

1871 struct an_ltv_genconfig *config;
1872 struct an_ltv_key *key;
1873 struct an_ltv_status *status;
1874 struct an_ltv_ssidlist_new *ssids;
1875 int mode;
1876 struct aironet_ioctl l_ioctl;
1877
1878 sc = ifp->if_softc;
1899
1900 sc->an_was_monitor = sc->an_monitor;
1901 an_cmd(sc, AN_CMD_SET_MODE, promisc ? 0xffff : 0);
1902
1903 return;
1904}
1905
1906static int

--- 12 unchanged lines hidden (view full) ---

1919 struct an_ltv_genconfig *config;
1920 struct an_ltv_key *key;
1921 struct an_ltv_status *status;
1922 struct an_ltv_ssidlist_new *ssids;
1923 int mode;
1924 struct aironet_ioctl l_ioctl;
1925
1926 sc = ifp->if_softc;
1879 AN_LOCK(sc);
1880 ifr = (struct ifreq *)data;
1881 ireq = (struct ieee80211req *)data;
1882
1883 config = (struct an_ltv_genconfig *)&sc->areq;
1884 key = (struct an_ltv_key *)&sc->areq;
1885 status = (struct an_ltv_status *)&sc->areq;
1886 ssids = (struct an_ltv_ssidlist_new *)&sc->areq;
1887
1888 if (sc->an_gone) {
1889 error = ENODEV;
1890 goto out;
1891 }
1892
1893 switch (command) {
1894 case SIOCSIFFLAGS:
1927 ifr = (struct ifreq *)data;
1928 ireq = (struct ieee80211req *)data;
1929
1930 config = (struct an_ltv_genconfig *)&sc->areq;
1931 key = (struct an_ltv_key *)&sc->areq;
1932 status = (struct an_ltv_status *)&sc->areq;
1933 ssids = (struct an_ltv_ssidlist_new *)&sc->areq;
1934
1935 if (sc->an_gone) {
1936 error = ENODEV;
1937 goto out;
1938 }
1939
1940 switch (command) {
1941 case SIOCSIFFLAGS:
1942 AN_LOCK(sc);
1895 if (ifp->if_flags & IFF_UP) {
1896 if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
1897 ifp->if_flags & IFF_PROMISC &&
1898 !(sc->an_if_flags & IFF_PROMISC)) {
1899 an_promisc(sc, 1);
1900 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
1901 !(ifp->if_flags & IFF_PROMISC) &&
1902 sc->an_if_flags & IFF_PROMISC) {
1903 an_promisc(sc, 0);
1943 if (ifp->if_flags & IFF_UP) {
1944 if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
1945 ifp->if_flags & IFF_PROMISC &&
1946 !(sc->an_if_flags & IFF_PROMISC)) {
1947 an_promisc(sc, 1);
1948 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
1949 !(ifp->if_flags & IFF_PROMISC) &&
1950 sc->an_if_flags & IFF_PROMISC) {
1951 an_promisc(sc, 0);
1904 } else
1952 } else {
1953 AN_UNLOCK(sc);
1905 an_init(sc);
1954 an_init(sc);
1955 AN_LOCK(sc);
1956 }
1906 } else {
1957 } else {
1907 if (ifp->if_drv_flags & IFF_DRV_RUNNING)
1958 if (ifp->if_drv_flags & IFF_DRV_RUNNING) {
1959 AN_UNLOCK(sc);
1908 an_stop(sc);
1960 an_stop(sc);
1961 AN_LOCK(sc);
1962 }
1909 }
1963 }
1964 AN_UNLOCK(sc);
1910 sc->an_if_flags = ifp->if_flags;
1911 error = 0;
1912 break;
1913 case SIOCSIFMEDIA:
1914 case SIOCGIFMEDIA:
1915 error = ifmedia_ioctl(ifp, ifr, &sc->an_ifmedia, command);
1916 break;
1917 case SIOCADDMULTI:
1918 case SIOCDELMULTI:
1919 /* The Aironet has no multicast filter. */
1920 error = 0;
1921 break;
1922 case SIOCGAIRONET:
1965 sc->an_if_flags = ifp->if_flags;
1966 error = 0;
1967 break;
1968 case SIOCSIFMEDIA:
1969 case SIOCGIFMEDIA:
1970 error = ifmedia_ioctl(ifp, ifr, &sc->an_ifmedia, command);
1971 break;
1972 case SIOCADDMULTI:
1973 case SIOCDELMULTI:
1974 /* The Aironet has no multicast filter. */
1975 error = 0;
1976 break;
1977 case SIOCGAIRONET:
1923 AN_UNLOCK(sc);
1924 error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq));
1978 error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq));
1925 AN_LOCK(sc);
1926 if (error != 0)
1927 break;
1979 if (error != 0)
1980 break;
1981 AN_LOCK(sc);
1928#ifdef ANCACHE
1929 if (sc->areq.an_type == AN_RID_ZERO_CACHE) {
1930 error = priv_check(td, PRIV_DRIVER);
1931 if (error)
1932 break;
1933 sc->an_sigitems = sc->an_nextitem = 0;
1934 break;
1935 } else if (sc->areq.an_type == AN_RID_READ_CACHE) {

--- 4 unchanged lines hidden (view full) ---

1940 sc->areq.an_len = sizeof(int) / 2;
1941 bcopy((char *)&sc->an_sigcache, (char *)pt,
1942 sizeof(struct an_sigcache) * sc->an_sigitems);
1943 sc->areq.an_len += ((sizeof(struct an_sigcache) *
1944 sc->an_sigitems) / 2) + 1;
1945 } else
1946#endif
1947 if (an_read_record(sc, (struct an_ltv_gen *)&sc->areq)) {
1982#ifdef ANCACHE
1983 if (sc->areq.an_type == AN_RID_ZERO_CACHE) {
1984 error = priv_check(td, PRIV_DRIVER);
1985 if (error)
1986 break;
1987 sc->an_sigitems = sc->an_nextitem = 0;
1988 break;
1989 } else if (sc->areq.an_type == AN_RID_READ_CACHE) {

--- 4 unchanged lines hidden (view full) ---

1994 sc->areq.an_len = sizeof(int) / 2;
1995 bcopy((char *)&sc->an_sigcache, (char *)pt,
1996 sizeof(struct an_sigcache) * sc->an_sigitems);
1997 sc->areq.an_len += ((sizeof(struct an_sigcache) *
1998 sc->an_sigitems) / 2) + 1;
1999 } else
2000#endif
2001 if (an_read_record(sc, (struct an_ltv_gen *)&sc->areq)) {
2002 AN_UNLOCK(sc);
1948 error = EINVAL;
1949 break;
1950 }
1951 AN_UNLOCK(sc);
1952 error = copyout(&sc->areq, ifr->ifr_data, sizeof(sc->areq));
2003 error = EINVAL;
2004 break;
2005 }
2006 AN_UNLOCK(sc);
2007 error = copyout(&sc->areq, ifr->ifr_data, sizeof(sc->areq));
1953 AN_LOCK(sc);
1954 break;
1955 case SIOCSAIRONET:
1956 if ((error = priv_check(td, PRIV_DRIVER)))
1957 goto out;
2008 break;
2009 case SIOCSAIRONET:
2010 if ((error = priv_check(td, PRIV_DRIVER)))
2011 goto out;
1958 AN_UNLOCK(sc);
1959 error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq));
1960 AN_LOCK(sc);
2012 AN_LOCK(sc);
2013 error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq));
1961 if (error != 0)
1962 break;
1963 an_setdef(sc, &sc->areq);
2014 if (error != 0)
2015 break;
2016 an_setdef(sc, &sc->areq);
2017 AN_UNLOCK(sc);
1964 break;
1965 case SIOCGPRIVATE_0: /* used by Cisco client utility */
1966 if ((error = priv_check(td, PRIV_DRIVER)))
1967 goto out;
2018 break;
2019 case SIOCGPRIVATE_0: /* used by Cisco client utility */
2020 if ((error = priv_check(td, PRIV_DRIVER)))
2021 goto out;
1968 AN_UNLOCK(sc);
1969 error = copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
2022 error = copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
1970 AN_LOCK(sc);
1971 if (error)
1972 goto out;
1973 mode = l_ioctl.command;
1974
2023 if (error)
2024 goto out;
2025 mode = l_ioctl.command;
2026
2027 AN_LOCK(sc);
1975 if (mode >= AIROGCAP && mode <= AIROGSTATSD32) {
1976 error = readrids(ifp, &l_ioctl);
1977 } else if (mode >= AIROPCAP && mode <= AIROPLEAPUSR) {
1978 error = writerids(ifp, &l_ioctl);
1979 } else if (mode >= AIROFLSHRST && mode <= AIRORESTART) {
1980 error = flashcard(ifp, &l_ioctl);
1981 } else {
1982 error =-1;
1983 }
2028 if (mode >= AIROGCAP && mode <= AIROGSTATSD32) {
2029 error = readrids(ifp, &l_ioctl);
2030 } else if (mode >= AIROPCAP && mode <= AIROPLEAPUSR) {
2031 error = writerids(ifp, &l_ioctl);
2032 } else if (mode >= AIROFLSHRST && mode <= AIRORESTART) {
2033 error = flashcard(ifp, &l_ioctl);
2034 } else {
2035 error =-1;
2036 }
2037 AN_UNLOCK(sc);
1984 if (!error) {
1985 /* copy out the updated command info */
2038 if (!error) {
2039 /* copy out the updated command info */
1986 AN_UNLOCK(sc);
1987 error = copyout(&l_ioctl, ifr->ifr_data, sizeof(l_ioctl));
2040 error = copyout(&l_ioctl, ifr->ifr_data, sizeof(l_ioctl));
1988 AN_LOCK(sc);
1989 }
1990 break;
1991 case SIOCGPRIVATE_1: /* used by Cisco client utility */
1992 if ((error = priv_check(td, PRIV_DRIVER)))
1993 goto out;
2041 }
2042 break;
2043 case SIOCGPRIVATE_1: /* used by Cisco client utility */
2044 if ((error = priv_check(td, PRIV_DRIVER)))
2045 goto out;
1994 AN_UNLOCK(sc);
1995 error = copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
2046 error = copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
1996 AN_LOCK(sc);
1997 if (error)
1998 goto out;
1999 l_ioctl.command = 0;
2000 error = AIROMAGIC;
2047 if (error)
2048 goto out;
2049 l_ioctl.command = 0;
2050 error = AIROMAGIC;
2001 AN_UNLOCK(sc);
2002 (void) copyout(&error, l_ioctl.data, sizeof(error));
2051 (void) copyout(&error, l_ioctl.data, sizeof(error));
2003 AN_LOCK(sc);
2004 error = 0;
2005 break;
2006 case SIOCG80211:
2007 sc->areq.an_len = sizeof(sc->areq);
2008 /* was that a good idea DJA we are doing a short-cut */
2009 switch (ireq->i_type) {
2010 case IEEE80211_IOC_SSID:
2052 error = 0;
2053 break;
2054 case SIOCG80211:
2055 sc->areq.an_len = sizeof(sc->areq);
2056 /* was that a good idea DJA we are doing a short-cut */
2057 switch (ireq->i_type) {
2058 case IEEE80211_IOC_SSID:
2059 AN_LOCK(sc);
2011 if (ireq->i_val == -1) {
2012 sc->areq.an_type = AN_RID_STATUS;
2013 if (an_read_record(sc,
2014 (struct an_ltv_gen *)&sc->areq)) {
2015 error = EINVAL;
2060 if (ireq->i_val == -1) {
2061 sc->areq.an_type = AN_RID_STATUS;
2062 if (an_read_record(sc,
2063 (struct an_ltv_gen *)&sc->areq)) {
2064 error = EINVAL;
2065 AN_UNLOCK(sc);
2016 break;
2017 }
2018 len = status->an_ssidlen;
2019 tmpptr = status->an_ssid;
2020 } else if (ireq->i_val >= 0) {
2021 sc->areq.an_type = AN_RID_SSIDLIST;
2022 if (an_read_record(sc,
2023 (struct an_ltv_gen *)&sc->areq)) {
2024 error = EINVAL;
2066 break;
2067 }
2068 len = status->an_ssidlen;
2069 tmpptr = status->an_ssid;
2070 } else if (ireq->i_val >= 0) {
2071 sc->areq.an_type = AN_RID_SSIDLIST;
2072 if (an_read_record(sc,
2073 (struct an_ltv_gen *)&sc->areq)) {
2074 error = EINVAL;
2075 AN_UNLOCK(sc);
2025 break;
2026 }
2027 max = (sc->areq.an_len - 4)
2028 / sizeof(struct an_ltv_ssid_entry);
2029 if ( max > MAX_SSIDS ) {
2030 printf("To many SSIDs only using "
2031 "%d of %d\n",
2032 MAX_SSIDS, max);
2033 max = MAX_SSIDS;
2034 }
2035 if (ireq->i_val > max) {
2036 error = EINVAL;
2076 break;
2077 }
2078 max = (sc->areq.an_len - 4)
2079 / sizeof(struct an_ltv_ssid_entry);
2080 if ( max > MAX_SSIDS ) {
2081 printf("To many SSIDs only using "
2082 "%d of %d\n",
2083 MAX_SSIDS, max);
2084 max = MAX_SSIDS;
2085 }
2086 if (ireq->i_val > max) {
2087 error = EINVAL;
2088 AN_UNLOCK(sc);
2037 break;
2038 } else {
2039 len = ssids->an_entry[ireq->i_val].an_len;
2040 tmpptr = ssids->an_entry[ireq->i_val].an_ssid;
2041 }
2042 } else {
2043 error = EINVAL;
2089 break;
2090 } else {
2091 len = ssids->an_entry[ireq->i_val].an_len;
2092 tmpptr = ssids->an_entry[ireq->i_val].an_ssid;
2093 }
2094 } else {
2095 error = EINVAL;
2096 AN_UNLOCK(sc);
2044 break;
2045 }
2046 if (len > IEEE80211_NWID_LEN) {
2047 error = EINVAL;
2097 break;
2098 }
2099 if (len > IEEE80211_NWID_LEN) {
2100 error = EINVAL;
2101 AN_UNLOCK(sc);
2048 break;
2049 }
2102 break;
2103 }
2104 AN_UNLOCK(sc);
2050 ireq->i_len = len;
2051 bzero(tmpstr, IEEE80211_NWID_LEN);
2052 bcopy(tmpptr, tmpstr, len);
2105 ireq->i_len = len;
2106 bzero(tmpstr, IEEE80211_NWID_LEN);
2107 bcopy(tmpptr, tmpstr, len);
2053 AN_UNLOCK(sc);
2054 error = copyout(tmpstr, ireq->i_data,
2055 IEEE80211_NWID_LEN);
2108 error = copyout(tmpstr, ireq->i_data,
2109 IEEE80211_NWID_LEN);
2056 AN_LOCK(sc);
2057 break;
2058 case IEEE80211_IOC_NUMSSIDS:
2110 break;
2111 case IEEE80211_IOC_NUMSSIDS:
2112 AN_LOCK(sc);
2059 sc->areq.an_len = sizeof(sc->areq);
2060 sc->areq.an_type = AN_RID_SSIDLIST;
2061 if (an_read_record(sc,
2062 (struct an_ltv_gen *)&sc->areq)) {
2113 sc->areq.an_len = sizeof(sc->areq);
2114 sc->areq.an_type = AN_RID_SSIDLIST;
2115 if (an_read_record(sc,
2116 (struct an_ltv_gen *)&sc->areq)) {
2117 AN_UNLOCK(sc);
2063 error = EINVAL;
2064 break;
2065 }
2066 max = (sc->areq.an_len - 4)
2067 / sizeof(struct an_ltv_ssid_entry);
2118 error = EINVAL;
2119 break;
2120 }
2121 max = (sc->areq.an_len - 4)
2122 / sizeof(struct an_ltv_ssid_entry);
2123 AN_UNLOCK(sc);
2068 if ( max > MAX_SSIDS ) {
2069 printf("To many SSIDs only using "
2070 "%d of %d\n",
2071 MAX_SSIDS, max);
2072 max = MAX_SSIDS;
2073 }
2074 ireq->i_val = max;
2075 break;
2076 case IEEE80211_IOC_WEP:
2124 if ( max > MAX_SSIDS ) {
2125 printf("To many SSIDs only using "
2126 "%d of %d\n",
2127 MAX_SSIDS, max);
2128 max = MAX_SSIDS;
2129 }
2130 ireq->i_val = max;
2131 break;
2132 case IEEE80211_IOC_WEP:
2133 AN_LOCK(sc);
2077 sc->areq.an_type = AN_RID_ACTUALCFG;
2078 if (an_read_record(sc,
2079 (struct an_ltv_gen *)&sc->areq)) {
2080 error = EINVAL;
2134 sc->areq.an_type = AN_RID_ACTUALCFG;
2135 if (an_read_record(sc,
2136 (struct an_ltv_gen *)&sc->areq)) {
2137 error = EINVAL;
2138 AN_UNLOCK(sc);
2081 break;
2082 }
2139 break;
2140 }
2141 AN_UNLOCK(sc);
2083 if (config->an_authtype & AN_AUTHTYPE_PRIVACY_IN_USE) {
2084 if (config->an_authtype &
2085 AN_AUTHTYPE_ALLOW_UNENCRYPTED)
2086 ireq->i_val = IEEE80211_WEP_MIXED;
2087 else
2088 ireq->i_val = IEEE80211_WEP_ON;
2089 } else {
2090 ireq->i_val = IEEE80211_WEP_OFF;

--- 7 unchanged lines hidden (view full) ---

2098 * access to actual Cisco code.
2099 */
2100 if (ireq->i_val < 0 || ireq->i_val > 8) {
2101 error = EINVAL;
2102 break;
2103 }
2104 len = 0;
2105 if (ireq->i_val < 5) {
2142 if (config->an_authtype & AN_AUTHTYPE_PRIVACY_IN_USE) {
2143 if (config->an_authtype &
2144 AN_AUTHTYPE_ALLOW_UNENCRYPTED)
2145 ireq->i_val = IEEE80211_WEP_MIXED;
2146 else
2147 ireq->i_val = IEEE80211_WEP_ON;
2148 } else {
2149 ireq->i_val = IEEE80211_WEP_OFF;

--- 7 unchanged lines hidden (view full) ---

2157 * access to actual Cisco code.
2158 */
2159 if (ireq->i_val < 0 || ireq->i_val > 8) {
2160 error = EINVAL;
2161 break;
2162 }
2163 len = 0;
2164 if (ireq->i_val < 5) {
2165 AN_LOCK(sc);
2106 sc->areq.an_type = AN_RID_WEP_TEMP;
2107 for (i = 0; i < 5; i++) {
2108 if (an_read_record(sc,
2109 (struct an_ltv_gen *)&sc->areq)) {
2110 error = EINVAL;
2111 break;
2112 }
2113 if (key->kindex == 0xffff)
2114 break;
2115 if (key->kindex == ireq->i_val)
2116 len = key->klen;
2117 /* Required to get next entry */
2118 sc->areq.an_type = AN_RID_WEP_PERM;
2119 }
2166 sc->areq.an_type = AN_RID_WEP_TEMP;
2167 for (i = 0; i < 5; i++) {
2168 if (an_read_record(sc,
2169 (struct an_ltv_gen *)&sc->areq)) {
2170 error = EINVAL;
2171 break;
2172 }
2173 if (key->kindex == 0xffff)
2174 break;
2175 if (key->kindex == ireq->i_val)
2176 len = key->klen;
2177 /* Required to get next entry */
2178 sc->areq.an_type = AN_RID_WEP_PERM;
2179 }
2120 if (error != 0)
2180 AN_UNLOCK(sc);
2181 if (error != 0) {
2121 break;
2182 break;
2183 }
2122 }
2123 /* We aren't allowed to read the value of the
2124 * key from the card so we just output zeros
2125 * like we would if we could read the card, but
2126 * denied the user access.
2127 */
2128 bzero(tmpstr, len);
2129 ireq->i_len = len;
2184 }
2185 /* We aren't allowed to read the value of the
2186 * key from the card so we just output zeros
2187 * like we would if we could read the card, but
2188 * denied the user access.
2189 */
2190 bzero(tmpstr, len);
2191 ireq->i_len = len;
2130 AN_UNLOCK(sc);
2131 error = copyout(tmpstr, ireq->i_data, len);
2192 error = copyout(tmpstr, ireq->i_data, len);
2132 AN_LOCK(sc);
2133 break;
2134 case IEEE80211_IOC_NUMWEPKEYS:
2135 ireq->i_val = 9; /* include home key */
2136 break;
2137 case IEEE80211_IOC_WEPTXKEY:
2138 /*
2139 * For some strange reason, you have to read all
2140 * keys before you can read the txkey.
2141 */
2193 break;
2194 case IEEE80211_IOC_NUMWEPKEYS:
2195 ireq->i_val = 9; /* include home key */
2196 break;
2197 case IEEE80211_IOC_WEPTXKEY:
2198 /*
2199 * For some strange reason, you have to read all
2200 * keys before you can read the txkey.
2201 */
2202 AN_LOCK(sc);
2142 sc->areq.an_type = AN_RID_WEP_TEMP;
2143 for (i = 0; i < 5; i++) {
2144 if (an_read_record(sc,
2145 (struct an_ltv_gen *) &sc->areq)) {
2146 error = EINVAL;
2147 break;
2148 }
2203 sc->areq.an_type = AN_RID_WEP_TEMP;
2204 for (i = 0; i < 5; i++) {
2205 if (an_read_record(sc,
2206 (struct an_ltv_gen *) &sc->areq)) {
2207 error = EINVAL;
2208 break;
2209 }
2149 if (key->kindex == 0xffff)
2210 if (key->kindex == 0xffff) {
2150 break;
2211 break;
2212 }
2151 /* Required to get next entry */
2152 sc->areq.an_type = AN_RID_WEP_PERM;
2153 }
2213 /* Required to get next entry */
2214 sc->areq.an_type = AN_RID_WEP_PERM;
2215 }
2154 if (error != 0)
2216 if (error != 0) {
2217 AN_UNLOCK(sc);
2155 break;
2218 break;
2219 }
2156
2157 sc->areq.an_type = AN_RID_WEP_PERM;
2158 key->kindex = 0xffff;
2159 if (an_read_record(sc,
2160 (struct an_ltv_gen *)&sc->areq)) {
2161 error = EINVAL;
2220
2221 sc->areq.an_type = AN_RID_WEP_PERM;
2222 key->kindex = 0xffff;
2223 if (an_read_record(sc,
2224 (struct an_ltv_gen *)&sc->areq)) {
2225 error = EINVAL;
2226 AN_UNLOCK(sc);
2162 break;
2163 }
2164 ireq->i_val = key->mac[0];
2165 /*
2166 * Check for home mode. Map home mode into
2167 * 5th key since that is how it is stored on
2168 * the card
2169 */
2170 sc->areq.an_len = sizeof(struct an_ltv_genconfig);
2171 sc->areq.an_type = AN_RID_GENCONFIG;
2172 if (an_read_record(sc,
2173 (struct an_ltv_gen *)&sc->areq)) {
2174 error = EINVAL;
2227 break;
2228 }
2229 ireq->i_val = key->mac[0];
2230 /*
2231 * Check for home mode. Map home mode into
2232 * 5th key since that is how it is stored on
2233 * the card
2234 */
2235 sc->areq.an_len = sizeof(struct an_ltv_genconfig);
2236 sc->areq.an_type = AN_RID_GENCONFIG;
2237 if (an_read_record(sc,
2238 (struct an_ltv_gen *)&sc->areq)) {
2239 error = EINVAL;
2240 AN_UNLOCK(sc);
2175 break;
2176 }
2177 if (config->an_home_product & AN_HOME_NETWORK)
2178 ireq->i_val = 4;
2241 break;
2242 }
2243 if (config->an_home_product & AN_HOME_NETWORK)
2244 ireq->i_val = 4;
2245 AN_UNLOCK(sc);
2179 break;
2180 case IEEE80211_IOC_AUTHMODE:
2246 break;
2247 case IEEE80211_IOC_AUTHMODE:
2248 AN_LOCK(sc);
2181 sc->areq.an_type = AN_RID_ACTUALCFG;
2182 if (an_read_record(sc,
2183 (struct an_ltv_gen *)&sc->areq)) {
2184 error = EINVAL;
2249 sc->areq.an_type = AN_RID_ACTUALCFG;
2250 if (an_read_record(sc,
2251 (struct an_ltv_gen *)&sc->areq)) {
2252 error = EINVAL;
2253 AN_UNLOCK(sc);
2185 break;
2186 }
2254 break;
2255 }
2256 AN_UNLOCK(sc);
2187 if ((config->an_authtype & AN_AUTHTYPE_MASK) ==
2188 AN_AUTHTYPE_NONE) {
2189 ireq->i_val = IEEE80211_AUTH_NONE;
2190 } else if ((config->an_authtype & AN_AUTHTYPE_MASK) ==
2191 AN_AUTHTYPE_OPEN) {
2192 ireq->i_val = IEEE80211_AUTH_OPEN;
2193 } else if ((config->an_authtype & AN_AUTHTYPE_MASK) ==
2194 AN_AUTHTYPE_SHAREDKEY) {
2195 ireq->i_val = IEEE80211_AUTH_SHARED;
2196 } else
2197 error = EINVAL;
2198 break;
2199 case IEEE80211_IOC_STATIONNAME:
2257 if ((config->an_authtype & AN_AUTHTYPE_MASK) ==
2258 AN_AUTHTYPE_NONE) {
2259 ireq->i_val = IEEE80211_AUTH_NONE;
2260 } else if ((config->an_authtype & AN_AUTHTYPE_MASK) ==
2261 AN_AUTHTYPE_OPEN) {
2262 ireq->i_val = IEEE80211_AUTH_OPEN;
2263 } else if ((config->an_authtype & AN_AUTHTYPE_MASK) ==
2264 AN_AUTHTYPE_SHAREDKEY) {
2265 ireq->i_val = IEEE80211_AUTH_SHARED;
2266 } else
2267 error = EINVAL;
2268 break;
2269 case IEEE80211_IOC_STATIONNAME:
2270 AN_LOCK(sc);
2200 sc->areq.an_type = AN_RID_ACTUALCFG;
2201 if (an_read_record(sc,
2202 (struct an_ltv_gen *)&sc->areq)) {
2203 error = EINVAL;
2271 sc->areq.an_type = AN_RID_ACTUALCFG;
2272 if (an_read_record(sc,
2273 (struct an_ltv_gen *)&sc->areq)) {
2274 error = EINVAL;
2275 AN_UNLOCK(sc);
2204 break;
2205 }
2276 break;
2277 }
2278 AN_UNLOCK(sc);
2206 ireq->i_len = sizeof(config->an_nodename);
2207 tmpptr = config->an_nodename;
2208 bzero(tmpstr, IEEE80211_NWID_LEN);
2209 bcopy(tmpptr, tmpstr, ireq->i_len);
2279 ireq->i_len = sizeof(config->an_nodename);
2280 tmpptr = config->an_nodename;
2281 bzero(tmpstr, IEEE80211_NWID_LEN);
2282 bcopy(tmpptr, tmpstr, ireq->i_len);
2210 AN_UNLOCK(sc);
2211 error = copyout(tmpstr, ireq->i_data,
2212 IEEE80211_NWID_LEN);
2283 error = copyout(tmpstr, ireq->i_data,
2284 IEEE80211_NWID_LEN);
2213 AN_LOCK(sc);
2214 break;
2215 case IEEE80211_IOC_CHANNEL:
2285 break;
2286 case IEEE80211_IOC_CHANNEL:
2287 AN_LOCK(sc);
2216 sc->areq.an_type = AN_RID_STATUS;
2217 if (an_read_record(sc,
2218 (struct an_ltv_gen *)&sc->areq)) {
2219 error = EINVAL;
2288 sc->areq.an_type = AN_RID_STATUS;
2289 if (an_read_record(sc,
2290 (struct an_ltv_gen *)&sc->areq)) {
2291 error = EINVAL;
2292 AN_UNLOCK(sc);
2220 break;
2221 }
2293 break;
2294 }
2295 AN_UNLOCK(sc);
2222 ireq->i_val = status->an_cur_channel;
2223 break;
2296 ireq->i_val = status->an_cur_channel;
2297 break;
2224 case IEEE80211_IOC_CURCHAN:
2225 sc->areq.an_type = AN_RID_STATUS;
2226 if (an_read_record(sc,
2227 (struct an_ltv_gen *)&sc->areq)) {
2298 case IEEE80211_IOC_CURCHAN:
2299 AN_LOCK(sc);
2300 sc->areq.an_type = AN_RID_STATUS;
2301 if (an_read_record(sc,
2302 (struct an_ltv_gen *)&sc->areq)) {
2228 error = EINVAL;
2303 error = EINVAL;
2304 AN_UNLOCK(sc);
2229 break;
2230 }
2305 break;
2306 }
2307 AN_UNLOCK(sc);
2231 bzero(&ch, sizeof(ch));
2232 ch.ic_freq = ieee80211_ieee2mhz(status->an_cur_channel,
2233 IEEE80211_CHAN_B);
2234 ch.ic_flags = IEEE80211_CHAN_B;
2235 ch.ic_ieee = status->an_cur_channel;
2308 bzero(&ch, sizeof(ch));
2309 ch.ic_freq = ieee80211_ieee2mhz(status->an_cur_channel,
2310 IEEE80211_CHAN_B);
2311 ch.ic_flags = IEEE80211_CHAN_B;
2312 ch.ic_ieee = status->an_cur_channel;
2236 AN_UNLOCK(sc);
2237 error = copyout(&ch, ireq->i_data, sizeof(ch));
2313 error = copyout(&ch, ireq->i_data, sizeof(ch));
2238 AN_LOCK(sc);
2239 break;
2240 case IEEE80211_IOC_POWERSAVE:
2314 break;
2315 case IEEE80211_IOC_POWERSAVE:
2316 AN_LOCK(sc);
2241 sc->areq.an_type = AN_RID_ACTUALCFG;
2242 if (an_read_record(sc,
2243 (struct an_ltv_gen *)&sc->areq)) {
2244 error = EINVAL;
2317 sc->areq.an_type = AN_RID_ACTUALCFG;
2318 if (an_read_record(sc,
2319 (struct an_ltv_gen *)&sc->areq)) {
2320 error = EINVAL;
2321 AN_UNLOCK(sc);
2245 break;
2246 }
2322 break;
2323 }
2324 AN_UNLOCK(sc);
2247 if (config->an_psave_mode == AN_PSAVE_NONE) {
2248 ireq->i_val = IEEE80211_POWERSAVE_OFF;
2249 } else if (config->an_psave_mode == AN_PSAVE_CAM) {
2250 ireq->i_val = IEEE80211_POWERSAVE_CAM;
2251 } else if (config->an_psave_mode == AN_PSAVE_PSP) {
2252 ireq->i_val = IEEE80211_POWERSAVE_PSP;
2253 } else if (config->an_psave_mode == AN_PSAVE_PSP_CAM) {
2254 ireq->i_val = IEEE80211_POWERSAVE_PSP_CAM;
2255 } else
2256 error = EINVAL;
2257 break;
2258 case IEEE80211_IOC_POWERSAVESLEEP:
2325 if (config->an_psave_mode == AN_PSAVE_NONE) {
2326 ireq->i_val = IEEE80211_POWERSAVE_OFF;
2327 } else if (config->an_psave_mode == AN_PSAVE_CAM) {
2328 ireq->i_val = IEEE80211_POWERSAVE_CAM;
2329 } else if (config->an_psave_mode == AN_PSAVE_PSP) {
2330 ireq->i_val = IEEE80211_POWERSAVE_PSP;
2331 } else if (config->an_psave_mode == AN_PSAVE_PSP_CAM) {
2332 ireq->i_val = IEEE80211_POWERSAVE_PSP_CAM;
2333 } else
2334 error = EINVAL;
2335 break;
2336 case IEEE80211_IOC_POWERSAVESLEEP:
2337 AN_LOCK(sc);
2259 sc->areq.an_type = AN_RID_ACTUALCFG;
2260 if (an_read_record(sc,
2261 (struct an_ltv_gen *)&sc->areq)) {
2262 error = EINVAL;
2338 sc->areq.an_type = AN_RID_ACTUALCFG;
2339 if (an_read_record(sc,
2340 (struct an_ltv_gen *)&sc->areq)) {
2341 error = EINVAL;
2342 AN_UNLOCK(sc);
2263 break;
2264 }
2343 break;
2344 }
2345 AN_UNLOCK(sc);
2265 ireq->i_val = config->an_listen_interval;
2266 break;
2267 }
2268 break;
2269 case SIOCS80211:
2270 if ((error = priv_check(td, PRIV_NET80211_MANAGE)))
2271 goto out;
2346 ireq->i_val = config->an_listen_interval;
2347 break;
2348 }
2349 break;
2350 case SIOCS80211:
2351 if ((error = priv_check(td, PRIV_NET80211_MANAGE)))
2352 goto out;
2353 AN_LOCK(sc);
2272 sc->areq.an_len = sizeof(sc->areq);
2273 /*
2274 * We need a config structure for everything but the WEP
2275 * key management and SSIDs so we get it now so avoid
2276 * duplicating this code every time.
2277 */
2278 if (ireq->i_type != IEEE80211_IOC_SSID &&
2279 ireq->i_type != IEEE80211_IOC_WEPKEY &&
2280 ireq->i_type != IEEE80211_IOC_WEPTXKEY) {
2281 sc->areq.an_type = AN_RID_GENCONFIG;
2282 if (an_read_record(sc,
2283 (struct an_ltv_gen *)&sc->areq)) {
2284 error = EINVAL;
2354 sc->areq.an_len = sizeof(sc->areq);
2355 /*
2356 * We need a config structure for everything but the WEP
2357 * key management and SSIDs so we get it now so avoid
2358 * duplicating this code every time.
2359 */
2360 if (ireq->i_type != IEEE80211_IOC_SSID &&
2361 ireq->i_type != IEEE80211_IOC_WEPKEY &&
2362 ireq->i_type != IEEE80211_IOC_WEPTXKEY) {
2363 sc->areq.an_type = AN_RID_GENCONFIG;
2364 if (an_read_record(sc,
2365 (struct an_ltv_gen *)&sc->areq)) {
2366 error = EINVAL;
2367 AN_UNLOCK(sc);
2285 break;
2286 }
2287 }
2288 switch (ireq->i_type) {
2289 case IEEE80211_IOC_SSID:
2290 sc->areq.an_len = sizeof(sc->areq);
2291 sc->areq.an_type = AN_RID_SSIDLIST;
2292 if (an_read_record(sc,
2293 (struct an_ltv_gen *)&sc->areq)) {
2294 error = EINVAL;
2368 break;
2369 }
2370 }
2371 switch (ireq->i_type) {
2372 case IEEE80211_IOC_SSID:
2373 sc->areq.an_len = sizeof(sc->areq);
2374 sc->areq.an_type = AN_RID_SSIDLIST;
2375 if (an_read_record(sc,
2376 (struct an_ltv_gen *)&sc->areq)) {
2377 error = EINVAL;
2378 AN_UNLOCK(sc);
2295 break;
2296 }
2297 if (ireq->i_len > IEEE80211_NWID_LEN) {
2298 error = EINVAL;
2379 break;
2380 }
2381 if (ireq->i_len > IEEE80211_NWID_LEN) {
2382 error = EINVAL;
2383 AN_UNLOCK(sc);
2299 break;
2300 }
2301 max = (sc->areq.an_len - 4)
2302 / sizeof(struct an_ltv_ssid_entry);
2303 if ( max > MAX_SSIDS ) {
2304 printf("To many SSIDs only using "
2305 "%d of %d\n",
2306 MAX_SSIDS, max);
2307 max = MAX_SSIDS;
2308 }
2309 if (ireq->i_val > max) {
2310 error = EINVAL;
2384 break;
2385 }
2386 max = (sc->areq.an_len - 4)
2387 / sizeof(struct an_ltv_ssid_entry);
2388 if ( max > MAX_SSIDS ) {
2389 printf("To many SSIDs only using "
2390 "%d of %d\n",
2391 MAX_SSIDS, max);
2392 max = MAX_SSIDS;
2393 }
2394 if (ireq->i_val > max) {
2395 error = EINVAL;
2396 AN_UNLOCK(sc);
2311 break;
2312 } else {
2397 break;
2398 } else {
2313 AN_UNLOCK(sc);
2314 error = copyin(ireq->i_data,
2399 error = copyin(ireq->i_data,
2315 ssids->an_entry[ireq->i_val].an_ssid,
2400 ssids->an_entry[ireq->i_val].an_ssid,
2316 ireq->i_len);
2401 ireq->i_len);
2317 AN_LOCK(sc);
2318 ssids->an_entry[ireq->i_val].an_len
2402 ssids->an_entry[ireq->i_val].an_len
2319 = ireq->i_len;
2403 = ireq->i_len;
2404 sc->areq.an_len = sizeof(sc->areq);
2405 sc->areq.an_type = AN_RID_SSIDLIST;
2406 an_setdef(sc, &sc->areq);
2407 AN_UNLOCK(sc);
2320 break;
2321 }
2322 break;
2323 case IEEE80211_IOC_WEP:
2324 switch (ireq->i_val) {
2325 case IEEE80211_WEP_OFF:
2326 config->an_authtype &=
2327 ~(AN_AUTHTYPE_PRIVACY_IN_USE |

--- 9 unchanged lines hidden (view full) ---

2337 config->an_authtype |=
2338 AN_AUTHTYPE_PRIVACY_IN_USE |
2339 AN_AUTHTYPE_ALLOW_UNENCRYPTED;
2340 break;
2341 default:
2342 error = EINVAL;
2343 break;
2344 }
2408 break;
2409 }
2410 break;
2411 case IEEE80211_IOC_WEP:
2412 switch (ireq->i_val) {
2413 case IEEE80211_WEP_OFF:
2414 config->an_authtype &=
2415 ~(AN_AUTHTYPE_PRIVACY_IN_USE |

--- 9 unchanged lines hidden (view full) ---

2425 config->an_authtype |=
2426 AN_AUTHTYPE_PRIVACY_IN_USE |
2427 AN_AUTHTYPE_ALLOW_UNENCRYPTED;
2428 break;
2429 default:
2430 error = EINVAL;
2431 break;
2432 }
2433 if (error != EINVAL)
2434 an_setdef(sc, &sc->areq);
2435 AN_UNLOCK(sc);
2345 break;
2346 case IEEE80211_IOC_WEPKEY:
2347 if (ireq->i_val < 0 || ireq->i_val > 8 ||
2348 ireq->i_len > 13) {
2349 error = EINVAL;
2436 break;
2437 case IEEE80211_IOC_WEPKEY:
2438 if (ireq->i_val < 0 || ireq->i_val > 8 ||
2439 ireq->i_len > 13) {
2440 error = EINVAL;
2441 AN_UNLOCK(sc);
2350 break;
2351 }
2442 break;
2443 }
2352 AN_UNLOCK(sc);
2353 error = copyin(ireq->i_data, tmpstr, 13);
2444 error = copyin(ireq->i_data, tmpstr, 13);
2354 AN_LOCK(sc);
2355 if (error != 0)
2445 if (error != 0) {
2446 AN_UNLOCK(sc);
2356 break;
2447 break;
2448 }
2357 /*
2358 * Map the 9th key into the home mode
2359 * since that is how it is stored on
2360 * the card
2361 */
2362 bzero(&sc->areq, sizeof(struct an_ltv_key));
2363 sc->areq.an_len = sizeof(struct an_ltv_key);
2364 key->mac[0] = 1; /* The others are 0. */
2365 if (ireq->i_val < 4) {
2366 sc->areq.an_type = AN_RID_WEP_TEMP;
2367 key->kindex = ireq->i_val;
2368 } else {
2369 sc->areq.an_type = AN_RID_WEP_PERM;
2370 key->kindex = ireq->i_val - 4;
2371 }
2372 key->klen = ireq->i_len;
2373 bcopy(tmpstr, key->key, key->klen);
2449 /*
2450 * Map the 9th key into the home mode
2451 * since that is how it is stored on
2452 * the card
2453 */
2454 bzero(&sc->areq, sizeof(struct an_ltv_key));
2455 sc->areq.an_len = sizeof(struct an_ltv_key);
2456 key->mac[0] = 1; /* The others are 0. */
2457 if (ireq->i_val < 4) {
2458 sc->areq.an_type = AN_RID_WEP_TEMP;
2459 key->kindex = ireq->i_val;
2460 } else {
2461 sc->areq.an_type = AN_RID_WEP_PERM;
2462 key->kindex = ireq->i_val - 4;
2463 }
2464 key->klen = ireq->i_len;
2465 bcopy(tmpstr, key->key, key->klen);
2466 an_setdef(sc, &sc->areq);
2467 AN_UNLOCK(sc);
2374 break;
2375 case IEEE80211_IOC_WEPTXKEY:
2376 if (ireq->i_val < 0 || ireq->i_val > 4) {
2377 error = EINVAL;
2468 break;
2469 case IEEE80211_IOC_WEPTXKEY:
2470 if (ireq->i_val < 0 || ireq->i_val > 4) {
2471 error = EINVAL;
2472 AN_UNLOCK(sc);
2378 break;
2379 }
2380
2381 /*
2382 * Map the 5th key into the home mode
2383 * since that is how it is stored on
2384 * the card
2385 */
2386 sc->areq.an_len = sizeof(struct an_ltv_genconfig);
2387 sc->areq.an_type = AN_RID_ACTUALCFG;
2388 if (an_read_record(sc,
2473 break;
2474 }
2475
2476 /*
2477 * Map the 5th key into the home mode
2478 * since that is how it is stored on
2479 * the card
2480 */
2481 sc->areq.an_len = sizeof(struct an_ltv_genconfig);
2482 sc->areq.an_type = AN_RID_ACTUALCFG;
2483 if (an_read_record(sc,
2389 (struct an_ltv_gen *)&sc->areq)) {
2390 error = EINVAL;
2484 (struct an_ltv_gen *)&sc->areq)) {
2485 error = EINVAL;
2486 AN_UNLOCK(sc);
2391 break;
2392 }
2487 break;
2488 }
2489 AN_UNLOCK(sc);
2393 if (ireq->i_val == 4) {
2394 config->an_home_product |= AN_HOME_NETWORK;
2395 ireq->i_val = 0;
2396 } else {
2397 config->an_home_product &= ~AN_HOME_NETWORK;
2398 }
2399
2400 sc->an_config.an_home_product
2401 = config->an_home_product;
2402
2403 /* update configuration */
2404 an_init(sc);
2405
2406 bzero(&sc->areq, sizeof(struct an_ltv_key));
2490 if (ireq->i_val == 4) {
2491 config->an_home_product |= AN_HOME_NETWORK;
2492 ireq->i_val = 0;
2493 } else {
2494 config->an_home_product &= ~AN_HOME_NETWORK;
2495 }
2496
2497 sc->an_config.an_home_product
2498 = config->an_home_product;
2499
2500 /* update configuration */
2501 an_init(sc);
2502
2503 bzero(&sc->areq, sizeof(struct an_ltv_key));
2504 AN_LOCK(sc);
2407 sc->areq.an_len = sizeof(struct an_ltv_key);
2408 sc->areq.an_type = AN_RID_WEP_PERM;
2409 key->kindex = 0xffff;
2410 key->mac[0] = ireq->i_val;
2505 sc->areq.an_len = sizeof(struct an_ltv_key);
2506 sc->areq.an_type = AN_RID_WEP_PERM;
2507 key->kindex = 0xffff;
2508 key->mac[0] = ireq->i_val;
2509 an_setdef(sc, &sc->areq);
2510 AN_UNLOCK(sc);
2411 break;
2412 case IEEE80211_IOC_AUTHMODE:
2413 switch (ireq->i_val) {
2414 case IEEE80211_AUTH_NONE:
2415 config->an_authtype = AN_AUTHTYPE_NONE |
2416 (config->an_authtype & ~AN_AUTHTYPE_MASK);
2417 break;
2418 case IEEE80211_AUTH_OPEN:
2419 config->an_authtype = AN_AUTHTYPE_OPEN |
2420 (config->an_authtype & ~AN_AUTHTYPE_MASK);
2421 break;
2422 case IEEE80211_AUTH_SHARED:
2423 config->an_authtype = AN_AUTHTYPE_SHAREDKEY |
2424 (config->an_authtype & ~AN_AUTHTYPE_MASK);
2425 break;
2426 default:
2427 error = EINVAL;
2428 }
2511 break;
2512 case IEEE80211_IOC_AUTHMODE:
2513 switch (ireq->i_val) {
2514 case IEEE80211_AUTH_NONE:
2515 config->an_authtype = AN_AUTHTYPE_NONE |
2516 (config->an_authtype & ~AN_AUTHTYPE_MASK);
2517 break;
2518 case IEEE80211_AUTH_OPEN:
2519 config->an_authtype = AN_AUTHTYPE_OPEN |
2520 (config->an_authtype & ~AN_AUTHTYPE_MASK);
2521 break;
2522 case IEEE80211_AUTH_SHARED:
2523 config->an_authtype = AN_AUTHTYPE_SHAREDKEY |
2524 (config->an_authtype & ~AN_AUTHTYPE_MASK);
2525 break;
2526 default:
2527 error = EINVAL;
2528 }
2529 if (error != EINVAL) {
2530 an_setdef(sc, &sc->areq);
2531 }
2532 AN_UNLOCK(sc);
2429 break;
2430 case IEEE80211_IOC_STATIONNAME:
2431 if (ireq->i_len > 16) {
2432 error = EINVAL;
2533 break;
2534 case IEEE80211_IOC_STATIONNAME:
2535 if (ireq->i_len > 16) {
2536 error = EINVAL;
2537 AN_UNLOCK(sc);
2433 break;
2434 }
2435 bzero(config->an_nodename, 16);
2538 break;
2539 }
2540 bzero(config->an_nodename, 16);
2436 AN_UNLOCK(sc);
2437 error = copyin(ireq->i_data,
2438 config->an_nodename, ireq->i_len);
2541 error = copyin(ireq->i_data,
2542 config->an_nodename, ireq->i_len);
2439 AN_LOCK(sc);
2543 an_setdef(sc, &sc->areq);
2544 AN_UNLOCK(sc);
2440 break;
2441 case IEEE80211_IOC_CHANNEL:
2442 /*
2443 * The actual range is 1-14, but if you set it
2444 * to 0 you get the default so we let that work
2445 * too.
2446 */
2447 if (ireq->i_val < 0 || ireq->i_val >14) {
2448 error = EINVAL;
2545 break;
2546 case IEEE80211_IOC_CHANNEL:
2547 /*
2548 * The actual range is 1-14, but if you set it
2549 * to 0 you get the default so we let that work
2550 * too.
2551 */
2552 if (ireq->i_val < 0 || ireq->i_val >14) {
2553 error = EINVAL;
2554 AN_UNLOCK(sc);
2449 break;
2450 }
2451 config->an_ds_channel = ireq->i_val;
2555 break;
2556 }
2557 config->an_ds_channel = ireq->i_val;
2558 an_setdef(sc, &sc->areq);
2559 AN_UNLOCK(sc);
2452 break;
2453 case IEEE80211_IOC_POWERSAVE:
2454 switch (ireq->i_val) {
2455 case IEEE80211_POWERSAVE_OFF:
2456 config->an_psave_mode = AN_PSAVE_NONE;
2457 break;
2458 case IEEE80211_POWERSAVE_CAM:
2459 config->an_psave_mode = AN_PSAVE_CAM;
2460 break;
2461 case IEEE80211_POWERSAVE_PSP:
2462 config->an_psave_mode = AN_PSAVE_PSP;
2463 break;
2464 case IEEE80211_POWERSAVE_PSP_CAM:
2465 config->an_psave_mode = AN_PSAVE_PSP_CAM;
2466 break;
2467 default:
2468 error = EINVAL;
2469 break;
2470 }
2560 break;
2561 case IEEE80211_IOC_POWERSAVE:
2562 switch (ireq->i_val) {
2563 case IEEE80211_POWERSAVE_OFF:
2564 config->an_psave_mode = AN_PSAVE_NONE;
2565 break;
2566 case IEEE80211_POWERSAVE_CAM:
2567 config->an_psave_mode = AN_PSAVE_CAM;
2568 break;
2569 case IEEE80211_POWERSAVE_PSP:
2570 config->an_psave_mode = AN_PSAVE_PSP;
2571 break;
2572 case IEEE80211_POWERSAVE_PSP_CAM:
2573 config->an_psave_mode = AN_PSAVE_PSP_CAM;
2574 break;
2575 default:
2576 error = EINVAL;
2577 break;
2578 }
2579 an_setdef(sc, &sc->areq);
2580 AN_UNLOCK(sc);
2471 break;
2472 case IEEE80211_IOC_POWERSAVESLEEP:
2473 config->an_listen_interval = ireq->i_val;
2581 break;
2582 case IEEE80211_IOC_POWERSAVESLEEP:
2583 config->an_listen_interval = ireq->i_val;
2584 an_setdef(sc, &sc->areq);
2585 AN_UNLOCK(sc);
2474 break;
2475 }
2476
2586 break;
2587 }
2588
2477 if (!error)
2589 /*
2590 if (!error) {
2591 AN_LOCK(sc);
2478 an_setdef(sc, &sc->areq);
2592 an_setdef(sc, &sc->areq);
2593 AN_UNLOCK(sc);
2594 }
2595 */
2479 break;
2480 default:
2596 break;
2597 default:
2481 AN_UNLOCK(sc);
2482 error = ether_ioctl(ifp, command, data);
2598 error = ether_ioctl(ifp, command, data);
2483 AN_LOCK(sc);
2484 break;
2485 }
2486out:
2599 break;
2600 }
2601out:
2487 AN_UNLOCK(sc);
2488
2489 return(error != 0);
2490}
2491
2492static int
2493an_init_tx_ring(struct an_softc *sc)
2494{
2495 int i;

--- 36 unchanged lines hidden (view full) ---

2532 an_stop(sc);
2533
2534 sc->an_associated = 0;
2535
2536 /* Allocate the TX buffers */
2537 if (an_init_tx_ring(sc)) {
2538 an_reset(sc);
2539 if (sc->mpi350)
2602
2603 return(error != 0);
2604}
2605
2606static int
2607an_init_tx_ring(struct an_softc *sc)
2608{
2609 int i;

--- 36 unchanged lines hidden (view full) ---

2646 an_stop(sc);
2647
2648 sc->an_associated = 0;
2649
2650 /* Allocate the TX buffers */
2651 if (an_init_tx_ring(sc)) {
2652 an_reset(sc);
2653 if (sc->mpi350)
2540 an_init_mpi350_desc(sc);
2654 an_init_mpi350_desc(sc);
2541 if (an_init_tx_ring(sc)) {
2542 printf("an%d: tx buffer allocation "
2543 "failed\n", sc->an_unit);
2544 AN_UNLOCK(sc);
2545 return;
2546 }
2547 }
2548

--- 106 unchanged lines hidden (view full) ---

2655 break;
2656 m_freem(m0);
2657 }
2658 return;
2659 }
2660
2661 idx = sc->an_rdata.an_tx_prod;
2662
2655 if (an_init_tx_ring(sc)) {
2656 printf("an%d: tx buffer allocation "
2657 "failed\n", sc->an_unit);
2658 AN_UNLOCK(sc);
2659 return;
2660 }
2661 }
2662

--- 106 unchanged lines hidden (view full) ---

2769 break;
2770 m_freem(m0);
2771 }
2772 return;
2773 }
2774
2775 idx = sc->an_rdata.an_tx_prod;
2776
2777 AN_LOCK(sc);
2663 if (!sc->mpi350) {
2664 bzero((char *)&tx_frame_802_3, sizeof(tx_frame_802_3));
2665
2666 while (sc->an_rdata.an_tx_ring[idx] == 0) {
2667 IFQ_DRV_DEQUEUE(&ifp->if_snd, m0);
2668 if (m0 == NULL)
2669 break;
2670
2671 id = sc->an_rdata.an_tx_fids[idx];
2672 eh = mtod(m0, struct ether_header *);
2673
2674 bcopy((char *)&eh->ether_dhost,
2778 if (!sc->mpi350) {
2779 bzero((char *)&tx_frame_802_3, sizeof(tx_frame_802_3));
2780
2781 while (sc->an_rdata.an_tx_ring[idx] == 0) {
2782 IFQ_DRV_DEQUEUE(&ifp->if_snd, m0);
2783 if (m0 == NULL)
2784 break;
2785
2786 id = sc->an_rdata.an_tx_fids[idx];
2787 eh = mtod(m0, struct ether_header *);
2788
2789 bcopy((char *)&eh->ether_dhost,
2675 (char *)&tx_frame_802_3.an_tx_dst_addr,
2790 (char *)&tx_frame_802_3.an_tx_dst_addr,
2676 ETHER_ADDR_LEN);
2677 bcopy((char *)&eh->ether_shost,
2791 ETHER_ADDR_LEN);
2792 bcopy((char *)&eh->ether_shost,
2678 (char *)&tx_frame_802_3.an_tx_src_addr,
2793 (char *)&tx_frame_802_3.an_tx_src_addr,
2679 ETHER_ADDR_LEN);
2680
2681 /* minus src/dest mac & type */
2682 tx_frame_802_3.an_tx_802_3_payload_len =
2794 ETHER_ADDR_LEN);
2795
2796 /* minus src/dest mac & type */
2797 tx_frame_802_3.an_tx_802_3_payload_len =
2683 m0->m_pkthdr.len - 12;
2798 m0->m_pkthdr.len - 12;
2684
2685 m_copydata(m0, sizeof(struct ether_header) - 2 ,
2686 tx_frame_802_3.an_tx_802_3_payload_len,
2687 (caddr_t)&sc->an_txbuf);
2688
2689 txcontrol = AN_TXCTL_8023;
2690 /* write the txcontrol only */
2691 an_write_data(sc, id, 0x08, (caddr_t)&txcontrol,

--- 38 unchanged lines hidden (view full) ---

2730 break;
2731 }
2732 buf = sc->an_tx_buffer[idx].an_dma_vaddr;
2733
2734 eh = mtod(m0, struct ether_header *);
2735
2736 /* DJA optimize this to limit bcopy */
2737 bcopy((char *)&eh->ether_dhost,
2799
2800 m_copydata(m0, sizeof(struct ether_header) - 2 ,
2801 tx_frame_802_3.an_tx_802_3_payload_len,
2802 (caddr_t)&sc->an_txbuf);
2803
2804 txcontrol = AN_TXCTL_8023;
2805 /* write the txcontrol only */
2806 an_write_data(sc, id, 0x08, (caddr_t)&txcontrol,

--- 38 unchanged lines hidden (view full) ---

2845 break;
2846 }
2847 buf = sc->an_tx_buffer[idx].an_dma_vaddr;
2848
2849 eh = mtod(m0, struct ether_header *);
2850
2851 /* DJA optimize this to limit bcopy */
2852 bcopy((char *)&eh->ether_dhost,
2738 (char *)&tx_frame_802_3.an_tx_dst_addr,
2853 (char *)&tx_frame_802_3.an_tx_dst_addr,
2739 ETHER_ADDR_LEN);
2740 bcopy((char *)&eh->ether_shost,
2854 ETHER_ADDR_LEN);
2855 bcopy((char *)&eh->ether_shost,
2741 (char *)&tx_frame_802_3.an_tx_src_addr,
2856 (char *)&tx_frame_802_3.an_tx_src_addr,
2742 ETHER_ADDR_LEN);
2743
2744 /* minus src/dest mac & type */
2745 tx_frame_802_3.an_tx_802_3_payload_len =
2857 ETHER_ADDR_LEN);
2858
2859 /* minus src/dest mac & type */
2860 tx_frame_802_3.an_tx_802_3_payload_len =
2746 m0->m_pkthdr.len - 12;
2861 m0->m_pkthdr.len - 12;
2747
2748 m_copydata(m0, sizeof(struct ether_header) - 2 ,
2749 tx_frame_802_3.an_tx_802_3_payload_len,
2750 (caddr_t)&sc->an_txbuf);
2751
2752 txcontrol = AN_TXCTL_8023;
2753 /* write the txcontrol only */
2754 bcopy((caddr_t)&txcontrol, &buf[0x08],

--- 9 unchanged lines hidden (view full) ---

2764
2765
2766 bzero(&an_tx_desc, sizeof(an_tx_desc));
2767 an_tx_desc.an_offset = 0;
2768 an_tx_desc.an_eoc = 1;
2769 an_tx_desc.an_valid = 1;
2770 an_tx_desc.an_len = 0x44 +
2771 tx_frame_802_3.an_tx_802_3_payload_len;
2862
2863 m_copydata(m0, sizeof(struct ether_header) - 2 ,
2864 tx_frame_802_3.an_tx_802_3_payload_len,
2865 (caddr_t)&sc->an_txbuf);
2866
2867 txcontrol = AN_TXCTL_8023;
2868 /* write the txcontrol only */
2869 bcopy((caddr_t)&txcontrol, &buf[0x08],

--- 9 unchanged lines hidden (view full) ---

2879
2880
2881 bzero(&an_tx_desc, sizeof(an_tx_desc));
2882 an_tx_desc.an_offset = 0;
2883 an_tx_desc.an_eoc = 1;
2884 an_tx_desc.an_valid = 1;
2885 an_tx_desc.an_len = 0x44 +
2886 tx_frame_802_3.an_tx_802_3_payload_len;
2772 an_tx_desc.an_phys
2887 an_tx_desc.an_phys
2773 = sc->an_tx_buffer[idx].an_dma_paddr;
2774 for (i = 0; i < sizeof(an_tx_desc) / 4 ; i++) {
2775 CSR_MEM_AUX_WRITE_4(sc, AN_TX_DESC_OFFSET
2888 = sc->an_tx_buffer[idx].an_dma_paddr;
2889 for (i = 0; i < sizeof(an_tx_desc) / 4 ; i++) {
2890 CSR_MEM_AUX_WRITE_4(sc, AN_TX_DESC_OFFSET
2776 /* zero for now */
2891 /* zero for now */
2777 + (0 * sizeof(an_tx_desc))
2778 + (i * 4),
2779 ((u_int32_t *)(void *)&an_tx_desc)[i]);
2780 }
2781
2782 /*
2783 * If there's a BPF listner, bounce a copy of
2784 * this frame to him.

--- 10 unchanged lines hidden (view full) ---

2795 * Set a timeout in case the chip goes out to lunch.
2796 */
2797 ifp->if_timer = 5;
2798 }
2799
2800 /* Re-enable interrupts. */
2801 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS(sc->mpi350));
2802 }
2892 + (0 * sizeof(an_tx_desc))
2893 + (i * 4),
2894 ((u_int32_t *)(void *)&an_tx_desc)[i]);
2895 }
2896
2897 /*
2898 * If there's a BPF listner, bounce a copy of
2899 * this frame to him.

--- 10 unchanged lines hidden (view full) ---

2910 * Set a timeout in case the chip goes out to lunch.
2911 */
2912 ifp->if_timer = 5;
2913 }
2914
2915 /* Re-enable interrupts. */
2916 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS(sc->mpi350));
2917 }
2918 AN_UNLOCK(sc);
2803
2804 if (m0 != NULL)
2805 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
2806
2807 sc->an_rdata.an_tx_prod = idx;
2808
2809 return;
2810}

--- 46 unchanged lines hidden (view full) ---

2857 AN_UNLOCK(sc);
2858 return;
2859 }
2860
2861 printf("an%d: device timeout\n", sc->an_unit);
2862
2863 an_reset(sc);
2864 if (sc->mpi350)
2919
2920 if (m0 != NULL)
2921 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
2922
2923 sc->an_rdata.an_tx_prod = idx;
2924
2925 return;
2926}

--- 46 unchanged lines hidden (view full) ---

2973 AN_UNLOCK(sc);
2974 return;
2975 }
2976
2977 printf("an%d: device timeout\n", sc->an_unit);
2978
2979 an_reset(sc);
2980 if (sc->mpi350)
2865 an_init_mpi350_desc(sc);
2981 an_init_mpi350_desc(sc);
2982 AN_UNLOCK(sc);
2866 an_init(sc);
2867
2868 ifp->if_oerrors++;
2983 an_init(sc);
2984
2985 ifp->if_oerrors++;
2869 AN_UNLOCK(sc);
2870
2871 return;
2872}
2873
2874void
2875an_shutdown(device_t dev)
2876{
2877 struct an_softc *sc;

--- 14 unchanged lines hidden (view full) ---

2892
2893 sc = device_get_softc(dev);
2894 AN_LOCK(sc);
2895 ifp = sc->an_ifp;
2896
2897 sc->an_gone = 0;
2898 an_reset(sc);
2899 if (sc->mpi350)
2986
2987 return;
2988}
2989
2990void
2991an_shutdown(device_t dev)
2992{
2993 struct an_softc *sc;

--- 14 unchanged lines hidden (view full) ---

3008
3009 sc = device_get_softc(dev);
3010 AN_LOCK(sc);
3011 ifp = sc->an_ifp;
3012
3013 sc->an_gone = 0;
3014 an_reset(sc);
3015 if (sc->mpi350)
2900 an_init_mpi350_desc(sc);
3016 an_init_mpi350_desc(sc);
2901 an_init(sc);
2902
2903 /* Recovery temporary keys */
2904 for (i = 0; i < 4; i++) {
2905 sc->areq.an_type = AN_RID_WEP_TEMP;
3017 an_init(sc);
3018
3019 /* Recovery temporary keys */
3020 for (i = 0; i < 4; i++) {
3021 sc->areq.an_type = AN_RID_WEP_TEMP;
2906 sc->areq.an_len = sizeof(struct an_ltv_key);
3022 sc->areq.an_len = sizeof(struct an_ltv_key);
2907 bcopy(&sc->an_temp_keys[i],
2908 &sc->areq, sizeof(struct an_ltv_key));
2909 an_setdef(sc, &sc->areq);
2910 }
2911
2912 if (ifp->if_flags & IFF_UP)
2913 an_start(ifp);
2914 AN_UNLOCK(sc);

--- 171 unchanged lines hidden (view full) ---

3086 sc->an_sigcache[cache_slot].ipsrc = ip->ip_src.s_addr;
3087 }
3088 bcopy( eh->ether_shost, sc->an_sigcache[cache_slot].macsrc, 6);
3089
3090
3091 switch (an_cache_mode) {
3092 case DBM:
3093 if (sc->an_have_rssimap) {
3023 bcopy(&sc->an_temp_keys[i],
3024 &sc->areq, sizeof(struct an_ltv_key));
3025 an_setdef(sc, &sc->areq);
3026 }
3027
3028 if (ifp->if_flags & IFF_UP)
3029 an_start(ifp);
3030 AN_UNLOCK(sc);

--- 171 unchanged lines hidden (view full) ---

3202 sc->an_sigcache[cache_slot].ipsrc = ip->ip_src.s_addr;
3203 }
3204 bcopy( eh->ether_shost, sc->an_sigcache[cache_slot].macsrc, 6);
3205
3206
3207 switch (an_cache_mode) {
3208 case DBM:
3209 if (sc->an_have_rssimap) {
3094 sc->an_sigcache[cache_slot].signal =
3210 sc->an_sigcache[cache_slot].signal =
3095 - sc->an_rssimap.an_entries[rx_rssi].an_rss_dbm;
3211 - sc->an_rssimap.an_entries[rx_rssi].an_rss_dbm;
3096 sc->an_sigcache[cache_slot].quality =
3212 sc->an_sigcache[cache_slot].quality =
3097 - sc->an_rssimap.an_entries[rx_quality].an_rss_dbm;
3098 } else {
3099 sc->an_sigcache[cache_slot].signal = rx_rssi - 100;
3100 sc->an_sigcache[cache_slot].quality = rx_quality - 100;
3101 }
3102 break;
3103 case PERCENT:
3104 if (sc->an_have_rssimap) {
3213 - sc->an_rssimap.an_entries[rx_quality].an_rss_dbm;
3214 } else {
3215 sc->an_sigcache[cache_slot].signal = rx_rssi - 100;
3216 sc->an_sigcache[cache_slot].quality = rx_quality - 100;
3217 }
3218 break;
3219 case PERCENT:
3220 if (sc->an_have_rssimap) {
3105 sc->an_sigcache[cache_slot].signal =
3221 sc->an_sigcache[cache_slot].signal =
3106 sc->an_rssimap.an_entries[rx_rssi].an_rss_pct;
3222 sc->an_rssimap.an_entries[rx_rssi].an_rss_pct;
3107 sc->an_sigcache[cache_slot].quality =
3223 sc->an_sigcache[cache_slot].quality =
3108 sc->an_rssimap.an_entries[rx_quality].an_rss_pct;
3109 } else {
3110 if (rx_rssi > 100)
3111 rx_rssi = 100;
3112 if (rx_quality > 100)
3113 rx_quality = 100;
3114 sc->an_sigcache[cache_slot].signal = rx_rssi;
3115 sc->an_sigcache[cache_slot].quality = rx_quality;

--- 19 unchanged lines hidden (view full) ---

3135 int otype = sc->an_config.an_opmode;
3136 int orate = sc->an_tx_rate;
3137
3138 sc->an_tx_rate = ieee80211_media2rate(
3139 IFM_SUBTYPE(sc->an_ifmedia.ifm_cur->ifm_media));
3140 if (sc->an_tx_rate < 0)
3141 sc->an_tx_rate = 0;
3142
3224 sc->an_rssimap.an_entries[rx_quality].an_rss_pct;
3225 } else {
3226 if (rx_rssi > 100)
3227 rx_rssi = 100;
3228 if (rx_quality > 100)
3229 rx_quality = 100;
3230 sc->an_sigcache[cache_slot].signal = rx_rssi;
3231 sc->an_sigcache[cache_slot].quality = rx_quality;

--- 19 unchanged lines hidden (view full) ---

3251 int otype = sc->an_config.an_opmode;
3252 int orate = sc->an_tx_rate;
3253
3254 sc->an_tx_rate = ieee80211_media2rate(
3255 IFM_SUBTYPE(sc->an_ifmedia.ifm_cur->ifm_media));
3256 if (sc->an_tx_rate < 0)
3257 sc->an_tx_rate = 0;
3258
3259 AN_LOCK(sc);
3143 if (orate != sc->an_tx_rate) {
3144 /* Read the current configuration */
3145 sc->an_config.an_type = AN_RID_GENCONFIG;
3146 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
3147 an_read_record(sc, (struct an_ltv_gen *)&sc->an_config);
3148 cfg = &sc->an_config;
3149
3150 /* clear other rates and set the only one we want */

--- 4 unchanged lines hidden (view full) ---

3155 sc->an_config.an_type = AN_RID_GENCONFIG;
3156 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
3157 }
3158
3159 if ((sc->an_ifmedia.ifm_cur->ifm_media & IFM_IEEE80211_ADHOC) != 0)
3160 sc->an_config.an_opmode &= ~AN_OPMODE_INFRASTRUCTURE_STATION;
3161 else
3162 sc->an_config.an_opmode |= AN_OPMODE_INFRASTRUCTURE_STATION;
3260 if (orate != sc->an_tx_rate) {
3261 /* Read the current configuration */
3262 sc->an_config.an_type = AN_RID_GENCONFIG;
3263 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
3264 an_read_record(sc, (struct an_ltv_gen *)&sc->an_config);
3265 cfg = &sc->an_config;
3266
3267 /* clear other rates and set the only one we want */

--- 4 unchanged lines hidden (view full) ---

3272 sc->an_config.an_type = AN_RID_GENCONFIG;
3273 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
3274 }
3275
3276 if ((sc->an_ifmedia.ifm_cur->ifm_media & IFM_IEEE80211_ADHOC) != 0)
3277 sc->an_config.an_opmode &= ~AN_OPMODE_INFRASTRUCTURE_STATION;
3278 else
3279 sc->an_config.an_opmode |= AN_OPMODE_INFRASTRUCTURE_STATION;
3280 AN_UNLOCK(sc);
3163
3281
3164 if (otype != sc->an_config.an_opmode ||
3282 if (otype != sc->an_config.an_opmode ||
3165 orate != sc->an_tx_rate)
3166 an_init(sc);
3167
3168 return(0);
3169}
3170
3171static void
3172an_media_status(struct ifnet *ifp, struct ifmediareq *imr)
3173{
3174 struct an_ltv_status status;
3175 struct an_softc *sc = ifp->if_softc;
3176
3177 imr->ifm_active = IFM_IEEE80211;
3178
3283 orate != sc->an_tx_rate)
3284 an_init(sc);
3285
3286 return(0);
3287}
3288
3289static void
3290an_media_status(struct ifnet *ifp, struct ifmediareq *imr)
3291{
3292 struct an_ltv_status status;
3293 struct an_softc *sc = ifp->if_softc;
3294
3295 imr->ifm_active = IFM_IEEE80211;
3296
3297 AN_LOCK(sc);
3179 status.an_len = sizeof(status);
3180 status.an_type = AN_RID_STATUS;
3181 if (an_read_record(sc, (struct an_ltv_gen *)&status)) {
3182 /* If the status read fails, just lie. */
3183 imr->ifm_active = sc->an_ifmedia.ifm_cur->ifm_media;
3184 imr->ifm_status = IFM_AVALID|IFM_ACTIVE;
3185 }
3298 status.an_len = sizeof(status);
3299 status.an_type = AN_RID_STATUS;
3300 if (an_read_record(sc, (struct an_ltv_gen *)&status)) {
3301 /* If the status read fails, just lie. */
3302 imr->ifm_active = sc->an_ifmedia.ifm_cur->ifm_media;
3303 imr->ifm_status = IFM_AVALID|IFM_ACTIVE;
3304 }
3305 AN_UNLOCK(sc);
3186
3187 if (sc->an_tx_rate == 0) {
3188 imr->ifm_active = IFM_IEEE80211|IFM_AUTO;
3189 }
3190
3191 if (sc->an_config.an_opmode == AN_OPMODE_IBSS_ADHOC)
3192 imr->ifm_active |= IFM_IEEE80211_ADHOC;
3193 imr->ifm_active |= ieee80211_rate2media(NULL,

--- 88 unchanged lines hidden (view full) ---

3282
3283static int
3284writerids(struct ifnet *ifp, struct aironet_ioctl *l_ioctl)
3285{
3286 struct an_softc *sc;
3287 int rid, command, error;
3288
3289 sc = ifp->if_softc;
3306
3307 if (sc->an_tx_rate == 0) {
3308 imr->ifm_active = IFM_IEEE80211|IFM_AUTO;
3309 }
3310
3311 if (sc->an_config.an_opmode == AN_OPMODE_IBSS_ADHOC)
3312 imr->ifm_active |= IFM_IEEE80211_ADHOC;
3313 imr->ifm_active |= ieee80211_rate2media(NULL,

--- 88 unchanged lines hidden (view full) ---

3402
3403static int
3404writerids(struct ifnet *ifp, struct aironet_ioctl *l_ioctl)
3405{
3406 struct an_softc *sc;
3407 int rid, command, error;
3408
3409 sc = ifp->if_softc;
3410 AN_LOCK_ASSERT(sc);
3290 rid = 0;
3291 command = l_ioctl->command;
3292
3293 switch (command) {
3294 case AIROPSIDS:
3295 rid = AN_RID_SSIDLIST;
3296 break;
3297 case AIROPCAP:

--- 93 unchanged lines hidden (view full) ---

3391#define FLASH_SIZE 32 * 1024
3392
3393static int
3394unstickbusy(struct ifnet *ifp)
3395{
3396 struct an_softc *sc = ifp->if_softc;
3397
3398 if (CSR_READ_2(sc, AN_COMMAND(sc->mpi350)) & AN_CMD_BUSY) {
3411 rid = 0;
3412 command = l_ioctl->command;
3413
3414 switch (command) {
3415 case AIROPSIDS:
3416 rid = AN_RID_SSIDLIST;
3417 break;
3418 case AIROPCAP:

--- 93 unchanged lines hidden (view full) ---

3512#define FLASH_SIZE 32 * 1024
3513
3514static int
3515unstickbusy(struct ifnet *ifp)
3516{
3517 struct an_softc *sc = ifp->if_softc;
3518
3519 if (CSR_READ_2(sc, AN_COMMAND(sc->mpi350)) & AN_CMD_BUSY) {
3399 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350),
3520 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350),
3400 AN_EV_CLR_STUCK_BUSY);
3401 return 1;
3402 }
3403 return 0;
3404}
3405
3406/*
3407 * Wait for busy completion from card wait for delay uSec's Return true for

--- 27 unchanged lines hidden (view full) ---

3435static int
3436cmdreset(struct ifnet *ifp)
3437{
3438 int status;
3439 struct an_softc *sc = ifp->if_softc;
3440
3441 an_stop(sc);
3442
3521 AN_EV_CLR_STUCK_BUSY);
3522 return 1;
3523 }
3524 return 0;
3525}
3526
3527/*
3528 * Wait for busy completion from card wait for delay uSec's Return true for

--- 27 unchanged lines hidden (view full) ---

3556static int
3557cmdreset(struct ifnet *ifp)
3558{
3559 int status;
3560 struct an_softc *sc = ifp->if_softc;
3561
3562 an_stop(sc);
3563
3564 AN_LOCK(sc);
3443 an_cmd(sc, AN_CMD_DISABLE, 0);
3444
3445 if (!(status = WaitBusy(ifp, AN_TIMEOUT))) {
3446 printf("an%d: Waitbusy hang b4 RESET =%d\n",
3447 sc->an_unit, status);
3565 an_cmd(sc, AN_CMD_DISABLE, 0);
3566
3567 if (!(status = WaitBusy(ifp, AN_TIMEOUT))) {
3568 printf("an%d: Waitbusy hang b4 RESET =%d\n",
3569 sc->an_unit, status);
3570 AN_UNLOCK(sc);
3448 return -EBUSY;
3449 }
3450 CSR_WRITE_2(sc, AN_COMMAND(sc->mpi350), AN_CMD_FW_RESTART);
3451
3452 FLASH_DELAY(sc, 1000); /* WAS 600 12/7/00 */
3453
3454
3455 if (!(status = WaitBusy(ifp, 100))) {
3456 printf("an%d: Waitbusy hang AFTER RESET =%d\n",
3457 sc->an_unit, status);
3571 return -EBUSY;
3572 }
3573 CSR_WRITE_2(sc, AN_COMMAND(sc->mpi350), AN_CMD_FW_RESTART);
3574
3575 FLASH_DELAY(sc, 1000); /* WAS 600 12/7/00 */
3576
3577
3578 if (!(status = WaitBusy(ifp, 100))) {
3579 printf("an%d: Waitbusy hang AFTER RESET =%d\n",
3580 sc->an_unit, status);
3581 AN_UNLOCK(sc);
3458 return -EBUSY;
3459 }
3582 return -EBUSY;
3583 }
3584 AN_UNLOCK(sc);
3460 return 0;
3461}
3462
3463/*
3464 * STEP 2) Put the card in legendary flash mode
3465 */
3466
3467static int

--- 132 unchanged lines hidden (view full) ---

3600 CSR_WRITE_2(sc, AN_AUX_PAGE, 0x100);
3601 CSR_WRITE_2(sc, AN_AUX_OFFSET, 0);
3602
3603 for (nwords = 0; nwords != FLASH_SIZE / 2; nwords++) {
3604 CSR_WRITE_2(sc, AN_AUX_DATA, bufp[nwords] & 0xffff);
3605 }
3606 } else {
3607 for (nwords = 0; nwords != FLASH_SIZE / 4; nwords++) {
3585 return 0;
3586}
3587
3588/*
3589 * STEP 2) Put the card in legendary flash mode
3590 */
3591
3592static int

--- 132 unchanged lines hidden (view full) ---

3725 CSR_WRITE_2(sc, AN_AUX_PAGE, 0x100);
3726 CSR_WRITE_2(sc, AN_AUX_OFFSET, 0);
3727
3728 for (nwords = 0; nwords != FLASH_SIZE / 2; nwords++) {
3729 CSR_WRITE_2(sc, AN_AUX_DATA, bufp[nwords] & 0xffff);
3730 }
3731 } else {
3732 for (nwords = 0; nwords != FLASH_SIZE / 4; nwords++) {
3608 CSR_MEM_AUX_WRITE_4(sc, 0x8000,
3733 CSR_MEM_AUX_WRITE_4(sc, 0x8000,
3609 ((u_int32_t *)bufp)[nwords] & 0xffff);
3610 }
3611 }
3612
3613 CSR_WRITE_2(sc, AN_SW0(sc->mpi350), 0x8000);
3614
3615 return 0;
3616}

--- 5 unchanged lines hidden (view full) ---

3622static int
3623flashrestart(struct ifnet *ifp)
3624{
3625 int status = 0;
3626 struct an_softc *sc = ifp->if_softc;
3627
3628 FLASH_DELAY(sc, 1024); /* Added 12/7/00 */
3629
3734 ((u_int32_t *)bufp)[nwords] & 0xffff);
3735 }
3736 }
3737
3738 CSR_WRITE_2(sc, AN_SW0(sc->mpi350), 0x8000);
3739
3740 return 0;
3741}

--- 5 unchanged lines hidden (view full) ---

3747static int
3748flashrestart(struct ifnet *ifp)
3749{
3750 int status = 0;
3751 struct an_softc *sc = ifp->if_softc;
3752
3753 FLASH_DELAY(sc, 1024); /* Added 12/7/00 */
3754
3755 AN_UNLOCK(sc);
3630 an_init(sc);
3756 an_init(sc);
3757 AN_LOCK(sc);
3631
3632 FLASH_DELAY(sc, 1024); /* Added 12/7/00 */
3633 return status;
3634}
3635
3636/*
3637 * Entry point for flash ioclt.
3638 */
3639
3640static int
3641flashcard(struct ifnet *ifp, struct aironet_ioctl *l_ioctl)
3642{
3643 int z = 0, status;
3644 struct an_softc *sc;
3645
3646 sc = ifp->if_softc;
3647 if (sc->mpi350) {
3758
3759 FLASH_DELAY(sc, 1024); /* Added 12/7/00 */
3760 return status;
3761}
3762
3763/*
3764 * Entry point for flash ioclt.
3765 */
3766
3767static int
3768flashcard(struct ifnet *ifp, struct aironet_ioctl *l_ioctl)
3769{
3770 int z = 0, status;
3771 struct an_softc *sc;
3772
3773 sc = ifp->if_softc;
3774 if (sc->mpi350) {
3648 printf("an%d: flashing not supported on MPI 350 yet\n",
3775 printf("an%d: flashing not supported on MPI 350 yet\n",
3649 sc->an_unit);
3650 return(-1);
3651 }
3652 status = l_ioctl->command;
3653
3654 switch (l_ioctl->command) {
3655 case AIROFLSHRST:
3656 return cmdreset(ifp);

--- 67 unchanged lines hidden ---
3776 sc->an_unit);
3777 return(-1);
3778 }
3779 status = l_ioctl->command;
3780
3781 switch (l_ioctl->command) {
3782 case AIROFLSHRST:
3783 return cmdreset(ifp);

--- 67 unchanged lines hidden ---