public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: bhargava.marreddy@broadcom.com
Cc: Jakub Kicinski <kuba@kernel.org>,
	edumazet@google.com, andrew+netdev@lunn.ch,
	ajit.khaparde@broadcom.com, horms@kernel.org, pabeni@redhat.com,
	michael.chan@broadcom.com, linux-kernel@vger.kernel.org,
	vsrama-krishna.nemani@broadcom.com, davem@davemloft.net,
	netdev@vger.kernel.org, rajashekar.hudumula@broadcom.com,
	vikas.gupta@broadcom.com, pavan.chebbi@broadcom.com,
	rahul-rg.gupta@broadcom.com
Subject: Re: [net-next,v3,3/8] bng_en: add ethtool link settings, get_link, and nway_reset
Date: Mon,  2 Mar 2026 19:00:29 -0800	[thread overview]
Message-ID: <20260303030029.1884718-1-kuba@kernel.org> (raw)
In-Reply-To: <20260228072715.1632280-4-bhargava.marreddy@broadcom.com>

This is an AI-generated review of your patch. The human sending this
email has considered the AI review valid, or at least plausible.

For local reproduction steps see https://netdev-ai.bots.linux.dev/ai-local.html
---
bng_en: add ethtool link settings, get_link, and nway_reset

This commit adds get/set_link_ksettings, get_link, and nway_reset support
to the bnge driver. It implements speed reporting across NRZ, PAM4, and
PAM4-112 signaling modes and enables lane count reporting.

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge.h b/drivers/net/ethernet/broadcom/bnge/bnge.h
> index 83ee4749cc70..e9b83c0c64b6 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge.h
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge.h

[ ... ]

> diff --git a/drivers/net/ethernet/broadcom/bnge/bnge_link.c b/drivers/net/ethernet/broadcom/bnge/bnge_link.c
> index d96fe662bba0..c2b3511fc913 100644
> --- a/drivers/net/ethernet/broadcom/bnge/bnge_link.c
> +++ b/drivers/net/ethernet/broadcom/bnge/bnge_link.c

[ ... ]

