Deleted Added
full compact
if_an.c (175445) if_an.c (175446)
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 175445 2008-01-18 16:31:24Z ambrisko $");
41__FBSDID("$FreeBSD: head/sys/dev/an/if_an.c 175446 2008-01-18 16:34:18Z 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.

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

257 }
258 if (an_dump != last)
259 printf("Sysctl changed for Aironet driver\n");
260
261 return error;
262}
263
264SYSCTL_PROC(_hw_an, OID_AUTO, an_dump, CTLTYPE_STRING | CTLFLAG_RW,
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.

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

257 }
258 if (an_dump != last)
259 printf("Sysctl changed for Aironet driver\n");
260
261 return error;
262}
263
264SYSCTL_PROC(_hw_an, OID_AUTO, an_dump, CTLTYPE_STRING | CTLFLAG_RW,
265 0, sizeof(an_conf), sysctl_an_dump, "A", "");
265 0, sizeof(an_conf), sysctl_an_dump, "A", "");
266
267static int
268sysctl_an_cache_mode(SYSCTL_HANDLER_ARGS)
269{
270 int error, last;
271
272 last = an_cache_mode;
273

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

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,
266
267static int
268sysctl_an_cache_mode(SYSCTL_HANDLER_ARGS)
269{
270 int error, last;
271
272 last = an_cache_mode;
273

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

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", "");
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{
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);
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/*
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{
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/*
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{
331 struct an_softc *sc = device_get_softc(dev);
331 struct an_softc *sc = device_get_softc(dev);
332 struct an_ltv_ssidlist_new ssid;
333 int error;
334
335 bzero((char *)&ssid, sizeof(ssid));
336
337 error = an_alloc_port(dev, 0, AN_IOSIZ);
338 if (error != 0)
339 return (0);

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

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
332 struct an_ltv_ssidlist_new ssid;
333 int error;
334
335 bzero((char *)&ssid, sizeof(ssid));
336
337 error = an_alloc_port(dev, 0, AN_IOSIZ);
338 if (error != 0)
339 return (0);

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

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. */
357 /* Make sure interrupts are disabled. */
358 sc->mpi350 = 0;
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);
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);
365 an_reset(sc);
366
367 if (an_cmd(sc, AN_CMD_READCFG, 0)) {
368 AN_UNLOCK(sc);

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

488 goto fail_0;
489
490 r = bus_dmamem_alloc(sc->an_dtag, (void**) &dma->an_dma_vaddr,
491 BUS_DMA_NOWAIT, &dma->an_dma_map);
492 if (r != 0)
493 goto fail_1;
494
495 r = bus_dmamap_load(sc->an_dtag, dma->an_dma_map, dma->an_dma_vaddr,
361
362 mtx_init(&sc->an_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
363 MTX_DEF | MTX_RECURSE);
364 AN_LOCK(sc);
365 an_reset(sc);
366
367 if (an_cmd(sc, AN_CMD_READCFG, 0)) {
368 AN_UNLOCK(sc);

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

488 goto fail_0;
489
490 r = bus_dmamem_alloc(sc->an_dtag, (void**) &dma->an_dma_vaddr,
491 BUS_DMA_NOWAIT, &dma->an_dma_map);
492 if (r != 0)
493 goto fail_1;
494
495 r = bus_dmamap_load(sc->an_dtag, dma->an_dma_map, dma->an_dma_vaddr,
496 size,
496 size,
497 an_dma_malloc_cb,
498 &dma->an_dma_paddr,
499 mapflags | BUS_DMA_NOWAIT);
500 if (r != 0)
501 goto fail_2;
502
503 dma->an_dma_size = size;
504 return (0);

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

1721 if (an_seek(sc, id, off, AN_BAP0))
1722 return(EIO);
1723 }
1724
1725 ptr = (u_int16_t *)buf;
1726 for (i = len; i > 1; i -= 2)
1727 CSR_WRITE_2(sc, AN_DATA0, *ptr++);
1728 if (i) {
497 an_dma_malloc_cb,
498 &dma->an_dma_paddr,
499 mapflags | BUS_DMA_NOWAIT);
500 if (r != 0)
501 goto fail_2;
502
503 dma->an_dma_size = size;
504 return (0);

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

1721 if (an_seek(sc, id, off, AN_BAP0))
1722 return(EIO);
1723 }
1724
1725 ptr = (u_int16_t *)buf;
1726 for (i = len; i > 1; i -= 2)
1727 CSR_WRITE_2(sc, AN_DATA0, *ptr++);
1728 if (i) {
1729 ptr2 = (u_int8_t *)ptr;
1730 CSR_WRITE_1(sc, AN_DATA0, *ptr2);
1729 ptr2 = (u_int8_t *)ptr;
1730 CSR_WRITE_1(sc, AN_DATA0, *ptr2);
1731 }
1732
1733 return(0);
1734}
1735
1736/*
1737 * Allocate a region of memory inside the NIC and zero
1738 * it out.

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

2011 goto out;
2012 AN_LOCK(sc);
2013 error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq));
2014 if (error != 0)
2015 break;
2016 an_setdef(sc, &sc->areq);
2017 AN_UNLOCK(sc);
2018 break;
1731 }
1732
1733 return(0);
1734}
1735
1736/*
1737 * Allocate a region of memory inside the NIC and zero
1738 * it out.

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

2011 goto out;
2012 AN_LOCK(sc);
2013 error = copyin(ifr->ifr_data, &sc->areq, sizeof(sc->areq));
2014 if (error != 0)
2015 break;
2016 an_setdef(sc, &sc->areq);
2017 AN_UNLOCK(sc);
2018 break;
2019 case SIOCGPRIVATE_0: /* used by Cisco client utility */
2019 case SIOCGPRIVATE_0: /* used by Cisco client utility */
2020 if ((error = priv_check(td, PRIV_DRIVER)))
2021 goto out;
2022 error = copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
2023 if (error)
2024 goto out;
2025 mode = l_ioctl.command;
2026
2027 AN_LOCK(sc);

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

