Received: by 10.213.65.68 with SMTP id h4csp2285598imn; Thu, 5 Apr 2018 12:11:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+QWLaxgryPWKIkyPEeeipJHTGChACseK7In3d1jIAn6QbdKcfeXsZP/jBWGtLxnctlMeGJ X-Received: by 2002:a17:902:9a81:: with SMTP id w1-v6mr23797851plp.148.1522955500336; Thu, 05 Apr 2018 12:11:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522955500; cv=none; d=google.com; s=arc-20160816; b=JFv8IeIRkaM3aSRJKNU1QgTXEaomfBzmsOSGC0+Y0i5gRFw3YLU/YdHtEx6hHu/MPN mXKDWRMfE42Mf8QH88UbGsgm9pzAJrR+JwQ0u77pyLZ4yUtq68qiqTVz9rVNST9Nit6y nlpPyBoF/lP1L4Y37fXL4DmxsQqciZEx79mDpqNSGT0jdC0GG+wEoMCEO9cM9/JsuYuv Oh3xOmsvF2Qmi+r3E/gRvZQhjpmUQ0r8mxBEbjz8xIVpnLP0/OUquxFlbskTXFywBh3j oaoqWQp4RevLBVKW716kKh/0amhdHZY9uhNKck03HdMsftVFCEz3BLBEBm6VmK6z4ab1 8G+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=GhL0PaM5NGKQwKNIdX3vFlVpfWQqGfa0Ag3hIupfGmE=; b=sZf+vv+GKUdw/3r6iI25KYgcSriFuQRtqFKhep8TFqRvbfr1iaZrNklY9trw5N9EEO 3shDehp3U5Uxz3vDIL0Z9D60fX6l0Fg4B1bzXTO5QVLLoOEwpzONWtgAl7sNCTnlpzqP s63Z6/TytZY0HO+u7x43c82g1BNuk2r7C6QMBaOFE9xve0yhghDebfRd0slSBp/PsEUu S4DjFuxi0dgbHLOjJ/XFiGqgRDVSmg73kL7rmoXDV78chJY76UBRikJped2veT2D7fsa hpTPSC+29vvabdwclIPhxjQ53lMmdBFZGZz/Sg5iyEsAiyfnAMSgn+6IgGOfwKZoAvjk VE/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o11si593850pgp.493.2018.04.05.12.11.26; Thu, 05 Apr 2018 12:11:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbeDETJj (ORCPT + 99 others); Thu, 5 Apr 2018 15:09:39 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:36010 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752561AbeDETJf (ORCPT ); Thu, 5 Apr 2018 15:09:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB9138185321; Thu, 5 Apr 2018 19:09:34 +0000 (UTC) Received: from mmorsy.remote.csb (unknown [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 62E0D2023235; Thu, 5 Apr 2018 19:09:32 +0000 (UTC) From: Mohammed Gamal To: netdev@vger.kernel.org, sthemmin@microsoft.com Cc: devel@linuxdriverproject.org, linux-kernel@vger.kernel.org, kys@microsoft.com, haiyangz@microsoft.com, vkuznets@redhat.com, otubo@redhat.com, Mohammed Gamal Subject: [PATCH 2/4] hv_netvsc: Split netvsc_revoke_buf() and netvsc_teardown_gpadl() Date: Thu, 5 Apr 2018 21:09:19 +0200 Message-Id: <1522955361-14704-3-git-send-email-mgamal@redhat.com> In-Reply-To: <1522955361-14704-1-git-send-email-mgamal@redhat.com> References: <1522955361-14704-1-git-send-email-mgamal@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Apr 2018 19:09:34 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Thu, 05 Apr 2018 19:09:34 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'mgamal@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Split each of the functions into two for each of send/recv buffers. This will be needed in order to implement a fine-grained messaging sequence to the host so tht we accommodate the requirements of different Windows versions Fixes: 0ef58b0a05c12 ("hv_netvsc: change GPAD teardown order on older versions") Signed-off-by: Mohammed Gamal --- drivers/net/hyperv/netvsc.c | 46 +++++++++++++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index d65b7fc..f4df5de 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -109,11 +109,11 @@ static void free_netvsc_device_rcu(struct netvsc_device *nvdev) call_rcu(&nvdev->rcu, free_netvsc_device); } -static void netvsc_revoke_buf(struct hv_device *device, - struct netvsc_device *net_device) +static void netvsc_revoke_recv_buf(struct hv_device *device, + struct netvsc_device *net_device) { - struct nvsp_message *revoke_packet; struct net_device *ndev = hv_get_drvdata(device); + struct nvsp_message *revoke_packet; int ret; /* @@ -157,6 +157,14 @@ static void netvsc_revoke_buf(struct hv_device *device, } net_device->recv_section_cnt = 0; } +} + +static void netvsc_revoke_send_buf(struct hv_device *device, + struct netvsc_device *net_device) +{ + struct net_device *ndev = hv_get_drvdata(device); + struct nvsp_message *revoke_packet; + int ret; /* Deal with the send buffer we may have setup. * If we got a send section size, it means we received a @@ -202,8 +210,8 @@ static void netvsc_revoke_buf(struct hv_device *device, } } -static void netvsc_teardown_gpadl(struct hv_device *device, - struct netvsc_device *net_device) +static void netvsc_teardown_recv_gpadl(struct hv_device *device, + struct netvsc_device *net_device) { struct net_device *ndev = hv_get_drvdata(device); int ret; @@ -222,6 +230,13 @@ static void netvsc_teardown_gpadl(struct hv_device *device, } net_device->recv_buf_gpadl_handle = 0; } +} + +static void netvsc_teardown_send_gpadl(struct hv_device *device, + struct netvsc_device *net_device) +{ + struct net_device *ndev = hv_get_drvdata(device); + int ret; if (net_device->send_buf_gpadl_handle) { ret = vmbus_teardown_gpadl(device->channel, @@ -437,8 +452,10 @@ static int netvsc_init_buf(struct hv_device *device, goto exit; cleanup: - netvsc_revoke_buf(device, net_device); - netvsc_teardown_gpadl(device, net_device); + netvsc_revoke_recv_buf(device, net_device); + netvsc_revoke_send_buf(device, net_device); + netvsc_teardown_recv_gpadl(device, net_device); + netvsc_teardown_send_gpadl(device, net_device); exit: return ret; @@ -575,7 +592,8 @@ void netvsc_device_remove(struct hv_device *device) = rtnl_dereference(net_device_ctx->nvdev); int i; - netvsc_revoke_buf(device, net_device); + netvsc_revoke_recv_buf(device, net_device); + netvsc_revoke_send_buf(device, net_device); RCU_INIT_POINTER(net_device_ctx->nvdev, NULL); @@ -590,14 +608,18 @@ void netvsc_device_remove(struct hv_device *device) netdev_dbg(ndev, "net device safe to remove\n"); /* older versions require that buffer be revoked before close */ - if (vmbus_proto_version < VERSION_WIN10) - netvsc_teardown_gpadl(device, net_device); + if (vmbus_proto_version < VERSION_WIN10) { + netvsc_teardown_recv_gpadl(device, net_device); + netvsc_teardown_send_gpadl(device, net_device); + } /* Now, we can close the channel safely */ vmbus_close(device->channel); - if (vmbus_proto_version >= VERSION_WIN10) - netvsc_teardown_gpadl(device, net_device); + if (vmbus_proto_version >= VERSION_WIN10) { + netvsc_teardown_recv_gpadl(device, net_device); + netvsc_teardown_send_gpadl(device, net_device); + } /* Release all resources */ free_netvsc_device_rcu(net_device); -- 1.8.3.1