Date: Fri, 13 Feb 2015 16:35:12 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r278681 - head/sys/ofed/include/linux Message-ID: <201502131635.t1DGZCUD063215@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: hselasky Date: Fri Feb 13 16:35:12 2015 New Revision: 278681 URL: https://svnweb.freebsd.org/changeset/base/278681 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/gfp.h head/sys/ofed/include/linux/kernel.h head/sys/ofed/include/linux/kref.h head/sys/ofed/include/linux/pci.h Modified: head/sys/ofed/include/linux/gfp.h ============================================================================== --- head/sys/ofed/include/linux/gfp.h Fri Feb 13 16:21:36 2015 (r278680) +++ head/sys/ofed/include/linux/gfp.h Fri Feb 13 16:35:12 2015 (r278681) @@ -105,6 +105,13 @@ __free_pages(struct page *m, unsigned in kmem_free(kmem_arena, (vm_offset_t)page_address(m), size); } +static inline void free_pages(uintptr_t addr, unsigned int order) +{ + if (addr == 0) + return; + __free_pages(virt_to_page((void *)addr), order); +} + /* * Alloc pages allocates directly from the buddy allocator on linux so * order specifies a power of two bucket of pages and the results @@ -124,6 +131,16 @@ alloc_pages(gfp_t gfp_mask, unsigned int return (virt_to_page(page)); } +static inline uintptr_t __get_free_pages(gfp_t gfp_mask, unsigned int order) +{ + struct page *page; + + page = alloc_pages(gfp_mask, order); + if (page == NULL) + return (0); + return ((uintptr_t)page_address(page)); +} + #define alloc_pages_node(node, mask, order) alloc_pages(mask, order) #define kmalloc_node(chunk, mask, node) kmalloc(chunk, mask) Modified: head/sys/ofed/include/linux/kernel.h ============================================================================== --- head/sys/ofed/include/linux/kernel.h Fri Feb 13 16:21:36 2015 (r278680) +++ head/sys/ofed/include/linux/kernel.h Fri Feb 13 16:35:12 2015 (r278681) @@ -68,6 +68,7 @@ #undef ALIGN #define ALIGN(x, y) roundup2((x), (y)) #define DIV_ROUND_UP howmany +#define FIELD_SIZEOF(t, f) sizeof(((t *)0)->f) #define printk(X...) printf(X) @@ -175,6 +176,7 @@ #define round_down(x, y) ((x) & ~__round_mask(x, y)) #define num_possible_cpus() mp_ncpus +#define num_online_cpus() mp_ncpus typedef struct pm_message { int event; Modified: head/sys/ofed/include/linux/kref.h ============================================================================== --- head/sys/ofed/include/linux/kref.h Fri Feb 13 16:21:36 2015 (r278680) +++ head/sys/ofed/include/linux/kref.h Fri Feb 13 16:35:12 2015 (r278681) @@ -29,6 +29,7 @@ #ifndef _LINUX_KREF_H_ #define _LINUX_KREF_H_ +#include <sys/types.h> #include <sys/refcount.h> struct kref { Modified: head/sys/ofed/include/linux/pci.h ============================================================================== --- head/sys/ofed/include/linux/pci.h Fri Feb 13 16:21:36 2015 (r278680) +++ head/sys/ofed/include/linux/pci.h Fri Feb 13 16:35:12 2015 (r278681) @@ -270,6 +270,14 @@ pci_set_master(struct pci_dev *pdev) } static inline int +pci_clear_master(struct pci_dev *pdev) +{ + + pci_disable_busmaster(pdev->dev.bsddev); + return (0); +} + +static inline int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name) { int rid; @@ -458,6 +466,30 @@ pci_enable_msix(struct pci_dev *pdev, st return (0); } +#define pci_enable_msix_range linux_pci_enable_msix_range +static inline int +pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, + int minvec, int maxvec) +{ + int nvec = maxvec; + int rc; + + if (maxvec < minvec) + return (-ERANGE); + + do { + rc = pci_enable_msix(dev, entries, nvec); + if (rc < 0) { + return (rc); + } else if (rc > 0) { + if (rc < minvec) + return (-ENOSPC); + nvec = rc; + } + } while (rc); + return (nvec); +} + static inline int pci_channel_offline(struct pci_dev *pdev) { return false;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502131635.t1DGZCUD063215>