From d0880467cf33c2e3b18e20a6ee53ee271a8586e4 Mon Sep 17 00:00:00 2001 From: Frank Du Date: Thu, 25 Jan 2024 13:26:44 +0800 Subject: [PATCH 1/2] timing_parser: log failed cause to a file Signed-off-by: Frank Du --- README.md | 1 + lib/src/st2110/st_header.h | 1 + lib/src/st2110/st_rx_video_session.c | 10 ++++++++++ python/example/misc_util.py | 11 +++++++++++ python/example/rx_timing_parser.py | 23 ++++++++++++++++------- 5 files changed, 39 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 88383061d..1d1c3bdf6 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ If you find value in our project, please consider giving it a star. Your support * SIMD color space converter between big-endian and little-endian. * ST2110-22 with encoder/decoder plugin interface. * ST2022-6 by RTP passthrough interface. +* ST2110-20 RX timing compliance parser with hardware RX timestamp offload. ### 1.2 Architecture diff --git a/lib/src/st2110/st_header.h b/lib/src/st2110/st_header.h index 3988424ef..fd5143bac 100644 --- a/lib/src/st2110/st_header.h +++ b/lib/src/st2110/st_header.h @@ -558,6 +558,7 @@ struct st_rx_video_session_impl { bool time_measure; uint16_t rx_burst_size; uint16_t cur_succ_burst_cnt; + bool in_continuous_burst[MTL_SESSION_PORT_MAX]; struct st20_rx_ops ops; char ops_name[ST_MAX_NAME_LEN]; diff --git a/lib/src/st2110/st_rx_video_session.c b/lib/src/st2110/st_rx_video_session.c index 5b7888e20..dd93195c5 100644 --- a/lib/src/st2110/st_rx_video_session.c +++ b/lib/src/st2110/st_rx_video_session.c @@ -1375,6 +1375,11 @@ static inline void rv_tp_pkt_handle(struct st_rx_video_session_impl* s, tp->stat_untrusted_pkts++; return; } + if (s->in_continuous_burst[s_port]) { + /* untrusted result */ + tp->stat_untrusted_pkts++; + return; + } struct mtl_main_impl* impl = rv_get_impl(s); enum mtl_port port = mt_port_logic2phy(s->port_maps, s_port); @@ -2670,11 +2675,16 @@ static int rv_pkt_rx_tasklet(struct st_rx_video_session_impl* s) { s->stat_burst_succ_cnt++; s->stat_burst_pkts_sum += rv; if (rv > s->stat_burst_pkts_max) s->stat_burst_pkts_max = rv; + if (rv >= s->rx_burst_size) { + s->in_continuous_burst[s_port] = true; + } rv_handle_mbuf(&s->priv[s_port], &mbuf[0], rv); rte_pktmbuf_free_bulk(&mbuf[0], rv); done = false; + } else { + s->in_continuous_burst[s_port] = false; } } diff --git a/python/example/misc_util.py b/python/example/misc_util.py index 1f62c2414..d494c7f09 100644 --- a/python/example/misc_util.py +++ b/python/example/misc_util.py @@ -4,6 +4,7 @@ import argparse import ctypes +import datetime import sys import cv2 @@ -117,6 +118,10 @@ def parse_args(is_tx): ) # lcores parser.add_argument("--lcores", type=str, default="", help="lcores") + # log file + parser.add_argument("--log_file", type=str, default="py_temp.log", help="log_file") + # default max histories 10 mins, 1 entry per second + parser.add_argument("--histories", type=int, default=60 * 10, help="histories") return parser.parse_args() @@ -354,3 +359,9 @@ def copy_to_st_frame(yuv_frame, frame): memcpy_ops.src = src_address_uint64 memcpy_ops.sz = frame.data_size mtl.mtl_memcpy_action(memcpy_ops) + + +def cur_time_str(): + current_time = datetime.datetime.now() + formatted_time = current_time.strftime("%Y-%m-%d %H:%M:%S.%f")[:-3] + return formatted_time diff --git a/python/example/rx_timing_parser.py b/python/example/rx_timing_parser.py index 62e9d1763..4ec93cc85 100644 --- a/python/example/rx_timing_parser.py +++ b/python/example/rx_timing_parser.py @@ -14,13 +14,13 @@ class Dashboard: active = False - def __init__(self, max_histories): + def __init__(self, max_histories, title_str): self.max_histories = max_histories # init data self.init_data() # init vrx plot self.fig, self.ax = plt.subplots() - plt.title("ST2110-20 Rx Timing Parser") + plt.title(title_str) plt.subplots_adjust(bottom=0.2) (self.vrx_max_line,) = self.ax.plot( self.times, self.vrx_max_values, label="VRX Max" @@ -110,7 +110,7 @@ def update_compliance(self, narrow, wide, fail): self.fail_count += fail -def rx_frame_loop(st20p_rx, update_interval, plot): +def rx_frame_loop(st20p_rx, update_interval, plot, log_file): f_idx = 0 vrx_min = 10000 vrx_max = -10000 @@ -119,8 +119,9 @@ def rx_frame_loop(st20p_rx, update_interval, plot): wide = 0 fail = 0 - # loop until ctrl-c + log_file.write(f"{misc_util.cur_time_str()}: start\n") + # loop until ctrl-c while plot.active: frame = mtl.st20p_rx_get_frame(st20p_rx) if frame: @@ -137,6 +138,8 @@ def rx_frame_loop(st20p_rx, update_interval, plot): wide += 1 else: fail += 1 + log_file.write(f"{misc_util.cur_time_str()}: {tp.failed_cause}\n") + log_file.flush() if f_idx > update_interval: vrx_avg = vrx_avg_sum // f_idx @@ -160,6 +163,8 @@ def rx_frame_loop(st20p_rx, update_interval, plot): # sleep to allow ui draw time.sleep(0.005) + log_file.write(f"{misc_util.cur_time_str()}: ending\n") + def plt_show(): plt.show() @@ -168,8 +173,10 @@ def plt_show(): def main(): args = misc_util.parse_args(False) - # initial plot, max 1 hour, 1 item 1 second - plot = Dashboard(max_histories=60 * 60 * 1) + log_file = open(args.log_file, "w") + + title_str = f"ST2110-20 Rx Timing Parser: {args.p_rx_ip}@{args.udp_port}" + plot = Dashboard(max_histories=args.histories, title_str=title_str) # Init mtl para init_para = mtl.mtl_init_params() @@ -226,7 +233,7 @@ def main(): # update plot per 1 s framerate = mtl.st_frame_rate(rx_para.fps) rx_frame_thread = threading.Thread( - target=rx_frame_loop, args=(st20p_rx, framerate, plot) + target=rx_frame_loop, args=(st20p_rx, framerate, plot, log_file) ) rx_frame_thread.start() @@ -245,6 +252,8 @@ def main(): # Free MTL instance mtl.mtl_uninit(mtl_handle) + log_file.close() + print("Everything fine, bye") From 14d567ad686b5b680b1815a06c4c86a9aa86a5ec Mon Sep 17 00:00:00 2001 From: Frank Du Date: Thu, 25 Jan 2024 14:28:01 +0800 Subject: [PATCH 2/2] fix Signed-off-by: Frank Du --- lib/src/st2110/st_rx_video_session.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/st2110/st_rx_video_session.c b/lib/src/st2110/st_rx_video_session.c index dd93195c5..e89f21400 100644 --- a/lib/src/st2110/st_rx_video_session.c +++ b/lib/src/st2110/st_rx_video_session.c @@ -2675,7 +2675,7 @@ static int rv_pkt_rx_tasklet(struct st_rx_video_session_impl* s) { s->stat_burst_succ_cnt++; s->stat_burst_pkts_sum += rv; if (rv > s->stat_burst_pkts_max) s->stat_burst_pkts_max = rv; - if (rv >= s->rx_burst_size) { + if (rv >= (s->rx_burst_size / 2)) { s->in_continuous_burst[s_port] = true; }