From owner-p4-projects@FreeBSD.ORG Thu Aug 3 15:06:15 2006 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 0D33516A4E5; Thu, 3 Aug 2006 15:06:15 +0000 (UTC) X-Original-To: perforce@FreeBSD.org Delivered-To: perforce@FreeBSD.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id DD1E416A4DA for ; Thu, 3 Aug 2006 15:06:14 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7EA2F43D53 for ; Thu, 3 Aug 2006 15:06:07 +0000 (GMT) (envelope-from hselasky@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k73F67SW037270 for ; Thu, 3 Aug 2006 15:06:07 GMT (envelope-from hselasky@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k73F67eL037267 for perforce@freebsd.org; Thu, 3 Aug 2006 15:06:07 GMT (envelope-from hselasky@FreeBSD.org) Date: Thu, 3 Aug 2006 15:06:07 GMT Message-Id: <200608031506.k73F67eL037267@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 103119 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: Thu, 03 Aug 2006 15:06:15 -0000 http://perforce.freebsd.org/chv.cgi?CH=103119 Change 103119 by hselasky@hselasky_mini_itx on 2006/08/03 15:05:54 Add new function, usbd_ether_get_mbuf(). Fix formatting of comments, so that the bounding boxes have the same width. Fix compilation of usbd_m_copy_in_cb() on NetBSD. Affected files ... .. //depot/projects/usb/src/sys/dev/usb/usb_port.h#7 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.c#12 edit .. //depot/projects/usb/src/sys/dev/usb/usb_subr.h#17 edit Differences ... ==== //depot/projects/usb/src/sys/dev/usb/usb_port.h#7 (text+ko) ==== @@ -64,6 +64,8 @@ # include # include /* callout_xxx() */ +# include /* ETHER_XXX */ + # ifndef __KASSERT typedef struct cdevsw cdevsw_t; # define __lockmgr lockmgr ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.c#12 (text+ko) ==== @@ -1552,11 +1552,11 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * allocate mbufs to an usbd interface queue * * returns a pointer that eventually should be passed to "free()" - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void * usbd_alloc_mbufs(struct malloc_type *type, struct usbd_ifqueue *ifq, u_int32_t block_size, u_int16_t block_number) @@ -1600,9 +1600,9 @@ return free_ptr; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_get_page - lookup DMA-able memory for the given offset - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_get_page(struct usbd_page_cache *cache, u_int32_t offset, struct usbd_page_search *res) @@ -1652,9 +1652,9 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_copy_in - copy directly to DMA-able memory - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_copy_in(struct usbd_page_cache *cache, u_int32_t offset, const void *ptr, u_int32_t len) @@ -1683,16 +1683,20 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_m_copy_in - copy a mbuf chain directly into DMA-able memory - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ struct usbd_m_copy_in_arg { struct usbd_page_cache *cache; u_int32_t dst_offset; }; static int32_t +#ifdef __FreeBSD__ usbd_m_copy_in_cb(void *arg, void *src, u_int32_t count) +#else +usbd_m_copy_in_cb(void *arg, caddr_t src, u_int32_t count) +#endif { register struct usbd_m_copy_in_arg *ua = arg; usbd_copy_in(ua->cache, ua->dst_offset, src, count); @@ -1710,9 +1714,9 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_copy_out - copy directly from DMA-able memory - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_copy_out(struct usbd_page_cache *cache, u_int32_t offset, void *ptr, u_int32_t len) @@ -1741,9 +1745,9 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_bzero - zero DMA-able memory - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_bzero(struct usbd_page_cache *cache, u_int32_t offset, u_int32_t len) { @@ -1770,13 +1774,13 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_page_alloc - allocate multiple DMA-able memory pages * * return values: * 1: failure * 0: success - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ u_int8_t usbd_page_alloc(bus_dma_tag_t tag, struct usbd_page *page, u_int32_t npages) @@ -1815,9 +1819,9 @@ return 0; /* success */ } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_page_free - free multiple DMA-able memory pages - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_page_free(struct usbd_page *page, u_int32_t npages) { @@ -1827,9 +1831,9 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_page_get_buf - get virtual buffer - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void * usbd_page_get_buf(struct usbd_page *page, u_int32_t size) { @@ -1838,9 +1842,9 @@ return ADD_BYTES(page->buffer,size); } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_page_get_phy - get physical buffer - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ bus_size_t usbd_page_get_phy(struct usbd_page *page, u_int32_t size) { @@ -1849,9 +1853,9 @@ return (page->physaddr + size); } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_page_set_start - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_page_set_start(struct usbd_page_cache *pc, struct usbd_page *page_ptr, u_int32_t size) @@ -1861,9 +1865,9 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_page_set_end - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_page_set_end(struct usbd_page_cache *pc, struct usbd_page *page_ptr, u_int32_t size) @@ -1873,9 +1877,9 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_page_fit_obj - fit object function - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ u_int32_t usbd_page_fit_obj(struct usbd_page *page, u_int32_t size, u_int32_t obj_len) { @@ -1908,9 +1912,9 @@ return adj; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_mem_alloc - allocate DMA-able memory - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void * usbd_mem_alloc(bus_dma_tag_t parent, u_int32_t size, u_int8_t align_power) @@ -1943,9 +1947,9 @@ return ptr; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_mem_vtophys - get the physical address of DMA-able memory - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ bus_size_t usbd_mem_vtophys(void *ptr, u_int32_t size) { @@ -1958,9 +1962,9 @@ return page->physaddr; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_mem_free - free DMA-able memory - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_mem_free(void *ptr, u_int32_t size) { @@ -1981,9 +1985,9 @@ } #ifdef __FreeBSD__ -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * bus_dmamap_load_callback - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ static void bus_dmamap_load_callback(void *arg, bus_dma_segment_t *segs, int nseg, int error) @@ -1998,9 +2002,9 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_dma_tag_alloc - allocate a bus-DMA tag - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ bus_dma_tag_t usbd_dma_tag_alloc(bus_dma_tag_t parent, u_int32_t size, u_int32_t alignment) @@ -2028,9 +2032,9 @@ return tag; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_dma_tag_free - free a bus-DMA tag - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_dma_tag_free(bus_dma_tag_t tag) { @@ -2038,9 +2042,9 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_mem_alloc_sub - allocate DMA-able memory - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void * usbd_mem_alloc_sub(bus_dma_tag_t tag, struct usbd_page *page, u_int32_t size, u_int32_t alignment) @@ -2082,9 +2086,9 @@ return ptr; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_mem_free_sub - free DMA-able memory - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_mem_free_sub(struct usbd_page *page) { @@ -2215,9 +2219,9 @@ } #endif -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_std_transfer_setup - standard transfer setup - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ void usbd_std_transfer_setup(struct usbd_xfer *xfer, const struct usbd_config *setup, @@ -2272,9 +2276,9 @@ return; } -/*---------------------------------------------------------------------------* +/*------------------------------------------------------------------------------* * usbd_make_str_desc - convert an ASCII string into a UNICODE string - *---------------------------------------------------------------------------*/ + *------------------------------------------------------------------------------*/ u_int8_t usbd_make_str_desc(void *ptr, u_int16_t max_len, const char *s) { @@ -2314,9 +2318,9 @@ return totlen; } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * mtx_drop_recurse - drop mutex recurse level - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ u_int32_t mtx_drop_recurse(struct mtx *mtx) { @@ -2332,9 +2336,9 @@ return recurse_level; } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * mtx_pickup_recurse - pickup mutex recurse level - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ void mtx_pickup_recurse(struct mtx *mtx, u_int32_t recurse_level) { @@ -2347,9 +2351,9 @@ } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * usbd_config_thread - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ static void usbd_config_td_thread(void *arg) { @@ -2399,7 +2403,7 @@ return; } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * usbd_config_td_setup * * NOTE: the structure pointed to by "ctd" must be zeroed before calling @@ -2408,7 +2412,7 @@ * Return values: * 0: success * else: failure - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ u_int8_t usbd_config_td_setup(struct usbd_config_td *ctd, void *priv_sc, struct mtx *priv_mtx, @@ -2451,9 +2455,9 @@ return 1; } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * usbd_config_td_dummy_cmd - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ static void usbd_config_td_dummy_cmd(struct usbd_config_td_softc *sc, struct usbd_config_td_cc *cc, @@ -2462,12 +2466,12 @@ return; } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * usbd_config_td_stop * * NOTE: If the structure pointed to by "ctd" is all zero, * this function does nothing. - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ void usbd_config_td_stop(struct usbd_config_td *ctd) { @@ -2492,12 +2496,12 @@ return; } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * usbd_config_td_unsetup * * NOTE: If the structure pointed to by "ctd" is all zero, * this function does nothing. - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ void usbd_config_td_unsetup(struct usbd_config_td *ctd) { @@ -2513,9 +2517,9 @@ return; } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * usbd_config_td_queue_command - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ void usbd_config_td_queue_command(struct usbd_config_td *ctd, usbd_config_td_command_t *command_func, @@ -2586,11 +2590,11 @@ return; } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * usbd_config_td_check_gone * * NOTE: this function can only be called from the config thread - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ void usbd_config_td_check_gone(struct usbd_config_td *ctd) { @@ -2613,11 +2617,11 @@ return; } -/*------------------------------------------------------------------------* +/*---------------------------------------------------------------------------* * usbd_config_td_sleep * * NOTE: this function can only be called from the config thread - *------------------------------------------------------------------------*/ + *---------------------------------------------------------------------------*/ void usbd_config_td_sleep(struct usbd_config_td *ctd, u_int32_t timeout) { @@ -2638,3 +2642,19 @@ return; } + +/*---------------------------------------------------------------------------* + * usbd_ether_get_mbuf - get a new ethernet mbuf + *---------------------------------------------------------------------------*/ +struct mbuf * +usbd_ether_get_mbuf(void) +{ + register struct mbuf *m_new; + + m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); + if (m_new) { + m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; + m_adj(m_new, ETHER_ALIGN); + } + return (m_new); +} ==== //depot/projects/usb/src/sys/dev/usb/usb_subr.h#17 (text+ko) ==== @@ -775,6 +775,9 @@ void usbd_config_td_sleep(struct usbd_config_td *ctd, u_int32_t timeout); +struct mbuf * +usbd_ether_get_mbuf(void); + /* routines from usb.c */ #if 0