Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jun 2016 16:26:59 GMT
From:      vincenzo@FreeBSD.org
To:        svn-soc-all@FreeBSD.org
Subject:   socsvn commit: r305304 - soc2016/vincenzo/head/sys/dev/netmap
Message-ID:  <201606171626.u5HGQxoB028313@socsvn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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);
+}
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201606171626.u5HGQxoB028313>