All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johan Hedberg <johan.hedberg@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH 02/13] Bluetooth: Create independent LE signalling defines and structs
Date: Mon, 29 Apr 2013 19:35:34 +0300	[thread overview]
Message-ID: <1367253345-12482-3-git-send-email-johan.hedberg@gmail.com> (raw)
In-Reply-To: <1367253345-12482-1-git-send-email-johan.hedberg@gmail.com>

From: Johan Hedberg <johan.hedberg@intel.com>

Since the LE signalling channel is independent from the BR/EDR
signalling channel and may experience changes incompatible with the
BR/EDR channel it makes sense from the start to have independent defines
and structs for it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 include/net/bluetooth/l2cap.h |   34 ++++++++++++++++++++++++++++++----
 net/bluetooth/l2cap_core.c    |   24 ++++++++++++------------
 2 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index fb94cf1..2f52a28 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -110,8 +110,13 @@ struct l2cap_conninfo {
 #define L2CAP_MOVE_CHAN_RSP	0x0f
 #define L2CAP_MOVE_CHAN_CFM	0x10
 #define L2CAP_MOVE_CHAN_CFM_RSP	0x11
-#define L2CAP_CONN_PARAM_UPDATE_REQ	0x12
-#define L2CAP_CONN_PARAM_UPDATE_RSP	0x13
+
+/* L2CAP LE command codes */
+#define L2CAP_LE_COMMAND_REJ		0x01
+#define L2CAP_LE_DISCONN_REQ		0x06
+#define L2CAP_LE_DISCONN_RSP		0x07
+#define L2CAP_LE_CONN_PARAM_UPDATE_REQ	0x12
+#define L2CAP_LE_CONN_PARAM_UPDATE_RSP	0x13
 
 /* L2CAP extended feature mask */
 #define L2CAP_FEAT_FLOWCTL	0x00000001
@@ -406,14 +411,35 @@ struct l2cap_move_chan_cfm_rsp {
 #define L2CAP_IR_SUCCESS	0x0000
 #define L2CAP_IR_NOTSUPP	0x0001
 
-struct l2cap_conn_param_update_req {
+struct l2cap_le_cmd_hdr {
+	__u8       code;
+	__u8       ident;
+	__le16     len;
+} __packed;
+#define L2CAP_LE_CMD_HDR_SIZE	4
+
+struct l2cap_le_cmd_rej_unk {
+	__le16     reason;
+} __packed;
+
+struct l2cap_le_disconn_req {
+	__le16     dcid;
+	__le16     scid;
+} __packed;
+
+struct l2cap_le_disconn_rsp {
+	__le16     dcid;
+	__le16     scid;
+} __packed;
+
+struct l2cap_le_conn_param_update_req {
 	__le16      min;
 	__le16      max;
 	__le16      latency;
 	__le16      to_multiplier;
 } __packed;
 
-struct l2cap_conn_param_update_rsp {
+struct l2cap_le_conn_param_update_rsp {
 	__le16      result;
 } __packed;
 
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 1adda11..6bf5d19 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -5113,13 +5113,13 @@ static inline int l2cap_check_conn_param(u16 min, u16 max, u16 latency,
 	return 0;
 }
 
-static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
-					      struct l2cap_cmd_hdr *cmd,
-					      u8 *data)
+static inline int l2cap_le_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;
+	struct l2cap_le_conn_param_update_req *req;
+	struct l2cap_le_conn_param_update_rsp rsp;
 	u16 min, max, latency, to_multiplier, cmd_len;
 	int err;
 
@@ -5127,10 +5127,10 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
 		return -EINVAL;
 
 	cmd_len = __le16_to_cpu(cmd->len);
-	if (cmd_len != sizeof(struct l2cap_conn_param_update_req))
+	if (cmd_len != sizeof(struct l2cap_le_conn_param_update_req))
 		return -EPROTO;
 
-	req = (struct l2cap_conn_param_update_req *) data;
+	req = (struct l2cap_le_conn_param_update_req *) data;
 	min		= __le16_to_cpu(req->min);
 	max		= __le16_to_cpu(req->max);
 	latency		= __le16_to_cpu(req->latency);
@@ -5147,7 +5147,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
 	else
 		rsp.result = __constant_cpu_to_le16(L2CAP_CONN_PARAM_ACCEPTED);
 
-	l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_PARAM_UPDATE_RSP,
+	l2cap_send_cmd(conn, cmd->ident, L2CAP_LE_CONN_PARAM_UPDATE_RSP,
 		       sizeof(rsp), &rsp);
 
 	if (!err)
@@ -5240,13 +5240,13 @@ static inline int l2cap_le_sig_cmd(struct l2cap_conn *conn,
 				   struct l2cap_cmd_hdr *cmd, u8 *data)
 {
 	switch (cmd->code) {
-	case L2CAP_COMMAND_REJ:
+	case L2CAP_LE_COMMAND_REJ:
 		return 0;
 
-	case L2CAP_CONN_PARAM_UPDATE_REQ:
-		return l2cap_conn_param_update_req(conn, cmd, data);
+	case L2CAP_LE_CONN_PARAM_UPDATE_REQ:
+		return l2cap_le_conn_param_update_req(conn, cmd, data);
 
-	case L2CAP_CONN_PARAM_UPDATE_RSP:
+	case L2CAP_LE_CONN_PARAM_UPDATE_RSP:
 		return 0;
 
 	default:
-- 
1.7.10.4


  parent reply	other threads:[~2013-04-29 16:35 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-29 16:35 [PATCH 00/13] Bluetooth: L2CAP cleanups and fixes Johan Hedberg
2013-04-29 16:35 ` [PATCH 01/13] Bluetooth: Handle LE L2CAP signalling in its own function Johan Hedberg
2013-04-29 16:35 ` Johan Hedberg [this message]
2013-04-29 16:35 ` [PATCH 03/13] Bluetooth: Rename L2CAP_CID_LE_DATA to L2CAP_CID_ATT Johan Hedberg
2013-04-29 16:35 ` [PATCH 04/13] Bluetooth: Fix LE vs BR/EDR selection when connecting Johan Hedberg
2013-04-30 17:36   ` Vinicius Costa Gomes
2013-04-30 17:51     ` Marcel Holtmann
2013-04-30 18:33       ` Vinicius Costa Gomes
2013-04-30 17:53     ` Johan Hedberg
2013-04-29 16:35 ` [PATCH 05/13] Bluetooth: Fix EBUSY condition test in l2cap_chan_connect Johan Hedberg
2013-04-29 16:35 ` [PATCH 06/13] Bluetooth: Fix hardcoding ATT CID in __l2cap_chan_add() Johan Hedberg
2013-04-29 16:35 ` [PATCH 07/13] Bluetooth: Add clarifying comment to l2cap_conn_ready() Johan Hedberg
2013-04-29 16:35 ` [PATCH 08/13] Bluetooth: Fix duplicate call to l2cap_chan_ready() Johan Hedberg
2013-04-29 16:35 ` [PATCH 09/13] Bluetooth: Remove useless sk variable in l2cap_le_conn_ready Johan Hedberg
2013-04-29 16:35 ` [PATCH 10/13] Bluetooth: Remove unnecessary L2CAP channel state check Johan Hedberg
2013-04-29 16:35 ` [PATCH 11/13] Bluetooth: Simplify hci_conn_hold/drop logic for L2CAP Johan Hedberg
2013-04-29 16:35 ` [PATCH 12/13] Bluetooth: Remove useless hci_conn disc_timeout setting Johan Hedberg
2013-04-29 16:35 ` [PATCH 13/13] Bluetooth: Fix multiple LE socket handling Johan Hedberg
2013-04-30 22:10   ` Gustavo Padovan
2013-04-29 17:07 ` [PATCH 00/13] Bluetooth: L2CAP cleanups and fixes Marcel Holtmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1367253345-12482-3-git-send-email-johan.hedberg@gmail.com \
    --to=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.