View | Details | Raw Unified | Return to bug 218579 | Differences between
and this patch

Collapse All | Expand All

(-)sys/dev/bge/if_bge.c (-4 / +89 lines)
Lines 491-496 Link Here
491
static void bge_stop_fw(struct bge_softc *);
491
static void bge_stop_fw(struct bge_softc *);
492
static int bge_reset(struct bge_softc *);
492
static int bge_reset(struct bge_softc *);
493
static void bge_link_upd(struct bge_softc *);
493
static void bge_link_upd(struct bge_softc *);
494
static void bge_setwol(struct bge_softc *);
495
static void bge_clrwol(struct bge_softc *);
494
496
495
static void bge_ape_lock_init(struct bge_softc *);
497
static void bge_ape_lock_init(struct bge_softc *);
496
static void bge_ape_read_fw_ver(struct bge_softc *);
498
static void bge_ape_read_fw_ver(struct bge_softc *);
Lines 935-940 Link Here
935
static void
937
static void
936
bge_ape_driver_state_change(struct bge_softc *sc, int kind)
938
bge_ape_driver_state_change(struct bge_softc *sc, int kind)
937
{
939
{
940
	struct ifnet *ifp;
938
	uint32_t apedata, event;
941
	uint32_t apedata, event;
939
942
940
	if ((sc->bge_mfw_flags & BGE_MFW_ON_APE) == 0)
943
	if ((sc->bge_mfw_flags & BGE_MFW_ON_APE) == 0)
Lines 967-975 Link Here
967
		event = BGE_APE_EVENT_STATUS_STATE_START;
970
		event = BGE_APE_EVENT_STATUS_STATE_START;
968
		break;
971
		break;
969
	case BGE_RESET_SHUTDOWN:
972
	case BGE_RESET_SHUTDOWN:
970
		APE_WRITE_4(sc, BGE_APE_HOST_DRVR_STATE,
973
                /* XXX  Needs rewording
971
		    BGE_APE_HOST_DRVR_STATE_UNLOAD);
974
                 * With the interface we are currently using,
972
		event = BGE_APE_EVENT_STATUS_STATE_UNLOAD;
975
                 * APE does not track driver state.  Wiping
976
                 * out the HOST SEGMENT SIGNATURE forces
977
                 * the APE to assume OS absent status.
978
                 */
979
		APE_WRITE_4(sc, BGE_APE_HOST_SEG_SIG, 0);
980
981
		ifp = sc->bge_ifp;
982
		if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) != 0) {
983
		    APE_WRITE_4(sc, BGE_APE_HOST_WOL_SPEED,
984
			BGE_APE_HOST_WOL_SPEED_AUTO);
985
		    APE_WRITE_4(sc, BGE_APE_HOST_DRVR_STATE,
986
			BGE_FW_DRV_STATE_WOL);
987
		    event = BGE_APE_EVENT_STATUS_STATE_WOL;
988
		    bge_ifmedia_upd_locked(ifp);
989
		} else {
990
		    APE_WRITE_4(sc, BGE_APE_HOST_DRVR_STATE,
991
			BGE_APE_HOST_DRVR_STATE_UNLOAD);
992
		    event = BGE_APE_EVENT_STATUS_STATE_UNLOAD;
993
		}
973
		break;
994
		break;
974
	case BGE_RESET_SUSPEND:
995
	case BGE_RESET_SUSPEND:
975
		event = BGE_APE_EVENT_STATUS_STATE_SUSPEND;
996
		event = BGE_APE_EVENT_STATUS_STATE_SUSPEND;
Lines 3750-3756 Link Here
3750
	if_setsendqready(ifp);
3771
	if_setsendqready(ifp);
3751
	if_sethwassist(ifp, sc->bge_csum_features);
3772
	if_sethwassist(ifp, sc->bge_csum_features);
3752
	if_setcapabilities(ifp, IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING |
3773
	if_setcapabilities(ifp, IFCAP_HWCSUM | IFCAP_VLAN_HWTAGGING |
3753
	    IFCAP_VLAN_MTU);
3774
	    IFCAP_VLAN_MTU | IFCAP_WOL_MAGIC);
3754
	if ((sc->bge_flags & (BGE_FLAG_TSO | BGE_FLAG_TSO3)) != 0) {
3775
	if ((sc->bge_flags & (BGE_FLAG_TSO | BGE_FLAG_TSO3)) != 0) {
3755
		if_sethwassistbits(ifp, CSUM_TSO, 0);
3776
		if_sethwassistbits(ifp, CSUM_TSO, 0);
3756
		if_setcapabilitiesbit(ifp, IFCAP_TSO4 | IFCAP_VLAN_HWTSO, 0);
3777
		if_setcapabilitiesbit(ifp, IFCAP_TSO4 | IFCAP_VLAN_HWTSO, 0);
Lines 3758-3763 Link Here
3758
#ifdef IFCAP_VLAN_HWCSUM
3779
#ifdef IFCAP_VLAN_HWCSUM
3759
	if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWCSUM, 0);
3780
	if_setcapabilitiesbit(ifp, IFCAP_VLAN_HWCSUM, 0);
3760
#endif
3781
#endif
3782
	if (pci_find_cap(dev, PCIY_PMG, &reg) == 0)
3783
		if_setcapabilitiesbit(ifp, IFCAP_WOL_MAGIC, 0);
3761
	if_setcapenable(ifp, if_getcapabilities(ifp));
3784
	if_setcapenable(ifp, if_getcapabilities(ifp));
3762
#ifdef DEVICE_POLLING
3785
#ifdef DEVICE_POLLING
3763
	if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0);
3786
	if_setcapabilitiesbit(ifp, IFCAP_POLLING, 0);
Lines 3942-3947 Link Here
3942
		ether_ifdetach(ifp);
3965
		ether_ifdetach(ifp);
3943
		device_printf(sc->bge_dev, "couldn't set up irq\n");
3966
		device_printf(sc->bge_dev, "couldn't set up irq\n");
3944
	}
