Skip to content

Commit

Permalink
dpif-netdev: Count sent packets and batches.
Browse files Browse the repository at this point in the history
New statistics for 'pmd-stats-show' command:
average number of packets per output batch.

Acked-by: Eelco Chaudron <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
Signed-off-by: Ian Stokes <[email protected]
  • Loading branch information
igsilya authored and istokes committed Dec 20, 2017
1 parent ad8b0b4 commit cc4891f
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions lib/dpif-netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,8 @@ enum dp_stat_type {
DP_STAT_LOST, /* Packets not passed up to the client. */
DP_STAT_LOOKUP_HIT, /* Number of subtable lookups for flow table
hits */
DP_STAT_SENT_PKTS, /* Packets that has been sent. */
DP_STAT_SENT_BATCHES, /* Number of batches sent. */
DP_N_STATS
};

Expand Down Expand Up @@ -508,6 +510,9 @@ struct dp_netdev_pmd_cycles {
atomic_ullong n[PMD_N_CYCLES];
};

static void dp_netdev_count_packet(struct dp_netdev_pmd_thread *,
enum dp_stat_type type, int cnt);

struct polled_queue {
struct dp_netdev_rxq *rxq;
odp_port_t port_no;
Expand Down Expand Up @@ -834,6 +839,7 @@ pmd_info_show_stats(struct ds *reply,
{
unsigned long long total_packets;
uint64_t total_cycles = 0;
double lookups_per_hit = 0, packets_per_batch = 0;
int i;

/* These loops subtracts reference values ('*_zero') from the counters.
Expand Down Expand Up @@ -875,15 +881,23 @@ pmd_info_show_stats(struct ds *reply,
}
ds_put_cstr(reply, ":\n");

if (stats[DP_STAT_MASKED_HIT] > 0) {
lookups_per_hit = stats[DP_STAT_LOOKUP_HIT]
/ (double) stats[DP_STAT_MASKED_HIT];
}
if (stats[DP_STAT_SENT_BATCHES] > 0) {
packets_per_batch = stats[DP_STAT_SENT_PKTS]
/ (double) stats[DP_STAT_SENT_BATCHES];
}

ds_put_format(reply,
"\temc hits:%llu\n\tmegaflow hits:%llu\n"
"\tavg. subtable lookups per hit:%.2f\n"
"\tmiss:%llu\n\tlost:%llu\n",
"\tmiss:%llu\n\tlost:%llu\n"
"\tavg. packets per output batch: %.2f\n",
stats[DP_STAT_EXACT_HIT], stats[DP_STAT_MASKED_HIT],
stats[DP_STAT_MASKED_HIT] > 0
? (1.0*stats[DP_STAT_LOOKUP_HIT])/stats[DP_STAT_MASKED_HIT]
: 0,
stats[DP_STAT_MISS], stats[DP_STAT_LOST]);
lookups_per_hit, stats[DP_STAT_MISS], stats[DP_STAT_LOST],
packets_per_batch);

if (total_cycles == 0) {
return;
Expand Down Expand Up @@ -3259,6 +3273,7 @@ dp_netdev_pmd_flush_output_on_port(struct dp_netdev_pmd_thread *pmd,
struct tx_port *p)
{
int tx_qid;
int output_cnt;
bool dynamic_txqs;

dynamic_txqs = p->port->dynamic_txqs;
Expand All @@ -3268,8 +3283,13 @@ dp_netdev_pmd_flush_output_on_port(struct dp_netdev_pmd_thread *pmd,
tx_qid = pmd->static_tx_qid;
}

output_cnt = dp_packet_batch_size(&p->output_pkts);

netdev_send(p->port->netdev, tx_qid, &p->output_pkts, dynamic_txqs);
dp_packet_batch_init(&p->output_pkts);

dp_netdev_count_packet(pmd, DP_STAT_SENT_PKTS, output_cnt);
dp_netdev_count_packet(pmd, DP_STAT_SENT_BATCHES, 1);
}

static void
Expand Down

0 comments on commit cc4891f

Please sign in to comment.