Skip to contentSkip to conversation

Connection Update improvements

PATCH In review Felipe F. Tonello 4 participants 9 messages Apr 13, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v5 cover Connection Update improvements

These changes implements compliant Bluetooth support for any possible way to update a connection parameter. Missing functionality is required to be implemented in user-space, which this patchset allows it.

Changes from v4:
* Handle Slave Connection Interval Range AD in kernel instead of user-space
* Removed new MGMT command, it is unnecessary since it was only supposed to be used for the Slave Connection Interval Range support, which now has been implemented in the kernel.

Changes from v3:
* Remove role check in refactored function
* Added handler for Connection Parameter Update Response
* Use Update Request when updating the connection parameters in slave
* Fix MGMT command name to ADD instead of UPDATE

Changes from v2:
* Added new MGMT command
* Roll back to first socket option implementation, details are on the patch iself.

Changes from v1:
* Use simpler user-space API
* Added refactor function

Felipe F. Tonello (4):
Bluetooth: L2CAP: Refactor L2CAP_CONN_PARAM_UPDATE_REQ into a function
Bluetooth: L2CAP: Add handler for Connection Parameter Update Response
Bluetooth: L2CAP: Add BT_LE_CONN_PARAM socket option
Bluetooth: Handle Slave Connection Interval Range AD

 include/net/bluetooth/bluetooth.h |   8 +++
 include/net/bluetooth/l2cap.h     |   5 ++
 net/bluetooth/l2cap_core.c        |  78 +++++++++++++++++++++++----
 net/bluetooth/l2cap_sock.c        | 110 ++++++++++++++++++++++++++++++++++++++
 net/bluetooth/mgmt.c              |  53 ++++++++++++++++++
 5 files changed, 243 insertions(+), 11 deletions(-)
Signature · 1 line
2.12.2
#1 lore raw

PATCH v5 1/4 Bluetooth: L2CAP: Refactor L2CAP_CONN_PARAM_UPDATE_REQ into a function

This signaling command is useful for any connection parameter change procedure, thus it is important to allow access to it from outside this translation unit.

---
 include/net/bluetooth/l2cap.h |  3 +++
 net/bluetooth/l2cap_core.c    | 31 ++++++++++++++++++++-----------
 2 files changed, 23 insertions(+), 11 deletions(-)
include/net/bluetooth/l2cap.h +3 -0
index 0697fd413087..803a7f4d93a7 100644
@@ -948,4 +948,7 @@ void l2cap_conn_put(struct l2cap_conn *conn);
 int l2cap_register_user(struct l2cap_conn *conn, struct l2cap_user *user);
 void l2cap_unregister_user(struct l2cap_conn *conn, struct l2cap_user *user);
 
+void l2cap_le_conn_update_req(struct l2cap_conn *conn, u8 min_interval,
+		u8 max_interval, u8 latency, u8 supv_timeout);
+
 #endif /* __L2CAP_H */
net/bluetooth/l2cap_core.c +20 -11
index f88ac99528ce..585d15ce0a33 100644
@@ -1483,6 +1483,21 @@ static void l2cap_conn_start(struct l2cap_conn *conn)
 	mutex_unlock(&conn->chan_lock);
 }
 
+/* This command shall only be send if the connection role is SLAVE */
+void l2cap_le_conn_update_req(struct l2cap_conn *conn, u8 min_interval,
+			      u8 max_interval, u8 latency, u8 supv_timeout)
+{
+	struct l2cap_conn_param_update_req req;
+
+	req.min = cpu_to_le16(min_interval);
+	req.max = cpu_to_le16(max_interval);
+	req.latency = cpu_to_le16(latency);
+	req.to_multiplier = cpu_to_le16(supv_timeout);
+
+	l2cap_send_cmd(conn, l2cap_get_ident(conn),
+		       L2CAP_CONN_PARAM_UPDATE_REQ, sizeof(req), &req);
+}
+
 static void l2cap_le_conn_ready(struct l2cap_conn *conn)
 {
 	struct hci_conn *hcon = conn->hcon;
@@ -1503,17 +1518,11 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
 	 */
 	if (hcon->role == HCI_ROLE_SLAVE &&
 	    (hcon->le_conn_interval < hcon->le_conn_min_interval ||
-	     hcon->le_conn_interval > hcon->le_conn_max_interval)) {
-		struct l2cap_conn_param_update_req req;
-
-		req.min = cpu_to_le16(hcon->le_conn_min_interval);
-		req.max = cpu_to_le16(hcon->le_conn_max_interval);
-		req.latency = cpu_to_le16(hcon->le_conn_latency);
-		req.to_multiplier = cpu_to_le16(hcon->le_supv_timeout);
-
-		l2cap_send_cmd(conn, l2cap_get_ident(conn),
-			       L2CAP_CONN_PARAM_UPDATE_REQ, sizeof(req), &req);
-	}
+	     hcon->le_conn_interval > hcon->le_conn_max_interval))
+		l2cap_le_conn_update_req(conn, hcon->le_conn_min_interval,
+					 hcon->le_conn_max_interval,
+					 hcon->le_conn_latency,
+					 hcon->le_supv_timeout);
 }
 
 static void l2cap_conn_ready(struct l2cap_conn *conn)
