if_bge.c (95673) | if_bge.c (98779) |
---|---|
1/* 2 * Copyright (c) 2001 Wind River Systems 3 * Copyright (c) 1997, 1998, 1999, 2001 4 * Bill Paul <wpaul@windriver.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 * | 1/* 2 * Copyright (c) 2001 Wind River Systems 3 * Copyright (c) 1997, 1998, 1999, 2001 4 * Bill Paul <wpaul@windriver.com>. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 16 unchanged lines hidden (view full) --- 25 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 31 * THE POSSIBILITY OF SUCH DAMAGE. 32 * |
33 * $FreeBSD: head/sys/dev/bge/if_bge.c 95673 2002-04-28 20:34:20Z phk $ | 33 * $FreeBSD: head/sys/dev/bge/if_bge.c 98779 2002-06-24 22:04:15Z jdp $ |
34 */ 35 36/* 37 * Broadcom BCM570x family gigabit ethernet driver for FreeBSD. 38 * 39 * Written by Bill Paul <wpaul@windriver.com> 40 * Senior Engineer, Wind River Systems 41 */ --- 75 unchanged lines hidden (view full) --- 117 118MODULE_DEPEND(bge, miibus, 1, 1, 1); 119 120/* "controller miibus0" required. See GENERIC if you get errors here. */ 121#include "miibus_if.h" 122 123#if !defined(lint) 124static const char rcsid[] = | 34 */ 35 36/* 37 * Broadcom BCM570x family gigabit ethernet driver for FreeBSD. 38 * 39 * Written by Bill Paul <wpaul@windriver.com> 40 * Senior Engineer, Wind River Systems 41 */ --- 75 unchanged lines hidden (view full) --- 117 118MODULE_DEPEND(bge, miibus, 1, 1, 1); 119 120/* "controller miibus0" required. See GENERIC if you get errors here. */ 121#include "miibus_if.h" 122 123#if !defined(lint) 124static const char rcsid[] = |
125 "$FreeBSD: head/sys/dev/bge/if_bge.c 95673 2002-04-28 20:34:20Z phk $"; | 125 "$FreeBSD: head/sys/dev/bge/if_bge.c 98779 2002-06-24 22:04:15Z jdp $"; |
126#endif 127 128/* 129 * Various supported device vendors/types and their names. Note: the 130 * spec seems to indicate that the hardware still has Alteon's vendor 131 * ID burned into it, though it will always be overriden by the vendor 132 * ID in the EEPROM. Just to be safe, we cover all possibilities. 133 */ --- 586 unchanged lines hidden (view full) --- 720 } 721 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; 722 } else { 723 m_new = m; 724 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; 725 m_new->m_data = m_new->m_ext.ext_buf; 726 } 727 | 126#endif 127 128/* 129 * Various supported device vendors/types and their names. Note: the 130 * spec seems to indicate that the hardware still has Alteon's vendor 131 * ID burned into it, though it will always be overriden by the vendor 132 * ID in the EEPROM. Just to be safe, we cover all possibilities. 133 */ --- 586 unchanged lines hidden (view full) --- 720 } 721 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; 722 } else { 723 m_new = m; 724 m_new->m_len = m_new->m_pkthdr.len = MCLBYTES; 725 m_new->m_data = m_new->m_ext.ext_buf; 726 } 727 |
728 m_adj(m_new, ETHER_ALIGN); | 728 if (!sc->bge_rx_alignment_bug) 729 m_adj(m_new, ETHER_ALIGN); |
729 sc->bge_cdata.bge_rx_std_chain[i] = m_new; 730 r = &sc->bge_rdata->bge_rx_std_ring[i]; 731 BGE_HOSTADDR(r->bge_addr) = vtophys(mtod(m_new, caddr_t)); 732 r->bge_flags = BGE_RXBDFLAG_END; 733 r->bge_len = m_new->m_len; 734 r->bge_idx = i; 735 736 return(0); --- 36 unchanged lines hidden (view full) --- 773 MEXTADD(m_new, buf, BGE_JUMBO_FRAMELEN, bge_jfree, 774 (struct bge_softc *)sc, 0, EXT_NET_DRV); 775 } else { 776 m_new = m; 777 m_new->m_data = m_new->m_ext.ext_buf; 778 m_new->m_ext.ext_size = BGE_JUMBO_FRAMELEN; 779 } 780 | 730 sc->bge_cdata.bge_rx_std_chain[i] = m_new; 731 r = &sc->bge_rdata->bge_rx_std_ring[i]; 732 BGE_HOSTADDR(r->bge_addr) = vtophys(mtod(m_new, caddr_t)); 733 r->bge_flags = BGE_RXBDFLAG_END; 734 r->bge_len = m_new->m_len; 735 r->bge_idx = i; 736 737 return(0); --- 36 unchanged lines hidden (view full) --- 774 MEXTADD(m_new, buf, BGE_JUMBO_FRAMELEN, bge_jfree, 775 (struct bge_softc *)sc, 0, EXT_NET_DRV); 776 } else { 777 m_new = m; 778 m_new->m_data = m_new->m_ext.ext_buf; 779 m_new->m_ext.ext_size = BGE_JUMBO_FRAMELEN; 780 } 781 |
781 m_adj(m_new, ETHER_ALIGN); | 782 if (!sc->bge_rx_alignment_bug) 783 m_adj(m_new, ETHER_ALIGN); |
782 /* Set up the descriptor. */ 783 r = &sc->bge_rdata->bge_rx_jumbo_ring[i]; 784 sc->bge_cdata.bge_rx_jumbo_chain[i] = m_new; 785 BGE_HOSTADDR(r->bge_addr) = vtophys(mtod(m_new, caddr_t)); 786 r->bge_flags = BGE_RXBDFLAG_END|BGE_RXBDFLAG_JUMBO_RING; 787 r->bge_len = m_new->m_len; 788 r->bge_idx = i; 789 --- 879 unchanged lines hidden (view full) --- 1669 bge_release_resources(sc); 1670 bge_free_jumbo_mem(sc); 1671 error = ENXIO; 1672 goto fail; 1673 } 1674 } 1675 1676 /* | 784 /* Set up the descriptor. */ 785 r = &sc->bge_rdata->bge_rx_jumbo_ring[i]; 786 sc->bge_cdata.bge_rx_jumbo_chain[i] = m_new; 787 BGE_HOSTADDR(r->bge_addr) = vtophys(mtod(m_new, caddr_t)); 788 r->bge_flags = BGE_RXBDFLAG_END|BGE_RXBDFLAG_JUMBO_RING; 789 r->bge_len = m_new->m_len; 790 r->bge_idx = i; 791 --- 879 unchanged lines hidden (view full) --- 1671 bge_release_resources(sc); 1672 bge_free_jumbo_mem(sc); 1673 error = ENXIO; 1674 goto fail; 1675 } 1676 } 1677 1678 /* |
1679 * When using the BCM5701 in PCI-X mode, data corruption has 1680 * been observed in the first few bytes of some received packets. 1681 * Aligning the packet buffer in memory eliminates the corruption. 1682 * Unfortunately, this misaligns the packet payloads. On platforms 1683 * which do not support unaligned accesses, we will realign the 1684 * payloads by copying the received packets. 1685 */ 1686 switch (sc->bge_asicrev) { 1687 case BGE_ASICREV_BCM5701_A0: 1688 case BGE_ASICREV_BCM5701_B0: 1689 case BGE_ASICREV_BCM5701_B2: 1690 case BGE_ASICREV_BCM5701_B5: 1691 /* If in PCI-X mode, work around the alignment bug. */ 1692 if ((pci_read_config(dev, BGE_PCI_PCISTATE, 4) & 1693 (BGE_PCISTATE_PCI_BUSMODE | BGE_PCISTATE_PCI_BUSSPEED)) == 1694 BGE_PCISTATE_PCI_BUSSPEED) 1695 sc->bge_rx_alignment_bug = 1; 1696 break; 1697 } 1698 1699 /* |
|
1677 * Call MI attach routine. 1678 */ 1679 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); 1680 callout_handle_init(&sc->bge_stat_ch); 1681 1682fail: 1683 splx(s); 1684 --- 215 unchanged lines hidden (view full) --- 1900 NULL) == ENOBUFS) { 1901 ifp->if_ierrors++; 1902 bge_newbuf_std(sc, sc->bge_std, m); 1903 continue; 1904 } 1905 } 1906 1907 ifp->if_ipackets++; | 1700 * Call MI attach routine. 1701 */ 1702 ether_ifattach(ifp, ETHER_BPF_SUPPORTED); 1703 callout_handle_init(&sc->bge_stat_ch); 1704 1705fail: 1706 splx(s); 1707 --- 215 unchanged lines hidden (view full) --- 1923 NULL) == ENOBUFS) { 1924 ifp->if_ierrors++; 1925 bge_newbuf_std(sc, sc->bge_std, m); 1926 continue; 1927 } 1928 } 1929 1930 ifp->if_ipackets++; |
1931#ifndef __i386__ 1932 /* 1933 * The i386 allows unaligned accesses, but for other 1934 * platforms we must make sure the payload is aligned. 1935 */ 1936 if (sc->bge_rx_alignment_bug) { 1937 bcopy(m->m_data, m->m_data + ETHER_ALIGN, 1938 cur_rx->bge_len); 1939 m->m_data += ETHER_ALIGN; 1940 } 1941#endif |
|
1908 eh = mtod(m, struct ether_header *); 1909 m->m_pkthdr.len = m->m_len = cur_rx->bge_len; 1910 m->m_pkthdr.rcvif = ifp; 1911 1912 /* Remove header from mbuf and pass it on. */ 1913 m_adj(m, sizeof(struct ether_header)); 1914 1915#if 0 /* currently broken for some packets, possibly related to TCP options */ --- 832 unchanged lines hidden --- | 1942 eh = mtod(m, struct ether_header *); 1943 m->m_pkthdr.len = m->m_len = cur_rx->bge_len; 1944 m->m_pkthdr.rcvif = ifp; 1945 1946 /* Remove header from mbuf and pass it on. */ 1947 m_adj(m, sizeof(struct ether_header)); 1948 1949#if 0 /* currently broken for some packets, possibly related to TCP options */ --- 832 unchanged lines hidden --- |