Skip to content

Commit

Permalink
UCT/UD: Added stats counter for dropped packets
Browse files Browse the repository at this point in the history
  • Loading branch information
brminich committed Sep 22, 2017
1 parent 348aa00 commit b54e114
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/uct/ib/ud/base/ud_iface.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}

Expand Down
9 changes: 9 additions & 0 deletions src/uct/ib/ud/base/ud_iface.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit b54e114

Please sign in to comment.