Merge pull request #16503 from haukepetersen/opt_nimble_buffersizes
pkg/nimble/netif: fix and optimize NimBLE buffer sizes
This commit is contained in:
commit
04a0992f59
@ -93,15 +93,27 @@ ifneq (,$(filter nimble_netif,$(USEMODULE)))
|
||||
|
||||
# configure NimBLE's internals
|
||||
NIMBLE_MAX_CONN ?= 3
|
||||
CFLAGS += -DMYNEWT_VAL_MSYS_1_BLOCK_SIZE=264
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM=$(NIMBLE_MAX_CONN)
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_MAX_CONNECTIONS=$(NIMBLE_MAX_CONN)
|
||||
# NimBLEs internal buffer need to hold one IPv6 MTU per connection
|
||||
# for the internal MTU of 256 byte, we need 10 mbufs per connection...
|
||||
|
||||
# the maximum fragment size that we can receive. For maximum efficiency this
|
||||
# should be equal to the maximum configured link layer packet size.
|
||||
# WARNING: this value MUST never be larger than MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_L2CAP_COC_MPS=251
|
||||
|
||||
# in order to fit a 251 byte COC data segment into a single mbuf buffer, the
|
||||
# used block size must be at least 297 byte (251 data + 48 overhead)
|
||||
CFLAGS += -DMYNEWT_VAL_MSYS_1_BLOCK_SIZE="(MYNEWT_VAL_BLE_L2CAP_COC_MPS + 48)"
|
||||
|
||||
# in the worst case, NimBLEs internal buffer needs to hold two full IPv6 MTUs
|
||||
# per connection (1 TX and 1 RX). But in practice this would be highly over-
|
||||
# provisioned. Allocating 10 memory blocks per connection plus another 5
|
||||
# for internal buffering has proven to be a generous default value.
|
||||
CFLAGS += -DMYNEWT_VAL_MSYS_1_BLOCK_COUNT=35
|
||||
|
||||
# optimize the NimBLE controller for IP traffic
|
||||
ifneq (,$(filter nimble_controller,$(USEMODULE)))
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_LL_MAX_PKT_SIZE=251
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_LL_CFG_FEAT_DATA_LEN_EXT=1
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -26,11 +26,21 @@ CFLAGS += -DAPP_CID=$(APP_CID)
|
||||
# configure NimBLE
|
||||
USEPKG += nimble
|
||||
MSYS_CNT ?= 40
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM=1
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_L2CAP_COC_MPS=250
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_MAX_CONNECTIONS=1
|
||||
CFLAGS += -DMYNEWT_VAL_MSYS_1_BLOCK_COUNT=$(MSYS_CNT)
|
||||
CFLAGS += -DMYNEWT_VAL_MSYS_1_BLOCK_SIZE=298
|
||||
# For this test we use the controllers link layer data length extension
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_LL_CFG_FEAT_DATA_LEN_EXT=1
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_LL_MAX_PKT_SIZE=251
|
||||
# Enable L2CAP connection oriented channels, 1 is sufficient for this test
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_MAX_CONNECTIONS=1
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_L2CAP_COC_MAX_NUM=1
|
||||
# For maximum efficiency, we set the maximum L2CAP fragment size to the same
|
||||
# value as the maximum link layer packet size.
|
||||
# WARNING: this value MUST never be larger than MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE
|
||||
CFLAGS += -DMYNEWT_VAL_BLE_L2CAP_COC_MPS=MYNEWT_VAL_BLE_LL_MAX_PKT_SIZE
|
||||
# To be able to handle large packets, we must increase the default packet buffer
|
||||
# used by NimBLE.
|
||||
# In order to store a full L2CAP fragment/link layer packet in a single block,
|
||||
# we need to cater for a 48 byte overhead per block.
|
||||
CFLAGS += -DMYNEWT_VAL_MSYS_1_BLOCK_COUNT=$(MSYS_CNT)
|
||||
CFLAGS += -DMYNEWT_VAL_MSYS_1_BLOCK_SIZE="(MYNEWT_VAL_BLE_L2CAP_COC_MPS + 48)"
|
||||
|
||||
INCLUDES += -I$(RIOTBASE)/tests/nimble_l2cap_server/include
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user