|
From: Mats F. <ma...@us...> - 2001-05-25 14:12:51
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
bcsp_sequence.c 1.8 1.9=20=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
Rewrote resending procedures
The diff of the modified file(s):
--- bcsp_sequence.c 2001/05/18 16:03:51 1.8
+++ bcsp_sequence.c 2001/05/25 14:12:50 1.9
@@ -58,7 +58,7 @@
#define D(fmt...)
#endif
=20
-#define WINSIZE 7
+#define WINSIZE 4
#define SEQUENCE_TIMEOUT HZ
=20
/****************** TYPE DEFINITION SECTION ******************************=
***/
@@ -126,25 +126,32 @@
bcsp_syncronized();
}
=20=09
+ printk(__FUNCTION__": txack:%d, expected_rxseq:%d, BCSP_GET_SEQ(bcsp):%d\=
n", txack, expected_rxseq, BCSP_GET_SEQ(bcsp));
+=09
if (expected_rxseq =3D=3D BCSP_GET_SEQ(bcsp)) {
cli();
txack =3D (BCSP_GET_SEQ(bcsp) + 1) % 8;
expected_rxseq =3D (expected_rxseq + 1) % 8;
sti();
=20
- bcsp_receive_top(bcsp->payload, bcsp->payload_length, bcsp->identifier);
+ if ((winspace > 0) && (hci_trig_send())) {
+ printk("*\n");
+ } else {
+ printk(" -\n");
+ send_ack();
}
=20
-/* FIXME: Do we need a task_queue for sending the ack packets ? */
-#if 0
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
- queue_task(&send_ack_task, &tq_immediate);
-#else
- queue_task(&send_ack_task, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
-#endif
-#endif=09=09
+ bcsp_receive_top(bcsp->payload, bcsp->payload_length,
+ 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");
+ } else {
+ printk(" --\n");
send_ack();
+ }
+ }
=20=09
return 0;
}
@@ -154,6 +161,8 @@
{
struct bcsp bcsp;
=20=09
+ //printk(__FUNCTION__": rxack:%d, txack:%d, txseq:%d, winspace:%d\n", rxa=
ck, txack, txseq, winspace);
+=09
if (winspace > 0) {
bcsp_init_packet(&bcsp);
=20
@@ -161,8 +170,8 @@
=20
BCSP_SET_PROTOCOL_TYPE(&bcsp, BCSP_RELIABLE);
=20
+ cli();
BCSP_SET_SEQ(&bcsp, txseq);
-
BCSP_SET_ACK(&bcsp, txack);
=20
bcsp.payload =3D data;
@@ -174,12 +183,11 @@
=20
txseq =3D (txseq + 1) % 8;
winspace--;
+ sti();
=20
D(__FUNCTION__": winspace:%d, txreq:%d\n", winspace, txseq);
=20
- if (resend_timer_active) {
- release_resend_timer();
- }
+ /* restart timer */
start_resend_timer();
} else {
printk(__FUNCTION__": winspace =3D 0\n");
@@ -192,40 +200,42 @@
void
bcsp_signal_rxack(u8 new_ack)
{
- D(__FUNCTION__": Got rxack:%d\n", 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);
=20=09
- if (rxack =3D=3D new_ack) {
- if (!(rxack =3D=3D txseq)) {
- printk(__FUNCTION__": Got incorrect new_ack:%d, seq_nbr:%d\n", new_ack=
, txseq);
=20=09=09
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
- queue_task(&resend_data_task, &tq_scheduler);
-#else
- queue_task(&resend_data_task, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
-#endif
- } else {
- printk(__FUNCTION__": Got repeted ack%d\n", new_ack);
+ if (rxack =3D=3D new_ack) { /* Same ack again... */
+ return;
}
- } else if (rxack < new_ack) {
+
+ cli();
+ if (winspace =3D=3D 0) {
+ trig_send =3D TRUE;
+ }
+
D(__FUNCTION__": winspace before:%d\n", winspace);
- winspace +=3D new_ack - rxack;
- D(__FUNCTION__": winspace after:%d\n", winspace);
+ if (new_ack > rxack) {
+ winspace +=3D (new_ack - rxack);
} else {
- D(__FUNCTION__": winspace before:%d\n", winspace);
- winspace +=3D (WINSIZE - rxack) + new_ack + 1;
- D(__FUNCTION__": winspace after:%d\n", winspace);
+ winspace +=3D (WINSIZE - (rxack - new_ack) + 1);
}
+ D(__FUNCTION__": winspace after:%d\n", winspace);
=20
rxack =3D new_ack;
+ sti();
=20
if (winspace =3D=3D WINSIZE) {
release_resend_timer();
} else if (winspace > WINSIZE) {
- printk(__FUNCTION__": Somthing has gone wrong winspace > WINSIZE\n");
+ printk(__FUNCTION__": Something has gone wrong winspace > WINSIZE\n");
release_resend_timer();
winspace =3D WINSIZE;
}
+=09
+ if (trig_send) {
+ printk(__FUNCTION__": Trying to trig send\n");
+ hci_trig_send();
+ }
}
=20
void
@@ -233,8 +243,9 @@
{
struct bcsp bcsp;
u8 resend_cnt =3D rxack;
-=09
+ cli();
while (resend_cnt !=3D txseq) {
+ sti();
printk(__FUNCTION__": Resending with seq_nbr:%d, last ack was %d, cur se=
q_nbr:%d\n", resend_cnt, rxack, txseq);
=20
bcsp_init_packet(&bcsp);
@@ -244,28 +255,36 @@
BCSP_SET_PROTOCOL_TYPE(&bcsp, BCSP_RELIABLE);
=20
BCSP_SET_SEQ(&bcsp, resend_cnt);
-
+ cli();
BCSP_SET_ACK(&bcsp, txack);
-
+ sti();
bcsp.payload =3D resend_buffer[resend_cnt].data;
bcsp.payload_length =3D resend_buffer[resend_cnt].len;
=20
bcsp_mux_send(&bcsp);
resend_cnt =3D (resend_cnt + 1) % 8;
}
-
+ sti();
start_resend_timer();
}
=20
void
send_ack(void)
{
- bcsp_send_txack(txack);
+ u8 tmp;
+ cli();
+ tmp =3D txack;
+ sti();
+ bcsp_send_txack(tmp);
}
=20
void
start_resend_timer(void)
{
+ if (resend_timer_active) {
+ release_resend_timer();
+ }
+=09
init_timer(&resend_timer);
resend_timer.function =3D (void*)sequence_resend;
resend_timer.data =3D 0;
@@ -279,8 +298,10 @@
void
release_resend_timer(void)
{
+ if (resend_timer_active) {
resend_timer_active =3D FALSE;
del_timer(&resend_timer);
+ }
}
=20
/****************** END OF FILE sequence.c *******************************=
***/
|