pcnet: Update with the 11.1 release of the le/pcn driver.

* switch compat layer.
* tested on Qemu, model=pcnet.
This commit is contained in:
Jérôme Duval 2017-11-18 18:45:37 +01:00
parent ad7432f214
commit dcdad04383
11 changed files with 61 additions and 78 deletions

View File

@ -1,8 +1,8 @@
SubDir HAIKU_TOP src add-ons kernel drivers network pcnet dev le ;
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 ;
@ -15,5 +15,5 @@ KernelAddon pcnet :
if_le_pci.c
lance.c
glue.c
: libfreebsd_network.a pcnet_pcn.a pcnet_mii.a
: pcnet_pcn.a pcnet_mii.a libfreebsd11_network.a
;

View File

@ -272,7 +272,7 @@ am7990_rint(struct lance_softc *sc)
bix = 0;
if (m != NULL) {
ifp->if_ipackets++;
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
#ifdef LANCE_REVC_BUG
/*
@ -296,7 +296,7 @@ am7990_rint(struct lance_softc *sc)
(*ifp->if_input)(ifp, m);
LE_LOCK(sc);
} else
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
}
sc->sc_last_rd = bix;
@ -352,22 +352,22 @@ am7990_tint(struct lance_softc *sc)
if_printf(ifp, "lost carrier\n");
}
if (tmd.tmd3 & LE_T3_LCOL)
ifp->if_collisions++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
if (tmd.tmd3 & LE_T3_RTRY) {
#ifdef LEDEBUG
if_printf(ifp, "excessive collisions, tdr %d\n",
tmd.tmd3 & LE_T3_TDR_MASK);
#endif
ifp->if_collisions += 16;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16);
}
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
} else {
if (tmd.tmd1_bits & LE_T1_ONE)
ifp->if_collisions++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
else if (tmd.tmd1_bits & LE_T1_MORE)
/* Real number is unknown. */
ifp->if_collisions += 2;
ifp->if_opackets++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 2);
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
}
if (++bix == sc->sc_ntbuf)
@ -394,7 +394,7 @@ am7990_intr(void *arg)
LE_LOCK(sc);
if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) {
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
lance_init_locked(sc);
LE_UNLOCK(sc);
return;
@ -426,19 +426,19 @@ am7990_intr(void *arg)
#ifdef LEDEBUG
if_printf(ifp, "babble\n");
#endif
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
}
#if 0
if (isr & LE_C0_CERR) {
if_printf(ifp, "collision error\n");
ifp->if_collisions++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
}
#endif
if (isr & LE_C0_MISS) {
#ifdef LEDEBUG
if_printf(ifp, "missed packet\n");
#endif
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
}
if (isr & LE_C0_MERR) {
if_printf(ifp, "memory error\n");
@ -450,14 +450,14 @@ am7990_intr(void *arg)
if ((isr & LE_C0_RXON) == 0) {
if_printf(ifp, "receiver disabled\n");
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
lance_init_locked(sc);
LE_UNLOCK(sc);
return;
}
if ((isr & LE_C0_TXON) == 0) {
if_printf(ifp, "transmitter disabled\n");
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
lance_init_locked(sc);
LE_UNLOCK(sc);
return;
@ -519,7 +519,7 @@ am7990_start_locked(struct lance_softc *sc)
}
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
if (m == 0)
if (m == NULL)
break;
/*

View File

@ -313,7 +313,7 @@ am79900_rint(struct lance_softc *sc)
bix = 0;
if (m != NULL) {
ifp->if_ipackets++;
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
#if defined(__i386__) && !defined(PC98)
/*
@ -333,7 +333,7 @@ am79900_rint(struct lance_softc *sc)
(*ifp->if_input)(ifp, m);
LE_LOCK(sc);
} else
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
}
sc->sc_last_rd = bix;
@ -391,21 +391,21 @@ am79900_tint(struct lance_softc *sc)
if_printf(ifp, "lost carrier\n");
}
if (tmd2 & LE_T2_LCOL)
ifp->if_collisions++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
if (tmd2 & LE_T2_RTRY) {
#ifdef LEDEBUG
if_printf(ifp, "excessive collisions\n");
#endif
ifp->if_collisions += 16;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 16);
}
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
} else {
if (tmd1 & LE_T1_ONE)
ifp->if_collisions++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
else if (tmd1 & LE_T1_MORE)
/* Real number is unknown. */
ifp->if_collisions += 2;
ifp->if_opackets++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 2);
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
}
if (++bix == sc->sc_ntbuf)
@ -432,7 +432,7 @@ am79900_intr(void *arg)
LE_LOCK(sc);
if (sc->sc_hwintr && (*sc->sc_hwintr)(sc) == -1) {
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
lance_init_locked(sc);
LE_UNLOCK(sc);
return;
@ -474,19 +474,19 @@ am79900_intr(void *arg)
#ifdef LEDEBUG
if_printf(ifp, "babble\n");
#endif
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
}
#if 0
if (isr & LE_C0_CERR) {
if_printf(ifp, "collision error\n");
ifp->if_collisions++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
}
#endif
if (isr & LE_C0_MISS) {
#ifdef LEDEBUG
if_printf(ifp, "missed packet\n");
#endif
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
}
if (isr & LE_C0_MERR) {
if_printf(ifp, "memory error\n");
@ -498,14 +498,14 @@ am79900_intr(void *arg)
if ((isr & LE_C0_RXON) == 0) {
if_printf(ifp, "receiver disabled\n");
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
lance_init_locked(sc);
LE_UNLOCK(sc);
return;
}
if ((isr & LE_C0_TXON) == 0) {
if_printf(ifp, "transmitter disabled\n");
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
lance_init_locked(sc);
LE_UNLOCK(sc);
return;
@ -567,7 +567,7 @@ am79900_start_locked(struct lance_softc *sc)
}
IFQ_DRV_DEQUEUE(&ifp->if_snd, m);
if (m == 0)
if (m == NULL)
break;
/*

View File

@ -53,6 +53,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_media.h>
#include <sparc64/sbus/lsi64854reg.h>
@ -387,7 +388,7 @@ le_dma_attach(device_t dev)
sc->sc_mediachange = le_dma_supmediachange;
sc->sc_mediastatus = le_dma_supmediastatus;
sc->sc_supmedia = le_dma_supmedia;
sc->sc_nsupmedia = sizeof(le_dma_supmedia) / sizeof(le_dma_supmedia[0]);
sc->sc_nsupmedia = nitems(le_dma_supmedia);
sc->sc_defaultmedia = le_dma_supmedia[0];
OF_getetheraddr(dev, sc->sc_enaddr);

View File

@ -72,6 +72,7 @@ __FBSDID("$FreeBSD$");
#include <sys/endian.h>
#include <sys/lock.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
#include <sys/mbuf.h>
#include <sys/mutex.h>
#include <sys/socket.h>
@ -79,6 +80,7 @@ __FBSDID("$FreeBSD$");
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/if_dl.h>
#include <net/if_media.h>
@ -195,7 +197,7 @@ lance_attach(struct lance_softc *sc)
ether_ifattach(ifp, sc->sc_enaddr);
/* Claim 802.1q capability. */
ifp->if_data.ifi_hdrlen = sizeof(struct ether_vlan_header);
ifp->if_hdrlen = sizeof(struct ether_vlan_header);
ifp->if_capabilities |= IFCAP_VLAN_MTU;
ifp->if_capenable |= IFCAP_VLAN_MTU;
}
@ -397,8 +399,7 @@ lance_get(struct lance_softc *sc, int boff, int totlen)
while (totlen > 0) {
if (totlen >= MINCLSIZE) {
MCLGET(m, M_NOWAIT);
if ((m->m_flags & M_EXT) == 0)
if (!(MCLGET(m, M_NOWAIT)))
goto bad;
len = MCLBYTES;
}
@ -417,7 +418,7 @@ lance_get(struct lance_softc *sc, int boff, int totlen)
totlen -= len;
if (totlen > 0) {
MGET(newm, M_NOWAIT, MT_DATA);
if (newm == 0)
if (newm == NULL)
goto bad;
len = MLEN;
m = m->m_next = newm;
@ -445,7 +446,7 @@ lance_watchdog(void *xsc)
}
if_printf(ifp, "device timeout\n");
++ifp->if_oerrors;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
lance_init_locked(sc);
}

