Merge branch 'ieee802154' of bitbucket.org:nuttx/nuttx into ieee802154

This commit is contained in:
Gregory Nutt 2017-05-04 17:17:15 -06:00
commit 9d9fbcb6dc
5 changed files with 135 additions and 149 deletions

View File

@ -48,6 +48,8 @@
#include <nuttx/config.h>
#include <nuttx/wireless/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
#ifdef CONFIG_WIRELESS_IEEE802154
/************************************************************************************
@ -74,7 +76,7 @@ struct mac802154dev_notify_s
struct mac802154dev_txframe_s
{
FAR struct ieee802154_frame_meta_s *meta;
struct ieee802154_frame_meta_s meta;
FAR uint8_t *payload;
};

View File

@ -462,17 +462,17 @@ union ieee802154_attr_val_u
uint8_t coord_eaddr[8];
uint16_t coord_saddr;
uint8_t is_assoc : 1;
uint8_t assoc_permit : 1;
uint8_t auto_req : 1;
uint8_t batt_life_ext : 1;
uint8_t gts_permit : 1;
uint8_t promisc_mode : 1;
uint8_t rng_support : 1;
uint8_t resp_wait_time;
uint8_t rx_when_idle : 1;
uint8_t sec_enabled : 1;
uint8_t timestamp_support : 1;
bool is_assoc;
bool assoc_permit;
bool auto_req;
bool batt_life_ext;
bool gts_permit;
bool promisc_mode;
bool rng_support;
bool resp_wait_time;
bool rx_when_idle;
bool sec_enabled;
bool timestamp_support;
uint32_t ack_wait_dur;
uint8_t batt_life_ext_periods;
@ -567,20 +567,6 @@ struct ieee802154_frame_meta_s
/* Primitive Semantics *******************************************************/
/*****************************************************************************
* Primitive: MCPS-DATA.request
*
* Description:
* Requests the transfer of data to another device.
*
*****************************************************************************/
struct ieee802154_data_req_s
{
FAR const struct ieee802154_frame_meta_s *meta; /* Metadata describing the req */
FAR struct iob_s *frame; /* Frame IOB with payload */
};
/*****************************************************************************
* Primitive: MCPS-DATA.confirm
*
@ -658,21 +644,6 @@ struct ieee802154_purge_req_s
uint8_t msdu_handle; /* Handle assoc. with MSDU */
};
/*****************************************************************************
* Primitive: MCPS-PURGE.confirm
*
* Description:
* Allows the MAC sublayer to notify the next higher layer of the success of
* its request to purge an MSDU from the transaction queue.
*
*****************************************************************************/
struct ieee802154_purge_conf_s
{
uint8_t msdu_handle; /* Handle assoc. with MSDU */
enum ieee802154_status_e status; /* The status of the MSDU transmission */
};
/*****************************************************************************
* Primitive: MLME-ASSOCIATE.request
*
@ -921,21 +892,7 @@ struct ieee802154_commstatus_ind_s
struct ieee802154_get_req_s
{
enum ieee802154_pib_attr_e pib_attr;
};
/*****************************************************************************
* Primitive: MLME-GET.confirm
*
* Description:
* Reports the results of an information request from the PIB.
*
*****************************************************************************/
struct ieee802154_get_conf_s
{
enum ieee802154_status_e status;
enum ieee802154_pib_attr_e pib_attr;
union ieee802154_attr_val_u attr_value;
FAR union ieee802154_attr_val_u *attr_value;
};
/*****************************************************************************
@ -1049,19 +1006,6 @@ struct ieee802154_reset_req_s
bool rst_pibattr;
};
/*****************************************************************************
* Primitive: MLME-RESET.confirm
*
* Description:
* Reports the results of the reset operation.
*
*****************************************************************************/
struct ieee802154_reset_conf_s
{
enum ieee802154_status_e status;
};
/*****************************************************************************
* Primitive: MLME-RXENABLE.request
*
@ -1287,9 +1231,7 @@ union ieee802154_mlme_notify_u
{
struct ieee802154_assoc_conf_s assocconf;
struct ieee802154_disassoc_conf_s disassocconf;
struct ieee802154_get_conf_s getconf;
struct ieee802154_gts_conf_s gtsconf;
struct ieee802154_reset_conf_s resetconf;
struct ieee802154_rxenable_conf_s rxenableconf;
struct ieee802154_scan_conf_s scanconf;
struct ieee802154_start_conf_s startconf;
@ -1307,7 +1249,6 @@ union ieee802154_mlme_notify_u
union ieee802154_mcps_notify_u
{
struct ieee802154_data_conf_s dataconf;
struct ieee802154_purge_conf_s purgeconf;
struct ieee802154_data_ind_s dataind;
};
@ -1362,19 +1303,16 @@ enum ieee802154_macnotify_e
/* MCPS Notifications */
IEEE802154_NOTIFY_CONF_DATA = 0x00,
IEEE802154_NOTIFY_CONF_PURGE,
IEEE802154_NOTIFY_IND_DATA,
/* MLME Notifications */
IEEE802154_NOTIFY_CONF_ASSOC,
IEEE802154_NOTIFY_CONF_DISASSOC,
IEEE802154_NOTIFY_CONF_GET,
IEEE802154_NOTIFY_CONF_GTS,
IEEE802154_NOTIFY_CONF_RESET,
IEEE802154_NOTIFY_CONF_RXENABLE,
IEEE802154_NOTIFY_CONF_SCAN,
IEEE802154_NOTIFY_CONF_SET,
IEEE802154_NOTIFY_CONF_START,
IEEE802154_NOTIFY_CONF_POLL,

