IB/qib: Optimize RC/UC code by IB operation
authorMike Marciniszyn <mike.marciniszyn@qlogic.com>
Fri, 23 Sep 2011 17:16:29 +0000 (13:16 -0400)
committerRoland Dreier <roland@purestorage.com>
Fri, 21 Oct 2011 16:38:49 +0000 (09:38 -0700)
The memset for zeroing work completions had been unconditional.

This patch removes the memset and moves the zeroing into the work
completion with a more explicit field by field set.  With this patch,
non-ONLY/non-LAST packets will avoid the overhead since they will not
generate a completion.

Signed-off-by: Mike Marciniszyn <mike.marciniszyn@qlogic.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/qib/qib_rc.c
drivers/infiniband/hw/qib/qib_uc.c

index eca0c41f12269cfc18a43ab9f0b0ad58fc136aff..5c1c49b299f1cf5e0b990421aa63d669c770dbdf 100644 (file)
@@ -1955,8 +1955,6 @@ void qib_rc_rcv(struct qib_ctxtdata *rcd, struct qib_ib_header *hdr,
                break;
        }
 
-       memset(&wc, 0, sizeof wc);
-
        if (qp->state == IB_QPS_RTR && !(qp->r_flags & QIB_R_COMM_EST)) {
                qp->r_flags |= QIB_R_COMM_EST;
                if (qp->ibqp.event_handler) {
@@ -2009,16 +2007,19 @@ send_middle:
                        goto rnr_nak;
                qp->r_rcv_len = 0;
                if (opcode == OP(SEND_ONLY))
-                       goto send_last;
-               /* FALLTHROUGH */
+                       goto no_immediate_data;
+               /* FALLTHROUGH for SEND_ONLY_WITH_IMMEDIATE */
        case OP(SEND_LAST_WITH_IMMEDIATE):
 send_last_imm:
                wc.ex.imm_data = ohdr->u.imm_data;
                hdrsize += 4;
                wc.wc_flags = IB_WC_WITH_IMM;
-               /* FALLTHROUGH */
+               goto send_last;
        case OP(SEND_LAST):
        case OP(RDMA_WRITE_LAST):
+no_immediate_data:
+               wc.wc_flags = 0;
+               wc.ex.imm_data = 0;
 send_last:
                /* Get the number of bytes the message was padded by. */
                pad = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
@@ -2051,6 +2052,12 @@ send_last:
                wc.src_qp = qp->remote_qpn;
                wc.slid = qp->remote_ah_attr.dlid;
                wc.sl = qp->remote_ah_attr.sl;
+               /* zero fields that are N/A */
+               wc.vendor_err = 0;
+               wc.pkey_index = 0;
+               wc.dlid_path_bits = 0;
+               wc.port_num = 0;
+               wc.csum_ok = 0;
                /* Signal completion event if the solicited bit is set. */
                qib_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
                             (ohdr->bth[0] &
@@ -2089,7 +2096,7 @@ send_last:
                if (opcode == OP(RDMA_WRITE_FIRST))
                        goto send_middle;
                else if (opcode == OP(RDMA_WRITE_ONLY))
-                       goto send_last;
+                       goto no_immediate_data;
                ret = qib_get_rwqe(qp, 1);
                if (ret < 0)
                        goto nack_op_err;
index 32ccf3c824ca5545bdf5972123016dca5fb110d4..d31f33a99887c4b72c7888dfa58176919db50515 100644 (file)
@@ -270,7 +270,6 @@ void qib_uc_rcv(struct qib_ibport *ibp, struct qib_ib_header *hdr,
 
        psn = be32_to_cpu(ohdr->bth[2]);
        opcode >>= 24;
-       memset(&wc, 0, sizeof wc);
 
        /* Compare the PSN verses the expected PSN. */
        if (unlikely(qib_cmp24(psn, qp->r_psn) != 0)) {
@@ -370,7 +369,7 @@ send_first:
                }
                qp->r_rcv_len = 0;
                if (opcode == OP(SEND_ONLY))
-                       goto send_last;
+                       goto no_immediate_data;
                else if (opcode == OP(SEND_ONLY_WITH_IMMEDIATE))
                        goto send_last_imm;
                /* FALLTHROUGH */
@@ -389,8 +388,11 @@ send_last_imm:
                wc.ex.imm_data = ohdr->u.imm_data;
                hdrsize += 4;
                wc.wc_flags = IB_WC_WITH_IMM;
-               /* FALLTHROUGH */
+               goto send_last;
        case OP(SEND_LAST):
+no_immediate_data:
+               wc.ex.imm_data = 0;
+               wc.wc_flags = 0;
 send_last:
                /* Get the number of bytes the message was padded by. */
                pad = (be32_to_cpu(ohdr->bth[0]) >> 20) & 3;
@@ -418,6 +420,12 @@ last_imm:
                wc.src_qp = qp->remote_qpn;
                wc.slid = qp->remote_ah_attr.dlid;
                wc.sl = qp->remote_ah_attr.sl;
+               /* zero fields that are N/A */
+               wc.vendor_err = 0;
+               wc.pkey_index = 0;
+               wc.dlid_path_bits = 0;
+               wc.port_num = 0;
+               wc.csum_ok = 0;
                /* Signal completion event if the solicited bit is set. */
                qib_cq_enter(to_icq(qp->ibqp.recv_cq), &wc,
                             (ohdr->bth[0] &