Netdev List
 help / color / mirror / Atom feed
From: Andrew Gaylard <ag@ffroot.co.za>
To: Daniel Machon <daniel.machon@microchip.com>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
	 "David S . Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@kernel.org>,
	 Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next] net: sunplus: also fix the byte order of 1c:50:1e MAC addresses
Date: Tue, 17 Nov 2026 15:32:07 +0200	[thread overview]
Message-ID: <sa64idfr3c8.fsf@andrew.office> (raw)
In-Reply-To: <20261117122857.kctlh54neeyye5vb@DEN-DL-M70577.microsemi.net> (Daniel Machon's message of "Tue, 17 Nov 2026 13:28:57 +0100")

Hi Daniel,

Daniel Machon <daniel.machon@microchip.com> writes:
> The fix looks correct to me, but I personally dislike that double-loop. I think
> it could be smaller and more readable with something like:
>
> +static bool spl2sw_is_sunplus_oui(u8 b0, u8 b1, u8 b2)
> +{
> +	return (b0 == 0xfc && b1 == 0x4b && b2 == 0xbc) ||
> +	       (b0 == 0x1c && b1 == 0x50 && b2 == 0x1e);
> +}
> +
>  static void spl2sw_check_mac_vendor_id_and_convert(u8 *mac_addr)
>  {
>  	/* Byte order of MAC address of some samples are reversed.
>  	 * Check vendor id and convert byte order if it is wrong.
> -	 * OUI of Sunplus: fc:4b:bc
> +	 * OUIs of Sunplus: fc:4b:bc, 1c:50:1e
>  	 */
> -	if (mac_addr[5] == 0xfc && mac_addr[4] == 0x4b && mac_addr[3] == 0xbc &&
> -	    (mac_addr[0] != 0xfc || mac_addr[1] != 0x4b || mac_addr[2] != 0xbc)) {
> -
> +	if (spl2sw_is_sunplus_oui(mac_addr[5], mac_addr[4], mac_addr[3]) &&
> +	    !spl2sw_is_sunplus_oui(mac_addr[0], mac_addr[1], mac_addr[2])) {
>  		swap(mac_addr[0], mac_addr[5]);
>  		swap(mac_addr[1], mac_addr[4]);
>  		swap(mac_addr[2], mac_addr[3]);
>
> This should behave the same as your two loops, and adding a new entry is still
> easy.  Only a suggestion though, dont respin if you disagree.
>
> Reviewed-by: Daniel Machon <daniel.machon@microchip.com>

Thanks for the review.  I prefer your approach: definitely more
readable.  I'll respin and send a v2.

-- 
Andrew

      reply	other threads:[~2026-11-17 13:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 12:37 [PATCH net-next] net: sunplus: also fix the byte order of 1c:50:1e MAC addresses Andrew Gaylard
2026-11-17 12:28 ` Daniel Machon
2026-11-17 13:32   ` Andrew Gaylard [this message]

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=sa64idfr3c8.fsf@andrew.office \
    --to=ag@ffroot.co.za \
    --cc=andrew+netdev@lunn.ch \
    --cc=daniel.machon@microchip.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.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