Signature · 1 line
2.12.2
#2 lore raw

PATCH v5 2/4 Bluetooth: L2CAP: Add handler for Connection Parameter Update Response

In reply to Felipe F. Tonello

In case of connected hosts that doesn't support the Connection Parameters Request Link Layer Control Procedure, we should support this event response from a slave device.

The slave device will answer based on a previous request done by the master (BlueZ in this case) and update current connection parameters accordingly. If the request was rejected, we don't do anything.

---
 include/net/bluetooth/l2cap.h |  2 ++
 net/bluetooth/l2cap_core.c    | 47 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)
include/net/bluetooth/l2cap.h +2 -0
index 803a7f4d93a7..eb7ecd5df9a3 100644
@@ -654,6 +654,8 @@ struct l2cap_conn {
 	struct mutex		chan_lock;
 	struct kref		ref;
 	struct list_head	users;
+
+	struct l2cap_conn_param_update_req conn_param_req;
 };
 
 struct l2cap_user {
net/bluetooth/l2cap_core.c +47 -0

65 lines not on this page · raw message

Signature · 1 line
2.12.2
#3 lore raw

PATCH v5 3/4 Bluetooth: L2CAP: Add BT_LE_CONN_PARAM socket option

In reply to Felipe F. Tonello

There is a need for certain LE profiles (MIDI for example) to change the current connection's parameters. In order to do that, this patch introduces a new BT_LE_CONN_PARAM socket option for SOL_BLUETOOTH protocol which allow user-space l2cap sockets to update the current connection.

It necessary to expose all the connection parameters to user-space because user-space are exposed to those values anyway, via PPCP characteristic or particular profile specification.

If ROLE is SLAVE, then it will send a L2CAP_CONN_PARAM_UPDATE_REQ signaling command to the MASTER, triggering proper LE parameter update procedure. The connection parameters update will only occur upon a successful L2CAP_CONN_PARAM_UPDATE_RSP sent by the MASTER.

If ROLE is MASTER, then immediately update the connection parameters.

Once the connection parameters are effective, a MGMT_EV_NEW_CONN_PARAM event with the store_hint set is sent to user-space so an application can store the connection parameters for persistence reasons.

---
 include/net/bluetooth/bluetooth.h |   8 +++
 net/bluetooth/l2cap_sock.c        | 110 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 118 insertions(+)
include/net/bluetooth/bluetooth.h +8 -0
index 01487192f628..ce5b3abd3b27 100644
@@ -122,6 +122,14 @@ struct bt_voice {
 #define BT_SNDMTU		12
 #define BT_RCVMTU		13
 
+#define BT_LE_CONN_PARAM	14
+struct bt_le_conn_param {
+	__u16 min_interval;
+	__u16 max_interval;
+	__u16 latency;
+	__u16 supervision_timeout;
+};
+
 __printf(1, 2)
 void bt_info(const char *fmt, ...);
 __printf(1, 2)
net/bluetooth/l2cap_sock.c +110 -0

122 lines not on this page · raw message

Signature · 1 line
2.12.2
#4 lore raw

PATCH v5 4/4 Bluetooth: Handle Slave Connection Interval Range AD

In reply to Felipe F. Tonello

The Slave Connection Interval Range data type contains the Peripheral's preferred connection interval range, for all logical connections.

It is useful to parse it in the Kernel so there is no multiple calls to MGMT interface to update the device connection parameters and subsequent connection command call to this device will use proper connection parameters. This saves context-switches and eliminates user-space to update the connection parameters each time a device is found or bluetoothd is restarted and so on. Also, there is no need for the user-space to know care about it because if the slave device wishes to persist with these parameters, it should use the L2CAP connection parameters upade request upon a completed connection.

---
 net/bluetooth/mgmt.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
net/bluetooth/mgmt.c +53 -0
index 1fba2a03f8ae..ea5d6c85f173 100644
@@ -7442,6 +7442,46 @@ static bool is_filter_match(struct hci_dev *hdev, s8 rssi, u8 *eir,
 	return true;
 }
 
+static bool has_eir_slave_conn_int(const u8 *eir_data, u8 eir_len,
+				   u16 *min_conn, u16 *max_conn)
+{
+	u16 len = 0;
+	const u8 EIR_SLAVE_CONN_INT = 0x12; /* Slave Connection Interval Range */
+
+	while (len < eir_len - 1) {
+		u8 field_len = eir_data[0];
+		const u8 *data;
+		u8 data_len;
+
+		/* Check for the end of EIR */
+		if (field_len == 0)
+			break;
+
+		len += field_len + 1;
+
+		/* Do not continue EIR Data parsing if got
+		 * incorrect length
+		 */
+		if (len > eir_len)
+			break;
+
+		data = &eir_data[2];
+		data_len = field_len - 1;
+
+		if (eir_data[1] == EIR_SLAVE_CONN_INT) {
+			if (data_len < 4)
+				break;
+			*min_conn = le16_to_cpu(&data[0]);
+			*max_conn = le16_to_cpu(&data[2]);
+			return true;
+		}
+
+		eir_data += field_len + 1;
+	}
+
+	return false;
+}
+
 void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 		       u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
 		       u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len)
@@ -7449,6 +7489,7 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 	char buf[512];
 	struct mgmt_ev_device_found *ev = (void *)buf;
 	size_t ev_size;
+	struct hci_conn *hcon;
 
 	/* Don't send events for a non-kernel initiated discovery. With
 	 * LE one exception is if we have pend_le_reports > 0 in which
@@ -7521,6 +7562,18 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 	ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len);
 	ev_size = sizeof(*ev) + eir_len + scan_rsp_len;
 
+	/* Search for Slave Connection Interval AD */
+	hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type);
+	if (hcon) {
+		u16 min_conn_int, max_conn_int;
+
+		if (has_eir_slave_conn_int(ev->eir, ev->eir_len,
+					   &min_conn_int, &max_conn_int)) {
+			hcon->le_conn_min_interval = min_conn_int;
+			hcon->le_conn_max_interval = max_conn_int;
+		}
+	}
+
 	mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
 }
 
