From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by mail.toke.dk (Postfix) with ESMTPS id E8A7CA33AA0 for ; Fri, 20 Oct 2023 19:49:46 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=PmHO+ei0 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c9fa869a63so8402355ad.0 for ; Fri, 20 Oct 2023 10:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697824185; x=1698428985; darn=xdp-project.net; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=A5RsvVPeK0HG7sfE95t4B3GsOpnKWLyM2VBqKfrYhJQ=; b=PmHO+ei0ZOBRblyocqnR5qARLO54W0I9gZ0U2H1bD6AFHg/delqH6Qy7AD2j/tMs/y HCcdqGUUdoXBo5VtXK3n56XqnLnPitqBKkwzFAuMdt/+ER4O4UD+9t+eotOAdlaxsLZj LYWTma8k+l/PH0hI1QEDkhYMOOXiGdLLnknpR3PZpU4XJy9vDez+Sx6aVA0n7hB+/v+s ucktcvdSKAgNVLDJ+QzG+lOh8aG+B25Lz9cznPRex1oGooXtcOw3TYVp9N5+Mmh50/Ve CE3jjh/N/a2SQvxe1CfnczgEaYq4a+zerYkYNV0OOvXw9t3JOVM1Zj8seQA9WrV+y3+O nIJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697824185; x=1698428985; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=A5RsvVPeK0HG7sfE95t4B3GsOpnKWLyM2VBqKfrYhJQ=; b=f3yCOg491ivAYlbeqHu5DtC2+NBDlLDgZCaHx9j7CoGeG/OG+3Z1RvjZQPm42Q/1wJ TepbtCyXCO8WKbHdiLAqRfX/BLa7GndB38/NHuWVUJxwNNVe/aFT0Q83lI/feNaEPH+5 PuOszzp+mOYpi6BDvNhrjZjtIW6t2MsyLMFol0Q6B6jH6WVVKWbGuDTc9rnIocY82kc8 XxVzBEF9vFpdrqMDFN0fXi09thZvZ/IkdZ+sHaQtfsSu5yQYvGEaPACdMo15Ry37uw6v dxQKmHmp8gc0ywFheFstCTOatHHu8YT3RkmMDjjCLUua8mU2taHcAAyyRzdnIZaZds7E cxFA== X-Gm-Message-State: AOJu0YwIJlnzCMbFOli+DTi9MVFEXMwXOwdfaKZVwOYZevOvQn6cTy0/ VWcaMXoSOcQmIRfoQCsHyL4= X-Google-Smtp-Source: AGHT+IFnz68PR5GXy3/PUKZX+fizAkSM9rw7oE4h4HRWFmkYlG0Adre5E2jREon0GalpZ47vUsiDKA== X-Received: by 2002:a17:903:11cc:b0:1c3:3363:8aea with SMTP id q12-20020a17090311cc00b001c333638aeamr2755996plh.61.1697824184869; Fri, 20 Oct 2023 10:49:44 -0700 (PDT) Received: from MacBook-Pro-49.local ([2620:10d:c090:400::4:821f]) by smtp.gmail.com with ESMTPSA id ix4-20020a170902f80400b001c74718f2f3sm1801104plb.119.2023.10.20.10.49.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Oct 2023 10:49:44 -0700 (PDT) Date: Fri, 20 Oct 2023 10:49:40 -0700 From: Alexei Starovoitov To: Stanislav Fomichev Message-ID: <20231020174940.gjubehkouns2hmgz@MacBook-Pro-49.local> References: <20231019174944.3376335-1-sdf@google.com> <20231019174944.3376335-3-sdf@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231019174944.3376335-3-sdf@google.com> Message-ID-Hash: 7VQM7WR5IZGZ2NDAC64D3VLFUKMDTKAM X-Message-ID-Hash: 7VQM7WR5IZGZ2NDAC64D3VLFUKMDTKAM X-MailFrom: alexei.starovoitov@gmail.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 02/11] xsk: Add TX timestamp and TX checksum offload support List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Thu, Oct 19, 2023 at 10:49:35AM -0700, Stanislav Fomichev wrote: > diff --git a/include/uapi/linux/if_xdp.h b/include/uapi/linux/if_xdp.h > index 2ecf79282c26..ecfd67988283 100644 > --- a/include/uapi/linux/if_xdp.h > +++ b/include/uapi/linux/if_xdp.h > @@ -106,6 +106,43 @@ struct xdp_options { > #define XSK_UNALIGNED_BUF_ADDR_MASK \ > ((1ULL << XSK_UNALIGNED_BUF_OFFSET_SHIFT) - 1) > > +/* Request transmit timestamp. Upon completion, put it into tx_timestamp > + * field of struct xsk_tx_metadata. > + */ > +#define XDP_TX_METADATA_TIMESTAMP (1 << 0) > + > +/* Request transmit checksum offload. Checksum start position and offset > + * are communicated via csum_start and csum_offset fields of struct > + * xsk_tx_metadata. > + */ > +#define XDP_TX_METADATA_CHECKSUM (1 << 1) > + > +/* Force checksum calculation in software. Can be used for testing or > + * working around potential HW issues. This option causes performance > + * degradation and only works in XDP_COPY mode. > + */ > +#define XDP_TX_METADATA_CHECKSUM_SW (1 << 2) > + > +struct xsk_tx_metadata { > + union { > + struct { > + __u32 flags; > + > + /* XDP_TX_METADATA_CHECKSUM */ > + > + /* Offset from desc->addr where checksumming should start. */ > + __u16 csum_start; > + /* Offset from csum_start where checksum should be stored. */ > + __u16 csum_offset; > + }; > + > + struct { > + /* XDP_TX_METADATA_TIMESTAMP */ > + __u64 tx_timestamp; > + } completion; > + }; > +}; Could you add a comment to above union that csum fields are consumed by the driver before it xmits the packet while timestamp is filled during xmit, so union doesn't prevent using both features simultaneously. It's clear from the example, but not obvious from uapi and the doc in patch 11 doesn't clarify it either. Also please add a name to csum part of the union like you did for completion. We've learned it the hard way with bpf_attr. All anon structs better have field name within a union. Helps extensibility (avoid conflicts) in the long term. Other than this the patch set looks great to me. With Saeed and Magnus acks we can take it in.