linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/3] LE Connection Parameter Update Procedure
@ 2011-02-11 21:28 Claudio Takahasi
  2011-02-11 21:28 ` [RFC 1/3] Bluetooth: Add LE signaling commands handling Claudio Takahasi
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Claudio Takahasi @ 2011-02-11 21:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: padovan, Claudio Takahasi

The following patches implement the support for LE Connection Parameter
Update procedure started by the LE slave/peripheral device. Procedure
started by the master will be addressed later when the requirements
become more clear, Bluetooth Core SPEC and GAP test specification are
not matching.

Patches are rebased using Vinicius SMP patches, repo:
git://git.infradead.org/users/vcgomes/linux-2.6.git for-next

LE signaling channel can receive the following L2CAP commands(only):
  - Command Reject
  - Connection Parameter Update request
  - Connection Parameter Update response

Claudio Takahasi (3):
  Bluetooth: Add LE signaling commands handling
  Bluetooth: Add connection parameter update response
  Bluetooth: Send LE Connection Update Command

 include/net/bluetooth/hci.h      |   11 ++
 include/net/bluetooth/hci_core.h |    2 +
 include/net/bluetooth/l2cap.h    |   17 +++
 net/bluetooth/hci_conn.c         |   20 ++++
 net/bluetooth/l2cap_core.c       |  213 ++++++++++++++++++++++++++++---------
 5 files changed, 211 insertions(+), 52 deletions(-)

-- 
1.7.4


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC 1/3] Bluetooth: Add LE signaling commands handling
  2011-02-11 21:28 [RFC 0/3] LE Connection Parameter Update Procedure Claudio Takahasi
@ 2011-02-11 21:28 ` Claudio Takahasi
  2011-02-15 21:14   ` Gustavo F. Padovan
  2011-02-11 21:28 ` [RFC 2/3] Bluetooth: Add connection parameter update response Claudio Takahasi
  2011-02-11 21:28 ` [RFC 3/3] Bluetooth: Send LE Connection Update Command Claudio Takahasi
  2 siblings, 1 reply; 11+ messages in thread
From: Claudio Takahasi @ 2011-02-11 21:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: padovan, Claudio Takahasi

This patch splits the L2CAP command handling function in order to
have a clear separation between the commands related to BR/EDR and
LE. Commands and responses in the LE signaling channel are not being
handled yet, command reject is sent to all received requests. Bluetooth
Core Specification, Volume 3, Part A, section 4 defines the signaling
packets formats and allowed commands/responses over the LE signaling
channel.

Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
---
 include/net/bluetooth/l2cap.h |    2 +
 net/bluetooth/l2cap_core.c    |  150 +++++++++++++++++++++++++++--------------
 2 files changed, 100 insertions(+), 52 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 420981c..6aa70e9 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -89,6 +89,8 @@ struct l2cap_conninfo {
 #define L2CAP_ECHO_RSP		0x09
 #define L2CAP_INFO_REQ		0x0a
 #define L2CAP_INFO_RSP		0x0b
+#define L2CAP_CONN_PARAM_UPDATE_REQ	0x12
+#define L2CAP_CONN_PARAM_UPDATE_RSP	0x13
 
 /* L2CAP feature mask */
 #define L2CAP_FEAT_FLOWCTL	0x00000001
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 0ca54d8..122fc1c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1435,7 +1435,11 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
 
 	lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
 	lh->len = cpu_to_le16(L2CAP_CMD_HDR_SIZE + dlen);
-	lh->cid = cpu_to_le16(L2CAP_CID_SIGNALING);
+
+	if (conn->hcon->type == LE_LINK)
+		lh->cid = cpu_to_le16(L2CAP_CID_LE_SIGNALING);
+	else
+		lh->cid = cpu_to_le16(L2CAP_CID_SIGNALING);
 
 	cmd = (struct l2cap_cmd_hdr *) skb_put(skb, L2CAP_CMD_HDR_SIZE);
 	cmd->code  = code;
@@ -2504,12 +2508,98 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
 	return 0;
 }
 
-static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
+static inline int bredr_sig_cmd(struct l2cap_conn *conn,
+			struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
+{
+	int err = 0;
+
+	switch (cmd->code) {
+	case L2CAP_COMMAND_REJ:
+		l2cap_command_rej(conn, cmd, data);
+		break;
+
+	case L2CAP_CONN_REQ:
+		err = l2cap_connect_req(conn, cmd, data);
+		break;
+
+	case L2CAP_CONN_RSP:
+		err = l2cap_connect_rsp(conn, cmd, data);
+		break;
+
+	case L2CAP_CONF_REQ:
+		err = l2cap_config_req(conn, cmd, cmd_len, data);
+		break;
+
+	case L2CAP_CONF_RSP:
+		err = l2cap_config_rsp(conn, cmd, data);
+		break;
+
+	case L2CAP_DISCONN_REQ:
+		err = l2cap_disconnect_req(conn, cmd, data);
+		break;
+
+	case L2CAP_DISCONN_RSP:
+		err = l2cap_disconnect_rsp(conn, cmd, data);
+		break;
+
+	case L2CAP_ECHO_REQ:
+		l2cap_send_cmd(conn, cmd->ident, L2CAP_ECHO_RSP, cmd_len, data);
+		break;
+
+	case L2CAP_ECHO_RSP:
+		break;
+
+	case L2CAP_INFO_REQ:
+		err = l2cap_information_req(conn, cmd, data);
+		break;
+
+	case L2CAP_INFO_RSP:
+		err = l2cap_information_rsp(conn, cmd, data);
+		break;
+
+	default:
+		BT_ERR("Unknown BR/EDR signaling command 0x%2.2x", cmd->code);
+		err = -EINVAL;
+		break;
+	}
+
+	return err;
+}
+
+static inline int le_sig_cmd(struct l2cap_conn *conn,
+					struct l2cap_cmd_hdr *cmd, u8 *data)
+{
+	int err;
+
+	switch (cmd->code) {
+	case L2CAP_COMMAND_REJ:
+		err = 0;
+		break;
+
+	case L2CAP_CONN_PARAM_UPDATE_REQ:
+		err = -EINVAL;
+		break;
+
+	case L2CAP_CONN_PARAM_UPDATE_RSP:
+		err = 0;
+		break;
+
+	default:
+		BT_ERR("Unknown LE signaling command 0x%2.2x", cmd->code);
+		err = -EINVAL;
+		break;
+	}
+
+	return err;
+}
+
+static inline void l2cap_sig_channel(struct l2cap_conn *conn,
+							struct sk_buff *skb)
 {
 	u8 *data = skb->data;
 	int len = skb->len;
 	struct l2cap_cmd_hdr cmd;
-	int err = 0;
+	int err;
 
 	l2cap_raw_recv(conn, skb);
 
@@ -2528,55 +2618,10 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *sk
 			break;
 		}
 
-		switch (cmd.code) {
-		case L2CAP_COMMAND_REJ:
-			l2cap_command_rej(conn, &cmd, data);
-			break;
-
-		case L2CAP_CONN_REQ:
-			err = l2cap_connect_req(conn, &cmd, data);
-			break;
-
-		case L2CAP_CONN_RSP:
-			err = l2cap_connect_rsp(conn, &cmd, data);
-			break;
-
-		case L2CAP_CONF_REQ:
-			err = l2cap_config_req(conn, &cmd, cmd_len, data);
-			break;
-
-		case L2CAP_CONF_RSP:
-			err = l2cap_config_rsp(conn, &cmd, data);
-			break;
-
-		case L2CAP_DISCONN_REQ:
-			err = l2cap_disconnect_req(conn, &cmd, data);
-			break;
-
-		case L2CAP_DISCONN_RSP:
-			err = l2cap_disconnect_rsp(conn, &cmd, data);
-			break;
-
-		case L2CAP_ECHO_REQ:
-			l2cap_send_cmd(conn, cmd.ident, L2CAP_ECHO_RSP, cmd_len, data);
-			break;
-
-		case L2CAP_ECHO_RSP:
-			break;
-
-		case L2CAP_INFO_REQ:
-			err = l2cap_information_req(conn, &cmd, data);
-			break;
-
-		case L2CAP_INFO_RSP:
-			err = l2cap_information_rsp(conn, &cmd, data);
-			break;
-
-		default:
-			BT_ERR("Unknown signaling command 0x%2.2x", cmd.code);
-			err = -EINVAL;
-			break;
-		}
+		if (conn->hcon->type == LE_LINK)
+			err = le_sig_cmd(conn, &cmd, data);
+		else
+			err = bredr_sig_cmd(conn, &cmd, cmd_len, data);
 
 		if (err) {
 			struct l2cap_cmd_rej rej;
@@ -3573,6 +3618,7 @@ static void l2cap_recv_frame(struct l2cap_conn *conn, struct sk_buff *skb)
 	BT_DBG("len %d, cid 0x%4.4x", len, cid);
 
 	switch (cid) {
+	case L2CAP_CID_LE_SIGNALING:
 	case L2CAP_CID_SIGNALING:
 		l2cap_sig_channel(conn, skb);
 		break;
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [RFC 2/3] Bluetooth: Add connection parameter update response
  2011-02-11 21:28 [RFC 0/3] LE Connection Parameter Update Procedure Claudio Takahasi
  2011-02-11 21:28 ` [RFC 1/3] Bluetooth: Add LE signaling commands handling Claudio Takahasi
