From patchwork Thu Apr 2 11:37:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1265535 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48tLdp189lz9sSJ; Thu, 2 Apr 2020 22:37:32 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jJyA2-0002Eh-NT; Thu, 02 Apr 2020 11:37:26 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA0-0002E3-NY for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:24 +0000 Received: from mail-qv1-f72.google.com ([209.85.219.72]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA0-000606-DU for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:24 +0000 Received: by mail-qv1-f72.google.com with SMTP id f12so2447853qvw.1 for ; Thu, 02 Apr 2020 04:37:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gOQMEI0+iDQbKlOkIobWR/agunjxfb+PHklmG/wvHaY=; b=n7VbQ4PHn+xyc1nstW1dBN3SpP8BoXJ6SDavzDT3dEHzrrHwed07yWjkvTawIzuACb TS6TE86J1BJOD1WNpLjsbsgUAX9w0/+Us55S8gWvbPJ7wWBKj0yBgkjVdhlxJ21QyeFJ ojtuNyXmuNf1M8Y7tUaxOeNlI85vN5o2U7+scPizr9kgs+N68AXEw6rXWlmxS2+ye6ln CoKtqrkb1oCIqAn9dB7R++vsGzVktZxlltkVsUrNJKRVCtmxwegSdebiO1bDVoxWjCIT rBhHiGTuehdGsnXNib5poZAILgxoZUHdb0MAWIcBXBTLKkfuulodDxfI3DlWxiB6iF+o iZhg== X-Gm-Message-State: AGi0PuYjLMJK/t8SIfU5SHCG6+kA4wYUrELDNknUnX8ZAxpdG0xcTZt+ 8wQTXfGjR/uyGUFdOTtS0W6d6bdfgawYAhXN6a7C4hwtMlfygV/77Ix3ZjjteRt8h4/5EPIzEg6 htZ+MpxL9w9uEf0PDtWD8vvFU7C/LbzPLeSaJjw71 X-Received: by 2002:ae9:efce:: with SMTP id d197mr2829184qkg.211.1585827443097; Thu, 02 Apr 2020 04:37:23 -0700 (PDT) X-Google-Smtp-Source: APiQypKz3BTG8L+yHWjH5w2xhMORmEOtaWLTNtcGBorl9Th+jm6LUBjZL7cIGLt+TyKc1W8uvl6yoA== X-Received: by 2002:ae9:efce:: with SMTP id d197mr2829166qkg.211.1585827442800; Thu, 02 Apr 2020 04:37:22 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e6:352:b906:503c:ddec:3d6e]) by smtp.gmail.com with ESMTPSA id f13sm3579353qte.53.2020.04.02.04.37.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 04:37:22 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [xenial:linux-azure][PATCH 1/6] hv_netvsc: Fix tx_table init in rndis_set_subchannel() Date: Thu, 2 Apr 2020 08:37:11 -0300 Message-Id: <20200402113716.20490-2-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200402113716.20490-1-marcelo.cerri@canonical.com> References: <20200402113716.20490-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: http://bugs.launchpad.net/bugs/1864233 Host can provide send indirection table messages anytime after RSS is enabled by calling rndis_filter_set_rss_param(). So the host provided table values may be overwritten by the initialization in rndis_set_subchannel(). To prevent this problem, move the tx_table initialization before calling rndis_filter_set_rss_param(). Fixes: a6fb6aa3cfa9 ("hv_netvsc: Set tx_table to equal weight after subchannels open") Signed-off-by: Haiyang Zhang Signed-off-by: Jakub Kicinski (backported from commit c39ea5cba5a2e97fc01b78c85208bf31383b399c) [marcelo.cerri@canonical.com: Fixed context] Signed-off-by: Marcelo Henrique Cerri --- drivers/net/hyperv/rndis_filter.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index e630c3e1410e..934f9901c50e 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -1107,15 +1107,15 @@ int rndis_set_subchannel(struct net_device *ndev, struct netvsc_device *nvdev) wait_event(nvdev->subchan_open, atomic_read(&nvdev->open_chn) == nvdev->num_chn); + for (i = 0; i < VRSS_SEND_TAB_SIZE; i++) + ndev_ctx->tx_table[i] = i % nvdev->num_chn; + /* ignore failues from setting rss parameters, still have channels */ rndis_filter_set_rss_param(rdev, netvsc_hash_key); netif_set_real_num_tx_queues(ndev, nvdev->num_chn); netif_set_real_num_rx_queues(ndev, nvdev->num_chn); - for (i = 0; i < VRSS_SEND_TAB_SIZE; i++) - ndev_ctx->tx_table[i] = i % nvdev->num_chn; - return 0; } From patchwork Thu Apr 2 11:37:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1265533 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48tLdp0Qtyz9sSG; Thu, 2 Apr 2020 22:37:33 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jJyA4-0002FG-Ub; Thu, 02 Apr 2020 11:37:28 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA2-0002Eq-VN for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:26 +0000 Received: from mail-qv1-f72.google.com ([209.85.219.72]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA2-00060J-J3 for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:26 +0000 Received: by mail-qv1-f72.google.com with SMTP id z4so2439184qvj.2 for ; Thu, 02 Apr 2020 04:37:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DnG8kgLMBsCfoSoep5FRMLGTIGDuIjLOPPX64EcCPC8=; b=j02lSwdbdkq6kYcOpt05pag1BGT6f1sTDa+OdL3E6+DG0Utr1gcXNuv0yApmQT22nI ySmxqcdAfnKDwAG3OR8Fx30AINiLayHizYe1KQGCRB3sOvIEZlgavjZhZpsmASv3Alcq P1o9BJeBexMZh1ioj3bEzqoqWKfxC8CkU4DAT+qazDGtUejgw3v6rjuJR9CCBwbs7Bop JfWIIUvsZOQ3MDeWPLFeRPp6dT6QKi45NAKcG86WIBeRnTSVa33spv6WrS2eGzzKwSad E8E2AsUAIRSHUQ0ep9NbEWLc2fp1OnWNzbfaYuw7xJIEf5v11D5DfB6cKxnHwLErdPCL WxnQ== X-Gm-Message-State: AGi0PuYGFze8D5fZFgvGrMSgWLPk8HDPFyXm+S/LnGmnFsgvK/uHIY0R cT9ORrsPWeK018869lw9ivlBAdZqewNRVTt8wsx5mfgIY9AEZJtT0UK5YuC2qXmm97wcLlsbz2n Boa/H0Z2ENDPeLU/1BAFaf1gj18cOS6/Cv+/SPlPO X-Received: by 2002:ac8:4f03:: with SMTP id b3mr2375115qte.282.1585827445250; Thu, 02 Apr 2020 04:37:25 -0700 (PDT) X-Google-Smtp-Source: APiQypI1uFcNbYY0watdg2UaN6INxFHM30FdRcCYSHvVF9DkmhVqP5Hy6QhgiTFtfyjGVXlgJ2E/FQ== X-Received: by 2002:ac8:4f03:: with SMTP id b3mr2375095qte.282.1585827444926; Thu, 02 Apr 2020 04:37:24 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e6:352:b906:503c:ddec:3d6e]) by smtp.gmail.com with ESMTPSA id f13sm3579353qte.53.2020.04.02.04.37.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 04:37:24 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [xenial:linux-azure][PATCH 2/6] hv_netvsc: simplify function args in receive status path Date: Thu, 2 Apr 2020 08:37:12 -0300 Message-Id: <20200402113716.20490-3-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200402113716.20490-1-marcelo.cerri@canonical.com> References: <20200402113716.20490-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Stephen Hemminger BugLink: http://bugs.launchpad.net/bugs/1864233 The caller (netvsc_receive) already has the net device pointer, and should just pass that to functions rather than the hyperv device. This eliminates several impossible error paths in the process. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller (backported from commit 79cf1bae384cfc51b0b0773b3591794302af6ebd) [marcelo.cerri@canonical.com: Fixed context] Signed-off-by: Marcelo Henrique Cerri --- drivers/net/hyperv/hyperv_net.h | 3 +-- drivers/net/hyperv/netvsc.c | 4 ++-- drivers/net/hyperv/netvsc_drv.c | 12 ++---------- drivers/net/hyperv/rndis_filter.c | 9 +++------ 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 9e8d0264a863..060ddd486bb3 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -199,7 +199,7 @@ int netvsc_send(struct net_device *net, struct rndis_message *rndis_msg, struct hv_page_buffer *page_buffer, struct sk_buff *skb); -void netvsc_linkstatus_callback(struct hv_device *device_obj, +void netvsc_linkstatus_callback(struct net_device *net, struct rndis_message *resp); int netvsc_recv_callback(struct net_device *net, struct vmbus_channel *channel, @@ -221,7 +221,6 @@ int rndis_filter_set_rss_param(struct rndis_device *rdev, const u8 *key); int rndis_filter_receive(struct net_device *ndev, struct netvsc_device *net_dev, - struct hv_device *dev, struct vmbus_channel *channel, void *data, u32 buflen); diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index c82fea28711a..f54b9847187d 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -1156,8 +1156,8 @@ static int netvsc_receive(struct net_device *ndev, int ret; /* Pass it to the upper layer */ - ret = rndis_filter_receive(ndev, net_device, device, - channel, data, buflen); + ret = rndis_filter_receive(ndev, net_device, + channel, data, buflen); if (unlikely(ret != NVSP_STAT_SUCCESS)) status = NVSP_STAT_FAIL; diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index 3b2589210eac..d64c656f88b5 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -728,22 +728,14 @@ static int netvsc_start_xmit(struct sk_buff *skb, struct net_device *net) /* * netvsc_linkstatus_callback - Link up/down notification */ -void netvsc_linkstatus_callback(struct hv_device *device_obj, +void netvsc_linkstatus_callback(struct net_device *net, struct rndis_message *resp) { struct rndis_indicate_status *indicate = &resp->msg.indicate_status; - struct net_device *net; - struct net_device_context *ndev_ctx; + struct net_device_context *ndev_ctx = netdev_priv(net); struct netvsc_reconfig *event; unsigned long flags; - net = hv_get_drvdata(device_obj); - - if (!net) - return; - - ndev_ctx = netdev_priv(net); - /* Update the physical link speed when changing to another vSwitch */ if (indicate->status == RNDIS_STATUS_LINK_SPEED_CHANGE) { u32 speed; diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c index 934f9901c50e..29e8741e1891 100644 --- a/drivers/net/hyperv/rndis_filter.c +++ b/drivers/net/hyperv/rndis_filter.c @@ -134,11 +134,9 @@ static void put_rndis_request(struct rndis_device *dev, kfree(req); } -static void dump_rndis_message(struct hv_device *hv_dev, +static void dump_rndis_message(struct net_device *netdev, const struct rndis_message *rndis_msg) { - struct net_device *netdev = hv_get_drvdata(hv_dev); - switch (rndis_msg->ndis_msg_type) { case RNDIS_MSG_PACKET: netdev_dbg(netdev, "RNDIS_MSG_PACKET (len %u, " @@ -406,7 +404,6 @@ static int rndis_filter_receive_data(struct net_device *ndev, int rndis_filter_receive(struct net_device *ndev, struct netvsc_device *net_dev, - struct hv_device *dev, struct vmbus_channel *channel, void *data, u32 buflen) { @@ -414,7 +411,7 @@ int rndis_filter_receive(struct net_device *ndev, struct rndis_message *rndis_msg = data; if (netif_msg_rx_status(net_device_ctx)) - dump_rndis_message(dev, rndis_msg); + dump_rndis_message(ndev, rndis_msg); switch (rndis_msg->ndis_msg_type) { case RNDIS_MSG_PACKET: @@ -429,7 +426,7 @@ int rndis_filter_receive(struct net_device *ndev, case RNDIS_MSG_INDICATE: /* notification msgs */ - netvsc_linkstatus_callback(dev, rndis_msg); + netvsc_linkstatus_callback(ndev, rndis_msg); break; default: netdev_err(ndev, From patchwork Thu Apr 2 11:37:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1265536 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48tLdp5Lxlz9sSW; Thu, 2 Apr 2020 22:37:34 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jJyA7-0002GG-4L; Thu, 02 Apr 2020 11:37:31 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA5-0002FR-7j for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:29 +0000 Received: from mail-qt1-f200.google.com ([209.85.160.200]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA4-00060R-Rw for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:28 +0000 Received: by mail-qt1-f200.google.com with SMTP id k46so2873770qta.2 for ; Thu, 02 Apr 2020 04:37:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HCEwWspndIch/XTY5h91e2ccZ91dUisKn8xY8ZpA0+w=; b=ZboE0lxWQ7+pbUBkpAu+PvegcklISfa60sAChoDT56s6runtu7dYm40IAUKSaGxEfB TQt0jdi6xO02v30n4VRtRDzfub74PCvrzYjdHA/SMdXSFGa2NwktWgB5H0jLVSD8FOm/ v75S63bW2jPzy1U9x/F6MHQGvgGO5vzA+YZ7B7jdtxgzJdygGcM8KdgZSV9faqtKCMCh Nx2mkwCQiPnIw3JLQ79ofy0oGCbY3+JdEBjLsFixDU8GFrVDgM8p4UAGcIIKeRO5JbeL I3paxTPmr4QJ//lDHXL6LTgxFxJ5J3dYW0E5OHmjDyvbPV41fag0lPIboWlAznvgI07y n2mg== X-Gm-Message-State: AGi0PubnmAOH7ain3BLv5lzwoMBDfI9k/7GGPfIE3cuMHSE9x2/xToiE Tor8KGiwO8HSbuhfL2K+wXEBn8zBsTRRiCV7ZU+ye75WHufV7cdHFYPVV/YAxMoIS0safzAST2f v1hQl+uL/nkRlC1CveUeaXLtJEKsk9zdSwtAmBizK X-Received: by 2002:aed:3eec:: with SMTP id o41mr2352513qtf.343.1585827447521; Thu, 02 Apr 2020 04:37:27 -0700 (PDT) X-Google-Smtp-Source: APiQypL8+JK/u+YSoZKwimjYiw5V6IrA/tryu12fIy5amyAVvhfUv5pDGN8ueodh+2guN6+CKHT42g== X-Received: by 2002:aed:3eec:: with SMTP id o41mr2352489qtf.343.1585827447202; Thu, 02 Apr 2020 04:37:27 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e6:352:b906:503c:ddec:3d6e]) by smtp.gmail.com with ESMTPSA id f13sm3579353qte.53.2020.04.02.04.37.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 04:37:26 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [xenial:linux-azure][PATCH 3/6] hv_netvsc: simplify receive side calling arguments Date: Thu, 2 Apr 2020 08:37:13 -0300 Message-Id: <20200402113716.20490-4-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200402113716.20490-1-marcelo.cerri@canonical.com> References: <20200402113716.20490-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Stephen Hemminger BugLink: http://bugs.launchpad.net/bugs/1864233 The calls up from the napi poll reading the receive ring had many places where an argument was being recreated. I.e the caller already had the value and wasn't passing it, then the callee would use known relationship to determine the same value. Simpler and faster to just pass arguments needed. Also, add const in a couple places where message is being only read. Signed-off-by: Stephen Hemminger Signed-off-by: David S. Miller (cherry picked from commit c347b9273c26453fa8c9e1acb92f45546d888745) Signed-off-by: Marcelo Henrique Cerri --- drivers/net/hyperv/netvsc.c | 58 +++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 32 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index f54b9847187d..c86d4611ad31 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -670,16 +670,14 @@ static inline void netvsc_free_send_slot(struct netvsc_device *net_device, sync_change_bit(index, net_device->send_section_map); } -static void netvsc_send_tx_complete(struct netvsc_device *net_device, - struct vmbus_channel *incoming_channel, - struct hv_device *device, +static void netvsc_send_tx_complete(struct net_device *ndev, + struct netvsc_device *net_device, + struct vmbus_channel *channel, const struct vmpacket_descriptor *desc, int budget) { struct sk_buff *skb = (struct sk_buff *)(unsigned long)desc->trans_id; - struct net_device *ndev = hv_get_drvdata(device); struct net_device_context *ndev_ctx = netdev_priv(ndev); - struct vmbus_channel *channel = device->channel; u16 q_idx = 0; int queue_sends; @@ -693,7 +691,6 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, if (send_index != NETVSC_INVALID_INDEX) netvsc_free_send_slot(net_device, send_index); q_idx = packet->q_idx; - channel = incoming_channel; tx_stats = &net_device->chan_table[q_idx].tx_stats; @@ -723,14 +720,13 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, } } -static void netvsc_send_completion(struct netvsc_device *net_device, +static void netvsc_send_completion(struct net_device *ndev, + struct netvsc_device *net_device, struct vmbus_channel *incoming_channel, - struct hv_device *device, const struct vmpacket_descriptor *desc, int budget) { - struct nvsp_message *nvsp_packet = hv_pkt_data(desc); - struct net_device *ndev = hv_get_drvdata(device); + const struct nvsp_message *nvsp_packet = hv_pkt_data(desc); switch (nvsp_packet->hdr.msg_type) { case NVSP_MSG_TYPE_INIT_COMPLETE: @@ -744,8 +740,8 @@ static void netvsc_send_completion(struct netvsc_device *net_device, break; case NVSP_MSG1_TYPE_SEND_RNDIS_PKT_COMPLETE: - netvsc_send_tx_complete(net_device, incoming_channel, - device, desc, budget); + netvsc_send_tx_complete(ndev, net_device, incoming_channel, + desc, budget); break; default: @@ -1116,12 +1112,11 @@ static void enq_receive_complete(struct net_device *ndev, static int netvsc_receive(struct net_device *ndev, struct netvsc_device *net_device, - struct net_device_context *net_device_ctx, - struct hv_device *device, struct vmbus_channel *channel, const struct vmpacket_descriptor *desc, - struct nvsp_message *nvsp) + const struct nvsp_message *nvsp) { + struct net_device_context *net_device_ctx = netdev_priv(ndev); const struct vmtransfer_page_packet_header *vmxferpage_packet = container_of(desc, const struct vmtransfer_page_packet_header, d); u16 q_idx = channel->offermsg.offer.sub_channel_index; @@ -1169,13 +1164,12 @@ static int netvsc_receive(struct net_device *ndev, return count; } -static void netvsc_send_table(struct hv_device *hdev, - struct nvsp_message *nvmsg) +static void netvsc_send_table(struct net_device *ndev, + const struct nvsp_message *nvmsg) { - struct net_device *ndev = hv_get_drvdata(hdev); struct net_device_context *net_device_ctx = netdev_priv(ndev); - int i; u32 count, *tab; + int i; count = nvmsg->msg.v5_msg.send_table.count; if (count != VRSS_SEND_TAB_SIZE) { @@ -1190,24 +1184,25 @@ static void netvsc_send_table(struct hv_device *hdev, net_device_ctx->tx_table[i] = tab[i]; } -static void netvsc_send_vf(struct net_device_context *net_device_ctx, - struct nvsp_message *nvmsg) +static void netvsc_send_vf(struct net_device *ndev, + const struct nvsp_message *nvmsg) { + struct net_device_context *net_device_ctx = netdev_priv(ndev); + net_device_ctx->vf_alloc = nvmsg->msg.v4_msg.vf_assoc.allocated; net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial; } -static inline void netvsc_receive_inband(struct hv_device *hdev, - struct net_device_context *net_device_ctx, - struct nvsp_message *nvmsg) +static void netvsc_receive_inband(struct net_device *ndev, + const struct nvsp_message *nvmsg) { switch (nvmsg->hdr.msg_type) { case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE: - netvsc_send_table(hdev, nvmsg); + netvsc_send_table(ndev, nvmsg); break; case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION: - netvsc_send_vf(net_device_ctx, nvmsg); + netvsc_send_vf(ndev, nvmsg); break; } } @@ -1219,22 +1214,21 @@ static int netvsc_process_raw_pkt(struct hv_device *device, const struct vmpacket_descriptor *desc, int budget) { - struct net_device_context *net_device_ctx = netdev_priv(ndev); - struct nvsp_message *nvmsg = hv_pkt_data(desc); + const struct nvsp_message *nvmsg = hv_pkt_data(desc); switch (desc->type) { case VM_PKT_COMP: - netvsc_send_completion(net_device, channel, device, + netvsc_send_completion(ndev, net_device, channel, desc, budget); break; case VM_PKT_DATA_USING_XFER_PAGES: - return netvsc_receive(ndev, net_device, net_device_ctx, - device, channel, desc, nvmsg); + return netvsc_receive(ndev, net_device, channel, + desc, nvmsg); break; case VM_PKT_DATA_INBAND: - netvsc_receive_inband(device, net_device_ctx, nvmsg); + netvsc_receive_inband(ndev, nvmsg); break; default: From patchwork Thu Apr 2 11:37:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1265537 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48tLds2wRmz9sSG; Thu, 2 Apr 2020 22:37:37 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jJyA9-0002Ho-Co; Thu, 02 Apr 2020 11:37:33 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA7-0002GL-8d for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:31 +0000 Received: from mail-qt1-f200.google.com ([209.85.160.200]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA6-00060f-T0 for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:31 +0000 Received: by mail-qt1-f200.google.com with SMTP id b3so2837242qte.13 for ; Thu, 02 Apr 2020 04:37:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=majAdtOQRiBB1JEZndstCad9vzj37W2L+/3FqlrNDUI=; b=XyGMAeRVph5BCUMw8VNRNJNzBtQ36u5PVcdpISA9v+/SD6iJitJn+oHvjj+0RTwAW2 D4CggXEoo8Og176G01zG97izi1/OpfDaEgw+QHpsBM0pYNNvW8lAFGVnHwJgoAyh3Rey kc2Z1H3JPogXidXNiP/Td2JQUJMRGxVIhCvmn7cJVRf5sLj3BeMTnYXfUEk6Ez0Znf0V 8gaDW9GXPbsETgZ25MOo14WX5nuCULbMpuNfkM9zBbNeRChE78Mn7d/I8nloBCVpQIGf J/a4Px+4J8U4LJ47yvUaLNITtnmKa60PcutsJZmc5zI9QEfzpuM1sUIO51rv/YVyDzIJ iinQ== X-Gm-Message-State: AGi0PubzVZojpKnBUA9VNNc7HKE8Ri/oRC0Jj+EFmJneoJKEg3+8D1nQ FMiKwqZ7HXIu16pACKeNd20iw6dF/BUtvKmlLfGlRDkVi/jpIge2j4oSJLRQNyHRpCnPJVYBRbR MNPlvm+HuOPTKeUCdLIIGIR8ZKoj28+Yvu52JZt/J X-Received: by 2002:ae9:ed54:: with SMTP id c81mr2186797qkg.313.1585827449544; Thu, 02 Apr 2020 04:37:29 -0700 (PDT) X-Google-Smtp-Source: APiQypLbaBXKaQyV9StE3Kx1MOqrcQWR6rNVQj66wA2g39gLjfj7FfWar/sH3uASyweMEci52k57pQ== X-Received: by 2002:ae9:ed54:: with SMTP id c81mr2186771qkg.313.1585827449185; Thu, 02 Apr 2020 04:37:29 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e6:352:b906:503c:ddec:3d6e]) by smtp.gmail.com with ESMTPSA id f13sm3579353qte.53.2020.04.02.04.37.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 04:37:28 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [xenial:linux-azure][PATCH 4/6] hv_netvsc: Fix offset usage in netvsc_send_table() Date: Thu, 2 Apr 2020 08:37:14 -0300 Message-Id: <20200402113716.20490-5-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200402113716.20490-1-marcelo.cerri@canonical.com> References: <20200402113716.20490-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: http://bugs.launchpad.net/bugs/1864233 To reach the data region, the existing code adds offset in struct nvsp_5_send_indirect_table on the beginning of this struct. But the offset should be based on the beginning of its container, struct nvsp_message. This bug causes the first table entry missing, and adds an extra zero from the zero pad after the data region. This can put extra burden on the channel 0. So, correct the offset usage. Also add a boundary check to ensure not reading beyond data region. Fixes: 5b54dac856cb ("hyperv: Add support for virtual Receive Side Scaling (vRSS)") Signed-off-by: Haiyang Zhang Signed-off-by: David S. Miller (cherry picked from commit 71f21959dd5516031db4f011e15e9a9508b93a7d) Signed-off-by: Marcelo Henrique Cerri --- drivers/net/hyperv/hyperv_net.h | 3 ++- drivers/net/hyperv/netvsc.c | 26 ++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 060ddd486bb3..803d63ea59ad 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -604,7 +604,8 @@ struct nvsp_5_send_indirect_table { /* The number of entries in the send indirection table */ u32 count; - /* The offset of the send indirection table from top of this struct. + /* The offset of the send indirection table from the beginning of + * struct nvsp_message. * The send indirection table tells which channel to put the send * traffic on. Each entry is a channel number. */ diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index c86d4611ad31..4256e0ab0781 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -1165,20 +1165,28 @@ static int netvsc_receive(struct net_device *ndev, } static void netvsc_send_table(struct net_device *ndev, - const struct nvsp_message *nvmsg) + const struct nvsp_message *nvmsg, + u32 msglen) { struct net_device_context *net_device_ctx = netdev_priv(ndev); - u32 count, *tab; + u32 count, offset, *tab; int i; count = nvmsg->msg.v5_msg.send_table.count; + offset = nvmsg->msg.v5_msg.send_table.offset; + if (count != VRSS_SEND_TAB_SIZE) { netdev_err(ndev, "Received wrong send-table size:%u\n", count); return; } - tab = (u32 *)((unsigned long)&nvmsg->msg.v5_msg.send_table + - nvmsg->msg.v5_msg.send_table.offset); + if (offset > msglen - count * sizeof(u32)) { + netdev_err(ndev, "Received send-table offset too big:%u\n", + offset); + return; + } + + tab = (void *)nvmsg + offset; for (i = 0; i < count; i++) net_device_ctx->tx_table[i] = tab[i]; @@ -1193,12 +1201,13 @@ static void netvsc_send_vf(struct net_device *ndev, net_device_ctx->vf_serial = nvmsg->msg.v4_msg.vf_assoc.serial; } -static void netvsc_receive_inband(struct net_device *ndev, - const struct nvsp_message *nvmsg) +static void netvsc_receive_inband(struct net_device *ndev, + const struct nvsp_message *nvmsg, + u32 msglen) { switch (nvmsg->hdr.msg_type) { case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE: - netvsc_send_table(ndev, nvmsg); + netvsc_send_table(ndev, nvmsg, msglen); break; case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION: @@ -1215,6 +1224,7 @@ static int netvsc_process_raw_pkt(struct hv_device *device, int budget) { const struct nvsp_message *nvmsg = hv_pkt_data(desc); + u32 msglen = hv_pkt_datalen(desc); switch (desc->type) { case VM_PKT_COMP: @@ -1228,7 +1238,7 @@ static int netvsc_process_raw_pkt(struct hv_device *device, break; case VM_PKT_DATA_INBAND: - netvsc_receive_inband(ndev, nvmsg); + netvsc_receive_inband(ndev, nvmsg, msglen); break; default: From patchwork Thu Apr 2 11:37:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1265538 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48tLdv71Pmz9sRN; Thu, 2 Apr 2020 22:37:39 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jJyAC-0002KO-La; Thu, 02 Apr 2020 11:37:36 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA9-0002HH-1s for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:33 +0000 Received: from mail-qk1-f200.google.com ([209.85.222.200]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyA8-00060n-Ls for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:32 +0000 Received: by mail-qk1-f200.google.com with SMTP id f206so2739731qke.9 for ; Thu, 02 Apr 2020 04:37:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2wiTZ9kCAdC2aaPgTr6uhOCCepguNfnz1/caGH3IOf4=; b=o2hwAwlkbauno5qDXGiGWwo01WZKkWl3E9d6Uxax8eg4012+9XK2hZoGFJXQDa+8vd NVYalalDshTqoJm5IeAuOJGLCiIkoBkJSGfhqDtLGVRHAz1Ob7r8EQJT11MOU0ifJiu3 LKozpRUqeoUI+G89U+uf6LaJ5BragwHx0XYSAcThFyHr0WFPv10v6begg5QfdWtFeKQ3 uwsjMSa7Etckjn7vpg4wtZbIAWqUyK6SJOOXx/3/phupOFjwBh5kH0mr4eVe4qWU+XQd SCZNnuVOihaQWQQifFF6aZMgDIA6N8ps8ZgdZEMjzv5A/gCmJPS0RuTyJSq86C9h8kej DLLw== X-Gm-Message-State: AGi0PuY8WEVhW/meTJSZ9Sp3FhehddXEXUMyJF62drv9Nc+mCKb5jDX1 o7p84OHYb0g+nc4sR1sWt0fBpKr/zHlABVA+JnEP7AnJRAJlUOYfLy4ratPctVnsy6lLyxcfEvt i0qO9swK+5xhWzxeFYMkFvtMs6Km11e4Z8F3XIOZY X-Received: by 2002:a37:e318:: with SMTP id y24mr2937493qki.39.1585827451314; Thu, 02 Apr 2020 04:37:31 -0700 (PDT) X-Google-Smtp-Source: APiQypJqzutCcU6ewcrcYAxEUBOYl0tPSDiPIPJqcOCXWQ3dylKcdHl+qSBHg77Fw1GjfqWbEGw0Tg== X-Received: by 2002:a37:e318:: with SMTP id y24mr2937468qki.39.1585827450990; Thu, 02 Apr 2020 04:37:30 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e6:352:b906:503c:ddec:3d6e]) by smtp.gmail.com with ESMTPSA id f13sm3579353qte.53.2020.04.02.04.37.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 04:37:30 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [xenial:linux-azure][PATCH 5/6] hv_netvsc: Add NetVSP v6 and v6.1 into version negotiation Date: Thu, 2 Apr 2020 08:37:15 -0300 Message-Id: <20200402113716.20490-6-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200402113716.20490-1-marcelo.cerri@canonical.com> References: <20200402113716.20490-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: http://bugs.launchpad.net/bugs/1864233 This patch adds the NetVSP v6 and 6.1 message structures, and includes these versions into NetVSC/NetVSP version negotiation process. Signed-off-by: Haiyang Zhang Signed-off-by: David S. Miller (cherry picked from commit 0dcec221dd39d4d48fe6b22b4cacf2f49b95ffa0) Signed-off-by: Marcelo Henrique Cerri --- drivers/net/hyperv/hyperv_net.h | 164 ++++++++++++++++++++++++++++++++ drivers/net/hyperv/netvsc.c | 3 +- 2 files changed, 166 insertions(+), 1 deletion(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index 803d63ea59ad..83e040359037 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -235,6 +235,8 @@ void netvsc_switch_datapath(struct net_device *nv_dev, bool vf); #define NVSP_PROTOCOL_VERSION_2 0x30002 #define NVSP_PROTOCOL_VERSION_4 0x40000 #define NVSP_PROTOCOL_VERSION_5 0x50000 +#define NVSP_PROTOCOL_VERSION_6 0x60000 +#define NVSP_PROTOCOL_VERSION_61 0x60001 enum { NVSP_MSG_TYPE_NONE = 0, @@ -306,6 +308,12 @@ enum { NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE, NVSP_MSG5_MAX = NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE, + + /* Version 6 messages */ + NVSP_MSG6_TYPE_PD_API, + NVSP_MSG6_TYPE_PD_POST_BATCH, + + NVSP_MSG6_MAX = NVSP_MSG6_TYPE_PD_POST_BATCH }; enum { @@ -618,12 +626,168 @@ union nvsp_5_message_uber { struct nvsp_5_send_indirect_table send_table; } __packed; +enum nvsp_6_pd_api_op { + PD_API_OP_CONFIG = 1, + PD_API_OP_SW_DATAPATH, /* Switch Datapath */ + PD_API_OP_OPEN_PROVIDER, + PD_API_OP_CLOSE_PROVIDER, + PD_API_OP_CREATE_QUEUE, + PD_API_OP_FLUSH_QUEUE, + PD_API_OP_FREE_QUEUE, + PD_API_OP_ALLOC_COM_BUF, /* Allocate Common Buffer */ + PD_API_OP_FREE_COM_BUF, /* Free Common Buffer */ + PD_API_OP_MAX +}; + +struct grp_affinity { + u64 mask; + u16 grp; + u16 reserved[3]; +} __packed; + +struct nvsp_6_pd_api_req { + u32 op; + + union { + /* MMIO information is sent from the VM to VSP */ + struct __packed { + u64 mmio_pa; /* MMIO Physical Address */ + u32 mmio_len; + + /* Number of PD queues a VM can support */ + u16 num_subchn; + } config; + + /* Switch Datapath */ + struct __packed { + /* Host Datapath Is PacketDirect */ + u8 host_dpath_is_pd; + + /* Guest PacketDirect Is Enabled */ + u8 guest_pd_enabled; + } sw_dpath; + + /* Open Provider*/ + struct __packed { + u32 prov_id; /* Provider id */ + u32 flag; + } open_prov; + + /* Close Provider */ + struct __packed { + u32 prov_id; + } cls_prov; + + /* Create Queue*/ + struct __packed { + u32 prov_id; + u16 q_id; + u16 q_size; + u8 is_recv_q; + u8 is_rss_q; + u32 recv_data_len; + struct grp_affinity affy; + } cr_q; + + /* Delete Queue*/ + struct __packed { + u32 prov_id; + u16 q_id; + } del_q; + + /* Flush Queue */ + struct __packed { + u32 prov_id; + u16 q_id; + } flush_q; + + /* Allocate Common Buffer */ + struct __packed { + u32 len; + u32 pf_node; /* Preferred Node */ + u16 region_id; + } alloc_com_buf; + + /* Free Common Buffer */ + struct __packed { + u32 len; + u64 pa; /* Physical Address */ + u32 pf_node; /* Preferred Node */ + u16 region_id; + u8 cache_type; + } free_com_buf; + } __packed; +} __packed; + +struct nvsp_6_pd_api_comp { + u32 op; + u32 status; + + union { + struct __packed { + /* actual number of PD queues allocated to the VM */ + u16 num_pd_q; + + /* Num Receive Rss PD Queues */ + u8 num_rss_q; + + u8 is_supported; /* Is supported by VSP */ + u8 is_enabled; /* Is enabled by VSP */ + } config; + + /* Open Provider */ + struct __packed { + u32 prov_id; + } open_prov; + + /* Create Queue */ + struct __packed { + u32 prov_id; + u16 q_id; + u16 q_size; + u32 recv_data_len; + struct grp_affinity affy; + } cr_q; + + /* Allocate Common Buffer */ + struct __packed { + u64 pa; /* Physical Address */ + u32 len; + u32 pf_node; /* Preferred Node */ + u16 region_id; + u8 cache_type; + } alloc_com_buf; + } __packed; +} __packed; + +struct nvsp_6_pd_buf { + u32 region_offset; + u16 region_id; + u16 is_partial:1; + u16 reserved:15; +} __packed; + +struct nvsp_6_pd_batch_msg { + struct nvsp_message_header hdr; + u16 count; + u16 guest2host:1; + u16 is_recv:1; + u16 reserved:14; + struct nvsp_6_pd_buf pd_buf[0]; +} __packed; + +union nvsp_6_message_uber { + struct nvsp_6_pd_api_req pd_req; + struct nvsp_6_pd_api_comp pd_comp; +} __packed; + union nvsp_all_messages { union nvsp_message_init_uber init_msg; union nvsp_1_message_uber v1_msg; union nvsp_2_message_uber v2_msg; union nvsp_4_message_uber v4_msg; union nvsp_5_message_uber v5_msg; + union nvsp_6_message_uber v6_msg; } __packed; /* ALL Messages */ diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 4256e0ab0781..ee7bc5e14fca 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -543,7 +543,8 @@ static int netvsc_connect_vsp(struct hv_device *device, { static const u32 ver_list[] = { NVSP_PROTOCOL_VERSION_1, NVSP_PROTOCOL_VERSION_2, - NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5 + NVSP_PROTOCOL_VERSION_4, NVSP_PROTOCOL_VERSION_5, + NVSP_PROTOCOL_VERSION_6, NVSP_PROTOCOL_VERSION_61 }; struct nvsp_message *init_packet; int ndis_version, i, ret; From patchwork Thu Apr 2 11:37:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Henrique Cerri X-Patchwork-Id: 1265539 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48tLdy3v4fz9sQt; Thu, 2 Apr 2020 22:37:42 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1jJyAE-0002MC-KT; Thu, 02 Apr 2020 11:37:38 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyAA-0002Iz-P4 for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:34 +0000 Received: from mail-qk1-f198.google.com ([209.85.222.198]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jJyAA-00060u-E1 for kernel-team@lists.ubuntu.com; Thu, 02 Apr 2020 11:37:34 +0000 Received: by mail-qk1-f198.google.com with SMTP id p8so2754688qkp.4 for ; Thu, 02 Apr 2020 04:37:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9Y1pQpQzdgDEOA687p46butyfvF7j9dp4rbIXcfrQhA=; b=Jp9BbeQmyaGnO4LsblGs0CYUSWme2tErEfJ4wXAU4Eu9ZSDtQ66TjcHqq+yF8ahGeD Trs9bV86dWxCByEepQLZUaLgdk2Uhi+eoXdYOLTl6vY5BZ0lZeIKSCbDW/CHPuDUvsEJ Lz4qtRDoPfdQjQLH8Kbc07smG/i4S5kVM4J01CS1dD+Bskqa6TwE0NCZaKSMYIJ5gUjC LmfWm+uBNWJtC76Ad+3EGy1iZFMJ7xTKnADTxrYOCPKLmh1YfJwiTUWOOsEdV/VTw+WS uwYhFMu4QkdfnxqzDl84+0eI/+PoJEOeLItAzfjmii3PicNNnx9jaTwj+NHheL4OQXhl H3uw== X-Gm-Message-State: AGi0PuYtZQBmknKVYn/ydunuh0D5PjRrY3se+XQuwWdIhm5Fuo6/59a/ VKWYhwo5XoxE3UYoKw1DnyRDbVoZYnHdakWYT8rWyKPa84W1KmLCIF0GwIews5SDueis496Go8C l8NFUzCx/fA05hbiJYMAtYzEZj2ZjWX0mD5kDBFuG X-Received: by 2002:ac8:7293:: with SMTP id v19mr2456849qto.133.1585827453134; Thu, 02 Apr 2020 04:37:33 -0700 (PDT) X-Google-Smtp-Source: APiQypJqBdys2D5mPPSHCmpGzukdFAmyptkaQClP5QfgdF++kPlInMxjUcx+2Sj/xnDld54KxvHVag== X-Received: by 2002:ac8:7293:: with SMTP id v19mr2456816qto.133.1585827452771; Thu, 02 Apr 2020 04:37:32 -0700 (PDT) Received: from gallifrey.lan ([2804:14c:4e6:352:b906:503c:ddec:3d6e]) by smtp.gmail.com with ESMTPSA id f13sm3579353qte.53.2020.04.02.04.37.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Apr 2020 04:37:32 -0700 (PDT) From: Marcelo Henrique Cerri To: kernel-team@lists.ubuntu.com Subject: [xenial:linux-azure][PATCH 6/6] hv_netvsc: Fix send_table offset in case of a host bug Date: Thu, 2 Apr 2020 08:37:16 -0300 Message-Id: <20200402113716.20490-7-marcelo.cerri@canonical.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200402113716.20490-1-marcelo.cerri@canonical.com> References: <20200402113716.20490-1-marcelo.cerri@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Haiyang Zhang BugLink: http://bugs.launchpad.net/bugs/1864233 If negotiated NVSP version <= NVSP_PROTOCOL_VERSION_6, the offset may be wrong (too small) due to a host bug. This can cause missing the end of the send indirection table, and add multiple zero entries from leading zeros before the data region. This bug adds extra burden on channel 0. So fix the offset by computing it from the data structure sizes. This will ensure netvsc driver runs normally on unfixed hosts, and future fixed hosts. Fixes: 5b54dac856cb ("hyperv: Add support for virtual Receive Side Scaling (vRSS)") Signed-off-by: Haiyang Zhang Signed-off-by: David S. Miller (cherry picked from commit 171c1fd98df3d5948d9a9eb755274850fa5e59c6) Signed-off-by: Marcelo Henrique Cerri --- drivers/net/hyperv/netvsc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index ee7bc5e14fca..b08643f6e16f 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -1166,6 +1166,7 @@ static int netvsc_receive(struct net_device *ndev, } static void netvsc_send_table(struct net_device *ndev, + struct netvsc_device *nvscdev, const struct nvsp_message *nvmsg, u32 msglen) { @@ -1181,6 +1182,16 @@ static void netvsc_send_table(struct net_device *ndev, return; } + /* If negotiated version <= NVSP_PROTOCOL_VERSION_6, the offset may be + * wrong due to a host bug. So fix the offset here. + */ + if (nvscdev->nvsp_version <= NVSP_PROTOCOL_VERSION_6 && + msglen >= sizeof(struct nvsp_message_header) + + sizeof(union nvsp_6_message_uber) + count * sizeof(u32)) + offset = sizeof(struct nvsp_message_header) + + sizeof(union nvsp_6_message_uber); + + /* Boundary check for all versions */ if (offset > msglen - count * sizeof(u32)) { netdev_err(ndev, "Received send-table offset too big:%u\n", offset); @@ -1203,12 +1214,13 @@ static void netvsc_send_vf(struct net_device *ndev, } static void netvsc_receive_inband(struct net_device *ndev, + struct netvsc_device *nvscdev, const struct nvsp_message *nvmsg, u32 msglen) { switch (nvmsg->hdr.msg_type) { case NVSP_MSG5_TYPE_SEND_INDIRECTION_TABLE: - netvsc_send_table(ndev, nvmsg, msglen); + netvsc_send_table(ndev, nvscdev, nvmsg, msglen); break; case NVSP_MSG4_TYPE_SEND_VF_ASSOCIATION: @@ -1239,7 +1251,7 @@ static int netvsc_process_raw_pkt(struct hv_device *device, break; case VM_PKT_DATA_INBAND: - netvsc_receive_inband(ndev, nvmsg, msglen); + netvsc_receive_inband(ndev, net_device, nvmsg, msglen); break; default: