-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/net/link_layer/ieee802154/submac: move ack transmission #21973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
9db609a
55d81be
a07216b
ec68e3a
4a88e62
87b185e
39b35fa
b3bdb3b
e0a3316
8c6dc34
22683b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,5 @@ | ||
| ifneq (,$(filter netdev_ieee802154_submac_soft_ack,$(USEMODULE))) | ||
| $(warning SubMAC Soft ACK is now on by default and will be deprecated.) | ||
| endif | ||
|
|
||
| include $(RIOTBASE)/Makefile.base |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,30 +30,36 @@ | |
| * | RX | |PREPARE |<--->| TX | | ||
| * | | +--->| | | | | ||
| * +--------+ | +--------+ +--------+ | ||
| * ^ | ^ | | ||
| * | | | | | ||
| * | | | | | ||
| * | | +--------+ | | ||
| * | | | | v | ||
| * | | |WAIT FOR|<--------+ | ||
| * | | | ACK | | | ||
| * | | +--------+ | | ||
| * | | | | | ||
| * | | | | | ||
| * | | v | | ||
| * | | +--------+ | | ||
| * | +-----| | | | ||
| * | | IDLE | | | ||
| * +------------->| |<-------+ | ||
| * +--------+ | ||
| * | ^ | ^ | | ||
| * | | | | | | ||
| * | | | | | | ||
| * | | | +--------+ | | ||
| * | | | | | v | ||
| * | | | |WAIT FOR|<--------+ | ||
| * | | | | ACK | | | ||
| * | | | +--------+ | | ||
| * | | | | | | ||
| * | | | | | | ||
| * | | | v | | ||
| * | | | +--------+ | | ||
| * | | +-----| | | | ||
| * | | | IDLE | | | ||
| * | +----------->| |<-------+ | ||
| * | +--------+ | ||
| * | +--------+ ^ | ||
| * | | | | | ||
| * +--->| TX ACK |-----+ | ||
| * | | | ||
| * +--------+ | ||
| * ``` | ||
| * | ||
| * - IDLE: The transceiver is off and therefore cannot receive frames. Sending | ||
| * frames might be triggered using @ref ieee802154_send. The next SubMAC | ||
| * state would be PREPARE. | ||
| * - RX: The device is ready to receive frames. In case the SubMAC receives a | ||
| * frame it will call @ref ieee802154_submac_cb_t::rx_done and immediately go | ||
| * to IDLE. Same as the IDLE state, it's possible | ||
| * frame it will transmit an ACK frame if necessary then call | ||
| * @ref ieee802154_submac_cb_t::rx_done and immediately go | ||
| * to IDLE or TX ACK. Same as the IDLE state, it's possible | ||
| * to trigger frames using @ref ieee802154_send. | ||
| * - PREPARE: The frame is already in the framebuffer and waiting to be | ||
| * transmitted. This state might handle CSMA-CA backoff timer in case the | ||
|
|
@@ -71,22 +77,25 @@ | |
| * (either triggered by the radio or a timer), the SubMAC goes to either | ||
| * IDLE if there are no more retransmissions left or no more CSMA-CA | ||
| * retries or PREPARE otherwise. | ||
| * - TX ACK: The received frame requires instantanous acknowledgement. Sending | ||
| * further frames in this state is not permitted. After ACK transmission is | ||
| * completed, the SubMAC will go IDLE. | ||
| * | ||
| * The events that trigger state machine changes are defined in | ||
| * @ref ieee802154_fsm_state_t | ||
| * | ||
| * The following events are valid for each state: | ||
| * | ||
| * Event/State | RX | IDLE | PREPARE | TX | WAIT FOR ACK | ||
| * --------------|----|-------|---------|----|------------- | ||
| * TX_DONE | - | - | - | X | - | ||
| * RX_DONE | X | X* | X* | X* | X | ||
| * CRC_ERROR | X | X* | X* | X* | X | ||
| * ACK_TIMEOUT | - | - | - | - | X | ||
| * BH | - | - | X | - | - | ||
| * REQ_TX | X | X | - | - | - | ||
| * REQ_SET_RX_ON | - | X | - | - | - | ||
| * REQ_SET_IDLE | X | - | - | - | - | ||
| * Event/State | RX | IDLE | PREPARE | TX | WAIT FOR ACK | TX ACK | | ||
| * --------------|----|-------|---------|----|------------------------ | ||
| * TX_DONE | - | - | - | X | - |X | ||
| * RX_DONE | X | X* | X* | X* | X |- | ||
| * CRC_ERROR | X | X* | X* | X* | X |- | ||
| * ACK_TIMEOUT | - | - | - | - | X |- | ||
| * BH | - | - | X | - | - |- | ||
| * REQ_TX | X | X | - | - | - |- | ||
| * REQ_SET_RX_ON | - | X | - | - | - |- | ||
| * REQ_SET_IDLE | X | - | - | - | - |- | ||
| * | ||
| * *: RX_DONE and CRC_ERROR during these events might be a race condition | ||
| * between the ACK Timer and the radios RX_DONE event. If this happens, the | ||
|
|
@@ -167,6 +176,7 @@ typedef enum { | |
| IEEE802154_FSM_STATE_PREPARE, /**< The SubMAC is preparing the next transmission */ | ||
| IEEE802154_FSM_STATE_TX, /**< The SubMAC is currently transmitting a frame */ | ||
| IEEE802154_FSM_STATE_WAIT_FOR_ACK, /**< The SubMAC is waiting for an ACK frame */ | ||
| IEEE802154_FSM_STATE_TX_ACK, /**< The SubMAC is transmitting an ACK frame */ | ||
| IEEE802154_FSM_STATE_NUMOF, /**< Number of SubMAC FSM states */ | ||
| } ieee802154_fsm_state_t; | ||
|
|
||
|
|
@@ -208,6 +218,9 @@ struct ieee802154_submac { | |
| ieee802154_fsm_state_t fsm_state; /**< State of the SubMAC */ | ||
| ieee802154_phy_mode_t phy_mode; /**< IEEE 802.15.4 PHY mode */ | ||
| const iolist_t *psdu; /**< stores the current PSDU */ | ||
| uint8_t rx_buf[IEEE802154_FRAME_LEN_MAX]; /**< stores received frame */ | ||
| size_t rx_len; /**< stores length of received frame */ | ||
| ieee802154_rx_info_t rx_info; /**< stores lqi and rssi of received frame */ | ||
| }; | ||
|
|
||
| /** | ||
|
|
@@ -410,26 +423,20 @@ static inline int ieee802154_set_tx_power(ieee802154_submac_t *submac, | |
| /** | ||
| * @brief Get the received frame length | ||
| * | ||
| * @pre this function MUST be called either inside @ref ieee802154_submac_cb_t::rx_done | ||
| * or in SLEEP state. | ||
|
Comment on lines
-413
to
-414
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure you can just remove this precondition? What is the initial value of it before receiving any frame? Isn't the buffer cleared at any point in time? (Should it maybe?) Also, does it make sense to retrieve a frame length in any other state than RX and SLEEP? (same below, obviously)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The preconditions were present because these functions accessed the radio buffer directly. Now that we have a separate rx-buffer we can access it anytime. The initial values are set to zero at |
||
| * | ||
| * @param[in] submac pointer to the SubMAC | ||
| * | ||
| * @return length of the PSDU (excluding FCS length) | ||
| */ | ||
| static inline int ieee802154_get_frame_length(ieee802154_submac_t *submac) | ||
| { | ||
| return ieee802154_radio_len(&submac->dev); | ||
| return submac->rx_len; | ||
| } | ||
|
|
||
| /** | ||
| * @brief Read the received frame | ||
| * | ||
| * This functions reads the received PSDU from the device (excluding FCS) | ||
| * | ||
| * @pre this function MUST be called either inside @ref ieee802154_submac_cb_t::rx_done | ||
| * or in SLEEP state. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's a good idea to remove the precondition here, because the |
||
| * | ||
| * @param[in] submac pointer to the SubMAC descriptor | ||
| * @param[out] buf buffer to write into. If NULL, the packet is discarded | ||
| * @param[in] len length of the buffer | ||
|
|
@@ -441,7 +448,15 @@ static inline int ieee802154_get_frame_length(ieee802154_submac_t *submac) | |
| static inline int ieee802154_read_frame(ieee802154_submac_t *submac, void *buf, | ||
| size_t len, ieee802154_rx_info_t *info) | ||
| { | ||
| return ieee802154_radio_read(&submac->dev, buf, len, info); | ||
| if (submac->rx_len > len) { | ||
| return -ENOBUFS; | ||
| } | ||
| if (info != NULL) { | ||
| info->rssi = submac->rx_info.rssi; | ||
| info->lqi = submac->rx_info.lqi; | ||
| } | ||
| memcpy(buf, submac->rx_buf, submac->rx_len); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a caller passes |
||
| return submac->rx_len; | ||
| } | ||
|
|
||
| /** | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.