From patchwork Tue Jun 25 17:59:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 167752 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5854299ilk; Tue, 25 Jun 2019 11:00:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNpEdWiZOgnW+6KioZAToVwdBCOrXyp5KMuIQqv7uitQuNH4mGbrXys0xelUU4FkWvbsI3 X-Received: by 2002:a63:e250:: with SMTP id y16mr38985540pgj.392.1561485612318; Tue, 25 Jun 2019 11:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561485612; cv=none; d=google.com; s=arc-20160816; b=Uo5MTwS1lagPISbkt+g2RHnFQPpC45y9KB15yFJaqIgT1rqSwpHTvrSQmgO7KqojA8 W5YAEY2chAUidwpDR5sK883f2/hOcJ4iAZCzNHvl8GCLEHKmR8nY4eAr27L9K1zSHazp 3wDuzWgkaNHKL0luILwrxPsaQmmUel0NXBby9AXP/IeX4jjlqap07Yurvo3dK9cDb8wu +HM8vXLPRCrowsrjBhDYZFSyEkSGj7vgCofcz2/nRi9xxLdD0NjuBQ63VpuYoWra9cyF Tq/ouSkhCv/oCwAtaOXp2UDm9olmNq+QZ6fLR0HrU4bRvNm4QL7JBU3YdcPMAMA0h4Ci qbrw== 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=QmxO/9gVmXF4taLxfCWA/1fSMjzT1beTSts3uWmQX/c=; b=zFQcLv0aTjvKQj2y8T/3VW/Td+3L0NXX9do0Ar5z+VU+bFdQ8GCA2Z74hew85CJHSF gHJJMz7f/7Lxq3mxXDAoUraUsIgmC4BLtyZYUxnX0f5BRrDwgEvanlJW61jDKOfeCRt1 cZRSfcj7gKxaMyWbTMfbofEPtGa6Ia1dhXgnfa/QQfNajEFXJNjVy35Inku330spAHaW 68YaUgHHLgND9tzoWORKsle+rTctw53NOHbbUz/HMjg6MxkJbGlR7bwLKOqopGHjSQJ3 vOnsqmmAVa/qrs0WnK8w8eJ1WNINrD9Y/AbN2l5ISZxFMuOrdrKwjF5DamyjTRCB1mDH QZ3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vpflNEPd; 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 200si16054619pfy.101.2019.06.25.11.00.12; Tue, 25 Jun 2019 11:00: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=vpflNEPd; 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 S1732694AbfFYSAA (ORCPT + 9 others); Tue, 25 Jun 2019 14:00:00 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40662 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731800AbfFYR74 (ORCPT ); Tue, 25 Jun 2019 13:59:56 -0400 Received: by mail-lj1-f193.google.com with SMTP id a21so17163813ljh.7 for ; Tue, 25 Jun 2019 10:59:54 -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=QmxO/9gVmXF4taLxfCWA/1fSMjzT1beTSts3uWmQX/c=; b=vpflNEPdlpmtF6ppcO+wcXweztt2Qm5bdsrxQRDQhamf0eRJO3Qogs94Fusq6ilfk7 8Yv+qjO4wUO2UeffXgyThzWBE5gKb5/Ds2EuvvI9tdPYrpT0RH7JRc7eLH9bVpBlmaCw lBbMlmDWfRysM555kgVKaozbbGxl2M5NHQ3b4g+bgxrXWs2d/ozTRi6v4ACMW+FFHqJx cQtIphyePbaGJxQr1YLejndiS5yg4f2KDd4TXXh0QaZFhM2RFdgxeSslwtZBcTPK1VOc mykNN9euAXUjlTXC3xoF2PsYzhhKGuX83I6jzot/y3ZoxT3WN3fXHBY92ZotgSt8kLhB cWjw== 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=QmxO/9gVmXF4taLxfCWA/1fSMjzT1beTSts3uWmQX/c=; b=r6gMdvVJElFQKqfW1PEvY0BHTTPrTSHa1+QaNcxIWnBzckgT104Y+HtUUZzGQf4dgI OLfxDj2J6YCNSgwsJHmEIoq35+jPP/T7+jC3EIDc+TeZu6BVRi5ZjA9wcqPpU4HRsfyK YlYJT5HHG3zSgLyJlLN9F5w6ugtPdUbrKZdhHonW34UYem+MS6uAX+bHhHZrnQFBLB7V FZWnuKv+ASs2tXqwYbJNs5ElppBh1E6ZmBNrcvnoLawrszoyAhcFxXU0yh0YYImdvYMg nOC7cLB/SMRDoYjS4QEORPVJIiVN08wi/GBPtg5b99GmdGZekcugwSPbxFywzI3vRCYp ABEw== X-Gm-Message-State: APjAAAWO1oC0PHTyj5w9xQOmbNmwlD5yUT1JARMrgUllWzmbo6pbA1MR W83llpOC/MTbjOLF+fDP+0ShjQ== X-Received: by 2002:a05:651c:87:: with SMTP id 7mr67283361ljq.184.1561485593465; Tue, 25 Jun 2019 10:59:53 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id g76sm2367597lje.43.2019.06.25.10.59.52 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 10:59:53 -0700 (PDT) From: Ivan Khoronzhuk To: davem@davemloft.net, grygorii.strashko@ti.com, hawk@kernel.org, brouer@redhat.com, saeedm@mellanox.com, leon@kernel.org 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 v4 net-next 1/4] net: core: page_pool: add user cnt preventing pool deletion Date: Tue, 25 Jun 2019 20:59:45 +0300 Message-Id: <20190625175948.24771-2-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625175948.24771-1-ivan.khoronzhuk@linaro.org> References: <20190625175948.24771-1-ivan.khoronzhuk@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add user counter allowing to delete pool only when no users. It doesn't prevent pool from flush, only prevents freeing the pool instance. Helps when no need to delete the pool and now it's user responsibility to free it by calling page_pool_free() while destroying procedure. It also makes to use page_pool_free() explicitly, not fully hidden in xdp unreg, which looks more correct after page pool "create" routine. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 8 +++++--- include/net/page_pool.h | 7 +++++++ net/core/page_pool.c | 7 +++++++ net/core/xdp.c | 3 +++ 4 files changed, 22 insertions(+), 3 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 5e40db8f92e6..cb028de64a1d 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -545,10 +545,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, } err = xdp_rxq_info_reg_mem_model(&rq->xdp_rxq, MEM_TYPE_PAGE_POOL, rq->page_pool); - if (err) { - page_pool_free(rq->page_pool); + if (err) goto err_free; - } for (i = 0; i < wq_sz; i++) { if (rq->wq_type == MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ) { @@ -613,6 +611,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, if (rq->xdp_prog) bpf_prog_put(rq->xdp_prog); xdp_rxq_info_unreg(&rq->xdp_rxq); + if (rq->page_pool) + page_pool_free(rq->page_pool); mlx5_wq_destroy(&rq->wq_ctrl); return err; @@ -643,6 +643,8 @@ static void mlx5e_free_rq(struct mlx5e_rq *rq) } xdp_rxq_info_unreg(&rq->xdp_rxq); + if (rq->page_pool) + page_pool_free(rq->page_pool); mlx5_wq_destroy(&rq->wq_ctrl); } diff --git a/include/net/page_pool.h b/include/net/page_pool.h index f07c518ef8a5..1ec838e9927e 100644 --- a/include/net/page_pool.h +++ b/include/net/page_pool.h @@ -101,6 +101,7 @@ struct page_pool { struct ptr_ring ring; atomic_t pages_state_release_cnt; + atomic_t user_cnt; }; struct page *page_pool_alloc_pages(struct page_pool *pool, gfp_t gfp); @@ -183,6 +184,12 @@ static inline dma_addr_t page_pool_get_dma_addr(struct page *page) return page->dma_addr; } +/* used to prevent pool from deallocation */ +static inline void page_pool_get(struct page_pool *pool) +{ + atomic_inc(&pool->user_cnt); +} + static inline bool is_page_pool_compiled_in(void) { #ifdef CONFIG_PAGE_POOL diff --git a/net/core/page_pool.c b/net/core/page_pool.c index b366f59885c1..169b0e3c870e 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -48,6 +48,7 @@ static int page_pool_init(struct page_pool *pool, return -ENOMEM; atomic_set(&pool->pages_state_release_cnt, 0); + atomic_set(&pool->user_cnt, 0); if (pool->p.flags & PP_FLAG_DMA_MAP) get_device(pool->p.dev); @@ -70,6 +71,8 @@ struct page_pool *page_pool_create(const struct page_pool_params *params) kfree(pool); return ERR_PTR(err); } + + page_pool_get(pool); return pool; } EXPORT_SYMBOL(page_pool_create); @@ -356,6 +359,10 @@ static void __warn_in_flight(struct page_pool *pool) void __page_pool_free(struct page_pool *pool) { + /* free only if no users */ + if (!atomic_dec_and_test(&pool->user_cnt)) + return; + WARN(pool->alloc.count, "API usage violation"); WARN(!ptr_ring_empty(&pool->ring), "ptr_ring is not empty"); diff --git a/net/core/xdp.c b/net/core/xdp.c index 829377cc83db..04bdcd784d2e 100644 --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -372,6 +372,9 @@ int xdp_rxq_info_reg_mem_model(struct xdp_rxq_info *xdp_rxq, mutex_unlock(&mem_id_lock); + if (type == MEM_TYPE_PAGE_POOL) + page_pool_get(xdp_alloc->page_pool); + trace_mem_connect(xdp_alloc, xdp_rxq); return 0; err: From patchwork Tue Jun 25 17:59:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 167749 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5854107ilk; Tue, 25 Jun 2019 11:00:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+NYfTKXpWJ7u8O80TAPySNPNoJNngugDC2Q1X2yw0ICPGCJif6HlDPslrREWdH4Yim98u X-Received: by 2002:a63:1952:: with SMTP id 18mr37114790pgz.334.1561485600404; Tue, 25 Jun 2019 11:00:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561485600; cv=none; d=google.com; s=arc-20160816; b=oZPzU20YR4a7rMCYhY5acTSkf8BK4C/d1csOVcQxxt+0dwJXJ1i+5hIg056eFma0VA pwH3rUeJYZfwxHk/DXUTBnF4kzi1gQiybj3Gr00YYUVMADmN52DvC6u8N0SHN26y0NJN gmIvkZqosf0Iin95I2i2/rf/Rqofs70OFdjfQpYFQABok/RI+0VbI4KUwXmCOA9jVuaH TjgSrQ4XpPrFYM5qEpTdVXNOJLn1FGkn7HmkOvTi50BPrtwZ7zhQSyNzjiPTNXfy6mjv BhX7CQbDgfn2jX/MWeSny29MrnlKUBIw8/jUAHCZhrOUux5lThZx6T8MCQmvrs8A8F0I b1tQ== 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=F7JFqzRXqxTzUkcqfAtcONZlOP60PRysVxN4UPvDiWY=; b=Gb+5AiJ+UJ6ZZFStv8UgYha4/CwMQ5iMyRrV3/toGyMg+qKaSy2TAW0Y7hkwDp1+pE rT7C4+WTDpYYuOTipVBBTmqKAnNNgHgzSCTyIKPbwcpCZ+JccxCS7QTG6v0putqYJDbS 48xsVrV6JLdP5d+/uVKsmynXOigClwSbhQOvlNzcE1/Rf4nqKcp6uNq7WwwQBU2dgGux qE6fzHFSTvBDX/e+d9+lzi9cMkE3z8qjXCQUZBdBcF6tMaczKt63+WDKGyO92fYrf9nW TqOD6n3aFIw6Fif2X1gNGWJjwwLVC8WwzVcKQscOWzNX9JRauUdOyCIhAGzXARJNC3lZ gIOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ZadifqpC; 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 t19si3393191pjr.68.2019.06.25.11.00.00; Tue, 25 Jun 2019 11:00:00 -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=ZadifqpC; 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 S1732674AbfFYR77 (ORCPT + 9 others); Tue, 25 Jun 2019 13:59:59 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:38287 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732408AbfFYR74 (ORCPT ); Tue, 25 Jun 2019 13:59:56 -0400 Received: by mail-lj1-f196.google.com with SMTP id r9so17163790ljg.5 for ; Tue, 25 Jun 2019 10:59:55 -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=F7JFqzRXqxTzUkcqfAtcONZlOP60PRysVxN4UPvDiWY=; b=ZadifqpCxAG5Bc754uL5Fhovr0r1XyRVOO1iONYf27GIXt8S2gj8Ja0ArmE2RSIBuT k3wNjjzrTLE/8Nj6fRGG5TdXYcIlj9ndlz5gT2xGXjEmH+WQDegmUtKXXwM8FS/exvi6 ogDi1sUcp9JoBT2F5aatoKSStsET9jc8LhZCEX7VkYejhx4laKXGrWzz55Fjz/a70zVU jVEhhvcq+Byj0LjMg+aO78FYXrJmsB/3uMnpl/qAeCmGJZYM6oYXYublMDwGkjuTSNf2 p7D019H3CyzIVq1vmlHcgtxRbqNCA0/0shsdNxjPhFQEXh1XQldkv2Dezh9ynvo9qEXl R6Lw== 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=F7JFqzRXqxTzUkcqfAtcONZlOP60PRysVxN4UPvDiWY=; b=nVVU1zKC1b897ZvwC/85GT2oiom4KxAfXoaf/M2i/uFx+7371MZySVczDelHtwjmet VlrkFyBSwFtVpFlnEh2IUH8/C8OJItDz+2A4h2IL/35WIkO8NP9mC00FStGImDXfm5Q/ gRQD3j3fcTWqmsKs+F4ron+0sCg1EfT35P8w3dICORaqUyfXUmEt7g0RLGikvyQ/3DWa BRSXlcoNrI1JNOQWEMWmRw9k/8LO7skb3dc9iDwC8MUlUm5NDZM+lV4YveU3sReII6cl 0+biWSJKqoLfdK4F4ErudyZQ85AONU/uOv9w/owcMU6we0wcIavDDDI1mTe+RvgPorYE IeAQ== X-Gm-Message-State: APjAAAW5qsv5+3eHufDSanLPxifAqXOxjQPS2teLfFMPQmKXJC1vyu5H tafW7tTblPEF7aE8T7US+RDcvA== X-Received: by 2002:a2e:658e:: with SMTP id e14mr54400481ljf.147.1561485594696; Tue, 25 Jun 2019 10:59:54 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id g76sm2367597lje.43.2019.06.25.10.59.53 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 10:59:54 -0700 (PDT) From: Ivan Khoronzhuk To: davem@davemloft.net, grygorii.strashko@ti.com, hawk@kernel.org, brouer@redhat.com, saeedm@mellanox.com, leon@kernel.org 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 v4 net-next 2/4] net: ethernet: ti: davinci_cpdma: add dma mapped submit Date: Tue, 25 Jun 2019 20:59:46 +0300 Message-Id: <20190625175948.24771-3-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625175948.24771-1-ivan.khoronzhuk@linaro.org> References: <20190625175948.24771-1-ivan.khoronzhuk@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In case if dma mapped packet needs to be sent, like with XDP page pool, the "mapped" submit can be used. This patch adds dma mapped submit based on regular one. Signed-off-by: Ivan Khoronzhuk --- drivers/net/ethernet/ti/davinci_cpdma.c | 89 ++++++++++++++++++++++--- drivers/net/ethernet/ti/davinci_cpdma.h | 4 ++ 2 files changed, 83 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 5cf1758d425b..8da46394c0e7 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -139,6 +139,7 @@ struct submit_info { int directed; void *token; void *data; + int flags; int len; }; @@ -184,6 +185,8 @@ static struct cpdma_control_info controls[] = { (directed << CPDMA_TO_PORT_SHIFT)); \ } while (0) +#define CPDMA_DMA_EXT_MAP BIT(16) + static void cpdma_desc_pool_destroy(struct cpdma_ctlr *ctlr) { struct cpdma_desc_pool *pool = ctlr->pool; @@ -1015,6 +1018,7 @@ static int cpdma_chan_submit_si(struct submit_info *si) struct cpdma_chan *chan = si->chan; struct cpdma_ctlr *ctlr = chan->ctlr; int len = si->len; + int swlen = len; struct cpdma_desc __iomem *desc; dma_addr_t buffer; u32 mode; @@ -1036,16 +1040,22 @@ static int cpdma_chan_submit_si(struct submit_info *si) chan->stats.runt_transmit_buff++; } - buffer = dma_map_single(ctlr->dev, si->data, len, chan->dir); - ret = dma_mapping_error(ctlr->dev, buffer); - if (ret) { - cpdma_desc_free(ctlr->pool, desc, 1); - return -EINVAL; - } - mode = CPDMA_DESC_OWNER | CPDMA_DESC_SOP | CPDMA_DESC_EOP; cpdma_desc_to_port(chan, mode, si->directed); + if (si->flags & CPDMA_DMA_EXT_MAP) { + buffer = (u32)si->data; + dma_sync_single_for_device(ctlr->dev, buffer, len, chan->dir); + swlen |= CPDMA_DMA_EXT_MAP; + } else { + buffer = dma_map_single(ctlr->dev, si->data, len, chan->dir); + ret = dma_mapping_error(ctlr->dev, buffer); + if (ret) { + cpdma_desc_free(ctlr->pool, desc, 1); + return -EINVAL; + } + } + /* Relaxed IO accessors can be used here as there is read barrier * at the end of write sequence. */ @@ -1055,7 +1065,7 @@ static int cpdma_chan_submit_si(struct submit_info *si) writel_relaxed(mode | len, &desc->hw_mode); writel_relaxed((uintptr_t)si->token, &desc->sw_token); writel_relaxed(buffer, &desc->sw_buffer); - writel_relaxed(len, &desc->sw_len); + writel_relaxed(swlen, &desc->sw_len); desc_read(desc, sw_len); __cpdma_chan_submit(chan, desc); @@ -1079,6 +1089,32 @@ int cpdma_chan_idle_submit(struct cpdma_chan *chan, void *token, void *data, si.data = data; si.len = len; si.directed = directed; + si.flags = 0; + + spin_lock_irqsave(&chan->lock, flags); + if (chan->state == CPDMA_STATE_TEARDOWN) { + spin_unlock_irqrestore(&chan->lock, flags); + return -EINVAL; + } + + ret = cpdma_chan_submit_si(&si); + spin_unlock_irqrestore(&chan->lock, flags); + return ret; +} + +int cpdma_chan_idle_submit_mapped(struct cpdma_chan *chan, void *token, + dma_addr_t data, int len, int directed) +{ + struct submit_info si; + unsigned long flags; + int ret; + + si.chan = chan; + si.token = token; + si.data = (void *)(u32)data; + si.len = len; + si.directed = directed; + si.flags = CPDMA_DMA_EXT_MAP; spin_lock_irqsave(&chan->lock, flags); if (chan->state == CPDMA_STATE_TEARDOWN) { @@ -1103,6 +1139,32 @@ int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data, si.data = data; si.len = len; si.directed = directed; + si.flags = 0; + + spin_lock_irqsave(&chan->lock, flags); + if (chan->state != CPDMA_STATE_ACTIVE) { + spin_unlock_irqrestore(&chan->lock, flags); + return -EINVAL; + } + + ret = cpdma_chan_submit_si(&si); + spin_unlock_irqrestore(&chan->lock, flags); + return ret; +} + +int cpdma_chan_submit_mapped(struct cpdma_chan *chan, void *token, + dma_addr_t data, int len, int directed) +{ + struct submit_info si; + unsigned long flags; + int ret; + + si.chan = chan; + si.token = token; + si.data = (void *)(u32)data; + si.len = len; + si.directed = directed; + si.flags = CPDMA_DMA_EXT_MAP; spin_lock_irqsave(&chan->lock, flags); if (chan->state != CPDMA_STATE_ACTIVE) { @@ -1140,10 +1202,17 @@ static void __cpdma_chan_free(struct cpdma_chan *chan, uintptr_t token; token = desc_read(desc, sw_token); - buff_dma = desc_read(desc, sw_buffer); origlen = desc_read(desc, sw_len); - dma_unmap_single(ctlr->dev, buff_dma, origlen, chan->dir); + buff_dma = desc_read(desc, sw_buffer); + if (origlen & CPDMA_DMA_EXT_MAP) { + origlen &= ~CPDMA_DMA_EXT_MAP; + dma_sync_single_for_cpu(ctlr->dev, buff_dma, origlen, + chan->dir); + } else { + dma_unmap_single(ctlr->dev, buff_dma, origlen, chan->dir); + } + cpdma_desc_free(pool, desc, 1); (*chan->handler)((void *)token, outlen, status); } diff --git a/drivers/net/ethernet/ti/davinci_cpdma.h b/drivers/net/ethernet/ti/davinci_cpdma.h index 9343c8c73c1b..0271a20c2e09 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.h +++ b/drivers/net/ethernet/ti/davinci_cpdma.h @@ -77,8 +77,12 @@ int cpdma_chan_stop(struct cpdma_chan *chan); int cpdma_chan_get_stats(struct cpdma_chan *chan, struct cpdma_chan_stats *stats); +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_idle_submit_mapped(struct cpdma_chan *chan, void *token, + dma_addr_t data, int len, int directed); int cpdma_chan_idle_submit(struct cpdma_chan *chan, void *token, void *data, int len, int directed); int cpdma_chan_process(struct cpdma_chan *chan, int quota); From patchwork Tue Jun 25 17:59:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 167750 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp5854138ilk; Tue, 25 Jun 2019 11:00:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtj3xdjXd9znmT0zpuWOKDAcEemYfrMHgpgsgVlzNN5gZmtfg4EKNSBQRLwBaygoHAhg+U X-Received: by 2002:a17:902:903:: with SMTP id 3mr132207254plm.281.1561485603306; Tue, 25 Jun 2019 11:00:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561485603; cv=none; d=google.com; s=arc-20160816; b=lO6pUW262t9bWumWeNg0npaCB+YbeSgL5IqaeOXKPtILtTtlU5JfnXa+dZdRouH7sM Bm/EOPCYbRmYzo3sE/Kqgv2eF+/h14dRzoM75lZBKgiHcWETAPjh0W2+RPEjHarAJ4W1 tlW7qG3Xo85PhNOgYW+sv46N+vKr8WLonCzFiL4rJaZVbPRdhy1LSBUiHYqgSDTKvxdS xHHYA0GdQbE4nwuknm0IqJF7QEm9BaC+KJtDQDqJmXxtogL/sFXvJlNxqR/iB9LzYwlW Aik3E/Vp/mjQwtMN1qtKXgcI27mowjkDTBdrcR/tKerpeqhwrJDmmZillKo/0vu5+G31 75pw== 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=BQmMDEf9H7Vaq7I5JuGUMaBd4qjuzhRid1mFRfo+/Y8=; b=NWLUGTQnQnddFQxjnOveiaHKhY/B/Q8NaPZF0hgjPIrvNvm401lyVdUMY0AautZg0U xq+QiLjRWeGIOUlR7fDFxGZhwlN9gk56HueTUx4GsuLqK7xciICVQosa/BfV2OdueHSf eVs/vEWHw1+DDaWnXtSrDBlUYGQDARWQtdApFiwqIqc3GolQxHqXxEx5Wk9ZmjVoTK9i pSJPRvr+a5I1pPDypwPO4BM0A3n5VOSx3MlksxZnnQ7ccZ4uPRYHNQncFnKS7/jxYxYR xm3dILavfvgOkEwMjo1UeHi1YD0pTklkiG1MFE6Ie13cIf58ljvaaw0+sAbtLMnNHpVQ 7oQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J0CIMS+x; 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 t19si3393191pjr.68.2019.06.25.11.00.03; Tue, 25 Jun 2019 11:00:03 -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=J0CIMS+x; 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 S1732699AbfFYSAB (ORCPT + 9 others); Tue, 25 Jun 2019 14:00:01 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:39580 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732410AbfFYR76 (ORCPT ); Tue, 25 Jun 2019 13:59:58 -0400 Received: by mail-lf1-f67.google.com with SMTP id p24so13292940lfo.6 for ; Tue, 25 Jun 2019 10:59:56 -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=BQmMDEf9H7Vaq7I5JuGUMaBd4qjuzhRid1mFRfo+/Y8=; b=J0CIMS+xGTc1gyaqwn7p/IWVtcnle2qwDqeLgpQYBmLUd844qKmh9hmf+gGwQjJpFl 4wDvP0pDThaFoFXmuiXT6pVFH+BVPQKxk/KRUOIlnCYRoL9X9a5SJqPKjU4FtQn1Cocd Ejxy8BPWqhPjJ5x99PBhx6kdDrDHjQIWCR4a52CTiyC6ggC3iDpfXEiAMbZtZprTIPSA zVW3s/B1MucDD3fovnNEWbchVpRiALo7Hz1I9F6trAWGwucREaAAP6ZVUFRcS4FI6LTp 9UWUGs3ecs5OTlyqXgKvHV6OThieDv5oIYdRlOuBMgfNXEAlEwbNg+OwRnB7577frJF1 +fXg== 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=BQmMDEf9H7Vaq7I5JuGUMaBd4qjuzhRid1mFRfo+/Y8=; b=mu/w1+xIXvQB5eNrsUA80Twnb4F3tjTVsZlMPC/RY+9yTjeRw2tkBTNFr8cyJg1gNm o93HEOD2U/BQvlaRxQTVQQNLwfVqtM/9+wuDKDFfl8ZIwuphIpYdoz2nbEFPOyKnHp5h GzHIGU5SpeaeufBRKTnc17b7P5M5zS7gEftNeE93QCZtn9xHniyqwBmoL7pS4a9aFJsK j43PXoufgymx9BrBfwOWNyhFJhm28hJvotLY+mlBQBZiyQ/C73ZfYC9OUsjohHX5K3RT H+sAmFSY4i5SoO7xB5UqjBUbqwj4iCH5kxcVI54joNqaB3aXk06w7IdJeASNPLCkYteG 8BmQ== X-Gm-Message-State: APjAAAXUl1mlL3lEvuJw6XD0JOS0yN8iUuk/jtaxRK7NU033Yyf4hrkl v2p80asYJeEtw4E07ONOPFPzcQ== X-Received: by 2002:a19:7616:: with SMTP id c22mr26526lff.115.1561485595986; Tue, 25 Jun 2019 10:59:55 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id g76sm2367597lje.43.2019.06.25.10.59.54 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 25 Jun 2019 10:59:55 -0700 (PDT) From: Ivan Khoronzhuk To: davem@davemloft.net, grygorii.strashko@ti.com, hawk@kernel.org, brouer@redhat.com, saeedm@mellanox.com, leon@kernel.org 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 v4 net-next 3/4] net: ethernet: ti: davinci_cpdma: return handler status Date: Tue, 25 Jun 2019 20:59:47 +0300 Message-Id: <20190625175948.24771-4-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190625175948.24771-1-ivan.khoronzhuk@linaro.org> References: <20190625175948.24771-1-ivan.khoronzhuk@linaro.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@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 | 21 ++++++++++----- 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, 49 insertions(+), 32 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 32b7b3b74a6b..726925df8d97 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); @@ -464,6 +465,8 @@ static void cpsw_rx_handler(void *token, int len, int status) WARN_ON(ret == -ENOMEM); dev_kfree_skb_any(new_skb); } + + return 0; } void cpsw_split_res(struct cpsw_common *cpsw) @@ -602,7 +605,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; } @@ -620,7 +624,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); @@ -652,7 +657,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; } @@ -670,7 +676,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 f60dc1dfc443..7c19eebbabcc 100644 --- a/drivers/net/ethernet/ti/cpsw_ethtool.c +++ b/drivers/net/ethernet/ti/cpsw_ethtool.c @@ -532,8 +532,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 8da46394c0e7..b96f5ae974ba 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -1191,15 +1191,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); @@ -1214,14 +1215,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; @@ -1232,7 +1235,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); @@ -1241,7 +1244,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; } @@ -1267,28 +1270,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 0271a20c2e09..69074738bef0 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); @@ -85,7 +85,7 @@ int cpdma_chan_idle_submit_mapped(struct cpdma_chan *chan, void *token, dma_addr_t data, int len, int directed); int cpdma_chan_idle_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 5f4ece0d5a73..0b768a426848 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;