Thread (12 messages) flat view 12 messages, 6 authors, 2012-12-11

Re: [PATCH v4 1/5] net: Add support for hardware-offloaded encapsulation

From: saeed bishara <hidden>
Date: 2012-12-11 08:11:56
Also in: lkml

On Mon, Dec 10, 2012 at 9:58 PM, Dmitry Kravkov [off-list ref] wrote:
quoted
-----Original Message-----
From: saeed bishara [mailto:saeed.bishara@gmail.com]
Sent: Monday, December 10, 2012 12:04 PM
To: Joseph Gasparakis
Cc: davem@davemloft.net; shemminger@vyatta.com; chrisw@sous-sol.org;
gospo@redhat.com; netdev@vger.kernel.org; linux-kernel@vger.kernel.org;
Dmitry Kravkov; bhutchings@solarflare.com; Peter P Waskiewicz Jr; Alexander
Duyck
Subject: Re: [PATCH v4 1/5] net: Add support for hardware-offloaded
encapsulation
quoted
+static inline struct iphdr *inner_ip_hdr(const struct sk_buff *skb)
+{
+       return (struct iphdr *)skb_inner_network_header(skb);
+}
Hi,
I'm a little bit bothered because of those inner_ functions, what
about the following approach:
1. the skb will have a new state, that state can be outer (normal
mode) and inner.
2. when you change the state to inner, all the helper functions such
as ip_hdr will return the innter header.

that's ofcourse the API side. the implementation may still use the
fields you added to the skb.

what you think?
saeed
Some drivers will probably need both inner_ and other_ in same flow, switching between two states will consume cpu cycles.
from performance perspective, I'm not sure the switching is worse, it
may be better as it reduces code size. please have a look at patch
2/5, with switching you can avoid doing the following change -> less
code, less if-else.
-                               skb_set_transport_header(skb,
-                                       skb_checksum_start_offset(skb));
+                               if (skb->encapsulation)
+                                       skb_set_inner_transport_header(skb,
+                                               skb_checksum_start_offset(skb));
+                               else
+                                       skb_set_transport_header(skb,
+                                               skb_checksum_start_offset(skb));
                                if (!(features & NETIF_F_ALL_CSUM) &&

I think also that from (stack) maintenance perspective, less code is better.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help