2035 error =-1;
2036 }
2037 AN_UNLOCK(sc);
2038 if (!error) {
2039 /* copy out the updated command info */
2040 error = copyout(&l_ioctl, ifr->ifr_data, sizeof(l_ioctl));
2041 }
2042 break;
2020 if ((error = priv_check(td, PRIV_DRIVER)))
2021 goto out;
2022 error = copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
2023 if (error)
2024 goto out;
2025 mode = l_ioctl.command;
2026
2027 AN_LOCK(sc);

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

2035 error =-1;
2036 }
2037 AN_UNLOCK(sc);
2038 if (!error) {
2039 /* copy out the updated command info */
2040 error = copyout(&l_ioctl, ifr->ifr_data, sizeof(l_ioctl));
2041 }
2042 break;
2043 case SIOCGPRIVATE_1: /* used by Cisco client utility */
2043 case SIOCGPRIVATE_1: /* used by Cisco client utility */
2044 if ((error = priv_check(td, PRIV_DRIVER)))
2045 goto out;
2046 error = copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
2047 if (error)
2048 goto out;
2049 l_ioctl.command = 0;
2050 error = AIROMAGIC;
2051 (void) copyout(&error, l_ioctl.data, sizeof(error));
2044 if ((error = priv_check(td, PRIV_DRIVER)))
2045 goto out;
2046 error = copyin(ifr->ifr_data, &l_ioctl, sizeof(l_ioctl));
2047 if (error)
2048 goto out;
2049 l_ioctl.command = 0;
2050 error = AIROMAGIC;
2051 (void) copyout(&error, l_ioctl.data, sizeof(error));
2052 error = 0;
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);
2060 if (ireq->i_val == -1) {

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

2741static void
2742an_start(struct ifnet *ifp)
2743{
2744 struct an_softc *sc;
2745 struct mbuf *m0 = NULL;
2746 struct an_txframe_802_3 tx_frame_802_3;
2747 struct ether_header *eh;
2748 int id, idx, i;
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);
2060 if (ireq->i_val == -1) {

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

2741static void
2742an_start(struct ifnet *ifp)
2743{
2744 struct an_softc *sc;
2745 struct mbuf *m0 = NULL;
2746 struct an_txframe_802_3 tx_frame_802_3;
2747 struct ether_header *eh;
2748 int id, idx, i;
2749 unsigned char txcontrol;
2749 unsigned char txcontrol;
2750 struct an_card_tx_desc an_tx_desc;
2751 u_int8_t *buf;
2752
2753 sc = ifp->if_softc;
2754
2755 if (sc->an_gone)
2756 return;
2757

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

3055 *
3056 * Note: the Aironet only has a single byte of signal strength value
3057 * in the rx frame header, and it's not scaled to anything sensible.
3058 * This is kind of lame, but it's all we've got.
3059 */
3060
3061#ifdef documentation
3062
2750 struct an_card_tx_desc an_tx_desc;
2751 u_int8_t *buf;
2752
2753 sc = ifp->if_softc;
2754
2755 if (sc->an_gone)
2756 return;
2757

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

3055 *
3056 * Note: the Aironet only has a single byte of signal strength value
3057 * in the rx frame header, and it's not scaled to anything sensible.
3058 * This is kind of lame, but it's all we've got.
3059 */
3060
3061#ifdef documentation
3062
3063int an_sigitems; /* number of cached entries */
3064struct an_sigcache an_sigcache[MAXANCACHE]; /* array of cache entries */
3065int an_nextitem; /* index/# of entries */
3063int an_sigitems; /* number of cached entries */
3064struct an_sigcache an_sigcache[MAXANCACHE]; /* array of cache entries */
3065int an_nextitem; /* index/# of entries */
3066
3067
3068#endif
3069
3070/* control variables for cache filtering. Basic idea is
3071 * to reduce cost (e.g., to only Mobile-IP agent beacons
3072 * which are broadcast or multicast). Still you might
3073 * want to measure signal strength anth unicast ping packets

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

3094 */
3095static void
3096an_cache_store(struct an_softc *sc, struct ether_header *eh, struct mbuf *m,
3097 u_int8_t rx_rssi, u_int8_t rx_quality)
3098{
3099 struct ip *ip = 0;
3100 int i;
3101 static int cache_slot = 0; /* use this cache entry */
3066
3067
3068#endif
3069
3070/* control variables for cache filtering. Basic idea is
3071 * to reduce cost (e.g., to only Mobile-IP agent beacons
3072 * which are broadcast or multicast). Still you might
3073 * want to measure signal strength anth unicast ping packets

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

3094 */
3095static void
3096an_cache_store(struct an_softc *sc, struct ether_header *eh, struct mbuf *m,
3097 u_int8_t rx_rssi, u_int8_t rx_quality)
3098{
3099 struct ip *ip = 0;
3100 int i;
3101 static int cache_slot = 0; /* use this cache entry */
3102 static int wrapindex = 0; /* next "free" cache entry */
3102 static int wrapindex = 0; /* next "free" cache entry */
3103 int type_ipv4 = 0;
3104
3105 /* filters:
3106 * 1. ip only
3107 * 2. configurable filter to throw out unicast packets,
3108 * keep multicast only.
3109 */
3110

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

3167 * note: an_nextitem also holds number of entries
3168 * added in the cache table
3169 */
3170 if ( sc->an_nextitem < MAXANCACHE ) {
3171 cache_slot = sc->an_nextitem;
3172 sc->an_nextitem++;
3173 sc->an_sigitems = sc->an_nextitem;
3174 }
3103 int type_ipv4 = 0;
3104
3105 /* filters:
3106 * 1. ip only
3107 * 2. configurable filter to throw out unicast packets,
3108 * keep multicast only.
3109 */
3110

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

3167 * note: an_nextitem also holds number of entries
3168 * added in the cache table
3169 */
3170 if ( sc->an_nextitem < MAXANCACHE ) {
3171 cache_slot = sc->an_nextitem;
3172 sc->an_nextitem++;
3173 sc->an_sigitems = sc->an_nextitem;
3174 }
3175 /* no space found, so simply wrap anth wrap index
3175 /* no space found, so simply wrap anth wrap index
3176 * and "zap" the next entry
3177 */
3178 else {
3179 if (wrapindex == MAXANCACHE) {
3180 wrapindex = 0;
3181 }
3182 cache_slot = wrapindex++;
3183 }

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

3399 AN_LOCK(sc);
3400 return (error);
3401}
3402
3403static int
3404writerids(struct ifnet *ifp, struct aironet_ioctl *l_ioctl)
3405{
3406 struct an_softc *sc;
3176 * and "zap" the next entry
3177 */
3178 else {
3179 if (wrapindex == MAXANCACHE) {
3180 wrapindex = 0;
3181 }
3182 cache_slot = wrapindex++;
3183 }

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

3399 AN_LOCK(sc);
3400 return (error);
3401}
3402
3403static int
3404writerids(struct ifnet *ifp, struct aironet_ioctl *l_ioctl)
3405{
3406 struct an_softc *sc;
3407 int rid, command, error;
3407 int rid, command, error;
3408
3409 sc = ifp->if_softc;
3410 AN_LOCK_ASSERT(sc);
3411 rid = 0;
3412 command = l_ioctl->command;
3413
3414 switch (command) {
3415 case AIROPSIDS:

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

3527/*
3528 * Wait for busy completion from card wait for delay uSec's Return true for
3529 * success meaning command reg is clear
3530 */
3531
3532static int
3533WaitBusy(struct ifnet *ifp, int uSec)
3534{
3408
3409 sc = ifp->if_softc;
3410 AN_LOCK_ASSERT(sc);
3411 rid = 0;
3412 command = l_ioctl->command;
3413
3414 switch (command) {
3415 case AIROPSIDS:

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

3527/*
3528 * Wait for busy completion from card wait for delay uSec's Return true for
3529 * success meaning command reg is clear
3530 */
3531
3532static int
3533WaitBusy(struct ifnet *ifp, int uSec)
3534{
3535 int statword = 0xffff;
3536 int delay = 0;
3537 struct an_softc *sc = ifp->if_softc;
3535 int statword = 0xffff;
3536 int delay = 0;
3537 struct an_softc *sc = ifp->if_softc;
3538
3539 while ((statword & AN_CMD_BUSY) && delay <= (1000 * 100)) {
3540 FLASH_DELAY(sc, 10);
3541 delay += 10;
3542 statword = CSR_READ_2(sc, AN_COMMAND(sc->mpi350));
3543
3544 if ((AN_CMD_BUSY & statword) && (delay % 200)) {
3545 unstickbusy(ifp);

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

3551
3552/*
3553 * STEP 1) Disable MAC and do soft reset on card.
3554 */
3555
3556static int
3557cmdreset(struct ifnet *ifp)
3558{
3538
3539 while ((statword & AN_CMD_BUSY) && delay <= (1000 * 100)) {
3540 FLASH_DELAY(sc, 10);
3541 delay += 10;
3542 statword = CSR_READ_2(sc, AN_COMMAND(sc->mpi350));
3543
3544 if ((AN_CMD_BUSY & statword) && (delay % 200)) {
3545 unstickbusy(ifp);

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

3551
3552/*
3553 * STEP 1) Disable MAC and do soft reset on card.
3554 */
3555
3556static int
3557cmdreset(struct ifnet *ifp)
3558{
3559 int status;
3560 struct an_softc *sc = ifp->if_softc;
3559 int status;
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))) {
3568 printf("an%d: Waitbusy hang b4 RESET =%d\n",

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

3587
3588/*
3589 * STEP 2) Put the card in legendary flash mode
3590 */
3591
3592static int
3593setflashmode(struct ifnet *ifp)
3594{
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))) {
3568 printf("an%d: Waitbusy hang b4 RESET =%d\n",

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

3587
3588/*
3589 * STEP 2) Put the card in legendary flash mode
3590 */
3591
3592static int
3593setflashmode(struct ifnet *ifp)
3594{
3595 int status;
3596 struct an_softc *sc = ifp->if_softc;
3595 int status;
3596 struct an_softc *sc = ifp->if_softc;
3597
3598 CSR_WRITE_2(sc, AN_SW0(sc->mpi350), FLASH_COMMAND);
3599 CSR_WRITE_2(sc, AN_SW1(sc->mpi350), FLASH_COMMAND);
3600 CSR_WRITE_2(sc, AN_SW0(sc->mpi350), FLASH_COMMAND);
3601 CSR_WRITE_2(sc, AN_COMMAND(sc->mpi350), FLASH_COMMAND);
3602
3603 /*
3604 * mdelay(500); // 500ms delay

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

3615
3616/*
3617 * Get a character from the card matching matchbyte Step 3)
3618 */
3619
3620static int
3621flashgchar(struct ifnet *ifp, int matchbyte, int dwelltime)
3622{
3597
3598 CSR_WRITE_2(sc, AN_SW0(sc->mpi350), FLASH_COMMAND);
3599 CSR_WRITE_2(sc, AN_SW1(sc->mpi350), FLASH_COMMAND);
3600 CSR_WRITE_2(sc, AN_SW0(sc->mpi350), FLASH_COMMAND);
3601 CSR_WRITE_2(sc, AN_COMMAND(sc->mpi350), FLASH_COMMAND);
3602
3603 /*
3604 * mdelay(500); // 500ms delay

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

3615
3616/*
3617 * Get a character from the card matching matchbyte Step 3)
3618 */
3619
3620static int
3621flashgchar(struct ifnet *ifp, int matchbyte, int dwelltime)
3622{
3623 int rchar;
3624 unsigned char rbyte = 0;
3625 int success = -1;
3626 struct an_softc *sc = ifp->if_softc;
3623 int rchar;
3624 unsigned char rbyte = 0;
3625 int success = -1;
3626 struct an_softc *sc = ifp->if_softc;
3627
3628
3629 do {
3630 rchar = CSR_READ_2(sc, AN_SW1(sc->mpi350));
3631
3632 if (dwelltime && !(0x8000 & rchar)) {
3633 dwelltime -= 10;
3634 FLASH_DELAY(sc, 10);

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

3651
3652/*
3653 * Put character to SWS0 wait for dwelltime x 50us for echo .
3654 */
3655
3656static int
3657flashpchar(struct ifnet *ifp, int byte, int dwelltime)
3658{
3627
3628
3629 do {
3630 rchar = CSR_READ_2(sc, AN_SW1(sc->mpi350));
3631
3632 if (dwelltime && !(0x8000 & rchar)) {
3633 dwelltime -= 10;
3634 FLASH_DELAY(sc, 10);

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

3651
3652/*
3653 * Put character to SWS0 wait for dwelltime x 50us for echo .
3654 */
3655
3656static int
3657flashpchar(struct ifnet *ifp, int byte, int dwelltime)
3658{
3659 int echo;
3660 int pollbusy, waittime;
3661 struct an_softc *sc = ifp->if_softc;
3659 int echo;
3660 int pollbusy, waittime;
3661 struct an_softc *sc = ifp->if_softc;
3662
3663 byte |= 0x8000;
3664
3665 if (dwelltime == 0)
3666 dwelltime = 200;
3667
3668 waittime = dwelltime;
3669

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

3709 * Transfer 32k of firmware data from user buffer to our buffer and send to
3710 * the card
3711 */
3712
3713static int
3714flashputbuf(struct ifnet *ifp)
3715{
3716 unsigned short *bufp;
3662
3663 byte |= 0x8000;
3664
3665 if (dwelltime == 0)
3666 dwelltime = 200;
3667
3668 waittime = dwelltime;
3669

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

3709 * Transfer 32k of firmware data from user buffer to our buffer and send to
3710 * the card
3711 */
3712
3713static int
3714flashputbuf(struct ifnet *ifp)
3715{
3716 unsigned short *bufp;
3717 int nwords;
3718 struct an_softc *sc = ifp->if_softc;
3717 int nwords;
3718 struct an_softc *sc = ifp->if_softc;
3719
3720 /* Write stuff */
3721
3722 bufp = sc->an_flash_buffer;
3723
3724 if (!sc->mpi350) {
3725 CSR_WRITE_2(sc, AN_AUX_PAGE, 0x100);
3726 CSR_WRITE_2(sc, AN_AUX_OFFSET, 0);

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

3742
3743/*
3744 * After flashing restart the card.
3745 */
3746
3747static int
3748flashrestart(struct ifnet *ifp)
3749{
3719
3720 /* Write stuff */
3721
3722 bufp = sc->an_flash_buffer;
3723
3724 if (!sc->mpi350) {
3725 CSR_WRITE_2(sc, AN_AUX_PAGE, 0x100);
3726 CSR_WRITE_2(sc, AN_AUX_OFFSET, 0);

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

3742
3743/*
3744 * After flashing restart the card.
3745 */
3746
3747static int
3748flashrestart(struct ifnet *ifp)
3749{
3750 int status = 0;
3751 struct an_softc *sc = ifp->if_softc;
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);
3756 an_init(sc);
3757 AN_LOCK(sc);
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{
3752
3753 FLASH_DELAY(sc, 1024); /* Added 12/7/00 */
3754
3755 AN_UNLOCK(sc);
3756 an_init(sc);
3757 AN_LOCK(sc);
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;
3770 int z = 0, status;
3771 struct an_softc *sc;
3772
3773 sc = ifp->if_softc;
3774 if (sc->mpi350) {
3775 printf("an%d: flashing not supported on MPI 350 yet\n",
3776 sc->an_unit);
3777 return(-1);
3778 }

--- 72 unchanged lines hidden ---
3771 struct an_softc *sc;
3772
3773 sc = ifp->if_softc;
3774 if (sc->mpi350) {
3775 printf("an%d: flashing not supported on MPI 350 yet\n",
3776 sc->an_unit);
3777 return(-1);
3778 }

--- 72 unchanged lines hidden ---