@ 2011-02-11 21:28 ` Claudio Takahasi
  2011-02-15 21:15   ` Gustavo F. Padovan
  2011-02-15 21:17   ` Gustavo F. Padovan
  2011-02-11 21:28 ` [RFC 3/3] Bluetooth: Send LE Connection Update Command Claudio Takahasi
  2 siblings, 2 replies; 11+ messages in thread
From: Claudio Takahasi @ 2011-02-11 21:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: padovan, Claudio Takahasi

Implements L2CAP Connection Parameter Update Response defined in
the Bluetooth Core Specification, Volume 3, Part A, section 4.21.
Address the LE Connection Parameter Procedure initiated by the slave.

Connection Interval Minimum and Maximum have the same range: 6 to
3200. Time = N * 1.25ms. Minimum shall be less or equal to Maximum.
The Slave Latency field shall have a value in the range of 0 to
((connSupervisionTimeout / connIntervalMax) - 1). Latency field shall
be less than 500. connSupervisionTimeout = Timeout Multiplier * 10 ms.
Multiplier field shall have a value in the range of 10 to 3200.

Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
---
 include/net/bluetooth/l2cap.h |   15 ++++++++++
 net/bluetooth/l2cap_core.c    |   60 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 74 insertions(+), 1 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 6aa70e9..be0116b 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -261,6 +261,21 @@ struct l2cap_info_rsp {
 #define L2CAP_IR_SUCCESS    0x0000
 #define L2CAP_IR_NOTSUPP    0x0001
 
+struct l2cap_conn_param_update_req {
+	__le16      min;
+	__le16      max;
+	__le16      latency;
+	__le16      to_multiplier;
+} __packed;
+
+struct l2cap_conn_param_update_rsp {
+	__le16      result;
+} __packed;
+
+/* Connection Parameters result */
+#define L2CAP_CONN_PARAM_ACCEPTED	0x0000
+#define L2CAP_CONN_PARAM_REJECTED	0x0001
+
 /* ----- L2CAP connections ----- */
 struct l2cap_chan_list {
 	struct sock	*head;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 122fc1c..8b76a72 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2508,6 +2508,64 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
 	return 0;
 }
 
+static int inline l2cap_check_conn_param(u16 min, u16 max, u16 latency,
+							u16 to_multiplier)
+{
+	u16 max_latency;
+
+	if (min > max || min < 6 || max > 3200)
+		return -EINVAL;
+
+	if (to_multiplier < 10 || to_multiplier > 3200)
+		return -EINVAL;
+
+	if (max >= to_multiplier * 8)
+		return -EINVAL;
+
+	max_latency = (to_multiplier * 8 / max) - 1;
+	if (latency > 499 || latency > max_latency)
+		return -EINVAL;
+
+	return 0;
+}
+
+static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
+					struct l2cap_cmd_hdr *cmd, u8 *data)
+{
+	struct hci_conn *hcon = conn->hcon;
+	struct l2cap_conn_param_update_req *req;
+	struct l2cap_conn_param_update_rsp rsp;
+	u16 min, max, latency, to_multiplier, cmd_len;
+	int err;
+
+	if (!(hcon->link_mode & HCI_LM_MASTER))
+		return -EINVAL;
+
+	cmd_len = __le16_to_cpu(cmd->len);
+	if (cmd_len != sizeof(struct l2cap_conn_param_update_req))
+		return -EPROTO;
+
+	req = (struct l2cap_conn_param_update_req *) data;
+	min 		= __le16_to_cpu(req->min);
+	max 		= __le16_to_cpu(req->max);
+	latency		= __le16_to_cpu(req->latency);
+	to_multiplier	= __le16_to_cpu(req->to_multiplier);
+
+	BT_DBG("min 0x%4.4x max 0x%4.4x latency: 0x%4.4x Timeout: 0x%4.4x",
+						min, max, latency, to_multiplier);
+
+	memset(&rsp, 0, sizeof(rsp));
+	if (l2cap_check_conn_param(min, max, latency, to_multiplier))
+		rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED);
+	else
+		rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED);
+
+	l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP,
+							sizeof(rsp), &rsp);
+
+	return 0;
+}
+
 static inline int bredr_sig_cmd(struct l2cap_conn *conn,
 			struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
 {
@@ -2577,7 +2635,7 @@ static inline int le_sig_cmd(struct l2cap_conn *conn,
 		break;
 
 	case L2CAP_CONN_PARAM_UPDATE_REQ:
-		err = -EINVAL;
+		err = l2cap_conn_param_update_req(conn, cmd, data);
 		break;
 
 	case L2CAP_CONN_PARAM_UPDATE_RSP:
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [RFC 3/3] Bluetooth: Send LE Connection Update Command
  2011-02-11 21:28 [RFC 0/3] LE Connection Parameter Update Procedure Claudio Takahasi
  2011-02-11 21:28 ` [RFC 1/3] Bluetooth: Add LE signaling commands handling Claudio Takahasi
  2011-02-11 21:28 ` [RFC 2/3] Bluetooth: Add connection parameter update response Claudio Takahasi
@ 2011-02-11 21:28 ` Claudio Takahasi
  2011-02-15 21:20   ` Gustavo F. Padovan
  2 siblings, 1 reply; 11+ messages in thread
From: Claudio Takahasi @ 2011-02-11 21:28 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: padovan, Claudio Takahasi

If the new connection update parameter are accepted, the LE master
host sends the LE Connection Update Command to its controller informing
the new requested parameters.

Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
---
 include/net/bluetooth/hci.h      |   11 +++++++++++
 include/net/bluetooth/hci_core.h |    2 ++
 net/bluetooth/hci_conn.c         |   20 ++++++++++++++++++++
 net/bluetooth/l2cap_core.c       |    7 ++++++-
 4 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 46438f4..12417e1 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -701,6 +701,17 @@ struct hci_rp_le_ltk_neg_reply {
 	__le16	handle;
 } __packed;
 
+#define HCI_OP_LE_CONN_UPDATE		0x2013
+struct hci_cp_le_conn_update {
+	__le16   handle;
+	__le16   conn_interval_min;
+	__le16   conn_interval_max;
+	__le16   conn_latency;
+	__le16   supervision_timeout;
+	__le16   min_ce_len;
+	__le16   max_ce_len;
+} __packed;
+
 /* ---- HCI Events ---- */
 #define HCI_EV_INQUIRY_COMPLETE		0x01
 
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 5114122..f6c61d2 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -786,5 +786,7 @@ void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result);
 void hci_le_start_enc(struct hci_conn *conn, u8 ltk[16]);
 void hci_le_ltk_reply(struct hci_conn *conn, u8 ltk[16]);
 void hci_le_ltk_neg_reply(struct hci_conn *conn);
+void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
+					u16 latency, u16 to_multiplier);
 
 #endif /* __HCI_CORE_H */
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index ee7dcdd..d646037 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -231,6 +231,26 @@ void hci_le_ltk_neg_reply(struct hci_conn *conn)
 }
 EXPORT_SYMBOL(hci_le_ltk_neg_reply);
 
