if_an.c (269712) | if_an.c (271849) |
---|---|
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 269712 2014-08-08 11:47:14Z imp $"); | 41__FBSDID("$FreeBSD: head/sys/dev/an/if_an.c 271849 2014-09-19 03:51:26Z glebius $"); |
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. --- 817 unchanged lines hidden (view full) --- 867 868 if (sc->an_monitor && (ifp->if_flags & IFF_PROMISC)) { 869 /* read raw 802.11 packet */ 870 bpf_buf = sc->buf_802_11; 871 872 /* read header */ 873 if (an_read_data(sc, id, 0x0, (caddr_t)&rx_frame, 874 sizeof(rx_frame))) { | 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. --- 817 unchanged lines hidden (view full) --- 867 868 if (sc->an_monitor && (ifp->if_flags & IFF_PROMISC)) { 869 /* read raw 802.11 packet */ 870 bpf_buf = sc->buf_802_11; 871 872 /* read header */ 873 if (an_read_data(sc, id, 0x0, (caddr_t)&rx_frame, 874 sizeof(rx_frame))) { |
875 ifp->if_ierrors++; | 875 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
876 return; 877 } 878 879 /* 880 * skip beacon by default since this increases the 881 * system load a lot 882 */ 883 --- 6 unchanged lines hidden (view full) --- 890 if (sc->an_monitor & AN_MONITOR_AIRONET_HEADER) { 891 len = rx_frame.an_rx_payload_len 892 + sizeof(rx_frame); 893 /* Check for insane frame length */ 894 if (len > sizeof(sc->buf_802_11)) { 895 if_printf(ifp, "oversized packet " 896 "received (%d, %d)\n", 897 len, MCLBYTES); | 876 return; 877 } 878 879 /* 880 * skip beacon by default since this increases the 881 * system load a lot 882 */ 883 --- 6 unchanged lines hidden (view full) --- 890 if (sc->an_monitor & AN_MONITOR_AIRONET_HEADER) { 891 len = rx_frame.an_rx_payload_len 892 + sizeof(rx_frame); 893 /* Check for insane frame length */ 894 if (len > sizeof(sc->buf_802_11)) { 895 if_printf(ifp, "oversized packet " 896 "received (%d, %d)\n", 897 len, MCLBYTES); |
898 ifp->if_ierrors++; | 898 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
899 return; 900 } 901 902 bcopy((char *)&rx_frame, 903 bpf_buf, sizeof(rx_frame)); 904 905 error = an_read_data(sc, id, sizeof(rx_frame), 906 (caddr_t)bpf_buf+sizeof(rx_frame), --- 9 unchanged lines hidden (view full) --- 916 917 len = rx_frame.an_rx_payload_len 918 + ieee80211_header_len; 919 /* Check for insane frame length */ 920 if (len > sizeof(sc->buf_802_11)) { 921 if_printf(ifp, "oversized packet " 922 "received (%d, %d)\n", 923 len, MCLBYTES); | 899 return; 900 } 901 902 bcopy((char *)&rx_frame, 903 bpf_buf, sizeof(rx_frame)); 904 905 error = an_read_data(sc, id, sizeof(rx_frame), 906 (caddr_t)bpf_buf+sizeof(rx_frame), --- 9 unchanged lines hidden (view full) --- 916 917 len = rx_frame.an_rx_payload_len 918 + ieee80211_header_len; 919 /* Check for insane frame length */ 920 if (len > sizeof(sc->buf_802_11)) { 921 if_printf(ifp, "oversized packet " 922 "received (%d, %d)\n", 923 len, MCLBYTES); |
924 ifp->if_ierrors++; | 924 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
925 return; 926 } 927 928 ih = (struct ieee80211_frame *)bpf_buf; 929 930 bcopy((char *)&rx_frame.an_frame_ctl, 931 (char *)ih, ieee80211_header_len); 932 933 error = an_read_data(sc, id, sizeof(rx_frame) + 934 rx_frame.an_gaplen, 935 (caddr_t)ih +ieee80211_header_len, 936 rx_frame.an_rx_payload_len); 937 } 938 /* dump raw 802.11 packet to bpf and skip ip stack */ 939 BPF_TAP(ifp, bpf_buf, len); 940 } else { 941 MGETHDR(m, M_NOWAIT, MT_DATA); 942 if (m == NULL) { | 925 return; 926 } 927 928 ih = (struct ieee80211_frame *)bpf_buf; 929 930 bcopy((char *)&rx_frame.an_frame_ctl, 931 (char *)ih, ieee80211_header_len); 932 933 error = an_read_data(sc, id, sizeof(rx_frame) + 934 rx_frame.an_gaplen, 935 (caddr_t)ih +ieee80211_header_len, 936 rx_frame.an_rx_payload_len); 937 } 938 /* dump raw 802.11 packet to bpf and skip ip stack */ 939 BPF_TAP(ifp, bpf_buf, len); 940 } else { 941 MGETHDR(m, M_NOWAIT, MT_DATA); 942 if (m == NULL) { |
943 ifp->if_ierrors++; | 943 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
944 return; 945 } 946 MCLGET(m, M_NOWAIT); 947 if (!(m->m_flags & M_EXT)) { 948 m_freem(m); | 944 return; 945 } 946 MCLGET(m, M_NOWAIT); 947 if (!(m->m_flags & M_EXT)) { 948 m_freem(m); |
949 ifp->if_ierrors++; | 949 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
950 return; 951 } 952 m->m_pkthdr.rcvif = ifp; 953 /* Read Ethernet encapsulated packet */ 954 955#ifdef ANCACHE 956 /* Read NIC frame header */ 957 if (an_read_data(sc, id, 0, (caddr_t)&rx_frame, 958 sizeof(rx_frame))) { 959 m_freem(m); | 950 return; 951 } 952 m->m_pkthdr.rcvif = ifp; 953 /* Read Ethernet encapsulated packet */ 954 955#ifdef ANCACHE 956 /* Read NIC frame header */ 957 if (an_read_data(sc, id, 0, (caddr_t)&rx_frame, 958 sizeof(rx_frame))) { 959 m_freem(m); |
960 ifp->if_ierrors++; | 960 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
961 return; 962 } 963#endif 964 /* Read in the 802_3 frame header */ 965 if (an_read_data(sc, id, 0x34, 966 (caddr_t)&rx_frame_802_3, 967 sizeof(rx_frame_802_3))) { 968 m_freem(m); | 961 return; 962 } 963#endif 964 /* Read in the 802_3 frame header */ 965 if (an_read_data(sc, id, 0x34, 966 (caddr_t)&rx_frame_802_3, 967 sizeof(rx_frame_802_3))) { 968 m_freem(m); |
969 ifp->if_ierrors++; | 969 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
970 return; 971 } 972 if (rx_frame_802_3.an_rx_802_3_status != 0) { 973 m_freem(m); | 970 return; 971 } 972 if (rx_frame_802_3.an_rx_802_3_status != 0) { 973 m_freem(m); |
974 ifp->if_ierrors++; | 974 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
975 return; 976 } 977 /* Check for insane frame length */ 978 len = rx_frame_802_3.an_rx_802_3_payload_len; 979 if (len > sizeof(sc->buf_802_11)) { 980 m_freem(m); 981 if_printf(ifp, "oversized packet " 982 "received (%d, %d)\n", 983 len, MCLBYTES); | 975 return; 976 } 977 /* Check for insane frame length */ 978 len = rx_frame_802_3.an_rx_802_3_payload_len; 979 if (len > sizeof(sc->buf_802_11)) { 980 m_freem(m); 981 if_printf(ifp, "oversized packet " 982 "received (%d, %d)\n", 983 len, MCLBYTES); |
984 ifp->if_ierrors++; | 984 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
985 return; 986 } 987 m->m_pkthdr.len = m->m_len = 988 rx_frame_802_3.an_rx_802_3_payload_len + 12; 989 990 eh = mtod(m, struct ether_header *); 991 992 bcopy((char *)&rx_frame_802_3.an_rx_dst_addr, 993 (char *)&eh->ether_dhost, ETHER_ADDR_LEN); 994 bcopy((char *)&rx_frame_802_3.an_rx_src_addr, 995 (char *)&eh->ether_shost, ETHER_ADDR_LEN); 996 997 /* in mbuf header type is just before payload */ 998 error = an_read_data(sc, id, 0x44, 999 (caddr_t)&(eh->ether_type), 1000 rx_frame_802_3.an_rx_802_3_payload_len); 1001 1002 if (error) { 1003 m_freem(m); | 985 return; 986 } 987 m->m_pkthdr.len = m->m_len = 988 rx_frame_802_3.an_rx_802_3_payload_len + 12; 989 990 eh = mtod(m, struct ether_header *); 991 992 bcopy((char *)&rx_frame_802_3.an_rx_dst_addr, 993 (char *)&eh->ether_dhost, ETHER_ADDR_LEN); 994 bcopy((char *)&rx_frame_802_3.an_rx_src_addr, 995 (char *)&eh->ether_shost, ETHER_ADDR_LEN); 996 997 /* in mbuf header type is just before payload */ 998 error = an_read_data(sc, id, 0x44, 999 (caddr_t)&(eh->ether_type), 1000 rx_frame_802_3.an_rx_802_3_payload_len); 1001 1002 if (error) { 1003 m_freem(m); |
1004 ifp->if_ierrors++; | 1004 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
1005 return; 1006 } | 1005 return; 1006 } |
1007 ifp->if_ipackets++; | 1007 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); |
1008 1009 /* Receive packet. */ 1010#ifdef ANCACHE 1011 an_cache_store(sc, eh, m, 1012 rx_frame.an_rx_signal_strength, 1013 rx_frame.an_rsvd0); 1014#endif 1015 AN_UNLOCK(sc); --- 10 unchanged lines hidden (view full) --- 1026 + (count * sizeof(an_rx_desc)) 1027 + (i * 4)); 1028 1029 if (an_rx_desc.an_done && !an_rx_desc.an_valid) { 1030 buf = sc->an_rx_buffer[count].an_dma_vaddr; 1031 1032 MGETHDR(m, M_NOWAIT, MT_DATA); 1033 if (m == NULL) { | 1008 1009 /* Receive packet. */ 1010#ifdef ANCACHE 1011 an_cache_store(sc, eh, m, 1012 rx_frame.an_rx_signal_strength, 1013 rx_frame.an_rsvd0); 1014#endif 1015 AN_UNLOCK(sc); --- 10 unchanged lines hidden (view full) --- 1026 + (count * sizeof(an_rx_desc)) 1027 + (i * 4)); 1028 1029 if (an_rx_desc.an_done && !an_rx_desc.an_valid) { 1030 buf = sc->an_rx_buffer[count].an_dma_vaddr; 1031 1032 MGETHDR(m, M_NOWAIT, MT_DATA); 1033 if (m == NULL) { |
1034 ifp->if_ierrors++; | 1034 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
1035 return; 1036 } 1037 MCLGET(m, M_NOWAIT); 1038 if (!(m->m_flags & M_EXT)) { 1039 m_freem(m); | 1035 return; 1036 } 1037 MCLGET(m, M_NOWAIT); 1038 if (!(m->m_flags & M_EXT)) { 1039 m_freem(m); |
1040 ifp->if_ierrors++; | 1040 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
1041 return; 1042 } 1043 m->m_pkthdr.rcvif = ifp; 1044 /* Read Ethernet encapsulated packet */ 1045 1046 /* 1047 * No ANCACHE support since we just get back 1048 * an Ethernet packet no 802.11 info --- 7 unchanged lines hidden (view full) --- 1056#endif 1057 /* Check for insane frame length */ 1058 len = an_rx_desc.an_len + 12; 1059 if (len > MCLBYTES) { 1060 m_freem(m); 1061 if_printf(ifp, "oversized packet " 1062 "received (%d, %d)\n", 1063 len, MCLBYTES); | 1041 return; 1042 } 1043 m->m_pkthdr.rcvif = ifp; 1044 /* Read Ethernet encapsulated packet */ 1045 1046 /* 1047 * No ANCACHE support since we just get back 1048 * an Ethernet packet no 802.11 info --- 7 unchanged lines hidden (view full) --- 1056#endif 1057 /* Check for insane frame length */ 1058 len = an_rx_desc.an_len + 12; 1059 if (len > MCLBYTES) { 1060 m_freem(m); 1061 if_printf(ifp, "oversized packet " 1062 "received (%d, %d)\n", 1063 len, MCLBYTES); |
1064 ifp->if_ierrors++; | 1064 if_inc_counter(ifp, IFCOUNTER_IERRORS, 1); |
1065 return; 1066 } 1067 1068 m->m_pkthdr.len = m->m_len = 1069 an_rx_desc.an_len + 12; 1070 1071 eh = mtod(m, struct ether_header *); 1072 1073 bcopy(buf, (char *)eh, 1074 m->m_pkthdr.len); 1075 | 1065 return; 1066 } 1067 1068 m->m_pkthdr.len = m->m_len = 1069 an_rx_desc.an_len + 12; 1070 1071 eh = mtod(m, struct ether_header *); 1072 1073 bcopy(buf, (char *)eh, 1074 m->m_pkthdr.len); 1075 |
1076 ifp->if_ipackets++; | 1076 if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1); |
1077 1078 /* Receive packet. */ 1079#if 0 1080#ifdef ANCACHE 1081 an_cache_store(sc, eh, m, 1082 rx_frame.an_rx_signal_strength, 1083 rx_frame.an_rsvd0); 1084#endif --- 36 unchanged lines hidden (view full) --- 1121 1122 sc->an_timer = 0; 1123 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1124 1125 if (!sc->mpi350) { 1126 id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350)); 1127 1128 if (status & AN_EV_TX_EXC) { | 1077 1078 /* Receive packet. */ 1079#if 0 1080#ifdef ANCACHE 1081 an_cache_store(sc, eh, m, 1082 rx_frame.an_rx_signal_strength, 1083 rx_frame.an_rsvd0); 1084#endif --- 36 unchanged lines hidden (view full) --- 1121 1122 sc->an_timer = 0; 1123 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; 1124 1125 if (!sc->mpi350) { 1126 id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350)); 1127 1128 if (status & AN_EV_TX_EXC) { |
1129 ifp->if_oerrors++; | 1129 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
1130 } else | 1130 } else |
1131 ifp->if_opackets++; | 1131 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); |
1132 1133 for (i = 0; i < AN_TX_RING_CNT; i++) { 1134 if (id == sc->an_rdata.an_tx_ring[i]) { 1135 sc->an_rdata.an_tx_ring[i] = 0; 1136 break; 1137 } 1138 } 1139 1140 AN_INC(sc->an_rdata.an_tx_cons, AN_TX_RING_CNT); 1141 } else { /* MPI 350 */ 1142 id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350)); 1143 if (!sc->an_rdata.an_tx_empty){ 1144 if (status & AN_EV_TX_EXC) { | 1132 1133 for (i = 0; i < AN_TX_RING_CNT; i++) { 1134 if (id == sc->an_rdata.an_tx_ring[i]) { 1135 sc->an_rdata.an_tx_ring[i] = 0; 1136 break; 1137 } 1138 } 1139 1140 AN_INC(sc->an_rdata.an_tx_cons, AN_TX_RING_CNT); 1141 } else { /* MPI 350 */ 1142 id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350)); 1143 if (!sc->an_rdata.an_tx_empty){ 1144 if (status & AN_EV_TX_EXC) { |
1145 ifp->if_oerrors++; | 1145 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
1146 } else | 1146 } else |
1147 ifp->if_opackets++; | 1147 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1); |
1148 AN_INC(sc->an_rdata.an_tx_cons, AN_MAX_TX_DESC); 1149 if (sc->an_rdata.an_tx_prod == 1150 sc->an_rdata.an_tx_cons) 1151 sc->an_rdata.an_tx_empty = 1; 1152 } 1153 } 1154 1155 return; --- 1801 unchanged lines hidden (view full) --- 2957 ifp = sc->an_ifp; 2958 if_printf(ifp, "device timeout\n"); 2959 2960 an_reset(sc); 2961 if (sc->mpi350) 2962 an_init_mpi350_desc(sc); 2963 an_init_locked(sc); 2964 | 1148 AN_INC(sc->an_rdata.an_tx_cons, AN_MAX_TX_DESC); 1149 if (sc->an_rdata.an_tx_prod == 1150 sc->an_rdata.an_tx_cons) 1151 sc->an_rdata.an_tx_empty = 1; 1152 } 1153 } 1154 1155 return; --- 1801 unchanged lines hidden (view full) --- 2957 ifp = sc->an_ifp; 2958 if_printf(ifp, "device timeout\n"); 2959 2960 an_reset(sc); 2961 if (sc->mpi350) 2962 an_init_mpi350_desc(sc); 2963 an_init_locked(sc); 2964 |
2965 ifp->if_oerrors++; | 2965 if_inc_counter(ifp, IFCOUNTER_OERRORS, 1); |
2966} 2967 2968int 2969an_shutdown(device_t dev) 2970{ 2971 struct an_softc *sc; 2972 2973 sc = device_get_softc(dev); --- 850 unchanged lines hidden --- | 2966} 2967 2968int 2969an_shutdown(device_t dev) 2970{ 2971 struct an_softc *sc; 2972 2973 sc = device_get_softc(dev); --- 850 unchanged lines hidden --- |