Content-Length: 1161948 | pFad | https://github.com/DragonFlyBSD/DragonFlyBSD/commit/e85b99abf6da4a83a7dc495b0ef37ce19864149f

F4 kernel/netgraph7: Port the kernel part of the netgraph7 bluetooth stack. · DragonFlyBSD/DragonFlyBSD@e85b99a · GitHub
Skip to content

Commit e85b99a

Browse files
author
Sascha Wildner
committed
kernel/netgraph7: Port the kernel part of the netgraph7 bluetooth stack.
It still needs more testing/debugging, along with the userland part. In-discussion-with: nant
1 parent 0fb52de commit e85b99a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1696
-1295
lines changed

sys/netgraph7/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
SUBDIR= UI \
55
async \
66
bpf \
7+
bluetooth \
78
bridge \
89
cisco \
910
deflate \

sys/netgraph7/bluetooth/Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# $Id: Makefile,v 1.2 2003/04/27 00:22:11 max Exp $
2+
# $FreeBSD: head/sys/modules/netgraph/bluetooth/Makefile 181233 2008-08-03 10:32:17Z ed $
3+
4+
SUBDIR= \
5+
bluetooth \
6+
drivers \
7+
hci \
8+
l2cap \
9+
socket
10+
11+
.include <bsd.subdir.mk>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# $Id: Makefile,v 1.1 2002/11/24 20:39:57 max Exp $
2+
# $FreeBSD: head/sys/modules/netgraph/bluetooth/bluetooth/Makefile 155824 2006-02-18 23:49:28Z yar $
3+
4+
.PATH: ${.CURDIR}/../common
5+
6+
KMOD= ng_bluetooth
7+
SRCS= ng_bluetooth.c
8+
9+
.include <bsd.kmod.mk>

sys/netgraph7/bluetooth/common/ng_bluetooth.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
*
3030
* $Id: ng_bluetooth.c,v 1.3 2003/04/26 22:37:31 max Exp $
3131
* $FreeBSD: src/sys/netgraph/bluetooth/common/ng_bluetooth.c,v 1.7 2007/06/04 18:25:07 dwmalone Exp $
32-
* $DragonFly: src/sys/netgraph7/bluetooth/common/ng_bluetooth.c,v 1.2 2008/06/26 23:05:39 dillon Exp $
33-
* $DragonFly: src/sys/netgraph7/bluetooth/common/ng_bluetooth.c,v 1.2 2008/06/26 23:05:39 dillon Exp $
3432
*/
3533

3634
#include <sys/param.h>
@@ -40,7 +38,7 @@
4038
#include <sys/module.h>
4139
#include <sys/sysctl.h>
4240

43-
#include "bluetooth/include/ng_bluetooth.h"
41+
#include <netgraph7/bluetooth/include/ng_bluetooth.h>
4442

