summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2015-12-19 02:16:38 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2015-12-19 02:16:38 +0000
commitcdb30b9b2d50ef47a88077593eea0522eadcd4e0 (patch)
tree51116d80675ab62c29d4be76fee32e55d019438f /sys/powerpc
parent690479eac41bea3965d72f8f50f29dc4576b616c (diff)
downloadFreeBSD-src-cdb30b9b2d50ef47a88077593eea0522eadcd4e0.zip
FreeBSD-src-cdb30b9b2d50ef47a88077593eea0522eadcd4e0.tar.gz
Provide link state reporting so that ifconfig_llan0="DHCP" works. The
reported link state is fictional (always up) since the hypervisor does not provide this information. MFC after: 1 week
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/pseries/phyp_llan.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/powerpc/pseries/phyp_llan.c b/sys/powerpc/pseries/phyp_llan.c
index 04e359d..e35124c 100644
--- a/sys/powerpc/pseries/phyp_llan.c
+++ b/sys/powerpc/pseries/phyp_llan.c
@@ -87,6 +87,8 @@ struct llan_softc {
cell_t unit;
uint8_t mac_address[8];
+ struct ifmedia media;
+
int irqid;
struct resource *irq;
void *irq_cookie;
@@ -116,6 +118,8 @@ static void llan_intr(void *xsc);
static void llan_init(void *xsc);
static void llan_start(struct ifnet *ifp);
static int llan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data);
+static void llan_media_status(struct ifnet *ifp, struct ifmediareq *ifmr);
+static int llan_media_change(struct ifnet *ifp);
static void llan_rx_load_cb(void *xsc, bus_dma_segment_t *segs, int nsegs,
int err);
static int llan_add_rxbuf(struct llan_softc *sc, struct llan_xfer *rx);
@@ -220,16 +224,46 @@ llan_attach(device_t dev)
sc->ifp->if_ioctl = llan_ioctl;
sc->ifp->if_init = llan_init;
+ ifmedia_init(&sc->media, IFM_IMASK, llan_media_change,
+ llan_media_status);
+ ifmedia_add(&sc->media, IFM_ETHER | IFM_AUTO, 0, NULL);
+ ifmedia_set(&sc->media, IFM_ETHER | IFM_AUTO);
+
IFQ_SET_MAXLEN(&sc->ifp->if_snd, LLAN_MAX_TX_PACKETS);
sc->ifp->if_snd.ifq_drv_maxlen = LLAN_MAX_TX_PACKETS;
IFQ_SET_READY(&sc->ifp->if_snd);
ether_ifattach(sc->ifp, &sc->mac_address[2]);
+ /* We don't have link state reporting, so make it always up */
+ if_link_state_change(sc->ifp, LINK_STATE_UP);
+
+ return (0);
+}
+
+static int
+llan_media_change(struct ifnet *ifp)
+{
+ struct llan_softc *sc = ifp->if_softc;
+
+ if (IFM_TYPE(sc->media.ifm_media) != IFM_ETHER)
+ return (EINVAL);
+
+ if (IFM_SUBTYPE(sc->media.ifm_media) != IFM_AUTO)
+ return (EINVAL);
+
return (0);
}
static void
+llan_media_status(struct ifnet *ifp, struct ifmediareq *ifmr)
+{
+
+ ifmr->ifm_status = IFM_AVALID | IFM_ACTIVE | IFM_UNKNOWN | IFM_FDX;
+ ifmr->ifm_active = IFM_ETHER;
+}
+
+static void
llan_rx_load_cb(void *xsc, bus_dma_segment_t *segs, int nsegs, int err)
{
struct llan_softc *sc = xsc;
@@ -501,6 +535,10 @@ llan_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
llan_set_multicast(sc);
mtx_unlock(&sc->io_lock);
break;
+ case SIOCGIFMEDIA:
+ case SIOCSIFMEDIA:
+ err = ifmedia_ioctl(ifp, (struct ifreq *)data, &sc->media, cmd);
+ break;
case SIOCSIFFLAGS:
default:
err = ether_ioctl(ifp, cmd, data);
OpenPOWER on IntegriCloud