Deleted Added
full compact
if_an.c (188128) if_an.c (198987)
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 188128 2009-02-04 20:39:45Z imp $");
41__FBSDID("$FreeBSD: head/sys/dev/an/if_an.c 198987 2009-11-06 14:52:37Z jhb $");
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.

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

344
345 /*
346 * We need to fake up a softc structure long enough
347 * to be able to issue commands and call some of the
348 * other routines.
349 */
350 sc->an_bhandle = rman_get_bushandle(sc->port_res);
351 sc->an_btag = rman_get_bustag(sc->port_res);
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.

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

344
345 /*
346 * We need to fake up a softc structure long enough
347 * to be able to issue commands and call some of the
348 * other routines.
349 */
350 sc->an_bhandle = rman_get_bushandle(sc->port_res);
351 sc->an_btag = rman_get_bustag(sc->port_res);
352 sc->an_unit = device_get_unit(dev);
353
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);

--- 234 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)) {
352
353 ssid.an_len = sizeof(ssid);
354 ssid.an_type = AN_RID_SSIDLIST;
355
356 /* Make sure interrupts are disabled. */
357 sc->mpi350 = 0;
358 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
359 CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), 0xFFFF);

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

594 * Allocate RX descriptor
595 */
596 bzero(&reply,sizeof(reply));
597 cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
598 cmd_struct.an_parm0 = AN_DESCRIPTOR_RX;
599 cmd_struct.an_parm1 = AN_RX_DESC_OFFSET;
600 cmd_struct.an_parm2 = AN_MAX_RX_DESC;
601 if (an_cmd_struct(sc, &cmd_struct, &reply)) {
603 printf("an%d: failed to allocate RX descriptor\n",
604 sc->an_unit);
602 if_printf(sc->an_ifp, "failed to allocate RX descriptor\n");
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;
612 an_rx_desc.an_done = 0;

--- 11 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)) {
603 return(EIO);
604 }
605
606 for (desc = 0; desc < AN_MAX_RX_DESC; desc++) {
607 bzero(&an_rx_desc, sizeof(an_rx_desc));
608 an_rx_desc.an_valid = 1;
609 an_rx_desc.an_len = AN_RX_BUFFER_SIZE;
610 an_rx_desc.an_done = 0;

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

622 */
623
624 bzero(&reply,sizeof(reply));
625 cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
626 cmd_struct.an_parm0 = AN_DESCRIPTOR_TX;
627 cmd_struct.an_parm1 = AN_TX_DESC_OFFSET;
628 cmd_struct.an_parm2 = AN_MAX_TX_DESC;
629 if (an_cmd_struct(sc, &cmd_struct, &reply)) {
632 printf("an%d: failed to allocate TX descriptor\n",
633 sc->an_unit);
630 if_printf(sc->an_ifp, "failed to allocate TX descriptor\n");
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;
641 an_tx_desc.an_valid = 0;

--- 12 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 return(EIO);
632 }
633
634 for (desc = 0; desc < AN_MAX_TX_DESC; desc++) {
635 bzero(&an_tx_desc, sizeof(an_tx_desc));
636 an_tx_desc.an_offset = 0;
637 an_tx_desc.an_eoc = 0;
638 an_tx_desc.an_valid = 0;

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

651 */
652
653 bzero(&reply,sizeof(reply));
654 cmd_struct.an_cmd = AN_CMD_ALLOC_DESC;
655 cmd_struct.an_parm0 = AN_DESCRIPTOR_HOSTRW;
656 cmd_struct.an_parm1 = AN_HOST_DESC_OFFSET;
657 cmd_struct.an_parm2 = 1;
658 if (an_cmd_struct(sc, &cmd_struct, &reply)) {
662 printf("an%d: failed to allocate host descriptor\n",
663 sc->an_unit);
659 if_printf(sc->an_ifp, "failed to allocate host descriptor\n");
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;

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

682{
683 struct ifnet *ifp;
684 int error = EIO;
685 int i, nrate, mword;
686 u_int8_t r;
687
688 ifp = sc->an_ifp = if_alloc(IFT_ETHER);
689 if (ifp == NULL) {
660 return(EIO);
661 }
662
663 bzero(&an_rid_desc, sizeof(an_rid_desc));
664 an_rid_desc.an_valid = 1;
665 an_rid_desc.an_len = AN_RID_BUFFER_SIZE;
666 an_rid_desc.an_rid = 0;
667 an_rid_desc.an_phys = sc->an_rid_buffer.an_dma_paddr;

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

678{
679 struct ifnet *ifp;
680 int error = EIO;
681 int i, nrate, mword;
682 u_int8_t r;
683
684 ifp = sc->an_ifp = if_alloc(IFT_ETHER);
685 if (ifp == NULL) {
690 printf("an%d: can not if_alloc()\n", sc->an_unit);
686 device_printf(sc->an_dev, "can not if_alloc()\n");
691 goto fail;
692 }
693
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;

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

703 if (sc->mpi350) {
704 error = an_init_mpi350_desc(sc);
705 if (error)
706 goto fail;
707 }
708
709 /* Load factory config */
710 if (an_cmd(sc, AN_CMD_READCFG, 0)) {
687 goto fail;
688 }
689
690 sc->an_gone = 0;
691 sc->an_associated = 0;
692 sc->an_monitor = 0;
693 sc->an_was_monitor = 0;
694 sc->an_flash_buffer = NULL;

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

699 if (sc->mpi350) {
700 error = an_init_mpi350_desc(sc);
701 if (error)
702 goto fail;
703 }
704
705 /* Load factory config */
706 if (an_cmd(sc, AN_CMD_READCFG, 0)) {
711 printf("an%d: failed to load config data\n", sc->an_unit);
707 device_printf(sc->an_dev, "failed to load config data\n");
712 goto fail;
713 }
714
715 /* Read the current configuration */
716 sc->an_config.an_type = AN_RID_GENCONFIG;
717 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
718 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_config)) {
708 goto fail;
709 }
710
711 /* Read the current configuration */
712 sc->an_config.an_type = AN_RID_GENCONFIG;
713 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
714 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_config)) {
719 printf("an%d: read record failed\n", sc->an_unit);
715 device_printf(sc->an_dev, "read record failed\n");
720 goto fail;
721 }
722
723 /* Read the card capabilities */
724 sc->an_caps.an_type = AN_RID_CAPABILITIES;
725 sc->an_caps.an_len = sizeof(struct an_ltv_caps);
726 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_caps)) {
716 goto fail;
717 }
718
719 /* Read the card capabilities */
720 sc->an_caps.an_type = AN_RID_CAPABILITIES;
721 sc->an_caps.an_len = sizeof(struct an_ltv_caps);
722 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_caps)) {
727 printf("an%d: read record failed\n", sc->an_unit);
723 device_printf(sc->an_dev, "read record failed\n");
728 goto fail;
729 }
730
731 /* Read ssid list */
732 sc->an_ssidlist.an_type = AN_RID_SSIDLIST;
733 sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new);
734 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) {
724 goto fail;
725 }
726
727 /* Read ssid list */
728 sc->an_ssidlist.an_type = AN_RID_SSIDLIST;
729 sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new);
730 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) {
735 printf("an%d: read record failed\n", sc->an_unit);
731 device_printf(sc->an_dev, "read record failed\n");
736 goto fail;
737 }
738
739 /* Read AP list */
740 sc->an_aplist.an_type = AN_RID_APLIST;
741 sc->an_aplist.an_len = sizeof(struct an_ltv_aplist);
742 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) {
732 goto fail;
733 }
734
735 /* Read AP list */
736 sc->an_aplist.an_type = AN_RID_APLIST;
737 sc->an_aplist.an_len = sizeof(struct an_ltv_aplist);
738 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) {
743 printf("an%d: read record failed\n", sc->an_unit);
739 device_printf(sc->an_dev, "read record failed\n");
744 goto fail;
745 }
746
747#ifdef ANCACHE
748 /* Read the RSSI <-> dBm map */
749 sc->an_have_rssimap = 0;
750 if (sc->an_caps.an_softcaps & 8) {
751 sc->an_rssimap.an_type = AN_RID_RSSI_MAP;
752 sc->an_rssimap.an_len = sizeof(struct an_ltv_rssi_map);
753 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_rssimap)) {
740 goto fail;
741 }
742
743#ifdef ANCACHE
744 /* Read the RSSI <-> dBm map */
745 sc->an_have_rssimap = 0;
746 if (sc->an_caps.an_softcaps & 8) {
747 sc->an_rssimap.an_type = AN_RID_RSSI_MAP;
748 sc->an_rssimap.an_len = sizeof(struct an_ltv_rssi_map);
749 if (an_read_record(sc, (struct an_ltv_gen *)&sc->an_rssimap)) {
754 printf("an%d: unable to get RSSI <-> dBM map\n", sc->an_unit);
750 device_printf(sc->an_dev,
751 "unable to get RSSI <-> dBM map\n");
755 } else {
752 } else {
756 printf("an%d: got RSSI <-> dBM map\n", sc->an_unit);
753 device_printf(sc->an_dev, "got RSSI <-> dBM map\n");
757 sc->an_have_rssimap = 1;
758 }
759 } else {
754 sc->an_have_rssimap = 1;
755 }
756 } else {
760 printf("an%d: no RSSI <-> dBM map\n", sc->an_unit);
757 device_printf(sc->an_dev, "no RSSI <-> dBM map\n");
761 }
762#endif
763 AN_UNLOCK(sc);
764
765 ifp->if_softc = sc;
758 }
759#endif
760 AN_UNLOCK(sc);
761
762 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;
772 ifp->if_start = an_start;
773 ifp->if_watchdog = an_watchdog;
774 ifp->if_init = an_init;

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

