- Fix the calculation of the expected size of a packet
- Enabling all net_buffers code & ACL - Asume contiguusness for outgoing packets - Fix incorrect cleaning of btDevices - Posting ACL data to the net_device Kernel module. Sumarizing this enables ACL tranmision mode in the driver which starts to be "real network data" of the bt protocols not configuration as we had before git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26638 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -11,9 +11,11 @@
|
|||||||
|
|
||||||
#define BT_DRIVER_SUPPORTS_CMD 1
|
#define BT_DRIVER_SUPPORTS_CMD 1
|
||||||
#define BT_DRIVER_SUPPORTS_EVT 1
|
#define BT_DRIVER_SUPPORTS_EVT 1
|
||||||
#define BT_DRIVER_SUPPORTS_ESCO 0
|
#define BT_DRIVER_SUPPORTS_ACL 1
|
||||||
#define BT_DRIVER_SUPPORTS_SCO 0
|
#define BT_DRIVER_SUPPORTS_SCO 0
|
||||||
#define BT_DRIVER_SUPPORTS_ACL 0
|
#define BT_DRIVER_SUPPORTS_ESCO 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* TODO: move exclusive header for drivers*/
|
/* TODO: move exclusive header for drivers*/
|
||||||
#define BT_DRIVER_RXCOVERAGE (BT_DRIVER_SUPPORTS_EVT+BT_DRIVER_SUPPORTS_ACL+BT_DRIVER_SUPPORTS_SCO+BT_DRIVER_SUPPORTS_ESCO)
|
#define BT_DRIVER_RXCOVERAGE (BT_DRIVER_SUPPORTS_EVT+BT_DRIVER_SUPPORTS_ACL+BT_DRIVER_SUPPORTS_SCO+BT_DRIVER_SUPPORTS_ESCO)
|
||||||
@@ -24,7 +26,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BT_SURVIVE_WITHOUT_HCI
|
#define BT_SURVIVE_WITHOUT_HCI
|
||||||
#define BT_SURVIVE_WITHOUT_NET_BUFFERS
|
//#define BT_SURVIVE_WITHOUT_NET_BUFFERS
|
||||||
|
|
||||||
////////////////////////////////////
|
////////////////////////////////////
|
||||||
|
|
||||||
|
|||||||
@@ -432,13 +432,13 @@ device_open(const char *name, uint32 flags, void **cookie)
|
|||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
acquire_sem(bdev->lock);
|
|
||||||
// Set RUNNING
|
// Set RUNNING
|
||||||
if ( TEST_AND_SET(&bdev->state, ANCILLYANT) ) {
|
if ( TEST_AND_SET(&bdev->state, ANCILLYANT) ) {
|
||||||
flowf("dev already running! - reOpened device!\n");
|
flowf("dev already running! - reOpened device!\n");
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
acquire_sem(bdev->lock);
|
||||||
// TX structures
|
// TX structures
|
||||||
for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) {
|
for (i = 0; i < BT_DRIVER_TXCOVERAGE; i++) {
|
||||||
list_init(&bdev->nbuffersTx[i]);
|
list_init(&bdev->nbuffersTx[i]);
|
||||||
@@ -476,11 +476,9 @@ device_open(const char *name, uint32 flags, void **cookie)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bdev->hdev = hdev;
|
bdev->hdev = hdev;
|
||||||
|
|
||||||
|
|
||||||
|
*cookie = bdev;
|
||||||
*cookie = bdev;
|
release_sem(bdev->lock);
|
||||||
release_sem(bdev->lock);
|
|
||||||
|
|
||||||
flowf(" successful\n");
|
flowf(" successful\n");
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@@ -573,8 +571,11 @@ device_control(void *cookie, uint32 msg, void *params, size_t size)
|
|||||||
status_t err = B_ERROR;
|
status_t err = B_ERROR;
|
||||||
bt_usb_dev* bdev = (bt_usb_dev*)cookie;
|
bt_usb_dev* bdev = (bt_usb_dev*)cookie;
|
||||||
snet_buffer* snbuf;
|
snet_buffer* snbuf;
|
||||||
|
#if BT_DRIVER_SUPPORTS_ACL // ACL
|
||||||
|
int32 i;
|
||||||
|
#endif
|
||||||
|
|
||||||
TOUCH(size);
|
TOUCH(size);
|
||||||
|
|
||||||
debugf("ioctl() opcode %ld size %ld.\n", msg, size);
|
debugf("ioctl() opcode %ld size %ld.\n", msg, size);
|
||||||
|
|
||||||
if (bdev == NULL) {
|
if (bdev == NULL) {
|
||||||
@@ -752,7 +753,7 @@ err_release:
|
|||||||
err_release1:
|
err_release1:
|
||||||
put_module(hci_name);
|
put_module(hci_name);
|
||||||
err_release2:
|
err_release2:
|
||||||
put_module(hci_name);
|
put_module(btDevices_name);
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,8 +39,7 @@ void event_complete(void* cookie, status_t status, void* data, size_t actual_len
|
|||||||
|
|
||||||
static status_t
|
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;
|
net_buffer* nbuf = NULL;
|
||||||
snet_buffer* snbuf = NULL;
|
snet_buffer* snbuf = NULL;
|
||||||
|
|
||||||
@@ -56,8 +55,7 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count)
|
|||||||
|
|
||||||
while (count) {
|
while (count) {
|
||||||
|
|
||||||
debugf("count %d %p %p\n",count, nbuf, nb);
|
debugf("count %d nb=%p sb=%p type=%d\n",count, nbuf, snbuf, type);
|
||||||
|
|
||||||
|
|
||||||
if ( (type != BT_EVENT && nbuf == NULL) ||
|
if ( (type != BT_EVENT && nbuf == NULL) ||
|
||||||
(type == BT_EVENT && (snbuf == NULL || snb_completed(snbuf))) ) {
|
(type == BT_EVENT && (snbuf == NULL || snb_completed(snbuf))) ) {
|
||||||
@@ -70,7 +68,7 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count)
|
|||||||
struct hci_event_header* headerPkt = data;
|
struct hci_event_header* headerPkt = data;
|
||||||
expectedPacketLen = HCI_EVENT_HDR_SIZE + headerPkt->elen;
|
expectedPacketLen = HCI_EVENT_HDR_SIZE + headerPkt->elen;
|
||||||
snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash, expectedPacketLen);
|
snbuf = bdev->eventRx = snb_fetch(&bdev->snetBufferRecycleTrash, expectedPacketLen);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
flowf("EVENT frame corrupted\n");
|
flowf("EVENT frame corrupted\n");
|
||||||
return -EILSEQ;
|
return -EILSEQ;
|
||||||
@@ -79,15 +77,22 @@ 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 + 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 */
|
||||||
bdev->nbufferRx[type] = nbuf = nb->create(expectedPacketLen);
|
bdev->nbufferRx[type] = nbuf = nb->create(expectedPacketLen);
|
||||||
|
// TODO: this allocation can fail!!
|
||||||
nbuf->protocol = type;
|
nbuf->protocol = type;
|
||||||
|
debugf("new ACL frame %p\n", nbuf);
|
||||||
|
debugf("### Incoming ACL: len = %d\n", count);
|
||||||
|
for (index = 0 ; index < count; index++ ) {
|
||||||
|
dprintf("%x:",((uint8*)data)[index]);
|
||||||
|
}
|
||||||
|
flowf("### \n");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
flowf("ACL frame corrupted\n");
|
flowf("ACL frame corrupted\n");
|
||||||
return -EILSEQ;
|
return -EILSEQ;
|
||||||
@@ -100,21 +105,7 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count)
|
|||||||
default:
|
default:
|
||||||
panic("unkown packet type in assembly");
|
panic("unkown packet type in assembly");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
if (nb == NULL) {
|
|
||||||
port_id port;
|
|
||||||
/* Coded for test purpose only we should panic here */
|
|
||||||
debugf("net_buffers are not ready post manually %d/%d\n",count,expectedPacketLen);
|
|
||||||
port = find_port(BT_USERLAND_PORT_NAME);
|
|
||||||
if (port != B_NAME_NOT_FOUND) {
|
|
||||||
(void)write_port(port, PACK_HEADER_PORT(bdev->num,type), data, count);
|
|
||||||
return B_OK;
|
|
||||||
}
|
|
||||||
panic("Algorithm just ready to arrive here");
|
|
||||||
return B_ERROR;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
currentPacketLen = expectedPacketLen;
|
currentPacketLen = expectedPacketLen;
|
||||||
|
|
||||||
@@ -136,8 +127,7 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count)
|
|||||||
|
|
||||||
/* Complete frame? */
|
/* Complete frame? */
|
||||||
if (type == BT_EVENT && snb_completed(snbuf)) {
|
if (type == BT_EVENT && snb_completed(snbuf)) {
|
||||||
|
|
||||||
flowf("Frame goes up!\n");
|
|
||||||
post_packet_up(bdev, type, snbuf);
|
post_packet_up(bdev, type, snbuf);
|
||||||
snbuf = bdev->eventRx = NULL;
|
snbuf = bdev->eventRx = NULL;
|
||||||
|
|
||||||
@@ -145,10 +135,12 @@ assembly_rx(bt_usb_dev* bdev, bt_packet_t type, void *data, int count)
|
|||||||
|
|
||||||
if (type != BT_EVENT && (get_expected_size(nbuf) - nbuf->size) == 0 ) {
|
if (type != BT_EVENT && (get_expected_size(nbuf) - nbuf->size) == 0 ) {
|
||||||
|
|
||||||
flowf("Frame goes up!\n");
|
|
||||||
post_packet_up(bdev, type, nbuf);
|
post_packet_up(bdev, type, nbuf);
|
||||||
bdev->nbufferRx[type] = nbuf = NULL;
|
bdev->nbufferRx[type] = nbuf = NULL;
|
||||||
}
|
} /*else {
|
||||||
|
if (type == BT_ACL)
|
||||||
|
debugf("ACL Packet not filled size=%ld expected=%ld\n", nbuf->size, get_expected_size(nbuf));
|
||||||
|
}*/
|
||||||
|
|
||||||
/* in case in the pipe there is info about the next buffer ... */
|
/* in case in the pipe there is info about the next buffer ... */
|
||||||
count -= currentPacketLen;
|
count -= currentPacketLen;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include <bluetooth/bluetooth.h>
|
#include <bluetooth/bluetooth.h>
|
||||||
#include <bluetooth/HCI/btHCI_transport.h>
|
#include <bluetooth/HCI/btHCI_transport.h>
|
||||||
|
|
||||||
|
#include "h2generic.h"
|
||||||
#include "h2upper.h"
|
#include "h2upper.h"
|
||||||
#include "h2transactions.h"
|
#include "h2transactions.h"
|
||||||
#include "snet_buffer.h"
|
#include "snet_buffer.h"
|
||||||
@@ -89,6 +90,8 @@ post_packet_up(bt_usb_dev* bdev, bt_packet_t type, void* buf)
|
|||||||
|
|
||||||
status_t err = B_OK;
|
status_t err = B_OK;
|
||||||
port_id port;
|
port_id port;
|
||||||
|
|
||||||
|
debugf("Frame up type=%d\n", type);
|
||||||
|
|
||||||
if (hci == NULL) {
|
if (hci == NULL) {
|
||||||
|
|
||||||
@@ -99,22 +102,28 @@ post_packet_up(bt_usb_dev* bdev, bt_packet_t type, void* buf)
|
|||||||
|
|
||||||
snet_buffer* snbuf = (snet_buffer*) buf;
|
snet_buffer* snbuf = (snet_buffer*) buf;
|
||||||
|
|
||||||
flowf("HCI not present, Posting to userland\n");
|
flowf("HCI not present for event, Posting to userland\n");
|
||||||
port = find_port(BT_USERLAND_PORT_NAME);
|
port = find_port(BT_USERLAND_PORT_NAME);
|
||||||
if (port != B_NAME_NOT_FOUND) {
|
if (port != B_NAME_NOT_FOUND) {
|
||||||
|
|
||||||
|
err = write_port_etc(port, PACK_PORTCODE(type,bdev->hdev, -1),
|
||||||
err = write_port_etc(port, PACK_PORTCODE(type,bdev->hdev, -1),
|
|
||||||
snb_get(snbuf), snb_size(snbuf), B_TIMEOUT, 1*1000*1000);
|
snb_get(snbuf), snb_size(snbuf), B_TIMEOUT, 1*1000*1000);
|
||||||
if (err != B_OK)
|
if (err != B_OK)
|
||||||
debugf("Error posting userland %s\n", strerror(err));
|
debugf("Error posting userland %s\n", strerror(err));
|
||||||
|
|
||||||
|
snb_park(&bdev->snetBufferRecycleTrash, snbuf);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
flowf("ERROR:bluetooth_server not found for posting\n");
|
flowf("ERROR:bluetooth_server not found for posting\n");
|
||||||
err = B_NAME_NOT_FOUND;
|
err = B_NAME_NOT_FOUND;
|
||||||
}
|
}
|
||||||
/* No need to free the buffer at allocation is gonna be reused */
|
} 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);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -126,6 +135,7 @@ post_packet_up(bt_usb_dev* bdev, bt_packet_t type, void* buf)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
status_t
|
status_t
|
||||||
send_packet(hci_id hid, bt_packet_t type, net_buffer* nbuf)
|
send_packet(hci_id hid, bt_packet_t type, net_buffer* nbuf)
|
||||||
{
|
{
|
||||||
@@ -146,7 +156,6 @@ send_packet(hci_id hid, bt_packet_t type, net_buffer* nbuf)
|
|||||||
case BT_COMMAND:
|
case BT_COMMAND:
|
||||||
case BT_ACL:
|
case BT_ACL:
|
||||||
case BT_SCO:
|
case BT_SCO:
|
||||||
|
|
||||||
list_add_item(&bdev->nbuffersTx[type],nbuf);
|
list_add_item(&bdev->nbuffersTx[type],nbuf);
|
||||||
bdev->nbuffersPendingTx[type]++;
|
bdev->nbuffersPendingTx[type]++;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -24,19 +24,17 @@ nb_get_whole_buffer(net_buffer* nbuf)
|
|||||||
{
|
{
|
||||||
void* conPointer;
|
void* conPointer;
|
||||||
status_t err;
|
status_t err;
|
||||||
|
#if 0
|
||||||
/* the job could be already done */
|
/* the job could be already done */
|
||||||
// !!! it could be trash from other upper protocols...
|
// !!! it could be trash from other upper protocols...
|
||||||
if (nbuf->COOKIEFIELD != NULL)
|
if (nbuf->COOKIEFIELD != NULL)
|
||||||
return (void*)nbuf->COOKIEFIELD;
|
return (void*)nbuf->COOKIEFIELD;
|
||||||
|
#endif
|
||||||
if (nb == NULL)
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
err = nb->direct_access(nbuf, 0, nbuf->size, &conPointer);
|
err = nb->direct_access(nbuf, 0, nbuf->size, &conPointer);
|
||||||
|
|
||||||
if (err != B_OK) {
|
if (err != B_OK) {
|
||||||
|
panic("I expected to be contiguous:(");
|
||||||
|
#if 0
|
||||||
/* pity, we are gonna need a realocation */
|
/* pity, we are gonna need a realocation */
|
||||||
nbuf->COOKIEFIELD = (uint32) malloc(nbuf->size);
|
nbuf->COOKIEFIELD = (uint32) malloc(nbuf->size);
|
||||||
if (nbuf->COOKIEFIELD == NULL)
|
if (nbuf->COOKIEFIELD == NULL)
|
||||||
@@ -47,15 +45,16 @@ nb_get_whole_buffer(net_buffer* nbuf)
|
|||||||
goto free;
|
goto free;
|
||||||
|
|
||||||
conPointer = (void*)nbuf->COOKIEFIELD;
|
conPointer = (void*)nbuf->COOKIEFIELD;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return conPointer;
|
return conPointer;
|
||||||
|
#if 0
|
||||||
free:
|
free:
|
||||||
free((void*) nbuf->COOKIEFIELD);
|
free((void*) nbuf->COOKIEFIELD);
|
||||||
fail:
|
fail:
|
||||||
return NULL;
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -64,11 +63,11 @@ nb_destroy(net_buffer* nbuf)
|
|||||||
{
|
{
|
||||||
if (nbuf == NULL)
|
if (nbuf == NULL)
|
||||||
return;
|
return;
|
||||||
|
#if 0
|
||||||
/* Free possible allocated */
|
/* Free possible allocated */
|
||||||
if (nbuf->COOKIEFIELD != NULL)
|
if (nbuf->COOKIEFIELD != NULL)
|
||||||
free((void*)nbuf->COOKIEFIELD);
|
free((void*)nbuf->COOKIEFIELD);
|
||||||
|
#endif
|
||||||
// TODO check for survivers...
|
// TODO check for survivers...
|
||||||
if (nb != NULL)
|
if (nb != NULL)
|
||||||
nb->free(nbuf);
|
nb->free(nbuf);
|
||||||
@@ -88,21 +87,20 @@ get_expected_size(net_buffer* nbuf)
|
|||||||
|
|
||||||
case BT_ACL: {
|
case BT_ACL: {
|
||||||
struct hci_acl_header* header = nb_get_whole_buffer(nbuf);
|
struct hci_acl_header* header = nb_get_whole_buffer(nbuf);
|
||||||
return header->alen;
|
return header->alen + sizeof(struct hci_acl_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
case BT_COMMAND: {
|
case BT_COMMAND: {
|
||||||
struct hci_command_header* header = nb_get_whole_buffer(nbuf);
|
struct hci_command_header* header = nb_get_whole_buffer(nbuf);
|
||||||
return header->clen;
|
return header->clen + sizeof(struct hci_command_header);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
case BT_EVENT: {
|
case BT_EVENT: {
|
||||||
struct hci_event_header* header = nb_get_whole_buffer(nbuf);
|
struct hci_event_header* header = nb_get_whole_buffer(nbuf);
|
||||||
return header->elen;
|
return header->elen + sizeof(struct hci_event_header);
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
panic("h2geneirc:no protocol specifiel for get expected size");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user