From owner-svn-src-head@FreeBSD.ORG Thu Mar 11 22:22:06 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C393D106564A; Thu, 11 Mar 2010 22:22:06 +0000 (UTC) (envelope-from jmallett@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B28EC8FC16; Thu, 11 Mar 2010 22:22:06 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2BMM669096591; Thu, 11 Mar 2010 22:22:06 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2BMM6HM096588; Thu, 11 Mar 2010 22:22:06 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201003112222.o2BMM6HM096588@svn.freebsd.org> From: Juli Mallett Date: Thu, 11 Mar 2010 22:22:06 +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: r205047 - head/sys/mips/cavium/dev/rgmii X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Mar 2010 22:22:06 -0000 Author: jmallett Date: Thu Mar 11 22:22:06 2010 New Revision: 205047 URL: http://svn.freebsd.org/changeset/base/205047 Log: o) Eliminate use of sc->typestr, which is always NULL. o) Inline octeon_rgmx_mark_ready into octeon_rgmx_init. o) Add a media status handler that reports link and media status. o) Set link state when if_init is called. o) Remove some printfs related to driver state changes. o) Remove some gratuitous comments. Reviewed by: imp Sponsored by: Packet Forensics Modified: head/sys/mips/cavium/dev/rgmii/octeon_rgmx.c Modified: head/sys/mips/cavium/dev/rgmii/octeon_rgmx.c ============================================================================== --- head/sys/mips/cavium/dev/rgmii/octeon_rgmx.c Thu Mar 11 22:14:07 2010 (r205046) +++ head/sys/mips/cavium/dev/rgmii/octeon_rgmx.c Thu Mar 11 22:22:06 2010 (r205047) @@ -136,7 +136,6 @@ struct rgmx_softc_dev { u_int idx; u_char ieee[6]; - char const * typestr; /* printable name of the interface. */ u_short txb_size; /* size of TX buffer, in bytes */ /* Transmission buffer management. */ @@ -182,7 +181,6 @@ static u_int get_rgmx_port_ordinal(u_int static void octeon_rgmx_set_mac(u_int port); static void octeon_rgmx_init_sc(struct rgmx_softc_dev *sc, device_t dev, u_int port, u_int num_devices); static int octeon_rgmx_init_ifnet(struct rgmx_softc_dev *sc); -static void octeon_rgmx_mark_ready(struct rgmx_softc_dev *sc); static void octeon_rgmx_stop(struct rgmx_softc_dev *sc); static void octeon_rgmx_config_speed(u_int port, u_int); #ifdef DEBUG_RGMX_DUMP @@ -349,8 +347,6 @@ static int octeon_rgmx_init_ifnet (struc ifmedia_set(&sc->media, bit2media[0]); ether_ifattach(sc->ifp, sc->ieee); - /* Print additional info when attached. */ - device_printf(sc->sc_dev, "type %s, full duplex\n", sc->typestr); return (0); } @@ -447,12 +443,6 @@ static int rgmii_attach (device_t dev) device_printf(dev, " ifinit failed for rgmx port %u\n", port); return (ENOSPC); } -/* - * Don't call octeon_rgmx_mark_ready() - * ifnet will call it indirectly via octeon_rgmx_init() - * - * octeon_rgmx_mark_ready(sc); - */ num_devices++; } } @@ -1648,9 +1638,47 @@ static int octeon_rgmx_medchange (struct static void octeon_rgmx_medstat (struct ifnet *ifp, struct ifmediareq *ifm) { - /* - * No support for Media Status callback - */ + struct rgmx_softc_dev *sc = ifp->if_softc; + octeon_rgmx_rxx_rx_inbnd_t link_status; + + octeon_rgmx_config_speed(sc->port, 1); + + RGMX_LOCK(sc); + + ifm->ifm_status = IFM_AVALID; + ifm->ifm_active = IFM_ETHER; + + /* + * Parse link status. + */ + link_status.word64 = sc->link_status; + + if (!link_status.bits.status) { + RGMX_UNLOCK(sc); + return; + } + + ifm->ifm_status |= IFM_ACTIVE; + + switch (link_status.bits.speed) { + case 0: + ifm->ifm_active |= IFM_10_T; + break; + case 1: + ifm->ifm_active |= IFM_100_TX; + break; + case 2: + ifm->ifm_active |= IFM_1000_T;; + break; + default: + /* Unknown! */ + break; + } + + /* Always full duplex. */ + ifm->ifm_active |= IFM_FDX; + + RGMX_UNLOCK(sc); } static int octeon_rgmx_ioctl (struct ifnet * ifp, u_long command, caddr_t data) @@ -1678,10 +1706,7 @@ static int octeon_rgmx_ioctl (struct ifn * Restart or Start now, if driver is not running currently. */ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) { - printf(" SIOCSTIFFLAGS UP/Not-running\n"); break; octeon_rgmx_init(sc); - } else { - printf(" SIOCSTIFFLAGS UP/Running\n"); break; } } else { /* @@ -1689,10 +1714,7 @@ static int octeon_rgmx_ioctl (struct ifn * Stop & shut it down now, if driver is running currently. */ if ((ifp->if_drv_flags & IFF_DRV_RUNNING) != 0) { - printf(" SIOCSTIFFLAGS Down/Running\n"); break; octeon_rgmx_stop(sc); - } else { - printf(" SIOCSTIFFLAGS Down/Not-Running\n"); break; } } break; @@ -1734,17 +1756,10 @@ static int octeon_rgmx_ioctl (struct ifn return (error); } - - - -/* - * octeon_rgmx_mark_ready - * - * Initialize the rgmx driver for this instance - * Initialize device. - */ -static void octeon_rgmx_mark_ready (struct rgmx_softc_dev *sc) +static void octeon_rgmx_init (void *xsc) { + struct rgmx_softc_dev *sc = xsc; + octeon_rgmx_rxx_rx_inbnd_t link_status; /* Enable interrupts. */ /* For RGMX they are already enabled earlier */ @@ -1763,21 +1778,21 @@ static void octeon_rgmx_mark_ready (stru /* Kick start the output */ /* Hopefully PKO is running and will pick up packets via the timer or receive loop */ -} + /* Set link status. */ + octeon_rgmx_config_speed(sc->port, 0); -static void octeon_rgmx_init (void *xsc) -{ + RGMX_LOCK(sc); + /* + * Parse link status. + */ + link_status.word64 = sc->link_status; - /* - * Called mostly from ifnet interface ifp->if_init(); - * I think we can anchor most of our iniialization here and - * not do it in different places from driver_attach(). - */ - /* - * For now, we only mark the interface ready - */ - octeon_rgmx_mark_ready((struct rgmx_softc_dev *) xsc); + if (link_status.bits.status) + if_link_state_change(sc->ifp, LINK_STATE_UP); + else + if_link_state_change(sc->ifp, LINK_STATE_DOWN); + RGMX_UNLOCK(sc); }