Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6255760imm; Mon, 23 Jul 2018 14:29:55 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe3yzuLvaAQvQcpNXpCnC/rjEndgDv0fwoMhZtartvzYkaLIg9FeZxsUpUSdhxfGET8tBPO X-Received: by 2002:a17:902:7482:: with SMTP id h2-v6mr14588211pll.185.1532381395221; Mon, 23 Jul 2018 14:29:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532381395; cv=none; d=google.com; s=arc-20160816; b=CCHlh1m1RUbVbjgrXYYLWYGuu0f2i2roTywYaaTom0DvaUNxsLRFIgogMhVsZM0OSd SLOw+jcFqO5XGVZ6tXtqvt4sjCGzxOP7v4zUZSdsIZSIk0+aRTdLJdR6hRhrLs6cyRDP +8XKyQmUdZvSSezWeovW39Qxa9KpcI96fvHWN/LUT/RaRVTLupYWb2Jo7Y//Pyj3B/G9 CiTBKeQTepYU2+sDYiKj7AA3vog0LMsbCpJCcYEYmCzxRBIR2cKVgPIzG7ppXr12Nwva Jtytu4dIshlsGBO6R4m5Hd8RtH8F2dSt/gjuu4U1e26NdiSoST391aHP/ujeSCy/G+Wc Ujkg== 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=o7Oc/jmwijNpxWrXdFhQ/BdX4OfuEgoV0xJjMD6tz/M=; b=Jqy+3VZYWU+haP4FdBWuhqykoy+c5hdaJ0h3FQjsKaTkwhuUxLIrAj5Gn9QmC72aCO 1qmngeY3LaSzgLD2bbj0fp2QXF5w+vwKBrAZM60CWS469Yz5JOAXdhzdny/LKxRP2SVo S/f3REEm4KoaMRAOgLSwz8ZvuyOKfeB5j2PcE9AfoL0JqSGCpck0JB1+K8i9gFB9jpx4 4eQHGBhDM/UHtiVOZpNxJ3KPIdOiEa7nG0h2B06gd5uJOolwvUdwRH6uJqBzFx3POK0C 6jpVwi5m4+exEUCbIrm/1yQ1wkEvFuKsGdRH88p0vt/NxfHvQcoB1x4kEi8zEE5PhDjl 3TwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="HHIi/rjW"; 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 a24-v6si8383117pgv.527.2018.07.23.14.29.40; Mon, 23 Jul 2018 14:29:55 -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="HHIi/rjW"; 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 S2388229AbeGWW36 (ORCPT + 99 others); Mon, 23 Jul 2018 18:29:58 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:44256 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388210AbeGWW35 (ORCPT ); Mon, 23 Jul 2018 18:29:57 -0400 Received: by mail-lf1-f68.google.com with SMTP id g6-v6so1497816lfb.11 for ; Mon, 23 Jul 2018 14:26:50 -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=o7Oc/jmwijNpxWrXdFhQ/BdX4OfuEgoV0xJjMD6tz/M=; b=HHIi/rjWoIa7wDsPm1NWPpYqDdzyHLJteOvkOMuib9rtzUHfJhvw4EE18f9Fx5cvuQ LvonTVzqXq+vrhGENKCa6zUbAJZ9sD50Rm7O5An9iMExKE/O4R7MCaXFx29ovCYVKbJn RTO2gvgPlbM7888u7REGBuzy9L3VizF9ObXUE= 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=o7Oc/jmwijNpxWrXdFhQ/BdX4OfuEgoV0xJjMD6tz/M=; b=dh8RkHvW0PZ0IGQQNCSoDyzmwy8nXoo7VI5kBUd8tQHEBJC2WvYzgigr3aWamVbrEa Tq/gFPOZUe1b7n1qJXii7Q85N9eg6z4R3ES56e9fnKNg722CQHPrLyvePn0Q4OJtqNTf 7lrTElri47/fPdZ5Oc6G25HhMcUS9VXa9PghGBRkoDRH5KvK6Q1AvtGKgQlCJ7Qm2VTT 0d0qQp2HosO8zJlMc7Q5vtHX3DCLa9E74w6CEDuFhhsjuqCgKGVLe26zbjegfYsZ/h+E QZWYy0ruKLePJdETrs1LGWBpxv2k0V/h1xjFrxfs1jhwErkVHub8qndy+C6l0lRnD8Zk Lzbg== X-Gm-Message-State: AOUpUlHfrXkPCp19CVVxFA7bNd/iK3wfXrQtmjwY27Mzw+sR4xDqQxzT MB/yNSJv5LQDewTyeSOeE2S06A== X-Received: by 2002:a19:2043:: with SMTP id g64-v6mr5715338lfg.66.1532381209412; Mon, 23 Jul 2018 14:26:49 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id q4-v6sm1990435ljh.36.2018.07.23.14.26.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jul 2018 14:26:48 -0700 (PDT) From: Ivan Khoronzhuk To: davem@davemloft.net, grygorii.strashko@ti.com 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 v5 net-next 1/6] net: ethernet: ti: cpsw: use cpdma channels in backward order for txq Date: Tue, 24 Jul 2018 00:26:29 +0300 Message-Id: <20180723212634.3219-2-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180723212634.3219-1-ivan.khoronzhuk@linaro.org> References: <20180723212634.3219-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. Reviewed-by: Ilias Apalodimas Reviewed-by: Grygorii Strashko 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 00761fe59848..4425b537b9dd 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -968,8 +968,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]; @@ -2432,7 +2432,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; @@ -2445,7 +2445,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; @@ -2982,7 +2983,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); @@ -3157,7 +3158,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