[RFC 3/5] Bluetooth: Add buffer count to tx scheduler parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Utilize already known tx buffer count values as parameters to
the tx scheduler, rather than determining the values on each
iteration of the tx scheduler.

This is preparatory for merging transmission types (such as SCO
and ESCO) and also for handling tx buffer counters atomically.

Signed-off-by: Peter Hurley <peter@xxxxxxxxxxxxxxxxxx>
---
 net/bluetooth/hci_core.c |   60 ++++++++++++++++-----------------------------
 1 files changed, 21 insertions(+), 39 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 0defa83..668088f 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1825,28 +1825,8 @@ static inline struct hci_conn *hci_low_sent(struct hci_dev *hdev, __u8 type, int
 		}
 	}
 
-	if (conn) {
-		int cnt;
-
-		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");
-		}
-
-		*quote = (cnt + (num - 1)) / num;
-	} else
-		*quote = 0;
+	if (conn)
+		*quote = (*quote + (num - 1)) / num;
 
 	BT_DBG("conn %p quote %d", conn, *quote);
 	return conn;
@@ -1875,7 +1855,7 @@ static inline void hci_sched_acl(struct hci_dev *hdev)
 {
 	struct hci_conn *conn;
 	struct sk_buff *skb;
-	int quote;
+	int quote = hdev->acl_cnt;
 
 	BT_DBG("%s", hdev->name);
 
@@ -1886,8 +1866,8 @@ static inline void hci_sched_acl(struct hci_dev *hdev)
 			hci_link_tx_to(hdev, ACL_LINK);
 	}
 
-	while (hdev->acl_cnt && (conn = hci_low_sent(hdev, ACL_LINK, &quote))) {
-		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
+	while (quote && (conn = hci_low_sent(hdev, ACL_LINK, &quote))) {
+		while (quote && (skb = skb_dequeue(&conn->data_q))) {
 			BT_DBG("skb %p len %d", skb, skb->len);
 
 			hci_conn_enter_active_mode(conn);
@@ -1895,10 +1875,11 @@ static inline void hci_sched_acl(struct hci_dev *hdev)
 			hci_send_frame(skb);
 			hdev->acl_last_tx = jiffies;
 
-			hdev->acl_cnt--;
+			quote--;
 			conn->sent++;
 		}
 	}
+	hdev->acl_cnt = quote;
 }
 
 /* Schedule SCO */
@@ -1906,15 +1887,16 @@ static inline void hci_sched_sco(struct hci_dev *hdev)
 {
 	struct hci_conn *conn;
 	struct sk_buff *skb;
-	int quote;
+	int quote = hdev->sco_cnt;
 
 	BT_DBG("%s", hdev->name);
 
-	while (hdev->sco_cnt && (conn = hci_low_sent(hdev, SCO_LINK, &quote))) {
-		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
+	while (quote && (conn = hci_low_sent(hdev, SCO_LINK, &quote))) {
+		while (quote && (skb = skb_dequeue(&conn->data_q))) {
 			BT_DBG("skb %p len %d", skb, skb->len);
 			hci_send_frame(skb);
 
+			quote--;
 			conn->sent++;
 			if (conn->sent == ~0)
 				conn->sent = 0;
@@ -1926,15 +1908,16 @@ static inline void hci_sched_esco(struct hci_dev *hdev)
 {
 	struct hci_conn *conn;
 	struct sk_buff *skb;
-	int quote;
+	int quote = hdev->sco_cnt;
 
 	BT_DBG("%s", hdev->name);
 
-	while (hdev->sco_cnt && (conn = hci_low_sent(hdev, ESCO_LINK, &quote))) {
-		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
+	while (quote && (conn = hci_low_sent(hdev, ESCO_LINK, &quote))) {
+		while (quote && (skb = skb_dequeue(&conn->data_q))) {
 			BT_DBG("skb %p len %d", skb, skb->len);
 			hci_send_frame(skb);
 
+			quote--;
 			conn->sent++;
 			if (conn->sent == ~0)
 				conn->sent = 0;
@@ -1946,7 +1929,7 @@ static inline void hci_sched_le(struct hci_dev *hdev)
 {
 	struct hci_conn *conn;
 	struct sk_buff *skb;
-	int quote, cnt;
+	int quote = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt;
 
 	BT_DBG("%s", hdev->name);
 
@@ -1958,22 +1941,21 @@ static inline void hci_sched_le(struct hci_dev *hdev)
 			hci_link_tx_to(hdev, LE_LINK);
 	}
 
-	cnt = hdev->le_pkts ? hdev->le_cnt : hdev->acl_cnt;
-	while (cnt && (conn = hci_low_sent(hdev, LE_LINK, &quote))) {
-		while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
+	while (quote && (conn = hci_low_sent(hdev, LE_LINK, &quote))) {
+		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--;
+			quote--;
 			conn->sent++;
 		}
 	}
 	if (hdev->le_pkts)
-		hdev->le_cnt = cnt;
+		hdev->le_cnt = quote;
 	else
-		hdev->acl_cnt = cnt;
+		hdev->acl_cnt = quote;
 }
 
 static void hci_tx_task(unsigned long arg)
-- 
1.7.4.1

��.n��������+%������w��{.n�����{����^n�r������&��z�ޗ�zf���h���~����������_��+v���)ߣ�

[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux