| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_wm.c,v 1.358 2015/10/13 08:14:27 knakahara Exp $ */ | | 1 | /* $NetBSD: if_wm.c,v 1.359 2015/10/13 08:17:15 knakahara Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. | | 4 | * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -73,27 +73,27 @@ | | | @@ -73,27 +73,27 @@ |
73 | * TODO (in order of importance): | | 73 | * TODO (in order of importance): |
74 | * | | 74 | * |
75 | * - Check XXX'ed comments | | 75 | * - Check XXX'ed comments |
76 | * - EEE (Energy Efficiency Ethernet) | | 76 | * - EEE (Energy Efficiency Ethernet) |
77 | * - Multi queue | | 77 | * - Multi queue |
78 | * - Image Unique ID | | 78 | * - Image Unique ID |
79 | * - LPLU other than PCH* | | 79 | * - LPLU other than PCH* |
80 | * - Virtual Function | | 80 | * - Virtual Function |
81 | * - Set LED correctly (based on contents in EEPROM) | | 81 | * - Set LED correctly (based on contents in EEPROM) |
82 | * - Rework how parameters are loaded from the EEPROM. | | 82 | * - Rework how parameters are loaded from the EEPROM. |
83 | */ | | 83 | */ |
84 | | | 84 | |
85 | #include <sys/cdefs.h> | | 85 | #include <sys/cdefs.h> |
86 | __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.358 2015/10/13 08:14:27 knakahara Exp $"); | | 86 | __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.359 2015/10/13 08:17:15 knakahara Exp $"); |
87 | | | 87 | |
88 | #ifdef _KERNEL_OPT | | 88 | #ifdef _KERNEL_OPT |
89 | #include "opt_net_mpsafe.h" | | 89 | #include "opt_net_mpsafe.h" |
90 | #endif | | 90 | #endif |
91 | | | 91 | |
92 | #include <sys/param.h> | | 92 | #include <sys/param.h> |
93 | #include <sys/systm.h> | | 93 | #include <sys/systm.h> |
94 | #include <sys/callout.h> | | 94 | #include <sys/callout.h> |
95 | #include <sys/mbuf.h> | | 95 | #include <sys/mbuf.h> |
96 | #include <sys/malloc.h> | | 96 | #include <sys/malloc.h> |
97 | #include <sys/kmem.h> | | 97 | #include <sys/kmem.h> |
98 | #include <sys/kernel.h> | | 98 | #include <sys/kernel.h> |
99 | #include <sys/socket.h> | | 99 | #include <sys/socket.h> |
| @@ -1629,26 +1629,33 @@ wm_attach(device_t parent, device_t self | | | @@ -1629,26 +1629,33 @@ wm_attach(device_t parent, device_t self |
1629 | preg = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); | | 1629 | preg = pci_conf_read(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); |
1630 | preg |= PCI_COMMAND_MASTER_ENABLE; | | 1630 | preg |= PCI_COMMAND_MASTER_ENABLE; |
1631 | if (sc->sc_type < WM_T_82542_2_1) | | 1631 | if (sc->sc_type < WM_T_82542_2_1) |
1632 | preg &= ~PCI_COMMAND_INVALIDATE_ENABLE; | | 1632 | preg &= ~PCI_COMMAND_INVALIDATE_ENABLE; |
1633 | pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, preg); | | 1633 | pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, preg); |
1634 | | | 1634 | |
1635 | /* power up chip */ | | 1635 | /* power up chip */ |
1636 | if ((error = pci_activate(pa->pa_pc, pa->pa_tag, self, | | 1636 | if ((error = pci_activate(pa->pa_pc, pa->pa_tag, self, |
1637 | NULL)) && error != EOPNOTSUPP) { | | 1637 | NULL)) && error != EOPNOTSUPP) { |
1638 | aprint_error_dev(sc->sc_dev, "cannot activate %d\n", error); | | 1638 | aprint_error_dev(sc->sc_dev, "cannot activate %d\n", error); |
1639 | return; | | 1639 | return; |
1640 | } | | 1640 | } |
1641 | | | 1641 | |
| | | 1642 | /* XXX Currently, Tx, Rx queue are always one. */ |
| | | 1643 | sc->sc_nrxqueues = 1; |
| | | 1644 | sc->sc_ntxqueues = 1; |
| | | 1645 | error = wm_alloc_txrx_queues(sc); |
| | | 1646 | if (error) |
| | | 1647 | return; |
| | | 1648 | |
1642 | #ifndef WM_MSI_MSIX | | 1649 | #ifndef WM_MSI_MSIX |
1643 | /* | | 1650 | /* |
1644 | * Map and establish our interrupt. | | 1651 | * Map and establish our interrupt. |
1645 | */ | | 1652 | */ |
1646 | if (pci_intr_map(pa, &ih)) { | | 1653 | if (pci_intr_map(pa, &ih)) { |
1647 | aprint_error_dev(sc->sc_dev, "unable to map interrupt\n"); | | 1654 | aprint_error_dev(sc->sc_dev, "unable to map interrupt\n"); |
1648 | return; | | 1655 | return; |
1649 | } | | 1656 | } |
1650 | intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf)); | | 1657 | intrstr = pci_intr_string(pc, ih, intrbuf, sizeof(intrbuf)); |
1651 | #ifdef WM_MPSAFE | | 1658 | #ifdef WM_MPSAFE |
1652 | pci_intr_setattr(pc, &ih, PCI_INTR_MPSAFE, true); | | 1659 | pci_intr_setattr(pc, &ih, PCI_INTR_MPSAFE, true); |
1653 | #endif | | 1660 | #endif |
1654 | sc->sc_ihs[0] = pci_intr_establish_xname(pc, ih, IPL_NET, | | 1661 | sc->sc_ihs[0] = pci_intr_establish_xname(pc, ih, IPL_NET, |
| @@ -1883,33 +1890,26 @@ alloc_retry: | | | @@ -1883,33 +1890,26 @@ alloc_retry: |
1883 | aprint_error_dev(sc->sc_dev, | | 1890 | aprint_error_dev(sc->sc_dev, |
1884 | "unknown PCIXSPD %d; assuming 66MHz\n", | | 1891 | "unknown PCIXSPD %d; assuming 66MHz\n", |
1885 | reg & STATUS_PCIXSPD_MASK); | | 1892 | reg & STATUS_PCIXSPD_MASK); |
1886 | sc->sc_bus_speed = 66; | | 1893 | sc->sc_bus_speed = 66; |
1887 | break; | | 1894 | break; |
1888 | } | | 1895 | } |
1889 | } else | | 1896 | } else |
1890 | sc->sc_bus_speed = (reg & STATUS_PCI66) ? 66 : 33; | | 1897 | sc->sc_bus_speed = (reg & STATUS_PCI66) ? 66 : 33; |
1891 | aprint_verbose_dev(sc->sc_dev, "%d-bit %dMHz %s bus\n", | | 1898 | aprint_verbose_dev(sc->sc_dev, "%d-bit %dMHz %s bus\n", |
1892 | (sc->sc_flags & WM_F_BUS64) ? 64 : 32, sc->sc_bus_speed, | | 1899 | (sc->sc_flags & WM_F_BUS64) ? 64 : 32, sc->sc_bus_speed, |
1893 | (sc->sc_flags & WM_F_PCIX) ? "PCIX" : "PCI"); | | 1900 | (sc->sc_flags & WM_F_PCIX) ? "PCIX" : "PCI"); |
1894 | } | | 1901 | } |
1895 | | | 1902 | |
1896 | /* XXX Currently, Tx, Rx queue are always one. */ | | | |
1897 | sc->sc_nrxqueues = 1; | | | |
1898 | sc->sc_ntxqueues = 1; | | | |
1899 | error = wm_alloc_txrx_queues(sc); | | | |
1900 | if (error) | | | |
1901 | return; | | | |
1902 | | | | |
1903 | /* clear interesting stat counters */ | | 1903 | /* clear interesting stat counters */ |
1904 | CSR_READ(sc, WMREG_COLC); | | 1904 | CSR_READ(sc, WMREG_COLC); |
1905 | CSR_READ(sc, WMREG_RXERRC); | | 1905 | CSR_READ(sc, WMREG_RXERRC); |
1906 | | | 1906 | |
1907 | /* get PHY control from SMBus to PCIe */ | | 1907 | /* get PHY control from SMBus to PCIe */ |
1908 | if ((sc->sc_type == WM_T_PCH) || (sc->sc_type == WM_T_PCH2) | | 1908 | if ((sc->sc_type == WM_T_PCH) || (sc->sc_type == WM_T_PCH2) |
1909 | || (sc->sc_type == WM_T_PCH_LPT)) | | 1909 | || (sc->sc_type == WM_T_PCH_LPT)) |
1910 | wm_smbustopci(sc); | | 1910 | wm_smbustopci(sc); |
1911 | | | 1911 | |
1912 | /* Reset the chip to a known state. */ | | 1912 | /* Reset the chip to a known state. */ |
1913 | wm_reset(sc); | | 1913 | wm_reset(sc); |
1914 | | | 1914 | |
1915 | /* Get some information about the EEPROM. */ | | 1915 | /* Get some information about the EEPROM. */ |