View File

@ -1,7 +1,7 @@
SubDir HAIKU_TOP src add-ons kernel drivers network pcnet 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 ;
@ -18,6 +18,6 @@ KernelStaticLibrary pcnet_mii.a
ObjectHdrs [ FGristFiles nsphy$(SUFOBJ) nsphyter$(SUFOBJ) ]
: [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR_$(TARGET_PACKAGING_ARCH)) libs
compat freebsd_network ] ;
compat freebsd11_network ] ;
Includes [ FGristFiles nsphy.c nsphyter.c ]
: <src!libs!compat!freebsd_network>miidevs.h ;
: <src!libs!compat!freebsd11_network>miidevs.h ;

View File

@ -71,6 +71,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_media.h>
#include <dev/mii/mii.h>
@ -128,15 +129,13 @@ nsphy_probe(device_t dev)
static int
nsphy_attach(device_t dev)
{
const char *nic;
u_int flags;
nic = device_get_name(device_get_parent(device_get_parent(dev)));
flags = MIIF_NOMANPAUSE;
/*
* Am79C971 wedge when isolating all of their external PHYs.
*/
if (strcmp(nic, "pcn") == 0)
if (mii_dev_mac_match(dev,"pcn"))
flags |= MIIF_NOISOLATE;
mii_phy_dev_attach(dev, flags, &nsphy_funcs, 1);
return (0);
@ -152,12 +151,6 @@ nsphy_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;
reg = PHY_READ(sc, MII_NSPHY_PCR);
/*
@ -191,7 +184,7 @@ nsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd)
*/
reg |= 0x0100 | 0x0400;
if (strcmp(mii->mii_ifp->if_dname, "fxp") == 0)
if (mii_phy_mac_match(sc, "fxp"))
PHY_WRITE(sc, MII_NSPHY_PCR, reg);
mii_phy_setmedia(sc);

View File

@ -149,12 +149,6 @@ nsphyter_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

@ -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

@ -1,7 +1,7 @@
SubDir HAIKU_TOP src add-ons kernel drivers network pcnet dev pcn ;
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 ;

View File

@ -62,6 +62,7 @@ __FBSDID("$FreeBSD$");
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_var.h>
#include <net/if_arp.h>
#include <net/ethernet.h>
#include <net/if_dl.h>
@ -802,8 +803,7 @@ pcn_newbuf(sc, idx, m)
if (m_new == NULL)
return(ENOBUFS);
MCLGET(m_new, M_NOWAIT);
if (!(m_new->m_flags & M_EXT)) {
if (!(MCLGET(m_new, M_NOWAIT))) {
m_freem(m_new);
return(ENOBUFS);
}
@ -855,7 +855,7 @@ pcn_rxeof(sc)
* comes up in the ring.
*/
if (cur_rx->pcn_rxstat & PCN_RXSTAT_ERR) {
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
pcn_newbuf(sc, i, m);
PCN_INC(i, PCN_RX_LIST_CNT);
continue;
@ -864,7 +864,7 @@ pcn_rxeof(sc)
if (pcn_newbuf(sc, i, NULL)) {
/* Ran out of mbufs; recycle this one. */
pcn_newbuf(sc, i, m);
ifp->if_ierrors++;
if_inc_counter(ifp, IFCOUNTER_IERRORS, 1);
PCN_INC(i, PCN_RX_LIST_CNT);
continue;
}
@ -872,7 +872,7 @@ pcn_rxeof(sc)
PCN_INC(i, PCN_RX_LIST_CNT);
/* No errors; receive the packet. */
ifp->if_ipackets++;
if_inc_counter(ifp, IFCOUNTER_IPACKETS, 1);
m->m_len = m->m_pkthdr.len =
cur_rx->pcn_rxlen - ETHER_CRC_LEN;
m->m_pkthdr.rcvif = ifp;
@ -920,17 +920,17 @@ pcn_txeof(sc)
}
if (cur_tx->pcn_txctl & PCN_TXCTL_ERR) {
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
if (cur_tx->pcn_txstat & PCN_TXSTAT_EXDEF)
ifp->if_collisions++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
if (cur_tx->pcn_txstat & PCN_TXSTAT_RTRY)
ifp->if_collisions++;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS, 1);
}
ifp->if_collisions +=
cur_tx->pcn_txstat & PCN_TXSTAT_TRC;
if_inc_counter(ifp, IFCOUNTER_COLLISIONS,
cur_tx->pcn_txstat & PCN_TXSTAT_TRC);
ifp->if_opackets++;
if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
if (sc->pcn_cdata.pcn_tx_chain[idx] != NULL) {
m_freem(sc->pcn_cdata.pcn_tx_chain[idx]);
sc->pcn_cdata.pcn_tx_chain[idx] = NULL;
@ -966,7 +966,7 @@ pcn_tick(xsc)
mii_tick(mii);
/* link just died */
if (sc->pcn_link & !(mii->mii_media_status & IFM_ACTIVE))
if (sc->pcn_link && !(mii->mii_media_status & IFM_ACTIVE))
sc->pcn_link = 0;
/* link just came up, restart */
@ -1435,7 +1435,7 @@ pcn_watchdog(struct pcn_softc *sc)
PCN_LOCK_ASSERT(sc);
ifp = sc->pcn_ifp;
ifp->if_oerrors++;
if_inc_counter(ifp, IFCOUNTER_OERRORS, 1);
if_printf(ifp, "watchdog timeout\n");
pcn_stop(sc);