View File

@ -890,7 +890,8 @@ int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg)
break;
case MAC802154IOC_MLME_GET_REQUEST:
{
mac802154_req_get(mac, &macarg->getreq);
mac802154_req_get(mac, macarg->getreq.pib_attr,
macarg->getreq.attr_value);
}
break;
case MAC802154IOC_MLME_GTS_REQUEST:
@ -905,7 +906,7 @@ int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg)
break;
case MAC802154IOC_MLME_RESET_REQUEST:
{
mac802154_req_reset(mac, &macarg->resetreq);
mac802154_req_reset(mac, macarg->resetreq.rst_pibattr);
}
break;
case MAC802154IOC_MLME_RXENABLE_REQUEST:
@ -1046,26 +1047,27 @@ int mac802154_get_mhrlen(MACHANDLE mac,
*
****************************************************************************/
int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req)
int mac802154_req_data(MACHANDLE mac,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *frame)
{
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)mac;
FAR struct mac802154_trans_s trans;
FAR const struct ieee802154_frame_meta_s *meta = req->meta;
uint16_t *frame_ctrl;
uint8_t mhr_len = 3; /* Start assuming frame control and seq. num */
int ret;
/* Check the required frame size */
if (req->frame->io_len > IEEE802154_MAX_PHY_PACKET_SIZE)
if (frame->io_len > IEEE802154_MAX_PHY_PACKET_SIZE)
{
return -E2BIG;
}
/* Cast the first two bytes of the IOB to a uint16_t frame control field */
frame_ctrl = (uint16_t *)&req->frame->io_data[0];
frame_ctrl = (uint16_t *)&frame->io_data[0];
/* Ensure we start with a clear frame control field */
@ -1097,17 +1099,17 @@ int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req)
if (meta->dest_addr.mode != IEEE802154_ADDRMODE_NONE)
{
memcpy(&req->frame->io_data[mhr_len], &meta->dest_addr.panid, 2);
memcpy(&frame->io_data[mhr_len], &meta->dest_addr.panid, 2);
mhr_len += 2;
if (meta->dest_addr.mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&req->frame->io_data[mhr_len], &meta->dest_addr.saddr, 2);
memcpy(&frame->io_data[mhr_len], &meta->dest_addr.saddr, 2);
mhr_len += 2;
}
else if (meta->dest_addr.mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&req->frame->io_data[mhr_len], &meta->dest_addr.eaddr, 8);
memcpy(&frame->io_data[mhr_len], &meta->dest_addr.eaddr, 8);
mhr_len += 8;
}
}
@ -1153,18 +1155,18 @@ int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req)
if ((meta->dest_addr.mode == IEEE802154_ADDRMODE_NONE) ||
(*frame_ctrl & IEEE802154_FRAMECTRL_PANIDCOMP))
{
memcpy(&req->frame->io_data[mhr_len], &priv->addr.panid, 2);
memcpy(&frame->io_data[mhr_len], &priv->addr.panid, 2);
mhr_len += 2;
}
if (meta->src_addr_mode == IEEE802154_ADDRMODE_SHORT)
{
memcpy(&req->frame->io_data[mhr_len], &priv->addr.saddr, 2);
memcpy(&frame->io_data[mhr_len], &priv->addr.saddr, 2);
mhr_len += 2;
}
else if (meta->src_addr_mode == IEEE802154_ADDRMODE_EXTENDED)
{
memcpy(&req->frame->io_data[mhr_len], &priv->addr.eaddr, 8);
memcpy(&frame->io_data[mhr_len], &priv->addr.eaddr, 8);
mhr_len += 8;
}
}
@ -1178,7 +1180,7 @@ int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req)
* of the outgoing frame and then increment it by one. [1] pg. 40.
*/
req->frame->io_data[2] = priv->dsn++;
frame->io_data[2] = priv->dsn++;
/* The MAC header we just created must never have exceeded where the app
* data starts. This should never happen since the offset should have
@ -1186,14 +1188,14 @@ int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req)
* here that created the header
*/
DEBUGASSERT(mhr_len == req->frame->io_offset);
DEBUGASSERT(mhr_len == frame->io_offset);
req->frame->io_offset = 0; /* Set the offset to 0 to include the header */
frame->io_offset = 0; /* Set the offset to 0 to include the header */
/* Setup our transaction */
trans.msdu_handle = meta->msdu_handle;
trans.frame = req->frame;
trans.frame = frame;
sem_init(&trans.sem, 0, 1);
/* If the TxOptions parameter specifies that a GTS transmission is required,
@ -1234,6 +1236,9 @@ int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req)
* coordinator, the destination address is not present, or the
* TxOptions parameter also specifies a GTS transmission, the indirect
* transmission option will be ignored. [1]
*
* NOTE: We don't just ignore the parameter. Instead, we throw an
* error, since this really shouldn't be happening.
*/
if (priv->is_coord && meta->dest_addr.mode != IEEE802154_ADDRMODE_NONE)
@ -1243,15 +1248,10 @@ int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req)
}
else
{
/* Override the setting since it wasn't valid */
meta->msdu_flags.indirect_tx = 0;
return -EINVAL;
}
}
/* If this is a direct transmission not during a GTS */
if (!meta->msdu_flags.indirect_tx)
else
{
/* Link the transaction into the CSMA transaction list */
@ -1281,9 +1281,15 @@ int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req)
* an MSDU from the transaction queue. Confirmation is returned via
* the struct ieee802154_maccb_s->conf_purge callback.
*
* NOTE: The standard specifies that confirmation should be indicated via
* the asynchronous MLME-PURGE.confirm primitve. However, in our
* implementation we synchronously return the status from the request.
* Therefore, we merge the functionality of the MLME-PURGE.request and
* MLME-PURGE.confirm primitives together.
*
****************************************************************************/
int mac802154_req_purge(MACHANDLE mac, FAR struct ieee802154_purge_req_s *req)
int mac802154_req_purge(MACHANDLE mac, uint8_t msdu_handle)
{
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)mac;
@ -1352,22 +1358,6 @@ int mac802154_req_disassociate(MACHANDLE mac,
return -ENOTTY;
}
/****************************************************************************
* Name: mac802154_req_get
*
* Description:
* The MLME-GET.request primitive requests information about a given PIB
* attribute. Actual data is returned via the
* struct ieee802154_maccb_s->conf_get callback.
*
****************************************************************************/
int mac802154_req_get(MACHANDLE mac, FAR struct ieee802154_get_req_s *req)
{
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)mac;
return -ENOTTY;
}
/****************************************************************************
* Name: mac802154_req_gts
@ -1392,12 +1382,21 @@ int mac802154_req_gts(MACHANDLE mac, FAR struct ieee802154_gts_req_s *req)
*
* Description:
* The MLME-RESET.request primitive allows the next higher layer to request
* that the MLME performs a reset operation. Confirmation is returned via
* the struct ieee802154_maccb_s->conf_reset callback.
* that the MLME performs a reset operation.
*
* NOTE: The standard specifies that confirmation should be provided via
* via the asynchronous MLME-RESET.confirm primitve. However, in our
* implementation we synchronously return the value immediately. Therefore,
* we merge the functionality of the MLME-RESET.request and MLME-RESET.confirm
* primitives together.
*
* Input Parameters:
* mac - Handle to the MAC layer instance
* rst_pibattr - Whether or not to reset the MAC PIB attributes to defaults
*
****************************************************************************/
int mac802154_req_reset(MACHANDLE mac, FAR struct ieee802154_reset_req_s *req)
int mac802154_req_reset(MACHANDLE mac, bool rst_pibattr)
{
FAR struct ieee802154_privmac_s * priv =
(FAR struct ieee802154_privmac_s *) mac;
@ -1445,6 +1444,29 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req)
return -ENOTTY;
}
/****************************************************************************
* Name: mac802154_req_get
*
* Description:
* The MLME-GET.request primitive requests information about a given PIB
* attribute.
*
* NOTE: The standard specifies that the attribute value should be returned
* via the asynchronous MLME-GET.confirm primitve. However, in our
* implementation, we synchronously return the value immediately.Therefore, we
* merge the functionality of the MLME-GET.request and MLME-GET.confirm
* primitives together.
*
****************************************************************************/
int mac802154_req_get(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr,
FAR union ieee802154_attr_val_u *attr_value)
{
FAR struct ieee802154_privmac_s *priv =
(FAR struct ieee802154_privmac_s *)mac;
return -ENOTTY;
}
/****************************************************************************
* Name: mac802154_req_set
*
@ -1454,9 +1476,9 @@ int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req)
*
* NOTE: The standard specifies that confirmation should be indicated via
* the asynchronous MLME-SET.confirm primitve. However, in our implementation
* there is no reason not to synchronously return the status immediately.
* Therefore, we do merge the functionality of the MLME-SET.request and
* MLME-SET.confirm primitives together.
* we synchronously return the status from the request. Therefore, we do merge
* the functionality of the MLME-SET.request and MLME-SET.confirm primitives
* together.
*
****************************************************************************/

