Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/bluetooth Conform to the spec. with regards to ackno...



details:   https://anonhg.NetBSD.org/src/rev/cf12160d0eba
branches:  trunk
changeset: 355782:cf12160d0eba
user:      nat <nat%NetBSD.org@localhost>
date:      Mon Aug 14 05:33:30 2017 +0000

description:
Conform to the spec. with regards to acknowlegment packets.  This prevents
the host controller from freezing.

Inmprove communication from inactive to active state.

diffstat:

 sys/dev/bluetooth/bth5.c |  27 ++++++++++++++++++---------
 1 files changed, 18 insertions(+), 9 deletions(-)

diffs (84 lines):

diff -r 6ecd37ef9906 -r cf12160d0eba sys/dev/bluetooth/bth5.c
--- a/sys/dev/bluetooth/bth5.c  Mon Aug 14 05:29:02 2017 +0000
+++ b/sys/dev/bluetooth/bth5.c  Mon Aug 14 05:33:30 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bth5.c,v 1.2 2017/08/11 00:58:37 nat Exp $     */
+/*     $NetBSD: bth5.c,v 1.3 2017/08/14 05:33:30 nat Exp $     */
 /*
  * Copyright (c) 2017 Nathanial Sloss <nathanialsloss%yahoo.com.au@localhost>
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.2 2017/08/11 00:58:37 nat Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bth5.c,v 1.3 2017/08/14 05:33:30 nat Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1076,13 +1076,14 @@
 bth5_sequencing_receive(struct bth5_softc *sc, struct mbuf *m)
 {
        bth5_hdr_t hdr;
-       uint32_t rxseq;
+       uint32_t exp_rxseq, rxseq;
 
+       exp_rxseq = sc->sc_seq_expected_rxseq & BTH5_FLAGS_SEQ_MASK;
        m_copydata(m, 0, sizeof(bth5_hdr_t), &hdr);
        rxseq = BTH5_FLAGS_SEQ(hdr.flags);
 
        DPRINTFN(1, ("%s: seq receive: rxseq=%d, expected %d\n",
-           device_xname(sc->sc_dev), rxseq, sc->sc_seq_expected_rxseq));
+           device_xname(sc->sc_dev), rxseq, exp_rxseq));
 #ifdef BTH5_DEBUG
        if (bth5_debug == 2)
                bth5_packet_print(m);
@@ -1094,9 +1095,10 @@
         */
        m_adj(m, sizeof(bth5_hdr_t) - sizeof(uint8_t));
 
-       if (rxseq != sc->sc_seq_expected_rxseq) {
+       if (rxseq != exp_rxseq) {
                m_freem(m);
 
+               bth5_send_ack_command(sc);
                /* send ack packet, if needly */
                bth5_mux_transmit(sc);
 
@@ -1144,10 +1146,15 @@
                break;
        }
 
+       if (sc->sc_seq_expected_rxseq / sc->sc_seq_winsize  ==
+                                        sc->sc_seq_winsize) {
+               bth5_send_ack_command(sc);
+               sc->sc_seq_txack = sc->sc_seq_expected_rxseq;
+       } else
+               sc->sc_seq_txack = rxseq;
+
        sc->sc_seq_expected_rxseq =
-           (sc->sc_seq_expected_rxseq + 1) & BTH5_FLAGS_SEQ_MASK;
-       sc->sc_seq_txack = sc->sc_seq_expected_rxseq;
-       bth5_send_ack_command(sc);
+           (sc->sc_seq_expected_rxseq + 1);
 }
 
 static bool
@@ -1539,7 +1546,7 @@
                } else if (*rcvpkt == *(const uint16_t *)syncresp) {
                        DPRINTF(("%s: state change to curious\n",
                            device_xname(sc->sc_dev)));
-
+                       rplypkt = conf;
                        callout_schedule(&sc->sc_le_timer,
                            BTH5_LE_TCONF_TIMEOUT);
                        sc->sc_le_state = le_state_curious;
@@ -1551,6 +1558,8 @@
        case le_state_curious:
                if (*rcvpkt == *(const uint16_t *)sync)
                        rplypkt = syncresp;
+               else if (*rcvpkt == *(const uint16_t *)syncresp)
+                       rplypkt = conf;
                else if (*rcvpkt == *(const uint16_t *)conf)
                        rplypkt = confresp;
                else if (*rcvpkt == *(const uint16_t *)confresp) {



Home | Main Index | Thread Index | Old Index