Composing Awesome System Drivers for Windows .


39 views
Uploaded on:
Category: Music / Dance
Description
Writing Great Network Drivers for Windows ®. Tom Fout Program Manager Windows ® Operating Systems Division Microsoft ® Corporation. Topics. General Miniport guidelines Common issues Installation Initialization/de-initialization Operation Testing Performance guidelines.
Transcripts
Slide 1

Composing Great Network Drivers for Windows ® Tom Fout Program Manager Windows ® Operating Systems Division Microsoft ® Corporation

Slide 2

Topics General Miniport rules Common issues Installation Initialization/de-instatement Operation Testing Performance rules

Slide 3

General Miniport Guidelines OS particular capacities diminish movability Use just NDIS & WDM Interfaces Note on Current Header Inconsistencies Use BINARY_COMPATIBLE banner Also For Portability Full MAC Support Will be Gone Soon Write Miniports for Longevity

Slide 4

Installation... Normal INF Issues Never utilize Tabs Don\'t utilize Hybrid INFs (For Windows 2000 consideration just) Start Type Should be "3" Displayed UI Must be Localizable ISAPNP/Legacy Mode Devices Have Two NDI segments Bustype=1; Bustype=14 List ALL Plug and Play IDs

Slide 5

...Installation Have Keyword Defaults Predefined in Driver Don\'t Bail if Key Cannot be Read Don\'t utilize Co or Class Installer Unless Required – Can Be Complex Multiport Serial, WAN, Layered Drivers Check INF Quality with Tools ChkINF Perl Script in DDK

Slide 6

Initialization... Instate Quickly – Effects System Boot Perform Media Detection First – Skip Speed Detection if Not Connected If Connected – Defer Speed to Timer Querying Hardware Resources Use NdisMQueryAdapterResources Use Standard Key names if Compatibility with Windows NT ® 4.0 is Required Do not get to transport config space Trust the Resources Returned by NDIS Manage your assets Free what you allot Reset what you Set Release what you Acquire

Slide 7

… Initialization... Utilize legitimate Initialization Order Map IO/Memory First Hook Interrupt Before Accessing Device When you allot intrude on, ISR might be summoned right Only show Media Connect after Sense Not each progression of n-way sense Indicate It – Or we will Poll! Reflect suitable Media Speed Especially after Media Change Indication Don\'t Indicate Status until Init Returns NdisMAllocateMapRegisters Dma32BitAddresses=TRUE Unless Can\'t Access Memory > 16MB

Slide 8

… Initialization Event logging For Out Of The Ordinary Events Make it Descriptive Only Log it Once Use significant parameter defaults Avoid UI Auto Tune (I.e. Get Buffers) Don\'t Scan the Bus amid Initialization If the HW is Plug and Play, it\'s there when the driver is requested that instate

Slide 9

Operation Interrupt taking care of Determine if Yours Keep Interrupt State Disable interferes with Wait for DPC to Re-empower MiniportCheckForHang handler Determine if the HW is Functioning Properly Request Reset if Not

Slide 10

Operation Implement a Reset State Machine Don\'t slow down, issuing Commands in a circle Avoid Stalling During Reset - it\'s running a DPC Media Sense/Negotiation Longer than Microseconds APIs can flop thus can HW Be set up to handle this

Slide 11

Operation Support Power Management Even in the event that you don\'t bolster Wake On LAN Capabilities, QueryPower, SetPower OIDs Improves Resume Time - Suspend/Hibernate Note: NdisImmediateXxx APIs Lookahead Size Does exclude MAC headers Intermediate drivers Must be Plug and Play and Power Managed See DDK and Passthru Sample

Slide 12

Operation Conserve CPU Cycles E.g. Try not to Spin sitting tight for a bit to change No Send Completions at DIRQL Beware Performance Enhancements That expect particular administration timing May work in a few adaptations of Windows May soften up others

Slide 13

De-Initialization Don\'t Leave Hardware in Undefined State Reset to Quiescent State Support Dynamic Start and Stop Don\'t require a reboot Differentiate Halt and Shutdown Halt - gadget being ceased or expelled Free assets, reset HW Cancel all clocks Shutdown - System closing down Reset HW to Quiet State Don\'t free assets or cleanup state

