You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by we...@apache.org on 2016/08/11 21:27:21 UTC
[21/50] [abbrv] incubator-mynewt-core git commit: BLE Host - Clean up
ACL tx fragmentation.
BLE Host - Clean up ACL tx fragmentation.
This commit does not result in a change in behavior. The fragmentation
code was overly complicated. This change just simplifies the
implementation.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/c7fbdb8a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/c7fbdb8a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/c7fbdb8a
Branch: refs/heads/phyrx_no_mbuf
Commit: c7fbdb8a51d160a247171ef1f704ee4be4920783
Parents: 5c65aaf
Author: Christopher Collins <cc...@apache.org>
Authored: Fri Aug 5 12:18:13 2016 -0700
Committer: William San Filippo <wi...@runtime.io>
Committed: Thu Aug 11 14:26:25 2016 -0700
----------------------------------------------------------------------
net/nimble/host/src/ble_hs_hci.c | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/c7fbdb8a/net/nimble/host/src/ble_hs_hci.c
----------------------------------------------------------------------
diff --git a/net/nimble/host/src/ble_hs_hci.c b/net/nimble/host/src/ble_hs_hci.c
index cd5cc6c..433c2e0 100644
--- a/net/nimble/host/src/ble_hs_hci.c
+++ b/net/nimble/host/src/ble_hs_hci.c
@@ -359,17 +359,16 @@ ble_hs_hci_rx_evt(uint8_t *hci_ev, void *arg)
* buffer size requirements, no splitting is performed. The fragment data is
* removed from the data packet mbuf.
*
- * @param om The ACL data packet.
+ * @param om The ACL data packet. If this constitutes a
+ * single fragment, it gets set to NULL on
+ * success.
* @param out_frag On success, this points to the fragment to
* send. If the entire packet can fit within
* a single fragment, this will point to the
* ACL data packet itself ('om').
*
- * @return BLE_HS_EDONE: success; this is the final
- * fragment.
- * BLE_HS_EAGAIN: success; more data remains in
- * the original mbuf.
- * Other BLE host core return code on error.
+ * @return 0 on success;
+ * BLE host core return code on error.
*/
static int
ble_hs_hci_split_frag(struct os_mbuf **om, struct os_mbuf **out_frag)
@@ -377,11 +376,14 @@ ble_hs_hci_split_frag(struct os_mbuf **om, struct os_mbuf **out_frag)
struct os_mbuf *frag;
int rc;
+ /* Assume failure. */
+ *out_frag = NULL;
+
if (OS_MBUF_PKTLEN(*om) <= ble_hs_hci_buf_sz) {
/* Final fragment. */
*out_frag = *om;
*om = NULL;
- return BLE_HS_EDONE;
+ return 0;
}
frag = ble_hs_mbuf_acm_pkt();
@@ -400,7 +402,7 @@ ble_hs_hci_split_frag(struct os_mbuf **om, struct os_mbuf **out_frag)
/* More fragments to follow. */
*out_frag = frag;
- return BLE_HS_EAGAIN;
+ return 0;
err:
os_mbuf_free_chain(frag);
@@ -449,7 +451,6 @@ ble_hs_hci_acl_tx(struct ble_hs_conn *connection, struct os_mbuf *txom)
{
struct os_mbuf *frag;
uint8_t pb;
- int done;
int rc;
/* The first fragment uses the first-non-flush packet boundary value.
@@ -459,20 +460,9 @@ ble_hs_hci_acl_tx(struct ble_hs_conn *connection, struct os_mbuf *txom)
pb = BLE_HCI_PB_FIRST_NON_FLUSH;
/* Send fragments until the entire packet has been sent. */
- done = 0;
- while (!done) {
+ while (txom != NULL) {
rc = ble_hs_hci_split_frag(&txom, &frag);
- switch (rc) {
- case BLE_HS_EDONE:
- /* This is the final fragment. */
- done = 1;
- break;
-
- case BLE_HS_EAGAIN:
- /* More fragments to follow. */
- break;
-
- default:
+ if (rc != 0) {
goto err;
}