|
From: Mattias A. <mat...@us...> - 2001-04-12 15:10:02
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.98 1.99=20=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* fixed return code when waking up wait queue (SIG_CONRSP)
* added conf_req_sent
* fixed auto shutdown of l2cap cons (currently not used)
* added l2ca_wait after l2cap_connect_req when baseband exists
* fixed bug when calculating new timer interval
* fixed usermode problems with timer
* cleanup & minor changes
The diff of the modified file(s):
--- l2cap.c 2001/04/11 11:16:30 1.98
+++ l2cap.c 2001/04/12 15:10:01 1.99
@@ -223,23 +223,23 @@
#define RTX_TIMEOUT 2 /* sec */
#define ERTX_TIMEOUT 60 /* sec */
=20
+
#ifdef __KERNEL__
-void start_rtx(l2cap_con *con, unsigned short timeout, unsigned short acti=
on);
-void disable_rtx(l2cap_con *con);
-void start_ertx(l2cap_con *con, unsigned short timeout);
-void disable_ertx(l2cap_con *con);
void l2cap_rtx_timeout(unsigned long ptr);
void l2cap_ertx_timeout(unsigned long ptr);
-
#else /* usermode stack */
-
l2cap_con *timeout_con =3D NULL;
s32 timer_cancelled =3D 0;
-void start_rtx(l2cap_con *con, s32 timeout, u16 action);
-void disable_rtx(l2cap_con *con);
void l2cap_rtx_timeout(void);
+void l2cap_ertx_timeout(unsigned long ptr);
#endif
=20
+void start_rtx(l2cap_con *con, unsigned short timeout, unsigned short acti=
on);
+void disable_rtx(l2cap_con *con);
+
+void start_ertx(l2cap_con *con, unsigned short timeout);
+void disable_ertx(l2cap_con *con);
+
#endif
=20
/****************** GLOBAL VARIABLE DECLARATION SECTION ******************=
***/
@@ -342,8 +342,6 @@
s32=20
l2cap_shutdown(void)
{
- //l2cap_con *con =3D get_first_con();
-=20=20
DSYS("Shutting down L2CAP\n");
if (!l2cap->initiated)
{
@@ -351,21 +349,25 @@
return -1;
}
=20=09
+/* experimental */
#if 0
- /* Notify upper users, don't have time for real disconnect... */
+ {=20=20
+ l2cap_con *con;
+ con =3D get_first_con();
while (con!=3D NULL) {
- l2ca_disconnect_ind(con);
- con =3D get_next_con(con);
+ if (l2ca_disconnect_req(con) !=3D 0)
+ break;
+ con =3D get_first_con();
}
+ }
#endif
- /* necessary ? */
+
free_list();
remove_all_upper();
=20
#ifdef __CRIS__
bt_connections =3D 0;
#endif
-
/*ALWAYS SUCCESS*/
return 0;
}
@@ -1003,7 +1005,9 @@
=20
switch (conrsp->result) {
case RES_SUCCESS:
- l2ca_wakeup("l2cap_connect_rsp", con);
+
+ con->c_result =3D RES_SUCCESS;
+ l2ca_wakeup("l2cap connect rsp", con);
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
l2ca_connect_cfm(con, conrsp->result);
@@ -1106,7 +1110,11 @@
/* notify upper layers that we successfully
opened a connection ! */
l2ca_config_cfm(con, confrsp->result);
- } return;
+
+ /* reset */
+ con->conf_req_sent =3D 0;
+ return;
+ }
=20=09=09=09
case CONF_FAILURE:
=20
@@ -1330,8 +1338,9 @@
l2cap_con *con;
D_STATE("lp_connect_cfm: %s (hci_handle : %d)\n",=20
get_err_msg(status), con_hdl);
- print_data("lp_connect_cfm BD", bd_addr, 6);
=20
+ D_STATE("lp_connect_cfm : bd %s\n", bd2str(bd_addr));
+
/* FIXME -- use bt session list to notify upper layers that=20
con failed !!! */
=20
@@ -1349,7 +1358,7 @@
con->link_up =3D TRUE;
=20
/* see if there is someone to wakeup */
- l2ca_wakeup("lp_connect_cfm", con);
+ l2ca_wakeup("lp_connect_cfm (pos)", con);
=20=09=09
if (con->c_flags & FLAG_RETURNNOW)
{
@@ -1496,7 +1505,7 @@
s32 i;
u8 rev_bd[6];
=20
- D_RCV("l2cap_connect_req\n");
+ D_RCV("l2ca_connect_req\n");
PRINTPKT("l2ca_connect_req : sent to bd ",bd, 6);
=20
/* Check bd_addr */
@@ -1562,6 +1571,9 @@
=20
l2cap_connect_req(con, psm);
=20
+ l2ca_wait("l2cap_connect_req : wait rsp", con);
+
+ /* fixme -- use con->c_status */
return 0;
} else {
D_STATE("l2ca_connect_req : create new baseband link\n");
@@ -1588,12 +1600,8 @@
=20
/* wait until we received a response or after timeout */
=20
-#ifdef BTD_USERSTACK
- printk("Sleeping 2 sec\n");=09
- sleep(2);
-#else
l2ca_wait("l2cap_connect_req : wait rsp", con);
-#endif
+
}
=20
return con->c_result;
@@ -1616,7 +1624,7 @@
=20
if (con->current_state =3D=3D CONFIG) {=20=20
/* local mtu is set in l2cap_config_req */
-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20
+ con->conf_req_sent =3D 1;
return l2cap_config_req(con, in_mtu, outflow,=20
flush_timeout, link_to);=20=20
=20
@@ -1668,6 +1676,7 @@
PRINTSTATE(con);
} else {
D_ERR("l2ca_disconnect_req : Invalid state !\n");
+ PRINTSTATE(con);
return -1;=20=20=20=20
}
=20=09
@@ -1755,6 +1764,9 @@
con->local_cid, con->remote_cid,=20
psm2str(con->psm));
=20=09=09=09
+ /* reset */
+ con->conf_req_sent =3D 0;
+
/* notify upper layers that we are opened */
l2ca_config_cfm(con, RES_SUCCESS);
=20
@@ -1991,6 +2003,7 @@
=20=20=20
cmd->code =3D SIG_CONREQ;
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con */
+
cmd->len =3D cpu_to_le16(CON_REQSIZE);
=20
SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
@@ -2602,6 +2615,7 @@
=20=09
if (PARANOIA_CHECKCON(con)) {
D_ERR("%s l.%d NULL/magic failed\n", __FILE__, __LINE__);
+ tx->flushed =3D 1; /* flush this buffer */
return -1;
}
=20
@@ -2913,15 +2927,15 @@
=20
#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
=20
-#ifdef __KERNEL__
-
/* Action is used when the sending function doesn't want
to handle the action it self */
void
start_rtx(l2cap_con *con, unsigned short timeout, u16 action)
{
/* multiply by 2 each rtx */
- timeout *=3D (2<<(con->timer.rtx_no));
+
+ if (con->timer.rtx_no > 0)
+ timeout =3D timeout*(2<<(con->timer.rtx_no - 1));
=20
/* FIXME -- use flush timeout to calculate number of
retransmissions */
@@ -2935,6 +2949,7 @@
return;
}
=20=09
+#ifdef __KERNEL__=09
init_timer(&con->timer.rtx);
con->timer.rtx.function =3D l2cap_rtx_timeout;
con->timer.rtx.data =3D (unsigned long)con;
@@ -2942,20 +2957,13 @@
con->timer.rtx_inuse =3D 1;
con->timer.rtx_action =3D action;
add_timer(&con->timer.rtx);=20=20
-}
=20
-
-#else /* USERSTACK */
+#else /* Usermode stack */
=20
-/* FIXME -- Currently usermode stack and signal() doesn't work=20
- since we are using threads */
-void=20
-start_rtx(l2cap_con *con, s32 timeout)
-{
-#if 1
- printk("use NO timer...\n");
+ /* FIXME */
+ printk("Use NO timer in usermode stack yet...\n");
return;
-#else
+#if 0
struct itimerval t =3D {{0,0},{timeout, 0}};
=20
D_TIM("Starting RTX timer (%d sec)\n", timeout);
@@ -2972,9 +2980,10 @@
=20
timer_cancelled =3D 0;
#endif
-}
+
#endif /* __KERNEL__ */
=20
+}
=20
void
disable_rtx(l2cap_con *con)
@@ -2984,6 +2993,8 @@
if (con->timer.rtx_inuse) {
del_timer(&con->timer.rtx);
con->timer.rtx_inuse =3D 0;
+ con->timer.rtx_no =3D 0;
+ con->timer.rtx_action =3D RTX_ACTION_DISCONNECT;
}
else
D_TIM("RTX never started\n");
@@ -3005,12 +3016,17 @@
return;
}
=20
+#ifdef __KERNEL__
init_timer(&con->timer.ertx);
con->timer.ertx.function =3D l2cap_ertx_timeout;
con->timer.ertx.data =3D (unsigned long)con;
con->timer.ertx.expires =3D jiffies + timeout*HZ;
con->timer.ertx_inuse =3D 1;
add_timer(&con->timer.ertx);
+#else
+ /* fixme */
+ con->timer.ertx_inuse =3D 1;
+#endif
}
=20
void
@@ -3018,15 +3034,18 @@
{
D_TIM("Disabling ERTX timer\n");
#ifdef __KERNEL__
- if (con->timer.rtx_inuse){
+ if (con->timer.ertx_inuse){
del_timer(&con->timer.ertx);
- con->timer.rtx_inuse =3D 0;
+ con->timer.ertx_inuse =3D 0;
+ con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
}
else
D_TIM("ERTX never started\n");
-#else
+#else /* Usermode stack */
/* FIXME */
printk("disable_ertx FIXME\n");
+ con->timer.ertx_inuse =3D 0;
+ con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
#endif
}
#endif /* CONFIG_BLUETOOTH_L2CAP_USE_TIMERS */
@@ -3070,13 +3089,6 @@
con->remote_mtu =3D *(opt->option_data) |=20
(*(opt->option_data + 1) << 8);
=20
- if ((con->remote_mtu < MTU_MIN) &&=20
- ((con->remote_mtu + L2CAP_HDRSIZE) > HCI_IN_SIZE)) {
- D_WARN("Remote side tries to use nonvalid MTU [%d]\n",
- con->remote_mtu);
- return CONF_FAILURE;
- }
-=09=09=09=20=20=20=20
D_RCV("Setting remote mtu (%d:%d) to %d bytes\n",
con->local_cid, con->remote_cid,=20
con->remote_mtu);
@@ -3189,14 +3201,13 @@
return;
} else {
printk(" flow:\n");
- printk(" flags:%d service:%d token_rate:%d\n",
- f->flags, f->service, (int) f->token_rate);
+ printk(" flags:%d service: 0x%x token_rate: 0x%d\n",
+ f->flags, f->service, (unsigned int) f->token_rate);
printk(" bucket_size:%d bytes peak:%d bps latency:%d ms delay:%d ms\n",
- (int)f->bucket_size, (int)f->peak, (int)f->latency,=20
- (int)f->delay);
+ (unsigned int)f->bucket_size, (unsigned int)f->peak,=20
+ (unsigned int)f->latency, (unsigned int)f->delay);
}
}
-
/* Returns a free cid in range 0x0040 - 0xffff */
/* FIXME - search from MIN_CID every time ? */
u16 get_cid(void)
|