drivers: ieee802154: rf2xx: Fix rx promiscuous behaviour

When radio is set to promiscuous mode it is desirable to receive
invalid frames. This skip a few checks and allow an invalid and
non-standard frames be delivered for diagnose.

Signed-off-by: Gerson Fernando Budke <nandojve@gmail.com>
This commit is contained in:
Gerson Fernando Budke 2023-09-24 17:57:28 +02:00 committed by Carles Cufí
commit 037618a638
2 changed files with 9 additions and 4 deletions

View file

@ -179,7 +179,7 @@ static void rf2xx_trx_rx(const struct device *dev)
pkt_len = rx_buf[RX2XX_FRAME_PHR_INDEX];
}
if (pkt_len < RX2XX_FRAME_MIN_PHR_SIZE) {
if (!ctx->promiscuous && pkt_len < RX2XX_FRAME_MIN_PHR_SIZE) {
LOG_ERR("Invalid RX frame length");
return;
}
@ -203,14 +203,14 @@ static void rf2xx_trx_rx(const struct device *dev)
}
ctx->pkt_lqi = rx_buf[pkt_len + RX2XX_FRAME_LQI_INDEX];
if (trac == RF2XX_TRX_PHY_STATE_TRAC_INVALID) {
if (!ctx->promiscuous && trac == RF2XX_TRX_PHY_STATE_TRAC_INVALID) {
LOG_ERR("Invalid RX frame");
return;
}
if (!IS_ENABLED(CONFIG_IEEE802154_RAW_MODE) &&
!IS_ENABLED(CONFIG_NET_L2_OPENTHREAD)) {
!IS_ENABLED(CONFIG_NET_L2_OPENTHREAD) &&
pkt_len >= RX2XX_FRAME_FCS_LENGTH) {
pkt_len -= RX2XX_FRAME_FCS_LENGTH;
}
@ -775,8 +775,11 @@ static int rf2xx_pan_coord_set(const struct device *dev, bool pan_coordinator)
static int rf2xx_promiscuous_set(const struct device *dev, bool promiscuous)
{
struct rf2xx_context *ctx = dev->data;
uint8_t reg;
ctx->promiscuous = promiscuous;
if (promiscuous) {
reg = rf2xx_iface_reg_read(dev, RF2XX_XAH_CTRL_1_REG);
reg |= (1 << RF2XX_AACK_PROM_MODE);
@ -903,6 +906,7 @@ static int power_on_and_setup(const struct device *dev)
}
ctx->tx_mode = IEEE802154_TX_MODE_CSMA_CA;
ctx->promiscuous = false;
/* Configure INT behaviour */
config = (1 << RF2XX_RX_START) |

View file

@ -122,6 +122,7 @@ struct rf2xx_context {
int8_t trx_rssi_base;
uint8_t trx_version;
uint8_t rx_phr;
bool promiscuous;
};
#endif /* ZEPHYR_DRIVERS_IEEE802154_IEEE802154_RF2XX_H_ */