Browse Source

[efi] Provide guaranteed space in transmitted packets

eIPoIB requires space to expand a transmitted ARP packet.  This
guarantee is met by ensuring that a transmitted packet consists of at
least MAX_LL_HEADER_LEN bytes from the start of the I/O buffer up to
the end of the link-layer header, and at least IOB_ZLEN bytes
thereafter.

Adjust the I/O buffer allocation for SNP transmitted packets to ensure
that this guarantee is met.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
09cc63fc8b
1 changed files with 7 additions and 6 deletions
  1. 7
    6
      src/interface/efi/efi_snp.c

+ 7
- 6
src/interface/efi/efi_snp.c View File

536
 		container_of ( snp, struct efi_snp_device, snp );
536
 		container_of ( snp, struct efi_snp_device, snp );
537
 	struct ll_protocol *ll_protocol = snpdev->netdev->ll_protocol;
537
 	struct ll_protocol *ll_protocol = snpdev->netdev->ll_protocol;
538
 	struct io_buffer *iobuf;
538
 	struct io_buffer *iobuf;
539
-	size_t ll_headroom;
539
+	size_t payload_len;
540
 	int rc;
540
 	int rc;
541
 	EFI_STATUS efirc;
541
 	EFI_STATUS efirc;
542
 
542
 
589
 	}
589
 	}
590
 
590
 
591
 	/* Allocate buffer */
591
 	/* Allocate buffer */
592
-	ll_headroom = ( MAX_LL_HEADER_LEN - ll_header_len );
593
-	iobuf = alloc_iob ( ll_headroom +
594
-			    ( ( len > IOB_ZLEN ) ? len : IOB_ZLEN ) );
592
+	payload_len = ( len - ll_protocol->ll_header_len );
593
+	iobuf = alloc_iob ( MAX_LL_HEADER_LEN + ( ( payload_len > IOB_ZLEN ) ?
594
+						  payload_len : IOB_ZLEN ) );
595
 	if ( ! iobuf ) {
595
 	if ( ! iobuf ) {
596
 		DBGC ( snpdev, "SNPDEV %p TX could not allocate %ld-byte "
596
 		DBGC ( snpdev, "SNPDEV %p TX could not allocate %ld-byte "
597
 		       "buffer\n", snpdev, ( ( unsigned long ) len ) );
597
 		       "buffer\n", snpdev, ( ( unsigned long ) len ) );
598
 		efirc = EFI_DEVICE_ERROR;
598
 		efirc = EFI_DEVICE_ERROR;
599
 		goto err_alloc_iob;
599
 		goto err_alloc_iob;
600
 	}
600
 	}
601
-	iob_reserve ( iobuf, ll_headroom );
601
+	iob_reserve ( iobuf, ( MAX_LL_HEADER_LEN -
602
+			       ll_protocol->ll_header_len ) );
602
 	memcpy ( iob_put ( iobuf, len ), data, len );
603
 	memcpy ( iob_put ( iobuf, len ), data, len );
603
 
604
 
604
 	/* Create link-layer header, if specified */
605
 	/* Create link-layer header, if specified */
605
 	if ( ll_header_len ) {
606
 	if ( ll_header_len ) {
606
-		iob_pull ( iobuf, ll_header_len );
607
+		iob_pull ( iobuf, ll_protocol->ll_header_len );
607
 		if ( ( rc = ll_protocol->push ( snpdev->netdev,
608
 		if ( ( rc = ll_protocol->push ( snpdev->netdev,
608
 						iobuf, ll_dest, ll_src,
609
 						iobuf, ll_dest, ll_src,
609
 						htons ( *net_proto ) )) != 0 ){
610
 						htons ( *net_proto ) )) != 0 ){

Loading…
Cancel
Save