Slide 14

De-Initialization Additional Notes On Halt: If CancelTimer Fails, Timer has Fired Wait for Timer To Complete Ensure Timer is not Re-Queued Indicating with NdisMIndicateReceivePacket Make beyond any doubt remarkable Packets have Been Returned – Before Returning from Halt Check PacketPoolUsage or Ref Count

Slide 15

De-Initialization When Reset: When Reset Completes, Nothing is Pending Abort All Pending Requests/Packets De-serialized drivers are in charge of finishing the prematurely ended solicitations/bundles NDIS Has No Record of Pending Req. NDIS_STATUS_REQUEST_ABORTED Standard miniports ought to just Abort NDIS Will Complete the Aborted asks for/parcels AddressingReset to have NDIS Restore State

Slide 16

Testing Test with the majority of the principle x86 HALs Legacy MPS ACPI APIC MPS ACPI ! Since we will ! Test Additional Features (Enable Them) Task Offload, 802.1p, WOL…

Slide 17

Performance Guidelines Scalability Task offload Path length decrease

Slide 18

Performance Guidelines Scalability Don\'t de-serialize by securing the driver with a solitary spinlock Minimize spinlock gets, discharges, and hold times (maintain a strategic distance from spinlocks) Use spinlocks to ensure information - not code When utilizing locks, stay away from IRQL changes Use NdisDprAcquireSpinLock in DPR, Etc… Cache-line adjust vital information structures NdisGetCacheFillSize To keep away from False Sharing

Slide 19

Performance Guidelines Scalability Partition information structures Use Per-Processor Data Structures Use Interlocked Operations Convert Queues to Ring Buffers Move Pointers with InterlockedIncrement Use Push/Pop/PopAll Slist operation i.e. NdisInterlockedPushEntrySList Consider Needs for Statistics Accuracy Avoid Protecting Counters Keep Per-Processor Statistics

Slide 20

Performance Guidelines Task Offload Implement errand offload Checksum Offload Both Send and Receive Up to 30% Performance Boost (CPU) Large Send No Hardware Support? - execute in Software Fast Forward Path (FFP)

Slide 21

Performance Guidelines Path Length Reduction Use Interrupt Moderation Interrupt per number of parcels or bytes Use Interrupt Avoidance Only Interrupt if Necessary E.g. in the event that in DPC, don\'t intrude on Use Large Frame Sizes where Possible Use Lookaside Lists for memory portion For settled size distributions Grab the same number of as required for primary code ways

Slide 22

Performance Guidelines Path Length Reduction Use new DMA work NdisMInitializeScatterGatherDma Replaces NdisMAllocateMapRegisters NDIS_PER_PACKET_INFO_FROM_PACKET Retrieves diffuse assemble list from the parcel Streamline DMA exchanges by collecting target pages Indicate group mode bundle signs NdisMIndicateReceivePacket Dynamically develop/recoil get cushions NdisMAllocateSharedMemoryAsync NdisReturnPackets De-serialized drivers ought to expect amid sign

Slide 23

Performance Guidelines Path Length Reduction Profile your Code (kernprof) Find out where most time is spent Optimize There Tuning parameters Auto tune where conceivable Registry based tuning parameters Use sensible names and defaults

Slide 24

New NDIS APIs NdisMInitializeScatterGatherDma Load Balance/Failover (LBFO) NdisMSetMiniportSecondary NdisMPromoteMiniport NdisMRemoveMiniport NdisMRegisterDevice (Deregister) Create Accessible Device Object NdisMRegisterUnloadHandler Read/Write Locks NdisInitializeReadWriteLock , NdisAcquireReadWriteLock , NdisReleaseReadWriteLock

Slide 25

Other API Notes NdisGetReceivedPacket NdisQueryReceiveInformation NdisSetTimer/NdisCancelTimer Protocol & Compatible Versions Not Obsolete NdisMSetTimer/NdisMCancelTimer NdisAllocatePacket/NdisFreePacket Free Macro versus Work Recompile w/Windows 2000 DDK

Recommended
View more...