Page MenuHomeFreeBSD

D35656.id107807.diff
No OneTemporary

D35656.id107807.diff

Index: sys/dev/etherswitch/e6000sw/e6000sw.c
===================================================================
--- sys/dev/etherswitch/e6000sw/e6000sw.c
+++ sys/dev/etherswitch/e6000sw/e6000sw.c
@@ -120,6 +120,8 @@
static int e6000sw_getport(device_t, etherswitch_port_t *);
static int e6000sw_setport(device_t, etherswitch_port_t *);
static int e6000sw_set_vlan_mode(e6000sw_softc_t *, uint32_t);
+static int e6000sw_readphy_locked(device_t, int, int);
+static int e6000sw_writephy_locked(device_t, int, int, int);
static int e6000sw_readreg_wrapper(device_t, int);
static int e6000sw_writereg_wrapper(device_t, int, int);
static int e6000sw_getvgroup_wrapper(device_t, etherswitch_vlangroup_t *);
@@ -170,10 +172,10 @@
DEVMETHOD(etherswitch_unlock, e6000sw_unlock),
DEVMETHOD(etherswitch_getport, e6000sw_getport),
DEVMETHOD(etherswitch_setport, e6000sw_setport),
- DEVMETHOD(etherswitch_readreg, e6000sw_readreg_wrapper),
- DEVMETHOD(etherswitch_writereg, e6000sw_writereg_wrapper),
- DEVMETHOD(etherswitch_readphyreg, e6000sw_readphy),
- DEVMETHOD(etherswitch_writephyreg, e6000sw_writephy),
+ DEVMETHOD(etherswitch_readreg, e6000sw_readphy_locked),
+ DEVMETHOD(etherswitch_writereg, e6000sw_writephy_locked),
+ DEVMETHOD(etherswitch_readphyreg, e6000sw_readphy_wrapper),
+ DEVMETHOD(etherswitch_writephyreg, e6000sw_writephy_wrapper),
DEVMETHOD(etherswitch_setvgroup, e6000sw_setvgroup_wrapper),
DEVMETHOD(etherswitch_getvgroup, e6000sw_getvgroup_wrapper),
@@ -657,6 +659,21 @@
return (0);
}
+static int e6000sw_readphy_locked(device_t dev, int phy, int reg)
+{
+ e6000sw_softc_t *sc;
+ int ret;
+
+ sc = device_get_softc(dev);
+ E6000SW_LOCK_ASSERT(sc, SA_UNLOCKED);
+
+ E6000SW_LOCK(sc);
+ ret = e6000sw_readphy(dev, phy, reg);
+ E6000SW_UNLOCK(sc);
+
+ return (ret);
+}
+
/*
* PHY registers are paged. Put page index in reg 22 (accessible from every
* page), then access specific register.
@@ -668,18 +685,15 @@
uint32_t val;
sc = device_get_softc(dev);
- E6000SW_LOCK_ASSERT(sc, SA_UNLOCKED);
+ E6000SW_LOCK_ASSERT(sc, SA_XLOCKED);
if (!e6000sw_is_phyport(sc, phy) || reg >= E6000SW_NUM_PHY_REGS) {
device_printf(dev, "Wrong register address.\n");
return (EINVAL);
}
- E6000SW_LOCK(sc);
-
if (E6000SW_WAITREADY2(sc, SMI_PHY_CMD_REG, SMI_CMD_BUSY)) {
device_printf(dev, "Timeout while waiting for switch\n");
- E6000SW_UNLOCK(sc);
return (ETIMEDOUT);
}
@@ -688,15 +702,27 @@
((phy << SMI_CMD_DEV_ADDR) & SMI_CMD_DEV_ADDR_MASK));
if (E6000SW_WAITREADY2(sc, SMI_PHY_CMD_REG, SMI_CMD_BUSY)) {
device_printf(dev, "Timeout while waiting for switch\n");
- E6000SW_UNLOCK(sc);
return (ETIMEDOUT);
}
val = e6000sw_readreg(sc, REG_GLOBAL2, SMI_PHY_DATA_REG);
+ return (val & PHY_DATA_MASK);
+}
+
+static int e6000sw_writephy_locked(device_t dev, int phy, int reg, int data)
+{
+ e6000sw_softc_t *sc;
+ int ret;
+
+ sc = device_get_softc(dev);
+ E6000SW_LOCK_ASSERT(sc, SA_UNLOCKED);
+
+ E6000SW_LOCK(sc);
+ ret = e6000sw_writephy(dev, phy, reg, data);
E6000SW_UNLOCK(sc);
- return (val & PHY_DATA_MASK);
+ return (ret);
}
static int
@@ -705,18 +731,15 @@
e6000sw_softc_t *sc;
sc = device_get_softc(dev);
- E6000SW_LOCK_ASSERT(sc, SA_UNLOCKED);
+ E6000SW_LOCK_ASSERT(sc, SA_XLOCKED);
if (!e6000sw_is_phyport(sc, phy) || reg >= E6000SW_NUM_PHY_REGS) {
device_printf(dev, "Wrong register address.\n");
return (EINVAL);
}
- E6000SW_LOCK(sc);
-
if (E6000SW_WAITREADY2(sc, SMI_PHY_CMD_REG, SMI_CMD_BUSY)) {
device_printf(dev, "Timeout while waiting for switch\n");
- E6000SW_UNLOCK(sc);
return (ETIMEDOUT);
}
@@ -726,8 +749,6 @@
SMI_CMD_OP_C22_WRITE | (reg & SMI_CMD_REG_ADDR_MASK) |
((phy << SMI_CMD_DEV_ADDR) & SMI_CMD_DEV_ADDR_MASK));
- E6000SW_UNLOCK(sc);
-
return (0);
}

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 18, 12:06 AM (8 h, 44 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25462552
Default Alt Text
D35656.id107807.diff (3 KB)

Event Timeline