+void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
+					u16 latency, u16 to_multiplier)
+{
+	struct hci_cp_le_conn_update cp;
+	struct hci_dev *hdev = conn->hdev;
+
+	memset(&cp, 0, sizeof(cp));
+
+	cp.handle		= cpu_to_le16(conn->handle);
+	cp.conn_interval_min	= cpu_to_le16(min);
+	cp.conn_interval_max	= cpu_to_le16(max);
+	cp.conn_latency		= cpu_to_le16(latency);
+	cp.supervision_timeout	= cpu_to_le16(to_multiplier);
+	cp.min_ce_len		= cpu_to_le16(0x0001);
+	cp.max_ce_len		= cpu_to_le16(0x0001);
+
+	hci_send_cmd(hdev, HCI_OP_LE_CONN_UPDATE, sizeof(cp), &cp);
+}
+EXPORT_SYMBOL(hci_le_conn_update);
+
 /* Device _must_ be locked */
 void hci_sco_setup(struct hci_conn *conn, __u8 status)
 {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 8b76a72..66c4d80 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2555,7 +2555,9 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
 						min, max, latency, to_multiplier);
 
 	memset(&rsp, 0, sizeof(rsp));
-	if (l2cap_check_conn_param(min, max, latency, to_multiplier))
+
+	err = l2cap_check_conn_param(min, max, latency, to_multiplier);
+	if (err)
 		rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED);
 	else
 		rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED);
