summaryrefslogtreecommitdiffstats
path: root/driver/rdma.c
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2016-03-02 15:34:01 +0100
committerSuren A. Chilingaryan <csa@suren.me>2016-03-02 15:34:01 +0100
commiteb88dc19b8729fea5dc740e80f6f9d44791570fe (patch)
tree7a41161ba917f4fd858a23823846bf418c9012dd /driver/rdma.c
parent867bddcf7be374221a04b7ae89f93a5f5d703ee6 (diff)
downloadpcitool-eb88dc19b8729fea5dc740e80f6f9d44791570fe.tar.gz
pcitool-eb88dc19b8729fea5dc740e80f6f9d44791570fe.tar.bz2
pcitool-eb88dc19b8729fea5dc740e80f6f9d44791570fe.tar.xz
pcitool-eb88dc19b8729fea5dc740e80f6f9d44791570fe.zip
Resolution of the user-space BAR addresses
Diffstat (limited to 'driver/rdma.c')
-rw-r--r--driver/rdma.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/driver/rdma.c b/driver/rdma.c
index 22a4a5e..78c6d69 100644
--- a/driver/rdma.c
+++ b/driver/rdma.c
@@ -7,7 +7,12 @@
#include <linux/mm.h>
#include <linux/pagemap.h>
#include <linux/hugetlb.h>
+#include <linux/cdev.h>
+#include "config.h"
+#include "compat.h"
+#include "pciDriver.h"
+#include "common.h"
#include "rdma.h"
static unsigned long pcidriver_follow_pte(struct mm_struct *mm, unsigned long address)
@@ -42,12 +47,28 @@ static unsigned long pcidriver_follow_pte(struct mm_struct *mm, unsigned long ad
}
unsigned long pcidriver_resolve_bar(unsigned long address) {
+ int dev, bar;
unsigned long pfn;
address = (address >> PAGE_SHIFT) << PAGE_SHIFT;
pfn = pcidriver_follow_pte(current->mm, address);
- return pfn;
+ for (dev = 0; dev < MAXDEVICES; dev++)
+ {
+ pcidriver_privdata_t *privdata = pcidriver_get_privdata(dev);
+ if (!privdata) continue;
+
+ for (bar = 0; bar < 6; bar++)
+ {
+ unsigned long start = pci_resource_start(privdata->pdev, bar);
+ unsigned long end = start + pci_resource_len(privdata->pdev, bar);
+ if ((pfn >= start)&&(pfn < end))
+ return pfn;
+ }
+ pcidriver_put_privdata(privdata);
+ }
+
+ return 0;
}
EXPORT_SYMBOL(pcidriver_resolve_bar);