drivers: ieee802154: cc13/26xx_subg: fix/document non-standard CSMA/CA

The CC13xx/CC26xx Sub-GHz driver announces a hardware CSMA/CA capability
which it provides only partially. This change documents the gap.

The change also fixes two related issues with the current CCA
implementation:

- The given default ED threshold was above the allowed threshold
  defined in the specification.

- The CCA timeout was not calculated according to the requirements
  defined in the standard.

Signed-off-by: Florian Grandel <fgrandel@code-for-humans.de>
This commit is contained in:
Florian Grandel 2023-05-30 12:59:50 +02:00 committed by Carles Cufí
parent 0f21a18f4b
commit 6bb03b5e3b
2 changed files with 23 additions and 11 deletions

View file

@ -71,11 +71,17 @@ config IEEE802154_CC13XX_CC26XX_SUB_GHZ_NUM_RX_BUF
receive buffers. receive buffers.
config IEEE802154_CC13XX_CC26XX_SUB_GHZ_CS_THRESHOLD config IEEE802154_CC13XX_CC26XX_SUB_GHZ_CS_THRESHOLD
int "TI CC13xx / CC26xx IEEE 802.15.4g Carrier Sense Threshold in dBm" int "TI CC13xx / CC26xx IEEE 802.15.4g Carrier Sense ED Threshold in dBm"
default -70 default -80 # Based on SUN FSK, 200 kHz bit rate, no FEC, see IEEE 802.15.4-2020, section 19.6.7
help help
This option sets RSSI threshold for carrier sense in the CSMA/CA This option sets the energy detection (ED) threshold for
algorithm. clear channel assessment (CCA) modes 1 or 3 in the CSMA/CA
algorithm. Except for the SUN O-QPSK PHY, the ED threshold
shall correspond to a received signal power of at most 10 dB
greater than the specified receiver sensitivity for that PHY,
or in accordance with local regulations (see IEEE 802.15.4-2020,
section 10.2.8). For the SUN O-QPSK PHY, the ED threshold shall
comply with IEEE 802.15.4-2020, section 21.5.13.
config IEEE802154_CC13XX_CC26XX_SUB_GHZ_INIT_PRIO config IEEE802154_CC13XX_CC26XX_SUB_GHZ_INIT_PRIO
int "TI CC13xx / CC26xx IEEE 802.15.4g initialization priority" int "TI CC13xx / CC26xx IEEE 802.15.4g initialization priority"

View file

@ -335,6 +335,7 @@ static enum ieee802154_hw_caps
ieee802154_cc13xx_cc26xx_subg_get_capabilities(const struct device *dev) ieee802154_cc13xx_cc26xx_subg_get_capabilities(const struct device *dev)
{ {
/* TODO: enable IEEE802154_HW_FILTER */ /* TODO: enable IEEE802154_HW_FILTER */
/* TODO: remove or actually implement IEEE802154_HW_CSMA */
return IEEE802154_HW_FCS | IEEE802154_HW_CSMA return IEEE802154_HW_FCS | IEEE802154_HW_CSMA
| IEEE802154_HW_SUB_GHZ; | IEEE802154_HW_SUB_GHZ;
} }
@ -526,11 +527,14 @@ static int ieee802154_cc13xx_cc26xx_subg_tx(const struct device *dev,
if (drv_data->cmd_prop_cs.status != PROP_DONE_IDLE) { if (drv_data->cmd_prop_cs.status != PROP_DONE_IDLE) {
LOG_DBG("Channel access failure (0x%x)", LOG_DBG("Channel access failure (0x%x)",
drv_data->cmd_prop_cs.status); drv_data->cmd_prop_cs.status);
/* Collision Avoidance is a WIP /* TODO: This is not a compliant CSMA/CA algorithm, use soft CSMA/CA
* Currently, we just wait a random amount of us in the * instead as the SubGHz radio of this SoC has no HW CSMA/CA backoff
* range [0,256) but k_busy_wait() is fairly inaccurate in * algorithm support as required by IEEE 802.15.4, section 6.2.5.1.
* practice. Future revisions may attempt to use the RAdio * Alternatively construct compliant CSMA/CA with a combination
* Timer (RAT) to measure this somewhat more precisely. * of CMD_NOP, CMD_PROP_CS and CMD_COUNT_BRANCH commands, see
* SimpleLink SDK (rfListenBeforeTalk.c) or calculate proper backoff
* period as in the SimpleLink WiSUN stack's mac_tx.c.
* Currently, we just wait a random amount of us in the range [0,256).
*/ */
k_busy_wait(sys_rand32_get() & 0xff); k_busy_wait(sys_rand32_get() & 0xff);
continue; continue;
@ -863,8 +867,10 @@ static struct ieee802154_cc13xx_cc26xx_subg_data ieee802154_cc13xx_cc26xx_subg_d
}, },
.rssiThr = CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_CS_THRESHOLD, .rssiThr = CONFIG_IEEE802154_CC13XX_CC26XX_SUB_GHZ_CS_THRESHOLD,
.csEndTrigger.triggerType = TRIG_REL_START, .csEndTrigger.triggerType = TRIG_REL_START,
/* 8 symbol periods. 802.15.4-2015 Table 11.1 */ /* see IEEE 802.15.4, section 11.3, table 11-1 and section 10.2.8 */
.csEndTime = 5000, .csEndTime = RF_convertUsToRatTicks(
IEEE802154_PHY_A_CCA_TIME *
IEEE802154_PHY_SUN_FSK_863MHZ_915MHZ_SYMBOL_PERIOD_US),
}, },
.cmd_prop_tx_adv = { .cmd_prop_tx_adv = {