* [Bluez-devel] Problem automatic flush timeout
@ 2008-08-22 2:41 Jui-Hao Chiang
2008-08-22 14:03 ` Jui-Hao Chiang
2008-08-23 19:33 ` [Bluez-devel] [Patch] Flush Occurred Event Jui-Hao Chiang
0 siblings, 2 replies; 5+ messages in thread
From: Jui-Hao Chiang @ 2008-08-22 2:41 UTC (permalink / raw)
To: bluez-devel
Hi,
Is there a way to simulate unreliable L2CAP socket in a client-server scenario?
(two PCs, each with single adapter; client sends 48 bytes packet to server every
1 second)
After establishing a L2CAP between two adapters, I tried to set the "automatic
flush timeout" on the client adapter with timeout to be 2. The hci_send_req is
successful, but after 7 to 8 seconds, the server adapter stops to receive any
data while client socket is still sending data. If I set it timeout to 4, then
everything is fine.
What I am imagining is "some data on client adapter may be flushed, but the
later packet should continue to be sent to server adapter".
Am I doing something wrong?
// build a command packet to send to the bluetooth microcontroller
cmd_param.handle = connection_handle;
cmd_param.flush_timeout = htobs(timeout);
rq.ogf = OGF_HOST_CTL;
rq.ocf = 0x28;
rq.cparam = &cmd_param;
rq.clen = sizeof(cmd_param);
rq.rparam = &cmd_response;
rq.rlen = sizeof(cmd_response);
rq.event = EVT_CMD_COMPLETE;
// send the command and wait for the response
err = hci_send_req( dd, &rq, 0 );
if( err ) goto cleanup;
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [Bluez-devel] Problem automatic flush timeout 2008-08-22 2:41 [Bluez-devel] Problem automatic flush timeout Jui-Hao Chiang @ 2008-08-22 14:03 ` Jui-Hao Chiang 2008-08-23 19:33 ` [Bluez-devel] [Patch] Flush Occurred Event Jui-Hao Chiang 1 sibling, 0 replies; 5+ messages in thread From: Jui-Hao Chiang @ 2008-08-22 14:03 UTC (permalink / raw) To: bluez-devel Hi, What I found in net/bluetooth/hci_core.c and net/bluetooth/hci_event.c are (1) the "Flush Occured Event" (ocf 0x11) is not handled in hci_event (2) while the user socket keeps pushing the data via l2cap_sock_sendmsg->l2cap_do_send->hci_send_acl ->hci_sched_tx->hci_tx_task->hci_sched_acl Eventually it stops in hci_sched_acl when checking hdev->acl_cnt. I consider that hdev->acl_cnt means: "the number of ACL packet we can push to hci_usb". Thus, I think the possible way to handle this event is to (1) add in "include/net/bluetooth/hci.h" #define HCI_EV_FLUSH_OCCURED 0x11 (2) catch the event in hci_event_packet, and do the following (same as hci_num_comp_pkts_evt) if ((++ hdev->acl_cnt) > hdev->acl_pkts) hdev->acl_cnt = hdev->acl_pkts; (3) decrement the conn->sent by atomic_sub(count, &conn->sent); Please correct me if I am wrong. Jui-Hao ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bluez-devel] [Patch] Flush Occurred Event 2008-08-22 2:41 [Bluez-devel] Problem automatic flush timeout Jui-Hao Chiang 2008-08-22 14:03 ` Jui-Hao Chiang @ 2008-08-23 19:33 ` Jui-Hao Chiang 2008-08-23 20:22 ` Marcel Holtmann 1 sibling, 1 reply; 5+ messages in thread From: Jui-Hao Chiang @ 2008-08-23 19:33 UTC (permalink / raw) To: bluez-devel > The following is a patch against 2.6.22 kernel to catch HCI "Flush Occurred" event. (meaningful for ACL; useless for SCO) One more thing to NOTICE is that the handle in the event packet from my adapter seems to be "Big Endian", so that I use ntohs to convert it. Normally it should be __le16_to_cpu(ev->handle) diff -r linux-source-2.6.22/include/net/bluetooth/hci_core.h patch-2.6.22/include/net/bluetooth/hci_core.h 27a28 > diff -r linux-source-2.6.22/include/net/bluetooth/hci.h patch-2.6.22/include/net/bluetooth/hci.h 587a588,595 > /* Flush Occurred Event JuiHao --*/ > #define HCI_EV_FLUSH_OCCURRED 0x11 > #define NUM_OF_FLUSH_PKT 0x1 > struct hci_ev_flush_occurred { > __le16 handle; > } __attribute__ ((packed)); > /* --Flush Occurred Event JuiHao */ > diff -r linux-source-2.6.22/net/bluetooth/hci_event.c patch-2.6.22/net/bluetooth/hci_event.c 854a855,882 > /* Flush Occurred packet JuiHao*/ > static inline void hci_flush_occurred_evt(struct hci_dev *hdev, struct sk_buff *skb) > { > struct hci_ev_flush_occurred *ev = (struct hci_ev_flush_occurred *) skb->data; > struct hci_conn *conn; > > tasklet_disable(&hdev->tx_task); > > BT_DBG("handle is %x, skb->len %d\n", ev->handle, skb->len); > > /* The handle returned is probably Big Endian such that __le16_to_cpu is useless*/ > conn = hci_conn_hash_lookup_handle(hdev, ntohs(ev->handle)); > > if (conn) { > atomic_sub(NUM_OF_FLUSH_PKT, &conn->sent); > > if (conn->type == ACL_LINK) { > if ((hdev->acl_cnt += NUM_OF_FLUSH_PKT) > hdev->acl_pkts) > hdev->acl_cnt = hdev->acl_pkts; > } > BT_DBG("conn %p type %d hdev->acl_cnt %d conn->sent %d", > conn, conn->type, hdev->acl_cnt, atomic_read(&conn->sent)); > } > hci_sched_tx(hdev); > > tasklet_enable(&hdev->tx_task); > } > 1289a1318,1322 > /* handle Flush Occurred Event JuiHao --*/ > case HCI_EV_FLUSH_OCCURRED: > hci_flush_occurred_evt(hdev, skb); > break; > /* -- handle Flush Occurred Event JuiHao */ Bests, Jui-Hao ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Bluez-devel] [Patch] Flush Occurred Event 2008-08-23 19:33 ` [Bluez-devel] [Patch] Flush Occurred Event Jui-Hao Chiang @ 2008-08-23 20:22 ` Marcel Holtmann 2008-08-23 21:13 ` Jui-Hao Chiang 0 siblings, 1 reply; 5+ messages in thread From: Marcel Holtmann @ 2008-08-23 20:22 UTC (permalink / raw) To: BlueZ development Hi, > The following is a patch against 2.6.22 kernel to catch HCI "Flush Occurred" > event. (meaningful for ACL; useless for SCO) > > One more thing to NOTICE is that the handle in the event packet from my adapter > seems to be "Big Endian", so that I use ntohs to convert it. > Normally it should be __le16_to_cpu(ev->handle) against 2.6.27-rc4 please and in unified diff format. I am not even going to bother reading context diffs. Regards Marcel ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [Bluez-devel] [Patch] Flush Occurred Event 2008-08-23 20:22 ` Marcel Holtmann @ 2008-08-23 21:13 ` Jui-Hao Chiang 0 siblings, 0 replies; 5+ messages in thread From: Jui-Hao Chiang @ 2008-08-23 21:13 UTC (permalink / raw) To: bluez-devel Hi, Marcel, please see if it is ok Marcel Holtmann <marcel <at> holtmann.org> writes: > > against 2.6.27-rc4 please and in unified diff format. I am not even > going to bother reading context diffs. > > Regards > > Marcel diff -ru orig/include/net/bluetooth/hci.h new/include/net/bluetooth/hci.h --- orig/include/net/bluetooth/hci.h 2008-08-23 11:42:08.000000000 -0400 +++ new/include/net/bluetooth/hci.h 2008-08-23 11:44:22.000000000 -0400 @@ -682,6 +682,12 @@ __le16 opcode; } __attribute__ ((packed)); +#define HCI_EV_FLUSH_OCCURRED 0x11 +#define NUM_OF_FLUSH_PKT 0x1 +struct hci_ev_flush_occurred { + __le16 handle; +} __attribute__ ((packed)); + #define HCI_EV_ROLE_CHANGE 0x12 struct hci_ev_role_change { __u8 status; diff -ru orig/net/bluetooth/hci_event.c new/net/bluetooth/hci_event.c --- orig/net/bluetooth/hci_event.c 2008-08-23 11:42:12.000000000 -0400 +++ new/net/bluetooth/hci_event.c 2008-08-23 11:50:36.000000000 -0400 @@ -1398,6 +1398,32 @@ hci_dev_unlock(hdev); } +static inline void hci_flush_occurred_evt(struct hci_dev *hdev, struct sk_buff *skb) +{ + struct hci_ev_flush_occurred *ev = (struct hci_ev_flush_occurred *) skb->data; + struct hci_conn *conn; + + tasklet_disable(&hdev->tx_task); + + BT_DBG("handle is %x, skb->len %d\n", ev->handle, skb->len); + + conn = hci_conn_hash_lookup_handle(hdev, __le16_to_cpu(ev->handle)); + + if (conn) { + atomic_sub(NUM_OF_FLUSH_PKT, &conn->sent); + + if (conn->type == ACL_LINK) { + if ((hdev->acl_cnt += NUM_OF_FLUSH_PKT) > hdev->acl_pkts) + hdev->acl_cnt = hdev->acl_pkts; + } + BT_DBG("conn %p type %d hdev->acl_cnt %d conn->sent %d", + conn, conn->type, hdev->acl_cnt, atomic_read(&conn->sent)); + } + hci_sched_tx(hdev); + + tasklet_enable(&hdev->tx_task); +} + static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb) { struct hci_ev_num_comp_pkts *ev = (void *) skb->data; @@ -1894,6 +1920,10 @@ hci_remote_host_features_evt(hdev, skb); break; + case HCI_EV_FLUSH_OCCURRED: + hci_flush_occurred_evt(hdev, skb); + break; + default: BT_DBG("%s event 0x%x", hdev->name, event); break; ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Bluez-devel mailing list Bluez-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bluez-devel ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-08-23 21:13 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2008-08-22 2:41 [Bluez-devel] Problem automatic flush timeout Jui-Hao Chiang 2008-08-22 14:03 ` Jui-Hao Chiang 2008-08-23 19:33 ` [Bluez-devel] [Patch] Flush Occurred Event Jui-Hao Chiang 2008-08-23 20:22 ` Marcel Holtmann 2008-08-23 21:13 ` Jui-Hao Chiang
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox