]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Bluetooth: mgmt: Add idle_timeout to configurable system parameters
authorStefan Sørensen <ssorensen@roku.com>
Tue, 16 Dec 2025 09:20:11 +0000 (10:20 +0100)
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Thu, 29 Jan 2026 18:24:22 +0000 (13:24 -0500)
While the configurable system parameters allow controlling the SNIFF
mode parameters, they do not include the idle_timeout parameter
responsible for enabling SNIFF mode.

Add the idle_timeout parameter to allow controlling the idle timeout
of BR/EDR connections.

Signed-off-by: Stefan Sørensen <ssorensen@roku.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
net/bluetooth/mgmt_config.c

index c4063d200c0a6e473e8a769289c1d546ccd3fc4a..fdcc752c6f13f6ae8576e8fa2ab3d04e47f1a7e8 100644 (file)
 #include "mgmt_util.h"
 #include "mgmt_config.h"
 
+#define HDEV_PARAM_U32(_param_name_) \
+       struct {\
+               struct mgmt_tlv_hdr entry; \
+               __le32 value; \
+       } __packed _param_name_
+
 #define HDEV_PARAM_U16(_param_name_) \
        struct {\
                struct mgmt_tlv_hdr entry; \
                cpu_to_le16(hdev->_param_name_) \
        }
 
+#define TLV_SET_U32(_param_code_, _param_name_) \
+       { \
+               { cpu_to_le16(_param_code_), sizeof(__u32) }, \
+               cpu_to_le32(hdev->_param_name_) \
+       }
+
 #define TLV_SET_U8(_param_code_, _param_name_) \
        { \
                { cpu_to_le16(_param_code_), sizeof(__u8) }, \
@@ -78,6 +90,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
                HDEV_PARAM_U16(advmon_allowlist_duration);
                HDEV_PARAM_U16(advmon_no_filter_duration);
                HDEV_PARAM_U8(enable_advmon_interleave_scan);
+               HDEV_PARAM_U32(idle_timeout);
        } __packed rp = {
                TLV_SET_U16(0x0000, def_page_scan_type),
                TLV_SET_U16(0x0001, def_page_scan_int),
@@ -111,6 +124,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
                TLV_SET_U16(0x001d, advmon_allowlist_duration),
                TLV_SET_U16(0x001e, advmon_no_filter_duration),
                TLV_SET_U8(0x001f, enable_advmon_interleave_scan),
+               TLV_SET_U32(0x0020, idle_timeout),
        };
 
        bt_dev_dbg(hdev, "sock %p", sk);
@@ -122,6 +136,7 @@ int read_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
 }
 
 #define TO_TLV(x)              ((struct mgmt_tlv *)(x))
+#define TLV_GET_LE32(tlv)      le32_to_cpu(*((__le32 *)(TO_TLV(tlv)->value)))
 #define TLV_GET_LE16(tlv)      le16_to_cpu(*((__le16 *)(TO_TLV(tlv)->value)))
 #define TLV_GET_U8(tlv)                (*((__u8 *)(TO_TLV(tlv)->value)))
 
@@ -191,6 +206,9 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
                case 0x001f:
                        exp_type_len = sizeof(u8);
                        break;
+               case 0x0020:
+                       exp_type_len = sizeof(u32);
+                       break;
                default:
                        exp_type_len = 0;
                        bt_dev_warn(hdev, "unsupported parameter %u", type);
@@ -314,6 +332,9 @@ int set_def_system_config(struct sock *sk, struct hci_dev *hdev, void *data,
                case 0x0001f:
                        hdev->enable_advmon_interleave_scan = TLV_GET_U8(buffer);
                        break;
+               case 0x00020:
+                       hdev->idle_timeout = TLV_GET_LE32(buffer);
+                       break;
                default:
                        bt_dev_warn(hdev, "unsupported parameter %u", type);
                        break;