Style cleanup(or not making it worse), fix some statistics(Monni)

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30767 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Oliver Ruiz Dorantes 2009-05-15 22:11:19 +00:00
parent 4ee70e3bba
commit 1343446530
4 changed files with 180 additions and 163 deletions

View File

@ -1,6 +1,6 @@
/*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
@ -12,8 +12,7 @@
#include <KernelExport.h>
#include <ByteOrder.h>
#include <Drivers.h>
#include <USB_spec.h>
#include <USB.h>
#include "snet_buffer.h"
@ -47,41 +46,46 @@ struct net_device_module_info* btDevices = NULL;
struct net_buffer_module_info* nb = NULL;
struct bluetooth_core_data_module_info* btCoreData = NULL;
/* Driver Global data */
// Driver Global data
static char *publish_names[MAX_BT_GENERIC_USB_DEVICES];
int32 dev_count = 0; /* number of connected devices */
static bt_usb_dev* bt_usb_devices[MAX_BT_GENERIC_USB_DEVICES];
sem_id dev_table_sem = -1; /* sem to synchronize access to device table */
int32 dev_count = 0; // number of connected devices
static bt_usb_dev* bt_usb_devices[MAX_BT_GENERIC_USB_DEVICES];
sem_id dev_table_sem = -1; // sem to synchronize access to device table
status_t submit_nbuffer(hci_id hid, net_buffer* nbuf);
usb_support_descriptor supported_devices[] =
{
/* Generic Bluetooth USB device */
/* Class, SubClass, and Protocol codes that describe a Bluetooth device */
// Generic Bluetooth USB device
// Class, SubClass, and Protocol codes that describe a Bluetooth device
{ UDCLASS_WIRELESS, UDSUBCLASS_RF, UDPROTO_BLUETOOTH , 0 , 0 },
/* Generic devices */
/* Broadcom BCM2035 */
// Broadcom BCM2035
{ 0, 0, 0, 0x0a5c, 0x200a },
{ 0, 0, 0, 0x0a5c, 0x2009 },
/* Devices taken from the linux Driver */
/* AVM BlueFRITZ! USB v2.0 */
// Devices taken from the linux Driver
// AVM BlueFRITZ! USB v2.0
{ 0, 0, 0, 0x057c , 0x3800 },
/* Bluetooth Ultraport Module from IBM */
// Bluetooth Ultraport Module from IBM
{ 0, 0, 0, 0x04bf , 0x030a },
/* ALPS Modules with non-standard id */
// ALPS Modules with non-standard id
{ 0, 0, 0, 0x044e , 0x3001 },
{ 0, 0, 0, 0x044e , 0x3002 },
/* Ericsson with non-standard id */
// Ericsson with non-standard id
{ 0, 0, 0, 0x0bdb , 0x1002 }
};
/* add a device to the list of connected devices */
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
static bt_usb_dev*
spawn_device(const usb_device* usb_dev)
spawn_device(usb_device usb_dev)
#else
static bt_usb_dev*
spawn_device(usb_device* usb_dev)
#endif
{
int32 i;
status_t err = B_OK;
@ -89,7 +93,7 @@ spawn_device(const usb_device* usb_dev)
flowf("add_device()\n");
/* 16 usb dongles... u are unsane */
// 16 usb dongles...
if (dev_count >= MAX_BT_GENERIC_USB_DEVICES) {
flowf("device table full\n");
goto exit;
@ -97,11 +101,11 @@ spawn_device(const usb_device* usb_dev)
/* try the allocation */
new_bt_dev = (bt_usb_dev*)malloc(sizeof(bt_usb_dev));
if ( new_bt_dev == NULL ) {
flowf("no memory allocating\n");
if (new_bt_dev == NULL) {
flowf("no memory\n");
goto exit;
}
memset(new_bt_dev, 0, sizeof(bt_usb_dev) );
memset(new_bt_dev, 0, sizeof(bt_usb_dev));
/* We will need this sem for some flow control */
new_bt_dev->cmd_complete = create_sem(1, BLUETOOTH_DEVICE_DEVFS_NAME "cmd_complete");
@ -210,8 +214,12 @@ fetch_device(bt_usb_dev* dev, hci_id hid)
/* called by USB Manager when device is added to the USB */
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
static status_t
device_added(const usb_device* dev, void** cookie)
device_added(usb_device dev, void** cookie)
#else
device_added(usb_device* dev, void** cookie)
#endif
{
const usb_interface_info* interface;
const usb_device_descriptor* desc;
@ -223,7 +231,7 @@ device_added(const usb_device* dev, void** cookie)
bt_usb_dev* new_bt_dev = spawn_device(dev);
int e;
debugf("device_added(%p, %p)\n", dev, new_bt_dev);
debugf("device_added(%ld, %p)\n", dev, new_bt_dev);
if (new_bt_dev == NULL) {
flowf("Couldn't allocate device record.\n");
@ -358,13 +366,13 @@ device_removed(void* cookie)
return B_ERROR;
}
if (!TEST_AND_CLEAR(&bdev->state, RUNNING) ) {
if (!TEST_AND_CLEAR(&bdev->state, RUNNING)) {
flowf(" wasnt running¿?\n");
}
flowf("Cancelling queues...\n");
if ( bdev->intr_in_ep != NULL ) {
if (bdev->intr_in_ep != NULL) {
usb->cancel_queued_transfers(bdev->intr_in_ep->handle);
flowf("Cancelling impossible EVENTS\n");
}
@ -455,7 +463,7 @@ device_open(const char *name, uint32 flags, void **cookie)
}
// Set RUNNING
if ( TEST_AND_SET(&bdev->state, ANCILLYANT) ) {
if (TEST_AND_SET(&bdev->state, RUNNING)) {
flowf("dev already running! - reOpened device!\n");
return B_ERROR;
}
@ -486,7 +494,7 @@ device_open(const char *name, uint32 flags, void **cookie)
// TODO: Fill the transport descriptor
err = btDevices->init_device(bdev->name, &ndev);
if ( err == B_OK ) {
if (err == B_OK) {
bdev->hdev = hdev = ndev->index; // get the index
bdev->ndev = ndev; // get the net_device
@ -645,7 +653,7 @@ device_control(void *cookie, uint32 msg, void *params, size_t size)
#if BT_DRIVER_SUPPORTS_ACL // ACL
for (i = 0; i < MAX_ACL_IN_WINDOW; i++) {
err = submit_rx_acl(bdev);
if (err != B_OK && i == 0 ) {
if (err != B_OK && i == 0) {
CLEAR_BIT(bdev->state, ANCILLYANT); // Set the flaq in the HCI world
flowf("Queuing failed device stops running\n");
break;

View File

@ -12,7 +12,12 @@
#include <net_device.h>
#include <OS.h>
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
#include <USB3.h>
#else
#include <USB_spec.h>
#include <USB.h>
#endif
#include <util/list.h>
#include <bluetooth/HCI/btHCI.h>
@ -54,7 +59,11 @@ extern struct bluetooth_core_data_module_info* btCoreData;
typedef struct bt_usb_dev bt_usb_dev;
struct bt_usb_dev {
const usb_device* dev; /* opaque handle */
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
usb_device dev; /* opaque handle */
#else
usb_device* dev; /* opaque handle */
#endif
hci_id hdev; /* HCI device id*/
struct net_device* ndev;

View File

@ -1,8 +1,7 @@
/*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#include "h2generic.h"
@ -38,13 +37,13 @@ void event_complete(void* cookie, status_t status, void* data, size_t actual_len
static status_t
assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count)
assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void* data, int count)
{
net_buffer* nbuf = NULL;
snet_buffer* snbuf = NULL;
net_buffer* nbuf = NULL;
snet_buffer* snbuf = NULL;
size_t currentPacketLen = 0;
size_t expectedPacketLen = 0;
size_t currentPacketLen = 0;
size_t expectedPacketLen = 0;
bdev->stat.bytesRX += count;
@ -55,43 +54,41 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count)
while (count) {
//debugf("count %d nb=%p sb=%p type=%d\n",count, nbuf, snbuf, type);
//debugf("count %d nb=%p sb=%p type=%d\n", count, nbuf, snbuf, type);
if ( (type != BT_EVENT && nbuf == NULL) ||
(type == BT_EVENT && (snbuf == NULL || snb_completed(snbuf))) ) {
if ((type != BT_EVENT && nbuf == NULL)
|| (type == BT_EVENT && (snbuf == NULL || snb_completed(snbuf)))) {
/* new buffer incoming */
switch (type) {
case BT_EVENT:
if (count >= HCI_EVENT_HDR_SIZE) {
struct hci_event_header* headerPkt = data;
expectedPacketLen = HCI_EVENT_HDR_SIZE + headerPkt->elen;
snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash, expectedPacketLen);
snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash,
expectedPacketLen);
} else {
flowf("EVENT frame corrupted\n");
return EILSEQ;
}
break;
break;
case BT_ACL:
if (count >= HCI_ACL_HDR_SIZE) {
int16 index;
struct hci_acl_header* headerPkt = data;
expectedPacketLen = HCI_ACL_HDR_SIZE + B_LENDIAN_TO_HOST_INT16(headerPkt->alen);
expectedPacketLen = HCI_ACL_HDR_SIZE
+ B_LENDIAN_TO_HOST_INT16(headerPkt->alen);
/* Create the buffer */
// Create the buffer -> TODO: this allocation can fail
bdev->nbufferRx[type] = nbuf = nb->create(expectedPacketLen);
// TODO: this allocation can fail!!
nbuf->protocol = type;
debugf("new ACL frame %p\n", nbuf);
debugf("### Incoming ACL: len = %d\n", count);
for (index = 0 ; index < count; index++ ) {
debugf("## Incoming ACL frame %p len = %d ", nbuf, count);
for (index = 0 ; index < count; index++)
dprintf("%x:",((uint8*)data)[index]);
}
flowf("### \n");
dprintf(" ## \n");
} else {
flowf("ACL frame corrupted\n");
@ -104,14 +101,14 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count)
break;
default:
panic("unkown packet type in assembly");
panic("unknown packet type in assembly");
break;
}
currentPacketLen = expectedPacketLen;
} else {
/* Continuation */
// Continuation of a packet
if (type != BT_EVENT)
currentPacketLen = get_expected_size(nbuf) - nbuf->size;
else
@ -125,20 +122,22 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count)
else
nb->append(nbuf, data, currentPacketLen);
/* Complete frame? */
// Complete frame?
if (type == BT_EVENT && snb_completed(snbuf)) {
post_packet_up(bdev, type, snbuf);
snbuf = bdev->eventRx = NULL;
}
if (type != BT_EVENT && (get_expected_size(nbuf) - nbuf->size) == 0 ) {
post_packet_up(bdev, type, nbuf);
bdev->nbufferRx[type] = nbuf = NULL;
} /*else {
} else {
#if DEBUG_ACL
if (type == BT_ACL)
debugf("ACL Packet not filled size=%ld expected=%ld\n", nbuf->size, get_expected_size(nbuf));
}*/
debugf("ACL Packet not filled size=%ld expected=%ld\n",
nbuf->size, get_expected_size(nbuf));
#endif
}
/* in case in the pipe there is info about the next buffer ... */
count -= currentPacketLen;
@ -162,16 +161,19 @@ event_complete(void* cookie, status_t status, void* data, size_t actual_len)
#endif
{
bt_usb_dev* bdev = cookie;
status_t err;
//bt_usb_dev* bdev = fetch_device(cookie, 0); -> safer/slower option
status_t error;
/* TODO: or not running anymore */
if (status == B_CANCELED)
if (bdev == NULL)
return;
if (status == B_CANCELED) // or not running anymore...
return;
if (status != B_OK || actual_len == 0)
goto resubmit;
if ( assembly_rx(cookie, BT_EVENT, data, actual_len) == B_OK ) {
if (assembly_rx(cookie, BT_EVENT, data, actual_len) == B_OK) {
bdev->stat.successfulTX++;
} else {
bdev->stat.errorRX++;
@ -179,18 +181,16 @@ event_complete(void* cookie, status_t status, void* data, size_t actual_len)
resubmit:
err = usb->queue_interrupt(bdev->intr_in_ep->handle,
data, bdev->max_packet_size_intr_in ,
event_complete, bdev);
error = usb->queue_interrupt(bdev->intr_in_ep->handle, data,
bdev->max_packet_size_intr_in, event_complete, bdev);
if (err != B_OK) {
if (error != B_OK) {
reuse_room(&bdev->eventRoom, data);
bdev->stat.rejectedRX++;
debugf("RX event resubmittion failed %s\n",strerror(err));
debugf("RX event resubmittion failed %s\n", strerror(error));
} else {
bdev->stat.acceptedRX++;
}
}
@ -202,10 +202,13 @@ acl_rx_complete(void* cookie, status_t status, void* data, size_t actual_len)
#endif
{
bt_usb_dev* bdev = cookie;
status_t err;
//bt_usb_dev* bdev = fetch_device(cookie, 0); -> safer/slower option
status_t error;
/* TODO: or not running anymore? */
if (status == B_CANCELED)
if (bdev == NULL)
return;
if (status == B_CANCELED) // or not running anymore...
return;
if (status != B_OK || actual_len == 0)
@ -219,14 +222,14 @@ acl_rx_complete(void* cookie, status_t status, void* data, size_t actual_len)
resubmit:
err = usb->queue_bulk(bdev->bulk_in_ep->handle, data,
max(HCI_MAX_FRAME_SIZE,bdev->max_packet_size_bulk_in),
acl_rx_complete, (void*) bdev);
error = usb->queue_bulk(bdev->bulk_in_ep->handle, data,
max(HCI_MAX_FRAME_SIZE, bdev->max_packet_size_bulk_in),
acl_rx_complete, (void*) bdev);
if (err != B_OK) {
if (error != B_OK) {
reuse_room(&bdev->aclRoom, data);
bdev->stat.rejectedRX++;
debugf("RX acl resubmittion failed %s\n", strerror(err));
debugf("RX acl resubmittion failed %s\n", strerror(error));
} else {
bdev->stat.acceptedRX++;
}
@ -239,16 +242,15 @@ resubmit:
status_t
submit_rx_event(bt_usb_dev* bdev)
{
status_t status;
size_t size = bdev->max_packet_size_intr_in;
void* buf = alloc_room(&bdev->eventRoom, size);
size_t size = bdev->max_packet_size_intr_in;
void* buf = alloc_room(&bdev->eventRoom, size);
status_t status;
if (buf == NULL)
return ENOMEM;
status = usb->queue_interrupt(bdev->intr_in_ep->handle,
buf, size ,
event_complete, (void*) bdev);
status = usb->queue_interrupt(bdev->intr_in_ep->handle, buf, size,
event_complete, (void*)bdev);
if (status != B_OK) {
reuse_room(&bdev->eventRoom, buf); // reuse allocated one
@ -264,19 +266,18 @@ submit_rx_event(bt_usb_dev* bdev)
status_t
submit_rx_acl(bt_usb_dev* bdev)
{
status_t status;
size_t size = max(HCI_MAX_FRAME_SIZE,bdev->max_packet_size_bulk_in);
void* buf = alloc_room(&bdev->aclRoom, size);
{
size_t size = max(HCI_MAX_FRAME_SIZE, bdev->max_packet_size_bulk_in);
void* buf = alloc_room(&bdev->aclRoom, size);
status_t status;
if (buf == NULL)
return ENOMEM;
status = usb->queue_bulk(bdev->bulk_in_ep->handle, buf, size ,
acl_rx_complete, bdev);
status = usb->queue_bulk(bdev->bulk_in_ep->handle, buf, size,
acl_rx_complete, bdev);
if (status != B_OK) {
if (status != B_OK) {
reuse_room(&bdev->aclRoom, buf); // reuse allocated
bdev->stat.rejectedRX++;
} else {
@ -290,12 +291,11 @@ submit_rx_acl(bt_usb_dev* bdev)
status_t
submit_rx_sco(bt_usb_dev* bdev)
{
/* not yet implemented */
return B_ERROR;
}
#if 0
#pragma mark --- TX Complete ---
#endif
@ -307,18 +307,17 @@ command_complete(void* cookie, uint32 status, void* data, uint32 actual_len)
command_complete(void* cookie, status_t status, void* data, size_t actual_len)
#endif
{
snet_buffer* snbuf = (snet_buffer*) cookie;
snet_buffer* snbuf = (snet_buffer*)cookie;
bt_usb_dev* bdev = snb_cookie(snbuf);
debugf("%ld @ %p\n", actual_len, data);
debugf("len = %ld @%p\n", actual_len, data);
if (status != B_OK) {
if (status == B_OK) {
bdev->stat.successfulTX++;
bdev->stat.bytesTX += actual_len;
} else {
bdev->stat.errorTX++;
/* the packet has been lost */
/* too late to requeue it? */
// the packet has been lost,too late to requeue it?
}
snb_park(&bdev->snetBufferRecycleTrash, snbuf);
@ -337,19 +336,17 @@ acl_tx_complete(void* cookie, uint32 status, void* data, uint32 actual_len)
acl_tx_complete(void* cookie, status_t status, void* data, size_t actual_len)
#endif
{
net_buffer* nbuf = (net_buffer*) cookie;
net_buffer* nbuf = (net_buffer*)cookie;
bt_usb_dev* bdev = GET_DEVICE(nbuf);
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.bytesTX += actual_len;
} else {
bdev->stat.errorTX++;
/* the packet has been lost */
/* too late to requeue it? */
// the packet has been lost,too late to requeue it?
}
nb_destroy(nbuf);
@ -365,13 +362,12 @@ acl_tx_complete(void* cookie, status_t status, void* data, size_t actual_len)
status_t
submit_tx_command(bt_usb_dev* bdev, snet_buffer* snbuf)
{
status_t err;
uint8 bRequestType = bdev->ctrl_req;
uint8 bRequest = 0;
uint16 wIndex = 0;
uint16 value = 0;
uint16 wLength = B_HOST_TO_LENDIAN_INT16(snb_size(snbuf));
uint8 bRequestType = bdev->ctrl_req;
uint8 bRequest = 0;
uint16 wIndex = 0;
uint16 value = 0;
uint16 wLength = B_HOST_TO_LENDIAN_INT16(snb_size(snbuf));
status_t error;
if (!GET_BIT(bdev->state, RUNNING)) {
return B_DEV_NOT_READY;
@ -382,30 +378,33 @@ submit_tx_command(bt_usb_dev* bdev, snet_buffer* snbuf)
debugf("@%p\n", snb_get(snbuf));
err = usb->queue_request(bdev->dev, bRequestType, bRequest,
value, wIndex, wLength,
snb_get(snbuf), wLength //???
,command_complete, (void*) snbuf);
error = usb->queue_request(bdev->dev, bRequestType, bRequest,
value, wIndex, wLength, snb_get(snbuf),
#ifndef HAIKU_TARGET_PLATFORM_HAIKU
wLength, //???
#endif
command_complete, (void*) snbuf);
if (err != B_OK ) {
if (error != B_OK) {
bdev->stat.rejectedTX++;
} else {
bdev->stat.acceptedTX++;
}
return err;
return error;
}
status_t
submit_tx_acl(bt_usb_dev* bdev, net_buffer* nbuf)
{
status_t err;
int32 index;
status_t error;
/* set cookie */
SET_DEVICE(nbuf, bdev->hdev);
if (!GET_BIT(bdev->state, RUNNING) ) {
if (!GET_BIT(bdev->state, RUNNING)) {
return B_DEV_NOT_READY;
}
@ -415,17 +414,16 @@ submit_tx_acl(bt_usb_dev* bdev, net_buffer* nbuf)
}
flowf("### \n");
err = usb->queue_bulk(bdev->bulk_out_ep->handle,
nb_get_whole_buffer(nbuf), nbuf->size,
acl_tx_complete, (void*) nbuf);
error = usb->queue_bulk(bdev->bulk_out_ep->handle, nb_get_whole_buffer(nbuf),
nbuf->size, acl_tx_complete, (void*)nbuf);
if (err != B_OK ) {
if (error != B_OK) {
bdev->stat.rejectedTX++;
} else {
bdev->stat.acceptedTX++;
}
return err;
return error;
}

View File

@ -1,11 +1,9 @@
/*
* Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
*
* Copyright 2008 Mika Lindqvist, monni1995_at_gmail.com
* All rights reserved. Distributed under the terms of the MIT License.
*
*/
#include <string.h>
#include <bluetooth/bluetooth.h>
@ -20,59 +18,61 @@
#include <btDebug.h>
/* TODO: split for commands and comunication(ACL&SCO) */
/* TODO: split for commands and comunication (ACL&SCO) */
void
sched_tx_processing(bt_usb_dev* bdev)
{
{
net_buffer* nbuf;
snet_buffer* snbuf;
status_t err;
debugf("(%p)\n", bdev)
net_buffer* nbuf;
snet_buffer* snbuf;
status_t err;
flowf("sched\n")
if (!TEST_AND_SET(&bdev->state, PROCESSING)) {
/* We are not processing in another thread so... START!! */
// We are not processing in another thread so... START!!
do {
/* Do while this bit is on... so someone should set it before we stop the iterations*/
/* Do while this bit is on... so someone should set it before we
* stop the iterations
*/
CLEAR_BIT(bdev->state, SENDING);
/* check Commands*/
// check Commands
#ifdef EMPTY_COMMAND_QUEUE
while (!list_is_empty(&bdev->nbuffersTx[BT_COMMAND]) ) {
while (!list_is_empty(&bdev->nbuffersTx[BT_COMMAND])) {
#else
if (!list_is_empty(&bdev->nbuffersTx[BT_COMMAND]) ) {
if (!list_is_empty(&bdev->nbuffersTx[BT_COMMAND])) {
#endif
snbuf = list_remove_head_item(&bdev->nbuffersTx[BT_COMMAND]);
err = submit_tx_command(bdev, snbuf);
if (err != B_OK) {
/* re-head it*/
// re-head it
list_insert_item_before(&bdev->nbuffersTx[BT_COMMAND],
list_get_first_item(&bdev->nbuffersTx[BT_COMMAND]), snbuf);
}
list_get_first_item(&bdev->nbuffersTx[BT_COMMAND]), snbuf);
}
}
/* check Acl */
// check ACl
#define EMPTY_ACL_QUEUE
#ifdef EMPTY_ACL_QUEUE
while (!list_is_empty(&bdev->nbuffersTx[BT_ACL]) ) {
while (!list_is_empty(&bdev->nbuffersTx[BT_ACL])) {
#else
if (!list_is_empty(&bdev->nbuffersTx[BT_ACL]) ) {
if (!list_is_empty(&bdev->nbuffersTx[BT_ACL])) {
#endif
nbuf = list_remove_head_item(&bdev->nbuffersTx[BT_ACL]);
err = submit_tx_acl(bdev, nbuf);
if (err != B_OK) {
/* re-head it*/
list_insert_item_before(&bdev->nbuffersTx[BT_ACL],
list_get_first_item(&bdev->nbuffersTx[BT_ACL]), nbuf);
}
list_get_first_item(&bdev->nbuffersTx[BT_ACL]), nbuf);
}
}
if (!list_is_empty(&bdev->nbuffersTx[BT_SCO]) ) {
if (!list_is_empty(&bdev->nbuffersTx[BT_SCO])) {
/* TODO to be implemented */
}
} while (GET_BIT(bdev->state, SENDING));
CLEAR_BIT(bdev->state, PROCESSING);
@ -81,28 +81,26 @@ sched_tx_processing(bt_usb_dev* bdev)
/* We are processing so MARK that we need to still go on with that ... */
SET_BIT(bdev->state, SENDING);
}
}
status_t
post_packet_up(bt_usb_dev* bdev, bt_packet_t type, void* buf)
{
status_t err = B_OK;
status_t err = B_ERROR;
debugf("Frame up type=%d\n", type);
err = B_ERROR;
if (type == BT_EVENT) {
snet_buffer* snbuf = (snet_buffer*) buf;
btCoreData->PostEvent(bdev->ndev, snb_get(snbuf), (size_t) snb_size(snbuf));
snet_buffer* snbuf = (snet_buffer*)buf;
flowf("to btDataCore\n");
btCoreData->PostEvent(bdev->ndev, snb_get(snbuf), (size_t)snb_size(snbuf));
snb_park(&bdev->snetBufferRecycleTrash, snbuf);
} else {
net_buffer* nbuf = (net_buffer*) buf;
/* No need to free the buffer at allocation is gonna be reused */
flowf("HCI not present for acl posting to net_device\n");
btDevices->receive_data(bdev->ndev, &nbuf);
flowf("to net_device\n");
btDevices->receive_data(bdev->ndev, &nbuf);
}
return err;
@ -133,7 +131,7 @@ send_packet(hci_id hid, bt_packet_t type, net_buffer* nbuf)
bdev->nbuffersPendingTx[type]++;
break;
default:
debugf("Unkown packet type for sending %d\n",type);
debugf("Unknown packet type for sending %d\n",type);
// TODO: free the net_buffer -> no, allow upper layer
// handle it with the given error
err = B_BAD_VALUE;
@ -144,9 +142,11 @@ send_packet(hci_id hid, bt_packet_t type, net_buffer* nbuf)
}
// TODO: check if device is actually ready for this
// TODO: unLock device
// TODO: unlock device
/* sched in All cases even if nbuf is null (hidden way to provoke re-scheduling)*/
/* sched in All cases even if nbuf is null (hidden way to provoke
* re-scheduling)
*/
sched_tx_processing(bdev);
return err;
@ -178,7 +178,9 @@ send_command(hci_id hid, snet_buffer* snbuf)
// TODO: check if device is actually ready for this
// TODO: mutex?
/* sched in All cases even if nbuf is null (hidden way to provoke re-scheduling)*/
/* sched in All cases even if nbuf is null (hidden way to provoke
* re-scheduling)
*/
sched_tx_processing(bdev);
return err;