Deleted Added
full compact
if_an.c (148639) if_an.c (148887)
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 148639 2005-08-02 16:03:51Z emax $");
41__FBSDID("$FreeBSD: head/sys/dev/an/if_an.c 148887 2005-08-09 10:20:02Z rwatson $");
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.

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

829 if (sc->an_gone) {
830 device_printf(dev,"already unloaded\n");
831 return(0);
832 }
833 AN_LOCK(sc);
834 an_stop(sc);
835 sc->an_gone = 1;
836 ifmedia_removeall(&sc->an_ifmedia);
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.

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

829 if (sc->an_gone) {
830 device_printf(dev,"already unloaded\n");
831 return(0);
832 }
833 AN_LOCK(sc);
834 an_stop(sc);
835 sc->an_gone = 1;
836 ifmedia_removeall(&sc->an_ifmedia);
837 ifp->if_flags &= ~IFF_RUNNING;
837 ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
838 AN_UNLOCK(sc);
839 ether_ifdetach(ifp);
840 if_free(ifp);
841 bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
842 an_release_resources(dev);
843 mtx_destroy(&sc->an_mtx);
844 return (0);
845}

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

1113 int status;
1114{
1115 struct ifnet *ifp;
1116 int id, i;
1117
1118 ifp = sc->an_ifp;
1119
1120 ifp->if_timer = 0;
838 AN_UNLOCK(sc);
839 ether_ifdetach(ifp);
840 if_free(ifp);
841 bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
842 an_release_resources(dev);
843 mtx_destroy(&sc->an_mtx);
844 return (0);
845}

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

1113 int status;
1114{
1115 struct ifnet *ifp;
1116 int id, i;
1117
1118 ifp = sc->an_ifp;
1119
1120 ifp->if_timer = 0;
1121 ifp->if_flags &= ~IFF_OACTIVE;
1121 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1122
1123 if (!sc->mpi350) {
1124 id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350));
1125
1126 if (status & AN_EV_TX_EXC) {
1127 ifp->if_oerrors++;
1128 } else
1129 ifp->if_opackets++;

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

