if_sn.c (148654) | if_sn.c (148887) |
---|---|
1/*- 2 * Copyright (c) 1996 Gardner Buchanan <gbuchanan@shl.com> 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 --- 16 unchanged lines hidden (view full) --- 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1996 Gardner Buchanan <gbuchanan@shl.com> 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 --- 16 unchanged lines hidden (view full) --- 25 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 29 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/sn/if_sn.c 148654 2005-08-03 00:18:35Z rwatson $"); | 33__FBSDID("$FreeBSD: head/sys/dev/sn/if_sn.c 148887 2005-08-09 10:20:02Z rwatson $"); |
34 35/* 36 * This is a driver for SMC's 9000 series of Ethernet adapters. 37 * 38 * This FreeBSD driver is derived from the smc9194 Linux driver by 39 * Erik Stahlman and is Copyright (C) 1996 by Erik Stahlman. 40 * This driver also shamelessly borrows from the FreeBSD ep driver 41 * which is Copyright (C) 1994 Herb Peyerl <hpeyerl@novatel.ca> --- 184 unchanged lines hidden (view full) --- 226 227int 228sn_detach(device_t dev) 229{ 230 struct sn_softc *sc = device_get_softc(dev); 231 struct ifnet *ifp = sc->ifp; 232 233 snstop(sc); | 34 35/* 36 * This is a driver for SMC's 9000 series of Ethernet adapters. 37 * 38 * This FreeBSD driver is derived from the smc9194 Linux driver by 39 * Erik Stahlman and is Copyright (C) 1996 by Erik Stahlman. 40 * This driver also shamelessly borrows from the FreeBSD ep driver 41 * which is Copyright (C) 1994 Herb Peyerl <hpeyerl@novatel.ca> --- 184 unchanged lines hidden (view full) --- 226 227int 228sn_detach(device_t dev) 229{ 230 struct sn_softc *sc = device_get_softc(dev); 231 struct ifnet *ifp = sc->ifp; 232 233 snstop(sc); |
234 ifp->if_flags &= ~IFF_RUNNING; | 234 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; |
235 ether_ifdetach(ifp); 236 if_free(ifp); 237 sn_deactivate(dev); 238 SN_LOCK_DESTORY(sc); 239 return 0; 240} 241 242static void --- 89 unchanged lines hidden (view full) --- 332 CSR_WRITE_1(sc, INTR_MASK_REG_B, mask); 333 sc->intr_mask = mask; 334 sc->pages_wanted = -1; 335 336 337 /* 338 * Mark the interface running but not active. 339 */ | 235 ether_ifdetach(ifp); 236 if_free(ifp); 237 sn_deactivate(dev); 238 SN_LOCK_DESTORY(sc); 239 return 0; 240} 241 242static void --- 89 unchanged lines hidden (view full) --- 332 CSR_WRITE_1(sc, INTR_MASK_REG_B, mask); 333 sc->intr_mask = mask; 334 sc->pages_wanted = -1; 335 336 337 /* 338 * Mark the interface running but not active. 339 */ |
340 ifp->if_flags |= IFF_RUNNING; 341 ifp->if_flags &= ~IFF_OACTIVE; | 340 ifp->if_drv_flags |= IFF_DRV_RUNNING; 341 ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
342 343 /* 344 * Attempt to push out any waiting packets. 345 */ 346 snstart_locked(ifp); 347} 348 349static void --- 18 unchanged lines hidden (view full) --- 368 uint16_t length; 369 uint16_t numPages; 370 uint8_t packet_no; 371 int time_out; 372 int junk = 0; 373 374 SN_ASSERT_LOCKED(sc); 375 | 342 343 /* 344 * Attempt to push out any waiting packets. 345 */ 346 snstart_locked(ifp); 347} 348 349static void --- 18 unchanged lines hidden (view full) --- 368 uint16_t length; 369 uint16_t numPages; 370 uint8_t packet_no; 371 int time_out; 372 int junk = 0; 373 374 SN_ASSERT_LOCKED(sc); 375 |
376 if (sc->ifp->if_flags & IFF_OACTIVE) | 376 if (sc->ifp->if_drv_flags & IFF_DRV_OACTIVE) |
377 return; 378 if (sc->pages_wanted != -1) { 379 if_printf(ifp, "snstart() while memory allocation pending\n"); 380 return; 381 } 382startagain: 383 384 /* --- 71 unchanged lines hidden (view full) --- 456 * interface active since there is no point in attempting an 457 * snstart() until after the memory is available. 458 */ 459 mask = CSR_READ_1(sc, INTR_MASK_REG_B) | IM_ALLOC_INT; 460 CSR_WRITE_1(sc, INTR_MASK_REG_B, mask); 461 sc->intr_mask = mask; 462 463 sc->ifp->if_timer = 1; | 377 return; 378 if (sc->pages_wanted != -1) { 379 if_printf(ifp, "snstart() while memory allocation pending\n"); 380 return; 381 } 382startagain: 383 384 /* --- 71 unchanged lines hidden (view full) --- 456 * interface active since there is no point in attempting an 457 * snstart() until after the memory is available. 458 */ 459 mask = CSR_READ_1(sc, INTR_MASK_REG_B) | IM_ALLOC_INT; 460 CSR_WRITE_1(sc, INTR_MASK_REG_B, mask); 461 sc->intr_mask = mask; 462 463 sc->ifp->if_timer = 1; |
464 sc->ifp->if_flags |= IFF_OACTIVE; | 464 sc->ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
465 sc->pages_wanted = numPages; 466 return; 467 } 468 /* 469 * The memory allocation completed. Check the results. 470 */ 471 packet_no = CSR_READ_1(sc, ALLOC_RESULT_REG_B); 472 if (packet_no & ARR_FAILED) { --- 66 unchanged lines hidden (view full) --- 539 * watchdog in case we miss the interrupt. 540 */ 541 mask = CSR_READ_1(sc, INTR_MASK_REG_B) | (IM_TX_INT | IM_TX_EMPTY_INT); 542 CSR_WRITE_1(sc, INTR_MASK_REG_B, mask); 543 sc->intr_mask = mask; 544 545 CSR_WRITE_2(sc, MMU_CMD_REG_W, MMUCR_ENQUEUE); 546 | 465 sc->pages_wanted = numPages; 466 return; 467 } 468 /* 469 * The memory allocation completed. Check the results. 470 */ 471 packet_no = CSR_READ_1(sc, ALLOC_RESULT_REG_B); 472 if (packet_no & ARR_FAILED) { --- 66 unchanged lines hidden (view full) --- 539 * watchdog in case we miss the interrupt. 540 */ 541 mask = CSR_READ_1(sc, INTR_MASK_REG_B) | (IM_TX_INT | IM_TX_EMPTY_INT); 542 CSR_WRITE_1(sc, INTR_MASK_REG_B, mask); 543 sc->intr_mask = mask; 544 545 CSR_WRITE_2(sc, MMU_CMD_REG_W, MMUCR_ENQUEUE); 546 |
547 sc->ifp->if_flags |= IFF_OACTIVE; | 547 sc->ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
548 sc->ifp->if_timer = 1; 549 550 BPF_MTAP(ifp, top); 551 552 sc->ifp->if_opackets++; 553 m_freem(top); 554 555 --- 190 unchanged lines hidden (view full) --- 746 sc->ifp->if_opackets++; 747 m_freem(top); 748 749try_start: 750 751 /* 752 * Now pass control to snstart() to queue any additional packets 753 */ | 548 sc->ifp->if_timer = 1; 549 550 BPF_MTAP(ifp, top); 551 552 sc->ifp->if_opackets++; 553 m_freem(top); 554 555 --- 190 unchanged lines hidden (view full) --- 746 sc->ifp->if_opackets++; 747 m_freem(top); 748 749try_start: 750 751 /* 752 * Now pass control to snstart() to queue any additional packets 753 */ |
754 sc->ifp->if_flags &= ~IFF_OACTIVE; | 754 sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
755 snstart(ifp); 756 757 /* 758 * We've sent something, so we're active. Set a watchdog in case the 759 * TX_EMPTY interrupt is lost. 760 */ | 755 snstart(ifp); 756 757 /* 758 * We've sent something, so we're active. Set a watchdog in case the 759 * TX_EMPTY interrupt is lost. 760 */ |
761 sc->ifp->if_flags |= IFF_OACTIVE; | 761 sc->ifp->if_drv_flags |= IFF_DRV_OACTIVE; |
762 sc->ifp->if_timer = 1; 763 764 return; 765} 766 767 768void 769sn_intr(void *arg) --- 70 unchanged lines hidden (view full) --- 840 /* 841 * An on-card memory allocation came through. 842 */ 843 if (status & IM_ALLOC_INT) { 844 /* 845 * Disable this interrupt. 846 */ 847 mask &= ~IM_ALLOC_INT; | 762 sc->ifp->if_timer = 1; 763 764 return; 765} 766 767 768void 769sn_intr(void *arg) --- 70 unchanged lines hidden (view full) --- 840 /* 841 * An on-card memory allocation came through. 842 */ 843 if (status & IM_ALLOC_INT) { 844 /* 845 * Disable this interrupt. 846 */ 847 mask &= ~IM_ALLOC_INT; |
848 sc->ifp->if_flags &= ~IFF_OACTIVE; | 848 sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
849 snresume(sc->ifp); 850 } 851 /* 852 * TX Completion. Handle a transmit error message. This will only be 853 * called when there is an error, because of the AUTO_RELEASE mode. 854 */ 855 if (status & IM_TX_INT) { 856 /* --- 50 unchanged lines hidden (view full) --- 907 SMC_SELECT_BANK(sc, 2); 908 while (CSR_READ_2(sc, MMU_CMD_REG_W) & MMUCR_BUSY) /* NOTHING */ 909 ; 910 CSR_WRITE_2(sc, MMU_CMD_REG_W, MMUCR_FREEPKT); 911 912 /* 913 * Attempt to queue more transmits. 914 */ | 849 snresume(sc->ifp); 850 } 851 /* 852 * TX Completion. Handle a transmit error message. This will only be 853 * called when there is an error, because of the AUTO_RELEASE mode. 854 */ 855 if (status & IM_TX_INT) { 856 /* --- 50 unchanged lines hidden (view full) --- 907 SMC_SELECT_BANK(sc, 2); 908 while (CSR_READ_2(sc, MMU_CMD_REG_W) & MMUCR_BUSY) /* NOTHING */ 909 ; 910 CSR_WRITE_2(sc, MMU_CMD_REG_W, MMUCR_FREEPKT); 911 912 /* 913 * Attempt to queue more transmits. 914 */ |
915 sc->ifp->if_flags &= ~IFF_OACTIVE; | 915 sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
916 snstart_locked(sc->ifp); 917 } 918 /* 919 * Transmit underrun. We use this opportunity to update transmit 920 * statistics from the card. 921 */ 922 if (status & IM_TX_EMPTY_INT) { 923 --- 21 unchanged lines hidden (view full) --- 945 */ 946 sc->ifp->if_collisions += (card_stats & ECR_MCOLN_MASK) >> 4; 947 948 SMC_SELECT_BANK(sc, 2); 949 950 /* 951 * Attempt to enqueue some more stuff. 952 */ | 916 snstart_locked(sc->ifp); 917 } 918 /* 919 * Transmit underrun. We use this opportunity to update transmit 920 * statistics from the card. 921 */ 922 if (status & IM_TX_EMPTY_INT) { 923 --- 21 unchanged lines hidden (view full) --- 945 */ 946 sc->ifp->if_collisions += (card_stats & ECR_MCOLN_MASK) >> 4; 947 948 SMC_SELECT_BANK(sc, 2); 949 950 /* 951 * Attempt to enqueue some more stuff. 952 */ |
953 sc->ifp->if_flags &= ~IFF_OACTIVE; | 953 sc->ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; |
954 snstart_locked(sc->ifp); 955 } 956 /* 957 * Some other error. Try to fix it by resetting the adapter. 958 */ 959 if (status & IM_EPH_INT) { 960 snstop(sc); 961 sninit_locked(sc); --- 164 unchanged lines hidden (view full) --- 1126snioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 1127{ 1128 struct sn_softc *sc = ifp->if_softc; 1129 int error = 0; 1130 1131 switch (cmd) { 1132 case SIOCSIFFLAGS: 1133 SN_LOCK(sc); | 954 snstart_locked(sc->ifp); 955 } 956 /* 957 * Some other error. Try to fix it by resetting the adapter. 958 */ 959 if (status & IM_EPH_INT) { 960 snstop(sc); 961 sninit_locked(sc); --- 164 unchanged lines hidden (view full) --- 1126snioctl(struct ifnet *ifp, u_long cmd, caddr_t data) 1127{ 1128 struct sn_softc *sc = ifp->if_softc; 1129 int error = 0; 1130 1131 switch (cmd) { 1132 case SIOCSIFFLAGS: 1133 SN_LOCK(sc); |
1134 if ((ifp->if_flags & IFF_UP) == 0 && ifp->if_flags & IFF_RUNNING) { 1135 ifp->if_flags &= ~IFF_RUNNING; | 1134 if ((ifp->if_flags & IFF_UP) == 0 && 1135 ifp->if_drv_flags & IFF_DRV_RUNNING) { 1136 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; |
1136 snstop(sc); 1137 } else { 1138 /* reinitialize card on any parameter change */ 1139 sninit_locked(sc); 1140 } 1141 SN_UNLOCK(sc); 1142 break; 1143 --- 288 unchanged lines hidden --- | 1137 snstop(sc); 1138 } else { 1139 /* reinitialize card on any parameter change */ 1140 sninit_locked(sc); 1141 } 1142 SN_UNLOCK(sc); 1143 break; 1144 --- 288 unchanged lines hidden --- |