From patchwork Wed Mar 28 00:48:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Long Li X-Patchwork-Id: 10311959 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5BB606037D for ; Wed, 28 Mar 2018 00:50:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51E7329B64 for ; Wed, 28 Mar 2018 00:50:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4629829E63; Wed, 28 Mar 2018 00:50:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0D5529B64 for ; Wed, 28 Mar 2018 00:50:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752820AbeC1Aua (ORCPT ); Tue, 27 Mar 2018 20:50:30 -0400 Received: from a2nlsmtp01-04.prod.iad2.secureserver.net ([198.71.225.38]:56338 "EHLO a2nlsmtp01-04.prod.iad2.secureserver.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752605AbeC1Au0 (ORCPT ); Tue, 27 Mar 2018 20:50:26 -0400 Received: from linuxonhyperv2.linuxonhyperv.com ([107.180.71.197]) by : HOSTING RELAY : with SMTP id 0zHJfpzP0YARI0zHJfas0F; Tue, 27 Mar 2018 17:49:25 -0700 x-originating-ip: 107.180.71.197 Received: from longli by linuxonhyperv2.linuxonhyperv.com with local (Exim 4.89_1) (envelope-from ) id 1f0zHJ-0005xC-9W; Tue, 27 Mar 2018 17:49:25 -0700 From: Long Li To: "K . Y . Srinivasan" , Haiyang Zhang , Stephen Hemminger , "James E . J . Bottomley" , "Martin K . Petersen" , devel@linuxdriverproject.org, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: Long Li Subject: [Resend Patch 2/3] Netvsc: Use the vmbus functiton to calculate ring buffer percentage Date: Tue, 27 Mar 2018 17:48:39 -0700 Message-Id: <20180328004840.22787-2-longli@linuxonhyperv.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180328004840.22787-1-longli@linuxonhyperv.com> References: <20180328004840.22787-1-longli@linuxonhyperv.com> Reply-To: longli@microsoft.com X-CMAE-Envelope: MS4wfK8iaB4Y41R6eTr5PofrmAXoFzoVhC2j0ZUHbZ2IazodCAARyFDVDct1cTXFXpTBtw/ZxSITBy23EGg7c1Wl/LYNNSdwxrZARu3ztZqLxBBeiyOeHrHF VgmKPEND1T1Wks4/4pyGqlwqft7HIy1pWpD7HfKZzqTr0g9Ad26qoQN14i5Gr0ksgGCj21XbiP2DRMSSCG4f/i14C3va2v0XybtoCUyeBs26DtNogf19KuwQ ulT7wZkzP8A4absE3pO1nNPhpnPkPLNe5CDje6weE1Doazyx6Gl3Q0tAFZN1+4KZ9iCgqf43TzvH/9YtubXyK1xNonzwEGufVFud+u/DAEfjA/oyWGBzoGQH aRnEFibLC+Epmb1GfdbPrh6pki0N2YsyY+3d5k0uwlJ4ampl9uTkIw6dtUhj8yrAt/r4ApCT0+J9qhdy6bkFktZw7svvnOMiRfOIG+ZGZC5JM5iLZLe5O3PK /JS3rJ/OHyAEyfDIYgu11oDS9ldCMu8NkzyIIPqB0M6/oqPZKWKjV3RN6jeTxuVl1G4C0WYPqBfRueTx Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Long Li In Vmbus, we have defined a function to calculate available ring buffer percentage to write. Use that function and remove netvsc's private version. Signed-off-by: Long Li Reviewed-by: Michael Kelley --- drivers/net/hyperv/hyperv_net.h | 1 - drivers/net/hyperv/netvsc.c | 17 +++-------------- drivers/net/hyperv/netvsc_drv.c | 3 --- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h index cd538d5a7986..a0199ab13d67 100644 --- a/drivers/net/hyperv/hyperv_net.h +++ b/drivers/net/hyperv/hyperv_net.h @@ -189,7 +189,6 @@ struct netvsc_device; struct net_device_context; extern u32 netvsc_ring_bytes; -extern struct reciprocal_value netvsc_ring_reciprocal; struct netvsc_device *netvsc_device_add(struct hv_device *device, const struct netvsc_device_info *info); diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 0265d703eb03..8af0069e4d8c 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c @@ -31,7 +31,6 @@ #include #include #include -#include #include @@ -590,17 +589,6 @@ void netvsc_device_remove(struct hv_device *device) #define RING_AVAIL_PERCENT_HIWATER 20 #define RING_AVAIL_PERCENT_LOWATER 10 -/* - * Get the percentage of available bytes to write in the ring. - * The return value is in range from 0 to 100. - */ -static u32 hv_ringbuf_avail_percent(const struct hv_ring_buffer_info *ring_info) -{ - u32 avail_write = hv_get_bytes_to_write(ring_info); - - return reciprocal_divide(avail_write * 100, netvsc_ring_reciprocal); -} - static inline void netvsc_free_send_slot(struct netvsc_device *net_device, u32 index) { @@ -649,7 +637,8 @@ static void netvsc_send_tx_complete(struct netvsc_device *net_device, wake_up(&net_device->wait_drain); if (netif_tx_queue_stopped(netdev_get_tx_queue(ndev, q_idx)) && - (hv_ringbuf_avail_percent(&channel->outbound) > RING_AVAIL_PERCENT_HIWATER || + (hv_get_avail_to_write_percent(&channel->outbound) > + RING_AVAIL_PERCENT_HIWATER || queue_sends < 1)) { netif_tx_wake_queue(netdev_get_tx_queue(ndev, q_idx)); ndev_ctx->eth_stats.wake_queue++; @@ -757,7 +746,7 @@ static inline int netvsc_send_pkt( struct netdev_queue *txq = netdev_get_tx_queue(ndev, packet->q_idx); u64 req_id; int ret; - u32 ring_avail = hv_ringbuf_avail_percent(&out_channel->outbound); + u32 ring_avail = hv_get_avail_to_write_percent(&out_channel->outbound); nvmsg.hdr.msg_type = NVSP_MSG1_TYPE_SEND_RNDIS_PKT; if (skb) diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c index faea0be18924..b0b1c2fd2b7b 100644 --- a/drivers/net/hyperv/netvsc_drv.c +++ b/drivers/net/hyperv/netvsc_drv.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include @@ -55,7 +54,6 @@ static unsigned int ring_size __ro_after_init = 128; module_param(ring_size, uint, S_IRUGO); MODULE_PARM_DESC(ring_size, "Ring buffer size (# of pages)"); unsigned int netvsc_ring_bytes __ro_after_init; -struct reciprocal_value netvsc_ring_reciprocal __ro_after_init; static const u32 default_msg = NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK | NETIF_MSG_IFUP | @@ -2186,7 +2184,6 @@ static int __init netvsc_drv_init(void) ring_size); } netvsc_ring_bytes = ring_size * PAGE_SIZE; - netvsc_ring_reciprocal = reciprocal_value(netvsc_ring_bytes); ret = vmbus_driver_register(&netvsc_drv); if (ret)