> @@ -458,3 +503,755 @@ void bnge_report_link(struct bnge_dev *bd)
>  		netdev_err(bd->netdev, "NIC Link is Down\n");
>  	}
>  }
> +
> +static const u16 bnge_nrz_speed_masks[] = {
> +	[BNGE_LINK_SPEED_100GB_IDX] = BNGE_LINK_SPEED_MSK_100GB,
> +	[__BNGE_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
> +};
> +
> +static const u16 bnge_pam4_speed_masks[] = {
> +	[BNGE_LINK_SPEED_50GB_IDX] = BNGE_LINK_PAM4_SPEED_MSK_50GB,
> +	[BNGE_LINK_SPEED_100GB_IDX] = BNGE_LINK_PAM4_SPEED_MSK_100GB,
> +	[BNGE_LINK_SPEED_200GB_IDX] = BNGE_LINK_PAM4_SPEED_MSK_200GB,
> +	[__BNGE_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
> +};
> +
> +static const u16 bnge_nrz_speeds2_masks[] = {
> +	[BNGE_LINK_SPEED_100GB_IDX] = BNGE_LINK_SPEEDS2_MSK_100GB,
> +	[__BNGE_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
> +};
> +
> +static const u16 bnge_pam4_speeds2_masks[] = {
> +	[BNGE_LINK_SPEED_50GB_IDX] = BNGE_LINK_SPEEDS2_MSK_50GB_PAM4,
> +	[BNGE_LINK_SPEED_100GB_IDX] = BNGE_LINK_SPEEDS2_MSK_100GB_PAM4,
> +	[BNGE_LINK_SPEED_200GB_IDX] = BNGE_LINK_SPEEDS2_MSK_200GB_PAM4,
> +	[BNGE_LINK_SPEED_400GB_IDX] = BNGE_LINK_SPEEDS2_MSK_400GB_PAM4,
> +	[__BNGE_LINK_SPEED_END - 1] = 0 /* make any legal speed a valid index */
> +};
> +
> +static const u16 bnge_pam4_112_speeds2_masks[] = {
> +	[BNGE_LINK_SPEED_100GB_IDX] = BNGE_LINK_SPEEDS2_MSK_100GB_PAM4_112,
> +	[BNGE_LINK_SPEED_200GB_IDX] = BNGE_LINK_SPEEDS2_MSK_200GB_PAM4_112,
> +	[BNGE_LINK_SPEED_400GB_IDX] = BNGE_LINK_SPEEDS2_MSK_400GB_PAM4_112,
> +	[BNGE_LINK_SPEED_800GB_IDX] = BNGE_LINK_SPEEDS2_MSK_800GB_PAM4_112,
> +};

The bnge_pam4_112_speeds2_masks array is missing the sentinel entry
that all other speed mask arrays have. Jakub Kicinski's AI review in v1
identified a potential out-of-bounds array access in this array.

The v2 changelog claims to have fixed this by 'adding the missing sentinel',
but only bnge_pam4_speeds2_masks[] was fixed. All other speed mask arrays
include '[__BNGE_LINK_SPEED_END - 1] = 0' to ensure any legal speed is a
valid index, but bnge_pam4_112_speeds2_masks[] still lacks this.

While the array currently has an entry at the highest accessed index
([5] = 800GB), the missing sentinel makes it inconsistent with the other
arrays and may cause issues if the loop or access patterns change.

Looking at bnge_set_ethtool_speeds():

drivers/net/ethernet/broadcom/bnge/bnge_link.c:bnge_set_ethtool_speeds() {
	for (i = 1; i < __BNGE_LINK_SPEED_END; i++) {
		for (m = 1; m < __BNGE_MEDIA_END; m++) {
			...
			bnge_update_speed(&delta_pam4_112, m == media,
					  adv_pam4_112, sp_pam4_112_msks[i],
					  et_mask,
					  bnge_link_modes[i][BNGE_SIG_MODE_PAM4_112][m]);
		}
	}
}

Should this array follow the same pattern as the other speed mask arrays?

Reference: https://lore.kernel.org/netdev/20260224001201.146384-2-kuba@kernel.org/

[ ... ]
-- 
pw-bot: cr

  reply	other threads:[~2026-03-03  3:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-28  7:27 [PATCH net-next v3 0/8] bng_en: add link management and statistics support Bhargava Marreddy
2026-02-28  7:27 ` [PATCH net-next v3 1/8] bng_en: add per-PF workqueue, timer, and slow-path task Bhargava Marreddy
2026-02-28  7:27 ` [PATCH net-next v3 2/8] bng_en: query PHY capabilities and report link status Bhargava Marreddy
2026-02-28  7:27 ` [PATCH net-next v3 3/8] bng_en: add ethtool link settings, get_link, and nway_reset Bhargava Marreddy
2026-03-03  3:00   ` Jakub Kicinski [this message]
2026-03-04 10:37     ` [net-next,v3,3/8] " Bhargava Chenna Marreddy
2026-03-04 18:17       ` Jakub Kicinski
2026-03-05 10:51         ` Bhargava Chenna Marreddy
2026-02-28  7:27 ` [PATCH net-next v3 4/8] bng_en: implement ethtool pauseparam operations Bhargava Marreddy
2026-02-28  7:27 ` [PATCH net-next v3 5/8] bng_en: add support for link async events Bhargava Marreddy
2026-02-28  7:27 ` [PATCH net-next v3 6/8] bng_en: add initial support for ethtool stats display Bhargava Marreddy
2026-03-03  3:00   ` [net-next,v3,6/8] " Jakub Kicinski
2026-03-04  8:08     ` Bhargava Chenna Marreddy
2026-03-04 18:22       ` Jakub Kicinski
2026-03-05 10:33         ` Bhargava Chenna Marreddy
2026-02-28  7:27 ` [PATCH net-next v3 7/8] bng_en: periodically fetch and accumulate hardware statistics Bhargava Marreddy
2026-02-28  7:27 ` [PATCH net-next v3 8/8] bng_en: implement ndo_get_stats64 Bhargava Marreddy

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=20260303030029.1884718-1-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=ajit.khaparde@broadcom.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=bhargava.marreddy@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pavan.chebbi@broadcom.com \
    --cc=rahul-rg.gupta@broadcom.com \
    --cc=rajashekar.hudumula@broadcom.com \
    --cc=vikas.gupta@broadcom.com \
    --cc=vsrama-krishna.nemani@broadcom.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