Skip to content

Commit

Permalink
admin: use dedicated port status for busy indicator (#682)
Browse files Browse the repository at this point in the history
Signed-off-by: Frank Du <frank.du@intel.com>
  • Loading branch information
frankdjx authored Jan 3, 2024
1 parent 4bfd8b1 commit 108ee53
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 4 deletions.
37 changes: 37 additions & 0 deletions lib/src/dev/mt_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ static int dev_inf_get_stat_dpdk(struct mt_interface* inf) {
stat_update_dpdk(stats_sum, &stats, drv_type);
struct mtl_port_status* port_stats = &inf->user_stats_port;
stat_update_dpdk(port_stats, &stats, drv_type);
struct mtl_port_status* stats_admin = &inf->stats_admin;
stat_update_dpdk(stats_admin, &stats, drv_type);

if (!dev_stats_not_reset) {
dbg("%s(%d), reset eth status\n", __func__, port);
Expand Down Expand Up @@ -229,6 +231,9 @@ static int dev_inf_get_stat_sw(struct mt_interface* inf) {
stat_update_sw(stats_sum, stats);
struct mtl_port_status* port_stats = &inf->user_stats_port;
stat_update_sw(port_stats, stats);
struct mtl_port_status* stats_admin = &inf->stats_admin;
stat_update_sw(stats_admin, stats);

memset(stats, 0, sizeof(*stats));

rte_spinlock_unlock(&inf->stats_lock);
Expand Down Expand Up @@ -2385,6 +2390,38 @@ int mt_dev_tsc_done_action(struct mtl_main_impl* impl) {
return 0;
}

int mt_update_admin_port_stats(struct mtl_main_impl* impl) {
int num_ports = mt_num_ports(impl);

for (int port = 0; port < num_ports; port++) {
struct mt_interface* inf = mt_if(impl, port);
dev_inf_get_stat(inf);
}
return 0;
}

int mt_reset_admin_port_stats(struct mtl_main_impl* impl) {
int num_ports = mt_num_ports(impl);

for (int port = 0; port < num_ports; port++) {
struct mt_interface* inf = mt_if(impl, port);
memset(&inf->stats_admin, 0, sizeof(inf->stats_admin));
}
return 0;
}

int mt_read_admin_port_stats(struct mtl_main_impl* impl, enum mtl_port port,
struct mtl_port_status* stats) {
if (port >= mt_num_ports(impl)) {
err("%s, invalid port %d\n", __func__, port);
return -EIO;
}

struct mt_interface* inf = mt_if(impl, port);
memcpy(stats, &inf->stats_admin, sizeof(*stats));
return 0;
}

int mtl_get_port_stats(mtl_handle mt, enum mtl_port port, struct mtl_port_status* stats) {
struct mtl_main_impl* impl = mt;

Expand Down
5 changes: 5 additions & 0 deletions lib/src/dev/mt_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,9 @@ int mt_dev_tsc_done_action(struct mtl_main_impl* impl);
uint16_t mt_dev_rss_hash_queue(struct mtl_main_impl* impl, enum mtl_port port,
uint32_t hash);

int mt_update_admin_port_stats(struct mtl_main_impl* impl);
int mt_read_admin_port_stats(struct mtl_main_impl* impl, enum mtl_port port,
struct mtl_port_status* stats);
int mt_reset_admin_port_stats(struct mtl_main_impl* impl);

#endif
5 changes: 4 additions & 1 deletion lib/src/mt_admin.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,10 @@ static void admin_alarm_handler(void* param) {

static int admin_func(struct mtl_main_impl* impl) {
struct mt_admin* admin = mt_get_admin(impl);

dbg("%s, start\n", __func__);

mt_update_admin_port_stats(impl);

admin_cal_cpu_busy(impl);

bool migrated = false;
Expand All @@ -349,6 +350,8 @@ static int admin_func(struct mtl_main_impl* impl) {

rte_eal_alarm_set(admin->period_us, admin_alarm_handler, impl);

mt_reset_admin_port_stats(impl);

return 0;
}

Expand Down
1 change: 1 addition & 0 deletions lib/src/mt_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,7 @@ struct mt_interface {
struct mtl_port_status* dev_stats_sw; /* for MT_DRV_F_NOT_DPDK_PMD */
struct mtl_port_status stats_sum; /* for dev_inf_stat dump */
struct mtl_port_status user_stats_port; /* for mtl_get_port_stats */
struct mtl_port_status stats_admin; /* stats used in admin task */

uint64_t simulate_malicious_pkt_tsc;

Expand Down
5 changes: 2 additions & 3 deletions lib/src/st2110/st_rx_video_session.c
Original file line number Diff line number Diff line change
Expand Up @@ -3124,7 +3124,7 @@ void rx_video_session_clear_cpu_busy(struct st_rx_video_session_impl* s) {
void rx_video_session_cal_cpu_busy(struct mtl_sch_impl* sch,
struct st_rx_video_session_impl* s) {
uint64_t avg_ns_per_loop = mt_sch_avg_ns_loop(sch);
/* aussme one taskelt can bulk 3 pkts */
/* assume one taskelt can bulk 3 pkts */
s->cpu_busy_score = (double)avg_ns_per_loop / 3 / s->trs * 100.0;
dbg("%s(%d), avg_ns_per_loop %" PRIu64 ", trs %f, busy %f\n", __func__, s->idx,
avg_ns_per_loop, s->trs, s->cpu_busy_score);
Expand All @@ -3137,13 +3137,12 @@ void rx_video_session_cal_cpu_busy(struct mtl_sch_impl* sch,
enum mtl_port port = mt_port_logic2phy(s->port_maps, MTL_SESSION_PORT_P);
struct mtl_port_status stats;
memset(&stats, 0, sizeof(stats));
mtl_get_port_stats(s->impl, port, &stats);
mt_read_admin_port_stats(s->impl, port, &stats);
if (stats.rx_hw_dropped_packets) {
dbg("%s(%d,%d), incomplete %d and hw_dropped_pkts %" PRIu64 "\n", __func__,
sch->idx, s->idx, incomplete_frame_cnt, stats.rx_hw_dropped_packets);
s->imiss_busy_score += 40.0;
}
mtl_reset_port_stats(s->impl, port);
if (s->imiss_busy_score > 95.0) {
notice("%s(%d,%d), imiss busy, incomplete %d and hw_dropped_pkts %" PRIu64 "\n",
__func__, sch->idx, s->idx, incomplete_frame_cnt,
Expand Down

0 comments on commit 108ee53

Please sign in to comment.