From d9f549121c0a67c1b34c6aaeefbea4da91139a22 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Tue, 20 Jun 2017 14:27:22 -0600 Subject: [PATCH] ieee802154_req_data: Don't modify the IOB until we are certain that no EINTR errors will occur. Otherwise, the retry will fail --- configs/clicker2-stm32/README.txt | 3 +-- net/sixlowpan/sixlowpan_framelist.c | 10 ++++++++++ wireless/ieee802154/mac802154_data.c | 29 +++++++++++++++++++++------- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/configs/clicker2-stm32/README.txt b/configs/clicker2-stm32/README.txt index c016313636..260137c152 100644 --- a/configs/clicker2-stm32/README.txt +++ b/configs/clicker2-stm32/README.txt @@ -460,8 +460,7 @@ Configurations telnetd_daemon: ERROR: socket failure: 106 - 2017-06-20: I am get EINTR errors from the MAC layer when trying the - udpclient tries to send messages. Still under investigation. + 2017-06-20: Debug underway.. not yet functional. nsh: diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c index 226711af02..bf57aa5027 100644 --- a/net/sixlowpan/sixlowpan_framelist.c +++ b/net/sixlowpan/sixlowpan_framelist.c @@ -444,6 +444,9 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, /* Add the first frame to the IOB queue */ + ninfo("Queuing frame io_len=%u io_offset=%u\n", + iob->io_len, iob->io_offset); + qhead = iob; qtail = iob; @@ -522,6 +525,9 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, /* Add the next frame to the tail of the IOB queue */ + ninfo("Queuing frame io_len=%u io_offset=%u\n", + iob->io_len, iob->io_offset); + qtail->io_flink = iob; qtail = iob; @@ -544,6 +550,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, /* And submit the frame to the MAC */ + ninfo("Submitting framelist\n"); ret = sixlowpan_frame_submit(ieee, &meta, iob); if (ret < 0) { @@ -580,6 +587,9 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, /* And submit the frame to the MAC */ + ninfo("Submitting frame length=%u io_offset=%u\n", + iob->io_len, iob->io_offset); + ret = sixlowpan_frame_submit(ieee, &meta, iob); if (ret < 0) { diff --git a/wireless/ieee802154/mac802154_data.c b/wireless/ieee802154/mac802154_data.c index 0676c52103..12a664e5e4 100644 --- a/wireless/ieee802154/mac802154_data.c +++ b/wireless/ieee802154/mac802154_data.c @@ -82,12 +82,15 @@ int mac802154_req_data(MACHANDLE mac, uint8_t mhr_len = 3; int ret; + wlinfo("Received frame io_len=%u io_offset=%u\n", + frame->io_offset, frame->io_len); + /* Check the required frame size */ if (frame->io_len > IEEE802154_MAX_PHY_PACKET_SIZE) - { - return -E2BIG; - } + { + return -E2BIG; + } /* Cast the first two bytes of the IOB to a uint16_t frame control field */ @@ -226,10 +229,9 @@ int mac802154_req_data(MACHANDLE mac, * here that created the header */ + wlinfo("mhr_len=%u\n", mhr_len); DEBUGASSERT(mhr_len == frame->io_offset); - frame->io_offset = 0; /* Set the offset to 0 to include the header */ - /* Allocate the txdesc, waiting if necessary, allow interruptions */ ret = mac802154_txdesc_alloc(priv, &txdesc, true); @@ -243,6 +245,16 @@ int mac802154_req_data(MACHANDLE mac, return ret; } + /* Set the offset to 0 to include the header ( we do not want to + * modify the frame until AFTER the last place that -EINTR could + * be returned and could generate a retry. Subsequent error returns + * are fatal and no retry should occur. + */ + + frame->io_offset = 0; + + /* Then initialize the TX descriptor */ + txdesc->conf->handle = meta->msdu_handle; txdesc->frame = frame; txdesc->frametype = IEEE802154_FRAME_DATA; @@ -269,7 +281,7 @@ int mac802154_req_data(MACHANDLE mac, */ ret = -ENOTSUP; - goto errout_with_sem; + goto errout_with_txdesc; } else { @@ -306,7 +318,7 @@ int mac802154_req_data(MACHANDLE mac, else { ret = -EINVAL; - goto errout_with_sem; + goto errout_with_txdesc; } } else @@ -327,6 +339,9 @@ int mac802154_req_data(MACHANDLE mac, return OK; +errout_with_txdesc: + /* REVISIT: Free TX descriptor, but preserve the IOB. */ + errout_with_sem: mac802154_givesem(&priv->exclsem); return ret;