Signature · 1 line
2.12.2
#5 lore raw

Re: [PATCH v5 BlueZ 4/4] Bluetooth: Handle Slave Connection Interval Range AD

Hi Felipe,

Quoted 12 lines · Felipe F. Tonello

The Slave Connection Interval Range data type contains the Peripheral's preferred connection interval range, for all logical connections.

It is useful to parse it in the Kernel so there is no multiple calls to MGMT interface to update the device connection parameters and subsequent connection command call to this device will use proper connection parameters. This saves context-switches and eliminates user-space to update the connection parameters each time a device is found or bluetoothd is restarted and so on. Also, there is no need for the user-space to know care about it because if the slave device wishes to persist with these parameters, it should use the L2CAP connection parameters upade request upon a completed connection.

nitpick: upade -> update

Quoted 71 lines
---
 net/bluetooth/mgmt.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
net/bluetooth/mgmt.c +43 -0
index 1fba2a03f8ae..ea5d6c85f173 100644
@@ -7442,6 +7442,46 @@ static bool is_filter_match(struct hci_dev *hdev, s8 rssi, u8 *eir,
 	return true;
 }
 
+static bool has_eir_slave_conn_int(const u8 *eir_data, u8 eir_len,
+				   u16 *min_conn, u16 *max_conn)
+{
+	u16 len = 0;
+	const u8 EIR_SLAVE_CONN_INT = 0x12; /* Slave Connection Interval Range */
+
+	while (len < eir_len - 1) {
+		u8 field_len = eir_data[0];
+		const u8 *data;
+		u8 data_len;
+
+		/* Check for the end of EIR */
+		if (field_len == 0)
+			break;
+
+		len += field_len + 1;
+
+		/* Do not continue EIR Data parsing if got
+		 * incorrect length
+		 */
+		if (len > eir_len)
+			break;
+
+		data = &eir_data[2];
+		data_len = field_len - 1;
+
+		if (eir_data[1] == EIR_SLAVE_CONN_INT) {
+			if (data_len < 4)
+				break;
+			*min_conn = le16_to_cpu(&data[0]);
+			*max_conn = le16_to_cpu(&data[2]);
+			return true;
+		}
+
+		eir_data += field_len + 1;
+	}
+
+	return false;
+}
+
 void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 		       u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
 		       u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len)
