阅读:3168回复:3
MPSend中为什么不调用NdisMSendComplete
那位大虾提示一下:为什么下面的程序在MPSendPackets中有,在MPSend中没有,
if (Status != NDIS_STATUS_PENDING) { NdisMSendComplete(pAdapt->pPrimaryAdapt>MiniportHandle,Packet,Status); } 谢谢 |
|
沙发#
发布于:2001-10-20 08:54
When an intermediate driver with a connectionless lower edge calls NdisSend from MiniportSend, it relinquishes ownership of the packet descriptor and of all the resources that it describes until the send completes, either synchronously or asynchronously. If the status returned by NdisSend is other than NDIS_STATUS_PENDING, the call completes synchronously, and ownership of the packet resources reverts to the intermediate driver on return from NdisSend. The intermediate driver should return any send resources allocated by a higher level driver and propagate the result of its call to NdisSend as the return status from MiniportSend.
If the status returned by NdisSend is NDIS_STATUS_PENDING, when the send subsequently completes, the final status of the send and the packet descriptor will be returned to ProtocolSendComplete. The intermediate driver should call NdisSendComplete from its ProtocolSendComplete function to propagate the send status up to the next higher driver. (摘自DDK里面的) 其实我也不知道为什么会这样做! [LikeDDK 编辑于 2001-10-20 08:59] |
|
板凳#
发布于:2001-10-20 11:58
这个问题是这样的:
我们从send的整个过程来看: 1。首先是IM Driver上的Protocol Driver调用了NdisSend或者NdisSendPackets,如果Protocol Driver调用NdisSend,则分两种情况,一种是NdisSend返回NDIS_STATUS_PENDING ,那么Protocol Driver将认为包描述符及其相关的缓冲区资源不可利用,因为其所有权认为在IM Driver中,将会等待ProtocolSendComplete的调用来重新利用包描述符及其相关的缓冲区资源,这是NDIS纯粹一种软件上的协定;那另一种情况就是返回非NDIS_STATUS_PENDING,那么Protocol Driver认为IM Driver已经处理完该包,可以马上重新利用包描述符及其相关的缓冲区资源,不必等到到ProtocolSendComplete去处理。如果调用NdisSendPackets,总是前一种情况,因为它根本没有返回参数,这样处理也是和NdisSendPackets完成的功能相一致的。 2。NdisSend/NdisSendPackets然后会调用IM Driver的MiniportSend或 MiniportSendPackets。如果调用MiniportSend,MiniportSend再调用NdisSend,如果NdisSend返回非NDIS_STATUS_PENDING, MiniportSend直接返回一个非NDIS_STATUS_PENDING,NDIS也就直接返回一个非NDIS_STATUS_PENDING给Protocol Driver,也就是上面1中的后面一种情况;如果MiniportSend调用NdisSend返回NDIS_STATUS_PENDING,那么MiniportSend就会返回NDIS_STATUS_PENDING。剩下的工作将由IM Driver中的protocol层中的ProtocolSendComplete函数去调用NdisMSendComplete,从而触发IM Driver上面的Protocol Driver的ProtocolSendComplete,也就是上面1中的前面一种情况; 已经解答了你的问题,MPSend中为什么不调用NdisMSendComplete?没有必要调用,当NdisSend返回非NDIS_STATUS_PENDING,他是依靠其返回值来实现发送的整个逻辑的; 3.为何MPSendPackets又要调用呢,直接原因是MPSendPackets没有任何返回值,为何不设一个返回值呢?因为MPSendPackets是用来一次发送多个包的,一个返回值表明那个包发送成功呢?因此,他总是依靠回调机制来实现发送逻辑,实际上,回调也总是一次通知一个包。 4.今天是星期六,祝大家周末愉快; [liuhb 编辑于 2001-10-20 12:01] |
|
|
地板#
发布于:2001-10-23 14:29
我的理解是:
如果要说简单一点,就是如果在MPSend中调用NdisSend时返回的状态值NDIS_STATUS_PENDING,那么在发送操作完成时,就会引起中间层的ProtocolSendComplete的调用,在这里面做NdisMSendComplete |
|
|