Deleted Added
full compact
if_xe.c (148838) if_xe.c (148887)
1/*-
2 * Copyright (c) 1998, 1999, 2003 Scott Mitchell
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 43 unchanged lines hidden (view full) ---

52 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
54 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
56 * OF THE POSSIBILITY OF SUCH DAMAGE.
57 */
58
59#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1998, 1999, 2003 Scott Mitchell
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 43 unchanged lines hidden (view full) ---

52 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
53 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
54 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
55 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
56 * OF THE POSSIBILITY OF SUCH DAMAGE.
57 */
58
59#include <sys/cdefs.h>
60__FBSDID("$FreeBSD: head/sys/dev/xe/if_xe.c 148838 2005-08-07 23:16:22Z imp $");
60__FBSDID("$FreeBSD: head/sys/dev/xe/if_xe.c 148887 2005-08-09 10:20:02Z rwatson $");
61
62/*
63 * FreeBSD device driver for Xircom CreditCard PCMCIA Ethernet adapters. The
64 * following cards are currently known to work with the driver:
65 * Xircom CreditCard 10/100 (CE3)
66 * Xircom CreditCard Ethernet + Modem 28 (CEM28)
67 * Xircom CreditCard Ethernet 10/100 + Modem 56 (CEM56)
68 * Xircom RealPort Ethernet 10

--- 337 unchanged lines hidden (view full) ---

406
407 /* Set up IMR, enable interrupts */
408 xe_enable_intr(scp);
409
410 /* Start media selection */
411 xe_setmedia(scp);
412
413 /* Enable output */
61
62/*
63 * FreeBSD device driver for Xircom CreditCard PCMCIA Ethernet adapters. The
64 * following cards are currently known to work with the driver:
65 * Xircom CreditCard 10/100 (CE3)
66 * Xircom CreditCard Ethernet + Modem 28 (CEM28)
67 * Xircom CreditCard Ethernet 10/100 + Modem 56 (CEM56)
68 * Xircom RealPort Ethernet 10

--- 337 unchanged lines hidden (view full) ---

406
407 /* Set up IMR, enable interrupts */
408 xe_enable_intr(scp);
409
410 /* Start media selection */
411 xe_setmedia(scp);
412
413 /* Enable output */
414 scp->ifp->if_flags |= IFF_RUNNING;
415 scp->ifp->if_flags &= ~IFF_OACTIVE;
414 scp->ifp->if_drv_flags |= IFF_DRV_RUNNING;
415 scp->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
416
417 (void)splx(s);
418}
419
420
421/*
422 * Start output on interface. Should be called at splimp() priority. Check
416
417 (void)splx(s);
418}
419
420
421/*
422 * Start output on interface. Should be called at splimp() priority. Check
423 * that the output is idle (ie, IFF_OACTIVE is not set) before calling this
424 * function. If media selection is in progress we set IFF_OACTIVE ourselves
423 * that the output is idle (ie, IFF_DRV_OACTIVE is not set) before calling this
424 * function. If media selection is in progress we set IFF_DRV_OACTIVE ourselves
425 * and return immediately.
426 */
427static void
428xe_start(struct ifnet *ifp) {
429 struct xe_softc *scp = ifp->if_softc;
430 struct mbuf *mbp;
431
432 if (scp->autoneg_status != XE_AUTONEG_NONE) {
425 * and return immediately.
426 */
427static void
428xe_start(struct ifnet *ifp) {
429 struct xe_softc *scp = ifp->if_softc;
430 struct mbuf *mbp;
431
432 if (scp->autoneg_status != XE_AUTONEG_NONE) {
433 ifp->if_flags |= IFF_OACTIVE;
433 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
434 return;
435 }
436
437 DEVPRINTF(3, (scp->dev, "start\n"));
438
439 /*
440 * Loop while there are packets to be sent, and space to send them.
441 */

--- 4 unchanged lines hidden (view full) ---

446 if (mbp == NULL) {
447 /*
448 * We are using the !OACTIVE flag to indicate to the outside world that
449 * we can accept an additional packet rather than that the transmitter
450 * is _actually_ active. Indeed, the transmitter may be active, but if
451 * we haven't filled all the buffers with data then we still want to
452 * accept more.
453 */
434 return;
435 }
436
437 DEVPRINTF(3, (scp->dev, "start\n"));
438
439 /*
440 * Loop while there are packets to be sent, and space to send them.
441 */

--- 4 unchanged lines hidden (view full) ---

446 if (mbp == NULL) {
447 /*
448 * We are using the !OACTIVE flag to indicate to the outside world that
449 * we can accept an additional packet rather than that the transmitter
450 * is _actually_ active. Indeed, the transmitter may be active, but if
451 * we haven't filled all the buffers with data then we still want to
452 * accept more.
453 */
454 ifp->if_flags &= ~IFF_OACTIVE;
454 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
455 return;
456 }
457
458 if (xe_pio_write_packet(scp, mbp) != 0) {
459 /* Push the packet back onto the queue */
460 IF_PREPEND(&ifp->if_snd, mbp);
455 return;
456 }
457
458 if (xe_pio_write_packet(scp, mbp) != 0) {
459 /* Push the packet back onto the queue */
460 IF_PREPEND(&ifp->if_snd, mbp);
461 ifp->if_flags |= IFF_OACTIVE;
461 ifp->if_drv_flags |= IFF_DRV_OACTIVE;
462 return;
463 }
464
465 /* Tap off here if there is a bpf listener */
466 BPF_MTAP(ifp, mbp);
467
468 /* In case we don't hear from the card again... */
469 ifp->if_timer = 5;

--- 21 unchanged lines hidden (view full) ---

491
492 case SIOCSIFFLAGS:
493 DEVPRINTF(2, (scp->dev, "ioctl: SIOCSIFFLAGS: 0x%04x\n", ifp->if_flags));
494 /*
495 * If the interface is marked up and stopped, then start it. If it is
496 * marked down and running, then stop it.
497 */
498 if (ifp->if_flags & IFF_UP) {
462 return;
463 }
464
465 /* Tap off here if there is a bpf listener */
466 BPF_MTAP(ifp, mbp);
467
468 /* In case we don't hear from the card again... */
469 ifp->if_timer = 5;

--- 21 unchanged lines hidden (view full) ---

491
492 case SIOCSIFFLAGS:
493 DEVPRINTF(2, (scp->dev, "ioctl: SIOCSIFFLAGS: 0x%04x\n", ifp->if_flags));
494 /*
495 * If the interface is marked up and stopped, then start it. If it is
496 * marked down and running, then stop it.
497 */
498 if (ifp->if_flags & IFF_UP) {
499 if (!(ifp->if_flags & IFF_RUNNING)) {
499 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) {
500 xe_reset(scp);
501 xe_init(scp);
502 }
503 }
504 else {
500 xe_reset(scp);
501 xe_init(scp);
502 }
503 }
504 else {
505 if (ifp->if_flags & IFF_RUNNING)
505 if (ifp->if_drv_flags & IFF_DRV_RUNNING)
506 xe_stop(scp);
507 }
508 /* FALL THROUGH (handle changes to PROMISC/ALLMULTI flags) */
509
510 case SIOCADDMULTI:
511 case SIOCDELMULTI:
512 DEVPRINTF(2, (scp->dev, "ioctl: SIOC{ADD,DEL}MULTI\n"));
513 /*

--- 111 unchanged lines hidden (view full) ---

625 scp->mibdata.dot3StatsCollFrequencies[0]++;
626 break;
627 default:
628 scp->mibdata.dot3StatsMultipleCollisionFrames++;
629 scp->mibdata.dot3StatsCollFrequencies[coll-1]++;
630 }
631 }
632 ifp->if_timer = 0;
506 xe_stop(scp);
507 }
508 /* FALL THROUGH (handle changes to PROMISC/ALLMULTI flags) */
509
510 case SIOCADDMULTI:
511 case SIOCDELMULTI:
512 DEVPRINTF(2, (scp->dev, "ioctl: SIOC{ADD,DEL}MULTI\n"));
513 /*

--- 111 unchanged lines hidden (view full) ---

625 scp->mibdata.dot3StatsCollFrequencies[0]++;
626 break;
627 default:
628 scp->mibdata.dot3StatsMultipleCollisionFrames++;
629 scp->mibdata.dot3StatsCollFrequencies[coll-1]++;
630 }
631 }
632 ifp->if_timer = 0;
633 ifp->if_flags &= ~IFF_OACTIVE;
633 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
634 }
635
636 /* Handle most MAC interrupts */
637 if (isr & XE_ISR_MAC_INTR) {
638
639#if 0
640 /* Carrier sense lost -- only in 10Mbit HDX mode */
641 if (txst0 & XE_TXST0_NO_CARRIER || !(txst1 & XE_TXST1_LINK_STATUS)) {

--- 288 unchanged lines hidden (view full) ---

930 * Select 10baseT or 10base2, whichever is connected
931 * ENDIF
932 * ENDIF
933 */
934 switch (scp->autoneg_status) {
935
936 case XE_AUTONEG_NONE:
937 DEVPRINTF(2, (scp->dev, "Waiting for idle transmitter\n"));
634 }
635
636 /* Handle most MAC interrupts */
637 if (isr & XE_ISR_MAC_INTR) {
638
639#if 0
640 /* Carrier sense lost -- only in 10Mbit HDX mode */
641 if (txst0 & XE_TXST0_NO_CARRIER || !(txst1 & XE_TXST1_LINK_STATUS)) {

--- 288 unchanged lines hidden (view full) ---

930 * Select 10baseT or 10base2, whichever is connected
931 * ENDIF
932 * ENDIF
933 */
934 switch (scp->autoneg_status) {
935
936 case XE_AUTONEG_NONE:
937 DEVPRINTF(2, (scp->dev, "Waiting for idle transmitter\n"));
938 scp->ifp->if_flags |= IFF_OACTIVE;
938 scp->ifp->if_drv_flags |= IFF_DRV_OACTIVE;
939 scp->autoneg_status = XE_AUTONEG_WAITING;
940 /* FALL THROUGH */
941
942 case XE_AUTONEG_WAITING:
943 if (scp->tx_queued != 0) {
944 scp->chand = timeout(xe_setmedia, scp, hz/2);
945 return;
946 }

--- 177 unchanged lines hidden (view full) ---

1124
1125 case IFM_10_2:
1126 XE_OUTB(XE_LED, 0x3a);
1127 break;
1128 }
1129
1130 /* Restart output? */
1131 xe_enable_intr(scp);
939 scp->autoneg_status = XE_AUTONEG_WAITING;
940 /* FALL THROUGH */
941
942 case XE_AUTONEG_WAITING:
943 if (scp->tx_queued != 0) {
944 scp->chand = timeout(xe_setmedia, scp, hz/2);
945 return;
946 }

--- 177 unchanged lines hidden (view full) ---

1124
1125 case IFM_10_2:
1126 XE_OUTB(XE_LED, 0x3a);
1127 break;
1128 }
1129
1130 /* Restart output? */
1131 xe_enable_intr(scp);
1132 scp->ifp->if_flags &= ~IFF_OACTIVE;
1132 scp->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1133 xe_start(scp->ifp);
1134}
1135
1136
1137/*
1138 * Hard reset (power cycle) the card.
1139 */
1140static void

--- 52 unchanged lines hidden (view full) ---

1193 * set GP1 high to power on the ML6692 (bit 0)
1194 * set GP2 low to power on the 10Mhz chip (bit 1)
1195 */
1196 XE_SELECT_PAGE(4);
1197 XE_OUTB(XE_GPR0, XE_GPR0_GP2_SELECT|XE_GPR0_GP1_SELECT|XE_GPR0_GP1_OUT);
1198 }
1199
1200 /*
1133 xe_start(scp->ifp);
1134}
1135
1136
1137/*
1138 * Hard reset (power cycle) the card.
1139 */
1140static void

--- 52 unchanged lines hidden (view full) ---

1193 * set GP1 high to power on the ML6692 (bit 0)
1194 * set GP2 low to power on the 10Mhz chip (bit 1)
1195 */
1196 XE_SELECT_PAGE(4);
1197 XE_OUTB(XE_GPR0, XE_GPR0_GP2_SELECT|XE_GPR0_GP1_SELECT|XE_GPR0_GP1_OUT);
1198 }
1199
1200 /*
1201 * ~IFF_RUNNING == interface down.
1201 * ~IFF_DRV_RUNNING == interface down.
1202 */
1202 */
1203 scp->ifp->if_flags &= ~IFF_RUNNING;
1204 scp->ifp->if_flags &= ~IFF_OACTIVE;
1203 scp->ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1204 scp->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
1205 scp->ifp->if_timer = 0;
1206
1207 (void)splx(s);
1208}
1209
1210
1211/*
1212 * Enable interrupts from the card.

--- 751 unchanged lines hidden ---
1205 scp->ifp->if_timer = 0;
1206
1207 (void)splx(s);
1208}
1209
1210
1211/*
1212 * Enable interrupts from the card.

--- 751 unchanged lines hidden ---