diff --git a/daemon/call.c b/daemon/call.c index a2adfe2fd..3111a8236 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -531,7 +531,7 @@ static void count_stream_stats_kernel(struct packet_stream *ps) { else \ diff_ ## x ## _ ## io = (ke)->x - ks_val; \ atomic64_add(&ps->stats_ ## io.x, diff_ ## x ## _ ## io); \ - atomic64_add(&ps->selected_sfd->local_intf->stats_ ## io.x, diff_ ## x ## _ ## io); \ + atomic64_add(&ps->selected_sfd->local_intf->stats.io.x, diff_ ## x ## _ ## io); \ RTPE_STATS_ADD(x ## _kernel, diff_ ## x ## _ ## io); \ } while (0) diff --git a/daemon/codec.c b/daemon/codec.c index d9ea65942..c4d683b21 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -1629,8 +1629,8 @@ static int __handler_func_sequencer(struct media_packet *mp, struct transcode_pa atomic64_inc(&ssrc_in->packets); atomic64_add(&ssrc_in->octets, mp->payload.len); - atomic64_inc(&mp->sfd->local_intf->stats_in.packets); - atomic64_add(&mp->sfd->local_intf->stats_in.bytes, mp->payload.len); + atomic64_inc(&mp->sfd->local_intf->stats.in.packets); + atomic64_add(&mp->sfd->local_intf->stats.in.bytes, mp->payload.len); if (packet->bypass_seq) { // bypass sequencer @@ -1672,7 +1672,7 @@ static int __handler_func_sequencer(struct media_packet *mp, struct transcode_pa if (func_ret != 1) __transcode_packet_free(packet); ssrc_in_p->duplicates++; - atomic64_inc(&mp->sfd->local_intf->stats.duplicates); + atomic64_inc(&mp->sfd->local_intf->stats.s.duplicates); RTPE_STATS_INC(rtp_duplicates); goto out; } diff --git a/daemon/media_player.c b/daemon/media_player.c index ece5e3121..f86908df8 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -252,8 +252,8 @@ static bool __send_timer_send_1(struct rtp_header *rh, struct packet_stream *sin atomic64_inc(&sink->stats_out.packets); atomic64_add(&sink->stats_out.bytes, cp->s.len); - atomic64_inc(&sink_fd->local_intf->stats_out.packets); - atomic64_add(&sink_fd->local_intf->stats_out.bytes, cp->s.len); + atomic64_inc(&sink_fd->local_intf->stats.out.packets); + atomic64_add(&sink_fd->local_intf->stats.out.bytes, cp->s.len); log_info_pop(); diff --git a/daemon/media_socket.c b/daemon/media_socket.c index e9e23b548..f589a2b1f 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -1523,7 +1523,7 @@ static void __stream_update_stats(struct packet_stream *ps, int have_in_lock) { parent->jitter = stats_info.ssrc_stats[u].jitter; RTPE_STATS_ADD(packets_lost, stats_info.ssrc_stats[u].total_lost); - atomic64_add(&ps->selected_sfd->local_intf->stats.packets_lost, + atomic64_add(&ps->selected_sfd->local_intf->stats.s.packets_lost, stats_info.ssrc_stats[u].total_lost); uint32_t ssrc_map_out = ssrc_ctx->ssrc_map_out; @@ -1941,7 +1941,7 @@ static void media_packet_rtp_in(struct packet_handler_ctx *phc) phc->payload_type, FMT_M(endpoint_print_buf(&phc->mp.fsin))); atomic64_inc(&phc->mp.stream->stats_in.errors); - atomic64_inc(&phc->mp.sfd->local_intf->stats_in.errors); + atomic64_inc(&phc->mp.sfd->local_intf->stats.in.errors); RTPE_STATS_INC(errors_user); } else { @@ -2131,7 +2131,7 @@ static int media_packet_address_check(struct packet_handler_ctx *phc) FMT_M(sockaddr_print_buf(&phc->mp.stream->endpoint.address), phc->mp.stream->endpoint.port)); atomic64_inc(&phc->mp.stream->stats_in.errors); - atomic64_inc(&phc->mp.sfd->local_intf->stats_in.errors); + atomic64_inc(&phc->mp.sfd->local_intf->stats.in.errors); ret = -1; } } @@ -2500,8 +2500,8 @@ static int stream_packet(struct packet_handler_ctx *phc) { } } atomic64_add(&phc->mp.stream->stats_in.bytes, phc->s.len); - atomic64_inc(&phc->mp.sfd->local_intf->stats_in.packets); - atomic64_add(&phc->mp.sfd->local_intf->stats_in.bytes, phc->s.len); + atomic64_inc(&phc->mp.sfd->local_intf->stats.in.packets); + atomic64_add(&phc->mp.sfd->local_intf->stats.in.bytes, phc->s.len); atomic64_set(&phc->mp.stream->last_packet, rtpe_now.tv_sec); RTPE_STATS_INC(packets_user); RTPE_STATS_ADD(bytes_user, phc->s.len); @@ -2665,7 +2665,7 @@ next_mirror: err_next: ilog(LOG_DEBUG | LOG_FLAG_LIMIT ,"Error when sending message. Error: %s", strerror(errno)); atomic64_inc(&sink->stats_in.errors); - atomic64_inc(&sink->selected_sfd->local_intf->stats_out.errors); + atomic64_inc(&sink->selected_sfd->local_intf->stats.out.errors); RTPE_STATS_INC(errors_user); goto next; @@ -2708,7 +2708,7 @@ out: if (handler_ret < 0) { atomic64_inc(&phc->mp.stream->stats_in.errors); - atomic64_inc(&phc->mp.sfd->local_intf->stats_in.errors); + atomic64_inc(&phc->mp.sfd->local_intf->stats.in.errors); RTPE_STATS_INC(errors_user); } diff --git a/daemon/statistics.c b/daemon/statistics.c index 652bbc097..c27b2ca24 100644 --- a/daemon/statistics.c +++ b/daemon/statistics.c @@ -681,7 +681,7 @@ GQueue *statistics_gather_metrics(void) { HEADER("}", NULL); #define F(f) \ - METRICs(#f, UINT64F, atomic64_get(&lif->stats.f)); \ + METRICs(#f, UINT64F, atomic64_get(&lif->stats.s.f)); \ PROM("interface_" #f, "counter"); \ PROMLAB("name=\"%s\",address=\"%s\"", lif->logical->name.s, \ sockaddr_print_buf(&lif->spec->local_address.addr)); @@ -692,10 +692,10 @@ GQueue *statistics_gather_metrics(void) { HEADER("{", NULL); struct interface_sampled_stats_avg stat_avg; - interface_sampled_avg(&stat_avg, &lif->sampled_stats); + interface_sampled_avg(&stat_avg, &lif->stats.sampled); #define INTF_SAMPLED_STAT(stat_name, name, divisor, prefix, label...) \ - STAT_GET_PRINT_GEN(&lif->sampled_stats, &sampled_avgs, stat_name, name, divisor, prefix, label) + STAT_GET_PRINT_GEN(&lif->stats.sampled, &stat_avg, stat_name, name, divisor, prefix, label) INTF_SAMPLED_STAT(mos, "MOS", 10.0, "interface_", "name=\"%s\",address=\"%s\"", lif->logical->name.s, @@ -721,7 +721,7 @@ GQueue *statistics_gather_metrics(void) { HEADER("ingress", NULL); HEADER("{", NULL); #define F(f) \ - METRICs(#f, UINT64F, atomic64_get(&lif->stats_in.f)); \ + METRICs(#f, UINT64F, atomic64_get(&lif->stats.in.f)); \ PROM("interface_" #f, "gauge"); \ PROMLAB("name=\"%s\",address=\"%s\",direction=\"ingress\"", lif->logical->name.s, \ sockaddr_print_buf(&lif->spec->local_address.addr)); @@ -732,7 +732,7 @@ GQueue *statistics_gather_metrics(void) { HEADER("egress", NULL); HEADER("{", NULL); #define F(f) \ - METRICs(#f, UINT64F, atomic64_get(&lif->stats_out.f)); \ + METRICs(#f, UINT64F, atomic64_get(&lif->stats.out.f)); \ PROM("interface_" #f, "gauge"); \ PROMLAB("name=\"%s\",address=\"%s\",direction=\"egress\"", lif->logical->name.s, \ sockaddr_print_buf(&lif->spec->local_address.addr)); diff --git a/include/media_socket.h b/include/media_socket.h index 5c466be2f..881a5d3fe 100644 --- a/include/media_socket.h +++ b/include/media_socket.h @@ -129,6 +129,12 @@ struct interface_sampled_stats_avg { struct interface_sampled_stats_fields avg; struct interface_sampled_stats_fields stddev; }; +struct interface_stats_block { + struct interface_counter_stats_dir in, + out; + struct interface_counter_stats s; + struct interface_sampled_stats sampled; +}; INLINE void interface_sampled_calc_diff(const struct interface_sampled_stats *stats, struct interface_sampled_stats *intv, struct interface_sampled_stats *diff) { @@ -149,10 +155,7 @@ struct local_intf { const struct logical_intf *logical; str ice_foundation; - struct interface_counter_stats_dir stats_in, - stats_out; - struct interface_counter_stats stats; - struct interface_sampled_stats sampled_stats; + struct interface_stats_block stats; }; struct intf_list { struct local_intf *local_intf; diff --git a/include/statistics.h b/include/statistics.h index 7d56b409a..a02b4ce84 100644 --- a/include/statistics.h +++ b/include/statistics.h @@ -174,9 +174,9 @@ extern struct global_sampled_min_max rtpe_sampled_min_max; // master lifetime m RTPE_STATS_SAMPLE(field, num); \ if (sfd) { \ struct local_intf *__intf = sfd->local_intf; \ - atomic64_add(&__intf->sampled_stats.sums.field, num); \ - atomic64_add(&__intf->sampled_stats.sums_squared.field, num * num); \ - atomic64_inc(&__intf->sampled_stats.counts.field); \ + atomic64_add(&__intf->stats.sampled.sums.field, num); \ + atomic64_add(&__intf->stats.sampled.sums_squared.field, num * num); \ + atomic64_inc(&__intf->stats.sampled.counts.field); \ } \ } while (0)