Add support to count upcall packets Signed-off-by: wangchuanlei <wangchuan...@inspur.com> --- include/linux/openvswitch.h | 19 +++++++++++++++++++ include/openvswitch/netdev.h | 3 +++ lib/dpctl.c | 4 ++++ lib/dpif-netlink.c | 12 ++++++++++++ lib/dpif-netlink.h | 1 + lib/netdev-linux.c | 8 ++++++++ 6 files changed, 47 insertions(+)
diff --git a/include/linux/openvswitch.h b/include/linux/openvswitch.h index 8bb5abdc8..d5e0f3fd9 100644 --- a/include/linux/openvswitch.h +++ b/include/linux/openvswitch.h @@ -141,6 +141,11 @@ struct ovs_vport_stats { __u64 tx_dropped; /* no space available in linux */ }; +struct ovs_vport_upcall_stats { + uint64_t upcall_success; /* total packets upcall succeed */ + uint64_t upcall_fail; /* total packets upcall failed */ +}; + /* Allow last Netlink attribute to be unaligned */ #define OVS_DP_F_UNALIGNED (1 << 0) @@ -301,11 +306,25 @@ enum ovs_vport_attr { OVS_VPORT_ATTR_PAD, OVS_VPORT_ATTR_IFINDEX, OVS_VPORT_ATTR_NETNSID, + OVS_VPORT_ATTR_UPCALL_STATS, __OVS_VPORT_ATTR_MAX }; #define OVS_VPORT_ATTR_MAX (__OVS_VPORT_ATTR_MAX - 1) +/** +* enum OVS_VPORT_UPCALL_ATTR -- attributes for %OVS_VPORT_UPCALL* commands +* @OVS_VPORT_UPCALL_SUCCESS: 64-bit upcall success packets. +* @OVS_VPORT_UPCALL_FAIL: 64-bit upcall fail packets. +*/ +enum OVS_VPORT_UPCALL_ATTR { + OVS_VPORT_UPCALL_SUCCESS, + OVS_VPORT_UPCALL_FAIL, + __OVS_VPORT_UPCALL_MAX, +}; + +#define OVS_VPORT_UPCALL_MAX (__OVS_VPORT_UPCALL_MAX - 1) + enum { OVS_VXLAN_EXT_UNSPEC, OVS_VXLAN_EXT_GBP, diff --git a/include/openvswitch/netdev.h b/include/openvswitch/netdev.h index 0c10f7b48..ed1bf73dc 100644 --- a/include/openvswitch/netdev.h +++ b/include/openvswitch/netdev.h @@ -87,6 +87,9 @@ struct netdev_stats { uint64_t rx_oversize_errors; uint64_t rx_fragmented_errors; uint64_t rx_jabber_errors; + + uint64_t tx_upcall_success; + uint64_t tx_upcall_fail; }; /* Structure representation of custom statistics counter */ diff --git a/lib/dpctl.c b/lib/dpctl.c index 29041fa3e..c8b195c89 100644 --- a/lib/dpctl.c +++ b/lib/dpctl.c @@ -744,6 +744,10 @@ show_dpif(struct dpif *dpif, struct dpctl_params *dpctl_p) print_stat(dpctl_p, " collisions:", s.collisions); dpctl_print(dpctl_p, "\n"); + print_stat(dpctl_p, " upcall success:", s.tx_upcall_success); + print_stat(dpctl_p, " upcall fail:", s.tx_upcall_fail); + dpctl_print(dpctl_p, "\n"); + print_stat(dpctl_p, " RX bytes:", s.rx_bytes); print_human_size(dpctl_p, s.rx_bytes); print_stat(dpctl_p, " TX bytes:", s.tx_bytes); diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c index 026b0daa8..ecc625aac 100644 --- a/lib/dpif-netlink.c +++ b/lib/dpif-netlink.c @@ -4685,6 +4685,7 @@ dpif_netlink_vport_from_ofpbuf(struct dpif_netlink_vport *vport, .optional = true }, [OVS_VPORT_ATTR_OPTIONS] = { .type = NL_A_NESTED, .optional = true }, [OVS_VPORT_ATTR_NETNSID] = { .type = NL_A_U32, .optional = true }, + [OVS_VPORT_ATTR_UPCALL_STATS] = { .type = NL_A_NESTED, .optional = true }, }; dpif_netlink_vport_init(vport); @@ -4716,6 +4717,17 @@ dpif_netlink_vport_from_ofpbuf(struct dpif_netlink_vport *vport, if (a[OVS_VPORT_ATTR_STATS]) { vport->stats = nl_attr_get(a[OVS_VPORT_ATTR_STATS]); } + if (a[OVS_VPORT_ATTR_UPCALL_STATS]) { + const struct nlattr *nla; + size_t left; + NL_NESTED_FOR_EACH (nla, left, a[OVS_VPORT_ATTR_UPCALL_STATS]) { + if (nl_attr_type(nla) == OVS_VPORT_UPCALL_SUCCESS) { + vport->upcall_stats.upcall_success = nl_attr_get_u64(nla); + } else if (nl_attr_type(nla) == OVS_VPORT_UPCALL_FAIL) { + vport->upcall_stats.upcall_fail = nl_attr_get_u64(nla); + } + } + } if (a[OVS_VPORT_ATTR_OPTIONS]) { vport->options = nl_attr_get(a[OVS_VPORT_ATTR_OPTIONS]); vport->options_len = nl_attr_get_size(a[OVS_VPORT_ATTR_OPTIONS]); diff --git a/lib/dpif-netlink.h b/lib/dpif-netlink.h index 24294bc42..7826e34f5 100644 --- a/lib/dpif-netlink.h +++ b/lib/dpif-netlink.h @@ -44,6 +44,7 @@ struct dpif_netlink_vport { uint32_t n_upcall_pids; const uint32_t *upcall_pids; /* OVS_VPORT_ATTR_UPCALL_PID. */ const struct ovs_vport_stats *stats; /* OVS_VPORT_ATTR_STATS. */ + struct ovs_vport_upcall_stats upcall_stats; /* OVS_VPORT_ATTR_UPCALL_STATS. */ const struct nlattr *options; /* OVS_VPORT_ATTR_OPTIONS. */ size_t options_len; }; diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 59e8dc0ae..d5a953244 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -2181,6 +2181,13 @@ netdev_stats_from_ovs_vport_stats(struct netdev_stats *dst, dst->tx_window_errors = 0; } +static void netdev_stats_from_ovs_vport_upcall_stats(struct netdev_stats *dst, + struct dpif_netlink_vport *vport) +{ + dst->tx_upcall_success = vport->upcall_stats.upcall_success; + dst->tx_upcall_fail = vport->upcall_stats.upcall_fail; +} + static int get_stats_via_vport__(const struct netdev *netdev, struct netdev_stats *stats) { @@ -2197,6 +2204,7 @@ get_stats_via_vport__(const struct netdev *netdev, struct netdev_stats *stats) } netdev_stats_from_ovs_vport_stats(stats, reply.stats); + netdev_stats_from_ovs_vport_upcall_stats(stats, &reply); ofpbuf_delete(buf); -- 2.27.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev