summaryrefslogtreecommitdiffstats
path: root/sys/dev/ti
diff options
context:
space:
mode:
authoryongari <yongari@FreeBSD.org>2011-11-04 20:43:37 +0000
committeryongari <yongari@FreeBSD.org>2011-11-04 20:43:37 +0000
commit302be77fb36ed87dfe0c7c5add226542a4f71206 (patch)
tree334b32acb08ab1c67f07b8fe7fb1b112bcc07db4 /sys/dev/ti
parentf6e77a8a74a860943f17f55f25ec0c53354f4f9e (diff)
downloadFreeBSD-src-302be77fb36ed87dfe0c7c5add226542a4f71206.zip
FreeBSD-src-302be77fb36ed87dfe0c7c5add226542a4f71206.tar.gz
Announce IFCAP_LINKSTATE capability and let network stack know link
state changes. Hide superfluous link up/down message under bootverbose since if_link_state_change(9) shows that information. While I'm here, change baudrate with the resolved speed of the established link instead of blindly setting it 1G. Unfortunately, it seems there is no way to differentiate 10/100Mbps from non-gigabit link so just assume we established a 100Mbps link if current link is not a gigabit link.
Diffstat (limited to 'sys/dev/ti')
-rw-r--r--sys/dev/ti/if_ti.c32
1 files changed, 25 insertions, 7 deletions
diff --git a/sys/dev/ti/if_ti.c b/sys/dev/ti/if_ti.c
index 4c24ad9..e519c42 100644
--- a/sys/dev/ti/if_ti.c
+++ b/sys/dev/ti/if_ti.c
@@ -924,12 +924,26 @@ ti_handle_events(struct ti_softc *sc)
switch (TI_EVENT_EVENT(e)) {
case TI_EV_LINKSTAT_CHANGED:
sc->ti_linkstat = TI_EVENT_CODE(e);
- if (sc->ti_linkstat == TI_EV_CODE_LINK_UP)
- device_printf(sc->ti_dev, "10/100 link up\n");
- else if (sc->ti_linkstat == TI_EV_CODE_GIG_LINK_UP)
- device_printf(sc->ti_dev, "gigabit link up\n");
- else if (sc->ti_linkstat == TI_EV_CODE_LINK_DOWN)
- device_printf(sc->ti_dev, "link down\n");
+ if (sc->ti_linkstat == TI_EV_CODE_LINK_UP) {
+ if_link_state_change(sc->ti_ifp, LINK_STATE_UP);
+ sc->ti_ifp->if_baudrate = IF_Mbps(100);
+ if (bootverbose)
+ device_printf(sc->ti_dev,
+ "10/100 link up\n");
+ } else if (sc->ti_linkstat == TI_EV_CODE_GIG_LINK_UP) {
+ if_link_state_change(sc->ti_ifp, LINK_STATE_UP);
+ sc->ti_ifp->if_baudrate = IF_Gbps(1UL);
+ if (bootverbose)
+ device_printf(sc->ti_dev,
+ "gigabit link up\n");
+ } else if (sc->ti_linkstat == TI_EV_CODE_LINK_DOWN) {
+ if_link_state_change(sc->ti_ifp,
+ LINK_STATE_DOWN);
+ sc->ti_ifp->if_baudrate = 0;
+ if (bootverbose)
+ device_printf(sc->ti_dev,
+ "link down\n");
+ }
break;
case TI_EV_ERROR:
if (TI_EVENT_CODE(e) == TI_EV_CODE_ERR_INVAL_CMD)
@@ -2417,7 +2431,7 @@ ti_attach(device_t dev)
ifp->if_ioctl = ti_ioctl;
ifp->if_start = ti_start;
ifp->if_init = ti_init;
- ifp->if_baudrate = 1000000000;
+ ifp->if_baudrate = IF_Gbps(1UL);
ifp->if_snd.ifq_maxlen = TI_TX_RING_CNT - 1;
/* Set up ifmedia support. */
@@ -2464,6 +2478,10 @@ ti_attach(device_t dev)
*/
ether_ifattach(ifp, eaddr);
+ /* Driver supports link state tracking. */
+ ifp->if_capabilities |= IFCAP_LINKSTATE;
+ ifp->if_capenable |= IFCAP_LINKSTATE;
+
/* Hook interrupt last to avoid having to lock softc */
error = bus_setup_intr(dev, sc->ti_irq, INTR_TYPE_NET|INTR_MPSAFE,
NULL, ti_intr, sc, &sc->ti_intrhand);
OpenPOWER on IntegriCloud