From owner-svn-src-all@FreeBSD.ORG Mon Jan 19 20:39:51 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A33A34F8; Mon, 19 Jan 2015 20:39:51 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 8E76B650; Mon, 19 Jan 2015 20:39:51 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t0JKdpCx033582; Mon, 19 Jan 2015 20:39:51 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t0JKdnYG033571; Mon, 19 Jan 2015 20:39:49 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201501192039.t0JKdnYG033571@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Mon, 19 Jan 2015 20:39:49 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r277396 - head/sys/ofed/include/linux X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 Jan 2015 20:39:51 -0000 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 +#include #include #include 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 +#include 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 +#include #include #include #include @@ -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)