[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1225838743.6116.20.camel@fry>
Date: Tue, 04 Nov 2008 23:45:43 +0100
From: Johann Baudy <johaahn@...il.com>
To: "Lovich, Vitali" <vlovich@...lcomm.com>
Cc: "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
Evgeniy Polyakov <zbr@...emap.net>
Subject: RE: [PATCH] Packet socket: mmapped IO: PACKET_TX_RING
Hi Vitali,
> Here's the code I came up with to determine the offset - anyone see any problems?
>
> union {
> tpacket2_hdr *t2;
> u8 *raw;
> }
>
> struct page *first_frag;
> u32 page_offset;
>
> first_frag = skb_shinfo(skb)->frags[0].page;
> page_offset = skb_shinfo(skb)->frags[0].page_offset;
>
> page_offset -= (skb_headlen(skb) + sizeof(struct tpacket2_hdr));
> if (unlikely(page_offset < 0)) {
> first_frag--;
> page_offset += PAGE_SIZE;
> }
> frame.raw = page_address(first_frag) + page_offset;
>
This won't work if your network card doesn't support Scatter/Gather IO.
Indeed, when SG is not supported, fragmented packets are linearized
after dev_queue_xmit() call. Thus addresses of pages are then lost.
Best regards,
Johann
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists