summaryrefslogtreecommitdiff
path: root/ofproto/ofproto-dpif.c
diff options
context:
space:
mode:
authorzhaozhanxu <zhaozhanxu@163.com>2019-12-05 14:26:25 +0800
committerSimon Horman <simon.horman@netronome.com>2019-12-06 10:57:16 +0100
commit164413156cf94d0f4dd1971cf0cc820f8b86055b (patch)
tree3c4147b854e9cbfa15710a349cb37a7924affe35 /ofproto/ofproto-dpif.c
parent3843208ee019b8559dc02a01039b8d43cc4dac0b (diff)
downloadopenvswitch-164413156cf94d0f4dd1971cf0cc820f8b86055b.tar.gz
Add offload packets statistics
Add argument '--offload-stats' for command ovs-appctl bridge/dump-flows to display the offloaded packets statistics. The commands display as below: orignal command: ovs-appctl bridge/dump-flows br0 duration=574s, n_packets=1152, n_bytes=110768, priority=0,actions=NORMAL table_id=254, duration=574s, n_packets=0, n_bytes=0, priority=2,recirc_id=0,actions=drop table_id=254, duration=574s, n_packets=0, n_bytes=0, priority=0,reg0=0x1,actions=controller(reason=) table_id=254, duration=574s, n_packets=0, n_bytes=0, priority=0,reg0=0x2,actions=drop table_id=254, duration=574s, n_packets=0, n_bytes=0, priority=0,reg0=0x3,actions=drop new command with argument '--offload-stats' Notice: 'n_offload_packets' are a subset of n_packets and 'n_offload_bytes' are a subset of n_bytes. ovs-appctl bridge/dump-flows --offload-stats br0 duration=582s, n_packets=1152, n_bytes=110768, n_offload_packets=1107, n_offload_bytes=107992, priority=0,actions=NORMAL table_id=254, duration=582s, n_packets=0, n_bytes=0, n_offload_packets=0, n_offload_bytes=0, priority=2,recirc_id=0,actions=drop table_id=254, duration=582s, n_packets=0, n_bytes=0, n_offload_packets=0, n_offload_bytes=0, priority=0,reg0=0x1,actions=controller(reason=) table_id=254, duration=582s, n_packets=0, n_bytes=0, n_offload_packets=0, n_offload_bytes=0, priority=0,reg0=0x2,actions=drop table_id=254, duration=582s, n_packets=0, n_bytes=0, n_offload_packets=0, n_offload_bytes=0, priority=0,reg0=0x3,actions=drop Signed-off-by: zhaozhanxu <zhaozhanxu@163.com> Signed-off-by: Simon Horman <simon.horman@netronome.com>
Diffstat (limited to 'ofproto/ofproto-dpif.c')
-rw-r--r--ofproto/ofproto-dpif.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index e5486fdab..b17c6cdca 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -80,7 +80,7 @@ COVERAGE_DEFINE(packet_in_overflow);
struct flow_miss;
-static void rule_get_stats(struct rule *, uint64_t *packets, uint64_t *bytes,
+static void rule_get_stats(struct rule *, struct pkt_stats *stats,
long long int *used);
static struct rule_dpif *rule_dpif_cast(const struct rule *);
static void rule_expire(struct rule_dpif *, long long now);
@@ -4168,7 +4168,7 @@ ofproto_dpif_execute_actions__(struct ofproto_dpif *ofproto,
dpif_flow_stats_extract(flow, packet, time_msec(), &stats);
if (rule) {
- rule_dpif_credit_stats(rule, &stats);
+ rule_dpif_credit_stats(rule, &stats, false);
}
uint64_t odp_actions_stub[1024 / 8];
@@ -4222,10 +4222,14 @@ ofproto_dpif_execute_actions(struct ofproto_dpif *ofproto,
static void
rule_dpif_credit_stats__(struct rule_dpif *rule,
const struct dpif_flow_stats *stats,
- bool credit_counts)
+ bool credit_counts, bool offloaded)
OVS_REQUIRES(rule->stats_mutex)
{
if (credit_counts) {
+ if (offloaded) {
+ rule->stats.n_offload_packets += stats->n_packets;
+ rule->stats.n_offload_bytes += stats->n_bytes;
+ }
rule->stats.n_packets += stats->n_packets;
rule->stats.n_bytes += stats->n_bytes;
}
@@ -4234,15 +4238,16 @@ rule_dpif_credit_stats__(struct rule_dpif *rule,
void
rule_dpif_credit_stats(struct rule_dpif *rule,
- const struct dpif_flow_stats *stats)
+ const struct dpif_flow_stats *stats, bool offloaded)
{
ovs_mutex_lock(&rule->stats_mutex);
if (OVS_UNLIKELY(rule->new_rule)) {
ovs_mutex_lock(&rule->new_rule->stats_mutex);
- rule_dpif_credit_stats__(rule->new_rule, stats, rule->forward_counts);
+ rule_dpif_credit_stats__(rule->new_rule, stats, rule->forward_counts,
+ offloaded);
ovs_mutex_unlock(&rule->new_rule->stats_mutex);
} else {
- rule_dpif_credit_stats__(rule, stats, true);
+ rule_dpif_credit_stats__(rule, stats, true, offloaded);
}
ovs_mutex_unlock(&rule->stats_mutex);
}
@@ -4701,17 +4706,19 @@ rule_destruct(struct rule *rule_)
}
static void
-rule_get_stats(struct rule *rule_, uint64_t *packets, uint64_t *bytes,
+rule_get_stats(struct rule *rule_, struct pkt_stats *stats,
long long int *used)
{
struct rule_dpif *rule = rule_dpif_cast(rule_);
ovs_mutex_lock(&rule->stats_mutex);
if (OVS_UNLIKELY(rule->new_rule)) {
- rule_get_stats(&rule->new_rule->up, packets, bytes, used);
+ rule_get_stats(&rule->new_rule->up, stats, used);
} else {
- *packets = rule->stats.n_packets;
- *bytes = rule->stats.n_bytes;
+ stats->n_packets = rule->stats.n_packets;
+ stats->n_bytes = rule->stats.n_bytes;
+ stats->n_offload_packets = rule->stats.n_offload_packets;
+ stats->n_offload_bytes = rule->stats.n_offload_bytes;
*used = rule->stats.used;
}
ovs_mutex_unlock(&rule->stats_mutex);
@@ -4875,7 +4882,7 @@ ofproto_dpif_xcache_execute(struct ofproto_dpif *ofproto,
case XC_GROUP:
case XC_TNL_NEIGH:
case XC_TUNNEL_HEADER:
- xlate_push_stats_entry(entry, stats);
+ xlate_push_stats_entry(entry, stats, false);
break;
default:
OVS_NOT_REACHED();