git: 7b976be508ce - stable/13 - ng_ubt(4): Introduce net.bluetooth.usb_isoc_enable loader tunable to disable isochronous transfers.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Fri, 07 Jan 2022 13:30:54 UTC
The branch stable/13 has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=7b976be508ce7bbb9652687d20a98d2e4b2d5a5b

commit 7b976be508ce7bbb9652687d20a98d2e4b2d5a5b
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2021-12-07 10:28:21 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-01-07 13:23:10 +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
    Sponsored by:   NVIDIA Networking
    
    (cherry picked from commit 67cbbf19595da4565d3c8603030fdb8d33ed571e)
    (cherry picked from commit 03f0393477db4c11f8dc4166fadc2628b2c15ae9)
    (cherry picked from commit 8fa952937bbe44a0fdd17348adfbbfd44aef6004)
---
 sys/netgraph/bluetooth/drivers/ubt/ng_ubt.c | 11 +++++++++--
 1 file changed, 9 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..dee829336331 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_RWTUN | 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;
 	}
@@ -2007,5 +2013,6 @@ DRIVER_MODULE(ng_ubt, uhub, ubt_driver, ubt_devclass, ubt_modevent, 0);
 MODULE_VERSION(ng_ubt, NG_BLUETOOTH_VERSION);
 MODULE_DEPEND(ng_ubt, netgraph, NG_ABI_VERSION, NG_ABI_VERSION, NG_ABI_VERSION);
 MODULE_DEPEND(ng_ubt, ng_hci, NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION);
+MODULE_DEPEND(ng_ubt, ng_bluetooth, NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION, NG_BLUETOOTH_VERSION);
 MODULE_DEPEND(ng_ubt, usb, 1, 1, 1);
 USB_PNP_HOST_INFO(ubt_devs);