summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2019-09-07 13:33:01 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2019-09-07 13:33:01 +0000
commitb862a681316b4bf7855e9a4da7c7131b9234d741 (patch)
tree4b8f000d34648748e0ea9f251c111c44bad67dce /sys
parentad4c03cf29c0e05d73b3e6723b817e21335d4367 (diff)
Retrieve SFP information using the SFP framework.
Feedback from dlg@ ok kettenis@
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/fdt/if_mvneta.c16
1 files changed, 15 insertions, 1 deletions
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 <dev/ofw/openfirm.h>
#include <dev/ofw/ofw_clock.h>
+#include <dev/ofw/ofw_misc.h>
#include <dev/ofw/ofw_pinctrl.h>
#include <dev/ofw/fdt.h>
@@ -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);