nimble/ll: Add helper to copy from "flat" mbuf

This helper can be used when we know that payload is stored in single
mbuf (not chained) and starts at offset 0. This silly optimization can
save some CPU cycles which does make difference when trying to send
CONNECT_REQ on nRF51.
This commit is contained in:
Andrzej Kaczmarek
2018-06-07 14:57:38 +02:00
parent 17297a3ffe
commit e62e520876
3 changed files with 19 additions and 1 deletions
@@ -451,6 +451,7 @@ int ble_ll_rx_end(uint8_t *rxbuf, struct ble_mbuf_hdr *rxhdr);
/* Helper callback to tx mbuf using ble_phy_tx() */
uint8_t ble_ll_tx_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte);
uint8_t ble_ll_tx_flat_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte);
/*--- Controller API ---*/
void ble_ll_mbuf_init(struct os_mbuf *m, uint8_t pdulen, uint8_t hdr);
+17
View File
@@ -1017,6 +1017,23 @@ ble_ll_tx_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
return ble_hdr->txinfo.pyld_len;
}
uint8_t
ble_ll_tx_flat_mbuf_pducb(uint8_t *dptr, void *pducb_arg, uint8_t *hdr_byte)
{
struct os_mbuf *txpdu;
struct ble_mbuf_hdr *ble_hdr;
txpdu = pducb_arg;
BLE_LL_ASSERT(txpdu);
ble_hdr = BLE_MBUF_HDR_PTR(txpdu);
memcpy(dptr, txpdu->om_data, ble_hdr->txinfo.pyld_len);
*hdr_byte = ble_hdr->txinfo.hdr_byte;
return ble_hdr->txinfo.pyld_len;
}
static void
ble_ll_event_rx_pkt(struct ble_npl_event *ev)
{
+1 -1
View File
@@ -2868,7 +2868,7 @@ ble_ll_conn_request_send(uint8_t addr_type, uint8_t *adva, uint16_t txoffset,
} else {
ble_phy_set_txend_cb(ble_ll_conn_req_txend_init, NULL);
}
rc = ble_phy_tx(ble_ll_tx_mbuf_pducb, m, end_trans);
rc = ble_phy_tx(ble_ll_tx_flat_mbuf_pducb, m, end_trans);
return rc;
}