Skip to content

Commit 1f2ca00

Browse files
jhirsinordicjm
authored andcommitted
samples: dect_phy: dect_shell: ping: harq fixes
Client side: fixing HARQ NAK based retx and ping completion. Server side: adding some delay to restart RX. Jira: MOSH-645 Signed-off-by: Jani Hirsimäki <[email protected]>
1 parent 710c6a5 commit 1f2ca00

File tree

1 file changed

+51
-12
lines changed

1 file changed

+51
-12
lines changed

samples/dect/dect_phy/dect_shell/src/dect/ping/dect_phy_ping.c

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ static struct dect_phy_ping_data {
158158
static struct dect_phy_ping_harq_tx_process_info
159159
harq_processes[DECT_PHY_PING_HARQ_TX_PROCESS_COUNT];
160160

161+
struct dect_phy_ping_harq_tx_payload_data_evt {
162+
enum dect_harq_user harq_user;
163+
uint32_t phy_handle;
164+
};
165+
161166
/**************************************************************************************************/
162167

163168
static void dect_phy_ping_rx_on_pcc_crc_failure(void);
@@ -288,10 +293,11 @@ static bool dect_phy_ping_harq_process_init(enum dect_phy_common_role role,
288293
void dect_phy_ping_harq_process_round_start(enum dect_harq_user harq_user)
289294
{
290295
if (harq_processes[harq_user].process_in_use) {
291-
desh_warn("Previous HARQ still on going and starting new round "
296+
desh_warn("Previous HARQ retx still ongoing and starting new round "
292297
"- no response to prev data?");
293298
}
294299
harq_processes[harq_user].process_in_use = true;
300+
harq_processes[harq_user].rtx_ongoing = false;
295301
harq_processes[harq_user].last_redundancy_version = 0;
296302
}
297303

@@ -309,6 +315,7 @@ void dect_phy_ping_harq_store_tx_payload_data_scheduler_cb(
309315
struct dect_phy_api_scheduler_list_item *ctrl_sche_list_item =
310316
&(harq_processes[harq_data->harq_user].sche_list_item);
311317
enum dect_harq_user harq_user = harq_data->harq_user;
318+
struct dect_phy_ping_harq_tx_payload_data_evt ping_harq_evt_data;
312319

313320
__ASSERT_NO_MSG(harq_user == DECT_HARQ_CLIENT); /* Only DECT_HARQ_CLIENT supported */
314321
__ASSERT_NO_MSG(in_sche_list_item->sched_config.tx.encoded_payload_pdu_size <=
@@ -317,8 +324,24 @@ void dect_phy_ping_harq_store_tx_payload_data_scheduler_cb(
317324
dect_phy_api_scheduler_list_item_mem_copy(ctrl_sche_list_item, in_sche_list_item);
318325
dect_phy_api_scheduler_list_item_dealloc(in_sche_list_item);
319326

320-
dect_phy_ping_msgq_data_op_add(DECT_PHY_PING_EVENT_HARQ_PAYLOAD_STORED, (void *)&harq_user,
321-
sizeof(enum dect_harq_user));
327+
ping_harq_evt_data.phy_handle = ctrl_sche_list_item->phy_op_handle;
328+
ping_harq_evt_data.harq_user = harq_user;
329+
330+
dect_phy_ping_msgq_data_op_add(DECT_PHY_PING_EVENT_HARQ_PAYLOAD_STORED,
331+
(void *)&ping_harq_evt_data,
332+
sizeof(struct dect_phy_ping_harq_tx_payload_data_evt));
333+
}
334+
335+
static void dect_phy_ping_client_retx_complete_cb(
336+
struct dect_phy_common_op_completed_params *params, uint64_t tx_frame_time)
337+
{
338+
if (params->status == DECT_SCHEDULER_DELAYED_ERROR || params->status ==
339+
DECT_SCHEDULER_SCHEDULER_FATAL_MEM_ALLOC_ERROR) {
340+
desh_error("DECT_HARQ_CLIENT: retransmit failed - scheduler error: %d\n",
341+
params->status);
342+
} else if (params->status != NRF_MODEM_DECT_PHY_SUCCESS) {
343+
desh_error("DECT_HARQ_CLIENT: retransmit failed - error %d\n", params->status);
344+
}
322345
}
323346

324347
void dect_phy_ping_harq_client_nak_handle(void)
@@ -360,20 +383,22 @@ void dect_phy_ping_harq_client_nak_handle(void)
360383
struct dect_phy_settings *current_settings = dect_common_settings_ref_get();
361384

362385
first_possible_tx =
363-
time_now + US_TO_MODEM_TICKS(current_settings->scheduler.scheduling_delay_us);
386+
time_now + (2 * US_TO_MODEM_TICKS(current_settings->scheduler.scheduling_delay_us));
364387

365388
/* Overwrite handle, complete_cb, tx/rx timing and redundancy version to header */
366389
new_sched_list_item->phy_op_handle = DECT_PHY_PING_CLIENT_RE_TX_HANDLE;
367-
new_sched_list_item_conf->cb_op_completed = NULL;
368390
new_sched_list_item_conf->frame_time = first_possible_tx;
391+
new_sched_list_item_conf->tx.combined_tx_rx_use = true;
369392
new_sched_list_item_conf->tx.combined_rx_op.duration =
370393
MAX(remaining_time, MS_TO_MODEM_TICKS(100));
371394

372395
/* Only one timer and we don't want to have separate callback for completion */
373396
new_sched_list_item_conf->interval_mdm_ticks = 0;
374397
new_sched_list_item_conf->interval_count_left = 0;
375398
new_sched_list_item_conf->cb_op_to_mdm_with_interval_count_completed = NULL;
376-
new_sched_list_item_conf->cb_op_completed = NULL;
399+
400+
/* ... except for completion failures that happens already in a scheduler */
401+
new_sched_list_item_conf->cb_op_completed = dect_phy_ping_client_retx_complete_cb;
377402

378403
struct dect_phy_header_type2_format0_t *header =
379404
(void *)&(new_sched_list_item_conf->tx.phy_header);
@@ -388,6 +413,10 @@ void dect_phy_ping_harq_client_nak_handle(void)
388413
dect_phy_api_scheduler_list_item_dealloc(new_sched_list_item);
389414
} else {
390415
harq_processes[DECT_HARQ_CLIENT].rtx_ongoing = true;
416+
harq_processes[DECT_HARQ_CLIENT].last_redundancy_version =
417+
redundancy_version;
418+
desh_print("PCC: DECT_HARQ_CLIENT: retransmit scheduled, redundancy version %d",
419+
redundancy_version);
391420
}
392421
}
393422

@@ -1523,11 +1552,12 @@ void dect_phy_ping_mdm_op_completed(
15231552
!harq_processes[DECT_HARQ_CLIENT].rtx_ongoing) {
15241553
desh_warn("ping timeout for seq_nbr %d",
15251554
ping_data.client_data.tx_next_seq_nbr - 1);
1555+
dect_phy_ping_harq_process_round_end(DECT_HARQ_CLIENT);
15261556
}
15271557
if (ping_data.client_data.tx_scheduler_intervals_done &&
15281558
!harq_processes[DECT_HARQ_CLIENT].rtx_ongoing &&
1529-
ping_data.cmd_params.ping_count ==
1530-
ping_data.tx_metrics.tx_total_ping_req_count) {
1559+
ping_data.tx_metrics.tx_total_ping_req_count >=
1560+
ping_data.cmd_params.ping_count) {
15311561
dect_phy_ping_client_report_local_results_and_req_server_results(
15321562
NULL);
15331563
}
@@ -1568,7 +1598,8 @@ void dect_phy_ping_mdm_op_completed(
15681598

15691599
first_possible_start =
15701600
time_now +
1571-
US_TO_MODEM_TICKS(current_settings->scheduler.scheduling_delay_us);
1601+
(2 * US_TO_MODEM_TICKS(
1602+
current_settings->scheduler.scheduling_delay_us));
15721603

15731604
dect_phy_ping_server_data_on_going_rx_count_decrease();
15741605

@@ -1646,6 +1677,8 @@ static void dect_phy_ping_thread_fn(void)
16461677
dect_phy_ping_mdm_op_completed(params);
16471678
} else if (params->handle == DECT_HARQ_FEEDBACK_TX_HANDLE) {
16481679
desh_print("HARQ feedback sent.");
1680+
} else if (params->handle == DECT_HARQ_FEEDBACK_RX_HANDLE) {
1681+
desh_print("HARQ feedback RX completed.");
16491682
}
16501683
} else if (params->status != NRF_MODEM_DECT_PHY_ERR_OP_CANCELED) {
16511684
char tmp_str[128] = {0};
@@ -1840,6 +1873,9 @@ static void dect_phy_ping_thread_fn(void)
18401873
DECT_PHY_PING_CLIENT_RX_HANDLE);
18411874
dect_phy_ping_harq_client_nak_handle();
18421875
}
1876+
} else {
1877+
desh_warn("PCC: DECT_HARQ_CLIENT: HARQ resp received "
1878+
"but no HARQ process in use.");
18431879
}
18441880
} else {
18451881
desh_warn("Unsupported process nbr %d received in HARQ feedback",
@@ -1905,9 +1941,12 @@ static void dect_phy_ping_thread_fn(void)
19051941
break;
19061942
}
19071943
case DECT_PHY_PING_EVENT_HARQ_PAYLOAD_STORED: {
1908-
enum dect_harq_user *harq_user = (enum dect_harq_user *)event.data;
1944+
struct dect_phy_ping_harq_tx_payload_data_evt *evt_data =
1945+
(struct dect_phy_ping_harq_tx_payload_data_evt *)event.data;
19091946

1910-
dect_phy_ping_harq_process_round_start(*harq_user);
1947+
if (evt_data->phy_handle != DECT_PHY_PING_CLIENT_RE_TX_HANDLE) {
1948+
dect_phy_ping_harq_process_round_start(evt_data->harq_user);
1949+
}
19111950
break;
19121951
}
19131952

@@ -2198,7 +2237,7 @@ static int dect_phy_ping_rx_pdc_data_handle(struct dect_phy_data_rcv_common_para
21982237
desh_print("Server results received.");
21992238
dect_phy_ping_cmd_done();
22002239
} else if (pdu.header.message_type == DECT_MAC_MESSAGE_TYPE_PING_HARQ_FEEDBACK) {
2201-
desh_print("HARQ feedback received.");
2240+
desh_print("PDU for HARQ feedback received.");
22022241
} else {
22032242
desh_warn("type %d", pdu.header.message_type);
22042243
}

0 commit comments

Comments
 (0)