Re: [PATCH v1 1/2] net: brcm: netXtreme driver
On Mon, Aug 23, 2021 at 5:14 PM Bharat Kumar Reddy Gooty wrote: > > From: Bharat Gooty > > Broadcom bnxt L2 driver support. Used by the Broadcom > iproc platforms. > > Signed-off-by: Bharat Gooty > --- > drivers/net/Kconfig |1 + > drivers/net/Makefile|1 + > drivers/net/bnxt/Kconfig|7 + > drivers/net/bnxt/Makefile |5 + > drivers/net/bnxt/bnxt.c | 2025 +++ > drivers/net/bnxt/bnxt_dbg.h | 538 ++ > drivers/net/bnxt/pci_ids.h | 17 + > include/broadcom/bnxt.h | 419 > include/broadcom/bnxt_hsi.h | 889 +++ > include/broadcom/bnxt_ver.h | 22 + > 10 files changed, 3924 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 > > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig > index 382639044b..ff2c1797b1 100644 > --- a/drivers/net/Kconfig > +++ b/drivers/net/Kconfig > @@ -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 DM_ETH > bool "Enable Driver Model for Ethernet drivers" > diff --git a/drivers/net/Makefile b/drivers/net/Makefile > index a44a7d3f56..f739f1e157 100644 > --- a/drivers/net/Makefile > +++ b/drivers/net/Makefile > @@ -96,3 +96,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/ > diff --git a/drivers/net/bnxt/Kconfig b/drivers/net/bnxt/Kconfig > new file mode 100644 > index 00..c263616612 > --- /dev/null > +++ b/drivers/net/bnxt/Kconfig > @@ -0,0 +1,7 @@ > +config BNXT_ETH > + bool "BNXT PCI support" > + depends on DM_ETH && DM_PCI > + help > + This driver implements support for bnxt pci controller > + driver of ethernet class. > + > diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile > new file mode 100644 > index 00..a9d6ce00d5 > --- /dev/null > +++ b/drivers/net/bnxt/Makefile > @@ -0,0 +1,5 @@ > +# SPDX-License-Identifier: GPL-2.0+ > +# Copyright 2019-2021 Broadcom. > + > +# Broadcom nxe Ethernet driver > +obj-y += bnxt.o > diff --git a/drivers/net/bnxt/bnxt.c b/drivers/net/bnxt/bnxt.c > new file mode 100644 > index 00..144df587f7 > --- /dev/null > +++ b/drivers/net/bnxt/bnxt.c > @@ -0,0 +1,2025 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Copyright 2019-2021 Broadcom. > + */ > + > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include "bnxt_dbg.h" > +#include "pci_ids.h" > + > +#define bnxt_down_chip(bp) bnxt_hwrm_run(down_chip, bp, 0) > +#define bnxt_bring_chip(bp)bnxt_hwrm_run(bring_chip, bp, 1) > + > +static const char banner[] = DRV_MODULE_DESC " v" UBOOT_MODULE_VER ","; > +static const char fw_ver[] = " FW v"; > + > +static int num_cards; /* Number of bnxt devices seen so far */ > + > +static void display_banner(struct bnxt *bp) > +{ > + int i; > + > + printf(banner); > + printf(fw_ver); > + printf("%d.%d.", bp->fw_maj, bp->fw_min); > + printf("%d.%d\n", bp->fw_bld, bp->fw_rsvd); > + printf("ETH MAC: "); > + for (i = 0; i < ETH_ALEN; i++) { > + printf("%02x", bp->mac_set[i]); > + if (i != (ETH_ALEN - 1)) > + printf(":"); > + } > + > + printf(", Port(%d), PF(%d)\n", bp->port_idx, bp->ordinal_value); > +} > + > +/* Broadcom ethernet driver PCI APIs. */ > +static void bnxt_bring_pci(struct bnxt *bp) > +{ > + u16 cmd_reg = 0; > + > + pci_read_word16(bp->pdev, PCI_VENDOR_ID, >vendor_id); > + pci_read_word16(bp->pdev, PCI_DEVICE_ID, >device_id); > + pci_read_word16(bp->pdev, > + PCI_SUBSYSTEM_VENDOR_ID, > + >subsystem_vendor); > + pci_read_word16(bp->pdev, PCI_SUBSYSTEM_ID, >subsystem_device); > + pci_read_word16(bp->pdev, PCI_COMMAND, >cmd_reg); > + pci_read_byte(bp->pdev, PCICFG_ME_REGISTER, >pf_num); > + pci_read_byte(bp->pdev, PCI_INTERRUPT_LINE, >irq); > + bp->bar0 = pci_map_bar(bp->pdev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM); > + bp->bar1 = pci_map_bar(bp->pdev, PCI_BASE_ADDRESS_2, PCI_REGION_MEM); > + bp->bar2 = pci_map_bar(bp->pdev, PCI_BASE_ADDRESS_4, PCI_REGION_MEM); > + cmd_reg = bp->cmd_reg | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER; > + cmd_reg
[PATCH v1 1/2] net: brcm: netXtreme driver
From: Bharat Gooty Broadcom bnxt L2 driver support. Used by the Broadcom iproc platforms. Signed-off-by: Bharat Gooty --- drivers/net/Kconfig |1 + drivers/net/Makefile|1 + drivers/net/bnxt/Kconfig|7 + drivers/net/bnxt/Makefile |5 + drivers/net/bnxt/bnxt.c | 2025 +++ drivers/net/bnxt/bnxt_dbg.h | 538 ++ drivers/net/bnxt/pci_ids.h | 17 + include/broadcom/bnxt.h | 419 include/broadcom/bnxt_hsi.h | 889 +++ include/broadcom/bnxt_ver.h | 22 + 10 files changed, 3924 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 diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 382639044b..ff2c1797b1 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -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 DM_ETH bool "Enable Driver Model for Ethernet drivers" diff --git a/drivers/net/Makefile b/drivers/net/Makefile index a44a7d3f56..f739f1e157 100644 --- a/drivers/net/Makefile +++ b/drivers/net/Makefile @@ -96,3 +96,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/ diff --git a/drivers/net/bnxt/Kconfig b/drivers/net/bnxt/Kconfig new file mode 100644 index 00..c263616612 --- /dev/null +++ b/drivers/net/bnxt/Kconfig @@ -0,0 +1,7 @@ +config BNXT_ETH + bool "BNXT PCI support" + depends on DM_ETH && DM_PCI + help + This driver implements support for bnxt pci controller + driver of ethernet class. + diff --git a/drivers/net/bnxt/Makefile b/drivers/net/bnxt/Makefile new file mode 100644 index 00..a9d6ce00d5 --- /dev/null +++ b/drivers/net/bnxt/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# Copyright 2019-2021 Broadcom. + +# Broadcom nxe Ethernet driver +obj-y += bnxt.o diff --git a/drivers/net/bnxt/bnxt.c b/drivers/net/bnxt/bnxt.c new file mode 100644 index 00..144df587f7 --- /dev/null +++ b/drivers/net/bnxt/bnxt.c @@ -0,0 +1,2025 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019-2021 Broadcom. + */ + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "bnxt_dbg.h" +#include "pci_ids.h" + +#define bnxt_down_chip(bp) bnxt_hwrm_run(down_chip, bp, 0) +#define bnxt_bring_chip(bp)bnxt_hwrm_run(bring_chip, bp, 1) + +static const char banner[] = DRV_MODULE_DESC " v" UBOOT_MODULE_VER ","; +static const char fw_ver[] = " FW v"; + +static int num_cards; /* Number of bnxt devices seen so far */ + +static void display_banner(struct bnxt *bp) +{ + int i; + + printf(banner); + printf(fw_ver); + printf("%d.%d.", bp->fw_maj, bp->fw_min); + printf("%d.%d\n", bp->fw_bld, bp->fw_rsvd); + printf("ETH MAC: "); + for (i = 0; i < ETH_ALEN; i++) { + printf("%02x", bp->mac_set[i]); + if (i != (ETH_ALEN - 1)) + printf(":"); + } + + printf(", Port(%d), PF(%d)\n", bp->port_idx, bp->ordinal_value); +} + +/* Broadcom ethernet driver PCI APIs. */ +static void bnxt_bring_pci(struct bnxt *bp) +{ + u16 cmd_reg = 0; + + pci_read_word16(bp->pdev, PCI_VENDOR_ID, >vendor_id); + pci_read_word16(bp->pdev, PCI_DEVICE_ID, >device_id); + pci_read_word16(bp->pdev, + PCI_SUBSYSTEM_VENDOR_ID, + >subsystem_vendor); + pci_read_word16(bp->pdev, PCI_SUBSYSTEM_ID, >subsystem_device); + pci_read_word16(bp->pdev, PCI_COMMAND, >cmd_reg); + pci_read_byte(bp->pdev, PCICFG_ME_REGISTER, >pf_num); + pci_read_byte(bp->pdev, PCI_INTERRUPT_LINE, >irq); + bp->bar0 = pci_map_bar(bp->pdev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM); + bp->bar1 = pci_map_bar(bp->pdev, PCI_BASE_ADDRESS_2, PCI_REGION_MEM); + bp->bar2 = pci_map_bar(bp->pdev, PCI_BASE_ADDRESS_4, PCI_REGION_MEM); + cmd_reg = bp->cmd_reg | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER; + cmd_reg |= PCI_COMMAND_INTX_DISABLE; /* disable intr */ + pci_write_word(bp->pdev, PCI_COMMAND, cmd_reg); + pci_read_word16(bp->pdev, PCI_COMMAND, _reg); + dbg_pci(bp, __func__, cmd_reg); +} + +int bnxt_free_rx_iob(struct bnxt *bp) +{ + unsigned int i; + + if (!(FLAG_TEST(bp->flag_hwrm, VALID_RX_IOB))) + return