From patchwork Fri Aug 10 06:12:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 143886 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2956536ljj; Thu, 9 Aug 2018 23:13:12 -0700 (PDT) X-Google-Smtp-Source: AA+uWPykNwKEqaIqp7aQXvSPSeaOaCcTVIk94Ov0KCL4pWpr8j0OBA3SpA/YqGBHIk2RqacOjuj0 X-Received: by 2002:a62:5cc1:: with SMTP id q184-v6mr5593364pfb.241.1533881592118; Thu, 09 Aug 2018 23:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533881592; cv=none; d=google.com; s=arc-20160816; b=ZX3bvXaNR1YrhZi2sLACeK0RNgosIR7AmW3frSIBhUMmI/vAlqI1caXXoPzyTB2DVl Ey71ab/cNKUotvUizSKcqXilT3RGVbA4ZE22JJnf0gtifBJUXYmd5CTkMYH5mly026dB T6VmWT+ujyS56Bgpt9RIaxfcQDD1AKHYvymAvCLClvAKw7obn7nsxKtF01f+L4xI3uiE OgBKtySH03lmwKWfUDRqpY3JGWhhLGCMtg/NbzKZ2Y9QTYH9Pqu8ccpB90+zq7mJ2np8 3YeWBz+8kPicK9uJwcU1YRJiP5LBxuMohZuqgSp0GUQ1H4RaDkSi0MdvgByVWz9+vxU3 u6jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=6DnYmzxPR99yYOnyX3p12scVESVzAIzadWbDdVifQkg=; b=gqxmtNigDaVSSMmP0AfyE32fQ0eS6kQa1XlmDxLdRjjEShqsWvliZH6vtCnzg0wqt5 LgCNmlLqk9LdT100Ti3SATaPA57Ei3tHkK/0+QInc4EVD4p6PI1yLMEFGB3AYtR95sCq rzLbuWGu2Dd79VGdhKqqlvzFKx8uv8s1o5I78VZcuIbVSKN4SbL4brTp6fMbgtHhaQbs kxAmJBXbIlCiLxom3OmcFR3haPytgvObc4NMQLiSIlTMfQMtGhpxQnW//ITMCiDkQWE+ IQMEzralH5D6BtordQm1krM1F226xABNtE1FW7KULv1Xib7rrrYvLcjhZ2D9b0zKg2BB bNyQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="ChNd9FA/"; 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 h90-v6si7116323plb.484.2018.08.09.23.13.11; Thu, 09 Aug 2018 23:13:12 -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="ChNd9FA/"; 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 S1727438AbeHJIlc (ORCPT + 10 others); Fri, 10 Aug 2018 04:41:32 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:51365 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbeHJIlb (ORCPT ); Fri, 10 Aug 2018 04:41:31 -0400 Received: by mail-wm0-f65.google.com with SMTP id y2-v6so635475wma.1 for ; Thu, 09 Aug 2018 23:13:08 -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:in-reply-to:references; bh=6DnYmzxPR99yYOnyX3p12scVESVzAIzadWbDdVifQkg=; b=ChNd9FA/8wIpkmXVlCNj36WGkKSoJU1DYu8K7WgX5YsXEwrYzISyofMFz+F7edHmPy DfwtmyDwrhKhBBhRfT6HIn2ndjQ5pB7xzIZ1jQ5vep5ivn4gbJ70F0FVBChpmOy6sO/8 tfwztYcfRr23fCunvW5ac/5NMW840k9i3A5hM= 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; bh=6DnYmzxPR99yYOnyX3p12scVESVzAIzadWbDdVifQkg=; b=pDwTR6jUyRlSAFtx2aUx7kI+5oDH3KL/LSia2Gt3VwOcbOCf7SeZKpS89Tbyvn+VEd tIcRP24U0XrZ6Fxd2D7u/WIF90H5hwqtXV1CLFORxVAijuokkrrbvdM84cCNJgqY67wM ECd+m7Q7UGPjg3q0D+JKULLbDFOHwbbJVZbDXIHebU21IJr8G/CyrMDpbK/G6s62VF3G AxMkvzuY5cfDfftftN0pJ9UT6vfFBVdzesa1MF09Bi18DzCXSK8L22CycHjmwLUT6s28 9kVQXxvITJuGUg+9LT3o8Ogek32Z48aqDIge8El9OQc483H9lHmaihUAeZ46/gWUbHvI r8+A== X-Gm-Message-State: AOUpUlEotqWSGcMMA/dB0dkNZ1rmYHAZEQdCOQmz86SU3T3yqnGNHcxQ jPDWy3DiOYERArK5Tj6IelG2Xy4osfI= X-Received: by 2002:a1c:4d09:: with SMTP id o9-v6mr596923wmh.111.1533881587447; Thu, 09 Aug 2018 23:13:07 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:4605:8300:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id i1-v6sm6182483wrq.69.2018.08.09.23.13.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Aug 2018 23:13:06 -0700 (PDT) From: Ilias Apalodimas To: netdev@vger.kernel.org, jaswinder.singh@linaro.org Cc: ard.biesheuvel@linaro.org, masami.hiramatsu@linaro.org, arnd@arndb.de, Ilias Apalodimas Subject: [net-next, PATCH 1/2 v2] net: socionext: Use descriptor info instead of MMIO reads on Rx Date: Fri, 10 Aug 2018 09:12:38 +0300 Message-Id: <1533881559-18589-2-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533881559-18589-1-git-send-email-ilias.apalodimas@linaro.org> References: <1533881559-18589-1-git-send-email-ilias.apalodimas@linaro.org> 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 | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 01589b6..334b618 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -642,8 +642,6 @@ static struct sk_buff *netsec_get_rx_pkt_data(struct netsec_priv *priv, tmp_skb = netsec_alloc_skb(priv, &td); - dma_rmb(); - tail = dring->tail; if (!tmp_skb) { @@ -657,8 +655,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 +727,24 @@ 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; + u16 idx = dring->tail; + struct netsec_de *de = dring->vaddr + (DESC_SZ * idx); - /* move head 'rx_num' */ - dring->head = (dring->head + rx_num) % DESC_NUM; + if (de->attr & (1U << NETSEC_RX_PKT_OWN_FIELD)) + break; - rx_num = dring->pkt_cnt; - if (!rx_num) - break; - } + /* This barrier is needed to keep us from reading + * any other fields out of the netsec_de until we have + * verified the descriptor has been written back + */ + dma_rmb(); 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, From patchwork Fri Aug 10 06:12:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilias Apalodimas X-Patchwork-Id: 143887 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2956567ljj; Thu, 9 Aug 2018 23:13:13 -0700 (PDT) X-Google-Smtp-Source: AA+uWPxUjKt6auoQz7NIDExDL0zyzSRjc1d4YHyc7khplwnEjMy+8IC/hVQHg24OspImVBr+6PXH X-Received: by 2002:a62:990f:: with SMTP id d15-v6mr5573170pfe.162.1533881593595; Thu, 09 Aug 2018 23:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533881593; cv=none; d=google.com; s=arc-20160816; b=ja9ye+i42jKJYdN4AavGJaL8Djg28fMxIRCnc9dB5vCyKERFrxIHZOz/yMqyPmxCLD 9P+n3iRjEDFIU88O1qozzddBtU4WcGZ8I/MucDkM5G9gPWMNP6V0zCToWsJlc/66sJZ+ f2uBSAQsuUFIjZ+bZ022tEGDPHKoSU56JorFTmH/MN1u03r3oE+PF16IP8OW12Wdic6e DZYa8oiTJAbJI/P7rvEbpHTPkmXrR1DRlLVkWTs7pLGJcYlGRWBF9tNdBFE2j0KQ6ZCa 1ceOKixhtF6Q2rlFX6t/n5rFqVgzo7IlON6BUAa5TPi2uGolyeKGMHYsNGybBF/NAv3z lrlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=J7J536chYQMuP2f8Ap1goSIjCZyTXPKdr51AcsLoKG0=; b=jDxIGOIVLLesPnRXKaBfNua62IcAD/EYS0Q7N4i7Ewyd/EK9FQ5hROm2JLJ8DqJJoB G/zj2WzStOnXkLAZfLBxDogYWsKp+/32PprysjQlbZMjpnRtVPRHjqvulPOMA8QyKKMr vgL6YoTtmA7z3ipJVnNbQuk/yjATIaCYyO2QqQld+EYcE4beIfrcyKdHmR+xtd030nFZ UG3nMTAO/MowhBMbdXUoaXoFeo6iOw4h6YzhbADrljTzs4wf8ppH/yUSaNEwKt4yMgjp CfSXyFGLV6VrAZYj/A2bcD7xnUrk6sM5ylFEIneSUiR1A0Acm7y/ITgpAhd933DpdnVU UP4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FsXOm+gO; 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 e36-v6si8183970pge.507.2018.08.09.23.13.13; Thu, 09 Aug 2018 23:13:13 -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=FsXOm+gO; 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 S1727461AbeHJIle (ORCPT + 10 others); Fri, 10 Aug 2018 04:41:34 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:56272 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725784AbeHJIld (ORCPT ); Fri, 10 Aug 2018 04:41:33 -0400 Received: by mail-wm0-f65.google.com with SMTP id f21-v6so619019wmc.5 for ; Thu, 09 Aug 2018 23:13:10 -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:in-reply-to:references; bh=J7J536chYQMuP2f8Ap1goSIjCZyTXPKdr51AcsLoKG0=; b=FsXOm+gOt7iPq2F8A0pLbxEMXncmPn9D9vWZCns0N6Nrx3wtMASUcebxx0tB6GJ7hA lxcJhHq/DeHuFO/vewh7pVSw2uJjax2sSJTur0K1r/3RXU3gJeyP7QFPFWOUbfwkM0Cc rwjhBdYdpN89OlyVu8gxbMETl4zwQszDqkG6o= 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; bh=J7J536chYQMuP2f8Ap1goSIjCZyTXPKdr51AcsLoKG0=; b=cHRM9wvQ9qHWSRI0flohl6CQgOIZwEd37Aash+DyF3VQ1rppLCjystiL/9yfuRi+14 VKPzxkJM0QQf4XENiKGnfCt8F7fTdUhgvApv2ncwyTuUOva9qv5u1nCO6HwB4/lp0MOk DfpTj6tD2FyVpsSYJn4eWKIxyUCtsFZey/DvPIGskytdJi0/vAjlyNvJ0lffuwK+nZJ4 SAmg9oxP26NTuhhDVBx48q0wBgoaF9IxIqW//73xFMUItkkTU+emqf3hXj72BT/ysT7T iLbgBRb1QdjTEgQMhE4ywoIdXEu3MEtCii7GKG/kdfvJH4aoNES2k6iJAp/CZ/cbL4MT 3d6w== X-Gm-Message-State: AOUpUlFMye4W1EdJwq5IUTpBV+QUhVSNPth9ikmknNGL4H1F0/GpiTVd Z0Gy7DKoWqUfZJRVVN2gVMzwUBeLttA= X-Received: by 2002:a1c:790b:: with SMTP id l11-v6mr538061wme.66.1533881589662; Thu, 09 Aug 2018 23:13:09 -0700 (PDT) Received: from localhost.localdomain ([2a02:587:4605:8300:2e56:dcff:fe9a:8f06]) by smtp.gmail.com with ESMTPSA id i1-v6sm6182483wrq.69.2018.08.09.23.13.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Aug 2018 23:13:09 -0700 (PDT) From: Ilias Apalodimas To: netdev@vger.kernel.org, jaswinder.singh@linaro.org Cc: ard.biesheuvel@linaro.org, masami.hiramatsu@linaro.org, arnd@arndb.de, Ilias Apalodimas Subject: [net-next, PATCH 2/2 v2] net: socionext: Increase descriptors to 256 Date: Fri, 10 Aug 2018 09:12:39 +0300 Message-Id: <1533881559-18589-3-git-send-email-ilias.apalodimas@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1533881559-18589-1-git-send-email-ilias.apalodimas@linaro.org> References: <1533881559-18589-1-git-send-email-ilias.apalodimas@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Increasing descriptors to 256 from 128 and adjusting the NAPI weight to 64 increases performace on Rx by ~20% on 64byte packets Signed-off-by: Ilias Apalodimas --- drivers/net/ethernet/socionext/netsec.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index 334b618..7aa5ebb 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c @@ -232,8 +232,7 @@ #define NETSEC_EEPROM_PKT_ME_ADDRESS 0x20 #define NETSEC_EEPROM_PKT_ME_SIZE 0x24 -#define DESC_NUM 128 -#define NAPI_BUDGET (DESC_NUM / 2) +#define DESC_NUM 256 #define DESC_SZ sizeof(struct netsec_de) @@ -1659,7 +1658,7 @@ static int netsec_probe(struct platform_device *pdev) dev_info(&pdev->dev, "hardware revision %d.%d\n", hw_ver >> 16, hw_ver & 0xffff); - netif_napi_add(ndev, &priv->napi, netsec_napi_poll, NAPI_BUDGET); + netif_napi_add(ndev, &priv->napi, netsec_napi_poll, NAPI_POLL_WEIGHT); ndev->netdev_ops = &netsec_netdev_ops; ndev->ethtool_ops = &netsec_ethtool_ops;