From patchwork Sat Apr 24 20:14:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 12222773 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=-18.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_HEADER_CTYPE_ONLY, 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 86774C433ED for ; Sat, 24 Apr 2021 20:14:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F53061463 for ; Sat, 24 Apr 2021 20:14:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237393AbhDXUPd (ORCPT ); Sat, 24 Apr 2021 16:15:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236954AbhDXUP1 (ORCPT ); Sat, 24 Apr 2021 16:15:27 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89E97C061756 for ; Sat, 24 Apr 2021 13:14:48 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id m11so36359131pfc.11 for ; Sat, 24 Apr 2021 13:14:48 -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=fmHMzftTFEsjNC9Oc3kwKDlrGFyBYxa5VB0miELt/sE=; b=RfNumrxjLD+Fz2UL4fgdQdpyaRMXnben+2jiUS4Hrj/FGEs2Kzgj/WhPW6B5x35Xc+ dIVxklRQzUHNwX+PAaXHkWJwdlsUml/D8pA1z8EIgIDrM3jseli5t33nwdajgr+S2Bsv 7Oi4VmP1FjjESmUN4i9JTciwghE+EEkZVTJaY= 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=fmHMzftTFEsjNC9Oc3kwKDlrGFyBYxa5VB0miELt/sE=; b=j69HCOkfANBVTPsrEg2XIuvNBGXM273uAeIDhCaUugeKX/NqX1m2vEgLnmci4IJCAK rqdy5muWTUwF3PQQpP7Ri5DzIs6J+8PmRxcWF/l+pxROy87axaI+aoahvuO3tY7xJJ7/ 0VbDxBvRBhqOzpuPr+GGSA01nIf/CsplO0yQEsaxBAf/Wb3i60/nxxFe+ha6M99QLENH HRYbBNFS/bdpAM2mG4lwaXqnRGpp3lkI0M4LOWLInTQSMzoSd6Nfqm+DMcB7GmBwoAP8 CbFKWCaRtmLh8aECmOtr9PhYKZSewlkkfe0xp91q7SOFAt0OuTxUKX3SkUazisn9We3Q sGgA== X-Gm-Message-State: AOAM530ikFwRhyuHkfNBROKWYfFoI9P7qtudwxhIgi1kujeHnwdc1j4P jvZMk1CDg3WpLD/dU4rznjNVAQ== X-Google-Smtp-Source: ABdhPJy9Q6HleClR1bcaIJlhsqE3xMGw/bgL+DrXq6SanvsB+B++Scxh6r8TiikpGsCrEBkweiQaZQ== X-Received: by 2002:a62:ce4a:0:b029:261:aa4e:a03c with SMTP id y71-20020a62ce4a0000b0290261aa4ea03cmr10217639pfg.19.1619295287774; Sat, 24 Apr 2021 13:14:47 -0700 (PDT) Received: from localhost.swdvt.lab.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id z29sm7914070pga.52.2021.04.24.13.14.46 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Apr 2021 13:14:47 -0700 (PDT) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, kuba@kernel.org, gospo@broadcom.com Subject: [PATCH net-next 06/10] bnxt_en: Move bnxt_approve_mac(). Date: Sat, 24 Apr 2021 16:14:27 -0400 Message-Id: <1619295271-30853-7-git-send-email-michael.chan@broadcom.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1619295271-30853-1-git-send-email-michael.chan@broadcom.com> References: <1619295271-30853-1-git-send-email-michael.chan@broadcom.com> Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Move it before bnxt_update_vf_mac(). In the next patch, we need to call bnxt_approve_mac() from bnxt_update_mac() under some conditions. This will avoid forward declaration. Reviewed-by: Edwin Peer Signed-off-by: Michael Chan --- .../net/ethernet/broadcom/bnxt/bnxt_sriov.c | 53 ++++++++++--------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c index 67856dbf9ce9..e65093f4aa7a 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c @@ -1116,6 +1116,33 @@ void bnxt_hwrm_exec_fwd_req(struct bnxt *bp) } } +int bnxt_approve_mac(struct bnxt *bp, u8 *mac, bool strict) +{ + struct hwrm_func_vf_cfg_input req = {0}; + int rc = 0; + + if (!BNXT_VF(bp)) + return 0; + + if (bp->hwrm_spec_code < 0x10202) { + if (is_valid_ether_addr(bp->vf.mac_addr)) + rc = -EADDRNOTAVAIL; + goto mac_done; + } + bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_CFG, -1, -1); + req.enables = cpu_to_le32(FUNC_VF_CFG_REQ_ENABLES_DFLT_MAC_ADDR); + memcpy(req.dflt_mac_addr, mac, ETH_ALEN); + rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); +mac_done: + if (rc && strict) { + rc = -EADDRNOTAVAIL; + netdev_warn(bp->dev, "VF MAC address %pM not approved by the PF\n", + mac); + return rc; + } + return 0; +} + void bnxt_update_vf_mac(struct bnxt *bp) { struct hwrm_func_qcaps_input req = {0}; @@ -1145,32 +1172,6 @@ void bnxt_update_vf_mac(struct bnxt *bp) mutex_unlock(&bp->hwrm_cmd_lock); } -int bnxt_approve_mac(struct bnxt *bp, u8 *mac, bool strict) -{ - struct hwrm_func_vf_cfg_input req = {0}; - int rc = 0; - - if (!BNXT_VF(bp)) - return 0; - - if (bp->hwrm_spec_code < 0x10202) { - if (is_valid_ether_addr(bp->vf.mac_addr)) - rc = -EADDRNOTAVAIL; - goto mac_done; - } - bnxt_hwrm_cmd_hdr_init(bp, &req, HWRM_FUNC_VF_CFG, -1, -1); - req.enables = cpu_to_le32(FUNC_VF_CFG_REQ_ENABLES_DFLT_MAC_ADDR); - memcpy(req.dflt_mac_addr, mac, ETH_ALEN); - rc = hwrm_send_message(bp, &req, sizeof(req), HWRM_CMD_TIMEOUT); -mac_done: - if (rc && strict) { - rc = -EADDRNOTAVAIL; - netdev_warn(bp->dev, "VF MAC address %pM not approved by the PF\n", - mac); - return rc; - } - return 0; -} #else int bnxt_cfg_hw_sriov(struct bnxt *bp, int *num_vfs, bool reset)