From patchwork Thu May 30 18:20:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165453 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1313880ili; Thu, 30 May 2019 11:20:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqy0OzKDFRPrz7Ii9h8o2PaXDV/9qP7GhR3XyWc9NJfleUaB2a0fe1djSnVORT6tMFa0sbxr X-Received: by 2002:a62:86c4:: with SMTP id x187mr5097294pfd.34.1559240456356; Thu, 30 May 2019 11:20:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559240456; cv=none; d=google.com; s=arc-20160816; b=0+AoIwLwo6W0wD3r0Bh+r+8F8mSBkHjgsz5ZyUQ2mI/Modd9HbElUw2Ao2LvUk4ltO w5wdgIRvE5ilWKiJh/NU8OFAiaQNdl1UxoGR3JPmRQg35W77Duj/nZHnHk/LcqdHEtUK s0N0mC8wd6UG0wzW1kvtmvUAiOtKD5ffGDS30FnyVytJJ8mnyj4O+8muFGkKYpnmMvyq XJMXkW4l22K58MgwVV+h76iS0kT4cr0US7eznaHrvLjksZdK9qFhBgbck+DvDf1l+/J9 ejhiMBKwNyunoKI+ToPaWYabdOKWJr3xe79H9rfqduoFabuLK4SKwC1GQRpuJjdFz78d Klww== 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=T7iVWRDzpDZ8Fqiy/Xzdv8JGGYZeF+1zwUEpOr30X3v9SWYKz309xzRZqhtVZHsnxc BbPhrbYbwc8xBiYuIRsoI1Zaln9Dpq8KdvSe0gC8FCJX8IReuFaIU1CJRxlzVDSFEgZs YdozKdWpIEhCU0vaNTx+EaIwqVwpS6L09BNTsaDfOxEHhmGtGMOYDd2yBN/bBiyDiuM+ xmEYwej3UaJ911nID9RbtU1mtLo3R3luC8OC7CITwqFDbhSNXkn0AYNSdEevorsRrn3b yIU2Fh7hgxvGq5FxRLF2Ue2ivFOfaEw2WRzryp1q+tPD/Lre2FnKZ7Y0JAmQVNgXzhpC rJ4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NTEyy87m; 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 v19si3673102plo.413.2019.05.30.11.20.56; Thu, 30 May 2019 11:20:56 -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=NTEyy87m; 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 S1726738AbfE3SUz (ORCPT + 30 others); Thu, 30 May 2019 14:20:55 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:36249 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfE3SUx (ORCPT ); Thu, 30 May 2019 14:20:53 -0400 Received: by mail-lj1-f194.google.com with SMTP id m22so6787279ljc.3 for ; Thu, 30 May 2019 11:20:51 -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=NTEyy87mbpZennf/zO3UY3SG/jU34eWt9oBeag4D8YjahXlGpvo7jFJ45TsemIdnir GDDTpbKLurGeDuALSvM6j7s2xNdezurfEaq3Do0FdVu1zSrcVUfBnzEjlX9CPvMPhzYJ syvG28Ahiha6P8q/z1kIyl0178d00DQHN+sX/j5wk8ko44/63zLEGfJyi7VPUdIJ0LKG TgaTpYJ6tpJG3xAZrI95TMKLk8q+WGk0L19nUTHjuhUVz5EeWBCSPoZe7eWVxtRSZtYW kYjH1/WFTyKdQ+VO2y6VV9nuGp1SruffgOv8KjxhvVfDhLZ+qlpEcUfBKzBd6xbaakTA 2nxA== 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=ZXKmn5oJ3RdxFXn7L45+qx3OR9LYg+lkNjAjsoI7YEbhClxvDQKdTo5qM+uaf6JtCX TnwXaFZ+kxTns3ZbJtqTomkOgYXbGoNJbJhvp7YFj6fOexA9Q6rmpdqM4StFZdc/IZY4 /KzsUo6uwmd49Kjr245wb/SLi5vs4b+rCXIv10BITYM7q+1bvGU/YPj12x5IgWlJZpEH jdo1mhZq+Uf16sBrZcvKa3JlSkQlXQLC9vgIUUEYU70p12riYcZPVOnGEL0R3aQMgC9n esXMo87jmINpB5wioVd5101twCZsKPyeBohBZp1EHlKEHyD82Bsm8QHPVIXagnVe1Ydf 0g4A== X-Gm-Message-State: APjAAAWnkrI97YA/D4UxSxkR86ufAA/OO5e5YaVoWvx0mK3TRCYRbE5G dX/4+un9QEZkeINWt6PiN1wrve6Tq6U= X-Received: by 2002:a2e:9756:: with SMTP id f22mr3083605ljj.30.1559240451067; Thu, 30 May 2019 11:20:51 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id v7sm388946lfe.11.2019.05.30.11.20.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 11:20:50 -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 v2 net-next 1/7] net: page_pool: add helper function to retrieve dma addresses Date: Thu, 30 May 2019 21:20:33 +0300 Message-Id: <20190530182039.4945-2-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190530182039.4945-1-ivan.khoronzhuk@linaro.org> References: <20190530182039.4945-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 Thu May 30 18:20:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165459 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1314668ili; Thu, 30 May 2019 11:21:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkulIUD/KvDQlXOfaCchBioO42JZ6p6ryTXSjzVJTA+T/PDwC1dgLiyTlDwd3OROc/F4++ X-Received: by 2002:a17:90a:1951:: with SMTP id 17mr4734195pjh.79.1559240500847; Thu, 30 May 2019 11:21:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559240500; cv=none; d=google.com; s=arc-20160816; b=EMGilt9ZlNvLzVFJoqKU4cCEK3JD7QYh1XvCMjx1c25gv9A1s3M2rVHhzEjvsHffzL 3riWyWg8xw5Th5ydRtfRdycEw1vYekVfUw2or2qnsYqlutiScGZwruQdgRxx20NWUb5D 6hgTZGJsihR9YYaoG/r7ba74FyhjiIf/DM+4Jzdw2MwKSwHkD2YkHhPIDP5XCm8+xjHW Ad/uLHVZoCzqVBOjLA3RoXPR9MbTtCbC9Bo0aUmkq08FbDZ3CZPN058204tfetOxq31Z 0rwJu+52LONv0Rdww5td4FzZOO9IYi/KGucU0h10GxO25bNtXdLS5gjde5ivcZxLc2ke 50CQ== 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=J8udFRfvbZ6fXOojTQ4C0YPBDnze74Ovvj+f7jr19Fw=; b=ozrmCS+NpKLiTuSzYbh2n5GzqZ8PG8duw2NdDY+qCQZawoxFxAiZhEYfJpvEXPMpK/ PzIgBF/nL1JwqpMGO7IjMiEmMCL7d6GlE0Bvkc1nouok42GKo2KGMiiQccKEI8PU5HBf KJlw7Ccghf4kUptFAPubn8+zrGl9L3FoB8mUMCJlei0kMsrD8vfED6hTukq7t7F6zJXt Axyp+6JSQ5cthBp43e55CwOrnyPMctBu3QjJ3Vq6E9BYcmPv/itOV3oAKu9iKa1mbB8e 4Qsd+BvqsG+RBqkPdd7dYOQT3CciUNvUsAuFvIQbSAGiEwoLUCqrnPxIl+L3NLH6pPk8 SNPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wU1WwXoE; 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 61si3717983plr.51.2019.05.30.11.21.40; Thu, 30 May 2019 11:21:40 -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=wU1WwXoE; 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 S1726963AbfE3SVj (ORCPT + 30 others); Thu, 30 May 2019 14:21:39 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:37163 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726674AbfE3SUy (ORCPT ); Thu, 30 May 2019 14:20:54 -0400 Received: by mail-lf1-f65.google.com with SMTP id m15so5783537lfh.4 for ; Thu, 30 May 2019 11:20:53 -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=J8udFRfvbZ6fXOojTQ4C0YPBDnze74Ovvj+f7jr19Fw=; b=wU1WwXoEjKxZ3uqM80S4B/iacjxdOKTanw/C0MhErCrltoOGbqOgl6D3+r1s/I5MDs 43CeGw6Y6RckooIj+upDJFUOq/x8S44sRl4IecU2CAs9bIntSdh8qHidWHvG+s5sZZwr tMo1h8S1ts9QZr8NNUvE3T9naG3R4FHAPT23kfi5+VV7aUci43qWu5ZZWJKAHQleHoEy /ajuUGqlAVxb3HPheATiiuEdAXwo7PokCTbdy4XNP9sZTvD5RheyUk1vZwg8Azp9xD2i pnBXFBTfRa7tQ02r91dRnH9CWokN/c7+ti7EZKQlpvZEfndG6pFqlRF4421kR1+T9DU1 CSjw== 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=J8udFRfvbZ6fXOojTQ4C0YPBDnze74Ovvj+f7jr19Fw=; b=LD3801oK8dwNL55At8p3UNM5Ih45hHkrgTUkvTHssE2RNEfwEfnfLyziWliTPuQtle ciPDdWyC1jhxnGGnte0Cr/8L3qT3JXrED60jKGOlpBGF6wgFPMeHA5x0hyxWNrOwJJDh AAY4H8aDyUHEqSozCYqkiZwdUwV/ZLWvpu7ssmjy+AynniAQzFdeH68ZV+6IdcPmxtEf Ntc6w4j70VwQP+IHBlm1pXR/YEiqfOJEYs+HXD0KFMW9lt0xSnPLibBTql5Icx5wPzAQ ONwftsK+9d4V3iTGGYA53IZ9dsDkvTFN7kgu4D1yAWiBqOi13xizOZTgh3B+pSdXgxoJ Zv0w== X-Gm-Message-State: APjAAAXoL/7PWSfA/ITejNTvkbVMD5xbYcNRg7k7Ij/pA52OXtSmaLZV J4TMzK8xcXxil473m2Fls70pbg== X-Received: by 2002:ac2:494f:: with SMTP id o15mr2908131lfi.22.1559240452479; Thu, 30 May 2019 11:20:52 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id v7sm388946lfe.11.2019.05.30.11.20.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 11:20:51 -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 v2 net-next 2/7] net: page_pool: add helper function to unmap dma addresses Date: Thu, 30 May 2019 21:20:34 +0300 Message-Id: <20190530182039.4945-3-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190530182039.4945-1-ivan.khoronzhuk@linaro.org> References: <20190530182039.4945-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 unmap 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 | 1 + net/core/page_pool.c | 7 +++++++ 2 files changed, 8 insertions(+) -- 2.17.1 diff --git a/include/net/page_pool.h b/include/net/page_pool.h index b885d86cb7a1..ad218cef88c5 100644 --- a/include/net/page_pool.h +++ b/include/net/page_pool.h @@ -110,6 +110,7 @@ static inline struct page *page_pool_dev_alloc_pages(struct page_pool *pool) struct page_pool *page_pool_create(const struct page_pool_params *params); void page_pool_destroy(struct page_pool *pool); +void page_pool_unmap_page(struct page_pool *pool, struct page *page); /* Never call this directly, use helpers below */ void __page_pool_put_page(struct page_pool *pool, diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 5b2252c6d49b..205af7bd6d09 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -190,6 +190,13 @@ static void __page_pool_clean_page(struct page_pool *pool, page->dma_addr = 0; } +/* unmap the page and clean our state */ +void page_pool_unmap_page(struct page_pool *pool, struct page *page) +{ + __page_pool_clean_page(pool, page); +} +EXPORT_SYMBOL(page_pool_unmap_page); + /* Return a page to the page allocator, cleaning up our state */ static void __page_pool_return_page(struct page_pool *pool, struct page *page) { From patchwork Thu May 30 18:20:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165458 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1314408ili; Thu, 30 May 2019 11:21:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmmqUfnHbhcoAkumf6X1W1+pBes0AT3TsMZGRvgMqh/u5SDJJmsLf5fRQJwDA5KyK+TLM4 X-Received: by 2002:a17:902:b695:: with SMTP id c21mr4834944pls.160.1559240487614; Thu, 30 May 2019 11:21:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559240487; cv=none; d=google.com; s=arc-20160816; b=wSkLLy2Xsk7Hal/tD2tD06x5FkcAnRBUYmcxFCN3GxKiLhnqgsprF9aKG39IQ/xmCG IeJ3LuZpM+H1kdnLVJ1QUGG1T5vgNSB5Ew3QNpZfViO44cqOzl1XdYsWWz2y3kHnbvF+ BP7XilpNMeJvyYd2XJyO1tWg6xE9ywNZfjspXphADwJu29TtTO6w6orBUmsStpgnrwXJ +Tjl0ZhYRqir2ezRtw8+88KAHeCVGHZZ+zGK7tmqfgSZXlh+XQyXyjR41b7PHqIYJSYO eR4EVkuFlRRV8+9kHA3v3wqfSZwWEYnDyACTRyCmyNd2my42QzRX7h1fuDVvtEd8uEI+ Vx5Q== 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=ksgNqXYuq7eYRSzBEvTxTsDgmGrsQMBHFwlmQvvNPkE=; b=KnMl9rDlvD0R14g9lgBOBnSFJcq37tvtVgqoT2N5t5NzC+uPEFcOCs4UFSLBW85AUJ RjlzPQeqR5QkR0VGR1boaIV5jalsxm9mKZmYfjQVeShQ0KmoQINMFW/LSBSDbix/Tn4M m9nb8FrYhvQ7UTAW+OlIh5tAvzMy6ZU32JpS2ymYeW1hJW7BoCkOZrXzaBcwiYHdZaPB 4RITxikw3UsK3X0lmfRxD46G+T5UUBUtXRF7lvXLhGU9fl1COnLPraGySiFnpOpsF5Hk HWkF/u+n2ipe+f6EumROounfUcUCuPoqkmU+v3q9ZjYN6b/A6L3rIpaVp1qUMmb0o8NE CoVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GxvvJPDK; 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 g1si328360pgd.425.2019.05.30.11.21.27; Thu, 30 May 2019 11:21:27 -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=GxvvJPDK; 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 S1726804AbfE3SU6 (ORCPT + 30 others); Thu, 30 May 2019 14:20:58 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:37146 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726563AbfE3SUz (ORCPT ); Thu, 30 May 2019 14:20:55 -0400 Received: by mail-lj1-f194.google.com with SMTP id h19so7014608ljj.4 for ; Thu, 30 May 2019 11:20: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=ksgNqXYuq7eYRSzBEvTxTsDgmGrsQMBHFwlmQvvNPkE=; b=GxvvJPDKMnF2Hc4YuIT4oM82YGKw8EcaMBLqKbLD6yc2xy1Jwtfbwfeyw6rJBMcxpP /8u5FHFV1Sy3qbcFK5Wmocu4voUWgTi5jFxXDOxc+ngyfsy4lqfvlE7oHUr+L6qZH+eX ueuXJk6RvJCOHnaTzXvc+TlemnLRktzO0mQfYVU9yC3NpOn2npdhCibuxqDZHEu55r80 3ZvBQY3uUcxW/C9LniDNuWN/a3zoHFJ2gJI3hYCe/2Td//7W/9ecVrlJaVueUFNuH3iF nCFCRSOlgR596k+Vvo6qoZ/d/mlLBZ1dEtqBninfkrngveooWNd17Db8p+jox/7w0ASv o/Xg== 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=ksgNqXYuq7eYRSzBEvTxTsDgmGrsQMBHFwlmQvvNPkE=; b=kmGB2EHT3toJ28yH793Iq2JZCHpL82yNdt7QI3r6pR0OnTIrmtH5OTkcsi8jT/umyn clwbwD7/m+bFTeO47YQQRHuuvADqw2hbF2478AiZ1fo5SdxH1Hsu6heeQ4jKczel5DCq Rrh59tND4fSCsF02p38S8HpM03yHjBKKmQY9uufMI8ZYVRzQ+MjavvwHwb/Yf+FHaqzb u/PYdWTe19+TlroZCO1YxgL8uOE85LnGcuzSMAZ3wE+RF70KbhLGWCw7cuyIZq8OF+n3 M/Hs5mofL97wzfXedUKLAQDIwchWRCDTEuK33cZZpT3ctaoUOGiSgJpK2dxdSeHka4BB 9fwA== X-Gm-Message-State: APjAAAUomEYhOoUbT8/z6jRKIXkoDglyopx8216cl4U9DQcSqueSjZgK Uf//pwGjuvJt9tKi1OOKSLLZng== X-Received: by 2002:a2e:88c7:: with SMTP id a7mr2713139ljk.118.1559240453797; Thu, 30 May 2019 11:20: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 v7sm388946lfe.11.2019.05.30.11.20.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 11:20:53 -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 v2 net-next 3/7] net: ethernet: ti: cpsw: use cpsw as drv data Date: Thu, 30 May 2019 21:20:35 +0300 Message-Id: <20190530182039.4945-4-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190530182039.4945-1-ivan.khoronzhuk@linaro.org> References: <20190530182039.4945-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. 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 Thu May 30 18:20:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165457 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1314329ili; Thu, 30 May 2019 11:21:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzwTTu2f8kxya4U5ITq+I942WDcLIlfkO0ioNj5ynhWyYwoK0ZCmTqaB6MSnBuFVwscpwQT X-Received: by 2002:a63:4d0b:: with SMTP id a11mr4824203pgb.74.1559240483283; Thu, 30 May 2019 11:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559240483; cv=none; d=google.com; s=arc-20160816; b=lkKoshcCd2D0XuLNP/uqxM21r2XRfEHZ/2/BDOVg03WH/na3NANq7LB9pMNNtly23f tU5EgbPOZUeH9Umk9onzwUNgXWsZMJDYRIELgIdn1qANsJKpSE08ahEa9aASwny5nYuO V9aCQu9Rm0T4VtlF9z8WwR302/YrXGqVyXQXv567ZYrtTr8FCWGdTyLLHxn8k6x6812Q 0M/yl7rXtLRuv5LDfZM42wiZ66h5jXE2AStKXrKsSz60aKVy2ujqQHiaJM1uQ2d/O//s rAWA5L2wGZtFkvLLp0VzXd+c8QWW6+n2GPT8d0WkxKOkQQLD9JCb+fU1pXUYxDLy3PVt jblg== 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=7Z+hJ2xpe6chUPepscBLPDGl6ohx6IXf3hvf84qy8k8=; b=wW6MMYcn9nVuHYm1Vv3kETTuUnfzP9a067uEdpHslZiLqvKEaikk7xtZ/XEnbPsRM/ bP31a0LRshW98Bi0k4V8FioCqWSISbFkm2g5iPG4ibd7Qb6seBWs6shg1MtsQeokfZ14 haYb4om+GEWJUU8NDPl/Kwb9UvugQVEDuHGWX2EYJeK/zuKpJPhjdrdbHkmr01MhVBTn P8GU2V3I3yDeA22Q0haHQG6Ky3BvLjy+RjsOUvQZWZ0tzlgFfDS1zC65QJ4UcN9TUUoP nZiA2OjKxd1eckQhjif8bD/Hg7xMG4wd+axcED7PWfGeZhuuA1b4i/J4J09oDvrxEK2u c4vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uhOmPRjv; 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 g1si328360pgd.425.2019.05.30.11.21.22; Thu, 30 May 2019 11:21:23 -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=uhOmPRjv; 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 S1726799AbfE3SVA (ORCPT + 30 others); Thu, 30 May 2019 14:21:00 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:35422 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726748AbfE3SU5 (ORCPT ); Thu, 30 May 2019 14:20:57 -0400 Received: by mail-lj1-f196.google.com with SMTP id h11so7043705ljb.2 for ; Thu, 30 May 2019 11:20: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=7Z+hJ2xpe6chUPepscBLPDGl6ohx6IXf3hvf84qy8k8=; b=uhOmPRjvEPSqocDDlrLrJvOMrG4BmMTmoKHMBhVYAOxkMPgQwKo8MLA+oUcoZpnE73 dmiFzXl+QuZrAp0Lgucvbbs/79sKAtpwEPKLe+oVyi9gpnJmlqdmQWFthozqsJ7vAlib O5ziXaNoSYxVerDq2kopFdPMRnnstnvVV+oXSSGa8KaD2zcWoIZqMQTCOKKkN2oZxBYH QXagZkmO/GrHY+9MvwRB2j/wtFTdc9VllDwFrNei7AQgikvYzJ4CyR3Aqnd1qkd/6ahV PUicArdA8GgZMhQv7A5UXBQJCzMMl0d5wd3whOjnjuW8jmjn5lApMHzCIAyDszBD+YcR T0hg== 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=7Z+hJ2xpe6chUPepscBLPDGl6ohx6IXf3hvf84qy8k8=; b=JqaaOVS/0V27lS7J3TEuiOPunUK5Y8BAvrPBRZ2BnvxR2Y5Xnt6pVnhVKQUNnxpVwW 5INzQumy2KKrv9QJQUy50k1ZvB3OP2S1FWXj2nzmLNJGZR5Gla0vK+bfbFKkk3mToFBH HJ/fzWH3O5QN2b5erXPet8gsieeRjiQtcAOy9tLzZdATq6gKicfLUNklGXWz+YRZW69K DWaZctQsVYH9dxeH97N+tdp2+spssDS0keYl1biIuLhqM1JvXkP5xNjsatSGORN5r5gh IBw9TPS4LuoviLyJWRZOJeSdJlKxhcquE7/jrAKSYXB4LDsm9s5xAvoG0ijaL0rXv+IV 4o3w== X-Gm-Message-State: APjAAAUhMunzFtNXCt0PMGyK43wCApWvKkIUOD2H8M2R2V5XpTg07QWI nZQ6yXw/pSpCN8KtZZ8MGu3bQw== X-Received: by 2002:a05:651c:93:: with SMTP id 19mr2944496ljq.213.1559240455046; Thu, 30 May 2019 11:20: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 v7sm388946lfe.11.2019.05.30.11.20.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 11:20:54 -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 v2 net-next 4/7] net: ethernet: ti: cpsw_ethtool: simplify slave loops Date: Thu, 30 May 2019 21:20:36 +0300 Message-Id: <20190530182039.4945-5-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190530182039.4945-1-ivan.khoronzhuk@linaro.org> References: <20190530182039.4945-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..c260bb32aacf 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,6 @@ 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; int i, ret; ret = cpsw_check_ch_settings(cpsw, chs); @@ -604,20 +606,20 @@ 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++) { + struct net_device *ndev = cpsw->slaves[i].ndev; + + if (!(ndev && netif_running(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(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(ndev, cpsw->rx_ch_num); if (ret) { dev_err(priv->dev, "cannot set real number of rx queues\n"); goto err; From patchwork Thu May 30 18:20:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165456 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1314272ili; Thu, 30 May 2019 11:21:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqynG8DL+fbjhasAelq6YMVMETpSv1v2qTu5p6fnkLwSDSArVr92rJGT58pkQjcOd4KaRkhq X-Received: by 2002:a17:90a:6505:: with SMTP id i5mr3116288pjj.13.1559240479715; Thu, 30 May 2019 11:21:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559240479; cv=none; d=google.com; s=arc-20160816; b=tE59DWsMAAiuzXSuizaziWc++Kn6mAkrtGgNmysXGciUGQign0KFh65JsMUrTUeWz6 20EfpYNVKwuDfzKKRAz1rchuwe6rYsV9kMlE55a1B6n9akrwSG4hLkE2PqFdo7tsnyYq ocsegyVzaB5lrreItRIohKN8NPhr1JYw9UF0z21yYl8ZeNni4/8PclAXxkFASFKQZ+NW tOLfTo1bBAbn67WfS5lPbrDfJ4DvVfsxZOn/Tm5VdnWc8ek5fCRsHDP/YYpcD5UP9z2s nSkPzEQxA9NHMyJMepX7n8l6Myb3wGecbtU1jPmlnsTVkDykht0zw5TNpNfyMGu6jzC4 LGhg== 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=ExBErmLKvAHAcEzB9N5VayIpTNJEe2yiC9dz/BkkizE=; b=ORumwoKBL2rp2LcdlSUgB638E5tS2NVkiLV1lmAaZJb2pbfn3L4KQuV5aQyFmxAjPy H/O6gDq2cWS/bQ1ga2F/dl+rsWucod7fapBksPggW2oIGt5F8ibEWdg9FZliPZ6qFhec cP7gTgJ424sbRQZRle5h39LJM9CsQ+6txuSho21Q/tslbphWCVUC/L0N99QDV5lfcnjt VrHWd/LSJbFjkvTEypRanZR+q5DU1Y0IPStuajvHOLiM60ekGO0fJPexwAEvzF6ed6sM IMQZ7z0Tfuw5r/KFoAXiB79jDX/pANakakYv4tAQWJdWjP4hfrCKExE84KHNQYSCtyMZ 79lQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=DcysaYWn; 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 g1si328360pgd.425.2019.05.30.11.21.19; Thu, 30 May 2019 11:21:19 -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=DcysaYWn; 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 S1726863AbfE3SVB (ORCPT + 30 others); Thu, 30 May 2019 14:21:01 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:39258 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726779AbfE3SU6 (ORCPT ); Thu, 30 May 2019 14:20:58 -0400 Received: by mail-lj1-f194.google.com with SMTP id a10so3791444ljf.6 for ; Thu, 30 May 2019 11:20:57 -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=ExBErmLKvAHAcEzB9N5VayIpTNJEe2yiC9dz/BkkizE=; b=DcysaYWnCA1gnUMQaWDrdM5fQsKXmvdSPN7uBZWkhioCiDLFa/PZca+gwzO2ODZUGu BeqQ+XolNN1zZDMTBmlKogUA2ykS1A4uAec4bRAsZhEtEMqU59dDLFjPagim1uxmY0lL mYZK46TUMEvcTcJPNwOjwXTifyAGBy+Sf6AWebORVwLTh5xL5ZEd8YUB1gdlmYUz/HUN hrG5hxWv80I9c88FHZtuPOuKMIQY+GL7Pf5NNtewzWkmUTEa/0ufXtD0h/glN9glpD6N KvdKGzssnzlj4lACSGsq3eQP9WVFBfMKqdFZIwUMep/1p/kimoUqfozrxCBUHF9SNaD+ WadQ== 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=ExBErmLKvAHAcEzB9N5VayIpTNJEe2yiC9dz/BkkizE=; b=hKlhWbYA5ACpOl6qC0ZP0FSbUwuQQrELx6Ljcj4ZCAsYq1QeXFVFWquR+08vwgczw/ kehu4YvFvpKhqFmz+jMHtnkNF0GcTQbQWAGfWiaQeKHJON7oi8bWxBEYf9kqAH/3I56G R5Ovsz6ENNXIiG9BtKBizSFPby/3u1CdjoPx1kgcmoyxW5IV8OJlLsG5QOLCODpADdET fuhxTbIjoxyujQdT1CgoecgKhlf5/x0u2p09SYQLk7dGbuKXKTjbqAVdORQl9fARmR+G uJRONx4r7HcFKQC7fE4KIGlvDNFiynDHxAEXmodrREZrH1PvcEet4Sl/JRIx4AUvnWTx 4bAg== X-Gm-Message-State: APjAAAVuvHfur/iLQUKC1T5zVh3d1+6cxntKbQM5fOTrV5T/CGwZRSBv 5lJ06W4bZLpaP5LsLCkClYMtkA== X-Received: by 2002:a2e:8555:: with SMTP id u21mr2920911ljj.133.1559240456396; Thu, 30 May 2019 11:20:56 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id v7sm388946lfe.11.2019.05.30.11.20.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 11:20:55 -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 v2 net-next 5/7] net: ethernet: ti: davinci_cpdma: add dma mapped submit Date: Thu, 30 May 2019 21:20:37 +0300 Message-Id: <20190530182039.4945-6-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190530182039.4945-1-ivan.khoronzhuk@linaro.org> References: <20190530182039.4945-1-ivan.khoronzhuk@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 | 88 ++++++++++++++++++++----- drivers/net/ethernet/ti/davinci_cpdma.h | 2 + 2 files changed, 75 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c index 35bf14d8e7af..7f89b2299f05 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.c +++ b/drivers/net/ethernet/ti/davinci_cpdma.c @@ -125,6 +125,15 @@ struct cpdma_chan { u32 rate; }; +struct submit_info { + struct cpdma_chan *chan; + int directed; + void *token; + void *data; + int flags; + int len; +}; + struct cpdma_control_info { u32 reg; u32 shift, mask; @@ -176,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; @@ -1002,10 +1013,12 @@ static void __cpdma_chan_submit(struct cpdma_chan *chan, } } -int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data, - int len, int directed) +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; unsigned long flags; @@ -1037,16 +1050,22 @@ int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data, chan->stats.runt_transmit_buff++; } - buffer = dma_map_single(ctlr->dev, data, len, chan->dir); - ret = dma_mapping_error(ctlr->dev, buffer); - if (ret) { - cpdma_desc_free(ctlr->pool, desc, 1); - ret = -EINVAL; - goto unlock_ret; - } - mode = CPDMA_DESC_OWNER | CPDMA_DESC_SOP | CPDMA_DESC_EOP; - cpdma_desc_to_port(chan, mode, directed); + cpdma_desc_to_port(chan, mode, si->directed); + + if (si->flags & CPDMA_DMA_EXT_MAP) { + buffer = (dma_addr_t)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); + ret = -EINVAL; + goto unlock_ret; + } + } /* Relaxed IO accessors can be used here as there is read barrier * at the end of write sequence. @@ -1055,9 +1074,9 @@ int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data, writel_relaxed(buffer, &desc->hw_buffer); writel_relaxed(len, &desc->hw_len); writel_relaxed(mode | len, &desc->hw_mode); - writel_relaxed((uintptr_t)token, &desc->sw_token); + 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); @@ -1072,6 +1091,38 @@ int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data, return ret; } +int cpdma_chan_submit(struct cpdma_chan *chan, void *token, void *data, int len, + int directed) +{ + struct submit_info si; + + si.chan = chan; + si.token = token; + si.data = data; + si.len = len; + si.directed = directed; + si.flags = 0; + + return cpdma_chan_submit_si(&si); +} +EXPORT_SYMBOL_GPL(cpdma_chan_submit); + +int cpdma_chan_submit_mapped(struct cpdma_chan *chan, void *token, + dma_addr_t data, int len, int directed) +{ + struct submit_info si; + + si.chan = chan; + si.token = token; + si.data = (void *)data; + si.len = len; + si.directed = directed; + si.flags = CPDMA_DMA_EXT_MAP; + + return cpdma_chan_submit_si(&si); +} +EXPORT_SYMBOL_GPL(cpdma_chan_submit_mapped); + bool cpdma_check_free_tx_desc(struct cpdma_chan *chan) { struct cpdma_ctlr *ctlr = chan->ctlr; @@ -1097,10 +1148,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 10376062dafa..8f6f27185c63 100644 --- a/drivers/net/ethernet/ti/davinci_cpdma.h +++ b/drivers/net/ethernet/ti/davinci_cpdma.h @@ -77,6 +77,8 @@ 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_process(struct cpdma_chan *chan, int quota); From patchwork Thu May 30 18:20:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Khoronzhuk X-Patchwork-Id: 165454 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp1313999ili; Thu, 30 May 2019 11:21:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoFAmBWUMz1a13BPiKU2InYpnQyO4n72JTHHx4HrffSHApTQYp0zC+SzlfPFLbs9+bUE8G X-Received: by 2002:a65:62cc:: with SMTP id m12mr4873007pgv.237.1559240463606; Thu, 30 May 2019 11:21:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559240463; cv=none; d=google.com; s=arc-20160816; b=TpZsLmpHNLBfygiD05jCE/vt4qzSQRGwzQUuHJmDPrtNNtN0cYax9MucrtAReCiPJN YwuIN7ZU9A94aIspnA/QPNxqRV1fKrnJqbBrYSSGViEdcdOpHBdpsWeP3FcEly2w0l9+ yei3BWLUfEhMZTFioC1u/GM+flAk4S1Cvt03bd9JfHDA22Tn4t0SzYLckYkgaUPRyzZE 4engyJ6chYx2rhV9fxR2Ekc/ZP3ZYCx9gPCNS3wFlT/KCP9wTCsH/4BMWmrYza1F2y/h HvNFYCqPMtuf5knW3VPckeU15tZXjbhpBMokwOf3ZP8TGcWPfW8Eqc0SCYnCHEGQ5slP u13Q== 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=VwtitAHrkRTmSXybjYU2tYI3XhcpB8SZvJGlF0k7LR8=; b=dxncH+jilH1A+yd+ChvpWLe24vGwq8qcz1wUMphyJQskMywZObUk2nHCgxXOk6Whyc D9l+WrJSWqFkePrzoX/qA0OsYLgSm7eIeu9Py3ygcYUM+1GQpHylkBFyuTPlccVmjTow bOJZd69KsshW+10/FcuFNBCzUu+5DoDnGM6jJXvucV89EX8pyU490rTqRllHZgLcPCya nBwlA9OMWzdCRcBnvp2KaXPtLfvZhiCO0HJBMCNxvFI5lld4VcZKAwKkTqy5nj/bkw4j 2Mh2ZdaZlkKB9zv54ZzD9c7gPerxftKgN4Sq4yROYYIn5hBIMk/l+1ciRGiTkw+cN/3h ktjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BDljY3oU; 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 v19si3673102plo.413.2019.05.30.11.21.03; Thu, 30 May 2019 11:21:03 -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=BDljY3oU; 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 S1726819AbfE3SVC (ORCPT + 30 others); Thu, 30 May 2019 14:21:02 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:34318 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726800AbfE3SVA (ORCPT ); Thu, 30 May 2019 14:21:00 -0400 Received: by mail-lj1-f196.google.com with SMTP id j24so7049913ljg.1 for ; Thu, 30 May 2019 11:20:58 -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=VwtitAHrkRTmSXybjYU2tYI3XhcpB8SZvJGlF0k7LR8=; b=BDljY3oUWcpSunX+BtsT3CUu8PlMz94C8FclzAwWRJkbl78QD3AXsjwE75dUI2Dqyg npYb2IV6svaRmO83F/ZPNySqRcy7YvA2+rlK2mI1mNNnH8+G4yara9URDlhWf+vqC+vS fZpWNJgofl1agt//ekdfueAUnvx9u3YirGyFAg1D1qzOkX9cz2Mi/b8IAdfAIt388pmL zDKPYy7xDfR6YPvMmWx32IPsyEo1ATPjq3neS6BAUd9+05qBGraq5mYLanHSBrHCWPXP 33Nz7aHrB08n9cDUEE4Q6usnwQZKe9aXG0iVSrmMsTlNoKL/ds+J9OcxxafkW3bc7JOo Fe0w== 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=VwtitAHrkRTmSXybjYU2tYI3XhcpB8SZvJGlF0k7LR8=; b=A41Ea/V0e2CRYJZIQwrMec8/N1uJXGUS+3Mq7XENrRvHSVR6YYJm4qCn1AtvH65xNW Jlayi9AgSQH51x3T0ZPgQaNEQgqHAlRPvAsgiBTaiBw4lEgIk3JyqmJsuqgE8LtGjkLb uHSLJveHr5L+usRr7+SWy+FeC3zMASiRWUD9gju7GZ4HpFJQ8LjlcD2s6Lfln8Swb/FB P9N3OjTl9F7Y6ieHXP1TO5ElaCh8H1dZsrALUzwj9AdS+PVcp1gvLsK5XZu4TZ/H0rAZ pEHk7d0AO++FHWnhSx7dDrfmWjucIWj1MIGrbhYwQlUoEX/lUwqFmm1LE2qsky/1mmJB TbVw== X-Gm-Message-State: APjAAAXhq/NNq/mvYn5FOLB4qEPqUcV/PYOEqHSShFGjssyfpPyaeFh5 wKxOPL54aIZQagsFCTk0qKoezA== X-Received: by 2002:a2e:9bc5:: with SMTP id w5mr3077209ljj.87.1559240457629; Thu, 30 May 2019 11:20:57 -0700 (PDT) Received: from localhost.localdomain (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id v7sm388946lfe.11.2019.05.30.11.20.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 May 2019 11:20:57 -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 v2 net-next 6/7] net: ethernet: ti: davinci_cpdma: return handler status Date: Thu, 30 May 2019 21:20:38 +0300 Message-Id: <20190530182039.4945-7-ivan.khoronzhuk@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190530182039.4945-1-ivan.khoronzhuk@linaro.org> References: <20190530182039.4945-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 c260bb32aacf..1a7c4818c890 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;