Skip to content

Commit 9ae55e2

Browse files
committed
[nrf fromtree] Revert "Bluetooth: host: Send host num completes as early as possible"
This reverts commit 147ee3d. Signed-off-by: Pavel Vasilyev <[email protected]> (cherry picked from commit da9acbc)
1 parent 8425a1a commit 9ae55e2

File tree

4 files changed

+5
-33
lines changed

4 files changed

+5
-33
lines changed

subsys/bluetooth/host/conn.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -388,12 +388,11 @@ void bt_conn_reset_rx_state(struct bt_conn *conn)
388388
conn->rx = NULL;
389389
}
390390

391-
static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags)
391+
static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf,
392+
uint8_t flags)
392393
{
393394
uint16_t acl_total_len;
394395

395-
bt_acl_set_ncp_sent(buf, false);
396-
397396
/* Check packet boundary flags */
398397
switch (flags) {
399398
case BT_ACL_START:
@@ -405,7 +404,7 @@ static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags
405404
LOG_DBG("First, len %u final %u", buf->len,
406405
(buf->len < sizeof(uint16_t)) ? 0 : sys_get_le16(buf->data));
407406

408-
conn->rx = net_buf_ref(buf);
407+
conn->rx = buf;
409408
break;
410409
case BT_ACL_CONT:
411410
if (!conn->rx) {
@@ -435,6 +434,7 @@ static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags
435434
}
436435

437436
net_buf_add_mem(conn->rx, buf->data, buf->len);
437+
net_buf_unref(buf);
438438
break;
439439
default:
440440
/* BT_ACL_START_NO_FLUSH and BT_ACL_COMPLETE are not allowed on
@@ -451,26 +451,16 @@ static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags
451451
/* Still not enough data received to retrieve the L2CAP header
452452
* length field.
453453
*/
454-
bt_send_one_host_num_completed_packets(conn->handle);
455-
bt_acl_set_ncp_sent(buf, true);
456-
net_buf_unref(buf);
457-
458454
return;
459455
}
460456

461457
acl_total_len = sys_get_le16(conn->rx->data) + sizeof(struct bt_l2cap_hdr);
462458

463459
if (conn->rx->len < acl_total_len) {
464460
/* L2CAP frame not complete. */
465-
bt_send_one_host_num_completed_packets(conn->handle);
466-
bt_acl_set_ncp_sent(buf, true);
467-
net_buf_unref(buf);
468-
469461
return;
470462
}
471463

472-
net_buf_unref(buf);
473-
474464
if (conn->rx->len > acl_total_len) {
475465
LOG_ERR("ACL len mismatch (%u > %u)", conn->rx->len, acl_total_len);
476466
bt_conn_reset_rx_state(conn);
@@ -481,8 +471,6 @@ static void bt_acl_recv(struct bt_conn *conn, struct net_buf *buf, uint8_t flags
481471
buf = conn->rx;
482472
conn->rx = NULL;
483473

484-
__ASSERT(buf->ref == 1, "buf->ref %d", buf->ref);
485-
486474
LOG_DBG("Successfully parsed %u byte L2CAP packet", buf->len);
487475
bt_l2cap_recv(conn, buf, true);
488476
}

subsys/bluetooth/host/conn_internal.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,12 +213,7 @@ struct acl_data {
213213
struct bt_buf_data buf_data;
214214

215215
/* Index into the bt_conn storage array */
216-
uint8_t index;
217-
218-
/** Host has already sent a Host Number of Completed Packets
219-
* for this buffer.
220-
*/
221-
bool host_ncp_sent;
216+
uint8_t index;
222217

223218
/** ACL connection handle */
224219
uint16_t handle;

subsys/bluetooth/host/hci_core.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -235,11 +235,6 @@ static void handle_vs_event(uint8_t event, struct net_buf *buf,
235235
/* Other possible errors are handled by handle_event_common function */
236236
}
237237

238-
void bt_acl_set_ncp_sent(struct net_buf *packet, bool value)
239-
{
240-
acl(packet)->host_ncp_sent = value;
241-
}
242-
243238
void bt_send_one_host_num_completed_packets(uint16_t handle)
244239
{
245240
if (!IS_ENABLED(CONFIG_BT_HCI_ACL_FLOW_CONTROL)) {
@@ -288,10 +283,6 @@ void bt_hci_host_num_completed_packets(struct net_buf *buf)
288283

289284
net_buf_destroy(buf);
290285

291-
if (acl(buf)->host_ncp_sent) {
292-
return;
293-
}
294-
295286
/* Do nothing if controller to host flow control is not supported */
296287
if (!BT_CMD_TEST(bt_dev.supported_commands, 10, 5)) {
297288
return;

subsys/bluetooth/host/hci_core.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -582,5 +582,3 @@ int bt_hci_le_read_max_data_len(uint16_t *tx_octets, uint16_t *tx_time);
582582
bool bt_drv_quirk_no_auto_dle(void);
583583

584584
void bt_tx_irq_raise(void);
585-
void bt_send_one_host_num_completed_packets(uint16_t handle);
586-
void bt_acl_set_ncp_sent(struct net_buf *packet, bool value);

0 commit comments

Comments
 (0)