drivers/network: Upgrade rtl8139, rtl81xx to FreeBSD 12.
Includes some logic fixes to Haiku-specific code in the MII drivers, and one new chipset supported by the rtl81xx MII driver. Otherwise, no major functional change.
This commit is contained in:
parent
2b5a056e03
commit
6d2ae71f16
@ -1,4 +1,6 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-4-Clause
|
||||
*
|
||||
* Copyright (c) 1997, 1998, 1999
|
||||
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
|
||||
*
|
||||
@ -31,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
__FBSDID("$FreeBSD: releng/12.0/sys/dev/mii/rlphy.c 325966 2017-11-18 14:26:50Z pfg $");
|
||||
|
||||
/*
|
||||
* driver for RealTek 8139 internal PHYs
|
||||
@ -111,12 +113,13 @@ rlphy_probe(device_t dev)
|
||||
int rv;
|
||||
|
||||
rv = mii_phy_dev_probe(dev, rlphys, BUS_PROBE_DEFAULT);
|
||||
#ifdef __HAIKU__
|
||||
if (rv == BUS_PROBE_DEFAULT)
|
||||
return (rv);
|
||||
#else
|
||||
#ifndef __HAIKU__
|
||||
if (rv <= 0)
|
||||
return (rv);
|
||||
#else /* __HAIKU__ */
|
||||
/* our BUS_PROBE_* constants are > 0 since errors are < 0 */
|
||||
if (rv > 0)
|
||||
return (rv);
|
||||
#endif
|
||||
|
||||
if (mii_dev_mac_match(dev, "rl") || mii_dev_mac_match(dev, "re"))
|
||||
|
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
__FBSDID("$FreeBSD: releng/12.0/sys/dev/rl/if_rl.c 338951 2018-09-26 19:41:00Z imp $");
|
||||
|
||||
/*
|
||||
* RealTek 8129/8139 PCI NIC driver
|
||||
@ -259,6 +259,8 @@ static driver_t rl_driver = {
|
||||
static devclass_t rl_devclass;
|
||||
|
||||
DRIVER_MODULE(rl, pci, rl_driver, rl_devclass, 0, 0);
|
||||
MODULE_PNP_INFO("U16:vendor;U16:device", pci, rl, rl_devs,
|
||||
nitems(rl_devs) - 1);
|
||||
DRIVER_MODULE(rl, cardbus, rl_driver, rl_devclass, 0, 0);
|
||||
DRIVER_MODULE(miibus, rl, miibus_driver, miibus_devclass, 0, 0);
|
||||
|
||||
@ -276,7 +278,7 @@ DRIVER_MODULE(miibus, rl, miibus_driver, miibus_devclass, 0, 0);
|
||||
static void
|
||||
rl_eeprom_putbyte(struct rl_softc *sc, int addr)
|
||||
{
|
||||
register int d, i;
|
||||
int d, i;
|
||||
|
||||
d = addr | sc->rl_eecmd_read;
|
||||
|
||||
@ -303,7 +305,7 @@ rl_eeprom_putbyte(struct rl_softc *sc, int addr)
|
||||
static void
|
||||
rl_eeprom_getword(struct rl_softc *sc, int addr, uint16_t *dest)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
uint16_t word = 0;
|
||||
|
||||
/* Enter EEPROM access mode. */
|
||||
@ -561,7 +563,7 @@ rl_rxfilter(struct rl_softc *sc)
|
||||
static void
|
||||
rl_reset(struct rl_softc *sc)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
RL_LOCK_ASSERT(sc);
|
||||
|
||||
@ -1912,7 +1914,7 @@ rl_watchdog(struct rl_softc *sc)
|
||||
static void
|
||||
rl_stop(struct rl_softc *sc)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
struct ifnet *ifp = sc->rl_ifp;
|
||||
|
||||
RL_LOCK_ASSERT(sc);
|
||||
|
@ -29,7 +29,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $FreeBSD: releng/12.0/sys/dev/rl/if_rlreg.h 306102 2016-09-21 14:15:15Z kevlo $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-4-Clause
|
||||
*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
@ -31,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
__FBSDID("$FreeBSD: releng/12.0/sys/dev/mii/rgephy.c 325966 2017-11-18 14:26:50Z pfg $");
|
||||
|
||||
/*
|
||||
* Driver for the RealTek 8169S/8110S/8211B/8211C internal 10/100/1000 PHY.
|
||||
@ -121,6 +123,8 @@ rgephy_attach(device_t dev)
|
||||
flags = 0;
|
||||
if (mii_dev_mac_match(dev, "re"))
|
||||
flags |= MIIF_PHYPRIV0;
|
||||
else if (mii_dev_mac_match(dev, "ure"))
|
||||
flags |= MIIF_PHYPRIV1;
|
||||
mii_phy_dev_attach(dev, flags, &rgephy_funcs, 0);
|
||||
|
||||
/* RTL8169S do not report auto-sense; add manually. */
|
||||
@ -293,7 +297,10 @@ rgephy_linkup(struct mii_softc *sc)
|
||||
linkup++;
|
||||
}
|
||||
} else {
|
||||
reg = PHY_READ(sc, RL_GMEDIASTAT);
|
||||
if (sc->mii_flags & MIIF_PHYPRIV1)
|
||||
reg = PHY_READ(sc, URE_GMEDIASTAT);
|
||||
else
|
||||
reg = PHY_READ(sc, RL_GMEDIASTAT);
|
||||
if (reg & RL_GMEDIASTAT_LINK)
|
||||
linkup++;
|
||||
}
|
||||
@ -378,7 +385,10 @@ rgephy_status(struct mii_softc *sc)
|
||||
mii->mii_media_active |= IFM_HDX;
|
||||
}
|
||||
} else {
|
||||
bmsr = PHY_READ(sc, RL_GMEDIASTAT);
|
||||
if (sc->mii_flags & MIIF_PHYPRIV1)
|
||||
bmsr = PHY_READ(sc, URE_GMEDIASTAT);
|
||||
else
|
||||
bmsr = PHY_READ(sc, RL_GMEDIASTAT);
|
||||
if (bmsr & RL_GMEDIASTAT_1000MBPS)
|
||||
mii->mii_media_active |= IFM_1000_T;
|
||||
else if (bmsr & RL_GMEDIASTAT_100MBPS)
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-4-Clause
|
||||
*
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
@ -29,7 +31,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $FreeBSD: releng/12.0/sys/dev/mii/rgephyreg.h 325966 2017-11-18 14:26:50Z pfg $
|
||||
*/
|
||||
|
||||
#ifndef _DEV_MII_RGEPHYREG_H_
|
||||
@ -199,4 +201,7 @@
|
||||
#define EEELPAR_1000T 0x0004 /* link partner 1000baseT EEE capable */
|
||||
#define EEELPAR_100TX 0x0002 /* link partner 100baseTX EEE capable */
|
||||
|
||||
/* RTL8153 */
|
||||
#define URE_GMEDIASTAT 0xe908 /* media status register */
|
||||
|
||||
#endif /* _DEV_RGEPHY_MIIREG_H_ */
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-4-Clause
|
||||
*
|
||||
* Copyright (c) 1997, 1998, 1999
|
||||
* Bill Paul <wpaul@ctr.columbia.edu>. All rights reserved.
|
||||
*
|
||||
@ -31,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
__FBSDID("$FreeBSD: releng/12.0/sys/dev/mii/rlphy.c 325966 2017-11-18 14:26:50Z pfg $");
|
||||
|
||||
/*
|
||||
* driver for RealTek 8139 internal PHYs
|
||||
@ -111,12 +113,13 @@ rlphy_probe(device_t dev)
|
||||
int rv;
|
||||
|
||||
rv = mii_phy_dev_probe(dev, rlphys, BUS_PROBE_DEFAULT);
|
||||
#ifdef __HAIKU__
|
||||
if (rv == BUS_PROBE_DEFAULT)
|
||||
return (rv);
|
||||
#else
|
||||
#ifndef __HAIKU__
|
||||
if (rv <= 0)
|
||||
return (rv);
|
||||
#else /* __HAIKU__ */
|
||||
/* our BUS_PROBE_* constants are > 0 since errors are < 0 */
|
||||
if (rv > 0)
|
||||
return (rv);
|
||||
#endif
|
||||
|
||||
if (mii_dev_mac_match(dev, "rl") || mii_dev_mac_match(dev, "re"))
|
||||
|
@ -1,4 +1,6 @@
|
||||
/*-
|
||||
* SPDX-License-Identifier: BSD-4-Clause
|
||||
*
|
||||
* Copyright (c) 1997, 1998-2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
@ -31,7 +33,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
__FBSDID("$FreeBSD: releng/12.0/sys/dev/re/if_re.c 333813 2018-05-18 20:13:34Z mmacy $");
|
||||
|
||||
/*
|
||||
* RealTek 8139C+/8169/8169S/8110S/8168/8111/8101E PCI NIC driver
|
||||
@ -137,6 +139,8 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
#include <net/bpf.h>
|
||||
|
||||
#include <netinet/netdump/netdump.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/resource.h>
|
||||
#include <sys/bus.h>
|
||||
@ -277,6 +281,7 @@ static void re_tick (void *);
|
||||
static void re_int_task (void *, int);
|
||||
static void re_start (struct ifnet *);
|
||||
static void re_start_locked (struct ifnet *);
|
||||
static void re_start_tx (struct rl_softc *);
|
||||
static int re_ioctl (struct ifnet *, u_long, caddr_t);
|
||||
static void re_init (void *);
|
||||
static void re_init_locked (struct rl_softc *);
|
||||
@ -305,6 +310,8 @@ static void re_setwol (struct rl_softc *);
|
||||
static void re_clrwol (struct rl_softc *);
|
||||
static void re_set_linkspeed (struct rl_softc *);
|
||||
|
||||
NETDUMP_DEFINE(re);
|
||||
|
||||
#ifdef DEV_NETMAP /* see ixgbe.c for details */
|
||||
#include <dev/netmap/if_re_netmap.h>
|
||||
MODULE_DEPEND(re, netmap, 1, 1, 1);
|
||||
@ -1358,15 +1365,17 @@ re_attach(device_t dev)
|
||||
CSR_WRITE_1(sc, RL_EECMD, RL_EEMODE_OFF);
|
||||
}
|
||||
|
||||
/* Disable ASPM L0S/L1. */
|
||||
/* Disable ASPM L0S/L1 and CLKREQ. */
|
||||
if (sc->rl_expcap != 0) {
|
||||
cap = pci_read_config(dev, sc->rl_expcap +
|
||||
PCIER_LINK_CAP, 2);
|
||||
if ((cap & PCIEM_LINK_CAP_ASPM) != 0) {
|
||||
ctl = pci_read_config(dev, sc->rl_expcap +
|
||||
PCIER_LINK_CTL, 2);
|
||||
if ((ctl & PCIEM_LINK_CTL_ASPMC) != 0) {
|
||||
ctl &= ~PCIEM_LINK_CTL_ASPMC;
|
||||
if ((ctl & (PCIEM_LINK_CTL_ECPM |
|
||||
PCIEM_LINK_CTL_ASPMC))!= 0) {
|
||||
ctl &= ~(PCIEM_LINK_CTL_ECPM |
|
||||
PCIEM_LINK_CTL_ASPMC);
|
||||
pci_write_config(dev, sc->rl_expcap +
|
||||
PCIER_LINK_CTL, ctl, 2);
|
||||
device_printf(dev, "ASPM disabled\n");
|
||||
@ -1733,8 +1742,11 @@ re_attach(device_t dev)
|
||||
if (error) {
|
||||
device_printf(dev, "couldn't set up irq\n");
|
||||
ether_ifdetach(ifp);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
NETDUMP_SET(ifp, re);
|
||||
|
||||
fail:
|
||||
if (error)
|
||||
re_detach(dev);
|
||||
@ -2929,7 +2941,7 @@ re_start_locked(struct ifnet *ifp)
|
||||
#ifdef DEV_NETMAP
|
||||
/* XXX is this necessary ? */
|
||||
if (ifp->if_capenable & IFCAP_NETMAP) {
|
||||
struct netmap_kring *kring = &NA(ifp)->tx_rings[0];
|
||||
struct netmap_kring *kring = NA(ifp)->tx_rings[0];
|
||||
if (sc->rl_ldata.rl_tx_prodidx != kring->nr_hwcur) {
|
||||
/* kick the tx unit */
|
||||
CSR_WRITE_1(sc, sc->rl_txstart, RL_TXSTART_START);
|
||||
@ -2977,8 +2989,14 @@ re_start_locked(struct ifnet *ifp)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Flush the TX descriptors */
|
||||
re_start_tx(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
re_start_tx(struct rl_softc *sc)
|
||||
{
|
||||
|
||||
/* Flush the TX descriptors */
|
||||
bus_dmamap_sync(sc->rl_ldata.rl_tx_list_tag,
|
||||
sc->rl_ldata.rl_tx_list_map,
|
||||
BUS_DMASYNC_PREWRITE|BUS_DMASYNC_PREREAD);
|
||||
@ -4074,3 +4092,59 @@ sysctl_hw_re_int_mod(SYSCTL_HANDLER_ARGS)
|
||||
return (sysctl_int_range(oidp, arg1, arg2, req, RL_TIMER_MIN,
|
||||
RL_TIMER_MAX));
|
||||
}
|
||||
|
||||
#ifdef NETDUMP
|
||||
static void
|
||||
re_netdump_init(struct ifnet *ifp, int *nrxr, int *ncl, int *clsize)
|
||||
{
|
||||
struct rl_softc *sc;
|
||||
|
||||
sc = if_getsoftc(ifp);
|
||||
RL_LOCK(sc);
|
||||
*nrxr = sc->rl_ldata.rl_rx_desc_cnt;
|
||||
*ncl = NETDUMP_MAX_IN_FLIGHT;
|
||||
*clsize = (ifp->if_mtu > RL_MTU &&
|
||||
(sc->rl_flags & RL_FLAG_JUMBOV2) != 0) ? MJUM9BYTES : MCLBYTES;
|
||||
RL_UNLOCK(sc);
|
||||
}
|
||||
|
||||
static void
|
||||
re_netdump_event(struct ifnet *ifp __unused, enum netdump_ev event __unused)
|
||||
{
|
||||
}
|
||||
|
||||
static int
|
||||
re_netdump_transmit(struct ifnet *ifp, struct mbuf *m)
|
||||
{
|
||||
struct rl_softc *sc;
|
||||
int error;
|
||||
|
||||
sc = if_getsoftc(ifp);
|
||||
if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING | IFF_DRV_OACTIVE)) !=
|
||||
IFF_DRV_RUNNING || (sc->rl_flags & RL_FLAG_LINK) == 0)
|
||||
return (EBUSY);
|
||||
|
||||
error = re_encap(sc, &m);
|
||||
if (error == 0)
|
||||
re_start_tx(sc);
|
||||
return (error);
|
||||
}
|
||||
|
||||
static int
|
||||
re_netdump_poll(struct ifnet *ifp, int count)
|
||||
{
|
||||
struct rl_softc *sc;
|
||||
int error;
|
||||
|
||||
sc = if_getsoftc(ifp);
|
||||
if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0 ||
|
||||
(sc->rl_flags & RL_FLAG_LINK) == 0)
|
||||
return (EBUSY);
|
||||
|
||||
re_txeof(sc);
|
||||
error = re_rxeof(sc, NULL);
|
||||
if (error != 0 && error != EAGAIN)
|
||||
return (error);
|
||||
return (0);
|
||||
}
|
||||
#endif /* NETDUMP */
|
||||
|
@ -29,7 +29,7 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
* $FreeBSD: releng/12.0/sys/dev/rl/if_rlreg.h 306102 2016-09-21 14:15:15Z kevlo $
|
||||
*/
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user