summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/ofed/include/linux/gfp.h17
-rw-r--r--sys/ofed/include/linux/kernel.h2
-rw-r--r--sys/ofed/include/linux/kref.h1
-rw-r--r--sys/ofed/include/linux/pci.h32
4 files changed, 52 insertions, 0 deletions
diff --git a/sys/ofed/include/linux/gfp.h b/sys/ofed/include/linux/gfp.h
index 3e77302..cb43104 100644
--- a/sys/ofed/include/linux/gfp.h
+++ b/sys/ofed/include/linux/gfp.h
@@ -105,6 +105,13 @@ __free_pages(struct page *m, unsigned int order)
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 order)
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)
diff --git a/sys/ofed/include/linux/kernel.h b/sys/ofed/include/linux/kernel.h
index 5d4e50b..2f665c6 100644
--- a/sys/ofed/include/linux/kernel.h
+++ b/sys/ofed/include/linux/kernel.h
@@ -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;
diff --git a/sys/ofed/include/linux/kref.h b/sys/ofed/include/linux/kref.h
index ee94cd0..883e1a1 100644
--- a/sys/ofed/include/linux/kref.h
+++ b/sys/ofed/include/linux/kref.h
@@ -29,6 +29,7 @@
#ifndef _LINUX_KREF_H_
#define _LINUX_KREF_H_
+#include <sys/types.h>
#include <sys/refcount.h>
struct kref {
diff --git a/sys/ofed/include/linux/pci.h b/sys/ofed/include/linux/pci.h
index e6b9023..60e1d02 100644
--- a/sys/ofed/include/linux/pci.h
+++ b/sys/ofed/include/linux/pci.h
@@ -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, struct msix_entry *entries, int nreq)
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;
OpenPOWER on IntegriCloud