diff options
author | 2001-04-16 00:40:40 +0000 | |
---|---|---|
committer | 2001-04-16 00:40:40 +0000 | |
commit | 314131c9f5d2c313744940d5bc6f9ae3a1cee017 (patch) | |
tree | 78aa7acd062857df23e6e47419c936feebc2a7aa | |
parent | Actually permit setting the transmit key in WEP mode; from Kurt Miller. (diff) | |
download | wireguard-openbsd-314131c9f5d2c313744940d5bc6f9ae3a1cee017.tar.xz wireguard-openbsd-314131c9f5d2c313744940d5bc6f9ae3a1cee017.zip |
Avoid resetting the interface when not needed; allows temporary WEP keys
to work. ALso optimize some interactions with the card.
Fixes rest of PR 1754; ok deraadt@
-rw-r--r-- | sys/dev/ic/an.c | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/sys/dev/ic/an.c b/sys/dev/ic/an.c index 2354242c2da..ba7812f8acf 100644 --- a/sys/dev/ic/an.c +++ b/sys/dev/ic/an.c @@ -1,4 +1,4 @@ -/* $OpenBSD: an.c,v 1.13 2001/02/27 06:48:28 tholo Exp $ */ +/* $OpenBSD: an.c,v 1.14 2001/04/16 00:40:40 tholo Exp $ */ /* * Copyright (c) 1997, 1998, 1999 @@ -262,6 +262,7 @@ an_attach(sc) shutdownhook_establish(an_shutdown, sc); + an_reset(sc); an_init(sc); return(0); @@ -503,7 +504,13 @@ an_cmd(sc, cmd, val) int cmd; int val; { - int i; + int i, stat; + + /* make sure previous command completed */ + if (CSR_READ_2(sc, AN_COMMAND) & AN_CMD_BUSY) { + printf("%s: command busy\n", sc->sc_dev.dv_xname); + CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_CLR_STUCK_BUSY); + } CSR_WRITE_2(sc, AN_PARAM0, val); CSR_WRITE_2(sc, AN_PARAM1, 0); @@ -522,30 +529,23 @@ an_cmd(sc, cmd, val) } } } -/* printf("<<cmd %x,%d>>", cmd, i); */ -#if 0 - DELAY(100); - for (i = AN_TIMEOUT; i--; DELAY(100)) { - int s = CSR_READ_2(sc, AN_STATUS); - CSR_READ_2(sc, AN_RESP0); - CSR_READ_2(sc, AN_RESP1); - CSR_READ_2(sc, AN_RESP2); - if ((s & AN_STAT_CMD_CODE) == (cmd & AN_STAT_CMD_CODE)) - break; - } -/*printf("<<resp %d, %x>>", i, s);*/ -#endif - /* Ack the command */ - CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_CMD); + stat = CSR_READ_2(sc, AN_STATUS); + + /* clear stuck command busy if needed */ if (CSR_READ_2(sc, AN_COMMAND) & AN_CMD_BUSY) { -/*printf("busy");*/ CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_CLR_STUCK_BUSY); } + /* Ack the command */ + CSR_WRITE_2(sc, AN_EVENT_ACK, AN_EV_CMD); + if (i <= 0) return(ETIMEDOUT); + if (stat & AN_STAT_CMD_RESULT) + return(EIO); + return(0); } @@ -955,6 +955,7 @@ an_ioctl(ifp, command, data) !(ifp->if_flags & IFF_PROMISC) && sc->an_if_flags & IFF_PROMISC) { an_promisc(sc, 0); + an_reset(sc); } an_init(sc); } else { @@ -1055,8 +1056,6 @@ an_init(sc) if (ifp->if_flags & IFF_RUNNING) an_stop(sc); - an_reset(sc); - sc->an_associated = 0; /* Allocate the TX buffers */ |