Received: by 10.213.65.68 with SMTP id h4csp109546imn; Tue, 27 Mar 2018 17:52:03 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+ZXNkihAAexHJClSXugKESCY29NIu/lJonyuVbk29xid9vykBKZJ7nyn6Klq4+u1t4hOhO X-Received: by 10.98.133.28 with SMTP id u28mr1168153pfd.190.1522198322945; Tue, 27 Mar 2018 17:52:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522198322; cv=none; d=google.com; s=arc-20160816; b=skc30TBmuT6A23oYtkUePzZ4eFZghVwq40wedyxN6M7vd6hNjKcUrezjd2vqbRLzaB gso4xUHOenbcX6hOW3f7v/9uacxnHux+TLK41tFta38dIWy0QoWCyUecuOXCwGa+Q9YH kyp45bd55EDi0mmdIAPmpeyI+CN6ZnMSntKW/8GrCstO+9N1U25EINqnXAIKeyAHQJ5s fNXwvlof55QI7aYyR7pnhZfnEABEx1TnSYPrK326tn8dycVDJuQ3AcdgPDgtIwnERZS8 bw8iWZleOtl3JwmO7CSF7LAKm+xVteOulaSpT2eC74LUtymRD0c/KhftDG8FOzBymYzW XyAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=TgVPLtum2NhhBxR6+0CuBL7NA7HYq2ymwMNG3aMmXCc=; b=OwOwgHGlZSEKWqrKzS8u4NyPbSQsWPwOasqDjYkNfQN03HhOSBlkjq4HHnYBheDBA7 lsZGysGwzEmew/YONXL4o5VOTgcmXlfuM3x80Bg8c+fPj7awNCvOq5HGx9wP+M60/u0A jmJJp45jI5J/U9sdj3ycEKjcd3VeqoLzKlC3SUJ+8/65bAYVrFchfG7IWIRsMIS7vNwF F+xmKwfm0Ds5nMWBQry/DXwql25ipQ+AruXeTX4scCkCFuVQzJqhJWOo2EJoBMjPdXwm Z3Z5GM9uOYOaQH6Mn3SvA3IyALLolc/0AICEFJE08sZeyhKkB6lhxs6mfqmDfgNGNm0Q hilw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8si1661493pgs.555.2018.03.27.17.51.47; Tue, 27 Mar 2018 17:52:02 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752831AbeC1Aua (ORCPT + 99 others); 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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) -- 2.14.1