net: brcm: netXtreme driver
PATCH v5 1/2 net: brcm: netXtreme driver
From: Bharat Gooty <[email protected]>
Broadcom bnxt L2 driver support. Used by the Broadcom iproc platforms.
---
Changes in v5:
- remove bnxt_env_set_ethaddr/bnxt_env_del_ethaddr methods
- add .read_rom_hwaddr = bnxt_read_rom_hwaddr
- move bnxt_bring_pci/bnxt_bring_chip to bnxt_read_rom_hwddr
- move mac copy from priv to plat to bnxt_read_rom_hwaddr
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 | 1748 +++++++++++++++++++++++++++++++++++ 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, 3622 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 +1748 -0
1,748 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
280 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 v5 2/2 board: brcm-ns3: Load netXtreme firmware
From: Bharat Gooty <[email protected]>
Load NetXtreme firmware in board_init when BNXT_ETH is selected.
---
(no changes since v4)
Changes in v4:
- remove bnxt commands
- 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.
Quoted 69 lines · On Mon, 1 Nov 2021 13:21:44 -0700 Roman Bacik <[email protected]> wrote:
drivers/net/bnxt/bnxt.c new file +69
-0+static int set_phy_speed (struct bnxt *bp) +{ +char name[20 ]; +char name1[30 ]; +u16 flag =PHY_STATUS |PHY_SPEED |DETECT_MEDIA ; + +/* Query Link Status */ +if (bnxt_hwrm_port_phy_qcfg (bp, flag) !=STATUS_SUCCESS ) +return STATUS_FAILURE ; + +switch (bp->current_link_speed) { +case PORT_PHY_QCFG_RESP_LINK_SPEED_100GB : +sprintf (name,"%s %s" , str_100, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_50GB : +sprintf (name,"%s %s" , str_50, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_40GB : +sprintf (name,"%s %s" , str_40, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_25GB : +sprintf (name,"%s %s" , str_25, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_20GB : +sprintf (name,"%s %s" , str_20, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_10GB : +sprintf (name,"%s %s" , str_10, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB : +sprintf (name,"%s %s" , str_2_5, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_2GB : +sprintf (name,"%s %s" , str_2, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_1GB : +sprintf (name,"%s %s" , str_1, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_100MB : +sprintf (name,"%s %s" , str_100, str_mbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_10MB : +sprintf (name,"%s %s" , str_10, str_mbps); +break ; +default : +sprintf (name,"%s %x" , str_unknown, bp->current_link_speed); + } + +sprintf (name1,"bnxt_eth%u_phy_speed" , bp->cardnum); +env_set (name1, name); +dbg_phy_speed (bp, name); + +return STATUS_SUCCESS ; +} + +static int set_phy_link (struct bnxt *bp,u32 tmo) +{ +char name[32 ]; +int ret; + +set_phy_speed (bp); +dbg_link_status (bp); +if (bp->link_status ==STATUS_LINK_ACTIVE ) { +dbg_link_state (bp, tmo); +sprintf (name,"bnxt_eth%u_link" , bp->cardnum); +env_set (name,"up" ); +sprintf (name,"bnxt_eth%u_media" , bp->cardnum); +env_set (name,"connected" ); + ret =STATUS_SUCCESS ;
drivers/net/bnxt/bnxt.c line 1376
Quoted 10 lines
drivers/net/bnxt/bnxt.c new file +10
-0+ }else { +sprintf (name,"bnxt_eth%u_link" , bp->cardnum); +env_set (name,"down" ); +sprintf (name,"bnxt_eth%u_media" , bp->cardnum); +env_set (name,"disconnected" ); + ret =STATUS_FAILURE ; + } + +return ret; +}
Hi Roman,
your proposal still contains non-standard and unneeded setting of environment variables. An ethernet driver should never do this. In fact no driver besides board code or sysinfo driver should do this directly.
There are other mechanisms for reporting PHY connection information in U-Boot, please use those if you need them (e.g. implement a PHY driver), but remove all env_set() calls from your ethernet driver.
Rationale: historically, many times things were solved with ad-hoc code in U-Boot, which did this kind of thing and similar. It got out of hand pretty fast, and it was horrible. So some people dedided to fix it, proposing APIs, unifying code, deduplicating code and so on. This is still, in fact, going on. For your driver to have it's own mechanism for reporting link status, by setting env variables, is going against this whole work.
I suggest for now just to remove these calls. When the driver is merged, we can work on extending support for passing link information to U-Boot via ethernet PHY API, if you need it.
Marek
Hi Marek,
Quoted 111 lines
-----Original Message-----
From: Marek Behún <[email protected]>
Sent: Tuesday, November 2, 2021 5:07 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]>
Subject: Re: [PATCH v5 1/2] net: brcm: netXtreme driverQuoted 70 lines · On Mon, 1 Nov 2021 13:21:44 -0700 Roman Bacik <[email protected]> wrote:
drivers/net/bnxt/bnxt.c new file +46
-0+static int set_phy_speed (struct bnxt *bp) +{ +char name[20 ]; +char name1[30 ]; +u16 flag =PHY_STATUS |PHY_SPEED |DETECT_MEDIA ; + +/* Query Link Status */ +if (bnxt_hwrm_port_phy_qcfg (bp, flag) !=STATUS_SUCCESS ) +return STATUS_FAILURE ; + +switch (bp->current_link_speed) { +case PORT_PHY_QCFG_RESP_LINK_SPEED_100GB : +sprintf (name,"%s %s" , str_100, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_50GB : +sprintf (name,"%s %s" , str_50, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_40GB : +sprintf (name,"%s %s" , str_40, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_25GB : +sprintf (name,"%s %s" , str_25, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_20GB : +sprintf (name,"%s %s" , str_20, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_10GB : +sprintf (name,"%s %s" , str_10, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_2_5GB : +sprintf (name,"%s %s" , str_2_5, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_2GB : +sprintf (name,"%s %s" , str_2, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_1GB : +sprintf (name,"%s %s" , str_1, str_gbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_100MB : +sprintf (name,"%s %s" , str_100, str_mbps); +break ; +case PORT_PHY_QCFG_RESP_LINK_SPEED_10MB : +sprintf (name,"%s %s" , str_10, str_mbps); +break ; +default : + sprintf(name, "%s %x", str_unknown, bp-
current_link_speed);drivers/net/bnxt/bnxt.c new file +23
-0+ } + +sprintf (name1,"bnxt_eth%u_phy_speed" , bp->cardnum); +env_set (name1, name); +dbg_phy_speed (bp, name); + +return STATUS_SUCCESS ; +} + +static int set_phy_link (struct bnxt *bp,u32 tmo) +{ +char name[32 ]; +int ret; + +set_phy_speed (bp); +dbg_link_status (bp); +if (bp->link_status ==STATUS_LINK_ACTIVE ) { +dbg_link_state (bp, tmo); +sprintf (name,"bnxt_eth%u_link" , bp->cardnum); +env_set (name,"up" ); +sprintf (name,"bnxt_eth%u_media" , bp->cardnum); +env_set (name,"connected" ); + ret =STATUS_SUCCESS ;drivers/net/bnxt/bnxt.c line 1376
Quoted 10 lines
drivers/net/bnxt/bnxt.c new file +10
-0+ }else { +sprintf (name,"bnxt_eth%u_link" , bp->cardnum); +env_set (name,"down" ); +sprintf (name,"bnxt_eth%u_media" , bp->cardnum); +env_set (name,"disconnected" ); + ret =STATUS_FAILURE ; + } + +return ret; +}Hi Roman,
your proposal still contains non-standard and unneeded setting of environment variables. An ethernet driver should never do this. In fact no driver besides board code or sysinfo driver should do this directly.
There are other mechanisms for reporting PHY connection information in U-Boot, please use those if you need them (e.g. implement a PHY driver), but remove all
env_set()calls from your ethernet driver.Rationale: historically, many times things were solved with ad-hoc code in U-Boot, which did this kind of thing and similar. It got out of hand pretty fast, and it was horrible. So some people dedided to fix it, proposing APIs, unifying code, deduplicating code and so on. This is still, in fact, going on. For your driver to have it's own mechanism for reporting link status, by setting env variables, is going against this whole work.
Quoted 5 lines
I suggest for now just to remove these calls. When the driver is merged, we can work on extending support for passing link information to U-Boot via ethernet PHY API, if you need it.
Marek
We will remove env_set() calls in v6 as requested. Thanks,
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.