ReactOS 0.4.15-dev-5666-gc548b97
init.c File Reference
#include "nvnet.h"
#include "debug.h"
Include dependency graph for init.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static VOID QueryInteger (_In_ NDIS_HANDLE ConfigurationHandle, _In_ PCWSTR EntryName, _Out_ PULONG EntryContext, _In_ ULONG DefaultValue, _In_ ULONG Minimum, _In_ ULONG Maximum)
 
static NDIS_STATUS NvNetReadConfiguration (_Inout_ PNVNET_ADAPTER Adapter)
 
static NDIS_STATUS NvNetInitializeAdapterResources (_Inout_ PNVNET_ADAPTER Adapter)
 
static NDIS_STATUS AllocateTransmitBuffers (_In_ PNVNET_ADAPTER Adapter)
 
static NDIS_STATUS AllocateTransmitBlocks (_In_ PNVNET_ADAPTER Adapter)
 
static NDIS_STATUS AllocateTransmitDescriptors (_In_ PNVNET_ADAPTER Adapter)
 
static NDIS_STATUS AllocateReceiveDescriptors (_In_ PNVNET_ADAPTER Adapter)
 
static NDIS_STATUS AllocateReceiveBuffers (_In_ PNVNET_ADAPTER Adapter)
 
static NDIS_STATUS AllocateAdapterMemory (_In_ PNVNET_ADAPTER Adapter)
 
VOID NvNetInitTransmitMemory (_In_ PNVNET_ADAPTER Adapter)
 
static VOID NvNetInitReceiveMemory (_In_ PNVNET_ADAPTER Adapter)
 
VOID NvNetFreeAdapter (_In_ PNVNET_ADAPTER Adapter)
 
NDIS_STATUS NTAPI MiniportInitialize (_Out_ PNDIS_STATUS OpenErrorStatus, _Out_ PUINT SelectedMediumIndex, _In_ PNDIS_MEDIUM MediumArray, _In_ UINT MediumArraySize, _In_ NDIS_HANDLE MiniportAdapterHandle, _In_ NDIS_HANDLE WrapperConfigurationContext)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 12 of file init.c.

Function Documentation

◆ AllocateAdapterMemory()

static NDIS_STATUS AllocateAdapterMemory ( _In_ PNVNET_ADAPTER  Adapter)
static

Definition at line 496 of file init.c.

498{
500
501 PAGED_CODE();
502
505 return Status;
506
509 return Status;
510
513 return Status;
514
517 return Status;
518
521 return Status;
522
523 NdisAllocateSpinLock(&Adapter->Send.Lock);
524 NdisAllocateSpinLock(&Adapter->Receive.Lock);
525 NdisAllocateSpinLock(&Adapter->Lock);
526
527 return NDIS_STATUS_SUCCESS;
528}
#define PAGED_CODE()
static NDIS_STATUS AllocateReceiveBuffers(_In_ PNVNET_ADAPTER Adapter)
Definition: init.c:475
static NDIS_STATUS AllocateReceiveDescriptors(_In_ PNVNET_ADAPTER Adapter)
Definition: init.c:443
static NDIS_STATUS AllocateTransmitDescriptors(_In_ PNVNET_ADAPTER Adapter)
Definition: init.c:398
static NDIS_STATUS AllocateTransmitBuffers(_In_ PNVNET_ADAPTER Adapter)
Definition: init.c:315
static NDIS_STATUS AllocateTransmitBlocks(_In_ PNVNET_ADAPTER Adapter)
Definition: init.c:371
Status
Definition: gdiplustypes.h:25
#define NdisAllocateSpinLock(_SpinLock)
Definition: ndis.h:4088
#define NDIS_STATUS_SUCCESS
Definition: ndis.h:346
int NDIS_STATUS
Definition: ntddndis.h:475

Referenced by MiniportInitialize().

◆ AllocateReceiveBuffers()

static NDIS_STATUS AllocateReceiveBuffers ( _In_ PNVNET_ADAPTER  Adapter)
static

Definition at line 475 of file init.c.

477{
478 PAGED_CODE();
479
480 NdisMAllocateSharedMemory(Adapter->AdapterHandle,
482 TRUE, /* Cached */
483 (PVOID*)&Adapter->ReceiveBuffer,
484 &Adapter->ReceiveBufferPhys);
485 if (!Adapter->ReceiveBuffer)
486 {
488 }
489
490 return NDIS_STATUS_SUCCESS;
491}
#define TRUE
Definition: types.h:120
VOID EXPORT NdisMAllocateSharedMemory(IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, IN BOOLEAN Cached, OUT PVOID *VirtualAddress, OUT PNDIS_PHYSICAL_ADDRESS PhysicalAddress)
Definition: memory.c:148
#define NDIS_STATUS_RESOURCES
Definition: ndis.h:466
#define NVNET_RECEIVE_DESCRIPTORS
Definition: nvnet.h:34
#define NVNET_RECEIVE_BUFFER_SIZE
Definition: nvnet.h:39

Referenced by AllocateAdapterMemory().

◆ AllocateReceiveDescriptors()

static NDIS_STATUS AllocateReceiveDescriptors ( _In_ PNVNET_ADAPTER  Adapter)
static

Definition at line 443 of file init.c.

