ieee802154_req_data: Don't modify the IOB until we are certain that no EINTR errors will occur. Otherwise, the retry will fail

This commit is contained in:
Gregory Nutt
2017-06-20 14:27:22 -06:00
parent 192bacbd7f
commit d9f549121c
3 changed files with 33 additions and 9 deletions
+1 -2
View File
@@ -460,8 +460,7 @@ Configurations
telnetd_daemon: ERROR: socket failure: 106 telnetd_daemon: ERROR: socket failure: 106
2017-06-20: I am get EINTR errors from the MAC layer when trying the 2017-06-20: Debug underway.. not yet functional.
udpclient tries to send messages. Still under investigation.
nsh: nsh:
+10
View File
@@ -444,6 +444,9 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
/* Add the first frame to the IOB queue */ /* 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; qhead = iob;
qtail = 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 */ /* 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->io_flink = iob;
qtail = iob; qtail = iob;
@@ -544,6 +550,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
/* And submit the frame to the MAC */ /* And submit the frame to the MAC */
ninfo("Submitting framelist\n");
ret = sixlowpan_frame_submit(ieee, &meta, iob); ret = sixlowpan_frame_submit(ieee, &meta, iob);
if (ret < 0) if (ret < 0)
{ {
@@ -580,6 +587,9 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee,
/* And submit the frame to the MAC */ /* 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); ret = sixlowpan_frame_submit(ieee, &meta, iob);
if (ret < 0) if (ret < 0)
{ {
+22 -7
View File
@@ -82,12 +82,15 @@ int mac802154_req_data(MACHANDLE mac,
uint8_t mhr_len = 3; uint8_t mhr_len = 3;
int ret; int ret;
wlinfo("Received frame io_len=%u io_offset=%u\n",
frame->io_offset, frame->io_len);
/* Check the required frame size */ /* Check the required frame size */
if (frame->io_len > IEEE802154_MAX_PHY_PACKET_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 */ /* 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 * here that created the header
*/ */
wlinfo("mhr_len=%u\n", mhr_len);
DEBUGASSERT(mhr_len == frame->io_offset); 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 */ /* Allocate the txdesc, waiting if necessary, allow interruptions */
ret = mac802154_txdesc_alloc(priv, &txdesc, true); ret = mac802154_txdesc_alloc(priv, &txdesc, true);
@@ -243,6 +245,16 @@ int mac802154_req_data(MACHANDLE mac,
return ret; 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->conf->handle = meta->msdu_handle;
txdesc->frame = frame; txdesc->frame = frame;
txdesc->frametype = IEEE802154_FRAME_DATA; txdesc->frametype = IEEE802154_FRAME_DATA;
@@ -269,7 +281,7 @@ int mac802154_req_data(MACHANDLE mac,
*/ */
ret = -ENOTSUP; ret = -ENOTSUP;
goto errout_with_sem; goto errout_with_txdesc;
} }
else else
{ {
@@ -306,7 +318,7 @@ int mac802154_req_data(MACHANDLE mac,
else else
{ {
ret = -EINVAL; ret = -EINVAL;
goto errout_with_sem; goto errout_with_txdesc;
} }
} }
else else
@@ -327,6 +339,9 @@ int mac802154_req_data(MACHANDLE mac,
return OK; return OK;
errout_with_txdesc:
/* REVISIT: Free TX descriptor, but preserve the IOB. */
errout_with_sem: errout_with_sem:
mac802154_givesem(&priv->exclsem); mac802154_givesem(&priv->exclsem);
return ret; return ret;