Hi,
I found a small discrepancy between the FreeBSD and OpenBSD bge driver
in the following code:
from FreeBSD if_bge.c@3289:
if (sc->bge_asicrev == BGE_ASICREV_BCM5717 ||
sc->bge_asicrev == BGE_ASICREV_BCM5719 ||
sc->bge_asicrev == BGE_ASICREV_BCM5720) {
if (sc->bge_chipid != BGE_CHIPID_BCM5717_A0) {
if (CSR_READ_4(sc, BGE_SGDIG_STS) &
BGE_SGDIGSTS_IS_SERDES)
sc->bge_phy_addr = sc->bge_func_addr + 8;
else
sc->bge_phy_addr = sc->bge_func_addr + 1;
} else {
if (CSR_READ_4(sc, BGE_CPMU_PHY_STRAP) &
BGE_CPMU_PHY_STRAP_IS_SERDES)
sc->bge_phy_addr = sc->bge_func_addr + 8;
else
sc->bge_phy_addr = sc->bge_func_addr + 1;
}
}
from OpenBSD if_bge.c@1592:
switch (BGE_ASICREV(sc->bge_chipid)) {
case BGE_ASICREV_BCM5717:
case BGE_ASICREV_BCM5719:
case BGE_ASICREV_BCM5720:
phy_addr = pa->pa_function;
if (sc->bge_chipid == BGE_CHIPID_BCM5717_A0) {
phy_addr += (CSR_READ_4(sc, BGE_SGDIG_STS) &
BGE_SGDIGSTS_IS_SERDES) ? 8 : 1;
} else {
phy_addr += (CSR_READ_4(sc, BGE_CPMU_PHY_STRAP) &
BGE_CPMU_PHY_STRAP_IS_SERDES) ? 8 : 1;
}
}
The FreeBSD code uses the BGE_SGDIG_STS register when the chip is NOT
a BCM5717_A0, the OpenBSD implementation does the opposite.
I can't tell which is correct. I tested this with a BCM5719 based card
and both path resulted in 1 being added. I have attached a patch below
in case the FreeBSD implementation is the correct one.
Kind regards,
David
--- if_bge.c.orig 2013-04-06 11:09:54.154949994 +0200
+++ if_bge.c 2013-04-06 11:19:26.366933077 +0200
@@ -1594,7 +1594,7 @@ bge_phy_addr(struct bge_softc *sc)
case BGE_ASICREV_BCM5719:
case BGE_ASICREV_BCM5720:
phy_addr = pa->pa_function;
- if (sc->bge_chipid == BGE_CHIPID_BCM5717_A0) {
+ if (sc->bge_chipid != BGE_CHIPID_BCM5717_A0) {
phy_addr += (CSR_READ_4(sc, BGE_SGDIG_STS) &
BGE_SGDIGSTS_IS_SERDES) ? 8 : 1;
} else {