Skip to content

Commit a6f639b

Browse files
paul-szczepanek-arm0xc0170
authored andcommitted
zero copy HCI as a config option
1 parent 87f5e1f commit a6f639b

File tree

4 files changed

+26
-11
lines changed

4 files changed

+26
-11
lines changed

features/FEATURE_BLE/targets/TARGET_CORDIO/driver/CordioHCITransportDriver.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ class CordioHCITransportDriver {
5555
* packet, ACL packet or EVT packet. Depending on the type of transport
5656
* it can prefix the packet itself.
5757
* @param len Number of bytes to transmit.
58-
* @param pData Pointer to the data to transmit. This is an WSF buffer and we receive ownership.
58+
* @param pData Pointer to the data to transmit. This is an WSF buffer
59+
* and if CORDIO_ZERO_COPY_HCI is enabled we receive ownership.
5960
*
6061
* @return The number of bytes which have been transmited.
6162
*/

features/FEATURE_BLE/targets/TARGET_CORDIO/stack_adaptation/hci_tr.c

+15-9
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,15 @@ void hciTrSendAclData(void *pContext, uint8_t *pData)
6666
HCI_PDUMP_TX_ACL(len, pData);
6767

6868
/* transmit ACL header and data */
69-
if (hciDrvWrite(HCI_ACL_TYPE, len, pData) != len)
69+
if (hciDrvWrite(HCI_ACL_TYPE, len, pData) == len)
7070
{
71-
/* transport failure */
72-
WSF_ASSERT(0);
71+
#if CORDIO_ZERO_COPY_HCI
72+
/* pData is not freed as the hciDrvWrite took ownership of the WSF buffer */
73+
#else
74+
/* free buffer */
75+
WsfMsgFree(pData);
76+
#endif // CORDIO_ZERO_COPY_HCI
7377
}
74-
/* pData is not freed as the hciDrvWrite took ownership of the WSF buffer */
7578
}
7679

7780

@@ -96,13 +99,16 @@ void hciTrSendCmd(uint8_t *pData)
9699
/* dump event for protocol analysis */
97100
HCI_PDUMP_CMD(len, pData);
98101

99-
/* transmit ACL header and data (releases the ownership of the WSF buffer containing pData) */
100-
if (hciDrvWrite(HCI_CMD_TYPE, len, pData) != len)
102+
/* transmit ACL header and data */
103+
if (hciDrvWrite(HCI_CMD_TYPE, len, pData) == len)
101104
{
102-
/* transport failure */
103-
WSF_ASSERT(0);
105+
#if CORDIO_ZERO_COPY_HCI
106+
/* pData is not freed as the hciDrvWrite took ownership of the WSF buffer */
107+
#else
108+
/* free buffer */
109+
WsfMsgFree(pData);
110+
#endif // CORDIO_ZERO_COPY_HCI
104111
}
105-
/* pData is not freed as the hciDrvWrite took ownership of the WSF buffer */
106112
}
107113

108114

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/NRFCordioHCITransportDriver.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class NRFCordioHCITransportDriver : public cordio::CordioHCITransportDriver {
5151
* packet, ACL packet or EVT packet. Depending on the type of transport
5252
* it can prefix the packet itself.
5353
* @param len Number of bytes to transmit.
54-
* @param pData Pointer to the data to transmit. This is an WSF buffer and we receive ownership.
54+
* @param pData Pointer to the data to transmit. This is an WSF buffer
55+
* and if CORDIO_ZERO_COPY_HCI is enabled we receive ownership.
5556
*
5657
* @return The number of bytes which have been transmited.
5758
*/

features/FEATURE_BLE/targets/TARGET_NORDIC/TARGET_NORDIC_CORDIO/TARGET_NRF5x/mbed_lib.json

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
{
22
"name": "cordio-nordic-ll",
3+
"config": {
4+
"zero-copy-hci": {
5+
"help": "messages sent between Host and Controller are passed directly without copying if enabled. WSF messages ownership is trasfered to the callee.",
6+
"value": 0,
7+
"macro_name": "CORDIO_ZERO_COPY_HCI"
8+
}
9+
},
310
"macros": [
411
"INIT_BROADCASTER",
512
"INIT_OBSERVER",

0 commit comments

Comments
 (0)