mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: kyle.switch@motor-comm.com
Cc: andrew@lunn.ch, olteanv@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	mmyangfl@gmail.com, horms@kernel.org, linux@armlinux.org.uk,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	ming.xu@motor-comm.com, xiaolin.xu@motor-comm.com,
	jianmin.wang@motor-comm.com, wei.zhang@gl-inet.com,
	sijia.huang@gl-inet.com
Subject: Re: [PATCH net-next v11 6/7] net: dsa: tag_yt922x: add support for Motorcomm YT922x tags
Date: Tue, 06 Oct 2026 18:44:10 +0000	[thread overview]
Message-ID: <179131225045.434549.15006490929783226716@kernel.org> (raw)
In-Reply-To: <20261002173706.1225502-7-kyle.switch@motor-comm.com>

Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.

Low priority / nit picks for your consideration:

- [Low] The commit message for "net: dsa: tag_yt922x: add support for
  Motorcomm YT922x tags" is one line ('Add support for Motorcomm YT922x…
- [Low] Concern: yt922x_tag_rcv() never sets skb->offload_fwd_mark, so
  the software bridge would duplicate frames the hardware already…
- [Low] The new NET_DSA_TAG_YT922X entry in net/dsa/Kconfig is indented
  with spaces: 2 spaces before 'tristate' and 'help', and 4 spaces…

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the new
  yt922x_tag_rcv() calls dsa_conduit_find_user(netdev, 0, port) and so…

--

net: dsa: tag_yt922x: add support for Motorcomm YT922x tags

This commit adds a DSA tag driver for Motorcomm YT922x switches. The tag
is 8 bytes, EtherType based, and uses the same EtherType as YT921x
(0x9988). The commit also adds DSA_TAG_PROTO_YT922X and the Kconfig and
Makefile entries, and updates the existing YT921x MAINTAINERS entry.

> diff --git a/MAINTAINERS b/MAINTAINERS
> index 3011f995437fd..1a48e4570c698 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -18433,11 +18433,13 @@ F:	drivers/net/phy/motorcomm.c
>  
>  MOTORCOMM YT921X ETHERNET SWITCH DRIVER
>  M:	David Yang <mmyangfl@gmail.com>
> +M:	Kyle Switch <kyle.switch@motor-comm.com>

[Severity: Low]
This isn't a bug, but the commit message is one sentence:

  Add support for Motorcomm YT922x tags with 8bytes. which includes
  ethertype field (default to 0x9988).

It doesn't mention this new M: line. The existing entry already has a
maintainer and covers drivers/net/dsa/motorcomm/, the DT binding and
tag_yt921x.c. Should the co-maintainer addition be a separate patch with
an ack from David Yang?

The commit message also doesn't say why YT922x needs a new tag protocol.
It uses the same ETH_P_YT921X EtherType and the same 8-byte length as
tag_yt921x. Could that be explained?

In net/dsa/tag_yt922x.c, the only description of the wire format is:

  /*
   * To define the from cpu tag format 8 bytes.
   */

The to-CPU layout isn't described at all. tag_yt921x.c, by contrast, has
a full bit layout diagram. Could both directions be documented here?

Some examples are that bits 5:2 of tag[2] carry the RX source port, and
that bit 15 of tag[2] selects TX port 0. It would also help to say why
the RX path doesn't check a valid bit, restore the priority or decode a
forward code.

>  L:	netdev@vger.kernel.org
>  S:	Maintained
>  F:	Documentation/devicetree/bindings/net/dsa/motorcomm,yt921x.yaml
>  F:	drivers/net/dsa/motorcomm/
>  F:	net/dsa/tag_yt921x.c
> +F:	net/dsa/tag_yt922x.c

[ ... ]

> diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig
> index 4f44bf3ede238..86802058678c0 100644
> --- a/net/dsa/Kconfig
> +++ b/net/dsa/Kconfig
> @@ -233,4 +233,10 @@ config NET_DSA_TAG_YT921X
>  	  Say Y or M if you want to enable support for tagging frames for
>  	  Motorcomm YT921x switches.
>  
> +config NET_DSA_TAG_YT922X
> +  tristate "Tag driver for Motorcomm YT922x switches"
> +  help
> +    Say Y or M if you want to enable support for tagging frames for
> +    Motorcomm YT922x switches.

[Severity: Low]
This isn't a bug, but this entry is indented with spaces. The
NET_DSA_TAG_YT921X entry just above it, and the rest of net/dsa/Kconfig,
indent attributes with one tab and help text with a tab plus two spaces.

[ ... ]

> diff --git a/net/dsa/tag_yt922x.c b/net/dsa/tag_yt922x.c
> new file mode 100644
> index 0000000000000..3c9fef651cf51
> --- /dev/null
> +++ b/net/dsa/tag_yt922x.c

[ ... ]

