From: Vladimir Oltean <olteanv@gmail.com>
To: "Jens Emil Schulz Østergaard" <jensemil.schulzostergaard@microchip.com>
Cc: UNGLinuxDriver@microchip.com, 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>,
Simon Horman <horms@kernel.org>, Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Woojung Huh <woojung.huh@microchip.com>,
Russell King <linux@armlinux.org.uk>,
Steen Hegelund <Steen.Hegelund@microchip.com>,
Daniel Machon <daniel.machon@microchip.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH net-next 1/8] net: dsa: add tag driver for LAN9645X
Date: Tue, 3 Mar 2026 18:11:47 +0200 [thread overview]
Message-ID: <20260303161147.bgbltslwrl2gtd7p@skbuf> (raw)
In-Reply-To: <20260303-dsa_lan9645x_switch_driver_base-v1-1-bff8ca1396f5@microchip.com>
On Tue, Mar 03, 2026 at 01:22:27PM +0100, Jens Emil Schulz Østergaard wrote:
> Use long prefix on extraction (RX) and no prefix on injection (TX). A
> long prefix on extraction helps get through the conduit port on host
> side, since it will see a broadcast MAC.
(...)
> The format can be configured asymmetrically on RX and TX.
Do you foresee a need to configure the prefix length? It would be
possible to do that by changing the tagging protocol. But it implies
that the "lan9645x" string as found in /sys/class/net/.../dsa/tagging
becomes user ABI that is set in stone. It will mean long extraction
prefix and no injection prefix. Otherwise user space will get very
confused (libpcap, XDP, whatever else might get written).
> +static inline u32 lan9645x_ifh_get(const u8 *ifh, size_t pos, size_t length)
> +{
> + size_t end = (pos + length) - 1;
> + size_t start_u8 = pos >> 3;
> + size_t end_u8 = end >> 3;
> + size_t end_rem = end & 0x7;
> + size_t pos_rem = pos & 0x7;
> + u8 end_mask, start_mask;
> + const u8 *ptr;
> + u32 val;
> +
> + end_mask = BTM_MSK(end_rem);
> + start_mask = TOP_MSK(pos_rem);
> +
> + ptr = &ifh[LAN9645X_IFH_LEN - 1 - end_u8];
> +
> + if (end_u8 == start_u8)
> + return (*ptr & end_mask & start_mask) >> pos_rem;
> +
> + val = *ptr++ & end_mask;
> +
> + for (size_t j = 1; j < end_u8 - start_u8; j++)
> + val = val << 8 | *ptr++;
> +
> + return val << (8 - pos_rem) | (*ptr & start_mask) >> pos_rem;
> +}
If performance isn't a huge concern, pack() and unpack() certainly seem
simpler than having your own implementation.
> +
> +static inline void lan9645x_xmit_get_vlan_info(struct sk_buff *skb,
> + struct net_device *br,
> + u32 *vlan_tci, u32 *tag_type)
> +{
> + struct vlan_ethhdr *hdr;
> + u16 proto, tci;
> +
> + if (!br || !br_vlan_enabled(br)) {
> + *vlan_tci = 0;
> + *tag_type = LAN9645X_IFH_TAG_TYPE_C;
> + return;
> + }
> +
> + hdr = (struct vlan_ethhdr *)skb_mac_header(skb);
> + br_vlan_get_proto(br, &proto);
> +
> + if (ntohs(hdr->h_vlan_proto) == proto) {
> + vlan_remove_tag(skb, &tci);
> + *vlan_tci = tci;
> + } else {
> + rcu_read_lock();
> + br_vlan_get_pvid_rcu(br, &tci);
> + rcu_read_unlock();
> + *vlan_tci = tci;
> + }
> +
> + *tag_type = (proto != ETH_P_8021Q) ? LAN9645X_IFH_TAG_TYPE_S :
> + LAN9645X_IFH_TAG_TYPE_C;
> +}
> +
> +#endif /* _NET_DSA_TAG_LAN9645X_H_ */
Why do these need to live in a separate include file? Who else needs
access to them other than the tagger?
> +static const struct dsa_device_ops lan9645x_netdev_ops = {
> + .name = LAN9645X_NAME,
> + .proto = DSA_TAG_PROTO_LAN9645X,
> + .xmit = lan9645x_xmit,
> + .rcv = lan9645x_rcv,
> + .needed_headroom = LAN9645X_TOTAL_TAG_LEN,
> + .promisc_on_conduit = false,
Initializing with false is unnecessary.
> +};
> +
> +MODULE_DESCRIPTION("DSA tag driver for LAN9645x family of switches, using NPI port");
> +MODULE_LICENSE("GPL");
> +MODULE_ALIAS_DSA_TAG_DRIVER(DSA_TAG_PROTO_LAN9645X, LAN9645X_NAME);
> +
> +module_dsa_tag_driver(lan9645x_netdev_ops);
>
> --
> 2.52.0
>
next prev parent reply other threads:[~2026-03-03 16:11 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-03 12:22 [PATCH net-next 0/8] net: dsa: add DSA support for the LAN9645x switch chip family Jens Emil Schulz Østergaard
2026-03-03 12:22 ` [PATCH net-next 1/8] net: dsa: add tag driver for LAN9645X Jens Emil Schulz Østergaard
2026-03-03 14:13 ` Andrew Lunn
2026-03-03 15:58 ` Jens Emil Schulz Ostergaard
2026-03-04 15:14 ` Andrew Lunn
2026-03-05 12:59 ` Jens Emil Schulz Ostergaard
2026-03-03 16:11 ` Vladimir Oltean [this message]
2026-03-05 13:53 ` Jens Emil Schulz Ostergaard
2026-03-04 15:23 ` Andrew Lunn
2026-03-05 13:01 ` Jens Emil Schulz Ostergaard
2026-03-03 12:22 ` [PATCH net-next 2/8] dt-bindings: net: lan9645x: add LAN9645X switch bindings Jens Emil Schulz Østergaard
2026-03-03 13:22 ` Vladimir Oltean
2026-03-03 16:00 ` Jens Emil Schulz Ostergaard
2026-03-03 14:18 ` Andrew Lunn
2026-03-03 19:04 ` Conor Dooley
2026-03-04 15:57 ` Jens Emil Schulz Ostergaard
2026-03-05 12:57 ` Jens Emil Schulz Ostergaard
2026-03-05 18:31 ` Conor Dooley
2026-03-06 15:08 ` Jens Emil Schulz Ostergaard
2026-03-06 15:20 ` Conor Dooley
2026-03-18 14:19 ` Jens Emil Schulz Ostergaard
2026-03-18 17:18 ` Conor Dooley
2026-03-18 17:20 ` Conor Dooley
2026-03-18 17:26 ` Christian Marangi
2026-03-24 10:31 ` Jens Emil Schulz Ostergaard
2026-03-04 15:55 ` Jens Emil Schulz Ostergaard
2026-03-03 18:49 ` Conor Dooley
2026-03-04 15:58 ` Jens Emil Schulz Ostergaard
2026-03-03 18:56 ` Conor Dooley
2026-03-04 16:10 ` Jens Emil Schulz Ostergaard
2026-03-04 16:14 ` Vladimir Oltean
2026-03-04 19:06 ` Conor Dooley
2026-03-05 13:08 ` Jens Emil Schulz Ostergaard
2026-03-03 12:22 ` [PATCH net-next 3/8] net: dsa: lan9645x: add autogenerated register macros Jens Emil Schulz Østergaard
2026-03-03 12:22 ` [PATCH net-next 4/8] net: dsa: lan9645x: add basic dsa driver for LAN9645X Jens Emil Schulz Østergaard
2026-03-03 14:15 ` Vladimir Oltean
2026-03-04 14:37 ` Jens Emil Schulz Ostergaard
2026-03-04 15:58 ` Russell King (Oracle)
2026-03-05 14:24 ` Jens Emil Schulz Ostergaard
2026-03-05 14:58 ` Andrew Lunn
2026-03-05 15:10 ` Vladimir Oltean
2026-03-05 16:54 ` Alexander Stein
2026-03-05 17:37 ` Andrew Lunn
2026-03-06 15:03 ` Jens Emil Schulz Ostergaard
2026-03-06 16:33 ` Andrew Lunn
2026-03-09 12:01 ` Jens Emil Schulz Ostergaard
2026-03-06 14:22 ` Russell King (Oracle)
2026-03-06 21:03 ` Jakub Kicinski
2026-03-03 12:22 ` [PATCH net-next 5/8] net: dsa: lan9645x: add bridge support Jens Emil Schulz Østergaard
2026-03-03 14:20 ` Vladimir Oltean
2026-03-03 16:08 ` Jens Emil Schulz Ostergaard
2026-03-03 16:17 ` Vladimir Oltean
2026-03-05 13:14 ` Jens Emil Schulz Ostergaard
2026-03-03 14:51 ` Vladimir Oltean
2026-03-09 12:09 ` Jens Emil Schulz Ostergaard
2026-03-03 12:22 ` [PATCH net-next 6/8] net: dsa: lan9645x: add vlan support Jens Emil Schulz Østergaard
2026-03-03 14:59 ` Vladimir Oltean
2026-03-04 14:40 ` Jens Emil Schulz Ostergaard
2026-03-04 14:52 ` Vladimir Oltean
2026-03-03 12:22 ` [PATCH net-next 7/8] net: dsa: lan9645x: add mac table integration Jens Emil Schulz Østergaard
2026-03-03 15:27 ` Vladimir Oltean
2026-03-04 15:23 ` Jens Emil Schulz Ostergaard
2026-03-04 15:34 ` Andrew Lunn
2026-03-05 13:17 ` Jens Emil Schulz Ostergaard
2026-03-03 12:22 ` [PATCH net-next 8/8] net: dsa: lan9645x: add port statistics Jens Emil Schulz Østergaard
2026-03-03 16:01 ` Vladimir Oltean
2026-03-03 20:21 ` Andrew Lunn
2026-03-04 15:51 ` Jens Emil Schulz Ostergaard
2026-03-04 15:50 ` Jens Emil Schulz Ostergaard
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=20260303161147.bgbltslwrl2gtd7p@skbuf \
--to=olteanv@gmail.com \
--cc=Steen.Hegelund@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=andrew@lunn.ch \
--cc=conor+dt@kernel.org \
--cc=daniel.machon@microchip.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jensemil.schulzostergaard@microchip.com \
--cc=krzk+dt@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=robh@kernel.org \
--cc=woojung.huh@microchip.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