Changeset View
Changeset View
Standalone View
Standalone View
sys/dev/neta/if_mvneta.c
Show First 20 Lines • Show All 183 Lines • ▼ Show 20 Lines | |||||
STATIC int sysctl_set_queue_rxthtime(SYSCTL_HANDLER_ARGS); | STATIC int sysctl_set_queue_rxthtime(SYSCTL_HANDLER_ARGS); | ||||
STATIC void sysctl_mvneta_init(struct mvneta_softc *); | STATIC void sysctl_mvneta_init(struct mvneta_softc *); | ||||
/* MIB */ | /* MIB */ | ||||
STATIC void mvneta_clear_mib(struct mvneta_softc *); | STATIC void mvneta_clear_mib(struct mvneta_softc *); | ||||
STATIC void mvneta_update_mib(struct mvneta_softc *); | STATIC void mvneta_update_mib(struct mvneta_softc *); | ||||
/* Switch */ | /* Switch */ | ||||
STATIC boolean_t mvneta_find_ethernet_prop_switch(phandle_t, phandle_t); | |||||
STATIC boolean_t mvneta_has_switch(device_t); | STATIC boolean_t mvneta_has_switch(device_t); | ||||
#define mvneta_sc_lock(sc) mtx_lock(&sc->mtx) | #define mvneta_sc_lock(sc) mtx_lock(&sc->mtx) | ||||
mw: don't add this new line | |||||
#define mvneta_sc_unlock(sc) mtx_unlock(&sc->mtx) | #define mvneta_sc_unlock(sc) mtx_unlock(&sc->mtx) | ||||
STATIC struct mtx mii_mutex; | STATIC struct mtx mii_mutex; | ||||
STATIC int mii_init = 0; | STATIC int mii_init = 0; | ||||
/* Device */ | /* Device */ | ||||
STATIC int mvneta_detach(device_t); | STATIC int mvneta_detach(device_t); | ||||
/* MII */ | /* MII */ | ||||
▲ Show 20 Lines • Show All 204 Lines • ▼ Show 20 Lines | #endif | ||||
addr[2] = (mac_h & 0x0000ff00) >> 8; | addr[2] = (mac_h & 0x0000ff00) >> 8; | ||||
addr[3] = (mac_h & 0x000000ff); | addr[3] = (mac_h & 0x000000ff); | ||||
addr[4] = (mac_l & 0x0000ff00) >> 8; | addr[4] = (mac_l & 0x0000ff00) >> 8; | ||||
addr[5] = (mac_l & 0x000000ff); | addr[5] = (mac_l & 0x000000ff); | ||||
return (0); | return (0); | ||||
} | } | ||||
STATIC boolean_t | 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); | for (child = OF_child(node); child != 0; child = OF_peer(child)) { | ||||
switch_node = | if (OF_getencprop(child, "ethernet", (void*)&switch_eth_handle, | ||||
ofw_bus_find_compatible(OF_finddevice("/"), "marvell,dsa"); | sizeof(switch_eth_handle)) > 0) { | ||||
Done Inline ActionsPlease do not add XXX comments, anyway mv88e6058 has a typo :) For finding if current port is referenced as a CPU port of the switch, I think we have 3 options: I'd go for c. Below code mostly does this anyway, just extend search to entire DT and the solution will be more generic. mw: Please do not add XXX comments, anyway mv88e6058 has a typo :)
For finding if current port is… | |||||
Done Inline Actions+1 xistence_0x58.com: +1 | |||||
switch_eth = 0; | if (switch_eth_handle > 0) { | ||||
switch_eth = OF_node_from_xref( | |||||
switch_eth_handle); | |||||
OF_getencprop(switch_node, "dsa,ethernet", | if (switch_eth == ethernet) | ||||
(void*)&switch_eth_handle, sizeof(switch_eth_handle)); | return (true); | ||||
} | |||||
} | |||||
if (switch_eth_handle > 0) | ret = mvneta_find_ethernet_prop_switch(ethernet, child); | ||||
switch_eth = OF_node_from_xref(switch_eth_handle); | if (ret != 0) | ||||
return (ret); | |||||
} | |||||
/* Return true if dsa,ethernet cell points to us */ | return (false); | ||||
return (node == switch_eth); | |||||
} | } | ||||
STATIC boolean_t | |||||
mvneta_has_switch(device_t self) | |||||
Done Inline ActionsMake sure "ports" is found. mw: Make sure "ports" is found. | |||||
Done Inline Actions+1 xistence_0x58.com: +1 | |||||
{ | |||||
phandle_t node; | |||||
node = ofw_bus_get_node(self); | |||||
return mvneta_find_ethernet_prop_switch(node, OF_finddevice("/")); | |||||
Done Inline Actionsnit: please add blank line before return. mw: nit: please add blank line before return. | |||||
} | |||||
STATIC int | STATIC int | ||||
mvneta_dma_create(struct mvneta_softc *sc) | mvneta_dma_create(struct mvneta_softc *sc) | ||||
{ | { | ||||
size_t maxsize, maxsegsz; | size_t maxsize, maxsegsz; | ||||
size_t q; | size_t q; | ||||
int error; | int error; | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 352 Lines • ▼ Show 20 Lines | if ((sc->phy_addr != MII_PHY_ANY) && (!sc->use_inband_status)) { | ||||
else | else | ||||
ifm_target |= IFM_HDX; | ifm_target |= IFM_HDX; | ||||
ifmedia_add(&sc->mvneta_ifmedia, ifm_target, 0, NULL); | ifmedia_add(&sc->mvneta_ifmedia, ifm_target, 0, NULL); | ||||
ifmedia_set(&sc->mvneta_ifmedia, ifm_target); | ifmedia_set(&sc->mvneta_ifmedia, ifm_target); | ||||
if_link_state_change(sc->ifp, LINK_STATE_UP); | if_link_state_change(sc->ifp, LINK_STATE_UP); | ||||
if (mvneta_has_switch(self)) { | 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); | child = device_add_child(sc->dev, "mdio", -1); | ||||
if (child == NULL) { | if (child == NULL) { | ||||
ether_ifdetach(sc->ifp); | ether_ifdetach(sc->ifp); | ||||
mvneta_detach(self); | mvneta_detach(self); | ||||
return (ENXIO); | return (ENXIO); | ||||
} | } | ||||
bus_generic_attach(sc->dev); | bus_generic_attach(sc->dev); | ||||
bus_generic_attach(child); | bus_generic_attach(child); | ||||
} else if (bootverbose) { | |||||
device_printf(self, "This device is not attached to a switch\n"); | |||||
Done Inline ActionsPlease remove this print for "!has_switch" case. It is most common case and most boards do not have it, so imo it won't look well. mw: Please remove this print for "!has_switch" case. It is most common case and most boards do not… | |||||
} | } | ||||
/* Configure MAC media */ | /* Configure MAC media */ | ||||
mvneta_update_media(sc, ifm_target); | mvneta_update_media(sc, ifm_target); | ||||
} | } | ||||
sysctl_mvneta_init(sc); | sysctl_mvneta_init(sc); | ||||
▲ Show 20 Lines • Show All 2,040 Lines • Show Last 20 Lines |
don't add this new line