Tue Oct 31 13:57:08 2023 UTC ()
eqos_pci: Limit to 32bit DMA only for PSE devices.


(msaitoh)
diff -r1.2 -r1.3 src/sys/dev/pci/if_eqos_pci.c

cvs diff -r1.2 -r1.3 src/sys/dev/pci/if_eqos_pci.c (expand / switch to unified diff)

--- src/sys/dev/pci/if_eqos_pci.c 2023/10/26 18:02:51 1.2
+++ src/sys/dev/pci/if_eqos_pci.c 2023/10/31 13:57:08 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: if_eqos_pci.c,v 1.2 2023/10/26 18:02:51 msaitoh Exp $ */ 1/* $NetBSD: if_eqos_pci.c,v 1.3 2023/10/31 13:57:08 msaitoh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2023 Masanobu SAITOH <msaitoh@netbsd.org> 4 * Copyright (c) 2023 Masanobu SAITOH <msaitoh@netbsd.org>
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -25,27 +25,27 @@ @@ -25,27 +25,27 @@
25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * TODO: 30 * TODO:
31 * Use multi vector MSI to support multiqueue. 31 * Use multi vector MSI to support multiqueue.
32 * 32 *
33 */ 33 */
34 34
35#include "opt_net_mpsafe.h" 35#include "opt_net_mpsafe.h"
36 36
37#include <sys/cdefs.h> 37#include <sys/cdefs.h>
38__KERNEL_RCSID(0, "$NetBSD: if_eqos_pci.c,v 1.2 2023/10/26 18:02:51 msaitoh Exp $"); 38__KERNEL_RCSID(0, "$NetBSD: if_eqos_pci.c,v 1.3 2023/10/31 13:57:08 msaitoh Exp $");
39 39
40#include <sys/param.h> 40#include <sys/param.h>
41#include <sys/bus.h> 41#include <sys/bus.h>
42#include <sys/device.h> 42#include <sys/device.h>
43#include <sys/rndsource.h> 43#include <sys/rndsource.h>
44 44
45#include <net/if_ether.h> 45#include <net/if_ether.h>
46#include <net/if_media.h> 46#include <net/if_media.h>
47 47
48#include <dev/pci/pcireg.h> 48#include <dev/pci/pcireg.h>
49#include <dev/pci/pcivar.h> 49#include <dev/pci/pcivar.h>
50#include <dev/pci/pcidevs.h> 50#include <dev/pci/pcidevs.h>
51 51
@@ -120,59 +120,60 @@ eqos_pci_attach(device_t parent, device_ @@ -120,59 +120,60 @@ eqos_pci_attach(device_t parent, device_
120 psc->sc_pcidevid = PCI_PRODUCT(pa->pa_id); 120 psc->sc_pcidevid = PCI_PRODUCT(pa->pa_id);
121 121
122 memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, PCI_BAR0); 122 memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, PCI_BAR0);
123 if (pci_mapreg_map(pa, PCI_BAR0, memtype, 0, &memt, &memh, NULL, 123 if (pci_mapreg_map(pa, PCI_BAR0, memtype, 0, &memt, &memh, NULL,
124 &memsize) != 0) { 124 &memsize) != 0) {
125 aprint_error(": can't map mem space\n"); 125 aprint_error(": can't map mem space\n");
126 return; 126 return;
127 } 127 }
128 sc->sc_dev = self; 128 sc->sc_dev = self;
129 sc->sc_bst = memt; 129 sc->sc_bst = memt;
130 sc->sc_bsh = memh; 130 sc->sc_bsh = memh;
131 prop = device_properties(sc->sc_dev); 131 prop = device_properties(sc->sc_dev);
132 132
133#if 0 /* I don't know why dmat64 doesn't work... */ 133 if (pci_dma64_available(pa))
134 if (pci_dma64_available(pa)) { 
135 aprint_verbose(", 64-bit DMA"); 
136 sc->sc_dmat = pa->pa_dmat64; 134 sc->sc_dmat = pa->pa_dmat64;
137 } else { 135 else
138 aprint_verbose(", 32-bit DMA"); 
139 sc->sc_dmat = pa->pa_dmat; 136 sc->sc_dmat = pa->pa_dmat;
140 } 137
141#else 
142 sc->sc_dmat = pa->pa_dmat; 
143#endif 
144 sc->sc_phy_id = MII_PHY_ANY; 138 sc->sc_phy_id = MII_PHY_ANY;
145 switch (psc->sc_pcidevid) { 139 switch (psc->sc_pcidevid) {
146 case PCI_PRODUCT_INTEL_EHL_ETH: 140 case PCI_PRODUCT_INTEL_EHL_ETH:
147 sc->sc_csr_clock = 204800000; 141 sc->sc_csr_clock = 204800000;
148 dma_pbl = 32; 142 dma_pbl = 32;
149 break; 143 break;
150 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_RGMII: 144 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_RGMII:
151 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_RGMII: 145 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_RGMII:
152 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_SGMII_1G: 146 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_SGMII_1G:
153 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_SGMII_1G: 147 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_SGMII_1G:
154 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_SGMII_2_5G: 148 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_0_SGMII_2_5G:
155 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_SGMII_2_5G: 149 case PCI_PRODUCT_INTEL_EHL_PSE_ETH_1_SGMII_2_5G:
 150 sc->sc_dmat = pa->pa_dmat; /* 32bit DMA only */
156 sc->sc_csr_clock = 200000000; 151 sc->sc_csr_clock = 200000000;
157 dma_pbl = 32; 152 dma_pbl = 32;
158 break; 153 break;
159#if 0 154#if 0
160 case PCI_PRODUCT_INTEL_QUARTK_ETH: 155 case PCI_PRODUCT_INTEL_QUARTK_ETH:
161 dma_pbl = 16; 156 dma_pbl = 16;
162#endif 157#endif
163 default: 158 default:
164 sc->sc_csr_clock = 200000000; /* XXX */ 159 sc->sc_csr_clock = 200000000; /* XXX */
165 } 160 }
 161
 162 if (sc->sc_dmat == pa->pa_dmat64)
 163 aprint_verbose(", 64-bit DMA");
 164 else
 165 aprint_verbose(", 32-bit DMA");
 166
166 /* Defaults */ 167 /* Defaults */
167 if (dma_pbl != 0) { 168 if (dma_pbl != 0) {
168 prop = device_properties(sc->sc_dev); 169 prop = device_properties(sc->sc_dev);
169 prop_dictionary_set_uint32(prop, "snps,pbl", dma_pbl); 170 prop_dictionary_set_uint32(prop, "snps,pbl", dma_pbl);
170 } 171 }
171 172
172 if (eqos_attach(sc) != 0) { 173 if (eqos_attach(sc) != 0) {
173 aprint_error_dev(sc->sc_dev, "failed in eqos_attach()\n"); 174 aprint_error_dev(sc->sc_dev, "failed in eqos_attach()\n");
174 return; 175 return;
175 } 176 }
176 177
177 /* Allocation settings */ 178 /* Allocation settings */
178 counts[PCI_INTR_TYPE_MSI] = 1; 179 counts[PCI_INTR_TYPE_MSI] = 1;