445{
446 ULONG Size;
447
448 PAGED_CODE();
449
450 if (Adapter->Features & DEV_HAS_HIGH_DMA)
451 {
452 Size = sizeof(NVNET_DESCRIPTOR_64);
453 }
454 else
455 {
456 Size = sizeof(NVNET_DESCRIPTOR_32);
457 }
458 NdisMAllocateSharedMemory(Adapter->AdapterHandle,
460 TRUE, /* Cached */
461 &Adapter->RbdOriginal,
462 &Adapter->RbdPhysOriginal);
463 if (!Adapter->RbdOriginal)
465
466 Adapter->Receive.NvRbd.Memory = ALIGN_UP_POINTER_BY(Adapter->RbdOriginal, NVNET_ALIGNMENT);
467 Adapter->RbdPhys.QuadPart = ALIGN_UP_BY(Adapter->RbdPhysOriginal.QuadPart, NVNET_ALIGNMENT);
468
469 return NDIS_STATUS_SUCCESS;
470}
#define ALIGN_UP_BY(size, align)
unsigned int ULONG
Definition: retypes.h:1
#define DEV_HAS_HIGH_DMA
Definition: nic.h:21
struct _NVNET_DESCRIPTOR_32 NVNET_DESCRIPTOR_32
struct _NVNET_DESCRIPTOR_64 NVNET_DESCRIPTOR_64
#define NVNET_ALIGNMENT
Definition: nvnet.h:37
#define ALIGN_UP_POINTER_BY(ptr, align)
Definition: umtypes.h:85
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533

Referenced by AllocateAdapterMemory().

◆ AllocateTransmitBlocks()

static NDIS_STATUS AllocateTransmitBlocks ( _In_ PNVNET_ADAPTER  Adapter)
static

Definition at line 371 of file init.c.

373{
374 PNVNET_TCB Tcb;
376
377 PAGED_CODE();
378
381 NVNET_TAG);
383 return Status;
384
386
387 Adapter->Send.TailTcb = Tcb + (NVNET_TRANSMIT_BLOCKS - 1);
388 Adapter->Send.HeadTcb = Tcb;
389 Adapter->Send.CurrentTcb = Tcb;
390 Adapter->Send.LastTcb = Tcb;
391
392 return NDIS_STATUS_SUCCESS;
393}
NDIS_STATUS EXPORT NdisAllocateMemoryWithTag(OUT PVOID *VirtualAddress, IN UINT Length, IN ULONG Tag)
Definition: memory.c:21
#define NdisZeroMemory(Destination, Length)
Definition: ndis.h:3926
#define NVNET_TRANSMIT_BLOCKS
Definition: nvnet.h:31
#define NVNET_TAG
Definition: nvnet.h:22

Referenced by AllocateAdapterMemory().

◆ AllocateTransmitBuffers()

static NDIS_STATUS AllocateTransmitBuffers ( _In_ PNVNET_ADAPTER  Adapter)
static

Definition at line 315 of file init.c.

317{
318 ULONG i;
319 BOOLEAN HasBuffer = FALSE;
320 PNVNET_TX_BUFFER CoalesceBuffer;
322
323 PAGED_CODE();
324
325 Status = NdisAllocateMemoryWithTag((PVOID*)&CoalesceBuffer,
327 NVNET_TAG);
329 return Status;
330
331 NdisZeroMemory(CoalesceBuffer, NVNET_TRANSMIT_BUFFERS * sizeof(NVNET_TX_BUFFER));
332
333 Adapter->SendBuffer = CoalesceBuffer;
334
335 for (i = 0; i < NVNET_TRANSMIT_BUFFERS; ++i)
336 {
339
340 NdisMAllocateSharedMemory(Adapter->AdapterHandle,
341 Adapter->MaximumFrameSize + NVNET_ALIGNMENT,
342 TRUE, /* Cached */
345 if (!VirtualAddress)
346 continue;
347
348 CoalesceBuffer->VirtualAddress = ALIGN_UP_POINTER_BY(VirtualAddress, NVNET_ALIGNMENT);
349 CoalesceBuffer->PhysicalAddress.QuadPart =
351
352 Adapter->SendBufferAllocationData[i].PhysicalAddress.QuadPart = PhysicalAddress.QuadPart;
353 Adapter->SendBufferAllocationData[i].VirtualAddress = VirtualAddress;
354
355 PushEntryList(&Adapter->Send.BufferList, &CoalesceBuffer->Link);
356 ++CoalesceBuffer;
357
358 HasBuffer = TRUE;
359 }
360 if (!HasBuffer)
361 {
363 }
364
365 return NDIS_STATUS_SUCCESS;
366}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NVNET_TRANSMIT_BUFFERS
Definition: nvnet.h:33
LONGLONG QuadPart
Definition: typedefs.h:114
_Must_inspect_result_ _In_ WDFDMATRANSACTION _In_ PFN_WDF_PROGRAM_DMA _In_ WDF_DMA_DIRECTION _In_ PMDL _In_ PVOID VirtualAddress
_Must_inspect_result_ typedef _In_ PHYSICAL_ADDRESS PhysicalAddress
Definition: iotypes.h:1098
FORCEINLINE VOID PushEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry)
Definition: rtlfuncs.h:253

Referenced by AllocateAdapterMemory().

◆ AllocateTransmitDescriptors()

static NDIS_STATUS AllocateTransmitDescriptors ( _In_ PNVNET_ADAPTER  Adapter)
static

Definition at line 398 of file init.c.

