From b862a681316b4bf7855e9a4da7c7131b9234d741 Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Sat, 7 Sep 2019 13:33:01 +0000 Subject: Retrieve SFP information using the SFP framework. Feedback from dlg@ ok kettenis@ --- sys/dev/fdt/if_mvneta.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'sys') diff --git a/sys/dev/fdt/if_mvneta.c b/sys/dev/fdt/if_mvneta.c index d68bb7c8247..852a5fa54fc 100644 --- a/sys/dev/fdt/if_mvneta.c +++ b/sys/dev/fdt/if_mvneta.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mvneta.c,v 1.7 2019/04/30 20:26:02 patrick Exp $ */ +/* $OpenBSD: if_mvneta.c,v 1.8 2019/09/07 13:33:00 patrick Exp $ */ /* $NetBSD: if_mvneta.c,v 1.41 2015/04/15 10:15:40 hsuenaga Exp $ */ /* * Copyright (c) 2007, 2008, 2013 KIYOHARA Takashi @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -164,6 +165,7 @@ struct mvneta_softc { int sc_inband_status; int sc_phy; int sc_link; + int sc_sfp; }; @@ -204,6 +206,8 @@ struct mvneta_dmamem *mvneta_dmamem_alloc(struct mvneta_softc *, void mvneta_dmamem_free(struct mvneta_softc *, struct mvneta_dmamem *); void mvneta_fill_rx_ring(struct mvneta_softc *); +static struct rwlock mvneta_sff_lock = RWLOCK_INITIALIZER("mvnetasff"); + struct cfdriver mvneta_cd = { NULL, "mvneta", DV_IFNET }; @@ -445,6 +449,8 @@ mvneta_attach(struct device *parent, struct device *self, void *aux) ether_fakeaddr(&sc->sc_ac.ac_if); } + sc->sc_sfp = OF_getpropint(faa->fa_node, "sfp", 0); + printf("%s: Ethernet address %s\n", self->dv_xname, ether_sprintf(sc->sc_enaddr)); @@ -847,6 +853,14 @@ mvneta_ioctl(struct ifnet *ifp, u_long cmd, caddr_t addr) error = if_rxr_ioctl((struct if_rxrinfo *)ifr->ifr_data, NULL, MCLBYTES, &sc->sc_rx_ring); break; + case SIOCGIFSFFPAGE: + error = rw_enter(&mvneta_sff_lock, RW_WRITE|RW_INTR); + if (error != 0) + break; + + error = sfp_get_sffpage(sc->sc_sfp, (struct if_sffpage *)addr); + rw_exit(&mvneta_sff_lock); + break; default: DPRINTFN(2, ("mvneta_ioctl ETHER\n")); error = ether_ioctl(ifp, &sc->sc_ac, cmd, addr); -- cgit v1.2.3