]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[infiniband] Use correct transaction identifier in CM responses
authorMichael Brown <mcb30@ipxe.org>
Fri, 4 Mar 2016 12:24:22 +0000 (12:24 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 8 Mar 2016 12:08:58 +0000 (12:08 +0000)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/include/ipxe/ib_mad.h
src/net/infiniband/ib_cm.c
src/net/infiniband/ib_mi.c

index 96e460eddcebf55efd72a44955c636348efdc91a..1342740267e3c0485b4c7cf9db4a41f4487f307b 100644 (file)
@@ -525,6 +525,12 @@ union ib_mad_class_specific {
        struct ib_smp_class_specific smp;
 } __attribute__ (( packed ));
 
+/** A management datagram transaction identifier */
+struct ib_mad_tid {
+       uint32_t high;
+       uint32_t low;
+} __attribute__ (( packed ));
+
 /** A management datagram common header
  *
  * Defined in section 13.4.2 of the IBA.
@@ -536,7 +542,7 @@ struct ib_mad_hdr {
        uint8_t method;
        uint16_t status;
        union ib_mad_class_specific class_specific;
-       uint32_t tid[2];
+       struct ib_mad_tid tid;
        uint16_t attr_id;
        uint8_t reserved[2];
        uint32_t attr_mod;
index 942939574bc8ea5b92e5ec8bbeadeff1c935a574..247b8e7a044fc1116c435d956b8c1821793dd262 100644 (file)
@@ -65,6 +65,7 @@ static struct ib_connection * ib_cm_find ( uint32_t local_id ) {
  *
  * @v ibdev            Infiniband device
  * @v mi               Management interface
+ * @v tid              Transaction identifier
  * @v av               Address vector
  * @v local_id         Local communication ID
  * @v remote_id                Remote communication ID
@@ -72,6 +73,7 @@ static struct ib_connection * ib_cm_find ( uint32_t local_id ) {
  */
 static int ib_cm_send_rtu ( struct ib_device *ibdev,
                            struct ib_mad_interface *mi,
+                           struct ib_mad_tid *tid,
                            struct ib_address_vector *av,
                            uint32_t local_id, uint32_t remote_id ) {
        union ib_mad mad;
@@ -83,6 +85,7 @@ static int ib_cm_send_rtu ( struct ib_device *ibdev,
        mad.hdr.mgmt_class = IB_MGMT_CLASS_CM;
        mad.hdr.class_version = IB_CM_CLASS_VERSION;
        mad.hdr.method = IB_MGMT_METHOD_SEND;
+       memcpy ( &mad.hdr.tid, tid, sizeof ( mad.hdr.tid ) );
        mad.hdr.attr_id = htons ( IB_CM_ATTR_READY_TO_USE );
        rtu->local_id = htonl ( local_id );
        rtu->remote_id = htonl ( remote_id );
@@ -121,7 +124,8 @@ static void ib_cm_recv_rep ( struct ib_device *ibdev,
        conn = ib_cm_find ( local_id );
        if ( conn ) {
                /* Try to send "ready to use" reply */
-               if ( ( rc = ib_cm_send_rtu ( ibdev, mi, av, conn->local_id,
+               if ( ( rc = ib_cm_send_rtu ( ibdev, mi, &mad->hdr.tid, av,
+                                            conn->local_id,
                                             conn->remote_id ) ) != 0 ) {
                        /* Ignore errors; the remote end will retry */
                }
@@ -135,6 +139,7 @@ static void ib_cm_recv_rep ( struct ib_device *ibdev,
  *
  * @v ibdev            Infiniband device
  * @v mi               Management interface
+ * @v tid              Transaction identifier
  * @v av               Address vector
  * @v local_id         Local communication ID
  * @v remote_id                Remote communication ID
@@ -142,6 +147,7 @@ static void ib_cm_recv_rep ( struct ib_device *ibdev,
  */
 static int ib_cm_send_drep ( struct ib_device *ibdev,
                             struct ib_mad_interface *mi,
+                            struct ib_mad_tid *tid,
                             struct ib_address_vector *av,
                             uint32_t local_id, uint32_t remote_id ) {
        union ib_mad mad;
@@ -153,6 +159,7 @@ static int ib_cm_send_drep ( struct ib_device *ibdev,
        mad.hdr.mgmt_class = IB_MGMT_CLASS_CM;
        mad.hdr.class_version = IB_CM_CLASS_VERSION;
        mad.hdr.method = IB_MGMT_METHOD_SEND;
+       memcpy ( &mad.hdr.tid, tid, sizeof ( mad.hdr.tid ) );
        mad.hdr.attr_id = htons ( IB_CM_ATTR_DISCONNECT_REPLY );
        drep->local_id = htonl ( local_id );
        drep->remote_id = htonl ( remote_id );
@@ -197,7 +204,7 @@ static void ib_cm_recv_dreq ( struct ib_device *ibdev,
        }
 
        /* Send reply */
-       if ( ( rc = ib_cm_send_drep ( ibdev, mi, av, local_id,
+       if ( ( rc = ib_cm_send_drep ( ibdev, mi, &mad->hdr.tid, av, local_id,
                                      remote_id ) ) != 0 ) {
                /* Ignore errors; the remote end will retry */
        }
@@ -294,7 +301,8 @@ static void ib_cm_req_complete ( struct ib_device *ibdev,
                }
 
                /* Send "ready to use" reply */
-               if ( ( rc = ib_cm_send_rtu ( ibdev, mi, av, conn->local_id,
+               if ( ( rc = ib_cm_send_rtu ( ibdev, mi, &mad->hdr.tid, av,
+                                            conn->local_id,
                                             conn->remote_id ) ) != 0 ) {
                        /* Treat as non-fatal */
                        rc = 0;
index b432129748479660bbdc41738abd51ec7771d073..f9c0862b989063c5818aa681e9a108d5b74a4ede 100644 (file)
@@ -106,7 +106,7 @@ static int ib_mi_handle ( struct ib_device *ibdev,
 
        /* Otherwise, ignore it */
        DBGC ( mi, "MI %p RX TID %08x%08x ignored\n",
-              mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ) );
+              mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
        return -ENOTSUP;
 }
 
@@ -152,7 +152,7 @@ static void ib_mi_complete_recv ( struct ib_device *ibdev,
                goto out;
        }
        DBGC ( mi, "MI %p RX TID %08x%08x (%02x,%02x,%02x,%04x) status "
-              "%04x\n", mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
+              "%04x\n", mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
               hdr->mgmt_class, hdr->class_version, hdr->method,
               ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
        DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
@@ -192,12 +192,12 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
 
        /* Set common fields */
        hdr->base_version = IB_MGMT_BASE_VERSION;
-       if ( ( hdr->tid[0] == 0 ) && ( hdr->tid[1] == 0 ) ) {
-               hdr->tid[0] = htonl ( IB_MI_TID_MAGIC );
-               hdr->tid[1] = htonl ( ++next_tid );
+       if ( ( hdr->tid.high == 0 ) && ( hdr->tid.low == 0 ) ) {
+               hdr->tid.high = htonl ( IB_MI_TID_MAGIC );
+               hdr->tid.low = htonl ( ++next_tid );
        }
        DBGC ( mi, "MI %p TX TID %08x%08x (%02x,%02x,%02x,%04x) status "
-              "%04x\n", mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
+              "%04x\n", mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
               hdr->mgmt_class, hdr->class_version, hdr->method,
               ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
        DBGC2_HDA ( mi, 0, mad, sizeof ( *mad ) );
@@ -217,8 +217,8 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
                        smp->return_path.hops[hop_pointer] = ibdev->port;
                } else {
                        DBGC ( mi, "MI %p TX TID %08x%08x invalid hop pointer "
-                              "%d\n", mi, ntohl ( hdr->tid[0] ),
-                              ntohl ( hdr->tid[1] ), hop_pointer );
+                              "%d\n", mi, ntohl ( hdr->tid.high ),
+                              ntohl ( hdr->tid.low ), hop_pointer );
                        return -EINVAL;
                }
        }
@@ -228,7 +228,7 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
        if ( ! iobuf ) {
                DBGC ( mi, "MI %p could not allocate buffer for TID "
                       "%08x%08x\n",
-                      mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ) );
+                      mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
                return -ENOMEM;
        }
        memcpy ( iob_put ( iobuf, sizeof ( *mad ) ), mad, sizeof ( *mad ) );
@@ -236,7 +236,7 @@ int ib_mi_send ( struct ib_device *ibdev, struct ib_mad_interface *mi,
        /* Send I/O buffer */
        if ( ( rc = ib_post_send ( ibdev, mi->qp, av, iobuf ) ) != 0 ) {
                DBGC ( mi, "MI %p TX TID %08x%08x failed: %s\n",
-                      mi,  ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
+                      mi,  ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ),
                       strerror ( rc ) );
                free_iob ( iobuf );
                return rc;
@@ -261,7 +261,7 @@ static void ib_mi_timer_expired ( struct retry_timer *timer, int expired ) {
        /* Abandon transaction if we have tried too many times */
        if ( expired ) {
                DBGC ( mi, "MI %p abandoning TID %08x%08x\n",
-                      mi, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ) );
+                      mi, ntohl ( hdr->tid.high ), ntohl ( hdr->tid.low ) );
                madx->op->complete ( ibdev, mi, madx, -ETIMEDOUT, NULL, NULL );
                return;
        }
@@ -408,8 +408,8 @@ void ib_destroy_mi ( struct ib_device *ibdev, struct ib_mad_interface *mi ) {
        /* Flush any outstanding requests */
        list_for_each_entry_safe ( madx, tmp, &mi->madx, list ) {
                DBGC ( mi, "MI %p destroyed while TID %08x%08x in progress\n",
-                      mi, ntohl ( madx->mad.hdr.tid[0] ),
-                      ntohl ( madx->mad.hdr.tid[1] ) );
+                      mi, ntohl ( madx->mad.hdr.tid.high ),
+                      ntohl ( madx->mad.hdr.tid.low ) );
                madx->op->complete ( ibdev, mi, madx, -ECANCELED, NULL, NULL );
        }