@@ -7449,6 +7489,7 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 	char buf[512];
 	struct mgmt_ev_device_found *ev = (void *)buf;
 	size_t ev_size;
+	struct hci_conn *hcon;
 
 	/* Don't send events for a non-kernel initiated discovery. With
 	 * LE one exception is if we have pend_le_reports > 0 in which
@@ -7521,6 +7562,18 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
 	ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len);
 	ev_size = sizeof(*ev) + eir_len + scan_rsp_len;
 
+	/* Search for Slave Connection Interval AD */
+	hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type);

net/bluetooth/mgmt.c void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type, · line 7576

Quoted 10 lines
net/bluetooth/mgmt.c +10 -0
+	if (hcon) {
+		u16 min_conn_int, max_conn_int;
+
+		if (has_eir_slave_conn_int(ev->eir, ev->eir_len,
+					   &min_conn_int, &max_conn_int)) {
+			hcon->le_conn_min_interval = min_conn_int;
+			hcon->le_conn_max_interval = max_conn_int;
+		}
+	}
+

It's been some time that I looked at this code, so I could be missing something, but I got the feeling that this part would make more sense if it was at process_adv_report(), there's even the check for a pending connection, so no need to redo that here.

Apart from this, the series looks good.

Quoted 10 lines
net/bluetooth/mgmt.c +0 -1
 	mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
 }
 
--

2.12.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Cheers,
--
Vinicius

#6 lore raw

Re: [PATCH v5 BlueZ 4/4] Bluetooth: Handle Slave Connection Interval Range AD

Hi,

Quoted 97 lines · Vinicius Costa Gomes

Hi Felipe,

Quoted 12 lines · Felipe F. Tonello

The Slave Connection Interval Range data type contains the Peripheral's preferred connection interval range, for all logical connections.

It is useful to parse it in the Kernel so there is no multiple calls to MGMT interface to update the device connection parameters and subsequent connection command call to this device will use proper connection parameters. This saves context-switches and eliminates user-space to update the connection parameters each time a device is found or bluetoothd is restarted and so on. Also, there is no need for the user-space to know care about it because if the slave device wishes to persist with these parameters, it should use the L2CAP connection parameters upade request upon a completed connection.

nitpick: upade -> update

Quoted 78 lines
---
 net/bluetooth/mgmt.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
net/bluetooth/mgmt.c +50 -0
index 1fba2a03f8ae..ea5d6c85f173 100644
@@ -7442,6 +7442,46 @@ static bool is_filter_match(struct hci_dev *hdev, s8 rssi, u8 *eir,
      return true;
 }
 
+static bool has_eir_slave_conn_int(const u8 *eir_data, u8 eir_len,
+                                u16 *min_conn, u16 *max_conn)
+{
+     u16 len = 0;
+     const u8 EIR_SLAVE_CONN_INT = 0x12; /* Slave Connection Interval Range */
+
+     while (len < eir_len - 1) {
+             u8 field_len = eir_data[0];
+             const u8 *data;
+             u8 data_len;
+
+             /* Check for the end of EIR */
+             if (field_len == 0)
+                     break;
+
+             len += field_len + 1;
+
+             /* Do not continue EIR Data parsing if got
+              * incorrect length
+              */
+             if (len > eir_len)
+                     break;
+
+             data = &eir_data[2];
+             data_len = field_len - 1;
+
+             if (eir_data[1] == EIR_SLAVE_CONN_INT) {
+                     if (data_len < 4)
+                             break;
+                     *min_conn = le16_to_cpu(&data[0]);
+                     *max_conn = le16_to_cpu(&data[2]);
+                     return true;
+             }
+
+             eir_data += field_len + 1;
+     }
+
+     return false;
+}
+
 void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
                     u8 addr_type, u8 *dev_class, s8 rssi, u32 flags,
                     u8 *eir, u16 eir_len, u8 *scan_rsp, u8 scan_rsp_len)
