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: --- 18 unchanged lines hidden (view full) --- 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 34#include <sys/cdefs.h> |
35__FBSDID("$FreeBSD: head/sys/dev/bge/if_bge.c 220368 2011-04-05 17:41:54Z yongari $"); |
36 37/* 38 * Broadcom BCM570x family gigabit ethernet driver for FreeBSD. 39 * 40 * The Broadcom BCM5700 is based on technology originally developed by 41 * Alteon Networks as part of the Tigon I and Tigon II gigabit ethernet 42 * MAC chips. The BCM5700, sometimes refered to as the Tigon III, has 43 * two on-board MIPS R4000 CPUs and can have as much as 16MB of external --- 894 unchanged lines hidden (view full) --- 938bge_newbuf_std(struct bge_softc *sc, int i) 939{ 940 struct mbuf *m; 941 struct bge_rx_bd *r; 942 bus_dma_segment_t segs[1]; 943 bus_dmamap_t map; 944 int error, nsegs; 945 |
946 if (sc->bge_flags & BGE_FLAG_JUMBO_STD && 947 (sc->bge_ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + 948 ETHER_VLAN_ENCAP_LEN > (MCLBYTES - ETHER_ALIGN))) { 949 m = m_getjcl(M_DONTWAIT, MT_DATA, M_PKTHDR, MJUM9BYTES); 950 if (m == NULL) 951 return (ENOBUFS); 952 m->m_len = m->m_pkthdr.len = MJUM9BYTES; 953 } else { 954 m = m_getcl(M_DONTWAIT, MT_DATA, M_PKTHDR); 955 if (m == NULL) 956 return (ENOBUFS); 957 m->m_len = m->m_pkthdr.len = MCLBYTES; 958 } |
959 if ((sc->bge_flags & BGE_FLAG_RX_ALIGNBUG) == 0) 960 m_adj(m, ETHER_ALIGN); 961 962 error = bus_dmamap_load_mbuf_sg(sc->bge_cdata.bge_rx_mtag, 963 sc->bge_cdata.bge_rx_std_sparemap, m, segs, &nsegs, 0); 964 if (error != 0) { 965 m_freem(m); 966 return (error); --- 1422 unchanged lines hidden (view full) --- 2389 } 2390 return (0); 2391} 2392 2393static int 2394bge_dma_alloc(struct bge_softc *sc) 2395{ 2396 bus_addr_t lowaddr; |
2397 bus_size_t boundary, sbsz, rxmaxsegsz, txsegsz, txmaxsegsz; |
2398 int i, error; 2399 2400 lowaddr = BUS_SPACE_MAXADDR; 2401 if ((sc->bge_flags & BGE_FLAG_40BIT_BUG) != 0) 2402 lowaddr = BGE_DMA_MAXADDR; 2403 /* 2404 * Allocate the parent bus DMA tag appropriate for PCI. 2405 */ --- 111 unchanged lines hidden (view full) --- 2517 &sc->bge_cdata.bge_tx_mtag); 2518 2519 if (error) { 2520 device_printf(sc->bge_dev, "could not allocate TX dma tag\n"); 2521 return (ENOMEM); 2522 } 2523 2524 /* Create tag for Rx mbufs. */ |
2525 if (sc->bge_flags & BGE_FLAG_JUMBO_STD) 2526 rxmaxsegsz = MJUM9BYTES; 2527 else 2528 rxmaxsegsz = MCLBYTES; |
2529 error = bus_dma_tag_create(sc->bge_cdata.bge_buffer_tag, 1, 0, |
2530 BUS_SPACE_MAXADDR, BUS_SPACE_MAXADDR, NULL, NULL, rxmaxsegsz, 1, 2531 rxmaxsegsz, 0, NULL, NULL, &sc->bge_cdata.bge_rx_mtag); |
2532 2533 if (error) { 2534 device_printf(sc->bge_dev, "could not allocate RX dma tag\n"); 2535 return (ENOMEM); 2536 } 2537 2538 /* Create DMA maps for RX buffers. */ 2539 error = bus_dmamap_create(sc->bge_cdata.bge_rx_mtag, 0, --- 227 unchanged lines hidden (view full) --- 2767 case BGE_ASICREV_BCM5701: 2768 case BGE_ASICREV_BCM5703: 2769 case BGE_ASICREV_BCM5704: 2770 sc->bge_flags |= BGE_FLAG_5700_FAMILY | BGE_FLAG_JUMBO; 2771 break; 2772 case BGE_ASICREV_BCM5714_A0: 2773 case BGE_ASICREV_BCM5780: 2774 case BGE_ASICREV_BCM5714: |
2775 sc->bge_flags |= BGE_FLAG_5714_FAMILY | BGE_FLAG_JUMBO_STD; |
2776 /* FALLTHROUGH */ 2777 case BGE_ASICREV_BCM5750: 2778 case BGE_ASICREV_BCM5752: 2779 case BGE_ASICREV_BCM5906: 2780 sc->bge_flags |= BGE_FLAG_575X_PLUS; 2781 if (sc->bge_asicrev == BGE_ASICREV_BCM5906) 2782 sc->bge_flags |= BGE_FLAG_SHORT_DMA_BUG; 2783 /* FALLTHROUGH */ --- 784 unchanged lines hidden (view full) --- 3568 return (rx_npkts); 3569 3570 ifp = sc->bge_ifp; 3571 3572 bus_dmamap_sync(sc->bge_cdata.bge_rx_return_ring_tag, 3573 sc->bge_cdata.bge_rx_return_ring_map, BUS_DMASYNC_POSTREAD); 3574 bus_dmamap_sync(sc->bge_cdata.bge_rx_std_ring_tag, 3575 sc->bge_cdata.bge_rx_std_ring_map, BUS_DMASYNC_POSTWRITE); |
3576 if (BGE_IS_JUMBO_CAPABLE(sc) && 3577 ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN > |
3578 (MCLBYTES - ETHER_ALIGN)) 3579 bus_dmamap_sync(sc->bge_cdata.bge_rx_jumbo_ring_tag, 3580 sc->bge_cdata.bge_rx_jumbo_ring_map, BUS_DMASYNC_POSTWRITE); 3581 3582 while (rx_cons != rx_prod) { 3583 struct bge_rx_bd *cur_rx; 3584 uint32_t rxidx; 3585 struct mbuf *m = NULL; --- 1112 unchanged lines hidden (view full) --- 4698 break; 4699 } 4700 if (i == 10) 4701 device_printf (sc->bge_dev, 4702 "5705 A0 chip failed to load RX ring\n"); 4703 } 4704 4705 /* Init jumbo RX ring. */ |
4706 if (BGE_IS_JUMBO_CAPABLE(sc) && 4707 ifp->if_mtu + ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN > |
4708 (MCLBYTES - ETHER_ALIGN)) { 4709 if (bge_init_rx_ring_jumbo(sc) != 0) { 4710 device_printf(sc->bge_dev, 4711 "no memory for jumbo Rx buffers.\n"); 4712 bge_stop(sc); 4713 return; 4714 } 4715 } --- 208 unchanged lines hidden (view full) --- 4924{ 4925 struct bge_softc *sc = ifp->if_softc; 4926 struct ifreq *ifr = (struct ifreq *) data; 4927 struct mii_data *mii; 4928 int flags, mask, error = 0; 4929 4930 switch (command) { 4931 case SIOCSIFMTU: |
4932 if (BGE_IS_JUMBO_CAPABLE(sc) || 4933 (sc->bge_flags & BGE_FLAG_JUMBO_STD)) { 4934 if (ifr->ifr_mtu < ETHERMIN || 4935 ifr->ifr_mtu > BGE_JUMBO_MTU) { 4936 error = EINVAL; 4937 break; 4938 } 4939 } else if (ifr->ifr_mtu < ETHERMIN || ifr->ifr_mtu > ETHERMTU) { 4940 error = EINVAL; 4941 break; 4942 } |
4943 BGE_LOCK(sc); |
4944 if (ifp->if_mtu != ifr->ifr_mtu) { |
4945 ifp->if_mtu = ifr->ifr_mtu; 4946 if (ifp->if_drv_flags & IFF_DRV_RUNNING) { 4947 ifp->if_drv_flags &= ~IFF_DRV_RUNNING; 4948 bge_init_locked(sc); 4949 } 4950 } 4951 BGE_UNLOCK(sc); 4952 break; --- 912 unchanged lines hidden --- |