| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_bge.c,v 1.205 2013/02/26 11:03:17 msaitoh Exp $ */ | | 1 | /* $NetBSD: if_bge.c,v 1.206 2013/02/26 11:06:23 msaitoh Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001 Wind River Systems | | 4 | * Copyright (c) 2001 Wind River Systems |
5 | * Copyright (c) 1997, 1998, 1999, 2001 | | 5 | * Copyright (c) 1997, 1998, 1999, 2001 |
6 | * Bill Paul <wpaul@windriver.com>. All rights reserved. | | 6 | * Bill Paul <wpaul@windriver.com>. All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -69,27 +69,27 @@ | | | @@ -69,27 +69,27 @@ |
69 | * does not support external SSRAM. | | 69 | * does not support external SSRAM. |
70 | * | | 70 | * |
71 | * Broadcom also produces a variation of the BCM5700 under the "Altima" | | 71 | * Broadcom also produces a variation of the BCM5700 under the "Altima" |
72 | * brand name, which is functionally similar but lacks PCI-X support. | | 72 | * brand name, which is functionally similar but lacks PCI-X support. |
73 | * | | 73 | * |
74 | * Without external SSRAM, you can only have at most 4 TX rings, | | 74 | * Without external SSRAM, you can only have at most 4 TX rings, |
75 | * and the use of the mini RX ring is disabled. This seems to imply | | 75 | * and the use of the mini RX ring is disabled. This seems to imply |
76 | * that these features are simply not available on the BCM5701. As a | | 76 | * that these features are simply not available on the BCM5701. As a |
77 | * result, this driver does not implement any support for the mini RX | | 77 | * result, this driver does not implement any support for the mini RX |
78 | * ring. | | 78 | * ring. |
79 | */ | | 79 | */ |
80 | | | 80 | |
81 | #include <sys/cdefs.h> | | 81 | #include <sys/cdefs.h> |
82 | __KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.205 2013/02/26 11:03:17 msaitoh Exp $"); | | 82 | __KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.206 2013/02/26 11:06:23 msaitoh Exp $"); |
83 | | | 83 | |
84 | #include "vlan.h" | | 84 | #include "vlan.h" |
85 | | | 85 | |
86 | #include <sys/param.h> | | 86 | #include <sys/param.h> |
87 | #include <sys/systm.h> | | 87 | #include <sys/systm.h> |
88 | #include <sys/callout.h> | | 88 | #include <sys/callout.h> |
89 | #include <sys/sockio.h> | | 89 | #include <sys/sockio.h> |
90 | #include <sys/mbuf.h> | | 90 | #include <sys/mbuf.h> |
91 | #include <sys/malloc.h> | | 91 | #include <sys/malloc.h> |
92 | #include <sys/kernel.h> | | 92 | #include <sys/kernel.h> |
93 | #include <sys/device.h> | | 93 | #include <sys/device.h> |
94 | #include <sys/socket.h> | | 94 | #include <sys/socket.h> |
95 | #include <sys/sysctl.h> | | 95 | #include <sys/sysctl.h> |
| @@ -689,26 +689,27 @@ static const struct bge_revision { | | | @@ -689,26 +689,27 @@ static const struct bge_revision { |
689 | { BGE_CHIPID_BCM5715_A3, "BCM5715 A3" }, | | 689 | { BGE_CHIPID_BCM5715_A3, "BCM5715 A3" }, |
690 | { BGE_CHIPID_BCM5755_A0, "BCM5755 A0" }, | | 690 | { BGE_CHIPID_BCM5755_A0, "BCM5755 A0" }, |
691 | { BGE_CHIPID_BCM5755_A1, "BCM5755 A1" }, | | 691 | { BGE_CHIPID_BCM5755_A1, "BCM5755 A1" }, |
692 | { BGE_CHIPID_BCM5755_A2, "BCM5755 A2" }, | | 692 | { BGE_CHIPID_BCM5755_A2, "BCM5755 A2" }, |
693 | { BGE_CHIPID_BCM5755_C0, "BCM5755 C0" }, | | 693 | { BGE_CHIPID_BCM5755_C0, "BCM5755 C0" }, |
694 | { BGE_CHIPID_BCM5761_A0, "BCM5761 A0" }, | | 694 | { BGE_CHIPID_BCM5761_A0, "BCM5761 A0" }, |
695 | { BGE_CHIPID_BCM5761_A1, "BCM5761 A1" }, | | 695 | { BGE_CHIPID_BCM5761_A1, "BCM5761 A1" }, |
696 | { BGE_CHIPID_BCM5784_A0, "BCM5784 A0" }, | | 696 | { BGE_CHIPID_BCM5784_A0, "BCM5784 A0" }, |
697 | { BGE_CHIPID_BCM5784_A1, "BCM5784 A1" }, | | 697 | { BGE_CHIPID_BCM5784_A1, "BCM5784 A1" }, |
698 | /* 5754 and 5787 share the same ASIC ID */ | | 698 | /* 5754 and 5787 share the same ASIC ID */ |
699 | { BGE_CHIPID_BCM5787_A0, "BCM5754/5787 A0" }, | | 699 | { BGE_CHIPID_BCM5787_A0, "BCM5754/5787 A0" }, |
700 | { BGE_CHIPID_BCM5787_A1, "BCM5754/5787 A1" }, | | 700 | { BGE_CHIPID_BCM5787_A1, "BCM5754/5787 A1" }, |
701 | { BGE_CHIPID_BCM5787_A2, "BCM5754/5787 A2" }, | | 701 | { BGE_CHIPID_BCM5787_A2, "BCM5754/5787 A2" }, |
| | | 702 | { BGE_CHIPID_BCM5906_A0, "BCM5906 A0" }, |
702 | { BGE_CHIPID_BCM5906_A1, "BCM5906 A1" }, | | 703 | { BGE_CHIPID_BCM5906_A1, "BCM5906 A1" }, |
703 | { BGE_CHIPID_BCM5906_A2, "BCM5906 A2" }, | | 704 | { BGE_CHIPID_BCM5906_A2, "BCM5906 A2" }, |
704 | { BGE_CHIPID_BCM57780_A0, "BCM57780 A0" }, | | 705 | { BGE_CHIPID_BCM57780_A0, "BCM57780 A0" }, |
705 | { BGE_CHIPID_BCM57780_A1, "BCM57780 A1" }, | | 706 | { BGE_CHIPID_BCM57780_A1, "BCM57780 A1" }, |
706 | | | 707 | |
707 | { 0, NULL } | | 708 | { 0, NULL } |
708 | }; | | 709 | }; |
709 | | | 710 | |
710 | /* | | 711 | /* |
711 | * Some defaults for major revisions, so that newer steppings | | 712 | * Some defaults for major revisions, so that newer steppings |
712 | * that we don't know about have a shot at working. | | 713 | * that we don't know about have a shot at working. |
713 | */ | | 714 | */ |
714 | static const struct bge_revision bge_majorrevs[] = { | | 715 | static const struct bge_revision bge_majorrevs[] = { |
| @@ -2087,26 +2088,34 @@ bge_blockinit(struct bge_softc *sc) | | | @@ -2087,26 +2088,34 @@ bge_blockinit(struct bge_softc *sc) |
2087 | /* Set up dummy disabled mini ring RCB */ | | 2088 | /* Set up dummy disabled mini ring RCB */ |
2088 | rcb = &sc->bge_rdata->bge_info.bge_mini_rx_rcb; | | 2089 | rcb = &sc->bge_rdata->bge_info.bge_mini_rx_rcb; |
2089 | rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(0, | | 2090 | rcb->bge_maxlen_flags = BGE_RCB_MAXLEN_FLAGS(0, |
2090 | BGE_RCB_FLAG_RING_DISABLED); | | 2091 | BGE_RCB_FLAG_RING_DISABLED); |
2091 | CSR_WRITE_4(sc, BGE_RX_MINI_RCB_MAXLEN_FLAGS, | | 2092 | CSR_WRITE_4(sc, BGE_RX_MINI_RCB_MAXLEN_FLAGS, |
2092 | rcb->bge_maxlen_flags); | | 2093 | rcb->bge_maxlen_flags); |
2093 | | | 2094 | |
2094 | bus_dmamap_sync(sc->bge_dmatag, sc->bge_ring_map, | | 2095 | bus_dmamap_sync(sc->bge_dmatag, sc->bge_ring_map, |
2095 | offsetof(struct bge_ring_data, bge_info), | | 2096 | offsetof(struct bge_ring_data, bge_info), |
2096 | sizeof (struct bge_gib), | | 2097 | sizeof (struct bge_gib), |
2097 | BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); | | 2098 | BUS_DMASYNC_PREREAD|BUS_DMASYNC_PREWRITE); |
2098 | } | | 2099 | } |
2099 | | | 2100 | |
| | | 2101 | /* Choose de-pipeline mode for BCM5906 A0, A1 and A2. */ |
| | | 2102 | if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906) { |
| | | 2103 | if (sc->bge_chipid == BGE_CHIPID_BCM5906_A0 || |
| | | 2104 | sc->bge_chipid == BGE_CHIPID_BCM5906_A1 || |
| | | 2105 | sc->bge_chipid == BGE_CHIPID_BCM5906_A2) |
| | | 2106 | CSR_WRITE_4(sc, BGE_ISO_PKT_TX, |
| | | 2107 | (CSR_READ_4(sc, BGE_ISO_PKT_TX) & ~3) | 2); |
| | | 2108 | } |
2100 | /* | | 2109 | /* |
2101 | * Set the BD ring replenish thresholds. The recommended | | 2110 | * Set the BD ring replenish thresholds. The recommended |
2102 | * values are 1/8th the number of descriptors allocated to | | 2111 | * values are 1/8th the number of descriptors allocated to |
2103 | * each ring. | | 2112 | * each ring. |
2104 | */ | | 2113 | */ |
2105 | i = BGE_STD_RX_RING_CNT / 8; | | 2114 | i = BGE_STD_RX_RING_CNT / 8; |
2106 | | | 2115 | |
2107 | /* | | 2116 | /* |
2108 | * Use a value of 8 for the following chips to workaround HW errata. | | 2117 | * Use a value of 8 for the following chips to workaround HW errata. |
2109 | * Some of these chips have been added based on empirical | | 2118 | * Some of these chips have been added based on empirical |
2110 | * evidence (they don't work unless this is done). | | 2119 | * evidence (they don't work unless this is done). |
2111 | */ | | 2120 | */ |
2112 | if (BGE_IS_5705_PLUS(sc)) | | 2121 | if (BGE_IS_5705_PLUS(sc)) |
| @@ -2299,26 +2308,29 @@ bge_blockinit(struct bge_softc *sc) | | | @@ -2299,26 +2308,29 @@ bge_blockinit(struct bge_softc *sc) |
2299 | #endif | | 2308 | #endif |
2300 | CSR_WRITE_4(sc, BGE_MISC_LOCAL_CTL, sc->bge_local_ctrl_reg); | | 2309 | CSR_WRITE_4(sc, BGE_MISC_LOCAL_CTL, sc->bge_local_ctrl_reg); |
2301 | | | 2310 | |
2302 | /* Turn on DMA completion state machine */ | | 2311 | /* Turn on DMA completion state machine */ |
2303 | if (BGE_IS_5700_FAMILY(sc)) | | 2312 | if (BGE_IS_5700_FAMILY(sc)) |
2304 | CSR_WRITE_4(sc, BGE_DMAC_MODE, BGE_DMACMODE_ENABLE); | | 2313 | CSR_WRITE_4(sc, BGE_DMAC_MODE, BGE_DMACMODE_ENABLE); |
2305 | | | 2314 | |
2306 | val = BGE_WDMAMODE_ENABLE | BGE_WDMAMODE_ALL_ATTNS; | | 2315 | val = BGE_WDMAMODE_ENABLE | BGE_WDMAMODE_ALL_ATTNS; |
2307 | | | 2316 | |
2308 | /* Enable host coalescing bug fix; see Linux tg3.c */ | | 2317 | /* Enable host coalescing bug fix; see Linux tg3.c */ |
2309 | if (BGE_IS_5755_PLUS(sc)) | | 2318 | if (BGE_IS_5755_PLUS(sc)) |
2310 | val |= BGE_WDMAMODE_STATUS_TAG_FIX; | | 2319 | val |= BGE_WDMAMODE_STATUS_TAG_FIX; |
2311 | | | 2320 | |
| | | 2321 | if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5785) |
| | | 2322 | val |= BGE_WDMAMODE_BURST_ALL_DATA; |
| | | 2323 | |
2312 | /* Turn on write DMA state machine */ | | 2324 | /* Turn on write DMA state machine */ |
2313 | CSR_WRITE_4(sc, BGE_WDMA_MODE, val); | | 2325 | CSR_WRITE_4(sc, BGE_WDMA_MODE, val); |
2314 | | | 2326 | |
2315 | val = BGE_RDMAMODE_ENABLE | BGE_RDMAMODE_ALL_ATTNS; | | 2327 | val = BGE_RDMAMODE_ENABLE | BGE_RDMAMODE_ALL_ATTNS; |
2316 | if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5784 || | | 2328 | if (BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5784 || |
2317 | BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5785 || | | 2329 | BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5785 || |
2318 | BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57780) | | 2330 | BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57780) |
2319 | val |= BGE_RDMAMODE_BD_SBD_CRPT_ATTN | | | 2331 | val |= BGE_RDMAMODE_BD_SBD_CRPT_ATTN | |
2320 | BGE_RDMAMODE_MBUF_RBD_CRPT_ATTN | | | 2332 | BGE_RDMAMODE_MBUF_RBD_CRPT_ATTN | |
2321 | BGE_RDMAMODE_MBUF_SBD_CRPT_ATTN; | | 2333 | BGE_RDMAMODE_MBUF_SBD_CRPT_ATTN; |
2322 | | | 2334 | |
2323 | if (sc->bge_flags & BGE_PCIE) | | 2335 | if (sc->bge_flags & BGE_PCIE) |
2324 | val |= BGE_RDMAMODE_FIFO_LONG_BURST; | | 2336 | val |= BGE_RDMAMODE_FIFO_LONG_BURST; |
| @@ -4294,26 +4306,27 @@ bge_start(struct ifnet *ifp) | | | @@ -4294,26 +4306,27 @@ bge_start(struct ifnet *ifp) |
4294 | sc->bge_tx_prodidx = prodidx; | | 4306 | sc->bge_tx_prodidx = prodidx; |
4295 | | | 4307 | |
4296 | /* | | 4308 | /* |
4297 | * Set a timeout in case the chip goes out to lunch. | | 4309 | * Set a timeout in case the chip goes out to lunch. |
4298 | */ | | 4310 | */ |
4299 | ifp->if_timer = 5; | | 4311 | ifp->if_timer = 5; |
4300 | } | | 4312 | } |
4301 | | | 4313 | |
4302 | static int | | 4314 | static int |
4303 | bge_init(struct ifnet *ifp) | | 4315 | bge_init(struct ifnet *ifp) |
4304 | { | | 4316 | { |
4305 | struct bge_softc *sc = ifp->if_softc; | | 4317 | struct bge_softc *sc = ifp->if_softc; |
4306 | const uint16_t *m; | | 4318 | const uint16_t *m; |
| | | 4319 | uint32_t mode; |
4307 | int s, error = 0; | | 4320 | int s, error = 0; |
4308 | | | 4321 | |
4309 | s = splnet(); | | 4322 | s = splnet(); |
4310 | | | 4323 | |
4311 | ifp = &sc->ethercom.ec_if; | | 4324 | ifp = &sc->ethercom.ec_if; |
4312 | | | 4325 | |
4313 | /* Cancel pending I/O and flush buffers. */ | | 4326 | /* Cancel pending I/O and flush buffers. */ |
4314 | bge_stop(ifp, 0); | | 4327 | bge_stop(ifp, 0); |
4315 | | | 4328 | |
4316 | bge_stop_fw(sc); | | 4329 | bge_stop_fw(sc); |
4317 | bge_sig_pre_reset(sc, BGE_RESET_START); | | 4330 | bge_sig_pre_reset(sc, BGE_RESET_START); |
4318 | bge_reset(sc); | | 4331 | bge_reset(sc); |
4319 | bge_sig_legacy(sc, BGE_RESET_START); | | 4332 | bge_sig_legacy(sc, BGE_RESET_START); |
| @@ -4374,31 +4387,39 @@ bge_init(struct ifnet *ifp) | | | @@ -4374,31 +4387,39 @@ bge_init(struct ifnet *ifp) |
4374 | "5705 A0 chip failed to load RX ring\n"); | | 4387 | "5705 A0 chip failed to load RX ring\n"); |
4375 | } | | 4388 | } |
4376 | | | 4389 | |
4377 | /* Init jumbo RX ring. */ | | 4390 | /* Init jumbo RX ring. */ |
4378 | if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN)) | | 4391 | if (ifp->if_mtu > (ETHERMTU + ETHER_HDR_LEN + ETHER_CRC_LEN)) |
4379 | bge_init_rx_ring_jumbo(sc); | | 4392 | bge_init_rx_ring_jumbo(sc); |
4380 | | | 4393 | |
4381 | /* Init our RX return ring index */ | | 4394 | /* Init our RX return ring index */ |
4382 | sc->bge_rx_saved_considx = 0; | | 4395 | sc->bge_rx_saved_considx = 0; |
4383 | | | 4396 | |
4384 | /* Init TX ring. */ | | 4397 | /* Init TX ring. */ |
4385 | bge_init_tx_ring(sc); | | 4398 | bge_init_tx_ring(sc); |
4386 | | | 4399 | |
| | | 4400 | /* Enable TX MAC state machine lockup fix. */ |
| | | 4401 | mode = CSR_READ_4(sc, BGE_TX_MODE); |
| | | 4402 | if (BGE_IS_5755_PLUS(sc) || |
| | | 4403 | BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM5906) |
| | | 4404 | mode |= BGE_TXMODE_MBUF_LOCKUP_FIX; |
| | | 4405 | |
4387 | /* Turn on transmitter */ | | 4406 | /* Turn on transmitter */ |
4388 | BGE_SETBIT(sc, BGE_TX_MODE, BGE_TXMODE_ENABLE); | | 4407 | CSR_WRITE_4(sc, BGE_TX_MODE, mode | BGE_TXMODE_ENABLE); |
| | | 4408 | DELAY(100); |
4389 | | | 4409 | |
4390 | /* Turn on receiver */ | | 4410 | /* Turn on receiver */ |
4391 | BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE); | | 4411 | BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE); |
| | | 4412 | DELAY(10); |
4392 | | | 4413 | |
4393 | CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 2); | | 4414 | CSR_WRITE_4(sc, BGE_MAX_RX_FRAME_LOWAT, 2); |
4394 | | | 4415 | |
4395 | /* Tell firmware we're alive. */ | | 4416 | /* Tell firmware we're alive. */ |
4396 | BGE_SETBIT(sc, BGE_MODE_CTL, BGE_MODECTL_STACKUP); | | 4417 | BGE_SETBIT(sc, BGE_MODE_CTL, BGE_MODECTL_STACKUP); |
4397 | | | 4418 | |
4398 | /* Enable host interrupts. */ | | 4419 | /* Enable host interrupts. */ |
4399 | BGE_SETBIT(sc, BGE_PCI_MISC_CTL, BGE_PCIMISCCTL_CLEAR_INTA); | | 4420 | BGE_SETBIT(sc, BGE_PCI_MISC_CTL, BGE_PCIMISCCTL_CLEAR_INTA); |
4400 | BGE_CLRBIT(sc, BGE_PCI_MISC_CTL, BGE_PCIMISCCTL_MASK_PCI_INTR); | | 4421 | BGE_CLRBIT(sc, BGE_PCI_MISC_CTL, BGE_PCIMISCCTL_MASK_PCI_INTR); |
4401 | bge_writembx(sc, BGE_MBX_IRQ0_LO, 0); | | 4422 | bge_writembx(sc, BGE_MBX_IRQ0_LO, 0); |
4402 | | | 4423 | |
4403 | if ((error = bge_ifmedia_upd(ifp)) != 0) | | 4424 | if ((error = bge_ifmedia_upd(ifp)) != 0) |
4404 | goto out; | | 4425 | goto out; |