diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2014-09-06 04:46:59 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2014-09-06 04:46:59 +0000 |
commit | 0e08178557a263e97ce7f98c3e93498df080c1cc (patch) | |
tree | 713d2692092e961a08ba8519d5fcd7f6c8bca89b /sys | |
parent | 1856cb461815dc29ef425f762867e7d638c94235 (diff) |
Various changes to the re(4) feature flags..
Changed RL_FLAG_MACLDPS to RL_FLAG_MACRESET.
Removed RL_FLAG_INVMAR and RL_FLAG_NOJUMBO.
Added RL_FLAG_FASTETHER, RL_FLAG_CMDSTOP_WAIT_TXQ, RL_FLAG_JUMBOV2, RL_FLAG_WOL_MANLINK,
RL_FLAG_WAIT_TXPOLL, RL_FLAG_WOLRXENB.
Also set in the softc the maximum MTU for the various generations of chips.
Input from and Ok jsg@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/cardbus/if_re_cardbus.c | 4 | ||||
-rw-r--r-- | sys/dev/ic/re.c | 128 | ||||
-rw-r--r-- | sys/dev/ic/rtl81x9reg.h | 52 | ||||
-rw-r--r-- | sys/dev/pci/if_re_pci.c | 4 |
4 files changed, 121 insertions, 67 deletions
diff --git a/sys/dev/cardbus/if_re_cardbus.c b/sys/dev/cardbus/if_re_cardbus.c index 1a6456846dc..8262596f597 100644 --- a/sys/dev/cardbus/if_re_cardbus.c +++ b/sys/dev/cardbus/if_re_cardbus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_re_cardbus.c,v 1.24 2014/08/11 12:45:45 mpi Exp $ */ +/* $OpenBSD: if_re_cardbus.c,v 1.25 2014/09/06 04:46:58 brad Exp $ */ /* * Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org> @@ -152,6 +152,8 @@ re_cardbus_attach(struct device *parent, struct device *self, void *aux) } snprintf(intrstr, sizeof(intrstr), "irq %d", ca->ca_intrline); + sc->sc_product = PCI_PRODUCT(ca->ca_id); + /* Call bus-independent (common) attach routine */ if (re_attach(sc, intrstr)) { cardbus_intr_disestablish(ct->ct_cc, ct->ct_cf, csc->sc_ih); diff --git a/sys/dev/ic/re.c b/sys/dev/ic/re.c index 12a0bed6e8f..9ca81f4c309 100644 --- a/sys/dev/ic/re.c +++ b/sys/dev/ic/re.c @@ -1,4 +1,4 @@ -/* $OpenBSD: re.c,v 1.155 2014/07/22 13:12:12 mpi Exp $ */ +/* $OpenBSD: re.c,v 1.156 2014/09/06 04:46:58 brad Exp $ */ /* $FreeBSD: if_re.c,v 1.31 2004/09/04 07:54:05 ru Exp $ */ /* * Copyright (c) 1997, 1998-2003 @@ -121,6 +121,8 @@ #include <sys/timeout.h> #include <sys/socket.h> +#include <machine/bus.h> + #include <net/if.h> #include <net/if_dl.h> #include <net/if_media.h> @@ -142,8 +144,7 @@ #include <dev/mii/mii.h> #include <dev/mii/miivar.h> -#include <dev/pci/pcireg.h> -#include <dev/pci/pcivar.h> +#include <dev/pci/pcidevs.h> #include <dev/ic/rtl81x9reg.h> #include <dev/ic/revar.h> @@ -578,7 +579,7 @@ re_iff(struct rl_softc *sc) * parts. This means we have to write the hash pattern in reverse * order for those devices. */ - if (sc->rl_flags & RL_FLAG_INVMAR) { + if (sc->rl_flags & RL_FLAG_PCIE) { CSR_WRITE_4(sc, RL_MAR0, swap32(hashes[1])); CSR_WRITE_4(sc, RL_MAR4, swap32(hashes[0])); } else { @@ -604,7 +605,7 @@ re_reset(struct rl_softc *sc) if (i == RL_TIMEOUT) printf("%s: reset never completed!\n", sc->sc_dev.dv_xname); - if (sc->rl_flags & RL_FLAG_MACLDPS) + if (sc->rl_flags & RL_FLAG_MACRESET) CSR_WRITE_1(sc, RL_LDPS, 1); } @@ -639,13 +640,14 @@ re_attach(struct rl_softc *sc, const char *intrstr) switch (sc->sc_hwrev) { case RL_HWREV_8139CPLUS: - sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_AUTOPAD; + sc->rl_flags |= RL_FLAG_FASTETHER | RL_FLAG_AUTOPAD; + sc->rl_max_mtu = RL_MTU; break; case RL_HWREV_8100E: case RL_HWREV_8100E_SPIN2: case RL_HWREV_8101E: - sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR | - RL_FLAG_PHYWAKE; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_FASTETHER; + sc->rl_max_mtu = RL_MTU; break; case RL_HWREV_8103E: sc->rl_flags |= RL_FLAG_MACSLEEP; @@ -653,70 +655,103 @@ re_attach(struct rl_softc *sc, const char *intrstr) case RL_HWREV_8102E: case RL_HWREV_8102EL: case RL_HWREV_8102EL_SPIN1: - sc->rl_flags |= RL_FLAG_NOJUMBO | RL_FLAG_INVMAR | - RL_FLAG_PHYWAKE | RL_FLAG_PAR | RL_FLAG_DESCV2 | - RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | + RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_FASTETHER | + RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD; + sc->rl_max_mtu = RL_MTU; break; case RL_HWREV_8401E: - case RL_HWREV_8402: case RL_HWREV_8105E: case RL_HWREV_8105E_SPIN1: case RL_HWREV_8106E: - sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | - RL_FLAG_PHYWAKE_PM | RL_FLAG_PAR | RL_FLAG_DESCV2 | - RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD | - RL_FLAG_NOJUMBO; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHYWAKE_PM | + RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | + RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD; + sc->rl_max_mtu = RL_MTU; + break; + case RL_HWREV_8402: + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHYWAKE_PM | + RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | + RL_FLAG_FASTETHER | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD | + RL_FLAG_CMDSTOP_WAIT_TXQ; + sc->rl_max_mtu = RL_MTU; break; case RL_HWREV_8168B_SPIN1: case RL_HWREV_8168B_SPIN2: + sc->rl_flags |= RL_FLAG_WOLRXENB; + /* FALLTHROUGH */ case RL_HWREV_8168B_SPIN3: - sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | - RL_FLAG_MACSTAT | RL_FLAG_HWIM; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_MACSTAT; + sc->rl_max_mtu = RL_MTU; break; case RL_HWREV_8168C_SPIN2: sc->rl_flags |= RL_FLAG_MACSLEEP; /* FALLTHROUGH */ case RL_HWREV_8168C: case RL_HWREV_8168CP: - case RL_HWREV_8168DP: - sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | - RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | - RL_FLAG_HWIM | RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD; - /* - * These controllers support jumbo frame but it seems - * that enabling it requires touching additional magic - * registers. Depending on MAC revisions some - * controllers need to disable checksum offload. So - * disable jumbo frame until I have better idea what - * it really requires to make it support. - * RTL8168C/CP : supports up to 6KB jumbo frame. - * RTL8111C/CP : supports up to 9KB jumbo frame. - */ - sc->rl_flags |= RL_FLAG_NOJUMBO; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | + RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | + RL_FLAG_AUTOPAD | RL_FLAG_JUMBOV2 | RL_FLAG_WOL_MANLINK; + sc->rl_max_mtu = RL_JUMBO_MTU_6K; break; case RL_HWREV_8168D: + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHYWAKE_PM | + RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | + RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD | RL_FLAG_JUMBOV2 | + RL_FLAG_WOL_MANLINK; + sc->rl_max_mtu = RL_JUMBO_MTU_9K; + break; + case RL_HWREV_8168DP: + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | + RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_AUTOPAD | + RL_FLAG_JUMBOV2 | RL_FLAG_WAIT_TXPOLL | RL_FLAG_WOL_MANLINK; + sc->rl_max_mtu = RL_JUMBO_MTU_9K; + break; case RL_HWREV_8168E: - sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | - RL_FLAG_PHYWAKE_PM | RL_FLAG_PAR | RL_FLAG_DESCV2 | - RL_FLAG_MACSTAT | RL_FLAG_HWIM | RL_FLAG_CMDSTOP | - RL_FLAG_AUTOPAD | RL_FLAG_NOJUMBO; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PHYWAKE_PM | + RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | + RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD | RL_FLAG_JUMBOV2 | + RL_FLAG_WOL_MANLINK; + sc->rl_max_mtu = RL_JUMBO_MTU_9K; break; case RL_HWREV_8168E_VL: + sc->rl_flags |= RL_FLAG_EARLYOFF | RL_FLAG_PHYWAKE | RL_FLAG_PAR | + RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | + RL_FLAG_AUTOPAD | RL_FLAG_JUMBOV2 | RL_FLAG_CMDSTOP_WAIT_TXQ | + RL_FLAG_WOL_MANLINK; + sc->rl_max_mtu = RL_JUMBO_MTU_6K; case RL_HWREV_8168F: sc->rl_flags |= RL_FLAG_EARLYOFF; /* FALLTHROUGH */ case RL_HWREV_8411: - sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | - RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | - RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD | RL_FLAG_NOJUMBO; + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | + RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | + RL_FLAG_AUTOPAD | RL_FLAG_JUMBOV2 | RL_FLAG_CMDSTOP_WAIT_TXQ | + RL_FLAG_WOL_MANLINK; + sc->rl_max_mtu = RL_JUMBO_MTU_9K; break; case RL_HWREV_8168EP: case RL_HWREV_8168G: case RL_HWREV_8411B: + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | + RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | + RL_FLAG_AUTOPAD | RL_FLAG_JUMBOV2 | RL_FLAG_CMDSTOP_WAIT_TXQ | + RL_FLAG_WOL_MANLINK | RL_FLAG_EARLYOFFV2 | RL_FLAG_RXDV_GATED; + sc->rl_max_mtu = RL_JUMBO_MTU_9K; + break; case RL_HWREV_8168GU: - sc->rl_flags |= RL_FLAG_INVMAR | RL_FLAG_PHYWAKE | - RL_FLAG_PAR | RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | - RL_FLAG_CMDSTOP | RL_FLAG_AUTOPAD | RL_FLAG_NOJUMBO | + if (sc->sc_product == PCI_PRODUCT_REALTEK_RT8101E) { + /* RTL8106EUS */ + sc->rl_flags |= RL_FLAG_FASTETHER; + sc->rl_max_mtu = RL_MTU; + } else { + sc->rl_flags |= RL_FLAG_JUMBOV2 | RL_FLAG_WOL_MANLINK; + sc->rl_max_mtu = RL_JUMBO_MTU_9K; + } + + sc->rl_flags |= RL_FLAG_PHYWAKE | RL_FLAG_PAR | + RL_FLAG_DESCV2 | RL_FLAG_MACSTAT | RL_FLAG_CMDSTOP | + RL_FLAG_AUTOPAD | RL_FLAG_CMDSTOP_WAIT_TXQ | RL_FLAG_EARLYOFFV2 | RL_FLAG_RXDV_GATED; break; case RL_HWREV_8169_8110SB: @@ -728,7 +763,8 @@ re_attach(struct rl_softc *sc, const char *intrstr) case RL_HWREV_8169: case RL_HWREV_8169S: case RL_HWREV_8110S: - sc->rl_flags |= RL_FLAG_MACLDPS; + sc->rl_flags |= RL_FLAG_MACRESET; + sc->rl_max_mtu = RL_JUMBO_MTU_7K; break; default: break; @@ -957,8 +993,8 @@ re_attach(struct rl_softc *sc, const char *intrstr) ifp->if_ioctl = re_ioctl; ifp->if_start = re_start; ifp->if_watchdog = re_watchdog; - if ((sc->rl_flags & RL_FLAG_NOJUMBO) == 0) - ifp->if_hardmtu = RL_JUMBO_MTU; + if ((sc->rl_flags & RL_FLAG_JUMBOV2) == 0) + ifp->if_hardmtu = sc->rl_max_mtu; IFQ_SET_MAXLEN(&ifp->if_snd, RL_TX_QLEN); IFQ_SET_READY(&ifp->if_snd); diff --git a/sys/dev/ic/rtl81x9reg.h b/sys/dev/ic/rtl81x9reg.h index e61e4e3d77b..531bf1accc7 100644 --- a/sys/dev/ic/rtl81x9reg.h +++ b/sys/dev/ic/rtl81x9reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rtl81x9reg.h,v 1.85 2014/07/08 05:35:18 dlg Exp $ */ +/* $OpenBSD: rtl81x9reg.h,v 1.86 2014/09/06 04:46:58 brad Exp $ */ /* * Copyright (c) 1997, 1998 @@ -736,7 +736,15 @@ struct rl_stats { /* see comment in dev/ic/re.c */ #define RL_JUMBO_FRAMELEN 7440 -#define RL_JUMBO_MTU (RL_JUMBO_FRAMELEN-ETHER_HDR_LEN-ETHER_CRC_LEN) +#define RL_JUMBO_MTU_4K \ + ((4 * 1024) - ETHER_HDR_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN) +#define RL_JUMBO_MTU_6K \ + ((6 * 1024) - ETHER_HDR_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN) +#define RL_JUMBO_MTU_7K \ + (RL_JUMBO_FRAMELEN - ETHER_HDR_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN) +#define RL_JUMBO_MTU_9K \ + ((9 * 1024) - ETHER_HDR_LEN - ETHER_CRC_LEN - ETHER_VLAN_ENCAP_LEN) +#define RL_MTU ETHERMTU #define MAX_NUM_MULTICAST_ADDRESSES 128 @@ -823,6 +831,8 @@ struct rl_softc { struct mii_data sc_mii; /* MII information */ u_int8_t rl_type; u_int32_t sc_hwrev; + u_int16_t sc_product; + int rl_max_mtu; int rl_eecmd_read; int rl_eewidth; int rl_bus_speed; @@ -841,23 +851,27 @@ struct rl_softc { #define RL_FLAG_MSI 0x00000001 #define RL_FLAG_PCI64 0x00000002 #define RL_FLAG_PCIE 0x00000004 -#define RL_FLAG_INVMAR 0x00000008 -#define RL_FLAG_PHYWAKE 0x00000010 -#define RL_FLAG_NOJUMBO 0x00000020 -#define RL_FLAG_PAR 0x00000040 -#define RL_FLAG_DESCV2 0x00000080 -#define RL_FLAG_MACSTAT 0x00000100 -#define RL_FLAG_HWIM 0x00000200 -#define RL_FLAG_TIMERINTR 0x00000400 -#define RL_FLAG_MACLDPS 0x00000800 -#define RL_FLAG_CMDSTOP 0x00001000 -#define RL_FLAG_MACSLEEP 0x00002000 -#define RL_FLAG_AUTOPAD 0x00004000 -#define RL_FLAG_LINK 0x00008000 -#define RL_FLAG_PHYWAKE_PM 0x00010000 -#define RL_FLAG_EARLYOFF 0x00020000 -#define RL_FLAG_EARLYOFFV2 0x00040000 -#define RL_FLAG_RXDV_GATED 0x00080000 +#define RL_FLAG_PHYWAKE 0x00000008 +#define RL_FLAG_PAR 0x00000010 +#define RL_FLAG_DESCV2 0x00000020 +#define RL_FLAG_MACSTAT 0x00000040 +#define RL_FLAG_HWIM 0x00000080 +#define RL_FLAG_TIMERINTR 0x00000100 +#define RL_FLAG_MACRESET 0x00000200 +#define RL_FLAG_CMDSTOP 0x00000400 +#define RL_FLAG_MACSLEEP 0x00000800 +#define RL_FLAG_AUTOPAD 0x00001000 +#define RL_FLAG_LINK 0x00002000 +#define RL_FLAG_PHYWAKE_PM 0x00004000 +#define RL_FLAG_EARLYOFF 0x00008000 +#define RL_FLAG_EARLYOFFV2 0x00010000 +#define RL_FLAG_RXDV_GATED 0x00020000 +#define RL_FLAG_FASTETHER 0x00040000 +#define RL_FLAG_CMDSTOP_WAIT_TXQ 0x00080000 +#define RL_FLAG_JUMBOV2 0x00100000 +#define RL_FLAG_WOL_MANLINK 0x00200000 +#define RL_FLAG_WAIT_TXPOLL 0x00400000 +#define RL_FLAG_WOLRXENB 0x00800000 u_int16_t rl_intrs; u_int16_t rl_tx_ack; diff --git a/sys/dev/pci/if_re_pci.c b/sys/dev/pci/if_re_pci.c index afb4c0a400f..9b7f8b594cb 100644 --- a/sys/dev/pci/if_re_pci.c +++ b/sys/dev/pci/if_re_pci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_re_pci.c,v 1.41 2014/07/22 13:12:11 mpi Exp $ */ +/* $OpenBSD: if_re_pci.c,v 1.42 2014/09/06 04:46:58 brad Exp $ */ /* * Copyright (c) 2005 Peter Valchev <pvalchev@openbsd.org> @@ -197,6 +197,8 @@ re_pci_attach(struct device *parent, struct device *self, void *aux) CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF); } + sc->sc_product = PCI_PRODUCT(pa->pa_id); + /* Call bus-independent attach routine */ if (re_attach(sc, intrstr)) { pci_intr_disestablish(pc, psc->sc_ih); |