902 return;
903 }
904
905 if (sc->an_monitor & AN_MONITOR_AIRONET_HEADER) {
906 len = rx_frame.an_rx_payload_len
907 + sizeof(rx_frame);
908 /* Check for insane frame length */
909 if (len > sizeof(sc->buf_802_11)) {
763 if_initname(ifp, device_get_name(sc->an_dev),
764 device_get_unit(sc->an_dev));
765 ifp->if_mtu = ETHERMTU;
766 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
767 ifp->if_ioctl = an_ioctl;
768 ifp->if_start = an_start;
769 ifp->if_watchdog = an_watchdog;
770 ifp->if_init = an_init;

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

898 return;
899 }
900
901 if (sc->an_monitor & AN_MONITOR_AIRONET_HEADER) {
902 len = rx_frame.an_rx_payload_len
903 + sizeof(rx_frame);
904 /* Check for insane frame length */
905 if (len > sizeof(sc->buf_802_11)) {
910 printf("an%d: oversized packet "
906 if_printf(ifp, "oversized packet "
911 "received (%d, %d)\n",
907 "received (%d, %d)\n",
912 sc->an_unit, len, MCLBYTES);
908 len, MCLBYTES);
913 ifp->if_ierrors++;
914 return;
915 }
916
917 bcopy((char *)&rx_frame,
918 bpf_buf, sizeof(rx_frame));
919
920 error = an_read_data(sc, id, sizeof(rx_frame),

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

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;
934 /* Check for insane frame length */
935 if (len > sizeof(sc->buf_802_11)) {
909 ifp->if_ierrors++;
910 return;
911 }
912
913 bcopy((char *)&rx_frame,
914 bpf_buf, sizeof(rx_frame));
915
916 error = an_read_data(sc, id, sizeof(rx_frame),

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

924 (fc1 & IEEE80211_FC1_DIR_FROMDS)) {
925 ieee80211_header_len += ETHER_ADDR_LEN;
926 }
927
928 len = rx_frame.an_rx_payload_len
929 + ieee80211_header_len;
930 /* Check for insane frame length */
931 if (len > sizeof(sc->buf_802_11)) {
936 printf("an%d: oversized packet "
932 if_printf(ifp, "oversized packet "
937 "received (%d, %d)\n",
933 "received (%d, %d)\n",
938 sc->an_unit, len, MCLBYTES);
934 len, MCLBYTES);
939 ifp->if_ierrors++;
940 return;
941 }
942
943 ih = (struct ieee80211_frame *)bpf_buf;
944
945 bcopy((char *)&rx_frame.an_frame_ctl,
946 (char *)ih, ieee80211_header_len);

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

988 m_freem(m);
989 ifp->if_ierrors++;
990 return;
991 }
992 /* Check for insane frame length */
993 len = rx_frame_802_3.an_rx_802_3_payload_len;
994 if (len > sizeof(sc->buf_802_11)) {
995 m_freem(m);
935 ifp->if_ierrors++;
936 return;
937 }
938
939 ih = (struct ieee80211_frame *)bpf_buf;
940
941 bcopy((char *)&rx_frame.an_frame_ctl,
942 (char *)ih, ieee80211_header_len);

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

984 m_freem(m);
985 ifp->if_ierrors++;
986 return;
987 }
988 /* Check for insane frame length */
989 len = rx_frame_802_3.an_rx_802_3_payload_len;
990 if (len > sizeof(sc->buf_802_11)) {
991 m_freem(m);
996 printf("an%d: oversized packet "
992 if_printf(ifp, "oversized packet "
997 "received (%d, %d)\n",
993 "received (%d, %d)\n",
998 sc->an_unit, len, MCLBYTES);
994 len, MCLBYTES);
999 ifp->if_ierrors++;
1000 return;
1001 }
1002 m->m_pkthdr.len = m->m_len =
1003 rx_frame_802_3.an_rx_802_3_payload_len + 12;
1004
1005 eh = mtod(m, struct ether_header *);
1006

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

1068 bcopy(buf, (caddr_t)&rx_frame,
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);
995 ifp->if_ierrors++;
996 return;
997 }
998 m->m_pkthdr.len = m->m_len =
999 rx_frame_802_3.an_rx_802_3_payload_len + 12;
1000
1001 eh = mtod(m, struct ether_header *);
1002

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

