git: 67cbbf19595d - main - ng_ubt(4): Introduce net.bluetooth.usb_isoc_enable loader tunable to disable isochronous transfers.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Tue, 07 Dec 2021 10:41:29 UTC
The branch main has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=67cbbf19595da4565d3c8603030fdb8d33ed571e

commit 67cbbf19595da4565d3c8603030fdb8d33ed571e
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2021-12-07 10:28:21 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2021-12-07 10:39:49 +0000

    ng_ubt(4): Introduce net.bluetooth.usb_isoc_enable loader tunable to disable
    isochronous transfers.
    
    If users want to disable isochronous transfers, which cause high
    frequency periodic interrupts from the USB host controller, then
    net.bluetooth.usb_isoc_enable can be set to zero, either as a
    sysctl(8) or as a loader.conf(5) tunable.
    
    Differential Revision:  https://reviews.freebsd.org/D33282
    Submitted by:   naito.yuichiro@gmail.com
    PR:             238235
    MFC after:      1 week
    Sponsored by:   NVIDIA Networking
---
 sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
index a79a8cd48509..c3820fc872af 100644
--- a/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
+++ b/sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c
@@ -152,6 +152,11 @@ static ng_disconnect_t	ng_ubt_disconnect;
 static ng_rcvmsg_t	ng_ubt_rcvmsg;
 static ng_rcvdata_t	ng_ubt_rcvdata;
 
+static int ng_usb_isoc_enable = 1;
+
+SYSCTL_INT(_net_bluetooth, OID_AUTO, usb_isoc_enable, CTLFLAG_RDTUN | CTLFLAG_MPSAFE,
+    &ng_usb_isoc_enable, 0, "enable isochronous transfers");
+
 /* Queue length */
 static const struct ng_parse_struct_field	ng_ubt_node_qlen_type_fields[] =
 {
@@ -742,8 +747,9 @@ ubt_attach(device_t dev)
 	}
 
 	/* Setup transfers for both interfaces */
-	if (usbd_transfer_setup(uaa->device, iface_index, sc->sc_xfer,
-			ubt_config, UBT_N_TRANSFER, sc, &sc->sc_if_mtx)) {
+	if (usbd_transfer_setup(uaa->device, iface_index, sc->sc_xfer, ubt_config,
+			ng_usb_isoc_enable ? UBT_N_TRANSFER : UBT_IF_1_ISOC_DT_RD1,
+			sc, &sc->sc_if_mtx)) {
 		UBT_ALERT(sc, "could not allocate transfers\n");
 		goto detach;
 	}