Skip to content

Commit 06ef5c4

Browse files
committed
Merge branch 'for-upstream' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next
2 parents 55cec50 + 0b27a4b commit 06ef5c4

8 files changed

Lines changed: 213 additions & 81 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ extern int l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt);
376376
extern int l2cap_recv_acldata(struct hci_conn *hcon, struct sk_buff *skb,
377377
u16 flags);
378378

379-
extern int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr);
379+
extern int sco_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr, __u8 *flags);
380380
extern void sco_connect_cfm(struct hci_conn *hcon, __u8 status);
381381
extern void sco_disconn_cfm(struct hci_conn *hcon, __u8 reason);
382382
extern int sco_recv_scodata(struct hci_conn *hcon, struct sk_buff *skb);
@@ -577,6 +577,7 @@ struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst);
577577
int hci_conn_del(struct hci_conn *conn);
578578
void hci_conn_hash_flush(struct hci_dev *hdev);
579579
void hci_conn_check_pending(struct hci_dev *hdev);
580+
void hci_conn_accept(struct hci_conn *conn, int mask);
580581

581582
struct hci_chan *hci_chan_create(struct hci_conn *conn);
582583
void hci_chan_del(struct hci_chan *chan);
@@ -766,7 +767,7 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
766767
#define lmp_sniffsubr_capable(dev) ((dev)->features[5] & LMP_SNIFF_SUBR)
767768
#define lmp_pause_enc_capable(dev) ((dev)->features[5] & LMP_PAUSE_ENC)
768769
#define lmp_ext_inq_capable(dev) ((dev)->features[6] & LMP_EXT_INQ)
769-
#define lmp_le_br_capable(dev) ((dev)->features[6] & LMP_SIMUL_LE_BR)
770+
#define lmp_le_br_capable(dev) !!((dev)->features[6] & LMP_SIMUL_LE_BR)
770771
#define lmp_ssp_capable(dev) ((dev)->features[6] & LMP_SIMPLE_PAIR)
771772
#define lmp_no_flush_capable(dev) ((dev)->features[6] & LMP_NO_FLUSH)
772773
#define lmp_lsto_capable(dev) ((dev)->features[7] & LMP_LSTO)
@@ -775,20 +776,38 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
775776

776777
/* ----- Extended LMP capabilities ----- */
777778
#define lmp_host_ssp_capable(dev) ((dev)->host_features[0] & LMP_HOST_SSP)
778-
#define lmp_host_le_capable(dev) ((dev)->host_features[0] & LMP_HOST_LE)
779-
#define lmp_host_le_br_capable(dev) ((dev)->host_features[0] & LMP_HOST_LE_BREDR)
779+
#define lmp_host_le_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE)
780+
#define lmp_host_le_br_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE_BREDR)
781+
782+
/* returns true if at least one AMP active */
783+
static inline bool hci_amp_capable(void)
784+
{
785+
struct hci_dev *hdev;
786+
bool ret = false;
787+
788+
read_lock(&hci_dev_list_lock);
789+
list_for_each_entry(hdev, &hci_dev_list, list)
790+
if (hdev->amp_type == HCI_AMP &&
791+
test_bit(HCI_UP, &hdev->flags))
792+
ret = true;
793+
read_unlock(&hci_dev_list_lock);
794+
795+
return ret;
796+
}
780797

