net: brcm: netXtreme driver
PATCH v4 1/2 net: brcm: netXtreme driver
From: Bharat Gooty <[email protected]>
Broadcom bnxt L2 driver support. Used by the Broadcom iproc platforms.
---
Changes in v4:
- remove static num_cards and use dev_seq(dev) instead
- add .probe
- merged probe/remove methods
- select PCI_INIT_R when BNXT_ETH is selected
Changes in v3:
- change printf to debug in display_banner
- remove get/set/print mac/speed
- remove bnxt_hwrm_set_nvmem
Changes in v2:
- rebase and remove DM_PCI dependency from BNXT_ETH
- remove tautology assignment from debug_resp()
drivers/net/Kconfig | 1 + drivers/net/Makefile | 1 + drivers/net/bnxt/Kconfig | 7 + drivers/net/bnxt/Makefile | 5 + drivers/net/bnxt/bnxt.c | 1775 +++++++++++++++++++++++++++++++++++ drivers/net/bnxt/bnxt_dbg.h | 537 +++++++++++ drivers/net/bnxt/pci_ids.h | 17 + include/broadcom/bnxt.h | 395 ++++++++ include/broadcom/bnxt_hsi.h | 889 ++++++++++++++++++ include/broadcom/bnxt_ver.h | 22 + 10 files changed, 3649 insertions(+) create mode 100644 drivers/net/bnxt/Kconfig create mode 100644 drivers/net/bnxt/Makefile create mode 100644 drivers/net/bnxt/bnxt.c create mode 100644 drivers/net/bnxt/bnxt_dbg.h create mode 100644 drivers/net/bnxt/pci_ids.h create mode 100644 include/broadcom/bnxt.h create mode 100644 include/broadcom/bnxt_hsi.h create mode 100644 include/broadcom/bnxt_ver.h
drivers/net/Kconfig +1 -0
@@ -1,6 +1,7 @@ source "drivers/net/phy/Kconfig" source "drivers/net/pfe_eth/Kconfig" source "drivers/net/fsl-mc/Kconfig" +source "drivers/net/bnxt/Kconfig" config ETH def_bool y
drivers/net/Makefile +1 -0
@@ -101,3 +101,4 @@ obj-$(CONFIG_HIGMACV300_ETH) += higmacv300.o obj-$(CONFIG_MDIO_SANDBOX) += mdio_sandbox.o obj-$(CONFIG_FSL_ENETC) += fsl_enetc.o fsl_enetc_mdio.o obj-$(CONFIG_FSL_LS_MDIO) += fsl_ls_mdio.o +obj-$(CONFIG_BNXT_ETH) += bnxt/
drivers/net/bnxt/Kconfig new file +7 -0
@@ -0,0 +1,7 @@ +config BNXT_ETH + bool "BNXT PCI support" + depends on DM_ETH + select PCI_INIT_R + help + This driver implements support for bnxt pci controller + driver of ethernet class.
drivers/net/bnxt/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2019-2021 Broadcom. + +# Broadcom nxe Ethernet driver +obj-y += bnxt.o
drivers/net/bnxt/bnxt.c new file +1775 -0
1,775 lines not on this page · raw message
drivers/net/bnxt/bnxt_dbg.h new file +537 -0
537 lines not on this page · raw message
drivers/net/bnxt/pci_ids.h new file +17 -0
@@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* +* Copyright 2019-2021 Broadcom. +*/ + +#ifndef _PCI_IDS_H_ +#define _PCI_IDS_H_ + +#define PCI_VID_BROADCOM 0x14e4 +#define PCI_DID_NXT_57320_1 0x16F0 + +static struct pci_device_id bnxt_nics[] = { + {PCI_DEVICE (PCI_VID_BROADCOM ,PCI_DID_NXT_57320_1 )}, + {} +}; + +#endif /* _PCI_IDS_H_ */
include/broadcom/bnxt.h new file +395 -0
395 lines not on this page · raw message
include/broadcom/bnxt_hsi.h new file +889 -0
253 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 15 lines
2.17.1 -- This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.
Part of the diff is not shown here. View the raw message.
PATCH v4 2/2 board: brcm-ns3: Load netXtreme firmware
From: Bharat Gooty <[email protected]>
Load NetXtreme firmware in board_init when BNXT_ETH is selected.
---
Changes in v4:
- remove bnxt command
- load bnxt firmware in board_init
Changes in v3:
- remove commands set/get mac/speed
- add doc/bnxt.rst
board/broadcom/bcmns3/ns3.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
board/broadcom/bcmns3/ns3.c +4 -1
@@ -150,7 +150,10 @@ int board_init(void)if (bl33_info->version !=BL33_INFO_VERSION )printf ("*** warning: ATF BL31 and U-Boot not in sync! ***\n" ); - +#if CONFIG_IS_ENABLED (BNXT_ETH ) +if (chimp_fastboot_optee () !=0 ) +printf ("*** warning: secure chimp fastboot failed! ***\n" ); +#endif return 0 ; }
Signature · 15 lines
2.17.1 -- This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.
Hello Roman,
Quoted 16 lines · On Thu, 28 Oct 2021 16:29:28 -0700 Roman Bacik <[email protected]> wrote:
drivers/net/bnxt/bnxt.c new file +16
-0+void bnxt_env_set_ethaddr (struct udevice *dev) +{ +struct eth_pdata *plat =dev_get_plat (dev); +char cmd[100 ]; +char var[32 ]; +u8 mac_env[ARP_HLEN ]; + +eth_env_get_enetaddr_by_index ("eth" ,dev_seq (dev), mac_env); +if (!memcmp (plat->enetaddr, mac_env,ARP_HLEN )) +return ; + +sprintf (var,dev_seq (dev) ?"%s%daddr" :"%saddr" ,"eth" ,dev_seq (dev)); +sprintf (cmd,"%s %s %pM" ,"env set -f" , var, plat->enetaddr); +run_command (cmd,CMD_FLAG_ENV ); +} +
drivers/net/bnxt/bnxt.c line 1569
Quoted 10 lines
drivers/net/bnxt/bnxt.c new file +10
-0+void bnxt_env_del_ethaddr (struct udevice *dev) +{ +struct eth_pdata *plat =dev_get_plat (dev); +char cmd[100 ]; +char var[32 ]; + +sprintf (var,dev_seq (dev) ?"%s%daddr" :"%saddr" ,"eth" ,dev_seq (dev)); +sprintf (cmd,"%s %s %pM" ,"env delete -f" , var, plat->enetaddr); +run_command (cmd,CMD_FLAG_ENV ); +}
And then in bnxt_eth_probe():
Quoted 1 line
drivers/net/bnxt/bnxt.c new file +1
-0+eth_env_get_enetaddr_by_index ("eth" ,dev_seq (dev), bp->mac_set);
...
drivers/net/bnxt/bnxt.c line 1740
Quoted 2 lines
drivers/net/bnxt/bnxt.c new file +2
-0+memcpy (plat->enetaddr, bp->mac_set,ETH_ALEN ); +bnxt_env_set_ethaddr (dev);
So if I understand this correctly, in bnxt_eth_probe(), you read env variable ethNaddr into bp->mac_set. Then bnxt_bring_chip() is called, which calls various functions, including bnxt_hwrm_func_qcaps_req(), which may overwrite bp->mac_set. Then bp->mac_set is copied into plat->enetaddr.
Then bnxt_env_set_ethaddr() is called, which reads the env variable ethNaddr again, and compares it with value in plat->enetaddr, and if they are different, it overwrites the value in ethNaddr with plat->enetaddr.
I have this to say:
- could you please explain why this is done so? I mean the logic behind this...
- it seems to me that you haven't read the documentation for struct env_ops in include/net.h: there are methods read_rom_hwaddr() and write_hwaddr(), which you could use, instead of implementing this whole mechanism ad-hoc. You should use those or explain your reasons why you aren't doing this
- why do you need the plat structure? Why not use bp->mac_set directly, without plat->enetaddr?
- the way you set and delete ethNaddr variable, by running U-Boot commands, is very weird, when there is a direct function for setting the value:
eth_env_set_enetaddr_by_index()
As for deleting:
- why do you need it in the first place? I mean you are removing the variable upon driver removal. No other ethernet driver does that...
- instead of assembling the "env delete" command it would make far more sense to include patch that adds env_del() function into env/common.c
I have another question: does this driver support adapters with SFP cages only, or also those with RJ-45 ports?
Thank you.
Marek
Hi Marek,
Quoted 45 lines · Marek Behún
Hello Roman,
Quoted 16 lines · On Thu, 28 Oct 2021 16:29:28 -0700 Roman Bacik <[email protected]> wrote:
drivers/net/bnxt/bnxt.c new file +16
-0+void bnxt_env_set_ethaddr (struct udevice *dev) +{ +struct eth_pdata *plat =dev_get_plat (dev); +char cmd[100 ]; +char var[32 ]; +u8 mac_env[ARP_HLEN ]; + +eth_env_get_enetaddr_by_index ("eth" ,dev_seq (dev), mac_env); +if (!memcmp (plat->enetaddr, mac_env,ARP_HLEN )) +return ; + +sprintf (var,dev_seq (dev) ?"%s%daddr" :"%saddr" ,"eth" ,dev_seq (dev)); +sprintf (cmd,"%s %s %pM" ,"env set -f" , var, plat->enetaddr); +run_command (cmd,CMD_FLAG_ENV ); +} +drivers/net/bnxt/bnxt.c line 1569
Quoted 10 lines
drivers/net/bnxt/bnxt.c new file +10
-0+void bnxt_env_del_ethaddr (struct udevice *dev) +{ +struct eth_pdata *plat =dev_get_plat (dev); +char cmd[100 ]; +char var[32 ]; + +sprintf (var,dev_seq (dev) ?"%s%daddr" :"%saddr" ,"eth" ,dev_seq (dev)); +sprintf (cmd,"%s %s %pM" ,"env delete -f" , var, plat->enetaddr); +run_command (cmd,CMD_FLAG_ENV ); +}And then in
bnxt_eth_probe():Quoted 1 line
+
eth_env_get_enetaddr_by_index("eth", dev_seq(dev), bp->mac_set);...
drivers/net/bnxt/bnxt.c line 1740
Quoted 2 lines
drivers/net/bnxt/bnxt.c new file +2
-0+memcpy (plat->enetaddr, bp->mac_set,ETH_ALEN ); +bnxt_env_set_ethaddr (dev);So if I understand this correctly, in
bnxt_eth_probe(), you read env variable ethNaddr intobp->mac_set. Thenbnxt_bring_chip()is called, which calls various functions, includingbnxt_hwrm_func_qcaps_req(), which may overwritebp->mac_set. Thenbp->mac_setis copied intoplat->enetaddr.
Quoted 8 lines
Then
bnxt_env_set_ethaddr()is called, which reads the env variable ethNaddr again, and compares it with value inplat->enetaddr, and if they are different, it overwrites the value in ethNaddr withplat->enetaddr.I have this to say:
- could you please explain why this is done so? I mean the logic behind this...
We read env to bp->mac_set in case hw does not have eth addr so it can use the random value from uboot. The bnxt_bring_chip will read mac programmed to hw nvram and set it into bp if available. The adress in hw and address in plat must be the same in the end.
Quoted 3 lines
- it seems to me that you haven't read the documentation for struct
env_opsininclude/net.h: there are methodsread_rom_hwaddr()andwrite_hwaddr(), which you could use, instead of implementing this
The mac address can be read from bp only after bnxt_bring_chip is called, which is after read_rom_hwaddr is called. Theoretically we can call bnxt_bring_chip in bind or in read_rom_hwaddr and then one can use this method if desired.
Quoted 8 lines
whole mechanism ad-hoc. You should use those or explain your reasons why you aren't doing this
- why do you need the plat structure? Why not usebp->mac_setdirectly, withoutplat->enetaddr?
- the way you set and delete ethNaddr variable, by running U-Boot commands, is very weird, when there is a direct function for setting the value:
eth_env_set_enetaddr_by_index()
We can change and use this method.
Quoted 6 lines
As for deleting:
- why do you need it in the first place? I mean you are removing the variable upon driver removal. No other ethernet driver does that...
- instead of assembling the "env delete" command it would make far more sense to include patch that addsenv_del()function intoenv/common.c
You are right, we can remove deleting. It is there because our earlier logic depended on it.
Quoted 3 lines
I have another question: does this driver support adapters with SFP cages only, or also those with RJ-45 ports?
Boards we have use SFP ports only. But theoretically one can use 10G traffic with RJ45. Lower than 10G speeds like 1G traffic are not supported by HW.
Quoted 4 lines
Thank you.
Marek
Signature · 11 lines
This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.
Quoted 4 lines · On Sat, 30 Oct 2021 08:48:05 -0700 Roman Bacik <[email protected]> wrote:
The mac address can be read from bp only after
bnxt_bring_chipis called, which is afterread_rom_hwaddris called. Theoretically we can callbnxt_bring_chipin bind or inread_rom_hwaddrand then one can use this method if desired.
How long does bnxt_bring_chip() take? In milliseconds? If it isn't extremely long, I think it could be called from read_rom_hwaddr...
Quoted 3 lines
Quoted 1 line
eth_env_set_enetaddr_by_index()We can change and use this method.
Pls do, and drop the env deletion.
Marek
Hi Marek,
Quoted 21 lines
-----Original Message-----
From: Marek Behún <[email protected]>
Sent: Sunday, October 31, 2021 3:56 AM
To: Roman Bacik <[email protected]>
Cc: U-Boot Mailing List <[email protected]>; Bharat Gooty <[email protected]>; Joe Hershberger <[email protected]>; Ramon Fried <[email protected]>; [email protected]
Subject: Re: [PATCH v4 1/2] net: brcm: netXtreme driverQuoted 4 lines · On Sat, 30 Oct 2021 08:48:05 -0700 Roman Bacik <[email protected]> wrote:
The mac address can be read from bp only after
bnxt_bring_chipis called, which is afterread_rom_hwaddris called. Theoretically we can callbnxt_bring_chipin bind or inread_rom_hwaddrand then one can use this method if desired.How long does
bnxt_bring_chip()take? In milliseconds? If it isn't extremely long, I think it could be called fromread_rom_hwaddr...
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
eth_env_set_enetaddr_by_index()We can change and use this method.
Pls do, and drop the env deletion.
Marek
We will make requested changes in v5.
Thank you very much for your review,
Roman
Signature · 11 lines
This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.