View File

@ -119,7 +119,9 @@ int mac802154_get_mhrlen(MACHANDLE mac,
*
****************************************************************************/
int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req);
int mac802154_req_data(MACHANDLE mac,
FAR const struct ieee802154_frame_meta_s *meta,
FAR struct iob_s *frame);
/****************************************************************************
* Name: mac802154_req_purge
@ -129,9 +131,15 @@ int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req);
* an MSDU from the transaction queue. Confirmation is returned via
* the struct ieee802154_maccb_s->conf_purge callback.
*
* NOTE: The standard specifies that confirmation should be indicated via
* the asynchronous MLME-PURGE.confirm primitve. However, in our
* implementation we synchronously return the status from the request.
* Therefore, we merge the functionality of the MLME-PURGE.request and
* MLME-PURGE.confirm primitives together.
*
****************************************************************************/
int mac802154_req_purge(MACHANDLE mac, FAR struct ieee802154_purge_req_s *req);
int mac802154_req_purge(MACHANDLE mac, uint8_t msdu_handle);
/****************************************************************************
* Name: mac802154_req_associate
@ -163,18 +171,6 @@ int mac802154_req_associate(MACHANDLE mac,
int mac802154_req_disassociate(MACHANDLE mac,
FAR struct ieee802154_disassoc_req_s *req);
/****************************************************************************
* Name: mac802154_req_get
*
* Description:
* The MLME-GET.request primitive requests information about a given PIB
* attribute. Actual data is returned via the
* struct ieee802154_maccb_s->conf_get callback.
*
****************************************************************************/
int mac802154_req_get(MACHANDLE mac, FAR struct ieee802154_get_req_s *req);
/****************************************************************************
* Name: mac802154_req_gts
*
@ -193,12 +189,21 @@ int mac802154_req_gts(MACHANDLE mac, FAR struct ieee802154_gts_req_s *req);
*
* Description:
* The MLME-RESET.request primitive allows the next higher layer to request
* that the MLME performs a reset operation. Confirmation is returned via
* the struct ieee802154_maccb_s->conf_reset callback.
* that the MLME performs a reset operation.
*
* NOTE: The standard specifies that confirmation should be provided via
* via the asynchronous MLME-RESET.confirm primitve. However, in our
* implementation we synchronously return the value immediately. Therefore,
* we merge the functionality of the MLME-RESET.request and MLME-RESET.confirm
* primitives together.
*
* Input Parameters:
* mac - Handle to the MAC layer instance
* rst_pibattr - Whether or not to reset the MAC PIB attributes to defaults
*
****************************************************************************/
int mac802154_req_reset(MACHANDLE mac, FAR struct ieee802154_reset_req_s *req);
int mac802154_req_reset(MACHANDLE mac, bool rst_pibattr);
/****************************************************************************
* Name: mac802154_req_rxenable
@ -231,13 +236,36 @@ int mac802154_req_rxenable(MACHANDLE mac,
int mac802154_req_scan(MACHANDLE mac, FAR struct ieee802154_scan_req_s *req);
/****************************************************************************
* Name: mac802154_req_get
*
* Description:
* The MLME-GET.request primitive requests information about a given PIB
* attribute.
*
* NOTE: The standard specifies that the attribute value should be returned
* via the asynchronous MLME-GET.confirm primitve. However, in our
* implementation, we synchronously return the value immediately.Therefore, we
* merge the functionality of the MLME-GET.request and MLME-GET.confirm
* primitives together.
*
****************************************************************************/
int mac802154_req_get(MACHANDLE mac, enum ieee802154_pib_attr_e pib_attr,
FAR union ieee802154_attr_val_u *attr_value);
/****************************************************************************
* Name: mac802154_req_set
*
* Description:
* The MLME-SET.request primitive attempts to write the given value to the
* indicated MAC PIB attribute. Confirmation is returned via the
* struct ieee802154_maccb_s->conf_set callback.
* indicated MAC PIB attribute.
*
* NOTE: The standard specifies that confirmation should be indicated via
* the asynchronous MLME-SET.confirm primitve. However, in our implementation
* we synchronously return the status from the request. Therefore, we do merge
* the functionality of the MLME-SET.request and MLME-SET.confirm primitives
* together.
*
****************************************************************************/