781798
/* ----- HCI protocols ----- */
799+
#define HCI_PROTO_DEFER 0x01
800+
782801
static inline int hci_proto_connect_ind(struct hci_dev *hdev, bdaddr_t *bdaddr,
783-
__u8 type)
802+
__u8 type, __u8 *flags)
784803
{
785804
switch (type) {
786805
case ACL_LINK:
787806
return l2cap_connect_ind(hdev, bdaddr);
788807

789808
case SCO_LINK:
790809
case ESCO_LINK:
791-
return sco_connect_ind(hdev, bdaddr);
810+
return sco_connect_ind(hdev, bdaddr, flags);
792811

793812
default:
794813
BT_ERR("unknown link type %d", type);

‎include/net/bluetooth/l2cap.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ enum {
611611
CONF_MTU_DONE,
612612
CONF_MODE_DONE,
613613
CONF_CONNECT_PEND,
614-
CONF_NO_FCS_RECV,
614+
CONF_RECV_NO_FCS,
615615
CONF_STATE2_DEVICE,
616616
CONF_EWS_RECV,
617617
CONF_LOC_CONF_PEND,

‎net/bluetooth/hci_core.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,9 @@ static int hci_dev_do_close(struct hci_dev *hdev)
861861
/* Clear flags */
862862
hdev->flags = 0;
863863

864+
/* Controller radio is available but is currently powered down */
865+
hdev->amp_status = 0;
866+
864867
memset(hdev->eir, 0, sizeof(hdev->eir));
865868
memset(hdev->dev_class, 0, sizeof(hdev->dev_class));
866869

@@ -1854,6 +1857,8 @@ void hci_unregister_dev(struct hci_dev *hdev)
18541857
for (i = 0; i < NUM_REASSEMBLY; i++)
18551858
kfree_skb(hdev->reassembly[i]);
18561859

1860+
cancel_work_sync(&hdev->power_on);
1861+
18571862
if (!test_bit(HCI_INIT, &hdev->flags) &&
18581863
!test_bit(HCI_SETUP, &hdev->dev_flags)) {
18591864
hci_dev_lock(hdev);

‎net/bluetooth/hci_event.c‎

Lines changed: 50 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -794,10 +794,10 @@ static void hci_set_le_support(struct hci_dev *hdev)
794794

795795
if (test_bit(HCI_LE_ENABLED, &hdev->dev_flags)) {
796796
cp.le = 1;
797-
cp.simul = !!lmp_le_br_capable(hdev);
797+
cp.simul = lmp_le_br_capable(hdev);
798798
}
799799

800-
if (cp.le != !!lmp_host_le_capable(hdev))
800+
if (cp.le != lmp_host_le_capable(hdev))
801801
hci_send_cmd(hdev, HCI_OP_WRITE_LE_HOST_SUPPORTED, sizeof(cp),
802802
&cp);
803803
}
@@ -2047,15 +2047,53 @@ static void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
20472047
hci_conn_check_pending(hdev);
20482048
}
20492049

2050+
void hci_conn_accept(struct hci_conn *conn, int mask)
2051+
{
2052+
struct hci_dev *hdev = conn->hdev;
2053+
2054+
BT_DBG("conn %p", conn);
2055+
2056+
conn->state = BT_CONFIG;
2057+
2058+
if (!lmp_esco_capable(hdev)) {
2059+
struct hci_cp_accept_conn_req cp;
2060+
2061+
bacpy(&cp.bdaddr, &conn->dst);
2062+
2063+
if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER))
2064+
cp.role = 0x00; /* Become master */
2065+
else
2066+
cp.role = 0x01; /* Remain slave */
2067+
2068+
hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp), &cp);
2069+
} else /* lmp_esco_capable(hdev)) */ {
2070+
struct hci_cp_accept_sync_conn_req cp;
2071+
2072+
bacpy(&cp.bdaddr, &conn->dst);
2073+
cp.pkt_type = cpu_to_le16(conn->pkt_type);
2074+
2075+
cp.tx_bandwidth = __constant_cpu_to_le32(0x00001f40);
2076+
cp.rx_bandwidth = __constant_cpu_to_le32(0x00001f40);
2077+
cp.max_latency = __constant_cpu_to_le16(0xffff);
2078+
cp.content_format = cpu_to_le16(hdev->voice_setting);
2079+
cp.retrans_effort = 0xff;
2080+
2081+
hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ,
2082+
sizeof(cp), &cp);
2083+
}
2084+
}
2085+
20502086
static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
20512087
{
20522088
struct hci_ev_conn_request *ev = (void *) skb->data;
20532089
int mask = hdev->link_mode;
2090+
__u8 flags = 0;
20542091

20552092
BT_DBG("%s bdaddr %pMR type 0x%x", hdev->name, &ev->bdaddr,
20562093
ev->link_type);
20572094

2058-
mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type);
2095+
mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type,
2096+
&flags);
20592097

20602098
if ((mask & HCI_LM_ACCEPT) &&
20612099
!hci_blacklist_lookup(hdev, &ev->bdaddr)) {
@@ -2081,12 +2119,13 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
20812119
}
20822120

20832121
memcpy(conn->dev_class, ev->dev_class, 3);
2084-
conn->state = BT_CONNECT;
20852122

20862123
hci_dev_unlock(hdev);
20872124

2088-
if (ev->link_type == ACL_LINK || !lmp_esco_capable(hdev)) {
2125+
if (ev->link_type == ACL_LINK ||
2126+
(!(flags & HCI_PROTO_DEFER) && !lmp_esco_capable(hdev))) {
20892127
struct hci_cp_accept_conn_req cp;
2128+
conn->state = BT_CONNECT;
20902129

20912130
bacpy(&cp.bdaddr, &ev->bdaddr);
20922131

@@ -2097,8 +2136,9 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
20972136

20982137
hci_send_cmd(hdev, HCI_OP_ACCEPT_CONN_REQ, sizeof(cp),
20992138
&cp);
2100-
} else {
2139+
} else if (!(flags & HCI_PROTO_DEFER)) {
21012140
struct hci_cp_accept_sync_conn_req cp;
2141+
conn->state = BT_CONNECT;
21022142

21032143
bacpy(&cp.bdaddr, &ev->bdaddr);
21042144
cp.pkt_type = cpu_to_le16(conn->pkt_type);
@@ -2111,6 +2151,10 @@ static void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
21112151

21122152
hci_send_cmd(hdev, HCI_OP_ACCEPT_SYNC_CONN_REQ,
21132153
sizeof(cp), &cp);
2154+
} else {
2155+
conn->state = BT_CONNECT2;
2156+
hci_proto_connect_cfm(conn, 0);
2157+
hci_conn_put(conn);
21142158
}
21152159
} else {
21162160
/* Connection rejected */

0 commit comments

Comments
 (0)