diff mbox series

[net-next] bnx2x: turn off FCoE if storage MAC-address setup failed

Message ID 20240712132915.54710-1-kiryushin@ancud.ru (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [net-next] bnx2x: turn off FCoE if storage MAC-address setup failed | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 816 this patch: 816
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 821 this patch: 821
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 823 this patch: 823
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 18 this patch: 18
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-07-13--03-00 (tests: 696)

Commit Message

Nikita Kiryushin July 12, 2024, 1:29 p.m. UTC
As of now, initial storage MAC setup (in bnx2x_init_one) is not checked.

This can lead to unexpected FCoE behavior (as address will be in unexpected
state) without notice.

Check dev_addr_add for storage MAC and if it failes produce error message
and turn off FCoE feature.

Signed-off-by: Nikita Kiryushin <kiryushin@ancud.ru>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Andrew Lunn July 13, 2024, 2:41 p.m. UTC | #1
On Fri, Jul 12, 2024 at 04:29:15PM +0300, Nikita Kiryushin wrote:
> As of now, initial storage MAC setup (in bnx2x_init_one) is not checked.
> 
> This can lead to unexpected FCoE behavior (as address will be in unexpected
> state) without notice.
> 
> Check dev_addr_add for storage MAC and if it failes produce error message
> and turn off FCoE feature.

How broken is it when this happens? This is called from .probe. So
returning the error code will fail the probe and the device will not
be created. Is that a better solution?

	Andrew
Nikita Kiryushin July 15, 2024, 2:10 p.m. UTC | #2
> How broken is it when this happens?
I can not say what would happen exactly, if the address is not assigned
the way it should. But there would be at least an attempt to free unallocated
address (in __bnx2x_remove).

> This is called from .probe. So
> returning the error code will fail the probe and the device will not
> be created. Is that a better solution?
To me, it does not seem fatal, that is why I am not returning error,
just print it and disable FCoE. The "rc" set will not be returned (unless
jumped to error handlers, which we are not doing). Would it be better, if
I used some other result variable other than "rc"? The check could be the call,
but than handling would be inside a lock, which I think is a bad idea.
Nikita Kiryushin Oct. 25, 2024, 6:15 p.m. UTC | #3
On 7/15/24 17:10, Nikita Kiryushin wrote:
>> How broken is it when this happens?
> I can not say what would happen exactly, if the address is not assigned
> the way it should. But there would be at least an attempt to free unallocated
> address (in __bnx2x_remove).
>
>> This is called from .probe. So
>> returning the error code will fail the probe and the device will not
>> be created. Is that a better solution?
> To me, it does not seem fatal, that is why I am not returning error,
> just print it and disable FCoE. The "rc" set will not be returned (unless
> jumped to error handlers, which we are not doing). Would it be better, if
> I used some other result variable other than "rc"? The check could be the call,
> but than handling would be inside a lock, which I think is a bad idea.

The patch is marked as "Changes Requested" at the Patchwork,
but I am not sure, what has to be done with it.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 678829646cec..c5d5e85777d4 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -13988,8 +13988,12 @@  static int bnx2x_init_one(struct pci_dev *pdev,
 	if (!NO_FCOE(bp)) {
 		/* Add storage MAC address */
 		rtnl_lock();
-		dev_addr_add(bp->dev, bp->fip_mac, NETDEV_HW_ADDR_T_SAN);
+		rc = dev_addr_add(bp->dev, bp->fip_mac, NETDEV_HW_ADDR_T_SAN);
 		rtnl_unlock();
+		if (rc) {
+			dev_err(&pdev->dev, "Cannot add storage MAC address\n");
+			bp->flags |= NO_FCOE_FLAG;
+		}
 	}
 	BNX2X_DEV_INFO(
 	       "%s (%c%d) PCI-E found at mem %lx, IRQ %d, node addr %pM\n",