Skip to content

Commit 38f86d2

Browse files
committed
Fix: RL training on e830 NIC
Rl training failed when measured throughput was significantly bigger then expected. Fixed by adding retraining in this case. Signed-off-by: Kasiewicz, Marek <[email protected]>
1 parent 4bd5d43 commit 38f86d2

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

lib/src/st2110/st_tx_audio_session.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,7 @@ static inline uint64_t tx_audio_session_profiling_rl_bps(
12551255
}
12561256
double actual_per_sec = actual_per_sec_sum / entry_in_sum;
12571257
double ratio = actual_per_sec / expect_per_sec;
1258-
if (ratio > 1.1 || ratio < 0.9) {
1258+
if (ratio > 1.15 || ratio < 0.9) {
12591259
err("%s(%d), fail, expect %f but actual %f\n", __func__, idx, expect_per_sec,
12601260
actual_per_sec);
12611261
return 0;

lib/src/st2110/st_tx_video_session.c

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -401,45 +401,46 @@ static int tv_train_pacing(struct mtl_main_impl* impl, struct st_tx_video_sessio
401401
}
402402
pkts_per_frame = pkts_per_frame * reactive;
403403
measured_bps = s->st20_pkt_size * pkts_per_sec * reactive;
404+
pad_interval = (float)s->st20_total_pkts / (pkts_per_frame - s->st20_total_pkts);
404405

405-
/* If the measured speed is lower than expected. Set higher bps and retrain to add
406-
* padding */
406+
/* Padding is effective only when the actual throughput slightly exceeds the expected value.
407+
* The pad interval decreases as the measured throughput surpasses the expected rate. If the
408+
* difference is too significant, it indicates an issue. A minimum padding value of 32 is chosen
409+
* as a reasonable threshold. */
410+
if (measured_bps > rl_bps && pad_interval > 32) {
411+
s->pacing.pad_interval = pad_interval;
412+
mt_pacing_train_pad_result_add(impl, port, rl_bps, pad_interval);
413+
train_end_time = mt_get_tsc(impl);
414+
info("%s(%d,%d), trained pad_interval %f pkts_per_frame %f with time %fs\n", __func__,
415+
idx, s_port, pad_interval, pkts_per_frame,
416+
(double)(train_end_time - train_start_time) / NS_PER_S);
417+
return 0;
418+
}
407419
if (measured_bps < rl_bps) {
408-
info("%s(%d), measured bps %" PRIu64 " is lower then set bps %" PRIu64 "\n", __func__,
420+
info("%s(%d), measured bps %" PRIu64 " is lower than set bps %" PRIu64 "\n", __func__,
409421
idx, (uint64_t)measured_bps, rl_bps);
422+
} else {
423+
info("%s(%d), too small pad_interval %f pkts_per_frame %f, st20_total_pkts %d\n",
424+
__func__, idx, pad_interval, pkts_per_frame, s->st20_total_pkts);
425+
}
410426

411-
if (!mt_pacing_train_bps_result_search(impl, port, rl_bps, &bps_to_set)) {
412-
err("%s(%d), measured speed is too low on already trained bps\n", __func__, idx);
413-
return -EINVAL;
414-
}
427+
if (!mt_pacing_train_bps_result_search(impl, port, rl_bps, &bps_to_set)) {
428+
err("%s(%d), measured speed is out of range on already trained bps\n", __func__, idx);
429+
return -EINVAL;
430+
}
415431

416432
/* Slightly increase the target bitrate to compensate for measurement inaccuracies,
417433
* rounding errors, and system overhead. This helps ensure the actual transmission bitrate
418434
* meets or exceeds the required rate
419435
*/
420436
#define INCREASE_BPS_FACTOR 1.005
421-
bps_to_set = INCREASE_BPS_FACTOR * (rl_bps * rl_bps) / measured_bps;
422-
info("%s(%d), increase bps to %" PRIu64 "\n", __func__, idx, bps_to_set);
423-
mt_pacing_train_bps_result_add(impl, port, rl_bps, bps_to_set);
424-
mt_txq_set_tx_bps(queue, bps_to_set);
425-
ret = tv_train_pacing(impl, s, s_port);
426-
return ret;
427-
}
428-
429-
pad_interval = (float)s->st20_total_pkts / (pkts_per_frame - s->st20_total_pkts);
430-
if (pad_interval < 32) {
431-
err("%s(%d), too small pad_interval %f pkts_per_frame %f, st20_total_pkts %d\n",
432-
__func__, idx, pad_interval, pkts_per_frame, s->st20_total_pkts);
433-
return -EINVAL;
434-
}
435-
436-
s->pacing.pad_interval = pad_interval;
437-
mt_pacing_train_pad_result_add(impl, port, rl_bps, pad_interval);
438-
train_end_time = mt_get_tsc(impl);
439-
info("%s(%d,%d), trained pad_interval %f pkts_per_frame %f with time %fs\n", __func__,
440-
idx, s_port, pad_interval, pkts_per_frame,
441-
(double)(train_end_time - train_start_time) / NS_PER_S);
442-
return 0;
437+
bps_to_set = INCREASE_BPS_FACTOR * (rl_bps * rl_bps) / measured_bps;
438+
info("%s(%d), Retrain pacing with bps changed to %" PRIu64 "\n", __func__, idx,
439+
bps_to_set);
440+
mt_pacing_train_bps_result_add(impl, port, rl_bps, bps_to_set);
441+
mt_txq_set_tx_bps(queue, bps_to_set);
442+
ret = tv_train_pacing(impl, s, s_port);
443+
return ret;
443444
}
444445

445446
static int tv_init_pacing(struct mtl_main_impl* impl,

0 commit comments

Comments
 (0)