From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by mail.toke.dk (Postfix) with ESMTPS id B10939B33C9 for ; Fri, 4 Nov 2022 19:22:04 +0100 (CET) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=NlOjSeut Received: by mail-il1-x129.google.com with SMTP id m15so3015499ilq.2 for ; Fri, 04 Nov 2022 11:22:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=K1k4WN2r7t/52mL+ugQRSlpNfDTjZcSRsmfM/st8EfQ=; b=NlOjSeut/Chjx9weuZnDn0wAec7Z5R9jiU7mFJRiMWsKCli0GmxJHUCin/Oh+0s/0k bDnY42jcAwS3M1Sa49AL8vAviZi1gszjv+ollhC317fRIvcrtXznA35Fy2RLkWe061J0 +FZryw8HiQVOvM6prKMFJVSez5nyYshL2L4TWOpyWXC57f15w1BkqMHiJapPoViSiDM4 1TMDTPYMWSFUOacJyaITm/BxSs2hYg3t4SHZrkLnsjUMmCc1LOQUJSvFKYej1POjAG2t RSUqKuk3cX6pAsgnWoTiGqQndg5t26yTCwkrmKl9lR45vXkBhUm5R1+KBTXN/pwfA5Fk tqSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=K1k4WN2r7t/52mL+ugQRSlpNfDTjZcSRsmfM/st8EfQ=; b=vU6j2PfQOi9lRftKuJT4AQZPefvL2Dn3Cy4ey83hsqM6+gYH8nDoxHnJ33+mPXND1c Vwu9/mJLV1pWfbighn634lzjg7YZN46+3IwxQnWt7w15+s9+3VIGAbiI37BI1xZOXwBj 0vOV0EMc5e2Ov90l0d8zCN+nrTnKOiF45wgTfIOlwrnJUl6pp0gF+YjznFFTg1ud4zOJ DIKXc0oK9fKKhmt5/0pZeEfi/UAJ7lT5nO+/64eZLjYxsPTiSebsqf/mpfZBjWxGp9ue 2CZrO6luX/TSKVXp+5eoPMaCb3DrPWVGeEr8rw6N75D6fk1Xgr4/Dw05fRTIqEmWT234 f0wQ== X-Gm-Message-State: ACrzQf0sBzNcdsiETERm8ed0mscrcTf2VOlizNQP5Z9paJqeOTvjYndP 08DVuiqb30ctHc80rybHvc+dvZnlPftDRhgJimibQQ== X-Google-Smtp-Source: AMsMyM70/MrBu8d7nQRFy0qecyRBPBOyVm88lmIP3GwrqmytkGF4i+QrzWrr4vvTceF6CORiXQSlRTFz/GZDSOsUdf4= X-Received: by 2002:a92:d3ca:0:b0:2ff:fb6a:5c38 with SMTP id c10-20020a92d3ca000000b002fffb6a5c38mr22312218ilh.259.1667586120229; Fri, 04 Nov 2022 11:22:00 -0700 (PDT) MIME-Version: 1.0 References: <20221104032532.1615099-1-sdf@google.com> <20221104032532.1615099-11-sdf@google.com> <20221104143547.3575615-1-alexandr.lobakin@intel.com> In-Reply-To: <20221104143547.3575615-1-alexandr.lobakin@intel.com> From: Stanislav Fomichev Date: Fri, 4 Nov 2022 11:21:47 -0700 Message-ID: To: Alexander Lobakin Content-Type: text/plain; charset="UTF-8" Message-ID-Hash: V3PHIZWLSJVBFMA3T4YEDQSWWOEVBELP X-Message-ID-Hash: V3PHIZWLSJVBFMA3T4YEDQSWWOEVBELP X-MailFrom: sdf@google.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: 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, David Ahern , Jakub Kicinski , Willem de Bruijn , Jesper Dangaard Brouer , Anatoly Burakov , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org X-Mailman-Version: 3.3.5 Precedence: list Subject: [xdp-hints] Re: [RFC bpf-next v2 10/14] ice: Support rx timestamp metadata for xdp List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, Nov 4, 2022 at 7:38 AM Alexander Lobakin wrote: > > From: Stanislav Fomichev > Date: Thu,3 Nov 2022 20:25:28 -0700 > > > COMPILE-TESTED ONLY! > > > > 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: Stanislav Fomichev > > --- > > drivers/net/ethernet/intel/ice/ice.h | 5 ++ > > drivers/net/ethernet/intel/ice/ice_main.c | 1 + > > drivers/net/ethernet/intel/ice/ice_txrx.c | 75 +++++++++++++++++++++++ > > 3 files changed, 81 insertions(+) > > > > diff --git a/drivers/net/ethernet/intel/ice/ice.h b/drivers/net/ethernet/intel/ice/ice.h > > index f88ee051e71c..c51a392d64a4 100644 > > --- a/drivers/net/ethernet/intel/ice/ice.h > > +++ b/drivers/net/ethernet/intel/ice/ice.h > > @@ -925,6 +925,11 @@ int ice_open_internal(struct net_device *netdev); > > int ice_stop(struct net_device *netdev); > > void ice_service_task_schedule(struct ice_pf *pf); > > > > +struct bpf_insn; > > +struct bpf_patch; > > +void ice_unroll_kfunc(const struct bpf_prog *prog, u32 func_id, > > + struct bpf_patch *patch); > > + > > /** > > * ice_set_rdma_cap - enable RDMA support > > * @pf: PF struct > > diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c > > index 1f27dc20b4f1..8ddc6851ef86 100644 > > --- a/drivers/net/ethernet/intel/ice/ice_main.c > > +++ b/drivers/net/ethernet/intel/ice/ice_main.c > > @@ -9109,4 +9109,5 @@ static const struct net_device_ops ice_netdev_ops = { > > .ndo_xdp_xmit = ice_xdp_xmit, > > .ndo_xsk_wakeup = ice_xsk_wakeup, > > .ndo_get_devlink_port = ice_get_devlink_port, > > + .ndo_unroll_kfunc = ice_unroll_kfunc, > > }; > > diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c > > index 1b6afa168501..e9b5e883753e 100644 > > --- a/drivers/net/ethernet/intel/ice/ice_txrx.c > > +++ b/drivers/net/ethernet/intel/ice/ice_txrx.c > > @@ -7,6 +7,7 @@ > > #include > > #include > > #include > > +#include > > #include > > #include > > #include > > @@ -1098,8 +1099,80 @@ ice_is_non_eop(struct ice_rx_ring *rx_ring, union ice_32b_rx_flex_desc *rx_desc) > > > > struct ice_xdp_buff { > > struct xdp_buff xdp; > > + struct ice_rx_ring *rx_ring; > > + union ice_32b_rx_flex_desc *rx_desc; > > }; > > > > +void ice_unroll_kfunc(const struct bpf_prog *prog, u32 func_id, > > + struct bpf_patch *patch) > > +{ > > + if (func_id == xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_EXPORT_TO_SKB)) { > > + return xdp_metadata_export_to_skb(prog, patch); > > Hey, > > FYI, our team wants to write a follow-up patch with ice support > added, not like a draft, more of a mature code. I'm thinking of > calling ice C function which would process Rx descriptors from > that BPF code from the unrolling callback -- otherwise, > implementing a couple hundred C code lines from ice_txrx_lib.c > would be a bit too much :D Sounds good! I would gladly drop all/most of the driver changes for the non-rfc posting :-) I'll probably have a mlx4 one because there is a chance I might find HW, but the rest I'll drop most likely. (they are here to show how the driver changes might look like, hence compile-tested only) Btw, does it make sense to have some small xsk selftest binary that can be used to test the metadata with the real device? The one I'm having right now depends on veth/namespaces; having a similar one for the real hardware to qualify it sounds useful? Something simple that sets up af_xdp for all queues, divers some traffic, and exposes to the userspace consumer all the info about frame metadata... Or maybe there is something I can reuse already? > > + } else if (func_id == xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_RX_TIMESTAMP_SUPPORTED)) { > > + /* return true; */ > > + bpf_patch_append(patch, BPF_MOV64_IMM(BPF_REG_0, 1)); > > + } else if (func_id == xdp_metadata_kfunc_id(XDP_METADATA_KFUNC_RX_TIMESTAMP)) { > > [...] > > > -- > > 2.38.1.431.g37b22c650d-goog > > Thanks, > Olek