From patchwork Mon Mar 13 21:21:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 738434 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vhrRN48HWz9s0m for ; Tue, 14 Mar 2017 08:22:08 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 10C1EB93; Mon, 13 Mar 2017 21:22:05 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id C9D1EB5D for ; Mon, 13 Mar 2017 21:22:03 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id BA9B02CE for ; Mon, 13 Mar 2017 21:22:02 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id b5so19715575pgg.1 for ; Mon, 13 Mar 2017 14:22:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=rE7ymdgiAa9ZO9Vu1Q17D/UOwgBS+2eeg2lTywEdHQM=; b=DNYLOiOyYeVRY1eA1WYiiQm5HUZaSx6mtmv+tyGKNBm0BJEA3H8hLibvpu4pmIKa8l yVUVL7d6Z+j/JIyxHse1MDZzpsMHAsQyiaLMK3hCfxKQp8ZOKSyPWyhrp8MkhfntmenV dGmXFlai8N1o4e44QSedqx1nx2USl9+hpnCbkTFvMsnHTvdY9s3/wb985Hx+sa5nou5T Y8LXoICgUHnqFkjP0KTIEessy9O8V4Jsk+DPmWIYk9TDdmcqJuL2YgQy8PupIYlLd/05 n9912cDVxr2u3d5Sm43aa2Vyuw1l0ukgO+4lX0fwNP14awk9l7oMT7mIi8GTaLIPYRZ7 OFnQ== X-Gm-Message-State: AMke39l+7wJT43cRyxe0c0j5WlMqRd4xwc6MOGEj/+gwTzma2rRE/jrVHzuhAGQlVXCfmQ== X-Received: by 10.84.233.197 with SMTP id m5mr51320072pln.169.1489440122303; Mon, 13 Mar 2017 14:22:02 -0700 (PDT) Received: from centos.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id m29sm34385307pfi.54.2017.03.13.14.22.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 13 Mar 2017 14:22:01 -0700 (PDT) From: Andy Zhou To: dev@openvswitch.org Date: Mon, 13 Mar 2017 14:21:32 -0700 Message-Id: <1489440092-13945-1-git-send-email-azhou@ovn.org> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH] ofproto: Add appctl command to show Datapath features X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org Exporting Datapath runtime detected features can be useful for both debugging and for writing system unit testing easier. Signed-off-by: Andy Zhou Acked-by: Joe Stringer --- ofproto/ofproto-dpif.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index df779c2..af70ab3 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -4891,6 +4891,38 @@ ofproto_unixctl_dpif_dump_dps(struct unixctl_conn *conn, int argc OVS_UNUSED, } static void +show_dp_feature_b(struct ds *ds, const char *feature, bool b) +{ + ds_put_format(ds, "%s: %s\n", feature, b ? "Yes" : "No"); +} + +static void +show_dp_feature_s(struct ds *ds, const char *feature, size_t s) +{ + ds_put_format(ds, "%s: %"PRIuSIZE"\n", feature, s); +} + +static void +dpif_show_support(const struct dpif_backer_support *support, struct ds *ds) +{ + show_dp_feature_b(ds, "Variable length userdata", + support->variable_length_userdata); + show_dp_feature_b(ds, "Masked set action", support->masked_set_action); + show_dp_feature_b(ds, "Tunnel push pop", support->tnl_push_pop); + show_dp_feature_b(ds, "Ufid", support->ufid); + show_dp_feature_b(ds, "Trunc action", support->trunc); + show_dp_feature_b(ds, "Clone action", support->clone); + show_dp_feature_s(ds, "Max MPLS depth", support->odp.max_mpls_depth); + show_dp_feature_b(ds, "Recirc", support->odp.recirc); + show_dp_feature_b(ds, "CT state", support->odp.ct_state); + show_dp_feature_b(ds, "CT zone", support->odp.ct_zone); + show_dp_feature_b(ds, "CT mark", support->odp.ct_mark); + show_dp_feature_b(ds, "CT label", support->odp.ct_label); + show_dp_feature_b(ds, "CT State NAT", support->odp.ct_state_nat); + show_dp_feature_s(ds, "Max sample nesting",support->sample_nesting); +} + +static void dpif_show_backer(const struct dpif_backer *backer, struct ds *ds) { const struct shash_node **ofprotos; @@ -4899,7 +4931,6 @@ dpif_show_backer(const struct dpif_backer *backer, struct ds *ds) size_t i; dpif_get_dp_stats(backer->dpif, &dp_stats); - ds_put_format(ds, "%s: hit:%"PRIu64" missed:%"PRIu64"\n", dpif_name(backer->dpif), dp_stats.n_hit, dp_stats.n_missed); @@ -5119,6 +5150,24 @@ disable_datapath_clone(struct unixctl_conn *conn OVS_UNUSED, } static void +ofproto_unixctl_dpif_show_dp_features(struct unixctl_conn *conn, + int argc, const char *argv[], + void *aux OVS_UNUSED) +{ + struct ds ds = DS_EMPTY_INITIALIZER; + const char *br = argv[argc -1]; + struct ofproto_dpif *ofproto = ofproto_dpif_lookup(br); + + if (!ofproto) { + unixctl_command_reply_error(conn, "no such bridge"); + return; + } + + dpif_show_support(&ofproto->backer->support, &ds); + unixctl_command_reply(conn, ds_cstr(&ds)); +} + +static void ofproto_unixctl_init(void) { static bool registered; @@ -5139,6 +5188,8 @@ ofproto_unixctl_init(void) ofproto_unixctl_dpif_dump_dps, NULL); unixctl_command_register("dpif/show", "", 0, 0, ofproto_unixctl_dpif_show, NULL); + unixctl_command_register("dpif/show-dp-features", "bridge", 1, 1, + ofproto_unixctl_dpif_show_dp_features, NULL); unixctl_command_register("dpif/dump-flows", "[-m] bridge", 1, 2, ofproto_unixctl_dpif_dump_flows, NULL);