socsvn commit: r288619 - in soc2015/stefano/ptnetmap/stable/10/sys: dev/netmap modules/netmap net

stefano at FreeBSD.org stefano at FreeBSD.org
Tue Jul 21 14:21:36 UTC 2015


Author: stefano
Date: Tue Jul 21 14:21:33 2015
New Revision: 288619
URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=288619

Log:
  add ptnetmap host and kthread support for FreeBSD

Modified:
  soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c
  soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_kern.h
  soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_mem2.c
  soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_virt.h
  soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/ptnetmap.c
  soc2015/stefano/ptnetmap/stable/10/sys/modules/netmap/Makefile
  soc2015/stefano/ptnetmap/stable/10/sys/net/netmap.h

Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c
==============================================================================
--- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c	Tue Jul 21 14:19:50 2015	(r288618)
+++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_freebsd.c	Tue Jul 21 14:21:33 2015	(r288619)
@@ -50,6 +50,10 @@
 #include <sys/malloc.h>
 #include <sys/socket.h> /* sockaddrs */
 #include <sys/selinfo.h>
+#include <sys/kthread.h> /* kthread_add() */
+#include <sys/proc.h> /* PROC_LOCK() */
+#include <sys/unistd.h> /* RFNOWAIT */
+#include <sys/sched.h> /* sched_bind() */
 #include <net/if.h>
 #include <net/if_var.h>
 #include <net/if_types.h> /* IFT_ETHER */
@@ -535,7 +539,7 @@
 	*nm_paddr = rman_get_start(ptn_dev->pci_mem);
 	*nm_addr = rman_get_virtual(ptn_dev->pci_mem);
 
