mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
Ieee802.15.4 MAC network driver. A little more logic (but still only partial). Add interface definitions to header file.
This commit is contained in:
@@ -264,20 +264,33 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
|
|||||||
wlerr("ERROR: Failed to initialize IEEE802.15.4 MAC\n");
|
wlerr("ERROR: Failed to initialize IEEE802.15.4 MAC\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_IEEE802154_MAC_DEV)
|
#if defined(CONFIG_IEEE802154_NETDEV)
|
||||||
/* If want to call these APIs from userspace, you have to wrap your mac
|
/* Use the IEEE802.15.4 MAC interface instance to create a 6loWPAN
|
||||||
* in a character device via mac802154_device.c.
|
* network interface by wrapping the MAC intrface instance in a
|
||||||
|
* network device driver via mac802154dev_register().
|
||||||
|
*/
|
||||||
|
|
||||||
|
ret = mac802154netdev_register(mac);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
wlerr("ERROR: Failed to register the MAC network driver wpan%d: %d\n",
|
||||||
|
0, ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#elif defined(CONFIG_IEEE802154_MAC_DEV)
|
||||||
|
/* If want to call these APIs from userspace, you have to wrap the MAC
|
||||||
|
* interface in a character device viamac802154dev_register().
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = mac802154dev_register(mac, 0);
|
ret = mac802154dev_register(mac, 0);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
wlerr("ERROR: Failed to register the MAC character driver ieee%d: %d\n",
|
wlerr("ERROR: Failed to register the MAC character driver /dev/ieee%d: %d\n",
|
||||||
0, ret);
|
0, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#elif defined(CONFIG_IEEE802154_DEV)
|
#elif defined(CONFIG_IEEE802154_DEV)
|
||||||
/* Register a character driver to access the IEEE 802.15.4 radio from
|
/* Register a character driver to access the IEEE 802.15.4 radio from
|
||||||
* user-space
|
* user-space
|
||||||
@@ -290,7 +303,7 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv)
|
|||||||
RADIO_DEVNAME, ret);
|
RADIO_DEVNAME, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_IEEE802154_MAC */
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -918,11 +918,11 @@ 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; /* Forware reference */
|
struct ieee802154_radio_s; /* Forward reference */
|
||||||
|
|
||||||
struct ieee802154_mac_s
|
struct ieee802154_mac_s
|
||||||
{
|
{
|
||||||
struct ieee802154_radio_s *radio;
|
FAR struct ieee802154_radio_s *radio;
|
||||||
struct ieee802154_macops_s ops;
|
struct ieee802154_macops_s ops;
|
||||||
struct ieee802154_maccb_s cbs;
|
struct ieee802154_maccb_s cbs;
|
||||||
};
|
};
|
||||||
@@ -947,9 +947,9 @@ extern "C"
|
|||||||
*
|
*
|
||||||
* The returned MAC structure should be passed to either the next highest
|
* The returned MAC structure should be passed to either the next highest
|
||||||
* layer in the network stack, or registered with a mac802154dev character
|
* layer in the network stack, or registered with a mac802154dev character
|
||||||
* driver. In either of these scenarios, the next highest layer should
|
* or network drivers. In any of these scenarios, the next highest layer
|
||||||
* register a set of callbacks with the MAC layer by setting the mac->cbs
|
* should register a set of callbacks with the MAC layer by setting the
|
||||||
* member.
|
* mac->cbs member.
|
||||||
*
|
*
|
||||||
* NOTE: This API does not create any device accessible to userspace. If you
|
* NOTE: This API does not create any device accessible to userspace. If you
|
||||||
* want to call these APIs from userspace, you have to wrap your mac in a
|
* want to call these APIs from userspace, you have to wrap your mac in a
|
||||||
@@ -975,7 +975,7 @@ FAR struct ieee802154_mac_s *
|
|||||||
* user-space
|
* user-space
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* mac - Pointer to the mac layer struct to be registerd.
|
* mac - Pointer to the mac layer struct to be registered.
|
||||||
* minor - The device minor number. The IEEE802.15.4 MAC character device
|
* minor - The device minor number. The IEEE802.15.4 MAC character device
|
||||||
* will be registered as /dev/ieeeN where N is the minor number
|
* will be registered as /dev/ieeeN where N is the minor number
|
||||||
*
|
*
|
||||||
@@ -987,6 +987,24 @@ FAR struct ieee802154_mac_s *
|
|||||||
|
|
||||||
int mac802154dev_register(FAR struct ieee802154_mac_s *mac, int minor);
|
int mac802154dev_register(FAR struct ieee802154_mac_s *mac, int minor);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: mac802154netdev_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register a network driver to access the IEEE 802.15.4 MAC layer from
|
||||||
|
* a socket using 6loWPAN
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* mac - Pointer to the mac layer struct to be registered.
|
||||||
|
*
|
||||||
|
* Returned Values:
|
||||||
|
* Zero (OK) is returned on success. Otherwise a negated errno value is
|
||||||
|
* returned to indicate the nature of the failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int mac802154netdev_register(FAR struct ieee802154_mac_s *mac);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -518,9 +518,9 @@ static int mac802154_rsp_orphan(FAR struct ieee802154_mac_s *mac,
|
|||||||
*
|
*
|
||||||
* The returned MAC structure should be passed to either the next highest
|
* The returned MAC structure should be passed to either the next highest
|
||||||
* layer in the network stack, or registered with a mac802154dev character
|
* layer in the network stack, or registered with a mac802154dev character
|
||||||
* driver. In either of these scenarios, the next highest layer should
|
* or network drivers. In any of these scenarios, the next highest layer
|
||||||
* register a set of callbacks with the MAC layer by setting the mac->cbs
|
* should register a set of callbacks with the MAC layer by setting the
|
||||||
* member.
|
* mac->cbs member.
|
||||||
*
|
*
|
||||||
* NOTE: This API does not create any device accessible to userspace. If you
|
* NOTE: This API does not create any device accessible to userspace. If you
|
||||||
* want to call these APIs from userspace, you have to wrap your mac in a
|
* want to call these APIs from userspace, you have to wrap your mac in a
|
||||||
|
|||||||
@@ -117,8 +117,8 @@ struct mac802154_driver_s
|
|||||||
{
|
{
|
||||||
/* This holds the information visible to the NuttX network */
|
/* This holds the information visible to the NuttX network */
|
||||||
|
|
||||||
struct ieee802154_driver_s m8_dev; /* Interface understood by the network */
|
struct ieee802154_driver_s m8_dev; /* Interface understood by the network */
|
||||||
struct ieee802154_mac_s m8_mac; /* Interface understood by the MAC */
|
FAR struct ieee802154_mac_s *m8_mac; /* Contained MAC interface */
|
||||||
|
|
||||||
/* For internal use by this driver */
|
/* For internal use by this driver */
|
||||||
|
|
||||||
@@ -129,19 +129,6 @@ struct mac802154_driver_s
|
|||||||
struct work_s m8_pollwork; /* For deferring poll work to the work queue */
|
struct work_s m8_pollwork; /* For deferring poll work to the work queue */
|
||||||
};
|
};
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Private Data
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
struct ieee802154_radio_s; /* Forware reference */
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
struct ieee802154_macops_s ops;
|
|
||||||
struct ieee802154_maccb_s cbs;
|
|
||||||
};
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -1282,26 +1269,25 @@ static void mac802154_ipv6multicast(FAR struct mac802154_driver_s *priv)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mac802154_initialize
|
* Name: mac802154netdev_register
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the Ethernet controller and driver
|
* Register a network driver to access the IEEE 802.15.4 MAC layer from
|
||||||
|
* a socket using 6loWPAN
|
||||||
*
|
*
|
||||||
* Parameters:
|
* Input Parameters:
|
||||||
* intf - In the case where there are multiple EMACs, this value
|
* mac - Pointer to the mac layer struct to be registered.
|
||||||
* identifies which EMAC is to be initialized.
|
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Values:
|
||||||
* OK on success; Negated errno on failure.
|
* Zero (OK) is returned on success. Otherwise a negated errno value is
|
||||||
*
|
* returned to indicate the nature of the failure.
|
||||||
* Assumptions:
|
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int mac802154_initialize(FAR struct ieee802154_radio_s *radio)
|
int mac802154netdev_register(FAR struct ieee802154_mac_s *mac);
|
||||||
{
|
{
|
||||||
FAR struct mac802154_driver_s *priv;
|
FAR struct mac802154_driver_s *priv;
|
||||||
FAR struct ieee802154_driver_s *ieee;
|
FAR truct ieee802154_maccb_s *macb;
|
||||||
FAR struct net_driver_s *dev;
|
FAR struct net_driver_s *dev;
|
||||||
FAR uint8_t *pktbuf;
|
FAR uint8_t *pktbuf;
|
||||||
|
|
||||||
@@ -1332,9 +1318,7 @@ int mac802154_initialize(FAR struct ieee802154_radio_s *radio)
|
|||||||
|
|
||||||
/* Initialize the driver structure */
|
/* Initialize the driver structure */
|
||||||
|
|
||||||
ieee = &priv->m8_dev;
|
dev = &ieee->m8_dev.i_dev;
|
||||||
dev = &ieee->i_dev;
|
|
||||||
|
|
||||||
dev->d_buf = pktbuf; /* Single packet buffer */
|
dev->d_buf = pktbuf; /* Single packet buffer */
|
||||||
dev->d_ifup = mac802154_ifup; /* I/F up (new IP address) callback */
|
dev->d_ifup = mac802154_ifup; /* I/F up (new IP address) callback */
|
||||||
dev->d_ifdown = mac802154_ifdown; /* I/F down callback */
|
dev->d_ifdown = mac802154_ifdown; /* I/F down callback */
|
||||||
@@ -1347,11 +1331,37 @@ int mac802154_initialize(FAR struct ieee802154_radio_s *radio)
|
|||||||
|
|
||||||
/* Create a watchdog for timing polling for and timing of transmisstions */
|
/* Create a watchdog for timing polling for and timing of transmisstions */
|
||||||
|
|
||||||
priv->m8_txpoll = wd_create(); /* Create periodic poll timer */
|
priv->m8_mac = mac; /* Save the MAC interface instance */
|
||||||
|
priv->m8_txpoll = wd_create(); /* Create periodic poll timer */
|
||||||
priv->m8_txtimeout = wd_create(); /* Create TX timeout timer */
|
priv->m8_txtimeout = wd_create(); /* Create TX timeout timer */
|
||||||
|
|
||||||
DEBUGASSERT(priv->m8_txpoll != NULL && priv->m8_txtimeout != NULL);
|
DEBUGASSERT(priv->m8_txpoll != NULL && priv->m8_txtimeout != NULL);
|
||||||
|
|
||||||
|
/* Initialize the MAC callbacks */
|
||||||
|
|
||||||
|
maccb = &mac->cbs;
|
||||||
|
maccb->cb_context = priv;
|
||||||
|
maccb->conf_data = mac802154_conf_data;
|
||||||
|
maccb->conf_purge = mac802154_conf_purge;
|
||||||
|
maccb->conf_associate = mac802154_conf_associate;
|
||||||
|
maccb->conf_disassociate = mac802154_conf_disassociate;
|
||||||
|
maccb->conf_get = mac802154_conf_get;
|
||||||
|
maccb->conf_gts = mac802154_conf_gts;
|
||||||
|
maccb->conf_reset = mac802154_conf_reset;
|
||||||
|
maccb->conf_rxenable = mac802154_conf_rxenable;
|
||||||
|
maccb->conf_scan = mac802154_conf_scan;
|
||||||
|
maccb->conf_set = mac802154_conf_set;
|
||||||
|
maccb->conf_start = mac802154_conf_start;
|
||||||
|
maccb->conf_poll = mac802154_conf_poll;
|
||||||
|
maccb->ind_data = mac802154_ind_data;
|
||||||
|
maccb->ind_associate = mac802154_ind_associate;
|
||||||
|
maccb->ind_disassociate = mac802154_ind_disassociate;
|
||||||
|
maccb->ind_beaconnotify = mac802154_ind_beaconnotify;
|
||||||
|
maccb->ind_gts = mac802154_ind_gts;
|
||||||
|
maccb->ind_orphan = mac802154_ind_orphan;
|
||||||
|
maccb->ind_commstatus = mac802154_ind_commstatus;
|
||||||
|
maccb->ind_syncloss = mac802154_ind_syncloss;
|
||||||
|
|
||||||
/* Put the interface in the down state. */
|
/* Put the interface in the down state. */
|
||||||
|
|
||||||
mac802154_ifdown(dev);
|
mac802154_ifdown(dev);
|
||||||
|
|||||||
Reference in New Issue
Block a user