mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
ieee802.15.4: de-couple MAC driver interface. Now works more like other drivers.
This commit is contained in:
@@ -883,7 +883,8 @@ struct ieee802154_netmac_s
|
|||||||
|
|
||||||
/* MAC Interface Operations *************************************************/
|
/* MAC Interface Operations *************************************************/
|
||||||
|
|
||||||
struct ieee802154_mac_s; /* Forward reference */
|
struct ieee802154_mac_s; /* Forward reference */
|
||||||
|
struct ieee802154_maccb_s; /* Forward reference */
|
||||||
|
|
||||||
struct ieee802154_macops_s
|
struct ieee802154_macops_s
|
||||||
{
|
{
|
||||||
@@ -960,6 +961,11 @@ struct ieee802154_macops_s
|
|||||||
FAR uint8_t *orphanaddr, uint16_t saddr,
|
FAR uint8_t *orphanaddr, uint16_t saddr,
|
||||||
bool associated);
|
bool associated);
|
||||||
|
|
||||||
|
/* Bind callbacks to the IEEE802.15.4 MAC */
|
||||||
|
|
||||||
|
CODE int (*bind)(FAR struct ieee802154_mac_s *mac,
|
||||||
|
FAR const struct ieee802154_maccb_s *cb);
|
||||||
|
|
||||||
/* IOCTL support */
|
/* IOCTL support */
|
||||||
|
|
||||||
CODE int (*ioctl)(FAR struct ieee802154_mac_s *mac, int cmd,
|
CODE int (*ioctl)(FAR struct ieee802154_mac_s *mac, int cmd,
|
||||||
@@ -970,10 +976,6 @@ struct ieee802154_macops_s
|
|||||||
|
|
||||||
struct ieee802154_maccb_s
|
struct ieee802154_maccb_s
|
||||||
{
|
{
|
||||||
/* Context arg for handling callback */
|
|
||||||
|
|
||||||
FAR void *cb_context;
|
|
||||||
|
|
||||||
/* Asynchronous confirmations to requests */
|
/* Asynchronous confirmations to requests */
|
||||||
|
|
||||||
/* Data frame was received by remote device */
|
/* Data frame was received by remote device */
|
||||||
@@ -1064,13 +1066,13 @@ struct ieee802154_maccb_s
|
|||||||
CODE void (*ind_syncloss)(FAR struct ieee802154_mac_s *mac, int reason);
|
CODE void (*ind_syncloss)(FAR struct ieee802154_mac_s *mac, int reason);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ieee802154_radio_s; /* Forward reference */
|
|
||||||
|
|
||||||
struct ieee802154_mac_s
|
struct ieee802154_mac_s
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_radio_s *radio;
|
/* Publicly visiable part of the MAC interface */
|
||||||
|
|
||||||
struct ieee802154_macops_s ops;
|
struct ieee802154_macops_s ops;
|
||||||
struct ieee802154_maccb_s cbs;
|
|
||||||
|
/* MAC private data may follow */
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -1085,6 +1087,8 @@ extern "C"
|
|||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
struct ieee802154_radio_s; /* Forward reference */
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mac802154_create
|
* Name: mac802154_create
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -61,7 +61,9 @@
|
|||||||
|
|
||||||
struct ieee802154_privmac_s
|
struct ieee802154_privmac_s
|
||||||
{
|
{
|
||||||
struct ieee802154_mac_s pubmac; /* This MUST be the first member */
|
struct ieee802154_mac_s pubmac; /* This MUST be the first member */
|
||||||
|
FAR struct ieee802154_radio_s *radio; /* Contained IEEE802.15.4 radio dev */
|
||||||
|
FAR const struct ieee802154_maccb_s *cb; /* Contained MAC callbacks */
|
||||||
|
|
||||||
/* MIB attributes, grouped to save memory */
|
/* MIB attributes, grouped to save memory */
|
||||||
/* 0x40 */ uint8_t macAckWaitDuration : 1; /* 55 or 120(true) */
|
/* 0x40 */ uint8_t macAckWaitDuration : 1; /* 55 or 120(true) */
|
||||||
@@ -143,6 +145,10 @@ static int mac802154_rsp_associate(FAR struct ieee802154_mac_s *mac,
|
|||||||
static int mac802154_rsp_orphan(FAR struct ieee802154_mac_s *mac,
|
static int mac802154_rsp_orphan(FAR struct ieee802154_mac_s *mac,
|
||||||
FAR uint8_t *orphanaddr, uint16_t saddr, bool associated);
|
FAR uint8_t *orphanaddr, uint16_t saddr, bool associated);
|
||||||
|
|
||||||
|
static int mac802154_bind(FAR struct ieee802154_mac_s *mac,
|
||||||
|
FAR struct ieee802154_maccb_s *cb);
|
||||||
|
static int mac802154_ioctl(FAR struct ieee802154_mac_s *mac, int cmd,
|
||||||
|
unsigned long arg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@@ -502,10 +508,76 @@ static int mac802154_rsp_orphan(FAR struct ieee802154_mac_s *mac,
|
|||||||
FAR uint8_t *orphanaddr, uint16_t saddr,
|
FAR uint8_t *orphanaddr, uint16_t saddr,
|
||||||
bool associated)
|
bool associated)
|
||||||
{
|
{
|
||||||
FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac;
|
FAR struct ieee802154_privmac_s *priv =
|
||||||
|
(FAR struct ieee802154_privmac_s *)mac;
|
||||||
return -ENOTTY;
|
return -ENOTTY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mac802154_bind
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Bind the MAC callback table to the MAC state.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* mac - Reference to the MAC driver state structure
|
||||||
|
* cb - MAC callback operations
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; Negated errno on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int mac802154_bind(FAR struct ieee802154_mac_s *mac,
|
||||||
|
FAR const struct ieee802154_maccb_s *cb)
|
||||||
|
{
|
||||||
|
FAR struct ieee802154_privmac_s *priv =
|
||||||
|
(FAR struct ieee802154_privmac_s *)mac;
|
||||||
|
|
||||||
|
priv->cb = cb;
|
||||||
|
return OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mac802154_ioctl
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Handle MAC and radio IOCTL commands directed to the MAC.
|
||||||
|
*
|
||||||
|
* Parameters:
|
||||||
|
* mac - Reference to the MAC driver state structure
|
||||||
|
* cmd - The IOCTL command
|
||||||
|
* arg - The argument for the IOCTL command
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* OK on success; Negated errno on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
static int mac802154_ioctl(FAR struct ieee802154_mac_s *mac, int cmd,
|
||||||
|
unsigned long arg)
|
||||||
|
{
|
||||||
|
FAR struct ieee802154_privmac_s *priv =
|
||||||
|
(FAR struct ieee802154_privmac_s *)mac;
|
||||||
|
int ret = -EINVAL;
|
||||||
|
|
||||||
|
/* Check for IOCTLs aimed at the IEEE802.15.4 MAC layer */
|
||||||
|
|
||||||
|
if (_MAC802154IOCVALID(cmd))
|
||||||
|
{
|
||||||
|
/* Handle the MAC IOCTL command */
|
||||||
|
#warning Missing logic
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No, other IOCTLs must be aimed at the IEEE802.15.4 radio layer */
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = priv->radio->ioctl(priv->radio, cmd, arg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -552,7 +624,7 @@ FAR struct ieee802154_mac_s *
|
|||||||
|
|
||||||
/* Initialize fields */
|
/* Initialize fields */
|
||||||
|
|
||||||
mac->pubmac.radio = radiodev;
|
mac->radio = radiodev;
|
||||||
mac->pubmac.ops = mac802154ops;
|
mac->pubmac.ops = mac802154ops;
|
||||||
|
|
||||||
mac802154_defaultmib(mac);
|
mac802154_defaultmib(mac);
|
||||||
|
|||||||
@@ -494,9 +494,10 @@ void mac802154dev_conf_data(FAR struct ieee802154_mac_s *mac,
|
|||||||
|
|
||||||
/* Get the dev from the callback context. This should have been set when
|
/* Get the dev from the callback context. This should have been set when
|
||||||
* the char driver was registered.
|
* the char driver was registered.
|
||||||
|
*
|
||||||
|
* REVISIT: See mac802154_netdev.c
|
||||||
*/
|
*/
|
||||||
|
#warning Missing logic
|
||||||
dev = mac->cbs.cb_context;
|
|
||||||
|
|
||||||
/* Get exclusive access to the driver structure */
|
/* Get exclusive access to the driver structure */
|
||||||
|
|
||||||
@@ -554,7 +555,13 @@ int mac802154dev_register(FAR struct ieee802154_mac_s *mac, int minor)
|
|||||||
dev->md_mac = mac;
|
dev->md_mac = mac;
|
||||||
sem_init(&dev->md_exclsem, 0, 1); /* Allow the device to be opened once
|
sem_init(&dev->md_exclsem, 0, 1); /* Allow the device to be opened once
|
||||||
* before blocking */
|
* before blocking */
|
||||||
|
|
||||||
|
/* Initialize the callbacks and bind them to the radio
|
||||||
|
*
|
||||||
|
* REVISIT: See mac802154_netdev.c
|
||||||
|
*/
|
||||||
|
#warning Missing logic
|
||||||
|
|
||||||
/* Create the character device name */
|
/* Create the character device name */
|
||||||
|
|
||||||
snprintf(devname, DEVNAME_FMTLEN, DEVNAME_FMT, minor);
|
snprintf(devname, DEVNAME_FMTLEN, DEVNAME_FMT, minor);
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user