Skip to content

Commit 5ca41bb

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 7c9b061 commit 5ca41bb

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-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: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -401,45 +401,43 @@ 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 can only help if the actual throughput is slightly higher than expected. */
407+
if (measured_bps > rl_bps && pad_interval > 32) {
408+
s->pacing.pad_interval = pad_interval;
409+
mt_pacing_train_pad_result_add(impl, port, rl_bps, pad_interval);
410+
train_end_time = mt_get_tsc(impl);
411+
info("%s(%d,%d), trained pad_interval %f pkts_per_frame %f with time %fs\n", __func__,
412+
idx, s_port, pad_interval, pkts_per_frame,
413+
(double)(train_end_time - train_start_time) / NS_PER_S);
414+
return 0;
415+
}
407416
if (measured_bps < rl_bps) {
408-
info("%s(%d), measured bps %" PRIu64 " is lower then set bps %" PRIu64 "\n", __func__,
417+
info("%s(%d), measured bps %" PRIu64 " is lower than set bps %" PRIu64 "\n", __func__,
409418
idx, (uint64_t)measured_bps, rl_bps);
419+
} else {
420+
info("%s(%d), too small pad_interval %f pkts_per_frame %f, st20_total_pkts %d\n",
421+
__func__, idx, pad_interval, pkts_per_frame, s->st20_total_pkts);
422+
}
410423

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-
}
424+
if (!mt_pacing_train_bps_result_search(impl, port, rl_bps, &bps_to_set)) {
425+
err("%s(%d), measured speed is out of range on already trained bps\n", __func__, idx);
426+
return -EINVAL;
427+
}
415428

416429
/* Slightly increase the target bitrate to compensate for measurement inaccuracies,
417430
* rounding errors, and system overhead. This helps ensure the actual transmission bitrate
418431
* meets or exceeds the required rate
419432
*/
420433
#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;
434+
bps_to_set = INCREASE_BPS_FACTOR * (rl_bps * rl_bps) / measured_bps;
435+
info("%s(%d), Retrain pacing with bps changed to %" PRIu64 "\n", __func__, idx,
436+
bps_to_set);
437+
mt_pacing_train_bps_result_add(impl, port, rl_bps, bps_to_set);
438+
mt_txq_set_tx_bps(queue, bps_to_set);
439+
ret = tv_train_pacing(impl, s, s_port);
440+
return ret;
443441
}
444442

445443
static int tv_init_pacing(struct mtl_main_impl* impl,

0 commit comments

Comments
 (0)