@@ -2563,6 +2565,9 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
 	l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP,
 							sizeof(rsp), &rsp);
 
+	if (!err)
+		hci_le_conn_update(hcon, min, max, latency, to_multiplier);
+
 	return 0;
 }
 
-- 
1.7.4


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [RFC 1/3] Bluetooth: Add LE signaling commands handling
  2011-02-11 21:28 ` [RFC 1/3] Bluetooth: Add LE signaling commands handling Claudio Takahasi
@ 2011-02-15 21:14   ` Gustavo F. Padovan
  0 siblings, 0 replies; 11+ messages in thread
From: Gustavo F. Padovan @ 2011-02-15 21:14 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

* Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-11 19:28:54 -0200]:

> This patch splits the L2CAP command handling function in order to
> have a clear separation between the commands related to BR/EDR and
> LE. Commands and responses in the LE signaling channel are not being
> handled yet, command reject is sent to all received requests. Bluetooth
> Core Specification, Volume 3, Part A, section 4 defines the signaling
> packets formats and allowed commands/responses over the LE signaling
> channel.
> 
> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
> ---
>  include/net/bluetooth/l2cap.h |    2 +
>  net/bluetooth/l2cap_core.c    |  150 +++++++++++++++++++++++++++--------------
>  2 files changed, 100 insertions(+), 52 deletions(-)
> 
> diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
> index 420981c..6aa70e9 100644
> --- a/include/net/bluetooth/l2cap.h
> +++ b/include/net/bluetooth/l2cap.h
> @@ -89,6 +89,8 @@ struct l2cap_conninfo {
>  #define L2CAP_ECHO_RSP		0x09
>  #define L2CAP_INFO_REQ		0x0a
>  #define L2CAP_INFO_RSP		0x0b
> +#define L2CAP_CONN_PARAM_UPDATE_REQ	0x12
> +#define L2CAP_CONN_PARAM_UPDATE_RSP	0x13
>  
>  /* L2CAP feature mask */
>  #define L2CAP_FEAT_FLOWCTL	0x00000001
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 0ca54d8..122fc1c 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -1435,7 +1435,11 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
>  
>  	lh = (struct l2cap_hdr *) skb_put(skb, L2CAP_HDR_SIZE);
>  	lh->len = cpu_to_le16(L2CAP_CMD_HDR_SIZE + dlen);
> -	lh->cid = cpu_to_le16(L2CAP_CID_SIGNALING);
> +
> +	if (conn->hcon->type == LE_LINK)
> +		lh->cid = cpu_to_le16(L2CAP_CID_LE_SIGNALING);
> +	else
> +		lh->cid = cpu_to_le16(L2CAP_CID_SIGNALING);
>  
>  	cmd = (struct l2cap_cmd_hdr *) skb_put(skb, L2CAP_CMD_HDR_SIZE);
>  	cmd->code  = code;
> @@ -2504,12 +2508,98 @@ static inline int l2cap_information_rsp(struct l2cap_conn *conn, struct l2cap_cm
>  	return 0;
>  }
>  
> -static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb)
> +static inline int bredr_sig_cmd(struct l2cap_conn *conn,
> +			struct l2cap_cmd_hdr *cmd, u16 cmd_len, u8 *data)
> +{
> +	int err = 0;
> +
> +	switch (cmd->code) {
> +	case L2CAP_COMMAND_REJ:
> +		l2cap_command_rej(conn, cmd, data);
> +		break;
> +
> +	case L2CAP_CONN_REQ:
> +		err = l2cap_connect_req(conn, cmd, data);
> +		break;
> +
> +	case L2CAP_CONN_RSP:
> +		err = l2cap_connect_rsp(conn, cmd, data);
> +		break;
> +
> +	case L2CAP_CONF_REQ:
> +		err = l2cap_config_req(conn, cmd, cmd_len, data);
> +		break;
> +
> +	case L2CAP_CONF_RSP:
> +		err = l2cap_config_rsp(conn, cmd, data);
> +		break;
> +
> +	case L2CAP_DISCONN_REQ:
> +		err = l2cap_disconnect_req(conn, cmd, data);
> +		break;
> +
> +	case L2CAP_DISCONN_RSP:
> +		err = l2cap_disconnect_rsp(conn, cmd, data);
> +		break;
> +
> +	case L2CAP_ECHO_REQ:
> +		l2cap_send_cmd(conn, cmd->ident, L2CAP_ECHO_RSP, cmd_len, data);
> +		break;
> +
> +	case L2CAP_ECHO_RSP:
> +		break;
> +
> +	case L2CAP_INFO_REQ:
> +		err = l2cap_information_req(conn, cmd, data);
> +		break;
> +
> +	case L2CAP_INFO_RSP:
> +		err = l2cap_information_rsp(conn, cmd, data);
> +		break;
> +
> +	default:
> +		BT_ERR("Unknown BR/EDR signaling command 0x%2.2x", cmd->code);
> +		err = -EINVAL;
> +		break;
> +	}
> +
> +	return err;
> +}
> +
> +static inline int le_sig_cmd(struct l2cap_conn *conn,
> +					struct l2cap_cmd_hdr *cmd, u8 *data)
> +{
> +	int err;

This var can be removed, I went ahead and removed it for you. Patch is now
applied. I also added a l2cap_ prefix to the new functions you added.

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC 2/3] Bluetooth: Add connection parameter update response
  2011-02-11 21:28 ` [RFC 2/3] Bluetooth: Add connection parameter update response Claudio Takahasi
@ 2011-02-15 21:15   ` Gustavo F. Padovan
  2011-02-15 21:17   ` Gustavo F. Padovan
  1 sibling, 0 replies; 11+ messages in thread
From: Gustavo F. Padovan @ 2011-02-15 21:15 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

* Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-11 19:28:55 -0200]:

> Implements L2CAP Connection Parameter Update Response defined in
> the Bluetooth Core Specification, Volume 3, Part A, section 4.21.
> Address the LE Connection Parameter Procedure initiated by the slave.
> 
> Connection Interval Minimum and Maximum have the same range: 6 to
> 3200. Time = N * 1.25ms. Minimum shall be less or equal to Maximum.
> The Slave Latency field shall have a value in the range of 0 to
> ((connSupervisionTimeout / connIntervalMax) - 1). Latency field shall
> be less than 500. connSupervisionTimeout = Timeout Multiplier * 10 ms.
> Multiplier field shall have a value in the range of 10 to 3200.
> 
> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
> ---
>  include/net/bluetooth/l2cap.h |   15 ++++++++++
>  net/bluetooth/l2cap_core.c    |   60 ++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 74 insertions(+), 1 deletions(-)

Applied, after fix the conflict caused by the changes I did in the previous
patch. Thanks.

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC 2/3] Bluetooth: Add connection parameter update response
  2011-02-11 21:28 ` [RFC 2/3] Bluetooth: Add connection parameter update response Claudio Takahasi
  2011-02-15 21:15   ` Gustavo F. Padovan
@ 2011-02-15 21:17   ` Gustavo F. Padovan
  1 sibling, 0 replies; 11+ messages in thread
