Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2868438lqo; Tue, 14 May 2024 11:36:53 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUBkazeF0dHsM6nEXhvK4UsV9RxmAEbeUcdnjDss7e9Ax2gUF2kZnYUCHLeWz9hD4MO0I/hni81O0ygu9b/f8Jds3ID1EmUxNS9GZifgg== X-Google-Smtp-Source: AGHT+IFeUMRS7Rl/hW2Bo3Wb19h35PdRrzXUSv2lAwVicw+sKubgj5uF0aRhLUizqAnJ1CLSXxAR X-Received: by 2002:a05:6512:4016:b0:51b:5490:1b3a with SMTP id 2adb3069b0e04-522105792ebmr12275706e87.53.1715711813477; Tue, 14 May 2024 11:36:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715711813; cv=pass; d=google.com; s=arc-20160816; b=vsVN5zKBNOrYtXxMj14lrpgo+MTKOymN2xiTjT06WjzTCApkb+3YVYsH1LHmlz3RhE 4lmsxg34j+4qcVdCbi2tOpfQb1esmGFGHqraGHoDOapEwdHed8x3t+GkPIcP0un/z/FD evBqrK8xrF0zqEVuLcG/7Ik7+o3GKiM4HDqUU7ti5xw7GX044oy9q/wCL4NXvQ2txMvy 7ARozFV/NBQTce3G/mQfBEhP7I7GyS2dwaiyndSHzXpCZVoewzE2K/efsTEDbox4770e WjjOUrXUmqa0JwXw2Vf3iaDuP6CEZyumXMUu47hmEJWuTamA0qKAp/6w0HoPOe3qiChF 9Kog== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yMGD/nasxBeFX2CsJttKbWc0owtfw8Nn805YWdp9IS0=; fh=yPyBVueOlV0xh9WIpneyBjPV+wI+YQTxV6XUuh1OKK4=; b=LDvJuJ+5h8BEHXJRuXD7JZHl8IWtFzmamcK7lTobPgbvCDbLrflGDKPVlx3+sY2MJZ 5/DZxsD6/kFE6KsWZ8Li7gV1OZb5j0PhXLxFgxqhJB7dI8aCPlyUxS4lE3JtI3MOKXbD 0G/G6JI2ijxIe4xvzWEK2RnM1mIfdJGX2xxoUhPpRhMxddUmq+FjdfycO4pzfL72XuZS 4gl3gca8tD3PITzPYzm6AmGUZIRQTKP4nMsSKamAAM8onfQbyhd2Nd1a/RtgWC8K13Cz Bdnu00y7XvUbZvL8O2864H3iDJYpdhqPbZYa1Fx4kPyTP/Ia+eBZAf9ayObft8sgO4Bk /BcA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=vmware.com); spf=pass (google.com: domain of linux-kernel+bounces-179062-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-574eccbee9bsi335323a12.593.2024.05.14.11.36.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 11:36:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-179062-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=vmware.com); spf=pass (google.com: domain of linux-kernel+bounces-179062-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-179062-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 351FA1F22CE8 for ; Tue, 14 May 2024 18:36:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9DBCA18131F; Tue, 14 May 2024 18:36:27 +0000 (UTC) Received: from EX-PRD-EDGE01.vmware.com (EX-PRD-EDGE01.vmware.com [208.91.3.33]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 763AB180A61; Tue, 14 May 2024 18:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=208.91.3.33 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715711787; cv=none; b=K1uBsSGlu7dxkoelRD3lX9EMOQQko6/OGsDeZw2GfMFs4BdtHtrCZUZvJehXt6yK+aYrFBDjvuKRpaLk8qmevpFvmtRyq1zIZNag6EQS+vRUc8o2xJCQijTzJYZ/sp5bcGCRf1Z3eiEI8Xw0+Ib5MKKXh49s0m9Sqg93nawGLko= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715711787; c=relaxed/simple; bh=UaV11EJDKhayJ4pE+bHk6XCQKZJIPyUBdUfILaFIwEY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E8/BaDKsFay1DtD7wgIaMWSZUr3LTV2+yvFu2B5RTfPC6JNEjBXQtMsFAecK6Lw+7jTBK4MakZijAX77ALcAuw64DU2dLnOGsbkaUFOnA1uW98R0dSJ1Qwo9G08F0bXm5G2ycFjrKd++LaxeJKXQxxF+CyjlG4uo4tzOByjauBg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=broadcom.com; spf=pass smtp.mailfrom=vmware.com; arc=none smtp.client-ip=208.91.3.33 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=vmware.com Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX-PRD-EDGE01.vmware.com (10.188.245.6) with Microsoft SMTP Server id 15.1.2375.34; Tue, 14 May 2024 11:20:59 -0700 Received: from htb-1n-eng-dhcp122.eng.vmware.com (unknown [10.172.6.252]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id AADF6202D7; Tue, 14 May 2024 11:21:07 -0700 (PDT) Received: by htb-1n-eng-dhcp122.eng.vmware.com (Postfix, from userid 0) id A8FA1AECCE; Tue, 14 May 2024 11:21:07 -0700 (PDT) From: Ronak Doshi To: CC: Ronak Doshi , Broadcom internal kernel review list , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , open list Subject: [PATCH net-next 3/4] vmxnet3: add command to allow disabling of offloads Date: Tue, 14 May 2024 11:20:48 -0700 Message-ID: <20240514182050.20931-4-ronak.doshi@broadcom.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20240514182050.20931-1-ronak.doshi@broadcom.com> References: <20240514182050.20931-1-ronak.doshi@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain Received-SPF: SoftFail (EX-PRD-EDGE01.vmware.com: domain of transitioning ronak.doshi@broadcom.com discourages use of 10.113.161.72 as permitted sender) This patch adds a new command to disable certain offloads. This allows user to specify, using VM configuration, if certain offloads need to be disabled. Signed-off-by: Ronak Doshi Acked-by: Guolin Yang --- drivers/net/vmxnet3/vmxnet3_defs.h | 4 ++++ drivers/net/vmxnet3/vmxnet3_drv.c | 19 +++++++++++++++++++ drivers/net/vmxnet3/vmxnet3_ethtool.c | 8 ++++++++ drivers/net/vmxnet3/vmxnet3_int.h | 1 + 4 files changed, 32 insertions(+) diff --git a/drivers/net/vmxnet3/vmxnet3_defs.h b/drivers/net/vmxnet3/vmxnet3_defs.h index dcf1cf8e7a86..5e56e1d42f77 100644 --- a/drivers/net/vmxnet3/vmxnet3_defs.h +++ b/drivers/net/vmxnet3/vmxnet3_defs.h @@ -126,6 +126,7 @@ enum { VMXNET3_CMD_GET_MAX_CAPABILITIES, VMXNET3_CMD_GET_DCR0_REG, VMXNET3_CMD_GET_TSRING_DESC_SIZE, + VMXNET3_CMD_GET_DISABLED_OFFLOADS, }; /* @@ -912,4 +913,7 @@ struct Vmxnet3_DriverShared { /* when new capability is introduced, update VMXNET3_CAP_MAX */ #define VMXNET3_CAP_MAX VMXNET3_CAP_VERSION_7_MAX +#define VMXNET3_OFFLOAD_TSO (1 << 0) +#define VMXNET3_OFFLOAD_LRO (1 << 1) + #endif /* _VMXNET3_DEFS_H_ */ diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c index 74cb63e3d311..2eaa9204c38e 100644 --- a/drivers/net/vmxnet3/vmxnet3_drv.c +++ b/drivers/net/vmxnet3/vmxnet3_drv.c @@ -3646,6 +3646,15 @@ static void vmxnet3_declare_features(struct vmxnet3_adapter *adapter) { struct net_device *netdev = adapter->netdev; + unsigned long flags; + + if (VMXNET3_VERSION_GE_9(adapter)) { + spin_lock_irqsave(&adapter->cmd_lock, flags); + VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, + VMXNET3_CMD_GET_DISABLED_OFFLOADS); + adapter->disabledOffloads = VMXNET3_READ_BAR1_REG(adapter, VMXNET3_REG_CMD); + spin_unlock_irqrestore(&adapter->cmd_lock, flags); + } netdev->hw_features = NETIF_F_SG | NETIF_F_RXCSUM | NETIF_F_HW_CSUM | NETIF_F_HW_VLAN_CTAG_TX | @@ -3663,6 +3672,16 @@ vmxnet3_declare_features(struct vmxnet3_adapter *adapter) NETIF_F_GSO_UDP_TUNNEL_CSUM; } + if (adapter->disabledOffloads & VMXNET3_OFFLOAD_TSO) { + netdev->hw_features &= ~(NETIF_F_TSO | NETIF_F_TSO6); + netdev->hw_enc_features &= ~(NETIF_F_TSO | NETIF_F_TSO6); + } + + if (adapter->disabledOffloads & VMXNET3_OFFLOAD_LRO) { + netdev->hw_features &= ~(NETIF_F_LRO); + netdev->hw_enc_features &= ~(NETIF_F_LRO); + } + if (VMXNET3_VERSION_GE_7(adapter)) { unsigned long flags; diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c index 471f91c4204a..b78cda41f643 100644 --- a/drivers/net/vmxnet3/vmxnet3_ethtool.c +++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c @@ -270,6 +270,14 @@ netdev_features_t vmxnet3_fix_features(struct net_device *netdev, if (!(features & NETIF_F_RXCSUM)) features &= ~NETIF_F_LRO; + if ((features & NETIF_F_LRO) && + (adapter->disabledOffloads & VMXNET3_OFFLOAD_LRO)) + features &= ~NETIF_F_LRO; + + if ((features & (NETIF_F_TSO | NETIF_F_TSO6)) && + (adapter->disabledOffloads & VMXNET3_OFFLOAD_TSO)) + features &= ~(NETIF_F_TSO | NETIF_F_TSO6); + /* If XDP is enabled, then LRO should not be enabled */ if (vmxnet3_xdp_enabled(adapter) && (features & NETIF_F_LRO)) { netdev_err(netdev, "LRO is not supported with XDP"); diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h index 68358e71526c..31e8db568db2 100644 --- a/drivers/net/vmxnet3/vmxnet3_int.h +++ b/drivers/net/vmxnet3/vmxnet3_int.h @@ -454,6 +454,7 @@ struct vmxnet3_adapter { /* Size of buffer in the ts ring */ u16 tx_ts_desc_size; u16 rx_ts_desc_size; + u32 disabledOffloads; }; #define VMXNET3_WRITE_BAR0_REG(adapter, reg, val) \ -- 2.11.0