- Schedule event interrupt transfer with the maximun possible event size, => reduces the number of callbacks for bigger packages

- Add debug options for dumping incoming usb buffers
- Styling



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32721 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes
2009-08-26 17:50:41 +00:00
parent 4c72b8cf43
commit 3f664b99dc
2 changed files with 44 additions and 35 deletions
@@ -269,10 +269,13 @@ device_added(usb_device* dev, void** cookie)
/* Place to find out whats our concrete device and set up some special info to our driver */ /* Place to find out whats our concrete device and set up some special info to our driver */
/* TODO: if this code increases too much reconsider this implementation*/ /* TODO: if this code increases too much reconsider this implementation*/
desc = usb->get_device_descriptor(dev); desc = usb->get_device_descriptor(dev);
if ( desc->vendor_id == 0x0a5c && (desc->product_id == 0x200a || if (desc->vendor_id == 0x0a5c
desc->product_id == 0x2009 || && (desc->product_id == 0x200a
desc->product_id == 0x2035 )) { || desc->product_id == 0x2009
|| desc->product_id == 0x2035)) {
new_bt_dev->driver_info = BT_WILL_NEED_A_RESET | BT_SCO_NOT_WORKING; new_bt_dev->driver_info = BT_WILL_NEED_A_RESET | BT_SCO_NOT_WORKING;
} }
/* /*
else if ( desc->vendor_id == YOUR_VENDOR_HERE && desc->product_id == YOUR_PRODUCT_HERE ) { else if ( desc->vendor_id == YOUR_VENDOR_HERE && desc->product_id == YOUR_PRODUCT_HERE ) {
@@ -287,7 +290,8 @@ device_added(usb_device* dev, void** cookie)
// security check // security check
if (config->interface->active->descr->interface_number > 0){ if (config->interface->active->descr->interface_number > 0){
debugf("Strange condition happened %d\n", config->interface->active->descr->interface_number); debugf("Strange condition happened %d\n",
config->interface->active->descr->interface_number);
err = B_ERROR; err = B_ERROR;
goto bail; goto bail;
} }
@@ -298,8 +302,7 @@ device_added(usb_device* dev, void** cookie)
for (e = 0; e < uif->descr->num_endpoints; e++) { for (e = 0; e < uif->descr->num_endpoints; e++) {
ep = &uif->endpoint[e]; ep = &uif->endpoint[e];
switch (ep->descr->attributes & USB_ENDPOINT_ATTR_MASK) switch (ep->descr->attributes & USB_ENDPOINT_ATTR_MASK) {
{
case USB_ENDPOINT_ATTR_INTERRUPT: case USB_ENDPOINT_ATTR_INTERRUPT:
if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN)
{ {
@@ -314,11 +317,11 @@ device_added(usb_device* dev, void** cookie)
case USB_ENDPOINT_ATTR_BULK: case USB_ENDPOINT_ATTR_BULK:
if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) { if (ep->descr->endpoint_address & USB_ENDPOINT_ADDR_DIR_IN) {
new_bt_dev->bulk_in_ep = ep; new_bt_dev->bulk_in_ep = ep;
new_bt_dev->max_packet_size_bulk_in = ep->descr->max_packet_size;; new_bt_dev->max_packet_size_bulk_in = ep->descr->max_packet_size;
flowf("BULK int\n"); flowf("BULK int\n");
} else { } else {
new_bt_dev->bulk_out_ep = ep; new_bt_dev->bulk_out_ep = ep;
new_bt_dev->max_packet_size_bulk_out = ep->descr->max_packet_size;; new_bt_dev->max_packet_size_bulk_out = ep->descr->max_packet_size;
flowf("BULK out\n"); flowf("BULK out\n");
} }
break; break;
@@ -341,7 +344,7 @@ device_added(usb_device* dev, void** cookie)
/* set the cookie that will be passed to other USB /* set the cookie that will be passed to other USB
hook functions (currently device_removed() is the only other) */ hook functions (currently device_removed() is the only other) */
*cookie = new_bt_dev; *cookie = new_bt_dev;
debugf("Ok %p\n",bt_usb_devices[0]); debugf("Ok %p\n", new_bt_dev);
return B_OK; return B_OK;
bail: bail:
@@ -362,14 +365,12 @@ device_removed(void* cookie)
debugf("device_removed(%p)\n", bdev); debugf("device_removed(%p)\n", bdev);
if (bdev == NULL) { if (bdev == NULL) {
flowf(" not present in driver¿?\n"); flowf(" not present in driver?\n");
return B_ERROR; return B_ERROR;
} }
if (!TEST_AND_CLEAR(&bdev->state, RUNNING)) { if (!TEST_AND_CLEAR(&bdev->state, RUNNING))
flowf(" wasnt running¿?\n"); flowf("wasnt running?\n");
}
flowf("Cancelling queues...\n"); flowf("Cancelling queues...\n");
if (bdev->intr_in_ep != NULL) { if (bdev->intr_in_ep != NULL) {
@@ -389,7 +390,6 @@ device_removed(void* cookie)
bdev->connected = false; bdev->connected = false;
return B_OK; return B_OK;
} }
@@ -412,10 +412,11 @@ submit_nbuffer(hci_id hid, net_buffer* nbuf)
bdev = fetch_device(NULL, hid); bdev = fetch_device(NULL, hid);
debugf("index=%lx nbuf=%p bdev=%p\n",hid, nbuf, bdev); debugf("index=%lx nbuf=%p bdev=%p\n",hid, nbuf, bdev);
if (bdev != NULL) { if (bdev != NULL) {
switch (nbuf->protocol) { switch (nbuf->protocol) {
case BT_COMMAND: case BT_COMMAND:
// not issed this way // not issued this way
break; break;
case BT_ACL: case BT_ACL:
@@ -496,10 +497,11 @@ device_open(const char *name, uint32 flags, void **cookie)
bdev->hdev = hdev = ndev->index; // get the index bdev->hdev = hdev = ndev->index; // get the index
bdev->ndev = ndev; // get the net_device bdev->ndev = ndev; // get the net_device
ndev->media = (uint32) submit_nbuffer; //XXX: interlayer-Hack ndev->media = (uint32)submit_nbuffer; //XXX: interlayer-Hack
} else } else {
hdev = bdev->num; /* XXX: Lets try to go on*/ hdev = bdev->num; /* XXX: Lets try to go on*/
}
} else { } else {
hdev = bdev->num; /* XXX: Lets try to go on*/ hdev = bdev->num; /* XXX: Lets try to go on*/
} }
@@ -576,7 +578,7 @@ device_close(void *cookie)
// unSet RUNNING // unSet RUNNING
if (TEST_AND_CLEAR(&bdev->state, RUNNING)) { if (TEST_AND_CLEAR(&bdev->state, RUNNING)) {
debugf(" %s not running¿?\n",bdev->name); debugf(" %s not running?\n",bdev->name);
return B_ERROR; return B_ERROR;
} }
@@ -850,7 +852,7 @@ uninit_driver(void)
// if (connected_dev != NULL) { // if (connected_dev != NULL) {
// debugf("Device %p still exists.\n", connected_dev); // debugf("Device %p still exists.\n", connected_dev);
// } // }
debugf("%s still present¿?\n",bt_usb_devices[j]->name); debugf("%s still present?\n",bt_usb_devices[j]->name);
kill_device(bt_usb_devices[j]); kill_device(bt_usb_devices[j]);
} }
} }
@@ -17,6 +17,7 @@
#include <string.h> #include <string.h>
//#define DUMP_BUFFERS
#define BT_DEBUG_THIS_MODULE #define BT_DEBUG_THIS_MODULE
#include <btDebug.h> #include <btDebug.h>
@@ -44,7 +45,9 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
size_t currentPacketLen = 0; size_t currentPacketLen = 0;
size_t expectedPacketLen = 0; size_t expectedPacketLen = 0;
#ifdef DUMP_BUFFERS
int16 index;
#endif
bdev->stat.bytesRX += count; bdev->stat.bytesRX += count;
if (type == BT_EVENT) if (type == BT_EVENT)
@@ -67,6 +70,12 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
expectedPacketLen = HCI_EVENT_HDR_SIZE + headerPkt->elen; expectedPacketLen = HCI_EVENT_HDR_SIZE + headerPkt->elen;
snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash, snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash,
expectedPacketLen); expectedPacketLen);
#ifdef DUMP_BUFFERS
debugf("## Incoming EVENT frame %p len = %d ", snbuf, count);
for (index = 0 ; index < count; index++)
dprintf("%x:",((uint8*)data)[index]);
dprintf(" ## \n");
#endif
} else { } else {
flowf("EVENT frame corrupted\n"); flowf("EVENT frame corrupted\n");
return EILSEQ; return EILSEQ;
@@ -75,7 +84,6 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
case BT_ACL: case BT_ACL:
if (count >= HCI_ACL_HDR_SIZE) { if (count >= HCI_ACL_HDR_SIZE) {
int16 index;
struct hci_acl_header* headerPkt = data; struct hci_acl_header* headerPkt = data;
expectedPacketLen = HCI_ACL_HDR_SIZE expectedPacketLen = HCI_ACL_HDR_SIZE
@@ -84,12 +92,12 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
// Create the buffer -> TODO: this allocation can fail // Create the buffer -> TODO: this allocation can fail
bdev->nbufferRx[type] = nbuf = nb->create(expectedPacketLen); bdev->nbufferRx[type] = nbuf = nb->create(expectedPacketLen);
nbuf->protocol = type; nbuf->protocol = type;
#ifdef DUMP_BUFFERS
debugf("## Incoming ACL frame %p len = %d ", nbuf, count); debugf("## Incoming ACL frame %p len = %d ", nbuf, count);
for (index = 0 ; index < count; index++) for (index = 0 ; index < count; index++)
dprintf("%x:",((uint8*)data)[index]); dprintf("%x:",((uint8*)data)[index]);
dprintf(" ## \n"); dprintf(" ## \n");
#endif
} else { } else {
flowf("ACL frame corrupted\n"); flowf("ACL frame corrupted\n");
return EILSEQ; return EILSEQ;
@@ -184,7 +192,7 @@ event_complete(void* cookie, status_t status, void* data, size_t actual_len)
resubmit: resubmit:
error = usb->queue_interrupt(bdev->intr_in_ep->handle, data, error = usb->queue_interrupt(bdev->intr_in_ep->handle, data,
bdev->max_packet_size_intr_in, event_complete, bdev); max(HCI_MAX_EVENT_SIZE, bdev->max_packet_size_intr_in), event_complete, bdev);
if (error != B_OK) { if (error != B_OK) {
reuse_room(&bdev->eventRoom, data); reuse_room(&bdev->eventRoom, data);
@@ -244,7 +252,7 @@ resubmit:
status_t status_t
submit_rx_event(bt_usb_dev* bdev) submit_rx_event(bt_usb_dev* bdev)
{ {
size_t size = bdev->max_packet_size_intr_in; size_t size = max(HCI_MAX_EVENT_SIZE, bdev->max_packet_size_intr_in);
void* buf = alloc_room(&bdev->eventRoom, size); void* buf = alloc_room(&bdev->eventRoom, size);
status_t status; status_t status;
@@ -293,7 +301,6 @@ submit_rx_acl(bt_usb_dev* bdev)
status_t status_t
submit_rx_sco(bt_usb_dev* bdev) submit_rx_sco(bt_usb_dev* bdev)
{ {
/* not yet implemented */ /* not yet implemented */
return B_ERROR; return B_ERROR;
} }
@@ -341,7 +348,7 @@ acl_tx_complete(void* cookie, status_t status, void* data, size_t actual_len)
net_buffer* nbuf = (net_buffer*)cookie; net_buffer* nbuf = (net_buffer*)cookie;
bt_usb_dev* bdev = GET_DEVICE(nbuf); bt_usb_dev* bdev = GET_DEVICE(nbuf);
debugf("fetched=%p status=%ld nbuftype %lx B%p\n",bdev, status, nbuf->type, data); debugf("fetched=%p status=%ld nbuftype %lx B%p\n", bdev, status, nbuf->type, data);
if (status == B_OK) { if (status == B_OK) {
bdev->stat.successfulTX++; bdev->stat.successfulTX++;