Commit eb4a81a
committed
extmod/zephyr_ble: Improve L2CAP CoC throughput with seg_recv and DLE.
Switch L2CAP CoC from recv+alloc_buf to the seg_recv API, which gives the
application per-PDU callbacks with manual credit control. The old path
issued one credit per SDU, forcing the peer to wait for the full SDU to
be delivered before sending the next one. With seg_recv, credits are
issued one per non-last PDU (allowing the peer to pipeline all K-frames
of a single SDU) and one credit per SDU from recvinto() (for the first
PDU of the next SDU), keeping at most one assembled SDU buffered.
Work around a Zephyr bug in l2cap_chan_seg_recv_rx_init() which leaves
rx.mps at zero for seg_recv channels (unlike l2cap_chan_rx_init for the
normal path), causing immediate channel disconnect on the first received
PDU. Set rx.mps = BT_L2CAP_RX_MTU in l2cap_create_channel() and use
bt_l2cap_chan_give_credits() in accept/connect paths, matching the
pattern from Zephyr's credits_seg_recv test.
Also enable Data Length Extension (DLE) so the controller can negotiate
251-byte PDU payloads, reducing per-PDU overhead.
TX pipeline: allow up to L2CAP_SDU_BUF_COUNT-1 SDUs in flight concurrently
(tracked via tx_in_flight counter) rather than stalling after every send.
On nRF52840 dongle (PCA10059) with PYBD (NimBLE) as central:
perf_l2cap.py before: ~2,184 B/s
perf_l2cap.py after: ~11,518 B/s (5.3x improvement)
All 11 BLE multitests pass.
Signed-off-by: Andrew Leech <andrew@alelec.net>1 parent 4f9cb08 commit eb4a81a
2 files changed
Lines changed: 236 additions & 145 deletions
0 commit comments