From patchwork Sun Sep 27 17:42:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 289541 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=-13.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_HEADER_CTYPE_ONLY, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, T_TVD_MIME_NO_HEADERS, USER_AGENT_GIT 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 19DD1C4346E for ; Sun, 27 Sep 2020 17:42:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CEB6123976 for ; Sun, 27 Sep 2020 17:42:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="cTibLTaR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726458AbgI0Rmt (ORCPT ); Sun, 27 Sep 2020 13:42:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726321AbgI0Rmr (ORCPT ); Sun, 27 Sep 2020 13:42:47 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD9E7C0613D3 for ; Sun, 27 Sep 2020 10:42:47 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id t18so1960276plo.1 for ; Sun, 27 Sep 2020 10:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=54IxSqK54h8ftvWavuwNFlDxVAjveMJx4K2FncD++Kk=; b=cTibLTaR+mB3fQTBARlhElP9nja2ZpxPW5fSmFcJjlPXH0EzMTyLA+gclViNQ97sQw m/e1QlLNNDCuFRZSf0s29/5InHFWT+iWyV6jCxDjEqOLRS6mxr4KB52HPdb2bttO3JrR yCT5BzZ71zugoPS17sWk2mKJqrTNVSrYGAOg8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=54IxSqK54h8ftvWavuwNFlDxVAjveMJx4K2FncD++Kk=; b=GPJM84I5Fya/wosMBCsKbMkkc30x6FLt+p36sIevXjmRsJdQBKc8TUV8XKAiV7ThEJ etM0SmM3fHgW6yhoNPZE5QoeBa4zJobKFG8Ic1IzuIdgOnaigDZboCusBpWYrH3Jw033 UsvxL42hUnxUlkFd9s8pgJ44CnelHpuFKrBOdBvfkdJ1ldtqatvXBIQn5NNhWO4S0uZn Yswsy5zXFQXvVLep50gBAf+RJFcWhCO7cgVpov56E+KE2a/i7DLOzCIrjeRzRJtoJvWT 7BcuS6t58iXPzarm2ZdHZSJSQY1WefHGqavjmVzzJxeeaoR8t+8h5L/q8QGZYGJqQcIB 0BzA== X-Gm-Message-State: AOAM530MEHDisQLc2cpKf3z5HRSK9yd2ufdhLzktbo2KlycOoKMK2PBC h+1oLsGitE8Q5dHW+0loybhG9A== X-Google-Smtp-Source: ABdhPJxW1Wlw/Sda3EoawOiTU7/w5MLrjBtrFveqbttV8yHszPuoavczB/vx5sa/djw3yy7kaX4J5w== X-Received: by 2002:a17:902:8f8f:b029:d2:4276:1b2d with SMTP id z15-20020a1709028f8fb02900d242761b2dmr8093596plo.17.1601228567044; Sun, 27 Sep 2020 10:42:47 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id o19sm8765570pfp.64.2020.09.27.10.42.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Sep 2020 10:42:46 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, Edwin Peer Subject: [PATCH net-next 02/11] bnxt_en: refactor code to limit speed advertising Date: Sun, 27 Sep 2020 13:42:11 -0400 Message-Id: <1601228540-20852-3-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1601228540-20852-1-git-send-email-michael.chan@broadcom.com> References: <1601228540-20852-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Edwin Peer Extract the code for determining an advertised speed is no longer supported into a separate function. This will avoid some code duplication in a later patch when supporting PAM4 speeds, since these speeds are specified in a separate field. Reviewed-by: Scott Branden Signed-off-by: Edwin Peer Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b57f28d2e716..0ca4f7a78c5d 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -8835,6 +8835,13 @@ static int bnxt_hwrm_phy_qcaps(struct bnxt *bp) return rc; } +static bool bnxt_support_dropped(u16 advertising, u16 supported) +{ + u16 diff = advertising ^ supported; + + return ((supported | diff) != supported); +} + static int bnxt_update_link(struct bnxt *bp, bool chng_link_state) { int rc = 0; @@ -8842,7 +8849,6 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state) struct hwrm_port_phy_qcfg_input req = {0}; struct hwrm_port_phy_qcfg_output *resp = bp->hwrm_cmd_resp_addr; u8 link_up = link_info->link_up; - u16 diff; bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_PORT_PHY_QCFG, -1, -1); @@ -8941,13 +8947,11 @@ static int bnxt_update_link(struct bnxt *bp, bool chng_link_state) if (!BNXT_PHY_CFG_ABLE(bp)) return 0; - diff = link_info->support_auto_speeds ^ link_info->advertising; - if ((link_info->support_auto_speeds | diff) != - link_info->support_auto_speeds) { - /* An advertised speed is no longer supported, so we need to - * update the advertisement settings. Caller holds RTNL - * so we can modify link settings. - */ + /* Check if any advertised speeds are no longer supported. The caller + * holds the link_lock mutex, so we can modify link_info settings. + */ + if (bnxt_support_dropped(link_info->advertising, + link_info->support_auto_speeds)) { link_info->advertising = link_info->support_auto_speeds; if (link_info->autoneg & BNXT_AUTONEG_SPEED) bnxt_hwrm_set_link_setting(bp, true, false);