Deleted Added
sdiff udiff text old ( 165138 ) new ( 165611 )
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 165138 2006-12-13 02:30:11Z 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>

--- 223 unchanged lines hidden (view full) ---

334static devclass_t msk_devclass;
335
336DRIVER_MODULE(mskc, pci, mskc_driver, mskc_devclass, 0, 0);
337DRIVER_MODULE(msk, mskc, msk_driver, msk_devclass, 0, 0);
338DRIVER_MODULE(miibus, msk, miibus_driver, miibus_devclass, 0, 0);
339
340static struct resource_spec msk_res_spec_io[] = {
341 { SYS_RES_IOPORT, PCIR_BAR(1), RF_ACTIVE },
342 { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
343 { -1, 0, 0 }
344};
345
346static struct resource_spec msk_res_spec_mem[] = {
347 { SYS_RES_MEMORY, PCIR_BAR(0), RF_ACTIVE },
348 { SYS_RES_IRQ, 0, RF_ACTIVE | RF_SHAREABLE },
349 { -1, 0, 0 }
350};
351
352static int
353msk_miibus_readreg(device_t dev, int phy, int reg)
354{
355 struct msk_if_softc *sc_if;
356
357 sc_if = device_get_softc(dev);
358
359 return (msk_phy_readreg(sc_if, phy, reg));

--- 1181 unchanged lines hidden (view full) ---

1541 mtx_init(&sc->msk_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
1542 MTX_DEF);
1543
1544 /*
1545 * Map control/status registers.
1546 */
1547 pci_enable_busmaster(dev);
1548
1549 /* Allocate resources */
1550 sc->msk_msi = 0;
1551 msic = pci_msi_count(dev);
1552 if (bootverbose)
1553 device_printf(dev, "MSI count : %d\n", msic);
1554 /*
1555 * Due to a unknown reason Yukon II reports it can handle two
1556 * messages even if it can handle just one message. Forcing
1557 * to allocate 1 message seems to work but reloading kernel
1558 * module after unloading the driver fails. Only use MSI when
1559 * it reports 1 message until we have better understanding
1560 * for the hardware.
1561 */
1562 if (msic == 1 && msi_disable == 0 && pci_alloc_msi(dev, &msic) == 0) {
1563 sc->msk_msi = 1;
1564 /* Set rid to 1 for SYS_RES_IRQ to use MSI. */
1565 msk_res_spec_io[1].rid = 1;
1566 msk_res_spec_mem[1].rid = 1;
1567 }
1568#ifdef MSK_USEIOSPACE
1569 sc->msk_res_spec = msk_res_spec_io;
1570#else
1571 sc->msk_res_spec = msk_res_spec_mem;
1572#endif
1573 error = bus_alloc_resources(dev, sc->msk_res_spec, sc->msk_res);
1574 if (error) {
1575 if (sc->msk_res_spec == msk_res_spec_mem)

--- 129 unchanged lines hidden (view full) ---

1705 HWF_WA_DEV_4115;
1706 }
1707 break;
1708 default:
1709 sc->msk_clock = 156; /* 156 Mhz */
1710 sc->msk_hw_feature = 0;
1711 }
1712
1713 if ((error = msk_status_dma_alloc(sc)) != 0)
1714 goto fail;
1715
1716 /* Set base interrupt mask. */
1717 sc->msk_intrmask = Y2_IS_HW_ERR | Y2_IS_STAT_BMU;
1718 sc->msk_intrhwemask = Y2_IS_TIST_OV | Y2_IS_MST_ERR |
1719 Y2_IS_IRQ_STAT | Y2_IS_PCI_EXP | Y2_IS_PCI_NEXP;
1720

--- 44 unchanged lines hidden (view full) ---

1765 }
1766
1767 TASK_INIT(&sc->msk_int_task, 0, msk_int_task, sc);
1768 sc->msk_tq = taskqueue_create_fast("msk_taskq", M_WAITOK,
1769 taskqueue_thread_enqueue, &sc->msk_tq);
1770 taskqueue_start_threads(&sc->msk_tq, 1, PI_NET, "%s taskq",
1771 device_get_nameunit(sc->msk_dev));
1772 /* Hook interrupt last to avoid having to lock softc. */
1773 error = bus_setup_intr(dev, sc->msk_res[1], INTR_TYPE_NET |
1774 INTR_MPSAFE | INTR_FAST, msk_intr, sc, &sc->msk_intrhand);
1775
1776 if (error != 0) {
1777 device_printf(dev, "couldn't set up interrupt handler\n");
1778 taskqueue_free(sc->msk_tq);
1779 sc->msk_tq = NULL;
1780 goto fail;
1781 }
1782fail:

--- 96 unchanged lines hidden (view full) ---

1879
1880 msk_status_dma_free(sc);
1881
1882 if (sc->msk_tq != NULL) {
1883 taskqueue_drain(sc->msk_tq, &sc->msk_int_task);
1884 taskqueue_free(sc->msk_tq);
1885 sc->msk_tq = NULL;
1886 }
1887 if (sc->msk_intrhand) {
1888 bus_teardown_intr(dev, sc->msk_res[1], sc->msk_intrhand);
1889 sc->msk_intrhand = NULL;
1890 }
1891 if (sc->msk_msi)
1892 pci_release_msi(dev);
1893 bus_release_resources(dev, sc->msk_res_spec, sc->msk_res);
1894 mtx_destroy(&sc->msk_mtx);
1895
1896 return (0);
1897}
1898

--- 2150 unchanged lines hidden ---