diff options
author | David Leonard <d@cvs.openbsd.org> | 1999-06-23 04:48:50 +0000 |
---|---|---|
committer | David Leonard <d@cvs.openbsd.org> | 1999-06-23 04:48:50 +0000 |
commit | 6b2d6c17377685009e0e10a5cfd2934d12028581 (patch) | |
tree | 3b2a770f3a736e02b87c54c0865a07a035a911e7 /sys/dev | |
parent | 38983a68dbb1c4de00206eea9fb1e605be253a31 (diff) |
attempt at repairing rl2_transmit (still broken); cleanup; spelling
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/rl2.c | 63 | ||||
-rw-r--r-- | sys/dev/ic/rl2subr.c | 42 | ||||
-rw-r--r-- | sys/dev/ic/rl2var.h | 32 | ||||
-rw-r--r-- | sys/dev/pcmcia/if_rl2_pcmcia.c | 16 |
4 files changed, 82 insertions, 71 deletions
diff --git a/sys/dev/ic/rl2.c b/sys/dev/ic/rl2.c index 3ec601655ff..3c6c78f9abe 100644 --- a/sys/dev/ic/rl2.c +++ b/sys/dev/ic/rl2.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rl2.c,v 1.1 1999/06/21 23:21:46 d Exp $ */ +/* $OpenBSD: rl2.c,v 1.2 1999/06/23 04:48:48 d Exp $ */ /* * David Leonard <d@openbsd.org>, 1999. Public Domain. * @@ -82,7 +82,6 @@ static int rl2_standby __P((struct rl2_softc *)); #endif /* Back-end attach and configure. */ - void rl2config(sc) struct rl2_softc * sc; @@ -97,7 +96,7 @@ rl2config(sc) sc->sc_cardtype |= sc->sc_dev.dv_cfdata->cf_flags; /* Initialise values in the soft state. */ - sc->sc_pktseq = 0; + sc->sc_pktseq = 0; /* rl2_newseq() */ sc->sc_txseq = 0; sc->sc_promisc = 0; @@ -162,7 +161,6 @@ rl2config(sc) } /* Bring device up. */ - static void rl2init(sc) struct rl2_softc * sc; @@ -215,10 +213,7 @@ rl2init(sc) return; } -/* - * Start outputting on interface. - * This is always called at splnet(). - */ +/* Start outputting on interface. This is always called at splnet(). */ static void rl2start(ifp) struct ifnet * ifp; @@ -267,7 +262,7 @@ rl2start(ifp) #define PACKETMIN (sizeof (struct ether_header) + ETHERMIN) #define PACKETMAX (sizeof (struct ether_header) + ETHERMTU + 4) - /* Packet size has to be an even number between 60 and 1518 bytes. */ + /* Packet size has to be an even number between 60 and 1518 octets. */ pad = len & 1; if (len + pad < PACKETMIN) pad = PACKETMIN - len; @@ -307,35 +302,40 @@ rl2_transmit(sc, m0, len, pad) int pad; { struct mbuf * m; - int zfirst = !(mtod(m0, u_int8_t*)[0]&1); + int zfirst; int actlen; int tlen = len + pad; struct rl2_msg_tx_state state; static u_int8_t zeroes[60]; - struct rl2_mm_sendpacket cmd = { - RL2_MM_SENDPACKET, + struct rl2_mm_sendpacket cmd = { RL2_MM_SENDPACKET }; + + /* Does the packet start with a zero bit? */ + zfirst = ((*mtod(m0, u_int8_t *) & 1) == 0); + + cmd.mode = RL2_MM_SENDPACKET_MODE_BIT7 | (zfirst ? RL2_MM_SENDPACKET_MODE_ZFIRST : 0) | - (1 ? RL2_MM_SENDPACKET_MODE_QFSK : 0), /* sc->qfsk? */ - 0x70, /* txpower */ - htons(4 + tlen) & 0xff, - (htons(4 + tlen) >> 8) & 0xff, - 0, - 0, - sc->sc_txseq++, - 0 - }; - -#ifdef DIAGNOSTIC - if (sizeof cmd != 12) - panic("rl2_transmit"); -#endif + (0 ? RL2_MM_SENDPACKET_MODE_QFSK : 0), /* sc->qfsk? */ + cmd.power = 0x70; /* 0x70 or 0xf0 */ + cmd.length_lo = htons(4 + tlen) & 0xff; + cmd.length_hi = (htons(4 + tlen) >> 8) & 0xff; + cmd.xxx1 = 0; + cmd.xxx2 = 0; + cmd.xxx3 = 0; + + /* A unique packet-level sequence number. XXX related to sc_seq? */ + cmd.sequence = sc->sc_txseq; + sc->sc_txseq++; + if (sc->sc_txseq > 0x7c) + sc->sc_txseq = 0; dprintf(" T[%d+%d", len, pad); if (rl2_msg_tx_start(sc, &cmd, sizeof cmd + tlen, &state)) goto error; + cmd.mm_cmd.cmd_seq = rl2_newseq(sc); + #ifdef RL2DUMP printf("%s: send %c%d seq %d data ", sc->sc_dev.dv_xname, cmd.mm_cmd.cmd_letter, cmd.mm_cmd.cmd_fn, cmd.mm_cmd.cmd_seq); @@ -564,6 +564,7 @@ rl2read(sc, hdr, len) sc->sc_dev.dv_xname); } #endif + /* XXX Jean's driver dealt with RFC893 trailers here */ eh = mtod(m, struct ether_header *); #if NBPFILTER > 0 if (ifp->if_bpf) @@ -593,8 +594,8 @@ rl2read(sc, hdr, len) switch (RL2_MM_CMD(hdr->cmd_letter, hdr->cmd_fn)) { case RL2_MM_CMD('b', 0): /* b0: Transmit done. */ #ifdef DIAGNOSTIC - if (len != 4) - printf("%s: 'b0' len %d != 4\n", + if (len != 7) + printf("%s: 'b0' len %d != 7\n", sc->sc_dev.dv_xname, len); #endif ifp->if_flags &= ~IFF_OACTIVE; @@ -668,7 +669,7 @@ rl2get(sc, hdr, totlen) int len; struct mbuf *m, **mp, *top; struct rl2_pdata pd = RL2_PDATA_INIT; - /* u_int8_t hwhdr[ETHER_ADDR_LEN * 2]; */ + u_int8_t hwhdr[20]; dprintf(" [get]"); @@ -687,7 +688,6 @@ rl2get(sc, hdr, totlen) } #endif -#if 0 totlen -= sizeof hwhdr; /* Skip the hardware header. */ rl2_rx_pdata(sc, hwhdr, sizeof hwhdr, &pd); @@ -695,7 +695,6 @@ rl2get(sc, hdr, totlen) RL2DUMPHEX(hwhdr, sizeof hwhdr); printf("/"); #endif -#endif /* (Most of the following code fleeced from elink3.c.) */ MGETHDR(m, M_DONTWAIT, MT_DATA); @@ -980,7 +979,7 @@ rl2_roamconfig(sc) if (rl2_msg_txrx(sc, &roam, sizeof roam, &response, sizeof response)) return (-1); - + return (0); } diff --git a/sys/dev/ic/rl2subr.c b/sys/dev/ic/rl2subr.c index 1c13098cf4b..38c5c43f5ee 100644 --- a/sys/dev/ic/rl2subr.c +++ b/sys/dev/ic/rl2subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rl2subr.c,v 1.1 1999/06/21 23:21:47 d Exp $ */ +/* $OpenBSD: rl2subr.c,v 1.2 1999/06/23 04:48:49 d Exp $ */ /* * David Leonard <d@openbsd.org>, 1999. Public Domain. * @@ -375,12 +375,12 @@ rl2_rx_request(sc, timeo) if (sc->sc_width == 16) { if (status != 0x10) goto badstatus_quiet; - /* Read 2 bytes. */ + /* Read 2 octets. */ len = rl2_data_read_2(sc); } else if (sc->sc_width == 8) { if (status != 0x60) goto badstatus_quiet; - /* Read low byte. */ + /* Read low octet. */ lo = rl2_data_read_1(sc); rl2_status_rx_write(sc, 0x70); rl2_status_rx_int(sc); @@ -394,7 +394,7 @@ rl2_rx_request(sc, timeo) splx(s); if (status != 0x10) goto badstatus; - /* Read high byte. */ + /* Read high octet. */ hi = rl2_data_read_1(sc); len = lo | (hi << 8); } @@ -405,9 +405,9 @@ rl2_rx_request(sc, timeo) dprintf(" len=%d]", len); return (len); - + badstatus: - printf("%s: rx_request tiemd out, status %02x\n", + printf("%s: rx_request timed out, status %02x\n", sc->sc_dev.dv_xname, status); badstatus_quiet: if (status == 0x50) @@ -442,7 +442,7 @@ rl2_rx_pdata(sc, buf, len, pd) dprinthex(data, len); #endif if (len & 1) { - /* Read the last byte plus a bit extra. */ + /* Read the last octet plus a bit extra. */ union { u_int16_t w; u_int8_t b[2]; @@ -652,6 +652,22 @@ rl2_msg_tx_end(sc, state) return (ret); } +/* Return the next unique sequence number to use for a transmitted command */ +u_int8_t +rl2_newseq(sc) + struct rl2_softc * sc; +{ + int s; + u_int8_t seq; + + s = splhigh(); + seq = sc->sc_pktseq++; + if (sc->sc_pktseq > 0x7c) + sc->sc_pktseq = 0; + splx(s); + return (seq); +} + /* * Transmit a command message to, and (optionally) receive a response * message from the card. Each transmitted message has a sequence @@ -674,19 +690,13 @@ rl2_msg_txrx(sc, tx, txlen, rx, rxlen) struct rl2_msg_tx_state state; int ien; int ret; - int s; #ifdef DIAGNOSTIC if (rx != NULL && rxlen < sizeof *rxc) panic("rl2_msg_txrx"); #endif - /* Each message has a unique sequence number. */ - s = splhigh(); - txc->cmd_seq = sc->sc_pktseq++; - if (sc->sc_pktseq > 0x7c) - sc->sc_pktseq = 0; - splx(s); + txc->cmd_seq = rl2_newseq(sc); #ifdef RL2DUMP printf("%s: send %c%d seq %d data ", sc->sc_dev.dv_xname, @@ -709,7 +719,7 @@ rl2_msg_txrx(sc, tx, txlen, rx, rxlen) return (ret); } - /* Always send an even number of bytes. */ + /* Always send an even number of octets. */ rl2_msg_tx_data(sc, tx, (txlen + 1) & ~1, &state); /* End the transmission. */ @@ -884,7 +894,7 @@ rl2_mbox_lock(sc, seq, bufp, lenp) return (0); } -/* Unlock a mailbox and inform the waiter of the actual number of bytes. */ +/* Unlock a mailbox and inform the waiter of the actual number of octets. */ void rl2_mbox_unlock(sc, seq, actlen) struct rl2_softc * sc; diff --git a/sys/dev/ic/rl2var.h b/sys/dev/ic/rl2var.h index 92143c1af9c..6dd3cfd4d47 100644 --- a/sys/dev/ic/rl2var.h +++ b/sys/dev/ic/rl2var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rl2var.h,v 1.1 1999/06/21 23:21:47 d Exp $ */ +/* $OpenBSD: rl2var.h,v 1.2 1999/06/23 04:48:49 d Exp $ */ /* * David Leonard <d@openbsd.org>, 1999. Public domain. * @@ -58,8 +58,8 @@ struct rl2_softc { /* Structure used to hold partial read state for rl2_rx_pdata() */ struct rl2_pdata { - u_int8_t p_data; /* extra bytes read but not consumed */ - int p_nremain; /* number of bytes not consumed */ + u_int8_t p_data; /* extra data read but not consumed */ + int p_nremain; /* size of unconsumed data */ }; #define RL2_PDATA_INIT {0,0} @@ -78,22 +78,24 @@ struct rl2_mm_cmd; /* fwd decl */ void rl2config __P((struct rl2_softc *)); int rl2intr __P((void *)); void rl2read __P((struct rl2_softc *, struct rl2_mm_cmd *, int)); -int rl2_enable __P((struct rl2_softc *, int)); -int rl2_reset __P((struct rl2_softc *)); -u_int8_t rl2_wakeup __P((struct rl2_softc *, u_int8_t)); -int rl2_rx_request __P((struct rl2_softc *, int)); -int rl2_rx_data __P((struct rl2_softc *, void *, int)); -void rl2_rx_pdata __P((struct rl2_softc *, void *, int, +int rl2_enable __P((struct rl2_softc *, int)); +int rl2_reset __P((struct rl2_softc *)); +u_int8_t rl2_wakeup __P((struct rl2_softc *, u_int8_t)); +int rl2_rx_request __P((struct rl2_softc *, int)); +int rl2_rx_data __P((struct rl2_softc *, void *, int)); +void rl2_rx_pdata __P((struct rl2_softc *, void *, int, struct rl2_pdata *)); -void rl2_rx_end __P((struct rl2_softc *)); -void rl2_clear_nak __P((struct rl2_softc *)); +void rl2_rx_end __P((struct rl2_softc *)); +void rl2_clear_nak __P((struct rl2_softc *)); +u_int8_t rl2_newseq __P((struct rl2_softc *)); + void rl2_msg_tx_data __P((struct rl2_softc *, void *, u_int16_t, struct rl2_msg_tx_state *)); -int rl2_msg_tx_start __P((struct rl2_softc *, void *, int, +int rl2_msg_tx_start __P((struct rl2_softc *, void *, int, struct rl2_msg_tx_state *)); -int rl2_msg_tx_end __P((struct rl2_softc *, +int rl2_msg_tx_end __P((struct rl2_softc *, struct rl2_msg_tx_state *)); -int rl2_msg_txrx __P((struct rl2_softc *, void *, int, +int rl2_msg_txrx __P((struct rl2_softc *, void *, int, void *, int)); int rl2_mbox_create __P((struct rl2_softc *, u_int8_t, void *, @@ -123,7 +125,7 @@ void rl2_mbox_unlock __P((struct rl2_softc *, u_int8_t, size_t)); #define dprinthex(buf, len) /* nothing */ #endif -/* debug messages to/from card. prints 4-byte groups separated by commas */ +/* debug messages to/from card. prints 4-octet groups separated by commas */ #define RL2DUMP #define RL2DUMPHEX(buf, buflen) do { \ int _i; \ diff --git a/sys/dev/pcmcia/if_rl2_pcmcia.c b/sys/dev/pcmcia/if_rl2_pcmcia.c index 0950e304cea..16143a80028 100644 --- a/sys/dev/pcmcia/if_rl2_pcmcia.c +++ b/sys/dev/pcmcia/if_rl2_pcmcia.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_rl2_pcmcia.c,v 1.1 1999/06/21 23:21:45 d Exp $ */ +/* $OpenBSD: if_rl2_pcmcia.c,v 1.2 1999/06/23 04:48:49 d Exp $ */ /* * David Leonard <d@openbsd.org>, 1999. Public domain. * @@ -83,7 +83,7 @@ rl2_pcmcia_product_lookup(pa) { struct rl2_pcmcia_product *rpp; - for (rpp = rl2_pcmcia_products; rpp->manufacturer && rpp->product; + for (rpp = rl2_pcmcia_products; rpp->manufacturer && rpp->product; rpp++) if (pa->manufacturer == rpp->manufacturer && pa->product == rpp->product) @@ -102,7 +102,7 @@ rl2_pcmcia_match(parent, match, aux) int i; for (i = 0; i < 4; i++) - if (cis1_info[i] && + if (cis1_info[i] && strcmp(cis1_info[i], pa->card->cis1_info[i]) != 0) return (0); @@ -126,7 +126,7 @@ rl2_pcmcia_attach(parent, self, aux) int i; static bus_addr_t iobases[] = { 0x270, /* useful in user-space debugging */ - 0x100, 0x120, 0x140, 0x218, 0x270, 0x280, 0x290, 0x298, + 0x100, 0x120, 0x140, 0x218, 0x270, 0x280, 0x290, 0x298, 0x2a0, 0x2a8, 0x2e0, 0x300, 0x310, 0x358, 0x360, 0x368, 0 }; @@ -164,12 +164,12 @@ rl2_pcmcia_attach(parent, self, aux) #ifdef RL2DEBUG /* Try only those ports from the manual */ for (i=0; iobases[i] != 0; i++) - if (pcmcia_io_alloc(psc->sc_pf, iobases[i], RL2_NPORTS, + if (pcmcia_io_alloc(psc->sc_pf, iobases[i], RL2_NPORTS, RL2_NPORTS, &psc->sc_pcioh) == 0) break; if (iobases[i] == 0) { #else - if (pcmcia_io_alloc(psc->sc_pf, 0, RL2_NPORTS, + if (pcmcia_io_alloc(psc->sc_pf, 0, RL2_NPORTS, RL2_NPORTS, &psc->sc_pcioh)) { #endif printf(": can't alloc i/o space\n"); @@ -265,7 +265,7 @@ rl2_pcmcia_enable(sc) struct pcmcia_function *pf = psc->sc_pf; /* Establish the interrupt */ - sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, + sc->sc_ih = pcmcia_intr_establish(psc->sc_pf, IPL_NET, rl2intr_pcmcia, sc); if (sc->sc_ih == NULL) { printf("%s: couldn't establish interrupt\n", @@ -281,7 +281,7 @@ rl2_pcmcia_disable(sc) struct rl2_softc *sc; { struct rl2_pcmcia_softc *psc = (struct rl2_pcmcia_softc *) sc; - + pcmcia_function_disable(psc->sc_pf); pcmcia_intr_disestablish(psc->sc_pf, sc->sc_ih); } |