| @@ -1,37 +1,37 @@ | | | @@ -1,37 +1,37 @@ |
1 | /* $NetBSD: if_nfe.c,v 1.56 2012/07/22 14:33:03 matt Exp $ */ | | 1 | /* $NetBSD: if_nfe.c,v 1.57 2012/09/23 01:12:01 chs Exp $ */ |
2 | /* $OpenBSD: if_nfe.c,v 1.77 2008/02/05 16:52:50 brad Exp $ */ | | 2 | /* $OpenBSD: if_nfe.c,v 1.77 2008/02/05 16:52:50 brad Exp $ */ |
3 | | | 3 | |
4 | /*- | | 4 | /*- |
5 | * Copyright (c) 2006, 2007 Damien Bergamini <damien.bergamini@free.fr> | | 5 | * Copyright (c) 2006, 2007 Damien Bergamini <damien.bergamini@free.fr> |
6 | * Copyright (c) 2005, 2006 Jonathan Gray <jsg@openbsd.org> | | 6 | * Copyright (c) 2005, 2006 Jonathan Gray <jsg@openbsd.org> |
7 | * | | 7 | * |
8 | * Permission to use, copy, modify, and distribute this software for any | | 8 | * Permission to use, copy, modify, and distribute this software for any |
9 | * purpose with or without fee is hereby granted, provided that the above | | 9 | * purpose with or without fee is hereby granted, provided that the above |
10 | * copyright notice and this permission notice appear in all copies. | | 10 | * copyright notice and this permission notice appear in all copies. |
11 | * | | 11 | * |
12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | | 12 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | | 13 | * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | | 14 | * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | | 15 | * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | | 16 | * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | | 17 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | | 18 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
19 | */ | | 19 | */ |
20 | | | 20 | |
21 | /* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */ | | 21 | /* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */ |
22 | | | 22 | |
23 | #include <sys/cdefs.h> | | 23 | #include <sys/cdefs.h> |
24 | __KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.56 2012/07/22 14:33:03 matt Exp $"); | | 24 | __KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.57 2012/09/23 01:12:01 chs Exp $"); |
25 | | | 25 | |
26 | #include "opt_inet.h" | | 26 | #include "opt_inet.h" |
27 | #include "vlan.h" | | 27 | #include "vlan.h" |
28 | | | 28 | |
29 | #include <sys/param.h> | | 29 | #include <sys/param.h> |
30 | #include <sys/endian.h> | | 30 | #include <sys/endian.h> |
31 | #include <sys/systm.h> | | 31 | #include <sys/systm.h> |
32 | #include <sys/types.h> | | 32 | #include <sys/types.h> |
33 | #include <sys/sockio.h> | | 33 | #include <sys/sockio.h> |
34 | #include <sys/mbuf.h> | | 34 | #include <sys/mbuf.h> |
35 | #include <sys/mutex.h> | | 35 | #include <sys/mutex.h> |
36 | #include <sys/queue.h> | | 36 | #include <sys/queue.h> |
37 | #include <sys/kernel.h> | | 37 | #include <sys/kernel.h> |
| @@ -245,28 +245,26 @@ nfe_attach(device_t parent, device_t sel | | | @@ -245,28 +245,26 @@ nfe_attach(device_t parent, device_t sel |
245 | } | | 245 | } |
246 | | | 246 | |
247 | intrstr = pci_intr_string(pc, ih); | | 247 | intrstr = pci_intr_string(pc, ih); |
248 | sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, nfe_intr, sc); | | 248 | sc->sc_ih = pci_intr_establish(pc, ih, IPL_NET, nfe_intr, sc); |
249 | if (sc->sc_ih == NULL) { | | 249 | if (sc->sc_ih == NULL) { |
250 | aprint_error_dev(self, "could not establish interrupt"); | | 250 | aprint_error_dev(self, "could not establish interrupt"); |
251 | if (intrstr != NULL) | | 251 | if (intrstr != NULL) |
252 | aprint_error(" at %s", intrstr); | | 252 | aprint_error(" at %s", intrstr); |
253 | aprint_error("\n"); | | 253 | aprint_error("\n"); |
254 | goto fail; | | 254 | goto fail; |
255 | } | | 255 | } |
256 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); | | 256 | aprint_normal_dev(self, "interrupting at %s\n", intrstr); |
257 | | | 257 | |
258 | sc->sc_dmat = pa->pa_dmat; | | | |
259 | | | | |
260 | csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); | | 258 | csr = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG); |
261 | csr |= PCI_COMMAND_MASTER_ENABLE; | | 259 | csr |= PCI_COMMAND_MASTER_ENABLE; |
262 | pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, csr); | | 260 | pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_COMMAND_STATUS_REG, csr); |
263 | | | 261 | |
264 | sc->sc_flags = 0; | | 262 | sc->sc_flags = 0; |
265 | | | 263 | |
266 | switch (PCI_PRODUCT(pa->pa_id)) { | | 264 | switch (PCI_PRODUCT(pa->pa_id)) { |
267 | case PCI_PRODUCT_NVIDIA_NFORCE3_LAN2: | | 265 | case PCI_PRODUCT_NVIDIA_NFORCE3_LAN2: |
268 | case PCI_PRODUCT_NVIDIA_NFORCE3_LAN3: | | 266 | case PCI_PRODUCT_NVIDIA_NFORCE3_LAN3: |
269 | case PCI_PRODUCT_NVIDIA_NFORCE3_LAN4: | | 267 | case PCI_PRODUCT_NVIDIA_NFORCE3_LAN4: |
270 | case PCI_PRODUCT_NVIDIA_NFORCE3_LAN5: | | 268 | case PCI_PRODUCT_NVIDIA_NFORCE3_LAN5: |
271 | sc->sc_flags |= NFE_JUMBO_SUP | NFE_HW_CSUM; | | 269 | sc->sc_flags |= NFE_JUMBO_SUP | NFE_HW_CSUM; |
272 | break; | | 270 | break; |
| @@ -314,26 +312,31 @@ nfe_attach(device_t parent, device_t sel | | | @@ -314,26 +312,31 @@ nfe_attach(device_t parent, device_t sel |
314 | case PCI_PRODUCT_NVIDIA_MCP65_LAN3: | | 312 | case PCI_PRODUCT_NVIDIA_MCP65_LAN3: |
315 | case PCI_PRODUCT_NVIDIA_MCP65_LAN4: | | 313 | case PCI_PRODUCT_NVIDIA_MCP65_LAN4: |
316 | sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | | | 314 | sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | |
317 | NFE_CORRECT_MACADDR | NFE_PWR_MGMT; | | 315 | NFE_CORRECT_MACADDR | NFE_PWR_MGMT; |
318 | mii_flags = MIIF_DOPAUSE; | | 316 | mii_flags = MIIF_DOPAUSE; |
319 | break; | | 317 | break; |
320 | case PCI_PRODUCT_NVIDIA_MCP55_LAN1: | | 318 | case PCI_PRODUCT_NVIDIA_MCP55_LAN1: |
321 | case PCI_PRODUCT_NVIDIA_MCP55_LAN2: | | 319 | case PCI_PRODUCT_NVIDIA_MCP55_LAN2: |
322 | sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM | | | 320 | sc->sc_flags |= NFE_JUMBO_SUP | NFE_40BIT_ADDR | NFE_HW_CSUM | |
323 | NFE_HW_VLAN | NFE_PWR_MGMT; | | 321 | NFE_HW_VLAN | NFE_PWR_MGMT; |
324 | break; | | 322 | break; |
325 | } | | 323 | } |
326 | | | 324 | |
| | | 325 | if (pci_dma64_available(pa) && (sc->sc_flags & NFE_40BIT_ADDR) != 0) |
| | | 326 | sc->sc_dmat = pa->pa_dmat64; |
| | | 327 | else |
| | | 328 | sc->sc_dmat = pa->pa_dmat; |
| | | 329 | |
327 | nfe_poweron(self); | | 330 | nfe_poweron(self); |
328 | | | 331 | |
329 | #ifndef NFE_NO_JUMBO | | 332 | #ifndef NFE_NO_JUMBO |
330 | /* enable jumbo frames for adapters that support it */ | | 333 | /* enable jumbo frames for adapters that support it */ |
331 | if (sc->sc_flags & NFE_JUMBO_SUP) | | 334 | if (sc->sc_flags & NFE_JUMBO_SUP) |
332 | sc->sc_flags |= NFE_USE_JUMBO; | | 335 | sc->sc_flags |= NFE_USE_JUMBO; |
333 | #endif | | 336 | #endif |
334 | | | 337 | |
335 | /* Check for reversed ethernet address */ | | 338 | /* Check for reversed ethernet address */ |
336 | if ((NFE_READ(sc, NFE_TX_UNK) & NFE_MAC_ADDR_INORDER) != 0) | | 339 | if ((NFE_READ(sc, NFE_TX_UNK) & NFE_MAC_ADDR_INORDER) != 0) |
337 | sc->sc_flags |= NFE_CORRECT_MACADDR; | | 340 | sc->sc_flags |= NFE_CORRECT_MACADDR; |
338 | | | 341 | |
339 | nfe_get_macaddr(sc, sc->sc_enaddr); | | 342 | nfe_get_macaddr(sc, sc->sc_enaddr); |