From: Gustavo F. Padovan @ 2011-02-15 21:17 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

* Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-11 19:28:55 -0200]:

> Implements L2CAP Connection Parameter Update Response defined in
> the Bluetooth Core Specification, Volume 3, Part A, section 4.21.
> Address the LE Connection Parameter Procedure initiated by the slave.
> 
> Connection Interval Minimum and Maximum have the same range: 6 to
> 3200. Time = N * 1.25ms. Minimum shall be less or equal to Maximum.
> The Slave Latency field shall have a value in the range of 0 to
> ((connSupervisionTimeout / connIntervalMax) - 1). Latency field shall
> be less than 500. connSupervisionTimeout = Timeout Multiplier * 10 ms.
> Multiplier field shall have a value in the range of 10 to 3200.
> 
> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
> ---
>  include/net/bluetooth/l2cap.h |   15 ++++++++++
>  net/bluetooth/l2cap_core.c    |   60 ++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 74 insertions(+), 1 deletions(-)

This one doesn't apply to my tree. Please rebase.

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC 3/3] Bluetooth: Send LE Connection Update Command
  2011-02-11 21:28 ` [RFC 3/3] Bluetooth: Send LE Connection Update Command Claudio Takahasi
@ 2011-02-15 21:20   ` Gustavo F. Padovan
  2011-02-16 13:09     ` Claudio Takahasi
  0 siblings, 1 reply; 11+ messages in thread
From: Gustavo F. Padovan @ 2011-02-15 21:20 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

* Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-11 19:28:56 -0200]:

> If the new connection update parameter are accepted, the LE master
> host sends the LE Connection Update Command to its controller informing
> the new requested parameters.
> 
> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
> ---
>  include/net/bluetooth/hci.h      |   11 +++++++++++
>  include/net/bluetooth/hci_core.h |    2 ++
>  net/bluetooth/hci_conn.c         |   20 ++++++++++++++++++++
>  net/bluetooth/l2cap_core.c       |    7 ++++++-
>  4 files changed, 39 insertions(+), 1 deletions(-)

Actually it is this one that doesn't apply, not 2 of 3.

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [RFC 3/3] Bluetooth: Send LE Connection Update Command
  2011-02-15 21:20   ` Gustavo F. Padovan
