Re: bnx(4) BCM5709S fiber support.

2010-04-21 Thread Stuart Henderson
On 2010/04/06 21:26, Brad wrote:
 Please test the following diff if you have a system utilizing the
 BCM5709S chipset. This diff adds support for the fiber PHY coupled
 with the BCM5709S controller.

Has anyone tested this on an R610 or R210?


 
 Index: pci/if_bnx.c
 ===
 RCS file: /cvs/src/sys/dev/pci/if_bnx.c,v
 retrieving revision 1.86
 diff -u -p -r1.86 if_bnx.c
 --- pci/if_bnx.c  23 Nov 2009 10:54:43 -  1.86
 +++ pci/if_bnx.c  28 Mar 2010 21:45:11 -
 @@ -42,6 +42,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
   *   BCM5708C B1, B2
   *   BCM5708S B1, B2
   *   BCM5709C A1, C0
 + *   BCM5709S A1, C0
   *   BCM5716  C0
   *
   * The following controllers are not supported by this driver:
 @@ -50,7 +51,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
   *   BCM5708C A0, B0
   *   BCM5708S A0, B0
   *   BCM5709C A0  B0, B1, B2 (pre-production)
 - *   BCM5709S A0, A1, B0, B1, B2, C0 (pre-production)
 + *   BCM5709S A0, B0, B1, B2 (pre-production)
   */
  
  #include dev/pci/if_bnxreg.h
 @@ -340,6 +341,7 @@ int   bnx_nvram_write(struct bnx_softc *, 
  /*  
 */
  
 //
  void bnx_get_media(struct bnx_softc *);
 +void bnx_init_media(struct bnx_softc *);
  int  bnx_dma_alloc(struct bnx_softc *);
  void bnx_dma_free(struct bnx_softc *);
  void bnx_release_resources(struct bnx_softc *);
 @@ -905,6 +907,9 @@ bnx_attachhook(void *xsc)
   sc-bnx_mii.mii_writereg = bnx_miibus_write_reg;
   sc-bnx_mii.mii_statchg = bnx_miibus_statchg;
  
 + /* Handle any special PHY initialization for SerDes PHYs. */
 + bnx_init_media(sc);
 +
   /* Look for our PHY. */
   ifmedia_init(sc-bnx_mii.mii_media, 0, bnx_ifmedia_upd,
   bnx_ifmedia_sts);
 @@ -1120,6 +1125,16 @@ bnx_miibus_read_reg(struct device *dev, 
   return(0);
   }
  
 + /*
 +  * The BCM5709S PHY is an IEEE Clause 45 PHY
 +  * with special mappings to work with IEEE
 +  * Clause 22 register accesses.
 +  */
 + if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
 + if (reg = MII_BMCR  reg = MII_ANLPRNP)
 + reg += 0x10;
 + }
 +
   if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
   val = REG_RD(sc, BNX_EMAC_MDIO_MODE);
   val = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
 @@ -1199,6 +1214,16 @@ bnx_miibus_write_reg(struct device *dev,
   val = 0x%04X\n, __FUNCTION__,
   phy, (u_int16_t) reg  0x, (u_int16_t) val  0x);
  
 + /*
 +  * The BCM5709S PHY is an IEEE Clause 45 PHY
 +  * with special mappings to work with IEEE
 +  * Clause 22 register accesses.
 +  */
 + if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
 + if (reg = MII_BMCR  reg = MII_ANLPRNP)
 + reg += 0x10;
 + }
 +
   if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
   val1 = REG_RD(sc, BNX_EMAC_MDIO_MODE);
   val1 = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
 @@ -2179,6 +2204,7 @@ bnx_get_media(struct bnx_softc *sc)
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for SerDes.\n);
   sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
 + break;
   default:
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for Copper.\n);
 @@ -2191,6 +2217,7 @@ bnx_get_media(struct bnx_softc *sc)
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for SerDes.\n);
   sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
 + break;
   default:
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for Copper.\n);
 @@ -2202,6 +2229,14 @@ bnx_get_media(struct bnx_softc *sc)
  
   if (sc-bnx_phy_flags  BNX_PHY_SERDES_FLAG) {
   sc-bnx_flags |= BNX_NO_WOL_FLAG;
 +
 + if (BNX_CHIP_NUM(sc) == BNX_CHIP_NUM_5709)
 + sc-bnx_phy_flags |= BNX_PHY_IEEE_CLAUSE_45_FLAG;
 +
 + /*
 +  * The BCM5708S, BCM5709S, and BCM5716S controllers use a
 +  * separate PHY for SerDes.
 +  */
   if (BNX_CHIP_NUM(sc) != BNX_CHIP_NUM_5706) {
   sc-bnx_phy_addr = 2;
   val = REG_RD_IND(sc, sc-bnx_shmem_base +
 @@ -2219,6 +2254,36 @@ bnx_get_media(struct bnx_softc *sc)
  bnx_get_media_exit:
   DBPRINT(sc, (BNX_INFO_LOAD | BNX_INFO_PHY), 
   Using PHY address %d.\n, sc-bnx_phy_addr);
 +}
 +
 

bnx(4) BCM5709S fiber support.

2010-04-06 Thread Brad
Please test the following diff if you have a system utilizing the
BCM5709S chipset. This diff adds support for the fiber PHY coupled
with the BCM5709S controller.


Index: pci/if_bnx.c
===
RCS file: /cvs/src/sys/dev/pci/if_bnx.c,v
retrieving revision 1.86
diff -u -p -r1.86 if_bnx.c
--- pci/if_bnx.c23 Nov 2009 10:54:43 -  1.86
+++ pci/if_bnx.c28 Mar 2010 21:45:11 -
@@ -42,6 +42,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
  *   BCM5708C B1, B2
  *   BCM5708S B1, B2
  *   BCM5709C A1, C0
+ *   BCM5709S A1, C0
  *   BCM5716  C0
  *
  * The following controllers are not supported by this driver:
@@ -50,7 +51,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
  *   BCM5708C A0, B0
  *   BCM5708S A0, B0
  *   BCM5709C A0  B0, B1, B2 (pre-production)
- *   BCM5709S A0, A1, B0, B1, B2, C0 (pre-production)
+ *   BCM5709S A0, B0, B1, B2 (pre-production)
  */
 
 #include dev/pci/if_bnxreg.h
@@ -340,6 +341,7 @@ int bnx_nvram_write(struct bnx_softc *, 
 /*  */
 //
 void   bnx_get_media(struct bnx_softc *);
+void   bnx_init_media(struct bnx_softc *);
 intbnx_dma_alloc(struct bnx_softc *);
 void   bnx_dma_free(struct bnx_softc *);
 void   bnx_release_resources(struct bnx_softc *);
@@ -905,6 +907,9 @@ bnx_attachhook(void *xsc)
sc-bnx_mii.mii_writereg = bnx_miibus_write_reg;
sc-bnx_mii.mii_statchg = bnx_miibus_statchg;
 
+   /* Handle any special PHY initialization for SerDes PHYs. */
+   bnx_init_media(sc);
+
/* Look for our PHY. */
ifmedia_init(sc-bnx_mii.mii_media, 0, bnx_ifmedia_upd,
bnx_ifmedia_sts);
@@ -1120,6 +1125,16 @@ bnx_miibus_read_reg(struct device *dev, 
return(0);
}
 
+   /*
+* The BCM5709S PHY is an IEEE Clause 45 PHY
+* with special mappings to work with IEEE
+* Clause 22 register accesses.
+*/
+   if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
+   if (reg = MII_BMCR  reg = MII_ANLPRNP)
+   reg += 0x10;
+   }
+
if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
val = REG_RD(sc, BNX_EMAC_MDIO_MODE);
val = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
@@ -1199,6 +1214,16 @@ bnx_miibus_write_reg(struct device *dev,
val = 0x%04X\n, __FUNCTION__,
phy, (u_int16_t) reg  0x, (u_int16_t) val  0x);
 
+   /*
+* The BCM5709S PHY is an IEEE Clause 45 PHY
+* with special mappings to work with IEEE
+* Clause 22 register accesses.
+*/
+   if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
+   if (reg = MII_BMCR  reg = MII_ANLPRNP)
+   reg += 0x10;
+   }
+
if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
val1 = REG_RD(sc, BNX_EMAC_MDIO_MODE);
val1 = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
@@ -2179,6 +2204,7 @@ bnx_get_media(struct bnx_softc *sc)
DBPRINT(sc, BNX_INFO_LOAD, 
BCM5709 s/w configured for SerDes.\n);
sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
+   break;
default:
DBPRINT(sc, BNX_INFO_LOAD, 
BCM5709 s/w configured for Copper.\n);
@@ -2191,6 +2217,7 @@ bnx_get_media(struct bnx_softc *sc)
DBPRINT(sc, BNX_INFO_LOAD, 
BCM5709 s/w configured for SerDes.\n);
sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
+   break;
default:
DBPRINT(sc, BNX_INFO_LOAD, 
BCM5709 s/w configured for Copper.\n);
@@ -2202,6 +2229,14 @@ bnx_get_media(struct bnx_softc *sc)
 
if (sc-bnx_phy_flags  BNX_PHY_SERDES_FLAG) {
sc-bnx_flags |= BNX_NO_WOL_FLAG;
+
+   if (BNX_CHIP_NUM(sc) == BNX_CHIP_NUM_5709)
+   sc-bnx_phy_flags |= BNX_PHY_IEEE_CLAUSE_45_FLAG;
+
+   /*
+* The BCM5708S, BCM5709S, and BCM5716S controllers use a
+* separate PHY for SerDes.
+*/
if (BNX_CHIP_NUM(sc) != BNX_CHIP_NUM_5706) {
sc-bnx_phy_addr = 2;
val = REG_RD_IND(sc, sc-bnx_shmem_base +
@@ -2219,6 +2254,36 @@ bnx_get_media(struct bnx_softc *sc)
 bnx_get_media_exit:
DBPRINT(sc, (BNX_INFO_LOAD | BNX_INFO_PHY), 
Using PHY address %d.\n, sc-bnx_phy_addr);
+}
+
+//
+/* Performs PHY 

Re: bnx(4) BCM5709S fiber support.

2010-04-06 Thread Theo de Raadt
 Please test the following diff if you have a system utilizing the
 BCM5709S chipset. This diff adds support for the fiber PHY coupled
 with the BCM5709S controller.

This is wrong.  Test if you have *any* bnx.  When a diff of this nasty
complexity and size goes by, noone could give a rats ass if it helps
support the new chip.

Everyone cares that it doesn't break an existing chipset.

If you have a bnx, test it.  Report all failures to brad.  He might
care to hear that it helps new chips, but what he really needs to hear
is that it breaks other chips, that people have.

Always approach all big diffs like that.  We don't care as much if
they help new chips people don't have.  We care that they don't break
things people have lots of.  When they break things people have, that
is embarrasing because it so preventable.

And honestly.. this is a simple diff compared to the others recently
floating around.

 Index: pci/if_bnx.c
 ===
 RCS file: /cvs/src/sys/dev/pci/if_bnx.c,v
 retrieving revision 1.86
 diff -u -p -r1.86 if_bnx.c
 --- pci/if_bnx.c  23 Nov 2009 10:54:43 -  1.86
 +++ pci/if_bnx.c  28 Mar 2010 21:45:11 -
 @@ -42,6 +42,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
   *   BCM5708C B1, B2
   *   BCM5708S B1, B2
   *   BCM5709C A1, C0
 + *   BCM5709S A1, C0
   *   BCM5716  C0
   *
   * The following controllers are not supported by this driver:
 @@ -50,7 +51,7 @@ __FBSDID($FreeBSD: src/sys/dev/bce/if_b
   *   BCM5708C A0, B0
   *   BCM5708S A0, B0
   *   BCM5709C A0  B0, B1, B2 (pre-production)
 - *   BCM5709S A0, A1, B0, B1, B2, C0 (pre-production)
 + *   BCM5709S A0, B0, B1, B2 (pre-production)
   */
  
  #include dev/pci/if_bnxreg.h
 @@ -340,6 +341,7 @@ int   bnx_nvram_write(struct bnx_softc *, 
  /*  
 */
  
 //
  void bnx_get_media(struct bnx_softc *);
 +void bnx_init_media(struct bnx_softc *);
  int  bnx_dma_alloc(struct bnx_softc *);
  void bnx_dma_free(struct bnx_softc *);
  void bnx_release_resources(struct bnx_softc *);
 @@ -905,6 +907,9 @@ bnx_attachhook(void *xsc)
   sc-bnx_mii.mii_writereg = bnx_miibus_write_reg;
   sc-bnx_mii.mii_statchg = bnx_miibus_statchg;
  
 + /* Handle any special PHY initialization for SerDes PHYs. */
 + bnx_init_media(sc);
 +
   /* Look for our PHY. */
   ifmedia_init(sc-bnx_mii.mii_media, 0, bnx_ifmedia_upd,
   bnx_ifmedia_sts);
 @@ -1120,6 +1125,16 @@ bnx_miibus_read_reg(struct device *dev, 
   return(0);
   }
  
 + /*
 +  * The BCM5709S PHY is an IEEE Clause 45 PHY
 +  * with special mappings to work with IEEE
 +  * Clause 22 register accesses.
 +  */
 + if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
 + if (reg = MII_BMCR  reg = MII_ANLPRNP)
 + reg += 0x10;
 + }
 +
   if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
   val = REG_RD(sc, BNX_EMAC_MDIO_MODE);
   val = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
 @@ -1199,6 +1214,16 @@ bnx_miibus_write_reg(struct device *dev,
   val = 0x%04X\n, __FUNCTION__,
   phy, (u_int16_t) reg  0x, (u_int16_t) val  0x);
  
 + /*
 +  * The BCM5709S PHY is an IEEE Clause 45 PHY
 +  * with special mappings to work with IEEE
 +  * Clause 22 register accesses.
 +  */
 + if ((sc-bnx_phy_flags  BNX_PHY_IEEE_CLAUSE_45_FLAG) != 0) {
 + if (reg = MII_BMCR  reg = MII_ANLPRNP)
 + reg += 0x10;
 + }
 +
   if (sc-bnx_phy_flags  BNX_PHY_INT_MODE_AUTO_POLLING_FLAG) {
   val1 = REG_RD(sc, BNX_EMAC_MDIO_MODE);
   val1 = ~BNX_EMAC_MDIO_MODE_AUTO_POLL;
 @@ -2179,6 +2204,7 @@ bnx_get_media(struct bnx_softc *sc)
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for SerDes.\n);
   sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
 + break;
   default:
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for Copper.\n);
 @@ -2191,6 +2217,7 @@ bnx_get_media(struct bnx_softc *sc)
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for SerDes.\n);
   sc-bnx_phy_flags |= BNX_PHY_SERDES_FLAG;
 + break;
   default:
   DBPRINT(sc, BNX_INFO_LOAD, 
   BCM5709 s/w configured for Copper.\n);
 @@ -2202,6 +2229,14 @@ bnx_get_media(struct bnx_softc *sc)
  
   if (sc-bnx_phy_flags  BNX_PHY_SERDES_FLAG) {
   sc-bnx_flags |= BNX_NO_WOL_FLAG;
 +
 + if