30#ifndef PARANDIS_56_COMMON_H
31#define PARANDIS_56_COMMON_H
35#if defined(OFFLOAD_UNIT_TEST)
39#define ETH_LENGTH_OF_ADDRESS 6
40#define DoPrint(fmt, ...) printf(fmt##"\n", __VA_ARGS__)
41#define DPrintf(a,b) DoPrint b
42#define RtlOffsetToPointer(B,O) ((PCHAR)( ((PCHAR)(B)) + ((ULONG_PTR)(O)) ))
47#if !defined(OFFLOAD_UNIT_TEST)
49#if !defined(RtlOffsetToPointer)
50#define RtlOffsetToPointer(Base,Offset) ((PCHAR)(((PCHAR)(Base))+((ULONG_PTR)(Offset))))
53#if !defined(RtlPointerToOffset)
54#define RtlPointerToOffset(Base,Pointer) ((ULONG)(((PCHAR)(Pointer))-((PCHAR)(Base))))
75#if !defined(NDIS_MINIPORT_MAJOR_VERSION) || !defined(NDIS_MINIPORT_MINOR_VERSION)
76#error "Something is wrong with NDIS environment"
90#define MAX_RX_LOOPS 1000
93#define MAX_NUM_OF_QUEUES 3
96#define VIRTIO_NET_F_CSUM 0
97#define VIRTIO_NET_F_GUEST_CSUM 1
98#define VIRTIO_NET_F_MAC 5
99#define VIRTIO_NET_F_GSO 6
100#define VIRTIO_NET_F_GUEST_TSO4 7
101#define VIRTIO_NET_F_GUEST_TSO6 8
102#define VIRTIO_NET_F_GUEST_ECN 9
103#define VIRTIO_NET_F_GUEST_UFO 10
104#define VIRTIO_NET_F_HOST_TSO4 11
105#define VIRTIO_NET_F_HOST_TSO6 12
106#define VIRTIO_NET_F_HOST_ECN 13
107#define VIRTIO_NET_F_HOST_UFO 14
108#define VIRTIO_NET_F_MRG_RXBUF 15
109#define VIRTIO_NET_F_STATUS 16
110#define VIRTIO_NET_F_CTRL_VQ 17
111#define VIRTIO_NET_F_CTRL_RX 18
112#define VIRTIO_NET_F_CTRL_VLAN 19
113#define VIRTIO_NET_F_CTRL_RX_EXTRA 20
115#define VIRTIO_NET_S_LINK_UP 1
117#define VIRTIO_NET_INVALID_INTERRUPT_STATUS 0xFF
119#define PARANDIS_MULTICAST_LIST_SIZE 32
120#define PARANDIS_MEMORY_TAG '5muQ'
121#define PARANDIS_FORMAL_LINK_SPEED (pContext->ulFormalLinkSpeed)
122#define PARANDIS_MAXIMUM_TRANSMIT_SPEED PARANDIS_FORMAL_LINK_SPEED
123#define PARANDIS_MAXIMUM_RECEIVE_SPEED PARANDIS_FORMAL_LINK_SPEED
124#define PARANDIS_MIN_LSO_SEGMENTS 2
126#define PARANDIS_MAX_LSO_SIZE 0xF800
128#define PARANDIS_UNLIMITED_PACKETS_TO_INDICATE (~0ul)
360#ifdef PARANDIS_DEBUG_INTERRUPTS
410#if !defined(UNIFY_LOCKS)
530#ifndef LAZY_TX_RELEASE
539 return pContext->
VlanId == 0 || pContext->
VlanId == VlanID;
572 ULONG ulMaxPacketsToIndicate);
583 ULONG interruptSource);
587 ULONG interruptSource);
619 ULONG knownInterruptSources);
645#if !defined(ENABLE_HISTORY_LOG)
707 ULONG ulRequiredSize);
enum _etagHistoryLogOperation eHistoryLogOperation
static BOOLEAN virtqueue_is_interrupt_enabled(struct virtqueue *vq)
#define DPrintf(Level, Fmt)
#define ETH_LENGTH_OF_ADDRESS
void ParaNdis_PadPacketReceived(PVOID pDataBuffer, PULONG pLength)
NDIS_STATUS ParaNdis_FinishInitialization(PARANDIS_ADAPTER *pContext)
struct _tagCompletePhysicalAddress tCompletePhysicalAddress
@ osbT4RxTCPOptionsChecksum
@ osbT4TcpOptionsChecksum
@ osbT4RxIPOptionsChecksum
@ osbT6TcpOptionsChecksum
@ osbT6RxTCPOptionsChecksum
struct _tagMulticastData tMulticastData
struct _tagIONetDescriptor IONetDescriptor
tTcpIpPacketParsingResult ParaNdis_CheckSumVerify(PVOID buffer, ULONG size, ULONG flags, LPCSTR caller)
struct _tagCopyPacketResult tCopyPacketResult
UINT ParaNdis_VirtIONetReleaseTransmitBuffers(PARANDIS_ADAPTER *pContext)
struct _tagNdisStatistics NDIS_STATISTICS_INFO
BOOLEAN ParaNdis_CheckForHang(PARANDIS_ADAPTER *pContext)
VOID ParaNdis_FreePhysicalMemory(PARANDIS_ADAPTER *pContext, tCompletePhysicalAddress *pAddresses)
tTcpIpPacketParsingResult ParaNdis_ReviewIPPacket(PVOID buffer, ULONG size, LPCSTR caller)
void ParaNdis_DebugCleanup(PDRIVER_OBJECT pDriverObject)
static void VirtIODeviceEnableGuestFeature(PARANDIS_ADAPTER *pContext, unsigned uFeature)
NDIS_HANDLE ParaNdis_OpenNICConfiguration(PARANDIS_ADAPTER *pContext)
NDIS_STATUS ParaNdis_PowerOn(PARANDIS_ADAPTER *pContext)
VOID ParaNdis_VirtIOEnableIrqSynchronized(PARANDIS_ADAPTER *pContext, ULONG interruptSource)
VOID ParaNdis_PacketMapper(PARANDIS_ADAPTER *pContext, tPacketType packet, PVOID Reference, struct VirtIOBufferDescriptor *buffers, pIONetDescriptor pDesc, tMapperResult *pMapperResult)
tCopyPacketResult ParaNdis_PacketCopier(tPacketType packet, PVOID dest, ULONG maxSize, PVOID refValue, BOOLEAN bPreview)
PNDIS_PACKET tPacketHolderType
VOID ParaNdis_OnTransmitBufferReleased(PARANDIS_ADAPTER *pContext, IONetDescriptor *pDesc)
VOID(* tOnAdditionalPhysicalMemoryAllocated)(PARANDIS_ADAPTER *pContext, tCompletePhysicalAddress *pAddresses)
tChecksumCheckResult ParaNdis_CheckRxChecksum(PARANDIS_ADAPTER *pContext, ULONG virtioFlags, PVOID pRxPacket, ULONG len)
struct _tagPARANDIS_ADAPTER * PPARANDIS_ADAPTER
PVOID ParaNdis_AllocateMemory(PARANDIS_ADAPTER *pContext, ULONG ulRequiredSize)
VOID ParaNdis_CleanupContext(PARANDIS_ADAPTER *pContext)
BOOLEAN ParaNdis_SetTimer(NDIS_HANDLE timer, LONG millies)
struct _tagTxOperationParameters tTxOperationParameters
void(* tReuseReceiveBufferProc)(void *pContext, pIONetDescriptor pDescriptor)
VOID ParaNdis_Resume(PARANDIS_ADAPTER *pContext)
VOID ParaNdis_OnPnPEvent(PARANDIS_ADAPTER *pContext, NDIS_DEVICE_PNP_EVENT pEvent, PVOID pInfo, ULONG ulSize)
tCopyPacketResult ParaNdis_DoCopyPacketData(PARANDIS_ADAPTER *pContext, tTxOperationParameters *pParams)
VOID ParaNdis_IndicateReceivedBatch(PARANDIS_ADAPTER *pContext, tPacketIndicationType *pBatch, ULONG nofPackets)
union _tagTcpIpPacketParsingResult tTcpIpPacketParsingResult
BOOLEAN ParaNdis_InitialAllocatePhysicalMemory(PARANDIS_ADAPTER *pContext, tCompletePhysicalAddress *pAddresses)
void ParaNdis_ResetOffloadSettings(PARANDIS_ADAPTER *pContext, tOffloadSettingsFlags *pDest, PULONG from)
VOID ParaNdis_SetPowerState(PARANDIS_ADAPTER *pContext, NDIS_DEVICE_POWER_STATE newState)
tPacketIndicationType ParaNdis_IndicateReceivedPacket(PARANDIS_ADAPTER *pContext, PVOID dataBuffer, PULONG pLength, BOOLEAN bPrepareOnly, pIONetDescriptor pBufferDesc)
static BOOLEAN FORCEINLINE IsPrioritySupported(PARANDIS_ADAPTER *pContext)
static BOOLEAN FORCEINLINE IsVlanSupported(PARANDIS_ADAPTER *pContext)
#define PARANDIS_MULTICAST_LIST_SIZE
void ParaNdis_DebugInitialize(PVOID DriverObject, PVOID RegistryPath)
struct _tagOurCounters tOurCounters
static __inline struct virtqueue * ParaNdis_GetQueueForInterrupt(PARANDIS_ADAPTER *pContext, ULONG interruptSource)
VOID ParaNdis_UpdateDeviceFilters(PARANDIS_ADAPTER *pContext)
enum _tagOffloadSettingsBit tOffloadSettingsBit
struct _tagMapperResult tMapperResult
struct _tagOffloadSettingsFlags tOffloadSettingsFlags
VOID ParaNdis_PowerOff(PARANDIS_ADAPTER *pContext)
void ParaNdis_DebugRegisterMiniport(PARANDIS_ADAPTER *pContext, BOOLEAN bRegister)
void ParaNdis_IndicateConnect(PARANDIS_ADAPTER *pContext, BOOLEAN bConnected, BOOLEAN bForce)
static BOOLEAN FORCEINLINE IsTimeToReleaseTx(PARANDIS_ADAPTER *pContext)
struct _tagNdisOffloadParams NDIS_OFFLOAD_PARAMETERS
BOOLEAN ParaNdis_ValidateMacAddress(PUCHAR pcMacAddress, BOOLEAN bLocal)
VOID ParaNdis_ReportLinkStatus(PARANDIS_ADAPTER *pContext, BOOLEAN bForce)
BOOLEAN ParaNdis_SynchronizeWithInterrupt(PARANDIS_ADAPTER *pContext, ULONG messageId, tSynchronizedProcedure procedure, PVOID parameter)
struct _tagMaxPacketSize tMaxPacketSize
VirtIOSystemOps ParaNdisSystemOps
enum _tagppResult ppResult
struct _tagPARANDIS_ADAPTER PARANDIS_ADAPTER
struct _tagSynchronizedContext tSynchronizedContext
VOID ParaNdis_FinalizeCleanup(PARANDIS_ADAPTER *pContext)
NDIS_STATUS NTAPI ParaNdis_FinishSpecificInitialization(PARANDIS_ADAPTER *pContext)
BOOLEAN ParaNdis_OnQueuedInterrupt(PARANDIS_ADAPTER *pContext, BOOLEAN *pRunDpc, ULONG knownInterruptSources)
VOID ParaNdis_DeviceFiltersUpdateVlanId(PARANDIS_ADAPTER *pContext)
enum _tagSendReceiveState tSendReceiveState
struct _tagIONetDescriptor * pIONetDescriptor
void ParaNdis_RestoreDeviceConfigurationAfterReset(PARANDIS_ADAPTER *pContext)
VOID ParaNdis_VirtIODisableIrqSynchronized(PARANDIS_ADAPTER *pContext, ULONG interruptSource)
ULONG ParaNdis_DPCWorkBody(PARANDIS_ADAPTER *pContext, ULONG ulMaxPacketsToIndicate)
VOID(* ONPAUSECOMPLETEPROC)(VOID *)
static const ULONG PARANDIS_PACKET_FILTERS
VOID ParaNdis_OnShutdown(PARANDIS_ADAPTER *pContext)
struct _tagPhysicalAddressAllocationContext tPhysicalAddressAllocationContext
enum _tagInterruptSource tInterruptSource
void ParaNdis_CallOnBugCheck(PARANDIS_ADAPTER *pContext)
enum _tagPacketOffloadRequest tPacketOffloadRequest
struct _tagBusResource tBusResource
void ParaNdis_UnbindBufferFromPacket(PARANDIS_ADAPTER *pContext, pIONetDescriptor pBufferDesc)
NDIS_STATUS ParaNdis_SetMulticastList(PARANDIS_ADAPTER *pContext, PVOID Buffer, ULONG BufferSize, PUINT pBytesRead, PUINT pBytesNeeded)
struct _tagAdapterResources tAdapterResources
VOID ParaNdis_Suspend(PARANDIS_ADAPTER *pContext)
BOOLEAN ParaNdis_OnLegacyInterrupt(PARANDIS_ADAPTER *pContext, BOOLEAN *pRunDpc)
PNDIS_PACKET tPacketIndicationType
struct _tagOffloadSettings tOffloadSettings
struct _tagChecksumCheckResult tChecksumCheckResult
static __inline BOOLEAN ParaNDIS_IsQueueInterruptEnabled(struct virtqueue *_vq)
BOOLEAN ParaNdis_BindBufferToPacket(PARANDIS_ADAPTER *pContext, pIONetDescriptor pBufferDesc)
NDIS_STATUS ParaNdis_InitializeContext(PARANDIS_ADAPTER *pContext, PNDIS_RESOURCE_LIST ResourceList)
static bool VirtIODeviceGetHostFeature(PARANDIS_ADAPTER *pContext, unsigned uFeature)
static void FORCEINLINE ParaNdis_DebugHistory(PARANDIS_ADAPTER *pContext, eHistoryLogOperation op, PVOID pParam1, ULONG lParam2, ULONG lParam3, ULONG lParam4)
tCopyPacketResult ParaNdis_DoSubmitPacket(PARANDIS_ADAPTER *pContext, tTxOperationParameters *Params)
#define MAX_NUM_OF_QUEUES
static BOOLEAN FORCEINLINE IsValidVlanId(PARANDIS_ADAPTER *pContext, ULONG VlanID)
BOOLEAN(NTAPI * tSynchronizedProcedure)(tSynchronizedContext *context)
BOOLEAN ParaNdis_ProcessTx(PARANDIS_ADAPTER *pContext, BOOLEAN IsDpc, BOOLEAN IsInterrupt)
enum _NDIS_DEVICE_PNP_EVENT NDIS_DEVICE_PNP_EVENT
#define NDIS_PACKET_TYPE_PROMISCUOUS
#define NDIS_PACKET_TYPE_BROADCAST
#define NDIS_PACKET_TYPE_MULTICAST
#define NDIS_PACKET_TYPE_DIRECTED
#define NDIS_PACKET_TYPE_ALL_MULTICAST
enum _NDIS_DEVICE_POWER_STATE NDIS_DEVICE_POWER_STATE
tBusResource PciBars[PCI_TYPE0_ADDRESSES]
NDIS_PHYSICAL_ADDRESS BasePA
struct _tagChecksumCheckResult::@1001::@1003 flags
PHYSICAL_ADDRESS Physical
tCompletePhysicalAddress HeaderInfo
tPacketHolderType pHolder
tCompletePhysicalAddress DataInfo
ULONG nofMulticastEntries
UCHAR MulticastList[ETH_LENGTH_OF_ADDRESS *PARANDIS_MULTICAST_LIST_SIZE]
ULONG64 ifHCOutMulticastPkts
ULONG64 ifHCInBroadcastPkts
ULONG64 ifHCOutMulticastOctets
ULONG64 ifHCOutBroadcastOctets
ULONG64 ifHCInMulticastOctets
ULONG64 ifHCInMulticastPkts
ULONG64 ifHCInUcastOctets
ULONG64 ifHCOutUcastOctets
ULONG64 ifHCOutBroadcastPkts
ULONG64 ifHCInBroadcastOctets
tOffloadSettingsFlags flags
NDIS_OFFLOAD_PARAMETERS InitialOffloadParameters
NDIS_DEVICE_POWER_STATE powerState
tAdapterResources AdapterResources
NDIS_MINIPORT_INTERRUPT Interrupt
UINT maxFreeHardwareBuffers
LONG NetTxPacketsToReturn
BOOLEAN bDoKickOnNoBuffer
ULONGLONG ullHostFeatures
ULONGLONG ulFormalLinkSpeed
NDIS_HANDLE MiniportHandle
UINT nofFreeHardwareBuffers
BOOLEAN bHasHardwareFilters
BOOLEAN bNoPauseOnSuspend
UINT uNumberOfHandledRXPacketsInDPC
BOOLEAN bFastSuspendInProcess
NDIS_SPIN_LOCK ReceiveLock
ONPAUSECOMPLETEPROC ReceivePauseCompletionProc
tMulticastData MulticastData
NDIS_STATISTICS_INFO Statistics
UINT minFreeHardwareBuffers
ULONG framesRxCSHwMissedGood
BOOLEAN bIODeviceInitialized
BOOLEAN bDoInterruptRecovery
BOOLEAN bDoGuestChecksumOnReceive
tSendReceiveState SendState
ULONG ulCurrentVlansFilterSet
BOOLEAN bUseScatterGather
BOOLEAN bUseMergedBuffers
struct virtqueue * NetSendQueue
NDIS_HANDLE WrapperConfigurationHandle
NDIS_DEVICE_PNP_EVENT PnpEvents[16]
UINT nofFreeTxDescriptors
struct VirtIOBufferDescriptor * sgTxGatherTable
LARGE_INTEGER LastInterruptTimeStamp
BOOLEAN bDoHwPacketFiltering
BOOLEAN bDoSupportPriority
ULONGLONG ullGuestFeatures
ONPAUSECOMPLETEPROC SendPauseCompletionProc
LIST_ENTRY NetSendBuffersInUse
tReuseReceiveBufferProc ReuseBufferProc
NDIS_TIMER DPCPostProcessTimer
tSendReceiveState ReceiveState
UINT NetMaxReceiveBuffers
BOOLEAN bEnableInterruptChecking
BOOLEAN bDoHardwareChecksum
ULONG ulPriorityVlanSetting
BOOLEAN bEnableInterruptHandlingDPC
UINT NetNofReceiveBuffers
tBusResource SharedMemoryRanges[MAX_NUM_OF_QUEUES]
ULONG nDetectedInactivity
UCHAR CurrentMacAddress[ETH_LENGTH_OF_ADDRESS]
struct _tagPARANDIS_ADAPTER::@1004 extraStatistics
UCHAR PermanentMacAddress[ETH_LENGTH_OF_ADDRESS]
LIST_ENTRY NetFreeSendBuffers
BOOLEAN bLinkDetectSupported
tCompletePhysicalAddress ControlData
LIST_ENTRY NetReceiveBuffers
tMaxPacketSize MaxPacketSize
struct virtqueue * NetControlQueue
ULONG framesRxCSHwMissedBad
UINT maxFreeTxDescriptors
LARGE_INTEGER LastTxCompletionTimeStamp
struct virtqueue * NetReceiveQueue
LIST_ENTRY NetReceiveBuffersWaiting
tOnAdditionalPhysicalMemoryAllocated Callback
tCompletePhysicalAddress address
PARANDIS_ADAPTER * pContext
PARANDIS_ADAPTER * pContext
#define VIRTIO_PCI_ISR_CONFIG
#define virtio_is_feature_enabled(FeaturesList, Feature)
#define virtio_feature_enable(FeaturesList, Feature)
_Must_inspect_result_ _In_ PDRIVER_OBJECT _In_ PCUNICODE_STRING RegistryPath
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
_Must_inspect_result_ _In_ WDFIORESREQLIST _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFIORESLIST * ResourceList
#define PCI_TYPE0_ADDRESSES