Author: luigi
Date: Tue Nov 11 00:13:28 2014
New Revision: 274362
URL: https://svnweb.freebsd.org/changeset/base/274362

Log:
  in the Linux section, properly define the NMG_LOCK type.
  Also import WITH_GENERIC in preparation to adding fine-grained
  options to disable specific netmap components.

Modified:
  head/sys/dev/netmap/netmap_kern.h

Modified: head/sys/dev/netmap/netmap_kern.h
==============================================================================
--- head/sys/dev/netmap/netmap_kern.h   Tue Nov 11 00:10:44 2014        
(r274361)
+++ head/sys/dev/netmap/netmap_kern.h   Tue Nov 11 00:13:28 2014        
(r274362)
@@ -37,6 +37,7 @@
 #define WITH_VALE      // comment out to disable VALE support
 #define WITH_PIPES
 #define WITH_MONITOR
+#define WITH_GENERIC
 
 #if defined(__FreeBSD__)
 
@@ -44,6 +45,8 @@
 #define unlikely(x)    __builtin_expect((long)!!(x), 0L)
 
 #define        NM_LOCK_T       struct mtx
+
+/* netmap global lock */
 #define        NMG_LOCK_T      struct sx
 #define NMG_LOCK_INIT()        sx_init(&netmap_global_lock, \
                                "netmap global lock")
@@ -107,13 +110,20 @@ struct hrtimer {
 
 #define NM_ATOMIC_T    volatile long unsigned int
 
-// XXX a mtx would suffice here too 20130404 gl
-#define NMG_LOCK_T             struct semaphore
-#define NMG_LOCK_INIT()                sema_init(&netmap_global_lock, 1)
-#define NMG_LOCK_DESTROY()
-#define NMG_LOCK()             down(&netmap_global_lock)
-#define NMG_UNLOCK()           up(&netmap_global_lock)
-#define NMG_LOCK_ASSERT()      //      XXX to be completed
+#define NM_MTX_T               struct mutex
+#define NM_MTX_INIT(m, s)      do { (void)s; mutex_init(&(m)); } while (0)
+#define NM_MTX_DESTROY(m)      do { (void)m; } while (0)
+#define NM_MTX_LOCK(m)         mutex_lock(&(m))
+#define NM_MTX_UNLOCK(m)       mutex_unlock(&(m))
+#define NM_MTX_LOCK_ASSERT(m)  mutex_is_locked(&(m))
+
+#define        NMG_LOCK_T              NM_MTX_T
+#define        NMG_LOCK_INIT()         NM_MTX_INIT(netmap_global_lock, \
+                                       "netmap_global_lock")
+#define        NMG_LOCK_DESTROY()      NM_MTX_DESTROY(netmap_global_lock)
+#define        NMG_LOCK()              NM_MTX_LOCK(netmap_global_lock)
+#define        NMG_UNLOCK()            NM_MTX_UNLOCK(netmap_global_lock)
+#define        NMG_LOCK_ASSERT()       NM_MTX_LOCK_ASSERT(netmap_global_lock)
 
 #ifndef DEV_NETMAP
 #define DEV_NETMAP
@@ -641,6 +651,7 @@ struct netmap_hw_adapter {  /* physical d
        int (*nm_hw_register)(struct netmap_adapter *, int onoff);
 };
 
+#ifdef WITH_GENERIC
 /* Mitigation support. */
 struct nm_generic_mit {
        struct hrtimer mit_timer;
@@ -668,6 +679,7 @@ struct netmap_generic_adapter {     /* emula
         netdev_tx_t (*save_start_xmit)(struct mbuf *, struct ifnet *);
 #endif
 };
+#endif  /* WITH_GENERIC */
 
 static __inline int
 netmap_real_tx_rings(struct netmap_adapter *na)
@@ -1481,6 +1493,7 @@ struct netmap_monitor_adapter {
 #endif /* WITH_MONITOR */
 
 
+#ifdef WITH_GENERIC
 /*
  * generic netmap emulation for devices that do not have
  * native netmap support.
@@ -1512,6 +1525,7 @@ void netmap_mitigation_start(struct nm_g
 void netmap_mitigation_restart(struct nm_generic_mit *mit);
 int netmap_mitigation_active(struct nm_generic_mit *mit);
 void netmap_mitigation_cleanup(struct nm_generic_mit *mit);
+#endif /* WITH_GENERIC */
 
 
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to