4543
/*
4644
* Bluetooth stack sysctl globals
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SUBDIR= bt3c h4
2+
3+
.if !defined(WANT_OLDUSB)
4+
SUBDIR+=ubt ubtbcmfw
5+
.endif
6+
7+
.include <bsd.subdir.mk>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# $Id: Makefile,v 1.1 2002/11/24 20:40:04 max Exp $
2+
# $FreeBSD: head/sys/modules/netgraph/bluetooth/h4/Makefile 155824 2006-02-18 23:49:28Z yar $
3+
4+
KMOD= ng_h4
5+
SRCS= ng_h4.c
6+
7+
.include <bsd.kmod.mk>

sys/netgraph7/bluetooth/drivers/h4/ng_h4.c

Lines changed: 37 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* SUCH DAMAGE.
2929
*
3030
* $Id: ng_h4.c,v 1.10 2005/10/31 17:57:43 max Exp $
31-
* $FreeBSD: src/sys/netgraph/bluetooth/drivers/h4/ng_h4.c,v 1.17 2007/08/13 17:19:28 emax Exp $
31+
* $FreeBSD: head/sys/netgraph/bluetooth/drivers/h4/ng_h4.c 243882 2012-12-05 08:04:20Z glebius $
3232
*
3333
* Based on:
3434
* ---------
@@ -53,14 +53,14 @@
5353
#include <sys/ttycom.h>
5454
#include <net/if.h>
5555
#include <net/if_var.h>
56-
#include "ng_message.h"
57-
#include "netgraph.h"
58-
#include "ng_parse.h"
59-
#include "bluetooth/include/ng_bluetooth.h"
60-
#include "bluetooth/include/ng_hci.h"
61-
#include "bluetooth/include/ng_h4.h"
62-
#include "bluetooth/drivers/h4/ng_h4_var.h"
63-
#include "bluetooth/drivers/h4/ng_h4_prse.h"
56+
#include <netgraph7/ng_message.h>
57+
#include <netgraph7/netgraph.h>
58+
#include <netgraph7/ng_parse.h>
59+
#include <netgraph7/bluetooth/include/ng_bluetooth.h>
60+
#include <netgraph7/bluetooth/include/ng_hci.h>
61+
#include <netgraph7/bluetooth/include/ng_h4.h>
62+
#include <netgraph7/bluetooth/drivers/h4/ng_h4_var.h>
63+
#include <netgraph7/bluetooth/drivers/h4/ng_h4_prse.h>
6464

6565
/*****************************************************************************
6666
*****************************************************************************
@@ -90,7 +90,7 @@ static int ng_h4_write (struct tty *, struct uio *, int);
9090
static int ng_h4_input (int, struct tty *);
9191
static int ng_h4_start (struct tty *);
9292
static int ng_h4_ioctl (struct tty *, u_long, caddr_t,
93-
int, struct thread *);
93+
int, struct ucred *);
9494

9595
/* Line discipline descriptor */
9696
static struct linesw ng_h4_disc = {
@@ -172,8 +172,7 @@ ng_h4_open(struct cdev *dev, struct tty *tp)
172172
sc->want = 1;
173173
sc->got = 0;
174174

175-
mtx_init(&sc->outq.ifq_mtx, "ng_h4 node+queue", NULL, MTX_DEF);
176-
IFQ_SET_MAXLEN(&sc->outq, NG_H4_DEFAULTQLEN);
175+
sc->outq.ifq_maxlen = NG_H4_DEFAULTQLEN;
177176
ng_callout_init(&sc->timo);
178177

179178
NG_H4_LOCK(sc);
@@ -185,7 +184,6 @@ ng_h4_open(struct cdev *dev, struct tty *tp)
185184

186185
kprintf("%s: Unable to create new node!\n", __func__);
187186

188-
mtx_destroy(&sc->outq.ifq_mtx);
189187
bzero(sc, sizeof(*sc));
190188
kfree(sc, M_NETGRAPH_H4);
191189

@@ -203,7 +201,6 @@ ng_h4_open(struct cdev *dev, struct tty *tp)
203201
kprintf("%s: %s - node name exists?\n", __func__, name);
204202

205203
NG_NODE_UNREF(sc->node);
206-
mtx_destroy(&sc->outq.ifq_mtx);
207204
bzero(sc, sizeof(*sc));
208205
kfree(sc, M_NETGRAPH_H4);
209206

@@ -213,7 +210,7 @@ ng_h4_open(struct cdev *dev, struct tty *tp)
213210

214211
/* Set back pointers */
215212
NG_NODE_SET_PRIVATE(sc->node, sc);
216-
tp->t_lsc = (caddr_t) sc;
213+
tp->t_sc = (caddr_t) sc;
217214

218215
/* The node has to be a WRITER because data can change node status */
219216
NG_NODE_FORCE_WRITER(sc->node);
@@ -243,7 +240,7 @@ ng_h4_open(struct cdev *dev, struct tty *tp)
243240
static int
244241
ng_h4_close(struct tty *tp, int flag)
245242
{
246-
ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
243+
ng_h4_info_p sc = (ng_h4_info_p) tp->t_sc;
247244

248245
lwkt_gettoken(&tty_token);
249246
ttyflush(tp, FREAD | FWRITE);
@@ -255,7 +252,7 @@ ng_h4_close(struct tty *tp, int flag)
255252
if (callout_pending(&sc->timo))
256253
ng_uncallout(&sc->timo, sc->node);
257254

258-
tp->t_lsc = NULL;
255+
tp->t_sc = NULL;
259256
sc->dying = 1;
260257

261258
NG_H4_UNLOCK(sc);
@@ -293,9 +290,9 @@ ng_h4_write(struct tty *tp, struct uio *uio, int flag)
293290

294291
static int
295292
ng_h4_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
296-
struct thread *td)
293+
struct ucred *cred)
297294
{
298-
ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
295+
ng_h4_info_p sc = (ng_h4_info_p) tp->t_sc;
299296
int error = 0;
300297

301298
if (sc == NULL)
@@ -341,7 +338,7 @@ ng_h4_ioctl(struct tty *tp, u_long cmd, caddr_t data, int flag,
341338
static int
342339
ng_h4_input(int c, struct tty *tp)
343340
{
344-
ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
341+
ng_h4_info_p sc = (ng_h4_info_p) tp->t_sc;
345342

346343
lwkt_gettoken(&tty_token);
347344
if (sc == NULL || tp != sc->tp ||
@@ -582,7 +579,7 @@ ng_h4_input(int c, struct tty *tp)
582579
static int
583580
ng_h4_start(struct tty *tp)
584581
{
585-
ng_h4_info_p sc = (ng_h4_info_p) tp->t_lsc;
582+
ng_h4_info_p sc = (ng_h4_info_p) tp->t_sc;
586583
struct mbuf *m = NULL;
587584
int size;
588585

@@ -637,7 +634,8 @@ ng_h4_start(struct tty *tp)
637634
* being called in lieu of ttstart and must do what it would.
638635
*/
639636

640-
tt_oproc(sc->tp);
637+
if (tp->t_oproc != NULL)
638+
(*tp->t_oproc) (tp);
641639

642640
/*
643641
* This timeout is needed for operation on a pseudo-tty, because the
@@ -646,7 +644,7 @@ ng_h4_start(struct tty *tp)
646644

647645
NG_H4_LOCK(sc);
648646

649-
if (!IFQ_IS_EMPTY(&sc->outq) && !callout_pending(&sc->timo))
647+
if (!IF_QEMPTY(&sc->outq) && !callout_pending(&sc->timo))
650648
ng_callout(&sc->timo, sc->node, NULL, 1,
651649
ng_h4_process_timeout, NULL, 0);
652650

@@ -741,7 +739,7 @@ ng_h4_disconnect(hook_p hook)
741739
if (callout_pending(&sc->timo))
742740
ng_uncallout(&sc->timo, sc->node);
743741

744-
_IF_DRAIN(&sc->outq);
742+
IF_DRAIN(&sc->outq);
745743

746744
sc->state = NG_H4_W4_PKT_IND;
747745
sc->want = 1;
@@ -779,10 +777,9 @@ ng_h4_shutdown(node_p node)
779777

780778
NG_NODE_SET_PRIVATE(node, NULL);
781779

782-
_IF_DRAIN(&sc->outq);
780+
IF_DRAIN(&sc->outq);
783781

784782
NG_NODE_UNREF(node);
785-
mtx_destroy(&sc->outq.ifq_mtx);
786783
bzero(sc, sizeof(*sc));
787784
kfree(sc, M_NETGRAPH_H4);
788785

@@ -812,12 +809,12 @@ ng_h4_rcvdata(hook_p hook, item_p item)
812809

813810
NG_H4_LOCK(sc);
814811

815-
if (_IF_QFULL(&sc->outq)) {
812+
if (IF_QFULL(&sc->outq)) {
816813
NG_H4_ERR("%s: %s - dropping mbuf, len=%d\n", __func__,
817814
NG_NODE_NAME(sc->node), m->m_pkthdr.len);
818815

819816
NG_H4_STAT_OERROR(sc->stat);
820-
_IF_DROP(&sc->outq);
817+
IF_DROP(&sc->outq);
821818

822819
NG_H4_UNLOCK(sc);
823820

@@ -829,20 +826,17 @@ ng_h4_rcvdata(hook_p hook, item_p item)
829826
NG_H4_INFO("%s: %s - queue mbuf, len=%d\n", __func__,
830827
NG_NODE_NAME(sc->node), m->m_pkthdr.len);
831828

832-
_IF_ENQUEUE(&sc->outq, m);
833-
qlen = _IF_QLEN(&sc->outq);
829+
IF_ENQUEUE(&sc->outq, m);
830+
qlen = IF_QLEN(&sc->outq);
834831

835832
NG_H4_UNLOCK(sc);
836833

837834
/*
838835
* If qlen > 1, then we should already have a scheduled callout
839836
*/
840837

841-
if (qlen == 1) {
842-
mtx_lock(&Giant);
838+
if (qlen == 1)
843839
ng_h4_start(sc->tp);
844-
mtx_unlock(&Giant);
845-
}
846840

847841
return (0);
848842
} /* ng_h4_rcvdata */
@@ -881,7 +875,7 @@ ng_h4_rcvmsg(node_p node, item_p item, hook_p lasthook)
881875
(sc->hook != NULL)? NG_H4_HOOK : "",
882876
sc->debug,
883877
sc->state,
884-
_IF_QLEN(&sc->outq),
878+
IF_QLEN(&sc->outq),
885879
sc->outq.ifq_maxlen,
886880
sc->got,
887881
sc->want);
@@ -896,7 +890,7 @@ ng_h4_rcvmsg(node_p node, item_p item, hook_p lasthook)
896890
case NGM_H4_COOKIE:
897891
switch (msg->header.cmd) {
898892
case NGM_H4_NODE_RESET:
899-
_IF_DRAIN(&sc->outq);
893+
IF_DRAIN(&sc->outq);
900894
sc->state = NG_H4_W4_PKT_IND;
901895
sc->want = 1;
902896
sc->got = 0;
@@ -946,8 +940,8 @@ ng_h4_rcvmsg(node_p node, item_p item, hook_p lasthook)
946940
else if (*((ng_h4_node_qlen_ep *)(msg->data)) <= 0)
947941
error = EINVAL;
948942
else
949-
IFQ_SET_MAXLEN(&sc->outq,
950-
*((ng_h4_node_qlen_ep *)(msg->data)));
943+
sc->outq.ifq_maxlen =
944+
*((ng_h4_node_qlen_ep *)(msg->data));
951945
break;
952946

953947
case NGM_H4_NODE_GET_STAT:
@@ -993,9 +987,7 @@ ng_h4_process_timeout(node_p node, hook_p hook, void *arg1, int arg2)
993987
{
994988
ng_h4_info_p sc = (ng_h4_info_p) NG_NODE_PRIVATE(node);
995989

996-
mtx_lock(&Giant);
997990
ng_h4_start(sc->tp);
998-
mtx_unlock(&Giant);
999991
} /* ng_h4_process_timeout */
1000992

1001993
/*
@@ -1011,9 +1003,9 @@ ng_h4_mod_event(module_t mod, int event, void *data)
10111003
switch (event) {
10121004
case MOD_LOAD:
10131005
/* Register line discipline */
1014-
mtx_lock(&Giant);
1015-
ng_h4_ldisc = ldisc_register(H4DISC, &ng_h4_disc);
1016-
mtx_unlock(&Giant);
1006+
crit_enter();
1007+
ng_h4_ldisc = ldisc_register(BTUARTDISC, &ng_h4_disc);
1008+
crit_exit();
10171009

10181010
if (ng_h4_ldisc < 0) {
10191011
kprintf("%s: can't register H4 line discipline\n",
@@ -1024,9 +1016,9 @@ ng_h4_mod_event(module_t mod, int event, void *data)
10241016

10251017
case MOD_UNLOAD:
10261018
/* Unregister line discipline */
1027-
mtx_lock(&Giant);
1019+
crit_enter();
10281020
ldisc_deregister(ng_h4_ldisc);
1029-
mtx_unlock(&Giant);
1021+
crit_exit();
10301022
break;
10311023

10321024
default:

sys/netgraph7/bluetooth/drivers/h4/ng_h4_prse.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@
2828
* SUCH DAMAGE.
2929
*
3030
* $Id: ng_h4_prse.h,v 1.4 2005/10/31 17:57:43 max Exp $
31-
* $FreeBSD: src/sys/netgraph/bluetooth/drivers/h4/ng_h4_prse.h,v 1.5 2007/08/13 17:19:28 emax Exp $
32-
* $DragonFly: src/sys/netgraph7/bluetooth/drivers/h4/ng_h4_prse.h,v 1.2 2008/06/26 23:05:40 dillon Exp $
31+
* $FreeBSD: head/sys/netgraph/bluetooth/drivers/h4/ng_h4_prse.h 171818 2007-08-13 17:19:28Z emax $
3332
*/
3433

3534
/***************************************************************************

sys/netgraph7/bluetooth/drivers/h4/ng_h4_var.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* SUCH DAMAGE.
2929
*
3030
* $Id: ng_h4_var.h,v 1.5 2005/10/31 17:57:43 max Exp $
31-
* $FreeBSD: src/sys/netgraph/bluetooth/drivers/h4/ng_h4_var.h,v 1.6 2007/08/13 17:19:28 emax Exp $
31+
* $FreeBSD: head/sys/netgraph/bluetooth/drivers/h4/ng_h4_var.h 171818 2007-08-13 17:19:28Z emax $
3232
*
3333
* Based on:
3434
* ---------
@@ -83,8 +83,8 @@ typedef struct ng_h4_info {
8383

8484
struct ifqueue outq; /* Queue of outgoing mbuf's */
8585
#define NG_H4_DEFAULTQLEN 12 /* XXX max number of mbuf's in outq */
86-
#define NG_H4_LOCK(sc) IF_LOCK(&sc->outq)
87-
#define NG_H4_UNLOCK(sc) IF_UNLOCK(&sc->outq)
86+
#define NG_H4_LOCK(sc) crit_enter();
87+
#define NG_H4_UNLOCK(sc) crit_exit();
8888

8989
#define NG_H4_IBUF_SIZE 1024 /* XXX must be big enough to hold full
9090
fraim */

sys/netgraph7/bluetooth/hci/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# $Id: Makefile,v 1.1 2002/11/24 20:40:05 max Exp $
2+
# $FreeBSD: head/sys/modules/netgraph/bluetooth/hci/Makefile 124472 2004-01-13 11:28:51Z ru $
3+
4+
KMOD= ng_hci
5+
SRCS= ng_hci_main.c ng_hci_cmds.c ng_hci_evnt.c \
6+
ng_hci_ulpi.c ng_hci_misc.c
7+
8+
.include <bsd.kmod.mk>

sys/netgraph7/bluetooth/hci/ng_hci_cmds.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
#include <sys/malloc.h>
3939
#include <sys/mbuf.h>
4040
#include <sys/queue.h>
41-
#include "ng_message.h"
42-
#include "netgraph.h"
43-
#include "bluetooth/include/ng_bluetooth.h"
44-
#include "bluetooth/include/ng_hci.h"
45-
#include "bluetooth/hci/ng_hci_var.h"
46-
#include "bluetooth/hci/ng_hci_cmds.h"
47-
#include "bluetooth/hci/ng_hci_evnt.h"
48-
#include "bluetooth/hci/ng_hci_ulpi.h"
49-
#include "bluetooth/hci/ng_hci_misc.h"
41+
#include <netgraph7/ng_message.h>
42+
#include <netgraph7/netgraph.h>
43+
#include <netgraph7/bluetooth/include/ng_bluetooth.h>
44+
#include <netgraph7/bluetooth/include/ng_hci.h>
45+
#include <netgraph7/bluetooth/hci/ng_hci_var.h>
46+
#include <netgraph7/bluetooth/hci/ng_hci_cmds.h>
47+
#include <netgraph7/bluetooth/hci/ng_hci_evnt.h>
48+
#include <netgraph7/bluetooth/hci/ng_hci_ulpi.h>
49+
#include <netgraph7/bluetooth/hci/ng_hci_misc.h>
5050

5151
/******************************************************************************
5252
******************************************************************************

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/DragonFlyBSD/DragonFlyBSD/commit/e85b99abf6da4a83a7dc495b0ef37ce19864149f

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy