Netdev List
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: netdev <netdev@vger.kernel.org>,
	"mattias.forsblad@gmail.com" <mattias.forsblad@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Christian Marangi <ansuelsmth@gmail.com>
Subject: Re: [PATCH rfc v2 08/10] net: dsa: qca8k: Pass error code from reply decoder to requester
Date: Fri, 23 Sep 2022 22:42:02 +0000	[thread overview]
Message-ID: <20220923224201.pf7slosr5yag5iac@skbuf> (raw)
In-Reply-To: <20220922175821.4184622-9-andrew@lunn.ch> <20220922175821.4184622-9-andrew@lunn.ch>

On Thu, Sep 22, 2022 at 07:58:19PM +0200, Andrew Lunn wrote:
> The code which decodes the frame and signals the complete can detect
> error within the reply, such as fields have unexpected values. Pass an
> error code between the completer and the function waiting on the
> complete. This simplifies the error handling, since all errors are
> combined into one place.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
> v2:
> 
> Remove EPROTO if the sequence numbers don't match, drop the reply
> ---
> @@ -1439,6 +1400,7 @@ static void qca8k_mib_autocast_handler(struct dsa_switch *ds, struct sk_buff *sk
>  	const struct qca8k_mib_desc *mib;
>  	struct mib_ethhdr *mib_ethhdr;
>  	int i, mib_len, offset = 0;
> +	int err = 0;
>  	u64 *data;
>  	u8 port;
>  
> @@ -1449,8 +1411,10 @@ static void qca8k_mib_autocast_handler(struct dsa_switch *ds, struct sk_buff *sk
>  	 * parse only the requested one.
>  	 */
>  	port = FIELD_GET(QCA_HDR_RECV_SOURCE_PORT, ntohs(mib_ethhdr->hdr));
> -	if (port != mib_eth_data->req_port)
> +	if (port != mib_eth_data->req_port) {
> +		err = -EPROTO;
>  		goto exit;
> +	}
>  
>  	data = mib_eth_data->data;
>  
> @@ -1479,7 +1443,7 @@ static void qca8k_mib_autocast_handler(struct dsa_switch *ds, struct sk_buff *sk
>  exit:
>  	/* Complete on receiving all the mib packet */
>  	if (refcount_dec_and_test(&mib_eth_data->port_parsed))
> -		dsa_inband_complete(&mib_eth_data->inband);
> +		dsa_inband_complete(&mib_eth_data->inband, err);
>  }

My understanding of the autocast function (I could be wrong) is that
it's essentially one request with 10 (or how many ports there are)
responses. At least this is what the code appears to handle.

I don't think you can say "if port isn't the requested port => set err
to -EPROTO". Because this will make dsa_inband_wait_for_completion() see
as a return code -EPROTO whenever the requested port was anything except
for the last port for which the switch had something to autocast. Which
is probably the last port.

  reply	other threads:[~2022-09-23 22:42 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-22 17:58 [PATCH rfc v2 00/10] DSA: Move parts of inband signalling into the DSA Andrew Lunn
2022-09-22 17:58 ` [PATCH rfc v2 01/10] net: dsa: qca8k: Fix inconsistent use of jiffies vs milliseconds Andrew Lunn
2022-09-22 17:58 ` [PATCH rfc v2 02/10] net: dsa: qca8k: Move completion into DSA core Andrew Lunn
2022-09-22 18:59   ` Vladimir Oltean
2022-09-22 17:58 ` [PATCH rfc v2 03/10] net: dsa: qca8K: Move queuing for request frame into the core Andrew Lunn
2022-09-22 17:58 ` [PATCH rfc v2 04/10] net: dsa: qca8k: dsa_inband_request: More normal return values Andrew Lunn
2022-09-22 17:58 ` [PATCH rfc v2 05/10] net: dsa: qca8k: Drop replies with wrong sequence numbers Andrew Lunn
2022-09-22 17:58 ` [PATCH rfc v2 06/10] net: dsa: qca8k: Move request sequence number handling into core Andrew Lunn
2022-09-22 17:58 ` [PATCH rfc v2 07/10] net: dsa: qca8k: Refactor sequence number mismatch to use error code Andrew Lunn
2022-09-22 17:58 ` [PATCH rfc v2 08/10] net: dsa: qca8k: Pass error code from reply decoder to requester Andrew Lunn
2022-09-23 22:42   ` Vladimir Oltean [this message]
2022-09-24 14:32     ` Andrew Lunn
2022-09-24 14:42       ` Vladimir Oltean
2022-09-24 15:27         ` Andrew Lunn
2022-09-24 14:45       ` Ansuel Smith
2022-09-22 17:58 ` [PATCH rfc v2 09/10] net: dsa: qca8k: Pass response buffer via dsa_rmu_request Andrew Lunn
2022-09-22 17:58 ` [PATCH rfc v2 10/10] net: dsa: qca8: Move inband mutex into DSA core Andrew Lunn
2022-09-22 18:09 ` [PATCH rfc v2 00/10] DSA: Move parts of inband signalling into the DSA Christian Marangi

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=20220923224201.pf7slosr5yag5iac@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=f.fainelli@gmail.com \
    --cc=mattias.forsblad@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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