diff --git a/wireless/ieee802154/mac802154.c b/wireless/ieee802154/mac802154.c index f05489947f8..dbfb79654a5 100644 --- a/wireless/ieee802154/mac802154.c +++ b/wireless/ieee802154/mac802154.c @@ -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); } } diff --git a/wireless/ieee802154/mac802154_assoc.c b/wireless/ieee802154/mac802154_assoc.c index 9f71db29c8d..1adf0aecd1a 100644 --- a/wireless/ieee802154/mac802154_assoc.c +++ b/wireless/ieee802154/mac802154_assoc.c @@ -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)); +} \ No newline at end of file diff --git a/wireless/ieee802154/mac802154_internal.h b/wireless/ieee802154/mac802154_internal.h index d2b2ecf7068..11929a27519 100644 --- a/wireless/ieee802154/mac802154_internal.h +++ b/wireless/ieee802154/mac802154_internal.h @@ -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; diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index 98eea0d0e23..c3becd7378c 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -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 */