Changeset 9
- Timestamp:
- 03/15/03 19:30:25 (6 years ago)
- Files:
-
- cvs-import/trunk/driver/Makefile (modified) (2 diffs)
- cvs-import/trunk/driver/if_ath.c (modified) (95 diffs)
- cvs-import/trunk/driver/if_ath_pci.c (modified) (10 diffs)
- cvs-import/trunk/driver/if_athvar.h (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
cvs-import/trunk/driver/Makefile
r3 r9 3 3 # Makefile for the Atheros WLAN driver. 4 4 # 5 DESTDIR= 6 7 VERSION= 2.4.20 5 8 6 9 # … … 13 16 ATH_HAL=../ath_hal 14 17 # 18 # Path to the 802.11 include files 19 # 20 WLAN= ../wlan 21 # 15 22 # Path to the Linux kernel include files. 16 23 # 17 LINUX= ../../linux- 2.4.20/include24 LINUX= ../../linux-${VERSION}/include 18 25 19 26 SRCS= ah_osdep.c if_ath.c if_ath_cs.c if_ath_pci.c 20 27 21 OBJS_COMMON= ah_osdep.o if_ath.o ${ATH_HAL}/hal.o 22 OBJS_CS= ${OBJS_COMMON} if_ath_cs.o 23 OBJS_PCI= ${OBJS_COMMON} if_ath_pci.o 28 OBJS_COMMON= ah_osdep.o if_ath.o 29 OBJS_CS= ${OBJS_COMMON} ${ATH_HAL}/hal.o if_ath_cs.o ${WLAN}/wlan.o 30 OBJS_PCI= ${OBJS_COMMON} ${ATH_HAL}/hal.o if_ath_pci.o ${WLAN}/wlan.o 31 OBJS= ${OBJS_COMMON} if_ath_cs.o if_ath_pci.o 24 32 25 CFLAGS= -I. -I${ATH_HAL} -I${HAL} -I${ LINUX} \26 -D_BUILD_STANDALONE_ -D__KERNEL__ - g -O33 CFLAGS= -I. -I${ATH_HAL} -I${HAL} -I${WLAN} -I${LINUX} \ 34 -D_BUILD_STANDALONE_ -D__KERNEL__ -DMODULE -g -O 27 35 28 all: ath_cs.o ath_pci.o 36 #ALL= ath_cs.o ath_pci.o 37 ALL= ath_pci.o 38 39 all: ${ALL} 40 41 install: all 42 cp ${ALL} ${DESTDIR}/lib/modules/${VERSION}/net 29 43 30 44 ath_cs.o: ${OBJS_CS} Makefile cvs-import/trunk/driver/if_ath.c
r3 r9 30 30 * Driver for the Atheros Wireless LAN controller. 31 31 */ 32 #include "opt_inet.h" 33 #define NBPFILTER 1 34 35 #include <sys/param.h> 36 #include <sys/systm.h> 37 #include <sys/sysctl.h> 38 #include <sys/mbuf.h> 39 #include <sys/malloc.h> 40 #include <sys/lock.h> 41 #include <sys/mutex.h> 42 #include <sys/kernel.h> 43 #include <sys/socket.h> 44 #include <sys/sockio.h> 45 #include <sys/errno.h> 46 #include <sys/callout.h> 47 #include <sys/bus.h> 48 #include <sys/endian.h> 49 50 #include <machine/bus.h> 51 52 #include <net/if.h> 53 #include <net/if_dl.h> 54 #include <net/if_media.h> 55 #include <net/ethernet.h> 56 #include <net/if_llc.h> 57 #include <net/if_ieee80211.h> 58 59 #if NBPFILTER > 0 60 #include <net/bpf.h> 61 #endif 62 63 #ifdef INET 64 #include <netinet/in.h> 65 #include <netinet/if_ether.h> 66 #endif 32 #include <linux/config.h> 33 #include <linux/version.h> 34 #include <linux/module.h> 35 #include <linux/init.h> 36 #include <linux/skbuff.h> 37 #include <linux/netdevice.h> 38 #include <linux/random.h> 39 #include <linux/pci.h> 40 #include <linux/delay.h> 41 42 #include <asm/uaccess.h> 67 43 68 44 #define AR_DEBUG 69 #include <dev/ath/if_athvar.h> 70 #include <contrib/dev/ath/ah_desc.h> 71 72 #ifndef M_DONTWAIT 73 #define M_DONTWAIT 0 /* XXX temporary workaround */ 74 #endif 75 76 /* NetBSD->FreeBSD portability shims */ 77 #define IF_POLL(ifq, m) ((m) = (ifq)->ifq_head) 78 #define IFQ_POLL(ifq, m) IF_POLL((ifq), (m)) 79 #define IFQ_DEQUEUE(ifq, m) IF_DEQUEUE((ifq), (m)) 45 #include "if_athvar.h" 46 #include "if_ethersubr.h" /* for ETHER_IS_MULTICAST */ 47 #include "ah_desc.h" 80 48 81 49 /* unalligned little endian access */ … … 88 56 (((u_int8_t *)(p))[2] << 16) | (((u_int8_t *)(p))[3] << 24))) 89 57 90 static void ath_init(void *); 91 static void ath_stop(struct ifnet *, int); 92 static void ath_start(struct ifnet *); 93 static void ath_watchdog(struct ifnet *); 94 static int ath_ioctl(struct ifnet *, u_long, caddr_t); 95 static int ath_media_change(struct ifnet *ifp); 96 static void ath_media_status(struct ifnet *ifp, struct ifmediareq *imr); 97 static void ath_mode_init(struct ath_softc *); 58 /* Bit map related macros. */ 59 #define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY)) 60 #define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY))) 61 #define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY))) 62 #define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0) 63 64 static int ath_init(struct net_device *); 65 static int ath_stop(struct net_device *); 66 static void ath_start(struct net_device *); 67 static void ath_watchdog(struct net_device *); 68 static int ath_ioctl(struct net_device *, struct ifreq *, int); 69 static int ath_media_change(struct net_device *); 70 static void ath_media_status(struct net_device *, struct ifmediareq *); 71 static void ath_mode_init(struct net_device *); 98 72 static int ath_beacon_alloc(struct ath_softc *, struct ieee80211_node *); 99 73 static void ath_beacon_int(struct ath_softc *); … … 104 78 static int ath_rxbuf_init(struct ath_softc *, struct ath_buf *); 105 79 static void ath_rx_int(struct ath_softc *); 80 static int ath_hardstart(struct sk_buff *, struct net_device *); 106 81 static int ath_tx_start(struct ath_softc *, struct ieee80211_node *, 107 struct ath_buf *, struct mbuf *);82 struct ath_buf *, struct sk_buff *); 108 83 static void ath_tx_int(struct ath_softc *); 109 84 static HAL_CHANNEL *ath_chan_find(struct ath_softc *, u_int); … … 112 87 static void ath_stoprecv(struct ath_softc *); 113 88 static int ath_startrecv(struct ath_softc *); 114 static void ath_next_scan( void *);115 static void ath_calibrate( void *);89 static void ath_next_scan(unsigned long); 90 static void ath_calibrate(unsigned long); 116 91 static int ath_newstate(void *, enum ieee80211_state); 117 92 static void ath_rate_ctl(struct ath_softc *, struct ieee80211_node *); 93 static struct net_device_stats *ath_getstats(struct net_device *); 118 94 119 95 #ifdef AR_DEBUG 120 96 int ath_debug = 2; /*XXX*/ 121 SYSCTL_INT(_debug, OID_AUTO, ath, CTLFLAG_RW, &ath_debug, 122 0, "Atheros driver debugging printfs"); 123 #define IFF_DUMPPKTS(_ifp) \ 124 (ath_debug || \ 125 ((_ifp)->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) 97 #define IFF_DUMPPKTS(_ic) (ath_debug || netif_msg_dumppkts(_ic)) 126 98 static void ath_printrxbuf(struct ath_buf *bf); 127 99 static void ath_printtxbuf(struct ath_buf *bf); 128 100 #else 129 #define IFF_DUMPPKTS(_ifp) \ 130 (((_ifp)->if_flags & (IFF_DEBUG|IFF_LINK2)) == (IFF_DEBUG|IFF_LINK2)) 101 #define IFF_DUMPPKTS(_ic) netif_msg_dumppkts(_ic) 131 102 #endif 132 103 … … 145 116 146 117 int 147 ath_attach(u_int16_t devid, struct ath_softc *sc) 148 { 118 ath_attach(uint16_t devid, struct net_device *dev) 119 { 120 struct ath_softc *sc = dev->priv; 149 121 struct ieee80211com *ic = &sc->sc_ic; 150 struct ifnet *ifp = &ic->ic_if;151 122 struct ath_hal *ah; 152 123 int i, error = 0; … … 155 126 HAL_STATUS status; 156 127 157 DPRINTF(("ath_attach: devid 0x%x\n", devid)); 158 159 /* set these up early for if_printf use */ 160 ifp->if_unit = device_get_unit(sc->sc_dev); 161 ifp->if_name = "ath"; 162 163 ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, &status); 128 DPRINTF(("ath_attach: unit %d devid 0x%x\n", sc->sc_unit, devid)); 129 130 spin_lock_init(&sc->sc_lock); 131 skb_queue_head_init(&sc->sc_sndq); 132 133 ah = ath_hal_attach(devid, sc, 0, (void *) dev->mem_start, &status); 164 134 if (ah == NULL) { 165 if_printf(ifp, "unable to attach hardware; HAL status %u\n",166 status);135 printk(KERN_ERR "%s: unable to attach hardware; HAL status %u\n", 136 dev->name, status); 167 137 error = ENXIO; 168 138 goto bad; … … 177 147 CTRY_DEFAULT, MODE_SELECT_11A, 1)) { 178 148 #endif 179 if_printf(ifp, "unable to initialize channel list\n"); 149 printk(KERN_ERR "%s: unable to initialize channel list\n", 150 dev->name); 180 151 error = EINVAL; 181 152 goto bad; … … 186 157 error = ath_desc_alloc(sc); 187 158 if (error != 0) { 188 if_printf(ifp, "failed to allocate descriptors: %d\n", error); 159 printk("%s: failed to allocate descriptors: %d\n", 160 dev->name, error); 189 161 goto bad; 190 162 } 191 callout_init(&sc->sc_scan_ch, 0); 192 callout_init(&sc->sc_cal_ch, 0); 193 194 ifp->if_softc = sc; 195 ifp->if_flags = IFF_SIMPLEX | IFF_BROADCAST | IFF_MULTICAST; 196 ifp->if_start = ath_start; 197 ifp->if_watchdog = ath_watchdog; 198 ifp->if_ioctl = ath_ioctl; 199 ifp->if_init = ath_init; 163 init_timer(&sc->sc_scan_ch); 164 sc->sc_scan_ch.function = ath_next_scan; 165 sc->sc_scan_ch.data = (unsigned long) sc; 166 init_timer(&sc->sc_cal_ch); 167 sc->sc_cal_ch.function = ath_calibrate; 168 sc->sc_cal_ch.data = (unsigned long) sc; 169 200 170 #if 0 201 ifp->if_stop = ath_stop;171 dev->features |= NETIF_F_SG; /* scatter/gather supported */ 202 172 #endif 203 ifp->if_snd.ifq_maxlen = IFQ_MAXLEN; 204 205 ic->ic_softc = sc; 173 dev->open = ath_init; 174 dev->hard_start_xmit = ath_hardstart; 175 dev->stop = ath_stop; 176 dev->get_stats = ath_getstats; 177 dev->set_multicast_list = ath_mode_init; 178 dev->do_ioctl = ath_ioctl; 179 206 180 ic->ic_newstate = ath_newstate; 207 181 ic->ic_phytype = IEEE80211_T_OFDM; … … 247 221 } 248 222 249 if_printf(ifp, "802.11 address: %s\n", ether_sprintf(ic->ic_myaddr)); 223 printk("%s: 802.11 address: %s\n", dev->name, 224 ether_sprintf(ic->ic_myaddr)); 250 225 251 226 /* call MI attach routine. */ 252 ieee80211_ifattach( ifp);227 ieee80211_ifattach(dev); 253 228 254 229 ifmedia_init(&sc->sc_media, 0, ath_media_change, ath_media_status); … … 262 237 IFM_MAKEWORD(IFM_IEEE80211, IFM_AUTO, IFM_IEEE80211_HOSTAP, 0), 263 238 0, NULL); 264 ath_media_status( ifp, &imr);239 ath_media_status(dev, &imr); 265 240 ifmedia_set(&sc->sc_media, imr.ifm_active); 266 241 … … 276 251 277 252 int 278 ath_detach(struct ath_softc *sc)279 { 280 struct ifnet *ifp = &sc->sc_ic.ic_if;253 ath_detach(struct net_device *dev) 254 { 255 struct ath_softc *sc = dev->priv; 281 256 282 257 DPRINTF(("ath_detach: sc_attached %u\n", sc->sc_attached)); … … 284 259 if (sc->sc_attached) { 285 260 sc->sc_invalid = 1; 286 ath_stop( ifp, 1);261 ath_stop(dev); 287 262 ath_desc_free(sc); 288 263 ath_hal_detach(sc->sc_ah); 289 264 ifmedia_removeall(&sc->sc_media); 290 ieee80211_ifdetach(ifp); 291 #ifdef __NetBSD__ 292 if_detach(ifp); 293 #endif 265 ieee80211_ifdetach(dev); 294 266 } 295 267 ATH_UNLOCK(sc); … … 297 269 } 298 270 299 #ifdef __NetBSD__300 int301 ath_activate(struct device *self, enum devact act)302 {303 struct ath_softc *sc = (struct ath_softc *)self;304 struct ifnet *ifp = &sc->sc_ic.ic_if;305 int error = 0;306 307 ATH_LOCK(sc);308 switch (act) {309 case DVACT_ACTIVATE:310 error = EOPNOTSUPP;311 break;312 case DVACT_DEACTIVATE:313 sc->sc_invalid = 1;314 if_deactivate(ifp);315 break;316 }317 ATH_UNLOCK(sc);318 return error;319 }320 #endif /* __NetBSD__ */321 322 271 void 323 ath_suspend(struct ath_softc *sc)324 { 325 struct ifnet *ifp = &sc->sc_ic.ic_if;272 ath_suspend(struct net_device *dev) 273 { 274 struct ath_softc *sc = dev->priv; 326 275 327 276 DPRINTF(("ath_suspend: sc_attached %u\n", sc->sc_attached)); 328 277 if (sc->sc_attached) { 329 278 ATH_LOCK(sc); 330 ath_stop( ifp, 1);279 ath_stop(dev); 331 280 ATH_UNLOCK(sc); 332 281 } … … 334 283 335 284 void 336 ath_resume(struct ath_softc *sc)337 { 338 struct ifnet *ifp = &sc->sc_ic.ic_if;285 ath_resume(struct net_device *dev) 286 { 287 struct ath_softc *sc = dev->priv; 339 288 340 289 DPRINTF(("ath_resume: sc_attached %u\n", sc->sc_attached)); 341 290 if (sc->sc_attached) { 342 291 ATH_LOCK(sc); 343 if ( ifp->if_flags & IFF_UP)344 ath_init( ifp);292 if (dev->flags & IFF_UP) 293 ath_init(dev); 345 294 ATH_UNLOCK(sc); 346 295 } … … 348 297 349 298 void 350 ath_shutdown(struct ath_softc *sc)351 { 352 struct ifnet *ifp = &sc->sc_ic.ic_if;299 ath_shutdown(struct net_device *dev) 300 { 301 struct ath_softc *sc = dev->priv; 353 302 354 303 DPRINTF(("ath_shutdown: sc_attached %u\n", sc->sc_attached)); 355 304 if (sc->sc_attached) 356 ath_stop( ifp, 1);305 ath_stop(dev); 357 306 } 358 307 … … 361 310 { 362 311 struct net_device *dev = dev_id; 363 local_info_t *local = dev->priv; 364 365 struct ath_softc *sc = arg; 312 struct ath_softc *sc = dev->priv; 366 313 struct ieee80211com *ic = &sc->sc_ic; 367 struct ifnet *ifp = &ic->ic_if;368 314 struct ath_hal *ah = sc->sc_ah; 369 315 HAL_INT status; 370 371 if (local->func->card_present && !local->func->card_present(local)) {372 printk(KERN_DEBUG "%s: interrupt, but device not OK\n",373 dev->name);374 return;375 }376 316 377 317 ATH_LOCK(sc); … … 380 320 DPRINTF2(("ath_intr: status 0x%x\n", status)); 381 321 if (status & HAL_INT_FATAL) { 382 if_printf(ifp, "hardware error (0x%x); resetting\n",383 status);322 printk("%s: hardware error (0x%x); resetting\n", 323 dev->name, status); 384 324 ath_hal_dumpstate(ah); /*XXX*/ 385 ath_init( ifp);325 ath_init(dev); 386 326 continue; 387 327 } 388 328 if (status & HAL_INT_RXORN) { 389 if_printf(ifp, "rx FIFO overrun (0x%x); resetting\n",390 status);329 printk("%s: rx FIFO overrun (0x%x); resetting\n", 330 dev->name, status); 391 331 ath_hal_dumpstate(ah); /*XXX*/ 392 ath_init( ifp);332 ath_init(dev); 393 333 continue; 394 334 } … … 413 353 if (ic->ic_opmode == IEEE80211_M_STA && 414 354 ic->ic_state == IEEE80211_S_RUN) 415 ieee80211_new_state( ifp, IEEE80211_S_SCAN, -1);355 ieee80211_new_state(dev, IEEE80211_S_SCAN, -1); 416 356 } 417 357 #endif … … 436 376 else 437 377 /* XXX return value */ 438 ath_hal_keyset(ah, i, k);439 } 440 } 441 442 static void443 ath_init( void *arg)444 { 445 struct ath_softc *sc = (struct ath_softc *) arg;378 ath_hal_keyset(ah, i, (const HAL_KEYVAL *) k); 379 } 380 } 381 382 static int 383 ath_init(struct net_device *dev) 384 { 385 struct ath_softc *sc = dev->priv; 446 386 struct ieee80211com *ic = &sc->sc_ic; 447 struct ifnet *ifp = &ic->ic_if;448 387 struct ieee80211_node *ni = &ic->ic_bss; 449 388 struct ath_hal *ah = sc->sc_ah; … … 452 391 453 392 ATH_LOCK(sc); 454 DPRINTF(("ath_init: enabled=%d\n", sc->sc_enabled)); 455 if (!sc->sc_enabled) { 456 if (sc->sc_enable) 457 (*sc->sc_enable)(sc); 458 sc->sc_enabled = 1; 459 } else { 460 ath_stop(ifp, 0); 461 } 393 DPRINTF(("ath_init\n")); 394 462 395 ic->ic_state = IEEE80211_S_INIT; 463 396 … … 470 403 */ 471 404 if (!ath_hal_reset(ah, ic->ic_opmode, sc->sc_cur_chan, AH_FALSE, &status)) { 472 if_printf(ifp, "unable to reset hardware; HAL status %u\n",473 status);405 printk("%s: unable to reset hardware; HAL status %u\n", 406 dev->name, status); 474 407 ATH_UNLOCK(sc); 475 408 return; … … 485 418 ath_initkeytable(sc); 486 419 if (ath_startrecv(sc) != 0) { 487 if_printf(ifp, "unable to start recv logic\n");420 printk("%s: unable to start recv logic\n", dev->name); 488 421 ATH_UNLOCK(sc); 489 422 return; … … 500 433 ath_hal_intrset(ah, val | HAL_INT_GLOBAL); 501 434 502 ifp->if_flags |= IFF_RUNNING;503 ifp->if_flags &= ~IFF_OACTIVE;435 dev->flags |= IFF_RUNNING; 436 netif_start_queue(dev); 504 437 505 438 /* … … 530 463 ic->ic_flags |= IEEE80211_F_SIBSS; 531 464 ic->ic_state = IEEE80211_S_SCAN; /*XXX*/ 532 ieee80211_new_state( &ic->ic_if, IEEE80211_S_RUN, -1);465 ieee80211_new_state(dev, IEEE80211_S_RUN, -1); 533 466 } else { 534 467 HAL_CHANNEL *c = sc->sc_cur_chan; 535 468 ni->ni_chan = ath_hal_ghz2ieee(c->channel, c->channelFlags); 536 ieee80211_new_state( ifp, IEEE80211_S_SCAN, -1);469 ieee80211_new_state(dev, IEEE80211_S_SCAN, -1); 537 470 } 538 471 ATH_UNLOCK(sc); 539 } 540 541 static void 542 ath_stop(struct ifnet *ifp, int disable) 543 { 544 struct ath_softc *sc = ifp->if_softc; 472 473 return 0; 474 } 475 476 static int 477 ath_stop(struct net_device *dev) 478 { 479 struct ath_softc *sc = dev->priv; 545 480 struct ath_hal *ah = sc->sc_ah; 546 481 struct ath_buf *bf; 547 482 548 483 ATH_LOCK(sc); 549 if (!sc->sc_enabled) { 550 ATH_UNLOCK(sc); 551 return; 552 } 553 DPRINTF(("ath_stop(%d): sc_invalid %u\n", disable, sc->sc_invalid)); 554 555 ieee80211_new_state(ifp, IEEE80211_S_INIT, -1); 484 DPRINTF(("ath_stop: sc_invalid %u\n", sc->sc_invalid)); 485 486 ieee80211_new_state(dev, IEEE80211_S_INIT, -1); 556 487 if (!sc->sc_invalid) { 557 488 /* … … 561 492 ath_draintxq(sc); /* clear pending tx frames */ 562 493 ath_stoprecv(sc); /* turn off frame recv */ 563 if (disable) 564 ath_hal_setpower(ah, PM_FULL_SLEEP, 0); 494 ath_hal_setpower(ah, PM_FULL_SLEEP, 0); 565 495 } 566 496 ath_beacon_free(sc); 567 497 sc->sc_txlink = sc->sc_rxlink = NULL; 568 ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE); 569 ifp->if_timer = 0; 498 dev->flags &= ~IFF_RUNNING; 499 sc->sc_oactive = 0; 500 sc->sc_ic.ic_timer = 0; 570 501 sc->sc_tx_timer = 0; 571 IF_DRAIN(&ifp->if_snd);502 skb_queue_purge(&sc->sc_sndq); 572 503 573 504 /* free transmit queue */ 574 505 while ((bf = TAILQ_FIRST(&sc->sc_txq)) != NULL) { 575 bus_dmamap_unload(sc->sc_dmat, bf->bf_dmamap); 576 m_freem(bf->bf_m); 577 bf->bf_m = NULL; 506 pci_unmap_single(sc->sc_pci_dev, 507 bf->bf_daddr, bf->bf_skb->len, PCI_DMA_FROMDEVICE); 508 dev_kfree_skb(bf->bf_skb); 509 bf->bf_skb = NULL; 578 510 bf->bf_node = NULL; 579 511 TAILQ_REMOVE(&sc->sc_txq, bf, bf_list); 580 512 TAILQ_INSERT_TAIL(&sc->sc_txbuf, bf, bf_list); 581 513 } 582 583 if (disable) {584 if (sc->sc_disable)585 (*sc->sc_disable)(sc);586 sc->sc_enabled = 0;587 }588 514 ATH_UNLOCK(sc); 515 516 return 0; 517 } 518 519 /* 520 * Accept packets from above; we queue them and kick the common 521 * start code. This is very un-Linux like but insures any management 522 * frames get priority w/o totally mangling the existing logic. 523 */ 524 static int 525 ath_hardstart(struct sk_buff *skb, struct net_device *dev) 526 { 527 struct ath_softc *sc = dev->priv; 528 529 ATH_LOCK(sc); 530 skb_queue_tail(&sc->sc_sndq, skb); 531 if (!sc->sc_oactive) 532 ath_start(dev); 533 ATH_UNLOCK(sc); 589 534 } 590 535 591 536 static void 592 ath_start(struct ifnet *ifp)593 { 594 struct ath_softc *sc = ifp->if_softc;537 ath_start(struct net_device *dev) 538 { 539 struct ath_softc *sc = dev->priv; 595 540 struct ath_hal *ah = sc->sc_ah; 596 541 struct ieee80211com *ic = &sc->sc_ic; 597 542 struct ieee80211_node *ni; 598 543 struct ath_buf *bf; 599 struct mbuf *m;544 struct sk_buff *skb; 600 545 struct ieee80211_frame *wh; 601 546 602 547 ATH_LOCK(sc); 603 if ( !sc->sc_enabled ||sc->sc_invalid) {548 if (sc->sc_invalid) { 604 549 ATH_UNLOCK(sc); 605 550 return; … … 614 559 * have priority over normal data frames. 615 560 */ 616 IF_POLL(&ic->ic_mgtq, m);617 if ( m!= NULL) {561 skb = skb_peek(&ic->ic_mgtq); 562 if (skb != NULL) { 618 563 if (bf == NULL) { 619 564 DPRINTF(("ath_start: out of xmit buffers (mgtq)\n")); 620 ifp->if_flags |= IFF_OACTIVE;565 sc->sc_oactive = 0; 621 566 break; 622 567 } 623 IF_DEQUEUE(&ic->ic_mgtq, m);624 wh = mtod(m, struct ieee80211_frame *);568 skb = skb_dequeue(&ic->ic_mgtq); 569 wh = (struct ieee80211_frame *) skb->data; 625 570 if ((wh->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK) == 626 571 IEEE80211_FC0_SUBTYPE_PROBE_RESP) { … … 633 578 tsf += 100; 634 579 tstamp = (u_int32_t *)&wh[1]; 635 tstamp[0] = htole32(tsf & 0xffffffff);636 tstamp[1] = htole32(tsf >> 32);580 tstamp[0] = cpu_to_le32(tsf & 0xffffffff); 581 tstamp[1] = cpu_to_le32(tsf >> 32); 637 582 } 638 583 } else { … … 645 590 break; 646 591 } 647 IFQ_POLL(&ifp->if_snd, m);648 if ( m== NULL)592 skb = skb_peek(&sc->sc_sndq); 593 if (skb == NULL) 649 594 break; 650 595 if (bf == NULL) { 651 596 DPRINTF(("ath_start: out of xmit buffers (data)\n")); 652 ifp->if_flags |= IFF_OACTIVE;597 sc->sc_oactive = 1; 653 598 break; 654 599 } 655 IFQ_DEQUEUE(&ifp->if_snd, m); 656 ifp->if_opackets++; 657 #if NBPFILTER > 0 658 BPF_MTAP(ifp, m); 659 #endif 600 skb = skb_dequeue(&sc->sc_sndq); 601 ic->ic_stats.tx_packets++; 660 602 /* 661 603 * Encapsulate the packet in prep for transmission. 662 604 */ 663 m = ieee80211_encap(ifp, m);664 if ( m== NULL) {605 skb = ieee80211_encap(dev, skb); 606 if (skb == NULL) { 665 607 DPRINTF(("ath_start: encapsulation failure\n")); 666 608 sc->sc_stats.ast_tx_encap++; 667 i fp->if_oerrors++;609 ic->ic_stats.tx_errors++; 668 610 continue; 669 611 } 670 wh = mtod(m, struct ieee80211_frame *);612 wh = (struct ieee80211_frame *) skb->data; 671 613 if (ic->ic_flags & IEEE80211_F_WEPON) 672 614 wh->i_fc[1] |= IEEE80211_FC1_WEP; … … 679 621 (wh->i_fc[0] & IEEE80211_FC0_TYPE_MASK) == 680 622 IEEE80211_FC0_TYPE_DATA) { 681 m_freem(m);623 dev_kfree_skb(skb); 682 624 sc->sc_stats.ast_tx_nonode++; 683 i fp->if_oerrors++;625 ic->ic_stats.tx_errors++; 684 626 continue; 685 627 } … … 695 637 */ 696 638 697 if (IFF_DUMPPKTS(i fp))698 ieee80211_dump_pkt( mtod(m, u_int8_t *), m->m_len,639 if (IFF_DUMPPKTS(ic)) 640 ieee80211_dump_pkt(skb->data, skb->len, 699 641 ni->ni_rates[ni->ni_txrate] & IEEE80211_RATE_VAL, 700 642 -1); 701 643 702 if (ath_tx_start(sc, ni, bf, m)) {703 i fp->if_oerrors++;644 if (ath_tx_start(sc, ni, bf, skb)) { 645 ic->ic_stats.tx_errors++; 704 646 continue; 705 647 } 706 648 707 649 sc->sc_tx_timer = 5; 708 i fp->if_timer = 1;650 ic->ic_timer = 1; 709 651 } 710 652 ATH_UNLOCK(sc); … … 712 654 713 655 static void 714 ath_watchdog(struct ifnet *ifp) 715 { 716 struct ath_softc *sc = ifp->if_softc; 656 ath_watchdog(struct net_device *dev) 657 { 658 struct ath_softc *sc = dev->priv; 659 struct ieee80211com *ic = &sc->sc_ic; 717 660 struct ieee80211_node *ni; 718 661 719 662 ATH_LOCK(sc); 720 i fp->if_timer = 0;721 if ( !sc->sc_enabled ||sc->sc_invalid) {663 ic->ic_timer = 0; 664 if (sc->sc_invalid) { 722 665 ATH_UNLOCK(sc); 723 666 return; … … 725 668 if (sc->sc_tx_timer) { 726 669 if (--sc->sc_tx_timer == 0) { 727 if_printf(ifp, "device timeout\n");670 printk("%s: device timeout\n", dev->name); 728 671 ath_hal_dumpstate(sc->sc_ah); /*XXX*/ 729 ath_init( ifp);730 i fp->if_oerrors++;672 ath_init(dev); 673 ic->ic_stats.tx_errors++; 731 674 sc->sc_stats.ast_watchdog++; 732 675 ATH_UNLOCK(sc); 733 676 return; 734 677 } 735 i fp->if_timer = 1;678 ic->ic_timer = 1; 736 679 } 737 680 if (sc->sc_ic.ic_opmode == IEEE80211_M_STA) … … 742 685 } 743 686 } 744 ieee80211_watchdog( ifp);687 ieee80211_watchdog(dev); 745 688 ATH_UNLOCK(sc); 746 689 } 747 690 748 691 static int 749 ath_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 750 { 751 struct ath_softc *sc = ifp->if_softc; 752 struct ifreq *ifr = (struct ifreq *)data; 692 ath_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 693 { 694 struct ath_softc *sc = dev->priv; 753 695 int error = 0; 754 696 755 697 ATH_LOCK(sc); 756 698 switch (cmd) { 757 case SIOCSIFFLAGS:758 if (ifp->if_flags & IFF_UP) {759 if (sc->sc_enabled) {760 /*761 * To avoid rescanning another access point,762 * do not call ath_init() here. Instead,763 * only reflect promisc mode settings.764 */765 ath_mode_init(sc);766 } else767 ath_init(ifp); /* XXX lose error */768 } else if (sc->sc_enabled)769 ath_stop(ifp, 1);770 break;771 699 case SIOCSIFMEDIA: 772 700 case SIOCGIFMEDIA: 773 error = ifmedia_ioctl(ifp, ifr, &sc->sc_media, cmd); 774 break; 775 case SIOCADDMULTI: 776 case SIOCDELMULTI: 777 /* 778 * The upper layer has already installed/removed 779 * the multicast address(es), just recalculate the 780 * multicast filter for the card. 781 */ 782 if (sc->sc_enabled) 783 ath_mode_init(sc); 784 break; 785 case SIOCGATHSTATS: 786 copyout(&sc->sc_stats, ifr->ifr_data, sizeof (sc->sc_stats)); 701 error = ifmedia_ioctl(dev, ifr, &sc->sc_media, cmd); 787 702 break; 788 703 default: 789 error = ieee80211_ioctl(ifp, cmd, data); 704 /* XXX ifr vs data */ 705 error = ieee80211_ioctl(dev, cmd, (caddr_t) ifr); 790 706 break; 791 707 } 792 708 if (error == ENETRESET) { 793 if (sc->sc_enabled) 794 ath_init(ifp); /* XXX lose error */ 709 ath_init(dev); /* XXX lose error */ 795 710 error = 0; 796 711 } … … 800 715 801 716 static int 802 ath_media_change(struct ifnet *ifp)803 { 804 struct ath_softc *sc = ifp->if_softc;717 ath_media_change(struct net_device *dev) 718 { 719 struct ath_softc *sc = dev->priv; 805 720 struct ieee80211com *ic = &sc->sc_ic; 806 721 struct ifmedia_entry *ime; … … 826 741 ic->ic_flags &= ~IEEE80211_F_IBSSON; 827 742 } 828 if (sc->sc_enabled) 829 ath_init(ifp); /* XXX lose error */ 743 ath_init(dev); /* XXX lose error */ 830 744 return error; 831 745 } 832 746 833 747 static void 834 ath_media_status(struct ifnet *ifp, struct ifmediareq *imr)835 { 836 struct ath_softc *sc = ifp->if_softc;748 ath_media_status(struct net_device *dev, struct ifmediareq *imr) 749 { 750 struct ath_softc *sc = dev->priv; 837 751 struct ieee80211_node *ni = NULL; 838 752 839 753 imr->ifm_status = IFM_AVALID; 840 754 imr->ifm_active = IFM_IEEE80211; 841 if (sc->sc_enabled) { 842 if (sc->sc_ic.ic_state == IEEE80211_S_RUN) 843 imr->ifm_status |= IFM_ACTIVE; 844 imr->ifm_active |= IFM_AUTO; 845 } 755 if (sc->sc_ic.ic_state == IEEE80211_S_RUN) 756 imr->ifm_status |= IFM_ACTIVE; 757 imr->ifm_active |= IFM_AUTO; 846 758 switch (sc->sc_ic.ic_opmode) { 847 759 case IEEE80211_M_STA: … … 908 820 909 821 static void 910 ath_mode_init(struct ath_softc *sc) 911 { 822 ath_mode_init(struct net_device *dev) 823 { 824 struct ath_softc *sc = dev->priv; 912 825 struct ieee80211com *ic = &sc->sc_ic; 913 826 struct ath_hal *ah = sc->sc_ah; 914 struct ifnet *ifp = &ic->ic_if;915 827 u_int32_t rfilt, mfilt[2], val; 916 828 u_int8_t pos; 917 struct ifmultiaddr *ifma;829 struct dev_mc_list *mc; 918 830 919 831 /* configure operational mode */ … … 922 834 /* receive filter */ 923 835 rfilt = HAL_RX_FILTER_UCAST | HAL_RX_FILTER_BCAST | HAL_RX_FILTER_MCAST; 924 if (ic->ic_opmode != IEEE80211_M_HOSTAP && 925 (ifp->if_flags & IFF_PROMISC)) 836 if (ic->ic_opmode != IEEE80211_M_HO
