|
From: Mattias A. <mat...@us...> - 2001-04-25 16:58:25
|
The following file was modified in linux/drivers/char/bluetooth:
Name Old version New version Comment
---- ----------- ----------- -------
l2cap.c 1.104 1.105=20=20=20=20=20=20=20=20=20=20=20
The accompanying log:
* add deletion of failed l2cap con in lp_connect_cfm if non-initiator
* added ifdefs around disable_rtx
* l2ca_disconnect_req is now responsible of deleting disconnected l2cap=20
cons and shutting down baseband if nbr of l2cap cons are 0 on this handle.
(Used to be done in l2ca_connect_cfm)
* don't increment ID if retransmission
* cleanup & minor changes
The diff of the modified file(s):
--- l2cap.c 2001/04/20 17:52:08 1.104
+++ l2cap.c 2001/04/25 16:58:24 1.105
@@ -292,7 +292,7 @@
if ((l2cap->my_bd[0] =3D=3D 0) && (l2cap->my_bd[1] =3D=3D 0) &&=20
(l2cap->my_bd[2] =3D=3D 0) && (l2cap->my_bd[3] =3D=3D 0) &&
(l2cap->my_bd[4] =3D=3D 0) && (l2cap->my_bd[5] =3D=3D 0))
- D_ERR("Failed to get local BD addr\n");
+ D_ERR(__FUNCTION__ ": Failed to get local BD addr\n");
else {
i =3D l2cap_sprint_bd(bd_name, l2cap->my_bd);
bd_name[i] =3D 0;
@@ -344,11 +344,11 @@
{
DSYS("Shutting down L2CAP\n");
if (!l2cap->initiated) {
- D_ERR("L2CAP not initiated\n");
+ D_ERR(__FUNCTION__ ": L2CAP not initiated\n");
return -1;
}
=20
-/* experimental */
+ /* fixme -- experimental */
#if 0
{
l2cap_con *con;
@@ -727,7 +727,7 @@
confreq->dst_cid, confreq->flags);
=20=09=09
if ((con =3D get_lcon(confreq->dst_cid)) =3D=3D NULL) {
- D_ERR("Couldn't find local CID\n");
+ D_ERR(__FUNCTION__ ": Couldn't find local CID\n");
/* send back response ? */
l2cap_cmdrej(hci_handle, CMDREJ_INVALIDCID, NULL, 0);
return;
@@ -758,7 +758,7 @@
/* send back negative response */
if (l2ca_config_rsp(con, result, STAT_NOINFO,=20
CONF_FAILURE) < 0) {
- D_ERR("Couldn't send conf rsp\n");
+ D_ERR(__FUNCTION__ ": Couldn't send conf rsp\n");
}
return;
}
@@ -777,7 +777,7 @@
convenient point=20
*/
=20=09=09=09
- D_STATE("Got conf req in OPEN, renegotiate !\n");
+ D_STATE(__FUNCTION__ "Got conf req in OPEN, renegotiate !\n");
=20
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
@@ -786,7 +786,7 @@
result =3D parse_options(con, confreq->options,
req->len-4);
} else {
- D_ERR("Remote peer tried to renegotiate but cinf req contained no opti=
ons !\n");
+ D_ERR(__FUNCTION__": Remote peer tried to renegotiate but cinf req con=
tained no options !\n");
return;
}
=20=09=09=09
@@ -801,7 +801,7 @@
if (l2ca_config_rsp(con, result,=20
STAT_NOINFO,=20
CONF_FAILURE) < 0) {
- D_ERR("Couldnt send conf rsp\n");
+ D_ERR(__FUNCTION__": Couldnt send conf rsp\n");
}
return;
}
@@ -819,7 +819,7 @@
}
=20=20=20=20=20=20=20=20=20=20=20=20
default:
- D_ERR("Got config req in invalid state! [%s]\n",
+ D_ERR(__FUNCTION__": Got config req in invalid state! [%s]\n",
state_name[con->current_state]);
PRINTSTATE(con);
break;
@@ -885,7 +885,7 @@
break;
=20
default:
- D_ERR("Unknown info request: type 0x%x\n", info->type);
+ D_ERR(__FUNCTION__ ": Unknown info request: type 0x%x\n", info->type);
l2cap_cmdrej(hci_handle, CMDREJ_NOTUNDERSTOOD,
NULL, 0);
break;=09=09
@@ -1003,7 +1003,11 @@
case RES_SUCCESS:
=20
con->c_result =3D RES_SUCCESS;
- l2ca_wakeup("l2cap connect rsp", con);
+ l2ca_wakeup("l2cap con rsp", con);
+
+#ifdef CONFIG_BLUETOOTH_L2CAP_USE_TIMERS
+ disable_rtx(con);
+#endif
ENTERSTATE(con, CONFIG);
PRINTSTATE(con);
l2ca_connect_cfm(con, conrsp->result);
@@ -1094,7 +1098,7 @@
=20
if (!con->conf_rsp_ready) {
/* Upper layers still haven't replied pos */
- D_STATE("Still haven't replied pos on other sides conf req\n");
+ D_STATE(__FUNCTION__": Still haven't replied pos on other sides conf r=
eq\n");
return ;
} else {=09=09=09=09
ENTERSTATE(con, OPEN);
@@ -1107,7 +1111,7 @@
opened a connection ! */
l2ca_config_cfm(con, confrsp->result);
=20
- /* reset */
+ /* reset variable */
con->conf_req_sent =3D 0;
return;
}
@@ -1182,7 +1186,7 @@
#endif
con->c_result =3D RES_SUCCESS;
l2ca_disconnect_cfm(con);
- l2ca_wakeup("l2cap_disconnect_rsp", con);
+ l2ca_wakeup("l2cap disc rsp", con);
break;
=20=20=20=20=20=20=20=20
case SIG_ECHORSP: {
@@ -1191,7 +1195,7 @@
D_STATE(__FUNCTION__ ": Got echo response\n");=09=09
=20
if ((tempcon =3D get_con_hcihdl(hci_handle))=3D=3DNULL) {
- D_STATE("Echo rsp: could not find connection\n");
+ D_STATE(__FUNCTION__": Echo rsp, could not find connection\n");
return;
}
=20=09=09
@@ -1218,7 +1222,7 @@
l2cap_con *tempcon;
=20
if ((tempcon =3D get_con_hcihdl(hci_handle))=3D=3DNULL) {
- D_STATE("Echo rsp: could not find connection\n");
+ D_STATE(__FUNCTION__": Echo rsp, could not find connection\n");
return;
}
=20
@@ -1330,11 +1334,18 @@
lp_connect_cfm(u8 *bd_addr, u32 status, u16 con_hdl)
{
l2cap_con *con;
+ u8 rev_bd[6];
+=09
D_STATE(__FUNCTION__ ": %s (hci_handle : %d)\n",=20
get_err_msg(status), con_hdl);
=20
- D_STATE(__FUNCTION__ ": bd %s\n", bd2str(bd_addr));
+ /* reverse byte order */
+ for (i =3D 0; i < 6; i++) {
+ rev_bd[5-i] =3D bd_addr[i];
+ }
=20
+ D_STATE(__FUNCTION__ ": bd %s\n", bd2str(rev_bd));
+
/* FIXME -- use bt session list to notify upper layers that=20
con failed !!! */
=20
@@ -1355,7 +1366,7 @@
l2ca_wakeup("lp_connect_cfm (pos)", con);
=20=09=09
if (con->c_flags & FLAG_RETURNNOW) {
- printk("Return NOW\n");
+ D_STATE(__FUNCTION__" Return NOW\n");
/* clear flag & set status */
con->c_flags &=3D ~FLAG_RETURNNOW;
return;
@@ -1389,10 +1400,15 @@
return;
}
=20
+ if (con->initiator) {
/* only notify upper layers if we are initiator */
- if (con->initiator)
l2ca_connect_cfm(con, MSGCODE(MSG_LAYER_HCI,=20
status));
+ } else {
+ /* delete connection if non-initiator */
+ delete_con(con);
+ }=20
+=09=09
}
}
=20=20
@@ -1444,7 +1460,6 @@
=20
/* flush old buffers waiting to be sent on this handle */
btmem_flushhandle((u16)con_hdl);
- //btmem_reset();
=20
#ifdef __CRIS__
if (bt_connections > 0)
@@ -1590,7 +1605,6 @@
l2cap_connect_req(con, con->psm);
=20
/* wait until we received a response or after timeout */
-
l2ca_wait(__FUNCTION__ ": wait rsp", con);
}
=20
@@ -1614,7 +1628,9 @@
=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
@@ -1622,7 +1638,7 @@
l2ca_config_cfm(con, CONF_REJ);
return -1;
} else if (con->current_state =3D=3D OPEN) {
- printk("l2ca_config_req: state OPEN, reconfiguration !\n");
+ DSYS("l2ca_config_req: state OPEN, reconfiguration !\n");
=20
/* FIXME -=20
Is data automatically suspended while reconfiguring ?
@@ -1649,6 +1665,7 @@
l2ca_disconnect_req(l2cap_con *con)
{
s32 result =3D -1;
+ u16 tmp_hdl =3D con->hci_hdl;
=20
if (PARANOIA_CHECKCON(con)) {
D_ERR(__FUNCTION__ ": Paranoia check failed\n");
@@ -1672,10 +1689,30 @@
/* wait here until we get a confirm */
l2ca_wait(__FUNCTION__, con);
=20
- return con->c_result;
+ result =3D con->c_result;
+
+ if (con->current_state =3D=3D CLOSED) {=09
+ /* remove l2cap connection */
+ delete_con(con);
+ } else {
+ D_ERR("L2CAP Disconnect failed\n");
+ PRINTSTATE(con);
}
=20
+ /* fixme -- if we want to keep baseband connection we must=20
+ leave the l2cap connection which holds the hci handle=20
+ simply just clear l2cap params but keep hci handle ! */
=20
+ if (count_con(tmp_hdl) =3D=3D 0) {
+ DSYS("l2ca_disconnect_req : (C) no more l2cap cons\n");
+ DSYS("Shutdown baseband\n");
+ lp_disconnect(tmp_hdl);
+ }
+
+ return result;
+}
+
+
/* Response from upper layer to the indication of a channel to a remote=20
device */
s32=20
@@ -1750,7 +1787,7 @@
con->local_cid, con->remote_cid,=20
psm2str(con->psm));
=20
- /* reset */
+ /* reset variable */
con->conf_req_sent =3D 0;
=20
/* notify upper layers that we are opened */
@@ -1802,8 +1839,6 @@
if (count_con(con->hci_hdl) > 1) {
delete_con(con);=20=20=20=20=20
}
- /* If this con is the last with this hci_hdl, it is deleted=20
- when the baseband link goes down */
} else {
D_ERR(__FUNCTION__ ": invalid state !\n\n");
PRINTSTATE(con);
@@ -1819,7 +1854,7 @@
=20
void l2ca_timeoutind(l2cap_con *con)
{
- printk("l2ca_timeoutind\n");
+ DSYS("l2ca_timeoutind\n");
con->c_status =3D CSTATUS_RTX_TIMEOUT;=09
l2ca_wakeup("l2ca_timeoutind ", con);
}
@@ -1981,7 +2016,12 @@
req->src_cid =3D cpu_to_le16(con->local_cid);
=20=20=20
cmd->code =3D SIG_CONREQ;
+
+ /* Don't increment ID if retransmission */
+ if (con->timer.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con */
+ else
+ DSYS("RTX, use same ID\n");
=20
cmd->len =3D cpu_to_le16(CON_REQSIZE);
=20
@@ -2062,7 +2102,7 @@
SIGCMD_HDRSIZE + CONF_REQSIZE);
=20=20
if (in_mtu !=3D 0) {
- printk("Sending in_mtu %d\n", in_mtu);
+ DSYS("Sending in_mtu %d\n", in_mtu);
opt->type =3D OPT_MTU;
opt->len =3D 2;
*(opt->option_data) =3D (u8)(in_mtu & 0x00ff);
@@ -2073,7 +2113,7 @@
}
=20=09=09
if (flush_timeout !=3D 0) {
- printk("Sending flush_timeout %d\n", flush_timeout);
+ DSYS("Sending flush_timeout %d\n", flush_timeout);
opt->type =3D OPT_FLUSH;
opt->len =3D 2;
*(opt->option_data) =3D (u8)(flush_timeout & 0x00ff);
@@ -2084,7 +2124,7 @@
}
=20=09=09
if (outflow !=3D NULL) {=20
- printk("Sending conf req outflow\n");
+ DSYS("Sending conf req outflow\n");
print_flow(outflow);
opt->type =3D OPT_QOS;
opt->len =3D sizeof *outflow;
@@ -2098,7 +2138,15 @@
=20
/* Signalling header */
cmd->code =3D SIG_CONFREQ;
+
+ /* Don't increment ID if retransmission */
+ if (con->timer.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con */
+ else
+ DSYS("RTX, use same ID\n");
+
+ /* fixme -- wrong len field should be 2 more */
+
cmd->len =3D cpu_to_le16(CONF_REQSIZE + opt_len);
=20
SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
@@ -2149,7 +2197,13 @@
req->src_cid =3D cpu_to_le16(con->local_cid);
=20
cmd->code =3D SIG_DISCREQ;
+=20=20=20=20=20=20=20=20
+ /* Don't increment ID if retransmission */
+ if (con->timer.rtx_no =3D=3D 0)
cmd->id =3D set_id(con); /* Sets sig_id_sent in l2cap_con */
+ else
+ DSYS("RTX, use same ID\n");
+=20=20=20=20=20=20=20=20
cmd->len =3D cpu_to_le16(DISC_REQSIZE);
=20
SET_L2CAP_HDR(l2cap_buf->frame, payload_len, CIDSIG);
@@ -2498,7 +2552,7 @@
opt =3D (struct l2cap_option*)(rsp + CONF_RSPSIZE);
=20
if (out_mtu !=3D 0) {
- printk("Sending out_mtu %d\n", out_mtu);
+ DSYS("Sending out_mtu %d\n", out_mtu);
opt->type =3D OPT_MTU;
opt->len =3D 2;
*(opt->option_data) =3D (u8)(out_mtu & 0x00ff);
@@ -2509,7 +2563,7 @@
}
=20=09=09
if (in_flow !=3D NULL) {=20
- printk("Sending conf req in_flow\n");
+ DSYS("Sending conf req in_flow\n");
print_flow(in_flow);
opt->type =3D OPT_QOS;
opt->len =3D sizeof *in_flow;
@@ -2600,8 +2654,7 @@
if (tx->cur_len > con->remote_mtu) {
D_ERR("%s tries to send more than remote mtu, ignore\n",=20
psm2str(con->psm));
-
- D_ERR("SETTING FLUSHED ON THIS BUFFER !!!\n");
+ D_ERR(__FUNCTION__ ": Flushing this buffer\n");
tx->flushed =3D 1;
return -1;
}
@@ -2609,7 +2662,7 @@
/* Only send on an OPEN channel */
if (con->current_state !=3D OPEN) {
D_ERR(__FUNCTION__ ": not in open state\n");
- D_ERR("SETTING FLUSHED ON THIS BUFFER !!!\n");
+ D_ERR(__FUNCTION__ ": Flushing this buffer\n");
tx->flushed =3D 1;
return -1;
}
@@ -2657,7 +2710,7 @@
con->remote_cid, status);
=20=09
if (!con->initiator) {=20
- D_ERR(__FUNCTION__": server is not initiator !!!\n");=20
+ D_ERR(__FUNCTION__": server is not initiator !\n");=20
return;
}
=20=09
@@ -2673,7 +2726,7 @@
con->remote_cid, result);
=20=09
if (!con->initiator) {=20
- D_ERR(__FUNCTION__ ": server is not initiator !!!\n");=20
+ D_ERR(__FUNCTION__ ": server is not initiator !\n");=20
return;
}
=20
@@ -2719,30 +2772,11 @@
/* tell upper layers that connection is down */
get_upper(con->psm)->disc_cfm(con);
=20
- tmp_hdl =3D con->hci_hdl;
-
ENTERSTATE(con, CLOSED);
PRINTSTATE(con);
=20
DSYS("l2cap channel (%d,%d) [%s] disconnected\n",=20
con->local_cid, con->remote_cid, psm2str(con->psm));
-
- /* remove l2cap connection */
- delete_con(con);
-
-#ifdef __KERNEL__
- l2ca_wakeup(__FUNCTION__, con);
-#endif
-
- /* fixme -- if we want to keep baseband connection we must=20
- leave the l2cap connection which holds the hci handle=20
- simply just clear l2cap params but keep hci handle ! */
-=09
- if (count_con(tmp_hdl) =3D=3D 0) {
- DSYS(__FUNCTION__ ": (C) no more l2cap connections\n");
- DSYS("Shutdown baseband\n");
- lp_disconnect(tmp_hdl);
- }
}
=20
s32 l2ca_ping(BD_ADDR bd, u8 *opt_data, u16 len)
@@ -2787,9 +2821,9 @@
=20
if (con->c_status =3D=3D RES_SUCCESS) {
/* check status */
- printk("Now we got baseband, send echo req !\n");
+ D_XMIT("Now we got baseband, send echo req !\n");
} else {
- printk("Ping failed !\n");
+ D_ERR(__FUNCTION__ ": Ping failed !\n");
delete_con(con);
return -1;
}
@@ -2801,15 +2835,13 @@
=20
/* leave loop when either status failed or success */
while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
- printk("Sending echo req...\n");
+ D_XMIT("Sending echo req...\n");
l2cap_echo_req(con, opt_data, len);=09
/* wait until we received a response or after timeout */
=20
- printk("Waiting for response or timeout\n");
+ D_XMIT("Waiting for response or timeout\n");
=20
l2ca_wait(__FUNCTION__ ": wait echo resp", con);
-
- printk("Woke up after sending echo req\n");
}
=20
if (con->c_status =3D=3D CSTATUS_MAX_NO_RTX) {
@@ -2861,9 +2893,9 @@
=20=09=09
if (con->c_status =3D=3D RES_SUCCESS) {
/* check status */
- printk("Now we got baseband, send info req !\n");
+ D_XMIT("Now we got baseband, send info req !\n");
} else {
- printk("GetInfo failed ! [cstatus %d]\n",=20
+ D_ERR(__FUNCTION__": GetInfo failed ! [cstatus %d]\n",=20
con->c_status);
delete_con(con);
return -1;
@@ -2876,15 +2908,11 @@
=20
/* leave loop when either status failed or success */
while (con->c_status =3D=3D CSTATUS_RTX_TIMEOUT) {
- printk("Sending info req...\n");
+ D_XMIT("Sending info req...\n");
l2cap_info_req(con, infotype);=09
- /* wait until we received a response or after timeout */
-=09=09
- printk("Waiting for response or timeout\n");
=20
+ /* wait until we received a response or after timeout */
l2ca_wait(__FUNCTION__ ": wait echo resp", con);
-
- printk("Woke up after sending info req\n");
}
=20
return con->c_result;
@@ -2931,7 +2959,7 @@
#else /* Usermode stack */
=20
/* FIXME */
- printk("Use NO timer in usermode stack yet...\n");
+ D_ERR("Use NO timer in usermode stack yet...\n");
return;
#if 0
struct itimerval t =3D {{0,0},{timeout, 0}};
@@ -3010,7 +3038,7 @@
D_TIM("ERTX never started\n");
#else /* Usermode stack */
/* FIXME */
- printk("disable_ertx FIXME\n");
+ D_ERR("disable_ertx FIXME\n");
con->timer.ertx_inuse =3D 0;
con->timer.ertx_action =3D ERTX_ACTION_DISCONNECT;
#endif
|