- 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.
This commit is contained in:
ambrisko 2003-12-30 01:07:12 +00:00
parent 0349754c19
commit dd8da6f3b3
6 changed files with 46 additions and 67 deletions

View File

@ -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

View File

@ -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

View File

@ -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 }
};

View File

@ -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 */
@ -130,27 +129,6 @@ an_pccard_match(device_t dev)
return (ENXIO);
}
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)
{

View File

@ -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);
@ -249,21 +248,6 @@ an_attach_pci(dev)
return(error);
}
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)
{
@ -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),

View File

@ -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;