@@ -7449,6 +7489,7 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
      char buf[512];
      struct mgmt_ev_device_found *ev = (void *)buf;
      size_t ev_size;
+     struct hci_conn *hcon;
 
      /* Don't send events for a non-kernel initiated discovery. With
       * LE one exception is if we have pend_le_reports > 0 in which
@@ -7521,6 +7562,18 @@ void mgmt_device_found(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 link_type,
      ev->eir_len = cpu_to_le16(eir_len + scan_rsp_len);
      ev_size = sizeof(*ev) + eir_len + scan_rsp_len;
 
+     /* Search for Slave Connection Interval AD */
+     hcon = hci_conn_hash_lookup_le(hdev, bdaddr, addr_type);
+     if (hcon) {
+             u16 min_conn_int, max_conn_int;
+
+             if (has_eir_slave_conn_int(ev->eir, ev->eir_len,
+                                        &min_conn_int, &max_conn_int)) {
+                     hcon->le_conn_min_interval = min_conn_int;
+                     hcon->le_conn_max_interval = max_conn_int;
Quoted 8 lines

net/bluetooth/mgmt.c static bool is_filter_match(struct hci_dev *hdev, s8 rssi, u8 *eir, · line 7481

Quoted 3 lines
net/bluetooth/mgmt.c +3 -0
+             }
+     }
+

It's been some time that I looked at this code, so I could be missing something, but I got the feeling that this part would make more sense if it was at process_adv_report(), there's even the check for a pending connection, so no need to redo that here.

Actually I would use the AD only in case the device is marked for auto-connect or there is a connection pending, so the parameters are only used for the connection alone and are not persisted.

Quoted 17 lines

Apart from this, the series looks good.

Quoted 10 lines
net/bluetooth/mgmt.c +0 -1
      mgmt_event(MGMT_EV_DEVICE_FOUND, hdev, ev, ev_size, NULL);
 }
 
--

2.12.2

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

Cheers,
--
Vinicius

Signature · 1 line
Luiz Augusto von Dentz
#7 lore raw

Re: [PATCH v5 BlueZ 4/4] Bluetooth: Handle Slave Connection Interval Range AD

In reply to Felipe F. Tonello
reproduce:

Hi Felipe,

[auto build test WARNING on bluetooth/master]
[also build test WARNING on v4.11-rc6 next-20170413]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Felipe-F-Tonello/Connection-Update-improvements/20170414-030326
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
config: x86_64-randconfig-x011-201715 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

In file included from include/linux/byteorder/little_endian.h:4:0,

                    from arch/x86/include/uapi/asm/byteorder.h:4,
                    from include/asm-generic/bitops/le.h:5,
                    from arch/x86/include/asm/bitops.h:517,
                    from include/linux/bitops.h:36,
                    from include/linux/kernel.h:10,
                    from include/linux/list.h:8,
                    from include/linux/module.h:9,
                    from net/bluetooth/mgmt.c:27:
   net/bluetooth/mgmt.c: In function 'has_eir_slave_conn_int':
>> include/uapi/linux/byteorder/little_endian.h:35:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^~~~~~~~~~~~~
>> net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^~~~~~~~~~~
>> include/uapi/linux/byteorder/little_endian.h:35:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^~~~~~~~~~~~~
   net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^~~~~~~~~~~
--
   In file included from include/linux/byteorder/little_endian.h:4:0,
                    from arch/x86/include/uapi/asm/byteorder.h:4,
                    from include/asm-generic/bitops/le.h:5,
                    from arch/x86/include/asm/bitops.h:517,
                    from include/linux/bitops.h:36,
                    from include/linux/kernel.h:10,
                    from include/linux/list.h:8,
                    from include/linux/module.h:9,
                    from net//bluetooth/mgmt.c:27:
   net//bluetooth/mgmt.c: In function 'has_eir_slave_conn_int':
>> include/uapi/linux/byteorder/little_endian.h:35:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^~~~~~~~~~~~~
   net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^~~~~~~~~~~
>> include/uapi/linux/byteorder/little_endian.h:35:42: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) ((__force __u16)(__le16)(x))
                                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^~~~~~~~~~~~~
   net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^~~~~~~~~~~

vim +/le16_to_cpu +7474 net/bluetooth/mgmt.c

