Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F142018226
D19036.id53662.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D19036.id53662.diff
View Options
Index: sys/dev/etherswitch/e6000sw/e6000sw.c
===================================================================
--- sys/dev/etherswitch/e6000sw/e6000sw.c
+++ sys/dev/etherswitch/e6000sw/e6000sw.c
@@ -45,8 +45,8 @@
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
-#include <dev/fdt/fdt_common.h>
#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
#include "e6000swreg.h"
#include "etherswitch_if.h"
@@ -197,15 +197,17 @@
{
e6000sw_softc_t *sc;
const char *description;
- phandle_t dsa_node, switch_node;
+ phandle_t switch_node;
- dsa_node = fdt_find_compatible(OF_finddevice("/"),
- "marvell,dsa", 0);
- switch_node = OF_child(dsa_node);
+ switch_node = ofw_bus_find_compatible(OF_finddevice("/"),
+ "marvell,mv88e6085");
if (switch_node == 0)
return (ENXIO);
+ if (bootverbose)
+ device_printf(dev, "Found switch_node: 0x%x\n", switch_node);
+
sc = device_get_softc(dev);
sc->dev = dev;
sc->node = switch_node;
@@ -214,8 +216,12 @@
sizeof(sc->sw_addr)) < 0)
return (ENXIO);
- if (!OF_hasprop(sc->node, "single-chip-addressing") &&
- (sc->sw_addr != 0 && (sc->sw_addr % 2) == 0))
+ /*
+ * According to the Linux source code, all of the Switch IDs we support
+ * are multi_chip capable, and should go into multi-chip mode if the
+ * sw_addr != 0.
+ */
+ if (!OF_hasprop(sc->node, "single-chip-addressing") && sc->sw_addr != 0)
sc->multi_chip = true;
/*
@@ -264,9 +270,9 @@
static int
e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t child, int *pport)
{
- char *name, *portlabel;
+ char *portlabel;
int speed;
- phandle_t fixed_link;
+ phandle_t fixed_link, switch_eth, switch_eth_handle;
uint32_t port;
if (pport == NULL)
@@ -287,23 +293,31 @@
free(portlabel, M_OFWPROP);
}
- fixed_link = OF_child(child);
- if (fixed_link != 0 &&
- OF_getprop_alloc(fixed_link, "name", (void **)&name) > 0) {
- if (strncmp(name, "fixed-link", 10) == 0) {
- /* Assume defaults: 1g - full-duplex. */
- sc->fixed_mask |= (1 << port);
- if (OF_getencprop(fixed_link, "speed", &speed,
- sizeof(speed)) > 0) {
- if (speed == 2500 &&
- (MVSWITCH(sc, MV88E6141) ||
- MVSWITCH(sc, MV88E6341))) {
- sc->fixed25_mask |= (1 << port);
+ 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);
+
+ fixed_link = ofw_bus_find_child(switch_eth,
+ "fixed-link");
+
+ if (fixed_link != 0) {
+ sc->fixed_mask |= (1 << port);
+ if (OF_getencprop(fixed_link, "speed", &speed,
+ sizeof(speed)) > 0) {
+ if (speed == 2500 &&
+ (MVSWITCH(sc, MV88E6141) ||
+ MVSWITCH(sc, MV88E6341))) {
+ sc->fixed25_mask |= (1 << port);
+ }
}
}
- }
- free(name, M_OFWPROP);
+ } else
+ device_printf(sc->dev,
+ "Port %d has ethernet property but it points "
+ "to an invalid location\n", port);
}
+
if ((sc->fixed_mask & (1 << port)) != 0)
device_printf(sc->dev, "fixed port at %d\n", port);
else
@@ -354,7 +368,7 @@
e6000sw_attach(device_t dev)
{
e6000sw_softc_t *sc;
- phandle_t child;
+ phandle_t child, ports;
int err, port;
uint32_t reg;
@@ -371,7 +385,9 @@
E6000SW_LOCK(sc);
e6000sw_setup(dev, sc);
- for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) {
+ ports = ofw_bus_find_child(sc->node, "ports");
+
+ for (child = OF_child(ports); child != 0; child = OF_peer(child)) {
err = e6000sw_parse_child_fdt(sc, child, &port);
if (err != 0) {
device_printf(sc->dev, "failed to parse DTS\n");
Index: sys/dev/neta/if_mvneta.c
===================================================================
--- sys/dev/neta/if_mvneta.c
+++ sys/dev/neta/if_mvneta.c
@@ -414,20 +414,35 @@
STATIC boolean_t
mvneta_has_switch(device_t self)
{
- phandle_t node, switch_node, switch_eth, switch_eth_handle;
+ phandle_t node, switch_node, switch_eth, switch_eth_handle, ports, child;
node = ofw_bus_get_node(self);
- switch_node =
- ofw_bus_find_compatible(OF_finddevice("/"), "marvell,dsa");
+ /* XXX: We need a better way to find out if we are refenced by any
+ * switches, since I doubt the mv88e6058 is the only one, but I have no
+ * idea how
+ */
+ switch_node = ofw_bus_find_compatible(OF_finddevice("/"),
+ "marvell,mv88e6085");
switch_eth = 0;
- OF_getencprop(switch_node, "dsa,ethernet",
- (void*)&switch_eth_handle, sizeof(switch_eth_handle));
+ if (switch_node == 0) {
+ return false;
+ }
+
+ ports = ofw_bus_find_child(switch_node, "ports");
- if (switch_eth_handle > 0)
- switch_eth = OF_node_from_xref(switch_eth_handle);
+ for (child = OF_child(ports); 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);
+ break;
+ }
+ }
+ }
- /* Return true if dsa,ethernet cell points to us */
+ /* Return true if ethernet cell points to us */
return (node == switch_eth);
}
@@ -799,6 +814,8 @@
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);
@@ -807,6 +824,8 @@
}
bus_generic_attach(sc->dev);
bus_generic_attach(child);
+ } else if (bootverbose) {
+ device_printf(self, "This device is not attached to a switch\n");
}
/* Configure MAC media */
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 16, 12:02 AM (4 h, 13 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
27656154
Default Alt Text
D19036.id53662.diff (5 KB)
Attached To
Mode
D19036: Update mvneta/e6000sw for new style Distributed Switch Architecture Device Tree Bindings
Attached
Detach File
Event Timeline
Log In to Comment