Merged in antmerlino/nuttx/mac802154-assoc-lpwork (pull request #1004)

mac802154: Defers handling of extracting association response to LPWORK queue.

Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
Anthony Merlino 2019-08-19 15:17:01 +00:00 committed by Gregory Nutt
parent d42fc094fa
commit 66d66b0616
4 changed files with 45 additions and 15 deletions

View File

@ -878,9 +878,9 @@ static void mac802154_txdone(FAR const struct ieee802154_radiocb_s *radiocb,
/* Schedule work with the work queue to process the completion further */
if (work_available(&priv->tx_work))
if (work_available(&priv->txdone_work))
{
work_queue(HPWORK, &priv->tx_work, mac802154_txdone_worker,
work_queue(HPWORK, &priv->txdone_work, mac802154_txdone_worker,
(FAR void *)priv, 0);
}
}

View File

@ -59,6 +59,7 @@
****************************************************************************/
static void mac802154_assoctimeout(FAR void *arg);
static void mac802154_extract_assocresp(FAR void *arg);
/****************************************************************************
* Public MAC Functions
@ -553,19 +554,13 @@ void mac802154_txdone_assocreq(FAR struct ieee802154_privmac_s *priv,
DEBUGASSERT(priv->pandesc.coordaddr.mode !=
IEEE802154_ADDRMODE_NONE);
/* Send the Data Request MAC command after macResponseWaitTime to
* extract the data from the coordinator.
/* Off-load extracting the Association Response to the work queue to
* avoid locking up the calling thread.
*/
mac802154_txdesc_alloc(priv, &respdesc, false);
mac802154_createdatareq(priv, &priv->pandesc.coordaddr,
IEEE802154_ADDRMODE_EXTENDED, respdesc);
priv->curr_cmd = IEEE802154_CMD_DATA_REQ;
priv->radio->txdelayed(priv->radio, respdesc,
(priv->resp_waittime*IEEE802154_BASE_SUPERFRAME_DURATION));
DEBUGASSERT(work_available(&priv->macop_work));
work_queue(LPWORK, &priv->macop_work, mac802154_extract_assocresp,
priv, 0);
}
/* Deallocate the data conf notification as it is no longer needed. */
@ -904,3 +899,36 @@ static void mac802154_assoctimeout(FAR void *arg)
mac802154_notify(priv, primitive);
mac802154_unlock(priv)
}
/****************************************************************************
* Name: mac802154_extract_assocrespj
*
* Description:
* Create and send a Data request command to extract the Association response
* from the Coordinator.
*
* Assumptions:
* Called with the MAC unlocked.
*
****************************************************************************/
static void mac802154_extract_assocresp(FAR void *arg)
{
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)arg;
FAR struct ieee802154_txdesc_s *respdesc;
mac802154_lock(priv, false);
mac802154_txdesc_alloc(priv, &respdesc, false);
mac802154_createdatareq(priv, &priv->pandesc.coordaddr,
IEEE802154_ADDRMODE_EXTENDED, respdesc);
mac802154_unlock(priv)
priv->curr_cmd = IEEE802154_CMD_DATA_REQ;
priv->radio->txdelayed(priv->radio, respdesc,
(priv->resp_waittime*IEEE802154_BASE_SUPERFRAME_DURATION));
}

View File

@ -147,6 +147,7 @@ struct ieee802154_privmac_s
enum ieee802154_cmdid_e curr_cmd; /* Type of the current cmd */
FAR struct ieee802154_txdesc_s *cmd_desc; /* TX descriptor for current cmd */
uint8_t nrxusers;
struct work_s macop_work;
/******************* Fields related to SCAN operation ***********************/
@ -223,7 +224,7 @@ struct ieee802154_privmac_s
/* Work structures for offloading aynchronous work */
struct work_s tx_work;
struct work_s txdone_work;
struct work_s rx_work;
struct work_s purge_work;
struct work_s timer_work;

View File

@ -115,7 +115,8 @@
#endif
#if (CONFIG_MAC802154_NTXDESC < CONFIG_IOB_NBUFFERS)
# warning "CONFIG_MAC802154_NTXDES should probably be equal to CONFIG_IOB_NBUFFERS to avoid waiting on req_data"
# warning "CONFIG_MAC802154_NTXDESC should probably be equal to" \
"CONFIG_IOB_NBUFFERS to avoid waiting on req_data"
#endif
/* TX poll delay = 1 seconds. CLK_TCK is the number of clock ticks per second */