svn commit: r277396 - head/sys/ofed/include/linux
Hans Petter Selasky
hselasky at FreeBSD.org
Mon Jan 19 20:39:51 UTC 2015
Author: hselasky
Date: Mon Jan 19 20:39:48 2015
New Revision: 277396
URL: https://svnweb.freebsd.org/changeset/base/277396
Log:
Add more functions to the Linux kernel compatibility layer. Add some
missing includes which are needed when the header files are not
included in a particular order.
MFC after: 1 month
Sponsored by: Mellanox Technologies
Modified:
head/sys/ofed/include/linux/bitops.h
head/sys/ofed/include/linux/cache.h
head/sys/ofed/include/linux/dma-mapping.h
head/sys/ofed/include/linux/etherdevice.h
head/sys/ofed/include/linux/gfp.h
head/sys/ofed/include/linux/io.h
head/sys/ofed/include/linux/kernel.h
head/sys/ofed/include/linux/ktime.h
head/sys/ofed/include/linux/slab.h
Modified: head/sys/ofed/include/linux/bitops.h
==============================================================================
--- head/sys/ofed/include/linux/bitops.h Mon Jan 19 18:42:10 2015 (r277395)
+++ head/sys/ofed/include/linux/bitops.h Mon Jan 19 20:39:48 2015 (r277396)
@@ -288,9 +288,15 @@ bitmap_empty(unsigned long *addr, int si
#define NBLONG (NBBY * sizeof(long))
+#define __set_bit(i, a) \
+ atomic_set_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG))
+
#define set_bit(i, a) \
atomic_set_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG))
+#define __clear_bit(i, a) \
+ atomic_clear_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG))
+
#define clear_bit(i, a) \
atomic_clear_long(&((volatile long *)(a))[(i)/NBLONG], 1UL << ((i) % NBLONG))
Modified: head/sys/ofed/include/linux/cache.h
==============================================================================
--- head/sys/ofed/include/linux/cache.h Mon Jan 19 18:42:10 2015 (r277395)
+++ head/sys/ofed/include/linux/cache.h Mon Jan 19 20:39:48 2015 (r277396)
@@ -30,8 +30,7 @@
#ifndef _LINUX_CACHE_H_
#define _LINUX_CACHE_H_
-
#define cache_line_size() CACHE_LINE_SIZE
-
+#define L1_CACHE_BYTES CACHE_LINE_SIZE
#endif /* _LINUX_CACHE_H_ */
Modified: head/sys/ofed/include/linux/dma-mapping.h
==============================================================================
--- head/sys/ofed/include/linux/dma-mapping.h Mon Jan 19 18:42:10 2015 (r277395)
+++ head/sys/ofed/include/linux/dma-mapping.h Mon Jan 19 20:39:48 2015 (r277396)
@@ -139,6 +139,14 @@ dma_alloc_coherent(struct device *dev, s
*dma_handle = 0;
return (mem);
}
+
+static inline void *
+dma_zalloc_coherent(struct device *dev, size_t size, dma_addr_t *dma_handle,
+ gfp_t flag)
+{
+
+ return (dma_alloc_coherent(dev, size, dma_handle, flag | __GFP_ZERO));
+}
static inline void
dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
Modified: head/sys/ofed/include/linux/etherdevice.h
==============================================================================
--- head/sys/ofed/include/linux/etherdevice.h Mon Jan 19 18:42:10 2015 (r277395)
+++ head/sys/ofed/include/linux/etherdevice.h Mon Jan 19 20:39:48 2015 (r277396)
@@ -89,6 +89,9 @@ static inline bool is_valid_ether_addr(c
return !is_multicast_ether_addr(addr) && !is_zero_ether_addr(addr);
}
-
+static inline void ether_addr_copy(u8 *dst, const u8 *src)
+{
+ memcpy(dst, src, 6);
+}
#endif /* _LINUX_ETHERDEVICE */
Modified: head/sys/ofed/include/linux/gfp.h
==============================================================================
--- head/sys/ofed/include/linux/gfp.h Mon Jan 19 18:42:10 2015 (r277395)
+++ head/sys/ofed/include/linux/gfp.h Mon Jan 19 20:39:48 2015 (r277396)
@@ -30,6 +30,8 @@
#ifndef _LINUX_GFP_H_
#define _LINUX_GFP_H_
+#include <sys/cdefs.h>
+#include <sys/types.h>
#include <sys/systm.h>
#include <sys/malloc.h>
Modified: head/sys/ofed/include/linux/io.h
==============================================================================
--- head/sys/ofed/include/linux/io.h Mon Jan 19 18:42:10 2015 (r277395)
+++ head/sys/ofed/include/linux/io.h Mon Jan 19 20:39:48 2015 (r277396)
@@ -31,6 +31,7 @@
#define _LINUX_IO_H_
#include <machine/vm.h>
+#include <sys/endian.h>
static inline uint32_t
__raw_readl(const volatile void *addr)
@@ -89,6 +90,20 @@ writew(uint16_t b, void *addr)
*(volatile uint16_t *)addr = b;
}
+#undef ioread32be
+static inline uint32_t
+ioread32be(const volatile void *addr)
+{
+ return be32toh(*(const volatile uint32_t *)addr);
+}
+
+#undef iowrite32be
+static inline void
+iowrite32be(uint32_t v, volatile void *addr)
+{
+ *(volatile uint32_t *)addr = htobe32(v);
+}
+
void *_ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr);
#define ioremap_nocache(addr, size) \
_ioremap_attr((addr), (size), VM_MEMATTR_UNCACHEABLE)
Modified: head/sys/ofed/include/linux/kernel.h
==============================================================================
--- head/sys/ofed/include/linux/kernel.h Mon Jan 19 18:42:10 2015 (r277395)
+++ head/sys/ofed/include/linux/kernel.h Mon Jan 19 20:39:48 2015 (r277396)
@@ -29,6 +29,8 @@
#ifndef _LINUX_KERNEL_H_
#define _LINUX_KERNEL_H_
+#include <sys/cdefs.h>
+#include <sys/types.h>
#include <sys/systm.h>
#include <sys/param.h>
#include <sys/libkern.h>
@@ -57,6 +59,8 @@
#define KERN_INFO "<6>"
#define KERN_DEBUG "<7>"
+#define BUILD_BUG_ON(x) CTASSERT(x)
+
#define BUG() panic("BUG")
#define BUG_ON(condition) do { if (condition) BUG(); } while(0)
#define WARN_ON BUG_ON
@@ -84,6 +88,7 @@
#endif
#define udelay(t) DELAY(t)
+#define usleep_range(min,max) DELAY(min)
#ifndef pr_fmt
#define pr_fmt(fmt) fmt
Modified: head/sys/ofed/include/linux/ktime.h
==============================================================================
--- head/sys/ofed/include/linux/ktime.h Mon Jan 19 18:42:10 2015 (r277395)
+++ head/sys/ofed/include/linux/ktime.h Mon Jan 19 20:39:48 2015 (r277396)
@@ -288,4 +288,13 @@ static inline s64 ktime_to_ns(const ktim
#endif /* !((BITS_PER_LONG == 64) || defined(CONFIG_KTIME_SCALAR)) */
+static inline s64 ktime_get_ns(void)
+{
+ struct timespec ts;
+ ktime_t kt;
+ ktime_get_ts(&ts);
+ kt = timespec_to_ktime(ts);
+ return (ktime_to_ns(kt));
+}
+
#endif /* _LINUX_KTIME_H */
Modified: head/sys/ofed/include/linux/slab.h
==============================================================================
--- head/sys/ofed/include/linux/slab.h Mon Jan 19 18:42:10 2015 (r277395)
+++ head/sys/ofed/include/linux/slab.h Mon Jan 19 20:39:48 2015 (r277396)
@@ -40,6 +40,7 @@
MALLOC_DECLARE(M_KMALLOC);
#define kmalloc(size, flags) malloc((size), M_KMALLOC, (flags))
+#define kvmalloc(size) kmalloc((size), 0)
#define kzalloc(size, flags) kmalloc((size), (flags) | M_ZERO)
#define kzalloc_node(size, flags, node) kzalloc(size, flags)
#define kfree(ptr) free(__DECONST(void *, (ptr)), M_KMALLOC)
@@ -47,6 +48,7 @@ MALLOC_DECLARE(M_KMALLOC);
#define kcalloc(n, size, flags) kmalloc((n) * (size), flags | M_ZERO)
#define vzalloc(size) kzalloc(size, GFP_KERNEL | __GFP_NOWARN)
#define vfree(arg) kfree(arg)
+#define kvfree(arg) kfree(arg)
#define vmalloc(size) kmalloc(size, GFP_KERNEL)
#define vmalloc_node(size, node) kmalloc(size, GFP_KERNEL)
More information about the svn-src-head
mailing list