if_fatm.c (147721) | if_fatm.c (148887) |
---|---|
1/*- 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 * 27 * Author: Hartmut Brandt <harti@freebsd.org> 28 * 29 * Fore PCA200E driver for NATM 30 */ 31 32#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2001-2003 3 * Fraunhofer Institute for Open Communication Systems (FhG Fokus). 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * SUCH DAMAGE. 26 * 27 * Author: Hartmut Brandt <harti@freebsd.org> 28 * 29 * Fore PCA200E driver for NATM 30 */ 31 32#include <sys/cdefs.h> |
33__FBSDID("$FreeBSD: head/sys/dev/fatm/if_fatm.c 147721 2005-07-01 10:45:02Z harti $"); | 33__FBSDID("$FreeBSD: head/sys/dev/fatm/if_fatm.c 148887 2005-08-09 10:20:02Z rwatson $"); |
34 35#include "opt_inet.h" 36#include "opt_natm.h" 37 38#include <sys/types.h> 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/malloc.h> --- 124 unchanged lines hidden (view full) --- 166fatm_utopia_writereg(struct ifatm *ifatm, u_int reg, u_int mask, u_int val) 167{ 168 int error; 169 struct cmdqueue *q; 170 struct fatm_softc *sc; 171 172 sc = ifatm->ifp->if_softc; 173 FATM_CHECKLOCK(sc); | 34 35#include "opt_inet.h" 36#include "opt_natm.h" 37 38#include <sys/types.h> 39#include <sys/param.h> 40#include <sys/systm.h> 41#include <sys/malloc.h> --- 124 unchanged lines hidden (view full) --- 166fatm_utopia_writereg(struct ifatm *ifatm, u_int reg, u_int mask, u_int val) 167{ 168 int error; 169 struct cmdqueue *q; 170 struct fatm_softc *sc; 171 172 sc = ifatm->ifp->if_softc; 173 FATM_CHECKLOCK(sc); |
174 if (!(ifatm->ifp->if_flags & IFF_RUNNING)) | 174 if (!(ifatm->ifp->if_drv_flags & IFF_DRV_RUNNING)) |
175 return (EIO); 176 177 /* get queue element and fill it */ 178 q = GET_QUEUE(sc->cmdqueue, struct cmdqueue, sc->cmdqueue.head); 179 180 H_SYNCSTAT_POSTREAD(sc, q->q.statp); 181 if (!(H_GETSTAT(q->q.statp) & FATM_STAT_FREE)) { 182 sc->istats.cmd_queue_full++; --- 66 unchanged lines hidden (view full) --- 249fatm_utopia_readregs_internal(struct fatm_softc *sc) 250{ 251 int error, i; 252 uint32_t *ptr; 253 struct cmdqueue *q; 254 255 /* get the buffer */ 256 for (;;) { | 175 return (EIO); 176 177 /* get queue element and fill it */ 178 q = GET_QUEUE(sc->cmdqueue, struct cmdqueue, sc->cmdqueue.head); 179 180 H_SYNCSTAT_POSTREAD(sc, q->q.statp); 181 if (!(H_GETSTAT(q->q.statp) & FATM_STAT_FREE)) { 182 sc->istats.cmd_queue_full++; --- 66 unchanged lines hidden (view full) --- 249fatm_utopia_readregs_internal(struct fatm_softc *sc) 250{ 251 int error, i; 252 uint32_t *ptr; 253 struct cmdqueue *q; 254 255 /* get the buffer */ 256 for (;;) { |
257 if (!(sc->ifp->if_flags & IFF_RUNNING)) | 257 if (!(sc->ifp->if_drv_flags & IFF_DRV_RUNNING)) |
258 return (EIO); 259 if (!(sc->flags & FATM_REGS_INUSE)) 260 break; 261 cv_wait(&sc->cv_regs, &sc->mtx); 262 } 263 sc->flags |= FATM_REGS_INUSE; 264 265 q = GET_QUEUE(sc->cmdqueue, struct cmdqueue, sc->cmdqueue.head); --- 125 unchanged lines hidden (view full) --- 391 * Ensure that the heart is still beating. 392 */ 393static void 394fatm_watchdog(struct ifnet *ifp) 395{ 396 struct fatm_softc *sc = ifp->if_softc; 397 398 FATM_LOCK(sc); | 258 return (EIO); 259 if (!(sc->flags & FATM_REGS_INUSE)) 260 break; 261 cv_wait(&sc->cv_regs, &sc->mtx); 262 } 263 sc->flags |= FATM_REGS_INUSE; 264 265 q = GET_QUEUE(sc->cmdqueue, struct cmdqueue, sc->cmdqueue.head); --- 125 unchanged lines hidden (view full) --- 391 * Ensure that the heart is still beating. 392 */ 393static void 394fatm_watchdog(struct ifnet *ifp) 395{ 396 struct fatm_softc *sc = ifp->if_softc; 397 398 FATM_LOCK(sc); |
399 if (ifp->if_flags & IFF_RUNNING) { | 399 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { |
400 fatm_check_heartbeat(sc); 401 ifp->if_timer = 5; 402 } 403 FATM_UNLOCK(sc); 404} 405 406/* 407 * Hard reset the i960 on the board. This is done by initializing registers, --- 63 unchanged lines hidden (view full) --- 471 472 /* Stop the board */ 473 utopia_stop(&sc->utopia); 474 (void)fatm_reset(sc); 475 476 /* stop watchdog */ 477 sc->ifp->if_timer = 0; 478 | 400 fatm_check_heartbeat(sc); 401 ifp->if_timer = 5; 402 } 403 FATM_UNLOCK(sc); 404} 405 406/* 407 * Hard reset the i960 on the board. This is done by initializing registers, --- 63 unchanged lines hidden (view full) --- 471 472 /* Stop the board */ 473 utopia_stop(&sc->utopia); 474 (void)fatm_reset(sc); 475 476 /* stop watchdog */ 477 sc->ifp->if_timer = 0; 478 |
479 if (sc->ifp->if_flags & IFF_RUNNING) { 480 sc->ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE); | 479 if (sc->ifp->if_drv_flags & IFF_DRV_RUNNING) { 480 sc->ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | IFF_DRV_OACTIVE); |
481 ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), 482 sc->utopia.carrier == UTP_CARR_OK); 483 484 /* 485 * Collect transmit mbufs, partial receive mbufs and 486 * supplied mbufs 487 */ 488 for (i = 0; i < FATM_TX_QLEN; i++) { --- 766 unchanged lines hidden (view full) --- 1255static void 1256fatm_init_locked(struct fatm_softc *sc) 1257{ 1258 struct rxqueue *q; 1259 int i, c, error; 1260 uint32_t start; 1261 1262 DBG(sc, INIT, ("initialize")); | 481 ATMEV_SEND_IFSTATE_CHANGED(IFP2IFATM(sc->ifp), 482 sc->utopia.carrier == UTP_CARR_OK); 483 484 /* 485 * Collect transmit mbufs, partial receive mbufs and 486 * supplied mbufs 487 */ 488 for (i = 0; i < FATM_TX_QLEN; i++) { --- 766 unchanged lines hidden (view full) --- 1255static void 1256fatm_init_locked(struct fatm_softc *sc) 1257{ 1258 struct rxqueue *q; 1259 int i, c, error; 1260 uint32_t start; 1261 1262 DBG(sc, INIT, ("initialize")); |
1263 if (sc->ifp->if_flags & IFF_RUNNING) | 1263 if (sc->ifp->if_drv_flags & IFF_DRV_RUNNING) |
1264 fatm_stop(sc); 1265 1266 /* 1267 * Hard reset the board 1268 */ 1269 if (fatm_reset(sc)) 1270 return; 1271 --- 59 unchanged lines hidden (view full) --- 1331 * Supply buffers to the card 1332 */ 1333 fatm_supply_small_buffers(sc); 1334 fatm_supply_large_buffers(sc); 1335 1336 /* 1337 * Now set flags, that we are ready 1338 */ | 1264 fatm_stop(sc); 1265 1266 /* 1267 * Hard reset the board 1268 */ 1269 if (fatm_reset(sc)) 1270 return; 1271 --- 59 unchanged lines hidden (view full) --- 1331 * Supply buffers to the card 1332 */ 1333 fatm_supply_small_buffers(sc); 1334 fatm_supply_large_buffers(sc); 1335 1336 /* 1337 * Now set flags, that we are ready 1338 */ |
1339 sc->ifp->if_flags |= IFF_RUNNING; | 1339 sc->ifp->if_drv_flags |= IFF_DRV_RUNNING; |
1340 1341 /* 1342 * Start the watchdog timer 1343 */ 1344 sc->ifp->if_timer = 5; 1345 1346 /* start SUNI */ 1347 utopia_start(&sc->utopia); --- 282 unchanged lines hidden (view full) --- 1630 1631 FATM_LOCK(sc); 1632 if (!READ4(sc, FATMO_PSR)) { 1633 FATM_UNLOCK(sc); 1634 return; 1635 } 1636 WRITE4(sc, FATMO_HCR, FATM_HCR_CLRIRQ); 1637 | 1340 1341 /* 1342 * Start the watchdog timer 1343 */ 1344 sc->ifp->if_timer = 5; 1345 1346 /* start SUNI */ 1347 utopia_start(&sc->utopia); --- 282 unchanged lines hidden (view full) --- 1630 1631 FATM_LOCK(sc); 1632 if (!READ4(sc, FATMO_PSR)) { 1633 FATM_UNLOCK(sc); 1634 return; 1635 } 1636 WRITE4(sc, FATMO_HCR, FATM_HCR_CLRIRQ); 1637 |
1638 if (!(sc->ifp->if_flags & IFF_RUNNING)) { | 1638 if (!(sc->ifp->if_drv_flags & IFF_DRV_RUNNING)) { |
1639 FATM_UNLOCK(sc); 1640 return; 1641 } 1642 fatm_intr_drain_cmd(sc); 1643 fatm_intr_drain_rx(sc); 1644 fatm_intr_drain_tx(sc); 1645 fatm_intr_drain_small_buffers(sc); 1646 fatm_intr_drain_large_buffers(sc); --- 38 unchanged lines hidden (view full) --- 1685 int error; 1686 struct cmdqueue *q; 1687 1688 /* 1689 * Wait until either the interface is stopped or we can get the 1690 * statistics buffer 1691 */ 1692 for (;;) { | 1639 FATM_UNLOCK(sc); 1640 return; 1641 } 1642 fatm_intr_drain_cmd(sc); 1643 fatm_intr_drain_rx(sc); 1644 fatm_intr_drain_tx(sc); 1645 fatm_intr_drain_small_buffers(sc); 1646 fatm_intr_drain_large_buffers(sc); --- 38 unchanged lines hidden (view full) --- 1685 int error; 1686 struct cmdqueue *q; 1687 1688 /* 1689 * Wait until either the interface is stopped or we can get the 1690 * statistics buffer 1691 */ 1692 for (;;) { |
1693 if (!(sc->ifp->if_flags & IFF_RUNNING)) | 1693 if (!(sc->ifp->if_drv_flags & IFF_DRV_RUNNING)) |
1694 return (EIO); 1695 if (!(sc->flags & FATM_STAT_INUSE)) 1696 break; 1697 cv_wait(&sc->cv_stat, &sc->mtx); 1698 } 1699 sc->flags |= FATM_STAT_INUSE; 1700 1701 q = GET_QUEUE(sc->cmdqueue, struct cmdqueue, sc->cmdqueue.head); --- 389 unchanged lines hidden (view full) --- 2091 2092 vci = ATM_PH_VCI(&aph); 2093 vpi = ATM_PH_VPI(&aph); 2094 2095 /* 2096 * From here on we need the softc 2097 */ 2098 FATM_LOCK(sc); | 1694 return (EIO); 1695 if (!(sc->flags & FATM_STAT_INUSE)) 1696 break; 1697 cv_wait(&sc->cv_stat, &sc->mtx); 1698 } 1699 sc->flags |= FATM_STAT_INUSE; 1700 1701 q = GET_QUEUE(sc->cmdqueue, struct cmdqueue, sc->cmdqueue.head); --- 389 unchanged lines hidden (view full) --- 2091 2092 vci = ATM_PH_VCI(&aph); 2093 vpi = ATM_PH_VPI(&aph); 2094 2095 /* 2096 * From here on we need the softc 2097 */ 2098 FATM_LOCK(sc); |
2099 if (!(ifp->if_flags & IFF_RUNNING)) { | 2099 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { |
2100 FATM_UNLOCK(sc); 2101 m_freem(m); 2102 break; 2103 } 2104 if (!VC_OK(sc, vpi, vci) || (vc = sc->vccs[vci]) == NULL || 2105 !(vc->vflags & FATM_VCC_OPEN)) { 2106 FATM_UNLOCK(sc); 2107 m_freem(m); --- 151 unchanged lines hidden (view full) --- 2259 2260 vc = uma_zalloc(sc->vcc_zone, M_NOWAIT | M_ZERO); 2261 if (vc == NULL) 2262 return (ENOMEM); 2263 2264 error = 0; 2265 2266 FATM_LOCK(sc); | 2100 FATM_UNLOCK(sc); 2101 m_freem(m); 2102 break; 2103 } 2104 if (!VC_OK(sc, vpi, vci) || (vc = sc->vccs[vci]) == NULL || 2105 !(vc->vflags & FATM_VCC_OPEN)) { 2106 FATM_UNLOCK(sc); 2107 m_freem(m); --- 151 unchanged lines hidden (view full) --- 2259 2260 vc = uma_zalloc(sc->vcc_zone, M_NOWAIT | M_ZERO); 2261 if (vc == NULL) 2262 return (ENOMEM); 2263 2264 error = 0; 2265 2266 FATM_LOCK(sc); |
2267 if (!(sc->ifp->if_flags & IFF_RUNNING)) { | 2267 if (!(sc->ifp->if_drv_flags & IFF_DRV_RUNNING)) { |
2268 error = EIO; 2269 goto done; 2270 } 2271 if (sc->vccs[op->param.vci] != NULL) { 2272 error = EBUSY; 2273 goto done; 2274 } 2275 vc->param = op->param; --- 123 unchanged lines hidden (view full) --- 2399 struct card_vcc *vc; 2400 2401 if (!VC_OK(sc, cl->vpi, cl->vci)) 2402 return (EINVAL); 2403 2404 error = 0; 2405 2406 FATM_LOCK(sc); | 2268 error = EIO; 2269 goto done; 2270 } 2271 if (sc->vccs[op->param.vci] != NULL) { 2272 error = EBUSY; 2273 goto done; 2274 } 2275 vc->param = op->param; --- 123 unchanged lines hidden (view full) --- 2399 struct card_vcc *vc; 2400 2401 if (!VC_OK(sc, cl->vpi, cl->vci)) 2402 return (EINVAL); 2403 2404 error = 0; 2405 2406 FATM_LOCK(sc); |
2407 if (!(sc->ifp->if_flags & IFF_RUNNING)) { | 2407 if (!(sc->ifp->if_drv_flags & IFF_DRV_RUNNING)) { |
2408 error = EIO; 2409 goto done; 2410 } 2411 vc = sc->vccs[cl->vci]; 2412 if (vc == NULL || !(vc->vflags & (FATM_VCC_OPEN | FATM_VCC_TRY_OPEN))) { 2413 error = ENOENT; 2414 goto done; 2415 } --- 46 unchanged lines hidden (view full) --- 2462 2463 case SIOCATMCLOSEVCC: /* kernel internal use */ 2464 error = fatm_close_vcc(sc, cl); 2465 break; 2466 2467 case SIOCSIFADDR: 2468 FATM_LOCK(sc); 2469 ifp->if_flags |= IFF_UP; | 2408 error = EIO; 2409 goto done; 2410 } 2411 vc = sc->vccs[cl->vci]; 2412 if (vc == NULL || !(vc->vflags & (FATM_VCC_OPEN | FATM_VCC_TRY_OPEN))) { 2413 error = ENOENT; 2414 goto done; 2415 } --- 46 unchanged lines hidden (view full) --- 2462 2463 case SIOCATMCLOSEVCC: /* kernel internal use */ 2464 error = fatm_close_vcc(sc, cl); 2465 break; 2466 2467 case SIOCSIFADDR: 2468 FATM_LOCK(sc); 2469 ifp->if_flags |= IFF_UP; |
2470 if (!(ifp->if_flags & IFF_RUNNING)) | 2470 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) |
2471 fatm_init_locked(sc); 2472 switch (ifa->ifa_addr->sa_family) { 2473#ifdef INET 2474 case AF_INET: 2475 case AF_INET6: 2476 ifa->ifa_rtrequest = atm_rtrequest; 2477 break; 2478#endif 2479 default: 2480 break; 2481 } 2482 FATM_UNLOCK(sc); 2483 break; 2484 2485 case SIOCSIFFLAGS: 2486 FATM_LOCK(sc); 2487 if (ifp->if_flags & IFF_UP) { | 2471 fatm_init_locked(sc); 2472 switch (ifa->ifa_addr->sa_family) { 2473#ifdef INET 2474 case AF_INET: 2475 case AF_INET6: 2476 ifa->ifa_rtrequest = atm_rtrequest; 2477 break; 2478#endif 2479 default: 2480 break; 2481 } 2482 FATM_UNLOCK(sc); 2483 break; 2484 2485 case SIOCSIFFLAGS: 2486 FATM_LOCK(sc); 2487 if (ifp->if_flags & IFF_UP) { |
2488 if (!(ifp->if_flags & IFF_RUNNING)) { | 2488 if (!(ifp->if_drv_flags & IFF_DRV_RUNNING)) { |
2489 fatm_init_locked(sc); 2490 } 2491 } else { | 2489 fatm_init_locked(sc); 2490 } 2491 } else { |
2492 if (ifp->if_flags & IFF_RUNNING) { | 2492 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { |
2493 fatm_stop(sc); 2494 } 2495 } 2496 FATM_UNLOCK(sc); 2497 break; 2498 2499 case SIOCGIFMEDIA: 2500 case SIOCSIFMEDIA: | 2493 fatm_stop(sc); 2494 } 2495 } 2496 FATM_UNLOCK(sc); 2497 break; 2498 2499 case SIOCGIFMEDIA: 2500 case SIOCSIFMEDIA: |
2501 if (ifp->if_flags & IFF_RUNNING) | 2501 if (ifp->if_drv_flags & IFF_DRV_RUNNING) |
2502 error = ifmedia_ioctl(ifp, ifr, &sc->media, cmd); 2503 else 2504 error = EINVAL; 2505 break; 2506 2507 case SIOCATMGVCCS: 2508 /* return vcc table */ 2509 vtab = atm_getvccs((struct atmio_vcc **)sc->vccs, --- 600 unchanged lines hidden --- | 2502 error = ifmedia_ioctl(ifp, ifr, &sc->media, cmd); 2503 else 2504 error = EINVAL; 2505 break; 2506 2507 case SIOCATMGVCCS: 2508 /* return vcc table */ 2509 vtab = atm_getvccs((struct atmio_vcc **)sc->vccs, --- 600 unchanged lines hidden --- |