1175 an_read_record(sc, (struct an_ltv_gen *)&sc->an_status);
1176
1177 if (sc->an_status.an_opmode & AN_STATUS_OPMODE_IN_SYNC)
1178 sc->an_associated = 1;
1179 else
1180 sc->an_associated = 0;
1181
1182 /* Don't do this while we're transmitting */
1122
1123 if (!sc->mpi350) {
1124 id = CSR_READ_2(sc, AN_TX_CMP_FID(sc->mpi350));
1125
1126 if (status & AN_EV_TX_EXC) {
1127 ifp->if_oerrors++;
1128 } else
1129 ifp->if_opackets++;

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

1175 an_read_record(sc, (struct an_ltv_gen *)&sc->an_status);
1176
1177 if (sc->an_status.an_opmode & AN_STATUS_OPMODE_IN_SYNC)
1178 sc->an_associated = 1;
1179 else
1180 sc->an_associated = 0;
1181
1182 /* Don't do this while we're transmitting */
1183 if (ifp->if_flags & IFF_OACTIVE) {
1183 if (ifp->if_drv_flags & IFF_DRV_OACTIVE) {
1184 sc->an_stat_ch = timeout(an_stats_update, sc, hz);
1185 AN_UNLOCK(sc);
1186 return;
1187 }
1188
1189 sc->an_stats.an_len = sizeof(struct an_ltv_stats);
1190 sc->an_stats.an_type = AN_RID_32BITS_CUM;
1191 an_read_record(sc, (struct an_ltv_gen *)&sc->an_stats.an_len);

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

1946 if (sc->an_gone) {
1947 error = ENODEV;
1948 goto out;
1949 }
1950
1951 switch (command) {
1952 case SIOCSIFFLAGS:
1953 if (ifp->if_flags & IFF_UP) {
1184 sc->an_stat_ch = timeout(an_stats_update, sc, hz);
1185 AN_UNLOCK(sc);
1186 return;
1187 }
1188
1189 sc->an_stats.an_len = sizeof(struct an_ltv_stats);
1190 sc->an_stats.an_type = AN_RID_32BITS_CUM;
1191 an_read_record(sc, (struct an_ltv_gen *)&sc->an_stats.an_len);

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

1946 if (sc->an_gone) {
1947 error = ENODEV;
1948 goto out;
1949 }
1950
1951 switch (command) {
1952 case SIOCSIFFLAGS:
1953 if (ifp->if_flags & IFF_UP) {
1954 if (ifp->if_flags & IFF_RUNNING &&
1954 if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
1955 ifp->if_flags & IFF_PROMISC &&
1956 !(sc->an_if_flags & IFF_PROMISC)) {
1957 an_promisc(sc, 1);
1955 ifp->if_flags & IFF_PROMISC &&
1956 !(sc->an_if_flags & IFF_PROMISC)) {
1957 an_promisc(sc, 1);
1958 } else if (ifp->if_flags & IFF_RUNNING &&
1958 } else if (ifp->if_drv_flags & IFF_DRV_RUNNING &&
1959 !(ifp->if_flags & IFF_PROMISC) &&
1960 sc->an_if_flags & IFF_PROMISC) {
1961 an_promisc(sc, 0);
1962 } else
1963 an_init(sc);
1964 } else {
1959 !(ifp->if_flags & IFF_PROMISC) &&
1960 sc->an_if_flags & IFF_PROMISC) {
1961 an_promisc(sc, 0);
1962 } else
1963 an_init(sc);
1964 } else {
1965 if (ifp->if_flags & IFF_RUNNING)
1965 if (ifp->if_drv_flags & IFF_DRV_RUNNING)
1966 an_stop(sc);
1967 }
1968 sc->an_if_flags = ifp->if_flags;
1969 error = 0;
1970 break;
1971 case SIOCSIFMEDIA:
1972 case SIOCGIFMEDIA:
1973 error = ifmedia_ioctl(ifp, ifr, &sc->an_ifmedia, command);

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

2539
2540 AN_LOCK(sc);
2541
2542 if (sc->an_gone) {
2543 AN_UNLOCK(sc);
2544 return;
2545 }
2546
1966 an_stop(sc);
1967 }
1968 sc->an_if_flags = ifp->if_flags;
1969 error = 0;
1970 break;
1971 case SIOCSIFMEDIA:
1972 case SIOCGIFMEDIA:
1973 error = ifmedia_ioctl(ifp, ifr, &sc->an_ifmedia, command);

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

2539
2540 AN_LOCK(sc);
2541
2542 if (sc->an_gone) {
2543 AN_UNLOCK(sc);
2544 return;
2545 }
2546
2547 if (ifp->if_flags & IFF_RUNNING)
2547 if (ifp->if_drv_flags & IFF_DRV_RUNNING)
2548 an_stop(sc);
2549
2550 sc->an_associated = 0;
2551
2552 /* Allocate the TX buffers */
2553 if (an_init_tx_ring(sc)) {
2554 an_reset(sc);
2555 if (sc->mpi350)

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

2626 }
2627
2628 if (ifp->if_flags & IFF_PROMISC)
2629 an_cmd(sc, AN_CMD_SET_MODE, 0xffff);
2630
2631 /* enable interrupts */
2632 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS(sc->mpi350));
2633
2548 an_stop(sc);
2549
2550 sc->an_associated = 0;
2551
2552 /* Allocate the TX buffers */
2553 if (an_init_tx_ring(sc)) {
2554 an_reset(sc);
2555 if (sc->mpi350)

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

2626 }
2627
2628 if (ifp->if_flags & IFF_PROMISC)
2629 an_cmd(sc, AN_CMD_SET_MODE, 0xffff);
2630
2631 /* enable interrupts */
2632 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS(sc->mpi350));
2633
2634 ifp->if_flags |= IFF_RUNNING;
2635 ifp->if_flags &= ~IFF_OACTIVE;
2634 ifp->if_drv_flags |= IFF_DRV_RUNNING;
2635 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
2636
2637 sc->an_stat_ch = timeout(an_stats_update, sc, hz);
2638 AN_UNLOCK(sc);
2639
2640 return;
2641}
2642
2643static void

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

2653 struct an_card_tx_desc an_tx_desc;
2654 u_int8_t *buf;
2655
2656 sc = ifp->if_softc;
2657
2658 if (sc->an_gone)
2659 return;
2660
2636
2637 sc->an_stat_ch = timeout(an_stats_update, sc, hz);
2638 AN_UNLOCK(sc);
2639
2640 return;
2641}
2642
2643static void

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

2653 struct an_card_tx_desc an_tx_desc;
2654 u_int8_t *buf;
2655
2656 sc = ifp->if_softc;
2657
2658 if (sc->an_gone)
2659 return;
2660
2661 if (ifp->if_flags & IFF_OACTIVE)
2661 if (ifp->if_drv_flags & IFF_DRV_OACTIVE)
2662 return;
2663
2664 if (!sc->an_associated)
2665 return;
2666
2667 /* We can't send in monitor mode so toss any attempts. */
2668 if (sc->an_monitor && (ifp->if_flags & IFF_PROMISC)) {
2669 for (;;) {

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

2814 ifp->if_timer = 5;
2815 }
2816
2817 /* Re-enable interrupts. */
2818 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS(sc->mpi350));
2819 }
2820
2821 if (m0 != NULL)
2662 return;
2663
2664 if (!sc->an_associated)
2665 return;
2666
2667 /* We can't send in monitor mode so toss any attempts. */
2668 if (sc->an_monitor && (ifp->if_flags & IFF_PROMISC)) {
2669 for (;;) {

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

2814 ifp->if_timer = 5;
2815 }
2816
2817 /* Re-enable interrupts. */
2818 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), AN_INTRS(sc->mpi350));
2819 }
2820
2821 if (m0 != NULL)
2822 ifp->if_flags |= IFF_OACTIVE;
2822 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
2823
2824 sc->an_rdata.an_tx_prod = idx;
2825
2826 return;
2827}
2828
2829void
2830an_stop(sc)

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

2846 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
2847 an_cmd(sc, AN_CMD_DISABLE, 0);
2848
2849 for (i = 0; i < AN_TX_RING_CNT; i++)
2850 an_cmd(sc, AN_CMD_DEALLOC_MEM, sc->an_rdata.an_tx_fids[i]);
2851
2852 untimeout(an_stats_update, sc, sc->an_stat_ch);
2853
2823
2824 sc->an_rdata.an_tx_prod = idx;
2825
2826 return;
2827}
2828
2829void
2830an_stop(sc)

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

2846 CSR_WRITE_2(sc, AN_INT_EN(sc->mpi350), 0);
2847 an_cmd(sc, AN_CMD_DISABLE, 0);
2848
2849 for (i = 0; i < AN_TX_RING_CNT; i++)
2850 an_cmd(sc, AN_CMD_DEALLOC_MEM, sc->an_rdata.an_tx_fids[i]);
2851
2852 untimeout(an_stats_update, sc, sc->an_stat_ch);
2853
2854 ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
2854 ifp->if_drv_flags &= ~(IFF_DRV_RUNNING|IFF_DRV_OACTIVE);
2855
2856 if (sc->an_flash_buffer) {
2857 free(sc->an_flash_buffer, M_DEVBUF);
2858 sc->an_flash_buffer = NULL;
2859 }
2860
2861 AN_UNLOCK(sc);
2862

--- 888 unchanged lines hidden ---
2855
2856 if (sc->an_flash_buffer) {
2857 free(sc->an_flash_buffer, M_DEVBUF);
2858 sc->an_flash_buffer = NULL;
2859 }
2860
2861 AN_UNLOCK(sc);
2862

--- 888 unchanged lines hidden ---