All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFCv1 0/6] Handle AMP_LINK
@ 2012-10-08 14:52 Andrei Emeltchenko
  2012-10-08 14:52 ` [RFCv1 1/6] Bluetooth: Allow to set flush timeout Andrei Emeltchenko
                   ` (6 more replies)
  0 siblings, 7 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-08 14:52 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Add code for handling High Speed link

Andrei Emeltchenko (6):
  Bluetooth: Allow to set flush timeout
  Bluetooth: AMP: Handle AMP_LINK timeout
  Bluetooth: AMP: Add handle to hci_chan structure
  Bluetooth: Handle number of compl blocks for AMP_LINK
  Bluetooth: AMP: Handle AMP_LINK connection
  Bluetooth: AMP: Hanlde AMP_LINK case in conn_put

 include/net/bluetooth/hci_core.h |   36 +++++++++++++++++---
 net/bluetooth/hci_conn.c         |   69 ++++++++++++++++++++++++++++++++++++--
 net/bluetooth/hci_core.c         |   22 ++++++++++--
 net/bluetooth/hci_event.c        |   13 +++++--
 net/bluetooth/l2cap_sock.c       |    1 +
 5 files changed, 128 insertions(+), 13 deletions(-)

-- 
1.7.9.5


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

* [RFCv1 1/6] Bluetooth: Allow to set flush timeout
  2012-10-08 14:52 [RFCv1 0/6] Handle AMP_LINK Andrei Emeltchenko
@ 2012-10-08 14:52 ` Andrei Emeltchenko
  2012-10-08 14:52 ` [RFCv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout Andrei Emeltchenko
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-08 14:52 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>


Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/l2cap_sock.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index a71c408..b0014d5 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -529,6 +529,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
 		chan->fcs  = opts.fcs;
 		chan->max_tx = opts.max_tx;
 		chan->tx_win = opts.txwin_size;
+		chan->flush_to = opts.flush_to;
 		break;
 
 	case L2CAP_LM:
-- 
1.7.9.5


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

* [RFCv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout
  2012-10-08 14:52 [RFCv1 0/6] Handle AMP_LINK Andrei Emeltchenko
  2012-10-08 14:52 ` [RFCv1 1/6] Bluetooth: Allow to set flush timeout Andrei Emeltchenko
@ 2012-10-08 14:52 ` Andrei Emeltchenko
  2012-10-09 14:39   ` Marcel Holtmann
  2012-10-08 14:52 ` [RFCv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure Andrei Emeltchenko
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-08 14:52 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

When AMP_LINK timeouts execute HCI_OP_DISCONN_PHY_LINK as analog to
HCI_OP_DISCONNECT for ACL_LINK.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/hci_conn.c |   35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 53202f6..3584f58 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -130,6 +130,20 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
 	hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp);
 }
 
+static void hci_amp_disconn(struct hci_conn *conn, __u8 reason)
+{
+	struct hci_cp_disconn_phy_link cp;
+
+	BT_DBG("hcon %p", conn);
+
+	conn->state = BT_DISCONN;
+
+	cp.phy_handle = (u8) conn->handle;
+	cp.reason = reason;
+	hci_send_cmd(conn->hdev, HCI_OP_DISCONN_PHY_LINK,
+		     sizeof(cp), &cp);
+}
+
 static void hci_add_sco(struct hci_conn *conn, __u16 handle)
 {
 	struct hci_dev *hdev = conn->hdev;
@@ -230,11 +244,27 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status)
 	}
 }
 
