Skip to content

Commit 6046368

Browse files
martinjaegerkartben
authored andcommitted
drivers: ieee802154: unify FCS configuration in L2 packet
Use the same Kconfig for all drivers to configure if the FCS bytes (checksum) should be included in the packets passed to L2. The description is slightly reworded to make clear that it does not only affect the length, but the packet content itself. Signed-off-by: Martin Jäger <[email protected]>
1 parent 81ed343 commit 6046368

File tree

9 files changed

+16
-23
lines changed

9 files changed

+16
-23
lines changed

drivers/ieee802154/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ config IEEE802154_VENDOR_OUI
6060

6161
endif # IEEE802154_VENDOR_OUI_ENABLE
6262

63+
config IEEE802154_L2_PKT_INCL_FCS
64+
bool "Include FCS field in the L2 packet"
65+
default y if IEEE802154_RAW_MODE || NET_L2_OPENTHREAD
66+
help
67+
Some 802.15.4 L2 implementations expect FCS to be included in the
68+
packet, while others do not. Allow to configure this behavior based
69+
on the upper layer selected.
70+
6371
source "drivers/ieee802154/Kconfig.b91"
6472

6573
source "drivers/ieee802154/Kconfig.cc2520"

drivers/ieee802154/Kconfig.nrf5

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,6 @@ config IEEE802154_NRF5_UICR_EUI64_REG
6262

6363
endif # IEEE802154_NRF5_UICR_EUI64_ENABLE
6464

65-
config IEEE802154_NRF5_FCS_IN_LENGTH
66-
bool "Include FCS field in the overall packet length"
67-
default y if IEEE802154_RAW_MODE || NET_L2_OPENTHREAD
68-
help
69-
Some 802.15.4 L2 implementations expect that FCS length is included in
70-
the overall packet length while others not. Allow to configure this
71-
behavior, based on the selected upper layer.
72-
7365
config IEEE802154_NRF5_DELAY_TRX_ACC
7466
int "Clock accuracy for delayed operations"
7567
default CLOCK_CONTROL_NRF_ACCURACY if (CLOCK_CONTROL_NRF && (CLOCK_CONTROL_NRF_ACCURACY < $(UINT8_MAX)))

drivers/ieee802154/ieee802154_b91.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@ static void b91_rf_rx_isr(void)
272272
/* check CRC */
273273
if (rf_zigbee_packet_crc_ok(data.rx_buffer)) {
274274
/* get payload length */
275-
if (IS_ENABLED(CONFIG_IEEE802154_RAW_MODE) ||
276-
IS_ENABLED(CONFIG_NET_L2_OPENTHREAD)) {
275+
if (IS_ENABLED(CONFIG_IEEE802154_L2_PKT_INCL_FCS)) {
277276
length = data.rx_buffer[B91_LENGTH_OFFSET];
278277
} else {
279278
length = data.rx_buffer[B91_LENGTH_OFFSET] - B91_FCS_LENGTH;

drivers/ieee802154/ieee802154_cc13xx_cc26xx.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,7 @@ static void ieee802154_cc13xx_cc26xx_rx_done(
413413
corr = drv_data->rx_data[i][len--] & 0x3F;
414414
rssi = drv_data->rx_data[i][len--];
415415

416-
/* remove fcs as it is not expected by L2
417-
* But keep it for RAW mode
418-
*/
419-
if (IS_ENABLED(CONFIG_NET_L2_IEEE802154)) {
416+
if (!IS_ENABLED(CONFIG_IEEE802154_L2_PKT_INCL_FCS)) {
420417
len -= 2;
421418
}
422419

drivers/ieee802154/ieee802154_cc13xx_cc26xx_subg.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,7 @@ static void drv_rx_done(struct ieee802154_cc13xx_cc26xx_subg_data *drv_data)
340340
status = drv_data->rx_data[i][len--];
341341
rssi = drv_data->rx_data[i][len--];
342342

343-
/* TODO: Configure firmware to include CRC in raw mode. */
344-
if (IS_ENABLED(CONFIG_IEEE802154_RAW_MODE) && len > 0) {
343+
if (IS_ENABLED(CONFIG_IEEE802154_L2_PKT_INCL_FCS) && len > 0) {
345344
/* append CRC-16/CCITT */
346345
uint16_t crc = 0;
347346

drivers/ieee802154/ieee802154_cc2520.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,7 @@ static void cc2520_rx(void *p1, void *p2, void *p3)
624624
goto flush;
625625
}
626626

627-
if (!IS_ENABLED(CONFIG_IEEE802154_RAW_MODE)) {
627+
if (!IS_ENABLED(CONFIG_IEEE802154_L2_PKT_INCL_FCS)) {
628628
pkt_len -= 2U;
629629
}
630630

drivers/ieee802154/ieee802154_dw1000.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ static inline void dwt_irq_handle_rx(const struct device *dev, uint32_t sys_stat
416416
rx_pacc = (rx_finfo & DWT_RX_FINFO_RXPACC_MASK) >>
417417
DWT_RX_FINFO_RXPACC_SHIFT;
418418

419-
if (!(IS_ENABLED(CONFIG_IEEE802154_RAW_MODE))) {
419+
if (!IS_ENABLED(CONFIG_IEEE802154_L2_PKT_INCL_FCS)) {
420420
pkt_len -= DWT_FCS_LENGTH;
421421
}
422422

drivers/ieee802154/ieee802154_nrf5.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ static void nrf5_rx_thread(void *arg1, void *arg2, void *arg3)
172172
* The last 2 bytes contain LQI or FCS, depending if
173173
* automatic CRC handling is enabled or not, respectively.
174174
*/
175-
if (IS_ENABLED(CONFIG_IEEE802154_NRF5_FCS_IN_LENGTH)) {
175+
if (IS_ENABLED(CONFIG_IEEE802154_L2_PKT_INCL_FCS)) {
176176
pkt_len = rx_frame->psdu[0];
177177
} else {
178178
pkt_len = rx_frame->psdu[0] - IEEE802154_FCS_LENGTH;
@@ -419,7 +419,7 @@ static int handle_ack(struct nrf5_802154_data *nrf5_radio)
419419
}
420420
#endif
421421

422-
if (IS_ENABLED(CONFIG_IEEE802154_NRF5_FCS_IN_LENGTH)) {
422+
if (IS_ENABLED(CONFIG_IEEE802154_L2_PKT_INCL_FCS)) {
423423
ack_len = nrf5_radio->ack_frame.psdu[0];
424424
} else {
425425
ack_len = nrf5_radio->ack_frame.psdu[0] - IEEE802154_FCS_LENGTH;

drivers/ieee802154/ieee802154_rf2xx.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,7 @@ static void rf2xx_trx_rx(const struct device *dev)
208208
return;
209209
}
210210

211-
if (!IS_ENABLED(CONFIG_IEEE802154_RAW_MODE) &&
212-
!IS_ENABLED(CONFIG_NET_L2_OPENTHREAD) &&
213-
pkt_len >= RX2XX_FRAME_FCS_LENGTH) {
211+
if (!IS_ENABLED(CONFIG_IEEE802154_L2_PKT_INCL_FCS) && pkt_len >= RX2XX_FRAME_FCS_LENGTH) {
214212
pkt_len -= RX2XX_FRAME_FCS_LENGTH;
215213
}
216214

0 commit comments

Comments
 (0)