400{
401 NVNET_TBD Tbd;
402 ULONG Size;
403
404 PAGED_CODE();
405
406 if (Adapter->Features & DEV_HAS_HIGH_DMA)
407 {
408 Size = sizeof(NVNET_DESCRIPTOR_64);
409 }
410 else
411 {
412 Size = sizeof(NVNET_DESCRIPTOR_32);
413 }
414 NdisMAllocateSharedMemory(Adapter->AdapterHandle,
416 TRUE, /* Cached */
417 &Adapter->TbdOriginal,
418 &Adapter->TbdPhysOriginal);
419 if (!Adapter->TbdOriginal)
421
422 Tbd.Memory = ALIGN_UP_POINTER_BY(Adapter->TbdOriginal, NVNET_ALIGNMENT);
423 Adapter->TbdPhys.QuadPart = ALIGN_UP_BY(Adapter->TbdPhysOriginal.QuadPart, NVNET_ALIGNMENT);
424
425 Adapter->Send.HeadTbd = Tbd;
426 Adapter->Send.CurrentTbd = Tbd;
427
428 if (Adapter->Features & DEV_HAS_HIGH_DMA)
429 {
430 Adapter->Send.TailTbd.x64 = Tbd.x64 + (NVNET_TRANSMIT_DESCRIPTORS - 1);
431 }
432 else
433 {
434 Adapter->Send.TailTbd.x32 = Tbd.x32 + (NVNET_TRANSMIT_DESCRIPTORS - 1);
435 }
436
437 return NDIS_STATUS_SUCCESS;
438}
#define NVNET_TRANSMIT_DESCRIPTORS
Definition: nvnet.h:32
PVOID Memory
Definition: nvnet.h:201
PNVNET_DESCRIPTOR_32 x32
Definition: nvnet.h:199
PNVNET_DESCRIPTOR_64 x64
Definition: nvnet.h:200

Referenced by AllocateAdapterMemory().

◆ MiniportInitialize()

NDIS_STATUS NTAPI MiniportInitialize ( _Out_ PNDIS_STATUS  OpenErrorStatus,
_Out_ PUINT  SelectedMediumIndex,
_In_ PNDIS_MEDIUM  MediumArray,
_In_ UINT  MediumArraySize,
_In_ NDIS_HANDLE  MiniportAdapterHandle,
_In_ NDIS_HANDLE  WrapperConfigurationContext 
)

Definition at line 700 of file init.c.

707{
708 UINT i;
709 ULONG Size;
710 PVOID UnalignedAdapter;
711 PNVNET_ADAPTER Adapter;
713
714 PAGED_CODE();
715
716 NDIS_DbgPrint(MIN_TRACE, ("()\n"));
717
718 for (i = 0; i < MediumArraySize; ++i)
719 {
720 if (MediumArray[i] == NdisMedium802_3)
721 {
723 break;
724 }
725 }
726 if (i == MediumArraySize)
727 {
728 NDIS_DbgPrint(MAX_TRACE, ("No supported media\n"));
730 }
731
733
734 Status = NdisAllocateMemoryWithTag((PVOID*)&UnalignedAdapter,
735 Size,
736 NVNET_TAG);
738 {
739 NDIS_DbgPrint(MAX_TRACE, ("Failed to allocate adapter\n"));
741 }
742
743 NdisZeroMemory(UnalignedAdapter, Size);
744 Adapter = ALIGN_UP_POINTER_BY(UnalignedAdapter, NdisGetSharedDataAlignment());
745 Adapter->AdapterOriginal = UnalignedAdapter;
748
751 {
752 goto Failure;
753 }
754
756 Adapter,
757 0,
759 // NDIS_ATTRIBUTE_DESERIALIZE | TODO
762
765 {
767 {
769 }
771 {
773 }
774
775 goto Failure;
776 }
777
780 {
781 goto Failure;
782 }
783
785 !!(Adapter->Features & DEV_HAS_HIGH_DMA),
787 // ^TODO: NVNET_MAX_DMA_TRANSFER);
789 {
791 goto Failure;
792 }
793
794 Status = AllocateAdapterMemory(Adapter);
796 {
797 NDIS_DbgPrint(MAX_TRACE, ("Failed to allocate adapter memory\n"));
798
800 goto Failure;
801 }
802
804 NvNetInitReceiveMemory(Adapter);
805
806 if (Adapter->Features & DEV_HAS_HIGH_DMA)
807 {
810 }
811 else
812 {
814
815 if (Adapter->Features & DEV_HAS_LARGEDESC)
816 {
818 }
819 else
820 {
822 }
823 }
824
827 {
829 goto Failure;
830 }
831
832 if (!(Adapter->Flags & NV_USE_SOFT_MAC_ADDRESS))
833 {
835 Adapter->PermanentMacAddress);
836 }
837
838 NvNetSetupMacAddress(Adapter, Adapter->CurrentMacAddress);
839
840 Status = NvNetInitNIC(Adapter, TRUE);
842 {
843 NDIS_DbgPrint(MAX_TRACE, ("Failed to initialize the NIC\n"));
844
846 goto Failure;
847 }
848
849 NvNetDisableInterrupts(Adapter);
852
853/* FIXME: Bug in the PIC HAL? */
854#if defined(SARCH_XBOX)
856 Adapter->AdapterHandle,
857 Adapter->InterruptVector,
858 Adapter->InterruptLevel,
859 TRUE, /* Request ISR calls */
860 FALSE,
862#else
864 Adapter->AdapterHandle,
865 Adapter->InterruptVector,
866 Adapter->InterruptLevel,
867 TRUE, /* Request ISR calls */
868 TRUE, /* Shared */
870#endif
872 {
874 goto Failure;
875 }
876
877 NvNetStartAdapter(Adapter);
878
879 return NDIS_STATUS_SUCCESS;
880
881Failure:
882 NvNetFreeAdapter(Adapter);
883
884 return Status;
885}
#define MIN_TRACE
Definition: debug.h:14
#define MAX_TRACE
Definition: debug.h:16
#define NDIS_DbgPrint(_t_, _x_)
Definition: debug.h:40
static NDIS_STATUS AllocateAdapterMemory(_In_ PNVNET_ADAPTER Adapter)
Definition: init.c:496
VOID NvNetFreeAdapter(_In_ PNVNET_ADAPTER Adapter)
Definition: init.c:595
static VOID NvNetInitReceiveMemory(_In_ PNVNET_ADAPTER Adapter)
Definition: init.c:555
VOID NvNetInitTransmitMemory(_In_ PNVNET_ADAPTER Adapter)
Definition: init.c:532
static NDIS_STATUS NvNetInitializeAdapterResources(_Inout_ PNVNET_ADAPTER Adapter)
Definition: init.c:215
static NDIS_STATUS NvNetReadConfiguration(_Inout_ PNVNET_ADAPTER Adapter)
Definition: init.c:67
NDIS_STATUS EXPORT NdisMInitializeScatterGatherDma(IN NDIS_HANDLE MiniportAdapterHandle, IN BOOLEAN Dma64BitAddresses, IN ULONG MaximumPhysicalMapping)
Definition: io.c:1169
NDIS_STATUS EXPORT NdisMRegisterInterrupt(OUT PNDIS_MINIPORT_INTERRUPT Interrupt, IN NDIS_HANDLE MiniportAdapterHandle, IN UINT InterruptVector, IN UINT InterruptLevel, IN BOOLEAN RequestIsr, IN BOOLEAN SharedInterrupt, IN NDIS_INTERRUPT_MODE InterruptMode)
Definition: io.c:941
ULONG EXPORT NdisGetSharedDataAlignment(VOID)
Definition: misc.c:502
#define NDIS_STATUS_NOT_RECOGNIZED
Definition: ndis.h:348
#define NdisInterruptLatched
Definition: ndis.h:921
unsigned int UINT
Definition: ndis.h:50
#define NDIS_ATTRIBUTE_BUS_MASTER
Definition: ndis.h:586
#define NDIS_ERROR_CODE_INTERRUPT_CONNECT
Definition: ndis.h:566
#define NdisInterruptLevelSensitive
Definition: ndis.h:920
#define NDIS_ERROR_CODE_OUT_OF_RESOURCES
Definition: ndis.h:563
#define NDIS_ERROR_CODE_NETWORK_ADDRESS
Definition: ndis.h:570
#define NDIS_ERROR_CODE_ADAPTER_NOT_FOUND
Definition: ndis.h:565
#define NDIS_ERROR_CODE_HARDWARE_FAILURE
Definition: ndis.h:564
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT SelectedMediumIndex
Definition: ndis.h:6011
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT MediumArraySize
Definition: ndis.h:6013
@ NdisInterfacePci
Definition: ndis.h:905
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _In_ NDIS_HANDLE WrapperConfigurationContext
Definition: ndis.h:3946
_In_ NDIS_HANDLE MiniportAdapterHandle
Definition: ndis.h:4668
#define NDIS_STATUS_UNSUPPORTED_MEDIA
Definition: ndis.h:490
#define NDIS_STATUS_ADAPTER_NOT_FOUND
Definition: ndis.h:470
#define NDIS_ATTRIBUTE_USES_SAFE_BUFFER_APIS
Definition: ndis.h:592
#define NDIS_ERROR_CODE_UNSUPPORTED_CONFIGURATION
Definition: ndis.h:571
VOID EXPORT NdisMSetAttributesEx(IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_HANDLE MiniportAdapterContext, IN UINT CheckForHangTimeInSeconds OPTIONAL, IN ULONG AttributeFlags, IN NDIS_INTERFACE_TYPE AdapterType)
Definition: miniport.c:2883
NDIS_STATUS NvNetRecognizeHardware(_Inout_ PNVNET_ADAPTER Adapter)
Definition: nic.c:675
VOID NvNetSetupMacAddress(_In_ PNVNET_ADAPTER Adapter, _In_reads_bytes_(ETH_LENGTH_OF_ADDRESS) PUCHAR MacAddress)
Definition: nic.c:622
NDIS_STATUS NvNetInitNIC(_In_ PNVNET_ADAPTER Adapter, _In_ BOOLEAN InitPhy)
Definition: nic.c:401
NDIS_STATUS NvNetGetPermanentMacAddress(_Inout_ PNVNET_ADAPTER Adapter, _Out_writes_bytes_all_(ETH_LENGTH_OF_ADDRESS) PUCHAR MacAddress)
Definition: nic.c:541
@ NdisMedium802_3
Definition: ntddndis.h:188
#define NVREG_IRQSTAT_MASK
Definition: nic.h:53
#define DEV_HAS_LARGEDESC
Definition: nic.h:20
#define NVREG_MIISTAT_MASK_ALL
Definition: nic.h:229
@ NvRegIrqStatus
Definition: nic.h:51
@ NvRegMIIStatus
Definition: nic.h:225
VOID NvNetStartAdapter(_In_ PNVNET_ADAPTER Adapter)
Definition: nvnet.c:74
NVNET_PROCESS_TRANSMIT ProcessTransmitDescriptorsLegacy
Definition: nvnet.h:392
NVNET_PROCESS_TRANSMIT ProcessTransmitDescriptors64
Definition: nvnet.h:394
NVNET_TRANSMIT_PACKET NvNetTransmitPacket64
Definition: nvnet.h:391
#define NVNET_MAXIMUM_FRAME_SIZE
Definition: nvnet.h:60
#define NvNetDisableInterrupts(Adapter)
Definition: nvnet.h:666
#define NvNetLogError(Adapter, ErrorCode)
Definition: nvnet.h:387
struct _NVNET_ADAPTER NVNET_ADAPTER
Definition: nvnet.h:259
NVNET_PROCESS_TRANSMIT ProcessTransmitDescriptors32
Definition: nvnet.h:393
#define NV_USE_SOFT_MAC_ADDRESS
Definition: nvnet.h:294
NVNET_TRANSMIT_PACKET NvNetTransmitPacket32
Definition: nvnet.h:390
FORCEINLINE VOID NV_WRITE(_In_ PNVNET_ADAPTER Adapter, _In_ NVNET_REGISTER Register, _In_ ULONG Value)
Definition: nvnet.h:646
UCHAR PermanentMacAddress[ETH_LENGTH_OF_ADDRESS]
Definition: nvnet.h:338
PNVNET_TRANSMIT_PACKET TransmitPacket
Definition: nvnet.h:316
ULONG Features
Definition: nvnet.h:284
ULONG Flags
Definition: nvnet.h:285
ULONG InterruptLevel
Definition: nvnet.h:371
PVOID AdapterOriginal
Definition: nvnet.h:381
NDIS_MINIPORT_INTERRUPT Interrupt
Definition: nvnet.h:369
ULONG InterruptVector
Definition: nvnet.h:370
NDIS_HANDLE AdapterHandle
Definition: nvnet.h:283
UCHAR CurrentMacAddress[ETH_LENGTH_OF_ADDRESS]
Definition: nvnet.h:339
NDIS_HANDLE WrapperConfigurationHandle
Definition: nvnet.h:351
PNVNET_PROCESS_TRANSMIT ProcessTransmit
Definition: nvnet.h:317
#define ETH_COPY_NETWORK_ADDRESS(_D, _S)
Definition: xfilter.h:75

