Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cpu/cc2538/radio/cc2538_rf_radio_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
* to inform the upper layer that CSMA-CA failed. */
RFCORE_SFR_RFST = STOP;

RFCORE_XREG_CSPX = 0; /* Holds timer value */

Check warning on line 153 in cpu/cc2538/radio/cc2538_rf_radio_ops.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
RFCORE_XREG_CSPY = cc2538_min_be; /* Holds MinBE */

assert(cc2538_csma_ca_retries >= 0);
Expand Down Expand Up @@ -387,7 +387,7 @@
handled_f1 |= TXACKDONE;
assert(cc2538_state == CC2538_STATE_TX_ACK);
cc2538_state = CC2538_STATE_READY;
}

Check warning on line 390 in cpu/cc2538/radio/cc2538_rf_radio_ops.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'switch' not followed by a single space

if ((flags_f0 & SFD)) {
handled_f0 |= SFD;
Expand Down Expand Up @@ -483,7 +483,7 @@

static int _config_addr_filter(ieee802154_dev_t *dev, ieee802154_af_cmd_t cmd, const void *value)
{
(void) dev;

Check warning on line 486 in cpu/cc2538/radio/cc2538_rf_radio_ops.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'switch' not followed by a single space
const network_uint16_t *short_addr = value;
const eui64_t *ext_addr = value;
const uint16_t *pan_id = value;
Expand All @@ -509,10 +509,10 @@
case IEEE802154_AF_PAN_COORD:
return -ENOTSUP;
}

Check warning on line 512 in cpu/cc2538/radio/cc2538_rf_radio_ops.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
return 0;
}

Check warning on line 515 in cpu/cc2538/radio/cc2538_rf_radio_ops.c

View workflow job for this annotation

GitHub Actions / static-tests

