Module Name:src
Committed By: jdolecek
Date: Sat May 19 08:59:38 UTC 2018
Modified Files:
src/sys/external/bsd/ena-com: ena_plat.h
Log Message:
adapt for NetBSD
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/sys/external/bsd/ena-com/ena_plat.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/external/bsd/ena-com/ena_plat.h
diff -u src/sys/external/bsd/ena-com/ena_plat.h:1.1.1.1 src/sys/external/bsd/ena-com/ena_plat.h:1.2
--- src/sys/external/bsd/ena-com/ena_plat.h:1.1.1.1 Sat May 19 08:56:06 2018
+++ src/sys/external/bsd/ena-com/ena_plat.h Sat May 19 08:59:38 2018
@@ -35,7 +35,10 @@
#define ENA_PLAT_H_
#include
+#if 0
__FBSDID("$FreeBSD: head/sys/contrib/ena-com/ena_plat.h 333453 2018-05-10 09:25:51Z mw $");
+#endif
+__KERNEL_RCSID(0, "$NetBSD: ena_plat.h,v 1.2 2018/05/19 08:59:38 jdolecek Exp $");
#include
#include
@@ -48,45 +51,29 @@ __FBSDID("$FreeBSD: head/sys/contrib/ena
#include
#include
#include
-#include
#include
-#include
#include
#include
#include
-#include
-#include
#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-#include
+#include
+#include
-#include
-#include
#include
-#include
-#include
#include
#include
+#include
-#include
-#include
+#include
+
+#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
+#include /* XXX for struct ip */
+#include /* XXX for struct ip */
+#include /* XXX for struct ip */
+#include /* XXX for struct ip6_hdr */
+#include /* XXX for struct tcphdr */
-#include
#include
#include
@@ -114,8 +101,8 @@ extern int ena_log_level;
} while (0)
#define ena_trace(level, fmt, args...)\
- ena_trace_raw(level, "%s() [TID:%d]: " \
- fmt " \n", __func__, curthread->td_tid, ##args)
+ ena_trace_raw(level, "%s() [LID:%d]: " \
+ fmt " \n", __func__, curlwp->l_lid, ##args)
#define ena_trc_dbg(format, arg...) ena_trace(ENA_DBG, format, ##arg)
@@ -184,11 +171,11 @@ static inline long PTR_ERR(const void *p
#define ENA_COM_PERMISSION EPERM
#define ENA_COM_TIMER_EXPIRED ETIMEDOUT
-#define ENA_MSLEEP(x) pause_sbt("ena", SBT_1MS * (x), SBT_1MS, 0)
+#define ENA_MSLEEP(x) kpause("enaw", false, mstohz(x), NULL)
#define ENA_UDELAY(x) DELAY(x)
#define ENA_GET_SYSTEM_TIMEOUT(timeout_us) \
-((long)cputick2usec(cpu_ticks()) + (timeout_us))
-#define ENA_TIME_EXPIRE(timeout) ((timeout) < (long)cputick2usec(cpu_ticks()))
+ mstohz(timeout_us * (1000 / 100)) /* XXX assumes 100 ms sleep */
+#define ENA_TIME_EXPIRE(timeout) ((timeout)-- <= 0)
#define ENA_MIGHT_SLEEP()
#define min_t(type, _x, _y) ((type)(_x) < (type)(_y) ? (type)(_x) : (type)(_y))
@@ -203,52 +190,51 @@ static inline long PTR_ERR(const void *p
#define ENA_MAX8(x,y) MAX(x, y)
/* Spinlock related methods */
-#define ena_spinlock_t struct mtx
+#define ena_spinlock_t kmutex_t
#define ENA_SPINLOCK_INIT(spinlock)\
- mtx_init(&(spinlock), "ena_spin", NULL, MTX_SPIN)
+ mutex_init(&(spinlock), MUTEX_DEFAULT, IPL_NET)
#define ENA_SPINLOCK_DESTROY(spinlock)\
do { \
- if (mtx_initialized(&(spinlock))) \
- mtx_destroy(&(spinlock)); \
+ mutex_destroy(&(spinlock)); \
} while (0)
#define ENA_SPINLOCK_LOCK(spinlock, flags) \
do { \
(void)(flags); \
- mtx_lock_spin(&(spinlock)); \
+ mutex_enter(&(spinlock)); \
} while (0)
#define ENA_SPINLOCK_UNLOCK(spinlock, flags) \
do { \
(void)(flags); \
- mtx_unlock_spin(&(spinlock)); \
+ mutex_exit(&(spinlock)); \
} while (0)
/* Wait queue related methods */
-#define ena_wait_event_t struct { struct cv wq; struct mtx mtx; }
+#define ena_wait_event_t struct { kcondvar_t wq; kmutex_t mtx; }
#define ENA_WAIT_EVENT_INIT(waitqueue) \
do {\
- cv_init(&((waitqueue).wq), "cv"); \
- mtx_init(&((waitqueue).mtx), "wq", NULL, MTX_DEF); \
+ cv_init(&((waitqueue).wq), "enacv"); \
+ mutex_init(&((waitqueue).mtx), MUTEX_DEFAULT, IPL_NET); \
} while (0)
#define ENA_WAIT_EVENT_DESTROY(waitqueue)\
do {\
cv_destroy(&((waitqueue).wq));\
- mtx_destroy(&((waitqueue).mtx)); \
+ mutex_destroy(&((waitqueue).mtx)); \
} while (0)
#define ENA_WAIT_EVENT_CLEAR(waitqueue) \
- cv_init(&((waitqueue).wq), (waitqueue).wq.cv_description)
+ cv_init(&((waitqueue).wq), "enacv")
#define ENA_WAIT_EVENT_WAIT(waitqueue, timeout_us) \
do {\
- mtx_lock(&((waitqueue).mtx));\
+ mutex_enter(&((waitqueue).mtx)); \
cv_timedwait(&((waitqueue).wq), &((waitqueue).mtx), \
timeout_us * hz / 1000 / 1000 ); \
- mtx_unlock(&((waitqueue).mtx));\
+ mutex_exit(&((waitqueue).mtx));\
} while (0)
#define ENA_WAIT_EVENT_SIGNAL(waitqueue) \
do { \
- mtx_lock(&((waitqueue).mtx)); \
+ mutex_enter(&((waitqueue).mtx)); \
cv_broadcast(&((waitqu