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,6 +172,9 @@ struct nii_nic {
172 172
 	/** Saved task priority level */
173 173
 	EFI_TPL saved_tpl;
174 174
 
175
+	/** Media status is supported */
176
+	int media;
177
+
175 178
 	/** Current transmit buffer */
176 179
 	struct io_buffer *txbuf;
177 180
 	/** Current receive buffer */
@@ -556,6 +559,7 @@ static int nii_get_init_info ( struct nii_nic *nii,
556 559
 	nii->buffer_len = db.MemoryRequired;
557 560
 	nii->mtu = ( db.FrameDataLen + db.MediaHeaderLen );
558 561
 	netdev->max_pkt_len = nii->mtu;
562
+	nii->media = ( stat & PXE_STATFLAGS_GET_STATUS_NO_MEDIA_SUPPORTED );
559 563
 
560 564
 	return 0;
561 565
 }
@@ -878,11 +882,14 @@ static void nii_poll ( struct net_device *netdev ) {
878 882
 	int stat;
879 883
 	int rc;
880 884
 
885
+	/* Construct data block */
886
+	memset ( &db, 0, sizeof ( db ) );
887
+
881 888
 	/* Get status */
882 889
 	op = NII_OP ( PXE_OPCODE_GET_STATUS,
883 890
 		      ( PXE_OPFLAGS_GET_INTERRUPT_STATUS |
884 891
 			PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS |
885
-			PXE_OPFLAGS_GET_MEDIA_STATUS ) );
892
+			( nii->media ? PXE_OPFLAGS_GET_MEDIA_STATUS : 0 ) ) );
886 893
 	if ( ( stat = nii_issue_db ( nii, op, &db, sizeof ( db ) ) ) < 0 ) {
887 894
 		rc = -EIO_STAT ( stat );
888 895
 		DBGC ( nii, "NII %s could not get status: %s\n",
@@ -897,7 +904,8 @@ static void nii_poll ( struct net_device *netdev ) {
897 904
 	nii_poll_rx ( netdev );
898 905
 
899 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,6 +1065,10 @@ int nii_start ( struct efi_device *efidev ) {
1057 1065
 	DBGC ( nii, "NII %s registered as %s for %p %s\n", nii->dev.name,
1058 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 1072
 	return 0;
1061 1073
 
1062 1074
 	unregister_netdev ( netdev );

Loading…
Cancel
Save