mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 23:03:27 +08:00
wireless/ieee802154: Restructuring of MAC notifications. Simplifes some interfaces
This commit is contained in:
+583
-212
File diff suppressed because it is too large
Load Diff
@@ -54,6 +54,26 @@
|
||||
|
||||
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data Types
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
|
||||
/* Callback operations to notify the next highest layer of various asynchronous
|
||||
* events, usually triggered by some previous request or response invoked by the
|
||||
* upper layer.
|
||||
*/
|
||||
|
||||
struct mac802154_maccb_s
|
||||
{
|
||||
CODE void (*notify)(FAR const struct mac802154_maccb_s *maccb,
|
||||
FAR struct ieee802154_notif_s *notif);
|
||||
|
||||
CODE void (*rxframe)(FAR const struct mac802154_maccb_s *maccb,
|
||||
FAR struct ieee802154_data_ind_s *ind);
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
@@ -75,7 +95,7 @@ struct iob_s; /* Forward reference */
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mac802154_bind(MACHANDLE mac, FAR const struct ieee802154_maccb_s *cb);
|
||||
int mac802154_bind(MACHANDLE mac, FAR const struct mac802154_maccb_s *cb);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_ioctl
|
||||
@@ -117,7 +137,7 @@ int mac802154_get_mhrlen(MACHANDLE mac,
|
||||
* The MCPS-DATA.request primitive requests the transfer of a data SPDU
|
||||
* (i.e., MSDU) from a local SSCS entity to a single peer SSCS entity.
|
||||
* Confirmation is returned via the
|
||||
* struct ieee802154_maccb_s->conf_data callback.
|
||||
* struct mac802154_maccb_s->conf_data callback.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -131,7 +151,7 @@ int mac802154_req_data(MACHANDLE mac,
|
||||
* Description:
|
||||
* The MCPS-PURGE.request primitive allows the next higher layer to purge
|
||||
* an MSDU from the transaction queue. Confirmation is returned via
|
||||
* the struct ieee802154_maccb_s->conf_purge callback.
|
||||
* the struct mac802154_maccb_s->conf_purge callback.
|
||||
*
|
||||
* NOTE: The standard specifies that confirmation should be indicated via
|
||||
* the asynchronous MLME-PURGE.confirm primitve. However, in our
|
||||
@@ -149,7 +169,7 @@ int mac802154_req_purge(MACHANDLE mac, uint8_t msdu_handle);
|
||||
* Description:
|
||||
* The MLME-ASSOCIATE.request primitive allows a device to request an
|
||||
* association with a coordinator. Confirmation is returned via the
|
||||
* struct ieee802154_maccb_s->conf_associate callback.
|
||||
* struct mac802154_maccb_s->conf_associate callback.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -166,7 +186,7 @@ int mac802154_req_associate(MACHANDLE mac,
|
||||
* PAN.
|
||||
*
|
||||
* Confirmation is returned via the
|
||||
* struct ieee802154_maccb_s->conf_disassociate callback.
|
||||
* struct mac802154_maccb_s->conf_disassociate callback.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -180,7 +200,7 @@ int mac802154_req_disassociate(MACHANDLE mac,
|
||||
* The MLME-GTS.request primitive allows a device to send a request to the
|
||||
* PAN coordinator to allocate a new GTS or to deallocate an existing GTS.
|
||||
* Confirmation is returned via the
|
||||
* struct ieee802154_maccb_s->conf_gts callback.
|
||||
* struct mac802154_maccb_s->conf_gts callback.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -214,7 +234,7 @@ int mac802154_req_reset(MACHANDLE mac, bool rst_pibattr);
|
||||
* The MLME-RX-ENABLE.request primitive allows the next higher layer to
|
||||
* request that the receiver is enable for a finite period of time.
|
||||
* Confirmation is returned via the
|
||||
* struct ieee802154_maccb_s->conf_rxenable callback.
|
||||
* struct mac802154_maccb_s->conf_rxenable callback.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -230,7 +250,7 @@ int mac802154_req_rxenable(MACHANDLE mac,
|
||||
* the energy on the channel, search for the coordinator with which it
|
||||
* associated, or search for all coordinators transmitting beacon frames
|
||||
* within the POS of the scanning device. Scan results are returned
|
||||
* via MULTIPLE calls to the struct ieee802154_maccb_s->conf_scan
|
||||
* via MULTIPLE calls to the struct mac802154_maccb_s->conf_scan
|
||||
* callback. This is a difference with the official 802.15.4
|
||||
* specification, implemented here to save memory.
|
||||
*
|
||||
@@ -280,7 +300,7 @@ int mac802154_req_set(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr,
|
||||
* Description:
|
||||
* The MLME-START.request primitive makes a request for the device to
|
||||
* start using a new superframe configuration. Confirmation is returned
|
||||
* via the struct ieee802154_maccb_s->conf_start callback.
|
||||
* via the struct mac802154_maccb_s->conf_start callback.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -293,7 +313,7 @@ int mac802154_req_start(MACHANDLE mac, FAR struct ieee802154_start_req_s *req);
|
||||
* The MLME-SYNC.request primitive requests to synchronize with the
|
||||
* coordinator by acquiring and, if specified, tracking its beacons.
|
||||
* Confirmation is returned via the
|
||||
* struct ieee802154_maccb_s->int_commstatus callback. TOCHECK.
|
||||
* struct mac802154_maccb_s->int_commstatus callback. TOCHECK.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -305,8 +325,8 @@ int mac802154_req_sync(MACHANDLE mac, FAR struct ieee802154_sync_req_s *req);
|
||||
* Description:
|
||||
* The MLME-POLL.request primitive prompts the device to request data from
|
||||
* the coordinator. Confirmation is returned via the
|
||||
* struct ieee802154_maccb_s->conf_poll callback, followed by a
|
||||
* struct ieee802154_maccb_s->ind_data callback.
|
||||
* struct mac802154_maccb_s->conf_poll callback, followed by a
|
||||
* struct mac802154_maccb_s->ind_data callback.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -336,6 +356,18 @@ int mac802154_resp_associate(MACHANDLE mac,
|
||||
int mac802154_resp_orphan(MACHANDLE mac,
|
||||
FAR struct ieee802154_orphan_resp_s *resp);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: mac802154_notif_free
|
||||
*
|
||||
* Description:
|
||||
* When the MAC calls the registered callback, it passes a reference
|
||||
* to a mac802154_notify_s structure. This structure needs to be freed
|
||||
* after the callback handler is done using it.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int mac802154_notif_free(MACHANDLE mac,
|
||||
FAR struct ieee802154_notif_s *notif);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -109,7 +109,7 @@ struct macnet_callback_s
|
||||
{
|
||||
/* This holds the information visible to the MAC layer */
|
||||
|
||||
struct ieee802154_maccb_s mc_cb; /* Interface understood by the MAC layer */
|
||||
struct mac802154_maccb_s mc_cb; /* Interface understood by the MAC layer */
|
||||
FAR struct macnet_driver_s *mc_priv; /* Our priv data */
|
||||
};
|
||||
|
||||
@@ -138,12 +138,10 @@ struct macnet_driver_s
|
||||
|
||||
/* IEE802.15.4 MAC callback functions ***************************************/
|
||||
|
||||
static void macnet_mlme_notify(FAR const struct ieee802154_maccb_s *maccb,
|
||||
enum ieee802154_macnotify_e notif,
|
||||
FAR const union ieee802154_mlme_notify_u *arg);
|
||||
static void macnet_mcps_notify(FAR const struct ieee802154_maccb_s *maccb,
|
||||
enum ieee802154_macnotify_e notif,
|
||||
FAR const union ieee802154_mcps_notify_u *arg);
|
||||
static void macnet_notify(FAR const struct mac802154_maccb_s *maccb,
|
||||
FAR struct ieee802154_notif_s *notif);
|
||||
static void macnet_rxframe(FAR const struct mac802154_maccb_s *maccb,
|
||||
FAR struct ieee802154_data_ind_s *ind);
|
||||
|
||||
/* Asynchronous confirmations to requests */
|
||||
|
||||
@@ -166,8 +164,6 @@ static void macnet_conf_poll(FAR struct macnet_driver_s *priv,
|
||||
|
||||
/* Asynchronous event indications, replied to synchronously with responses */
|
||||
|
||||
static void macnet_ind_data(FAR struct macnet_driver_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *conf);
|
||||
static void macnet_ind_associate(FAR struct macnet_driver_s *priv,
|
||||
FAR struct ieee802154_assoc_ind_s *conf);
|
||||
static void macnet_ind_disassociate(FAR struct macnet_driver_s *priv,
|
||||
@@ -221,15 +217,14 @@ static int macnet_req_data(FAR struct ieee802154_driver_s *netdev,
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: macnet_mlme_notify
|
||||
* Name: macnet_notify
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void macnet_mlme_notify(FAR const struct ieee802154_maccb_s *maccb,
|
||||
enum ieee802154_macnotify_e notif,
|
||||
FAR const union ieee802154_mlme_notify_u *arg)
|
||||
static void macnet_notify(FAR const struct mac802154_maccb_s *maccb,
|
||||
FAR struct ieee802154_notif_s *notif)
|
||||
{
|
||||
FAR struct macnet_callback_s *cb =
|
||||
(FAR struct macnet_callback_s *)maccb;
|
||||
@@ -238,8 +233,13 @@ static void macnet_mlme_notify(FAR const struct ieee802154_maccb_s *maccb,
|
||||
DEBUGASSERT(cb != NULL && cb->mc_priv != NULL);
|
||||
priv = cb->mc_priv;
|
||||
|
||||
switch (notif)
|
||||
switch (notif->notiftype)
|
||||
{
|
||||
case IEEE802154_NOTIFY_CONF_DATA:
|
||||
{
|
||||
macnet_conf_data(priv, ¬if->u.dataconf);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -247,40 +247,38 @@ static void macnet_mlme_notify(FAR const struct ieee802154_maccb_s *maccb,
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: macnet_mcps_notify
|
||||
* Name: macnet_rxframe
|
||||
*
|
||||
* Description:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void macnet_mcps_notify(FAR const struct ieee802154_maccb_s *maccb,
|
||||
enum ieee802154_macnotify_e notif,
|
||||
FAR const union ieee802154_mcps_notify_u *arg)
|
||||
static void macnet_rxframe(FAR const struct mac802154_maccb_s *maccb,
|
||||
FAR struct ieee802154_data_ind_s *ind)
|
||||
{
|
||||
FAR struct macnet_callback_s *cb =
|
||||
(FAR struct macnet_callback_s *)maccb;
|
||||
FAR struct macnet_driver_s *priv;
|
||||
FAR struct iob_s *iob;
|
||||
|
||||
DEBUGASSERT(cb != NULL && cb->mc_priv != NULL);
|
||||
priv = cb->mc_priv;
|
||||
|
||||
switch (notif)
|
||||
{
|
||||
case IEEE802154_NOTIFY_CONF_DATA:
|
||||
{
|
||||
macnet_conf_data(priv, &arg->dataconf);
|
||||
}
|
||||
break;
|
||||
/* Extract the IOB containing the frame from the struct ieee802154_data_ind_s */
|
||||
|
||||
case IEEE802154_NOTIFY_IND_DATA:
|
||||
{
|
||||
macnet_ind_data(priv, arg->dataind);
|
||||
}
|
||||
break;
|
||||
DEBUGASSERT(priv != NULL && ind != NULL && ind->frame != NULL);
|
||||
iob = ind->frame;
|
||||
ind->frame = NULL;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
/* Transfer the frame to the network logic */
|
||||
|
||||
sixlowpan_input(&priv->md_dev, iob, ind);
|
||||
|
||||
/* sixlowpan_input() will free the IOB, but we must free the struct
|
||||
* ieee802154_data_ind_s container here.
|
||||
*/
|
||||
|
||||
ieee802154_ind_free(ind);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -391,36 +389,6 @@ static void macnet_conf_poll(FAR struct macnet_driver_s *priv,
|
||||
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: macnet_ind_data
|
||||
*
|
||||
* Description:
|
||||
* Data frame received
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void macnet_ind_data(FAR struct macnet_driver_s *priv,
|
||||
FAR struct ieee802154_data_ind_s *ind)
|
||||
{
|
||||
FAR struct iob_s *iob;
|
||||
|
||||
/* Extract the IOB containing the frame from the struct ieee802154_data_ind_s */
|
||||
|
||||
DEBUGASSERT(priv != NULL && ind != NULL && ind->frame != NULL);
|
||||
iob = ind->frame;
|
||||
ind->frame = NULL;
|
||||
|
||||
/* Transfer the frame to the network logic */
|
||||
|
||||
sixlowpan_input(&priv->md_dev, iob, ind);
|
||||
|
||||
/* sixlowpan_input() will free the IOB, but we must free the struct
|
||||
* ieee802154_data_ind_s container here.
|
||||
*/
|
||||
|
||||
ieee802154_ind_free(ind);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Name: macnet_ind_associate
|
||||
*
|
||||
@@ -1041,7 +1009,7 @@ int mac802154netdev_register(MACHANDLE mac)
|
||||
FAR struct macnet_driver_s *priv;
|
||||
FAR struct ieee802154_driver_s *ieee;
|
||||
FAR struct net_driver_s *dev;
|
||||
FAR struct ieee802154_maccb_s *maccb;
|
||||
FAR struct mac802154_maccb_s *maccb;
|
||||
FAR uint8_t *pktbuf;
|
||||
int ret;
|
||||
|
||||
@@ -1103,9 +1071,9 @@ int mac802154netdev_register(MACHANDLE mac)
|
||||
|
||||
priv->md_cb.mc_priv = priv;
|
||||
|
||||
maccb = &priv->md_cb.mc_cb;
|
||||
maccb->mlme_notify = macnet_mlme_notify;
|
||||
maccb->mcps_notify = macnet_mcps_notify;
|
||||
maccb = &priv->md_cb.mc_cb;
|
||||
maccb->notify = macnet_notify;
|
||||
maccb->rxframe = macnet_rxframe;
|
||||
|
||||
/* Bind the callback structure */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user