Subject: Re: [ethtool v5 2/6] Add cable test TDR support

From: Ido Schimmel <[email-masked]>
Date: Mon, 22 Nov 2021 20:51:56 +0200

On Sun, Jul 05, 2020 at 07:54:48PM +0200, Andrew Lunn wrote:
> +/* Receive the broadcasted messages until we get the cable test
> + * results
> + */
> +static int nl_cable_test_tdr_process_results(struct cmd_context *ctx)
> +{
> +	struct nl_context *nlctx = ctx->nlctx;
> +	struct nl_socket *nlsk = nlctx->ethnl_socket;
> +	struct cable_test_context ctctx;
> +	int err;
> +
> +	nlctx->is_monitor = true;
> +	nlsk->port = 0;
> +	nlsk->seq = 0;

Andrew, is this missing the following patch?

diff --git a/netlink/cable_test.c b/netlink/cable_test.c
index 17139f7d297d..9305a4763c5b 100644
--- a/netlink/cable_test.c
+++ b/netlink/cable_test.c
@@ -225,6 +225,7 @@ static int nl_cable_test_process_results(struct cmd_context *ctx)
        nlctx->is_monitor = true;
        nlsk->port = 0;
        nlsk->seq = 0;
+       nlctx->filter_devname = ctx->devname;
 
        ctctx.breakout = false;
        nlctx->cmd_private = &ctctx;
@@ -496,6 +497,7 @@ static int nl_cable_test_tdr_process_results(struct cmd_context *ctx)
        nlctx->is_monitor = true;
        nlsk->port = 0;
        nlsk->seq = 0;
+       nlctx->filter_devname = ctx->devname;
 
        ctctx.breakout = false;
        nlctx->cmd_private = &ctctx;

I don't have hardware with cable test support so wondered if you could
test it. I think that without this patch you would see problems with two
simultaneous cable tests. The first one to finish will terminate both
ethtool processes because the code is processing all cable tests
notifications regardless of the device for which the test was issued.

Context: I'm using a similar scheme for transceiver module firmware
update in order to support simultaneous update of several modules.

> +
> +	ctctx.breakout = false;
> +	nlctx->cmd_private = &ctctx;
> +
> +	while (!ctctx.breakout) {
> +		err = nlsock_process_reply(nlsk, nl_cable_test_tdr_results_cb,
> +					   nlctx);
> +		if (err)
> +			return err;
> +	}
> +
> +	return err;
> +}