diff --git a/configs/clicker2-stm32/src/stm32_mrf24j40.c b/configs/clicker2-stm32/src/stm32_mrf24j40.c index 8f6868f59ea..e1b664f28b1 100644 --- a/configs/clicker2-stm32/src/stm32_mrf24j40.c +++ b/configs/clicker2-stm32/src/stm32_mrf24j40.c @@ -228,7 +228,7 @@ static int stm32_mrf24j40_devsetup(FAR struct stm32_priv_s *priv) { FAR struct ieee802154_radio_s *radio; #ifdef CONFIG_IEEE802154_MAC - FAR struct ieee802154_mac_s *mac; + MACHANDLE mac; #endif FAR struct spi_dev_s *spi; int ret; diff --git a/include/nuttx/wireless/ieee802154/ieee802154_mac.h b/include/nuttx/wireless/ieee802154/ieee802154_mac.h index 5dbed05ea77..acfc541c589 100644 --- a/include/nuttx/wireless/ieee802154/ieee802154_mac.h +++ b/include/nuttx/wireless/ieee802154/ieee802154_mac.h @@ -881,96 +881,12 @@ struct ieee802154_netmac_s }; #endif -/* MAC Interface Operations *************************************************/ +/* This is an opaque reference to the MAC's internal private state. It is + * returned by mac802154_create() when it is created. It may then be used + * at other interfaces in order to interact with the MAC. + */ -struct ieee802154_mac_s; /* Forward reference */ -struct ieee802154_maccb_s; /* Forward reference */ - -struct ieee802154_macops_s -{ - /* Requests, confirmed asynchronously via callbacks */ - - /* Transmit a data frame */ - - CODE int (*req_data)(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_data_req_s *req); - - /* Cancel transmission of a data frame */ - - CODE int (*req_purge)(FAR struct ieee802154_mac_s *mac, uint8_t handle); - - /* Start association with coordinator */ - - CODE int (*req_associate)(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_assoc_req_s *req); - - /* Start disassociation with coordinator */ - - CODE int (*req_disassociate)(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_disassoc_req_s *req); - - /* Read the PIB */ - - CODE int (*req_get)(FAR struct ieee802154_mac_s *mac, - enum ieee802154_pib_attr_e attr); - - /* Allocate or deallocate a GTS */ - - CODE int (*req_gts)(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *characteristics); - - /* MAC layer reset */ - - CODE int (*req_reset)(FAR struct ieee802154_mac_s *mac, bool setdefaults); - - /* PHY receiver control */ - - CODE int (*req_rxenable)(FAR struct ieee802154_mac_s *mac, bool deferrable, - int ontime, int duration); - - /* Start a network scan */ - - CODE int (*req_scan)(FAR struct ieee802154_mac_s *mac, uint8_t type, - uint32_t channels, int duration); - - /* Change the PIB */ - - CODE int (*req_set)(FAR struct ieee802154_mac_s *mac, int attribute, - FAR uint8_t *value, int valuelen); - - CODE int (*req_start)(FAR struct ieee802154_mac_s *mac, uint16_t panid, - int channel, uint8_t bo, uint8_t fo, bool coord, - bool batext, bool realign); - - CODE int (*req_sync)(FAR struct ieee802154_mac_s *mac, int channel, - bool track); - - CODE int (*req_poll)(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *coordaddr); - - /* Synchronous Responses to Indications received via callbacks */ - - /* Reply to an association request */ - - CODE int (*rsp_associate)(FAR struct ieee802154_mac_s *mac, uint8_t eadr, - uint16_t saddr, int status); - - /* Orphan device management */ - - CODE int (*rsp_orphan)(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *orphanaddr, uint16_t saddr, - 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 */ - - CODE int (*ioctl)(FAR struct ieee802154_mac_s *mac, int cmd, - unsigned long arg); -}; +typedef FAR void *MACHANDLE; /* Notifications */ @@ -980,99 +896,83 @@ struct ieee802154_maccb_s /* Data frame was received by remote device */ - CODE void (*conf_data)(FAR struct ieee802154_mac_s *mac, + CODE void (*conf_data)(MACHANDLE mac, FAR struct ieee802154_data_conf_s *conf); /* Data frame was purged */ - CODE void (*conf_purge)(FAR struct ieee802154_mac_s *mac, uint8_t handle, - int status); + CODE void (*conf_purge)(MACHANDLE mac, uint8_t handle, int status); /* Association request completed */ - CODE void (*conf_associate)(FAR struct ieee802154_mac_s *mac, - uint16_t saddr, int status); + CODE void (*conf_associate)(MACHANDLE mac, uint16_t saddr, int status); /* Disassociation request completed */ - CODE void (*conf_disassociate)(FAR struct ieee802154_mac_s *mac, - int status); + CODE void (*conf_disassociate)(MACHANDLE mac, int status); /* PIvoata returned */ - CODE void (*conf_get)(FAR struct ieee802154_mac_s *mac, int status, - int attribute, FAR uint8_t *value, - int valuelen); + CODE void (*conf_get)(MACHANDLE mac, int status, int attribute, + FAR uint8_t *value, int valuelen); /* GTvoanagement completed */ - CODE void (*conf_gts)(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *characteristics, int status); + CODE void (*conf_gts)(MACHANDLE mac, FAR uint8_t *characteristics, + int status); /* MAveset completed */ - CODE void (*conf_reset)(FAR struct ieee802154_mac_s *mac, int status); + CODE void (*conf_reset)(MACHANDLE mac, int status); - CODE void (*conf_rxenable)(FAR struct ieee802154_mac_s *mac, int status); + CODE void (*conf_rxenable)(MACHANDLE mac, int status); - CODE void (*conf_scan)(FAR struct ieee802154_mac_s *mac, int status, - uint8_t type, uint32_t unscanned, int rsltsize, + CODE void (*conf_scan)(MACHANDLE mac, int status, uint8_t type, + uint32_t unscanned, int rsltsize, FAR uint8_t *edlist, FAR uint8_t *pandescs); - CODE void (*conf_set)(FAR struct ieee802154_mac_s *mac, int status, - int attribute); + CODE void (*conf_set)(MACHANDLE mac, int status, int attribute); - CODE void (*conf_start)(FAR struct ieee802154_mac_s *mac, int status); + CODE void (*conf_start)(MACHANDLE mac, int status); - CODE void (*conf_poll)(FAR struct ieee802154_mac_s *mac, int status); + CODE void (*conf_poll)(MACHANDLE mac, int status); /* Asynchronous event indications, replied to synchronously with responses */ /* Data frame received */ - CODE void (*ind_data)(FAR struct ieee802154_mac_s *mac, FAR uint8_t *buf, - int len); + CODE void (*ind_data)(MACHANDLE mac, FAR uint8_t *buf, int len); /* Association request received */ - CODE void (*ind_associate)(FAR struct ieee802154_mac_s *mac, - uint16_t clipanid, FAR uint8_t *clieaddr); + CODE void (*ind_associate)(MACHANDLE mac, uint16_t clipanid, + FAR uint8_t *clieaddr); /* Disassociation request received */ - CODE void (*ind_disassociate)(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *eadr, uint8_t reason); + CODE void (*ind_disassociate)(MACHANDLE mac, FAR uint8_t *eadr, + uint8_t reason); /* Beacon notification */ - CODE void (*ind_beaconnotify)(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *bsn, FAR struct ieee802154_pan_desc_s *pandesc, + CODE void (*ind_beaconnotify)(MACHANDLE mac, FAR uint8_t *bsn, + FAR struct ieee802154_pan_desc_s *pandesc, FAR uint8_t *sdu, int sdulen); /* GTS management request received */ - CODE void (*ind_gts)(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *devaddr, FAR uint8_t *characteristics); + CODE void (*ind_gts)(MACHANDLE mac, FAR uint8_t *devaddr, + FAR uint8_t *characteristics); /* Orphan device detected */ - CODE void (*ind_orphan)(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *orphanaddr); + CODE void (*ind_orphan)(MACHANDLE mac, FAR uint8_t *orphanaddr); - CODE void (*ind_commstatus)(FAR struct ieee802154_mac_s *mac, - uint16_t panid, FAR uint8_t *src, - FAR uint8_t *dst, int status); + CODE void (*ind_commstatus)(MACHANDLE mac, uint16_t panid, + FAR uint8_t *src, FAR uint8_t *dst, + int status); - CODE void (*ind_syncloss)(FAR struct ieee802154_mac_s *mac, int reason); -}; - -struct ieee802154_mac_s -{ - /* Publicly visiable part of the MAC interface */ - - struct ieee802154_macops_s ops; - - /* MAC private data may follow */ + CODE void (*ind_syncloss)(MACHANDLE mac, int reason); }; #ifdef __cplusplus @@ -1109,13 +1009,11 @@ struct ieee802154_radio_s; /* Forward reference */ * radiodev - an instance of an IEEE 802.15.4 radio * * Returned Value: - * A MAC structure that has pointers to MAC operations - * and responses. + * An opaque reference to the MAC state data. * ****************************************************************************/ -FAR struct ieee802154_mac_s * - mac802154_create(FAR struct ieee802154_radio_s *radiodev); +MACHANDLE mac802154_create(FAR struct ieee802154_radio_s *radiodev); /**************************************************************************** * Name: mac802154dev_register @@ -1135,7 +1033,7 @@ FAR struct ieee802154_mac_s * * ****************************************************************************/ -int mac802154dev_register(FAR struct ieee802154_mac_s *mac, int minor); +int mac802154dev_register(MACHANDLE mac, int minor); /**************************************************************************** * Name: mac802154netdev_register @@ -1153,7 +1051,245 @@ int mac802154dev_register(FAR struct ieee802154_mac_s *mac, int minor); * ****************************************************************************/ -int mac802154netdev_register(FAR struct ieee802154_mac_s *mac); +int mac802154netdev_register(MACHANDLE mac); + +/**************************************************************************** + * 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. + * + ****************************************************************************/ + +int mac802154_bind(MACHANDLE mac, FAR const struct ieee802154_maccb_s *cb); + +/**************************************************************************** + * 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. + * + ****************************************************************************/ + +int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg); + +/**************************************************************************** + * MAC Interface Operations + ****************************************************************************/ + +/**************************************************************************** + * Name: mac802154_req_data + * + * Description: + * 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. + * + ****************************************************************************/ + +int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req); + +/**************************************************************************** + * Name: mac802154_req_purge + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_purge(MACHANDLE mac, uint8_t handle); + +/**************************************************************************** + * Name: mac802154_req_associate + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_associate(MACHANDLE mac + FAR struct ieee802154_assoc_req_s *req); + +/**************************************************************************** + * Name: mac802154_req_disassociate + * + * Description: + * The MLME-DISASSOCIATE.request primitive is used by an associated device to + * notify the coordinator of its intent to leave the PAN. It is also used by + * the coordinator to instruct an associated device to leave the PAN. + * Confirmation is returned via the + * struct ieee802154_maccb_s->conf_disassociate callback. + * + ****************************************************************************/ + +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, enum ieee802154_pib_attr_e attr); + +/**************************************************************************** + * Name: mac802154_req_gts + * + * Description: + * 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. + * + ****************************************************************************/ + +int mac802154_req_gts(MACHANDLE mac, FAR uint8_t *characteristics); + +/**************************************************************************** + * Name: mac802154_req_reset + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_reset(MACHANDLE mac, bool setdefaults); + +/**************************************************************************** + * Name: mac802154_req_rxenable + * + * Description: + * 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. + * + ****************************************************************************/ + +int mac802154_req_rxenable(MACHANDLE mac, bool deferrable, int ontime, + int duration); + +/**************************************************************************** + * Name: mac802154_req_scan + * + * Description: + * The MLME-SCAN.request primitive is used to initiate a channel scan over a + * given list of channels. A device can use a channel scan to measure 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 callback. + * This is a difference with the official 802.15.4 specification, implemented + * here to save memory. + * + ****************************************************************************/ + +int mac802154_req_scan(MACHANDLE mac, uint8_t type, uint32_t channels, + int duration); + +/**************************************************************************** + * 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. + * + ****************************************************************************/ + +int mac802154_req_set(MACHANDLE mac, int attribute, FAR uint8_t *value, + int valuelen); + +/**************************************************************************** + * Name: mac802154_req_start + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_start(MACHANDLE mac, uint16_t panid, int channel, + uint8_t bo, uint8_t fo, bool coord, bool batext, + bool realign); + +/**************************************************************************** + * Name: mac802154_req_sync + * + * Description: + * 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. + * + ****************************************************************************/ + +int mac802154_req_sync(MACHANDLE mac, int channel, bool track); + +/**************************************************************************** + * Name: mac802154_req_poll + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_poll(MACHANDLE mac, FAR uint8_t *coordaddr); + +/**************************************************************************** + * Name: mac802154_rsp_associate + * + * Description: + * The MLME-ASSOCIATE.response primitive is used to initiate a response to an + * MLME-ASSOCIATE.indication primitive. + * + ****************************************************************************/ + +int mac802154_rsp_associate(MACHANDLE mac, uint8_t eadr, uint16_t saddr, + int status); + +/**************************************************************************** + * Name: mac802154_rsp_orphan + * + * Description: + * The MLME-ORPHAN.response primitive allows the next higher layer of a + * coordinator to respond to the MLME-ORPHAN.indication primitive. + * + ****************************************************************************/ + +int mac802154_rsp_orphan(MACHANDLE mac, FAR uint8_t *orphanaddr, + uint16_t saddr, bool associated); #undef EXTERN #ifdef __cplusplus diff --git a/wireless/ieee802154/mac802154.c b/wireless/ieee802154/mac802154.c index a1bf2655341..693e2db7711 100644 --- a/wireless/ieee802154/mac802154.c +++ b/wireless/ieee802154/mac802154.c @@ -55,13 +55,13 @@ * Private Types ****************************************************************************/ -/* The privmac structure is an extension of the public ieee802154_mac_s type. - * It contains storage for the IEEE802.15.4 MIB attributes. +/* The privmac structure holds the internal state of the MAC and is the + * underlying represention of the opaque MACHANDLE. It contains storage for + * the IEEE802.15.4 MIB attributes. */ struct ieee802154_privmac_s { - 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 */ @@ -104,75 +104,6 @@ struct ieee802154_privmac_s #endif }; -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/* MAC Data Service (MCPS) functions */ - -static int mac802154_req_data(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_data_req_s *req); -static int mac802154_req_purge(FAR struct ieee802154_mac_s *mac, - uint8_t handle); - -/* MAC Sublayer Management Entity (MLME) functions */ - -static int mac802154_req_associate(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_assoc_req_s *req); -static int mac802154_req_disassociate(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_disassoc_req_s *req); -static int mac802154_req_get(FAR struct ieee802154_mac_s *mac, - enum ieee802154_pib_attr_e attr); -static int mac802154_req_gts(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *characteristics); -static int mac802154_req_reset(FAR struct ieee802154_mac_s *mac, - bool setdefaults); -static int mac802154_req_rxenable(FAR struct ieee802154_mac_s *mac, - bool deferrable, int ontime, int duration); -static int mac802154_req_scan(FAR struct ieee802154_mac_s *mac, - uint8_t type, uint32_t channels, int duration); -static int mac802154_req_set(FAR struct ieee802154_mac_s *mac, - int attribute, FAR uint8_t *value, int valuelen); -static int mac802154_req_start(FAR struct ieee802154_mac_s *mac, - uint16_t panid, int channel, uint8_t bo, uint8_t fo, - bool coord, bool batext, bool realign); -static int mac802154_req_sync(FAR struct ieee802154_mac_s *mac, - int channel, bool track); -static int mac802154_req_poll(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *coordaddr); -static int mac802154_rsp_associate(FAR struct ieee802154_mac_s *mac, - uint8_t eadr, uint16_t saddr, int status); -static int mac802154_rsp_orphan(FAR struct ieee802154_mac_s *mac, - 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 - ****************************************************************************/ - -static const struct ieee802154_macops_s mac802154ops = -{ - .req_data = mac802154_req_data, - .req_purge = mac802154_req_purge, - .req_associate = mac802154_req_associate, - .req_disassociate = mac802154_req_disassociate, - .req_get = mac802154_req_get, - .req_gts = mac802154_req_gts, - .req_reset = mac802154_req_reset, - .req_rxenable = mac802154_req_rxenable, - .req_scan = mac802154_req_scan, - .req_set = mac802154_req_set, - .req_start = mac802154_req_start, - .req_sync = mac802154_req_sync, - .req_poll = mac802154_req_poll, - .rsp_associate = mac802154_rsp_associate, - .rsp_orphan = mac802154_rsp_orphan, -}; - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -241,276 +172,55 @@ static int mac802154_applymib(FAR struct ieee802154_privmac_s *priv) } /**************************************************************************** - * API Functions + * Public Functions ****************************************************************************/ /**************************************************************************** - * Name: mac802154_reqdata + * Name: mac802154_create * * Description: - * 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. + * Create a 802.15.4 MAC device from a 802.15.4 compatible radio device. + * + * The returned MAC structure should be passed to either the next highest + * layer in the network stack, or registered with a mac802154dev character + * or network drivers. In any of these scenarios, the next highest layer + * should register a set of callbacks with the MAC layer by setting the + * mac->cbs member. + * + * 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 + * character device via mac802154_device.c. + * + * Input Parameters: + * radiodev - an instance of an IEEE 802.15.4 radio + * + * Returned Value: + * An opaque reference to the MAC state data. * ****************************************************************************/ -static int mac802154_req_data(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_data_req_s *req) +MACHANDLE mac802154_create(FAR struct ieee802154_radio_s *radiodev) { - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} + FAR struct ieee802154_privmac_s *mac; -/**************************************************************************** - * Name: mac802154_reqpurge - * - * 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. - * - ****************************************************************************/ + /* Allocate object */ -static int mac802154_req_purge(FAR struct ieee802154_mac_s *mac, - uint8_t handle) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} + mac = (FAR struct ieee802154_privmac_s *) + kmm_zalloc(sizeof(struct ieee802154_privmac_s)); -/**************************************************************************** - * Name: mac802154_req_associate - * - * 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. - * - ****************************************************************************/ + if (mac == NULL) + { + return NULL; + } -static int mac802154_req_associate(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_assoc_req_s *req) -{ - FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} + /* Initialize fields */ -/**************************************************************************** - * Name: mac802154_req_disassociate - * - * Description: - * The MLME-DISASSOCIATE.request primitive is used by an associated device to - * notify the coordinator of its intent to leave the PAN. It is also used by - * the coordinator to instruct an associated device to leave the PAN. - * Confirmation is returned via the - * struct ieee802154_maccb_s->conf_disassociate callback. - * - ****************************************************************************/ + mac->radio = radiodev; -static int mac802154_req_disassociate(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_disassoc_req_s *req) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} + mac802154_defaultmib(mac); + mac802154_applymib(mac); -/**************************************************************************** - * 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. - * - ****************************************************************************/ - -static int mac802154_req_get(FAR struct ieee802154_mac_s *mac, - enum ieee802154_pib_attr_e attr) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} - -/**************************************************************************** - * Name: mac802154_req_gts - * - * Description: - * 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. - * - ****************************************************************************/ - -static int mac802154_req_gts(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *characteristics) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} - -/**************************************************************************** - * Name: mac802154_req_reset - * - * 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. - * - ****************************************************************************/ - -static int mac802154_req_reset(FAR struct ieee802154_mac_s *mac, - bool setdefaults) -{ - FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac; - return -ENOTTY; -} - -/**************************************************************************** - * Name: mac802154_req_rxenable - * - * Description: - * 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. - * - ****************************************************************************/ - -static int mac802154_req_rxenable(FAR struct ieee802154_mac_s *mac, - bool deferrable, int ontime, int duration) -{ - FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} - -/**************************************************************************** - * Name: mac802154_req_scan - * - * Description: - * The MLME-SCAN.request primitive is used to initiate a channel scan over a - * given list of channels. A device can use a channel scan to measure 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 callback. - * This is a difference with the official 802.15.4 specification, implemented - * here to save memory. - * - ****************************************************************************/ - -static int mac802154_req_scan(FAR struct ieee802154_mac_s *mac, - uint8_t type, uint32_t channels, int duration) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} - -/**************************************************************************** - * 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. - * - ****************************************************************************/ - -static int mac802154_req_set(FAR struct ieee802154_mac_s *mac, - int attribute, FAR uint8_t *value, int valuelen) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} - -/**************************************************************************** - * Name: mac802154_req_start - * - * 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. - * - ****************************************************************************/ - -static int mac802154_req_start(FAR struct ieee802154_mac_s *mac, - uint16_t panid, int channel, uint8_t bo, - uint8_t fo, bool coord, bool batext, - bool realign) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} - -/**************************************************************************** - * Name: mac802154_req_sync - * - * Description: - * 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. - * - ****************************************************************************/ - -static int mac802154_req_sync(FAR struct ieee802154_mac_s *mac, - int channel, bool track) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} - -/**************************************************************************** - * Name: mac802154_req_poll - * - * 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. - * - ****************************************************************************/ - -static int mac802154_req_poll(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *coordaddr) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} - -/**************************************************************************** - * Name: mac802154_rsp_associate - * - * Description: - * The MLME-ASSOCIATE.response primitive is used to initiate a response to an - * MLME-ASSOCIATE.indication primitive. - * - ****************************************************************************/ - -static int mac802154_rsp_associate(FAR struct ieee802154_mac_s *mac, - uint8_t eadr, uint16_t saddr, int status) -{ - FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; -} - -/**************************************************************************** - * Name: mac802154_rsp_orphan - * - * Description: - * The MLME-ORPHAN.response primitive allows the next higher layer of a - * coordinator to respond to the MLME-ORPHAN.indication primitive. - * - ****************************************************************************/ - -static int mac802154_rsp_orphan(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *orphanaddr, uint16_t saddr, - bool associated) -{ - FAR struct ieee802154_privmac_s *priv = - (FAR struct ieee802154_privmac_s *)mac; - return -ENOTTY; + return (MACHANDLE)mac; } /**************************************************************************** @@ -528,8 +238,7 @@ static int mac802154_rsp_orphan(FAR struct ieee802154_mac_s *mac, * ****************************************************************************/ -static int mac802154_bind(FAR struct ieee802154_mac_s *mac, - FAR const struct ieee802154_maccb_s *cb) +int mac802154_bind(MACHANDLE mac, FAR const struct ieee802154_maccb_s *cb) { FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; @@ -554,8 +263,7 @@ static int mac802154_bind(FAR struct ieee802154_mac_s *mac, * ****************************************************************************/ -static int mac802154_ioctl(FAR struct ieee802154_mac_s *mac, int cmd, - unsigned long arg) +int mac802154_ioctl(MACHANDLE mac, int cmd, unsigned long arg) { FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; @@ -576,59 +284,267 @@ static int mac802154_ioctl(FAR struct ieee802154_mac_s *mac, int cmd, ret = priv->radio->ioctl(priv->radio, cmd, arg); } } -#endif /**************************************************************************** - * Public Functions + * MAC Interface Operations ****************************************************************************/ /**************************************************************************** - * Name: mac802154_create + * Name: mac802154_req_data * * Description: - * Create a 802.15.4 MAC device from a 802.15.4 compatible radio device. - * - * The returned MAC structure should be passed to either the next highest - * layer in the network stack, or registered with a mac802154dev character - * or network drivers. In any of these scenarios, the next highest layer - * should register a set of callbacks with the MAC layer by setting the - * mac->cbs member. - * - * 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 - * character device via mac802154_device.c. - * - * Input Parameters: - * radiodev - an instance of an IEEE 802.15.4 radio - * - * Returned Value: - * A MAC structure that has pointers to MAC operations - * and responses. + * 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. * ****************************************************************************/ -FAR struct ieee802154_mac_s * - mac802154_create(FAR struct ieee802154_radio_s *radiodev) +int mac802154_req_data(MACHANDLE mac, FAR struct ieee802154_data_req_s *req) { - FAR struct ieee802154_privmac_s *mac; - - /* Allocate object */ - - mac = (FAR struct ieee802154_privmac_s *) - kmm_zalloc(sizeof(struct ieee802154_privmac_s)); - - if (mac == NULL) - { - return NULL; - } - - /* Initialize fields */ - - mac->radio = radiodev; - mac->pubmac.ops = mac802154ops; - - mac802154_defaultmib(mac); - mac802154_applymib(mac); - - return &mac->pubmac; + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_purge + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_purge(MACHANDLE mac, uint8_t handle) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_associate + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_associate(MACHANDLE mac + FAR struct ieee802154_assoc_req_s *req) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_disassociate + * + * Description: + * The MLME-DISASSOCIATE.request primitive is used by an associated device to + * notify the coordinator of its intent to leave the PAN. It is also used by + * the coordinator to instruct an associated device to leave the PAN. + * Confirmation is returned via the + * struct ieee802154_maccb_s->conf_disassociate callback. + * + ****************************************************************************/ + +int mac802154_req_disassociate(MACHANDLE mac, + FAR struct ieee802154_disassoc_req_s *req) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)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, enum ieee802154_pib_attr_e attr) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_gts + * + * Description: + * 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. + * + ****************************************************************************/ + +int mac802154_req_gts(MACHANDLE mac, FAR uint8_t *characteristics) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_reset + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_reset(MACHANDLE mac, bool setdefaults) +{ + FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *) mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_rxenable + * + * Description: + * 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. + * + ****************************************************************************/ + +int mac802154_req_rxenable(MACHANDLE mac, bool deferrable, int ontime, + int duration) +{ + FAR struct ieee802154_privmac_s * priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_scan + * + * Description: + * The MLME-SCAN.request primitive is used to initiate a channel scan over a + * given list of channels. A device can use a channel scan to measure 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 callback. + * This is a difference with the official 802.15.4 specification, implemented + * here to save memory. + * + ****************************************************************************/ + +int mac802154_req_scan(MACHANDLE mac, uint8_t type, uint32_t channels, + int duration) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * 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. + * + ****************************************************************************/ + +int mac802154_req_set(MACHANDLE mac, int attribute, FAR uint8_t *value, + int valuelen) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_start + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_start(MACHANDLE mac, uint16_t panid, int channel, + uint8_t bo, uint8_t fo, bool coord, bool batext, + bool realign) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_sync + * + * Description: + * 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. + * + ****************************************************************************/ + +int mac802154_req_sync(MACHANDLE mac, int channel, bool track) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_req_poll + * + * 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. + * + ****************************************************************************/ + +int mac802154_req_poll(MACHANDLE mac, FAR uint8_t *coordaddr) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_rsp_associate + * + * Description: + * The MLME-ASSOCIATE.response primitive is used to initiate a response to an + * MLME-ASSOCIATE.indication primitive. + * + ****************************************************************************/ + +int mac802154_rsp_associate(MACHANDLE mac, uint8_t eadr, uint16_t saddr, + int status) +{ + FAR struct ieee802154_privmac_s *priv = (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; +} + +/**************************************************************************** + * Name: mac802154_rsp_orphan + * + * Description: + * The MLME-ORPHAN.response primitive allows the next higher layer of a + * coordinator to respond to the MLME-ORPHAN.indication primitive. + * + ****************************************************************************/ + +int mac802154_rsp_orphan(MACHANDLE mac, FAR uint8_t *orphanaddr, + uint16_t saddr, bool associated) +{ + FAR struct ieee802154_privmac_s *priv = + (FAR struct ieee802154_privmac_s *)mac; + return -ENOTTY; } diff --git a/wireless/ieee802154/mac802154_device.c b/wireless/ieee802154/mac802154_device.c index 83e33f8cf38..fde4cab707d 100644 --- a/wireless/ieee802154/mac802154_device.c +++ b/wireless/ieee802154/mac802154_device.c @@ -66,15 +66,14 @@ struct mac802154_devwrapper_s { - FAR struct ieee802154_mac_s *md_mac; /* Saved binding to the mac layer */ - sem_t md_exclsem; /* Exclusive device access */ + MACHANDLE md_mac; /* Saved binding to the mac layer */ + sem_t md_exclsem; /* Exclusive device access */ /* The following is a singly linked list of open references to the * MAC device. */ FAR struct mac802154_open_s *md_open; - FAR struct mac802154dev_dwait_s *md_dwait; }; @@ -452,7 +451,7 @@ static int mac802154dev_ioctl(FAR struct file *filep, int cmd, { FAR struct inode *inode; FAR struct mac802154_devwrapper_s *dev; - FAR struct ieee802154_mac_s *mac; + MACHANDLE mac; int ret; DEBUGASSERT(filep != NULL && filep->f_priv != NULL && @@ -484,8 +483,8 @@ static int mac802154dev_ioctl(FAR struct file *filep, int cmd, return ret; } -void mac802154dev_conf_data(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_data_conf_s *conf) +void mac802154dev_conf_data(MACHANDLE mac, + FAR struct ieee802154_data_conf_s *conf) { FAR struct mac802154_devwrapper_s *dev; FAR struct mac802154dev_dwait_s *curr; @@ -537,7 +536,7 @@ void mac802154dev_conf_data(FAR struct ieee802154_mac_s *mac, * ****************************************************************************/ -int mac802154dev_register(FAR struct ieee802154_mac_s *mac, int minor) +int mac802154dev_register(MACHANDLE mac, int minor) { FAR struct mac802154_devwrapper_s *dev; char devname[DEVNAME_FMTLEN]; diff --git a/wireless/ieee802154/mac802154_netdev.c b/wireless/ieee802154/mac802154_netdev.c index 6dd798f24b5..616d57adfd0 100644 --- a/wireless/ieee802154/mac802154_netdev.c +++ b/wireless/ieee802154/mac802154_netdev.c @@ -111,25 +111,25 @@ /* This is our private version of the MAC callback stucture */ -struct mac802154_callback_s +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 */ - FAR struct mac802154_driver_s *mc_priv; /* Our priv data */ + FAR struct macnet_driver_s *mc_priv; /* Our priv data */ }; -/* The mac802154_driver_s encapsulates all state information for a single +/* The macnet_driver_s encapsulates all state information for a single * IEEE802.15.4 MAC interface. */ -struct mac802154_driver_s +struct macnet_driver_s { /* This holds the information visible to the NuttX network */ - struct ieee802154_driver_s md_dev; /* Interface understood by the network */ - FAR struct ieee802154_mac_s *md_mac; /* Contained MAC interface */ - struct mac802154_callback_s md_cb; /* Callback information */ + struct ieee802154_driver_s md_dev; /* Interface understood by the network */ + struct macnet_callback_s md_cb; /* Callback information */ + MACHANDLE md_mac; /* Contained MAC interface */ /* For internal use by this driver */ @@ -140,20 +140,6 @@ struct mac802154_driver_s struct work_s md_pollwork; /* For deferring poll work to the work queue */ }; -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/* A single packet buffer per device is used here. There might be multiple - * packet buffers in a more complex, pipelined design. - */ - -static uint8_t g_pktbuf[MAX_NET_DEV_MTU + CONFIG_NET_GUARDSIZE]; - -/* Driver state structure */ - -static struct mac802154_driver_s g_skel[CONFIG_IEEE802154_NETDEV_NINTERFACES]; - /**************************************************************************** * Private Function Prototypes ****************************************************************************/ @@ -161,93 +147,84 @@ static struct mac802154_driver_s g_skel[CONFIG_IEEE802154_NETDEV_NINTERFACES]; /* IEE802.15.4 MAC callback functions ***************************************/ /* Asynchronous confirmations to requests */ -static void mac802154_conf_data(FAR struct ieee802154_mac_s *mac, +static void macnet_conf_data(MACHANDLE mac, FAR struct ieee802154_data_conf_s *conf); -static void mac802154_conf_purge(FAR struct ieee802154_mac_s *mac, - uint8_t handle, int status); -static void mac802154_conf_associate(FAR struct ieee802154_mac_s *mac, - uint16_t saddr, int status); -static void mac802154_conf_disassociate(FAR struct ieee802154_mac_s *mac, -static void mac802154_conf_get(FAR struct ieee802154_mac_s *mac, int status, - int attribute, FAR uint8_t *value, int valuelen); -static void mac802154_conf_gts(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *characteristics, int status); -static void mac802154_conf_reset(FAR struct ieee802154_mac_s *mac, - int status); -static void mac802154_conf_rxenable(FAR struct ieee802154_mac_s *mac, - int status); -static void mac802154_conf_scan(FAR struct ieee802154_mac_s *mac, - int status, uint8_t type, uint32_t unscanned, int rsltsize, - FAR uint8_t *edlist, FAR uint8_t *pandescs); -static void mac802154_conf_set(FAR struct ieee802154_mac_s *mac, int status, - int attribute); -static void mac802154_conf_start(FAR struct ieee802154_mac_s *mac, - int status); -static void mac802154_conf_poll(FAR struct ieee802154_mac_s *mac, +static void macnet_conf_purge(MACHANDLE mac, uint8_t handle, int status); +static void macnet_conf_associate(MACHANDLE mac, uint16_t saddr, int status); +static void macnet_conf_disassociate(MACHANDLE mac, int status); +static void macnet_conf_get(MACHANDLE mac, int status, int attribute, + FAR uint8_t *value, int valuelen); +static void macnet_conf_gts(MACHANDLE mac, FAR uint8_t *characteristics, int status); +static void macnet_conf_reset(MACHANDLE mac, int status); +static void macnet_conf_rxenable(MACHANDLE mac, int status); +static void macnet_conf_scan(MACHANDLE mac, int status, uint8_t type, + uint32_t unscanned, int rsltsize, FAR uint8_t *edlist, + FAR uint8_t *pandescs); +static void macnet_conf_set(MACHANDLE mac, int status, int attribute); +static void macnet_conf_start(MACHANDLE mac, int status); +static void macnet_conf_poll(MACHANDLE mac, int status); /* Asynchronous event indications, replied to synchronously with responses */ -static void mac802154_ind_data(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *buf, int len); -static void mac802154_ind_associate(FAR struct ieee802154_mac_s *mac, - uint16_t clipanid, FAR uint8_t *clieaddr); -static void mac802154_ind_disassociate(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *eadr, uint8_t reason); -static void mac802154_ind_beaconnotify(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *bsn, FAR struct ieee802154_pan_desc_s *pandesc, - FAR uint8_t *sdu, int sdulen); -static void mac802154_ind_gts(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *devaddr, FAR uint8_t *characteristics); -static void mac802154_ind_orphan(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *orphanaddr); -static void mac802154_ind_commstatus(FAR struct ieee802154_mac_s *mac, - uint16_t panid, FAR uint8_t *src, FAR uint8_t *dst, - int status); -static void mac802154_ind_syncloss(FAR struct ieee802154_mac_s *mac, - int reason); +static void macnet_ind_data(MACHANDLE mac, FAR uint8_t *buf, int len); +static void macnet_ind_associate(MACHANDLE mac, uint16_t clipanid, + FAR uint8_t *clieaddr); +static void macnet_ind_disassociate(MACHANDLE mac, FAR uint8_t *eadr, + uint8_t reason); +static void macnet_ind_beaconnotify(MACHANDLE mac, FAR uint8_t *bsn, + FAR struct ieee802154_pan_desc_s *pandesc, FAR uint8_t *sdu, + int sdulen); +static void macnet_ind_gts(MACHANDLE mac, FAR uint8_t *devaddr, + FAR uint8_t *characteristics); +static void macnet_ind_orphan(MACHANDLE mac, FAR uint8_t *orphanaddr); +static void macnet_ind_commstatus(MACHANDLE mac, uint16_t panid, + FAR uint8_t *src, FAR uint8_t *dst, int status); +static void macnet_ind_syncloss(MACHANDLE mac, int reason); /* Network interface support ************************************************/ /* Common TX logic */ -static int mac802154_transmit(FAR struct mac802154_driver_s *priv); -static int mac802154_txpoll(FAR struct net_driver_s *dev); +static int macnet_transmit(FAR struct macnet_driver_s *priv); +static int macnet_txpoll(FAR struct net_driver_s *dev); /* Frame transfer */ -static void mac802154_receive(FAR struct mac802154_driver_s *priv); -static void mac802154_txdone(FAR struct mac802154_driver_s *priv); +static void macnet_receive(FAR struct macnet_driver_s *priv); +static void macnet_txdone(FAR struct macnet_driver_s *priv); -static void mac802154_transfer_work(FAR void *arg); -static int mac802154_transfer(int irq, FAR void *context, FAR void *arg); +static void macnet_transfer_work(FAR void *arg); +static int macnet_transfer(int irq, FAR void *context, FAR void *arg); /* Watchdog timer expirations */ -static void mac802154_txtimeout_work(FAR void *arg); -static void mac802154_txtimeout_expiry(int argc, wdparm_t arg, ...); +static void macnet_txtimeout_work(FAR void *arg); +static void macnet_txtimeout_expiry(int argc, wdparm_t arg, ...); -static void mac802154_poll_work(FAR void *arg); -static void mac802154_poll_expiry(int argc, wdparm_t arg, ...); +static void macnet_poll_work(FAR void *arg); +static void macnet_poll_expiry(int argc, wdparm_t arg, ...); /* NuttX callback functions */ -static int mac802154_ifup(FAR struct net_driver_s *dev); -static int mac802154_ifdown(FAR struct net_driver_s *dev); +static int macnet_ifup(FAR struct net_driver_s *dev); +static int macnet_ifdown(FAR struct net_driver_s *dev); -static void mac802154_txavail_work(FAR void *arg); -static int mac802154_txavail(FAR struct net_driver_s *dev); +static void macnet_txavail_work(FAR void *arg); +static int macnet_txavail(FAR struct net_driver_s *dev); #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) -static int mac802154_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac); +static int macnet_addmac(FAR struct net_driver_s *dev, + FAR const uint8_t *mac); #ifdef CONFIG_NET_IGMP -static int mac802154_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac); +static int macnet_rmmac(FAR struct net_driver_s *dev, + FAR const uint8_t *mac); #endif #ifdef CONFIG_NET_ICMPv6 -static void mac802154_ipv6multicast(FAR struct mac802154_driver_s *priv); +static void macnet_ipv6multicast(FAR struct macnet_driver_s *priv); #endif #endif #ifdef CONFIG_NETDEV_IOCTL -static int mac802154_ioctl(FAR struct net_driver_s *dev, int cmd, long arg); +static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd, long arg); #endif /**************************************************************************** @@ -255,367 +232,352 @@ static int mac802154_ioctl(FAR struct net_driver_s *dev, int cmd, long arg); ****************************************************************************/ /**************************************************************************** - * Name: mac802154_conf_data + * Name: macnet_conf_data * * Description: * Data frame was received by remote device * ****************************************************************************/ -static void mac802154_conf_data(FAR struct ieee802154_mac_s *mac, - FAR struct ieee802154_data_conf_s *conf) +static void macnet_conf_data(MACHANDLE mac, + FAR struct ieee802154_data_conf_s *conf) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_purge + * Name: macnet_conf_purge * * Description: * Data frame was purged * ****************************************************************************/ -static void mac802154_conf_purge(FAR struct ieee802154_mac_s *mac, - uint8_t handle, int status) +static void macnet_conf_purge(MACHANDLE mac, uint8_t handle, int status) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_associate + * Name: macnet_conf_associate * * Description: * Association request completed * ****************************************************************************/ -static void mac802154_conf_associate(FAR struct ieee802154_mac_s *mac, - uint16_t saddr, int status) +static void macnet_conf_associate(MACHANDLE mac, uint16_t saddr, int status) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_disassociate + * Name: macnet_conf_disassociate * * Description: * Disassociation request completed * ****************************************************************************/ -static void mac802154_conf_disassociate(FAR struct ieee802154_mac_s *mac, +static void macnet_conf_disassociate(MACHANDLE mac, int status) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_get + * Name: macnet_conf_get * * Description: * PIvoata returned * ****************************************************************************/ -static void mac802154_conf_get(FAR struct ieee802154_mac_s *mac, int status, - int attribute, FAR uint8_t *value, - int valuelen) +static void macnet_conf_get(MACHANDLE mac, int status, int attribute, + FAR uint8_t *value, int valuelen) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_gts + * Name: macnet_conf_gts * * Description: * GTvoanagement completed * ****************************************************************************/ -static void mac802154_conf_gts(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *characteristics, int status) +static void macnet_conf_gts(MACHANDLE mac, FAR uint8_t *characteristics, + int status) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_reset + * Name: macnet_conf_reset * * Description: * MAveset completed * ****************************************************************************/ -static void mac802154_conf_reset(FAR struct ieee802154_mac_s *mac, - int status) +static void macnet_conf_reset(MACHANDLE mac, int status) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_rxenable + * Name: macnet_conf_rxenable * * Description: * ****************************************************************************/ -static void mac802154_conf_rxenable(FAR struct ieee802154_mac_s *mac, - int status) +static void macnet_conf_rxenable(MACHANDLE mac, int status) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_scan + * Name: macnet_conf_scan * * Description: * ****************************************************************************/ -static void mac802154_conf_scan(FAR struct ieee802154_mac_s *mac, - int status, uint8_t type, - uint32_t unscanned, int rsltsize, - FAR uint8_t *edlist, FAR uint8_t *pandescs) +static void macnet_conf_scan(MACHANDLE mac, int status, uint8_t type, + uint32_t unscanned, int rsltsize, + FAR uint8_t *edlist, FAR uint8_t *pandescs) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_set + * Name: macnet_conf_set * * Description: * ****************************************************************************/ -static void mac802154_conf_set(FAR struct ieee802154_mac_s *mac, int status, - int attribute) +static void macnet_conf_set(MACHANDLE mac, int status, int attribute) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_start + * Name: macnet_conf_start * * Description: * ****************************************************************************/ -static void mac802154_conf_start(FAR struct ieee802154_mac_s *mac, - int status) +static void macnet_conf_start(MACHANDLE mac, int status) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_conf_poll + * Name: macnet_conf_poll * * Description: * ****************************************************************************/ -static void mac802154_conf_poll(FAR struct ieee802154_mac_s *mac, - int status) +static void macnet_conf_poll(MACHANDLE mac, int status) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_ind_data + * Name: macnet_ind_data * * Description: * Data frame received * ****************************************************************************/ -static void mac802154_ind_data(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *buf, int len) +static void macnet_ind_data(MACHANDLE mac, FAR uint8_t *buf, int len) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_ind_associate + * Name: macnet_ind_associate * * Description: * Association request received * ****************************************************************************/ -static void mac802154_ind_associate(FAR struct ieee802154_mac_s *mac, - uint16_t clipanid, - FAR uint8_t *clieaddr) +static void macnet_ind_associate(MACHANDLE mac, uint16_t clipanid, + FAR uint8_t *clieaddr) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_ind_disassociate + * Name: macnet_ind_disassociate * * Description: * Disassociation request received * ****************************************************************************/ -static void mac802154_ind_disassociate(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *eadr, uint8_t reason) +static void macnet_ind_disassociate(MACHANDLE mac, FAR uint8_t *eadr, + uint8_t reason) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_ind_beaconnotify + * Name: macnet_ind_beaconnotify * * Description: * Beacon notification * ****************************************************************************/ -static void mac802154_ind_beaconnotify(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *bsn, - FAR struct ieee802154_pan_desc_s *pandesc, - FAR uint8_t *sdu, int sdulen) +static void macnet_ind_beaconnotify(MACHANDLE mac, FAR uint8_t *bsn, + FAR struct ieee802154_pan_desc_s *pandesc, + FAR uint8_t *sdu, int sdulen) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_ind_gts + * Name: macnet_ind_gts * * Description: * GTS management request received * ****************************************************************************/ -static void mac802154_ind_gts(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *devaddr, - FAR uint8_t *characteristics) +static void macnet_ind_gts(MACHANDLE mac, FAR uint8_t *devaddr, + FAR uint8_t *characteristics) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_ind_orphan + * Name: macnet_ind_orphan * * Description: * Orphan device detected * ****************************************************************************/ -static void mac802154_ind_orphan(FAR struct ieee802154_mac_s *mac, - FAR uint8_t *orphanaddr) +static void macnet_ind_orphan(MACHANDLE mac, FAR uint8_t *orphanaddr) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_ind_commstatus + * Name: macnet_ind_commstatus * * Description: * ****************************************************************************/ -static void mac802154_ind_commstatus(FAR struct ieee802154_mac_s *mac, - uint16_t panid, FAR uint8_t *src, - FAR uint8_t *dst, int status) +static void macnet_ind_commstatus(MACHANDLE mac, uint16_t panid, + FAR uint8_t *src, FAR uint8_t *dst, + int status) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_ind_syncloss + * Name: macnet_ind_syncloss * * Description: * ****************************************************************************/ -static void mac802154_ind_syncloss(FAR struct ieee802154_mac_s *mac, - int reason) +static void macnet_ind_syncloss(MACHANDLE mac, int reason) { - FAR struct mac802154_callback_s *cb = (FAR struct mac802154_callback_s *)mac; - FAR struct mac802154_driver_s *priv; + FAR struct macnet_callback_s *cb = (FAR struct macnet_callback_s *)mac; + FAR struct macnet_driver_s *priv; DEBUGASSERT(cb != NULL && cb->mc_priv != NULL); priv = cb->mc_priv; } /**************************************************************************** - * Name: mac802154_transmit + * Name: macnet_transmit * * Description: * Start hardware transmission. Called either from the txdone interrupt @@ -633,7 +595,7 @@ static void mac802154_ind_syncloss(FAR struct ieee802154_mac_s *mac, * ****************************************************************************/ -static int mac802154_transmit(FAR struct mac802154_driver_s *priv) +static int macnet_transmit(FAR struct macnet_driver_s *priv) { /* Verify that the hardware is ready to send another packet. If we get * here, then we are committed to sending a packet; Higher level logic @@ -651,12 +613,12 @@ static int mac802154_transmit(FAR struct mac802154_driver_s *priv) /* Setup the TX timeout watchdog (perhaps restarting the timer) */ (void)wd_start(priv->md_txtimeout, skeleton_TXTIMEOUT, - mac802154_txtimeout_expiry, 1, (wdparm_t)priv); + macnet_txtimeout_expiry, 1, (wdparm_t)priv); return OK; } /**************************************************************************** - * Name: mac802154_txpoll + * Name: macnet_txpoll * * Description: * The transmitter is available, check if the network has any outgoing @@ -679,9 +641,9 @@ static int mac802154_transmit(FAR struct mac802154_driver_s *priv) * ****************************************************************************/ -static int mac802154_txpoll(FAR struct net_driver_s *dev) +static int macnet_txpoll(FAR struct net_driver_s *dev) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)dev->d_private; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)dev->d_private; /* If the polling resulted in data that should be sent out, the field * i_framelist will set to a new, outgoing list of frames. @@ -691,7 +653,7 @@ static int mac802154_txpoll(FAR struct net_driver_s *dev) { /* And send the packet */ - mac802154_transmit(priv); + macnet_transmit(priv); } /* If zero is returned, the polling will continue until all connections have @@ -702,7 +664,7 @@ static int mac802154_txpoll(FAR struct net_driver_s *dev) } /**************************************************************************** - * Name: mac802154_receive + * Name: macnet_receive * * Description: * An interrupt was received indicating the availability of a new RX packet @@ -718,7 +680,7 @@ static int mac802154_txpoll(FAR struct net_driver_s *dev) * ****************************************************************************/ -static void mac802154_receive(FAR struct mac802154_driver_s *priv) +static void macnet_receive(FAR struct macnet_driver_s *priv) { FAR struct iob_s *iob; FAR struct iob_s *fptr; @@ -753,12 +715,12 @@ static void mac802154_receive(FAR struct mac802154_driver_s *priv) { /* And send the packet */ - mac802154_transmit(priv); + macnet_transmit(priv); } } /**************************************************************************** - * Name: mac802154_txdone + * Name: macnet_txdone * * Description: * An interrupt was received indicating that the last TX packet(s) is done @@ -774,7 +736,7 @@ static void mac802154_receive(FAR struct mac802154_driver_s *priv) * ****************************************************************************/ -static void mac802154_txdone(FAR struct mac802154_driver_s *priv) +static void macnet_txdone(FAR struct macnet_driver_s *priv) { int delay; @@ -794,11 +756,11 @@ static void mac802154_txdone(FAR struct mac802154_driver_s *priv) /* In any event, poll the network for new TX data */ - (void)devif_poll(&priv->md_dev, mac802154_txpoll); + (void)devif_poll(&priv->md_dev, macnet_txpoll); } /**************************************************************************** - * Name: mac802154_transfer_work + * Name: macnet_transfer_work * * Description: * Perform interrupt related work from the worker thread @@ -814,9 +776,9 @@ static void mac802154_txdone(FAR struct mac802154_driver_s *priv) * ****************************************************************************/ -static void mac802154_transfer_work(FAR void *arg) +static void macnet_transfer_work(FAR void *arg) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)arg; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)arg; /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work @@ -832,16 +794,16 @@ static void mac802154_transfer_work(FAR void *arg) /* Handle interrupts according to status bit settings */ - /* Check if we received an incoming packet, if so, call mac802154_receive() */ + /* Check if we received an incoming packet, if so, call macnet_receive() */ - mac802154_receive(priv); + macnet_receive(priv); - /* Check if a packet transmission just completed. If so, call mac802154_txdone. + /* Check if a packet transmission just completed. If so, call macnet_txdone. * This may disable further Tx interrupts if there are no pending * transmissions. */ - mac802154_txdone(priv); + macnet_txdone(priv); net_unlock(); /* Re-enable Ethernet interrupts */ @@ -850,7 +812,7 @@ static void mac802154_transfer_work(FAR void *arg) } /**************************************************************************** - * Name: mac802154_transfer + * Name: macnet_transfer * * Description: * Hardware interrupt handler @@ -866,9 +828,9 @@ static void mac802154_transfer_work(FAR void *arg) * ****************************************************************************/ -static int mac802154_transfer(int irq, FAR void *context, FAR void *arg) +static int macnet_transfer(int irq, FAR void *context, FAR void *arg) { - FAR struct mac802154_driver_s *priv = &g_skel[0]; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)arg; /* Disable further Ethernet interrupts. Because Ethernet interrupts are * also disabled if the TX timeout event occurs, there can be no race @@ -890,12 +852,12 @@ static int mac802154_transfer(int irq, FAR void *context, FAR void *arg) /* Schedule to perform the interrupt processing on the worker thread. */ - work_queue(ETHWORK, &priv->md_irqwork, mac802154_transfer_work, priv, 0); + work_queue(ETHWORK, &priv->md_irqwork, macnet_transfer_work, priv, 0); return OK; } /**************************************************************************** - * Name: mac802154_txtimeout_work + * Name: macnet_txtimeout_work * * Description: * Perform TX timeout related work from the worker thread @@ -911,9 +873,9 @@ static int mac802154_transfer(int irq, FAR void *context, FAR void *arg) * ****************************************************************************/ -static void mac802154_txtimeout_work(FAR void *arg) +static void macnet_txtimeout_work(FAR void *arg) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)arg; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)arg; /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work @@ -931,12 +893,12 @@ static void mac802154_txtimeout_work(FAR void *arg) /* Then poll the network for new XMIT data */ - (void)devif_poll(&priv->md_dev, mac802154_txpoll); + (void)devif_poll(&priv->md_dev, macnet_txpoll); net_unlock(); } /**************************************************************************** - * Name: mac802154_txtimeout_expiry + * Name: macnet_txtimeout_expiry * * Description: * Our TX watchdog timed out. Called from the timer interrupt handler. @@ -954,9 +916,9 @@ static void mac802154_txtimeout_work(FAR void *arg) * ****************************************************************************/ -static void mac802154_txtimeout_expiry(int argc, wdparm_t arg, ...) +static void macnet_txtimeout_expiry(int argc, wdparm_t arg, ...) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)arg; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)arg; /* Disable further Ethernet interrupts. This will prevent some race * conditions with interrupt work. There is still a potential race @@ -967,11 +929,11 @@ static void mac802154_txtimeout_expiry(int argc, wdparm_t arg, ...) /* Schedule to perform the TX timeout processing on the worker thread. */ - work_queue(ETHWORK, &priv->md_irqwork, mac802154_txtimeout_work, priv, 0); + work_queue(ETHWORK, &priv->md_irqwork, macnet_txtimeout_work, priv, 0); } /**************************************************************************** - * Name: mac802154_poll_process + * Name: macnet_poll_process * * Description: * Perform the periodic poll. This may be called either from watchdog @@ -987,12 +949,12 @@ static void mac802154_txtimeout_expiry(int argc, wdparm_t arg, ...) * ****************************************************************************/ -static inline void mac802154_poll_process(FAR struct mac802154_driver_s *priv) +static inline void macnet_poll_process(FAR struct macnet_driver_s *priv) { } /**************************************************************************** - * Name: mac802154_poll_work + * Name: macnet_poll_work * * Description: * Perform periodic polling from the worker thread @@ -1008,9 +970,9 @@ static inline void mac802154_poll_process(FAR struct mac802154_driver_s *priv) * ****************************************************************************/ -static void mac802154_poll_work(FAR void *arg) +static void macnet_poll_work(FAR void *arg) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)arg; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)arg; /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work @@ -1031,17 +993,17 @@ static void mac802154_poll_work(FAR void *arg) * progress, we will missing TCP time state updates? */ - (void)devif_timer(&priv->md_dev, mac802154_txpoll); + (void)devif_timer(&priv->md_dev, macnet_txpoll); /* Setup the watchdog poll timer again */ - (void)wd_start(priv->md_txpoll, skeleton_WDDELAY, mac802154_poll_expiry, 1, + (void)wd_start(priv->md_txpoll, skeleton_WDDELAY, macnet_poll_expiry, 1, (wdparm_t)priv); net_unlock(); } /**************************************************************************** - * Name: mac802154_poll_expiry + * Name: macnet_poll_expiry * * Description: * Periodic timer handler. Called from the timer interrupt handler. @@ -1058,17 +1020,17 @@ static void mac802154_poll_work(FAR void *arg) * ****************************************************************************/ -static void mac802154_poll_expiry(int argc, wdparm_t arg, ...) +static void macnet_poll_expiry(int argc, wdparm_t arg, ...) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)arg; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)arg; /* Schedule to perform the interrupt processing on the worker thread. */ - work_queue(ETHWORK, &priv->md_pollwork, mac802154_poll_work, priv, 0); + work_queue(ETHWORK, &priv->md_pollwork, macnet_poll_work, priv, 0); } /**************************************************************************** - * Name: mac802154_ifup + * Name: macnet_ifup * * Description: * NuttX Callback: Bring up the Ethernet interface when an IP address is @@ -1084,9 +1046,9 @@ static void mac802154_poll_expiry(int argc, wdparm_t arg, ...) * ****************************************************************************/ -static int mac802154_ifup(FAR struct net_driver_s *dev) +static int macnet_ifup(FAR struct net_driver_s *dev) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)dev->d_private; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)dev->d_private; #ifdef CONFIG_NET_IPv4 ninfo("Bringing up: %d.%d.%d.%d\n", @@ -1107,12 +1069,12 @@ static int mac802154_ifup(FAR struct net_driver_s *dev) #ifdef CONFIG_NET_ICMPv6 /* Set up IPv6 multicast address filtering */ - mac802154_ipv6multicast(priv); + macnet_ipv6multicast(priv); #endif /* Set and activate a timer process */ - (void)wd_start(priv->md_txpoll, skeleton_WDDELAY, mac802154_poll_expiry, 1, + (void)wd_start(priv->md_txpoll, skeleton_WDDELAY, macnet_poll_expiry, 1, (wdparm_t)priv); /* Enable the Ethernet interrupt */ @@ -1123,7 +1085,7 @@ static int mac802154_ifup(FAR struct net_driver_s *dev) } /**************************************************************************** - * Name: mac802154_ifdown + * Name: macnet_ifdown * * Description: * NuttX Callback: Stop the interface. @@ -1138,9 +1100,9 @@ static int mac802154_ifup(FAR struct net_driver_s *dev) * ****************************************************************************/ -static int mac802154_ifdown(FAR struct net_driver_s *dev) +static int macnet_ifdown(FAR struct net_driver_s *dev) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)dev->d_private; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)dev->d_private; irqstate_t flags; /* Disable the Ethernet interrupt */ @@ -1154,7 +1116,7 @@ static int mac802154_ifdown(FAR struct net_driver_s *dev) wd_cancel(priv->md_txtimeout); /* Put the EMAC in its reset, non-operational state. This should be - * a known configuration that will guarantee the mac802154_ifup() always + * a known configuration that will guarantee the macnet_ifup() always * successfully brings the interface back up. */ @@ -1166,7 +1128,7 @@ static int mac802154_ifdown(FAR struct net_driver_s *dev) } /**************************************************************************** - * Name: mac802154_txavail_work + * Name: macnet_txavail_work * * Description: * Perform an out-of-cycle poll on the worker thread. @@ -1182,9 +1144,9 @@ static int mac802154_ifdown(FAR struct net_driver_s *dev) * ****************************************************************************/ -static void mac802154_txavail_work(FAR void *arg) +static void macnet_txavail_work(FAR void *arg) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)arg; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)arg; /* Lock the network and serialize driver operations if necessary. * NOTE: Serialization is only required in the case where the driver work @@ -1202,14 +1164,14 @@ static void mac802154_txavail_work(FAR void *arg) /* If so, then poll the network for new XMIT data */ - (void)devif_poll(&priv->md_dev, mac802154_txpoll); + (void)devif_poll(&priv->md_dev, macnet_txpoll); } net_unlock(); } /**************************************************************************** - * Name: mac802154_txavail + * Name: macnet_txavail * * Description: * Driver callback invoked when new TX data is available. This is a @@ -1227,9 +1189,9 @@ static void mac802154_txavail_work(FAR void *arg) * ****************************************************************************/ -static int mac802154_txavail(FAR struct net_driver_s *dev) +static int macnet_txavail(FAR struct net_driver_s *dev) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)dev->d_private; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)dev->d_private; /* Is our single work structure available? It may not be if there are * pending interrupt actions and we will have to ignore the Tx @@ -1240,14 +1202,14 @@ static int mac802154_txavail(FAR struct net_driver_s *dev) { /* Schedule to serialize the poll on the worker thread. */ - work_queue(ETHWORK, &priv->md_pollwork, mac802154_txavail_work, priv, 0); + work_queue(ETHWORK, &priv->md_pollwork, macnet_txavail_work, priv, 0); } return OK; } /**************************************************************************** - * Name: mac802154_addmac + * Name: macnet_addmac * * Description: * NuttX Callback: Add the specified MAC address to the hardware multicast @@ -1265,9 +1227,9 @@ static int mac802154_txavail(FAR struct net_driver_s *dev) ****************************************************************************/ #if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) -static int mac802154_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) +static int macnet_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)dev->d_private; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)dev->d_private; /* Add the MAC address to the hardware multicast routing table */ @@ -1276,7 +1238,7 @@ static int mac802154_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac #endif /**************************************************************************** - * Name: mac802154_rmmac + * Name: macnet_rmmac * * Description: * NuttX Callback: Remove the specified MAC address from the hardware multicast @@ -1294,9 +1256,9 @@ static int mac802154_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac ****************************************************************************/ #ifdef CONFIG_NET_IGMP -static int mac802154_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) +static int macnet_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)dev->d_private; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)dev->d_private; /* Add the MAC address to the hardware multicast routing table */ @@ -1305,7 +1267,7 @@ static int mac802154_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) #endif /**************************************************************************** - * Name: mac802154_ipv6multicast + * Name: macnet_ipv6multicast * * Description: * Configure the IPv6 multicast MAC address. @@ -1321,7 +1283,7 @@ static int mac802154_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac) ****************************************************************************/ #ifdef CONFIG_NET_ICMPv6 -static void mac802154_ipv6multicast(FAR struct mac802154_driver_s *priv) +static void macnet_ipv6multicast(FAR struct macnet_driver_s *priv) { FAR struct net_driver_s *dev; uint16_t tmp16; @@ -1354,7 +1316,7 @@ static void mac802154_ipv6multicast(FAR struct mac802154_driver_s *priv) ninfo("IPv6 Multicast: %02x:%02x:%02x:%02x:%02x:%02x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - (void)mac802154_addmac(dev, mac); + (void)macnet_addmac(dev, mac); #ifdef CONFIG_NET_ICMPv6_AUTOCONF /* Add the IPv6 all link-local nodes Ethernet address. This is the @@ -1362,7 +1324,7 @@ static void mac802154_ipv6multicast(FAR struct mac802154_driver_s *priv) * packets. */ - (void)mac802154_addmac(dev, g_ipv6_ethallnodes.ether_addr_octet); + (void)macnet_addmac(dev, g_ipv6_ethallnodes.ether_addr_octet); #endif /* CONFIG_NET_ICMPv6_AUTOCONF */ @@ -1372,14 +1334,14 @@ static void mac802154_ipv6multicast(FAR struct mac802154_driver_s *priv) * packets. */ - (void)mac802154_addmac(dev, g_ipv6_ethallrouters.ether_addr_octet); + (void)macnet_addmac(dev, g_ipv6_ethallrouters.ether_addr_octet); #endif /* CONFIG_NET_ICMPv6_ROUTER */ } #endif /* CONFIG_NET_ICMPv6 */ /**************************************************************************** - * Name: mac802154_ioctl + * Name: macnet_ioctl * * Description: * Handle network IOCTL commands directed to this device. @@ -1397,9 +1359,9 @@ static void mac802154_ipv6multicast(FAR struct mac802154_driver_s *priv) ****************************************************************************/ #ifdef CONFIG_NETDEV_IOCTL -static int mac802154_ioctl(FAR struct net_driver_s *dev, int cmd, long arg) +static int macnet_ioctl(FAR struct net_driver_s *dev, int cmd, long arg) { - FAR struct mac802154_driver_s *priv = (FAR struct mac802154_driver_s *)dev->d_private; + FAR struct macnet_driver_s *priv = (FAR struct macnet_driver_s *)dev->d_private; int ret = -EINVAL; /* Check for IOCTLs aimed at the IEEE802.15.4 MAC layer */ @@ -1461,9 +1423,9 @@ static int mac802154_ioctl(FAR struct net_driver_s *dev, int cmd, long arg) * ****************************************************************************/ -int mac802154netdev_register(FAR struct ieee802154_mac_s *mac); +int mac802154netdev_register(MACHANDLE mac) { - FAR struct mac802154_driver_s *priv; + FAR struct macnet_driver_s *priv; FAR struct net_driver_s *dev; FAR uint8_t *pktbuf; int ret; @@ -1472,8 +1434,8 @@ int mac802154netdev_register(FAR struct ieee802154_mac_s *mac); /* Get the interface structure associated with this interface number. */ - priv = (FAR struct mac802154_driver_s *) - kmm_zalloc(sizeof(struct mac802154_driver_s)); + priv = (FAR struct macnet_driver_s *) + kmm_zalloc(sizeof(struct macnet_driver_s)); if (priv == NULL) { @@ -1497,15 +1459,15 @@ int mac802154netdev_register(FAR struct ieee802154_mac_s *mac); dev = &ieee->md_dev.i_dev; dev->d_buf = pktbuf; /* Single packet buffer */ - dev->d_ifup = mac802154_ifup; /* I/F up (new IP address) callback */ - dev->d_ifdown = mac802154_ifdown; /* I/F down callback */ - dev->d_txavail = mac802154_txavail; /* New TX data callback */ + dev->d_ifup = macnet_ifup; /* I/F up (new IP address) callback */ + dev->d_ifdown = macnet_ifdown; /* I/F down callback */ + dev->d_txavail = macnet_txavail; /* New TX data callback */ #ifdef CONFIG_NET_IGMP - dev->d_addmac = mac802154_addmac; /* Add multicast MAC address */ - dev->d_rmmac = mac802154_rmmac; /* Remove multicast MAC address */ + dev->d_addmac = macnet_addmac; /* Add multicast MAC address */ + dev->d_rmmac = macnet_rmmac; /* Remove multicast MAC address */ #endif #ifdef CONFIG_NETDEV_IOCTL - dev->d_ioctl = mac802154_ioctl; /* Handle network IOCTL commands */ + dev->d_ioctl = macnet_ioctl; /* Handle network IOCTL commands */ #endif dev->d_private = (FAR void *)priv; /* Used to recover private state from dev */ @@ -1522,26 +1484,26 @@ int mac802154netdev_register(FAR struct ieee802154_mac_s *mac); priv->md_cb.mc_priv = priv; maccb = &priv->md_cb.mc_cb; - 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; + maccb->conf_data = macnet_conf_data; + maccb->conf_purge = macnet_conf_purge; + maccb->conf_associate = macnet_conf_associate; + maccb->conf_disassociate = macnet_conf_disassociate; + maccb->conf_get = macnet_conf_get; + maccb->conf_gts = macnet_conf_gts; + maccb->conf_reset = macnet_conf_reset; + maccb->conf_rxenable = macnet_conf_rxenable; + maccb->conf_scan = macnet_conf_scan; + maccb->conf_set = macnet_conf_set; + maccb->conf_start = macnet_conf_start; + maccb->conf_poll = macnet_conf_poll; + maccb->ind_data = macnet_ind_data; + maccb->ind_associate = macnet_ind_associate; + maccb->ind_disassociate = macnet_ind_disassociate; + maccb->ind_beaconnotify = macnet_ind_beaconnotify; + maccb->ind_gts = macnet_ind_gts; + maccb->ind_orphan = macnet_ind_orphan; + maccb->ind_commstatus = macnet_ind_commstatus; + maccb->ind_syncloss = macnet_ind_syncloss; /* Bind the callback structure */ @@ -1563,7 +1525,7 @@ int mac802154netdev_register(FAR struct ieee802154_mac_s *mac); /* Put the interface in the down state. */ - mac802154_ifdown(dev); + macnet_ifdown(dev); /* Register the device with the OS so that socket IOCTLs can be performed */