|
From: Mattias A. <mat...@us...> - 2001-06-06 14:55:19
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bcsp_sequence.c 1.10 1.11=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* Fixed bug when calculating winspace=20
* Don't use static variables if BCSP_PARSELOWER is defined
* Set rtx timeout to default (250 ms)
* Always reset variables in bcsp_sequence_init()
* Choke all received data until we are syncronized
* Added debug macros aroung some printouts
* Don't turn off interrupts more than necessary
* Added max number of retransmits (default 20)
The diff of the modified file(s):
--- bcsp_sequence.c 2001/05/30 09:47:00 1.10
+++ bcsp_sequence.c 2001/06/06 14:55:18 1.11
@@ -62,7 +62,7 @@
#endif
=20
#define WINSIZE 4
-#define SEQUENCE_TIMEOUT HZ
+#define SEQUENCE_TIMEOUT (HZ/4) /* default 250 ms */
=20
/****************** TYPE DEFINITION SECTION ******************************=
***/
=20
@@ -88,12 +88,20 @@
static struct tq_struct resend_data_task;
static struct tq_struct send_ack_task;
=20
-static u8 txseq =3D 0;
-static u8 txack =3D 0;
-static u8 rxack =3D 0;
-static u8 expected_rxseq =3D 0;
+#if BCSP_PARSELOWER
+u8 txseq;
+u8 txack;
+u8 rxack;
+u8 expected_rxseq;
+u8 winspace;
+#else
+static u8 txseq;
+static u8 txack;
+static u8 rxack;
+static u8 expected_rxseq;
+static u8 winspace;
+#endif
=20
-static u8 winspace =3D WINSIZE;
=20
static u32 got_packet =3D FALSE;
=20
@@ -113,6 +121,12 @@
=20
send_ack_task.routine =3D (void*)send_ack;
send_ack_task.data =3D NULL;
+
+ txseq =3D 0;
+ txack =3D 0;
+ rxack =3D 0;
+ expected_rxseq =3D 0;
+ winspace =3D WINSIZE;
}
=20
void
@@ -124,12 +138,12 @@
s32
bcsp_sequence_receive(struct bcsp *bcsp)
{
- if (!got_packet) {
- got_packet =3D TRUE;
- bcsp_syncronized();
+ if (!bcsp_issyncronized()){=09
+ D(printk("Still not synced\n"));
+ return 0;
}
=20
- printk(__FUNCTION__": txack:%d, expected_rxseq:%d, BCSP_GET_SEQ(bcsp):%d\=
n", txack, expected_rxseq, BCSP_GET_SEQ(bcsp));
+ D(__FUNCTION__": txack:%d, expected_rxseq:%d, BCSP_GET_SEQ(bcsp):%d\n", t=
xack, expected_rxseq, BCSP_GET_SEQ(bcsp));
=20=09
if (expected_rxseq =3D=3D BCSP_GET_SEQ(bcsp)) {
cli();
@@ -137,10 +151,11 @@
expected_rxseq =3D (expected_rxseq + 1) % 8;
sti();
=20
- if ((winspace > 0) && (hci_trig_send())) {
- printk("*\n");
+ if ((winspace > 0) && (buf_count())) {
+ /* ack is piggybacked in next tx data packet */
+ D("<-data ack\n");
} else {
- printk(" -\n");
+ D("<-ack\n");
send_ack();
}
=20=09=09
@@ -148,10 +163,13 @@
bcsp->identifier);
} else { /* out of order rx seq nbr */=20
if ((winspace > 0) && (hci_trig_send())) {
- print_data(__FUNCTION__, bcsp->payload, bcsp->payload_length);
- printk("**\n");
+ print_data(__FUNCTION__, bcsp->payload,=20
+ bcsp->payload_length);
+ printk("seq out-of-order [exp:%d, got:%d]\n",=20
+ expected_rxseq, BCSP_GET_SEQ(bcsp));
} else {
- printk(" --\n");
+ printk("seq out-of-order [exp:%d, got:%d], send ack\n",
+ expected_rxseq, BCSP_GET_SEQ(bcsp));
send_ack();
}
}
@@ -164,7 +182,7 @@
{
struct bcsp bcsp;
=20
- //printk(__FUNCTION__": rxack:%d, txack:%d, txseq:%d, winspace:%d\n", rxa=
ck, txack, txseq, winspace);
+ D(__FUNCTION__": rxack:%d, txack:%d, txseq:%d, winspace:%d\n", rxack, txa=
ck, txseq, winspace);
=20=09
if (winspace > 0) {
bcsp_init_packet(&bcsp);
@@ -176,14 +194,15 @@
cli();
BCSP_SET_SEQ(&bcsp, txseq);
BCSP_SET_ACK(&bcsp, txack);
-=09=09
bcsp.payload =3D data;
bcsp.payload_length =3D len;
+ sti();
=20
memcpy(resend_buffer[txseq].data, data, len);
resend_buffer[txseq].len =3D len;
resend_buffer[txseq].chn =3D chn;
=20=09=09
+ cli();
txseq =3D (txseq + 1) % 8;
winspace--;
sti();
@@ -193,7 +212,9 @@
/* restart timer */
start_resend_timer();
} else {
- printk(__FUNCTION__": winspace =3D 0\n");
+#ifdef DBG_BCSPHEADER
+ printk(__FUNCTION__": win=3D0\n");
+#endif
return 0;
}
=20
@@ -204,8 +225,7 @@
bcsp_signal_rxack(u8 new_ack)
{
s32 trig_send =3D FALSE;
- printk(__FUNCTION__": Got new ack:%d, rxack is:%d, txseq:%d, winspace:%d\=
n", new_ack, rxack, txseq, winspace);
-
+ D(__FUNCTION__": Got new ack:%d, rxack is:%d, txseq:%d, winspace:%d\n", n=
ew_ack, rxack, txseq, winspace);
=20
if (rxack =3D=3D new_ack) { /* Same ack again... */
return;
@@ -216,40 +236,45 @@
trig_send =3D TRUE;
}
=20
- D(__FUNCTION__": winspace before:%d\n", winspace);
+ D(__FUNCTION__": winspace before:%d [%d, %d]\n",=20
+ winspace, rxack, new_ack);
if (new_ack > rxack) {
winspace +=3D (new_ack - rxack);
} else {
- winspace +=3D (WINSIZE - (rxack - new_ack) + 1);
+ winspace +=3D (8 - (rxack - new_ack));
}
- D(__FUNCTION__": winspace after:%d\n", winspace);
=20=09
+ D(__FUNCTION__" win_up:%d\n", winspace);
+
rxack =3D new_ack;
+
sti();
=20=09
if (winspace =3D=3D WINSIZE) {
release_resend_timer();
} else if (winspace > WINSIZE) {
- printk(__FUNCTION__": Something has gone wrong winspace > WINSIZE\n");
+ printk(__FUNCTION__": ERROR winspace > WINSIZE [%d]\n",=20
+ winspace);
release_resend_timer();
- winspace =3D WINSIZE;
}
=20=09
if (trig_send) {
- printk(__FUNCTION__": Trying to trig send\n");
hci_trig_send();
}
}
=20
+#define BCSP_RTX_MAX 20
void
sequence_resend(void)
{
struct bcsp bcsp;
u8 resend_cnt =3D rxack;
+ u8 rtx_count =3D BCSP_RTX_MAX;
+=09
cli();
- while (resend_cnt !=3D txseq) {
+ while ((resend_cnt !=3D txseq) && (rtx_count--)) {
sti();
- printk(__FUNCTION__": Resending with seq_nbr:%d, last ack was %d, cur se=
q_nbr:%d\n", resend_cnt, rxack, txseq);
+ printk(__FUNCTION__" : seq_nbr:%d, last_ack:%d, cur_seq:%d\n\n", resend_=
cnt, rxack, txseq);
=20
bcsp_init_packet(&bcsp);
=20
@@ -268,8 +293,16 @@
resend_cnt =3D (resend_cnt + 1) % 8;
}
sti();
+=09
+ if (rtx_count =3D=3D 0)
+ {
+ printk("ERROR : giving up on rtx !\n");
+ /* fixme -- signal link down etc. */
+ }
+ else
start_resend_timer();
}
+
=20
void
send_ack(void)
|