Hi everyone,

1. I am writing an NDIS6 virtual miniport driver and I am confused
by the miniport and NDIS behaviour when I am disabling the device
(through device manager).
What happens is that
Ndis calls MiniportPause, than it calls MiniportRestart and after
that it calls MiniportPause again
and finally it calls MiniportHalt.

This confuses me since from what I understood from the state machine
documented at
WDK the sequence should be:
a call to MiniportPause followed by a call to MiniportHalt - no call
to MiniportRestart in the middle

Is the sequence I see in my miniport indicates a problem on it or is
it the normal sequence when
disabling a device?

2. In the future I would like to turn the mninipot into NDIS + KMDF
driver using USB.
I would like to use the ContiniousReader mechanism.
In NdisEdge sample it is written shortly about how to convert the
sample to a USB but it is very
general. So I looked at the WDK and at the osrusbfx2 sample and I
saw that when using it on a
KMDF driver one should do some actions on the following KMDF
callbacks:
EvtDeviceD0Entry (MiniportRestart ?)
EvtDeviceD0Exit (MiniportPause ?)
EvtDevicePrepareHardware (MiniportInitializeEx ?)
EvtDeviceReleaseHardware (MiniportHaltEx ?)

Writing an NDIS+KMDF miniport I don't have these callbacks what are
the NDIS callbacks that
complies to the these KMDF callbacks (I wrote my assumptions in
parenthesis) ?

Thanks
Miki

Re: NDIS6 - state machine and USB questions by Eliyas

Eliyas
Fri Dec 22 10:47:11 CST 2006

1) Why do you care whether miniport is being paused and restarted before
being removed? As long as you do what is expected of you in those
callbacks, you should be fine. My guess is that NDIS is getting some filters
out of your way before allowing the device to be removed.


> EvtDeviceD0Entry (MiniportRestart ?)
> EvtDeviceD0Exit (MiniportPause ?)
> EvtDevicePrepareHardware (MiniportInitializeEx ?)
> EvtDeviceReleaseHardware (MiniportHaltEx ?)

2) MiniportRestart/Pause doesn't directly map to D0Entry/Exit because they
are called not just during pnp/power state change but also when NDIS has to
change the bindings of other network components layered above you.

MiniportInitilize - Create WDFUSBDEVICE, select interface and initialize
your usb device, configure and start the continuous reader.
MiniportHalt - Stop the continuous reader and free all the resources and
KMDF objects.
MiniportPause/Restart - You may stop and restart the continuous reader.

I don't remember all the little details on what to do when power oids are
sent by NDIS. We have written a native wifi sample driver for a realtek USB
device to demonstrate how to use KMDF to interact with USB device in an NDIS
6.0 miniport driver. This sample will be in the next release of WDK. Please
send me a private note by email and I will see if I can get this sample to
you.

-Eliyas



Re: NDIS6 - state machine and USB questions by miki

miki
Sat Dec 23 13:55:00 CST 2006

Thanks Eliays,

I had two concerns from this additional restart pause phase:

1. I was worried that it is a symptom of some other potential problem
in the miniport driver.
2. In the restart phase I do work to start the device. It seems to me
unnecessary to burden the system with claiming resources just to
release them in a minute (not to mention that the halting time of the
device is getting longer).

Is there way to differentiate between a restart that is done to bring
the device to its running state ((afer miniportinitialize) and a
pause-restart that occur before halting the device?








Eliyas Yakub [MSFT] wrote:
> 1) Why do you care whether miniport is being paused and restarted before
> being removed? As long as you do what is expected of you in those
> callbacks, you should be fine. My guess is that NDIS is getting some filters
> out of your way before allowing the device to be removed.
>
>
> > EvtDeviceD0Entry (MiniportRestart ?)
> > EvtDeviceD0Exit (MiniportPause ?)
> > EvtDevicePrepareHardware (MiniportInitializeEx ?)
> > EvtDeviceReleaseHardware (MiniportHaltEx ?)
>
> 2) MiniportRestart/Pause doesn't directly map to D0Entry/Exit because they
> are called not just during pnp/power state change but also when NDIS has to
> change the bindings of other network components layered above you.
>
> MiniportInitilize - Create WDFUSBDEVICE, select interface and initialize
> your usb device, configure and start the continuous reader.
> MiniportHalt - Stop the continuous reader and free all the resources and
> KMDF objects.
> MiniportPause/Restart - You may stop and restart the continuous reader.
>
> I don't remember all the little details on what to do when power oids are
> sent by NDIS. We have written a native wifi sample driver for a realtek USB
> device to demonstrate how to use KMDF to interact with USB device in an NDIS
> 6.0 miniport driver. This sample will be in the next release of WDK. Please
> send me a private note by email and I will see if I can get this sample to
> you.
>
> -Eliyas


Re: NDIS6 - state machine and USB questions by Alireza

Alireza
Sun Dec 24 04:23:34 CST 2006

There is no guarantee that you will always get a pause/restart right before
the halt and you must not write a code that behaves differently when
miniport is restarted after initial initialization vs. "possibly" a restart
it gets before another pause and then halt.

If it helps, when we pause the miniport we tell it "why" in the PauseReason
field of NDIS_MINIPORT_PAUSE_PARAMETER. Check out NDIS_PAUSE_xxx defines in
NDIS.H.

-ali

--
This posting is provided "AS IS" with no warranties, and confers no rights.

"miki" <michael.waksman@gmail.com> wrote in message
news:1166903700.046740.237870@42g2000cwt.googlegroups.com...
> Thanks Eliays,
>
> I had two concerns from this additional restart pause phase:
>
> 1. I was worried that it is a symptom of some other potential problem
> in the miniport driver.
> 2. In the restart phase I do work to start the device. It seems to me
> unnecessary to burden the system with claiming resources just to
> release them in a minute (not to mention that the halting time of the
> device is getting longer).
>
> Is there way to differentiate between a restart that is done to bring
> the device to its running state ((afer miniportinitialize) and a
> pause-restart that occur before halting the device?
>
>
>
>
>
>
>
>
> Eliyas Yakub [MSFT] wrote:
>> 1) Why do you care whether miniport is being paused and restarted before
>> being removed? As long as you do what is expected of you in those
>> callbacks, you should be fine. My guess is that NDIS is getting some
>> filters
>> out of your way before allowing the device to be removed.
>>
>>
>> > EvtDeviceD0Entry (MiniportRestart ?)
>> > EvtDeviceD0Exit (MiniportPause ?)
>> > EvtDevicePrepareHardware (MiniportInitializeEx ?)
>> > EvtDeviceReleaseHardware (MiniportHaltEx ?)
>>
>> 2) MiniportRestart/Pause doesn't directly map to D0Entry/Exit because
>> they
>> are called not just during pnp/power state change but also when NDIS has
>> to
>> change the bindings of other network components layered above you.
>>
>> MiniportInitilize - Create WDFUSBDEVICE, select interface and initialize
>> your usb device, configure and start the continuous reader.
>> MiniportHalt - Stop the continuous reader and free all the resources and
>> KMDF objects.
>> MiniportPause/Restart - You may stop and restart the continuous reader.
>>
>> I don't remember all the little details on what to do when power oids are
>> sent by NDIS. We have written a native wifi sample driver for a realtek
>> USB
>> device to demonstrate how to use KMDF to interact with USB device in an
>> NDIS
>> 6.0 miniport driver. This sample will be in the next release of WDK.
>> Please
>> send me a private note by email and I will see if I can get this sample
>> to
>> you.
>>
>> -Eliyas
>