◆ NvNetFreeAdapter()

VOID NvNetFreeAdapter ( _In_ PNVNET_ADAPTER  Adapter)

Definition at line 595 of file init.c.

597{
598 ULONG i;
600
601 PAGED_CODE();
602
603 NDIS_DbgPrint(MIN_TRACE, ("()\n"));
604
605 for (i = 0; i < RTL_NUMBER_OF(Adapter->WakeFrames); ++i)
606 {
607 PNVNET_WAKE_FRAME WakeFrame = Adapter->WakeFrames[i];
608
609 if (!WakeFrame)
610 continue;
611
612 NdisFreeMemory(WakeFrame, sizeof(*WakeFrame), 0);
613 }
614
615 if (Adapter->Interrupt.InterruptObject)
616 {
617 NdisMDeregisterInterrupt(&Adapter->Interrupt);
618 Adapter->Interrupt.InterruptObject = NULL;
619 }
620
621 if (Adapter->Features & DEV_HAS_HIGH_DMA)
622 {
624 }
625 else
626 {
628 }
629 if (Adapter->TbdOriginal)
630 {
631 NdisMFreeSharedMemory(Adapter->AdapterHandle,
633 FALSE,
634 Adapter->TbdOriginal,
635 Adapter->TbdPhysOriginal);
636 Adapter->TbdOriginal = NULL;
637 }
638 if (Adapter->RbdOriginal)
639 {
640 NdisMFreeSharedMemory(Adapter->AdapterHandle,
642 FALSE,
643 Adapter->RbdOriginal,
644 Adapter->RbdPhysOriginal);
645 Adapter->RbdOriginal = NULL;
646 }
647 if (Adapter->SendBuffer)
648 {
649 ULONG Length = ALIGN_UP_BY(Adapter->MaximumFrameSize, NVNET_ALIGNMENT);
650
651 for (i = 0; i < NVNET_TRANSMIT_BUFFERS; ++i)
652 {
653 PNVNET_TX_BUFFER_DATA SendBufferData = &Adapter->SendBufferAllocationData[i];
654
655 if (!SendBufferData->VirtualAddress)
656 continue;
657
658 NdisMFreeSharedMemory(Adapter->AdapterHandle,
659 Length,
660 TRUE,
661 SendBufferData->VirtualAddress,
662 SendBufferData->PhysicalAddress);
663 }
664
665 NdisFreeMemory(Adapter->SendBuffer, NVNET_TRANSMIT_BUFFERS * sizeof(NVNET_TX_BUFFER), 0);
666 Adapter->SendBuffer = NULL;
667 }
668
669 if (Adapter->ReceiveBuffer)
670 {
671 NdisMFreeSharedMemory(Adapter->AdapterHandle,
673 FALSE,
674 Adapter->ReceiveBuffer,
675 Adapter->ReceiveBufferPhys);
676 Adapter->ReceiveBuffer = NULL;
677 }
678
679 if (Adapter->IoBase)
680 {
681 NdisMUnmapIoSpace(Adapter->AdapterHandle,
682 Adapter->IoBase,
683 Adapter->IoLength);
684 Adapter->IoBase = NULL;
685 }
686
687 if (Adapter->Lock.SpinLock)
688 NdisFreeSpinLock(&Adapter->Lock);
689 if (Adapter->Send.Lock.SpinLock)
690 NdisFreeSpinLock(&Adapter->Send.Lock);
691 if (Adapter->Receive.Lock.SpinLock)
692 NdisFreeSpinLock(&Adapter->Receive.Lock);
693
694 NdisFreeMemory(Adapter->AdapterOriginal, sizeof(NVNET_ADAPTER), 0);
695}
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
#define NULL
Definition: types.h:112
VOID EXPORT NdisMDeregisterInterrupt(IN PNDIS_MINIPORT_INTERRUPT Interrupt)
Definition: io.c:700
VOID EXPORT NdisMUnmapIoSpace(IN NDIS_HANDLE MiniportAdapterHandle, IN PVOID VirtualAddress, IN UINT Length)
Definition: io.c:1139
VOID EXPORT NdisFreeMemory(IN PVOID VirtualAddress, IN UINT Length, IN UINT MemoryFlags)
Definition: memory.c:110
VOID EXPORT NdisMFreeSharedMemory(IN NDIS_HANDLE MiniportAdapterHandle, IN ULONG Length, IN BOOLEAN Cached, IN PVOID VirtualAddress, IN NDIS_PHYSICAL_ADDRESS PhysicalAddress)
Definition: memory.c:215
#define NdisFreeSpinLock(_SpinLock)
Definition: ndis.h:4097
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NDIS_PHYSICAL_ADDRESS PhysicalAddress
Definition: nvnet.h:187
PVOID VirtualAddress
Definition: nvnet.h:186
_In_ SIZE_T DescriptorSize
Definition: nls.c:40

Referenced by MiniportHalt(), and MiniportInitialize().

◆ NvNetInitializeAdapterResources()

static NDIS_STATUS NvNetInitializeAdapterResources ( _Inout_ PNVNET_ADAPTER  Adapter)
static

Definition at line 215 of file init.c.

217{
219 PNDIS_RESOURCE_LIST AssignedResources = NULL;
220 UINT i, ResourceListSize = 0;
221
222 PAGED_CODE();
223
224 NDIS_DbgPrint(MIN_TRACE, ("()\n"));
225
227 Adapter->WrapperConfigurationHandle,
228 AssignedResources,
229 &ResourceListSize);
231 {
233 return NDIS_STATUS_FAILURE;
234 }
235
236 Status = NdisAllocateMemoryWithTag((PVOID*)&AssignedResources,
237 ResourceListSize,
238 NVNET_TAG);
240 {
242 return Status;
243 }
244
246 Adapter->WrapperConfigurationHandle,
247 AssignedResources,
248 &ResourceListSize);
250 {
252 goto Cleanup;
253 }
254
255 for (i = 0; i < AssignedResources->Count; ++i)
256 {
258
259 switch (Descriptor->Type)
260 {
262 {
263 Adapter->IoAddress = Descriptor->u.Memory.Start;
264 Adapter->IoLength = Descriptor->u.Memory.Length;
265 break;
266 }
267
269 {
270 Adapter->InterruptVector = Descriptor->u.Interrupt.Vector;
271 Adapter->InterruptLevel = Descriptor->u.Interrupt.Level;
272 Adapter->InterruptShared = (Descriptor->ShareDisposition == CmResourceShareShared);
273 Adapter->InterruptFlags = Descriptor->Flags;
274 break;
275 }
276
277 default:
278 break;
279 }
280 }
281
282 if (!Adapter->IoAddress.QuadPart || !Adapter->InterruptVector)
283 {
286 goto Cleanup;
287 }
288
289 NDIS_DbgPrint(MIN_TRACE, ("MEM at [%I64X-%I64X]\n",
290 Adapter->IoAddress.QuadPart,
291 Adapter->IoAddress.QuadPart + Adapter->IoLength));
292 NDIS_DbgPrint(MIN_TRACE, ("IRQ Vector %d Level %d\n",
293 Adapter->InterruptVector,
294 Adapter->InterruptLevel));
295
296 Status = NdisMMapIoSpace((PVOID*)&Adapter->IoBase,
297 Adapter->AdapterHandle,
298 Adapter->IoAddress,
299 Adapter->IoLength);
301 {
303 goto Cleanup;
304 }
305
306Cleanup:
307 NdisFreeMemory(AssignedResources, ResourceListSize, 0);
308
309 return Status;
310}
static const WCHAR Cleanup[]
Definition: register.c:80
VOID EXPORT NdisMQueryAdapterResources(OUT PNDIS_STATUS Status, IN NDIS_HANDLE WrapperConfigurationContext, OUT PNDIS_RESOURCE_LIST ResourceList, IN OUT PUINT BufferSize)
Definition: hardware.c:103
NDIS_STATUS EXPORT NdisMMapIoSpace(OUT PVOID *VirtualAddress, IN NDIS_HANDLE MiniportAdapterHandle, IN NDIS_PHYSICAL_ADDRESS PhysicalAddress, IN UINT Length)
Definition: io.c:774
#define CmResourceTypeMemory
Definition: hwresource.cpp:125
#define CmResourceTypeInterrupt
Definition: hwresource.cpp:124
#define NDIS_ERROR_CODE_RESOURCE_CONFLICT
Definition: ndis.h:562
#define NDIS_STATUS_FAILURE
Definition: ndis.h:465
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
@ CmResourceShareShared
Definition: cmtypes.h:243

