From patchwork Tue Jan 12 08:28:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12012721 X-Patchwork-Delegate: kuba@kernel.org 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 A9F02C433E6 for ; Tue, 12 Jan 2021 08:29:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 66569221FC for ; Tue, 12 Jan 2021 08:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405424AbhALI30 (ORCPT ); Tue, 12 Jan 2021 03:29:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405405AbhALI30 (ORCPT ); Tue, 12 Jan 2021 03:29:26 -0500 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81444C061575 for ; Tue, 12 Jan 2021 00:28:45 -0800 (PST) Received: by mail-wm1-x330.google.com with SMTP id 190so1106570wmz.0 for ; Tue, 12 Jan 2021 00:28:45 -0800 (PST) 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=l0azDAxFxfqdbj7nWlyJ2wSq6xWvCEoOtEgYv1pxqRw=; b=bJ1+MXu2A+uIDlRmoihGslRkuOAtdf5LpKh5Fl9fYyP6ER8IKwff6OU557nyFnpo3C r+Q/Y9N8bBySFfDqUXUOI9yexE3fU4u50LVxSRdnhFB8nwsJeoxLhU/2oO8ur7wUlcvN uazLVIsSrygxYpWVTyDB0ezWzE8KSO8sdjpE9/lmrmUMSwaEV1xOjiZfsg5QKCnGnSNC G33KYTQX7P9O8V04LXmFgl1AmICL07uqFXRbOK/1jyWqhLtx5WZ3ZAnAXaZQauvlWojH 92/qRfE2k21dMobqJEK7ghBc3BDXLSFsI6QdGcREDnPPbuJvBhJG6nype6Ps4YYtwvP5 369g== 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=l0azDAxFxfqdbj7nWlyJ2wSq6xWvCEoOtEgYv1pxqRw=; b=OeCHO9NYVEUF2BceQvPQGr1w4mNcuC/uZ2++7sx0Sg24hJGmuLYYOopGmQdpykxWK4 Z1lEdQbjt44RCQ7ykt8+jxjwkrbKxt9TvZvlgUeNPxk75ymbXRcSP0AL3yN7HJQAts+I 0GvTM32UDjZU4B5HqFmquDMLCk9KF5b/0nKvFTpUzsrTkd24coaRI8yotApMS7hzvNE7 dxcdtZ4dZxFQJoHFSw4ig5eGb3cNww4rcmezBQFPYgyno8bEJ48a5YrWiu/LgDPOTBdV qdS/pyrXAfl4M8IhCBguBty/VP57HfI4kGXuccHhQzrBWgNhEbN0iGbAyH4i7w0lbd3j UbGw== X-Gm-Message-State: AOAM530Qo5Qkl9cKIK2IyP19F7Q2BavVwpYbg1mPKvf1HI/ke8helX0W y3lqivuKFK94SHGtwTQ3S3a9CGMgrtM= X-Google-Smtp-Source: ABdhPJxecei1syp/iGzMLtJDltbOz43kwiQi0v3hWJyGCPzfZnGwmj6kBKkcAXoGCbUPE/JmmuOGBA== X-Received: by 2002:a1c:4e19:: with SMTP id g25mr2359021wmh.93.1610440124091; Tue, 12 Jan 2021 00:28:44 -0800 (PST) Received: from ?IPv6:2003:ea:8f06:5500:d420:a714:6def:4af7? (p200300ea8f065500d420a7146def4af7.dip0.t-ipconnect.de. [2003:ea:8f06:5500:d420:a714:6def:4af7]) by smtp.googlemail.com with ESMTPSA id h13sm3609582wrm.28.2021.01.12.00.28.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jan 2021 00:28:43 -0800 (PST) Subject: [PATCH net-next 1/3] r8169: align rtl_wol_suspend_quirk with vendor driver and rename it From: Heiner Kallweit To: Jakub Kicinski , David Miller , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: <1bc3b7ef-b54a-d517-df54-27d61ca7ba94@gmail.com> Message-ID: Date: Tue, 12 Jan 2021 09:28:41 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <1bc3b7ef-b54a-d517-df54-27d61ca7ba94@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org At least from chip version 25 the vendor driver sets these rx flags for all chip versions if WOL is enabled. Therefore I wouldn't consider it a quirk, so let's rename the function. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 33336098b..84f488d1c 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -2210,23 +2210,11 @@ static int rtl_set_mac_address(struct net_device *dev, void *p) return 0; } -static void rtl_wol_suspend_quirk(struct rtl8169_private *tp) +static void rtl_wol_enable_rx(struct rtl8169_private *tp) { - switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_25: - case RTL_GIGA_MAC_VER_26: - case RTL_GIGA_MAC_VER_29: - case RTL_GIGA_MAC_VER_30: - case RTL_GIGA_MAC_VER_32: - case RTL_GIGA_MAC_VER_33: - case RTL_GIGA_MAC_VER_34: - case RTL_GIGA_MAC_VER_37 ... RTL_GIGA_MAC_VER_63: + if (tp->mac_version >= RTL_GIGA_MAC_VER_25) RTL_W32(tp, RxConfig, RTL_R32(tp, RxConfig) | AcceptBroadcast | AcceptMulticast | AcceptMyPhys); - break; - default: - break; - } } static void rtl_prepare_power_down(struct rtl8169_private *tp) @@ -2240,7 +2228,7 @@ static void rtl_prepare_power_down(struct rtl8169_private *tp) if (device_may_wakeup(tp_to_dev(tp))) { phy_speed_down(tp->phydev, false); - rtl_wol_suspend_quirk(tp); + rtl_wol_enable_rx(tp); } } @@ -4872,7 +4860,7 @@ static void rtl_shutdown(struct pci_dev *pdev) if (system_state == SYSTEM_POWER_OFF) { if (tp->saved_wolopts) { - rtl_wol_suspend_quirk(tp); + rtl_wol_enable_rx(tp); rtl_wol_shutdown_quirk(tp); } From patchwork Tue Jan 12 08:29:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12012723 X-Patchwork-Delegate: kuba@kernel.org 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 64C66C433E0 for ; Tue, 12 Jan 2021 08:30:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 284D122DD3 for ; Tue, 12 Jan 2021 08:30:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405556AbhALIae (ORCPT ); Tue, 12 Jan 2021 03:30:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405068AbhALIad (ORCPT ); Tue, 12 Jan 2021 03:30:33 -0500 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 117DDC061575 for ; Tue, 12 Jan 2021 00:29:49 -0800 (PST) Received: by mail-wr1-x433.google.com with SMTP id a12so1490115wrv.8 for ; Tue, 12 Jan 2021 00:29:48 -0800 (PST) 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=cePMcyi0KtDrhtKJT1Dly10onkOcNFFKNROUVgRJ3aw=; b=flyV+i6+WyvJPnUl2PvZbOfhLZRzmRTC8E0vXgoDQdXTkBR91Fr1iZd1OBuMBolAII XkrtA1QHlMWxH0Idk/UJ+1stT1jhFQ/fEzC4Sc2/lyNMa7zclQmb/ZZHKxAQ2QXSkMhb Stf/iOX7zNV1DgwWPNyFJ7HC32R3ikV7EKfcgBEfJNGmdqUDmCq/W3swwizp936iV4vd JOvgaDagNDqLYhgDEwK97Rfq0TslgPgOYwOJIw0QRuY+e9i/2rNzoLIO1OqHCbUSF2Oe GlFnP8UzJP9Fr6MyEdKBt8vEnC189zvHzcmmHi1W5xe2GjplEhWAvTGPgCWgeV1bv28u HjoA== 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=cePMcyi0KtDrhtKJT1Dly10onkOcNFFKNROUVgRJ3aw=; b=Npl+tbjEx1DYOCqfg6Lgt1OxmURe4LUDaVtPXGxglAtcd+uakHR46u9D5vum9Y+u4D oo6KB6AlaZj9mxaCZwBSw2hcUyytcUGuwS4WjNkz7BNeatLtKhxm2bHyz4UujCkul9hu /JVN41JC20/cK7Z4T3nLMVglCRwbtcHty4lWHu2/BwLxpN1sqU+M1lic5Uleixl1Oy4x NjiDyndzSaduvmOmL2nneudi5F+PEEnkiNVimMBWg5unpNBH+m8EYK1wd37GjFcqY/24 ld8J6GInQpavFMDU94j6NHVj37ZQEp0vJwh/7cAJN/9ejYOFMFn0blx02jNbmBfJpJEs 1Zrg== X-Gm-Message-State: AOAM531WM7SOcG4H7GIBo8tYc1dqqMNJYlZfn46BK54uFJsU1Z0ss/+I zHREdFKYoLbznaKxFnfcg/ipwV5MjZ4= X-Google-Smtp-Source: ABdhPJxM8TU3NGQKWe/5JLFtV5EI1dg7oYtLQCLl9oYmmuODd9qC1tflDMjD5u+SqBxUWv5g9+9CMw== X-Received: by 2002:a5d:690d:: with SMTP id t13mr2998698wru.410.1610440187620; Tue, 12 Jan 2021 00:29:47 -0800 (PST) Received: from ?IPv6:2003:ea:8f06:5500:d420:a714:6def:4af7? (p200300ea8f065500d420a7146def4af7.dip0.t-ipconnect.de. [2003:ea:8f06:5500:d420:a714:6def:4af7]) by smtp.googlemail.com with ESMTPSA id z8sm1376462wrh.65.2021.01.12.00.29.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jan 2021 00:29:47 -0800 (PST) Subject: [PATCH net-next 2/3] r8169: improve rtl8169_rx_csum From: Heiner Kallweit To: Jakub Kicinski , David Miller , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: <1bc3b7ef-b54a-d517-df54-27d61ca7ba94@gmail.com> Message-ID: Date: Tue, 12 Jan 2021 09:29:45 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <1bc3b7ef-b54a-d517-df54-27d61ca7ba94@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Extend the mask to include the checksum failure bits. This allows to simplify the condition in rtl8169_rx_csum(). Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 84f488d1c..b4c080cc6 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -533,6 +533,9 @@ enum rtl_rx_desc_bit { IPFail = (1 << 16), /* IP checksum failed */ UDPFail = (1 << 15), /* UDP/IP checksum failed */ TCPFail = (1 << 14), /* TCP/IP checksum failed */ + +#define RxCSFailMask (IPFail | UDPFail | TCPFail) + RxVlanTag = (1 << 16), /* VLAN tag available */ }; @@ -4377,10 +4380,9 @@ static inline int rtl8169_fragmented_frame(u32 status) static inline void rtl8169_rx_csum(struct sk_buff *skb, u32 opts1) { - u32 status = opts1 & RxProtoMask; + u32 status = opts1 & (RxProtoMask | RxCSFailMask); - if (((status == RxProtoTCP) && !(opts1 & TCPFail)) || - ((status == RxProtoUDP) && !(opts1 & UDPFail))) + if (status == RxProtoTCP || status == RxProtoUDP) skb->ip_summed = CHECKSUM_UNNECESSARY; else skb_checksum_none_assert(skb); From patchwork Tue Jan 12 08:31:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 12012725 X-Patchwork-Delegate: kuba@kernel.org 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 F2A2CC433DB for ; Tue, 12 Jan 2021 08:32:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AC58722D58 for ; Tue, 12 Jan 2021 08:32:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405578AbhALIcF (ORCPT ); Tue, 12 Jan 2021 03:32:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405230AbhALIcF (ORCPT ); Tue, 12 Jan 2021 03:32:05 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E45DDC061786 for ; Tue, 12 Jan 2021 00:31:24 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id a12so1495282wrv.8 for ; Tue, 12 Jan 2021 00:31:24 -0800 (PST) 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=PQQa2bXqMB0L6EZnJGHlqQyCdoS8v8GxuelOcwERFVg=; b=Nwu4utx8eltQUuq6657VtbcWWvDyLrfVeNcqW3dzh/0DI/e+8FFLcLFMym0hjIesw3 VqGXqLW+wFqZcxfpx6XuogKDx1+zlMhY+4D2esHzG5fl3aP/ehN2nUWujj89W1l7Ucal wseYftq1/KVFN4/xaY1Awoqbero34RdSkTSU+P9Ko4Zl3l+TfvHU1KhsPnyzF55IVwVR SyCwQI3vhxMrosWb13DUrQ+5FHya5v2MFsNxWOGRW24Mq/gj4eSh9ggSBoLW3nks4G5R 2dGkyCkitncxNcJwQDHRsTRuBEVlEsQDc37PEz31ZqWP896fF12H4Kx9D1uBcER72gy+ wngg== 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=PQQa2bXqMB0L6EZnJGHlqQyCdoS8v8GxuelOcwERFVg=; b=K3CAsdWAuJHg8VysG33ZI4Ww4E4wEhu4A1iJ350Zg6FzlEQKeNsVZ6QdV2mBRR8RQd DXsiS2xMLF5mJHhh+K26Sgqxuf/mUyZByjT/qCkxzqscZoVGdpfspmK+o+0M9G66RtV1 AdJQPK+BvXETyflhnqJWU6QIA4mh4f9q95apwD8gBxBNqZEepbhlgBCUSBp+o4ZpBEBp Ub9XoqqPqONje06L384Nu+GlPaen2tEcpo0mM9dHIrdVqo1d1RKP1PO15+sZNlHC7C3J IgMijErkTUu9qWljlTivlm++DlDbgvUY9CoWn0Cl83MnO6OrdiXD8o1t41SYjbFQ0hy3 MGsQ== X-Gm-Message-State: AOAM530CvUCg6QM5QFDoNeZ/cEMeKwtjrfKdgk2MU7K6lPl2s2YZj2Mt dlYV1NtfboxgCaThDVB11KEkzQw5kg8= X-Google-Smtp-Source: ABdhPJw6eieqMKF5G0MM4OQwdJIyVH+HNuieFpRV/GaKYgWtWaxYKw/nq2boedgbrFMXliZImU3SBw== X-Received: by 2002:adf:9d82:: with SMTP id p2mr3013208wre.330.1610440283404; Tue, 12 Jan 2021 00:31:23 -0800 (PST) Received: from ?IPv6:2003:ea:8f06:5500:d420:a714:6def:4af7? (p200300ea8f065500d420a7146def4af7.dip0.t-ipconnect.de. [2003:ea:8f06:5500:d420:a714:6def:4af7]) by smtp.googlemail.com with ESMTPSA id h5sm3789093wrp.56.2021.01.12.00.31.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jan 2021 00:31:23 -0800 (PST) Subject: [PATCH net-next 3/3] r8169: improve DASH support From: Heiner Kallweit To: Jakub Kicinski , David Miller , Realtek linux nic maintainers Cc: "netdev@vger.kernel.org" References: <1bc3b7ef-b54a-d517-df54-27d61ca7ba94@gmail.com> Message-ID: Date: Tue, 12 Jan 2021 09:31:20 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <1bc3b7ef-b54a-d517-df54-27d61ca7ba94@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Instead of doing the full DASH check each time r8168_check_dash() is called, let's do it once in probe and store DASH capabilities in a new rtl8169_private member. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/realtek/r8169_main.c | 53 ++++++++++------------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index b4c080cc6..fb67d8f79 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -591,6 +591,12 @@ enum rtl_flag { RTL_FLAG_MAX }; +enum rtl_dash_type { + RTL_DASH_NONE, + RTL_DASH_DP, + RTL_DASH_EP, +}; + struct rtl8169_private { void __iomem *mmio_addr; /* memory map physical address */ struct pci_dev *pci_dev; @@ -598,6 +604,7 @@ struct rtl8169_private { struct phy_device *phydev; struct napi_struct napi; enum mac_version mac_version; + enum rtl_dash_type dash_type; u32 cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */ u32 cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */ u32 dirty_tx; @@ -1184,19 +1191,10 @@ static void rtl8168ep_driver_start(struct rtl8169_private *tp) static void rtl8168_driver_start(struct rtl8169_private *tp) { - switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_27: - case RTL_GIGA_MAC_VER_28: - case RTL_GIGA_MAC_VER_31: + if (tp->dash_type == RTL_DASH_DP) rtl8168dp_driver_start(tp); - break; - case RTL_GIGA_MAC_VER_49 ... RTL_GIGA_MAC_VER_52: + else rtl8168ep_driver_start(tp); - break; - default: - BUG(); - break; - } } static void rtl8168dp_driver_stop(struct rtl8169_private *tp) @@ -1215,44 +1213,35 @@ static void rtl8168ep_driver_stop(struct rtl8169_private *tp) static void rtl8168_driver_stop(struct rtl8169_private *tp) { - switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_27: - case RTL_GIGA_MAC_VER_28: - case RTL_GIGA_MAC_VER_31: + if (tp->dash_type == RTL_DASH_DP) rtl8168dp_driver_stop(tp); - break; - case RTL_GIGA_MAC_VER_49 ... RTL_GIGA_MAC_VER_52: + else rtl8168ep_driver_stop(tp); - break; - default: - BUG(); - break; - } } static bool r8168dp_check_dash(struct rtl8169_private *tp) { u16 reg = rtl8168_get_ocp_reg(tp); - return !!(r8168dp_ocp_read(tp, reg) & 0x00008000); + return r8168dp_ocp_read(tp, reg) & BIT(15); } static bool r8168ep_check_dash(struct rtl8169_private *tp) { - return r8168ep_ocp_read(tp, 0x128) & 0x00000001; + return r8168ep_ocp_read(tp, 0x128) & BIT(0); } -static bool r8168_check_dash(struct rtl8169_private *tp) +static enum rtl_dash_type rtl_check_dash(struct rtl8169_private *tp) { switch (tp->mac_version) { case RTL_GIGA_MAC_VER_27: case RTL_GIGA_MAC_VER_28: case RTL_GIGA_MAC_VER_31: - return r8168dp_check_dash(tp); + return r8168dp_check_dash(tp) ? RTL_DASH_DP : RTL_DASH_NONE; case RTL_GIGA_MAC_VER_49 ... RTL_GIGA_MAC_VER_52: - return r8168ep_check_dash(tp); + return r8168ep_check_dash(tp) ? RTL_DASH_EP : RTL_DASH_NONE; default: - return false; + return RTL_DASH_NONE; } } @@ -2222,7 +2211,7 @@ static void rtl_wol_enable_rx(struct rtl8169_private *tp) static void rtl_prepare_power_down(struct rtl8169_private *tp) { - if (r8168_check_dash(tp)) + if (tp->dash_type != RTL_DASH_NONE) return; if (tp->mac_version == RTL_GIGA_MAC_VER_32 || @@ -4880,7 +4869,7 @@ static void rtl_remove_one(struct pci_dev *pdev) unregister_netdev(tp->dev); - if (r8168_check_dash(tp)) + if (tp->dash_type != RTL_DASH_NONE) rtl8168_driver_stop(tp); rtl_release_firmware(tp); @@ -5240,6 +5229,8 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) tp->mac_version = chipset; + tp->dash_type = rtl_check_dash(tp); + tp->cp_cmd = RTL_R16(tp, CPlusCmd) & CPCMD_MASK; if (sizeof(dma_addr_t) > 4 && tp->mac_version >= RTL_GIGA_MAC_VER_18 && @@ -5344,7 +5335,7 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) jumbo_max, tp->mac_version <= RTL_GIGA_MAC_VER_06 ? "ok" : "ko"); - if (r8168_check_dash(tp)) { + if (tp->dash_type != RTL_DASH_NONE) { netdev_info(dev, "DASH enabled\n"); rtl8168_driver_start(tp); }