From patchwork Thu Apr 20 19:17:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladislav Yasevich X-Patchwork-Id: 752976 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3w87tN6566z9s78 for ; Fri, 21 Apr 2017 05:17:48 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="BEqHJKjm"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S947017AbdDTTRk (ORCPT ); Thu, 20 Apr 2017 15:17:40 -0400 Received: from mail-qt0-f193.google.com ([209.85.216.193]:36676 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S947006AbdDTTRh (ORCPT ); Thu, 20 Apr 2017 15:17:37 -0400 Received: by mail-qt0-f193.google.com with SMTP id t52so8927807qtb.3 for ; Thu, 20 Apr 2017 12:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Ps39eYuQneATf5skKS4oDksC5kQryARwA2tXyT+ySeo=; b=BEqHJKjmALy+MTASGlofgXViarTvetUqM/e6Vt2fNgnUDAqg004d3vAVzN8ZBen0XE H0+RmfsXF4LBKUubJkYmslcj+GcEk+wRKoQeJEBUZ2w63XuQzEldLJh+OmykfwhhDU3J zoTV9p1DA1ARWJraqE6ZhEk97hs8BHjtwbkciuOQDXeek3sBOGxBZsZAbAa51Ew50ace L/TXYeKhrlrNkysb7s4GjErUwDy7txinMJYrnCxeprkVPNQjXEXmq27Y6ajfiFv1omtZ YE6hKh3R1HEHDzYuVAp7WyI2FVXXTONrLRphs4F5XerMI3bn0O+qGSO7c0doEV64lOD5 HakA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ps39eYuQneATf5skKS4oDksC5kQryARwA2tXyT+ySeo=; b=Kk3nqg5fi9SHpGrbHrMnV8qzcfiis7OePHx6gEXl/ATY4rl5dE/FqAHnmXAEkkfBOb UT1JNSx5qcwH/wfa753K0sfqkMBNP6Ou+iT6m/TrIZE2thpJEKG9D0IP3y9C/NDfUfBz I+9hOGQpOtUbAtHtYVPa5oBbn2CnvOfJ9CsIBii7qbHMV4xgPFVL2lHclV6LHID0KDCv pufTWWs5UnIShK3rgKQ3Ak5yt24tg50m/hZdFyN3tnPVVvDVGxZAzgANS/U4pS977S34 9kYNsF5rhs7rcPm69UVHkYAenF05YL3azXI+YEE+qIpb0H6cvqLRfSnUVZ6EOgbq+U7P WKuA== X-Gm-Message-State: AN3rC/451gZ9fOrmmfWOea9Su9QZADKVfBU2f3C06oGSBbun1ccJLjmz H78gTtzXQXEhXg== X-Received: by 10.237.49.9 with SMTP id 9mr9222828qtg.291.1492715851242; Thu, 20 Apr 2017 12:17:31 -0700 (PDT) Received: from flash.redhat.com (pool-71-169-167-36.burl.east.myfairpoint.net. [71.169.167.36]) by smtp.gmail.com with ESMTPSA id z63sm3395106qkc.6.2017.04.20.12.17.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Apr 2017 12:17:30 -0700 (PDT) From: Vladislav Yasevich X-Google-Original-From: Vladislav Yasevich To: netdev@vger.kernel.org Cc: Vladislav Yasevich , Michal Kubecek , Alexander Duyck , Tom Herbert Subject: [PATCH V2 net] netdevice: Include NETIF_F_HW_CSUM when intersecting features Date: Thu, 20 Apr 2017 15:17:24 -0400 Message-Id: <1492715844-30273-1-git-send-email-vyasevic@redhat.com> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 CC: Alexander Duyck CC: Tom Herbert Signed-off-by: Vladislav Yasevich --- 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;