Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7531079rwb; Tue, 15 Nov 2022 13:51:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf4n92GQ6b4sHgnPvZ9qM/fJqNsB/fRNGC4aNkhqd3DgpDtRHVY0RH7ji6ACHiiFSH19kg+V X-Received: by 2002:a17:906:66da:b0:7a5:f8a5:6f84 with SMTP id k26-20020a17090666da00b007a5f8a56f84mr14950035ejp.569.1668549108918; Tue, 15 Nov 2022 13:51:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668549108; cv=none; d=google.com; s=arc-20160816; b=cd2gR2QZHzxXCatxz6sIWQ8gi3EHU5gKPCxWpGIGVVkpAnDPYE+3gGT4YG1kixMGLK pKNKlsgVapF22U3XohQ1I8MmfA8UHHNbYdRpCg98uyR/JAkz//xDZV2k7+0xImtAMiqc x+f5JSwcfYWSCA6TtdmqzT5E0H8YJJRCHLeuJwNaLNCQB8a7Huad5DsU5spYGgycLq/4 HuHMk6EL1Su0yMV9wc73br/cBxT/QyZjY5qjR97x5DkL9vDRtaZZfMoWiidpZkfm/RMp gqI64V80K4s0t+tsYx77NOk0NowXFC8MIHaI48NJ3NVozJlL4eY8ZNAVrPnmD9kqIlL4 h45g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qs1s2ENuS1HxKJUn7dlYW3Oc+jM1IsYuFiyw3J+oEzw=; b=gG+jLGb2RWWAOpJd/GwdqsfX7TH19jUobw1j47QMZtu2tmDNQJdjbQlf1KlIMphlW8 vbz/tZzsXY/acASTGA3Jr2MYM0MVDtfwyzBEEE5SbvPFix5hTNcR8CEQtLJClsvoqO5b T8hLWWTOlZQnQeA+2uKXf0xuAs2MWo6vfS+f+CLtkbtbQpUmUtKutGMFmc/hHYEDqaAp 1u/JtxR4nM6/ZBWL90noFsrbziZN/IEHVBcTG5HH/vBm0rWUSiZ8OA7bQxUDpw82BiTL ehdqzfa0z+oQK6gIqghNM3iMH+Xfq6vqY2rAj2gE0LRlEyjKHgZ1bAMeNgRfYSF0BrqK 7hPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ZEfG3ByO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020a1709061e1600b007a641e472f0si11033069ejj.139.2022.11.15.13.51.23; Tue, 15 Nov 2022 13:51:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ZEfG3ByO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238764AbiKOVke (ORCPT + 90 others); Tue, 15 Nov 2022 16:40:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238606AbiKOVka (ORCPT ); Tue, 15 Nov 2022 16:40:30 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ED86826118; Tue, 15 Nov 2022 13:40:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1668548430; x=1700084430; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j2O7GMy+IIz1SySbZrYhpOJz3Xy8edTsWmZxxV8XFC4=; b=ZEfG3ByOvC+G9AwTWsMxkvuNm56+3Jgz3/Q0VJOI6gZtcJsnFTaYbmSF jhqzHd4+sABv20LC/Ap0lnkzyWq0bVbYufz2deBc3xMZFzDI7a2hCY0CA F/7XECzA+wambzYxj/3XjY00AT4wAERviiw+qiw/oZsx7x7A2vXsT8STU T2WIJnzwOUp2cXoyAJuZVS6Vw8tbZ3Btmr9fF3l/EBCiUs53X11u3p/+Q MmDhZ2KXSB6wRD2fFZwuF7SzINtJh9TFfyv9Riid45AvMMD1rKGXL/4Xe 9NqL7bZ1LV2f7vMYfVAtt9BQMIoQAyw4IX0oU5gHLSIYtSwicjxEaa0al g==; X-IronPort-AV: E=Sophos;i="5.96,167,1665471600"; d="scan'208";a="123588507" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 15 Nov 2022 14:40:29 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 15 Nov 2022 14:40:27 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Tue, 15 Nov 2022 14:40:25 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , , Horatiu Vultur Subject: [PATCH net-next v2 2/5] net: lan966x: Introduce helper functions Date: Tue, 15 Nov 2022 22:44:53 +0100 Message-ID: <20221115214456.1456856-3-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221115214456.1456856-1-horatiu.vultur@microchip.com> References: <20221115214456.1456856-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Introduce lan966x_fdma_tx_setup_dcb and lan966x_fdma_tx_start functions and use of them inside lan966x_fdma_xmit. There is no functional change in here. They are introduced to be used when XDP_TX/REDIRECT actions are introduced. Signed-off-by: Horatiu Vultur --- .../ethernet/microchip/lan966x/lan966x_fdma.c | 71 ++++++++++++------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c index 3055124b4dd79..94c720e59caee 100644 --- a/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c +++ b/drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c @@ -612,14 +612,53 @@ static int lan966x_fdma_get_next_dcb(struct lan966x_tx *tx) return -1; } +static void lan966x_fdma_tx_setup_dcb(struct lan966x_tx *tx, + int next_to_use, int len, + dma_addr_t dma_addr) +{ + struct lan966x_tx_dcb *next_dcb; + struct lan966x_db *next_db; + + next_dcb = &tx->dcbs[next_to_use]; + next_dcb->nextptr = FDMA_DCB_INVALID_DATA; + + next_db = &next_dcb->db[0]; + next_db->dataptr = dma_addr; + next_db->status = FDMA_DCB_STATUS_SOF | + FDMA_DCB_STATUS_EOF | + FDMA_DCB_STATUS_INTR | + FDMA_DCB_STATUS_BLOCKO(0) | + FDMA_DCB_STATUS_BLOCKL(len); +} + +static void lan966x_fdma_tx_start(struct lan966x_tx *tx, int next_to_use) +{ + struct lan966x *lan966x = tx->lan966x; + struct lan966x_tx_dcb *dcb; + + if (likely(lan966x->tx.activated)) { + /* Connect current dcb to the next db */ + dcb = &tx->dcbs[tx->last_in_use]; + dcb->nextptr = tx->dma + (next_to_use * + sizeof(struct lan966x_tx_dcb)); + + lan966x_fdma_tx_reload(tx); + } else { + /* Because it is first time, then just activate */ + lan966x->tx.activated = true; + lan966x_fdma_tx_activate(tx); + } + + /* Move to next dcb because this last in use */ + tx->last_in_use = next_to_use; +} + int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev) { struct lan966x_port *port = netdev_priv(dev); struct lan966x *lan966x = port->lan966x; struct lan966x_tx_dcb_buf *next_dcb_buf; - struct lan966x_tx_dcb *next_dcb, *dcb; struct lan966x_tx *tx = &lan966x->tx; - struct lan966x_db *next_db; int needed_headroom; int needed_tailroom; dma_addr_t dma_addr; @@ -665,16 +704,7 @@ int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev) } /* Setup next dcb */ - next_dcb = &tx->dcbs[next_to_use]; - next_dcb->nextptr = FDMA_DCB_INVALID_DATA; - - next_db = &next_dcb->db[0]; - next_db->dataptr = dma_addr; - next_db->status = FDMA_DCB_STATUS_SOF | - FDMA_DCB_STATUS_EOF | - FDMA_DCB_STATUS_INTR | - FDMA_DCB_STATUS_BLOCKO(0) | - FDMA_DCB_STATUS_BLOCKL(skb->len); + lan966x_fdma_tx_setup_dcb(tx, next_to_use, skb->len, dma_addr); /* Fill up the buffer */ next_dcb_buf = &tx->dcbs_buf[next_to_use]; @@ -688,21 +718,8 @@ int lan966x_fdma_xmit(struct sk_buff *skb, __be32 *ifh, struct net_device *dev) LAN966X_SKB_CB(skb)->rew_op == IFH_REW_OP_TWO_STEP_PTP) next_dcb_buf->ptp = true; - if (likely(lan966x->tx.activated)) { - /* Connect current dcb to the next db */ - dcb = &tx->dcbs[tx->last_in_use]; - dcb->nextptr = tx->dma + (next_to_use * - sizeof(struct lan966x_tx_dcb)); - - lan966x_fdma_tx_reload(tx); - } else { - /* Because it is first time, then just activate */ - lan966x->tx.activated = true; - lan966x_fdma_tx_activate(tx); - } - - /* Move to next dcb because this last in use */ - tx->last_in_use = next_to_use; + /* Start the transmission */ + lan966x_fdma_tx_start(tx, next_to_use); return NETDEV_TX_OK; -- 2.38.0