7458 break;
7459
7460 len += field_len + 1;
7461
7462 /* Do not continue EIR Data parsing if got
7463 * incorrect length
7464 */
7465 if (len > eir_len)
7466 break;
7467
7468 data = &eir_data[2];
7469 data_len = field_len - 1;
7470
7471 if (eir_data[1] == EIR_SLAVE_CONN_INT) {
7472 if (data_len < 4)
7473 break;

> 7474				*min_conn = le16_to_cpu(&data[0]);

7475 *max_conn = le16_to_cpu(&data[2]);
7476 return true;
7477 }
7478
7479 eir_data += field_len + 1;
7480 }
7481
7482 return false;

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#8 lore raw

Re: [PATCH v5 BlueZ 4/4] Bluetooth: Handle Slave Connection Interval Range AD

In reply to Felipe F. Tonello
reproduce: wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross…

Hi Felipe,

[auto build test WARNING on bluetooth/master]
[also build test WARNING on v4.11-rc6 next-20170413]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Felipe-F-Tonello/Connection-Update-improvements/20170414-030326
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth.git master
config: xtensa-allmodconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 4.9.0

reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=xtensa

All warnings (new ones prefixed by >>):

In file included from include/linux/swab.h:4:0,
from include/uapi/linux/byteorder/big_endian.h:12, from include/linux/byteorder/big_endian.h:4, from arch/xtensa/include/uapi/asm/byteorder.h:7, from arch/xtensa/include/asm/bitops.h:23, from include/linux/bitops.h:36,
from include/linux/kernel.h:10,
from include/linux/list.h:8,
from include/linux/module.h:9,
from net/bluetooth/mgmt.c:27:
net/bluetooth/mgmt.c: In function 'has_eir_slave_conn_int':

>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:103:32: note: in definition of macro '__swab16'
     (__builtin_constant_p((__u16)(x)) ? \
                                   ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:13:12: note: in definition of macro '___constant_swab16'
     (((__u16)(x) & (__u16)0x00ffU) << 8) |   \
               ^
   include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:14:12: note: in definition of macro '___constant_swab16'
     (((__u16)(x) & (__u16)0xff00U) >> 8)))
               ^
   include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:105:12: note: in definition of macro '__swab16'
     __fswab16(x))
               ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net/bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:103:32: note: in definition of macro '__swab16'
     (__builtin_constant_p((__u16)(x)) ? \
                                   ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:13:12: note: in definition of macro '___constant_swab16'
     (((__u16)(x) & (__u16)0x00ffU) << 8) |   \
               ^
   include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:14:12: note: in definition of macro '___constant_swab16'
     (((__u16)(x) & (__u16)0xff00U) >> 8)))
               ^
   include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:105:12: note: in definition of macro '__swab16'
     __fswab16(x))
               ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net/bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^
--
   In file included from include/linux/swab.h:4:0,
                    from include/uapi/linux/byteorder/big_endian.h:12,
                    from include/linux/byteorder/big_endian.h:4,
                    from arch/xtensa/include/uapi/asm/byteorder.h:7,
                    from arch/xtensa/include/asm/bitops.h:23,
                    from include/linux/bitops.h:36,
                    from include/linux/kernel.h:10,
                    from include/linux/list.h:8,
                    from include/linux/module.h:9,
                    from net//bluetooth/mgmt.c:27:
   net//bluetooth/mgmt.c: In function 'has_eir_slave_conn_int':
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:103:32: note: in definition of macro '__swab16'
     (__builtin_constant_p((__u16)(x)) ? \
                                   ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:13:12: note: in definition of macro '___constant_swab16'
     (((__u16)(x) & (__u16)0x00ffU) << 8) |   \
               ^
   include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:14:12: note: in definition of macro '___constant_swab16'
     (((__u16)(x) & (__u16)0xff00U) >> 8)))
               ^
   include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:105:12: note: in definition of macro '__swab16'
     __fswab16(x))
               ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net//bluetooth/mgmt.c:7474:16: note: in expansion of macro 'le16_to_cpu'
       *min_conn = le16_to_cpu(&data[0]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:103:32: note: in definition of macro '__swab16'
     (__builtin_constant_p((__u16)(x)) ? \
                                   ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:13:12: note: in definition of macro '___constant_swab16'
     (((__u16)(x) & (__u16)0x00ffU) << 8) |   \
               ^
   include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:14:12: note: in definition of macro '___constant_swab16'
     (((__u16)(x) & (__u16)0xff00U) >> 8)))
               ^
   include/uapi/linux/byteorder/big_endian.h:35:26: note: in expansion of macro '__swab16'
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                             ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^
>> include/uapi/linux/byteorder/big_endian.h:35:50: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
    #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
                                                     ^
   include/uapi/linux/swab.h:105:12: note: in definition of macro '__swab16'
     __fswab16(x))
               ^
   include/linux/byteorder/generic.h:90:21: note: in expansion of macro '__le16_to_cpu'
    #define le16_to_cpu __le16_to_cpu
                        ^
   net//bluetooth/mgmt.c:7475:16: note: in expansion of macro 'le16_to_cpu'
       *max_conn = le16_to_cpu(&data[2]);
                   ^