> +static struct sk_buff *
> +yt922x_tag_rcv(struct sk_buff *skb, struct net_device *netdev)
> +{

[ ... ]

> +	/* Locate which port this is coming from */
> +	rx = ntohs(tag[2]);
> +	port = FIELD_GET(YT922X_TAG_RX_PORT_M, rx);
> +	skb->dev = dsa_conduit_find_user(netdev, 0, port);

[Severity: High]
This isn't a bug introduced by this patch, but the new tagger inherits an
existing race in the DSA receive path. Can dsa_conduit_find_user() see a
NULL dev->dsa_ptr here?

dsa_switch_rcv() checks the pointer once, before it calls the tagger:

net/dsa/tag.c:dsa_switch_rcv() {
    struct dsa_port *cpu_dp = dev->dsa_ptr;
    ...
    if (unlikely(!cpu_dp)) {
        kfree_skb(skb);
        return 0;
    }
    ...
}

dsa_conduit_find_user() then reloads it and dereferences it without a
check:

net/dsa/tag.h:dsa_conduit_find_user() {
    struct dsa_port *cpu_dp = dev->dsa_ptr;
    struct dsa_switch_tree *dst = cpu_dp->dst;
    ...
}

Meanwhile, teardown clears the pointer under RTNL while the conduit can
still be receiving frames:

dsa_unregister_switch()
  dsa_tree_teardown()
    dsa_tree_teardown_conduit()
      dsa_conduit_teardown()
        dev->dsa_ptr = NULL;
        wmb();

The wmb() only orders the store. Nothing like synchronize_net() waits for
receive callbacks that are already running.

Suppose the store lands after the check in dsa_switch_rcv() but before
the reload in dsa_conduit_find_user(). Would the NET_RX softirq then
dereference NULL->dst? Every tagger that uses dsa_conduit_find_user() has
the same pattern.

> +	if (unlikely(!skb->dev)) {
> +		dev_warn_ratelimited(&netdev->dev,
> +				     "Couldn't decode source port %u\n", port);
> +		kfree_skb(skb);
> +		return NULL;
> +	}
> +
> +	/* Remove tag and update checksum */
> +	skb_pull_rcsum(skb, YT922X_TAG_LEN);
> +	dsa_strip_etype_header(skb, YT922X_TAG_LEN);
> +
> +	return skb;
> +}

[Severity: Low]
This isn't a bug with the series as it stands, but yt922x_tag_rcv() never
sets skb->offload_fwd_mark.

That is fine today. yt922x_dsa_switch_ops in
drivers/net/dsa/motorcomm/chip.c has no .port_bridge_join, so
dsa_user_changeupper() falls back to a software bridge.

yt922x_port_setup() also isolates each user port so that it can only
reach the CPU port:

	ctrl = ~priv->cpu_ports_mask;
	res = yt921x_reg_write(priv, YT922X_PORTn_ISOLATION(port), ctrl);

If bridge offload is added later, would this tagger have to decode the
hardware forward or reason code and set offload_fwd_mark, as tag_yt921x
does? Otherwise the bridge could forward duplicate frames.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261002173706.1225502-1-kyle.switch%40motor-comm.com

  reply	other threads:[~2026-10-06 18:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-02 17:36 [PATCH net-next v11 0/7] net: dsa: motorcomm: add support yt922x driver Kyle Switch
2026-10-02 17:37 ` [PATCH net-next v11 1/7] net: dsa: motorcomm: initialize dsa_switch based on chipid Kyle Switch
2026-10-06 18:44   ` netdev-bot+sashiko
2026-10-02 17:37 ` [PATCH net-next v11 2/7] net: dsa: motorcomm: use max_ports in series for port bounds checking Kyle Switch
2026-10-02 17:37 ` [PATCH net-next v11 3/7] net: dsa: motorcomm: use fixed-width GENMASK_U*() helpers Kyle Switch
2026-10-06 18:44   ` netdev-bot+sashiko
2026-10-02 17:37 ` [PATCH net-next v11 4/7] net: dsa: motorcomm: move mib start from probe() to dsa_setup() Kyle Switch
2026-10-06 18:44   ` netdev-bot+sashiko
2026-10-02 17:37 ` [PATCH net-next v11 5/7] net: dsa: motorcomm: move mib stop from remove() to teardown() Kyle Switch
2026-10-06 18:44   ` netdev-bot+sashiko
2026-10-02 17:37 ` [PATCH net-next v11 6/7] net: dsa: tag_yt922x: add support for Motorcomm YT922x tags Kyle Switch
2026-10-06 18:44   ` netdev-bot+sashiko [this message]
2026-10-02 17:37 ` [PATCH net-next v11 7/7] net: dsa: motorcomm: Add support for Motorcomm YT922x Kyle Switch
2026-10-06 18:44   ` netdev-bot+sashiko

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=179131225045.434549.15006490929783226716@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jianmin.wang@motor-comm.com \
    --cc=kuba@kernel.org \
    --cc=kyle.switch@motor-comm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=ming.xu@motor-comm.com \
    --cc=mmyangfl@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=sijia.huang@gl-inet.com \
    --cc=wei.zhang@gl-inet.com \
    --cc=xiaolin.xu@motor-comm.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

all inboxes | Powered by JetHome®