From patchwork Wed Jun 5 13:20:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165886 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7340055ili; Wed, 5 Jun 2019 06:20:45 -0700 (PDT) X-Google-Smtp-Source: APXvYqxokQlw77dWHCBsxXtpnY+qg4HwiDsEQeo3Ur/FTkJks8YBLO3xn5S0VPLZWH765MP0Tbtj X-Received: by 2002:a65:41c6:: with SMTP id b6mr4242947pgq.399.1559740845326; Wed, 05 Jun 2019 06:20:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559740845; cv=none; d=google.com; s=arc-20160816; b=UWELPE1Pq7tKbcJQbBKQbu5zgUC8iywgFhR6vfTczxlqCnSmfOBrLJ9pNQ1K5EkcFz XrDq94I32gULXsZtS/nKc7KJi6+bmXPKOMp83BioV3np83q+c7fEFTks9JrB/BLssRYG 1y8nMQy4Ijjj3IFxtkf/RerbUIj0TZ/ARcF3Ihbfh18izO4rzTK1Wf/vlFXogC3BwCE3 vi7Uzfc1V1AbpaV3ptp4+S4VNBLOM9/e/oIQlpynq96GYqyeQNqTyLYG0G6Ubf69bQmy QwvmoPf74+nYfpUXhPtA3bwEnYnUInVK6OwOVXqMpLYrgtBjUTCLGr/ZOCdSRCLAzHRX N1pA== 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; bh=AdSMTsu+LtgUCnPNRXGwSYsCPQyqbNfQqw5/RcvDJNQ=; b=SU0wv5oLJadiM6zfhurSHyA3I/VCsTraiCknOukVsKAE8y1QQqezHSKk5eVjw+HXV3 WDrvFx24oruzNKPwVpEPTlmiv102i+31Ecq3a2vds5WsbYSfVTYZQaY8K+VCYVJs+e+M w5qzhAEUWEFGWpU28ZsZ0ct69scO3LNotgviqERsbPa7JNmMgZ2aDwyXDoSH+/X8Qy5I zhOyOHQyjgYwacSQBpihKbkWYQveRPMye2LN3s11uJLWAUz3InlGVFt2pXs+T1oPZ+H4 Avi7qACyVTzp0X57vU4vOaAkqJyPFegycOHQEKsc3k0fnuHoUqqbiK9TTdJMCHFl7rKO nVyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=mRYi4qcN; 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 b10si3733551pjw.6.2019.06.05.06.20.44; Wed, 05 Jun 2019 06:20:45 -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=mRYi4qcN; 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 S1728066AbfFENUW (ORCPT + 30 others); Wed, 5 Jun 2019 09:20:22 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34201 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727941AbfFENUQ (ORCPT ); Wed, 5 Jun 2019 09:20:16 -0400 Received: by mail-lj1-f196.google.com with SMTP id j24so23136109ljg.1 for ; Wed, 05 Jun 2019 06:20:15 -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=AdSMTsu+LtgUCnPNRXGwSYsCPQyqbNfQqw5/RcvDJNQ=; b=mRYi4qcNVbZ//c6G57A5oDbp2t2NbASCzTsCDdchf6yJyjEu+CCRyMzKu+9CKFoid3 ZwHgGIiAW5HvrqKBJ1X5jiXV8j+0CWCui9NP5egRT36VcapZyU/vhp6SCCBuya6WqE09 EJI5NV/HOBQBQfIBMKnZYUXlDbPa5bHZf929T1qOP8lEPB6+5X4JX3FTK/mOgRyEjxPo NR9mpIYi6oFT+jPz7XZ9EZc54Uv5lBo2CILwvY4E+3997zzLyyuwJiHIM/f3AzUS5BuF Ott0Mezc+lVW/EK674CogiBpGozPsRXV/dA4sdWr0gp2tJ/mtnknDAgMwxIU0+VWMBe/ l5IA== 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=AdSMTsu+LtgUCnPNRXGwSYsCPQyqbNfQqw5/RcvDJNQ=; b=Wum1//M5Mz8iLby5nusqAVvot0E2UPsI8kAMETeVaz+PsRhXrpZ8r81Gh6q5lFb9GQ YQoqL2z/6hzY4SYTtqR751TiG0oJ2hj3c5gnJw4TmSIJDTpDLZtzr36s0KvW3xbYJGFi vBON2+cVHgfsMk+kZKmHN894V2iFL9oKOSGMM+7Zd+Fz6UVFFaAdPKK7hWaEpcnF7oRu DmmvrWgObMDbbAtFzvXxUA9Ay5KVdNvwGtMS8BIu2F9I/1FxkPJZEzaking7xjdKDrYj rXd6j1xY0mvb8TUICXf9rmVPYW3mY3J23Wu/c7pOqDSujDnPDukeG8ct4GGpaF/rap5R seew== X-Gm-Message-State: APjAAAUnOPa7k2Thh0dyd0KA+RzPSLw6vyZSIs3ET3ESwuqvOefJzNIs H5XJp86LSbGnatvq67S8OMgWPA== X-Received: by 2002:a2e:9c03:: with SMTP id s3mr6004919lji.209.1559740814483; Wed, 05 Jun 2019 06:20:14 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id t3sm1893259lfk.59.2019.06.05.06.20.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 06:20:13 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net Cc: ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com, Jesper Dangaard Brouer , Ivan Khoronzhuk Subject: [PATCH v3 net-next 1/7] net: page_pool: add helper function to retrieve dma addresses Date: Wed, 5 Jun 2019 16:20:03 +0300 Message-Id: <20190605132009.10734-2-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605132009.10734-1-ivan.khoronzhuk@linaro.org> References: <20190605132009.10734-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilias Apalodimas On a previous patch dma addr was stored in 'struct page'. Use that to retrieve DMA addresses used by network drivers Signed-off-by: Ilias Apalodimas Signed-off-by: Jesper Dangaard Brouer Signed-off-by: Ivan Khoronzhuk --- include/net/page_pool.h | 5 +++++ 1 file changed, 5 insertions(+) -- 2.17.1 diff --git a/include/net/page_pool.h b/include/net/page_pool.h index 694d055e01ef..b885d86cb7a1 100644 --- a/include/net/page_pool.h +++ b/include/net/page_pool.h @@ -132,6 +132,11 @@ static inline void page_pool_recycle_direct(struct page_pool *pool, __page_pool_put_page(pool, page, true); } +static inline dma_addr_t page_pool_get_dma_addr(struct page *page) +{ + return page->dma_addr; +} + static inline bool is_page_pool_compiled_in(void) { #ifdef CONFIG_PAGE_POOL From patchwork Wed Jun 5 13:20:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165882 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7339621ili; Wed, 5 Jun 2019 06:20:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqz0KrDXxYr7zG0K8KHO6Bl5lnTZuCgV+mDXhCC3OtOjTgPwDTLRv16+t6GzF30ATLzH8dz+ X-Received: by 2002:a63:81c2:: with SMTP id t185mr4455745pgd.257.1559740825110; Wed, 05 Jun 2019 06:20:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559740825; cv=none; d=google.com; s=arc-20160816; b=JYCBGBrCJYsn/3pQ09oFfUXW385QJKS8FKCCzsDhU/GLwKROTM35cEW+0/SDo1LJXo K6g7g7x5K3Rfa3GTmxA24pZ5aPzn/J4NpYEThguj+Mk2BuSQX4KDI01Y0jnfwKi5jNJE uuazGgX57Hfe0eF10IPLf93T8bveMUoJKlK87GBsBeSMJMTeZ6agWOvsKE5z6qQ4ymUj S6KIKMzO2Ii/5rM7LOf+1lHxBJeuncTu2Gvc2b5mafVTnlrxad1cBgT1a8VGf5Zu48oG tZt+E5d66r7NECZGt5DkAocMAuOMRGWB6cFJONcbgAiW9D+pjRo5GYKYxikh0IqNAYZq ULUQ== 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; bh=CE8Iq8ZjUtNENgYj+FlGTMxcTQ2fFaeeS723D5LJTaU=; b=v2rtw3+vrw6cSqZ0b1Bt0/e/ZYHEo7qXJF7Y2qbDcNmU7OJ2L5qyc045f+3G0QpoP5 0fa1hiEgv2m3FLAbPkNUO8kCjPztqzTCoKx2+iRoxRU1DmgYpzlfTRw0QtuVI1SzPHKC hzOnNIze0xJQj9fAiozHKo17DnqgFra2ygG+hdJJ08gRxoTL+LfGXpjEUwlyDTyq1+Dc UWrgKCKg4skkAUp1EDxMMMhx7CvD0fC+n9DofOVcnyYM/yVRqgJy5DJ2pjiyEpAfmXG2 S5ZsOgtEExwf79x5rk0jxRmOFWUo+1eMZpsssxDJo5xw5xFwTOy5JQykoZWS+EobmH68 6b0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Ie/iVmmm"; 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 j17si30459504pfn.226.2019.06.05.06.20.24; Wed, 05 Jun 2019 06:20:25 -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="Ie/iVmmm"; 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 S1728076AbfFENUY (ORCPT + 30 others); Wed, 5 Jun 2019 09:20:24 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45368 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727642AbfFENUT (ORCPT ); Wed, 5 Jun 2019 09:20:19 -0400 Received: by mail-lf1-f66.google.com with SMTP id u10so12023423lfm.12 for ; Wed, 05 Jun 2019 06:20:17 -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=CE8Iq8ZjUtNENgYj+FlGTMxcTQ2fFaeeS723D5LJTaU=; b=Ie/iVmmmXC6K55Uaa53Di3vSnNQfwFe1FvKFIdOAI2En/YaClJm3K8u2Hw01cBFi/b RytUn8xjSlb/3NQuDuoxQom0+Udw7r6FvZd18bSt7iyupgyOrRmKC+OMKowrKmAGRB63 uBq2urzv3cyOApD2MKU65Q1u0P8ojAkvxcHiVqF/hBHGcihIQS4HMpqgWyZSZqd0nOo5 8kESN0+fpHn6UddiWD8pg+cXV42hX8sHqS3r43SktDUC27osbBWxOGhPGHrNTC6FexB1 pTr+tpVaOvaF68MfWcPNdljRzLk3X3EQymwMI5uA6DpySSsr+jKQRPsgpStETVz2sPXM w7nQ== 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=CE8Iq8ZjUtNENgYj+FlGTMxcTQ2fFaeeS723D5LJTaU=; b=F9Kc1hvNjAkt7rE1zBe7I3bmsJK/ld1BEjrTfKO1hmWOWzk7CRCMps/kClN1AFRJfd sviSwAxHQ50yXOAROh9E2cF6pLq7T5cX6yYPNO8jngVtCKbNVuhfahPPOWQH+5qtNYqt hXsQn1rHTYTs4FXFRdvVm3WD3li6oU7mG4jH/H0lRI1e3j1lqk8d988nvlHt0TwJrcKF YEbf4NuYnEnp3o7tLbu6UY39Xxmh9jHs2VqJz2pITxI3OITebEJy7BPISSrQ1GSqUeV6 7ber9PYQ83Z8NmKqJnzDFWVg3NoTEExj/yy0852gwW5sCrqJJiGV6+CYR035iuDoYnS4 8R+A== X-Gm-Message-State: APjAAAVfwgofA6TqFHorD7/ou3B7tIlT02PTQydm7UbVKX0XtvRg/UQA HMAlCsU8yZYnuOHZudrn1Jhuow== X-Received: by 2002:a19:7110:: with SMTP id m16mr20414541lfc.4.1559740817213; Wed, 05 Jun 2019 06:20:17 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id t3sm1893259lfk.59.2019.06.05.06.20.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 06:20:16 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net Cc: ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com, Ivan Khoronzhuk Subject: [PATCH v3 net-next 3/7] net: ethernet: ti: cpsw: use cpsw as drv data Date: Wed, 5 Jun 2019 16:20:05 +0300 Message-Id: <20190605132009.10734-4-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605132009.10734-1-ivan.khoronzhuk@linaro.org> References: <20190605132009.10734-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No need to set ndev for drvdata when mainly cpsw reference is needed, so correct this legacy decision. Reviewed-by: Grygorii Strashko Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 6d3f1f3f90cb..3430503e1053 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -2265,8 +2265,7 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, static void cpsw_remove_dt(struct platform_device *pdev) { - struct net_device *ndev = platform_get_drvdata(pdev); - struct cpsw_common *cpsw = ndev_to_cpsw(ndev); + struct cpsw_common *cpsw = platform_get_drvdata(pdev); struct cpsw_platform_data *data = &cpsw->data; struct device_node *node = pdev->dev.of_node; struct device_node *slave_node; @@ -2477,7 +2476,7 @@ static int cpsw_probe(struct platform_device *pdev) goto clean_cpts; } - platform_set_drvdata(pdev, ndev); + platform_set_drvdata(pdev, cpsw); priv = netdev_priv(ndev); priv->cpsw = cpsw; priv->ndev = ndev; @@ -2570,9 +2569,8 @@ static int cpsw_probe(struct platform_device *pdev) static int cpsw_remove(struct platform_device *pdev) { - struct net_device *ndev = platform_get_drvdata(pdev); - struct cpsw_common *cpsw = ndev_to_cpsw(ndev); - int ret; + struct cpsw_common *cpsw = platform_get_drvdata(pdev); + int i, ret; ret = pm_runtime_get_sync(&pdev->dev); if (ret < 0) { @@ -2580,9 +2578,9 @@ static int cpsw_remove(struct platform_device *pdev) return ret; } - if (cpsw->data.dual_emac) - unregister_netdev(cpsw->slaves[1].ndev); - unregister_netdev(ndev); + for (i = 0; i < cpsw->data.slaves; i++) + if (cpsw->slaves[i].ndev) + unregister_netdev(cpsw->slaves[i].ndev); cpts_release(cpsw->cpts); cpdma_ctlr_destroy(cpsw->dma); From patchwork Wed Jun 5 13:20:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165887 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7340204ili; Wed, 5 Jun 2019 06:20:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqwIA/W5OiHADZLD3F1ieIA7+hZZgATDKtYtt3ygmx5ZVV707cbo0V3rgPEjsGZITi8oOYcP X-Received: by 2002:a65:620a:: with SMTP id d10mr4405167pgv.42.1559740852141; Wed, 05 Jun 2019 06:20:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559740852; cv=none; d=google.com; s=arc-20160816; b=Q3nGnaLDO9PZlgc/GduQ6oUjjud+5pQgf1pvHscCon8WOozLXe/uuYm3CRV40Cr8Ys j1VaDH1hmGt4uTsz62m3Joc8BGKv9jHNfn6J5sgAQLHnCHkEYttdAu07uUl3itqJ/ole pAHPNlJxAg19+at54QpoNdK2XakrDaflmkyNpvGhsQrzTxIkFl081RzWiucFstNtw0kk blnA8UsXYvTnEzPrwnICOBX2/OkW8yjJWx61Sz+2cGEfh/Q7zRf3FDzJtr2yJHhof0Ay eg6B0tmbDkgjpjK3LmP8M+57zUbKhiw+QmVCTc0vl0PfgodDm4Xupt7UT5TLR2twTMUP XovA== 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; bh=mszTEyuZf7y7lIdYQewtMvW8UUIaYv1rPkX1Aw39++8=; b=BgpyCldJgRpaSbVxcRhGkasB5Sk34RNhHbzIrh6s964U+zS3Ziov7GiwgyOXXYdDsb ufuUPtnTQz3VURTYceERF9khy/0kWhtuPVlvf9snjDXXDtSuIl2JBp5J+UIu70QnOq0t 8hXqJe5Ho4erVv10KYAgQCJ/MeE0EuFXKwJC4JBGlPDUTGcQTHlGarPY9Ehtwfq94EJ5 ApNPyUns/arTTqWzHC79t/vPzskOKp9YQ/m4G8qz/kBMZ4Vwp8vQ2AyRAuPZbxk/ws/W YKQEYZSy4AWoq/7hdxSCvNp0exNJa6b0Q9tQ30mH2Xx56TOmoFPRb0tiCruDnF00knV/ 25Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GeKKL4uF; 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 be3si26235442plb.127.2019.06.05.06.20.51; Wed, 05 Jun 2019 06:20:52 -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=GeKKL4uF; 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 S1728151AbfFENUu (ORCPT + 30 others); Wed, 5 Jun 2019 09:20:50 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:40595 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728044AbfFENUU (ORCPT ); Wed, 5 Jun 2019 09:20:20 -0400 Received: by mail-lj1-f196.google.com with SMTP id a21so7890715ljh.7 for ; Wed, 05 Jun 2019 06:20:19 -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=mszTEyuZf7y7lIdYQewtMvW8UUIaYv1rPkX1Aw39++8=; b=GeKKL4uFsj2/YpNSdGplVaT5cKsjpFQjUhD224JDjupcB6mr9U156zGjxPD4bGUmXl xB/PoUc1l920zPS+AnJJUOr9ASZFlrKJHyoVjNuSmdT8879k0qfJ9qMZZ+CxTKOYYbT2 DnBUQOhmdPXG6+ez1tunwdiZq5pICCDQjgjAeY2LzFhMwHW0ju/L4HO+RevJrWXifqBT Ox86+S/xgtHpy1qZNnStIiHq6Qm62g9w1K+rkaHKFRD/YXdbTQ1HpPL8lrj6ndFR3YVL dKcg7pP5myPZNZJlqjzpJQMtIGf/p0I/ZTCU0XPBvt2oIGCUCqu0hAR/kU1GDuzk7Rla 1sxQ== 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=mszTEyuZf7y7lIdYQewtMvW8UUIaYv1rPkX1Aw39++8=; b=gnjH4g9ewO+hh2LQJeKsrTreTM99HieTBT67/p3ryDKEprzs2ptbseV3qDHiYzBrvP 64cBFHHmNk1rXYcxu+P2EAIe6jPNzH8KZY+53PYdg2NoN+7pa3VsNeYruG1+rmjc63IJ +Zi5J+Ug4cyTVBG4VB7B393yU18kd/5o80z+NiHrD+FX8gdkSGifC9kMPEO2r6aQuLXs Dv1HHyJh3sJBKAYok1Iyw40IFSs1RPfAIyfBI6B1CstnJ7T12OaZfR9Z1Pgi5hKY7uTN +pNII34wpUg/DchW+buzPrtW3wEbHwpb8mBXLyOoxuhUrI2FHtTgPlHQwgAyjzSb5HCM Jqew== X-Gm-Message-State: APjAAAWOn5fsBEvaPN/4tdIgtDYXZH+7N6E58cxGCUDMpK7X8NTEjwUc r660LbVFaphkJx3CzXLlVnxAvw== X-Received: by 2002:a2e:7216:: with SMTP id n22mr6617872ljc.42.1559740818396; Wed, 05 Jun 2019 06:20:18 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id t3sm1893259lfk.59.2019.06.05.06.20.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 06:20:17 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net Cc: ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com, Ivan Khoronzhuk Subject: [PATCH v3 net-next 4/7] net: ethernet: ti: cpsw_ethtool: simplify slave loops Date: Wed, 5 Jun 2019 16:20:06 +0300 Message-Id: <20190605132009.10734-5-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605132009.10734-1-ivan.khoronzhuk@linaro.org> References: <20190605132009.10734-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Only for consistency reasons, do it like in main cpsw.c module and use ndev reference but not by means of slave. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw_ethtool.c | 40 ++++++++++++++------------ 1 file changed, 21 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c index a4a7ec0d2531..3d5ae3fa5a8f 100644 --- a/drivers/net/ethernet/ti/cpsw_ethtool.c +++ b/drivers/net/ethernet/ti/cpsw_ethtool.c @@ -458,7 +458,6 @@ int cpsw_nway_reset(struct net_device *ndev) static void cpsw_suspend_data_pass(struct net_device *ndev) { struct cpsw_common *cpsw = ndev_to_cpsw(ndev); - struct cpsw_slave *slave; int i; /* Disable NAPI scheduling */ @@ -467,12 +466,13 @@ static void cpsw_suspend_data_pass(struct net_device *ndev) /* Stop all transmit queues for every network device. * Disable re-using rx descriptors with dormant_on. */ - for (i = cpsw->data.slaves, slave = cpsw->slaves; i; i--, slave++) { - if (!(slave->ndev && netif_running(slave->ndev))) + for (i = 0; i < cpsw->data.slaves; i++) { + ndev = cpsw->slaves[i].ndev; + if (!(ndev && netif_running(ndev))) continue; - netif_tx_stop_all_queues(slave->ndev); - netif_dormant_on(slave->ndev); + netif_tx_stop_all_queues(ndev); + netif_dormant_on(ndev); } /* Handle rest of tx packets and stop cpdma channels */ @@ -483,13 +483,14 @@ static int cpsw_resume_data_pass(struct net_device *ndev) { struct cpsw_priv *priv = netdev_priv(ndev); struct cpsw_common *cpsw = priv->cpsw; - struct cpsw_slave *slave; int i, ret; /* Allow rx packets handling */ - for (i = cpsw->data.slaves, slave = cpsw->slaves; i; i--, slave++) - if (slave->ndev && netif_running(slave->ndev)) - netif_dormant_off(slave->ndev); + for (i = 0; i < cpsw->data.slaves; i++) { + ndev = cpsw->slaves[i].ndev; + if (ndev && netif_running(ndev)) + netif_dormant_off(ndev); + } /* After this receive is started */ if (cpsw->usage_count) { @@ -502,9 +503,11 @@ static int cpsw_resume_data_pass(struct net_device *ndev) } /* Resume transmit for every affected interface */ - for (i = cpsw->data.slaves, slave = cpsw->slaves; i; i--, slave++) - if (slave->ndev && netif_running(slave->ndev)) - netif_tx_start_all_queues(slave->ndev); + for (i = 0; i < cpsw->data.slaves; i++) { + ndev = cpsw->slaves[i].ndev; + if (ndev && netif_running(ndev)) + netif_tx_start_all_queues(ndev); + } return 0; } @@ -587,7 +590,7 @@ int cpsw_set_channels_common(struct net_device *ndev, { struct cpsw_priv *priv = netdev_priv(ndev); struct cpsw_common *cpsw = priv->cpsw; - struct cpsw_slave *slave; + struct net_device *sl_ndev; int i, ret; ret = cpsw_check_ch_settings(cpsw, chs); @@ -604,20 +607,19 @@ int cpsw_set_channels_common(struct net_device *ndev, if (ret) goto err; - for (i = cpsw->data.slaves, slave = cpsw->slaves; i; i--, slave++) { - if (!(slave->ndev && netif_running(slave->ndev))) + for (i = 0; i < cpsw->data.slaves; i++) { + sl_ndev = cpsw->slaves[i].ndev; + if (!(sl_ndev && netif_running(sl_ndev))) continue; /* Inform stack about new count of queues */ - ret = netif_set_real_num_tx_queues(slave->ndev, - cpsw->tx_ch_num); + ret = netif_set_real_num_tx_queues(sl_ndev, cpsw->tx_ch_num); if (ret) { dev_err(priv->dev, "cannot set real number of tx queues\n"); goto err; } - ret = netif_set_real_num_rx_queues(slave->ndev, - cpsw->rx_ch_num); + ret = netif_set_real_num_rx_queues(sl_ndev, cpsw->rx_ch_num); if (ret) { dev_err(priv->dev, "cannot set real number of rx queues\n"); goto err; From patchwork Wed Jun 5 13:20:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165885 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp7339881ili; Wed, 5 Jun 2019 06:20:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqzNX1dM2VdXGcmEOizfFXmNSlMtyrCSU/HDgXaI+/Tp1HlPace7ceAGkBVjDO5K/OWrXTWH X-Received: by 2002:a17:902:9041:: with SMTP id w1mr29677376plz.132.1559740836048; Wed, 05 Jun 2019 06:20:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559740836; cv=none; d=google.com; s=arc-20160816; b=PuBM+FyuhdgL6P1vIoJGPfqvF5SyfNSfghVmrqDkkPZvC406oBRG4N8wJd1r940MZ6 E1+SbrFxxR/CeZ9Ri2TF+PfgvcPcXry1flKf+lYVs3KAOEZJKZakvQvc3LCEgmgNqEKl +mvrMrmtijZXvriL2WC8l4ANPtgU0xkaoH/6mSaSE8DAbvnjstVzI5G417eE+kGJXT2w gc+gDhkXWPOzWU/GTIE8SJk48c1nRBUiHHkCfgcTfpBYTzDuqQMJelrosA2J4fHubOQW 1xM/SUfEGDD3Q7UYa4DRGWwKge0Pi5RRW2+hVHz9lwuYq2S+RT/5Fmw9PZUJXRS3Tmgz kuEQ== 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; bh=VHuNQ1++LWysFMf3aILQufzbZgwyC+0uuSHbvmrF61E=; b=CNcoVi2TpSrSvo6rEt0TQgwM2DWpZC0paeK/YCXPOhwsTG4rErZjftC4KJBKbchNeY EU4+83oXqLSjZ34NPCsVIPzpawcij/rBhfRgBa46fsrcOlMIDfu9w6mCGWL4l9bam9az WPtqJ4D/KvfzoU/IUoBDeg/DEUCz+CiHdok0ScYA7uPs8nQDWn2unV/Qdu3lQAmsp+wm 6etYKpuJiEbBIiIM4tvZhdT5uzg5fyLCBivfSnGOczRIu6ENCSqThVHl1CxlchUAO9dn 1X6T2i/6sDXDod6hJMy9ziaB9yuBzBRWHssumHTMQRYHbj0ZsNBKTrX9o5Put+Bj71Pu NnNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vCpeBGeE; 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 14si30156875pfu.76.2019.06.05.06.20.35; Wed, 05 Jun 2019 06:20:36 -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=vCpeBGeE; 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 S1728122AbfFENUe (ORCPT + 30 others); Wed, 5 Jun 2019 09:20:34 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:35464 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728060AbfFENUX (ORCPT ); Wed, 5 Jun 2019 09:20:23 -0400 Received: by mail-lf1-f66.google.com with SMTP id a25so19078869lfg.2 for ; Wed, 05 Jun 2019 06:20:21 -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=VHuNQ1++LWysFMf3aILQufzbZgwyC+0uuSHbvmrF61E=; b=vCpeBGeEkRctKU9ZdjqmLqgeTn1q8TfQfx17gP6KP/v4irpBlkPlTAcTtP2WgKU8eT 1GjAOrrk4NiJZidwYEDIaB0amFJ6EypRPEwY9fVfSlV7VnILxHt+catB5mgCaONQSPI/ ZVkw/2yXruqRxuVQeajoMIjeWMQTuRnOpA6nduvuXSMSZWoUqwfvJ76MJ1ljm0WJ3uBI /JLIKJEKhjglvQdWjlVvqOQqwZTAH4lDYUNYpm16TrieliuIuIzdxfWKLbqg4uh8U9aO 2DHUoQag/9C6vDVObhI/2sgcjMOLBOnubbKXltrKxzj5zOHIxy/ibLyU7FoahHT8P+MR Pl+A== 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=VHuNQ1++LWysFMf3aILQufzbZgwyC+0uuSHbvmrF61E=; b=HStIhD0+AEgQ/5/Te58JBUWSYY2hsJOLEL2vjdMAp/k5woQoB7qD/nX2lhekYYwiUY 03zNAaHTJvhRE8bYg/2i4wN+ZWGFyKxpRF9YisijxhIlBbZNjoMKATtT82MBzNm7T0OR QhVZMlDKnwaq1TCjTZeDrPZTPD1Uo28u7DkKDFoP1gsW+qXlyAwa1LGmSv+c+uTRf2Ho IJT8E+08n/ubj4/SlmyUNcnIW8GXr5q7l3ydl/QulcgT643SQCnJX9jzlkXcdEwA52dg laJkz/w7ZYGpJmH44FJuXokpe8uwetmRxMyDFdaprZQ3dz6oMfLvUWB6kOIHoZGg6Bej fOpw== X-Gm-Message-State: APjAAAULLGu4dt7nGuREU5Law1TIGQYBu0hNU26IQSdOLouBLBvWNLRQ J0vbqMQ4Kz6fAaNMq4YE9cWarg== X-Received: by 2002:a19:2981:: with SMTP id p123mr19756368lfp.190.1559740820942; Wed, 05 Jun 2019 06:20:20 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id t3sm1893259lfk.59.2019.06.05.06.20.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 06:20:20 -0700 (PDT) From: Ivan Khoronzhuk To: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net Cc: ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com, Ivan Khoronzhuk Subject: [PATCH v3 net-next 6/7] net: ethernet: ti: davinci_cpdma: return handler status Date: Wed, 5 Jun 2019 16:20:08 +0300 Message-Id: <20190605132009.10734-7-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190605132009.10734-1-ivan.khoronzhuk@linaro.org> References: <20190605132009.10734-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change is needed to return flush status of rx handler for flushing redirected xdp frames after processing channel packets. Do it as separate patch for simplicity. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/cpsw.c | 23 +++++++++++------ drivers/net/ethernet/ti/cpsw_ethtool.c | 2 +- drivers/net/ethernet/ti/cpsw_priv.h | 2 +- drivers/net/ethernet/ti/davinci_cpdma.c | 34 +++++++++++++++---------- drivers/net/ethernet/ti/davinci_cpdma.h | 4 +-- drivers/net/ethernet/ti/davinci_emac.c | 18 ++++++++----- 6 files changed, 50 insertions(+), 33 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 3430503e1053..d89ad428315c 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -337,7 +337,7 @@ void cpsw_intr_disable(struct cpsw_common *cpsw) return; } -void cpsw_tx_handler(void *token, int len, int status) +int cpsw_tx_handler(void *token, int len, int status) { struct netdev_queue *txq; struct sk_buff *skb = token; @@ -355,6 +355,7 @@ void cpsw_tx_handler(void *token, int len, int status) ndev->stats.tx_packets++; ndev->stats.tx_bytes += len; dev_kfree_skb_any(skb); + return 0; } static void cpsw_rx_vlan_encap(struct sk_buff *skb) @@ -400,7 +401,7 @@ static void cpsw_rx_vlan_encap(struct sk_buff *skb) } } -static void cpsw_rx_handler(void *token, int len, int status) +static int cpsw_rx_handler(void *token, int len, int status) { struct cpdma_chan *ch; struct sk_buff *skb = token; @@ -434,7 +435,7 @@ static void cpsw_rx_handler(void *token, int len, int status) /* the interface is going down, skbs are purged */ dev_kfree_skb_any(skb); - return; + return 0; } new_skb = netdev_alloc_skb_ip_align(ndev, cpsw->rx_packet_max); @@ -459,7 +460,7 @@ static void cpsw_rx_handler(void *token, int len, int status) requeue: if (netif_dormant(ndev)) { dev_kfree_skb_any(new_skb); - return; + return 0; } ch = cpsw->rxv[skb_get_queue_mapping(new_skb)].ch; @@ -467,6 +468,8 @@ static void cpsw_rx_handler(void *token, int len, int status) skb_tailroom(new_skb), 0); if (WARN_ON(ret < 0)) dev_kfree_skb_any(new_skb); + + return 0; } void cpsw_split_res(struct cpsw_common *cpsw) @@ -605,7 +608,8 @@ static int cpsw_tx_mq_poll(struct napi_struct *napi_tx, int budget) else cur_budget = txv->budget; - num_tx += cpdma_chan_process(txv->ch, cur_budget); + cpdma_chan_process(txv->ch, &cur_budget); + num_tx += cur_budget; if (num_tx >= budget) break; } @@ -623,7 +627,8 @@ static int cpsw_tx_poll(struct napi_struct *napi_tx, int budget) struct cpsw_common *cpsw = napi_to_cpsw(napi_tx); int num_tx; - num_tx = cpdma_chan_process(cpsw->txv[0].ch, budget); + num_tx = budget; + cpdma_chan_process(cpsw->txv[0].ch, &num_tx); if (num_tx < budget) { napi_complete(napi_tx); writel(0xff, &cpsw->wr_regs->tx_en); @@ -655,7 +660,8 @@ static int cpsw_rx_mq_poll(struct napi_struct *napi_rx, int budget) else cur_budget = rxv->budget; - num_rx += cpdma_chan_process(rxv->ch, cur_budget); + cpdma_chan_process(rxv->ch, &cur_budget); + num_rx += cur_budget; if (num_rx >= budget) break; } @@ -673,7 +679,8 @@ static int cpsw_rx_poll(struct napi_struct *napi_rx, int budget) struct cpsw_common *cpsw = napi_to_cpsw(napi_rx); int num_rx; - num_rx = cpdma_chan_process(cpsw->rxv[0].ch, budget); + num_rx = budget; + cpdma_chan_process(cpsw->rxv[0].ch, &num_rx); if (num_rx < budget) { napi_complete_done(napi_rx, num_rx); writel(0xff, &cpsw->wr_regs->rx_en); diff --git a/drivers/net/ethernet/ti/cpsw_ethtool.c b/drivers/net/ethernet/ti/cpsw_ethtool.c index 3d5ae3fa5a8f..94f8f5ab46a5 100644 --- a/drivers/net/ethernet/ti/cpsw_ethtool.c +++ b/drivers/net/ethernet/ti/cpsw_ethtool.c @@ -538,8 +538,8 @@ static int cpsw_update_channels_res(struct cpsw_priv *priv, int ch_num, int rx, cpdma_handler_fn rx_handler) { struct cpsw_common *cpsw = priv->cpsw; - void (*handler)(void *, int, int); struct netdev_queue *queue; + cpdma_handler_fn handler; struct cpsw_vector *vec; int ret, *ch, vch; diff --git a/drivers/net/ethernet/ti/cpsw_priv.h b/drivers/net/ethernet/ti/cpsw_priv.h index 04795b97ee71..2ecb3af59fe9 100644 --- a/drivers/net/ethernet/ti/cpsw_priv.h +++ b/drivers/net/ethernet/ti/cpsw_priv.h @@ -390,7 +390,7 @@ void cpsw_split_res(struct cpsw_common *cpsw); int cpsw_fill_rx_channels(struct cpsw_priv *priv); void cpsw_intr_enable(struct cpsw_common *cpsw); void cpsw_intr_disable(struct cpsw_common *cpsw); -void cpsw_tx_handler(void *token, int len, int status); +int cpsw_tx_handler(void *token, int len, int status); /* ethtool */ u32 cpsw_get_msglevel(struct net_device *ndev); diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 7f89b2299f05..a59011d315d5 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -1137,15 +1137,16 @@ bool cpdma_check_free_tx_desc(struct cpdma_chan *chan) return free_tx_desc; } -static void __cpdma_chan_free(struct cpdma_chan *chan, - struct cpdma_desc __iomem *desc, - int outlen, int status) +static int __cpdma_chan_free(struct cpdma_chan *chan, + struct cpdma_desc __iomem *desc, int outlen, + int status) { struct cpdma_ctlr *ctlr = chan->ctlr; struct cpdma_desc_pool *pool = ctlr->pool; dma_addr_t buff_dma; int origlen; uintptr_t token; + int ret; token = desc_read(desc, sw_token); origlen = desc_read(desc, sw_len); @@ -1160,14 +1161,16 @@ static void __cpdma_chan_free(struct cpdma_chan *chan, } cpdma_desc_free(pool, desc, 1); - (*chan->handler)((void *)token, outlen, status); + ret = (*chan->handler)((void *)token, outlen, status); + + return ret; } static int __cpdma_chan_process(struct cpdma_chan *chan) { + int status, outlen, ret; struct cpdma_ctlr *ctlr = chan->ctlr; struct cpdma_desc __iomem *desc; - int status, outlen; int cb_status = 0; struct cpdma_desc_pool *pool = ctlr->pool; dma_addr_t desc_dma; @@ -1178,7 +1181,7 @@ static int __cpdma_chan_process(struct cpdma_chan *chan) desc = chan->head; if (!desc) { chan->stats.empty_dequeue++; - status = -ENOENT; + ret = -ENOENT; goto unlock_ret; } desc_dma = desc_phys(pool, desc); @@ -1187,7 +1190,7 @@ static int __cpdma_chan_process(struct cpdma_chan *chan) outlen = status & 0x7ff; if (status & CPDMA_DESC_OWNER) { chan->stats.busy_dequeue++; - status = -EBUSY; + ret = -EBUSY; goto unlock_ret; } @@ -1213,28 +1216,31 @@ static int __cpdma_chan_process(struct cpdma_chan *chan) else cb_status = status; - __cpdma_chan_free(chan, desc, outlen, cb_status); - return status; + ret = __cpdma_chan_free(chan, desc, outlen, cb_status); + return ret; unlock_ret: spin_unlock_irqrestore(&chan->lock, flags); - return status; + return ret; } -int cpdma_chan_process(struct cpdma_chan *chan, int quota) +int cpdma_chan_process(struct cpdma_chan *chan, int *quota) { - int used = 0, ret = 0; + int used = 0, ret = 0, res = 0; if (chan->state != CPDMA_STATE_ACTIVE) return -EINVAL; - while (used < quota) { + while (used < *quota) { ret = __cpdma_chan_process(chan); if (ret < 0) break; + res |= ret; used++; } - return used; + + *quota = used; + return res; } int cpdma_chan_start(struct cpdma_chan *chan) diff --git a/drivers/net/ethernet/ti/davinci_cpdma.h b/drivers/net/ethernet/ti/davinci_cpdma.h index 8f6f27185c63..56543d375923 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.h +++ b/drivers/net/ethernet/ti/davinci_cpdma.h @@ -61,7 +61,7 @@ struct cpdma_chan_stats { struct cpdma_ctlr; struct cpdma_chan; -typedef void (*cpdma_handler_fn)(void *token, int len, int status); +typedef int (*cpdma_handler_fn)(void *token, int len, int status); struct cpdma_ctlr *cpdma_ctlr_create(struct cpdma_params *params); int cpdma_ctlr_destroy(struct cpdma_ctlr *ctlr); @@ -81,7 +81,7 @@ int cpdma_chan_submit_mapped(struct cpdma_chan *chan, void *token, dma_addr_t data, int len, int directed); int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data, int len, int directed); -int cpdma_chan_process(struct cpdma_chan *chan, int quota); +int cpdma_chan_process(struct cpdma_chan *chan, int *quota); int cpdma_ctlr_int_ctrl(struct cpdma_ctlr *ctlr, bool enable); void cpdma_ctlr_eoi(struct cpdma_ctlr *ctlr, u32 value); diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 4bf65cab79e6..3592690b8dd8 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -860,7 +860,7 @@ static struct sk_buff *emac_rx_alloc(struct emac_priv *priv) return skb; } -static void emac_rx_handler(void *token, int len, int status) +static int emac_rx_handler(void *token, int len, int status) { struct sk_buff *skb = token; struct net_device *ndev = skb->dev; @@ -871,7 +871,7 @@ static void emac_rx_handler(void *token, int len, int status) /* free and bail if we are shutting down */ if (unlikely(!netif_running(ndev))) { dev_kfree_skb_any(skb); - return; + return 0; } /* recycle on receive error */ @@ -892,7 +892,7 @@ static void emac_rx_handler(void *token, int len, int status) if (!skb) { if (netif_msg_rx_err(priv) && net_ratelimit()) dev_err(emac_dev, "failed rx buffer alloc\n"); - return; + return 0; } recycle: @@ -902,9 +902,11 @@ static void emac_rx_handler(void *token, int len, int status) WARN_ON(ret == -ENOMEM); if (unlikely(ret < 0)) dev_kfree_skb_any(skb); + + return 0; } -static void emac_tx_handler(void *token, int len, int status) +static int emac_tx_handler(void *token, int len, int status) { struct sk_buff *skb = token; struct net_device *ndev = skb->dev; @@ -917,6 +919,7 @@ static void emac_tx_handler(void *token, int len, int status) ndev->stats.tx_packets++; ndev->stats.tx_bytes += len; dev_kfree_skb_any(skb); + return 0; } /** @@ -1237,8 +1240,8 @@ static int emac_poll(struct napi_struct *napi, int budget) mask = EMAC_DM646X_MAC_IN_VECTOR_TX_INT_VEC; if (status & mask) { - num_tx_pkts = cpdma_chan_process(priv->txchan, - EMAC_DEF_TX_MAX_SERVICE); + num_tx_pkts = EMAC_DEF_TX_MAX_SERVICE; + cpdma_chan_process(priv->txchan, &num_tx_pkts); } /* TX processing */ mask = EMAC_DM644X_MAC_IN_VECTOR_RX_INT_VEC; @@ -1247,7 +1250,8 @@ static int emac_poll(struct napi_struct *napi, int budget) mask = EMAC_DM646X_MAC_IN_VECTOR_RX_INT_VEC; if (status & mask) { - num_rx_pkts = cpdma_chan_process(priv->rxchan, budget); + num_rx_pkts = budget; + cpdma_chan_process(priv->rxchan, &num_rx_pkts); } /* RX processing */ mask = EMAC_DM644X_MAC_IN_VECTOR_HOST_INT;