Browse Source

Make PKB_ZLEN the minimum possible size of packet buffer (to allow for

hardware that can't autopad).
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
6c50564724
2 changed files with 13 additions and 0 deletions
  1. 9
    0
      src/include/gpxe/pkbuff.h
  2. 4
    0
      src/net/pkbuff.c

+ 9
- 0
src/include/gpxe/pkbuff.h View File

28
  */
28
  */
29
 #define PKBUFF_ALIGN 2048
29
 #define PKBUFF_ALIGN 2048
30
 
30
 
31
+/**
32
+ * Minimum packet buffer length
33
+ *
34
+ * alloc_pkb() will round up the allocated length to this size if
35
+ * necessary.  This is used on behalf of hardware that is not capable
36
+ * of auto-padding.
37
+ */
38
+#define PKB_ZLEN 64
39
+
31
 /** A packet buffer
40
 /** A packet buffer
32
  *
41
  *
33
  * This structure is used to represent a network packet within gPXE.
42
  * This structure is used to represent a network packet within gPXE.

+ 4
- 0
src/net/pkbuff.c View File

39
 	struct pk_buff *pkb = NULL;
39
 	struct pk_buff *pkb = NULL;
40
 	void *data;
40
 	void *data;
41
 
41
 
42
+	/* Pad to minimum length */
43
+	if ( len < PKB_ZLEN )
44
+		len = PKB_ZLEN;
45
+
42
 	/* Align buffer length */
46
 	/* Align buffer length */
43
 	len = ( len + __alignof__( *pkb ) - 1 ) & ~( __alignof__( *pkb ) - 1 );
47
 	len = ( len + __alignof__( *pkb ) - 1 ) & ~( __alignof__( *pkb ) - 1 );
44
 	
48
 	

Loading…
Cancel
Save