Skip to content

Commit 2e8836f

Browse files
edmontcarlescufi
authored andcommitted
net: openthread: separated variable for rx/tx operations results
The use of a single error variable for RX and TX operations has shown the OpenThread code to be asserting in some conditions. This commit splits tx_rx_result into rx_result and tx_result to avoid such cases. Signed-off-by: Eduardo Montoya <[email protected]>
1 parent 157c11d commit 2e8836f

File tree

1 file changed

+15
-14
lines changed
  • subsys/net/lib/openthread/platform

1 file changed

+15
-14
lines changed

subsys/net/lib/openthread/platform/radio.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ ATOMIC_DEFINE(pending_events, PENDING_EVENT_COUNT);
8989
K_KERNEL_STACK_DEFINE(ot_task_stack,
9090
CONFIG_OPENTHREAD_RADIO_WORKQUEUE_STACK_SIZE);
9191
static struct k_work_q ot_work_q;
92-
static otError tx_rx_result;
92+
static otError rx_result;
93+
static otError tx_result;
9394

9495
K_FIFO_DEFINE(rx_pkt_fifo);
9596
K_FIFO_DEFINE(tx_pkt_fifo);
@@ -171,21 +172,21 @@ void handle_radio_event(const struct device *dev, enum ieee802154_event evt,
171172
switch (*(enum ieee802154_rx_fail_reason *)
172173
event_params) {
173174
case IEEE802154_RX_FAIL_NOT_RECEIVED:
174-
tx_rx_result = OT_ERROR_NO_FRAME_RECEIVED;
175+
rx_result = OT_ERROR_NO_FRAME_RECEIVED;
175176
break;
176177

177178
case IEEE802154_RX_FAIL_INVALID_FCS:
178-
tx_rx_result = OT_ERROR_FCS;
179+
rx_result = OT_ERROR_FCS;
179180
break;
180181

181182
case IEEE802154_RX_FAIL_ADDR_FILTERED:
182-
tx_rx_result
183+
rx_result
183184
= OT_ERROR_DESTINATION_ADDRESS_FILTERED;
184185
break;
185186

186187
case IEEE802154_RX_FAIL_OTHER:
187188
default:
188-
tx_rx_result = OT_ERROR_FAILED;
189+
rx_result = OT_ERROR_FAILED;
189190
break;
190191
}
191192
set_pending_event(PENDING_EVENT_RX_FAILED);
@@ -243,7 +244,7 @@ void transmit_message(struct k_work *tx_job)
243244
{
244245
ARG_UNUSED(tx_job);
245246

246-
tx_rx_result = OT_ERROR_NONE;
247+
tx_result = OT_ERROR_NONE;
247248
/*
248249
* The payload is already in tx_payload->data,
249250
* but we need to set the length field
@@ -264,17 +265,17 @@ void transmit_message(struct k_work *tx_job)
264265
if (radio_api->tx(radio_dev,
265266
IEEE802154_TX_MODE_CSMA_CA,
266267
tx_pkt, tx_payload) != 0) {
267-
tx_rx_result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
268+
tx_result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
268269
}
269270
} else if (radio_api->cca(radio_dev) != 0 ||
270271
radio_api->tx(radio_dev, IEEE802154_TX_MODE_DIRECT,
271272
tx_pkt, tx_payload) != 0) {
272-
tx_rx_result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
273+
tx_result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
273274
}
274275
} else {
275276
if (radio_api->tx(radio_dev, IEEE802154_TX_MODE_DIRECT,
276277
tx_pkt, tx_payload)) {
277-
tx_rx_result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
278+
tx_result = OT_ERROR_CHANNEL_ACCESS_FAILURE;
278279
}
279280
}
280281

@@ -285,7 +286,7 @@ static inline void handle_tx_done(otInstance *aInstance)
285286
{
286287
if (IS_ENABLED(CONFIG_OPENTHREAD_DIAG) && otPlatDiagModeGet()) {
287288
otPlatDiagRadioTransmitDone(aInstance, &sTransmitFrame,
288-
tx_rx_result);
289+
tx_result);
289290
} else {
290291
if (sTransmitFrame.mPsdu[0] & IEEE802154_AR_FLAG_SET) {
291292
if (ack_frame.mLength == 0) {
@@ -294,11 +295,11 @@ static inline void handle_tx_done(otInstance *aInstance)
294295
NULL, OT_ERROR_NO_ACK);
295296
} else {
296297
otPlatRadioTxDone(aInstance, &sTransmitFrame,
297-
&ack_frame, tx_rx_result);
298+
&ack_frame, tx_result);
298299
}
299300
} else {
300301
otPlatRadioTxDone(aInstance, &sTransmitFrame, NULL,
301-
tx_rx_result);
302+
tx_result);
302303
}
303304
ack_frame.mLength = 0;
304305
}
@@ -438,10 +439,10 @@ void platformRadioProcess(otInstance *aInstance)
438439
reset_pending_event(PENDING_EVENT_RX_FAILED);
439440
if (IS_ENABLED(CONFIG_OPENTHREAD_DIAG) && otPlatDiagModeGet()) {
440441
otPlatDiagRadioReceiveDone(aInstance,
441-
NULL, tx_rx_result);
442+
NULL, rx_result);
442443
} else {
443444
otPlatRadioReceiveDone(aInstance,
444-
NULL, tx_rx_result);
445+
NULL, rx_result);
445446
}
446447
}
447448

0 commit comments

Comments
 (0)