keyword 'switch' not followed by a single space
static int _config_src_addr_match(ieee802154_dev_t *dev, ieee802154_src_match_t cmd, const void *value)
{
(void) dev;
Expand Down Expand Up @@ -619,6 +619,7 @@

static const ieee802154_radio_ops_t cc2538_rf_ops = {
.caps = IEEE802154_CAP_24_GHZ
| IEEE802154_CAP_AUTO_ACK
| IEEE802154_CAP_AUTO_CSMA
| IEEE802154_CAP_IRQ_CRC_ERROR
| IEEE802154_CAP_IRQ_TX_DONE
Expand Down
1 change: 1 addition & 0 deletions cpu/esp32/esp-ieee802154/esp_ieee802154_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ int esp_ieee802154_init(void)
static const ieee802154_radio_ops_t esp_ieee802154_driver = {
.caps = IEEE802154_CAP_24_GHZ
| IEEE802154_CAP_PHY_OQPSK
| IEEE802154_CAP_AUTO_ACK
| IEEE802154_CAP_AUTO_CSMA
| IEEE802154_CAP_SRC_ADDR_MATCH
#if _USE_CCA_DONE
Expand Down
1 change: 1 addition & 0 deletions cpu/native/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ ifneq (,$(filter socket_zep,$(USEMODULE)))
USEMODULE += ieee802154
ifneq (,$(filter netdev,$(USEMODULE)))
USEMODULE += netdev_ieee802154_submac
USEMODULE += netdev_ieee802154_submac_soft_ack
endif
endif

Expand Down
58 changes: 19 additions & 39 deletions cpu/native/socket_zep/socket_zep.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,37 +257,6 @@
}
}

static void _send_ack(void *arg)
{
ieee802154_dev_t *dev = arg;
socket_zep_t *zepdev = dev->priv;
const uint8_t *rxbuf = &zepdev->rcv_buf[sizeof(zep_v2_data_hdr_t)];
uint8_t ack[3];
zep_v2_data_hdr_t hdr;

/* sending ACK should only happen if we received a frame */
assert(zepdev->state == ZEPDEV_STATE_RX_RECV);
/* ACK request bit should be set if we get here */
assert((rxbuf[0] & IEEE802154_FCF_ACK_REQ) != 0);

DEBUG("socket_zep::send_ack: seq_no: %u\n", rxbuf[2]);

_zep_hdr_fill(zepdev, &hdr.hdr, sizeof(ack) + IEEE802154_FCF_LEN);

ack[0] = IEEE802154_FCF_TYPE_ACK; /* FCF */
ack[1] = 0; /* FCF */
ack[2] = rxbuf[2]; /* SeqNum */

/* calculate checksum */
uint16_t chksum = crc16_ccitt_false_update(0, ack, 3);

real_send(zepdev->sock_fd, &hdr, sizeof(hdr), MSG_MORE);
real_send(zepdev->sock_fd, ack, sizeof(ack), MSG_MORE);
real_send(zepdev->sock_fd, &chksum, sizeof(chksum), 0);

dev->cb(dev, IEEE802154_RADIO_INDICATION_RX_DONE);
}

static void _send_frame(void *arg)
{
ieee802154_dev_t *dev = arg;
Expand Down Expand Up @@ -359,13 +328,7 @@
zepdev->rcv_len = res;
dev->cb(dev, IEEE802154_RADIO_INDICATION_RX_START);

/* send ACK after 192 µs */
if ((((uint8_t *)(zep + 1))[0] & IEEE802154_FCF_ACK_REQ) != 0) {
zepdev->ack_timer.callback = _send_ack;
ztimer_set(ZTIMER_USEC, &zepdev->ack_timer, ACK_DELAY_US);
} else {
dev->cb(dev, IEEE802154_RADIO_INDICATION_RX_DONE);
}
dev->cb(dev, IEEE802154_RADIO_INDICATION_RX_DONE);

return;
out:
Expand Down Expand Up @@ -505,6 +468,13 @@
return 0;
}

static int _get_frame_filter_mode(ieee802154_dev_t *dev, ieee802154_filter_mode_t *mode)
{
socket_zep_t *zepdev = dev->priv;
*mode = zepdev->filter_mode;
return 0;
}

static int _write(ieee802154_dev_t *dev, const iolist_t *iolist)
{
socket_zep_t *zepdev = dev->priv;
Expand Down Expand Up @@ -541,10 +511,10 @@
{
socket_zep_t *zepdev = dev->priv;

zepdev->state = ZEPDEV_STATE_TX;

Check warning on line 514 in cpu/native/socket_zep/socket_zep.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

/* 8 bit are mapped to 2 symbols */
unsigned time_tx = 2 * zepdev->snd_len * IEEE802154_SYMBOL_TIME_US;
unsigned time_tx = 2 * (zepdev->snd_len - sizeof(zep_v2_data_hdr_t)) * IEEE802154_SYMBOL_TIME_US;
DEBUG("socket_zep::request_transmit(%u bytes, %u µs)\n", zepdev->snd_len, time_tx);

dev->cb(dev, IEEE802154_RADIO_INDICATION_TX_START);
Expand All @@ -560,7 +530,14 @@
{
(void) dev;

socket_zep_t *zepdev = dev->priv;

if (zepdev->state == ZEPDEV_STATE_TX) {
DEBUG("socket_zep::confirm_transmit: still in TX state\n");
return -EAGAIN; /* TX is still in progress */
}
if (info) {
DEBUG("socket_zep::confirm_transmit: success\n");
info->status = TX_STATUS_SUCCESS;
}

Expand Down Expand Up @@ -628,6 +605,7 @@
switch (op) {
case IEEE802154_HAL_OP_TRANSMIT:
if (zepdev->state != ZEPDEV_STATE_IDLE) {
DEBUG("socket_zep::request_op: request TX in state %u (busy)\n", zepdev->state);
return -EBUSY;
}
res = _request_transmit(dev);
Expand Down Expand Up @@ -659,6 +637,7 @@
ztimer_remove(ZTIMER_USEC, &zepdev->ack_timer);
zepdev->state = ZEPDEV_STATE_IDLE;
} else {
DEBUG("socket_zep::request_op: request IDLE in state TX\n");
return -EBUSY;
}

Expand Down Expand Up @@ -723,6 +702,7 @@
.config_src_addr_match = _config_src_addr_match,
.set_csma_params = _set_csma_params,
.set_frame_filter_mode = _set_frame_filter_mode,
.get_frame_filter_mode = _get_frame_filter_mode,
};

void socket_zep_hal_setup(socket_zep_t *dev, ieee802154_dev_t *hal)
Expand Down
1 change: 1 addition & 0 deletions cpu/nrf52/Makefile.dep
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ ifneq (,$(filter nrf802154,$(USEMODULE)))
USEMODULE += luid
ifneq (,$(filter netdev,$(USEMODULE)))
USEMODULE += netdev_ieee802154_submac
USEMODULE += netdev_ieee802154_submac_soft_ack
endif
endif

Expand Down
67 changes: 19 additions & 48 deletions cpu/nrf52/radio/nrf802154/nrf802154_radio.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@

static uint8_t rxbuf[IEEE802154_FRAME_LEN_MAX + 3]; /* len PHR + PSDU + LQI */
static uint8_t txbuf[IEEE802154_FRAME_LEN_MAX + 3]; /* len PHR + PSDU + LQI */
static uint8_t ack[IEEE802154_ACK_FRAME_LEN];

typedef enum {
STATE_IDLE,
Expand Down Expand Up @@ -430,30 +429,6 @@ static void _set_ifs_timer(bool lifs)
timer_start(NRF802154_TIMER);
}

static void _timer_cb(void *arg, int chan)
{
(void)arg;
ieee802154_dev_t *dev = nrf802154_hal_dev;

if (chan == MAC_TIMER_CHAN_ACK) {
/* Copy sqn */
ack[1] = IEEE802154_FCF_TYPE_ACK;
if (cfg.pending) {
ack[1] |= IEEE802154_FCF_FRAME_PEND;
}

ack[3] = rxbuf[3];

NRF_RADIO->PACKETPTR = (uint32_t) &ack;
NRF_RADIO->TASKS_TXEN = 1;
dev->cb(dev, IEEE802154_RADIO_INDICATION_RX_DONE);
}
else if (chan == MAC_TIMER_CHAN_IFS) {
cfg.ifs = false;
}

timer_stop(NRF802154_TIMER);
}
/**
* @brief Set radio into DISABLED state
*/
Expand All @@ -463,16 +438,6 @@ int nrf802154_init(void)
/* reset buffer */
rxbuf[0] = 0;
txbuf[0] = 0;

ack[0] = IEEE802154_ACK_FRAME_LEN; /* PSDU length */
ack[1] = IEEE802154_FCF_TYPE_ACK; /* FCF */
ack[2] = 0; /* FCF */

int result = timer_init(NRF802154_TIMER, TIMER_FREQ, _timer_cb, NULL);
assert(result >= 0);
(void)result;
timer_stop(NRF802154_TIMER);

/* power off peripheral (but do not release the HFXO as we never requested
* it so far) */
NRF_RADIO->POWER = 0;
Expand Down Expand Up @@ -528,9 +493,7 @@ void isr_radio(void)
case STATE_RX:
if (NRF_RADIO->CRCSTATUS) {
bool l2filter_passed = _l2filter(rxbuf+1);
bool is_auto_ack_en = !IS_ACTIVE(CONFIG_IEEE802154_AUTO_ACK_DISABLE);
bool is_ack = rxbuf[1] & IEEE802154_FCF_TYPE_ACK;
bool ack_req = rxbuf[1] & IEEE802154_FCF_ACK_REQ;

/* If radio is in promiscuos mode, indicate packet and
* don't event think of sending an ACK frame :) */
Expand All @@ -543,17 +506,9 @@ void isr_radio(void)
* directly or if the driver should send an ACK frame before
* the indication */
else if (l2filter_passed) {
if (ack_req && is_auto_ack_en) {
timer_set(NRF802154_TIMER, MAC_TIMER_CHAN_ACK, IEEE802154_SIFS_SYMS);
timer_start(NRF802154_TIMER);
_disable();
_state = STATE_ACK;
}
else {
DEBUG("[nrf802154] RX frame doesn't require ACK frame.\n");
_state = STATE_IDLE;
dev->cb(dev, IEEE802154_RADIO_INDICATION_RX_DONE);
}
DEBUG("[nrf802154] RX frame doesn't require ACK frame.\n");
_state = STATE_IDLE;
dev->cb(dev, IEEE802154_RADIO_INDICATION_RX_DONE);
}
/* In case the packet is an ACK and the ACK filter is disabled,
* indicate the frame reception */
Expand Down Expand Up @@ -770,6 +725,21 @@ static int _set_frame_filter_mode(ieee802154_dev_t *dev, ieee802154_filter_mode_
return 0;
}

static int _get_frame_filter_mode(ieee802154_dev_t *dev, ieee802154_filter_mode_t *mode)
{
(void) dev;
if (cfg.promisc) {
*mode = IEEE802154_FILTER_PROMISC;
}
else if (!cfg.ack_filter) {
*mode = IEEE802154_FILTER_ACK_ONLY;
}
else {
*mode = IEEE802154_FILTER_ACCEPT;
}
return 0;
}

static int _set_csma_params(ieee802154_dev_t *dev, const ieee802154_csma_be_t *bd,
int8_t retries)
{
Expand Down Expand Up @@ -823,4 +793,5 @@ static const ieee802154_radio_ops_t nrf802154_ops = {
.config_addr_filter = _config_addr_filter,
.config_src_addr_match = _config_src_addr_match,
.set_frame_filter_mode = _set_frame_filter_mode,
.get_frame_filter_mode = _get_frame_filter_mode,
};
2 changes: 1 addition & 1 deletion drivers/include/net/netdev/ieee802154_submac.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ typedef struct {
netdev_ieee802154_t dev; /**< IEEE 802.15.4 netdev descriptor */
ieee802154_submac_t submac; /**< IEEE 802.15.4 SubMAC descriptor */
ztimer_t ack_timer; /**< ztimer descriptor for the ACK timeout timer */
int isr_flags; /**< netdev submac @ref NETDEV_EVENT_ISR flags */
uint32_t isr_flags; /**< netdev submac @ref NETDEV_EVENT_ISR flags */
int bytes_tx; /**< size of the sent frame or tx error */
int8_t retrans; /**< number of frame retransmissions of the last TX */
bool dispatch; /**< whether an event should be dispatched or not */
Expand Down
1 change: 1 addition & 0 deletions drivers/kw2xrf/kw2xrf_radio_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@
printf("MKW2XDM_IRQSTS3_TMR3IRQ: %s (%s|%s)\n", dregs[MKW2XDM_IRQSTS3] & MKW2XDM_IRQSTS3_TMR3IRQ ? "SET" : "off",
dregs[MKW2XDM_IRQSTS3] & MKW2XDM_IRQSTS3_TMR3MSK ? "masked" : "ACTIVE",
dregs[MKW2XDM_PHY_CTRL3] & MKW2XDM_PHY_CTRL3_TMR3CMP_EN ? "compare" : "no-compare");
printf("MKW2XDM_IRQSTS3_TMR2IRQ: %s (%s|%s)\n", dregs[MKW2XDM_IRQSTS3] & MKW2XDM_IRQSTS3_TMR2IRQ ? "SET" : "off",

Check warning on line 100 in drivers/kw2xrf/kw2xrf_radio_hal.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
dregs[MKW2XDM_IRQSTS3] & MKW2XDM_IRQSTS3_TMR2MSK ? "masked" : "ACTIVE",

Check warning on line 101 in drivers/kw2xrf/kw2xrf_radio_hal.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
dregs[MKW2XDM_PHY_CTRL3] & MKW2XDM_PHY_CTRL3_TMR2CMP_EN ? "compare" : "no-compare");

Check warning on line 102 in drivers/kw2xrf/kw2xrf_radio_hal.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
printf("MKW2XDM_IRQSTS3_TMR1IRQ: %s (%s|%s)\n", dregs[MKW2XDM_IRQSTS3] & MKW2XDM_IRQSTS3_TMR1IRQ ? "SET" : "off",

Check warning on line 103 in drivers/kw2xrf/kw2xrf_radio_hal.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
dregs[MKW2XDM_IRQSTS3] & MKW2XDM_IRQSTS3_TMR1MSK ? "masked" : "ACTIVE",
dregs[MKW2XDM_PHY_CTRL3] & MKW2XDM_PHY_CTRL3_TMR1CMP_EN ? "compare" : "no-compare");
}
Expand Down Expand Up @@ -705,6 +705,7 @@

static const ieee802154_radio_ops_t kw2xrf_ops = {
.caps = IEEE802154_CAP_24_GHZ
| IEEE802154_CAP_AUTO_ACK
| IEEE802154_CAP_IRQ_CRC_ERROR
| IEEE802154_CAP_IRQ_RX_START
| IEEE802154_CAP_IRQ_TX_DONE
Expand Down
1 change: 1 addition & 0 deletions drivers/mrf24j40/mrf24j40_radio_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ int _set_frame_retrans(ieee802154_dev_t *hal, uint8_t retrans)

static const ieee802154_radio_ops_t mrf24j40_ops = {
.caps = IEEE802154_CAP_24_GHZ
| IEEE802154_CAP_AUTO_ACK
| IEEE802154_CAP_IRQ_TX_DONE
| IEEE802154_CAP_FRAME_RETRANS
| IEEE802154_CAP_FRAME_RETRANS_INFO
Expand Down
1 change: 1 addition & 0 deletions drivers/netdev_ieee802154_submac/Makefile.include
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PSEUDOMODULES += netdev_ieee802154_submac_soft_ack
Loading
Loading