Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1106868imm; Fri, 15 Jun 2018 11:17:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKINpReRRl8LpLZUjUf3LLiYZpBnZhEEm6Xq0gVHZyyF8mRjwavVAg/q1emeClZ5piyJ2ZLG X-Received: by 2002:a63:6e4e:: with SMTP id j75-v6mr2553584pgc.125.1529086670738; Fri, 15 Jun 2018 11:17:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529086670; cv=none; d=google.com; s=arc-20160816; b=bT1d4ul7/GHUEdDiQPnFtL70Z+6wUjJ9ePteemN5iHX9Nh21SsckFMFHLPF7NCLGnB tASaJMZXcN33rnmcIJwSZIOq4gWdcYYTJ4vmCANu1M9BWinpim4DvODxDIrEIq1dXU44 cwjDZE8E0sog4Q+Apj+5TychDIwiox5JQOMZ1zXLqYbi++cjq5UsZmFGvQC7Ls7VBvOv cIXmA9ygWSo5J6jHBjemqoigHE22MRDrwqdhN8po7kCamJb2g2SOATlQZ08ugoJBOD/0 TcQvlMXRvTuDK7qMg8/js8vrpQYMri9sSBydHU0/Q3djsKsZSDf/QKfeGjEoeG/aCmUL LIkQ== 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=j3jIepUwDw2xc+pgExVeFYswjqlQIgEI3e1Xbicq7EM=; b=Zj7xWHz1H5MkMGyQka5H8GvxCQEH6dB89svD3pSUdrpgQLUA74i8e0b4xr1HmQP1OY RMghUFIVazUELRNRnEIKyls53SWeQrCqB3UNZpX21j7k/RMF4Sho4+AJ252vrRy8WPH+ b79qVe1ALdT7P2tLTvHjvq4NLHJ8k1uP3ZpjQHWW3i87UT6WLov57z1mBVTan4bSAZcf C+2c11Y0tgYbDRy8+WjGErGX85gt66fWQxLqoad5E3Vj0lNJkM+vNy0h4TaVyqg3GjZ4 DkySs9T4Aqh9x/7QScUe6GYLplTBJKFkcd7kfePrwqG44aEzynu/kvL0ykrZXiTtkAeB L/ZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MB6nTE7a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 4-v6si8625164pfl.289.2018.06.15.11.17.35; Fri, 15 Jun 2018 11:17:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=MB6nTE7a; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1756563AbeFOSPc (ORCPT + 99 others); Fri, 15 Jun 2018 14:15:32 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:38730 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756298AbeFOSNR (ORCPT ); Fri, 15 Jun 2018 14:13:17 -0400 Received: by mail-lf0-f68.google.com with SMTP id i83-v6so15891667lfh.5 for ; Fri, 15 Jun 2018 11:13:16 -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=j3jIepUwDw2xc+pgExVeFYswjqlQIgEI3e1Xbicq7EM=; b=MB6nTE7aJ3eJJTiSH6BDy3JK8a4ovz4lxXEQP7zZnX3rhojCabrb37HXiMoqRRVdkT pqacbX0SZpNdNN7hH6xHv3kpPFwbJIihGIoXkjDUM9RiHqMzs4ityas8Fl1234aVJ3ZP x5jzSDsGuaTrhSKeiciCXeuQKGhQChQgJbOS8= 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=j3jIepUwDw2xc+pgExVeFYswjqlQIgEI3e1Xbicq7EM=; b=JcYGM5uWfZ4PqAmAugzKnnZ7/fBpvXxCL559OFRrndnajfyw80l6mvh0zVv+IrQQeI aIC/Ib8uyaTMH+VkSaRIizTuvRMdyZqs8iGA5TCgwqPUh8kypLM5hzljoDIC4+ghUbW8 ++vwNxhSg19Gizr/asv2yFpnTjU/DlbTDKRAZKKuXTxaBCUKDr51h8lOoDobwe7s6X+u oTnYPA3yaJ3e0acpoB4bsLMGshe4CEDRvoZw9xgwmgc03jLNQWD9314wovG0KfQrFkNb S56RlVPqSgC7ok58tG7/imrvAWyXVp+BRj+ahUBpZ3e1eEzCa/fY0VZwY08UPI++AL+O TudQ== X-Gm-Message-State: APt69E24e6tDX2smqFxITZQn2Z7880CK/UcxqTrw6MLou1GG/K5om1CC QTyfRidd1klPStIFZirMRiycdA== X-Received: by 2002:a19:ef11:: with SMTP id n17-v6mr1947708lfh.66.1529086396162; Fri, 15 Jun 2018 11:13:16 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id h4-v6sm1543260ljc.8.2018.06.15.11.13.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Jun 2018 11:13:15 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, davem@davemloft.net Cc: corbet@lwn.net, akpm@linux-foundation.org, netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, vinicius.gomes@intel.com, henrik@austad.us, jesus.sanchez-palencia@intel.com, ilias.apalodimas@linaro.org, p-varis@ti.com, spatton@ti.com, francois.ozog@linaro.org, yogeshs@ti.com, nsekhar@ti.com, andrew@lunn.ch, Ivan Khoronzhuk Subject: [PATCH v3 net-next 1/6] net: ethernet: ti: cpsw: use cpdma channels in backward order for txq Date: Fri, 15 Jun 2018 21:13:05 +0300 Message-Id: <20180615181310.10437-2-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180615181310.10437-1-ivan.khoronzhuk@linaro.org> References: <20180615181310.10437-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cpdma channel highest priority is from hi to lo number. The driver has limited number of descriptors that are shared between number of cpdma channels. Number of queues can be tuned with ethtool, that allows to not spend descriptors on not needed cpdma channels. In AVB usually only 2 tx queues can be enough with rate limitation. The rate limitation can be used only for hi priority queues. Thus, to use only 2 queues the 8 has to be created. It's wasteful. So, in order to allow using only needed number of rate limited tx queues, save resources, and be able to set rate limitation for them, let assign tx cpdma channels in backward order to queues. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 534596ce00d3..406537d74ec1 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -967,8 +967,8 @@ static int cpsw_tx_mq_poll(struct napi_struct *napi_tx, int budget) /* process every unprocessed channel */ ch_map = cpdma_ctrl_txchs_state(cpsw->dma); - for (ch = 0, num_tx = 0; ch_map; ch_map >>= 1, ch++) { - if (!(ch_map & 0x01)) + for (ch = 0, num_tx = 0; ch_map & 0xff; ch_map <<= 1, ch++) { + if (!(ch_map & 0x80)) continue; txv = &cpsw->txv[ch]; @@ -2431,7 +2431,7 @@ static int cpsw_update_channels_res(struct cpsw_priv *priv, int ch_num, int rx) void (*handler)(void *, int, int); struct netdev_queue *queue; struct cpsw_vector *vec; - int ret, *ch; + int ret, *ch, vch; if (rx) { ch = &cpsw->rx_ch_num; @@ -2444,7 +2444,8 @@ static int cpsw_update_channels_res(struct cpsw_priv *priv, int ch_num, int rx) } while (*ch < ch_num) { - vec[*ch].ch = cpdma_chan_create(cpsw->dma, *ch, handler, rx); + vch = rx ? *ch : 7 - *ch; + vec[*ch].ch = cpdma_chan_create(cpsw->dma, vch, handler, rx); queue = netdev_get_tx_queue(priv->ndev, *ch); queue->tx_maxrate = 0; @@ -2980,7 +2981,7 @@ static int cpsw_probe(struct platform_device *pdev) u32 slave_offset, sliver_offset, slave_size; const struct soc_device_attribute *soc; struct cpsw_common *cpsw; - int ret = 0, i; + int ret = 0, i, ch; int irq; cpsw = devm_kzalloc(&pdev->dev, sizeof(struct cpsw_common), GFP_KERNEL); @@ -3155,7 +3156,8 @@ static int cpsw_probe(struct platform_device *pdev) if (soc) cpsw->quirk_irq = 1; - cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, 0, cpsw_tx_handler, 0); + ch = cpsw->quirk_irq ? 0 : 7; + cpsw->txv[0].ch = cpdma_chan_create(cpsw->dma, ch, cpsw_tx_handler, 0); if (IS_ERR(cpsw->txv[0].ch)) { dev_err(priv->dev, "error initializing tx dma channel\n"); ret = PTR_ERR(cpsw->txv[0].ch); -- 2.17.1