Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3300141ybi; Fri, 5 Jul 2019 05:12:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvfyNPT5dChAky3cdaHFKoM9Vp7H8nm4/eQDSy1Qh45/rrFfjOUE3q/ULRuMD9cFebzeeV X-Received: by 2002:a17:902:1e6:: with SMTP id b93mr5208971plb.295.1562328773856; Fri, 05 Jul 2019 05:12:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562328773; cv=none; d=google.com; s=arc-20160816; b=TDkfSOCUS7xdGqSoAvSg6rJ9EOeqxBswTABThK8W4AuQB6spoo/UjbIzL++dDe0mwW HeqyPONnqodRTU8Pb5fI1dN9lug2d2VCba2LdlI+3GppiqTcqnR1ZbV3adzukvdZlbTS 5M9T4B2Y2HrWhsCUzy+CbUwEkC0rUHB109U9YQJtqmYPFNlT2WMFih9sdU7a60ejHo8q PSEJItf3uJn2t5qQD9MI5vSEfIpCVPJWmUuyjFNGLdkZuAwzwCFX+DCcY/pfcXB7cXFB IeWKLifP7pRJrBPOxuY0JEBlgdfvZClZZUCvddZaf13mhnXb2Q8TQCD1abnD8uNEd6RS 0AlA== 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=Bwcx4Wrt/iXqyeT5/Qi9DpMy8WMhSBFAEuk3MBcreWs=; b=mtgTHW95QT+wb8+ey+aaOZDJIm8HpncGJkYZr1oByL6l35/zguZ6WS1eE+XjsiqqpI PDeCU6VUt3XBh7h/ckNcsQlHsG5VtGlRtydNEwhvE4xNuGSxhLKsjhH/eZC+6BEl3p8h cGiRlAXdOrjvnUI1azCjAQuaORMTIepfQo3OVIq0WjOfkPDCjV1KFE+DzRfRYhhzlvwg crlYwyi44S9dZoFKNWn2S68E964ImD+glfDjHhqVSTcQZK/QavcewrC2pNC/ix8KjYRx 4Xh2VqxDSSgy0Op9ulf7IPfuKHlvLUIphst9SQxN6rMHTfJL0ODRiEjaDAW5A+42OQxA dYoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=PDLasy29; 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 h38si8384706plb.149.2019.07.05.05.12.38; Fri, 05 Jul 2019 05:12:53 -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=PDLasy29; 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 S1727326AbfGEMBV (ORCPT + 99 others); Fri, 5 Jul 2019 08:01:21 -0400 Received: from mail-lj1-f194.google.com ([209.85.208.194]:35892 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726593AbfGEMBU (ORCPT ); Fri, 5 Jul 2019 08:01:20 -0400 Received: by mail-lj1-f194.google.com with SMTP id i21so9049318ljj.3 for ; Fri, 05 Jul 2019 05:01: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=Bwcx4Wrt/iXqyeT5/Qi9DpMy8WMhSBFAEuk3MBcreWs=; b=PDLasy29nXLVksqy7cLdFBOQ9g2BdW8VmAJB2XAM3FVzzudxYV1GYTh4MxhCTAhdRY I2eU7LywN45QJfSknrIMQcUhoFzKrFlbBXQDiWO6sbH9bRermdHBGkNFBwbt3Dey734R MLg9SOSXh8SW1giZ1GMV975NOYl7iUiaPi6QMePfFqIhiC2aHaE7zyV3pFtm3ncn2AqN GzHLIRxgQtIoaBvYzUNMsHlhw7MtFqXZhGDAnNf38XhdqKak8Af/TBkCAeaEEwI22phG Cdi8EBwpTxIl071uBoKLN5i/SLqStnx6Qba+01fW4FVWgH5SiFipPCRQ2pD5Zxr73ip0 IjCA== 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=Bwcx4Wrt/iXqyeT5/Qi9DpMy8WMhSBFAEuk3MBcreWs=; b=SneTXJB1i2SF+4JCNOM7QIQz5vAe3YxYoGskLm4tO5PCkbCDC2W0VeGizDdxtnDi/A b2bv8sYmCnZrD9MY09QICEUGKAPvuQPLp5A3/wF8j5JHbU2v/87yo9JYKA14ljjW5EKe 44pgTUAWvSI9M9hExGC79yKA3TdNG3ut0262Z1R2KzJN96FEj/vUm2AC3EMj2KtKDWZc Ge/KCb1m64Aal7pwJPKqx1gidKCof6NG/f8PQjKrkDj169bgpx615ravAChPC+hf7QAg WeQcwM/5BGeOOTABpsTs6yByibB1A9JEFKIw2vZt3h1oW0UT7vnypTCK0ZlrYG6AuH0w GIJg== X-Gm-Message-State: APjAAAUJmjnr9Mg9DE7IQgbz0PFv0nnx4k+65iDF8sYjDYg59R2+Dv8r g+NfVS/8rZCJHkN4jODRLOF5tg== X-Received: by 2002:a2e:3a13:: with SMTP id h19mr1946573lja.220.1562328079191; Fri, 05 Jul 2019 05:01:19 -0700 (PDT) Received: from khorivan (59-201-94-178.pool.ukrtel.net. [178.94.201.59]) by smtp.gmail.com with ESMTPSA id h18sm1351494lfc.40.2019.07.05.05.01.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Jul 2019 05:01:18 -0700 (PDT) Date: Fri, 5 Jul 2019 15:01:16 +0300 From: Ivan Khoronzhuk To: Jesper Dangaard Brouer Cc: grygorii.strashko@ti.com, davem@davemloft.net, ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com Subject: Re: [PATCH v7 net-next 5/5] net: ethernet: ti: cpsw: add XDP support Message-ID: <20190705120114.GA3587@khorivan> Mail-Followup-To: Jesper Dangaard Brouer , grygorii.strashko@ti.com, davem@davemloft.net, ast@kernel.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, ilias.apalodimas@linaro.org, netdev@vger.kernel.org, daniel@iogearbox.net, jakub.kicinski@netronome.com, john.fastabend@gmail.com References: <20190704231406.27083-1-ivan.khoronzhuk@linaro.org> <20190704231406.27083-6-ivan.khoronzhuk@linaro.org> <20190705131354.15a9313c@carbon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190705131354.15a9313c@carbon> 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, Jul 05, 2019 at 01:13:54PM +0200, Jesper Dangaard Brouer wrote: >On Fri, 5 Jul 2019 02:14:06 +0300 >Ivan Khoronzhuk wrote: > >> +static int cpsw_xdp_tx_frame(struct cpsw_priv *priv, struct xdp_frame *xdpf, >> + struct page *page) >> +{ >> + struct cpsw_common *cpsw = priv->cpsw; >> + struct cpsw_meta_xdp *xmeta; >> + struct cpdma_chan *txch; >> + dma_addr_t dma; >> + int ret, port; >> + >> + xmeta = (void *)xdpf + CPSW_XMETA_OFFSET; >> + xmeta->ndev = priv->ndev; >> + xmeta->ch = 0; >> + txch = cpsw->txv[0].ch; >> + >> + port = priv->emac_port + cpsw->data.dual_emac; >> + if (page) { >> + dma = page_pool_get_dma_addr(page); >> + dma += xdpf->data - (void *)xdpf; > >This code is only okay because this only happens for XDP_TX, where you >know this head-room calculation will be true. The "correct" >calculation of the head-room would be: > > dma += xdpf->headroom + sizeof(struct xdp_frame); > >The reason behind not using xdpf pointer itself as "data_hard_start", >is to allow struct xdp_frame to be located in another memory area. My assumption was based on: struct xdp_frame *convert_to_xdp_frame(struct xdp_buff *xdp) { ... xdp_frame = xdp->data_hard_start; ... xdp_frame->headroom = headroom - sizeof(*xdp_frame); ... } But agree, it doesn't contradict the reason in question. So, better use proposed variant. Will check and do this in v8 a little later: dma += xdpf->headroom + sizeof(struct xdp_frame); >This will be useful for e.g. AF_XDP transmit, or other zero-copy >transmit to go through ndo_xdp_xmit() (as we don't want userspace to >be-able to e.g. "race" change xdpf->len during transmit/DMA-completion). > > >> + ret = cpdma_chan_submit_mapped(txch, cpsw_xdpf_to_handle(xdpf), >> + dma, xdpf->len, port); >> + } else { >> + if (sizeof(*xmeta) > xdpf->headroom) { >> + xdp_return_frame_rx_napi(xdpf); >> + return -EINVAL; >> + } >> + >> + ret = cpdma_chan_submit(txch, cpsw_xdpf_to_handle(xdpf), >> + xdpf->data, xdpf->len, port); >> + } > > > >-- >Best regards, > Jesper Dangaard Brouer > MSc.CS, Principal Kernel Engineer at Red Hat > LinkedIn: http://www.linkedin.com/in/brouer -- Regards, Ivan Khoronzhuk