From patchwork Wed Mar 10 12:03:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127929 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=-15.8 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_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 7D1BFC433E6 for ; Wed, 10 Mar 2021 12:05:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E04064FF3 for ; Wed, 10 Mar 2021 12:05:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232438AbhCJMEv (ORCPT ); Wed, 10 Mar 2021 07:04:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232929AbhCJMEo (ORCPT ); Wed, 10 Mar 2021 07:04:44 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B3BBC061761 for ; Wed, 10 Mar 2021 04:04:44 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id c10so38117501ejx.9 for ; Wed, 10 Mar 2021 04:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OJnVq8r2fzUNQAWLMQfE4OMc3vq4nuKCHOZGEnNktZ4=; b=CZeIHB+3kLnaiIA7T8Nb4iAWICAL1HEogtz7STJBIv2nIyNLkRQCATDXLyKlb0c6N2 mi5xlsIQ6X6zDb8BAME7zneL7Sgc1+YrNHssP8MJ/4/GzscfbRom7LI9UVxr9m3zuSrl 9kO12xXGJRlmyLkoFW46YwAyz4wHyZ02IuE9C2S3FvpG1gx0Ss1dgW8u7IbeiWUHQMoF BDOjn7XWdnaxYEjUnV37X30gR4Mf4gwGDWPUbq7rus9odIS+CKN/iPEVCSCfW41M1ag4 KzeIN/L09Y0SambdEC9qXvQT3Y5VBnAwxnDMwDhO/8zvlgNiEHP+5yhtA3uP5NGzLCe9 SOhQ== 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:mime-version:content-transfer-encoding; bh=OJnVq8r2fzUNQAWLMQfE4OMc3vq4nuKCHOZGEnNktZ4=; b=Neoy8RzS2sLa3FjWr4/G2Y7Uk3lFNgntbBnEJmYi5lASiVBMWWOVPrlIzDy/z5Tmkn oDLe8FXvSXOHYtTgD2fZIz41RRzdz4tsSFlgNAM4/+krOCYchgmRYAPSC1EEi/NVvXoD xHRIAhYWYJU3OFr5W9AUY7x49+3OuTS8Wwx3aJgrjJw7jsHGIim+6/63MXCX3d+N3m9m HKQLoijExRw4/zOL9KtjqytfrKkW81QrwkPOf8UunqmPUpyUImffucuD+zz+s/NBAt8j QcEySlDFlG3YzYV/wQFO6ITbBcA3m2Sm27sSKdsUs6Do4g2qGqsdfxGSdkN9Y2EMx765 YApw== X-Gm-Message-State: AOAM530iW8CU5zsCLyYOtytnzFClOowsPfocKnCy4Nar870NvgszR2m2 NwMf8eBBT9c8OrTSxJB9w4I= X-Google-Smtp-Source: ABdhPJysXzemETsEpZxT3u/D0SiEr0FkTXiYsQwE+x/p82t0xqs6z8bBfSiFX7f1MbwfOh8bT1G4Ag== X-Received: by 2002:a17:906:688:: with SMTP id u8mr3221619ejb.38.1615377882675; Wed, 10 Mar 2021 04:04:42 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:42 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 01/12] net: enetc: move the CBDR API to enetc_cbdr.c Date: Wed, 10 Mar 2021 14:03:40 +0200 Message-Id: <20210310120351.542292-2-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since there is a dedicated file in this driver for interacting with control BD rings, it makes sense to move these functions there. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 54 ------------------- .../net/ethernet/freescale/enetc/enetc_cbdr.c | 54 +++++++++++++++++++ 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 09471329f3a3..a6ae4ebaee7d 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -995,60 +995,6 @@ static void enetc_free_rxtx_rings(struct enetc_ndev_priv *priv) enetc_free_tx_ring(priv->tx_ring[i]); } -int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) -{ - int size = cbdr->bd_count * sizeof(struct enetc_cbd); - - cbdr->bd_base = dma_alloc_coherent(dev, size, &cbdr->bd_dma_base, - GFP_KERNEL); - if (!cbdr->bd_base) - return -ENOMEM; - - /* h/w requires 128B alignment */ - if (!IS_ALIGNED(cbdr->bd_dma_base, 128)) { - dma_free_coherent(dev, size, cbdr->bd_base, cbdr->bd_dma_base); - return -EINVAL; - } - - cbdr->next_to_clean = 0; - cbdr->next_to_use = 0; - - return 0; -} - -void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr) -{ - int size = cbdr->bd_count * sizeof(struct enetc_cbd); - - dma_free_coherent(dev, size, cbdr->bd_base, cbdr->bd_dma_base); - cbdr->bd_base = NULL; -} - -void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) -{ - /* set CBDR cache attributes */ - enetc_wr(hw, ENETC_SICAR2, - ENETC_SICAR_RD_COHERENT | ENETC_SICAR_WR_COHERENT); - - enetc_wr(hw, ENETC_SICBDRBAR0, lower_32_bits(cbdr->bd_dma_base)); - enetc_wr(hw, ENETC_SICBDRBAR1, upper_32_bits(cbdr->bd_dma_base)); - enetc_wr(hw, ENETC_SICBDRLENR, ENETC_RTBLENR_LEN(cbdr->bd_count)); - - enetc_wr(hw, ENETC_SICBDRPIR, 0); - enetc_wr(hw, ENETC_SICBDRCIR, 0); - - /* enable ring */ - enetc_wr(hw, ENETC_SICBDRMR, BIT(31)); - - cbdr->pir = hw->reg + ENETC_SICBDRPIR; - cbdr->cir = hw->reg + ENETC_SICBDRCIR; -} - -void enetc_clear_cbdr(struct enetc_hw *hw) -{ - enetc_wr(hw, ENETC_SICBDRMR, 0); -} - static int enetc_setup_default_rss_table(struct enetc_si *si, int num_groups) { int *rss_table; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index 201cbc362e33..ad6aecda6b47 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -3,6 +3,60 @@ #include "enetc.h" +int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) +{ + int size = cbdr->bd_count * sizeof(struct enetc_cbd); + + cbdr->bd_base = dma_alloc_coherent(dev, size, &cbdr->bd_dma_base, + GFP_KERNEL); + if (!cbdr->bd_base) + return -ENOMEM; + + /* h/w requires 128B alignment */ + if (!IS_ALIGNED(cbdr->bd_dma_base, 128)) { + dma_free_coherent(dev, size, cbdr->bd_base, cbdr->bd_dma_base); + return -EINVAL; + } + + cbdr->next_to_clean = 0; + cbdr->next_to_use = 0; + + return 0; +} + +void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr) +{ + int size = cbdr->bd_count * sizeof(struct enetc_cbd); + + dma_free_coherent(dev, size, cbdr->bd_base, cbdr->bd_dma_base); + cbdr->bd_base = NULL; +} + +void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) +{ + /* set CBDR cache attributes */ + enetc_wr(hw, ENETC_SICAR2, + ENETC_SICAR_RD_COHERENT | ENETC_SICAR_WR_COHERENT); + + enetc_wr(hw, ENETC_SICBDRBAR0, lower_32_bits(cbdr->bd_dma_base)); + enetc_wr(hw, ENETC_SICBDRBAR1, upper_32_bits(cbdr->bd_dma_base)); + enetc_wr(hw, ENETC_SICBDRLENR, ENETC_RTBLENR_LEN(cbdr->bd_count)); + + enetc_wr(hw, ENETC_SICBDRPIR, 0); + enetc_wr(hw, ENETC_SICBDRCIR, 0); + + /* enable ring */ + enetc_wr(hw, ENETC_SICBDRMR, BIT(31)); + + cbdr->pir = hw->reg + ENETC_SICBDRPIR; + cbdr->cir = hw->reg + ENETC_SICBDRCIR; +} + +void enetc_clear_cbdr(struct enetc_hw *hw) +{ + enetc_wr(hw, ENETC_SICBDRMR, 0); +} + static void enetc_clean_cbdr(struct enetc_si *si) { struct enetc_cbdr *ring = &si->cbd_ring; From patchwork Wed Mar 10 12:03:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127933 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=-15.7 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,URIBL_BLOCKED,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 CAA02C43381 for ; Wed, 10 Mar 2021 12:05:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 89CFD64FF6 for ; Wed, 10 Mar 2021 12:05:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232901AbhCJMEw (ORCPT ); Wed, 10 Mar 2021 07:04:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232930AbhCJMEp (ORCPT ); Wed, 10 Mar 2021 07:04:45 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A6A2EC061762 for ; Wed, 10 Mar 2021 04:04:44 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id x9so27607560edd.0 for ; Wed, 10 Mar 2021 04:04:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=FT1x6x9ugdWaFZzEHSyMIq0oqTnCwmalm2czRraEjvg=; b=j5wi7JXT9jCdrYhhyMIQ0a7h5rhV2PV2w++mtOECUS2jc8Nscx1XOf0yaw3F1V4APn 6/LFc2rEVRDV7PMhblCoh7iic/DEY68HEU1xK2cxFbIpS7Bf9BDJ/+ZNHBPye2UAuH3Z TYHtGW9gAvvZ6buJ+2NjqXMpWE5PBCkUdwKlUK5Z7pR2VX69c8MYMGFzrn+5kvUutjCa K5DzJ1+Cj7qTD6zVLUiynpLFtYr9K9IE8oFGw7qN2aB2mzqGoSxL5gNtz2uo4MJF4tCb 1/7aRzPStnHe0E0dbmv5vfvPBY8OrksD0QERnrovfXA+f8XToOmp7JnKiRqtGARMD2HQ Kl3g== 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:mime-version:content-transfer-encoding; bh=FT1x6x9ugdWaFZzEHSyMIq0oqTnCwmalm2czRraEjvg=; b=f/rN9EbEYiAzVxqyquQPpt84tjCQwSCpPDnidd2ov7/qh2wMQ7v5pqqW5SdF8aoZs5 eFNjr04jovuax3QhlvpDJcBKUtob73kErZSRRwHp0z7Suy0eoFq/dWyDlaKKLvxhxhyS rjbwxzUnWlGznhpZB8qccWhBTU+cw81v4LebVfUEyDtL157bAqvmzhoFYepZI0PrfGba l8HUeGqi0snWM8gO+ddM62mjIVnvPGN3h5iDdT07TRgrLF8kE2rAYx2UB0lY4V234p5O 9r3Wu3UpEbHd8Sfd8cUv4zHfXIrS7fJf99kS5e2ayq9oTQ88RnHEoBVxm56udFykOB/N wLrQ== X-Gm-Message-State: AOAM5304x5eACQA2FuOTG6SItxOcj2K+FbNoeLKULWPuJJhV8K26PZuU ZKy9bIGMo2X9jaGo+Lda2ns= X-Google-Smtp-Source: ABdhPJy2dIUjTwde4JTPmpPpjFUKzg5l3YA1rBaHE3gAKYWy7l7kWcVSstBpO+IUOpqW1sGEFC44Bg== X-Received: by 2002:aa7:c386:: with SMTP id k6mr2782634edq.224.1615377883462; Wed, 10 Mar 2021 04:04:43 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:43 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 02/12] net: enetc: save the DMA device for enetc_free_cbdr Date: Wed, 10 Mar 2021 14:03:41 +0200 Message-Id: <20210310120351.542292-3-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org We shouldn't need to pass the struct device *dev to enetc CBDR APIs over and over again, so save this inside struct enetc_cbdr::dma_dev and avoid calling it from the enetc_free_cbdr functions. This breaks the dependency of the cbdr API from struct enetc_si (the station interface). Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 4 +- drivers/net/ethernet/freescale/enetc/enetc.h | 3 +- .../net/ethernet/freescale/enetc/enetc_cbdr.c | 37 +++++++++++-------- .../net/ethernet/freescale/enetc/enetc_pf.c | 2 +- 4 files changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index a6ae4ebaee7d..ceecee42f0f1 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1081,7 +1081,7 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) err_alloc_cls: enetc_clear_cbdr(&si->hw); - enetc_free_cbdr(priv->dev, &si->cbd_ring); + enetc_free_cbdr(&si->cbd_ring); return err; } @@ -1091,7 +1091,7 @@ void enetc_free_si_resources(struct enetc_ndev_priv *priv) struct enetc_si *si = priv->si; enetc_clear_cbdr(&si->hw); - enetc_free_cbdr(priv->dev, &si->cbd_ring); + enetc_free_cbdr(&si->cbd_ring); kfree(priv->cls_rules); } diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 8b380fc13314..b343d1002bb7 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -104,6 +104,7 @@ struct enetc_cbdr { int next_to_clean; dma_addr_t bd_dma_base; + struct device *dma_dev; }; #define ENETC_TXBD(BDR, i) (&(((union enetc_tx_bd *)((BDR).bd_base))[i])) @@ -311,7 +312,7 @@ void enetc_set_ethtool_ops(struct net_device *ndev); /* control buffer descriptor ring (CBDR) */ int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr); -void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr); +void enetc_free_cbdr(struct enetc_cbdr *cbdr); void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr); void enetc_clear_cbdr(struct enetc_hw *hw); int enetc_set_mac_flt_entry(struct enetc_si *si, int index, diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index ad6aecda6b47..7e84eb665ecd 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -14,22 +14,26 @@ int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) /* h/w requires 128B alignment */ if (!IS_ALIGNED(cbdr->bd_dma_base, 128)) { - dma_free_coherent(dev, size, cbdr->bd_base, cbdr->bd_dma_base); + dma_free_coherent(dev, size, cbdr->bd_base, + cbdr->bd_dma_base); return -EINVAL; } cbdr->next_to_clean = 0; cbdr->next_to_use = 0; + cbdr->dma_dev = dev; return 0; } -void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr) +void enetc_free_cbdr(struct enetc_cbdr *cbdr) { int size = cbdr->bd_count * sizeof(struct enetc_cbd); - dma_free_coherent(dev, size, cbdr->bd_base, cbdr->bd_dma_base); + dma_free_coherent(cbdr->dma_dev, size, cbdr->bd_base, + cbdr->bd_dma_base); cbdr->bd_base = NULL; + cbdr->dma_dev = NULL; } void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) @@ -57,9 +61,8 @@ void enetc_clear_cbdr(struct enetc_hw *hw) enetc_wr(hw, ENETC_SICBDRMR, 0); } -static void enetc_clean_cbdr(struct enetc_si *si) +static void enetc_clean_cbdr(struct enetc_cbdr *ring) { - struct enetc_cbdr *ring = &si->cbd_ring; struct enetc_cbd *dest_cbd; int i, status; @@ -69,7 +72,7 @@ static void enetc_clean_cbdr(struct enetc_si *si) dest_cbd = ENETC_CBD(*ring, i); status = dest_cbd->status_flags & ENETC_CBD_STATUS_MASK; if (status) - dev_warn(&si->pdev->dev, "CMD err %04x for cmd %04x\n", + dev_warn(ring->dma_dev, "CMD err %04x for cmd %04x\n", status, dest_cbd->cmd); memset(dest_cbd, 0, sizeof(*dest_cbd)); @@ -97,7 +100,7 @@ int enetc_send_cmd(struct enetc_si *si, struct enetc_cbd *cbd) return -EIO; if (unlikely(!enetc_cbd_unused(ring))) - enetc_clean_cbdr(si); + enetc_clean_cbdr(ring); i = ring->next_to_use; dest_cbd = ENETC_CBD(*ring, i); @@ -123,7 +126,7 @@ int enetc_send_cmd(struct enetc_si *si, struct enetc_cbd *cbd) /* CBD may writeback data, feedback up level */ *cbd = *dest_cbd; - enetc_clean_cbdr(si); + enetc_clean_cbdr(ring); return 0; } @@ -171,6 +174,7 @@ int enetc_set_mac_flt_entry(struct enetc_si *si, int index, int enetc_set_fs_entry(struct enetc_si *si, struct enetc_cmd_rfse *rfse, int index) { + struct enetc_cbdr *ring = &si->cbd_ring; struct enetc_cbd cbd = {.cmd = 0}; dma_addr_t dma, dma_align; void *tmp, *tmp_align; @@ -183,10 +187,10 @@ int enetc_set_fs_entry(struct enetc_si *si, struct enetc_cmd_rfse *rfse, cbd.length = cpu_to_le16(sizeof(*rfse)); cbd.opt[3] = cpu_to_le32(0); /* SI */ - tmp = dma_alloc_coherent(&si->pdev->dev, sizeof(*rfse) + RFSE_ALIGN, + tmp = dma_alloc_coherent(ring->dma_dev, sizeof(*rfse) + RFSE_ALIGN, &dma, GFP_KERNEL); if (!tmp) { - dev_err(&si->pdev->dev, "DMA mapping of RFS entry failed!\n"); + dev_err(ring->dma_dev, "DMA mapping of RFS entry failed!\n"); return -ENOMEM; } @@ -199,9 +203,9 @@ int enetc_set_fs_entry(struct enetc_si *si, struct enetc_cmd_rfse *rfse, err = enetc_send_cmd(si, &cbd); if (err) - dev_err(&si->pdev->dev, "FS entry add failed (%d)!", err); + dev_err(ring->dma_dev, "FS entry add failed (%d)!", err); - dma_free_coherent(&si->pdev->dev, sizeof(*rfse) + RFSE_ALIGN, + dma_free_coherent(ring->dma_dev, sizeof(*rfse) + RFSE_ALIGN, tmp, dma); return err; @@ -211,6 +215,7 @@ int enetc_set_fs_entry(struct enetc_si *si, struct enetc_cmd_rfse *rfse, static int enetc_cmd_rss_table(struct enetc_si *si, u32 *table, int count, bool read) { + struct enetc_cbdr *ring = &si->cbd_ring; struct enetc_cbd cbd = {.cmd = 0}; dma_addr_t dma, dma_align; u8 *tmp, *tmp_align; @@ -220,10 +225,10 @@ static int enetc_cmd_rss_table(struct enetc_si *si, u32 *table, int count, /* HW only takes in a full 64 entry table */ return -EINVAL; - tmp = dma_alloc_coherent(&si->pdev->dev, count + RSSE_ALIGN, + tmp = dma_alloc_coherent(ring->dma_dev, count + RSSE_ALIGN, &dma, GFP_KERNEL); if (!tmp) { - dev_err(&si->pdev->dev, "DMA mapping of RSS table failed!\n"); + dev_err(ring->dma_dev, "DMA mapping of RSS table failed!\n"); return -ENOMEM; } dma_align = ALIGN(dma, RSSE_ALIGN); @@ -243,13 +248,13 @@ static int enetc_cmd_rss_table(struct enetc_si *si, u32 *table, int count, err = enetc_send_cmd(si, &cbd); if (err) - dev_err(&si->pdev->dev, "RSS cmd failed (%d)!", err); + dev_err(ring->dma_dev, "RSS cmd failed (%d)!", err); if (read) for (i = 0; i < count; i++) table[i] = tmp_align[i]; - dma_free_coherent(&si->pdev->dev, count + RSSE_ALIGN, tmp, dma); + dma_free_coherent(ring->dma_dev, count + RSSE_ALIGN, tmp, dma); return err; } diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 224fc37a6757..a7195ec736f3 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1098,7 +1098,7 @@ static void enetc_init_unused_port(struct enetc_si *si) enetc_init_port_rss_memory(si); enetc_clear_cbdr(hw); - enetc_free_cbdr(dev, &si->cbd_ring); + enetc_free_cbdr(&si->cbd_ring); } static int enetc_pf_probe(struct pci_dev *pdev, From patchwork Wed Mar 10 12:03:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127935 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=-15.7 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,URIBL_BLOCKED,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 48370C4332D for ; Wed, 10 Mar 2021 12:05:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED3A264FEF for ; Wed, 10 Mar 2021 12:05:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232915AbhCJMEy (ORCPT ); Wed, 10 Mar 2021 07:04:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231691AbhCJMEp (ORCPT ); Wed, 10 Mar 2021 07:04:45 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94716C061760 for ; Wed, 10 Mar 2021 04:04:45 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id w9so27617402edc.11 for ; Wed, 10 Mar 2021 04:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rYYV0DV/HZe1x6KQOm6y5XhVWh1furGAHhlPiSskupM=; b=RsbLgvoMtw6kJA/ChEvHucRK770EJIVxjLgWLIoPjwd4JTFPU0uaopyARGvx/MRswC nUv+oNn6rwD+sanEsmgjHbf1kJadCRDjDZz3yA2A6Ar5NSSrfmRUsuTa8fVo+mtthB/3 c47OgLyo5edk0/suSm4ubTtLVSsCT3Rj+349GitclmlVw3NfVu46sY6wU5CSdr0m0zOc fqf0NqWENMnEwksUr26exNcEwECL1Bv3UVpRgUzsPmnVBluU8FA1ercL5l597VPt/Y+l WwbQEBkfU+7MGTdfPe7rm22iH5La0NmLGgI7eL6CWmnDajEmksup/1O4WPsa+ZRKGPL6 F0tA== 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:mime-version:content-transfer-encoding; bh=rYYV0DV/HZe1x6KQOm6y5XhVWh1furGAHhlPiSskupM=; b=oMcUMyTFsI4k8TtwxhQ5sDW0b7jA2T5fiW5IeRzzU7Jp4wEGXUdhiNg8B2nh+xDVFQ IEOy8qq7WotiVNqtGSaElP5P6t4/WR10ctG2ypv4+jsAHPAgpV25PlNsUlc/4aygXeB7 RnM6Tf8sX5nUhmX5aCropgxTRl+AbmcB3jv8jxRsVQ5w0ozAhngpehEoiFcXulgkjH18 FvLbTq703qYUQfe8xfJPNz76uLOtUdJc9yRufDvpbvw3GwpG1y5MGapIZagxm7fr/m2+ lB6r+YS/WJSZqPNRG4UrW8gaTREBo7aXNNuS7+CqSwF+cuHbUdEJcLh8UqiJfKW11CYP J1HA== X-Gm-Message-State: AOAM532s/T/t+5qEd8BAG8TYbvnhcSuLajnzDWl+f9GM+the6pQECHUY pWp00sO/z4wKdL+4CK1h/oc= X-Google-Smtp-Source: ABdhPJzwrXdg3iMi5wUTrqdxgUkB66pwzmvNHD9cO13CVSLNoWm/aI10SN87CHE3is9TQ55U1LWKCg== X-Received: by 2002:a05:6402:b41:: with SMTP id bx1mr2895460edb.69.1615377884292; Wed, 10 Mar 2021 04:04:44 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:44 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 03/12] net: enetc: squash enetc_alloc_cbdr and enetc_setup_cbdr Date: Wed, 10 Mar 2021 14:03:42 +0200 Message-Id: <20210310120351.542292-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org enetc_alloc_cbdr and enetc_setup_cbdr are always called one after another, so we can simplify the callers and make enetc_setup_cbdr do everything that's needed. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 4 +-- drivers/net/ethernet/freescale/enetc/enetc.h | 4 +-- .../net/ethernet/freescale/enetc/enetc_cbdr.c | 30 +++++++++---------- .../net/ethernet/freescale/enetc/enetc_pf.c | 4 +-- 4 files changed, 18 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index ceecee42f0f1..57073c3c679e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1064,12 +1064,10 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) struct enetc_si *si = priv->si; int err; - err = enetc_alloc_cbdr(priv->dev, &si->cbd_ring); + err = enetc_setup_cbdr(priv->dev, &si->hw, &si->cbd_ring); if (err) return err; - enetc_setup_cbdr(&si->hw, &si->cbd_ring); - priv->cls_rules = kcalloc(si->num_fs_entries, sizeof(*priv->cls_rules), GFP_KERNEL); if (!priv->cls_rules) { diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index b343d1002bb7..1f2e9bec1b30 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -311,9 +311,9 @@ int enetc_setup_tc(struct net_device *ndev, enum tc_setup_type type, void enetc_set_ethtool_ops(struct net_device *ndev); /* control buffer descriptor ring (CBDR) */ -int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr); +int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, + struct enetc_cbdr *cbdr); void enetc_free_cbdr(struct enetc_cbdr *cbdr); -void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr); void enetc_clear_cbdr(struct enetc_hw *hw); int enetc_set_mac_flt_entry(struct enetc_si *si, int index, char *mac_addr, int si_map); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index 7e84eb665ecd..4de31b283319 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -3,7 +3,8 @@ #include "enetc.h" -int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) +int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, + struct enetc_cbdr *cbdr) { int size = cbdr->bd_count * sizeof(struct enetc_cbd); @@ -23,21 +24,6 @@ int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) cbdr->next_to_use = 0; cbdr->dma_dev = dev; - return 0; -} - -void enetc_free_cbdr(struct enetc_cbdr *cbdr) -{ - int size = cbdr->bd_count * sizeof(struct enetc_cbd); - - dma_free_coherent(cbdr->dma_dev, size, cbdr->bd_base, - cbdr->bd_dma_base); - cbdr->bd_base = NULL; - cbdr->dma_dev = NULL; -} - -void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) -{ /* set CBDR cache attributes */ enetc_wr(hw, ENETC_SICAR2, ENETC_SICAR_RD_COHERENT | ENETC_SICAR_WR_COHERENT); @@ -54,6 +40,18 @@ void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) cbdr->pir = hw->reg + ENETC_SICBDRPIR; cbdr->cir = hw->reg + ENETC_SICBDRCIR; + + return 0; +} + +void enetc_free_cbdr(struct enetc_cbdr *cbdr) +{ + int size = cbdr->bd_count * sizeof(struct enetc_cbd); + + dma_free_coherent(cbdr->dma_dev, size, cbdr->bd_base, + cbdr->bd_dma_base); + cbdr->bd_base = NULL; + cbdr->dma_dev = NULL; } void enetc_clear_cbdr(struct enetc_hw *hw) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index a7195ec736f3..31d229e0912a 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1088,12 +1088,10 @@ static void enetc_init_unused_port(struct enetc_si *si) int err; si->cbd_ring.bd_count = ENETC_CBDR_DEFAULT_SIZE; - err = enetc_alloc_cbdr(dev, &si->cbd_ring); + err = enetc_setup_cbdr(dev, hw, &si->cbd_ring); if (err) return; - enetc_setup_cbdr(hw, &si->cbd_ring); - enetc_init_port_rfs_memory(si); enetc_init_port_rss_memory(si); From patchwork Wed Mar 10 12:03:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127939 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=-15.7 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,URIBL_BLOCKED,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 9D87DC4332B for ; Wed, 10 Mar 2021 12:05:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B1AA64FF2 for ; Wed, 10 Mar 2021 12:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232918AbhCJMEz (ORCPT ); Wed, 10 Mar 2021 07:04:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232428AbhCJMEr (ORCPT ); Wed, 10 Mar 2021 07:04:47 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AD98C061760 for ; Wed, 10 Mar 2021 04:04:46 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id w9so27617503edc.11 for ; Wed, 10 Mar 2021 04:04:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XUi8gowQSgFvmLf+t1J83hXEcoJ+WnDjt01OgciC29U=; b=gI5Q8Pl7X0lXfDwjTy5CVLjOWopeB+wwIn2H/u5uAWutL5ZQGNErSOotuS+3/KJxm2 HEq7VUq+xn+v3TMwS2Ia1R9c82BMdnuDrOEVyob+TxmbLTCiGxD+nu+22w1+uuKkKdaM WvlK4QGmmVTPuKnga5ozRbaU9io6nTgTpCN0huDqFzuq7zs+JSx5P3VhoQn9yCwGk6Il aPDQ5J4XnoX4//2VpwsftrkWa3QEVflxofnOUfm/seJu95t045zU3BAgvEZgyNaaDhVS ENSmmv80jfXr5umA+btihQ/3r9YnNpfT5hjBI+fFkbAmAU4ZGyD7LGLpF4tWZqc2njSd qTMA== 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:mime-version:content-transfer-encoding; bh=XUi8gowQSgFvmLf+t1J83hXEcoJ+WnDjt01OgciC29U=; b=INYdCYKo8T1F+Q38VEhgBLDQ60rv9DOeMJNSbwoyAEoZhOfpo2FrJw/dBqXFDTQ3q2 MF4lYgzr8+U0VO/t7woK7DNVKqiACLO5eO8Bgh2HFLZKBJZnVKGMZI1oyzNN5K4bEYxQ F4HVod7zISXh+pY1I28qu4LSR5akJCfxOjgICGwOv83Y1RlpfWkoi8nXXsDHBXwc4JOo UitjEv2K27JGoqZU5pT5ZNuKPQGeFl2/CdM1uTCl9umgaS7PxHDaISMvevsJIjMcylwB vTxRx4yOrXjXA8sgPDeXzq29JvzsQAalJO8fixmhpoQ7GAyZ1OolbL9btyslsSQALR3G dYMw== X-Gm-Message-State: AOAM531LJYAml4WV1lFj9zCedvxYy0gjk/ubKQCkhqdV28VHSP8ZIZRm 7JT6SZ+GcBIRRYQ+P34IaX/IsevYClc= X-Google-Smtp-Source: ABdhPJzCjQyx1kyRcIfVtb8jBcd3CO9mEL21KOE7dJEIl/Q9nLaMeQGH/ni5iI2JC2COwMZ+mtqgWw== X-Received: by 2002:aa7:c044:: with SMTP id k4mr2828210edo.47.1615377885116; Wed, 10 Mar 2021 04:04:45 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:44 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 04/12] net: enetc: save the mode register address inside struct enetc_cbdr Date: Wed, 10 Mar 2021 14:03:43 +0200 Message-Id: <20210310120351.542292-5-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org enetc_clear_cbdr depends on struct enetc_hw because it must disable the ring through a register write. We'd like to remove that dependency, so let's do what's already done with the producer and consumer indices, which is to save the iomem address in a variable kept in struct enetc_cbdr. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 4 ++-- drivers/net/ethernet/freescale/enetc/enetc.h | 3 ++- .../net/ethernet/freescale/enetc/enetc_cbdr.c | 19 ++++++++++--------- .../net/ethernet/freescale/enetc/enetc_pf.c | 2 +- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 57073c3c679e..b1077a6e2b2b 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1078,7 +1078,7 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) return 0; err_alloc_cls: - enetc_clear_cbdr(&si->hw); + enetc_clear_cbdr(&si->cbd_ring); enetc_free_cbdr(&si->cbd_ring); return err; @@ -1088,7 +1088,7 @@ void enetc_free_si_resources(struct enetc_ndev_priv *priv) { struct enetc_si *si = priv->si; - enetc_clear_cbdr(&si->hw); + enetc_clear_cbdr(&si->cbd_ring); enetc_free_cbdr(&si->cbd_ring); kfree(priv->cls_rules); diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 1f2e9bec1b30..9d4dbeef61ac 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -98,6 +98,7 @@ struct enetc_cbdr { void *bd_base; /* points to Rx or Tx BD ring */ void __iomem *pir; void __iomem *cir; + void __iomem *mr; /* mode register */ int bd_count; /* # of BDs */ int next_to_use; @@ -314,7 +315,7 @@ void enetc_set_ethtool_ops(struct net_device *ndev); int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, struct enetc_cbdr *cbdr); void enetc_free_cbdr(struct enetc_cbdr *cbdr); -void enetc_clear_cbdr(struct enetc_hw *hw); +void enetc_clear_cbdr(struct enetc_cbdr *cbdr); int enetc_set_mac_flt_entry(struct enetc_si *si, int index, char *mac_addr, int si_map); int enetc_clear_mac_flt_entry(struct enetc_si *si, int index); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index 4de31b283319..bb20a58e8830 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -24,6 +24,10 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, cbdr->next_to_use = 0; cbdr->dma_dev = dev; + cbdr->pir = hw->reg + ENETC_SICBDRPIR; + cbdr->cir = hw->reg + ENETC_SICBDRCIR; + cbdr->mr = hw->reg + ENETC_SICBDRMR; + /* set CBDR cache attributes */ enetc_wr(hw, ENETC_SICAR2, ENETC_SICAR_RD_COHERENT | ENETC_SICAR_WR_COHERENT); @@ -32,14 +36,10 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, enetc_wr(hw, ENETC_SICBDRBAR1, upper_32_bits(cbdr->bd_dma_base)); enetc_wr(hw, ENETC_SICBDRLENR, ENETC_RTBLENR_LEN(cbdr->bd_count)); - enetc_wr(hw, ENETC_SICBDRPIR, 0); - enetc_wr(hw, ENETC_SICBDRCIR, 0); - + enetc_wr_reg(cbdr->pir, cbdr->next_to_clean); + enetc_wr_reg(cbdr->cir, cbdr->next_to_use); /* enable ring */ - enetc_wr(hw, ENETC_SICBDRMR, BIT(31)); - - cbdr->pir = hw->reg + ENETC_SICBDRPIR; - cbdr->cir = hw->reg + ENETC_SICBDRCIR; + enetc_wr_reg(cbdr->mr, BIT(31)); return 0; } @@ -54,9 +54,10 @@ void enetc_free_cbdr(struct enetc_cbdr *cbdr) cbdr->dma_dev = NULL; } -void enetc_clear_cbdr(struct enetc_hw *hw) +void enetc_clear_cbdr(struct enetc_cbdr *cbdr) { - enetc_wr(hw, ENETC_SICBDRMR, 0); + /* disable ring */ + enetc_wr_reg(cbdr->mr, 0); } static void enetc_clean_cbdr(struct enetc_cbdr *ring) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 31d229e0912a..f083d49d7772 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1095,7 +1095,7 @@ static void enetc_init_unused_port(struct enetc_si *si) enetc_init_port_rfs_memory(si); enetc_init_port_rss_memory(si); - enetc_clear_cbdr(hw); + enetc_clear_cbdr(&si->cbd_ring); enetc_free_cbdr(&si->cbd_ring); } From patchwork Wed Mar 10 12:03:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127937 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=-15.8 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_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 6A30DC4332E for ; Wed, 10 Mar 2021 12:05:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1D01864FEE for ; Wed, 10 Mar 2021 12:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbhCJME4 (ORCPT ); Wed, 10 Mar 2021 07:04:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232932AbhCJMEr (ORCPT ); Wed, 10 Mar 2021 07:04:47 -0500 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 22894C061761 for ; Wed, 10 Mar 2021 04:04:47 -0800 (PST) Received: by mail-ej1-x635.google.com with SMTP id e19so38231348ejt.3 for ; Wed, 10 Mar 2021 04:04:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DEAVvFDcDkzIv8+6LoQc58Y1go1M6iSGO4707+Npq+4=; b=E3/ymp0GVxMBCEHI8N5AZmKyR+6qAukat8UZlcgkOCHuWXTcM9I0dzTGDGgGAcWjJv QKNtwuEJiMJ4falBOTGoc81rGdOUlsP0L2yiydPPh1InuHWhzb46PHZ3K6ooYN2GHSG4 8LkfJAEsV8QtAEdG28Bmj+StiYQmkzKWqJ02cgtx0b/o3HigUgCLBIwsBQUCKKEsmAJS oNKwpUNACcTpV9eFE3ez8ahBY25IkJibcGUKRpFfgAy7BaadkELue2bj9NsCH+g6NBTc qCOs0mLOzpCLTQMkco5bx210/RqPSGglUDRMhNazrdnGgx61gcLlBWc3XkRKyMwY+Swq Z8SA== 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:mime-version:content-transfer-encoding; bh=DEAVvFDcDkzIv8+6LoQc58Y1go1M6iSGO4707+Npq+4=; b=dRAEGzZT+15NzfYjnCN6E8DxW6uoVsnDdgRA+BZpeIlyEahc/shabOHqgXInnhaLGB w/u2xulP3MSVuCPlidRLgWrL17O0OR2NuGsXAqLNQFs8OWouc/vZsvuBS/AQdSYcnK6m eoGmbLfJD1oOyODwZVuApfBy94Bju76i8sNAl1ine1acLtQ+EPOYD9JVAJricQbUsCaX Bj5Jx2KVYMR9pQm6pLorJEGggr7lCzEZxEXHx5CLF7bQ1ORl50Yn8kKLJUpXh+guPRns V1z1guCkTZmeBXfR+BFyBA+jEZukvMyFt5I3Hd4jUveRh2VA7qRzpl/Baktq4mslem6F Peww== X-Gm-Message-State: AOAM5317jXYDJqJBDLyrzRQ4XLB5PoRK8iFVROaUwC4BCNIauuhbK8YV cCA8tv57NesHLP49F2LLyZAUG0uQoOA= X-Google-Smtp-Source: ABdhPJynt9QzUSj9vkFJj3pkT88W7owSe4iIAWvzVH1W2Ly0hi6wSMTUxNeMjwoL6tLZxJeEgGmW1A== X-Received: by 2002:a17:906:607:: with SMTP id s7mr3190600ejb.495.1615377885937; Wed, 10 Mar 2021 04:04:45 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:45 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 05/12] net: enetc: squash clear_cbdr and free_cbdr into teardown_cbdr Date: Wed, 10 Mar 2021 14:03:44 +0200 Message-Id: <20210310120351.542292-6-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org All call sites call enetc_clear_cbdr and enetc_free_cbdr one after another, so let's combine the two functions into a single method named enetc_teardown_cbdr which does both, and in the same order. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 6 ++---- drivers/net/ethernet/freescale/enetc/enetc.h | 3 +-- drivers/net/ethernet/freescale/enetc/enetc_cbdr.c | 11 ++++------- drivers/net/ethernet/freescale/enetc/enetc_pf.c | 3 +-- 4 files changed, 8 insertions(+), 15 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index b1077a6e2b2b..a32283533408 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1078,8 +1078,7 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) return 0; err_alloc_cls: - enetc_clear_cbdr(&si->cbd_ring); - enetc_free_cbdr(&si->cbd_ring); + enetc_teardown_cbdr(&si->cbd_ring); return err; } @@ -1088,8 +1087,7 @@ void enetc_free_si_resources(struct enetc_ndev_priv *priv) { struct enetc_si *si = priv->si; - enetc_clear_cbdr(&si->cbd_ring); - enetc_free_cbdr(&si->cbd_ring); + enetc_teardown_cbdr(&si->cbd_ring); kfree(priv->cls_rules); } diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 9d4dbeef61ac..19772be63a2c 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -314,8 +314,7 @@ void enetc_set_ethtool_ops(struct net_device *ndev); /* control buffer descriptor ring (CBDR) */ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, struct enetc_cbdr *cbdr); -void enetc_free_cbdr(struct enetc_cbdr *cbdr); -void enetc_clear_cbdr(struct enetc_cbdr *cbdr); +void enetc_teardown_cbdr(struct enetc_cbdr *cbdr); int enetc_set_mac_flt_entry(struct enetc_si *si, int index, char *mac_addr, int si_map); int enetc_clear_mac_flt_entry(struct enetc_si *si, int index); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index bb20a58e8830..bee453be2240 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -44,22 +44,19 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, return 0; } -void enetc_free_cbdr(struct enetc_cbdr *cbdr) +void enetc_teardown_cbdr(struct enetc_cbdr *cbdr) { int size = cbdr->bd_count * sizeof(struct enetc_cbd); + /* disable ring */ + enetc_wr_reg(cbdr->mr, 0); + dma_free_coherent(cbdr->dma_dev, size, cbdr->bd_base, cbdr->bd_dma_base); cbdr->bd_base = NULL; cbdr->dma_dev = NULL; } -void enetc_clear_cbdr(struct enetc_cbdr *cbdr) -{ - /* disable ring */ - enetc_wr_reg(cbdr->mr, 0); -} - static void enetc_clean_cbdr(struct enetc_cbdr *ring) { struct enetc_cbd *dest_cbd; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index f083d49d7772..4dd7199d5007 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1095,8 +1095,7 @@ static void enetc_init_unused_port(struct enetc_si *si) enetc_init_port_rfs_memory(si); enetc_init_port_rss_memory(si); - enetc_clear_cbdr(&si->cbd_ring); - enetc_free_cbdr(&si->cbd_ring); + enetc_teardown_cbdr(&si->cbd_ring); } static int enetc_pf_probe(struct pci_dev *pdev, From patchwork Wed Mar 10 12:03:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127941 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=-15.8 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_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 A0B27C43332 for ; Wed, 10 Mar 2021 12:05:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6947864FF3 for ; Wed, 10 Mar 2021 12:05:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232932AbhCJME5 (ORCPT ); Wed, 10 Mar 2021 07:04:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232934AbhCJMEs (ORCPT ); Wed, 10 Mar 2021 07:04:48 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0490CC061762 for ; Wed, 10 Mar 2021 04:04:48 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id x9so27607869edd.0 for ; Wed, 10 Mar 2021 04:04:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sox2Ii9W50FhUaR8bUHhhLyqmibUnWMc7Ry439DSURE=; b=SDC9p8JqmmfrDqbr+eGudgzwqTkCJMgdqNa4jzAdvp8MNScih2frdKBv8wyRE6CdS8 cT3NICesJLD6MALwqx/lpBYqxwAPYR0z0mAoxcRYMGN5kRLNFrIuIEUq5GOJe3y7teLG tvM+jwooa/ORN8Q2E9+zhjt/IOzEzwq+5JcnoO7S2AFLedYeHDV/yGiZeDAWOYrHF3tw m6gXpCEu1GAVbRAKPP9FscSxpn4wl5y9R6VXhIAqCOiu9BbgKyaeaiR0X+2IJj4L1C5R xsqyM7QaurIpE9Mee4e/rIE1yqSMktxwdUeqhlF4If4Ja+H9WWLMAmARBlCQS7GR5YaR PWWg== 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:mime-version:content-transfer-encoding; bh=sox2Ii9W50FhUaR8bUHhhLyqmibUnWMc7Ry439DSURE=; b=J39f8MI4Dag3oWLvRgPzG3fCwAeit6nryFYwI6rT+cM+ESgwTRkVDNnxIT7pRlTpYv NeoZAfBoHQOvtWPhEemjKv9+L+/M+/p4onc3TTh1iO1FZznk0ByzW4X3+OyxcrdwdRCv zIi+kfevI2Wp4NI6ObKV1WrgjBmZ2pGUFudoozQ/SgxNmb7EXF5ttRM4EDk9QtmGkGrA iLmmnUF6dFePPLNl3laGwMRXh+53uvyL3G0CS3F23b1FIQYxlMSAVZMZfKz+tGzqLqJ0 lLv0XwmXLk9AxawiSMsoGHY3VliXG1gxJ1Wcb2x1SFKR5eNeRDN5zUHwbr8KZ3mjZGBA vZ5Q== X-Gm-Message-State: AOAM533alfdpjWh3mitaD25tpYZMGFeol8D1sHPy+wdLiurXEMZY22Dl EGO0tTWzaGQTiW4BskqtVYo= X-Google-Smtp-Source: ABdhPJzJDbXQGEp7eVN1xXjORdIJ+Nh0ugIsaSRJFZgj1rV/C0Ty9mz0PI9tdQfYdS9eQ+x5Dsrd9w== X-Received: by 2002:aa7:d841:: with SMTP id f1mr2813198eds.286.1615377886815; Wed, 10 Mar 2021 04:04:46 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:46 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 06/12] net: enetc: pass bd_count as an argument to enetc_setup_cbdr Date: Wed, 10 Mar 2021 14:03:45 +0200 Message-Id: <20210310120351.542292-7-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org It makes no sense from an API perspective to first initialize some portion of struct enetc_cbdr outside enetc_setup_cbdr, then leave that function to initialize the rest. enetc_setup_cbdr should be able to perform all initialization given a zero-initialized struct enetc_cbdr. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 6 ++---- drivers/net/ethernet/freescale/enetc/enetc.h | 2 +- drivers/net/ethernet/freescale/enetc/enetc_cbdr.c | 5 +++-- drivers/net/ethernet/freescale/enetc/enetc_pf.c | 3 +-- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index a32283533408..06fcab53c471 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1054,9 +1054,6 @@ void enetc_init_si_rings_params(struct enetc_ndev_priv *priv) priv->bdr_int_num = cpus; priv->ic_mode = ENETC_IC_RX_ADAPTIVE | ENETC_IC_TX_MANUAL; priv->tx_ictt = ENETC_TXIC_TIMETHR; - - /* SI specific */ - si->cbd_ring.bd_count = ENETC_CBDR_DEFAULT_SIZE; } int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) @@ -1064,7 +1061,8 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) struct enetc_si *si = priv->si; int err; - err = enetc_setup_cbdr(priv->dev, &si->hw, &si->cbd_ring); + err = enetc_setup_cbdr(priv->dev, &si->hw, ENETC_CBDR_DEFAULT_SIZE, + &si->cbd_ring); if (err) return err; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 19772be63a2c..af8b8be114bd 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -312,7 +312,7 @@ int enetc_setup_tc(struct net_device *ndev, enum tc_setup_type type, void enetc_set_ethtool_ops(struct net_device *ndev); /* control buffer descriptor ring (CBDR) */ -int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, +int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int bd_count, struct enetc_cbdr *cbdr); void enetc_teardown_cbdr(struct enetc_cbdr *cbdr); int enetc_set_mac_flt_entry(struct enetc_si *si, int index, diff --git a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c index bee453be2240..073e56dcca4e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_cbdr.c @@ -3,10 +3,10 @@ #include "enetc.h" -int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, +int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, int bd_count, struct enetc_cbdr *cbdr) { - int size = cbdr->bd_count * sizeof(struct enetc_cbd); + int size = bd_count * sizeof(struct enetc_cbd); cbdr->bd_base = dma_alloc_coherent(dev, size, &cbdr->bd_dma_base, GFP_KERNEL); @@ -23,6 +23,7 @@ int enetc_setup_cbdr(struct device *dev, struct enetc_hw *hw, cbdr->next_to_clean = 0; cbdr->next_to_use = 0; cbdr->dma_dev = dev; + cbdr->bd_count = bd_count; cbdr->pir = hw->reg + ENETC_SICBDRPIR; cbdr->cir = hw->reg + ENETC_SICBDRCIR; diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index 4dd7199d5007..bf70b8f9943f 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1087,8 +1087,7 @@ static void enetc_init_unused_port(struct enetc_si *si) struct enetc_hw *hw = &si->hw; int err; - si->cbd_ring.bd_count = ENETC_CBDR_DEFAULT_SIZE; - err = enetc_setup_cbdr(dev, hw, &si->cbd_ring); + err = enetc_setup_cbdr(dev, hw, ENETC_CBDR_DEFAULT_SIZE, &si->cbd_ring); if (err) return; From patchwork Wed Mar 10 12:03:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127945 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=-15.7 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,URIBL_BLOCKED,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 1385CC433E6 for ; Wed, 10 Mar 2021 12:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D046B64FFA for ; Wed, 10 Mar 2021 12:05:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232690AbhCJMF1 (ORCPT ); Wed, 10 Mar 2021 07:05:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232936AbhCJMEt (ORCPT ); Wed, 10 Mar 2021 07:04:49 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB4F4C061760 for ; Wed, 10 Mar 2021 04:04:48 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id l12so27706118edt.3 for ; Wed, 10 Mar 2021 04:04:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VPKhDvpNanMg66h5KIXhooZXRDUExMMWXCLmke7I9Dw=; b=sFaLMgelmZrYovDwLApFBFhftVMZ71ZDCyHQRRDdA0eJ1ogi4BNCVjL3Ews1t1mhr/ /bM29hmX+xte9B7UkAsAiryCZuusm4yaaMdWjS8TIZA3Yikp8biq932ac+ygoXQ4Nuqs sO+56BpjDXGiKkHDbK0312Xw++7Cp7vzQuIFmqdkd02xaFkTYbLn94BWhz46zdSAhbL2 WHx4HYKQyFpYFsVqp+6duLPZKQ0hJrQO2P5YHhbCIpM9m4pTri2mpYma0af9/3tOK+zp h97pMexgQnHL+VZkWgyO9CYeww4FMh4CsGz2nK/7ZJSwPeyfHTtsOsXGYY4vUeqa8uFp K3ZA== 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:mime-version:content-transfer-encoding; bh=VPKhDvpNanMg66h5KIXhooZXRDUExMMWXCLmke7I9Dw=; b=NRsa0p6cbQETdH14BrrU24jcF++oIrbZBvmi2nkkkMqoh/2+Evnt62qQhUSRI+eNL2 O0KbbQcBjzzQ09p1yYgTZJFV7QqgY/Glyg5Fbj12a7aWM5mpeQSnwFIgVAtOTJl9JPlb PbHKv6s40TWAi6oolcBlTlvuZ58kUXzWMBFTu8FKOv4nGOWagczGMunpk1xhmoTaF7Z4 8suPwapWsCsx5XdXD1qMZYQL8/cIBKQ1qSyqRmaDj1z3lMxwQnwOxuYjJ0RehSFVdaxD 848D5Rq2VU9Z00N9qs/OaKHUzpckW/by2+VknM6J6Z4yJsLxKyW4tNfrKAMPZgwJ8G4M 4JqQ== X-Gm-Message-State: AOAM5319eMEndzavh3+9mrTO+ITTMYnqpqkiRlB7TZAUdJGGu5h3aTC/ mi/JmlohfY0+SKQRk2inFBA= X-Google-Smtp-Source: ABdhPJxd9QHO9gcu9iwkedjzv41jyqUTGjG2On7nrw2C9ffJ/l4iWDdU6sSthM7WOgtq6/j2wd26zA== X-Received: by 2002:aa7:c98f:: with SMTP id c15mr2878798edt.231.1615377887547; Wed, 10 Mar 2021 04:04:47 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:47 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 07/12] net: enetc: don't initialize unused ports from a separate code path Date: Wed, 10 Mar 2021 14:03:46 +0200 Message-Id: <20210310120351.542292-8-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since commit 3222b5b613db ("net: enetc: initialize RFS/RSS memories for unused ports too") there is a requirement to initialize the memories of unused PFs too, which has left the probe path in a bit of a rough shape, because we basically have a minimal initialization path for unused PFs which is separate from the main initialization path. Now that initializing a control BD ring is as simple as calling enetc_setup_cbdr, let's move that outside of enetc_alloc_si_resources (unused PFs don't need classification rules, so no point in allocating them just to free them later). But enetc_alloc_si_resources is called both for PFs and for VFs, so now that enetc_setup_cbdr is no longer called from this common function, it means that the VF probe path needs to explicitly call enetc_setup_cbdr too. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 21 +------- .../net/ethernet/freescale/enetc/enetc_pf.c | 52 ++++++++----------- .../net/ethernet/freescale/enetc/enetc_vf.c | 7 +++ 3 files changed, 30 insertions(+), 50 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 06fcab53c471..f92d29b62bae 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1059,34 +1059,17 @@ void enetc_init_si_rings_params(struct enetc_ndev_priv *priv) int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) { struct enetc_si *si = priv->si; - int err; - - err = enetc_setup_cbdr(priv->dev, &si->hw, ENETC_CBDR_DEFAULT_SIZE, - &si->cbd_ring); - if (err) - return err; priv->cls_rules = kcalloc(si->num_fs_entries, sizeof(*priv->cls_rules), GFP_KERNEL); - if (!priv->cls_rules) { - err = -ENOMEM; - goto err_alloc_cls; - } + if (!priv->cls_rules) + return -ENOMEM; return 0; - -err_alloc_cls: - enetc_teardown_cbdr(&si->cbd_ring); - - return err; } void enetc_free_si_resources(struct enetc_ndev_priv *priv) { - struct enetc_si *si = priv->si; - - enetc_teardown_cbdr(&si->cbd_ring); - kfree(priv->cls_rules); } diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index bf70b8f9943f..c8b6110448d4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1081,22 +1081,6 @@ static int enetc_init_port_rss_memory(struct enetc_si *si) return err; } -static void enetc_init_unused_port(struct enetc_si *si) -{ - struct device *dev = &si->pdev->dev; - struct enetc_hw *hw = &si->hw; - int err; - - err = enetc_setup_cbdr(dev, hw, ENETC_CBDR_DEFAULT_SIZE, &si->cbd_ring); - if (err) - return; - - enetc_init_port_rfs_memory(si); - enetc_init_port_rss_memory(si); - - enetc_teardown_cbdr(&si->cbd_ring); -} - static int enetc_pf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -1120,8 +1104,24 @@ static int enetc_pf_probe(struct pci_dev *pdev, goto err_map_pf_space; } + err = enetc_setup_cbdr(&pdev->dev, &si->hw, ENETC_CBDR_DEFAULT_SIZE, + &si->cbd_ring); + if (err) + goto err_setup_cbdr; + + err = enetc_init_port_rfs_memory(si); + if (err) { + dev_err(&pdev->dev, "Failed to initialize RFS memory\n"); + goto err_init_port_rfs; + } + + err = enetc_init_port_rss_memory(si); + if (err) { + dev_err(&pdev->dev, "Failed to initialize RSS memory\n"); + goto err_init_port_rss; + } + if (node && !of_device_is_available(node)) { - enetc_init_unused_port(si); dev_info(&pdev->dev, "device is disabled, skipping\n"); err = -ENODEV; goto err_device_disabled; @@ -1154,18 +1154,6 @@ static int enetc_pf_probe(struct pci_dev *pdev, goto err_alloc_si_res; } - err = enetc_init_port_rfs_memory(si); - if (err) { - dev_err(&pdev->dev, "Failed to initialize RFS memory\n"); - goto err_init_port_rfs; - } - - err = enetc_init_port_rss_memory(si); - if (err) { - dev_err(&pdev->dev, "Failed to initialize RSS memory\n"); - goto err_init_port_rss; - } - err = enetc_configure_si(priv); if (err) { dev_err(&pdev->dev, "Failed to configure SI\n"); @@ -1201,15 +1189,17 @@ static int enetc_pf_probe(struct pci_dev *pdev, err_mdiobus_create: enetc_free_msix(priv); err_config_si: -err_init_port_rss: -err_init_port_rfs: err_alloc_msix: enetc_free_si_resources(priv); err_alloc_si_res: si->ndev = NULL; free_netdev(ndev); err_alloc_netdev: +err_init_port_rss: +err_init_port_rfs: err_device_disabled: + enetc_teardown_cbdr(&si->cbd_ring); +err_setup_cbdr: err_map_pf_space: enetc_pci_remove(pdev); diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c index 9b755a84c2d6..371a34d3c6b4 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c @@ -165,6 +165,11 @@ static int enetc_vf_probe(struct pci_dev *pdev, enetc_init_si_rings_params(priv); + err = enetc_setup_cbdr(priv->dev, &si->hw, ENETC_CBDR_DEFAULT_SIZE, + &si->cbd_ring); + if (err) + goto err_setup_cbdr; + err = enetc_alloc_si_resources(priv); if (err) { dev_err(&pdev->dev, "SI resource alloc failed\n"); @@ -197,6 +202,8 @@ static int enetc_vf_probe(struct pci_dev *pdev, err_alloc_msix: enetc_free_si_resources(priv); err_alloc_si_res: + enetc_teardown_cbdr(&si->cbd_ring); +err_setup_cbdr: si->ndev = NULL; free_netdev(ndev); err_alloc_netdev: From patchwork Wed Mar 10 12:03:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127949 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=-15.7 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,URIBL_BLOCKED,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 425ECC4332B for ; Wed, 10 Mar 2021 12:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 131B264FFE for ; Wed, 10 Mar 2021 12:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232943AbhCJMF3 (ORCPT ); Wed, 10 Mar 2021 07:05:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232940AbhCJMEt (ORCPT ); Wed, 10 Mar 2021 07:04:49 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F381C061761 for ; Wed, 10 Mar 2021 04:04:49 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id dx17so38200083ejb.2 for ; Wed, 10 Mar 2021 04:04:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/p6MuCdSjj8dGCJeSNxOi5fq7cl/jqB+h/TJZol4I48=; b=XSVV80yUzE2/Y92FrMZNN79Zp2fkKZvMaCagV4VEZDlSBDMruYhHvnmigoxBR4yety wlQIElfD1HJDJat54RGjtfz3UCD8YMUa4nWXu82vRlp76AcaKk+bFpcpsDVB8oV/h0Sj XTZ3R6YTp0Rxk58vf6rD7+8PsThRLsyh0C599noobXbld/5jrPzjeP43S9qAyoTyFHQ4 j+axPkX2RIgMGJlH+KpgkL8dGxKsOOEXCwR6QqwPTMH3K2Y8bSKYbleDLtBdTdCxOTVd MzwHaUdGLd5OmtsIjgwdVrKFBrt0tmVmqlxC+vBKZp8JNhdNNGzJBQZ83rljgSK+a6zR NtzA== 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:mime-version:content-transfer-encoding; bh=/p6MuCdSjj8dGCJeSNxOi5fq7cl/jqB+h/TJZol4I48=; b=AyOL+l1Nlvjdj3eq20BDeGmtCt9Sqwt0RNNA/Xr9NEYKJQ2QUwrUBY1VpnV8Ih5ajF kg1Q86YWe7FEJez5hp93uZ7N5O5IUUw1KzwEo2X/FTSIFSB3SsMSX4BaXWqFX7q+QWtR Pg95kxl/3UzfNuKqk+kpu9it5dDbOVHQalErmHeDAPZGXTZWJKEEQ4YToVvKmNJ4I1mQ n6UqavKECDYDpuF/9nF9DVlwP6J2zY/hBbYRc7tQlpIe48ST7FdDRnHXdUG9t10wLipf Jm5Ld6jC0reK+jMyW93ixVLF9ix8WmtfrPkvCj6W7xvSrT+x/y6/WCmbnbBw9A7UkXVy dM0g== X-Gm-Message-State: AOAM532lxLQfU5Wmyz1X1TBpIsWOPXE3ezevIKRL3EZlPCbInQJKKDHz HvAqpi8Icfk1gqhDWsvm0nA= X-Google-Smtp-Source: ABdhPJy6Ae276DfLs/4iMF3IqmNxbXnVBSMr28Sx9M8u0tXPMQ5+GkGwgBoX+b+la0Q546XYV7hzPA== X-Received: by 2002:a17:906:32da:: with SMTP id k26mr3251291ejk.483.1615377888288; Wed, 10 Mar 2021 04:04:48 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:48 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 08/12] net: enetc: simplify callers of enetc_rxbd_next Date: Wed, 10 Mar 2021 14:03:47 +0200 Message-Id: <20210310120351.542292-9-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org When we iterate through the BDs in the RX ring, the software producer index (which is already passed by value to enetc_rxbd_next) lags behind, and we end up with this funny looking "++i == rx_ring->bd_count" check so that we drag it after us. Let's pass the software producer index "i" by reference, so that enetc_rxbd_next can increment it by itself (mod rx_ring->bd_count), especially since enetc_rxbd_next has to increment the index anyway. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 21 +++++------------- drivers/net/ethernet/freescale/enetc/enetc.h | 23 +++++++++++++------- 2 files changed, 20 insertions(+), 24 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index f92d29b62bae..3b04d7596d80 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -483,13 +483,8 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt) /* clear 'R" as well */ rxbd->r.lstatus = 0; - rxbd = enetc_rxbd_next(rx_ring, rxbd, i); - rx_swbd++; - i++; - if (unlikely(i == rx_ring->bd_count)) { - i = 0; - rx_swbd = rx_ring->rx_swbd; - } + enetc_rxbd_next(rx_ring, &rxbd, &i); + rx_swbd = &rx_ring->rx_swbd[i]; } if (likely(j)) { @@ -704,9 +699,7 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring, cleaned_cnt++; - rxbd = enetc_rxbd_next(rx_ring, rxbd, i); - if (unlikely(++i == rx_ring->bd_count)) - i = 0; + enetc_rxbd_next(rx_ring, &rxbd, &i); if (unlikely(bd_status & ENETC_RXBD_LSTATUS(ENETC_RXBD_ERR_MASK))) { @@ -715,9 +708,7 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring, dma_rmb(); bd_status = le32_to_cpu(rxbd->r.lstatus); - rxbd = enetc_rxbd_next(rx_ring, rxbd, i); - if (unlikely(++i == rx_ring->bd_count)) - i = 0; + enetc_rxbd_next(rx_ring, &rxbd, &i); } rx_ring->ndev->stats.rx_dropped++; @@ -740,9 +731,7 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring, cleaned_cnt++; - rxbd = enetc_rxbd_next(rx_ring, rxbd, i); - if (unlikely(++i == rx_ring->bd_count)) - i = 0; + enetc_rxbd_next(rx_ring, &rxbd, &i); } rx_byte_cnt += skb->len; diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index af8b8be114bd..30b9ad550d7b 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -121,19 +121,26 @@ static inline union enetc_rx_bd *enetc_rxbd(struct enetc_bdr *rx_ring, int i) return &(((union enetc_rx_bd *)rx_ring->bd_base)[hw_idx]); } -static inline union enetc_rx_bd *enetc_rxbd_next(struct enetc_bdr *rx_ring, - union enetc_rx_bd *rxbd, - int i) +static inline void enetc_rxbd_next(struct enetc_bdr *rx_ring, + union enetc_rx_bd **old_rxbd, int *old_index) { - rxbd++; + union enetc_rx_bd *new_rxbd = *old_rxbd; + int new_index = *old_index; + + new_rxbd++; + #ifdef CONFIG_FSL_ENETC_PTP_CLOCK if (rx_ring->ext_en) - rxbd++; + new_rxbd++; #endif - if (unlikely(++i == rx_ring->bd_count)) - rxbd = rx_ring->bd_base; - return rxbd; + if (unlikely(++new_index == rx_ring->bd_count)) { + new_rxbd = rx_ring->bd_base; + new_index = 0; + } + + *old_rxbd = new_rxbd; + *old_index = new_index; } static inline union enetc_rx_bd *enetc_rxbd_ext(union enetc_rx_bd *rxbd) From patchwork Wed Mar 10 12:03:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127943 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=-15.8 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_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 D4867C433DB for ; Wed, 10 Mar 2021 12:05:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9846464FC4 for ; Wed, 10 Mar 2021 12:05:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231402AbhCJMFY (ORCPT ); Wed, 10 Mar 2021 07:05:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbhCJMEu (ORCPT ); Wed, 10 Mar 2021 07:04:50 -0500 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F5D5C061760 for ; Wed, 10 Mar 2021 04:04:50 -0800 (PST) Received: by mail-ej1-x632.google.com with SMTP id jt13so38238712ejb.0 for ; Wed, 10 Mar 2021 04:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+AAyewktgEXL0O/8ExlIFLXjGVBFM+lqDw29htiKYs4=; b=n/2DlZnBliXQMCCnEI1Q9SPEo45fdNFzCqhFewKo//Uylb4DIhNi7VohkkKUoQNpod GSWN/HsUoxLUiyKOWOhhOAxTI+FEtoy/MuqzZKU22L8snsTM2OCWnxCJuiTG6xO1Iih2 1/E23AsT8szNeEuryV1h+c8foWrwmMB2q6g+ptQfOOkfNKasDGzLk0AIWBq0bgY6CaCo 3s5EP6A6Vs21RvE1Blhap3sVMmF6PC3BaedRp6Mjwl1cfojAh7XtfAPCdqs57duOU8K6 Mxn2FC21UbbLw6UZdAfehJ7usbiSaLi6AXHiaiQKcGjwyFJzsIhvvogYKeXBW4CMzRTj LkSA== 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:mime-version:content-transfer-encoding; bh=+AAyewktgEXL0O/8ExlIFLXjGVBFM+lqDw29htiKYs4=; b=R58+Ys0hcTLO2dYtxEy6tS47pBAWZD+TXQZx1XdC1nLsPrWfnYhsYlcqGpvVViqhg0 uwMDy3RINOixZgNzkPvJy4OtmHJRzYLfikXPnnjWaZkC8wruQCX0axsiZvtXCQ1Ug1oI x38zb2wLZHS1qMJwVYXlo6T8cdpN6vneJFzYIDLMmYOVLwAuHVlEHqq5ZOOa/obLwysU E16PLB7o0wiXHV8962PCPPNnz1V00py9WL0Yda3YTpRv/oIxO7u9+iVabhL+XhPBaKss bRnZazI+1w/L5vJSd8Y0XNn6DEwG+7GO26KteQYKArCXoPpra5Zj4hMUQ6NATsptxNk3 00qA== X-Gm-Message-State: AOAM530yz/RWJ9QWfoMPpTCKs2CXAojGGw9r2BvYxYoHE+5lqukT3dgK tPwHxCGL8rMsIMrjYWFw78k= X-Google-Smtp-Source: ABdhPJwx0GPrIAW3V1dpRfSNuwwucSXIHCW3ZyUStnbpD9LGADTPVzwPCvqFpgFytfoQYX7FZrbIsw== X-Received: by 2002:a17:906:1ecc:: with SMTP id m12mr3273486ejj.4.1615377888996; Wed, 10 Mar 2021 04:04:48 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:48 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 09/12] net: enetc: use enum enetc_active_offloads Date: Wed, 10 Mar 2021 14:03:48 +0200 Message-Id: <20210310120351.542292-10-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The active_offloads variable of enetc_ndev_priv has an enum type, use it. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h index 30b9ad550d7b..773e412b9f4e 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.h +++ b/drivers/net/ethernet/freescale/enetc/enetc.h @@ -261,7 +261,7 @@ struct enetc_ndev_priv { u16 rx_bd_count, tx_bd_count; u16 msg_enable; - int active_offloads; + enum enetc_active_offloads active_offloads; u32 speed; /* store speed for compare update pspeed */ From patchwork Wed Mar 10 12:03:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127947 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=-15.7 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,URIBL_BLOCKED,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 5ED80C4332E for ; Wed, 10 Mar 2021 12:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 378C064FFF for ; Wed, 10 Mar 2021 12:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232948AbhCJMFa (ORCPT ); Wed, 10 Mar 2021 07:05:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232674AbhCJMEv (ORCPT ); Wed, 10 Mar 2021 07:04:51 -0500 Received: from mail-ej1-x62c.google.com (mail-ej1-x62c.google.com [IPv6:2a00:1450:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5B02C061760 for ; Wed, 10 Mar 2021 04:04:50 -0800 (PST) Received: by mail-ej1-x62c.google.com with SMTP id mm21so38115642ejb.12 for ; Wed, 10 Mar 2021 04:04:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=+ZQfcmHqQXHrh3vzokputHIWJTJ0QWN5/Qo2JLyjqfo=; b=re2Tzr+GXNh4Gr7k+qD6kQS5X9Sl6WfY94ShQqLA09db+XZzIiD5cGWPYyejr+WHmn QpoIzgYzSLlf+cixfqW/nWtrN3TOVdHSfQ9swmFg2or2WFZpCzaww6Coky1XmGSsA8HG cd0iYVTGzIe6Etlui6VxmH3BS1trAvBWqBHMRm7+cDAaSeAIePJP8SdC5bmbUMGy9di7 wTPubTnhPa5n/aZ30EV/v9Ojzi3s8lGFTofCsifGIu4y6L2gP/Zq9a3StLGRZspPrMWB Xlkp2sWUFxlW4HmXU9nSaVaINXYEWc1g6j6PJNKO5JcykgHA7leSrfrqgY3bkzn1DLeV axng== 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:mime-version:content-transfer-encoding; bh=+ZQfcmHqQXHrh3vzokputHIWJTJ0QWN5/Qo2JLyjqfo=; b=pCyM76WA2ydC8AxNwLZYK2/1IZqoTLeMcYbVI+iZusi1WRnoeUl5uTm/+YIhqOwtUc q6TPFZs3yslomkru4r3Pc3aXEaWt/QNCGd/CnkTgq0pPoIZHwxWHuQudgPqz/QdDliEk oWdqoS6MY9snBUEGs8LY2iQd5BY5AWUFJNSwEHghRCbjPZsYNhKuwGMRZOe7vU+YnzS6 6KV/8M/PPtBBEp5Fh8PU09IAWNwbWqixnOY9zonNJhcuFdqJ/g3HAv2oQSK8lh4SAtvJ gauwOWwglQiqONWiaip/MnCA87vNEi+RSlQ8LXb172MbuSnb2XbtdDcCo/dRk6s1cCRS LNIw== X-Gm-Message-State: AOAM532aI9uQKHtEOOqVbFfnELsd4BXE5Do7wozGD98YkSSCsKDkrWQm ftGeVKshZMXqSutadrndU1wN8Rr3TQA= X-Google-Smtp-Source: ABdhPJwzvyMusXhRctlojb8CLSdNY2U2y62pS9fcVNOoAZVFDK223yHx+kBR1Pl1cCs9wACsGTKpTg== X-Received: by 2002:a17:906:2ed1:: with SMTP id s17mr3270588eji.153.1615377889745; Wed, 10 Mar 2021 04:04:49 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:49 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 10/12] net: enetc: remove forward-declarations of enetc_clean_{rx,tx}_ring Date: Wed, 10 Mar 2021 14:03:49 +0200 Message-Id: <20210310120351.542292-11-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This patch moves the NAPI enetc_poll after enetc_clean_rx_ring such that we can delete the forward declarations. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 92 ++++++++++---------- 1 file changed, 44 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 3b04d7596d80..ddda16f60df9 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -241,10 +241,6 @@ static irqreturn_t enetc_msix(int irq, void *data) return IRQ_HANDLED; } -static bool enetc_clean_tx_ring(struct enetc_bdr *tx_ring, int napi_budget); -static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring, - struct napi_struct *napi, int work_limit); - static void enetc_rx_dim_work(struct work_struct *w) { struct dim *dim = container_of(w, struct dim, work); @@ -273,50 +269,6 @@ static void enetc_rx_net_dim(struct enetc_int_vector *v) net_dim(&v->rx_dim, dim_sample); } -static int enetc_poll(struct napi_struct *napi, int budget) -{ - struct enetc_int_vector - *v = container_of(napi, struct enetc_int_vector, napi); - bool complete = true; - int work_done; - int i; - - enetc_lock_mdio(); - - for (i = 0; i < v->count_tx_rings; i++) - if (!enetc_clean_tx_ring(&v->tx_ring[i], budget)) - complete = false; - - work_done = enetc_clean_rx_ring(&v->rx_ring, napi, budget); - if (work_done == budget) - complete = false; - if (work_done) - v->rx_napi_work = true; - - if (!complete) { - enetc_unlock_mdio(); - return budget; - } - - napi_complete_done(napi, work_done); - - if (likely(v->rx_dim_en)) - enetc_rx_net_dim(v); - - v->rx_napi_work = false; - - /* enable interrupts */ - enetc_wr_reg_hot(v->rbier, ENETC_RBIER_RXTIE); - - for_each_set_bit(i, &v->tx_rings_map, ENETC_MAX_NUM_TXQS) - enetc_wr_reg_hot(v->tbier_base + ENETC_BDR_OFF(i), - ENETC_TBIER_TXTIE); - - enetc_unlock_mdio(); - - return work_done; -} - static int enetc_bd_ready_count(struct enetc_bdr *tx_ring, int ci) { int pi = enetc_rd_reg_hot(tx_ring->tcir) & ENETC_TBCIR_IDX_MASK; @@ -751,6 +703,50 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring, return rx_frm_cnt; } +static int enetc_poll(struct napi_struct *napi, int budget) +{ + struct enetc_int_vector + *v = container_of(napi, struct enetc_int_vector, napi); + bool complete = true; + int work_done; + int i; + + enetc_lock_mdio(); + + for (i = 0; i < v->count_tx_rings; i++) + if (!enetc_clean_tx_ring(&v->tx_ring[i], budget)) + complete = false; + + work_done = enetc_clean_rx_ring(&v->rx_ring, napi, budget); + if (work_done == budget) + complete = false; + if (work_done) + v->rx_napi_work = true; + + if (!complete) { + enetc_unlock_mdio(); + return budget; + } + + napi_complete_done(napi, work_done); + + if (likely(v->rx_dim_en)) + enetc_rx_net_dim(v); + + v->rx_napi_work = false; + + /* enable interrupts */ + enetc_wr_reg_hot(v->rbier, ENETC_RBIER_RXTIE); + + for_each_set_bit(i, &v->tx_rings_map, ENETC_MAX_NUM_TXQS) + enetc_wr_reg_hot(v->tbier_base + ENETC_BDR_OFF(i), + ENETC_TBIER_TXTIE); + + enetc_unlock_mdio(); + + return work_done; +} + /* Probing and Init */ #define ENETC_MAX_RFS_SIZE 64 void enetc_get_si_caps(struct enetc_si *si) From patchwork Wed Mar 10 12:03:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127951 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=-15.7 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,URIBL_BLOCKED,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 7C133C4332D for ; Wed, 10 Mar 2021 12:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 574B364FF2 for ; Wed, 10 Mar 2021 12:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232951AbhCJMFb (ORCPT ); Wed, 10 Mar 2021 07:05:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232880AbhCJMEw (ORCPT ); Wed, 10 Mar 2021 07:04:52 -0500 Received: from mail-ej1-x62a.google.com (mail-ej1-x62a.google.com [IPv6:2a00:1450:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD62BC061760 for ; Wed, 10 Mar 2021 04:04:51 -0800 (PST) Received: by mail-ej1-x62a.google.com with SMTP id ci14so38087681ejc.7 for ; Wed, 10 Mar 2021 04:04:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ayYyAvBxr1TrABfTdFV1fUEE39SFpOOX8S3ioR21sGE=; b=vZLCYzaESyqy1EEiqnE/mArAZyHU1S6oVLkLu1Bbng8ofBSJLtpYAV1fB0pAbXqBN9 4jYWCtuBa/aXGPpcCG5vM1qGtD8V9nrnfPf1YFj7s3cdRQqdX5ZHhMGc5hHbWtIaerGa pk7xZvkWxH0Y5YQTzhgUpqtaU7e8CtrM91m0xrhVKtZGYNr3dJecVWIPD9rXtGL1KCh6 1qqfsoDqR9ND3179NsEoCKGnR4nj9+D+tnMM0JWca3kab48mGUHMUQQX8cZpbVOb2DWT UE2oEfJY0OrDUquSnEVmGG1DSJZUvcPQMHyD8N6k3xlcXh3q7IYl4SQn1BG2vjfOD29+ BE9w== 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:mime-version:content-transfer-encoding; bh=ayYyAvBxr1TrABfTdFV1fUEE39SFpOOX8S3ioR21sGE=; b=L7RpbOKdmX9/Z/1NcR0ZvFIfi2SkV1r6whlh/l38uRZmC4Vr38kaV/E9WSLQ83L64U oA/uvvM+Tu5GJy42f1JwuNwO9JLNcPF1lbejoci3tNO65DU9XEaQotgZeNmJAL+CtOmd o7HufZBXYLQW1mbz5h3D0JQRO9HV75mwZX5MKhyBLDWaswAalb7HrcxU670fow3AJu7+ cMzGC6NzeIW0WuYObBd0PdT+l8GeN38eSUqghYXtBqlzWJE6x4/O1GtpeCEPF17+VrNj 2iJpDKZZDW5BKIHnMagxhj/Lsk0rB3jKmiCF7dqVqha03+pqvTgXqR0OkXx7DNoAQhjh +LVA== X-Gm-Message-State: AOAM532xoz3ERggpGOutKnhRLaappd/3zdaLIceU0HgPoGBGvraRAZeq /ymuPlk7ivdmdF8fwu3I4JA= X-Google-Smtp-Source: ABdhPJy+D+OG6Y8ietSvkPEa6nYMWuCwSF9SkW27q2LGwW93B5eB7QUQwff9I7m8rZoC5ugYAmclsw== X-Received: by 2002:a17:907:3e21:: with SMTP id hp33mr3276230ejc.313.1615377890629; Wed, 10 Mar 2021 04:04:50 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:50 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 11/12] net: enetc: remove forward declaration for enetc_map_tx_buffs Date: Wed, 10 Mar 2021 14:03:50 +0200 Message-Id: <20210310120351.542292-12-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org There is no other reason why this forward declaration exists rather than poor ordering of the functions. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 73 ++++++++++---------- 1 file changed, 35 insertions(+), 38 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index ddda16f60df9..c8b0b03f5ee7 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -12,44 +12,6 @@ #define ENETC_MAX_SKB_FRAGS 13 #define ENETC_TXBDS_MAX_NEEDED ENETC_TXBDS_NEEDED(ENETC_MAX_SKB_FRAGS + 1) -static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb, - int active_offloads); - -netdev_tx_t enetc_xmit(struct sk_buff *skb, struct net_device *ndev) -{ - struct enetc_ndev_priv *priv = netdev_priv(ndev); - struct enetc_bdr *tx_ring; - int count; - - tx_ring = priv->tx_ring[skb->queue_mapping]; - - if (unlikely(skb_shinfo(skb)->nr_frags > ENETC_MAX_SKB_FRAGS)) - if (unlikely(skb_linearize(skb))) - goto drop_packet_err; - - count = skb_shinfo(skb)->nr_frags + 1; /* fragments + head */ - if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_NEEDED(count)) { - netif_stop_subqueue(ndev, tx_ring->index); - return NETDEV_TX_BUSY; - } - - enetc_lock_mdio(); - count = enetc_map_tx_buffs(tx_ring, skb, priv->active_offloads); - enetc_unlock_mdio(); - - if (unlikely(!count)) - goto drop_packet_err; - - if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED) - netif_stop_subqueue(ndev, tx_ring->index); - - return NETDEV_TX_OK; - -drop_packet_err: - dev_kfree_skb_any(skb); - return NETDEV_TX_OK; -} - static void enetc_unmap_tx_buff(struct enetc_bdr *tx_ring, struct enetc_tx_swbd *tx_swbd) { @@ -220,6 +182,41 @@ static int enetc_map_tx_buffs(struct enetc_bdr *tx_ring, struct sk_buff *skb, return 0; } +netdev_tx_t enetc_xmit(struct sk_buff *skb, struct net_device *ndev) +{ + struct enetc_ndev_priv *priv = netdev_priv(ndev); + struct enetc_bdr *tx_ring; + int count; + + tx_ring = priv->tx_ring[skb->queue_mapping]; + + if (unlikely(skb_shinfo(skb)->nr_frags > ENETC_MAX_SKB_FRAGS)) + if (unlikely(skb_linearize(skb))) + goto drop_packet_err; + + count = skb_shinfo(skb)->nr_frags + 1; /* fragments + head */ + if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_NEEDED(count)) { + netif_stop_subqueue(ndev, tx_ring->index); + return NETDEV_TX_BUSY; + } + + enetc_lock_mdio(); + count = enetc_map_tx_buffs(tx_ring, skb, priv->active_offloads); + enetc_unlock_mdio(); + + if (unlikely(!count)) + goto drop_packet_err; + + if (enetc_bd_unused(tx_ring) < ENETC_TXBDS_MAX_NEEDED) + netif_stop_subqueue(ndev, tx_ring->index); + + return NETDEV_TX_OK; + +drop_packet_err: + dev_kfree_skb_any(skb); + return NETDEV_TX_OK; +} + static irqreturn_t enetc_msix(int irq, void *data) { struct enetc_int_vector *v = data; From patchwork Wed Mar 10 12:03:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 12127953 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=-15.7 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,URIBL_BLOCKED,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 A4AE0C43331 for ; Wed, 10 Mar 2021 12:05:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 77E2F64FEE for ; Wed, 10 Mar 2021 12:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232958AbhCJMFc (ORCPT ); Wed, 10 Mar 2021 07:05:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232902AbhCJMEx (ORCPT ); Wed, 10 Mar 2021 07:04:53 -0500 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A17F9C061761 for ; Wed, 10 Mar 2021 04:04:52 -0800 (PST) Received: by mail-ej1-x631.google.com with SMTP id dx17so38200400ejb.2 for ; Wed, 10 Mar 2021 04:04:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xA/ml8LK32aqYsuvbZVIyJ1xT0WmGfjBmjXYMFysg7Q=; b=nWNuqvMdNHXaNetrEAIl+oYi/B02EZmkHM+ngWtYvlcnx7Qw3dstdV5ED8IFmPUZpg mpPe8UypTu3u0DT2Icy9i4jvjN8qt/NqrSBjrzOHDyKKQ4JJ+40I1OFZ4d7YOo8XQQlX 43WKjL68cgCifWUSYtylum3iBdPjUZyzXEdVk0jtuuutTXkUyKATWo2DN117Kv+etDif IwLIoA13huo0Dm5cPRwij24LLucJj2fxkWOfDhy4lEKkTqV/iZAMBq95CsQOFH5v5t3l 3FTqeGwfnUM3BIc8KgC9/qBVbemRhbFI/DFLqlEs+2jSY0hYniFNdsgez+6uU7bsPXsX nFRQ== 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:mime-version:content-transfer-encoding; bh=xA/ml8LK32aqYsuvbZVIyJ1xT0WmGfjBmjXYMFysg7Q=; b=T788bxrTURSnBDjK9cN5HJJFH7xfOUGTUZXt/NjpHtGDe810n5UCildnPkFUB94Y0/ h55hmMnHiLVfcZ1g0BxecDtF+asHcBjmBuS5tQG9aJPyIk+13W4Z9BcxTSHwjYJEk6oj 5CTB2jlFkCe+L7CWAVBqY5PM81IgIBFJLWd9aBPg1R35W9DiQj7LTC8dMyJDsx4uMuRO 60Uyss8CPD80tgA8/epX2YaY/Eze76hCXQ84RtI6A3ybJ66WbOgKMWB2zTX4lkvFCVdO Se0aLxd9h1VqD2SLoOoiQz4vUGthZp0Jf9vmjMmxqGrmynUBINRjBXcGS8NduEpks3l2 VkCQ== X-Gm-Message-State: AOAM530q/joLsYKATctza4+tNmb6afOjmaBvsOemjXKB49iVywZn1dch CUy1U9znwI7j7ag87xVIOrU= X-Google-Smtp-Source: ABdhPJzjAYLMWKPVVne4JDVZKQHfVpWvuKfJnnmnkiO3q5N49NHC6SJdb5DxZuMdxE66/pGLu1CYtg== X-Received: by 2002:a17:906:1754:: with SMTP id d20mr3210823eje.221.1615377891407; Wed, 10 Mar 2021 04:04:51 -0800 (PST) Received: from localhost.localdomain ([188.25.219.167]) by smtp.gmail.com with ESMTPSA id q20sm9913239ejs.41.2021.03.10.04.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Mar 2021 04:04:51 -0800 (PST) From: Vladimir Oltean X-Google-Original-From: Vladimir Oltean To: "David S . Miller" , Jakub Kicinski , netdev@vger.kernel.org Cc: Alex Marginean , Claudiu Manoil Subject: [PATCH net-next 12/12] net: enetc: make enetc_refill_rx_ring update the consumer index Date: Wed, 10 Mar 2021 14:03:51 +0200 Message-Id: <20210310120351.542292-13-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210310120351.542292-1-vladimir.oltean@nxp.com> References: <20210310120351.542292-1-vladimir.oltean@nxp.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Since commit fd5736bf9f23 ("enetc: Workaround for MDIO register access issue"), enetc_refill_rx_ring no longer updates the RX BD ring's consumer index, that is left to be done by the caller. This has led to bugs such as the ones found in 96a5223b918c ("net: enetc: remove bogus write to SIRXIDR from enetc_setup_rxbdr") and 3a5d12c9be6f ("net: enetc: keep RX ring consumer index in sync with hardware"), so it is desirable that we move back the update of the consumer index into enetc_refill_rx_ring. The trouble with that is the different MDIO locking context for the two callers of enetc_refill_rx_ring: - enetc_clean_rx_ring runs under enetc_lock_mdio() - enetc_setup_rxbdr runs outside enetc_lock_mdio() Simplify the callers of enetc_refill_rx_ring by making enetc_setup_rxbdr explicitly take enetc_lock_mdio() around the call. It will be the only place in need of ensuring the hot accessors can be used. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index c8b0b03f5ee7..e85dfccb9ed1 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -439,6 +439,9 @@ static int enetc_refill_rx_ring(struct enetc_bdr *rx_ring, const int buff_cnt) if (likely(j)) { rx_ring->next_to_alloc = i; /* keep track from page reuse */ rx_ring->next_to_use = i; + + /* update ENETC's consumer index */ + enetc_wr_reg_hot(rx_ring->rcir, rx_ring->next_to_use); } return j; @@ -624,13 +627,9 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring, u32 bd_status; u16 size; - if (cleaned_cnt >= ENETC_RXBD_BUNDLE) { - int count = enetc_refill_rx_ring(rx_ring, cleaned_cnt); - - /* update ENETC's consumer index */ - enetc_wr_reg_hot(rx_ring->rcir, rx_ring->next_to_use); - cleaned_cnt -= count; - } + if (cleaned_cnt >= ENETC_RXBD_BUNDLE) + cleaned_cnt -= enetc_refill_rx_ring(rx_ring, + cleaned_cnt); rxbd = enetc_rxbd(rx_ring, i); bd_status = le32_to_cpu(rxbd->r.lstatus); @@ -1122,9 +1121,9 @@ static void enetc_setup_rxbdr(struct enetc_hw *hw, struct enetc_bdr *rx_ring) rx_ring->rcir = hw->reg + ENETC_BDR(RX, idx, ENETC_RBCIR); rx_ring->idr = hw->reg + ENETC_SIRXIDR; + enetc_lock_mdio(); enetc_refill_rx_ring(rx_ring, enetc_bd_unused(rx_ring)); - /* update ENETC's consumer index */ - enetc_rxbdr_wr(hw, idx, ENETC_RBCIR, rx_ring->next_to_use); + enetc_unlock_mdio(); /* enable ring */ enetc_rxbdr_wr(hw, idx, ENETC_RBMR, rbmr);