Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 302975cb authored by Spoorthi Ravishankar Koppad's avatar Spoorthi Ravishankar Koppad Committed by Marcel Holtmann
Browse files

Bluetooth: Add support for LE ping feature



Changes made to add HCI Write Authenticated Payload timeout
command for LE Ping feature.

As per the Core Specification 5.0 Volume 2 Part E Section 7.3.94,
the following code changes implements
HCI Write Authenticated Payload timeout command for LE Ping feature.

Signed-off-by: default avatarSpoorthi Ravishankar Koppad <spoorthix.k@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 28261da8
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
@@ -1143,6 +1143,26 @@ struct hci_cp_write_sc_support {
	__u8	support;
} __packed;

#define HCI_OP_READ_AUTH_PAYLOAD_TO    0x0c7b
struct hci_cp_read_auth_payload_to {
	__le16  handle;
} __packed;
struct hci_rp_read_auth_payload_to {
	__u8    status;
	__le16  handle;
	__le16  timeout;
} __packed;

#define HCI_OP_WRITE_AUTH_PAYLOAD_TO    0x0c7c
struct hci_cp_write_auth_payload_to {
	__le16  handle;
	__le16  timeout;
} __packed;
struct hci_rp_write_auth_payload_to {
	__u8    status;
	__le16  handle;
} __packed;

#define HCI_OP_READ_LOCAL_OOB_EXT_DATA	0x0c7d
struct hci_rp_read_local_oob_ext_data {
	__u8     status;
+4 −0
Original line number Diff line number Diff line
@@ -199,6 +199,8 @@ struct adv_info {
/* Default min/max age of connection information (1s/3s) */
#define DEFAULT_CONN_INFO_MIN_AGE	1000
#define DEFAULT_CONN_INFO_MAX_AGE	3000
/* Default authenticated payload timeout 30s */
#define DEFAULT_AUTH_PAYLOAD_TIMEOUT   0x0bb8

struct amp_assoc {
	__u16	len;
@@ -275,6 +277,7 @@ struct hci_dev {
	__u16		discov_interleaved_timeout;
	__u16		conn_info_min_age;
	__u16		conn_info_max_age;
	__u16		auth_payload_timeout;
	__u8		ssp_debug_mode;
	__u8		hw_error_code;
	__u32		clock;
@@ -481,6 +484,7 @@ struct hci_conn {
	__u16		disc_timeout;
	__u16		conn_timeout;
	__u16		setting;
	__u16		auth_payload_timeout;
	__u16		le_conn_min_interval;
	__u16		le_conn_max_interval;
	__u16		le_conn_interval;
+3 −0
Original line number Diff line number Diff line
@@ -520,6 +520,9 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst,
	set_bit(HCI_CONN_POWER_SAVE, &conn->flags);
	conn->disc_timeout = HCI_DISCONN_TIMEOUT;

	/* Set Default Authenticated payload timeout to 30s */
	conn->auth_payload_timeout = DEFAULT_AUTH_PAYLOAD_TIMEOUT;

	if (conn->role == HCI_ROLE_MASTER)
		conn->out = true;

+1 −0
Original line number Diff line number Diff line
@@ -3200,6 +3200,7 @@ struct hci_dev *hci_alloc_dev(void)
	hdev->discov_interleaved_timeout = DISCOV_INTERLEAVED_TIMEOUT;
	hdev->conn_info_min_age = DEFAULT_CONN_INFO_MIN_AGE;
	hdev->conn_info_max_age = DEFAULT_CONN_INFO_MAX_AGE;
	hdev->auth_payload_timeout = DEFAULT_AUTH_PAYLOAD_TIMEOUT;

	mutex_init(&hdev->lock);
	mutex_init(&hdev->req_lock);
+31 −0
Original line number Diff line number Diff line
@@ -941,6 +941,35 @@ static int adv_max_interval_get(void *data, u64 *val)
DEFINE_SIMPLE_ATTRIBUTE(adv_max_interval_fops, adv_max_interval_get,
			adv_max_interval_set, "%llu\n");

static int auth_payload_timeout_set(void *data, u64 val)
{
	struct hci_dev *hdev = data;

	if (val < 0x0001 || val > 0xffff)
		return -EINVAL;

	hci_dev_lock(hdev);
	hdev->auth_payload_timeout = val;
	hci_dev_unlock(hdev);

	return 0;
}

static int auth_payload_timeout_get(void *data, u64 *val)
{
	struct hci_dev *hdev = data;

	hci_dev_lock(hdev);
	*val = hdev->auth_payload_timeout;
	hci_dev_unlock(hdev);

	return 0;
}

DEFINE_SIMPLE_ATTRIBUTE(auth_payload_timeout_fops,
			auth_payload_timeout_get,
			auth_payload_timeout_set, "%llu\n");

DEFINE_QUIRK_ATTRIBUTE(quirk_strict_duplicate_filter,
		       HCI_QUIRK_STRICT_DUPLICATE_FILTER);
DEFINE_QUIRK_ATTRIBUTE(quirk_simultaneous_discovery,
@@ -994,6 +1023,8 @@ void hci_debugfs_create_le(struct hci_dev *hdev)
			    &adv_max_interval_fops);
	debugfs_create_u16("discov_interleaved_timeout", 0644, hdev->debugfs,
			   &hdev->discov_interleaved_timeout);
	debugfs_create_file("auth_payload_timeout", 0644, hdev->debugfs, hdev,
			    &auth_payload_timeout_fops);

	debugfs_create_file("quirk_strict_duplicate_filter", 0644,
			    hdev->debugfs, hdev,
Loading