From patchwork Thu Apr 30 19:56:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 220137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1C3AFC4724C for ; Thu, 30 Apr 2020 20:00:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E85BD2072A for ; Thu, 30 Apr 2020 20:00:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MLNzvrIR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726884AbgD3UAN (ORCPT ); Thu, 30 Apr 2020 16:00:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726338AbgD3UAM (ORCPT ); Thu, 30 Apr 2020 16:00:12 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBAE0C035494 for ; Thu, 30 Apr 2020 13:00:10 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id x4so3408831wmj.1 for ; Thu, 30 Apr 2020 13:00:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=sZWt42IkXoz6fTpATIpmdrNPAwDi2KVKj/U0sinlL94=; b=MLNzvrIRQwt/p9gj08eYztMwIbYhgWjxybkBIxiD9Fz5GE+oWqhVGlAQKwrSydVhLH nYe0oBXpk9CGoTce7E0biIz+B8V/DJKqmyRDs3vwjtTX05fNI7x3e6VtioYVTFSZiCMG Dcwfp/k1qX9W/cKQyErQDLsM3AFdAYeMxjwfkbfLZKoWg98YlNGXoN2t78Xakir/Lw6O ubivY+A0Wtk6eoXWm2syVEoPRDe19Vu43Yh8BIknA7x92NKbA5q/Fn8snPo34UEp9Vqo EldjdJk1d6nKN/B/It2UPJBwucd3/efL4MqkVtsKUVBOv25U4TxbLNP0Q0kwdxGvrMx+ aPmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=sZWt42IkXoz6fTpATIpmdrNPAwDi2KVKj/U0sinlL94=; b=f5hAKjMkpAJeXkrSlB7uo4+bxCIWRlsHK/XQN/i1IthCwsMwOIIvLZLckhfVlqH9Ik LpsQraGKSU8bsUBvBH5CuRKrEC2xw1zSeKS0qymLZUXJXw73zd7ExUCzJgeQzJECKeho 842zjc+UvF15CXhEQNE2sPDNqyHBG9eBxttZfMA/f9CRAAPdVLBvNpKWEA8+7Kb7WTkZ Lx8h6aQgAjSKFNFKfou43woG4kzXK2HPbKYWD6Pggm5oWTU9lWtABtY8ArKZ/5B5hCbE f1ooBIGV068nVA9cmR72XOdaYsYFxx6T/iUy2FQZpBqFn9mqvUkTsg7XYyGgjvq/gmne OC4g== X-Gm-Message-State: AGi0PubaOjAqLiAlLmKovwy8Rq/VcKWZzjb7ecrszMHJLYYWvjwZKotb CUYRmccoxWZBy+tmq6wiyyUgtHgS X-Google-Smtp-Source: APiQypL2jdtcFM5ZCUdbMlERajuXYAxFfgwBrWK3NAMzCcypjNWoC2I+Cg94xKf9nJHMeu/t1JQrqw== X-Received: by 2002:a1c:7706:: with SMTP id t6mr281396wmi.110.1588276809307; Thu, 30 Apr 2020 13:00:09 -0700 (PDT) Received: from ?IPv6:2003:ea:8f0e:e300:b04f:e17d:bb1a:140e? (p200300EA8F0EE300B04FE17DBB1A140E.dip0.t-ipconnect.de. [2003:ea:8f0e:e300:b04f:e17d:bb1a:140e]) by smtp.googlemail.com with ESMTPSA id b191sm1000574wmd.39.2020.04.30.13.00.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Apr 2020 13:00:08 -0700 (PDT) Subject: [PATCH net-next 2/7] r8169: merge scale for tx and rx irq coalescing From: Heiner Kallweit To: Realtek linux nic maintainers , David Miller Cc: "netdev@vger.kernel.org" References: Message-ID: <47a27f86-23c8-7328-9329-39797f166013@gmail.com> Date: Thu, 30 Apr 2020 21:56:20 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Rx and tx scale are the same always. Simplify the code by using one scale for rx and tx only. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 65 +++++++++-------------- 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 726f4057a..1fddc5a5e 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -1768,41 +1768,29 @@ static void rtl8169_get_strings(struct net_device *dev, u32 stringset, u8 *data) * 1 1 160us 81.92us 1.31ms */ -/* rx/tx scale factors for one particular CPlusCmd[0:1] value */ -struct rtl_coalesce_scale { - /* Rx / Tx */ - u32 nsecs[2]; -}; - /* rx/tx scale factors for all CPlusCmd[0:1] cases */ struct rtl_coalesce_info { u32 speed; - struct rtl_coalesce_scale scalev[4]; /* each CPlusCmd[0:1] case */ + u32 scale_nsecs[4]; }; -/* produce (r,t) pairs with each being in series of *1, *8, *8*2, *8*2*2 */ -#define rxtx_x1822(r, t) { \ - {{(r), (t)}}, \ - {{(r)*8, (t)*8}}, \ - {{(r)*8*2, (t)*8*2}}, \ - {{(r)*8*2*2, (t)*8*2*2}}, \ -} +/* produce array with base delay *1, *8, *8*2, *8*2*2 */ +#define COALESCE_DELAY(d) { (d), 8 * (d), 16 * (d), 32 * (d) } + static const struct rtl_coalesce_info rtl_coalesce_info_8169[] = { - /* speed delays: rx00 tx00 */ - { SPEED_10, rxtx_x1822(40960, 40960) }, - { SPEED_100, rxtx_x1822( 2560, 2560) }, - { SPEED_1000, rxtx_x1822( 320, 320) }, + { SPEED_10, COALESCE_DELAY(40960) }, + { SPEED_100, COALESCE_DELAY(2560) }, + { SPEED_1000, COALESCE_DELAY(320) }, { 0 }, }; static const struct rtl_coalesce_info rtl_coalesce_info_8168_8136[] = { - /* speed delays: rx00 tx00 */ - { SPEED_10, rxtx_x1822(40960, 40960) }, - { SPEED_100, rxtx_x1822( 2560, 2560) }, - { SPEED_1000, rxtx_x1822( 5000, 5000) }, + { SPEED_10, COALESCE_DELAY(40960) }, + { SPEED_100, COALESCE_DELAY(2560) }, + { SPEED_1000, COALESCE_DELAY(5000) }, { 0 }, }; -#undef rxtx_x1822 +#undef COALESCE_DELAY /* get rx/tx scale vector corresponding to current speed */ static const struct rtl_coalesce_info * @@ -1827,7 +1815,6 @@ static int rtl_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) { struct rtl8169_private *tp = netdev_priv(dev); const struct rtl_coalesce_info *ci; - const struct rtl_coalesce_scale *scale; struct { u32 *max_frames; u32 *usecs; @@ -1835,6 +1822,7 @@ static int rtl_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) { &ec->rx_max_coalesced_frames, &ec->rx_coalesce_usecs }, { &ec->tx_max_coalesced_frames, &ec->tx_coalesce_usecs } }, *p = coal_settings; + u32 scale; int i; u16 w; @@ -1848,7 +1836,7 @@ static int rtl_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) if (IS_ERR(ci)) return PTR_ERR(ci); - scale = &ci->scalev[tp->cp_cmd & INTT_MASK]; + scale = ci->scale_nsecs[tp->cp_cmd & INTT_MASK]; /* read IntrMitigate and adjust according to scale */ for (w = RTL_R16(tp, IntrMitigate); w; w >>= RTL_COALESCE_SHIFT, p++) { @@ -1859,7 +1847,7 @@ static int rtl_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) for (i = 0; i < 2; i++) { p = coal_settings + i; - *p->usecs = (*p->usecs * scale->nsecs[i]) / 1000; + *p->usecs = (*p->usecs * scale) / 1000; /* * ethtool_coalesce says it is illegal to set both usecs and @@ -1873,32 +1861,29 @@ static int rtl_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) } /* choose appropriate scale factor and CPlusCmd[0:1] for (speed, nsec) */ -static const struct rtl_coalesce_scale *rtl_coalesce_choose_scale( - struct rtl8169_private *tp, u32 nsec, u16 *cp01) +static int rtl_coalesce_choose_scale(struct rtl8169_private *tp, u32 nsec, + u16 *cp01) { const struct rtl_coalesce_info *ci; u16 i; ci = rtl_coalesce_info(tp); if (IS_ERR(ci)) - return ERR_CAST(ci); + return PTR_ERR(ci); for (i = 0; i < 4; i++) { - u32 rxtx_maxscale = max(ci->scalev[i].nsecs[0], - ci->scalev[i].nsecs[1]); - if (nsec <= rxtx_maxscale * RTL_COALESCE_T_MAX) { + if (nsec <= ci->scale_nsecs[i] * RTL_COALESCE_T_MAX) { *cp01 = i; - return &ci->scalev[i]; + return ci->scale_nsecs[i]; } } - return ERR_PTR(-EINVAL); + return -EINVAL; } static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) { struct rtl8169_private *tp = netdev_priv(dev); - const struct rtl_coalesce_scale *scale; struct { u32 frames; u32 usecs; @@ -1906,16 +1891,16 @@ static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) { ec->rx_max_coalesced_frames, ec->rx_coalesce_usecs }, { ec->tx_max_coalesced_frames, ec->tx_coalesce_usecs } }, *p = coal_settings; - u16 w = 0, cp01; - int i; + u16 w = 0, cp01 = 0; + int scale, i; if (rtl_is_8125(tp)) return -EOPNOTSUPP; scale = rtl_coalesce_choose_scale(tp, max(p[0].usecs, p[1].usecs) * 1000, &cp01); - if (IS_ERR(scale)) - return PTR_ERR(scale); + if (scale < 0) + return scale; for (i = 0; i < 2; i++, p++) { u32 units; @@ -1936,7 +1921,7 @@ static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) p->frames = 0; } - units = p->usecs * 1000 / scale->nsecs[i]; + units = p->usecs * 1000 / scale; if (p->frames > RTL_COALESCE_FRAME_MAX || p->frames % 4) return -EINVAL; From patchwork Thu Apr 30 19:57:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 220136 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59FDEC4724C for ; Thu, 30 Apr 2020 20:00:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3C1002072A for ; Thu, 30 Apr 2020 20:00:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Np9diWhO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726915AbgD3UAR (ORCPT ); Thu, 30 Apr 2020 16:00:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726784AbgD3UAN (ORCPT ); Thu, 30 Apr 2020 16:00:13 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E262BC035494 for ; Thu, 30 Apr 2020 13:00:12 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id h4so3413404wmb.4 for ; Thu, 30 Apr 2020 13:00:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=xN+odAodqOebFWoxnEURaCdwiNve62tDkHg9Crur6qg=; b=Np9diWhOhVbbW7NDerk66E9zs4YuI0hjsUG4k7vtqTtBTFAiPVgZZZDQ+gbmH8R3aP fv3g+x176lGEKHIwR6zxyQ8J/UcYptxmH/KkH8PPObwN8E579bsCPCJnpYM0hsz6bQ6x nzX3XG6c6GswvSev6N7sh/EeJGSXBm4JwM69fxWfdLpsgiezFCUDBDMEQFrYJ7JsyTF2 tk/xj4Yp9akzGUYNHAuelz7TSrYb297LZpOP3Dl6nDjr8czVFIAwJUzPdfKorUjAUoWP EI17aOPWOFgp/fkUmViOFxclzxMb+jSqdFmsK0f5Nm7lSUYHL8jNPS6gNKwEooQ1I52y hw4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=xN+odAodqOebFWoxnEURaCdwiNve62tDkHg9Crur6qg=; b=iTIgr11K6W0kPRMI0E8Oiwk8AePdRBOxygkLKqA8CVmLTGbCAz8Fm1SKTfCysLY7aq Ez+cn4IABWCNmuSSylUiHA6GPdzBhEVZwboPJSN4d8nDM7OzQjQncOK8kyovrFXuyfEg 4WoCjxJ2y/dd3Fbfuah+nIaBxaKB0wqR5aMgobJsqiCx1Cx/VZSizFXji/iK4SQRaK8h bMKUVWkGSkG/6qpN8983VgXUg6nGZPZs0XWDScsH975y3I8sOwEKEUk/KkRnzoAGt4m4 losx31gpYSPTobKm1njftceqYulRfrHkP68shcNZDNEvJqIrMrH02MHKwD5352Kz6rOV ibKw== X-Gm-Message-State: AGi0PuYRtzHCLiX9+fByy4tGoNErKSHIppHGkfjwT8QtxLyVoBEYTuZY wJa/4vbI0zLIxkx1LJAUOH8iWkrq X-Google-Smtp-Source: APiQypLHMsCghVYM2ONe+LedzCKjyQPMJDVV92SA00X1J2OAMQt82lQpvJ9WFNf3C0alRpn+thTPCQ== X-Received: by 2002:a7b:c104:: with SMTP id w4mr298441wmi.8.1588276811343; Thu, 30 Apr 2020 13:00:11 -0700 (PDT) Received: from ?IPv6:2003:ea:8f0e:e300:b04f:e17d:bb1a:140e? (p200300EA8F0EE300B04FE17DBB1A140E.dip0.t-ipconnect.de. [2003:ea:8f0e:e300:b04f:e17d:bb1a:140e]) by smtp.googlemail.com with ESMTPSA id n6sm1176343wrs.81.2020.04.30.13.00.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Apr 2020 13:00:10 -0700 (PDT) Subject: [PATCH net-next 4/7] r8169: improve rtl_coalesce_choose_scale From: Heiner Kallweit To: Realtek linux nic maintainers , David Miller Cc: "netdev@vger.kernel.org" References: Message-ID: <15ec315a-724b-e4ba-83ad-9df424307fa4@gmail.com> Date: Thu, 30 Apr 2020 21:57:32 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The time limit provided by userspace is multiplied with 1000, what could result in an overflow. Therefore change the time limit parameter unit from ns to us, and avoid the problematic operation. If there's no matching scale because provided time limit is too big, return ERANGE instead of EINVAL to provide a hint to the user what's wrong. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index d898e6f5f..a95615684 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -1854,8 +1854,8 @@ static int rtl_get_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) return 0; } -/* choose appropriate scale factor and CPlusCmd[0:1] for (speed, nsec) */ -static int rtl_coalesce_choose_scale(struct rtl8169_private *tp, u32 nsec, +/* choose appropriate scale factor and CPlusCmd[0:1] for (speed, usec) */ +static int rtl_coalesce_choose_scale(struct rtl8169_private *tp, u32 usec, u16 *cp01) { const struct rtl_coalesce_info *ci; @@ -1866,13 +1866,13 @@ static int rtl_coalesce_choose_scale(struct rtl8169_private *tp, u32 nsec, return PTR_ERR(ci); for (i = 0; i < 4; i++) { - if (nsec <= ci->scale_nsecs[i] * RTL_COALESCE_T_MAX) { + if (usec <= ci->scale_nsecs[i] * RTL_COALESCE_T_MAX / 1000U) { *cp01 = i; return ci->scale_nsecs[i]; } } - return -EINVAL; + return -ERANGE; } static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) @@ -1886,13 +1886,14 @@ static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) { ec->tx_max_coalesced_frames, ec->tx_coalesce_usecs } }, *p = coal_settings; u16 w = 0, cp01 = 0; + u32 coal_usec_max; int scale, i; if (rtl_is_8125(tp)) return -EOPNOTSUPP; - scale = rtl_coalesce_choose_scale(tp, - max(p[0].usecs, p[1].usecs) * 1000, &cp01); + coal_usec_max = max(ec->rx_coalesce_usecs, ec->tx_coalesce_usecs); + scale = rtl_coalesce_choose_scale(tp, coal_usec_max, &cp01); if (scale < 0) return scale; From patchwork Thu Apr 30 19:59:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 220135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E9EFC4724C for ; Thu, 30 Apr 2020 20:00:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0B1382072A for ; Thu, 30 Apr 2020 20:00:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lpt0ysMS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726961AbgD3UAV (ORCPT ); Thu, 30 Apr 2020 16:00:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726764AbgD3UAQ (ORCPT ); Thu, 30 Apr 2020 16:00:16 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3418C035494 for ; Thu, 30 Apr 2020 13:00:15 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id g12so3575125wmh.3 for ; Thu, 30 Apr 2020 13:00:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=m/z3pQ3DUBxVgJ+cnZWVOh7UmSQTTtMSGiNh0lbgWXY=; b=lpt0ysMS/NHBjPRT1AW8XjNEoKXoD4ZOKRBxE6frR1e5NE+yi9UEfHBuFw6qda5oKW V34FyNPWqUbH9rYgq/GQ1UMvHBKzAFcqjmckELnkeK4JcY06hX0him9Tviw4K23FF4gl ozzOGAJCTRBKb7YZo9UD2AlWYXzc9p+xFUemblqH/2cVQ7EBBeygUSIIGYqNAUScmKmR VMDG8u/P9Kwyf+gJp9KheL6hM05+Uy/2MY4SlUjV7/PyHBy/uES6GLJjMb7E58HVyvSz t42ihqZptOI+QMhgF385zzg5EWkH6tP99WoiM7ziT+V4wdW59Ob45O1QwDbOfvFlgR7Q N6Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=m/z3pQ3DUBxVgJ+cnZWVOh7UmSQTTtMSGiNh0lbgWXY=; b=PZMXJ5eUucOpeOl2pVeI4Y5a4TSIuzVuX+pbUr+euIJS/jsG/4+rtmNhGnmtBrE6+O NGjsGoIU015mcMXd3NQESktZHINh7xO7rJiM+TlrJQH9HHQJv+QH1+7izpQXbqFuqD7M zhWuJ9BNreHkLcZPPk+2/ZRuke0xmWKJ5b5TyAHEP+J2STJOEsTOUGnavDJG5kyfMkMM nqALxdBipvDJGg+6SHWSBSPC4pTvAg1b2wvMeJiYGvKtUrp7LixrdMXpxHS2xtIcteKT uk4iaShJvBIKtGnbYpv7iNvMtalArpMtSGKOPEF7SiuhQwgw7HLWF0yIgT6hI0CupRWH fzRg== X-Gm-Message-State: AGi0PubH/IM9PbatvwODM/9uK0CA6ATH4Kp0Zpd25xvuXE5MQ7IAnYbC 1baSsuY4Vj1I8l5dYFHPuoMv8BCK X-Google-Smtp-Source: APiQypIU6xRl4XT1OeKhYqw9cElNUlracEp68G9+QEWARj7EzW0T2N/CvZKtUflo2x7iTlA9U0dOBA== X-Received: by 2002:a7b:cb88:: with SMTP id m8mr241564wmi.103.1588276814349; Thu, 30 Apr 2020 13:00:14 -0700 (PDT) Received: from ?IPv6:2003:ea:8f0e:e300:b04f:e17d:bb1a:140e? (p200300EA8F0EE300B04FE17DBB1A140E.dip0.t-ipconnect.de. [2003:ea:8f0e:e300:b04f:e17d:bb1a:140e]) by smtp.googlemail.com with ESMTPSA id k9sm1207877wrd.17.2020.04.30.13.00.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 30 Apr 2020 13:00:13 -0700 (PDT) Subject: [PATCH net-next 7/7] r8169: add check for invalid parameter combination in rtl_set_coalesce From: Heiner Kallweit To: Realtek linux nic maintainers , David Miller Cc: "netdev@vger.kernel.org" References: Message-ID: <14b4a80a-fb2c-f669-be09-4092bfc6cd57@gmail.com> Date: Thu, 30 Apr 2020 21:59:48 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Realtek provided information about a HW constraint that time limit must not be set to 0 if the frame limit is >0. Add a check for this and reject invalid parameter combinations. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 3fef1b254..0ac3976e3 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -1908,6 +1908,11 @@ static int rtl_set_coalesce(struct net_device *dev, struct ethtool_coalesce *ec) if (tx_fr == 1) tx_fr = 0; + /* HW requires time limit to be set if frame limit is set */ + if ((tx_fr && !ec->tx_coalesce_usecs) || + (rx_fr && !ec->rx_coalesce_usecs)) + return -EINVAL; + w |= FIELD_PREP(RTL_COALESCE_TX_FRAMES, DIV_ROUND_UP(tx_fr, 4)); w |= FIELD_PREP(RTL_COALESCE_RX_FRAMES, DIV_ROUND_UP(rx_fr, 4));