diff options
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/an/if_an.c | 258 |
1 files changed, 82 insertions, 176 deletions
diff --git a/sys/dev/an/if_an.c b/sys/dev/an/if_an.c index 23f94ed..b2e356f 100644 --- a/sys/dev/an/if_an.c +++ b/sys/dev/an/if_an.c @@ -135,35 +135,35 @@ __FBSDID("$FreeBSD$"); #include <dev/an/if_anreg.h> /* These are global because we need them in sys/pci/if_an_p.c. */ -static void an_reset (struct an_softc *); -static int an_init_mpi350_desc (struct an_softc *); -static int an_ioctl (struct ifnet *, u_long, caddr_t); -static void an_init (void *); -static int an_init_tx_ring (struct an_softc *); -static void an_start (struct ifnet *); -static void an_watchdog (struct ifnet *); -static void an_rxeof (struct an_softc *); -static void an_txeof (struct an_softc *, int); - -static void an_promisc (struct an_softc *, int); -static int an_cmd (struct an_softc *, int, int); -static int an_cmd_struct (struct an_softc *, struct an_command *, - struct an_reply *); -static int an_read_record (struct an_softc *, struct an_ltv_gen *); -static int an_write_record (struct an_softc *, struct an_ltv_gen *); -static int an_read_data (struct an_softc *, int, int, caddr_t, int); -static int an_write_data (struct an_softc *, int, int, caddr_t, int); -static int an_seek (struct an_softc *, int, int, int); -static int an_alloc_nicmem (struct an_softc *, int, int *); -static int an_dma_malloc (struct an_softc *, bus_size_t, - struct an_dma_alloc *, int); -static void an_dma_free (struct an_softc *, struct an_dma_alloc *); -static void an_dma_malloc_cb (void *, bus_dma_segment_t *, int, int); -static void an_stats_update (void *); -static void an_setdef (struct an_softc *, struct an_req *); +static void an_reset(struct an_softc *); +static int an_init_mpi350_desc(struct an_softc *); +static int an_ioctl(struct ifnet *, u_long, caddr_t); +static void an_init(void *); +static int an_init_tx_ring(struct an_softc *); +static void an_start(struct ifnet *); +static void an_watchdog(struct ifnet *); +static void an_rxeof(struct an_softc *); +static void an_txeof(struct an_softc *, int); + +static void an_promisc(struct an_softc *, int); +static int an_cmd(struct an_softc *, int, int); +static int an_cmd_struct(struct an_softc *, struct an_command *, + struct an_reply *); +static int an_read_record(struct an_softc *, struct an_ltv_gen *); +static int an_write_record(struct an_softc *, struct an_ltv_gen *); +static int an_read_data(struct an_softc *, int, int, caddr_t, int); +static int an_write_data(struct an_softc *, int, int, caddr_t, int); +static int an_seek(struct an_softc *, int, int, int); +static int an_alloc_nicmem(struct an_softc *, int, int *); +static int an_dma_malloc(struct an_softc *, bus_size_t, struct an_dma_alloc *, + int); +static void an_dma_free(struct an_softc *, struct an_dma_alloc *); +static void an_dma_malloc_cb(void *, bus_dma_segment_t *, int, int); +static void an_stats_update(void *); +static void an_setdef(struct an_softc *, struct an_req *); #ifdef ANCACHE -static void an_cache_store (struct an_softc *, struct ether_header *, - struct mbuf *, u_int8_t, u_int8_t); +static void an_cache_store(struct an_softc *, struct ether_header *, + struct mbuf *, u_int8_t, u_int8_t); #endif /* function definitions for use with the Cisco's Linux configuration @@ -308,8 +308,7 @@ SYSCTL_PROC(_hw_an, OID_AUTO, an_cache_mode, CTLTYPE_STRING | CTLFLAG_RW, * find this, then there's no card present. */ int -an_probe(dev) - device_t dev; +an_probe(device_t dev) { struct an_softc *sc = device_get_softc(dev); struct an_ltv_ssidlist_new ssid; @@ -361,10 +360,7 @@ an_probe(dev) * Allocate a port resource with the given resource id. */ int -an_alloc_port(dev, rid, size) - device_t dev; - int rid; - int size; +an_alloc_port(device_t dev, int rid, int size) { struct an_softc *sc = device_get_softc(dev); struct resource *res; @@ -424,10 +420,7 @@ int an_alloc_aux_memory(device_t dev, int rid, int size) * Allocate an irq resource with the given resource id. */ int -an_alloc_irq(dev, rid, flags) - device_t dev; - int rid; - int flags; +an_alloc_irq(device_t dev, int rid, int flags) { struct an_softc *sc = device_get_softc(dev); struct resource *res; @@ -444,11 +437,7 @@ an_alloc_irq(dev, rid, flags) } static void -an_dma_malloc_cb(arg, segs, nseg, error) - void *arg; - bus_dma_segment_t *segs; - int nseg; - int error; +an_dma_malloc_cb(void *arg, bus_dma_segment_t *segs, int nseg, int error) { bus_addr_t *paddr = (bus_addr_t*) arg; *paddr = segs->ds_addr; @@ -458,11 +447,8 @@ an_dma_malloc_cb(arg, segs, nseg, error) * Alloc DMA memory and set the pointer to it */ static int -an_dma_malloc(sc, size, dma, mapflags) - struct an_softc *sc; - bus_size_t size; - struct an_dma_alloc *dma; - int mapflags; +an_dma_malloc(struct an_softc *sc, bus_size_t size, struct an_dma_alloc *dma, + int mapflags) { int r; @@ -497,9 +483,7 @@ fail_0: } static void -an_dma_free(sc, dma) - struct an_softc *sc; - struct an_dma_alloc *dma; +an_dma_free(struct an_softc *sc, struct an_dma_alloc *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); @@ -511,8 +495,7 @@ an_dma_free(sc, dma) * Release all resources */ void -an_release_resources(dev) - device_t dev; +an_release_resources(device_t dev) { struct an_softc *sc = device_get_softc(dev); int i; @@ -555,8 +538,7 @@ an_release_resources(dev) } int -an_init_mpi350_desc(sc) - struct an_softc *sc; +an_init_mpi350_desc(struct an_softc *sc) { struct an_command cmd_struct; struct an_reply reply; @@ -664,10 +646,7 @@ an_init_mpi350_desc(sc) } int -an_attach(sc, unit, flags) - struct an_softc *sc; - int unit; - int flags; +an_attach(struct an_softc *sc, int unit, int flags) { struct ifnet *ifp; int error = EIO; @@ -845,8 +824,7 @@ an_detach(device_t dev) } static void -an_rxeof(sc) - struct an_softc *sc; +an_rxeof(struct an_softc *sc) { struct ifnet *ifp; struct ether_header *eh; @@ -1108,9 +1086,7 @@ an_rxeof(sc) } static void -an_txeof(sc, status) - struct an_softc *sc; - int status; +an_txeof(struct an_softc *sc, int status) { struct ifnet *ifp; int id, i; @@ -1160,8 +1136,7 @@ an_txeof(sc, status) * in an ad-hoc group, or as a station connected to an access point). */ static void -an_stats_update(xsc) - void *xsc; +an_stats_update(void *xsc) { struct an_softc *sc; struct ifnet *ifp; @@ -1197,8 +1172,7 @@ an_stats_update(xsc) } void -an_intr(xsc) - void *xsc; +an_intr(void *xsc) { struct an_softc *sc; struct ifnet *ifp; @@ -1241,14 +1215,12 @@ an_intr(xsc) if (sc->mpi350 && status & AN_EV_TX_CPY) { an_txeof(sc, status); - CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), - AN_EV_TX_CPY); + CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_TX_CPY); } if (status & AN_EV_TX) { an_txeof(sc, status); - CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), - AN_EV_TX); + CSR_WRITE_2(sc, AN_EVENT_ACK(sc->mpi350), AN_EV_TX); } if (status & AN_EV_TX_EXC) { @@ -1272,10 +1244,8 @@ an_intr(xsc) static int -an_cmd_struct(sc, cmd, reply) - struct an_softc *sc; - struct an_command *cmd; - struct an_reply *reply; +an_cmd_struct(struct an_softc *sc, struct an_command *cmd, + struct an_reply *reply) { int i; @@ -1321,10 +1291,7 @@ an_cmd_struct(sc, cmd, reply) } static int -an_cmd(sc, cmd, val) - struct an_softc *sc; - int cmd; - int val; +an_cmd(struct an_softc *sc, int cmd, int val) { int i, s = 0; @@ -1369,8 +1336,7 @@ an_cmd(sc, cmd, val) * head and force it to reboot correctly. */ static void -an_reset(sc) - struct an_softc *sc; +an_reset(struct an_softc *sc) { if (sc->an_gone) return; @@ -1391,9 +1357,7 @@ an_reset(sc) * Read an LTV record from the NIC. */ static int -an_read_record(sc, ltv) - struct an_softc *sc; - struct an_ltv_gen *ltv; +an_read_record(struct an_softc *sc, struct an_ltv_gen *ltv) { struct an_ltv_gen *an_ltv; struct an_card_rid_desc an_rid_desc; @@ -1503,9 +1467,7 @@ an_read_record(sc, ltv) * Same as read, except we inject data instead of reading it. */ static int -an_write_record(sc, ltv) - struct an_softc *sc; - struct an_ltv_gen *ltv; +an_write_record(struct an_softc *sc, struct an_ltv_gen *ltv) { struct an_card_rid_desc an_rid_desc; struct an_command cmd; @@ -1605,10 +1567,7 @@ an_write_record(sc, ltv) } static void -an_dump_record(sc, ltv, string) - struct an_softc *sc; - struct an_ltv_gen *ltv; - char *string; +an_dump_record(struct an_softc *sc, struct an_ltv_gen *ltv, char *string) { u_int8_t *ptr2; int len; @@ -1650,9 +1609,7 @@ an_dump_record(sc, ltv, string) } static int -an_seek(sc, id, off, chan) - struct an_softc *sc; - int id, off, chan; +an_seek(struct an_softc *sc, int id, int off, int chan) { int i; int selreg, offreg; @@ -1686,11 +1643,7 @@ an_seek(sc, id, off, chan) } static int -an_read_data(sc, id, off, buf, len) - struct an_softc *sc; - int id, off; - caddr_t buf; - int len; +an_read_data(struct an_softc *sc, int id, int off, caddr_t buf, int len) { int i; u_int16_t *ptr; @@ -1713,11 +1666,7 @@ an_read_data(sc, id, off, buf, len) } static int -an_write_data(sc, id, off, buf, len) - struct an_softc *sc; - int id, off; - caddr_t buf; - int len; +an_write_data(struct an_softc *sc, int id, int off, caddr_t buf, int len) { int i; u_int16_t *ptr; @@ -1744,10 +1693,7 @@ an_write_data(sc, id, off, buf, len) * it out. */ static int -an_alloc_nicmem(sc, len, id) - struct an_softc *sc; - int len; - int *id; +an_alloc_nicmem(struct an_softc *sc, int len, int *id) { int i; @@ -1778,9 +1724,7 @@ an_alloc_nicmem(sc, len, id) } static void -an_setdef(sc, areq) - struct an_softc *sc; - struct an_req *areq; +an_setdef(struct an_softc *sc, struct an_req *areq) { struct sockaddr_dl *sdl; struct ifaddr *ifa; @@ -1893,15 +1837,13 @@ an_setdef(sc, areq) */ static void -an_promisc(sc, promisc) - struct an_softc *sc; - int promisc; +an_promisc(struct an_softc *sc, int promisc) { - if (sc->an_was_monitor) + if (sc->an_was_monitor) { an_reset(sc); - /* XXX: indentation bug or braces bug ? */ if (sc->mpi350) an_init_mpi350_desc(sc); + } if (sc->an_monitor || sc->an_was_monitor) an_init(sc); @@ -1912,10 +1854,7 @@ an_promisc(sc, promisc) } static int -an_ioctl(ifp, command, data) - struct ifnet *ifp; - u_long command; - caddr_t data; +an_ioctl(struct ifnet *ifp, u_long command, caddr_t data) { int error = 0; int len; @@ -2504,8 +2443,7 @@ out: } static int -an_init_tx_ring(sc) - struct an_softc *sc; +an_init_tx_ring(struct an_softc *sc) { int i; int id; @@ -2531,8 +2469,7 @@ an_init_tx_ring(sc) } static void -an_init(xsc) - void *xsc; +an_init(void *xsc) { struct an_softc *sc = xsc; struct ifnet *ifp = sc->an_ifp; @@ -2641,8 +2578,7 @@ an_init(xsc) } static void -an_start(ifp) - struct ifnet *ifp; +an_start(struct ifnet *ifp) { struct an_softc *sc; struct mbuf *m0 = NULL; @@ -2827,8 +2763,7 @@ an_start(ifp) } void -an_stop(sc) - struct an_softc *sc; +an_stop(struct an_softc *sc) { struct ifnet *ifp; int i; @@ -2864,8 +2799,7 @@ an_stop(sc) } static void -an_watchdog(ifp) - struct ifnet *ifp; +an_watchdog(struct ifnet *ifp) { struct an_softc *sc; @@ -2891,8 +2825,7 @@ an_watchdog(ifp) } void -an_shutdown(dev) - device_t dev; +an_shutdown(device_t dev) { struct an_softc *sc; @@ -2904,8 +2837,7 @@ an_shutdown(dev) } void -an_resume(dev) - device_t dev; +an_resume(device_t dev) { struct an_softc *sc; struct ifnet *ifp; @@ -2998,12 +2930,8 @@ SYSCTL_INT(_hw_an, OID_AUTO, an_cache_iponly, CTLFLAG_RW, * strength in MAC (src) indexed cache. */ static void -an_cache_store (sc, eh, m, rx_rssi, rx_quality) - struct an_softc *sc; - struct ether_header *eh; - struct mbuf *m; - u_int8_t rx_rssi; - u_int8_t rx_quality; +an_cache_store(struct an_softc *sc, struct ether_header *eh, struct mbuf *m, + u_int8_t rx_rssi, u_int8_t rx_quality) { struct ip *ip = 0; int i; @@ -3153,8 +3081,7 @@ an_cache_store (sc, eh, m, rx_rssi, rx_quality) #endif static int -an_media_change(ifp) - struct ifnet *ifp; +an_media_change(struct ifnet *ifp) { struct an_softc *sc = ifp->if_softc; struct an_ltv_genconfig *cfg; @@ -3195,9 +3122,7 @@ an_media_change(ifp) } static void -an_media_status(ifp, imr) - struct ifnet *ifp; - struct ifmediareq *imr; +an_media_status(struct ifnet *ifp, struct ifmediareq *imr) { struct an_ltv_status status; struct an_softc *sc = ifp->if_softc; @@ -3233,9 +3158,7 @@ an_media_status(ifp, imr) */ static int -readrids(ifp, l_ioctl) - struct ifnet *ifp; - struct aironet_ioctl *l_ioctl; +readrids(struct ifnet *ifp, struct aironet_ioctl *l_ioctl) { unsigned short rid; struct an_softc *sc; @@ -3304,9 +3227,7 @@ readrids(ifp, l_ioctl) } static int -writerids(ifp, l_ioctl) - struct ifnet *ifp; - struct aironet_ioctl *l_ioctl; +writerids(struct ifnet *ifp, struct aironet_ioctl *l_ioctl) { struct an_softc *sc; int rid, command; @@ -3409,8 +3330,7 @@ writerids(ifp, l_ioctl) #define FLASH_SIZE 32 * 1024 static int -unstickbusy(ifp) - struct ifnet *ifp; +unstickbusy(struct ifnet *ifp) { struct an_softc *sc = ifp->if_softc; @@ -3428,9 +3348,7 @@ unstickbusy(ifp) */ static int -WaitBusy(ifp, uSec) - struct ifnet *ifp; - int uSec; +WaitBusy(struct ifnet *ifp, int uSec) { int statword = 0xffff; int delay = 0; @@ -3454,8 +3372,7 @@ WaitBusy(ifp, uSec) */ static int -cmdreset(ifp) - struct ifnet *ifp; +cmdreset(struct ifnet *ifp) { int status; struct an_softc *sc = ifp->if_softc; @@ -3487,8 +3404,7 @@ cmdreset(ifp) */ static int -setflashmode(ifp) - struct ifnet *ifp; +setflashmode(struct ifnet *ifp) { int status; struct an_softc *sc = ifp->if_softc; @@ -3516,10 +3432,7 @@ setflashmode(ifp) */ static int -flashgchar(ifp, matchbyte, dwelltime) - struct ifnet *ifp; - int matchbyte; - int dwelltime; +flashgchar(struct ifnet *ifp, int matchbyte, int dwelltime) { int rchar; unsigned char rbyte = 0; @@ -3555,10 +3468,7 @@ flashgchar(ifp, matchbyte, dwelltime) */ static int -flashpchar(ifp, byte, dwelltime) - struct ifnet *ifp; - int byte; - int dwelltime; +flashpchar(struct ifnet *ifp, int byte, int dwelltime) { int echo; int pollbusy, waittime; @@ -3615,8 +3525,7 @@ flashpchar(ifp, byte, dwelltime) */ static int -flashputbuf(ifp) - struct ifnet *ifp; +flashputbuf(struct ifnet *ifp) { unsigned short *bufp; int nwords; @@ -3650,8 +3559,7 @@ flashputbuf(ifp) */ static int -flashrestart(ifp) - struct ifnet *ifp; +flashrestart(struct ifnet *ifp) { int status = 0; struct an_softc *sc = ifp->if_softc; @@ -3669,9 +3577,7 @@ flashrestart(ifp) */ static int -flashcard(ifp, l_ioctl) - struct ifnet *ifp; - struct aironet_ioctl *l_ioctl; +flashcard(struct ifnet *ifp, struct aironet_ioctl *l_ioctl) { int z = 0, status; struct an_softc *sc; |