]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[infiniband] Include destination address vector in ib_complete_recv()
authorMichael Brown <mcb30@ipxe.org>
Fri, 31 Aug 2012 00:48:49 +0000 (01:48 +0100)
committerMichael Brown <mcb30@ipxe.org>
Fri, 31 Aug 2012 20:22:58 +0000 (21:22 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/drivers/infiniband/arbel.c
src/drivers/infiniband/hermon.c
src/drivers/infiniband/linda.c
src/drivers/infiniband/qib7322.c
src/drivers/net/ipoib.c
src/include/ipxe/ib_packet.h
src/include/ipxe/infiniband.h
src/net/infiniband.c
src/net/infiniband/ib_cmrc.c
src/net/infiniband/ib_mi.c
src/net/infiniband/ib_packet.c

index 61fe46219f74204af470acaa71d4dc7f49968cd1..1a56ff9af686f262695681815fa2a503292242e6 100644 (file)
@@ -1525,6 +1525,7 @@ static int arbel_complete ( struct ib_device *ibdev,
        struct arbel_recv_work_queue *arbel_recv_wq;
        struct arbelprm_recv_wqe *recv_wqe;
        struct io_buffer *iobuf;
+       struct ib_address_vector recv_dest;
        struct ib_address_vector recv_source;
        struct ib_global_route_header *grh;
        struct ib_address_vector *source;
@@ -1608,6 +1609,8 @@ static int arbel_complete ( struct ib_device *ibdev,
                             l_key, ARBEL_INVALID_LKEY );
                assert ( len <= iob_tailroom ( iobuf ) );
                iob_put ( iobuf, len );
+               memset ( &recv_dest, 0, sizeof ( recv_dest ) );
+               recv_dest.qpn = qpn;
                switch ( qp->type ) {
                case IB_QPT_SMI:
                case IB_QPT_GSI:
@@ -1621,7 +1624,10 @@ static int arbel_complete ( struct ib_device *ibdev,
                        source->qpn = MLX_GET ( &cqe->normal, rqpn );
                        source->lid = MLX_GET ( &cqe->normal, rlid );
                        source->sl = MLX_GET ( &cqe->normal, sl );
-                       source->gid_present = MLX_GET ( &cqe->normal, g );
+                       recv_dest.gid_present = source->gid_present =
+                               MLX_GET ( &cqe->normal, g );
+                       memcpy ( &recv_dest.gid, &grh->dgid,
+                                sizeof ( recv_dest.gid ) );
                        memcpy ( &source->gid, &grh->sgid,
                                 sizeof ( source->gid ) );
                        break;
@@ -1633,7 +1639,7 @@ static int arbel_complete ( struct ib_device *ibdev,
                        return -EINVAL;
                }
                /* Hand off to completion handler */
-               ib_complete_recv ( ibdev, qp, source, iobuf, rc );
+               ib_complete_recv ( ibdev, qp, &recv_dest, source, iobuf, rc );
        }
 
        return rc;
index 7849b14337d1b6dc92a503f62ce22eddf6b2eee4..8a4fba940748c61bd8b787ee849e2756c047e7f5 100644 (file)
@@ -1677,6 +1677,7 @@ static int hermon_complete ( struct ib_device *ibdev,
        struct ib_work_queue *wq;
        struct ib_queue_pair *qp;
        struct io_buffer *iobuf;
+       struct ib_address_vector recv_dest;
        struct ib_address_vector recv_source;
        struct ib_global_route_header *grh;
        struct ib_address_vector *source;
@@ -1737,6 +1738,8 @@ static int hermon_complete ( struct ib_device *ibdev,
                len = MLX_GET ( &cqe->normal, byte_cnt );
                assert ( len <= iob_tailroom ( iobuf ) );
                iob_put ( iobuf, len );
+               memset ( &recv_dest, 0, sizeof ( recv_dest ) );
+               recv_dest.qpn = qpn;
                memset ( &recv_source, 0, sizeof ( recv_source ) );
                switch ( qp->type ) {
                case IB_QPT_SMI:
@@ -1750,7 +1753,10 @@ static int hermon_complete ( struct ib_device *ibdev,
                        source->qpn = MLX_GET ( &cqe->normal, srq_rqpn );
                        source->lid = MLX_GET ( &cqe->normal, slid_smac47_32 );
                        source->sl = MLX_GET ( &cqe->normal, sl );
-                       source->gid_present = MLX_GET ( &cqe->normal, g );
+                       recv_dest.gid_present = source->gid_present =
+                               MLX_GET ( &cqe->normal, g );
+                       memcpy ( &recv_dest.gid, &grh->dgid,
+                                sizeof ( recv_dest.gid ) );
                        memcpy ( &source->gid, &grh->sgid,
                                 sizeof ( source->gid ) );
                        break;
@@ -1768,7 +1774,7 @@ static int hermon_complete ( struct ib_device *ibdev,
                        return -EINVAL;
                }
                /* Hand off to completion handler */
-               ib_complete_recv ( ibdev, qp, source, iobuf, rc );
+               ib_complete_recv ( ibdev, qp, &recv_dest, source, iobuf, rc );
        }
 
        return rc;
@@ -3155,12 +3161,14 @@ static void hermon_eth_complete_send ( struct ib_device *ibdev __unused,
  *
  * @v ibdev            Infiniband device
  * @v qp               Queue pair
+ * @v dest             Destination address vector, or NULL
  * @v source           Source address vector, or NULL
  * @v iobuf            I/O buffer
  * @v rc               Completion status code
  */
 static void hermon_eth_complete_recv ( struct ib_device *ibdev __unused,
                                       struct ib_queue_pair *qp,
+                                      struct ib_address_vector *dest __unused,
                                       struct ib_address_vector *source,
                                       struct io_buffer *iobuf, int rc ) {
        struct net_device *netdev = ib_qp_get_ownerdata ( qp );
index fca17475e5a274c1b75b7291e6547c80788b71b4..4afda1208860c4848de406c497146333e3ae6fbb 100644 (file)
@@ -1170,6 +1170,7 @@ static void linda_complete_recv ( struct ib_device *ibdev,
        struct io_buffer headers;
        struct io_buffer *iobuf;
        struct ib_queue_pair *intended_qp;
+       struct ib_address_vector dest;
        struct ib_address_vector source;
        unsigned int rcvtype;
        unsigned int pktlen;
@@ -1238,7 +1239,7 @@ static void linda_complete_recv ( struct ib_device *ibdev,
        qp0 = ( qp->qpn == 0 );
        intended_qp = NULL;
        if ( ( rc = ib_pull ( ibdev, &headers, ( qp0 ? &intended_qp : NULL ),
-                             &payload_len, &source ) ) != 0 ) {
+                             &payload_len, &dest, &source ) ) != 0 ) {
                DBGC ( linda, "Linda %p could not parse headers: %s\n",
                       linda, strerror ( rc ) );
                err = 1;
@@ -1295,11 +1296,11 @@ static void linda_complete_recv ( struct ib_device *ibdev,
                                qp->recv.fill--;
                                intended_qp->recv.fill++;
                        }
-                       ib_complete_recv ( ibdev, intended_qp, &source,
+                       ib_complete_recv ( ibdev, intended_qp, &dest, &source,
                                           iobuf, rc);
                } else {
                        /* Completing on a skipped-over eager buffer */
-                       ib_complete_recv ( ibdev, qp, &source, iobuf,
+                       ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,
                                           -ECANCELED );
                }
 
index 89614129bed33953864f96681403e2bf3d88438f..9979b346e9c97ed6b1fc5d312ead9cdcbf849c0f 100644 (file)
@@ -1413,6 +1413,7 @@ static void qib7322_complete_recv ( struct ib_device *ibdev,
        struct io_buffer headers;
        struct io_buffer *iobuf;
        struct ib_queue_pair *intended_qp;
+       struct ib_address_vector dest;
        struct ib_address_vector source;
        unsigned int rcvtype;
        unsigned int pktlen;
@@ -1474,7 +1475,7 @@ static void qib7322_complete_recv ( struct ib_device *ibdev,
        qp0 = ( qp->qpn == 0 );
        intended_qp = NULL;
        if ( ( rc = ib_pull ( ibdev, &headers, ( qp0 ? &intended_qp : NULL ),
-                             &payload_len, &source ) ) != 0 ) {
+                             &payload_len, &dest, &source ) ) != 0 ) {
                DBGC ( qib7322, "QIB7322 %p could not parse headers: %s\n",
                       qib7322, strerror ( rc ) );
                err = 1;
@@ -1531,11 +1532,11 @@ static void qib7322_complete_recv ( struct ib_device *ibdev,
                                qp->recv.fill--;
                                intended_qp->recv.fill++;
                        }
-                       ib_complete_recv ( ibdev, intended_qp, &source,
+                       ib_complete_recv ( ibdev, intended_qp, &dest, &source,
                                           iobuf, rc);
                } else {
                        /* Completing on a skipped-over eager buffer */
-                       ib_complete_recv ( ibdev, qp, &source, iobuf,
+                       ib_complete_recv ( ibdev, qp, &dest, &source, iobuf,
                                           -ECANCELED );
                }
 
index bbc9425a6f28e55df616020588c76bf07a2edd6a..41ba348bf6c2296e980cc247e936faac572225b7 100644 (file)
@@ -480,12 +480,14 @@ static void ipoib_complete_send ( struct ib_device *ibdev __unused,
  *
  * @v ibdev            Infiniband device
  * @v qp               Queue pair
+ * @v dest             Destination address vector, or NULL
  * @v source           Source address vector, or NULL
  * @v iobuf            I/O buffer
  * @v rc               Completion status code
  */
 static void ipoib_complete_recv ( struct ib_device *ibdev __unused,
                                  struct ib_queue_pair *qp,
+                                 struct ib_address_vector *dest __unused,
                                  struct ib_address_vector *source,
                                  struct io_buffer *iobuf, int rc ) {
        struct ipoib_device *ipoib = ib_qp_get_ownerdata ( qp );
index 2556b6e18345cccac6fb1e0e2d3ce6339c6a9cce..a959967cbb859e5d6396afb7a05222ab3a690c9c 100644 (file)
@@ -155,6 +155,7 @@ extern int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
                     const struct ib_address_vector *dest );
 extern int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
                     struct ib_queue_pair **qp, size_t *payload_len,
+                    struct ib_address_vector *dest,
                     struct ib_address_vector *source );
 
 #endif /* _IPXE_IB_PACKET_H */
index 48c618875687e6a06e04db8d54ea8bd502c5647f..f546ea61b5036dbc6a882f15a122cc2064f6b82c 100644 (file)
@@ -205,12 +205,14 @@ struct ib_completion_queue_operations {
         *
         * @v ibdev             Infiniband device
         * @v qp                Queue pair
+        * @v dest              Destination address vector, or NULL
         * @v source            Source address vector, or NULL
         * @v iobuf             I/O buffer
         * @v rc                Completion status code
         */
        void ( * complete_recv ) ( struct ib_device *ibdev,
                                   struct ib_queue_pair *qp,
+                                  struct ib_address_vector *dest,
                                   struct ib_address_vector *source,
                                   struct io_buffer *iobuf, int rc );
 };
@@ -511,6 +513,7 @@ extern void ib_complete_send ( struct ib_device *ibdev,
                               struct io_buffer *iobuf, int rc );
 extern void ib_complete_recv ( struct ib_device *ibdev,
                               struct ib_queue_pair *qp,
+                              struct ib_address_vector *dest,
                               struct ib_address_vector *source,
                               struct io_buffer *iobuf, int rc );
 extern void ib_refill_recv ( struct ib_device *ibdev,
index f50778d0059172c2e766eefa4b5ea6ebdda507ba..12d1d83cee34eed80e49a6c4106a77867097e4ca 100644 (file)
@@ -304,7 +304,7 @@ void ib_destroy_qp ( struct ib_device *ibdev, struct ib_queue_pair *qp ) {
        }
        for ( i = 0 ; i < qp->recv.num_wqes ; i++ ) {
                if ( ( iobuf = qp->recv.iobufs[i] ) != NULL ) {
-                       ib_complete_recv ( ibdev, qp, NULL, iobuf,
+                       ib_complete_recv ( ibdev, qp, NULL, NULL, iobuf,
                                           -ECANCELED );
                }
        }
@@ -486,16 +486,19 @@ void ib_complete_send ( struct ib_device *ibdev, struct ib_queue_pair *qp,
  *
  * @v ibdev            Infiniband device
  * @v qp               Queue pair
+ * @v dest             Destination address vector, or NULL
  * @v source           Source address vector, or NULL
  * @v iobuf            I/O buffer
  * @v rc               Completion status code
  */
 void ib_complete_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp,
+                       struct ib_address_vector *dest,
                        struct ib_address_vector *source,
                        struct io_buffer *iobuf, int rc ) {
 
        if ( qp->recv.cq->op->complete_recv ) {
-               qp->recv.cq->op->complete_recv ( ibdev, qp, source, iobuf, rc );
+               qp->recv.cq->op->complete_recv ( ibdev, qp, dest, source,
+                                                iobuf, rc );
        } else {
                free_iob ( iobuf );
        }
index cb5ed47bd6bf5179e1bb7a9c9c7a4b9b78084c3c..1cc0fcfefb6ea9e27b281b9b2971c1333c9814be 100644 (file)
@@ -220,12 +220,14 @@ static void ib_cmrc_complete_send ( struct ib_device *ibdev __unused,
  *
  * @v ibdev            Infiniband device
  * @v qp               Queue pair
+ * @v dest             Destination address vector, or NULL
  * @v source           Source address vector, or NULL
  * @v iobuf            I/O buffer
  * @v rc               Completion status code
  */
 static void ib_cmrc_complete_recv ( struct ib_device *ibdev __unused,
                                    struct ib_queue_pair *qp,
+                                   struct ib_address_vector *dest __unused,
                                    struct ib_address_vector *source __unused,
                                    struct io_buffer *iobuf, int rc ) {
        struct ib_cmrc_connection *cmrc = ib_qp_get_ownerdata ( qp );
index 2ca919436ef073e35c6d5c6de5c70559bc2ed194..ef6d539f112a8317d392c6e395590bf4f6f494c2 100644 (file)
@@ -112,12 +112,14 @@ static int ib_mi_handle ( struct ib_device *ibdev,
  *
  * @v ibdev            Infiniband device
  * @v qp               Queue pair
- * @v source           Address vector
+ * @v dest             Destination address vector
+ * @v source           Source address vector
  * @v iobuf            I/O buffer
  * @v rc               Completion status code
  */
 static void ib_mi_complete_recv ( struct ib_device *ibdev,
                                  struct ib_queue_pair *qp,
+                                 struct ib_address_vector *dest __unused,
                                  struct ib_address_vector *source,
                                  struct io_buffer *iobuf, int rc ) {
        struct ib_mad_interface *mi = ib_qp_get_ownerdata ( qp );
index 36b533f5d0b6cf4617821bc0c672ecc93ebf0695..6c850e39b602c5b0f49a32ce89c9bd1dea03ea09 100644 (file)
@@ -122,11 +122,13 @@ int ib_push ( struct ib_device *ibdev, struct io_buffer *iobuf,
  * @v iobuf            I/O buffer containing headers
  * @v qp               Queue pair to fill in, or NULL
  * @v payload_len      Payload length to fill in, or NULL
+ * @v dest             Destination address vector to fill in
  * @v source           Source address vector to fill in
  * @ret rc             Return status code
  */
 int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
              struct ib_queue_pair **qp, size_t *payload_len,
+             struct ib_address_vector *dest,
              struct ib_address_vector *source ) {
        struct ib_local_route_header *lrh;
        struct ib_global_route_header *grh;
@@ -135,14 +137,13 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
        size_t orig_iob_len = iob_len ( iobuf );
        unsigned int lnh;
        size_t pad_len;
-       unsigned long qpn;
-       unsigned int lid;
 
        /* Clear return values */
        if ( qp )
                *qp = NULL;
        if ( payload_len )
                *payload_len = 0;
+       memset ( dest, 0, sizeof ( *dest ) );
        memset ( source, 0, sizeof ( *source ) );
 
        /* Extract LRH */
@@ -153,10 +154,11 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
        }
        lrh = iobuf->data;
        iob_pull ( iobuf, sizeof ( *lrh ) );
+       dest->lid = ntohs ( lrh->dlid );
+       dest->sl = ( lrh->sl__lnh >> 4 );
        source->lid = ntohs ( lrh->slid );
        source->sl = ( lrh->sl__lnh >> 4 );
        lnh = ( lrh->sl__lnh & 0x3 );
-       lid = ntohs ( lrh->dlid );
 
        /* Reject unsupported packets */
        if ( ! ( ( lnh == IB_LNH_BTH ) || ( lnh == IB_LNH_GRH ) ) ) {
@@ -174,6 +176,8 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
                }
                grh = iobuf->data;
                iob_pull ( iobuf, sizeof ( *grh ) );
+               dest->gid_present = 1;
+               memcpy ( &dest->gid, &grh->dgid, sizeof ( dest->gid ) );
                source->gid_present = 1;
                memcpy ( &source->gid, &grh->sgid, sizeof ( source->gid ) );
        } else {
@@ -193,7 +197,7 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
                       ibdev, bth->opcode );
                return -ENOTSUP;
        }
-       qpn = ntohl ( bth->dest_qp );
+       dest->qpn = ntohl ( bth->dest_qp );
 
        /* Extract DETH */
        if ( iob_len ( iobuf ) < sizeof ( *deth ) ) {
@@ -216,7 +220,7 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
 
        /* Determine destination QP, if applicable */
        if ( qp ) {
-               if ( IB_LID_MULTICAST ( lid ) && grh ) {
+               if ( IB_LID_MULTICAST ( dest->lid ) && grh ) {
                        if ( ! ( *qp = ib_find_qp_mgid ( ibdev, &grh->dgid ))){
                                DBGC ( ibdev, "IBDEV %p RX for unknown MGID "
                                       IB_GID_FMT "\n",
@@ -224,9 +228,9 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
                                return -ENODEV;
                        }
                } else {
-                       if ( ! ( *qp = ib_find_qp_qpn ( ibdev, qpn ) ) ) {
+                       if ( ! ( *qp = ib_find_qp_qpn ( ibdev, dest->qpn ) ) ) {
                                DBGC ( ibdev, "IBDEV %p RX for nonexistent "
-                                      "QPN %lx\n", ibdev, qpn );
+                                      "QPN %lx\n", ibdev, dest->qpn );
                                return -ENODEV;
                        }
                }
@@ -234,8 +238,8 @@ int ib_pull ( struct ib_device *ibdev, struct io_buffer *iobuf,
        }
 
        DBGC2 ( ibdev, "IBDEV %p RX %04x:%08lx <= %04x:%08lx (key %08x)\n",
-               ibdev, lid, ( IB_LID_MULTICAST( lid ) ?
-                             ( qp ? (*qp)->ext_qpn : -1UL ) : qpn ),
+               ibdev, dest->lid, ( IB_LID_MULTICAST ( dest->lid ) ?
+                             ( qp ? (*qp)->ext_qpn : -1UL ) : dest->qpn ),
                source->lid, source->qpn, ntohl ( deth->qkey ) );
        DBGCP_HDA ( ibdev, 0,
                    ( iobuf->data - ( orig_iob_len - iob_len ( iobuf ) ) ),