From 2a88dad0458cf2fd4f9f62ffe3c464fbd6db9919 Mon Sep 17 00:00:00 2001 From: Maciej Baczmanski Date: Wed, 7 Feb 2024 11:57:33 +0100 Subject: [PATCH] [nrf fromtree] Revert "drivers: ieee802154: nrf: cache radio channel" This reverts commit 780b12854c11f10f6b3e4b21ae02eaa1b2965736. "drivers: ieee802154: nrf: cache radio channel" Implementation affected RCP devices in openthread as MAC layer does not call `Receive()` functions after transmit is done. Additionally, after sending a frame to a new channel (for example while discovery operation), radio switches to RX state immediately after TX, but continues to listen on old channel for about 5ms, until MAC layer calls `Receive` operation, forcing to change the channel. Signed-off-by: Maciej Baczmanski (cherry picked from commit dbe74b3299f1e247db8c33491ad932e1681c0efa) --- drivers/ieee802154/ieee802154_nrf5.c | 18 ++---------------- drivers/ieee802154/ieee802154_nrf5.h | 3 --- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/drivers/ieee802154/ieee802154_nrf5.c b/drivers/ieee802154/ieee802154_nrf5.c index 553d71188e9..1831a5b4a6a 100644 --- a/drivers/ieee802154/ieee802154_nrf5.c +++ b/drivers/ieee802154/ieee802154_nrf5.c @@ -255,8 +255,6 @@ static int nrf5_cca(const struct device *dev) { struct nrf5_802154_data *nrf5_radio = NRF5_802154_DATA(dev); - nrf_802154_channel_set(nrf5_data.channel); - if (!nrf_802154_cca()) { LOG_DBG("CCA failed"); return -EBUSY; @@ -282,7 +280,7 @@ static int nrf5_set_channel(const struct device *dev, uint16_t channel) return channel < 11 ? -ENOTSUP : -EINVAL; } - nrf5_data.channel = channel; + nrf_802154_channel_set(channel); return 0; } @@ -295,8 +293,6 @@ static int nrf5_energy_scan_start(const struct device *dev, ARG_UNUSED(dev); - nrf_802154_channel_set(nrf5_data.channel); - if (nrf5_data.energy_scan_done == NULL) { nrf5_data.energy_scan_done = done_cb; @@ -462,10 +458,6 @@ static bool nrf5_tx_immediate(struct net_pkt *pkt, uint8_t *payload, bool cca) .use_metadata_value = true, .power = nrf5_data.txpwr, }, - .tx_channel = { - .use_metadata_value = true, - .channel = nrf5_data.channel, - }, }; return nrf_802154_transmit_raw(payload, &metadata); @@ -483,10 +475,6 @@ static bool nrf5_tx_csma_ca(struct net_pkt *pkt, uint8_t *payload) .use_metadata_value = true, .power = nrf5_data.txpwr, }, - .tx_channel = { - .use_metadata_value = true, - .channel = nrf5_data.channel, - }, }; return nrf_802154_transmit_csma_ca_raw(payload, &metadata); @@ -526,7 +514,7 @@ static bool nrf5_tx_at(struct nrf5_802154_data *nrf5_radio, struct net_pkt *pkt, .dynamic_data_is_set = net_pkt_ieee802154_mac_hdr_rdy(pkt), }, .cca = cca, - .channel = nrf5_data.channel, + .channel = nrf_802154_channel_get(), .tx_power = { .use_metadata_value = true, .power = nrf5_data.txpwr, @@ -668,7 +656,6 @@ static int nrf5_start(const struct device *dev) ARG_UNUSED(dev); nrf_802154_tx_power_set(nrf5_data.txpwr); - nrf_802154_channel_set(nrf5_data.channel); if (!nrf_802154_receive()) { LOG_ERR("Failed to enter receive state"); @@ -713,7 +700,6 @@ static int nrf5_continuous_carrier(const struct device *dev) ARG_UNUSED(dev); nrf_802154_tx_power_set(nrf5_data.txpwr); - nrf_802154_channel_set(nrf5_data.channel); if (!nrf_802154_continuous_carrier()) { LOG_ERR("Failed to enter continuous carrier state"); diff --git a/drivers/ieee802154/ieee802154_nrf5.h b/drivers/ieee802154/ieee802154_nrf5.h index 0d4d9c9accf..b1c95548210 100644 --- a/drivers/ieee802154/ieee802154_nrf5.h +++ b/drivers/ieee802154/ieee802154_nrf5.h @@ -100,9 +100,6 @@ struct nrf5_802154_data { /* The TX power in dBm. */ int8_t txpwr; - /* The radio channel. */ - uint8_t channel; - #if defined(CONFIG_NRF_802154_SER_HOST) && defined(CONFIG_IEEE802154_CSL_ENDPOINT) /* The last configured value of CSL period in units of 10 symbols. */ uint32_t csl_period;