public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: Jonas Gorski <jonas.gorski@gmail.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Florian Fainelli <florian.fainelli@broadcom.com>
Subject: Re: [PATCH net-next 02/15] net: dsa: tag_brcm: use the dsa_xmit_port_mask() helper
Date: Thu, 27 Nov 2025 15:42:12 +0200	[thread overview]
Message-ID: <20251127134212.wh7d7djiv23lyv2e@skbuf> (raw)
In-Reply-To: <CAOiHx=miR4JAbnYeRJwcHowgBUmvCn4X19syCxuwk8N7=xAXRQ@mail.gmail.com>

On Thu, Nov 27, 2025 at 02:29:27PM +0100, Jonas Gorski wrote:
> > @@ -119,10 +120,9 @@ static struct sk_buff *brcm_tag_xmit_ll(struct sk_buff *skb,
> >         brcm_tag[0] = (1 << BRCM_OPCODE_SHIFT) |
> >                        ((queue & BRCM_IG_TC_MASK) << BRCM_IG_TC_SHIFT);
> >         brcm_tag[1] = 0;
> > -       brcm_tag[2] = 0;
> > -       if (dp->index == 8)
> > -               brcm_tag[2] = BRCM_IG_DSTMAP2_MASK;
> > -       brcm_tag[3] = (1 << dp->index) & BRCM_IG_DSTMAP1_MASK;
> > +       port_mask = dsa_xmit_port_mask(skb, dev);
> > +       brcm_tag[2] = (port_mask >> 8) & BRCM_IG_DSTMAP2_MASK;
> > +       brcm_tag[3] = port_mask & BRCM_IG_DSTMAP1_MASK;
> 
> Since this is a consecutive bitmask (actually [22:0]), I wonder if doing
> 
> put_unaligned_be16(port_mask, &brcm_tag[2]);
> 
> would be a bit more readable.
> 
> Or even more correct put_unaligned_be24(port_mask, &brcm_tag[1]), but
> we don't support any switches with that many ports.

I don't think there's a technical requirement for unaligned access here.
We have to use unaligned access for tail tags, but this here is handling
EtherType and/or prepended headers, which are both aligned to a boundary
of 2 due to NET_IP_ALIGN AFAIK.

Anyway, with the replacement of u8 by u8 -> u16 by u16 access I do agree
it would be a good idea, as long as u16 is used throughout (not just in
order not to split the bit mask). Alternatively if there are more than
16 ports, there's pack() which tolerates bit fields crossing any
alignment boundary (but still performs u8 by u8 access).

But I don't feel like changing the access pattern of the tagger is in
the scope of this change set.

  reply	other threads:[~2025-11-27 13:42 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-27 12:08 [PATCH net-next 00/15] Introduce the dsa_xmit_port_mask() tagging protocol helper Vladimir Oltean
2025-11-27 12:08 ` [PATCH net-next 01/15] net: dsa: introduce " Vladimir Oltean
2025-11-27 12:08 ` [PATCH net-next 02/15] net: dsa: tag_brcm: use the dsa_xmit_port_mask() helper Vladimir Oltean
2025-11-27 13:29   ` Jonas Gorski
2025-11-27 13:42     ` Vladimir Oltean [this message]
2025-11-27 12:08 ` [PATCH net-next 03/15] net: dsa: tag_gswip: " Vladimir Oltean
2025-11-27 12:08 ` [PATCH net-next 04/15] net: dsa: tag_hellcreek: " Vladimir Oltean
2025-11-27 12:08 ` [PATCH net-next 05/15] net: dsa: tag_ksz: " Vladimir Oltean
2025-11-27 12:08 ` [PATCH net-next 06/15] net: dsa: tag_mtk: " Vladimir Oltean
2025-11-27 12:08 ` [PATCH net-next 07/15] net: dsa: tag_mxl_gsw1xx: " Vladimir Oltean
2025-11-27 12:08 ` [PATCH net-next 08/15] net: dsa: tag_ocelot: " Vladimir Oltean
2025-11-27 12:08 ` [PATCH net-next 09/15] net: dsa: tag_qca: " Vladimir Oltean
2025-11-27 12:08 ` [PATCH net-next 10/15] net: dsa: tag_rtl4_a: " Vladimir Oltean
2025-12-31  3:17   ` Luiz Angelo Daros de Luca
2025-12-31 21:05   ` Linus Walleij
2025-11-27 12:08 ` [PATCH net-next 11/15] net: dsa: tag_rtl8_4: " Vladimir Oltean
2025-12-31  3:20   ` Luiz Angelo Daros de Luca
2025-12-31 21:05   ` Linus Walleij
2025-11-27 12:08 ` [PATCH net-next 12/15] net: dsa: tag_rzn1_a5psw: " Vladimir Oltean
2025-11-27 12:09 ` [PATCH net-next 13/15] net: dsa: tag_trailer: " Vladimir Oltean
2025-11-27 12:09 ` [PATCH net-next 14/15] net: dsa: tag_xrs700x: " Vladimir Oltean
2025-11-27 12:09 ` [PATCH net-next 15/15] net: dsa: tag_yt921x: " Vladimir Oltean
2025-11-29  4:10 ` [PATCH net-next 00/15] Introduce the dsa_xmit_port_mask() tagging protocol helper patchwork-bot+netdevbpf

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=20251127134212.wh7d7djiv23lyv2e@skbuf \
    --to=vladimir.oltean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=florian.fainelli@broadcom.com \
    --cc=jonas.gorski@gmail.com \
    --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