Skip to content

Commit

Permalink
Enable AXEN_RXCTL_START bit only when RX is ready. Otherwise,
Browse files Browse the repository at this point in the history
the adapter eventually falls into "no carrier" state while it
is not running.
  • Loading branch information
rokuyama committed Jan 31, 2019
1 parent 938a368 commit 4603809
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions sys/dev/usb/if_axen.c
@@ -1,4 +1,4 @@
/* $NetBSD: if_axen.c,v 1.20 2019/01/31 15:21:05 rin Exp $ */
/* $NetBSD: if_axen.c,v 1.21 2019/01/31 15:22:56 rin Exp $ */
/* $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */

/*
Expand All @@ -23,7 +23,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.20 2019/01/31 15:21:05 rin Exp $");
__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.21 2019/01/31 15:22:56 rin Exp $");

#ifdef _KERNEL_OPT
#include "opt_inet.h"
Expand Down Expand Up @@ -571,7 +571,6 @@ axen_ax88179_init(struct axen_softc *sc)
/* Set RX control register */
ctl = AXEN_RXCTL_IPE | AXEN_RXCTL_DROPCRCERR | AXEN_RXCTL_AUTOB;
ctl |= AXEN_RXCTL_ACPT_PHY_MCAST | AXEN_RXCTL_ACPT_ALL_MCAST;
ctl |= AXEN_RXCTL_START;
wval = htole16(ctl);
axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval);

Expand Down Expand Up @@ -1535,9 +1534,19 @@ axen_stop(struct ifnet *ifp, int disable)
struct axen_softc *sc = ifp->if_softc;
usbd_status err;
int i;
uint16_t rxmode, wval;

axen_reset(sc);

/* Disable receiver, set RX mode */
axen_lock_mii(sc);
axen_cmd(sc, AXEN_CMD_MAC_READ2, 2, AXEN_MAC_RXCTL, &wval);
rxmode = le16toh(wval);
rxmode &= ~AXEN_RXCTL_START;
wval = htole16(rxmode);
axen_cmd(sc, AXEN_CMD_MAC_WRITE2, 2, AXEN_MAC_RXCTL, &wval);
axen_unlock_mii(sc);

ifp->if_timer = 0;
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);

Expand Down

0 comments on commit 4603809

Please sign in to comment.