Netdev List
 help / color / mirror / Atom feed
From: Mohsin Bashir <mohsin.bashr@gmail.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, edumazet@google.com,
	pabeni@redhat.com, horms@kernel.org, andrew@lunn.ch,
	Willem de Bruijn <willemb@google.com>
Subject: Re: [PATCH net-next v2 4/7] selftests: drv-net: refactor so_txtime errqueue handling
Date: Thu, 23 Jul 2026 07:40:45 -0700	[thread overview]
Message-ID: <06dbed72-1f5c-4c91-bab2-4acf6e562713@gmail.com> (raw)
In-Reply-To: <20260722204454.3234605-5-willemdebruijn.kernel@gmail.com>



On 7/22/26 1:43 PM, Willem de Bruijn wrote:
> From: Willem de Bruijn <willemb@google.com>
> 
> Prepare error queue handling for upcoming SO_EE_ORIGIN_TIMESTAMPING
> messages in the next patch in this series.
> 
> Convert do_recv_errqueue_timeout into dispatcher do_recv_errqueue
> and move SO_EE_ORIGIN_TXTIME specific code into a separate helper.
> 
> This will make the next patch a lot more readable.
> 
> No functional changes.
> 
> Signed-off-by: Willem de Bruijn <willemb@google.com>
> ---
>   .../testing/selftests/drivers/net/so_txtime.c | 66 ++++++++++---------
>   1 file changed, 36 insertions(+), 30 deletions(-)
> 
> diff --git a/tools/testing/selftests/drivers/net/so_txtime.c b/tools/testing/selftests/drivers/net/so_txtime.c
> index 55a386f3d1b9..7364ce2bec0b 100644
> --- a/tools/testing/selftests/drivers/net/so_txtime.c
> +++ b/tools/testing/selftests/drivers/net/so_txtime.c
> @@ -158,7 +158,40 @@ static void do_recv_verify_empty(int fdr)
>   		error(1, 0, "recv: not empty as expected (%d, %d)", ret, errno);
>   }
>   
> -static int do_recv_errqueue_timeout(int fdt)
> +static int do_recv_errqueue_timeout(struct sock_extended_err *err,
> +				    const char payload_char)
> +{
> +	const char *reason = NULL;
> +	int64_t tstamp = 0;
> +
> +	switch (err->ee_errno) {
> +	case ECANCELED:
> +		if (err->ee_code != SO_EE_CODE_TXTIME_MISSED)
> +			error(1, 0, "errqueue: unknown ECANCELED %u\n",
> +			      err->ee_code);
> +		reason = "missed txtime";
> +	break;
> +	case EINVAL:
> +		if (err->ee_code != SO_EE_CODE_TXTIME_INVALID_PARAM)
> +			error(1, 0, "errqueue: unknown EINVAL %u\n",
> +			      err->ee_code);
> +		reason = "invalid txtime";
> +	break;
> +	default:
> +		error(1, 0, "errqueue: errno %u code %u\n",
> +		      err->ee_errno, err->ee_code);
> +	}
> +
> +	tstamp = ((int64_t)err->ee_data) << 32 | err->ee_info;
> +	tstamp -= (int64_t)glob_tstart;
> +	tstamp /= 1000 * 1000;
> +	fprintf(stderr, "send: pkt %c at %" PRId64 "ms dropped: %s\n",
> +		payload_char, tstamp, reason);
> +
> +	return 1;
> +}
> +
> +static int do_recv_errqueue(int fdt)
>   {
>   	char control[CMSG_SPACE(sizeof(struct sock_extended_err)) +
>   		     CMSG_SPACE(sizeof(struct sockaddr_in6))] = {0};
> @@ -169,7 +202,6 @@ static int do_recv_errqueue_timeout(int fdt)
>   	struct msghdr msg = {0};
>   	struct iovec iov = {0};
>   	struct cmsghdr *cm;
> -	int64_t tstamp = 0;
>   
>   	iov.iov_base = data;
>   	iov.iov_len = sizeof(data);
> @@ -181,8 +213,6 @@ static int do_recv_errqueue_timeout(int fdt)
>   	msg.msg_controllen = sizeof(control);
>   
>   	while (1) {
> -		const char *reason = NULL;
> -
>   		ret = recvmsg(fdt, &msg, MSG_ERRQUEUE);
>   		if (ret == -1 && errno == EAGAIN)
>   			break;
> @@ -201,33 +231,9 @@ static int do_recv_errqueue_timeout(int fdt)
>   		if (err->ee_origin != SO_EE_ORIGIN_TXTIME)
>   			error(1, 0, "errqueue: origin 0x%x\n", err->ee_origin);
>   
> -		switch (err->ee_errno) {
> -		case ECANCELED:
> -			if (err->ee_code != SO_EE_CODE_TXTIME_MISSED)
> -				error(1, 0, "errqueue: unknown ECANCELED %u\n",
> -				      err->ee_code);
> -			reason = "missed txtime";
> -		break;
> -		case EINVAL:
> -			if (err->ee_code != SO_EE_CODE_TXTIME_INVALID_PARAM)
> -				error(1, 0, "errqueue: unknown EINVAL %u\n",
> -				      err->ee_code);
> -			reason = "invalid txtime";
> -		break;
> -		default:
> -			error(1, 0, "errqueue: errno %u code %u\n",
> -			      err->ee_errno, err->ee_code);
> -		}
> -
> -		tstamp = ((int64_t) err->ee_data) << 32 | err->ee_info;
> -		tstamp -= (int64_t) glob_tstart;
> -		tstamp /= 1000 * 1000;
> -		fprintf(stderr, "send: pkt %c at %" PRId64 "ms dropped: %s\n",
> -			data[ret - 1], tstamp, reason);
> -
> +		num_tstamp += do_recv_errqueue_timeout(err, data[ret - 1]);
>   		msg.msg_flags = 0;
>   		msg.msg_controllen = sizeof(control);
> -		num_tstamp++;
>   	}
>   
>   	return num_tstamp;
> @@ -245,7 +251,7 @@ static void recv_errqueue_msgs(int fdt)
>   			error(1, errno, "poll");
>   
>   		if (ret && (pfd.revents & POLLERR))
> -			num_tstamp += do_recv_errqueue_timeout(fdt);
> +			num_tstamp += do_recv_errqueue(fdt);
>   
>   		if (num_tstamp == cfg_num_pkt)
>   			break;

Reviewed-by: Mohsin Bashir <hmohsin@meta.com>

  reply	other threads:[~2026-07-23 14:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-22 20:43 [PATCH net-next v2 0/7] hardware pacing offload Willem de Bruijn
2026-07-22 20:43 ` [PATCH net-next v2 1/7] net: ethtool: add hardware pacing offload support to rings Willem de Bruijn
2026-07-23 14:16   ` Mohsin Bashir
2026-07-23 21:29     ` Willem de Bruijn
2026-07-23 22:11       ` Mohsin Bashir
2026-07-22 20:43 ` [PATCH net-next v2 2/7] net_sched: sch_fq: clear past skb->tstamp if offloading pacing Willem de Bruijn
2026-07-22 20:43 ` [PATCH net-next v2 3/7] idpf: support pacing offload Willem de Bruijn
2026-07-23 14:32   ` Mohsin Bashir
2026-07-23 21:27     ` Willem de Bruijn
2026-07-22 20:43 ` [PATCH net-next v2 4/7] selftests: drv-net: refactor so_txtime errqueue handling Willem de Bruijn
2026-07-23 14:40   ` Mohsin Bashir [this message]
2026-07-22 20:43 ` [PATCH net-next v2 5/7] selftests: drv-net: in so_txtime tell apart sw from hw pacing Willem de Bruijn
2026-07-22 20:43 ` [PATCH net-next v2 6/7] selftests: drv-net: extend so_txtime with hw offload Willem de Bruijn
2026-07-22 20:43 ` [PATCH net-next v2 7/7] net: pktgen: add support for SO_TXTIME Willem de Bruijn
2026-07-23 14:12 ` [PATCH net-next v2 0/7] hardware pacing offload Mohsin Bashir

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=06dbed72-1f5c-4c91-bab2-4acf6e562713@gmail.com \
    --to=mohsin.bashr@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --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