Browse Source

[efi] Poll media status only if advertised as supported

Some NII implementations will fail the GET_STATUS operation if we
request the media status.  Fix by doing so only if GET_INIT_INFO
reported that media status is supported.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
729c16ad5b
1 changed files with 14 additions and 2 deletions
  1. 14
    2
      src/drivers/net/efi/nii.c

+ 14
- 2
src/drivers/net/efi/nii.c View File

172
 	/** Saved task priority level */
172
 	/** Saved task priority level */
173
 	EFI_TPL saved_tpl;
173
 	EFI_TPL saved_tpl;
174
 
174
 
175
+	/** Media status is supported */
176
+	int media;
177
+
175
 	/** Current transmit buffer */
178
 	/** Current transmit buffer */
176
 	struct io_buffer *txbuf;
179
 	struct io_buffer *txbuf;
177
 	/** Current receive buffer */
180
 	/** Current receive buffer */
556
 	nii->buffer_len = db.MemoryRequired;
559
 	nii->buffer_len = db.MemoryRequired;
557
 	nii->mtu = ( db.FrameDataLen + db.MediaHeaderLen );
560
 	nii->mtu = ( db.FrameDataLen + db.MediaHeaderLen );
558
 	netdev->max_pkt_len = nii->mtu;
561
 	netdev->max_pkt_len = nii->mtu;
562
+	nii->media = ( stat & PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED );
559
 
563
 
560
 	return 0;
564
 	return 0;
561
 }
565
 }
878
 	int stat;
882
 	int stat;
879
 	int rc;
883
 	int rc;
880
 
884
 
885
+	/* Construct data block */
886
+	memset ( &db, 0, sizeof ( db ) );
887
+
881
 	/* Get status */
888
 	/* Get status */
882
 	op = NII_OP ( PXE_OPCODE_GET_STATUS,
889
 	op = NII_OP ( PXE_OPCODE_GET_STATUS,
883
 		      ( PXE_OPFLAGS_GET_INTERRUPT_STATUS |
890
 		      ( PXE_OPFLAGS_GET_INTERRUPT_STATUS |
884
 			PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS |
891
 			PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS |
885
-			PXE_OPFLAGS_GET_MEDIA_STATUS ) );
892
+			( nii->media ? PXE_OPFLAGS_GET_MEDIA_STATUS : 0 ) ) );
886
 	if ( ( stat = nii_issue_db ( nii, op, &db, sizeof ( db ) ) ) < 0 ) {
893
 	if ( ( stat = nii_issue_db ( nii, op, &db, sizeof ( db ) ) ) < 0 ) {
887
 		rc = -EIO_STAT ( stat );
894
 		rc = -EIO_STAT ( stat );
888
 		DBGC ( nii, "NII %s could not get status: %s\n",
895
 		DBGC ( nii, "NII %s could not get status: %s\n",
897
 	nii_poll_rx ( netdev );
904
 	nii_poll_rx ( netdev );
898
 
905
 
899
 	/* Check for link state changes */
906
 	/* Check for link state changes */
900
-	nii_poll_link ( netdev, stat );
907
+	if ( nii->media )
908
+		nii_poll_link ( netdev, stat );
901
 }
909
 }
902
 
910
 
903
 /**
911
 /**
1057
 	DBGC ( nii, "NII %s registered as %s for %p %s\n", nii->dev.name,
1065
 	DBGC ( nii, "NII %s registered as %s for %p %s\n", nii->dev.name,
1058
 	       netdev->name, device, efi_handle_name ( device ) );
1066
 	       netdev->name, device, efi_handle_name ( device ) );
1059
 
1067
 
1068
+	/* Set initial link state (if media detection is not supported) */
1069
+	if ( ! nii->media )
1070
+		netdev_link_up ( netdev );
1071
+
1060
 	return 0;
1072
 	return 0;
1061
 
1073
 
1062
 	unregister_netdev ( netdev );
1074
 	unregister_netdev ( netdev );

Loading…
Cancel
Save