From patchwork Thu Dec 7 08:03:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 845450 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=broadcom.com header.i=@broadcom.com header.b="YWlLjQ1C"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3ysp0D5rrNz9s9Y for ; Thu, 7 Dec 2017 19:03:56 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752325AbdLGIDy (ORCPT ); Thu, 7 Dec 2017 03:03:54 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:46888 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752282AbdLGIDx (ORCPT ); Thu, 7 Dec 2017 03:03:53 -0500 Received: by mail-qt0-f195.google.com with SMTP id r39so15393807qtr.13 for ; Thu, 07 Dec 2017 00:03:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=rzGtTC6A5pbYEz8q/j7096gwRKZFZsp2BdKcXOWyvIA=; b=YWlLjQ1CgiaLlMy97tXFVtN8tNz9RGP/dyiJgTjef2MO75DuxdXyaIzchzPMBLES5L iL+ww5hVOLVYbapfB2ZvH3gSKpP1RAfNkQUXfSaoOOpr0cWcPkfAdQNLkiS2KFrW2VMH wsha+cv2Q6TeKyaLVKhTZH2/GEtyDhnFkO7RM= 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:in-reply-to :references; bh=rzGtTC6A5pbYEz8q/j7096gwRKZFZsp2BdKcXOWyvIA=; b=G0PUZtkDXPB+8Cf4tjv22hUbYcpr836XBn8XVGNfOEZi3t/61XziwC5m2wAMKCouVD onAPI8tsAMhi5nbY4Uz/AQl6T7ixA0+nUO4/q8zLXaxQ0md6631eP9AmkYo8GBujhYv9 sj7OTKdHGVxYnfns9c/UqHrAlzBseJqhxIbs9ZL/1RpTUQ9AsgwmUtohD2YLGbOUcW/2 MXKcOQbBOT2ciAZz45C42FwgzvSy66UiM77JUhFO/ubI5kw7mY82uZDPV9OQT40QNfJP dRXoNEgLQ6A293XIYga/h0LEpPr5xSuOuX4D/4e3R1cUUQiz8bU1Y8N/NFDJceGOR5U7 m0fQ== X-Gm-Message-State: AKGB3mKB6/6Bmlr0YgX9dNKGnWKuxfYNmRqeN1wO2r7NDmfo7LBpu3IM DU5sT5d3iWKCOOJl+K+/Xz49WA== X-Google-Smtp-Source: AGs4zMbWZvF+D96jrRzcDOc6W13pFEJ75inKUTCamj9w4JakZ9HYge9ncuMJZ7dj1ad8H6T0giig3A== X-Received: by 10.55.27.88 with SMTP id b85mr28771497qkb.144.1512633832350; Thu, 07 Dec 2017 00:03:52 -0800 (PST) Received: from localhost.dhcp.broadcom.net ([192.19.255.250]) by smtp.gmail.com with ESMTPSA id n3sm2818192qte.14.2017.12.07.00.03.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 00:03:51 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, andrew.gospodarek@broadcom.com, Ariel Elior , everest-linux-l2@cavium.com Subject: [PATCH net-next v2 1/5] net: Introduce NETIF_F_GRO_HW. Date: Thu, 7 Dec 2017 03:03:31 -0500 Message-Id: <1512633815-25037-2-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1512633815-25037-1-git-send-email-michael.chan@broadcom.com> References: <1512633815-25037-1-git-send-email-michael.chan@broadcom.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Introduce NETIF_F_GRO_HW feature flag for NICs that support hardware GRO. With this flag, we can now independently turn on or off hardware GRO when GRO is on. Previously, drivers were using NETIF_F_GRO to control hardware GRO and so it cannot be independently turned on or off without affecting GRO. Hardware GRO (just like GRO) guarantees that packets can be re-segmented by TSO/GSO to reconstruct the original packet stream. It is a subset of NETIF_F_GRO and depends on it Since NETIF_F_GRO is not propagated between upper and lower devices, NETIF_F_GRO_HW should follow suit since it is a subset of GRO. In other words, a lower device can independent have GRO/GRO_HW enabled or disabled and no feature propagation is required. This will preserve the current GRO behavior. Cc: Ariel Elior Cc: everest-linux-l2@cavium.com Signed-off-by: Michael Chan --- Documentation/networking/netdev-features.txt | 8 ++++++++ include/linux/netdev_features.h | 3 +++ net/core/dev.c | 17 +++++++++++++++++ net/core/ethtool.c | 1 + 4 files changed, 29 insertions(+) diff --git a/Documentation/networking/netdev-features.txt b/Documentation/networking/netdev-features.txt index 7413eb0..8f36527 100644 --- a/Documentation/networking/netdev-features.txt +++ b/Documentation/networking/netdev-features.txt @@ -163,3 +163,11 @@ This requests that the NIC receive all possible frames, including errored frames (such as bad FCS, etc). This can be helpful when sniffing a link with bad packets on it. Some NICs may receive more packets if also put into normal PROMISC mode. + +* rx-gro-hw + +This requests that the NIC enables Hardware GRO (generic receive offload). +Hardware GRO is basically the exact reverse of TSO, and is generally +stricter than Hardware LRO. A packet stream merged by Hardware GRO must +be re-segmentable by GSO or TSO back to the exact original packet stream. +Hardware GRO is dependent on GRO and RXCSUM. diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h index b1b0ca7..db84c51 100644 --- a/include/linux/netdev_features.h +++ b/include/linux/netdev_features.h @@ -78,6 +78,8 @@ enum { NETIF_F_HW_ESP_TX_CSUM_BIT, /* ESP with TX checksum offload */ NETIF_F_RX_UDP_TUNNEL_PORT_BIT, /* Offload of RX port for UDP tunnels */ + NETIF_F_GRO_HW_BIT, /* Hardware Generic receive offload */ + /* * Add your fresh new feature above and remember to update * netdev_features_strings[] in net/core/ethtool.c and maybe @@ -97,6 +99,7 @@ enum { #define NETIF_F_FRAGLIST __NETIF_F(FRAGLIST) #define NETIF_F_FSO __NETIF_F(FSO) #define NETIF_F_GRO __NETIF_F(GRO) +#define NETIF_F_GRO_HW __NETIF_F(GRO_HW) #define NETIF_F_GSO __NETIF_F(GSO) #define NETIF_F_GSO_ROBUST __NETIF_F(GSO_ROBUST) #define NETIF_F_HIGHDMA __NETIF_F(HIGHDMA) diff --git a/net/core/dev.c b/net/core/dev.c index 6bea893..7242e5e 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -7405,6 +7405,23 @@ static netdev_features_t netdev_fix_features(struct net_device *dev, features &= ~dev->gso_partial_features; } + if (features & NETIF_F_GRO_HW) { + /* Hardware GRO depends on GRO and RXCSUM. */ + if (!(features & NETIF_F_GRO)) { + netdev_dbg(dev, "Dropping NETIF_F_GSO_HW since no GRO feature.\n"); + features &= ~NETIF_F_GRO_HW; + } + if (!(features & NETIF_F_RXCSUM)) { + netdev_dbg(dev, "Dropping NETIF_F_GSO_HW since no RXCSUM feature.\n"); + features &= ~NETIF_F_GRO_HW; + } + /* Hardware GRO and LRO are mutually exclusive. */ + if (features & NETIF_F_LRO) { + netdev_dbg(dev, "Dropping NETIF_F_LRO since GRO_HW is set.\n"); + features &= ~NETIF_F_LRO; + } + } + return features; } diff --git a/net/core/ethtool.c b/net/core/ethtool.c index f8fcf45..50a7920 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -73,6 +73,7 @@ int ethtool_op_get_ts_info(struct net_device *dev, struct ethtool_ts_info *info) [NETIF_F_LLTX_BIT] = "tx-lockless", [NETIF_F_NETNS_LOCAL_BIT] = "netns-local", [NETIF_F_GRO_BIT] = "rx-gro", + [NETIF_F_GRO_HW_BIT] = "rx-gro-hw", [NETIF_F_LRO_BIT] = "rx-lro", [NETIF_F_TSO_BIT] = "tx-tcp-segmentation",