Skip to content

Commit 96040be

Browse files
paul-szczepanek-arm0xc0170
authored andcommitted
wsf buffer transfers owenrship to controller
1 parent 0de3510 commit 96040be

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ 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.
58+
* @param pData Pointer to the data to transmit. This is an WSF buffer and we receive ownership.
5959
*
6060
* @return The number of bytes which have been transmited.
6161
*/

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ void hciTrSendAclData(void *pContext, uint8_t *pData)
8080
*
8181
* \brief Send a complete HCI command to the transport.
8282
*
83-
* \param pData WSF msg buffer containing an HCI command.
83+
* \param pData WSF msg buffer containing an HCI command. WSF buffer ownership is released by this function.
8484
*
8585
* \return None.
8686
*/
@@ -95,12 +95,13 @@ void hciTrSendCmd(uint8_t *pData)
9595
/* dump event for protocol analysis */
9696
HCI_PDUMP_CMD(len, pData);
9797

98-
/* transmit ACL header and data */
99-
if (hciDrvWrite(HCI_CMD_TYPE, len, pData) == len)
98+
/* transmit ACL header and data (releases the ownership of the WSF buffer containing pData) */
99+
if (hciDrvWrite(HCI_CMD_TYPE, len, pData) != len)
100100
{
101-
/* free buffer */
102-
WsfMsgFree(pData);
101+
/* transport failure */
102+
WSF_ASSERT(0);
103103
}
104+
/* pData is not freed as the hciDrvWrite took ownership of the WSF buffer */
104105
}
105106

106107

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ void NRFCordioHCITransportDriver::terminate()
4646

4747
uint16_t NRFCordioHCITransportDriver::write(uint8_t hci_type, uint16_t len, uint8_t *pData)
4848
{
49+
/* ownership of the WSF buffer is transferred to the controller (zero copy HCI) */
4950
return FakeChciTrRead(CHCI_TR_PROT_BLE, hci_type, len, pData);
5051
}
5152

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ 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.
54+
* @param pData Pointer to the data to transmit. This is an WSF buffer and we receive ownership.
5555
*
5656
* @return The number of bytes which have been transmited.
5757
*/

0 commit comments

Comments
 (0)