From patchwork Thu Aug 9 08:02:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 143817 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1786133ljj; Thu, 9 Aug 2018 01:02:43 -0700 (PDT) X-Google-Smtp-Source: AA+uWPydD07jOGxfiuA47szi2Z8PSr7/GFlQvufv0lL+wVZzXTiT2IJwO4XvuEbodE52P2VS/kh/ X-Received: by 2002:a62:ed5:: with SMTP id 82-v6mr1245041pfo.198.1533801762998; Thu, 09 Aug 2018 01:02:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533801762; cv=none; d=google.com; s=arc-20160816; b=m244ecWCRvaR5f/AcMlRSw/f745LvXjpdvFBfSNVRsCNaiOrAwXIlwoZgLd6NdzX09 r8wcHv3URGz+bFYW3iiKg9IPAILOhcDmTWe6UBiAGGD/OPiKZxAyTcjK/z/C+Hvxlp2t dCqvdAfCgOCc/rSq5JRas/qPwzwE3Ic68oeAHEG2f7qbg+ew8DrdUzm7/8cadOtCO4gI Shnt/CTQILN2WWXOzVPzdTpxHu5DtqlHqkloFsBmUtACPKePUyFfst02+8cej1jUINdX SvKXB8kaJlFaHepqbT1+CJBIRFsGWVlMb9IrWAhrtyqq9f83G8vv1LY5ueVSipCMQvH6 W7KA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=OPKMUFB7iB94xe5frHT+wx+1uf6dgLXE0iSRMhrq5f4=; b=oCchPy3mZGeyd7Cf++xfqO6yx1Af4taRf7apdpPAemmDe+zn3WKrFnpRS1psb40FTG JvtJWHYimag7pfQAIEDJBEI+HDZo5PXwBlnHtsTSo+Q+q93KQ8YOv1hvaRopcM6VQTPY 8b0pBsot28wi19cb3JWs7zKwx20eno+tMgqfmJAGzx04MjYd1wWANbtIzJgjENAGx85D nb60zu2CURaZpIacDYjIVWEUjOXqpM54ZOd0+gVdDUPVBRsd/QyPDX9y2AC14uF5AVRq iu4D5rbXIHrxDoTMS1cwGpEfCD6ZaD0srhAwiPtsZu5yTjQthnfCIc+cUjPQ1cgMXh6l bZSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EvJ/Kdwc"; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y23-v6si5333350pll.224.2018.08.09.01.02.42; Thu, 09 Aug 2018 01:02:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="EvJ/Kdwc"; spf=pass (google.com: best guess record for domain of netdev-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728005AbeHIK0J (ORCPT + 10 others); Thu, 9 Aug 2018 06:26:09 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33644 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727786AbeHIK0J (ORCPT ); Thu, 9 Aug 2018 06:26:09 -0400 Received: by mail-wr1-f66.google.com with SMTP id g6-v6so4329523wrp.0 for ; Thu, 09 Aug 2018 01:02:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=OPKMUFB7iB94xe5frHT+wx+1uf6dgLXE0iSRMhrq5f4=; b=EvJ/KdwcGzsDaTAQkYB23uSX23f4MeRT9q7BtmWZYwjDFe0UO2Z0Pg4AIII8T2eQEI pFBfSgLMhQy5arf0N4OeSjDFBQdRG71hhgEi5KTCS18VWWFOWJYa5T2YVSRtAaKoC15e 03iJ4xnFIYT0vL5D6KU5xjvQbi7DZnUaHHNgk= 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; bh=OPKMUFB7iB94xe5frHT+wx+1uf6dgLXE0iSRMhrq5f4=; b=sV7pkRfurKcYMvypTJ/n7mMIPAtW3MUaUU+t762FEUnOAEQlkVHpiLmgGcu/f7/Ww3 RazNREFu/CFH0JQLov8YJSDH+n2gcAeUsqDUtIx+f41FGU+XIJ/3yJ3beqW2o7Izo669 eNNVnFmrV9yVCoOYtcS98hbf/K6rFzA6pFzQAgP/lLt2oKW/R45dhfTOdAnNJOM1+rJU yhQ3MdYea8hfWCEZzySWDj5frG+Mg9mUqCYvQ3Ay3c1iWMP2myUqcGgYCIL1O/x65MPw rkT8GlFnK37S/mixpbJDgPrmqR7zXMmm3c03VZMNkkveMtuMgTEbwW3wclmYW1BEq3g7 QT2w== X-Gm-Message-State: AOUpUlFXig/AoRDzLfwruYWviPu460T60v0RZxS9JYSGddelmwOoGes5 GuH1k6oWpfd2VQxY9rAbXhDWJCCjt0M= X-Received: by 2002:adf:e14a:: with SMTP id f10-v6mr681235wri.42.1533801749423; Thu, 09 Aug 2018 01:02:29 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:4605:8300:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id r140-v6sm16753589wmd.7.2018.08.09.01.02.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Aug 2018 01:02:28 -0700 (PDT) From: Ilias Apalodimas To: netdev@vger.kernel.org, jaswinder.singh@linaro.org Cc: arnd@arndb.de, Ilias Apalodimas Subject: [net-next, PATCH 1/2] net: socionext: Use descriptor info instead of MMIO reads on Rx Date: Thu, 9 Aug 2018 11:02:18 +0300 Message-Id: <1533801739-15312-1-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org MMIO reads for remaining packets in queue occur (at least)twice per invocation of netsec_process_rx(). We can use the packet descriptor to identify if it's owned by the hardware and break out, avoiding the more expensive MMIO read operations. This has a ~2% increase on the pps of the Rx path when tested with 64byte packets Signed-off-by: Ilias Apalodimas --- drivers/net/ethernet/socionext/netsec.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 01589b6..ae32909 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -657,8 +657,6 @@ static struct sk_buff *netsec_get_rx_pkt_data(struct netsec_priv *priv, /* move tail ahead */ dring->tail = (dring->tail + 1) % DESC_NUM; - dring->pkt_cnt--; - return skb; } @@ -731,25 +729,18 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget) struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX]; struct net_device *ndev = priv->ndev; struct netsec_rx_pkt_info rx_info; - int done = 0, rx_num = 0; + int done = 0; struct netsec_desc desc; struct sk_buff *skb; u16 len; while (done < budget) { - if (!rx_num) { - rx_num = netsec_read(priv, NETSEC_REG_NRM_RX_PKTCNT); - dring->pkt_cnt += rx_num; - - /* move head 'rx_num' */ - dring->head = (dring->head + rx_num) % DESC_NUM; + u16 idx = dring->tail; + struct netsec_de *de = dring->vaddr + (DESC_SZ * idx); - rx_num = dring->pkt_cnt; - if (!rx_num) - break; - } + if (de->attr & (1U << NETSEC_RX_PKT_OWN_FIELD)) + break; done++; - rx_num--; skb = netsec_get_rx_pkt_data(priv, &rx_info, &desc, &len); if (unlikely(!skb) || rx_info.err_flag) { netif_err(priv, drv, priv->ndev,