-	D("=== BAR %d start %llx len %llx mem_size %x ===",
+	D("=== BAR %d start %lx len %lx mem_size %x ===",
 			PTNETMAP_MEM_PCI_BAR,
 			*nm_paddr,
 			rman_get_size(ptn_dev->pci_mem),
@@ -892,6 +896,215 @@
 	return 0;
 }
 
+/******************** kthread wrapper ****************/
+struct nm_kthread_ctx {
+	void *ioevent_file;
+	void *irq_file;
+#if 0 /* to be dane after eventfd implementation */
+	/* files to exchange notifications */
+	struct file *ioevent_file;          /* notification from guest */
+	struct file *irq_file;              /* notification to guest (interrupt) */
+	struct eventfd_ctx  *irq_ctx;
+
+	/* poll ioeventfd to receive notification from the guest */
+	poll_table poll_table;
+	wait_queue_head_t *waitq_head;
+	wait_queue_t waitq;
+#endif /* 0 */
+
+	/* worker function and parameter */
+	nm_kthread_worker_fn_t worker_fn;
+	void *worker_private;
+
+	struct nm_kthread *nmk;
+
+	/* integer to manage multiple worker contexts (e.g., RX or TX on ptnetmap) */
+	long type;
+};
+
+struct nm_kthread {
+	//struct mm_struct *mm;
+	struct thread *worker;
+	struct mtx worker_lock;
+	uint64_t scheduled; /* currently not used */
+	struct nm_kthread_ctx worker_ctx;
+	int affinity;
+};
+
+void inline
+nm_kthread_wakeup_worker(struct nm_kthread *nmk)
+{
+	(void)nmk;
+}
+
+void inline
+nm_kthread_send_irq(struct nm_kthread *nmk)
+{
+	(void)nmk;
+}
+
+static
+int is_suspended(void)
+{
+	struct proc *p;
+	struct thread *td;
+	int ret = 0;
+
+	td = curthread;
+	p = td->td_proc;
+
+	if ((td->td_pflags & TDP_KTHREAD) == 0)
+		panic("%s: curthread is not a valid kthread", __func__);
+	PROC_LOCK(p);
+	if (td->td_flags & TDF_KTH_SUSP) {
+		wakeup(&td->td_flags);
+		//msleep(&td->td_flags, &p->p_mtx, PPAUSE, "ktsusp", 0);
+		ret = 1;
+	}
+	PROC_UNLOCK(p);
+	return ret;
+}
+
+static void
+nm_kthread_worker(void *data)
+{
+	struct nm_kthread *nmk = data;
+	struct nm_kthread_ctx *ctx = &nmk->worker_ctx;
+
+	thread_lock(curthread);
+	if (nmk->affinity >= 0)
+		sched_bind(curthread, nmk->affinity);
+	thread_unlock(curthread);
+	for (; !is_suspended();) {
+		if (nmk->worker == NULL)
+			break;
+		ctx->worker_fn(ctx->worker_private); /* worker_body */
+	}
+	kthread_exit();
+}
+
+static int
+nm_kthread_open_files(struct nm_kthread *nmk, struct nm_eventfd_cfg_ring *ring_cfg)
+{
+	(void)nmk;
+	(void)ring_cfg;
+	return 0;
+}
+
+static void
+nm_kthread_close_files(struct nm_kthread *nmk)
+{
+	(void)nmk;
+}
+
+static void
+nm_kthread_init_poll(struct nm_kthread *nmk, struct nm_kthread_ctx *ctx)
+{
+	(void)nmk;
+	(void)ctx;
+	return;
+}
+
+static int
+nm_kthread_start_poll(struct nm_kthread_ctx *ctx, void *file)
+{
+	(void)ctx;
+	(void)file;
+	return 0;
+}
+
+static void
+nm_kthread_stop_poll(struct nm_kthread_ctx *ctx)
+{
+	(void)ctx;
+}
+
+void
+nm_kthread_set_affinity(struct nm_kthread *nmk, int affinity)
+{
+	nmk->affinity = affinity;
+}
+
+struct nm_kthread *
+nm_kthread_create(struct nm_kthread_cfg *cfg)
+{
+	struct nm_kthread *nmk = NULL;
+	int error;
+
+	nmk = malloc(sizeof(*nmk),  M_DEVBUF, M_NOWAIT | M_ZERO);
+	if (!nmk)
+		return NULL;
+
+	mtx_init(&nmk->worker_lock, "nm_kthread lock", NULL, MTX_DEF);
+	nmk->worker_ctx.worker_fn = cfg->worker_fn;
+	nmk->worker_ctx.worker_private = cfg->worker_private;
+	nmk->worker_ctx.type = cfg->type;
+	nmk->affinity = -1;
+
+	/* open event fd */
+	error = nm_kthread_open_files(nmk, &cfg->ring);
+	if (error)
+		goto err;
+	nm_kthread_init_poll(nmk, &nmk->worker_ctx);
+
+	return nmk;
+err:
+	free(nmk, M_DEVBUF);
+	return NULL;
+}
+
+int
+nm_kthread_start(struct nm_kthread *nmk)
+{
+	int error = 0;
+
+	if (nmk->worker) {
+		return EBUSY;
+	}
+
+	error = kthread_add(nm_kthread_worker, nmk, curproc,
+			&nmk->worker, RFNOWAIT /* to be checked */, 0, "nm-kthread-%ld",
+			nmk->worker_ctx.type);
+	if (error)
+		goto err;
+	D("started td 0x%p", nmk->worker);
+
+	error = nm_kthread_start_poll(&nmk->worker_ctx, nmk->worker_ctx.ioevent_file);
+	if (error)
+		goto err_kstop;
+	return 0;
+err_kstop:
+	kthread_suspend(nmk->worker, 0);
+err:
+	nmk->worker = NULL;
+	return error;
+}
+
+void
+nm_kthread_stop(struct nm_kthread *nmk)
+{
+	if (!nmk->worker) {
+		return;
+	}
+	nm_kthread_stop_poll(&nmk->worker_ctx);
+	kthread_suspend(nmk->worker, 100);
+	nmk->worker = NULL;
+}
+
+void
+nm_kthread_delete(struct nm_kthread *nmk)
+{
+	if (!nmk)
+		return;
+	if (nmk->worker) {
+		nm_kthread_stop(nmk);
+	}
+
+	nm_kthread_close_files(nmk);
+
+	free(nmk, M_DEVBUF);
+}
+
 /******************** kqueue support ****************/
 
 /*

Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_kern.h
==============================================================================
--- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_kern.h	Tue Jul 21 14:19:50 2015	(r288618)
+++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_kern.h	Tue Jul 21 14:21:33 2015	(r288619)
@@ -62,8 +62,8 @@
 #define WITH_PIPES
 #define WITH_MONITOR
 #define WITH_GENERIC
-//#define WITH_PTNETMAP_HOST /* ptnetmap host not supported in FreeBSD */
-#define WITH_PTNETMAP_GUEST
+#define WITH_PTNETMAP_HOST	/* ptnetmap host support */
+#define WITH_PTNETMAP_GUEST	/* ptnetmap guest support */
 
 #endif
 
@@ -1753,6 +1753,26 @@
 void nm_vi_detach(struct ifnet *);
 void nm_vi_init_index(void);
 
+/*
+ * kernel thread routines
+ */
+struct nm_kthread; /* OS-specific kthread - opaque */
+typedef void (*nm_kthread_worker_fn_t)(void *data);
+/* kthread configuration */
+struct nm_kthread_cfg {
+	long type;				/* kthread type */
+	struct nm_eventfd_cfg_ring ring;	/* ring event fd */
+	nm_kthread_worker_fn_t worker_fn;	/* worker function */
+	void *worker_private;			/* worker parameter */
+};
+/* kthread configuration */
+struct nm_kthread *nm_kthread_create(struct nm_kthread_cfg *cfg);
+int nm_kthread_start(struct nm_kthread *);
+void nm_kthread_stop(struct nm_kthread *);
+void nm_kthread_delete(struct nm_kthread *);
+void nm_kthread_wakeup_worker(struct nm_kthread *nmk);
+void nm_kthread_send_irq(struct nm_kthread *);
+void nm_kthread_set_affinity(struct nm_kthread *, int);
 
 #ifdef WITH_PTNETMAP_HOST
 /*

Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_mem2.c
==============================================================================
--- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_mem2.c	Tue Jul 21 14:19:50 2015	(r288618)
+++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_mem2.c	Tue Jul 21 14:21:33 2015	(r288619)
@@ -1764,7 +1764,7 @@
 		}
 	}
 
-        vaddr = (char *)(pv->nm_addr + nms_info->buf_pool_offset);
+        vaddr = (char *)(pv->nm_addr) + nms_info->buf_pool_offset;
 	paddr = pv->nm_paddr + nms_info->buf_pool_offset;
 
 	for (i = 0; i < nbuffers; i++) {
@@ -1901,7 +1901,7 @@
 {
 	struct netmap_mem_ptg *pv = (struct netmap_mem_ptg *)nmd;
 
-	return vaddr - pv->nm_addr;
+	return (const char *)(vaddr) - (char *)(pv->nm_addr);
 }
 
 static void
@@ -1932,7 +1932,7 @@
 	if (csb == NULL)
 		return NULL;
 
-	return (struct netmap_if *)(pv->nm_addr + csb->nifp_offset);
+	return (struct netmap_if *)((char *)(pv->nm_addr) + csb->nifp_offset);
 }
 
 static void
@@ -1961,7 +1961,7 @@
 	NMA_LOCK(na->nm_mem);
 
 	/* point each kring to the corresponding backend ring */
-	nifp = (struct netmap_if *)(pv->nm_addr + csb->nifp_offset);
+	nifp = (struct netmap_if *)((char *)pv->nm_addr + csb->nifp_offset);
 	for (i = 0; i <= na->num_tx_rings; i++) {
 		struct netmap_kring *kring = na->tx_rings + i;
 		if (kring->ring)

Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_virt.h
==============================================================================
--- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_virt.h	Tue Jul 21 14:19:50 2015	(r288618)
+++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/netmap_virt.h	Tue Jul 21 14:21:33 2015	(r288619)
@@ -179,11 +179,6 @@
 /*
  * Structures used for ptnetmap configuration
  */
-struct ptnetmap_cfg_ring {
-	uint32_t ioeventfd;
-	uint32_t irqfd;
-};
-
 /*
  * struct ptnetmap_cfg overlaps struct nmreq
  * from nr_offset field, but nr_cmd is required in netmap_ioctl()
@@ -195,8 +190,8 @@
         uint32_t features;
 #define PTNETMAP_CFG_FEAT_CSB           0x0001
 #define PTNETMAP_CFG_FEAT_EVENTFD       0x0002
-	struct ptnetmap_cfg_ring tx_ring;
-	struct ptnetmap_cfg_ring rx_ring;
+	struct nm_eventfd_cfg_ring tx_ring;
+	struct nm_eventfd_cfg_ring rx_ring;
 	uint8_t pad[2];                 /* padding to overlap strct nmreq */
 	uint16_t nr_cmd;                /* needed in netmap_ioctl() */
         void *csb;   /* CSB */
@@ -275,21 +270,6 @@
 #ifdef WITH_PTNETMAP_HOST
 /* ptnetmap kernel thread routines */
 enum ptn_kthread_t { PTK_RX = 0, PTK_TX = 1 }; /* kthread type */
-struct ptn_kthread; /* ptnetmap kthread - opaque */
-typedef void (*ptn_kthread_worker_fn_t)(void *data);
-/* ptnetmap kthread configuration */
-struct ptn_kthread_cfg {
-    enum ptn_kthread_t type;            /* kthread TX or RX */
-    struct ptnetmap_cfg_ring ring;      /* ring event fd */
-    ptn_kthread_worker_fn_t worker_fn;  /* worker function */
-    void *worker_private;               /* worker parameter */
-};
-struct ptn_kthread *ptn_kthread_create(struct ptn_kthread_cfg *);
-int ptn_kthread_start(struct ptn_kthread *);
-void ptn_kthread_stop(struct ptn_kthread *);
-void ptn_kthread_delete(struct ptn_kthread *);
-void ptn_kthread_wakeup_worker(struct ptn_kthread *ptk);
-void ptn_kthread_send_irq(struct ptn_kthread *);
 
 /* Functions to read and write CSB fields in the host */
 #if defined (linux)

Modified: soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/ptnetmap.c
==============================================================================
--- soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/ptnetmap.c	Tue Jul 21 14:19:50 2015	(r288618)
+++ soc2015/stefano/ptnetmap/stable/10/sys/dev/netmap/ptnetmap.c	Tue Jul 21 14:21:33 2015	(r288619)
@@ -1,8 +1,23 @@
 /*
  * common headers
  */
+#if defined(__FreeBSD__)
+#include <sys/cdefs.h>
+#include <sys/param.h>
+#include <sys/kernel.h>
+#include <sys/types.h>
+#include <sys/selinfo.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/if_var.h>
+#include <machine/bus.h>
 
+#define usleep_range(_1, _2)	pause("ptnetmap-sleep", _1 * hz / 1000000)
+
+#elif defined(linux)
 #include <bsd_glue.h>
+#endif
+
 #include <net/netmap.h>
 #include <dev/netmap/netmap_kern.h>
 #include <dev/netmap/netmap_virt.h>
@@ -11,9 +26,10 @@
 #ifdef WITH_PTNETMAP_HOST
 
 #define PTN_RX_NOWORK_CYCLE   10                               /* RX cycle without receive any packets */
-#define PTN_TX_BATCH_LIM      ((nkr_num_slots >> 1))     /* Limit Batch TX to half ring */
+//#define PTN_TX_BATCH_LIM      ((nkr_num_slots >> 1))     /* Limit Batch TX to half ring */
 
 #define PTN_AVOID_NM_PROLOGUE /* XXX: avoid nm_*sync_prologue() */
+#define BUSY_WAIT
 
 #define DEBUG  /* Enables communication debugging. */
 #ifdef DEBUG
@@ -113,7 +129,7 @@
 #endif /* RATE */
 
 struct ptnetmap_state {
-    struct ptn_kthread *ptk_tx, *ptk_rx;        /* kthreads pointers */
+    struct nm_kthread *ptk_tx, *ptk_rx;        /* kthreads pointers */
 
     struct ptnetmap_cfg config;                      /* rings configuration */
     struct paravirt_csb __user *csb;            /* shared page with the guest */
@@ -129,12 +145,13 @@
 static inline void
 ptnetmap_kring_dump(const char *title, const struct netmap_kring *kring)
 {
-    D("%s - name: %s hwcur: %d hwtail: %d rhead: %d rcur: %d rtail: %d head: %d cur: %d tail: %d",
+    RD(1, "%s - name: %s hwcur: %d hwtail: %d rhead: %d rcur: %d rtail: %d head: %d cur: %d tail: %d",
             title, kring->name, kring->nr_hwcur,
             kring->nr_hwtail, kring->rhead, kring->rcur, kring->rtail,
             kring->ring->head, kring->ring->cur, kring->ring->tail);
 }
 
+#if 0
 static inline void
 ptnetmap_ring_reinit(struct netmap_kring *kring, uint32_t g_head, uint32_t g_cur)
 {
@@ -148,7 +165,7 @@
     netmap_ring_reinit(kring);
     ptnetmap_kring_dump("kring reinit", kring);
 }
-
+#endif
 
 /*
  * TX functions to set/get and to handle host/guest kick.
@@ -191,7 +208,9 @@
     uint32_t g_cur, g_head, g_flags = 0; /* guest variables; init for compiler */
     uint32_t nkr_num_slots;
     bool work = false;
+#ifdef PTN_TX_BATCH_LIM
     int batch;
+#endif
     IFRATE(uint32_t pre_tail;)
 
     if (unlikely(!pts)) {
@@ -200,7 +219,7 @@
     }
 
     if (unlikely(!pts->pth_na || pts->stopped || !pts->configured)) {
-        D("backend netmap is not configured or stopped");
+        RD(1, "backend netmap is not configured or stopped");
         goto leave;
     }
 
@@ -282,13 +301,12 @@
         if (unlikely(netmap_verbose & NM_VERB_TXSYNC))
             ptnetmap_kring_dump("post txsync", kring);
 
-//#define BUSY_WAIT
 #ifndef BUSY_WAIT
         /* Send kick to the guest if it needs them */
         if (work && ptnetmap_tx_get_guestkick(csb)) {
             /* Disable guest kick to avoid sending unnecessary kicks */
             ptnetmap_tx_set_guestkick(csb, 0);
-            ptn_kthread_send_irq(pts->ptk_tx);
+            nm_kthread_send_irq(pts->ptk_tx);
             IFRATE(pts->rate_ctx.new.htxk++);
             work = false;
         }
@@ -337,7 +355,7 @@
     /* Send kick to the guest if it needs them */
     if (work && ptnetmap_tx_get_guestkick(csb)) {
         ptnetmap_tx_set_guestkick(csb, 0);
-        ptn_kthread_send_irq(pts->ptk_tx);
+        nm_kthread_send_irq(pts->ptk_tx);
         IFRATE(pts->rate_ctx.new.htxk++);
     }
 }
@@ -380,11 +398,13 @@
  *       ring is full
  *       We need to wait that the guest gets some packets from the ring and then it notifies us.
  */
+#ifndef BUSY_WAIT
 static inline int
 ptnetmap_kr_rxfull(struct netmap_kring *kring, uint32_t g_head)
 {
     return (ACCESS_ONCE(kring->nr_hwtail) == nm_prev(g_head, kring->nkr_num_slots - 1));
 }
+#endif /* !BUSY_WAIT */
 
 /* Handle RX events: from the guest or from the backend */
 static void
@@ -406,7 +426,7 @@
     }
 
     if (unlikely(!pts->pth_na || pts->stopped || !pts->configured)) {
-        D("backend netmap is not configured or stopped");
+        RD(1, "backend netmap is not configured or stopped");
         goto leave;
     }
 
@@ -479,7 +499,7 @@
         if (work && ptnetmap_rx_get_guestkick(csb)) {
             /* Disable guest kick to avoid sending unnecessary kicks */
             ptnetmap_rx_set_guestkick(csb, 0);
-            ptn_kthread_send_irq(pts->ptk_rx);
+            nm_kthread_send_irq(pts->ptk_rx);
             IFRATE(pts->rate_ctx.new.hrxk++);
             work = false;
         }
@@ -529,7 +549,7 @@
     /* Send kick to the guest if it needs them */
     if (work && ptnetmap_rx_get_guestkick(csb)) {
         ptnetmap_rx_set_guestkick(csb, 0);
-        ptn_kthread_send_irq(pts->ptk_rx);
+        nm_kthread_send_irq(pts->ptk_rx);
         IFRATE(pts->rate_ctx.new.hrxk++);
     }
 }
@@ -540,7 +560,7 @@
     if (unlikely(!pts))
         return;
     ND("TX notify");
-    ptn_kthread_wakeup_worker(pts->ptk_tx);
+    nm_kthread_wakeup_worker(pts->ptk_tx);
     IFRATE(pts->rate_ctx.new.btxwu++);
 }
 
