On Tue, Jun 13, 2023 at 7:48 AM Willem de Bruijn <willemdebruijn.kernel@xxxxxxxxx> wrote: > > On Mon, Jun 12, 2023 at 7:26 PM Stanislav Fomichev <sdf@xxxxxxxxxx> wrote: > > > > Attach kfuncs that request and report TX timestamp via ringbuf. > > Confirm on the userspace side that the program has triggered > > and the timestamp is non-zero. > > > > Also make sure devtx_frame has a sensible pointers and data. > > > > Cc: netdev@xxxxxxxxxxxxxxx > > Signed-off-by: Stanislav Fomichev <sdf@xxxxxxxxxx> > > > +SEC("fentry/devtx_sb") > > +int BPF_PROG(devtx_sb, const struct devtx_frame *frame) > > +{ > > + int ret; > > + > > + ret = verify_frame(frame); > > + if (ret < 0) > > + __sync_add_and_fetch(&pkts_fail_tx, 1); > > intend to return in these error cases? in this and following patch Yeah, let's do it. > > + > > + ret = bpf_devtx_sb_request_timestamp(frame); > > + if (ret < 0) > > + __sync_add_and_fetch(&pkts_fail_tx, 1); > > + > > + return 0; > > +} > > + > > +SEC("fentry/devtx_cp") > > +int BPF_PROG(devtx_cp, const struct devtx_frame *frame) > > +{ > > + struct devtx_sample *sample; > > + int ret; > > + > > + ret = verify_frame(frame); > > + if (ret < 0) > > + __sync_add_and_fetch(&pkts_fail_tx, 1); > > + > > + sample = bpf_ringbuf_reserve(&tx_compl_buf, sizeof(*sample), 0); > > + if (!sample) > > + return 0; > > return non-zero? Can't return non-zero from fentry :-( The userspace verifies that pkts_fail_tx stays zero, so that should be enough. > > + > > + sample->timestamp_retval = bpf_devtx_cp_timestamp(frame, &sample->timestamp); > > + > > + bpf_ringbuf_submit(sample, 0); > > + > > + return 0; > > +}