1064 bcopy(buf, (caddr_t)&rx_frame,
1065 sizeof(rx_frame));
1066#endif
1067#endif
1068 /* Check for insane frame length */
1069 len = an_rx_desc.an_len + 12;
1070 if (len > MCLBYTES) {
1071 m_freem(m);
1076 printf("an%d: oversized packet "
1072 if_printf(ifp, "oversized packet "
1077 "received (%d, %d)\n",
1073 "received (%d, %d)\n",
1078 sc->an_unit, len, MCLBYTES);
1074 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;
1085
1086 eh = mtod(m, struct ether_header *);

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

1111 for (i = 0; i < sizeof(an_rx_desc) / 4; i++)
1112 CSR_MEM_AUX_WRITE_4(sc,
1113 AN_RX_DESC_OFFSET
1114 + (count * sizeof(an_rx_desc))
1115 + (i * 4),
1116 ((u_int32_t *)(void *)&an_rx_desc)[i]);
1117
1118 } else {
1075 ifp->if_ierrors++;
1076 return;
1077 }
1078
1079 m->m_pkthdr.len = m->m_len =
1080 an_rx_desc.an_len + 12;
1081
1082 eh = mtod(m, struct ether_header *);

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

1107 for (i = 0; i < sizeof(an_rx_desc) / 4; i++)
1108 CSR_MEM_AUX_WRITE_4(sc,
1109 AN_RX_DESC_OFFSET
1110 + (count * sizeof(an_rx_desc))
1111 + (i * 4),
1112 ((u_int32_t *)(void *)&an_rx_desc)[i]);
1113
1114 } else {
1119 printf("an%d: Didn't get valid RX packet "
1115 if_printf(ifp, "Didn't get valid RX packet "
1120 "%x %x %d\n",
1116 "%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

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

1388 return;
1389
1390 AN_LOCK_ASSERT(sc);
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)
1117 an_rx_desc.an_done,
1118 an_rx_desc.an_valid, an_rx_desc.an_len);
1119 }
1120 }
1121 }
1122}
1123
1124static void

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

1383 return;
1384
1385 AN_LOCK_ASSERT(sc);
1386 an_cmd(sc, AN_CMD_ENABLE, 0);
1387 an_cmd(sc, AN_CMD_FW_RESTART, 0);
1388 an_cmd(sc, AN_CMD_NOOP2, 0);
1389
1390 if (an_cmd(sc, AN_CMD_FORCE_SYNCLOSS, 0) == ETIMEDOUT)
1396 printf("an%d: reset failed\n", sc->an_unit);
1391 if_printf(sc->an_ifp, "reset failed\n");
1397
1398 an_cmd(sc, AN_CMD_DISABLE, 0);
1399
1400 return;
1401}
1402
1403/*
1404 * Read an LTV record from the NIC.
1405 */
1406static int
1407an_read_record(struct an_softc *sc, struct an_ltv_gen *ltv)
1408{
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;
1392
1393 an_cmd(sc, AN_CMD_DISABLE, 0);
1394
1395 return;
1396}
1397
1398/*
1399 * Read an LTV record from the NIC.
1400 */
1401static int
1402an_read_record(struct an_softc *sc, struct an_ltv_gen *ltv)
1403{
1404 struct an_ltv_gen *an_ltv;
1405 struct an_card_rid_desc an_rid_desc;
1406 struct an_command cmd;
1407 struct an_reply reply;
1408 struct ifnet *ifp;
1413 u_int16_t *ptr;
1414 u_int8_t *ptr2;
1415 int i, len;
1416
1417 AN_LOCK_ASSERT(sc);
1418 if (ltv->an_len < 4 || ltv->an_type == 0)
1419 return(EINVAL);
1420
1409 u_int16_t *ptr;
1410 u_int8_t *ptr2;
1411 int i, len;
1412
1413 AN_LOCK_ASSERT(sc);
1414 if (ltv->an_len < 4 || ltv->an_type == 0)
1415 return(EINVAL);
1416
1417 ifp = sc->an_ifp;
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)) {
1418 if (!sc->mpi350){
1419 /* Tell the NIC to enter record read mode. */
1420 if (an_cmd(sc, AN_CMD_ACCESS|AN_ACCESS_READ, ltv->an_type)) {
1424 printf("an%d: RID access failed\n", sc->an_unit);
1421 if_printf(ifp, "RID access failed\n");
1425 return(EIO);
1426 }
1427
1428 /* Seek to the record. */
1429 if (an_seek(sc, ltv->an_type, 0, AN_BAP1)) {
1422 return(EIO);
1423 }
1424
1425 /* Seek to the record. */
1426 if (an_seek(sc, ltv->an_type, 0, AN_BAP1)) {
1430 printf("an%d: seek to record failed\n", sc->an_unit);
1427 if_printf(ifp, "seek to record failed\n");
1431 return(EIO);
1432 }
1433
1434 /*
1435 * Read the length and record type and make sure they
1436 * match what we expect (this verifies that we have enough
1437 * room to hold all of the returned data).
1438 * Length includes type but not length.
1439 */
1440 len = CSR_READ_2(sc, AN_DATA1);
1441 if (len > (ltv->an_len - 2)) {
1428 return(EIO);
1429 }
1430
1431 /*
1432 * Read the length and record type and make sure they
1433 * match what we expect (this verifies that we have enough
1434 * room to hold all of the returned data).
1435 * Length includes type but not length.
1436 */
1437 len = CSR_READ_2(sc, AN_DATA1);
1438 if (len > (ltv->an_len - 2)) {
1442 printf("an%d: record length mismatch -- expected %d, "
1443 "got %d for Rid %x\n", sc->an_unit,
1439 if_printf(ifp, "record length mismatch -- expected %d, "
1440 "got %d for Rid %x\n",
1444 ltv->an_len - 2, len, ltv->an_type);
1445 len = ltv->an_len - 2;
1446 } else {
1447 ltv->an_len = len + 2;
1448 }
1449
1450 /* Now read the data. */
1451 len -= 2; /* skip the type */

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

1471 cmd.an_parm0 = ltv->an_type;
1472
1473 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
1474 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
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) {
1441 ltv->an_len - 2, len, ltv->an_type);
1442 len = ltv->an_len - 2;
1443 } else {
1444 ltv->an_len = len + 2;
1445 }
1446
1447 /* Now read the data. */
1448 len -= 2; /* skip the type */

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

1468 cmd.an_parm0 = ltv->an_type;
1469
1470 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
1471 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
1472 ((u_int32_t *)(void *)&an_rid_desc)[i]);
1473
1474 if (an_cmd_struct(sc, &cmd, &reply)
1475 || reply.an_status & AN_CMD_QUAL_MASK) {
1479 printf("an%d: failed to read RID %x %x %x %x %x, %d\n",
1480 sc->an_unit, ltv->an_type,
1476 if_printf(ifp, "failed to read RID %x %x %x %x %x, %d\n",
1477 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
1489 an_ltv = (struct an_ltv_gen *)sc->an_rid_buffer.an_dma_vaddr;
1490 if (an_ltv->an_len + 2 < an_rid_desc.an_len) {
1491 an_rid_desc.an_len = an_ltv->an_len;
1492 }
1493
1494 len = an_rid_desc.an_len;
1495 if (len > (ltv->an_len - 2)) {
1478 reply.an_status,
1479 reply.an_resp0,
1480 reply.an_resp1,
1481 reply.an_resp2,
1482 i);
1483 return(EIO);
1484 }
1485
1486 an_ltv = (struct an_ltv_gen *)sc->an_rid_buffer.an_dma_vaddr;
1487 if (an_ltv->an_len + 2 < an_rid_desc.an_len) {
1488 an_rid_desc.an_len = an_ltv->an_len;
1489 }
1490
1491 len = an_rid_desc.an_len;
1492 if (len > (ltv->an_len - 2)) {
1496 printf("an%d: record length mismatch -- expected %d, "
1497 "got %d for Rid %x\n", sc->an_unit,
1493 if_printf(ifp, "record length mismatch -- expected %d, "
1494 "got %d for Rid %x\n",
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,
1504 &ltv->an_val,
1505 len);

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

1581
1582 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
1583 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
1584 ((u_int32_t *)(void *)&an_rid_desc)[i]);
1585
1586 DELAY(100000);
1587
1588 if ((i = an_cmd_struct(sc, &cmd, &reply))) {
1495 ltv->an_len - 2, len, ltv->an_type);
1496 len = ltv->an_len - 2;
1497 } else {
1498 ltv->an_len = len + 2;
1499 }
1500 bcopy(&an_ltv->an_type,
1501 &ltv->an_val,
1502 len);

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

1578
1579 for (i = 0; i < sizeof(an_rid_desc) / 4; i++)
1580 CSR_MEM_AUX_WRITE_4(sc, AN_HOST_DESC_OFFSET + i * 4,
1581 ((u_int32_t *)(void *)&an_rid_desc)[i]);
1582
1583 DELAY(100000);
1584
1585 if ((i = an_cmd_struct(sc, &cmd, &reply))) {
1589 printf("an%d: failed to write RID 1 %x %x %x %x %x, %d\n",
1590 sc->an_unit, ltv->an_type,
1586 if_printf(sc->an_ifp,
1587 "failed to write RID 1 %x %x %x %x %x, %d\n",
1588 ltv->an_type,
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) {
1589 reply.an_status,
1590 reply.an_resp0,
1591 reply.an_resp1,
1592 reply.an_resp2,
1593 i);
1594 return(EIO);
1595 }
1596
1597
1598 if (reply.an_status & AN_CMD_QUAL_MASK) {
1601 printf("an%d: failed to write RID 2 %x %x %x %x %x, %d\n",
1602 sc->an_unit, ltv->an_type,
1599 if_printf(sc->an_ifp,
1600 "failed to write RID 2 %x %x %x %x %x, %d\n",
1601 ltv->an_type,
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);

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

1618{
1619 u_int8_t *ptr2;
1620 int len;
1621 int i;
1622 int count = 0;
1623 char buf[17], temp;
1624
1625 len = ltv->an_len - 4;
1602 reply.an_status,
1603 reply.an_resp0,
1604 reply.an_resp1,
1605 reply.an_resp2,
1606 i);
1607 return(EIO);
1608 }
1609 DELAY(100000);

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

1617{
1618 u_int8_t *ptr2;
1619 int len;
1620 int i;
1621 int count = 0;
1622 char buf[17], temp;
1623
1624 len = ltv->an_len - 4;
1626 printf("an%d: RID %4x, Length %4d, Mode %s\n",
1627 sc->an_unit, ltv->an_type, ltv->an_len - 4, string);
1625 if_printf(sc->an_ifp, "RID %4x, Length %4d, Mode %s\n",
1626 ltv->an_type, ltv->an_len - 4, string);
1628
1629 if (an_dump == 1 || (an_dump == ltv->an_type)) {
1627
1628 if (an_dump == 1 || (an_dump == ltv->an_type)) {
1630 printf("an%d:\t", sc->an_unit);
1629 if_printf(sc->an_ifp, "\t");
1631 bzero(buf,sizeof(buf));
1632
1633 ptr2 = (u_int8_t *)&ltv->an_val;
1634 for (i = len; i > 0; i--) {
1635 printf("%02x ", *ptr2);
1636
1637 temp = *ptr2++;
1638 if (isprint(temp))
1639 buf[count] = temp;
1640 else
1641 buf[count] = '.';
1642 if (++count == 16) {
1643 count = 0;
1644 printf("%s\n",buf);
1630 bzero(buf,sizeof(buf));
1631
1632 ptr2 = (u_int8_t *)&ltv->an_val;
1633 for (i = len; i > 0; i--) {
1634 printf("%02x ", *ptr2);
1635
1636 temp = *ptr2++;
1637 if (isprint(temp))
1638 buf[count] = temp;
1639 else
1640 buf[count] = '.';
1641 if (++count == 16) {
1642 count = 0;
1643 printf("%s\n",buf);
1645 printf("an%d:\t", sc->an_unit);
1644 if_printf(sc->an_ifp, "\t");
1646 bzero(buf,sizeof(buf));
1647 }
1648 }
1649 for (; count != 16; count++) {
1650 printf(" ");
1651 }
1652 printf(" %s\n",buf);
1653 }

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

1664 selreg = AN_SEL0;
1665 offreg = AN_OFF0;
1666 break;
1667 case AN_BAP1:
1668 selreg = AN_SEL1;
1669 offreg = AN_OFF1;
1670 break;
1671 default:
1645 bzero(buf,sizeof(buf));
1646 }
1647 }
1648 for (; count != 16; count++) {
1649 printf(" ");
1650 }
1651 printf(" %s\n",buf);
1652 }

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

1663 selreg = AN_SEL0;
1664 offreg = AN_OFF0;
1665 break;
1666 case AN_BAP1:
1667 selreg = AN_SEL1;
1668 offreg = AN_OFF1;
1669 break;
1670 default:
1672 printf("an%d: invalid data path: %x\n", sc->an_unit, chan);
1671 if_printf(sc->an_ifp, "invalid data path: %x\n", chan);
1673 return(EIO);
1674 }
1675
1676 CSR_WRITE_2(sc, selreg, id);
1677 CSR_WRITE_2(sc, offreg, off);
1678
1679 for (i = 0; i < AN_TIMEOUT; i++) {
1680 if (!(CSR_READ_2(sc, offreg) & (AN_OFF_BUSY|AN_OFF_ERR)))

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

1738 * it out.
1739 */
1740static int
1741an_alloc_nicmem(struct an_softc *sc, int len, int *id)
1742{
1743 int i;
1744
1745 if (an_cmd(sc, AN_CMD_ALLOC_MEM, len)) {
1672 return(EIO);
1673 }
1674
1675 CSR_WRITE_2(sc, selreg, id);
1676 CSR_WRITE_2(sc, offreg, off);
1677
1678 for (i = 0; i < AN_TIMEOUT; i++) {
1679 if (!(CSR_READ_2(sc, offreg) & (AN_OFF_BUSY|AN_OFF_ERR)))

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

1737 * it out.
1738 */
1739static int
1740an_alloc_nicmem(struct an_softc *sc, int len, int *id)
1741{
1742 int i;
1743
1744 if (an_cmd(sc, AN_CMD_ALLOC_MEM, len)) {
1746 printf("an%d: failed to allocate %d bytes on NIC\n",
1747 sc->an_unit, len);
1745 if_printf(sc->an_ifp, "failed to allocate %d bytes on NIC\n",
1746 len);
1748 return(ENOMEM);
1749 }
1750
1751 for (i = 0; i < AN_TIMEOUT; i++) {
1752 if (CSR_READ_2(sc, AN_EVENT_STAT(sc->mpi350)) & AN_EV_ALLOC)
1753 break;
1754 }
1755

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

1858 } else {
1859 bpfattach(ifp, DLT_EN10MB,
1860 sizeof(struct ether_header));
1861 if (ng_ether_attach_p != NULL)
1862 (*ng_ether_attach_p) (ifp);
1863 }
1864 break;
1865 default:
1747 return(ENOMEM);
1748 }
1749
1750 for (i = 0; i < AN_TIMEOUT; i++) {
1751 if (CSR_READ_2(sc, AN_EVENT_STAT(sc->mpi350)) & AN_EV_ALLOC)
1752 break;
1753 }
1754

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

1857 } else {
1858 bpfattach(ifp, DLT_EN10MB,
1859 sizeof(struct ether_header));
1860 if (ng_ether_attach_p != NULL)
1861 (*ng_ether_attach_p) (ifp);
1862 }
1863 break;
1864 default:
1866 printf("an%d: unknown RID: %x\n", sc->an_unit, areq->an_type);
1865 if_printf(ifp, "unknown RID: %x\n", areq->an_type);
1867 return;
1868 }
1869
1870
1871 /* Reinitialize the card. */
1872 if (ifp->if_flags) {
1873 AN_UNLOCK(sc);
1874 an_init(sc);

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

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)
2654 an_init_mpi350_desc(sc);
2655 if (an_init_tx_ring(sc)) {
1866 return;
1867 }
1868
1869
1870 /* Reinitialize the card. */
1871 if (ifp->if_flags) {
1872 AN_UNLOCK(sc);
1873 an_init(sc);

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

2647 sc->an_associated = 0;
2648
2649 /* Allocate the TX buffers */
2650 if (an_init_tx_ring(sc)) {
2651 an_reset(sc);
2652 if (sc->mpi350)
2653 an_init_mpi350_desc(sc);
2654 if (an_init_tx_ring(sc)) {
2656 printf("an%d: tx buffer allocation "
2657 "failed\n", sc->an_unit);
2655 if_printf(ifp, "tx buffer allocation failed\n");
2658 AN_UNLOCK(sc);
2659 return;
2660 }
2661 }
2662
2663 /* Set our MAC address. */
2664 bcopy((char *)IF_LLADDR(sc->an_ifp),
2665 (char *)&sc->an_config.an_macaddr, ETHER_ADDR_LEN);

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

2690 if (sc->an_have_rssimap)
2691 sc->an_config.an_rxmode |= AN_RXMODE_NORMALIZED_RSSI;
2692#endif
2693
2694 /* Set the ssid list */
2695 sc->an_ssidlist.an_type = AN_RID_SSIDLIST;
2696 sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new);
2697 if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) {
2656 AN_UNLOCK(sc);
2657 return;
2658 }
2659 }
2660
2661 /* Set our MAC address. */
2662 bcopy((char *)IF_LLADDR(sc->an_ifp),
2663 (char *)&sc->an_config.an_macaddr, ETHER_ADDR_LEN);

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

2688 if (sc->an_have_rssimap)
2689 sc->an_config.an_rxmode |= AN_RXMODE_NORMALIZED_RSSI;
2690#endif
2691
2692 /* Set the ssid list */
2693 sc->an_ssidlist.an_type = AN_RID_SSIDLIST;
2694 sc->an_ssidlist.an_len = sizeof(struct an_ltv_ssidlist_new);
2695 if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_ssidlist)) {
2698 printf("an%d: failed to set ssid list\n", sc->an_unit);
2696 if_printf(ifp, "failed to set ssid list\n");
2699 AN_UNLOCK(sc);
2700 return;
2701 }
2702
2703 /* Set the AP list */
2704 sc->an_aplist.an_type = AN_RID_APLIST;
2705 sc->an_aplist.an_len = sizeof(struct an_ltv_aplist);
2706 if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) {
2697 AN_UNLOCK(sc);
2698 return;
2699 }
2700
2701 /* Set the AP list */
2702 sc->an_aplist.an_type = AN_RID_APLIST;
2703 sc->an_aplist.an_len = sizeof(struct an_ltv_aplist);
2704 if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_aplist)) {
2707 printf("an%d: failed to set AP list\n", sc->an_unit);
2705 if_printf(ifp, "failed to set AP list\n");
2708 AN_UNLOCK(sc);
2709 return;
2710 }
2711
2712 /* Set the configuration in the NIC */
2713 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
2714 sc->an_config.an_type = AN_RID_GENCONFIG;
2715 if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_config)) {
2706 AN_UNLOCK(sc);
2707 return;
2708 }
2709
2710 /* Set the configuration in the NIC */
2711 sc->an_config.an_len = sizeof(struct an_ltv_genconfig);
2712 sc->an_config.an_type = AN_RID_GENCONFIG;
2713 if (an_write_record(sc, (struct an_ltv_gen *)&sc->an_config)) {
2716 printf("an%d: failed to set configuration\n", sc->an_unit);
2714 if_printf(ifp, "failed to set configuration\n");
2717 AN_UNLOCK(sc);
2718 return;
2719 }
2720
2721 /* Enable the MAC */
2722 if (an_cmd(sc, AN_CMD_ENABLE, 0)) {
2715 AN_UNLOCK(sc);
2716 return;
2717 }
2718
2719 /* Enable the MAC */
2720 if (an_cmd(sc, AN_CMD_ENABLE, 0)) {
2723 printf("an%d: failed to enable MAC\n", sc->an_unit);
2721 if_printf(ifp, "failed to enable MAC\n");
2724 AN_UNLOCK(sc);
2725 return;
2726 }
2727
2728 if (ifp->if_flags & IFF_PROMISC)
2729 an_cmd(sc, AN_CMD_SET_MODE, 0xffff);
2730
2731 /* enable interrupts */

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

