From patchwork Wed Apr 6 02:25:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Troy Kisky X-Patchwork-Id: 8757671 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A93B19F336 for ; Wed, 6 Apr 2016 02:34:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C1DBF202A1 for ; Wed, 6 Apr 2016 02:34:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D2F4A20295 for ; Wed, 6 Apr 2016 02:34:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1andGD-0003BB-KE; Wed, 06 Apr 2016 02:32:01 +0000 Received: from mail-pa0-x22f.google.com ([2607:f8b0:400e:c03::22f]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1andD4-0007jR-Bn for linux-arm-kernel@lists.infradead.org; Wed, 06 Apr 2016 02:28:47 +0000 Received: by mail-pa0-x22f.google.com with SMTP id td3so22731934pab.2 for ; Tue, 05 Apr 2016 19:28:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=boundarydevices-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yTkXKzFUZESonezkrxy3wgqxCWgwiwrrP65iz1AlWJ0=; b=fTubWjVYpijuZoMGX+P0rQe/jpyJamFZG8CmsX3KekJoNULHh3Zvw1HDEXP1DOJQDQ 3LocMwZf4gh1nF5Fa91Dxmc1/R8xhRIHNrqIJVJvpclqUDOYLtlidNUoehhf/Rsg3uiy 4u6xkwivnfFz09zPRuCP9WxFfAQwVlQEM3BVANECuTf1dAcTPuxp10VREcphzZ0b7agI dcTOuj43VdefGRmXlfUisxWsoZkaOjzd5yo5Rir/izM639jnz/q7YGjH4btvOlaNIK6H P3lomNwOi5/gQCU6bIcCpreGbpFKKfkjNn+I/R/k9tXT2mBQs5jpVSxNgbRBpl3hMzw7 TZ9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yTkXKzFUZESonezkrxy3wgqxCWgwiwrrP65iz1AlWJ0=; b=hFAWX98rQMLmc8Eor2VTfMWoqu1+fdwF36jVKd8eLrlknAVu0qhQWqJQ3MvZH0oRIY twgjki41yE7NYQ5azHSv/Cx9AgQVtNV1yaV0Cogie80Y0XvkBDd1F5mShzc2X8GWo0Gd rMhbWQQLaUKj0ERRK99t268SGnNn631HqUnb4WtODRPUn15G4aLm8ffRZI9MjHcnjVjU wJ+XkD6W0wPj37tquPU023eCkQ9tygpbabTXQpA0cmKJoK/qEFJ6rmZFLlt5J9l5SXe4 o8qcS8UHVJA9h9khuNXQvaHXs9wuRUkyyXfrxyKcuiLKz0cDy1cLXXgBnbnrarh5ctzL jAXQ== X-Gm-Message-State: AD7BkJK7z9Mt4iz7MCBL4GCMt7/vMQ9Vo87/FNMX8BZtRrotpEX0p/yAxs4Qyuw46wvG+g== X-Received: by 10.66.141.76 with SMTP id rm12mr68111737pab.30.1459909703849; Tue, 05 Apr 2016 19:28:23 -0700 (PDT) Received: from localhost.localdomain (wsip-70-184-93-199.ph.ph.cox.net. [70.184.93.199]) by smtp.googlemail.com with ESMTPSA id l14sm528682pfi.23.2016.04.05.19.28.22 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 05 Apr 2016 19:28:23 -0700 (PDT) From: Troy Kisky To: netdev@vger.kernel.org, davem@davemloft.net, fugang.duan@nxp.com, lznuaa@gmail.com Subject: [PATCH net-next V3 09/16] net: fec: eliminate calls to fec_enet_get_prevdesc Date: Tue, 5 Apr 2016 19:25:55 -0700 Message-Id: <1459909562-22865-10-git-send-email-troy.kisky@boundarydevices.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459909562-22865-1-git-send-email-troy.kisky@boundarydevices.com> References: <1459909562-22865-1-git-send-email-troy.kisky@boundarydevices.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160405_192846_601283_C32F2844 X-CRM114-Status: GOOD ( 13.84 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: andrew@lunn.ch, stillcompiling@gmail.com, arnd@arndb.de, sergei.shtylyov@cogentembedded.com, Troy Kisky , gerg@uclinux.org, fabio.estevam@nxp.com, johannes@sipsolutions.net, l.stach@pengutronix.de, linux-arm-kernel@lists.infradead.org, tremyfr@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Eliminating calls to fec_enet_get_prevdesc shrinks the code a little. Signed-off-by: Troy Kisky --- v3: Change commit message s/unsigned status/unsigned int status/ as requested --- drivers/net/ethernet/freescale/fec_main.c | 37 +++++++++---------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 21d2cd0..349fda1 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -758,6 +758,7 @@ static void fec_enet_bd_init(struct net_device *dev) struct bufdesc *bdp; unsigned int i; unsigned int q; + unsigned int status; for (q = 0; q < fep->num_rx_queues; q++) { /* Initialize the receive buffer descriptors. */ @@ -765,19 +766,13 @@ static void fec_enet_bd_init(struct net_device *dev) bdp = rxq->bd.base; for (i = 0; i < rxq->bd.ring_size; i++) { - /* Initialize the BD for every fragment in the page. */ - if (bdp->cbd_bufaddr) - bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY); - else - bdp->cbd_sc = cpu_to_fec16(0); + status = bdp->cbd_bufaddr ? BD_ENET_RX_EMPTY : 0; + if (bdp == rxq->bd.last) + status |= BD_SC_WRAP; + bdp->cbd_sc = cpu_to_fec16(status); bdp = fec_enet_get_nextdesc(bdp, &rxq->bd); } - - /* Set the last buffer to wrap */ - bdp = fec_enet_get_prevdesc(bdp, &rxq->bd); - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); - rxq->bd.cur = rxq->bd.base; } @@ -789,18 +784,16 @@ static void fec_enet_bd_init(struct net_device *dev) for (i = 0; i < txq->bd.ring_size; i++) { /* Initialize the BD for every fragment in the page. */ - bdp->cbd_sc = cpu_to_fec16(0); if (txq->tx_skbuff[i]) { dev_kfree_skb_any(txq->tx_skbuff[i]); txq->tx_skbuff[i] = NULL; } bdp->cbd_bufaddr = cpu_to_fec32(0); + bdp->cbd_sc = cpu_to_fec16((bdp == txq->bd.last) ? + BD_SC_WRAP : 0); bdp = fec_enet_get_nextdesc(bdp, &txq->bd); } - - /* Set the last buffer to wrap */ bdp = fec_enet_get_prevdesc(bdp, &txq->bd); - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); txq->dirty_tx = bdp; } } @@ -2717,19 +2710,16 @@ fec_enet_alloc_rxq_buffers(struct net_device *ndev, unsigned int queue) } rxq->rx_skbuff[i] = skb; - bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY); if (fep->bufdesc_ex) { struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; ebdp->cbd_esc = cpu_to_fec32(BD_ENET_RX_INT); } + bdp->cbd_sc = cpu_to_fec16(BD_ENET_RX_EMPTY | + ((bdp == rxq->bd.last) ? BD_SC_WRAP : 0)); bdp = fec_enet_get_nextdesc(bdp, &rxq->bd); } - - /* Set the last buffer to wrap. */ - bdp = fec_enet_get_prevdesc(bdp, &rxq->bd); - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); return 0; err_alloc: @@ -2752,21 +2742,16 @@ fec_enet_alloc_txq_buffers(struct net_device *ndev, unsigned int queue) if (!txq->tx_bounce[i]) goto err_alloc; - bdp->cbd_sc = cpu_to_fec16(0); bdp->cbd_bufaddr = cpu_to_fec32(0); if (fep->bufdesc_ex) { struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; ebdp->cbd_esc = cpu_to_fec32(BD_ENET_TX_INT); } - + bdp->cbd_sc = cpu_to_fec16((bdp == txq->bd.last) ? + BD_SC_WRAP : 0); bdp = fec_enet_get_nextdesc(bdp, &txq->bd); } - - /* Set the last buffer to wrap. */ - bdp = fec_enet_get_prevdesc(bdp, &txq->bd); - bdp->cbd_sc |= cpu_to_fec16(BD_SC_WRAP); - return 0; err_alloc: