Browse Source

[infiniband] Centralise assumption of 2048-byte payloads

IPoIB and the SMA have separate constants for the packet size to be
used to I/O buffer allocations.  Merge these into the single
IB_MAX_PAYLOAD_SIZE constant.

(Various other points in the Infiniband stack have hard-coded
assumptions of a 2048-byte payload; we don't currently support
variable MTUs.)
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
1f5c0239b4

+ 3
- 3
src/drivers/net/ipoib.c View File

838
 				     IPOIB_META_NUM_CQES, &ipoib_meta_cq_op,
838
 				     IPOIB_META_NUM_CQES, &ipoib_meta_cq_op,
839
 				     IPOIB_META_NUM_SEND_WQES,
839
 				     IPOIB_META_NUM_SEND_WQES,
840
 				     IPOIB_META_NUM_RECV_WQES,
840
 				     IPOIB_META_NUM_RECV_WQES,
841
-				     IPOIB_PKT_LEN, IB_GLOBAL_QKEY ) ) != 0 ) {
841
+				     IB_GLOBAL_QKEY ) ) != 0 ) {
842
 		DBGC ( ipoib, "IPoIB %p could not allocate metadata QP: %s\n",
842
 		DBGC ( ipoib, "IPoIB %p could not allocate metadata QP: %s\n",
843
 		       ipoib, strerror ( rc ) );
843
 		       ipoib, strerror ( rc ) );
844
 		goto err_create_meta_qset;
844
 		goto err_create_meta_qset;
850
 				     IPOIB_DATA_NUM_CQES, &ipoib_data_cq_op,
850
 				     IPOIB_DATA_NUM_CQES, &ipoib_data_cq_op,
851
 				     IPOIB_DATA_NUM_SEND_WQES,
851
 				     IPOIB_DATA_NUM_SEND_WQES,
852
 				     IPOIB_DATA_NUM_RECV_WQES,
852
 				     IPOIB_DATA_NUM_RECV_WQES,
853
-				     IPOIB_PKT_LEN, IB_GLOBAL_QKEY ) ) != 0 ) {
853
+				     IB_GLOBAL_QKEY ) ) != 0 ) {
854
 		DBGC ( ipoib, "IPoIB %p could not allocate data QP: %s\n",
854
 		DBGC ( ipoib, "IPoIB %p could not allocate data QP: %s\n",
855
 		       ipoib, strerror ( rc ) );
855
 		       ipoib, strerror ( rc ) );
856
 		goto err_create_data_qset;
856
 		goto err_create_data_qset;
1040
 	if ( netdev ) {
1040
 	if ( netdev ) {
1041
 		netdev->ll_protocol = &ipoib_protocol;
1041
 		netdev->ll_protocol = &ipoib_protocol;
1042
 		netdev->ll_broadcast = ( uint8_t * ) &ipoib_broadcast;
1042
 		netdev->ll_broadcast = ( uint8_t * ) &ipoib_broadcast;
1043
-		netdev->max_pkt_len = IPOIB_PKT_LEN;
1043
+		netdev->max_pkt_len = IB_MAX_PAYLOAD_SIZE;
1044
 	}
1044
 	}
1045
 	return netdev;
1045
 	return netdev;
1046
 }
1046
 }

+ 1
- 4
src/include/gpxe/ib_qset.h View File

20
 	struct ib_queue_pair *qp;
20
 	struct ib_queue_pair *qp;
21
 	/** Receive work queue maximum fill level */
21
 	/** Receive work queue maximum fill level */
22
 	unsigned int recv_max_fill;
22
 	unsigned int recv_max_fill;
23
-	/** Receive packet length */
24
-	size_t recv_pkt_len;
25
 };
23
 };
26
 
24
 
27
 extern int ib_create_qset ( struct ib_device *ibdev,
25
 extern int ib_create_qset ( struct ib_device *ibdev,
28
 			    struct ib_queue_set *qset, unsigned int num_cqes,
26
 			    struct ib_queue_set *qset, unsigned int num_cqes,
29
 			    struct ib_completion_queue_operations *cq_op,
27
 			    struct ib_completion_queue_operations *cq_op,
30
 			    unsigned int num_send_wqes,
28
 			    unsigned int num_send_wqes,
31
-			    unsigned int num_recv_wqes, size_t recv_pkt_len,
32
-			    unsigned long qkey );
29
+			    unsigned int num_recv_wqes, unsigned long qkey );
33
 extern void ib_qset_refill_recv ( struct ib_device *ibdev,
30
 extern void ib_qset_refill_recv ( struct ib_device *ibdev,
34
 				  struct ib_queue_set *qset );
31
 				  struct ib_queue_set *qset );
35
 extern void ib_destroy_qset ( struct ib_device *ibdev,
32
 extern void ib_destroy_qset ( struct ib_device *ibdev,

+ 0
- 3
src/include/gpxe/ib_sma.h View File

37
 	struct process poll;
37
 	struct process poll;
38
 };
38
 };
39
 
39
 
40
-/** SMA payload size allocated for received packets */
41
-#define IB_SMA_PAYLOAD_LEN 2048
42
-
43
 /** SMA number of send WQEs
40
 /** SMA number of send WQEs
44
  *
41
  *
45
  * This is a policy decision.
42
  * This is a policy decision.

+ 8
- 0
src/include/gpxe/infiniband.h View File

24
 /** Subnet administrator queue key */
24
 /** Subnet administrator queue key */
25
 #define IB_GLOBAL_QKEY 0x80010000UL
25
 #define IB_GLOBAL_QKEY 0x80010000UL
26
 
26
 
27
+/**
28
+ * Maximum payload size
29
+ *
30
+ * This is currently hard-coded in various places (drivers, subnet
31
+ * management agent, etc.) to 2048.
32
+ */
33
+#define IB_MAX_PAYLOAD_SIZE 2048
34
+
27
 struct ib_device;
35
 struct ib_device;
28
 struct ib_queue_pair;
36
 struct ib_queue_pair;
29
 struct ib_address_vector;
37
 struct ib_address_vector;

+ 0
- 3
src/include/gpxe/ipoib.h View File

10
 
10
 
11
 #include <gpxe/infiniband.h>
11
 #include <gpxe/infiniband.h>
12
 
12
 
13
-/** IPoIB packet length */
14
-#define IPOIB_PKT_LEN 2048
15
-
16
 /** IPoIB MAC address length */
13
 /** IPoIB MAC address length */
17
 #define IPOIB_ALEN 20
14
 #define IPOIB_ALEN 20
18
 
15
 

+ 7
- 0
src/net/infiniband.c View File

345
 		   struct io_buffer *iobuf ) {
345
 		   struct io_buffer *iobuf ) {
346
 	int rc;
346
 	int rc;
347
 
347
 
348
+	/* Check packet length */
349
+	if ( iob_tailroom ( iobuf ) < IB_MAX_PAYLOAD_SIZE ) {
350
+		DBGC ( ibdev, "IBDEV %p QPN %#lx wrong RX buffer size (%zd)\n",
351
+		       ibdev, qp->qpn, iob_tailroom ( iobuf ) );
352
+		return -EINVAL;
353
+	}
354
+
348
 	/* Check queue fill level */
355
 	/* Check queue fill level */
349
 	if ( qp->recv.fill >= qp->recv.num_wqes ) {
356
 	if ( qp->recv.fill >= qp->recv.num_wqes ) {
350
 		DBGC ( ibdev, "IBDEV %p QPN %#lx receive queue full\n",
357
 		DBGC ( ibdev, "IBDEV %p QPN %#lx receive queue full\n",

+ 2
- 4
src/net/infiniband/ib_qset.c View File

40
  * @v cq_op		Completion queue operations
40
  * @v cq_op		Completion queue operations
41
  * @v num_send_wqes	Number of send work queue entries
41
  * @v num_send_wqes	Number of send work queue entries
42
  * @v num_recv_wqes	Number of receive work queue entries
42
  * @v num_recv_wqes	Number of receive work queue entries
43
- * @v recv_pkt_len	Receive packet length
44
  * @v qkey		Queue key
43
  * @v qkey		Queue key
45
  * @ret rc		Return status code
44
  * @ret rc		Return status code
46
  */
45
  */
48
 		     unsigned int num_cqes,
47
 		     unsigned int num_cqes,
49
 		     struct ib_completion_queue_operations *cq_op,
48
 		     struct ib_completion_queue_operations *cq_op,
50
 		     unsigned int num_send_wqes, unsigned int num_recv_wqes,
49
 		     unsigned int num_send_wqes, unsigned int num_recv_wqes,
51
-		     size_t recv_pkt_len, unsigned long qkey ) {
50
+		     unsigned long qkey ) {
52
 	int rc;
51
 	int rc;
53
 
52
 
54
 	/* Sanity check */
53
 	/* Sanity check */
57
 
56
 
58
 	/* Store queue parameters */
57
 	/* Store queue parameters */
59
 	qset->recv_max_fill = num_recv_wqes;
58
 	qset->recv_max_fill = num_recv_wqes;
60
-	qset->recv_pkt_len = recv_pkt_len;
61
 
59
 
62
 	/* Allocate completion queue */
60
 	/* Allocate completion queue */
63
 	qset->cq = ib_create_cq ( ibdev, num_cqes, cq_op );
61
 	qset->cq = ib_create_cq ( ibdev, num_cqes, cq_op );
99
 	while ( qset->qp->recv.fill < qset->recv_max_fill ) {
97
 	while ( qset->qp->recv.fill < qset->recv_max_fill ) {
100
 
98
 
101
 		/* Allocate I/O buffer */
99
 		/* Allocate I/O buffer */
102
-		iobuf = alloc_iob ( qset->recv_pkt_len );
100
+		iobuf = alloc_iob ( IB_MAX_PAYLOAD_SIZE );
103
 		if ( ! iobuf ) {
101
 		if ( ! iobuf ) {
104
 			/* Non-fatal; we will refill on next attempt */
102
 			/* Non-fatal; we will refill on next attempt */
105
 			return;
103
 			return;

+ 1
- 1
src/net/infiniband/ib_sma.c View File

361
 	while ( sma->qp->recv.fill < IB_SMA_NUM_RECV_WQES ) {
361
 	while ( sma->qp->recv.fill < IB_SMA_NUM_RECV_WQES ) {
362
 
362
 
363
 		/* Allocate I/O buffer */
363
 		/* Allocate I/O buffer */
364
-		iobuf = alloc_iob ( IB_SMA_PAYLOAD_LEN );
364
+		iobuf = alloc_iob ( IB_MAX_PAYLOAD_SIZE );
365
 		if ( ! iobuf ) {
365
 		if ( ! iobuf ) {
366
 			/* Non-fatal; we will refill on next attempt */
366
 			/* Non-fatal; we will refill on next attempt */
367
 			return;
367
 			return;

Loading…
Cancel
Save