On 10/15/2014 10:15 PM, Jiafei.Pan@xxxxxxxxxxxxx wrote:
-----Original Message-----
From: Eric Dumazet [mailto:eric.dumazet@xxxxxxxxx]
Sent: Thursday, October 16, 2014 12:15 PM
To: Pan Jiafei-B37022
Cc: David Miller; jkosina@xxxxxxx; netdev@xxxxxxxxxxxxxxx; Li Yang-Leo-R58472;
linux-doc@xxxxxxxxxxxxxxx
Subject: Re: [PATCH] net: use hardware buffer pool to allocate skb
On Thu, 2014-10-16 at 02:17 +0000, Jiafei.Pan@xxxxxxxxxxxxx wrote:
Thanks for your comments and suggestion. In my case, I want to build skb
from hardware block specified memory, I only can see two ways, one is modified
net card driver replace common skb allocation function with my specially
functions, another way is to hack common skb allocation function in which
redirect to my specially functions. My patch is just for the second way.
Except these two ways, would you please give me some advice for some other
ways for my case? Thanks
I suggest you read drivers/net/ethernet numerous examples.
No need to change anything in net/* or include/*, really.
For a start, look at drivers/net/ethernet/intel/igb/igb_main.c
Mentioning 'hack' in your mails simply should hint you are doing
something very wrong.
What makes you think your hardware is so special ?
In fact, I am developing a bridge driver, it can bridge between any other the
third party net card and my own net card. My target is to let any other the
third party net card can directly use my own net card specified buffer, then
there will be no memory copy in the whole bridge process.
By the way, I don’t see any similar between igb_main.c and my case. And also
My bridge also can’t implemented with "skb frag" in order to aim at zero memory
copy.
I think the part you are not getting is that is how buffers are
essentially handled now. So for example in the case if igb the only
part we have copied out is usually the header, or the entire frame in
the case of small packets. This has to happen in order to allow for
changes to the header for routing and such. Beyond that the frags that
are passed are the buffers that igb is still holding onto. So
effectively what the other device transmits in a bridging/routing
scenario is my own net card specified buffer plus the copied/modified
header.
For a brief period igb used build_skb but that isn't valid on most
systems as memory mapped for a device can be overwritten if the page is
unmapped resulting in any changes to the header for routing/bridging
purposes being invalidated. Thus we cannot use the buffers for both the
skb->data header which may be changed and Rx DMA simultaneously.
Thanks,
Alex
--
To unsubscribe from this list: send the line "unsubscribe linux-doc" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html