@@ -549,7 +569,7 @@
     if (unlikely(!pts))
         return;
     ND("RX notify");
-    ptn_kthread_wakeup_worker(pts->ptk_rx);
+    nm_kthread_wakeup_worker(pts->ptk_rx);
     IFRATE(pts->rate_ctx.new.brxwu++);
 }
 
@@ -614,24 +634,24 @@
 static int
 ptnetmap_create_kthreads(struct ptnetmap_state *pts)
 {
-    struct ptn_kthread_cfg ptk_cfg;
+    struct nm_kthread_cfg nmk_cfg;
 
-    ptk_cfg.worker_private = pts;
+    nmk_cfg.worker_private = pts;
 
     /* TX kthread */
-    ptk_cfg.type = PTK_TX;
-    ptk_cfg.ring = pts->config.tx_ring;
-    ptk_cfg.worker_fn = ptnetmap_tx_handler;
-    pts->ptk_tx = ptn_kthread_create(&ptk_cfg);
+    nmk_cfg.type = PTK_TX;
+    nmk_cfg.ring = pts->config.tx_ring;
+    nmk_cfg.worker_fn = ptnetmap_tx_handler;
+    pts->ptk_tx = nm_kthread_create(&nmk_cfg);
     if (pts->ptk_tx == NULL) {
         goto err;
     }
 
     /* RX kthread */
-    ptk_cfg.type = PTK_RX;
-    ptk_cfg.ring = pts->config.rx_ring;
-    ptk_cfg.worker_fn = ptnetmap_rx_handler;
-    pts->ptk_rx = ptn_kthread_create(&ptk_cfg);
+    nmk_cfg.type = PTK_RX;
+    nmk_cfg.ring = pts->config.rx_ring;
+    nmk_cfg.worker_fn = ptnetmap_rx_handler;
+    pts->ptk_rx = nm_kthread_create(&nmk_cfg);
     if (pts->ptk_rx == NULL) {
         goto err;
     }
@@ -639,7 +659,7 @@
     return 0;
 err:
     if (pts->ptk_tx) {
-        ptn_kthread_delete(pts->ptk_tx);
+        nm_kthread_delete(pts->ptk_tx);
         pts->ptk_tx = NULL;
     }
     return EFAULT;
@@ -659,14 +679,16 @@
     pts->stopped = false;
 
     /* TX kthread */
-    error = ptn_kthread_start(pts->ptk_tx);
+    //nm_kthread_set_affinity(pts->ptk_tx, 2);
+    error = nm_kthread_start(pts->ptk_tx);
     if (error) {
         return error;
     }
     /* RX kthread */
-    error = ptn_kthread_start(pts->ptk_rx);
+    //nm_kthread_set_affinity(pts->ptk_tx, 3);
+    error = nm_kthread_start(pts->ptk_rx);
     if (error) {
-        ptn_kthread_stop(pts->ptk_tx);
+        nm_kthread_stop(pts->ptk_tx);
         return error;
     }
 
@@ -683,9 +705,9 @@
     pts->stopped = true;
 
     /* TX kthread */
-    ptn_kthread_stop(pts->ptk_tx);
+    nm_kthread_stop(pts->ptk_tx);
     /* RX kthread */
-    ptn_kthread_stop(pts->ptk_rx);
+    nm_kthread_stop(pts->ptk_rx);
 }
 
 static int nm_pt_host_notify(struct netmap_kring *, int);
