Commit a78b3371 authored by Linus Torvalds's avatar Linus Torvalds

Merge HEAD from master.kernel.org:/pub/scm/linux/kernel/git/roland/infiniband.git

parents 97c169a2 a4d61e84
EXTRA_CFLAGS += -Idrivers/infiniband/include
obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o \ obj-$(CONFIG_INFINIBAND) += ib_core.o ib_mad.o ib_sa.o \
ib_cm.o ib_umad.o ib_ucm.o ib_cm.o ib_umad.o ib_ucm.o
obj-$(CONFIG_INFINIBAND_USER_VERBS) += ib_uverbs.o obj-$(CONFIG_INFINIBAND_USER_VERBS) += ib_uverbs.o
......
/* /*
* Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2004, 2005 Mellanox Technologies Ltd. All rights reserved.
* Copyright (c) 2004 Infinicon Corporation. All rights reserved. * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
* Copyright (c) 2004 Intel Corporation. All rights reserved. * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
* Copyright (c) 2004 Topspin Corporation. All rights reserved. * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
* Copyright (c) 2004 Voltaire Corporation. All rights reserved. * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -40,7 +41,7 @@ ...@@ -40,7 +41,7 @@
#include <asm/bug.h> #include <asm/bug.h>
#include <ib_smi.h> #include <rdma/ib_smi.h>
#include "smi.h" #include "smi.h"
#include "agent_priv.h" #include "agent_priv.h"
......
/* /*
* Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2004, 2005 Mellanox Technologies Ltd. All rights reserved.
* Copyright (c) 2004 Infinicon Corporation. All rights reserved. * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
* Copyright (c) 2004 Intel Corporation. All rights reserved. * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
* Copyright (c) 2004 Topspin Corporation. All rights reserved. * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
* Copyright (c) 2004 Voltaire Corporation. All rights reserved. * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
......
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Intel Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2005 Voltaire, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -32,12 +35,11 @@ ...@@ -32,12 +35,11 @@
* $Id: cache.c 1349 2004-12-16 21:09:43Z roland $ * $Id: cache.c 1349 2004-12-16 21:09:43Z roland $
*/ */
#include <linux/version.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <ib_cache.h> #include <rdma/ib_cache.h>
#include "core_priv.h" #include "core_priv.h"
......
This diff is collapsed.
This diff is collapsed.
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <ib_verbs.h> #include <rdma/ib_verbs.h>
int ib_device_register_sysfs(struct ib_device *device); int ib_device_register_sysfs(struct ib_device *device);
void ib_device_unregister_sysfs(struct ib_device *device); void ib_device_unregister_sysfs(struct ib_device *device);
......
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
......
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
#include <linux/jhash.h> #include <linux/jhash.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <ib_fmr_pool.h> #include <rdma/ib_fmr_pool.h>
#include "core_priv.h" #include "core_priv.h"
...@@ -334,6 +334,7 @@ void ib_destroy_fmr_pool(struct ib_fmr_pool *pool) ...@@ -334,6 +334,7 @@ void ib_destroy_fmr_pool(struct ib_fmr_pool *pool)
{ {
struct ib_pool_fmr *fmr; struct ib_pool_fmr *fmr;
struct ib_pool_fmr *tmp; struct ib_pool_fmr *tmp;
LIST_HEAD(fmr_list);
int i; int i;
kthread_stop(pool->thread); kthread_stop(pool->thread);
...@@ -341,6 +342,11 @@ void ib_destroy_fmr_pool(struct ib_fmr_pool *pool) ...@@ -341,6 +342,11 @@ void ib_destroy_fmr_pool(struct ib_fmr_pool *pool)
i = 0; i = 0;
list_for_each_entry_safe(fmr, tmp, &pool->free_list, list) { list_for_each_entry_safe(fmr, tmp, &pool->free_list, list) {
if (fmr->remap_count) {
INIT_LIST_HEAD(&fmr_list);
list_add_tail(&fmr->fmr->list, &fmr_list);
ib_unmap_fmr(&fmr_list);
}
ib_dealloc_fmr(fmr->fmr); ib_dealloc_fmr(fmr->fmr);
list_del(&fmr->list); list_del(&fmr->list);
kfree(fmr); kfree(fmr);
......
...@@ -693,7 +693,8 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv, ...@@ -693,7 +693,8 @@ static int handle_outgoing_dr_smp(struct ib_mad_agent_private *mad_agent_priv,
goto out; goto out;
} }
build_smp_wc(send_wr->wr_id, smp->dr_slid, send_wr->wr.ud.pkey_index, build_smp_wc(send_wr->wr_id, be16_to_cpu(smp->dr_slid),
send_wr->wr.ud.pkey_index,
send_wr->wr.ud.port_num, &mad_wc); send_wr->wr.ud.port_num, &mad_wc);
/* No GRH for DR SMP */ /* No GRH for DR SMP */
...@@ -1554,7 +1555,7 @@ static int is_data_mad(struct ib_mad_agent_private *mad_agent_priv, ...@@ -1554,7 +1555,7 @@ static int is_data_mad(struct ib_mad_agent_private *mad_agent_priv,
} }
struct ib_mad_send_wr_private* struct ib_mad_send_wr_private*
ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv, u64 tid) ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv, __be64 tid)
{ {
struct ib_mad_send_wr_private *mad_send_wr; struct ib_mad_send_wr_private *mad_send_wr;
...@@ -1597,7 +1598,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv, ...@@ -1597,7 +1598,7 @@ static void ib_mad_complete_recv(struct ib_mad_agent_private *mad_agent_priv,
struct ib_mad_send_wr_private *mad_send_wr; struct ib_mad_send_wr_private *mad_send_wr;
struct ib_mad_send_wc mad_send_wc; struct ib_mad_send_wc mad_send_wc;
unsigned long flags; unsigned long flags;
u64 tid; __be64 tid;
INIT_LIST_HEAD(&mad_recv_wc->rmpp_list); INIT_LIST_HEAD(&mad_recv_wc->rmpp_list);
list_add(&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list); list_add(&mad_recv_wc->recv_buf.list, &mad_recv_wc->rmpp_list);
...@@ -2165,7 +2166,8 @@ static void local_completions(void *data) ...@@ -2165,7 +2166,8 @@ static void local_completions(void *data)
* Defined behavior is to complete response * Defined behavior is to complete response
* before request * before request
*/ */
build_smp_wc(local->wr_id, IB_LID_PERMISSIVE, build_smp_wc(local->wr_id,
be16_to_cpu(IB_LID_PERMISSIVE),
0 /* pkey index */, 0 /* pkey index */,
recv_mad_agent->agent.port_num, &wc); recv_mad_agent->agent.port_num, &wc);
...@@ -2294,7 +2296,7 @@ static void timeout_sends(void *data) ...@@ -2294,7 +2296,7 @@ static void timeout_sends(void *data)
spin_unlock_irqrestore(&mad_agent_priv->lock, flags); spin_unlock_irqrestore(&mad_agent_priv->lock, flags);
} }
static void ib_mad_thread_completion_handler(struct ib_cq *cq) static void ib_mad_thread_completion_handler(struct ib_cq *cq, void *arg)
{ {
struct ib_mad_port_private *port_priv = cq->cq_context; struct ib_mad_port_private *port_priv = cq->cq_context;
...@@ -2574,8 +2576,7 @@ static int ib_mad_port_open(struct ib_device *device, ...@@ -2574,8 +2576,7 @@ static int ib_mad_port_open(struct ib_device *device,
cq_size = (IB_MAD_QP_SEND_SIZE + IB_MAD_QP_RECV_SIZE) * 2; cq_size = (IB_MAD_QP_SEND_SIZE + IB_MAD_QP_RECV_SIZE) * 2;
port_priv->cq = ib_create_cq(port_priv->device, port_priv->cq = ib_create_cq(port_priv->device,
(ib_comp_handler) ib_mad_thread_completion_handler,
ib_mad_thread_completion_handler,
NULL, port_priv, cq_size); NULL, port_priv, cq_size);
if (IS_ERR(port_priv->cq)) { if (IS_ERR(port_priv->cq)) {
printk(KERN_ERR PFX "Couldn't create ib_mad CQ\n"); printk(KERN_ERR PFX "Couldn't create ib_mad CQ\n");
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <ib_mad.h> #include <rdma/ib_mad.h>
#include <ib_smi.h> #include <rdma/ib_smi.h>
#define PFX "ib_mad: " #define PFX "ib_mad: "
...@@ -121,7 +121,7 @@ struct ib_mad_send_wr_private { ...@@ -121,7 +121,7 @@ struct ib_mad_send_wr_private {
struct ib_send_wr send_wr; struct ib_send_wr send_wr;
struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG]; struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
u64 wr_id; /* client WR ID */ u64 wr_id; /* client WR ID */
u64 tid; __be64 tid;
unsigned long timeout; unsigned long timeout;
int retries; int retries;
int retry; int retry;
...@@ -144,7 +144,7 @@ struct ib_mad_local_private { ...@@ -144,7 +144,7 @@ struct ib_mad_local_private {
struct ib_send_wr send_wr; struct ib_send_wr send_wr;
struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG]; struct ib_sge sg_list[IB_MAD_SEND_REQ_MAX_SG];
u64 wr_id; /* client WR ID */ u64 wr_id; /* client WR ID */
u64 tid; __be64 tid;
}; };
struct ib_mad_mgmt_method_table { struct ib_mad_mgmt_method_table {
...@@ -210,7 +210,7 @@ extern kmem_cache_t *ib_mad_cache; ...@@ -210,7 +210,7 @@ extern kmem_cache_t *ib_mad_cache;
int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr); int ib_send_mad(struct ib_mad_send_wr_private *mad_send_wr);
struct ib_mad_send_wr_private * struct ib_mad_send_wr_private *
ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv, u64 tid); ib_find_send_mad(struct ib_mad_agent_private *mad_agent_priv, __be64 tid);
void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr, void ib_mad_complete_send_wr(struct ib_mad_send_wr_private *mad_send_wr,
struct ib_mad_send_wc *mad_send_wc); struct ib_mad_send_wc *mad_send_wc);
......
This diff is collapsed.
/* /*
* Copyright (c) 2004 Topspin Corporation. All rights reserved. * Copyright (c) 2004 Topspin Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
* $Id: packer.c 1349 2004-12-16 21:09:43Z roland $ * $Id: packer.c 1349 2004-12-16 21:09:43Z roland $
*/ */
#include <ib_pack.h> #include <rdma/ib_pack.h>
static u64 value_read(int offset, int size, void *structure) static u64 value_read(int offset, int size, void *structure)
{ {
......
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Voltaire, Inc. All rights reserved. * Copyright (c) 2005 Voltaire, Inc.  All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -44,8 +44,8 @@ ...@@ -44,8 +44,8 @@
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <ib_pack.h> #include <rdma/ib_pack.h>
#include <ib_sa.h> #include <rdma/ib_sa.h>
MODULE_AUTHOR("Roland Dreier"); MODULE_AUTHOR("Roland Dreier");
MODULE_DESCRIPTION("InfiniBand subnet administration query support"); MODULE_DESCRIPTION("InfiniBand subnet administration query support");
......
/* /*
* Copyright (c) 2004 Mellanox Technologies Ltd. All rights reserved. * Copyright (c) 2004, 2005 Mellanox Technologies Ltd. All rights reserved.
* Copyright (c) 2004 Infinicon Corporation. All rights reserved. * Copyright (c) 2004, 2005 Infinicon Corporation. All rights reserved.
* Copyright (c) 2004 Intel Corporation. All rights reserved. * Copyright (c) 2004, 2005 Intel Corporation. All rights reserved.
* Copyright (c) 2004 Topspin Corporation. All rights reserved. * Copyright (c) 2004, 2005 Topspin Corporation. All rights reserved.
* Copyright (c) 2004 Voltaire Corporation. All rights reserved. * Copyright (c) 2004, 2005 Voltaire Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
* $Id: smi.c 1389 2004-12-27 22:56:47Z roland $ * $Id: smi.c 1389 2004-12-27 22:56:47Z roland $
*/ */
#include <ib_smi.h> #include <rdma/ib_smi.h>
#include "smi.h" #include "smi.h"
/* /*
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -34,7 +36,7 @@ ...@@ -34,7 +36,7 @@
#include "core_priv.h" #include "core_priv.h"
#include <ib_mad.h> #include <rdma/ib_mad.h>
struct ib_port { struct ib_port {
struct kobject kobj; struct kobject kobj;
...@@ -253,14 +255,14 @@ static ssize_t show_port_gid(struct ib_port *p, struct port_attribute *attr, ...@@ -253,14 +255,14 @@ static ssize_t show_port_gid(struct ib_port *p, struct port_attribute *attr,
return ret; return ret;
return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n", return sprintf(buf, "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
be16_to_cpu(((u16 *) gid.raw)[0]), be16_to_cpu(((__be16 *) gid.raw)[0]),
be16_to_cpu(((u16 *) gid.raw)[1]), be16_to_cpu(((__be16 *) gid.raw)[1]),
be16_to_cpu(((u16 *) gid.raw)[2]), be16_to_cpu(((__be16 *) gid.raw)[2]),
be16_to_cpu(((u16 *) gid.raw)[3]), be16_to_cpu(((__be16 *) gid.raw)[3]),
be16_to_cpu(((u16 *) gid.raw)[4]), be16_to_cpu(((__be16 *) gid.raw)[4]),
be16_to_cpu(((u16 *) gid.raw)[5]), be16_to_cpu(((__be16 *) gid.raw)[5]),
be16_to_cpu(((u16 *) gid.raw)[6]), be16_to_cpu(((__be16 *) gid.raw)[6]),
be16_to_cpu(((u16 *) gid.raw)[7])); be16_to_cpu(((__be16 *) gid.raw)[7]));
} }
static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr, static ssize_t show_port_pkey(struct ib_port *p, struct port_attribute *attr,
...@@ -332,11 +334,11 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr, ...@@ -332,11 +334,11 @@ static ssize_t show_pma_counter(struct ib_port *p, struct port_attribute *attr,
break; break;
case 16: case 16:
ret = sprintf(buf, "%u\n", ret = sprintf(buf, "%u\n",
be16_to_cpup((u16 *)(out_mad->data + 40 + offset / 8))); be16_to_cpup((__be16 *)(out_mad->data + 40 + offset / 8)));
break; break;
case 32: case 32:
ret = sprintf(buf, "%u\n", ret = sprintf(buf, "%u\n",
be32_to_cpup((u32 *)(out_mad->data + 40 + offset / 8))); be32_to_cpup((__be32 *)(out_mad->data + 40 + offset / 8)));
break; break;
default: default:
ret = 0; ret = 0;
...@@ -598,10 +600,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf) ...@@ -598,10 +600,10 @@ static ssize_t show_sys_image_guid(struct class_device *cdev, char *buf)
return ret; return ret;
return sprintf(buf, "%04x:%04x:%04x:%04x\n", return sprintf(buf, "%04x:%04x:%04x:%04x\n",
be16_to_cpu(((u16 *) &attr.sys_image_guid)[0]), be16_to_cpu(((__be16 *) &attr.sys_image_guid)[0]),
be16_to_cpu(((u16 *) &attr.sys_image_guid)[1]), be16_to_cpu(((__be16 *) &attr.sys_image_guid)[1]),
be16_to_cpu(((u16 *) &attr.sys_image_guid)[2]), be16_to_cpu(((__be16 *) &attr.sys_image_guid)[2]),
be16_to_cpu(((u16 *) &attr.sys_image_guid)[3])); be16_to_cpu(((__be16 *) &attr.sys_image_guid)[3]));
} }
static ssize_t show_node_guid(struct class_device *cdev, char *buf) static ssize_t show_node_guid(struct class_device *cdev, char *buf)
...@@ -615,10 +617,10 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf) ...@@ -615,10 +617,10 @@ static ssize_t show_node_guid(struct class_device *cdev, char *buf)
return ret; return ret;
return sprintf(buf, "%04x:%04x:%04x:%04x\n", return sprintf(buf, "%04x:%04x:%04x:%04x\n",
be16_to_cpu(((u16 *) &attr.node_guid)[0]), be16_to_cpu(((__be16 *) &attr.node_guid)[0]),
be16_to_cpu(((u16 *) &attr.node_guid)[1]), be16_to_cpu(((__be16 *) &attr.node_guid)[1]),
be16_to_cpu(((u16 *) &attr.node_guid)[2]), be16_to_cpu(((__be16 *) &attr.node_guid)[2]),
be16_to_cpu(((u16 *) &attr.node_guid)[3])); be16_to_cpu(((__be16 *) &attr.node_guid)[3]));
} }
static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL); static CLASS_DEVICE_ATTR(node_type, S_IRUGO, show_node_type, NULL);
......
This diff is collapsed.
...@@ -40,17 +40,15 @@ ...@@ -40,17 +40,15 @@
#include <linux/cdev.h> #include <linux/cdev.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <ib_cm.h> #include <rdma/ib_cm.h>
#include <ib_user_cm.h> #include <rdma/ib_user_cm.h>
#define IB_UCM_CM_ID_INVALID 0xffffffff #define IB_UCM_CM_ID_INVALID 0xffffffff
struct ib_ucm_file { struct ib_ucm_file {
struct semaphore mutex; struct semaphore mutex;
struct file *filp; struct file *filp;
/*
* list of pending events
*/
struct list_head ctxs; /* list of active connections */ struct list_head ctxs; /* list of active connections */
struct list_head events; /* list of pending events */ struct list_head events; /* list of pending events */
wait_queue_head_t poll_wait; wait_queue_head_t poll_wait;
...@@ -58,12 +56,11 @@ struct ib_ucm_file { ...@@ -58,12 +56,11 @@ struct ib_ucm_file {
struct ib_ucm_context { struct ib_ucm_context {
int id; int id;
int ref; wait_queue_head_t wait;
int error; atomic_t ref;
struct ib_ucm_file *file; struct ib_ucm_file *file;
struct ib_cm_id *cm_id; struct ib_cm_id *cm_id;
struct semaphore mutex;
struct list_head events; /* list of pending events. */ struct list_head events; /* list of pending events. */
struct list_head file_list; /* member in file ctx list */ struct list_head file_list; /* member in file ctx list */
......
/* /*
* Copyright (c) 2004 Topspin Corporation. All rights reserved. * Copyright (c) 2004 Topspin Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -34,7 +35,7 @@ ...@@ -34,7 +35,7 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <ib_pack.h> #include <rdma/ib_pack.h>
#define STRUCT_FIELD(header, field) \ #define STRUCT_FIELD(header, field) \
.struct_offset_bytes = offsetof(struct ib_unpacked_ ## header, field), \ .struct_offset_bytes = offsetof(struct ib_unpacked_ ## header, field), \
...@@ -194,6 +195,7 @@ void ib_ud_header_init(int payload_bytes, ...@@ -194,6 +195,7 @@ void ib_ud_header_init(int payload_bytes,
struct ib_ud_header *header) struct ib_ud_header *header)
{ {
int header_len; int header_len;
u16 packet_length;
memset(header, 0, sizeof *header); memset(header, 0, sizeof *header);
...@@ -208,7 +210,7 @@ void ib_ud_header_init(int payload_bytes, ...@@ -208,7 +210,7 @@ void ib_ud_header_init(int payload_bytes,
header->lrh.link_version = 0; header->lrh.link_version = 0;
header->lrh.link_next_header = header->lrh.link_next_header =
grh_present ? IB_LNH_IBA_GLOBAL : IB_LNH_IBA_LOCAL; grh_present ? IB_LNH_IBA_GLOBAL : IB_LNH_IBA_LOCAL;
header->lrh.packet_length = (IB_LRH_BYTES + packet_length = (IB_LRH_BYTES +
IB_BTH_BYTES + IB_BTH_BYTES +
IB_DETH_BYTES + IB_DETH_BYTES +
payload_bytes + payload_bytes +
...@@ -217,8 +219,7 @@ void ib_ud_header_init(int payload_bytes, ...@@ -217,8 +219,7 @@ void ib_ud_header_init(int payload_bytes,
header->grh_present = grh_present; header->grh_present = grh_present;
if (grh_present) { if (grh_present) {
header->lrh.packet_length += IB_GRH_BYTES / 4; packet_length += IB_GRH_BYTES / 4;
header->grh.ip_version = 6; header->grh.ip_version = 6;
header->grh.payload_length = header->grh.payload_length =
cpu_to_be16((IB_BTH_BYTES + cpu_to_be16((IB_BTH_BYTES +
...@@ -229,7 +230,7 @@ void ib_ud_header_init(int payload_bytes, ...@@ -229,7 +230,7 @@ void ib_ud_header_init(int payload_bytes,
header->grh.next_header = 0x1b; header->grh.next_header = 0x1b;
} }
cpu_to_be16s(&header->lrh.packet_length); header->lrh.packet_length = cpu_to_be16(packet_length);
if (header->immediate_present) if (header->immediate_present)
header->bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE; header->bth.opcode = IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE;
......
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Voltaire, Inc. All rights reserved. * Copyright (c) 2005 Voltaire, Inc. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
...@@ -49,8 +49,8 @@ ...@@ -49,8 +49,8 @@
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <ib_mad.h> #include <rdma/ib_mad.h>
#include <ib_user_mad.h> #include <rdma/ib_user_mad.h>
MODULE_AUTHOR("Roland Dreier"); MODULE_AUTHOR("Roland Dreier");
MODULE_DESCRIPTION("InfiniBand userspace MAD packet access"); MODULE_DESCRIPTION("InfiniBand userspace MAD packet access");
...@@ -271,7 +271,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf, ...@@ -271,7 +271,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
struct ib_send_wr *bad_wr; struct ib_send_wr *bad_wr;
struct ib_rmpp_mad *rmpp_mad; struct ib_rmpp_mad *rmpp_mad;
u8 method; u8 method;
u64 *tid; __be64 *tid;
int ret, length, hdr_len, data_len, rmpp_hdr_size; int ret, length, hdr_len, data_len, rmpp_hdr_size;
int rmpp_active = 0; int rmpp_active = 0;
...@@ -316,7 +316,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf, ...@@ -316,7 +316,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf,
if (packet->mad.hdr.grh_present) { if (packet->mad.hdr.grh_present) {
ah_attr.ah_flags = IB_AH_GRH; ah_attr.ah_flags = IB_AH_GRH;
memcpy(ah_attr.grh.dgid.raw, packet->mad.hdr.gid, 16); memcpy(ah_attr.grh.dgid.raw, packet->mad.hdr.gid, 16);
ah_attr.grh.flow_label = packet->mad.hdr.flow_label; ah_attr.grh.flow_label = be32_to_cpu(packet->mad.hdr.flow_label);
ah_attr.grh.hop_limit = packet->mad.hdr.hop_limit; ah_attr.grh.hop_limit = packet->mad.hdr.hop_limit;
ah_attr.grh.traffic_class = packet->mad.hdr.traffic_class; ah_attr.grh.traffic_class = packet->mad.hdr.traffic_class;
} }
......
/* /*
* Copyright (c) 2005 Topspin Communications. All rights reserved. * Copyright (c) 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* Copyright (c) 2005 Voltaire, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -43,8 +45,8 @@ ...@@ -43,8 +45,8 @@
#include <linux/kref.h> #include <linux/kref.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <ib_verbs.h> #include <rdma/ib_verbs.h>
#include <ib_user_verbs.h> #include <rdma/ib_user_verbs.h>
struct ib_uverbs_device { struct ib_uverbs_device {
int devnum; int devnum;
...@@ -97,10 +99,12 @@ extern struct idr ib_uverbs_mw_idr; ...@@ -97,10 +99,12 @@ extern struct idr ib_uverbs_mw_idr;
extern struct idr ib_uverbs_ah_idr; extern struct idr ib_uverbs_ah_idr;
extern struct idr ib_uverbs_cq_idr; extern struct idr ib_uverbs_cq_idr;
extern struct idr ib_uverbs_qp_idr; extern struct idr ib_uverbs_qp_idr;
extern struct idr ib_uverbs_srq_idr;
void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context); void ib_uverbs_comp_handler(struct ib_cq *cq, void *cq_context);
void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr); void ib_uverbs_cq_event_handler(struct ib_event *event, void *context_ptr);
void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr); void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr);
void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr);
int ib_umem_get(struct ib_device *dev, struct ib_umem *mem, int ib_umem_get(struct ib_device *dev, struct ib_umem *mem,
void *addr, size_t size, int write); void *addr, size_t size, int write);
...@@ -129,5 +133,8 @@ IB_UVERBS_DECLARE_CMD(modify_qp); ...@@ -129,5 +133,8 @@ IB_UVERBS_DECLARE_CMD(modify_qp);
IB_UVERBS_DECLARE_CMD(destroy_qp); IB_UVERBS_DECLARE_CMD(destroy_qp);
IB_UVERBS_DECLARE_CMD(attach_mcast); IB_UVERBS_DECLARE_CMD(attach_mcast);
IB_UVERBS_DECLARE_CMD(detach_mcast); IB_UVERBS_DECLARE_CMD(detach_mcast);
IB_UVERBS_DECLARE_CMD(create_srq);
IB_UVERBS_DECLARE_CMD(modify_srq);
IB_UVERBS_DECLARE_CMD(destroy_srq);
#endif /* UVERBS_H */ #endif /* UVERBS_H */
...@@ -724,6 +724,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, ...@@ -724,6 +724,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
struct ib_uobject *uobj; struct ib_uobject *uobj;
struct ib_pd *pd; struct ib_pd *pd;
struct ib_cq *scq, *rcq; struct ib_cq *scq, *rcq;
struct ib_srq *srq;
struct ib_qp *qp; struct ib_qp *qp;
struct ib_qp_init_attr attr; struct ib_qp_init_attr attr;
int ret; int ret;
...@@ -747,10 +748,12 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, ...@@ -747,10 +748,12 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle); pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
scq = idr_find(&ib_uverbs_cq_idr, cmd.send_cq_handle); scq = idr_find(&ib_uverbs_cq_idr, cmd.send_cq_handle);
rcq = idr_find(&ib_uverbs_cq_idr, cmd.recv_cq_handle); rcq = idr_find(&ib_uverbs_cq_idr, cmd.recv_cq_handle);
srq = cmd.is_srq ? idr_find(&ib_uverbs_srq_idr, cmd.srq_handle) : NULL;
if (!pd || pd->uobject->context != file->ucontext || if (!pd || pd->uobject->context != file->ucontext ||
!scq || scq->uobject->context != file->ucontext || !scq || scq->uobject->context != file->ucontext ||
!rcq || rcq->uobject->context != file->ucontext) { !rcq || rcq->uobject->context != file->ucontext ||
(cmd.is_srq && (!srq || srq->uobject->context != file->ucontext))) {
ret = -EINVAL; ret = -EINVAL;
goto err_up; goto err_up;
} }
...@@ -759,7 +762,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file, ...@@ -759,7 +762,7 @@ ssize_t ib_uverbs_create_qp(struct ib_uverbs_file *file,
attr.qp_context = file; attr.qp_context = file;
attr.send_cq = scq; attr.send_cq = scq;
attr.recv_cq = rcq; attr.recv_cq = rcq;
attr.srq = NULL; attr.srq = srq;
attr.sq_sig_type = cmd.sq_sig_all ? IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR; attr.sq_sig_type = cmd.sq_sig_all ? IB_SIGNAL_ALL_WR : IB_SIGNAL_REQ_WR;
attr.qp_type = cmd.qp_type; attr.qp_type = cmd.qp_type;
...@@ -1004,3 +1007,178 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file, ...@@ -1004,3 +1007,178 @@ ssize_t ib_uverbs_detach_mcast(struct ib_uverbs_file *file,
return ret ? ret : in_len; return ret ? ret : in_len;
} }
ssize_t ib_uverbs_create_srq(struct ib_uverbs_file *file,
const char __user *buf, int in_len,
int out_len)
{
struct ib_uverbs_create_srq cmd;
struct ib_uverbs_create_srq_resp resp;
struct ib_udata udata;
struct ib_uobject *uobj;
struct ib_pd *pd;
struct ib_srq *srq;
struct ib_srq_init_attr attr;
int ret;
if (out_len < sizeof resp)
return -ENOSPC;
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
INIT_UDATA(&udata, buf + sizeof cmd,
(unsigned long) cmd.response + sizeof resp,
in_len - sizeof cmd, out_len - sizeof resp);
uobj = kmalloc(sizeof *uobj, GFP_KERNEL);
if (!uobj)
return -ENOMEM;
down(&ib_uverbs_idr_mutex);
pd = idr_find(&ib_uverbs_pd_idr, cmd.pd_handle);
if (!pd || pd->uobject->context != file->ucontext) {
ret = -EINVAL;
goto err_up;
}
attr.event_handler = ib_uverbs_srq_event_handler;
attr.srq_context = file;
attr.attr.max_wr = cmd.max_wr;
attr.attr.max_sge = cmd.max_sge;
attr.attr.srq_limit = cmd.srq_limit;
uobj->user_handle = cmd.user_handle;
uobj->context = file->ucontext;
srq = pd->device->create_srq(pd, &attr, &udata);
if (IS_ERR(srq)) {
ret = PTR_ERR(srq);
goto err_up;
}
srq->device = pd->device;
srq->pd = pd;
srq->uobject = uobj;
srq->event_handler = attr.event_handler;
srq->srq_context = attr.srq_context;
atomic_inc(&pd->usecnt);
atomic_set(&srq->usecnt, 0);
memset(&resp, 0, sizeof resp);
retry:
if (!idr_pre_get(&ib_uverbs_srq_idr, GFP_KERNEL)) {
ret = -ENOMEM;
goto err_destroy;
}
ret = idr_get_new(&ib_uverbs_srq_idr, srq, &uobj->id);
if (ret == -EAGAIN)
goto retry;
if (ret)
goto err_destroy;
resp.srq_handle = uobj->id;
spin_lock_irq(&file->ucontext->lock);
list_add_tail(&uobj->list, &file->ucontext->srq_list);
spin_unlock_irq(&file->ucontext->lock);
if (copy_to_user((void __user *) (unsigned long) cmd.response,
&resp, sizeof resp)) {
ret = -EFAULT;
goto err_list;
}
up(&ib_uverbs_idr_mutex);
return in_len;
err_list:
spin_lock_irq(&file->ucontext->lock);
list_del(&uobj->list);
spin_unlock_irq(&file->ucontext->lock);
err_destroy:
ib_destroy_srq(srq);
err_up:
up(&ib_uverbs_idr_mutex);
kfree(uobj);
return ret;
}
ssize_t ib_uverbs_modify_srq(struct ib_uverbs_file *file,
const char __user *buf, int in_len,
int out_len)
{
struct ib_uverbs_modify_srq cmd;
struct ib_srq *srq;
struct ib_srq_attr attr;
int ret;
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle);
if (!srq || srq->uobject->context != file->ucontext) {
ret = -EINVAL;
goto out;
}
attr.max_wr = cmd.max_wr;
attr.max_sge = cmd.max_sge;
attr.srq_limit = cmd.srq_limit;
ret = ib_modify_srq(srq, &attr, cmd.attr_mask);
out:
up(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file,
const char __user *buf, int in_len,
int out_len)
{
struct ib_uverbs_destroy_srq cmd;
struct ib_srq *srq;
struct ib_uobject *uobj;
int ret = -EINVAL;
if (copy_from_user(&cmd, buf, sizeof cmd))
return -EFAULT;
down(&ib_uverbs_idr_mutex);
srq = idr_find(&ib_uverbs_srq_idr, cmd.srq_handle);
if (!srq || srq->uobject->context != file->ucontext)
goto out;
uobj = srq->uobject;
ret = ib_destroy_srq(srq);
if (ret)
goto out;
idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle);
spin_lock_irq(&file->ucontext->lock);
list_del(&uobj->list);
spin_unlock_irq(&file->ucontext->lock);
kfree(uobj);
out:
up(&ib_uverbs_idr_mutex);
return ret ? ret : in_len;
}
/* /*
* Copyright (c) 2005 Topspin Communications. All rights reserved. * Copyright (c) 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* Copyright (c) 2005 Voltaire, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -67,6 +69,7 @@ DEFINE_IDR(ib_uverbs_mw_idr); ...@@ -67,6 +69,7 @@ DEFINE_IDR(ib_uverbs_mw_idr);
DEFINE_IDR(ib_uverbs_ah_idr); DEFINE_IDR(ib_uverbs_ah_idr);
DEFINE_IDR(ib_uverbs_cq_idr); DEFINE_IDR(ib_uverbs_cq_idr);
DEFINE_IDR(ib_uverbs_qp_idr); DEFINE_IDR(ib_uverbs_qp_idr);
DEFINE_IDR(ib_uverbs_srq_idr);
static spinlock_t map_lock; static spinlock_t map_lock;
static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES); static DECLARE_BITMAP(dev_map, IB_UVERBS_MAX_DEVICES);
...@@ -91,6 +94,9 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file, ...@@ -91,6 +94,9 @@ static ssize_t (*uverbs_cmd_table[])(struct ib_uverbs_file *file,
[IB_USER_VERBS_CMD_DESTROY_QP] = ib_uverbs_destroy_qp, [IB_USER_VERBS_CMD_DESTROY_QP] = ib_uverbs_destroy_qp,
[IB_USER_VERBS_CMD_ATTACH_MCAST] = ib_uverbs_attach_mcast, [IB_USER_VERBS_CMD_ATTACH_MCAST] = ib_uverbs_attach_mcast,
[IB_USER_VERBS_CMD_DETACH_MCAST] = ib_uverbs_detach_mcast, [IB_USER_VERBS_CMD_DETACH_MCAST] = ib_uverbs_detach_mcast,
[IB_USER_VERBS_CMD_CREATE_SRQ] = ib_uverbs_create_srq,
[IB_USER_VERBS_CMD_MODIFY_SRQ] = ib_uverbs_modify_srq,
[IB_USER_VERBS_CMD_DESTROY_SRQ] = ib_uverbs_destroy_srq,
}; };
static struct vfsmount *uverbs_event_mnt; static struct vfsmount *uverbs_event_mnt;
...@@ -125,7 +131,14 @@ static int ib_dealloc_ucontext(struct ib_ucontext *context) ...@@ -125,7 +131,14 @@ static int ib_dealloc_ucontext(struct ib_ucontext *context)
kfree(uobj); kfree(uobj);
} }
/* XXX Free SRQs */ list_for_each_entry_safe(uobj, tmp, &context->srq_list, list) {
struct ib_srq *srq = idr_find(&ib_uverbs_srq_idr, uobj->id);
idr_remove(&ib_uverbs_srq_idr, uobj->id);
ib_destroy_srq(srq);
list_del(&uobj->list);
kfree(uobj);
}
/* XXX Free MWs */ /* XXX Free MWs */
list_for_each_entry_safe(uobj, tmp, &context->mr_list, list) { list_for_each_entry_safe(uobj, tmp, &context->mr_list, list) {
...@@ -344,6 +357,13 @@ void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr) ...@@ -344,6 +357,13 @@ void ib_uverbs_qp_event_handler(struct ib_event *event, void *context_ptr)
event->event); event->event);
} }
void ib_uverbs_srq_event_handler(struct ib_event *event, void *context_ptr)
{
ib_uverbs_async_handler(context_ptr,
event->element.srq->uobject->user_handle,
event->event);
}
static void ib_uverbs_event_handler(struct ib_event_handler *handler, static void ib_uverbs_event_handler(struct ib_event_handler *handler,
struct ib_event *event) struct ib_event *event)
{ {
......
/* /*
* Copyright (c) 2005 Topspin Communications. All rights reserved. * Copyright (c) 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* Copyright (c) 2004 Intel Corporation. All rights reserved. * Copyright (c) 2004 Intel Corporation. All rights reserved.
* Copyright (c) 2004 Topspin Corporation. All rights reserved. * Copyright (c) 2004 Topspin Corporation. All rights reserved.
* Copyright (c) 2004 Voltaire Corporation. All rights reserved. * Copyright (c) 2004 Voltaire Corporation. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
...@@ -40,8 +41,8 @@ ...@@ -40,8 +41,8 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/err.h> #include <linux/err.h>
#include <ib_verbs.h> #include <rdma/ib_verbs.h>
#include <ib_cache.h> #include <rdma/ib_cache.h>
/* Protection domains */ /* Protection domains */
...@@ -153,6 +154,66 @@ int ib_destroy_ah(struct ib_ah *ah) ...@@ -153,6 +154,66 @@ int ib_destroy_ah(struct ib_ah *ah)
} }
EXPORT_SYMBOL(ib_destroy_ah); EXPORT_SYMBOL(ib_destroy_ah);
/* Shared receive queues */
struct ib_srq *ib_create_srq(struct ib_pd *pd,
struct ib_srq_init_attr *srq_init_attr)
{
struct ib_srq *srq;
if (!pd->device->create_srq)
return ERR_PTR(-ENOSYS);
srq = pd->device->create_srq(pd, srq_init_attr, NULL);
if (!IS_ERR(srq)) {
srq->device = pd->device;
srq->pd = pd;
srq->uobject = NULL;
srq->event_handler = srq_init_attr->event_handler;
srq->srq_context = srq_init_attr->srq_context;
atomic_inc(&pd->usecnt);
atomic_set(&srq->usecnt, 0);
}
return srq;
}
EXPORT_SYMBOL(ib_create_srq);
int ib_modify_srq(struct ib_srq *srq,
struct ib_srq_attr *srq_attr,
enum ib_srq_attr_mask srq_attr_mask)
{
return srq->device->modify_srq(srq, srq_attr, srq_attr_mask);
}
EXPORT_SYMBOL(ib_modify_srq);
int ib_query_srq(struct ib_srq *srq,
struct ib_srq_attr *srq_attr)
{
return srq->device->query_srq ?
srq->device->query_srq(srq, srq_attr) : -ENOSYS;
}
EXPORT_SYMBOL(ib_query_srq);
int ib_destroy_srq(struct ib_srq *srq)
{
struct ib_pd *pd;
int ret;
if (atomic_read(&srq->usecnt))
return -EBUSY;
pd = srq->pd;
ret = srq->device->destroy_srq(srq);
if (!ret)
atomic_dec(&pd->usecnt);
return ret;
}
EXPORT_SYMBOL(ib_destroy_srq);
/* Queue pairs */ /* Queue pairs */
struct ib_qp *ib_create_qp(struct ib_pd *pd, struct ib_qp *ib_create_qp(struct ib_pd *pd,
......
EXTRA_CFLAGS += -Idrivers/infiniband/include
ifdef CONFIG_INFINIBAND_MTHCA_DEBUG ifdef CONFIG_INFINIBAND_MTHCA_DEBUG
EXTRA_CFLAGS += -DDEBUG EXTRA_CFLAGS += -DDEBUG
endif endif
...@@ -9,4 +7,4 @@ obj-$(CONFIG_INFINIBAND_MTHCA) += ib_mthca.o ...@@ -9,4 +7,4 @@ obj-$(CONFIG_INFINIBAND_MTHCA) += ib_mthca.o
ib_mthca-y := mthca_main.o mthca_cmd.o mthca_profile.o mthca_reset.o \ ib_mthca-y := mthca_main.o mthca_cmd.o mthca_profile.o mthca_reset.o \
mthca_allocator.o mthca_eq.o mthca_pd.o mthca_cq.o \ mthca_allocator.o mthca_eq.o mthca_pd.o mthca_cq.o \
mthca_mr.o mthca_qp.o mthca_av.o mthca_mcg.o mthca_mad.o \ mthca_mr.o mthca_qp.o mthca_av.o mthca_mcg.o mthca_mad.o \
mthca_provider.o mthca_memfree.o mthca_uar.o mthca_provider.o mthca_memfree.o mthca_uar.o mthca_srq.o
...@@ -177,3 +177,119 @@ void mthca_array_cleanup(struct mthca_array *array, int nent) ...@@ -177,3 +177,119 @@ void mthca_array_cleanup(struct mthca_array *array, int nent)
kfree(array->page_list); kfree(array->page_list);
} }
/*
* Handling for queue buffers -- we allocate a bunch of memory and
* register it in a memory region at HCA virtual address 0. If the
* requested size is > max_direct, we split the allocation into
* multiple pages, so we don't require too much contiguous memory.
*/
int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
union mthca_buf *buf, int *is_direct, struct mthca_pd *pd,
int hca_write, struct mthca_mr *mr)
{
int err = -ENOMEM;
int npages, shift;
u64 *dma_list = NULL;
dma_addr_t t;
int i;
if (size <= max_direct) {
*is_direct = 1;
npages = 1;
shift = get_order(size) + PAGE_SHIFT;
buf->direct.buf = dma_alloc_coherent(&dev->pdev->dev,
size, &t, GFP_KERNEL);
if (!buf->direct.buf)
return -ENOMEM;
pci_unmap_addr_set(&buf->direct, mapping, t);
memset(buf->direct.buf, 0, size);
while (t & ((1 << shift) - 1)) {
--shift;
npages *= 2;
}
dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
if (!dma_list)
goto err_free;
for (i = 0; i < npages; ++i)
dma_list[i] = t + i * (1 << shift);
} else {
*is_direct = 0;
npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
shift = PAGE_SHIFT;
dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
if (!dma_list)
return -ENOMEM;
buf->page_list = kmalloc(npages * sizeof *buf->page_list,
GFP_KERNEL);
if (!buf->page_list)
goto err_out;
for (i = 0; i < npages; ++i)
buf->page_list[i].buf = NULL;
for (i = 0; i < npages; ++i) {
buf->page_list[i].buf =
dma_alloc_coherent(&dev->pdev->dev, PAGE_SIZE,
&t, GFP_KERNEL);
if (!buf->page_list[i].buf)
goto err_free;
dma_list[i] = t;
pci_unmap_addr_set(&buf->page_list[i], mapping, t);
memset(buf->page_list[i].buf, 0, PAGE_SIZE);
}
}
err = mthca_mr_alloc_phys(dev, pd->pd_num,
dma_list, shift, npages,
0, size,
MTHCA_MPT_FLAG_LOCAL_READ |
(hca_write ? MTHCA_MPT_FLAG_LOCAL_WRITE : 0),
mr);
if (err)
goto err_free;
kfree(dma_list);
return 0;
err_free:
mthca_buf_free(dev, size, buf, *is_direct, NULL);
err_out:
kfree(dma_list);
return err;
}
void mthca_buf_free(struct mthca_dev *dev, int size, union mthca_buf *buf,
int is_direct, struct mthca_mr *mr)
{
int i;
if (mr)
mthca_free_mr(dev, mr);
if (is_direct)
dma_free_coherent(&dev->pdev->dev, size, buf->direct.buf,
pci_unmap_addr(&buf->direct, mapping));
else {
for (i = 0; i < (size + PAGE_SIZE - 1) / PAGE_SIZE; ++i)
dma_free_coherent(&dev->pdev->dev, PAGE_SIZE,
buf->page_list[i].buf,
pci_unmap_addr(&buf->page_list[i],
mapping));
kfree(buf->page_list);
}
}
...@@ -35,22 +35,22 @@ ...@@ -35,22 +35,22 @@
#include <linux/init.h> #include <linux/init.h>
#include <ib_verbs.h> #include <rdma/ib_verbs.h>
#include <ib_cache.h> #include <rdma/ib_cache.h>
#include "mthca_dev.h" #include "mthca_dev.h"
struct mthca_av { struct mthca_av {
u32 port_pd; __be32 port_pd;
u8 reserved1; u8 reserved1;
u8 g_slid; u8 g_slid;
u16 dlid; __be16 dlid;
u8 reserved2; u8 reserved2;
u8 gid_index; u8 gid_index;
u8 msg_sr; u8 msg_sr;
u8 hop_limit; u8 hop_limit;
u32 sl_tclass_flowlabel; __be32 sl_tclass_flowlabel;
u32 dgid[4]; __be32 dgid[4];
}; };
int mthca_create_ah(struct mthca_dev *dev, int mthca_create_ah(struct mthca_dev *dev,
...@@ -128,7 +128,7 @@ int mthca_create_ah(struct mthca_dev *dev, ...@@ -128,7 +128,7 @@ int mthca_create_ah(struct mthca_dev *dev,
av, (unsigned long) ah->avdma); av, (unsigned long) ah->avdma);
for (j = 0; j < 8; ++j) for (j = 0; j < 8; ++j)
printk(KERN_DEBUG " [%2x] %08x\n", printk(KERN_DEBUG " [%2x] %08x\n",
j * 4, be32_to_cpu(((u32 *) av)[j])); j * 4, be32_to_cpu(((__be32 *) av)[j]));
} }
if (ah->type == MTHCA_AH_ON_HCA) { if (ah->type == MTHCA_AH_ON_HCA) {
...@@ -169,7 +169,7 @@ int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah, ...@@ -169,7 +169,7 @@ int mthca_read_ah(struct mthca_dev *dev, struct mthca_ah *ah,
header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28; header->lrh.service_level = be32_to_cpu(ah->av->sl_tclass_flowlabel) >> 28;
header->lrh.destination_lid = ah->av->dlid; header->lrh.destination_lid = ah->av->dlid;
header->lrh.source_lid = ah->av->g_slid & 0x7f; header->lrh.source_lid = cpu_to_be16(ah->av->g_slid & 0x7f);
if (ah->av->g_slid & 0x80) { if (ah->av->g_slid & 0x80) {
header->grh_present = 1; header->grh_present = 1;
header->grh.traffic_class = header->grh.traffic_class =
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/io.h> #include <asm/io.h>
#include <ib_mad.h> #include <rdma/ib_mad.h>
#include "mthca_dev.h" #include "mthca_dev.h"
#include "mthca_config_reg.h" #include "mthca_config_reg.h"
...@@ -108,6 +109,7 @@ enum { ...@@ -108,6 +109,7 @@ enum {
CMD_SW2HW_SRQ = 0x35, CMD_SW2HW_SRQ = 0x35,
CMD_HW2SW_SRQ = 0x36, CMD_HW2SW_SRQ = 0x36,
CMD_QUERY_SRQ = 0x37, CMD_QUERY_SRQ = 0x37,
CMD_ARM_SRQ = 0x40,
/* QP/EE commands */ /* QP/EE commands */
CMD_RST2INIT_QPEE = 0x19, CMD_RST2INIT_QPEE = 0x19,
...@@ -219,20 +221,20 @@ static int mthca_cmd_post(struct mthca_dev *dev, ...@@ -219,20 +221,20 @@ static int mthca_cmd_post(struct mthca_dev *dev,
* (and some architectures such as ia64 implement memcpy_toio * (and some architectures such as ia64 implement memcpy_toio
* in terms of writeb). * in terms of writeb).
*/ */
__raw_writel(cpu_to_be32(in_param >> 32), dev->hcr + 0 * 4); __raw_writel((__force u32) cpu_to_be32(in_param >> 32), dev->hcr + 0 * 4);
__raw_writel(cpu_to_be32(in_param & 0xfffffffful), dev->hcr + 1 * 4); __raw_writel((__force u32) cpu_to_be32(in_param & 0xfffffffful), dev->hcr + 1 * 4);
__raw_writel(cpu_to_be32(in_modifier), dev->hcr + 2 * 4); __raw_writel((__force u32) cpu_to_be32(in_modifier), dev->hcr + 2 * 4);
__raw_writel(cpu_to_be32(out_param >> 32), dev->hcr + 3 * 4); __raw_writel((__force u32) cpu_to_be32(out_param >> 32), dev->hcr + 3 * 4);
__raw_writel(cpu_to_be32(out_param & 0xfffffffful), dev->hcr + 4 * 4); __raw_writel((__force u32) cpu_to_be32(out_param & 0xfffffffful), dev->hcr + 4 * 4);
__raw_writel(cpu_to_be32(token << 16), dev->hcr + 5 * 4); __raw_writel((__force u32) cpu_to_be32(token << 16), dev->hcr + 5 * 4);
/* __raw_writel may not order writes. */ /* __raw_writel may not order writes. */
wmb(); wmb();
__raw_writel(cpu_to_be32((1 << HCR_GO_BIT) | __raw_writel((__force u32) cpu_to_be32((1 << HCR_GO_BIT) |
(event ? (1 << HCA_E_BIT) : 0) | (event ? (1 << HCA_E_BIT) : 0) |
(op_modifier << HCR_OPMOD_SHIFT) | (op_modifier << HCR_OPMOD_SHIFT) |
op), dev->hcr + 6 * 4); op), dev->hcr + 6 * 4);
out: out:
up(&dev->cmd.hcr_sem); up(&dev->cmd.hcr_sem);
...@@ -273,12 +275,14 @@ static int mthca_cmd_poll(struct mthca_dev *dev, ...@@ -273,12 +275,14 @@ static int mthca_cmd_poll(struct mthca_dev *dev,
goto out; goto out;
} }
if (out_is_imm) { if (out_is_imm)
memcpy_fromio(out_param, dev->hcr + HCR_OUT_PARAM_OFFSET, sizeof (u64)); *out_param =
be64_to_cpus(out_param); (u64) be32_to_cpu((__force __be32)
} __raw_readl(dev->hcr + HCR_OUT_PARAM_OFFSET)) << 32 |
(u64) be32_to_cpu((__force __be32)
__raw_readl(dev->hcr + HCR_OUT_PARAM_OFFSET + 4));
*status = be32_to_cpu(__raw_readl(dev->hcr + HCR_STATUS_OFFSET)) >> 24; *status = be32_to_cpu((__force __be32) __raw_readl(dev->hcr + HCR_STATUS_OFFSET)) >> 24;
out: out:
up(&dev->cmd.poll_sem); up(&dev->cmd.poll_sem);
...@@ -1029,6 +1033,8 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev, ...@@ -1029,6 +1033,8 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
mthca_dbg(dev, "Max QPs: %d, reserved QPs: %d, entry size: %d\n", mthca_dbg(dev, "Max QPs: %d, reserved QPs: %d, entry size: %d\n",
dev_lim->max_qps, dev_lim->reserved_qps, dev_lim->qpc_entry_sz); dev_lim->max_qps, dev_lim->reserved_qps, dev_lim->qpc_entry_sz);
mthca_dbg(dev, "Max SRQs: %d, reserved SRQs: %d, entry size: %d\n",
dev_lim->max_srqs, dev_lim->reserved_srqs, dev_lim->srq_entry_sz);
mthca_dbg(dev, "Max CQs: %d, reserved CQs: %d, entry size: %d\n", mthca_dbg(dev, "Max CQs: %d, reserved CQs: %d, entry size: %d\n",
dev_lim->max_cqs, dev_lim->reserved_cqs, dev_lim->cqc_entry_sz); dev_lim->max_cqs, dev_lim->reserved_cqs, dev_lim->cqc_entry_sz);
mthca_dbg(dev, "Max EQs: %d, reserved EQs: %d, entry size: %d\n", mthca_dbg(dev, "Max EQs: %d, reserved EQs: %d, entry size: %d\n",
...@@ -1082,6 +1088,34 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev, ...@@ -1082,6 +1088,34 @@ int mthca_QUERY_DEV_LIM(struct mthca_dev *dev,
return err; return err;
} }
static void get_board_id(void *vsd, char *board_id)
{
int i;
#define VSD_OFFSET_SIG1 0x00
#define VSD_OFFSET_SIG2 0xde
#define VSD_OFFSET_MLX_BOARD_ID 0xd0
#define VSD_OFFSET_TS_BOARD_ID 0x20
#define VSD_SIGNATURE_TOPSPIN 0x5ad
memset(board_id, 0, MTHCA_BOARD_ID_LEN);
if (be16_to_cpup(vsd + VSD_OFFSET_SIG1) == VSD_SIGNATURE_TOPSPIN &&
be16_to_cpup(vsd + VSD_OFFSET_SIG2) == VSD_SIGNATURE_TOPSPIN) {
strlcpy(board_id, vsd + VSD_OFFSET_TS_BOARD_ID, MTHCA_BOARD_ID_LEN);
} else {
/*
* The board ID is a string but the firmware byte
* swaps each 4-byte word before passing it back to
* us. Therefore we need to swab it before printing.
*/
for (i = 0; i < 4; ++i)
((u32 *) board_id)[i] =
swab32(*(u32 *) (vsd + VSD_OFFSET_MLX_BOARD_ID + i * 4));
}
}
int mthca_QUERY_ADAPTER(struct mthca_dev *dev, int mthca_QUERY_ADAPTER(struct mthca_dev *dev,
struct mthca_adapter *adapter, u8 *status) struct mthca_adapter *adapter, u8 *status)
{ {
...@@ -1094,6 +1128,7 @@ int mthca_QUERY_ADAPTER(struct mthca_dev *dev, ...@@ -1094,6 +1128,7 @@ int mthca_QUERY_ADAPTER(struct mthca_dev *dev,
#define QUERY_ADAPTER_DEVICE_ID_OFFSET 0x04 #define QUERY_ADAPTER_DEVICE_ID_OFFSET 0x04
#define QUERY_ADAPTER_REVISION_ID_OFFSET 0x08 #define QUERY_ADAPTER_REVISION_ID_OFFSET 0x08
#define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10 #define QUERY_ADAPTER_INTA_PIN_OFFSET 0x10
#define QUERY_ADAPTER_VSD_OFFSET 0x20
mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
if (IS_ERR(mailbox)) if (IS_ERR(mailbox))
...@@ -1111,6 +1146,9 @@ int mthca_QUERY_ADAPTER(struct mthca_dev *dev, ...@@ -1111,6 +1146,9 @@ int mthca_QUERY_ADAPTER(struct mthca_dev *dev,
MTHCA_GET(adapter->revision_id, outbox, QUERY_ADAPTER_REVISION_ID_OFFSET); MTHCA_GET(adapter->revision_id, outbox, QUERY_ADAPTER_REVISION_ID_OFFSET);
MTHCA_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET); MTHCA_GET(adapter->inta_pin, outbox, QUERY_ADAPTER_INTA_PIN_OFFSET);
get_board_id(outbox + QUERY_ADAPTER_VSD_OFFSET / 4,
adapter->board_id);
out: out:
mthca_free_mailbox(dev, mailbox); mthca_free_mailbox(dev, mailbox);
return err; return err;
...@@ -1121,7 +1159,7 @@ int mthca_INIT_HCA(struct mthca_dev *dev, ...@@ -1121,7 +1159,7 @@ int mthca_INIT_HCA(struct mthca_dev *dev,
u8 *status) u8 *status)
{ {
struct mthca_mailbox *mailbox; struct mthca_mailbox *mailbox;
u32 *inbox; __be32 *inbox;
int err; int err;
#define INIT_HCA_IN_SIZE 0x200 #define INIT_HCA_IN_SIZE 0x200
...@@ -1247,10 +1285,8 @@ int mthca_INIT_IB(struct mthca_dev *dev, ...@@ -1247,10 +1285,8 @@ int mthca_INIT_IB(struct mthca_dev *dev,
#define INIT_IB_FLAG_SIG (1 << 18) #define INIT_IB_FLAG_SIG (1 << 18)
#define INIT_IB_FLAG_NG (1 << 17) #define INIT_IB_FLAG_NG (1 << 17)
#define INIT_IB_FLAG_G0 (1 << 16) #define INIT_IB_FLAG_G0 (1 << 16)
#define INIT_IB_FLAG_1X (1 << 8)
#define INIT_IB_FLAG_4X (1 << 9)
#define INIT_IB_FLAG_12X (1 << 11)
#define INIT_IB_VL_SHIFT 4 #define INIT_IB_VL_SHIFT 4
#define INIT_IB_PORT_WIDTH_SHIFT 8
#define INIT_IB_MTU_SHIFT 12 #define INIT_IB_MTU_SHIFT 12
#define INIT_IB_MAX_GID_OFFSET 0x06 #define INIT_IB_MAX_GID_OFFSET 0x06
#define INIT_IB_MAX_PKEY_OFFSET 0x0a #define INIT_IB_MAX_PKEY_OFFSET 0x0a
...@@ -1266,12 +1302,11 @@ int mthca_INIT_IB(struct mthca_dev *dev, ...@@ -1266,12 +1302,11 @@ int mthca_INIT_IB(struct mthca_dev *dev,
memset(inbox, 0, INIT_IB_IN_SIZE); memset(inbox, 0, INIT_IB_IN_SIZE);
flags = 0; flags = 0;
flags |= param->enable_1x ? INIT_IB_FLAG_1X : 0;
flags |= param->enable_4x ? INIT_IB_FLAG_4X : 0;
flags |= param->set_guid0 ? INIT_IB_FLAG_G0 : 0; flags |= param->set_guid0 ? INIT_IB_FLAG_G0 : 0;
flags |= param->set_node_guid ? INIT_IB_FLAG_NG : 0; flags |= param->set_node_guid ? INIT_IB_FLAG_NG : 0;
flags |= param->set_si_guid ? INIT_IB_FLAG_SIG : 0; flags |= param->set_si_guid ? INIT_IB_FLAG_SIG : 0;
flags |= param->vl_cap << INIT_IB_VL_SHIFT; flags |= param->vl_cap << INIT_IB_VL_SHIFT;
flags |= param->port_width << INIT_IB_PORT_WIDTH_SHIFT;
flags |= param->mtu_cap << INIT_IB_MTU_SHIFT; flags |= param->mtu_cap << INIT_IB_MTU_SHIFT;
MTHCA_PUT(inbox, flags, INIT_IB_FLAGS_OFFSET); MTHCA_PUT(inbox, flags, INIT_IB_FLAGS_OFFSET);
...@@ -1342,7 +1377,7 @@ int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt, u8 *st ...@@ -1342,7 +1377,7 @@ int mthca_MAP_ICM(struct mthca_dev *dev, struct mthca_icm *icm, u64 virt, u8 *st
int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt, u8 *status) int mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt, u8 *status)
{ {
struct mthca_mailbox *mailbox; struct mthca_mailbox *mailbox;
u64 *inbox; __be64 *inbox;
int err; int err;
mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL); mailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);
...@@ -1468,6 +1503,27 @@ int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox, ...@@ -1468,6 +1503,27 @@ int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
CMD_TIME_CLASS_A, status); CMD_TIME_CLASS_A, status);
} }
int mthca_SW2HW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
int srq_num, u8 *status)
{
return mthca_cmd(dev, mailbox->dma, srq_num, 0, CMD_SW2HW_SRQ,
CMD_TIME_CLASS_A, status);
}
int mthca_HW2SW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
int srq_num, u8 *status)
{
return mthca_cmd_box(dev, 0, mailbox->dma, srq_num, 0,
CMD_HW2SW_SRQ,
CMD_TIME_CLASS_A, status);
}
int mthca_ARM_SRQ(struct mthca_dev *dev, int srq_num, int limit, u8 *status)
{
return mthca_cmd(dev, limit, srq_num, 0, CMD_ARM_SRQ,
CMD_TIME_CLASS_B, status);
}
int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num, int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num,
int is_ee, struct mthca_mailbox *mailbox, u32 optmask, int is_ee, struct mthca_mailbox *mailbox, u32 optmask,
u8 *status) u8 *status)
...@@ -1513,7 +1569,7 @@ int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num, ...@@ -1513,7 +1569,7 @@ int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num,
if (i % 8 == 0) if (i % 8 == 0)
printk(" [%02x] ", i * 4); printk(" [%02x] ", i * 4);
printk(" %08x", printk(" %08x",
be32_to_cpu(((u32 *) mailbox->buf)[i + 2])); be32_to_cpu(((__be32 *) mailbox->buf)[i + 2]));
if ((i + 1) % 8 == 0) if ((i + 1) % 8 == 0)
printk("\n"); printk("\n");
} }
...@@ -1533,7 +1589,7 @@ int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num, ...@@ -1533,7 +1589,7 @@ int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num,
if (i % 8 == 0) if (i % 8 == 0)
printk("[%02x] ", i * 4); printk("[%02x] ", i * 4);
printk(" %08x", printk(" %08x",
be32_to_cpu(((u32 *) mailbox->buf)[i + 2])); be32_to_cpu(((__be32 *) mailbox->buf)[i + 2]));
if ((i + 1) % 8 == 0) if ((i + 1) % 8 == 0)
printk("\n"); printk("\n");
} }
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -35,7 +36,7 @@ ...@@ -35,7 +36,7 @@
#ifndef MTHCA_CMD_H #ifndef MTHCA_CMD_H
#define MTHCA_CMD_H #define MTHCA_CMD_H
#include <ib_verbs.h> #include <rdma/ib_verbs.h>
#define MTHCA_MAILBOX_SIZE 4096 #define MTHCA_MAILBOX_SIZE 4096
...@@ -183,10 +184,11 @@ struct mthca_dev_lim { ...@@ -183,10 +184,11 @@ struct mthca_dev_lim {
}; };
struct mthca_adapter { struct mthca_adapter {
u32 vendor_id; u32 vendor_id;
u32 device_id; u32 device_id;
u32 revision_id; u32 revision_id;
u8 inta_pin; char board_id[MTHCA_BOARD_ID_LEN];
u8 inta_pin;
}; };
struct mthca_init_hca_param { struct mthca_init_hca_param {
...@@ -218,8 +220,7 @@ struct mthca_init_hca_param { ...@@ -218,8 +220,7 @@ struct mthca_init_hca_param {
}; };
struct mthca_init_ib_param { struct mthca_init_ib_param {
int enable_1x; int port_width;
int enable_4x;
int vl_cap; int vl_cap;
int mtu_cap; int mtu_cap;
u16 gid_cap; u16 gid_cap;
...@@ -297,6 +298,11 @@ int mthca_SW2HW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox, ...@@ -297,6 +298,11 @@ int mthca_SW2HW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
int cq_num, u8 *status); int cq_num, u8 *status);
int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox, int mthca_HW2SW_CQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
int cq_num, u8 *status); int cq_num, u8 *status);
int mthca_SW2HW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
int srq_num, u8 *status);
int mthca_HW2SW_SRQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
int srq_num, u8 *status);
int mthca_ARM_SRQ(struct mthca_dev *dev, int srq_num, int limit, u8 *status);
int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num, int mthca_MODIFY_QP(struct mthca_dev *dev, int trans, u32 num,
int is_ee, struct mthca_mailbox *mailbox, u32 optmask, int is_ee, struct mthca_mailbox *mailbox, u32 optmask,
u8 *status); u8 *status);
......
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
......
This diff is collapsed.
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* Copyright (c) 2004 Voltaire, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -66,6 +68,10 @@ enum { ...@@ -66,6 +68,10 @@ enum {
MTHCA_MAX_PORTS = 2 MTHCA_MAX_PORTS = 2
}; };
enum {
MTHCA_BOARD_ID_LEN = 64
};
enum { enum {
MTHCA_EQ_CONTEXT_SIZE = 0x40, MTHCA_EQ_CONTEXT_SIZE = 0x40,
MTHCA_CQ_CONTEXT_SIZE = 0x40, MTHCA_CQ_CONTEXT_SIZE = 0x40,
...@@ -142,6 +148,7 @@ struct mthca_limits { ...@@ -142,6 +148,7 @@ struct mthca_limits {
int reserved_mcgs; int reserved_mcgs;
int num_pds; int num_pds;
int reserved_pds; int reserved_pds;
u8 port_width_cap;
}; };
struct mthca_alloc { struct mthca_alloc {
...@@ -211,6 +218,13 @@ struct mthca_cq_table { ...@@ -211,6 +218,13 @@ struct mthca_cq_table {
struct mthca_icm_table *table; struct mthca_icm_table *table;
}; };
struct mthca_srq_table {
struct mthca_alloc alloc;
spinlock_t lock;
struct mthca_array srq;
struct mthca_icm_table *table;
};
struct mthca_qp_table { struct mthca_qp_table {
struct mthca_alloc alloc; struct mthca_alloc alloc;
u32 rdb_base; u32 rdb_base;
...@@ -246,6 +260,7 @@ struct mthca_dev { ...@@ -246,6 +260,7 @@ struct mthca_dev {
unsigned long device_cap_flags; unsigned long device_cap_flags;
u32 rev_id; u32 rev_id;
char board_id[MTHCA_BOARD_ID_LEN];
/* firmware info */ /* firmware info */
u64 fw_ver; u64 fw_ver;
...@@ -291,6 +306,7 @@ struct mthca_dev { ...@@ -291,6 +306,7 @@ struct mthca_dev {
struct mthca_mr_table mr_table; struct mthca_mr_table mr_table;
struct mthca_eq_table eq_table; struct mthca_eq_table eq_table;
struct mthca_cq_table cq_table; struct mthca_cq_table cq_table;
struct mthca_srq_table srq_table;
struct mthca_qp_table qp_table; struct mthca_qp_table qp_table;
struct mthca_av_table av_table; struct mthca_av_table av_table;
struct mthca_mcg_table mcg_table; struct mthca_mcg_table mcg_table;
...@@ -331,14 +347,13 @@ extern void __buggy_use_of_MTHCA_PUT(void); ...@@ -331,14 +347,13 @@ extern void __buggy_use_of_MTHCA_PUT(void);
#define MTHCA_PUT(dest, source, offset) \ #define MTHCA_PUT(dest, source, offset) \
do { \ do { \
__typeof__(source) *__p = \ void *__d = ((char *) (dest) + (offset)); \
(__typeof__(source) *) ((char *) (dest) + (offset)); \
switch (sizeof(source)) { \ switch (sizeof(source)) { \
case 1: *__p = (source); break; \ case 1: *(u8 *) __d = (source); break; \
case 2: *__p = cpu_to_be16(source); break; \ case 2: *(__be16 *) __d = cpu_to_be16(source); break; \
case 4: *__p = cpu_to_be32(source); break; \ case 4: *(__be32 *) __d = cpu_to_be32(source); break; \
case 8: *__p = cpu_to_be64(source); break; \ case 8: *(__be64 *) __d = cpu_to_be64(source); break; \
default: __buggy_use_of_MTHCA_PUT(); \ default: __buggy_use_of_MTHCA_PUT(); \
} \ } \
} while (0) } while (0)
...@@ -354,12 +369,18 @@ int mthca_array_set(struct mthca_array *array, int index, void *value); ...@@ -354,12 +369,18 @@ int mthca_array_set(struct mthca_array *array, int index, void *value);
void mthca_array_clear(struct mthca_array *array, int index); void mthca_array_clear(struct mthca_array *array, int index);
int mthca_array_init(struct mthca_array *array, int nent); int mthca_array_init(struct mthca_array *array, int nent);
void mthca_array_cleanup(struct mthca_array *array, int nent); void mthca_array_cleanup(struct mthca_array *array, int nent);
int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
union mthca_buf *buf, int *is_direct, struct mthca_pd *pd,
int hca_write, struct mthca_mr *mr);
void mthca_buf_free(struct mthca_dev *dev, int size, union mthca_buf *buf,
int is_direct, struct mthca_mr *mr);
int mthca_init_uar_table(struct mthca_dev *dev); int mthca_init_uar_table(struct mthca_dev *dev);
int mthca_init_pd_table(struct mthca_dev *dev); int mthca_init_pd_table(struct mthca_dev *dev);
int mthca_init_mr_table(struct mthca_dev *dev); int mthca_init_mr_table(struct mthca_dev *dev);
int mthca_init_eq_table(struct mthca_dev *dev); int mthca_init_eq_table(struct mthca_dev *dev);
int mthca_init_cq_table(struct mthca_dev *dev); int mthca_init_cq_table(struct mthca_dev *dev);
int mthca_init_srq_table(struct mthca_dev *dev);
int mthca_init_qp_table(struct mthca_dev *dev); int mthca_init_qp_table(struct mthca_dev *dev);
int mthca_init_av_table(struct mthca_dev *dev); int mthca_init_av_table(struct mthca_dev *dev);
int mthca_init_mcg_table(struct mthca_dev *dev); int mthca_init_mcg_table(struct mthca_dev *dev);
...@@ -369,6 +390,7 @@ void mthca_cleanup_pd_table(struct mthca_dev *dev); ...@@ -369,6 +390,7 @@ void mthca_cleanup_pd_table(struct mthca_dev *dev);
void mthca_cleanup_mr_table(struct mthca_dev *dev); void mthca_cleanup_mr_table(struct mthca_dev *dev);
void mthca_cleanup_eq_table(struct mthca_dev *dev); void mthca_cleanup_eq_table(struct mthca_dev *dev);
void mthca_cleanup_cq_table(struct mthca_dev *dev); void mthca_cleanup_cq_table(struct mthca_dev *dev);
void mthca_cleanup_srq_table(struct mthca_dev *dev);
void mthca_cleanup_qp_table(struct mthca_dev *dev); void mthca_cleanup_qp_table(struct mthca_dev *dev);
void mthca_cleanup_av_table(struct mthca_dev *dev); void mthca_cleanup_av_table(struct mthca_dev *dev);
void mthca_cleanup_mcg_table(struct mthca_dev *dev); void mthca_cleanup_mcg_table(struct mthca_dev *dev);
...@@ -419,7 +441,19 @@ int mthca_init_cq(struct mthca_dev *dev, int nent, ...@@ -419,7 +441,19 @@ int mthca_init_cq(struct mthca_dev *dev, int nent,
void mthca_free_cq(struct mthca_dev *dev, void mthca_free_cq(struct mthca_dev *dev,
struct mthca_cq *cq); struct mthca_cq *cq);
void mthca_cq_event(struct mthca_dev *dev, u32 cqn); void mthca_cq_event(struct mthca_dev *dev, u32 cqn);
void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn); void mthca_cq_clean(struct mthca_dev *dev, u32 cqn, u32 qpn,
struct mthca_srq *srq);
int mthca_alloc_srq(struct mthca_dev *dev, struct mthca_pd *pd,
struct ib_srq_attr *attr, struct mthca_srq *srq);
void mthca_free_srq(struct mthca_dev *dev, struct mthca_srq *srq);
void mthca_srq_event(struct mthca_dev *dev, u32 srqn,
enum ib_event_type event_type);
void mthca_free_srq_wqe(struct mthca_srq *srq, u32 wqe_addr);
int mthca_tavor_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
struct ib_recv_wr **bad_wr);
int mthca_arbel_post_srq_recv(struct ib_srq *srq, struct ib_recv_wr *wr,
struct ib_recv_wr **bad_wr);
void mthca_qp_event(struct mthca_dev *dev, u32 qpn, void mthca_qp_event(struct mthca_dev *dev, u32 qpn,
enum ib_event_type event_type); enum ib_event_type event_type);
...@@ -433,7 +467,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, ...@@ -433,7 +467,7 @@ int mthca_arbel_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr, int mthca_arbel_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
struct ib_recv_wr **bad_wr); struct ib_recv_wr **bad_wr);
int mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send, int mthca_free_err_wqe(struct mthca_dev *dev, struct mthca_qp *qp, int is_send,
int index, int *dbd, u32 *new_wqe); int index, int *dbd, __be32 *new_wqe);
int mthca_alloc_qp(struct mthca_dev *dev, int mthca_alloc_qp(struct mthca_dev *dev,
struct mthca_pd *pd, struct mthca_pd *pd,
struct mthca_cq *send_cq, struct mthca_cq *send_cq,
......
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -57,13 +58,13 @@ static inline void mthca_write64_raw(__be64 val, void __iomem *dest) ...@@ -57,13 +58,13 @@ static inline void mthca_write64_raw(__be64 val, void __iomem *dest)
__raw_writeq((__force u64) val, dest); __raw_writeq((__force u64) val, dest);
} }
static inline void mthca_write64(u32 val[2], void __iomem *dest, static inline void mthca_write64(__be32 val[2], void __iomem *dest,
spinlock_t *doorbell_lock) spinlock_t *doorbell_lock)
{ {
__raw_writeq(*(u64 *) val, dest); __raw_writeq(*(u64 *) val, dest);
} }
static inline void mthca_write_db_rec(u32 val[2], u32 *db) static inline void mthca_write_db_rec(__be32 val[2], __be32 *db)
{ {
*(u64 *) db = *(u64 *) val; *(u64 *) db = *(u64 *) val;
} }
...@@ -86,18 +87,18 @@ static inline void mthca_write64_raw(__be64 val, void __iomem *dest) ...@@ -86,18 +87,18 @@ static inline void mthca_write64_raw(__be64 val, void __iomem *dest)
__raw_writel(((__force u32 *) &val)[1], dest + 4); __raw_writel(((__force u32 *) &val)[1], dest + 4);
} }
static inline void mthca_write64(u32 val[2], void __iomem *dest, static inline void mthca_write64(__be32 val[2], void __iomem *dest,
spinlock_t *doorbell_lock) spinlock_t *doorbell_lock)
{ {
unsigned long flags; unsigned long flags;
spin_lock_irqsave(doorbell_lock, flags); spin_lock_irqsave(doorbell_lock, flags);
__raw_writel(val[0], dest); __raw_writel((__force u32) val[0], dest);
__raw_writel(val[1], dest + 4); __raw_writel((__force u32) val[1], dest + 4);
spin_unlock_irqrestore(doorbell_lock, flags); spin_unlock_irqrestore(doorbell_lock, flags);
} }
static inline void mthca_write_db_rec(u32 val[2], u32 *db) static inline void mthca_write_db_rec(__be32 val[2], __be32 *db)
{ {
db[0] = val[0]; db[0] = val[0];
wmb(); wmb();
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -51,18 +52,18 @@ enum { ...@@ -51,18 +52,18 @@ enum {
* Must be packed because start is 64 bits but only aligned to 32 bits. * Must be packed because start is 64 bits but only aligned to 32 bits.
*/ */
struct mthca_eq_context { struct mthca_eq_context {
u32 flags; __be32 flags;
u64 start; __be64 start;
u32 logsize_usrpage; __be32 logsize_usrpage;
u32 tavor_pd; /* reserved for Arbel */ __be32 tavor_pd; /* reserved for Arbel */
u8 reserved1[3]; u8 reserved1[3];
u8 intr; u8 intr;
u32 arbel_pd; /* lost_count for Tavor */ __be32 arbel_pd; /* lost_count for Tavor */
u32 lkey; __be32 lkey;
u32 reserved2[2]; u32 reserved2[2];
u32 consumer_index; __be32 consumer_index;
u32 producer_index; __be32 producer_index;
u32 reserved3[4]; u32 reserved3[4];
} __attribute__((packed)); } __attribute__((packed));
#define MTHCA_EQ_STATUS_OK ( 0 << 28) #define MTHCA_EQ_STATUS_OK ( 0 << 28)
...@@ -127,28 +128,28 @@ struct mthca_eqe { ...@@ -127,28 +128,28 @@ struct mthca_eqe {
union { union {
u32 raw[6]; u32 raw[6];
struct { struct {
u32 cqn; __be32 cqn;
} __attribute__((packed)) comp; } __attribute__((packed)) comp;
struct { struct {
u16 reserved1; u16 reserved1;
u16 token; __be16 token;
u32 reserved2; u32 reserved2;
u8 reserved3[3]; u8 reserved3[3];
u8 status; u8 status;
u64 out_param; __be64 out_param;
} __attribute__((packed)) cmd; } __attribute__((packed)) cmd;
struct { struct {
u32 qpn; __be32 qpn;
} __attribute__((packed)) qp; } __attribute__((packed)) qp;
struct { struct {
u32 cqn; __be32 cqn;
u32 reserved1; u32 reserved1;
u8 reserved2[3]; u8 reserved2[3];
u8 syndrome; u8 syndrome;
} __attribute__((packed)) cq_err; } __attribute__((packed)) cq_err;
struct { struct {
u32 reserved1[2]; u32 reserved1[2];
u32 port; __be32 port;
} __attribute__((packed)) port_change; } __attribute__((packed)) port_change;
} event; } event;
u8 reserved3[3]; u8 reserved3[3];
...@@ -167,7 +168,7 @@ static inline u64 async_mask(struct mthca_dev *dev) ...@@ -167,7 +168,7 @@ static inline u64 async_mask(struct mthca_dev *dev)
static inline void tavor_set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci) static inline void tavor_set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci)
{ {
u32 doorbell[2]; __be32 doorbell[2];
doorbell[0] = cpu_to_be32(MTHCA_EQ_DB_SET_CI | eq->eqn); doorbell[0] = cpu_to_be32(MTHCA_EQ_DB_SET_CI | eq->eqn);
doorbell[1] = cpu_to_be32(ci & (eq->nent - 1)); doorbell[1] = cpu_to_be32(ci & (eq->nent - 1));
...@@ -190,8 +191,8 @@ static inline void arbel_set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u ...@@ -190,8 +191,8 @@ static inline void arbel_set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u
{ {
/* See comment in tavor_set_eq_ci() above. */ /* See comment in tavor_set_eq_ci() above. */
wmb(); wmb();
__raw_writel(cpu_to_be32(ci), dev->eq_regs.arbel.eq_set_ci_base + __raw_writel((__force u32) cpu_to_be32(ci),
eq->eqn * 8); dev->eq_regs.arbel.eq_set_ci_base + eq->eqn * 8);
/* We still want ordering, just not swabbing, so add a barrier */ /* We still want ordering, just not swabbing, so add a barrier */
mb(); mb();
} }
...@@ -206,7 +207,7 @@ static inline void set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci) ...@@ -206,7 +207,7 @@ static inline void set_eq_ci(struct mthca_dev *dev, struct mthca_eq *eq, u32 ci)
static inline void tavor_eq_req_not(struct mthca_dev *dev, int eqn) static inline void tavor_eq_req_not(struct mthca_dev *dev, int eqn)
{ {
u32 doorbell[2]; __be32 doorbell[2];
doorbell[0] = cpu_to_be32(MTHCA_EQ_DB_REQ_NOT | eqn); doorbell[0] = cpu_to_be32(MTHCA_EQ_DB_REQ_NOT | eqn);
doorbell[1] = 0; doorbell[1] = 0;
...@@ -224,7 +225,7 @@ static inline void arbel_eq_req_not(struct mthca_dev *dev, u32 eqn_mask) ...@@ -224,7 +225,7 @@ static inline void arbel_eq_req_not(struct mthca_dev *dev, u32 eqn_mask)
static inline void disarm_cq(struct mthca_dev *dev, int eqn, int cqn) static inline void disarm_cq(struct mthca_dev *dev, int eqn, int cqn)
{ {
if (!mthca_is_memfree(dev)) { if (!mthca_is_memfree(dev)) {
u32 doorbell[2]; __be32 doorbell[2];
doorbell[0] = cpu_to_be32(MTHCA_EQ_DB_DISARM_CQ | eqn); doorbell[0] = cpu_to_be32(MTHCA_EQ_DB_DISARM_CQ | eqn);
doorbell[1] = cpu_to_be32(cqn); doorbell[1] = cpu_to_be32(cqn);
......
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* Copyright (c) 2004 Voltaire, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -32,9 +34,9 @@ ...@@ -32,9 +34,9 @@
* $Id: mthca_mad.c 1349 2004-12-16 21:09:43Z roland $ * $Id: mthca_mad.c 1349 2004-12-16 21:09:43Z roland $
*/ */
#include <ib_verbs.h> #include <rdma/ib_verbs.h>
#include <ib_mad.h> #include <rdma/ib_mad.h>
#include <ib_smi.h> #include <rdma/ib_smi.h>
#include "mthca_dev.h" #include "mthca_dev.h"
#include "mthca_cmd.h" #include "mthca_cmd.h"
...@@ -192,7 +194,7 @@ int mthca_process_mad(struct ib_device *ibdev, ...@@ -192,7 +194,7 @@ int mthca_process_mad(struct ib_device *ibdev,
{ {
int err; int err;
u8 status; u8 status;
u16 slid = in_wc ? in_wc->slid : IB_LID_PERMISSIVE; u16 slid = in_wc ? in_wc->slid : be16_to_cpu(IB_LID_PERMISSIVE);
/* Forward locally generated traps to the SM */ /* Forward locally generated traps to the SM */
if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP && if (in_mad->mad_hdr.method == IB_MGMT_METHOD_TRAP &&
......
This diff is collapsed.
...@@ -42,10 +42,10 @@ enum { ...@@ -42,10 +42,10 @@ enum {
}; };
struct mthca_mgm { struct mthca_mgm {
u32 next_gid_index; __be32 next_gid_index;
u32 reserved[3]; u32 reserved[3];
u8 gid[16]; u8 gid[16];
u32 qp[MTHCA_QP_PER_MGM]; __be32 qp[MTHCA_QP_PER_MGM];
}; };
static const u8 zero_gid[16]; /* automatically initialized to 0 */ static const u8 zero_gid[16]; /* automatically initialized to 0 */
...@@ -94,10 +94,14 @@ static int find_mgm(struct mthca_dev *dev, ...@@ -94,10 +94,14 @@ static int find_mgm(struct mthca_dev *dev,
if (0) if (0)
mthca_dbg(dev, "Hash for %04x:%04x:%04x:%04x:" mthca_dbg(dev, "Hash for %04x:%04x:%04x:%04x:"
"%04x:%04x:%04x:%04x is %04x\n", "%04x:%04x:%04x:%04x is %04x\n",
be16_to_cpu(((u16 *) gid)[0]), be16_to_cpu(((u16 *) gid)[1]), be16_to_cpu(((__be16 *) gid)[0]),
be16_to_cpu(((u16 *) gid)[2]), be16_to_cpu(((u16 *) gid)[3]), be16_to_cpu(((__be16 *) gid)[1]),
be16_to_cpu(((u16 *) gid)[4]), be16_to_cpu(((u16 *) gid)[5]), be16_to_cpu(((__be16 *) gid)[2]),
be16_to_cpu(((u16 *) gid)[6]), be16_to_cpu(((u16 *) gid)[7]), be16_to_cpu(((__be16 *) gid)[3]),
be16_to_cpu(((__be16 *) gid)[4]),
be16_to_cpu(((__be16 *) gid)[5]),
be16_to_cpu(((__be16 *) gid)[6]),
be16_to_cpu(((__be16 *) gid)[7]),
*hash); *hash);
*index = *hash; *index = *hash;
...@@ -258,14 +262,14 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) ...@@ -258,14 +262,14 @@ int mthca_multicast_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
if (index == -1) { if (index == -1) {
mthca_err(dev, "MGID %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x " mthca_err(dev, "MGID %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x "
"not found\n", "not found\n",
be16_to_cpu(((u16 *) gid->raw)[0]), be16_to_cpu(((__be16 *) gid->raw)[0]),
be16_to_cpu(((u16 *) gid->raw)[1]), be16_to_cpu(((__be16 *) gid->raw)[1]),
be16_to_cpu(((u16 *) gid->raw)[2]), be16_to_cpu(((__be16 *) gid->raw)[2]),
be16_to_cpu(((u16 *) gid->raw)[3]), be16_to_cpu(((__be16 *) gid->raw)[3]),
be16_to_cpu(((u16 *) gid->raw)[4]), be16_to_cpu(((__be16 *) gid->raw)[4]),
be16_to_cpu(((u16 *) gid->raw)[5]), be16_to_cpu(((__be16 *) gid->raw)[5]),
be16_to_cpu(((u16 *) gid->raw)[6]), be16_to_cpu(((__be16 *) gid->raw)[6]),
be16_to_cpu(((u16 *) gid->raw)[7])); be16_to_cpu(((__be16 *) gid->raw)[7]));
err = -EINVAL; err = -EINVAL;
goto out; goto out;
} }
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -285,6 +286,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, ...@@ -285,6 +286,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
{ {
struct mthca_icm_table *table; struct mthca_icm_table *table;
int num_icm; int num_icm;
unsigned chunk_size;
int i; int i;
u8 status; u8 status;
...@@ -305,7 +307,11 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, ...@@ -305,7 +307,11 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev,
table->icm[i] = NULL; table->icm[i] = NULL;
for (i = 0; i * MTHCA_TABLE_CHUNK_SIZE < reserved * obj_size; ++i) { for (i = 0; i * MTHCA_TABLE_CHUNK_SIZE < reserved * obj_size; ++i) {
table->icm[i] = mthca_alloc_icm(dev, MTHCA_TABLE_CHUNK_SIZE >> PAGE_SHIFT, chunk_size = MTHCA_TABLE_CHUNK_SIZE;
if ((i + 1) * MTHCA_TABLE_CHUNK_SIZE > nobj * obj_size)
chunk_size = nobj * obj_size - i * MTHCA_TABLE_CHUNK_SIZE;
table->icm[i] = mthca_alloc_icm(dev, chunk_size >> PAGE_SHIFT,
(use_lowmem ? GFP_KERNEL : GFP_HIGHUSER) | (use_lowmem ? GFP_KERNEL : GFP_HIGHUSER) |
__GFP_NOWARN); __GFP_NOWARN);
if (!table->icm[i]) if (!table->icm[i])
...@@ -481,7 +487,7 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar, ...@@ -481,7 +487,7 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar,
} }
} }
int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, u32 **db) int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db)
{ {
int group; int group;
int start, end, dir; int start, end, dir;
...@@ -564,7 +570,7 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, u32 **db) ...@@ -564,7 +570,7 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, u32 **db)
page->db_rec[j] = cpu_to_be64((qn << 8) | (type << 5)); page->db_rec[j] = cpu_to_be64((qn << 8) | (type << 5));
*db = (u32 *) &page->db_rec[j]; *db = (__be32 *) &page->db_rec[j];
out: out:
up(&dev->db_tab->mutex); up(&dev->db_tab->mutex);
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -137,7 +138,7 @@ enum { ...@@ -137,7 +138,7 @@ enum {
struct mthca_db_page { struct mthca_db_page {
DECLARE_BITMAP(used, MTHCA_DB_REC_PER_PAGE); DECLARE_BITMAP(used, MTHCA_DB_REC_PER_PAGE);
u64 *db_rec; __be64 *db_rec;
dma_addr_t mapping; dma_addr_t mapping;
}; };
...@@ -172,7 +173,7 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar, ...@@ -172,7 +173,7 @@ void mthca_cleanup_user_db_tab(struct mthca_dev *dev, struct mthca_uar *uar,
int mthca_init_db_tab(struct mthca_dev *dev); int mthca_init_db_tab(struct mthca_dev *dev);
void mthca_cleanup_db_tab(struct mthca_dev *dev); void mthca_cleanup_db_tab(struct mthca_dev *dev);
int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, u32 **db); int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db);
void mthca_free_db(struct mthca_dev *dev, int type, int db_index); void mthca_free_db(struct mthca_dev *dev, int type, int db_index);
#endif /* MTHCA_MEMFREE_H */ #endif /* MTHCA_MEMFREE_H */
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -50,18 +51,18 @@ struct mthca_mtt { ...@@ -50,18 +51,18 @@ struct mthca_mtt {
* Must be packed because mtt_seg is 64 bits but only aligned to 32 bits. * Must be packed because mtt_seg is 64 bits but only aligned to 32 bits.
*/ */
struct mthca_mpt_entry { struct mthca_mpt_entry {
u32 flags; __be32 flags;
u32 page_size; __be32 page_size;
u32 key; __be32 key;
u32 pd; __be32 pd;
u64 start; __be64 start;
u64 length; __be64 length;
u32 lkey; __be32 lkey;
u32 window_count; __be32 window_count;
u32 window_count_limit; __be32 window_count_limit;
u64 mtt_seg; __be64 mtt_seg;
u32 mtt_sz; /* Arbel only */ __be32 mtt_sz; /* Arbel only */
u32 reserved[2]; u32 reserved[2];
} __attribute__((packed)); } __attribute__((packed));
#define MTHCA_MPT_FLAG_SW_OWNS (0xfUL << 28) #define MTHCA_MPT_FLAG_SW_OWNS (0xfUL << 28)
...@@ -247,7 +248,7 @@ int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt, ...@@ -247,7 +248,7 @@ int mthca_write_mtt(struct mthca_dev *dev, struct mthca_mtt *mtt,
int start_index, u64 *buffer_list, int list_len) int start_index, u64 *buffer_list, int list_len)
{ {
struct mthca_mailbox *mailbox; struct mthca_mailbox *mailbox;
u64 *mtt_entry; __be64 *mtt_entry;
int err = 0; int err = 0;
u8 status; u8 status;
int i; int i;
...@@ -389,7 +390,7 @@ int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift, ...@@ -389,7 +390,7 @@ int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) { for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) {
if (i % 4 == 0) if (i % 4 == 0)
printk("[%02x] ", i * 4); printk("[%02x] ", i * 4);
printk(" %08x", be32_to_cpu(((u32 *) mpt_entry)[i])); printk(" %08x", be32_to_cpu(((__be32 *) mpt_entry)[i]));
if ((i + 1) % 4 == 0) if ((i + 1) % 4 == 0)
printk("\n"); printk("\n");
} }
...@@ -458,7 +459,7 @@ int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd, ...@@ -458,7 +459,7 @@ int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
static void mthca_free_region(struct mthca_dev *dev, u32 lkey) static void mthca_free_region(struct mthca_dev *dev, u32 lkey)
{ {
mthca_table_put(dev, dev->mr_table.mpt_table, mthca_table_put(dev, dev->mr_table.mpt_table,
arbel_key_to_hw_index(lkey)); key_to_hw_index(dev, lkey));
mthca_free(&dev->mr_table.mpt_alloc, key_to_hw_index(dev, lkey)); mthca_free(&dev->mr_table.mpt_alloc, key_to_hw_index(dev, lkey));
} }
...@@ -562,7 +563,7 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd, ...@@ -562,7 +563,7 @@ int mthca_fmr_alloc(struct mthca_dev *dev, u32 pd,
for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) { for (i = 0; i < sizeof (struct mthca_mpt_entry) / 4; ++i) {
if (i % 4 == 0) if (i % 4 == 0)
printk("[%02x] ", i * 4); printk("[%02x] ", i * 4);
printk(" %08x", be32_to_cpu(((u32 *) mpt_entry)[i])); printk(" %08x", be32_to_cpu(((__be32 *) mpt_entry)[i]));
if ((i + 1) % 4 == 0) if ((i + 1) % 4 == 0)
printk("\n"); printk("\n");
} }
...@@ -669,7 +670,7 @@ int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list, ...@@ -669,7 +670,7 @@ int mthca_tavor_map_phys_fmr(struct ib_fmr *ibfmr, u64 *page_list,
mpt_entry.length = cpu_to_be64(list_len * (1ull << fmr->attr.page_size)); mpt_entry.length = cpu_to_be64(list_len * (1ull << fmr->attr.page_size));
mpt_entry.start = cpu_to_be64(iova); mpt_entry.start = cpu_to_be64(iova);
writel(mpt_entry.lkey, &fmr->mem.tavor.mpt->key); __raw_writel((__force u32) mpt_entry.lkey, &fmr->mem.tavor.mpt->key);
memcpy_toio(&fmr->mem.tavor.mpt->start, &mpt_entry.start, memcpy_toio(&fmr->mem.tavor.mpt->start, &mpt_entry.start,
offsetof(struct mthca_mpt_entry, window_count) - offsetof(struct mthca_mpt_entry, window_count) -
offsetof(struct mthca_mpt_entry, start)); offsetof(struct mthca_mpt_entry, start));
......
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -101,6 +102,7 @@ u64 mthca_make_profile(struct mthca_dev *dev, ...@@ -101,6 +102,7 @@ u64 mthca_make_profile(struct mthca_dev *dev,
profile[MTHCA_RES_UARC].size = request->uarc_size; profile[MTHCA_RES_UARC].size = request->uarc_size;
profile[MTHCA_RES_QP].num = request->num_qp; profile[MTHCA_RES_QP].num = request->num_qp;
profile[MTHCA_RES_SRQ].num = request->num_srq;
profile[MTHCA_RES_EQP].num = request->num_qp; profile[MTHCA_RES_EQP].num = request->num_qp;
profile[MTHCA_RES_RDB].num = request->num_qp * request->rdb_per_qp; profile[MTHCA_RES_RDB].num = request->num_qp * request->rdb_per_qp;
profile[MTHCA_RES_CQ].num = request->num_cq; profile[MTHCA_RES_CQ].num = request->num_cq;
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -41,6 +42,7 @@ ...@@ -41,6 +42,7 @@
struct mthca_profile { struct mthca_profile {
int num_qp; int num_qp;
int rdb_per_qp; int rdb_per_qp;
int num_srq;
int num_cq; int num_cq;
int num_mcg; int num_mcg;
int num_mpt; int num_mpt;
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* Copyright (c) 2004 Voltaire, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -34,7 +36,7 @@ ...@@ -34,7 +36,7 @@
* $Id: mthca_provider.c 1397 2004-12-28 05:09:00Z roland $ * $Id: mthca_provider.c 1397 2004-12-28 05:09:00Z roland $
*/ */
#include <ib_smi.h> #include <rdma/ib_smi.h>
#include <linux/mm.h> #include <linux/mm.h>
#include "mthca_dev.h" #include "mthca_dev.h"
...@@ -79,10 +81,10 @@ static int mthca_query_device(struct ib_device *ibdev, ...@@ -79,10 +81,10 @@ static int mthca_query_device(struct ib_device *ibdev,
} }
props->device_cap_flags = mdev->device_cap_flags; props->device_cap_flags = mdev->device_cap_flags;
props->vendor_id = be32_to_cpup((u32 *) (out_mad->data + 36)) & props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) &
0xffffff; 0xffffff;
props->vendor_part_id = be16_to_cpup((u16 *) (out_mad->data + 30)); props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30));
props->hw_ver = be16_to_cpup((u16 *) (out_mad->data + 32)); props->hw_ver = be16_to_cpup((__be16 *) (out_mad->data + 32));
memcpy(&props->sys_image_guid, out_mad->data + 4, 8); memcpy(&props->sys_image_guid, out_mad->data + 4, 8);
memcpy(&props->node_guid, out_mad->data + 12, 8); memcpy(&props->node_guid, out_mad->data + 12, 8);
...@@ -118,6 +120,8 @@ static int mthca_query_port(struct ib_device *ibdev, ...@@ -118,6 +120,8 @@ static int mthca_query_port(struct ib_device *ibdev,
if (!in_mad || !out_mad) if (!in_mad || !out_mad)
goto out; goto out;
memset(props, 0, sizeof *props);
memset(in_mad, 0, sizeof *in_mad); memset(in_mad, 0, sizeof *in_mad);
in_mad->base_version = 1; in_mad->base_version = 1;
in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED; in_mad->mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
...@@ -136,16 +140,17 @@ static int mthca_query_port(struct ib_device *ibdev, ...@@ -136,16 +140,17 @@ static int mthca_query_port(struct ib_device *ibdev,
goto out; goto out;
} }
props->lid = be16_to_cpup((u16 *) (out_mad->data + 16)); props->lid = be16_to_cpup((__be16 *) (out_mad->data + 16));
props->lmc = out_mad->data[34] & 0x7; props->lmc = out_mad->data[34] & 0x7;
props->sm_lid = be16_to_cpup((u16 *) (out_mad->data + 18)); props->sm_lid = be16_to_cpup((__be16 *) (out_mad->data + 18));
props->sm_sl = out_mad->data[36] & 0xf; props->sm_sl = out_mad->data[36] & 0xf;
props->state = out_mad->data[32] & 0xf; props->state = out_mad->data[32] & 0xf;
props->phys_state = out_mad->data[33] >> 4; props->phys_state = out_mad->data[33] >> 4;
props->port_cap_flags = be32_to_cpup((u32 *) (out_mad->data + 20)); props->port_cap_flags = be32_to_cpup((__be32 *) (out_mad->data + 20));
props->gid_tbl_len = to_mdev(ibdev)->limits.gid_table_len; props->gid_tbl_len = to_mdev(ibdev)->limits.gid_table_len;
props->max_msg_sz = 0x80000000;
props->pkey_tbl_len = to_mdev(ibdev)->limits.pkey_table_len; props->pkey_tbl_len = to_mdev(ibdev)->limits.pkey_table_len;
props->qkey_viol_cntr = be16_to_cpup((u16 *) (out_mad->data + 48)); props->qkey_viol_cntr = be16_to_cpup((__be16 *) (out_mad->data + 48));
props->active_width = out_mad->data[31] & 0xf; props->active_width = out_mad->data[31] & 0xf;
props->active_speed = out_mad->data[35] >> 4; props->active_speed = out_mad->data[35] >> 4;
...@@ -221,7 +226,7 @@ static int mthca_query_pkey(struct ib_device *ibdev, ...@@ -221,7 +226,7 @@ static int mthca_query_pkey(struct ib_device *ibdev,
goto out; goto out;
} }
*pkey = be16_to_cpu(((u16 *) out_mad->data)[index % 32]); *pkey = be16_to_cpu(((__be16 *) out_mad->data)[index % 32]);
out: out:
kfree(in_mad); kfree(in_mad);
...@@ -420,6 +425,77 @@ static int mthca_ah_destroy(struct ib_ah *ah) ...@@ -420,6 +425,77 @@ static int mthca_ah_destroy(struct ib_ah *ah)
return 0; return 0;
} }
static struct ib_srq *mthca_create_srq(struct ib_pd *pd,
struct ib_srq_init_attr *init_attr,
struct ib_udata *udata)
{
struct mthca_create_srq ucmd;
struct mthca_ucontext *context = NULL;
struct mthca_srq *srq;
int err;
srq = kmalloc(sizeof *srq, GFP_KERNEL);
if (!srq)
return ERR_PTR(-ENOMEM);
if (pd->uobject) {
context = to_mucontext(pd->uobject->context);
if (ib_copy_from_udata(&ucmd, udata, sizeof ucmd))
return ERR_PTR(-EFAULT);
err = mthca_map_user_db(to_mdev(pd->device), &context->uar,
context->db_tab, ucmd.db_index,
ucmd.db_page);
if (err)
goto err_free;
srq->mr.ibmr.lkey = ucmd.lkey;
srq->db_index = ucmd.db_index;
}
err = mthca_alloc_srq(to_mdev(pd->device), to_mpd(pd),
&init_attr->attr, srq);
if (err && pd->uobject)
mthca_unmap_user_db(to_mdev(pd->device), &context->uar,
context->db_tab, ucmd.db_index);
if (err)
goto err_free;
if (context && ib_copy_to_udata(udata, &srq->srqn, sizeof (__u32))) {
mthca_free_srq(to_mdev(pd->device), srq);
err = -EFAULT;
goto err_free;
}
return &srq->ibsrq;
err_free:
kfree(srq);
return ERR_PTR(err);
}
static int mthca_destroy_srq(struct ib_srq *srq)
{
struct mthca_ucontext *context;
if (srq->uobject) {
context = to_mucontext(srq->uobject->context);
mthca_unmap_user_db(to_mdev(srq->device), &context->uar,
context->db_tab, to_msrq(srq)->db_index);
}
mthca_free_srq(to_mdev(srq->device), to_msrq(srq));
kfree(srq);
return 0;
}
static struct ib_qp *mthca_create_qp(struct ib_pd *pd, static struct ib_qp *mthca_create_qp(struct ib_pd *pd,
struct ib_qp_init_attr *init_attr, struct ib_qp_init_attr *init_attr,
struct ib_udata *udata) struct ib_udata *udata)
...@@ -956,14 +1032,22 @@ static ssize_t show_hca(struct class_device *cdev, char *buf) ...@@ -956,14 +1032,22 @@ static ssize_t show_hca(struct class_device *cdev, char *buf)
} }
} }
static ssize_t show_board(struct class_device *cdev, char *buf)
{
struct mthca_dev *dev = container_of(cdev, struct mthca_dev, ib_dev.class_dev);
return sprintf(buf, "%.*s\n", MTHCA_BOARD_ID_LEN, dev->board_id);
}
static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); static CLASS_DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); static CLASS_DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); static CLASS_DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
static CLASS_DEVICE_ATTR(board_id, S_IRUGO, show_board, NULL);
static struct class_device_attribute *mthca_class_attributes[] = { static struct class_device_attribute *mthca_class_attributes[] = {
&class_device_attr_hw_rev, &class_device_attr_hw_rev,
&class_device_attr_fw_ver, &class_device_attr_fw_ver,
&class_device_attr_hca_type &class_device_attr_hca_type,
&class_device_attr_board_id
}; };
int mthca_register_device(struct mthca_dev *dev) int mthca_register_device(struct mthca_dev *dev)
...@@ -990,6 +1074,17 @@ int mthca_register_device(struct mthca_dev *dev) ...@@ -990,6 +1074,17 @@ int mthca_register_device(struct mthca_dev *dev)
dev->ib_dev.dealloc_pd = mthca_dealloc_pd; dev->ib_dev.dealloc_pd = mthca_dealloc_pd;
dev->ib_dev.create_ah = mthca_ah_create; dev->ib_dev.create_ah = mthca_ah_create;
dev->ib_dev.destroy_ah = mthca_ah_destroy; dev->ib_dev.destroy_ah = mthca_ah_destroy;
if (dev->mthca_flags & MTHCA_FLAG_SRQ) {
dev->ib_dev.create_srq = mthca_create_srq;
dev->ib_dev.destroy_srq = mthca_destroy_srq;
if (mthca_is_memfree(dev))
dev->ib_dev.post_srq_recv = mthca_arbel_post_srq_recv;
else
dev->ib_dev.post_srq_recv = mthca_tavor_post_srq_recv;
}
dev->ib_dev.create_qp = mthca_create_qp; dev->ib_dev.create_qp = mthca_create_qp;
dev->ib_dev.modify_qp = mthca_modify_qp; dev->ib_dev.modify_qp = mthca_modify_qp;
dev->ib_dev.destroy_qp = mthca_destroy_qp; dev->ib_dev.destroy_qp = mthca_destroy_qp;
......
/* /*
* Copyright (c) 2004 Topspin Communications. All rights reserved. * Copyright (c) 2004 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Cisco Systems. All rights reserved. * Copyright (c) 2005 Cisco Systems. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -36,8 +37,8 @@ ...@@ -36,8 +37,8 @@
#ifndef MTHCA_PROVIDER_H #ifndef MTHCA_PROVIDER_H
#define MTHCA_PROVIDER_H #define MTHCA_PROVIDER_H
#include <ib_verbs.h> #include <rdma/ib_verbs.h>
#include <ib_pack.h> #include <rdma/ib_pack.h>
#define MTHCA_MPT_FLAG_ATOMIC (1 << 14) #define MTHCA_MPT_FLAG_ATOMIC (1 << 14)
#define MTHCA_MPT_FLAG_REMOTE_WRITE (1 << 13) #define MTHCA_MPT_FLAG_REMOTE_WRITE (1 << 13)
...@@ -50,6 +51,11 @@ struct mthca_buf_list { ...@@ -50,6 +51,11 @@ struct mthca_buf_list {
DECLARE_PCI_UNMAP_ADDR(mapping) DECLARE_PCI_UNMAP_ADDR(mapping)
}; };
union mthca_buf {
struct mthca_buf_list direct;
struct mthca_buf_list *page_list;
};
struct mthca_uar { struct mthca_uar {
unsigned long pfn; unsigned long pfn;
int index; int index;
...@@ -181,19 +187,39 @@ struct mthca_cq { ...@@ -181,19 +187,39 @@ struct mthca_cq {
/* Next fields are Arbel only */ /* Next fields are Arbel only */
int set_ci_db_index; int set_ci_db_index;
u32 *set_ci_db; __be32 *set_ci_db;
int arm_db_index; int arm_db_index;
u32 *arm_db; __be32 *arm_db;
int arm_sn; int arm_sn;
union { union mthca_buf queue;
struct mthca_buf_list direct;
struct mthca_buf_list *page_list;
} queue;
struct mthca_mr mr; struct mthca_mr mr;
wait_queue_head_t wait; wait_queue_head_t wait;
}; };
struct mthca_srq {
struct ib_srq ibsrq;
spinlock_t lock;
atomic_t refcount;
int srqn;
int max;
int max_gs;
int wqe_shift;
int first_free;
int last_free;
u16 counter; /* Arbel only */
int db_index; /* Arbel only */
__be32 *db; /* Arbel only */
void *last;
int is_direct;
u64 *wrid;
union mthca_buf queue;
struct mthca_mr mr;
wait_queue_head_t wait;
};
struct mthca_wq { struct mthca_wq {
spinlock_t lock; spinlock_t lock;
int max; int max;
...@@ -206,7 +232,7 @@ struct mthca_wq { ...@@ -206,7 +232,7 @@ struct mthca_wq {
int wqe_shift; int wqe_shift;
int db_index; /* Arbel only */ int db_index; /* Arbel only */
u32 *db; __be32 *db;
}; };
struct mthca_qp { struct mthca_qp {
...@@ -227,10 +253,7 @@ struct mthca_qp { ...@@ -227,10 +253,7 @@ struct mthca_qp {
int send_wqe_offset; int send_wqe_offset;
u64 *wrid; u64 *wrid;
union { union mthca_buf queue;
struct mthca_buf_list direct;
struct mthca_buf_list *page_list;
} queue;
wait_queue_head_t wait; wait_queue_head_t wait;
}; };
...@@ -277,6 +300,11 @@ static inline struct mthca_cq *to_mcq(struct ib_cq *ibcq) ...@@ -277,6 +300,11 @@ static inline struct mthca_cq *to_mcq(struct ib_cq *ibcq)
return container_of(ibcq, struct mthca_cq, ibcq); return container_of(ibcq, struct mthca_cq, ibcq);
} }
static inline struct mthca_srq *to_msrq(struct ib_srq *ibsrq)
{
return container_of(ibsrq, struct mthca_srq, ibsrq);
}
static inline struct mthca_qp *to_mqp(struct ib_qp *ibqp) static inline struct mthca_qp *to_mqp(struct ib_qp *ibqp)
{ {
return container_of(ibqp, struct mthca_qp, ibqp); return container_of(ibqp, struct mthca_qp, ibqp);
......
This diff is collapsed.
This diff is collapsed.
...@@ -69,6 +69,17 @@ struct mthca_create_cq_resp { ...@@ -69,6 +69,17 @@ struct mthca_create_cq_resp {
__u32 reserved; __u32 reserved;
}; };
struct mthca_create_srq {
__u32 lkey;
__u32 db_index;
__u64 db_page;
};
struct mthca_create_srq_resp {
__u32 srqn;
__u32 reserved;
};
struct mthca_create_qp { struct mthca_create_qp {
__u32 lkey; __u32 lkey;
__u32 reserved; __u32 reserved;
......
/*
* Copyright (c) 2005 Cisco Systems. All rights reserved.
*
* This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU
* General Public License (GPL) Version 2, available from the file
* COPYING in the main directory of this source tree, or the
* OpenIB.org BSD license below:
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met:
*
* - Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* - Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* $Id: mthca_wqe.h 3047 2005-08-10 03:59:35Z roland $
*/
#ifndef MTHCA_WQE_H
#define MTHCA_WQE_H
#include <linux/types.h>
enum {
MTHCA_NEXT_DBD = 1 << 7,
MTHCA_NEXT_FENCE = 1 << 6,
MTHCA_NEXT_CQ_UPDATE = 1 << 3,
MTHCA_NEXT_EVENT_GEN = 1 << 2,
MTHCA_NEXT_SOLICIT = 1 << 1,
MTHCA_MLX_VL15 = 1 << 17,
MTHCA_MLX_SLR = 1 << 16
};
enum {
MTHCA_INVAL_LKEY = 0x100
};
struct mthca_next_seg {
__be32 nda_op; /* [31:6] next WQE [4:0] next opcode */
__be32 ee_nds; /* [31:8] next EE [7] DBD [6] F [5:0] next WQE size */
__be32 flags; /* [3] CQ [2] Event [1] Solicit */
__be32 imm; /* immediate data */
};
struct mthca_tavor_ud_seg {
u32 reserved1;
__be32 lkey;
__be64 av_addr;
u32 reserved2[4];
__be32 dqpn;
__be32 qkey;
u32 reserved3[2];
};
struct mthca_arbel_ud_seg {
__be32 av[8];
__be32 dqpn;
__be32 qkey;
u32 reserved[2];
};
struct mthca_bind_seg {
__be32 flags; /* [31] Atomic [30] rem write [29] rem read */
u32 reserved;
__be32 new_rkey;
__be32 lkey;
__be64 addr;
__be64 length;
};
struct mthca_raddr_seg {
__be64 raddr;
__be32 rkey;
u32 reserved;
};
struct mthca_atomic_seg {
__be64 swap_add;
__be64 compare;
};
struct mthca_data_seg {
__be32 byte_count;
__be32 lkey;
__be64 addr;
};
struct mthca_mlx_seg {
__be32 nda_op;
__be32 nds;
__be32 flags; /* [17] VL15 [16] SLR [14:12] static rate
[11:8] SL [3] C [2] E */
__be16 rlid;
__be16 vcrc;
};
#endif /* MTHCA_WQE_H */
EXTRA_CFLAGS += -Idrivers/infiniband/include
obj-$(CONFIG_INFINIBAND_IPOIB) += ib_ipoib.o obj-$(CONFIG_INFINIBAND_IPOIB) += ib_ipoib.o
ib_ipoib-y := ipoib_main.o \ ib_ipoib-y := ipoib_main.o \
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2004 Voltaire, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -49,9 +51,9 @@ ...@@ -49,9 +51,9 @@
#include <asm/atomic.h> #include <asm/atomic.h>
#include <asm/semaphore.h> #include <asm/semaphore.h>
#include <ib_verbs.h> #include <rdma/ib_verbs.h>
#include <ib_pack.h> #include <rdma/ib_pack.h>
#include <ib_sa.h> #include <rdma/ib_sa.h>
/* constants */ /* constants */
...@@ -88,8 +90,8 @@ enum { ...@@ -88,8 +90,8 @@ enum {
/* structs */ /* structs */
struct ipoib_header { struct ipoib_header {
u16 proto; __be16 proto;
u16 reserved; u16 reserved;
}; };
struct ipoib_pseudoheader { struct ipoib_pseudoheader {
......
...@@ -97,7 +97,7 @@ static int ipoib_mcg_seq_show(struct seq_file *file, void *iter_ptr) ...@@ -97,7 +97,7 @@ static int ipoib_mcg_seq_show(struct seq_file *file, void *iter_ptr)
for (n = 0, i = 0; i < sizeof mgid / 2; ++i) { for (n = 0, i = 0; i < sizeof mgid / 2; ++i) {
n += sprintf(gid_buf + n, "%x", n += sprintf(gid_buf + n, "%x",
be16_to_cpu(((u16 *)mgid.raw)[i])); be16_to_cpu(((__be16 *) mgid.raw)[i]));
if (i < sizeof mgid / 2 - 1) if (i < sizeof mgid / 2 - 1)
gid_buf[n++] = ':'; gid_buf[n++] = ':';
} }
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -35,7 +38,7 @@ ...@@ -35,7 +38,7 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <ib_cache.h> #include <rdma/ib_cache.h>
#include "ipoib.h" #include "ipoib.h"
......
This diff is collapsed.
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved.
* Copyright (c) 2004 Voltaire, Inc. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -357,7 +359,7 @@ static int ipoib_mcast_sendonly_join(struct ipoib_mcast *mcast) ...@@ -357,7 +359,7 @@ static int ipoib_mcast_sendonly_join(struct ipoib_mcast *mcast)
rec.mgid = mcast->mcmember.mgid; rec.mgid = mcast->mcmember.mgid;
rec.port_gid = priv->local_gid; rec.port_gid = priv->local_gid;
rec.pkey = be16_to_cpu(priv->pkey); rec.pkey = cpu_to_be16(priv->pkey);
ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec, ret = ib_sa_mcmember_rec_set(priv->ca, priv->port, &rec,
IB_SA_MCMEMBER_REC_MGID | IB_SA_MCMEMBER_REC_MGID |
...@@ -457,7 +459,7 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast, ...@@ -457,7 +459,7 @@ static void ipoib_mcast_join(struct net_device *dev, struct ipoib_mcast *mcast,
rec.mgid = mcast->mcmember.mgid; rec.mgid = mcast->mcmember.mgid;
rec.port_gid = priv->local_gid; rec.port_gid = priv->local_gid;
rec.pkey = be16_to_cpu(priv->pkey); rec.pkey = cpu_to_be16(priv->pkey);
comp_mask = comp_mask =
IB_SA_MCMEMBER_REC_MGID | IB_SA_MCMEMBER_REC_MGID |
...@@ -646,7 +648,7 @@ static int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast) ...@@ -646,7 +648,7 @@ static int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
rec.mgid = mcast->mcmember.mgid; rec.mgid = mcast->mcmember.mgid;
rec.port_gid = priv->local_gid; rec.port_gid = priv->local_gid;
rec.pkey = be16_to_cpu(priv->pkey); rec.pkey = cpu_to_be16(priv->pkey);
/* Remove ourselves from the multicast group */ /* Remove ourselves from the multicast group */
ret = ipoib_mcast_detach(dev, be16_to_cpu(mcast->mcmember.mlid), ret = ipoib_mcast_detach(dev, be16_to_cpu(mcast->mcmember.mlid),
......
/* /*
* Copyright (c) 2004, 2005 Topspin Communications. All rights reserved. * Copyright (c) 2004, 2005 Topspin Communications. All rights reserved.
* Copyright (c) 2005 Mellanox Technologies. All rights reserved.
* *
* This software is available to you under a choice of one of two * This software is available to you under a choice of one of two
* licenses. You may choose to be licensed under the terms of the GNU * licenses. You may choose to be licensed under the terms of the GNU
...@@ -32,7 +33,7 @@ ...@@ -32,7 +33,7 @@
* $Id: ipoib_verbs.c 1349 2004-12-16 21:09:43Z roland $ * $Id: ipoib_verbs.c 1349 2004-12-16 21:09:43Z roland $
*/ */
#include <ib_cache.h> #include <rdma/ib_cache.h>
#include "ipoib.h" #include "ipoib.h"
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment