svn commit: r205299 - head/sys/dev/mii

2010-03-18 Thread David Christensen
Author: davidch
Date: Thu Mar 18 20:57:57 2010
New Revision: 205299
URL: http://svn.freebsd.org/changeset/base/205299

Log:
  - Added support for 5709S/5716S PHYs.
  
  Submitted by: pyunyh
  MFC after:2 weeks

Modified:
  head/sys/dev/mii/brgphy.c
  head/sys/dev/mii/brgphyreg.h
  head/sys/dev/mii/miidevs

Modified: head/sys/dev/mii/brgphy.c
==
--- head/sys/dev/mii/brgphy.c   Thu Mar 18 20:30:25 2010(r205298)
+++ head/sys/dev/mii/brgphy.c   Thu Mar 18 20:57:57 2010(r205299)
@@ -75,6 +75,7 @@ struct brgphy_softc {
 #define BRGPHY_5706S   0x0001
 #define BRGPHY_5708S   0x0002
 #define BRGPHY_NOANWAIT0x0004
+#define BRGPHY_5709S   0x0008
int bce_phy_flags;  /* PHY flags transferred from the MAC driver */
 };
 
@@ -139,6 +140,7 @@ static const struct mii_phydesc brgphys[
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5784),
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709C),
MII_PHY_DESC(xxBROADCOM_ALT1, BCM5761),
+MII_PHY_DESC(xxBROADCOM_ALT1, BCM5709S),
MII_PHY_DESC(BROADCOM2, BCM5906),
MII_PHY_END
 };
@@ -216,30 +218,34 @@ brgphy_attach(device_t dev)
break;
case MII_OUI_xxBROADCOM:
switch (bsc->mii_model) {
-   case MII_MODEL_xxBROADCOM_BCM5706:
-   case MII_MODEL_xxBROADCOM_BCM5714:
-   /*
-* The 5464 PHY used in the 5706 supports both 
copper
-* and fiber interfaces over GMII.  Need to 
check the
-* shadow registers to see which mode is 
actually
-* in effect, and therefore whether we have 
5706C or
-* 5706S.
-*/
-   PHY_WRITE(sc, BRGPHY_MII_SHADOW_1C,
-   BRGPHY_SHADOW_1C_MODE_CTRL);
-   if (PHY_READ(sc, BRGPHY_MII_SHADOW_1C) &
-   BRGPHY_SHADOW_1C_ENA_1000X) {
-   bsc->serdes_flags |= BRGPHY_5706S;
-   sc->mii_flags |= MIIF_HAVEFIBER;
-   }
-   break;
+   case MII_MODEL_xxBROADCOM_BCM5706:
+   case MII_MODEL_xxBROADCOM_BCM5714:
+   /*
+* The 5464 PHY used in the 5706 supports both copper
+* and fiber interfaces over GMII.  Need to check the
+* shadow registers to see which mode is actually
+* in effect, and therefore whether we have 5706C or
+* 5706S.
+*/
+   PHY_WRITE(sc, BRGPHY_MII_SHADOW_1C,
+   BRGPHY_SHADOW_1C_MODE_CTRL);
+   if (PHY_READ(sc, BRGPHY_MII_SHADOW_1C) &
+   BRGPHY_SHADOW_1C_ENA_1000X) {
+   bsc->serdes_flags |= BRGPHY_5706S;
+   sc->mii_flags |= MIIF_HAVEFIBER;
+   }
+   break;
} break;
case MII_OUI_xxBROADCOM_ALT1:
switch (bsc->mii_model) {
-   case MII_MODEL_xxBROADCOM_ALT1_BCM5708S:
-   bsc->serdes_flags |= BRGPHY_5708S;
-   sc->mii_flags |= MIIF_HAVEFIBER;
-   break;
+   case MII_MODEL_xxBROADCOM_ALT1_BCM5708S:
+   bsc->serdes_flags |= BRGPHY_5708S;
+   sc->mii_flags |= MIIF_HAVEFIBER;
+   break;
+case MII_MODEL_xxBROADCOM_ALT1_BCM5709S:
+bsc->serdes_flags |= BRGPHY_5709S;
+sc->mii_flags |= MIIF_HAVEFIBER;
+break;
} break;
default:
device_printf(dev, "Unrecognized OUI for PHY!\n");
@@ -631,6 +637,7 @@ brgphy_status(struct mii_softc *sc)
PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, 
BRGPHY_5708S_DIG_PG0);
xstat = PHY_READ(sc, BRGPHY_5708S_PG0_1000X_STAT1);
 
+/* Check for MRBE auto-negotiated speed results. */
switch (xstat & 
BRGPHY_5708S_PG0_1000X_STAT1_SPEED_MASK) {
case BRGPHY_5708S_PG0_1000X_STAT1_SPEED_10:
mii->mii_media_active |= IFM_10_FL; break;
@@ -642,11 +649,40 @@ brgphy_status(struct mii_softc *sc)
mii->mii_media_active |= IFM_2500_SX; break;
}
 
+/* Check for MRBE auto-negotiated duplex results. */
if (xstat & BRGPHY_5708S_PG0_1000X_STAT1_FDX)

svn commit: r205300 - head/sys/dev/bce

2010-03-18 Thread David Christensen
Author: davidch
Date: Thu Mar 18 21:00:53 2010
New Revision: 205300
URL: http://svn.freebsd.org/changeset/base/205300

Log:
  - Added support for 5709S/5716S PHYs.
  - Update copyright to 2010.
  - Add new debug code for RV2P block.
  - Improve output formatting for various debug functions.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/bce/if_bce.c
  head/sys/dev/bce/if_bcefw.h
  head/sys/dev/bce/if_bcereg.h

Modified: head/sys/dev/bce/if_bce.c
==
--- head/sys/dev/bce/if_bce.c   Thu Mar 18 20:57:57 2010(r205299)
+++ head/sys/dev/bce/if_bce.c   Thu Mar 18 21:00:53 2010(r205300)
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2006-2009 Broadcom Corporation
+ * Copyright (c) 2006-2010 Broadcom Corporation
  * David Christensen .  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -38,7 +38,9 @@ __FBSDID("$FreeBSD$");
  *   BCM5708C B1, B2
  *   BCM5708S B1, B2
  *   BCM5709C A1, C0
+ *   BCM5709S A1, C0
  *  BCM5716C C0
+ *  BCM5716S C0
  *
  * The following controllers are not supported by this driver:
  *   BCM5706C A0, A1 (pre-production)
@@ -46,7 +48,7 @@ __FBSDID("$FreeBSD$");
  *   BCM5708C A0, B0 (pre-production)
  *   BCM5708S A0, B0 (pre-production)
  *   BCM5709C A0  B0, B1, B2 (pre-production)
- *   BCM5709S A0, A1, B0, B1, B2, C0 (pre-production)
+ *   BCM5709S A0, B0, B1, B2 (pre-production)
  */
 
 #include "opt_bce.h"
@@ -320,6 +322,7 @@ static void bce_dump_rxp_state  (struct 
 static void bce_dump_tpat_state(struct bce_softc *, int);
 static void bce_dump_cp_state  (struct bce_softc *, int);
 static void bce_dump_com_state (struct bce_softc *, int);
+static void bce_dump_rv2p_state(struct bce_softc *);
 static void bce_breakpoint (struct bce_softc *);
 #endif
 
@@ -360,6 +363,7 @@ static int  bce_nvram_write (struct bc
 /*  */
 //
 static void bce_get_media  (struct bce_softc *);
+static void bce_init_media (struct bce_softc *);
 static void bce_dma_map_addr   (void *, bus_dma_segment_t *, int, int);
 static int  bce_dma_alloc  (device_t);
 static void bce_dma_free   (struct bce_softc *);
@@ -1096,7 +1100,10 @@ bce_attach(device_t dev)
else
ifp->if_baudrate = IF_Mbps(1000);
 
-   /* Check for an MII child bus by probing the PHY. */
+/* Handle any special PHY initialization for SerDes PHYs. */
+bce_init_media(sc);
+
+   /* MII child bus by probing the PHY. */
if (mii_phy_probe(dev, &sc->bce_miibus, bce_ifmedia_upd,
bce_ifmedia_sts)) {
BCE_PRINTF("%s(%d): No PHY found on child MII bus!\n",
@@ -1504,7 +1511,17 @@ bce_miibus_read_reg(device_t dev, int ph
return(0);
}
 
-   if (sc->bce_phy_flags & BCE_PHY_INT_MODE_AUTO_POLLING_FLAG) {
+/*
+ * The 5709S PHY is an IEEE Clause 45 PHY
+ * with special mappings to work with IEEE
+ * Clause 22 register accesses.
+ */
+   if ((sc->bce_phy_flags & BCE_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
+   if (reg >= MII_BMCR && reg <= MII_ANLPRNP)
+   reg += 0x10;
+   }
+
+if (sc->bce_phy_flags & BCE_PHY_INT_MODE_AUTO_POLLING_FLAG) {
val = REG_RD(sc, BCE_EMAC_MDIO_MODE);
val &= ~BCE_EMAC_MDIO_MODE_AUTO_POLL;
 
@@ -1584,6 +1601,16 @@ bce_miibus_write_reg(device_t dev, int p
 
DB_PRINT_PHY_REG(reg, val);
 
+/*
+ * The 5709S PHY is an IEEE Clause 45 PHY
+ * with special mappings to work with IEEE
+ * Clause 22 register accesses.
+ */
+   if ((sc->bce_phy_flags & BCE_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
+   if (reg >= MII_BMCR && reg <= MII_ANLPRNP)
+   reg += 0x10;
+   }
+
if (sc->bce_phy_flags & BCE_PHY_INT_MODE_AUTO_POLLING_FLAG) {
val1 = REG_RD(sc, BCE_EMAC_MDIO_MODE);
val1 &= ~BCE_EMAC_MDIO_MODE_AUTO_POLL;
@@ -2647,9 +2674,11 @@ bce_get_media(struct bce_softc *sc)
DBPRINT(sc, BCE_INFO_LOAD,
"BCM5709 s/w configured for SerDes.\n");
sc->bce_phy_flags |= BCE_PHY_SERDES_FLAG;
+break;
default:
DBPRINT(sc, BCE_INFO_LOAD,
"BCM5709 s/w configured for Copper.\n");
+break;
}
} else {
 

svn commit: r206268 - head/sys/dev/bce

2010-04-06 Thread David Christensen
Author: davidch
Date: Tue Apr  6 12:44:28 2010
New Revision: 206268
URL: http://svn.freebsd.org/changeset/base/206268

Log:
  - Fixed 5708S 2.5G support broken in last commit.
  - Added some new debug helper routines to systcl.
  - Fixed many of the style(9) violations that have crept into the code
due to my use of a "smart" editor.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/bce/if_bce.c
  head/sys/dev/bce/if_bcereg.h

Modified: head/sys/dev/bce/if_bce.c
==
--- head/sys/dev/bce/if_bce.c   Tue Apr  6 12:33:05 2010(r206267)
+++ head/sys/dev/bce/if_bce.c   Tue Apr  6 12:44:28 2010(r206268)
@@ -39,8 +39,8 @@ __FBSDID("$FreeBSD$");
  *   BCM5708S B1, B2
  *   BCM5709C A1, C0
  *   BCM5709S A1, C0
- *  BCM5716C C0
- *  BCM5716S C0
+ *   BCM5716C C0
+ *   BCM5716S C0
  *
  * The following controllers are not supported by this driver:
  *   BCM5706C A0, A1 (pre-production)
@@ -277,37 +277,41 @@ static struct flash_spec flash_5709 = {
 //
 /* FreeBSD device entry points. */
 //
-static int  bce_probe  (device_t);
-static int  bce_attach (device_t);
-static int  bce_detach (device_t);
-static int  bce_shutdown   (device_t);
+static int  bce_probe  (device_t);
+static int  bce_attach (device_t);
+static int  bce_detach (device_t);
+static int  bce_shutdown   (device_t);
 
 
 //
 /* BCE Debug Data Structure Dump Routines   */
 //
 #ifdef BCE_DEBUG
-static u32 bce_reg_rd  (struct bce_softc *, 
u32);
-static voidbce_reg_wr  (struct bce_softc *, 
u32, u32);
-static voidbce_reg_wr16(struct bce_softc *, u32, u16);
-static u32  bce_ctx_rd (struct bce_softc *, u32, u32);
-static void bce_dump_enet   (struct bce_softc *, struct mbuf *);
-static void bce_dump_mbuf  (struct bce_softc *, struct 
mbuf *);
+static u32  bce_reg_rd (struct bce_softc *, u32);
+static void bce_reg_wr (struct bce_softc *, u32, u32);
+static void bce_reg_wr16   (struct bce_softc *, u32, u16);
+static u32  bce_ctx_rd (struct bce_softc *, u32, u32);
+static void bce_dump_enet  (struct bce_softc *, struct mbuf *);
+static void bce_dump_mbuf  (struct bce_softc *, struct mbuf *);
 static void bce_dump_tx_mbuf_chain (struct bce_softc *, u16, int);
 static void bce_dump_rx_mbuf_chain (struct bce_softc *, u16, int);
 #ifdef BCE_JUMBO_HDRSPLIT
 static void bce_dump_pg_mbuf_chain (struct bce_softc *, u16, int);
 #endif
-static void bce_dump_txbd  (struct bce_softc *, int, 
struct tx_bd *);
-static void bce_dump_rxbd  (struct bce_softc *, int, 
struct rx_bd *);
+static void bce_dump_txbd  (struct bce_softc *,
+int, struct tx_bd *);
+static void bce_dump_rxbd  (struct bce_softc *,
+int, struct rx_bd *);
 #ifdef BCE_JUMBO_HDRSPLIT
-static void bce_dump_pgbd  (struct bce_softc *, int, 
struct rx_bd *);
+static void bce_dump_pgbd  (struct bce_softc *, 
+int, struct rx_bd *);
 #endif
-static void bce_dump_l2fhdr(struct bce_softc *, int, 
struct l2_fhdr *);
-static void bce_dump_ctx   (struct bce_softc *, u16);
-static void bce_dump_ftqs  (struct bce_softc *);
+static void bce_dump_l2fhdr(struct bce_softc *,
+int, struct l2_fhdr *);
+static void bce_dump_ctx   (struct bce_softc *, u16);
+static void bce_dump_ftqs  (struct bce_softc *);
 static void bce_dump_tx_chain  (struct bce_softc *, u16, int);
-static void bce_dump_rx_chain  (struct bce_softc *, u16, int);
+static void bce_dump_rx_bd_chain   (struct bce_softc *, u16, int);
 #ifdef BCE_JUMBO_HDRSPLIT
 static void bce_dump_pg_chain  (struct bce_softc *, u16, int);
 #endif
@@ -315,7 +319,7 @@ static void bce_dump_status_block   (struc
 static void bce_dump_stats_block   (struct bce_softc *);
 static void bce_dump_driver_state  (struct bce_softc *);
 static void bce_dump_hw_state  (struct bce_softc *);
-static void bce_dump_mq_regs(struct bce_softc *);
+static void bce_dump_mq_regs   (struct bce_softc *);
 static void bce_dump_bc_state  (struct bce_softc *);
 static void bce_dump_txp

svn commit: r207391 - head/sys/dev/mii

2010-04-29 Thread David Christensen
Author: davidch
Date: Thu Apr 29 22:00:57 2010
New Revision: 207391
URL: http://svn.freebsd.org/changeset/base/207391

Log:
  - Pass flow control settings back to bce(4).
  
  MFC after:Two weeks

Modified:
  head/sys/dev/mii/brgphy.c

Modified: head/sys/dev/mii/brgphy.c
==
--- head/sys/dev/mii/brgphy.c   Thu Apr 29 21:55:20 2010(r207390)
+++ head/sys/dev/mii/brgphy.c   Thu Apr 29 22:00:57 2010(r207391)
@@ -685,16 +685,15 @@ brgphy_status(struct mii_softc *sc)
 
}
 
-#if 0
-   /* Todo: Change bge/bce to use these settings. */
+   /* Todo: Change bge to use these settings. */
 
-   /* Fetch flow control settings from the PHY */
+   /* Fetch flow control settings from the copper PHY. */
if ((sc->mii_flags & MIIF_HAVEFIBER) == 0) {
-   /* Set FLAG0 is RX is enabled and FLAG1 if TX is enabled */
+   /* Set FLAG0 if RX is enabled and FLAG1 if TX is enabled */
if ((anar & BRGPHY_ANAR_PC) && (anlpar & BRGPHY_ANLPAR_PC)) {
mii->mii_media_active |= IFM_FLAG0 | IFM_FLAG1;
} else if (!(anar & BRGPHY_ANAR_PC) && (anlpar & 
BRGPHY_ANAR_ASP) &&
-   (anlpar & BRPHY_ANLPAR_PC) && (anlpar & BRGPHY_ANLPAR_ASP)) 
{
+   (anlpar & BRGPHY_ANLPAR_PC) && (anlpar & 
BRGPHY_ANLPAR_ASP)) {
mii->mii_media_active |= IFM_FLAG1;
} else if ((anar & BRGPHY_ANAR_PC) && (anar & BRGPHY_ANAR_ASP) 
&&
!(anlpar & BRGPHY_ANLPAR_PC) && (anlpar & 
BRGPHY_ANLPAR_ASP)) {
@@ -703,7 +702,6 @@ brgphy_status(struct mii_softc *sc)
}
 
/* Todo: Add support for fiber settings too. */
-#endif
 
 
 brgphy_status_exit:
___
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"


svn commit: r207411 - head/sys/dev/bce

2010-04-29 Thread David Christensen
Author: davidch
Date: Fri Apr 30 02:35:46 2010
New Revision: 207411
URL: http://svn.freebsd.org/changeset/base/207411

Log:
  - Enable flow control.
  - Print device details only when verbose boot is enabled.
  - Add debug output for shared memory access.
  - Add debug statistics (checksum offload & VLAN frame counters).
  - Modify TX path to update consumer index for each frame completed
rather than updating the consumer index only once for a group of
frames to improve small packet performance.
  - Print driver/firmware pulse messages only when verbose boot
is enabled.
  - Add debug sysctl to clear statistics.
  - Fix more style(9) violations.
  
  MFC after:2 weeks

Modified:
  head/sys/dev/bce/if_bce.c
  head/sys/dev/bce/if_bcereg.h

Modified: head/sys/dev/bce/if_bce.c
==
--- head/sys/dev/bce/if_bce.c   Fri Apr 30 00:46:43 2010(r207410)
+++ head/sys/dev/bce/if_bce.c   Fri Apr 30 02:35:46 2010(r207411)
@@ -303,7 +303,7 @@ static void bce_dump_txbd   (struct bce_s
 static void bce_dump_rxbd  (struct bce_softc *,
 int, struct rx_bd *);
 #ifdef BCE_JUMBO_HDRSPLIT
-static void bce_dump_pgbd  (struct bce_softc *, 
+static void bce_dump_pgbd  (struct bce_softc *,
 int, struct rx_bd *);
 #endif
 static void bce_dump_l2fhdr(struct bce_softc *,
@@ -368,7 +368,7 @@ static int  bce_nvram_write (struct bce
 //
 static void bce_get_media  (struct bce_softc *);
 static void bce_init_media (struct bce_softc *);
-static void bce_dma_map_addr   (void *, 
+static void bce_dma_map_addr   (void *,
 bus_dma_segment_t *, int, int);
 static int  bce_dma_alloc  (device_t);
 static void bce_dma_free   (struct bce_softc *);
@@ -379,7 +379,7 @@ static void bce_release_resources   (struc
 //
 static int  bce_fw_sync(struct bce_softc *, u32);
 static void bce_load_rv2p_fw   (struct bce_softc *, u32 *, u32, u32);
-static void bce_load_cpu_fw(struct bce_softc *, 
+static void bce_load_cpu_fw(struct bce_softc *,
 struct cpu_reg *, struct fw_info *);
 static void bce_start_cpu  (struct bce_softc *, struct cpu_reg *);
 static void bce_halt_cpu   (struct bce_softc *, struct cpu_reg *);
@@ -401,21 +401,21 @@ static int  bce_blockinit (struct bce_
 static int  bce_init_tx_chain  (struct bce_softc *);
 static void bce_free_tx_chain  (struct bce_softc *);
 
-static int  bce_get_rx_buf (struct bce_softc *, 
+static int  bce_get_rx_buf (struct bce_softc *,
 struct mbuf *, u16 *, u16 *, u32 *);
 static int  bce_init_rx_chain  (struct bce_softc *);
 static void bce_fill_rx_chain  (struct bce_softc *);
 static void bce_free_rx_chain  (struct bce_softc *);
 
 #ifdef BCE_JUMBO_HDRSPLIT
-static int  bce_get_pg_buf (struct bce_softc *, 
+static int  bce_get_pg_buf (struct bce_softc *,
 struct mbuf *, u16 *, u16 *);
 static int  bce_init_pg_chain  (struct bce_softc *);
 static void bce_fill_pg_chain  (struct bce_softc *);
 static void bce_free_pg_chain  (struct bce_softc *);
 #endif
 
-static struct mbuf *bce_tso_setup  (struct bce_softc *, 
+static struct mbuf *bce_tso_setup  (struct bce_softc *,
 struct mbuf **, u16 *);
 static int  bce_tx_encap   (struct bce_softc *, struct mbuf **);
 static void bce_start_locked   (struct ifnet *);
@@ -566,7 +566,7 @@ bce_probe(device_t dev)
 
/* Print out the device identity. */
snprintf(descbuf, BCE_DEVDESC_MAX, "%s (%c%d)",
-   t->bce_name, (((pci_read_config(dev, 
+   t->bce_name, (((pci_read_config(dev,
PCIR_REVID, 4) & 0xf0) >> 4) + 'A'),
(pci_read_config(dev, PCIR_REVID, 4) & 0xf));
 
@@ -593,57 +593,60 @@ bce_probe(device_t dev)
 static void
 bce_print_adapter_info(struct bce_softc *sc)
 {
-int i = 0;
+   int i = 0;
 
DBENTER(BCE_VERBOSE_LOAD);
 
-   BCE_PRINTF("ASIC (0x%08X); ", sc->bce_chipid);
-   printf("Rev (%c%d); ", ((BCE_CHIP_ID(sc) & 0xf000) >> 12) + 'A',
-   ((BCE_CHIP_ID(sc) & 0x0ff0) >> 4));
-
-   /* Bus info. */
-   if (sc->bce_flags & BCE_PCIE_FLAG) {
-   printf("Bus (PCIe x%d, ", sc->link_width);
-   switch (sc->link_speed) {
-   case 1: printf("2.5Gbps); "); break;
-   case 2: printf("5Gbps); "); break;
-   default: printf("Unknown link speed); ");
+   if (bootverbose) {
+   BCE_PRINTF("AS