From patchwork Tue Nov 22 21:44:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 24592 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2454878wrr; Tue, 22 Nov 2022 13:50:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4GBT8r/6/jJ32W/IIrPPTGrJo1hCBnt6YZy7Jxs1DFBUecS21x5H/9c7D/pdj4tiuN23Ea X-Received: by 2002:a17:906:89a1:b0:7ae:3193:8cf3 with SMTP id gg33-20020a17090689a100b007ae31938cf3mr20218121ejc.416.1669153850429; Tue, 22 Nov 2022 13:50:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669153850; cv=none; d=google.com; s=arc-20160816; b=WftA1srcOKBHZraIeQN+aQDqwdlhe3/ohsNsHcUDmCO4qIF+CkzwneF2sDfVNG81p/ qs/fGzzjyzbFS5AbuLWJNQEExISEWu+fDZr84DkwDapd9dt4YyKYH2v7/UUqo58lPzcV SRMeVIVxkXuPk9QWk1y6GReFu27jfBks8mI4qnO7asS05aFYRet0XJHGcpP1tmJ1OEf7 WU+I3ClVlgb1u5t3j6u7+OrIwjTtRhcU9GyxuniRYyRs0lVTumykCNF+uJcrMjpvRO2S 2TSKg8b9SKxmC5PDk7JL4eiCsdkqYhMEzfKdUQ6demO0eVYjPk4JuSA5wuk+eCl1zmjw DrNg== 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=wHaOKFMZXTrHNoMhFtFOGAUiPOnZvXmPAX9tgDADGBkvZoEPSVFZ1Er3cjLkzqhQ3/ +garFCkVwk3FEfeM02ik9r6/7efSDpHIjbDiyK7o2VKnfw/lyKrm3p6nnpVPhhkiPSdx un7s1PsOaDg4aBp5gPFaLzPr9wqWzjn+qlfKxNqVf25HBhGHquWjTUdYu8WALt7UvgL/ 3El5P67Y1dK3lG4lrn22UoRk39U7ibYDeOKR5YTSCXu/yNgHPSAUG2pdKd2YNgaz+A/p ub7p6+tJx1jg3JUieMX0WaPP24qC9YBSdD0/BCNmV6NzVGNQvVM9LcxwCVblQY9YuwE+ sWFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=MUUHP5FF; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z19-20020a05640235d300b00461f10cb543si14405981edc.154.2022.11.22.13.50.26; Tue, 22 Nov 2022 13:50:50 -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=MUUHP5FF; 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 S233207AbiKVVka (ORCPT + 99 others); Tue, 22 Nov 2022 16:40:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235109AbiKVVkO (ORCPT ); Tue, 22 Nov 2022 16:40:14 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67A0DC6549; Tue, 22 Nov 2022 13:40:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1669153209; x=1700689209; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=j2O7GMy+IIz1SySbZrYhpOJz3Xy8edTsWmZxxV8XFC4=; b=MUUHP5FFQzIX/szcWm7WhYV5XZG8UbLgEPgxCV+2EyY87524CyQ2i3j6 GRzBySIRnoeu70Z52Ud7TuLQWfm0LLffU1WsayjXxqRLi9N5/pR59maqg miSIVPmWokTDs7Kwbu/LOi81zzVR7FT4TCHS+XaVKpYLegizuQbTUT1lP T/pjyXT5j3/4FGEO+JCRAfgZnxTGNb2BKST68gpYutCWxD8yq4Vq4S/3i G/W0OcTda1XLgE7w6Hmv0wA5I3Tys6OvW1QKl5LecZsjVQnvgKT3fWSGM RpEwc/ziaFhLMu1FlTTeUaK8ze73O2KFBxuCKG1sZJGLI0C6/oDmjMoZo g==; X-IronPort-AV: E=Sophos;i="5.96,185,1665471600"; d="scan'208";a="201008054" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 22 Nov 2022 14:40:08 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 22 Nov 2022 14:40:00 -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, 22 Nov 2022 14:39:57 -0700 From: Horatiu Vultur To: , , CC: , , , , , , , , , , Horatiu Vultur Subject: [PATCH net-next v4 2/7] net: lan966x: Introduce helper functions Date: Tue, 22 Nov 2022 22:44:08 +0100 Message-ID: <20221122214413.3446006-3-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221122214413.3446006-1-horatiu.vultur@microchip.com> References: <20221122214413.3446006-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 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, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_SPF_TEMPERROR 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750234668294334618?= X-GMAIL-MSGID: =?utf-8?q?1750234668294334618?= 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;