* is each frag of a skb always less than 1 page?
@ 2006-10-10 22:37 Ronghua Zhang
2006-10-10 22:47 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Ronghua Zhang @ 2006-10-10 22:37 UTC (permalink / raw)
To: netdev
>From the code of tcp_sendmsg, it seems to me that each frag is at most
one page. Is it a guaranteed property or the driver should not assume
it? Thanks
Ronghua
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: is each frag of a skb always less than 1 page?
2006-10-10 22:37 is each frag of a skb always less than 1 page? Ronghua Zhang
@ 2006-10-10 22:47 ` David Miller
2006-10-10 23:26 ` Ronghua Zhang
0 siblings, 1 reply; 5+ messages in thread
From: David Miller @ 2006-10-10 22:47 UTC (permalink / raw)
To: ronghuazhang; +Cc: netdev
From: "Ronghua Zhang" <ronghuazhang@gmail.com>
Date: Tue, 10 Oct 2006 15:37:04 -0700
> >From the code of tcp_sendmsg, it seems to me that each frag is at most
> one page. Is it a guaranteed property or the driver should not assume
> it? Thanks
This assumption basically already exists everywhere since
all drivers that create DMA mappings of the frags call
pci_map_page().
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: is each frag of a skb always less than 1 page?
2006-10-10 22:47 ` David Miller
@ 2006-10-10 23:26 ` Ronghua Zhang
2006-10-11 2:10 ` David Miller
2006-10-11 7:30 ` Jarek Poplawski
0 siblings, 2 replies; 5+ messages in thread
From: Ronghua Zhang @ 2006-10-10 23:26 UTC (permalink / raw)
To: David Miller; +Cc: netdev
Thank you for your explanation, David.
But pci_map_page should work fine if we have multiple contiguous pages
in one frag that are allocated using alloc_pages, ie:
frag->page = alloc_pages(GFP_KERNEL, 2); // get 4 pages
frag->page_offset = 0;
frag->size = 4 * PAGE_SIZE;
dma_addr = pci_map_page(frag->page, frag->page_offset, frag->size, ..);
The reason I asked this is that I saw the following code in forthdeth drvier:
#define NV_TX2_TSO_MAX_SHIFT) 14
/* add fragments to entries count */
for (i = 0; i < fragments; i++) {
entries += (skb_shinfo(skb)->frags[i].size >> NV_TX2_TSO_MAX_SHIFT) +
((skb_shinfo(skb)->frags[i].size &
(NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
}
This looks unnecessary if each frag is guaranteed not to span pages.
Ronghua
On 10/10/06, David Miller <davem@davemloft.net> wrote:
> From: "Ronghua Zhang" <ronghuazhang@gmail.com>
> Date: Tue, 10 Oct 2006 15:37:04 -0700
>
> > >From the code of tcp_sendmsg, it seems to me that each frag is at most
> > one page. Is it a guaranteed property or the driver should not assume
> > it? Thanks
>
> This assumption basically already exists everywhere since
> all drivers that create DMA mappings of the frags call
> pci_map_page().
>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: is each frag of a skb always less than 1 page?
2006-10-10 23:26 ` Ronghua Zhang
@ 2006-10-11 2:10 ` David Miller
2006-10-11 7:30 ` Jarek Poplawski
1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2006-10-11 2:10 UTC (permalink / raw)
To: ronghuazhang; +Cc: netdev
From: "Ronghua Zhang" <ronghuazhang@gmail.com>
Date: Tue, 10 Oct 2006 16:26:58 -0700
> Thank you for your explanation, David.
>
> But pci_map_page should work fine if we have multiple contiguous pages
> in one frag that are allocated using alloc_pages, ie:
>
> frag->page = alloc_pages(GFP_KERNEL, 2); // get 4 pages
> frag->page_offset = 0;
> frag->size = 4 * PAGE_SIZE;
>
> dma_addr = pci_map_page(frag->page, frag->page_offset, frag->size, ..);
You should look at the implementation of pci_map_page() on
some interesting architectures such as sparc64 and powerpc
where an IOMMU is used to map the pages into DMA space on the
PCI bus.
Those implementations (rightly) assume only a single page needs
to be mapped.
If you assume that multiple pages would get mapped properly by
such a call, things would fail. You might even get a PCI Master
ABORT after crossing past the end of the first page in that
multi-page chunk since the IOMMU will not have a DMA translation.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: is each frag of a skb always less than 1 page?
2006-10-10 23:26 ` Ronghua Zhang
2006-10-11 2:10 ` David Miller
@ 2006-10-11 7:30 ` Jarek Poplawski
1 sibling, 0 replies; 5+ messages in thread
From: Jarek Poplawski @ 2006-10-11 7:30 UTC (permalink / raw)
To: Ronghua Zhang; +Cc: netdev, davem
On 11-10-2006 01:26, Ronghua Zhang wrote:
...
> The reason I asked this is that I saw the following code in forthdeth
> drvier:
>
> #define NV_TX2_TSO_MAX_SHIFT) 14
> /* add fragments to entries count */
> for (i = 0; i < fragments; i++) {
> entries += (skb_shinfo(skb)->frags[i].size >> NV_TX2_TSO_MAX_SHIFT) +
> ((skb_shinfo(skb)->frags[i].size &
> (NV_TX2_TSO_MAX_SIZE-1)) ? 1 : 0);
> }
>
> This looks unnecessary if each frag is guaranteed not to span pages.
Even if PAGE_SIZE > NV_TX2_TSO_MAX_SIZE?
Jarek P.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2006-10-11 7:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-10 22:37 is each frag of a skb always less than 1 page? Ronghua Zhang
2006-10-10 22:47 ` David Miller
2006-10-10 23:26 ` Ronghua Zhang
2006-10-11 2:10 ` David Miller
2006-10-11 7:30 ` Jarek Poplawski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).