From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by mail.toke.dk (Postfix) with ESMTPS id 4847EA1B33F for ; Fri, 21 Jul 2023 00:14:38 +0200 (CEST) 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=20221208 header.b=2+e4wlpB Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-53fa00ed93dso963355a12.3 for ; Thu, 20 Jul 2023 15:14:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1689891277; x=1690496077; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ntAPyIcMbj4x2RdnE4QWJ5FnaEQOtZId8qQ+eDe+suw=; b=2+e4wlpBPGsDpkyw9CWHUhUURlWwywpD9mLf9/RBs1kZ8I0EHM8GFP0kqUHjLBcgnz GFnq5AWj7J7LoL/lcihBMgvlTppJkp978bgwidS+pSzERqqVPAmvnYZ1OOqW6B53PHI2 a4PqOh82SNuR6MmQUuG7pjquwvMJYeyp2xYQ2/Z1XjWtTEwbz4n/SOBasMM4oQvuOxF8 L706QxaAyVlF9w+Ey+PMmd5QG7b5M4ASTxtsrm335ulibPXAOXznvyKyPxnj9GXEw0P8 w+Fxp4fl8CEj2VR+2GsBGpU5KuYDPb11xZ475wFcZTzvOGhKFSqmxcWJpsZVhmQy8EDI Sd9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689891277; x=1690496077; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ntAPyIcMbj4x2RdnE4QWJ5FnaEQOtZId8qQ+eDe+suw=; b=eRjj2Xykdm+OiWrV4iUXe9yLMVfR8UCgyjAEUSfZPqm1a/bi8N9HWNu0CUo2CDi4Ef FTIu6crvw69+FN/tcMiuDTgY4EWnjzbizWNkDQfwOxPPY0rvbZqKn2pzDCsVibYZPA2S MUrUsmiS/gJ9UMxwI00XPFkMemES5bhx9Y2I0V15fOz9AGLmP/g9ucdLIsgs1ZvN1KO3 BdskyNLa56NtOEEkqUX5hGPKqHR15n/E9U6XJfWrcAI4rok90MhJEqbO/37HPN3kL/su sHlOFBE7tWEeHmBNN7cR1wyhnqA6QVJutj8pjxd2kEvgWZVMw0k5BcUjdy1lbwtIgvc8 k+VQ== X-Gm-Message-State: ABy/qLYUR0cjL2o/LZCbX9xf0GveqTkWVWxB6XKMGRtqiPdyMGRCaQGc LTe1BvwVLfXPbTzfk2fZ5xNRBYo= X-Google-Smtp-Source: APBJJlEMcGX2ZkdXhS334WMXGI7SezRrsjD1b1FT17XrD7DpNm7fvdr043HoswPQetYExgcds8n3skw= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a63:7448:0:b0:557:531e:34c7 with SMTP id e8-20020a637448000000b00557531e34c7mr27pgn.11.1689891276612; Thu, 20 Jul 2023 15:14:36 -0700 (PDT) Date: Thu, 20 Jul 2023 15:14:34 -0700 In-Reply-To: <20230719183734.21681-22-larysa.zaremba@intel.com> Mime-Version: 1.0 References: <20230719183734.21681-1-larysa.zaremba@intel.com> <20230719183734.21681-22-larysa.zaremba@intel.com> Message-ID: From: Stanislav Fomichev To: Larysa Zaremba Content-Type: text/plain; charset="utf-8" Message-ID-Hash: QBUDNTUM6ZUCXSOGWXPHN4MIUWJBYB5H X-Message-ID-Hash: QBUDNTUM6ZUCXSOGWXPHN4MIUWJBYB5H X-MailFrom: 3zLG5ZAMKCUMxiklttlqj.htr2iu-mnsyx2iu-uwtojhy.sjy@flex--sdf.bounces.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 , Alexander Lobakin , Magnus Karlsson , Maryam Tahhan , xdp-hints@xdp-project.net, netdev@vger.kernel.org X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v3 21/21] selftests/bpf: check checksum state in xdp_metadata List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 07/19, Larysa Zaremba wrote: > Verify, whether kfunc in xdp_metadata test correctly returns partial > checksum status and offsets. > > Signed-off-by: Larysa Zaremba Acked-by: Stanislav Fomichev > --- > .../selftests/bpf/prog_tests/xdp_metadata.c | 30 +++++++++++++++++++ > .../selftests/bpf/progs/xdp_metadata.c | 6 ++++ > 2 files changed, 36 insertions(+) > > diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c > index 6665cf0c59cc..c0ce66703696 100644 > --- a/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c > +++ b/tools/testing/selftests/bpf/prog_tests/xdp_metadata.c > @@ -47,6 +47,7 @@ > > #define XDP_RSS_TYPE_L4 BIT(3) > #define VLAN_VID_MASK 0xfff > +#define XDP_CHECKSUM_PARTIAL BIT(3) > > struct xsk { > void *umem_area; > @@ -168,6 +169,32 @@ static void refill_rx(struct xsk *xsk, __u64 addr) > } > } > > +struct partial_csum_info { > + __u16 csum_start; > + __u16 csum_offset; > +}; > + > +static bool assert_checksum_ok(struct xdp_meta *meta) > +{ > + struct partial_csum_info *info; > + u32 csum_start, csum_offset; > + > + if (!ASSERT_EQ(meta->rx_csum_status, XDP_CHECKSUM_PARTIAL, > + "rx_csum_status")) > + return false; > + > + csum_start = sizeof(struct ethhdr) + sizeof(struct iphdr); > + csum_offset = offsetof(struct udphdr, check); > + info = (void *)&meta->rx_csum_info; > + > + if (!ASSERT_EQ(info->csum_start, csum_start, "rx csum_start")) > + return false; > + if (!ASSERT_EQ(info->csum_offset, csum_offset, "rx csum_offset")) > + return false; > + > + return true; > +} > + > static int verify_xsk_metadata(struct xsk *xsk) > { > const struct xdp_desc *rx_desc; > @@ -229,6 +256,9 @@ static int verify_xsk_metadata(struct xsk *xsk) > if (!ASSERT_EQ(meta->rx_vlan_proto, VLAN_PID, "rx_vlan_proto")) > return -1; > > + if (!assert_checksum_ok(meta)) > + return -1; > + > xsk_ring_cons__release(&xsk->rx, 1); > refill_rx(xsk, comp_addr); > > diff --git a/tools/testing/selftests/bpf/progs/xdp_metadata.c b/tools/testing/selftests/bpf/progs/xdp_metadata.c > index d3111649170e..e79667a0726e 100644 > --- a/tools/testing/selftests/bpf/progs/xdp_metadata.c > +++ b/tools/testing/selftests/bpf/progs/xdp_metadata.c > @@ -26,6 +26,9 @@ extern int bpf_xdp_metadata_rx_hash(const struct xdp_md *ctx, __u32 *hash, > extern int bpf_xdp_metadata_rx_vlan_tag(const struct xdp_md *ctx, > __u16 *vlan_tci, > __be16 *vlan_proto) __ksym; > +extern int bpf_xdp_metadata_rx_csum(const struct xdp_md *ctx, > + enum xdp_csum_status *csum_status, > + union xdp_csum_info *csum_info) __ksym; > > SEC("xdp") > int rx(struct xdp_md *ctx) > @@ -62,6 +65,9 @@ int rx(struct xdp_md *ctx) > bpf_xdp_metadata_rx_hash(ctx, &meta->rx_hash, &meta->rx_hash_type); > bpf_xdp_metadata_rx_vlan_tag(ctx, &meta->rx_vlan_tci, &meta->rx_vlan_proto); > > + bpf_xdp_metadata_rx_csum(ctx, &meta->rx_csum_status, > + (void *)&meta->rx_csum_info); > + > return bpf_redirect_map(&xsk, ctx->rx_queue_index, XDP_PASS); > } > > -- > 2.41.0 >