From owner-svn-src-all@FreeBSD.ORG Fri Nov 4 20:43:38 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3C321106566B; Fri, 4 Nov 2011 20:43:38 +0000 (UTC) (envelope-from yongari@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 12D978FC1A; Fri, 4 Nov 2011 20:43:38 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id pA4Khb0q033798; Fri, 4 Nov 2011 20:43:37 GMT (envelope-from yongari@svn.freebsd.org) Received: (from yongari@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id pA4Khb6Z033796; Fri, 4 Nov 2011 20:43:37 GMT (envelope-from yongari@svn.freebsd.org) Message-Id: <201111042043.pA4Khb6Z033796@svn.freebsd.org> From: Pyun YongHyeon Date: Fri, 4 Nov 2011 20:43:37 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r227092 - head/sys/dev/ti X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Nov 2011 20:43:38 -0000 Author: yongari Date: Fri Nov 4 20:43:37 2011 New Revision: 227092 URL: http://svn.freebsd.org/changeset/base/227092 Log: 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. Modified: head/sys/dev/ti/if_ti.c Modified: head/sys/dev/ti/if_ti.c ============================================================================== --- head/sys/dev/ti/if_ti.c Fri Nov 4 20:25:30 2011 (r227091) +++ head/sys/dev/ti/if_ti.c Fri Nov 4 20:43:37 2011 (r227092) @@ -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);