| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_wm.c,v 1.549 2017/12/08 05:22:23 ozaki-r Exp $ */ | | 1 | /* $NetBSD: if_wm.c,v 1.550 2017/12/28 06:13:50 msaitoh 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 | * - TX Multi queue improvement (refine queue selection logic) | | 76 | * - TX Multi queue improvement (refine queue selection logic) |
77 | * - Split header buffer for newer descriptors | | 77 | * - Split header buffer for newer descriptors |
78 | * - EEE (Energy Efficiency Ethernet) | | 78 | * - EEE (Energy Efficiency Ethernet) |
79 | * - Virtual Function | | 79 | * - Virtual Function |
80 | * - Set LED correctly (based on contents in EEPROM) | | 80 | * - Set LED correctly (based on contents in EEPROM) |
81 | * - Rework how parameters are loaded from the EEPROM. | | 81 | * - Rework how parameters are loaded from the EEPROM. |
82 | * - Image Unique ID | | 82 | * - Image Unique ID |
83 | */ | | 83 | */ |
84 | | | 84 | |
85 | #include <sys/cdefs.h> | | 85 | #include <sys/cdefs.h> |
86 | __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.549 2017/12/08 05:22:23 ozaki-r Exp $"); | | 86 | __KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.550 2017/12/28 06:13:50 msaitoh Exp $"); |
87 | | | 87 | |
88 | #ifdef _KERNEL_OPT | | 88 | #ifdef _KERNEL_OPT |
89 | #include "opt_net_mpsafe.h" | | 89 | #include "opt_net_mpsafe.h" |
90 | #include "opt_if_wm.h" | | 90 | #include "opt_if_wm.h" |
91 | #endif | | 91 | #endif |
92 | | | 92 | |
93 | #include <sys/param.h> | | 93 | #include <sys/param.h> |
94 | #include <sys/systm.h> | | 94 | #include <sys/systm.h> |
95 | #include <sys/callout.h> | | 95 | #include <sys/callout.h> |
96 | #include <sys/mbuf.h> | | 96 | #include <sys/mbuf.h> |
97 | #include <sys/malloc.h> | | 97 | #include <sys/malloc.h> |
98 | #include <sys/kmem.h> | | 98 | #include <sys/kmem.h> |
99 | #include <sys/kernel.h> | | 99 | #include <sys/kernel.h> |
| @@ -1840,36 +1840,45 @@ wm_attach(device_t parent, device_t self | | | @@ -1840,36 +1840,45 @@ wm_attach(device_t parent, device_t self |
1840 | preg |= PCI_COMMAND_MASTER_ENABLE; | | 1840 | preg |= PCI_COMMAND_MASTER_ENABLE; |
1841 | if (sc->sc_type < WM_T_82542_2_1) | | 1841 | if (sc->sc_type < WM_T_82542_2_1) |
1842 | preg &= ~PCI_COMMAND_INVALIDATE_ENABLE; | | 1842 | preg &= ~PCI_COMMAND_INVALIDATE_ENABLE; |
1843 | pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, preg); | | 1843 | pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, preg); |
1844 | | | 1844 | |
1845 | /* power up chip */ | | 1845 | /* power up chip */ |
1846 | if ((error = pci_activate(pa->pa_pc, pa->pa_tag, self, | | 1846 | if ((error = pci_activate(pa->pa_pc, pa->pa_tag, self, |
1847 | NULL)) && error != EOPNOTSUPP) { | | 1847 | NULL)) && error != EOPNOTSUPP) { |
1848 | aprint_error_dev(sc->sc_dev, "cannot activate %d\n", error); | | 1848 | aprint_error_dev(sc->sc_dev, "cannot activate %d\n", error); |
1849 | return; | | 1849 | return; |
1850 | } | | 1850 | } |
1851 | | | 1851 | |
1852 | wm_adjust_qnum(sc, pci_msix_count(pa->pa_pc, pa->pa_tag)); | | 1852 | wm_adjust_qnum(sc, pci_msix_count(pa->pa_pc, pa->pa_tag)); |
1853 | | | | |
1854 | /* Allocation settings */ | | | |
1855 | max_type = PCI_INTR_TYPE_MSIX; | | | |
1856 | /* | | 1853 | /* |
1857 | * 82583 has a MSI-X capability in the PCI configuration space but | | 1854 | * Don't use MSI-X if we can use only one queue to save interrupt |
1858 | * it doesn't support it. At least the document doesn't say anything | | 1855 | * resource. |
1859 | * about MSI-X. | | | |
1860 | */ | | 1856 | */ |
1861 | counts[PCI_INTR_TYPE_MSIX] | | 1857 | if (sc->sc_nqueues > 1) { |
1862 | = (sc->sc_type == WM_T_82583) ? 0 : sc->sc_nqueues + 1; | | 1858 | max_type = PCI_INTR_TYPE_MSIX; |
| | | 1859 | /* |
| | | 1860 | * 82583 has a MSI-X capability in the PCI configuration space |
| | | 1861 | * but it doesn't support it. At least the document doesn't |
| | | 1862 | * say anything about MSI-X. |
| | | 1863 | */ |
| | | 1864 | counts[PCI_INTR_TYPE_MSIX] |
| | | 1865 | = (sc->sc_type == WM_T_82583) ? 0 : sc->sc_nqueues + 1; |
| | | 1866 | } else { |
| | | 1867 | max_type = PCI_INTR_TYPE_MSI; |
| | | 1868 | counts[PCI_INTR_TYPE_MSIX] = 0; |
| | | 1869 | } |
| | | 1870 | |
| | | 1871 | /* Allocation settings */ |
1863 | counts[PCI_INTR_TYPE_MSI] = 1; | | 1872 | counts[PCI_INTR_TYPE_MSI] = 1; |
1864 | counts[PCI_INTR_TYPE_INTX] = 1; | | 1873 | counts[PCI_INTR_TYPE_INTX] = 1; |
1865 | /* overridden by disable flags */ | | 1874 | /* overridden by disable flags */ |
1866 | if (wm_disable_msi != 0) { | | 1875 | if (wm_disable_msi != 0) { |
1867 | counts[PCI_INTR_TYPE_MSI] = 0; | | 1876 | counts[PCI_INTR_TYPE_MSI] = 0; |
1868 | if (wm_disable_msix != 0) { | | 1877 | if (wm_disable_msix != 0) { |
1869 | max_type = PCI_INTR_TYPE_INTX; | | 1878 | max_type = PCI_INTR_TYPE_INTX; |
1870 | counts[PCI_INTR_TYPE_MSIX] = 0; | | 1879 | counts[PCI_INTR_TYPE_MSIX] = 0; |
1871 | } | | 1880 | } |
1872 | } else if (wm_disable_msix != 0) { | | 1881 | } else if (wm_disable_msix != 0) { |
1873 | max_type = PCI_INTR_TYPE_MSI; | | 1882 | max_type = PCI_INTR_TYPE_MSI; |
1874 | counts[PCI_INTR_TYPE_MSIX] = 0; | | 1883 | counts[PCI_INTR_TYPE_MSIX] = 0; |
1875 | } | | 1884 | } |