svn commit: r211258 - in projects/ofed/head/sys/ofed/drivers:
infiniband/core infiniband/hw/mlx4 infiniband/hw/mthca
infiniband/ulp/sdp infiniband/ulp/srpt net/mlx4
Jeff Roberson
jeff at FreeBSD.org
Fri Aug 13 03:08:39 UTC 2010
Author: jeff
Date: Fri Aug 13 03:08:38 2010
New Revision: 211258
URL: http://svn.freebsd.org/changeset/base/211258
Log:
Commit changes to the linux code to work with the wrapper layer.
- Define our own umem.
- iounmap becomes pmap_unmapdev and requires a size argument. We cannot
determine the size from the address and must track it seperately.
- Some ipoib related address code is #ifdef'd
- Some minor changes required for things not statically known at compile
time on BSD such as HZ and ilog2 results.
Sponsored by: Isilon Systems, iX Systems, and Panasas.
Modified:
projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/cm.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/cma.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/device.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/notice.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/sa_query.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/sysfs.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/ucm.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/ucma.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/user_mad.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs.h
projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_cmd.c
projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_main.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/mlx4_ib.h
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/mr.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/qp.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/srq.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/wc.h
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_av.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_catas.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_cmd.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_dev.h
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_eq.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_main.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_memfree.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_mr.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_provider.c
projects/ofed/head/sys/ofed/drivers/infiniband/hw/mthca/mthca_reset.c
projects/ofed/head/sys/ofed/drivers/infiniband/ulp/sdp/sdp_main.c
projects/ofed/head/sys/ofed/drivers/infiniband/ulp/srpt/ib_srpt.c
projects/ofed/head/sys/ofed/drivers/net/mlx4/alloc.c
projects/ofed/head/sys/ofed/drivers/net/mlx4/catas.c
projects/ofed/head/sys/ofed/drivers/net/mlx4/cmd.c
projects/ofed/head/sys/ofed/drivers/net/mlx4/en_resources.c
projects/ofed/head/sys/ofed/drivers/net/mlx4/eq.c
projects/ofed/head/sys/ofed/drivers/net/mlx4/fw.h
projects/ofed/head/sys/ofed/drivers/net/mlx4/icm.h
projects/ofed/head/sys/ofed/drivers/net/mlx4/main.c
projects/ofed/head/sys/ofed/drivers/net/mlx4/mlx4.h
projects/ofed/head/sys/ofed/drivers/net/mlx4/mr.c
projects/ofed/head/sys/ofed/drivers/net/mlx4/reset.c
projects/ofed/head/sys/ofed/drivers/net/mlx4/srq.c
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/addr.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -65,7 +65,7 @@ static void process_req(struct work_stru
static DEFINE_MUTEX(lock);
static LIST_HEAD(req_list);
-static DECLARE_DELAYED_WORK(work, process_req);
+static struct delayed_work work;
static struct workqueue_struct *addr_wq;
void rdma_addr_register_client(struct rdma_addr_client *client)
@@ -88,6 +88,7 @@ void rdma_addr_unregister_client(struct
}
EXPORT_SYMBOL(rdma_addr_unregister_client);
+#ifdef __linux__
int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
const unsigned char *dst_dev_addr)
{
@@ -99,6 +100,20 @@ int rdma_copy_addr(struct rdma_dev_addr
dev_addr->bound_dev_if = dev->ifindex;
return 0;
}
+#else
+int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct ifnet *dev,
+ const unsigned char *dst_dev_addr)
+{
+ dev_addr->dev_type = dev->if_type;
+ memcpy(dev_addr->src_dev_addr, IF_LLADDR(dev), MAX_ADDR_LEN);
+ memcpy(dev_addr->broadcast, __DECONST(char *, dev->if_broadcastaddr),
+ MAX_ADDR_LEN);
+ if (dst_dev_addr)
+ memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN);
+ dev_addr->bound_dev_if = dev->if_index;
+ return 0;
+}
+#endif
EXPORT_SYMBOL(rdma_copy_addr);
int rdma_translate_ip(struct sockaddr *addr, struct rdma_dev_addr *dev_addr)
@@ -176,6 +191,7 @@ static void queue_req(struct addr_req *r
mutex_unlock(&lock);
}
+#ifdef __linux__
static int addr4_resolve(struct sockaddr_in *src_in,
struct sockaddr_in *dst_in,
struct rdma_dev_addr *addr)
@@ -293,6 +309,23 @@ static int addr6_resolve(struct sockaddr
}
#endif
+#else
+
+static int addr6_resolve(struct sockaddr_in6 *src_in,
+ struct sockaddr_in6 *dst_in,
+ struct rdma_dev_addr *addr)
+{
+ return -EADDRNOTAVAIL;
+}
+
+static int addr4_resolve(struct sockaddr_in *src_in,
+ struct sockaddr_in *dst_in,
+ struct rdma_dev_addr *addr)
+{
+ /* XXX This will have to be filled in after ipoib is functional. */
+ return -EADDRNOTAVAIL;
+}
+
static int addr_resolve(struct sockaddr *src_in,
struct sockaddr *dst_in,
struct rdma_dev_addr *addr)
@@ -305,6 +338,8 @@ static int addr_resolve(struct sockaddr
(struct sockaddr_in6 *) dst_in, addr);
}
+#endif
+
static void process_req(struct work_struct *work)
{
struct addr_req *req, *temp_req;
@@ -418,6 +453,7 @@ void rdma_addr_cancel(struct rdma_dev_ad
}
EXPORT_SYMBOL(rdma_addr_cancel);
+#ifdef __linux__
static int netevent_callback(struct notifier_block *self, unsigned long event,
void *ctx)
{
@@ -434,20 +470,26 @@ static int netevent_callback(struct noti
static struct notifier_block nb = {
.notifier_call = netevent_callback
};
+#endif
static int addr_init(void)
{
+ INIT_DELAYED_WORK(&work, process_req);
addr_wq = create_singlethread_workqueue("ib_addr");
if (!addr_wq)
return -ENOMEM;
+#ifdef __linux__
register_netevent_notifier(&nb);
+#endif
return 0;
}
static void addr_cleanup(void)
{
+#ifdef __linux__
unregister_netevent_notifier(&nb);
+#endif
destroy_workqueue(addr_wq);
}
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/cm.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/cm.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/cm.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -3890,6 +3890,6 @@ static void __exit ib_cm_cleanup(void)
idr_destroy(&cm.local_id_table);
}
-module_init(ib_cm_init);
+module_init_order(ib_cm_init, SI_ORDER_SECOND);
module_exit(ib_cm_cleanup);
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/cma.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/cma.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/cma.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -1679,6 +1679,7 @@ out:
kfree(work);
}
+#ifdef __linux__
static void cma_ndev_work_handler(struct work_struct *_work)
{
struct cma_ndev_work *work = container_of(_work, struct cma_ndev_work, work);
@@ -1702,6 +1703,7 @@ out:
rdma_destroy_id(&id_priv->id);
kfree(work);
}
+#endif
static int cma_resolve_ib_route(struct rdma_id_private *id_priv, int timeout_ms)
{
@@ -1833,7 +1835,11 @@ static int cma_resolve_iboe_route(struct
route->path_rec->mtu_selector = IB_SA_EQ;
route->path_rec->sl = tos_to_sl(id_priv->tos);
+#ifdef __linux__
route->path_rec->mtu = iboe_get_mtu(ndev->mtu);
+#else
+ route->path_rec->mtu = iboe_get_mtu(ndev->if_mtu);
+#endif
route->path_rec->rate_selector = IB_SA_EQ;
route->path_rec->rate = iboe_get_rate(ndev);
dev_put(ndev);
@@ -2184,8 +2190,10 @@ static int cma_use_port(struct idr *ps,
sin = (struct sockaddr_in *) &id_priv->id.route.addr.src_addr;
snum = ntohs(sin->sin_port);
+#ifdef __linux__
if (snum < PROT_SOCK && !capable(CAP_NET_BIND_SERVICE))
return -EACCES;
+#endif
bind_list = idr_find(ps, snum);
if (!bind_list)
@@ -2220,15 +2228,21 @@ static int cma_get_tcp_port(struct rdma_
ret = sock_create_kern(AF_INET, SOCK_STREAM, IPPROTO_TCP, &sock);
if (ret)
return ret;
+#ifdef __linux__
ret = sock->ops->bind(sock,
(struct sockaddr *) &id_priv->id.route.addr.src_addr,
ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr));
+#else
+ ret = -sobind(sock,
+ (struct sockaddr *)&id_priv->id.route.addr.src_addr,
+ curthread);
+#endif
if (ret) {
sock_release(sock);
return ret;
}
size = ip_addr_size((struct sockaddr *) &id_priv->id.route.addr.src_addr);
- ret = sock->ops->getname(sock,
+ ret = sock_getname(sock,
(struct sockaddr *) &id_priv->id.route.addr.src_addr,
&size, 0);
if (ret) {
@@ -3046,7 +3060,11 @@ static int cma_iboe_join_multicast(struc
mc->multicast.ib->rec.rate = iboe_get_rate(ndev);
mc->multicast.ib->rec.hop_limit = 1;
+#ifdef __linux__
mc->multicast.ib->rec.mtu = iboe_get_mtu(ndev->mtu);
+#else
+ mc->multicast.ib->rec.mtu = iboe_get_mtu(ndev->if_mtu);
+#endif
dev_put(ndev);
if (!mc->multicast.ib->rec.mtu) {
err = -EINVAL;
@@ -3158,6 +3176,7 @@ void rdma_leave_multicast(struct rdma_cm
}
EXPORT_SYMBOL(rdma_leave_multicast);
+#ifdef __linux__
static int cma_netdev_change(struct net_device *ndev, struct rdma_id_private *id_priv)
{
struct rdma_dev_addr *dev_addr;
@@ -3216,6 +3235,7 @@ out:
static struct notifier_block cma_nb = {
.notifier_call = cma_netdev_callback
};
+#endif
static void cma_add_one(struct ib_device *device)
{
@@ -3325,7 +3345,9 @@ static int cma_init(void)
ib_sa_register_client(&sa_client);
rdma_addr_register_client(&addr_client);
+#ifdef __linux__
register_netdevice_notifier(&cma_nb);
+#endif
ret = ib_register_client(&cma_client);
if (ret)
@@ -3333,7 +3355,9 @@ static int cma_init(void)
return 0;
err:
+#ifdef __linux__
unregister_netdevice_notifier(&cma_nb);
+#endif
rdma_addr_unregister_client(&addr_client);
ib_sa_unregister_client(&sa_client);
destroy_workqueue(cma_wq);
@@ -3343,7 +3367,9 @@ err:
static void cma_cleanup(void)
{
ib_unregister_client(&cma_client);
+#ifdef __linux__
unregister_netdevice_notifier(&cma_nb);
+#endif
rdma_addr_unregister_client(&addr_client);
ib_sa_unregister_client(&sa_client);
destroy_workqueue(cma_wq);
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/device.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/device.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/device.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -100,7 +100,7 @@ static int ib_device_check_mandatory(str
int i;
for (i = 0; i < ARRAY_SIZE(mandatory_table); ++i) {
- if (!*(void **) ((void *) device + mandatory_table[i].offset)) {
+ if (!*(void **) ((u_char *) device + mandatory_table[i].offset)) {
printk(KERN_WARNING "Device %s is missing mandatory function %s\n",
device->name, mandatory_table[i].name);
return -EINVAL;
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/notice.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/notice.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/notice.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -669,7 +669,7 @@ static void inform_add_one(struct ib_dev
if (rdma_node_get_transport(device->node_type) != RDMA_TRANSPORT_IB)
return;
- dev = kmalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
+ dev = kzalloc(sizeof *dev + device->phys_port_cnt * sizeof *port,
GFP_KERNEL);
if (!dev)
return;
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/sa_query.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/sa_query.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/sa_query.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -1474,5 +1474,5 @@ static void __exit ib_sa_cleanup(void)
idr_destroy(&query_idr);
}
-module_init(ib_sa_init);
+module_init_order(ib_sa_init, SI_ORDER_SECOND);
module_exit(ib_sa_cleanup);
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/sysfs.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/sysfs.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/sysfs.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -265,12 +265,15 @@ static ssize_t show_port_gid(struct ib_p
container_of(attr, struct port_table_attribute, attr);
union ib_gid gid;
ssize_t ret;
+ u16 *raw;
ret = ib_query_gid(p->ibdev, p->port_num, tab_attr->index, &gid);
if (ret)
return ret;
- return sprintf(buf, "%pI6\n", gid.raw);
+ raw = (u16 *)gid.raw;
+ return sprintf(buf, "%.4x:%.4x:%.4x:%.4x:%.4x:%.4x:%.4x:%.4x\n",
+ raw[0], raw[1], raw[2], raw[3], raw[4], raw[5], raw[6], raw[7]);
}
static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr,
@@ -439,6 +442,7 @@ static void ib_device_release(struct dev
kfree(dev);
}
+#ifdef __linux__
static int ib_device_uevent(struct device *device,
struct kobj_uevent_env *env)
{
@@ -453,6 +457,7 @@ static int ib_device_uevent(struct devic
return 0;
}
+#endif
static struct attribute **
alloc_group_attrs(ssize_t (*show)(struct ib_port *,
@@ -545,7 +550,9 @@ static int add_port(struct ib_device *de
list_add_tail(&p->kobj.entry, &device->port_list);
+#ifdef __linux__
kobject_uevent(&p->kobj, KOBJ_ADD);
+#endif
return 0;
err_free_pkey:
@@ -658,7 +665,9 @@ static struct device_attribute *ib_class
static struct class ib_class = {
.name = "infiniband",
.dev_release = ib_device_release,
+#ifdef __linux__
.dev_uevent = ib_device_uevent,
+#endif
};
/* Show a given an attribute in the statistics group */
@@ -666,7 +675,7 @@ static ssize_t show_protocol_stat(const
struct device_attribute *attr, char *buf,
unsigned offset)
{
- struct ib_device *dev = container_of(device, struct ib_device, dev);
+ struct ib_device *dev = container_of(__DECONST(struct device *, device), struct ib_device, dev);
union rdma_protocol_stats stats;
ssize_t ret;
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/ucm.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/ucm.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/ucm.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -380,6 +380,8 @@ static int ib_ucm_event_handler(struct i
list_add_tail(&uevent->file_list, &ctx->file->events);
list_add_tail(&uevent->ctx_list, &ctx->events);
wake_up_interruptible(&ctx->file->poll_wait);
+ if (ctx->file->filp)
+ selwakeup(&ctx->file->filp->f_selinfo);
mutex_unlock(&ctx->file->file_mutex);
return 0;
@@ -1165,7 +1167,7 @@ static int ib_ucm_open(struct inode *ino
{
struct ib_ucm_file *file;
- file = kmalloc(sizeof(*file), GFP_KERNEL);
+ file = kzalloc(sizeof(*file), GFP_KERNEL);
if (!file)
return -ENOMEM;
@@ -1177,7 +1179,7 @@ static int ib_ucm_open(struct inode *ino
filp->private_data = file;
file->filp = filp;
- file->device = container_of(inode->i_cdev, struct ib_ucm_device, cdev);
+ file->device = container_of(inode->i_cdev->si_drv1, struct ib_ucm_device, cdev);
return 0;
}
@@ -1342,5 +1344,5 @@ static void __exit ib_ucm_cleanup(void)
idr_destroy(&ctx_id_table);
}
-module_init(ib_ucm_init);
+module_init_order(ib_ucm_init, SI_ORDER_THIRD);
module_exit(ib_ucm_cleanup);
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/ucma.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/ucma.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/ucma.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -284,6 +284,8 @@ static int ucma_event_handler(struct rdm
list_add_tail(&uevent->list, &ctx->file->event_list);
wake_up_interruptible(&ctx->file->poll_wait);
+ if (ctx->file->filp)
+ selwakeup(&ctx->file->filp->f_selinfo);
out:
mutex_unlock(&ctx->file->mut);
return ret;
@@ -585,20 +587,22 @@ static void ucma_copy_iboe_route(struct
struct rdma_route *route)
{
struct rdma_dev_addr *dev_addr;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
struct net_device *dev;
+#endif
u16 vid = 0;
resp->num_paths = route->num_paths;
switch (route->num_paths) {
case 0:
dev_addr = &route->addr.dev_addr;
+#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
dev = dev_get_by_index(&init_net, dev_addr->bound_dev_if);
if (dev) {
-#if defined(CONFIG_VLAN_8021Q) || defined(CONFIG_VLAN_8021Q_MODULE)
vid = vlan_dev_vlan_id(dev);
-#endif
dev_put(dev);
}
+#endif
iboe_mac_vlan_to_ll((union ib_gid *) &resp->ib_route[0].dgid,
dev_addr->dst_dev_addr, vid);
@@ -1250,7 +1254,7 @@ static int ucma_open(struct inode *inode
{
struct ucma_file *file;
- file = kmalloc(sizeof *file, GFP_KERNEL);
+ file = kzalloc(sizeof *file, GFP_KERNEL);
if (!file)
return -ENOMEM;
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -35,9 +35,20 @@
#include <linux/mm.h>
#include <linux/dma-mapping.h>
#include <linux/sched.h>
+#ifdef __linux__
#include <linux/hugetlb.h>
+#endif
#include <linux/dma-attrs.h>
+#include <sys/priv.h>
+#include <sys/resource.h>
+#include <sys/resourcevar.h>
+
+#include <vm/vm.h>
+#include <vm/vm_map.h>
+#include <vm/vm_pageout.h>
+
+
#include "uverbs.h"
static int allow_weak_ordering;
@@ -108,11 +119,12 @@ static void __ib_umem_release(struct ib_
ib_dma_unmap_sg_attrs(dev, chunk->page_list,
chunk->nents, DMA_BIDIRECTIONAL, &chunk->attrs);
for (i = 0; i < chunk->nents; ++i) {
+#ifdef __linux__
struct page *page = sg_page(&chunk->page_list[i]);
-
if (umem->writable && dirty)
set_page_dirty_lock(page);
put_page(page);
+#endif
}
kfree(chunk);
@@ -130,6 +142,7 @@ static void __ib_umem_release(struct ib_
struct ib_umem *ib_umem_get(struct ib_ucontext *context, unsigned long addr,
size_t size, int access, int dmasync)
{
+#ifdef __linux__
struct ib_umem *umem;
struct page **page_list;
struct vm_area_struct **vma_list;
@@ -148,7 +161,6 @@ struct ib_umem *ib_umem_get(struct ib_uc
else if (allow_weak_ordering)
dma_set_attr(DMA_ATTR_WEAK_ORDERING, &attrs);
-
if (!can_do_mlock())
return ERR_PTR(-EPERM);
@@ -203,6 +215,7 @@ struct ib_umem *ib_umem_get(struct ib_uc
cur_base = addr & PAGE_MASK;
ret = 0;
+
while (npages) {
ret = get_user_pages(current, current->mm, cur_base,
min_t(unsigned long, npages,
@@ -271,9 +284,127 @@ out:
free_page((unsigned long) page_list);
return ret < 0 ? ERR_PTR(ret) : umem;
+#else
+ struct ib_umem *umem;
+ struct ib_umem_chunk *chunk;
+ struct proc *proc;
+ pmap_t pmap;
+ vm_offset_t end, last, start;
+ vm_size_t npages;
+ int error;
+ int ents;
+ int ret;
+ int i;
+ DEFINE_DMA_ATTRS(attrs);
+
+ error = priv_check(curthread, PRIV_VM_MLOCK);
+ if (error)
+ return ERR_PTR(-error);
+
+ last = addr + size;
+ start = addr & PAGE_MASK; /* Use the linux PAGE_MASK definition. */
+ end = roundup2(last, PAGE_SIZE); /* Use PAGE_MASK safe operation. */
+ if (last < addr || end < addr)
+ return ERR_PTR(-EINVAL);
+ npages = atop(end - start);
+ if (npages > vm_page_max_wired)
+ return ERR_PTR(-ENOMEM);
+ umem = kzalloc(sizeof *umem, GFP_KERNEL);
+ if (!umem)
+ return ERR_PTR(-ENOMEM);
+ proc = curthread->td_proc;
+ PROC_LOCK(proc);
+ if (ptoa(npages +
+ pmap_wired_count(vm_map_pmap(&proc->p_vmspace->vm_map))) >
+ lim_cur(proc, RLIMIT_MEMLOCK)) {
+ PROC_UNLOCK(proc);
+ kfree(umem);
+ return ERR_PTR(-ENOMEM);
+ }
+ PROC_UNLOCK(proc);
+ if (npages + cnt.v_wire_count > vm_page_max_wired) {
+ kfree(umem);
+ return ERR_PTR(-EAGAIN);
+ }
+ error = vm_map_wire(&proc->p_vmspace->vm_map, start, end,
+ VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
+ if (error != KERN_SUCCESS) {
+ kfree(umem);
+ return ERR_PTR(-ENOMEM);
+ }
+
+ umem->context = context;
+ umem->length = size;
+ umem->offset = addr & ~PAGE_MASK;
+ umem->page_size = PAGE_SIZE;
+ umem->start = addr;
+ /*
+ * We ask for writable memory if any access flags other than
+ * "remote read" are set. "Local write" and "remote write"
+ * obviously require write access. "Remote atomic" can do
+ * things like fetch and add, which will modify memory, and
+ * "MW bind" can change permissions by binding a window.
+ */
+ umem->writable = !!(access & ~IB_ACCESS_REMOTE_READ);
+ umem->hugetlb = 0;
+ INIT_LIST_HEAD(&umem->chunk_list);
+
+ pmap = vm_map_pmap(&proc->p_vmspace->vm_map);
+ ret = 0;
+ while (npages) {
+ ents = min_t(int, npages, IB_UMEM_MAX_PAGE_CHUNK);
+ chunk = kmalloc(sizeof(*chunk) +
+ (sizeof(struct scatterlist) * ents),
+ GFP_KERNEL);
+ if (!chunk) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ chunk->attrs = attrs;
+ chunk->nents = ents;
+ sg_init_table(&chunk->page_list[0], ents);
+ for (i = 0; i < chunk->nents; ++i) {
+ vm_paddr_t pa;
+
+ pa = pmap_extract(pmap, start);
+ if (pa == 0) {
+ ret = -ENOMEM;
+ kfree(chunk);
+ goto out;
+ }
+ sg_set_page(&chunk->page_list[i], PHYS_TO_VM_PAGE(pa),
+ PAGE_SIZE, 0);
+ npages--;
+ start += PAGE_SIZE;
+ }
+
+ chunk->nmap = ib_dma_map_sg_attrs(context->device,
+ &chunk->page_list[0],
+ chunk->nents,
+ DMA_BIDIRECTIONAL,
+ &attrs);
+ if (chunk->nmap != chunk->nents) {
+ kfree(chunk);
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ list_add_tail(&chunk->list, &umem->chunk_list);
+ }
+
+out:
+ if (ret < 0) {
+ __ib_umem_release(context->device, umem, 0);
+ kfree(umem);
+ }
+
+ return ret < 0 ? ERR_PTR(ret) : umem;
+#endif
}
EXPORT_SYMBOL(ib_umem_get);
+#ifdef __linux__
static void ib_umem_account(struct work_struct *work)
{
struct ib_umem *umem = container_of(work, struct ib_umem, work);
@@ -284,6 +415,7 @@ static void ib_umem_account(struct work_
mmput(umem->mm);
kfree(umem);
}
+#endif
/**
* ib_umem_release - release memory pinned with ib_umem_get
@@ -291,6 +423,7 @@ static void ib_umem_account(struct work_
*/
void ib_umem_release(struct ib_umem *umem)
{
+#ifdef __linux__
struct ib_ucontext *context = umem->context;
struct mm_struct *mm;
unsigned long diff;
@@ -328,6 +461,29 @@ void ib_umem_release(struct ib_umem *ume
current->mm->locked_vm -= diff;
up_write(&mm->mmap_sem);
mmput(mm);
+#else
+ vm_offset_t addr, end, last, start;
+ vm_size_t size;
+ int error;
+
+ __ib_umem_release(umem->context->device, umem, 1);
+
+ if (umem->context->closing) {
+ kfree(umem);
+ return;
+ }
+ error = priv_check(curthread, PRIV_VM_MUNLOCK);
+ if (error)
+ return;
+ addr = umem->start;
+ size = umem->length;
+ last = addr + size;
+ start = addr & PAGE_MASK; /* Use the linux PAGE_MASK definition. */
+ end = roundup2(last, PAGE_SIZE); /* Use PAGE_MASK safe operation. */
+ vm_map_unwire(&curthread->td_proc->p_vmspace->vm_map, start, end,
+ VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
+
+#endif
kfree(umem);
}
EXPORT_SYMBOL(ib_umem_release);
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/user_mad.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/user_mad.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/user_mad.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -678,7 +678,7 @@ found:
file->already_used = 1;
if (!file->use_pkey_index) {
printk(KERN_WARNING "user_mad: process %s did not enable "
- "P_Key index support.\n", current->comm);
+ "P_Key index support.\n", curproc->p_comm);
printk(KERN_WARNING "user_mad: Documentation/infiniband/user_mad.txt "
"has info on the new ABI.\n");
}
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs.h
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs.h Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs.h Fri Aug 13 03:08:38 2010 (r211258)
@@ -79,6 +79,7 @@ struct ib_uverbs_device {
struct ib_uverbs_event_file {
struct kref ref;
+ struct file *filp;
struct ib_uverbs_file *uverbs_file;
spinlock_t lock;
wait_queue_head_t poll_wait;
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_cmd.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_cmd.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_cmd.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -498,7 +498,7 @@ ssize_t ib_uverbs_alloc_pd(struct ib_uve
(unsigned long) cmd.response + sizeof resp,
in_len - sizeof cmd, out_len - sizeof resp);
- uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
+ uobj = kzalloc(sizeof *uobj, GFP_KERNEL);
if (!uobj)
return -ENOMEM;
@@ -619,7 +619,7 @@ ssize_t ib_uverbs_reg_mr(struct ib_uverb
!(cmd.access_flags & IB_ACCESS_LOCAL_WRITE))
return -EINVAL;
- uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
+ uobj = kzalloc(sizeof *uobj, GFP_KERNEL);
if (!uobj)
return -ENOMEM;
@@ -779,7 +779,7 @@ ssize_t ib_uverbs_create_cq(struct ib_uv
if (cmd.comp_vector >= file->device->num_comp_vectors)
return -EINVAL;
- obj = kmalloc(sizeof *obj, GFP_KERNEL);
+ obj = kzalloc(sizeof *obj, GFP_KERNEL);
if (!obj)
return -ENOMEM;
@@ -1057,7 +1057,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uv
(unsigned long) cmd.response + sizeof resp,
in_len - sizeof cmd, out_len - sizeof resp);
- obj = kmalloc(sizeof *obj, GFP_KERNEL);
+ obj = kzalloc(sizeof *obj, GFP_KERNEL);
if (!obj)
return -ENOMEM;
@@ -1784,7 +1784,7 @@ ssize_t ib_uverbs_create_ah(struct ib_uv
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
- uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
+ uobj = kzalloc(sizeof *uobj, GFP_KERNEL);
if (!uobj)
return -ENOMEM;
@@ -2031,7 +2031,7 @@ ssize_t ib_uverbs_create_srq(struct ib_u
(unsigned long) cmd.response + sizeof resp,
in_len - sizeof cmd, out_len - sizeof resp);
- obj = kmalloc(sizeof *obj, GFP_KERNEL);
+ obj = kzalloc(sizeof *obj, GFP_KERNEL);
if (!obj)
return -ENOMEM;
@@ -2137,7 +2137,7 @@ ssize_t ib_uverbs_create_xrc_srq(struct
(unsigned long) cmd.response + sizeof resp,
in_len - sizeof cmd, out_len - sizeof resp);
- obj = kmalloc(sizeof *obj, GFP_KERNEL);
+ obj = kzalloc(sizeof *obj, GFP_KERNEL);
if (!obj)
return -ENOMEM;
@@ -2507,7 +2507,7 @@ ssize_t ib_uverbs_open_xrc_domain(struct
}
}
- xrcd_uobj = kmalloc(sizeof *xrcd_uobj, GFP_KERNEL);
+ xrcd_uobj = kzalloc(sizeof *xrcd_uobj, GFP_KERNEL);
if (!xrcd_uobj) {
ret = -ENOMEM;
goto err_table_mutex_unlock;
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_main.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_main.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/core/uverbs_main.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -120,7 +120,9 @@ static ssize_t (*uverbs_cmd_table[])(str
[IB_USER_VERBS_CMD_GET_ETH_L2_ADDR] = ib_uverbs_get_eth_l2_addr,
};
+#ifdef __linux__
static struct vfsmount *uverbs_event_mnt;
+#endif
static void ib_uverbs_add_one(struct ib_device *device);
static void ib_uverbs_remove_one(struct ib_device *device);
@@ -359,6 +361,7 @@ static unsigned int ib_uverbs_event_poll
unsigned int pollflags = 0;
struct ib_uverbs_event_file *file = filp->private_data;
+ file->filp = filp;
poll_wait(filp, &file->poll_wait, wait);
spin_lock_irq(&file->lock);
@@ -369,12 +372,14 @@ static unsigned int ib_uverbs_event_poll
return pollflags;
}
+#ifdef __linux__
static int ib_uverbs_event_fasync(int fd, struct file *filp, int on)
{
struct ib_uverbs_event_file *file = filp->private_data;
return fasync_helper(fd, filp, on, &file->async_queue);
}
+#endif
static int ib_uverbs_event_close(struct inode *inode, struct file *filp)
{
@@ -404,7 +409,9 @@ static const struct file_operations uver
.read = ib_uverbs_event_read,
.poll = ib_uverbs_event_poll,
.release = ib_uverbs_event_close,
+#ifdef __linux__
.fasync = ib_uverbs_event_fasync
+#endif
};
void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context)
@@ -439,7 +446,12 @@ void ib_uverbs_comp_handler(struct ib_cq
spin_unlock_irqrestore(&file->lock, flags);
wake_up_interruptible(&file->poll_wait);
+ if (file->filp)
+ selwakeup(&file->filp->f_selinfo);
+#ifdef __linux__
+ /* funsetown ? */
kill_fasync(&file->async_queue, SIGIO, POLL_IN);
+#endif
}
static void ib_uverbs_async_handler(struct ib_uverbs_file *file,
@@ -472,7 +484,12 @@ static void ib_uverbs_async_handler(stru
spin_unlock_irqrestore(&file->async_file->lock, flags);
wake_up_interruptible(&file->async_file->poll_wait);
+ if (file->async_file->filp)
+ selwakeup(&file->async_file->filp->f_selinfo);
+#ifdef __linux__
+ /* funsetown? */
kill_fasync(&file->async_file->async_queue, SIGIO, POLL_IN);
+#endif
}
void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr)
@@ -533,7 +550,7 @@ struct file *ib_uverbs_alloc_event_file(
struct file *filp;
int ret;
- ev_file = kmalloc(sizeof *ev_file, GFP_KERNEL);
+ ev_file = kzalloc(sizeof *ev_file, GFP_KERNEL);
if (!ev_file)
return ERR_PTR(-ENOMEM);
@@ -546,6 +563,7 @@ struct file *ib_uverbs_alloc_event_file(
ev_file->is_async = is_async;
ev_file->is_closed = 0;
+#ifdef __linux__
*fd = get_unused_fd();
if (*fd < 0) {
ret = *fd;
@@ -564,12 +582,28 @@ struct file *ib_uverbs_alloc_event_file(
goto err_fd;
}
+#else
+ filp = kzalloc(sizeof(*filp), GFP_KERNEL);
+ if (filp == NULL) {
+ ret = -ENOMEM;
+ goto err;
+ }
+ filp->f_op = &uverbs_event_fops;
+ ret = falloc(curthread, &filp->_file, fd);
+ if (ret) {
+ ret = -ret;
+ goto err;
+ }
+ finit(filp->_file, FREAD, DTYPE_DEV, filp, &badfileops);
+#endif
filp->private_data = ev_file;
return filp;
+#ifdef __linux__
err_fd:
put_unused_fd(*fd);
+#endif
err:
kfree(ev_file);
@@ -677,7 +711,7 @@ static int ib_uverbs_open(struct inode *
goto err;
}
- file = kmalloc(sizeof *file, GFP_KERNEL);
+ file = kzalloc(sizeof *file, GFP_KERNEL);
if (!file) {
ret = -ENOMEM;
goto err_module;
@@ -766,6 +800,46 @@ static ssize_t show_abi_version(struct c
}
static CLASS_ATTR(abi_version, S_IRUGO, show_abi_version, NULL);
+#include <linux/pci.h>
+
+static ssize_t
+show_dev_device(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct ib_uverbs_device *dev = dev_get_drvdata(device);
+
+ if (!dev)
+ return -ENODEV;
+
+ return sprintf(buf, "0x%04x\n",
+ ((struct pci_dev *)dev->ib_dev->dma_device)->device);
+}
+static DEVICE_ATTR(device, S_IRUGO, show_dev_device, NULL);
+
+static ssize_t
+show_dev_vendor(struct device *device, struct device_attribute *attr, char *buf)
+{
+ struct ib_uverbs_device *dev = dev_get_drvdata(device);
+
+ if (!dev)
+ return -ENODEV;
+
+ return sprintf(buf, "0x%04x\n",
+ ((struct pci_dev *)dev->ib_dev->dma_device)->vendor);
+}
+static DEVICE_ATTR(vendor, S_IRUGO, show_dev_vendor, NULL);
+
+struct attribute *device_attrs[] =
+{
+ &dev_attr_device.attr,
+ &dev_attr_vendor.attr,
+ NULL
+};
+
+static struct attribute_group device_group = {
+ .name = "device",
+ .attrs = device_attrs
+};
+
static void ib_uverbs_add_one(struct ib_device *device)
{
struct ib_uverbs_device *uverbs_dev;
@@ -811,6 +885,8 @@ static void ib_uverbs_add_one(struct ib_
goto err_class;
if (device_create_file(uverbs_dev->dev, &dev_attr_abi_version))
goto err_class;
+ if (sysfs_create_group(&uverbs_dev->dev->kobj, &device_group))
+ goto err_class;
spin_lock(&map_lock);
dev_table[uverbs_dev->devnum] = uverbs_dev;
@@ -855,7 +931,7 @@ static void ib_uverbs_remove_one(struct
wait_for_completion(&uverbs_dev->comp);
kfree(uverbs_dev);
}
-
+#ifdef __linux__
static int uverbs_event_get_sb(struct file_system_type *fs_type, int flags,
const char *dev_name, void *data,
struct vfsmount *mnt)
@@ -870,6 +946,7 @@ static struct file_system_type uverbs_ev
.get_sb = uverbs_event_get_sb,
.kill_sb = kill_litter_super
};
+#endif
static int __init ib_uverbs_init(void)
{
@@ -897,6 +974,7 @@ static int __init ib_uverbs_init(void)
goto out_class;
}
+#ifdef __linux__
ret = register_filesystem(&uverbs_event_fs);
if (ret) {
printk(KERN_ERR "user_verbs: couldn't register infinibandeventfs\n");
@@ -909,6 +987,7 @@ static int __init ib_uverbs_init(void)
printk(KERN_ERR "user_verbs: couldn't mount infinibandeventfs\n");
goto out_fs;
}
+#endif
ret = ib_register_client(&uverbs_client);
if (ret) {
@@ -919,10 +998,12 @@ static int __init ib_uverbs_init(void)
return 0;
out_mnt:
+#ifdef __linux__
mntput(uverbs_event_mnt);
out_fs:
unregister_filesystem(&uverbs_event_fs);
+#endif
out_class:
class_destroy(uverbs_class);
@@ -937,8 +1018,10 @@ out:
static void __exit ib_uverbs_cleanup(void)
{
ib_unregister_client(&uverbs_client);
+#ifdef __linux__
mntput(uverbs_event_mnt);
unregister_filesystem(&uverbs_event_fs);
+#endif
class_destroy(uverbs_class);
unregister_chrdev_region(IB_UVERBS_BASE_DEV, IB_UVERBS_MAX_DEVICES);
idr_destroy(&ib_uverbs_pd_idr);
Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c
==============================================================================
--- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Fri Aug 13 03:06:09 2010 (r211257)
+++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Fri Aug 13 03:08:38 2010 (r211258)
@@ -61,7 +61,7 @@ MODULE_VERSION(DRV_VERSION);
#ifdef CONFIG_MLX4_DEBUG
-int mlx4_ib_debug_level = 0;
*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
More information about the svn-src-projects
mailing list