if_msk.c (192720) | if_msk.c (192723) |
---|---|
1/****************************************************************************** 2 * 3 * Name : sky2.c 4 * Project: Gigabit Ethernet Driver for FreeBSD 5.x/6.x 5 * Version: $Revision: 1.23 $ 6 * Date : $Date: 2005/12/22 09:04:11 $ 7 * Purpose: Main driver source file 8 * --- 85 unchanged lines hidden (view full) --- 94 95/* 96 * Device driver for the Marvell Yukon II Ethernet controller. 97 * Due to lack of documentation, this driver is based on the code from 98 * sk(4) and Marvell's myk(4) driver for FreeBSD 5.x. 99 */ 100 101#include <sys/cdefs.h> | 1/****************************************************************************** 2 * 3 * Name : sky2.c 4 * Project: Gigabit Ethernet Driver for FreeBSD 5.x/6.x 5 * Version: $Revision: 1.23 $ 6 * Date : $Date: 2005/12/22 09:04:11 $ 7 * Purpose: Main driver source file 8 * --- 85 unchanged lines hidden (view full) --- 94 95/* 96 * Device driver for the Marvell Yukon II Ethernet controller. 97 * Due to lack of documentation, this driver is based on the code from 98 * sk(4) and Marvell's myk(4) driver for FreeBSD 5.x. 99 */ 100 101#include <sys/cdefs.h> |
102__FBSDID("$FreeBSD: head/sys/dev/msk/if_msk.c 192720 2009-05-25 03:53:12Z yongari $"); | 102__FBSDID("$FreeBSD: head/sys/dev/msk/if_msk.c 192723 2009-05-25 04:22:27Z yongari $"); |
103 104#include <sys/param.h> 105#include <sys/systm.h> 106#include <sys/bus.h> 107#include <sys/endian.h> 108#include <sys/mbuf.h> 109#include <sys/malloc.h> 110#include <sys/kernel.h> --- 785 unchanged lines hidden (view full) --- 896 int error, mask; 897 898 sc_if = ifp->if_softc; 899 ifr = (struct ifreq *)data; 900 error = 0; 901 902 switch(command) { 903 case SIOCSIFMTU: | 103 104#include <sys/param.h> 105#include <sys/systm.h> 106#include <sys/bus.h> 107#include <sys/endian.h> 108#include <sys/mbuf.h> 109#include <sys/malloc.h> 110#include <sys/kernel.h> --- 785 unchanged lines hidden (view full) --- 896 int error, mask; 897 898 sc_if = ifp->if_softc; 899 ifr = (struct ifreq *)data; 900 error = 0; 901 902 switch(command) { 903 case SIOCSIFMTU: |
904 MSK_IF_LOCK(sc_if); |
|
904 if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN) 905 error = EINVAL; 906 else if (ifp->if_mtu != ifr->ifr_mtu) { | 905 if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN) 906 error = EINVAL; 907 else if (ifp->if_mtu != ifr->ifr_mtu) { |
907 if ((sc_if->msk_flags & MSK_FLAG_NOJUMBO) != 0 && 908 ifr->ifr_mtu > ETHERMTU) 909 error = EINVAL; 910 else { 911 MSK_IF_LOCK(sc_if); 912 ifp->if_mtu = ifr->ifr_mtu; 913 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) 914 msk_init_locked(sc_if); 915 MSK_IF_UNLOCK(sc_if); | 908 if (ifr->ifr_mtu > ETHERMTU) { 909 if ((sc_if->msk_flags & MSK_FLAG_JUMBO) == 0) { 910 error = EINVAL; 911 MSK_IF_UNLOCK(sc_if); 912 break; 913 } 914 if ((sc_if->msk_flags & 915 MSK_FLAG_JUMBO_NOCSUM) != 0) { 916 ifp->if_hwassist &= 917 ~(MSK_CSUM_FEATURES | CSUM_TSO); 918 ifp->if_capenable &= 919 ~(IFCAP_TSO4 | IFCAP_TXCSUM); 920 VLAN_CAPABILITIES(ifp); 921 } |
916 } | 922 } |
923 ifp->if_mtu = ifr->ifr_mtu; 924 msk_init_locked(sc_if); |
|
917 } | 925 } |
926 MSK_IF_UNLOCK(sc_if); |
|
918 break; 919 case SIOCSIFFLAGS: 920 MSK_IF_LOCK(sc_if); 921 if ((ifp->if_flags & IFF_UP) != 0) { 922 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { 923 if (((ifp->if_flags ^ sc_if->msk_if_flags) 924 & (IFF_PROMISC | IFF_ALLMULTI)) != 0) 925 msk_rxfilter(sc_if); --- 40 unchanged lines hidden (view full) --- 966 ifp->if_capenable ^= IFCAP_TSO4; 967 if ((IFCAP_TSO4 & ifp->if_capenable) != 0 && 968 (IFCAP_TSO4 & ifp->if_capabilities) != 0) 969 ifp->if_hwassist |= CSUM_TSO; 970 else 971 ifp->if_hwassist &= ~CSUM_TSO; 972 } 973 if (ifp->if_mtu > ETHERMTU && | 927 break; 928 case SIOCSIFFLAGS: 929 MSK_IF_LOCK(sc_if); 930 if ((ifp->if_flags & IFF_UP) != 0) { 931 if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { 932 if (((ifp->if_flags ^ sc_if->msk_if_flags) 933 & (IFF_PROMISC | IFF_ALLMULTI)) != 0) 934 msk_rxfilter(sc_if); --- 40 unchanged lines hidden (view full) --- 975 ifp->if_capenable ^= IFCAP_TSO4; 976 if ((IFCAP_TSO4 & ifp->if_capenable) != 0 && 977 (IFCAP_TSO4 & ifp->if_capabilities) != 0) 978 ifp->if_hwassist |= CSUM_TSO; 979 else 980 ifp->if_hwassist &= ~CSUM_TSO; 981 } 982 if (ifp->if_mtu > ETHERMTU && |
974 sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U) { 975 /* 976 * In Yukon EC Ultra, TSO & checksum offload is not 977 * supported for jumbo frame. 978 */ | 983 (sc_if->msk_flags & MSK_FLAG_JUMBO_NOCSUM) != 0) { |
979 ifp->if_hwassist &= ~(MSK_CSUM_FEATURES | CSUM_TSO); 980 ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_TXCSUM); 981 } 982 983 VLAN_CAPABILITIES(ifp); 984 MSK_IF_UNLOCK(sc_if); 985 break; 986 default: --- 414 unchanged lines hidden (view full) --- 1401 sc_if->msk_txq = Q_XA2; 1402 sc_if->msk_txsq = Q_XS2; 1403 sc_if->msk_rxq = Q_R2; 1404 } 1405 1406 callout_init_mtx(&sc_if->msk_tick_ch, &sc_if->msk_softc->msk_mtx, 0); 1407 msk_sysctl_node(sc_if); 1408 | 984 ifp->if_hwassist &= ~(MSK_CSUM_FEATURES | CSUM_TSO); 985 ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_TXCSUM); 986 } 987 988 VLAN_CAPABILITIES(ifp); 989 MSK_IF_UNLOCK(sc_if); 990 break; 991 default: --- 414 unchanged lines hidden (view full) --- 1406 sc_if->msk_txq = Q_XA2; 1407 sc_if->msk_txsq = Q_XS2; 1408 sc_if->msk_rxq = Q_R2; 1409 } 1410 1411 callout_init_mtx(&sc_if->msk_tick_ch, &sc_if->msk_softc->msk_mtx, 0); 1412 msk_sysctl_node(sc_if); 1413 |
1409 /* Disable jumbo frame for Yukon FE. */ 1410 if (sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_FE) 1411 sc_if->msk_flags |= MSK_FLAG_NOJUMBO; 1412 | |
1413 if ((error = msk_txrx_dma_alloc(sc_if) != 0)) 1414 goto fail; 1415 msk_rx_dma_jalloc(sc_if); 1416 1417 ifp = sc_if->msk_ifp = if_alloc(IFT_ETHER); 1418 if (ifp == NULL) { 1419 device_printf(sc_if->msk_if_dev, "can not if_alloc()\n"); 1420 error = ENOSPC; --- 183 unchanged lines hidden (view full) --- 1604 sc->msk_bustype = MSK_PEX_BUS; 1605 else if (pci_find_extcap(sc->msk_dev, PCIY_PCIX, ®) == 0) 1606 sc->msk_bustype = MSK_PCIX_BUS; 1607 else 1608 sc->msk_bustype = MSK_PCI_BUS; 1609 1610 switch (sc->msk_hw_id) { 1611 case CHIP_ID_YUKON_EC: | 1414 if ((error = msk_txrx_dma_alloc(sc_if) != 0)) 1415 goto fail; 1416 msk_rx_dma_jalloc(sc_if); 1417 1418 ifp = sc_if->msk_ifp = if_alloc(IFT_ETHER); 1419 if (ifp == NULL) { 1420 device_printf(sc_if->msk_if_dev, "can not if_alloc()\n"); 1421 error = ENOSPC; --- 183 unchanged lines hidden (view full) --- 1605 sc->msk_bustype = MSK_PEX_BUS; 1606 else if (pci_find_extcap(sc->msk_dev, PCIY_PCIX, ®) == 0) 1607 sc->msk_bustype = MSK_PCIX_BUS; 1608 else 1609 sc->msk_bustype = MSK_PCI_BUS; 1610 1611 switch (sc->msk_hw_id) { 1612 case CHIP_ID_YUKON_EC: |
1613 sc->msk_clock = 125; /* 125 Mhz */ 1614 sc->msk_pflags |= MSK_FLAG_JUMBO; 1615 break; |
|
1612 case CHIP_ID_YUKON_EC_U: 1613 sc->msk_clock = 125; /* 125 Mhz */ | 1616 case CHIP_ID_YUKON_EC_U: 1617 sc->msk_clock = 125; /* 125 Mhz */ |
1618 sc->msk_pflags |= MSK_FLAG_JUMBO | MSK_FLAG_JUMBO_NOCSUM; |
|
1614 break; 1615 case CHIP_ID_YUKON_FE: 1616 sc->msk_clock = 100; /* 100 Mhz */ | 1619 break; 1620 case CHIP_ID_YUKON_FE: 1621 sc->msk_clock = 100; /* 100 Mhz */ |
1622 sc->msk_pflags |= MSK_FLAG_FASTETHER; |
|
1617 break; 1618 case CHIP_ID_YUKON_XL: 1619 sc->msk_clock = 156; /* 156 Mhz */ | 1623 break; 1624 case CHIP_ID_YUKON_XL: 1625 sc->msk_clock = 156; /* 156 Mhz */ |
1626 sc->msk_pflags |= MSK_FLAG_JUMBO; |
|
1620 break; 1621 default: 1622 sc->msk_clock = 156; /* 156 Mhz */ 1623 break; 1624 } 1625 1626 /* Allocate IRQ resources. */ 1627 msic = pci_msi_count(dev); --- 525 unchanged lines hidden (view full) --- 2153static int 2154msk_rx_dma_jalloc(struct msk_if_softc *sc_if) 2155{ 2156 struct msk_dmamap_arg ctx; 2157 struct msk_rxdesc *jrxd; 2158 bus_size_t rxalign; 2159 int error, i; 2160 | 1627 break; 1628 default: 1629 sc->msk_clock = 156; /* 156 Mhz */ 1630 break; 1631 } 1632 1633 /* Allocate IRQ resources. */ 1634 msic = pci_msi_count(dev); --- 525 unchanged lines hidden (view full) --- 2160static int 2161msk_rx_dma_jalloc(struct msk_if_softc *sc_if) 2162{ 2163 struct msk_dmamap_arg ctx; 2164 struct msk_rxdesc *jrxd; 2165 bus_size_t rxalign; 2166 int error, i; 2167 |
2161 if (jumbo_disable != 0 || (sc_if->msk_flags & MSK_FLAG_NOJUMBO) != 0) { 2162 sc_if->msk_flags |= MSK_FLAG_NOJUMBO; | 2168 if (jumbo_disable != 0 || (sc_if->msk_flags & MSK_FLAG_JUMBO) == 0) { 2169 sc_if->msk_flags &= ~MSK_FLAG_JUMBO; |
2163 device_printf(sc_if->msk_if_dev, 2164 "disabling jumbo frame support\n"); | 2170 device_printf(sc_if->msk_if_dev, 2171 "disabling jumbo frame support\n"); |
2165 sc_if->msk_flags |= MSK_FLAG_NOJUMBO; | |
2166 return (0); 2167 } 2168 /* Create tag for jumbo Rx ring. */ 2169 error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ 2170 MSK_RING_ALIGN, 0, /* alignment, boundary */ 2171 BUS_SPACE_MAXADDR, /* lowaddr */ 2172 BUS_SPACE_MAXADDR, /* highaddr */ 2173 NULL, NULL, /* filter, filterarg */ --- 78 unchanged lines hidden (view full) --- 2252 } 2253 2254 return (0); 2255 2256jumbo_fail: 2257 msk_rx_dma_jfree(sc_if); 2258 device_printf(sc_if->msk_if_dev, "disabling jumbo frame support " 2259 "due to resource shortage\n"); | 2172 return (0); 2173 } 2174 /* Create tag for jumbo Rx ring. */ 2175 error = bus_dma_tag_create(sc_if->msk_cdata.msk_parent_tag,/* parent */ 2176 MSK_RING_ALIGN, 0, /* alignment, boundary */ 2177 BUS_SPACE_MAXADDR, /* lowaddr */ 2178 BUS_SPACE_MAXADDR, /* highaddr */ 2179 NULL, NULL, /* filter, filterarg */ --- 78 unchanged lines hidden (view full) --- 2258 } 2259 2260 return (0); 2261 2262jumbo_fail: 2263 msk_rx_dma_jfree(sc_if); 2264 device_printf(sc_if->msk_if_dev, "disabling jumbo frame support " 2265 "due to resource shortage\n"); |
2260 sc_if->msk_flags |= MSK_FLAG_NOJUMBO; | 2266 sc_if->msk_flags &= ~MSK_FLAG_JUMBO; |
2261 return (error); 2262} 2263 2264static void 2265msk_txrx_dma_free(struct msk_if_softc *sc_if) 2266{ 2267 struct msk_txdesc *txd; 2268 struct msk_rxdesc *rxd; --- 1216 unchanged lines hidden (view full) --- 3485 msk_stop(sc_if); 3486 3487 if (ifp->if_mtu < ETHERMTU) 3488 sc_if->msk_framesize = ETHERMTU; 3489 else 3490 sc_if->msk_framesize = ifp->if_mtu; 3491 sc_if->msk_framesize += ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; 3492 if (ifp->if_mtu > ETHERMTU && | 2267 return (error); 2268} 2269 2270static void 2271msk_txrx_dma_free(struct msk_if_softc *sc_if) 2272{ 2273 struct msk_txdesc *txd; 2274 struct msk_rxdesc *rxd; --- 1216 unchanged lines hidden (view full) --- 3491 msk_stop(sc_if); 3492 3493 if (ifp->if_mtu < ETHERMTU) 3494 sc_if->msk_framesize = ETHERMTU; 3495 else 3496 sc_if->msk_framesize = ifp->if_mtu; 3497 sc_if->msk_framesize += ETHER_HDR_LEN + ETHER_VLAN_ENCAP_LEN; 3498 if (ifp->if_mtu > ETHERMTU && |
3493 sc_if->msk_softc->msk_hw_id == CHIP_ID_YUKON_EC_U) { 3494 /* 3495 * In Yukon EC Ultra, TSO & checksum offload is not 3496 * supported for jumbo frame. 3497 */ | 3499 (sc_if->msk_flags & MSK_FLAG_JUMBO_NOCSUM) != 0) { |
3498 ifp->if_hwassist &= ~(MSK_CSUM_FEATURES | CSUM_TSO); 3499 ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_TXCSUM); 3500 } 3501 3502 /* 3503 * Initialize GMAC first. 3504 * Without this initialization, Rx MAC did not work as expected 3505 * and Rx MAC garbled status LEs and it resulted in out-of-order --- 727 unchanged lines hidden --- | 3500 ifp->if_hwassist &= ~(MSK_CSUM_FEATURES | CSUM_TSO); 3501 ifp->if_capenable &= ~(IFCAP_TSO4 | IFCAP_TXCSUM); 3502 } 3503 3504 /* 3505 * Initialize GMAC first. 3506 * Without this initialization, Rx MAC did not work as expected 3507 * and Rx MAC garbled status LEs and it resulted in out-of-order --- 727 unchanged lines hidden --- |