+static void hci_conn_disconnect(struct hci_conn *conn)
+{
+	u8 reason;
+
+	reason = hci_proto_disconn_ind(conn);
+
+	switch (conn->type) {
+	case ACL_LINK:
+		hci_acl_disconn(conn, reason);
+		break;
+
+	case AMP_LINK:
+		hci_amp_disconn(conn, reason);
+		break;
+	}
+}
+
 static void hci_conn_timeout(struct work_struct *work)
 {
 	struct hci_conn *conn = container_of(work, struct hci_conn,
 					     disc_work.work);
-	__u8 reason;
 
 	BT_DBG("hcon %p state %s", conn, state_to_string(conn->state));
 
@@ -253,8 +283,7 @@ static void hci_conn_timeout(struct work_struct *work)
 		break;
 	case BT_CONFIG:
 	case BT_CONNECTED:
-		reason = hci_proto_disconn_ind(conn);
-		hci_acl_disconn(conn, reason);
+		hci_conn_disconnect(conn);
 		break;
 	default:
 		conn->state = BT_CLOSED;
-- 
1.7.9.5


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

* [RFCv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure
  2012-10-08 14:52 [RFCv1 0/6] Handle AMP_LINK Andrei Emeltchenko
  2012-10-08 14:52 ` [RFCv1 1/6] Bluetooth: Allow to set flush timeout Andrei Emeltchenko
  2012-10-08 14:52 ` [RFCv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout Andrei Emeltchenko
@ 2012-10-08 14:52 ` Andrei Emeltchenko
  2012-10-09 14:46   ` Marcel Holtmann
  2012-10-08 14:52 ` [RFCv1 4/6] Bluetooth: Handle number of compl blocks for AMP_LINK Andrei Emeltchenko
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-08 14:52 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

hci_chan will be identified by handle used in logical link creation
process. This handle is used in AMP ACL-U packet handle field.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci_core.h |    6 ++++--
 net/bluetooth/hci_conn.c         |   34 ++++++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 90ae4f0..951f604 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -348,7 +348,7 @@ struct hci_conn {
 
 struct hci_chan {
 	struct list_head list;
-
+	__u16 handle;
 	struct hci_conn *conn;
 	struct sk_buff_head data_q;
 	unsigned int	sent;
@@ -565,7 +565,9 @@ void hci_conn_check_pending(struct hci_dev *hdev);
 struct hci_chan *hci_chan_create(struct hci_conn *conn);
 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_conn *hcon, __u16 handle);
+struct hci_chan *hci_chan_lookup_handle_all(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);
 int hci_conn_check_link_mode(struct hci_conn *conn);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 3584f58..7387516 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -992,3 +992,37 @@ void hci_chan_list_flush(struct hci_conn *conn)
 	list_for_each_entry_safe(chan, n, &conn->chan_list, list)
 		hci_chan_del(chan);
 }
+
+struct hci_chan *hci_chan_lookup_handle(struct hci_conn *hcon, __u16 handle)
+{
+	struct hci_chan *hchan;
+
+	list_for_each_entry(hchan, &hcon->chan_list, list) {
+		if (hchan->handle == handle)
+			return hchan;
+	}
+
+	return NULL;
+}
+
+struct hci_chan *hci_chan_lookup_handle_all(struct hci_dev *hdev, __u16 handle)
+{
+	struct hci_conn_hash *h = &hdev->conn_hash;
+	struct hci_conn *hcon;
+
+	rcu_read_lock();
+
+	list_for_each_entry_rcu(hcon, &h->list, list) {
+		struct hci_chan *hchan;
+
+		hchan = hci_chan_lookup_handle(hcon, handle);
+		if (hchan) {
+			rcu_read_unlock();
+			return hchan;
+		}
+	}
+
+	rcu_read_unlock();
+
+	return NULL;
+}
-- 
1.7.9.5


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

* [RFCv1 4/6] Bluetooth: Handle number of compl blocks for AMP_LINK
  2012-10-08 14:52 [RFCv1 0/6] Handle AMP_LINK Andrei Emeltchenko
                   ` (2 preceding siblings ...)
  2012-10-08 14:52 ` [RFCv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure Andrei Emeltchenko
@ 2012-10-08 14:52 ` Andrei Emeltchenko
  2012-10-09 14:49   ` Marcel Holtmann
  2012-10-08 14:52 ` [RFCv1 5/6] Bluetooth: AMP: Handle AMP_LINK connection Andrei Emeltchenko
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-08 14:52 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Add handling blocks count for AMP link.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/hci_event.c |   12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 82e478a..c479732 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2698,13 +2698,21 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
 
 	for (i = 0; i < ev->num_hndl; i++) {
 		struct hci_comp_blocks_info *info = &ev->handles[i];
-		struct hci_conn *conn;
+		struct hci_conn *conn = NULL;
+		struct hci_chan *chan;
 		__u16  handle, block_count;
 
 		handle = __le16_to_cpu(info->handle);
 		block_count = __le16_to_cpu(info->blocks);
 
-		conn = hci_conn_hash_lookup_handle(hdev, handle);
+		if (hdev->dev_type == HCI_BREDR) {
+			conn = hci_conn_hash_lookup_handle(hdev, handle);
+		} else {
+			chan = hci_chan_lookup_handle_all(hdev, handle);
+			if (chan)
+				conn = chan->conn;
+		}
+
 		if (!conn)
 			continue;
 
-- 
1.7.9.5


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

* [RFCv1 5/6] Bluetooth: AMP: Handle AMP_LINK connection
  2012-10-08 14:52 [RFCv1 0/6] Handle AMP_LINK Andrei Emeltchenko
                   ` (3 preceding siblings ...)
  2012-10-08 14:52 ` [RFCv1 4/6] Bluetooth: Handle number of compl blocks for AMP_LINK Andrei Emeltchenko
@ 2012-10-08 14:52 ` Andrei Emeltchenko
  2012-10-08 14:52 ` [RFCv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put Andrei Emeltchenko
  2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
  6 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-08 14:52 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

AMP_LINK represents physical link between AMP controllers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci_core.h |   13 +++++++++++++
 net/bluetooth/hci_core.c         |   22 +++++++++++++++++++---
 net/bluetooth/hci_event.c        |    1 +
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 951f604..744713b 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -73,6 +73,7 @@ struct discovery_state {
 struct hci_conn_hash {
 	struct list_head list;
 	unsigned int     acl_num;
+	unsigned int     amp_num;
 	unsigned int     sco_num;
 	unsigned int     le_num;
 };
@@ -447,6 +448,9 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
 	case ACL_LINK:
 		h->acl_num++;
 		break;
+	case AMP_LINK:
+		h->amp_num++;
+		break;
 	case LE_LINK:
 		h->le_num++;
 		break;
@@ -468,6 +472,9 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
 	case ACL_LINK:
 		h->acl_num--;
 		break;
+	case AMP_LINK:
+		h->amp_num--;
+		break;
 	case LE_LINK:
 		h->le_num--;
 		break;
@@ -484,6 +491,8 @@ static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type)
 	switch (type) {
 	case ACL_LINK:
 		return h->acl_num;
+	case AMP_LINK:
+		return h->amp_num;
 	case LE_LINK:
 		return h->le_num;
 	case SCO_LINK:
@@ -800,6 +809,10 @@ static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason)
 		sco_disconn_cfm(conn, reason);
 		break;
 
+	/* L2CAP would be handled for BREDR chan */
+	case AMP_LINK:
+		break;
+
 	default:
 		BT_ERR("unknown link type %d", conn->type);
 		break;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index bd26cb5..2e72c41 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2379,6 +2379,9 @@ static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type,
 	case ACL_LINK:
 		cnt = hdev->acl_cnt;
 		break;
+	case AMP_LINK:
+		cnt = hdev->block_cnt;
+		break;
 	case SCO_LINK:
 	case ESCO_LINK:
 		cnt = hdev->sco_cnt;
@@ -2508,11 +2511,19 @@ static void hci_sched_acl_blk(struct hci_dev *hdev)
 	struct hci_chan *chan;
 	struct sk_buff *skb;
 	int quote;
+	u8 type;
 
 	__check_timeout(hdev, cnt);
 
+	BT_DBG("%s", hdev->name);
+
+	if (hdev->dev_type == HCI_AMP)
+		type = AMP_LINK;
+	else
+		type = ACL_LINK;
+
 	while (hdev->block_cnt > 0 &&
-	       (chan = hci_chan_sent(hdev, ACL_LINK, &quote))) {
+	       (chan = hci_chan_sent(hdev, type, &quote))) {
 		u32 priority = (skb_peek(&chan->data_q))->priority;
 		while (quote > 0 && (skb = skb_peek(&chan->data_q))) {
 			int blocks;
@@ -2545,14 +2556,19 @@ static void hci_sched_acl_blk(struct hci_dev *hdev)
 	}
 
 	if (cnt != hdev->block_cnt)
-		hci_prio_recalculate(hdev, ACL_LINK);
+		hci_prio_recalculate(hdev, type);
 }
 
 static void hci_sched_acl(struct hci_dev *hdev)
 {
 	BT_DBG("%s", hdev->name);
 
-	if (!hci_conn_num(hdev, ACL_LINK))
+	/* No ACL link over BR/EDR controller */
+	if (!hci_conn_num(hdev, ACL_LINK) && hdev->dev_type == HCI_BREDR)
+		return;
+
+	/* No AMP link over AMP controller */
+	if (!hci_conn_num(hdev, AMP_LINK) && hdev->dev_type == HCI_AMP)
 		return;
 
 	switch (hdev->flow_ctl_mode) {
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index c479732..9a1c2f6 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2720,6 +2720,7 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
 
 		switch (conn->type) {
 		case ACL_LINK:
+		case AMP_LINK:
 			hdev->block_cnt += block_count;
 			if (hdev->block_cnt > hdev->num_blocks)
 				hdev->block_cnt = hdev->num_blocks;
-- 
1.7.9.5


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

* [RFCv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put
  2012-10-08 14:52 [RFCv1 0/6] Handle AMP_LINK Andrei Emeltchenko
                   ` (4 preceding siblings ...)
  2012-10-08 14:52 ` [RFCv1 5/6] Bluetooth: AMP: Handle AMP_LINK connection Andrei Emeltchenko
@ 2012-10-08 14:52 ` Andrei Emeltchenko
  2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
  6 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-08 14:52 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Handle AMP link when setting up disconnect timeout.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci_core.h |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 744713b..0cc8c85 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -604,7 +604,10 @@ static inline void hci_conn_put(struct hci_conn *conn)
 
 	if (atomic_dec_and_test(&conn->refcnt)) {
 		unsigned long timeo;
-		if (conn->type == ACL_LINK || conn->type == LE_LINK) {
+
+		switch (conn->type) {
+		case ACL_LINK:
+		case LE_LINK:
 			del_timer(&conn->idle_timer);
 			if (conn->state == BT_CONNECTED) {
 				timeo = conn->disc_timeout;
@@ -613,12 +616,20 @@ static inline void hci_conn_put(struct hci_conn *conn)
 			} else {
 				timeo = msecs_to_jiffies(10);
 			}
-		} else {
+			break;
+
+		case AMP_LINK:
+			timeo = conn->disc_timeout;
+			break;
+
+		default:
 			timeo = msecs_to_jiffies(10);
+			break;
 		}
+
 		cancel_delayed_work(&conn->disc_work);
 		queue_delayed_work(conn->hdev->workqueue,
-					&conn->disc_work, timeo);
+				   &conn->disc_work, timeo);
 	}
 }
 
-- 
1.7.9.5


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

* Re: [RFCv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout
  2012-10-08 14:52 ` [RFCv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout Andrei Emeltchenko
@ 2012-10-09 14:39   ` Marcel Holtmann
  0 siblings, 0 replies; 23+ messages in thread
From: Marcel Holtmann @ 2012-10-09 14:39 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

> When AMP_LINK timeouts execute HCI_OP_DISCONN_PHY_LINK as analog to
> HCI_OP_DISCONNECT for ACL_LINK.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/hci_conn.c |   35 ++++++++++++++++++++++++++++++++---
>  1 file changed, 32 insertions(+), 3 deletions(-)
> 
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 53202f6..3584f58 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -130,6 +130,20 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
>  	hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp);
>  }
>  
> +static void hci_amp_disconn(struct hci_conn *conn, __u8 reason)
> +{
> +	struct hci_cp_disconn_phy_link cp;
> +
> +	BT_DBG("hcon %p", conn);
> +
> +	conn->state = BT_DISCONN;
> +
> +	cp.phy_handle = (u8) conn->handle;

I rather not do this cast. Maybe having conn->phy_handle is cleaner or
some helper macro like HCI_PHY_HANDLE(conn->handle) or something. Or
just do conn->handle & 0xff.

> +	cp.reason = reason;
> +	hci_send_cmd(conn->hdev, HCI_OP_DISCONN_PHY_LINK,
> +		     sizeof(cp), &cp);
> +}
> +
>  static void hci_add_sco(struct hci_conn *conn, __u16 handle)
>  {
>  	struct hci_dev *hdev = conn->hdev;
> @@ -230,11 +244,27 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status)
>  	}
>  }
>  
> +static void hci_conn_disconnect(struct hci_conn *conn)
> +{
> +	u8 reason;
> +
> +	reason = hci_proto_disconn_ind(conn);

Please keep using __u8 and in this case just make it one line.

	__u8 reason = hci_proto_disconn_ind(conn);

> +
> +	switch (conn->type) {
> +	case ACL_LINK:
> +		hci_acl_disconn(conn, reason);
> +		break;
> +

Don't bother with this empty line.

> +	case AMP_LINK:
> +		hci_amp_disconn(conn, reason);
> +		break;
> +	}
> +}
> +
>  static void hci_conn_timeout(struct work_struct *work)
>  {
>  	struct hci_conn *conn = container_of(work, struct hci_conn,
>  					     disc_work.work);
> -	__u8 reason;
>  
>  	BT_DBG("hcon %p state %s", conn, state_to_string(conn->state));
>  
> @@ -253,8 +283,7 @@ static void hci_conn_timeout(struct work_struct *work)
>  		break;
>  	case BT_CONFIG:
>  	case BT_CONNECTED:
> -		reason = hci_proto_disconn_ind(conn);
> -		hci_acl_disconn(conn, reason);
> +		hci_conn_disconnect(conn);
>  		break;
>  	default:
>  		conn->state = BT_CLOSED;

Regards

Marcel



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

* Re: [RFCv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure
  2012-10-08 14:52 ` [RFCv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure Andrei Emeltchenko
@ 2012-10-09 14:46   ` Marcel Holtmann
  2012-10-10  8:34     ` Andrei Emeltchenko
  0 siblings, 1 reply; 23+ messages in thread
From: Marcel Holtmann @ 2012-10-09 14:46 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

> hci_chan will be identified by handle used in logical link creation
> process. This handle is used in AMP ACL-U packet handle field.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  include/net/bluetooth/hci_core.h |    6 ++++--
>  net/bluetooth/hci_conn.c         |   34 ++++++++++++++++++++++++++++++++++
>  2 files changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 90ae4f0..951f604 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -348,7 +348,7 @@ struct hci_conn {
>  
>  struct hci_chan {
>  	struct list_head list;
> -
> +	__u16 handle;
>  	struct hci_conn *conn;
>  	struct sk_buff_head data_q;
>  	unsigned int	sent;
> @@ -565,7 +565,9 @@ void hci_conn_check_pending(struct hci_dev *hdev);
>  struct hci_chan *hci_chan_create(struct hci_conn *conn);
>  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_conn *hcon, __u16 handle);
> +struct hci_chan *hci_chan_lookup_handle_all(struct hci_dev *hdev,
> +					    __u16 handle);

this naming is pretty bad. I have no idea what one function does
different compared to the other. Especially since none of them take a
hci_chan as argument, but start with that prefix.

Would be the naming hci_conn_lookup_chan be a lot clearer? Or maybe
hci_chan_lookup_from_dev or similar.

>  struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst,
>  			     __u8 dst_type, __u8 sec_level, __u8 auth_type);
>  int hci_conn_check_link_mode(struct hci_conn *conn);
> diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
> index 3584f58..7387516 100644
> --- a/net/bluetooth/hci_conn.c
> +++ b/net/bluetooth/hci_conn.c
> @@ -992,3 +992,37 @@ void hci_chan_list_flush(struct hci_conn *conn)
>  	list_for_each_entry_safe(chan, n, &conn->chan_list, list)
>  		hci_chan_del(chan);
>  }
> +
> +struct hci_chan *hci_chan_lookup_handle(struct hci_conn *hcon, __u16 handle)
> +{
> +	struct hci_chan *hchan;
> +
> +	list_for_each_entry(hchan, &hcon->chan_list, list) {
> +		if (hchan->handle == handle)
> +			return hchan;
> +	}
> +
> +	return NULL;
> +}

Since this function is unprotected, you better make this __hci_....

And on a different note. It is not used at all. So why is this public
anyway?

> +
> +struct hci_chan *hci_chan_lookup_handle_all(struct hci_dev *hdev, __u16 handle)
> +{
> +	struct hci_conn_hash *h = &hdev->conn_hash;
> +	struct hci_conn *hcon;
> +
> +	rcu_read_lock();
> +
> +	list_for_each_entry_rcu(hcon, &h->list, list) {
> +		struct hci_chan *hchan;
> +
> +		hchan = hci_chan_lookup_handle(hcon, handle);
> +		if (hchan) {
> +			rcu_read_unlock();
> +			return hchan;

Please use break here. Have a global hchan variable assigned to NULL and
just break here.

> +		}
> +	}
> +
> +	rcu_read_unlock();
> +
> +	return NULL;
> +}

Regards

Marcel



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

* Re: [RFCv1 4/6] Bluetooth: Handle number of compl blocks for AMP_LINK
  2012-10-08 14:52 ` [RFCv1 4/6] Bluetooth: Handle number of compl blocks for AMP_LINK Andrei Emeltchenko
@ 2012-10-09 14:49   ` Marcel Holtmann
  2012-10-10  8:22     ` Andrei Emeltchenko
  0 siblings, 1 reply; 23+ messages in thread
From: Marcel Holtmann @ 2012-10-09 14:49 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

> Add handling blocks count for AMP link.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  net/bluetooth/hci_event.c |   12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> index 82e478a..c479732 100644
> --- a/net/bluetooth/hci_event.c
> +++ b/net/bluetooth/hci_event.c
> @@ -2698,13 +2698,21 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
>  
>  	for (i = 0; i < ev->num_hndl; i++) {
>  		struct hci_comp_blocks_info *info = &ev->handles[i];
> -		struct hci_conn *conn;
> +		struct hci_conn *conn = NULL;
> +		struct hci_chan *chan;
>  		__u16  handle, block_count;
>  
>  		handle = __le16_to_cpu(info->handle);
>  		block_count = __le16_to_cpu(info->blocks);
>  
> -		conn = hci_conn_hash_lookup_handle(hdev, handle);
> +		if (hdev->dev_type == HCI_BREDR) {
> +			conn = hci_conn_hash_lookup_handle(hdev, handle);
> +		} else {
> +			chan = hci_chan_lookup_handle_all(hdev, handle);
> +			if (chan)
> +				conn = chan->conn;

Just in case, we better use a switch statement here.

And now coming to think about it, do we ever need the hci_chan anyway.
Then why not have a function that looks up the hci_conn.

Maybe introduce a new hci_conn_lookup_handle(hdev, handle) and it will
do the right thing depending on what the device type is.

> +		}
> +
>  		if (!conn)
>  			continue;
>  

Regards

Marcel



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

* Re: [RFCv1 4/6] Bluetooth: Handle number of compl blocks for AMP_LINK
  2012-10-09 14:49   ` Marcel Holtmann
@ 2012-10-10  8:22     ` Andrei Emeltchenko
  0 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10  8:22 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Tue, Oct 09, 2012 at 04:49:18PM +0200, Marcel Holtmann wrote:
> Hi Andrei,
> 
> > Add handling blocks count for AMP link.
> > 
> > Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> > ---
> >  net/bluetooth/hci_event.c |   12 ++++++++++--
> >  1 file changed, 10 insertions(+), 2 deletions(-)
> > 
> > diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
> > index 82e478a..c479732 100644
> > --- a/net/bluetooth/hci_event.c
> > +++ b/net/bluetooth/hci_event.c
> > @@ -2698,13 +2698,21 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
> >  
> >  	for (i = 0; i < ev->num_hndl; i++) {
> >  		struct hci_comp_blocks_info *info = &ev->handles[i];
> > -		struct hci_conn *conn;
> > +		struct hci_conn *conn = NULL;
> > +		struct hci_chan *chan;
> >  		__u16  handle, block_count;
> >  
> >  		handle = __le16_to_cpu(info->handle);
> >  		block_count = __le16_to_cpu(info->blocks);
> >  
> > -		conn = hci_conn_hash_lookup_handle(hdev, handle);
> > +		if (hdev->dev_type == HCI_BREDR) {
> > +			conn = hci_conn_hash_lookup_handle(hdev, handle);
> > +		} else {
> > +			chan = hci_chan_lookup_handle_all(hdev, handle);
> > +			if (chan)
> > +				conn = chan->conn;
> 
> Just in case, we better use a switch statement here.
> 
> And now coming to think about it, do we ever need the hci_chan anyway.

For AMP hchan represents logical link so it is needed.

> Then why not have a function that looks up the hci_conn.
> 
> Maybe introduce a new hci_conn_lookup_handle(hdev, handle) and it will
> do the right thing depending on what the device type is.

This looks good, will do this way.

Best regards 
Andrei Emeltchenko 

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

* Re: [RFCv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure
  2012-10-09 14:46   ` Marcel Holtmann
@ 2012-10-10  8:34     ` Andrei Emeltchenko
  2012-10-10 10:07       ` Marcel Holtmann
  0 siblings, 1 reply; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10  8:34 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Tue, Oct 09, 2012 at 04:46:31PM +0200, Marcel Holtmann wrote:
...
> > -
> > +struct hci_chan *hci_chan_lookup_handle(struct hci_conn *hcon, __u16 handle);
> > +struct hci_chan *hci_chan_lookup_handle_all(struct hci_dev *hdev,
> > +					    __u16 handle);
> 
> this naming is pretty bad. I have no idea what one function does
> different compared to the other. Especially since none of them take a
> hci_chan as argument, but start with that prefix.
> 
> Would be the naming hci_conn_lookup_chan be a lot clearer? Or maybe
> hci_chan_lookup_from_dev or similar.

So are names like:

hci_conn_lookup_hchan_by_handle
hci_conn_lookup_hchan_from_hdev

better?

...
> > +struct hci_chan *hci_chan_lookup_handle(struct hci_conn *hcon, __u16 handle)
> > +{
> > +	struct hci_chan *hchan;
> > +
> > +	list_for_each_entry(hchan, &hcon->chan_list, list) {
> > +		if (hchan->handle == handle)
> > +			return hchan;
> > +	}
> > +
> > +	return NULL;
> > +}
> 
> Since this function is unprotected, you better make this __hci_....
> 
> And on a different note. It is not used at all. So why is this public
> anyway?

I will make it static.

...
> > +	rcu_read_lock();
> > +
> > +	list_for_each_entry_rcu(hcon, &h->list, list) {
> > +		struct hci_chan *hchan;
> > +
> > +		hchan = hci_chan_lookup_handle(hcon, handle);
> > +		if (hchan) {
> > +			rcu_read_unlock();
> > +			return hchan;
> 
> Please use break here. Have a global hchan variable assigned to NULL and
> just break here.

OK.

Best regards 
Andrei Emeltchenko 

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

* Re: [RFCv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure
  2012-10-10  8:34     ` Andrei Emeltchenko
@ 2012-10-10 10:07       ` Marcel Holtmann
  2012-10-10 10:12         ` Andrei Emeltchenko
  0 siblings, 1 reply; 23+ messages in thread
From: Marcel Holtmann @ 2012-10-10 10:07 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

> > > -
> > > +struct hci_chan *hci_chan_lookup_handle(struct hci_conn *hcon, __u16 handle);
> > > +struct hci_chan *hci_chan_lookup_handle_all(struct hci_dev *hdev,
> > > +					    __u16 handle);
> > 
> > this naming is pretty bad. I have no idea what one function does
> > different compared to the other. Especially since none of them take a
> > hci_chan as argument, but start with that prefix.
> > 
> > Would be the naming hci_conn_lookup_chan be a lot clearer? Or maybe
> > hci_chan_lookup_from_dev or similar.
> 
> So are names like:
> 
> hci_conn_lookup_hchan_by_handle

since this one is only internal, you better have a shortcut version as
just a static helper inside that code.

> hci_conn_lookup_hchan_from_hdev

If we follow our naming convention then hci_chan_lookup_from_dev would
come closest. However since you only need one of these, then
hci_chan_lookup_handle would be fine and in sync with how we named
everything else.

I rather not have the prefixing h everywhere that we use in variable
names. That should be really only for variable names.

Regards

Marcel



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

* Re: [RFCv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure
  2012-10-10 10:07       ` Marcel Holtmann
@ 2012-10-10 10:12         ` Andrei Emeltchenko
  0 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10 10:12 UTC (permalink / raw)
  To: Marcel Holtmann; +Cc: linux-bluetooth

Hi Marcel,

On Wed, Oct 10, 2012 at 12:07:56PM +0200, Marcel Holtmann wrote:
> Hi Andrei,
> 
> > > > -
> > > > +struct hci_chan *hci_chan_lookup_handle(struct hci_conn *hcon, __u16 handle);
> > > > +struct hci_chan *hci_chan_lookup_handle_all(struct hci_dev *hdev,
> > > > +					    __u16 handle);
> > > 
> > > this naming is pretty bad. I have no idea what one function does
> > > different compared to the other. Especially since none of them take a
> > > hci_chan as argument, but start with that prefix.
> > > 
> > > Would be the naming hci_conn_lookup_chan be a lot clearer? Or maybe
> > > hci_chan_lookup_from_dev or similar.
> > 
> > So are names like:
> > 
> > hci_conn_lookup_hchan_by_handle
> 
> since this one is only internal, you better have a shortcut version as
> just a static helper inside that code.

OK, will name this like __hci_chan_lookup_handle

> 
> > hci_conn_lookup_hchan_from_hdev
> 
> If we follow our naming convention then hci_chan_lookup_from_dev would
> come closest. However since you only need one of these, then
> hci_chan_lookup_handle would be fine and in sync with how we named
> everything else.

then this would be:

hci_chan_lookup_handle

Best regards 
Andrei Emeltchenko 

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

* [PATCHv1 0/6] Handle AMP_LINK
  2012-10-08 14:52 [RFCv1 0/6] Handle AMP_LINK Andrei Emeltchenko
                   ` (5 preceding siblings ...)
  2012-10-08 14:52 ` [RFCv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put Andrei Emeltchenko
@ 2012-10-10 14:38 ` Andrei Emeltchenko
  2012-10-10 14:38   ` [PATCHv1 1/6] Bluetooth: Allow to set flush timeout Andrei Emeltchenko
                     ` (6 more replies)
  6 siblings, 7 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10 14:38 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Add code for handling High Speed link

Changes:
	* v1: Fixes according to Marcel's review
	* RFCv1: Initial release

Andrei Emeltchenko (6):
  Bluetooth: Allow to set flush timeout
  Bluetooth: AMP: Handle AMP_LINK timeout
  Bluetooth: AMP: Add handle to hci_chan structure
  Bluetooth: AMP: Handle number of compl blocks for AMP_LINK
  Bluetooth: AMP: Handle AMP_LINK connection
  Bluetooth: AMP: Hanlde AMP_LINK case in conn_put

 include/net/bluetooth/hci_core.h |   35 ++++++++++++++++++---
 net/bluetooth/hci_conn.c         |   64 ++++++++++++++++++++++++++++++++++++--
 net/bluetooth/hci_core.c         |   22 +++++++++++--
 net/bluetooth/hci_event.c        |   26 ++++++++++++++--
 net/bluetooth/l2cap_sock.c       |    1 +
 5 files changed, 136 insertions(+), 12 deletions(-)

-- 
1.7.9.5


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

* [PATCHv1 1/6] Bluetooth: Allow to set flush timeout
  2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
@ 2012-10-10 14:38   ` Andrei Emeltchenko
  2012-10-10 14:38   ` [PATCHv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout Andrei Emeltchenko
                     ` (5 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10 14:38 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>


Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/l2cap_sock.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
index af467ce..ed2dfc9 100644
--- a/net/bluetooth/l2cap_sock.c
+++ b/net/bluetooth/l2cap_sock.c
@@ -529,6 +529,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname, char __us
 		chan->fcs  = opts.fcs;
 		chan->max_tx = opts.max_tx;
 		chan->tx_win = opts.txwin_size;
+		chan->flush_to = opts.flush_to;
 		break;
 
 	case L2CAP_LM:
-- 
1.7.9.5


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

* [PATCHv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout
  2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
  2012-10-10 14:38   ` [PATCHv1 1/6] Bluetooth: Allow to set flush timeout Andrei Emeltchenko
@ 2012-10-10 14:38   ` Andrei Emeltchenko
  2012-10-10 14:38   ` [PATCHv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure Andrei Emeltchenko
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10 14:38 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

When AMP_LINK timeouts execute HCI_OP_DISCONN_PHY_LINK as analog to
HCI_OP_DISCONNECT for ACL_LINK.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci_core.h |    2 ++
 net/bluetooth/hci_conn.c         |   32 +++++++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 90ae4f0..dfa108c 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -285,6 +285,8 @@ struct hci_dev {
 	int (*ioctl)(struct hci_dev *hdev, unsigned int cmd, unsigned long arg);
 };
 
+#define HCI_PHY_HANDLE(handle)	(handle & 0xff)
+
 struct hci_conn {
 	struct list_head list;
 
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 53202f6..6487579 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -130,6 +130,20 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
 	hci_send_cmd(conn->hdev, HCI_OP_DISCONNECT, sizeof(cp), &cp);
 }
 
+static void hci_amp_disconn(struct hci_conn *conn, __u8 reason)
+{
+	struct hci_cp_disconn_phy_link cp;
+
+	BT_DBG("hcon %p", conn);
+
+	conn->state = BT_DISCONN;
+
+	cp.phy_handle = HCI_PHY_HANDLE(conn->handle);
+	cp.reason = reason;
+	hci_send_cmd(conn->hdev, HCI_OP_DISCONN_PHY_LINK,
+		     sizeof(cp), &cp);
+}
+
 static void hci_add_sco(struct hci_conn *conn, __u16 handle)
 {
 	struct hci_dev *hdev = conn->hdev;
@@ -230,11 +244,24 @@ void hci_sco_setup(struct hci_conn *conn, __u8 status)
 	}
 }
 
+static void hci_conn_disconnect(struct hci_conn *conn)
+{
+	__u8 reason = hci_proto_disconn_ind(conn);
+
+	switch (conn->type) {
+	case ACL_LINK:
+		hci_acl_disconn(conn, reason);
+		break;
+	case AMP_LINK:
+		hci_amp_disconn(conn, reason);
+		break;
+	}
+}
+
 static void hci_conn_timeout(struct work_struct *work)
 {
 	struct hci_conn *conn = container_of(work, struct hci_conn,
 					     disc_work.work);
-	__u8 reason;
 
 	BT_DBG("hcon %p state %s", conn, state_to_string(conn->state));
 
@@ -253,8 +280,7 @@ static void hci_conn_timeout(struct work_struct *work)
 		break;
 	case BT_CONFIG:
 	case BT_CONNECTED:
-		reason = hci_proto_disconn_ind(conn);
-		hci_acl_disconn(conn, reason);
+		hci_conn_disconnect(conn);
 		break;
 	default:
 		conn->state = BT_CLOSED;
-- 
1.7.9.5


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

* [PATCHv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure
  2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
  2012-10-10 14:38   ` [PATCHv1 1/6] Bluetooth: Allow to set flush timeout Andrei Emeltchenko
  2012-10-10 14:38   ` [PATCHv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout Andrei Emeltchenko
@ 2012-10-10 14:38   ` Andrei Emeltchenko
  2012-10-10 14:38   ` [PATCHv1 4/6] Bluetooth: AMP: Handle number of compl blocks for AMP_LINK Andrei Emeltchenko
                     ` (3 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10 14:38 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

hci_chan will be identified by handle used in logical link creation
process. This handle is used in AMP ACL-U packet handle field.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci_core.h |    3 ++-
 net/bluetooth/hci_conn.c         |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index dfa108c..b697ef3 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -350,7 +350,7 @@ struct hci_conn {
 
 struct hci_chan {
 	struct list_head list;
-
+	__u16 handle;
 	struct hci_conn *conn;
 	struct sk_buff_head data_q;
 	unsigned int	sent;
@@ -567,6 +567,7 @@ void hci_conn_check_pending(struct hci_dev *hdev);
 struct hci_chan *hci_chan_create(struct hci_conn *conn);
 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);
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index 6487579..fe64621 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -989,3 +989,35 @@ void hci_chan_list_flush(struct hci_conn *conn)
 	list_for_each_entry_safe(chan, n, &conn->chan_list, list)
 		hci_chan_del(chan);
 }
+
+static struct hci_chan *__hci_chan_lookup_handle(struct hci_conn *hcon,
+						 __u16 handle)
+{
+	struct hci_chan *hchan;
+
+	list_for_each_entry(hchan, &hcon->chan_list, list) {
+		if (hchan->handle == handle)
+			return hchan;
+	}
+
+	return NULL;
+}
+
+struct hci_chan *hci_chan_lookup_handle(struct hci_dev *hdev, __u16 handle)
+{
+	struct hci_conn_hash *h = &hdev->conn_hash;
+	struct hci_conn *hcon;
+	struct hci_chan *hchan = NULL;
+
+	rcu_read_lock();
+
+	list_for_each_entry_rcu(hcon, &h->list, list) {
+		hchan = __hci_chan_lookup_handle(hcon, handle);
+		if (hchan)
+			break;
+	}
+
+	rcu_read_unlock();
+
+	return hchan;
+}
-- 
1.7.9.5


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

* [PATCHv1 4/6] Bluetooth: AMP: Handle number of compl blocks for AMP_LINK
  2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
                     ` (2 preceding siblings ...)
  2012-10-10 14:38   ` [PATCHv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure Andrei Emeltchenko
@ 2012-10-10 14:38   ` Andrei Emeltchenko
  2012-10-10 14:38   ` [PATCHv1 5/6] Bluetooth: AMP: Handle AMP_LINK connection Andrei Emeltchenko
                     ` (2 subsequent siblings)
  6 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10 14:38 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Add handling blocks count for AMP link.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 net/bluetooth/hci_event.c |   25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 82e478a..5c0b6c1 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2677,6 +2677,27 @@ static void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
 	queue_work(hdev->workqueue, &hdev->tx_work);
 }
 
+static struct hci_conn *__hci_conn_lookup_handle(struct hci_dev *hdev,
+						 __u16 handle)
+{
+	struct hci_chan *chan;
+
+	switch (hdev->dev_type) {
+	case HCI_BREDR:
+		return hci_conn_hash_lookup_handle(hdev, handle);
+	case HCI_AMP:
+		chan = hci_chan_lookup_handle(hdev, handle);
+		if (chan)
+			return chan->conn;
+		break;
+	default:
+		BT_ERR("%s unknown dev_type %d", hdev->name, hdev->dev_type);
+		break;
+	}
+
+	return NULL;
+}
+
 static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
 {
 	struct hci_ev_num_comp_blocks *ev = (void *) skb->data;
@@ -2698,13 +2719,13 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
 
 	for (i = 0; i < ev->num_hndl; i++) {
 		struct hci_comp_blocks_info *info = &ev->handles[i];
-		struct hci_conn *conn;
+		struct hci_conn *conn = NULL;
 		__u16  handle, block_count;
 
 		handle = __le16_to_cpu(info->handle);
 		block_count = __le16_to_cpu(info->blocks);
 
-		conn = hci_conn_hash_lookup_handle(hdev, handle);
+		conn = __hci_conn_lookup_handle(hdev, handle);
 		if (!conn)
 			continue;
 
-- 
1.7.9.5


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

* [PATCHv1 5/6] Bluetooth: AMP: Handle AMP_LINK connection
  2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
                     ` (3 preceding siblings ...)
  2012-10-10 14:38   ` [PATCHv1 4/6] Bluetooth: AMP: Handle number of compl blocks for AMP_LINK Andrei Emeltchenko
@ 2012-10-10 14:38   ` Andrei Emeltchenko
  2012-10-10 14:38   ` [PATCHv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put Andrei Emeltchenko
  2012-10-10 15:28   ` [PATCHv1 0/6] Handle AMP_LINK Marcel Holtmann
  6 siblings, 0 replies; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10 14:38 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

AMP_LINK represents physical link between AMP controllers.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci_core.h |   13 +++++++++++++
 net/bluetooth/hci_core.c         |   22 +++++++++++++++++++---
 net/bluetooth/hci_event.c        |    1 +
 3 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index b697ef3..d5ed054 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -73,6 +73,7 @@ struct discovery_state {
 struct hci_conn_hash {
 	struct list_head list;
 	unsigned int     acl_num;
+	unsigned int     amp_num;
 	unsigned int     sco_num;
 	unsigned int     le_num;
 };
@@ -449,6 +450,9 @@ static inline void hci_conn_hash_add(struct hci_dev *hdev, struct hci_conn *c)
 	case ACL_LINK:
 		h->acl_num++;
 		break;
+	case AMP_LINK:
+		h->amp_num++;
+		break;
 	case LE_LINK:
 		h->le_num++;
 		break;
@@ -470,6 +474,9 @@ static inline void hci_conn_hash_del(struct hci_dev *hdev, struct hci_conn *c)
 	case ACL_LINK:
 		h->acl_num--;
 		break;
+	case AMP_LINK:
+		h->amp_num--;
+		break;
 	case LE_LINK:
 		h->le_num--;
 		break;
@@ -486,6 +493,8 @@ static inline unsigned int hci_conn_num(struct hci_dev *hdev, __u8 type)
 	switch (type) {
 	case ACL_LINK:
 		return h->acl_num;
+	case AMP_LINK:
+		return h->amp_num;
 	case LE_LINK:
 		return h->le_num;
 	case SCO_LINK:
@@ -801,6 +810,10 @@ static inline void hci_proto_disconn_cfm(struct hci_conn *conn, __u8 reason)
 		sco_disconn_cfm(conn, reason);
 		break;
 
+	/* L2CAP would be handled for BREDR chan */
+	case AMP_LINK:
+		break;
+
 	default:
 		BT_ERR("unknown link type %d", conn->type);
 		break;
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index bd26cb5..2e72c41 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2379,6 +2379,9 @@ static struct hci_chan *hci_chan_sent(struct hci_dev *hdev, __u8 type,
 	case ACL_LINK:
 		cnt = hdev->acl_cnt;
 		break;
+	case AMP_LINK:
+		cnt = hdev->block_cnt;
+		break;
 	case SCO_LINK:
 	case ESCO_LINK:
 		cnt = hdev->sco_cnt;
@@ -2508,11 +2511,19 @@ static void hci_sched_acl_blk(struct hci_dev *hdev)
 	struct hci_chan *chan;
 	struct sk_buff *skb;
 	int quote;
+	u8 type;
 
 	__check_timeout(hdev, cnt);
 
+	BT_DBG("%s", hdev->name);
+
+	if (hdev->dev_type == HCI_AMP)
+		type = AMP_LINK;
+	else
+		type = ACL_LINK;
+
 	while (hdev->block_cnt > 0 &&
-	       (chan = hci_chan_sent(hdev, ACL_LINK, &quote))) {
+	       (chan = hci_chan_sent(hdev, type, &quote))) {
 		u32 priority = (skb_peek(&chan->data_q))->priority;
 		while (quote > 0 && (skb = skb_peek(&chan->data_q))) {
 			int blocks;
@@ -2545,14 +2556,19 @@ static void hci_sched_acl_blk(struct hci_dev *hdev)
 	}
 
 	if (cnt != hdev->block_cnt)
-		hci_prio_recalculate(hdev, ACL_LINK);
+		hci_prio_recalculate(hdev, type);
 }
 
 static void hci_sched_acl(struct hci_dev *hdev)
 {
 	BT_DBG("%s", hdev->name);
 
-	if (!hci_conn_num(hdev, ACL_LINK))
+	/* No ACL link over BR/EDR controller */
+	if (!hci_conn_num(hdev, ACL_LINK) && hdev->dev_type == HCI_BREDR)
+		return;
+
+	/* No AMP link over AMP controller */
+	if (!hci_conn_num(hdev, AMP_LINK) && hdev->dev_type == HCI_AMP)
 		return;
 
 	switch (hdev->flow_ctl_mode) {
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 5c0b6c1..0383635 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -2733,6 +2733,7 @@ static void hci_num_comp_blocks_evt(struct hci_dev *hdev, struct sk_buff *skb)
 
 		switch (conn->type) {
 		case ACL_LINK:
+		case AMP_LINK:
 			hdev->block_cnt += block_count;
 			if (hdev->block_cnt > hdev->num_blocks)
 				hdev->block_cnt = hdev->num_blocks;
-- 
1.7.9.5


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

* [PATCHv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put
  2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
                     ` (4 preceding siblings ...)
  2012-10-10 14:38   ` [PATCHv1 5/6] Bluetooth: AMP: Handle AMP_LINK connection Andrei Emeltchenko
@ 2012-10-10 14:38   ` Andrei Emeltchenko
  2012-10-11  6:36     ` Gustavo Padovan
  2012-10-10 15:28   ` [PATCHv1 0/6] Handle AMP_LINK Marcel Holtmann
  6 siblings, 1 reply; 23+ messages in thread
From: Andrei Emeltchenko @ 2012-10-10 14:38 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Handle AMP link when setting up disconnect timeout.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci_core.h |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index d5ed054..9fe8e2d 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -605,7 +605,10 @@ static inline void hci_conn_put(struct hci_conn *conn)
 
 	if (atomic_dec_and_test(&conn->refcnt)) {
 		unsigned long timeo;
-		if (conn->type == ACL_LINK || conn->type == LE_LINK) {
+
+		switch (conn->type) {
+		case ACL_LINK:
+		case LE_LINK:
 			del_timer(&conn->idle_timer);
 			if (conn->state == BT_CONNECTED) {
 				timeo = conn->disc_timeout;
@@ -614,12 +617,20 @@ static inline void hci_conn_put(struct hci_conn *conn)
 			} else {
 				timeo = msecs_to_jiffies(10);
 			}
-		} else {
+			break;
+
+		case AMP_LINK:
+			timeo = conn->disc_timeout;
+			break;
+
+		default:
 			timeo = msecs_to_jiffies(10);
+			break;
 		}
+
 		cancel_delayed_work(&conn->disc_work);
 		queue_delayed_work(conn->hdev->workqueue,
-					&conn->disc_work, timeo);
+				   &conn->disc_work, timeo);
 	}
 }
 
-- 
1.7.9.5


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

* Re: [PATCHv1 0/6] Handle AMP_LINK
  2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
                     ` (5 preceding siblings ...)
  2012-10-10 14:38   ` [PATCHv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put Andrei Emeltchenko
@ 2012-10-10 15:28   ` Marcel Holtmann
  6 siblings, 0 replies; 23+ messages in thread
From: Marcel Holtmann @ 2012-10-10 15:28 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

> Add code for handling High Speed link
> 
> Changes:
> 	* v1: Fixes according to Marcel's review
> 	* RFCv1: Initial release
> 
> Andrei Emeltchenko (6):
>   Bluetooth: Allow to set flush timeout
>   Bluetooth: AMP: Handle AMP_LINK timeout
>   Bluetooth: AMP: Add handle to hci_chan structure
>   Bluetooth: AMP: Handle number of compl blocks for AMP_LINK
>   Bluetooth: AMP: Handle AMP_LINK connection
>   Bluetooth: AMP: Hanlde AMP_LINK case in conn_put

patches look fine to me.

Acked-by: Marcel Holtmann <marcel@holtmann.org>

Regards

Marcel



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

* Re: [PATCHv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put
  2012-10-10 14:38   ` [PATCHv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put Andrei Emeltchenko
@ 2012-10-11  6:36     ` Gustavo Padovan
  0 siblings, 0 replies; 23+ messages in thread
From: Gustavo Padovan @ 2012-10-11  6:36 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth

Hi Andrei,

* Andrei Emeltchenko <Andrei.Emeltchenko.news@gmail.com> [2012-10-10 17:38:31 +0300]:

> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Handle AMP link when setting up disconnect timeout.
> 
> Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> ---
>  include/net/bluetooth/hci_core.h |   17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)

All 6 patches have been applied to bluetooth-next. Thanks.

	Gustavo

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

end of thread, other threads:[~2012-10-11  6:36 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-08 14:52 [RFCv1 0/6] Handle AMP_LINK Andrei Emeltchenko
2012-10-08 14:52 ` [RFCv1 1/6] Bluetooth: Allow to set flush timeout Andrei Emeltchenko
2012-10-08 14:52 ` [RFCv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout Andrei Emeltchenko
2012-10-09 14:39   ` Marcel Holtmann
2012-10-08 14:52 ` [RFCv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure Andrei Emeltchenko
2012-10-09 14:46   ` Marcel Holtmann
2012-10-10  8:34     ` Andrei Emeltchenko
2012-10-10 10:07       ` Marcel Holtmann
2012-10-10 10:12         ` Andrei Emeltchenko
2012-10-08 14:52 ` [RFCv1 4/6] Bluetooth: Handle number of compl blocks for AMP_LINK Andrei Emeltchenko
2012-10-09 14:49   ` Marcel Holtmann
2012-10-10  8:22     ` Andrei Emeltchenko
2012-10-08 14:52 ` [RFCv1 5/6] Bluetooth: AMP: Handle AMP_LINK connection Andrei Emeltchenko
2012-10-08 14:52 ` [RFCv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put Andrei Emeltchenko
2012-10-10 14:38 ` [PATCHv1 0/6] Handle AMP_LINK Andrei Emeltchenko
2012-10-10 14:38   ` [PATCHv1 1/6] Bluetooth: Allow to set flush timeout Andrei Emeltchenko
2012-10-10 14:38   ` [PATCHv1 2/6] Bluetooth: AMP: Handle AMP_LINK timeout Andrei Emeltchenko
2012-10-10 14:38   ` [PATCHv1 3/6] Bluetooth: AMP: Add handle to hci_chan structure Andrei Emeltchenko
2012-10-10 14:38   ` [PATCHv1 4/6] Bluetooth: AMP: Handle number of compl blocks for AMP_LINK Andrei Emeltchenko
2012-10-10 14:38   ` [PATCHv1 5/6] Bluetooth: AMP: Handle AMP_LINK connection Andrei Emeltchenko
2012-10-10 14:38   ` [PATCHv1 6/6] Bluetooth: AMP: Hanlde AMP_LINK case in conn_put Andrei Emeltchenko
2012-10-11  6:36     ` Gustavo Padovan
2012-10-10 15:28   ` [PATCHv1 0/6] Handle AMP_LINK Marcel Holtmann

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.