vt612x: sync with FreeBSD 11.1.

This commit is contained in:
Jérôme Duval 2018-04-21 22:07:48 +02:00
parent e68394b978
commit 853a76f1f3
5 changed files with 33 additions and 50 deletions

View File

@ -1,7 +1,7 @@
SubDir HAIKU_TOP src add-ons kernel drivers network vt612x dev mii ;
UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network compat ] : true ;
UsePrivateHeaders net system ;
UsePrivateKernelHeaders ;
@ -17,6 +17,6 @@ KernelStaticLibrary vt612x_mii.a
ObjectHdrs [ FGristFiles ciphy$(SUFOBJ) ukphy$(SUFOBJ) ]
: [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)) libs
compat freebsd_network ] ;
Includes [ FGristFiles ciphy.c ukphy.c ] : <src!libs!compat!freebsd_network>miidevs.h ;
compat freebsd11_network ] ;
Includes [ FGristFiles ciphy.c ukphy.c ] : <src!libs!compat!freebsd11_network>miidevs.h ;

View File

@ -91,8 +91,10 @@ static const struct mii_phydesc ciphys[] = {
MII_PHY_DESC(xxCICADA, CS8201B),
MII_PHY_DESC(xxCICADA, CS8204),
MII_PHY_DESC(xxCICADA, VSC8211),
MII_PHY_DESC(xxCICADA, VSC8221),
MII_PHY_DESC(xxCICADA, CS8244),
MII_PHY_DESC(xxVITESSE, VSC8601),
MII_PHY_DESC(xxVITESSE, VSC8641),
MII_PHY_END
};
@ -129,12 +131,6 @@ ciphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
break;
case MII_MEDIACHG:
/*
* If the interface is not up, don't do anything.
*/
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
break;
ciphy_fixup(sc); /* XXX hardware bug work-around */
switch (IFM_SUBTYPE(ife->ifm_media)) {
@ -184,12 +180,6 @@ setit:
break;
case MII_TICK:
/*
* Is the interface even up?
*/
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
return (0);
/*
* Only used for autonegotiation.
*/
@ -313,8 +303,7 @@ ciphy_fixup(struct mii_softc *sc)
status = PHY_READ(sc, CIPHY_MII_AUXCSR);
speed = status & CIPHY_AUXCSR_SPEED;
if (strcmp(device_get_name(device_get_parent(sc->mii_dev)),
"nfe") == 0) {
if (mii_phy_mac_match(sc, "nfe")) {
/* need to set for 2.5V RGMII for NVIDIA adapters */
val = PHY_READ(sc, CIPHY_MII_ECTL1);
val &= ~(CIPHY_ECTL1_IOVOL | CIPHY_ECTL1_INTSEL);
@ -368,8 +357,10 @@ ciphy_fixup(struct mii_softc *sc)
break;
case MII_MODEL_xxCICADA_VSC8211:
case MII_MODEL_xxCICADA_VSC8221:
case MII_MODEL_xxCICADA_CS8244:
case MII_MODEL_xxVITESSE_VSC8601:
case MII_MODEL_xxVITESSE_VSC8641:
break;
default:
device_printf(sc->mii_dev, "unknown CICADA PHY model %x\n",

View File

@ -140,12 +140,6 @@ ukphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
break;
case MII_MEDIACHG:
/*
* If the interface is not up, don't do anything.
*/
if ((mii->mii_ifp->if_flags & IFF_UP) == 0)
break;
mii_phy_setmedia(sc);
break;

View File

@ -3,8 +3,8 @@ SubDir HAIKU_TOP src add-ons kernel drivers network vt612x dev vge ;
SubDirCcFlags -Wall ;
UseHeaders [ FDirName $(SUBDIR) .. .. ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd_network compat ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network ] : true ;
UseHeaders [ FDirName $(HAIKU_TOP) src libs compat freebsd11_network compat ] : true ;
UsePrivateHeaders net system ;
UsePrivateKernelHeaders ;
@ -14,6 +14,6 @@ SubDirCcFlags [ FDefines _KERNEL=1 FBSD_DRIVER=1 ] ;
KernelAddon vt612x :
if_vge.c
glue.c
: libfreebsd_network.a vt612x_mii.a
: vt612x_mii.a libfreebsd11_network.a
;

View File

@ -99,6 +99,7 @@ __FBSDID("$FreeBSD$");
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
#include <net/if_var.h>
#include <net/if_media.h>
#include <net/if_types.h>
#include <net/if_vlan_var.h>
@ -911,31 +912,29 @@ vge_dma_free(struct vge_softc *sc)
/* Tx ring. */
if (sc->vge_cdata.vge_tx_ring_tag != NULL) {
if (sc->vge_cdata.vge_tx_ring_map)
if (sc->vge_rdata.vge_tx_ring_paddr)
bus_dmamap_unload(sc->vge_cdata.vge_tx_ring_tag,
sc->vge_cdata.vge_tx_ring_map);
if (sc->vge_cdata.vge_tx_ring_map &&
sc->vge_rdata.vge_tx_ring)
if (sc->vge_rdata.vge_tx_ring)
bus_dmamem_free(sc->vge_cdata.vge_tx_ring_tag,
sc->vge_rdata.vge_tx_ring,
sc->vge_cdata.vge_tx_ring_map);
sc->vge_rdata.vge_tx_ring = NULL;
sc->vge_cdata.vge_tx_ring_map = NULL;
sc->vge_rdata.vge_tx_ring_paddr = 0;
bus_dma_tag_destroy(sc->vge_cdata.vge_tx_ring_tag);
sc->vge_cdata.vge_tx_ring_tag = NULL;
}
/* Rx ring. */
if (sc->vge_cdata.vge_rx_ring_tag != NULL) {
if (sc->vge_cdata.vge_rx_ring_map)
if (sc->vge_rdata.vge_rx_ring_paddr)
bus_dmamap_unload(sc->vge_cdata.vge_rx_ring_tag,
sc->vge_cdata.vge_rx_ring_map);
if (sc->vge_cdata.vge_rx_ring_map &&
sc->vge_rdata.vge_rx_ring)
if (sc->vge_rdata.vge_rx_ring)
bus_dmamem_free(sc->vge_cdata.vge_rx_ring_tag,
sc->vge_rdata.vge_rx_ring,
sc->vge_cdata.vge_rx_ring_map);
sc->vge_rdata.vge_rx_ring = NULL;
sc->vge_cdata.vge_rx_ring_map = NULL;
sc->vge_rdata.vge_rx_ring_paddr = 0;
bus_dma_tag_destroy(sc->vge_cdata.vge_rx_ring_tag);
sc->vge_cdata.vge_rx_ring_tag = NULL;
}
@ -1131,7 +1130,7 @@ vge_attach(device_t dev)
ether_ifattach(ifp, eaddr);
/* Tell the upper layer(s) we support long frames. */
ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
ifp->if_hdrlen = sizeof(struct ether_vlan_header);
/* Hook interrupt last to avoid having to lock softc */
error = bus_setup_intr(dev, sc->vge_irq, INTR_TYPE_NET|INTR_MPSAFE,
@ -1401,7 +1400,7 @@ vge_freebufs(struct vge_softc *sc)
txd->tx_dmamap);
m_freem(txd->tx_m);
txd->tx_m = NULL;
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
}
}
}
@ -1468,7 +1467,7 @@ vge_rxeof(struct vge_softc *sc, int count)
*/
if ((rxstat & VGE_RXPKT_SOF) != 0) {
if (vge_newbuf(sc, prod) != 0) {
ifp->if_iqdrops++;
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
VGE_CHAIN_RESET(sc);
vge_discard_rxbuf(sc, prod);
continue;
@ -1499,7 +1498,7 @@ vge_rxeof(struct vge_softc *sc, int count)
if ((rxstat & VGE_RDSTS_RXOK) == 0 &&
(rxstat & (VGE_RDSTS_VIDM | VGE_RDSTS_RLERR |
VGE_RDSTS_CSUMERR)) == 0) {
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
/*
* If this is part of a multi-fragment packet,
* discard all the pieces.
@ -1510,7 +1509,7 @@ vge_rxeof(struct vge_softc *sc, int count)
}
if (vge_newbuf(sc, prod) != 0) {
ifp->if_iqdrops++;
if_inc_counter(ifp, IFCOUNTER_IQDROPS, 1);
VGE_CHAIN_RESET(sc);
vge_discard_rxbuf(sc, prod);
continue;
@ -2022,11 +2021,9 @@ static void
vge_init_locked(struct vge_softc *sc)
{
struct ifnet *ifp = sc->vge_ifp;
struct mii_data *mii;
int error, i;
VGE_LOCK_ASSERT(sc);
mii = device_get_softc(sc->vge_miibus);
if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0)
return;
@ -2383,7 +2380,7 @@ vge_watchdog(void *arg)
ifp = sc->vge_ifp;
if_printf(ifp, "watchdog timeout\n");
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
vge_txeof(sc);
vge_rxeof(sc, VGE_RX_DESC_CNT);
@ -2709,24 +2706,25 @@ reset_idx:
stats->tx_latecolls += mib[VGE_MIB_TX_LATECOLLS];
/* Update counters in ifnet. */
ifp->if_opackets += mib[VGE_MIB_TX_GOOD_FRAMES];
if_inc_counter(ifp, IFCOUNTER_OPACKETS, mib[VGE_MIB_TX_GOOD_FRAMES]);
ifp->if_collisions += mib[VGE_MIB_TX_COLLS] +
mib[VGE_MIB_TX_LATECOLLS];
if_inc_counter(ifp, IFCOUNTER_COLLISIONS,
mib[VGE_MIB_TX_COLLS] + mib[VGE_MIB_TX_LATECOLLS]);
ifp->if_oerrors += mib[VGE_MIB_TX_COLLS] +
mib[VGE_MIB_TX_LATECOLLS];
if_inc_counter(ifp, IFCOUNTER_OERRORS,
mib[VGE_MIB_TX_COLLS] + mib[VGE_MIB_TX_LATECOLLS]);
ifp->if_ipackets += mib[VGE_MIB_RX_GOOD_FRAMES];
if_inc_counter(ifp, IFCOUNTER_IPACKETS, mib[VGE_MIB_RX_GOOD_FRAMES]);
ifp->if_ierrors += mib[VGE_MIB_RX_FIFO_OVERRUNS] +
if_inc_counter(ifp, IFCOUNTER_IERRORS,
mib[VGE_MIB_RX_FIFO_OVERRUNS] +
mib[VGE_MIB_RX_RUNTS] +
mib[VGE_MIB_RX_RUNTS_ERRS] +
mib[VGE_MIB_RX_CRCERRS] +
mib[VGE_MIB_RX_ALIGNERRS] +
mib[VGE_MIB_RX_NOBUFS] +
mib[VGE_MIB_RX_SYMERRS] +
mib[VGE_MIB_RX_LENERRS];
mib[VGE_MIB_RX_LENERRS]);
}
static void