From: John Fastabend <john.r.fastabend@intel.com>
To: Jesse Gross <jesse@nicira.com>
Cc: David Miller <davem@davemloft.net>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: [PATCH v2 04/14] vlan: Enable software emulation for vlan accleration.
Date: Wed, 20 Oct 2010 20:32:12 -0700 [thread overview]
Message-ID: <4CBFB43C.6000501@intel.com> (raw)
In-Reply-To: <1287618974-4714-5-git-send-email-jesse@nicira.com>
On 10/20/2010 4:56 PM, Jesse Gross wrote:
> Currently users of hardware vlan accleration need to know whether
> the device supports it before generating packets. However, vlan
> acceleration will soon be available in a more flexible manner so
> knowing ahead of time becomes much more difficult. This adds
> a software fallback path for vlan packets on devices without the
> necessary offloading support, similar to other types of hardware
> accleration.
>
> Signed-off-by: Jesse Gross <jesse@nicira.com>
> ---
> include/linux/netdevice.h | 14 +++++++++++---
> net/core/dev.c | 36 +++++++++++++++++++++++++++++++++---
> 2 files changed, 44 insertions(+), 6 deletions(-)
>
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 880d565..2861565 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -2248,9 +2248,17 @@ static inline int skb_gso_ok(struct sk_buff *skb, int features)
>
> static inline int netif_needs_gso(struct net_device *dev, struct sk_buff *skb)
> {
> - return skb_is_gso(skb) &&
> - (!skb_gso_ok(skb, dev->features) ||
> - unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
> + if (skb_is_gso(skb)) {
> + int features = dev->features;
> +
> + if (skb->protocol == htons(ETH_P_8021Q) || skb->vlan_tci)
> + features &= dev->vlan_features;
> +
> + return (!skb_gso_ok(skb, features) ||
> + unlikely(skb->ip_summed != CHECKSUM_PARTIAL));
> + }
> +
> + return 0;
> }
>
> static inline void netif_set_gso_max_size(struct net_device *dev,
> diff --git a/net/core/dev.c b/net/core/dev.c
> index 4c3ac53..1bfd96b 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -1694,7 +1694,12 @@ static bool can_checksum_protocol(unsigned long features, __be16 protocol)
>
> static bool dev_can_checksum(struct net_device *dev, struct sk_buff *skb)
> {
> - if (can_checksum_protocol(dev->features, skb->protocol))
> + int features = dev->features;
> +
> + if (vlan_tx_tag_present(skb))
> + features &= dev->vlan_features;
> +
> + if (can_checksum_protocol(features, skb->protocol))
> return true;
>
> if (skb->protocol == htons(ETH_P_8021Q)) {
> @@ -1793,6 +1798,16 @@ struct sk_buff *skb_gso_segment(struct sk_buff *skb, int features)
> __be16 type = skb->protocol;
> int err;
>
> + if (type == htons(ETH_P_8021Q)) {
> + struct vlan_ethhdr *veh;
> +
> + if (unlikely(!pskb_may_pull(skb, VLAN_ETH_HLEN)))
> + return ERR_PTR(-EINVAL);
> +
> + veh = (struct vlan_ethhdr *)skb->data;
> + type = veh->h_vlan_encapsulated_proto;
> + }
> +
> skb_reset_mac_header(skb);
> skb->mac_len = skb->network_header - skb->mac_header;
> __skb_pull(skb, skb->mac_len);
> @@ -1964,9 +1979,14 @@ static inline void skb_orphan_try(struct sk_buff *skb)
> static inline int skb_needs_linearize(struct sk_buff *skb,
> struct net_device *dev)
> {
> + int features = dev->features;
> +
> + if (skb->protocol == htons(ETH_P_8021Q) || vlan_tx_tag_present(skb))
> + features &= dev->vlan_features;
> +
> return skb_is_nonlinear(skb) &&
> - ((skb_has_frag_list(skb) && !(dev->features & NETIF_F_FRAGLIST)) ||
> - (skb_shinfo(skb)->nr_frags && (!(dev->features & NETIF_F_SG) ||
> + ((skb_has_frag_list(skb) && !(features & NETIF_F_FRAGLIST)) ||
> + (skb_shinfo(skb)->nr_frags && (!(features & NETIF_F_SG) ||
> illegal_highdma(dev, skb))));
> }
>
> @@ -1989,6 +2009,15 @@ int dev_hard_start_xmit(struct sk_buff *skb, struct net_device *dev,
>
> skb_orphan_try(skb);
>
> + if (vlan_tx_tag_present(skb) &&
> + !(dev->features & NETIF_F_HW_VLAN_TX)) {
> + skb = __vlan_put_tag(skb, vlan_tx_tag_get(skb));
> + if (unlikely(!skb))
> + goto out;
> +
> + skb->vlan_tci = 0;
> + }
> +
Nice set of patches! If we tag frames in dev_hard_start_xmit() can we consolidate
the offload enabled and non-offloaded net_device_ops in 8021q. And then not tag in
vlan_dev_hard_start_xmit? I'll post an example thinking out loud here.
Thanks,
John.
> if (netif_needs_gso(dev, skb)) {
> if (unlikely(dev_gso_segment(skb)))
> goto out_kfree_skb;
> @@ -2050,6 +2079,7 @@ out_kfree_gso_skb:
> skb->destructor = DEV_GSO_CB(skb)->destructor;
> out_kfree_skb:
> kfree_skb(skb);
> +out:
> return rc;
> }
>
next prev parent reply other threads:[~2010-10-21 3:32 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-20 23:56 [PATCH v2 00/14] Move vlan acceleration into networking core Jesse Gross
2010-10-20 23:56 ` [PATCH v2 01/14] ebtables: Allow filtering of hardware accelerated vlan frames Jesse Gross
2010-10-20 23:56 ` [PATCH v2 02/14] vlan: Rename VLAN_GROUP_ARRAY_LEN to VLAN_N_VID Jesse Gross
2010-10-20 23:56 ` [PATCH v2 03/14] vlan: Don't check for vlan group before vlan_tx_tag_present Jesse Gross
2010-10-20 23:56 ` [PATCH v2 04/14] vlan: Enable software emulation for vlan accleration Jesse Gross
2010-10-21 3:32 ` John Fastabend [this message]
2010-10-21 15:30 ` Ben Hutchings
2010-10-21 21:44 ` Jesse Gross
2010-10-22 14:12 ` [PATCH net-next-2.6] net: Fix some corner cases in dev_can_checksum() Ben Hutchings
2010-10-22 14:18 ` Ben Hutchings
2010-10-26 0:21 ` Jesse Gross
2010-10-26 13:29 ` Ben Hutchings
2010-10-26 18:11 ` Jesse Gross
2010-10-27 18:00 ` David Miller
2010-10-20 23:56 ` [PATCH v2 05/14] vlan: Avoid hash table lookup to find group Jesse Gross
2010-10-20 23:56 ` [PATCH v2 06/14] vlan: Centralize handling of hardware acceleration Jesse Gross
2010-10-20 23:56 ` [PATCH v2 07/14] ethtool: Add support for vlan accleration Jesse Gross
2010-10-21 3:27 ` John Fastabend
2010-10-21 19:43 ` Jesse Gross
2010-10-20 23:56 ` [PATCH v2 08/14] bridge: Add support for TX vlan offload Jesse Gross
2010-10-20 23:56 ` [PATCH v2 09/14] bnx2: Update bnx2 to use new vlan accleration Jesse Gross
2010-10-21 15:31 ` Ben Hutchings
2010-10-21 21:38 ` Jesse Gross
2010-10-20 23:56 ` [PATCH v2 10/14] ixgbe: Update ixgbe " Jesse Gross
2010-10-22 13:24 ` Michał Mirosław
2010-10-25 17:50 ` Peter P Waskiewicz Jr
2010-10-25 21:40 ` Michał Mirosław
2010-10-25 22:02 ` John Fastabend
2010-10-25 23:23 ` Michał Mirosław
2010-10-26 0:08 ` Jesse Gross
2010-10-20 23:56 ` [PATCH v2 11/14] bnx2x: Update bnx2x " Jesse Gross
2010-10-21 13:54 ` Vladislav Zolotarov
2010-10-21 14:02 ` Vladislav Zolotarov
2010-10-21 14:50 ` Vladislav Zolotarov
2010-10-21 21:36 ` Jesse Gross
2010-10-22 0:57 ` Dmitry Kravkov
2010-10-24 9:21 ` Vladislav Zolotarov
2010-10-24 10:11 ` Vladislav Zolotarov
2010-10-26 0:29 ` Jesse Gross
2010-10-26 9:14 ` Vladislav Zolotarov
2010-10-26 17:57 ` Jesse Gross
2010-10-21 21:34 ` Jesse Gross
2010-10-20 23:56 ` [PATCH v2 12/14] lro: Remove explicit vlan support Jesse Gross
2010-10-20 23:56 ` [PATCH v2 13/14] bonding: Update bonding for new vlan model Jesse Gross
2010-10-20 23:56 ` [PATCH v2 14/14] vlan: Remove accleration legacy functions Jesse Gross
2010-10-21 2:02 ` [PATCH v2 00/14] Move vlan acceleration into networking core David Dillow
2010-10-21 19:32 ` Jesse Gross
2010-10-21 8:33 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4CBFB43C.6000501@intel.com \
--to=john.r.fastabend@intel.com \
--cc=davem@davemloft.net \
--cc=jesse@nicira.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).