DevPCNet.cpp revision aa842cf37c9d778a25c1acf8bab91528c54bb996
/* $Id$ */
/** @file
* DevPCNet - AMD PCnet-PCI II / PCnet-FAST III (Am79C970A / Am79C973) Ethernet Controller Emulation.
*
* This software was written to be compatible with the specifications:
* AMD Am79C970A PCnet-PCI II Ethernet Controller Data-Sheet
* AMD Publication# 19436 Rev:E Amendment/0 Issue Date: June 2000
* and
* todo
*/
/*
* Copyright (C) 2006-2013 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
* --------------------------------------------------------------------
*
* This code is based on:
*
* AMD PC-Net II (Am79C970A) emulation
*
* Copyright (c) 2004 Antony T Curtis
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_DEV_PCNET
#include <VBox/DevPCNet.h>
#include <iprt/critsect.h>
#ifdef IN_RING3
# include <iprt/semaphore.h>
#endif
#include "VBoxDD.h"
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/* Enable this to catch writes to the ring descriptors instead of using excessive polling */
/* #define PCNET_NO_POLLING */
/* Enable to handle frequent io reads in the guest context (recommended) */
#define PCNET_GC_ENABLED
#if defined(LOG_ENABLED)
#define PCNET_DEBUG_IO
#define PCNET_DEBUG_BCR
#define PCNET_DEBUG_CSR
#define PCNET_DEBUG_RMD
#define PCNET_DEBUG_TMD
#define PCNET_DEBUG_MATCH
#define PCNET_DEBUG_MII
#endif
#define PCNET_IOPORT_SIZE 0x20
#define PCNET_PNPMMIO_SIZE 0x20
#define PCNET_SAVEDSTATE_VERSION 10
#define BCR_MAX_RAP 50
#define MII_MAX_REG 32
#define CSR_MAX_REG 128
/** Maximum number of times we report a link down to the guest (failure to send frame) */
#define PCNET_MAX_LINKDOWN_REPORTED 3
/** Maximum frame size we handle */
#define MAX_FRAME 1536
/** @name Bus configuration registers
* @{ */
#define BCR_MSRDA 0
#define BCR_MSWRA 1
#define BCR_MC 2
#define BCR_RESERVED3 3
#define BCR_LNKST 4
#define BCR_LED1 5
#define BCR_LED2 6
#define BCR_LED3 7
#define BCR_RESERVED8 8
#define BCR_FDC 9
/* 10 - 15 = reserved */
#define BCR_BSBC 18
#define BCR_EECAS 19
#define BCR_SWS 20
#define BCR_PLAT 22
#define BCR_PCISVID 23
#define BCR_PCISID 24
#define BCR_SRAMSIZ 25
#define BCR_SRAMB 26
#define BCR_SRAMIC 27
#define BCR_EBADDRL 28
#define BCR_EBADDRU 29
#define BCR_EBD 30
#define BCR_STVAL 31
#define BCR_MIICAS 32
#define BCR_MIIADDR 33
#define BCR_MIIMDR 34
#define BCR_PCIVID 35
#define BCR_PMC_A 36
#define BCR_DATA0 37
#define BCR_DATA1 38
#define BCR_DATA2 39
#define BCR_DATA3 40
#define BCR_DATA4 41
#define BCR_DATA5 42
#define BCR_DATA6 43
#define BCR_DATA7 44
#define BCR_PMR1 45
#define BCR_PMR2 46
#define BCR_PMR3 47
/** @} */
/** @name Bus configuration sub register accessors.
* @{ */
/** @} */
/** @name CSR subregister accessors.
* @{ */
#define CSR_TDMD(S) !!((S)->aCSR[0] & 0x0008) /**< Transmit demand. (perform xmit poll now (readable, settable, not clearable) */
/** @} */
#if !defined(RT_ARCH_X86) && !defined(RT_ARCH_AMD64)
#endif
/** @name CSR register accessors.
* @{ */
/** @} */
* @{ */
#define CSR_VERSION_HIGH 0x0262
/** @} */
/** Calculates the full physical address. */
#define PHYSADDR(S,A) ((A) | (S)->GCUpperPhys)
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* PCNET state.
*
* @extends PCIDEVICE
* @implements PDMIBASE
* @implements PDMINETWORKDOWN
* @implements PDMINETWORKCONFIG
* @implements PDMILEDPORTS
*/
typedef struct PCNETSTATE
{
/** Pointer to the device instance - R3. */
/** Transmit signaller - R3. */
/** Receive signaller - R3. */
/** Pointer to the connector of the attached network driver - R3. */
/** Pointer to the attached network driver. */
/** LUN\#0 + status LUN: The base interface. */
/** LUN\#0: The network port interface. */
/** LUN\#0: The network config port interface. */
/** The shared memory used for the private interface - R3. */
/** Software Interrupt timer - R3. */
#ifndef PCNET_NO_POLLING
/** Poll timer - R3. */
#endif
/** Restore timer.
* This is used to disconnect and reconnect the link after a restore. */
/** Pointer to the device instance - R0. */
/** Receive signaller - R0. */
/** Transmit signaller - R0. */
/** Pointer to the connector of the attached network driver - R0. */
/** The shared memory used for the private interface - R0. */
/** Software Interrupt timer - R0. */
#ifndef PCNET_NO_POLLING
/** Poll timer - R0. */
#endif
/** Pointer to the device instance - RC. */
/** Receive signaller - RC. */
/** Transmit signaller - RC. */
/** Pointer to the connector of the attached network driver - RC. */
/** The shared memory used for the private interface - RC. */
/** Software Interrupt timer - RC. */
#ifndef PCNET_NO_POLLING
/** Poll timer - RC. */
#endif
//#if HC_ARCH_BITS == 64
//#endif
/** Register Address Pointer */
/** Internal interrupt service */
/** ??? */
/** Address of the RX descriptor table (ring). Loaded at init. */
/** Address of the TX descriptor table (ring). Loaded at init. */
/** Holds the bits which were really seen by the guest. Relevant are bits
* 8..14 (IDON, TINT, RINT, MERR, MISS, CERR, BABL). We don't allow the
* guest to clear any of these bits (by writing a ONE) before a bit was
* seen by the guest. */
/** Last time we polled the queues */
/** The loopback transmit buffer (avoid stack allocations). */
/** The recv buffer. */
/** Unused / padding. */
int iLog2DescSize;
/** Bits 16..23 in 16-bit mode */
/** Base address of the MMIO region. */
/** Base port of the I/O space region. */
/** If set the link is currently up. */
bool fLinkUp;
/** If set the link is temporarily down because of a saved state load. */
bool fLinkTempDown;
/** Number of times we've reported the link down. */
/** The configured MAC address. */
/** Alignment padding. */
/** The LED. */
/** Status LUN: The LED ports. */
/** Partner of ILeds. */
/** Access critical section. */
/** Event semaphore for blocking on receive. */
bool volatile fMaybeOutOfSpace;
/** True if we signal the guest that RX packets are missing. */
bool fSignalRxMiss;
#ifdef PCNET_NO_POLLING
DECLRCCALLBACKMEMBER(int, pfnEMInterpretInstructionRC, (PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize));
DECLR0CALLBACKMEMBER(int, pfnEMInterpretInstructionR0, (PVM pVM, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, uint32_t *pcbSize));
#endif
/** Error counter for bad receive descriptors. */
/** True if host and guest admitted to use the private interface. */
bool fPrivIfEnabled;
bool fGCEnabled;
bool fR0Enabled;
bool fAm79C973;
#ifdef VBOX_WITH_STATISTICS
# ifdef PCNET_NO_POLLING
# endif
#endif /* VBOX_WITH_STATISTICS */
} PCNETSTATE;
//AssertCompileMemberAlignment(PCNETSTATE, StatReceiveBytes, 8);
/** Pointer to a PC-Net state structure. */
typedef PCNETSTATE *PPCNETSTATE;
/** @todo All structs: big endian? */
struct INITBLK16
{
};
/** bird: I've changed the type for the bitfields. They should only be 16-bit all together.
* frank: I've changed the bitfiled types to uint32_t to prevent compiler warnings. */
struct INITBLK32
{
};
/** Transmit Message Descriptor */
typedef struct TMD
{
struct
{
} tmd0;
struct
{
transmitter FCS generation is activated. */
} tmd1;
struct
{
} tmd2;
struct
{
} tmd3;
} TMD;
/** Receive Message Descriptor */
typedef struct RMD
{
struct
{
} rmd0;
struct
{
} rmd1;
struct
{
} rmd2;
struct
{
} rmd3;
} RMD;
#ifndef VBOX_DEVICE_STRUCT_TESTCASE
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
"TMD0 : TBADR=%#010x\n" \
"TMD1 : OWN=%d, ERR=%d, FCS=%d, LTI=%d, " \
"ONE=%d, DEF=%d, STP=%d, ENP=%d,\n" \
" BPE=%d, BCNT=%d\n" \
"TMD2 : BUF=%d, UFL=%d, EXD=%d, LCO=%d, " \
"LCA=%d, RTR=%d,\n" \
" TDR=%d, TRC=%d\n", \
"RMD0 : RBADR=%#010x\n" \
"RMD1 : OWN=%d, ERR=%d, FRAM=%d, OFLO=%d, " \
"CRC=%d, BUFF=%d, STP=%d, ENP=%d,\n " \
"BPE=%d, PAM=%d, LAFM=%d, BAM=%d, ONES=%d, BCNT=%d\n" \
"RMD2 : RCC=%d, RPC=%d, MCNT=%d, ZEROS=%d\n", \
/**
* Checks if the link is up.
* @returns true if the link is up.
* @returns false if the link is down.
*/
{
}
/**
* Load transmit message descriptor
* Make sure we read the own flag first.
*
* @param pThis adapter private data
* @param addr physical address of the descriptor
* @param fRetIfNotOwn return immediately after reading the own flag if we don't own the descriptor
* @return true if we own the descriptor, false otherwise
*/
{
if (pThis->fPrivIfEnabled)
{
return false;
return true;
}
{
return false;
}
{
return false;
}
else
{
return false;
}
/* Double check the own bit; guest drivers might be buggy and lock prefixes in the recompiler are ignored by other threads. */
#ifdef DEBUG
Log(("pcnetTmdLoad: own bit flipped while reading!!\n"));
#endif
if (!(ownbyte & 0x80))
}
/**
* Store transmit message descriptor and hand it over to the host (the VM guest).
* Make sure that all data are transmitted before we clear the own flag.
*/
{
if (pThis->fPrivIfEnabled)
{
}
{
}
{
}
else
{
}
}
/**
* Load receive message descriptor
* Make sure we read the own flag first.
*
* @param pThis adapter private data
* @param addr physical address of the descriptor
* @param fRetIfNotOwn return immediately after reading the own flag if we don't own the descriptor
* @return true if we own the descriptor, false otherwise
*/
{
if (pThis->fPrivIfEnabled)
{
return false;
return true;
}
{
return false;
}
{
return false;
}
else
{
return false;
}
/* Double check the own bit; guest drivers might be buggy and lock prefixes in the recompiler are ignored by other threads. */
#ifdef DEBUG
Log(("pcnetRmdLoad: own bit flipped while reading!!\n"));
#endif
if (!(ownbyte & 0x80))
}
/**
* Store receive message descriptor and hand it over to the host (the VM guest).
* Make sure that all data are transmitted before we clear the own flag.
*/
{
if (pThis->fPrivIfEnabled)
{
}
{
}
{
}
else
{
}
}
#ifdef IN_RING3
/**
* pages later when we shouldn't schedule to EMT. Temporarily hack.
*/
{
if (!pThis->fPrivIfEnabled)
{
cbDesc = 8;
else
cbDesc = 16;
}
}
#endif /* IN_RING3 */
/** Checks if it's a bad (as in invalid) RMD.*/
#ifndef ETHER_IS_MULTICAST /* Net/Open BSD macro it seems */
#endif
#define ETHER_ADDR_LEN ETH_ALEN
#define ETH_ALEN 6
#pragma pack(1)
struct ether_header /** @todo Use RTNETETHERHDR */
{
};
#pragma pack()
#define PRINT_PKTHDR(BUF) do { \
Log(("#%d packet dhost=%02x:%02x:%02x:%02x:%02x:%02x, " \
"shost=%02x:%02x:%02x:%02x:%02x:%02x, " \
"type=%#06x (bcast=%d)\n", PCNET_INST_NR, \
} while (0)
#ifdef IN_RING3
/**
* Initialize the shared memory for the private guest interface.
*
* @note Changing this layout will break SSM for guests using the private guest interface!
*/
{
/* Clear the entire block for pcnetReset usage. */
/*
* The Descriptor arrays.
*/
/* Make sure all the descriptors are mapped into HMA space (and later ring-0). The 8192
bytes limit is hardcoded in the PDMDevHlpMMHyperMapMMIO2 call down in pcnetConstruct. */
/*
* The buffer arrays.
*/
#if 0
/* Don't allocate TX buffers since Windows guests cannot use it */
#endif
/* Update the header with the final size. */
}
#endif /* IN_RING3 */
#define MULTICAST_FILTER_LEN 8
{
#define LNC_POLYNOMIAL 0xEDB88320UL
{
{
data >>= 1;
}
}
return crc;
}
/* generated using the AUTODIN II polynomial
* x^32 + x^26 + x^23 + x^22 + x^16 +
* x^12 + x^11 + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + 1
*/
{
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba,
0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec,
0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5,
0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940,
0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116,
0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f,
0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d,
0x76dc4190, 0x01db7106, 0x98d220bc, 0xefd5102a,
0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818,
0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457,
0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c,
0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb,
0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9,
0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086,
0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4,
0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad,
0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683,
0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe,
0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7,
0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252,
0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60,
0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79,
0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f,
0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04,
0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a,
0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21,
0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e,
0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45,
0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db,
0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0,
0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6,
0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf,
0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d,
};
{
int result;
#else
#endif
#ifdef PCNET_DEBUG_MATCH
Log(("#%d packet dhost=%02x:%02x:%02x:%02x:%02x:%02x, "
"padr=%02x:%02x:%02x:%02x:%02x:%02x => %d\n", PCNET_INST_NR,
#endif
return result;
}
{
#ifdef PCNET_DEBUG_MATCH
#endif
return result;
}
{
{
int index;
#if defined(RT_ARCH_X86) || defined(RT_ARCH_AMD64)
#else
#endif
}
return 0;
}
/**
* Get the receive descriptor ring address with a given index.
*/
{
}
/**
* Get the transmit descriptor ring address with a given index.
*/
{
}
#ifndef IN_RING3
#endif
#define htonl(x) ASMByteSwapU32(x)
#ifdef PCNET_NO_POLLING
# ifndef IN_RING3
/**
* #PF Virtual Handler callback for Guest write access to the ring descriptor page(pThis)
*
* @return VBox status code (appropriate for trap handling and GC return).
* @param pVM VM Handle.
* @param uErrorCode CPU Error code.
* @param pRegFrame Trap register frame.
* @param pvFault The fault address (cr2).
* @param GCPhysFault The GC physical address corresponding to pvFault.
* @param pvUser User argument.
*/
{
{
#ifdef PCNET_MONITOR_RECEIVE_RING
#endif
)
{
if (RT_SUCCESS(rc))
{
/* Check if we can do something now */
return VINF_SUCCESS;
}
}
else
{
return VINF_SUCCESS; /* outside of the ring range */
}
}
return VINF_IOM_R3_MMIO_WRITE; /* handle in ring3 */
}
# else /* IN_RING3 */
/**
* #PF Handler callback for physical access handler ranges (MMIO among others) in HC.
*
* The handler can not raise any faults, it's mainly for monitoring write access
* to certain pages.
*
* @returns VINF_SUCCESS if the handler have carried out the operation.
* @returns VINF_PGM_HANDLER_DO_DEFAULT if the caller should carry out the access operation.
* @param pVM VM Handle.
* @param GCPhys The physical address the guest is writing to.
* @param pvPhys The HC mapping of that address.
* @param enmAccessType The access type.
* @param pvUser User argument.
*/
{
#ifdef VBOX_WITH_STATISTICS
#endif
/* Perform the actual write */
/* Writes done by our code don't require polling of course */
{
#ifdef PCNET_MONITOR_RECEIVE_RING
#endif
)
{
/* Check if we can do something now */
}
}
return VINF_SUCCESS;
}
# endif /* !IN_RING3 */
#endif /* PCNET_NO_POLLING */
{
}
/**
* Check if we have to send an interrupt to the guest. An interrupt can occur on
* - csr0 (written quite often)
* - csr4 (only written by pcnetSoftReset(), pcnetStop() or by the guest driver)
* - csr5 (only written by pcnetSoftReset(), pcnetStop or by the driver guest)
*/
{
register int iISR = 0;
/* Linux guests set csr4=0x0915
* W2k guests set csr3=0x4940 (disable BABL, MERR, IDON, DXSUFLO */
#if 1
#else
#endif
{
}
#ifdef VBOX
{
}
{
iISR = 1;
}
#else /* !VBOX */
{
iISR = 1;
}
#endif /* !VBOX */
#if 1
#else
#endif
{
iISR = 1;
}
iISR = 1;
/* normal path is to _not_ change the IRQ status */
{
}
}
/**
*/
{
{
LogRel(("PCNet#%d: %s private interface\n", PCNET_INST_NR, fPrivIfEnabled ? "Enabling" : "Disabling"));
}
}
#ifdef IN_RING3
#ifdef PCNET_NO_POLLING
{
int rc;
Log(("pcnetUpdateRingHandlers TD %RX32 size %#x -> %RX32 ?size? %#x\n", pThis->TDRAPhysOld, pThis->cbTDRAOld, pThis->GCTDRA, pcnetTdraAddr(pThis, 0)));
Log(("pcnetUpdateRingHandlers RX %RX32 size %#x -> %RX32 ?size? %#x\n", pThis->RDRAPhysOld, pThis->cbRDRAOld, pThis->GCRDRA, pcnetRdraAddr(pThis, 0)));
/** @todo unregister order not correct! */
#ifdef PCNET_MONITOR_RECEIVE_RING
{
if (pThis->RDRAPhysOld != 0)
"PCNet receive ring write access handler");
}
#endif /* PCNET_MONITOR_RECEIVE_RING */
#ifdef PCNET_MONITOR_RECEIVE_RING
/* 3 possibilities:
* 1) TDRA on different physical page as RDRA
* 2) TDRA completely on same physical page as RDRA
* 3) TDRA & RDRA overlap partly with different physical pages
*/
if ( RDRAPageStart > TDRAPageEnd
|| TDRAPageStart > RDRAPageEnd)
{
#endif /* PCNET_MONITOR_RECEIVE_RING */
/* 1) */
{
if (pThis->TDRAPhysOld != 0)
"PCNet transmit ring write access handler");
}
#ifdef PCNET_MONITOR_RECEIVE_RING
}
else
if ( RDRAPageStart != TDRAPageStart
&& ( TDRAPageStart == RDRAPageEnd
|| TDRAPageEnd == RDRAPageStart
)
)
{
/* 3) */
AssertFailed();
}
/* else 2) */
#endif
}
#endif /* PCNET_NO_POLLING */
{
/** @todo Documentation says that RCVRL and XMTRL are stored as two's complement!
* Software is allowed to write these registers directly. */
#define PCNET_INIT() do { \
} while (0)
if (BCR_SSIZE32(pThis))
{
pThis->GCUpperPhys = 0;
PCNET_INIT();
}
else
{
PCNET_INIT();
}
size_t cbRxBuffers = 0;
{
/* At this time it is not guaranteed that the buffers are already initialized. */
{
cbRxBuffers += cbBuf;
}
}
{
}
/*
* Heuristics: The Solaris pcn driver allocates too few RX buffers (128 buffers of a
* size of 128 bytes are 16KB in summary) leading to frequent RX buffer overflows. In
* that case we don't signal RX overflows through the CSR0_MISS flag as the driver
* re-initializes the device on every miss. Other guests use at least 32 buffers of
* usually 1536 bytes and should therefore not run into condition. If they are still
* short in RX buffers we notify this condition.
*/
#ifdef PCNET_NO_POLLING
#endif
/* Reset cached RX and TX states */
LogRel(("PCNet#%d: Init: ss32=%d GCRDRA=%#010x[%d] GCTDRA=%#010x[%d]%s\n",
}
#endif /* IN_RING3 */
/**
*/
{
}
/**
*/
{
}
#ifdef IN_RING3
{
}
{
return true;
}
#endif /* IN_RING3 */
/**
* Poll Receive Descriptor Table Entry and cache the results in the appropriate registers.
* Note: Once a descriptor belongs to the network card (this driver), it cannot be changed
* by the host (the guest driver) anymore. Well, it could but the results are undefined by
* definition.
* @param fSkipCurrent if true, don't scan the current RDTE.
*/
{
/* assume lack of a next receive descriptor */
{
/*
* The current receive message descriptor.
*/
if (i < 1)
if (!fSkipCurrent)
{
{
return;
}
{
if (pThis->fMaybeOutOfSpace)
{
#ifdef IN_RING3
#else
if (pItem)
#endif
}
}
else
{
/* This is not problematic since we don't own the descriptor
* We actually do own it, otherwise pcnetRmdLoad would have returned false.
* Don't flood the release log with errors.
*/
LogRel(("PCNet#%d: BAD RMD ENTRIES AT %#010x (i=%d)\n",
PCNET_INST_NR, addr, i));
return;
}
}
/*
* The next descriptor.
*/
if (--i < 1)
{
return;
}
{
}
else
{
/* This is not problematic since we don't own the descriptor
* We actually do own it, otherwise pcnetRmdLoad would have returned false.
* Don't flood the release log with errors.
*/
LogRel(("PCNet#%d: BAD RMD ENTRIES + AT %#010x (i=%d)\n",
PCNET_INST_NR, addr, i));
return;
}
/**
* @todo NNRD
*/
}
else
{
}
}
/**
* Poll Transmit Descriptor Table Entry
* @return true if transmit descriptors available
*/
{
{
{
return 0;
}
{
LogRel(("PCNet#%d: BAD TMD XDA=%#010x\n",
return 0;
}
/* previous xmit descriptor */
/* set current transmit descriptor. */
}
else
{
/** @todo consistency with previous receive descriptor */
return 0;
}
}
/**
* Poll Transmit Descriptor Table Entry
* @return true if transmit descriptors available
*/
{
do
{
/* Advance the ring counter */
if (iDesc < 2)
else
iDesc--;
{
/*
* No need to count further since this packet won't be sent anyway
* due to underflow.
*/
return cbPacket;
}
{
LogRel(("PCNet#%d: BAD TMD XDA=%#010x\n",
return cbPacket;
}
return cbPacket;
}
/**
* Write data into guest receive buffers.
*/
static void pcnetReceiveNoSync(PPCNETSTATE pThis, const uint8_t *buf, size_t cbToRecv, bool fAddFCS)
{
unsigned iRxDesc;
int cbPacket;
return;
/*
*/
if ( enmVMState != VMSTATE_RUNNING
&& enmVMState != VMSTATE_RUNNING_LS)
return;
/*
* Drop packets if the cable is not connected
*/
if (!pcnetIsLinkUp(pThis))
return;
/*
* Perform address matching.
*/
{
{
/* Not owned by controller. This should not be possible as
* we already called pcnetCanReceive(). */
/* Dump the status of all RX descriptors */
while (iRxDesc-- > 0)
{
}
}
else
{
if (!CSR_ASTRP_RCV(pThis))
{
while (cbToRecv < 60)
if (fAddFCS)
{
/* FCS at end of packet */
cbToRecv += 4;
}
}
#ifdef PCNET_DEBUG_MATCH
#endif
/*if (!CSR_LAPPEN(pThis))*/
/* save the old value to check if it was changed as long as we didn't
* hold the critical section */
/* We have to leave the critical section here or we risk deadlocking
* with EMT when the write is to an unallocated page or has an access
* handler associated with it.
*
* This shouldn't be a problem because:
* - any modification to the RX descriptor by the driver is
* forbidden as long as it is owned by the device
* - we don't cache any register state beyond this point
*/
/* RX disabled in the meantime? If so, abort RX. */
return;
/* Was the register modified in the meantime? If so, don't touch the
* register but still update the RX descriptor. */
{
if (iRxDesc-- < 2)
}
else
while (cbToRecv > 0)
{
/* Read the entire next descriptor as we're likely to need it. */
/* Check next descriptor's own bit. If we don't own it, we have
* to quit and write error status into the last descriptor we own.
*/
break;
/* Write back current descriptor, clear the own bit. */
/* Switch to the next descriptor */
/* We have to leave the critical section here or we risk deadlocking
* with EMT when the write is to an unallocated page or has an access
* handler associated with it. See above for additional comments. */
/* RX disabled in the meantime? If so, abort RX. */
return;
/* Was the register modified in the meantime? If so, don't touch the
* register but still update the RX descriptor. */
{
if (iRxDesc-- < 2)
}
else
}
{
}
else
{
}
/* write back, clear the own bit */
#ifdef PCNET_DEBUG_RMD
#endif
/* guest driver is owner: force repoll of current and next RDTEs */
}
}
/* see description of TXDPOLL:
* ``transmit polling will take place following receive activities'' */
}
/**
* Transmit queue consumer
* This is just a very simple way of delaying sending to R3.
*
* @returns Success indicator.
* If false the item will not be removed and the flushing will stop.
* @param pDevIns The device instance.
* @param pItem The item to consume. Upon return this item will be freed.
*/
{
/*
* Transmit as much as we can.
*/
return true;
}
/**
*
* @returns See PPDMINETWORKUP::pfnAllocBuf.
* @param pThis The device instance.
* @param cbMin The minimum buffer size.
* @param fLoopback Set if we're in loopback mode.
* @param pSgLoop Pointer to stack storage for the loopback SG.
* @param ppSgBuf Where to return the SG buffer descriptor on success.
* Always set.
*/
{
int rc;
{
rc = VINF_SUCCESS;
}
else
{
{
AssertMsg(rc == VINF_SUCCESS || rc == VERR_TRY_AGAIN || rc == VERR_NET_DOWN || rc == VERR_NO_MEMORY, ("%Rrc\n", rc));
if (RT_FAILURE(rc))
}
else
{
rc = VERR_NET_DOWN;
}
}
return rc;
}
/**
* Frees an unsent buffer.
*
* @param pThis The device instance.
* @param fLoopback Set if we're in loopback mode.
* @param pSgBuf The SG to free. Can be NULL.
*/
{
if (pSgBuf)
{
if (RT_UNLIKELY(fLoopback))
else
{
}
}
}
/**
*
* Wrapper around PDMINETWORKUP::pfnSendBuf, so check it out for the fine print.
*
* @returns See PDMINETWORKUP::pfnSendBuf.
* @param pThis The device instance.
* @param fLoopback Set if we're in loopback mode.
* @param pSgBuf The SG to send.
* @param fOnWorkerThread Set if we're being called on a work thread. Clear
* if an EMT.
*/
DECLINLINE(int) pcnetXmitSendBuf(PPCNETSTATE pThis, bool fLoopback, PPDMSCATTERGATHER pSgBuf, bool fOnWorkerThread)
{
int rc;
{
rc = VINF_SUCCESS;
}
else
{
/** @todo We used to leave the critsect here, not sure if that's necessary any
* longer. If we could avoid that we could cache a bit more info in
* the loop and make it part of the driver<->device contract, saving
* critsect mess down in DrvIntNet. */
{
AssertMsg(rc == VINF_SUCCESS || rc == VERR_NET_DOWN || rc == VERR_NET_NO_BUFFER_SPACE, ("%Rrc\n", rc));
}
else
rc = VERR_NET_DOWN;
}
return rc;
}
/**
* pcnetXmitRead1st worker that handles the unlikely + slower segmented code
* path.
*/
{
AssertFailed(); /* This path is not supposed to be taken atm */
{
if (!cbFrame)
return;
GCPhysFrame += cbRead;
}
}
/**
* pcnetXmitSgReadMore worker that handles the unlikely + slower segmented code
* path.
*/
{
AssertFailed(); /* This path is not supposed to be taken atm */
/* Find the segment which we'll put the next byte into. */
{
iSeg++;
}
/* Commit before we start copying so we can decrement cbFrame. */
/* Deal with the first segment if we at an offset into it. */
{
if (!cbFrame)
return;
GCPhysFrame += cbRead;
iSeg++;
}
/* For the remainder, we've got whole segments. */
for (;; iSeg++)
{
if (!cbFrame)
return;
GCPhysFrame += cbFrame;
}
}
/**
* Reads the first part of a frame into the scatter gather buffer.
*/
DECLINLINE(void) pcnetXmitRead1st(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame,
{
if (RT_LIKELY(pSgBuf->aSegs[0].cbSeg >= cbFrame)) /* justification: all drivers returns a single segment atm. */
{
}
else
}
/**
* Reads more into the current frame.
*/
DECLINLINE(void) pcnetXmitReadMore(PPCNETSTATE pThis, RTGCPHYS32 GCPhysFrame, const unsigned cbFrame,
{
{
}
else
}
/**
* Fails a TMD with a link down error.
*/
{
/* make carrier error - hope this is correct. */
Log(("#%d pcnetTransmit: Signaling send error. swstyle=%#x\n",
}
/**
* Fails a TMD with a generic error.
*/
{
/* make carrier error - hope this is correct. */
Log(("#%d pcnetTransmit: Signaling send error. swstyle=%#x\n",
}
/**
* Try to transmit frames
*/
{
{
return;
}
/*
* Check the current transmit descriptors.
*/
return;
/*
* Clear TDMD.
*/
/*
* Transmit pending packets if possible, defer it if we cannot do it
* in the current context.
*/
{
if (RT_UNLIKELY(pItem))
}
else
#endif
{
if (rc == VERR_TRY_AGAIN)
rc = VINF_SUCCESS;
}
}
/**
* Actually try transmit frames.
*
* @threads TX or EMT.
*/
{
/*
* Just cleared transmit demand if the transmitter is off.
*/
{
return VINF_SUCCESS;
}
/*
* Iterate the transmit descriptors.
*/
int rc;
unsigned cFlushIrq = 0;
do
{
#ifdef VBOX_WITH_STATISTICS
unsigned cBuffers = 1;
#endif
break;
/* Don't continue sending packets when the link is down. */
)
break;
#ifdef PCNET_DEBUG_TMD
#endif
/*
* The typical case - a complete packet.
*/
{
{
/* From the manual: ``A zero length buffer is acceptable as
* long as it is not the last buffer in a chain (STP = 0 and
* ENP = 1).'' That means that the first buffer might have a
* zero length if it is not the last one in the chain. */
{
if (RT_SUCCESS(rc))
{
}
else if (rc == VERR_TRY_AGAIN)
{
return VINF_SUCCESS;
}
if (RT_FAILURE(rc))
}
else if (cb == 4096)
{
/* The Windows NT4 pcnet driver sometimes marks the first
* unused descriptor as owned by us. Ignore that (by
* passing it back). Do not update the ring counter in this
* case (otherwise that driver becomes even more confused,
* which causes transmit to stall for about 10 seconds).
* This is just a workaround, not a final solution. */
/* r=frank: IMHO this is the correct implementation. The
* manual says: ``If the OWN bit is set and the buffer
* length is 0, the OWN bit will be cleared. In the C-LANCE
* the buffer length of 0 is interpreted as a 4096-byte
* buffer.'' */
break;
}
else
{
/* Signal error, as this violates the Ethernet specs. */
/** @todo check if the correct error is generated. */
}
}
else
/* Write back the TMD and pass it to the host (clear own bit). */
/* advance the ring counter register */
else
}
{
/*
* Read TMDs until end-of-packet or tdte poll fails (underflow).
*
* We allocate a maximum sized buffer here since we do not wish to
* waste time finding out how much space we actually need even if
* we could reliably do that on SMP guests.
*/
if (rc == VERR_TRY_AGAIN)
{
return VINF_SUCCESS;
}
if (!fDropFrame)
for (;;)
{
/*
* Advance the ring counter register and check the next tmd.
*/
#ifdef LOG_ENABLED
#endif
else
{
/*
* Underflow!
*/
/* Don't allow the guest to clear TINT before reading it */
AssertMsgFailed(("pcnetAsyncTransmit: Underflow!!!\n"));
break;
}
/* release & save the previous tmd, pass it to the host */
/*
* The next tmd.
*/
#ifdef VBOX_WITH_STATISTICS
cBuffers++;
#endif
if ( !fDropFrame
else
{
fDropFrame = true;
}
/*
* Done already?
*/
{
{
}
else
if (fDropFrame)
/* Write back the TMD, pass it to the host */
/* advance the ring counter register */
else
break;
}
} /* the loop */
}
else
{
/*
* We underflowed in a previous transfer, or the driver is giving us shit.
* Simply stop the transmitting for now.
*/
/** @todo according to the specs we're supposed to clear the own bit and move on to the next one. */
break;
}
/* Update TDMD, TXSTRT and TINT. */
{
cFlushIrq++;
}
/** @todo should we continue after an error (tmd.tmd1.err) or not? */
if (cFlushIrq)
{
STAM_COUNTER_INC(&pThis->aStatXmitFlush[RT_MIN(cFlushIrq, RT_ELEMENTS(pThis->aStatXmitFlush)) - 1]);
/* The WinXP PCnet driver has apparently a bug: It sets CSR0.TDMD _before_
* it clears CSR0.TINT. This can lead to a race where the driver clears
* CSR0.TINT right after it was set by the device. The driver waits until
* CSR0.TINT is set again but this will never happen. So prevent clearing
* this bit as long as the driver didn't read it. See @bugref{5288}. */
/* Don't allow the guest to clear TINT before reading it */
}
return VINF_SUCCESS;
}
/**
* Transmit pending descriptors.
*
* @returns VBox status code. VERR_TRY_AGAIN is returned if we're busy.
*
* @param pThis The PCNet instance data.
* @param fOnWorkerThread Whether we're on a worker thread or on an EMT.
*/
{
int rc = VINF_SUCCESS;
/*
* Grab the xmit lock of the driver as well as the E1K device state.
*/
if (pDrv)
{
if (RT_FAILURE(rc))
return rc;
}
if (RT_SUCCESS(rc))
{
/** @todo check if we're supposed to suspend now. */
/*
* Do the transmitting.
*/
/*
* Release the locks.
*/
}
else
if (pDrv)
return rc;
}
/**
* Poll for changes in RX and TX descriptor rings.
*/
{
{
/*
* The second case is important for pcnetWaitReceiveAvail(): If CSR_CRST(pThis) was
* true but pcnetCanReceive() returned false for some other reason we need to check
* _now_ if we have to wakeup pcnetWaitReceiveAvail().
*/
}
}
/**
* Start the poller timer.
* Poll timer interval is fixed to 500Hz. Don't stop it.
* @thread EMT, TAP.
*/
{
}
/**
* Update the poller timer.
* @thread EMT.
*/
{
#ifdef LOG_ENABLED
Log2(("#%d pcnetPollTimer time=%#010llx CSR_STOP=%d CSR_SPND=%d\n",
else
Log2(("#%d pcnetPollTimer time=%#010llx TDMD=%d TXON=%d POLL=%d TDTE=%d TDRA=%#x\n",
Log2(("#%d pcnetPollTimer: CSR_CXDA=%#x CSR_XMTRL=%d CSR_XMTRC=%d\n",
#endif
#ifdef PCNET_DEBUG_TMD
{
}
#endif
* disabled. We wouldn't need to poll for new TX descriptors in that case but it will
* not hurt as waiting for RX descriptors should happen very seldom */
|| pThis->fMaybeOutOfSpace)))
{
/* We ensure that we poll at least every 2ms (500Hz) but not more often than
* 5000 times per second. This way we completely prevent the overhead from
* heavy reprogramming the timer which turned out to be very CPU-intensive.
* The drawback is that csr46 and csr47 are not updated properly anymore
* but so far I have not seen any guest depending on these values. The 2ms
* interval is the default polling interval of the PCNet card (65536/33MHz). */
#ifdef PCNET_NO_POLLING
#else
{
}
#endif
}
}
{
int rc = VINF_SUCCESS;
#ifdef PCNET_DEBUG_CSR
#endif
switch (u32RAP)
{
case 0:
{
/* Clear any interrupt flags.
* Don't clear an interrupt flag which was not seen by the guest yet. */
/* Iff STOP, STRT and INIT are set, clear STRT and INIT */
val &= ~3;
#ifndef IN_RING3
{
return VINF_IOM_R3_IOPORT_WRITE;
}
#endif
#ifdef IN_RING3
#endif
return rc;
}
case 1: /* IADRL */
case 2: /* IADRH */
case 8: /* LADRF 0..15 */
case 9: /* LADRF 16..31 */
case 10: /* LADRF 32..47 */
case 11: /* LADRF 48..63 */
case 12: /* PADR 0..15 */
case 13: /* PADR 16..31 */
case 14: /* PADR 32..47 */
case 18: /* CRBAL */
case 19: /* CRBAU */
case 20: /* CXBAL */
case 21: /* CXBAU */
case 22: /* NRBAL */
case 23: /* NRBAU */
case 26: /* NRDAL */
case 27: /* NRDAU */
case 28: /* CRDAL */
case 29: /* CRDAU */
case 32: /* NXDAL */
case 33: /* NXDAU */
case 34: /* CXDAL */
case 35: /* CXDAU */
case 36: /* NNRDL */
case 37: /* NNRDU */
case 38: /* NNXDL */
case 39: /* NNXDU */
case 40: /* CRBCL */
case 41: /* CRBCU */
case 42: /* CXBCL */
case 43: /* CXBCU */
case 44: /* NRBCL */
case 45: /* NRBCU */
case 46: /* POLL */
case 47: /* POLLINT */
case 72: /* RCVRC */
case 74: /* XMTRC */
case 112: /* MISSC */
break;
case 3: /* Interrupt Mask and Deferral Control */
break;
case 4: /* Test and Features Control */
val &= ~0x026a;
break;
case 5: /* Extended Control and Interrupt 1 */
val &= ~0x0a90;
break;
case 7: /* Extended Control and Interrupt 2 */
{
csr7 &= ~0x0400 ;
return rc;
}
case 15: /* Mode */
{
#ifndef IN_RING3
return VINF_IOM_R3_IOPORT_WRITE;
#else
/* check for promiscuous mode change */
#endif
}
break;
case 16: /* IADRL */
case 17: /* IADRH */
/*
* 24 and 25 are the Base Address of Receive Descriptor.
* We combine and mirror these in GCRDRA.
*/
case 24: /* BADRL */
case 25: /* BADRU */
{
return rc;
}
if (u32RAP == 24)
else
Log(("#%d: WRITE CSR%d, %#06x => GCRDRA=%08x (alt init)\n", PCNET_INST_NR, u32RAP, val, pThis->GCRDRA));
break;
/*
* 30 & 31 are the Base Address of Transmit Descriptor.
* We combine and mirrorthese in GCTDRA.
*/
case 30: /* BADXL */
case 31: /* BADXU */
{
return rc;
}
if (u32RAP == 30)
else
Log(("#%d: WRITE CSR%d, %#06x => GCTDRA=%08x (alt init)\n", PCNET_INST_NR, u32RAP, val, pThis->GCTDRA));
break;
case 58: /* Software Style */
break;
/*
* Registers 76 and 78 aren't stored correctly (see todos), but I'm don't dare
* try fix that right now. So, as a quick hack for 'alt init' I'll just correct them here.
*/
case 76: /* RCVRL */ /** @todo call pcnetUpdateRingHandlers */
/** @todo receive ring length is stored in two's complement! */
case 78: /* XMTRL */ /** @todo call pcnetUpdateRingHandlers */
/** @todo transmit ring length is stored in two's complement! */
{
return rc;
}
/*
* HACK ALERT! Set the counter registers too.
*/
break;
default:
return rc;
}
return rc;
}
/**
* Encode a 32-bit link speed into a custom 16-bit floating-point value
*/
{
unsigned exp = 0;
while (speed & 0xFFFFE000)
{
speed /= 10;
++exp;
}
}
{
switch (u32RAP)
{
case 0:
break;
case 16:
case 17:
case 58:
case 68: /* Custom register to pass link speed to driver */
case 88:
val <<= 16;
break;
default:
}
#ifdef PCNET_DEBUG_CSR
#endif
return val;
}
{
int rc = VINF_SUCCESS;
u32RAP &= 0x7f;
#ifdef PCNET_DEBUG_BCR
#endif
switch (u32RAP)
{
case BCR_SWS:
return rc;
val &= ~0x0300;
switch (val & 0x00ff)
{
default:
// fall through
case 0:
break;
case 1:
pThis->GCUpperPhys = 0;
break;
case 2:
case 3:
pThis->GCUpperPhys = 0;
break;
}
/* fall through */
case BCR_LNKST:
case BCR_LED1:
case BCR_LED2:
case BCR_LED3:
case BCR_MC:
case BCR_FDC:
case BCR_BSBC:
case BCR_EECAS:
case BCR_PLAT:
case BCR_MIICAS:
case BCR_MIIADDR:
break;
case BCR_STVAL:
val &= 0xffff;
break;
case BCR_MIIMDR:
#ifdef PCNET_DEBUG_MII
#endif
break;
default:
break;
}
return rc;
}
{
switch (miiaddr)
{
case 0:
/* MII basic mode control register. */
val = 0;
if (autoneg)
if (fast)
if (duplex) /* Full duplex forced */
break;
case 1:
/* MII basic mode status register. */
| 0x0040 /* Mgmt frame preamble not required. */
| 0x0020 /* Auto-negotiation complete. */
| 0x0008 /* Able to do auto-negotiation. */
| 0x0004 /* Link up. */
| 0x0001; /* Extended Capability, i.e. registers 4+ valid. */
}
if (!autoneg) {
/* Auto-negotiation disabled. */
if (duplex)
/* Full duplex forced. */
val &= ~0x2800;
else
/* Half duplex forced. */
val &= ~0x5000;
if (fast)
/* 100 Mbps forced */
val &= ~0x1800;
else
/* 10 Mbps forced */
val &= ~0x6000;
}
break;
case 2:
/* PHY identifier 1. */
break;
case 3:
/* PHY identifier 2. */
break;
case 4:
/* Advertisement control register. */
#if 0
// Advertising flow control is a) not the default, and b) confuses
// the link speed detection routine in Windows PCnet driver
| 0x0400 /* Try flow control. */
#endif
| 0x0001; /* CSMA selector. */
break;
case 5:
/* Link partner ability register. */
| 0x4000 /* Link partner acked us. */
| 0x0400 /* Can do flow control. */
| 0x0001; /* Use CSMA selector. */
else
{
val = 0;
}
break;
case 6:
/* Auto negotiation expansion register. */
| 0x0004 /* Enable npage words. */
| 0x0001; /* Can do N-way auto-negotiation. */
else
{
val = 0;
}
break;
default:
val = 0;
break;
}
#ifdef PCNET_DEBUG_MII
#endif
return val;
}
{
u32RAP &= 0x7f;
switch (u32RAP)
{
case BCR_LNKST:
case BCR_LED1:
case BCR_LED2:
case BCR_LED3:
/* Clear LNKSTE if we're not connected or if we've just loaded a VM state. */
{
if (u32RAP == 4)
val &= ~0x40;
}
break;
case BCR_MIIMDR:
{
}
else
val = 0xffff;
break;
default:
break;
}
#ifdef PCNET_DEBUG_BCR
#endif
return val;
}
#ifdef IN_RING3 /* move down */
{
int i;
/* Initialize the PROM */
for (i = 0, checksum = 0; i < 16; i++)
/* Reset the error counter. */
pThis->uCntBadRMD = 0;
}
#endif /* IN_RING3 */
/* -=-=-=-=-=- APROM I/O Port access -=-=-=-=-=- */
{
addr &= 0x0f;
val &= 0xff;
/* Check APROMWE bit to enable write access */
}
{
return val;
}
/**
* @callback_method_impl{FNIOMIOPORTIN, APROM}
*/
PDMBOTHCBDECL(int) pcnetIOPortAPromRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
int rc = VINF_SUCCESS;
/* FreeBSD is accessing in dwords. */
if (cb == 1)
else
{
}
LogFlow(("#%d pcnetIOPortAPromRead: Port=%RTiop *pu32=%#RX32 cb=%d rc=%Rrc\n", PCNET_INST_NR, Port, *pu32, cb, rc));
return rc;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT, APROM}
*/
PDMBOTHCBDECL(int) pcnetIOPortAPromWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
int rc = VINF_SUCCESS;
if (cb == 1)
{
}
else
LogFlow(("#%d pcnetIOPortAPromWrite: Port=%RTiop u32=%#RX32 cb=%d rc=%Rrc\n", PCNET_INST_NR, Port, u32, cb, rc));
return rc;
}
/* -=-=-=-=-=- I/O Port access -=-=-=-=-=- */
{
int rc = VINF_SUCCESS;
#ifdef PCNET_DEBUG_IO
#endif
{
switch (addr & 0x0f)
{
case 0x04: /* RESET */
break;
}
}
else
return rc;
}
{
*pRC = VINF_SUCCESS;
{
switch (addr & 0x0f)
{
case 0x04: /* RESET */
val = 0;
break;
}
}
else
Log(("#%d pcnetIoportReadU8: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xff));
#ifdef PCNET_DEBUG_IO
#endif
return val;
}
{
int rc = VINF_SUCCESS;
#ifdef PCNET_DEBUG_IO
#endif
{
switch (addr & 0x0f)
{
case 0x00: /* RDP */
break;
case 0x02: /* RAP */
break;
case 0x06: /* BDP */
break;
}
}
else
return rc;
}
{
*pRC = VINF_SUCCESS;
{
switch (addr & 0x0f)
{
case 0x00: /* RDP */
/** @note if we're not polling, then the guest will tell us when to poll by setting TDMD in CSR0 */
/** Polling is then useless here and possibly expensive. */
goto skip_update_irq;
break;
case 0x02: /* RAP */
goto skip_update_irq;
case 0x04: /* RESET */
val = 0;
break;
case 0x06: /* BDP */
break;
}
}
else
Log(("#%d pcnetIoportReadU16: addr=%#010x val=%#06x BCR_DWIO !!\n", PCNET_INST_NR, addr, val & 0xffff));
#ifdef PCNET_DEBUG_IO
#endif
return val;
}
{
int rc = VINF_SUCCESS;
#ifdef PCNET_DEBUG_IO
#endif
{
switch (addr & 0x0f)
{
case 0x00: /* RDP */
break;
case 0x04: /* RAP */
break;
case 0x0c: /* BDP */
break;
}
}
else if ((addr & 0x0f) == 0)
{
/* switch device to dword I/O mode */
#ifdef PCNET_DEBUG_IO
Log2(("device switched into dword i/o mode\n"));
#endif
}
else
return rc;
}
{
*pRC = VINF_SUCCESS;
{
switch (addr & 0x0f)
{
case 0x00: /* RDP */
/** @note if we're not polling, then the guest will tell us when to poll by setting TDMD in CSR0 */
/** Polling is then useless here and possibly expensive. */
goto skip_update_irq;
break;
case 0x04: /* RAP */
goto skip_update_irq;
case 0x08: /* RESET */
val = 0;
break;
case 0x0c: /* BDP */
break;
}
}
else
#ifdef PCNET_DEBUG_IO
#endif
return val;
}
/**
* @callback_method_impl{FNIOMIOPORTIN}
*/
PDMBOTHCBDECL(int) pcnetIOPortRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
{
int rc = VINF_SUCCESS;
switch (cb)
{
default:
"pcnetIOPortRead: unsupported op size: offset=%#10x cb=%u\n",
}
Log2(("#%d pcnetIOPortRead: Port=%RTiop *pu32=%#RX32 cb=%d rc=%Rrc\n", PCNET_INST_NR, Port, *pu32, cb, rc));
return rc;
}
/**
* @callback_method_impl{FNIOMIOPORTOUT}
*/
PDMBOTHCBDECL(int) pcnetIOPortWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
{
int rc = VINF_SUCCESS;
switch (cb)
{
default:
"pcnetIOPortWrite: unsupported op size: offset=%#10x cb=%u\n",
}
Log2(("#%d pcnetIOPortWrite: Port=%RTiop u32=%#RX32 cb=%d rc=%Rrc\n", PCNET_INST_NR, Port, u32, cb, rc));
return rc;
}
/* -=-=-=-=-=- MMIO -=-=-=-=-=- */
{
#ifdef PCNET_DEBUG_IO
#endif
if (!(addr & 0x10))
}
{
if (!(addr & 0x10))
#ifdef PCNET_DEBUG_IO
#endif
return val;
}
{
#ifdef PCNET_DEBUG_IO
#endif
if (addr & 0x10)
else
{
}
}
{
int rc;
if (addr & 0x10)
else
{
val <<= 8;
}
#ifdef PCNET_DEBUG_IO
#endif
return val;
}
{
#ifdef PCNET_DEBUG_IO
#endif
if (addr & 0x10)
else
{
}
}
{
int rc;
if (addr & 0x10)
else
{
val <<= 8;
val <<= 8;
val <<= 8;
}
#ifdef PCNET_DEBUG_IO
#endif
return val;
}
/**
* @callback_method_impl{FNIOMMMIOREAD}
*/
PDMBOTHCBDECL(int) pcnetMMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
{
int rc = VINF_SUCCESS;
/*
* We have to check the range, because we're page aligning the MMIO.
*/
{
switch (cb)
{
default:
"pcnetMMIORead: unsupported op size: address=%RGp cb=%u\n",
GCPhysAddr, cb);
}
}
else
LogFlow(("#%d pcnetMMIORead: pvUser=%p:{%.*Rhxs} cb=%d GCPhysAddr=%RGp rc=%Rrc\n",
return rc;
}
/**
* @callback_method_impl{FNIOMMMIOWRITE}
*/
PDMBOTHCBDECL(int) pcnetMMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
{
int rc = VINF_SUCCESS;
/*
* We have to check the range, because we're page aligning the MMIO stuff presently.
*/
{
switch (cb)
{
default:
"pcnetMMIOWrite: unsupported op size: address=%RGp cb=%u\n",
GCPhysAddr, cb);
}
}
LogFlow(("#%d pcnetMMIOWrite: pvUser=%p:{%.*Rhxs} cb=%d GCPhysAddr=%RGp rc=%Rrc\n",
return rc;
}
#ifdef IN_RING3
/* -=-=-=-=-=- Timer Callbacks -=-=-=-=-=- */
/**
* @callback_method_impl{FNTMTIMERDEV, Poll timer}
*/
{
}
/**
* @callback_method_impl{FNTMTIMERDEV,
* Software interrupt timer callback function.}
*/
{
}
/**
* @callback_method_impl{FNTMTIMERDEV, Restore timer callback}
*
* This is only called when we restore a saved state and temporarily
* disconnected the network link to inform the guest that network connections
* should be considered lost.
*/
{
if (RT_FAILURE(rc))
{
pThis->fLinkTempDown = false;
{
LogRel(("PCNet#%d: The link is back up again after the restore.\n",
Log(("#%d pcnetTimerRestore: Clearing ERR and CERR after load. cLinkDownReported=%d\n",
pThis->aCSR[0] &= ~(RT_BIT(15) | RT_BIT(13)); /* ERR | CERR - probably not 100% correct either... */
}
}
else
Log(("#%d pcnetTimerRestore: cLinkDownReported=%d, wait another 1500ms...\n",
}
/* -=-=-=-=-=- PCI Device Callbacks -=-=-=-=-=- */
/**
* @callback_method_impl{FNPCIIOREGIONMAP, For the PC-NET I/O Ports.}
*/
{
int rc;
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
if (pThis->fGCEnabled)
{
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
}
if (pThis->fR0Enabled)
{
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
}
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNPCIIOREGIONMAP, For the PC-Net MMIO region.}
*/
{
int rc;
/* We use the assigned size here, because we only support page aligned MMIO ranges. */
if (RT_FAILURE(rc))
return rc;
return rc;
}
/**
* @callback_method_impl{FNPCIIOREGIONMAP, VBox specific MMIO2 interface.}
*/
{
if (GCPhysAddress != NIL_RTGCPHYS)
/* nothing to clean up */
return VINF_SUCCESS;
}
/* -=-=-=-=-=- Debug Info Handler -=-=-=-=-=- */
/**
* @callback_method_impl{FNDBGFHANDLERDEV}
*/
{
bool fRcvRing = false;
bool fXmtRing = false;
/*
* Parse args.
*/
if (pszArgs)
{
}
/*
* Show info.
*/
"pcnet #%d: port=%RTiop mmio=%RX32 mac-cfg=%RTmac %s\n",
pThis->fAm79C973 ? "Am79C973" : "Am79C970A", pThis->fGCEnabled ? " GC" : "", pThis->fR0Enabled ? " R0" : "");
PDMCritSectEnter(&pThis->CritSect, VERR_INTERNAL_ERROR); /* Take it here so we know why we're hanging... */
"CSR0=%#06x:\n",
"CSR1=%#06x:\n",
"CSR2=%#06x:\n",
"CSR3=%#06x: BSWP=%d EMBA=%d DXMT2PD=%d LAPPEN=%d DXSUFLO=%d IDONM=%d TINTM=%d RINTM=%d MERRM=%d MISSM=%d BABLM=%d\n",
!!(pThis->aCSR[3] & RT_BIT(2)), !!(pThis->aCSR[3] & RT_BIT(3)), !!(pThis->aCSR[3] & RT_BIT(4)), CSR_LAPPEN(pThis),
CSR_DXSUFLO(pThis), !!(pThis->aCSR[3] & RT_BIT(8)), !!(pThis->aCSR[3] & RT_BIT(9)), !!(pThis->aCSR[3] & RT_BIT(10)),
"CSR4=%#06x: JABM=%d JAB=%d TXSTRM=%d TXSTRT=%d RCVCOOM=%d RCVCCO=%d UINT=%d UINTCMD=%d\n"
" MFCOM=%d MFCO=%d ASTRP_RCV=%d APAD_XMT=%d DPOLL=%d TIMER=%d EMAPLUS=%d EN124=%d\n",
!!(pThis->aCSR[4] & RT_BIT( 0)), !!(pThis->aCSR[4] & RT_BIT( 1)), !!(pThis->aCSR[4] & RT_BIT( 2)), !!(pThis->aCSR[4] & RT_BIT( 3)),
!!(pThis->aCSR[4] & RT_BIT( 4)), !!(pThis->aCSR[4] & RT_BIT( 5)), !!(pThis->aCSR[4] & RT_BIT( 6)), !!(pThis->aCSR[4] & RT_BIT( 7)),
!!(pThis->aCSR[4] & RT_BIT( 8)), !!(pThis->aCSR[4] & RT_BIT( 9)), !!(pThis->aCSR[4] & RT_BIT(10)), !!(pThis->aCSR[4] & RT_BIT(11)),
!!(pThis->aCSR[4] & RT_BIT(12)), !!(pThis->aCSR[4] & RT_BIT(13)), !!(pThis->aCSR[4] & RT_BIT(14)), !!(pThis->aCSR[4] & RT_BIT(15)));
"CSR5=%#06x:\n",
"CSR6=%#06x: RLEN=%#x* TLEN=%#x* [* encoded]\n",
"CSR8..11=%#06x,%#06x,%#06x,%#06x: LADRF=%#018llx\n",
"CSR12..14=%#06x,%#06x,%#06x: PADR=%02x:%02x:%02x:%02x:%02x:%02x (Current MAC Address)\n",
"CSR15=%#06x: DXR=%d DTX=%d LOOP=%d DXMTFCS=%d FCOLL=%d DRTY=%d INTL=%d PORTSEL=%d LTR=%d\n"
" MENDECL=%d DAPC=%d DLNKTST=%d DRCVPV=%d DRCVBC=%d PROM=%d\n",
!!(pThis->aCSR[15] & RT_BIT( 0)), !!(pThis->aCSR[15] & RT_BIT( 1)), !!(pThis->aCSR[15] & RT_BIT( 2)), !!(pThis->aCSR[15] & RT_BIT( 3)),
!!(pThis->aCSR[15] & RT_BIT( 4)), !!(pThis->aCSR[15] & RT_BIT( 5)), !!(pThis->aCSR[15] & RT_BIT( 6)), (pThis->aCSR[15] >> 7) & 3,
!!(pThis->aCSR[15] & RT_BIT( 9)), !!(pThis->aCSR[15] & RT_BIT(10)), !!(pThis->aCSR[15] & RT_BIT(11)),
!!(pThis->aCSR[15] & RT_BIT(12)), !!(pThis->aCSR[15] & RT_BIT(13)), !!(pThis->aCSR[15] & RT_BIT(14)), !!(pThis->aCSR[15] & RT_BIT(15)));
"CSR46=%#06x: POLL=%#06x (Poll Time Counter)\n",
"CSR47=%#06x: POLLINT=%#06x (Poll Time Interval)\n",
"CSR58=%#06x: SWSTYLE=%d %s SSIZE32=%d CSRPCNET=%d APERRENT=%d\n",
: "!!reserved!!",
!!(pThis->aCSR[58] & RT_BIT(8)), !!(pThis->aCSR[58] & RT_BIT(9)), !!(pThis->aCSR[58] & RT_BIT(10)));
"CSR112=%04RX32: MFC=%04x (Missed receive Frame Count)\n",
"CSR122=%04RX32: RCVALGN=%04x (Receive Frame Align)\n",
"CSR124=%04RX32: RPA=%04x (Runt Packet Accept)\n",
/*
* Dump the receive ring.
*/
"RCVRL=%04x RCVRC=%04x GCRDRA=%RX32 \n"
"CRDA=%08RX32 CRBA=%08RX32 CRBC=%03x CRST=%04x\n"
"NRDA=%08RX32 NRBA=%08RX32 NRBC=%03x NRST=%04x\n"
"NNRDA=%08RX32\n"
,
if (fRcvRing)
{
while (i-- > 0)
{
"%04x %RX32:%c%c RBADR=%08RX32 BCNT=%03x MCNT=%03x "
"OWN=%d ERR=%d FRAM=%d OFLO=%d CRC=%d BUFF=%d STP=%d ENP=%d BPE=%d "
"PAM=%d LAFM=%d BAM=%d RCC=%02x RPC=%02x ONES=%#x ZEROS=%d\n",
}
}
/*
* Dump the transmit ring.
*/
"XMTRL=%04x XMTRC=%04x GCTDRA=%08RX32 BADX=%08RX32\n"
"PXDA=%08RX32 PXBC=%03x PXST=%04x\n"
"CXDA=%08RX32 CXBA=%08RX32 CXBC=%03x CXST=%04x\n"
"NXDA=%08RX32 NXBA=%08RX32 NXBC=%03x NXST=%04x\n"
"NNXDA=%08RX32\n"
,
if (fXmtRing)
{
while (i-- > 0)
{
"%04x %RX32:%c%c TBADR=%08RX32 BCNT=%03x OWN=%d "
"ERR=%d NOFCS=%d LTINT=%d ONE=%d DEF=%d STP=%d ENP=%d BPE=%d "
"BUFF=%d UFLO=%d EXDEF=%d LCOL=%d LCAR=%d RTRY=%d TDR=%03x TRC=%#x ONES=%#x\n"
,
}
}
}
/* -=-=-=-=-=- Helper(s) -=-=-=-=-=- */
/**
* Takes down the link temporarily if it's current status is up.
*
* This is used during restore and when replumbing the network link.
*
* The temporary link outage is supposed to indicate to the OS that all network
* connections have been lost and that it for instance is appropriate to
* renegotiate any DHCP lease.
*
* @param pThis The PCNet instance data.
*/
{
{
pThis->fLinkTempDown = true;
pThis->cLinkDownReported = 0;
}
}
/* -=-=-=-=-=- Saved State -=-=-=-=-=- */
/**
* Saves the configuration.
*
* @param pThis The PCNet instance data.
* @param pSSM The saved state handle.
*/
{
}
/**
* @callback_method_impl{FNSSMDEVLIVEEXEC, Pass 0 only.}
*/
{
return VINF_SSM_DONT_CALL_AGAIN;
}
/**
* @callback_method_impl{FNSSMDEVSAVEPREP,
* Serializes the receive thread, it may be working inside the critsect.}
*/
{
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNSSMDEVSAVEEXEC}
*/
{
int rc = VINF_SUCCESS;
#ifndef PCNET_NO_POLLING
if (RT_FAILURE(rc))
return rc;
#endif
return rc;
}
/**
* @callback_method_impl{FNSSMDEVLOADPREP,
* Serializes the receive thread, it may be working inside the critsect.}
*/
{
return VINF_SUCCESS;
}
/**
* @callback_method_impl{FNSSMDEVLOADEXEC}
*/
static DECLCALLBACK(int) pcnetLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
{
if (uPass == SSM_PASS_FINAL)
{
/* restore data */
if ( SSM_VERSION_MAJOR(uVersion) > 0
{
if (pThis->fPrivIfEnabled)
}
if ( SSM_VERSION_MAJOR(uVersion) > 0
{
}
}
/* check config */
LogRel(("PCNet#%u: The mac address differs: config=%RTmac saved=%RTmac\n", PCNET_INST_NR, &pThis->MacConfigured, &Mac));
bool fAm79C973;
return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("The fAm79C973 flag differs: config=%RTbool saved=%RTbool"), pThis->fAm79C973, fAm79C973);
LogRel(("PCNet#%u: The mac link speed differs: config=%u saved=%u\n", PCNET_INST_NR, pThis->u32LinkSpeed, u32LinkSpeed));
if (uPass == SSM_PASS_FINAL)
{
/* restore timers and stuff */
#ifndef PCNET_NO_POLLING
#endif
{
if ( SSM_VERSION_MAJOR(uVersion) > 0
}
? 4
: 3;
? 0
/* update promiscuous mode. */
#ifdef PCNET_NO_POLLING
/* Enable physical monitoring again (!) */
#endif
/* Indicate link down to the guest OS that all network connections have
been lost, unless we've been teleported here. */
}
return VINF_SUCCESS;
}
/* -=-=-=-=-=- PCNETSTATE::INetworkDown -=-=-=-=-=- */
/**
*
* Worker for pcnetNetworkDown_WaitReceiveAvail(). This must be called before
* the pfnRecieve() method is called.
*
* @returns VBox status code.
* @param pThis The PC-Net instance data.
*/
{
{
{
/** @todo Notify the guest _now_. Will potentially increase the interrupt load */
if (pThis->fSignalRxMiss)
}
else
rc = VINF_SUCCESS;
}
return rc;
}
/**
* @interface_method_impl{PDMINETWORKDOWN,pfnWaitReceiveAvail}
*/
static DECLCALLBACK(int) pcnetNetworkDown_WaitReceiveAvail(PPDMINETWORKDOWN pInterface, RTMSINTERVAL cMillies)
{
if (RT_SUCCESS(rc))
return VINF_SUCCESS;
if (RT_UNLIKELY(cMillies == 0))
return VERR_NET_NO_BUFFER_SPACE;
|| enmVMState == VMSTATE_RUNNING_LS))
{
if (RT_SUCCESS(rc2))
{
rc = VINF_SUCCESS;
break;
}
/* Start the poll timer once which will remain active as long fMaybeOutOfSpace
* is true -- even if (transmit) polling is disabled (CSR_DPOLL). */
}
return rc;
}
/**
* @interface_method_impl{PDMINETWORKDOWN,pfnReceive}
*/
static DECLCALLBACK(int) pcnetNetworkDown_Receive(PPDMINETWORKDOWN pInterface, const void *pvBuf, size_t cb)
{
int rc;
/*
* Check for the max ethernet frame size, taking the IEEE 802.1Q (VLAN) tag into
* account. Note that the CRC Checksum is optional.
* Ethernet frames consist of a 14-byte header [+ 4-byte vlan tag] + a 1500-byte body [+ 4-byte CRC].
*/
|| ( cb <= 1522
{
|| ( cb <= 1518
}
#ifdef LOG_ENABLED
else
{
static bool s_fFirstBigFrameLoss = true;
? 1522 : 1518;
if (s_fFirstBigFrameLoss)
{
s_fFirstBigFrameLoss = false;
Log(("PCNet#%d: Received giant frame %zu, max %u. (Further giants will be reported at level5.)\n",
}
else
Log5(("PCNet#%d: Received giant frame %zu bytes, max %u.\n",
}
#endif /* LOG_ENABLED */
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMINETWORKDOWN,pfnXmitPending}
*/
{
}
/* -=-=-=-=-=- PCNETSTATE::INetworkConfig -=-=-=-=-=- */
/**
* @interface_method_impl{PDMINETWORKCONFIG,pfnGetMac}
*/
{
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMINETWORKCONFIG,pfnGetLinkState}
*/
{
return PDMNETWORKLINKSTATE_UP;
return PDMNETWORKLINKSTATE_DOWN;
if (pThis->fLinkTempDown)
return PDMNETWORKLINKSTATE_DOWN_RESUME;
AssertMsgFailed(("Invalid link state!\n"));
return PDMNETWORKLINKSTATE_INVALID;
}
/**
* @interface_method_impl{PDMINETWORKCONFIG,pfnSetLinkState}
*/
static DECLCALLBACK(int) pcnetSetLinkState(PPDMINETWORKCONFIG pInterface, PDMNETWORKLINKSTATE enmState)
{
bool fLinkUp;
if ( enmState != PDMNETWORKLINKSTATE_DOWN
&& enmState != PDMNETWORKLINKSTATE_UP)
{
return VERR_INVALID_PARAMETER;
}
/* has the state changed? */
{
if (fLinkUp)
{
/* connect with a delay of 5 seconds */
pThis->fLinkTempDown = true;
pThis->cLinkDownReported = 0;
}
else
{
/* disconnect */
pThis->cLinkDownReported = 0;
}
}
return VINF_SUCCESS;
}
/* -=-=-=-=-=- PCNETSTATE::ILeds (LUN#0) -=-=-=-=-=- */
/**
* @interface_method_impl{PDMILEDPORTS,pfnQueryStatusLed}
*/
static DECLCALLBACK(int) pcnetQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
{
if (iLUN == 0)
{
return VINF_SUCCESS;
}
return VERR_PDM_LUN_NOT_FOUND;
}
/* -=-=-=-=-=- PCNETSTATE::IBase (LUN#0) -=-=-=-=-=- */
/**
* @interface_method_impl{PDMIBASE,pfnQueryInterface}
*/
{
return NULL;
}
/* -=-=-=-=-=- PDMDEVREG -=-=-=-=-=- */
/**
* @interface_method_impl{PDMDEVREG,pfnPowerOff}
*/
{
/* Poke thread waiting for buffer space. */
}
/**
* @interface_method_impl{PDMDEVREG,pfnDetach}
*
* One port on the network card has been disconnected from the network.
*/
{
AssertLogRelReturnVoid(iLUN == 0);
/** @todo: r=pritesh still need to check if i missed
* to clean something in this function
*/
/*
* Zero some important members.
*/
}
/**
* @interface_method_impl{PDMDEVREG,pfnAttach}
* One port on the network card has been connected to a network.
*/
{
/*
* Attach the driver.
*/
if (RT_SUCCESS(rc))
{
if (rc == VINF_NAT_DNS)
{
#ifdef RT_OS_LINUX
N_("A Domain Name Server (DNS) for NAT networking could not be determined. Please check your /etc/resolv.conf for <tt>nameserver</tt> entries. Either add one manually (<i>man resolv.conf</i>) or ensure that your host is correctly connected to an ISP. If you ignore this warning the guest will not be able to perform nameserver lookups and it will probably observe delays if trying so"));
#else
N_("A Domain Name Server (DNS) for NAT networking could not be determined. Ensure that your host is correctly connected to an ISP. If you ignore this warning the guest will not be able to perform nameserver lookups and it will probably observe delays if trying so"));
#endif
}
pThis->pDrvR0 = PDMIBASER0_QUERY_INTERFACE(PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBASER0), PDMINETWORKUP);
pThis->pDrvRC = PDMIBASERC_QUERY_INTERFACE(PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBASERC), PDMINETWORKUP);
}
else if ( rc == VERR_PDM_NO_ATTACHED_DRIVER
{
/* This should never happen because this function is not called
* if there is no driver to attach! */
}
/*
* Temporary set the link down if it was up so that the guest
* will know that we have change the configuration of the
* network card
*/
if (RT_SUCCESS(rc))
return rc;
}
/**
* @interface_method_impl{PDMDEVREG,pfnSuspend}
*/
{
/* Poke thread waiting for buffer space. */
}
/**
* @interface_method_impl{PDMDEVREG,pfnReset}
*/
{
if (pThis->fLinkTempDown)
{
}
if (pThis->pSharedMMIOR3)
/** @todo How to flush the queues? */
}
/**
* @interface_method_impl{PDMDEVREG,pfnRelocate}
*/
{
if (pThis->pSharedMMIOR3)
#ifdef PCNET_NO_POLLING
#else
#endif
}
/**
* @interface_method_impl{PDMDEVREG,pfnDestruct}
*/
{
{
}
return VINF_SUCCESS;
}
/**
* @interface_method_impl{PDMDEVREG,pfnConstruct}
*/
{
char szTmp[128];
int rc;
/*
* Init what's required to make the destructor safe.
*/
/*
* Validate configuration.
*/
if (!CFGMR3AreValuesValid(pCfg, "MAC\0" "CableConnected\0" "Am79C973\0" "LineSpeed\0" "GCEnabled\0" "R0Enabled\0" "PrivIfEnabled\0" "LinkUpDelay\0"))
N_("Invalid configuration for pcnet device"));
/*
* Read the configuration.
*/
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"MAC\" value"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"CableConnected\" value"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"Am79C973\" value"));
rc = CFGMR3QueryU32Def(pCfg, "LineSpeed", &pThis->u32LinkSpeed, 1000000); /* 1GBit/s (in kbps units)*/
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"LineSpeed\" value"));
#ifdef PCNET_GC_ENABLED
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"GCEnabled\" value"));
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"R0Enabled\" value"));
#else /* !PCNET_GC_ENABLED */
pThis->fGCEnabled = false;
pThis->fR0Enabled = false;
#endif /* !PCNET_GC_ENABLED */
if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the value of 'LinkUpDelay'"));
{
LogRel(("PCNet#%d WARNING! Link up delay is set to %u seconds!\n",
}
Log(("#%d Link up delay is set to %u seconds\n",
/*
* Initialize data (most of it anyway).
*/
/* IBase */
/* INeworkPort */
/* INetworkConfig */
/* ILeds */
/* PCI Device */
/* subsystem and subvendor IDs */
/*
* We use own critical section (historical reasons).
*/
/*
* Register the PCI device, its I/O regions, the timer and the saved state item.
*/
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, PCNET_IOPORT_SIZE, PCI_ADDRESS_SPACE_IO, pcnetIOPortMap);
if (RT_FAILURE(rc))
return rc;
rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, PCNET_PNPMMIO_SIZE, PCI_ADDRESS_SPACE_MEM, pcnetMMIOMap);
if (RT_FAILURE(rc))
return rc;
bool fPrivIfEnabled;
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
fPrivIfEnabled = true;
else if (RT_FAILURE(rc))
N_("Configuration error: Failed to get the \"PrivIfEnabled\" value"));
if (fPrivIfEnabled)
{
/*
* Initialize shared memory between host and guest for descriptors and RX buffers. Most guests
* should not care if there is an additional PCI resource but just in case we made this configurable.
*/
rc = PDMDevHlpMMIO2Register(pDevIns, 2, PCNET_GUEST_SHARED_MEMORY_SIZE, 0, (void **)&pThis->pSharedMMIOR3, "PCNetShMem");
if (RT_FAILURE(rc))
if (RT_FAILURE(rc))
N_("Failed to map 8192 bytes of memory for the PCNet device into the hyper memory"));
pThis->pSharedMMIOR0 = (uintptr_t)pThis->pSharedMMIOR3; /** @todo @bugref{1865}: Map MMIO2 into ring-0. */
if (RT_FAILURE(rc))
return rc;
}
#ifdef PCNET_NO_POLLING
/*
* Resolve the R0 and RC handlers.
*/
rc = PDMR3LdrGetSymbolR0Lazy(PDMDevHlpGetVM(pDevIns), NULL, NULL, "EMInterpretInstruction", &pThis->pfnEMInterpretInstructionR0);
if (RT_SUCCESS(rc))
rc = PDMR3LdrGetSymbolRCLazy(PDMDevHlpGetVM(pDevIns), NULL, NULL, "EMInterpretInstruction", (RTGCPTR *)&pThis->pfnEMInterpretInstructionRC);
#else
if (RT_FAILURE(rc))
return rc;
#endif
{
/* Software Interrupt timer */
rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, pcnetTimerSoftInt, pThis, /** @todo r=bird: the locking here looks bogus now with SMP... */
if (RT_FAILURE(rc))
return rc;
}
if (RT_FAILURE(rc))
return rc;
if (RT_FAILURE(rc))
return rc;
/*
* Create the transmit queue.
*/
if (RT_FAILURE(rc))
return rc;
/*
* Create the RX notifier signaller.
*/
if (RT_FAILURE(rc))
return rc;
/*
* Register the info item.
*/
/*
* Attach status driver (optional).
*/
if (RT_SUCCESS(rc))
else if ( rc != VERR_PDM_NO_ATTACHED_DRIVER
{
return rc;
}
/*
* Attach driver.
*/
if (RT_SUCCESS(rc))
{
if (rc == VINF_NAT_DNS)
{
#ifdef RT_OS_LINUX
N_("A Domain Name Server (DNS) for NAT networking could not be determined. Please check your /etc/resolv.conf for <tt>nameserver</tt> entries. Either add one manually (<i>man resolv.conf</i>) or ensure that your host is correctly connected to an ISP. If you ignore this warning the guest will not be able to perform nameserver lookups and it will probably observe delays if trying so"));
#else
N_("A Domain Name Server (DNS) for NAT networking could not be determined. Ensure that your host is correctly connected to an ISP. If you ignore this warning the guest will not be able to perform nameserver lookups and it will probably observe delays if trying so"));
#endif
}
pThis->pDrvR0 = PDMIBASER0_QUERY_INTERFACE(PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBASER0), PDMINETWORKUP);
pThis->pDrvRC = PDMIBASERC_QUERY_INTERFACE(PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIBASERC), PDMINETWORKUP);
}
else if ( rc == VERR_PDM_NO_ATTACHED_DRIVER
{
/* No error! */
Log(("No attached driver!\n"));
}
else
return rc;
/*
* Reset the device state. (Do after attaching.)
*/
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatReceiveBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Amount of data received", "/Public/Net/PCNet%u/BytesReceived", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Amount of data transmitted", "/Public/Net/PCNet%u/BytesTransmitted", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatReceiveBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Amount of data received", "/Devices/PCNet%d/ReceiveBytes", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitBytes, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_BYTES, "Amount of data transmitted", "/Devices/PCNet%d/TransmitBytes", iInstance);
#ifdef VBOX_WITH_STATISTICS
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMMIOReadRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling MMIO reads in RZ", "/Devices/PCNet%d/MMIO/ReadRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMMIOReadR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling MMIO reads in R3", "/Devices/PCNet%d/MMIO/ReadR3", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMMIOWriteRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling MMIO writes in RZ", "/Devices/PCNet%d/MMIO/WriteRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMMIOWriteR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling MMIO writes in R3", "/Devices/PCNet%d/MMIO/WriteR3", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatAPROMRead, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling APROM reads", "/Devices/PCNet%d/IO/APROMRead", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatAPROMWrite, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling APROM writes", "/Devices/PCNet%d/IO/APROMWrite", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatIOReadRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling IO reads in RZ", "/Devices/PCNet%d/IO/ReadRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatIOReadR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling IO reads in R3", "/Devices/PCNet%d/IO/ReadR3", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatIOWriteRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling IO writes in RZ", "/Devices/PCNet%d/IO/WriteRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatIOWriteR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling IO writes in R3", "/Devices/PCNet%d/IO/WriteR3", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTimer, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling Timer", "/Devices/PCNet%d/Timer", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatReceive, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling receive", "/Devices/PCNet%d/Receive", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRxOverflow, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_OCCURENCE, "Profiling RX overflows", "/Devices/PCNet%d/RxOverflow", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRxOverflowWakeup, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_OCCURENCE, "Nr of RX overflow wakeups", "/Devices/PCNet%d/RxOverflowWakeup", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitCase1, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Single descriptor transmit", "/Devices/PCNet%d/Transmit/Case1", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitCase2, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Multi descriptor transmit", "/Devices/PCNet%d/Transmit/Case2", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling transmits in RZ", "/Devices/PCNet%d/Transmit/TotalRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling transmits in R3", "/Devices/PCNet%d/Transmit/TotalR3", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitSendRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet send transmit in RZ","/Devices/PCNet%d/Transmit/SendRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTransmitSendR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet send transmit in R3","/Devices/PCNet%d/Transmit/SendR3", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTxLenCalcRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TX len calc in RZ", "/Devices/PCNet%d/Transmit/LenCalcRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTxLenCalcR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TX len calc in R3", "/Devices/PCNet%d/Transmit/LenCalcR3", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTdtePollRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TdtePoll in RZ", "/Devices/PCNet%d/TdtePollRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTdtePollR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TdtePoll in R3", "/Devices/PCNet%d/TdtePollR3", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRdtePollRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet RdtePoll in RZ", "/Devices/PCNet%d/RdtePollRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRdtePollR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet RdtePoll in R3", "/Devices/PCNet%d/RdtePollR3", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTmdStoreRZ, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TmdStore in RZ", "/Devices/PCNet%d/TmdStoreRZ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTmdStoreR3, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling PCNet TmdStore in R3", "/Devices/PCNet%d/TmdStoreR3", iInstance);
unsigned i;
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aStatXmitFlush[i], STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, "", "/Devices/PCNet%d/XmitFlushIrq/%d", iInstance, i + 1);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aStatXmitFlush[i], STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, "", "/Devices/PCNet%d/XmitFlushIrq/%d+", iInstance, i + 1);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aStatXmitChainCounts[i], STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, "", "/Devices/PCNet%d/XmitChainCounts/%d", iInstance, i + 1);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->aStatXmitChainCounts[i], STAMTYPE_COUNTER, STAMVISIBILITY_USED, STAMUNIT_OCCURENCES, "", "/Devices/PCNet%d/XmitChainCounts/%d+", iInstance, i + 1);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatXmitSkipCurrent, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "", "/Devices/PCNet%d/Xmit/Skipped", iInstance, i + 1);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatInterrupt, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling interrupt checks", "/Devices/PCNet%d/UpdateIRQ", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatPollTimer, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling poll timer", "/Devices/PCNet%d/PollTimer", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMIIReads, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of MII reads", "/Devices/PCNet%d/MIIReads", iInstance);
# ifdef PCNET_NO_POLLING
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRCVRingWrite, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of receive ring writes", "/Devices/PCNet%d/Ring/RCVWrites", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatTXRingWrite, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of transmit ring writes", "/Devices/PCNet%d/Ring/TXWrites", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRingWriteR3, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of monitored ring page writes", "/Devices/PCNet%d/Ring/R3/Writes", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRingWriteR0, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of monitored ring page writes", "/Devices/PCNet%d/Ring/R0/Writes", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRingWriteRC, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of monitored ring page writes", "/Devices/PCNet%d/Ring/RC/Writes", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRingWriteFailedR3, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of failed ring page writes", "/Devices/PCNet%d/Ring/R3/Failed", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRingWriteFailedR0, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of failed ring page writes", "/Devices/PCNet%d/Ring/R0/Failed", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRingWriteFailedRC, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of failed ring page writes", "/Devices/PCNet%d/Ring/RC/Failed", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRingWriteOutsideR3, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of monitored writes outside ring","/Devices/PCNet%d/Ring/R3/Outside", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRingWriteOutsideR0, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of monitored writes outside ring","/Devices/PCNet%d/Ring/R0/Outside", iInstance);
PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatRingWriteOutsideRC, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Nr of monitored writes outside ring","/Devices/PCNet%d/Ring/RC/Outside", iInstance);
# endif /* PCNET_NO_POLLING */
#endif /* VBOX_WITH_STATISTICS */
return VINF_SUCCESS;
}
/**
* The device registration structure.
*/
const PDMDEVREG g_DevicePCNet =
{
/* u32Version */
/* szName */
"pcnet",
/* szRCMod */
#ifdef PCNET_GC_ENABLED
"VBoxDDGC.gc",
"VBoxDDR0.r0",
#else
"",
"",
#endif
/* pszDescription */
"AMD PC-Net II Ethernet controller.\n",
/* fFlags */
#ifdef PCNET_GC_ENABLED
#else
#endif
/* fClass */
/* cMaxInstances */
~0U,
/* cbInstance */
sizeof(PCNETSTATE),
/* pfnConstruct */
/* pfnDestruct */
/* pfnRelocate */
/* pfnMemSetup */
NULL,
/* pfnPowerOn */
NULL,
/* pfnReset */
/* pfnSuspend */
/* pfnResume */
NULL,
/* pfnAttach */
/* pfnDetach */
/* pfnQueryInterface. */
NULL,
/* pfnInitComplete. */
NULL,
/* pfnPowerOff. */
/* pfnSoftReset */
NULL,
/* u32VersionEnd */
};
#endif /* IN_RING3 */
#endif /* !VBOX_DEVICE_STRUCT_TESTCASE */