2822 */
2823 BPF_MTAP(ifp, m0);
2824
2825 m_freem(m0);
2826 m0 = NULL;
2827
2828 sc->an_rdata.an_tx_ring[idx] = id;
2829 if (an_cmd(sc, AN_CMD_TX, id))
2722 AN_UNLOCK(sc);
2723 return;
2724 }
2725
2726 if (ifp->if_flags & IFF_PROMISC)
2727 an_cmd(sc, AN_CMD_SET_MODE, 0xffff);
2728
2729 /* enable interrupts */

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

2820 */
2821 BPF_MTAP(ifp, m0);
2822
2823 m_freem(m0);
2824 m0 = NULL;
2825
2826 sc->an_rdata.an_tx_ring[idx] = id;
2827 if (an_cmd(sc, AN_CMD_TX, id))
2830 printf("an%d: xmit failed\n", sc->an_unit);
2828 if_printf(ifp, "xmit failed\n");
2831
2832 AN_INC(idx, AN_TX_RING_CNT);
2833
2834 /*
2835 * Set a timeout in case the chip goes out to lunch.
2836 */
2837 ifp->if_timer = 5;
2838 }

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

2971 sc = ifp->if_softc;
2972 AN_LOCK(sc);
2973
2974 if (sc->an_gone) {
2975 AN_UNLOCK(sc);
2976 return;
2977 }
2978
2829
2830 AN_INC(idx, AN_TX_RING_CNT);
2831
2832 /*
2833 * Set a timeout in case the chip goes out to lunch.
2834 */
2835 ifp->if_timer = 5;
2836 }

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

