Page MenuHomeFreeBSD

D59315.id185593.diff
No OneTemporary

D59315.id185593.diff

diff --git a/sys/dev/alc/if_alc.c b/sys/dev/alc/if_alc.c
--- a/sys/dev/alc/if_alc.c
+++ b/sys/dev/alc/if_alc.c
@@ -3936,8 +3936,8 @@
static void
alc_reset(struct alc_softc *sc)
{
- uint32_t pmcfg, reg;
- int i;
+ uint32_t mcfg, pmcfg, reg;
+ int i, step;
pmcfg = 0;
if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) {
@@ -3955,13 +3955,19 @@
}
}
}
- reg = CSR_READ_4(sc, ALC_MASTER_CFG);
- reg |= MASTER_OOB_DIS_OFF | MASTER_RESET;
- CSR_WRITE_4(sc, ALC_MASTER_CFG, reg);
+ mcfg = CSR_READ_4(sc, ALC_MASTER_CFG) | MASTER_OOB_DIS_OFF;
+ CSR_WRITE_4(sc, ALC_MASTER_CFG, mcfg | MASTER_RESET);
+
+ /* The firmware MAC needs time to settle before it can be polled. */
+ step = ALC_RESET_DELAY;
+ if ((sc->alc_flags & ALC_FLAG_MT) != 0) {
+ DELAY(ALC_MT_RESET_SETTLE);
+ step = ALC_MT_RESET_DELAY;
+ }
if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) {
for (i = ALC_RESET_TIMEOUT; i > 0; i--) {
- DELAY(10);
+ DELAY(step);
if (CSR_READ_4(sc, ALC_MBOX_RD0_PROD_IDX) == 0)
break;
}
@@ -3969,7 +3975,7 @@
device_printf(sc->alc_dev, "MAC reset timeout!\n");
}
for (i = ALC_RESET_TIMEOUT; i > 0; i--) {
- DELAY(10);
+ DELAY(step);
if ((CSR_READ_4(sc, ALC_MASTER_CFG) & MASTER_RESET) == 0)
break;
}
@@ -3981,11 +3987,19 @@
if ((reg & (IDLE_STATUS_RXMAC | IDLE_STATUS_TXMAC |
IDLE_STATUS_RXQ | IDLE_STATUS_TXQ)) == 0)
break;
- DELAY(10);
+ DELAY(step);
}
if (i == 0)
device_printf(sc->alc_dev, "reset timeout(0x%08x)!\n", reg);
+ /*
+ * The Mikrotik firmware does not drop the reset request on its own,
+ * and if we just write back the value we would read during reset,
+ * the card never resets successfully.
+ */
+ if ((sc->alc_flags & ALC_FLAG_MT) != 0)
+ CSR_WRITE_4(sc, ALC_MASTER_CFG, mcfg);
+
if ((sc->alc_flags & ALC_FLAG_AR816X_FAMILY) != 0) {
if (AR816X_REV(sc->alc_rev) <= AR816X_REV_A1 &&
(sc->alc_rev & 0x01) != 0) {
@@ -4493,7 +4507,7 @@
alc_stop_mac(struct alc_softc *sc)
{
uint32_t reg;
- int i;
+ int i, step;
alc_stop_queue(sc);
/* Disable Rx/Tx MAC. */
@@ -4502,11 +4516,13 @@
reg &= ~(MAC_CFG_TX_ENB | MAC_CFG_RX_ENB);
CSR_WRITE_4(sc, ALC_MAC_CFG, reg);
}
+ step = ((sc->alc_flags & ALC_FLAG_MT) != 0) ? ALC_MT_RESET_DELAY :
+ ALC_RESET_DELAY;
for (i = ALC_TIMEOUT; i > 0; i--) {
reg = CSR_READ_4(sc, ALC_IDLE_STATUS);
if ((reg & (IDLE_STATUS_RXMAC | IDLE_STATUS_TXMAC)) == 0)
break;
- DELAY(10);
+ DELAY(step);
}
if (i == 0)
device_printf(sc->alc_dev,
@@ -4545,7 +4561,7 @@
alc_stop_queue(struct alc_softc *sc)
{
uint32_t reg;
- int i;
+ int i, step;
/* Disable RxQ. */
reg = CSR_READ_4(sc, ALC_RXQ_CFG);
@@ -4567,11 +4583,13 @@
CSR_WRITE_4(sc, ALC_TXQ_CFG, reg);
}
DELAY(40);
+ step = ((sc->alc_flags & ALC_FLAG_MT) != 0) ? ALC_MT_RESET_DELAY :
+ ALC_RESET_DELAY;
for (i = ALC_TIMEOUT; i > 0; i--) {
reg = CSR_READ_4(sc, ALC_IDLE_STATUS);
if ((reg & (IDLE_STATUS_RXQ | IDLE_STATUS_TXQ)) == 0)
break;
- DELAY(10);
+ DELAY(step);
}
if (i == 0)
device_printf(sc->alc_dev,
diff --git a/sys/dev/alc/if_alcvar.h b/sys/dev/alc/if_alcvar.h
--- a/sys/dev/alc/if_alcvar.h
+++ b/sys/dev/alc/if_alcvar.h
@@ -289,4 +289,9 @@
#define ALC_TIMEOUT 1000
#define ALC_PHY_TIMEOUT 10000
+/* Reset poll interval, in microseconds. The firmware MAC is far slower. */
+#define ALC_RESET_DELAY 10
+#define ALC_MT_RESET_DELAY 1000
+#define ALC_MT_RESET_SETTLE (50 * 1000)
+
#endif /* _IF_ALCVAR_H */

File Metadata

Mime Type
text/plain
Expires
Tue, Sep 29, 1:42 AM (2 h, 55 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39785347
Default Alt Text
D59315.id185593.diff (3 KB)

Event Timeline