IB/cma: Add debug messages to error flows
authorMoni Shoua <monis@mellanox.com>
Thu, 5 Jan 2017 14:16:35 +0000 (16:16 +0200)
committerDoug Ledford <dledford@redhat.com>
Tue, 24 Jan 2017 21:20:37 +0000 (16:20 -0500)
Print debug messages to the kernel log to add more
information about RDMA_CM events that indicate an error.

Signed-off-by: Moni Shoua <monis@mellanox.com>
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/cm.c
drivers/infiniband/core/cma.c

index cf1edfa1cbacafca1687726f69a220c2473e2eee..6535f09dc575c1df7f6dc22c04be96ccc65130c1 100644 (file)
@@ -3409,6 +3409,8 @@ static void cm_process_send_error(struct ib_mad_send_buf *msg,
        if (msg != cm_id_priv->msg || state != cm_id_priv->id.state)
                goto discard;
 
+       pr_debug_ratelimited("CM: failed sending MAD in state %d. (%s)\n",
+                            state, ib_wc_status_msg(wc_status));
        switch (state) {
        case IB_CM_REQ_SENT:
        case IB_CM_MRA_REQ_RCVD:
index a14a18cfc8f359ff3d50967271ee69fd17253011..37e4644685393c761fff97612356d5f81b862dd7 100644 (file)
@@ -1693,6 +1693,7 @@ static int cma_rep_recv(struct rdma_id_private *id_priv)
 
        return 0;
 reject:
+       pr_debug_ratelimited("RDMA CM: CONNECT_ERROR: failed to handle reply. status %d\n", ret);
        cma_modify_qp_err(id_priv);
        ib_send_cm_rej(id_priv->cm_id.ib, IB_CM_REJ_CONSUMER_DEFINED,
                       NULL, 0, NULL, 0);
@@ -1764,6 +1765,8 @@ static int cma_ib_handler(struct ib_cm_id *cm_id, struct ib_cm_event *ib_event)
                /* ignore event */
                goto out;
        case IB_CM_REJ_RECEIVED:
+               pr_debug_ratelimited("RDMA CM: REJECTED: %s\n", rdma_reject_msg(&id_priv->id,
+                                                                               ib_event->param.rej_rcvd.reason));
                cma_modify_qp_err(id_priv);
                event.status = ib_event->param.rej_rcvd.reason;
                event.event = RDMA_CM_EVENT_REJECTED;
@@ -2289,6 +2292,8 @@ static void cma_query_handler(int status, struct ib_sa_path_rec *path_rec,
                work->new_state = RDMA_CM_ADDR_RESOLVED;
                work->event.event = RDMA_CM_EVENT_ROUTE_ERROR;
                work->event.status = status;
+               pr_debug_ratelimited("RDMA CM: ROUTE_ERROR: failed to query path. status %d\n",
+                                    status);
        }
 
        queue_work(cma_wq, &work->work);
@@ -2724,8 +2729,14 @@ static void addr_handler(int status, struct sockaddr *src_addr,
                goto out;
 
        memcpy(cma_src_addr(id_priv), src_addr, rdma_addr_size(src_addr));
-       if (!status && !id_priv->cma_dev)
+       if (!status && !id_priv->cma_dev) {
                status = cma_acquire_dev(id_priv, NULL);
+               if (status)
+                       pr_debug_ratelimited("RDMA CM: ADDR_ERROR: failed to acquire device. status %d\n",
+                                            status);
+       } else {
+               pr_debug_ratelimited("RDMA CM: ADDR_ERROR: failed to resolve IP. status %d\n", status);
+       }
 
        if (status) {
                if (!cma_comp_exch(id_priv, RDMA_CM_ADDR_RESOLVED,
@@ -3311,10 +3322,13 @@ static int cma_sidr_rep_handler(struct ib_cm_id *cm_id,
                if (rep->status != IB_SIDR_SUCCESS) {
                        event.event = RDMA_CM_EVENT_UNREACHABLE;
                        event.status = ib_event->param.sidr_rep_rcvd.status;
+                       pr_debug_ratelimited("RDMA CM: UNREACHABLE: bad SIDR reply. status %d\n",
+                                            event.status);
                        break;
                }
                ret = cma_set_qkey(id_priv, rep->qkey);
                if (ret) {
+                       pr_debug_ratelimited("RDMA CM: ADDR_ERROR: failed to set qkey. status %d\n", ret);
                        event.event = RDMA_CM_EVENT_ADDR_ERROR;
                        event.status = ret;
                        break;
@@ -3763,10 +3777,17 @@ static int cma_ib_mc_handler(int status, struct ib_sa_multicast *multicast)
 
        if (!status)
                status = cma_set_qkey(id_priv, be32_to_cpu(multicast->rec.qkey));
+       else
+               pr_debug_ratelimited("RDMA CM: MULTICAST_ERROR: failed to join multicast. status %d\n",
+                                    status);
        mutex_lock(&id_priv->qp_mutex);
-       if (!status && id_priv->id.qp)
+       if (!status && id_priv->id.qp) {
                status = ib_attach_mcast(id_priv->id.qp, &multicast->rec.mgid,
                                         be16_to_cpu(multicast->rec.mlid));
+               if (!status)
+                       pr_debug_ratelimited("RDMA CM: MULTICAST_ERROR: failed to attach QP. status %d\n",
+                                            status);
+       }
        mutex_unlock(&id_priv->qp_mutex);
 
        memset(&event, 0, sizeof event);