3967
	}
3968
	BGE_LOCK(sc);
3969
	bge_clrwol(sc);
3970
	BGE_UNLOCK(sc);
3945
3971
3946
fail:
3972
fail:
3947
	if (error)
3973
	if (error)
Lines 5855-5860 Link Here
5855
			}
5881
			}
5856
		}
5882
		}
5857
#endif
5883
#endif
5884
		if ((mask & IFCAP_WOL_MAGIC) != 0 &&
5885
			(if_getcapabilities(ifp) & IFCAP_WOL_MAGIC) != 0)
5886
				if_togglecapenable(ifp, IFCAP_WOL_MAGIC);
5858
		if ((mask & IFCAP_TXCSUM) != 0 &&
5887
		if ((mask & IFCAP_TXCSUM) != 0 &&
5859
		    (if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
5888
		    (if_getcapabilities(ifp) & IFCAP_TXCSUM) != 0) {
5860
			if_togglecapenable(ifp, IFCAP_TXCSUM);
5889
			if_togglecapenable(ifp, IFCAP_TXCSUM);
Lines 6082-6087 Link Here
6082
6111
6083
	sc = device_get_softc(dev);
6112
	sc = device_get_softc(dev);
6084
	BGE_LOCK(sc);
6113
	BGE_LOCK(sc);
6114
#if 0
6115
	/* ifmdedia_set panic */
6116
	ifmedia_set(&sc->bge_ifmedia, IFM_ETHER | IFM_100_TX | IFM_HDX);
6117
#endif
6118
	bge_setwol(sc);
6085
	bge_stop(sc);
6119
	bge_stop(sc);
6086
	BGE_UNLOCK(sc);
6120
	BGE_UNLOCK(sc);
6087
6121
Lines 6095-6100 Link Here
6095
6129
6096
	sc = device_get_softc(dev);
6130
	sc = device_get_softc(dev);
6097
	BGE_LOCK(sc);
6131
	BGE_LOCK(sc);
6132
#if 0
6133
	/* ifmdedia_set panic */
6134
	ifmedia_set(&sc->bge_ifmedia, IFM_ETHER | IFM_100_TX | IFM_HDX);
6135
#endif
6136
	bge_setwol(sc);
6098
	bge_stop(sc);
6137
	bge_stop(sc);
6099
	BGE_UNLOCK(sc);
6138
	BGE_UNLOCK(sc);
6100
6139
Lines 6110-6115 Link Here
6110
	sc = device_get_softc(dev);
6149
	sc = device_get_softc(dev);
6111
	BGE_LOCK(sc);
6150
	BGE_LOCK(sc);
6112
	ifp = sc->bge_ifp;
6151
	ifp = sc->bge_ifp;
6152
	bge_clrwol(sc);
6153
	bge_reset(sc);
6113
	if (if_getflags(ifp) & IFF_UP) {
6154
	if (if_getflags(ifp) & IFF_UP) {
6114
		bge_init_locked(sc);
6155
		bge_init_locked(sc);
6115
		if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
6156
		if (if_getdrvflags(ifp) & IFF_DRV_RUNNING)
Lines 6796-6798 Link Here
6796
		return (if_get_counter_default(ifp, cnt));
6837
		return (if_get_counter_default(ifp, cnt));
6797
	}
6838
	}
6798
}
6839
}
6840
6841
static void
6842
bge_setwol(struct bge_softc *sc)
6843
{
6844
	struct ifnet *ifp;
6845
	uint16_t pmstat;
6846
	int pmc;
6847
6848
	if (pci_find_cap(sc->bge_dev, PCIY_PMG, &pmc) != 0)
6849
		return;
6850
	ifp = sc->bge_ifp;
6851
	if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) == 0)
6852
		return;
6853
	if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) != 0) {
6854
		BGE_SETBIT(sc, BGE_MAC_MODE, BGE_MACMODE_MAGIC_PKT_ENB);
6855
		BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_PORTMODE);
6856
		BGE_SETBIT(sc, BGE_MAC_MODE, BGE_PORTMODE_GMII);
6857
		BGE_SETBIT(sc, BGE_RX_MODE, BGE_RXMODE_ENABLE);
6858
	}
6859
	else {
6860
		BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_MAGIC_PKT_ENB);
6861
	}
6862
6863
	/* Request PME if WOL is requested. */
6864
	pmstat = pci_read_config(sc->bge_dev, pmc + PCIR_POWER_STATUS, 2);
6865
	pmstat &= ~(PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE);
6866
	if ((if_getcapenable(ifp) & IFCAP_WOL) != 0)
6867
		pmstat |= PCIM_PSTAT_PME | PCIM_PSTAT_PMEENABLE;
6868
	pci_write_config(sc->bge_dev, pmc + PCIR_POWER_STATUS, pmstat, 2);
6869
}
6870
6871
static void
6872
bge_clrwol(struct bge_softc *sc)
6873
{
6874
	struct ifnet *ifp;
6875
	int pmc;
6876
6877
	if (pci_find_cap(sc->bge_dev, PCIY_PMG, &pmc) != 0)
6878
		return;
6879
	ifp = sc->bge_ifp;
6880
	if ((if_getcapenable(ifp) & IFCAP_WOL_MAGIC) == 0)
6881
		return;
6882
	BGE_CLRBIT(sc, BGE_MAC_MODE, BGE_MACMODE_MAGIC_PKT_ENB);
6883
}

Return to bug 218579