Browse Source

[hermon] Fix received packet length

Debugged-by: Wissam Shoukair <wissams@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
3ad028cf1c
1 changed files with 3 additions and 2 deletions
  1. 3
    2
      src/drivers/infiniband/hermon.c

+ 3
- 2
src/drivers/infiniband/hermon.c View File

@@ -1769,8 +1769,6 @@ static int hermon_complete ( struct ib_device *ibdev,
1769 1769
 	} else {
1770 1770
 		/* Set received length */
1771 1771
 		len = MLX_GET ( &cqe->normal, byte_cnt );
1772
-		assert ( len <= iob_tailroom ( iobuf ) );
1773
-		iob_put ( iobuf, len );
1774 1772
 		memset ( &recv_dest, 0, sizeof ( recv_dest ) );
1775 1773
 		recv_dest.qpn = qpn;
1776 1774
 		memset ( &recv_source, 0, sizeof ( recv_source ) );
@@ -1781,6 +1779,7 @@ static int hermon_complete ( struct ib_device *ibdev,
1781 1779
 			/* Locate corresponding GRH */
1782 1780
 			assert ( hermon_qp->recv.grh != NULL );
1783 1781
 			grh = &hermon_qp->recv.grh[ wqe_idx & wqe_idx_mask ];
1782
+			len -= sizeof ( *grh );
1784 1783
 			/* Construct address vector */
1785 1784
 			source = &recv_source;
1786 1785
 			source->qpn = MLX_GET ( &cqe->normal, srq_rqpn );
@@ -1806,6 +1805,8 @@ static int hermon_complete ( struct ib_device *ibdev,
1806 1805
 			assert ( 0 );
1807 1806
 			return -EINVAL;
1808 1807
 		}
1808
+		assert ( len <= iob_tailroom ( iobuf ) );
1809
+		iob_put ( iobuf, len );
1809 1810
 		/* Hand off to completion handler */
1810 1811
 		ib_complete_recv ( ibdev, qp, &recv_dest, source, iobuf, rc );
1811 1812
 	}

Loading…
Cancel
Save