summaryrefslogtreecommitdiffstats
path: root/sys/dev/an
diff options
context:
space:
mode:
authorambrisko <ambrisko@FreeBSD.org>2003-12-30 01:07:12 +0000
committerambrisko <ambrisko@FreeBSD.org>2003-12-30 01:07:12 +0000
commitdd8da6f3b336de5809dcbca650a6d79234d3a829 (patch)
tree8b9f3caeb5795ef2d529f037fe33777349ca3612 /sys/dev/an
parent0349754c19e68a2772d230b459d076d752d26b19 (diff)
downloadFreeBSD-src-dd8da6f3b336de5809dcbca650a6d79234d3a829.zip
FreeBSD-src-dd8da6f3b336de5809dcbca650a6d79234d3a829.tar.gz
- Bump up the general and status RID sizes
- Clear out an_dma_vaddr on free so we can test to see if dma is setup when the card is kldunloaded/kldloaded etc. only for MPI350 - Use a common detach like wi(4) - Notify on RID read overflow and truncate this currently causes a panic in -stable when the stack during an ifconfig an0 is done with newer firmware - Convert from UNLOCK/tsleep/LOCK to msleep. I thought I did that a while ago.
Diffstat (limited to 'sys/dev/an')
-rw-r--r--sys/dev/an/if_aironet_ieee.h4
-rw-r--r--sys/dev/an/if_an.c48
-rw-r--r--sys/dev/an/if_an_isa.c18
-rw-r--r--sys/dev/an/if_an_pccard.c24
-rw-r--r--sys/dev/an/if_an_pci.c18
-rw-r--r--sys/dev/an/if_anreg.h1
6 files changed, 46 insertions, 67 deletions
diff --git a/sys/dev/an/if_aironet_ieee.h b/sys/dev/an/if_aironet_ieee.h
index c894593..a838424 100644
--- a/sys/dev/an/if_aironet_ieee.h
+++ b/sys/dev/an/if_aironet_ieee.h
@@ -337,7 +337,7 @@ struct an_ltv_genconfig {
u_int8_t an_magic_packet_action; /* 0x98 */
u_int8_t an_magic_packet_ctl; /* 0x99 */
u_int16_t an_rsvd9;
- u_int16_t an_spare[13];
+ u_int16_t an_spare[19];
};
#define AN_OPMODE_IBSS_ADHOC 0x0000
@@ -593,7 +593,7 @@ struct an_ltv_status {
u_int8_t an_avg_noise_prev_min_db; /* 0x7D */
u_int8_t an_max_noise_prev_min_pc; /* 0x7E */
u_int8_t an_max_noise_prev_min_db; /* 0x7F */
- u_int16_t an_spare[8];
+ u_int16_t an_spare[18];
};
#define AN_STATUS_OPMODE_CONFIGURED 0x0001
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c
index ec96d95..b4aef61 100644
--- a/sys/dev/an/if_an.c
+++ b/sys/dev/an/if_an.c
@@ -503,6 +503,7 @@ an_dma_free(sc, dma)
{
bus_dmamap_unload(sc->an_dtag, dma->an_dma_map);
bus_dmamem_free(sc->an_dtag, dma->an_dma_vaddr, dma->an_dma_map);
+ dma->an_dma_vaddr = 0;
bus_dmamap_destroy(sc->an_dtag, dma->an_dma_map);
}
@@ -816,6 +817,29 @@ fail:;
return(error);
}
+int
+an_detach(device_t dev)
+{
+ struct an_softc *sc = device_get_softc(dev);
+ struct ifnet *ifp = &sc->arpcom.ac_if;
+
+ if (sc->an_gone) {
+ device_printf(dev,"already unloaded\n");
+ return(0);
+ }
+ AN_LOCK(sc);
+ an_stop(sc);
+ ifmedia_removeall(&sc->an_ifmedia);
+ ifp->if_flags &= ~IFF_RUNNING;
+ ether_ifdetach(ifp);
+ sc->an_gone = 1;
+ AN_UNLOCK(sc);
+ bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
+ an_release_resources(dev);
+ mtx_destroy(&sc->an_mtx);
+ return (0);
+}
+
static void
an_rxeof(sc)
struct an_softc *sc;
@@ -1417,6 +1441,8 @@ an_read_record(sc, ltv)
*ptr2 = CSR_READ_1(sc, AN_DATA1);
}
} else { /* MPI-350 */
+ if (!sc->an_rid_buffer.an_dma_vaddr)
+ return(EIO);
an_rid_desc.an_valid = 1;
an_rid_desc.an_len = AN_RID_BUFFER_SIZE;
an_rid_desc.an_rid = 0;
@@ -1449,11 +1475,18 @@ an_read_record(sc, ltv)
an_rid_desc.an_len = an_ltv->an_len;
}
- if (an_rid_desc.an_len > 2)
- bcopy(&an_ltv->an_type,
- &ltv->an_val,
- an_rid_desc.an_len - 2);
- ltv->an_len = an_rid_desc.an_len + 2;
+ len = an_rid_desc.an_len;
+ if (len > (ltv->an_len - 2)) {
+ printf("an%d: record length mismatch -- expected %d, "
+ "got %d for Rid %x\n", sc->an_unit,
+ ltv->an_len - 2, len, ltv->an_type);
+ len = ltv->an_len - 2;
+ } else {
+ ltv->an_len = len + 2;
+ }
+ bcopy(&an_ltv->an_type,
+ &ltv->an_val,
+ len);
}
if (an_dump)
@@ -3376,9 +3409,8 @@ writerids(ifp, l_ioctl)
* Linux driver
*/
-#define FLASH_DELAY(_sc, x) AN_UNLOCK(_sc) ; \
- tsleep(ifp, PZERO, "flash", ((x) / hz) + 1); \
- AN_LOCK(_sc) ;
+#define FLASH_DELAY(_sc, x) msleep(ifp, &(_sc)->an_mtx, PZERO, \
+ "flash", ((x) / hz) + 1);
#define FLASH_COMMAND 0x7e7e
#define FLASH_SIZE 32 * 1024
diff --git a/sys/dev/an/if_an_isa.c b/sys/dev/an/if_an_isa.c
index 8b0efd5..92b9d1c 100644
--- a/sys/dev/an/if_an_isa.c
+++ b/sys/dev/an/if_an_isa.c
@@ -79,7 +79,6 @@ static struct isa_pnp_id an_ids[] = {
static int an_probe_isa (device_t);
static int an_attach_isa (device_t);
-static int an_detach_isa (device_t);
static int
an_probe_isa(dev)
@@ -133,26 +132,11 @@ an_attach_isa(dev)
return (0);
}
-static int
-an_detach_isa(device_t dev)
-{
- struct an_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
-
- an_stop(sc);
- ifmedia_removeall(&sc->an_ifmedia);
- ether_ifdetach(ifp);
- bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
- an_release_resources(dev);
-
- return (0);
-}
-
static device_method_t an_isa_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, an_probe_isa),
DEVMETHOD(device_attach, an_attach_isa),
- DEVMETHOD(device_detach, an_detach_isa),
+ DEVMETHOD(device_detach, an_detach),
DEVMETHOD(device_shutdown, an_shutdown),
{ 0, 0 }
};
diff --git a/sys/dev/an/if_an_pccard.c b/sys/dev/an/if_an_pccard.c
index 4ecaaca..2dbd48a 100644
--- a/sys/dev/an/if_an_pccard.c
+++ b/sys/dev/an/if_an_pccard.c
@@ -79,13 +79,12 @@ __FBSDID("$FreeBSD$");
static int an_pccard_match(device_t);
static int an_pccard_probe(device_t);
static int an_pccard_attach(device_t);
-static int an_pccard_detach(device_t);
static device_method_t an_pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pccard_compat_probe),
DEVMETHOD(device_attach, pccard_compat_attach),
- DEVMETHOD(device_detach, an_pccard_detach),
+ DEVMETHOD(device_detach, an_detach),
DEVMETHOD(device_shutdown, an_shutdown),
/* Card interface */
@@ -131,27 +130,6 @@ an_pccard_match(device_t dev)
}
static int
-an_pccard_detach(device_t dev)
-{
- struct an_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
-
- if (sc->an_gone) {
- device_printf(dev,"already unloaded\n");
- return(0);
- }
- an_stop(sc);
- ifmedia_removeall(&sc->an_ifmedia);
- ifp->if_flags &= ~IFF_RUNNING;
- ether_ifdetach(ifp);
- sc->an_gone = 1;
- bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
- an_release_resources(dev);
- mtx_destroy(&sc->an_mtx);
- return (0);
-}
-
-static int
an_pccard_probe(device_t dev)
{
int error;
diff --git a/sys/dev/an/if_an_pci.c b/sys/dev/an/if_an_pci.c
index 3484679..67d27a3 100644
--- a/sys/dev/an/if_an_pci.c
+++ b/sys/dev/an/if_an_pci.c
@@ -111,7 +111,6 @@ static struct an_type an_devs[] = {
static int an_probe_pci (device_t);
static int an_attach_pci (device_t);
-static int an_detach_pci (device_t);
static int an_suspend_pci (device_t);
static int an_resume_pci (device_t);
@@ -250,21 +249,6 @@ fail:
}
static int
-an_detach_pci(device_t dev)
-{
- struct an_softc *sc = device_get_softc(dev);
- struct ifnet *ifp = &sc->arpcom.ac_if;
-
- an_stop(sc);
- ifmedia_removeall(&sc->an_ifmedia);
- ether_ifdetach(ifp);
- bus_teardown_intr(dev, sc->irq_res, sc->irq_handle);
- an_release_resources(dev);
-
- return (0);
-}
-
-static int
an_suspend_pci(device_t dev)
{
an_shutdown(dev);
@@ -284,7 +268,7 @@ static device_method_t an_pci_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, an_probe_pci),
DEVMETHOD(device_attach, an_attach_pci),
- DEVMETHOD(device_detach, an_detach_pci),
+ DEVMETHOD(device_detach, an_detach),
DEVMETHOD(device_shutdown, an_shutdown),
DEVMETHOD(device_suspend, an_suspend_pci),
DEVMETHOD(device_resume, an_resume_pci),
diff --git a/sys/dev/an/if_anreg.h b/sys/dev/an/if_anreg.h
index 6ed2bf9..47db1be 100644
--- a/sys/dev/an/if_anreg.h
+++ b/sys/dev/an/if_anreg.h
@@ -513,6 +513,7 @@ int an_probe (device_t);
void an_shutdown (device_t);
void an_resume (device_t);
int an_attach (struct an_softc *, int, int);
+int an_detach (device_t);
void an_stop (struct an_softc *);
driver_intr_t an_intr;
OpenPOWER on IntegriCloud