Referenced by MiniportInitialize().

◆ NvNetInitReceiveMemory()

static VOID NvNetInitReceiveMemory ( _In_ PNVNET_ADAPTER  Adapter)
static

Definition at line 555 of file init.c.

557{
558 NV_RBD NvRbd;
559 ULONG i;
560
561 PAGED_CODE();
562
563 Adapter->CurrentRx = 0;
564
565 if (Adapter->Features & DEV_HAS_HIGH_DMA)
566 {
567 for (i = 0; i < NVNET_RECEIVE_DESCRIPTORS; ++i)
568 {
569 NvRbd.x64 = &Adapter->Receive.NvRbd.x64[i];
570
571 NvRbd.x64->AddressHigh = NdisGetPhysicalAddressHigh(Adapter->ReceiveBufferPhys)
573 NvRbd.x64->AddressLow = NdisGetPhysicalAddressLow(Adapter->ReceiveBufferPhys)
575 NvRbd.x64->VlanTag = 0;
577 }
578 }
579 else
580 {
581 for (i = 0; i < NVNET_RECEIVE_DESCRIPTORS; ++i)
582 {
583 NvRbd.x32 = &Adapter->Receive.NvRbd.x32[i];
584
585 NvRbd.x32->Address = NdisGetPhysicalAddressLow(Adapter->ReceiveBufferPhys)
588 }
589 }
590}
#define NdisGetPhysicalAddressLow(PhysicalAddress)
Definition: ndis.h:3847
#define NdisGetPhysicalAddressHigh(PhysicalAddress)
Definition: ndis.h:3830
#define NV_RX_AVAIL
Definition: nic.h:418
#define NV_RX2_AVAIL
Definition: nic.h:437
ULONG FlagsLength
Definition: nic.h:357
ULONG AddressHigh
Definition: nic.h:362
ULONG AddressLow
Definition: nic.h:363
ULONG FlagsLength
Definition: nic.h:365
Definition: nvnet.h:222
PNVNET_DESCRIPTOR_32 x32
Definition: nvnet.h:223
PNVNET_DESCRIPTOR_64 x64
Definition: nvnet.h:224

Referenced by MiniportInitialize().

◆ NvNetInitTransmitMemory()

VOID NvNetInitTransmitMemory ( _In_ PNVNET_ADAPTER  Adapter)

Definition at line 532 of file init.c.

534{
535 PAGED_CODE();
536
537 Adapter->Send.TcbSlots = NVNET_TRANSMIT_BLOCKS;
538 Adapter->Send.TbdSlots = NVNET_TRANSMIT_DESCRIPTORS;
539
540 if (Adapter->Features & DEV_HAS_HIGH_DMA)
541 {
542 NdisZeroMemory(Adapter->Send.HeadTbd.x64,
544 }
545 else
546 {
547 NdisZeroMemory(Adapter->Send.HeadTbd.x32,
549 }
550}

Referenced by MiniportInitialize().

◆ NvNetReadConfiguration()

static NDIS_STATUS NvNetReadConfiguration ( _Inout_ PNVNET_ADAPTER  Adapter)
static

Definition at line 67 of file init.c.

69{
74 ULONG GenericUlong;
75
76 PAGED_CODE();
77
78 NDIS_DbgPrint(MIN_TRACE, ("()\n"));
79
82 Adapter->WrapperConfigurationHandle);
84 return Status;
85
87 L"OptimizationMode",
88 &GenericUlong,
92 Adapter->OptimizationMode = GenericUlong;
93
95 L"FlowControl",
96 &GenericUlong,
100 Adapter->FlowControlMode = GenericUlong;
101
103 L"SpeedDuplex",
104 &GenericUlong,
105 0,
106 0,
107 4);
108 switch (GenericUlong)
109 {
110 case 1:
111 Adapter->Flags |= NV_FORCE_SPEED_AND_DUPLEX;
112 break;
113 case 2:
115 break;
116 case 3:
117 Adapter->Flags |= (NV_FORCE_SPEED_AND_DUPLEX | NV_USER_SPEED_100);
118 break;
119 case 4:
122 break;
123
124 default:
125 break;
126 }
127
129 L"ChecksumOffload",
130 &GenericUlong,
131 0,
132 0,
133 1);
134 if (GenericUlong)
135 Adapter->Flags |= NV_SEND_CHECKSUM;
136
138 L"LargeSendOffload",
139 &GenericUlong,
140 0,
141 0,
142 1);
143 if (GenericUlong)
144 Adapter->Flags |= NV_SEND_LARGE_SEND;
145
147 L"JumboSize",
148 &GenericUlong,
152 Adapter->MaximumFrameSize = GenericUlong;
153
155 L"Priority",
156 &GenericUlong,
157 0,
158 0,
159 1);
160 if (GenericUlong)
161 Adapter->Flags |= NV_PACKET_PRIORITY;
162
164 L"VlanTag",
165 &GenericUlong,
166 0,
167 0,
168 1);
169 if (GenericUlong)
170 Adapter->Flags |= NV_VLAN_TAGGING;
171
173 L"VlanID",
174 &GenericUlong,
175 0,
176 0,
178
181 &Length,
184 {
187 {
188 NDIS_DbgPrint(MAX_TRACE, ("Invalid software MAC: %02x:%02x:%02x:%02x:%02x:%02x\n",
194 NetworkAddress[5]));
195 }
196 else
197 {
198 NDIS_DbgPrint(MIN_TRACE, ("Using software MAC\n"));
199
200 ETH_COPY_NETWORK_ADDRESS(Adapter->CurrentMacAddress, NetworkAddress);
201
202 Adapter->Flags |= NV_USE_SOFT_MAC_ADDRESS;
203 }
204 }
206
208
209 return Status;
210}
static VOID QueryInteger(_In_ NDIS_HANDLE ConfigurationHandle, _In_ PCWSTR EntryName, _Out_ PULONG EntryContext, _In_ ULONG DefaultValue, _In_ ULONG Minimum, _In_ ULONG Maximum)
Definition: init.c:20
VOID EXPORT NdisCloseConfiguration(IN NDIS_HANDLE ConfigurationHandle)
Definition: config.c:136
VOID EXPORT NdisReadNetworkAddress(OUT PNDIS_STATUS Status, OUT PVOID *NetworkAddress, OUT PUINT NetworkAddressLength, IN NDIS_HANDLE ConfigurationHandle)
Definition: config.c:740
VOID EXPORT NdisOpenConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_HANDLE ConfigurationHandle, IN NDIS_HANDLE WrapperConfigurationContext)
Definition: config.c:197
#define ETH_LENGTH_OF_ADDRESS
Definition: efilter.h:16
#define ETH_IS_LOCALLY_ADMINISTERED(Address)
Definition: ethernetutils.h:35
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _Out_ PNDIS_STATUS _Outptr_result_bytebuffer_to_ NetworkAddressLength PVOID * NetworkAddress
Definition: ndis.h:3956
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE ConfigurationHandle
Definition: ndis.h:3945
#define L(x)
Definition: ntvdm.h:50
@ NV_OPTIMIZATION_MODE_DYNAMIC
Definition: nvnet.h:80
@ NV_OPTIMIZATION_MODE_THROUGHPUT
Definition: nvnet.h:82
#define NV_PACKET_PRIORITY
Definition: nvnet.h:298
@ NV_FLOW_CONTROL_AUTO
Definition: nvnet.h:88
@ NV_FLOW_CONTROL_DISABLE
Definition: nvnet.h:87
@ NV_FLOW_CONTROL_RX_TX
Definition: nvnet.h:91
#define NV_SEND_LARGE_SEND
Definition: nvnet.h:288
#define NV_SEND_CHECKSUM
Definition: nvnet.h:287
#define NV_VLAN_TAGGING
Definition: nvnet.h:299
#define NV_FORCE_SPEED_AND_DUPLEX
Definition: nvnet.h:295
#define NVNET_MAXIMUM_FRAME_SIZE_JUMBO
Definition: nvnet.h:61
#define NV_FORCE_FULL_DUPLEX
Definition: nvnet.h:296
#define NVNET_MAXIMUM_VLAN_ID
Definition: nvnet.h:62
#define NV_USER_SPEED_100
Definition: nvnet.h:297
#define ETH_IS_BROADCAST(Address)
Definition: xfilter.h:32
#define ETH_IS_MULTICAST(Address)
Definition: xfilter.h:35

Referenced by MiniportInitialize().

◆ QueryInteger()

static VOID QueryInteger ( _In_ NDIS_HANDLE  ConfigurationHandle,
_In_ PCWSTR  EntryName,
_Out_ PULONG  EntryContext,
_In_ ULONG  DefaultValue,
_In_ ULONG  Minimum,
_In_ ULONG  Maximum 
)
static

Definition at line 20 of file init.c.

27{
30 PNDIS_CONFIGURATION_PARAMETER ConfigurationParameter;
31
32 PAGED_CODE();
33
34 NdisInitUnicodeString(&Keyword, EntryName);
36 &ConfigurationParameter,
38 &Keyword,
41 {
42 NDIS_DbgPrint(MIN_TRACE, ("'%S' request failed\n", EntryName));
43
44 *EntryContext = DefaultValue;
45 }
46 else
47 {
48 if (ConfigurationParameter->ParameterData.IntegerData >= Minimum &&
49 ConfigurationParameter->ParameterData.IntegerData <= Maximum)
50 {
51 *EntryContext = ConfigurationParameter->ParameterData.IntegerData;
52 }
53 else
54 {
55 NDIS_DbgPrint(MAX_TRACE, ("'%S' value out of range\n", EntryName));
56
57 *EntryContext = DefaultValue;
58 }
59 }
60
61 NDIS_DbgPrint(MIN_TRACE, ("Set '%S' to %d\n", EntryName, *EntryContext));
62}
VOID EXPORT NdisReadConfiguration(OUT PNDIS_STATUS Status, OUT PNDIS_CONFIGURATION_PARAMETER *ParameterValue, IN NDIS_HANDLE ConfigurationHandle, IN PNDIS_STRING Keyword, IN NDIS_PARAMETER_TYPE ParameterType)
Definition: config.c:414
VOID EXPORT NdisInitUnicodeString(IN OUT PNDIS_STRING DestinationString, IN PCWSTR SourceString)
Definition: string.c:130
@ NdisParameterInteger
Definition: ndis.h:926
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
Definition: rtlfuncs.h:4196
union _NDIS_CONFIGURATION_PARAMETER::@2077 ParameterData

Referenced by NvNetReadConfiguration().