From owner-svn-soc-all@freebsd.org Fri Jun 17 16:27:00 2016 Return-Path: Delivered-To: svn-soc-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9B566A7787D for ; Fri, 17 Jun 2016 16:27:00 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8036826D1 for ; Fri, 17 Jun 2016 16:27:00 +0000 (UTC) (envelope-from vincenzo@FreeBSD.org) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.15.2/8.15.2) with ESMTP id u5HGR0FM028321 for ; Fri, 17 Jun 2016 16:27:00 GMT (envelope-from vincenzo@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.15.2/8.15.2/Submit) id u5HGQxoB028313 for svn-soc-all@FreeBSD.org; Fri, 17 Jun 2016 16:26:59 GMT (envelope-from vincenzo@FreeBSD.org) Date: Fri, 17 Jun 2016 16:26:59 GMT Message-Id: <201606171626.u5HGQxoB028313@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to vincenzo@FreeBSD.org using -f From: vincenzo@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r305304 - soc2016/vincenzo/head/sys/dev/netmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2016 16:27:00 -0000 Author: vincenzo Date: Fri Jun 17 16:26:59 2016 New Revision: 305304 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=305304 Log: freebsd: ptnet: support taskqueue on receive datapath Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Modified: soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c ============================================================================== --- soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri Jun 17 16:26:20 2016 (r305303) +++ soc2016/vincenzo/head/sys/dev/netmap/if_ptnet.c Fri Jun 17 16:26:59 2016 (r305304) @@ -102,6 +102,8 @@ struct ptnet_ring *ptring; unsigned int kick; struct mtx lock; + struct taskqueue *taskq; + struct task task; char lock_name[16]; }; @@ -175,6 +177,7 @@ static void ptnet_rx_intr(void *opaque); static int ptnet_rx_eof(struct ptnet_queue *pq); +static void ptnet_rx_task(void *context, int pending); static device_method_t ptnet_methods[] = { DEVMETHOD(device_probe, ptnet_probe), @@ -478,6 +481,7 @@ unsigned int num_tx_rings; device_t dev = sc->dev; int err = ENOSPC; + int cpu_cur; int i; num_tx_rings = bus_read_4(sc->iomem, PTNET_IO_NUM_TX_RINGS); @@ -519,6 +523,7 @@ } } + cpu_cur = CPU_FIRST(); for (i = 0; i < nvecs; i++) { struct ptnet_queue *pq = sc->queues + i; void (*handler)(void *) = ptnet_tx_intr; @@ -536,11 +541,29 @@ } bus_describe_intr(dev, pq->irq, pq->cookie, "q%d", i); - //bus_bind_intr(); /* bind intr to CPU */ + bus_bind_intr(sc->dev, pq->irq, cpu_cur); + cpu_cur = CPU_NEXT(cpu_cur); } device_printf(dev, "Allocated %d MSI-X vectors\n", nvecs); + cpu_cur = CPU_FIRST(); + for (i = 0; i < nvecs; i++) { + struct ptnet_queue *pq = sc->queues + i; + + if (i < num_tx_rings) { + /* Only support RX queues for now. */ + continue; + } + + TASK_INIT(&pq->task, 0, ptnet_rx_task, pq); + pq->taskq = taskqueue_create_fast("ptnet_queue", M_NOWAIT, + taskqueue_thread_enqueue, &pq->taskq); + taskqueue_start_threads(&pq->taskq, 1, PI_NET, "%s-pq-%d", + device_get_nameunit(sc->dev), cpu_cur); + cpu_cur = CPU_NEXT(cpu_cur); + } + /* Tell the hypervisor that we have allocated the MSI-X vectors, * so that it can do its own setup. */ bus_write_4(sc->iomem, PTNET_IO_CTRL, PTNET_CTRL_IRQINIT); @@ -1169,9 +1192,10 @@ struct netmap_kring *kring = na->rx_rings + pq->kring_id; struct netmap_ring *ring = kring->ring; unsigned int const lim = kring->nkr_num_slots - 1; + unsigned int budget = RX_BUDGET; unsigned int head = ring->head; struct ifnet *ifp = sc->ifp; - unsigned int budget = RX_BUDGET; + unsigned int more; PTNET_Q_LOCK(pq); @@ -1246,7 +1270,26 @@ } } + more = (head != ring->tail); + PTNET_Q_UNLOCK(pq); + if (more) { + device_printf(sc->dev, "%s: resched: budget %u h %u " + "t %u\n", __func__, budget, ring->head, + ring->tail); + taskqueue_enqueue(pq->taskq, &pq->task); + } + return 0; } + +static void +ptnet_rx_task(void *context, int pending) +{ + struct ptnet_queue *pq = context; + + device_printf(pq->sc->dev, "%s: pq #%u\n", __func__, pq->kring_id); + ptnet_rx_eof(pq); +} +