@@ -796,8 +818,8 @@
     pts->configured = false;
 
     /* delete kthreads */
-    ptn_kthread_delete(pts->ptk_tx);
-    ptn_kthread_delete(pts->ptk_rx);
+    nm_kthread_delete(pts->ptk_tx);
+    nm_kthread_delete(pts->ptk_rx);
 
     IFRATE(del_timer(&pts->rate_ctx.timer));
 

Modified: soc2015/stefano/ptnetmap/stable/10/sys/modules/netmap/Makefile
==============================================================================
--- soc2015/stefano/ptnetmap/stable/10/sys/modules/netmap/Makefile	Tue Jul 21 14:19:50 2015	(r288618)
+++ soc2015/stefano/ptnetmap/stable/10/sys/modules/netmap/Makefile	Tue Jul 21 14:21:33 2015	(r288619)
@@ -10,7 +10,7 @@
 .PATH.h: ${.CURDIR}/../../net
 CFLAGS += -I${.CURDIR}/../../
 KMOD	= netmap
-SRCS	= device_if.h bus_if.h opt_netmap.h
+SRCS	= device_if.h bus_if.h pci_if.h opt_netmap.h
 SRCS	+= netmap.c netmap.h netmap_kern.h
 SRCS	+= netmap_mem2.c netmap_mem2.h
 SRCS	+= netmap_generic.c
@@ -20,7 +20,7 @@
 SRCS	+= netmap_offloadings.c
 SRCS	+= netmap_pipe.c
 SRCS	+= netmap_monitor.c
-SRCS	+= ptnetmap_freebsd.c
+SRCS	+= ptnetmap.c
 SRCS	+= opt_inet.h opt_inet6.h
 
 .include <bsd.kmod.mk>

Modified: soc2015/stefano/ptnetmap/stable/10/sys/net/netmap.h
==============================================================================
--- soc2015/stefano/ptnetmap/stable/10/sys/net/netmap.h	Tue Jul 21 14:19:50 2015	(r288618)
+++ soc2015/stefano/ptnetmap/stable/10/sys/net/netmap.h	Tue Jul 21 14:21:33 2015	(r288619)
@@ -563,4 +563,12 @@
 	char nifr_name[IFNAMSIZ];
 	char data[NM_IFRDATA_LEN];
 };
+
+/*
+ * kernel thread config
+ */
+struct nm_eventfd_cfg_ring {
+	uint32_t ioeventfd;
+	uint32_t irqfd;
+};
 #endif /* _NET_NETMAP_H_ */


More information about the svn-soc-all mailing list