Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4112914ybi; Mon, 27 May 2019 11:22:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqxs6AcqV06N4tyE67YpsHuR3yWVhHzJ31ju0RriPe8YzJkhhdpv/fRH+MPb+2dtEb/bWWUx X-Received: by 2002:a65:5304:: with SMTP id m4mr31881981pgq.126.1558981360869; Mon, 27 May 2019 11:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558981360; cv=none; d=google.com; s=arc-20160816; b=DpO6n8TS45Z8B4ybI8TZW98IFSLAjLIOurEK9OciFTjWwiy7iE055YMuKUNVbJ+kxp CBtVupb2YYUWufhrE6IE3a8Ep/ib+qsiGffXPGJF+KSoU9c+DagLO90FYkt1b8q9lC7d tS7veGpcXebkpJ01eb9/vc4kZO6xWT3Hw+ilXcRNT80wC2B2cqyhVytDh8thCdXkTs2W MD/lRVtNuP48LlEJK+Py7siudZxXY9XbSXwelZQHAOJXkid3CKAMnLCQE4Vdrm47VCSq xWjPWKiktw8Qkk7cyuBiol2aa3bo+b0jQ4n9Wa+EE3Rumfy+lELAGCdfeebRFk8+kMXb B2CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:mail-followup-to :message-id:subject:cc:to:from:date:dkim-signature; bh=cIQmYr9qDMcXw/frZVuWSs4Z6gJsQGJv00LJLaCloGU=; b=HjOiN+0mOFlsaGW4k22dN5xDGJrWAYtn78/fFoIcaAWya5zav/Zg3cP5J3mZvdC4CR sv5s+e3EwJ3QETQhjgfodkpKTlmrdy8Zmgxwu8eepvAqLewYR10nuRwySu5/5wn1NPyM mvnHo7jCLcvXWDk1Fbu9LRG1/tgo41yPv1luaHezmxHeAjk3bmb3J/T7UX4/hw0dHYJK pRcbgMkfntWAK9mJtsTuv4zoGDf3ii0mRlCkqqrdn3xfVMAi4H58p3ozQdaHaPrwjNS6 KTD//65v+trlqdRmENDS00My4aY4ZmJ2e3O6Y8N3P2wXBBtziAPskLN4r8ttDIQVbp4P M5dA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=I08TnzUs; 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 h91si165320pje.38.2019.05.27.11.22.25; Mon, 27 May 2019 11:22: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=I08TnzUs; 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 S1727195AbfE0SVV (ORCPT + 99 others); Mon, 27 May 2019 14:21:21 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:34196 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726971AbfE0SVV (ORCPT ); Mon, 27 May 2019 14:21:21 -0400 Received: by mail-lf1-f65.google.com with SMTP id v18so12708765lfi.1 for ; Mon, 27 May 2019 11:21:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=cIQmYr9qDMcXw/frZVuWSs4Z6gJsQGJv00LJLaCloGU=; b=I08TnzUsf6VHmv0MXTkDHbfoBRdecoRH0TuiyGZxWw8T/dKfvmFxurJh24q+r49R1I uuBsAjEvsYuQVzOoOb3D/N7u7nOScU/WuvpJOoKOonbzLXeyUjVDwST+keiuS7+9Ep+c 9q3wN8GM8AMakM+zDHACUii5tQCDFhYO/FT9ju/fCN7i2H2AXkr/xmaXk4OsfwRXGrx9 SMfN0Yl8/YCWP4xc2fnnlx3W1HgrN9Etv+qHvLuC+kjaskSvPZkoZ+JxuICxIvBb8k8o s8FkfDAJ9B0HfHyZKf90/w/4Gk6FSEjX1O+4luIDGxWIbdEi5/l2iakNB0XR0tj79Qs2 50dg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=cIQmYr9qDMcXw/frZVuWSs4Z6gJsQGJv00LJLaCloGU=; b=cBVBjkfSXesU0xyeIZyLQ0IS1ojnYDKDakTB1XZOM5oOnkhEpFO+msfo63zxmtSFm3 6T+/fRMvbOhUESbHzylBmJ3KFKX4oDYw2EHO4vHQnt07Ml796NYitLHFSqNicX4Q7OQD PwHDZ1t5kEiEJI9v61HP0NRTYy4HirMYh555vqWm9iOW4k6PLjLKFEONuJLV943tKK+y Bg8i7qwsqvrzXSRrBS4yVlfemGLLKB4pCZlpkarTdgEHX1VBEZFCqTm+6ekfSbpBRreZ +JgYli3w50Y/MAVw+0YkaPK7F7f6dQA2Shxj5rh6Jw/MBM365PwkpI6z7XW7IT7t6xSi vWlQ== X-Gm-Message-State: APjAAAXbFUW6OTpwiHlQU2gCtfNd4w7c5GeMfENc+riyh0W6shsZZCAC 8vCTDsXIp+PHzVFYCUwwvNASqg== X-Received: by 2002:ac2:5595:: with SMTP id v21mr6577390lfg.54.1558981278784; Mon, 27 May 2019 11:21:18 -0700 (PDT) Received: from khorivan (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id w20sm2451515ljd.39.2019.05.27.11.21.17 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 May 2019 11:21:17 -0700 (PDT) Date: Mon, 27 May 2019 21:21:15 +0300 From: Ivan Khoronzhuk To: Ilias Apalodimas Cc: grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net, ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com Subject: Re: [PATCH net-next 3/3] net: ethernet: ti: cpsw: add XDP support Message-ID: <20190527182114.GB4246@khorivan> Mail-Followup-To: Ilias Apalodimas , grygorii.strashko@ti.com, hawk@kernel.org, davem@davemloft.net, ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, xdp-newbies@vger.kernel.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com References: <20190523182035.9283-1-ivan.khoronzhuk@linaro.org> <20190523182035.9283-4-ivan.khoronzhuk@linaro.org> <20190524110511.GA27885@apalos> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190524110511.GA27885@apalos> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 24, 2019 at 02:05:11PM +0300, Ilias Apalodimas wrote: >On Thu, May 23, 2019 at 09:20:35PM +0300, Ivan Khoronzhuk wrote: >> Add XDP support based on rx page_pool allocator, one frame per page. >> Page pool allocator is used with assumption that only one rx_handler >> is running simultaneously. DMA map/unmap is reused from page pool >> despite there is no need to map whole page. >> >> Due to specific of cpsw, the same TX/RX handler can be used by 2 >> network devices, so special fields in buffer are added to identify >> an interface the frame is destined to. Thus XDP works for both >> interfaces, that allows to test xdp redirect between two interfaces >> easily. >> >> XDP prog is common for all channels till appropriate changes are added >> in XDP infrastructure. >> >> Signed-off-by: Ivan Khoronzhuk >> --- >> drivers/net/ethernet/ti/Kconfig | 1 + >> drivers/net/ethernet/ti/cpsw.c | 555 ++++++++++++++++++++++--- >> drivers/net/ethernet/ti/cpsw_ethtool.c | 53 +++ >> drivers/net/ethernet/ti/cpsw_priv.h | 7 + >> 4 files changed, 554 insertions(+), 62 deletions(-) >> >> diff --git a/drivers/net/ethernet/ti/Kconfig b/drivers/net/ethernet/ti/Kconfig >> index bd05a977ee7e..3cb8c5214835 100644 >> --- a/drivers/net/ethernet/ti/Kconfig >> +++ b/drivers/net/ethernet/ti/Kconfig >> @@ -50,6 +50,7 @@ config TI_CPSW >> depends on ARCH_DAVINCI || ARCH_OMAP2PLUS || COMPILE_TEST >> select TI_DAVINCI_MDIO >> select MFD_SYSCON >> + select PAGE_POOL >> select REGMAP >> ---help--- >> This driver supports TI's CPSW Ethernet Switch. >> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c >> index 87a600aeee4a..274e6b64ea9e 100644 >> --- a/drivers/net/ethernet/ti/cpsw.c >> +++ b/drivers/net/ethernet/ti/cpsw.c >> @@ -31,6 +31,10 @@ >> #include >> #include >> #include >> +#include >> +#include >> +#include >> +#include >> >> #include [...] >> + start_free = 1; >> + continue; >> + } >> + >> + /* if refcnt > 1, page has been holding by netstack, it's pity, >> + * so put it to the ring to be consumed later when fast cash is >s/cash/cache > >> + * empty. If ring is full then free page by recycling as above. >> + */ >> + ret = ptr_ring_produce(&pool->ring, page); >> + if (ret) { >> + page_pool_recycle_direct(pool, page); >> + continue; >> + } >Although this should be fine since this part won't be called during the driver >init, i think i'd prefer unmapping the buffer and let the network stack free it, >instead of pushing it for recycling. The occurence should be pretty low, so >allocating a buffer every once in a while shouldn't have a noticeable >performance impact > Ok, I will leave previous version from RFC. -- Regards, Ivan Khoronzhuk