From patchwork Tue Dec 1 08:57:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 336673 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=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, 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 86E8DC8301A for ; Tue, 1 Dec 2020 09:30:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 477B7221FD for ; Tue, 1 Dec 2020 09:30:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="iUlHxlQs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391209AbgLAJaT (ORCPT ); Tue, 1 Dec 2020 04:30:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50382 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387900AbgLAI6R (ORCPT ); Tue, 1 Dec 2020 03:58:17 -0500 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 456E2C0613D2 for ; Tue, 1 Dec 2020 00:57:37 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id a6so1630781wmc.2 for ; Tue, 01 Dec 2020 00:57:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding; bh=pATMwjcygT9AkthrFzsMCRTD5iOTr1gj6Zd3ahL9hm4=; b=iUlHxlQslTPsF4nGMHFQw76o5BDkFoZSgJeXaW7SqzH72vuCU9rQZJ+FDDyBuq+IQE CW9cutAhnjIGCht3G3L+CGOooqr1WZ4pn09/hxpEyMdaFAhYpDScV5MeZwpdfP45FjnR qriJSqFJpfOK0HmJwC0Ac1ulex+Z7VKFE7QMNdjJeyL8b5rZsiHCJYfKaFE8H97Ovr/0 Bo1JsuQpKlk+0q4AXtUyXzVa0WGim0vn0CG0Z9f/CqlT8Ax4zGDFDi4MHd8mii4R8xGS bo9FcH3fXnMF4W9lhpGcWbj5/6x2UcEJenS0L9wGlH5lxNm/LOcYxyuCBAlmXcPVhnPA DwNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding; bh=pATMwjcygT9AkthrFzsMCRTD5iOTr1gj6Zd3ahL9hm4=; b=HIpt37awKKhQK7/hrL8CAvbiS5+iZB36SjXSxBrRVH3mh3XrGzlEkJWKcaXnsvtFly 0obKcYpSXuqRwHlFLlkxPb4D8VoX91DgVpCkBM4ZyhBGSrJVB6ym839AxtVwxNxGBDZV DBC8amKgfXkbIEK609XvGfHlY0FnfMudDS9/R6ksqY92YA0JSasAuy0+NvJptIzkQa6L o6tuB5srtP7YRVh9EVMgypD7iZAyA+E1D/JmxIdh5zqZw43x6/fuQdzVYR3KJw3Tjs/I Ku90+tJnArB+hJXY0TVTnjkWXJZKRYDRMf0l48GjRkXQWzJCrO/8pHRL4OSsCboU4Pam guJw== X-Gm-Message-State: AOAM5311h6kwLUPkbzhJTxPCvo7oOUoXNDcFMyBl+xoHn829BR3qoZcz HZJ4cO8lX2dmHVIOo4K/Y1JdWbteWQ8+ZA== X-Google-Smtp-Source: ABdhPJySO6pTDr4L2FgdEC8MtJ22rf2qM7LdG33lBo2GKWifYTf0X+a3EeHQixr+p9TCakv9wOL1AA== X-Received: by 2002:a1c:e084:: with SMTP id x126mr1628881wmg.109.1606813055611; Tue, 01 Dec 2020 00:57:35 -0800 (PST) Received: from ?IPv6:2003:ea:8f23:2800:c8da:c2a2:5860:ab22? (p200300ea8f232800c8dac2a25860ab22.dip0.t-ipconnect.de. [2003:ea:8f23:2800:c8da:c2a2:5860:ab22]) by smtp.googlemail.com with ESMTPSA id a12sm1891602wrq.58.2020.12.01.00.57.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Dec 2020 00:57:35 -0800 (PST) From: Heiner Kallweit Subject: [PATCH net-next] r8169: set tc_offset only if tally counter reset isn't supported To: Jakub Kicinski , David Miller , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" Message-ID: <526618b2-b1bf-1844-b82a-dab2df7bdc8f@gmail.com> Date: Tue, 1 Dec 2020 09:57:29 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On chip versions supporting tally counter reset we currently update the counters after a reset although we know all counters are zero. Skip this unnecessary step. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 25 ++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 32a4c8c0b..3ef1b31c9 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -1562,16 +1562,6 @@ static void rtl8169_do_counters(struct rtl8169_private *tp, u32 counter_cmd) rtl_loop_wait_low(tp, &rtl_counters_cond, 10, 1000); } -static void rtl8169_reset_counters(struct rtl8169_private *tp) -{ - /* - * Versions prior to RTL_GIGA_MAC_VER_19 don't support resetting the - * tally counters. - */ - if (tp->mac_version >= RTL_GIGA_MAC_VER_19) - rtl8169_do_counters(tp, CounterReset); -} - static void rtl8169_update_counters(struct rtl8169_private *tp) { u8 val = RTL_R8(tp, ChipCmd); @@ -1606,13 +1596,16 @@ static void rtl8169_init_counter_offsets(struct rtl8169_private *tp) if (tp->tc_offset.inited) return; - rtl8169_reset_counters(tp); - rtl8169_update_counters(tp); + if (tp->mac_version >= RTL_GIGA_MAC_VER_19) { + rtl8169_do_counters(tp, CounterReset); + } else { + rtl8169_update_counters(tp); + tp->tc_offset.tx_errors = counters->tx_errors; + tp->tc_offset.tx_multi_collision = counters->tx_multi_collision; + tp->tc_offset.tx_aborted = counters->tx_aborted; + tp->tc_offset.rx_missed = counters->rx_missed; + } - tp->tc_offset.tx_errors = counters->tx_errors; - tp->tc_offset.tx_multi_collision = counters->tx_multi_collision; - tp->tc_offset.tx_aborted = counters->tx_aborted; - tp->tc_offset.rx_missed = counters->rx_missed; tp->tc_offset.inited = true; }