This may not be the proper spot to post, but I figured it was a good starting
point. I also suspect this may be dependent upon the actual Ethernet device
driver, and not an industry standard. That being said:

When data is transferred across an Ethernet connection using, say a TCP-IP
socket connection, the end caller issues a receive call, and passes in a
pointer to a buffer where the data is written.

My question is:
a) Is the data being transferred ONLY written into that buffer which is
passed in, or
b) is there an intermediate buffer contained w/in the driver to store the
data as it is transferred across the medium (and then copied into the buffer
passed in on the receive call)?

I am trying to minimize copies in my code, because I have large amounts of
data being transferred. Again, I realize that this may be totally dependent
upon the ethernet card being used, I just was curious if there was an
industry standard, or some underlying protocol/handshaking to which I was not
aware of.

Thanks.

Re: Ethernet driver buffer allocation by Doron

Doron
Thu Oct 11 09:11:37 PDT 2007

this is dependent on the card. the zero copy solution is called chimney,
essentially for this to work the NIC must be able to crask the tcp/ip
headers and know the target buffer to copy to (which also means that the
buffer pending on the NIC also must have additional data to indicate which
address it is for)

d

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"Jan" <Jan@discussions.microsoft.com> wrote in message
news:27E8CBDC-DC3A-4F03-A025-87D2E6661F55@microsoft.com...
> This may not be the proper spot to post, but I figured it was a good
> starting
> point. I also suspect this may be dependent upon the actual Ethernet
> device
> driver, and not an industry standard. That being said:
>
> When data is transferred across an Ethernet connection using, say a TCP-IP
> socket connection, the end caller issues a receive call, and passes in a
> pointer to a buffer where the data is written.
>
> My question is:
> a) Is the data being transferred ONLY written into that buffer which is
> passed in, or
> b) is there an intermediate buffer contained w/in the driver to store the
> data as it is transferred across the medium (and then copied into the
> buffer
> passed in on the receive call)?
>
> I am trying to minimize copies in my code, because I have large amounts of
> data being transferred. Again, I realize that this may be totally
> dependent
> upon the ethernet card being used, I just was curious if there was an
> industry standard, or some underlying protocol/handshaking to which I was
> not
> aware of.
>
> Thanks.


Re: Ethernet driver buffer allocation by Maxim

Maxim
Thu Oct 11 13:47:59 PDT 2007

> b) is there an intermediate buffer contained w/in the driver to store the
> data as it is transferred across the medium (and then copied into the buffer
> passed in on the receive call)?

Modern NDIS drivers receive packets to the DMA common buffer. Then the chunks
of this common buffer are indicated up to TCP/IP, which passes them to AFD.

If AFD has pending receive call from the app - then it does only 1 memcpy() and
copies the data from the indicated buffer to the app's buffer, then completing
the app's receive call.

But, if there are no app's receive call - then AFD allocates its own temp
buffer (the total limiting size of all of them is the SO_RCVBUF option) and
copies the data from the indicated buffer to the temp buffer. Then, when the
app calls recv(), AFD copies from the temp buffer to the app's buffer and frees
the temp buffer. 2 memcpy().

For 1-memcpy-on-receive, you must always have lots of pending overlapped
receive calls on a socket.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
maxim@storagecraft.com
http://www.storagecraft.com