aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/infiniband
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2008-07-18 05:39:39 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-18 05:39:39 -0400
commit49997d75152b3d23c53b0fa730599f2f74c92c65 (patch)
tree46e93126170d02cfec9505172e545732c1b69656 /drivers/infiniband
parenta0c80b80e0fb48129e4e9d6a9ede914f9ff1850d (diff)
parent5b664cb235e97afbf34db9c4d77f08ebd725335e (diff)
Merge branch 'master' of master.kernel.org:/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts: Documentation/powerpc/booting-without-of.txt drivers/atm/Makefile drivers/net/fs_enet/fs_enet-main.c drivers/pci/pci-acpi.c net/8021q/vlan.c net/iucv/iucv.c
Diffstat (limited to 'drivers/infiniband')
-rw-r--r--drivers/infiniband/core/addr.c42
-rw-r--r--drivers/infiniband/core/agent.h2
-rw-r--r--drivers/infiniband/core/cache.c2
-rw-r--r--drivers/infiniband/core/cm.c2
-rw-r--r--drivers/infiniband/core/cma.c162
-rw-r--r--drivers/infiniband/core/core_priv.h2
-rw-r--r--drivers/infiniband/core/device.c2
-rw-r--r--drivers/infiniband/core/fmr_pool.c2
-rw-r--r--drivers/infiniband/core/mad_priv.h2
-rw-r--r--drivers/infiniband/core/mad_rmpp.c2
-rw-r--r--drivers/infiniband/core/mad_rmpp.h2
-rw-r--r--drivers/infiniband/core/packer.c2
-rw-r--r--drivers/infiniband/core/sa_query.c24
-rw-r--r--drivers/infiniband/core/sysfs.c122
-rw-r--r--drivers/infiniband/core/ucm.c4
-rw-r--r--drivers/infiniband/core/ucma.c3
-rw-r--r--drivers/infiniband/core/ud_header.c2
-rw-r--r--drivers/infiniband/core/umem.c2
-rw-r--r--drivers/infiniband/core/user_mad.c15
-rw-r--r--drivers/infiniband/core/uverbs.h2
-rw-r--r--drivers/infiniband/core/uverbs_cmd.c4
-rw-r--r--drivers/infiniband/core/uverbs_main.c15
-rw-r--r--drivers/infiniband/core/verbs.c49
-rw-r--r--drivers/infiniband/hw/amso1100/c2_rnic.c2
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.c27
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_hal.h5
-rw-r--r--drivers/infiniband/hw/cxgb3/cxio_wr.h103
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch.c8
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch.h2
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_cq.c15
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.c203
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_provider.h8
-rw-r--r--drivers/infiniband/hw/cxgb3/iwch_qp.c261
-rw-r--r--drivers/infiniband/hw/ehca/ehca_irq.c9
-rw-r--r--drivers/infiniband/hw/ehca/ehca_main.c1
-rw-r--r--drivers/infiniband/hw/ehca/ehca_reqs.c14
-rw-r--r--drivers/infiniband/hw/ehca/hcp_if.c10
-rw-r--r--drivers/infiniband/hw/ehca/hcp_if.h1
-rw-r--r--drivers/infiniband/hw/ipath/ipath_cq.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_file_ops.c2
-rw-r--r--drivers/infiniband/hw/ipath/ipath_iba7220.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_mad.c6
-rw-r--r--drivers/infiniband/hw/ipath/ipath_rc.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ruc.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_uc.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_ud.c8
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs.c4
-rw-r--r--drivers/infiniband/hw/ipath/ipath_verbs_mcast.c3
-rw-r--r--drivers/infiniband/hw/mlx4/cq.c12
-rw-r--r--drivers/infiniband/hw/mlx4/mad.c3
-rw-r--r--drivers/infiniband/hw/mlx4/main.c7
-rw-r--r--drivers/infiniband/hw/mlx4/mlx4_ib.h3
-rw-r--r--drivers/infiniband/hw/mlx4/qp.c73
-rw-r--r--drivers/infiniband/hw/mthca/mthca_allocator.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_av.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_catas.c17
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cmd.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_config_reg.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_cq.c6
-rw-r--r--drivers/infiniband/hw/mthca/mthca_dev.h3
-rw-r--r--drivers/infiniband/hw/mthca/mthca_doorbell.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_eq.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mad.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_main.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mcg.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_memfree.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_mr.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_pd.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_profile.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_profile.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_provider.h2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_qp.c32
-rw-r--r--drivers/infiniband/hw/mthca/mthca_reset.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_srq.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_uar.c2
-rw-r--r--drivers/infiniband/hw/mthca/mthca_user.h1
-rw-r--r--drivers/infiniband/hw/mthca/mthca_wqe.h2
-rw-r--r--drivers/infiniband/hw/nes/nes.c2
-rw-r--r--drivers/infiniband/hw/nes/nes.h9
-rw-r--r--drivers/infiniband/hw/nes/nes_cm.c1
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.c68
-rw-r--r--drivers/infiniband/hw/nes/nes_hw.h2
-rw-r--r--drivers/infiniband/hw/nes/nes_utils.c33
-rw-r--r--drivers/infiniband/hw/nes/nes_verbs.c207
-rw-r--r--drivers/infiniband/ulp/ipoib/Kconfig1
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib.h48
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_cm.c104
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ethtool.c46
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_fs.c2
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_ib.c52
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_main.c115
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_multicast.c27
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_verbs.c69
-rw-r--r--drivers/infiniband/ulp/ipoib/ipoib_vlan.c2
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.c359
-rw-r--r--drivers/infiniband/ulp/iser/iscsi_iser.h46
-rw-r--r--drivers/infiniband/ulp/iser/iser_initiator.c211
-rw-r--r--drivers/infiniband/ulp/iser/iser_memory.c79
-rw-r--r--drivers/infiniband/ulp/iser/iser_verbs.c30
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.c15
-rw-r--r--drivers/infiniband/ulp/srp/ib_srp.h2
104 files changed, 1751 insertions, 1160 deletions
diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c
index 781ea5950373..09a2bec7fd32 100644
--- a/drivers/infiniband/core/addr.c
+++ b/drivers/infiniband/core/addr.c
@@ -4,28 +4,33 @@
4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved. 4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
5 * Copyright (c) 2005 Intel Corporation. All rights reserved. 5 * Copyright (c) 2005 Intel Corporation. All rights reserved.
6 * 6 *
7 * This Software is licensed under one of the following licenses: 7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
8 * 12 *
9 * 1) under the terms of the "Common Public License 1.0" a copy of which is 13 * Redistribution and use in source and binary forms, with or
10 * available from the Open Source Initiative, see 14 * without modification, are permitted provided that the following
11 * http://www.opensource.org/licenses/cpl.php. 15 * conditions are met:
12 * 16 *
13 * 2) under the terms of the "The BSD License" a copy of which is 17 * - Redistributions of source code must retain the above
14 * available from the Open Source Initiative, see 18 * copyright notice, this list of conditions and the following
15 * http://www.opensource.org/licenses/bsd-license.php. 19 * disclaimer.
16 * 20 *
17 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a 21 * - Redistributions in binary form must reproduce the above
18 * copy of which is available from the Open Source Initiative, see 22 * copyright notice, this list of conditions and the following
19 * http://www.opensource.org/licenses/gpl-license.php. 23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
20 * 25 *
21 * Licensee has the right to choose one of the above licenses. 26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * 27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * Redistributions of source code must retain the above copyright 28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 * notice and one of the license notices. 29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
25 * 30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
26 * Redistributions in binary form must reproduce both the above copyright 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
27 * notice, one of the license notices in the documentation 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 * and/or other materials provided with the distribution. 33 * SOFTWARE.
29 */ 34 */
30 35
31#include <linux/mutex.h> 36#include <linux/mutex.h>
@@ -100,6 +105,7 @@ int rdma_copy_addr(struct rdma_dev_addr *dev_addr, struct net_device *dev,
100 memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN); 105 memcpy(dev_addr->broadcast, dev->broadcast, MAX_ADDR_LEN);
101 if (dst_dev_addr) 106 if (dst_dev_addr)
102 memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN); 107 memcpy(dev_addr->dst_dev_addr, dst_dev_addr, MAX_ADDR_LEN);
108 dev_addr->src_dev = dev;
103 return 0; 109 return 0;
104} 110}
105EXPORT_SYMBOL(rdma_copy_addr); 111EXPORT_SYMBOL(rdma_copy_addr);
diff --git a/drivers/infiniband/core/agent.h b/drivers/infiniband/core/agent.h
index fb9ed1489f95..6669287009c2 100644
--- a/drivers/infiniband/core/agent.h
+++ b/drivers/infiniband/core/agent.h
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: agent.h 1389 2004-12-27 22:56:47Z roland $
37 */ 35 */
38 36
39#ifndef __AGENT_H_ 37#ifndef __AGENT_H_
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c
index e85f7013de57..68883565b725 100644
--- a/drivers/infiniband/core/cache.c
+++ b/drivers/infiniband/core/cache.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: cache.c 1349 2004-12-16 21:09:43Z roland $
36 */ 34 */
37 35
38#include <linux/module.h> 36#include <linux/module.h>
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index a47fe64e5c39..55738eead3bf 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: cm.c 4311 2005-12-05 18:42:01Z sean.hefty $
36 */ 34 */
37 35
38#include <linux/completion.h> 36#include <linux/completion.h>
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c
index 671f13738054..ae11d5cc74d0 100644
--- a/drivers/infiniband/core/cma.c
+++ b/drivers/infiniband/core/cma.c
@@ -4,29 +4,33 @@
4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved. 4 * Copyright (c) 1999-2005, Mellanox Technologies, Inc. All rights reserved.
5 * Copyright (c) 2005-2006 Intel Corporation. All rights reserved. 5 * Copyright (c) 2005-2006 Intel Corporation. All rights reserved.
6 * 6 *
7 * This Software is licensed under one of the following licenses: 7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
8 * 12 *
9 * 1) under the terms of the "Common Public License 1.0" a copy of which is 13 * Redistribution and use in source and binary forms, with or
10 * available from the Open Source Initiative, see 14 * without modification, are permitted provided that the following
11 * http://www.opensource.org/licenses/cpl.php. 15 * conditions are met:
12 * 16 *
13 * 2) under the terms of the "The BSD License" a copy of which is 17 * - Redistributions of source code must retain the above
14 * available from the Open Source Initiative, see 18 * copyright notice, this list of conditions and the following
15 * http://www.opensource.org/licenses/bsd-license.php. 19 * disclaimer.
16 * 20 *
17 * 3) under the terms of the "GNU General Public License (GPL) Version 2" a 21 * - Redistributions in binary form must reproduce the above
18 * copy of which is available from the Open Source Initiative, see 22 * copyright notice, this list of conditions and the following
19 * http://www.opensource.org/licenses/gpl-license.php. 23 * disclaimer in the documentation and/or other materials
20 * 24 * provided with the distribution.
21 * Licensee has the right to choose one of the above licenses.
22 *
23 * Redistributions of source code must retain the above copyright
24 * notice and one of the license notices.
25 *
26 * Redistributions in binary form must reproduce both the above copyright
27 * notice, one of the license notices in the documentation
28 * and/or other materials provided with the distribution.
29 * 25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE.
30 */ 34 */
31 35
32#include <linux/completion.h> 36#include <linux/completion.h>
@@ -126,8 +130,7 @@ struct rdma_id_private {
126 130
127 struct completion comp; 131 struct completion comp;
128 atomic_t refcount; 132 atomic_t refcount;
129 wait_queue_head_t wait_remove; 133 struct mutex handler_mutex;
130 atomic_t dev_remove;
131 134
132 int backlog; 135 int backlog;
133 int timeout_ms; 136 int timeout_ms;
@@ -351,26 +354,15 @@ static void cma_deref_id(struct rdma_id_private *id_priv)
351 complete(&id_priv->comp); 354 complete(&id_priv->comp);
352} 355}
353 356
354static int cma_disable_remove(struct rdma_id_private *id_priv, 357static int cma_disable_callback(struct rdma_id_private *id_priv,
355 enum cma_state state) 358 enum cma_state state)
356{ 359{
357 unsigned long flags; 360 mutex_lock(&id_priv->handler_mutex);
358 int ret; 361 if (id_priv->state != state) {
359 362 mutex_unlock(&id_priv->handler_mutex);
360 spin_lock_irqsave(&id_priv->lock, flags); 363 return -EINVAL;
361 if (id_priv->state == state) { 364 }
362 atomic_inc(&id_priv->dev_remove); 365 return 0;
363 ret = 0;
364 } else
365 ret = -EINVAL;
366 spin_unlock_irqrestore(&id_priv->lock, flags);
367 return ret;
368}
369
370static void cma_enable_remove(struct rdma_id_private *id_priv)
371{
372 if (atomic_dec_and_test(&id_priv->dev_remove))
373 wake_up(&id_priv->wait_remove);
374} 366}
375 367
376static int cma_has_cm_dev(struct rdma_id_private *id_priv) 368static int cma_has_cm_dev(struct rdma_id_private *id_priv)
@@ -395,8 +387,7 @@ struct rdma_cm_id *rdma_create_id(rdma_cm_event_handler event_handler,
395 mutex_init(&id_priv->qp_mutex); 387 mutex_init(&id_priv->qp_mutex);
396 init_completion(&id_priv->comp); 388 init_completion(&id_priv->comp);
397 atomic_set(&id_priv->refcount, 1); 389 atomic_set(&id_priv->refcount, 1);
398 init_waitqueue_head(&id_priv->wait_remove); 390 mutex_init(&id_priv->handler_mutex);
399 atomic_set(&id_priv->dev_remove, 0);
400 INIT_LIST_HEAD(&id_priv->listen_list); 391 INIT_LIST_HEAD(&id_priv->listen_list);
401 INIT_LIST_HEAD(&id_priv->mc_list); 392 INIT_LIST_HEAD(&id_priv->mc_list);
402 get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num); 393 get_random_bytes(&id_priv->seq_num, sizeof id_priv->seq_num);
@@ -923,7 +914,7 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
923 struct rdma_cm_event event; 914 struct rdma_cm_event event;
924 int ret = 0; 915 int ret = 0;
925 916
926 if (cma_disable_remove(id_priv, CMA_CONNECT)) 917 if (cma_disable_callback(id_priv, CMA_CONNECT))
927 return 0; 918 return 0;
928 919
929 memset(&event, 0, sizeof event); 920 memset(&event, 0, sizeof event);
@@ -970,7 +961,7 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
970 event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE; 961 event.param.conn.private_data_len = IB_CM_REJ_PRIVATE_DATA_SIZE;
971 break; 962 break;
972 default: 963 default:
973 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d", 964 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n",
974 ib_event->event); 965 ib_event->event);
975 goto out; 966 goto out;
976 } 967 }
@@ -980,12 +971,12 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
980 /* Destroy the CM ID by returning a non-zero value. */ 971 /* Destroy the CM ID by returning a non-zero value. */
981 id_priv->cm_id.ib = NULL; 972 id_priv->cm_id.ib = NULL;
982 cma_exch(id_priv, CMA_DESTROYING); 973 cma_exch(id_priv, CMA_DESTROYING);
983 cma_enable_remove(id_priv); 974 mutex_unlock(&id_priv->handler_mutex);
984 rdma_destroy_id(&id_priv->id); 975 rdma_destroy_id(&id_priv->id);
985 return ret; 976 return ret;
986 } 977 }
987out: 978out:
988 cma_enable_remove(id_priv); 979 mutex_unlock(&id_priv->handler_mutex);
989 return ret; 980 return ret;
990} 981}
991 982
@@ -998,6 +989,7 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
998 union cma_ip_addr *src, *dst; 989 union cma_ip_addr *src, *dst;
999 __be16 port; 990 __be16 port;
1000 u8 ip_ver; 991 u8 ip_ver;
992 int ret;
1001 993
1002 if (cma_get_net_info(ib_event->private_data, listen_id->ps, 994 if (cma_get_net_info(ib_event->private_data, listen_id->ps,
1003 &ip_ver, &port, &src, &dst)) 995 &ip_ver, &port, &src, &dst))
@@ -1022,10 +1014,11 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
1022 if (rt->num_paths == 2) 1014 if (rt->num_paths == 2)
1023 rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path; 1015 rt->path_rec[1] = *ib_event->param.req_rcvd.alternate_path;
1024 1016
1025 ib_addr_set_sgid(&rt->addr.dev_addr, &rt->path_rec[0].sgid);
1026 ib_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid); 1017 ib_addr_set_dgid(&rt->addr.dev_addr, &rt->path_rec[0].dgid);
1027 ib_addr_set_pkey(&rt->addr.dev_addr, be16_to_cpu(rt->path_rec[0].pkey)); 1018 ret = rdma_translate_ip(&id->route.addr.src_addr,
1028 rt->addr.dev_addr.dev_type = RDMA_NODE_IB_CA; 1019 &id->route.addr.dev_addr);
1020 if (ret)
1021 goto destroy_id;
1029 1022
1030 id_priv = container_of(id, struct rdma_id_private, id); 1023 id_priv = container_of(id, struct rdma_id_private, id);
1031 id_priv->state = CMA_CONNECT; 1024 id_priv->state = CMA_CONNECT;
@@ -1095,7 +1088,7 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1095 int offset, ret; 1088 int offset, ret;
1096 1089
1097 listen_id = cm_id->context; 1090 listen_id = cm_id->context;
1098 if (cma_disable_remove(listen_id, CMA_LISTEN)) 1091 if (cma_disable_callback(listen_id, CMA_LISTEN))
1099 return -ECONNABORTED; 1092 return -ECONNABORTED;
1100 1093
1101 memset(&event, 0, sizeof event); 1094 memset(&event, 0, sizeof event);
@@ -1116,7 +1109,7 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1116 goto out; 1109 goto out;
1117 } 1110 }
1118 1111
1119 atomic_inc(&conn_id->dev_remove); 1112 mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
1120 mutex_lock(&lock); 1113 mutex_lock(&lock);
1121 ret = cma_acquire_dev(conn_id); 1114 ret = cma_acquire_dev(conn_id);
1122 mutex_unlock(&lock); 1115 mutex_unlock(&lock);
@@ -1138,7 +1131,7 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1138 !cma_is_ud_ps(conn_id->id.ps)) 1131 !cma_is_ud_ps(conn_id->id.ps))
1139 ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0); 1132 ib_send_cm_mra(cm_id, CMA_CM_MRA_SETTING, NULL, 0);
1140 mutex_unlock(&lock); 1133 mutex_unlock(&lock);
1141 cma_enable_remove(conn_id); 1134 mutex_unlock(&conn_id->handler_mutex);
1142 goto out; 1135 goto out;
1143 } 1136 }
1144 1137
@@ -1147,11 +1140,11 @@ static int cma_req_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
1147 1140
1148release_conn_id: 1141release_conn_id:
1149 cma_exch(conn_id, CMA_DESTROYING); 1142 cma_exch(conn_id, CMA_DESTROYING);
1150 cma_enable_remove(conn_id); 1143 mutex_unlock(&conn_id->handler_mutex);
1151 rdma_destroy_id(&conn_id->id); 1144 rdma_destroy_id(&conn_id->id);
1152 1145
1153out: 1146out:
1154 cma_enable_remove(listen_id); 1147 mutex_unlock(&listen_id->handler_mutex);
1155 return ret; 1148 return ret;
1156} 1149}
1157 1150
@@ -1217,7 +1210,7 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
1217 struct sockaddr_in *sin; 1210 struct sockaddr_in *sin;
1218 int ret = 0; 1211 int ret = 0;
1219 1212
1220 if (cma_disable_remove(id_priv, CMA_CONNECT)) 1213 if (cma_disable_callback(id_priv, CMA_CONNECT))
1221 return 0; 1214 return 0;
1222 1215
1223 memset(&event, 0, sizeof event); 1216 memset(&event, 0, sizeof event);
@@ -1261,12 +1254,12 @@ static int cma_iw_handler(struct iw_cm_id *iw_id, struct iw_cm_event *iw_event)
1261 /* Destroy the CM ID by returning a non-zero value. */ 1254 /* Destroy the CM ID by returning a non-zero value. */
1262 id_priv->cm_id.iw = NULL; 1255 id_priv->cm_id.iw = NULL;
1263 cma_exch(id_priv, CMA_DESTROYING); 1256 cma_exch(id_priv, CMA_DESTROYING);
1264 cma_enable_remove(id_priv); 1257 mutex_unlock(&id_priv->handler_mutex);
1265 rdma_destroy_id(&id_priv->id); 1258 rdma_destroy_id(&id_priv->id);
1266 return ret; 1259 return ret;
1267 } 1260 }
1268 1261
1269 cma_enable_remove(id_priv); 1262 mutex_unlock(&id_priv->handler_mutex);
1270 return ret; 1263 return ret;
1271} 1264}
1272 1265
@@ -1282,7 +1275,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1282 struct ib_device_attr attr; 1275 struct ib_device_attr attr;
1283 1276
1284 listen_id = cm_id->context; 1277 listen_id = cm_id->context;
1285 if (cma_disable_remove(listen_id, CMA_LISTEN)) 1278 if (cma_disable_callback(listen_id, CMA_LISTEN))
1286 return -ECONNABORTED; 1279 return -ECONNABORTED;
1287 1280
1288 /* Create a new RDMA id for the new IW CM ID */ 1281 /* Create a new RDMA id for the new IW CM ID */
@@ -1294,19 +1287,19 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1294 goto out; 1287 goto out;
1295 } 1288 }
1296 conn_id = container_of(new_cm_id, struct rdma_id_private, id); 1289 conn_id = container_of(new_cm_id, struct rdma_id_private, id);
1297 atomic_inc(&conn_id->dev_remove); 1290 mutex_lock_nested(&conn_id->handler_mutex, SINGLE_DEPTH_NESTING);
1298 conn_id->state = CMA_CONNECT; 1291 conn_id->state = CMA_CONNECT;
1299 1292
1300 dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr); 1293 dev = ip_dev_find(&init_net, iw_event->local_addr.sin_addr.s_addr);
1301 if (!dev) { 1294 if (!dev) {
1302 ret = -EADDRNOTAVAIL; 1295 ret = -EADDRNOTAVAIL;
1303 cma_enable_remove(conn_id); 1296 mutex_unlock(&conn_id->handler_mutex);
1304 rdma_destroy_id(new_cm_id); 1297 rdma_destroy_id(new_cm_id);
1305 goto out; 1298 goto out;
1306 } 1299 }
1307 ret = rdma_copy_addr(&conn_id->id.route.addr.dev_addr, dev, NULL); 1300 ret = rdma_copy_addr(&conn_id->id.route.addr.dev_addr, dev, NULL);
1308 if (ret) { 1301 if (ret) {
1309 cma_enable_remove(conn_id); 1302 mutex_unlock(&conn_id->handler_mutex);
1310 rdma_destroy_id(new_cm_id); 1303 rdma_destroy_id(new_cm_id);
1311 goto out; 1304 goto out;
1312 } 1305 }
@@ -1315,7 +1308,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1315 ret = cma_acquire_dev(conn_id); 1308 ret = cma_acquire_dev(conn_id);
1316 mutex_unlock(&lock); 1309 mutex_unlock(&lock);
1317 if (ret) { 1310 if (ret) {
1318 cma_enable_remove(conn_id); 1311 mutex_unlock(&conn_id->handler_mutex);
1319 rdma_destroy_id(new_cm_id); 1312 rdma_destroy_id(new_cm_id);
1320 goto out; 1313 goto out;
1321 } 1314 }
@@ -1331,7 +1324,7 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1331 1324
1332 ret = ib_query_device(conn_id->id.device, &attr); 1325 ret = ib_query_device(conn_id->id.device, &attr);
1333 if (ret) { 1326 if (ret) {
1334 cma_enable_remove(conn_id); 1327 mutex_unlock(&conn_id->handler_mutex);
1335 rdma_destroy_id(new_cm_id); 1328 rdma_destroy_id(new_cm_id);
1336 goto out; 1329 goto out;
1337 } 1330 }
@@ -1347,14 +1340,17 @@ static int iw_conn_req_handler(struct iw_cm_id *cm_id,
1347 /* User wants to destroy the CM ID */ 1340 /* User wants to destroy the CM ID */
1348 conn_id->cm_id.iw = NULL; 1341 conn_id->cm_id.iw = NULL;
1349 cma_exch(conn_id, CMA_DESTROYING); 1342 cma_exch(conn_id, CMA_DESTROYING);
1350 cma_enable_remove(conn_id); 1343 mutex_unlock(&conn_id->handler_mutex);
1351 rdma_destroy_id(&conn_id->id); 1344 rdma_destroy_id(&conn_id->id);
1345 goto out;
1352 } 1346 }
1353 1347
1348 mutex_unlock(&conn_id->handler_mutex);
1349
1354out: 1350out:
1355 if (dev) 1351 if (dev)
1356 dev_put(dev); 1352 dev_put(dev);
1357 cma_enable_remove(listen_id); 1353 mutex_unlock(&listen_id->handler_mutex);
1358 return ret; 1354 return ret;
1359} 1355}
1360 1356
@@ -1446,7 +1442,7 @@ static void cma_listen_on_dev(struct rdma_id_private *id_priv,
1446 ret = rdma_listen(id, id_priv->backlog); 1442 ret = rdma_listen(id, id_priv->backlog);
1447 if (ret) 1443 if (ret)
1448 printk(KERN_WARNING "RDMA CMA: cma_listen_on_dev, error %d, " 1444 printk(KERN_WARNING "RDMA CMA: cma_listen_on_dev, error %d, "
1449 "listening on device %s", ret, cma_dev->device->name); 1445 "listening on device %s\n", ret, cma_dev->device->name);
1450} 1446}
1451 1447
1452static void cma_listen_on_all(struct rdma_id_private *id_priv) 1448static void cma_listen_on_all(struct rdma_id_private *id_priv)
@@ -1586,7 +1582,7 @@ static void cma_work_handler(struct work_struct *_work)
1586 struct rdma_id_private *id_priv = work->id; 1582 struct rdma_id_private *id_priv = work->id;
1587 int destroy = 0; 1583 int destroy = 0;
1588 1584
1589 atomic_inc(&id_priv->dev_remove); 1585 mutex_lock(&id_priv->handler_mutex);
1590 if (!cma_comp_exch(id_priv, work->old_state, work->new_state)) 1586 if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
1591 goto out; 1587 goto out;
1592 1588
@@ -1595,7 +1591,7 @@ static void cma_work_handler(struct work_struct *_work)
1595 destroy = 1; 1591 destroy = 1;
1596 } 1592 }
1597out: 1593out:
1598 cma_enable_remove(id_priv); 1594 mutex_unlock(&id_priv->handler_mutex);
1599 cma_deref_id(id_priv); 1595 cma_deref_id(id_priv);
1600 if (destroy) 1596 if (destroy)
1601 rdma_destroy_id(&id_priv->id); 1597 rdma_destroy_id(&id_priv->id);
@@ -1758,7 +1754,7 @@ static void addr_handler(int status, struct sockaddr *src_addr,
1758 struct rdma_cm_event event; 1754 struct rdma_cm_event event;
1759 1755
1760 memset(&event, 0, sizeof event); 1756 memset(&event, 0, sizeof event);
1761 atomic_inc(&id_priv->dev_remove); 1757 mutex_lock(&id_priv->handler_mutex);
1762 1758
1763 /* 1759 /*
1764 * Grab mutex to block rdma_destroy_id() from removing the device while 1760 * Grab mutex to block rdma_destroy_id() from removing the device while
@@ -1787,13 +1783,13 @@ static void addr_handler(int status, struct sockaddr *src_addr,
1787 1783
1788 if (id_priv->id.event_handler(&id_priv->id, &event)) { 1784 if (id_priv->id.event_handler(&id_priv->id, &event)) {
1789 cma_exch(id_priv, CMA_DESTROYING); 1785 cma_exch(id_priv, CMA_DESTROYING);
1790 cma_enable_remove(id_priv); 1786 mutex_unlock(&id_priv->handler_mutex);
1791 cma_deref_id(id_priv); 1787 cma_deref_id(id_priv);
1792 rdma_destroy_id(&id_priv->id); 1788 rdma_destroy_id(&id_priv->id);
1793 return; 1789 return;
1794 } 1790 }
1795out: 1791out:
1796 cma_enable_remove(id_priv); 1792 mutex_unlock(&id_priv->handler_mutex);
1797 cma_deref_id(id_priv); 1793 cma_deref_id(id_priv);
1798} 1794}
1799 1795
@@ -2120,7 +2116,7 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
2120 struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd; 2116 struct ib_cm_sidr_rep_event_param *rep = &ib_event->param.sidr_rep_rcvd;
2121 int ret = 0; 2117 int ret = 0;
2122 2118
2123 if (cma_disable_remove(id_priv, CMA_CONNECT)) 2119 if (cma_disable_callback(id_priv, CMA_CONNECT))
2124 return 0; 2120 return 0;
2125 2121
2126 memset(&event, 0, sizeof event); 2122 memset(&event, 0, sizeof event);
@@ -2151,7 +2147,7 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
2151 event.status = 0; 2147 event.status = 0;
2152 break; 2148 break;
2153 default: 2149 default:
2154 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d", 2150 printk(KERN_ERR "RDMA CMA: unexpected IB CM event: %d\n",
2155 ib_event->event); 2151 ib_event->event);
2156 goto out; 2152 goto out;
2157 } 2153 }
@@ -2161,12 +2157,12 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
2161 /* Destroy the CM ID by returning a non-zero value. */ 2157 /* Destroy the CM ID by returning a non-zero value. */
2162 id_priv->cm_id.ib = NULL; 2158 id_priv->cm_id.ib = NULL;
2163 cma_exch(id_priv, CMA_DESTROYING); 2159 cma_exch(id_priv, CMA_DESTROYING);
2164 cma_enable_remove(id_priv); 2160 mutex_unlock(&id_priv->handler_mutex);
2165 rdma_destroy_id(&id_priv->id); 2161 rdma_destroy_id(&id_priv->id);
2166 return ret; 2162 return ret;
2167 } 2163 }
2168out: 2164out:
2169 cma_enable_remove(id_priv); 2165 mutex_unlock(&id_priv->handler_mutex);
2170 return ret; 2166 return ret;
2171} 2167}
2172 2168
@@ -2564,8 +2560,8 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
2564 int ret; 2560 int ret;
2565 2561
2566 id_priv = mc->id_priv; 2562 id_priv = mc->id_priv;
2567 if (cma_disable_remove(id_priv, CMA_ADDR_BOUND) && 2563 if (cma_disable_callback(id_priv, CMA_ADDR_BOUND) &&
2568 cma_disable_remove(id_priv, CMA_ADDR_RESOLVED)) 2564 cma_disable_callback(id_priv, CMA_ADDR_RESOLVED))
2569 return 0; 2565 return 0;
2570 2566
2571 mutex_lock(&id_priv->qp_mutex); 2567 mutex_lock(&id_priv->qp_mutex);
@@ -2590,12 +2586,12 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
2590 ret = id_priv->id.event_handler(&id_priv->id, &event); 2586 ret = id_priv->id.event_handler(&id_priv->id, &event);
2591 if (ret) { 2587 if (ret) {
2592 cma_exch(id_priv, CMA_DESTROYING); 2588 cma_exch(id_priv, CMA_DESTROYING);
2593 cma_enable_remove(id_priv); 2589 mutex_unlock(&id_priv->handler_mutex);
2594 rdma_destroy_id(&id_priv->id); 2590 rdma_destroy_id(&id_priv->id);
2595 return 0; 2591 return 0;
2596 } 2592 }
2597 2593
2598 cma_enable_remove(id_priv); 2594 mutex_unlock(&id_priv->handler_mutex);
2599 return 0; 2595 return 0;
2600} 2596}
2601 2597
@@ -2754,6 +2750,7 @@ static int cma_remove_id_dev(struct rdma_id_private *id_priv)
2754{ 2750{
2755 struct rdma_cm_event event; 2751 struct rdma_cm_event event;
2756 enum cma_state state; 2752 enum cma_state state;
2753 int ret = 0;
2757 2754
2758 /* Record that we want to remove the device */ 2755 /* Record that we want to remove the device */
2759 state = cma_exch(id_priv, CMA_DEVICE_REMOVAL); 2756 state = cma_exch(id_priv, CMA_DEVICE_REMOVAL);
@@ -2761,15 +2758,18 @@ static int cma_remove_id_dev(struct rdma_id_private *id_priv)
2761 return 0; 2758 return 0;
2762 2759
2763 cma_cancel_operation(id_priv, state); 2760 cma_cancel_operation(id_priv, state);
2764 wait_event(id_priv->wait_remove, !atomic_read(&id_priv->dev_remove)); 2761 mutex_lock(&id_priv->handler_mutex);
2765 2762
2766 /* Check for destruction from another callback. */ 2763 /* Check for destruction from another callback. */
2767 if (!cma_comp(id_priv, CMA_DEVICE_REMOVAL)) 2764 if (!cma_comp(id_priv, CMA_DEVICE_REMOVAL))
2768 return 0; 2765 goto out;
2769 2766
2770 memset(&event, 0, sizeof event); 2767 memset(&event, 0, sizeof event);
2771 event.event = RDMA_CM_EVENT_DEVICE_REMOVAL; 2768 event.event = RDMA_CM_EVENT_DEVICE_REMOVAL;
2772 return id_priv->id.event_handler(&id_priv->id, &event); 2769 ret = id_priv->id.event_handler(&id_priv->id, &event);
2770out:
2771 mutex_unlock(&id_priv->handler_mutex);
2772 return ret;
2773} 2773}
2774 2774
2775static void cma_process_remove(struct cma_device *cma_dev) 2775static void cma_process_remove(struct cma_device *cma_dev)
diff --git a/drivers/infiniband/core/core_priv.h b/drivers/infiniband/core/core_priv.h
index 7ad47a4b166b..05ac36e6acdb 100644
--- a/drivers/infiniband/core/core_priv.h
+++ b/drivers/infiniband/core/core_priv.h
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: core_priv.h 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#ifndef _CORE_PRIV_H 33#ifndef _CORE_PRIV_H
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c
index 5ac5ffee05cb..7913b804311e 100644
--- a/drivers/infiniband/core/device.c
+++ b/drivers/infiniband/core/device.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: device.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/module.h> 34#include <linux/module.h>
diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
index 1286dc1b98b2..4507043d24c8 100644
--- a/drivers/infiniband/core/fmr_pool.c
+++ b/drivers/infiniband/core/fmr_pool.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: fmr_pool.c 2730 2005-06-28 16:43:03Z sean.hefty $
34 */ 32 */
35 33
36#include <linux/errno.h> 34#include <linux/errno.h>
diff --git a/drivers/infiniband/core/mad_priv.h b/drivers/infiniband/core/mad_priv.h
index 8b75010016ec..05ce331733b0 100644
--- a/drivers/infiniband/core/mad_priv.h
+++ b/drivers/infiniband/core/mad_priv.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mad_priv.h 5596 2006-03-03 01:00:07Z sean.hefty $
35 */ 33 */
36 34
37#ifndef __IB_MAD_PRIV_H__ 35#ifndef __IB_MAD_PRIV_H__
diff --git a/drivers/infiniband/core/mad_rmpp.c b/drivers/infiniband/core/mad_rmpp.c
index a5e2a310f312..d0ef7d61c037 100644
--- a/drivers/infiniband/core/mad_rmpp.c
+++ b/drivers/infiniband/core/mad_rmpp.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mad_rmpp.c 1921 2005-03-02 22:58:44Z sean.hefty $
34 */ 32 */
35 33
36#include "mad_priv.h" 34#include "mad_priv.h"
diff --git a/drivers/infiniband/core/mad_rmpp.h b/drivers/infiniband/core/mad_rmpp.h
index f0616fd22494..3d336bff1148 100644
--- a/drivers/infiniband/core/mad_rmpp.h
+++ b/drivers/infiniband/core/mad_rmpp.h
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mad_rmpp.h 1921 2005-02-25 22:58:44Z sean.hefty $
33 */ 31 */
34 32
35#ifndef __MAD_RMPP_H__ 33#ifndef __MAD_RMPP_H__
diff --git a/drivers/infiniband/core/packer.c b/drivers/infiniband/core/packer.c
index c972d7235764..019bd4b0863e 100644
--- a/drivers/infiniband/core/packer.c
+++ b/drivers/infiniband/core/packer.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: packer.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/string.h> 34#include <linux/string.h>
diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
index cf474ec27070..1341de793e51 100644
--- a/drivers/infiniband/core/sa_query.c
+++ b/drivers/infiniband/core/sa_query.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: sa_query.c 2811 2005-07-06 18:11:43Z halr $
35 */ 33 */
36 34
37#include <linux/module.h> 35#include <linux/module.h>
@@ -361,7 +359,7 @@ static void update_sm_ah(struct work_struct *work)
361{ 359{
362 struct ib_sa_port *port = 360 struct ib_sa_port *port =
363 container_of(work, struct ib_sa_port, update_task); 361 container_of(work, struct ib_sa_port, update_task);
364 struct ib_sa_sm_ah *new_ah, *old_ah; 362 struct ib_sa_sm_ah *new_ah;
365 struct ib_port_attr port_attr; 363 struct ib_port_attr port_attr;
366 struct ib_ah_attr ah_attr; 364 struct ib_ah_attr ah_attr;
367 365
@@ -397,12 +395,9 @@ static void update_sm_ah(struct work_struct *work)
397 } 395 }
398 396
399 spin_lock_irq(&port->ah_lock); 397 spin_lock_irq(&port->ah_lock);
400 old_ah = port->sm_ah;
401 port->sm_ah = new_ah; 398 port->sm_ah = new_ah;
402 spin_unlock_irq(&port->ah_lock); 399 spin_unlock_irq(&port->ah_lock);
403 400
404 if (old_ah)
405 kref_put(&old_ah->ref, free_sm_ah);
406} 401}
407 402
408static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event) 403static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event)
@@ -413,8 +408,17 @@ static void ib_sa_event(struct ib_event_handler *handler, struct ib_event *event
413 event->event == IB_EVENT_PKEY_CHANGE || 408 event->event == IB_EVENT_PKEY_CHANGE ||
414 event->event == IB_EVENT_SM_CHANGE || 409 event->event == IB_EVENT_SM_CHANGE ||
415 event->event == IB_EVENT_CLIENT_REREGISTER) { 410 event->event == IB_EVENT_CLIENT_REREGISTER) {
416 struct ib_sa_device *sa_dev; 411 unsigned long flags;
417 sa_dev = container_of(handler, typeof(*sa_dev), event_handler); 412 struct ib_sa_device *sa_dev =
413 container_of(handler, typeof(*sa_dev), event_handler);
414 struct ib_sa_port *port =
415 &sa_dev->port[event->element.port_num - sa_dev->start_port];
416
417 spin_lock_irqsave(&port->ah_lock, flags);
418 if (port->sm_ah)
419 kref_put(&port->sm_ah->ref, free_sm_ah);
420 port->sm_ah = NULL;
421 spin_unlock_irqrestore(&port->ah_lock, flags);
418 422
419 schedule_work(&sa_dev->port[event->element.port_num - 423 schedule_work(&sa_dev->port[event->element.port_num -
420 sa_dev->start_port].update_task); 424 sa_dev->start_port].update_task);
@@ -519,6 +523,10 @@ static int alloc_mad(struct ib_sa_query *query, gfp_t gfp_mask)
519 unsigned long flags; 523 unsigned long flags;
520 524
521 spin_lock_irqsave(&query->port->ah_lock, flags); 525 spin_lock_irqsave(&query->port->ah_lock, flags);
526 if (!query->port->sm_ah) {
527 spin_unlock_irqrestore(&query->port->ah_lock, flags);
528 return -EAGAIN;
529 }
522 kref_get(&query->port->sm_ah->ref); 530 kref_get(&query->port->sm_ah->ref);
523 query->sm_ah = query->port->sm_ah; 531 query->sm_ah = query->port->sm_ah;
524 spin_unlock_irqrestore(&query->port->ah_lock, flags); 532 spin_unlock_irqrestore(&query->port->ah_lock, flags);
diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 95756551cf7c..4d1042115598 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: sysfs.c 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include "core_priv.h" 35#include "core_priv.h"
@@ -665,6 +663,120 @@ static struct class ib_class = {
665 .dev_uevent = ib_device_uevent, 663 .dev_uevent = ib_device_uevent,
666}; 664};
667 665
666/* Show a given an attribute in the statistics group */
667static ssize_t show_protocol_stat(const struct device *device,
668 struct device_attribute *attr, char *buf,
669 unsigned offset)
670{
671 struct ib_device *dev = container_of(device, struct ib_device, dev);
672 union rdma_protocol_stats stats;
673 ssize_t ret;
674
675 ret = dev->get_protocol_stats(dev, &stats);
676 if (ret)
677 return ret;
678
679 return sprintf(buf, "%llu\n",
680 (unsigned long long) ((u64 *) &stats)[offset]);
681}
682
683/* generate a read-only iwarp statistics attribute */
684#define IW_STATS_ENTRY(name) \
685static ssize_t show_##name(struct device *device, \
686 struct device_attribute *attr, char *buf) \
687{ \
688 return show_protocol_stat(device, attr, buf, \
689 offsetof(struct iw_protocol_stats, name) / \
690 sizeof (u64)); \
691} \
692static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL)
693
694IW_STATS_ENTRY(ipInReceives);
695IW_STATS_ENTRY(ipInHdrErrors);
696IW_STATS_ENTRY(ipInTooBigErrors);
697IW_STATS_ENTRY(ipInNoRoutes);
698IW_STATS_ENTRY(ipInAddrErrors);
699IW_STATS_ENTRY(ipInUnknownProtos);
700IW_STATS_ENTRY(ipInTruncatedPkts);
701IW_STATS_ENTRY(ipInDiscards);
702IW_STATS_ENTRY(ipInDelivers);
703IW_STATS_ENTRY(ipOutForwDatagrams);
704IW_STATS_ENTRY(ipOutRequests);
705IW_STATS_ENTRY(ipOutDiscards);
706IW_STATS_ENTRY(ipOutNoRoutes);
707IW_STATS_ENTRY(ipReasmTimeout);
708IW_STATS_ENTRY(ipReasmReqds);
709IW_STATS_ENTRY(ipReasmOKs);
710IW_STATS_ENTRY(ipReasmFails);
711IW_STATS_ENTRY(ipFragOKs);
712IW_STATS_ENTRY(ipFragFails);
713IW_STATS_ENTRY(ipFragCreates);
714IW_STATS_ENTRY(ipInMcastPkts);
715IW_STATS_ENTRY(ipOutMcastPkts);
716IW_STATS_ENTRY(ipInBcastPkts);
717IW_STATS_ENTRY(ipOutBcastPkts);
718IW_STATS_ENTRY(tcpRtoAlgorithm);
719IW_STATS_ENTRY(tcpRtoMin);
720IW_STATS_ENTRY(tcpRtoMax);
721IW_STATS_ENTRY(tcpMaxConn);
722IW_STATS_ENTRY(tcpActiveOpens);
723IW_STATS_ENTRY(tcpPassiveOpens);
724IW_STATS_ENTRY(tcpAttemptFails);
725IW_STATS_ENTRY(tcpEstabResets);
726IW_STATS_ENTRY(tcpCurrEstab);
727IW_STATS_ENTRY(tcpInSegs);
728IW_STATS_ENTRY(tcpOutSegs);
729IW_STATS_ENTRY(tcpRetransSegs);
730IW_STATS_ENTRY(tcpInErrs);
731IW_STATS_ENTRY(tcpOutRsts);
732
733static struct attribute *iw_proto_stats_attrs[] = {
734 &dev_attr_ipInReceives.attr,
735 &dev_attr_ipInHdrErrors.attr,
736 &dev_attr_ipInTooBigErrors.attr,
737 &dev_attr_ipInNoRoutes.attr,
738 &dev_attr_ipInAddrErrors.attr,
739 &dev_attr_ipInUnknownProtos.attr,
740 &dev_attr_ipInTruncatedPkts.attr,
741 &dev_attr_ipInDiscards.attr,
742 &dev_attr_ipInDelivers.attr,
743 &dev_attr_ipOutForwDatagrams.attr,
744 &dev_attr_ipOutRequests.attr,
745 &dev_attr_ipOutDiscards.attr,
746 &dev_attr_ipOutNoRoutes.attr,
747 &dev_attr_ipReasmTimeout.attr,
748 &dev_attr_ipReasmReqds.attr,
749 &dev_attr_ipReasmOKs.attr,
750 &dev_attr_ipReasmFails.attr,
751 &dev_attr_ipFragOKs.attr,
752 &dev_attr_ipFragFails.attr,
753 &dev_attr_ipFragCreates.attr,
754 &dev_attr_ipInMcastPkts.attr,
755 &dev_attr_ipOutMcastPkts.attr,
756 &dev_attr_ipInBcastPkts.attr,
757 &dev_attr_ipOutBcastPkts.attr,
758 &dev_attr_tcpRtoAlgorithm.attr,
759 &dev_attr_tcpRtoMin.attr,
760 &dev_attr_tcpRtoMax.attr,
761 &dev_attr_tcpMaxConn.attr,
762 &dev_attr_tcpActiveOpens.attr,
763 &dev_attr_tcpPassiveOpens.attr,
764 &dev_attr_tcpAttemptFails.attr,
765 &dev_attr_tcpEstabResets.attr,
766 &dev_attr_tcpCurrEstab.attr,
767 &dev_attr_tcpInSegs.attr,
768 &dev_attr_tcpOutSegs.attr,
769 &dev_attr_tcpRetransSegs.attr,
770 &dev_attr_tcpInErrs.attr,
771 &dev_attr_tcpOutRsts.attr,
772 NULL
773};
774
775static struct attribute_group iw_stats_group = {
776 .name = "proto_stats",
777 .attrs = iw_proto_stats_attrs,
778};
779
668int ib_device_register_sysfs(struct ib_device *device) 780int ib_device_register_sysfs(struct ib_device *device)
669{ 781{
670 struct device *class_dev = &device->dev; 782 struct device *class_dev = &device->dev;
@@ -707,6 +819,12 @@ int ib_device_register_sysfs(struct ib_device *device)
707 } 819 }
708 } 820 }
709 821
822 if (device->node_type == RDMA_NODE_RNIC && device->get_protocol_stats) {
823 ret = sysfs_create_group(&class_dev->kobj, &iw_stats_group);
824 if (ret)
825 goto err_put;
826 }
827
710 return 0; 828 return 0;
711 829
712err_put: 830err_put:
diff --git a/drivers/infiniband/core/ucm.c b/drivers/infiniband/core/ucm.c
index d7a6881b571d..9494005d1c9a 100644
--- a/drivers/infiniband/core/ucm.c
+++ b/drivers/infiniband/core/ucm.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: ucm.c 4311 2005-12-05 18:42:01Z sean.hefty $
34 */ 32 */
35 33
36#include <linux/completion.h> 34#include <linux/completion.h>
@@ -45,6 +43,7 @@
45#include <linux/cdev.h> 43#include <linux/cdev.h>
46#include <linux/idr.h> 44#include <linux/idr.h>
47#include <linux/mutex.h> 45#include <linux/mutex.h>
46#include <linux/smp_lock.h>
48 47
49#include <asm/uaccess.h> 48#include <asm/uaccess.h>
50 49
@@ -1159,6 +1158,7 @@ static int ib_ucm_open(struct inode *inode, struct file *filp)
1159{ 1158{
1160 struct ib_ucm_file *file; 1159 struct ib_ucm_file *file;
1161 1160
1161 cycle_kernel_lock();
1162 file = kmalloc(sizeof(*file), GFP_KERNEL); 1162 file = kmalloc(sizeof(*file), GFP_KERNEL);
1163 if (!file) 1163 if (!file)
1164 return -ENOMEM; 1164 return -ENOMEM;
diff --git a/drivers/infiniband/core/ucma.c b/drivers/infiniband/core/ucma.c
index ca4cf3a511ab..195f97302fe5 100644
--- a/drivers/infiniband/core/ucma.c
+++ b/drivers/infiniband/core/ucma.c
@@ -38,6 +38,7 @@
38#include <linux/in.h> 38#include <linux/in.h>
39#include <linux/in6.h> 39#include <linux/in6.h>
40#include <linux/miscdevice.h> 40#include <linux/miscdevice.h>
41#include <linux/smp_lock.h>
41 42
42#include <rdma/rdma_user_cm.h> 43#include <rdma/rdma_user_cm.h>
43#include <rdma/ib_marshall.h> 44#include <rdma/ib_marshall.h>
@@ -1156,6 +1157,7 @@ static int ucma_open(struct inode *inode, struct file *filp)
1156 if (!file) 1157 if (!file)
1157 return -ENOMEM; 1158 return -ENOMEM;
1158 1159
1160 lock_kernel();
1159 INIT_LIST_HEAD(&file->event_list); 1161 INIT_LIST_HEAD(&file->event_list);
1160 INIT_LIST_HEAD(&file->ctx_list); 1162 INIT_LIST_HEAD(&file->ctx_list);
1161 init_waitqueue_head(&file->poll_wait); 1163 init_waitqueue_head(&file->poll_wait);
@@ -1163,6 +1165,7 @@ static int ucma_open(struct inode *inode, struct file *filp)
1163 1165
1164 filp->private_data = file; 1166 filp->private_data = file;
1165 file->filp = filp; 1167 file->filp = filp;
1168 unlock_kernel();
1166 return 0; 1169 return 0;
1167} 1170}
1168 1171
diff --git a/drivers/infiniband/core/ud_header.c b/drivers/infiniband/core/ud_header.c
index 997c07db6d8f..8ec7876bedcf 100644
--- a/drivers/infiniband/core/ud_header.c
+++ b/drivers/infiniband/core/ud_header.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: ud_header.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/errno.h> 34#include <linux/errno.h>
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index a1768dbb0720..6f7c096abf13 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: uverbs_mem.c 2743 2005-06-28 22:27:59Z roland $
35 */ 33 */
36 34
37#include <linux/mm.h> 35#include <linux/mm.h>
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 840ede9ae965..268a2d23b7c9 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: user_mad.c 5596 2006-03-03 01:00:07Z sean.hefty $
36 */ 34 */
37 35
38#include <linux/module.h> 36#include <linux/module.h>
@@ -777,6 +775,19 @@ static long ib_umad_compat_ioctl(struct file *filp, unsigned int cmd,
777} 775}
778#endif 776#endif
779 777
778/*
779 * ib_umad_open() does not need the BKL:
780 *
781 * - umad_port[] accesses are protected by port_lock, the
782 * ib_umad_port structures are properly reference counted, and
783 * everything else is purely local to the file being created, so
784 * races against other open calls are not a problem;
785 * - the ioctl method does not affect any global state outside of the
786 * file structure being operated on;
787 * - the port is added to umad_port[] as the last part of module
788 * initialization so the open method will either immediately run
789 * -ENXIO, or all required initialization will be done.
790 */
780static int ib_umad_open(struct inode *inode, struct file *filp) 791static int ib_umad_open(struct inode *inode, struct file *filp)
781{ 792{
782 struct ib_umad_port *port; 793 struct ib_umad_port *port;
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h
index 376a57ce1b40..b3ea9587dc80 100644
--- a/drivers/infiniband/core/uverbs.h
+++ b/drivers/infiniband/core/uverbs.h
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: uverbs.h 2559 2005-06-06 19:43:16Z roland $
37 */ 35 */
38 36
39#ifndef UVERBS_H 37#ifndef UVERBS_H
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c
index 2c3bff5fe867..56feab6c251e 100644
--- a/drivers/infiniband/core/uverbs_cmd.c
+++ b/drivers/infiniband/core/uverbs_cmd.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: uverbs_cmd.c 2708 2005-06-24 17:27:21Z roland $
36 */ 34 */
37 35
38#include <linux/file.h> 36#include <linux/file.h>
@@ -919,7 +917,7 @@ ssize_t ib_uverbs_poll_cq(struct ib_uverbs_file *file,
919 resp->wc[i].opcode = wc[i].opcode; 917 resp->wc[i].opcode = wc[i].opcode;
920 resp->wc[i].vendor_err = wc[i].vendor_err; 918 resp->wc[i].vendor_err = wc[i].vendor_err;
921 resp->wc[i].byte_len = wc[i].byte_len; 919 resp->wc[i].byte_len = wc[i].byte_len;
922 resp->wc[i].imm_data = (__u32 __force) wc[i].imm_data; 920 resp->wc[i].ex.imm_data = (__u32 __force) wc[i].ex.imm_data;
923 resp->wc[i].qp_num = wc[i].qp->qp_num; 921 resp->wc[i].qp_num = wc[i].qp->qp_num;
924 resp->wc[i].src_qp = wc[i].src_qp; 922 resp->wc[i].src_qp = wc[i].src_qp;
925 resp->wc[i].wc_flags = wc[i].wc_flags; 923 resp->wc[i].wc_flags = wc[i].wc_flags;
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c
index caed42bf7ef5..aeee856c4060 100644
--- a/drivers/infiniband/core/uverbs_main.c
+++ b/drivers/infiniband/core/uverbs_main.c
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: uverbs_main.c 2733 2005-06-28 19:14:34Z roland $
37 */ 35 */
38 36
39#include <linux/module.h> 37#include <linux/module.h>
@@ -610,6 +608,18 @@ static int ib_uverbs_mmap(struct file *filp, struct vm_area_struct *vma)
610 return file->device->ib_dev->mmap(file->ucontext, vma); 608 return file->device->ib_dev->mmap(file->ucontext, vma);
611} 609}
612 610
611/*
612 * ib_uverbs_open() does not need the BKL:
613 *
614 * - dev_table[] accesses are protected by map_lock, the
615 * ib_uverbs_device structures are properly reference counted, and
616 * everything else is purely local to the file being created, so
617 * races against other open calls are not a problem;
618 * - there is no ioctl method to race against;
619 * - the device is added to dev_table[] as the last part of module
620 * initialization, the open method will either immediately run
621 * -ENXIO, or all required initialization will be done.
622 */
613static int ib_uverbs_open(struct inode *inode, struct file *filp) 623static int ib_uverbs_open(struct inode *inode, struct file *filp)
614{ 624{
615 struct ib_uverbs_device *dev; 625 struct ib_uverbs_device *dev;
@@ -651,7 +661,6 @@ err_module:
651 661
652err: 662err:
653 kref_put(&dev->ref, ib_uverbs_release_dev); 663 kref_put(&dev->ref, ib_uverbs_release_dev);
654
655 return ret; 664 return ret;
656} 665}
657 666
diff --git a/drivers/infiniband/core/verbs.c b/drivers/infiniband/core/verbs.c
index 05042089de6e..a7da9be43e61 100644
--- a/drivers/infiniband/core/verbs.c
+++ b/drivers/infiniband/core/verbs.c
@@ -34,8 +34,6 @@
34 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 34 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
35 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 35 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
36 * SOFTWARE. 36 * SOFTWARE.
37 *
38 * $Id: verbs.c 1349 2004-12-16 21:09:43Z roland $
39 */ 37 */
40 38
41#include <linux/errno.h> 39#include <linux/errno.h>
@@ -317,7 +315,6 @@ static const struct {
317} qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = { 315} qp_state_table[IB_QPS_ERR + 1][IB_QPS_ERR + 1] = {
318 [IB_QPS_RESET] = { 316 [IB_QPS_RESET] = {
319 [IB_QPS_RESET] = { .valid = 1 }, 317 [IB_QPS_RESET] = { .valid = 1 },
320 [IB_QPS_ERR] = { .valid = 1 },
321 [IB_QPS_INIT] = { 318 [IB_QPS_INIT] = {
322 .valid = 1, 319 .valid = 1,
323 .req_param = { 320 .req_param = {
@@ -755,6 +752,52 @@ int ib_dereg_mr(struct ib_mr *mr)
755} 752}
756EXPORT_SYMBOL(ib_dereg_mr); 753EXPORT_SYMBOL(ib_dereg_mr);
757 754
755struct ib_mr *ib_alloc_fast_reg_mr(struct ib_pd *pd, int max_page_list_len)
756{
757 struct ib_mr *mr;
758
759 if (!pd->device->alloc_fast_reg_mr)
760 return ERR_PTR(-ENOSYS);
761
762 mr = pd->device->alloc_fast_reg_mr(pd, max_page_list_len);
763
764 if (!IS_ERR(mr)) {
765 mr->device = pd->device;
766 mr->pd = pd;
767 mr->uobject = NULL;
768 atomic_inc(&pd->usecnt);
769 atomic_set(&mr->usecnt, 0);
770 }
771
772 return mr;
773}
774EXPORT_SYMBOL(ib_alloc_fast_reg_mr);
775
776struct ib_fast_reg_page_list *ib_alloc_fast_reg_page_list(struct ib_device *device,
777 int max_page_list_len)
778{
779 struct ib_fast_reg_page_list *page_list;
780
781 if (!device->alloc_fast_reg_page_list)
782 return ERR_PTR(-ENOSYS);
783
784 page_list = device->alloc_fast_reg_page_list(device, max_page_list_len);
785
786 if (!IS_ERR(page_list)) {
787 page_list->device = device;
788 page_list->max_page_list_len = max_page_list_len;
789 }
790
791 return page_list;
792}
793EXPORT_SYMBOL(ib_alloc_fast_reg_page_list);
794
795void ib_free_fast_reg_page_list(struct ib_fast_reg_page_list *page_list)
796{
797 page_list->device->free_fast_reg_page_list(page_list);
798}
799EXPORT_SYMBOL(ib_free_fast_reg_page_list);
800
758/* Memory windows */ 801/* Memory windows */
759 802
760struct ib_mw *ib_alloc_mw(struct ib_pd *pd) 803struct ib_mw *ib_alloc_mw(struct ib_pd *pd)
diff --git a/drivers/infiniband/hw/amso1100/c2_rnic.c b/drivers/infiniband/hw/amso1100/c2_rnic.c
index b1441aeb60c2..dd05c4835642 100644
--- a/drivers/infiniband/hw/amso1100/c2_rnic.c
+++ b/drivers/infiniband/hw/amso1100/c2_rnic.c
@@ -454,7 +454,7 @@ int __devinit c2_rnic_init(struct c2_dev *c2dev)
454 (IB_DEVICE_RESIZE_MAX_WR | 454 (IB_DEVICE_RESIZE_MAX_WR |
455 IB_DEVICE_CURR_QP_STATE_MOD | 455 IB_DEVICE_CURR_QP_STATE_MOD |
456 IB_DEVICE_SYS_IMAGE_GUID | 456 IB_DEVICE_SYS_IMAGE_GUID |
457 IB_DEVICE_ZERO_STAG | 457 IB_DEVICE_LOCAL_DMA_LKEY |
458 IB_DEVICE_MEM_WINDOW); 458 IB_DEVICE_MEM_WINDOW);
459 459
460 /* Allocate the qptr_array */ 460 /* Allocate the qptr_array */
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c
index 3f441fc57c17..f6d5747153a5 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.c
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c
@@ -145,7 +145,9 @@ static int cxio_hal_clear_qp_ctx(struct cxio_rdev *rdev_p, u32 qpid)
145 } 145 }
146 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); 146 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe));
147 memset(wqe, 0, sizeof(*wqe)); 147 memset(wqe, 0, sizeof(*wqe));
148 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 3, 0, qpid, 7); 148 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD,
149 T3_COMPLETION_FLAG | T3_NOTIFY_FLAG, 0, qpid, 7,
150 T3_SOPEOP);
149 wqe->flags = cpu_to_be32(MODQP_WRITE_EC); 151 wqe->flags = cpu_to_be32(MODQP_WRITE_EC);
150 sge_cmd = qpid << 8 | 3; 152 sge_cmd = qpid << 8 | 3;
151 wqe->sge_cmd = cpu_to_be64(sge_cmd); 153 wqe->sge_cmd = cpu_to_be64(sge_cmd);
@@ -276,7 +278,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain,
276 if (!wq->qpid) 278 if (!wq->qpid)
277 return -ENOMEM; 279 return -ENOMEM;
278 280
279 wq->rq = kzalloc(depth * sizeof(u64), GFP_KERNEL); 281 wq->rq = kzalloc(depth * sizeof(struct t3_swrq), GFP_KERNEL);
280 if (!wq->rq) 282 if (!wq->rq)
281 goto err1; 283 goto err1;
282 284
@@ -300,6 +302,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain,
300 if (!kernel_domain) 302 if (!kernel_domain)
301 wq->udb = (u64)rdev_p->rnic_info.udbell_physbase + 303 wq->udb = (u64)rdev_p->rnic_info.udbell_physbase +
302 (wq->qpid << rdev_p->qpshift); 304 (wq->qpid << rdev_p->qpshift);
305 wq->rdev = rdev_p;
303 PDBG("%s qpid 0x%x doorbell 0x%p udb 0x%llx\n", __func__, 306 PDBG("%s qpid 0x%x doorbell 0x%p udb 0x%llx\n", __func__,
304 wq->qpid, wq->doorbell, (unsigned long long) wq->udb); 307 wq->qpid, wq->doorbell, (unsigned long long) wq->udb);
305 return 0; 308 return 0;
@@ -558,7 +561,7 @@ static int cxio_hal_init_ctrl_qp(struct cxio_rdev *rdev_p)
558 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe)); 561 wqe = (struct t3_modify_qp_wr *) skb_put(skb, sizeof(*wqe));
559 memset(wqe, 0, sizeof(*wqe)); 562 memset(wqe, 0, sizeof(*wqe));
560 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0, 563 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_QP_MOD, 0, 0,
561 T3_CTL_QP_TID, 7); 564 T3_CTL_QP_TID, 7, T3_SOPEOP);
562 wqe->flags = cpu_to_be32(MODQP_WRITE_EC); 565 wqe->flags = cpu_to_be32(MODQP_WRITE_EC);
563 sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3; 566 sge_cmd = (3ULL << 56) | FW_RI_SGEEC_START << 8 | 3;
564 wqe->sge_cmd = cpu_to_be64(sge_cmd); 567 wqe->sge_cmd = cpu_to_be64(sge_cmd);
@@ -674,7 +677,7 @@ static int cxio_hal_ctrl_qp_write_mem(struct cxio_rdev *rdev_p, u32 addr,
674 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_BP, flag, 677 build_fw_riwrh((struct fw_riwrh *) wqe, T3_WR_BP, flag,
675 Q_GENBIT(rdev_p->ctrl_qp.wptr, 678 Q_GENBIT(rdev_p->ctrl_qp.wptr,
676 T3_CTRL_QP_SIZE_LOG2), T3_CTRL_QP_ID, 679 T3_CTRL_QP_SIZE_LOG2), T3_CTRL_QP_ID,
677 wr_len); 680 wr_len, T3_SOPEOP);
678 if (flag == T3_COMPLETION_FLAG) 681 if (flag == T3_COMPLETION_FLAG)
679 ring_doorbell(rdev_p->ctrl_qp.doorbell, T3_CTRL_QP_ID); 682 ring_doorbell(rdev_p->ctrl_qp.doorbell, T3_CTRL_QP_ID);
680 len -= 96; 683 len -= 96;
@@ -816,6 +819,13 @@ int cxio_deallocate_window(struct cxio_rdev *rdev_p, u32 stag)
816 0, 0); 819 0, 0);
817} 820}
818 821
822int cxio_allocate_stag(struct cxio_rdev *rdev_p, u32 *stag, u32 pdid, u32 pbl_size, u32 pbl_addr)
823{
824 *stag = T3_STAG_UNSET;
825 return __cxio_tpt_op(rdev_p, 0, stag, 0, pdid, TPT_NON_SHARED_MR,
826 0, 0, 0ULL, 0, 0, pbl_size, pbl_addr);
827}
828
819int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr) 829int cxio_rdma_init(struct cxio_rdev *rdev_p, struct t3_rdma_init_attr *attr)
820{ 830{
821 struct t3_rdma_init_wr *wqe; 831 struct t3_rdma_init_wr *wqe;
@@ -1257,13 +1267,16 @@ proc_cqe:
1257 wq->sq_rptr = CQE_WRID_SQ_WPTR(*hw_cqe); 1267 wq->sq_rptr = CQE_WRID_SQ_WPTR(*hw_cqe);
1258 PDBG("%s completing sq idx %ld\n", __func__, 1268 PDBG("%s completing sq idx %ld\n", __func__,
1259 Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2)); 1269 Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2));
1260 *cookie = (wq->sq + 1270 *cookie = wq->sq[Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2)].wr_id;
1261 Q_PTR2IDX(wq->sq_rptr, wq->sq_size_log2))->wr_id;
1262 wq->sq_rptr++; 1271 wq->sq_rptr++;
1263 } else { 1272 } else {
1264 PDBG("%s completing rq idx %ld\n", __func__, 1273 PDBG("%s completing rq idx %ld\n", __func__,
1265 Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); 1274 Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2));
1266 *cookie = *(wq->rq + Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)); 1275 *cookie = wq->rq[Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)].wr_id;
1276 if (wq->rq[Q_PTR2IDX(wq->rq_rptr, wq->rq_size_log2)].pbl_addr)
1277 cxio_hal_pblpool_free(wq->rdev,
1278 wq->rq[Q_PTR2IDX(wq->rq_rptr,
1279 wq->rq_size_log2)].pbl_addr, T3_STAG0_PBL_SIZE);
1267 wq->rq_rptr++; 1280 wq->rq_rptr++;
1268 } 1281 }
1269 1282
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.h b/drivers/infiniband/hw/cxgb3/cxio_hal.h
index 6e128f6bab05..656fe47bc84f 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_hal.h
+++ b/drivers/infiniband/hw/cxgb3/cxio_hal.h
@@ -45,15 +45,17 @@
45#define T3_CTRL_QP_SIZE_LOG2 8 45#define T3_CTRL_QP_SIZE_LOG2 8
46#define T3_CTRL_CQ_ID 0 46#define T3_CTRL_CQ_ID 0
47 47
48/* TBD */
49#define T3_MAX_NUM_RI (1<<15) 48#define T3_MAX_NUM_RI (1<<15)
50#define T3_MAX_NUM_QP (1<<15) 49#define T3_MAX_NUM_QP (1<<15)
51#define T3_MAX_NUM_CQ (1<<15) 50#define T3_MAX_NUM_CQ (1<<15)
52#define T3_MAX_NUM_PD (1<<15) 51#define T3_MAX_NUM_PD (1<<15)
53#define T3_MAX_PBL_SIZE 256 52#define T3_MAX_PBL_SIZE 256
54#define T3_MAX_RQ_SIZE 1024 53#define T3_MAX_RQ_SIZE 1024
54#define T3_MAX_QP_DEPTH (T3_MAX_RQ_SIZE-1)
55#define T3_MAX_CQ_DEPTH 8192
55#define T3_MAX_NUM_STAG (1<<15) 56#define T3_MAX_NUM_STAG (1<<15)
56#define T3_MAX_MR_SIZE 0x100000000ULL 57#define T3_MAX_MR_SIZE 0x100000000ULL
58#define T3_PAGESIZE_MASK 0xffff000 /* 4KB-128MB */
57 59
58#define T3_STAG_UNSET 0xffffffff 60#define T3_STAG_UNSET 0xffffffff
59 61
@@ -165,6 +167,7 @@ int cxio_reregister_phys_mem(struct cxio_rdev *rdev, u32 * stag, u32 pdid,
165int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size, 167int cxio_dereg_mem(struct cxio_rdev *rdev, u32 stag, u32 pbl_size,
166 u32 pbl_addr); 168 u32 pbl_addr);
167int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid); 169int cxio_allocate_window(struct cxio_rdev *rdev, u32 * stag, u32 pdid);
170int cxio_allocate_stag(struct cxio_rdev *rdev, u32 *stag, u32 pdid, u32 pbl_size, u32 pbl_addr);
168int cxio_deallocate_window(struct cxio_rdev *rdev, u32 stag); 171int cxio_deallocate_window(struct cxio_rdev *rdev, u32 stag);
169int cxio_rdma_init(struct cxio_rdev *rdev, struct t3_rdma_init_attr *attr); 172int cxio_rdma_init(struct cxio_rdev *rdev, struct t3_rdma_init_attr *attr);
170void cxio_register_ev_cb(cxio_hal_ev_callback_func_t ev_cb); 173void cxio_register_ev_cb(cxio_hal_ev_callback_func_t ev_cb);
diff --git a/drivers/infiniband/hw/cxgb3/cxio_wr.h b/drivers/infiniband/hw/cxgb3/cxio_wr.h
index f1a25a821a45..04618f7bfbb3 100644
--- a/drivers/infiniband/hw/cxgb3/cxio_wr.h
+++ b/drivers/infiniband/hw/cxgb3/cxio_wr.h
@@ -39,6 +39,9 @@
39 39
40#define T3_MAX_SGE 4 40#define T3_MAX_SGE 4
41#define T3_MAX_INLINE 64 41#define T3_MAX_INLINE 64
42#define T3_STAG0_PBL_SIZE (2 * T3_MAX_SGE << 3)
43#define T3_STAG0_MAX_PBE_LEN (128 * 1024 * 1024)
44#define T3_STAG0_PAGE_SHIFT 15
42 45
43#define Q_EMPTY(rptr,wptr) ((rptr)==(wptr)) 46#define Q_EMPTY(rptr,wptr) ((rptr)==(wptr))
44#define Q_FULL(rptr,wptr,size_log2) ( (((wptr)-(rptr))>>(size_log2)) && \ 47#define Q_FULL(rptr,wptr,size_log2) ( (((wptr)-(rptr))>>(size_log2)) && \
@@ -72,7 +75,8 @@ enum t3_wr_opcode {
72 T3_WR_BIND = FW_WROPCODE_RI_BIND_MW, 75 T3_WR_BIND = FW_WROPCODE_RI_BIND_MW,
73 T3_WR_RCV = FW_WROPCODE_RI_RECEIVE, 76 T3_WR_RCV = FW_WROPCODE_RI_RECEIVE,
74 T3_WR_INIT = FW_WROPCODE_RI_RDMA_INIT, 77 T3_WR_INIT = FW_WROPCODE_RI_RDMA_INIT,
75 T3_WR_QP_MOD = FW_WROPCODE_RI_MODIFY_QP 78 T3_WR_QP_MOD = FW_WROPCODE_RI_MODIFY_QP,
79 T3_WR_FASTREG = FW_WROPCODE_RI_FASTREGISTER_MR
76} __attribute__ ((packed)); 80} __attribute__ ((packed));
77 81
78enum t3_rdma_opcode { 82enum t3_rdma_opcode {
@@ -89,7 +93,8 @@ enum t3_rdma_opcode {
89 T3_FAST_REGISTER, 93 T3_FAST_REGISTER,
90 T3_LOCAL_INV, 94 T3_LOCAL_INV,
91 T3_QP_MOD, 95 T3_QP_MOD,
92 T3_BYPASS 96 T3_BYPASS,
97 T3_RDMA_READ_REQ_WITH_INV,
93} __attribute__ ((packed)); 98} __attribute__ ((packed));
94 99
95static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop) 100static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop)
@@ -103,6 +108,7 @@ static inline enum t3_rdma_opcode wr2opcode(enum t3_wr_opcode wrop)
103 case T3_WR_BIND: return T3_BIND_MW; 108 case T3_WR_BIND: return T3_BIND_MW;
104 case T3_WR_INIT: return T3_RDMA_INIT; 109 case T3_WR_INIT: return T3_RDMA_INIT;
105 case T3_WR_QP_MOD: return T3_QP_MOD; 110 case T3_WR_QP_MOD: return T3_QP_MOD;
111 case T3_WR_FASTREG: return T3_FAST_REGISTER;
106 default: break; 112 default: break;
107 } 113 }
108 return -1; 114 return -1;
@@ -170,11 +176,54 @@ struct t3_send_wr {
170 struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */ 176 struct t3_sge sgl[T3_MAX_SGE]; /* 4+ */
171}; 177};
172 178
179#define T3_MAX_FASTREG_DEPTH 24
180#define T3_MAX_FASTREG_FRAG 10
181
182struct t3_fastreg_wr {
183 struct fw_riwrh wrh; /* 0 */
184 union t3_wrid wrid; /* 1 */
185 __be32 stag; /* 2 */
186 __be32 len;
187 __be32 va_base_hi; /* 3 */
188 __be32 va_base_lo_fbo;
189 __be32 page_type_perms; /* 4 */
190 __be32 reserved1;
191 __be64 pbl_addrs[0]; /* 5+ */
192};
193
194/*
195 * If a fastreg wr spans multiple wqes, then the 2nd fragment look like this.
196 */
197struct t3_pbl_frag {
198 struct fw_riwrh wrh; /* 0 */
199 __be64 pbl_addrs[14]; /* 1..14 */
200};
201
202#define S_FR_PAGE_COUNT 24
203#define M_FR_PAGE_COUNT 0xff
204#define V_FR_PAGE_COUNT(x) ((x) << S_FR_PAGE_COUNT)
205#define G_FR_PAGE_COUNT(x) ((((x) >> S_FR_PAGE_COUNT)) & M_FR_PAGE_COUNT)
206
207#define S_FR_PAGE_SIZE 16
208#define M_FR_PAGE_SIZE 0x1f
209#define V_FR_PAGE_SIZE(x) ((x) << S_FR_PAGE_SIZE)
210#define G_FR_PAGE_SIZE(x) ((((x) >> S_FR_PAGE_SIZE)) & M_FR_PAGE_SIZE)
211
212#define S_FR_TYPE 8
213#define M_FR_TYPE 0x1
214#define V_FR_TYPE(x) ((x) << S_FR_TYPE)
215#define G_FR_TYPE(x) ((((x) >> S_FR_TYPE)) & M_FR_TYPE)
216
217#define S_FR_PERMS 0
218#define M_FR_PERMS 0xff
219#define V_FR_PERMS(x) ((x) << S_FR_PERMS)
220#define G_FR_PERMS(x) ((((x) >> S_FR_PERMS)) & M_FR_PERMS)
221
173struct t3_local_inv_wr { 222struct t3_local_inv_wr {
174 struct fw_riwrh wrh; /* 0 */ 223 struct fw_riwrh wrh; /* 0 */
175 union t3_wrid wrid; /* 1 */ 224 union t3_wrid wrid; /* 1 */
176 __be32 stag; /* 2 */ 225 __be32 stag; /* 2 */
177 __be32 reserved3; 226 __be32 reserved;
178}; 227};
179 228
180struct t3_rdma_write_wr { 229struct t3_rdma_write_wr {
@@ -193,7 +242,8 @@ struct t3_rdma_read_wr {
193 struct fw_riwrh wrh; /* 0 */ 242 struct fw_riwrh wrh; /* 0 */
194 union t3_wrid wrid; /* 1 */ 243 union t3_wrid wrid; /* 1 */
195 u8 rdmaop; /* 2 */ 244 u8 rdmaop; /* 2 */
196 u8 reserved[3]; 245 u8 local_inv;
246 u8 reserved[2];
197 __be32 rem_stag; 247 __be32 rem_stag;
198 __be64 rem_to; /* 3 */ 248 __be64 rem_to; /* 3 */
199 __be32 local_stag; /* 4 */ 249 __be32 local_stag; /* 4 */
@@ -201,18 +251,6 @@ struct t3_rdma_read_wr {
201 __be64 local_to; /* 5 */ 251 __be64 local_to; /* 5 */
202}; 252};
203 253
204enum t3_addr_type {
205 T3_VA_BASED_TO = 0x0,
206 T3_ZERO_BASED_TO = 0x1
207} __attribute__ ((packed));
208
209enum t3_mem_perms {
210 T3_MEM_ACCESS_LOCAL_READ = 0x1,
211 T3_MEM_ACCESS_LOCAL_WRITE = 0x2,
212 T3_MEM_ACCESS_REM_READ = 0x4,
213 T3_MEM_ACCESS_REM_WRITE = 0x8
214} __attribute__ ((packed));
215
216struct t3_bind_mw_wr { 254struct t3_bind_mw_wr {
217 struct fw_riwrh wrh; /* 0 */ 255 struct fw_riwrh wrh; /* 0 */
218 union t3_wrid wrid; /* 1 */ 256 union t3_wrid wrid; /* 1 */
@@ -336,6 +374,11 @@ struct t3_genbit {
336 __be64 genbit; 374 __be64 genbit;
337}; 375};
338 376
377struct t3_wq_in_err {
378 u64 flit[13];
379 u64 err;
380};
381
339enum rdma_init_wr_flags { 382enum rdma_init_wr_flags {
340 MPA_INITIATOR = (1<<0), 383 MPA_INITIATOR = (1<<0),
341 PRIV_QP = (1<<1), 384 PRIV_QP = (1<<1),
@@ -346,13 +389,16 @@ union t3_wr {
346 struct t3_rdma_write_wr write; 389 struct t3_rdma_write_wr write;
347 struct t3_rdma_read_wr read; 390 struct t3_rdma_read_wr read;
348 struct t3_receive_wr recv; 391 struct t3_receive_wr recv;
392 struct t3_fastreg_wr fastreg;
393 struct t3_pbl_frag pbl_frag;
349 struct t3_local_inv_wr local_inv; 394 struct t3_local_inv_wr local_inv;
350 struct t3_bind_mw_wr bind; 395 struct t3_bind_mw_wr bind;
351 struct t3_bypass_wr bypass; 396 struct t3_bypass_wr bypass;
352 struct t3_rdma_init_wr init; 397 struct t3_rdma_init_wr init;
353 struct t3_modify_qp_wr qp_mod; 398 struct t3_modify_qp_wr qp_mod;
354 struct t3_genbit genbit; 399 struct t3_genbit genbit;
355 u64 flit[16]; 400 struct t3_wq_in_err wq_in_err;
401 __be64 flit[16];
356}; 402};
357 403
358#define T3_SQ_CQE_FLIT 13 404#define T3_SQ_CQE_FLIT 13
@@ -366,12 +412,18 @@ static inline enum t3_wr_opcode fw_riwrh_opcode(struct fw_riwrh *wqe)
366 return G_FW_RIWR_OP(be32_to_cpu(wqe->op_seop_flags)); 412 return G_FW_RIWR_OP(be32_to_cpu(wqe->op_seop_flags));
367} 413}
368 414
415enum t3_wr_hdr_bits {
416 T3_EOP = 1,
417 T3_SOP = 2,
418 T3_SOPEOP = T3_EOP|T3_SOP,
419};
420
369static inline void build_fw_riwrh(struct fw_riwrh *wqe, enum t3_wr_opcode op, 421static inline void build_fw_riwrh(struct fw_riwrh *wqe, enum t3_wr_opcode op,
370 enum t3_wr_flags flags, u8 genbit, u32 tid, 422 enum t3_wr_flags flags, u8 genbit, u32 tid,
371 u8 len) 423 u8 len, u8 sopeop)
372{ 424{
373 wqe->op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(op) | 425 wqe->op_seop_flags = cpu_to_be32(V_FW_RIWR_OP(op) |
374 V_FW_RIWR_SOPEOP(M_FW_RIWR_SOPEOP) | 426 V_FW_RIWR_SOPEOP(sopeop) |
375 V_FW_RIWR_FLAGS(flags)); 427 V_FW_RIWR_FLAGS(flags));
376 wmb(); 428 wmb();
377 wqe->gen_tid_len = cpu_to_be32(V_FW_RIWR_GEN(genbit) | 429 wqe->gen_tid_len = cpu_to_be32(V_FW_RIWR_GEN(genbit) |
@@ -404,6 +456,7 @@ enum tpt_addr_type {
404}; 456};
405 457
406enum tpt_mem_perm { 458enum tpt_mem_perm {
459 TPT_MW_BIND = 0x10,
407 TPT_LOCAL_READ = 0x8, 460 TPT_LOCAL_READ = 0x8,
408 TPT_LOCAL_WRITE = 0x4, 461 TPT_LOCAL_WRITE = 0x4,
409 TPT_REMOTE_READ = 0x2, 462 TPT_REMOTE_READ = 0x2,
@@ -615,6 +668,11 @@ struct t3_swsq {
615 int signaled; 668 int signaled;
616}; 669};
617 670
671struct t3_swrq {
672 __u64 wr_id;
673 __u32 pbl_addr;
674};
675
618/* 676/*
619 * A T3 WQ implements both the SQ and RQ. 677 * A T3 WQ implements both the SQ and RQ.
620 */ 678 */
@@ -631,14 +689,15 @@ struct t3_wq {
631 u32 sq_wptr; /* sq_wptr - sq_rptr == count of */ 689 u32 sq_wptr; /* sq_wptr - sq_rptr == count of */
632 u32 sq_rptr; /* pending wrs */ 690 u32 sq_rptr; /* pending wrs */
633 u32 sq_size_log2; /* sq size */ 691 u32 sq_size_log2; /* sq size */
634 u64 *rq; /* SW RQ (holds consumer wr_ids */ 692 struct t3_swrq *rq; /* SW RQ (holds consumer wr_ids */
635 u32 rq_wptr; /* rq_wptr - rq_rptr == count of */ 693 u32 rq_wptr; /* rq_wptr - rq_rptr == count of */
636 u32 rq_rptr; /* pending wrs */ 694 u32 rq_rptr; /* pending wrs */
637 u64 *rq_oldest_wr; /* oldest wr on the SW RQ */ 695 struct t3_swrq *rq_oldest_wr; /* oldest wr on the SW RQ */
638 u32 rq_size_log2; /* rq size */ 696 u32 rq_size_log2; /* rq size */
639 u32 rq_addr; /* rq adapter address */ 697 u32 rq_addr; /* rq adapter address */
640 void __iomem *doorbell; /* kernel db */ 698 void __iomem *doorbell; /* kernel db */
641 u64 udb; /* user db if any */ 699 u64 udb; /* user db if any */
700 struct cxio_rdev *rdev;
642}; 701};
643 702
644struct t3_cq { 703struct t3_cq {
@@ -659,7 +718,7 @@ struct t3_cq {
659 718
660static inline void cxio_set_wq_in_error(struct t3_wq *wq) 719static inline void cxio_set_wq_in_error(struct t3_wq *wq)
661{ 720{
662 wq->queue->flit[13] = 1; 721 wq->queue->wq_in_err.err = 1;
663} 722}
664 723
665static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq) 724static inline struct t3_cqe *cxio_next_hw_cqe(struct t3_cq *cq)
diff --git a/drivers/infiniband/hw/cxgb3/iwch.c b/drivers/infiniband/hw/cxgb3/iwch.c
index 71554eacb13c..4489c89d6710 100644
--- a/drivers/infiniband/hw/cxgb3/iwch.c
+++ b/drivers/infiniband/hw/cxgb3/iwch.c
@@ -71,18 +71,16 @@ static void rnic_init(struct iwch_dev *rnicp)
71 idr_init(&rnicp->mmidr); 71 idr_init(&rnicp->mmidr);
72 spin_lock_init(&rnicp->lock); 72 spin_lock_init(&rnicp->lock);
73 73
74 rnicp->attr.vendor_id = 0x168;
75 rnicp->attr.vendor_part_id = 7;
76 rnicp->attr.max_qps = T3_MAX_NUM_QP - 32; 74 rnicp->attr.max_qps = T3_MAX_NUM_QP - 32;
77 rnicp->attr.max_wrs = (1UL << 24) - 1; 75 rnicp->attr.max_wrs = T3_MAX_QP_DEPTH;
78 rnicp->attr.max_sge_per_wr = T3_MAX_SGE; 76 rnicp->attr.max_sge_per_wr = T3_MAX_SGE;
79 rnicp->attr.max_sge_per_rdma_write_wr = T3_MAX_SGE; 77 rnicp->attr.max_sge_per_rdma_write_wr = T3_MAX_SGE;
80 rnicp->attr.max_cqs = T3_MAX_NUM_CQ - 1; 78 rnicp->attr.max_cqs = T3_MAX_NUM_CQ - 1;
81 rnicp->attr.max_cqes_per_cq = (1UL << 24) - 1; 79 rnicp->attr.max_cqes_per_cq = T3_MAX_CQ_DEPTH;
82 rnicp->attr.max_mem_regs = cxio_num_stags(&rnicp->rdev); 80 rnicp->attr.max_mem_regs = cxio_num_stags(&rnicp->rdev);
83 rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE; 81 rnicp->attr.max_phys_buf_entries = T3_MAX_PBL_SIZE;
84 rnicp->attr.max_pds = T3_MAX_NUM_PD - 1; 82 rnicp->attr.max_pds = T3_MAX_NUM_PD - 1;
85 rnicp->attr.mem_pgsizes_bitmask = 0x7FFF; /* 4KB-128MB */ 83 rnicp->attr.mem_pgsizes_bitmask = T3_PAGESIZE_MASK;
86 rnicp->attr.max_mr_size = T3_MAX_MR_SIZE; 84 rnicp->attr.max_mr_size = T3_MAX_MR_SIZE;
87 rnicp->attr.can_resize_wq = 0; 85 rnicp->attr.can_resize_wq = 0;
88 rnicp->attr.max_rdma_reads_per_qp = 8; 86 rnicp->attr.max_rdma_reads_per_qp = 8;
diff --git a/drivers/infiniband/hw/cxgb3/iwch.h b/drivers/infiniband/hw/cxgb3/iwch.h
index d2409a505e8d..3773453b2cf0 100644
--- a/drivers/infiniband/hw/cxgb3/iwch.h
+++ b/drivers/infiniband/hw/cxgb3/iwch.h
@@ -48,8 +48,6 @@ struct iwch_qp;
48struct iwch_mr; 48struct iwch_mr;
49 49
50struct iwch_rnic_attributes { 50struct iwch_rnic_attributes {
51 u32 vendor_id;
52 u32 vendor_part_id;
53 u32 max_qps; 51 u32 max_qps;
54 u32 max_wrs; /* Max for any SQ/RQ */ 52 u32 max_wrs; /* Max for any SQ/RQ */
55 u32 max_sge_per_wr; 53 u32 max_sge_per_wr;
diff --git a/drivers/infiniband/hw/cxgb3/iwch_cq.c b/drivers/infiniband/hw/cxgb3/iwch_cq.c
index 4ee8ccd0a9e5..cf5474ae68ff 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_cq.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_cq.c
@@ -81,6 +81,7 @@ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp,
81 wc->wr_id = cookie; 81 wc->wr_id = cookie;
82 wc->qp = &qhp->ibqp; 82 wc->qp = &qhp->ibqp;
83 wc->vendor_err = CQE_STATUS(cqe); 83 wc->vendor_err = CQE_STATUS(cqe);
84 wc->wc_flags = 0;
84 85
85 PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x " 86 PDBG("%s qpid 0x%x type %d opcode %d status 0x%x wrid hi 0x%x "
86 "lo 0x%x cookie 0x%llx\n", __func__, 87 "lo 0x%x cookie 0x%llx\n", __func__,
@@ -94,6 +95,11 @@ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp,
94 else 95 else
95 wc->byte_len = 0; 96 wc->byte_len = 0;
96 wc->opcode = IB_WC_RECV; 97 wc->opcode = IB_WC_RECV;
98 if (CQE_OPCODE(cqe) == T3_SEND_WITH_INV ||
99 CQE_OPCODE(cqe) == T3_SEND_WITH_SE_INV) {
100 wc->ex.invalidate_rkey = CQE_WRID_STAG(cqe);
101 wc->wc_flags |= IB_WC_WITH_INVALIDATE;
102 }
97 } else { 103 } else {
98 switch (CQE_OPCODE(cqe)) { 104 switch (CQE_OPCODE(cqe)) {
99 case T3_RDMA_WRITE: 105 case T3_RDMA_WRITE:
@@ -105,17 +111,20 @@ static int iwch_poll_cq_one(struct iwch_dev *rhp, struct iwch_cq *chp,
105 break; 111 break;
106 case T3_SEND: 112 case T3_SEND:
107 case T3_SEND_WITH_SE: 113 case T3_SEND_WITH_SE:
114 case T3_SEND_WITH_INV:
115 case T3_SEND_WITH_SE_INV:
108 wc->opcode = IB_WC_SEND; 116 wc->opcode = IB_WC_SEND;
109 break; 117 break;
110 case T3_BIND_MW: 118 case T3_BIND_MW:
111 wc->opcode = IB_WC_BIND_MW; 119 wc->opcode = IB_WC_BIND_MW;
112 break; 120 break;
113 121
114 /* these aren't supported yet */
115 case T3_SEND_WITH_INV:
116 case T3_SEND_WITH_SE_INV:
117 case T3_LOCAL_INV: 122 case T3_LOCAL_INV:
123 wc->opcode = IB_WC_LOCAL_INV;
124 break;
118 case T3_FAST_REGISTER: 125 case T3_FAST_REGISTER:
126 wc->opcode = IB_WC_FAST_REG_MR;
127 break;
119 default: 128 default:
120 printk(KERN_ERR MOD "Unexpected opcode %d " 129 printk(KERN_ERR MOD "Unexpected opcode %d "
121 "in the CQE received for QPID=0x%0x\n", 130 "in the CQE received for QPID=0x%0x\n",
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.c b/drivers/infiniband/hw/cxgb3/iwch_provider.c
index 8934178a23ee..b89640aa6e10 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.c
@@ -56,6 +56,7 @@
56#include "iwch_provider.h" 56#include "iwch_provider.h"
57#include "iwch_cm.h" 57#include "iwch_cm.h"
58#include "iwch_user.h" 58#include "iwch_user.h"
59#include "common.h"
59 60
60static int iwch_modify_port(struct ib_device *ibdev, 61static int iwch_modify_port(struct ib_device *ibdev,
61 u8 port, int port_modify_mask, 62 u8 port, int port_modify_mask,
@@ -747,6 +748,7 @@ static struct ib_mw *iwch_alloc_mw(struct ib_pd *pd)
747 mhp->attr.type = TPT_MW; 748 mhp->attr.type = TPT_MW;
748 mhp->attr.stag = stag; 749 mhp->attr.stag = stag;
749 mmid = (stag) >> 8; 750 mmid = (stag) >> 8;
751 mhp->ibmw.rkey = stag;
750 insert_handle(rhp, &rhp->mmidr, mhp, mmid); 752 insert_handle(rhp, &rhp->mmidr, mhp, mmid);
751 PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag); 753 PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
752 return &(mhp->ibmw); 754 return &(mhp->ibmw);
@@ -768,6 +770,68 @@ static int iwch_dealloc_mw(struct ib_mw *mw)
768 return 0; 770 return 0;
769} 771}
770 772
773static struct ib_mr *iwch_alloc_fast_reg_mr(struct ib_pd *pd, int pbl_depth)
774{
775 struct iwch_dev *rhp;
776 struct iwch_pd *php;
777 struct iwch_mr *mhp;
778 u32 mmid;
779 u32 stag = 0;
780 int ret;
781
782 php = to_iwch_pd(pd);
783 rhp = php->rhp;
784 mhp = kzalloc(sizeof(*mhp), GFP_KERNEL);
785 if (!mhp)
786 return ERR_PTR(-ENOMEM);
787
788 mhp->rhp = rhp;
789 ret = iwch_alloc_pbl(mhp, pbl_depth);
790 if (ret) {
791 kfree(mhp);
792 return ERR_PTR(ret);
793 }
794 mhp->attr.pbl_size = pbl_depth;
795 ret = cxio_allocate_stag(&rhp->rdev, &stag, php->pdid,
796 mhp->attr.pbl_size, mhp->attr.pbl_addr);
797 if (ret) {
798 iwch_free_pbl(mhp);
799 kfree(mhp);
800 return ERR_PTR(ret);
801 }
802 mhp->attr.pdid = php->pdid;
803 mhp->attr.type = TPT_NON_SHARED_MR;
804 mhp->attr.stag = stag;
805 mhp->attr.state = 1;
806 mmid = (stag) >> 8;
807 mhp->ibmr.rkey = mhp->ibmr.lkey = stag;
808 insert_handle(rhp, &rhp->mmidr, mhp, mmid);
809 PDBG("%s mmid 0x%x mhp %p stag 0x%x\n", __func__, mmid, mhp, stag);
810 return &(mhp->ibmr);
811}
812
813static struct ib_fast_reg_page_list *iwch_alloc_fastreg_pbl(
814 struct ib_device *device,
815 int page_list_len)
816{
817 struct ib_fast_reg_page_list *page_list;
818
819 page_list = kmalloc(sizeof *page_list + page_list_len * sizeof(u64),
820 GFP_KERNEL);
821 if (!page_list)
822 return ERR_PTR(-ENOMEM);
823
824 page_list->page_list = (u64 *)(page_list + 1);
825 page_list->max_page_list_len = page_list_len;
826
827 return page_list;
828}
829
830static void iwch_free_fastreg_pbl(struct ib_fast_reg_page_list *page_list)
831{
832 kfree(page_list);
833}
834
771static int iwch_destroy_qp(struct ib_qp *ib_qp) 835static int iwch_destroy_qp(struct ib_qp *ib_qp)
772{ 836{
773 struct iwch_dev *rhp; 837 struct iwch_dev *rhp;
@@ -843,6 +907,15 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
843 */ 907 */
844 sqsize = roundup_pow_of_two(attrs->cap.max_send_wr); 908 sqsize = roundup_pow_of_two(attrs->cap.max_send_wr);
845 wqsize = roundup_pow_of_two(rqsize + sqsize); 909 wqsize = roundup_pow_of_two(rqsize + sqsize);
910
911 /*
912 * Kernel users need more wq space for fastreg WRs which can take
913 * 2 WR fragments.
914 */
915 ucontext = pd->uobject ? to_iwch_ucontext(pd->uobject->context) : NULL;
916 if (!ucontext && wqsize < (rqsize + (2 * sqsize)))
917 wqsize = roundup_pow_of_two(rqsize +
918 roundup_pow_of_two(attrs->cap.max_send_wr * 2));
846 PDBG("%s wqsize %d sqsize %d rqsize %d\n", __func__, 919 PDBG("%s wqsize %d sqsize %d rqsize %d\n", __func__,
847 wqsize, sqsize, rqsize); 920 wqsize, sqsize, rqsize);
848 qhp = kzalloc(sizeof(*qhp), GFP_KERNEL); 921 qhp = kzalloc(sizeof(*qhp), GFP_KERNEL);
@@ -851,7 +924,6 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
851 qhp->wq.size_log2 = ilog2(wqsize); 924 qhp->wq.size_log2 = ilog2(wqsize);
852 qhp->wq.rq_size_log2 = ilog2(rqsize); 925 qhp->wq.rq_size_log2 = ilog2(rqsize);
853 qhp->wq.sq_size_log2 = ilog2(sqsize); 926 qhp->wq.sq_size_log2 = ilog2(sqsize);
854 ucontext = pd->uobject ? to_iwch_ucontext(pd->uobject->context) : NULL;
855 if (cxio_create_qp(&rhp->rdev, !udata, &qhp->wq, 927 if (cxio_create_qp(&rhp->rdev, !udata, &qhp->wq,
856 ucontext ? &ucontext->uctx : &rhp->rdev.uctx)) { 928 ucontext ? &ucontext->uctx : &rhp->rdev.uctx)) {
857 kfree(qhp); 929 kfree(qhp);
@@ -935,10 +1007,10 @@ static struct ib_qp *iwch_create_qp(struct ib_pd *pd,
935 qhp->ibqp.qp_num = qhp->wq.qpid; 1007 qhp->ibqp.qp_num = qhp->wq.qpid;
936 init_timer(&(qhp->timer)); 1008 init_timer(&(qhp->timer));
937 PDBG("%s sq_num_entries %d, rq_num_entries %d " 1009 PDBG("%s sq_num_entries %d, rq_num_entries %d "
938 "qpid 0x%0x qhp %p dma_addr 0x%llx size %d\n", 1010 "qpid 0x%0x qhp %p dma_addr 0x%llx size %d rq_addr 0x%x\n",
939 __func__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries, 1011 __func__, qhp->attr.sq_num_entries, qhp->attr.rq_num_entries,
940 qhp->wq.qpid, qhp, (unsigned long long) qhp->wq.dma_addr, 1012 qhp->wq.qpid, qhp, (unsigned long long) qhp->wq.dma_addr,
941 1 << qhp->wq.size_log2); 1013 1 << qhp->wq.size_log2, qhp->wq.rq_addr);
942 return &qhp->ibqp; 1014 return &qhp->ibqp;
943} 1015}
944 1016
@@ -1023,6 +1095,29 @@ static int iwch_query_gid(struct ib_device *ibdev, u8 port,
1023 return 0; 1095 return 0;
1024} 1096}
1025 1097
1098static u64 fw_vers_string_to_u64(struct iwch_dev *iwch_dev)
1099{
1100 struct ethtool_drvinfo info;
1101 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1102 char *cp, *next;
1103 unsigned fw_maj, fw_min, fw_mic;
1104
1105 rtnl_lock();
1106 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1107 rtnl_unlock();
1108
1109 next = info.fw_version + 1;
1110 cp = strsep(&next, ".");
1111 sscanf(cp, "%i", &fw_maj);
1112 cp = strsep(&next, ".");
1113 sscanf(cp, "%i", &fw_min);
1114 cp = strsep(&next, ".");
1115 sscanf(cp, "%i", &fw_mic);
1116
1117 return (((u64)fw_maj & 0xffff) << 32) | ((fw_min & 0xffff) << 16) |
1118 (fw_mic & 0xffff);
1119}
1120
1026static int iwch_query_device(struct ib_device *ibdev, 1121static int iwch_query_device(struct ib_device *ibdev,
1027 struct ib_device_attr *props) 1122 struct ib_device_attr *props)
1028{ 1123{
@@ -1033,7 +1128,10 @@ static int iwch_query_device(struct ib_device *ibdev,
1033 dev = to_iwch_dev(ibdev); 1128 dev = to_iwch_dev(ibdev);
1034 memset(props, 0, sizeof *props); 1129 memset(props, 0, sizeof *props);
1035 memcpy(&props->sys_image_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); 1130 memcpy(&props->sys_image_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6);
1131 props->hw_ver = dev->rdev.t3cdev_p->type;
1132 props->fw_ver = fw_vers_string_to_u64(dev);
1036 props->device_cap_flags = dev->device_cap_flags; 1133 props->device_cap_flags = dev->device_cap_flags;
1134 props->page_size_cap = dev->attr.mem_pgsizes_bitmask;
1037 props->vendor_id = (u32)dev->rdev.rnic_info.pdev->vendor; 1135 props->vendor_id = (u32)dev->rdev.rnic_info.pdev->vendor;
1038 props->vendor_part_id = (u32)dev->rdev.rnic_info.pdev->device; 1136 props->vendor_part_id = (u32)dev->rdev.rnic_info.pdev->device;
1039 props->max_mr_size = dev->attr.max_mr_size; 1137 props->max_mr_size = dev->attr.max_mr_size;
@@ -1048,6 +1146,7 @@ static int iwch_query_device(struct ib_device *ibdev,
1048 props->max_mr = dev->attr.max_mem_regs; 1146 props->max_mr = dev->attr.max_mem_regs;
1049 props->max_pd = dev->attr.max_pds; 1147 props->max_pd = dev->attr.max_pds;
1050 props->local_ca_ack_delay = 0; 1148 props->local_ca_ack_delay = 0;
1149 props->max_fast_reg_page_list_len = T3_MAX_FASTREG_DEPTH;
1051 1150
1052 return 0; 1151 return 0;
1053} 1152}
@@ -1088,6 +1187,28 @@ static ssize_t show_rev(struct device *dev, struct device_attribute *attr,
1088 return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type); 1187 return sprintf(buf, "%d\n", iwch_dev->rdev.t3cdev_p->type);
1089} 1188}
1090 1189
1190static int fw_supports_fastreg(struct iwch_dev *iwch_dev)
1191{
1192 struct ethtool_drvinfo info;
1193 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1194 char *cp, *next;
1195 unsigned fw_maj, fw_min;
1196
1197 rtnl_lock();
1198 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1199 rtnl_unlock();
1200
1201 next = info.fw_version+1;
1202 cp = strsep(&next, ".");
1203 sscanf(cp, "%i", &fw_maj);
1204 cp = strsep(&next, ".");
1205 sscanf(cp, "%i", &fw_min);
1206
1207 PDBG("%s maj %u min %u\n", __func__, fw_maj, fw_min);
1208
1209 return fw_maj > 6 || (fw_maj == 6 && fw_min > 0);
1210}
1211
1091static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf) 1212static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, char *buf)
1092{ 1213{
1093 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev, 1214 struct iwch_dev *iwch_dev = container_of(dev, struct iwch_dev,
@@ -1096,7 +1217,9 @@ static ssize_t show_fw_ver(struct device *dev, struct device_attribute *attr, ch
1096 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; 1217 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1097 1218
1098 PDBG("%s dev 0x%p\n", __func__, dev); 1219 PDBG("%s dev 0x%p\n", __func__, dev);
1220 rtnl_lock();
1099 lldev->ethtool_ops->get_drvinfo(lldev, &info); 1221 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1222 rtnl_unlock();
1100 return sprintf(buf, "%s\n", info.fw_version); 1223 return sprintf(buf, "%s\n", info.fw_version);
1101} 1224}
1102 1225
@@ -1109,7 +1232,9 @@ static ssize_t show_hca(struct device *dev, struct device_attribute *attr,
1109 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev; 1232 struct net_device *lldev = iwch_dev->rdev.t3cdev_p->lldev;
1110 1233
1111 PDBG("%s dev 0x%p\n", __func__, dev); 1234 PDBG("%s dev 0x%p\n", __func__, dev);
1235 rtnl_lock();
1112 lldev->ethtool_ops->get_drvinfo(lldev, &info); 1236 lldev->ethtool_ops->get_drvinfo(lldev, &info);
1237 rtnl_unlock();
1113 return sprintf(buf, "%s\n", info.driver); 1238 return sprintf(buf, "%s\n", info.driver);
1114} 1239}
1115 1240
@@ -1123,6 +1248,61 @@ static ssize_t show_board(struct device *dev, struct device_attribute *attr,
1123 iwch_dev->rdev.rnic_info.pdev->device); 1248 iwch_dev->rdev.rnic_info.pdev->device);
1124} 1249}
1125 1250
1251static int iwch_get_mib(struct ib_device *ibdev,
1252 union rdma_protocol_stats *stats)
1253{
1254 struct iwch_dev *dev;
1255 struct tp_mib_stats m;
1256 int ret;
1257
1258 PDBG("%s ibdev %p\n", __func__, ibdev);
1259 dev = to_iwch_dev(ibdev);
1260 ret = dev->rdev.t3cdev_p->ctl(dev->rdev.t3cdev_p, RDMA_GET_MIB, &m);
1261 if (ret)
1262 return -ENOSYS;
1263
1264 memset(stats, 0, sizeof *stats);
1265 stats->iw.ipInReceives = ((u64) m.ipInReceive_hi << 32) +
1266 m.ipInReceive_lo;
1267 stats->iw.ipInHdrErrors = ((u64) m.ipInHdrErrors_hi << 32) +
1268 m.ipInHdrErrors_lo;
1269 stats->iw.ipInAddrErrors = ((u64) m.ipInAddrErrors_hi << 32) +
1270 m.ipInAddrErrors_lo;
1271 stats->iw.ipInUnknownProtos = ((u64) m.ipInUnknownProtos_hi << 32) +
1272 m.ipInUnknownProtos_lo;
1273 stats->iw.ipInDiscards = ((u64) m.ipInDiscards_hi << 32) +
1274 m.ipInDiscards_lo;
1275 stats->iw.ipInDelivers = ((u64) m.ipInDelivers_hi << 32) +
1276 m.ipInDelivers_lo;
1277 stats->iw.ipOutRequests = ((u64) m.ipOutRequests_hi << 32) +
1278 m.ipOutRequests_lo;
1279 stats->iw.ipOutDiscards = ((u64) m.ipOutDiscards_hi << 32) +
1280 m.ipOutDiscards_lo;
1281 stats->iw.ipOutNoRoutes = ((u64) m.ipOutNoRoutes_hi << 32) +
1282 m.ipOutNoRoutes_lo;
1283 stats->iw.ipReasmTimeout = (u64) m.ipReasmTimeout;
1284 stats->iw.ipReasmReqds = (u64) m.ipReasmReqds;
1285 stats->iw.ipReasmOKs = (u64) m.ipReasmOKs;
1286 stats->iw.ipReasmFails = (u64) m.ipReasmFails;
1287 stats->iw.tcpActiveOpens = (u64) m.tcpActiveOpens;
1288 stats->iw.tcpPassiveOpens = (u64) m.tcpPassiveOpens;
1289 stats->iw.tcpAttemptFails = (u64) m.tcpAttemptFails;
1290 stats->iw.tcpEstabResets = (u64) m.tcpEstabResets;
1291 stats->iw.tcpOutRsts = (u64) m.tcpOutRsts;
1292 stats->iw.tcpCurrEstab = (u64) m.tcpCurrEstab;
1293 stats->iw.tcpInSegs = ((u64) m.tcpInSegs_hi << 32) +
1294 m.tcpInSegs_lo;
1295 stats->iw.tcpOutSegs = ((u64) m.tcpOutSegs_hi << 32) +
1296 m.tcpOutSegs_lo;
1297 stats->iw.tcpRetransSegs = ((u64) m.tcpRetransSeg_hi << 32) +
1298 m.tcpRetransSeg_lo;
1299 stats->iw.tcpInErrs = ((u64) m.tcpInErrs_hi << 32) +
1300 m.tcpInErrs_lo;
1301 stats->iw.tcpRtoMin = (u64) m.tcpRtoMin;
1302 stats->iw.tcpRtoMax = (u64) m.tcpRtoMax;
1303 return 0;
1304}
1305
1126static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL); 1306static DEVICE_ATTR(hw_rev, S_IRUGO, show_rev, NULL);
1127static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL); 1307static DEVICE_ATTR(fw_ver, S_IRUGO, show_fw_ver, NULL);
1128static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL); 1308static DEVICE_ATTR(hca_type, S_IRUGO, show_hca, NULL);
@@ -1132,7 +1312,7 @@ static struct device_attribute *iwch_class_attributes[] = {
1132 &dev_attr_hw_rev, 1312 &dev_attr_hw_rev,
1133 &dev_attr_fw_ver, 1313 &dev_attr_fw_ver,
1134 &dev_attr_hca_type, 1314 &dev_attr_hca_type,
1135 &dev_attr_board_id 1315 &dev_attr_board_id,
1136}; 1316};
1137 1317
1138int iwch_register_device(struct iwch_dev *dev) 1318int iwch_register_device(struct iwch_dev *dev)
@@ -1145,8 +1325,12 @@ int iwch_register_device(struct iwch_dev *dev)
1145 memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid)); 1325 memset(&dev->ibdev.node_guid, 0, sizeof(dev->ibdev.node_guid));
1146 memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6); 1326 memcpy(&dev->ibdev.node_guid, dev->rdev.t3cdev_p->lldev->dev_addr, 6);
1147 dev->ibdev.owner = THIS_MODULE; 1327 dev->ibdev.owner = THIS_MODULE;
1148 dev->device_cap_flags = 1328 dev->device_cap_flags = IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW;
1149 (IB_DEVICE_ZERO_STAG | IB_DEVICE_MEM_WINDOW); 1329
1330 /* cxgb3 supports STag 0. */
1331 dev->ibdev.local_dma_lkey = 0;
1332 if (fw_supports_fastreg(dev))
1333 dev->device_cap_flags |= IB_DEVICE_MEM_MGT_EXTENSIONS;
1150 1334
1151 dev->ibdev.uverbs_cmd_mask = 1335 dev->ibdev.uverbs_cmd_mask =
1152 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) | 1336 (1ull << IB_USER_VERBS_CMD_GET_CONTEXT) |
@@ -1198,15 +1382,16 @@ int iwch_register_device(struct iwch_dev *dev)
1198 dev->ibdev.alloc_mw = iwch_alloc_mw; 1382 dev->ibdev.alloc_mw = iwch_alloc_mw;
1199 dev->ibdev.bind_mw = iwch_bind_mw; 1383 dev->ibdev.bind_mw = iwch_bind_mw;
1200 dev->ibdev.dealloc_mw = iwch_dealloc_mw; 1384 dev->ibdev.dealloc_mw = iwch_dealloc_mw;
1201 1385 dev->ibdev.alloc_fast_reg_mr = iwch_alloc_fast_reg_mr;
1386 dev->ibdev.alloc_fast_reg_page_list = iwch_alloc_fastreg_pbl;
1387 dev->ibdev.free_fast_reg_page_list = iwch_free_fastreg_pbl;
1202 dev->ibdev.attach_mcast = iwch_multicast_attach; 1388 dev->ibdev.attach_mcast = iwch_multicast_attach;
1203 dev->ibdev.detach_mcast = iwch_multicast_detach; 1389 dev->ibdev.detach_mcast = iwch_multicast_detach;
1204 dev->ibdev.process_mad = iwch_process_mad; 1390 dev->ibdev.process_mad = iwch_process_mad;
1205
1206 dev->ibdev.req_notify_cq = iwch_arm_cq; 1391 dev->ibdev.req_notify_cq = iwch_arm_cq;
1207 dev->ibdev.post_send = iwch_post_send; 1392 dev->ibdev.post_send = iwch_post_send;
1208 dev->ibdev.post_recv = iwch_post_receive; 1393 dev->ibdev.post_recv = iwch_post_receive;
1209 1394 dev->ibdev.get_protocol_stats = iwch_get_mib;
1210 1395
1211 dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL); 1396 dev->ibdev.iwcm = kmalloc(sizeof(struct iw_cm_verbs), GFP_KERNEL);
1212 if (!dev->ibdev.iwcm) 1397 if (!dev->ibdev.iwcm)
diff --git a/drivers/infiniband/hw/cxgb3/iwch_provider.h b/drivers/infiniband/hw/cxgb3/iwch_provider.h
index 836163fc5429..f5ceca05c435 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_provider.h
+++ b/drivers/infiniband/hw/cxgb3/iwch_provider.h
@@ -296,14 +296,6 @@ static inline u32 iwch_ib_to_tpt_access(int acc)
296 TPT_LOCAL_READ; 296 TPT_LOCAL_READ;
297} 297}
298 298
299static inline u32 iwch_ib_to_mwbind_access(int acc)
300{
301 return (acc & IB_ACCESS_REMOTE_WRITE ? T3_MEM_ACCESS_REM_WRITE : 0) |
302 (acc & IB_ACCESS_REMOTE_READ ? T3_MEM_ACCESS_REM_READ : 0) |
303 (acc & IB_ACCESS_LOCAL_WRITE ? T3_MEM_ACCESS_LOCAL_WRITE : 0) |
304 T3_MEM_ACCESS_LOCAL_READ;
305}
306
307enum iwch_mmid_state { 299enum iwch_mmid_state {
308 IWCH_STAG_STATE_VALID, 300 IWCH_STAG_STATE_VALID,
309 IWCH_STAG_STATE_INVALID 301 IWCH_STAG_STATE_INVALID
diff --git a/drivers/infiniband/hw/cxgb3/iwch_qp.c b/drivers/infiniband/hw/cxgb3/iwch_qp.c
index 992613799228..9a3be3a9d5dc 100644
--- a/drivers/infiniband/hw/cxgb3/iwch_qp.c
+++ b/drivers/infiniband/hw/cxgb3/iwch_qp.c
@@ -33,10 +33,11 @@
33#include "iwch.h" 33#include "iwch.h"
34#include "iwch_cm.h" 34#include "iwch_cm.h"
35#include "cxio_hal.h" 35#include "cxio_hal.h"
36#include "cxio_resource.h"
36 37
37#define NO_SUPPORT -1 38#define NO_SUPPORT -1
38 39
39static int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr, 40static int build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr,
40 u8 * flit_cnt) 41 u8 * flit_cnt)
41{ 42{
42 int i; 43 int i;
@@ -44,59 +45,44 @@ static int iwch_build_rdma_send(union t3_wr *wqe, struct ib_send_wr *wr,
44 45
45 switch (wr->opcode) { 46 switch (wr->opcode) {
46 case IB_WR_SEND: 47 case IB_WR_SEND:
47 case IB_WR_SEND_WITH_IMM:
48 if (wr->send_flags & IB_SEND_SOLICITED) 48 if (wr->send_flags & IB_SEND_SOLICITED)
49 wqe->send.rdmaop = T3_SEND_WITH_SE; 49 wqe->send.rdmaop = T3_SEND_WITH_SE;
50 else 50 else
51 wqe->send.rdmaop = T3_SEND; 51 wqe->send.rdmaop = T3_SEND;
52 wqe->send.rem_stag = 0; 52 wqe->send.rem_stag = 0;
53 break; 53 break;
54#if 0 /* Not currently supported */ 54 case IB_WR_SEND_WITH_INV:
55 case TYPE_SEND_INVALIDATE: 55 if (wr->send_flags & IB_SEND_SOLICITED)
56 case TYPE_SEND_INVALIDATE_IMMEDIATE: 56 wqe->send.rdmaop = T3_SEND_WITH_SE_INV;
57 wqe->send.rdmaop = T3_SEND_WITH_INV; 57 else
58 wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); 58 wqe->send.rdmaop = T3_SEND_WITH_INV;
59 break; 59 wqe->send.rem_stag = cpu_to_be32(wr->ex.invalidate_rkey);
60 case TYPE_SEND_SE_INVALIDATE:
61 wqe->send.rdmaop = T3_SEND_WITH_SE_INV;
62 wqe->send.rem_stag = cpu_to_be32(wr->wr.rdma.rkey);
63 break; 60 break;
64#endif
65 default: 61 default:
66 break; 62 return -EINVAL;
67 } 63 }
68 if (wr->num_sge > T3_MAX_SGE) 64 if (wr->num_sge > T3_MAX_SGE)
69 return -EINVAL; 65 return -EINVAL;
70 wqe->send.reserved[0] = 0; 66 wqe->send.reserved[0] = 0;
71 wqe->send.reserved[1] = 0; 67 wqe->send.reserved[1] = 0;
72 wqe->send.reserved[2] = 0; 68 wqe->send.reserved[2] = 0;
73 if (wr->opcode == IB_WR_SEND_WITH_IMM) { 69 plen = 0;
74 plen = 4; 70 for (i = 0; i < wr->num_sge; i++) {
75 wqe->send.sgl[0].stag = wr->ex.imm_data; 71 if ((plen + wr->sg_list[i].length) < plen)
76 wqe->send.sgl[0].len = __constant_cpu_to_be32(0); 72 return -EMSGSIZE;
77 wqe->send.num_sgle = __constant_cpu_to_be32(0); 73
78 *flit_cnt = 5; 74 plen += wr->sg_list[i].length;
79 } else { 75 wqe->send.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey);
80 plen = 0; 76 wqe->send.sgl[i].len = cpu_to_be32(wr->sg_list[i].length);
81 for (i = 0; i < wr->num_sge; i++) { 77 wqe->send.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr);
82 if ((plen + wr->sg_list[i].length) < plen) {
83 return -EMSGSIZE;
84 }
85 plen += wr->sg_list[i].length;
86 wqe->send.sgl[i].stag =
87 cpu_to_be32(wr->sg_list[i].lkey);
88 wqe->send.sgl[i].len =
89 cpu_to_be32(wr->sg_list[i].length);
90 wqe->send.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr);
91 }
92 wqe->send.num_sgle = cpu_to_be32(wr->num_sge);
93 *flit_cnt = 4 + ((wr->num_sge) << 1);
94 } 78 }
79 wqe->send.num_sgle = cpu_to_be32(wr->num_sge);
80 *flit_cnt = 4 + ((wr->num_sge) << 1);
95 wqe->send.plen = cpu_to_be32(plen); 81 wqe->send.plen = cpu_to_be32(plen);
96 return 0; 82 return 0;
97} 83}
98 84
99static int iwch_build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr, 85static int build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr,
100 u8 *flit_cnt) 86 u8 *flit_cnt)
101{ 87{
102 int i; 88 int i;
@@ -137,15 +123,18 @@ static int iwch_build_rdma_write(union t3_wr *wqe, struct ib_send_wr *wr,
137 return 0; 123 return 0;
138} 124}
139 125
140static int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr, 126static int build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr,
141 u8 *flit_cnt) 127 u8 *flit_cnt)
142{ 128{
143 if (wr->num_sge > 1) 129 if (wr->num_sge > 1)
144 return -EINVAL; 130 return -EINVAL;
145 wqe->read.rdmaop = T3_READ_REQ; 131 wqe->read.rdmaop = T3_READ_REQ;
132 if (wr->opcode == IB_WR_RDMA_READ_WITH_INV)
133 wqe->read.local_inv = 1;
134 else
135 wqe->read.local_inv = 0;
146 wqe->read.reserved[0] = 0; 136 wqe->read.reserved[0] = 0;
147 wqe->read.reserved[1] = 0; 137 wqe->read.reserved[1] = 0;
148 wqe->read.reserved[2] = 0;
149 wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey); 138 wqe->read.rem_stag = cpu_to_be32(wr->wr.rdma.rkey);
150 wqe->read.rem_to = cpu_to_be64(wr->wr.rdma.remote_addr); 139 wqe->read.rem_to = cpu_to_be64(wr->wr.rdma.remote_addr);
151 wqe->read.local_stag = cpu_to_be32(wr->sg_list[0].lkey); 140 wqe->read.local_stag = cpu_to_be32(wr->sg_list[0].lkey);
@@ -155,6 +144,57 @@ static int iwch_build_rdma_read(union t3_wr *wqe, struct ib_send_wr *wr,
155 return 0; 144 return 0;
156} 145}
157 146
147static int build_fastreg(union t3_wr *wqe, struct ib_send_wr *wr,
148 u8 *flit_cnt, int *wr_cnt, struct t3_wq *wq)
149{
150 int i;
151 __be64 *p;
152
153 if (wr->wr.fast_reg.page_list_len > T3_MAX_FASTREG_DEPTH)
154 return -EINVAL;
155 *wr_cnt = 1;
156 wqe->fastreg.stag = cpu_to_be32(wr->wr.fast_reg.rkey);
157 wqe->fastreg.len = cpu_to_be32(wr->wr.fast_reg.length);
158 wqe->fastreg.va_base_hi = cpu_to_be32(wr->wr.fast_reg.iova_start >> 32);
159 wqe->fastreg.va_base_lo_fbo =
160 cpu_to_be32(wr->wr.fast_reg.iova_start & 0xffffffff);
161 wqe->fastreg.page_type_perms = cpu_to_be32(
162 V_FR_PAGE_COUNT(wr->wr.fast_reg.page_list_len) |
163 V_FR_PAGE_SIZE(wr->wr.fast_reg.page_shift-12) |
164 V_FR_TYPE(TPT_VATO) |
165 V_FR_PERMS(iwch_ib_to_tpt_access(wr->wr.fast_reg.access_flags)));
166 p = &wqe->fastreg.pbl_addrs[0];
167 for (i = 0; i < wr->wr.fast_reg.page_list_len; i++, p++) {
168
169 /* If we need a 2nd WR, then set it up */
170 if (i == T3_MAX_FASTREG_FRAG) {
171 *wr_cnt = 2;
172 wqe = (union t3_wr *)(wq->queue +
173 Q_PTR2IDX((wq->wptr+1), wq->size_log2));
174 build_fw_riwrh((void *)wqe, T3_WR_FASTREG, 0,
175 Q_GENBIT(wq->wptr + 1, wq->size_log2),
176 0, 1 + wr->wr.fast_reg.page_list_len - T3_MAX_FASTREG_FRAG,
177 T3_EOP);
178
179 p = &wqe->pbl_frag.pbl_addrs[0];
180 }
181 *p = cpu_to_be64((u64)wr->wr.fast_reg.page_list->page_list[i]);
182 }
183 *flit_cnt = 5 + wr->wr.fast_reg.page_list_len;
184 if (*flit_cnt > 15)
185 *flit_cnt = 15;
186 return 0;
187}
188
189static int build_inv_stag(union t3_wr *wqe, struct ib_send_wr *wr,
190 u8 *flit_cnt)
191{
192 wqe->local_inv.stag = cpu_to_be32(wr->ex.invalidate_rkey);
193 wqe->local_inv.reserved = 0;
194 *flit_cnt = sizeof(struct t3_local_inv_wr) >> 3;
195 return 0;
196}
197
158/* 198/*
159 * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now. 199 * TBD: this is going to be moved to firmware. Missing pdid/qpid check for now.
160 */ 200 */
@@ -205,23 +245,106 @@ static int iwch_sgl2pbl_map(struct iwch_dev *rhp, struct ib_sge *sg_list,
205 return 0; 245 return 0;
206} 246}
207 247
208static int iwch_build_rdma_recv(struct iwch_dev *rhp, union t3_wr *wqe, 248static int build_rdma_recv(struct iwch_qp *qhp, union t3_wr *wqe,
209 struct ib_recv_wr *wr) 249 struct ib_recv_wr *wr)
210{ 250{
211 int i; 251 int i, err = 0;
212 if (wr->num_sge > T3_MAX_SGE) 252 u32 pbl_addr[T3_MAX_SGE];
213 return -EINVAL; 253 u8 page_size[T3_MAX_SGE];
254
255 err = iwch_sgl2pbl_map(qhp->rhp, wr->sg_list, wr->num_sge, pbl_addr,
256 page_size);
257 if (err)
258 return err;
259 wqe->recv.pagesz[0] = page_size[0];
260 wqe->recv.pagesz[1] = page_size[1];
261 wqe->recv.pagesz[2] = page_size[2];
262 wqe->recv.pagesz[3] = page_size[3];
214 wqe->recv.num_sgle = cpu_to_be32(wr->num_sge); 263 wqe->recv.num_sgle = cpu_to_be32(wr->num_sge);
215 for (i = 0; i < wr->num_sge; i++) { 264 for (i = 0; i < wr->num_sge; i++) {
216 wqe->recv.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey); 265 wqe->recv.sgl[i].stag = cpu_to_be32(wr->sg_list[i].lkey);
217 wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length); 266 wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length);
267
268 /* to in the WQE == the offset into the page */
269 wqe->recv.sgl[i].to = cpu_to_be64(((u32) wr->sg_list[i].addr) %
270 (1UL << (12 + page_size[i])));
271
272 /* pbl_addr is the adapters address in the PBL */
273 wqe->recv.pbl_addr[i] = cpu_to_be32(pbl_addr[i]);
274 }
275 for (; i < T3_MAX_SGE; i++) {
276 wqe->recv.sgl[i].stag = 0;
277 wqe->recv.sgl[i].len = 0;
278 wqe->recv.sgl[i].to = 0;
279 wqe->recv.pbl_addr[i] = 0;
280 }
281 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
282 qhp->wq.rq_size_log2)].wr_id = wr->wr_id;
283 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
284 qhp->wq.rq_size_log2)].pbl_addr = 0;
285 return 0;
286}
287
288static int build_zero_stag_recv(struct iwch_qp *qhp, union t3_wr *wqe,
289 struct ib_recv_wr *wr)
290{
291 int i;
292 u32 pbl_addr;
293 u32 pbl_offset;
294
295
296 /*
297 * The T3 HW requires the PBL in the HW recv descriptor to reference
298 * a PBL entry. So we allocate the max needed PBL memory here and pass
299 * it to the uP in the recv WR. The uP will build the PBL and setup
300 * the HW recv descriptor.
301 */
302 pbl_addr = cxio_hal_pblpool_alloc(&qhp->rhp->rdev, T3_STAG0_PBL_SIZE);
303 if (!pbl_addr)
304 return -ENOMEM;
305
306 /*
307 * Compute the 8B aligned offset.
308 */
309 pbl_offset = (pbl_addr - qhp->rhp->rdev.rnic_info.pbl_base) >> 3;
310
311 wqe->recv.num_sgle = cpu_to_be32(wr->num_sge);
312
313 for (i = 0; i < wr->num_sge; i++) {
314
315 /*
316 * Use a 128MB page size. This and an imposed 128MB
317 * sge length limit allows us to require only a 2-entry HW
318 * PBL for each SGE. This restriction is acceptable since
319 * since it is not possible to allocate 128MB of contiguous
320 * DMA coherent memory!
321 */
322 if (wr->sg_list[i].length > T3_STAG0_MAX_PBE_LEN)
323 return -EINVAL;
324 wqe->recv.pagesz[i] = T3_STAG0_PAGE_SHIFT;
325
326 /*
327 * T3 restricts a recv to all zero-stag or all non-zero-stag.
328 */
329 if (wr->sg_list[i].lkey != 0)
330 return -EINVAL;
331 wqe->recv.sgl[i].stag = 0;
332 wqe->recv.sgl[i].len = cpu_to_be32(wr->sg_list[i].length);
218 wqe->recv.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr); 333 wqe->recv.sgl[i].to = cpu_to_be64(wr->sg_list[i].addr);
334 wqe->recv.pbl_addr[i] = cpu_to_be32(pbl_offset);
335 pbl_offset += 2;
219 } 336 }
220 for (; i < T3_MAX_SGE; i++) { 337 for (; i < T3_MAX_SGE; i++) {
338 wqe->recv.pagesz[i] = 0;
221 wqe->recv.sgl[i].stag = 0; 339 wqe->recv.sgl[i].stag = 0;
222 wqe->recv.sgl[i].len = 0; 340 wqe->recv.sgl[i].len = 0;
223 wqe->recv.sgl[i].to = 0; 341 wqe->recv.sgl[i].to = 0;
342 wqe->recv.pbl_addr[i] = 0;
224 } 343 }
344 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
345 qhp->wq.rq_size_log2)].wr_id = wr->wr_id;
346 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr,
347 qhp->wq.rq_size_log2)].pbl_addr = pbl_addr;
225 return 0; 348 return 0;
226} 349}
227 350
@@ -238,6 +361,7 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
238 u32 num_wrs; 361 u32 num_wrs;
239 unsigned long flag; 362 unsigned long flag;
240 struct t3_swsq *sqp; 363 struct t3_swsq *sqp;
364 int wr_cnt = 1;
241 365
242 qhp = to_iwch_qp(ibqp); 366 qhp = to_iwch_qp(ibqp);
243 spin_lock_irqsave(&qhp->lock, flag); 367 spin_lock_irqsave(&qhp->lock, flag);
@@ -262,33 +386,45 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
262 t3_wr_flags = 0; 386 t3_wr_flags = 0;
263 if (wr->send_flags & IB_SEND_SOLICITED) 387 if (wr->send_flags & IB_SEND_SOLICITED)
264 t3_wr_flags |= T3_SOLICITED_EVENT_FLAG; 388 t3_wr_flags |= T3_SOLICITED_EVENT_FLAG;
265 if (wr->send_flags & IB_SEND_FENCE)
266 t3_wr_flags |= T3_READ_FENCE_FLAG;
267 if (wr->send_flags & IB_SEND_SIGNALED) 389 if (wr->send_flags & IB_SEND_SIGNALED)
268 t3_wr_flags |= T3_COMPLETION_FLAG; 390 t3_wr_flags |= T3_COMPLETION_FLAG;
269 sqp = qhp->wq.sq + 391 sqp = qhp->wq.sq +
270 Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); 392 Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2);
271 switch (wr->opcode) { 393 switch (wr->opcode) {
272 case IB_WR_SEND: 394 case IB_WR_SEND:
273 case IB_WR_SEND_WITH_IMM: 395 case IB_WR_SEND_WITH_INV:
396 if (wr->send_flags & IB_SEND_FENCE)
397 t3_wr_flags |= T3_READ_FENCE_FLAG;
274 t3_wr_opcode = T3_WR_SEND; 398 t3_wr_opcode = T3_WR_SEND;
275 err = iwch_build_rdma_send(wqe, wr, &t3_wr_flit_cnt); 399 err = build_rdma_send(wqe, wr, &t3_wr_flit_cnt);
276 break; 400 break;
277 case IB_WR_RDMA_WRITE: 401 case IB_WR_RDMA_WRITE:
278 case IB_WR_RDMA_WRITE_WITH_IMM: 402 case IB_WR_RDMA_WRITE_WITH_IMM:
279 t3_wr_opcode = T3_WR_WRITE; 403 t3_wr_opcode = T3_WR_WRITE;
280 err = iwch_build_rdma_write(wqe, wr, &t3_wr_flit_cnt); 404 err = build_rdma_write(wqe, wr, &t3_wr_flit_cnt);
281 break; 405 break;
282 case IB_WR_RDMA_READ: 406 case IB_WR_RDMA_READ:
407 case IB_WR_RDMA_READ_WITH_INV:
283 t3_wr_opcode = T3_WR_READ; 408 t3_wr_opcode = T3_WR_READ;
284 t3_wr_flags = 0; /* T3 reads are always signaled */ 409 t3_wr_flags = 0; /* T3 reads are always signaled */
285 err = iwch_build_rdma_read(wqe, wr, &t3_wr_flit_cnt); 410 err = build_rdma_read(wqe, wr, &t3_wr_flit_cnt);
286 if (err) 411 if (err)
287 break; 412 break;
288 sqp->read_len = wqe->read.local_len; 413 sqp->read_len = wqe->read.local_len;
289 if (!qhp->wq.oldest_read) 414 if (!qhp->wq.oldest_read)
290 qhp->wq.oldest_read = sqp; 415 qhp->wq.oldest_read = sqp;
291 break; 416 break;
417 case IB_WR_FAST_REG_MR:
418 t3_wr_opcode = T3_WR_FASTREG;
419 err = build_fastreg(wqe, wr, &t3_wr_flit_cnt,
420 &wr_cnt, &qhp->wq);
421 break;
422 case IB_WR_LOCAL_INV:
423 if (wr->send_flags & IB_SEND_FENCE)
424 t3_wr_flags |= T3_LOCAL_FENCE_FLAG;
425 t3_wr_opcode = T3_WR_INV_STAG;
426 err = build_inv_stag(wqe, wr, &t3_wr_flit_cnt);
427 break;
292 default: 428 default:
293 PDBG("%s post of type=%d TBD!\n", __func__, 429 PDBG("%s post of type=%d TBD!\n", __func__,
294 wr->opcode); 430 wr->opcode);
@@ -307,14 +443,15 @@ int iwch_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr,
307 443
308 build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags, 444 build_fw_riwrh((void *) wqe, t3_wr_opcode, t3_wr_flags,
309 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 445 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2),
310 0, t3_wr_flit_cnt); 446 0, t3_wr_flit_cnt,
447 (wr_cnt == 1) ? T3_SOPEOP : T3_SOP);
311 PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n", 448 PDBG("%s cookie 0x%llx wq idx 0x%x swsq idx %ld opcode %d\n",
312 __func__, (unsigned long long) wr->wr_id, idx, 449 __func__, (unsigned long long) wr->wr_id, idx,
313 Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2), 450 Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2),
314 sqp->opcode); 451 sqp->opcode);
315 wr = wr->next; 452 wr = wr->next;
316 num_wrs--; 453 num_wrs--;
317 ++(qhp->wq.wptr); 454 qhp->wq.wptr += wr_cnt;
318 ++(qhp->wq.sq_wptr); 455 ++(qhp->wq.sq_wptr);
319 } 456 }
320 spin_unlock_irqrestore(&qhp->lock, flag); 457 spin_unlock_irqrestore(&qhp->lock, flag);
@@ -345,21 +482,27 @@ int iwch_post_receive(struct ib_qp *ibqp, struct ib_recv_wr *wr,
345 return -EINVAL; 482 return -EINVAL;
346 } 483 }
347 while (wr) { 484 while (wr) {
485 if (wr->num_sge > T3_MAX_SGE) {
486 err = -EINVAL;
487 *bad_wr = wr;
488 break;
489 }
348 idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2); 490 idx = Q_PTR2IDX(qhp->wq.wptr, qhp->wq.size_log2);
349 wqe = (union t3_wr *) (qhp->wq.queue + idx); 491 wqe = (union t3_wr *) (qhp->wq.queue + idx);
350 if (num_wrs) 492 if (num_wrs)
351 err = iwch_build_rdma_recv(qhp->rhp, wqe, wr); 493 if (wr->sg_list[0].lkey)
494 err = build_rdma_recv(qhp, wqe, wr);
495 else
496 err = build_zero_stag_recv(qhp, wqe, wr);
352 else 497 else
353 err = -ENOMEM; 498 err = -ENOMEM;
354 if (err) { 499 if (err) {
355 *bad_wr = wr; 500 *bad_wr = wr;
356 break; 501 break;
357 } 502 }
358 qhp->wq.rq[Q_PTR2IDX(qhp->wq.rq_wptr, qhp->wq.rq_size_log2)] =
359 wr->wr_id;
360 build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG, 503 build_fw_riwrh((void *) wqe, T3_WR_RCV, T3_COMPLETION_FLAG,
361 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 504 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2),
362 0, sizeof(struct t3_receive_wr) >> 3); 505 0, sizeof(struct t3_receive_wr) >> 3, T3_SOPEOP);
363 PDBG("%s cookie 0x%llx idx 0x%x rq_wptr 0x%x rw_rptr 0x%x " 506 PDBG("%s cookie 0x%llx idx 0x%x rq_wptr 0x%x rw_rptr 0x%x "
364 "wqe %p \n", __func__, (unsigned long long) wr->wr_id, 507 "wqe %p \n", __func__, (unsigned long long) wr->wr_id,
365 idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe); 508 idx, qhp->wq.rq_wptr, qhp->wq.rq_rptr, wqe);
@@ -419,10 +562,10 @@ int iwch_bind_mw(struct ib_qp *qp,
419 sgl.lkey = mw_bind->mr->lkey; 562 sgl.lkey = mw_bind->mr->lkey;
420 sgl.length = mw_bind->length; 563 sgl.length = mw_bind->length;
421 wqe->bind.reserved = 0; 564 wqe->bind.reserved = 0;
422 wqe->bind.type = T3_VA_BASED_TO; 565 wqe->bind.type = TPT_VATO;
423 566
424 /* TBD: check perms */ 567 /* TBD: check perms */
425 wqe->bind.perms = iwch_ib_to_mwbind_access(mw_bind->mw_access_flags); 568 wqe->bind.perms = iwch_ib_to_tpt_access(mw_bind->mw_access_flags);
426 wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey); 569 wqe->bind.mr_stag = cpu_to_be32(mw_bind->mr->lkey);
427 wqe->bind.mw_stag = cpu_to_be32(mw->rkey); 570 wqe->bind.mw_stag = cpu_to_be32(mw->rkey);
428 wqe->bind.mw_len = cpu_to_be32(mw_bind->length); 571 wqe->bind.mw_len = cpu_to_be32(mw_bind->length);
@@ -430,7 +573,7 @@ int iwch_bind_mw(struct ib_qp *qp,
430 err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size); 573 err = iwch_sgl2pbl_map(rhp, &sgl, 1, &pbl_addr, &page_size);
431 if (err) { 574 if (err) {
432 spin_unlock_irqrestore(&qhp->lock, flag); 575 spin_unlock_irqrestore(&qhp->lock, flag);
433 return err; 576 return err;
434 } 577 }
435 wqe->send.wrid.id0.hi = qhp->wq.sq_wptr; 578 wqe->send.wrid.id0.hi = qhp->wq.sq_wptr;
436 sqp = qhp->wq.sq + Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2); 579 sqp = qhp->wq.sq + Q_PTR2IDX(qhp->wq.sq_wptr, qhp->wq.sq_size_log2);
@@ -441,10 +584,9 @@ int iwch_bind_mw(struct ib_qp *qp,
441 sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED); 584 sqp->signaled = (mw_bind->send_flags & IB_SEND_SIGNALED);
442 wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr); 585 wqe->bind.mr_pbl_addr = cpu_to_be32(pbl_addr);
443 wqe->bind.mr_pagesz = page_size; 586 wqe->bind.mr_pagesz = page_size;
444 wqe->flit[T3_SQ_COOKIE_FLIT] = mw_bind->wr_id;
445 build_fw_riwrh((void *)wqe, T3_WR_BIND, t3_wr_flags, 587 build_fw_riwrh((void *)wqe, T3_WR_BIND, t3_wr_flags,
446 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0, 588 Q_GENBIT(qhp->wq.wptr, qhp->wq.size_log2), 0,
447 sizeof(struct t3_bind_mw_wr) >> 3); 589 sizeof(struct t3_bind_mw_wr) >> 3, T3_SOPEOP);
448 ++(qhp->wq.wptr); 590 ++(qhp->wq.wptr);
449 ++(qhp->wq.sq_wptr); 591 ++(qhp->wq.sq_wptr);
450 spin_unlock_irqrestore(&qhp->lock, flag); 592 spin_unlock_irqrestore(&qhp->lock, flag);
@@ -758,7 +900,8 @@ static int rdma_init(struct iwch_dev *rhp, struct iwch_qp *qhp,
758 init_attr.qp_dma_size = (1UL << qhp->wq.size_log2); 900 init_attr.qp_dma_size = (1UL << qhp->wq.size_log2);
759 init_attr.rqe_count = iwch_rqes_posted(qhp); 901 init_attr.rqe_count = iwch_rqes_posted(qhp);
760 init_attr.flags = qhp->attr.mpa_attr.initiator ? MPA_INITIATOR : 0; 902 init_attr.flags = qhp->attr.mpa_attr.initiator ? MPA_INITIATOR : 0;
761 init_attr.flags |= capable(CAP_NET_BIND_SERVICE) ? PRIV_QP : 0; 903 if (!qhp->ibqp.uobject)
904 init_attr.flags |= PRIV_QP;
762 if (peer2peer) { 905 if (peer2peer) {
763 init_attr.rtr_type = RTR_READ; 906 init_attr.rtr_type = RTR_READ;
764 if (init_attr.ord == 0 && qhp->attr.mpa_attr.initiator) 907 if (init_attr.ord == 0 && qhp->attr.mpa_attr.initiator)
diff --git a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
index ce1ab0571be3..0792d930c481 100644
--- a/drivers/infiniband/hw/ehca/ehca_irq.c
+++ b/drivers/infiniband/hw/ehca/ehca_irq.c
@@ -531,7 +531,7 @@ void ehca_process_eq(struct ehca_shca *shca, int is_irq)
531{ 531{
532 struct ehca_eq *eq = &shca->eq; 532 struct ehca_eq *eq = &shca->eq;
533 struct ehca_eqe_cache_entry *eqe_cache = eq->eqe_cache; 533 struct ehca_eqe_cache_entry *eqe_cache = eq->eqe_cache;
534 u64 eqe_value; 534 u64 eqe_value, ret;
535 unsigned long flags; 535 unsigned long flags;
536 int eqe_cnt, i; 536 int eqe_cnt, i;
537 int eq_empty = 0; 537 int eq_empty = 0;
@@ -583,8 +583,13 @@ void ehca_process_eq(struct ehca_shca *shca, int is_irq)
583 ehca_dbg(&shca->ib_device, 583 ehca_dbg(&shca->ib_device,
584 "No eqe found for irq event"); 584 "No eqe found for irq event");
585 goto unlock_irq_spinlock; 585 goto unlock_irq_spinlock;
586 } else if (!is_irq) 586 } else if (!is_irq) {
587 ret = hipz_h_eoi(eq->ist);
588 if (ret != H_SUCCESS)
589 ehca_err(&shca->ib_device,
590 "bad return code EOI -rc = %ld\n", ret);
587 ehca_dbg(&shca->ib_device, "deadman found %x eqe", eqe_cnt); 591 ehca_dbg(&shca->ib_device, "deadman found %x eqe", eqe_cnt);
592 }
588 if (unlikely(eqe_cnt == EHCA_EQE_CACHE_SIZE)) 593 if (unlikely(eqe_cnt == EHCA_EQE_CACHE_SIZE))
589 ehca_dbg(&shca->ib_device, "too many eqes for one irq event"); 594 ehca_dbg(&shca->ib_device, "too many eqes for one irq event");
590 /* enable irq for new packets */ 595 /* enable irq for new packets */
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 482103eb6eac..598844d2edc9 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -923,6 +923,7 @@ static struct of_device_id ehca_device_table[] =
923 }, 923 },
924 {}, 924 {},
925}; 925};
926MODULE_DEVICE_TABLE(of, ehca_device_table);
926 927
927static struct of_platform_driver ehca_driver = { 928static struct of_platform_driver ehca_driver = {
928 .name = "ehca", 929 .name = "ehca",
diff --git a/drivers/infiniband/hw/ehca/ehca_reqs.c b/drivers/infiniband/hw/ehca/ehca_reqs.c
index f093b0033daf..dd9bc68f1c7b 100644
--- a/drivers/infiniband/hw/ehca/ehca_reqs.c
+++ b/drivers/infiniband/hw/ehca/ehca_reqs.c
@@ -544,8 +544,16 @@ int ehca_post_recv(struct ib_qp *qp,
544 struct ib_recv_wr *recv_wr, 544 struct ib_recv_wr *recv_wr,
545 struct ib_recv_wr **bad_recv_wr) 545 struct ib_recv_wr **bad_recv_wr)
546{ 546{
547 return internal_post_recv(container_of(qp, struct ehca_qp, ib_qp), 547 struct ehca_qp *my_qp = container_of(qp, struct ehca_qp, ib_qp);
548 qp->device, recv_wr, bad_recv_wr); 548
549 /* Reject WR if QP is in RESET state */
550 if (unlikely(my_qp->state == IB_QPS_RESET)) {
551 ehca_err(qp->device, "Invalid QP state qp_state=%d qpn=%x",
552 my_qp->state, qp->qp_num);
553 return -EINVAL;
554 }
555
556 return internal_post_recv(my_qp, qp->device, recv_wr, bad_recv_wr);
549} 557}
550 558
551int ehca_post_srq_recv(struct ib_srq *srq, 559int ehca_post_srq_recv(struct ib_srq *srq,
@@ -681,7 +689,7 @@ poll_cq_one_read_cqe:
681 wc->dlid_path_bits = cqe->dlid; 689 wc->dlid_path_bits = cqe->dlid;
682 wc->src_qp = cqe->remote_qp_number; 690 wc->src_qp = cqe->remote_qp_number;
683 wc->wc_flags = cqe->w_completion_flags; 691 wc->wc_flags = cqe->w_completion_flags;
684 wc->imm_data = cpu_to_be32(cqe->immediate_data); 692 wc->ex.imm_data = cpu_to_be32(cqe->immediate_data);
685 wc->sl = cqe->service_level; 693 wc->sl = cqe->service_level;
686 694
687poll_cq_one_exit0: 695poll_cq_one_exit0:
diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c
index 5245e13c3a30..415d3a465de6 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.c
+++ b/drivers/infiniband/hw/ehca/hcp_if.c
@@ -933,3 +933,13 @@ u64 hipz_h_error_data(const struct ipz_adapter_handle adapter_handle,
933 r_cb, 933 r_cb,
934 0, 0, 0, 0); 934 0, 0, 0, 0);
935} 935}
936
937u64 hipz_h_eoi(int irq)
938{
939 unsigned long xirr;
940
941 iosync();
942 xirr = (0xffULL << 24) | irq;
943
944 return plpar_hcall_norets(H_EOI, xirr);
945}
diff --git a/drivers/infiniband/hw/ehca/hcp_if.h b/drivers/infiniband/hw/ehca/hcp_if.h
index 60ce02b70663..2c3c6e0ea5c2 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.h
+++ b/drivers/infiniband/hw/ehca/hcp_if.h
@@ -260,5 +260,6 @@ u64 hipz_h_error_data(const struct ipz_adapter_handle adapter_handle,
260 const u64 ressource_handle, 260 const u64 ressource_handle,
261 void *rblock, 261 void *rblock,
262 unsigned long *byte_count); 262 unsigned long *byte_count);
263u64 hipz_h_eoi(int irq);
263 264
264#endif /* __HCP_IF_H__ */ 265#endif /* __HCP_IF_H__ */
diff --git a/drivers/infiniband/hw/ipath/ipath_cq.c b/drivers/infiniband/hw/ipath/ipath_cq.c
index a03bd28d9b48..d385e4168c97 100644
--- a/drivers/infiniband/hw/ipath/ipath_cq.c
+++ b/drivers/infiniband/hw/ipath/ipath_cq.c
@@ -82,7 +82,7 @@ void ipath_cq_enter(struct ipath_cq *cq, struct ib_wc *entry, int solicited)
82 wc->uqueue[head].opcode = entry->opcode; 82 wc->uqueue[head].opcode = entry->opcode;
83 wc->uqueue[head].vendor_err = entry->vendor_err; 83 wc->uqueue[head].vendor_err = entry->vendor_err;
84 wc->uqueue[head].byte_len = entry->byte_len; 84 wc->uqueue[head].byte_len = entry->byte_len;
85 wc->uqueue[head].imm_data = (__u32 __force)entry->imm_data; 85 wc->uqueue[head].ex.imm_data = (__u32 __force) entry->ex.imm_data;
86 wc->uqueue[head].qp_num = entry->qp->qp_num; 86 wc->uqueue[head].qp_num = entry->qp->qp_num;
87 wc->uqueue[head].src_qp = entry->src_qp; 87 wc->uqueue[head].src_qp = entry->src_qp;
88 wc->uqueue[head].wc_flags = entry->wc_flags; 88 wc->uqueue[head].wc_flags = entry->wc_flags;
diff --git a/drivers/infiniband/hw/ipath/ipath_file_ops.c b/drivers/infiniband/hw/ipath/ipath_file_ops.c
index b472b15637f0..35f301c88b57 100644
--- a/drivers/infiniband/hw/ipath/ipath_file_ops.c
+++ b/drivers/infiniband/hw/ipath/ipath_file_ops.c
@@ -39,6 +39,7 @@
39#include <linux/highmem.h> 39#include <linux/highmem.h>
40#include <linux/io.h> 40#include <linux/io.h>
41#include <linux/jiffies.h> 41#include <linux/jiffies.h>
42#include <linux/smp_lock.h>
42#include <asm/pgtable.h> 43#include <asm/pgtable.h>
43 44
44#include "ipath_kernel.h" 45#include "ipath_kernel.h"
@@ -1815,6 +1816,7 @@ done:
1815static int ipath_open(struct inode *in, struct file *fp) 1816static int ipath_open(struct inode *in, struct file *fp)
1816{ 1817{
1817 /* The real work is performed later in ipath_assign_port() */ 1818 /* The real work is performed later in ipath_assign_port() */
1819 cycle_kernel_lock();
1818 fp->private_data = kzalloc(sizeof(struct ipath_filedata), GFP_KERNEL); 1820 fp->private_data = kzalloc(sizeof(struct ipath_filedata), GFP_KERNEL);
1819 return fp->private_data ? 0 : -ENOMEM; 1821 return fp->private_data ? 0 : -ENOMEM;
1820} 1822}
diff --git a/drivers/infiniband/hw/ipath/ipath_iba7220.c b/drivers/infiniband/hw/ipath/ipath_iba7220.c
index 8eee7830f042..fb70712ac85c 100644
--- a/drivers/infiniband/hw/ipath/ipath_iba7220.c
+++ b/drivers/infiniband/hw/ipath/ipath_iba7220.c
@@ -2228,8 +2228,8 @@ static void ipath_autoneg_send(struct ipath_devdata *dd, int which)
2228 0xffffffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 2228 0xffffffff, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
2229 0x40000001, 0x1388, 0x15e, /* rest 0's */ 2229 0x40000001, 0x1388, 0x15e, /* rest 0's */
2230 }; 2230 };
2231 dcnt = sizeof(madpayload_start)/sizeof(madpayload_start[0]); 2231 dcnt = ARRAY_SIZE(madpayload_start);
2232 hcnt = sizeof(hdr)/sizeof(hdr[0]); 2232 hcnt = ARRAY_SIZE(hdr);
2233 if (!swapped) { 2233 if (!swapped) {
2234 /* for maintainability, do it at runtime */ 2234 /* for maintainability, do it at runtime */
2235 for (i = 0; i < hcnt; i++) { 2235 for (i = 0; i < hcnt; i++) {
diff --git a/drivers/infiniband/hw/ipath/ipath_mad.c b/drivers/infiniband/hw/ipath/ipath_mad.c
index 5f9315d77a43..be4fc9ada8e7 100644
--- a/drivers/infiniband/hw/ipath/ipath_mad.c
+++ b/drivers/infiniband/hw/ipath/ipath_mad.c
@@ -111,9 +111,9 @@ static int recv_subn_get_nodeinfo(struct ib_smp *smp,
111 nip->revision = cpu_to_be32((majrev << 16) | minrev); 111 nip->revision = cpu_to_be32((majrev << 16) | minrev);
112 nip->local_port_num = port; 112 nip->local_port_num = port;
113 vendor = dd->ipath_vendorid; 113 vendor = dd->ipath_vendorid;
114 nip->vendor_id[0] = 0; 114 nip->vendor_id[0] = IPATH_SRC_OUI_1;
115 nip->vendor_id[1] = vendor >> 8; 115 nip->vendor_id[1] = IPATH_SRC_OUI_2;
116 nip->vendor_id[2] = vendor; 116 nip->vendor_id[2] = IPATH_SRC_OUI_3;
117 117
118 return reply(smp); 118 return reply(smp);
119} 119}
diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
index 108df667d2ee..97710522624d 100644
--- a/drivers/infiniband/hw/ipath/ipath_rc.c
+++ b/drivers/infiniband/hw/ipath/ipath_rc.c
@@ -1703,11 +1703,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
1703 case OP(SEND_LAST_WITH_IMMEDIATE): 1703 case OP(SEND_LAST_WITH_IMMEDIATE):
1704 send_last_imm: 1704 send_last_imm:
1705 if (header_in_data) { 1705 if (header_in_data) {
1706 wc.imm_data = *(__be32 *) data; 1706 wc.ex.imm_data = *(__be32 *) data;
1707 data += sizeof(__be32); 1707 data += sizeof(__be32);
1708 } else { 1708 } else {
1709 /* Immediate data comes after BTH */ 1709 /* Immediate data comes after BTH */
1710 wc.imm_data = ohdr->u.imm_data; 1710 wc.ex.imm_data = ohdr->u.imm_data;
1711 } 1711 }
1712 hdrsize += 4; 1712 hdrsize += 4;
1713 wc.wc_flags = IB_WC_WITH_IMM; 1713 wc.wc_flags = IB_WC_WITH_IMM;
diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
index a4b5521567fe..af051f757663 100644
--- a/drivers/infiniband/hw/ipath/ipath_ruc.c
+++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
@@ -331,7 +331,7 @@ again:
331 switch (wqe->wr.opcode) { 331 switch (wqe->wr.opcode) {
332 case IB_WR_SEND_WITH_IMM: 332 case IB_WR_SEND_WITH_IMM:
333 wc.wc_flags = IB_WC_WITH_IMM; 333 wc.wc_flags = IB_WC_WITH_IMM;
334 wc.imm_data = wqe->wr.ex.imm_data; 334 wc.ex.imm_data = wqe->wr.ex.imm_data;
335 /* FALLTHROUGH */ 335 /* FALLTHROUGH */
336 case IB_WR_SEND: 336 case IB_WR_SEND:
337 if (!ipath_get_rwqe(qp, 0)) 337 if (!ipath_get_rwqe(qp, 0))
@@ -342,7 +342,7 @@ again:
342 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE))) 342 if (unlikely(!(qp->qp_access_flags & IB_ACCESS_REMOTE_WRITE)))
343 goto inv_err; 343 goto inv_err;
344 wc.wc_flags = IB_WC_WITH_IMM; 344 wc.wc_flags = IB_WC_WITH_IMM;
345 wc.imm_data = wqe->wr.ex.imm_data; 345 wc.ex.imm_data = wqe->wr.ex.imm_data;
346 if (!ipath_get_rwqe(qp, 1)) 346 if (!ipath_get_rwqe(qp, 1))
347 goto rnr_nak; 347 goto rnr_nak;
348 /* FALLTHROUGH */ 348 /* FALLTHROUGH */
diff --git a/drivers/infiniband/hw/ipath/ipath_uc.c b/drivers/infiniband/hw/ipath/ipath_uc.c
index 0596ec16fcbd..82cc588b8bf2 100644
--- a/drivers/infiniband/hw/ipath/ipath_uc.c
+++ b/drivers/infiniband/hw/ipath/ipath_uc.c
@@ -379,11 +379,11 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
379 case OP(SEND_LAST_WITH_IMMEDIATE): 379 case OP(SEND_LAST_WITH_IMMEDIATE):
380 send_last_imm: 380 send_last_imm:
381 if (header_in_data) { 381 if (header_in_data) {
382 wc.imm_data = *(__be32 *) data; 382 wc.ex.imm_data = *(__be32 *) data;
383 data += sizeof(__be32); 383 data += sizeof(__be32);
384 } else { 384 } else {
385 /* Immediate data comes after BTH */ 385 /* Immediate data comes after BTH */
386 wc.imm_data = ohdr->u.imm_data; 386 wc.ex.imm_data = ohdr->u.imm_data;
387 } 387 }
388 hdrsize += 4; 388 hdrsize += 4;
389 wc.wc_flags = IB_WC_WITH_IMM; 389 wc.wc_flags = IB_WC_WITH_IMM;
@@ -483,11 +483,11 @@ void ipath_uc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
483 case OP(RDMA_WRITE_LAST_WITH_IMMEDIATE): 483 case OP(RDMA_WRITE_LAST_WITH_IMMEDIATE):
484 rdma_last_imm: 484 rdma_last_imm:
485 if (header_in_data) { 485 if (header_in_data) {
486 wc.imm_data = *(__be32 *) data; 486 wc.ex.imm_data = *(__be32 *) data;
487 data += sizeof(__be32); 487 data += sizeof(__be32);
488 } else { 488 } else {
489 /* Immediate data comes after BTH */ 489 /* Immediate data comes after BTH */
490 wc.imm_data = ohdr->u.imm_data; 490 wc.ex.imm_data = ohdr->u.imm_data;
491 } 491 }
492 hdrsize += 4; 492 hdrsize += 4;
493 wc.wc_flags = IB_WC_WITH_IMM; 493 wc.wc_flags = IB_WC_WITH_IMM;
diff --git a/drivers/infiniband/hw/ipath/ipath_ud.c b/drivers/infiniband/hw/ipath/ipath_ud.c
index 77ca8ca74e78..36aa242c487c 100644
--- a/drivers/infiniband/hw/ipath/ipath_ud.c
+++ b/drivers/infiniband/hw/ipath/ipath_ud.c
@@ -96,7 +96,7 @@ static void ipath_ud_loopback(struct ipath_qp *sqp, struct ipath_swqe *swqe)
96 96
97 if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) { 97 if (swqe->wr.opcode == IB_WR_SEND_WITH_IMM) {
98 wc.wc_flags = IB_WC_WITH_IMM; 98 wc.wc_flags = IB_WC_WITH_IMM;
99 wc.imm_data = swqe->wr.ex.imm_data; 99 wc.ex.imm_data = swqe->wr.ex.imm_data;
100 } 100 }
101 101
102 /* 102 /*
@@ -492,14 +492,14 @@ void ipath_ud_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
492 if (qp->ibqp.qp_num > 1 && 492 if (qp->ibqp.qp_num > 1 &&
493 opcode == IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE) { 493 opcode == IB_OPCODE_UD_SEND_ONLY_WITH_IMMEDIATE) {
494 if (header_in_data) { 494 if (header_in_data) {
495 wc.imm_data = *(__be32 *) data; 495 wc.ex.imm_data = *(__be32 *) data;
496 data += sizeof(__be32); 496 data += sizeof(__be32);
497 } else 497 } else
498 wc.imm_data = ohdr->u.ud.imm_data; 498 wc.ex.imm_data = ohdr->u.ud.imm_data;
499 wc.wc_flags = IB_WC_WITH_IMM; 499 wc.wc_flags = IB_WC_WITH_IMM;
500 hdrsize += sizeof(u32); 500 hdrsize += sizeof(u32);
501 } else if (opcode == IB_OPCODE_UD_SEND_ONLY) { 501 } else if (opcode == IB_OPCODE_UD_SEND_ONLY) {
502 wc.imm_data = 0; 502 wc.ex.imm_data = 0;
503 wc.wc_flags = 0; 503 wc.wc_flags = 0;
504 } else { 504 } else {
505 dev->n_pkt_drops++; 505 dev->n_pkt_drops++;
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs.c b/drivers/infiniband/hw/ipath/ipath_verbs.c
index 7779165b2c2c..55c718828826 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs.c
@@ -35,6 +35,7 @@
35#include <rdma/ib_user_verbs.h> 35#include <rdma/ib_user_verbs.h>
36#include <linux/io.h> 36#include <linux/io.h>
37#include <linux/utsname.h> 37#include <linux/utsname.h>
38#include <linux/rculist.h>
38 39
39#include "ipath_kernel.h" 40#include "ipath_kernel.h"
40#include "ipath_verbs.h" 41#include "ipath_verbs.h"
@@ -1497,7 +1498,8 @@ static int ipath_query_device(struct ib_device *ibdev,
1497 IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN | 1498 IB_DEVICE_SYS_IMAGE_GUID | IB_DEVICE_RC_RNR_NAK_GEN |
1498 IB_DEVICE_PORT_ACTIVE_EVENT | IB_DEVICE_SRQ_RESIZE; 1499 IB_DEVICE_PORT_ACTIVE_EVENT | IB_DEVICE_SRQ_RESIZE;
1499 props->page_size_cap = PAGE_SIZE; 1500 props->page_size_cap = PAGE_SIZE;
1500 props->vendor_id = dev->dd->ipath_vendorid; 1501 props->vendor_id =
1502 IPATH_SRC_OUI_1 << 16 | IPATH_SRC_OUI_2 << 8 | IPATH_SRC_OUI_3;
1501 props->vendor_part_id = dev->dd->ipath_deviceid; 1503 props->vendor_part_id = dev->dd->ipath_deviceid;
1502 props->hw_ver = dev->dd->ipath_pcirev; 1504 props->hw_ver = dev->dd->ipath_pcirev;
1503 1505
diff --git a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
index 9e5abf9c309d..d73e32232879 100644
--- a/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
+++ b/drivers/infiniband/hw/ipath/ipath_verbs_mcast.c
@@ -31,8 +31,7 @@
31 * SOFTWARE. 31 * SOFTWARE.
32 */ 32 */
33 33
34#include <linux/list.h> 34#include <linux/rculist.h>
35#include <linux/rcupdate.h>
36 35
37#include "ipath_verbs.h" 36#include "ipath_verbs.h"
38 37
diff --git a/drivers/infiniband/hw/mlx4/cq.c b/drivers/infiniband/hw/mlx4/cq.c
index 4521319b1406..299f20832ab6 100644
--- a/drivers/infiniband/hw/mlx4/cq.c
+++ b/drivers/infiniband/hw/mlx4/cq.c
@@ -663,18 +663,18 @@ repoll:
663 663
664 switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) { 664 switch (cqe->owner_sr_opcode & MLX4_CQE_OPCODE_MASK) {
665 case MLX4_RECV_OPCODE_RDMA_WRITE_IMM: 665 case MLX4_RECV_OPCODE_RDMA_WRITE_IMM:
666 wc->opcode = IB_WC_RECV_RDMA_WITH_IMM; 666 wc->opcode = IB_WC_RECV_RDMA_WITH_IMM;
667 wc->wc_flags = IB_WC_WITH_IMM; 667 wc->wc_flags = IB_WC_WITH_IMM;
668 wc->imm_data = cqe->immed_rss_invalid; 668 wc->ex.imm_data = cqe->immed_rss_invalid;
669 break; 669 break;
670 case MLX4_RECV_OPCODE_SEND: 670 case MLX4_RECV_OPCODE_SEND:
671 wc->opcode = IB_WC_RECV; 671 wc->opcode = IB_WC_RECV;
672 wc->wc_flags = 0; 672 wc->wc_flags = 0;
673 break; 673 break;
674 case MLX4_RECV_OPCODE_SEND_IMM: 674 case MLX4_RECV_OPCODE_SEND_IMM:
675 wc->opcode = IB_WC_RECV; 675 wc->opcode = IB_WC_RECV;
676 wc->wc_flags = IB_WC_WITH_IMM; 676 wc->wc_flags = IB_WC_WITH_IMM;
677 wc->imm_data = cqe->immed_rss_invalid; 677 wc->ex.imm_data = cqe->immed_rss_invalid;
678 break; 678 break;
679 } 679 }
680 680
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
index 4c1e72fc8f57..cdca3a511e1c 100644
--- a/drivers/infiniband/hw/mlx4/mad.c
+++ b/drivers/infiniband/hw/mlx4/mad.c
@@ -255,7 +255,8 @@ int mlx4_ib_process_mad(struct ib_device *ibdev, int mad_flags, u8 port_num,
255 return IB_MAD_RESULT_SUCCESS; 255 return IB_MAD_RESULT_SUCCESS;
256 } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT || 256 } else if (in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_PERF_MGMT ||
257 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS1 || 257 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS1 ||
258 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS2) { 258 in_mad->mad_hdr.mgmt_class == MLX4_IB_VENDOR_CLASS2 ||
259 in_mad->mad_hdr.mgmt_class == IB_MGMT_CLASS_CONG_MGMT) {
259 if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET && 260 if (in_mad->mad_hdr.method != IB_MGMT_METHOD_GET &&
260 in_mad->mad_hdr.method != IB_MGMT_METHOD_SET) 261 in_mad->mad_hdr.method != IB_MGMT_METHOD_SET)
261 return IB_MAD_RESULT_SUCCESS; 262 return IB_MAD_RESULT_SUCCESS;
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c
index 4d61e32866c6..bcf50648fa18 100644
--- a/drivers/infiniband/hw/mlx4/main.c
+++ b/drivers/infiniband/hw/mlx4/main.c
@@ -90,7 +90,8 @@ static int mlx4_ib_query_device(struct ib_device *ibdev,
90 props->device_cap_flags = IB_DEVICE_CHANGE_PHY_PORT | 90 props->device_cap_flags = IB_DEVICE_CHANGE_PHY_PORT |
91 IB_DEVICE_PORT_ACTIVE_EVENT | 91 IB_DEVICE_PORT_ACTIVE_EVENT |
92 IB_DEVICE_SYS_IMAGE_GUID | 92 IB_DEVICE_SYS_IMAGE_GUID |
93 IB_DEVICE_RC_RNR_NAK_GEN; 93 IB_DEVICE_RC_RNR_NAK_GEN |
94 IB_DEVICE_BLOCK_MULTICAST_LOOPBACK;
94 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR) 95 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_PKEY_CNTR)
95 props->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR; 96 props->device_cap_flags |= IB_DEVICE_BAD_PKEY_CNTR;
96 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR) 97 if (dev->dev->caps.flags & MLX4_DEV_CAP_FLAG_BAD_QKEY_CNTR)
@@ -437,7 +438,9 @@ static int mlx4_ib_dealloc_pd(struct ib_pd *pd)
437static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) 438static int mlx4_ib_mcg_attach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
438{ 439{
439 return mlx4_multicast_attach(to_mdev(ibqp->device)->dev, 440 return mlx4_multicast_attach(to_mdev(ibqp->device)->dev,
440 &to_mqp(ibqp)->mqp, gid->raw); 441 &to_mqp(ibqp)->mqp, gid->raw,
442 !!(to_mqp(ibqp)->flags &
443 MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK));
441} 444}
442 445
443static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid) 446static int mlx4_ib_mcg_detach(struct ib_qp *ibqp, union ib_gid *gid, u16 lid)
diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
index 5cf994794d25..c4cf5b69eefa 100644
--- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
+++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
@@ -101,7 +101,8 @@ struct mlx4_ib_wq {
101}; 101};
102 102
103enum mlx4_ib_qp_flags { 103enum mlx4_ib_qp_flags {
104 MLX4_IB_QP_LSO = 1 << 0 104 MLX4_IB_QP_LSO = 1 << 0,
105 MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK = 1 << 1,
105}; 106};
106 107
107struct mlx4_ib_qp { 108struct mlx4_ib_qp {
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c
index a80df22deae8..89eb6cbe592e 100644
--- a/drivers/infiniband/hw/mlx4/qp.c
+++ b/drivers/infiniband/hw/mlx4/qp.c
@@ -129,9 +129,10 @@ static void stamp_send_wqe(struct mlx4_ib_qp *qp, int n, int size)
129 int ind; 129 int ind;
130 void *buf; 130 void *buf;
131 __be32 stamp; 131 __be32 stamp;
132 struct mlx4_wqe_ctrl_seg *ctrl;
132 133
133 s = roundup(size, 1U << qp->sq.wqe_shift);
134 if (qp->sq_max_wqes_per_wr > 1) { 134 if (qp->sq_max_wqes_per_wr > 1) {
135 s = roundup(size, 1U << qp->sq.wqe_shift);
135 for (i = 0; i < s; i += 64) { 136 for (i = 0; i < s; i += 64) {
136 ind = (i >> qp->sq.wqe_shift) + n; 137 ind = (i >> qp->sq.wqe_shift) + n;
137 stamp = ind & qp->sq.wqe_cnt ? cpu_to_be32(0x7fffffff) : 138 stamp = ind & qp->sq.wqe_cnt ? cpu_to_be32(0x7fffffff) :
@@ -141,7 +142,8 @@ static void stamp_send_wqe(struct mlx4_ib_qp *qp, int n, int size)
141 *wqe = stamp; 142 *wqe = stamp;
142 } 143 }
143 } else { 144 } else {
144 buf = get_send_wqe(qp, n & (qp->sq.wqe_cnt - 1)); 145 ctrl = buf = get_send_wqe(qp, n & (qp->sq.wqe_cnt - 1));
146 s = (ctrl->fence_size & 0x3f) << 4;
145 for (i = 64; i < s; i += 64) { 147 for (i = 64; i < s; i += 64) {
146 wqe = buf + i; 148 wqe = buf + i;
147 *wqe = cpu_to_be32(0xffffffff); 149 *wqe = cpu_to_be32(0xffffffff);
@@ -452,19 +454,8 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
452 spin_lock_init(&qp->rq.lock); 454 spin_lock_init(&qp->rq.lock);
453 455
454 qp->state = IB_QPS_RESET; 456 qp->state = IB_QPS_RESET;
455 qp->atomic_rd_en = 0;
456 qp->resp_depth = 0;
457
458 qp->rq.head = 0;
459 qp->rq.tail = 0;
460 qp->sq.head = 0;
461 qp->sq.tail = 0;
462 qp->sq_next_wqe = 0;
463
464 if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR) 457 if (init_attr->sq_sig_type == IB_SIGNAL_ALL_WR)
465 qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE); 458 qp->sq_signal_bits = cpu_to_be32(MLX4_WQE_CTRL_CQ_UPDATE);
466 else
467 qp->sq_signal_bits = 0;
468 459
469 err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, !!init_attr->srq, qp); 460 err = set_rq_size(dev, &init_attr->cap, !!pd->uobject, !!init_attr->srq, qp);
470 if (err) 461 if (err)
@@ -509,6 +500,9 @@ static int create_qp_common(struct mlx4_ib_dev *dev, struct ib_pd *pd,
509 } else { 500 } else {
510 qp->sq_no_prefetch = 0; 501 qp->sq_no_prefetch = 0;
511 502
503 if (init_attr->create_flags & IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK)
504 qp->flags |= MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK;
505
512 if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO) 506 if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO)
513 qp->flags |= MLX4_IB_QP_LSO; 507 qp->flags |= MLX4_IB_QP_LSO;
514 508
@@ -682,10 +676,15 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
682 struct mlx4_ib_qp *qp; 676 struct mlx4_ib_qp *qp;
683 int err; 677 int err;
684 678
685 /* We only support LSO, and only for kernel UD QPs. */ 679 /*
686 if (init_attr->create_flags & ~IB_QP_CREATE_IPOIB_UD_LSO) 680 * We only support LSO and multicast loopback blocking, and
681 * only for kernel UD QPs.
682 */
683 if (init_attr->create_flags & ~(IB_QP_CREATE_IPOIB_UD_LSO |
684 IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK))
687 return ERR_PTR(-EINVAL); 685 return ERR_PTR(-EINVAL);
688 if (init_attr->create_flags & IB_QP_CREATE_IPOIB_UD_LSO && 686
687 if (init_attr->create_flags &&
689 (pd->uobject || init_attr->qp_type != IB_QPT_UD)) 688 (pd->uobject || init_attr->qp_type != IB_QPT_UD))
690 return ERR_PTR(-EINVAL); 689 return ERR_PTR(-EINVAL);
691 690
@@ -694,7 +693,7 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
694 case IB_QPT_UC: 693 case IB_QPT_UC:
695 case IB_QPT_UD: 694 case IB_QPT_UD:
696 { 695 {
697 qp = kmalloc(sizeof *qp, GFP_KERNEL); 696 qp = kzalloc(sizeof *qp, GFP_KERNEL);
698 if (!qp) 697 if (!qp)
699 return ERR_PTR(-ENOMEM); 698 return ERR_PTR(-ENOMEM);
700 699
@@ -715,7 +714,7 @@ struct ib_qp *mlx4_ib_create_qp(struct ib_pd *pd,
715 if (pd->uobject) 714 if (pd->uobject)
716 return ERR_PTR(-EINVAL); 715 return ERR_PTR(-EINVAL);
717 716
718 sqp = kmalloc(sizeof *sqp, GFP_KERNEL); 717 sqp = kzalloc(sizeof *sqp, GFP_KERNEL);
719 if (!sqp) 718 if (!sqp)
720 return ERR_PTR(-ENOMEM); 719 return ERR_PTR(-ENOMEM);
721 720
@@ -906,7 +905,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
906 attr->path_mtu); 905 attr->path_mtu);
907 goto out; 906 goto out;
908 } 907 }
909 context->mtu_msgmax = (attr->path_mtu << 5) | 31; 908 context->mtu_msgmax = (attr->path_mtu << 5) |
909 ilog2(dev->dev->caps.max_msg_sz);
910 } 910 }
911 911
912 if (qp->rq.wqe_cnt) 912 if (qp->rq.wqe_cnt)
@@ -1063,6 +1063,8 @@ static int __mlx4_ib_modify_qp(struct ib_qp *ibqp,
1063 for (i = 0; i < qp->sq.wqe_cnt; ++i) { 1063 for (i = 0; i < qp->sq.wqe_cnt; ++i) {
1064 ctrl = get_send_wqe(qp, i); 1064 ctrl = get_send_wqe(qp, i);
1065 ctrl->owner_opcode = cpu_to_be32(1 << 31); 1065 ctrl->owner_opcode = cpu_to_be32(1 << 31);
1066 if (qp->sq_max_wqes_per_wr == 1)
1067 ctrl->fence_size = 1 << (qp->sq.wqe_shift - 4);
1066 1068
1067 stamp_send_wqe(qp, i, 1 << qp->sq.wqe_shift); 1069 stamp_send_wqe(qp, i, 1 << qp->sq.wqe_shift);
1068 } 1070 }
@@ -1127,23 +1129,6 @@ out:
1127 return err; 1129 return err;
1128} 1130}
1129 1131
1130static const struct ib_qp_attr mlx4_ib_qp_attr = { .port_num = 1 };
1131static const int mlx4_ib_qp_attr_mask_table[IB_QPT_UD + 1] = {
1132 [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
1133 IB_QP_PORT |
1134 IB_QP_QKEY),
1135 [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
1136 IB_QP_PORT |
1137 IB_QP_ACCESS_FLAGS),
1138 [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
1139 IB_QP_PORT |
1140 IB_QP_ACCESS_FLAGS),
1141 [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
1142 IB_QP_QKEY),
1143 [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
1144 IB_QP_QKEY),
1145};
1146
1147int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, 1132int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1148 int attr_mask, struct ib_udata *udata) 1133 int attr_mask, struct ib_udata *udata)
1149{ 1134{
@@ -1186,15 +1171,6 @@ int mlx4_ib_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr,
1186 goto out; 1171 goto out;
1187 } 1172 }
1188 1173
1189 if (cur_state == IB_QPS_RESET && new_state == IB_QPS_ERR) {
1190 err = __mlx4_ib_modify_qp(ibqp, &mlx4_ib_qp_attr,
1191 mlx4_ib_qp_attr_mask_table[ibqp->qp_type],
1192 IB_QPS_RESET, IB_QPS_INIT);
1193 if (err)
1194 goto out;
1195 cur_state = IB_QPS_INIT;
1196 }
1197
1198 err = __mlx4_ib_modify_qp(ibqp, attr, attr_mask, cur_state, new_state); 1174 err = __mlx4_ib_modify_qp(ibqp, attr, attr_mask, cur_state, new_state);
1199 1175
1200out: 1176out:
@@ -1865,6 +1841,13 @@ done:
1865 1841
1866 qp_init_attr->cap = qp_attr->cap; 1842 qp_init_attr->cap = qp_attr->cap;
1867 1843
1844 qp_init_attr->create_flags = 0;
1845 if (qp->flags & MLX4_IB_QP_BLOCK_MULTICAST_LOOPBACK)
1846 qp_init_attr->create_flags |= IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK;
1847
1848 if (qp->flags & MLX4_IB_QP_LSO)
1849 qp_init_attr->create_flags |= IB_QP_CREATE_IPOIB_UD_LSO;
1850
1868out: 1851out:
1869 mutex_unlock(&qp->mutex); 1852 mutex_unlock(&qp->mutex);
1870 return err; 1853 return err;
diff --git a/drivers/infiniband/hw/mthca/mthca_allocator.c b/drivers/infiniband/hw/mthca/mthca_allocator.c
index a76306709618..c5ccc2daab60 100644
--- a/drivers/infiniband/hw/mthca/mthca_allocator.c
+++ b/drivers/infiniband/hw/mthca/mthca_allocator.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_allocator.c 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#include <linux/errno.h> 33#include <linux/errno.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_av.c b/drivers/infiniband/hw/mthca/mthca_av.c
index 4b111a852ff6..32f6c6315454 100644
--- a/drivers/infiniband/hw/mthca/mthca_av.c
+++ b/drivers/infiniband/hw/mthca/mthca_av.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_av.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/string.h> 34#include <linux/string.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_catas.c b/drivers/infiniband/hw/mthca/mthca_catas.c
index e948158a28d9..cc440f90000b 100644
--- a/drivers/infiniband/hw/mthca/mthca_catas.c
+++ b/drivers/infiniband/hw/mthca/mthca_catas.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id$
33 */ 31 */
34 32
35#include <linux/jiffies.h> 33#include <linux/jiffies.h>
@@ -128,7 +126,6 @@ static void handle_catas(struct mthca_dev *dev)
128static void poll_catas(unsigned long dev_ptr) 126static void poll_catas(unsigned long dev_ptr)
129{ 127{
130 struct mthca_dev *dev = (struct mthca_dev *) dev_ptr; 128 struct mthca_dev *dev = (struct mthca_dev *) dev_ptr;
131 unsigned long flags;
132 int i; 129 int i;
133 130
134 for (i = 0; i < dev->catas_err.size; ++i) 131 for (i = 0; i < dev->catas_err.size; ++i)
@@ -137,13 +134,8 @@ static void poll_catas(unsigned long dev_ptr)
137 return; 134 return;
138 } 135 }
139 136
140 spin_lock_irqsave(&catas_lock, flags); 137 mod_timer(&dev->catas_err.timer,
141 if (!dev->catas_err.stop) 138 round_jiffies(jiffies + MTHCA_CATAS_POLL_INTERVAL));
142 mod_timer(&dev->catas_err.timer,
143 jiffies + MTHCA_CATAS_POLL_INTERVAL);
144 spin_unlock_irqrestore(&catas_lock, flags);
145
146 return;
147} 139}
148 140
149void mthca_start_catas_poll(struct mthca_dev *dev) 141void mthca_start_catas_poll(struct mthca_dev *dev)
@@ -151,7 +143,6 @@ void mthca_start_catas_poll(struct mthca_dev *dev)
151 unsigned long addr; 143 unsigned long addr;
152 144
153 init_timer(&dev->catas_err.timer); 145 init_timer(&dev->catas_err.timer);
154 dev->catas_err.stop = 0;
155 dev->catas_err.map = NULL; 146 dev->catas_err.map = NULL;
156 147
157 addr = pci_resource_start(dev->pdev, 0) + 148 addr = pci_resource_start(dev->pdev, 0) +
@@ -182,10 +173,6 @@ void mthca_start_catas_poll(struct mthca_dev *dev)
182 173
183void mthca_stop_catas_poll(struct mthca_dev *dev) 174void mthca_stop_catas_poll(struct mthca_dev *dev)
184{ 175{
185 spin_lock_irq(&catas_lock);
186 dev->catas_err.stop = 1;
187 spin_unlock_irq(&catas_lock);
188
189 del_timer_sync(&dev->catas_err.timer); 176 del_timer_sync(&dev->catas_err.timer);
190 177
191 if (dev->catas_err.map) { 178 if (dev->catas_err.map) {
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
index 54d230ee7d63..c33e1c53c799 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.c
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_cmd.c 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include <linux/completion.h> 35#include <linux/completion.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.h b/drivers/infiniband/hw/mthca/mthca_cmd.h
index 8928ca4a9325..6efd3265f248 100644
--- a/drivers/infiniband/hw/mthca/mthca_cmd.h
+++ b/drivers/infiniband/hw/mthca/mthca_cmd.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_cmd.h 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#ifndef MTHCA_CMD_H 35#ifndef MTHCA_CMD_H
diff --git a/drivers/infiniband/hw/mthca/mthca_config_reg.h b/drivers/infiniband/hw/mthca/mthca_config_reg.h
index afa56bfaab2e..75671f75cac4 100644
--- a/drivers/infiniband/hw/mthca/mthca_config_reg.h
+++ b/drivers/infiniband/hw/mthca/mthca_config_reg.h
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_config_reg.h 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#ifndef MTHCA_CONFIG_REG_H 34#ifndef MTHCA_CONFIG_REG_H
diff --git a/drivers/infiniband/hw/mthca/mthca_cq.c b/drivers/infiniband/hw/mthca/mthca_cq.c
index 20401d2ba6b2..d9f4735c2b37 100644
--- a/drivers/infiniband/hw/mthca/mthca_cq.c
+++ b/drivers/infiniband/hw/mthca/mthca_cq.c
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: mthca_cq.c 1369 2004-12-20 16:17:07Z roland $
37 */ 35 */
38 36
39#include <linux/hardirq.h> 37#include <linux/hardirq.h>
@@ -622,13 +620,13 @@ static inline int mthca_poll_one(struct mthca_dev *dev,
622 case IB_OPCODE_SEND_LAST_WITH_IMMEDIATE: 620 case IB_OPCODE_SEND_LAST_WITH_IMMEDIATE:
623 case IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE: 621 case IB_OPCODE_SEND_ONLY_WITH_IMMEDIATE:
624 entry->wc_flags = IB_WC_WITH_IMM; 622 entry->wc_flags = IB_WC_WITH_IMM;
625 entry->imm_data = cqe->imm_etype_pkey_eec; 623 entry->ex.imm_data = cqe->imm_etype_pkey_eec;
626 entry->opcode = IB_WC_RECV; 624 entry->opcode = IB_WC_RECV;
627 break; 625 break;
628 case IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE: 626 case IB_OPCODE_RDMA_WRITE_LAST_WITH_IMMEDIATE:
629 case IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE: 627 case IB_OPCODE_RDMA_WRITE_ONLY_WITH_IMMEDIATE:
630 entry->wc_flags = IB_WC_WITH_IMM; 628 entry->wc_flags = IB_WC_WITH_IMM;
631 entry->imm_data = cqe->imm_etype_pkey_eec; 629 entry->ex.imm_data = cqe->imm_etype_pkey_eec;
632 entry->opcode = IB_WC_RECV_RDMA_WITH_IMM; 630 entry->opcode = IB_WC_RECV_RDMA_WITH_IMM;
633 break; 631 break;
634 default: 632 default:
diff --git a/drivers/infiniband/hw/mthca/mthca_dev.h b/drivers/infiniband/hw/mthca/mthca_dev.h
index 7bc32f8e377e..ee4d073c889f 100644
--- a/drivers/infiniband/hw/mthca/mthca_dev.h
+++ b/drivers/infiniband/hw/mthca/mthca_dev.h
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: mthca_dev.h 1349 2004-12-16 21:09:43Z roland $
37 */ 35 */
38 36
39#ifndef MTHCA_DEV_H 37#ifndef MTHCA_DEV_H
@@ -279,7 +277,6 @@ struct mthca_mcg_table {
279struct mthca_catas_err { 277struct mthca_catas_err {
280 u64 addr; 278 u64 addr;
281 u32 __iomem *map; 279 u32 __iomem *map;
282 unsigned long stop;
283 u32 size; 280 u32 size;
284 struct timer_list timer; 281 struct timer_list timer;
285 struct list_head list; 282 struct list_head list;
diff --git a/drivers/infiniband/hw/mthca/mthca_doorbell.h b/drivers/infiniband/hw/mthca/mthca_doorbell.h
index b374dc395be1..14f51ef97d7e 100644
--- a/drivers/infiniband/hw/mthca/mthca_doorbell.h
+++ b/drivers/infiniband/hw/mthca/mthca_doorbell.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_doorbell.h 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include <linux/types.h> 35#include <linux/types.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c
index 8bde7f98e58a..4e36aa7cb3d2 100644
--- a/drivers/infiniband/hw/mthca/mthca_eq.c
+++ b/drivers/infiniband/hw/mthca/mthca_eq.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_eq.c 1382 2004-12-24 02:21:02Z roland $
34 */ 32 */
35 33
36#include <linux/errno.h> 34#include <linux/errno.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_mad.c b/drivers/infiniband/hw/mthca/mthca_mad.c
index 8b7e83e6e88f..640449582aba 100644
--- a/drivers/infiniband/hw/mthca/mthca_mad.c
+++ b/drivers/infiniband/hw/mthca/mthca_mad.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_mad.c 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include <linux/string.h> 35#include <linux/string.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
index 200cf13fc9bb..fb9f91b60f30 100644
--- a/drivers/infiniband/hw/mthca/mthca_main.c
+++ b/drivers/infiniband/hw/mthca/mthca_main.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_main.c 1396 2004-12-28 04:10:27Z roland $
35 */ 33 */
36 34
37#include <linux/module.h> 35#include <linux/module.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_mcg.c b/drivers/infiniband/hw/mthca/mthca_mcg.c
index a8ad072be074..3f5f94879208 100644
--- a/drivers/infiniband/hw/mthca/mthca_mcg.c
+++ b/drivers/infiniband/hw/mthca/mthca_mcg.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_mcg.c 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#include <linux/string.h> 33#include <linux/string.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c
index d5862e5d99a0..1f7d1a29d2a8 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.c
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id$
35 */ 33 */
36 34
37#include <linux/mm.h> 35#include <linux/mm.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.h b/drivers/infiniband/hw/mthca/mthca_memfree.h
index a1ab06847b75..da9b8f9b884f 100644
--- a/drivers/infiniband/hw/mthca/mthca_memfree.h
+++ b/drivers/infiniband/hw/mthca/mthca_memfree.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id$
35 */ 33 */
36 34
37#ifndef MTHCA_MEMFREE_H 35#ifndef MTHCA_MEMFREE_H
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
index 820205dec560..8489b1e81c0f 100644
--- a/drivers/infiniband/hw/mthca/mthca_mr.c
+++ b/drivers/infiniband/hw/mthca/mthca_mr.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_mr.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/slab.h> 34#include <linux/slab.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_pd.c b/drivers/infiniband/hw/mthca/mthca_pd.c
index c1e950764bd8..266f14e47406 100644
--- a/drivers/infiniband/hw/mthca/mthca_pd.c
+++ b/drivers/infiniband/hw/mthca/mthca_pd.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_pd.c 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#include <linux/errno.h> 35#include <linux/errno.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_profile.c b/drivers/infiniband/hw/mthca/mthca_profile.c
index 605a8d57fac6..d168c2540611 100644
--- a/drivers/infiniband/hw/mthca/mthca_profile.c
+++ b/drivers/infiniband/hw/mthca/mthca_profile.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_profile.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include <linux/module.h> 34#include <linux/module.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_profile.h b/drivers/infiniband/hw/mthca/mthca_profile.h
index e76cb62d8e32..62b009cc8730 100644
--- a/drivers/infiniband/hw/mthca/mthca_profile.h
+++ b/drivers/infiniband/hw/mthca/mthca_profile.h
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: mthca_profile.h 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#ifndef MTHCA_PROFILE_H 34#ifndef MTHCA_PROFILE_H
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
index be34f99ca625..87ad889e367b 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.c
+++ b/drivers/infiniband/hw/mthca/mthca_provider.c
@@ -32,8 +32,6 @@
32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 33 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 * SOFTWARE. 34 * SOFTWARE.
35 *
36 * $Id: mthca_provider.c 4859 2006-01-09 21:55:10Z roland $
37 */ 35 */
38 36
39#include <rdma/ib_smi.h> 37#include <rdma/ib_smi.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.h b/drivers/infiniband/hw/mthca/mthca_provider.h
index 934bf9544037..c621f8794b88 100644
--- a/drivers/infiniband/hw/mthca/mthca_provider.h
+++ b/drivers/infiniband/hw/mthca/mthca_provider.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: mthca_provider.h 1349 2004-12-16 21:09:43Z roland $
35 */ 33 */
36 34
37#ifndef MTHCA_PROVIDER_H 35#ifndef MTHCA_PROVIDER_H
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c
index 09dc3614cf2c..f5081bfde6db 100644
--- a/drivers/infiniband/hw/mthca/mthca_qp.c
+++ b/drivers/infiniband/hw/mthca/mthca_qp.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: mthca_qp.c 1355 2004-12-17 15:23:43Z roland $
36 */ 34 */
37 35
38#include <linux/string.h> 36#include <linux/string.h>
@@ -850,23 +848,6 @@ out:
850 return err; 848 return err;
851} 849}
852 850
853static const struct ib_qp_attr dummy_init_attr = { .port_num = 1 };
854static const int dummy_init_attr_mask[] = {
855 [IB_QPT_UD] = (IB_QP_PKEY_INDEX |
856 IB_QP_PORT |
857 IB_QP_QKEY),
858 [IB_QPT_UC] = (IB_QP_PKEY_INDEX |
859 IB_QP_PORT |
860 IB_QP_ACCESS_FLAGS),
861 [IB_QPT_RC] = (IB_QP_PKEY_INDEX |
862 IB_QP_PORT |
863 IB_QP_ACCESS_FLAGS),
864 [IB_QPT_SMI] = (IB_QP_PKEY_INDEX |
865 IB_QP_QKEY),
866 [IB_QPT_GSI] = (IB_QP_PKEY_INDEX |
867 IB_QP_QKEY),
868};
869
870int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask, 851int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
871 struct ib_udata *udata) 852 struct ib_udata *udata)
872{ 853{
@@ -928,15 +909,6 @@ int mthca_modify_qp(struct ib_qp *ibqp, struct ib_qp_attr *attr, int attr_mask,
928 goto out; 909 goto out;
929 } 910 }
930 911
931 if (cur_state == IB_QPS_RESET && new_state == IB_QPS_ERR) {
932 err = __mthca_modify_qp(ibqp, &dummy_init_attr,
933 dummy_init_attr_mask[ibqp->qp_type],
934 IB_QPS_RESET, IB_QPS_INIT);
935 if (err)
936 goto out;
937 cur_state = IB_QPS_INIT;
938 }
939
940 err = __mthca_modify_qp(ibqp, attr, attr_mask, cur_state, new_state); 912 err = __mthca_modify_qp(ibqp, attr, attr_mask, cur_state, new_state);
941 913
942out: 914out:
@@ -1277,10 +1249,10 @@ static int mthca_set_qp_size(struct mthca_dev *dev, struct ib_qp_cap *cap,
1277 return -EINVAL; 1249 return -EINVAL;
1278 1250
1279 /* 1251 /*
1280 * For MLX transport we need 2 extra S/G entries: 1252 * For MLX transport we need 2 extra send gather entries:
1281 * one for the header and one for the checksum at the end 1253 * one for the header and one for the checksum at the end
1282 */ 1254 */
1283 if (qp->transport == MLX && cap->max_recv_sge + 2 > dev->limits.max_sg) 1255 if (qp->transport == MLX && cap->max_send_sge + 2 > dev->limits.max_sg)
1284 return -EINVAL; 1256 return -EINVAL;
1285 1257
1286 if (mthca_is_memfree(dev)) { 1258 if (mthca_is_memfree(dev)) {
diff --git a/drivers/infiniband/hw/mthca/mthca_reset.c b/drivers/infiniband/hw/mthca/mthca_reset.c
index 91934f2d9dba..acb6817f6060 100644
--- a/drivers/infiniband/hw/mthca/mthca_reset.c
+++ b/drivers/infiniband/hw/mthca/mthca_reset.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_reset.c 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#include <linux/init.h> 33#include <linux/init.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c
index a5ffff6e1026..4fabe62aab8a 100644
--- a/drivers/infiniband/hw/mthca/mthca_srq.c
+++ b/drivers/infiniband/hw/mthca/mthca_srq.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_srq.c 3047 2005-08-10 03:59:35Z roland $
33 */ 31 */
34 32
35#include <linux/slab.h> 33#include <linux/slab.h>
diff --git a/drivers/infiniband/hw/mthca/mthca_uar.c b/drivers/infiniband/hw/mthca/mthca_uar.c
index 8b728486410d..ca5900c96fcf 100644
--- a/drivers/infiniband/hw/mthca/mthca_uar.c
+++ b/drivers/infiniband/hw/mthca/mthca_uar.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id$
33 */ 31 */
34 32
35#include <asm/page.h> /* PAGE_SHIFT */ 33#include <asm/page.h> /* PAGE_SHIFT */
diff --git a/drivers/infiniband/hw/mthca/mthca_user.h b/drivers/infiniband/hw/mthca/mthca_user.h
index e1262c942db8..5fe56e810739 100644
--- a/drivers/infiniband/hw/mthca/mthca_user.h
+++ b/drivers/infiniband/hw/mthca/mthca_user.h
@@ -29,7 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 */ 32 */
34 33
35#ifndef MTHCA_USER_H 34#ifndef MTHCA_USER_H
diff --git a/drivers/infiniband/hw/mthca/mthca_wqe.h b/drivers/infiniband/hw/mthca/mthca_wqe.h
index b3551a8dea1d..341a5ae881c1 100644
--- a/drivers/infiniband/hw/mthca/mthca_wqe.h
+++ b/drivers/infiniband/hw/mthca/mthca_wqe.h
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: mthca_wqe.h 3047 2005-08-10 03:59:35Z roland $
33 */ 31 */
34 32
35#ifndef MTHCA_WQE_H 33#ifndef MTHCA_WQE_H
diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
index a4e9269a29bd..d2884e778098 100644
--- a/drivers/infiniband/hw/nes/nes.c
+++ b/drivers/infiniband/hw/nes/nes.c
@@ -328,7 +328,7 @@ void nes_rem_ref(struct ib_qp *ibqp)
328 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_ID_IDX, nesqp->hwqp.qp_id); 328 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_WQE_ID_IDX, nesqp->hwqp.qp_id);
329 u64temp = (u64)nesqp->nesqp_context_pbase; 329 u64temp = (u64)nesqp->nesqp_context_pbase;
330 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, u64temp); 330 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, u64temp);
331 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 331 nes_post_cqp_request(nesdev, cqp_request);
332 } 332 }
333} 333}
334 334
diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
index 61b46e9c7d2d..39bd897b40c6 100644
--- a/drivers/infiniband/hw/nes/nes.h
+++ b/drivers/infiniband/hw/nes/nes.h
@@ -94,9 +94,6 @@
94 94
95#define MAX_DPC_ITERATIONS 128 95#define MAX_DPC_ITERATIONS 128
96 96
97#define NES_CQP_REQUEST_NO_DOORBELL_RING 0
98#define NES_CQP_REQUEST_RING_DOORBELL 1
99
100#define NES_DRV_OPT_ENABLE_MPA_VER_0 0x00000001 97#define NES_DRV_OPT_ENABLE_MPA_VER_0 0x00000001
101#define NES_DRV_OPT_DISABLE_MPA_CRC 0x00000002 98#define NES_DRV_OPT_DISABLE_MPA_CRC 0x00000002
102#define NES_DRV_OPT_DISABLE_FIRST_WRITE 0x00000004 99#define NES_DRV_OPT_DISABLE_FIRST_WRITE 0x00000004
@@ -538,7 +535,11 @@ void nes_read_1G_phy_reg(struct nes_device *, u8, u8, u16 *);
538void nes_write_10G_phy_reg(struct nes_device *, u16, u8, u16, u16); 535void nes_write_10G_phy_reg(struct nes_device *, u16, u8, u16, u16);
539void nes_read_10G_phy_reg(struct nes_device *, u8, u8, u16); 536void nes_read_10G_phy_reg(struct nes_device *, u8, u8, u16);
540struct nes_cqp_request *nes_get_cqp_request(struct nes_device *); 537struct nes_cqp_request *nes_get_cqp_request(struct nes_device *);
541void nes_post_cqp_request(struct nes_device *, struct nes_cqp_request *, int); 538void nes_free_cqp_request(struct nes_device *nesdev,
539 struct nes_cqp_request *cqp_request);
540void nes_put_cqp_request(struct nes_device *nesdev,
541 struct nes_cqp_request *cqp_request);
542void nes_post_cqp_request(struct nes_device *, struct nes_cqp_request *);
542int nes_arp_table(struct nes_device *, u32, u8 *, u32); 543int nes_arp_table(struct nes_device *, u32, u8 *, u32);
543void nes_mh_fix(unsigned long); 544void nes_mh_fix(unsigned long);
544void nes_clc(unsigned long); 545void nes_clc(unsigned long);
diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
index 9a4b40fae40d..6aa531d5276d 100644
--- a/drivers/infiniband/hw/nes/nes_cm.c
+++ b/drivers/infiniband/hw/nes/nes_cm.c
@@ -1603,7 +1603,6 @@ static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *cm_core,
1603 return NULL; 1603 return NULL;
1604 } 1604 }
1605 1605
1606 memset(listener, 0, sizeof(struct nes_cm_listener));
1607 listener->loc_addr = htonl(cm_info->loc_addr); 1606 listener->loc_addr = htonl(cm_info->loc_addr);
1608 listener->loc_port = htons(cm_info->loc_port); 1607 listener->loc_port = htons(cm_info->loc_port);
1609 listener->reused_node = 0; 1608 listener->reused_node = 0;
diff --git a/drivers/infiniband/hw/nes/nes_hw.c b/drivers/infiniband/hw/nes/nes_hw.c
index d3278f111ca7..85f26d19a32b 100644
--- a/drivers/infiniband/hw/nes/nes_hw.c
+++ b/drivers/infiniband/hw/nes/nes_hw.c
@@ -398,7 +398,7 @@ struct nes_adapter *nes_init_adapter(struct nes_device *nesdev, u8 hw_rev) {
398 nesadapter->base_pd = 1; 398 nesadapter->base_pd = 1;
399 399
400 nesadapter->device_cap_flags = 400 nesadapter->device_cap_flags =
401 IB_DEVICE_ZERO_STAG | IB_DEVICE_MEM_WINDOW; 401 IB_DEVICE_LOCAL_DMA_LKEY | IB_DEVICE_MEM_WINDOW;
402 402
403 nesadapter->allocated_qps = (unsigned long *)&(((unsigned char *)nesadapter) 403 nesadapter->allocated_qps = (unsigned long *)&(((unsigned char *)nesadapter)
404 [(sizeof(struct nes_adapter)+(sizeof(unsigned long)-1))&(~(sizeof(unsigned long)-1))]); 404 [(sizeof(struct nes_adapter)+(sizeof(unsigned long)-1))&(~(sizeof(unsigned long)-1))]);
@@ -2710,39 +2710,11 @@ static void nes_cqp_ce_handler(struct nes_device *nesdev, struct nes_hw_cq *cq)
2710 barrier(); 2710 barrier();
2711 cqp_request->request_done = 1; 2711 cqp_request->request_done = 1;
2712 wake_up(&cqp_request->waitq); 2712 wake_up(&cqp_request->waitq);
2713 if (atomic_dec_and_test(&cqp_request->refcount)) { 2713 nes_put_cqp_request(nesdev, cqp_request);
2714 nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) freed.\n",
2715 cqp_request,
2716 le32_to_cpu(cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX])&0x3f);
2717 if (cqp_request->dynamic) {
2718 kfree(cqp_request);
2719 } else {
2720 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2721 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2722 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2723 }
2724 }
2725 } else if (cqp_request->callback) {
2726 /* Envoke the callback routine */
2727 cqp_request->cqp_callback(nesdev, cqp_request);
2728 if (cqp_request->dynamic) {
2729 kfree(cqp_request);
2730 } else {
2731 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2732 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2733 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2734 }
2735 } else { 2714 } else {
2736 nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) freed.\n", 2715 if (cqp_request->callback)
2737 cqp_request, 2716 cqp_request->cqp_callback(nesdev, cqp_request);
2738 le32_to_cpu(cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX]) & 0x3f); 2717 nes_free_cqp_request(nesdev, cqp_request);
2739 if (cqp_request->dynamic) {
2740 kfree(cqp_request);
2741 } else {
2742 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2743 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2744 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2745 }
2746 } 2718 }
2747 } else { 2719 } else {
2748 wake_up(&nesdev->cqp.waitq); 2720 wake_up(&nesdev->cqp.waitq);
@@ -3149,7 +3121,6 @@ int nes_manage_apbvt(struct nes_vnic *nesvnic, u32 accel_local_port,
3149{ 3121{
3150 struct nes_device *nesdev = nesvnic->nesdev; 3122 struct nes_device *nesdev = nesvnic->nesdev;
3151 struct nes_hw_cqp_wqe *cqp_wqe; 3123 struct nes_hw_cqp_wqe *cqp_wqe;
3152 unsigned long flags;
3153 struct nes_cqp_request *cqp_request; 3124 struct nes_cqp_request *cqp_request;
3154 int ret = 0; 3125 int ret = 0;
3155 u16 major_code; 3126 u16 major_code;
@@ -3176,7 +3147,7 @@ int nes_manage_apbvt(struct nes_vnic *nesvnic, u32 accel_local_port,
3176 nes_debug(NES_DBG_QP, "Waiting for CQP completion for APBVT.\n"); 3147 nes_debug(NES_DBG_QP, "Waiting for CQP completion for APBVT.\n");
3177 3148
3178 atomic_set(&cqp_request->refcount, 2); 3149 atomic_set(&cqp_request->refcount, 2);
3179 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 3150 nes_post_cqp_request(nesdev, cqp_request);
3180 3151
3181 if (add_port == NES_MANAGE_APBVT_ADD) 3152 if (add_port == NES_MANAGE_APBVT_ADD)
3182 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0), 3153 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0),
@@ -3184,15 +3155,9 @@ int nes_manage_apbvt(struct nes_vnic *nesvnic, u32 accel_local_port,
3184 nes_debug(NES_DBG_QP, "Completed, ret=%u, CQP Major:Minor codes = 0x%04X:0x%04X\n", 3155 nes_debug(NES_DBG_QP, "Completed, ret=%u, CQP Major:Minor codes = 0x%04X:0x%04X\n",
3185 ret, cqp_request->major_code, cqp_request->minor_code); 3156 ret, cqp_request->major_code, cqp_request->minor_code);
3186 major_code = cqp_request->major_code; 3157 major_code = cqp_request->major_code;
3187 if (atomic_dec_and_test(&cqp_request->refcount)) { 3158
3188 if (cqp_request->dynamic) { 3159 nes_put_cqp_request(nesdev, cqp_request);
3189 kfree(cqp_request); 3160
3190 } else {
3191 spin_lock_irqsave(&nesdev->cqp.lock, flags);
3192 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
3193 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
3194 }
3195 }
3196 if (!ret) 3161 if (!ret)
3197 return -ETIME; 3162 return -ETIME;
3198 else if (major_code) 3163 else if (major_code)
@@ -3252,7 +3217,7 @@ void nes_manage_arp_cache(struct net_device *netdev, unsigned char *mac_addr,
3252 nesdev->cqp.sq_head, nesdev->cqp.sq_tail); 3217 nesdev->cqp.sq_head, nesdev->cqp.sq_tail);
3253 3218
3254 atomic_set(&cqp_request->refcount, 1); 3219 atomic_set(&cqp_request->refcount, 1);
3255 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 3220 nes_post_cqp_request(nesdev, cqp_request);
3256} 3221}
3257 3222
3258 3223
@@ -3262,7 +3227,6 @@ void nes_manage_arp_cache(struct net_device *netdev, unsigned char *mac_addr,
3262void flush_wqes(struct nes_device *nesdev, struct nes_qp *nesqp, 3227void flush_wqes(struct nes_device *nesdev, struct nes_qp *nesqp,
3263 u32 which_wq, u32 wait_completion) 3228 u32 which_wq, u32 wait_completion)
3264{ 3229{
3265 unsigned long flags;
3266 struct nes_cqp_request *cqp_request; 3230 struct nes_cqp_request *cqp_request;
3267 struct nes_hw_cqp_wqe *cqp_wqe; 3231 struct nes_hw_cqp_wqe *cqp_wqe;
3268 int ret; 3232 int ret;
@@ -3285,7 +3249,7 @@ void flush_wqes(struct nes_device *nesdev, struct nes_qp *nesqp,
3285 cpu_to_le32(NES_CQP_FLUSH_WQES | which_wq); 3249 cpu_to_le32(NES_CQP_FLUSH_WQES | which_wq);
3286 cqp_wqe->wqe_words[NES_CQP_WQE_ID_IDX] = cpu_to_le32(nesqp->hwqp.qp_id); 3250 cqp_wqe->wqe_words[NES_CQP_WQE_ID_IDX] = cpu_to_le32(nesqp->hwqp.qp_id);
3287 3251
3288 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 3252 nes_post_cqp_request(nesdev, cqp_request);
3289 3253
3290 if (wait_completion) { 3254 if (wait_completion) {
3291 /* Wait for CQP */ 3255 /* Wait for CQP */
@@ -3294,14 +3258,6 @@ void flush_wqes(struct nes_device *nesdev, struct nes_qp *nesqp,
3294 nes_debug(NES_DBG_QP, "Flush SQ QP WQEs completed, ret=%u," 3258 nes_debug(NES_DBG_QP, "Flush SQ QP WQEs completed, ret=%u,"
3295 " CQP Major:Minor codes = 0x%04X:0x%04X\n", 3259 " CQP Major:Minor codes = 0x%04X:0x%04X\n",
3296 ret, cqp_request->major_code, cqp_request->minor_code); 3260 ret, cqp_request->major_code, cqp_request->minor_code);
3297 if (atomic_dec_and_test(&cqp_request->refcount)) { 3261 nes_put_cqp_request(nesdev, cqp_request);
3298 if (cqp_request->dynamic) {
3299 kfree(cqp_request);
3300 } else {
3301 spin_lock_irqsave(&nesdev->cqp.lock, flags);
3302 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
3303 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
3304 }
3305 }
3306 } 3262 }
3307} 3263}
diff --git a/drivers/infiniband/hw/nes/nes_hw.h b/drivers/infiniband/hw/nes/nes_hw.h
index 745bf94f3f07..7b81e0ae0076 100644
--- a/drivers/infiniband/hw/nes/nes_hw.h
+++ b/drivers/infiniband/hw/nes/nes_hw.h
@@ -1172,7 +1172,7 @@ struct nes_vnic {
1172 u32 mcrq_qp_id; 1172 u32 mcrq_qp_id;
1173 struct nes_ucontext *mcrq_ucontext; 1173 struct nes_ucontext *mcrq_ucontext;
1174 struct nes_cqp_request* (*get_cqp_request)(struct nes_device *nesdev); 1174 struct nes_cqp_request* (*get_cqp_request)(struct nes_device *nesdev);
1175 void (*post_cqp_request)(struct nes_device*, struct nes_cqp_request *, int); 1175 void (*post_cqp_request)(struct nes_device*, struct nes_cqp_request *);
1176 int (*mcrq_mcast_filter)( struct nes_vnic* nesvnic, __u8* dmi_addr ); 1176 int (*mcrq_mcast_filter)( struct nes_vnic* nesvnic, __u8* dmi_addr );
1177 struct net_device_stats netstats; 1177 struct net_device_stats netstats;
1178 /* used to put the netdev on the adapters logical port list */ 1178 /* used to put the netdev on the adapters logical port list */
diff --git a/drivers/infiniband/hw/nes/nes_utils.c b/drivers/infiniband/hw/nes/nes_utils.c
index fe83d1b2b177..fb8cbd71a2ef 100644
--- a/drivers/infiniband/hw/nes/nes_utils.c
+++ b/drivers/infiniband/hw/nes/nes_utils.c
@@ -567,12 +567,36 @@ struct nes_cqp_request *nes_get_cqp_request(struct nes_device *nesdev)
567 return cqp_request; 567 return cqp_request;
568} 568}
569 569
570void nes_free_cqp_request(struct nes_device *nesdev,
571 struct nes_cqp_request *cqp_request)
572{
573 unsigned long flags;
574
575 nes_debug(NES_DBG_CQP, "CQP request %p (opcode 0x%02X) freed.\n",
576 cqp_request,
577 le32_to_cpu(cqp_request->cqp_wqe.wqe_words[NES_CQP_WQE_OPCODE_IDX]) & 0x3f);
578
579 if (cqp_request->dynamic) {
580 kfree(cqp_request);
581 } else {
582 spin_lock_irqsave(&nesdev->cqp.lock, flags);
583 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
584 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
585 }
586}
587
588void nes_put_cqp_request(struct nes_device *nesdev,
589 struct nes_cqp_request *cqp_request)
590{
591 if (atomic_dec_and_test(&cqp_request->refcount))
592 nes_free_cqp_request(nesdev, cqp_request);
593}
570 594
571/** 595/**
572 * nes_post_cqp_request 596 * nes_post_cqp_request
573 */ 597 */
574void nes_post_cqp_request(struct nes_device *nesdev, 598void nes_post_cqp_request(struct nes_device *nesdev,
575 struct nes_cqp_request *cqp_request, int ring_doorbell) 599 struct nes_cqp_request *cqp_request)
576{ 600{
577 struct nes_hw_cqp_wqe *cqp_wqe; 601 struct nes_hw_cqp_wqe *cqp_wqe;
578 unsigned long flags; 602 unsigned long flags;
@@ -600,10 +624,9 @@ void nes_post_cqp_request(struct nes_device *nesdev,
600 nesdev->cqp.sq_head, nesdev->cqp.sq_tail, nesdev->cqp.sq_size, 624 nesdev->cqp.sq_head, nesdev->cqp.sq_tail, nesdev->cqp.sq_size,
601 cqp_request->waiting, atomic_read(&cqp_request->refcount)); 625 cqp_request->waiting, atomic_read(&cqp_request->refcount));
602 barrier(); 626 barrier();
603 if (ring_doorbell) { 627
604 /* Ring doorbell (1 WQEs) */ 628 /* Ring doorbell (1 WQEs) */
605 nes_write32(nesdev->regs+NES_WQE_ALLOC, 0x01800000 | nesdev->cqp.qp_id); 629 nes_write32(nesdev->regs+NES_WQE_ALLOC, 0x01800000 | nesdev->cqp.qp_id);
606 }
607 630
608 barrier(); 631 barrier();
609 } else { 632 } else {
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
index d617da9bd351..e3939d13484e 100644
--- a/drivers/infiniband/hw/nes/nes_verbs.c
+++ b/drivers/infiniband/hw/nes/nes_verbs.c
@@ -55,7 +55,6 @@ static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
55 * nes_alloc_mw 55 * nes_alloc_mw
56 */ 56 */
57static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) { 57static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
58 unsigned long flags;
59 struct nes_pd *nespd = to_nespd(ibpd); 58 struct nes_pd *nespd = to_nespd(ibpd);
60 struct nes_vnic *nesvnic = to_nesvnic(ibpd->device); 59 struct nes_vnic *nesvnic = to_nesvnic(ibpd->device);
61 struct nes_device *nesdev = nesvnic->nesdev; 60 struct nes_device *nesdev = nesvnic->nesdev;
@@ -119,7 +118,7 @@ static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
119 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, stag); 118 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, stag);
120 119
121 atomic_set(&cqp_request->refcount, 2); 120 atomic_set(&cqp_request->refcount, 2);
122 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 121 nes_post_cqp_request(nesdev, cqp_request);
123 122
124 /* Wait for CQP */ 123 /* Wait for CQP */
125 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0), 124 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0),
@@ -128,15 +127,7 @@ static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
128 " CQP Major:Minor codes = 0x%04X:0x%04X.\n", 127 " CQP Major:Minor codes = 0x%04X:0x%04X.\n",
129 stag, ret, cqp_request->major_code, cqp_request->minor_code); 128 stag, ret, cqp_request->major_code, cqp_request->minor_code);
130 if ((!ret) || (cqp_request->major_code)) { 129 if ((!ret) || (cqp_request->major_code)) {
131 if (atomic_dec_and_test(&cqp_request->refcount)) { 130 nes_put_cqp_request(nesdev, cqp_request);
132 if (cqp_request->dynamic) {
133 kfree(cqp_request);
134 } else {
135 spin_lock_irqsave(&nesdev->cqp.lock, flags);
136 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
137 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
138 }
139 }
140 kfree(nesmr); 131 kfree(nesmr);
141 nes_free_resource(nesadapter, nesadapter->allocated_mrs, stag_index); 132 nes_free_resource(nesadapter, nesadapter->allocated_mrs, stag_index);
142 if (!ret) { 133 if (!ret) {
@@ -144,17 +135,8 @@ static struct ib_mw *nes_alloc_mw(struct ib_pd *ibpd) {
144 } else { 135 } else {
145 return ERR_PTR(-ENOMEM); 136 return ERR_PTR(-ENOMEM);
146 } 137 }
147 } else {
148 if (atomic_dec_and_test(&cqp_request->refcount)) {
149 if (cqp_request->dynamic) {
150 kfree(cqp_request);
151 } else {
152 spin_lock_irqsave(&nesdev->cqp.lock, flags);
153 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
154 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
155 }
156 }
157 } 138 }
139 nes_put_cqp_request(nesdev, cqp_request);
158 140
159 nesmr->ibmw.rkey = stag; 141 nesmr->ibmw.rkey = stag;
160 nesmr->mode = IWNES_MEMREG_TYPE_MW; 142 nesmr->mode = IWNES_MEMREG_TYPE_MW;
@@ -178,7 +160,6 @@ static int nes_dealloc_mw(struct ib_mw *ibmw)
178 struct nes_hw_cqp_wqe *cqp_wqe; 160 struct nes_hw_cqp_wqe *cqp_wqe;
179 struct nes_cqp_request *cqp_request; 161 struct nes_cqp_request *cqp_request;
180 int err = 0; 162 int err = 0;
181 unsigned long flags;
182 int ret; 163 int ret;
183 164
184 /* Deallocate the window with the adapter */ 165 /* Deallocate the window with the adapter */
@@ -194,7 +175,7 @@ static int nes_dealloc_mw(struct ib_mw *ibmw)
194 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, ibmw->rkey); 175 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, ibmw->rkey);
195 176
196 atomic_set(&cqp_request->refcount, 2); 177 atomic_set(&cqp_request->refcount, 2);
197 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 178 nes_post_cqp_request(nesdev, cqp_request);
198 179
199 /* Wait for CQP */ 180 /* Wait for CQP */
200 nes_debug(NES_DBG_MR, "Waiting for deallocate STag 0x%08X to complete.\n", 181 nes_debug(NES_DBG_MR, "Waiting for deallocate STag 0x%08X to complete.\n",
@@ -204,32 +185,12 @@ static int nes_dealloc_mw(struct ib_mw *ibmw)
204 nes_debug(NES_DBG_MR, "Deallocate STag completed, wait_event_timeout ret = %u," 185 nes_debug(NES_DBG_MR, "Deallocate STag completed, wait_event_timeout ret = %u,"
205 " CQP Major:Minor codes = 0x%04X:0x%04X.\n", 186 " CQP Major:Minor codes = 0x%04X:0x%04X.\n",
206 ret, cqp_request->major_code, cqp_request->minor_code); 187 ret, cqp_request->major_code, cqp_request->minor_code);
207 if ((!ret) || (cqp_request->major_code)) { 188 if (!ret)
208 if (atomic_dec_and_test(&cqp_request->refcount)) { 189 err = -ETIME;
209 if (cqp_request->dynamic) { 190 else if (cqp_request->major_code)
210 kfree(cqp_request); 191 err = -EIO;
211 } else { 192
212 spin_lock_irqsave(&nesdev->cqp.lock, flags); 193 nes_put_cqp_request(nesdev, cqp_request);
213 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
214 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
215 }
216 }
217 if (!ret) {
218 err = -ETIME;
219 } else {
220 err = -EIO;
221 }
222 } else {
223 if (atomic_dec_and_test(&cqp_request->refcount)) {
224 if (cqp_request->dynamic) {
225 kfree(cqp_request);
226 } else {
227 spin_lock_irqsave(&nesdev->cqp.lock, flags);
228 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
229 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
230 }
231 }
232 }
233 194
234 nes_free_resource(nesadapter, nesadapter->allocated_mrs, 195 nes_free_resource(nesadapter, nesadapter->allocated_mrs,
235 (ibmw->rkey & 0x0fffff00) >> 8); 196 (ibmw->rkey & 0x0fffff00) >> 8);
@@ -516,7 +477,7 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd,
516 (nesfmr->nesmr.pbls_used-1) : nesfmr->nesmr.pbls_used); 477 (nesfmr->nesmr.pbls_used-1) : nesfmr->nesmr.pbls_used);
517 478
518 atomic_set(&cqp_request->refcount, 2); 479 atomic_set(&cqp_request->refcount, 2);
519 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 480 nes_post_cqp_request(nesdev, cqp_request);
520 481
521 /* Wait for CQP */ 482 /* Wait for CQP */
522 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0), 483 ret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0),
@@ -526,29 +487,11 @@ static struct ib_fmr *nes_alloc_fmr(struct ib_pd *ibpd,
526 stag, ret, cqp_request->major_code, cqp_request->minor_code); 487 stag, ret, cqp_request->major_code, cqp_request->minor_code);
527 488
528 if ((!ret) || (cqp_request->major_code)) { 489 if ((!ret) || (cqp_request->major_code)) {
529 if (atomic_dec_and_test(&cqp_request->refcount)) { 490 nes_put_cqp_request(nesdev, cqp_request);
530 if (cqp_request->dynamic) {
531 kfree(cqp_request);
532 } else {
533 spin_lock_irqsave(&nesdev->cqp.lock, flags);
534 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
535 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
536 }
537 }
538 ret = (!ret) ? -ETIME : -EIO; 491 ret = (!ret) ? -ETIME : -EIO;
539 goto failed_leaf_vpbl_pages_alloc; 492 goto failed_leaf_vpbl_pages_alloc;
540 } else {
541 if (atomic_dec_and_test(&cqp_request->refcount)) {
542 if (cqp_request->dynamic) {
543 kfree(cqp_request);
544 } else {
545 spin_lock_irqsave(&nesdev->cqp.lock, flags);
546 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
547 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
548 }
549 }
550 } 493 }
551 494 nes_put_cqp_request(nesdev, cqp_request);
552 nesfmr->nesmr.ibfmr.lkey = stag; 495 nesfmr->nesmr.ibfmr.lkey = stag;
553 nesfmr->nesmr.ibfmr.rkey = stag; 496 nesfmr->nesmr.ibfmr.rkey = stag;
554 nesfmr->attr = *ibfmr_attr; 497 nesfmr->attr = *ibfmr_attr;
@@ -1474,7 +1417,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1474 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, u64temp); 1417 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, u64temp);
1475 1418
1476 atomic_set(&cqp_request->refcount, 2); 1419 atomic_set(&cqp_request->refcount, 2);
1477 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 1420 nes_post_cqp_request(nesdev, cqp_request);
1478 1421
1479 /* Wait for CQP */ 1422 /* Wait for CQP */
1480 nes_debug(NES_DBG_QP, "Waiting for create iWARP QP%u to complete.\n", 1423 nes_debug(NES_DBG_QP, "Waiting for create iWARP QP%u to complete.\n",
@@ -1487,15 +1430,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1487 nesqp->hwqp.qp_id, ret, nesdev->cqp.sq_head, nesdev->cqp.sq_tail, 1430 nesqp->hwqp.qp_id, ret, nesdev->cqp.sq_head, nesdev->cqp.sq_tail,
1488 cqp_request->major_code, cqp_request->minor_code); 1431 cqp_request->major_code, cqp_request->minor_code);
1489 if ((!ret) || (cqp_request->major_code)) { 1432 if ((!ret) || (cqp_request->major_code)) {
1490 if (atomic_dec_and_test(&cqp_request->refcount)) { 1433 nes_put_cqp_request(nesdev, cqp_request);
1491 if (cqp_request->dynamic) {
1492 kfree(cqp_request);
1493 } else {
1494 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1495 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1496 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1497 }
1498 }
1499 nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num); 1434 nes_free_resource(nesadapter, nesadapter->allocated_qps, qp_num);
1500 nes_free_qp_mem(nesdev, nesqp,virt_wqs); 1435 nes_free_qp_mem(nesdev, nesqp,virt_wqs);
1501 kfree(nesqp->allocated_buffer); 1436 kfree(nesqp->allocated_buffer);
@@ -1504,18 +1439,10 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
1504 } else { 1439 } else {
1505 return ERR_PTR(-EIO); 1440 return ERR_PTR(-EIO);
1506 } 1441 }
1507 } else {
1508 if (atomic_dec_and_test(&cqp_request->refcount)) {
1509 if (cqp_request->dynamic) {
1510 kfree(cqp_request);
1511 } else {
1512 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1513 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1514 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1515 }
1516 }
1517 } 1442 }
1518 1443
1444 nes_put_cqp_request(nesdev, cqp_request);
1445
1519 if (ibpd->uobject) { 1446 if (ibpd->uobject) {
1520 uresp.mmap_sq_db_index = nesqp->mmap_sq_db_index; 1447 uresp.mmap_sq_db_index = nesqp->mmap_sq_db_index;
1521 uresp.actual_sq_size = sq_size; 1448 uresp.actual_sq_size = sq_size;
@@ -1817,7 +1744,7 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1817 cpu_to_le32(((u32)((u64temp) >> 33)) & 0x7FFFFFFF); 1744 cpu_to_le32(((u32)((u64temp) >> 33)) & 0x7FFFFFFF);
1818 1745
1819 atomic_set(&cqp_request->refcount, 2); 1746 atomic_set(&cqp_request->refcount, 2);
1820 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 1747 nes_post_cqp_request(nesdev, cqp_request);
1821 1748
1822 /* Wait for CQP */ 1749 /* Wait for CQP */
1823 nes_debug(NES_DBG_CQ, "Waiting for create iWARP CQ%u to complete.\n", 1750 nes_debug(NES_DBG_CQ, "Waiting for create iWARP CQ%u to complete.\n",
@@ -1827,32 +1754,15 @@ static struct ib_cq *nes_create_cq(struct ib_device *ibdev, int entries,
1827 nes_debug(NES_DBG_CQ, "Create iWARP CQ%u completed, wait_event_timeout ret = %d.\n", 1754 nes_debug(NES_DBG_CQ, "Create iWARP CQ%u completed, wait_event_timeout ret = %d.\n",
1828 nescq->hw_cq.cq_number, ret); 1755 nescq->hw_cq.cq_number, ret);
1829 if ((!ret) || (cqp_request->major_code)) { 1756 if ((!ret) || (cqp_request->major_code)) {
1830 if (atomic_dec_and_test(&cqp_request->refcount)) { 1757 nes_put_cqp_request(nesdev, cqp_request);
1831 if (cqp_request->dynamic) {
1832 kfree(cqp_request);
1833 } else {
1834 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1835 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1836 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1837 }
1838 }
1839 if (!context) 1758 if (!context)
1840 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem, 1759 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, mem,
1841 nescq->hw_cq.cq_pbase); 1760 nescq->hw_cq.cq_pbase);
1842 nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num); 1761 nes_free_resource(nesadapter, nesadapter->allocated_cqs, cq_num);
1843 kfree(nescq); 1762 kfree(nescq);
1844 return ERR_PTR(-EIO); 1763 return ERR_PTR(-EIO);
1845 } else {
1846 if (atomic_dec_and_test(&cqp_request->refcount)) {
1847 if (cqp_request->dynamic) {
1848 kfree(cqp_request);
1849 } else {
1850 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1851 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1852 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1853 }
1854 }
1855 } 1764 }
1765 nes_put_cqp_request(nesdev, cqp_request);
1856 1766
1857 if (context) { 1767 if (context) {
1858 /* free the nespbl */ 1768 /* free the nespbl */
@@ -1931,7 +1841,7 @@ static int nes_destroy_cq(struct ib_cq *ib_cq)
1931 (nescq->hw_cq.cq_number | ((u32)PCI_FUNC(nesdev->pcidev->devfn) << 16))); 1841 (nescq->hw_cq.cq_number | ((u32)PCI_FUNC(nesdev->pcidev->devfn) << 16)));
1932 nes_free_resource(nesadapter, nesadapter->allocated_cqs, nescq->hw_cq.cq_number); 1842 nes_free_resource(nesadapter, nesadapter->allocated_cqs, nescq->hw_cq.cq_number);
1933 atomic_set(&cqp_request->refcount, 2); 1843 atomic_set(&cqp_request->refcount, 2);
1934 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 1844 nes_post_cqp_request(nesdev, cqp_request);
1935 1845
1936 /* Wait for CQP */ 1846 /* Wait for CQP */
1937 nes_debug(NES_DBG_CQ, "Waiting for destroy iWARP CQ%u to complete.\n", 1847 nes_debug(NES_DBG_CQ, "Waiting for destroy iWARP CQ%u to complete.\n",
@@ -1942,37 +1852,18 @@ static int nes_destroy_cq(struct ib_cq *ib_cq)
1942 " CQP Major:Minor codes = 0x%04X:0x%04X.\n", 1852 " CQP Major:Minor codes = 0x%04X:0x%04X.\n",
1943 nescq->hw_cq.cq_number, ret, cqp_request->major_code, 1853 nescq->hw_cq.cq_number, ret, cqp_request->major_code,
1944 cqp_request->minor_code); 1854 cqp_request->minor_code);
1945 if ((!ret) || (cqp_request->major_code)) { 1855 if (!ret) {
1946 if (atomic_dec_and_test(&cqp_request->refcount)) { 1856 nes_debug(NES_DBG_CQ, "iWARP CQ%u destroy timeout expired\n",
1947 if (cqp_request->dynamic) {
1948 kfree(cqp_request);
1949 } else {
1950 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1951 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1952 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1953 }
1954 }
1955 if (!ret) {
1956 nes_debug(NES_DBG_CQ, "iWARP CQ%u destroy timeout expired\n",
1957 nescq->hw_cq.cq_number); 1857 nescq->hw_cq.cq_number);
1958 ret = -ETIME; 1858 ret = -ETIME;
1959 } else { 1859 } else if (cqp_request->major_code) {
1960 nes_debug(NES_DBG_CQ, "iWARP CQ%u destroy failed\n", 1860 nes_debug(NES_DBG_CQ, "iWARP CQ%u destroy failed\n",
1961 nescq->hw_cq.cq_number); 1861 nescq->hw_cq.cq_number);
1962 ret = -EIO; 1862 ret = -EIO;
1963 }
1964 } else { 1863 } else {
1965 ret = 0; 1864 ret = 0;
1966 if (atomic_dec_and_test(&cqp_request->refcount)) {
1967 if (cqp_request->dynamic) {
1968 kfree(cqp_request);
1969 } else {
1970 spin_lock_irqsave(&nesdev->cqp.lock, flags);
1971 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
1972 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
1973 }
1974 }
1975 } 1865 }
1866 nes_put_cqp_request(nesdev, cqp_request);
1976 1867
1977 if (nescq->cq_mem_size) 1868 if (nescq->cq_mem_size)
1978 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size, 1869 pci_free_consistent(nesdev->pcidev, nescq->cq_mem_size,
@@ -2096,7 +1987,7 @@ static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd,
2096 barrier(); 1987 barrier();
2097 1988
2098 atomic_set(&cqp_request->refcount, 2); 1989 atomic_set(&cqp_request->refcount, 2);
2099 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 1990 nes_post_cqp_request(nesdev, cqp_request);
2100 1991
2101 /* Wait for CQP */ 1992 /* Wait for CQP */
2102 ret = wait_event_timeout(cqp_request->waitq, (0 != cqp_request->request_done), 1993 ret = wait_event_timeout(cqp_request->waitq, (0 != cqp_request->request_done),
@@ -2105,15 +1996,8 @@ static int nes_reg_mr(struct nes_device *nesdev, struct nes_pd *nespd,
2105 " CQP Major:Minor codes = 0x%04X:0x%04X.\n", 1996 " CQP Major:Minor codes = 0x%04X:0x%04X.\n",
2106 stag, ret, cqp_request->major_code, cqp_request->minor_code); 1997 stag, ret, cqp_request->major_code, cqp_request->minor_code);
2107 major_code = cqp_request->major_code; 1998 major_code = cqp_request->major_code;
2108 if (atomic_dec_and_test(&cqp_request->refcount)) { 1999 nes_put_cqp_request(nesdev, cqp_request);
2109 if (cqp_request->dynamic) { 2000
2110 kfree(cqp_request);
2111 } else {
2112 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2113 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2114 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2115 }
2116 }
2117 if (!ret) 2001 if (!ret)
2118 return -ETIME; 2002 return -ETIME;
2119 else if (major_code) 2003 else if (major_code)
@@ -2754,7 +2638,7 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
2754 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, ib_mr->rkey); 2638 set_wqe_32bit_value(cqp_wqe->wqe_words, NES_CQP_STAG_WQE_STAG_IDX, ib_mr->rkey);
2755 2639
2756 atomic_set(&cqp_request->refcount, 2); 2640 atomic_set(&cqp_request->refcount, 2);
2757 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 2641 nes_post_cqp_request(nesdev, cqp_request);
2758 2642
2759 /* Wait for CQP */ 2643 /* Wait for CQP */
2760 nes_debug(NES_DBG_MR, "Waiting for deallocate STag 0x%08X completed\n", ib_mr->rkey); 2644 nes_debug(NES_DBG_MR, "Waiting for deallocate STag 0x%08X completed\n", ib_mr->rkey);
@@ -2771,15 +2655,9 @@ static int nes_dereg_mr(struct ib_mr *ib_mr)
2771 2655
2772 major_code = cqp_request->major_code; 2656 major_code = cqp_request->major_code;
2773 minor_code = cqp_request->minor_code; 2657 minor_code = cqp_request->minor_code;
2774 if (atomic_dec_and_test(&cqp_request->refcount)) { 2658
2775 if (cqp_request->dynamic) { 2659 nes_put_cqp_request(nesdev, cqp_request);
2776 kfree(cqp_request); 2660
2777 } else {
2778 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2779 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2780 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2781 }
2782 }
2783 if (!ret) { 2661 if (!ret) {
2784 nes_debug(NES_DBG_MR, "Timeout waiting to destroy STag," 2662 nes_debug(NES_DBG_MR, "Timeout waiting to destroy STag,"
2785 " ib_mr=%p, rkey = 0x%08X\n", 2663 " ib_mr=%p, rkey = 0x%08X\n",
@@ -2904,7 +2782,6 @@ int nes_hw_modify_qp(struct nes_device *nesdev, struct nes_qp *nesqp,
2904 /* struct iw_cm_id *cm_id = nesqp->cm_id; */ 2782 /* struct iw_cm_id *cm_id = nesqp->cm_id; */
2905 /* struct iw_cm_event cm_event; */ 2783 /* struct iw_cm_event cm_event; */
2906 struct nes_cqp_request *cqp_request; 2784 struct nes_cqp_request *cqp_request;
2907 unsigned long flags;
2908 int ret; 2785 int ret;
2909 u16 major_code; 2786 u16 major_code;
2910 2787
@@ -2932,7 +2809,7 @@ int nes_hw_modify_qp(struct nes_device *nesdev, struct nes_qp *nesqp,
2932 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, (u64)nesqp->nesqp_context_pbase); 2809 set_wqe_64bit_value(cqp_wqe->wqe_words, NES_CQP_QP_WQE_CONTEXT_LOW_IDX, (u64)nesqp->nesqp_context_pbase);
2933 2810
2934 atomic_set(&cqp_request->refcount, 2); 2811 atomic_set(&cqp_request->refcount, 2);
2935 nes_post_cqp_request(nesdev, cqp_request, NES_CQP_REQUEST_RING_DOORBELL); 2812 nes_post_cqp_request(nesdev, cqp_request);
2936 2813
2937 /* Wait for CQP */ 2814 /* Wait for CQP */
2938 if (wait_completion) { 2815 if (wait_completion) {
@@ -2950,15 +2827,9 @@ int nes_hw_modify_qp(struct nes_device *nesdev, struct nes_qp *nesqp,
2950 nesqp->hwqp.qp_id, cqp_request->major_code, 2827 nesqp->hwqp.qp_id, cqp_request->major_code,
2951 cqp_request->minor_code, next_iwarp_state); 2828 cqp_request->minor_code, next_iwarp_state);
2952 } 2829 }
2953 if (atomic_dec_and_test(&cqp_request->refcount)) { 2830
2954 if (cqp_request->dynamic) { 2831 nes_put_cqp_request(nesdev, cqp_request);
2955 kfree(cqp_request); 2832
2956 } else {
2957 spin_lock_irqsave(&nesdev->cqp.lock, flags);
2958 list_add_tail(&cqp_request->list, &nesdev->cqp_avail_reqs);
2959 spin_unlock_irqrestore(&nesdev->cqp.lock, flags);
2960 }
2961 }
2962 if (!ret) 2833 if (!ret)
2963 return -ETIME; 2834 return -ETIME;
2964 else if (major_code) 2835 else if (major_code)
diff --git a/drivers/infiniband/ulp/ipoib/Kconfig b/drivers/infiniband/ulp/ipoib/Kconfig
index 1f76bad020f3..691525cf394a 100644
--- a/drivers/infiniband/ulp/ipoib/Kconfig
+++ b/drivers/infiniband/ulp/ipoib/Kconfig
@@ -1,6 +1,7 @@
1config INFINIBAND_IPOIB 1config INFINIBAND_IPOIB
2 tristate "IP-over-InfiniBand" 2 tristate "IP-over-InfiniBand"
3 depends on NETDEVICES && INET && (IPV6 || IPV6=n) 3 depends on NETDEVICES && INET && (IPV6 || IPV6=n)
4 select INET_LRO
4 ---help--- 5 ---help---
5 Support for the IP-over-InfiniBand protocol (IPoIB). This 6 Support for the IP-over-InfiniBand protocol (IPoIB). This
6 transports IP packets over InfiniBand so you can use your IB 7 transports IP packets over InfiniBand so you can use your IB
diff --git a/drivers/infiniband/ulp/ipoib/ipoib.h b/drivers/infiniband/ulp/ipoib/ipoib.h
index ca126fc2b853..b0ffc9abe8c0 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib.h
+++ b/drivers/infiniband/ulp/ipoib/ipoib.h
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: ipoib.h 1358 2004-12-17 22:00:11Z roland $
35 */ 33 */
36 34
37#ifndef _IPOIB_H 35#ifndef _IPOIB_H
@@ -52,9 +50,16 @@
52#include <rdma/ib_verbs.h> 50#include <rdma/ib_verbs.h>
53#include <rdma/ib_pack.h> 51#include <rdma/ib_pack.h>
54#include <rdma/ib_sa.h> 52#include <rdma/ib_sa.h>
53#include <linux/inet_lro.h>
55 54
56/* constants */ 55/* constants */
57 56
57enum ipoib_flush_level {
58 IPOIB_FLUSH_LIGHT,
59 IPOIB_FLUSH_NORMAL,
60 IPOIB_FLUSH_HEAVY
61};
62
58enum { 63enum {
59 IPOIB_ENCAP_LEN = 4, 64 IPOIB_ENCAP_LEN = 4,
60 65
@@ -65,8 +70,8 @@ enum {
65 IPOIB_CM_BUF_SIZE = IPOIB_CM_MTU + IPOIB_ENCAP_LEN, 70 IPOIB_CM_BUF_SIZE = IPOIB_CM_MTU + IPOIB_ENCAP_LEN,
66 IPOIB_CM_HEAD_SIZE = IPOIB_CM_BUF_SIZE % PAGE_SIZE, 71 IPOIB_CM_HEAD_SIZE = IPOIB_CM_BUF_SIZE % PAGE_SIZE,
67 IPOIB_CM_RX_SG = ALIGN(IPOIB_CM_BUF_SIZE, PAGE_SIZE) / PAGE_SIZE, 72 IPOIB_CM_RX_SG = ALIGN(IPOIB_CM_BUF_SIZE, PAGE_SIZE) / PAGE_SIZE,
68 IPOIB_RX_RING_SIZE = 128, 73 IPOIB_RX_RING_SIZE = 256,
69 IPOIB_TX_RING_SIZE = 64, 74 IPOIB_TX_RING_SIZE = 128,
70 IPOIB_MAX_QUEUE_SIZE = 8192, 75 IPOIB_MAX_QUEUE_SIZE = 8192,
71 IPOIB_MIN_QUEUE_SIZE = 2, 76 IPOIB_MIN_QUEUE_SIZE = 2,
72 IPOIB_CM_MAX_CONN_QP = 4096, 77 IPOIB_CM_MAX_CONN_QP = 4096,
@@ -84,7 +89,6 @@ enum {
84 IPOIB_FLAG_SUBINTERFACE = 5, 89 IPOIB_FLAG_SUBINTERFACE = 5,
85 IPOIB_MCAST_RUN = 6, 90 IPOIB_MCAST_RUN = 6,
86 IPOIB_STOP_REAPER = 7, 91 IPOIB_STOP_REAPER = 7,
87 IPOIB_MCAST_STARTED = 8,
88 IPOIB_FLAG_ADMIN_CM = 9, 92 IPOIB_FLAG_ADMIN_CM = 9,
89 IPOIB_FLAG_UMCAST = 10, 93 IPOIB_FLAG_UMCAST = 10,
90 IPOIB_FLAG_CSUM = 11, 94 IPOIB_FLAG_CSUM = 11,
@@ -96,7 +100,11 @@ enum {
96 IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */ 100 IPOIB_MCAST_FLAG_BUSY = 2, /* joining or already joined */
97 IPOIB_MCAST_FLAG_ATTACHED = 3, 101 IPOIB_MCAST_FLAG_ATTACHED = 3,
98 102
103 IPOIB_MAX_LRO_DESCRIPTORS = 8,
104 IPOIB_LRO_MAX_AGGR = 64,
105
99 MAX_SEND_CQE = 16, 106 MAX_SEND_CQE = 16,
107 IPOIB_CM_COPYBREAK = 256,
100}; 108};
101 109
102#define IPOIB_OP_RECV (1ul << 31) 110#define IPOIB_OP_RECV (1ul << 31)
@@ -149,6 +157,11 @@ struct ipoib_tx_buf {
149 u64 mapping[MAX_SKB_FRAGS + 1]; 157 u64 mapping[MAX_SKB_FRAGS + 1];
150}; 158};
151 159
160struct ipoib_cm_tx_buf {
161 struct sk_buff *skb;
162 u64 mapping;
163};
164
152struct ib_cm_id; 165struct ib_cm_id;
153 166
154struct ipoib_cm_data { 167struct ipoib_cm_data {
@@ -207,7 +220,7 @@ struct ipoib_cm_tx {
207 struct net_device *dev; 220 struct net_device *dev;
208 struct ipoib_neigh *neigh; 221 struct ipoib_neigh *neigh;
209 struct ipoib_path *path; 222 struct ipoib_path *path;
210 struct ipoib_tx_buf *tx_ring; 223 struct ipoib_cm_tx_buf *tx_ring;
211 unsigned tx_head; 224 unsigned tx_head;
212 unsigned tx_tail; 225 unsigned tx_tail;
213 unsigned long flags; 226 unsigned long flags;
@@ -249,6 +262,11 @@ struct ipoib_ethtool_st {
249 u16 max_coalesced_frames; 262 u16 max_coalesced_frames;
250}; 263};
251 264
265struct ipoib_lro {
266 struct net_lro_mgr lro_mgr;
267 struct net_lro_desc lro_desc[IPOIB_MAX_LRO_DESCRIPTORS];
268};
269
252/* 270/*
253 * Device private locking: tx_lock protects members used in TX fast 271 * Device private locking: tx_lock protects members used in TX fast
254 * path (and we use LLTX so upper layers don't do extra locking). 272 * path (and we use LLTX so upper layers don't do extra locking).
@@ -264,7 +282,6 @@ struct ipoib_dev_priv {
264 282
265 unsigned long flags; 283 unsigned long flags;
266 284
267 struct mutex mcast_mutex;
268 struct mutex vlan_mutex; 285 struct mutex vlan_mutex;
269 286
270 struct rb_root path_tree; 287 struct rb_root path_tree;
@@ -276,10 +293,11 @@ struct ipoib_dev_priv {
276 293
277 struct delayed_work pkey_poll_task; 294 struct delayed_work pkey_poll_task;
278 struct delayed_work mcast_task; 295 struct delayed_work mcast_task;
279 struct work_struct flush_task; 296 struct work_struct flush_light;
297 struct work_struct flush_normal;
298 struct work_struct flush_heavy;
280 struct work_struct restart_task; 299 struct work_struct restart_task;
281 struct delayed_work ah_reap_task; 300 struct delayed_work ah_reap_task;
282 struct work_struct pkey_event_task;
283 301
284 struct ib_device *ca; 302 struct ib_device *ca;
285 u8 port; 303 u8 port;
@@ -335,6 +353,8 @@ struct ipoib_dev_priv {
335 int hca_caps; 353 int hca_caps;
336 struct ipoib_ethtool_st ethtool; 354 struct ipoib_ethtool_st ethtool;
337 struct timer_list poll_timer; 355 struct timer_list poll_timer;
356
357 struct ipoib_lro lro;
338}; 358};
339 359
340struct ipoib_ah { 360struct ipoib_ah {
@@ -359,6 +379,7 @@ struct ipoib_path {
359 379
360 struct rb_node rb_node; 380 struct rb_node rb_node;
361 struct list_head list; 381 struct list_head list;
382 int valid;
362}; 383};
363 384
364struct ipoib_neigh { 385struct ipoib_neigh {
@@ -423,11 +444,14 @@ void ipoib_send(struct net_device *dev, struct sk_buff *skb,
423 struct ipoib_ah *address, u32 qpn); 444 struct ipoib_ah *address, u32 qpn);
424void ipoib_reap_ah(struct work_struct *work); 445void ipoib_reap_ah(struct work_struct *work);
425 446
447void ipoib_mark_paths_invalid(struct net_device *dev);
426void ipoib_flush_paths(struct net_device *dev); 448void ipoib_flush_paths(struct net_device *dev);
427struct ipoib_dev_priv *ipoib_intf_alloc(const char *format); 449struct ipoib_dev_priv *ipoib_intf_alloc(const char *format);
428 450
429int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port); 451int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port);
430void ipoib_ib_dev_flush(struct work_struct *work); 452void ipoib_ib_dev_flush_light(struct work_struct *work);
453void ipoib_ib_dev_flush_normal(struct work_struct *work);
454void ipoib_ib_dev_flush_heavy(struct work_struct *work);
431void ipoib_pkey_event(struct work_struct *work); 455void ipoib_pkey_event(struct work_struct *work);
432void ipoib_ib_dev_cleanup(struct net_device *dev); 456void ipoib_ib_dev_cleanup(struct net_device *dev);
433 457
@@ -466,9 +490,7 @@ void ipoib_path_iter_read(struct ipoib_path_iter *iter,
466#endif 490#endif
467 491
468int ipoib_mcast_attach(struct net_device *dev, u16 mlid, 492int ipoib_mcast_attach(struct net_device *dev, u16 mlid,
469 union ib_gid *mgid); 493 union ib_gid *mgid, int set_qkey);
470int ipoib_mcast_detach(struct net_device *dev, u16 mlid,
471 union ib_gid *mgid);
472 494
473int ipoib_init_qp(struct net_device *dev); 495int ipoib_init_qp(struct net_device *dev);
474int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca); 496int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca);
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
index 97e67d36378f..0f2d3045061a 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id$
33 */ 31 */
34 32
35#include <rdma/ib_cm.h> 33#include <rdma/ib_cm.h>
@@ -113,18 +111,20 @@ static int ipoib_cm_post_receive_srq(struct net_device *dev, int id)
113} 111}
114 112
115static int ipoib_cm_post_receive_nonsrq(struct net_device *dev, 113static int ipoib_cm_post_receive_nonsrq(struct net_device *dev,
116 struct ipoib_cm_rx *rx, int id) 114 struct ipoib_cm_rx *rx,
115 struct ib_recv_wr *wr,
116 struct ib_sge *sge, int id)
117{ 117{
118 struct ipoib_dev_priv *priv = netdev_priv(dev); 118 struct ipoib_dev_priv *priv = netdev_priv(dev);
119 struct ib_recv_wr *bad_wr; 119 struct ib_recv_wr *bad_wr;
120 int i, ret; 120 int i, ret;
121 121
122 priv->cm.rx_wr.wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV; 122 wr->wr_id = id | IPOIB_OP_CM | IPOIB_OP_RECV;
123 123
124 for (i = 0; i < IPOIB_CM_RX_SG; ++i) 124 for (i = 0; i < IPOIB_CM_RX_SG; ++i)
125 priv->cm.rx_sge[i].addr = rx->rx_ring[id].mapping[i]; 125 sge[i].addr = rx->rx_ring[id].mapping[i];
126 126
127 ret = ib_post_recv(rx->qp, &priv->cm.rx_wr, &bad_wr); 127 ret = ib_post_recv(rx->qp, wr, &bad_wr);
128 if (unlikely(ret)) { 128 if (unlikely(ret)) {
129 ipoib_warn(priv, "post recv failed for buf %d (%d)\n", id, ret); 129 ipoib_warn(priv, "post recv failed for buf %d (%d)\n", id, ret);
130 ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1, 130 ipoib_cm_dma_unmap_rx(priv, IPOIB_CM_RX_SG - 1,
@@ -322,10 +322,33 @@ static int ipoib_cm_modify_rx_qp(struct net_device *dev,
322 return 0; 322 return 0;
323} 323}
324 324
325static void ipoib_cm_init_rx_wr(struct net_device *dev,
326 struct ib_recv_wr *wr,
327 struct ib_sge *sge)
328{
329 struct ipoib_dev_priv *priv = netdev_priv(dev);
330 int i;
331
332 for (i = 0; i < priv->cm.num_frags; ++i)
333 sge[i].lkey = priv->mr->lkey;
334
335 sge[0].length = IPOIB_CM_HEAD_SIZE;
336 for (i = 1; i < priv->cm.num_frags; ++i)
337 sge[i].length = PAGE_SIZE;
338
339 wr->next = NULL;
340 wr->sg_list = priv->cm.rx_sge;
341 wr->num_sge = priv->cm.num_frags;
342}
343
325static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_id, 344static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_id,
326 struct ipoib_cm_rx *rx) 345 struct ipoib_cm_rx *rx)
327{ 346{
328 struct ipoib_dev_priv *priv = netdev_priv(dev); 347 struct ipoib_dev_priv *priv = netdev_priv(dev);
348 struct {
349 struct ib_recv_wr wr;
350 struct ib_sge sge[IPOIB_CM_RX_SG];
351 } *t;
329 int ret; 352 int ret;
330 int i; 353 int i;
331 354
@@ -333,6 +356,14 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
333 if (!rx->rx_ring) 356 if (!rx->rx_ring)
334 return -ENOMEM; 357 return -ENOMEM;
335 358
359 t = kmalloc(sizeof *t, GFP_KERNEL);
360 if (!t) {
361 ret = -ENOMEM;
362 goto err_free;
363 }
364
365 ipoib_cm_init_rx_wr(dev, &t->wr, t->sge);
366
336 spin_lock_irq(&priv->lock); 367 spin_lock_irq(&priv->lock);
337 368
338 if (priv->cm.nonsrq_conn_qp >= ipoib_max_conn_qp) { 369 if (priv->cm.nonsrq_conn_qp >= ipoib_max_conn_qp) {
@@ -351,8 +382,8 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
351 ipoib_warn(priv, "failed to allocate receive buffer %d\n", i); 382 ipoib_warn(priv, "failed to allocate receive buffer %d\n", i);
352 ret = -ENOMEM; 383 ret = -ENOMEM;
353 goto err_count; 384 goto err_count;
354 } 385 }
355 ret = ipoib_cm_post_receive_nonsrq(dev, rx, i); 386 ret = ipoib_cm_post_receive_nonsrq(dev, rx, &t->wr, t->sge, i);
356 if (ret) { 387 if (ret) {
357 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq " 388 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq "
358 "failed for buf %d\n", i); 389 "failed for buf %d\n", i);
@@ -363,6 +394,8 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
363 394
364 rx->recv_count = ipoib_recvq_size; 395 rx->recv_count = ipoib_recvq_size;
365 396
397 kfree(t);
398
366 return 0; 399 return 0;
367 400
368err_count: 401err_count:
@@ -371,6 +404,7 @@ err_count:
371 spin_unlock_irq(&priv->lock); 404 spin_unlock_irq(&priv->lock);
372 405
373err_free: 406err_free:
407 kfree(t);
374 ipoib_cm_free_rx_ring(dev, rx->rx_ring); 408 ipoib_cm_free_rx_ring(dev, rx->rx_ring);
375 409
376 return ret; 410 return ret;
@@ -525,6 +559,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
525 u64 mapping[IPOIB_CM_RX_SG]; 559 u64 mapping[IPOIB_CM_RX_SG];
526 int frags; 560 int frags;
527 int has_srq; 561 int has_srq;
562 struct sk_buff *small_skb;
528 563
529 ipoib_dbg_data(priv, "cm recv completion: id %d, status: %d\n", 564 ipoib_dbg_data(priv, "cm recv completion: id %d, status: %d\n",
530 wr_id, wc->status); 565 wr_id, wc->status);
@@ -579,6 +614,23 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
579 } 614 }
580 } 615 }
581 616
617 if (wc->byte_len < IPOIB_CM_COPYBREAK) {
618 int dlen = wc->byte_len;
619
620 small_skb = dev_alloc_skb(dlen + 12);
621 if (small_skb) {
622 skb_reserve(small_skb, 12);
623 ib_dma_sync_single_for_cpu(priv->ca, rx_ring[wr_id].mapping[0],
624 dlen, DMA_FROM_DEVICE);
625 skb_copy_from_linear_data(skb, small_skb->data, dlen);
626 ib_dma_sync_single_for_device(priv->ca, rx_ring[wr_id].mapping[0],
627 dlen, DMA_FROM_DEVICE);
628 skb_put(small_skb, dlen);
629 skb = small_skb;
630 goto copied;
631 }
632 }
633
582 frags = PAGE_ALIGN(wc->byte_len - min(wc->byte_len, 634 frags = PAGE_ALIGN(wc->byte_len - min(wc->byte_len,
583 (unsigned)IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE; 635 (unsigned)IPOIB_CM_HEAD_SIZE)) / PAGE_SIZE;
584 636
@@ -601,6 +653,7 @@ void ipoib_cm_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
601 653
602 skb_put_frags(skb, IPOIB_CM_HEAD_SIZE, wc->byte_len, newskb); 654 skb_put_frags(skb, IPOIB_CM_HEAD_SIZE, wc->byte_len, newskb);
603 655
656copied:
604 skb->protocol = ((struct ipoib_header *) skb->data)->proto; 657 skb->protocol = ((struct ipoib_header *) skb->data)->proto;
605 skb_reset_mac_header(skb); 658 skb_reset_mac_header(skb);
606 skb_pull(skb, IPOIB_ENCAP_LEN); 659 skb_pull(skb, IPOIB_ENCAP_LEN);
@@ -620,7 +673,10 @@ repost:
620 ipoib_warn(priv, "ipoib_cm_post_receive_srq failed " 673 ipoib_warn(priv, "ipoib_cm_post_receive_srq failed "
621 "for buf %d\n", wr_id); 674 "for buf %d\n", wr_id);
622 } else { 675 } else {
623 if (unlikely(ipoib_cm_post_receive_nonsrq(dev, p, wr_id))) { 676 if (unlikely(ipoib_cm_post_receive_nonsrq(dev, p,
677 &priv->cm.rx_wr,
678 priv->cm.rx_sge,
679 wr_id))) {
624 --p->recv_count; 680 --p->recv_count;
625 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq failed " 681 ipoib_warn(priv, "ipoib_cm_post_receive_nonsrq failed "
626 "for buf %d\n", wr_id); 682 "for buf %d\n", wr_id);
@@ -647,7 +703,7 @@ static inline int post_send(struct ipoib_dev_priv *priv,
647void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx) 703void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_tx *tx)
648{ 704{
649 struct ipoib_dev_priv *priv = netdev_priv(dev); 705 struct ipoib_dev_priv *priv = netdev_priv(dev);
650 struct ipoib_tx_buf *tx_req; 706 struct ipoib_cm_tx_buf *tx_req;
651 u64 addr; 707 u64 addr;
652 708
653 if (unlikely(skb->len > tx->mtu)) { 709 if (unlikely(skb->len > tx->mtu)) {
@@ -678,7 +734,7 @@ void ipoib_cm_send(struct net_device *dev, struct sk_buff *skb, struct ipoib_cm_
678 return; 734 return;
679 } 735 }
680 736
681 tx_req->mapping[0] = addr; 737 tx_req->mapping = addr;
682 738
683 if (unlikely(post_send(priv, tx, tx->tx_head & (ipoib_sendq_size - 1), 739 if (unlikely(post_send(priv, tx, tx->tx_head & (ipoib_sendq_size - 1),
684 addr, skb->len))) { 740 addr, skb->len))) {
@@ -703,7 +759,7 @@ void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
703 struct ipoib_dev_priv *priv = netdev_priv(dev); 759 struct ipoib_dev_priv *priv = netdev_priv(dev);
704 struct ipoib_cm_tx *tx = wc->qp->qp_context; 760 struct ipoib_cm_tx *tx = wc->qp->qp_context;
705 unsigned int wr_id = wc->wr_id & ~IPOIB_OP_CM; 761 unsigned int wr_id = wc->wr_id & ~IPOIB_OP_CM;
706 struct ipoib_tx_buf *tx_req; 762 struct ipoib_cm_tx_buf *tx_req;
707 unsigned long flags; 763 unsigned long flags;
708 764
709 ipoib_dbg_data(priv, "cm send completion: id %d, status: %d\n", 765 ipoib_dbg_data(priv, "cm send completion: id %d, status: %d\n",
@@ -717,7 +773,7 @@ void ipoib_cm_handle_tx_wc(struct net_device *dev, struct ib_wc *wc)
717 773
718 tx_req = &tx->tx_ring[wr_id]; 774 tx_req = &tx->tx_ring[wr_id];
719 775
720 ib_dma_unmap_single(priv->ca, tx_req->mapping[0], tx_req->skb->len, DMA_TO_DEVICE); 776 ib_dma_unmap_single(priv->ca, tx_req->mapping, tx_req->skb->len, DMA_TO_DEVICE);
721 777
722 /* FIXME: is this right? Shouldn't we only increment on success? */ 778 /* FIXME: is this right? Shouldn't we only increment on success? */
723 ++dev->stats.tx_packets; 779 ++dev->stats.tx_packets;
@@ -1087,7 +1143,7 @@ err_tx:
1087static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p) 1143static void ipoib_cm_tx_destroy(struct ipoib_cm_tx *p)
1088{ 1144{
1089 struct ipoib_dev_priv *priv = netdev_priv(p->dev); 1145 struct ipoib_dev_priv *priv = netdev_priv(p->dev);
1090 struct ipoib_tx_buf *tx_req; 1146 struct ipoib_cm_tx_buf *tx_req;
1091 unsigned long flags; 1147 unsigned long flags;
1092 unsigned long begin; 1148 unsigned long begin;
1093 1149
@@ -1115,7 +1171,7 @@ timeout:
1115 1171
1116 while ((int) p->tx_tail - (int) p->tx_head < 0) { 1172 while ((int) p->tx_tail - (int) p->tx_head < 0) {
1117 tx_req = &p->tx_ring[p->tx_tail & (ipoib_sendq_size - 1)]; 1173 tx_req = &p->tx_ring[p->tx_tail & (ipoib_sendq_size - 1)];
1118 ib_dma_unmap_single(priv->ca, tx_req->mapping[0], tx_req->skb->len, 1174 ib_dma_unmap_single(priv->ca, tx_req->mapping, tx_req->skb->len,
1119 DMA_TO_DEVICE); 1175 DMA_TO_DEVICE);
1120 dev_kfree_skb_any(tx_req->skb); 1176 dev_kfree_skb_any(tx_req->skb);
1121 ++p->tx_tail; 1177 ++p->tx_tail;
@@ -1384,7 +1440,9 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
1384 ipoib_warn(priv, "enabling connected mode " 1440 ipoib_warn(priv, "enabling connected mode "
1385 "will cause multicast packet drops\n"); 1441 "will cause multicast packet drops\n");
1386 1442
1443 rtnl_lock();
1387 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO); 1444 dev->features &= ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO);
1445 rtnl_unlock();
1388 priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM; 1446 priv->tx_wr.send_flags &= ~IB_SEND_IP_CSUM;
1389 1447
1390 ipoib_flush_paths(dev); 1448 ipoib_flush_paths(dev);
@@ -1393,14 +1451,16 @@ static ssize_t set_mode(struct device *d, struct device_attribute *attr,
1393 1451
1394 if (!strcmp(buf, "datagram\n")) { 1452 if (!strcmp(buf, "datagram\n")) {
1395 clear_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags); 1453 clear_bit(IPOIB_FLAG_ADMIN_CM, &priv->flags);
1396 dev->mtu = min(priv->mcast_mtu, dev->mtu);
1397 ipoib_flush_paths(dev);
1398 1454
1455 rtnl_lock();
1399 if (test_bit(IPOIB_FLAG_CSUM, &priv->flags)) { 1456 if (test_bit(IPOIB_FLAG_CSUM, &priv->flags)) {
1400 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG; 1457 dev->features |= NETIF_F_IP_CSUM | NETIF_F_SG;
1401 if (priv->hca_caps & IB_DEVICE_UD_TSO) 1458 if (priv->hca_caps & IB_DEVICE_UD_TSO)
1402 dev->features |= NETIF_F_TSO; 1459 dev->features |= NETIF_F_TSO;
1403 } 1460 }
1461 dev_set_mtu(dev, min(priv->mcast_mtu, dev->mtu));
1462 rtnl_unlock();
1463 ipoib_flush_paths(dev);
1404 1464
1405 return count; 1465 return count;
1406 } 1466 }
@@ -1485,15 +1545,7 @@ int ipoib_cm_dev_init(struct net_device *dev)
1485 priv->cm.num_frags = IPOIB_CM_RX_SG; 1545 priv->cm.num_frags = IPOIB_CM_RX_SG;
1486 } 1546 }
1487 1547
1488 for (i = 0; i < priv->cm.num_frags; ++i) 1548 ipoib_cm_init_rx_wr(dev, &priv->cm.rx_wr, priv->cm.rx_sge);
1489 priv->cm.rx_sge[i].lkey = priv->mr->lkey;
1490
1491 priv->cm.rx_sge[0].length = IPOIB_CM_HEAD_SIZE;
1492 for (i = 1; i < priv->cm.num_frags; ++i)
1493 priv->cm.rx_sge[i].length = PAGE_SIZE;
1494 priv->cm.rx_wr.next = NULL;
1495 priv->cm.rx_wr.sg_list = priv->cm.rx_sge;
1496 priv->cm.rx_wr.num_sge = priv->cm.num_frags;
1497 1549
1498 if (ipoib_cm_has_srq(dev)) { 1550 if (ipoib_cm_has_srq(dev)) {
1499 for (i = 0; i < ipoib_recvq_size; ++i) { 1551 for (i = 0; i < ipoib_recvq_size; ++i) {
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
index 10279b79c44d..66af5c1a76e5 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ethtool.c
@@ -86,11 +86,57 @@ static int ipoib_set_coalesce(struct net_device *dev,
86 return 0; 86 return 0;
87} 87}
88 88
89static const char ipoib_stats_keys[][ETH_GSTRING_LEN] = {
90 "LRO aggregated", "LRO flushed",
91 "LRO avg aggr", "LRO no desc"
92};
93
94static void ipoib_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
95{
96 switch (stringset) {
97 case ETH_SS_STATS:
98 memcpy(data, *ipoib_stats_keys, sizeof(ipoib_stats_keys));
99 break;
100 }
101}
102
103static int ipoib_get_sset_count(struct net_device *dev, int sset)
104{
105 switch (sset) {
106 case ETH_SS_STATS:
107 return ARRAY_SIZE(ipoib_stats_keys);
108 default:
109 return -EOPNOTSUPP;
110 }
111}
112
113static void ipoib_get_ethtool_stats(struct net_device *dev,
114 struct ethtool_stats *stats, uint64_t *data)
115{
116 struct ipoib_dev_priv *priv = netdev_priv(dev);
117 int index = 0;
118
119 /* Get LRO statistics */
120 data[index++] = priv->lro.lro_mgr.stats.aggregated;
121 data[index++] = priv->lro.lro_mgr.stats.flushed;
122 if (priv->lro.lro_mgr.stats.flushed)
123 data[index++] = priv->lro.lro_mgr.stats.aggregated /
124 priv->lro.lro_mgr.stats.flushed;
125 else
126 data[index++] = 0;
127 data[index++] = priv->lro.lro_mgr.stats.no_desc;
128}
129
89static const struct ethtool_ops ipoib_ethtool_ops = { 130static const struct ethtool_ops ipoib_ethtool_ops = {
90 .get_drvinfo = ipoib_get_drvinfo, 131 .get_drvinfo = ipoib_get_drvinfo,
91 .get_tso = ethtool_op_get_tso, 132 .get_tso = ethtool_op_get_tso,
92 .get_coalesce = ipoib_get_coalesce, 133 .get_coalesce = ipoib_get_coalesce,
93 .set_coalesce = ipoib_set_coalesce, 134 .set_coalesce = ipoib_set_coalesce,
135 .get_flags = ethtool_op_get_flags,
136 .set_flags = ethtool_op_set_flags,
137 .get_strings = ipoib_get_strings,
138 .get_sset_count = ipoib_get_sset_count,
139 .get_ethtool_stats = ipoib_get_ethtool_stats,
94}; 140};
95 141
96void ipoib_set_ethtool_ops(struct net_device *dev) 142void ipoib_set_ethtool_ops(struct net_device *dev)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_fs.c b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
index 8b882bbd1d05..961c585da216 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_fs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_fs.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: ipoib_fs.c 1389 2004-12-27 22:56:47Z roland $
33 */ 31 */
34 32
35#include <linux/err.h> 33#include <linux/err.h>
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_ib.c b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
index f429bce24c20..66cafa20c246 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_ib.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_ib.c
@@ -31,8 +31,6 @@
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33 * SOFTWARE. 33 * SOFTWARE.
34 *
35 * $Id: ipoib_ib.c 1386 2004-12-27 16:23:17Z roland $
36 */ 34 */
37 35
38#include <linux/delay.h> 36#include <linux/delay.h>
@@ -290,7 +288,10 @@ static void ipoib_ib_handle_rx_wc(struct net_device *dev, struct ib_wc *wc)
290 if (test_bit(IPOIB_FLAG_CSUM, &priv->flags) && likely(wc->csum_ok)) 288 if (test_bit(IPOIB_FLAG_CSUM, &priv->flags) && likely(wc->csum_ok))
291 skb->ip_summed = CHECKSUM_UNNECESSARY; 289 skb->ip_summed = CHECKSUM_UNNECESSARY;
292 290
293 netif_receive_skb(skb); 291 if (dev->features & NETIF_F_LRO)
292 lro_receive_skb(&priv->lro.lro_mgr, skb, NULL);
293 else
294 netif_receive_skb(skb);
294 295
295repost: 296repost:
296 if (unlikely(ipoib_ib_post_receive(dev, wr_id))) 297 if (unlikely(ipoib_ib_post_receive(dev, wr_id)))
@@ -442,6 +443,9 @@ poll_more:
442 } 443 }
443 444
444 if (done < budget) { 445 if (done < budget) {
446 if (dev->features & NETIF_F_LRO)
447 lro_flush_all(&priv->lro.lro_mgr);
448
445 netif_rx_complete(dev, napi); 449 netif_rx_complete(dev, napi);
446 if (unlikely(ib_req_notify_cq(priv->recv_cq, 450 if (unlikely(ib_req_notify_cq(priv->recv_cq,
447 IB_CQ_NEXT_COMP | 451 IB_CQ_NEXT_COMP |
@@ -898,7 +902,8 @@ int ipoib_ib_dev_init(struct net_device *dev, struct ib_device *ca, int port)
898 return 0; 902 return 0;
899} 903}
900 904
901static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event) 905static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv,
906 enum ipoib_flush_level level)
902{ 907{
903 struct ipoib_dev_priv *cpriv; 908 struct ipoib_dev_priv *cpriv;
904 struct net_device *dev = priv->dev; 909 struct net_device *dev = priv->dev;
@@ -911,7 +916,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
911 * the parent is down. 916 * the parent is down.
912 */ 917 */
913 list_for_each_entry(cpriv, &priv->child_intfs, list) 918 list_for_each_entry(cpriv, &priv->child_intfs, list)
914 __ipoib_ib_dev_flush(cpriv, pkey_event); 919 __ipoib_ib_dev_flush(cpriv, level);
915 920
916 mutex_unlock(&priv->vlan_mutex); 921 mutex_unlock(&priv->vlan_mutex);
917 922
@@ -925,7 +930,7 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
925 return; 930 return;
926 } 931 }
927 932
928 if (pkey_event) { 933 if (level == IPOIB_FLUSH_HEAVY) {
929 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) { 934 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &new_index)) {
930 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 935 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
931 ipoib_ib_dev_down(dev, 0); 936 ipoib_ib_dev_down(dev, 0);
@@ -943,11 +948,15 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
943 priv->pkey_index = new_index; 948 priv->pkey_index = new_index;
944 } 949 }
945 950
946 ipoib_dbg(priv, "flushing\n"); 951 if (level == IPOIB_FLUSH_LIGHT) {
952 ipoib_mark_paths_invalid(dev);
953 ipoib_mcast_dev_flush(dev);
954 }
947 955
948 ipoib_ib_dev_down(dev, 0); 956 if (level >= IPOIB_FLUSH_NORMAL)
957 ipoib_ib_dev_down(dev, 0);
949 958
950 if (pkey_event) { 959 if (level == IPOIB_FLUSH_HEAVY) {
951 ipoib_ib_dev_stop(dev, 0); 960 ipoib_ib_dev_stop(dev, 0);
952 ipoib_ib_dev_open(dev); 961 ipoib_ib_dev_open(dev);
953 } 962 }
@@ -957,27 +966,34 @@ static void __ipoib_ib_dev_flush(struct ipoib_dev_priv *priv, int pkey_event)
957 * we get here, don't bring it back up if it's not configured up 966 * we get here, don't bring it back up if it's not configured up
958 */ 967 */
959 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) { 968 if (test_bit(IPOIB_FLAG_ADMIN_UP, &priv->flags)) {
960 ipoib_ib_dev_up(dev); 969 if (level >= IPOIB_FLUSH_NORMAL)
970 ipoib_ib_dev_up(dev);
961 ipoib_mcast_restart_task(&priv->restart_task); 971 ipoib_mcast_restart_task(&priv->restart_task);
962 } 972 }
963} 973}
964 974
965void ipoib_ib_dev_flush(struct work_struct *work) 975void ipoib_ib_dev_flush_light(struct work_struct *work)
976{
977 struct ipoib_dev_priv *priv =
978 container_of(work, struct ipoib_dev_priv, flush_light);
979
980 __ipoib_ib_dev_flush(priv, IPOIB_FLUSH_LIGHT);
981}
982
983void ipoib_ib_dev_flush_normal(struct work_struct *work)
966{ 984{
967 struct ipoib_dev_priv *priv = 985 struct ipoib_dev_priv *priv =
968 container_of(work, struct ipoib_dev_priv, flush_task); 986 container_of(work, struct ipoib_dev_priv, flush_normal);
969 987
970 ipoib_dbg(priv, "Flushing %s\n", priv->dev->name); 988 __ipoib_ib_dev_flush(priv, IPOIB_FLUSH_NORMAL);
971 __ipoib_ib_dev_flush(priv, 0);
972} 989}
973 990
974void ipoib_pkey_event(struct work_struct *work) 991void ipoib_ib_dev_flush_heavy(struct work_struct *work)
975{ 992{
976 struct ipoib_dev_priv *priv = 993 struct ipoib_dev_priv *priv =
977 container_of(work, struct ipoib_dev_priv, pkey_event_task); 994 container_of(work, struct ipoib_dev_priv, flush_heavy);
978 995
979 ipoib_dbg(priv, "Flushing %s and restarting its QP\n", priv->dev->name); 996 __ipoib_ib_dev_flush(priv, IPOIB_FLUSH_HEAVY);
980 __ipoib_ib_dev_flush(priv, 1);
981} 997}
982 998
983void ipoib_ib_dev_cleanup(struct net_device *dev) 999void ipoib_ib_dev_cleanup(struct net_device *dev)
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c
index 2442090ac8d1..8be9ea0436e6 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_main.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: ipoib_main.c 1377 2004-12-23 19:57:12Z roland $
35 */ 33 */
36 34
37#include "ipoib.h" 35#include "ipoib.h"
@@ -62,6 +60,15 @@ MODULE_PARM_DESC(send_queue_size, "Number of descriptors in send queue");
62module_param_named(recv_queue_size, ipoib_recvq_size, int, 0444); 60module_param_named(recv_queue_size, ipoib_recvq_size, int, 0444);
63MODULE_PARM_DESC(recv_queue_size, "Number of descriptors in receive queue"); 61MODULE_PARM_DESC(recv_queue_size, "Number of descriptors in receive queue");
64 62
63static int lro;
64module_param(lro, bool, 0444);
65MODULE_PARM_DESC(lro, "Enable LRO (Large Receive Offload)");
66
67static int lro_max_aggr = IPOIB_LRO_MAX_AGGR;
68module_param(lro_max_aggr, int, 0644);
69MODULE_PARM_DESC(lro_max_aggr, "LRO: Max packets to be aggregated "
70 "(default = 64)");
71
65#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG 72#ifdef CONFIG_INFINIBAND_IPOIB_DEBUG
66int ipoib_debug_level; 73int ipoib_debug_level;
67 74
@@ -350,6 +357,23 @@ void ipoib_path_iter_read(struct ipoib_path_iter *iter,
350 357
351#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */ 358#endif /* CONFIG_INFINIBAND_IPOIB_DEBUG */
352 359
360void ipoib_mark_paths_invalid(struct net_device *dev)
361{
362 struct ipoib_dev_priv *priv = netdev_priv(dev);
363 struct ipoib_path *path, *tp;
364
365 spin_lock_irq(&priv->lock);
366
367 list_for_each_entry_safe(path, tp, &priv->path_list, list) {
368 ipoib_dbg(priv, "mark path LID 0x%04x GID " IPOIB_GID_FMT " invalid\n",
369 be16_to_cpu(path->pathrec.dlid),
370 IPOIB_GID_ARG(path->pathrec.dgid));
371 path->valid = 0;
372 }
373
374 spin_unlock_irq(&priv->lock);
375}
376
353void ipoib_flush_paths(struct net_device *dev) 377void ipoib_flush_paths(struct net_device *dev)
354{ 378{
355 struct ipoib_dev_priv *priv = netdev_priv(dev); 379 struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -386,6 +410,7 @@ static void path_rec_completion(int status,
386 struct net_device *dev = path->dev; 410 struct net_device *dev = path->dev;
387 struct ipoib_dev_priv *priv = netdev_priv(dev); 411 struct ipoib_dev_priv *priv = netdev_priv(dev);
388 struct ipoib_ah *ah = NULL; 412 struct ipoib_ah *ah = NULL;
413 struct ipoib_ah *old_ah;
389 struct ipoib_neigh *neigh, *tn; 414 struct ipoib_neigh *neigh, *tn;
390 struct sk_buff_head skqueue; 415 struct sk_buff_head skqueue;
391 struct sk_buff *skb; 416 struct sk_buff *skb;
@@ -409,6 +434,7 @@ static void path_rec_completion(int status,
409 434
410 spin_lock_irqsave(&priv->lock, flags); 435 spin_lock_irqsave(&priv->lock, flags);
411 436
437 old_ah = path->ah;
412 path->ah = ah; 438 path->ah = ah;
413 439
414 if (ah) { 440 if (ah) {
@@ -421,6 +447,17 @@ static void path_rec_completion(int status,
421 __skb_queue_tail(&skqueue, skb); 447 __skb_queue_tail(&skqueue, skb);
422 448
423 list_for_each_entry_safe(neigh, tn, &path->neigh_list, list) { 449 list_for_each_entry_safe(neigh, tn, &path->neigh_list, list) {
450 if (neigh->ah) {
451 WARN_ON(neigh->ah != old_ah);
452 /*
453 * Dropping the ah reference inside
454 * priv->lock is safe here, because we
455 * will hold one more reference from
456 * the original value of path->ah (ie
457 * old_ah).
458 */
459 ipoib_put_ah(neigh->ah);
460 }
424 kref_get(&path->ah->ref); 461 kref_get(&path->ah->ref);
425 neigh->ah = path->ah; 462 neigh->ah = path->ah;
426 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw, 463 memcpy(&neigh->dgid.raw, &path->pathrec.dgid.raw,
@@ -443,6 +480,7 @@ static void path_rec_completion(int status,
443 while ((skb = __skb_dequeue(&neigh->queue))) 480 while ((skb = __skb_dequeue(&neigh->queue)))
444 __skb_queue_tail(&skqueue, skb); 481 __skb_queue_tail(&skqueue, skb);
445 } 482 }
483 path->valid = 1;
446 } 484 }
447 485
448 path->query = NULL; 486 path->query = NULL;
@@ -450,6 +488,9 @@ static void path_rec_completion(int status,
450 488
451 spin_unlock_irqrestore(&priv->lock, flags); 489 spin_unlock_irqrestore(&priv->lock, flags);
452 490
491 if (old_ah)
492 ipoib_put_ah(old_ah);
493
453 while ((skb = __skb_dequeue(&skqueue))) { 494 while ((skb = __skb_dequeue(&skqueue))) {
454 skb->dev = dev; 495 skb->dev = dev;
455 if (dev_queue_xmit(skb)) 496 if (dev_queue_xmit(skb))
@@ -623,8 +664,9 @@ static void unicast_arp_send(struct sk_buff *skb, struct net_device *dev,
623 spin_lock(&priv->lock); 664 spin_lock(&priv->lock);
624 665
625 path = __path_find(dev, phdr->hwaddr + 4); 666 path = __path_find(dev, phdr->hwaddr + 4);
626 if (!path) { 667 if (!path || !path->valid) {
627 path = path_rec_create(dev, phdr->hwaddr + 4); 668 if (!path)
669 path = path_rec_create(dev, phdr->hwaddr + 4);
628 if (path) { 670 if (path) {
629 /* put pseudoheader back on for next time */ 671 /* put pseudoheader back on for next time */
630 skb_push(skb, sizeof *phdr); 672 skb_push(skb, sizeof *phdr);
@@ -938,6 +980,54 @@ static const struct header_ops ipoib_header_ops = {
938 .create = ipoib_hard_header, 980 .create = ipoib_hard_header,
939}; 981};
940 982
983static int get_skb_hdr(struct sk_buff *skb, void **iphdr,
984 void **tcph, u64 *hdr_flags, void *priv)
985{
986 unsigned int ip_len;
987 struct iphdr *iph;
988
989 if (unlikely(skb->protocol != htons(ETH_P_IP)))
990 return -1;
991
992 /*
993 * In the future we may add an else clause that verifies the
994 * checksum and allows devices which do not calculate checksum
995 * to use LRO.
996 */
997 if (unlikely(skb->ip_summed != CHECKSUM_UNNECESSARY))
998 return -1;
999
1000 /* Check for non-TCP packet */
1001 skb_reset_network_header(skb);
1002 iph = ip_hdr(skb);
1003 if (iph->protocol != IPPROTO_TCP)
1004 return -1;
1005
1006 ip_len = ip_hdrlen(skb);
1007 skb_set_transport_header(skb, ip_len);
1008 *tcph = tcp_hdr(skb);
1009
1010 /* check if IP header and TCP header are complete */
1011 if (ntohs(iph->tot_len) < ip_len + tcp_hdrlen(skb))
1012 return -1;
1013
1014 *hdr_flags = LRO_IPV4 | LRO_TCP;
1015 *iphdr = iph;
1016
1017 return 0;
1018}
1019
1020static void ipoib_lro_setup(struct ipoib_dev_priv *priv)
1021{
1022 priv->lro.lro_mgr.max_aggr = lro_max_aggr;
1023 priv->lro.lro_mgr.max_desc = IPOIB_MAX_LRO_DESCRIPTORS;
1024 priv->lro.lro_mgr.lro_arr = priv->lro.lro_desc;
1025 priv->lro.lro_mgr.get_skb_header = get_skb_hdr;
1026 priv->lro.lro_mgr.features = LRO_F_NAPI;
1027 priv->lro.lro_mgr.dev = priv->dev;
1028 priv->lro.lro_mgr.ip_summed_aggr = CHECKSUM_UNNECESSARY;
1029}
1030
941static void ipoib_setup(struct net_device *dev) 1031static void ipoib_setup(struct net_device *dev)
942{ 1032{
943 struct ipoib_dev_priv *priv = netdev_priv(dev); 1033 struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -977,10 +1067,11 @@ static void ipoib_setup(struct net_device *dev)
977 1067
978 priv->dev = dev; 1068 priv->dev = dev;
979 1069
1070 ipoib_lro_setup(priv);
1071
980 spin_lock_init(&priv->lock); 1072 spin_lock_init(&priv->lock);
981 spin_lock_init(&priv->tx_lock); 1073 spin_lock_init(&priv->tx_lock);
982 1074
983 mutex_init(&priv->mcast_mutex);
984 mutex_init(&priv->vlan_mutex); 1075 mutex_init(&priv->vlan_mutex);
985 1076
986 INIT_LIST_HEAD(&priv->path_list); 1077 INIT_LIST_HEAD(&priv->path_list);
@@ -989,9 +1080,10 @@ static void ipoib_setup(struct net_device *dev)
989 INIT_LIST_HEAD(&priv->multicast_list); 1080 INIT_LIST_HEAD(&priv->multicast_list);
990 1081
991 INIT_DELAYED_WORK(&priv->pkey_poll_task, ipoib_pkey_poll); 1082 INIT_DELAYED_WORK(&priv->pkey_poll_task, ipoib_pkey_poll);
992 INIT_WORK(&priv->pkey_event_task, ipoib_pkey_event);
993 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task); 1083 INIT_DELAYED_WORK(&priv->mcast_task, ipoib_mcast_join_task);
994 INIT_WORK(&priv->flush_task, ipoib_ib_dev_flush); 1084 INIT_WORK(&priv->flush_light, ipoib_ib_dev_flush_light);
1085 INIT_WORK(&priv->flush_normal, ipoib_ib_dev_flush_normal);
1086 INIT_WORK(&priv->flush_heavy, ipoib_ib_dev_flush_heavy);
995 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task); 1087 INIT_WORK(&priv->restart_task, ipoib_mcast_restart_task);
996 INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah); 1088 INIT_DELAYED_WORK(&priv->ah_reap_task, ipoib_reap_ah);
997} 1089}
@@ -1154,6 +1246,9 @@ static struct net_device *ipoib_add_port(const char *format,
1154 priv->dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM; 1246 priv->dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
1155 } 1247 }
1156 1248
1249 if (lro)
1250 priv->dev->features |= NETIF_F_LRO;
1251
1157 /* 1252 /*
1158 * Set the full membership bit, so that we join the right 1253 * Set the full membership bit, so that we join the right
1159 * broadcast group, etc. 1254 * broadcast group, etc.
@@ -1304,6 +1399,12 @@ static int __init ipoib_init_module(void)
1304 ipoib_max_conn_qp = min(ipoib_max_conn_qp, IPOIB_CM_MAX_CONN_QP); 1399 ipoib_max_conn_qp = min(ipoib_max_conn_qp, IPOIB_CM_MAX_CONN_QP);
1305#endif 1400#endif
1306 1401
1402 /*
1403 * When copying small received packets, we only copy from the
1404 * linear data part of the SKB, so we rely on this condition.
1405 */
1406 BUILD_BUG_ON(IPOIB_CM_COPYBREAK > IPOIB_CM_HEAD_SIZE);
1407
1307 ret = ipoib_register_debugfs(); 1408 ret = ipoib_register_debugfs();
1308 if (ret) 1409 if (ret)
1309 return ret; 1410 return ret;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
index cd2fb955040f..8950e9546f4e 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_multicast.c
@@ -30,8 +30,6 @@
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32 * SOFTWARE. 32 * SOFTWARE.
33 *
34 * $Id: ipoib_multicast.c 1362 2004-12-18 15:56:29Z roland $
35 */ 33 */
36 34
37#include <linux/skbuff.h> 35#include <linux/skbuff.h>
@@ -188,6 +186,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
188 struct ipoib_dev_priv *priv = netdev_priv(dev); 186 struct ipoib_dev_priv *priv = netdev_priv(dev);
189 struct ipoib_ah *ah; 187 struct ipoib_ah *ah;
190 int ret; 188 int ret;
189 int set_qkey = 0;
191 190
192 mcast->mcmember = *mcmember; 191 mcast->mcmember = *mcmember;
193 192
@@ -202,6 +201,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
202 priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey); 201 priv->qkey = be32_to_cpu(priv->broadcast->mcmember.qkey);
203 spin_unlock_irq(&priv->lock); 202 spin_unlock_irq(&priv->lock);
204 priv->tx_wr.wr.ud.remote_qkey = priv->qkey; 203 priv->tx_wr.wr.ud.remote_qkey = priv->qkey;
204 set_qkey = 1;
205 } 205 }
206 206
207 if (!test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) { 207 if (!test_bit(IPOIB_MCAST_FLAG_SENDONLY, &mcast->flags)) {
@@ -214,7 +214,7 @@ static int ipoib_mcast_join_finish(struct ipoib_mcast *mcast,
214 } 214 }
215 215
216 ret = ipoib_mcast_attach(dev, be16_to_cpu(mcast->mcmember.mlid), 216 ret = ipoib_mcast_attach(dev, be16_to_cpu(mcast->mcmember.mlid),
217 &mcast->mcmember.mgid); 217 &mcast->mcmember.mgid, set_qkey);
218 if (ret < 0) { 218 if (ret < 0) {
219 ipoib_warn(priv, "couldn't attach QP to multicast group " 219 ipoib_warn(priv, "couldn't attach QP to multicast group "
220 IPOIB_GID_FMT "\n", 220 IPOIB_GID_FMT "\n",
@@ -575,8 +575,11 @@ void ipoib_mcast_join_task(struct work_struct *work)
575 575
576 priv->mcast_mtu = IPOIB_UD_MTU(ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu)); 576 priv->mcast_mtu = IPOIB_UD_MTU(ib_mtu_enum_to_int(priv->broadcast->mcmember.mtu));
577 577
578 if (!ipoib_cm_admin_enabled(dev)) 578 if (!ipoib_cm_admin_enabled(dev)) {
579 dev->mtu = min(priv->mcast_mtu, priv->admin_mtu); 579 rtnl_lock();
580 dev_set_mtu(dev, min(priv->mcast_mtu, priv->admin_mtu));
581 rtnl_unlock();
582 }
580 583
581 ipoib_dbg_mcast(priv, "successfully joined all multicast groups\n"); 584 ipoib_dbg_mcast(priv, "successfully joined all multicast groups\n");
582 585
@@ -594,10 +597,6 @@ int ipoib_mcast_start_thread(struct net_device *dev)
594 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 0); 597 queue_delayed_work(ipoib_workqueue, &priv->mcast_task, 0);
595 mutex_unlock(&mcast_mutex); 598 mutex_unlock(&mcast_mutex);
596 599
597 spin_lock_irq(&priv->lock);
598 set_bit(IPOIB_MCAST_STARTED, &priv->flags);
599 spin_unlock_irq(&priv->lock);
600
601 return 0; 600 return 0;
602} 601}
603 602
@@ -607,10 +606,6 @@ int ipoib_mcast_stop_thread(struct net_device *dev, int flush)
607 606
608 ipoib_dbg_mcast(priv, "stopping multicast thread\n"); 607 ipoib_dbg_mcast(priv, "stopping multicast thread\n");
609 608
610 spin_lock_irq(&priv->lock);
611 clear_bit(IPOIB_MCAST_STARTED, &priv->flags);
612 spin_unlock_irq(&priv->lock);
613
614 mutex_lock(&mcast_mutex); 609 mutex_lock(&mcast_mutex);
615 clear_bit(IPOIB_MCAST_RUN, &priv->flags); 610 clear_bit(IPOIB_MCAST_RUN, &priv->flags);
616 cancel_delayed_work(&priv->mcast_task); 611 cancel_delayed_work(&priv->mcast_task);
@@ -635,10 +630,10 @@ static int ipoib_mcast_leave(struct net_device *dev, struct ipoib_mcast *mcast)
635 IPOIB_GID_ARG(mcast->mcmember.mgid)); 630 IPOIB_GID_ARG(mcast->mcmember.mgid));
636 631
637 /* Remove ourselves from the multicast group */ 632 /* Remove ourselves from the multicast group */
638 ret = ipoib_mcast_detach(dev, be16_to_cpu(mcast->mcmember.mlid), 633 ret = ib_detach_mcast(priv->qp, &mcast->mcmember.mgid,
639 &mcast->mcmember.mgid); 634 be16_to_cpu(mcast->mcmember.mlid));
640 if (ret) 635 if (ret)
641 ipoib_warn(priv, "ipoib_mcast_detach failed (result = %d)\n", ret); 636 ipoib_warn(priv, "ib_detach_mcast failed (result = %d)\n", ret);
642 } 637 }
643 638
644 return 0; 639 return 0;
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
index 8766d29ce3b7..68325119f740 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_verbs.c
@@ -29,24 +29,17 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: ipoib_verbs.c 1349 2004-12-16 21:09:43Z roland $
34 */ 32 */
35 33
36#include "ipoib.h" 34#include "ipoib.h"
37 35
38int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid) 36int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid, int set_qkey)
39{ 37{
40 struct ipoib_dev_priv *priv = netdev_priv(dev); 38 struct ipoib_dev_priv *priv = netdev_priv(dev);
41 struct ib_qp_attr *qp_attr; 39 struct ib_qp_attr *qp_attr = NULL;
42 int ret; 40 int ret;
43 u16 pkey_index; 41 u16 pkey_index;
44 42
45 ret = -ENOMEM;
46 qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL);
47 if (!qp_attr)
48 goto out;
49
50 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) { 43 if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) {
51 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 44 clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
52 ret = -ENXIO; 45 ret = -ENXIO;
@@ -54,18 +47,23 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
54 } 47 }
55 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags); 48 set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
56 49
57 /* set correct QKey for QP */ 50 if (set_qkey) {
58 qp_attr->qkey = priv->qkey; 51 ret = -ENOMEM;
59 ret = ib_modify_qp(priv->qp, qp_attr, IB_QP_QKEY); 52 qp_attr = kmalloc(sizeof *qp_attr, GFP_KERNEL);
60 if (ret) { 53 if (!qp_attr)
61 ipoib_warn(priv, "failed to modify QP, ret = %d\n", ret); 54 goto out;
62 goto out; 55
56 /* set correct QKey for QP */
57 qp_attr->qkey = priv->qkey;
58 ret = ib_modify_qp(priv->qp, qp_attr, IB_QP_QKEY);
59 if (ret) {
60 ipoib_warn(priv, "failed to modify QP, ret = %d\n", ret);
61 goto out;
62 }
63 } 63 }
64 64
65 /* attach QP to multicast group */ 65 /* attach QP to multicast group */
66 mutex_lock(&priv->mcast_mutex);
67 ret = ib_attach_mcast(priv->qp, mgid, mlid); 66 ret = ib_attach_mcast(priv->qp, mgid, mlid);
68 mutex_unlock(&priv->mcast_mutex);
69 if (ret) 67 if (ret)
70 ipoib_warn(priv, "failed to attach to multicast group, ret = %d\n", ret); 68 ipoib_warn(priv, "failed to attach to multicast group, ret = %d\n", ret);
71 69
@@ -74,20 +72,6 @@ out:
74 return ret; 72 return ret;
75} 73}
76 74
77int ipoib_mcast_detach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
78{
79 struct ipoib_dev_priv *priv = netdev_priv(dev);
80 int ret;
81
82 mutex_lock(&priv->mcast_mutex);
83 ret = ib_detach_mcast(priv->qp, mgid, mlid);
84 mutex_unlock(&priv->mcast_mutex);
85 if (ret)
86 ipoib_warn(priv, "ib_detach_mcast failed (result = %d)\n", ret);
87
88 return ret;
89}
90
91int ipoib_init_qp(struct net_device *dev) 75int ipoib_init_qp(struct net_device *dev)
92{ 76{
93 struct ipoib_dev_priv *priv = netdev_priv(dev); 77 struct ipoib_dev_priv *priv = netdev_priv(dev);
@@ -201,7 +185,10 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
201 init_attr.recv_cq = priv->recv_cq; 185 init_attr.recv_cq = priv->recv_cq;
202 186
203 if (priv->hca_caps & IB_DEVICE_UD_TSO) 187 if (priv->hca_caps & IB_DEVICE_UD_TSO)
204 init_attr.create_flags = IB_QP_CREATE_IPOIB_UD_LSO; 188 init_attr.create_flags |= IB_QP_CREATE_IPOIB_UD_LSO;
189
190 if (priv->hca_caps & IB_DEVICE_BLOCK_MULTICAST_LOOPBACK)
191 init_attr.create_flags |= IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK;
205 192
206 if (dev->features & NETIF_F_SG) 193 if (dev->features & NETIF_F_SG)
207 init_attr.cap.max_send_sge = MAX_SKB_FRAGS + 1; 194 init_attr.cap.max_send_sge = MAX_SKB_FRAGS + 1;
@@ -289,15 +276,17 @@ void ipoib_event(struct ib_event_handler *handler,
289 if (record->element.port_num != priv->port) 276 if (record->element.port_num != priv->port)
290 return; 277 return;
291 278
292 if (record->event == IB_EVENT_PORT_ERR || 279 ipoib_dbg(priv, "Event %d on device %s port %d\n", record->event,
293 record->event == IB_EVENT_PORT_ACTIVE || 280 record->device->name, record->element.port_num);
294 record->event == IB_EVENT_LID_CHANGE || 281
295 record->event == IB_EVENT_SM_CHANGE || 282 if (record->event == IB_EVENT_SM_CHANGE ||
296 record->event == IB_EVENT_CLIENT_REREGISTER) { 283 record->event == IB_EVENT_CLIENT_REREGISTER) {
297 ipoib_dbg(priv, "Port state change event\n"); 284 queue_work(ipoib_workqueue, &priv->flush_light);
298 queue_work(ipoib_workqueue, &priv->flush_task); 285 } else if (record->event == IB_EVENT_PORT_ERR ||
286 record->event == IB_EVENT_PORT_ACTIVE ||
287 record->event == IB_EVENT_LID_CHANGE) {
288 queue_work(ipoib_workqueue, &priv->flush_normal);
299 } else if (record->event == IB_EVENT_PKEY_CHANGE) { 289 } else if (record->event == IB_EVENT_PKEY_CHANGE) {
300 ipoib_dbg(priv, "P_Key change event on port:%d\n", priv->port); 290 queue_work(ipoib_workqueue, &priv->flush_heavy);
301 queue_work(ipoib_workqueue, &priv->pkey_event_task);
302 } 291 }
303} 292}
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
index 1cdb5cfb0ff1..b08eb56196d3 100644
--- a/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
+++ b/drivers/infiniband/ulp/ipoib/ipoib_vlan.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: ipoib_vlan.c 1349 2004-12-16 21:09:43Z roland $
33 */ 31 */
34 32
35#include <linux/module.h> 33#include <linux/module.h>
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.c b/drivers/infiniband/ulp/iser/iscsi_iser.c
index aeb58cae9a3f..5a1cf2580e16 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.c
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.c
@@ -42,9 +42,6 @@
42 * Zhenyu Wang 42 * Zhenyu Wang
43 * Modified by: 43 * Modified by:
44 * Erez Zilber 44 * Erez Zilber
45 *
46 *
47 * $Id: iscsi_iser.c 6965 2006-05-07 11:36:20Z ogerlitz $
48 */ 45 */
49 46
50#include <linux/types.h> 47#include <linux/types.h>
@@ -74,6 +71,10 @@
74 71
75#include "iscsi_iser.h" 72#include "iscsi_iser.h"
76 73
74static struct scsi_host_template iscsi_iser_sht;
75static struct iscsi_transport iscsi_iser_transport;
76static struct scsi_transport_template *iscsi_iser_scsi_transport;
77
77static unsigned int iscsi_max_lun = 512; 78static unsigned int iscsi_max_lun = 512;
78module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO); 79module_param_named(max_lun, iscsi_max_lun, uint, S_IRUGO);
79 80
@@ -94,7 +95,6 @@ iscsi_iser_recv(struct iscsi_conn *conn,
94 struct iscsi_hdr *hdr, char *rx_data, int rx_data_len) 95 struct iscsi_hdr *hdr, char *rx_data, int rx_data_len)
95{ 96{
96 int rc = 0; 97 int rc = 0;
97 uint32_t ret_itt;
98 int datalen; 98 int datalen;
99 int ahslen; 99 int ahslen;
100 100
@@ -110,12 +110,7 @@ iscsi_iser_recv(struct iscsi_conn *conn,
110 /* read AHS */ 110 /* read AHS */
111 ahslen = hdr->hlength * 4; 111 ahslen = hdr->hlength * 4;
112 112
113 /* verify itt (itt encoding: age+cid+itt) */ 113 rc = iscsi_complete_pdu(conn, hdr, rx_data, rx_data_len);
114 rc = iscsi_verify_itt(conn, hdr, &ret_itt);
115
116 if (!rc)
117 rc = iscsi_complete_pdu(conn, hdr, rx_data, rx_data_len);
118
119 if (rc && rc != ISCSI_ERR_NO_SCSI_CMD) 114 if (rc && rc != ISCSI_ERR_NO_SCSI_CMD)
120 goto error; 115 goto error;
121 116
@@ -126,25 +121,33 @@ error:
126 121
127 122
128/** 123/**
129 * iscsi_iser_cmd_init - Initialize iSCSI SCSI_READ or SCSI_WRITE commands 124 * iscsi_iser_task_init - Initialize task
125 * @task: iscsi task
130 * 126 *
131 **/ 127 * Initialize the task for the scsi command or mgmt command.
128 */
132static int 129static int
133iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask) 130iscsi_iser_task_init(struct iscsi_task *task)
134{ 131{
135 struct iscsi_iser_conn *iser_conn = ctask->conn->dd_data; 132 struct iscsi_iser_conn *iser_conn = task->conn->dd_data;
136 struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; 133 struct iscsi_iser_task *iser_task = task->dd_data;
137 134
138 iser_ctask->command_sent = 0; 135 /* mgmt task */
139 iser_ctask->iser_conn = iser_conn; 136 if (!task->sc) {
140 iser_ctask_rdma_init(iser_ctask); 137 iser_task->desc.data = task->data;
138 return 0;
139 }
140
141 iser_task->command_sent = 0;
142 iser_task->iser_conn = iser_conn;
143 iser_task_rdma_init(iser_task);
141 return 0; 144 return 0;
142} 145}
143 146
144/** 147/**
145 * iscsi_mtask_xmit - xmit management(immediate) task 148 * iscsi_iser_mtask_xmit - xmit management(immediate) task
146 * @conn: iscsi connection 149 * @conn: iscsi connection
147 * @mtask: task management task 150 * @task: task management task
148 * 151 *
149 * Notes: 152 * Notes:
150 * The function can return -EAGAIN in which case caller must 153 * The function can return -EAGAIN in which case caller must
@@ -153,20 +156,19 @@ iscsi_iser_cmd_init(struct iscsi_cmd_task *ctask)
153 * 156 *
154 **/ 157 **/
155static int 158static int
156iscsi_iser_mtask_xmit(struct iscsi_conn *conn, 159iscsi_iser_mtask_xmit(struct iscsi_conn *conn, struct iscsi_task *task)
157 struct iscsi_mgmt_task *mtask)
158{ 160{
159 int error = 0; 161 int error = 0;
160 162
161 debug_scsi("mtask deq [cid %d itt 0x%x]\n", conn->id, mtask->itt); 163 debug_scsi("task deq [cid %d itt 0x%x]\n", conn->id, task->itt);
162 164
163 error = iser_send_control(conn, mtask); 165 error = iser_send_control(conn, task);
164 166
165 /* since iser xmits control with zero copy, mtasks can not be recycled 167 /* since iser xmits control with zero copy, tasks can not be recycled
166 * right after sending them. 168 * right after sending them.
167 * The recycling scheme is based on whether a response is expected 169 * The recycling scheme is based on whether a response is expected
168 * - if yes, the mtask is recycled at iscsi_complete_pdu 170 * - if yes, the task is recycled at iscsi_complete_pdu
169 * - if no, the mtask is recycled at iser_snd_completion 171 * - if no, the task is recycled at iser_snd_completion
170 */ 172 */
171 if (error && error != -ENOBUFS) 173 if (error && error != -ENOBUFS)
172 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 174 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
@@ -175,97 +177,86 @@ iscsi_iser_mtask_xmit(struct iscsi_conn *conn,
175} 177}
176 178
177static int 179static int
178iscsi_iser_ctask_xmit_unsol_data(struct iscsi_conn *conn, 180iscsi_iser_task_xmit_unsol_data(struct iscsi_conn *conn,
179 struct iscsi_cmd_task *ctask) 181 struct iscsi_task *task)
180{ 182{
181 struct iscsi_data hdr; 183 struct iscsi_data hdr;
182 int error = 0; 184 int error = 0;
183 185
184 /* Send data-out PDUs while there's still unsolicited data to send */ 186 /* Send data-out PDUs while there's still unsolicited data to send */
185 while (ctask->unsol_count > 0) { 187 while (task->unsol_count > 0) {
186 iscsi_prep_unsolicit_data_pdu(ctask, &hdr); 188 iscsi_prep_unsolicit_data_pdu(task, &hdr);
187 debug_scsi("Sending data-out: itt 0x%x, data count %d\n", 189 debug_scsi("Sending data-out: itt 0x%x, data count %d\n",
188 hdr.itt, ctask->data_count); 190 hdr.itt, task->data_count);
189 191
190 /* the buffer description has been passed with the command */ 192 /* the buffer description has been passed with the command */
191 /* Send the command */ 193 /* Send the command */
192 error = iser_send_data_out(conn, ctask, &hdr); 194 error = iser_send_data_out(conn, task, &hdr);
193 if (error) { 195 if (error) {
194 ctask->unsol_datasn--; 196 task->unsol_datasn--;
195 goto iscsi_iser_ctask_xmit_unsol_data_exit; 197 goto iscsi_iser_task_xmit_unsol_data_exit;
196 } 198 }
197 ctask->unsol_count -= ctask->data_count; 199 task->unsol_count -= task->data_count;
198 debug_scsi("Need to send %d more as data-out PDUs\n", 200 debug_scsi("Need to send %d more as data-out PDUs\n",
199 ctask->unsol_count); 201 task->unsol_count);
200 } 202 }
201 203
202iscsi_iser_ctask_xmit_unsol_data_exit: 204iscsi_iser_task_xmit_unsol_data_exit:
203 return error; 205 return error;
204} 206}
205 207
206static int 208static int
207iscsi_iser_ctask_xmit(struct iscsi_conn *conn, 209iscsi_iser_task_xmit(struct iscsi_task *task)
208 struct iscsi_cmd_task *ctask)
209{ 210{
210 struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; 211 struct iscsi_conn *conn = task->conn;
212 struct iscsi_iser_task *iser_task = task->dd_data;
211 int error = 0; 213 int error = 0;
212 214
213 if (ctask->sc->sc_data_direction == DMA_TO_DEVICE) { 215 if (!task->sc)
214 BUG_ON(scsi_bufflen(ctask->sc) == 0); 216 return iscsi_iser_mtask_xmit(conn, task);
217
218 if (task->sc->sc_data_direction == DMA_TO_DEVICE) {
219 BUG_ON(scsi_bufflen(task->sc) == 0);
215 220
216 debug_scsi("cmd [itt %x total %d imm %d unsol_data %d\n", 221 debug_scsi("cmd [itt %x total %d imm %d unsol_data %d\n",
217 ctask->itt, scsi_bufflen(ctask->sc), 222 task->itt, scsi_bufflen(task->sc),
218 ctask->imm_count, ctask->unsol_count); 223 task->imm_count, task->unsol_count);
219 } 224 }
220 225
221 debug_scsi("ctask deq [cid %d itt 0x%x]\n", 226 debug_scsi("task deq [cid %d itt 0x%x]\n",
222 conn->id, ctask->itt); 227 conn->id, task->itt);
223 228
224 /* Send the cmd PDU */ 229 /* Send the cmd PDU */
225 if (!iser_ctask->command_sent) { 230 if (!iser_task->command_sent) {
226 error = iser_send_command(conn, ctask); 231 error = iser_send_command(conn, task);
227 if (error) 232 if (error)
228 goto iscsi_iser_ctask_xmit_exit; 233 goto iscsi_iser_task_xmit_exit;
229 iser_ctask->command_sent = 1; 234 iser_task->command_sent = 1;
230 } 235 }
231 236
232 /* Send unsolicited data-out PDU(s) if necessary */ 237 /* Send unsolicited data-out PDU(s) if necessary */
233 if (ctask->unsol_count) 238 if (task->unsol_count)
234 error = iscsi_iser_ctask_xmit_unsol_data(conn, ctask); 239 error = iscsi_iser_task_xmit_unsol_data(conn, task);
235 240
236 iscsi_iser_ctask_xmit_exit: 241 iscsi_iser_task_xmit_exit:
237 if (error && error != -ENOBUFS) 242 if (error && error != -ENOBUFS)
238 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED); 243 iscsi_conn_failure(conn, ISCSI_ERR_CONN_FAILED);
239 return error; 244 return error;
240} 245}
241 246
242static void 247static void
243iscsi_iser_cleanup_ctask(struct iscsi_conn *conn, struct iscsi_cmd_task *ctask) 248iscsi_iser_cleanup_task(struct iscsi_conn *conn, struct iscsi_task *task)
244{ 249{
245 struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; 250 struct iscsi_iser_task *iser_task = task->dd_data;
246
247 if (iser_ctask->status == ISER_TASK_STATUS_STARTED) {
248 iser_ctask->status = ISER_TASK_STATUS_COMPLETED;
249 iser_ctask_rdma_finalize(iser_ctask);
250 }
251}
252 251
253static struct iser_conn * 252 /* mgmt tasks do not need special cleanup */
254iscsi_iser_ib_conn_lookup(__u64 ep_handle) 253 if (!task->sc)
255{ 254 return;
256 struct iser_conn *ib_conn;
257 struct iser_conn *uib_conn = (struct iser_conn *)(unsigned long)ep_handle;
258 255
259 mutex_lock(&ig.connlist_mutex); 256 if (iser_task->status == ISER_TASK_STATUS_STARTED) {
260 list_for_each_entry(ib_conn, &ig.connlist, conn_list) { 257 iser_task->status = ISER_TASK_STATUS_COMPLETED;
261 if (ib_conn == uib_conn) { 258 iser_task_rdma_finalize(iser_task);
262 mutex_unlock(&ig.connlist_mutex);
263 return ib_conn;
264 }
265 } 259 }
266 mutex_unlock(&ig.connlist_mutex);
267 iser_err("no conn exists for eph %llx\n",(unsigned long long)ep_handle);
268 return NULL;
269} 260}
270 261
271static struct iscsi_cls_conn * 262static struct iscsi_cls_conn *
@@ -275,7 +266,7 @@ iscsi_iser_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
275 struct iscsi_cls_conn *cls_conn; 266 struct iscsi_cls_conn *cls_conn;
276 struct iscsi_iser_conn *iser_conn; 267 struct iscsi_iser_conn *iser_conn;
277 268
278 cls_conn = iscsi_conn_setup(cls_session, conn_idx); 269 cls_conn = iscsi_conn_setup(cls_session, sizeof(*iser_conn), conn_idx);
279 if (!cls_conn) 270 if (!cls_conn)
280 return NULL; 271 return NULL;
281 conn = cls_conn->dd_data; 272 conn = cls_conn->dd_data;
@@ -286,21 +277,11 @@ iscsi_iser_conn_create(struct iscsi_cls_session *cls_session, uint32_t conn_idx)
286 */ 277 */
287 conn->max_recv_dlength = 128; 278 conn->max_recv_dlength = 128;
288 279
289 iser_conn = kzalloc(sizeof(*iser_conn), GFP_KERNEL); 280 iser_conn = conn->dd_data;
290 if (!iser_conn)
291 goto conn_alloc_fail;
292
293 /* currently this is the only field which need to be initiated */
294 rwlock_init(&iser_conn->lock);
295
296 conn->dd_data = iser_conn; 281 conn->dd_data = iser_conn;
297 iser_conn->iscsi_conn = conn; 282 iser_conn->iscsi_conn = conn;
298 283
299 return cls_conn; 284 return cls_conn;
300
301conn_alloc_fail:
302 iscsi_conn_teardown(cls_conn);
303 return NULL;
304} 285}
305 286
306static void 287static void
@@ -308,11 +289,18 @@ iscsi_iser_conn_destroy(struct iscsi_cls_conn *cls_conn)
308{ 289{
309 struct iscsi_conn *conn = cls_conn->dd_data; 290 struct iscsi_conn *conn = cls_conn->dd_data;
310 struct iscsi_iser_conn *iser_conn = conn->dd_data; 291 struct iscsi_iser_conn *iser_conn = conn->dd_data;
292 struct iser_conn *ib_conn = iser_conn->ib_conn;
311 293
312 iscsi_conn_teardown(cls_conn); 294 iscsi_conn_teardown(cls_conn);
313 if (iser_conn->ib_conn) 295 /*
314 iser_conn->ib_conn->iser_conn = NULL; 296 * Userspace will normally call the stop callback and
315 kfree(iser_conn); 297 * already have freed the ib_conn, but if it goofed up then
298 * we free it here.
299 */
300 if (ib_conn) {
301 ib_conn->iser_conn = NULL;
302 iser_conn_put(ib_conn);
303 }
316} 304}
317 305
318static int 306static int
@@ -323,6 +311,7 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
323 struct iscsi_conn *conn = cls_conn->dd_data; 311 struct iscsi_conn *conn = cls_conn->dd_data;
324 struct iscsi_iser_conn *iser_conn; 312 struct iscsi_iser_conn *iser_conn;
325 struct iser_conn *ib_conn; 313 struct iser_conn *ib_conn;
314 struct iscsi_endpoint *ep;
326 int error; 315 int error;
327 316
328 error = iscsi_conn_bind(cls_session, cls_conn, is_leading); 317 error = iscsi_conn_bind(cls_session, cls_conn, is_leading);
@@ -331,12 +320,14 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
331 320
332 /* the transport ep handle comes from user space so it must be 321 /* the transport ep handle comes from user space so it must be
333 * verified against the global ib connections list */ 322 * verified against the global ib connections list */
334 ib_conn = iscsi_iser_ib_conn_lookup(transport_eph); 323 ep = iscsi_lookup_endpoint(transport_eph);
335 if (!ib_conn) { 324 if (!ep) {
336 iser_err("can't bind eph %llx\n", 325 iser_err("can't bind eph %llx\n",
337 (unsigned long long)transport_eph); 326 (unsigned long long)transport_eph);
338 return -EINVAL; 327 return -EINVAL;
339 } 328 }
329 ib_conn = ep->dd_data;
330
340 /* binds the iSER connection retrieved from the previously 331 /* binds the iSER connection retrieved from the previously
341 * connected ep_handle to the iSCSI layer connection. exchanges 332 * connected ep_handle to the iSCSI layer connection. exchanges
342 * connection pointers */ 333 * connection pointers */
@@ -344,10 +335,30 @@ iscsi_iser_conn_bind(struct iscsi_cls_session *cls_session,
344 iser_conn = conn->dd_data; 335 iser_conn = conn->dd_data;
345 ib_conn->iser_conn = iser_conn; 336 ib_conn->iser_conn = iser_conn;
346 iser_conn->ib_conn = ib_conn; 337 iser_conn->ib_conn = ib_conn;
338 iser_conn_get(ib_conn);
339 return 0;
340}
347 341
348 conn->recv_lock = &iser_conn->lock; 342static void
343iscsi_iser_conn_stop(struct iscsi_cls_conn *cls_conn, int flag)
344{
345 struct iscsi_conn *conn = cls_conn->dd_data;
346 struct iscsi_iser_conn *iser_conn = conn->dd_data;
347 struct iser_conn *ib_conn = iser_conn->ib_conn;
349 348
350 return 0; 349 /*
350 * Userspace may have goofed up and not bound the connection or
351 * might have only partially setup the connection.
352 */
353 if (ib_conn) {
354 iscsi_conn_stop(cls_conn, flag);
355 /*
356 * There is no unbind event so the stop callback
357 * must release the ref from the bind.
358 */
359 iser_conn_put(ib_conn);
360 }
361 iser_conn->ib_conn = NULL;
351} 362}
352 363
353static int 364static int
@@ -363,55 +374,75 @@ iscsi_iser_conn_start(struct iscsi_cls_conn *cls_conn)
363 return iscsi_conn_start(cls_conn); 374 return iscsi_conn_start(cls_conn);
364} 375}
365 376
366static struct iscsi_transport iscsi_iser_transport; 377static void iscsi_iser_session_destroy(struct iscsi_cls_session *cls_session)
378{
379 struct Scsi_Host *shost = iscsi_session_to_shost(cls_session);
380
381 iscsi_host_remove(shost);
382 iscsi_host_free(shost);
383}
367 384
368static struct iscsi_cls_session * 385static struct iscsi_cls_session *
369iscsi_iser_session_create(struct iscsi_transport *iscsit, 386iscsi_iser_session_create(struct iscsi_endpoint *ep,
370 struct scsi_transport_template *scsit, 387 uint16_t cmds_max, uint16_t qdepth,
371 uint16_t cmds_max, uint16_t qdepth, 388 uint32_t initial_cmdsn, uint32_t *hostno)
372 uint32_t initial_cmdsn, uint32_t *hostno)
373{ 389{
374 struct iscsi_cls_session *cls_session; 390 struct iscsi_cls_session *cls_session;
375 struct iscsi_session *session; 391 struct iscsi_session *session;
392 struct Scsi_Host *shost;
376 int i; 393 int i;
377 uint32_t hn; 394 struct iscsi_task *task;
378 struct iscsi_cmd_task *ctask; 395 struct iscsi_iser_task *iser_task;
379 struct iscsi_mgmt_task *mtask; 396 struct iser_conn *ib_conn;
380 struct iscsi_iser_cmd_task *iser_ctask; 397
381 struct iser_desc *desc; 398 shost = iscsi_host_alloc(&iscsi_iser_sht, 0, ISCSI_MAX_CMD_PER_LUN);
399 if (!shost)
400 return NULL;
401 shost->transportt = iscsi_iser_scsi_transport;
402 shost->max_lun = iscsi_max_lun;
403 shost->max_id = 0;
404 shost->max_channel = 0;
405 shost->max_cmd_len = 16;
406
407 /*
408 * older userspace tools (before 2.0-870) did not pass us
409 * the leading conn's ep so this will be NULL;
410 */
411 if (ep)
412 ib_conn = ep->dd_data;
413
414 if (iscsi_host_add(shost,
415 ep ? ib_conn->device->ib_device->dma_device : NULL))
416 goto free_host;
417 *hostno = shost->host_no;
382 418
383 /* 419 /*
384 * we do not support setting can_queue cmd_per_lun from userspace yet 420 * we do not support setting can_queue cmd_per_lun from userspace yet
385 * because we preallocate so many resources 421 * because we preallocate so many resources
386 */ 422 */
387 cls_session = iscsi_session_setup(iscsit, scsit, 423 cls_session = iscsi_session_setup(&iscsi_iser_transport, shost,
388 ISCSI_DEF_XMIT_CMDS_MAX, 424 ISCSI_DEF_XMIT_CMDS_MAX,
389 ISCSI_MAX_CMD_PER_LUN, 425 sizeof(struct iscsi_iser_task),
390 sizeof(struct iscsi_iser_cmd_task), 426 initial_cmdsn, 0);
391 sizeof(struct iser_desc),
392 initial_cmdsn, &hn);
393 if (!cls_session) 427 if (!cls_session)
394 return NULL; 428 goto remove_host;
395 429 session = cls_session->dd_data;
396 *hostno = hn;
397 session = class_to_transport_session(cls_session);
398 430
431 shost->can_queue = session->scsi_cmds_max;
399 /* libiscsi setup itts, data and pool so just set desc fields */ 432 /* libiscsi setup itts, data and pool so just set desc fields */
400 for (i = 0; i < session->cmds_max; i++) { 433 for (i = 0; i < session->cmds_max; i++) {
401 ctask = session->cmds[i]; 434 task = session->cmds[i];
402 iser_ctask = ctask->dd_data; 435 iser_task = task->dd_data;
403 ctask->hdr = (struct iscsi_cmd *)&iser_ctask->desc.iscsi_header; 436 task->hdr = (struct iscsi_cmd *)&iser_task->desc.iscsi_header;
404 ctask->hdr_max = sizeof(iser_ctask->desc.iscsi_header); 437 task->hdr_max = sizeof(iser_task->desc.iscsi_header);
405 }
406
407 for (i = 0; i < session->mgmtpool_max; i++) {
408 mtask = session->mgmt_cmds[i];
409 desc = mtask->dd_data;
410 mtask->hdr = &desc->iscsi_header;
411 desc->data = mtask->data;
412 } 438 }
413
414 return cls_session; 439 return cls_session;
440
441remove_host:
442 iscsi_host_remove(shost);
443free_host:
444 iscsi_host_free(shost);
445 return NULL;
415} 446}
416 447
417static int 448static int
@@ -484,34 +515,37 @@ iscsi_iser_conn_get_stats(struct iscsi_cls_conn *cls_conn, struct iscsi_stats *s
484 stats->custom[3].value = conn->fmr_unalign_cnt; 515 stats->custom[3].value = conn->fmr_unalign_cnt;
485} 516}
486 517
487static int 518static struct iscsi_endpoint *
488iscsi_iser_ep_connect(struct sockaddr *dst_addr, int non_blocking, 519iscsi_iser_ep_connect(struct sockaddr *dst_addr, int non_blocking)
489 __u64 *ep_handle)
490{ 520{
491 int err; 521 int err;
492 struct iser_conn *ib_conn; 522 struct iser_conn *ib_conn;
523 struct iscsi_endpoint *ep;
493 524
494 err = iser_conn_init(&ib_conn); 525 ep = iscsi_create_endpoint(sizeof(*ib_conn));
495 if (err) 526 if (!ep)
496 goto out; 527 return ERR_PTR(-ENOMEM);
497 528
498 err = iser_connect(ib_conn, NULL, (struct sockaddr_in *)dst_addr, non_blocking); 529 ib_conn = ep->dd_data;
499 if (!err) 530 ib_conn->ep = ep;
500 *ep_handle = (__u64)(unsigned long)ib_conn; 531 iser_conn_init(ib_conn);
501 532
502out: 533 err = iser_connect(ib_conn, NULL, (struct sockaddr_in *)dst_addr,
503 return err; 534 non_blocking);
535 if (err) {
536 iscsi_destroy_endpoint(ep);
537 return ERR_PTR(err);
538 }
539 return ep;
504} 540}
505 541
506static int 542static int
507iscsi_iser_ep_poll(__u64 ep_handle, int timeout_ms) 543iscsi_iser_ep_poll(struct iscsi_endpoint *ep, int timeout_ms)
508{ 544{
509 struct iser_conn *ib_conn = iscsi_iser_ib_conn_lookup(ep_handle); 545 struct iser_conn *ib_conn;
510 int rc; 546 int rc;
511 547
512 if (!ib_conn) 548 ib_conn = ep->dd_data;
513 return -EINVAL;
514
515 rc = wait_event_interruptible_timeout(ib_conn->wait, 549 rc = wait_event_interruptible_timeout(ib_conn->wait,
516 ib_conn->state == ISER_CONN_UP, 550 ib_conn->state == ISER_CONN_UP,
517 msecs_to_jiffies(timeout_ms)); 551 msecs_to_jiffies(timeout_ms));
@@ -533,13 +567,21 @@ iscsi_iser_ep_poll(__u64 ep_handle, int timeout_ms)
533} 567}
534 568
535static void 569static void
536iscsi_iser_ep_disconnect(__u64 ep_handle) 570iscsi_iser_ep_disconnect(struct iscsi_endpoint *ep)
537{ 571{
538 struct iser_conn *ib_conn; 572 struct iser_conn *ib_conn;
539 573
540 ib_conn = iscsi_iser_ib_conn_lookup(ep_handle); 574 ib_conn = ep->dd_data;
541 if (!ib_conn) 575 if (ib_conn->iser_conn)
542 return; 576 /*
577 * Must suspend xmit path if the ep is bound to the
578 * iscsi_conn, so we know we are not accessing the ib_conn
579 * when we free it.
580 *
581 * This may not be bound if the ep poll failed.
582 */
583 iscsi_suspend_tx(ib_conn->iser_conn->iscsi_conn);
584
543 585
544 iser_err("ib conn %p state %d\n",ib_conn, ib_conn->state); 586 iser_err("ib conn %p state %d\n",ib_conn, ib_conn->state);
545 iser_conn_terminate(ib_conn); 587 iser_conn_terminate(ib_conn);
@@ -550,7 +592,6 @@ static struct scsi_host_template iscsi_iser_sht = {
550 .name = "iSCSI Initiator over iSER, v." DRV_VER, 592 .name = "iSCSI Initiator over iSER, v." DRV_VER,
551 .queuecommand = iscsi_queuecommand, 593 .queuecommand = iscsi_queuecommand,
552 .change_queue_depth = iscsi_change_queue_depth, 594 .change_queue_depth = iscsi_change_queue_depth,
553 .can_queue = ISCSI_DEF_XMIT_CMDS_MAX - 1,
554 .sg_tablesize = ISCSI_ISER_SG_TABLESIZE, 595 .sg_tablesize = ISCSI_ISER_SG_TABLESIZE,
555 .max_sectors = 1024, 596 .max_sectors = 1024,
556 .cmd_per_lun = ISCSI_MAX_CMD_PER_LUN, 597 .cmd_per_lun = ISCSI_MAX_CMD_PER_LUN,
@@ -584,17 +625,14 @@ static struct iscsi_transport iscsi_iser_transport = {
584 ISCSI_USERNAME | ISCSI_PASSWORD | 625 ISCSI_USERNAME | ISCSI_PASSWORD |
585 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN | 626 ISCSI_USERNAME_IN | ISCSI_PASSWORD_IN |
586 ISCSI_FAST_ABORT | ISCSI_ABORT_TMO | 627 ISCSI_FAST_ABORT | ISCSI_ABORT_TMO |
587 ISCSI_PING_TMO | ISCSI_RECV_TMO, 628 ISCSI_PING_TMO | ISCSI_RECV_TMO |
629 ISCSI_IFACE_NAME | ISCSI_INITIATOR_NAME,
588 .host_param_mask = ISCSI_HOST_HWADDRESS | 630 .host_param_mask = ISCSI_HOST_HWADDRESS |
589 ISCSI_HOST_NETDEV_NAME | 631 ISCSI_HOST_NETDEV_NAME |
590 ISCSI_HOST_INITIATOR_NAME, 632 ISCSI_HOST_INITIATOR_NAME,
591 .host_template = &iscsi_iser_sht,
592 .conndata_size = sizeof(struct iscsi_conn),
593 .max_lun = ISCSI_ISER_MAX_LUN,
594 .max_cmd_len = ISCSI_ISER_MAX_CMD_LEN,
595 /* session management */ 633 /* session management */
596 .create_session = iscsi_iser_session_create, 634 .create_session = iscsi_iser_session_create,
597 .destroy_session = iscsi_session_teardown, 635 .destroy_session = iscsi_iser_session_destroy,
598 /* connection management */ 636 /* connection management */
599 .create_conn = iscsi_iser_conn_create, 637 .create_conn = iscsi_iser_conn_create,
600 .bind_conn = iscsi_iser_conn_bind, 638 .bind_conn = iscsi_iser_conn_bind,
@@ -603,17 +641,16 @@ static struct iscsi_transport iscsi_iser_transport = {
603 .get_conn_param = iscsi_conn_get_param, 641 .get_conn_param = iscsi_conn_get_param,
604 .get_session_param = iscsi_session_get_param, 642 .get_session_param = iscsi_session_get_param,
605 .start_conn = iscsi_iser_conn_start, 643 .start_conn = iscsi_iser_conn_start,
606 .stop_conn = iscsi_conn_stop, 644 .stop_conn = iscsi_iser_conn_stop,
607 /* iscsi host params */ 645 /* iscsi host params */
608 .get_host_param = iscsi_host_get_param, 646 .get_host_param = iscsi_host_get_param,
609 .set_host_param = iscsi_host_set_param, 647 .set_host_param = iscsi_host_set_param,
610 /* IO */ 648 /* IO */
611 .send_pdu = iscsi_conn_send_pdu, 649 .send_pdu = iscsi_conn_send_pdu,
612 .get_stats = iscsi_iser_conn_get_stats, 650 .get_stats = iscsi_iser_conn_get_stats,
613 .init_cmd_task = iscsi_iser_cmd_init, 651 .init_task = iscsi_iser_task_init,
614 .xmit_cmd_task = iscsi_iser_ctask_xmit, 652 .xmit_task = iscsi_iser_task_xmit,
615 .xmit_mgmt_task = iscsi_iser_mtask_xmit, 653 .cleanup_task = iscsi_iser_cleanup_task,
616 .cleanup_cmd_task = iscsi_iser_cleanup_ctask,
617 /* recovery */ 654 /* recovery */
618 .session_recovery_timedout = iscsi_session_recovery_timedout, 655 .session_recovery_timedout = iscsi_session_recovery_timedout,
619 656
@@ -633,8 +670,6 @@ static int __init iser_init(void)
633 return -EINVAL; 670 return -EINVAL;
634 } 671 }
635 672
636 iscsi_iser_transport.max_lun = iscsi_max_lun;
637
638 memset(&ig, 0, sizeof(struct iser_global)); 673 memset(&ig, 0, sizeof(struct iser_global));
639 674
640 ig.desc_cache = kmem_cache_create("iser_descriptors", 675 ig.desc_cache = kmem_cache_create("iser_descriptors",
@@ -650,7 +685,9 @@ static int __init iser_init(void)
650 mutex_init(&ig.connlist_mutex); 685 mutex_init(&ig.connlist_mutex);
651 INIT_LIST_HEAD(&ig.connlist); 686 INIT_LIST_HEAD(&ig.connlist);
652 687
653 if (!iscsi_register_transport(&iscsi_iser_transport)) { 688 iscsi_iser_scsi_transport = iscsi_register_transport(
689 &iscsi_iser_transport);
690 if (!iscsi_iser_scsi_transport) {
654 iser_err("iscsi_register_transport failed\n"); 691 iser_err("iscsi_register_transport failed\n");
655 err = -EINVAL; 692 err = -EINVAL;
656 goto register_transport_failure; 693 goto register_transport_failure;
diff --git a/drivers/infiniband/ulp/iser/iscsi_iser.h b/drivers/infiniband/ulp/iser/iscsi_iser.h
index a8c1b300e34d..81a82628a5f1 100644
--- a/drivers/infiniband/ulp/iser/iscsi_iser.h
+++ b/drivers/infiniband/ulp/iser/iscsi_iser.h
@@ -36,8 +36,6 @@
36 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 36 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
37 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 37 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 * SOFTWARE. 38 * SOFTWARE.
39 *
40 * $Id: iscsi_iser.h 7051 2006-05-10 12:29:11Z ogerlitz $
41 */ 39 */
42#ifndef __ISCSI_ISER_H__ 40#ifndef __ISCSI_ISER_H__
43#define __ISCSI_ISER_H__ 41#define __ISCSI_ISER_H__
@@ -96,7 +94,6 @@
96 /* support upto 512KB in one RDMA */ 94 /* support upto 512KB in one RDMA */
97#define ISCSI_ISER_SG_TABLESIZE (0x80000 >> SHIFT_4K) 95#define ISCSI_ISER_SG_TABLESIZE (0x80000 >> SHIFT_4K)
98#define ISCSI_ISER_MAX_LUN 256 96#define ISCSI_ISER_MAX_LUN 256
99#define ISCSI_ISER_MAX_CMD_LEN 16
100 97
101/* QP settings */ 98/* QP settings */
102/* Maximal bounds on received asynchronous PDUs */ 99/* Maximal bounds on received asynchronous PDUs */
@@ -174,7 +171,8 @@ struct iser_data_buf {
174/* fwd declarations */ 171/* fwd declarations */
175struct iser_device; 172struct iser_device;
176struct iscsi_iser_conn; 173struct iscsi_iser_conn;
177struct iscsi_iser_cmd_task; 174struct iscsi_iser_task;
175struct iscsi_endpoint;
178 176
179struct iser_mem_reg { 177struct iser_mem_reg {
180 u32 lkey; 178 u32 lkey;
@@ -198,7 +196,7 @@ struct iser_regd_buf {
198#define MAX_REGD_BUF_VECTOR_LEN 2 196#define MAX_REGD_BUF_VECTOR_LEN 2
199 197
200struct iser_dto { 198struct iser_dto {
201 struct iscsi_iser_cmd_task *ctask; 199 struct iscsi_iser_task *task;
202 struct iser_conn *ib_conn; 200 struct iser_conn *ib_conn;
203 int notify_enable; 201 int notify_enable;
204 202
@@ -242,7 +240,9 @@ struct iser_device {
242 240
243struct iser_conn { 241struct iser_conn {
244 struct iscsi_iser_conn *iser_conn; /* iser conn for upcalls */ 242 struct iscsi_iser_conn *iser_conn; /* iser conn for upcalls */
243 struct iscsi_endpoint *ep;
245 enum iser_ib_conn_state state; /* rdma connection state */ 244 enum iser_ib_conn_state state; /* rdma connection state */
245 atomic_t refcount;
246 spinlock_t lock; /* used for state changes */ 246 spinlock_t lock; /* used for state changes */
247 struct iser_device *device; /* device context */ 247 struct iser_device *device; /* device context */
248 struct rdma_cm_id *cma_id; /* CMA ID */ 248 struct rdma_cm_id *cma_id; /* CMA ID */
@@ -261,11 +261,9 @@ struct iser_conn {
261struct iscsi_iser_conn { 261struct iscsi_iser_conn {
262 struct iscsi_conn *iscsi_conn;/* ptr to iscsi conn */ 262 struct iscsi_conn *iscsi_conn;/* ptr to iscsi conn */
263 struct iser_conn *ib_conn; /* iSER IB conn */ 263 struct iser_conn *ib_conn; /* iSER IB conn */
264
265 rwlock_t lock;
266}; 264};
267 265
268struct iscsi_iser_cmd_task { 266struct iscsi_iser_task {
269 struct iser_desc desc; 267 struct iser_desc desc;
270 struct iscsi_iser_conn *iser_conn; 268 struct iscsi_iser_conn *iser_conn;
271 enum iser_task_status status; 269 enum iser_task_status status;
@@ -298,22 +296,26 @@ extern int iser_debug_level;
298/* allocate connection resources needed for rdma functionality */ 296/* allocate connection resources needed for rdma functionality */
299int iser_conn_set_full_featured_mode(struct iscsi_conn *conn); 297int iser_conn_set_full_featured_mode(struct iscsi_conn *conn);
300 298
301int iser_send_control(struct iscsi_conn *conn, 299int iser_send_control(struct iscsi_conn *conn,
302 struct iscsi_mgmt_task *mtask); 300 struct iscsi_task *task);
303 301
304int iser_send_command(struct iscsi_conn *conn, 302int iser_send_command(struct iscsi_conn *conn,
305 struct iscsi_cmd_task *ctask); 303 struct iscsi_task *task);
306 304
307int iser_send_data_out(struct iscsi_conn *conn, 305int iser_send_data_out(struct iscsi_conn *conn,
308 struct iscsi_cmd_task *ctask, 306 struct iscsi_task *task,
309 struct iscsi_data *hdr); 307 struct iscsi_data *hdr);
310 308
311void iscsi_iser_recv(struct iscsi_conn *conn, 309void iscsi_iser_recv(struct iscsi_conn *conn,
312 struct iscsi_hdr *hdr, 310 struct iscsi_hdr *hdr,
313 char *rx_data, 311 char *rx_data,
314 int rx_data_len); 312 int rx_data_len);
315 313
316int iser_conn_init(struct iser_conn **ib_conn); 314void iser_conn_init(struct iser_conn *ib_conn);
315
316void iser_conn_get(struct iser_conn *ib_conn);
317
318void iser_conn_put(struct iser_conn *ib_conn);
317 319
318void iser_conn_terminate(struct iser_conn *ib_conn); 320void iser_conn_terminate(struct iser_conn *ib_conn);
319 321
@@ -322,9 +324,9 @@ void iser_rcv_completion(struct iser_desc *desc,
322 324
323void iser_snd_completion(struct iser_desc *desc); 325void iser_snd_completion(struct iser_desc *desc);
324 326
325void iser_ctask_rdma_init(struct iscsi_iser_cmd_task *ctask); 327void iser_task_rdma_init(struct iscsi_iser_task *task);
326 328
327void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *ctask); 329void iser_task_rdma_finalize(struct iscsi_iser_task *task);
328 330
329void iser_dto_buffs_release(struct iser_dto *dto); 331void iser_dto_buffs_release(struct iser_dto *dto);
330 332
@@ -334,10 +336,10 @@ void iser_reg_single(struct iser_device *device,
334 struct iser_regd_buf *regd_buf, 336 struct iser_regd_buf *regd_buf,
335 enum dma_data_direction direction); 337 enum dma_data_direction direction);
336 338
337void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *ctask, 339void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_task *task,
338 enum iser_data_dir cmd_dir); 340 enum iser_data_dir cmd_dir);
339 341
340int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *ctask, 342int iser_reg_rdma_mem(struct iscsi_iser_task *task,
341 enum iser_data_dir cmd_dir); 343 enum iser_data_dir cmd_dir);
342 344
343int iser_connect(struct iser_conn *ib_conn, 345int iser_connect(struct iser_conn *ib_conn,
@@ -357,10 +359,10 @@ int iser_post_send(struct iser_desc *tx_desc);
357int iser_conn_state_comp(struct iser_conn *ib_conn, 359int iser_conn_state_comp(struct iser_conn *ib_conn,
358 enum iser_ib_conn_state comp); 360 enum iser_ib_conn_state comp);
359 361
360int iser_dma_map_task_data(struct iscsi_iser_cmd_task *iser_ctask, 362int iser_dma_map_task_data(struct iscsi_iser_task *iser_task,
361 struct iser_data_buf *data, 363 struct iser_data_buf *data,
362 enum iser_data_dir iser_dir, 364 enum iser_data_dir iser_dir,
363 enum dma_data_direction dma_dir); 365 enum dma_data_direction dma_dir);
364 366
365void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *iser_ctask); 367void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task);
366#endif 368#endif
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c
index 08dc81c46f41..cdd283189047 100644
--- a/drivers/infiniband/ulp/iser/iser_initiator.c
+++ b/drivers/infiniband/ulp/iser/iser_initiator.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: iser_initiator.c 6964 2006-05-07 11:11:43Z ogerlitz $
33 */ 31 */
34#include <linux/kernel.h> 32#include <linux/kernel.h>
35#include <linux/slab.h> 33#include <linux/slab.h>
@@ -66,46 +64,46 @@ static void iser_dto_add_regd_buff(struct iser_dto *dto,
66 64
67/* Register user buffer memory and initialize passive rdma 65/* Register user buffer memory and initialize passive rdma
68 * dto descriptor. Total data size is stored in 66 * dto descriptor. Total data size is stored in
69 * iser_ctask->data[ISER_DIR_IN].data_len 67 * iser_task->data[ISER_DIR_IN].data_len
70 */ 68 */
71static int iser_prepare_read_cmd(struct iscsi_cmd_task *ctask, 69static int iser_prepare_read_cmd(struct iscsi_task *task,
72 unsigned int edtl) 70 unsigned int edtl)
73 71
74{ 72{
75 struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; 73 struct iscsi_iser_task *iser_task = task->dd_data;
76 struct iser_regd_buf *regd_buf; 74 struct iser_regd_buf *regd_buf;
77 int err; 75 int err;
78 struct iser_hdr *hdr = &iser_ctask->desc.iser_header; 76 struct iser_hdr *hdr = &iser_task->desc.iser_header;
79 struct iser_data_buf *buf_in = &iser_ctask->data[ISER_DIR_IN]; 77 struct iser_data_buf *buf_in = &iser_task->data[ISER_DIR_IN];
80 78
81 err = iser_dma_map_task_data(iser_ctask, 79 err = iser_dma_map_task_data(iser_task,
82 buf_in, 80 buf_in,
83 ISER_DIR_IN, 81 ISER_DIR_IN,
84 DMA_FROM_DEVICE); 82 DMA_FROM_DEVICE);
85 if (err) 83 if (err)
86 return err; 84 return err;
87 85
88 if (edtl > iser_ctask->data[ISER_DIR_IN].data_len) { 86 if (edtl > iser_task->data[ISER_DIR_IN].data_len) {
89 iser_err("Total data length: %ld, less than EDTL: " 87 iser_err("Total data length: %ld, less than EDTL: "
90 "%d, in READ cmd BHS itt: %d, conn: 0x%p\n", 88 "%d, in READ cmd BHS itt: %d, conn: 0x%p\n",
91 iser_ctask->data[ISER_DIR_IN].data_len, edtl, 89 iser_task->data[ISER_DIR_IN].data_len, edtl,
92 ctask->itt, iser_ctask->iser_conn); 90 task->itt, iser_task->iser_conn);
93 return -EINVAL; 91 return -EINVAL;
94 } 92 }
95 93
96 err = iser_reg_rdma_mem(iser_ctask,ISER_DIR_IN); 94 err = iser_reg_rdma_mem(iser_task,ISER_DIR_IN);
97 if (err) { 95 if (err) {
98 iser_err("Failed to set up Data-IN RDMA\n"); 96 iser_err("Failed to set up Data-IN RDMA\n");
99 return err; 97 return err;
100 } 98 }
101 regd_buf = &iser_ctask->rdma_regd[ISER_DIR_IN]; 99 regd_buf = &iser_task->rdma_regd[ISER_DIR_IN];
102 100
103 hdr->flags |= ISER_RSV; 101 hdr->flags |= ISER_RSV;
104 hdr->read_stag = cpu_to_be32(regd_buf->reg.rkey); 102 hdr->read_stag = cpu_to_be32(regd_buf->reg.rkey);
105 hdr->read_va = cpu_to_be64(regd_buf->reg.va); 103 hdr->read_va = cpu_to_be64(regd_buf->reg.va);
106 104
107 iser_dbg("Cmd itt:%d READ tags RKEY:%#.4X VA:%#llX\n", 105 iser_dbg("Cmd itt:%d READ tags RKEY:%#.4X VA:%#llX\n",
108 ctask->itt, regd_buf->reg.rkey, 106 task->itt, regd_buf->reg.rkey,
109 (unsigned long long)regd_buf->reg.va); 107 (unsigned long long)regd_buf->reg.va);
110 108
111 return 0; 109 return 0;
@@ -113,43 +111,43 @@ static int iser_prepare_read_cmd(struct iscsi_cmd_task *ctask,
113 111
114/* Register user buffer memory and initialize passive rdma 112/* Register user buffer memory and initialize passive rdma
115 * dto descriptor. Total data size is stored in 113 * dto descriptor. Total data size is stored in
116 * ctask->data[ISER_DIR_OUT].data_len 114 * task->data[ISER_DIR_OUT].data_len
117 */ 115 */
118static int 116static int
119iser_prepare_write_cmd(struct iscsi_cmd_task *ctask, 117iser_prepare_write_cmd(struct iscsi_task *task,
120 unsigned int imm_sz, 118 unsigned int imm_sz,
121 unsigned int unsol_sz, 119 unsigned int unsol_sz,
122 unsigned int edtl) 120 unsigned int edtl)
123{ 121{
124 struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; 122 struct iscsi_iser_task *iser_task = task->dd_data;
125 struct iser_regd_buf *regd_buf; 123 struct iser_regd_buf *regd_buf;
126 int err; 124 int err;
127 struct iser_dto *send_dto = &iser_ctask->desc.dto; 125 struct iser_dto *send_dto = &iser_task->desc.dto;
128 struct iser_hdr *hdr = &iser_ctask->desc.iser_header; 126 struct iser_hdr *hdr = &iser_task->desc.iser_header;
129 struct iser_data_buf *buf_out = &iser_ctask->data[ISER_DIR_OUT]; 127 struct iser_data_buf *buf_out = &iser_task->data[ISER_DIR_OUT];
130 128
131 err = iser_dma_map_task_data(iser_ctask, 129 err = iser_dma_map_task_data(iser_task,
132 buf_out, 130 buf_out,
133 ISER_DIR_OUT, 131 ISER_DIR_OUT,
134 DMA_TO_DEVICE); 132 DMA_TO_DEVICE);
135 if (err) 133 if (err)
136 return err; 134 return err;
137 135
138 if (edtl > iser_ctask->data[ISER_DIR_OUT].data_len) { 136 if (edtl > iser_task->data[ISER_DIR_OUT].data_len) {
139 iser_err("Total data length: %ld, less than EDTL: %d, " 137 iser_err("Total data length: %ld, less than EDTL: %d, "
140 "in WRITE cmd BHS itt: %d, conn: 0x%p\n", 138 "in WRITE cmd BHS itt: %d, conn: 0x%p\n",
141 iser_ctask->data[ISER_DIR_OUT].data_len, 139 iser_task->data[ISER_DIR_OUT].data_len,
142 edtl, ctask->itt, ctask->conn); 140 edtl, task->itt, task->conn);
143 return -EINVAL; 141 return -EINVAL;
144 } 142 }
145 143
146 err = iser_reg_rdma_mem(iser_ctask,ISER_DIR_OUT); 144 err = iser_reg_rdma_mem(iser_task,ISER_DIR_OUT);
147 if (err != 0) { 145 if (err != 0) {
148 iser_err("Failed to register write cmd RDMA mem\n"); 146 iser_err("Failed to register write cmd RDMA mem\n");
149 return err; 147 return err;
150 } 148 }
151 149
152 regd_buf = &iser_ctask->rdma_regd[ISER_DIR_OUT]; 150 regd_buf = &iser_task->rdma_regd[ISER_DIR_OUT];
153 151
154 if (unsol_sz < edtl) { 152 if (unsol_sz < edtl) {
155 hdr->flags |= ISER_WSV; 153 hdr->flags |= ISER_WSV;
@@ -158,13 +156,13 @@ iser_prepare_write_cmd(struct iscsi_cmd_task *ctask,
158 156
159 iser_dbg("Cmd itt:%d, WRITE tags, RKEY:%#.4X " 157 iser_dbg("Cmd itt:%d, WRITE tags, RKEY:%#.4X "
160 "VA:%#llX + unsol:%d\n", 158 "VA:%#llX + unsol:%d\n",
161 ctask->itt, regd_buf->reg.rkey, 159 task->itt, regd_buf->reg.rkey,
162 (unsigned long long)regd_buf->reg.va, unsol_sz); 160 (unsigned long long)regd_buf->reg.va, unsol_sz);
163 } 161 }
164 162
165 if (imm_sz > 0) { 163 if (imm_sz > 0) {
166 iser_dbg("Cmd itt:%d, WRITE, adding imm.data sz: %d\n", 164 iser_dbg("Cmd itt:%d, WRITE, adding imm.data sz: %d\n",
167 ctask->itt, imm_sz); 165 task->itt, imm_sz);
168 iser_dto_add_regd_buff(send_dto, 166 iser_dto_add_regd_buff(send_dto,
169 regd_buf, 167 regd_buf,
170 0, 168 0,
@@ -316,38 +314,38 @@ iser_check_xmit(struct iscsi_conn *conn, void *task)
316/** 314/**
317 * iser_send_command - send command PDU 315 * iser_send_command - send command PDU
318 */ 316 */
319int iser_send_command(struct iscsi_conn *conn, 317int iser_send_command(struct iscsi_conn *conn,
320 struct iscsi_cmd_task *ctask) 318 struct iscsi_task *task)
321{ 319{
322 struct iscsi_iser_conn *iser_conn = conn->dd_data; 320 struct iscsi_iser_conn *iser_conn = conn->dd_data;
323 struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; 321 struct iscsi_iser_task *iser_task = task->dd_data;
324 struct iser_dto *send_dto = NULL; 322 struct iser_dto *send_dto = NULL;
325 unsigned long edtl; 323 unsigned long edtl;
326 int err = 0; 324 int err = 0;
327 struct iser_data_buf *data_buf; 325 struct iser_data_buf *data_buf;
328 326
329 struct iscsi_cmd *hdr = ctask->hdr; 327 struct iscsi_cmd *hdr = task->hdr;
330 struct scsi_cmnd *sc = ctask->sc; 328 struct scsi_cmnd *sc = task->sc;
331 329
332 if (!iser_conn_state_comp(iser_conn->ib_conn, ISER_CONN_UP)) { 330 if (!iser_conn_state_comp(iser_conn->ib_conn, ISER_CONN_UP)) {
333 iser_err("Failed to send, conn: 0x%p is not up\n", iser_conn->ib_conn); 331 iser_err("Failed to send, conn: 0x%p is not up\n", iser_conn->ib_conn);
334 return -EPERM; 332 return -EPERM;
335 } 333 }
336 if (iser_check_xmit(conn, ctask)) 334 if (iser_check_xmit(conn, task))
337 return -ENOBUFS; 335 return -ENOBUFS;
338 336
339 edtl = ntohl(hdr->data_length); 337 edtl = ntohl(hdr->data_length);
340 338
341 /* build the tx desc regd header and add it to the tx desc dto */ 339 /* build the tx desc regd header and add it to the tx desc dto */
342 iser_ctask->desc.type = ISCSI_TX_SCSI_COMMAND; 340 iser_task->desc.type = ISCSI_TX_SCSI_COMMAND;
343 send_dto = &iser_ctask->desc.dto; 341 send_dto = &iser_task->desc.dto;
344 send_dto->ctask = iser_ctask; 342 send_dto->task = iser_task;
345 iser_create_send_desc(iser_conn, &iser_ctask->desc); 343 iser_create_send_desc(iser_conn, &iser_task->desc);
346 344
347 if (hdr->flags & ISCSI_FLAG_CMD_READ) 345 if (hdr->flags & ISCSI_FLAG_CMD_READ)
348 data_buf = &iser_ctask->data[ISER_DIR_IN]; 346 data_buf = &iser_task->data[ISER_DIR_IN];
349 else 347 else
350 data_buf = &iser_ctask->data[ISER_DIR_OUT]; 348 data_buf = &iser_task->data[ISER_DIR_OUT];
351 349
352 if (scsi_sg_count(sc)) { /* using a scatter list */ 350 if (scsi_sg_count(sc)) { /* using a scatter list */
353 data_buf->buf = scsi_sglist(sc); 351 data_buf->buf = scsi_sglist(sc);
@@ -357,15 +355,15 @@ int iser_send_command(struct iscsi_conn *conn,
357 data_buf->data_len = scsi_bufflen(sc); 355 data_buf->data_len = scsi_bufflen(sc);
358 356
359 if (hdr->flags & ISCSI_FLAG_CMD_READ) { 357 if (hdr->flags & ISCSI_FLAG_CMD_READ) {
360 err = iser_prepare_read_cmd(ctask, edtl); 358 err = iser_prepare_read_cmd(task, edtl);
361 if (err) 359 if (err)
362 goto send_command_error; 360 goto send_command_error;
363 } 361 }
364 if (hdr->flags & ISCSI_FLAG_CMD_WRITE) { 362 if (hdr->flags & ISCSI_FLAG_CMD_WRITE) {
365 err = iser_prepare_write_cmd(ctask, 363 err = iser_prepare_write_cmd(task,
366 ctask->imm_count, 364 task->imm_count,
367 ctask->imm_count + 365 task->imm_count +
368 ctask->unsol_count, 366 task->unsol_count,
369 edtl); 367 edtl);
370 if (err) 368 if (err)
371 goto send_command_error; 369 goto send_command_error;
@@ -380,27 +378,27 @@ int iser_send_command(struct iscsi_conn *conn,
380 goto send_command_error; 378 goto send_command_error;
381 } 379 }
382 380
383 iser_ctask->status = ISER_TASK_STATUS_STARTED; 381 iser_task->status = ISER_TASK_STATUS_STARTED;
384 382
385 err = iser_post_send(&iser_ctask->desc); 383 err = iser_post_send(&iser_task->desc);
386 if (!err) 384 if (!err)
387 return 0; 385 return 0;
388 386
389send_command_error: 387send_command_error:
390 iser_dto_buffs_release(send_dto); 388 iser_dto_buffs_release(send_dto);
391 iser_err("conn %p failed ctask->itt %d err %d\n",conn, ctask->itt, err); 389 iser_err("conn %p failed task->itt %d err %d\n",conn, task->itt, err);
392 return err; 390 return err;
393} 391}
394 392
395/** 393/**
396 * iser_send_data_out - send data out PDU 394 * iser_send_data_out - send data out PDU
397 */ 395 */
398int iser_send_data_out(struct iscsi_conn *conn, 396int iser_send_data_out(struct iscsi_conn *conn,
399 struct iscsi_cmd_task *ctask, 397 struct iscsi_task *task,
400 struct iscsi_data *hdr) 398 struct iscsi_data *hdr)
401{ 399{
402 struct iscsi_iser_conn *iser_conn = conn->dd_data; 400 struct iscsi_iser_conn *iser_conn = conn->dd_data;
403 struct iscsi_iser_cmd_task *iser_ctask = ctask->dd_data; 401 struct iscsi_iser_task *iser_task = task->dd_data;
404 struct iser_desc *tx_desc = NULL; 402 struct iser_desc *tx_desc = NULL;
405 struct iser_dto *send_dto = NULL; 403 struct iser_dto *send_dto = NULL;
406 unsigned long buf_offset; 404 unsigned long buf_offset;
@@ -413,7 +411,7 @@ int iser_send_data_out(struct iscsi_conn *conn,
413 return -EPERM; 411 return -EPERM;
414 } 412 }
415 413
416 if (iser_check_xmit(conn, ctask)) 414 if (iser_check_xmit(conn, task))
417 return -ENOBUFS; 415 return -ENOBUFS;
418 416
419 itt = (__force uint32_t)hdr->itt; 417 itt = (__force uint32_t)hdr->itt;
@@ -434,7 +432,7 @@ int iser_send_data_out(struct iscsi_conn *conn,
434 432
435 /* build the tx desc regd header and add it to the tx desc dto */ 433 /* build the tx desc regd header and add it to the tx desc dto */
436 send_dto = &tx_desc->dto; 434 send_dto = &tx_desc->dto;
437 send_dto->ctask = iser_ctask; 435 send_dto->task = iser_task;
438 iser_create_send_desc(iser_conn, tx_desc); 436 iser_create_send_desc(iser_conn, tx_desc);
439 437
440 iser_reg_single(iser_conn->ib_conn->device, 438 iser_reg_single(iser_conn->ib_conn->device,
@@ -442,15 +440,15 @@ int iser_send_data_out(struct iscsi_conn *conn,
442 440
443 /* all data was registered for RDMA, we can use the lkey */ 441 /* all data was registered for RDMA, we can use the lkey */
444 iser_dto_add_regd_buff(send_dto, 442 iser_dto_add_regd_buff(send_dto,
445 &iser_ctask->rdma_regd[ISER_DIR_OUT], 443 &iser_task->rdma_regd[ISER_DIR_OUT],
446 buf_offset, 444 buf_offset,
447 data_seg_len); 445 data_seg_len);
448 446
449 if (buf_offset + data_seg_len > iser_ctask->data[ISER_DIR_OUT].data_len) { 447 if (buf_offset + data_seg_len > iser_task->data[ISER_DIR_OUT].data_len) {
450 iser_err("Offset:%ld & DSL:%ld in Data-Out " 448 iser_err("Offset:%ld & DSL:%ld in Data-Out "
451 "inconsistent with total len:%ld, itt:%d\n", 449 "inconsistent with total len:%ld, itt:%d\n",
452 buf_offset, data_seg_len, 450 buf_offset, data_seg_len,
453 iser_ctask->data[ISER_DIR_OUT].data_len, itt); 451 iser_task->data[ISER_DIR_OUT].data_len, itt);
454 err = -EINVAL; 452 err = -EINVAL;
455 goto send_data_out_error; 453 goto send_data_out_error;
456 } 454 }
@@ -470,10 +468,11 @@ send_data_out_error:
470} 468}
471 469
472int iser_send_control(struct iscsi_conn *conn, 470int iser_send_control(struct iscsi_conn *conn,
473 struct iscsi_mgmt_task *mtask) 471 struct iscsi_task *task)
474{ 472{
475 struct iscsi_iser_conn *iser_conn = conn->dd_data; 473 struct iscsi_iser_conn *iser_conn = conn->dd_data;
476 struct iser_desc *mdesc = mtask->dd_data; 474 struct iscsi_iser_task *iser_task = task->dd_data;
475 struct iser_desc *mdesc = &iser_task->desc;
477 struct iser_dto *send_dto = NULL; 476 struct iser_dto *send_dto = NULL;
478 unsigned long data_seg_len; 477 unsigned long data_seg_len;
479 int err = 0; 478 int err = 0;
@@ -485,27 +484,27 @@ int iser_send_control(struct iscsi_conn *conn,
485 return -EPERM; 484 return -EPERM;
486 } 485 }
487 486
488 if (iser_check_xmit(conn,mtask)) 487 if (iser_check_xmit(conn, task))
489 return -ENOBUFS; 488 return -ENOBUFS;
490 489
491 /* build the tx desc regd header and add it to the tx desc dto */ 490 /* build the tx desc regd header and add it to the tx desc dto */
492 mdesc->type = ISCSI_TX_CONTROL; 491 mdesc->type = ISCSI_TX_CONTROL;
493 send_dto = &mdesc->dto; 492 send_dto = &mdesc->dto;
494 send_dto->ctask = NULL; 493 send_dto->task = NULL;
495 iser_create_send_desc(iser_conn, mdesc); 494 iser_create_send_desc(iser_conn, mdesc);
496 495
497 device = iser_conn->ib_conn->device; 496 device = iser_conn->ib_conn->device;
498 497
499 iser_reg_single(device, send_dto->regd[0], DMA_TO_DEVICE); 498 iser_reg_single(device, send_dto->regd[0], DMA_TO_DEVICE);
500 499
501 data_seg_len = ntoh24(mtask->hdr->dlength); 500 data_seg_len = ntoh24(task->hdr->dlength);
502 501
503 if (data_seg_len > 0) { 502 if (data_seg_len > 0) {
504 regd_buf = &mdesc->data_regd_buf; 503 regd_buf = &mdesc->data_regd_buf;
505 memset(regd_buf, 0, sizeof(struct iser_regd_buf)); 504 memset(regd_buf, 0, sizeof(struct iser_regd_buf));
506 regd_buf->device = device; 505 regd_buf->device = device;
507 regd_buf->virt_addr = mtask->data; 506 regd_buf->virt_addr = task->data;
508 regd_buf->data_size = mtask->data_count; 507 regd_buf->data_size = task->data_count;
509 iser_reg_single(device, regd_buf, 508 iser_reg_single(device, regd_buf,
510 DMA_TO_DEVICE); 509 DMA_TO_DEVICE);
511 iser_dto_add_regd_buff(send_dto, regd_buf, 510 iser_dto_add_regd_buff(send_dto, regd_buf,
@@ -535,15 +534,13 @@ send_control_error:
535void iser_rcv_completion(struct iser_desc *rx_desc, 534void iser_rcv_completion(struct iser_desc *rx_desc,
536 unsigned long dto_xfer_len) 535 unsigned long dto_xfer_len)
537{ 536{
538 struct iser_dto *dto = &rx_desc->dto; 537 struct iser_dto *dto = &rx_desc->dto;
539 struct iscsi_iser_conn *conn = dto->ib_conn->iser_conn; 538 struct iscsi_iser_conn *conn = dto->ib_conn->iser_conn;
540 struct iscsi_session *session = conn->iscsi_conn->session; 539 struct iscsi_task *task;
541 struct iscsi_cmd_task *ctask; 540 struct iscsi_iser_task *iser_task;
542 struct iscsi_iser_cmd_task *iser_ctask;
543 struct iscsi_hdr *hdr; 541 struct iscsi_hdr *hdr;
544 char *rx_data = NULL; 542 char *rx_data = NULL;
545 int rx_data_len = 0; 543 int rx_data_len = 0;
546 unsigned int itt;
547 unsigned char opcode; 544 unsigned char opcode;
548 545
549 hdr = &rx_desc->iscsi_header; 546 hdr = &rx_desc->iscsi_header;
@@ -559,19 +556,24 @@ void iser_rcv_completion(struct iser_desc *rx_desc,
559 opcode = hdr->opcode & ISCSI_OPCODE_MASK; 556 opcode = hdr->opcode & ISCSI_OPCODE_MASK;
560 557
561 if (opcode == ISCSI_OP_SCSI_CMD_RSP) { 558 if (opcode == ISCSI_OP_SCSI_CMD_RSP) {
562 itt = get_itt(hdr->itt); /* mask out cid and age bits */ 559 spin_lock(&conn->iscsi_conn->session->lock);
563 if (!(itt < session->cmds_max)) 560 task = iscsi_itt_to_ctask(conn->iscsi_conn, hdr->itt);
561 if (task)
562 __iscsi_get_task(task);
563 spin_unlock(&conn->iscsi_conn->session->lock);
564
565 if (!task)
564 iser_err("itt can't be matched to task!!! " 566 iser_err("itt can't be matched to task!!! "
565 "conn %p opcode %d cmds_max %d itt %d\n", 567 "conn %p opcode %d itt %d\n",
566 conn->iscsi_conn,opcode,session->cmds_max,itt); 568 conn->iscsi_conn, opcode, hdr->itt);
567 /* use the mapping given with the cmds array indexed by itt */ 569 else {
568 ctask = (struct iscsi_cmd_task *)session->cmds[itt]; 570 iser_task = task->dd_data;
569 iser_ctask = ctask->dd_data; 571 iser_dbg("itt %d task %p\n",hdr->itt, task);
570 iser_dbg("itt %d ctask %p\n",itt,ctask); 572 iser_task->status = ISER_TASK_STATUS_COMPLETED;
571 iser_ctask->status = ISER_TASK_STATUS_COMPLETED; 573 iser_task_rdma_finalize(iser_task);
572 iser_ctask_rdma_finalize(iser_ctask); 574 iscsi_put_task(task);
575 }
573 } 576 }
574
575 iser_dto_buffs_release(dto); 577 iser_dto_buffs_release(dto);
576 578
577 iscsi_iser_recv(conn->iscsi_conn, hdr, rx_data, rx_data_len); 579 iscsi_iser_recv(conn->iscsi_conn, hdr, rx_data, rx_data_len);
@@ -592,7 +594,7 @@ void iser_snd_completion(struct iser_desc *tx_desc)
592 struct iser_conn *ib_conn = dto->ib_conn; 594 struct iser_conn *ib_conn = dto->ib_conn;
593 struct iscsi_iser_conn *iser_conn = ib_conn->iser_conn; 595 struct iscsi_iser_conn *iser_conn = ib_conn->iser_conn;
594 struct iscsi_conn *conn = iser_conn->iscsi_conn; 596 struct iscsi_conn *conn = iser_conn->iscsi_conn;
595 struct iscsi_mgmt_task *mtask; 597 struct iscsi_task *task;
596 int resume_tx = 0; 598 int resume_tx = 0;
597 599
598 iser_dbg("Initiator, Data sent dto=0x%p\n", dto); 600 iser_dbg("Initiator, Data sent dto=0x%p\n", dto);
@@ -615,36 +617,31 @@ void iser_snd_completion(struct iser_desc *tx_desc)
615 617
616 if (tx_desc->type == ISCSI_TX_CONTROL) { 618 if (tx_desc->type == ISCSI_TX_CONTROL) {
617 /* this arithmetic is legal by libiscsi dd_data allocation */ 619 /* this arithmetic is legal by libiscsi dd_data allocation */
618 mtask = (void *) ((long)(void *)tx_desc - 620 task = (void *) ((long)(void *)tx_desc -
619 sizeof(struct iscsi_mgmt_task)); 621 sizeof(struct iscsi_task));
620 if (mtask->hdr->itt == RESERVED_ITT) { 622 if (task->hdr->itt == RESERVED_ITT)
621 struct iscsi_session *session = conn->session; 623 iscsi_put_task(task);
622
623 spin_lock(&conn->session->lock);
624 iscsi_free_mgmt_task(conn, mtask);
625 spin_unlock(&session->lock);
626 }
627 } 624 }
628} 625}
629 626
630void iser_ctask_rdma_init(struct iscsi_iser_cmd_task *iser_ctask) 627void iser_task_rdma_init(struct iscsi_iser_task *iser_task)
631 628
632{ 629{
633 iser_ctask->status = ISER_TASK_STATUS_INIT; 630 iser_task->status = ISER_TASK_STATUS_INIT;
634 631
635 iser_ctask->dir[ISER_DIR_IN] = 0; 632 iser_task->dir[ISER_DIR_IN] = 0;
636 iser_ctask->dir[ISER_DIR_OUT] = 0; 633 iser_task->dir[ISER_DIR_OUT] = 0;
637 634
638 iser_ctask->data[ISER_DIR_IN].data_len = 0; 635 iser_task->data[ISER_DIR_IN].data_len = 0;
639 iser_ctask->data[ISER_DIR_OUT].data_len = 0; 636 iser_task->data[ISER_DIR_OUT].data_len = 0;
640 637
641 memset(&iser_ctask->rdma_regd[ISER_DIR_IN], 0, 638 memset(&iser_task->rdma_regd[ISER_DIR_IN], 0,
642 sizeof(struct iser_regd_buf)); 639 sizeof(struct iser_regd_buf));
643 memset(&iser_ctask->rdma_regd[ISER_DIR_OUT], 0, 640 memset(&iser_task->rdma_regd[ISER_DIR_OUT], 0,
644 sizeof(struct iser_regd_buf)); 641 sizeof(struct iser_regd_buf));
645} 642}
646 643
647void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask) 644void iser_task_rdma_finalize(struct iscsi_iser_task *iser_task)
648{ 645{
649 int deferred; 646 int deferred;
650 int is_rdma_aligned = 1; 647 int is_rdma_aligned = 1;
@@ -653,17 +650,17 @@ void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask)
653 /* if we were reading, copy back to unaligned sglist, 650 /* if we were reading, copy back to unaligned sglist,
654 * anyway dma_unmap and free the copy 651 * anyway dma_unmap and free the copy
655 */ 652 */
656 if (iser_ctask->data_copy[ISER_DIR_IN].copy_buf != NULL) { 653 if (iser_task->data_copy[ISER_DIR_IN].copy_buf != NULL) {
657 is_rdma_aligned = 0; 654 is_rdma_aligned = 0;
658 iser_finalize_rdma_unaligned_sg(iser_ctask, ISER_DIR_IN); 655 iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_IN);
659 } 656 }
660 if (iser_ctask->data_copy[ISER_DIR_OUT].copy_buf != NULL) { 657 if (iser_task->data_copy[ISER_DIR_OUT].copy_buf != NULL) {
661 is_rdma_aligned = 0; 658 is_rdma_aligned = 0;
662 iser_finalize_rdma_unaligned_sg(iser_ctask, ISER_DIR_OUT); 659 iser_finalize_rdma_unaligned_sg(iser_task, ISER_DIR_OUT);
663 } 660 }
664 661
665 if (iser_ctask->dir[ISER_DIR_IN]) { 662 if (iser_task->dir[ISER_DIR_IN]) {
666 regd = &iser_ctask->rdma_regd[ISER_DIR_IN]; 663 regd = &iser_task->rdma_regd[ISER_DIR_IN];
667 deferred = iser_regd_buff_release(regd); 664 deferred = iser_regd_buff_release(regd);
668 if (deferred) { 665 if (deferred) {
669 iser_err("%d references remain for BUF-IN rdma reg\n", 666 iser_err("%d references remain for BUF-IN rdma reg\n",
@@ -671,8 +668,8 @@ void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask)
671 } 668 }
672 } 669 }
673 670
674 if (iser_ctask->dir[ISER_DIR_OUT]) { 671 if (iser_task->dir[ISER_DIR_OUT]) {
675 regd = &iser_ctask->rdma_regd[ISER_DIR_OUT]; 672 regd = &iser_task->rdma_regd[ISER_DIR_OUT];
676 deferred = iser_regd_buff_release(regd); 673 deferred = iser_regd_buff_release(regd);
677 if (deferred) { 674 if (deferred) {
678 iser_err("%d references remain for BUF-OUT rdma reg\n", 675 iser_err("%d references remain for BUF-OUT rdma reg\n",
@@ -682,7 +679,7 @@ void iser_ctask_rdma_finalize(struct iscsi_iser_cmd_task *iser_ctask)
682 679
683 /* if the data was unaligned, it was already unmapped and then copied */ 680 /* if the data was unaligned, it was already unmapped and then copied */
684 if (is_rdma_aligned) 681 if (is_rdma_aligned)
685 iser_dma_unmap_task_data(iser_ctask); 682 iser_dma_unmap_task_data(iser_task);
686} 683}
687 684
688void iser_dto_buffs_release(struct iser_dto *dto) 685void iser_dto_buffs_release(struct iser_dto *dto)
diff --git a/drivers/infiniband/ulp/iser/iser_memory.c b/drivers/infiniband/ulp/iser/iser_memory.c
index cac50c4dc159..b9453d068e9d 100644
--- a/drivers/infiniband/ulp/iser/iser_memory.c
+++ b/drivers/infiniband/ulp/iser/iser_memory.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: iser_memory.c 6964 2006-05-07 11:11:43Z ogerlitz $
33 */ 31 */
34#include <linux/module.h> 32#include <linux/module.h>
35#include <linux/kernel.h> 33#include <linux/kernel.h>
@@ -101,13 +99,13 @@ void iser_reg_single(struct iser_device *device,
101/** 99/**
102 * iser_start_rdma_unaligned_sg 100 * iser_start_rdma_unaligned_sg
103 */ 101 */
104static int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask, 102static int iser_start_rdma_unaligned_sg(struct iscsi_iser_task *iser_task,
105 enum iser_data_dir cmd_dir) 103 enum iser_data_dir cmd_dir)
106{ 104{
107 int dma_nents; 105 int dma_nents;
108 struct ib_device *dev; 106 struct ib_device *dev;
109 char *mem = NULL; 107 char *mem = NULL;
110 struct iser_data_buf *data = &iser_ctask->data[cmd_dir]; 108 struct iser_data_buf *data = &iser_task->data[cmd_dir];
111 unsigned long cmd_data_len = data->data_len; 109 unsigned long cmd_data_len = data->data_len;
112 110
113 if (cmd_data_len > ISER_KMALLOC_THRESHOLD) 111 if (cmd_data_len > ISER_KMALLOC_THRESHOLD)
@@ -140,37 +138,37 @@ static int iser_start_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
140 } 138 }
141 } 139 }
142 140
143 sg_init_one(&iser_ctask->data_copy[cmd_dir].sg_single, mem, cmd_data_len); 141 sg_init_one(&iser_task->data_copy[cmd_dir].sg_single, mem, cmd_data_len);
144 iser_ctask->data_copy[cmd_dir].buf = 142 iser_task->data_copy[cmd_dir].buf =
145 &iser_ctask->data_copy[cmd_dir].sg_single; 143 &iser_task->data_copy[cmd_dir].sg_single;
146 iser_ctask->data_copy[cmd_dir].size = 1; 144 iser_task->data_copy[cmd_dir].size = 1;
147 145
148 iser_ctask->data_copy[cmd_dir].copy_buf = mem; 146 iser_task->data_copy[cmd_dir].copy_buf = mem;
149 147
150 dev = iser_ctask->iser_conn->ib_conn->device->ib_device; 148 dev = iser_task->iser_conn->ib_conn->device->ib_device;
151 dma_nents = ib_dma_map_sg(dev, 149 dma_nents = ib_dma_map_sg(dev,
152 &iser_ctask->data_copy[cmd_dir].sg_single, 150 &iser_task->data_copy[cmd_dir].sg_single,
153 1, 151 1,
154 (cmd_dir == ISER_DIR_OUT) ? 152 (cmd_dir == ISER_DIR_OUT) ?
155 DMA_TO_DEVICE : DMA_FROM_DEVICE); 153 DMA_TO_DEVICE : DMA_FROM_DEVICE);
156 BUG_ON(dma_nents == 0); 154 BUG_ON(dma_nents == 0);
157 155
158 iser_ctask->data_copy[cmd_dir].dma_nents = dma_nents; 156 iser_task->data_copy[cmd_dir].dma_nents = dma_nents;
159 return 0; 157 return 0;
160} 158}
161 159
162/** 160/**
163 * iser_finalize_rdma_unaligned_sg 161 * iser_finalize_rdma_unaligned_sg
164 */ 162 */
165void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask, 163void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_task *iser_task,
166 enum iser_data_dir cmd_dir) 164 enum iser_data_dir cmd_dir)
167{ 165{
168 struct ib_device *dev; 166 struct ib_device *dev;
169 struct iser_data_buf *mem_copy; 167 struct iser_data_buf *mem_copy;
170 unsigned long cmd_data_len; 168 unsigned long cmd_data_len;
171 169
172 dev = iser_ctask->iser_conn->ib_conn->device->ib_device; 170 dev = iser_task->iser_conn->ib_conn->device->ib_device;
173 mem_copy = &iser_ctask->data_copy[cmd_dir]; 171 mem_copy = &iser_task->data_copy[cmd_dir];
174 172
175 ib_dma_unmap_sg(dev, &mem_copy->sg_single, 1, 173 ib_dma_unmap_sg(dev, &mem_copy->sg_single, 1,
176 (cmd_dir == ISER_DIR_OUT) ? 174 (cmd_dir == ISER_DIR_OUT) ?
@@ -186,8 +184,8 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
186 /* copy back read RDMA to unaligned sg */ 184 /* copy back read RDMA to unaligned sg */
187 mem = mem_copy->copy_buf; 185 mem = mem_copy->copy_buf;
188 186
189 sgl = (struct scatterlist *)iser_ctask->data[ISER_DIR_IN].buf; 187 sgl = (struct scatterlist *)iser_task->data[ISER_DIR_IN].buf;
190 sg_size = iser_ctask->data[ISER_DIR_IN].size; 188 sg_size = iser_task->data[ISER_DIR_IN].size;
191 189
192 p = mem; 190 p = mem;
193 for_each_sg(sgl, sg, sg_size, i) { 191 for_each_sg(sgl, sg, sg_size, i) {
@@ -200,7 +198,7 @@ void iser_finalize_rdma_unaligned_sg(struct iscsi_iser_cmd_task *iser_ctask,
200 } 198 }
201 } 199 }
202 200
203 cmd_data_len = iser_ctask->data[cmd_dir].data_len; 201 cmd_data_len = iser_task->data[cmd_dir].data_len;
204 202
205 if (cmd_data_len > ISER_KMALLOC_THRESHOLD) 203 if (cmd_data_len > ISER_KMALLOC_THRESHOLD)
206 free_pages((unsigned long)mem_copy->copy_buf, 204 free_pages((unsigned long)mem_copy->copy_buf,
@@ -378,15 +376,15 @@ static void iser_page_vec_build(struct iser_data_buf *data,
378 } 376 }
379} 377}
380 378
381int iser_dma_map_task_data(struct iscsi_iser_cmd_task *iser_ctask, 379int iser_dma_map_task_data(struct iscsi_iser_task *iser_task,
382 struct iser_data_buf *data, 380 struct iser_data_buf *data,
383 enum iser_data_dir iser_dir, 381 enum iser_data_dir iser_dir,
384 enum dma_data_direction dma_dir) 382 enum dma_data_direction dma_dir)
385{ 383{
386 struct ib_device *dev; 384 struct ib_device *dev;
387 385
388 iser_ctask->dir[iser_dir] = 1; 386 iser_task->dir[iser_dir] = 1;
389 dev = iser_ctask->iser_conn->ib_conn->device->ib_device; 387 dev = iser_task->iser_conn->ib_conn->device->ib_device;
390 388
391 data->dma_nents = ib_dma_map_sg(dev, data->buf, data->size, dma_dir); 389 data->dma_nents = ib_dma_map_sg(dev, data->buf, data->size, dma_dir);
392 if (data->dma_nents == 0) { 390 if (data->dma_nents == 0) {
@@ -396,20 +394,20 @@ int iser_dma_map_task_data(struct iscsi_iser_cmd_task *iser_ctask,
396 return 0; 394 return 0;
397} 395}
398 396
399void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *iser_ctask) 397void iser_dma_unmap_task_data(struct iscsi_iser_task *iser_task)
400{ 398{
401 struct ib_device *dev; 399 struct ib_device *dev;
402 struct iser_data_buf *data; 400 struct iser_data_buf *data;
403 401
404 dev = iser_ctask->iser_conn->ib_conn->device->ib_device; 402 dev = iser_task->iser_conn->ib_conn->device->ib_device;
405 403
406 if (iser_ctask->dir[ISER_DIR_IN]) { 404 if (iser_task->dir[ISER_DIR_IN]) {
407 data = &iser_ctask->data[ISER_DIR_IN]; 405 data = &iser_task->data[ISER_DIR_IN];
408 ib_dma_unmap_sg(dev, data->buf, data->size, DMA_FROM_DEVICE); 406 ib_dma_unmap_sg(dev, data->buf, data->size, DMA_FROM_DEVICE);
409 } 407 }
410 408
411 if (iser_ctask->dir[ISER_DIR_OUT]) { 409 if (iser_task->dir[ISER_DIR_OUT]) {
412 data = &iser_ctask->data[ISER_DIR_OUT]; 410 data = &iser_task->data[ISER_DIR_OUT];
413 ib_dma_unmap_sg(dev, data->buf, data->size, DMA_TO_DEVICE); 411 ib_dma_unmap_sg(dev, data->buf, data->size, DMA_TO_DEVICE);
414 } 412 }
415} 413}
@@ -420,21 +418,21 @@ void iser_dma_unmap_task_data(struct iscsi_iser_cmd_task *iser_ctask)
420 * 418 *
421 * returns 0 on success, errno code on failure 419 * returns 0 on success, errno code on failure
422 */ 420 */
423int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask, 421int iser_reg_rdma_mem(struct iscsi_iser_task *iser_task,
424 enum iser_data_dir cmd_dir) 422 enum iser_data_dir cmd_dir)
425{ 423{
426 struct iscsi_conn *iscsi_conn = iser_ctask->iser_conn->iscsi_conn; 424 struct iscsi_conn *iscsi_conn = iser_task->iser_conn->iscsi_conn;
427 struct iser_conn *ib_conn = iser_ctask->iser_conn->ib_conn; 425 struct iser_conn *ib_conn = iser_task->iser_conn->ib_conn;
428 struct iser_device *device = ib_conn->device; 426 struct iser_device *device = ib_conn->device;
429 struct ib_device *ibdev = device->ib_device; 427 struct ib_device *ibdev = device->ib_device;
430 struct iser_data_buf *mem = &iser_ctask->data[cmd_dir]; 428 struct iser_data_buf *mem = &iser_task->data[cmd_dir];
431 struct iser_regd_buf *regd_buf; 429 struct iser_regd_buf *regd_buf;
432 int aligned_len; 430 int aligned_len;
433 int err; 431 int err;
434 int i; 432 int i;
435 struct scatterlist *sg; 433 struct scatterlist *sg;
436 434
437 regd_buf = &iser_ctask->rdma_regd[cmd_dir]; 435 regd_buf = &iser_task->rdma_regd[cmd_dir];
438 436
439 aligned_len = iser_data_buf_aligned_len(mem, ibdev); 437 aligned_len = iser_data_buf_aligned_len(mem, ibdev);
440 if (aligned_len != mem->dma_nents) { 438 if (aligned_len != mem->dma_nents) {
@@ -444,13 +442,13 @@ int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask,
444 iser_data_buf_dump(mem, ibdev); 442 iser_data_buf_dump(mem, ibdev);
445 443
446 /* unmap the command data before accessing it */ 444 /* unmap the command data before accessing it */
447 iser_dma_unmap_task_data(iser_ctask); 445 iser_dma_unmap_task_data(iser_task);
448 446
449 /* allocate copy buf, if we are writing, copy the */ 447 /* allocate copy buf, if we are writing, copy the */
450 /* unaligned scatterlist, dma map the copy */ 448 /* unaligned scatterlist, dma map the copy */
451 if (iser_start_rdma_unaligned_sg(iser_ctask, cmd_dir) != 0) 449 if (iser_start_rdma_unaligned_sg(iser_task, cmd_dir) != 0)
452 return -ENOMEM; 450 return -ENOMEM;
453 mem = &iser_ctask->data_copy[cmd_dir]; 451 mem = &iser_task->data_copy[cmd_dir];
454 } 452 }
455 453
456 /* if there a single dma entry, FMR is not needed */ 454 /* if there a single dma entry, FMR is not needed */
@@ -474,8 +472,9 @@ int iser_reg_rdma_mem(struct iscsi_iser_cmd_task *iser_ctask,
474 err = iser_reg_page_vec(ib_conn, ib_conn->page_vec, &regd_buf->reg); 472 err = iser_reg_page_vec(ib_conn, ib_conn->page_vec, &regd_buf->reg);
475 if (err) { 473 if (err) {
476 iser_data_buf_dump(mem, ibdev); 474 iser_data_buf_dump(mem, ibdev);
477 iser_err("mem->dma_nents = %d (dlength = 0x%x)\n", mem->dma_nents, 475 iser_err("mem->dma_nents = %d (dlength = 0x%x)\n",
478 ntoh24(iser_ctask->desc.iscsi_header.dlength)); 476 mem->dma_nents,
477 ntoh24(iser_task->desc.iscsi_header.dlength));
479 iser_err("page_vec: data_size = 0x%x, length = %d, offset = 0x%x\n", 478 iser_err("page_vec: data_size = 0x%x, length = %d, offset = 0x%x\n",
480 ib_conn->page_vec->data_size, ib_conn->page_vec->length, 479 ib_conn->page_vec->data_size, ib_conn->page_vec->length,
481 ib_conn->page_vec->offset); 480 ib_conn->page_vec->offset);
diff --git a/drivers/infiniband/ulp/iser/iser_verbs.c b/drivers/infiniband/ulp/iser/iser_verbs.c
index d19cfe605ebb..3a917c1f796f 100644
--- a/drivers/infiniband/ulp/iser/iser_verbs.c
+++ b/drivers/infiniband/ulp/iser/iser_verbs.c
@@ -29,8 +29,6 @@
29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31 * SOFTWARE. 31 * SOFTWARE.
32 *
33 * $Id: iser_verbs.c 7051 2006-05-10 12:29:11Z ogerlitz $
34 */ 32 */
35#include <linux/kernel.h> 33#include <linux/kernel.h>
36#include <linux/module.h> 34#include <linux/module.h>
@@ -325,7 +323,18 @@ static void iser_conn_release(struct iser_conn *ib_conn)
325 iser_device_try_release(device); 323 iser_device_try_release(device);
326 if (ib_conn->iser_conn) 324 if (ib_conn->iser_conn)
327 ib_conn->iser_conn->ib_conn = NULL; 325 ib_conn->iser_conn->ib_conn = NULL;
328 kfree(ib_conn); 326 iscsi_destroy_endpoint(ib_conn->ep);
327}
328
329void iser_conn_get(struct iser_conn *ib_conn)
330{
331 atomic_inc(&ib_conn->refcount);
332}
333
334void iser_conn_put(struct iser_conn *ib_conn)
335{
336 if (atomic_dec_and_test(&ib_conn->refcount))
337 iser_conn_release(ib_conn);
329} 338}
330 339
331/** 340/**
@@ -349,7 +358,7 @@ void iser_conn_terminate(struct iser_conn *ib_conn)
349 wait_event_interruptible(ib_conn->wait, 358 wait_event_interruptible(ib_conn->wait,
350 ib_conn->state == ISER_CONN_DOWN); 359 ib_conn->state == ISER_CONN_DOWN);
351 360
352 iser_conn_release(ib_conn); 361 iser_conn_put(ib_conn);
353} 362}
354 363
355static void iser_connect_error(struct rdma_cm_id *cma_id) 364static void iser_connect_error(struct rdma_cm_id *cma_id)
@@ -483,24 +492,15 @@ static int iser_cma_handler(struct rdma_cm_id *cma_id, struct rdma_cm_event *eve
483 return ret; 492 return ret;
484} 493}
485 494
486int iser_conn_init(struct iser_conn **ibconn) 495void iser_conn_init(struct iser_conn *ib_conn)
487{ 496{
488 struct iser_conn *ib_conn;
489
490 ib_conn = kzalloc(sizeof *ib_conn, GFP_KERNEL);
491 if (!ib_conn) {
492 iser_err("can't alloc memory for struct iser_conn\n");
493 return -ENOMEM;
494 }
495 ib_conn->state = ISER_CONN_INIT; 497 ib_conn->state = ISER_CONN_INIT;
496 init_waitqueue_head(&ib_conn->wait); 498 init_waitqueue_head(&ib_conn->wait);
497 atomic_set(&ib_conn->post_recv_buf_count, 0); 499 atomic_set(&ib_conn->post_recv_buf_count, 0);
498 atomic_set(&ib_conn->post_send_buf_count, 0); 500 atomic_set(&ib_conn->post_send_buf_count, 0);
501 atomic_set(&ib_conn->refcount, 1);
499 INIT_LIST_HEAD(&ib_conn->conn_list); 502 INIT_LIST_HEAD(&ib_conn->conn_list);
500 spin_lock_init(&ib_conn->lock); 503 spin_lock_init(&ib_conn->lock);
501
502 *ibconn = ib_conn;
503 return 0;
504} 504}
505 505
506 /** 506 /**
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 435145709dd6..ed7c5f72cb8b 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: ib_srp.c 3932 2005-11-01 17:19:29Z roland $
33 */ 31 */
34 32
35#include <linux/module.h> 33#include <linux/module.h>
@@ -49,8 +47,6 @@
49#include <scsi/srp.h> 47#include <scsi/srp.h>
50#include <scsi/scsi_transport_srp.h> 48#include <scsi/scsi_transport_srp.h>
51 49
52#include <rdma/ib_cache.h>
53
54#include "ib_srp.h" 50#include "ib_srp.h"
55 51
56#define DRV_NAME "ib_srp" 52#define DRV_NAME "ib_srp"
@@ -183,10 +179,10 @@ static int srp_init_qp(struct srp_target_port *target,
183 if (!attr) 179 if (!attr)
184 return -ENOMEM; 180 return -ENOMEM;
185 181
186 ret = ib_find_cached_pkey(target->srp_host->srp_dev->dev, 182 ret = ib_find_pkey(target->srp_host->srp_dev->dev,
187 target->srp_host->port, 183 target->srp_host->port,
188 be16_to_cpu(target->path.pkey), 184 be16_to_cpu(target->path.pkey),
189 &attr->pkey_index); 185 &attr->pkey_index);
190 if (ret) 186 if (ret)
191 goto out; 187 goto out;
192 188
@@ -1883,8 +1879,7 @@ static ssize_t srp_create_target(struct device *dev,
1883 if (ret) 1879 if (ret)
1884 goto err; 1880 goto err;
1885 1881
1886 ib_get_cached_gid(host->srp_dev->dev, host->port, 0, 1882 ib_query_gid(host->srp_dev->dev, host->port, 0, &target->path.sgid);
1887 &target->path.sgid);
1888 1883
1889 shost_printk(KERN_DEBUG, target->scsi_host, PFX 1884 shost_printk(KERN_DEBUG, target->scsi_host, PFX
1890 "new target: id_ext %016llx ioc_guid %016llx pkey %04x " 1885 "new target: id_ext %016llx ioc_guid %016llx pkey %04x "
diff --git a/drivers/infiniband/ulp/srp/ib_srp.h b/drivers/infiniband/ulp/srp/ib_srp.h
index 63d2ae724061..e185b907fc12 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.h
+++ b/drivers/infiniband/ulp/srp/ib_srp.h
@@ -28,8 +28,6 @@
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30 * SOFTWARE. 30 * SOFTWARE.
31 *
32 * $Id: ib_srp.h 3932 2005-11-01 17:19:29Z roland $
33 */ 31 */
34 32
35#ifndef IB_SRP_H 33#ifndef IB_SRP_H