Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[sfrench/cifs-2.6.git] / drivers / infiniband / ulp / ipoib / ipoib_verbs.c
index 5c3c6a43a52b55733601073f0617491e6c3baa2c..433e99ac227b85a2bd6e8594c69fe47f3dc6e274 100644 (file)
@@ -33,8 +33,6 @@
  * $Id: ipoib_verbs.c 1349 2004-12-16 21:09:43Z roland $
  */
 
-#include <rdma/ib_cache.h>
-
 #include "ipoib.h"
 
 int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
@@ -49,7 +47,7 @@ int ipoib_mcast_attach(struct net_device *dev, u16 mlid, union ib_gid *mgid)
        if (!qp_attr)
                goto out;
 
-       if (ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) {
+       if (ib_find_pkey(priv->ca, priv->port, priv->pkey, &pkey_index)) {
                clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
                ret = -ENXIO;
                goto out;
@@ -94,26 +92,16 @@ int ipoib_init_qp(struct net_device *dev)
 {
        struct ipoib_dev_priv *priv = netdev_priv(dev);
        int ret;
-       u16 pkey_index;
        struct ib_qp_attr qp_attr;
        int attr_mask;
 
-       /*
-        * Search through the port P_Key table for the requested pkey value.
-        * The port has to be assigned to the respective IB partition in
-        * advance.
-        */
-       ret = ib_find_cached_pkey(priv->ca, priv->port, priv->pkey, &pkey_index);
-       if (ret) {
-               clear_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
-               return ret;
-       }
-       set_bit(IPOIB_PKEY_ASSIGNED, &priv->flags);
+       if (!test_bit(IPOIB_PKEY_ASSIGNED, &priv->flags))
+               return -1;
 
        qp_attr.qp_state = IB_QPS_INIT;
        qp_attr.qkey = 0;
        qp_attr.port_num = priv->port;
-       qp_attr.pkey_index = pkey_index;
+       qp_attr.pkey_index = priv->pkey_index;
        attr_mask =
            IB_QP_QKEY |
            IB_QP_PORT |
@@ -184,8 +172,12 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
 
        size = ipoib_sendq_size + ipoib_recvq_size + 1;
        ret = ipoib_cm_dev_init(dev);
-       if (!ret)
-               size += ipoib_recvq_size;
+       if (!ret) {
+               if (ipoib_cm_has_srq(dev))
+                       size += ipoib_recvq_size + 1; /* 1 extra for rx_drain_qp */
+               else
+                       size += ipoib_recvq_size * ipoib_max_conn_qp;
+       }
 
        priv->cq = ib_create_cq(priv->ca, ipoib_ib_completion, NULL, dev, size, 0);
        if (IS_ERR(priv->cq)) {
@@ -197,7 +189,7 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
                goto out_free_cq;
 
        init_attr.send_cq = priv->cq;
-       init_attr.recv_cq = priv->cq,
+       init_attr.recv_cq = priv->cq;
 
        priv->qp = ib_create_qp(priv->pd, &init_attr);
        if (IS_ERR(priv->qp)) {
@@ -209,12 +201,12 @@ int ipoib_transport_dev_init(struct net_device *dev, struct ib_device *ca)
        priv->dev->dev_addr[2] = (priv->qp->qp_num >>  8) & 0xff;
        priv->dev->dev_addr[3] = (priv->qp->qp_num      ) & 0xff;
 
-       priv->tx_sge.lkey       = priv->mr->lkey;
+       priv->tx_sge.lkey       = priv->mr->lkey;
 
-       priv->tx_wr.opcode      = IB_WR_SEND;
-       priv->tx_wr.sg_list     = &priv->tx_sge;
-       priv->tx_wr.num_sge     = 1;
-       priv->tx_wr.send_flags  = IB_SEND_SIGNALED;
+       priv->tx_wr.opcode      = IB_WR_SEND;
+       priv->tx_wr.sg_list     = &priv->tx_sge;
+       priv->tx_wr.num_sge     = 1;
+       priv->tx_wr.send_flags  = IB_SEND_SIGNALED;
 
        return 0;
 
@@ -223,6 +215,7 @@ out_free_cq:
 
 out_free_mr:
        ib_dereg_mr(priv->mr);
+       ipoib_cm_dev_cleanup(dev);
 
 out_free_pd:
        ib_dealloc_pd(priv->pd);
@@ -259,14 +252,18 @@ void ipoib_event(struct ib_event_handler *handler,
        struct ipoib_dev_priv *priv =
                container_of(handler, struct ipoib_dev_priv, event_handler);
 
-       if ((record->event == IB_EVENT_PORT_ERR    ||
-            record->event == IB_EVENT_PKEY_CHANGE ||
-            record->event == IB_EVENT_PORT_ACTIVE ||
-            record->event == IB_EVENT_LID_CHANGE  ||
-            record->event == IB_EVENT_SM_CHANGE   ||
-            record->event == IB_EVENT_CLIENT_REREGISTER) &&
-           record->element.port_num == priv->port) {
+       if (record->element.port_num != priv->port)
+               return;
+
+       if (record->event == IB_EVENT_PORT_ERR    ||
+           record->event == IB_EVENT_PORT_ACTIVE ||
+           record->event == IB_EVENT_LID_CHANGE  ||
+           record->event == IB_EVENT_SM_CHANGE   ||
+           record->event == IB_EVENT_CLIENT_REREGISTER) {
                ipoib_dbg(priv, "Port state change event\n");
                queue_work(ipoib_workqueue, &priv->flush_task);
+       } else if (record->event == IB_EVENT_PKEY_CHANGE) {
+               ipoib_dbg(priv, "P_Key change event on port:%d\n", priv->port);
+               queue_work(ipoib_workqueue, &priv->pkey_event_task);
        }
 }