From owner-p4-projects@FreeBSD.ORG Wed Mar 28 15:29:21 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 1268716A409; Wed, 28 Mar 2007 15:29:21 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DD89516A404 for ; Wed, 28 Mar 2007 15:29:20 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id CD38E13C4BB for ; Wed, 28 Mar 2007 15:29:20 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l2SFTK3N086268 for ; Wed, 28 Mar 2007 15:29:20 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l2SFTKuB086256 for perforce@freebsd.org; Wed, 28 Mar 2007 15:29:20 GMT (envelope-from hselasky@FreeBSD.org) Date: Wed, 28 Mar 2007 15:29:20 GMT Message-Id: <200703281529.l2SFTKuB086256@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky To: Perforce Change Reviews Cc: Subject: PERFORCE change 116736 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Mar 2007 15:29:21 -0000 http://perforce.freebsd.org/chv.cgi?CH=116736 Change 116736 by hselasky@hselasky_mini_itx on 2007/03/28 15:28:22 Make changes to the config thread system, like suggested by Sam Leffler. Basically this means, split the two parts of the config thread function into pre- and post-functions. Also extend the config thread system to allow N-phase semantics, where N-1 is a number that can be passed to the usbd_config_td_queue_command() function. Default is 0 which means 1-phase semantics are used. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/if_aue.c#18 edit .. //depot/projects/usb/src/sys/dev/usb/if_axe.c#16 edit .. //depot/projects/usb/src/sys/dev/usb/if_cue.c#14 edit .. //depot/projects/usb/src/sys/dev/usb/if_kue.c#16 edit .. //depot/projects/usb/src/sys/dev/usb/if_rue.c#15 edit .. //depot/projects/usb/src/sys/dev/usb/if_udav.c#15 edit .. //depot/projects/usb/src/sys/dev/usb/if_ural.c#19 edit .. //depot/projects/usb/src/sys/dev/usb/if_zyd.c#5 edit .. //depot/projects/usb/src/sys/dev/usb/ufoma.c#11 edit .. //depot/projects/usb/src/sys/dev/usb/uftdi.c#12 edit .. //depot/projects/usb/src/sys/dev/usb/umct.c#10 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#29 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#34 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/if_aue.c#18 (text+ko) ==== @@ -221,9 +221,17 @@ static miibus_writereg_t aue_cfg_miibus_writereg; static miibus_statchg_t aue_cfg_miibus_statchg; -static void -aue_cfg_setmulti(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount); +static usbd_config_td_command_t aue_cfg_setmulti; +static usbd_config_td_command_t aue_cfg_first_time_setup; +static usbd_config_td_command_t aue_config_copy; +static usbd_config_td_command_t aue_cfg_tick; +static usbd_config_td_command_t aue_cfg_pre_init; +static usbd_config_td_command_t aue_cfg_init; +static usbd_config_td_command_t aue_cfg_promisc_upd; +static usbd_config_td_command_t aue_cfg_ifmedia_upd; +static usbd_config_td_command_t aue_cfg_pre_stop; +static usbd_config_td_command_t aue_cfg_stop; + static void aue_cfg_reset_pegasus_II(struct aue_softc *sc); @@ -231,9 +239,6 @@ aue_cfg_reset(struct aue_softc *sc); static void -aue_cfg_first_time_setup(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount); -static void aue_intr_clear_stall_callback(struct usbd_xfer *xfer); static void @@ -252,12 +257,6 @@ aue_bulk_write_callback(struct usbd_xfer *xfer); static void -aue_config_copy(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount); -static void -aue_cfg_tick(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount); -static void aue_start_cb(struct ifnet *ifp); static void @@ -266,19 +265,10 @@ static void aue_start_transfers(struct aue_softc *sc); -static void -aue_cfg_init(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount); -static void -aue_cfg_promisc_upd(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount); static int aue_ifmedia_upd_cb(struct ifnet *ifp); static void -aue_cfg_ifmedia_upd(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount); -static void aue_ifmedia_sts_cb(struct ifnet *ifp, struct ifmediareq *ifmr); static int @@ -287,10 +277,6 @@ static void aue_watchdog(void *arg); -static void -aue_cfg_stop(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount); - static const struct usbd_config aue_config[AUE_ENDPT_MAX] = { [0] = { @@ -680,11 +666,6 @@ { u_int16_t i; - if (cc == NULL) { - /* nothing to do */ - return; - } - if ((cc->if_flags & IFF_ALLMULTI) || (cc->if_flags & IFF_PROMISC)) { AUE_CFG_SETBIT(sc, AUE_CTL0, AUE_CTL0_ALLMULTI); @@ -849,8 +830,7 @@ } error = usbd_config_td_setup(&(sc->sc_config_td), sc, &(sc->sc_mtx), - &aue_config_copy, NULL, - sizeof(struct aue_config_copy), 16); + NULL, sizeof(struct aue_config_copy), 16); if (error) { device_printf(dev, "could not setup config " "thread!\n"); @@ -864,7 +844,7 @@ /* start setup */ usbd_config_td_queue_command - (&(sc->sc_config_td), &aue_cfg_first_time_setup, 0); + (&(sc->sc_config_td), NULL, &aue_cfg_first_time_setup, 0, 0); /* start watchdog (will exit mutex) */ @@ -885,10 +865,6 @@ int error; u_int8_t eaddr[min(ETHER_ADDR_LEN,6)]; - if (cc == NULL) { - return; - } - /* reset the adapter */ aue_cfg_reset(sc); @@ -985,7 +961,7 @@ __callout_stop(&(sc->sc_watchdog)); - aue_cfg_stop(sc, NULL, 0); + aue_cfg_pre_stop(sc, NULL, 0); ifp = sc->sc_ifp; @@ -1355,8 +1331,7 @@ struct ifnet * ifp = sc->sc_ifp; struct mii_data * mii = GET_MII(sc); - if ((cc == NULL) || - (ifp == NULL) || + if ((ifp == NULL) || (mii == NULL)) { /* not ready */ return; @@ -1403,7 +1378,7 @@ mtx_lock(&(sc->sc_mtx)); usbd_config_td_queue_command - (&(sc->sc_config_td), &aue_cfg_init, 0); + (&(sc->sc_config_td), &aue_cfg_pre_init, &aue_cfg_init, 0, 0); mtx_unlock(&(sc->sc_mtx)); return; @@ -1426,27 +1401,28 @@ } static void -aue_cfg_init(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount) +aue_cfg_pre_init(struct aue_softc *sc, + struct aue_config_copy *cc, u_int16_t refcount) { - struct mii_data *mii = GET_MII(sc); - u_int8_t i; + struct ifnet *ifp = sc->sc_ifp; - if (cc == NULL) { + /* immediate configuration */ - /* immediate configuration */ + aue_cfg_pre_stop(sc, cc, 0); - struct ifnet *ifp = sc->sc_ifp; + ifp->if_drv_flags |= IFF_DRV_RUNNING; + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - aue_cfg_stop(sc, NULL, 0); + sc->sc_flags |= AUE_FLAG_HL_READY; + return; +} - ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - - sc->sc_flags |= AUE_FLAG_HL_READY; - - return; - } +static void +aue_cfg_init(struct aue_softc *sc, + struct aue_config_copy *cc, u_int16_t refcount) +{ + struct mii_data *mii = GET_MII(sc); + u_int8_t i; /* * Cancel pending I/O @@ -1486,11 +1462,6 @@ aue_cfg_promisc_upd(struct aue_softc *sc, struct aue_config_copy *cc, u_int16_t refcount) { - if (cc == NULL) { - /* nothing to do */ - return; - } - /* if we want promiscuous mode, set the allframes bit: */ if (cc->if_flags & IFF_PROMISC) { AUE_CFG_SETBIT(sc, AUE_CTL2, AUE_CTL2_RX_PROMISC); @@ -1510,7 +1481,7 @@ mtx_lock(&(sc->sc_mtx)); usbd_config_td_queue_command - (&(sc->sc_config_td), &aue_cfg_ifmedia_upd, 0); + (&(sc->sc_config_td), NULL, &aue_cfg_ifmedia_upd, 0, 0); mtx_unlock(&(sc->sc_mtx)); return 0; @@ -1523,8 +1494,7 @@ struct ifnet * ifp = sc->sc_ifp; struct mii_data * mii = GET_MII(sc); - if ((cc == NULL) || - (ifp == NULL) || + if ((ifp == NULL) || (mii == NULL)) { /* not ready */ return; @@ -1576,15 +1546,18 @@ if (ifp->if_flags & IFF_UP) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { usbd_config_td_queue_command - (&(sc->sc_config_td), &aue_cfg_promisc_upd, 0); + (&(sc->sc_config_td), &aue_config_copy, + &aue_cfg_promisc_upd, 0, 0); } else { usbd_config_td_queue_command - (&(sc->sc_config_td), &aue_cfg_init, 0); + (&(sc->sc_config_td), &aue_cfg_pre_init, + &aue_cfg_init, 0, 0); } } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { usbd_config_td_queue_command - (&(sc->sc_config_td), &aue_cfg_stop, 0); + (&(sc->sc_config_td), &aue_cfg_pre_stop, + &aue_cfg_stop, 0, 0); } } break; @@ -1592,7 +1565,8 @@ case SIOCADDMULTI: case SIOCDELMULTI: usbd_config_td_queue_command - (&(sc->sc_config_td), &aue_cfg_setmulti, 0); + (&(sc->sc_config_td), &aue_config_copy, + &aue_cfg_setmulti, 0, 0); break; case SIOCGIFMEDIA: @@ -1624,7 +1598,7 @@ mtx_assert(&(sc->sc_mtx), MA_OWNED); usbd_config_td_queue_command - (&(sc->sc_config_td), &aue_cfg_tick, 0); + (&(sc->sc_config_td), NULL, &aue_cfg_tick, 0, 0); __callout_reset(&(sc->sc_watchdog), hz, &aue_watchdog, sc); @@ -1640,50 +1614,57 @@ * NOTE: can be called when "ifp" is NULL */ static void -aue_cfg_stop(struct aue_softc *sc, - struct aue_config_copy *cc, u_int16_t refcount) +aue_cfg_pre_stop(struct aue_softc *sc, + struct aue_config_copy *cc, uint16_t refcount) { - if (cc == NULL) { + struct ifnet *ifp = sc->sc_ifp; - /* immediate configuration */ + if (cc) { + /* copy the needed configuration */ + aue_config_copy(sc, cc, refcount); + } - struct ifnet *ifp = sc->sc_ifp; + /* immediate configuration */ - if (ifp) { - /* clear flags */ - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | - IFF_DRV_OACTIVE); - } + if (ifp) { + /* clear flags */ + ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | + IFF_DRV_OACTIVE); + } - sc->sc_flags &= ~(AUE_FLAG_HL_READY| - AUE_FLAG_LL_READY); + sc->sc_flags &= ~(AUE_FLAG_HL_READY| + AUE_FLAG_LL_READY); - sc->sc_flags |= AUE_FLAG_WAIT_LINK; + sc->sc_flags |= AUE_FLAG_WAIT_LINK; - /* stop all the transfers, - * if not already stopped: - */ - if (sc->sc_xfer[0]) { - usbd_transfer_stop(sc->sc_xfer[0]); - } - if (sc->sc_xfer[1]) { - usbd_transfer_stop(sc->sc_xfer[1]); - } - if (sc->sc_xfer[2]) { - usbd_transfer_stop(sc->sc_xfer[2]); - } - if (sc->sc_xfer[3]) { - usbd_transfer_stop(sc->sc_xfer[3]); - } - if (sc->sc_xfer[4]) { - usbd_transfer_stop(sc->sc_xfer[4]); - } - if (sc->sc_xfer[5]) { - usbd_transfer_stop(sc->sc_xfer[5]); - } - return; + /* stop all the transfers, + * if not already stopped: + */ + if (sc->sc_xfer[0]) { + usbd_transfer_stop(sc->sc_xfer[0]); + } + if (sc->sc_xfer[1]) { + usbd_transfer_stop(sc->sc_xfer[1]); + } + if (sc->sc_xfer[2]) { + usbd_transfer_stop(sc->sc_xfer[2]); + } + if (sc->sc_xfer[3]) { + usbd_transfer_stop(sc->sc_xfer[3]); + } + if (sc->sc_xfer[4]) { + usbd_transfer_stop(sc->sc_xfer[4]); + } + if (sc->sc_xfer[5]) { + usbd_transfer_stop(sc->sc_xfer[5]); } + return; +} +static void +aue_cfg_stop(struct aue_softc *sc, + struct aue_config_copy *cc, u_int16_t refcount) +{ aue_cfg_csr_write_1(sc, AUE_CTL0, 0); aue_cfg_csr_write_1(sc, AUE_CTL1, 0); aue_cfg_reset(sc); @@ -1702,7 +1683,8 @@ mtx_lock(&(sc->sc_mtx)); usbd_config_td_queue_command - (&(sc->sc_config_td), &aue_cfg_stop, 0); + (&(sc->sc_config_td), &aue_cfg_pre_stop, + &aue_cfg_stop, 0, 0); mtx_unlock(&(sc->sc_mtx)); ==== //depot/projects/usb/src/sys/dev/usb/if_axe.c#16 (text+ko) ==== @@ -154,28 +154,27 @@ static miibus_writereg_t axe_cfg_miibus_writereg; static miibus_statchg_t axe_cfg_miibus_statchg; +static usbd_config_td_command_t axe_cfg_ifmedia_upd; +static usbd_config_td_command_t axe_config_copy; +static usbd_config_td_command_t axe_cfg_setmulti; +static usbd_config_td_command_t axe_cfg_first_time_setup; +static usbd_config_td_command_t axe_cfg_tick; +static usbd_config_td_command_t axe_cfg_pre_init; +static usbd_config_td_command_t axe_cfg_init; +static usbd_config_td_command_t axe_cfg_promisc_upd; +static usbd_config_td_command_t axe_cfg_pre_stop; +static usbd_config_td_command_t axe_cfg_stop; + static int axe_ifmedia_upd_cb(struct ifnet *ifp); static void -axe_cfg_ifmedia_upd(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount); -static void axe_ifmedia_sts_cb(struct ifnet *ifp, struct ifmediareq *ifmr); static void -axe_config_copy(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount); -static void -axe_cfg_setmulti(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount); -static void axe_cfg_reset(struct axe_softc *sc); static void -axe_cfg_first_time_setup(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount); -static void axe_intr_clear_stall_callback(struct usbd_xfer *xfer); static void @@ -194,9 +193,6 @@ axe_bulk_write_callback(struct usbd_xfer *xfer); static void -axe_cfg_tick(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount); -static void axe_start_cb(struct ifnet *ifp); static void @@ -205,22 +201,12 @@ static void axe_init_cb(void *arg); -static void -axe_cfg_init(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount); -static void -axe_cfg_promisc_upd(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount); static int axe_ioctl_cb(struct ifnet *ifp, u_long command, caddr_t data); static void axe_watchdog(void *arg); -static void -axe_cfg_stop(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount); - static const struct usbd_config axe_config[AXE_ENDPT_MAX] = { [0] = { @@ -430,7 +416,7 @@ mtx_lock(&(sc->sc_mtx)); usbd_config_td_queue_command - (&(sc->sc_config_td), &axe_cfg_ifmedia_upd, 0); + (&(sc->sc_config_td), NULL, &axe_cfg_ifmedia_upd, 0, 0); mtx_unlock(&(sc->sc_mtx)); return 0; @@ -443,8 +429,7 @@ struct ifnet * ifp = sc->sc_ifp; struct mii_data * mii = GET_MII(sc); - if ((cc == NULL) || - (ifp == NULL) || + if ((ifp == NULL) || (mii == NULL)) { /* not ready */ return; @@ -526,11 +511,6 @@ { u_int16_t rxmode; - if (cc == NULL) { - /* nothing to do */ - return; - } - axe_cfg_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode); rxmode = le16toh(rxmode); @@ -647,8 +627,7 @@ } error = usbd_config_td_setup(&(sc->sc_config_td), sc, &(sc->sc_mtx), - &axe_config_copy, NULL, - sizeof(struct axe_config_copy), 16); + NULL, sizeof(struct axe_config_copy), 16); if (error) { device_printf(dev, "could not setup config " "thread!\n"); @@ -662,7 +641,7 @@ /* start setup */ usbd_config_td_queue_command - (&(sc->sc_config_td), &axe_cfg_first_time_setup, 0); + (&(sc->sc_config_td), NULL, &axe_cfg_first_time_setup, 0, 0); /* start watchdog (will exit mutex) */ @@ -683,10 +662,6 @@ int error; u_int8_t eaddr[min(ETHER_ADDR_LEN,6)]; - if (cc == NULL) { - return; - } - /* set default value */ bzero(eaddr, sizeof(eaddr)); @@ -781,7 +756,7 @@ __callout_stop(&sc->sc_watchdog); - axe_cfg_stop(sc, NULL, 0); + axe_cfg_pre_stop(sc, NULL, 0); ifp = sc->sc_ifp; @@ -1049,8 +1024,7 @@ struct ifnet * ifp = sc->sc_ifp; struct mii_data * mii = GET_MII(sc); - if ((cc == NULL) || - (ifp == NULL) || + if ((ifp == NULL) || (mii == NULL)) { /* not ready */ return; @@ -1113,35 +1087,36 @@ mtx_lock(&(sc->sc_mtx)); usbd_config_td_queue_command - (&(sc->sc_config_td), &axe_cfg_init, 0); + (&(sc->sc_config_td), &axe_cfg_pre_init, &axe_cfg_init, 0, 0); mtx_unlock(&(sc->sc_mtx)); return; } static void -axe_cfg_init(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount) +axe_cfg_pre_init(struct axe_softc *sc, + struct axe_config_copy *cc, u_int16_t refcount) { - struct mii_data *mii = GET_MII(sc); - u_int16_t rxmode; + struct ifnet *ifp = sc->sc_ifp; - if (cc == NULL) { + /* immediate configuration */ - /* immediate configuration */ + axe_cfg_pre_stop(sc, cc, 0); - struct ifnet *ifp = sc->sc_ifp; + ifp->if_drv_flags |= IFF_DRV_RUNNING; + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - axe_cfg_stop(sc, NULL, 0); + sc->sc_flags |= AXE_FLAG_HL_READY; + return; +} - ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - - sc->sc_flags |= AXE_FLAG_HL_READY; +static void +axe_cfg_init(struct axe_softc *sc, + struct axe_config_copy *cc, u_int16_t refcount) +{ + struct mii_data *mii = GET_MII(sc); + u_int16_t rxmode; - return; - } - /* * Cancel pending I/O */ @@ -1192,11 +1167,6 @@ { u_int16_t rxmode; - if (cc == NULL) { - /* nothing to do */ - return; - } - axe_cfg_cmd(sc, AXE_CMD_RXCTL_READ, 0, 0, &rxmode); rxmode = le16toh(rxmode); @@ -1229,15 +1199,18 @@ if (ifp->if_flags & IFF_UP) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { usbd_config_td_queue_command - (&(sc->sc_config_td), &axe_cfg_promisc_upd, 0); + (&(sc->sc_config_td), &axe_config_copy, + &axe_cfg_promisc_upd, 0, 0); } else { usbd_config_td_queue_command - (&(sc->sc_config_td), &axe_cfg_init, 0); + (&(sc->sc_config_td), &axe_cfg_pre_init, + &axe_cfg_init, 0, 0); } } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { usbd_config_td_queue_command - (&(sc->sc_config_td), &axe_cfg_stop, 0); + (&(sc->sc_config_td), &axe_cfg_pre_stop, + &axe_cfg_stop, 0, 0); } } break; @@ -1245,7 +1218,8 @@ case SIOCADDMULTI: case SIOCDELMULTI: usbd_config_td_queue_command - (&(sc->sc_config_td), &axe_cfg_setmulti, 0); + (&(sc->sc_config_td), &axe_config_copy, + &axe_cfg_setmulti, 0, 0); break; case SIOCGIFMEDIA: @@ -1277,7 +1251,7 @@ mtx_assert(&(sc->sc_mtx), MA_OWNED); usbd_config_td_queue_command - (&(sc->sc_config_td), &axe_cfg_tick, 0); + (&(sc->sc_config_td), NULL, &axe_cfg_tick, 0, 0); __callout_reset(&(sc->sc_watchdog), hz, &axe_watchdog, sc); @@ -1290,50 +1264,57 @@ * NOTE: can be called when "ifp" is NULL */ static void -axe_cfg_stop(struct axe_softc *sc, - struct axe_config_copy *cc, u_int16_t refcount) +axe_cfg_pre_stop(struct axe_softc *sc, + struct axe_config_copy *cc, u_int16_t refcount) { - if (cc == NULL) { + struct ifnet *ifp = sc->sc_ifp; - /* immediate configuration */ + if (cc) { + /* copy the needed configuration */ + axe_config_copy(sc, cc, refcount); + } - struct ifnet *ifp = sc->sc_ifp; + /* immediate configuration */ - if (ifp) { - /* clear flags */ - ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | - IFF_DRV_OACTIVE); - } + if (ifp) { + /* clear flags */ + ifp->if_drv_flags &= ~(IFF_DRV_RUNNING | + IFF_DRV_OACTIVE); + } - sc->sc_flags &= ~(AXE_FLAG_HL_READY| - AXE_FLAG_LL_READY); + sc->sc_flags &= ~(AXE_FLAG_HL_READY| + AXE_FLAG_LL_READY); - sc->sc_flags |= AXE_FLAG_WAIT_LINK; + sc->sc_flags |= AXE_FLAG_WAIT_LINK; - /* stop all the transfers, - * if not already stopped: - */ - if (sc->sc_xfer[0]) { - usbd_transfer_stop(sc->sc_xfer[0]); - } - if (sc->sc_xfer[1]) { - usbd_transfer_stop(sc->sc_xfer[1]); - } - if (sc->sc_xfer[2]) { - usbd_transfer_stop(sc->sc_xfer[2]); - } - if (sc->sc_xfer[3]) { - usbd_transfer_stop(sc->sc_xfer[3]); - } - if (sc->sc_xfer[4]) { - usbd_transfer_stop(sc->sc_xfer[4]); - } - if (sc->sc_xfer[5]) { - usbd_transfer_stop(sc->sc_xfer[5]); - } - return; + /* stop all the transfers, + * if not already stopped: + */ + if (sc->sc_xfer[0]) { + usbd_transfer_stop(sc->sc_xfer[0]); + } + if (sc->sc_xfer[1]) { + usbd_transfer_stop(sc->sc_xfer[1]); + } + if (sc->sc_xfer[2]) { + usbd_transfer_stop(sc->sc_xfer[2]); + } + if (sc->sc_xfer[3]) { + usbd_transfer_stop(sc->sc_xfer[3]); + } + if (sc->sc_xfer[4]) { + usbd_transfer_stop(sc->sc_xfer[4]); + } + if (sc->sc_xfer[5]) { + usbd_transfer_stop(sc->sc_xfer[5]); } + return; +} +static void +axe_cfg_stop(struct axe_softc *sc, + struct axe_config_copy *cc, u_int16_t refcount) +{ axe_cfg_reset(sc); return; } @@ -1350,7 +1331,8 @@ mtx_lock(&(sc->sc_mtx)); usbd_config_td_queue_command - (&(sc->sc_config_td), &axe_cfg_stop, 0); + (&(sc->sc_config_td), &axe_cfg_pre_stop, + &axe_cfg_stop, 0, 0); mtx_unlock(&(sc->sc_mtx)); ==== //depot/projects/usb/src/sys/dev/usb/if_cue.c#14 (text+ko) ==== @@ -103,6 +103,15 @@ static device_detach_t cue_detach; static device_shutdown_t cue_shutdown; +static usbd_config_td_command_t cue_cfg_promisc_upd; +static usbd_config_td_command_t cue_config_copy; +static usbd_config_td_command_t cue_cfg_first_time_setup; +static usbd_config_td_command_t cue_cfg_tick; +static usbd_config_td_command_t cue_cfg_pre_init; +static usbd_config_td_command_t cue_cfg_init; +static usbd_config_td_command_t cue_cfg_pre_stop; +static usbd_config_td_command_t cue_cfg_stop; + static void cue_cfg_do_request(struct cue_softc *sc, usb_device_request_t *req, void *data); @@ -125,27 +134,15 @@ cue_mchash(const uint8_t *addr); static void -cue_cfg_promisc_upd(struct cue_softc *sc, - struct cue_config_copy *cc, u_int16_t refcount); -static void -cue_config_copy(struct cue_softc *sc, - struct cue_config_copy *cc, u_int16_t refcount); -static void cue_cfg_reset(struct cue_softc *sc); static void -cue_cfg_first_time_setup(struct cue_softc *sc, - struct cue_config_copy *cc, u_int16_t refcount); -static void cue_bulk_read_clear_stall_callback(struct usbd_xfer *xfer); static void cue_bulk_read_callback(struct usbd_xfer *xfer); static void -cue_cfg_tick(struct cue_softc *sc, - struct cue_config_copy *cc, u_int16_t refcount); -static void cue_start_cb(struct ifnet *ifp); static void @@ -160,19 +157,12 @@ static void cue_init_cb(void *arg); -static void -cue_cfg_init(struct cue_softc *sc, - struct cue_config_copy *cc, u_int16_t refcount); static int cue_ioctl_cb(struct ifnet *ifp, u_long command, caddr_t data); static void cue_watchdog(void *arg); -static void -cue_cfg_stop(struct cue_softc *sc, - struct cue_config_copy *cc, u_int16_t refcount); - #define DPRINTF(...) static const struct usbd_config cue_config[CUE_ENDPT_MAX] = { @@ -373,11 +363,6 @@ cue_cfg_promisc_upd(struct cue_softc *sc, struct cue_config_copy *cc, u_int16_t refcount) { - if (cc == NULL) { - /* nothing to do */ - return; - } - /* if we want promiscuous mode, set the allframes bit */ if (cc->if_flags & IFF_PROMISC) { @@ -525,8 +510,7 @@ } error = usbd_config_td_setup(&(sc->sc_config_td), sc, &(sc->sc_mtx), - &cue_config_copy, NULL, - sizeof(struct cue_config_copy), 16); + NULL, sizeof(struct cue_config_copy), 16); if (error) { device_printf(dev, "could not setup config " "thread!\n"); @@ -538,7 +522,7 @@ /* start setup */ usbd_config_td_queue_command - (&(sc->sc_config_td), &cue_cfg_first_time_setup, 0); + (&(sc->sc_config_td), NULL, &cue_cfg_first_time_setup, 0, 0); /* start watchdog (will exit mutex) */ @@ -558,9 +542,6 @@ u_int8_t eaddr[ETHER_ADDR_LEN]; struct ifnet * ifp; - if (cc == NULL) { - return; - } #if 0 /* Reset the adapter. */ cue_cfg_reset(sc); @@ -619,7 +600,7 @@ __callout_stop(&(sc->sc_watchdog)); - cue_cfg_stop(sc, NULL, 0); + cue_cfg_pre_stop(sc, NULL, 0); ifp = sc->sc_ifp; @@ -739,8 +720,7 @@ { struct ifnet * ifp = sc->sc_ifp; - if ((cc == NULL) || - (ifp == NULL)) { + if ((ifp == NULL)) { /* not ready */ return; } @@ -897,34 +877,37 @@ mtx_lock(&(sc->sc_mtx)); usbd_config_td_queue_command - (&(sc->sc_config_td), &cue_cfg_init, 0); + (&(sc->sc_config_td), &cue_cfg_pre_init, + &cue_cfg_init, 0, 0); mtx_unlock(&(sc->sc_mtx)); return; } static void -cue_cfg_init(struct cue_softc *sc, - struct cue_config_copy *cc, u_int16_t refcount) +cue_cfg_pre_init(struct cue_softc *sc, + struct cue_config_copy *cc, u_int16_t refcount) { - u_int8_t i; + struct ifnet *ifp = sc->sc_ifp; - if (cc == NULL) { + /* immediate configuration */ - /* immediate configuration */ + cue_cfg_pre_stop(sc, cc, 0); - struct ifnet *ifp = sc->sc_ifp; + ifp->if_drv_flags |= IFF_DRV_RUNNING; + ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; - cue_cfg_stop(sc, NULL, 0); + sc->sc_flags |= CUE_FLAG_HL_READY; - ifp->if_drv_flags |= IFF_DRV_RUNNING; - ifp->if_drv_flags &= ~IFF_DRV_OACTIVE; + return; +} - sc->sc_flags |= CUE_FLAG_HL_READY; +static void +cue_cfg_init(struct cue_softc *sc, + struct cue_config_copy *cc, u_int16_t refcount) +{ + u_int8_t i; - return; - } - /* * Cancel pending I/O and free all RX/TX buffers. */ @@ -979,15 +962,18 @@ if (ifp->if_flags & IFF_UP) { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { usbd_config_td_queue_command - (&(sc->sc_config_td), &cue_cfg_promisc_upd, 0); + (&(sc->sc_config_td), &cue_config_copy, + &cue_cfg_promisc_upd, 0, 0); } else { usbd_config_td_queue_command - (&(sc->sc_config_td), &cue_cfg_init, 0); + (&(sc->sc_config_td), &cue_cfg_pre_init, + &cue_cfg_init, 0, 0); } } else { if (ifp->if_drv_flags & IFF_DRV_RUNNING) { usbd_config_td_queue_command - (&(sc->sc_config_td), &cue_cfg_stop, 0); + (&(sc->sc_config_td), &cue_cfg_pre_stop, + &cue_cfg_stop, 0, 0); } } break; @@ -995,7 +981,8 @@ case SIOCADDMULTI: case SIOCDELMULTI: usbd_config_td_queue_command - (&(sc->sc_config_td), &cue_cfg_promisc_upd, 0); + (&(sc->sc_config_td), &cue_config_copy, + &cue_cfg_promisc_upd, 0, 0); break; default: @@ -1016,7 +1003,7 @@ mtx_assert(&(sc->sc_mtx), MA_OWNED); usbd_config_td_queue_command - (&(sc->sc_config_td), &cue_cfg_tick, 0); + (&(sc->sc_config_td), NULL, &cue_cfg_tick, 0, 0); __callout_reset(&(sc->sc_watchdog), hz, &cue_watchdog, sc); @@ -1030,42 +1017,49 @@ * RX and TX lists. */ static void -cue_cfg_stop(struct cue_softc *sc, - struct cue_config_copy *cc, u_int16_t refcount) +cue_cfg_pre_stop(struct cue_softc *sc, + struct cue_config_copy *cc, u_int16_t refcount) { - if (cc == NULL) { + struct ifnet *ifp = sc->sc_ifp; - /* immediate configuration */ + if (cc) { + /* copy the needed configuration */ + cue_config_copy(sc, cc, refcount); + } - struct ifnet *ifp = sc->sc_ifp; + /* immediate configuration */ >>> TRUNCATED FOR MAIL (1000 lines) <<<