From: Vladislav Yasevich <vyasevich@gmail.com>
To: netdev@vger.kernel.org
Cc: Vladislav Yasevich <vyasevic@redhat.com>,
Michal Kubecek <mkubecek@suse.cz>,
Alexander Duyck <alexander.duyck@gmail.com>,
Tom Herbert <tom@herbertland.com>
Subject: [PATCH V2 net] netdevice: Include NETIF_F_HW_CSUM when intersecting features
Date: Thu, 20 Apr 2017 15:17:24 -0400 [thread overview]
Message-ID: <1492715844-30273-1-git-send-email-vyasevic@redhat.com> (raw)
While hardware device use either NETIF_F_(IP|IPV6)_CSUM or
NETIF_F_HW_CSUM, all of the software devices use HW_CSUM.
This results in an interesting situation when the software
device is configured on top of hw device using (IP|IPV6)_CSUM.
In this situation, the user can't turn off checksum offloading
features on the software device.
This patch resolves that by adding NETIF_F_HW_CSUM to the mask
if a feature set includes only IP|IPV6 csum. This allows the user
to control the upper (software) device checksum, while at the same
time correctly propagating lower device changes up.
CC: Michal Kubecek <mkubecek@suse.cz>
CC: Alexander Duyck <alexander.duyck@gmail.com>
CC: Tom Herbert <tom@herbertland.com>
Signed-off-by: Vladislav Yasevich <vyasevic@redhat.com>
---
V2: Addressed comments from Alex Duyck. I tested this with hacked virtio
device that set IP|IPV6 checksums instead of HW. Configuring a vlan on
top gave the vlan device with 'ip-generic: on' setting (using HW checksum).
This allows me to change vlan checksum offloads independent of virt-io nic.
Changes to virtio-nic propagated up to vlan, turning off the offloading
correctly.
include/linux/netdevice.h | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index b0aa089..81aed2f 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -4009,10 +4009,10 @@ static inline netdev_features_t netdev_intersect_features(netdev_features_t f1,
netdev_features_t f2)
{
if ((f1 ^ f2) & NETIF_F_HW_CSUM) {
- if (f1 & NETIF_F_HW_CSUM)
- f1 |= (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM);
- else
- f2 |= (NETIF_F_IP_CSUM|NETIF_F_IPV6_CSUM);
+ if (f1 & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))
+ f1 |= NETIF_F_HW_CSUM;
+ if(f2 & (NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM))
+ f2 |= NETIF_F_HW_CSUM;
}
return f1 & f2;
--
2.7.4
next reply other threads:[~2017-04-20 19:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-20 19:17 Vladislav Yasevich [this message]
2017-04-20 22:31 ` [PATCH V2 net] netdevice: Include NETIF_F_HW_CSUM when intersecting features Alexander Duyck
2017-04-20 23:19 ` Vlad Yasevich
2017-04-21 3:06 ` Alexander Duyck
2017-04-21 5:33 ` Michal Kubecek
2017-04-21 17:33 ` Vladislav Yasevich
2017-04-21 18:53 ` Alexander Duyck
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=1492715844-30273-1-git-send-email-vyasevic@redhat.com \
--to=vyasevich@gmail.com \
--cc=alexander.duyck@gmail.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=tom@herbertland.com \
--cc=vyasevic@redhat.com \
/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).