public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Xing <kerneljasonxing@gmail.com>
To: Pavel Begunkov <asml.silence@gmail.com>
Cc: Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	 Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	io-uring@vger.kernel.org,  netdev@vger.kernel.org,
	Eric Dumazet <edumazet@google.com>,
	 Kuniyuki Iwashima <kuniyu@amazon.com>,
	Paolo Abeni <pabeni@redhat.com>,
	 Willem de Bruijn <willemb@google.com>,
	"David S . Miller" <davem@davemloft.net>,
	 Jakub Kicinski <kuba@kernel.org>,
	Richard Cochran <richardcochran@gmail.com>
Subject: Re: [PATCH v2 5/5] io_uring/netcmd: add tx timestamping cmd support
Date: Fri, 6 Jun 2025 16:33:25 +0800	[thread overview]
Message-ID: <CAL+tcoCTpFm+-CVZb-6=70ZCh3ERHrJ19MmL+u56SNFrkd2QCw@mail.gmail.com> (raw)
In-Reply-To: <449d5c82-7af5-42ce-bd69-00c2bb135a21@gmail.com>

On Fri, Jun 6, 2025 at 4:11 PM Pavel Begunkov <asml.silence@gmail.com> wrote:
>
> On 6/6/25 01:02, Jason Xing wrote:
> ...>>>>                                 optlen);
> >>>>    }
> >>>>
> >>>> +static bool io_process_timestamp_skb(struct io_uring_cmd *cmd, struct sock *sk,
> >>>> +                                 struct sk_buff *skb, unsigned issue_flags)
> >>>> +{
> >>>> +    struct sock_exterr_skb *serr = SKB_EXT_ERR(skb);
> >>>> +    struct io_uring_cqe cqe[2];
> >>>> +    struct io_timespec *iots;
> >>>> +    struct timespec64 ts;
> >>>> +    u32 tskey;
> >>>> +
> >>>> +    BUILD_BUG_ON(sizeof(struct io_uring_cqe) != sizeof(struct io_timespec));
> >>>> +
> >>>> +    if (!skb_get_tx_timestamp(skb, sk, &ts))
> >>>> +            return false;
> >>>> +
> >>>> +    tskey = serr->ee.ee_data;
> >>>> +
> >>>> +    cqe->user_data = 0;
> >>>> +    cqe->res = tskey;
> >>>> +    cqe->flags = IORING_CQE_F_MORE;
> >>>> +    cqe->flags |= (u32)serr->ee.ee_info << IORING_CQE_BUFFER_SHIFT;
> >>>> +
> >>>> +    iots = (struct io_timespec *)&cqe[1];
> >>>> +    iots->tv_sec = ts.tv_sec;
> >>>> +    iots->tv_nsec = ts.tv_nsec;
> >>>
> >>> skb_get_tx_timestamp loses the information whether this is a
> >>> software or a hardware timestamp. Is that loss problematic?
> >>>
> >>> If a process only requests one type of timestamp, it will not be.
> >>>
> >>> But when requesting both (SOF_TIMESTAMPING_OPT_TX_SWHW) this per cqe
> >>> annotation may be necessary.
> >>
> >> skb_has_tx_timestamp() helper has clear priority of software timestamp,
> >> if enabled for the socket. Looks like SOF_TIMESTAMPING_OPT_TX_SWHW case
> >> won't produce both timestamps with the current implementation. Am I
> >> missing something?
> >
> > Sorry that I don't know how iouring works at a high level, so my
> > question could be naive and unrelated to what Willem said.
> >
> > Is it possible that applications set various tx sw timestamp flags
> > (like SOF_TIMESTAMPING_TX_SCHED, SOF_TIMESTAMPING_TX_SOFTWARE)? If it
>
> io_uring takes timestamps from the error queue, just like the socket
> api does it. There should be different skbs in the queue for different
> SCM_TSTAMP_{SND,SCHED,ACK,*} timestamps, io_uring only passes the
> type it got in an skb's serr->ee.ee_info to user without changes.
> Hope it answers it

Sure, thanks, io_uring has no difference from other regular
applications in this case. Then the question that Willem proposed
remains because in other applications struct scm_timestamping_internal
can be used to distinguish sw and hw timestamps (please see
__sock_recv_timestamp() as an example).

Thanks,
Jason

  reply	other threads:[~2025-06-06  8:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-04  8:42 [PATCH v2 0/5] io_uring cmd for tx timestamps Pavel Begunkov
2025-06-04  8:42 ` [PATCH v2 1/5] net: timestamp: add helper returning skb's tx tstamp Pavel Begunkov
2025-06-04 15:37   ` Stanislav Fomichev
2025-06-05  0:52   ` Willem de Bruijn
2025-06-05  3:51   ` Jason Xing
2025-06-04  8:42 ` [PATCH v2 2/5] io_uring/poll: introduce io_arm_apoll() Pavel Begunkov
2025-06-04  8:42 ` [PATCH v2 3/5] io_uring/cmd: allow multishot polled commands Pavel Begunkov
2025-06-04  8:42 ` [PATCH v2 4/5] io_uring: add mshot helper for posting CQE32 Pavel Begunkov
2025-06-04  8:42 ` [PATCH v2 5/5] io_uring/netcmd: add tx timestamping cmd support Pavel Begunkov
2025-06-04 12:04   ` Jens Axboe
2025-06-04 12:33     ` Pavel Begunkov
2025-06-05  0:59   ` Willem de Bruijn
2025-06-05 10:25     ` Vadim Fedorenko
2025-06-05 11:01       ` Pavel Begunkov
2025-06-05 23:54       ` Willem de Bruijn
2025-06-06  0:17         ` Jason Xing
2025-06-06  0:02       ` Jason Xing
2025-06-06  8:12         ` Pavel Begunkov
2025-06-06  8:33           ` Jason Xing [this message]
2025-06-06  9:08             ` Pavel Begunkov
2025-06-04  8:53 ` [PATCH v2 0/5] io_uring cmd for tx timestamps Pavel Begunkov
2025-06-04 12:06 ` Jens Axboe
2025-06-04 12:38   ` Pavel Begunkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAL+tcoCTpFm+-CVZb-6=70ZCh3ERHrJ19MmL+u56SNFrkd2QCw@mail.gmail.com' \
    --to=kerneljasonxing@gmail.com \
    --cc=asml.silence@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=io-uring@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    --cc=vadim.fedorenko@linux.dev \
    --cc=willemb@google.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox