Re: [PATCH net-next v4] net: Re-use and set mono_delivery_time bit for userspace tstamp packets

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 3/14/2024 1:28 PM, Willem de Bruijn wrote:
> Martin KaFai Lau wrote:
>> On 3/14/24 2:49 AM, Willem de Bruijn wrote:
>>>> The two bits could potentially only encode the delivery time that is allowed to
>>>> be forwarded without reset. 0 could mean refering back to sk_clockid and don't
>>>> forward. The final consumer of the forwarded skb->tstamp is the qdisc which
>>>> currently only has mono and tai.
>>>
>>> So the followinng meaning of bit pair
>>> { skb->mono_delivery_time, skb->user_delivery_time } ?
>>>   
>>> - { 0, 0 } legacy skb->tstamp: realtime on rx
>>> - { 1, 0 } skb->tstamp is mono: existing behavior of mono_delivery_time bit
>>> - { 0, 1 } skb->tstamp is tai: analogous to mono case
>>> - { 1, 1 } skb->tstamp defined by skb->sk->sk_clockid
>>
>> I was thinking only forward mono and tai until it is clearer how other clocks 
>> will be useful for forwarding between e/ingress. By resetting all skb->tstamp 
>> other than mono and tai, { 0, 0 } at ingress will mean realtime on rx and { 0, 0 
>> } at egress will mean go look skb->sk->sk_clockid.
>>
>> I do like your scheme such that it is much clearer what is in skb->tstamp 
>> without depending on other bits like tc_at_ingress or not.
>>
>> "{ 0, 1 } skb->tstamp is tai: analogous to mono case" can probably be dropped 
>> for now until bpf_skb_set_tstamp(BPF_SKB_TSTAMP_DELIVERY_TAI) is needed.
>> Otherwise, it is mostly a duplicate of "{ 1, 1 } skb->tstamp defined by 
>> skb->sk->sk_clockid".
>>
>> The bpf_convert_tstamp_{read,write} and the helper bpf_skb_set_tstamp need to be 
>> changed to handle the new "user_delivery_time" bit anyway, e.g. 
>> bpf_skb_set_tstamp(BPF_SKB_TSTAMP_DELIVERY_MONO) needs to clear the 
>> "user_delivery_time" bit.
>>
>> I think the "struct inet_frag_queue" also needs a new "user_delivery_time" 
>> field. "mono_delivery_time" is already in there.
>>
>> It may as well be cleaner to combine mono_delivery_time and user_delivery_time 
>> into a 2 bits field like:
>>
>> struct sk_buff {
>> 	__u8 tstamp_type:2;
>> };
>>
>> enum {
>> 	SKB_TSTAMP_TYPE_RX_REAL = 0, /* A RX (receive) time in real */
>> 	SKB_TSTAMP_TYPE_TX_MONO = 1, /* A TX (delivery) time in mono */
>>
>> 	/* A TX (delivery) time and its clock is in skb->sk->sk_clockid.
>> 	 *
>> 	 * BPF_SKB_TSTAMP_DELIVERY_USER should be added
>> 	 * such that reading __sk_buff->tstamp_type will match the
>> 	 * SKB_TSTAMP_TYPE_TX_USER.
>> 	 *
>> 	 * The bpf program can learn the clockid by
>> 	 * reading skb->sk->sk_clockid.
>> 	 *
>> 	 * bpf_skb_set_tstamp(BPF_SKB_TSTAMP_DELIVERY_USER)
>> 	 * should be disallowed for now until the use case
>> 	 * is more clear. Potentially, we could allow it
>> 	 * in the future as long as
>> 	 * the sock_flag(sk, SOCK_TXTIME) is true at that moment.
>> 	 */
>> 	SKB_TSTAMP_TYPE_TX_USER = 2,
>>
>> 	/* UNUSED_FOR_FUTURE = 3, */
>> };
>>
>> It will have more code churns in the first patch to rename 
>> s/mono_delivery_time/tstamp_type/.
>>
>> wdyt?
> 
> I asked for such code churn in the original patch. We then decided to
> leave the variable name as is, as the churn was significant.
> 
> Long term, it is obviously cleaner.
> 
> I don't have a strong opinion. If doing this, let's at least make it
> two separate patches, one that is a NOOP rename only.
> Martin and Willem.
Lets do the cleaner approach. I feel its now or never. 

1. I will raise one patch to introduce rename mono_delivery_time to 
tstamp_type 
2. I will introduce setting of userspace timestamp type as the second bit 
whem transmit_time is set. 
3. This will be a first step to make the design scalable. 
4. Tomorrow if we have more timestamp to support, upstream community has to do is 
update the enum and increase the bitfield from 2=>3 and so on. 

I need help from Martin to test the patch which renames the mono_delivery_time 
to tstamp_type (Which i feel should be straight forward as the value of the bit is 1)

Sounds like a plan ? 

> 




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux