From owner-svn-src-all@FreeBSD.ORG Thu Apr 15 19:31:21 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6C2F11065672; Thu, 15 Apr 2010 19:31:21 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 594CF8FC29; Thu, 15 Apr 2010 19:31:21 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o3FJVLgH096539; Thu, 15 Apr 2010 19:31:21 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o3FJVLgF096536; Thu, 15 Apr 2010 19:31:21 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201004151931.o3FJVLgF096536@svn.freebsd.org> From: Pyun YongHyeon Date: Thu, 15 Apr 2010 19:31:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r206683 - stable/7/sys/dev/bce X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Apr 2010 19:31:21 -0000 Author: yongari Date: Thu Apr 15 19:31:21 2010 New Revision: 206683 URL: http://svn.freebsd.org/changeset/base/206683 Log: MFC r206268 - Fixed 5708S 2.5G support broken in last commit. - Added some new debug helper routines to systcl. - Fixed many of the style(9) violations that have crept into the code due to my use of a "smart" editor. Modified: stable/7/sys/dev/bce/if_bce.c stable/7/sys/dev/bce/if_bcereg.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/bce/if_bce.c ============================================================================== --- stable/7/sys/dev/bce/if_bce.c Thu Apr 15 19:29:56 2010 (r206682) +++ stable/7/sys/dev/bce/if_bce.c Thu Apr 15 19:31:21 2010 (r206683) @@ -39,8 +39,8 @@ __FBSDID("$FreeBSD$"); * BCM5708S B1, B2 * BCM5709C A1, C0 * BCM5709S A1, C0 - * BCM5716C C0 - * BCM5716S C0 + * BCM5716C C0 + * BCM5716S C0 * * The following controllers are not supported by this driver: * BCM5706C A0, A1 (pre-production) @@ -277,37 +277,41 @@ static struct flash_spec flash_5709 = { /****************************************************************************/ /* FreeBSD device entry points. */ /****************************************************************************/ -static int bce_probe (device_t); -static int bce_attach (device_t); -static int bce_detach (device_t); -static int bce_shutdown (device_t); +static int bce_probe (device_t); +static int bce_attach (device_t); +static int bce_detach (device_t); +static int bce_shutdown (device_t); /****************************************************************************/ /* BCE Debug Data Structure Dump Routines */ /****************************************************************************/ #ifdef BCE_DEBUG -static u32 bce_reg_rd (struct bce_softc *, u32); -static void bce_reg_wr (struct bce_softc *, u32, u32); -static void bce_reg_wr16 (struct bce_softc *, u32, u16); -static u32 bce_ctx_rd (struct bce_softc *, u32, u32); -static void bce_dump_enet (struct bce_softc *, struct mbuf *); -static void bce_dump_mbuf (struct bce_softc *, struct mbuf *); +static u32 bce_reg_rd (struct bce_softc *, u32); +static void bce_reg_wr (struct bce_softc *, u32, u32); +static void bce_reg_wr16 (struct bce_softc *, u32, u16); +static u32 bce_ctx_rd (struct bce_softc *, u32, u32); +static void bce_dump_enet (struct bce_softc *, struct mbuf *); +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_JUMBO_HDRSPLIT 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 *); +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_JUMBO_HDRSPLIT -static void bce_dump_pgbd (struct bce_softc *, int, struct rx_bd *); +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 *); -static void bce_dump_ctx (struct bce_softc *, u16); -static void bce_dump_ftqs (struct bce_softc *); +static void bce_dump_l2fhdr (struct bce_softc *, + int, struct l2_fhdr *); +static void bce_dump_ctx (struct bce_softc *, u16); +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); +static void bce_dump_rx_bd_chain (struct bce_softc *, u16, int); #ifdef BCE_JUMBO_HDRSPLIT static void bce_dump_pg_chain (struct bce_softc *, u16, int); #endif @@ -315,7 +319,7 @@ static void bce_dump_status_block (struc static void bce_dump_stats_block (struct bce_softc *); static void bce_dump_driver_state (struct bce_softc *); static void bce_dump_hw_state (struct bce_softc *); -static void bce_dump_mq_regs (struct bce_softc *); +static void bce_dump_mq_regs (struct bce_softc *); static void bce_dump_bc_state (struct bce_softc *); static void bce_dump_txp_state (struct bce_softc *, int); static void bce_dump_rxp_state (struct bce_softc *, int); @@ -323,18 +327,18 @@ static void bce_dump_tpat_state (struct static void bce_dump_cp_state (struct bce_softc *, int); static void bce_dump_com_state (struct bce_softc *, int); static void bce_dump_rv2p_state (struct bce_softc *); -static void bce_breakpoint (struct bce_softc *); +static void bce_breakpoint (struct bce_softc *); #endif /****************************************************************************/ /* BCE Register/Memory Access Routines */ /****************************************************************************/ -static u32 bce_reg_rd_ind (struct bce_softc *, u32); -static void bce_reg_wr_ind (struct bce_softc *, u32, u32); -static void bce_shmem_wr (struct bce_softc *, u32, u32); -static u32 bce_shmem_rd (struct bce_softc *, u32); -static void bce_ctx_wr (struct bce_softc *, u32, u32, u32); +static u32 bce_reg_rd_ind (struct bce_softc *, u32); +static void bce_reg_wr_ind (struct bce_softc *, u32, u32); +static void bce_shmem_wr (struct bce_softc *, u32, u32); +static u32 bce_shmem_rd (struct bce_softc *, u32); +static void bce_ctx_wr (struct bce_softc *, u32, u32, u32); static int bce_miibus_read_reg (device_t, int, int); static int bce_miibus_write_reg (device_t, int, int, int); static void bce_miibus_statchg (device_t); @@ -346,96 +350,101 @@ static void bce_miibus_statchg (device_ static int bce_acquire_nvram_lock (struct bce_softc *); static int bce_release_nvram_lock (struct bce_softc *); static void bce_enable_nvram_access (struct bce_softc *); -static void bce_disable_nvram_access(struct bce_softc *); +static void bce_disable_nvram_access (struct bce_softc *); static int bce_nvram_read_dword (struct bce_softc *, u32, u8 *, u32); -static int bce_init_nvram (struct bce_softc *); -static int bce_nvram_read (struct bce_softc *, u32, u8 *, int); -static int bce_nvram_test (struct bce_softc *); +static int bce_init_nvram (struct bce_softc *); +static int bce_nvram_read (struct bce_softc *, u32, u8 *, int); +static int bce_nvram_test (struct bce_softc *); #ifdef BCE_NVRAM_WRITE_SUPPORT static int bce_enable_nvram_write (struct bce_softc *); static void bce_disable_nvram_write (struct bce_softc *); static int bce_nvram_erase_page (struct bce_softc *, u32); static int bce_nvram_write_dword (struct bce_softc *, u32, u8 *, u32); -static int bce_nvram_write (struct bce_softc *, u32, u8 *, int); +static int bce_nvram_write (struct bce_softc *, u32, u8 *, int); #endif /****************************************************************************/ /* */ /****************************************************************************/ -static void bce_get_media (struct bce_softc *); -static void bce_init_media (struct bce_softc *); -static void bce_dma_map_addr (void *, bus_dma_segment_t *, int, int); -static int bce_dma_alloc (device_t); -static void bce_dma_free (struct bce_softc *); +static void bce_get_media (struct bce_softc *); +static void bce_init_media (struct bce_softc *); +static void bce_dma_map_addr (void *, + bus_dma_segment_t *, int, int); +static int bce_dma_alloc (device_t); +static void bce_dma_free (struct bce_softc *); static void bce_release_resources (struct bce_softc *); /****************************************************************************/ /* BCE Firmware Synchronization and Load */ /****************************************************************************/ -static int bce_fw_sync (struct bce_softc *, u32); +static int bce_fw_sync (struct bce_softc *, u32); static void bce_load_rv2p_fw (struct bce_softc *, u32 *, u32, u32); -static void bce_load_cpu_fw (struct bce_softc *, struct cpu_reg *, struct fw_info *); -static void bce_start_cpu (struct bce_softc *, struct cpu_reg *); -static void bce_halt_cpu (struct bce_softc *, struct cpu_reg *); -static void bce_start_rxp_cpu (struct bce_softc *); +static void bce_load_cpu_fw (struct bce_softc *, + struct cpu_reg *, struct fw_info *); +static void bce_start_cpu (struct bce_softc *, struct cpu_reg *); +static void bce_halt_cpu (struct bce_softc *, struct cpu_reg *); +static void bce_start_rxp_cpu (struct bce_softc *); static void bce_init_rxp_cpu (struct bce_softc *); static void bce_init_txp_cpu (struct bce_softc *); static void bce_init_tpat_cpu (struct bce_softc *); -static void bce_init_cp_cpu (struct bce_softc *); +static void bce_init_cp_cpu (struct bce_softc *); static void bce_init_com_cpu (struct bce_softc *); -static void bce_init_cpus (struct bce_softc *); +static void bce_init_cpus (struct bce_softc *); static void bce_print_adapter_info (struct bce_softc *); static void bce_probe_pci_caps (device_t, struct bce_softc *); -static void bce_stop (struct bce_softc *); -static int bce_reset (struct bce_softc *, u32); -static int bce_chipinit (struct bce_softc *); -static int bce_blockinit (struct bce_softc *); +static void bce_stop (struct bce_softc *); +static int bce_reset (struct bce_softc *, u32); +static int bce_chipinit (struct bce_softc *); +static int bce_blockinit (struct bce_softc *); static int bce_init_tx_chain (struct bce_softc *); static void bce_free_tx_chain (struct bce_softc *); -static int bce_get_rx_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *, u32 *); +static int bce_get_rx_buf (struct bce_softc *, + struct mbuf *, u16 *, u16 *, u32 *); static int bce_init_rx_chain (struct bce_softc *); static void bce_fill_rx_chain (struct bce_softc *); static void bce_free_rx_chain (struct bce_softc *); #ifdef BCE_JUMBO_HDRSPLIT -static int bce_get_pg_buf (struct bce_softc *, struct mbuf *, u16 *, u16 *); +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 *); static void bce_free_pg_chain (struct bce_softc *); #endif -static struct mbuf *bce_tso_setup (struct bce_softc *, struct mbuf **, u16 *); -static int bce_tx_encap (struct bce_softc *, struct mbuf **); +static struct mbuf *bce_tso_setup (struct bce_softc *, + struct mbuf **, u16 *); +static int bce_tx_encap (struct bce_softc *, struct mbuf **); static void bce_start_locked (struct ifnet *); -static void bce_start (struct ifnet *); -static int bce_ioctl (struct ifnet *, u_long, caddr_t); -static void bce_watchdog (struct bce_softc *); -static int bce_ifmedia_upd (struct ifnet *); +static void bce_start (struct ifnet *); +static int bce_ioctl (struct ifnet *, u_long, caddr_t); +static void bce_watchdog (struct bce_softc *); +static int bce_ifmedia_upd (struct ifnet *); static void bce_ifmedia_upd_locked (struct ifnet *); -static void bce_ifmedia_sts (struct ifnet *, struct ifmediareq *); -static void bce_init_locked (struct bce_softc *); -static void bce_init (void *); +static void bce_ifmedia_sts (struct ifnet *, struct ifmediareq *); +static void bce_init_locked (struct bce_softc *); +static void bce_init (void *); static void bce_mgmt_init_locked (struct bce_softc *sc); -static void bce_init_ctx (struct bce_softc *); +static void bce_init_ctx (struct bce_softc *); static void bce_get_mac_addr (struct bce_softc *); static void bce_set_mac_addr (struct bce_softc *); -static void bce_phy_intr (struct bce_softc *); -static inline u16 bce_get_hw_rx_cons(struct bce_softc *); -static void bce_rx_intr (struct bce_softc *); -static void bce_tx_intr (struct bce_softc *); +static void bce_phy_intr (struct bce_softc *); +static inline u16 bce_get_hw_rx_cons (struct bce_softc *); +static void bce_rx_intr (struct bce_softc *); +static void bce_tx_intr (struct bce_softc *); static void bce_disable_intr (struct bce_softc *); -static void bce_enable_intr (struct bce_softc *, int); +static void bce_enable_intr (struct bce_softc *, int); -static void bce_intr (void *); -static void bce_set_rx_mode (struct bce_softc *); +static void bce_intr (void *); +static void bce_set_rx_mode (struct bce_softc *); static void bce_stats_update (struct bce_softc *); -static void bce_tick (void *); -static void bce_pulse (void *); -static void bce_add_sysctls (struct bce_softc *); +static void bce_tick (void *); +static void bce_pulse (void *); +static void bce_add_sysctls (struct bce_softc *); /****************************************************************************/ @@ -540,15 +549,15 @@ bce_probe(device_t dev) sdid = pci_get_subdevice(dev); DBPRINT(sc, BCE_EXTREME_LOAD, - "%s(); VID = 0x%04X, DID = 0x%04X, SVID = 0x%04X, " - "SDID = 0x%04X\n", __FUNCTION__, vid, did, svid, sdid); + "%s(); VID = 0x%04X, DID = 0x%04X, SVID = 0x%04X, " + "SDID = 0x%04X\n", __FUNCTION__, vid, did, svid, sdid); /* Look through the list of known devices for a match. */ while(t->bce_name != NULL) { if ((vid == t->bce_vid) && (did == t->bce_did) && - ((svid == t->bce_svid) || (t->bce_svid == PCI_ANY_ID)) && - ((sdid == t->bce_sdid) || (t->bce_sdid == PCI_ANY_ID))) { + ((svid == t->bce_svid) || (t->bce_svid == PCI_ANY_ID)) && + ((sdid == t->bce_sdid) || (t->bce_sdid == PCI_ANY_ID))) { descbuf = malloc(BCE_DEVDESC_MAX, M_TEMP, M_NOWAIT); @@ -557,8 +566,8 @@ bce_probe(device_t dev) /* Print out the device identity. */ snprintf(descbuf, BCE_DEVDESC_MAX, "%s (%c%d)", - t->bce_name, - (((pci_read_config(dev, PCIR_REVID, 4) & 0xf0) >> 4) + 'A'), + t->bce_name, (((pci_read_config(dev, + PCIR_REVID, 4) & 0xf0) >> 4) + 'A'), (pci_read_config(dev, PCIR_REVID, 4) & 0xf)); device_set_desc_copy(dev, descbuf); @@ -590,21 +599,21 @@ bce_print_adapter_info(struct bce_softc BCE_PRINTF("ASIC (0x%08X); ", sc->bce_chipid); printf("Rev (%c%d); ", ((BCE_CHIP_ID(sc) & 0xf000) >> 12) + 'A', - ((BCE_CHIP_ID(sc) & 0x0ff0) >> 4)); + ((BCE_CHIP_ID(sc) & 0x0ff0) >> 4)); /* Bus info. */ if (sc->bce_flags & BCE_PCIE_FLAG) { printf("Bus (PCIe x%d, ", sc->link_width); switch (sc->link_speed) { - case 1: printf("2.5Gbps); "); break; - case 2: printf("5Gbps); "); break; - default: printf("Unknown link speed); "); + case 1: printf("2.5Gbps); "); break; + case 2: printf("5Gbps); "); break; + default: printf("Unknown link speed); "); } } else { printf("Bus (PCI%s, %s, %dMHz); ", - ((sc->bce_flags & BCE_PCIX_FLAG) ? "-X" : ""), - ((sc->bce_flags & BCE_PCI_32BIT_FLAG) ? "32-bit" : "64-bit"), - sc->bus_speed_mhz); + ((sc->bce_flags & BCE_PCIX_FLAG) ? "-X" : ""), + ((sc->bce_flags & BCE_PCI_32BIT_FLAG) ? + "32-bit" : "64-bit"), sc->bus_speed_mhz); } /* Firmware version and device features. */ @@ -612,30 +621,30 @@ bce_print_adapter_info(struct bce_softc #ifdef BCE_JUMBO_HDRSPLIT printf("SPLT"); - i++; + i++; #endif - if (sc->bce_flags & BCE_USING_MSI_FLAG) { - if (i > 0) printf("|"); + if (sc->bce_flags & BCE_USING_MSI_FLAG) { + if (i > 0) printf("|"); printf("MSI"); i++; - } + } - if (sc->bce_flags & BCE_USING_MSIX_FLAG) { - if (i > 0) printf("|"); + if (sc->bce_flags & BCE_USING_MSIX_FLAG) { + if (i > 0) printf("|"); printf("MSI-X"); i++; - } + } - if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) { - if (i > 0) printf("|"); + if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG) { + if (i > 0) printf("|"); printf("2.5G"); i++; - } + } - if (sc->bce_flags & BCE_MFW_ENABLE_FLAG) { - if (i > 0) printf("|"); - printf("MFW); MFW (%s)\n", sc->bce_mfw_ver); - } else { - printf(")\n"); - } + if (sc->bce_flags & BCE_MFW_ENABLE_FLAG) { + if (i > 0) printf("|"); + printf("MFW); MFW (%s)\n", sc->bce_mfw_ver); + } else { + printf(")\n"); + } DBEXIT(BCE_VERBOSE_LOAD); } @@ -667,8 +676,8 @@ bce_probe_pci_caps(device_t dev, struct if (pci_find_extcap(dev, PCIY_EXPRESS, ®) == 0) { if (reg != 0) { u16 link_status = pci_read_config(dev, reg + 0x12, 2); - DBPRINT(sc, BCE_INFO_LOAD, "PCIe link_status = 0x%08X\n", - link_status); + DBPRINT(sc, BCE_INFO_LOAD, "PCIe link_status = " + "0x%08X\n", link_status); sc->link_speed = link_status & 0xf; sc->link_width = (link_status >> 4) & 0x3f; sc->bce_cap_flags |= BCE_PCIE_CAPABLE_FLAG; @@ -730,7 +739,7 @@ bce_attach(device_t dev) if (sc->bce_res_mem == NULL) { BCE_PRINTF("%s(%d): PCI memory allocation failed\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; } @@ -801,14 +810,14 @@ bce_attach(device_t dev) } sc->bce_res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, - &rid, RF_SHAREABLE | RF_ACTIVE); + &rid, RF_SHAREABLE | RF_ACTIVE); sc->bce_irq_rid = rid; /* Report any IRQ allocation errors. */ if (sc->bce_res_irq == NULL) { BCE_PRINTF("%s(%d): PCI map interrupt failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; } @@ -823,28 +832,28 @@ bce_attach(device_t dev) * valid until this is done. */ pci_write_config(dev, BCE_PCICFG_MISC_CONFIG, - BCE_PCICFG_MISC_CONFIG_REG_WINDOW_ENA | - BCE_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP, 4); + BCE_PCICFG_MISC_CONFIG_REG_WINDOW_ENA | + BCE_PCICFG_MISC_CONFIG_TARGET_MB_WORD_SWAP, 4); /* Save ASIC revsion info. */ sc->bce_chipid = REG_RD(sc, BCE_MISC_ID); /* Weed out any non-production controller revisions. */ switch(BCE_CHIP_ID(sc)) { - case BCE_CHIP_ID_5706_A0: - case BCE_CHIP_ID_5706_A1: - case BCE_CHIP_ID_5708_A0: - case BCE_CHIP_ID_5708_B0: - case BCE_CHIP_ID_5709_A0: - case BCE_CHIP_ID_5709_B0: - case BCE_CHIP_ID_5709_B1: - case BCE_CHIP_ID_5709_B2: - BCE_PRINTF("%s(%d): Unsupported controller revision (%c%d)!\n", - __FILE__, __LINE__, - (((pci_read_config(dev, PCIR_REVID, 4) & 0xf0) >> 4) + 'A'), - (pci_read_config(dev, PCIR_REVID, 4) & 0xf)); - rc = ENODEV; - goto bce_attach_fail; + case BCE_CHIP_ID_5706_A0: + case BCE_CHIP_ID_5706_A1: + case BCE_CHIP_ID_5708_A0: + case BCE_CHIP_ID_5708_B0: + case BCE_CHIP_ID_5709_A0: + case BCE_CHIP_ID_5709_B0: + case BCE_CHIP_ID_5709_B1: + case BCE_CHIP_ID_5709_B2: + BCE_PRINTF("%s(%d): Unsupported controller revision (%c%d)!\n", + __FILE__, __LINE__, + (((pci_read_config(dev, PCIR_REVID, 4) & 0xf0) >> 4) + 'A'), + (pci_read_config(dev, PCIR_REVID, 4) & 0xf)); + rc = ENODEV; + goto bce_attach_fail; } /* @@ -866,58 +875,67 @@ bce_attach(device_t dev) if ((val & BCE_SHM_HDR_SIGNATURE_SIG_MASK) == BCE_SHM_HDR_SIGNATURE_SIG) /* Multi-port devices use different offsets in shared memory. */ sc->bce_shmem_base = REG_RD_IND(sc, BCE_SHM_HDR_ADDR_0 + - (pci_get_function(sc->bce_dev) << 2)); + (pci_get_function(sc->bce_dev) << 2)); else sc->bce_shmem_base = HOST_VIEW_SHMEM_BASE; DBPRINT(sc, BCE_VERBOSE_FIRMWARE, "%s(): bce_shmem_base = 0x%08X\n", - __FUNCTION__, sc->bce_shmem_base); + __FUNCTION__, sc->bce_shmem_base); /* Fetch the bootcode revision. */ - val = bce_shmem_rd(sc, BCE_DEV_INFO_BC_REV); - for (int i = 0, j = 0; i < 3; i++) { - u8 num; - - num = (u8) (val >> (24 - (i * 8))); - for (int k = 100, skip0 = 1; k >= 1; num %= k, k /= 10) { - if (num >= k || !skip0 || k == 1) { - sc->bce_bc_ver[j++] = (num / k) + '0'; - skip0 = 0; - } - } - if (i != 2) - sc->bce_bc_ver[j++] = '.'; - } - - /* Check if any management firwmare is running. */ - val = bce_shmem_rd(sc, BCE_PORT_FEATURE); - if (val & BCE_PORT_FEATURE_ASF_ENABLED) { - sc->bce_flags |= BCE_MFW_ENABLE_FLAG; - - /* Allow time for firmware to enter the running state. */ - for (int i = 0; i < 30; i++) { - val = bce_shmem_rd(sc, BCE_BC_STATE_CONDITION); - if (val & BCE_CONDITION_MFW_RUN_MASK) - break; - DELAY(10000); - } - } - - /* Check the current bootcode state. */ - val = bce_shmem_rd(sc, BCE_BC_STATE_CONDITION); - val &= BCE_CONDITION_MFW_RUN_MASK; - if (val != BCE_CONDITION_MFW_RUN_UNKNOWN && - val != BCE_CONDITION_MFW_RUN_NONE) { - u32 addr = bce_shmem_rd(sc, BCE_MFW_VER_PTR); - int i = 0; - - for (int j = 0; j < 3; j++) { - val = bce_reg_rd_ind(sc, addr + j * 4); - val = bswap32(val); - memcpy(&sc->bce_mfw_ver[i], &val, 4); - i += 4; - } - } + val = bce_shmem_rd(sc, BCE_DEV_INFO_BC_REV); + for (int i = 0, j = 0; i < 3; i++) { + u8 num; + + num = (u8) (val >> (24 - (i * 8))); + for (int k = 100, skip0 = 1; k >= 1; num %= k, k /= 10) { + if (num >= k || !skip0 || k == 1) { + sc->bce_bc_ver[j++] = (num / k) + '0'; + skip0 = 0; + } + } + + if (i != 2) + sc->bce_bc_ver[j++] = '.'; + } + + /* Check if any management firwmare is enabled. */ + val = bce_shmem_rd(sc, BCE_PORT_FEATURE); + if (val & BCE_PORT_FEATURE_ASF_ENABLED) { + sc->bce_flags |= BCE_MFW_ENABLE_FLAG; + + /* Allow time for firmware to enter the running state. */ + for (int i = 0; i < 30; i++) { + val = bce_shmem_rd(sc, BCE_BC_STATE_CONDITION); + if (val & BCE_CONDITION_MFW_RUN_MASK) + break; + DELAY(10000); + } + + /* Check if management firmware is running. */ + val = bce_shmem_rd(sc, BCE_BC_STATE_CONDITION); + val &= BCE_CONDITION_MFW_RUN_MASK; + if ((val != BCE_CONDITION_MFW_RUN_UNKNOWN) && + (val != BCE_CONDITION_MFW_RUN_NONE)) { + u32 addr = bce_shmem_rd(sc, BCE_MFW_VER_PTR); + int i = 0; + + /* Read the management firmware version string. */ + for (int j = 0; j < 3; j++) { + val = bce_reg_rd_ind(sc, addr + j * 4); + val = bswap32(val); + memcpy(&sc->bce_mfw_ver[i], &val, 4); + i += 4; + } + } else { + /* May cause firmware synchronization timeouts. */ + BCE_PRINTF("%s(%d): Management firmware enabled " + "but not running!\n", __FILE__, __LINE__); + strcpy(sc->bce_mfw_ver, "NOT RUNNING!"); + + /* ToDo: Any action the driver should take? */ + } + } /* Get PCI bus information (speed and type). */ val = REG_RD(sc, BCE_PCICFG_MISC_STATUS); @@ -964,10 +982,10 @@ bce_attach(device_t dev) if (val & BCE_PCICFG_MISC_STATUS_32BIT_DET) sc->bce_flags |= BCE_PCI_32BIT_FLAG; - /* Reset the controller and announce to bootcode that driver is present. */ + /* Reset controller and announce to bootcode that driver is present. */ if (bce_reset(sc, BCE_DRV_MSG_CODE_RESET)) { BCE_PRINTF("%s(%d): Controller reset failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; } @@ -975,7 +993,7 @@ bce_attach(device_t dev) /* Initialize the controller. */ if (bce_chipinit(sc)) { BCE_PRINTF("%s(%d): Controller initialization failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; } @@ -983,7 +1001,7 @@ bce_attach(device_t dev) /* Perform NVRAM test. */ if (bce_nvram_test(sc)) { BCE_PRINTF("%s(%d): NVRAM test failed!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENXIO; goto bce_attach_fail; } @@ -1024,6 +1042,14 @@ bce_attach(device_t dev) sc->bce_rx_ticks = 18; #endif + /* Not used for L2. */ + sc->bce_comp_prod_trip_int = 0; + sc->bce_comp_prod_trip = 0; + sc->bce_com_ticks_int = 0; + sc->bce_com_ticks = 0; + sc->bce_cmd_ticks_int = 0; + sc->bce_cmd_ticks = 0; + /* Update statistics once every second. */ sc->bce_stats_ticks = 1000000 & 0xffff00; @@ -1507,7 +1533,8 @@ bce_miibus_read_reg(device_t dev, int ph /* Make sure we are accessing the correct PHY address. */ if (phy != sc->bce_phy_addr) { - DBPRINT(sc, BCE_INSANE_PHY, "Invalid PHY address %d for PHY read!\n", phy); + DBPRINT(sc, BCE_INSANE_PHY, "Invalid PHY address %d " + "for PHY read!\n", phy); return(0); } @@ -1533,8 +1560,8 @@ bce_miibus_read_reg(device_t dev, int ph val = BCE_MIPHY(phy) | BCE_MIREG(reg) | - BCE_EMAC_MDIO_COMM_COMMAND_READ | BCE_EMAC_MDIO_COMM_DISEXT | - BCE_EMAC_MDIO_COMM_START_BUSY; + BCE_EMAC_MDIO_COMM_COMMAND_READ | BCE_EMAC_MDIO_COMM_DISEXT | + BCE_EMAC_MDIO_COMM_START_BUSY; REG_WR(sc, BCE_EMAC_MDIO_COMM, val); for (i = 0; i < BCE_PHY_TIMEOUT; i++) { @@ -1552,8 +1579,8 @@ bce_miibus_read_reg(device_t dev, int ph } if (val & BCE_EMAC_MDIO_COMM_START_BUSY) { - BCE_PRINTF("%s(%d): Error: PHY read timeout! phy = %d, reg = 0x%04X\n", - __FILE__, __LINE__, phy, reg); + BCE_PRINTF("%s(%d): Error: PHY read timeout! phy = %d, " + "reg = 0x%04X\n", __FILE__, __LINE__, phy, reg); val = 0x0; } else { val = REG_RD(sc, BCE_EMAC_MDIO_COMM); @@ -1595,17 +1622,18 @@ bce_miibus_write_reg(device_t dev, int p /* Make sure we are accessing the correct PHY address. */ if (phy != sc->bce_phy_addr) { - DBPRINT(sc, BCE_INSANE_PHY, "Invalid PHY address %d for PHY write!\n", phy); + DBPRINT(sc, BCE_INSANE_PHY, "Invalid PHY address %d " + "for PHY write!\n", phy); return(0); } DB_PRINT_PHY_REG(reg, val); - /* - * The 5709S PHY is an IEEE Clause 45 PHY - * with special mappings to work with IEEE - * Clause 22 register accesses. - */ + /* + * The 5709S PHY is an IEEE Clause 45 PHY + * with special mappings to work with IEEE + * Clause 22 register accesses. + */ if ((sc->bce_phy_flags & BCE_PHY_IEEE_CLAUSE_45_FLAG) != 0) { if (reg >= MII_BMCR && reg <= MII_ANLPRNP) reg += 0x10; @@ -1622,8 +1650,8 @@ bce_miibus_write_reg(device_t dev, int p } val1 = BCE_MIPHY(phy) | BCE_MIREG(reg) | val | - BCE_EMAC_MDIO_COMM_COMMAND_WRITE | - BCE_EMAC_MDIO_COMM_START_BUSY | BCE_EMAC_MDIO_COMM_DISEXT; + BCE_EMAC_MDIO_COMM_COMMAND_WRITE | + BCE_EMAC_MDIO_COMM_START_BUSY | BCE_EMAC_MDIO_COMM_DISEXT; REG_WR(sc, BCE_EMAC_MDIO_COMM, val1); for (i = 0; i < BCE_PHY_TIMEOUT; i++) { @@ -1638,7 +1666,7 @@ bce_miibus_write_reg(device_t dev, int p if (val1 & BCE_EMAC_MDIO_COMM_START_BUSY) BCE_PRINTF("%s(%d): PHY write timeout!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); if (sc->bce_phy_flags & BCE_PHY_INT_MODE_AUTO_POLLING_FLAG) { val1 = REG_RD(sc, BCE_EMAC_MDIO_MODE); @@ -2653,18 +2681,22 @@ bce_get_media(struct bce_softc *sc) * for Copper or SerDes operation. */ if (bond_id == BCE_MISC_DUAL_MEDIA_CTRL_BOND_ID_C) { - DBPRINT(sc, BCE_INFO_LOAD, "5709 bonded for copper.\n"); + DBPRINT(sc, BCE_INFO_LOAD, "5709 bonded " + "for copper.\n"); goto bce_get_media_exit; } else if (bond_id == BCE_MISC_DUAL_MEDIA_CTRL_BOND_ID_S) { - DBPRINT(sc, BCE_INFO_LOAD, "5709 bonded for dual media.\n"); + DBPRINT(sc, BCE_INFO_LOAD, "5709 bonded " + "for dual media.\n"); sc->bce_phy_flags |= BCE_PHY_SERDES_FLAG; goto bce_get_media_exit; } if (val & BCE_MISC_DUAL_MEDIA_CTRL_STRAP_OVERRIDE) - strap = (val & BCE_MISC_DUAL_MEDIA_CTRL_PHY_CTRL) >> 21; + strap = (val & + BCE_MISC_DUAL_MEDIA_CTRL_PHY_CTRL) >> 21; else - strap = (val & BCE_MISC_DUAL_MEDIA_CTRL_PHY_CTRL_STRAP) >> 8; + strap = (val & + BCE_MISC_DUAL_MEDIA_CTRL_PHY_CTRL_STRAP) >> 8; if (pci_get_function(sc->bce_dev) == 0) { switch (strap) { @@ -2672,13 +2704,13 @@ bce_get_media(struct bce_softc *sc) case 0x5: case 0x6: DBPRINT(sc, BCE_INFO_LOAD, - "BCM5709 s/w configured for SerDes.\n"); + "BCM5709 s/w configured for SerDes.\n"); sc->bce_phy_flags |= BCE_PHY_SERDES_FLAG; - break; + break; default: DBPRINT(sc, BCE_INFO_LOAD, - "BCM5709 s/w configured for Copper.\n"); - break; + "BCM5709 s/w configured for Copper.\n"); + break; } } else { switch (strap) { @@ -2686,13 +2718,13 @@ bce_get_media(struct bce_softc *sc) case 0x2: case 0x4: DBPRINT(sc, BCE_INFO_LOAD, - "BCM5709 s/w configured for SerDes.\n"); + "BCM5709 s/w configured for SerDes.\n"); sc->bce_phy_flags |= BCE_PHY_SERDES_FLAG; - break; + break; default: DBPRINT(sc, BCE_INFO_LOAD, - "BCM5709 s/w configured for Copper.\n"); - break; + "BCM5709 s/w configured for Copper.\n"); + break; } } @@ -2703,21 +2735,23 @@ bce_get_media(struct bce_softc *sc) sc->bce_flags |= BCE_NO_WOL_FLAG; - /* 5708S, 5709S, and 5716S use a separate PHY for SerDes. */ - if (BCE_CHIP_NUM(sc) != BCE_CHIP_NUM_5706) - sc->bce_phy_addr = 2; - - if (BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5709) { + if (BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5709) sc->bce_phy_flags |= BCE_PHY_IEEE_CLAUSE_45_FLAG; + if (BCE_CHIP_NUM(sc) != BCE_CHIP_NUM_5706) { + /* 5708S/09S/16S use a separate PHY for SerDes. */ + sc->bce_phy_addr = 2; + val = bce_shmem_rd(sc, BCE_SHARED_HW_CFG_CONFIG); if (val & BCE_SHARED_HW_CFG_PHY_2_5G) { - sc->bce_phy_flags |= BCE_PHY_2_5G_CAPABLE_FLAG; - DBPRINT(sc, BCE_INFO_LOAD, "Found 2.5Gb capable adapter\n"); + sc->bce_phy_flags |= + BCE_PHY_2_5G_CAPABLE_FLAG; + DBPRINT(sc, BCE_INFO_LOAD, "Found 2.5Gb " + "capable adapter\n"); } - } + } } else if ((BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5706) || - (BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5708)) + (BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5708)) sc->bce_phy_flags |= BCE_PHY_CRC_FIX_FLAG; bce_get_media_exit: @@ -2746,13 +2780,13 @@ bce_init_media(struct bce_softc *sc) * is done in mii layer. */ - /* Select auto-negotiation MMD of the PHY. */ - bce_miibus_write_reg(sc->bce_dev, sc->bce_phy_addr, + /* Select auto-negotiation MMD of the PHY. */ + bce_miibus_write_reg(sc->bce_dev, sc->bce_phy_addr, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_ADDR_EXT); bce_miibus_write_reg(sc->bce_dev, sc->bce_phy_addr, BRGPHY_ADDR_EXT, BRGPHY_ADDR_EXT_AN_MMD); - /* Select IEEE0 block of AN MMD (assumed in all brgphy(4) code). */ + /* Set IEEE0 block of AN MMD (assumed in brgphy(4) code). */ bce_miibus_write_reg(sc->bce_dev, sc->bce_phy_addr, BRGPHY_BLOCK_ADDR, BRGPHY_BLOCK_ADDR_COMBO_IEEE0); } @@ -2778,7 +2812,7 @@ bce_dma_free(struct bce_softc *sc) /* Free, unmap, and destroy the status block. */ if (sc->status_block != NULL) { bus_dmamem_free( - sc->status_tag, + sc->status_tag, sc->status_block, sc->status_map); sc->status_block = NULL; @@ -2786,7 +2820,7 @@ bce_dma_free(struct bce_softc *sc) if (sc->status_map != NULL) { bus_dmamap_unload( - sc->status_tag, + sc->status_tag, sc->status_map); bus_dmamap_destroy(sc->status_tag, sc->status_map); @@ -2802,7 +2836,7 @@ bce_dma_free(struct bce_softc *sc) /* Free, unmap, and destroy the statistics block. */ if (sc->stats_block != NULL) { bus_dmamem_free( - sc->stats_tag, + sc->stats_tag, sc->stats_block, sc->stats_map); sc->stats_block = NULL; @@ -2810,7 +2844,7 @@ bce_dma_free(struct bce_softc *sc) if (sc->stats_map != NULL) { bus_dmamap_unload( - sc->stats_tag, + sc->stats_tag, sc->stats_map); bus_dmamap_destroy(sc->stats_tag, sc->stats_map); @@ -2829,7 +2863,7 @@ bce_dma_free(struct bce_softc *sc) for (i = 0; i < sc->ctx_pages; i++ ) { if (sc->ctx_block[i] != NULL) { bus_dmamem_free( - sc->ctx_tag, + sc->ctx_tag, sc->ctx_block[i], sc->ctx_map[i]); sc->ctx_block[i] = NULL; @@ -2837,10 +2871,10 @@ bce_dma_free(struct bce_softc *sc) if (sc->ctx_map[i] != NULL) { bus_dmamap_unload( - sc->ctx_tag, - sc->ctx_map[i]); + sc->ctx_tag, + sc->ctx_map[i]); bus_dmamap_destroy( - sc->ctx_tag, + sc->ctx_tag, sc->ctx_map[i]); sc->ctx_map[i] = NULL; } @@ -2858,7 +2892,7 @@ bce_dma_free(struct bce_softc *sc) for (i = 0; i < TX_PAGES; i++ ) { if (sc->tx_bd_chain[i] != NULL) { bus_dmamem_free( - sc->tx_bd_chain_tag, + sc->tx_bd_chain_tag, sc->tx_bd_chain[i], sc->tx_bd_chain_map[i]); sc->tx_bd_chain[i] = NULL; @@ -2866,10 +2900,10 @@ bce_dma_free(struct bce_softc *sc) if (sc->tx_bd_chain_map[i] != NULL) { bus_dmamap_unload( - sc->tx_bd_chain_tag, - sc->tx_bd_chain_map[i]); + sc->tx_bd_chain_tag, + sc->tx_bd_chain_map[i]); bus_dmamap_destroy( - sc->tx_bd_chain_tag, + sc->tx_bd_chain_tag, sc->tx_bd_chain_map[i]); sc->tx_bd_chain_map[i] = NULL; } @@ -2886,7 +2920,7 @@ bce_dma_free(struct bce_softc *sc) for (i = 0; i < RX_PAGES; i++ ) { if (sc->rx_bd_chain[i] != NULL) { bus_dmamem_free( - sc->rx_bd_chain_tag, + sc->rx_bd_chain_tag, sc->rx_bd_chain[i], sc->rx_bd_chain_map[i]); sc->rx_bd_chain[i] = NULL; @@ -2894,10 +2928,10 @@ bce_dma_free(struct bce_softc *sc) if (sc->rx_bd_chain_map[i] != NULL) { bus_dmamap_unload( - sc->rx_bd_chain_tag, - sc->rx_bd_chain_map[i]); + sc->rx_bd_chain_tag, + sc->rx_bd_chain_map[i]); bus_dmamap_destroy( - sc->rx_bd_chain_tag, + sc->rx_bd_chain_tag, sc->rx_bd_chain_map[i]); sc->rx_bd_chain_map[i] = NULL; } @@ -2915,7 +2949,7 @@ bce_dma_free(struct bce_softc *sc) for (i = 0; i < PG_PAGES; i++ ) { if (sc->pg_bd_chain[i] != NULL) { bus_dmamem_free( - sc->pg_bd_chain_tag, + sc->pg_bd_chain_tag, sc->pg_bd_chain[i], sc->pg_bd_chain_map[i]); sc->pg_bd_chain[i] = NULL; @@ -2923,10 +2957,10 @@ bce_dma_free(struct bce_softc *sc) if (sc->pg_bd_chain_map[i] != NULL) { bus_dmamap_unload( - sc->pg_bd_chain_tag, - sc->pg_bd_chain_map[i]); + sc->pg_bd_chain_tag, + sc->pg_bd_chain_map[i]); bus_dmamap_destroy( - sc->pg_bd_chain_tag, + sc->pg_bd_chain_tag, sc->pg_bd_chain_map[i]); sc->pg_bd_chain_map[i] = NULL; } @@ -2944,9 +2978,9 @@ bce_dma_free(struct bce_softc *sc) for (i = 0; i < TOTAL_TX_BD; i++) { if (sc->tx_mbuf_map[i] != NULL) { bus_dmamap_unload(sc->tx_mbuf_tag, - sc->tx_mbuf_map[i]); + sc->tx_mbuf_map[i]); bus_dmamap_destroy(sc->tx_mbuf_tag, - sc->tx_mbuf_map[i]); + sc->tx_mbuf_map[i]); sc->tx_mbuf_map[i] = NULL; } } @@ -2961,9 +2995,9 @@ bce_dma_free(struct bce_softc *sc) for (i = 0; i < TOTAL_RX_BD; i++) { if (sc->rx_mbuf_map[i] != NULL) { bus_dmamap_unload(sc->rx_mbuf_tag, - sc->rx_mbuf_map[i]); + sc->rx_mbuf_map[i]); bus_dmamap_destroy(sc->rx_mbuf_tag, - sc->rx_mbuf_map[i]); + sc->rx_mbuf_map[i]); sc->rx_mbuf_map[i] = NULL; } } @@ -2979,9 +3013,9 @@ bce_dma_free(struct bce_softc *sc) for (i = 0; i < TOTAL_PG_BD; i++) { if (sc->pg_mbuf_map[i] != NULL) { bus_dmamap_unload(sc->pg_mbuf_tag, - sc->pg_mbuf_map[i]); + sc->pg_mbuf_map[i]); bus_dmamap_destroy(sc->pg_mbuf_tag, - sc->pg_mbuf_map[i]); + sc->pg_mbuf_map[i]); sc->pg_mbuf_map[i] = NULL; } } @@ -3074,20 +3108,12 @@ bce_dma_alloc(device_t dev) /* * Allocate the parent bus DMA tag appropriate for PCI. */ - if (bus_dma_tag_create(NULL, - 1, - BCE_DMA_BOUNDARY, - sc->max_bus_addr, - BUS_SPACE_MAXADDR, - NULL, NULL, - MAXBSIZE, - BUS_SPACE_UNRESTRICTED, - BUS_SPACE_MAXSIZE_32BIT, - 0, - NULL, NULL, - &sc->parent_tag)) { + if (bus_dma_tag_create(NULL, 1, BCE_DMA_BOUNDARY, + sc->max_bus_addr, BUS_SPACE_MAXADDR, NULL, NULL, + MAXBSIZE, BUS_SPACE_UNRESTRICTED, BUS_SPACE_MAXSIZE_32BIT, + 0, NULL, NULL, &sc->parent_tag)) { BCE_PRINTF("%s(%d): Could not allocate parent DMA tag!\n", - __FILE__, __LINE__); + __FILE__, __LINE__); rc = ENOMEM; goto bce_dma_alloc_exit; } @@ -3097,117 +3123,89 @@ bce_dma_alloc(device_t dev) * memory, map the memory into DMA space, and fetch the physical * address of the block. */ - if (bus_dma_tag_create(sc->parent_tag, - BCE_DMA_ALIGN, - BCE_DMA_BOUNDARY, - sc->max_bus_addr, - BUS_SPACE_MAXADDR, - NULL, NULL, - BCE_STATUS_BLK_SZ, - 1, - BCE_STATUS_BLK_SZ, - 0, - NULL, NULL, - &sc->status_tag)) { - BCE_PRINTF("%s(%d): Could not allocate status block DMA tag!\n", - __FILE__, __LINE__); + if (bus_dma_tag_create(sc->parent_tag, BCE_DMA_ALIGN, + BCE_DMA_BOUNDARY, sc->max_bus_addr, BUS_SPACE_MAXADDR, *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***