From owner-svn-src-head@FreeBSD.ORG Fri Feb 27 19:25:07 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 652C8106564A; Fri, 27 Feb 2009 19:25:07 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 52EEA8FC12; Fri, 27 Feb 2009 19:25:07 +0000 (UTC) (envelope-from davidch@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1RJP7Sq080661; Fri, 27 Feb 2009 19:25:07 GMT (envelope-from davidch@svn.freebsd.org) Received: (from davidch@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1RJP699080658; Fri, 27 Feb 2009 19:25:06 GMT (envelope-from davidch@svn.freebsd.org) Message-Id: <200902271925.n1RJP699080658@svn.freebsd.org> From: David Christensen Date: Fri, 27 Feb 2009 19:25:06 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189117 - head/sys/dev/bce X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Feb 2009 19:25:07 -0000 Author: davidch Date: Fri Feb 27 19:25:06 2009 New Revision: 189117 URL: http://svn.freebsd.org/changeset/base/189117 Log: - Update copyright to 2009. - Only enable split header operation when ZERO_COPY_SOCKETS is enabled in the kernel. Submitted by: davidch MFC after: 1 week Modified: head/sys/dev/bce/if_bce.c head/sys/dev/bce/if_bcefw.h head/sys/dev/bce/if_bcereg.h Modified: head/sys/dev/bce/if_bce.c ============================================================================== --- head/sys/dev/bce/if_bce.c Fri Feb 27 19:23:55 2009 (r189116) +++ head/sys/dev/bce/if_bce.c Fri Feb 27 19:25:06 2009 (r189117) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2006-2008 Broadcom Corporation + * Copyright (c) 2006-2009 Broadcom Corporation * David Christensen . All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -89,7 +89,6 @@ __FBSDID("$FreeBSD$"); /****************************************************************************/ /* BCE Build Time Options */ /****************************************************************************/ -#define BCE_USE_SPLIT_HEADER 1 /* #define BCE_NVRAM_WRITE_SUPPORT 1 */ @@ -294,12 +293,12 @@ static void bce_dump_enet (str static void bce_dump_mbuf (struct bce_softc *, struct mbuf *); static void bce_dump_tx_mbuf_chain (struct bce_softc *, u16, int); static void bce_dump_rx_mbuf_chain (struct bce_softc *, u16, int); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS static void bce_dump_pg_mbuf_chain (struct bce_softc *, u16, int); #endif static void bce_dump_txbd (struct bce_softc *, int, struct tx_bd *); static void bce_dump_rxbd (struct bce_softc *, int, struct rx_bd *); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS static void bce_dump_pgbd (struct bce_softc *, int, struct rx_bd *); #endif static void bce_dump_l2fhdr (struct bce_softc *, int, struct l2_fhdr *); @@ -307,7 +306,7 @@ static void bce_dump_ctx (struct bce_s static void bce_dump_ftqs (struct bce_softc *); static void bce_dump_tx_chain (struct bce_softc *, u16, int); static void bce_dump_rx_chain (struct bce_softc *, u16, int); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS static void bce_dump_pg_chain (struct bce_softc *, u16, int); #endif static void bce_dump_status_block (struct bce_softc *); @@ -392,7 +391,7 @@ static int bce_init_rx_chain (struct b static void bce_fill_rx_chain (struct bce_softc *); static void bce_free_rx_chain (struct bce_softc *); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS static int bce_get_pg_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *); static int bce_init_pg_chain (struct bce_softc *); static void bce_fill_pg_chain (struct bce_softc *); @@ -597,7 +596,7 @@ bce_print_adapter_info(struct bce_softc /* Firmware version and device features. */ printf("F/W (0x%08X); Flags( ", sc->bce_fw_ver); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS printf("SPLT "); #endif if (sc->bce_flags & BCE_MFW_ENABLE_FLAG) @@ -1013,7 +1012,7 @@ bce_attach(device_t dev) * This may change later if the MTU size is set to * something other than 1500. */ -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS sc->rx_bd_mbuf_alloc_size = MHLEN; /* Make sure offset is 16 byte aligned for hardware. */ sc->rx_bd_mbuf_align_pad = roundup2((MSIZE - MHLEN), 16) - @@ -2753,7 +2752,7 @@ bce_dma_free(struct bce_softc *sc) } -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /* Free, unmap and destroy all page buffer descriptor chain pages. */ for (i = 0; i < PG_PAGES; i++ ) { if (sc->pg_bd_chain[i] != NULL) { @@ -2817,7 +2816,7 @@ bce_dma_free(struct bce_softc *sc) sc->rx_mbuf_tag = NULL; } -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /* Unload and destroy the page mbuf maps. */ for (i = 0; i < TOTAL_PG_BD; i++) { if (sc->pg_mbuf_map[i] != NULL) { @@ -3267,7 +3266,7 @@ bce_dma_alloc(device_t dev) /* * Create a DMA tag for RX mbufs. */ -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS max_size = max_seg_size = ((sc->rx_bd_mbuf_alloc_size < MCLBYTES) ? MCLBYTES : sc->rx_bd_mbuf_alloc_size); #else @@ -3303,7 +3302,7 @@ bce_dma_alloc(device_t dev) } } -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /* * Create a DMA tag for the page buffer descriptor chain, * allocate and clear the memory, and fetch the physical @@ -4384,7 +4383,7 @@ bce_stop(struct bce_softc *sc) bce_disable_intr(sc); /* Free RX buffers. */ -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS bce_free_pg_chain(sc); #endif bce_free_rx_chain(sc); @@ -4822,7 +4821,7 @@ bce_get_rx_buf(struct bce_softc *sc, str goto bce_get_rx_buf_exit); /* This is a new mbuf allocation. */ -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS MGETHDR(m_new, M_DONTWAIT, MT_DATA); #else if (sc->rx_bd_mbuf_alloc_size <= MCLBYTES) @@ -4901,7 +4900,7 @@ bce_get_rx_buf_exit: } -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /****************************************************************************/ /* Encapsulate an mbuf cluster into the page chain. */ /* */ @@ -5010,7 +5009,7 @@ bce_get_pg_buf_exit: return(rc); } -#endif /* BCE_USE_SPLIT_HEADER */ +#endif /* ZERO_COPY_SOCKETS */ /****************************************************************************/ /* Initialize the TX context memory. */ @@ -5368,7 +5367,7 @@ bce_free_rx_chain(struct bce_softc *sc) } -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /****************************************************************************/ /* Allocate memory and initialize the page data structures. */ /* Assumes that bce_init_rx_chain() has not already been called. */ @@ -5534,7 +5533,7 @@ bce_free_pg_chain(struct bce_softc *sc) DBEXIT(BCE_VERBOSE_RESET | BCE_VERBOSE_RECV | BCE_VERBOSE_UNLOAD); } -#endif /* BCE_USE_SPLIT_HEADER */ +#endif /* ZERO_COPY_SOCKETS */ /****************************************************************************/ @@ -5707,7 +5706,7 @@ bce_rx_intr(struct bce_softc *sc) unsigned int pkt_len; u16 sw_rx_cons, sw_rx_cons_idx, hw_rx_cons; u32 status; -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS unsigned int rem_len; u16 sw_pg_cons, sw_pg_cons_idx; #endif @@ -5723,7 +5722,7 @@ bce_rx_intr(struct bce_softc *sc) bus_dmamap_sync(sc->rx_bd_chain_tag, sc->rx_bd_chain_map[i], BUS_DMASYNC_POSTWRITE); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /* Prepare the page chain pages to be accessed by the host CPU. */ for (int i = 0; i < PG_PAGES; i++) bus_dmamap_sync(sc->pg_bd_chain_tag, @@ -5735,7 +5734,7 @@ bce_rx_intr(struct bce_softc *sc) /* Get working copies of the driver's view of the consumer indices. */ sw_rx_cons = sc->rx_cons; -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS sw_pg_cons = sc->pg_cons; #endif @@ -5797,7 +5796,7 @@ bce_rx_intr(struct bce_softc *sc) */ m_adj(m0, sizeof(struct l2_fhdr) + ETHER_ALIGN); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /* * Check whether the received frame fits in a single * mbuf or not (i.e. packet data + FCS <= @@ -5970,7 +5969,7 @@ bce_rx_int_next_rx: if (m0) { /* Make sure we don't lose our place when we release the lock. */ sc->rx_cons = sw_rx_cons; -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS sc->pg_cons = sw_pg_cons; #endif @@ -5980,7 +5979,7 @@ bce_rx_int_next_rx: /* Recover our place. */ sw_rx_cons = sc->rx_cons; -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS sw_pg_cons = sc->pg_cons; #endif } @@ -5991,7 +5990,7 @@ bce_rx_int_next_rx: } /* No new packets to process. Refill the RX and page chains and exit. */ -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS sc->pg_cons = sw_pg_cons; bce_fill_pg_chain(sc); #endif @@ -6003,7 +6002,7 @@ bce_rx_int_next_rx: bus_dmamap_sync(sc->rx_bd_chain_tag, sc->rx_bd_chain_map[i], BUS_DMASYNC_PREWRITE); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS for (int i = 0; i < PG_PAGES; i++) bus_dmamap_sync(sc->pg_bd_chain_tag, sc->pg_bd_chain_map[i], BUS_DMASYNC_PREWRITE); @@ -6249,7 +6248,7 @@ bce_init_locked(struct bce_softc *sc) * Calculate and program the hardware Ethernet MTU * size. Be generous on the receive if we have room. */ -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS if (ifp->if_mtu <= (sc->rx_bd_mbuf_data_len + sc->pg_bd_mbuf_alloc_size)) ether_mtu = sc->rx_bd_mbuf_data_len + sc->pg_bd_mbuf_alloc_size; #else @@ -6281,7 +6280,7 @@ bce_init_locked(struct bce_softc *sc) /* Program appropriate promiscuous/multicast filtering. */ bce_set_rx_mode(sc); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /* Init page buffer descriptor chain. */ bce_init_pg_chain(sc); #endif @@ -6794,7 +6793,7 @@ bce_ioctl(struct ifnet *ifp, u_long comm BCE_LOCK(sc); ifp->if_mtu = ifr->ifr_mtu; ifp->if_drv_flags &= ~IFF_DRV_RUNNING; -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /* No buffer allocation size changes are necessary. */ #else /* Recalculate our buffer allocation sizes. */ @@ -7495,7 +7494,7 @@ bce_tick(void *xsc) bce_stats_update(sc); /* Top off the receive and page chains. */ -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS bce_fill_pg_chain(sc); #endif bce_fill_rx_chain(sc); @@ -7675,7 +7674,7 @@ bce_sysctl_dump_tx_chain(SYSCTL_HANDLER_ } -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /****************************************************************************/ /* Provides a sysctl interface to allow dumping the page chain. */ /* */ @@ -8248,7 +8247,7 @@ bce_add_sysctls(struct bce_softc *sc) (void *)sc, 0, bce_sysctl_dump_tx_chain, "I", "Dump tx_bd chain"); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS SYSCTL_ADD_PROC(ctx, children, OID_AUTO, "dump_pg_chain", CTLTYPE_INT | CTLFLAG_RW, (void *)sc, 0, @@ -8543,7 +8542,7 @@ bce_dump_rx_mbuf_chain(struct bce_softc } -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /****************************************************************************/ /* Prints out the mbufs in the mbuf page chain. */ /* */ @@ -8667,7 +8666,7 @@ bce_dump_rxbd(struct bce_softc *sc, int } -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /****************************************************************************/ /* Prints out a rx_bd structure in the page chain. */ /* */ @@ -9154,7 +9153,7 @@ bce_dump_rx_chain(struct bce_softc *sc, } -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS /****************************************************************************/ /* Prints out the page chain. */ /* */ @@ -9635,7 +9634,7 @@ bce_dump_driver_state(struct bce_softc * "0x%08X:%08X - (sc->rx_bd_chain) rx_bd chain virtual address\n", val_hi, val_lo); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS val_hi = BCE_ADDR_HI(sc->pg_bd_chain); val_lo = BCE_ADDR_LO(sc->pg_bd_chain); BCE_PRINTF( @@ -9655,7 +9654,7 @@ bce_dump_driver_state(struct bce_softc * "0x%08X:%08X - (sc->rx_mbuf_ptr) rx mbuf chain virtual address\n", val_hi, val_lo); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS val_hi = BCE_ADDR_HI(sc->pg_mbuf_ptr); val_lo = BCE_ADDR_LO(sc->pg_mbuf_ptr); BCE_PRINTF( @@ -9708,7 +9707,7 @@ bce_dump_driver_state(struct bce_softc * BCE_PRINTF(" 0x%08X - (sc->free_rx_bd) free rx_bd's\n", sc->free_rx_bd); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS BCE_PRINTF(" 0x%04X(0x%04X) - (sc->pg_prod) page producer index\n", sc->pg_prod, (u16) PG_CHAIN_IDX(sc->pg_prod)); @@ -10218,7 +10217,7 @@ bce_breakpoint(struct bce_softc *sc) bce_dump_tpat_state(sc, 0); bce_dump_cp_state(sc, 0); bce_dump_com_state(sc, 0); -#ifdef BCE_USE_SPLIT_HEADER +#ifdef ZERO_COPY_SOCKETS bce_dump_pgbd(sc, 0, NULL); bce_dump_pg_mbuf_chain(sc, 0, USABLE_PG_BD); bce_dump_pg_chain(sc, 0, USABLE_PG_BD); Modified: head/sys/dev/bce/if_bcefw.h ============================================================================== --- head/sys/dev/bce/if_bcefw.h Fri Feb 27 19:23:55 2009 (r189116) +++ head/sys/dev/bce/if_bcefw.h Fri Feb 27 19:25:06 2009 (r189117) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2006-2008 Broadcom Corporation + * Copyright (c) 2006-2009 Broadcom Corporation * David Christensen . All rights reserved. * * Redistribution and use in source and binary forms, with or without Modified: head/sys/dev/bce/if_bcereg.h ============================================================================== --- head/sys/dev/bce/if_bcereg.h Fri Feb 27 19:23:55 2009 (r189116) +++ head/sys/dev/bce/if_bcereg.h Fri Feb 27 19:25:06 2009 (r189117) @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2006-2008 Broadcom Corporation + * Copyright (c) 2006-2009 Broadcom Corporation * David Christensen . All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -6206,6 +6206,7 @@ struct l2_fhdr { #define RX_PAGE(x) (((x) & ~USABLE_RX_BD_PER_PAGE) >> (BCM_PAGE_BITS - 4)) #define RX_IDX(x) ((x) & USABLE_RX_BD_PER_PAGE) +#ifdef ZERO_COPY_SOCKETS /* * To accomodate jumbo frames, the page chain should * be 4 times larger than the receive chain. @@ -6226,6 +6227,8 @@ struct l2_fhdr { #define PG_PAGE(x) (((x) & ~USABLE_PG_BD_PER_PAGE) >> (BCM_PAGE_BITS - 4)) #define PG_IDX(x) ((x) & USABLE_PG_BD_PER_PAGE) +#endif /* ZERO_COPY_SOCKETS */ + /* Context size. */ #define CTX_SHIFT 7 #define CTX_SIZE (1 << CTX_SHIFT) @@ -6499,8 +6502,11 @@ struct bce_softc u16 tx_prod; u16 tx_cons; u32 tx_prod_bseq; /* Counts the bytes used. */ + +#ifdef ZERO_COPY_SOCKETS u16 pg_prod; u16 pg_cons; +#endif int bce_link; struct callout bce_tick_callout; @@ -6513,7 +6519,10 @@ struct bce_softc int rx_bd_mbuf_alloc_size; int rx_bd_mbuf_data_len; int rx_bd_mbuf_align_pad; + +#ifdef ZERO_COPY_SOCKETS int pg_bd_mbuf_alloc_size; +#endif /* Receive mode settings (i.e promiscuous, multicast, etc.). */ u32 rx_mode; @@ -6533,11 +6542,13 @@ struct bce_softc struct rx_bd *rx_bd_chain[RX_PAGES]; bus_addr_t rx_bd_chain_paddr[RX_PAGES]; +#ifdef ZERO_COPY_SOCKETS /* H/W maintained page buffer descriptor chain structure. */ bus_dma_tag_t pg_bd_chain_tag; bus_dmamap_t pg_bd_chain_map[PG_PAGES]; struct rx_bd *pg_bd_chain[PG_PAGES]; bus_addr_t pg_bd_chain_paddr[PG_PAGES]; +#endif /* H/W maintained status block. */ bus_dma_tag_t status_tag; @@ -6567,7 +6578,10 @@ struct bce_softc /* Bus tag for RX/TX mbufs. */ bus_dma_tag_t rx_mbuf_tag; bus_dma_tag_t tx_mbuf_tag; + +#ifdef ZERO_COPY_SOCKETS bus_dma_tag_t pg_mbuf_tag; +#endif /* S/W maintained mbuf TX chain structure. */ bus_dmamap_t tx_mbuf_map[TOTAL_TX_BD]; @@ -6577,17 +6591,22 @@ struct bce_softc bus_dmamap_t rx_mbuf_map[TOTAL_RX_BD]; struct mbuf *rx_mbuf_ptr[TOTAL_RX_BD]; +#ifdef ZERO_COPY_SOCKETS /* S/W maintained mbuf page chain structure. */ bus_dmamap_t pg_mbuf_map[TOTAL_PG_BD]; struct mbuf *pg_mbuf_ptr[TOTAL_PG_BD]; +#endif /* Track the number of buffer descriptors in use. */ u16 free_rx_bd; u16 max_rx_bd; u16 used_tx_bd; u16 max_tx_bd; + +#ifdef ZERO_COPY_SOCKETS u16 free_pg_bd; u16 max_pg_bd; +#endif /* Provides access to hardware statistics through sysctl. */ u64 stat_IfHCInOctets; @@ -6661,7 +6680,10 @@ struct bce_softc /* Track the number of enqueued mbufs. */ int debug_tx_mbuf_alloc; int debug_rx_mbuf_alloc; + +#ifdef ZERO_COPY_SOCKETS int debug_pg_mbuf_alloc; +#endif /* Track how many and what type of interrupts are generated. */ u32 interrupts_generated; @@ -6676,8 +6698,10 @@ struct bce_softc u32 rx_low_watermark; /* Lowest number of rx_bd's free. */ u32 rx_empty_count; /* Number of times the RX chain was empty. */ +#ifdef ZERO_COPY_SOCKETS u32 pg_low_watermark; /* Lowest number of pages free. */ u32 pg_empty_count; /* Number of times the page chain was empty. */ +#endif u32 tx_hi_watermark; /* Greatest number of tx_bd's used. */ u32 tx_full_count; /* Number of times the TX chain was full. */ @@ -6693,5 +6717,5 @@ struct bce_softc #endif }; -#endif /* #ifndef _BCE_H_DEFINED */ +#endif /* __BCEREG_H_DEFINED */