brgphy(4) model checking tweaking

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

brgphy(4) model checking tweaking

Brad Smith-14
Ok here is a diff that tweaks up the model checking a bit, a little
bit of paranoia but I just want to make sure that the appropriate
adjustments are only applied as necessary. Using only the model
numbers for checking the appropriate PHY can overlap between different
OUI's. Test with any adapters using brgphy(4). Please provide a dmesg.


Index: brgphy.c
===================================================================
RCS file: /cvs/src/sys/dev/mii/brgphy.c,v
retrieving revision 1.84
diff -u -p -r1.84 brgphy.c
--- brgphy.c 8 Nov 2008 03:03:50 -0000 1.84
+++ brgphy.c 8 Nov 2008 03:15:33 -0000
@@ -183,20 +183,19 @@ brgphy_attach(struct device *parent, str
 
  sc->mii_inst = mii->mii_instance;
  sc->mii_phy = ma->mii_phyno;
+ sc->mii_oui = MII_OUI(ma->mii_id1, ma->mii_id2);
  sc->mii_model = MII_MODEL(ma->mii_id2);
  sc->mii_rev = MII_REV(ma->mii_id2);
  sc->mii_pdata = mii;
  sc->mii_flags = ma->mii_flags;
  if (sc->mii_flags & MIIF_HAVEFIBER) {
- if (MII_OUI(ma->mii_id1, ma->mii_id2) ==
-    MII_OUI_xxBROADCOM &&
+ if (sc->mii_oui == MII_OUI_xxBROADCOM &&
     (sc->mii_model == MII_MODEL_xxBROADCOM_BCM5706 ||
      sc->mii_model == MII_MODEL_xxBROADCOM_BCM5714 ||
      sc->mii_model == MII_MODEL_xxBROADCOM_BCM5780))
  sc->mii_funcs = &brgphy_fiber_funcs;
- else if (MII_OUI(ma->mii_id1, ma->mii_id2) ==
-    MII_OUI_xxBROADCOM2 && sc->mii_model ==
-    MII_MODEL_xxBROADCOM2_BCM5708S)
+ else if (sc->mii_oui == MII_OUI_xxBROADCOM2 &&
+    sc->mii_model == MII_MODEL_xxBROADCOM2_BCM5708S)
  sc->mii_funcs = &brgphy_5708s_funcs;
  } else
  sc->mii_funcs = &brgphy_copper_funcs;
@@ -359,17 +358,19 @@ setit:
  if (sc->mii_media_active != mii->mii_media_active ||
     sc->mii_media_status != mii->mii_media_status ||
     cmd == MII_MEDIACHG) {
- switch (sc->mii_model) {
- case MII_MODEL_BROADCOM_BCM5400:
- brgphy_bcm5401_dspcode(sc);
- break;
- case MII_MODEL_xxBROADCOM_BCM5401:
- if (sc->mii_rev == 1 || sc->mii_rev == 3)
+ if (sc->mii_oui == MII_OUI_xxBROADCOM) {
+ switch (sc->mii_model) {
+ case MII_MODEL_xxBROADCOM_BCM5400:
  brgphy_bcm5401_dspcode(sc);
- break;
- case MII_MODEL_xxBROADCOM_BCM5411:
- brgphy_bcm5411_dspcode(sc);
- break;
+ break;
+ case MII_MODEL_xxBROADCOM_BCM5401:
+ if (sc->mii_rev == 1 || sc->mii_rev == 3)
+ brgphy_bcm5401_dspcode(sc);
+ break;
+ case MII_MODEL_xxBROADCOM_BCM5411:
+ brgphy_bcm5411_dspcode(sc);
+ break;
+ }
  }
  }
 
@@ -431,7 +432,8 @@ brgphy_copper_status(struct mii_softc *s
  mii->mii_media_active |= IFM_10_T | IFM_HDX;
  break;
  default:
- if (sc->mii_model == MII_MODEL_BROADCOM2_BCM5906) {
+ if (sc->mii_oui == MII_OUI_BROADCOM2 &&
+    sc->mii_model == MII_MODEL_BROADCOM2_BCM5906) {
  mii->mii_media_active |= (auxsts &
     BRGPHY_RES_100) ? IFM_100_TX : IFM_10_T;
  mii->mii_media_active |= (auxsts &
@@ -613,23 +615,25 @@ brgphy_reset(struct mii_softc *sc)
 
  mii_phy_reset(sc);
 
- switch (sc->mii_model) {
- case MII_MODEL_BROADCOM_BCM5400:
- brgphy_bcm5401_dspcode(sc);
- break;
- case MII_MODEL_BROADCOM_BCM5401:
- if (sc->mii_rev == 1 || sc->mii_rev == 3)
+ if (sc->mii_oui == MII_OUI_xxBROADCOM) {
+ switch (sc->mii_model) {
+ case MII_MODEL_xxBROADCOM_BCM5400:
  brgphy_bcm5401_dspcode(sc);
- break;
- case MII_MODEL_BROADCOM_BCM5411:
- brgphy_bcm5411_dspcode(sc);
- break;
- case MII_MODEL_xxBROADCOM_BCM5421:
- brgphy_bcm5421_dspcode(sc);
- break;
- case MII_MODEL_xxBROADCOM_BCM54K2:
- brgphy_bcm54k2_dspcode(sc);
- break;
+ break;
+ case MII_MODEL_xxBROADCOM_BCM5401:
+ if (sc->mii_rev == 1 || sc->mii_rev == 3)
+ brgphy_bcm5401_dspcode(sc);
+ break;
+ case MII_MODEL_xxBROADCOM_BCM5411:
+ brgphy_bcm5411_dspcode(sc);
+ break;
+ case MII_MODEL_xxBROADCOM_BCM5421:
+ brgphy_bcm5421_dspcode(sc);
+ break;
+ case MII_MODEL_xxBROADCOM_BCM54K2:
+ brgphy_bcm54k2_dspcode(sc);
+ break;
+ }
  }
 
  /* Handle any bge (NetXtreme/NetLink) workarounds. */
@@ -668,7 +672,8 @@ brgphy_reset(struct mii_softc *sc)
  brgphy_jumbo_settings(sc);
 
  /* Adjust output voltage */
- if (sc->mii_model == MII_MODEL_BROADCOM2_BCM5906)
+ if (sc->mii_oui == MII_OUI_BROADCOM2 &&
+    sc->mii_model == MII_MODEL_BROADCOM2_BCM5906)
  PHY_WRITE(sc, BRGPHY_MII_EPHY_PTEST, 0x12);
 
  /* Enable Ethernet@Wirespeed */
@@ -686,7 +691,8 @@ brgphy_reset(struct mii_softc *sc)
  } else if (strcmp(devname, "bnx") == 0) {
  bnx_sc = sc->mii_pdata->mii_ifp->if_softc;
 
- if (sc->mii_model == MII_MODEL_xxBROADCOM2_BCM5708S) {
+ if (sc->mii_oui == MII_OUI_xxBROADCOM2 &&
+    sc->mii_model == MII_MODEL_xxBROADCOM2_BCM5708S) {
  /* Store autoneg capabilities/results in digital block (Page 0) */
  PHY_WRITE(sc, BRGPHY_5708S_BLOCK_ADDR, BRGPHY_5708S_DIG3_PG2);
  PHY_WRITE(sc, BRGPHY_5708S_PG2_DIGCTL_3_0,
@@ -918,7 +924,8 @@ brgphy_jumbo_settings(struct mii_softc *
  u_int32_t val;
 
  /* Set Jumbo frame settings in the PHY. */
- if (sc->mii_model == MII_MODEL_BROADCOM_BCM5401) {
+ if (sc->mii_oui == MII_OUI_xxBROADCOM &&
+    sc->mii_model == MII_MODEL_xxBROADCOM_BCM5401) {
  /* Cannot do read-modify-write on the BCM5401 */
  PHY_WRITE(sc, BRGPHY_MII_AUXCTL, 0x4c20);
  } else {

--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.

Reply | Threaded
Open this post in threaded view
|

Re: brgphy(4) model checking tweaking

Sevan / Venture37-2
Hi Brad
dmesg output as requested, there is no difference between the output of
the unpatched & patched kernel.

OpenBSD 4.4-current (GENERIC) #0: Tue Nov 18 05:44:04 GMT 2008
     [hidden email]:/usr/src/sys/arch/amd64/compile/GENERIC
real mem = 3475267584 (3314MB)
avail mem = 3371716608 (3215MB)
mainbus0 at root
bios0 at mainbus0: SMBIOS rev. 2.5 @ 0xf0b70 (48 entries)
bios0: vendor Dell Inc. version "1.3.2" date 08/20/2008
bios0: Dell Inc. PowerEdge T105
acpi0 at bios0: rev 2
acpi0: tables DSDT FACP TCPA SLIC SPCR EINJ HEST BERT SSDT ERST SRAT
SSDT MCFG HPET APIC BOOT
acpi0: wakeup devices PCI0(S5) USB0(S0) P2P0(S5)
acpitimer0 at acpi0: 3579545 Hz, 24 bits
acpihpet0 at acpi0: 25000000 Hz
acpiprt0 at acpi0: bus 0 (PCI0)
acpiprt1 at acpi0: bus 1 (P2P0)
acpiprt2 at acpi0: bus 5 (XVR0)
acpiprt3 at acpi0: bus 4 (XVR1)
acpiprt4 at acpi0: bus 3 (XVR2)
acpiprt5 at acpi0: bus 2 (XVR3)
acpicpu0 at acpi0: C3, C2, PSS
acpibtn0 at acpi0: PWRB
cpu0 at mainbus0: (uniprocessor)
cpu0: Dual-Core AMD Opteron(tm) Processor 1212, 2009.49 MHz
cpu0:
FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX,FXSR,SSE,SSE2,HTT,SSE3,CX16,NXE,MMXX,FFXSR,LONG,3DNOW2,3DNOW
cpu0: 64KB 64b/line 2-way I-cache, 64KB 64b/line 2-way D-cache, 1MB
64b/line 16-way L2 cache
cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: DTLB 32 4KB entries fully associative, 8 4MB entries fully associative
cpu0: PowerNow! K8 2009 MHz: speeds: 2000 1800 1000 MHz
pci0 at mainbus0 bus 0: configuration mode 1
"NVIDIA nForce4 DDR" rev 0xa4 at pci0 dev 0 function 0 not configured
pcib0 at pci0 dev 1 function 0 "NVIDIA nForce4 ISA" rev 0xf1
nviic0 at pci0 dev 1 function 1 "NVIDIA nForce4 SMBus" rev 0xa2
iic0 at nviic0
spdmem0 at iic0 addr 0x52: 2GB DDR2 SDRAM ECC PC2-5300CL5
spdmem1 at iic0 addr 0x53: 2GB DDR2 SDRAM ECC PC2-5300CL5
iic1 at nviic0
ohci0 at pci0 dev 2 function 0 "NVIDIA nForce4 USB" rev 0xa2: irq 11,
version 1.0, legacy support
ehci0 at pci0 dev 2 function 1 "NVIDIA nForce4 USB" rev 0xa4: irq 3
usb0 at ehci0: USB revision 2.0
uhub0 at usb0 "NVIDIA EHCI root hub" rev 2.00/1.00 addr 1
pciide0 at pci0 dev 7 function 0 "NVIDIA nForce4 SATA" rev 0xf3: DMA
pciide0: using irq 10 for native-PCI interrupt
wd0 at pciide0 channel 0 drive 0: <WDC WD800JD-75MSA3>
wd0: 16-sector PIO, LBA48, 76293MB, 156250000 sectors
wd0(pciide0:0:0): using PIO mode 4, Ultra-DMA mode 5
wd1 at pciide0 channel 1 drive 0: <WDC WD800JD-75MSA3>
wd1: 16-sector PIO, LBA48, 76293MB, 156250000 sectors
wd1(pciide0:1:0): using PIO mode 4, Ultra-DMA mode 5
pciide1 at pci0 dev 8 function 0 "NVIDIA nForce4 SATA" rev 0xf3: DMA
pciide1: using irq 11 for native-PCI interrupt
atapiscsi0 at pciide1 channel 0 drive 0
scsibus0 at atapiscsi0: 2 targets, initiator 7
cd0 at scsibus0 targ 0 lun 0: <TSSTcorp, CDRWDVD TS-H493B, D200> ATAPI
5/cdrom removable
cd0(pciide1:0:0): using PIO mode 4, Ultra-DMA mode 5
ppb0 at pci0 dev 9 function 0 "NVIDIA nForce4 PCI-PCI" rev 0xf2
pci1 at ppb0 bus 1
vga1 at pci1 dev 8 function 0 "ATI ES1000" rev 0x02
wsdisplay0 at vga1 mux 1: console (80x25, vt100 emulation)
wsdisplay0: screen 1-5 added (80x25, vt100 emulation)
radeondrm0 at vga1
ppb1 at pci0 dev 11 function 0 "NVIDIA nForce4 PCIE" rev 0xf3
pci2 at ppb1 bus 2
bge0 at pci2 dev 0 function 0 "Broadcom BCM5722" rev 0x00, BCM5755 C0
(0xa200): irq 12, address 00:1d:09:
brgphy0 at bge0 phy 1: BCM5722 10/100/1000baseT PHY, rev. 0
ppb2 at pci0 dev 12 function 0 "NVIDIA nForce4 PCIE" rev 0xf3
pci3 at ppb2 bus 3
ppb3 at pci0 dev 13 function 0 "NVIDIA nForce4 PCIE" rev 0xf3
pci4 at ppb3 bus 4
ppb4 at pci0 dev 14 function 0 "NVIDIA nForce4 PCIE" rev 0xa3
pci5 at ppb4 bus 5
ppb5 at pci5 dev 0 function 0 "IDT 89HPES12N3A" rev 0x04
pci6 at ppb5 bus 6
ppb6 at pci6 dev 0 function 0 "IDT 89HPES12N3A" rev 0x04
pci7 at ppb6 bus 7
em0 at pci7 dev 0 function 0 "Intel PRO/1000 QP (82571EB)" rev 0x06: irq
10, address 00:15:17:
em1 at pci7 dev 0 function 1 "Intel PRO/1000 QP (82571EB)" rev 0x06: irq
10, address 00:15:17:
ppb7 at pci6 dev 1 function 0 "IDT 89HPES12N3A" rev 0x04
pci8 at ppb7 bus 8
em2 at pci8 dev 0 function 0 "Intel PRO/1000 QP (82571EB)" rev 0x06: irq
10, address 00:15:17:
em3 at pci8 dev 0 function 1 "Intel PRO/1000 QP (82571EB)" rev 0x06: irq
10, address 00:15:17:
pchb0 at pci0 dev 24 function 0 "AMD AMD64 0Fh HyperTransport" rev 0x00
pchb1 at pci0 dev 24 function 1 "AMD AMD64 0Fh Address Map" rev 0x00
pchb2 at pci0 dev 24 function 2 "AMD AMD64 0Fh DRAM Cfg" rev 0x00
kate0 at pci0 dev 24 function 3 "AMD AMD64 0Fh Misc Cfg" rev 0x00: core
rev JH-F3
isa0 at pcib0
isadma0 at isa0
com0 at isa0 port 0x3f8/8 irq 4: ns16550a, 16 byte fifo
pckbc0 at isa0 port 0x60/5
pckbd0 at pckbc0 (kbd slot)
pckbc0: using irq 1 for kbd slot
wskbd0 at pckbd0: console keyboard, using wsdisplay0
pcppi0 at isa0 port 0x61
midi0 at pcppi0: <PC speaker>
spkr0 at pcppi0
usb1 at ohci0: USB revision 1.0
uhub1 at usb1 "NVIDIA OHCI root hub" rev 1.00/1.00 addr 1
mtrr: Pentium Pro MTRR support
softraid0 at root
root on wd0a swap on wd0b dump on wd0b