View File

@ -406,7 +406,6 @@ static ssize_t mac802154dev_write(FAR struct file *filep,
FAR struct mac802154_chardevice_s *dev;
FAR struct mac802154dev_txframe_s *tx;
FAR struct iob_s *iob;
struct ieee802154_data_req_s req;
struct mac802154dev_dwait_s dwait;
int ret;
@ -440,7 +439,7 @@ static ssize_t mac802154dev_write(FAR struct file *filep,
/* Get the MAC header length */
ret = mac802154_get_mhrlen(dev->md_mac, tx->meta);
ret = mac802154_get_mhrlen(dev->md_mac, &tx->meta);
if (ret < 0)
{
wlerr("ERROR: TX meta-data is invalid");
@ -450,9 +449,9 @@ static ssize_t mac802154dev_write(FAR struct file *filep,
iob->io_offset = ret;
iob->io_len = iob->io_offset;
memcpy(&iob->io_data[iob->io_offset], tx->payload, tx->meta->msdu_length);
memcpy(&iob->io_data[iob->io_offset], tx->payload, tx->meta.msdu_length);
iob->io_len += tx->meta->msdu_length;
iob->io_len += tx->meta.msdu_length;
/* If this is a blocking operation, we need to setup a wait struct so we
* can unblock when the packet transmission has finished. If this is a
@ -473,7 +472,7 @@ static ssize_t mac802154dev_write(FAR struct file *filep,
/* Setup the wait struct */
dwait.mw_handle = tx->meta->msdu_handle;
dwait.mw_handle = tx->meta.msdu_handle;
/* Link the wait struct */
@ -486,12 +485,9 @@ static ssize_t mac802154dev_write(FAR struct file *filep,
mac802154dev_givesem(&dev->md_exclsem);
}
req.meta = tx->meta;
req.frame = iob;
/* Pass the request to the MAC layer */
ret = mac802154_req_data(dev->md_mac, &req);
ret = mac802154_req_data(dev->md_mac, &tx->meta, iob);
if (ret < 0)
{