summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/netbt/bt_input.c11
-rw-r--r--sys/netbt/hci.h5
-rw-r--r--sys/netbt/hci_event.c6
-rw-r--r--sys/netbt/hci_unit.c82
4 files changed, 49 insertions, 55 deletions
diff --git a/sys/netbt/bt_input.c b/sys/netbt/bt_input.c
index d15841e26c7..440d69389a9 100644
--- a/sys/netbt/bt_input.c
+++ b/sys/netbt/bt_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bt_input.c,v 1.3 2007/05/30 08:10:02 uwe Exp $ */
+/* $OpenBSD: bt_input.c,v 1.4 2007/05/31 23:50:19 uwe Exp $ */
/*
* Copyright (c) 2004 Alexander Yurchenko <grange@openbsd.org>
*
@@ -19,6 +19,7 @@
#include <sys/mbuf.h>
#include <sys/systm.h>
#include <sys/socket.h>
+#include <sys/timeout.h>
#include <net/if.h>
#include <net/if_types.h>
@@ -26,6 +27,9 @@
#include <netbt/bluetooth.h>
#include <netbt/bt_var.h>
+#include <netbt/hci.h>
+
+extern void hci_intr(void *); /* XXX */
struct ifqueue btintrq;
@@ -38,9 +42,14 @@ bt_init(void)
void
btintr(void)
{
+ struct hci_unit *unit;
struct mbuf *m;
int s;
+ TAILQ_FOREACH(unit, &hci_unit_list, hci_next) {
+ hci_intr(unit);
+ }
+
for (;;) {
s = splnet();
IF_DEQUEUE(&btintrq, m);
diff --git a/sys/netbt/hci.h b/sys/netbt/hci.h
index cab7f897649..b6916c2a433 100644
--- a/sys/netbt/hci.h
+++ b/sys/netbt/hci.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: hci.h,v 1.4 2007/05/30 03:42:53 uwe Exp $ */
+/* $OpenBSD: hci.h,v 1.5 2007/05/31 23:50:19 uwe Exp $ */
/* $NetBSD: hci.h,v 1.10 2007/04/21 06:15:23 plunky Exp $ */
/*-
@@ -55,7 +55,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: hci.h,v 1.4 2007/05/30 03:42:53 uwe Exp $
+ * $Id: hci.h,v 1.5 2007/05/31 23:50:19 uwe Exp $
* $FreeBSD: src/sys/netgraph/bluetooth/include/ng_hci.h,v 1.6 2005/01/07 01:45:43 imp Exp $
*/
@@ -2144,7 +2144,6 @@ struct hci_unit {
int hci_ipl; /* to block queue operations */
/* input queues */
- void *hci_rxint; /* receive interrupt cookie */
struct ifqueue hci_eventq; /* Event queue */
struct ifqueue hci_aclrxq; /* ACL rx queue */
struct ifqueue hci_scorxq; /* SCO rx queue */
diff --git a/sys/netbt/hci_event.c b/sys/netbt/hci_event.c
index 645f53e251b..98d418552f7 100644
--- a/sys/netbt/hci_event.c
+++ b/sys/netbt/hci_event.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hci_event.c,v 1.1 2007/05/30 03:42:53 uwe Exp $ */
+/* $OpenBSD: hci_event.c,v 1.2 2007/05/31 23:50:19 uwe Exp $ */
/* $NetBSD: hci_event.c,v 1.6 2007/04/21 06:15:23 plunky Exp $ */
/*-
@@ -44,6 +44,8 @@
#include <netbt/hci.h>
#include <netbt/sco.h>
+#define splraiseipl(ipl) splbio() /* XXX */
+
static void hci_event_inquiry_result(struct hci_unit *, struct mbuf *);
static void hci_event_command_status(struct hci_unit *, struct mbuf *);
static void hci_event_command_compl(struct hci_unit *, struct mbuf *);
@@ -132,6 +134,7 @@ hci_eventstr(unsigned int event)
* We will free the mbuf at the end, no need for any sub
* functions to handle that. We kind of assume that the
* device sends us valid events.
+ * XXX "kind of"? This needs to be fixed.
*/
void
hci_event(struct mbuf *m, struct hci_unit *unit)
@@ -755,7 +758,6 @@ hci_cmd_read_bdaddr(struct hci_unit *unit, struct mbuf *m)
bdaddr_copy(&unit->hci_bdaddr, &rp.bdaddr);
-#define splraiseipl(ipl) spltty() /* XXX */
s = splraiseipl(unit->hci_ipl);
unit->hci_flags &= ~BTF_INIT_BDADDR;
splx(s);
diff --git a/sys/netbt/hci_unit.c b/sys/netbt/hci_unit.c
index e683db244a2..5bd4aa3b5fd 100644
--- a/sys/netbt/hci_unit.c
+++ b/sys/netbt/hci_unit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: hci_unit.c,v 1.1 2007/05/30 03:42:53 uwe Exp $ */
+/* $OpenBSD: hci_unit.c,v 1.2 2007/05/31 23:50:19 uwe Exp $ */
/* $NetBSD: hci_unit.c,v 1.4 2007/03/30 20:47:03 plunky Exp $ */
/*-
@@ -42,10 +42,15 @@
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/systm.h>
+#include <sys/workq.h>
+
+#include <net/netisr.h>
#include <netbt/bluetooth.h>
#include <netbt/hci.h>
+#define splraiseipl(ipl) splbio() /* XXX */
+
struct hci_unit_list hci_unit_list = TAILQ_HEAD_INITIALIZER(hci_unit_list);
/*
@@ -59,12 +64,14 @@ int hci_scorxq_max = 50;
* bluetooth unit functions
*/
+void hci_enable_task(void *, void *);
void hci_intr(void *);
+struct workq *hci_workq;
+
void
hci_attach(struct hci_unit *unit)
{
-
KASSERT(unit->hci_softc != NULL);
KASSERT(unit->hci_devname != NULL);
KASSERT(unit->hci_enable != NULL);
@@ -81,17 +88,32 @@ hci_attach(struct hci_unit *unit)
LIST_INIT(&unit->hci_memos);
TAILQ_INSERT_TAIL(&hci_unit_list, unit, hci_next);
+
+ /* XXX enable HCI by default until we have userland tools */
+ if (hci_workq == NULL)
+ hci_workq = workq_create("hci_enable", 1);
+ if (hci_workq != NULL)
+ (void)workq_add_task(hci_workq, hci_enable_task, unit,
+ NULL, 0);
}
void
hci_detach(struct hci_unit *unit)
{
-
hci_disable(unit);
TAILQ_REMOVE(&hci_unit_list, unit, hci_next);
}
+void
+hci_enable_task(void *arg0, void *arg1)
+{
+ struct hci_unit *unit = arg0;
+
+ if (!(unit->hci_flags & BTF_UP) && hci_enable(unit) == 0)
+ unit->hci_flags |= BTF_UP;
+}
+
int
hci_enable(struct hci_unit *unit)
{
@@ -117,14 +139,6 @@ hci_enable(struct hci_unit *unit)
unit->hci_acl_mask = HCI_PKT_DM1 | HCI_PKT_DH1;
unit->hci_packet_type = unit->hci_acl_mask;
-/* XXX */
-#ifdef notyet
- unit->hci_rxint = softintr_establish(IPL_SOFTNET, &hci_intr, unit);
- if (unit->hci_rxint == NULL)
- return EIO;
-#endif
-#define splraiseipl(ipl) splnet()
-
s = splraiseipl(unit->hci_ipl);
err = (*unit->hci_enable)(unit);
splx(s);
@@ -166,11 +180,6 @@ bad2:
splx(s);
bad1:
-#ifdef notyet /* XXX */
- softintr_disestablish(unit->hci_rxint);
-#endif
- unit->hci_rxint = NULL;
-
return err;
}
@@ -186,13 +195,6 @@ hci_disable(struct hci_unit *unit)
unit->hci_bthub = NULL;
}
- if (unit->hci_rxint) {
-#ifdef notyet /* XXX */
- softintr_disestablish(unit->hci_rxint);
-#endif
- unit->hci_rxint = NULL;
- }
-
s = splraiseipl(unit->hci_ipl);
(*unit->hci_disable)(unit);
splx(s);
@@ -391,51 +393,42 @@ another:
void
hci_input_event(struct hci_unit *unit, struct mbuf *m)
{
-
- if (unit->hci_eventqlen > hci_eventq_max || unit->hci_rxint == NULL) {
+ if (unit->hci_eventqlen > hci_eventq_max) {
DPRINTF("(%s) dropped event packet.\n", unit->hci_devname);
unit->hci_stats.err_rx++;
m_freem(m);
} else {
unit->hci_eventqlen++;
IF_ENQUEUE(&unit->hci_eventq, m);
-#ifdef notyet /* XXX */
- softintr_schedule(unit->hci_rxint);
-#endif
+ schednetisr(NETISR_BT);
}
}
void
hci_input_acl(struct hci_unit *unit, struct mbuf *m)
{
-
- if (unit->hci_aclrxqlen > hci_aclrxq_max || unit->hci_rxint == NULL) {
+ if (unit->hci_aclrxqlen > hci_aclrxq_max) {
DPRINTF("(%s) dropped ACL packet.\n", unit->hci_devname);
unit->hci_stats.err_rx++;
m_freem(m);
} else {
unit->hci_aclrxqlen++;
IF_ENQUEUE(&unit->hci_aclrxq, m);
-#ifdef notyet /* XXX */
- softintr_schedule(unit->hci_rxint);
-#endif
+ schednetisr(NETISR_BT);
}
}
void
hci_input_sco(struct hci_unit *unit, struct mbuf *m)
{
-
- if (unit->hci_scorxqlen > hci_scorxq_max || unit->hci_rxint == NULL) {
+ if (unit->hci_scorxqlen > hci_scorxq_max) {
DPRINTF("(%s) dropped SCO packet.\n", unit->hci_devname);
unit->hci_stats.err_rx++;
m_freem(m);
} else {
unit->hci_scorxqlen++;
IF_ENQUEUE(&unit->hci_scorxq, m);
-#ifdef notyet /* XXX */
- softintr_schedule(unit->hci_rxint);
-#endif
+ schednetisr(NETISR_BT);
}
}
@@ -515,15 +508,6 @@ hci_output_sco(struct hci_unit *unit, struct mbuf *m)
void
hci_complete_sco(struct hci_unit *unit, struct mbuf *m)
{
-
- if (unit->hci_rxint == NULL) {
- DPRINTFN(10, "(%s) complete SCO!\n", unit->hci_devname);
- unit->hci_stats.err_rx++;
- m_freem(m);
- } else {
- IF_ENQUEUE(&unit->hci_scodone, m);
-#ifdef notyet /* XXX */
- softintr_schedule(unit->hci_rxint);
-#endif
- }
+ IF_ENQUEUE(&unit->hci_scodone, m);
+ schednetisr(NETISR_BT);
}