if_bce.c (179436) | if_bce.c (179695) |
---|---|
1/*- 2 * Copyright (c) 2006-2008 Broadcom Corporation 3 * David Christensen <davidch@broadcom.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 15 unchanged lines hidden (view full) --- 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2006-2008 Broadcom Corporation 3 * David Christensen <davidch@broadcom.com>. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * --- 15 unchanged lines hidden (view full) --- 24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 28 * THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31#include <sys/cdefs.h> |
32__FBSDID("$FreeBSD: head/sys/dev/bce/if_bce.c 179436 2008-05-30 18:26:37Z jhb $"); | 32__FBSDID("$FreeBSD: head/sys/dev/bce/if_bce.c 179695 2008-06-10 02:19:11Z davidch $"); |
33 34/* 35 * The following controllers are supported by this driver: 36 * BCM5706C A2, A3 37 * BCM5706S A2, A3 38 * BCM5708C B1, B2 39 * BCM5708S B1, B2 40 * --- 36 unchanged lines hidden (view full) --- 77 78 /* Controls how often to simulate a DMA mapping failure. */ 79 int bce_debug_dma_map_addr_failure = 0; 80 81 /* Controls how often to simulate a bootcode failure. */ 82 int bce_debug_bootcode_running_failure = 0; 83#endif 84 | 33 34/* 35 * The following controllers are supported by this driver: 36 * BCM5706C A2, A3 37 * BCM5706S A2, A3 38 * BCM5708C B1, B2 39 * BCM5708S B1, B2 40 * --- 36 unchanged lines hidden (view full) --- 77 78 /* Controls how often to simulate a DMA mapping failure. */ 79 int bce_debug_dma_map_addr_failure = 0; 80 81 /* Controls how often to simulate a bootcode failure. */ 82 int bce_debug_bootcode_running_failure = 0; 83#endif 84 |
85/****************************************************************************/ 86/* BCE Build Time Options */ 87/****************************************************************************/ 88#define BCE_USE_SPLIT_HEADER 1 89/* #define BCE_NVRAM_WRITE_SUPPORT 1 */ |
|
85 86/****************************************************************************/ 87/* PCI Device ID Table */ 88/* */ 89/* Used by bce_probe() to identify the devices supported by this driver. */ 90/****************************************************************************/ 91#define BCE_DEVDESC_MAX 64 92 --- 126 unchanged lines hidden (view full) --- 219/****************************************************************************/ 220/* BCE Debug Data Structure Dump Routines */ 221/****************************************************************************/ 222#ifdef BCE_DEBUG 223static u32 bce_ctx_rd (struct bce_softc *, u32, u32); 224static void bce_dump_mbuf (struct bce_softc *, struct mbuf *); 225static void bce_dump_tx_mbuf_chain (struct bce_softc *, u16, int); 226static void bce_dump_rx_mbuf_chain (struct bce_softc *, u16, int); | 90 91/****************************************************************************/ 92/* PCI Device ID Table */ 93/* */ 94/* Used by bce_probe() to identify the devices supported by this driver. */ 95/****************************************************************************/ 96#define BCE_DEVDESC_MAX 64 97 --- 126 unchanged lines hidden (view full) --- 224/****************************************************************************/ 225/* BCE Debug Data Structure Dump Routines */ 226/****************************************************************************/ 227#ifdef BCE_DEBUG 228static u32 bce_ctx_rd (struct bce_softc *, u32, u32); 229static void bce_dump_mbuf (struct bce_softc *, struct mbuf *); 230static void bce_dump_tx_mbuf_chain (struct bce_softc *, u16, int); 231static void bce_dump_rx_mbuf_chain (struct bce_softc *, u16, int); |
232#ifdef BCE_USE_SPLIT_HEADER |
|
227static void bce_dump_pg_mbuf_chain (struct bce_softc *, u16, int); | 233static void bce_dump_pg_mbuf_chain (struct bce_softc *, u16, int); |
234#endif |
|
228static void bce_dump_txbd (struct bce_softc *, int, struct tx_bd *); 229static void bce_dump_rxbd (struct bce_softc *, int, struct rx_bd *); | 235static void bce_dump_txbd (struct bce_softc *, int, struct tx_bd *); 236static void bce_dump_rxbd (struct bce_softc *, int, struct rx_bd *); |
237#ifdef BCE_USE_SPLIT_HEADER |
|
230static void bce_dump_pgbd (struct bce_softc *, int, struct rx_bd *); | 238static void bce_dump_pgbd (struct bce_softc *, int, struct rx_bd *); |
239#endif |
|
231static void bce_dump_l2fhdr (struct bce_softc *, int, struct l2_fhdr *); 232static void bce_dump_ctx (struct bce_softc *, u16); 233static void bce_dump_ftqs (struct bce_softc *); 234static void bce_dump_tx_chain (struct bce_softc *, u16, int); 235static void bce_dump_rx_chain (struct bce_softc *, u16, int); | 240static void bce_dump_l2fhdr (struct bce_softc *, int, struct l2_fhdr *); 241static void bce_dump_ctx (struct bce_softc *, u16); 242static void bce_dump_ftqs (struct bce_softc *); 243static void bce_dump_tx_chain (struct bce_softc *, u16, int); 244static void bce_dump_rx_chain (struct bce_softc *, u16, int); |
245#ifdef BCE_USE_SPLIT_HEADER |
|
236static void bce_dump_pg_chain (struct bce_softc *, u16, int); | 246static void bce_dump_pg_chain (struct bce_softc *, u16, int); |
247#endif |
|
237static void bce_dump_status_block (struct bce_softc *); 238static void bce_dump_stats_block (struct bce_softc *); 239static void bce_dump_driver_state (struct bce_softc *); 240static void bce_dump_hw_state (struct bce_softc *); 241static void bce_dump_bc_state (struct bce_softc *); 242static void bce_breakpoint (struct bce_softc *); 243#endif 244 --- 44 unchanged lines hidden (view full) --- 289static void bce_load_cpu_fw (struct bce_softc *, struct cpu_reg *, struct fw_info *); 290static void bce_init_cpus (struct bce_softc *); 291 292static void bce_stop (struct bce_softc *); 293static int bce_reset (struct bce_softc *, u32); 294static int bce_chipinit (struct bce_softc *); 295static int bce_blockinit (struct bce_softc *); 296static int bce_get_rx_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *, u32 *); | 248static void bce_dump_status_block (struct bce_softc *); 249static void bce_dump_stats_block (struct bce_softc *); 250static void bce_dump_driver_state (struct bce_softc *); 251static void bce_dump_hw_state (struct bce_softc *); 252static void bce_dump_bc_state (struct bce_softc *); 253static void bce_breakpoint (struct bce_softc *); 254#endif 255 --- 44 unchanged lines hidden (view full) --- 300static void bce_load_cpu_fw (struct bce_softc *, struct cpu_reg *, struct fw_info *); 301static void bce_init_cpus (struct bce_softc *); 302 303static void bce_stop (struct bce_softc *); 304static int bce_reset (struct bce_softc *, u32); 305static int bce_chipinit (struct bce_softc *); 306static int bce_blockinit (struct bce_softc *); 307static int bce_get_rx_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *, u32 *); |
308#ifdef BCE_USE_SPLIT_HEADER |
|
297static int bce_get_pg_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *); | 309static int bce_get_pg_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *); |
310#endif |
|
298 299static int bce_init_tx_chain (struct bce_softc *); 300static void bce_free_tx_chain (struct bce_softc *); 301 302static int bce_init_rx_chain (struct bce_softc *); 303static void bce_fill_rx_chain (struct bce_softc *); 304static void bce_free_rx_chain (struct bce_softc *); 305 | 311 312static int bce_init_tx_chain (struct bce_softc *); 313static void bce_free_tx_chain (struct bce_softc *); 314 315static int bce_init_rx_chain (struct bce_softc *); 316static void bce_fill_rx_chain (struct bce_softc *); 317static void bce_free_rx_chain (struct bce_softc *); 318 |
319#ifdef BCE_USE_SPLIT_HEADER |
|
306static int bce_init_pg_chain (struct bce_softc *); 307static void bce_fill_pg_chain (struct bce_softc *); 308static void bce_free_pg_chain (struct bce_softc *); | 320static int bce_init_pg_chain (struct bce_softc *); 321static void bce_fill_pg_chain (struct bce_softc *); 322static void bce_free_pg_chain (struct bce_softc *); |
323#endif |
|
309 310static int bce_tx_encap (struct bce_softc *, struct mbuf **); 311static void bce_start_locked (struct ifnet *); 312static void bce_start (struct ifnet *); 313static int bce_ioctl (struct ifnet *, u_long, caddr_t); 314static void bce_watchdog (struct bce_softc *); 315static int bce_ifmedia_upd (struct ifnet *); 316static void bce_ifmedia_upd_locked (struct ifnet *); --- 456 unchanged lines hidden (view full) --- 773 ifp->if_capabilities = BCE_IF_CAPABILITIES; 774 } 775 776 ifp->if_capenable = ifp->if_capabilities; 777 778 /* Use standard mbuf sizes for buffer allocation. */ 779#ifdef BCE_USE_SPLIT_HEADER 780 sc->rx_bd_mbuf_alloc_size = MHLEN; | 324 325static int bce_tx_encap (struct bce_softc *, struct mbuf **); 326static void bce_start_locked (struct ifnet *); 327static void bce_start (struct ifnet *); 328static int bce_ioctl (struct ifnet *, u_long, caddr_t); 329static void bce_watchdog (struct bce_softc *); 330static int bce_ifmedia_upd (struct ifnet *); 331static void bce_ifmedia_upd_locked (struct ifnet *); --- 456 unchanged lines hidden (view full) --- 788 ifp->if_capabilities = BCE_IF_CAPABILITIES; 789 } 790 791 ifp->if_capenable = ifp->if_capabilities; 792 793 /* Use standard mbuf sizes for buffer allocation. */ 794#ifdef BCE_USE_SPLIT_HEADER 795 sc->rx_bd_mbuf_alloc_size = MHLEN; |
796 /* Make sure offset is 16 byte aligned for hardware. */ 797 sc->rx_bd_mbuf_align_pad = roundup2((MSIZE - MHLEN), 16) - 798 (MSIZE - MHLEN); 799 sc->rx_bd_mbuf_data_len = sc->rx_bd_mbuf_alloc_size - 800 sc->rx_bd_mbuf_align_pad; 801 sc->pg_bd_mbuf_alloc_size = MCLBYTES; |
|
781#else 782 sc->rx_bd_mbuf_alloc_size = MCLBYTES; | 802#else 803 sc->rx_bd_mbuf_alloc_size = MCLBYTES; |
804 sc->rx_bd_mbuf_align_pad = roundup2(MCLBYTES, 16) - MCLBYTES; 805 sc->rx_bd_mbuf_data_len = sc->rx_bd_mbuf_alloc_size - 806 sc->rx_bd_mbuf_align_pad; |
|
783#endif | 807#endif |
784 sc->pg_bd_mbuf_alloc_size = MCLBYTES; | |
785 786 ifp->if_snd.ifq_drv_maxlen = USABLE_TX_BD; 787 IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); 788 IFQ_SET_READY(&ifp->if_snd); 789 790 if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) 791 ifp->if_baudrate = IF_Mbps(2500ULL); 792 else --- 58 unchanged lines hidden (view full) --- 851 BCE_PRINTF("ASIC (0x%08X); ", sc->bce_chipid); 852 printf("Rev (%c%d); ", ((BCE_CHIP_ID(sc) & 0xf000) >> 12) + 'A', 853 ((BCE_CHIP_ID(sc) & 0x0ff0) >> 4)); 854 printf("Bus (PCI%s, %s, %dMHz); ", 855 ((sc->bce_flags & BCE_PCIX_FLAG) ? "-X" : ""), 856 ((sc->bce_flags & BCE_PCI_32BIT_FLAG) ? "32-bit" : "64-bit"), 857 sc->bus_speed_mhz); 858 printf("F/W (0x%08X); Flags( ", sc->bce_fw_ver); | 808 809 ifp->if_snd.ifq_drv_maxlen = USABLE_TX_BD; 810 IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen); 811 IFQ_SET_READY(&ifp->if_snd); 812 813 if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) 814 ifp->if_baudrate = IF_Mbps(2500ULL); 815 else --- 58 unchanged lines hidden (view full) --- 874 BCE_PRINTF("ASIC (0x%08X); ", sc->bce_chipid); 875 printf("Rev (%c%d); ", ((BCE_CHIP_ID(sc) & 0xf000) >> 12) + 'A', 876 ((BCE_CHIP_ID(sc) & 0x0ff0) >> 4)); 877 printf("Bus (PCI%s, %s, %dMHz); ", 878 ((sc->bce_flags & BCE_PCIX_FLAG) ? "-X" : ""), 879 ((sc->bce_flags & BCE_PCI_32BIT_FLAG) ? "32-bit" : "64-bit"), 880 sc->bus_speed_mhz); 881 printf("F/W (0x%08X); Flags( ", sc->bce_fw_ver); |
882#ifdef BCE_USE_SPLIT_HEADER 883 printf("SPLT "); 884#endif |
|
859 if (sc->bce_flags & BCE_MFW_ENABLE_FLAG) 860 printf("MFW "); 861 if (sc->bce_flags & BCE_USING_MSI_FLAG) 862 printf("MSI "); 863 if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) 864 printf("2.5G "); 865 printf(")\n"); 866 --- 1374 unchanged lines hidden (view full) --- 2241 2242 /* Destroy the RX buffer descriptor tag. */ 2243 if (sc->rx_bd_chain_tag != NULL) { 2244 bus_dma_tag_destroy(sc->rx_bd_chain_tag); 2245 sc->rx_bd_chain_tag = NULL; 2246 } 2247 2248 | 885 if (sc->bce_flags & BCE_MFW_ENABLE_FLAG) 886 printf("MFW "); 887 if (sc->bce_flags & BCE_USING_MSI_FLAG) 888 printf("MSI "); 889 if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) 890 printf("2.5G "); 891 printf(")\n"); 892 --- 1374 unchanged lines hidden (view full) --- 2267 2268 /* Destroy the RX buffer descriptor tag. */ 2269 if (sc->rx_bd_chain_tag != NULL) { 2270 bus_dma_tag_destroy(sc->rx_bd_chain_tag); 2271 sc->rx_bd_chain_tag = NULL; 2272 } 2273 2274 |
2275#ifdef BCE_USE_SPLIT_HEADER |
|
2249 /* Free, unmap and destroy all page buffer descriptor chain pages. */ 2250 for (i = 0; i < PG_PAGES; i++ ) { 2251 if (sc->pg_bd_chain[i] != NULL) { 2252 bus_dmamem_free( 2253 sc->pg_bd_chain_tag, 2254 sc->pg_bd_chain[i], 2255 sc->pg_bd_chain_map[i]); 2256 sc->pg_bd_chain[i] = NULL; --- 10 unchanged lines hidden (view full) --- 2267 } 2268 } 2269 2270 /* Destroy the page buffer descriptor tag. */ 2271 if (sc->pg_bd_chain_tag != NULL) { 2272 bus_dma_tag_destroy(sc->pg_bd_chain_tag); 2273 sc->pg_bd_chain_tag = NULL; 2274 } | 2276 /* Free, unmap and destroy all page buffer descriptor chain pages. */ 2277 for (i = 0; i < PG_PAGES; i++ ) { 2278 if (sc->pg_bd_chain[i] != NULL) { 2279 bus_dmamem_free( 2280 sc->pg_bd_chain_tag, 2281 sc->pg_bd_chain[i], 2282 sc->pg_bd_chain_map[i]); 2283 sc->pg_bd_chain[i] = NULL; --- 10 unchanged lines hidden (view full) --- 2294 } 2295 } 2296 2297 /* Destroy the page buffer descriptor tag. */ 2298 if (sc->pg_bd_chain_tag != NULL) { 2299 bus_dma_tag_destroy(sc->pg_bd_chain_tag); 2300 sc->pg_bd_chain_tag = NULL; 2301 } |
2302#endif |
|
2275 2276 2277 /* Unload and destroy the TX mbuf maps. */ 2278 for (i = 0; i < TOTAL_TX_BD; i++) { 2279 if (sc->tx_mbuf_map[i] != NULL) { 2280 bus_dmamap_unload(sc->tx_mbuf_tag, 2281 sc->tx_mbuf_map[i]); 2282 bus_dmamap_destroy(sc->tx_mbuf_tag, --- 20 unchanged lines hidden (view full) --- 2303 } 2304 2305 /* Destroy the RX mbuf tag. */ 2306 if (sc->rx_mbuf_tag != NULL) { 2307 bus_dma_tag_destroy(sc->rx_mbuf_tag); 2308 sc->rx_mbuf_tag = NULL; 2309 } 2310 | 2303 2304 2305 /* Unload and destroy the TX mbuf maps. */ 2306 for (i = 0; i < TOTAL_TX_BD; i++) { 2307 if (sc->tx_mbuf_map[i] != NULL) { 2308 bus_dmamap_unload(sc->tx_mbuf_tag, 2309 sc->tx_mbuf_map[i]); 2310 bus_dmamap_destroy(sc->tx_mbuf_tag, --- 20 unchanged lines hidden (view full) --- 2331 } 2332 2333 /* Destroy the RX mbuf tag. */ 2334 if (sc->rx_mbuf_tag != NULL) { 2335 bus_dma_tag_destroy(sc->rx_mbuf_tag); 2336 sc->rx_mbuf_tag = NULL; 2337 } 2338 |
2339#ifdef BCE_USE_SPLIT_HEADER |
|
2311 /* Unload and destroy the page mbuf maps. */ 2312 for (i = 0; i < TOTAL_PG_BD; i++) { 2313 if (sc->pg_mbuf_map[i] != NULL) { 2314 bus_dmamap_unload(sc->pg_mbuf_tag, 2315 sc->pg_mbuf_map[i]); 2316 bus_dmamap_destroy(sc->pg_mbuf_tag, 2317 sc->pg_mbuf_map[i]); 2318 sc->pg_mbuf_map[i] = NULL; 2319 } 2320 } 2321 2322 /* Destroy the page mbuf tag. */ 2323 if (sc->pg_mbuf_tag != NULL) { 2324 bus_dma_tag_destroy(sc->pg_mbuf_tag); 2325 sc->pg_mbuf_tag = NULL; 2326 } | 2340 /* Unload and destroy the page mbuf maps. */ 2341 for (i = 0; i < TOTAL_PG_BD; i++) { 2342 if (sc->pg_mbuf_map[i] != NULL) { 2343 bus_dmamap_unload(sc->pg_mbuf_tag, 2344 sc->pg_mbuf_map[i]); 2345 bus_dmamap_destroy(sc->pg_mbuf_tag, 2346 sc->pg_mbuf_map[i]); 2347 sc->pg_mbuf_map[i] = NULL; 2348 } 2349 } 2350 2351 /* Destroy the page mbuf tag. */ 2352 if (sc->pg_mbuf_tag != NULL) { 2353 bus_dma_tag_destroy(sc->pg_mbuf_tag); 2354 sc->pg_mbuf_tag = NULL; 2355 } |
2356#endif |
|
2327 2328 /* Destroy the parent tag */ 2329 if (sc->parent_tag != NULL) { 2330 bus_dma_tag_destroy(sc->parent_tag); 2331 sc->parent_tag = NULL; 2332 } 2333 2334 DBPRINT(sc, BCE_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); --- 38 unchanged lines hidden (view full) --- 2373 2374 2375/****************************************************************************/ 2376/* Allocate any DMA memory needed by the driver. */ 2377/* */ 2378/* Allocates DMA memory needed for the various global structures needed by */ 2379/* hardware. */ 2380/* */ | 2357 2358 /* Destroy the parent tag */ 2359 if (sc->parent_tag != NULL) { 2360 bus_dma_tag_destroy(sc->parent_tag); 2361 sc->parent_tag = NULL; 2362 } 2363 2364 DBPRINT(sc, BCE_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); --- 38 unchanged lines hidden (view full) --- 2403 2404 2405/****************************************************************************/ 2406/* Allocate any DMA memory needed by the driver. */ 2407/* */ 2408/* Allocates DMA memory needed for the various global structures needed by */ 2409/* hardware. */ 2410/* */ |
2411/* Memory alignment requirements: */ 2412/* -----------------+----------+----------+ */ 2413/* Data Structure | 5706 | 5708 | */ 2414/* -----------------+----------+----------+ */ 2415/* Status Block | 8 bytes | 8 bytes | */ 2416/* Statistics Block | 8 bytes | 8 bytes | */ 2417/* RX Buffers | 16 bytes | 16 bytes | */ 2418/* PG Buffers | none | none | */ 2419/* TX Buffers | none | none | */ 2420/* Chain Pages(1) | 4KiB | 4KiB | */ 2421/* -----------------+----------+----------+ */ 2422/* */ 2423/* (1) Must align with CPU page size (BCM_PAGE_SZIE). */ 2424/* */ |
|
2381/* Returns: */ 2382/* 0 for success, positive value for failure. */ 2383/****************************************************************************/ 2384static int 2385bce_dma_alloc(device_t dev) 2386{ 2387 struct bce_softc *sc; 2388 int i, error, rc = 0; --- 289 unchanged lines hidden (view full) --- 2678 /* DRC - Fix for 64 bit systems. */ 2679 DBPRINT(sc, BCE_INFO, "rx_bd_chain_paddr[%d] = 0x%08X\n", 2680 i, (u32) sc->rx_bd_chain_paddr[i]); 2681 } 2682 2683 /* 2684 * Create a DMA tag for RX mbufs. 2685 */ | 2425/* Returns: */ 2426/* 0 for success, positive value for failure. */ 2427/****************************************************************************/ 2428static int 2429bce_dma_alloc(device_t dev) 2430{ 2431 struct bce_softc *sc; 2432 int i, error, rc = 0; --- 289 unchanged lines hidden (view full) --- 2722 /* DRC - Fix for 64 bit systems. */ 2723 DBPRINT(sc, BCE_INFO, "rx_bd_chain_paddr[%d] = 0x%08X\n", 2724 i, (u32) sc->rx_bd_chain_paddr[i]); 2725 } 2726 2727 /* 2728 * Create a DMA tag for RX mbufs. 2729 */ |
2730#ifdef BCE_USE_SPLIT_HEADER |
|
2686 max_size = max_seg_size = ((sc->rx_bd_mbuf_alloc_size < MCLBYTES) ? 2687 MCLBYTES : sc->rx_bd_mbuf_alloc_size); | 2731 max_size = max_seg_size = ((sc->rx_bd_mbuf_alloc_size < MCLBYTES) ? 2732 MCLBYTES : sc->rx_bd_mbuf_alloc_size); |
2733#else 2734 max_size = max_seg_size = MJUM9BYTES; 2735#endif |
|
2688 2689 if (bus_dma_tag_create(sc->parent_tag, 2690 1, 2691 BCE_DMA_BOUNDARY, 2692 sc->max_bus_addr, 2693 BUS_SPACE_MAXADDR, 2694 NULL, NULL, 2695 max_size, --- 14 unchanged lines hidden (view full) --- 2710 &sc->rx_mbuf_map[i])) { 2711 BCE_PRINTF("%s(%d): Unable to create RX mbuf DMA map!\n", 2712 __FILE__, __LINE__); 2713 rc = ENOMEM; 2714 goto bce_dma_alloc_exit; 2715 } 2716 } 2717 | 2736 2737 if (bus_dma_tag_create(sc->parent_tag, 2738 1, 2739 BCE_DMA_BOUNDARY, 2740 sc->max_bus_addr, 2741 BUS_SPACE_MAXADDR, 2742 NULL, NULL, 2743 max_size, --- 14 unchanged lines hidden (view full) --- 2758 &sc->rx_mbuf_map[i])) { 2759 BCE_PRINTF("%s(%d): Unable to create RX mbuf DMA map!\n", 2760 __FILE__, __LINE__); 2761 rc = ENOMEM; 2762 goto bce_dma_alloc_exit; 2763 } 2764 } 2765 |
2766#ifdef BCE_USE_SPLIT_HEADER |
|
2718 /* 2719 * Create a DMA tag for the page buffer descriptor chain, 2720 * allocate and clear the memory, and fetch the physical 2721 * address of the blocks. 2722 */ 2723 if (bus_dma_tag_create(sc->parent_tag, 2724 BCM_PAGE_SIZE, 2725 BCE_DMA_BOUNDARY, --- 46 unchanged lines hidden (view full) --- 2772 DBPRINT(sc, BCE_INFO, "pg_bd_chain_paddr[%d] = 0x%08X\n", 2773 i, (u32) sc->pg_bd_chain_paddr[i]); 2774 } 2775 2776 /* 2777 * Create a DMA tag for page mbufs. 2778 */ 2779 max_size = max_seg_size = ((sc->pg_bd_mbuf_alloc_size < MCLBYTES) ? | 2767 /* 2768 * Create a DMA tag for the page buffer descriptor chain, 2769 * allocate and clear the memory, and fetch the physical 2770 * address of the blocks. 2771 */ 2772 if (bus_dma_tag_create(sc->parent_tag, 2773 BCM_PAGE_SIZE, 2774 BCE_DMA_BOUNDARY, --- 46 unchanged lines hidden (view full) --- 2821 DBPRINT(sc, BCE_INFO, "pg_bd_chain_paddr[%d] = 0x%08X\n", 2822 i, (u32) sc->pg_bd_chain_paddr[i]); 2823 } 2824 2825 /* 2826 * Create a DMA tag for page mbufs. 2827 */ 2828 max_size = max_seg_size = ((sc->pg_bd_mbuf_alloc_size < MCLBYTES) ? |
2780 MCLBYTES : sc->rx_bd_mbuf_alloc_size); | 2829 MCLBYTES : sc->pg_bd_mbuf_alloc_size); |
2781 2782 if (bus_dma_tag_create(sc->parent_tag, 2783 1, 2784 BCE_DMA_BOUNDARY, 2785 sc->max_bus_addr, 2786 BUS_SPACE_MAXADDR, 2787 NULL, NULL, 2788 max_size, --- 13 unchanged lines hidden (view full) --- 2802 if (bus_dmamap_create(sc->pg_mbuf_tag, BUS_DMA_NOWAIT, 2803 &sc->pg_mbuf_map[i])) { 2804 BCE_PRINTF("%s(%d): Unable to create page mbuf DMA map!\n", 2805 __FILE__, __LINE__); 2806 rc = ENOMEM; 2807 goto bce_dma_alloc_exit; 2808 } 2809 } | 2830 2831 if (bus_dma_tag_create(sc->parent_tag, 2832 1, 2833 BCE_DMA_BOUNDARY, 2834 sc->max_bus_addr, 2835 BUS_SPACE_MAXADDR, 2836 NULL, NULL, 2837 max_size, --- 13 unchanged lines hidden (view full) --- 2851 if (bus_dmamap_create(sc->pg_mbuf_tag, BUS_DMA_NOWAIT, 2852 &sc->pg_mbuf_map[i])) { 2853 BCE_PRINTF("%s(%d): Unable to create page mbuf DMA map!\n", 2854 __FILE__, __LINE__); 2855 rc = ENOMEM; 2856 goto bce_dma_alloc_exit; 2857 } 2858 } |
2859#endif |
|
2810 2811bce_dma_alloc_exit: 2812 DBPRINT(sc, BCE_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); 2813 2814 return(rc); 2815} 2816 2817 --- 626 unchanged lines hidden (view full) --- 3444 /* Disable the transmit/receive blocks. */ 3445 REG_WR(sc, BCE_MISC_ENABLE_CLR_BITS, 0x5ffffff); 3446 REG_RD(sc, BCE_MISC_ENABLE_CLR_BITS); 3447 DELAY(20); 3448 3449 bce_disable_intr(sc); 3450 3451 /* Free RX buffers. */ | 2860 2861bce_dma_alloc_exit: 2862 DBPRINT(sc, BCE_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); 2863 2864 return(rc); 2865} 2866 2867 --- 626 unchanged lines hidden (view full) --- 3494 /* Disable the transmit/receive blocks. */ 3495 REG_WR(sc, BCE_MISC_ENABLE_CLR_BITS, 0x5ffffff); 3496 REG_RD(sc, BCE_MISC_ENABLE_CLR_BITS); 3497 DELAY(20); 3498 3499 bce_disable_intr(sc); 3500 3501 /* Free RX buffers. */ |
3502#ifdef BCE_USE_SPLIT_HEADER |
|
3452 bce_free_pg_chain(sc); | 3503 bce_free_pg_chain(sc); |
3504#endif |
|
3453 bce_free_rx_chain(sc); 3454 3455 /* Free TX buffers. */ 3456 bce_free_tx_chain(sc); 3457 3458 /* 3459 * Isolate/power down the PHY, but leave the media selection 3460 * unchanged so that things will be put back to normal when --- 345 unchanged lines hidden (view full) --- 3806 sc->debug_mbuf_sim_alloc_failed++; 3807 rc = ENOBUFS; 3808 goto bce_get_rx_buf_exit); 3809 3810 /* This is a new mbuf allocation. */ 3811#ifdef BCE_USE_SPLIT_HEADER 3812 MGETHDR(m_new, M_DONTWAIT, MT_DATA); 3813#else | 3505 bce_free_rx_chain(sc); 3506 3507 /* Free TX buffers. */ 3508 bce_free_tx_chain(sc); 3509 3510 /* 3511 * Isolate/power down the PHY, but leave the media selection 3512 * unchanged so that things will be put back to normal when --- 345 unchanged lines hidden (view full) --- 3858 sc->debug_mbuf_sim_alloc_failed++; 3859 rc = ENOBUFS; 3860 goto bce_get_rx_buf_exit); 3861 3862 /* This is a new mbuf allocation. */ 3863#ifdef BCE_USE_SPLIT_HEADER 3864 MGETHDR(m_new, M_DONTWAIT, MT_DATA); 3865#else |
3814 m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); | 3866 if (sc->rx_bd_mbuf_alloc_size == MCLBYTES) 3867 m_new = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 3868 else 3869 m_new = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, sc->rx_bd_mbuf_alloc_size); |
3815#endif | 3870#endif |
3871 |
|
3816 if (m_new == NULL) { 3817 sc->mbuf_alloc_failed++; 3818 rc = ENOBUFS; 3819 goto bce_get_rx_buf_exit; 3820 } 3821 3822 DBRUN(sc->debug_rx_mbuf_alloc++); 3823 } else { 3824 /* Reuse an existing mbuf. */ 3825 m_new = m; 3826 } 3827 | 3872 if (m_new == NULL) { 3873 sc->mbuf_alloc_failed++; 3874 rc = ENOBUFS; 3875 goto bce_get_rx_buf_exit; 3876 } 3877 3878 DBRUN(sc->debug_rx_mbuf_alloc++); 3879 } else { 3880 /* Reuse an existing mbuf. */ 3881 m_new = m; 3882 } 3883 |
3884 /* Make sure we have a valid packet header. */ |
|
3828 M_ASSERTPKTHDR(m_new); 3829 | 3885 M_ASSERTPKTHDR(m_new); 3886 |
3887 /* Initialize the mbuf size and pad if necessary for alignment. */ |
|
3830 m_new->m_pkthdr.len = m_new->m_len = sc->rx_bd_mbuf_alloc_size; | 3888 m_new->m_pkthdr.len = m_new->m_len = sc->rx_bd_mbuf_alloc_size; |
3889 m_adj(m_new, sc->rx_bd_mbuf_align_pad); |
|
3831 3832 /* ToDo: Consider calling m_fragment() to test error handling. */ 3833 3834 /* Map the mbuf cluster into device memory. */ 3835 map = sc->rx_mbuf_map[*chain_prod]; 3836 error = bus_dmamap_load_mbuf_sg(sc->rx_mbuf_tag, map, m_new, 3837 segs, &nsegs, BUS_DMA_NOWAIT); 3838 3839 /* Handle any mapping errors. */ 3840 if (error) { | 3890 3891 /* ToDo: Consider calling m_fragment() to test error handling. */ 3892 3893 /* Map the mbuf cluster into device memory. */ 3894 map = sc->rx_mbuf_map[*chain_prod]; 3895 error = bus_dmamap_load_mbuf_sg(sc->rx_mbuf_tag, map, m_new, 3896 segs, &nsegs, BUS_DMA_NOWAIT); 3897 3898 /* Handle any mapping errors. */ 3899 if (error) { |
3841 BCE_PRINTF("%s(%d): Error mapping mbuf into RX chain!\n", 3842 __FILE__, __LINE__); | 3900 BCE_PRINTF("%s(%d): Error mapping mbuf into RX chain (%d)!\n", 3901 __FILE__, __LINE__, error); |
3843 3844 m_freem(m_new); 3845 DBRUN(sc->debug_rx_mbuf_alloc--); 3846 3847 rc = ENOBUFS; 3848 goto bce_get_rx_buf_exit; 3849 } 3850 --- 5 unchanged lines hidden (view full) --- 3856 3857 /* Setup the rx_bd for the segment. */ 3858 rxbd = &sc->rx_bd_chain[RX_PAGE(*chain_prod)][RX_IDX(*chain_prod)]; 3859 3860 rxbd->rx_bd_haddr_lo = htole32(BCE_ADDR_LO(segs[0].ds_addr)); 3861 rxbd->rx_bd_haddr_hi = htole32(BCE_ADDR_HI(segs[0].ds_addr)); 3862 rxbd->rx_bd_len = htole32(segs[0].ds_len); 3863 rxbd->rx_bd_flags = htole32(RX_BD_FLAGS_START | RX_BD_FLAGS_END); | 3902 3903 m_freem(m_new); 3904 DBRUN(sc->debug_rx_mbuf_alloc--); 3905 3906 rc = ENOBUFS; 3907 goto bce_get_rx_buf_exit; 3908 } 3909 --- 5 unchanged lines hidden (view full) --- 3915 3916 /* Setup the rx_bd for the segment. */ 3917 rxbd = &sc->rx_bd_chain[RX_PAGE(*chain_prod)][RX_IDX(*chain_prod)]; 3918 3919 rxbd->rx_bd_haddr_lo = htole32(BCE_ADDR_LO(segs[0].ds_addr)); 3920 rxbd->rx_bd_haddr_hi = htole32(BCE_ADDR_HI(segs[0].ds_addr)); 3921 rxbd->rx_bd_len = htole32(segs[0].ds_len); 3922 rxbd->rx_bd_flags = htole32(RX_BD_FLAGS_START | RX_BD_FLAGS_END); |
3864 *prod_bseq += segs[0].ds_len; | 3923 *prod_bseq += segs[0].ds_len; |
3865 3866 /* Save the mbuf and update our counter. */ 3867 sc->rx_mbuf_ptr[*chain_prod] = m_new; 3868 sc->free_rx_bd -= nsegs; 3869 3870 DBRUNMSG(BCE_EXCESSIVE, bce_dump_rx_mbuf_chain(sc, debug_chain_prod, 3871 nsegs)); 3872 3873 DBPRINT(sc, BCE_VERBOSE, "%s(exit): prod = 0x%04X, chain_prod = 0x%04X, " 3874 "prod_bseq = 0x%08X\n", __FUNCTION__, *prod, *chain_prod, *prod_bseq); 3875 3876bce_get_rx_buf_exit: 3877 DBPRINT(sc, (BCE_VERBOSE_RECV | BCE_VERBOSE_LOAD), "Exiting %s()\n", 3878 __FUNCTION__); 3879 3880 return(rc); 3881} 3882 3883 | 3924 3925 /* Save the mbuf and update our counter. */ 3926 sc->rx_mbuf_ptr[*chain_prod] = m_new; 3927 sc->free_rx_bd -= nsegs; 3928 3929 DBRUNMSG(BCE_EXCESSIVE, bce_dump_rx_mbuf_chain(sc, debug_chain_prod, 3930 nsegs)); 3931 3932 DBPRINT(sc, BCE_VERBOSE, "%s(exit): prod = 0x%04X, chain_prod = 0x%04X, " 3933 "prod_bseq = 0x%08X\n", __FUNCTION__, *prod, *chain_prod, *prod_bseq); 3934 3935bce_get_rx_buf_exit: 3936 DBPRINT(sc, (BCE_VERBOSE_RECV | BCE_VERBOSE_LOAD), "Exiting %s()\n", 3937 __FUNCTION__); 3938 3939 return(rc); 3940} 3941 3942 |
3943#ifdef BCE_USE_SPLIT_HEADER |
|
3884/****************************************************************************/ 3885/* Encapsulate an mbuf cluster into the page chain. */ 3886/* */ 3887/* Returns: */ 3888/* 0 for success, positive value for failure. */ 3889/****************************************************************************/ 3890static int 3891bce_get_pg_buf(struct bce_softc *sc, struct mbuf *m, u16 *prod, --- 94 unchanged lines hidden (view full) --- 3986 "prod_idx = 0x%04X\n", __FUNCTION__, *prod, *prod_idx); 3987 3988bce_get_pg_buf_exit: 3989 DBPRINT(sc, (BCE_VERBOSE_RESET | BCE_VERBOSE_RECV), "Exiting %s()\n", 3990 __FUNCTION__); 3991 3992 return(rc); 3993} | 3944/****************************************************************************/ 3945/* Encapsulate an mbuf cluster into the page chain. */ 3946/* */ 3947/* Returns: */ 3948/* 0 for success, positive value for failure. */ 3949/****************************************************************************/ 3950static int 3951bce_get_pg_buf(struct bce_softc *sc, struct mbuf *m, u16 *prod, --- 94 unchanged lines hidden (view full) --- 4046 "prod_idx = 0x%04X\n", __FUNCTION__, *prod, *prod_idx); 4047 4048bce_get_pg_buf_exit: 4049 DBPRINT(sc, (BCE_VERBOSE_RESET | BCE_VERBOSE_RECV), "Exiting %s()\n", 4050 __FUNCTION__); 4051 4052 return(rc); 4053} |
4054#endif /* BCE_USE_SPLIT_HEADER */ |
|
3994 3995 3996/****************************************************************************/ 3997/* Allocate memory and initialize the TX data structures. */ 3998/* */ 3999/* Returns: */ 4000/* 0 for success, positive value for failure. */ 4001/****************************************************************************/ --- 227 unchanged lines hidden (view full) --- 4229/****************************************************************************/ 4230static void 4231bce_free_rx_chain(struct bce_softc *sc) 4232{ 4233 int i; 4234 4235 DBPRINT(sc, BCE_VERBOSE_RESET, "Entering %s()\n", __FUNCTION__); 4236 | 4055 4056 4057/****************************************************************************/ 4058/* Allocate memory and initialize the TX data structures. */ 4059/* */ 4060/* Returns: */ 4061/* 0 for success, positive value for failure. */ 4062/****************************************************************************/ --- 227 unchanged lines hidden (view full) --- 4290/****************************************************************************/ 4291static void 4292bce_free_rx_chain(struct bce_softc *sc) 4293{ 4294 int i; 4295 4296 DBPRINT(sc, BCE_VERBOSE_RESET, "Entering %s()\n", __FUNCTION__); 4297 |
4298#ifdef BCE_USE_SPLIT_HEADER |
|
4237 /* Clear the jumbo page chain support. */ 4238 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_PG_BUF_SIZE, 0); | 4299 /* Clear the jumbo page chain support. */ 4300 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_PG_BUF_SIZE, 0); |
4301#endif |
|
4239 4240 /* Free any mbufs still in the RX mbuf chain. */ 4241 for (i = 0; i < TOTAL_RX_BD; i++) { 4242 if (sc->rx_mbuf_ptr[i] != NULL) { 4243 if (sc->rx_mbuf_map[i] != NULL) 4244 bus_dmamap_sync(sc->rx_mbuf_tag, sc->rx_mbuf_map[i], 4245 BUS_DMASYNC_POSTREAD); 4246 m_freem(sc->rx_mbuf_ptr[i]); --- 12 unchanged lines hidden (view full) --- 4259 DBRUNIF((sc->debug_rx_mbuf_alloc), 4260 BCE_PRINTF("%s(): Memory leak! Lost %d mbufs from rx chain!\n", 4261 __FUNCTION__, sc->debug_rx_mbuf_alloc)); 4262 4263 DBPRINT(sc, BCE_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); 4264} 4265 4266 | 4302 4303 /* Free any mbufs still in the RX mbuf chain. */ 4304 for (i = 0; i < TOTAL_RX_BD; i++) { 4305 if (sc->rx_mbuf_ptr[i] != NULL) { 4306 if (sc->rx_mbuf_map[i] != NULL) 4307 bus_dmamap_sync(sc->rx_mbuf_tag, sc->rx_mbuf_map[i], 4308 BUS_DMASYNC_POSTREAD); 4309 m_freem(sc->rx_mbuf_ptr[i]); --- 12 unchanged lines hidden (view full) --- 4322 DBRUNIF((sc->debug_rx_mbuf_alloc), 4323 BCE_PRINTF("%s(): Memory leak! Lost %d mbufs from rx chain!\n", 4324 __FUNCTION__, sc->debug_rx_mbuf_alloc)); 4325 4326 DBPRINT(sc, BCE_VERBOSE_RESET, "Exiting %s()\n", __FUNCTION__); 4327} 4328 4329 |
4330#ifdef BCE_USE_SPLIT_HEADER |
|
4267/****************************************************************************/ 4268/* Allocate memory and initialize the page data structures. */ 4269/* Assumes that bce_init_rx_chain() has not already been called. */ 4270/* */ 4271/* Returns: */ 4272/* 0 for success, positive value for failure. */ 4273/****************************************************************************/ 4274static int --- 32 unchanged lines hidden (view full) --- 4307 4308 /* Point the hardware to the first page in the page chain. */ 4309 val = BCE_ADDR_HI(sc->pg_bd_chain_paddr[0]); 4310 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_NX_PG_BDHADDR_HI, val); 4311 val = BCE_ADDR_LO(sc->pg_bd_chain_paddr[0]); 4312 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_NX_PG_BDHADDR_LO, val); 4313 4314 /* Configure the rx_bd and page chain mbuf cluster size. */ | 4331/****************************************************************************/ 4332/* Allocate memory and initialize the page data structures. */ 4333/* Assumes that bce_init_rx_chain() has not already been called. */ 4334/* */ 4335/* Returns: */ 4336/* 0 for success, positive value for failure. */ 4337/****************************************************************************/ 4338static int --- 32 unchanged lines hidden (view full) --- 4371 4372 /* Point the hardware to the first page in the page chain. */ 4373 val = BCE_ADDR_HI(sc->pg_bd_chain_paddr[0]); 4374 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_NX_PG_BDHADDR_HI, val); 4375 val = BCE_ADDR_LO(sc->pg_bd_chain_paddr[0]); 4376 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_NX_PG_BDHADDR_LO, val); 4377 4378 /* Configure the rx_bd and page chain mbuf cluster size. */ |
4315 val = (sc->rx_bd_mbuf_alloc_size << 16) | sc->pg_bd_mbuf_alloc_size; | 4379#ifdef BCE_USE_SPLIT_HEADER 4380 val = (sc->rx_bd_mbuf_data_len << 16) | sc->pg_bd_mbuf_alloc_size; 4381#else 4382 val = (sc->rx_bd_mbuf_data_len << 16); 4383#endif |
4316 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_PG_BUF_SIZE, val); 4317 4318 /* Configure the context reserved for jumbo support. */ 4319 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_RBDC_KEY, 4320 BCE_L2CTX_RBDC_JUMBO_KEY); 4321 4322 /* Fill up the page chain. */ 4323 bce_fill_pg_chain(sc); --- 84 unchanged lines hidden (view full) --- 4408 4409 /* Check if we lost any mbufs in the process. */ 4410 DBRUNIF((sc->debug_pg_mbuf_alloc), 4411 BCE_PRINTF("%s(): Memory leak! Lost %d mbufs from page chain!\n", 4412 __FUNCTION__, sc->debug_pg_mbuf_alloc)); 4413 4414 DBPRINT(sc, BCE_EXCESSIVE_RESET, "Exiting %s()\n", __FUNCTION__); 4415} | 4384 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_PG_BUF_SIZE, val); 4385 4386 /* Configure the context reserved for jumbo support. */ 4387 CTX_WR(sc, GET_CID_ADDR(RX_CID), BCE_L2CTX_RBDC_KEY, 4388 BCE_L2CTX_RBDC_JUMBO_KEY); 4389 4390 /* Fill up the page chain. */ 4391 bce_fill_pg_chain(sc); --- 84 unchanged lines hidden (view full) --- 4476 4477 /* Check if we lost any mbufs in the process. */ 4478 DBRUNIF((sc->debug_pg_mbuf_alloc), 4479 BCE_PRINTF("%s(): Memory leak! Lost %d mbufs from page chain!\n", 4480 __FUNCTION__, sc->debug_pg_mbuf_alloc)); 4481 4482 DBPRINT(sc, BCE_EXCESSIVE_RESET, "Exiting %s()\n", __FUNCTION__); 4483} |
4484#endif /* BCE_USE_SPLIT_HEADER */ |
|
4416 4417 4418/****************************************************************************/ 4419/* Set media options. */ 4420/* */ 4421/* Returns: */ 4422/* 0 for success, positive value for failure. */ 4423/****************************************************************************/ --- 138 unchanged lines hidden (view full) --- 4562/* Returns: */ 4563/* Nothing. */ 4564/****************************************************************************/ 4565static void 4566bce_rx_intr(struct bce_softc *sc) 4567{ 4568 struct ifnet *ifp = sc->bce_ifp; 4569 struct l2_fhdr *l2fhdr; | 4485 4486 4487/****************************************************************************/ 4488/* Set media options. */ 4489/* */ 4490/* Returns: */ 4491/* 0 for success, positive value for failure. */ 4492/****************************************************************************/ --- 138 unchanged lines hidden (view full) --- 4631/* Returns: */ 4632/* Nothing. */ 4633/****************************************************************************/ 4634static void 4635bce_rx_intr(struct bce_softc *sc) 4636{ 4637 struct ifnet *ifp = sc->bce_ifp; 4638 struct l2_fhdr *l2fhdr; |
4570 unsigned int pages, pkt_len, rem_len; 4571 u16 sw_rx_cons, sw_rx_cons_idx, sw_pg_cons, sw_pg_cons_idx, hw_rx_cons; | 4639 unsigned int pkt_len; 4640 u16 sw_rx_cons, sw_rx_cons_idx, hw_rx_cons; |
4572 u32 status; | 4641 u32 status; |
4642#ifdef BCE_USE_SPLIT_HEADER 4643 unsigned int pages, rem_len; 4644 u16 sw_pg_cons, sw_pg_cons_idx; 4645#endif |
|
4573 4574 4575#ifdef BCE_DEBUG 4576 u32 timer_start, timer_end; 4577 timer_start = REG_RD(sc, BCE_TIMER_25MHZ_FREE_RUN); 4578 sc->rx_interrupts++; 4579#endif 4580 4581 /* Prepare the RX chain pages to be accessed by the host CPU. */ 4582 for (int i = 0; i < RX_PAGES; i++) 4583 bus_dmamap_sync(sc->rx_bd_chain_tag, 4584 sc->rx_bd_chain_map[i], BUS_DMASYNC_POSTWRITE); 4585 | 4646 4647 4648#ifdef BCE_DEBUG 4649 u32 timer_start, timer_end; 4650 timer_start = REG_RD(sc, BCE_TIMER_25MHZ_FREE_RUN); 4651 sc->rx_interrupts++; 4652#endif 4653 4654 /* Prepare the RX chain pages to be accessed by the host CPU. */ 4655 for (int i = 0; i < RX_PAGES; i++) 4656 bus_dmamap_sync(sc->rx_bd_chain_tag, 4657 sc->rx_bd_chain_map[i], BUS_DMASYNC_POSTWRITE); 4658 |
4659#ifdef BCE_USE_SPLIT_HEADER |
|
4586 /* Prepare the page chain pages to be accessed by the host CPU. */ 4587 for (int i = 0; i < PG_PAGES; i++) 4588 bus_dmamap_sync(sc->pg_bd_chain_tag, 4589 sc->pg_bd_chain_map[i], BUS_DMASYNC_POSTWRITE); | 4660 /* Prepare the page chain pages to be accessed by the host CPU. */ 4661 for (int i = 0; i < PG_PAGES; i++) 4662 bus_dmamap_sync(sc->pg_bd_chain_tag, 4663 sc->pg_bd_chain_map[i], BUS_DMASYNC_POSTWRITE); |
4664#endif |
|
4590 4591 /* Get the hardware's view of the RX consumer index. */ 4592 hw_rx_cons = sc->hw_rx_cons = bce_get_hw_rx_cons(sc); 4593 4594 /* Get working copies of the driver's view of the consumer indices. */ 4595 sw_rx_cons = sc->rx_cons; | 4665 4666 /* Get the hardware's view of the RX consumer index. */ 4667 hw_rx_cons = sc->hw_rx_cons = bce_get_hw_rx_cons(sc); 4668 4669 /* Get working copies of the driver's view of the consumer indices. */ 4670 sw_rx_cons = sc->rx_cons; |
4671#ifdef BCE_USE_SPLIT_HEADER |
|
4596 sw_pg_cons = sc->pg_cons; | 4672 sw_pg_cons = sc->pg_cons; |
4673#endif |
|
4597 4598 DBPRINT(sc, BCE_INFO_RECV, "%s(enter): rx_prod = 0x%04X, " 4599 "rx_cons = 0x%04X, rx_prod_bseq = 0x%08X\n", 4600 __FUNCTION__, sc->rx_prod, sc->rx_cons, sc->rx_prod_bseq); 4601 4602 /* Update some debug statistics counters */ 4603 DBRUNIF((sc->free_rx_bd < sc->rx_low_watermark), 4604 sc->rx_low_watermark = sc->free_rx_bd); --- 46 unchanged lines hidden (view full) --- 4651 * Skip over the l2_fhdr and pad, resulting in the 4652 * following data in the mbuf: 4653 * +---------------------+-----+ 4654 * | packet data | FCS | 4655 * +---------------------+-----+ 4656 */ 4657 m_adj(m0, sizeof(struct l2_fhdr) + ETHER_ALIGN); 4658 | 4674 4675 DBPRINT(sc, BCE_INFO_RECV, "%s(enter): rx_prod = 0x%04X, " 4676 "rx_cons = 0x%04X, rx_prod_bseq = 0x%08X\n", 4677 __FUNCTION__, sc->rx_prod, sc->rx_cons, sc->rx_prod_bseq); 4678 4679 /* Update some debug statistics counters */ 4680 DBRUNIF((sc->free_rx_bd < sc->rx_low_watermark), 4681 sc->rx_low_watermark = sc->free_rx_bd); --- 46 unchanged lines hidden (view full) --- 4728 * Skip over the l2_fhdr and pad, resulting in the 4729 * following data in the mbuf: 4730 * +---------------------+-----+ 4731 * | packet data | FCS | 4732 * +---------------------+-----+ 4733 */ 4734 m_adj(m0, sizeof(struct l2_fhdr) + ETHER_ALIGN); 4735 |
4736 4737#ifdef BCE_USE_SPLIT_HEADER |
|
4659 /* 4660 * Check whether the received frame fits in a single 4661 * mbuf or not (i.e. packet data + FCS <= | 4738 /* 4739 * Check whether the received frame fits in a single 4740 * mbuf or not (i.e. packet data + FCS <= |
4662 * sc->rx_bd_mbuf_alloc_size bytes). | 4741 * sc->rx_bd_mbuf_data_len bytes). |
4663 */ 4664 if (pkt_len > m0->m_len) { 4665 /* 4666 * The received frame is larger than a single mbuf. 4667 * If the frame was a TCP frame then only the TCP 4668 * header is placed in the mbuf, the remaining 4669 * payload (including FCS) is placed in the page 4670 * chain, the SPLIT flag is set, and the header --- 62 unchanged lines hidden (view full) --- 4733 */ 4734 4735 DBPRINT(sc, BCE_INFO_RECV, "%s(): Found a small packet.\n", 4736 __FUNCTION__); 4737 4738 /* Set the total packet length. */ 4739 m0->m_pkthdr.len = m0->m_len = pkt_len; 4740 } | 4742 */ 4743 if (pkt_len > m0->m_len) { 4744 /* 4745 * The received frame is larger than a single mbuf. 4746 * If the frame was a TCP frame then only the TCP 4747 * header is placed in the mbuf, the remaining 4748 * payload (including FCS) is placed in the page 4749 * chain, the SPLIT flag is set, and the header --- 62 unchanged lines hidden (view full) --- 4812 */ 4813 4814 DBPRINT(sc, BCE_INFO_RECV, "%s(): Found a small packet.\n", 4815 __FUNCTION__); 4816 4817 /* Set the total packet length. */ 4818 m0->m_pkthdr.len = m0->m_len = pkt_len; 4819 } |
4820#endif |
|
4741 4742 /* Remove the trailing Ethernet FCS. */ 4743 m_adj(m0, -ETHER_CRC_LEN); 4744 4745 /* Check that the resulting mbuf chain is valid. */ 4746 DBRUN(m_sanity(m0, FALSE)); 4747 4748 DBRUNIF((m0->m_len < ETHER_HDR_LEN), --- 71 unchanged lines hidden (view full) --- 4820 4821bce_rx_int_next_rx: 4822 sw_rx_cons = NEXT_RX_BD(sw_rx_cons); 4823 4824 /* If we have a packet, pass it up the stack */ 4825 if (m0) { 4826 /* Make sure we don't lose our place when we release the lock. */ 4827 sc->rx_cons = sw_rx_cons; | 4821 4822 /* Remove the trailing Ethernet FCS. */ 4823 m_adj(m0, -ETHER_CRC_LEN); 4824 4825 /* Check that the resulting mbuf chain is valid. */ 4826 DBRUN(m_sanity(m0, FALSE)); 4827 4828 DBRUNIF((m0->m_len < ETHER_HDR_LEN), --- 71 unchanged lines hidden (view full) --- 4900 4901bce_rx_int_next_rx: 4902 sw_rx_cons = NEXT_RX_BD(sw_rx_cons); 4903 4904 /* If we have a packet, pass it up the stack */ 4905 if (m0) { 4906 /* Make sure we don't lose our place when we release the lock. */ 4907 sc->rx_cons = sw_rx_cons; |
4908#ifdef BCE_USE_SPLIT_HEADER |
|
4828 sc->pg_cons = sw_pg_cons; | 4909 sc->pg_cons = sw_pg_cons; |
4910#endif |
|
4829 4830 BCE_UNLOCK(sc); 4831 (*ifp->if_input)(ifp, m0); 4832 BCE_LOCK(sc); 4833 4834 /* Recover our place. */ 4835 sw_rx_cons = sc->rx_cons; | 4911 4912 BCE_UNLOCK(sc); 4913 (*ifp->if_input)(ifp, m0); 4914 BCE_LOCK(sc); 4915 4916 /* Recover our place. */ 4917 sw_rx_cons = sc->rx_cons; |
4918#ifdef BCE_USE_SPLIT_HEADER |
|
4836 sw_pg_cons = sc->pg_cons; | 4919 sw_pg_cons = sc->pg_cons; |
4920#endif |
|
4837 } 4838 4839 /* Refresh hw_cons to see if there's new work */ 4840 if (sw_rx_cons == hw_rx_cons) 4841 hw_rx_cons = sc->hw_rx_cons = bce_get_hw_rx_cons(sc); 4842 } 4843 4844 /* No new packets to process. Refill the RX and page chains and exit. */ | 4921 } 4922 4923 /* Refresh hw_cons to see if there's new work */ 4924 if (sw_rx_cons == hw_rx_cons) 4925 hw_rx_cons = sc->hw_rx_cons = bce_get_hw_rx_cons(sc); 4926 } 4927 4928 /* No new packets to process. Refill the RX and page chains and exit. */ |
4929#ifdef BCE_USE_SPLIT_HEADER |
|
4845 sc->pg_cons = sw_pg_cons; 4846 bce_fill_pg_chain(sc); | 4930 sc->pg_cons = sw_pg_cons; 4931 bce_fill_pg_chain(sc); |
4932#endif |
|
4847 4848 sc->rx_cons = sw_rx_cons; 4849 bce_fill_rx_chain(sc); 4850 4851 for (int i = 0; i < RX_PAGES; i++) 4852 bus_dmamap_sync(sc->rx_bd_chain_tag, 4853 sc->rx_bd_chain_map[i], BUS_DMASYNC_PREWRITE); 4854 | 4933 4934 sc->rx_cons = sw_rx_cons; 4935 bce_fill_rx_chain(sc); 4936 4937 for (int i = 0; i < RX_PAGES; i++) 4938 bus_dmamap_sync(sc->rx_bd_chain_tag, 4939 sc->rx_bd_chain_map[i], BUS_DMASYNC_PREWRITE); 4940 |
4941#ifdef BCE_USE_SPLIT_HEADER |
|
4855 for (int i = 0; i < PG_PAGES; i++) 4856 bus_dmamap_sync(sc->pg_bd_chain_tag, 4857 sc->pg_bd_chain_map[i], BUS_DMASYNC_PREWRITE); | 4942 for (int i = 0; i < PG_PAGES; i++) 4943 bus_dmamap_sync(sc->pg_bd_chain_tag, 4944 sc->pg_bd_chain_map[i], BUS_DMASYNC_PREWRITE); |
4945#endif |
|
4858 4859 DBPRINT(sc, BCE_INFO_RECV, "%s(exit): rx_prod = 0x%04X, " 4860 "rx_cons = 0x%04X, rx_prod_bseq = 0x%08X\n", 4861 __FUNCTION__, sc->rx_prod, sc->rx_cons, sc->rx_prod_bseq); 4862 4863#ifdef BCE_DEBUG 4864 timer_end = REG_RD(sc, BCE_TIMER_25MHZ_FREE_RUN); 4865 sc->rx_intr_time += (u64) (timer_start > timer_end ? --- 218 unchanged lines hidden (view full) --- 5084 __FILE__, __LINE__); 5085 goto bce_init_locked_exit; 5086 } 5087 5088 /* Load our MAC address. */ 5089 bcopy(IF_LLADDR(sc->bce_ifp), sc->eaddr, ETHER_ADDR_LEN); 5090 bce_set_mac_addr(sc); 5091 | 4946 4947 DBPRINT(sc, BCE_INFO_RECV, "%s(exit): rx_prod = 0x%04X, " 4948 "rx_cons = 0x%04X, rx_prod_bseq = 0x%08X\n", 4949 __FUNCTION__, sc->rx_prod, sc->rx_cons, sc->rx_prod_bseq); 4950 4951#ifdef BCE_DEBUG 4952 timer_end = REG_RD(sc, BCE_TIMER_25MHZ_FREE_RUN); 4953 sc->rx_intr_time += (u64) (timer_start > timer_end ? --- 218 unchanged lines hidden (view full) --- 5172 __FILE__, __LINE__); 5173 goto bce_init_locked_exit; 5174 } 5175 5176 /* Load our MAC address. */ 5177 bcopy(IF_LLADDR(sc->bce_ifp), sc->eaddr, ETHER_ADDR_LEN); 5178 bce_set_mac_addr(sc); 5179 |
5092 /* Calculate and program the hardware Ethernet MTU size. */ 5093 if (ifp->if_mtu <= sc->pg_bd_mbuf_alloc_size) 5094 /* Be generous on receive if we have room. */ 5095 ether_mtu = sc->pg_bd_mbuf_alloc_size; | 5180 /* 5181 * Calculate and program the hardware Ethernet MTU 5182 * size. Be generous on the receive if we have room. 5183 */ 5184#ifdef BCE_USE_SPLIT_HEADER 5185 if (ifp->if_mtu <= (sc->rx_bd_mbuf_data_len + sc->pg_bd_mbuf_alloc_size)) 5186 ether_mtu = sc->rx_bd_mbuf_data_len + sc->pg_bd_mbuf_alloc_size; 5187#else 5188 if (ifp->if_mtu <= sc->rx_bd_mbuf_data_len) 5189 ether_mtu = sc->rx_bd_mbuf_data_len; 5190#endif |
5096 else 5097 ether_mtu = ifp->if_mtu; 5098 5099 ether_mtu += ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + ETHER_CRC_LEN; 5100 5101 DBPRINT(sc, BCE_INFO_MISC, "%s(): setting h/w mtu = %d\n", __FUNCTION__, 5102 ether_mtu); 5103 5104 /* Program the mtu, enabling jumbo frame support if necessary. */ 5105 if (ether_mtu > (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN)) 5106 REG_WR(sc, BCE_EMAC_RX_MTU_SIZE, 5107 min(ether_mtu, BCE_MAX_JUMBO_ETHER_MTU) | 5108 BCE_EMAC_RX_MTU_SIZE_JUMBO_ENA); 5109 else 5110 REG_WR(sc, BCE_EMAC_RX_MTU_SIZE, ether_mtu); 5111 5112 DBPRINT(sc, BCE_INFO_LOAD, | 5191 else 5192 ether_mtu = ifp->if_mtu; 5193 5194 ether_mtu += ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + ETHER_CRC_LEN; 5195 5196 DBPRINT(sc, BCE_INFO_MISC, "%s(): setting h/w mtu = %d\n", __FUNCTION__, 5197 ether_mtu); 5198 5199 /* Program the mtu, enabling jumbo frame support if necessary. */ 5200 if (ether_mtu > (ETHER_MAX_LEN + ETHER_VLAN_ENCAP_LEN)) 5201 REG_WR(sc, BCE_EMAC_RX_MTU_SIZE, 5202 min(ether_mtu, BCE_MAX_JUMBO_ETHER_MTU) | 5203 BCE_EMAC_RX_MTU_SIZE_JUMBO_ENA); 5204 else 5205 REG_WR(sc, BCE_EMAC_RX_MTU_SIZE, ether_mtu); 5206 5207 DBPRINT(sc, BCE_INFO_LOAD, |
5113 "%s(): rx_bd_mbuf_alloc_size = %d, pg_bd_mbuf_alloc_size = %d\n", 5114 __FUNCTION__, sc->rx_bd_mbuf_alloc_size, sc->pg_bd_mbuf_alloc_size); | 5208 "%s(): rx_bd_mbuf_alloc_size = %d, rx_bce_mbuf_data_len = %d, " 5209 "rx_bd_mbuf_align_pad = %d, pg_bd_mbuf_alloc_size = %d\n", 5210 __FUNCTION__, sc->rx_bd_mbuf_alloc_size, sc->rx_bd_mbuf_data_len, 5211 sc->rx_bd_mbuf_align_pad, sc->pg_bd_mbuf_alloc_size); |
5115 5116 /* Program appropriate promiscuous/multicast filtering. */ 5117 bce_set_rx_mode(sc); 5118 | 5212 5213 /* Program appropriate promiscuous/multicast filtering. */ 5214 bce_set_rx_mode(sc); 5215 |
5216#ifdef BCE_USE_SPLIT_HEADER |
|
5119 /* Init page buffer descriptor chain. */ 5120 bce_init_pg_chain(sc); | 5217 /* Init page buffer descriptor chain. */ 5218 bce_init_pg_chain(sc); |
5219#endif |
|
5121 5122 /* Init RX buffer descriptor chain. */ 5123 bce_init_rx_chain(sc); 5124 5125 /* Init TX buffer descriptor chain. */ 5126 bce_init_tx_chain(sc); 5127 5128 /* Enable host interrupts. */ --- 450 unchanged lines hidden (view full) --- 5579 5580 DBPRINT(sc, BCE_INFO_MISC, 5581 "SIOCSIFMTU: Changing MTU from %d to %d\n", 5582 (int) ifp->if_mtu, (int) ifr->ifr_mtu); 5583 5584 BCE_LOCK(sc); 5585 ifp->if_mtu = ifr->ifr_mtu; 5586 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; | 5220 5221 /* Init RX buffer descriptor chain. */ 5222 bce_init_rx_chain(sc); 5223 5224 /* Init TX buffer descriptor chain. */ 5225 bce_init_tx_chain(sc); 5226 5227 /* Enable host interrupts. */ --- 450 unchanged lines hidden (view full) --- 5678 5679 DBPRINT(sc, BCE_INFO_MISC, 5680 "SIOCSIFMTU: Changing MTU from %d to %d\n", 5681 (int) ifp->if_mtu, (int) ifr->ifr_mtu); 5682 5683 BCE_LOCK(sc); 5684 ifp->if_mtu = ifr->ifr_mtu; 5685 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; |
5686#ifdef BCE_USE_SPLIT_HEADER 5687 /* No buffer allocation size changes are necessary. */ 5688#else 5689 /* Recalculate our buffer allocation sizes. */ 5690 if ((ifp->if_mtu + ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN + ETHER_CRC_LEN) > MCLBYTES) { 5691 sc->rx_bd_mbuf_alloc_size = MJUM9BYTES; 5692 sc->rx_bd_mbuf_align_pad = roundup2(MJUM9BYTES, 16) - MJUM9BYTES; 5693 sc->rx_bd_mbuf_data_len = sc->rx_bd_mbuf_alloc_size - 5694 sc->rx_bd_mbuf_align_pad; 5695 } else { 5696 sc->rx_bd_mbuf_alloc_size = MCLBYTES; 5697 sc->rx_bd_mbuf_align_pad = roundup2(MCLBYTES, 16) - MCLBYTES; 5698 sc->rx_bd_mbuf_data_len = sc->rx_bd_mbuf_alloc_size - 5699 sc->rx_bd_mbuf_align_pad; 5700 } 5701#endif 5702 |
|
5587 bce_init_locked(sc); 5588 BCE_UNLOCK(sc); 5589 break; 5590 5591 /* Set interface flags. */ 5592 case SIOCSIFFLAGS: 5593 DBPRINT(sc, BCE_VERBOSE_SPECIAL, "Received SIOCSIFFLAGS\n"); 5594 --- 633 unchanged lines hidden (view full) --- 6228 6229 /* Schedule the next tick. */ 6230 callout_reset(&sc->bce_tick_callout, hz, bce_tick, sc); 6231 6232 /* Update the statistics from the hardware statistics block. */ 6233 bce_stats_update(sc); 6234 6235 /* Top off the receive and page chains. */ | 5703 bce_init_locked(sc); 5704 BCE_UNLOCK(sc); 5705 break; 5706 5707 /* Set interface flags. */ 5708 case SIOCSIFFLAGS: 5709 DBPRINT(sc, BCE_VERBOSE_SPECIAL, "Received SIOCSIFFLAGS\n"); 5710 --- 633 unchanged lines hidden (view full) --- 6344 6345 /* Schedule the next tick. */ 6346 callout_reset(&sc->bce_tick_callout, hz, bce_tick, sc); 6347 6348 /* Update the statistics from the hardware statistics block. */ 6349 bce_stats_update(sc); 6350 6351 /* Top off the receive and page chains. */ |
6352#ifdef BCE_USE_SPLIT_HEADER |
|
6236 bce_fill_pg_chain(sc); | 6353 bce_fill_pg_chain(sc); |
6354#endif |
|
6237 bce_fill_rx_chain(sc); 6238 6239 /* Check that chip hasn't hung. */ 6240 bce_watchdog(sc); 6241 6242 /* If link is up already up then we're done. */ 6243 if (sc->bce_link) 6244 goto bce_tick_locked_exit; --- 156 unchanged lines hidden (view full) --- 6401 sc = (struct bce_softc *)arg1; 6402 bce_dump_tx_chain(sc, 0, USABLE_TX_BD); 6403 } 6404 6405 return error; 6406} 6407 6408 | 6355 bce_fill_rx_chain(sc); 6356 6357 /* Check that chip hasn't hung. */ 6358 bce_watchdog(sc); 6359 6360 /* If link is up already up then we're done. */ 6361 if (sc->bce_link) 6362 goto bce_tick_locked_exit; --- 156 unchanged lines hidden (view full) --- 6519 sc = (struct bce_softc *)arg1; 6520 bce_dump_tx_chain(sc, 0, USABLE_TX_BD); 6521 } 6522 6523 return error; 6524} 6525 6526 |
6527#ifdef BCE_USE_SPLIT_HEADER |
|
6409/****************************************************************************/ 6410/* Provides a sysctl interface to allow dumping the page chain. */ 6411/* */ 6412/* Returns: */ 6413/* 0 for success, positive value for failure. */ 6414/****************************************************************************/ 6415static int 6416bce_sysctl_dump_pg_chain(SYSCTL_HANDLER_ARGS) --- 10 unchanged lines hidden (view full) --- 6427 6428 if (result == 1) { 6429 sc = (struct bce_softc *)arg1; 6430 bce_dump_pg_chain(sc, 0, TOTAL_PG_BD); 6431 } 6432 6433 return error; 6434} | 6528/****************************************************************************/ 6529/* Provides a sysctl interface to allow dumping the page chain. */ 6530/* */ 6531/* Returns: */ 6532/* 0 for success, positive value for failure. */ 6533/****************************************************************************/ 6534static int 6535bce_sysctl_dump_pg_chain(SYSCTL_HANDLER_ARGS) --- 10 unchanged lines hidden (view full) --- 6546 6547 if (result == 1) { 6548 sc = (struct bce_softc *)arg1; 6549 bce_dump_pg_chain(sc, 0, TOTAL_PG_BD); 6550 } 6551 6552 return error; 6553} |
6554#endif |
|
6435 6436 6437/****************************************************************************/ 6438/* Provides a sysctl interface to allow reading arbitrary registers in the */ 6439/* device. DO NOT ENABLE ON PRODUCTION SYSTEMS! */ 6440/* */ 6441/* Returns: */ 6442/* 0 for success, positive value for failure. */ --- 475 unchanged lines hidden (view full) --- 6918 (void *)sc, 0, 6919 bce_sysctl_dump_rx_chain, "I", "Dump rx_bd chain"); 6920 6921 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 6922 "dump_tx_chain", CTLTYPE_INT | CTLFLAG_RW, 6923 (void *)sc, 0, 6924 bce_sysctl_dump_tx_chain, "I", "Dump tx_bd chain"); 6925 | 6555 6556 6557/****************************************************************************/ 6558/* Provides a sysctl interface to allow reading arbitrary registers in the */ 6559/* device. DO NOT ENABLE ON PRODUCTION SYSTEMS! */ 6560/* */ 6561/* Returns: */ 6562/* 0 for success, positive value for failure. */ --- 475 unchanged lines hidden (view full) --- 7038 (void *)sc, 0, 7039 bce_sysctl_dump_rx_chain, "I", "Dump rx_bd chain"); 7040 7041 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 7042 "dump_tx_chain", CTLTYPE_INT | CTLFLAG_RW, 7043 (void *)sc, 0, 7044 bce_sysctl_dump_tx_chain, "I", "Dump tx_bd chain"); 7045 |
7046#ifdef BCE_USE_SPLIT_HEADER |
|
6926 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 6927 "dump_pg_chain", CTLTYPE_INT | CTLFLAG_RW, 6928 (void *)sc, 0, 6929 bce_sysctl_dump_pg_chain, "I", "Dump page chain"); | 7047 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 7048 "dump_pg_chain", CTLTYPE_INT | CTLFLAG_RW, 7049 (void *)sc, 0, 7050 bce_sysctl_dump_pg_chain, "I", "Dump page chain"); |
7051#endif |
|
6930 6931 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 6932 "breakpoint", CTLTYPE_INT | CTLFLAG_RW, 6933 (void *)sc, 0, 6934 bce_sysctl_breakpoint, "I", "Driver breakpoint"); 6935 6936 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 6937 "reg_read", CTLTYPE_INT | CTLFLAG_RW, --- 161 unchanged lines hidden (view full) --- 7099 7100 BCE_PRINTF( 7101 "----------------------------" 7102 "----------------" 7103 "----------------------------\n"); 7104} 7105 7106 | 7052 7053 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 7054 "breakpoint", CTLTYPE_INT | CTLFLAG_RW, 7055 (void *)sc, 0, 7056 bce_sysctl_breakpoint, "I", "Driver breakpoint"); 7057 7058 SYSCTL_ADD_PROC(ctx, children, OID_AUTO, 7059 "reg_read", CTLTYPE_INT | CTLFLAG_RW, --- 161 unchanged lines hidden (view full) --- 7221 7222 BCE_PRINTF( 7223 "----------------------------" 7224 "----------------" 7225 "----------------------------\n"); 7226} 7227 7228 |
7229#ifdef BCE_USE_SPLIT_HEADER |
|
7107/****************************************************************************/ 7108/* Prints out the mbufs in the mbuf page chain. */ 7109/* */ 7110/* Returns: */ 7111/* Nothing. */ 7112/****************************************************************************/ 7113static void 7114bce_dump_pg_mbuf_chain(struct bce_softc *sc, u16 chain_prod, int count) --- 13 unchanged lines hidden (view full) --- 7128 } 7129 7130 7131 BCE_PRINTF( 7132 "----------------------------" 7133 "----------------" 7134 "----------------------------\n"); 7135} | 7230/****************************************************************************/ 7231/* Prints out the mbufs in the mbuf page chain. */ 7232/* */ 7233/* Returns: */ 7234/* Nothing. */ 7235/****************************************************************************/ 7236static void 7237bce_dump_pg_mbuf_chain(struct bce_softc *sc, u16 chain_prod, int count) --- 13 unchanged lines hidden (view full) --- 7251 } 7252 7253 7254 BCE_PRINTF( 7255 "----------------------------" 7256 "----------------" 7257 "----------------------------\n"); 7258} |
7259#endif |
|
7136 7137 7138/****************************************************************************/ 7139/* Prints out a tx_bd structure. */ 7140/* */ 7141/* Returns: */ 7142/* Nothing. */ 7143/****************************************************************************/ --- 77 unchanged lines hidden (view full) --- 7221 /* Normal rx_bd entry. */ 7222 BCE_PRINTF("rx_bd[0x%04X]: haddr = 0x%08X:%08X, nbytes = 0x%08X, " 7223 "flags = 0x%08X\n", idx, 7224 rxbd->rx_bd_haddr_hi, rxbd->rx_bd_haddr_lo, 7225 rxbd->rx_bd_len, rxbd->rx_bd_flags); 7226} 7227 7228 | 7260 7261 7262/****************************************************************************/ 7263/* Prints out a tx_bd structure. */ 7264/* */ 7265/* Returns: */ 7266/* Nothing. */ 7267/****************************************************************************/ --- 77 unchanged lines hidden (view full) --- 7345 /* Normal rx_bd entry. */ 7346 BCE_PRINTF("rx_bd[0x%04X]: haddr = 0x%08X:%08X, nbytes = 0x%08X, " 7347 "flags = 0x%08X\n", idx, 7348 rxbd->rx_bd_haddr_hi, rxbd->rx_bd_haddr_lo, 7349 rxbd->rx_bd_len, rxbd->rx_bd_flags); 7350} 7351 7352 |
7353#ifdef BCE_USE_SPLIT_HEADER |
|
7229/****************************************************************************/ 7230/* Prints out a rx_bd structure in the page chain. */ 7231/* */ 7232/* Returns: */ 7233/* Nothing. */ 7234/****************************************************************************/ 7235static void 7236bce_dump_pgbd(struct bce_softc *sc, int idx, struct rx_bd *pgbd) --- 7 unchanged lines hidden (view full) --- 7244 idx, pgbd->rx_bd_haddr_hi, pgbd->rx_bd_haddr_lo); 7245 else 7246 /* Normal rx_bd entry. */ 7247 BCE_PRINTF("pg_bd[0x%04X]: haddr = 0x%08X:%08X, nbytes = 0x%08X, " 7248 "flags = 0x%08X\n", idx, 7249 pgbd->rx_bd_haddr_hi, pgbd->rx_bd_haddr_lo, 7250 pgbd->rx_bd_len, pgbd->rx_bd_flags); 7251} | 7354/****************************************************************************/ 7355/* Prints out a rx_bd structure in the page chain. */ 7356/* */ 7357/* Returns: */ 7358/* Nothing. */ 7359/****************************************************************************/ 7360static void 7361bce_dump_pgbd(struct bce_softc *sc, int idx, struct rx_bd *pgbd) --- 7 unchanged lines hidden (view full) --- 7369 idx, pgbd->rx_bd_haddr_hi, pgbd->rx_bd_haddr_lo); 7370 else 7371 /* Normal rx_bd entry. */ 7372 BCE_PRINTF("pg_bd[0x%04X]: haddr = 0x%08X:%08X, nbytes = 0x%08X, " 7373 "flags = 0x%08X\n", idx, 7374 pgbd->rx_bd_haddr_hi, pgbd->rx_bd_haddr_lo, 7375 pgbd->rx_bd_len, pgbd->rx_bd_flags); 7376} |
7377#endif |
|
7252 7253 7254/****************************************************************************/ 7255/* Prints out a l2_fhdr structure. */ 7256/* */ 7257/* Returns: */ 7258/* Nothing. */ 7259/****************************************************************************/ --- 347 unchanged lines hidden (view full) --- 7607 7608 BCE_PRINTF( 7609 "----------------------------" 7610 "----------------" 7611 "----------------------------\n"); 7612} 7613 7614 | 7378 7379 7380/****************************************************************************/ 7381/* Prints out a l2_fhdr structure. */ 7382/* */ 7383/* Returns: */ 7384/* Nothing. */ 7385/****************************************************************************/ --- 347 unchanged lines hidden (view full) --- 7733 7734 BCE_PRINTF( 7735 "----------------------------" 7736 "----------------" 7737 "----------------------------\n"); 7738} 7739 7740 |
7741#ifdef BCE_USE_SPLIT_HEADER |
|
7615/****************************************************************************/ 7616/* Prints out the page chain. */ 7617/* */ 7618/* Returns: */ 7619/* Nothing. */ 7620/****************************************************************************/ 7621static void 7622bce_dump_pg_chain(struct bce_softc *sc, u16 pg_prod, int count) --- 27 unchanged lines hidden (view full) --- 7650 pg_prod = PG_CHAIN_IDX(pg_prod + 1); 7651 } 7652 7653 BCE_PRINTF( 7654 "----------------------------" 7655 "----------------" 7656 "----------------------------\n"); 7657} | 7742/****************************************************************************/ 7743/* Prints out the page chain. */ 7744/* */ 7745/* Returns: */ 7746/* Nothing. */ 7747/****************************************************************************/ 7748static void 7749bce_dump_pg_chain(struct bce_softc *sc, u16 pg_prod, int count) --- 27 unchanged lines hidden (view full) --- 7777 pg_prod = PG_CHAIN_IDX(pg_prod + 1); 7778 } 7779 7780 BCE_PRINTF( 7781 "----------------------------" 7782 "----------------" 7783 "----------------------------\n"); 7784} |
7785#endif |
|
7658 7659 7660/****************************************************************************/ 7661/* Prints out the status block from host memory. */ 7662/* */ 7663/* Returns: */ 7664/* Nothing. */ 7665/****************************************************************************/ --- 420 unchanged lines hidden (view full) --- 8086 val_hi, val_lo); 8087 8088 val_hi = BCE_ADDR_HI(sc->rx_bd_chain); 8089 val_lo = BCE_ADDR_LO(sc->rx_bd_chain); 8090 BCE_PRINTF( 8091 "0x%08X:%08X - (sc->rx_bd_chain) rx_bd chain virtual address\n", 8092 val_hi, val_lo); 8093 | 7786 7787 7788/****************************************************************************/ 7789/* Prints out the status block from host memory. */ 7790/* */ 7791/* Returns: */ 7792/* Nothing. */ 7793/****************************************************************************/ --- 420 unchanged lines hidden (view full) --- 8214 val_hi, val_lo); 8215 8216 val_hi = BCE_ADDR_HI(sc->rx_bd_chain); 8217 val_lo = BCE_ADDR_LO(sc->rx_bd_chain); 8218 BCE_PRINTF( 8219 "0x%08X:%08X - (sc->rx_bd_chain) rx_bd chain virtual address\n", 8220 val_hi, val_lo); 8221 |
8222#ifdef BCE_USE_SPLIT_HEADER |
|
8094 val_hi = BCE_ADDR_HI(sc->pg_bd_chain); 8095 val_lo = BCE_ADDR_LO(sc->pg_bd_chain); 8096 BCE_PRINTF( 8097 "0x%08X:%08X - (sc->pg_bd_chain) page chain virtual address\n", 8098 val_hi, val_lo); | 8223 val_hi = BCE_ADDR_HI(sc->pg_bd_chain); 8224 val_lo = BCE_ADDR_LO(sc->pg_bd_chain); 8225 BCE_PRINTF( 8226 "0x%08X:%08X - (sc->pg_bd_chain) page chain virtual address\n", 8227 val_hi, val_lo); |
8228#endif |
|
8099 8100 val_hi = BCE_ADDR_HI(sc->tx_mbuf_ptr); 8101 val_lo = BCE_ADDR_LO(sc->tx_mbuf_ptr); 8102 BCE_PRINTF( 8103 "0x%08X:%08X - (sc->tx_mbuf_ptr) tx mbuf chain virtual address\n", 8104 val_hi, val_lo); 8105 8106 val_hi = BCE_ADDR_HI(sc->rx_mbuf_ptr); 8107 val_lo = BCE_ADDR_LO(sc->rx_mbuf_ptr); 8108 BCE_PRINTF( 8109 "0x%08X:%08X - (sc->rx_mbuf_ptr) rx mbuf chain virtual address\n", 8110 val_hi, val_lo); 8111 | 8229 8230 val_hi = BCE_ADDR_HI(sc->tx_mbuf_ptr); 8231 val_lo = BCE_ADDR_LO(sc->tx_mbuf_ptr); 8232 BCE_PRINTF( 8233 "0x%08X:%08X - (sc->tx_mbuf_ptr) tx mbuf chain virtual address\n", 8234 val_hi, val_lo); 8235 8236 val_hi = BCE_ADDR_HI(sc->rx_mbuf_ptr); 8237 val_lo = BCE_ADDR_LO(sc->rx_mbuf_ptr); 8238 BCE_PRINTF( 8239 "0x%08X:%08X - (sc->rx_mbuf_ptr) rx mbuf chain virtual address\n", 8240 val_hi, val_lo); 8241 |
8242#ifdef BCE_USE_SPLIT_HEADER |
|
8112 val_hi = BCE_ADDR_HI(sc->pg_mbuf_ptr); 8113 val_lo = BCE_ADDR_LO(sc->pg_mbuf_ptr); 8114 BCE_PRINTF( 8115 "0x%08X:%08X - (sc->pg_mbuf_ptr) page mbuf chain virtual address\n", 8116 val_hi, val_lo); | 8243 val_hi = BCE_ADDR_HI(sc->pg_mbuf_ptr); 8244 val_lo = BCE_ADDR_LO(sc->pg_mbuf_ptr); 8245 BCE_PRINTF( 8246 "0x%08X:%08X - (sc->pg_mbuf_ptr) page mbuf chain virtual address\n", 8247 val_hi, val_lo); |
8248#endif |
|
8117 8118 BCE_PRINTF(" 0x%08X - (sc->interrupts_generated) h/w intrs\n", 8119 sc->interrupts_generated); 8120 8121 BCE_PRINTF(" 0x%08X - (sc->rx_interrupts) rx interrupts handled\n", 8122 sc->rx_interrupts); 8123 8124 BCE_PRINTF(" 0x%08X - (sc->tx_interrupts) tx interrupts handled\n", --- 30 unchanged lines hidden (view full) --- 8155 sc->rx_prod_bseq); 8156 8157 BCE_PRINTF(" 0x%08X - (sc->debug_rx_mbuf_alloc) rx mbufs allocated\n", 8158 sc->debug_rx_mbuf_alloc); 8159 8160 BCE_PRINTF(" 0x%08X - (sc->free_rx_bd) free rx_bd's\n", 8161 sc->free_rx_bd); 8162 | 8249 8250 BCE_PRINTF(" 0x%08X - (sc->interrupts_generated) h/w intrs\n", 8251 sc->interrupts_generated); 8252 8253 BCE_PRINTF(" 0x%08X - (sc->rx_interrupts) rx interrupts handled\n", 8254 sc->rx_interrupts); 8255 8256 BCE_PRINTF(" 0x%08X - (sc->tx_interrupts) tx interrupts handled\n", --- 30 unchanged lines hidden (view full) --- 8287 sc->rx_prod_bseq); 8288 8289 BCE_PRINTF(" 0x%08X - (sc->debug_rx_mbuf_alloc) rx mbufs allocated\n", 8290 sc->debug_rx_mbuf_alloc); 8291 8292 BCE_PRINTF(" 0x%08X - (sc->free_rx_bd) free rx_bd's\n", 8293 sc->free_rx_bd); 8294 |
8295#ifdef BCE_USE_SPLIT_HEADER |
|
8163 BCE_PRINTF(" 0x%04X(0x%04X) - (sc->pg_prod) page producer index\n", 8164 sc->pg_prod, (u16) PG_CHAIN_IDX(sc->pg_prod)); 8165 8166 BCE_PRINTF(" 0x%04X(0x%04X) - (sc->pg_cons) page consumer index\n", 8167 sc->pg_cons, (u16) PG_CHAIN_IDX(sc->pg_cons)); 8168 8169 BCE_PRINTF(" 0x%08X - (sc->debug_pg_mbuf_alloc) page mbufs allocated\n", 8170 sc->debug_pg_mbuf_alloc); 8171 8172 BCE_PRINTF(" 0x%08X - (sc->free_pg_bd) free page rx_bd's\n", 8173 sc->free_pg_bd); 8174 8175 BCE_PRINTF("0x%08X/%08X - (sc->pg_low_watermark) page low watermark\n", 8176 sc->pg_low_watermark, sc->max_pg_bd); | 8296 BCE_PRINTF(" 0x%04X(0x%04X) - (sc->pg_prod) page producer index\n", 8297 sc->pg_prod, (u16) PG_CHAIN_IDX(sc->pg_prod)); 8298 8299 BCE_PRINTF(" 0x%04X(0x%04X) - (sc->pg_cons) page consumer index\n", 8300 sc->pg_cons, (u16) PG_CHAIN_IDX(sc->pg_cons)); 8301 8302 BCE_PRINTF(" 0x%08X - (sc->debug_pg_mbuf_alloc) page mbufs allocated\n", 8303 sc->debug_pg_mbuf_alloc); 8304 8305 BCE_PRINTF(" 0x%08X - (sc->free_pg_bd) free page rx_bd's\n", 8306 sc->free_pg_bd); 8307 8308 BCE_PRINTF("0x%08X/%08X - (sc->pg_low_watermark) page low watermark\n", 8309 sc->pg_low_watermark, sc->max_pg_bd); |
8310#endif |
|
8177 8178 BCE_PRINTF(" 0x%08X - (sc->mbuf_alloc_failed) " 8179 "mbuf alloc failures\n", 8180 sc->mbuf_alloc_failed); 8181 8182 BCE_PRINTF(" 0x%08X - (sc->debug_mbuf_sim_alloc_failed) " 8183 "simulated mbuf alloc failures\n", 8184 sc->debug_mbuf_sim_alloc_failed); --- 292 unchanged lines hidden (view full) --- 8477 * Unreachable code to silence compiler warnings 8478 * about unused functions. 8479 */ 8480 if (0) { 8481 bce_freeze_controller(sc); 8482 bce_unfreeze_controller(sc); 8483 bce_dump_txbd(sc, 0, NULL); 8484 bce_dump_rxbd(sc, 0, NULL); | 8311 8312 BCE_PRINTF(" 0x%08X - (sc->mbuf_alloc_failed) " 8313 "mbuf alloc failures\n", 8314 sc->mbuf_alloc_failed); 8315 8316 BCE_PRINTF(" 0x%08X - (sc->debug_mbuf_sim_alloc_failed) " 8317 "simulated mbuf alloc failures\n", 8318 sc->debug_mbuf_sim_alloc_failed); --- 292 unchanged lines hidden (view full) --- 8611 * Unreachable code to silence compiler warnings 8612 * about unused functions. 8613 */ 8614 if (0) { 8615 bce_freeze_controller(sc); 8616 bce_unfreeze_controller(sc); 8617 bce_dump_txbd(sc, 0, NULL); 8618 bce_dump_rxbd(sc, 0, NULL); |
8485 bce_dump_pgbd(sc, 0, NULL); | |
8486 bce_dump_tx_mbuf_chain(sc, 0, USABLE_TX_BD); 8487 bce_dump_rx_mbuf_chain(sc, 0, USABLE_RX_BD); | 8619 bce_dump_tx_mbuf_chain(sc, 0, USABLE_TX_BD); 8620 bce_dump_rx_mbuf_chain(sc, 0, USABLE_RX_BD); |
8488 bce_dump_pg_mbuf_chain(sc, 0, USABLE_PG_BD); | |
8489 bce_dump_l2fhdr(sc, 0, NULL); 8490 bce_dump_ctx(sc, RX_CID); 8491 bce_dump_ftqs(sc); 8492 bce_dump_tx_chain(sc, 0, USABLE_TX_BD); 8493 bce_dump_rx_chain(sc, 0, USABLE_RX_BD); | 8621 bce_dump_l2fhdr(sc, 0, NULL); 8622 bce_dump_ctx(sc, RX_CID); 8623 bce_dump_ftqs(sc); 8624 bce_dump_tx_chain(sc, 0, USABLE_TX_BD); 8625 bce_dump_rx_chain(sc, 0, USABLE_RX_BD); |
8494 bce_dump_pg_chain(sc, 0, USABLE_PG_BD); | |
8495 bce_dump_status_block(sc); 8496 bce_dump_stats_block(sc); 8497 bce_dump_driver_state(sc); 8498 bce_dump_hw_state(sc); 8499 bce_dump_bc_state(sc); 8500 bce_dump_txp_state(sc); 8501 bce_dump_rxp_state(sc); 8502 bce_dump_tpat_state(sc); | 8626 bce_dump_status_block(sc); 8627 bce_dump_stats_block(sc); 8628 bce_dump_driver_state(sc); 8629 bce_dump_hw_state(sc); 8630 bce_dump_bc_state(sc); 8631 bce_dump_txp_state(sc); 8632 bce_dump_rxp_state(sc); 8633 bce_dump_tpat_state(sc); |
8634#ifdef BCE_USE_SPLIT_HEADER 8635 bce_dump_pgbd(sc, 0, NULL); 8636 bce_dump_pg_mbuf_chain(sc, 0, USABLE_PG_BD); 8637 bce_dump_pg_chain(sc, 0, USABLE_PG_BD); 8638#endif |
|
8503 } 8504 8505 bce_dump_status_block(sc); 8506 bce_dump_driver_state(sc); 8507 8508 /* Call the debugger. */ 8509 breakpoint(); 8510 8511 return; 8512} 8513#endif 8514 | 8639 } 8640 8641 bce_dump_status_block(sc); 8642 bce_dump_driver_state(sc); 8643 8644 /* Call the debugger. */ 8645 breakpoint(); 8646 8647 return; 8648} 8649#endif 8650 |