瀏覽代碼

[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 年之前
父節點
當前提交
1f5c0239b4

+ 3
- 3
src/drivers/net/ipoib.c 查看文件

@@ -838,7 +838,7 @@ static int ipoib_open ( struct net_device *netdev ) {
838 838
 				     IPOIB_META_NUM_CQES, &ipoib_meta_cq_op,
839 839
 				     IPOIB_META_NUM_SEND_WQES,
840 840
 				     IPOIB_META_NUM_RECV_WQES,
841
-				     IPOIB_PKT_LEN, IB_GLOBAL_QKEY ) ) != 0 ) {
841
+				     IB_GLOBAL_QKEY ) ) != 0 ) {
842 842
 		DBGC ( ipoib, "IPoIB %p could not allocate metadata QP: %s\n",
843 843
 		       ipoib, strerror ( rc ) );
844 844
 		goto err_create_meta_qset;
@@ -850,7 +850,7 @@ static int ipoib_open ( struct net_device *netdev ) {
850 850
 				     IPOIB_DATA_NUM_CQES, &ipoib_data_cq_op,
851 851
 				     IPOIB_DATA_NUM_SEND_WQES,
852 852
 				     IPOIB_DATA_NUM_RECV_WQES,
853
-				     IPOIB_PKT_LEN, IB_GLOBAL_QKEY ) ) != 0 ) {
853
+				     IB_GLOBAL_QKEY ) ) != 0 ) {
854 854
 		DBGC ( ipoib, "IPoIB %p could not allocate data QP: %s\n",
855 855
 		       ipoib, strerror ( rc ) );
856 856
 		goto err_create_data_qset;
@@ -1040,7 +1040,7 @@ struct net_device * alloc_ipoibdev ( size_t priv_size ) {
1040 1040
 	if ( netdev ) {
1041 1041
 		netdev->ll_protocol = &ipoib_protocol;
1042 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 1045
 	return netdev;
1046 1046
 }

+ 1
- 4
src/include/gpxe/ib_qset.h 查看文件

@@ -20,16 +20,13 @@ struct ib_queue_set {
20 20
 	struct ib_queue_pair *qp;
21 21
 	/** Receive work queue maximum fill level */
22 22
 	unsigned int recv_max_fill;
23
-	/** Receive packet length */
24
-	size_t recv_pkt_len;
25 23
 };
26 24
 
27 25
 extern int ib_create_qset ( struct ib_device *ibdev,
28 26
 			    struct ib_queue_set *qset, unsigned int num_cqes,
29 27
 			    struct ib_completion_queue_operations *cq_op,
30 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 30
 extern void ib_qset_refill_recv ( struct ib_device *ibdev,
34 31
 				  struct ib_queue_set *qset );
35 32
 extern void ib_destroy_qset ( struct ib_device *ibdev,

+ 0
- 3
src/include/gpxe/ib_sma.h 查看文件

@@ -37,9 +37,6 @@ struct ib_sma {
37 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 40
 /** SMA number of send WQEs
44 41
  *
45 42
  * This is a policy decision.

+ 8
- 0
src/include/gpxe/infiniband.h 查看文件

@@ -24,6 +24,14 @@ FILE_LICENCE ( GPL2_OR_LATER );
24 24
 /** Subnet administrator queue key */
25 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 35
 struct ib_device;
28 36
 struct ib_queue_pair;
29 37
 struct ib_address_vector;

+ 0
- 3
src/include/gpxe/ipoib.h 查看文件

@@ -10,9 +10,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
10 10
 
11 11
 #include <gpxe/infiniband.h>
12 12
 
13
-/** IPoIB packet length */
14
-#define IPOIB_PKT_LEN 2048
15
-
16 13
 /** IPoIB MAC address length */
17 14
 #define IPOIB_ALEN 20
18 15
 

+ 7
- 0
src/net/infiniband.c 查看文件

@@ -345,6 +345,13 @@ int ib_post_recv ( struct ib_device *ibdev, struct ib_queue_pair *qp,
345 345
 		   struct io_buffer *iobuf ) {
346 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 355
 	/* Check queue fill level */
349 356
 	if ( qp->recv.fill >= qp->recv.num_wqes ) {
350 357
 		DBGC ( ibdev, "IBDEV %p QPN %#lx receive queue full\n",

+ 2
- 4
src/net/infiniband/ib_qset.c 查看文件

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

+ 1
- 1
src/net/infiniband/ib_sma.c 查看文件

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

Loading…
取消
儲存