Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3323434ybi; Fri, 5 Jul 2019 05:36:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqwApNNJzhVnI/NFoYVjD8zC/WjPnCAGd/anzsLwKXJsxcd+iCOJZn1I1e8at40s6jtIhjmf X-Received: by 2002:a17:902:ac1:: with SMTP id 59mr5471429plp.168.1562330178442; Fri, 05 Jul 2019 05:36:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562330178; cv=none; d=google.com; s=arc-20160816; b=yDpj7aPtXTb9NHkDrgfmYCciJgebikHJIRwfJCZ2iGraxb7d3KHluBkbimq8TqlHBn GP3I+5LEJf/89YMGYe42K+RNTgh/KWOZ561Y/zELdovSGU90SmxrnW2rLBjcL9TP7JDR hZw5y2CwbuF0KWf6JNGH+GCUhQ5WWIRB5vvdNJVB29IueTLtQPRNZ6MnjErXdP8wJQXx VBEQF2o4P0ERtoTJZXu2kNt0JbyXwbC//wqjJVLdl+Rb4bg1MJPEFeWODwGRKHXNMcWO 3ZnljuEYZkMu2HcEOAyeElFnNDOm0JNBT8hQX9YzGl6ZldDA8jym/J5ZtIHydfH5hpBv CKRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=QWM/f0zux9/u5Lvz++qvZqRsCQ+isXb/yHnHRTmkHos=; b=MToqqRTttQv+fBxxkxQ0FPRDY7cco5pn87rpZvX6wHCTMLuLAgJPPsZ7cVIdK2yZoY dMS7Vl/7SgWRznLWM8YYFstpQAfuY4xpFp/jF43889/wv9O5PNJO6vY9zdbb8WhJcDPu 5S8RDVBOqilbseAuaYPfmKq/knpiWzaf3WA+ljhedYEB/Rwo9AnXMyPJCS5M8NgcwCfr 0tJP9U8kDY0trZi1+wSMJPWwe02VSLZTF3d5ylrdoqgRnSr2NMhze1ibjRendnkqlkDs 71U1WZKOLow1oO77pc9gHcFOWhg7Es0NH8kLzGCSsxfjLl1u9DAepOrsBGzzq/Kn6fst e22w== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o30si9293140pgl.575.2019.07.05.05.36.02; Fri, 05 Jul 2019 05:36:18 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728030AbfGELOH (ORCPT + 99 others); Fri, 5 Jul 2019 07:14:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40716 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727066AbfGELOH (ORCPT ); Fri, 5 Jul 2019 07:14:07 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5538F34CF; Fri, 5 Jul 2019 11:14:06 +0000 (UTC) Received: from carbon (ovpn-200-17.brq.redhat.com [10.40.200.17]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F6ED7F76E; Fri, 5 Jul 2019 11:13:56 +0000 (UTC) Date: Fri, 5 Jul 2019 13:13:54 +0200 From: Jesper Dangaard Brouer To: Ivan Khoronzhuk 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, brouer@redhat.com Subject: Re: [PATCH v7 net-next 5/5] net: ethernet: ti: cpsw: add XDP support Message-ID: <20190705131354.15a9313c@carbon> In-Reply-To: <20190704231406.27083-6-ivan.khoronzhuk@linaro.org> References: <20190704231406.27083-1-ivan.khoronzhuk@linaro.org> <20190704231406.27083-6-ivan.khoronzhuk@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Fri, 05 Jul 2019 11:14:06 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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