wireless/ieee802154: Restructuring of MAC notifications. Simplifes some interfaces

This commit is contained in:
Anthony Merlino
2017-05-15 21:44:51 -04:00
parent b10d2bbc8c
commit 06634afbe0
8 changed files with 1061 additions and 705 deletions
+17 -27
View File
@@ -107,13 +107,6 @@
* Private Types * Private Types
****************************************************************************/ ****************************************************************************/
struct mrf24j40_txdesc_s
{
struct ieee802154_txdesc_s pub;
uint8_t busy : 1; /* Is this txdesc being used */
};
/* A MRF24J40 device instance */ /* A MRF24J40 device instance */
struct mrf24j40_radio_s struct mrf24j40_radio_s
@@ -145,11 +138,13 @@ struct mrf24j40_radio_s
/* Buffer Allocations */ /* Buffer Allocations */
struct mrf24j40_txdesc_s csma_desc; struct ieee802154_txdesc_s *csma_desc;
FAR struct iob_s *csma_frame; FAR struct iob_s *csma_frame;
bool csma_busy;
struct mrf24j40_txdesc_s gts_desc[MRF24J40_GTS_SLOTS]; struct ieee802154_txdesc_s *gts_desc[MRF24J40_GTS_SLOTS];
FAR struct iob_s *gts_frame[MRF24J40_GTS_SLOTS]; FAR struct iob_s *gts_frame[MRF24J40_GTS_SLOTS];
bool gts_busy[MRF24J40_GTS_SLOTS];
}; };
/**************************************************************************** /****************************************************************************
@@ -189,7 +184,6 @@ static int mrf24j40_gts_setup(FAR struct mrf24j40_radio_s *dev, uint8_t gts,
static int mrf24j40_setup_fifo(FAR struct mrf24j40_radio_s *dev, static int mrf24j40_setup_fifo(FAR struct mrf24j40_radio_s *dev,
FAR struct iob_s *frame, uint32_t fifo_addr); FAR struct iob_s *frame, uint32_t fifo_addr);
static int mrf24j40_setchannel(FAR struct mrf24j40_radio_s *dev, static int mrf24j40_setchannel(FAR struct mrf24j40_radio_s *dev,
uint8_t chan); uint8_t chan);
static int mrf24j40_getchannel(FAR struct mrf24j40_radio_s *dev, static int mrf24j40_getchannel(FAR struct mrf24j40_radio_s *dev,
@@ -206,10 +200,6 @@ static int mrf24j40_seteaddr(FAR struct mrf24j40_radio_s *dev,
FAR const uint8_t *eaddr); FAR const uint8_t *eaddr);
static int mrf24j40_geteaddr(FAR struct mrf24j40_radio_s *dev, static int mrf24j40_geteaddr(FAR struct mrf24j40_radio_s *dev,
FAR uint8_t *eaddr); FAR uint8_t *eaddr);
static int mrf24j40_setpromisc(FAR struct mrf24j40_radio_s *dev,
bool promisc);
static int mrf24j40_getpromisc(FAR struct mrf24j40_radio_s *dev,
FAR bool *promisc);
static int mrf24j40_setdevmode(FAR struct mrf24j40_radio_s *dev, static int mrf24j40_setdevmode(FAR struct mrf24j40_radio_s *dev,
uint8_t mode); uint8_t mode);
static int mrf24j40_getdevmode(FAR struct mrf24j40_radio_s *dev, static int mrf24j40_getdevmode(FAR struct mrf24j40_radio_s *dev,
@@ -446,17 +436,17 @@ static void mrf24j40_dopoll_csma(FAR void *arg)
/* If this a CSMA transaction and we have room in the CSMA fifo */ /* If this a CSMA transaction and we have room in the CSMA fifo */
if (!dev->csma_desc.busy) if (!dev->csma_busy)
{ {
/* need to somehow allow for a handle to be passed */ /* need to somehow allow for a handle to be passed */
len = dev->radiocb->poll_csma(dev->radiocb, &dev->csma_desc.pub, len = dev->radiocb->poll_csma(dev->radiocb, &dev->csma_desc,
&dev->csma_frame); &dev->csma_frame);
if (len > 0) if (len > 0)
{ {
/* Now the txdesc is in use */ /* Now the txdesc is in use */
dev->csma_desc.busy = 1; dev->csma_busy = 1;
/* Setup the transaction on the device in the CSMA FIFO */ /* Setup the transaction on the device in the CSMA FIFO */
@@ -501,15 +491,15 @@ static void mrf24j40_dopoll_gts(FAR void *arg)
for (gts = 0; gts < MRF24J40_GTS_SLOTS; gts++) for (gts = 0; gts < MRF24J40_GTS_SLOTS; gts++)
{ {
if (!dev->gts_desc[gts].busy) if (!dev->gts_busy[gts])
{ {
len = dev->radiocb->poll_gts(dev->radiocb, &dev->gts_desc[gts].pub, len = dev->radiocb->poll_gts(dev->radiocb, &dev->gts_desc[gts],
&dev->gts_frame[0]); &dev->gts_frame[0]);
if (len > 0) if (len > 0)
{ {
/* Now the txdesc is in use */ /* Now the txdesc is in use */
dev->gts_desc[gts].busy = 1; dev->gts_busy[gts]= 1;
/* Setup the transaction on the device in the open GTS FIFO */ /* Setup the transaction on the device in the open GTS FIFO */
@@ -1406,15 +1396,15 @@ static void mrf24j40_irqwork_txnorm(FAR struct mrf24j40_radio_s *dev)
*/ */
txstat = mrf24j40_getreg(dev->spi, MRF24J40_TXSTAT); txstat = mrf24j40_getreg(dev->spi, MRF24J40_TXSTAT);
dev->csma_desc.pub.status = txstat & MRF24J40_TXSTAT_TXNSTAT; dev->csma_desc->conf->status = txstat & MRF24J40_TXSTAT_TXNSTAT;
/* Inform the next layer of the transmission success/failure */ /* Inform the next layer of the transmission success/failure */
dev->radiocb->txdone(dev->radiocb, &dev->csma_desc.pub); dev->radiocb->txdone(dev->radiocb, dev->csma_desc);
/* We are now done with the transaction */ /* We are now done with the transaction */
dev->csma_desc.busy = 0; dev->csma_busy = 0;
/* Free the IOB */ /* Free the IOB */
@@ -1451,20 +1441,20 @@ static void mrf24j40_irqwork_txgts(FAR struct mrf24j40_radio_s *dev,
if (gts == 0) if (gts == 0)
{ {
dev->csma_desc.pub.status = txstat & MRF24J40_TXSTAT_TXG1STAT; dev->csma_desc->conf->status = txstat & MRF24J40_TXSTAT_TXG1STAT;
} }
else if (gts == 1) else if (gts == 1)
{ {
dev->csma_desc.pub.status = txstat & MRF24J40_TXSTAT_TXG2STAT; dev->csma_desc->conf->status = txstat & MRF24J40_TXSTAT_TXG2STAT;
} }
/* Inform the next layer of the transmission success/failure */ /* Inform the next layer of the transmission success/failure */
dev->radiocb->txdone(dev->radiocb, &dev->gts_desc[gts].pub); dev->radiocb->txdone(dev->radiocb, dev->gts_desc[gts]);
/* We are now done with the transaction */ /* We are now done with the transaction */
dev->gts_desc[gts].busy = 0; dev->gts_busy[gts]= 0;
/* Free the IOB */ /* Free the IOB */
@@ -62,8 +62,9 @@
/* IEEE 802.15.4 MAC Character Driver IOCTL commands ********************************/ /* IEEE 802.15.4 MAC Character Driver IOCTL commands ********************************/
#define MAC802154IOC_MCPS_REGISTER _WLCIOC(IEEE802154_FIRST) #define MAC802154IOC_NOTIFY_REGISTER _WLCIOC(IEEE802154_FIRST)
#define MAC802154IOC_MLME_REGISTER _WLCIOC(IEEE802154_FIRST+1) #define MAC802154IOC_GET_EVENT _WLCIOC(IEEE802154_FIRST+1)
#define MAC802154IOC_ENABLE_EVENTS _WLCIOC(IEEE802154_FIRST+2)
/************************************************************************************ /************************************************************************************
* Public Types * Public Types
+133 -103
View File
@@ -102,31 +102,12 @@
/* IEEE 802.15.4 MAC Interface **********************************************/ /* IEEE 802.15.4 MAC Interface **********************************************/
/* Frame Type */
#define IEEE802154_FRAME_BEACON 0x00
#define IEEE802154_FRAME_DATA 0x01
#define IEEE802154_FRAME_ACK 0x02
#define IEEE802154_FRAME_COMMAND 0x03
/* MAC commands */
#define IEEE802154_CMD_ASSOC_REQ 0x01
#define IEEE802154_CMD_ASSOC_RESP 0x02
#define IEEE802154_CMD_DISASSOC_NOT 0x03
#define IEEE802154_CMD_DATA_REQ 0x04
#define IEEE802154_CMD_PANID_CONF_NOT 0x05
#define IEEE802154_CMD_ORPHAN_NOT 0x06
#define IEEE802154_CMD_BEACON_REQ 0x07
#define IEEE802154_CMD_COORD_REALIGN 0x08
#define IEEE802154_CMD_GTS_REQ 0x09
/* Some addresses */ /* Some addresses */
#define IEEE802154_PAN_UNSPEC (uint16_t)0xFFFF #define IEEE802154_PAN_UNSPEC (uint16_t)0xFFFF
#define IEEE802154_SADDR_UNSPEC (uint16_t)0xFFFF #define IEEE802154_SADDR_UNSPEC (uint16_t)0xFFFF
#define IEEE802154_SADDR_BCAST (uint16_t)0xFFFE #define IEEE802154_SADDR_BCAST (uint16_t)0xFFFE
#define IEEE802154_EADDR_UNSPEC (uint8_t*)"\xff\xff\xff\xff\xff\xff\xff\xff" #define IEEE802154_EADDR_UNSPEC (uint8_t[]){0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF}
/* Frame control field masks, 2 bytes /* Frame control field masks, 2 bytes
* Seee IEEE 802.15.4/2011 5.2.1.1 page 57 * Seee IEEE 802.15.4/2011 5.2.1.1 page 57
@@ -150,6 +131,22 @@
#define IEEE802154_FRAMECTRL_SHIFT_VERSION 12 /* Source addressing mode, bits 12-13 */ #define IEEE802154_FRAMECTRL_SHIFT_VERSION 12 /* Source addressing mode, bits 12-13 */
#define IEEE802154_FRAMECTRL_SHIFT_SADDR 14 /* Source addressing mode, bits 14-15 */ #define IEEE802154_FRAMECTRL_SHIFT_SADDR 14 /* Source addressing mode, bits 14-15 */
/* Capability Information Bitfield
*
*/
#define IEEE802154_CAPABILITY_DEVTYPE 0x02
#define IEEE802154_CAPABILITY_PWRSRC 0x04
#define IEEE802154_CAPABILITY_RXONIDLE 0x08
#define IEEE802154_CAPABILITY_SECURITY 0x40
#define IEEE802154_CAPABILITY_ALLOCADDR 0x80
#define IEEE802154_CAPABILITY_SHIFT_DEVTYPE 1
#define IEEE802154_CAPABILITY_SHIFT_PWRSRC 2
#define IEEE802154_CAPABILITY_SHIFT_RXONIDLE 3
#define IEEE802154_CAPABILITY_SHIFT_SECURITY 6
#define IEEE802154_CAPABILITY_SHIFT_ALLOCADDR 7
/* IEEE 802.15.4 PHY constants */ /* IEEE 802.15.4 PHY constants */
#define IEEE802154_MAX_PHY_PACKET_SIZE 127 #define IEEE802154_MAX_PHY_PACKET_SIZE 127
@@ -194,7 +191,6 @@
#define MAX_ORPHAN_ADDR 32 /* REVISIT */ #define MAX_ORPHAN_ADDR 32 /* REVISIT */
// TODO: Add macros
/**************************************************************************** /****************************************************************************
* Public Types * Public Types
@@ -329,6 +325,31 @@ enum ieee802154_pib_attr_e
IEEE802154_PIB_MAC_PANCOORD_SHORT_ADDR, IEEE802154_PIB_MAC_PANCOORD_SHORT_ADDR,
}; };
/* Frame Type */
enum ieee802154_frametype_e
{
IEEE802154_FRAME_BEACON = 0,
IEEE802154_FRAME_DATA,
IEEE802154_FRAME_ACK,
IEEE802154_FRAME_COMMAND
};
/* MAC command IDs */
enum ieee802154_cmdid_e
{
IEEE802154_CMD_ASSOC_REQ = 1,
IEEE802154_CMD_ASSOC_RESP,
IEEE802154_CMD_DISASSOC_NOT,
IEEE802154_CMD_DATA_REQ,
IEEE802154_CMD_PANID_CONF_NOT,
IEEE802154_CMD_ORPHAN_NOT,
IEEE802154_CMD_BEACON_REQ,
IEEE802154_CMD_COORD_REALIGN,
IEEE802154_CMD_GTS_REQ,
};
enum ieee802154_devmode_e enum ieee802154_devmode_e
{ {
IEEE802154_DEVMODE_ENDPOINT, IEEE802154_DEVMODE_ENDPOINT,
@@ -405,13 +426,13 @@ enum ieee802154_ranging_e
struct ieee802154_capability_info_s struct ieee802154_capability_info_s
{ {
uint8_t reserved_0 : 1; /* Reserved */ uint8_t reserved_0 : 1; /* Reserved */
uint8_t device_type : 1; /* 0=RFD, 1=FFD */ uint8_t devtype : 1; /* 0=RFD, 1=FFD */
uint8_t power_source : 1; /* 1=AC, 0=Other */ uint8_t powersource : 1; /* 1=AC, 0=Other */
uint8_t rx_on_idle : 1; /* 0=Receiver off when idle uint8_t rxonidle : 1; /* 0=Receiver off when idle
* 1=Receiver on when idle */ * 1=Receiver on when idle */
uint8_t reserved_45 : 2; /* Reserved */ uint8_t reserved_45 : 2; /* Reserved */
uint8_t security : 1; /* 0=disabled, 1=enabled */ uint8_t security : 1; /* 0=disabled, 1=enabled */
uint8_t allocate_addr : 1; /* 1=Coordinator allocates short address uint8_t allocaddr : 1; /* 1=Coordinator allocates short address
* 0=otherwise */ * 0=otherwise */
}; };
@@ -462,31 +483,6 @@ struct ieee802154_pend_addr_s
struct ieee802154_addr_s addr[7]; /* Array of at most 7 addresses */ struct ieee802154_addr_s addr[7]; /* Array of at most 7 addresses */
}; };
#ifdef CONFIG_IEEE802154_RANGING
#define IEEE802154_TXDESC_FIELDS \
uint8_t handle; \
uint32_t timestamp; \
uint8_t status;
#else
#define IEEE802154_TXDESC_FIELDS \
uint8_t handle; \
uint32_t timestamp; \
uint8_t status;
bool rng_rcvd; \
uint32_t rng_counter_start; \
uint32_t rng_counter_stop; \
uint32_t rng_tracking_interval; \
uint32_t rng_offset;\
uint8_t rng_fom;
#endif
struct ieee802154_txdesc_s
{
IEEE802154_TXDESC_FIELDS
/* TODO: Add slotting information for GTS transactions */
};
struct ieee802154_cca_s struct ieee802154_cca_s
{ {
uint8_t use_ed : 1; /* CCA using ED */ uint8_t use_ed : 1; /* CCA using ED */
@@ -631,7 +627,44 @@ struct ieee802154_frame_meta_s
struct ieee802154_data_conf_s struct ieee802154_data_conf_s
{ {
IEEE802154_TXDESC_FIELDS uint8_t handle; /* Handle assoc. with MSDU */
/* The time, in symbols, at which the data were transmitted */
uint32_t timestamp;
enum ieee802154_status_e status; /* The status of the MSDU transmission */
#ifdef CONFIG_IEEE802154_RANGING
bool rng_rcvd; /* Ranging indicated by MSDU */
/* A count of the time units corresponding to an RMARKER at the antenna at
* the beginning of the ranging exchange
*/
uint32_t rng_counter_start;
/* A count of the time units corresponding to an RMARKER at the antenna at
* end of the ranging exchange
*/
uint32_t rng_counter_stop;
/* A count of the time units in a message exchange over which the tracking
* offset was measured
*/
uint32_t rng_tracking_interval;
/* A count of the time units slipped or advanced by the radio tracking
* system over the course of the entire tracking interval
*/
uint32_t rng_offset;
/* The Figure of Merit (FoM) characterizing the ranging measurement */
uint8_t rng_fom;
#endif
}; };
/***************************************************************************** /*****************************************************************************
@@ -734,12 +767,12 @@ struct ieee802154_purge_req_s
struct ieee802154_assoc_req_s struct ieee802154_assoc_req_s
{ {
uint8_t channel; /* Channel number to attempt association */ uint8_t chnum; /* Channel number to attempt association */
uint8_t channel_page; /* Channel page to attempt association */ uint8_t chpage; /* Channel page to attempt association */
/* Coordinator Address with which to associate */ /* Coordinator Address with which to associate */
struct ieee802154_addr_s coord_addr; struct ieee802154_addr_s coordaddr;
/* Capabilities of associating device */ /* Capabilities of associating device */
@@ -1307,8 +1340,42 @@ struct ieee802154_poll_conf_s
enum ieee802154_status_e status; enum ieee802154_status_e status;
}; };
union ieee802154_mlme_notify_u /* MAC Service Notifications */
enum ieee802154_notify_e
{ {
/* MCPS Notifications */
IEEE802154_NOTIFY_CONF_DATA = 0x00,
/* MLME Notifications */
IEEE802154_NOTIFY_CONF_ASSOC,
IEEE802154_NOTIFY_CONF_DISASSOC,
IEEE802154_NOTIFY_CONF_GTS,
IEEE802154_NOTIFY_CONF_RESET,
IEEE802154_NOTIFY_CONF_RXENABLE,
IEEE802154_NOTIFY_CONF_SCAN,
IEEE802154_NOTIFY_CONF_START,
IEEE802154_NOTIFY_CONF_POLL,
IEEE802154_NOTIFY_IND_ASSOC,
IEEE802154_NOTIFY_IND_DISASSOC,
IEEE802154_NOTIFY_IND_BEACONNOTIFY,
IEEE802154_NOTIFY_IND_GTS,
IEEE802154_NOTIFY_IND_ORPHAN,
IEEE802154_NOTIFY_IND_COMMSTATUS,
IEEE802154_NOTIFY_IND_SYNCLOSS
};
union ieee802154_notif_u
{
/* MCPS Notifications */
struct ieee802154_data_conf_s dataconf;
/* MLME Notifications */
struct ieee802154_assoc_conf_s assocconf; struct ieee802154_assoc_conf_s assocconf;
struct ieee802154_disassoc_conf_s disassocconf; struct ieee802154_disassoc_conf_s disassocconf;
struct ieee802154_gts_conf_s gtsconf; struct ieee802154_gts_conf_s gtsconf;
@@ -1326,10 +1393,18 @@ union ieee802154_mlme_notify_u
struct ieee802154_syncloss_ind_s synclossind; struct ieee802154_syncloss_ind_s synclossind;
}; };
union ieee802154_mcps_notify_u struct ieee802154_notif_s
{ {
struct ieee802154_data_conf_s dataconf; /* Must be first member so that we can interchange between the actual
struct ieee802154_data_ind_s *dataind; *notification and this extended struct.
*/
union ieee802154_notif_u u;
enum ieee802154_notify_e notiftype;
/* Support a singly linked list */
FAR struct ieee802154_notif_s *flink;
}; };
/* A pointer to this structure is passed as the argument of each IOCTL /* A pointer to this structure is passed as the argument of each IOCTL
@@ -1376,51 +1451,6 @@ struct ieee802154_netmac_s
typedef FAR void *MACHANDLE; typedef FAR void *MACHANDLE;
/* MAC Service Notifications */
enum ieee802154_macnotify_e
{
/* MCPS Notifications */
IEEE802154_NOTIFY_CONF_DATA = 0x00,
IEEE802154_NOTIFY_IND_DATA,
/* MLME Notifications */
IEEE802154_NOTIFY_CONF_ASSOC,
IEEE802154_NOTIFY_CONF_DISASSOC,
IEEE802154_NOTIFY_CONF_GTS,
IEEE802154_NOTIFY_CONF_RESET,
IEEE802154_NOTIFY_CONF_RXENABLE,
IEEE802154_NOTIFY_CONF_SCAN,
IEEE802154_NOTIFY_CONF_START,
IEEE802154_NOTIFY_CONF_POLL,
IEEE802154_NOTIFY_IND_ASSOC,
IEEE802154_NOTIFY_IND_DISASSOC,
IEEE802154_NOTIFY_IND_BEACONNOTIFY,
IEEE802154_NOTIFY_IND_GTS,
IEEE802154_NOTIFY_IND_ORPHAN,
IEEE802154_NOTIFY_IND_COMMSTATUS,
IEEE802154_NOTIFY_IND_SYNCLOSS
};
/* 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 ieee802154_maccb_s
{
CODE void (*mlme_notify)(FAR const struct ieee802154_maccb_s *maccb,
enum ieee802154_macnotify_e notif,
FAR const union ieee802154_mlme_notify_u *arg);
CODE void (*mcps_notify)(FAR const struct ieee802154_maccb_s *maccb,
enum ieee802154_macnotify_e notif,
FAR const union ieee802154_mcps_notify_u *arg);
};
#ifdef __cplusplus #ifdef __cplusplus
#define EXTERN extern "C" #define EXTERN extern "C"
extern "C" extern "C"
@@ -58,15 +58,35 @@
* Public Types * Public Types
****************************************************************************/ ****************************************************************************/
/* Data only used between radio and MAC layer */
struct ieee802154_txdesc_s
{
/* Support a singly linked list of tx descriptors */
FAR struct ieee802154_txdesc_s *flink;
/* Pointer to the data confirmation structure to be populated upon
* success/failure of the transmission.
*/
FAR struct ieee802154_data_conf_s *conf;
enum ieee802154_frametype_e frametype; /* Frame type. Used by MAC layer to
* control how tx done is handled */
/* TODO: Add slotting information for GTS transactions */
};
/* IEEE802.15.4 Radio Interface Operations **********************************/ /* IEEE802.15.4 Radio Interface Operations **********************************/
struct ieee802154_radiocb_s struct ieee802154_radiocb_s
{ {
CODE int (*poll_csma) (FAR const struct ieee802154_radiocb_s *radiocb, CODE int (*poll_csma) (FAR const struct ieee802154_radiocb_s *radiocb,
FAR struct ieee802154_txdesc_s *tx_desc, FAR struct ieee802154_txdesc_s **tx_desc,
FAR struct iob_s **frame); FAR struct iob_s **frame);
CODE int (*poll_gts) (FAR const struct ieee802154_radiocb_s *radiocb, CODE int (*poll_gts) (FAR const struct ieee802154_radiocb_s *radiocb,
FAR struct ieee802154_txdesc_s *tx_desc, FAR struct ieee802154_txdesc_s **tx_desc,
FAR struct iob_s **frame); FAR struct iob_s **frame);
CODE void (*txdone) (FAR const struct ieee802154_radiocb_s *radiocb, CODE void (*txdone) (FAR const struct ieee802154_radiocb_s *radiocb,
FAR const struct ieee802154_txdesc_s *tx_desc); FAR const struct ieee802154_txdesc_s *tx_desc);
File diff suppressed because it is too large Load Diff
+44 -12
View File
@@ -54,6 +54,26 @@
#include <nuttx/wireless/ieee802154/ieee802154_mac.h> #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 * 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 * 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 * 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. * (i.e., MSDU) from a local SSCS entity to a single peer SSCS entity.
* Confirmation is returned via the * 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: * Description:
* The MCPS-PURGE.request primitive allows the next higher layer to purge * The MCPS-PURGE.request primitive allows the next higher layer to purge
* an MSDU from the transaction queue. Confirmation is returned via * 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 * NOTE: The standard specifies that confirmation should be indicated via
* the asynchronous MLME-PURGE.confirm primitve. However, in our * the asynchronous MLME-PURGE.confirm primitve. However, in our
@@ -149,7 +169,7 @@ int mac802154_req_purge(MACHANDLE mac, uint8_t msdu_handle);
* Description: * Description:
* The MLME-ASSOCIATE.request primitive allows a device to request an * The MLME-ASSOCIATE.request primitive allows a device to request an
* association with a coordinator. Confirmation is returned via the * 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. * PAN.
* *
* Confirmation is returned via the * 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 * 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. * PAN coordinator to allocate a new GTS or to deallocate an existing GTS.
* Confirmation is returned via the * 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 * The MLME-RX-ENABLE.request primitive allows the next higher layer to
* request that the receiver is enable for a finite period of time. * request that the receiver is enable for a finite period of time.
* Confirmation is returned via the * 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 * the energy on the channel, search for the coordinator with which it
* associated, or search for all coordinators transmitting beacon frames * associated, or search for all coordinators transmitting beacon frames
* within the POS of the scanning device. Scan results are returned * 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 * callback. This is a difference with the official 802.15.4
* specification, implemented here to save memory. * specification, implemented here to save memory.
* *
@@ -280,7 +300,7 @@ int mac802154_req_set(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr,
* Description: * Description:
* The MLME-START.request primitive makes a request for the device to * The MLME-START.request primitive makes a request for the device to
* start using a new superframe configuration. Confirmation is returned * 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 * The MLME-SYNC.request primitive requests to synchronize with the
* coordinator by acquiring and, if specified, tracking its beacons. * coordinator by acquiring and, if specified, tracking its beacons.
* Confirmation is returned via the * 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: * Description:
* The MLME-POLL.request primitive prompts the device to request data from * The MLME-POLL.request primitive prompts the device to request data from
* the coordinator. Confirmation is returned via the * the coordinator. Confirmation is returned via the
* struct ieee802154_maccb_s->conf_poll callback, followed by a * struct mac802154_maccb_s->conf_poll callback, followed by a
* struct ieee802154_maccb_s->ind_data callback. * struct mac802154_maccb_s->ind_data callback.
* *
****************************************************************************/ ****************************************************************************/
@@ -336,6 +356,18 @@ int mac802154_resp_associate(MACHANDLE mac,
int mac802154_resp_orphan(MACHANDLE mac, int mac802154_resp_orphan(MACHANDLE mac,
FAR struct ieee802154_orphan_resp_s *resp); 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 #undef EXTERN
#ifdef __cplusplus #ifdef __cplusplus
File diff suppressed because it is too large Load Diff
+35 -67
View File
@@ -109,7 +109,7 @@ struct macnet_callback_s
{ {
/* This holds the information visible to the MAC layer */ /* 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 */ FAR struct macnet_driver_s *mc_priv; /* Our priv data */
}; };
@@ -138,12 +138,10 @@ struct macnet_driver_s
/* IEE802.15.4 MAC callback functions ***************************************/ /* IEE802.15.4 MAC callback functions ***************************************/
static void macnet_mlme_notify(FAR const struct ieee802154_maccb_s *maccb, static void macnet_notify(FAR const struct mac802154_maccb_s *maccb,
enum ieee802154_macnotify_e notif, FAR struct ieee802154_notif_s *notif);
FAR const union ieee802154_mlme_notify_u *arg); static void macnet_rxframe(FAR const struct mac802154_maccb_s *maccb,
static void macnet_mcps_notify(FAR const struct ieee802154_maccb_s *maccb, FAR struct ieee802154_data_ind_s *ind);
enum ieee802154_macnotify_e notif,
FAR const union ieee802154_mcps_notify_u *arg);
/* Asynchronous confirmations to requests */ /* 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 */ /* 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, static void macnet_ind_associate(FAR struct macnet_driver_s *priv,
FAR struct ieee802154_assoc_ind_s *conf); FAR struct ieee802154_assoc_ind_s *conf);
static void macnet_ind_disassociate(FAR struct macnet_driver_s *priv, 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: * Description:
* *
****************************************************************************/ ****************************************************************************/
static void macnet_mlme_notify(FAR const struct ieee802154_maccb_s *maccb, static void macnet_notify(FAR const struct mac802154_maccb_s *maccb,
enum ieee802154_macnotify_e notif, FAR struct ieee802154_notif_s *notif)
FAR const union ieee802154_mlme_notify_u *arg)
{ {
FAR struct macnet_callback_s *cb = FAR struct macnet_callback_s *cb =
(FAR struct macnet_callback_s *)maccb; (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); DEBUGASSERT(cb != NULL && cb->mc_priv != NULL);
priv = cb->mc_priv; priv = cb->mc_priv;
switch (notif) switch (notif->notiftype)
{ {
case IEEE802154_NOTIFY_CONF_DATA:
{
macnet_conf_data(priv, &notif->u.dataconf);
}
break;
default: default:
break; 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: * Description:
* *
****************************************************************************/ ****************************************************************************/
static void macnet_mcps_notify(FAR const struct ieee802154_maccb_s *maccb, static void macnet_rxframe(FAR const struct mac802154_maccb_s *maccb,
enum ieee802154_macnotify_e notif, FAR struct ieee802154_data_ind_s *ind)
FAR const union ieee802154_mcps_notify_u *arg)
{ {
FAR struct macnet_callback_s *cb = FAR struct macnet_callback_s *cb =
(FAR struct macnet_callback_s *)maccb; (FAR struct macnet_callback_s *)maccb;
FAR struct macnet_driver_s *priv; FAR struct macnet_driver_s *priv;
FAR struct iob_s *iob;
DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); DEBUGASSERT(cb != NULL && cb->mc_priv != NULL);
priv = cb->mc_priv; priv = cb->mc_priv;
switch (notif) /* Extract the IOB containing the frame from the struct ieee802154_data_ind_s */
{
case IEEE802154_NOTIFY_CONF_DATA:
{
macnet_conf_data(priv, &arg->dataconf);
}
break;
case IEEE802154_NOTIFY_IND_DATA: DEBUGASSERT(priv != NULL && ind != NULL && ind->frame != NULL);
{ iob = ind->frame;
macnet_ind_data(priv, arg->dataind); ind->frame = NULL;
}
break;
default: /* Transfer the frame to the network logic */
break;
} 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 * Name: macnet_ind_associate
* *
@@ -1041,7 +1009,7 @@ int mac802154netdev_register(MACHANDLE mac)
FAR struct macnet_driver_s *priv; FAR struct macnet_driver_s *priv;
FAR struct ieee802154_driver_s *ieee; FAR struct ieee802154_driver_s *ieee;
FAR struct net_driver_s *dev; FAR struct net_driver_s *dev;
FAR struct ieee802154_maccb_s *maccb; FAR struct mac802154_maccb_s *maccb;
FAR uint8_t *pktbuf; FAR uint8_t *pktbuf;
int ret; int ret;
@@ -1103,9 +1071,9 @@ int mac802154netdev_register(MACHANDLE mac)
priv->md_cb.mc_priv = priv; priv->md_cb.mc_priv = priv;
maccb = &priv->md_cb.mc_cb; maccb = &priv->md_cb.mc_cb;
maccb->mlme_notify = macnet_mlme_notify; maccb->notify = macnet_notify;
maccb->mcps_notify = macnet_mcps_notify; maccb->rxframe = macnet_rxframe;
/* Bind the callback structure */ /* Bind the callback structure */