Received: by 10.213.65.68 with SMTP id h4csp1031794imn; Wed, 21 Mar 2018 00:22:13 -0700 (PDT) X-Google-Smtp-Source: AG47ELuWMRZq0mixYyL5NqufgckJyHezFtuEEcyos0O4YzZVmGseaPnK3QlzPzgGkWguzoF4mcv6 X-Received: by 10.98.242.6 with SMTP id m6mr712361pfh.170.1521616933172; Wed, 21 Mar 2018 00:22:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521616933; cv=none; d=google.com; s=arc-20160816; b=Fqzlwt33TbeDbM3E6pYwVY9ohzwO9g6I4BohticroRW14WL30VtsQ5de8SEB6kiReL 1uL1iVPlFTS5TuQHRhLs7v728C5S66xlJMlWxxlQMU3A+Pp+BBuFrZCSEz3jeow67vvO nex3lXTArnzpm1jw5XSDO0H+V5E9eMk//dAJMqiTx20nY4JSICLKTAXP0Li65VyGEPxj fFabu+6GWfVaJGF6hQA7vPHGHe/q4uHi1o8l4ZH01vvJnVnt60RlYKN/y/c3bfLKR2uV Be9c1WNXvqfSql1xfxJAJ9t3sUH6mgc2HIiSfxIVq9zFtj8YROKQAFxeZKRae0RYQusT 33oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=cjkl6bvsdr7EsPUoAWoXm2Qq0EfRj2EHUiyxNMA9kCg=; b=NeN5CB0WkjZZhe6g7HDHgIeX/MKiWv7S/1WYHahiBT79YIFm8vQ9GtSHMzx3hW0xGM +G3mXosD2ZS5tPQ+ZVhbZSM1l0E4HF+AH9bsazBCmccgGidU++tBbvsB+lIuYi/iLr7e PuzWw5cVIWyFYG5fg06o7GV/SCtzaf5YFjJB0+pI/ozNDbTX/K80PWqxa2Jzueotobst h04hc6/D1kK6w5wkHKqEzC8mSRu3LsZ2jCIGCHH4p8JdDGCxR5ke5sVXFvLOHCbOz7go akGA0h025MywJIQjFLhETXrwsvB5jkg/hlZpvyyMPLMzRP8I4ESl0K7vyXwkQKJaOx8q IH+Q== 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 w130si2604257pfd.280.2018.03.21.00.21.59; Wed, 21 Mar 2018 00:22:13 -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 S1752041AbeCUHUu (ORCPT + 99 others); Wed, 21 Mar 2018 03:20:50 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6666 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751545AbeCUHST (ORCPT ); Wed, 21 Mar 2018 03:18:19 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 2F51EB85F3861; Wed, 21 Mar 2018 15:18:01 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 21 Mar 2018 15:17:53 +0800 From: Peng Li To: CC: , , , , Subject: [PATCH net-next 07/11] net: hns3: change the time interval of int_gl calculating Date: Wed, 21 Mar 2018 15:49:26 +0800 Message-ID: <1521618570-129694-8-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521618570-129694-1-git-send-email-lipeng321@huawei.com> References: <1521618570-129694-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang Since we change the update rate of int_gl from every interrupt to every one hundred interrupts, the old way to get time interval by int_gl value is not accurate. This patch calculates the time interval using the jiffies value. Signed-off-by: Fuyun Liang Signed-off-by: Peng Li --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 46 ++++++++++++++++--------- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 1 + 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index e7cf7b4..0b4a676 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -2406,15 +2406,15 @@ int hns3_clean_rx_ring( static bool hns3_get_new_int_gl(struct hns3_enet_ring_group *ring_group) { -#define HNS3_RX_ULTRA_PACKET_RATE 40000 + struct hns3_enet_tqp_vector *tqp_vector = + ring_group->ring->tqp_vector; enum hns3_flow_level_range new_flow_level; - struct hns3_enet_tqp_vector *tqp_vector; - int packets_per_secs; - int bytes_per_usecs; + int packets_per_msecs; + int bytes_per_msecs; + u32 time_passed_ms; u16 new_int_gl; - int usecs; - if (!ring_group->coal.int_gl) + if (!ring_group->coal.int_gl || !tqp_vector->last_jiffies) return false; if (ring_group->total_packets == 0) { @@ -2431,33 +2431,44 @@ static bool hns3_get_new_int_gl(struct hns3_enet_ring_group *ring_group) */ new_flow_level = ring_group->coal.flow_level; new_int_gl = ring_group->coal.int_gl; - tqp_vector = ring_group->ring->tqp_vector; - usecs = (ring_group->coal.int_gl << 1); - bytes_per_usecs = ring_group->total_bytes / usecs; - /* 1000000 microseconds */ - packets_per_secs = ring_group->total_packets * 1000000 / usecs; + time_passed_ms = + jiffies_to_msecs(jiffies - tqp_vector->last_jiffies); + + if (!time_passed_ms) + return false; + + do_div(ring_group->total_packets, time_passed_ms); + packets_per_msecs = ring_group->total_packets; + + do_div(ring_group->total_bytes, time_passed_ms); + bytes_per_msecs = ring_group->total_bytes; + +#define HNS3_RX_LOW_BYTE_RATE 10000 +#define HNS3_RX_MID_BYTE_RATE 20000 switch (new_flow_level) { case HNS3_FLOW_LOW: - if (bytes_per_usecs > 10) + if (bytes_per_msecs > HNS3_RX_LOW_BYTE_RATE) new_flow_level = HNS3_FLOW_MID; break; case HNS3_FLOW_MID: - if (bytes_per_usecs > 20) + if (bytes_per_msecs > HNS3_RX_MID_BYTE_RATE) new_flow_level = HNS3_FLOW_HIGH; - else if (bytes_per_usecs <= 10) + else if (bytes_per_msecs <= HNS3_RX_LOW_BYTE_RATE) new_flow_level = HNS3_FLOW_LOW; break; case HNS3_FLOW_HIGH: case HNS3_FLOW_ULTRA: default: - if (bytes_per_usecs <= 20) + if (bytes_per_msecs <= HNS3_RX_MID_BYTE_RATE) new_flow_level = HNS3_FLOW_MID; break; } - if ((packets_per_secs > HNS3_RX_ULTRA_PACKET_RATE) && - (&tqp_vector->rx_group == ring_group)) +#define HNS3_RX_ULTRA_PACKET_RATE 40 + + if (packets_per_msecs > HNS3_RX_ULTRA_PACKET_RATE && + &tqp_vector->rx_group == ring_group) new_flow_level = HNS3_FLOW_ULTRA; switch (new_flow_level) { @@ -2512,6 +2523,7 @@ static void hns3_update_new_int_gl(struct hns3_enet_tqp_vector *tqp_vector) tx_group->coal.int_gl); } + tqp_vector->last_jiffies = jiffies; tqp_vector->int_adapt_down = HNS3_INT_ADAPT_DOWN_START; } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index 2fe870b..39daa01 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -499,6 +499,7 @@ struct hns3_enet_tqp_vector { /* when 0 should adjust interrupt coalesce parameter */ u8 int_adapt_down; + unsigned long last_jiffies; } ____cacheline_internodealigned_in_smp; enum hns3_udp_tnl_type { -- 2.9.3