ieee802154/hal: remove set_rx_mode

This commit is contained in:
Jose Alamos 2020-11-18 14:01:31 +01:00 committed by Jose Alamos
parent 6d64b537ef
commit 7d14fb3571
No known key found for this signature in database
GPG Key ID: F483EB800EF89DD9
5 changed files with 25 additions and 92 deletions

View File

@ -72,5 +72,10 @@ ifneq (,$(filter at86rf2xx,$(USEMODULE)))
CFLAGS += -DAT86RF2XX_BASIC_MODE CFLAGS += -DAT86RF2XX_BASIC_MODE
endif endif
# Auto ACK should be disabled in order to run OpenWSN
ifndef CONFIG_KCONFIG_USEMODULE_IEEE802154
CFLAGS += -DCONFIG_IEEE802154_AUTO_ACK_DISABLE
endif
# LLVM ARM shows issues with missing definitions for stdatomic # LLVM ARM shows issues with missing definitions for stdatomic
TOOLCHAINS_BLACKLIST += llvm TOOLCHAINS_BLACKLIST += llvm

View File

@ -140,8 +140,8 @@ int openwsn_radio_init(void *radio_dev)
/* If the radio is still not in TRX_OFF state, spin */ /* If the radio is still not in TRX_OFF state, spin */
while (ieee802154_radio_confirm_on(dev) == -EAGAIN) {} while (ieee802154_radio_confirm_on(dev) == -EAGAIN) {}
/* Enable basic mode, no AUTOACK. no CSMA */ /* Enable basic mode (no AUTOACK. no CSMA-CA).
ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_AACK_DISABLED); * Auto ACK is disabled via CONFIG_IEEE802154_AUTO_ACK_DISABLE. */
/* MAC layer retransmissions are disabled by _set_csma_params() */ /* MAC layer retransmissions are disabled by _set_csma_params() */
ieee802154_radio_set_csma_params(dev, NULL, -1); ieee802154_radio_set_csma_params(dev, NULL, -1);
@ -150,7 +150,7 @@ int openwsn_radio_init(void *radio_dev)
where the destination-address mode is 0 (no destination address). where the destination-address mode is 0 (no destination address).
per rfc8180 4.5.1 the destination address must be set, which means per rfc8180 4.5.1 the destination address must be set, which means
the destination-address mode can't be 0 */ the destination-address mode can't be 0 */
ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_PROMISC); ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_PROMISC);
} }
/* Configure PHY settings (channel, TX power) */ /* Configure PHY settings (channel, TX power) */

View File

@ -462,40 +462,6 @@ typedef enum {
IEEE802154_CCA_MODE_ED_THRESH_OR_CS, IEEE802154_CCA_MODE_ED_THRESH_OR_CS,
} ieee802154_cca_mode_t; } ieee802154_cca_mode_t;
/**
* @brief RX mode configuration
*/
typedef enum {
/**
* @brief Auto ACK is disabled
*/
IEEE802154_RX_AACK_DISABLED,
/**
* @brief Auto ACK is enabled
*/
IEEE802154_RX_AACK_ENABLED,
/**
* @brief Auto ACK is enabled and frame pending bit set in the next ACK frame
*/
IEEE802154_RX_AACK_FRAME_PENDING,
/**
* @brief Radio is in promiscuous mode
*/
IEEE802154_RX_PROMISC,
/**
* @brief Radio is ready to receive ACK frames
*
* This mode is optional. If a radio decides to implement it, the radio
* should allow ACK frames (and block ACK frames in all other RX modes).
* Note that this mode cannot guarantee that only ACK frames will be
* received.
*
* Expected to be implemented when either @ref IEEE802154_CAP_FRAME_RETRANS
* or @ref IEEE802154_CAP_IRQ_ACK_TIMEOUT is not there.
*/
IEEE802154_RX_WAIT_FOR_ACK,
} ieee802154_rx_mode_t;
/** /**
* @brief Holder of the PHY configuration * @brief Holder of the PHY configuration
*/ */
@ -657,7 +623,6 @@ struct ieee802154_radio_ops {
* - @ref config_phy * - @ref config_phy
* - @ref config_addr_filter * - @ref config_addr_filter
* - @ref set_csma_params * - @ref set_csma_params
* - @ref set_rx_mode
* - @ref set_frame_filter_mode * - @ref set_frame_filter_mode
* - @ref config_src_addr_match * - @ref config_src_addr_match
* - @ref set_frame_retrans (if available) * - @ref set_frame_retrans (if available)
@ -827,17 +792,6 @@ struct ieee802154_radio_ops {
int (*set_csma_params)(ieee802154_dev_t *dev, const ieee802154_csma_be_t *bd, int (*set_csma_params)(ieee802154_dev_t *dev, const ieee802154_csma_be_t *bd,
int8_t retries); int8_t retries);
/**
* @brief Set the RX mode.
*
* @param[in] dev IEEE802.15.4 device descriptor
* @param[in] mode RX mode
*
* @return 0 on success
* @return negative errno on error
*/
int (*set_rx_mode)(ieee802154_dev_t *dev, ieee802154_rx_mode_t mode);
/** /**
* @brief Set the frame filter moder. * @brief Set the frame filter moder.
* *
@ -1456,20 +1410,6 @@ static inline uint32_t ieee802154_radio_get_phy_modes(ieee802154_dev_t *dev)
return (dev->driver->caps & IEEE802154_RF_CAPS_PHY_MASK); return (dev->driver->caps & IEEE802154_RF_CAPS_PHY_MASK);
} }
/**
* @brief Shortcut to @ref ieee802154_radio_ops::set_rx_mode
*
* @param[in] dev IEEE802.15.4 device descriptor
* @param[in] mode RX mode
*
* @return result of @ref ieee802154_radio_ops::set_rx_mode
*/
static inline int ieee802154_radio_set_rx_mode(ieee802154_dev_t *dev,
ieee802154_rx_mode_t mode)
{
return dev->driver->set_rx_mode(dev, mode);
}
/** /**
* @brief Convert a @ref ieee802154_phy_mode_t to a @ref ieee802154_rf_caps_t * @brief Convert a @ref ieee802154_phy_mode_t to a @ref ieee802154_rf_caps_t
* value. * value.

View File

@ -76,7 +76,7 @@ static int _perform_csma_ca(ieee802154_submac_t *submac)
submac->csma_retries_nb++; submac->csma_retries_nb++;
} }
else { else {
ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_AACK_ENABLED); ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_ACCEPT);
_tx_end(submac, TX_STATUS_MEDIUM_BUSY, NULL); _tx_end(submac, TX_STATUS_MEDIUM_BUSY, NULL);
} }
@ -134,7 +134,7 @@ static void _perform_retrans(ieee802154_submac_t *submac)
ieee802154_csma_ca_transmit(submac); ieee802154_csma_ca_transmit(submac);
} }
else { else {
ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_AACK_ENABLED); ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_ACCEPT);
_tx_end(submac, TX_STATUS_NO_ACK, NULL); _tx_end(submac, TX_STATUS_NO_ACK, NULL);
} }
} }
@ -169,8 +169,7 @@ void ieee802154_submac_rx_done_cb(ieee802154_submac_t *submac)
ieee802154_tx_info_t tx_info; ieee802154_tx_info_t tx_info;
tx_info.retrans = submac->retrans; tx_info.retrans = submac->retrans;
bool fp = (ack[0] & IEEE802154_FCF_FRAME_PEND); bool fp = (ack[0] & IEEE802154_FCF_FRAME_PEND);
ieee802154_radio_set_rx_mode(submac->dev, ieee802154_radio_set_frame_filter_mode(submac->dev, IEEE802154_FILTER_ACCEPT);
IEEE802154_RX_AACK_ENABLED);
_tx_end(submac, fp ? TX_STATUS_FRAME_PENDING : TX_STATUS_SUCCESS, _tx_end(submac, fp ? TX_STATUS_FRAME_PENDING : TX_STATUS_SUCCESS,
&tx_info); &tx_info);
} }
@ -216,7 +215,7 @@ static void _handle_tx_success(ieee802154_submac_t *submac,
_tx_end(submac, info->status, info); _tx_end(submac, info->status, info);
} }
else { else {
ieee802154_radio_set_rx_mode(dev, IEEE802154_RX_WAIT_FOR_ACK); ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_ACK_ONLY);
/* Handle ACK reception */ /* Handle ACK reception */
ieee802154_submac_ack_timer_set(submac, ACK_TIMEOUT_US); ieee802154_submac_ack_timer_set(submac, ACK_TIMEOUT_US);

View File

@ -48,7 +48,6 @@ static xtimer_t timer_ack;
static mutex_t lock; static mutex_t lock;
static const char *str_states[3]= {"TRX_OFF", "RX", "TX"}; static const char *str_states[3]= {"TRX_OFF", "RX", "TX"};
static ieee802154_rx_mode_t current_rx_mode;
static eui64_t ext_addr; static eui64_t ext_addr;
static network_uint16_t short_addr; static network_uint16_t short_addr;
static uint8_t seq; static uint8_t seq;
@ -86,7 +85,7 @@ static void _ack_timeout(event_t *event)
(void) event; (void) event;
ieee802154_dev_t *dev = ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID); ieee802154_dev_t *dev = ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID);
ieee802154_radio_set_rx_mode(dev, current_rx_mode); ieee802154_radio_set_frame_filter_mode(dev, IEEE802154_FILTER_ACCEPT);
} }
static event_t _ack_timeout_ev = { static event_t _ack_timeout_ev = {
@ -217,8 +216,8 @@ static void _send(iolist_t *pkt)
while(ieee802154_radio_confirm_set_trx_state(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)) == -EAGAIN); while(ieee802154_radio_confirm_set_trx_state(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)) == -EAGAIN);
/* Trigger the transmit and wait for the mutex unlock (TX_DONE event) */ /* Trigger the transmit and wait for the mutex unlock (TX_DONE event) */
ieee802154_radio_set_frame_filter_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), IEEE802154_FILTER_ACK_ONLY);
ieee802154_radio_request_transmit(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)); ieee802154_radio_request_transmit(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID));
ieee802154_radio_set_rx_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), IEEE802154_RX_WAIT_FOR_ACK);
mutex_lock(&lock); mutex_lock(&lock);
event_post(EVENT_PRIO_HIGHEST, &_tx_finish_ev); event_post(EVENT_PRIO_HIGHEST, &_tx_finish_ev);
@ -241,8 +240,7 @@ static int _init(void)
ieee802154_radio_request_on(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)); ieee802154_radio_request_on(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID));
while(ieee802154_radio_confirm_on(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)) == -EAGAIN) {} while(ieee802154_radio_confirm_on(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID)) == -EAGAIN) {}
current_rx_mode = IEEE802154_RX_AACK_ENABLED; ieee802154_radio_set_frame_filter_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), IEEE802154_FILTER_ACCEPT);
ieee802154_radio_set_rx_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), current_rx_mode);
uint16_t panid = CONFIG_IEEE802154_DEFAULT_PANID; uint16_t panid = CONFIG_IEEE802154_DEFAULT_PANID;
/* Set all IEEE addresses */ /* Set all IEEE addresses */
@ -462,33 +460,24 @@ int txtsnd(int argc, char **argv)
return send(addr, res, len); return send(addr, res, len);
} }
static int rx_mode_cmd(int argc, char **argv) static int promisc(int argc, char **argv)
{ {
ieee802154_rx_mode_t conf; ieee802154_filter_mode_t conf;
if (argc < 2) { if (argc < 2) {
printf("Usage: %s <on|off|pend|promisc>", argv[0]); printf("Usage: %s <on|off>", argv[0]);
return 1; return 1;
} }
if (strcmp(argv[1], "pend") == 0) { if (strcmp(argv[1], "on") == 0) {
conf = IEEE802154_RX_AACK_FRAME_PENDING; conf = IEEE802154_FILTER_PROMISC;
puts("ACK enabled with Frame Pending"); puts("Enabled promiscuos mode");
}
else if (strcmp(argv[1], "off") == 0) {
conf = IEEE802154_RX_AACK_DISABLED;
puts("ACK disabled");
}
else if (strcmp(argv[1], "promisc") == 0) {
conf = IEEE802154_RX_PROMISC;
puts("Promiscuous mode enabled");
} }
else { else {
conf = IEEE802154_RX_AACK_ENABLED; conf = IEEE802154_FILTER_ACCEPT;
puts("ACK enabled"); puts("Disabled promiscuos mode");
} }
current_rx_mode = conf; ieee802154_radio_set_frame_filter_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), conf);
ieee802154_radio_set_rx_mode(ieee802154_hal_test_get_dev(RADIO_DEFAULT_ID), conf);
return 0; return 0;
} }
@ -734,7 +723,7 @@ static const shell_command_t shell_commands[] = {
{ "test_states", "Test state changes", _test_states }, { "test_states", "Test state changes", _test_states },
{ "cca", "Perform CCA", _cca }, { "cca", "Perform CCA", _cca },
{ "config_cca", "Config CCA parameters", _config_cca_cmd }, { "config_cca", "Config CCA parameters", _config_cca_cmd },
{ "rx_mode", "Enable/Disable AACK or set Frame Pending bit or set promiscuos mode", rx_mode_cmd }, { "promisc", "Set promiscuos mode", promisc },
{ "tx_mode", "Enable CSMA-CA, CCA or direct transmission", txmode_cmd }, { "tx_mode", "Enable CSMA-CA, CCA or direct transmission", txmode_cmd },
{ "caps", "Get a list of caps supported by the device", _caps_cmd }, { "caps", "Get a list of caps supported by the device", _caps_cmd },
{ NULL, NULL, NULL } { NULL, NULL, NULL }