vim +35 include/uapi/linux/byteorder/big_endian.h

5921e6f8 David Howells  2012-10-13  19  #define __constant_le64_to_cpu(x) ___constant_swab64((__force __u64)(__le64)(x))
5921e6f8 David Howells  2012-10-13  20  #define __constant_cpu_to_le32(x) ((__force __le32)___constant_swab32((x)))
5921e6f8 David Howells  2012-10-13  21  #define __constant_le32_to_cpu(x) ___constant_swab32((__force __u32)(__le32)(x))
5921e6f8 David Howells  2012-10-13  22  #define __constant_cpu_to_le16(x) ((__force __le16)___constant_swab16((x)))
5921e6f8 David Howells  2012-10-13  23  #define __constant_le16_to_cpu(x) ___constant_swab16((__force __u16)(__le16)(x))
5921e6f8 David Howells  2012-10-13  24  #define __constant_cpu_to_be64(x) ((__force __be64)(__u64)(x))
5921e6f8 David Howells  2012-10-13  25  #define __constant_be64_to_cpu(x) ((__force __u64)(__be64)(x))
5921e6f8 David Howells  2012-10-13  26  #define __constant_cpu_to_be32(x) ((__force __be32)(__u32)(x))
5921e6f8 David Howells  2012-10-13  27  #define __constant_be32_to_cpu(x) ((__force __u32)(__be32)(x))
5921e6f8 David Howells  2012-10-13  28  #define __constant_cpu_to_be16(x) ((__force __be16)(__u16)(x))
5921e6f8 David Howells  2012-10-13  29  #define __constant_be16_to_cpu(x) ((__force __u16)(__be16)(x))
5921e6f8 David Howells  2012-10-13  30  #define __cpu_to_le64(x) ((__force __le64)__swab64((x)))
5921e6f8 David Howells  2012-10-13  31  #define __le64_to_cpu(x) __swab64((__force __u64)(__le64)(x))
5921e6f8 David Howells  2012-10-13  32  #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
5921e6f8 David Howells  2012-10-13  33  #define __le32_to_cpu(x) __swab32((__force __u32)(__le32)(x))
5921e6f8 David Howells  2012-10-13  34  #define __cpu_to_le16(x) ((__force __le16)__swab16((x)))
5921e6f8 David Howells  2012-10-13 @35  #define __le16_to_cpu(x) __swab16((__force __u16)(__le16)(x))
5921e6f8 David Howells  2012-10-13  36  #define __cpu_to_be64(x) ((__force __be64)(__u64)(x))
5921e6f8 David Howells  2012-10-13  37  #define __be64_to_cpu(x) ((__force __u64)(__be64)(x))
5921e6f8 David Howells  2012-10-13  38  #define __cpu_to_be32(x) ((__force __be32)(__u32)(x))
5921e6f8 David Howells  2012-10-13  39  #define __be32_to_cpu(x) ((__force __u32)(__be32)(x))
5921e6f8 David Howells  2012-10-13  40  #define __cpu_to_be16(x) ((__force __be16)(__u16)(x))
5921e6f8 David Howells  2012-10-13  41  #define __be16_to_cpu(x) ((__force __u16)(__be16)(x))
5921e6f8 David Howells  2012-10-13  42  

bc27fb68 Denys Vlasenko 2016-03-17 43 static __always_inline __le64 __cpu_to_le64p(const __u64 *p)

:::::: The code at line 35 was first introduced by commit
:::::: 5921e6f8809b1616932ca4afd40fe449faa8fd88 UAPI: (Scripted) Disintegrate include/linux/byteorder

:::::: TO: David Howells <[email protected]>
:::::: CC: David Howells <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation