if_axe.c revision 1.17.10.5 1 /* $NetBSD: if_axe.c,v 1.17.10.5 2007/06/22 10:42:10 itohy Exp $ */
2
3 /*
4 * Copyright (c) 1997, 1998, 1999, 2000-2003
5 * Bill Paul <wpaul (at) windriver.com>. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by Bill Paul.
18 * 4. Neither the name of the author nor the names of any co-contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
26 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
33 */
34
35 /*
36 * ASIX Electronics AX88172 USB 2.0 ethernet driver. Used in the
37 * LinkSys USB200M and various other adapters.
38 *
39 * Manuals available from:
40 * http://www.asix.com.tw/datasheet/mac/Ax88172.PDF
41 * (also http://people.freebsd.org/~wpaul/ASIX/Ax88172.PDF)
42 * Note: you need the manual for the AX88170 chip (USB 1.x ethernet
43 * controller) to find the definitions for the RX control register.
44 * http://www.asix.com.tw/datasheet/mac/Ax88170.PDF
45 *
46 * Written by Bill Paul <wpaul (at) windriver.com>
47 * Senior Engineer
48 * Wind River Systems
49 */
50
51 /*
52 * The AX88172 provides USB ethernet supports at 10 and 100Mbps.
53 * It uses an external PHY (reference designs use a RealTek chip),
54 * and has a 64-bit multicast hash filter. There is some information
55 * missing from the manual which one needs to know in order to make
56 * the chip function:
57 *
58 * - You must set bit 7 in the RX control register, otherwise the
59 * chip won't receive any packets.
60 * - You must initialize all 3 IPG registers, or you won't be able
61 * to send any packets.
62 *
63 * Note that this device appears to only support loading the station
64 * address via autload from the EEPROM (i.e. there's no way to manaully
65 * set it).
66 *
67 * (Adam Weinberger wanted me to name this driver if_gir.c.)
68 */
69
70 /*
71 * Ported to OpenBSD 3/28/2004 by Greg Taleck <taleck (at) oz.net>
72 * with bits and pieces from the aue and url drivers.
73 */
74
75 #include <sys/cdefs.h>
76 __KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.17.10.5 2007/06/22 10:42:10 itohy Exp $");
77
78 #if defined(__NetBSD__)
79 #include "opt_inet.h"
80 #include "rnd.h"
81 #endif
82
83 #include "bpfilter.h"
84
85 #include <sys/param.h>
86 #include <sys/systm.h>
87 #include <sys/sockio.h>
88 #include <sys/lock.h>
89 #include <sys/mbuf.h>
90 #include <sys/kernel.h>
91 #if defined(__OpenBSD__)
92 #include <sys/proc.h>
93 #endif
94 #include <sys/socket.h>
95
96 #include <sys/device.h>
97 #if NRND > 0
98 #include <sys/rnd.h>
99 #endif
100
101 #include <net/if.h>
102 #if defined(__NetBSD__)
103 #include <net/if_arp.h>
104 #endif
105 #include <net/if_dl.h>
106 #include <net/if_media.h>
107
108 #define BPF_MTAP(ifp, m) bpf_mtap((ifp)->if_bpf, (m))
109
110 #if NBPFILTER > 0
111 #include <net/bpf.h>
112 #endif
113
114 #if defined(__NetBSD__)
115 #include <net/if_ether.h>
116 #ifdef INET
117 #include <netinet/in.h>
118 #include <netinet/if_inarp.h>
119 #endif
120 #endif /* defined(__NetBSD__) */
121
122 #if defined(__OpenBSD__)
123 #ifdef INET
124 #include <netinet/in.h>
125 #include <netinet/in_systm.h>
126 #include <netinet/in_var.h>
127 #include <netinet/ip.h>
128 #include <netinet/if_ether.h>
129 #endif
130 #endif /* defined(__OpenBSD__) */
131
132
133 #include <dev/mii/mii.h>
134 #include <dev/mii/miivar.h>
135
136 #include <dev/usb/usb.h>
137 #include <dev/usb/usbdi.h>
138 #include <dev/usb/usbdi_util.h>
139 #include <dev/usb/usbdevs.h>
140 #include <dev/usb/usb_ethersubr.h>
141
142 #include <dev/usb/if_axereg.h>
143
144 #ifdef AXE_DEBUG
145 #define DPRINTF(x) do { if (axedebug) logprintf x; } while (0)
146 #define DPRINTFN(n,x) do { if (axedebug >= (n)) logprintf x; } while (0)
147 int axedebug = 0;
148 #else
149 #define DPRINTF(x)
150 #define DPRINTFN(n,x)
151 #endif
152
153 /*
154 * Various supported device vendors/products.
155 */
156 Static const struct axe_type axe_devs[] = {
157 { { USB_VENDOR_ASIX, USB_PRODUCT_ASIX_AX88172}, 0 },
158 { { USB_VENDOR_COREGA, USB_PRODUCT_COREGA_FETHER_USB2_TX }, 0},
159 { { USB_VENDOR_DLINK, USB_PRODUCT_DLINK_DUBE100}, 0 },
160 { { USB_VENDOR_LINKSYS2, USB_PRODUCT_LINKSYS2_USB200M}, 0 },
161 { { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_LUAU2KTX}, 0 },
162 { { USB_VENDOR_NETGEAR, USB_PRODUCT_NETGEAR_FA120}, 0 },
163 { { USB_VENDOR_SITECOM, USB_PRODUCT_SITECOM_LN029}, 0 },
164 { { USB_VENDOR_SYSTEMTALKS, USB_PRODUCT_SYSTEMTALKS_SGCX2UL}, 0 },
165 };
166 #define axe_lookup(v, p) ((const struct axe_type *)usb_lookup(axe_devs, v, p))
167
168 USB_DECLARE_DRIVER(axe);
169
170 Static int axe_encap(struct axe_softc *, struct mbuf *, int);
171 Static void axe_rxeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
172 Static void axe_txeof(usbd_xfer_handle, usbd_private_handle, usbd_status);
173 Static void axe_tick(void *);
174 Static void axe_tick_task(void *);
175 #if 0
176 Static void axe_rxstart(struct ifnet *);
177 #endif
178 Static void axe_start(struct ifnet *);
179 Static int axe_ioctl(struct ifnet *, u_long, usb_ioctlarg_t);
180 Static int axe_init(struct ifnet *);
181 Static void axe_stop(struct ifnet *, int);
182 Static void axe_watchdog(struct ifnet *);
183 Static int axe_miibus_readreg(device_ptr_t, int, int);
184 Static void axe_miibus_writereg(device_ptr_t, int, int, int);
185 Static void axe_miibus_statchg(device_ptr_t);
186 Static int axe_cmd(struct axe_softc *, int, int, int, void *);
187 Static int axe_ifmedia_upd(struct ifnet *);
188 Static void axe_ifmedia_sts(struct ifnet *, struct ifmediareq *);
189 Static void axe_reset(struct axe_softc *sc);
190
191 Static void axe_setmulti(struct axe_softc *);
192 Static void axe_lock_mii(struct axe_softc *sc);
193 Static void axe_unlock_mii(struct axe_softc *sc);
194
195 /* Get exclusive access to the MII registers */
196 Static void
197 axe_lock_mii(struct axe_softc *sc)
198 {
199 sc->axe_refcnt++;
200 usb_lockmgr(&sc->axe_mii_lock, LK_EXCLUSIVE, NULL);
201 }
202
203 Static void
204 axe_unlock_mii(struct axe_softc *sc)
205 {
206 usb_lockmgr(&sc->axe_mii_lock, LK_RELEASE, NULL);
207 if (--sc->axe_refcnt < 0)
208 usb_detach_wakeup(USBDEV(sc->axe_dev));
209 }
210
211 Static int
212 axe_cmd(struct axe_softc *sc, int cmd, int index, int val, void *buf)
213 {
214 usb_device_request_t req;
215 usbd_status err;
216
217 if (sc->axe_dying)
218 return(0);
219
220 axe_lock_mii(sc);
221 if (AXE_CMD_DIR(cmd))
222 req.bmRequestType = UT_WRITE_VENDOR_DEVICE;
223 else
224 req.bmRequestType = UT_READ_VENDOR_DEVICE;
225 req.bRequest = AXE_CMD_CMD(cmd);
226 USETW(req.wValue, val);
227 USETW(req.wIndex, index);
228 USETW(req.wLength, AXE_CMD_LEN(cmd));
229
230 err = usbd_do_request(sc->axe_udev, &req, buf);
231 axe_unlock_mii(sc);
232
233 if (err)
234 return(-1);
235
236 return(0);
237 }
238
239 Static int
240 axe_miibus_readreg(device_ptr_t dev, int phy, int reg)
241 {
242 struct axe_softc *sc = USBGETSOFTC(dev);
243 usbd_status err;
244 u_int16_t val;
245
246 if (sc->axe_dying) {
247 DPRINTF(("axe: dying\n"));
248 return(0);
249 }
250
251 #ifdef notdef
252 /*
253 * The chip tells us the MII address of any supported
254 * PHYs attached to the chip, so only read from those.
255 */
256
257 if (sc->axe_phyaddrs[0] != AXE_NOPHY && phy != sc->axe_phyaddrs[0])
258 return (0);
259
260 if (sc->axe_phyaddrs[1] != AXE_NOPHY && phy != sc->axe_phyaddrs[1])
261 return (0);
262 #endif
263 if (sc->axe_phyaddrs[0] != 0xFF && sc->axe_phyaddrs[0] != phy)
264 return (0);
265
266 val = 0;
267
268 axe_lock_mii(sc);
269 axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
270 err = axe_cmd(sc, AXE_CMD_MII_READ_REG, reg, phy, (void *)&val);
271 axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
272 axe_unlock_mii(sc);
273
274 if (err) {
275 printf("%s: read PHY failed\n", USBDEVNAME(sc->axe_dev));
276 return(-1);
277 }
278
279 if (val)
280 sc->axe_phyaddrs[0] = phy;
281
282 return (le16toh(val));
283 }
284
285 Static void
286 axe_miibus_writereg(device_ptr_t dev, int phy, int reg, int aval)
287 {
288 struct axe_softc *sc = USBGETSOFTC(dev);
289 usbd_status err;
290 u_int16_t val;
291
292 if (sc->axe_dying)
293 return;
294
295 val = htole16(aval);
296 axe_lock_mii(sc);
297 axe_cmd(sc, AXE_CMD_MII_OPMODE_SW, 0, 0, NULL);
298 err = axe_cmd(sc, AXE_CMD_MII_WRITE_REG, reg, phy, (void *)&val);
299 axe_cmd(sc, AXE_CMD_MII_OPMODE_HW, 0, 0, NULL);
300 axe_unlock_mii(sc);
301
302 if (err) {
303 printf("%s: write PHY failed\n", USBDEVNAME(sc->axe_dev));
304 return;
305 }
306 }
307
308 Static void
309 axe_miibus_statchg(device_ptr_t dev)
310 {
311 struct axe_softc *sc = USBGETSOFTC(dev);
312 struct mii_data *mii = GET_MII(sc);
313 int val, err;
314
315 if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX)
316 val = AXE_MEDIA_FULL_DUPLEX;
317 else
318 val = 0;
319 DPRINTF(("axe_miibus_statchg: val=0x%x\n", val));
320 err = axe_cmd(sc, AXE_CMD_WRITE_MEDIA, 0, val, NULL);
321 if (err) {
322 printf("%s: media change failed\n", USBDEVNAME(sc->axe_dev));
323 return;
324 }
325 }
326
327 /*
328 * Set media options.
329 */
330 Static int
331 axe_ifmedia_upd(struct ifnet *ifp)
332 {
333 struct axe_softc *sc = ifp->if_softc;
334 struct mii_data *mii = GET_MII(sc);
335
336 sc->axe_link = 0;
337 if (mii->mii_instance) {
338 struct mii_softc *miisc;
339 LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
340 mii_phy_reset(miisc);
341 }
342 mii_mediachg(mii);
343
344 return (0);
345 }
346
347 /*
348 * Report current media status.
349 */
350 Static void
351 axe_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr)
352 {
353 struct axe_softc *sc = ifp->if_softc;
354 struct mii_data *mii = GET_MII(sc);
355
356 mii_pollstat(mii);
357 ifmr->ifm_active = mii->mii_media_active;
358 ifmr->ifm_status = mii->mii_media_status;
359 }
360
361 Static void
362 axe_setmulti(struct axe_softc *sc)
363 {
364 struct ifnet *ifp;
365 struct ether_multi *enm;
366 struct ether_multistep step;
367 u_int32_t h = 0;
368 u_int16_t rxmode;
369 u_int8_t hashtbl[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
370
371 if (sc->axe_dying)
372 return;
373
374 ifp = GET_IFP(sc);
375
376 axe_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, (void *)&rxmode);
377 rxmode = le16toh(rxmode);
378
379 if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
380 allmulti:
381 rxmode |= AXE_RXCMD_ALLMULTI;
382 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
383 return;
384 } else
385 rxmode &= ~AXE_RXCMD_ALLMULTI;
386
387 /* now program new ones */
388 #if defined(__NetBSD__)
389 ETHER_FIRST_MULTI(step, &sc->axe_ec, enm);
390 #else
391 ETHER_FIRST_MULTI(step, &sc->arpcom, enm);
392 #endif
393 while (enm != NULL) {
394 if (memcmp(enm->enm_addrlo, enm->enm_addrhi,
395 ETHER_ADDR_LEN) != 0)
396 goto allmulti;
397
398 h = ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26;
399 hashtbl[h / 8] |= 1 << (h % 8);
400 ETHER_NEXT_MULTI(step, enm);
401 }
402
403 ifp->if_flags &= ~IFF_ALLMULTI;
404 axe_cmd(sc, AXE_CMD_WRITE_MCAST, 0, 0, (void *)&hashtbl);
405 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
406 return;
407 }
408
409 Static void
410 axe_reset(struct axe_softc *sc)
411 {
412 if (sc->axe_dying)
413 return;
414 /* XXX What to reset? */
415
416 /* Wait a little while for the chip to get its brains in order. */
417 DELAY(1000);
418 return;
419 }
420
421 /*
422 * Probe for a AX88172 chip.
423 */
424 USB_MATCH(axe)
425 {
426 USB_MATCH_START(axe, uaa);
427
428 #ifndef USB_USE_IFATTACH
429 if (!uaa->iface) {
430 return(UMATCH_NONE);
431 }
432 #endif /* USB_USE_IFATTACH */
433
434 return (axe_lookup(uaa->vendor, uaa->product) != NULL ?
435 UMATCH_VENDOR_PRODUCT : UMATCH_NONE);
436 }
437
438 /*
439 * Attach the interface. Allocate softc structures, do ifmedia
440 * setup and ethernet/BPF attach.
441 */
442 USB_ATTACH(axe)
443 {
444 USB_ATTACH_START(axe, sc, uaa);
445 usbd_device_handle dev = uaa->device;
446 usbd_status err;
447 usb_interface_descriptor_t *id;
448 usb_endpoint_descriptor_t *ed;
449 struct mii_data *mii;
450 u_char eaddr[ETHER_ADDR_LEN];
451 char *devinfop;
452 char *devname = USBDEVNAME(sc->axe_dev);
453 struct ifnet *ifp;
454 int i, s;
455
456 devinfop = usbd_devinfo_alloc(dev, 0);
457 USB_ATTACH_SETUP;
458
459 err = usbd_set_config_no(dev, AXE_CONFIG_NO, 1);
460 if (err) {
461 printf("%s: getting interface handle failed\n",
462 USBDEVNAME(sc->axe_dev));
463 usbd_devinfo_free(devinfop);
464 USB_ATTACH_ERROR_RETURN;
465 }
466
467 usb_init_task(&sc->axe_tick_task, axe_tick_task, sc);
468 lockinit(&sc->axe_mii_lock, PZERO, "axemii", 0, LK_CANRECURSE);
469 usb_init_task(&sc->axe_stop_task, (void (*)(void *))axe_stop, sc);
470
471 err = usbd_device2interface_handle(dev, AXE_IFACE_IDX, &sc->axe_iface);
472 if (err) {
473 printf("%s: getting interface handle failed\n",
474 USBDEVNAME(sc->axe_dev));
475 usbd_devinfo_free(devinfop);
476 USB_ATTACH_ERROR_RETURN;
477 }
478
479 sc->axe_udev = dev;
480 sc->axe_product = uaa->product;
481 sc->axe_vendor = uaa->vendor;
482
483 id = usbd_get_interface_descriptor(sc->axe_iface);
484
485 printf("%s: %s\n", USBDEVNAME(sc->axe_dev), devinfop);
486 usbd_devinfo_free(devinfop);
487
488 /* Find endpoints. */
489 for (i = 0; i < id->bNumEndpoints; i++) {
490 ed = usbd_interface2endpoint_descriptor(sc->axe_iface, i);
491 if (!ed) {
492 printf("%s: couldn't get ep %d\n",
493 USBDEVNAME(sc->axe_dev), i);
494 USB_ATTACH_ERROR_RETURN;
495 }
496 if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
497 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
498 sc->axe_ed[AXE_ENDPT_RX] = ed->bEndpointAddress;
499 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_OUT &&
500 UE_GET_XFERTYPE(ed->bmAttributes) == UE_BULK) {
501 sc->axe_ed[AXE_ENDPT_TX] = ed->bEndpointAddress;
502 } else if (UE_GET_DIR(ed->bEndpointAddress) == UE_DIR_IN &&
503 UE_GET_XFERTYPE(ed->bmAttributes) == UE_INTERRUPT) {
504 sc->axe_ed[AXE_ENDPT_INTR] = ed->bEndpointAddress;
505 }
506 }
507
508 s = splnet();
509
510 /*
511 * Get station address.
512 */
513 axe_cmd(sc, AXE_CMD_READ_NODEID, 0, 0, &eaddr);
514
515 /*
516 * Load IPG values and PHY indexes.
517 */
518 axe_cmd(sc, AXE_CMD_READ_IPG012, 0, 0, (void *)&sc->axe_ipgs);
519 axe_cmd(sc, AXE_CMD_READ_PHYID, 0, 0, (void *)&sc->axe_phyaddrs);
520
521 /*
522 * Work around broken adapters that appear to lie about
523 * their PHY addresses.
524 */
525 sc->axe_phyaddrs[0] = sc->axe_phyaddrs[1] = 0xFF;
526
527 /*
528 * An ASIX chip was detected. Inform the world.
529 */
530 printf("%s: Ethernet address %s\n", USBDEVNAME(sc->axe_dev),
531 ether_sprintf(eaddr));
532
533 /* Initialize interface info.*/
534 ifp = GET_IFP(sc);
535 ifp->if_softc = sc;
536 strncpy(ifp->if_xname, devname, IFNAMSIZ);
537 ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
538 ifp->if_ioctl = axe_ioctl;
539 ifp->if_start = axe_start;
540
541 ifp->if_init = axe_init;
542 ifp->if_stop = axe_stop;
543 ifp->if_watchdog = axe_watchdog;
544
545 /* ifp->if_baudrate = 10000000; */
546 /* ifp->if_snd.ifq_maxlen = IFQ_MAXLEN;*/
547
548 IFQ_SET_READY(&ifp->if_snd);
549
550 /* Initialize MII/media info. */
551 mii = &sc->axe_mii;
552 mii->mii_ifp = ifp;
553 mii->mii_readreg = axe_miibus_readreg;
554 mii->mii_writereg = axe_miibus_writereg;
555 mii->mii_statchg = axe_miibus_statchg;
556 mii->mii_flags = MIIF_AUTOTSLEEP;
557
558 ifmedia_init(&mii->mii_media, 0, axe_ifmedia_upd, axe_ifmedia_sts);
559 mii_attach(self, mii, 0xffffffff, MII_PHY_ANY, MII_OFFSET_ANY, 0);
560
561 if (LIST_FIRST(&mii->mii_phys) == NULL) {
562 ifmedia_add(&mii->mii_media, IFM_ETHER | IFM_NONE, 0, NULL);
563 ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_NONE);
564 } else
565 ifmedia_set(&mii->mii_media, IFM_ETHER | IFM_AUTO);
566
567 /* Attach the interface. */
568 if_attach(ifp);
569 Ether_ifattach(ifp, eaddr);
570 #if NRND > 0
571 rnd_attach_source(&sc->rnd_source, USBDEVNAME(sc->axe_dev),
572 RND_TYPE_NET, 0);
573 #endif
574
575 usb_callout_init(sc->axe_stat_ch);
576
577 sc->axe_attached = 1;
578 splx(s);
579
580 usbd_add_drv_event(USB_EVENT_DRIVER_ATTACH, sc->axe_udev,
581 USBDEV(sc->axe_dev));
582
583 USB_ATTACH_SUCCESS_RETURN;
584 }
585
586 USB_DETACH(axe)
587 {
588 USB_DETACH_START(axe, sc);
589 int s;
590 struct ifnet *ifp = GET_IFP(sc);
591
592 DPRINTFN(2,("%s: %s: enter\n", USBDEVNAME(sc->axe_dev), __func__));
593
594 /* Detached before attached finished, so just bail out. */
595 if (!sc->axe_attached)
596 return (0);
597
598 usb_uncallout(sc->axe_stat_ch, axe_tick, sc);
599
600 sc->axe_dying = 1;
601
602 ether_ifdetach(ifp);
603
604 if (sc->axe_ep[AXE_ENDPT_TX] != NULL)
605 usbd_abort_pipe(sc->axe_ep[AXE_ENDPT_TX]);
606 if (sc->axe_ep[AXE_ENDPT_RX] != NULL)
607 usbd_abort_pipe(sc->axe_ep[AXE_ENDPT_RX]);
608 if (sc->axe_ep[AXE_ENDPT_INTR] != NULL)
609 usbd_abort_pipe(sc->axe_ep[AXE_ENDPT_INTR]);
610
611 /*
612 * Remove any pending tasks. They cannot be executing because they run
613 * in the same thread as detach.
614 */
615 usb_rem_task(sc->axe_udev, &sc->axe_tick_task);
616 usb_rem_task(sc->axe_udev, &sc->axe_stop_task);
617
618 s = splusb();
619
620 if (--sc->axe_refcnt >= 0) {
621 /* Wait for processes to go away */
622 usb_detach_wait(USBDEV(sc->axe_dev));
623 }
624
625 if (ifp->if_flags & IFF_RUNNING)
626 axe_stop(ifp, 1);
627
628 #if defined(__NetBSD__)
629 #if NRND > 0
630 rnd_detach_source(&sc->rnd_source);
631 #endif
632 #endif /* __NetBSD__ */
633 mii_detach(&sc->axe_mii, MII_PHY_ANY, MII_OFFSET_ANY);
634 ifmedia_delete_instance(&sc->axe_mii.mii_media, IFM_INST_ANY);
635 ether_ifdetach(ifp);
636 if_detach(ifp);
637
638 #ifdef DIAGNOSTIC
639 if (sc->axe_ep[AXE_ENDPT_TX] != NULL ||
640 sc->axe_ep[AXE_ENDPT_RX] != NULL ||
641 sc->axe_ep[AXE_ENDPT_INTR] != NULL)
642 printf("%s: detach has active endpoints\n",
643 USBDEVNAME(sc->axe_dev));
644 #endif
645
646 sc->axe_attached = 0;
647
648 if (--sc->axe_refcnt >= 0) {
649 /* Wait for processes to go away. */
650 usb_detach_wait(USBDEV(sc->axe_dev));
651 }
652 splx(s);
653
654 usbd_add_drv_event(USB_EVENT_DRIVER_DETACH, sc->axe_udev,
655 USBDEV(sc->axe_dev));
656
657 return (0);
658 }
659
660 int
661 axe_activate(device_ptr_t self, enum devact act)
662 {
663 struct axe_softc *sc = (struct axe_softc *)self;
664
665 DPRINTFN(2,("%s: %s: enter\n", USBDEVNAME(sc->axe_dev), __func__));
666
667 switch (act) {
668 case DVACT_ACTIVATE:
669 return (EOPNOTSUPP);
670 break;
671
672 case DVACT_DEACTIVATE:
673 if_deactivate(&sc->axe_ec.ec_if);
674 sc->axe_dying = 1;
675 break;
676 }
677 return (0);
678 }
679
680 /*
681 * A frame has been uploaded: pass the resulting mbuf chain up to
682 * the higher level protocols.
683 */
684 Static void
685 axe_rxeof(usbd_xfer_handle xfer, usbd_private_handle priv, usbd_status status)
686 {
687 struct axe_softc *sc;
688 struct ue_chain *c;
689 struct ifnet *ifp;
690 struct mbuf *m;
691 u_int32_t total_len;
692 int s;
693
694 c = priv;
695 sc = (void *)c->ue_dev;
696 ifp = GET_IFP(sc);
697
698 DPRINTFN(10,("%s: %s: enter\n", USBDEVNAME(sc->axe_dev),__func__));
699
700 if (sc->axe_dying)
701 return;
702
703 usbd_unmap_buffer(xfer);
704
705 if (!(ifp->if_flags & IFF_RUNNING))
706 return;
707
708 if (status != USBD_NORMAL_COMPLETION) {
709 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED)
710 return;
711 if (usbd_ratecheck(&sc->axe_rx_notice)) {
712 printf("%s: usb errors on rx: %s\n",
713 USBDEVNAME(sc->axe_dev), usbd_errstr(status));
714 }
715 if (status == USBD_STALLED)
716 usbd_clear_endpoint_stall_async(sc->axe_ep[AXE_ENDPT_RX]);
717 goto done;
718 }
719
720 usbd_get_xfer_status(xfer, NULL, NULL, &total_len, NULL);
721
722 m = c->ue_mbuf;
723
724 if (total_len <= sizeof(struct ether_header)) {
725 ifp->if_ierrors++;
726 goto done;
727 }
728
729 /*
730 * Allocate new mbuf cluster for the next transfer.
731 * If that failed, discard current packet and recycle the mbuf.
732 */
733 if ((c->ue_mbuf = usb_ether_newbuf(NULL)) == NULL) {
734 printf("%s: no memory for rx list -- packet dropped!\n",
735 USBDEVNAME(sc->axe_dev));
736 ifp->if_ierrors++;
737 c->ue_mbuf = usb_ether_newbuf(m);
738 goto done;
739 }
740
741 ifp->if_ipackets++;
742 m->m_pkthdr.rcvif = ifp;
743 m->m_pkthdr.len = m->m_len = total_len;
744
745 /* No errors; receive the packet. */
746 total_len -= ETHER_CRC_LEN + 4;
747 /* XXX XXX What is it? Should it be moved several lines above? */
748
749 s = splnet();
750
751 #if NBPFILTER > 0
752 if (ifp->if_bpf)
753 BPF_MTAP(ifp, m);
754 #endif
755
756 DPRINTFN(10,("%s: %s: deliver %d\n", USBDEVNAME(sc->axe_dev),
757 __func__, m->m_len));
758 IF_INPUT(ifp, m);
759 splx(s);
760
761 done:
762
763 /* Setup new transfer. */
764 (void)usbd_map_buffer_mbuf(c->ue_xfer, c->ue_mbuf);
765 usbd_setup_xfer(xfer, sc->axe_ep[AXE_ENDPT_RX],
766 c, NULL /* XXX buf */, AXE_BUFSZ,
767 USBD_SHORT_XFER_OK | USBD_NO_COPY
768 #ifdef __FreeBSD__ /* callback needs context */
769 | USBD_CALLBACK_AS_TASK
770 #endif
771 ,
772 USBD_NO_TIMEOUT, axe_rxeof);
773 usbd_transfer(xfer);
774
775 DPRINTFN(10,("%s: %s: start rx\n", USBDEVNAME(sc->axe_dev),
776 __func__));
777 return;
778 }
779
780 /*
781 * A frame was downloaded to the chip. It's safe for us to clean up
782 * the list buffers.
783 */
784
785 Static void
786 axe_txeof(usbd_xfer_handle xfer, usbd_private_handle priv,
787 usbd_status status)
788 {
789 struct axe_softc *sc;
790 struct ue_chain *c;
791 struct ifnet *ifp;
792 int s;
793
794 c = priv;
795 sc = (void *)c->ue_dev;
796 ifp = GET_IFP(sc);
797
798 if (sc->axe_dying)
799 return;
800
801 usbd_unmap_buffer(xfer);
802
803 s = splnet();
804
805 if (status != USBD_NORMAL_COMPLETION) {
806 if (status == USBD_NOT_STARTED || status == USBD_CANCELLED) {
807 splx(s);
808 return;
809 }
810 ifp->if_oerrors++;
811 printf("%s: usb error on tx: %s\n", USBDEVNAME(sc->axe_dev),
812 usbd_errstr(status));
813 if (status == USBD_STALLED)
814 usbd_clear_endpoint_stall_async(sc->axe_ep[AXE_ENDPT_TX]);
815 splx(s);
816 return;
817 }
818
819 ifp->if_timer = 0;
820 ifp->if_flags &= ~IFF_OACTIVE;
821
822 m_freem(c->ue_mbuf);
823 c->ue_mbuf = NULL;
824
825 if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
826 axe_start(ifp);
827
828 ifp->if_opackets++;
829 splx(s);
830 return;
831 }
832
833 Static void
834 axe_tick(void *xsc)
835 {
836 struct axe_softc *sc = xsc;
837
838 if (sc == NULL)
839 return;
840
841 DPRINTFN(0xff, ("%s: %s: enter\n", USBDEVNAME(sc->axe_dev),
842 __func__));
843
844 if (sc->axe_dying)
845 return;
846
847 /* Perform periodic stuff in process context */
848 usb_add_task(sc->axe_udev, &sc->axe_tick_task, USB_TASKQ_DRIVER);
849
850 }
851
852 Static void
853 axe_tick_task(void *xsc)
854 {
855 int s;
856 struct axe_softc *sc;
857 struct ifnet *ifp;
858 struct mii_data *mii;
859
860 sc = xsc;
861
862 if (sc == NULL)
863 return;
864
865 if (sc->axe_dying)
866 return;
867
868 ifp = GET_IFP(sc);
869 mii = GET_MII(sc);
870 if (mii == NULL)
871 return;
872
873 s = splnet();
874
875 mii_tick(mii);
876 if (!sc->axe_link) {
877 mii_pollstat(mii);
878 if (mii->mii_media_status & IFM_ACTIVE &&
879 IFM_SUBTYPE(mii->mii_media_active) != IFM_NONE) {
880 DPRINTF(("%s: %s: got link\n",
881 USBDEVNAME(sc->axe_dev), __func__));
882 sc->axe_link++;
883 if (IFQ_IS_EMPTY(&ifp->if_snd) == 0)
884 axe_start(ifp);
885 }
886 }
887
888 usb_callout(sc->axe_stat_ch, hz, axe_tick, sc);
889
890 splx(s);
891 }
892
893 Static int
894 axe_encap(struct axe_softc *sc, struct mbuf *m, int idx)
895 {
896 struct ue_chain *c;
897 usbd_status err;
898 int ret;
899
900 c = &sc->axe_cdata.axe_tx_chain[idx];
901
902 ret = usb_ether_map_tx_buffer_mbuf(c, m);
903 if (ret)
904 return (ret);
905
906 usbd_setup_xfer(c->ue_xfer, sc->axe_ep[AXE_ENDPT_TX],
907 c, NULL /* XXX buf */, m->m_pkthdr.len,
908 USBD_FORCE_SHORT_XFER | USBD_NO_COPY
909 #ifdef __FreeBSD__ /* callback needs context */
910 | USBD_CALLBACK_AS_TASK
911 #endif
912 , 10000,
913 axe_txeof);
914
915 /* Transmit */
916 err = usbd_transfer(c->ue_xfer);
917 if (err != USBD_IN_PROGRESS) {
918 axe_stop(GET_IFP(sc), 0);
919 return(EIO);
920 }
921
922 sc->axe_cdata.axe_tx_cnt++;
923
924 return(0);
925 }
926
927 Static void
928 axe_start(struct ifnet *ifp)
929 {
930 struct axe_softc *sc;
931 struct mbuf *m_head = NULL;
932
933 sc = ifp->if_softc;
934
935 if (!sc->axe_link) {
936 return;
937 }
938
939 if (ifp->if_flags & IFF_OACTIVE) {
940 return;
941 }
942
943 IFQ_POLL(&ifp->if_snd, m_head);
944 if (m_head == NULL) {
945 return;
946 }
947
948 if (axe_encap(sc, m_head, 0)) {
949 ifp->if_flags |= IFF_OACTIVE;
950 return;
951 }
952
953 IFQ_DEQUEUE(&ifp->if_snd, m_head);
954
955 /*
956 * If there's a BPF listener, bounce a copy of this frame
957 * to him.
958 */
959 #if NBPFILTER > 0
960 if (ifp->if_bpf)
961 BPF_MTAP(ifp, m_head);
962 #endif
963
964 ifp->if_flags |= IFF_OACTIVE;
965
966 /*
967 * Set a timeout in case the chip goes out to lunch.
968 */
969 ifp->if_timer = 5;
970
971 return;
972 }
973
974 Static int
975 axe_init(struct ifnet *ifp)
976 {
977 struct axe_softc *sc = ifp->if_softc;
978 struct ue_chain *c;
979 usbd_status err;
980 int rxmode;
981 int i, s;
982
983 if (ifp->if_flags & IFF_RUNNING)
984 return (EIO);
985
986 s = splnet();
987
988 /*
989 * Cancel pending I/O and free all RX/TX buffers.
990 */
991 axe_reset(sc);
992
993 /* Set transmitter IPG values */
994 axe_cmd(sc, AXE_CMD_WRITE_IPG0, 0, sc->axe_ipgs[0], NULL);
995 axe_cmd(sc, AXE_CMD_WRITE_IPG1, 0, sc->axe_ipgs[1], NULL);
996 axe_cmd(sc, AXE_CMD_WRITE_IPG2, 0, sc->axe_ipgs[2], NULL);
997
998 /* Enable receiver, set RX mode */
999 rxmode = AXE_RXCMD_UNICAST|AXE_RXCMD_MULTICAST|AXE_RXCMD_ENABLE;
1000
1001 /* If we want promiscuous mode, set the allframes bit. */
1002 if (ifp->if_flags & IFF_PROMISC)
1003 rxmode |= AXE_RXCMD_PROMISC;
1004
1005 if (ifp->if_flags & IFF_BROADCAST)
1006 rxmode |= AXE_RXCMD_BROADCAST;
1007
1008 axe_cmd(sc, AXE_CMD_RXCTL_WRITE, 0, rxmode, NULL);
1009
1010 /* Load the multicast filter. */
1011 axe_setmulti(sc);
1012
1013 /* Open RX and TX pipes. */
1014 err = usbd_open_pipe(sc->axe_iface, sc->axe_ed[AXE_ENDPT_RX],
1015 USBD_EXCLUSIVE_USE, &sc->axe_ep[AXE_ENDPT_RX]);
1016 if (err) {
1017 printf("%s: open rx pipe failed: %s\n",
1018 USBDEVNAME(sc->axe_dev), usbd_errstr(err));
1019 splx(s);
1020 return (EIO);
1021 }
1022
1023 err = usbd_open_pipe(sc->axe_iface, sc->axe_ed[AXE_ENDPT_TX],
1024 USBD_EXCLUSIVE_USE, &sc->axe_ep[AXE_ENDPT_TX]);
1025 if (err) {
1026 printf("%s: open tx pipe failed: %s\n",
1027 USBDEVNAME(sc->axe_dev), usbd_errstr(err));
1028 splx(s);
1029 return (EIO);
1030 }
1031
1032 /* Init RX ring. */
1033 if ((i = usb_ether_rx_list_init(USBDEV(sc->axe_dev),
1034 sc->axe_cdata.axe_rx_chain, AXE_RX_LIST_CNT,
1035 sc->axe_udev, sc->axe_ep[AXE_ENDPT_RX]))) {
1036 printf("%s: rx list init failed\n", USBDEVNAME(sc->axe_dev));
1037 splx(s);
1038 return (i);
1039 }
1040
1041 /* Init TX ring. */
1042 if ((i = usb_ether_tx_list_init(USBDEV(sc->axe_dev),
1043 sc->axe_cdata.axe_tx_chain, AXE_TX_LIST_CNT,
1044 sc->axe_udev, sc->axe_ep[AXE_ENDPT_TX], NULL))) {
1045 printf("%s: tx list init failed\n", USBDEVNAME(sc->axe_dev));
1046 splx(s);
1047 return (i);
1048 }
1049
1050 /* Start up the receive pipe. */
1051 for (i = 0; i < AXE_RX_LIST_CNT; i++) {
1052 c = &sc->axe_cdata.axe_rx_chain[i];
1053 (void)usbd_map_buffer_mbuf(c->ue_xfer, c->ue_mbuf);
1054 usbd_setup_xfer(c->ue_xfer, sc->axe_ep[AXE_ENDPT_RX],
1055 c, NULL /* buf */, AXE_BUFSZ,
1056 USBD_SHORT_XFER_OK | USBD_NO_COPY
1057 #ifdef __FreeBSD__ /* callback needs context */
1058 | USBD_CALLBACK_AS_TASK
1059 #endif
1060 , USBD_NO_TIMEOUT, axe_rxeof);
1061 usbd_transfer(c->ue_xfer);
1062 }
1063
1064 ifp->if_flags |= IFF_RUNNING;
1065 ifp->if_flags &= ~IFF_OACTIVE;
1066
1067 splx(s);
1068
1069 usb_callout_init(sc->axe_stat_ch);
1070 usb_callout(sc->axe_stat_ch, hz, axe_tick, sc);
1071 return (0);
1072 }
1073
1074 Static int
1075 axe_ioctl(struct ifnet *ifp, u_long cmd, usb_ioctlarg_t data)
1076 {
1077 struct axe_softc *sc = ifp->if_softc;
1078 struct ifreq *ifr = (struct ifreq *)data;
1079 #if 0
1080 struct ifaddr *ifa = (struct ifaddr *)data;
1081 #endif
1082 struct mii_data *mii;
1083 u_int16_t rxmode;
1084 int error = 0;
1085
1086 switch(cmd) {
1087 #if 0
1088 case SIOCSIFADDR:
1089 ifp->if_flags |= IFF_UP;
1090 axe_init(ifp);
1091
1092 switch (ifa->ifa_addr->sa_family) {
1093 #ifdef INET
1094 case AF_INET:
1095 #if defined(__NetBSD__)
1096 arp_ifinit(ifp, ifa);
1097 #else
1098 arp_ifinit(&sc->arpcom, ifa);
1099 #endif
1100 break;
1101 #endif /* INET */
1102 }
1103 break;
1104
1105 case SIOCSIFMTU:
1106 if (ifr->ifr_mtu > ETHERMTU)
1107 error = EINVAL;
1108 else
1109 ifp->if_mtu = ifr->ifr_mtu;
1110 break;
1111 #endif
1112
1113 case SIOCSIFFLAGS:
1114 if (ifp->if_flags & IFF_UP) {
1115 if (ifp->if_flags & IFF_RUNNING &&
1116 ifp->if_flags & IFF_PROMISC &&
1117 !(sc->axe_if_flags & IFF_PROMISC)) {
1118
1119 axe_cmd(sc, AXE_CMD_RXCTL_READ,
1120 0, 0, (void *)&rxmode);
1121 rxmode = le16toh(rxmode) | AXE_RXCMD_PROMISC;
1122 axe_cmd(sc, AXE_CMD_RXCTL_WRITE,
1123 0, rxmode, NULL);
1124
1125 axe_setmulti(sc);
1126 } else if (ifp->if_flags & IFF_RUNNING &&
1127 !(ifp->if_flags & IFF_PROMISC) &&
1128 sc->axe_if_flags & IFF_PROMISC) {
1129 axe_cmd(sc, AXE_CMD_RXCTL_READ,
1130 0, 0, (void *)&rxmode);
1131 rxmode = le16toh(rxmode) & ~AXE_RXCMD_PROMISC;
1132 axe_cmd(sc, AXE_CMD_RXCTL_WRITE,
1133 0, rxmode, NULL);
1134 axe_setmulti(sc);
1135 } else if (!(ifp->if_flags & IFF_RUNNING))
1136 axe_init(ifp);
1137 } else {
1138 if (ifp->if_flags & IFF_RUNNING)
1139 axe_stop(ifp, 1);
1140 }
1141 sc->axe_if_flags = ifp->if_flags;
1142 error = 0;
1143 break;
1144 #if 0
1145 case SIOCADDMULTI:
1146 case SIOCDELMULTI:
1147 #ifdef __NetBSD__
1148 error = (cmd == SIOCADDMULTI) ?
1149 ether_addmulti(ifr, &sc->axe_ec) :
1150 ether_delmulti(ifr, &sc->axe_ec);
1151 #else
1152 error = (cmd == SIOCADDMULTI) ?
1153 ether_addmulti(ifr, &sc->arpcom) :
1154 ether_delmulti(ifr, &sc->arpcom);
1155 #endif /* __NetBSD__ */
1156 if (error == ENETRESET) {
1157 /*
1158 * Multicast list has changed; set the hardware
1159 * filter accordingly.
1160 */
1161 if (ifp->if_flags & IFF_RUNNING)
1162 axe_setmulti(sc);
1163 error = 0;
1164 }
1165 break;
1166 #endif
1167 case SIOCGIFMEDIA:
1168 case SIOCSIFMEDIA:
1169 mii = GET_MII(sc);
1170 error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd);
1171 break;
1172
1173 default:
1174 error = ether_ioctl(ifp, cmd, data);
1175 if (error == ENETRESET) {
1176 /*
1177 * Multicast list has changed; set the hardware
1178 * filter accordingly.
1179 */
1180 if (ifp->if_flags & IFF_RUNNING)
1181 axe_setmulti(sc);
1182 error = 0;
1183 }
1184 break;
1185 }
1186
1187 return(error);
1188 }
1189
1190 /*
1191 * XXX
1192 * You can't call axe_txeof since the USB transfer has not
1193 * completed yet.
1194 */
1195 Static void
1196 axe_watchdog(struct ifnet *ifp)
1197 {
1198 struct axe_softc *sc;
1199 struct ue_chain *c;
1200 usbd_status stat;
1201 int s;
1202
1203 sc = ifp->if_softc;
1204
1205 ifp->if_oerrors++;
1206 printf("%s: watchdog timeout\n", USBDEVNAME(sc->axe_dev));
1207
1208 s = splusb();
1209 c = &sc->axe_cdata.axe_tx_chain[0];
1210 usbd_get_xfer_status(c->ue_xfer, NULL, NULL, NULL, &stat);
1211 axe_txeof(c->ue_xfer, c, stat);
1212
1213 if (ifp->if_snd.ifq_head != NULL)
1214 axe_start(ifp);
1215 splx(s);
1216 }
1217
1218 /*
1219 * Stop the adapter and free any mbufs allocated to the
1220 * RX and TX lists.
1221 */
1222 Static void
1223 axe_stop(struct ifnet *ifp, int disable)
1224 {
1225 struct axe_softc *sc = ifp->if_softc;
1226 usbd_status err;
1227
1228 axe_reset(sc);
1229
1230 ifp = GET_IFP(sc);
1231 ifp->if_timer = 0;
1232
1233 usb_uncallout(sc->axe_stat_ch, axe_tick, sc);
1234
1235 /* Stop transfers. */
1236 if (sc->axe_ep[AXE_ENDPT_RX] != NULL) {
1237 err = usbd_abort_pipe(sc->axe_ep[AXE_ENDPT_RX]);
1238 if (err) {
1239 printf("%s: abort rx pipe failed: %s\n",
1240 USBDEVNAME(sc->axe_dev), usbd_errstr(err));
1241 }
1242 }
1243
1244 if (sc->axe_ep[AXE_ENDPT_TX] != NULL) {
1245 err = usbd_abort_pipe(sc->axe_ep[AXE_ENDPT_TX]);
1246 if (err) {
1247 printf("%s: abort tx pipe failed: %s\n",
1248 USBDEVNAME(sc->axe_dev), usbd_errstr(err));
1249 }
1250 }
1251
1252 if (sc->axe_ep[AXE_ENDPT_INTR] != NULL) {
1253 err = usbd_abort_pipe(sc->axe_ep[AXE_ENDPT_INTR]);
1254 if (err) {
1255 printf("%s: abort intr pipe failed: %s\n",
1256 USBDEVNAME(sc->axe_dev), usbd_errstr(err));
1257 }
1258 }
1259
1260 /* Free RX/TX resources. */
1261 usb_ether_rx_list_free(sc->axe_cdata.axe_rx_chain, AXE_RX_LIST_CNT);
1262 usb_ether_tx_list_free(sc->axe_cdata.axe_tx_chain, AXE_TX_LIST_CNT);
1263
1264 /* Close pipes. */
1265 if (sc->axe_ep[AXE_ENDPT_RX] != NULL) {
1266 err = usbd_close_pipe(sc->axe_ep[AXE_ENDPT_RX]);
1267 if (err) {
1268 printf("%s: close rx pipe failed: %s\n",
1269 USBDEVNAME(sc->axe_dev), usbd_errstr(err));
1270 }
1271 sc->axe_ep[AXE_ENDPT_RX] = NULL;
1272 }
1273
1274 if (sc->axe_ep[AXE_ENDPT_TX] != NULL) {
1275 err = usbd_close_pipe(sc->axe_ep[AXE_ENDPT_TX]);
1276 if (err) {
1277 printf("%s: close tx pipe failed: %s\n",
1278 USBDEVNAME(sc->axe_dev), usbd_errstr(err));
1279 }
1280 sc->axe_ep[AXE_ENDPT_TX] = NULL;
1281 }
1282
1283 if (sc->axe_ep[AXE_ENDPT_INTR] != NULL) {
1284 err = usbd_close_pipe(sc->axe_ep[AXE_ENDPT_INTR]);
1285 if (err) {
1286 printf("%s: close intr pipe failed: %s\n",
1287 USBDEVNAME(sc->axe_dev), usbd_errstr(err));
1288 }
1289 sc->axe_ep[AXE_ENDPT_INTR] = NULL;
1290 }
1291
1292 sc->axe_link = 0;
1293 ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
1294 }
1295
1296