From: netdev-bot+sashiko@kernel.org
To: illusion.wang@nebula-matrix.com
Cc: dimon.zhao@nebula-matrix.com, alvin.wang@nebula-matrix.com,
sam.chen@nebula-matrix.com, netdev@vger.kernel.org,
andrew+netdev@lunn.ch, corbet@lwn.net, kuba@kernel.org,
horms@kernel.org, linux-doc@vger.kernel.org, pabeni@redhat.com,
vadim.fedorenko@linux.dev, lukas.bulwahn@redhat.com,
edumazet@google.com, enelsonmoore@gmail.com,
skhan@linuxfoundation.org, hkallweit1@gmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [v26,net-next,04/10] net/nebula-matrix: add common resource implementation
Date: Thu, 03 Sep 2026 17:18:37 +0000 [thread overview]
Message-ID: <178845591752.3394541.1488499474047337134@kernel.org> (raw)
In-Reply-To: <20260831021408.2325-5-illusion.wang@nebula-matrix.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issue(s) to consider:
Critical: 0 · High: 0 · Medium: 2 · Low: 4
- [Medium] New, undisclosed fatal probe conditions derived purely from
firmware/register content.
- [Medium] The kernel-doc contract of nbl_hw_ops::get_host_pf_mask in
nbl_include/nbl_def_hw.h states 'PF0 cannot be masked, bit0 is…
- [Low] The commit message and a new code comment describe consumers and
an execution-order guarantee that do not exist at this commit, and the…
- [Low] nbl_include/nbl_def_channel.h newly uses static_assert() but is
not self-contained: its only include is <linux/types.h> (which pulls…
- [Low] The kernel-doc block for nbl_hw_ops::get_host_pf_mask documents
'@priv: hw ops private context', but the declared first parameter is…
- [Low] Comment/implementation mismatch in
nbl_res_ctrl_dev_setup_eth_info(): the comment states 'Code accepts…
--
net/nebula-matrix: add common resource implementation
This patch adds the common resource layer for the nbl driver, with helpers
converting between vsi_id, func_id, eth_id and pf_id, plus new hw ops to
read the board info, the FW eth bitmap and the real bus number.
nbl_res_init_leonis() is now called from nbl_core_init() and initializes
the VSI/Eth/PF data only for control devices.
A few questions below about the new firmware topology checks, the ops
documentation and some of the new comments.
> nbl_res_start() initializes VSI/Eth/PF data structures only for control
> devices (`common->has_ctrl == true`). Framework dispatch layer ensures
> resource mapping APIs such as nbl_res_func_id_to_vsi_id() are only invoked
> on control devices.
[Severity: Low]
Which dispatch layer is meant here? At this commit nbl_core_init() returns
right after nbl_res_init_leonis():
ret = nbl_res_init_leonis(adapter);
if (ret)
goto res_init_fail;
return adapter;
adap->intf.resource_ops_tbl is published but has no consumer yet, and
nbl_res_vsi_id_to_pf_id() and nbl_res_pf_dev_vsi_type_to_hw_vsi_type() are
non-static with no users outside nbl_resource.c.
Could the commit message describe the guarantee that exists at this point in
the series, i.e. the has_ctrl checks inside the helpers themselves?
The same concern applies to the ordering comment in
nbl_res_ctrl_dev_sriov_info_init(), see below.
> diff --git a/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c b/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c
> new file mode 100644
> index 000000000000..a719cc8fbf8a
> --- /dev/null
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_hw/nbl_hw_leonis/nbl_resource_leonis.c
> @@ -0,0 +1,334 @@
[ ... ]
> + eth_info->eth_num = fw_port_num;
> + /* Intentional design constraint: each PF maps to exactly one
> + * Ethernet port. This couples PF identity to port identity
> + * and is required by nbl_res_get_eth_id() which indexes
> + * eth_info->eth_id[] by relative PF id.
> + */
> + if (res_mgt->resource_info->max_pf != eth_info->eth_num) {
> + dev_err(dev, "Invalid PF-to-port topology: max_pf=%u, eth_num=%u\n",
> + res_mgt->resource_info->max_pf, eth_info->eth_num);
> + return -EINVAL;
> + }
[Severity: Medium]
Is the equality of these two values actually guaranteed by the hardware?
max_pf comes from the k_pf_mask register via nbl_res_init_pf_num(), while
eth_num comes from NBL_FW_BOARD_DW3 port_num via nbl_hw_get_board_info().
The two quantities are reported independently by firmware, and the only
statement that they must match is this comment.
The consequence is a probe failure: nbl_probe() -> nbl_core_init() ->
nbl_res_init_leonis() -> nbl_res_start() -> nbl_res_ctrl_dev_setup_eth_info()
returns -EINVAL, and nbl_core_init() turns that into ERR_PTR(ret), so the
control PF does not bind at all.
Would it make sense to document this firmware contract in nbl_def_hw.h next
to get_host_pf_mask/get_board_info, and to mention in the changelog that this
patch introduces new fatal probe conditions?
> +
> + /*
> + * Original comment said dual-port board eth_id fixed to 0,2;
> + * Code accepts any contiguous valid bitmap bits (0/1 or 0/2 etc).
> + * Firmware only needs to report correct count of active ports,
> + * no hard-coded fixed bit positions required.
> + */
> + for (i = 0; i < NBL_MAX_ETHERNET; i++) {
> + if ((1 << i) & eth_bitmap) {
> + set_bit(i, eth_info->eth_bitmap);
> + eth_info->eth_id[eth_num] = i;
> + eth_info->logic_eth_id[i] = eth_num;
> + eth_num++;
> + }
> + }
[Severity: Low]
This isn't a bug, but the word "contiguous" in the comment does not match the
loop, and the example given (0/2) is not contiguous either.
The loop imposes no contiguity rule: any subset of bits 0..3 whose population
count equals board_info.eth_num (and equals max_pf) is accepted, so
eth_bitmap = 0b1010 is mapped to PF0/PF1 as well.
Should the word be dropped, or should the bitmap actually be checked for
contiguity?
[ ... ]
> + res_mgt->resource_info->sriov_info = sriov_info;
> + /*
> + * common->hw_bus supplies bus number for channel mailbox QINFO mapping.
> + * Execution order guarantee: this assignment runs before
> + * cfg_chan_qinfo_map_table() in nbl_dev_start(), only executed
> + * on control PF path.
> + */
> + common->hw_bus = hw_bus;
[Severity: Low]
Where is nbl_dev_start()? It does not exist at this commit, and later in the
series cfg_chan_qinfo_map_table() is reached from nbl_dev_setup_ctrl_dev() via
nbl_dev_setup_chan_qinfo():
nbl_dev_setup_ctrl_dev()
nbl_dev_setup_chan_qinfo(dev_mgt, NBL_CHAN_TYPE_MAILBOX)
cfg_chan_qinfo_map_table()
so the function named in the ordering comment is wrong even at the end of the
series. Could the comment name the actual caller?
[ ... ]
> +static int nbl_res_init_pf_num(struct nbl_resource_mgt *res_mgt)
> +{
> + struct nbl_hw_ops *hw_ops = res_mgt->hw_ops_tbl->ops;
> + u32 exp_contiguous_mask = 0;
> + u32 pf_mask = 0;
> + u32 pf_num = 0;
> + int i;
> +
> + hw_ops->get_host_pf_mask(res_mgt->hw_ops_tbl->priv, &pf_mask);
> +
> + /*
> + * k_pf_mask register rule:
> + * bit N == 0 -> PF#N enabled; bit N == 1 -> PF#N masked out.
> + * Hardware constraint: bit0 is reserved, PF0 cannot be masked.
> + * All-zero pf_mask means all PF0~PF7 are enabled.
> + *
> + * Product firmware constraint: only 3 valid configurations supported:
> + * 1 PF (PF0 only): pf_num = 1, mask = 0xfe
> + * 2 PFs (PF0,PF1): pf_num = 2, mask = 0xfc
> + * 4 PFs (PF0~PF3): pf_num = 4, mask = 0xf0
> + * No other PF count or sparse/non-contiguous PF layout is allowed.
> + */
> + for (i = 0; i < NBL_MAX_PF; i++) {
> + if (!(pf_mask & (1 << i)))
> + pf_num++;
> + }
> +
> + /*
> + * Sanity check: enabled PFs must be contiguous starting from PF0.
> + * Current resource framework uses relative PF id, sparse PF layout
> + * will cause mismatch between resource layer and hardware func_id.
> + */
> + for (i = 0; i < pf_num; i++)
> + exp_contiguous_mask |= BIT(i);
> + if ((pf_mask & exp_contiguous_mask) != 0) {
> + dev_err(res_mgt->common->dev,
> + "pf_mask 0x%08x: non-contiguous enabled PF, unsupported\n",
> + pf_mask);
> + return -EINVAL;
> + }
[Severity: Medium]
Does this treatment of bit0 agree with the ops documentation?
nbl_def_hw.h says of the same register:
* PF0 cannot be masked, bit0 is reserved and has no hardware effect.
* All-zero mask indicates all supported PFs are present and enabled.
but here bit0 is counted as a normal PF enable bit, and the contiguity test
then requires it to be clear: exp_contiguous_mask always contains BIT(0) for
any accepted pf_num >= 1, so a pf_mask with bit0 set fails.
Two examples: mask 0xff (PF0 only, with the documented-as-reserved bit0 also
set) gives pf_num == 0, and mask 0xfd gives pf_num == 1 with bit0 set and
trips the contiguity check. Both end in -EINVAL and an aborted probe.
Should nbl_res_init_pf_num() ignore bit0, or should the header comment be
corrected to say bit0 is a real enable bit?
> +
> + /* Only allow product-specified PF count: 1 / 2 / 4 */
> + if (pf_num != 1 && pf_num != 2 && pf_num != 4) {
> + dev_err(res_mgt->common->dev,
> + "Invalid pf_num=%u (mask=0x%08x), only 1/2/4 PFs supported\n",
> + pf_num, pf_mask);
> + return -EINVAL;
> + }
[Severity: Medium]
What happens on a board where the k_pf_mask register still reads its reset
value of zero? nbl_def_hw.h describes an all-zero mask as "all supported PFs
are present and enabled", which yields pf_num == 8 here and is then rejected
with -EINVAL, failing probe.
Is the all-zero case expected to be rejected, and if so should the header
comment say so?
[ ... ]
> diff --git a/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h b/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h
> index 4fc987c0e56d..61dd97c779ef 100644
> --- a/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_channel.h
> @@ -39,6 +39,16 @@ enum nbl_chan_state {
> NBL_CHAN_STATE_NBITS
> };
>
> +struct nbl_board_port_info {
> + u8 eth_num;
> + u8 eth_speed;
> + u8 p4_version;
> + u8 rsv[5];
> +};
> +
> +static_assert(sizeof(struct nbl_board_port_info) == 8,
> + "nbl_board_port_info size must be 8 bytes");
> +
[Severity: Low]
Should this header include linux/build_bug.h? static_assert is defined there,
while the only include in nbl_def_channel.h is linux/types.h.
It builds today because every current translation unit pulls in linux/device.h
or linux/pci.h before the nbl headers, but nbl_hw_reg.h already includes
nbl_def_channel.h before linux/pci.h arrives via nbl_core.h, so a future .c or
.h that includes nbl_def_channel.h first would fail with an implicit
declaration of static_assert.
[ ... ]
> diff --git a/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h b/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h
> index 587ac0c58c24..ee53f9e10a8e 100644
> --- a/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_include/nbl_def_hw.h
> @@ -34,9 +35,13 @@ struct nbl_hw_ops {
> * or other PF counts are unsupported by driver resource management.
> */
> void (*get_host_pf_mask)(struct nbl_hw_mgt *hw_mgt, u32 *pf_mask);
> + void (*get_real_bus)(struct nbl_hw_mgt *hw_mgt, u8 *bus);
[Severity: Low]
This isn't a bug, but the kernel-doc block just above get_host_pf_mask
documents "@priv: hw ops private context" while the declared first parameter
is struct nbl_hw_mgt *hw_mgt, so scripts/kernel-doc -Wall reports an
undescribed parameter hw_mgt plus an excess @priv description.
Since this patch extends the same ops structure and its new resource-layer
consumer relies on that comment block for the pf_mask contract, could the
parameter name be fixed here?
[ ... ]
> diff --git a/drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c b/drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c
> index b7c80ea54c8d..1aafed2d46d7 100644
> --- a/drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c
> +++ b/drivers/net/ethernet/nebula-matrix/nbl/nbl_main.c
> @@ -42,7 +44,13 @@ struct nbl_adapter *nbl_core_init(struct pci_dev *pdev,
> ret = nbl_chan_init_common(adapter);
> if (ret)
> goto chan_init_fail;
> +
> + ret = nbl_res_init_leonis(adapter);
> + if (ret)
> + goto res_init_fail;
> return adapter;
[Severity: Medium]
This is the point where the new firmware topology validations become probe
failures: any -EINVAL from nbl_res_init_pf_num() or
nbl_res_ctrl_dev_setup_eth_info() propagates here and nbl_core_init() returns
ERR_PTR(ret), so nbl_probe() reports "Nbl adapter init fail" and the device
does not bind.
Could the changelog mention that this patch alone can turn a previously
successful probe into -EINVAL depending on register content?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260831021408.2325-1-illusion.wang%40nebula-matrix.com
next prev parent reply other threads:[~2026-09-03 17:18 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-31 2:13 [PATCH v26 net-next 00/10] nbl driver for Nebulamatrix NICs illusion.wang
2026-08-31 2:13 ` [PATCH v26 net-next 01/10] net/nebula-matrix: add minimum nbl build framework illusion.wang
2026-09-03 17:18 ` [v26,net-next,01/10] " netdev-bot+sashiko
2026-08-31 2:13 ` [PATCH v26 net-next 02/10] net/nebula-matrix: add core driver architecture and HW layer initialization illusion.wang
2026-09-03 17:18 ` [v26,net-next,02/10] " netdev-bot+sashiko
2026-08-31 2:13 ` [PATCH v26 net-next 03/10] net/nebula-matrix: add channel layer illusion.wang
2026-09-03 17:18 ` [v26,net-next,03/10] " netdev-bot+sashiko
2026-08-31 2:13 ` [PATCH v26 net-next 04/10] net/nebula-matrix: add common resource implementation illusion.wang
2026-09-03 17:18 ` netdev-bot+sashiko [this message]
2026-08-31 2:13 ` [PATCH v26 net-next 05/10] net/nebula-matrix: add intr " illusion.wang
2026-09-03 17:18 ` [v26,net-next,05/10] " netdev-bot+sashiko
2026-08-31 2:13 ` [PATCH v26 net-next 06/10] net/nebula-matrix: add chip-wide hardware init/deinit implementation illusion.wang
2026-09-03 17:18 ` [v26,net-next,06/10] " netdev-bot+sashiko
2026-08-31 2:13 ` [PATCH v26 net-next 07/10] net/nebula-matrix: dispatch: add control-level routing core infrastructure illusion.wang
2026-08-31 2:13 ` [PATCH v26 net-next 08/10] net/nebula-matrix: dispatch: implement channel RPC framework and serialize hardware ops illusion.wang
2026-09-03 17:18 ` [v26,net-next,08/10] " netdev-bot+sashiko
2026-08-31 2:14 ` [PATCH v26 net-next 09/10] net/nebula-matrix: add common/ctrl dev init/remove operation illusion.wang
2026-09-03 17:18 ` [v26,net-next,09/10] " netdev-bot+sashiko
2026-08-31 2:14 ` [PATCH v26 net-next 10/10] net/nebula-matrix: add common dev start/stop operation illusion.wang
2026-09-03 17:18 ` [v26,net-next,10/10] " 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=178845591752.3394541.1488499474047337134@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=alvin.wang@nebula-matrix.com \
--cc=andrew+netdev@lunn.ch \
--cc=corbet@lwn.net \
--cc=dimon.zhao@nebula-matrix.com \
--cc=edumazet@google.com \
--cc=enelsonmoore@gmail.com \
--cc=hkallweit1@gmail.com \
--cc=horms@kernel.org \
--cc=illusion.wang@nebula-matrix.com \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lukas.bulwahn@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sam.chen@nebula-matrix.com \
--cc=skhan@linuxfoundation.org \
--cc=vadim.fedorenko@linux.dev \
/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