aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavlin Radoslavov <pavlin@google.com>2015-09-22 11:27:30 -0700
committerScott James Remnant <keybuk@google.com>2015-10-19 10:36:20 -0700
commit21cce2ecb75265845e7b24f2cde11e104b074838 (patch)
tree0483c6649243416a768b17af26bfe08ded6143d4
parent2e3d006b96eafb0651fe7f78d28250faf89405de (diff)
downloadbt-21cce2ecb75265845e7b24f2cde11e104b074838.tar.gz
GKI cleanup - Eliminated function GKI_poolcount
Refactored function l2c_link_adjust_chnl_allocation. Now the buffer quota computation is done without using the GKI poll counts. Change-Id: I669492becc9024c12f3360ea58a06188caa6420a
-rw-r--r--gki/common/gki.h1
-rw-r--r--gki/common/gki_buffer.c20
-rw-r--r--stack/l2cap/l2c_int.h4
-rw-r--r--stack/l2cap/l2c_link.c94
4 files changed, 13 insertions, 106 deletions
diff --git a/gki/common/gki.h b/gki/common/gki.h
index 61d3afa6f..e8affab9e 100644
--- a/gki/common/gki.h
+++ b/gki/common/gki.h
@@ -66,7 +66,6 @@ typedef struct
void GKI_freebuf (void *);
void *GKI_getbuf (UINT16);
UINT16 GKI_get_buf_size (void *);
-UINT16 GKI_poolcount (UINT8);
/* User buffer queue management
diff --git a/gki/common/gki_buffer.c b/gki/common/gki_buffer.c
index e27ac4d25..ee4e416ff 100644
--- a/gki/common/gki_buffer.c
+++ b/gki/common/gki_buffer.c
@@ -459,26 +459,6 @@ UINT16 GKI_queue_length(BUFFER_Q *p_q)
/*******************************************************************************
**
-** Function GKI_poolcount
-**
-** Description Called by an application to get the total number of buffers
-** in the specified buffer pool.
-**
-** Parameters pool_id - (input) pool ID to get the free count of.
-**
-** Returns the total number of buffers in the pool
-**
-*******************************************************************************/
-UINT16 GKI_poolcount (UINT8 pool_id)
-{
- if (pool_id >= GKI_NUM_TOTAL_BUF_POOLS)
- return (0);
-
- return (gki_cb.com.freeq[pool_id].total);
-}
-
-/*******************************************************************************
-**
** Function GKI_get_pool_bufsize
**
** Description Called by an application to get the size of buffers in a pool
diff --git a/stack/l2cap/l2c_int.h b/stack/l2cap/l2c_int.h
index 2f06fb893..c6cf9a8c2 100644
--- a/stack/l2cap/l2c_int.h
+++ b/stack/l2cap/l2c_int.h
@@ -245,6 +245,10 @@ typedef struct
} tL2C_RCB;
+#ifndef L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA
+#define L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA 100
+#endif
+
/* Define a channel control block (CCB). There may be many channel control blocks
** between the same two Bluetooth devices (i.e. on the same link).
** Each CCB has unique local and remote CIDs. All channel control blocks on
diff --git a/stack/l2cap/l2c_link.c b/stack/l2cap/l2c_link.c
index 822257e1c..29f7bcd93 100644
--- a/stack/l2cap/l2c_link.c
+++ b/stack/l2cap/l2c_link.c
@@ -837,103 +837,27 @@ void l2c_link_adjust_allocation (void)
*******************************************************************************/
void l2c_link_adjust_chnl_allocation (void)
{
- tL2C_CCB *p_ccb;
UINT8 xx;
- UINT16 weighted_chnls[GKI_NUM_TOTAL_BUF_POOLS];
- UINT16 quota_per_weighted_chnls[GKI_NUM_TOTAL_BUF_POOLS];
- UINT16 reserved_buff[GKI_NUM_TOTAL_BUF_POOLS];
-
- L2CAP_TRACE_DEBUG ("l2c_link_adjust_chnl_allocation");
-
- /* initialize variables */
- for (xx = 0; xx < GKI_NUM_TOTAL_BUF_POOLS; xx++ )
- {
- weighted_chnls[xx] = 0;
- reserved_buff[xx] = 0;
- }
-
- /* add up all of tx and rx data rate requirement */
- /* channel required higher data rate will get more buffer quota */
- for (xx = 0; xx < MAX_L2CAP_CHANNELS; xx++)
- {
- p_ccb = l2cb.ccb_pool + xx;
-
- if (!p_ccb->in_use)
- continue;
-
- if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE)
- {
- weighted_chnls[p_ccb->ertm_info.user_tx_pool_id] += p_ccb->tx_data_rate;
- weighted_chnls[p_ccb->ertm_info.user_rx_pool_id] += p_ccb->rx_data_rate;
-
- if (p_ccb->ertm_info.fcr_tx_pool_id == HCI_ACL_POOL_ID)
- {
- /* reserve buffers only for wait_for_ack_q to maximize throughput */
- /* retrans_q will work based on buffer status */
- reserved_buff[HCI_ACL_POOL_ID] += p_ccb->peer_cfg.fcr.tx_win_sz;
- }
-
- if (p_ccb->ertm_info.fcr_rx_pool_id == HCI_ACL_POOL_ID)
- {
- /* reserve buffers for srej_rcv_hold_q */
- reserved_buff[HCI_ACL_POOL_ID] += p_ccb->peer_cfg.fcr.tx_win_sz;
- }
- }
- else
- {
- /* low data rate is 1, medium is 2, high is 3 and no traffic is 0 */
- weighted_chnls[HCI_ACL_POOL_ID] += p_ccb->tx_data_rate + p_ccb->rx_data_rate;
- }
- }
-
-
- /* get unit quota per pool */
- for (xx = 0; xx < GKI_NUM_TOTAL_BUF_POOLS; xx++ )
- {
- if ( weighted_chnls[xx] > 0 )
- {
- if (GKI_poolcount(xx) > reserved_buff[xx])
- quota_per_weighted_chnls[xx] = ((GKI_poolcount(xx) - reserved_buff[xx])/weighted_chnls[xx]) + 1;
- else
- quota_per_weighted_chnls[xx] = 1;
-
- L2CAP_TRACE_DEBUG ("POOL ID:%d, GKI_poolcount = %d, reserved_buff = %d, weighted_chnls = %d, quota_per_weighted_chnls = %d",
- xx, GKI_poolcount(xx), reserved_buff[xx], weighted_chnls[xx], quota_per_weighted_chnls[xx] );
- }
- else
- quota_per_weighted_chnls[xx] = 0;
- }
-
+ L2CAP_TRACE_DEBUG("%s", __func__);
/* assign buffer quota to each channel based on its data rate requirement */
for (xx = 0; xx < MAX_L2CAP_CHANNELS; xx++)
{
- p_ccb = l2cb.ccb_pool + xx;
+ tL2C_CCB *p_ccb = l2cb.ccb_pool + xx;
if (!p_ccb->in_use)
continue;
- if (p_ccb->peer_cfg.fcr.mode != L2CAP_FCR_BASIC_MODE)
- {
- p_ccb->buff_quota = quota_per_weighted_chnls[p_ccb->ertm_info.user_tx_pool_id] * p_ccb->tx_data_rate;
-
- L2CAP_TRACE_EVENT ("CID:0x%04x FCR Mode:%u UserTxPool:%u Priority:%u TxDataRate:%u Quota:%u",
- p_ccb->local_cid, p_ccb->peer_cfg.fcr.mode, p_ccb->ertm_info.user_tx_pool_id,
- p_ccb->ccb_priority, p_ccb->tx_data_rate, p_ccb->buff_quota);
-
- }
- else
- {
- p_ccb->buff_quota = quota_per_weighted_chnls[HCI_ACL_POOL_ID] * p_ccb->tx_data_rate;
-
- L2CAP_TRACE_EVENT ("CID:0x%04x Priority:%u TxDataRate:%u Quota:%u",
- p_ccb->local_cid,
- p_ccb->ccb_priority, p_ccb->tx_data_rate, p_ccb->buff_quota);
- }
+ tL2CAP_CHNL_DATA_RATE data_rate = p_ccb->tx_data_rate + p_ccb->rx_data_rate;
+ p_ccb->buff_quota = L2CAP_CBB_DEFAULT_DATA_RATE_BUFF_QUOTA * data_rate;
+ L2CAP_TRACE_EVENT("CID:0x%04x FCR Mode:%u Priority:%u TxDataRate:%u RxDataRate:%u Quota:%u",
+ p_ccb->local_cid, p_ccb->peer_cfg.fcr.mode,
+ p_ccb->ccb_priority, p_ccb->tx_data_rate,
+ p_ccb->rx_data_rate, p_ccb->buff_quota);
/* quota may be change so check congestion */
- l2cu_check_channel_congestion (p_ccb);
+ l2cu_check_channel_congestion(p_ccb);
}
}