[PATCH 1/2] bluetooth: Pass HCI LE connection parameters
* Move hard coded values in hci_le_create_connection() for Bluetooth LE connections to the channel defaults so that they can be overriden by a patch to follow. * Add an argument to hci_connect() so that special connections can pass additional connection parameters. Update existing function calls to pass NULL and not change the functionality. Signed-off-by: Kyle Manna --- include/net/bluetooth/hci_core.h | 5 +++-- include/net/bluetooth/l2cap.h| 2 ++ net/bluetooth/hci_conn.c | 33 ++--- net/bluetooth/l2cap_core.c | 13 +++-- net/bluetooth/l2cap_sock.c | 2 ++ net/bluetooth/mgmt.c | 4 ++-- net/bluetooth/sco.c | 2 +- 7 files changed, 35 insertions(+), 26 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 7cb6d36..5169ec6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -591,8 +591,9 @@ void hci_chan_del(struct hci_chan *chan); void hci_chan_list_flush(struct hci_conn *conn); struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle); -struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, -__u8 dst_type, __u8 sec_level, __u8 auth_type); +struct hci_conn *hci_connect(struct hci_dev *hdev, int type, void *cp, +bdaddr_t *dst, __u8 dst_type, +__u8 sec_level, __u8 auth_type); int hci_conn_check_link_mode(struct hci_conn *conn); int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index fb94cf1..7ebbf56 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -438,6 +438,8 @@ struct l2cap_chan { struct l2cap_conn *conn; struct hci_conn *hs_hcon; struct hci_chan *hs_hchan; + struct hci_cp_le_create_conn cp_le; + struct kref kref; __u8state; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 6c7f363..9894e2b 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -31,28 +31,20 @@ #include #include -static void hci_le_create_connection(struct hci_conn *conn) +static void hci_le_create_connection(struct hci_conn *conn, +struct hci_cp_le_create_conn *cp) { struct hci_dev *hdev = conn->hdev; - struct hci_cp_le_create_conn cp; conn->state = BT_CONNECT; conn->out = true; conn->link_mode |= HCI_LM_MASTER; conn->sec_level = BT_SECURITY_LOW; - memset(, 0, sizeof(cp)); - cp.scan_interval = __constant_cpu_to_le16(0x0060); - cp.scan_window = __constant_cpu_to_le16(0x0030); - bacpy(_addr, >dst); - cp.peer_addr_type = conn->dst_type; - cp.conn_interval_min = __constant_cpu_to_le16(0x0028); - cp.conn_interval_max = __constant_cpu_to_le16(0x0038); - cp.supervision_timeout = __constant_cpu_to_le16(0x002a); - cp.min_ce_len = __constant_cpu_to_le16(0x); - cp.max_ce_len = __constant_cpu_to_le16(0x); - - hci_send_cmd(hdev, HCI_OP_LE_CREATE_CONN, sizeof(cp), ); + bacpy(>peer_addr, >dst); + cp->peer_addr_type = conn->dst_type; + + hci_send_cmd(hdev, HCI_OP_LE_CREATE_CONN, sizeof(*cp), cp); } static void hci_le_create_connection_cancel(struct hci_conn *conn) @@ -507,7 +499,8 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) EXPORT_SYMBOL(hci_get_route); static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, - u8 dst_type, u8 sec_level, u8 auth_type) + u8 dst_type, u8 sec_level, u8 auth_type, + struct hci_cp_le_create_conn *cp) { struct hci_conn *le; @@ -525,7 +518,7 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, return ERR_PTR(-ENOMEM); le->dst_type = bdaddr_to_le(dst_type); - hci_le_create_connection(le); + hci_le_create_connection(le, cp); } le->pending_sec_level = sec_level; @@ -602,14 +595,16 @@ static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, } /* Create SCO, ACL or LE connection. */ -struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, -__u8 dst_type, __u8 sec_level, __u8 auth_type) +struct hci_conn *hci_connect(struct hci_dev *hdev, int type, void *cp, +bdaddr_t *dst, __u8 dst_type, +__u8 sec_level, __u8 auth_type) { BT_DBG("%s dst %pMR type 0x%x", hdev->name, dst, type); switch (type) { case
[PATCH 1/2] bluetooth: Pass HCI LE connection parameters
* Move hard coded values in hci_le_create_connection() for Bluetooth LE connections to the channel defaults so that they can be overriden by a patch to follow. * Add an argument to hci_connect() so that special connections can pass additional connection parameters. Update existing function calls to pass NULL and not change the functionality. Signed-off-by: Kyle Manna k...@kylemanna.com --- include/net/bluetooth/hci_core.h | 5 +++-- include/net/bluetooth/l2cap.h| 2 ++ net/bluetooth/hci_conn.c | 33 ++--- net/bluetooth/l2cap_core.c | 13 +++-- net/bluetooth/l2cap_sock.c | 2 ++ net/bluetooth/mgmt.c | 4 ++-- net/bluetooth/sco.c | 2 +- 7 files changed, 35 insertions(+), 26 deletions(-) diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h index 7cb6d36..5169ec6 100644 --- a/include/net/bluetooth/hci_core.h +++ b/include/net/bluetooth/hci_core.h @@ -591,8 +591,9 @@ void hci_chan_del(struct hci_chan *chan); void hci_chan_list_flush(struct hci_conn *conn); struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle); -struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, -__u8 dst_type, __u8 sec_level, __u8 auth_type); +struct hci_conn *hci_connect(struct hci_dev *hdev, int type, void *cp, +bdaddr_t *dst, __u8 dst_type, +__u8 sec_level, __u8 auth_type); int hci_conn_check_link_mode(struct hci_conn *conn); int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h index fb94cf1..7ebbf56 100644 --- a/include/net/bluetooth/l2cap.h +++ b/include/net/bluetooth/l2cap.h @@ -438,6 +438,8 @@ struct l2cap_chan { struct l2cap_conn *conn; struct hci_conn *hs_hcon; struct hci_chan *hs_hchan; + struct hci_cp_le_create_conn cp_le; + struct kref kref; __u8state; diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index 6c7f363..9894e2b 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c @@ -31,28 +31,20 @@ #include net/bluetooth/a2mp.h #include net/bluetooth/smp.h -static void hci_le_create_connection(struct hci_conn *conn) +static void hci_le_create_connection(struct hci_conn *conn, +struct hci_cp_le_create_conn *cp) { struct hci_dev *hdev = conn-hdev; - struct hci_cp_le_create_conn cp; conn-state = BT_CONNECT; conn-out = true; conn-link_mode |= HCI_LM_MASTER; conn-sec_level = BT_SECURITY_LOW; - memset(cp, 0, sizeof(cp)); - cp.scan_interval = __constant_cpu_to_le16(0x0060); - cp.scan_window = __constant_cpu_to_le16(0x0030); - bacpy(cp.peer_addr, conn-dst); - cp.peer_addr_type = conn-dst_type; - cp.conn_interval_min = __constant_cpu_to_le16(0x0028); - cp.conn_interval_max = __constant_cpu_to_le16(0x0038); - cp.supervision_timeout = __constant_cpu_to_le16(0x002a); - cp.min_ce_len = __constant_cpu_to_le16(0x); - cp.max_ce_len = __constant_cpu_to_le16(0x); - - hci_send_cmd(hdev, HCI_OP_LE_CREATE_CONN, sizeof(cp), cp); + bacpy(cp-peer_addr, conn-dst); + cp-peer_addr_type = conn-dst_type; + + hci_send_cmd(hdev, HCI_OP_LE_CREATE_CONN, sizeof(*cp), cp); } static void hci_le_create_connection_cancel(struct hci_conn *conn) @@ -507,7 +499,8 @@ struct hci_dev *hci_get_route(bdaddr_t *dst, bdaddr_t *src) EXPORT_SYMBOL(hci_get_route); static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, - u8 dst_type, u8 sec_level, u8 auth_type) + u8 dst_type, u8 sec_level, u8 auth_type, + struct hci_cp_le_create_conn *cp) { struct hci_conn *le; @@ -525,7 +518,7 @@ static struct hci_conn *hci_connect_le(struct hci_dev *hdev, bdaddr_t *dst, return ERR_PTR(-ENOMEM); le-dst_type = bdaddr_to_le(dst_type); - hci_le_create_connection(le); + hci_le_create_connection(le, cp); } le-pending_sec_level = sec_level; @@ -602,14 +595,16 @@ static struct hci_conn *hci_connect_sco(struct hci_dev *hdev, int type, } /* Create SCO, ACL or LE connection. */ -struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, -__u8 dst_type, __u8 sec_level, __u8 auth_type) +struct hci_conn *hci_connect(struct hci_dev *hdev, int type, void *cp, +bdaddr_t *dst, __u8 dst_type, +__u8 sec_level, __u8 auth_type) { BT_DBG(%s dst %pMR type