diff options
author | Michael Brown <mcb30@ipxe.org> | 2014-08-05 17:32:16 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2014-08-05 17:32:16 +0100 |
commit | 1f7b26995404cb2501aa7aba1f91f4a038b2b2a4 (patch) | |
tree | 256b3caa2be389c591b70a07b784ada2a883397f /src/drivers/net/efi | |
parent | 27e9ee147aa9918e23a1f9a0940e37f9481057ae (diff) | |
download | ipxe-1f7b26995404cb2501aa7aba1f91f4a038b2b2a4.zip ipxe-1f7b26995404cb2501aa7aba1f91f4a038b2b2a4.tar.gz ipxe-1f7b26995404cb2501aa7aba1f91f4a038b2b2a4.tar.bz2 |
[efi] Add ability to dump SNP device mode information
Originally-implemented-by: Curtis Larsen <larsen@dixie.edu>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/drivers/net/efi')
-rw-r--r-- | src/drivers/net/efi/snpnet.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/drivers/net/efi/snpnet.c b/src/drivers/net/efi/snpnet.c index 766eb42..61b66c6 100644 --- a/src/drivers/net/efi/snpnet.c +++ b/src/drivers/net/efi/snpnet.c @@ -26,6 +26,7 @@ FILE_LICENCE ( GPL2_OR_LATER ); #include <ipxe/iobuf.h> #include <ipxe/netdevice.h> #include <ipxe/ethernet.h> +#include <ipxe/vsprintf.h> #include <ipxe/efi/efi.h> #include <ipxe/efi/Protocol/SimpleNetwork.h> #include <ipxe/efi/efi_driver.h> @@ -72,6 +73,65 @@ static EFI_GUID efi_pci_io_protocol_guid = EFI_PCI_IO_PROTOCOL_GUID; /** + * Format SNP MAC address (for debugging) + * + * @v mac MAC address + * @v len Length of MAC address + * @ret text MAC address as text + */ +static const char * snpnet_mac_text ( EFI_MAC_ADDRESS *mac, size_t len ) { + static char buf[ sizeof ( *mac ) * 3 /* "xx:" or "xx\0" */ ]; + size_t used = 0; + unsigned int i; + + for ( i = 0 ; i < len ; i++ ) { + used += ssnprintf ( &buf[used], ( sizeof ( buf ) - used ), + "%s%02x", ( used ? ":" : "" ), + mac->Addr[i] ); + } + return buf; +} + +/** + * Dump SNP mode information (for debugging) + * + * @v netdev Network device + */ +static void snpnet_dump_mode ( struct net_device *netdev ) { + struct snp_nic *snp = netdev_priv ( netdev ); + EFI_SIMPLE_NETWORK_MODE *mode = snp->snp->Mode; + size_t mac_len = mode->HwAddressSize; + unsigned int i; + + /* Do nothing unless debugging is enabled */ + if ( ! DBG_EXTRA ) + return; + + DBGC2 ( snp, "SNP %s st %d type %d hdr %d pkt %d rxflt %#x/%#x%s " + "nvram %d acc %d mcast %d/%d\n", netdev->name, mode->State, + mode->IfType, mode->MediaHeaderSize, mode->MaxPacketSize, + mode->ReceiveFilterSetting, mode->ReceiveFilterMask, + ( mode->MultipleTxSupported ? " multitx" : "" ), + mode->NvRamSize, mode->NvRamAccessSize, + mode->MCastFilterCount, mode->MaxMCastFilterCount ); + DBGC2 ( snp, "SNP %s hw %s", netdev->name, + snpnet_mac_text ( &mode->PermanentAddress, mac_len ) ); + DBGC2 ( snp, " addr %s%s", + snpnet_mac_text ( &mode->CurrentAddress, mac_len ), + ( mode->MacAddressChangeable ? "" : "(f)" ) ); + DBGC2 ( snp, " bcast %s\n", + snpnet_mac_text ( &mode->BroadcastAddress, mac_len ) ); + for ( i = 0 ; i < mode->MCastFilterCount ; i++ ) { + DBGC2 ( snp, "SNP %s mcast %s\n", netdev->name, + snpnet_mac_text ( &mode->MCastFilter[i], mac_len ) ); + } + DBGC2 ( snp, "SNP %s media %s\n", netdev->name, + ( mode->MediaPresentSupported ? + ( mode->MediaPresent ? "present" : "not present" ) : + "presence not supported" ) ); +} + +/** * Check link state * * @v netdev Network device @@ -255,6 +315,7 @@ static int snpnet_open ( struct net_device *netdev ) { /* Initialise NIC */ if ( ( efirc = snp->snp->Initialize ( snp->snp, 0, 0 ) ) != 0 ) { rc = -EEFI ( efirc ); + snpnet_dump_mode ( netdev ); DBGC ( snp, "SNP %s could not initialise: %s\n", netdev->name, strerror ( rc ) ); return rc; @@ -282,6 +343,9 @@ static int snpnet_open ( struct net_device *netdev ) { /* Ignore error */ } + /* Dump mode information (for debugging) */ + snpnet_dump_mode ( netdev ); + return 0; } |