summaryrefslogtreecommitdiffstats
path: root/sys/dev/bce
diff options
context:
space:
mode:
authordavidch <davidch@FreeBSD.org>2007-06-07 02:23:56 +0000
committerdavidch <davidch@FreeBSD.org>2007-06-07 02:23:56 +0000
commitd5a0460612dc52476149f3d7a0389399c714c166 (patch)
tree8d7f72ead3d19dc3be4fd0f56c17cf8aae22ac01 /sys/dev/bce
parent191cff0657264dd90de7f14ece92267ea2a4007d (diff)
downloadFreeBSD-src-d5a0460612dc52476149f3d7a0389399c714c166.zip
FreeBSD-src-d5a0460612dc52476149f3d7a0389399c714c166.tar.gz
New Features:
- Added 2.5G support for BCM5708S. MFC after: 4 weeks
Diffstat (limited to 'sys/dev/bce')
-rw-r--r--sys/dev/bce/if_bce.c778
-rw-r--r--sys/dev/bce/if_bcereg.h44
2 files changed, 412 insertions, 410 deletions
diff --git a/sys/dev/bce/if_bce.c b/sys/dev/bce/if_bce.c
index bfd5563..7158f9b 100644
--- a/sys/dev/bce/if_bce.c
+++ b/sys/dev/bce/if_bce.c
@@ -109,7 +109,7 @@ static struct bce_type bce_devs[] = {
/* BCM5708S controllers and OEM boards. */
{ BRCM_VENDORID, BRCM_DEVICEID_BCM5708S, PCI_ANY_ID, PCI_ANY_ID,
- "Broadcom NetXtreme II BCM5708S 1000Base-T" },
+ "Broadcom NetXtreme II BCM5708 1000Base-SX" },
{ 0, 0, 0, 0, NULL }
};
@@ -359,25 +359,25 @@ MODULE_DEPEND(bce, miibus, 1, 1, 1);
DRIVER_MODULE(bce, pci, bce_driver, bce_devclass, 0, 0);
DRIVER_MODULE(miibus, bce, miibus_driver, miibus_devclass, 0, 0);
-
-
+
+
/****************************************************************************/
/* Tunable device values */
/****************************************************************************/
-static int bce_tso_enable = TRUE;
+static int bce_tso_enable = TRUE;
static int bce_msi_enable = 1;
-
-/* Allowable values are TRUE or FALSE */
-TUNABLE_INT("hw.bce.tso_enable", &bce_tso_enable);
+
+/* Allowable values are TRUE or FALSE */
+TUNABLE_INT("hw.bce.tso_enable", &bce_tso_enable);
/* Allowable values are 0 (IRQ only) and 1 (IRQ or MSI) */
TUNABLE_INT("hw.bce.msi_enable", &bce_msi_enable);
-SYSCTL_NODE(_hw, OID_AUTO, bce, CTLFLAG_RD, 0, "bce driver parameters");
-SYSCTL_UINT(_hw_bce, OID_AUTO, tso_enable, CTLFLAG_RDTUN, &bce_tso_enable, 0,
+SYSCTL_NODE(_hw, OID_AUTO, bce, CTLFLAG_RD, 0, "bce driver parameters");
+SYSCTL_UINT(_hw_bce, OID_AUTO, tso_enable, CTLFLAG_RDTUN, &bce_tso_enable, 0,
"TSO Enable/Disable");
-SYSCTL_UINT(_hw_bce, OID_AUTO, msi_enable, CTLFLAG_RDTUN, &bce_msi_enable, 0,
+SYSCTL_UINT(_hw_bce, OID_AUTO, msi_enable, CTLFLAG_RDTUN, &bce_msi_enable, 0,
"MSI | INTx selector");
-
+
/****************************************************************************/
/* Device probe function. */
/* */
@@ -468,7 +468,7 @@ bce_attach(device_t dev)
DBPRINT(sc, BCE_VERBOSE_RESET, "Entering %s()\n", __FUNCTION__);
mbuf = device_get_unit(dev);
-
+
/* Set initial device and PHY flags */
sc->bce_flags = 0;
sc->bce_phy_flags = 0;
@@ -494,19 +494,19 @@ bce_attach(device_t dev)
sc->bce_bhandle = rman_get_bushandle(sc->bce_res_mem);
sc->bce_vhandle = (vm_offset_t) rman_get_virtual(sc->bce_res_mem);
- /* If MSI is enabled in the driver, get the vector count. */
- count = bce_msi_enable ? pci_msi_count(dev) : 0;
-
+ /* If MSI is enabled in the driver, get the vector count. */
+ count = bce_msi_enable ? pci_msi_count(dev) : 0;
+
/* Allocate PCI IRQ resources. */
if (count == 1 && pci_alloc_msi(dev, &count) == 0 && count == 1) {
rid = 1;
sc->bce_flags |= BCE_USING_MSI_FLAG;
DBPRINT(sc, BCE_INFO, "Allocating %d MSI interrupt(s).\n", count);
} else {
- rid = 0;
+ rid = 0;
DBPRINT(sc, BCE_INFO, "Allocating IRQ interrupt.\n");
}
-
+
sc->bce_res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &rid,
RF_SHAREABLE | RF_ACTIVE);
@@ -632,7 +632,7 @@ bce_attach(device_t dev)
/* Initialize the controller. */
if (bce_chipinit(sc)) {
BCE_PRINTF("%s(%d): Controller initialization failed!\n",
- __FILE__, __LINE__);
+ __FILE__, __LINE__);
rc = ENXIO;
goto bce_attach_fail;
}
@@ -684,25 +684,33 @@ bce_attach(device_t dev)
sc->bce_stats_ticks = 1000000 & 0xffff00;
/*
- * The copper based NetXtreme II controllers
- * use an integrated PHY at address 1 while
- * the SerDes controllers use a PHY at
- * address 2.
+ * The SerDes based NetXtreme II controllers
+ * that support 2.5Gb operation (currently
+ * 5708S) use a PHY at address 2, otherwise
+ * the PHY is present at address 1.
*/
sc->bce_phy_addr = 1;
if (BCE_CHIP_BOND_ID(sc) & BCE_CHIP_BOND_ID_SERDES_BIT) {
sc->bce_phy_flags |= BCE_PHY_SERDES_FLAG;
sc->bce_flags |= BCE_NO_WOL_FLAG;
- if (BCE_CHIP_NUM(sc) == BCE_CHIP_NUM_5708) {
+ if (BCE_CHIP_NUM(sc) != BCE_CHIP_NUM_5706) {
sc->bce_phy_addr = 2;
val = REG_RD_IND(sc, sc->bce_shmem_base +
BCE_SHARED_HW_CFG_CONFIG);
- if (val & BCE_SHARED_HW_CFG_PHY_2_5G)
+ if (val & BCE_SHARED_HW_CFG_PHY_2_5G) {
sc->bce_phy_flags |= BCE_PHY_2_5G_CAPABLE_FLAG;
+ DBPRINT(sc, BCE_WARN, "Found 2.5Gb capable adapter\n");
+ }
}
}
+ /* Store config data needed by the PHY driver for backplane applications */
+ sc->bce_shared_hw_cfg = REG_RD_IND(sc, sc->bce_shmem_base +
+ BCE_SHARED_HW_CFG_CONFIG);
+ sc->bce_port_hw_cfg = REG_RD_IND(sc, sc->bce_shmem_base +
+ BCE_SHARED_HW_CFG_CONFIG);
+
/* Allocate DMA memory resources. */
if (bce_dma_alloc(dev)) {
BCE_PRINTF("%s(%d): DMA resource allocation failed!\n",
@@ -728,14 +736,14 @@ bce_attach(device_t dev)
ifp->if_start = bce_start;
ifp->if_init = bce_init;
ifp->if_mtu = ETHERMTU;
-
- if (bce_tso_enable) {
- ifp->if_hwassist = BCE_IF_HWASSIST | CSUM_TSO;
+
+ if (bce_tso_enable) {
+ ifp->if_hwassist = BCE_IF_HWASSIST | CSUM_TSO;
ifp->if_capabilities = BCE_IF_CAPABILITIES | IFCAP_TSO4;
- } else {
- ifp->if_hwassist = BCE_IF_HWASSIST;
- ifp->if_capabilities = BCE_IF_CAPABILITIES;
- }
+ } else {
+ ifp->if_hwassist = BCE_IF_HWASSIST;
+ ifp->if_capabilities = BCE_IF_CAPABILITIES;
+ }
ifp->if_capenable = ifp->if_capabilities;
@@ -747,9 +755,9 @@ bce_attach(device_t dev)
ifp->if_snd.ifq_drv_maxlen = USABLE_TX_BD;
if (sc->bce_phy_flags & BCE_PHY_2_5G_CAPABLE_FLAG)
- ifp->if_baudrate = IF_Gbps(2.5);
+ ifp->if_baudrate = IF_Mbps(2500ULL);
else
- ifp->if_baudrate = IF_Gbps(1);
+ ifp->if_baudrate = IF_Mbps(1000);
IFQ_SET_MAXLEN(&ifp->if_snd, ifp->if_snd.ifq_drv_maxlen);
IFQ_SET_READY(&ifp->if_snd);
@@ -792,7 +800,7 @@ bce_attach(device_t dev)
/* Get the firmware running so IPMI still works */
BCE_LOCK(sc);
bce_mgmt_init_locked(sc);
- BCE_UNLOCK(sc);
+ BCE_UNLOCK(sc);
goto bce_attach_exit;
@@ -1047,7 +1055,7 @@ bce_miibus_write_reg(device_t dev, int phy, int reg, int val)
/* Make sure we are accessing the correct PHY address. */
if (phy != sc->bce_phy_addr) {
- DBPRINT(sc, BCE_WARN, "Invalid PHY address %d for PHY write!\n", phy);
+ DBPRINT(sc, BCE_VERBOSE, "Invalid PHY address %d for PHY write!\n", phy);
return(0);
}
@@ -1111,71 +1119,61 @@ bce_miibus_statchg(device_t dev)
{
struct bce_softc *sc;
struct mii_data *mii;
+ int val;
sc = device_get_softc(dev);
mii = device_get_softc(sc->bce_miibus);
- DBPRINT(sc, BCE_INFO, "mii_media_active = 0x%08X\n",
- mii->mii_media_active);
-
-#ifdef BCE_DEBUG
- /* Decode the interface media flags. */
- BCE_PRINTF("Media: ( ");
- switch(IFM_TYPE(mii->mii_media_active)) {
- case IFM_ETHER: printf("Ethernet )");
- break;
- default: printf("Unknown )");
- }
-
- printf(" Media Options: ( ");
- switch(IFM_SUBTYPE(mii->mii_media_active)) {
- case IFM_AUTO: printf("Autoselect )"); break;
- case IFM_MANUAL: printf("Manual )"); break;
- case IFM_NONE: printf("None )"); break;
- case IFM_10_T: printf("10Base-T )"); break;
- case IFM_100_TX: printf("100Base-TX )"); break;
- case IFM_1000_SX: printf("1000Base-SX )"); break;
- case IFM_1000_T: printf("1000Base-T )"); break;
- default: printf("Other )");
- }
-
- printf(" Global Options: (");
- if (mii->mii_media_active & IFM_FDX)
- printf(" FullDuplex");
- if (mii->mii_media_active & IFM_HDX)
- printf(" HalfDuplex");
- if (mii->mii_media_active & IFM_LOOP)
- printf(" Loopback");
- if (mii->mii_media_active & IFM_FLAG0)
- printf(" Flag0");
- if (mii->mii_media_active & IFM_FLAG1)
- printf(" Flag1");
- if (mii->mii_media_active & IFM_FLAG2)
- printf(" Flag2");
- printf(" )\n");
-#endif
-
- BCE_CLRBIT(sc, BCE_EMAC_MODE, BCE_EMAC_MODE_PORT);
+ val = REG_RD(sc, BCE_EMAC_MODE);
+ val &= ~(BCE_EMAC_MODE_PORT | BCE_EMAC_MODE_HALF_DUPLEX |
+ BCE_EMAC_MODE_MAC_LOOP | BCE_EMAC_MODE_FORCE_LINK |
+ BCE_EMAC_MODE_25G);
/* Set MII or GMII interface based on the speed negotiated by the PHY. */
- if (IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_T ||
- IFM_SUBTYPE(mii->mii_media_active) == IFM_1000_SX) {
- DBPRINT(sc, BCE_INFO, "Setting GMII interface.\n");
- BCE_SETBIT(sc, BCE_EMAC_MODE, BCE_EMAC_MODE_PORT_GMII);
- } else {
- DBPRINT(sc, BCE_INFO, "Setting MII interface.\n");
- BCE_SETBIT(sc, BCE_EMAC_MODE, BCE_EMAC_MODE_PORT_MII);
+ switch (IFM_SUBTYPE(mii->mii_media_active)) {
+ case IFM_10_T:
+ if (BCE_CHIP_NUM(sc) != BCE_CHIP_NUM_5706) {
+ DBPRINT(sc, BCE_INFO, "Enabling 10Mb interface.\n");
+ val |= BCE_EMAC_MODE_PORT_MII_10;
+ break;
+ }
+ /* fall-through */
+ case IFM_100_TX:
+ DBPRINT(sc, BCE_INFO, "Enabling MII interface.\n");
+ val |= BCE_EMAC_MODE_PORT_MII;
+ break;
+ case IFM_2500_SX:
+ DBPRINT(sc, BCE_INFO, "Enabling 2.5G MAC mode.\n");
+ val |= BCE_EMAC_MODE_25G;
+ /* fall-through */
+ case IFM_1000_T:
+ case IFM_1000_SX:
+ DBPRINT(sc, BCE_INFO, "Enablinb GMII interface.\n");
+ val |= BCE_EMAC_MODE_PORT_GMII;
+ break;
+ default:
+ val |= BCE_EMAC_MODE_PORT_GMII;
}
/* Set half or full duplex based on the duplicity negotiated by the PHY. */
- if ((mii->mii_media_active & IFM_GMASK) == IFM_FDX) {
- DBPRINT(sc, BCE_INFO, "Setting Full-Duplex interface.\n");
- BCE_CLRBIT(sc, BCE_EMAC_MODE, BCE_EMAC_MODE_HALF_DUPLEX);
- } else {
+ if ((mii->mii_media_active & IFM_GMASK) == IFM_HDX) {
DBPRINT(sc, BCE_INFO, "Setting Half-Duplex interface.\n");
- BCE_SETBIT(sc, BCE_EMAC_MODE, BCE_EMAC_MODE_HALF_DUPLEX);
- }
+ val |= BCE_EMAC_MODE_HALF_DUPLEX;
+ } else
+ DBPRINT(sc, BCE_INFO, "Setting Full-Duplex interface.\n");
+
+ REG_WR(sc, BCE_EMAC_MODE, val);
+
+#if 0
+ /* Todo: Enable this support in brgphy and bge. */
+ /* FLAG0 is set if RX is enabled and FLAG1 if TX is enabled */
+ if (mii->mii_media_active & IFM_FLAG0)
+ BCE_SETBIT(sc, BCE_EMAC_RX_MODE, BCE_EMAC_RX_MODE_FLOW_EN);
+ if (mii->mii_media_active & IFM_FLAG1)
+ BCE_SETBIT(sc, BCE_EMAC_RX_MODE, BCE_EMAC_TX_MODE_FLOW_EN);
+#endif
+
}
@@ -2210,9 +2208,9 @@ bce_dma_alloc(device_t dev)
{
struct bce_softc *sc;
int i, error, rc = 0;
- bus_addr_t busaddr;
- bus_size_t max_size, max_seg_size;
- int max_segments;
+ bus_addr_t busaddr;
+ bus_size_t max_size, max_seg_size;
+ int max_segments;
sc = device_get_softc(dev);
@@ -2404,17 +2402,17 @@ bce_dma_alloc(device_t dev)
DBPRINT(sc, BCE_INFO, "tx_bd_chain_paddr[%d] = 0x%08X\n",
i, (u32) sc->tx_bd_chain_paddr[i]);
}
-
- /* Check the required size before mapping to conserve resources. */
- if (bce_tso_enable) {
- max_size = BCE_TSO_MAX_SIZE;
- max_segments = BCE_MAX_SEGMENTS;
- max_seg_size = BCE_TSO_MAX_SEG_SIZE;
- } else {
- max_size = MCLBYTES * BCE_MAX_SEGMENTS;
- max_segments = BCE_MAX_SEGMENTS;
- max_seg_size = MCLBYTES;
- }
+
+ /* Check the required size before mapping to conserve resources. */
+ if (bce_tso_enable) {
+ max_size = BCE_TSO_MAX_SIZE;
+ max_segments = BCE_MAX_SEGMENTS;
+ max_seg_size = BCE_TSO_MAX_SEG_SIZE;
+ } else {
+ max_size = MCLBYTES * BCE_MAX_SEGMENTS;
+ max_segments = BCE_MAX_SEGMENTS;
+ max_seg_size = MCLBYTES;
+ }
/* Create a DMA tag for TX mbufs. */
if (bus_dma_tag_create(sc->parent_tag,
@@ -2425,7 +2423,7 @@ bce_dma_alloc(device_t dev)
NULL, NULL,
max_size,
max_segments,
- max_seg_size,
+ max_seg_size,
0,
NULL, NULL,
&sc->tx_mbuf_tag)) {
@@ -2562,31 +2560,31 @@ bce_release_resources(struct bce_softc *sc)
dev = sc->bce_dev;
bce_dma_free(sc);
-
- if (sc->bce_intrhand != NULL) {
+
+ if (sc->bce_intrhand != NULL) {
DBPRINT(sc, BCE_INFO_RESET, "Removing interrupt handler.\n");
- bus_teardown_intr(dev, sc->bce_res_irq, sc->bce_intrhand);
+ bus_teardown_intr(dev, sc->bce_res_irq, sc->bce_intrhand);
}
- if (sc->bce_res_irq != NULL) {
+ if (sc->bce_res_irq != NULL) {
DBPRINT(sc, BCE_INFO_RESET, "Releasing IRQ.\n");
- bus_release_resource(dev, SYS_RES_IRQ, sc->bce_flags & BCE_USING_MSI_FLAG ? 1 : 0,
+ bus_release_resource(dev, SYS_RES_IRQ, sc->bce_flags & BCE_USING_MSI_FLAG ? 1 : 0,
sc->bce_res_irq);
}
-
- if (sc->bce_flags & BCE_USING_MSI_FLAG) {
+
+ if (sc->bce_flags & BCE_USING_MSI_FLAG) {
DBPRINT(sc, BCE_INFO_RESET, "Releasing MSI vector.\n");
- pci_release_msi(dev);
- }
+ pci_release_msi(dev);
+ }
- if (sc->bce_res_mem != NULL) {
+ if (sc->bce_res_mem != NULL) {
DBPRINT(sc, BCE_INFO_RESET, "Releasing PCI memory.\n");
- bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(0), sc->bce_res_mem);
+ bus_release_resource(dev, SYS_RES_MEMORY, PCIR_BAR(0), sc->bce_res_mem);
}
- if (sc->bce_ifp != NULL) {
+ if (sc->bce_ifp != NULL) {
DBPRINT(sc, BCE_INFO_RESET, "Releasing IF.\n");
- if_free(sc->bce_ifp);
+ if_free(sc->bce_ifp);
}
if (mtx_initialized(&sc->bce_mtx))
@@ -3257,9 +3255,9 @@ bce_chipinit(struct bce_softc *sc)
/* Make sure the interrupt is not active. */
REG_WR(sc, BCE_PCICFG_INT_ACK_CMD, BCE_PCICFG_INT_ACK_CMD_MASK_INT);
- /*
+ /*
* Initialize DMA byte/word swapping, configure the number of DMA
- * channels and PCI clock compensation delay.
+ * channels and PCI clock compensation delay.
*/
val = BCE_DMA_CONFIG_DATA_BYTE_SWAP |
BCE_DMA_CONFIG_DATA_WORD_SWAP |
@@ -3322,7 +3320,7 @@ bce_chipinit(struct bce_softc *sc)
val = 0x10000 + (MAX_CID_CNT * MB_KERNEL_CTX_SIZE);
REG_WR(sc, BCE_MQ_KNL_BYP_WIND_START, val);
REG_WR(sc, BCE_MQ_KNL_WIND_END, val);
-
+
/* Set the page size and clear the RV2P processor stall bits. */
val = (BCM_PAGE_BITS - 8) << 24;
REG_WR(sc, BCE_RV2P_CONFIG, val);
@@ -3553,10 +3551,10 @@ bce_get_buf(struct bce_softc *sc, struct mbuf *m, u16 *prod, u16 *chain_prod,
DBRUNIF((sc->free_rx_bd > USABLE_RX_BD),
BCE_PRINTF("%s(%d): Too many free rx_bd (0x%04X > 0x%04X)!\n",
__FILE__, __LINE__, sc->free_rx_bd, (u16) USABLE_RX_BD));
-
+
/* Update some debug statistic counters */
DBRUNIF((sc->free_rx_bd < sc->rx_low_watermark),
- sc->rx_low_watermark = sc->free_rx_bd);
+ sc->rx_low_watermark = sc->free_rx_bd);
DBRUNIF((sc->free_rx_bd == 0), sc->rx_empty_count++);
/* Setup the rx_bd for the first segment. */
@@ -3621,9 +3619,9 @@ bce_init_tx_chain(struct bce_softc *sc)
sc->tx_prod = 0;
sc->tx_cons = 0;
sc->tx_prod_bseq = 0;
- sc->used_tx_bd = 0;
+ sc->used_tx_bd = 0;
sc->max_tx_bd = USABLE_TX_BD;
- DBRUNIF(1, sc->tx_hi_watermark = USABLE_TX_BD);
+ DBRUNIF(1, sc->tx_hi_watermark = USABLE_TX_BD);
DBRUNIF(1, sc->tx_full_count = 0);
/*
@@ -3733,9 +3731,9 @@ bce_init_rx_chain(struct bce_softc *sc)
sc->rx_prod = 0;
sc->rx_cons = 0;
sc->rx_prod_bseq = 0;
- sc->free_rx_bd = USABLE_RX_BD;
- sc->max_rx_bd = USABLE_RX_BD;
- DBRUNIF(1, sc->rx_low_watermark = USABLE_RX_BD);
+ sc->free_rx_bd = USABLE_RX_BD;
+ sc->max_rx_bd = USABLE_RX_BD;
+ DBRUNIF(1, sc->rx_low_watermark = USABLE_RX_BD);
DBRUNIF(1, sc->rx_empty_count = 0);
/* Initialize the RX next pointer chain entries. */
@@ -3792,7 +3790,7 @@ bce_init_rx_chain(struct bce_softc *sc)
}
/* Tell the chip about the waiting rx_bd's. */
- REG_WR16(sc, MB_RX_CID_ADDR + BCE_L2CTX_HOST_BDIDX, sc->rx_prod);
+ REG_WR16(sc, MB_RX_CID_ADDR + BCE_L2CTX_HOST_BDIDX, sc->rx_prod);
REG_WR(sc, MB_RX_CID_ADDR + BCE_L2CTX_HOST_BSEQ, sc->rx_prod_bseq);
DBRUN(BCE_VERBOSE_RECV, bce_dump_rx_chain(sc, 0, TOTAL_RX_BD));
@@ -3858,7 +3856,7 @@ bce_ifmedia_upd(struct ifnet *ifp)
BCE_UNLOCK(sc);
return (0);
}
-
+
/****************************************************************************/
/* Set media options. */
@@ -3872,15 +3870,15 @@ bce_ifmedia_upd_locked(struct ifnet *ifp)
struct bce_softc *sc;
struct mii_data *mii;
struct ifmedia *ifm;
-
+
sc = ifp->if_softc;
ifm = &sc->bce_ifmedia;
BCE_LOCK_ASSERT(sc);
mii = device_get_softc(sc->bce_miibus);
-
- /* Make sure the MII bus has been enumerated. */
- if (mii) {
+
+ /* Make sure the MII bus has been enumerated. */
+ if (mii) {
sc->bce_link = 0;
if (mii->mii_instance) {
struct mii_softc *miisc;
@@ -3888,7 +3886,7 @@ bce_ifmedia_upd_locked(struct ifnet *ifp)
LIST_FOREACH(miisc, &mii->mii_phys, mii_list)
mii_phy_reset(miisc);
}
- mii_mediachg(mii);
+ mii_mediachg(mii);
}
}
@@ -4004,9 +4002,9 @@ bce_rx_intr(struct bce_softc *sc)
bus_space_barrier(sc->bce_btag, sc->bce_bhandle, 0, 0,
BUS_SPACE_BARRIER_READ);
- /* Update some debug statistics counters */
+ /* Update some debug statistics counters */
DBRUNIF((sc->free_rx_bd < sc->rx_low_watermark),
- sc->rx_low_watermark = sc->free_rx_bd);
+ sc->rx_low_watermark = sc->free_rx_bd);
DBRUNIF((sc->free_rx_bd == 0), sc->rx_empty_count++);
/* Scan through the receive chain as long as there is work to do */
@@ -4016,9 +4014,9 @@ bce_rx_intr(struct bce_softc *sc)
unsigned int len;
u32 status;
- /* Clear the mbuf pointer. */
- m = NULL;
-
+ /* Clear the mbuf pointer. */
+ m = NULL;
+
/* Convert the producer/consumer indices to an actual rx_bd index. */
sw_chain_cons = RX_CHAIN_IDX(sw_cons);
sw_chain_prod = RX_CHAIN_IDX(sw_prod);
@@ -4048,11 +4046,11 @@ bce_rx_intr(struct bce_softc *sc)
__FILE__, __LINE__, sw_chain_cons);
bce_breakpoint(sc));
- /*
- * ToDo: If the received packet is small enough
+ /*
+ * ToDo: If the received packet is small enough
* to fit into a single, non-M_EXT mbuf,
- * allocate a new mbuf here, copy the data to
- * that mbuf, and recycle the mapped jumbo frame.
+ * allocate a new mbuf here, copy the data to
+ * that mbuf, and recycle the mapped jumbo frame.
*/
/* Unmap the mbuf from DMA space. */
@@ -4212,30 +4210,30 @@ bce_rx_int_next_rx:
}
sw_cons = NEXT_RX_BD(sw_cons);
-
- /* If we have a packet, pass it up the stack */
- if (m) {
- /* Make sure we don't lose our place when we release the lock. */
- sc->rx_cons = sw_cons;
- sc->rx_prod = sw_prod;
- sc->rx_prod_bseq = sw_prod_bseq;
+
+ /* If we have a packet, pass it up the stack */
+ if (m) {
+ /* Make sure we don't lose our place when we release the lock. */
+ sc->rx_cons = sw_cons;
+ sc->rx_prod = sw_prod;
+ sc->rx_prod_bseq = sw_prod_bseq;
DBPRINT(sc, BCE_VERBOSE_RECV, "%s(): Passing received frame up.\n",
__FUNCTION__);
BCE_UNLOCK(sc);
(*ifp->if_input)(ifp, m);
DBRUNIF(1, sc->rx_mbuf_alloc--);
- BCE_LOCK(sc);
-
- /* Recover our place. */
- sw_cons = sc->rx_cons;
- sw_prod = sc->rx_prod;
- sw_prod_bseq = sc->rx_prod_bseq;
- hw_cons = sc->hw_rx_cons = sblk->status_rx_quick_consumer_index0;
- if ((hw_cons & USABLE_RX_BD_PER_PAGE) == USABLE_RX_BD_PER_PAGE)
- hw_cons++;
- }
-
+ BCE_LOCK(sc);
+
+ /* Recover our place. */
+ sw_cons = sc->rx_cons;
+ sw_prod = sc->rx_prod;
+ sw_prod_bseq = sc->rx_prod_bseq;
+ hw_cons = sc->hw_rx_cons = sblk->status_rx_quick_consumer_index0;
+ if ((hw_cons & USABLE_RX_BD_PER_PAGE) == USABLE_RX_BD_PER_PAGE)
+ hw_cons++;
+ }
+
/* Refresh hw_cons to see if there's new work */
if (sw_cons == hw_cons) {
hw_cons = sc->hw_rx_cons = sblk->status_rx_quick_consumer_index0;
@@ -4372,7 +4370,7 @@ bce_tx_intr(struct bce_softc *sc)
/* Clear the tx hardware queue full flag. */
if (sc->used_tx_bd < sc->max_tx_bd) {
DBRUNIF((ifp->if_drv_flags & IFF_DRV_OACTIVE),
- DBPRINT(sc, BCE_WARN_SEND,
+ DBPRINT(sc, BCE_WARN_SEND,
"%s(): Open TX chain! %d/%d (used/total)\n",
__FUNCTION__, sc->used_tx_bd, sc->max_tx_bd));
ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
@@ -4530,9 +4528,9 @@ bce_init_locked_exit:
return;
}
-
+
/****************************************************************************/
-/* Initialize the controller just enough so that any management firmware */
+/* Initialize the controller just enough so that any management firmware */
/* running on the device will continue to operate corectly. */
/* */
/* Returns: */
@@ -4612,9 +4610,9 @@ bce_tx_encap(struct bce_softc *sc, struct mbuf **m_head)
struct ip *ip;
struct tcphdr *th;
u16 prod, chain_prod, etype, mss = 0, vlan_tag = 0, flags = 0;
- u32 prod_bseq;
- int hdr_len = 0, e_hlen = 0, ip_hlen = 0, tcp_hlen = 0, ip_len = 0;
-
+ u32 prod_bseq;
+ int hdr_len = 0, e_hlen = 0, ip_hlen = 0, tcp_hlen = 0, ip_len = 0;
+
#ifdef BCE_DEBUG
u16 debug_prod;
@@ -4627,12 +4625,12 @@ bce_tx_encap(struct bce_softc *sc, struct mbuf **m_head)
if (m0->m_pkthdr.csum_flags & CSUM_IP)
flags |= TX_BD_FLAGS_IP_CKSUM;
if (m0->m_pkthdr.csum_flags & (CSUM_TCP | CSUM_UDP))
- flags |= TX_BD_FLAGS_TCP_UDP_CKSUM;
- if (m0->m_pkthdr.csum_flags & CSUM_TSO) {
- /* For TSO the controller needs two pieces of info, */
- /* the MSS and the IP+TCP options length. */
- mss = htole16(m0->m_pkthdr.tso_segsz);
-
+ flags |= TX_BD_FLAGS_TCP_UDP_CKSUM;
+ if (m0->m_pkthdr.csum_flags & CSUM_TSO) {
+ /* For TSO the controller needs two pieces of info, */
+ /* the MSS and the IP+TCP options length. */
+ mss = htole16(m0->m_pkthdr.tso_segsz);
+
/* Map the header and find the Ethernet type & header length */
eh = mtod(m0, struct ether_vlan_header *);
if (eh->evl_encap_proto == htons(ETHERTYPE_VLAN)) {
@@ -4641,55 +4639,55 @@ bce_tx_encap(struct bce_softc *sc, struct mbuf **m_head)
} else {
etype = ntohs(eh->evl_encap_proto);
e_hlen = ETHER_HDR_LEN;
- }
-
- /* Check for supported TSO Ethernet types (only IPv4 for now) */
+ }
+
+ /* Check for supported TSO Ethernet types (only IPv4 for now) */
switch (etype) {
case ETHERTYPE_IP:
ip = (struct ip *)(m0->m_data + e_hlen);
-
- /* TSO only supported for TCP protocol */
+
+ /* TSO only supported for TCP protocol */
if (ip->ip_p != IPPROTO_TCP) {
BCE_PRINTF("%s(%d): TSO enabled for non-TCP frame!.\n",
- __FILE__, __LINE__);
- goto bce_tx_encap_skip_tso;
+ __FILE__, __LINE__);
+ goto bce_tx_encap_skip_tso;
}
-
- /* Get IP header length in bytes (min 20) */
- ip_hlen = ip->ip_hl << 2;
-
- /* Get the TCP header length in bytes (min 20) */
+
+ /* Get IP header length in bytes (min 20) */
+ ip_hlen = ip->ip_hl << 2;
+
+ /* Get the TCP header length in bytes (min 20) */
th = (struct tcphdr *)((caddr_t)ip + ip_hlen);
- tcp_hlen = (th->th_off << 2);
-
- /* IP header length and checksum will be calc'd by hardware */
- ip_len = ip->ip_len;
- ip->ip_len = 0;
+ tcp_hlen = (th->th_off << 2);
+
+ /* IP header length and checksum will be calc'd by hardware */
+ ip_len = ip->ip_len;
+ ip->ip_len = 0;
ip->ip_sum = 0;
break;
case ETHERTYPE_IPV6:
BCE_PRINTF("%s(%d): TSO over IPv6 not supported!.\n",
- __FILE__, __LINE__);
- goto bce_tx_encap_skip_tso;
+ __FILE__, __LINE__);
+ goto bce_tx_encap_skip_tso;
default:
BCE_PRINTF("%s(%d): TSO enabled for unsupported protocol!.\n",
- __FILE__, __LINE__);
- goto bce_tx_encap_skip_tso;
+ __FILE__, __LINE__);
+ goto bce_tx_encap_skip_tso;
}
-
+
hdr_len = e_hlen + ip_hlen + tcp_hlen;
- DBPRINT(sc, BCE_EXCESSIVE_SEND,
- "%s(): hdr_len = %d, e_hlen = %d, ip_hlen = %d, tcp_hlen = %d, ip_len = %d\n",
- __FUNCTION__, hdr_len, e_hlen, ip_hlen, tcp_hlen, ip_len);
-
- /* Set the LSO flag in the TX BD */
- flags |= TX_BD_FLAGS_SW_LSO;
- /* Set the length of IP + TCP options (in 32 bit words) */
- flags |= (((ip_hlen + tcp_hlen - 40) >> 2) << 8);
-
-bce_tx_encap_skip_tso:
- DBRUNIF(1, sc->requested_tso_frames++);
+ DBPRINT(sc, BCE_EXCESSIVE_SEND,
+ "%s(): hdr_len = %d, e_hlen = %d, ip_hlen = %d, tcp_hlen = %d, ip_len = %d\n",
+ __FUNCTION__, hdr_len, e_hlen, ip_hlen, tcp_hlen, ip_len);
+
+ /* Set the LSO flag in the TX BD */
+ flags |= TX_BD_FLAGS_SW_LSO;
+ /* Set the length of IP + TCP options (in 32 bit words) */
+ flags |= (((ip_hlen + tcp_hlen - 40) >> 2) << 8);
+
+bce_tx_encap_skip_tso:
+ DBRUNIF(1, sc->requested_tso_frames++);
}
}
@@ -4708,23 +4706,23 @@ bce_tx_encap_skip_tso:
error = bus_dmamap_load_mbuf_sg(sc->tx_mbuf_tag, map, m0,
segs, &nsegs, BUS_DMA_NOWAIT);
- /* Check if the DMA mapping was successful */
+ /* Check if the DMA mapping was successful */
if (error == EFBIG) {
DBPRINT(sc, BCE_WARN, "%s(): fragmented mbuf (%d pieces)\n",
__FUNCTION__, nsegs);
DBRUNIF(1, bce_dump_mbuf(sc, m0););
-
+
/* Try to defrag the mbuf if there are too many segments. */
m0 = m_defrag(*m_head, M_DONTWAIT);
- if (m0 == NULL) {
+ if (m0 == NULL) {
/* Defrag was unsuccessful */
m_freem(*m_head);
*m_head = NULL;
return (ENOBUFS);
}
- /* Defrag was successful, try mapping again */
+ /* Defrag was successful, try mapping again */
*m_head = m0;
error = bus_dmamap_load_mbuf_sg(sc->tx_mbuf_tag, map, m0,
segs, &nsegs, BUS_DMA_NOWAIT);
@@ -4747,7 +4745,7 @@ bce_tx_encap_skip_tso:
*m_head = NULL;
return (error);
}
-
+
/* Make sure there's room in the chain */
if (nsegs > (sc->max_tx_bd - sc->used_tx_bd)) {
bus_dmamap_unload(sc->tx_mbuf_tag, map);
@@ -4784,7 +4782,7 @@ bce_tx_encap_skip_tso:
txbd->tx_bd_flags = htole16(flags);
prod_bseq += segs[i].ds_len;
if (i == 0)
- txbd->tx_bd_flags |= htole16(TX_BD_FLAGS_START);
+ txbd->tx_bd_flags |= htole16(TX_BD_FLAGS_START);
prod = NEXT_TX_BD(prod);
}
@@ -4810,9 +4808,9 @@ bce_tx_encap_skip_tso:
sc->tx_mbuf_ptr[chain_prod] = m0;
sc->used_tx_bd += nsegs;
- /* Update some debug statistic counters */
+ /* Update some debug statistic counters */
DBRUNIF((sc->used_tx_bd > sc->tx_hi_watermark),
- sc->tx_hi_watermark = sc->used_tx_bd);
+ sc->tx_hi_watermark = sc->used_tx_bd);
DBRUNIF((sc->used_tx_bd == sc->max_tx_bd), sc->tx_full_count++);
DBRUNIF(1, sc->tx_mbuf_alloc++);
@@ -5666,14 +5664,14 @@ bce_stats_update(struct bce_softc *sc)
sc->stat_CatchupInRuleCheckerP4Hit =
stats->stat_CatchupInRuleCheckerP4Hit;
- sc->com_no_buffers = REG_RD_IND(sc, 0x120084);
-
+ sc->com_no_buffers = REG_RD_IND(sc, 0x120084);
+
DBPRINT(sc, BCE_EXCESSIVE, "Exiting %s()\n", __FUNCTION__);
}
/****************************************************************************/
-/* Periodic function to perform maintenance tasks. */
+/* Periodic function to perform maintenance tasks. */
/* */
/* Returns: */
/* Nothing. */
@@ -5850,8 +5848,8 @@ bce_sysctl_dump_tx_chain(SYSCTL_HANDLER_ARGS)
/****************************************************************************/
-/* Provides a sysctl interface to allow reading arbitrary registers in the */
-/* device. DO NOT ENABLE ON PRODUCTION SYSTEMS! */
+/* Provides a sysctl interface to allow reading arbitrary registers in the */
+/* device. DO NOT ENABLE ON PRODUCTION SYSTEMS! */
/* */
/* Returns: */
/* 0 for success, positive value for failure. */
@@ -5868,7 +5866,7 @@ bce_sysctl_reg_read(SYSCTL_HANDLER_ARGS)
if (error || (req->newptr == NULL))
return (error);
- /* Make sure the register is accessible. */
+ /* Make sure the register is accessible. */
if (result < 0x8000) {
sc = (struct bce_softc *)arg1;
val = REG_RD(sc, result);
@@ -5876,16 +5874,16 @@ bce_sysctl_reg_read(SYSCTL_HANDLER_ARGS)
} else if (result < 0x0280000) {
sc = (struct bce_softc *)arg1;
val = REG_RD_IND(sc, result);
- BCE_PRINTF("reg 0x%08X = 0x%08X\n", result, val);
+ BCE_PRINTF("reg 0x%08X = 0x%08X\n", result, val);
}
return (error);
}
-
-
+
+
/****************************************************************************/
-/* Provides a sysctl interface to allow reading arbitrary PHY registers in */
-/* the device. DO NOT ENABLE ON PRODUCTION SYSTEMS! */
+/* Provides a sysctl interface to allow reading arbitrary PHY registers in */
+/* the device. DO NOT ENABLE ON PRODUCTION SYSTEMS! */
/* */
/* Returns: */
/* 0 for success, positive value for failure. */
@@ -5893,7 +5891,7 @@ bce_sysctl_reg_read(SYSCTL_HANDLER_ARGS)
static int
bce_sysctl_phy_read(SYSCTL_HANDLER_ARGS)
{
- struct bce_softc *sc;
+ struct bce_softc *sc;
device_t dev;
int error, result;
u16 val;
@@ -5903,19 +5901,19 @@ bce_sysctl_phy_read(SYSCTL_HANDLER_ARGS)
if (error || (req->newptr == NULL))
return (error);
- /* Make sure the register is accessible. */
+ /* Make sure the register is accessible. */
if (result < 0x20) {
- sc = (struct bce_softc *)arg1;
+ sc = (struct bce_softc *)arg1;
dev = sc->bce_dev;
val = bce_miibus_read_reg(dev, sc->bce_phy_addr, result);
BCE_PRINTF("phy 0x%02X = 0x%04X\n", result, val);
}
return (error);
}
-
-
+
+
/****************************************************************************/
-/* Provides a sysctl interface to forcing the driver to dump state and */
+/* Provides a sysctl interface to forcing the driver to dump state and */
/* enter the debugger. DO NOT ENABLE ON PRODUCTION SYSTEMS! */
/* */
/* Returns: */
@@ -5998,12 +5996,12 @@ bce_add_sysctls(struct bce_softc *sc)
SYSCTL_ADD_INT(ctx, children, OID_AUTO,
"mbuf_alloc_failed",
CTLFLAG_RD, &sc->mbuf_alloc_failed,
- 0, "mbuf cluster allocation failures");
-
+ 0, "mbuf cluster allocation failures");
+
SYSCTL_ADD_INT(ctx, children, OID_AUTO,
"requested_tso_frames",
CTLFLAG_RD, &sc->requested_tso_frames,
- 0, "The number of TSO frames received");
+ 0, "The number of TSO frames received");
#endif
SYSCTL_ADD_ULONG(ctx, children, OID_AUTO,
@@ -6306,15 +6304,15 @@ bce_add_sysctls(struct bce_softc *sc)
"breakpoint", CTLTYPE_INT | CTLFLAG_RW,
(void *)sc, 0,
bce_sysctl_breakpoint, "I", "Driver breakpoint");
-
- SYSCTL_ADD_PROC(ctx, children, OID_AUTO,
- "reg_read", CTLTYPE_INT | CTLFLAG_RW,
- (void *)sc, 0,
+
+ SYSCTL_ADD_PROC(ctx, children, OID_AUTO,
+ "reg_read", CTLTYPE_INT | CTLFLAG_RW,
+ (void *)sc, 0,
bce_sysctl_reg_read, "I", "Register read");
- SYSCTL_ADD_PROC(ctx, children, OID_AUTO,
- "phy_read", CTLTYPE_INT | CTLFLAG_RW,
- (void *)sc, 0,
+ SYSCTL_ADD_PROC(ctx, children, OID_AUTO,
+ "phy_read", CTLTYPE_INT | CTLFLAG_RW,
+ (void *)sc, 0,
bce_sysctl_phy_read, "I", "PHY register read");
#endif
@@ -6326,7 +6324,7 @@ bce_add_sysctls(struct bce_softc *sc)
/* BCE Debug Routines */
/****************************************************************************/
#ifdef BCE_DEBUG
-
+
/****************************************************************************/
/* Freezes the controller to allow for a cohesive state dump. */
/* */
@@ -6337,15 +6335,15 @@ static void
bce_freeze_controller(struct bce_softc *sc)
{
u32 val;
- val = REG_RD(sc, BCE_MISC_COMMAND);
- val |= BCE_MISC_COMMAND_DISABLE_ALL;
+ val = REG_RD(sc, BCE_MISC_COMMAND);
+ val |= BCE_MISC_COMMAND_DISABLE_ALL;
REG_WR(sc, BCE_MISC_COMMAND, val);
-
-}
-
+
+}
+
/****************************************************************************/
-/* Unfreezes the controller after a freeze operation. This may not always */
+/* Unfreezes the controller after a freeze operation. This may not always */
/* work and the controller will require a reset! */
/* */
/* Returns: */
@@ -6355,12 +6353,12 @@ static void
bce_unfreeze_controller(struct bce_softc *sc)
{
u32 val;
- val = REG_RD(sc, BCE_MISC_COMMAND);
- val |= BCE_MISC_COMMAND_ENABLE_ALL;
+ val = REG_RD(sc, BCE_MISC_COMMAND);
+ val |= BCE_MISC_COMMAND_ENABLE_ALL;
REG_WR(sc, BCE_MISC_COMMAND, val);
-
-}
-
+
+}
+
/****************************************************************************/
/* Prints out information about an mbuf. */
/* */
@@ -6398,8 +6396,8 @@ bce_dump_mbuf(struct bce_softc *sc, struct mbuf *m)
printf(") m_data = 0x%08X:%08X\n",
val_hi, val_lo);
- if (mp->m_flags & M_PKTHDR) {
- BCE_PRINTF("- m_pkthdr: flags = ( ");
+ if (mp->m_flags & M_PKTHDR) {
+ BCE_PRINTF("- m_pkthdr: flags = ( ");
if (mp->m_flags & M_BCAST)
printf("M_BCAST ");
if (mp->m_flags & M_MCAST)
@@ -6414,7 +6412,7 @@ bce_dump_mbuf(struct bce_softc *sc, struct mbuf *m)
printf("M_VLANTAG ");
if (mp->m_flags & M_PROMISC)
printf("M_PROMISC ");
- printf(") csum_flags = ( ");
+ printf(") csum_flags = ( ");
if (mp->m_pkthdr.csum_flags & CSUM_IP)
printf("CSUM_IP ");
if (mp->m_pkthdr.csum_flags & CSUM_TCP)
@@ -6434,26 +6432,26 @@ bce_dump_mbuf(struct bce_softc *sc, struct mbuf *m)
if (mp->m_pkthdr.csum_flags & CSUM_DATA_VALID)
printf("CSUM_DATA_VALID ");
printf(")\n");
- }
+ }
if (mp->m_flags & M_EXT) {
val_hi = BCE_ADDR_HI(mp->m_ext.ext_buf);
val_lo = BCE_ADDR_LO(mp->m_ext.ext_buf);
BCE_PRINTF("- m_ext: vaddr = 0x%08X:%08X, ext_size = %d, type = ",
val_hi, val_lo, mp->m_ext.ext_size);
- switch (mp->m_ext.ext_type) {
- case EXT_CLUSTER: printf("EXT_CLUSTER\n"); break;
- case EXT_SFBUF: printf("EXT_SFBUF\n"); break;
- case EXT_JUMBO9: printf("EXT_JUMBO9\n"); break;
- case EXT_JUMBO16: printf("EXT_JUMBO16\n"); break;
- case EXT_PACKET: printf("EXT_PACKET\n"); break;
- case EXT_MBUF: printf("EXT_MBUF\n"); break;
- case EXT_NET_DRV: printf("EXT_NET_DRV\n"); break;
- case EXT_MOD_TYPE: printf("EXT_MDD_TYPE\n"); break;
- case EXT_DISPOSABLE: printf("EXT_DISPOSABLE\n"); break;
- case EXT_EXTREF: printf("EXT_EXTREF\n"); break;
- default: printf("UNKNOWN\n");
- }
+ switch (mp->m_ext.ext_type) {
+ case EXT_CLUSTER: printf("EXT_CLUSTER\n"); break;
+ case EXT_SFBUF: printf("EXT_SFBUF\n"); break;
+ case EXT_JUMBO9: printf("EXT_JUMBO9\n"); break;
+ case EXT_JUMBO16: printf("EXT_JUMBO16\n"); break;
+ case EXT_PACKET: printf("EXT_PACKET\n"); break;
+ case EXT_MBUF: printf("EXT_MBUF\n"); break;
+ case EXT_NET_DRV: printf("EXT_NET_DRV\n"); break;
+ case EXT_MOD_TYPE: printf("EXT_MDD_TYPE\n"); break;
+ case EXT_DISPOSABLE: printf("EXT_DISPOSABLE\n"); break;
+ case EXT_EXTREF: printf("EXT_EXTREF\n"); break;
+ default: printf("UNKNOWN\n");
+ }
}
mp = mp->m_next;
@@ -6545,46 +6543,46 @@ bce_dump_txbd(struct bce_softc *sc, int idx, struct tx_bd *txbd)
txbd->tx_bd_haddr_hi, txbd->tx_bd_haddr_lo,
txbd->tx_bd_mss_nbytes, txbd->tx_bd_vlan_tag,
txbd->tx_bd_flags);
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_CONN_FAULT)
- printf(" CONN_FAULT");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_TCP_UDP_CKSUM)
- printf(" TCP_UDP_CKSUM");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_IP_CKSUM)
- printf(" IP_CKSUM");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_VLAN_TAG)
- printf(" VLAN");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_COAL_NOW)
- printf(" COAL_NOW");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_DONT_GEN_CRC)
- printf(" DONT_GEN_CRC");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_START)
- printf(" START");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_END)
- printf(" END");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_SW_LSO)
- printf(" LSO");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_SW_OPTION_WORD)
- printf(" OPTION_WORD");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_SW_FLAGS)
- printf(" FLAGS");
-
- if (txbd->tx_bd_flags & TX_BD_FLAGS_SW_SNAP)
- printf(" SNAP");
-
- printf(" )\n");
- }
-
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_CONN_FAULT)
+ printf(" CONN_FAULT");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_TCP_UDP_CKSUM)
+ printf(" TCP_UDP_CKSUM");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_IP_CKSUM)
+ printf(" IP_CKSUM");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_VLAN_TAG)
+ printf(" VLAN");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_COAL_NOW)
+ printf(" COAL_NOW");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_DONT_GEN_CRC)
+ printf(" DONT_GEN_CRC");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_START)
+ printf(" START");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_END)
+ printf(" END");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_SW_LSO)
+ printf(" LSO");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_SW_OPTION_WORD)
+ printf(" OPTION_WORD");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_SW_FLAGS)
+ printf(" FLAGS");
+
+ if (txbd->tx_bd_flags & TX_BD_FLAGS_SW_SNAP)
+ printf(" SNAP");
+
+ printf(" )\n");
+ }
+
}
@@ -6622,7 +6620,7 @@ bce_dump_rxbd(struct bce_softc *sc, int idx, struct rx_bd *rxbd)
static void
bce_dump_l2fhdr(struct bce_softc *sc, int idx, struct l2_fhdr *l2fhdr)
{
-
+
BCE_PRINTF("l2_fhdr[0x%04X]: status = 0x%08X, "
"pkt_len = 0x%04X, vlan = 0x%04x, ip_xsum = 0x%04X, "
"tcp_udp_xsum = 0x%04X\n", idx,
@@ -6737,7 +6735,7 @@ bce_dump_status_block(struct bce_softc *sc)
"----------------------------"
" Status Block "
"----------------------------\n");
-
+
BCE_PRINTF(" 0x%08X - attn_bits\n",
sblk->status_attn_bits);
@@ -6745,11 +6743,11 @@ bce_dump_status_block(struct bce_softc *sc)
sblk->status_attn_bits_ack);
BCE_PRINTF("0x%04X(0x%04X) - rx_cons0\n",
- sblk->status_rx_quick_consumer_index0,
+ sblk->status_rx_quick_consumer_index0,
(u16) RX_CHAIN_IDX(sblk->status_rx_quick_consumer_index0));
-
+
BCE_PRINTF("0x%04X(0x%04X) - tx_cons0\n",
- sblk->status_tx_quick_consumer_index0,
+ sblk->status_tx_quick_consumer_index0,
(u16) TX_CHAIN_IDX(sblk->status_tx_quick_consumer_index0));
BCE_PRINTF(" 0x%04X - status_idx\n", sblk->status_idx);
@@ -6759,7 +6757,7 @@ bce_dump_status_block(struct bce_softc *sc)
BCE_PRINTF("0x%04X(0x%04X) - rx_cons1\n",
sblk->status_rx_quick_consumer_index1,
(u16) RX_CHAIN_IDX(sblk->status_rx_quick_consumer_index1));
-
+
if (sblk->status_tx_quick_consumer_index1)
BCE_PRINTF("0x%04X(0x%04X) - tx_cons1\n",
sblk->status_tx_quick_consumer_index1,
@@ -6769,22 +6767,22 @@ bce_dump_status_block(struct bce_softc *sc)
BCE_PRINTF("0x%04X(0x%04X)- rx_cons2\n",
sblk->status_rx_quick_consumer_index2,
(u16) RX_CHAIN_IDX(sblk->status_rx_quick_consumer_index2));
-
+
if (sblk->status_tx_quick_consumer_index2)
BCE_PRINTF("0x%04X(0x%04X) - tx_cons2\n",
sblk->status_tx_quick_consumer_index2,
(u16) TX_CHAIN_IDX(sblk->status_tx_quick_consumer_index2));
-
+
if (sblk->status_rx_quick_consumer_index3)
BCE_PRINTF("0x%04X(0x%04X) - rx_cons3\n",
sblk->status_rx_quick_consumer_index3,
(u16) RX_CHAIN_IDX(sblk->status_rx_quick_consumer_index3));
-
+
if (sblk->status_tx_quick_consumer_index3)
BCE_PRINTF("0x%04X(0x%04X) - tx_cons3\n",
sblk->status_tx_quick_consumer_index3,
(u16) TX_CHAIN_IDX(sblk->status_tx_quick_consumer_index3));
-
+
if (sblk->status_rx_quick_consumer_index4 ||
sblk->status_rx_quick_consumer_index5)
BCE_PRINTF("rx_cons4 = 0x%08X, rx_cons5 = 0x%08X\n",
@@ -6826,7 +6824,7 @@ bce_dump_status_block(struct bce_softc *sc)
BCE_PRINTF("com_prod = 0x%08X, cmd_cons = 0x%08X\n",
sblk->status_completion_producer_index,
sblk->status_cmd_consumer_index);
-
+
BCE_PRINTF(
"----------------------------"
"----------------"
@@ -6846,82 +6844,82 @@ bce_dump_stats_block(struct bce_softc *sc)
struct statistics_block *sblk;
sblk = sc->stats_block;
-
+
BCE_PRINTF(
"---------------"
" Stats Block (All Stats Not Shown Are 0) "
"---------------\n");
- if (sblk->stat_IfHCInOctets_hi
+ if (sblk->stat_IfHCInOctets_hi
|| sblk->stat_IfHCInOctets_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcInOctets\n",
- sblk->stat_IfHCInOctets_hi,
- sblk->stat_IfHCInOctets_lo);
-
- if (sblk->stat_IfHCInBadOctets_hi
+ sblk->stat_IfHCInOctets_hi,
+ sblk->stat_IfHCInOctets_lo);
+
+ if (sblk->stat_IfHCInBadOctets_hi
|| sblk->stat_IfHCInBadOctets_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcInBadOctets\n",
- sblk->stat_IfHCInBadOctets_hi,
- sblk->stat_IfHCInBadOctets_lo);
-
- if (sblk->stat_IfHCOutOctets_hi
+ sblk->stat_IfHCInBadOctets_hi,
+ sblk->stat_IfHCInBadOctets_lo);
+
+ if (sblk->stat_IfHCOutOctets_hi
|| sblk->stat_IfHCOutOctets_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcOutOctets\n",
- sblk->stat_IfHCOutOctets_hi,
- sblk->stat_IfHCOutOctets_lo);
-
- if (sblk->stat_IfHCOutBadOctets_hi
+ sblk->stat_IfHCOutOctets_hi,
+ sblk->stat_IfHCOutOctets_lo);
+
+ if (sblk->stat_IfHCOutBadOctets_hi
|| sblk->stat_IfHCOutBadOctets_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcOutBadOctets\n",
- sblk->stat_IfHCOutBadOctets_hi,
- sblk->stat_IfHCOutBadOctets_lo);
-
- if (sblk->stat_IfHCInUcastPkts_hi
+ sblk->stat_IfHCOutBadOctets_hi,
+ sblk->stat_IfHCOutBadOctets_lo);
+
+ if (sblk->stat_IfHCInUcastPkts_hi
|| sblk->stat_IfHCInUcastPkts_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcInUcastPkts\n",
- sblk->stat_IfHCInUcastPkts_hi,
- sblk->stat_IfHCInUcastPkts_lo);
-
- if (sblk->stat_IfHCInBroadcastPkts_hi
+ sblk->stat_IfHCInUcastPkts_hi,
+ sblk->stat_IfHCInUcastPkts_lo);
+
+ if (sblk->stat_IfHCInBroadcastPkts_hi
|| sblk->stat_IfHCInBroadcastPkts_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcInBroadcastPkts\n",
- sblk->stat_IfHCInBroadcastPkts_hi,
- sblk->stat_IfHCInBroadcastPkts_lo);
-
- if (sblk->stat_IfHCInMulticastPkts_hi
+ sblk->stat_IfHCInBroadcastPkts_hi,
+ sblk->stat_IfHCInBroadcastPkts_lo);
+
+ if (sblk->stat_IfHCInMulticastPkts_hi
|| sblk->stat_IfHCInMulticastPkts_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcInMulticastPkts\n",
- sblk->stat_IfHCInMulticastPkts_hi,
- sblk->stat_IfHCInMulticastPkts_lo);
-
- if (sblk->stat_IfHCOutUcastPkts_hi
+ sblk->stat_IfHCInMulticastPkts_hi,
+ sblk->stat_IfHCInMulticastPkts_lo);
+
+ if (sblk->stat_IfHCOutUcastPkts_hi
|| sblk->stat_IfHCOutUcastPkts_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcOutUcastPkts\n",
- sblk->stat_IfHCOutUcastPkts_hi,
- sblk->stat_IfHCOutUcastPkts_lo);
-
- if (sblk->stat_IfHCOutBroadcastPkts_hi
+ sblk->stat_IfHCOutUcastPkts_hi,
+ sblk->stat_IfHCOutUcastPkts_lo);
+
+ if (sblk->stat_IfHCOutBroadcastPkts_hi
|| sblk->stat_IfHCOutBroadcastPkts_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcOutBroadcastPkts\n",
- sblk->stat_IfHCOutBroadcastPkts_hi,
- sblk->stat_IfHCOutBroadcastPkts_lo);
-
- if (sblk->stat_IfHCOutMulticastPkts_hi
+ sblk->stat_IfHCOutBroadcastPkts_hi,
+ sblk->stat_IfHCOutBroadcastPkts_lo);
+
+ if (sblk->stat_IfHCOutMulticastPkts_hi
|| sblk->stat_IfHCOutMulticastPkts_lo)
BCE_PRINTF("0x%08X:%08X : "
"IfHcOutMulticastPkts\n",
- sblk->stat_IfHCOutMulticastPkts_hi,
- sblk->stat_IfHCOutMulticastPkts_lo);
-
+ sblk->stat_IfHCOutMulticastPkts_hi,
+ sblk->stat_IfHCOutMulticastPkts_lo);
+
if (sblk->stat_emac_tx_stat_dot3statsinternalmactransmiterrors)
BCE_PRINTF(" 0x%08X : "
"emac_tx_stat_dot3statsinternalmactransmiterrors\n",
@@ -7225,10 +7223,10 @@ bce_dump_driver_state(struct bce_softc *sc)
"----------------"
"----------------------------\n");
}
-
+
/****************************************************************************/
-/* Prints out the hardware state through a summary of important registers, */
+/* Prints out the hardware state through a summary of important registers, */
/* followed by a complete register dump. */
/* */
/* Returns: */
@@ -7298,7 +7296,7 @@ bce_dump_hw_state(struct bce_softc *sc)
"----------------------------"
" Register Dump "
"----------------------------\n");
-
+
for (int i = 0x400; i < 0x8000; i += 0x10)
BCE_PRINTF("0x%04X: 0x%08X 0x%08X 0x%08X 0x%08X\n",
i, REG_RD(sc, i), REG_RD(sc, i + 0x4),
@@ -7312,7 +7310,7 @@ bce_dump_hw_state(struct bce_softc *sc)
/****************************************************************************/
-/* Prints out the TXP state. */
+/* Prints out the TXP state. */
/* */
/* Returns: */
/* Nothing. */
@@ -7340,13 +7338,13 @@ bce_dump_txp_state(struct bce_softc *sc)
"----------------------------"
" Register Dump "
"----------------------------\n");
-
- for (int i = BCE_TXP_CPU_MODE; i < 0x68000; i += 0x10) {
- /* Skip the big blank spaces */
+
+ for (int i = BCE_TXP_CPU_MODE; i < 0x68000; i += 0x10) {
+ /* Skip the big blank spaces */
if (i < 0x454000 && i > 0x5ffff)
BCE_PRINTF("0x%04X: 0x%08X 0x%08X 0x%08X 0x%08X\n",
i, REG_RD_IND(sc, i), REG_RD_IND(sc, i + 0x4),
- REG_RD_IND(sc, i + 0x8), REG_RD_IND(sc, i + 0xC));
+ REG_RD_IND(sc, i + 0x8), REG_RD_IND(sc, i + 0xC));
}
BCE_PRINTF(
@@ -7357,7 +7355,7 @@ bce_dump_txp_state(struct bce_softc *sc)
/****************************************************************************/
-/* Prints out the RXP state. */
+/* Prints out the RXP state. */
/* */
/* Returns: */
/* Nothing. */
@@ -7385,13 +7383,13 @@ bce_dump_rxp_state(struct bce_softc *sc)
"----------------------------"
" Register Dump "
"----------------------------\n");
-
- for (int i = BCE_RXP_CPU_MODE; i < 0xe8fff; i += 0x10) {
- /* Skip the big blank sapces */
+
+ for (int i = BCE_RXP_CPU_MODE; i < 0xe8fff; i += 0x10) {
+ /* Skip the big blank sapces */
if (i < 0xc5400 && i > 0xdffff)
BCE_PRINTF("0x%04X: 0x%08X 0x%08X 0x%08X 0x%08X\n",
i, REG_RD_IND(sc, i), REG_RD_IND(sc, i + 0x4),
- REG_RD_IND(sc, i + 0x8), REG_RD_IND(sc, i + 0xC));
+ REG_RD_IND(sc, i + 0x8), REG_RD_IND(sc, i + 0xC));
}
BCE_PRINTF(
@@ -7402,7 +7400,7 @@ bce_dump_rxp_state(struct bce_softc *sc)
/****************************************************************************/
-/* Prints out the TPAT state. */
+/* Prints out the TPAT state. */
/* */
/* Returns: */
/* Nothing. */
@@ -7430,13 +7428,13 @@ bce_dump_tpat_state(struct bce_softc *sc)
"----------------------------"
" Register Dump "
"----------------------------\n");
-
+
for (int i = BCE_TPAT_CPU_MODE; i < 0xa3fff; i += 0x10) {
- /* Skip the big blank spaces */
- if (i < 0x854000 && i > 0x9ffff)
+ /* Skip the big blank spaces */
+ if (i < 0x854000 && i > 0x9ffff)
BCE_PRINTF("0x%04X: 0x%08X 0x%08X 0x%08X 0x%08X\n",
i, REG_RD_IND(sc, i), REG_RD_IND(sc, i + 0x4),
- REG_RD_IND(sc, i + 0x8), REG_RD_IND(sc, i + 0xC));
+ REG_RD_IND(sc, i + 0x8), REG_RD_IND(sc, i + 0xC));
}
BCE_PRINTF(
@@ -7447,7 +7445,7 @@ bce_dump_tpat_state(struct bce_softc *sc)
/****************************************************************************/
-/* Prints out the driver state and then enters the debugger. */
+/* Prints out the driver state and then enters the debugger. */
/* */
/* Returns: */
/* Nothing. */
@@ -7458,8 +7456,8 @@ bce_breakpoint(struct bce_softc *sc)
/* Unreachable code to shut the compiler up about unused functions. */
if (0) {
- bce_freeze_controller(sc);
- bce_unfreeze_controller(sc);
+ bce_freeze_controller(sc);
+ bce_unfreeze_controller(sc);
bce_dump_txbd(sc, 0, NULL);
bce_dump_rxbd(sc, 0, NULL);
bce_dump_tx_mbuf_chain(sc, 0, USABLE_TX_BD);
@@ -7471,19 +7469,19 @@ bce_breakpoint(struct bce_softc *sc)
bce_dump_stats_block(sc);
bce_dump_driver_state(sc);
bce_dump_hw_state(sc);
- bce_dump_txp_state(sc);
- bce_dump_rxp_state(sc);
- bce_dump_tpat_state(sc);
+ bce_dump_txp_state(sc);
+ bce_dump_rxp_state(sc);
+ bce_dump_tpat_state(sc);
}
-/* bce_freeze_controller(sc); */
+/* bce_freeze_controller(sc); */
bce_dump_driver_state(sc);
bce_dump_status_block(sc);
- bce_dump_tx_chain(sc, 0, TOTAL_TX_BD);
+ bce_dump_tx_chain(sc, 0, TOTAL_TX_BD);
bce_dump_hw_state(sc);
- bce_dump_txp_state(sc);
+ bce_dump_txp_state(sc);
/* bce_unfreeze_controller(sc); */
-
+
/* Call the debugger. */
breakpoint();
diff --git a/sys/dev/bce/if_bcereg.h b/sys/dev/bce/if_bcereg.h
index 22ddd59..892df72 100644
--- a/sys/dev/bce/if_bcereg.h
+++ b/sys/dev/bce/if_bcereg.h
@@ -65,7 +65,7 @@
#include <netinet/ip6.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
-
+
#include <machine/bus.h>
#include <machine/resource.h>
#include <sys/bus.h>
@@ -99,7 +99,7 @@
/****************************************************************************/
/* Debugging macros and definitions. */
-/****************************************************************************/
+/****************************************************************************/
#define BCE_CP_LOAD 0x00000001
#define BCE_CP_SEND 0x00000002
#define BCE_CP_RECV 0x00000004
@@ -4469,16 +4469,16 @@ struct l2_fhdr {
/* Use the natural page size of the host CPU. */
/* XXX: This has only been tested on amd64/i386 systems using 4KB pages. */
#define BCM_PAGE_BITS PAGE_SHIFT
-#define BCM_PAGE_SIZE PAGE_SIZE
+#define BCM_PAGE_SIZE PAGE_SIZE
-#define TX_PAGES 2
+#define TX_PAGES 2
#define TOTAL_TX_BD_PER_PAGE (BCM_PAGE_SIZE / sizeof(struct tx_bd))
#define USABLE_TX_BD_PER_PAGE (TOTAL_TX_BD_PER_PAGE - 1)
#define TOTAL_TX_BD (TOTAL_TX_BD_PER_PAGE * TX_PAGES)
#define USABLE_TX_BD (USABLE_TX_BD_PER_PAGE * TX_PAGES)
#define MAX_TX_BD (TOTAL_TX_BD - 1)
-
-#define RX_PAGES 2
+
+#define RX_PAGES 2
#define TOTAL_RX_BD_PER_PAGE (BCM_PAGE_SIZE / sizeof(struct rx_bd))
#define USABLE_RX_BD_PER_PAGE (TOTAL_RX_BD_PER_PAGE - 1)
#define TOTAL_RX_BD (TOTAL_RX_BD_PER_PAGE * RX_PAGES)
@@ -4604,10 +4604,10 @@ struct fw_info {
#define BCE_CRC32_RESIDUAL 0xdebb20e3
#define BCE_TX_TIMEOUT 5
-
-#define BCE_MAX_SEGMENTS 32
-#define BCE_TSO_MAX_SIZE 65536
-#define BCE_TSO_MAX_SEG_SIZE 4096
+
+#define BCE_MAX_SEGMENTS 32
+#define BCE_TSO_MAX_SIZE 65536
+#define BCE_TSO_MAX_SEG_SIZE 4096
#define BCE_DMA_ALIGN 8
#define BCE_DMA_BOUNDARY 0
@@ -4699,6 +4699,10 @@ struct bce_softc
#define BCE_PHY_INT_MODE_AUTO_POLLING_FLAG 0x100
#define BCE_PHY_INT_MODE_LINK_READY_FLAG 0x200
+ /* Values that need to be shared with the PHY driver. */
+ u32 bce_shared_hw_cfg;
+ u32 bce_port_hw_cfg;
+
bus_addr_t max_bus_addr;
u16 bus_speed_mhz; /* PCI bus speed */
struct flash_spec *bce_flash_info; /* Flash NVRAM settings */
@@ -4819,9 +4823,9 @@ struct bce_softc
struct mbuf *rx_mbuf_ptr[TOTAL_RX_BD];
/* Track the number of rx_bd and tx_bd's in use. */
- u16 free_rx_bd;
+ u16 free_rx_bd;
u16 max_rx_bd;
- u16 used_tx_bd;
+ u16 used_tx_bd;
u16 max_tx_bd;
/* Provides access to hardware statistics through sysctl. */
@@ -4879,9 +4883,9 @@ struct bce_softc
u32 stat_CatchupInRuleCheckerDiscards;
u32 stat_CatchupInFTQDiscards;
u32 stat_CatchupInMBUFDiscards;
- u32 stat_CatchupInRuleCheckerP4Hit;
-
- /* Provides access to certain firmware statistics. */
+ u32 stat_CatchupInRuleCheckerP4Hit;
+
+ /* Provides access to certain firmware statistics. */
u32 com_no_buffers;
#ifdef BCE_DEBUG
@@ -4895,16 +4899,16 @@ struct bce_softc
u32 rx_interrupts;
u32 tx_interrupts;
- u32 rx_low_watermark; /* Lowest number of rx_bd's free. */
+ u32 rx_low_watermark; /* Lowest number of rx_bd's free. */
u32 rx_empty_count; /* Number of times the RX chain was empty. */
- u32 tx_hi_watermark; /* Greatest number of tx_bd's used. */
+ u32 tx_hi_watermark; /* Greatest number of tx_bd's used. */
u32 tx_full_count; /* Number of times the TX chain was full. */
u32 mbuf_alloc_failed; /* Mbuf allocation failure counter. */
u32 l2fhdr_status_errors;
u32 unexpected_attentions;
- u32 lost_status_block_updates;
-
- u32 requested_tso_frames; /* Number of TSO frames enqueued. */
+ u32 lost_status_block_updates;
+
+ u32 requested_tso_frames; /* Number of TSO frames enqueued. */
#endif
};
OpenPOWER on IntegriCloud