| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: if_bge.c,v 1.152.4.3 2009/08/04 19:46:20 snj Exp $ */ | | 1 | /* $NetBSD: if_bge.c,v 1.152.4.4 2009/08/04 19:57:24 snj Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 2001 Wind River Systems | | 4 | * Copyright (c) 2001 Wind River Systems |
5 | * Copyright (c) 1997, 1998, 1999, 2001 | | 5 | * Copyright (c) 1997, 1998, 1999, 2001 |
6 | * Bill Paul <wpaul@windriver.com>. All rights reserved. | | 6 | * Bill Paul <wpaul@windriver.com>. All rights reserved. |
7 | * | | 7 | * |
8 | * Redistribution and use in source and binary forms, with or without | | 8 | * Redistribution and use in source and binary forms, with or without |
9 | * modification, are permitted provided that the following conditions | | 9 | * modification, are permitted provided that the following conditions |
10 | * are met: | | 10 | * are met: |
11 | * 1. Redistributions of source code must retain the above copyright | | 11 | * 1. Redistributions of source code must retain the above copyright |
12 | * notice, this list of conditions and the following disclaimer. | | 12 | * notice, this list of conditions and the following disclaimer. |
13 | * 2. Redistributions in binary form must reproduce the above copyright | | 13 | * 2. Redistributions in binary form must reproduce the above copyright |
14 | * notice, this list of conditions and the following disclaimer in the | | 14 | * notice, this list of conditions and the following disclaimer in the |
| @@ -69,27 +69,27 @@ | | | @@ -69,27 +69,27 @@ |
69 | * does not support external SSRAM. | | 69 | * does not support external SSRAM. |
70 | * | | 70 | * |
71 | * Broadcom also produces a variation of the BCM5700 under the "Altima" | | 71 | * Broadcom also produces a variation of the BCM5700 under the "Altima" |
72 | * brand name, which is functionally similar but lacks PCI-X support. | | 72 | * brand name, which is functionally similar but lacks PCI-X support. |
73 | * | | 73 | * |
74 | * Without external SSRAM, you can only have at most 4 TX rings, | | 74 | * Without external SSRAM, you can only have at most 4 TX rings, |
75 | * and the use of the mini RX ring is disabled. This seems to imply | | 75 | * and the use of the mini RX ring is disabled. This seems to imply |
76 | * that these features are simply not available on the BCM5701. As a | | 76 | * that these features are simply not available on the BCM5701. As a |
77 | * result, this driver does not implement any support for the mini RX | | 77 | * result, this driver does not implement any support for the mini RX |
78 | * ring. | | 78 | * ring. |
79 | */ | | 79 | */ |
80 | | | 80 | |
81 | #include <sys/cdefs.h> | | 81 | #include <sys/cdefs.h> |
82 | __KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.152.4.3 2009/08/04 19:46:20 snj Exp $"); | | 82 | __KERNEL_RCSID(0, "$NetBSD: if_bge.c,v 1.152.4.4 2009/08/04 19:57:24 snj Exp $"); |
83 | | | 83 | |
84 | #include "bpfilter.h" | | 84 | #include "bpfilter.h" |
85 | #include "vlan.h" | | 85 | #include "vlan.h" |
86 | #include "rnd.h" | | 86 | #include "rnd.h" |
87 | | | 87 | |
88 | #include <sys/param.h> | | 88 | #include <sys/param.h> |
89 | #include <sys/systm.h> | | 89 | #include <sys/systm.h> |
90 | #include <sys/callout.h> | | 90 | #include <sys/callout.h> |
91 | #include <sys/sockio.h> | | 91 | #include <sys/sockio.h> |
92 | #include <sys/mbuf.h> | | 92 | #include <sys/mbuf.h> |
93 | #include <sys/malloc.h> | | 93 | #include <sys/malloc.h> |
94 | #include <sys/kernel.h> | | 94 | #include <sys/kernel.h> |
95 | #include <sys/device.h> | | 95 | #include <sys/device.h> |
| @@ -2549,26 +2549,30 @@ bge_attach(device_t parent, device_t sel | | | @@ -2549,26 +2549,30 @@ bge_attach(device_t parent, device_t sel |
2549 | bge_read_eeprom(sc, (void *)&hwcfg, | | 2549 | bge_read_eeprom(sc, (void *)&hwcfg, |
2550 | BGE_EE_HWCFG_OFFSET, sizeof(hwcfg)); | | 2550 | BGE_EE_HWCFG_OFFSET, sizeof(hwcfg)); |
2551 | hwcfg = be32toh(hwcfg); | | 2551 | hwcfg = be32toh(hwcfg); |
2552 | } | | 2552 | } |
2553 | /* The SysKonnect SK-9D41 is a 1000baseSX card. */ | | 2553 | /* The SysKonnect SK-9D41 is a 1000baseSX card. */ |
2554 | if (PCI_PRODUCT(pa->pa_id) == SK_SUBSYSID_9D41 || | | 2554 | if (PCI_PRODUCT(pa->pa_id) == SK_SUBSYSID_9D41 || |
2555 | (hwcfg & BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER) { | | 2555 | (hwcfg & BGE_HWCFG_MEDIA) == BGE_MEDIA_FIBER) { |
2556 | if (BGE_IS_5714_FAMILY(sc)) | | 2556 | if (BGE_IS_5714_FAMILY(sc)) |
2557 | sc->bge_flags |= BGE_PHY_FIBER_MII; | | 2557 | sc->bge_flags |= BGE_PHY_FIBER_MII; |
2558 | else | | 2558 | else |
2559 | sc->bge_flags |= BGE_PHY_FIBER_TBI; | | 2559 | sc->bge_flags |= BGE_PHY_FIBER_TBI; |
2560 | } | | 2560 | } |
2561 | | | 2561 | |
| | | 2562 | /* set phyflags before mii_attach() */ |
| | | 2563 | dict = device_properties(self); |
| | | 2564 | prop_dictionary_set_uint32(dict, "phyflags", sc->bge_flags); |
| | | 2565 | |
2562 | if (sc->bge_flags & BGE_PHY_FIBER_TBI) { | | 2566 | if (sc->bge_flags & BGE_PHY_FIBER_TBI) { |
2563 | ifmedia_init(&sc->bge_ifmedia, IFM_IMASK, bge_ifmedia_upd, | | 2567 | ifmedia_init(&sc->bge_ifmedia, IFM_IMASK, bge_ifmedia_upd, |
2564 | bge_ifmedia_sts); | | 2568 | bge_ifmedia_sts); |
2565 | ifmedia_add(&sc->bge_ifmedia, IFM_ETHER|IFM_1000_SX, 0, NULL); | | 2569 | ifmedia_add(&sc->bge_ifmedia, IFM_ETHER|IFM_1000_SX, 0, NULL); |
2566 | ifmedia_add(&sc->bge_ifmedia, IFM_ETHER|IFM_1000_SX|IFM_FDX, | | 2570 | ifmedia_add(&sc->bge_ifmedia, IFM_ETHER|IFM_1000_SX|IFM_FDX, |
2567 | 0, NULL); | | 2571 | 0, NULL); |
2568 | ifmedia_add(&sc->bge_ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL); | | 2572 | ifmedia_add(&sc->bge_ifmedia, IFM_ETHER|IFM_AUTO, 0, NULL); |
2569 | ifmedia_set(&sc->bge_ifmedia, IFM_ETHER|IFM_AUTO); | | 2573 | ifmedia_set(&sc->bge_ifmedia, IFM_ETHER|IFM_AUTO); |
2570 | /* Pretend the user requested this setting */ | | 2574 | /* Pretend the user requested this setting */ |
2571 | sc->bge_ifmedia.ifm_media = sc->bge_ifmedia.ifm_cur->ifm_media; | | 2575 | sc->bge_ifmedia.ifm_media = sc->bge_ifmedia.ifm_cur->ifm_media; |
2572 | } else { | | 2576 | } else { |
2573 | /* | | 2577 | /* |
2574 | * Do transceiver setup. | | 2578 | * Do transceiver setup. |
| @@ -2637,29 +2641,26 @@ bge_attach(device_t parent, device_t sel | | | @@ -2637,29 +2641,26 @@ bge_attach(device_t parent, device_t sel |
2637 | NULL, device_xname(sc->bge_dev), "rx_xon"); | | 2641 | NULL, device_xname(sc->bge_dev), "rx_xon"); |
2638 | evcnt_attach_dynamic(&sc->bge_ev_rx_macctl, EVCNT_TYPE_MISC, | | 2642 | evcnt_attach_dynamic(&sc->bge_ev_rx_macctl, EVCNT_TYPE_MISC, |
2639 | NULL, device_xname(sc->bge_dev), "rx_macctl"); | | 2643 | NULL, device_xname(sc->bge_dev), "rx_macctl"); |
2640 | evcnt_attach_dynamic(&sc->bge_ev_xoffentered, EVCNT_TYPE_MISC, | | 2644 | evcnt_attach_dynamic(&sc->bge_ev_xoffentered, EVCNT_TYPE_MISC, |
2641 | NULL, device_xname(sc->bge_dev), "xoffentered"); | | 2645 | NULL, device_xname(sc->bge_dev), "xoffentered"); |
2642 | #endif /* BGE_EVENT_COUNTERS */ | | 2646 | #endif /* BGE_EVENT_COUNTERS */ |
2643 | DPRINTFN(5, ("callout_init\n")); | | 2647 | DPRINTFN(5, ("callout_init\n")); |
2644 | callout_init(&sc->bge_timeout, 0); | | 2648 | callout_init(&sc->bge_timeout, 0); |
2645 | | | 2649 | |
2646 | if (!pmf_device_register(self, NULL, NULL)) | | 2650 | if (!pmf_device_register(self, NULL, NULL)) |
2647 | aprint_error_dev(self, "couldn't establish power handler\n"); | | 2651 | aprint_error_dev(self, "couldn't establish power handler\n"); |
2648 | else | | 2652 | else |
2649 | pmf_class_network_register(self, ifp); | | 2653 | pmf_class_network_register(self, ifp); |
2650 | | | | |
2651 | dict = device_properties(self); | | | |
2652 | prop_dictionary_set_uint32(dict, "phyflags", sc->bge_flags); | | | |
2653 | } | | 2654 | } |
2654 | | | 2655 | |
2655 | static void | | 2656 | static void |
2656 | bge_release_resources(struct bge_softc *sc) | | 2657 | bge_release_resources(struct bge_softc *sc) |
2657 | { | | 2658 | { |
2658 | if (sc->bge_vpd_prodname != NULL) | | 2659 | if (sc->bge_vpd_prodname != NULL) |
2659 | free(sc->bge_vpd_prodname, M_DEVBUF); | | 2660 | free(sc->bge_vpd_prodname, M_DEVBUF); |
2660 | | | 2661 | |
2661 | if (sc->bge_vpd_readonly != NULL) | | 2662 | if (sc->bge_vpd_readonly != NULL) |
2662 | free(sc->bge_vpd_readonly, M_DEVBUF); | | 2663 | free(sc->bge_vpd_readonly, M_DEVBUF); |
2663 | } | | 2664 | } |
2664 | | | 2665 | |
2665 | static void | | 2666 | static void |