From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by mail.toke.dk (Postfix) with ESMTPS id AE04DA34E21 for ; Mon, 23 Oct 2023 20:31:22 +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=20230601 header.b=AcdBhCdc Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1c9d4e38f79so25533745ad.2 for ; Mon, 23 Oct 2023 11:31:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1698085881; x=1698690681; darn=xdp-project.net; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=wPnBqAKtu7qfmlWwJUK17l0J3rYG4g6m8kBJfqHBWcI=; b=AcdBhCdcJh+44hewhdpirINU7dO2gKBrCG6WvWqIdxH0mGrkuXF+mYlPZsLcQYgSa4 3YE0gNgWKiHJkVwpW+WY0J6zRPv0zlOipco9V1vyZit8XNBBPQq8wJAzBiN0RrjUeVAF /pR2QcTBmQvzcDu36OCxN4c0S96u/+2Rp0TFhMbaIFCy5w3cgwDHsBQJUCEZqL88UT5l B74knneVDDrdHAcEcZ0DA0c3aV0E3v7u6IYQF9f/MCvebZvCBiSFDCEtf3WhbgRazkzB T2lGRVIbZjPt+5fKirnSx3pHA6NsUiyQFHSC/0vHBq1GEVRwTF4il9X6UwYysTdi4OB3 OM9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698085881; x=1698690681; 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=wPnBqAKtu7qfmlWwJUK17l0J3rYG4g6m8kBJfqHBWcI=; b=pxclamC4NR6DQZvGlBEfH7DTUQd33vyhPNv8uZWZTlyUhdTjs4SJYBbtw1YsmIoO2Y oXeBmwHcQ1wqIVqnPvTveJ1vsuZHxDyr4NGwKAU74Dhl2boGTdp5U9ilujpY2UOyNQBX VRq+ImB+j+zgQvBDAEvz4A6Z3DviV1TduLEBhsTZ9T06cT6dM8t3819v6WUkbvq2NX+Z 2H8NkbmO/Q6uZmidCTa5utIGa4bWersTNluKT1Kb07SRFUrecXVrrIARvuP3DxDn4qgV nIDqqipDax7QxDqr+60KantWEJ3axOar0gvo602jkb17/3hDiIeanVvtiE7Rudf+PLAa LuRw== X-Gm-Message-State: AOJu0YxFC+Bf1VstOUgNVnCJd/shDFhpGrQIK6bHVMRBs9u+rXs2MFOJ 5QglfpkvxFwAmQAaLuHYxZX/KIM= X-Google-Smtp-Source: AGHT+IG+XvWazJNWN5c7NNnSVe2lrJdtfauU4L3Qq2lLLg+ikexd9cjwYoiGnk2YQZO9DGNX/ZkD6CQ= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:902:968d:b0:1ca:7a4c:834d with SMTP id n13-20020a170902968d00b001ca7a4c834dmr206694plp.13.1698085881006; Mon, 23 Oct 2023 11:31:21 -0700 (PDT) Date: Mon, 23 Oct 2023 11:31:19 -0700 In-Reply-To: Mime-Version: 1.0 References: <20231019174944.3376335-1-sdf@google.com> <20231019174944.3376335-12-sdf@google.com> Message-ID: From: Stanislav Fomichev To: Magnus Karlsson Content-Type: text/plain; charset="utf-8" Message-ID-Hash: M42436RJSQI6RRP4OMCIEFSKKO3EZWFH X-Message-ID-Hash: M42436RJSQI6RRP4OMCIEFSKKO3EZWFH X-MailFrom: 3-bs2ZQMKCXwxiklttlqj.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, kuba@kernel.org, toke@kernel.org, willemb@google.com, dsahern@kernel.org, magnus.karlsson@intel.com, bjorn@kernel.org, maciej.fijalkowski@intel.com, hawk@kernel.org, yoong.siang.song@intel.com, netdev@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.8 Precedence: list Subject: [xdp-hints] Re: [PATCH bpf-next v4 11/11] xsk: Document tx_metadata_len layout List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On 10/23, Magnus Karlsson wrote: > On Thu, 19 Oct 2023 at 19:50, Stanislav Fomichev wrote: > > > > - how to use > > - how to query features > > - pointers to the examples > > > > Signed-off-by: Stanislav Fomichev > > --- > > Documentation/networking/index.rst | 1 + > > Documentation/networking/xsk-tx-metadata.rst | 77 ++++++++++++++++++++ > > 2 files changed, 78 insertions(+) > > create mode 100644 Documentation/networking/xsk-tx-metadata.rst > > > > diff --git a/Documentation/networking/index.rst b/Documentation/networking/index.rst > > index 2ffc5ad10295..f3c2566d6cad 100644 > > --- a/Documentation/networking/index.rst > > +++ b/Documentation/networking/index.rst > > @@ -122,6 +122,7 @@ Refer to :ref:`netdev-FAQ` for a guide on netdev development process specifics. > > xfrm_sync > > xfrm_sysctl > > xdp-rx-metadata > > + xsk-tx-metadata > > > > .. only:: subproject and html > > > > diff --git a/Documentation/networking/xsk-tx-metadata.rst b/Documentation/networking/xsk-tx-metadata.rst > > new file mode 100644 > > index 000000000000..b7289f06745c > > --- /dev/null > > +++ b/Documentation/networking/xsk-tx-metadata.rst > > @@ -0,0 +1,77 @@ > > +================== > > +AF_XDP TX Metadata > > +================== > > + > > +This document describes how to enable offloads when transmitting packets > > +via :doc:`af_xdp`. Refer to :doc:`xdp-rx-metadata` on how to access similar > > +metadata on the receive side. > > + > > +General Design > > +============== > > + > > +The headroom for the metadata is reserved via ``tx_metadata_len`` in > > +``struct xdp_umem_reg``. The metadata length is therefore the same for > > +every socket that shares the same umem. The metadata layout is a fixed UAPI, > > +refer to ``union xsk_tx_metadata`` in ``include/uapi/linux/if_xdp.h``. > > +Thus, generally, the ``tx_metadata_len`` field above should contain > > +``sizeof(union xsk_tx_metadata)``. > > + > > +The headroom and the metadata itself should be located right before > > +``xdp_desc->addr`` in the umem frame. Within a frame, the metadata > > +layout is as follows:: > > + > > + tx_metadata_len > > + / \ > > + +-----------------+---------+----------------------------+ > > + | xsk_tx_metadata | padding | payload | > > + +-----------------+---------+----------------------------+ > > + ^ > > + | > > + xdp_desc->addr > > + > > +An AF_XDP application can request headrooms larger than ``sizeof(struct > > +xsk_tx_metadata)``. The kernel will ignore the padding (and will still > > +use ``xdp_desc->addr - tx_metadata_len`` to locate > > +the ``xsk_tx_metadata``). For the frames that shouldn't carry > > +any metadata (i.e., the ones that don't have ``XDP_TX_METADATA`` option), > > +the metadata area is ignored by the kernel as well. > > + > > +The flags field enables the particular offload: > > + > > +- ``XDP_TX_METADATA_TIMESTAMP``: requests the device to put transmission > > + timestamp into ``tx_timestamp`` field of ``union xsk_tx_metadata``. > > +- ``XDP_TX_METADATA_CHECKSUM``: requests the device to calculate L4 > > + checksum. ``csum_start`` specifies byte offset of there the checksumming > > nit: of there -> where > > > + should start and ``csum_offset`` specifies byte offset where the > > + device should store the computed checksum. > > +- ``XDP_TX_METADATA_CHECKSUM_SW``: requests checksum calculation to > > + be done in software; this mode works only in ``XSK_COPY`` mode and > > + is mostly intended for testing. Do not enable this option, it > > + will negatively affect performance. > > + > > +Besides the flags above, in order to trigger the offloads, the first > > +packet's ``struct xdp_desc`` descriptor should set ``XDP_TX_METADATA`` > > +bit in the ``options`` field. Also not that in a multi-buffer packet > > nit: not -> note Thank you for both, will fix!