wireless/ieee802154: Removes radio IOCTL. Starts bringing radio and MAC closer with well-defined interface.

This commit is contained in:
Anthony Merlino
2017-05-05 11:15:28 -04:00
parent abc15c8429
commit dd40014279
18 changed files with 270 additions and 1890 deletions
-7
View File
@@ -89,7 +89,6 @@
#define _CLIOCBASE (0x2400) /* Contactless modules ioctl commands */
#define _USBCBASE (0x2500) /* USB-C controller ioctl commands */
#define _MAC802154BASE (0x2600) /* 802.15.4 MAC ioctl commands */
#define _PHY802154BASE (0x2700) /* 802.15.4 Radio ioctl commands */
/* boardctl() commands share the same number space */
@@ -429,12 +428,6 @@
#define _MAC802154IOCVALID(c) (_IOC_TYPE(c)==_MAC802154BASE)
#define _MAC802154IOC(nr) _IOC(_MAC802154BASE,nr)
/* 802.15.4 Radio driver ioctl definitions **********************************/
/* (see nuttx/ieee802154/wireless/ieee802154_radio.h */
#define _PHY802154IOCVALID(c) (_IOC_TYPE(c)==_PHY802154BASE)
#define _PHY802154IOC(nr) _IOC(_PHY802154BASE,nr)
/* boardctl() command definitions *******************************************/
#define _BOARDIOCVALID(c) (_IOC_TYPE(c)==_BOARDBASE)
@@ -55,8 +55,6 @@
# include <net/if.h>
#endif
#include <nuttx/wireless/ieee802154/ieee802154_radio.h>
#include <nuttx/fs/ioctl.h>
/****************************************************************************
@@ -331,6 +329,8 @@ enum ieee802154_pib_attr_e
IEEE802154_PIB_MAC_PANCOORD_SHORT_ADDR,
};
#define IEEE802154_EADDR_LEN 8
/* IEEE 802.15.4 Device address
* The addresses in ieee802154 have several formats:
* No address : [none]
@@ -351,9 +351,10 @@ struct ieee802154_addr_s
enum ieee802154_addr_mode_e mode;
uint16_t panid; /* PAN identifier, can be IEEE802154_PAN_UNSPEC */
uint16_t saddr; /* short address */
uint8_t eaddr[8]; /* extended address */
uint16_t panid; /* PAN identifier, can be
* IEEE802154_PAN_UNSPEC */
uint16_t saddr; /* short address */
uint8_t eaddr[IEEE802154_EADDR_LEN]; /* extended address */
};
#define IEEE802154_ADDRSTRLEN 22 /* (2*2+1+8*2, PPPP/EEEEEEEEEEEEEEEE) */
@@ -454,15 +455,54 @@ struct ieee802154_pend_addr_s
struct ieee802154_addr_s addr[7]; /* Array of at most 7 addresses */
};
#ifdef CONFIG_IEEE802154_RANGING
#define IEEE802154_TXDESC_FIELDS \
uint8_t handle; \
uint32_t timestamp; \
uint8_t status;
#else
#define IEEE802154_TXDESC_FIELDS \
uint8_t handle; \
uint32_t timestamp; \
uint8_t status;
bool rng_rcvd; \
uint32_t rng_counter_start; \
uint32_t rng_counter_stop; \
uint32_t rng_tracking_interval; \
uint32_t rng_offset;\
uint8_t rng_fom;
#endif
struct ieee802154_txdesc_s
{
IEEE802154_TXDESC_FIELDS
/* TODO: Add slotting information for GTS transactions */
};
struct ieee802154_rxdesc_s
{
uint8_t lqi;
uint8_t rssi;
};
struct ieee802154_cca_s
{
uint8_t use_ed : 1; /* CCA using ED */
uint8_t use_cs : 1; /* CCA using carrier sense */
uint8_t edth; /* Energy detection threshold for CCA */
uint8_t csth; /* Carrier sense threshold for CCA */
};
/* Primitive Support Types ***************************************************/
union ieee802154_attr_val_u
union ieee802154_macattr_u
{
uint8_t eaddr[8];
uint8_t eaddr[IEEE802154_EADDR_LEN];
uint16_t saddr;
uint16_t pan_id;
uint16_t panid;
uint8_t coord_eaddr[8];
uint8_t coord_eaddr[IEEE802154_EADDR_LEN];
uint16_t coord_saddr;
bool is_assoc;
@@ -503,6 +543,25 @@ union ieee802154_attr_val_u
uint8_t dsn;
};
union ieee802154_phyattr_u
{
uint8_t channel;
int32_t txpwr
/* TODO: Fill this out as we implement supported get/set commands */
};
union ieee802154_secattr_u
{
/* TODO: Fill this out as we implement supported get/set commands */
};
union ieee802154_attr_val_u
{
union ieee802154_macattr_u mac;
union ieee802154_phyattr_u phy;
union ieee802154_secattr_u sec;
};
struct ieee802154_gts_info_s
{
uint8_t length : 4; /* Number of SF slots for GTS */
@@ -884,20 +943,6 @@ struct ieee802154_commstatus_ind_s
#endif
};
/*****************************************************************************
* Primitive: MLME-GET.request
*
* Description:
* Requests information about a given PIB attribute.
*
*****************************************************************************/
struct ieee802154_get_req_s
{
enum ieee802154_pib_attr_e pib_attr;
FAR union ieee802154_attr_val_u *attr_value;
};
/*****************************************************************************
* Primitive: MLME-GTS.request
*
@@ -1092,6 +1137,20 @@ struct ieee802154_scan_conf_s
#warning Figure out how to handle missing primitive semantics. See standard.
};
/*****************************************************************************
* Primitive: MLME-GET.request
*
* Description:
* Requests information about a given PIB attribute.
*
*****************************************************************************/
struct ieee802154_get_req_s
{
enum ieee802154_pib_attr_e pib_attr;
union ieee802154_attr_val_u attr_value;
};
/*****************************************************************************
* Primitive: MLME-SET.request
*
@@ -48,150 +48,18 @@
#include <stdbool.h>
#include <semaphore.h>
#ifdef CONFIG_NET_6LOWPAN
# include <net/if.h>
#endif
#include <nuttx/fs/ioctl.h>
#include <nuttx/wireless/ieee802154/ieee802154_mac.h>
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* IEEE 802.15.4 Radio Interface **********************************************/
/* This layer only knows radio frames. There are no 802.15.4 specific bits
* at this layer. */
/* Device modes */
#define IEEE802154_MODE_DEVICE 0x00
#define IEEE802154_MODE_COORD 0x01 /* avail in mrf24j40, but why? */
#define IEEE802154_MODE_PANCOORD 0x02
/* IEEE 802.15.4 Radio Character Driver IOCTL ********************************/
#define PHY802154IOC_SET_CHAN _PHY802154IOC(0x0001)
#define PHY802154IOC_GET_CHAN _PHY802154IOC(0x0002)
#define PHY802154IOC_SET_PANID _PHY802154IOC(0x0003)
#define PHY802154IOC_GET_PANID _PHY802154IOC(0x0004)
#define PHY802154IOC_SET_SADDR _PHY802154IOC(0x0005)
#define PHY802154IOC_GET_SADDR _PHY802154IOC(0x0006)
#define PHY802154IOC_SET_EADDR _PHY802154IOC(0x0007)
#define PHY802154IOC_GET_EADDR _PHY802154IOC(0x0008)
#define PHY802154IOC_SET_PROMISC _PHY802154IOC(0x0009)
#define PHY802154IOC_GET_PROMISC _PHY802154IOC(0x000A)
#define PHY802154IOC_SET_DEVMODE _PHY802154IOC(0x000B)
#define PHY802154IOC_GET_DEVMODE _PHY802154IOC(0x000C)
#define PHY802154IOC_SET_TXPWR _PHY802154IOC(0x000D)
#define PHY802154IOC_GET_TXPWR _PHY802154IOC(0x000E)
#define PHY802154IOC_SET_CCA _PHY802154IOC(0x000F)
#define PHY802154IOC_GET_CCA _PHY802154IOC(0x0010)
#define PHY802154IOC_ENERGYDETECT _PHY802154IOC(0x0011)
#define EADDR_SIZE 8 /* Extended address size */
/****************************************************************************
* Public Types
****************************************************************************/
/* Structures used with IEEE802.15.4 radio interface operations *************/
struct ieee802154_cca_s
{
uint8_t use_ed : 1; /* CCA using ED */
uint8_t use_cs : 1; /* CCA using carrier sense */
uint8_t edth; /* Energy detection threshold for CCA */
uint8_t csth; /* Carrier sense threshold for CCA */
};
struct ieee802154_packet_s
{
uint8_t len;
uint8_t data[127];
uint8_t lqi;
uint8_t rssi;
};
/* IOCTL command data argument **********************************************/
/* A pointer to this structure is passed as the argument of each IOCTL
* command.
*/
union ieee802154_radioarg_u
{
uint8_t channel; /* PHY802154IOC_GET/SET_CHAN */
uint16_t panid; /* PHY802154IOC_GET/SET_PANID */
uint16_t saddr; /* PHY802154IOC_GET/SET_SADDR */
uint8_t eaddr[EADDR_SIZE]; /* PHY802154IOC_GET/SET_EADDR */
bool promisc; /* PHY802154IOC_GET/SET_EADDR */
uint8_t devmode; /* PHY802154IOC_GET/SET_DEVMODE */
int32_t txpwr; /* PHY802154IOC_GET/SET_TXPWR */
bool energy; /* PHY802154IOC_ENERGYDETECT */
struct ieee802154_cca_s cca; /* PHY802154IOC_GET/SET_CCA */
};
#ifdef CONFIG_NET_6LOWPAN
/* For the case of network IOCTLs, the network IOCTL to the MAC network
* driver will include a device name like "wpan0" as the destination of
* the IOCTL command. The MAC layer will forward only the payload union
* to the radio IOCTL method.
*/
struct ieee802154_netradio_s
{
char ifr_name[IFNAMSIZ]; /* Interface name, e.g. "wpan0" */
union ieee802154_radioarg_u u; /* Data payload */
};
#endif
/* IEEE802.15.4 Radio Interface Operations **********************************/
/* This is a work-around to allow the MAC upper layer have a struct with
* identical members but with a different name. */
#ifdef CONFIG_IEEE802154_RANGING
#define IEEE802154_TXDESC_FIELDS \
uint8_t handle; \
uint32_t timestamp; \
uint8_t status;
#else
#define IEEE802154_TXDESC_FIELDS \
uint8_t handle; \
uint32_t timestamp; \
uint8_t status;
bool rng_rcvd; \
uint32_t rng_counter_start; \
uint32_t rng_counter_stop; \
uint32_t rng_tracking_interval; \
uint32_t rng_offset;\
uint8_t rng_fom;
#endif
struct ieee802154_txdesc_s
{
IEEE802154_TXDESC_FIELDS
/* TODO: Add slotting information for GTS transactions */
};
struct ieee802154_rxdesc_s
{
uint8_t lqi;
uint8_t rssi;
};
struct ieee802154_radiocb_s
{
CODE int (*poll_csma) (FAR const struct ieee802154_radiocb_s *radiocb,
@@ -213,11 +81,14 @@ struct ieee802154_radioops_s
{
CODE int (*bind) (FAR struct ieee802154_radio_s *radio,
FAR struct ieee802154_radiocb_s *radiocb);
CODE int (*ioctl)(FAR struct ieee802154_radio_s *radio, int cmd,
unsigned long arg);
CODE int (*rxenable)(FAR struct ieee802154_radio_s *radio, bool enable);
CODE int (*txnotify_csma)(FAR struct ieee802154_radio_s *radio);
CODE int (*txnotify_gts)(FAR struct ieee802154_radio_s *radio);
CODE int (*get_attr) (FAR struct ieee802154_radio_s *radio,
enum ieee802154_pib_attr_e pib_attr,
FAR union ieee802154_attr_val_u *attr_value);
CODE int (*set_attr) (FAR struct ieee802154_radio_s *radio,
enum ieee802154_pib_attr_e pib_attr,
FAR const union ieee802154_attr_val_u *attr_value);
};
struct ieee802154_radio_s
@@ -237,28 +108,6 @@ extern "C"
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: radio802154dev_register
*
* Description:
* Register a character driver to access the IEEE 802.15.4 radio from
* user-space
*
* Input Parameters:
* radio - Pointer to the radio struct to be registerd.
* devname - The name of the IEEE 802.15.4 radio to be registered.
*
* Returned Values:
* Zero (OK) is returned on success. Otherwise a negated errno value is
* returned to indicate the nature of the failure.
*
****************************************************************************/
#ifdef CONFIG_IEEE802154_DEV
int radio802154dev_register(FAR struct ieee802154_radio_s *radio,
FAR char *devname);
#endif
#undef EXTERN
#ifdef __cplusplus
}
-5
View File
@@ -65,11 +65,6 @@
#endif
#ifdef CONFIG_WIRELESS_IEEE802154
#ifdef CONFIG_IEEE802154_DEV
/* Include ieee802.15.4 radio IOCTL definitions */
# include <nuttx/wireless/ieee802154/ ieee802154_radio.h>
#endif
#ifdef CONFIG_IEEE802154_MAC
/* Include ieee802.15.4 MAC IOCTL definitions */