Deleted Added
sdiff udiff text old ( 192720 ) new ( 192723 )
full compact
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 $");
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 if (ifr->ifr_mtu > MSK_JUMBO_MTU || ifr->ifr_mtu < ETHERMIN)
905 error = EINVAL;
906 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);
916 }
917 }
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 &&
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 */
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
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, &reg) == 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:
1612 case CHIP_ID_YUKON_EC_U:
1613 sc->msk_clock = 125; /* 125 Mhz */
1614 break;
1615 case CHIP_ID_YUKON_FE:
1616 sc->msk_clock = 100; /* 100 Mhz */
1617 break;
1618 case CHIP_ID_YUKON_XL:
1619 sc->msk_clock = 156; /* 156 Mhz */
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
2161 if (jumbo_disable != 0 || (sc_if->msk_flags & MSK_FLAG_NOJUMBO) != 0) {
2162 sc_if->msk_flags |= MSK_FLAG_NOJUMBO;
2163 device_printf(sc_if->msk_if_dev,
2164 "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");
2260 sc_if->msk_flags |= MSK_FLAG_NOJUMBO;
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 &&
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 */
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 ---