don't track client packets granted in l2cap and rfcomm

This commit is contained in:
Matthias Ringwald 2015-12-18 16:14:23 +01:00
parent 47c8cf6f28
commit 3aff022f9b
4 changed files with 2 additions and 32 deletions

View File

@ -203,8 +203,6 @@ static void l2cap_emit_service_registered(void *connection, uint8_t status, uint
static void l2cap_emit_credits(l2cap_channel_t *channel, uint8_t credits) {
log_info("L2CAP_EVENT_CREDITS local_cid 0x%x credits %u", channel->local_cid, credits);
// track credits
channel->packets_granted += credits;
uint8_t event[5];
event[0] = L2CAP_EVENT_CREDITS;
@ -229,9 +227,7 @@ static void l2cap_hand_out_credits(void){
l2cap_channel_t * channel = (l2cap_channel_t *) linked_list_iterator_next(&it);
if (channel->state != L2CAP_STATE_OPEN) continue;
if (!hci_number_free_acl_slots_for_handle(channel->handle)) return;
if (hci_number_outgoing_packets(channel->handle) < NR_BUFFERED_ACL_PACKETS && channel->packets_granted == 0) {
l2cap_emit_credits(channel, 1);
}
l2cap_emit_credits(channel, 1);
}
}
@ -398,12 +394,7 @@ int l2cap_send_prepared(uint16_t local_cid, uint16_t len){
return BTSTACK_ACL_BUFFERS_FULL;
}
if (channel->packets_granted){
--channel->packets_granted;
}
log_debug("l2cap_send_prepared cid 0x%02x, handle %u, 1 credit used, credits left %u;",
local_cid, channel->handle, channel->packets_granted);
log_debug("l2cap_send_prepared cid 0x%02x, handle %u, 1 credit used", local_cid, channel->handle);
uint8_t *acl_buffer = hci_get_outgoing_packet_buffer();
@ -795,7 +786,6 @@ void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t c
chan->packet_handler = channel_packet_handler;
chan->remote_mtu = L2CAP_MINIMAL_MTU;
chan->local_mtu = mtu;
chan->packets_granted = 0;
// set initial state
chan->state = L2CAP_STATE_WILL_SEND_CREATE_CONNECTION;
@ -1087,7 +1077,6 @@ static void l2cap_handle_connection_request(hci_con_handle_t handle, uint8_t sig
channel->remote_cid = source_cid;
channel->local_mtu = service->mtu;
channel->remote_mtu = L2CAP_DEFAULT_MTU;
channel->packets_granted = 0;
channel->remote_sig_id = sig_id;
channel->required_security_level = service->required_security_level;

View File

@ -156,8 +156,6 @@ typedef struct {
gap_security_level_t required_security_level;
uint8_t packets_granted; // number of L2CAP/ACL packets client is allowed to send
uint8_t reason; // used in decline internal
timer_source_t rtx; // also used for ertx

View File

@ -380,7 +380,6 @@ static void rfcomm_channel_initialize(rfcomm_channel_t *channel, rfcomm_multiple
channel->credits_incoming = 0;
channel->credits_outgoing = 0;
channel->packets_granted = 0;
// set defaults for port configuration (even for services)
rfcomm_rpn_data_set_defaults(&channel->rpn_data);
@ -941,9 +940,7 @@ static int rfcomm_multiplexer_hci_event_handler(uint8_t *packet, uint16_t size){
l2cap_cid = READ_BT_16(packet, 2);
multiplexer = rfcomm_multiplexer_for_l2cap_cid(l2cap_cid);
if (!multiplexer) break;
// log_info("L2CAP_EVENT_CREDITS: %u (now %u)", packet[4], multiplexer->l2cap_credits);
// new credits, continue with signaling
rfcomm_run();
if (multiplexer->state != RFCOMM_MULTIPLEXER_OPEN) break;
@ -1185,17 +1182,12 @@ static void rfcomm_hand_out_credits(void){
// log_info("RFCOMM_EVENT_CREDITS: multiplexer not open");
continue;
}
if (channel->packets_granted) {
// log_info("RFCOMM_EVENT_CREDITS: already packets granted");
continue;
}
if (!channel->credits_outgoing) {
// log_info("RFCOMM_EVENT_CREDITS: no outgoing credits");
continue;
}
// channel open, multiplexer has l2cap credits and we didn't hand out credit before -> go!
// log_info("RFCOMM_EVENT_CREDITS: 1");
channel->packets_granted += 1;
rfcomm_emit_credits(channel, 1);
}
}
@ -2040,17 +2032,11 @@ int rfcomm_send_prepared(uint16_t rfcomm_cid, uint16_t len){
// send might cause l2cap to emit new credits, update counters first
channel->credits_outgoing--;
int packets_granted_decreased = 0;
if (channel->packets_granted) {
channel->packets_granted--;
packets_granted_decreased++;
}
int result = rfcomm_send_uih_prepared(channel->multiplexer, channel->dlci, len);
if (result != 0) {
channel->credits_outgoing++;
channel->packets_granted += packets_granted_decreased;
log_info("rfcomm_send_internal: error %d", result);
return result;
}

View File

@ -316,9 +316,6 @@ typedef struct {
uint8_t outgoing;
uint8_t dlci;
// number of packets granted to client
uint8_t packets_granted;
// credits for outgoing traffic
uint8_t credits_outgoing;