@ 2011-02-16 13:09     ` Claudio Takahasi
  2011-02-16 22:44       ` [RFC 3/3 v2] " Claudio Takahasi
  0 siblings, 1 reply; 11+ messages in thread
From: Claudio Takahasi @ 2011-02-16 13:09 UTC (permalink / raw)
  To: Gustavo F. Padovan; +Cc: linux-bluetooth

Hi Gustavo,

On Tue, Feb 15, 2011 at 7:20 PM, Gustavo F. Padovan
<padovan@profusion.mobi> wrote:
> Hi Claudio,
>
> * Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-11 19:28:56 -0200]:
>
>> If the new connection update parameter are accepted, the LE master
>> host sends the LE Connection Update Command to its controller informing
>> the new requested parameters.
>>
>> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
>> ---
>>  include/net/bluetooth/hci.h      |   11 +++++++++++
>>  include/net/bluetooth/hci_core.h |    2 ++
>>  net/bluetooth/hci_conn.c         |   20 ++++++++++++++++++++
>>  net/bluetooth/l2cap_core.c       |    7 ++++++-
>>  4 files changed, 39 insertions(+), 1 deletions(-)
>
> Actually it is this one that doesn't apply, not 2 of 3.
>
> --
> Gustavo F. Padovan
> http://profusion.mobi
>

I will rebase it against bluetooth-next. All patches were using
Vinicius SMP branch as baseline.

Br,
Claudio

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [RFC 3/3 v2] Bluetooth: Send LE Connection Update Command
  2011-02-16 13:09     ` Claudio Takahasi
@ 2011-02-16 22:44       ` Claudio Takahasi
  2011-02-16 23:15         ` Gustavo F. Padovan
  0 siblings, 1 reply; 11+ messages in thread
From: Claudio Takahasi @ 2011-02-16 22:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: padovan, Claudio Takahasi

If the new connection update parameter are accepted, the LE master
host sends the LE Connection Update Command to its controller informing
the new requested parameters.

Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
---
 include/net/bluetooth/hci.h      |   11 +++++++++++
 include/net/bluetooth/hci_core.h |    2 ++
 net/bluetooth/hci_conn.c         |   20 ++++++++++++++++++++
 net/bluetooth/l2cap_core.c       |    8 +++++++-
 4 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 6d4e116..a5f8c46 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -677,6 +677,17 @@ struct hci_cp_le_create_conn {
 
 #define HCI_OP_LE_CREATE_CONN_CANCEL	0x200e
 
+#define HCI_OP_LE_CONN_UPDATE		0x2013
+struct hci_cp_le_conn_update {
+	__le16   handle;
+	__le16   conn_interval_min;
+	__le16   conn_interval_max;
+	__le16   conn_latency;
+	__le16   supervision_timeout;
+	__le16   min_ce_len;
+	__le16   max_ce_len;
+} __packed;
+
 /* ---- HCI Events ---- */
 #define HCI_EV_INQUIRY_COMPLETE		0x01
 
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index ecd2acf..7ee921d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -777,4 +777,6 @@ struct hci_sec_filter {
 
 void hci_req_complete(struct hci_dev *hdev, __u16 cmd, int result);
 
+void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
+					u16 latency, u16 to_multiplier);
 #endif /* __HCI_CORE_H */
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index efcd2b5..a050a69 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -183,6 +183,26 @@ void hci_setup_sync(struct hci_conn *conn, __u16 handle)
 	hci_send_cmd(hdev, HCI_OP_SETUP_SYNC_CONN, sizeof(cp), &cp);
 }
 
+void hci_le_conn_update(struct hci_conn *conn, u16 min, u16 max,
+					u16 latency, u16 to_multiplier)
+{
+	struct hci_cp_le_conn_update cp;
+	struct hci_dev *hdev = conn->hdev;
+
+	memset(&cp, 0, sizeof(cp));
+
+	cp.handle		= cpu_to_le16(conn->handle);
+	cp.conn_interval_min	= cpu_to_le16(min);
+	cp.conn_interval_max	= cpu_to_le16(max);
+	cp.conn_latency		= cpu_to_le16(latency);
+	cp.supervision_timeout	= cpu_to_le16(to_multiplier);
+	cp.min_ce_len		= cpu_to_le16(0x0001);
+	cp.max_ce_len		= cpu_to_le16(0x0001);
+
+	hci_send_cmd(hdev, HCI_OP_LE_CONN_UPDATE, sizeof(cp), &cp);
+}
+EXPORT_SYMBOL(hci_le_conn_update);
+
 /* Device _must_ be locked */
 void hci_sco_setup(struct hci_conn *conn, __u8 status)
 {
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index e0e7b82..bd31367 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -2529,6 +2529,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
 	struct l2cap_conn_param_update_req *req;
 	struct l2cap_conn_param_update_rsp rsp;
 	u16 min, max, latency, to_multiplier, cmd_len;
+	int err;
 
 	if (!(hcon->link_mode & HCI_LM_MASTER))
 		return -EINVAL;
@@ -2547,7 +2548,9 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
 						min, max, latency, to_multiplier);
 
 	memset(&rsp, 0, sizeof(rsp));
-	if (l2cap_check_conn_param(min, max, latency, to_multiplier))
+
+	err = l2cap_check_conn_param(min, max, latency, to_multiplier);
+	if (err)
 		rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED);
 	else
 		rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED);
@@ -2555,6 +2558,9 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
 	l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP,
 							sizeof(rsp), &rsp);
 
+	if (!err)
+		hci_le_conn_update(hcon, min, max, latency, to_multiplier);
+
 	return 0;
 }
 
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [RFC 3/3 v2] Bluetooth: Send LE Connection Update Command
  2011-02-16 22:44       ` [RFC 3/3 v2] " Claudio Takahasi
