From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 030F4C54EBE for ; Thu, 12 Jan 2023 22:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232292AbjALWcG (ORCPT ); Thu, 12 Jan 2023 17:32:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240503AbjALWbg (ORCPT ); Thu, 12 Jan 2023 17:31:36 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD7E637266 for ; Thu, 12 Jan 2023 14:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1673562602; 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=AmmMTMTkl1SpATAvKbKhhENq0+Dt4nDr+jehSO4eUlc=; b=DXZnzuNfihmqAr9GUGiqoymcbTIuNU19yeQN6ZdQZix/TBB3Xz3RcktDQgkzz2bSGNRC7S 2fmY3251VhAvn0QChh4rTQHuqH1hGrTpyB5RnJPymduUum9LW95vUS4qhaI7kucmQcxO1y 2ensxCDUhw/sxJJx8FEC1y5mBk0rJ+o= Received: from mail-ej1-f71.google.com (mail-ej1-f71.google.com [209.85.218.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-367-7d5g5STfM7izumR4gK8oog-1; Thu, 12 Jan 2023 17:30:00 -0500 X-MC-Unique: 7d5g5STfM7izumR4gK8oog-1 Received: by mail-ej1-f71.google.com with SMTP id ga21-20020a1709070c1500b007c171be7cd7so13846242ejc.20 for ; Thu, 12 Jan 2023 14:30:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AmmMTMTkl1SpATAvKbKhhENq0+Dt4nDr+jehSO4eUlc=; b=5i+BNitg9PgiNvrp2fERMkbhw1EtlicbTZeEwlMVQApSfMH0T3JQoiT8SWig2taicc MfE3fUO1MqSCsz7esNSl6sNmK3jg779Ehqq63NUQumtUk9N4ikchPefBNEwqX27n9SEm A7Eh5J/y/0N1UkoSlswUP8jzs1yHLwTjfLEWp18KhVcRIwpvx6h4sz2DS15kHuJJT+HL v+Y4/obl9sfFdQlfzf+/kr13s+iigzOJLkT8E+61zlO83ibhJ5F39wcC+rnB59RDsGIb EyjwCFCs7L0buNh4Oqcmjx4vLaBLoD5rk9SNnGz2oVW5OcD+UoKk9M43MRyO9VwsfqS1 TJJg== X-Gm-Message-State: AFqh2kpmYrL/9TP1BX+W9XCv//Asr1tbCCaYqCuVzuote/OnVt9Sxi6j KoNjRo3GTMbQyJwm5aJlumEfp8dakv2YgEwAN29JVVTpfubLqEKHHyGWyNeBADonVfeyNHO4pCX wRcM4hLMLxZWb2dru X-Received: by 2002:a17:906:9f20:b0:84d:43a0:7090 with SMTP id fy32-20020a1709069f2000b0084d43a07090mr15422511ejc.77.1673562599654; Thu, 12 Jan 2023 14:29:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXsqPdHBhI5sdFZhQI7ZFU9LyJiPErvoKHj1tV1uSh9/yzeA+17qJ9uEVoWX2vLXSimcX2vkQQ== X-Received: by 2002:a17:906:9f20:b0:84d:43a0:7090 with SMTP id fy32-20020a1709069f2000b0084d43a07090mr15422479ejc.77.1673562599344; Thu, 12 Jan 2023 14:29:59 -0800 (PST) Received: from alrua-x1.borgediget.toke.dk ([45.145.92.2]) by smtp.gmail.com with ESMTPSA id c10-20020a17090618aa00b0084d14646fd9sm7751190ejf.165.2023.01.12.14.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Jan 2023 14:29:58 -0800 (PST) Received: by alrua-x1.borgediget.toke.dk (Postfix, from userid 1000) id 45232900731; Thu, 12 Jan 2023 23:29:58 +0100 (CET) From: Toke =?utf-8?Q?H=C3=B8iland-J=C3=B8rgensen?= To: Stanislav Fomichev Cc: Tariq Toukan , bpf@vger.kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, haoluo@google.com, jolsa@kernel.org, Tariq Toukan , Saeed Mahameed , David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org Subject: Re: [xdp-hints] Re: [PATCH bpf-next v7 15/17] net/mlx5e: Introduce wrapper for xdp_buff In-Reply-To: References: <20230112003230.3779451-1-sdf@google.com> <20230112003230.3779451-16-sdf@google.com> <87k01rfojm.fsf@toke.dk> <87h6wvfmfa.fsf@toke.dk> X-Clacks-Overhead: GNU Terry Pratchett Date: Thu, 12 Jan 2023 23:29:58 +0100 Message-ID: <87edrzfkt5.fsf@toke.dk> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Stanislav Fomichev writes: > On Thu, Jan 12, 2023 at 1:55 PM Toke H=C3=B8iland-J=C3=B8rgensen wrote: >> >> Toke H=C3=B8iland-J=C3=B8rgensen writes: >> >> > Stanislav Fomichev writes: >> > >> >> On Thu, Jan 12, 2023 at 12:07 AM Tariq Toukan wrote: >> >>> >> >>> >> >>> >> >>> On 12/01/2023 2:32, Stanislav Fomichev wrote: >> >>> > From: Toke H=C3=B8iland-J=C3=B8rgensen >> >>> > >> >>> > Preparation for implementing HW metadata kfuncs. No functional cha= nge. >> >>> > >> >>> > Cc: Tariq Toukan >> >>> > Cc: Saeed Mahameed >> >>> > Cc: John Fastabend >> >>> > Cc: David Ahern >> >>> > Cc: Martin KaFai Lau >> >>> > Cc: Jakub Kicinski >> >>> > Cc: Willem de Bruijn >> >>> > Cc: Jesper Dangaard Brouer >> >>> > Cc: Anatoly Burakov >> >>> > Cc: Alexander Lobakin >> >>> > Cc: Magnus Karlsson >> >>> > Cc: Maryam Tahhan >> >>> > Cc: xdp-hints@xdp-project.net >> >>> > Cc: netdev@vger.kernel.org >> >>> > Signed-off-by: Toke H=C3=B8iland-J=C3=B8rgensen >> >>> > Signed-off-by: Stanislav Fomichev >> >>> > --- >> >>> > drivers/net/ethernet/mellanox/mlx5/core/en.h | 1 + >> >>> > .../net/ethernet/mellanox/mlx5/core/en/xdp.c | 3 +- >> >>> > .../net/ethernet/mellanox/mlx5/core/en/xdp.h | 6 +- >> >>> > .../ethernet/mellanox/mlx5/core/en/xsk/rx.c | 25 ++++---- >> >>> > .../net/ethernet/mellanox/mlx5/core/en_rx.c | 58 +++++++++----= ------ >> >>> > 5 files changed, 50 insertions(+), 43 deletions(-) >> >>> > >> >>> > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/driver= s/net/ethernet/mellanox/mlx5/core/en.h >> >>> > index 2d77fb8a8a01..af663978d1b4 100644 >> >>> > --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h >> >>> > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h >> >>> > @@ -469,6 +469,7 @@ struct mlx5e_txqsq { >> >>> > union mlx5e_alloc_unit { >> >>> > struct page *page; >> >>> > struct xdp_buff *xsk; >> >>> > + struct mlx5e_xdp_buff *mxbuf; >> >>> >> >>> In XSK files below you mix usage of both alloc_units[page_idx].mxbuf= and >> >>> alloc_units[page_idx].xsk, while both fields share the memory of a u= nion. >> >>> >> >>> As struct mlx5e_xdp_buff wraps struct xdp_buff, I think that you just >> >>> need to change the existing xsk field type from struct xdp_buff *xsk >> >>> into struct mlx5e_xdp_buff *xsk and align the usage. >> >> >> >> Hmmm, good point. I'm actually not sure how it works currently. >> >> mlx5e_alloc_unit.mxbuf doesn't seem to be initialized anywhere? Toke, >> >> am I missing something? >> > >> > It's initialised piecemeal in different places; but yeah, we're mixing >> > things a bit... >> > >> >> I'm thinking about something like this: > > Seems more invasive? I don't care much tbf, but what's wrong with > keeping 'xdp_buff xsk' member and use it consistently? Yeah, it's more invasive, but it's also more consistent with the non-xsk path where every usage of struct xdp_buff is replaced with the wrapping struct? Both will work, I suppose (in fact I think the resulting code will be more or less identical), so it's more a matter of which one is easier to read and where we put the type-safety-breaking casts. I can live with either one (just note you'll have to move the 'mxbuf->rq' initialisation next to the one for mxbuf->cqe for yours, but that's probably fine too). Let's see which way Tariq prefers... -Toke