|
From: Peter K. <pk...@us...> - 2001-09-18 12:11:20
|
The following files were modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bcsp.c 1.19 1.20=20=20=20=20=20=20=20=20=20=20=20=20
bcsp_slip.c 1.6 1.7=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Made bcsp_slip_receive() call bcsp_integrity_receive() instead of
having bcsp_receive_lower() do it.
* Moved bcsp_dbg() to bcsp_slip.c and renamed it to slip_debug().
Previously there was a chance of it displaying incorrect seq and
ack values for outgoing packets (as it used the slip encoded values).
The diff of the modified file(s):
--- bcsp.c 2001/09/07 12:53:24 1.19
+++ bcsp.c 2001/09/18 12:10:49 1.20
@@ -56,7 +56,6 @@
#include <linux/bluetooth/btcommon.h>
#include <linux/bluetooth/bluetooth.h>
#include <linux/bluetooth/hci.h>
-#include <linux/bluetooth/btmem.h>
#include <linux/bluetooth/bcsp.h>
#include <linux/bluetooth/bcsp_debug.h>
#else
@@ -68,7 +67,6 @@
#include "btcommon.h"
#include "bluetooth.h"
#include "hci.h"
-#include "btmem.h"
#include "bcsp.h"
#include "bcsp_debug.h"
#endif
@@ -235,56 +233,18 @@
return 0;
}
=20
-#if BCSP_PARSELOWER
-
-/*
- * Used to parse headers of sent/incoming BCSP packets
- * Also prints other potentially interesting stats=20
- */
-
-void
-bcsp_dbg(const u8 *str, u8 flags, u32 tot_len)
-{
-#include <linux/bluetooth/hci_internal.h>
- extern hci_controller hci_ctrl;
- extern u8 winspace;
- extern u8 txseq;
- extern u8 txack;
- extern u8 rxack;
- extern u8 expected_rxseq;
-
- printk("%s | seq:%d | ack:%d | winsize:%d | acl:%d | bufc:%d [%d]\n",
- str, (flags&BCSP_FLAG_SEQ),=20
- (flags&BCSP_FLAG_ACK) >> 3,=20
- winspace, hci_ctrl.hc_buf.acl_num, buf_byte_count(-1), tot_len);
-
- printk("status: txseq[%d] txack[%d] cur_rxack[%d] exp_rxseq[%d]\n\n",=20
- txseq, txack, rxack, expected_rxseq);
-}
-#endif
-
s32
bcsp_receive_lower(u8 *data, u32 len)
{
s32 handled =3D 0;
- struct bcsp bcsp;
=20
D(__FUNCTION__ ": Incoming data:\n");
=20
BCSPDUMP(data, len);
=20
while (handled < len) {
- bcsp_init_packet(&bcsp);
- handled +=3D bcsp_slip_receive(&bcsp, data + handled,=20
- len - handled);
+ handled +=3D bcsp_slip_receive(data + handled, len - handled);
D(__FUNCTION__ ": So far handled: %d bytes\n", handled);
- if (bcsp.packet) {
-#if BCSP_PARSELOWER
- bcsp_dbg("=3D=3D> ", bcsp.packet[0], bcsp.packet_length);
-#endif
- bcsp_integrity_receive(&bcsp);
- kfree(bcsp.packet);
- }
}
return 0;
}
@@ -325,9 +285,6 @@
=20
BCSPDUMP(data, len);
=20
-#if BCSP_PARSELOWER
- bcsp_dbg("<-- ", data[1], len);
-#endif=20
return bt_write_lower_driver_real(data, len);
}
=20
--- bcsp_slip.c 2001/08/16 13:01:22 1.6
+++ bcsp_slip.c 2001/09/18 12:10:49 1.7
@@ -46,6 +46,8 @@
#ifdef __KERNEL__
#include <linux/malloc.h>
=20
+#include <linux/bluetooth/btcommon.h>
+#include <linux/bluetooth/btmem.h>
#include <linux/bluetooth/bcsp.h>
#include <linux/bluetooth/bcsp_debug.h>
#else
@@ -53,6 +55,7 @@
#include <errno.h>
=20
#include "btcommon.h"
+#include "btmem.h"
#include "bcsp.h"
#include "bcsp_debug.h"
#endif
@@ -73,6 +76,10 @@
=20
static void slip_send_add_byte(struct bcsp* bcsp, u8 data);
=20
+#if BCSP_PARSELOWER
+static void slip_debug(const u8 *str, const struct bcsp *bcsp);
+#endif
+
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
=20
/****************** LOCAL VARIABLE DECLARATION SECTION *******************=
***/
@@ -114,6 +121,10 @@
=20
bcsp->packet[bcsp->packet_length++] =3D 0xC0;
=20
+#if BCSP_PARSELOWER
+ slip_debug("<=3D=3D ", bcsp);
+#endif=20
+
bcsp_write_lower(bcsp->packet, bcsp->packet_length);
kfree(bcsp->packet);
=20
@@ -121,15 +132,18 @@
}
=20
s32
-bcsp_slip_receive(struct bcsp* bcsp, const u8* packet, u32 len)
+bcsp_slip_receive(const u8* packet, u32 len)
{
static u8 buffer[4 + 4096 + 2 + 1];
static s32 length =3D 0;
static s32 skipping =3D TRUE;
+ struct bcsp bcsp;
s32 i =3D 0;
=20
D(__FUNCTION__ "\n");
=20=09
+ bcsp_init_packet(&bcsp);
+=09
if (skipping) {
while (i < len) {
if (packet[i++] =3D=3D 0xC0) {
@@ -139,7 +153,7 @@
}
}
=20
- bcsp->packet =3D NULL;
+ bcsp.packet =3D NULL;
}
=20
for (; i < len && !skipping; i++) {
@@ -149,9 +163,9 @@
if (!length) {
i--;
}
- else if ((bcsp->packet =3D kmalloc(length, GFP_ATOMIC))) {
- memcpy(bcsp->packet, buffer, length);
- bcsp->packet_length =3D length;
+ else if ((bcsp.packet =3D kmalloc(length, GFP_ATOMIC))) {
+ memcpy(bcsp.packet, buffer, length);
+ bcsp.packet_length =3D length;
}
break;
=20
@@ -181,6 +195,14 @@
}
}
=20
+ if (bcsp.packet) {
+#if BCSP_PARSELOWER
+ slip_debug("=3D=3D> ", &bcsp);
+#endif
+ bcsp_integrity_receive(&bcsp);
+ kfree(bcsp.packet);
+ }
+
return i;
}
=20
@@ -203,5 +225,34 @@
break;
}
}
+
+#if BCSP_PARSELOWER
+
+/*
+ * Used to parse headers of sent/incoming BCSP packets
+ * Also prints other potentially interesting stats=20
+ */
+
+#include <linux/bluetooth/hci_internal.h>
+
+void
+slip_debug(const u8 *str, const struct bcsp *bcsp)
+{
+ extern hci_controller hci_ctrl;
+ extern u8 winspace;
+ extern u8 txseq;
+ extern u8 txack;
+ extern u8 rxack;
+ extern u8 expected_rxseq;
+
+ printk("%sseq: %ld, ack: %ld, winsize: %d, acl: %d, bufc: %d, length: %d\=
n",
+ str, BCSP_GET_SEQ(bcsp), BCSP_GET_ACK(bcsp), winspace,
+ hci_ctrl.hc_buf.acl_num, buf_byte_count(-1),
+ bcsp->packet_length);
+
+ printk("Status: txseq: %d, txack: %d, cur_rxack: %d, exp_rxseq: %d\n",
+ txseq, txack, rxack, expected_rxseq);
+}
+#endif
=20
/****************** END OF FILE slip.c ***********************************=
***/
|