2969 sc = ifp->if_softc;
2970 AN_LOCK(sc);
2971
2972 if (sc->an_gone) {
2973 AN_UNLOCK(sc);
2974 return;
2975 }
2976
2979 printf("an%d: device timeout\n", sc->an_unit);
2977 if_printf(ifp, "device timeout\n");
2980
2981 an_reset(sc);
2982 if (sc->mpi350)
2983 an_init_mpi350_desc(sc);
2984 AN_UNLOCK(sc);
2985 an_init(sc);
2986
2987 ifp->if_oerrors++;

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

3122
3123 /* filter for broadcast/multicast only
3124 */
3125 if (an_cache_mcastonly && ((eh->ether_dhost[0] & 1) == 0)) {
3126 return;
3127 }
3128
3129#ifdef SIGDEBUG
2978
2979 an_reset(sc);
2980 if (sc->mpi350)
2981 an_init_mpi350_desc(sc);
2982 AN_UNLOCK(sc);
2983 an_init(sc);
2984
2985 ifp->if_oerrors++;

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

3120
3121 /* filter for broadcast/multicast only
3122 */
3123 if (an_cache_mcastonly && ((eh->ether_dhost[0] & 1) == 0)) {
3124 return;
3125 }
3126
3127#ifdef SIGDEBUG
3130 printf("an: q value %x (MSB=0x%x, LSB=0x%x) \n",
3128 if_printf(sc->an_ifp, "q value %x (MSB=0x%x, LSB=0x%x) \n",
3131 rx_rssi & 0xffff, rx_rssi >> 8, rx_rssi & 0xff);
3132#endif
3133
3134 /* find the ip header. we want to store the ip_src
3135 * address.
3136 */
3137 if (type_ipv4) {
3138 ip = mtod(m, struct ip *);

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

3562 struct an_softc *sc = ifp->if_softc;
3563
3564 an_stop(sc);
3565
3566 AN_LOCK(sc);
3567 an_cmd(sc, AN_CMD_DISABLE, 0);
3568
3569 if (!(status = WaitBusy(ifp, AN_TIMEOUT))) {
3129 rx_rssi & 0xffff, rx_rssi >> 8, rx_rssi & 0xff);
3130#endif
3131
3132 /* find the ip header. we want to store the ip_src
3133 * address.
3134 */
3135 if (type_ipv4) {
3136 ip = mtod(m, struct ip *);

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

3560 struct an_softc *sc = ifp->if_softc;
3561
3562 an_stop(sc);
3563
3564 AN_LOCK(sc);
3565 an_cmd(sc, AN_CMD_DISABLE, 0);
3566
3567 if (!(status = WaitBusy(ifp, AN_TIMEOUT))) {
3570 printf("an%d: Waitbusy hang b4 RESET =%d\n",
3571 sc->an_unit, status);
3568 if_printf(ifp, "Waitbusy hang b4 RESET =%d\n", status);
3572 AN_UNLOCK(sc);
3573 return -EBUSY;
3574 }
3575 CSR_WRITE_2(sc, AN_COMMAND(sc->mpi350), AN_CMD_FW_RESTART);
3576
3577 FLASH_DELAY(sc, 1000); /* WAS 600 12/7/00 */
3578
3579
3580 if (!(status = WaitBusy(ifp, 100))) {
3569 AN_UNLOCK(sc);
3570 return -EBUSY;
3571 }
3572 CSR_WRITE_2(sc, AN_COMMAND(sc->mpi350), AN_CMD_FW_RESTART);
3573
3574 FLASH_DELAY(sc, 1000); /* WAS 600 12/7/00 */
3575
3576
3577 if (!(status = WaitBusy(ifp, 100))) {
3581 printf("an%d: Waitbusy hang AFTER RESET =%d\n",
3582 sc->an_unit, status);
3578 if_printf(ifp, "Waitbusy hang AFTER RESET =%d\n", status);
3583 AN_UNLOCK(sc);
3584 return -EBUSY;
3585 }
3586 AN_UNLOCK(sc);
3587 return 0;
3588}
3589
3590/*

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

3682 } else
3683 break;
3684 }
3685 while (waittime >= 0);
3686
3687 /* timeout for busy clear wait */
3688
3689 if (waittime <= 0) {
3579 AN_UNLOCK(sc);
3580 return -EBUSY;
3581 }
3582 AN_UNLOCK(sc);
3583 return 0;
3584}
3585
3586/*

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

3678 } else
3679 break;
3680 }
3681 while (waittime >= 0);
3682
3683 /* timeout for busy clear wait */
3684
3685 if (waittime <= 0) {
3690 printf("an%d: flash putchar busywait timeout! \n",
3691 sc->an_unit);
3686 if_printf(ifp, "flash putchar busywait timeout!\n");
3692 return -1;
3693 }
3694 /*
3695 * Port is clear now write byte and wait for it to echo back
3696 */
3697 do {
3698 CSR_WRITE_2(sc, AN_SW0(sc->mpi350), byte);
3699 FLASH_DELAY(sc, 50);

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

3769static int
3770flashcard(struct ifnet *ifp, struct aironet_ioctl *l_ioctl)
3771{
3772 int z = 0, status;
3773 struct an_softc *sc;
3774
3775 sc = ifp->if_softc;
3776 if (sc->mpi350) {
3687 return -1;
3688 }
3689 /*
3690 * Port is clear now write byte and wait for it to echo back
3691 */
3692 do {
3693 CSR_WRITE_2(sc, AN_SW0(sc->mpi350), byte);
3694 FLASH_DELAY(sc, 50);

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

3764static int
3765flashcard(struct ifnet *ifp, struct aironet_ioctl *l_ioctl)
3766{
3767 int z = 0, status;
3768 struct an_softc *sc;
3769
3770 sc = ifp->if_softc;
3771 if (sc->mpi350) {
3777 printf("an%d: flashing not supported on MPI 350 yet\n",
3778 sc->an_unit);
3772 if_printf(ifp, "flashing not supported on MPI 350 yet\n");
3779 return(-1);
3780 }
3781 status = l_ioctl->command;
3782
3783 switch (l_ioctl->command) {
3784 case AIROFLSHRST:
3785 return cmdreset(ifp);
3786 break;

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

3815 z = *(int *)&sc->areq;
3816 if ((status = flashpchar(ifp, z, 8000)) == -1)
3817 return -EIO;
3818 else
3819 return 0;
3820 break;
3821 case AIROFLPUTBUF: /* Send 32k to card */
3822 if (l_ioctl->len > FLASH_SIZE) {
3773 return(-1);
3774 }
3775 status = l_ioctl->command;
3776
3777 switch (l_ioctl->command) {
3778 case AIROFLSHRST:
3779 return cmdreset(ifp);
3780 break;

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

3809 z = *(int *)&sc->areq;
3810 if ((status = flashpchar(ifp, z, 8000)) == -1)
3811 return -EIO;
3812 else
3813 return 0;
3814 break;
3815 case AIROFLPUTBUF: /* Send 32k to card */
3816 if (l_ioctl->len > FLASH_SIZE) {
3823 printf("an%d: Buffer to big, %x %x\n", sc->an_unit,
3817 if_printf(ifp, "Buffer to big, %x %x\n",
3824 l_ioctl->len, FLASH_SIZE);
3825 return -EINVAL;
3826 }
3827 AN_UNLOCK(sc);
3828 status = copyin(l_ioctl->data, sc->an_flash_buffer, l_ioctl->len);
3829 AN_LOCK(sc);
3830 if (status)
3831 return status;
3832
3833 if ((status = flashputbuf(ifp)) != 0)
3834 return -EIO;
3835 else
3836 return 0;
3837 break;
3838 case AIRORESTART:
3839 if ((status = flashrestart(ifp)) != 0) {
3818 l_ioctl->len, FLASH_SIZE);
3819 return -EINVAL;
3820 }
3821 AN_UNLOCK(sc);
3822 status = copyin(l_ioctl->data, sc->an_flash_buffer, l_ioctl->len);
3823 AN_LOCK(sc);
3824 if (status)
3825 return status;
3826
3827 if ((status = flashputbuf(ifp)) != 0)
3828 return -EIO;
3829 else
3830 return 0;
3831 break;
3832 case AIRORESTART:
3833 if ((status = flashrestart(ifp)) != 0) {
3840 printf("an%d: FLASHRESTART returned %d\n",
3841 sc->an_unit, status);
3834 if_printf(ifp, "FLASHRESTART returned %d\n", status);
3842 return -EIO;
3843 } else
3844 return 0;
3845
3846 break;
3847 default:
3848 return -EINVAL;
3849 }
3850
3851 return -EINVAL;
3852}
3835 return -EIO;
3836 } else
3837 return 0;
3838
3839 break;
3840 default:
3841 return -EINVAL;
3842 }
3843
3844 return -EINVAL;
3845}