Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1185932lqd; Thu, 25 Apr 2024 08:13:05 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUHMT1iN3M2pdm4Xeu4L8uzigY8rXiSBc7P54QejfHzNiGRh6W6JTA7CuR+26Cck2uD89woZnmLk7OvCShuNV4egYZdUr3EiKzZYLyv1Q== X-Google-Smtp-Source: AGHT+IGdyXHk6012Ycgv7OcgPtTIsQ7sgsgCh1Xiw1MgezBXVUedO//SeBZYON1xL9DI3NFAap3j X-Received: by 2002:a05:6a21:3d94:b0:1a7:5721:7011 with SMTP id bj20-20020a056a213d9400b001a757217011mr6385307pzc.41.1714057985489; Thu, 25 Apr 2024 08:13:05 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714057985; cv=pass; d=google.com; s=arc-20160816; b=JaDDpEtHJ6xnROVjcyonIrmEwXb7Y/F4pA0TD3pOJTEWHIH99FJ3MyrKHbSlmH80Zj FFxr5/+BHIlwE6VwxPtpk7Q9jIMIVdCSXYlSpviRcxdOqNsFIfC4i+rdFcaS1fMaE540 7M92EeAWe5wPMFe2fPaTmh068DY7qvT8HpsON+iRTAzpaeDJTnnGd/zCHjQ7EjrnfWtt vH6plGatdt+McKjMaZ4a/bBkhxFMIPoxPH9RDqDVFS/OUv65PiP0CKe6I2S26kjWEyAU o8u5vYFiosPGFj3RpFUM1OraVvZzGJwsZJGJpf8LiUQxQlBbyIACPy7zgirHQXbi3p7u 8vQA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:references:in-reply-to :message-id:cc:to:from:date:dkim-signature; bh=7aCWY+qk5d2DEjGUd6wNU0MLhGO6MuLkRc4d4CIwvHY=; fh=e3GTyRcZWBvn69RPF+PAni6wLsyxexuVUzRtyS5uiRs=; b=deReZ1sVDVYCAf4JUD1upP2OqCPbffpaeGjY2/zaMyqqIw25X0tXUhJj3UCpbZ1mfk HUT3APMLrNGDlAhJ9F44tkz2SNvau8RHE7uMaOF/GkJr/4vxlBrwPbQ+p0kBhadGRznr +7NLAm2FTfIWCcamAGwtFY+rIjGLcRHyWvB7HEgM7hSs+N+H6cWq7gMN5JtvZnCaluMC KoxvtPLf4r63WMMz8DbI+hkV7VXoOC0n5qQnB1VlKPjmz4B0zMIJZNF1c3f329/4O8Sy ObRj4qRrYc/2W7p+WrM9igAGnwNgV7Qrz2RrkTNwxLfLFO7DqWz/7sonH79Ng2nOLp4Z 66dA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E1dI3voJ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-158732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id e21-20020a635015000000b006043a4aa84asi4562743pgb.324.2024.04.25.08.13.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 08:13:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=E1dI3voJ; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-158732-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158732-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 4AC9CB25D30 for ; Thu, 25 Apr 2024 14:43:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 92BFC14AD2F; Thu, 25 Apr 2024 14:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E1dI3voJ" Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EC4514A622; Thu, 25 Apr 2024 14:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714056171; cv=none; b=AAqBK21NnX8dvcdDZgkzjXAW9YzokXobQxWX2OHJBeeJ6tm17pcMV2tW8obM8gCACsP5cN4ZgV2txIGq7zmNk0URV2CuMPoXGvqoeNEfe2CwruBYCC4skc7dxKWcUM7l/UhDk5ytfUtQwT9M10/PDbe9UacdjCHIndv/33I+97I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714056171; c=relaxed/simple; bh=RLEWmqtBtrpZPVVfXoZ4Fx5SjHlhnjzmtiqohhXwtUc=; h=Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject: Mime-Version:Content-Type; b=WY3HHA+qK7NUPbvQojIJLf8ax7/1e4LGVHuDdR/Z7uBe/5Tf02Adkrqpc4k3EOnTm+i1geNbqyPJvMRRYmpR+aTyNP7l3yqe/WcfAflHFCdizQpxR8CJOx5cT2v+X0VtUzYBoDQgXPuwrhcASooHDi7075r6R1xagOobSFyDe5A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=E1dI3voJ; arc=none smtp.client-ip=209.85.167.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3c74a75d9adso748181b6e.0; Thu, 25 Apr 2024 07:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714056169; x=1714660969; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=7aCWY+qk5d2DEjGUd6wNU0MLhGO6MuLkRc4d4CIwvHY=; b=E1dI3voJcGZbAeG19/sgI4Fs+zzPv+pYt0yKJtYD42EYMkh7rzTceFKmsTpwzr+u7U YoQ+i2xLihd8dHzYFt5ulVf26CsEwFeIDLfmgTA7to7x/4CbhT+meUgMRQMh3f+mZA9n IIMDo8Kphu8z+mKnP7hEOwhpmCkLrfP9J6TwBDMM1iIBLvbg9gGMpOF2igw+89pUCtv0 +zkqGPA4KBIT4nWBr+9PBFrvcTgGeNmNvlmaZ/8BFtl1TeuFMk++PugPDo5dQkU8Ym6T tCXyvpaDv7+pm+s+rWrs+3vW8JUizC7c7gRhwv3VRWovVoKXx4/c+InlEg9kKiBcxvsr 3wwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714056169; x=1714660969; h=content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=7aCWY+qk5d2DEjGUd6wNU0MLhGO6MuLkRc4d4CIwvHY=; b=CWYZBx7/2VxguwKalomMtYAsfG12JM/RIeSR7GeFhXpx8ISLTXmWS3oXdqDnwYKgLf Y4ThSNl6m9gxHH2ACKaU5COK4q5TIbt+/mPfBZpCdveoHR8WHusCSzfE/AKhVZBh9B5F 6flSfmYsaf2p+OhihyrAG6x3ptC8zNGuZJOn1B0h0+j0Q1QSanP/5uuu/h13bBPa4c3H ZPg88rgbS7LDNI3GC1dKKyWc76O0VC4phVuK4rvDUJgmTW2BqL/1lyPueAb3oW8o/MM4 T0gnhOOOflwE8ok21FzOb12StmgVwBEm624kqNFQQ3dxsPMvZnreCUFBlJj41G4OChR1 bNnQ== X-Forwarded-Encrypted: i=1; AJvYcCUhF4Td7Nhy1dCskfTVbdLxiOtt5Y6LIs8IZLFjOk0GkT5MFTq7jbCqYC+IlvFj3CVnczCBIKzw5tt7pm5BMFFJdz5kTYm/PV4rt0NLVegCadZ6VR04+/btOPY1wQzoT7bGt/nHzPBI352Nz8+DpuS22PUp+IhEDElN X-Gm-Message-State: AOJu0Yx3tL3ruiul1Wlts1IeZExWLzglLdJFfiNXhUQUuH79icilBsFb UBNAXr0rm4by3DRLaJbZPpB1NpSBaSoypLfIHg0qegrXAR1WGz0+ X-Received: by 2002:a54:418b:0:b0:3c7:4579:7526 with SMTP id 11-20020a54418b000000b003c745797526mr5515852oiy.59.1714056169233; Thu, 25 Apr 2024 07:42:49 -0700 (PDT) Received: from localhost (164.146.150.34.bc.googleusercontent.com. [34.150.146.164]) by smtp.gmail.com with ESMTPSA id c5-20020a05620a11a500b007907a91e573sm3203565qkk.130.2024.04.25.07.42.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 07:42:48 -0700 (PDT) Date: Thu, 25 Apr 2024 10:42:48 -0400 From: Willem de Bruijn To: Abhishek Chauhan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Halaney , Willem de Bruijn , Martin KaFai Lau , Martin KaFai Lau , Daniel Borkmann , bpf Cc: kernel@quicinc.com Message-ID: <662a6be8aed1a_1de39b2946c@willemb.c.googlers.com.notmuch> In-Reply-To: <20240424222028.1080134-3-quic_abchauha@quicinc.com> References: <20240424222028.1080134-1-quic_abchauha@quicinc.com> <20240424222028.1080134-3-quic_abchauha@quicinc.com> Subject: Re: [RFC PATCH bpf-next v5 2/2] net: Add additional bit to support clockid_t timestamp type Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Abhishek Chauhan wrote: > tstamp_type is now set based on actual clockid_t compressed > into 2 bits. > > To make the design scalable for future needs this commit bring in > the change to extend the tstamp_type:1 to tstamp_type:2 to support > other clockid_t timestamp. > > We now support CLOCK_TAI as part of tstamp_type as part of this > commit with exisiting support CLOCK_MONOTONIC and CLOCK_REALTIME. > > Link: https://lore.kernel.org/netdev/bc037db4-58bb-4861-ac31-a361a93841d3@linux.dev/ > Signed-off-by: Abhishek Chauhan > --- > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > index e464d0ebc9c1..3ad0de07d261 100644 > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -711,6 +711,8 @@ typedef unsigned char *sk_buff_data_t; > enum skb_tstamp_type { > SKB_CLOCK_REALTIME, > SKB_CLOCK_MONOTONIC, > + SKB_CLOCK_TAI, > + __SKB_CLOCK_MAX = SKB_CLOCK_TAI, > }; > > /** > @@ -831,8 +833,8 @@ enum skb_tstamp_type { > * @decrypted: Decrypted SKB > * @slow_gro: state present at GRO time, slower prepare step required > * @tstamp_type: When set, skb->tstamp has the > - * delivery_time in mono clock base Otherwise, the > - * timestamp is considered real clock base. > + * delivery_time in mono clock base or clock base of skb->tstamp. drop "in mono clock base or " > + * Otherwise, the timestamp is considered real clock base drop this: whenever in realtime clock base, tstamp_type is zero, so the above shorter statement always holds. > * @napi_id: id of the NAPI struct this skb came from > * @sender_cpu: (aka @napi_id) source CPU in XPS > * @alloc_cpu: CPU which did the skb allocation. > @@ -960,7 +962,7 @@ struct sk_buff { > /* private: */ > __u8 __mono_tc_offset[0]; > /* public: */ > - __u8 tstamp_type:1; /* See skb_tstamp_type */ > + __u8 tstamp_type:2; /* See skb_tstamp_type */ > #ifdef CONFIG_NET_XGRESS > __u8 tc_at_ingress:1; /* See TC_AT_INGRESS_MASK */ > __u8 tc_skip_classify:1; > @@ -1090,15 +1092,17 @@ struct sk_buff { > #endif > #define PKT_TYPE_OFFSET offsetof(struct sk_buff, __pkt_type_offset) > > -/* if you move tc_at_ingress or mono_delivery_time > +/* if you move tc_at_ingress or tstamp_type:2 > * around, you also must adapt these constants. > */ > #ifdef __BIG_ENDIAN_BITFIELD > -#define SKB_MONO_DELIVERY_TIME_MASK (1 << 7) > -#define TC_AT_INGRESS_MASK (1 << 6) > +#define SKB_TSTAMP_TYPE_MASK (3 << 6) > +#define SKB_TSTAMP_TYPE_RSH (6) > +#define TC_AT_INGRESS_RSH (5) I had to find BPF_RSH to understand this abbreviation. use SHIFT instead of RSH, as that is so domain specific? > +#define TC_AT_INGRESS_MASK (1 << 5) > #else > -#define SKB_MONO_DELIVERY_TIME_MASK (1 << 0) > -#define TC_AT_INGRESS_MASK (1 << 1) > +#define SKB_TSTAMP_TYPE_MASK (3) > +#define TC_AT_INGRESS_MASK (1 << 2) > #endif > #define SKB_BF_MONO_TC_OFFSET offsetof(struct sk_buff, __mono_tc_offset) > > - if (skb->tstamp_type == BPF_SKB_TSTAMP_DELIVERY_MONO) { > + if (skb->tstamp_type == BPF_SKB_TSTAMP_DELIVERY_MONO || > + skb->tstamp_type == BPF_SKB_TSTAMP_DELIVERY_TAI) { Peculiar indentation? Just FYI that I'm not the best person to review the BPF part. Thankfully Martin is helping you with that.