@ 2011-02-16 23:15         ` Gustavo F. Padovan
  0 siblings, 0 replies; 11+ messages in thread
From: Gustavo F. Padovan @ 2011-02-16 23:15 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

* Claudio Takahasi <claudio.takahasi@openbossa.org> [2011-02-16 20:44:53 -0200]:

> If the new connection update parameter are accepted, the LE master
> host sends the LE Connection Update Command to its controller informing
> the new requested parameters.
> 
> Signed-off-by: Claudio Takahasi <claudio.takahasi@openbossa.org>
> ---
>  include/net/bluetooth/hci.h      |   11 +++++++++++
>  include/net/bluetooth/hci_core.h |    2 ++
>  net/bluetooth/hci_conn.c         |   20 ++++++++++++++++++++
>  net/bluetooth/l2cap_core.c       |    8 +++++++-
>  4 files changed, 40 insertions(+), 1 deletions(-)

Applied, thanks.

-- 
Gustavo F. Padovan
http://profusion.mobi

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2011-02-16 23:15 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-11 21:28 [RFC 0/3] LE Connection Parameter Update Procedure Claudio Takahasi
2011-02-11 21:28 ` [RFC 1/3] Bluetooth: Add LE signaling commands handling Claudio Takahasi
2011-02-15 21:14   ` Gustavo F. Padovan
2011-02-11 21:28 ` [RFC 2/3] Bluetooth: Add connection parameter update response Claudio Takahasi
2011-02-15 21:15   ` Gustavo F. Padovan
2011-02-15 21:17   ` Gustavo F. Padovan
2011-02-11 21:28 ` [RFC 3/3] Bluetooth: Send LE Connection Update Command Claudio Takahasi
2011-02-15 21:20   ` Gustavo F. Padovan
2011-02-16 13:09     ` Claudio Takahasi
2011-02-16 22:44       ` [RFC 3/3 v2] " Claudio Takahasi
2011-02-16 23:15         ` Gustavo F. Padovan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).