summaryrefslogtreecommitdiff
path: root/sys/dev/neta
diff options
context:
space:
mode:
authorMarcin Wojtas <mw@FreeBSD.org>2019-03-23 02:48:47 +0000
committerMarcin Wojtas <mw@FreeBSD.org>2019-03-23 02:48:47 +0000
commit0fd68d7298292d55e00375dff06077f1689d3f89 (patch)
tree26c23467a92eb2b738d141922a97c40556e5e84b /sys/dev/neta
parent55d3f888de48acdad3979651a73825ac11513010 (diff)
Notes
Diffstat (limited to 'sys/dev/neta')
-rw-r--r--sys/dev/neta/if_mvneta.c43
1 files changed, 31 insertions, 12 deletions
diff --git a/sys/dev/neta/if_mvneta.c b/sys/dev/neta/if_mvneta.c
index 9b0b2384d74b..d6cdd7032445 100644
--- a/sys/dev/neta/if_mvneta.c
+++ b/sys/dev/neta/if_mvneta.c
@@ -189,6 +189,7 @@ STATIC void mvneta_clear_mib(struct mvneta_softc *);
STATIC void mvneta_update_mib(struct mvneta_softc *);
/* Switch */
+STATIC boolean_t mvneta_find_ethernet_prop_switch(phandle_t, phandle_t);
STATIC boolean_t mvneta_has_switch(device_t);
#define mvneta_sc_lock(sc) mtx_lock(&sc->mtx)
@@ -412,23 +413,39 @@ mvneta_get_mac_address(struct mvneta_softc *sc, uint8_t *addr)
}
STATIC boolean_t
-mvneta_has_switch(device_t self)
+mvneta_find_ethernet_prop_switch(phandle_t ethernet, phandle_t node)
{
- phandle_t node, switch_node, switch_eth, switch_eth_handle;
+ boolean_t ret;
+ phandle_t child, switch_eth_handle, switch_eth;
- node = ofw_bus_get_node(self);
- switch_node =
- ofw_bus_find_compatible(OF_finddevice("/"), "marvell,dsa");
- switch_eth = 0;
+ for (child = OF_child(node); child != 0; child = OF_peer(child)) {
+ if (OF_getencprop(child, "ethernet", (void*)&switch_eth_handle,
+ sizeof(switch_eth_handle)) > 0) {
+ if (switch_eth_handle > 0) {
+ switch_eth = OF_node_from_xref(
+ switch_eth_handle);
- OF_getencprop(switch_node, "dsa,ethernet",
- (void*)&switch_eth_handle, sizeof(switch_eth_handle));
+ if (switch_eth == ethernet)
+ return (true);
+ }
+ }
- if (switch_eth_handle > 0)
- switch_eth = OF_node_from_xref(switch_eth_handle);
+ ret = mvneta_find_ethernet_prop_switch(ethernet, child);
+ if (ret != 0)
+ return (ret);
+ }
+
+ return (false);
+}
+
+STATIC boolean_t
+mvneta_has_switch(device_t self)
+{
+ phandle_t node;
+
+ node = ofw_bus_get_node(self);
- /* Return true if dsa,ethernet cell points to us */
- return (node == switch_eth);
+ return mvneta_find_ethernet_prop_switch(node, OF_finddevice("/"));
}
STATIC int
@@ -799,6 +816,8 @@ mvneta_attach(device_t self)
if_link_state_change(sc->ifp, LINK_STATE_UP);
if (mvneta_has_switch(self)) {
+ if (bootverbose)
+ device_printf(self, "This device is attached to a switch\n");
child = device_add_child(sc->dev, "mdio", -1);
if (child == NULL) {
ether_ifdetach(sc->ifp);