diff --git a/src/uct/ib/ud/base/ud_iface.c b/src/uct/ib/ud/base/ud_iface.c index 46601d4d959..bc8ab302c03 100644 --- a/src/uct/ib/ud/base/ud_iface.c +++ b/src/uct/ib/ud/base/ud_iface.c @@ -20,6 +20,15 @@ #define UCT_UD_IPV4_ADDR_LEN sizeof(struct in_addr) #define UCT_UD_IPV6_ADDR_LEN sizeof(struct in6_addr) +#if ENABLE_STATS +static ucs_stats_class_t uct_ud_iface_stats_class = { + .name = "ud_iface", + .num_counters = UCT_UD_IFACE_STAT_LAST, + .counter_names = { + [UCT_UD_IFACE_STAT_RX_DROP] = "rx_drop" + } +}; +#endif SGLIB_DEFINE_LIST_FUNCTIONS(uct_ud_iface_peer_t, uct_ud_iface_peer_cmp, next) SGLIB_DEFINE_HASHED_CONTAINER_FUNCTIONS(uct_ud_iface_peer_t, @@ -496,7 +505,7 @@ UCS_CLASS_INIT_FUNC(uct_ud_iface_t, uct_ud_iface_ops_t *ops, uct_md_h md, &config->super.tx.mp, self->config.tx_qp_len, uct_ud_iface_send_skb_init, "ud_tx_skb"); if (status != UCS_OK) { - goto err_mpool; + goto err_rx_mpool; } self->tx.skb = ucs_mpool_get(&self->tx.mp); self->tx.skb_inl.super.len = sizeof(uct_ud_neth_t); @@ -511,9 +520,17 @@ UCS_CLASS_INIT_FUNC(uct_ud_iface_t, uct_ud_iface_ops_t *ops, uct_md_h md, uct_ud_iface_calc_gid_len(self); + status = UCS_STATS_NODE_ALLOC(&self->stats, &uct_ud_iface_stats_class, + self->super.super.stats); + if (status != UCS_OK) { + goto err_tx_mpool; + } + return UCS_OK; -err_mpool: +err_tx_mpool: + ucs_mpool_cleanup(&self->tx.mp, 1); +err_rx_mpool: ucs_mpool_cleanup(&self->rx.mp, 1); err_qp: ibv_destroy_qp(self->qp); @@ -540,6 +557,7 @@ static UCS_CLASS_CLEANUP_FUNC(uct_ud_iface_t) ucs_ptr_array_cleanup(&self->eps); ucs_arbiter_cleanup(&self->tx.pending_q); ucs_assert(self->tx.pending_q_len == 0); + UCS_STATS_NODE_FREE(self->stats); uct_ud_leave(self); } diff --git a/src/uct/ib/ud/base/ud_iface.h b/src/uct/ib/ud/base/ud_iface.h index da1e1e4633f..09082761062 100644 --- a/src/uct/ib/ud/base/ud_iface.h +++ b/src/uct/ib/ud/base/ud_iface.h @@ -24,6 +24,11 @@ #define UCT_UD_MIN_INLINE 48 +enum { + UCT_UD_IFACE_STAT_RX_DROP, + UCT_UD_IFACE_STAT_LAST +}; + /* TODO: maybe tx_moderation can be defined at compile-time since tx completions are used only to know how much space is there in tx qp */ typedef struct uct_ud_iface_config { @@ -127,6 +132,9 @@ struct uct_ud_iface { int check_grh_dgid; unsigned gid_len; } config; + + UCS_STATS_NODE_DECLARE(stats); + ucs_ptr_array_t eps; uct_ud_iface_peer_t *peers[UCT_UD_HASH_SIZE]; struct { @@ -236,6 +244,7 @@ uct_ud_iface_check_grh(uct_ud_iface_t *iface, void *grh_end, int is_grh_present) dest_gid = (char*)grh_end - iface->config.gid_len; if (memcmp(local_gid, dest_gid, iface->config.gid_len)) { + UCS_STATS_UPDATE_COUNTER(iface->stats, UCT_UD_IFACE_STAT_RX_DROP, 1); ucs_trace_data("Drop packet with wrong dgid"); return 0; }