From owner-svn-src-head@FreeBSD.ORG Sat Sep 25 01:18:01 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 B84A3106564A; Sat, 25 Sep 2010 01:18:01 +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 A5D4B8FC17; Sat, 25 Sep 2010 01:18:01 +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 o8P1I1Wj045194; Sat, 25 Sep 2010 01:18:01 GMT (envelope-from jmallett@svn.freebsd.org) Received: (from jmallett@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o8P1I1La045188; Sat, 25 Sep 2010 01:18:01 GMT (envelope-from jmallett@svn.freebsd.org) Message-Id: <201009250118.o8P1I1La045188@svn.freebsd.org> From: Juli Mallett Date: Sat, 25 Sep 2010 01:18:01 +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: r213150 - head/sys/mips/cavium/octe 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: Sat, 25 Sep 2010 01:18:01 -0000 Author: jmallett Date: Sat Sep 25 01:18:01 2010 New Revision: 213150 URL: http://svn.freebsd.org/changeset/base/213150 Log: Handle link updates in a task. Modified: head/sys/mips/cavium/octe/cavium-ethernet.h head/sys/mips/cavium/octe/ethernet-rgmii.c head/sys/mips/cavium/octe/ethernet-sgmii.c head/sys/mips/cavium/octe/ethernet-xaui.c head/sys/mips/cavium/octe/ethernet.c Modified: head/sys/mips/cavium/octe/cavium-ethernet.h ============================================================================== --- head/sys/mips/cavium/octe/cavium-ethernet.h Sat Sep 25 00:01:55 2010 (r213149) +++ head/sys/mips/cavium/octe/cavium-ethernet.h Sat Sep 25 01:18:01 2010 (r213150) @@ -75,6 +75,8 @@ typedef struct { struct ifqueue tx_free_queue[16]; + int need_link_update; + struct task link_task; struct ifmedia media; int if_flags; Modified: head/sys/mips/cavium/octe/ethernet-rgmii.c ============================================================================== --- head/sys/mips/cavium/octe/ethernet-rgmii.c Sat Sep 25 00:01:55 2010 (r213149) +++ head/sys/mips/cavium/octe/ethernet-rgmii.c Sat Sep 25 01:18:01 2010 (r213150) @@ -136,27 +136,8 @@ static void cvm_oct_rgmii_poll(struct if link_info = cvmx_helper_link_autoconf(priv->port); priv->link_info = link_info.u64; + priv->need_link_update = 1; mtx_unlock_spin(&global_register_lock); - - /* Tell Linux */ - if (link_info.s.link_up) { - - if_link_state_change(ifp, LINK_STATE_UP); - if (priv->queue != -1) - DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, queue %2d\n", - if_name(ifp), link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port, priv->queue); - else - DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, POW\n", - if_name(ifp), link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port); - } else { - - if_link_state_change(ifp, LINK_STATE_DOWN); - DEBUGPRINT("%s: Link down\n", if_name(ifp)); - } } Modified: head/sys/mips/cavium/octe/ethernet-sgmii.c ============================================================================== --- head/sys/mips/cavium/octe/ethernet-sgmii.c Sat Sep 25 00:01:55 2010 (r213149) +++ head/sys/mips/cavium/octe/ethernet-sgmii.c Sat Sep 25 01:18:01 2010 (r213150) @@ -93,25 +93,7 @@ static void cvm_oct_sgmii_poll(struct if link_info = cvmx_helper_link_autoconf(priv->port); priv->link_info = link_info.u64; - - /* Tell Linux */ - if (link_info.s.link_up) { - - if_link_state_change(ifp, LINK_STATE_UP); - if (priv->queue != -1) - DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, queue %2d\n", - if_name(ifp), link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port, priv->queue); - else - DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, POW\n", - if_name(ifp), link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port); - } else { - if_link_state_change(ifp, LINK_STATE_DOWN); - DEBUGPRINT("%s: Link down\n", if_name(ifp)); - } + priv->need_link_update = 1; } int cvm_oct_sgmii_init(struct ifnet *ifp) Modified: head/sys/mips/cavium/octe/ethernet-xaui.c ============================================================================== --- head/sys/mips/cavium/octe/ethernet-xaui.c Sat Sep 25 00:01:55 2010 (r213149) +++ head/sys/mips/cavium/octe/ethernet-xaui.c Sat Sep 25 01:18:01 2010 (r213150) @@ -92,25 +92,7 @@ static void cvm_oct_xaui_poll(struct ifn link_info = cvmx_helper_link_autoconf(priv->port); priv->link_info = link_info.u64; - - /* Tell Linux */ - if (link_info.s.link_up) { - - if_link_state_change(ifp, LINK_STATE_UP); - if (priv->queue != -1) - DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, queue %2d\n", - if_name(ifp), link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port, priv->queue); - else - DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, POW\n", - if_name(ifp), link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port); - } else { - if_link_state_change(ifp, LINK_STATE_DOWN); - DEBUGPRINT("%s: Link down\n", if_name(ifp)); - } + priv->need_link_update = 1; } Modified: head/sys/mips/cavium/octe/ethernet.c ============================================================================== --- head/sys/mips/cavium/octe/ethernet.c Sat Sep 25 00:01:55 2010 (r213149) +++ head/sys/mips/cavium/octe/ethernet.c Sat Sep 25 01:18:01 2010 (r213150) @@ -40,6 +40,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -129,6 +130,40 @@ static struct callout cvm_oct_poll_timer */ struct ifnet *cvm_oct_device[TOTAL_NUMBER_OF_PORTS]; +/** + * Task to handle link status changes. + */ +static struct taskqueue *cvm_oct_link_taskq; + +/** + * Function to update link status. + */ +static void cvm_oct_update_link(void *context, int pending) +{ + cvm_oct_private_t *priv = (cvm_oct_private_t *)context; + struct ifnet *ifp = priv->ifp; + cvmx_helper_link_info_t link_info; + + link_info.u64 = priv->link_info; + + if (link_info.s.link_up) { + if_link_state_change(ifp, LINK_STATE_UP); + if (priv->queue != -1) + DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, queue %2d\n", + if_name(ifp), link_info.s.speed, + (link_info.s.full_duplex) ? "Full" : "Half", + priv->port, priv->queue); + else + DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, POW\n", + if_name(ifp), link_info.s.speed, + (link_info.s.full_duplex) ? "Full" : "Half", + priv->port); + } else { + if_link_state_change(ifp, LINK_STATE_DOWN); + DEBUGPRINT("%s: Link down\n", if_name(ifp)); + } + priv->need_link_update = 0; +} /** * Periodic timer tick for slow management operations @@ -149,6 +184,10 @@ static void cvm_do_timer(void *arg) if (MDIO_TRYLOCK()) { priv->poll(cvm_oct_device[port]); MDIO_UNLOCK(); + + if (priv->need_link_update) { + taskqueue_enqueue(cvm_oct_link_taskq, &priv->link_task); + } } } @@ -323,6 +362,11 @@ int cvm_oct_init_module(device_t bus) memset(cvm_oct_device, 0, sizeof(cvm_oct_device)); + cvm_oct_link_taskq = taskqueue_create("octe link", M_NOWAIT, + taskqueue_thread_enqueue, &cvm_oct_link_taskq); + taskqueue_start_threads(&cvm_oct_link_taskq, 1, PI_NET, + "octe link taskq"); + /* Initialize the FAU used for counting packet buffers that need to be freed */ cvmx_fau_atomic_write32(FAU_NUM_PACKET_BUFFERS_TO_FREE, 0); @@ -345,6 +389,7 @@ int cvm_oct_init_module(device_t bus) priv->imode = CVMX_HELPER_INTERFACE_MODE_DISABLED; priv->port = CVMX_PIP_NUM_INPUT_PORTS; priv->queue = -1; + TASK_INIT(&priv->link_task, 0, cvm_oct_update_link, priv); device_set_desc(dev, "Cavium Octeon POW Ethernet\n"); @@ -398,6 +443,7 @@ int cvm_oct_init_module(device_t bus) priv->fau = fau - cvmx_pko_get_num_queues(port) * 4; for (qos = 0; qos < cvmx_pko_get_num_queues(port); qos++) cvmx_fau_atomic_write32(priv->fau+qos*4, 0); + TASK_INIT(&priv->link_task, 0, cvm_oct_update_link, priv); switch (priv->imode) {