* [PATCH -v2 1/2] Bluetooth: Merge L2CAP and SCO modules into bluetooth.ko
From: Gustavo F. Padovan @ 2011-02-09 17:17 UTC (permalink / raw)
To: linux-bluetooth
Actually doesn't make sense have these modules built separately.
The L2CAP layer is needed by almost all Bluetooth protocols and profiles.
There isn't any real use case without having L2CAP loaded.
SCO is only essential for Audio transfers, but it is so small that we can
have it loaded always in bluetooth.ko without problems.
If you really doesn't want it you can disable SCO in the kernel config.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
include/net/bluetooth/bluetooth.h | 28 ++++++++++++++++++++++++++++
net/bluetooth/Kconfig | 10 ++--------
net/bluetooth/Makefile | 5 ++---
net/bluetooth/af_bluetooth.c | 32 ++++++++++++++++++++++++++++++--
net/bluetooth/l2cap_core.c | 16 ++--------------
net/bluetooth/sco.c | 16 ++--------------
6 files changed, 66 insertions(+), 41 deletions(-)
diff --git a/include/net/bluetooth/bluetooth.h b/include/net/bluetooth/bluetooth.h
index ed7d775..4375043 100644
--- a/include/net/bluetooth/bluetooth.h
+++ b/include/net/bluetooth/bluetooth.h
@@ -205,4 +205,32 @@ extern void bt_sysfs_cleanup(void);
extern struct dentry *bt_debugfs;
+#ifdef CONFIG_BT_L2CAP
+int l2cap_init(void);
+void l2cap_exit(void);
+#else
+static inline int l2cap_init(void)
+{
+ return 0;
+}
+
+static inline void l2cap_exit(void)
+{
+}
+#endif
+
+#ifdef CONFIG_BT_SCO
+int sco_init(void);
+void sco_exit(void);
+#else
+static inline int sco_init(void)
+{
+ return 0;
+}
+
+static inline void sco_exit(void)
+{
+}
+#endif
+
#endif /* __BLUETOOTH_H */
diff --git a/net/bluetooth/Kconfig b/net/bluetooth/Kconfig
index e45eae6..c6f9c2f 100644
--- a/net/bluetooth/Kconfig
+++ b/net/bluetooth/Kconfig
@@ -32,7 +32,7 @@ menuconfig BT
more information, see <http://www.bluez.org/>.
config BT_L2CAP
- tristate "L2CAP protocol support"
+ bool "L2CAP protocol support"
depends on BT
select CRC16
help
@@ -40,19 +40,13 @@ config BT_L2CAP
connection oriented and connection-less data transport. L2CAP
support is required for most Bluetooth applications.
- Say Y here to compile L2CAP support into the kernel or say M to
- compile it as module (l2cap).
-
config BT_SCO
- tristate "SCO links support"
+ bool "SCO links support"
depends on BT
help
SCO link provides voice transport over Bluetooth. SCO support is
required for voice applications like Headset and Audio.
- Say Y here to compile SCO support into the kernel or say M to
- compile it as module (sco).
-
source "net/bluetooth/rfcomm/Kconfig"
source "net/bluetooth/bnep/Kconfig"
diff --git a/net/bluetooth/Makefile b/net/bluetooth/Makefile
index 339b429..f04fe9a 100644
--- a/net/bluetooth/Makefile
+++ b/net/bluetooth/Makefile
@@ -3,12 +3,11 @@
#
obj-$(CONFIG_BT) += bluetooth.o
-obj-$(CONFIG_BT_L2CAP) += l2cap.o
-obj-$(CONFIG_BT_SCO) += sco.o
obj-$(CONFIG_BT_RFCOMM) += rfcomm/
obj-$(CONFIG_BT_BNEP) += bnep/
obj-$(CONFIG_BT_CMTP) += cmtp/
obj-$(CONFIG_BT_HIDP) += hidp/
bluetooth-y := af_bluetooth.o hci_core.o hci_conn.o hci_event.o mgmt.o hci_sock.o hci_sysfs.o lib.o
-l2cap-y := l2cap_core.o l2cap_sock.o
+bluetooth-$(CONFIG_BT_L2CAP) += l2cap_core.o l2cap_sock.o
+bluetooth-$(CONFIG_BT_SCO) += sco.o
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c
index 2abfe2f..c258027 100644
--- a/net/bluetooth/af_bluetooth.c
+++ b/net/bluetooth/af_bluetooth.c
@@ -40,7 +40,7 @@
#include <net/bluetooth/bluetooth.h>
-#define VERSION "2.15"
+#define VERSION "2.16"
/* Bluetooth sockets */
#define BT_MAX_PROTO 8
@@ -545,13 +545,41 @@ static int __init bt_init(void)
BT_INFO("HCI device and connection manager initialized");
- hci_sock_init();
+ err = hci_sock_init();
+ if (err < 0)
+ goto error;
+
+ err = l2cap_init();
+ if (err < 0) {
+ hci_sock_cleanup();
+ goto sock_err;
+ }
+
+ err = sco_init();
+ if (err < 0) {
+ l2cap_exit();
+ goto sock_err;
+ }
return 0;
+
+sock_err:
+ hci_sock_cleanup();
+
+error:
+ sock_unregister(PF_BLUETOOTH);
+ bt_sysfs_cleanup();
+
+ return err;
}
static void __exit bt_exit(void)
{
+
+ sco_exit();
+
+ l2cap_exit();
+
hci_sock_cleanup();
sock_unregister(PF_BLUETOOTH);
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index ba7f9da..6f054d9 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -55,8 +55,6 @@
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/l2cap.h>
-#define VERSION "2.15"
-
int disable_ertm;
static u32 l2cap_feat_mask = L2CAP_FEAT_FIXED_CHAN;
@@ -3806,7 +3804,7 @@ static struct hci_proto l2cap_hci_proto = {
.recv_acldata = l2cap_recv_acldata
};
-static int __init l2cap_init(void)
+int __init l2cap_init(void)
{
int err;
@@ -3834,7 +3832,6 @@ static int __init l2cap_init(void)
BT_ERR("Failed to create L2CAP debug file");
}
- BT_INFO("L2CAP ver %s", VERSION);
BT_INFO("L2CAP socket layer initialized");
return 0;
@@ -3845,7 +3842,7 @@ error:
return err;
}
-static void __exit l2cap_exit(void)
+void l2cap_exit(void)
{
debugfs_remove(l2cap_debugfs);
@@ -3866,14 +3863,5 @@ void l2cap_load(void)
}
EXPORT_SYMBOL(l2cap_load);
-module_init(l2cap_init);
-module_exit(l2cap_exit);
-
module_param(disable_ertm, bool, 0644);
MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode");
-
-MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
-MODULE_DESCRIPTION("Bluetooth L2CAP ver " VERSION);
-MODULE_VERSION(VERSION);
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("bt-proto-0");
diff --git a/net/bluetooth/sco.c b/net/bluetooth/sco.c
index 960c6d1..b517183 100644
--- a/net/bluetooth/sco.c
+++ b/net/bluetooth/sco.c
@@ -50,8 +50,6 @@
#include <net/bluetooth/hci_core.h>
#include <net/bluetooth/sco.h>
-#define VERSION "0.6"
-
static int disable_esco;
static const struct proto_ops sco_sock_ops;
@@ -1023,7 +1021,7 @@ static struct hci_proto sco_hci_proto = {
.recv_scodata = sco_recv_scodata
};
-static int __init sco_init(void)
+int __init sco_init(void)
{
int err;
@@ -1051,7 +1049,6 @@ static int __init sco_init(void)
BT_ERR("Failed to create SCO debug file");
}
- BT_INFO("SCO (Voice Link) ver %s", VERSION);
BT_INFO("SCO socket layer initialized");
return 0;
@@ -1061,7 +1058,7 @@ error:
return err;
}
-static void __exit sco_exit(void)
+void __exit sco_exit(void)
{
debugfs_remove(sco_debugfs);
@@ -1074,14 +1071,5 @@ static void __exit sco_exit(void)
proto_unregister(&sco_proto);
}
-module_init(sco_init);
-module_exit(sco_exit);
-
module_param(disable_esco, bool, 0644);
MODULE_PARM_DESC(disable_esco, "Disable eSCO connection creation");
-
-MODULE_AUTHOR("Marcel Holtmann <marcel@holtmann.org>");
-MODULE_DESCRIPTION("Bluetooth SCO ver " VERSION);
-MODULE_VERSION(VERSION);
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("bt-proto-2");
--
1.7.4
^ permalink raw reply related
* [PATCH -v2 2/2] Bluetooth: remove l2cap_load() hack
From: Gustavo F. Padovan @ 2011-02-09 17:17 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1297271871-7458-1-git-send-email-padovan@profusion.mobi>
l2cap_load() was added to trigger l2cap.ko module loading from the RFCOMM
and BNEP modules. Now that L2CAP module is gone, we don't need it anymore.
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
---
net/bluetooth/bnep/core.c | 2 --
net/bluetooth/l2cap_core.c | 8 --------
net/bluetooth/rfcomm/core.c | 2 --
3 files changed, 0 insertions(+), 12 deletions(-)
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 5868597..03d4d12 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -708,8 +708,6 @@ static int __init bnep_init(void)
{
char flt[50] = "";
- l2cap_load();
-
#ifdef CONFIG_BT_BNEP_PROTO_FILTER
strcat(flt, "protocol ");
#endif
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 6f054d9..bd88641 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3855,13 +3855,5 @@ void l2cap_exit(void)
l2cap_cleanup_sockets();
}
-void l2cap_load(void)
-{
- /* Dummy function to trigger automatic L2CAP module loading by
- * other modules that use L2CAP sockets but don't use any other
- * symbols from it. */
-}
-EXPORT_SYMBOL(l2cap_load);
-
module_param(disable_ertm, bool, 0644);
MODULE_PARM_DESC(disable_ertm, "Disable enhanced retransmission mode");
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index 6b83776..c997393 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -2154,8 +2154,6 @@ static int __init rfcomm_init(void)
{
int err;
- l2cap_load();
-
hci_register_cb(&rfcomm_cb);
rfcomm_thread = kthread_run(rfcomm_run, NULL, "krfcommd");
--
1.7.4
^ permalink raw reply related
* [PATCH -v3 1/6] Partial dump of ATT PDUs
From: Andre Dieb Martins @ 2011-02-09 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Dieb Martins
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 6617 bytes --]
Starts implementing dumping for ATT/GATT pdus.
---
Makefile.am | 1 +
parser/att.c | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
parser/l2cap.c | 7 +++
parser/parser.h | 2 +
src/hcidump.c | 1 +
5 files changed, 172 insertions(+), 0 deletions(-)
create mode 100644 parser/att.c
diff --git a/Makefile.am b/Makefile.am
index e39ae1e..99dd422 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,6 +5,7 @@ parser_sources = parser/parser.h parser/parser.c \
parser/lmp.c \
parser/hci.c \
parser/l2cap.c \
+ parser/att.c \
parser/sdp.h parser/sdp.c \
parser/rfcomm.h parser/rfcomm.c \
parser/bnep.c \
diff --git a/parser/att.c b/parser/att.c
new file mode 100644
index 0000000..eb0d00b
--- /dev/null
+++ b/parser/att.c
@@ -0,0 +1,161 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2011 André Dieb Martins <andre.dieb@gmail.com>
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <netinet/in.h>
+
+#include "parser.h"
+
+/* Attribute Protocol Opcodes */
+#define ATT_OP_ERROR 0x01
+#define ATT_OP_MTU_REQ 0x02
+#define ATT_OP_MTU_RESP 0x03
+#define ATT_OP_FIND_INFO_REQ 0x04
+#define ATT_OP_FIND_INFO_RESP 0x05
+#define ATT_OP_FIND_BY_TYPE_REQ 0x06
+#define ATT_OP_FIND_BY_TYPE_RESP 0x07
+#define ATT_OP_READ_BY_TYPE_REQ 0x08
+#define ATT_OP_READ_BY_TYPE_RESP 0x09
+#define ATT_OP_READ_REQ 0x0A
+#define ATT_OP_READ_RESP 0x0B
+#define ATT_OP_READ_BLOB_REQ 0x0C
+#define ATT_OP_READ_BLOB_RESP 0x0D
+#define ATT_OP_READ_MULTI_REQ 0x0E
+#define ATT_OP_READ_MULTI_RESP 0x0F
+#define ATT_OP_READ_BY_GROUP_REQ 0x10
+#define ATT_OP_READ_BY_GROUP_RESP 0x11
+#define ATT_OP_WRITE_REQ 0x12
+#define ATT_OP_WRITE_RESP 0x13
+#define ATT_OP_WRITE_CMD 0x52
+#define ATT_OP_PREP_WRITE_REQ 0x16
+#define ATT_OP_PREP_WRITE_RESP 0x17
+#define ATT_OP_EXEC_WRITE_REQ 0x18
+#define ATT_OP_EXEC_WRITE_RESP 0x19
+#define ATT_OP_HANDLE_NOTIFY 0x1B
+#define ATT_OP_HANDLE_IND 0x1D
+#define ATT_OP_HANDLE_CNF 0x1E
+#define ATT_OP_SIGNED_WRITE_CMD 0xD2
+
+
+/* Attribute Protocol Opcodes */
+static const char *attop2str(uint8_t op)
+{
+ switch (op) {
+ case ATT_OP_ERROR:
+ return "Error";
+ case ATT_OP_MTU_REQ:
+ return "MTU req";
+ case ATT_OP_MTU_RESP:
+ return "MTU resp";
+ case ATT_OP_FIND_INFO_REQ:
+ return "Find Information req";
+ case ATT_OP_FIND_INFO_RESP:
+ return "Find Information resp";
+ case ATT_OP_FIND_BY_TYPE_REQ:
+ return "Find By Type req";
+ case ATT_OP_FIND_BY_TYPE_RESP:
+ return "Find By Type resp";
+ case ATT_OP_READ_BY_TYPE_REQ:
+ return "Read By Type req";
+ case ATT_OP_READ_BY_TYPE_RESP:
+ return "Read By Type resp";
+ case ATT_OP_READ_REQ:
+ return "Read req";
+ case ATT_OP_READ_RESP:
+ return "Read resp";
+ case ATT_OP_READ_BLOB_REQ:
+ return "Read Blob req";
+ case ATT_OP_READ_BLOB_RESP:
+ return "Read Blob resp";
+ case ATT_OP_READ_MULTI_REQ:
+ return "Read Multi req";
+ case ATT_OP_READ_MULTI_RESP:
+ return "Read Multi resp";
+ case ATT_OP_READ_BY_GROUP_REQ:
+ return "Read By Group req";
+ case ATT_OP_READ_BY_GROUP_RESP:
+ return "Read By Group resp";
+ case ATT_OP_WRITE_REQ:
+ return "Write req";
+ case ATT_OP_WRITE_RESP:
+ return "Write resp";
+ case ATT_OP_WRITE_CMD:
+ return "Write cmd";
+ case ATT_OP_PREP_WRITE_REQ:
+ return "Prepare Write req";
+ case ATT_OP_PREP_WRITE_RESP:
+ return "Prepare Write resp";
+ case ATT_OP_EXEC_WRITE_REQ:
+ return "Exec Write req";
+ case ATT_OP_EXEC_WRITE_RESP:
+ return "Exec Write resp";
+ case ATT_OP_HANDLE_NOTIFY:
+ return "Handle notify";
+ case ATT_OP_HANDLE_IND:
+ return "Handle indicate";
+ case ATT_OP_HANDLE_CNF:
+ return "Handle CNF";
+ case ATT_OP_SIGNED_WRITE_CMD:
+ return "Signed Write Cmd";
+ default:
+ return "Unknown";
+ }
+}
+
+static void att_handle_notify_dump(int level, struct frame *frm)
+{
+ uint16_t handle = btohs(htons(get_u16(frm)));
+
+ p_indent(level, frm);
+ printf("handle 0x%2.2x\n", handle);
+}
+
+void att_dump(int level, struct frame *frm)
+{
+ uint8_t op;
+
+ op = get_u8(frm);
+
+ p_indent(level, frm);
+ printf("ATT: %s (0x%.2x)\n", attop2str(op), op);
+
+ switch (op) {
+ case ATT_OP_HANDLE_NOTIFY:
+ att_handle_notify_dump(level + 1, frm);
+ break;
+
+ default:
+ raw_dump(level, frm);
+ break;
+ }
+}
diff --git a/parser/l2cap.c b/parser/l2cap.c
index 5c5371f..963468c 100644
--- a/parser/l2cap.c
+++ b/parser/l2cap.c
@@ -898,6 +898,13 @@ static void l2cap_parse(int level, struct frame *frm)
raw_dump(level + 1, frm);
break;
+ case 0x1f:
+ if (!p_filter(FILT_ATT))
+ att_dump(level, frm);
+ else
+ raw_dump(level + 1, frm);
+ break;
+
default:
proto = get_proto(frm->handle, psm, 0);
diff --git a/parser/parser.h b/parser/parser.h
index 973ab22..f093b6b 100644
--- a/parser/parser.h
+++ b/parser/parser.h
@@ -77,6 +77,7 @@ struct frame {
#define FILT_HCRP 0x0200
#define FILT_AVDTP 0x0400
#define FILT_AVCTP 0x0800
+#define FILT_ATT 0x1000
#define FILT_OBEX 0x00010000
#define FILT_CAPI 0x00020000
@@ -229,6 +230,7 @@ void hidp_dump(int level, struct frame *frm);
void hcrp_dump(int level, struct frame *frm);
void avdtp_dump(int level, struct frame *frm);
void avctp_dump(int level, struct frame *frm);
+void att_dump(int level, struct frame *frm);
void obex_dump(int level, struct frame *frm);
void capi_dump(int level, struct frame *frm);
diff --git a/src/hcidump.c b/src/hcidump.c
index b344489..af086c7 100644
--- a/src/hcidump.c
+++ b/src/hcidump.c
@@ -824,6 +824,7 @@ static struct {
{ "cmtp", FILT_CMTP },
{ "hidp", FILT_HIDP },
{ "hcrp", FILT_HCRP },
+ { "att", FILT_ATT },
{ "avdtp", FILT_AVDTP },
{ "avctp", FILT_AVCTP },
{ "obex", FILT_OBEX },
--
1.7.1
^ permalink raw reply related
* [PATCH -v3 2/6] Add ATT MTU req/resp and notify value
From: Andre Dieb Martins @ 2011-02-09 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Dieb Martins
In-Reply-To: <1297272535-14890-1-git-send-email-andre.dieb@signove.com>
---
parser/att.c | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/parser/att.c b/parser/att.c
index eb0d00b..261dfe6 100644
--- a/parser/att.c
+++ b/parser/att.c
@@ -132,12 +132,35 @@ static const char *attop2str(uint8_t op)
}
}
+static void att_mtu_req_dump(int level, struct frame *frm)
+{
+ uint16_t client_rx_mtu = btohs(htons(get_u16(frm)));
+
+ p_indent(level, frm);
+ printf("client rx mtu %d\n", client_rx_mtu);
+}
+
+static void att_mtu_resp_dump(int level, struct frame *frm)
+{
+ uint16_t server_rx_mtu = btohs(htons(get_u16(frm)));
+
+ p_indent(level, frm);
+ printf("server rx mtu %d\n", server_rx_mtu);
+}
+
static void att_handle_notify_dump(int level, struct frame *frm)
{
uint16_t handle = btohs(htons(get_u16(frm)));
p_indent(level, frm);
printf("handle 0x%2.2x\n", handle);
+
+ p_indent(level, frm);
+ printf("value ");
+ while (frm->len > 0) {
+ printf("0x%.2x ", get_u8(frm));
+ }
+ printf("\n");
}
void att_dump(int level, struct frame *frm)
@@ -150,6 +173,12 @@ void att_dump(int level, struct frame *frm)
printf("ATT: %s (0x%.2x)\n", attop2str(op), op);
switch (op) {
+ case ATT_OP_MTU_REQ:
+ att_mtu_req_dump(level + 1, frm);
+ break;
+ case ATT_OP_MTU_RESP:
+ att_mtu_resp_dump(level + 1, frm);
+ break;
case ATT_OP_HANDLE_NOTIFY:
att_handle_notify_dump(level + 1, frm);
break;
--
1.7.1
^ permalink raw reply related
* [PATCH -v3 3/6] Add ATT error pdu dump
From: Andre Dieb Martins @ 2011-02-09 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Dieb Martins
In-Reply-To: <1297272535-14890-1-git-send-email-andre.dieb@signove.com>
---
parser/att.c | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 80 insertions(+), 0 deletions(-)
diff --git a/parser/att.c b/parser/att.c
index 261dfe6..3717839 100644
--- a/parser/att.c
+++ b/parser/att.c
@@ -66,6 +66,26 @@
#define ATT_OP_HANDLE_CNF 0x1E
#define ATT_OP_SIGNED_WRITE_CMD 0xD2
+/* Error codes for Error response PDU */
+#define ATT_ECODE_INVALID_HANDLE 0x01
+#define ATT_ECODE_READ_NOT_PERM 0x02
+#define ATT_ECODE_WRITE_NOT_PERM 0x03
+#define ATT_ECODE_INVALID_PDU 0x04
+#define ATT_ECODE_INSUFF_AUTHEN 0x05
+#define ATT_ECODE_REQ_NOT_SUPP 0x06
+#define ATT_ECODE_INVALID_OFFSET 0x07
+#define ATT_ECODE_INSUFF_AUTHO 0x08
+#define ATT_ECODE_PREP_QUEUE_FULL 0x09
+#define ATT_ECODE_ATTR_NOT_FOUND 0x0A
+#define ATT_ECODE_ATTR_NOT_LONG 0x0B
+#define ATT_ECODE_INSUFF_ENCR_KEY_SIZE 0x0C
+#define ATT_ECODE_INVAL_ATTR_VALUE_LEN 0x0D
+#define ATT_ECODE_UNLIKELY 0x0E
+#define ATT_ECODE_INSUFF_ENC 0x0F
+#define ATT_ECODE_UNSUPP_GRP_TYPE 0x10
+#define ATT_ECODE_INSUFF_RESOURCES 0x11
+#define ATT_ECODE_IO 0xFF
+
/* Attribute Protocol Opcodes */
static const char *attop2str(uint8_t op)
@@ -132,6 +152,63 @@ static const char *attop2str(uint8_t op)
}
}
+static const char * atterror2str(uint8_t err)
+{
+ switch (err) {
+ case ATT_ECODE_INVALID_HANDLE:
+ return "Invalid handle";
+ case ATT_ECODE_READ_NOT_PERM:
+ return "Read not permitted";
+ case ATT_ECODE_WRITE_NOT_PERM:
+ return "Write not permitted";
+ case ATT_ECODE_INVALID_PDU:
+ return "Invalid PDU";
+ case ATT_ECODE_INSUFF_AUTHEN:
+ return "Insufficient authentication";
+ case ATT_ECODE_REQ_NOT_SUPP:
+ return "Request not supported";
+ case ATT_ECODE_INVALID_OFFSET:
+ return "Invalid offset";
+ case ATT_ECODE_INSUFF_AUTHO:
+ return "Insufficient authorization";
+ case ATT_ECODE_PREP_QUEUE_FULL:
+ return "Prepare queue full";
+ case ATT_ECODE_ATTR_NOT_FOUND:
+ return "Attribute not found";
+ case ATT_ECODE_ATTR_NOT_LONG:
+ return "Attribute not long";
+ case ATT_ECODE_INSUFF_ENCR_KEY_SIZE:
+ return "Insufficient encryption key size";
+ case ATT_ECODE_INVAL_ATTR_VALUE_LEN:
+ return "Invalid attribute value length";
+ case ATT_ECODE_UNLIKELY:
+ return "Unlikely error";
+ case ATT_ECODE_INSUFF_ENC:
+ return "Insufficient encryption";
+ case ATT_ECODE_UNSUPP_GRP_TYPE:
+ return "Unsupported group type";
+ case ATT_ECODE_INSUFF_RESOURCES:
+ return "Insufficient resources";
+ case ATT_ECODE_IO:
+ return "Application Error";
+ default:
+ return "Reserved";
+ }
+}
+
+static void att_error_dump(int level, struct frame *frm)
+{
+ uint8_t op = get_u8(frm);
+ uint16_t handle = btohs(htons(get_u16(frm)));
+ uint8_t err = get_u8(frm);
+
+ p_indent(level, frm);
+ printf("Error: %s 0x%.2x\n", atterror2str(err), err);
+
+ p_indent(level, frm);
+ printf("opcode %d (%s) on handle 0x%2.2x\n", op, attop2str(op), handle);
+}
+
static void att_mtu_req_dump(int level, struct frame *frm)
{
uint16_t client_rx_mtu = btohs(htons(get_u16(frm)));
@@ -173,6 +250,9 @@ void att_dump(int level, struct frame *frm)
printf("ATT: %s (0x%.2x)\n", attop2str(op), op);
switch (op) {
+ case ATT_OP_ERROR:
+ att_error_dump(level + 1, frm);
+ break;
case ATT_OP_MTU_REQ:
att_mtu_req_dump(level + 1, frm);
break;
--
1.7.1
^ permalink raw reply related
* [PATCH -v3 4/6] Add ATT find info req/resp dump
From: Andre Dieb Martins @ 2011-02-09 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Dieb Martins
In-Reply-To: <1297272535-14890-1-git-send-email-andre.dieb@signove.com>
Adds dumping for ATT's Find Info Request and Response. Also adds a simple
name resolving for GATT common uuids (listed on Assigned Numbers).
---
parser/att.c | 116 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 113 insertions(+), 3 deletions(-)
diff --git a/parser/att.c b/parser/att.c
index 3717839..d8a10fc 100644
--- a/parser/att.c
+++ b/parser/att.c
@@ -36,6 +36,27 @@
#include "parser.h"
+#define GATT_PRIM_SVC_UUID 0x2800
+#define GATT_SND_SVC_UUID 0x2801
+#define GATT_INCLUDE_UUID 0x2802
+#define GATT_CHARAC_UUID 0x2803
+
+#define GATT_CHARAC_DEVICE_NAME 0x2A00
+#define GATT_CHARAC_APPEARANCE 0x2A01
+#define GATT_CHARAC_PERIPHERAL_PRIV_FLAG 0x2A02
+#define GATT_CHARAC_RECONNECTION_ADDRESS 0x2A03
+#define GATT_CHARAC_PERIPHERAL_PREF_CONN 0x2A04
+#define GATT_CHARAC_SERVICE_CHANGED 0x2A05
+
+#define GATT_CHARAC_EXT_PROPER_UUID 0x2900
+#define GATT_CHARAC_USER_DESC_UUID 0x2901
+#define GATT_CLIENT_CHARAC_CFG_UUID 0x2902
+#define GATT_SERVER_CHARAC_CFG_UUID 0x2903
+#define GATT_CHARAC_FMT_UUID 0x2904
+#define GATT_CHARAC_AGREG_FMT_UUID 0x2905
+
+
+
/* Attribute Protocol Opcodes */
#define ATT_OP_ERROR 0x01
#define ATT_OP_MTU_REQ 0x02
@@ -196,6 +217,46 @@ static const char * atterror2str(uint8_t err)
}
}
+static const char *uuid2str(uint16_t uuid)
+{
+ switch (uuid) {
+ case GATT_PRIM_SVC_UUID:
+ return "GATT Primary Service";
+ case GATT_SND_SVC_UUID:
+ return "GATT Secondary Service";
+ case GATT_INCLUDE_UUID:
+ return "GATT Include";
+ case GATT_CHARAC_UUID:
+ return "GATT Characteristic";
+ case GATT_CHARAC_DEVICE_NAME:
+ return "GATT(type) Device Name";
+ case GATT_CHARAC_APPEARANCE:
+ return "GATT(type) Appearance";
+ case GATT_CHARAC_PERIPHERAL_PRIV_FLAG:
+ return "GATT(type) Peripheral Privacy Flag";
+ case GATT_CHARAC_RECONNECTION_ADDRESS:
+ return "GATT(type) Characteristic Reconnection Address";
+ case GATT_CHARAC_PERIPHERAL_PREF_CONN:
+ return "GATT(type) Characteristic Preferred Connection Parameters";
+ case GATT_CHARAC_SERVICE_CHANGED:
+ return "GATT(type) Characteristic Service Changed";
+ case GATT_CHARAC_EXT_PROPER_UUID:
+ return "GATT(desc) Characteristic Extended Properties";
+ case GATT_CHARAC_USER_DESC_UUID:
+ return "GATT(desc) User Description";
+ case GATT_CLIENT_CHARAC_CFG_UUID:
+ return "GATT(desc) Client Characteristic Configuration";
+ case GATT_SERVER_CHARAC_CFG_UUID:
+ return "GATT(desc) Server Characteristic Configuration";
+ case GATT_CHARAC_FMT_UUID:
+ return "GATT(desc) Format";
+ case GATT_CHARAC_AGREG_FMT_UUID:
+ return "GATT(desc) Aggregate Format";
+ default:
+ return "Unknown";
+ }
+}
+
static void att_error_dump(int level, struct frame *frm)
{
uint8_t op = get_u8(frm);
@@ -203,10 +264,10 @@ static void att_error_dump(int level, struct frame *frm)
uint8_t err = get_u8(frm);
p_indent(level, frm);
- printf("Error: %s 0x%.2x\n", atterror2str(err), err);
+ printf("Error: %s (%d)\n", atterror2str(err), err);
p_indent(level, frm);
- printf("opcode %d (%s) on handle 0x%2.2x\n", op, attop2str(op), handle);
+ printf("%s (0x%.2x) on handle 0x%2.2x\n", attop2str(op), op, handle);
}
static void att_mtu_req_dump(int level, struct frame *frm)
@@ -225,6 +286,50 @@ static void att_mtu_resp_dump(int level, struct frame *frm)
printf("server rx mtu %d\n", server_rx_mtu);
}
+static void att_find_info_req_dump(int level, struct frame *frm)
+{
+ uint16_t start = btohs(htons(get_u16(frm)));
+ uint16_t end = btohs(htons(get_u16(frm)));
+
+ p_indent(level, frm);
+ printf("start 0x%2.2x, end 0x%2.2x\n", start, end);
+}
+
+static void att_find_info_resp_dump(int level, struct frame *frm)
+{
+ uint8_t fmt = get_u8(frm);
+
+ p_indent(level, frm);
+
+ if (fmt == 0x01) {
+ printf("format: uuid-16\n");
+
+ while (frm->len > 0) {
+ uint16_t handle = btohs(htons(get_u16(frm)));
+ uint16_t uuid = btohs(htons(get_u16(frm)));
+ p_indent(level + 1, frm);
+ printf("handle 0x%2.2x, uuid 0x%2.2x (%s)\n", handle, uuid,
+ uuid2str(uuid));
+ }
+ } else {
+ printf("format: uuid-128\n");
+
+ while (frm->len > 0) {
+ uint16_t handle = btohs(htons(get_u16(frm)));
+ int i;
+
+ p_indent(level + 1, frm);
+ printf("handle 0x%2.2x, uuid ", handle);
+ for (i = 0; i < 16; i++) {
+ printf("%02x", get_u8(frm));
+ if (i == 3 || i == 5 || i == 7 || i == 9)
+ printf("-");
+ }
+ printf("\n");
+ }
+ }
+}
+
static void att_handle_notify_dump(int level, struct frame *frm)
{
uint16_t handle = btohs(htons(get_u16(frm)));
@@ -259,10 +364,15 @@ void att_dump(int level, struct frame *frm)
case ATT_OP_MTU_RESP:
att_mtu_resp_dump(level + 1, frm);
break;
+ case ATT_OP_FIND_INFO_REQ:
+ att_find_info_req_dump(level + 1, frm);
+ break;
+ case ATT_OP_FIND_INFO_RESP:
+ att_find_info_resp_dump(level + 1, frm);
+ break;
case ATT_OP_HANDLE_NOTIFY:
att_handle_notify_dump(level + 1, frm);
break;
-
default:
raw_dump(level, frm);
break;
--
1.7.1
^ permalink raw reply related
* [PATCH -v3 5/6] Add ATT dump for read req/resp
From: Andre Dieb Martins @ 2011-02-09 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Dieb Martins
In-Reply-To: <1297272535-14890-1-git-send-email-andre.dieb@signove.com>
---
parser/att.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/parser/att.c b/parser/att.c
index d8a10fc..887cdac 100644
--- a/parser/att.c
+++ b/parser/att.c
@@ -330,6 +330,14 @@ static void att_find_info_resp_dump(int level, struct frame *frm)
}
}
+static void att_read_req_dump(int level, struct frame *frm)
+{
+ uint16_t handle = btohs(htons(get_u16(frm)));
+
+ p_indent(level, frm);
+ printf("handle 0x%2.2x\n", handle);
+}
+
static void att_handle_notify_dump(int level, struct frame *frm)
{
uint16_t handle = btohs(htons(get_u16(frm)));
@@ -370,6 +378,12 @@ void att_dump(int level, struct frame *frm)
case ATT_OP_FIND_INFO_RESP:
att_find_info_resp_dump(level + 1, frm);
break;
+ case ATT_OP_READ_REQ:
+ att_read_req_dump(level + 1, frm);
+ break;
+ case ATT_OP_READ_RESP:
+ raw_dump(level + 1, frm);
+ break;
case ATT_OP_HANDLE_NOTIFY:
att_handle_notify_dump(level + 1, frm);
break;
--
1.7.1
^ permalink raw reply related
* [PATCH -v3 6/6] Add ATT read by type req/resp dump
From: Andre Dieb Martins @ 2011-02-09 17:28 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Andre Dieb Martins
In-Reply-To: <1297272535-14890-1-git-send-email-andre.dieb@signove.com>
---
parser/att.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/parser/att.c b/parser/att.c
index 887cdac..a0fb135 100644
--- a/parser/att.c
+++ b/parser/att.c
@@ -330,6 +330,54 @@ static void att_find_info_resp_dump(int level, struct frame *frm)
}
}
+static void att_read_by_type_req_dump(int level, struct frame *frm)
+{
+ uint16_t start = btohs(htons(get_u16(frm)));
+ uint16_t end = btohs(htons(get_u16(frm)));
+ int i;
+
+ p_indent(level, frm);
+ printf("start 0x%2.2x, end 0x%2.2x\n", start, end);
+
+ p_indent(level, frm);
+ if (frm->len == 2) {
+ printf("type-uuid 0x%2.2x\n", btohs(htons(get_u16(frm))));
+ } else if (frm->len == 16) {
+ printf("type-uuid ");
+ for (i = 0; i < 16; i++) {
+ printf("%02x", get_u8(frm));
+ if (i == 3 || i == 5 || i == 7 || i == 9)
+ printf("-");
+ }
+ printf("\n");
+ } else {
+ printf("malformed uuid (expected 2 or 16 octets)\n");
+ p_indent(level, frm);
+ raw_dump(level, frm);
+ }
+}
+
+static void att_read_by_type_resp_dump(int level, struct frame *frm)
+{
+ uint8_t length = get_u8(frm);
+
+ p_indent(level, frm);
+ printf("length: %d\n", length);
+
+ while (frm->len > 0) {
+ uint16_t handle = btohs(htons(get_u16(frm)));
+ int val_len = length - 2;
+ int i;
+
+ p_indent(level + 1, frm);
+ printf("handle 0x%2.2x, value ", handle);
+ for (i = 0; i < val_len; i++) {
+ printf("0x%.2x ", get_u8(frm));
+ }
+ printf("\n");
+ }
+}
+
static void att_read_req_dump(int level, struct frame *frm)
{
uint16_t handle = btohs(htons(get_u16(frm)));
@@ -378,6 +426,12 @@ void att_dump(int level, struct frame *frm)
case ATT_OP_FIND_INFO_RESP:
att_find_info_resp_dump(level + 1, frm);
break;
+ case ATT_OP_READ_BY_TYPE_REQ:
+ att_read_by_type_req_dump(level + 1, frm);
+ break;
+ case ATT_OP_READ_BY_TYPE_RESP:
+ att_read_by_type_resp_dump(level + 1, frm);
+ break;
case ATT_OP_READ_REQ:
att_read_req_dump(level + 1, frm);
break;
--
1.7.1
^ permalink raw reply related
* Re: Not able to test GATT on ubuntu
From: Anderson Lizardo @ 2011-02-09 17:56 UTC (permalink / raw)
To: Vijayalakshmi N; +Cc: Luiz Augusto von Dentz, Mika Linnanoja, linux-bluetooth
In-Reply-To: <AANLkTinRHYs+W+os7xn1O9cehqFnzOzhnedsqXWiNAcN@mail.gmail.com>
Hi,
On Wed, Feb 9, 2011 at 8:47 AM, Vijayalakshmi N
<vijayalakshmi.nk@gmail.com> wrote:
> Now I have an updated setup where the bluetooth kernel code with BLE
> patches are taken from
> http://git.infradead.org/users/vcgomes/linux-2.6.git/tree/refs/heads/devel
> and hcidump 2.0
May I suggest you test first with two BR/EDR dongles to make sure the
GATT part is ok?
1) Make sure "AttributeServer = true" is added to
/etc/bluetooth/main.conf and start bluetoothd on the server
2) Make sure bluetoothd is started on the client as well (at least for
me this is required), if server/client are on different machines
3) On client, run:
gatttool -i <adapter> -b <server_bdaddr> --primary
The rest of the parameters already have sane defaults. If that still
does not work, send us the server and client hcidump logs
HTH,
--
Anderson Lizardo
OpenBossa Labs - INdT
Manaus - Brazil
^ permalink raw reply
* [PATCH] use a valid PSM value in l2test.
From: Gustavo F. Padovan @ 2011-02-09 18:26 UTC (permalink / raw)
To: linux-bluetooth
---
test/l2test.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/l2test.c b/test/l2test.c
index 17883a9..00d31dc 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -87,7 +87,7 @@ static long buffer_size = 2048;
/* Default addr and psm and cid */
static bdaddr_t bdaddr;
-static unsigned short psm = 10;
+static unsigned short psm = 1011;
static unsigned short cid = 0;
/* Default number of frames to send (-1 = infinite) */
--
1.7.4
^ permalink raw reply related
* Re: [PATCH] use a valid PSM value in l2test.
From: Gustavo F. Padovan @ 2011-02-09 18:28 UTC (permalink / raw)
To: linux-bluetooth
In-Reply-To: <1297275997-15274-1-git-send-email-padovan@profusion.mobi>
* Gustavo F. Padovan <padovan@profusion.mobi> [2011-02-09 16:26:37 -0200]:
> ---
> test/l2test.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
Gah, this is wrong. L2CAP doesn't accept this value
--
Gustavo F. Padovan
http://profusion.mobi
^ permalink raw reply
* [PATCH] use a valid PSM value in l2test.
From: Gustavo F. Padovan @ 2011-02-09 18:42 UTC (permalink / raw)
To: linux-bluetooth
---
test/l2test.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/l2test.c b/test/l2test.c
index 17883a9..3ac332f 100644
--- a/test/l2test.c
+++ b/test/l2test.c
@@ -87,7 +87,7 @@ static long buffer_size = 2048;
/* Default addr and psm and cid */
static bdaddr_t bdaddr;
-static unsigned short psm = 10;
+static unsigned short psm = 0x1011;
static unsigned short cid = 0;
/* Default number of frames to send (-1 = infinite) */
--
1.7.4
^ permalink raw reply related
* Re: [PATCH 3/5] Add an initial interactive mode to gatttool
From: Johan Hedberg @ 2011-02-09 21:26 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
In-Reply-To: <1297179136-14750-3-git-send-email-sheldon.demario@openbossa.org>
On Tue, Feb 08, 2011, Sheldon Demario wrote:
> +int do_interactive(void);
I don't really like having an exported function called do_*. The places
I've seen this naming convention have usually been when there's some
other function already with the name you want and in all places the do_
variant is static. How about simply interactive() or interactive_mode().
Also, shouldn't you be passing the minimum config options as parameters
to this function? Otherwise you'll have to have some sort of global
config variables.
> +++ b/attrib/igatttool.c
Since we don't have igattool anymore, how about calling this
interactive.c?
> +static void cmd_help(int argcp, char **argvp);
> +static void cmd_exit(int argcp, char **argvp);
No forward-declarations please. Just reorder the functions so that you
don't need to do this.
Johan
^ permalink raw reply
* Re: [PATCH 1/3] Add return value to reply_list_foreach_t in phonebook-tracker
From: Johan Hedberg @ 2011-02-09 21:56 UTC (permalink / raw)
To: Radoslaw Jablonski; +Cc: linux-bluetooth
In-Reply-To: <1297081658-30573-1-git-send-email-ext-jablonski.radoslaw@nokia.com>
Hi Radek,
On Mon, Feb 07, 2011, Radoslaw Jablonski wrote:
> + return -1;
Could you please use some more meaningful POSIX error codes here,
-EINVAL, etc.
> @@ -1645,13 +1652,14 @@ fail:
> g_free(temp_id);
> temp_id = NULL;
>
> + return -1;
Same here.
> done:
> if (num_fields <= 0)
> data->ready_cb(data->user_data);
>
> + return -1;
And here.
> if (num_fields < 0) {
> data->cb(NULL, 0, num_fields, 0, data->user_data);
> - return;
> + return -1;
And here.
> }
>
> if (data->params->maxlistcount == 0) {
> @@ -1880,6 +1889,8 @@ done:
> query_tracker(query, col_amount, pull_cb, data, &err);
> if (err < 0)
> data->cb(NULL, 0, err, 0, data->user_data);
> +
> + return -1;
> }
This looks a bit strange. Is it really a failure even if err is 0? I'd
expect the return statement to look like "return err;". Btw, why doesn't
query_tracker return the error in its return value?
Johan
^ permalink raw reply
* Re: [PATCH] Fix small typo
From: Johan Hedberg @ 2011-02-09 21:58 UTC (permalink / raw)
To: Elvis Pfützenreuter; +Cc: linux-bluetooth
In-Reply-To: <1297193877-26625-1-git-send-email-epx@signove.com>
Hi Elvis,
On Tue, Feb 08, 2011, Elvis Pfützenreuter wrote:
> ---
> doc/health-api.txt | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/doc/health-api.txt b/doc/health-api.txt
> index a0a1685..3d0a717 100644
> --- a/doc/health-api.txt
> +++ b/doc/health-api.txt
> @@ -18,7 +18,7 @@ Methods:
>
> Returns the path of the new registered application.
>
> - Dict is defined as bellow:
> + Dict is defined as below:
> {
> "DataType": uint16, (mandatory)
> "Role" : ("Source" or "Sink"), (mandatory)
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH 1/3] Add support for notyfying pbap about more parts from backend
From: Johan Hedberg @ 2011-02-09 22:00 UTC (permalink / raw)
To: Radoslaw Jablonski; +Cc: linux-bluetooth
In-Reply-To: <1297237127-16286-1-git-send-email-ext-jablonski.radoslaw@nokia.com>
Hi Radek,
On Wed, Feb 09, 2011, Radoslaw Jablonski wrote:
> Added new parameter to phonebook_cb - lastpart variable.
> If backend want to notify that more parts of current
> request will be delivered later, it should use lastpart=FALSE.
> Because of that, PBAP core will 'know' that should not finalize
> request immediately after receiving data and wait for more
> parts to come.
> If result is returned in one part and no more responses part
> will be sent later, then backend should use lastparam=TRUE.
> Previously results of request from backend was always returned
> in one part to PBAP core.
> ---
> plugins/irmc.c | 5 +++--
> plugins/pbap.c | 10 +++++++---
> plugins/phonebook-dummy.c | 4 ++--
> plugins/phonebook-ebook.c | 7 ++++---
> plugins/phonebook-tracker.c | 13 +++++++------
> plugins/phonebook.h | 2 +-
> 6 files changed, 24 insertions(+), 17 deletions(-)
It seems these patches depend on your previous ones which weren't ready
for upstream, so I suppose they'll need to be fixed and resent (once
you've done the necessary changes to the first ones).
Johan
^ permalink raw reply
* Re: [PATCH v2] Fix blutoothd exit on badly formated AT+VTS
From: Johan Hedberg @ 2011-02-09 22:01 UTC (permalink / raw)
To: Dmitriy Paliy; +Cc: linux-bluetooth
In-Reply-To: <1297263346-29728-1-git-send-email-dmitriy.paliy@nokia.com>
Hi Dmitriy,
On Wed, Feb 09, 2011, Dmitriy Paliy wrote:
> This fixes bluetoothd exit when AT+VTS command is badly formatted,
> e.g. as AT+VTS\xfe\xfe[...]=1
>
> Verification it done for the numeric value to be larger than 0x23,
> that corresponds to the hash '#', and to be lower than 0x44, that
> corresponds to 'D', such that the tone is in {0-9, *, #, A, B, C, D}.
> ---
> audio/headset.c | 8 +++++++-
> 1 files changed, 7 insertions(+), 1 deletions(-)
Pushed upstream (after the obvious typo fix in the subject). Thanks.
Johan
^ permalink raw reply
* Re: [PATCH -v3 1/6] Partial dump of ATT PDUs
From: Johan Hedberg @ 2011-02-09 22:03 UTC (permalink / raw)
To: Andre Dieb Martins; +Cc: linux-bluetooth
In-Reply-To: <1297272535-14890-1-git-send-email-andre.dieb@signove.com>
Hi André,
On Wed, Feb 09, 2011, Andre Dieb Martins wrote:
> Starts implementing dumping for ATT/GATT pdus.
> ---
> Makefile.am | 1 +
> parser/att.c | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
> parser/l2cap.c | 7 +++
> parser/parser.h | 2 +
> src/hcidump.c | 1 +
> 5 files changed, 172 insertions(+), 0 deletions(-)
> create mode 100644 parser/att.c
All six patches have been pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH] use a valid PSM value in l2test.
From: Johan Hedberg @ 2011-02-09 22:04 UTC (permalink / raw)
To: Gustavo F. Padovan; +Cc: linux-bluetooth
In-Reply-To: <1297276920-15467-1-git-send-email-padovan@profusion.mobi>
Hi Gustavo,
On Wed, Feb 09, 2011, Gustavo F. Padovan wrote:
> ---
> test/l2test.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/test/l2test.c b/test/l2test.c
> index 17883a9..3ac332f 100644
> --- a/test/l2test.c
> +++ b/test/l2test.c
> @@ -87,7 +87,7 @@ static long buffer_size = 2048;
>
> /* Default addr and psm and cid */
> static bdaddr_t bdaddr;
> -static unsigned short psm = 10;
> +static unsigned short psm = 0x1011;
> static unsigned short cid = 0;
>
> /* Default number of frames to send (-1 = infinite) */
Pushed upstream. Thanks.
Johan
^ permalink raw reply
* Re: [BUG] usb problems in .38-rc3+
From: Ed Tomlinson @ 2011-02-09 23:48 UTC (permalink / raw)
To: Anand Gadiyar; +Cc: Oliver Neukum, linux-kernel, linux-bluetooth, linux-usb
In-Reply-To: <c037b856cfa01b5c7014873850cd07a9@mail.gmail.com>
On Wednesday 09 February 2011 01:17:40 Anand Gadiyar wrote:
> Ed Tomlinson wrote:
> > On Tuesday 08 February 2011 01:46:16 Gadiyar, Anand wrote:
> > > On Tue, Feb 8, 2011 at 7:45 AM, Ed Tomlinson <edt@aei.ca> wrote:
> > > > I tried bisecting without much luck. It started with about 4000
> commits to check. It was still bad
> > > > when it reached the first 1000 commits post .37. Then all boots
> started crashing. I think its possible
> > > > to restrict a bisect to a directory - if so, what dir should I try?
> > > >
> > >
> > > Maybe drivers/ or drivers/usb would be enough for a first attempt?
> > > I usually start there.
> > >
> > > You could just do:
> > >
> > > git bisect start -- [path]
> > >
> > > to restrict bisection to commits that touch [path].
> >
> > This is as far as I can get:
> >
> > # bad: [100b33c8bd8a3235fd0b7948338d6cbb3db3c63d] Linux 2.6.38-rc4
> > # good: [3c0eee3fe6a3a1c745379547c7e7c904aa64f6d5] Linux 2.6.37
> > # good: [387c31c7e5c9805b0aef8833d1731a5fe7bdea14] Linux 2.6.37-rc8
> > # good: [90a8a73c06cc32b609a880d48449d7083327e11a] Linux 2.6.37-rc7
> > # good: [c8ddb2713c624f432fa5fe3c7ecffcdda46ea0d4] Linux 2.6.37-rc1
> > git bisect start 'v2.6.38-rc4' 'v2.6.37' 'v2.6.37-rc8' 'v2.6.37-rc7'
> 'v2.6.37-rc1' '--' 'drivers/usb' 'drivers/bluetooth'
> > # good: [5cdc5bd8b2b1190cb54548c03194b154b4892e2a] Merge branch
> 'musb-hw' of git://gitorious.org/usb/usb into musb
> > git bisect good 5cdc5bd8b2b1190cb54548c03194b154b4892e2a
> > # bad: [f2c565e223af39ed38be5c84b1a37b591b22db83] xHCI: replace
> dev_dbg() with xhci_dbg()
> > git bisect bad f2c565e223af39ed38be5c84b1a37b591b22db83
> > # good: [2af10844eb6ed104f9505bf3a7ba3ceb02264f31] USB: Merge 2.6.37-rc5
> into usb-next
> > git bisect good 2af10844eb6ed104f9505bf3a7ba3ceb02264f31
> > # bad: [3e5b08cbbf78bedd316904ab0cf3b27119433ee5] Merge branch
> 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
> > git bisect bad 3e5b08cbbf78bedd316904ab0cf3b27119433ee5
> > # good: [1051b9f0f9eab8091fe3bf98320741adf36b4cfa] Merge branch
> 'for-rmk' of git://git.pengutronix.de/git/imx/linux-2.6 into devel-stable
> > git bisect good 1051b9f0f9eab8091fe3bf98320741adf36b4cfa
> >
> > After this the kernel does not build.
> >
> > Any clues?
>
> Is it easier to just fix the build break locally and proceed?
>
> I'm afraid I don't know how to skip a step during bisection.
> I try narrowing things down manually.
>
> Given that 2.6.37 is fine, can you check if v2.6.38-rc1 works?
> If it doesn't work, then this break was caused by something that
> went in during the merge window (which I believe is most likely).
>
> You may be able to get somewhere by using snapshots of
> linux-next as of particular days. They are available at [1]
> as a single patch against a tag from Linus' tree.
> Warning: This could be tedious, maybe not much more than a
> git-bisect. Maybe easier to try and work it out from the
> code.
one interesting point. Its NOT
3e5b08cbbf78bedd316904ab0cf3b27119433ee5 Merge branch 'usb-next' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6
Building a kernel with the merge preceeding this one (da40d036fd716f0efb2917076220814b1e927ae1) still has the problem.
One other symptom I've noticed. With .37 kde 4.5/6's bluedevil bluetooth control sees the adapter,
with the failing post .37 kernels it does not.
Thanks,
Ed
^ permalink raw reply
* [PATCH] Bluetooth: hcitool: add bdaddr type option to lecc
From: Emeltchenko Andrei @ 2011-02-10 0:59 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@nokia.com>
---
tools/hcitool.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 536d407..c097526 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2420,7 +2420,7 @@ static struct option lecc_options[] = {
static const char *lecc_help =
"Usage:\n"
- "\tlecc <bdaddr>\n";
+ "\tlecc <bdaddr> [conn type]\n";
static void cmd_lecc(int dev_id, int argc, char **argv)
{
@@ -2437,7 +2437,7 @@ static void cmd_lecc(int dev_id, int argc, char **argv)
return;
}
}
- helper_arg(1, 1, &argc, &argv, lecc_help);
+ helper_arg(1, 2, &argc, &argv, lecc_help);
if (dev_id < 0)
dev_id = hci_get_route(NULL);
@@ -2450,10 +2450,14 @@ static void cmd_lecc(int dev_id, int argc, char **argv)
str2ba(argv[0], &bdaddr);
+ if (argc == 2)
+ peer_bdaddr_type = atoi(argv[1]);
+ else
+ peer_bdaddr_type = 0;
+
interval = htobs(0x0004);
window = htobs(0x0004);
initiator_filter = 0x00;
- peer_bdaddr_type = 0x00;
own_bdaddr_type = 0x00;
min_interval = htobs(0x000F);
max_interval = htobs(0x000F);
--
1.7.1
^ permalink raw reply related
* [bluetooth-next 00/24] Just Works SMP implementation
From: Vinicius Costa Gomes @ 2011-02-10 1:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Vinicius Costa Gomes
Hi,
This patch series adds support for making (and receiving) LE connections
and the simplest SMP pairing method.
What is (should be) working:
- Creating LE connections;
- Receiving LE connections;
- Creating LE connections with higher security levels (MEDIUM and HIGH);
- Changing LE security level during the connection;
Cheers,
--
Vinicius
Anderson Briglia (7):
Bluetooth: Implement the first SMP commands
Bluetooth: Start SMP procedure
Bluetooth: simple SMP pairing negotiation
Bluetooth: LE SMP Cryptoolbox functions
Bluetooth: Add SMP confirmation structs
Bluetooth: Add SMP confirmation checks methods
Bluetooth: Minor fix in SMP methods
Ville Tervo (8):
Bluetooth: Add low energy commands and events
Bluetooth: Add LE connect support
Bluetooth: Use LE buffers for LE traffic
Bluetooth: Add LE connection support to L2CAP
Bluetooth: Add server socket support for LE connection
Bluetooth: Do not send disconn comand over LE links
Bluetooth: Treat LE and ACL links separately on timeout
Bluetooth: Add SMP command structures
Vinicius Costa Gomes (9):
Bluetooth: Fix initiated LE connections
Bluetooth: Add support for using the crypto subsystem
Bluetooth: Add support for LE Start Encryption
Bluetooth: Add support for resuming socket when SMP is finished
Bluetooth: Fix initial security level of LE links
Bluetooth: Update the security level when link is encrypted
Bluetooth: Add support for Pairing features exchange
Bluetooth: Add support for SMP timeout
Bluetooth: Add key size checks for SMP
include/net/bluetooth/hci.h | 85 ++++++
include/net/bluetooth/hci_core.h | 40 +++-
include/net/bluetooth/l2cap.h | 13 +
include/net/bluetooth/smp.h | 122 +++++++++
net/bluetooth/Kconfig | 12 +
net/bluetooth/Makefile | 2 +-
net/bluetooth/hci_conn.c | 105 ++++++++-
net/bluetooth/hci_core.c | 101 +++++++-
net/bluetooth/hci_event.c | 201 ++++++++++++++
net/bluetooth/l2cap_core.c | 209 +++++++++++----
net/bluetooth/l2cap_sock.c | 46 +++-
net/bluetooth/smp.c | 532 ++++++++++++++++++++++++++++++++++++++
12 files changed, 1381 insertions(+), 87 deletions(-)
create mode 100644 include/net/bluetooth/smp.h
create mode 100644 net/bluetooth/smp.c
--
1.7.4
^ permalink raw reply
* [bluetooth-next 01/24] Bluetooth: Add low energy commands and events
From: Vinicius Costa Gomes @ 2011-02-10 1:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ville Tervo
In-Reply-To: <1297300704-30006-1-git-send-email-vinicius.gomes@openbossa.org>
From: Ville Tervo <ville.tervo@nokia.com>
Add needed HCI command and event structs to
create LE connections.
Signed-off-by: Ville Tervo <ville.tervo@nokia.com>
---
include/net/bluetooth/hci.h | 49 +++++++++++++++++++++++++++++++++++++++++++
1 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 4bee030..802d250 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -642,6 +642,36 @@ struct hci_rp_read_bd_addr {
bdaddr_t bdaddr;
} __packed;
+#define HCI_OP_LE_SET_EVENT_MASK 0x2001
+struct hci_cp_le_set_event_mask {
+ __u8 mask[8];
+} __packed;
+
+#define HCI_OP_LE_READ_BUFFER_SIZE 0x2002
+struct hci_rp_le_read_buffer_size {
+ __u8 status;
+ __le16 le_mtu;
+ __u8 le_max_pkt;
+} __packed;
+
+#define HCI_OP_LE_CREATE_CONN 0x200d
+struct hci_cp_le_create_conn {
+ __le16 scan_interval;
+ __le16 scan_window;
+ __u8 filter_policy;
+ __u8 peer_addr_type;
+ bdaddr_t peer_addr;
+ __u8 own_address_type;
+ __le16 conn_interval_min;
+ __le16 conn_interval_max;
+ __le16 conn_latency;
+ __le16 supervision_timeout;
+ __le16 min_ce_len;
+ __le16 max_ce_len;
+} __packed;
+
+#define HCI_OP_LE_CREATE_CONN_CANCEL 0x200e
+
/* ---- HCI Events ---- */
#define HCI_EV_INQUIRY_COMPLETE 0x01
@@ -902,6 +932,25 @@ struct hci_ev_remote_host_features {
__u8 features[8];
} __packed;
+#define HCI_EV_LE_META 0x3e
+struct hci_ev_le_meta {
+ __u8 subevent;
+} __packed;
+
+/* Low energy meta events */
+#define HCI_EV_LE_CONN_COMPLETE 0x01
+struct hci_ev_le_conn_complete {
+ __u8 status;
+ __le16 handle;
+ __u8 role;
+ __u8 bdaddr_type;
+ bdaddr_t bdaddr;
+ __le16 interval;
+ __le16 latency;
+ __le16 supervision_timeout;
+ __u8 clk_accurancy;
+} __packed;
+
/* Internal events generated by Bluetooth stack */
#define HCI_EV_STACK_INTERNAL 0xfd
struct hci_ev_stack_internal {
--
1.7.4
^ permalink raw reply related
* [bluetooth-next 02/24] Bluetooth: Add LE connect support
From: Vinicius Costa Gomes @ 2011-02-10 1:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ville Tervo
In-Reply-To: <1297300704-30006-1-git-send-email-vinicius.gomes@openbossa.org>
From: Ville Tervo <ville.tervo@nokia.com>
Bluetooth V4.0 adds support for Low Energy (LE) connections.
Specification introduces new set of hci commands to control LE
connection. This patch adds logic to create, cancel and disconnect
LE connections.
Signed-off-by: Ville Tervo <ville.tervo@nokia.com>
---
include/net/bluetooth/hci.h | 2 +
include/net/bluetooth/hci_core.h | 25 +++++++++--
net/bluetooth/hci_conn.c | 51 +++++++++++++++++++-
net/bluetooth/hci_event.c | 93 ++++++++++++++++++++++++++++++++++++++
4 files changed, 164 insertions(+), 7 deletions(-)
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 802d250..e756f82 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -168,6 +168,8 @@ enum {
#define SCO_LINK 0x00
#define ACL_LINK 0x01
#define ESCO_LINK 0x02
+/* Low Energy links do not have defined link type. Use invented one */
+#define LE_LINK 0x80
/* LMP features */
#define LMP_3SLOT 0x01
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 6163bff..f434e96 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -60,6 +60,7 @@ struct hci_conn_hash {
spinlock_t lock;
unsigned int acl_num;
unsigned int sco_num;
+ unsigned int le_num;
};
struct bdaddr_list {
@@ -309,20 +310,36 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
{
struct hci_conn_hash *h = &hdev->conn_hash;
list_add(&c->list, &h->list);
- if (c->type == ACL_LINK)
+ switch (c->type) {
+ case ACL_LINK:
h->acl_num++;
- else
+ break;
+ case LE_LINK:
+ h->le_num++;
+ break;
+ case SCO_LINK:
+ case ESCO_LINK:
h->sco_num++;
+ break;
+ }
}
static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
{
struct hci_conn_hash *h = &hdev->conn_hash;
list_del(&c->list);
- if (c->type == ACL_LINK)
+ switch (c->type) {
+ case ACL_LINK:
h->acl_num--;
- else
+ break;
+ case LE_LINK:
+ h->le_num--;
+ break;
+ case SCO_LINK:
+ case ESCO_LINK:
h->sco_num--;
+ break;
+ }
}
static inline struct hci_conn *hci_conn_hash_lookup_handle(struct hci_dev *hdev,
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 42dc39f..d0c470c 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -45,6 +45,32 @@
#include <net/bluetooth/bluetooth.h>
#include <net/bluetooth/hci_core.h>
+static void hci_le_connect(struct hci_conn *conn)
+{
+ struct hci_dev *hdev = conn->hdev;
+ struct hci_cp_le_create_conn cp;
+
+ conn->state = BT_CONNECT;
+ conn->out = 1;
+
+ memset(&cp, 0, sizeof(cp));
+ cp.scan_interval = cpu_to_le16(0x0004);
+ cp.scan_window = cpu_to_le16(0x0004);
+ bacpy(&cp.peer_addr, &conn->dst);
+ cp.conn_interval_min = cpu_to_le16(0x0008);
+ cp.conn_interval_max = cpu_to_le16(0x0100);
+ cp.supervision_timeout = cpu_to_le16(0x0064);
+ cp.min_ce_len = cpu_to_le16(0x0001);
+ cp.max_ce_len = cpu_to_le16(0x0001);
+
+ hci_send_cmd(hdev, HCI_OP_LE_CREATE_CONN, sizeof(cp), &cp);
+}
+
+static void hci_le_connect_cancel(struct hci_conn *conn)
+{
+ hci_send_cmd(conn->hdev, HCI_OP_LE_CREATE_CONN_CANCEL, 0, NULL);
+}
+
void hci_acl_connect(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
@@ -193,8 +219,12 @@ static void hci_conn_timeout(unsigned long arg)
switch (conn->state) {
case BT_CONNECT:
case BT_CONNECT2:
- if (conn->type == ACL_LINK && conn->out)
- hci_acl_connect_cancel(conn);
+ if (conn->out) {
+ if (conn->type == ACL_LINK)
+ hci_acl_connect_cancel(conn);
+ else if (conn->type == LE_LINK)
+ hci_le_connect_cancel(conn);
+ }
break;
case BT_CONFIG:
case BT_CONNECTED:
@@ -361,15 +391,30 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src)
}
EXPORT_SYMBOL(hci_get_route);
-/* Create SCO or ACL connection.
+/* Create SCO, ACL or LE connection.
* Device _must_ be locked */
struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type)
{
struct hci_conn *acl;
struct hci_conn *sco;
+ struct hci_conn *le;
BT_DBG("%s dst %s", hdev->name, batostr(dst));
+ if (type == LE_LINK) {
+ le = hci_conn_hash_lookup_ba(hdev, LE_LINK, dst);
+ if (!le)
+ le = hci_conn_add(hdev, LE_LINK, dst);
+ if (!le)
+ return NULL;
+ if (le->state == BT_OPEN)
+ hci_le_connect(le);
+
+ hci_conn_hold(le);
+
+ return le;
+ }
+
acl = hci_conn_hash_lookup_ba(hdev, ACL_LINK, dst);
if (!acl) {
acl = hci_conn_add(hdev, ACL_LINK, dst);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index cee46cb..47c6e93 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -1107,6 +1107,43 @@ static void hci_cs_exit_sniff_mode(struct hci_dev *hdev, __u8 status)
hci_dev_unlock(hdev);
}
+static void hci_cs_le_create_conn(struct hci_dev *hdev, __u8 status)
+{
+ struct hci_cp_le_create_conn *cp;
+ struct hci_conn *conn;
+
+ BT_DBG("%s status 0x%x", hdev->name, status);
+
+ cp = hci_sent_cmd_data(hdev, HCI_OP_LE_CREATE_CONN);
+ if (!cp)
+ return;
+
+ hci_dev_lock(hdev);
+
+ conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &cp->peer_addr);
+
+ BT_DBG("%s bdaddr %s conn %p", hdev->name, batostr(&cp->peer_addr),
+ conn);
+
+ if (status) {
+ if (conn && conn->state == BT_CONNECT) {
+ conn->state = BT_CLOSED;
+ hci_proto_connect_cfm(conn, status);
+ hci_conn_del(conn);
+ }
+ } else {
+ if (!conn) {
+ conn = hci_conn_add(hdev, LE_LINK, &cp->peer_addr);
+ if (conn)
+ conn->out = 1;
+ else
+ BT_ERR("No memory for new connection");
+ }
+ }
+
+ hci_dev_unlock(hdev);
+}
+
static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
__u8 status = *((__u8 *) skb->data);
@@ -1738,6 +1775,10 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
mgmt_disconnect_failed(hdev->id);
break;
+ case HCI_OP_LE_CREATE_CONN:
+ hci_cs_le_create_conn(hdev, ev->status);
+ break;
+
default:
BT_DBG("%s opcode 0x%x", hdev->name, opcode);
break;
@@ -2321,6 +2362,54 @@ static inline void hci_remote_host_features_evt(struct hci_dev *hdev, struct sk_
hci_dev_unlock(hdev);
}
+static inline void hci_le_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ struct hci_ev_le_conn_complete *ev = (void *) skb->data;
+ struct hci_conn *conn;
+
+ BT_DBG("%s status %d", hdev->name, ev->status);
+
+ hci_dev_lock(hdev);
+
+ conn = hci_conn_hash_lookup_ba(hdev, LE_LINK, &ev->bdaddr);
+ if (!conn)
+ goto unlock;
+
+ if (ev->status) {
+ hci_proto_connect_cfm(conn, ev->status);
+ conn->state = BT_CLOSED;
+ hci_conn_del(conn);
+ goto unlock;
+ }
+
+ conn->handle = __le16_to_cpu(ev->handle);
+ conn->state = BT_CONNECTED;
+
+ hci_conn_hold_device(conn);
+ hci_conn_add_sysfs(conn);
+
+ hci_proto_connect_cfm(conn, ev->status);
+
+unlock:
+ hci_dev_unlock(hdev);
+}
+
+static inline void hci_le_meta_evt(struct hci_dev *hdev, struct sk_buff *skb)
+{
+ struct hci_ev_le_meta *le_ev = (void *) skb->data;
+
+ skb_pull(skb, sizeof(*le_ev));
+
+ switch (le_ev->subevent) {
+ case HCI_EV_LE_CONN_COMPLETE:
+ hci_le_conn_complete_evt(hdev, skb);
+ break;
+
+ default:
+ break;
+ }
+}
+
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
{
struct hci_event_hdr *hdr = (void *) skb->data;
@@ -2461,6 +2550,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
hci_remote_host_features_evt(hdev, skb);
break;
+ case HCI_EV_LE_META:
+ hci_le_meta_evt(hdev, skb);
+ break;
+
default:
BT_DBG("%s event 0x%x", hdev->name, event);
break;
--
1.7.4
^ permalink raw reply related
* [bluetooth-next 03/24] Bluetooth: Use LE buffers for LE traffic
From: Vinicius Costa Gomes @ 2011-02-10 1:18 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Ville Tervo
In-Reply-To: <1297300704-30006-1-git-send-email-vinicius.gomes@openbossa.org>
From: Ville Tervo <ville.tervo@nokia.com>
Bluetooth chips may have separate buffers for LE traffic.
This patch add support to use LE buffers provided by the chip.
Signed-off-by: Ville Tervo <ville.tervo@nokia.com>
---
include/net/bluetooth/hci_core.h | 5 +++
net/bluetooth/hci_conn.c | 5 +++
net/bluetooth/hci_core.c | 74 +++++++++++++++++++++++++++++++++++--
net/bluetooth/hci_event.c | 33 +++++++++++++++++
4 files changed, 113 insertions(+), 4 deletions(-)
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index f434e96..d30b93c 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -123,15 +123,19 @@ struct hci_dev {
atomic_t cmd_cnt;
unsigned int acl_cnt;
unsigned int sco_cnt;
+ unsigned int le_cnt;
unsigned int acl_mtu;
unsigned int sco_mtu;
+ unsigned int le_mtu;
unsigned int acl_pkts;
unsigned int sco_pkts;
+ unsigned int le_pkts;
unsigned long cmd_last_tx;
unsigned long acl_last_tx;
unsigned long sco_last_tx;
+ unsigned long le_last_tx;
struct workqueue_struct *workqueue;
@@ -521,6 +525,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
#define lmp_esco_capable(dev) ((dev)->features[3] & LMP_ESCO)
#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR)
#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)
+#define lmp_le_capable(dev) ((dev)->features[4] & LMP_LE)
/* ----- HCI protocols ----- */
struct hci_proto {
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index d0c470c..aecd78e 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -326,6 +326,11 @@ int hci_conn_del(struct hci_conn *conn)
/* Unacked frames */
hdev->acl_cnt += conn->sent;
+ } else if (conn->type == LE_LINK) {
+ if (hdev->le_pkts)
+ hdev->le_cnt += conn->sent;
+ else
+ hdev->acl_cnt += conn->sent;
} else {
struct hci_conn *acl = conn->link;
if (acl) {
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 2f00322..9296053 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -263,6 +263,14 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
hci_send_cmd(hdev, HCI_OP_DELETE_STORED_LINK_KEY, sizeof(cp), &cp);
}
+static void hci_le_init_req(struct hci_dev *hdev, unsigned long opt)
+{
+ BT_DBG("%s", hdev->name);
+
+ /* Read LE buffer size */
+ hci_send_cmd(hdev, HCI_OP_LE_READ_BUFFER_SIZE, 0, NULL);
+}
+
static void hci_scan_req(struct hci_dev *hdev, unsigned long opt)
{
__u8 scan = opt;
@@ -529,6 +537,10 @@ int hci_dev_open(__u16 dev)
ret = __hci_request(hdev, hci_init_req, 0,
msecs_to_jiffies(HCI_INIT_TIMEOUT));
+ if (lmp_le_capable(hdev))
+ ret = __hci_request(hdev, hci_le_init_req, 0,
+ msecs_to_jiffies(HCI_INIT_TIMEOUT));
+
clear_bit(HCI_INIT, &hdev->flags);
}
@@ -671,7 +683,7 @@ int hci_dev_reset(__u16 dev)
hdev->flush(hdev);
atomic_set(&hdev->cmd_cnt, 1);
- hdev->acl_cnt = 0; hdev->sco_cnt = 0;
+ hdev->acl_cnt = 0; hdev->sco_cnt = 0; hdev->le_cnt = 0;
if (!test_bit(HCI_RAW, &hdev->flags))
ret = __hci_request(hdev, hci_reset_req, 0,
@@ -1672,8 +1684,25 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
}
if (conn) {
- int cnt = (type == ACL_LINK ? hdev->acl_cnt : hdev->sco_cnt);
- int q = cnt / num;
+ int cnt, q;
+
+ switch (conn->type) {
+ case ACL_LINK:
+ cnt = hdev->acl_cnt;
+ break;
+ case SCO_LINK:
+ case ESCO_LINK:
+ cnt = hdev->sco_cnt;
+ break;
+ case LE_LINK:
+ cnt = hdev->le_mtu ? hdev->le_cnt : hdev->acl_cnt;
+ break;
+ default:
+ cnt = 0;
+ BT_ERR("Unknown link type");
+ }
+
+ q = cnt / num;
*quote = q ? q : 1;
} else
*quote = 0;
@@ -1772,6 +1801,40 @@ static inline void hci_sched_esco(struct hci_dev *hdev)
}
}
+static inline void hci_sched_le(struct hci_dev *hdev)
+{
+ struct hci_conn *conn;
+ struct sk_buff *skb;
+ int quote, cnt;
+
+ BT_DBG("%s", hdev->name);
+
+ if (!test_bit(HCI_RAW, &hdev->flags)) {
+ /* LE tx timeout must be longer than maximum
+ * link supervision timeout (40.9 seconds) */
+ if (!hdev->le_cnt &&
+ time_after(jiffies, hdev->le_last_tx + HZ * 45))
+ hci_acl_tx_to(hdev);
+ }
+
+ cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt;
+ while (cnt && (conn = hci_low_sent(hdev, LE_LINK, "e))) {
+ while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
+ BT_DBG("skb %p len %d", skb, skb->len);
+
+ hci_send_frame(skb);
+ hdev->le_last_tx = jiffies;
+
+ cnt--;
+ conn->sent++;
+ }
+ }
+ if (hdev->le_pkts)
+ hdev->le_cnt = cnt;
+ else
+ hdev->acl_cnt = cnt;
+}
+
static void hci_tx_task(unsigned long arg)
{
struct hci_dev *hdev = (struct hci_dev *) arg;
@@ -1779,7 +1842,8 @@ static void hci_tx_task(unsigned long arg)
read_lock(&hci_task_lock);
- BT_DBG("%s acl %d sco %d", hdev->name, hdev->acl_cnt, hdev->sco_cnt);
+ BT_DBG("%s acl %d sco %d le %d", hdev->name, hdev->acl_cnt,
+ hdev->sco_cnt, hdev->le_cnt);
/* Schedule queues and send stuff to HCI driver */
@@ -1789,6 +1853,8 @@ static void hci_tx_task(unsigned long arg)
hci_sched_esco(hdev);
+ hci_sched_le(hdev);
+
/* Send next queued raw (unknown type) packet */
while ((skb = skb_dequeue(&hdev->raw_q)))
hci_send_frame(skb);
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 47c6e93..3155ad5 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -776,6 +776,25 @@ static void hci_cc_pin_code_neg_reply(struct hci_dev *hdev, struct sk_buff *skb)
mgmt_pin_code_neg_reply_complete(hdev->id, &rp->bdaddr,
rp->status);
}
+static void hci_cc_le_read_buffer_size(struct hci_dev *hdev,
+ struct sk_buff *skb)
+{
+ struct hci_rp_le_read_buffer_size *rp = (void *) skb->data;
+
+ BT_DBG("%s status 0x%x", hdev->name, rp->status);
+
+ if (rp->status)
+ return;
+
+ hdev->le_mtu = __le16_to_cpu(rp->le_mtu);
+ hdev->le_pkts = rp->le_max_pkt;
+
+ hdev->le_cnt = hdev->le_pkts;
+
+ BT_DBG("%s le mtu %d:%d", hdev->name, hdev->le_mtu, hdev->le_pkts);
+
+ hci_req_complete(hdev, HCI_OP_LE_READ_BUFFER_SIZE, rp->status);
+}
static inline void hci_cs_inquiry(struct hci_dev *hdev, __u8 status)
{
@@ -1704,6 +1723,10 @@ static inline void hci_cmd_complete_evt(struct hci_dev *hdev, struct sk_buff *sk
hci_cc_pin_code_neg_reply(hdev, skb);
break;
+ case HCI_OP_LE_READ_BUFFER_SIZE:
+ hci_cc_le_read_buffer_size(hdev, skb);
+ break;
+
default:
BT_DBG("%s opcode 0x%x", hdev->name, opcode);
break;
@@ -1849,6 +1872,16 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
hdev->acl_cnt += count;
if (hdev->acl_cnt > hdev->acl_pkts)
hdev->acl_cnt = hdev->acl_pkts;
+ } else if (conn->type == LE_LINK) {
+ if (hdev->le_pkts) {
+ hdev->le_cnt += count;
+ if (hdev->le_cnt > hdev->le_pkts)
+ hdev->le_cnt = hdev->le_pkts;
+ } else {
+ hdev->acl_cnt += count;
+ if (hdev->acl_cnt > hdev->acl_pkts)
+ hdev->acl_cnt = hdev->acl_pkts;
+ }
} else {
hdev->sco_cnt += count;
if (hdev->sco_cnt > hdev->sco_pkts)
--
1.7.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox