From owner-p4-projects@FreeBSD.ORG Sat Jun 6 05:33:12 2009 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 5C8A91065672; Sat, 6 Jun 2009 05:33:12 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DABFC106566B for ; Sat, 6 Jun 2009 05:33:11 +0000 (UTC) (envelope-from thompsa@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id C7F0A8FC0A for ; Sat, 6 Jun 2009 05:33:11 +0000 (UTC) (envelope-from thompsa@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.3/8.14.3) with ESMTP id n565XBxb044115 for ; Sat, 6 Jun 2009 05:33:11 GMT (envelope-from thompsa@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.3/8.14.3/Submit) id n565XBUm044096 for perforce@freebsd.org; Sat, 6 Jun 2009 05:33:11 GMT (envelope-from thompsa@freebsd.org) Date: Sat, 6 Jun 2009 05:33:11 GMT Message-Id: <200906060533.n565XBUm044096@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to thompsa@freebsd.org using -f From: Andrew Thompson To: Perforce Change Reviews Cc: Subject: PERFORCE change 163630 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: Sat, 06 Jun 2009 05:33:13 -0000 http://perforce.freebsd.org/chv.cgi?CH=163630 Change 163630 by thompsa@thompsa_burger on 2009/06/06 05:32:25 Transfer the data directly into the rx mbuf. Affected files ... .. //depot/projects/usb_buf/src/sys/dev/usb/usb_handle_request.c#11 edit .. //depot/projects/usb_buf/src/sys/dev/usb/usb_transfer.c#15 edit .. //depot/projects/usb_buf/src/sys/dev/usb/usbdi.h#6 edit .. //depot/projects/usb_buf/src/sys/dev/usb/wlan/if_rum.c#10 edit .. //depot/projects/usb_buf/src/sys/dev/usb/wlan/if_rumvar.h#6 edit Differences ... ==== //depot/projects/usb_buf/src/sys/dev/usb/usb_handle_request.c#11 (text+ko) ==== @@ -738,8 +738,8 @@ usb2_copy_in(urb->frbuffers + 1, 0, src_mcopy, max_len); } else { - usb2_set_frame_data(urb, - USB_ADD_BYTES(src_zcopy, off), 1); + urb_set_framedata(urb, 1, + USB_ADD_BYTES(src_zcopy, off), max_len); } urb->frlengths[1] = max_len; } else { ==== //depot/projects/usb_buf/src/sys/dev/usb/usb_transfer.c#15 (text+ko) ==== @@ -1631,6 +1631,7 @@ struct usb_pipe *pipe = urb->ub_pipe; USB_PIPE_LOCK(pipe); + urb->do_sync = 0; usb_submit_urb_flags(urb, 0); USB_PIPE_UNLOCK(pipe); } @@ -1763,21 +1764,6 @@ } /*------------------------------------------------------------------------* - * usb2_set_frame_data - * - * This function sets the pointer of the buffer that should - * loaded directly into DMA for the given USB frame. Passing "ptr" - * equal to NULL while the corresponding "frlength" is greater - * than zero gives undefined results! - *------------------------------------------------------------------------*/ -void -usb2_set_frame_data(struct usb_urb *urb, void *ptr, usb_frcount_t frindex) -{ - /* set virtual address to load and length */ - urb->frbuffers[frindex].buffer = ptr; -} - -/*------------------------------------------------------------------------* * usb2_set_frame_offset * * This function sets the frame data buffer offset relative to the beginning @@ -2765,8 +2751,6 @@ struct usb_pipe *pipe = urb->ub_pipe; urb->frlengths[0] = pipe->max_data_length; - urb->do_sync = 0; - urb->is_done = 0; } struct usb_urb * @@ -2847,6 +2831,23 @@ *err = urb->error; } +/*------------------------------------------------------------------------* + * usb_set_frame_data + * + * This function sets the pointer of the buffer that should + * loaded directly into DMA for the given USB frame. Passing "ptr" + * equal to NULL while the corresponding "frlength" is greater + * than zero gives undefined results! + *------------------------------------------------------------------------*/ +void +urb_set_framedata(struct usb_urb *urb, usb_frcount_t frame, void *ptr, + usb_frlength_t len) +{ + /* set virtual address to load and length */ + urb->frbuffers[frame].buffer = ptr; + urb_set_framelen(urb, frame, len); +} + void urb_set_framelen(struct usb_urb *urb, usb_frcount_t frame, usb_frlength_t len) { ==== //depot/projects/usb_buf/src/sys/dev/usb/usbdi.h#6 (text+ko) ==== @@ -306,6 +306,8 @@ void *urb_get_softc(struct usb_urb *urb); void *urb_get_priv(struct usb_urb *urb); void urb_set_priv(struct usb_urb *urb, void *); +void urb_set_framedata(struct usb_urb *urb, usb_frcount_t frame, void *ptr, + usb_frlength_t len); void urb_set_framelen(struct usb_urb *urb, usb_frcount_t frame, usb_frlength_t len); ==== //depot/projects/usb_buf/src/sys/dev/usb/wlan/if_rum.c#10 (text+ko) ==== @@ -155,8 +155,8 @@ const uint8_t mac[IEEE80211_ADDR_LEN]); static void rum_vap_delete(struct ieee80211vap *); static void rum_tx_free(struct rum_tx_data *, int); -static void rum_setup_tx_list(struct rum_softc *); -static void rum_unsetup_tx_list(struct rum_softc *); +static void rum_alloc_tx_list(struct rum_softc *); +static void rum_free_tx_list(struct rum_softc *); static int rum_newstate(struct ieee80211vap *, enum ieee80211_state, int); static void rum_setup_tx_desc(struct rum_softc *, @@ -398,7 +398,7 @@ .direction = UE_DIR_IN, .bufsize = (MCLBYTES + RT2573_RX_DESC_SIZE), .urb_count = RUM_RX_LIST_COUNT, - .flags = {.pipe_bof = 1,.short_xfer_ok = 1,}, + .flags = {.ext_buffer = 1,.pipe_bof = 1,.short_xfer_ok = 1,}, .callback = rum_bulk_read_callback, }, }; @@ -552,7 +552,7 @@ /* free TX list, if any */ RUM_LOCK(sc); - rum_unsetup_tx_list(sc); + rum_free_tx_list(sc); RUM_UNLOCK(sc); if (ifp) { @@ -657,7 +657,7 @@ } static void -rum_setup_tx_list(struct rum_softc *sc) +rum_alloc_tx_list(struct rum_softc *sc) { struct rum_tx_data *data; int i; @@ -672,12 +672,11 @@ KASSERT(data->urb != NULL, ("usb_get_urb failed")); urb_set_priv(data->urb, data); urb_list_insert(&sc->tx_free, data->urb); - sc->tx_nfree++; } } static void -rum_unsetup_tx_list(struct rum_softc *sc) +rum_free_tx_list(struct rum_softc *sc) { struct rum_tx_data *data; int i; @@ -802,7 +801,7 @@ struct ifnet *ifp = sc->sc_ifp; struct ieee80211com *ic = ifp->if_l2com; struct ieee80211_node *ni; - struct mbuf *m = NULL; + struct mbuf *m, *mnew; struct rum_rx_desc *desc; uint32_t flags; uint8_t rssi = 0; @@ -816,6 +815,7 @@ goto skip; } + m = urb_get_priv(urb); urb_get_status(urb, (void **)&desc, NULL, &actlen, NULL); DPRINTFN(5, "rx done, urb=%p actlen=%d\n", urb, actlen); @@ -826,8 +826,6 @@ goto skip; } - actlen -= RT2573_RX_DESC_SIZE; - rssi = rum_get_rssi(sc, desc->rssi); flags = le32toh(desc->flags); if (flags & RT2573_RX_CRC_ERROR) { @@ -841,16 +839,20 @@ goto skip; } - m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); - if (m == NULL) { + mnew = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (mnew == NULL) { DPRINTF("could not allocate mbuf\n"); ifp->if_ierrors++; goto skip; } + /* load up new mbuf in hardware */ + urb_set_framedata(urb, 0, mtod(mnew, uint8_t *), MCLBYTES); + urb_set_priv(urb, mnew); + /* finalize mbuf */ m->m_pkthdr.rcvif = ifp; - bcopy((caddr_t)(desc + 1), mtod(m, uint8_t *), actlen); + m->m_data = (caddr_t)(desc + 1); m->m_pkthdr.len = m->m_len = (flags >> 16) & 0xfff; if (ieee80211_radiotap_active(ic)) { @@ -872,7 +874,6 @@ } else (void) ieee80211_input_all(ic, m, rssi, RT2573_NOISE_FLOOR); skip: - usb_init_urb(urb); usb_submit_urb(urb); } @@ -1977,6 +1978,7 @@ struct ifnet *ifp = sc->sc_ifp; struct ieee80211com *ic = ifp->if_l2com; struct usb_urb *urb; + struct mbuf *m; uint32_t tmp; usb_error_t error; int i, ntries; @@ -2026,7 +2028,7 @@ /* * Allocate Tx and Rx xfer queues. */ - rum_setup_tx_list(sc); + rum_alloc_tx_list(sc); /* update Rx filter */ tmp = rum_read(sc, RT2573_TXRX_CSR0) & 0xffff; @@ -2045,7 +2047,16 @@ /* * Start up the receive pipe. */ - while ((urb = usb_get_urb(sc->sc_xfer[RUM_BULK_RD], 0)) != NULL) { + for (i = 0; i < RUM_RX_LIST_COUNT; i++) { + urb = usb_get_urb(sc->sc_xfer[RUM_BULK_RD], 0); + m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m == NULL) { + device_printf(sc->sc_dev, + "could not allocate rx mbuf\n"); + goto fail; + } + urb_set_framedata(urb, 0, mtod(m, uint8_t *), MCLBYTES); + urb_set_priv(urb, m); usb_submit_urb(urb); } @@ -2090,7 +2101,7 @@ usb_pipe_halt(sc->sc_xfer[RUM_BULK_WR]); usb_pipe_halt(sc->sc_xfer[RUM_BULK_RD]); - rum_unsetup_tx_list(sc); + rum_free_tx_list(sc); /* disable Rx */ tmp = rum_read(sc, RT2573_TXRX_CSR0); ==== //depot/projects/usb_buf/src/sys/dev/usb/wlan/if_rumvar.h#6 (text+ko) ==== @@ -105,9 +105,6 @@ struct rum_tx_data tx_data[RUM_TX_LIST_COUNT]; usb_urb_list tx_free; - usb_urb_list rx_free; - int tx_nfree; - struct rum_rx_desc sc_rx_desc; struct mtx sc_mtx;