Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2743079rwl; Thu, 13 Apr 2023 10:12:34 -0700 (PDT) X-Google-Smtp-Source: AKy350aXjr30D+gaLHhkpx466bYGMVAIxk/xkK8Rvv8QAsIVLVWFlKvumoBDgqtiyqw8e3XQoPzq X-Received: by 2002:a17:903:24f:b0:1a1:dd05:39fe with SMTP id j15-20020a170903024f00b001a1dd0539femr3851791plh.4.1681405953750; Thu, 13 Apr 2023 10:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681405953; cv=none; d=google.com; s=arc-20160816; b=yVkVyiEHhrAkI50NEillHZfVseJiCLJ1o88sLMy0WsusM81jXkfpkC9pGHZ/3q45lg 4t9rcVcgUlI6fnwGXPU+OxFo7ctrlUPX0/R+opimF3TFm2Wpu8Qlz1fi0O2LvZGGK/gz KCMEqoVg5iMe2GvM51OdiLV/opEs/SON0K/AGfCMCl8TMuO64WX0Z9A4KEMfOqy97vjO sAqUIFyMVYaRQgmP04P9IGCNpfqTma4HBJSp2jnaZgn6+IUsqEaBrBAUfL3EQ1SDLjQU Gn6qFCFm1RHiTbJDGLp3x3ma7CRUIINi7YtklbnMSuYKod4V7aIVdE8wBP+y/ToBhL4G mh8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :to:content-language:subject:cc:user-agent:mime-version:date :message-id:from:dkim-signature; bh=O5dv4XAyW10/07F5EnvMKRPv3TLobZcUlN4bcbi+kaA=; b=OktmldfnQWB8wUZHarQVw+pGMv8/sVYoZJv97gx0DU+uY4WNtZavwbheH2a9SWW5mN N9IB2opVV473zBPU69JZOokCF1K0s2lrgvle0OtDTBR09VmXmSdtHEnHbzexu6GCDgJd JBNOe9C0s/906fR8BYTYcY26GVku+q4pbaqShDK5+eqUKJy1SjolmltkE7qdqy01r7xk n64PO6n0eB4N/HWIpnXEiv1oZ4QqaaMeVry6PvoJbO5Jb0BAKPPVhEJ6mFb2cDLfeBzc QmMG18uU3EGiznH7DRRzMrZOrpAlUfT5lZKeQMvco+8MNlaQpWYr9xINAIc1w/LNU+f0 q52A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fIKGaOGa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ij6-20020a170902ab4600b001a60d1d4c96si2338959plb.241.2023.04.13.10.12.20; Thu, 13 Apr 2023 10:12:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=fIKGaOGa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230333AbjDMRKg (ORCPT + 99 others); Thu, 13 Apr 2023 13:10:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230305AbjDMRKb (ORCPT ); Thu, 13 Apr 2023 13:10:31 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A90C349FF for ; Thu, 13 Apr 2023 10:09:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681405789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=O5dv4XAyW10/07F5EnvMKRPv3TLobZcUlN4bcbi+kaA=; b=fIKGaOGaC1XkGwTcSQHcS3m60Bv41dD9LtF4cbZHk6+e+p1jXwFqsI7PHV/ekDQeJ+2ssG ripKB7xBdfYc2zTVoZ4Ui5esMIhJ5qBqQnYob5XZc7wm+j/L6+M6tTrV8o7I69JMncpxvd +NtF1Y800XKQO3mYm2fybC+9OlwOdeA= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-7MMqoOqMOcGrFdZmwxQk-A-1; Thu, 13 Apr 2023 13:09:48 -0400 X-MC-Unique: 7MMqoOqMOcGrFdZmwxQk-A-1 Received: by mail-ed1-f69.google.com with SMTP id z34-20020a509e25000000b00504ed11e0c5so3424028ede.1 for ; Thu, 13 Apr 2023 10:09:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681405787; x=1683997787; h=content-transfer-encoding:in-reply-to:references:to :content-language:subject:cc:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=O5dv4XAyW10/07F5EnvMKRPv3TLobZcUlN4bcbi+kaA=; b=ApQ15Xshd5oUXSVpW5CDTLhavD1Q+uDDy0NJ3s2l44MCc04bV0YqGmMh6I0xF4ZY6y SwGkxfmJ+k5/N5/2107WWmVfRFPzpmI1f+S24vBxAbtD2OLFG0DN04XsfJbWNpSzdmOA W0nf55bTyApVui6JF4yvvzgUd3CL0jFZBUB4KeG5QG2nPWzfKNBURhsV2YXgZrBBfU/k 3joJfYDMWiaOxEG54W00vNlwG8uynqp5dd8EGW2RszlzeV06O4HniOHVvF3Fo/VBiTRO EY//hqtedyG2eaK456ggh2eMvDOgwYYuG/+oxa8YyBczZs0bEd99UZKHL1n8ygh8CQbL /nVg== X-Gm-Message-State: AAQBX9eKXiSwtxw4NPDpNKxHovtr8dSDkEVZRvnhZYQsKUTguNEXOQpR A6SfJoE0A128Zvvd5uTwS49CAR49jFIu5dmru1ikngyisllyMET4Hu8EQpTqyK8OwqL5xMSpDH1 rUGJEAoRsZIAHTlVOkPfEnSI6 X-Received: by 2002:a17:906:2a56:b0:94c:6762:e20d with SMTP id k22-20020a1709062a5600b0094c6762e20dmr2839493eje.12.1681405787185; Thu, 13 Apr 2023 10:09:47 -0700 (PDT) X-Received: by 2002:a17:906:2a56:b0:94c:6762:e20d with SMTP id k22-20020a1709062a5600b0094c6762e20dmr2839449eje.12.1681405786887; Thu, 13 Apr 2023 10:09:46 -0700 (PDT) Received: from [192.168.42.222] (194-45-78-10.static.kviknet.net. [194.45.78.10]) by smtp.gmail.com with ESMTPSA id p8-20020a17090664c800b0094b360a281dsm1221750ejn.123.2023.04.13.10.09.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 13 Apr 2023 10:09:46 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: <203ab7d9-3695-f734-92b5-503118444108@redhat.com> Date: Thu, 13 Apr 2023 19:09:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Cc: brouer@redhat.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, xdp-hints@xdp-project.net Subject: Re: [PATCH net-next v4 1/3] net: stmmac: introduce wrapper for struct xdp_buff Content-Language: en-US To: Song Yoong Siang , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Stanislav Fomichev , Alexander Duyck , Ong Boon Leong References: <20230413032541.885238-1-yoong.siang.song@intel.com> <20230413032541.885238-2-yoong.siang.song@intel.com> In-Reply-To: <20230413032541.885238-2-yoong.siang.song@intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/04/2023 05.25, Song Yoong Siang wrote: > Introduce struct stmmac_xdp_buff as a preparation to support XDP Rx > metadata via kfuncs. > > Reviewed-by: Jacob Keller > Signed-off-by: Song Yoong Siang > --- > drivers/net/ethernet/stmicro/stmmac/stmmac.h | 4 ++++ > .../net/ethernet/stmicro/stmmac/stmmac_main.c | 18 +++++++++--------- > 2 files changed, 13 insertions(+), 9 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h > index 3d15e1e92e18..ac8ccf851708 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h > @@ -92,6 +92,10 @@ struct stmmac_rx_buffer { > dma_addr_t sec_addr; > }; > > +struct stmmac_xdp_buff { > + struct xdp_buff xdp; > +}; > + > struct stmmac_rx_queue { > u32 rx_count_frames; > u32 queue_index; > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index d7fcab057032..6ffce52ca837 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -5188,9 +5188,9 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) > int status = 0, coe = priv->hw->rx_csum; > unsigned int next_entry = rx_q->cur_rx; > enum dma_data_direction dma_dir; > + struct stmmac_xdp_buff ctx = {}; This code trick {} will zero out the struct. Is this done purpose and really needed? On x86_64 this unfortunately generates an asm instruction: rep stos A repeated store string operation, for zeroing out memory, which is slow. (Because[1] it supports be suspended by an exception or interrupt, which requires it to store/restore CPU flags). [1] https://www.felixcloutier.com/x86/rep:repe:repz:repne:repnz#tbl-4-22 > unsigned int desc_size; > struct sk_buff *skb = NULL; > - struct xdp_buff xdp; > int xdp_status = 0; > int buf_sz; > > @@ -5311,17 +5311,17 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) > dma_sync_single_for_cpu(priv->device, buf->addr, > buf1_len, dma_dir); > > - xdp_init_buff(&xdp, buf_sz, &rx_q->xdp_rxq); > - xdp_prepare_buff(&xdp, page_address(buf->page), > + xdp_init_buff(&ctx.xdp, buf_sz, &rx_q->xdp_rxq); > + xdp_prepare_buff(&ctx.xdp, page_address(buf->page), > buf->page_offset, buf1_len, false); > > - pre_len = xdp.data_end - xdp.data_hard_start - > + pre_len = ctx.xdp.data_end - ctx.xdp.data_hard_start - > buf->page_offset; > - skb = stmmac_xdp_run_prog(priv, &xdp); > + skb = stmmac_xdp_run_prog(priv, &ctx.xdp); > /* Due xdp_adjust_tail: DMA sync for_device > * cover max len CPU touch > */ > - sync_len = xdp.data_end - xdp.data_hard_start - > + sync_len = ctx.xdp.data_end - ctx.xdp.data_hard_start - > buf->page_offset; > sync_len = max(sync_len, pre_len); > > @@ -5331,7 +5331,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) > > if (xdp_res & STMMAC_XDP_CONSUMED) { > page_pool_put_page(rx_q->page_pool, > - virt_to_head_page(xdp.data), > + virt_to_head_page(ctx.xdp.data), > sync_len, true); > buf->page = NULL; > priv->dev->stats.rx_dropped++; > @@ -5359,7 +5359,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) > > if (!skb) { > /* XDP program may expand or reduce tail */ > - buf1_len = xdp.data_end - xdp.data; > + buf1_len = ctx.xdp.data_end - ctx.xdp.data; > > skb = napi_alloc_skb(&ch->rx_napi, buf1_len); > if (!skb) { > @@ -5369,7 +5369,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) > } > > /* XDP program may adjust header */ > - skb_copy_to_linear_data(skb, xdp.data, buf1_len); > + skb_copy_to_linear_data(skb, ctx.xdp.data, buf1_len); > skb_put(skb, buf1_len); > > /* Data payload copied into SKB, page ready for recycle */