|
@@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
26
|
26
|
#include <ipxe/iobuf.h>
|
27
|
27
|
#include <ipxe/netdevice.h>
|
28
|
28
|
#include <ipxe/ethernet.h>
|
|
29
|
+#include <ipxe/vsprintf.h>
|
29
|
30
|
#include <ipxe/efi/efi.h>
|
30
|
31
|
#include <ipxe/efi/Protocol/SimpleNetwork.h>
|
31
|
32
|
#include <ipxe/efi/efi_driver.h>
|
|
@@ -71,6 +72,65 @@ static EFI_GUID efi_simple_network_protocol_guid
|
71
|
72
|
static EFI_GUID efi_pci_io_protocol_guid
|
72
|
73
|
= EFI_PCI_IO_PROTOCOL_GUID;
|
73
|
74
|
|
|
75
|
+/**
|
|
76
|
+ * Format SNP MAC address (for debugging)
|
|
77
|
+ *
|
|
78
|
+ * @v mac MAC address
|
|
79
|
+ * @v len Length of MAC address
|
|
80
|
+ * @ret text MAC address as text
|
|
81
|
+ */
|
|
82
|
+static const char * snpnet_mac_text ( EFI_MAC_ADDRESS *mac, size_t len ) {
|
|
83
|
+ static char buf[ sizeof ( *mac ) * 3 /* "xx:" or "xx\0" */ ];
|
|
84
|
+ size_t used = 0;
|
|
85
|
+ unsigned int i;
|
|
86
|
+
|
|
87
|
+ for ( i = 0 ; i < len ; i++ ) {
|
|
88
|
+ used += ssnprintf ( &buf[used], ( sizeof ( buf ) - used ),
|
|
89
|
+ "%s%02x", ( used ? ":" : "" ),
|
|
90
|
+ mac->Addr[i] );
|
|
91
|
+ }
|
|
92
|
+ return buf;
|
|
93
|
+}
|
|
94
|
+
|
|
95
|
+/**
|
|
96
|
+ * Dump SNP mode information (for debugging)
|
|
97
|
+ *
|
|
98
|
+ * @v netdev Network device
|
|
99
|
+ */
|
|
100
|
+static void snpnet_dump_mode ( struct net_device *netdev ) {
|
|
101
|
+ struct snp_nic *snp = netdev_priv ( netdev );
|
|
102
|
+ EFI_SIMPLE_NETWORK_MODE *mode = snp->snp->Mode;
|
|
103
|
+ size_t mac_len = mode->HwAddressSize;
|
|
104
|
+ unsigned int i;
|
|
105
|
+
|
|
106
|
+ /* Do nothing unless debugging is enabled */
|
|
107
|
+ if ( ! DBG_EXTRA )
|
|
108
|
+ return;
|
|
109
|
+
|
|
110
|
+ DBGC2 ( snp, "SNP %s st %d type %d hdr %d pkt %d rxflt %#x/%#x%s "
|
|
111
|
+ "nvram %d acc %d mcast %d/%d\n", netdev->name, mode->State,
|
|
112
|
+ mode->IfType, mode->MediaHeaderSize, mode->MaxPacketSize,
|
|
113
|
+ mode->ReceiveFilterSetting, mode->ReceiveFilterMask,
|
|
114
|
+ ( mode->MultipleTxSupported ? " multitx" : "" ),
|
|
115
|
+ mode->NvRamSize, mode->NvRamAccessSize,
|
|
116
|
+ mode->MCastFilterCount, mode->MaxMCastFilterCount );
|
|
117
|
+ DBGC2 ( snp, "SNP %s hw %s", netdev->name,
|
|
118
|
+ snpnet_mac_text ( &mode->PermanentAddress, mac_len ) );
|
|
119
|
+ DBGC2 ( snp, " addr %s%s",
|
|
120
|
+ snpnet_mac_text ( &mode->CurrentAddress, mac_len ),
|
|
121
|
+ ( mode->MacAddressChangeable ? "" : "(f)" ) );
|
|
122
|
+ DBGC2 ( snp, " bcast %s\n",
|
|
123
|
+ snpnet_mac_text ( &mode->BroadcastAddress, mac_len ) );
|
|
124
|
+ for ( i = 0 ; i < mode->MCastFilterCount ; i++ ) {
|
|
125
|
+ DBGC2 ( snp, "SNP %s mcast %s\n", netdev->name,
|
|
126
|
+ snpnet_mac_text ( &mode->MCastFilter[i], mac_len ) );
|
|
127
|
+ }
|
|
128
|
+ DBGC2 ( snp, "SNP %s media %s\n", netdev->name,
|
|
129
|
+ ( mode->MediaPresentSupported ?
|
|
130
|
+ ( mode->MediaPresent ? "present" : "not present" ) :
|
|
131
|
+ "presence not supported" ) );
|
|
132
|
+}
|
|
133
|
+
|
74
|
134
|
/**
|
75
|
135
|
* Check link state
|
76
|
136
|
*
|
|
@@ -255,6 +315,7 @@ static int snpnet_open ( struct net_device *netdev ) {
|
255
|
315
|
/* Initialise NIC */
|
256
|
316
|
if ( ( efirc = snp->snp->Initialize ( snp->snp, 0, 0 ) ) != 0 ) {
|
257
|
317
|
rc = -EEFI ( efirc );
|
|
318
|
+ snpnet_dump_mode ( netdev );
|
258
|
319
|
DBGC ( snp, "SNP %s could not initialise: %s\n",
|
259
|
320
|
netdev->name, strerror ( rc ) );
|
260
|
321
|
return rc;
|
|
@@ -282,6 +343,9 @@ static int snpnet_open ( struct net_device *netdev ) {
|
282
|
343
|
/* Ignore error */
|
283
|
344
|
}
|
284
|
345
|
|
|
346
|
+ /* Dump mode information (for debugging) */
|
|
347
|
+ snpnet_dump_mode ( netdev );
|
|
348
|
+
|
285
|
349
|
return 0;
|
286
|
350
|
}
|
287
|
351
|
|