2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-12-04 02:24:35 +00:00

[pxe] Improve pxe_undi debug messages

The PXE debugging messages have remained pretty much unaltered since
Etherboot 5.4, and are now difficult to read in comparison to most of
the rest of gPXE.

Bring the pxe_undi debug messages up to normal gPXE standards.
This commit is contained in:
Michael Brown 2009-06-27 14:43:10 +01:00
parent 15ce2fb851
commit 9580f9d5cd
2 changed files with 93 additions and 32 deletions

View File

@ -95,7 +95,7 @@ static void pxe_netdev_close ( void ) {
* Status: working
*/
PXENV_EXIT_t pxenv_undi_startup ( struct s_PXENV_UNDI_STARTUP *undi_startup ) {
DBG ( "PXENV_UNDI_STARTUP" );
DBG ( "PXENV_UNDI_STARTUP\n" );
undi_startup->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
@ -106,7 +106,7 @@ PXENV_EXIT_t pxenv_undi_startup ( struct s_PXENV_UNDI_STARTUP *undi_startup ) {
* Status: working
*/
PXENV_EXIT_t pxenv_undi_cleanup ( struct s_PXENV_UNDI_CLEANUP *undi_cleanup ) {
DBG ( "PXENV_UNDI_CLEANUP" );
DBG ( "PXENV_UNDI_CLEANUP\n" );
pxe_netdev_close();
@ -120,7 +120,8 @@ PXENV_EXIT_t pxenv_undi_cleanup ( struct s_PXENV_UNDI_CLEANUP *undi_cleanup ) {
*/
PXENV_EXIT_t pxenv_undi_initialize ( struct s_PXENV_UNDI_INITIALIZE
*undi_initialize ) {
DBG ( "PXENV_UNDI_INITIALIZE" );
DBG ( "PXENV_UNDI_INITIALIZE protocolini %08x\n",
undi_initialize->ProtocolIni );
undi_initialize->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
@ -134,10 +135,13 @@ PXENV_EXIT_t pxenv_undi_reset_adapter ( struct s_PXENV_UNDI_RESET
*undi_reset_adapter ) {
int rc;
DBG ( "PXENV_UNDI_RESET_ADAPTER" );
DBG ( "PXENV_UNDI_RESET_ADAPTER %04x\n",
undi_reset_adapter->R_Mcast_Buf.MCastAddrCount );
pxe_netdev_close();
if ( ( rc = pxe_netdev_open() ) != 0 ) {
DBG ( "PXENV_UNDI_RESET_ADAPTER could not reopen %s: %s\n",
pxe_netdev->name, strerror ( rc ) );
undi_reset_adapter->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
@ -152,7 +156,7 @@ PXENV_EXIT_t pxenv_undi_reset_adapter ( struct s_PXENV_UNDI_RESET
*/
PXENV_EXIT_t pxenv_undi_shutdown ( struct s_PXENV_UNDI_SHUTDOWN
*undi_shutdown ) {
DBG ( "PXENV_UNDI_SHUTDOWN" );
DBG ( "PXENV_UNDI_SHUTDOWN\n" );
pxe_netdev_close();
@ -167,9 +171,13 @@ PXENV_EXIT_t pxenv_undi_shutdown ( struct s_PXENV_UNDI_SHUTDOWN
PXENV_EXIT_t pxenv_undi_open ( struct s_PXENV_UNDI_OPEN *undi_open ) {
int rc;
DBG ( "PXENV_UNDI_OPEN" );
DBG ( "PXENV_UNDI_OPEN flag %04x filter %04x mcast %04x\n",
undi_open->OpenFlag, undi_open->PktFilter,
undi_open->R_Mcast_Buf.MCastAddrCount );
if ( ( rc = pxe_netdev_open() ) != 0 ) {
DBG ( "PXENV_UNDI_OPEN could not open %s: %s\n",
pxe_netdev->name, strerror ( rc ) );
undi_open->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
@ -183,7 +191,7 @@ PXENV_EXIT_t pxenv_undi_open ( struct s_PXENV_UNDI_OPEN *undi_open ) {
* Status: working
*/
PXENV_EXIT_t pxenv_undi_close ( struct s_PXENV_UNDI_CLOSE *undi_close ) {
DBG ( "PXENV_UNDI_CLOSE" );
DBG ( "PXENV_UNDI_CLOSE\n" );
pxe_netdev_close();
@ -209,7 +217,7 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
unsigned int i;
int rc;
DBG ( "PXENV_UNDI_TRANSMIT" );
DBG2 ( "PXENV_UNDI_TRANSMIT" );
/* Forcibly enable interrupts at this point, to work around
* callers that never call PXENV_UNDI_OPEN before attempting
@ -227,25 +235,29 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
ll_hlen = 0;
break;
default:
DBG2 ( " %02x invalid protocol\n", undi_transmit->Protocol );
undi_transmit->Status = PXENV_STATUS_UNDI_INVALID_PARAMETER;
return PXENV_EXIT_FAILURE;
}
DBG ( " %s", ( net_protocol ? net_protocol->name : "RAW" ) );
DBG2 ( " %s", ( net_protocol ? net_protocol->name : "RAW" ) );
/* Calculate total packet length */
copy_from_real ( &tbd, undi_transmit->TBD.segment,
undi_transmit->TBD.offset, sizeof ( tbd ) );
len = tbd.ImmedLength;
DBG ( " %d", tbd.ImmedLength );
DBG2 ( " %04x:%04x+%x", tbd.Xmit.segment, tbd.Xmit.offset,
tbd.ImmedLength );
for ( i = 0 ; i < tbd.DataBlkCount ; i++ ) {
datablk = &tbd.DataBlock[i];
len += datablk->TDDataLen;
DBG ( "+%d", datablk->TDDataLen );
DBG2 ( " %04x:%04x+%x", datablk->TDDataPtr.segment,
datablk->TDDataPtr.offset, datablk->TDDataLen );
}
/* Allocate and fill I/O buffer */
iobuf = alloc_iob ( ll_hlen + len );
if ( ! iobuf ) {
DBG2 ( " could not allocate iobuf\n" );
undi_transmit->Status = PXENV_STATUS_OUT_OF_RESOURCES;
return PXENV_EXIT_FAILURE;
}
@ -270,15 +282,18 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
undi_transmit->DestAddr.offset,
ll_protocol->ll_addr_len );
ll_dest = destaddr;
DBG2 ( " DEST %s", ll_protocol->ntoa ( ll_dest ) );
} else {
DBG ( " BCAST" );
ll_dest = ll_protocol->ll_broadcast;
DBG2 ( " BCAST" );
}
/* Add link-layer header */
if ( ( rc = ll_protocol->push ( pxe_netdev, iobuf, ll_dest,
pxe_netdev->ll_addr,
net_protocol->net_proto ))!=0){
DBG2 ( " could not add link-layer header: %s\n",
strerror ( rc ) );
free_iob ( iobuf );
undi_transmit->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
@ -286,7 +301,10 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
}
/* Transmit packet */
DBG2 ( "\n" ); /* ISR may trigger before we return from netdev_tx() */
if ( ( rc = netdev_tx ( pxe_netdev, iobuf ) ) != 0 ) {
DBG2 ( "PXENV_UNDI_TRANSMIT could not transmit: %s\n",
strerror ( rc ) );
undi_transmit->Status = PXENV_STATUS ( rc );
return PXENV_EXIT_FAILURE;
}
@ -305,7 +323,8 @@ PXENV_EXIT_t pxenv_undi_transmit ( struct s_PXENV_UNDI_TRANSMIT
PXENV_EXIT_t
pxenv_undi_set_mcast_address ( struct s_PXENV_UNDI_SET_MCAST_ADDRESS
*undi_set_mcast_address ) {
DBG ( "PXENV_UNDI_SET_MCAST_ADDRESS" );
DBG ( "PXENV_UNDI_SET_MCAST_ADDRESS %04x failed: unsupported\n",
undi_set_mcast_address->R_Mcast_Buf.MCastAddrCount );
undi_set_mcast_address->Status = PXENV_STATUS_UNSUPPORTED;
return PXENV_EXIT_FAILURE;
@ -318,13 +337,16 @@ pxenv_undi_set_mcast_address ( struct s_PXENV_UNDI_SET_MCAST_ADDRESS
PXENV_EXIT_t
pxenv_undi_set_station_address ( struct s_PXENV_UNDI_SET_STATION_ADDRESS
*undi_set_station_address ) {
struct ll_protocol *ll_protocol = pxe_netdev->ll_protocol;
DBG ( "PXENV_UNDI_SET_STATION_ADDRESS" );
DBG ( "PXENV_UNDI_SET_STATION_ADDRESS %s",
ll_protocol->ntoa ( undi_set_station_address->StationAddress ) );
/* If adapter is open, the change will have no effect; return
* an error
*/
if ( pxe_netdev->state & NETDEV_OPEN ) {
DBG ( " failed: netdev is open\n" );
undi_set_station_address->Status =
PXENV_STATUS_UNDI_INVALID_STATE;
return PXENV_EXIT_FAILURE;
@ -333,8 +355,9 @@ pxenv_undi_set_station_address ( struct s_PXENV_UNDI_SET_STATION_ADDRESS
/* Update MAC address */
memcpy ( pxe_netdev->ll_addr,
&undi_set_station_address->StationAddress,
pxe_netdev->ll_protocol->ll_addr_len );
ll_protocol->ll_addr_len );
DBG ( "\n" );
undi_set_station_address->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
@ -348,13 +371,13 @@ PXENV_EXIT_t
pxenv_undi_set_packet_filter ( struct s_PXENV_UNDI_SET_PACKET_FILTER
*undi_set_packet_filter ) {
DBG ( "PXENV_UNDI_SET_PACKET_FILTER" );
DBG ( "PXENV_UNDI_SET_PACKET_FILTER %02x\n",
undi_set_packet_filter->filter );
/* Pretend that we succeeded, otherwise the 3Com DOS UNDI
* driver refuses to load. (We ignore the filter value in the
* PXENV_UNDI_OPEN call anyway.)
*/
DBG ( " %02x", undi_set_packet_filter->filter );
undi_set_packet_filter->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
@ -395,6 +418,10 @@ PXENV_EXIT_t pxenv_undi_get_information ( struct s_PXENV_UNDI_GET_INFORMATION
undi_get_information->RxBufCt = 1;
undi_get_information->TxBufCt = 1;
DBG ( " io %04x irq %d mtu %d %s %s\n",
undi_get_information->BaseIo, undi_get_information->IntNumber,
undi_get_information->MaxTranUnit, ll_protocol->name,
ll_protocol->ntoa ( &undi_get_information->CurrentNodeAddress ));
undi_get_information->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
@ -412,6 +439,11 @@ PXENV_EXIT_t pxenv_undi_get_statistics ( struct s_PXENV_UNDI_GET_STATISTICS
undi_get_statistics->RcvCRCErrors = pxe_netdev->rx_stats.bad;
undi_get_statistics->RcvResourceErrors = pxe_netdev->rx_stats.bad;
DBG ( " txok %d rxok %d rxcrc %d rxrsrc %d\n",
undi_get_statistics->XmtGoodFrames,
undi_get_statistics->RcvGoodFrames,
undi_get_statistics->RcvCRCErrors,
undi_get_statistics->RcvResourceErrors );
undi_get_statistics->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
@ -422,7 +454,7 @@ PXENV_EXIT_t pxenv_undi_get_statistics ( struct s_PXENV_UNDI_GET_STATISTICS
*/
PXENV_EXIT_t pxenv_undi_clear_statistics ( struct s_PXENV_UNDI_CLEAR_STATISTICS
*undi_clear_statistics ) {
DBG ( "PXENV_UNDI_CLEAR_STATISTICS" );
DBG ( "PXENV_UNDI_CLEAR_STATISTICS\n" );
memset ( &pxe_netdev->tx_stats, 0, sizeof ( pxe_netdev->tx_stats ) );
memset ( &pxe_netdev->rx_stats, 0, sizeof ( pxe_netdev->rx_stats ) );
@ -438,7 +470,7 @@ PXENV_EXIT_t pxenv_undi_clear_statistics ( struct s_PXENV_UNDI_CLEAR_STATISTICS
*/
PXENV_EXIT_t pxenv_undi_initiate_diags ( struct s_PXENV_UNDI_INITIATE_DIAGS
*undi_initiate_diags ) {
DBG ( "PXENV_UNDI_INITIATE_DIAGS" );
DBG ( "PXENV_UNDI_INITIATE_DIAGS failed: unsupported\n" );
undi_initiate_diags->Status = PXENV_STATUS_UNSUPPORTED;
return PXENV_EXIT_FAILURE;
@ -451,7 +483,7 @@ PXENV_EXIT_t pxenv_undi_initiate_diags ( struct s_PXENV_UNDI_INITIATE_DIAGS
*/
PXENV_EXIT_t pxenv_undi_force_interrupt ( struct s_PXENV_UNDI_FORCE_INTERRUPT
*undi_force_interrupt ) {
DBG ( "PXENV_UNDI_FORCE_INTERRUPT" );
DBG ( "PXENV_UNDI_FORCE_INTERRUPT failed: unsupported\n" );
undi_force_interrupt->Status = PXENV_STATUS_UNSUPPORTED;
return PXENV_EXIT_FAILURE;
@ -464,7 +496,10 @@ PXENV_EXIT_t pxenv_undi_force_interrupt ( struct s_PXENV_UNDI_FORCE_INTERRUPT
PXENV_EXIT_t
pxenv_undi_get_mcast_address ( struct s_PXENV_UNDI_GET_MCAST_ADDRESS
*undi_get_mcast_address ) {
DBG ( "PXENV_UNDI_GET_MCAST_ADDRESS" );
struct in_addr ip = { .s_addr = undi_get_mcast_address->InetAddr };
DBG ( "PXENV_UNDI_GET_MCAST_ADDRESS %s failed: unsupported\n",
inet_ntoa ( ip ) );
undi_get_mcast_address->Status = PXENV_STATUS_UNSUPPORTED;
return PXENV_EXIT_FAILURE;
@ -499,6 +534,13 @@ PXENV_EXIT_t pxenv_undi_get_nic_type ( struct s_PXENV_UNDI_GET_NIC_TYPE
*/
undi_get_nic_type->info.pci.SubVendor_ID = 0xffff;
undi_get_nic_type->info.pci.SubDevice_ID = 0xffff;
DBG ( " PCI %02x:%02x.%x %04x:%04x (%04x:%04x) %02x%02x%02x "
"rev %02x\n", PCI_BUS ( info->BusDevFunc ),
PCI_SLOT ( info->BusDevFunc ),
PCI_FUNC ( info->BusDevFunc ), info->Vendor_ID,
info->Dev_ID, info->SubVendor_ID, info->SubDevice_ID,
info->Base_Class, info->Sub_Class, info->Prog_Intf,
info->Rev );
break; }
case BUS_TYPE_ISAPNP: {
struct pnp_nic_info *info = &undi_get_nic_type->info.pnp;
@ -510,8 +552,12 @@ PXENV_EXIT_t pxenv_undi_get_nic_type ( struct s_PXENV_UNDI_GET_NIC_TYPE
/* Cheat: remaining fields are probably unnecessary,
* and would require adding extra code to isapnp.c.
*/
DBG ( " ISAPnP CSN %04x %08x %02x%02x%02x\n",
info->CardSelNum, info->EISA_Dev_ID,
info->Base_Class, info->Sub_Class, info->Prog_Intf );
break; }
default:
DBG ( " failed: unknown bus type\n" );
undi_get_nic_type->Status = PXENV_STATUS_FAILURE;
return PXENV_EXIT_FAILURE;
}
@ -541,6 +587,9 @@ PXENV_EXIT_t pxenv_undi_get_iface_info ( struct s_PXENV_UNDI_GET_IFACE_INFO
memset ( undi_get_iface_info->Reserved, 0,
sizeof(undi_get_iface_info->Reserved) );
DBG ( " %s %dbps flags %08x\n", undi_get_iface_info->IfaceType,
undi_get_iface_info->LinkSpeed,
undi_get_iface_info->ServiceFlags );
undi_get_iface_info->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}
@ -551,7 +600,7 @@ PXENV_EXIT_t pxenv_undi_get_iface_info ( struct s_PXENV_UNDI_GET_IFACE_INFO
*/
PXENV_EXIT_t pxenv_undi_get_state ( struct s_PXENV_UNDI_GET_STATE
*undi_get_state ) {
DBG ( "PXENV_UNDI_GET_STATE" );
DBG ( "PXENV_UNDI_GET_STATE failed: unsupported\n" );
undi_get_state->Status = PXENV_STATUS_UNSUPPORTED;
return PXENV_EXIT_FAILURE;
@ -573,7 +622,10 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
unsigned int prottype;
int rc;
DBG ( "PXENV_UNDI_ISR" );
/* Use coloured debug, since UNDI ISR messages are likely to
* be interspersed amongst other UNDI messages.
*/
DBGC2 ( &pxenv_undi_isr, "PXENV_UNDI_ISR" );
/* Just in case some idiot actually looks at these fields when
* we weren't meant to fill them in...
@ -586,7 +638,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
switch ( undi_isr->FuncFlag ) {
case PXENV_UNDI_ISR_IN_START :
DBG ( " START" );
DBGC2 ( &pxenv_undi_isr, " START" );
/* Call poll(). This should acknowledge the device
* interrupt and queue up any received packet.
@ -597,13 +649,14 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
netdev_irq ( pxe_netdev, 0 );
/* Always say it was ours for the sake of simplicity */
DBGC2 ( &pxenv_undi_isr, " OURS" );
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_OURS;
break;
case PXENV_UNDI_ISR_IN_PROCESS :
DBG ( " PROCESS" );
/* Fall through */
case PXENV_UNDI_ISR_IN_GET_NEXT :
DBG ( " GET_NEXT" );
DBGC2 ( &pxenv_undi_isr, " %s",
( ( undi_isr->FuncFlag == PXENV_UNDI_ISR_IN_PROCESS ) ?
"PROCESS" : "GET_NEXT" ) );
/* Some dumb NBPs (e.g. emBoot's winBoot/i) never call
* PXENV_UNDI_ISR with FuncFlag=PXENV_UNDI_ISR_START;
@ -618,7 +671,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
* netdev TX queue is empty, report the TX completion.
*/
if ( undi_tx_count && list_empty ( &pxe_netdev->tx_queue ) ) {
DBG ( " TXC" );
DBGC2 ( &pxenv_undi_isr, " TXC" );
undi_tx_count--;
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_TRANSMIT;
break;
@ -627,7 +680,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
/* Remove first packet from netdev RX queue */
iobuf = netdev_rx_dequeue ( pxe_netdev );
if ( ! iobuf ) {
DBG ( " DONE" );
DBGC2 ( &pxenv_undi_isr, " DONE" );
/* No more packets remaining */
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_DONE;
/* Re-enable interrupts */
@ -637,9 +690,10 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
/* Copy packet to base memory buffer */
len = iob_len ( iobuf );
DBG ( " RX %zd", len );
DBGC2 ( &pxenv_undi_isr, " RX" );
if ( len > sizeof ( basemem_packet ) ) {
/* Should never happen */
DBGC2 ( &pxenv_undi_isr, " overlength (%x)", len );
len = sizeof ( basemem_packet );
}
memcpy ( basemem_packet, iobuf->data, len );
@ -673,7 +727,6 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
prottype = P_UNKNOWN;
break;
}
DBG ( " %s", ( net_protocol ? net_protocol->name : "RAW" ) );
/* Fill in UNDI_ISR structure */
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_RECEIVE;
@ -684,12 +737,18 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
undi_isr->Frame.offset = __from_data16 ( basemem_packet );
undi_isr->ProtType = prottype;
undi_isr->PktType = XMT_DESTADDR;
DBGC2 ( &pxenv_undi_isr, " %04x:%04x+%x(%x) %s hlen %d",
undi_isr->Frame.segment, undi_isr->Frame.offset,
undi_isr->BufferLength, undi_isr->FrameLength,
( net_protocol ? net_protocol->name : "RAW" ),
undi_isr->FrameHeaderLength );
/* Free packet */
free_iob ( iobuf );
break;
default :
DBG ( " INVALID(%04x)", undi_isr->FuncFlag );
DBGC2 ( &pxenv_undi_isr, " INVALID(%04x)\n",
undi_isr->FuncFlag );
/* Should never happen */
undi_isr->FuncFlag = PXENV_UNDI_ISR_OUT_DONE;
@ -697,6 +756,7 @@ PXENV_EXIT_t pxenv_undi_isr ( struct s_PXENV_UNDI_ISR *undi_isr ) {
return PXENV_EXIT_FAILURE;
}
DBGC2 ( &pxenv_undi_isr, "\n" );
undi_isr->Status = PXENV_STATUS_SUCCESS;
return PXENV_EXIT_SUCCESS;
}

View File

@ -321,6 +321,7 @@ struct pci_driver {
#define PCI_DEVFN( slot, func ) ( ( (slot) << 3 ) | (func) )
#define PCI_SLOT( devfn ) ( ( (devfn) >> 3 ) & 0x1f )
#define PCI_FUNC( devfn ) ( (devfn) & 0x07 )
#define PCI_BUS( busdevfn ) ( (busdevfn) >> 8 )
#define PCI_BUSDEVFN( bus, devfn ) ( ( (bus) << 8 ) | (devfn) )
#define PCI_BASE_CLASS( class ) ( (class) >> 16 )