From patchwork Thu Mar 9 22:50:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 737161 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 3vfQbJ01k6z9s7c for ; Fri, 10 Mar 2017 09:50:36 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C4410B80; Thu, 9 Mar 2017 22:50:30 +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 C6426B7F for ; Thu, 9 Mar 2017 22:50:29 +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 54F2816B for ; Thu, 9 Mar 2017 22:50:29 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id 25so8181424pgy.3 for ; Thu, 09 Mar 2017 14:50:29 -0800 (PST) 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=lYyUoonZ4spE/ExzcoRM+ingkFiIGcJrpyeVboaaHfc=; b=Od3k4wrRsy2XPWVLXPvOeEu2syOKVnnHnD9x+XK76M1kkJgVadBAz/FJ7kHu9Vs32P vOiIzC4wWatooTuJtD+UHMqIXaH3QoQ8PzDW62R9nLrCrPcuRC3Y+c86Lq/CZzT6IpXR zSustXOvAowq3qUwh+ctdUtJjLZ0coXZhBPT3HbMF/I2slvBYHsYD5ExFW7dDp7zrEFW KSloVmM6NyZw3fHlm/vqEtfjFD4SUbTy3hkVbNNtl3aP6rlatIcziG0rLEeJIQnVpvTw Snoc9poXvV8jySTSd7Rv/gxPJLxYF80XRlBBNSEU8/l8IRfg+r2BYegUKXHMW/wOqEkF DSYA== X-Gm-Message-State: AMke39mcacBhORSq7WPN1MVKJ8oPBpP2GuGOuZt0rFLSiBsx3yozb2/IolYNra+LJg07Zg== X-Received: by 10.99.97.16 with SMTP id v16mr16390548pgb.175.1489099828944; Thu, 09 Mar 2017 14:50:28 -0800 (PST) Received: from ubuntu.localdomain ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id d63sm14343059pfg.132.2017.03.09.14.50.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 09 Mar 2017 14:50:28 -0800 (PST) From: Andy Zhou To: dev@openvswitch.org Date: Thu, 9 Mar 2017 14:50:08 -0800 Message-Id: <1489099810-68023-1-git-send-email-azhou@ovn.org> X-Mailer: git-send-email 1.9.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 1/3] dpif: Refactor dpif_probe_feature() 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 Allow actions to be part of the probe. No functional changes. Future patch will make use this new API. Signed-off-by: Andy Zhou Acked-by: Joe Stringer --- lib/dpif.c | 8 ++++++-- lib/dpif.h | 3 ++- ofproto/ofproto-dpif.c | 8 ++++---- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/lib/dpif.c b/lib/dpif.c index 5c17f18..dad0fcd 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -897,19 +897,23 @@ dpif_flow_flush(struct dpif *dpif) */ bool dpif_probe_feature(struct dpif *dpif, const char *name, - const struct ofpbuf *key, const ovs_u128 *ufid) + const struct ofpbuf *key, const struct ofpbuf *actions, + const ovs_u128 *ufid) { struct dpif_flow flow; struct ofpbuf reply; uint64_t stub[DPIF_FLOW_BUFSIZE / 8]; bool enable_feature = false; int error; + const struct nlattr *nl_actions = actions ? actions->data : NULL; + const size_t nl_actions_size = actions ? actions->size : 0; /* Use DPIF_FP_MODIFY to cover the case where ovs-vswitchd is killed (and * restarted) at just the right time such that feature probes from the * previous run are still present in the datapath. */ error = dpif_flow_put(dpif, DPIF_FP_CREATE | DPIF_FP_MODIFY | DPIF_FP_PROBE, - key->data, key->size, NULL, 0, NULL, 0, + key->data, key->size, NULL, 0, + nl_actions, nl_actions_size, ufid, NON_PMD_CORE_ID, NULL); if (error) { if (error != EINVAL) { diff --git a/lib/dpif.h b/lib/dpif.h index f81d9fe..5d49b11 100644 --- a/lib/dpif.h +++ b/lib/dpif.h @@ -519,7 +519,8 @@ enum dpif_flow_put_flags { }; bool dpif_probe_feature(struct dpif *, const char *name, - const struct ofpbuf *key, const ovs_u128 *ufid); + const struct ofpbuf *key, const struct ofpbuf *actions, + const ovs_u128 *ufid); void dpif_flow_hash(const struct dpif *, const void *key, size_t key_len, ovs_u128 *hash); int dpif_flow_flush(struct dpif *); diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index 4ef7166..5289693 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -822,7 +822,7 @@ check_recirc(struct dpif_backer *backer) ofpbuf_use_stack(&key, &keybuf, sizeof keybuf); odp_flow_key_from_flow(&odp_parms, &key); enable_recirc = dpif_probe_feature(backer->dpif, "recirculation", &key, - NULL); + NULL, NULL); if (enable_recirc) { VLOG_INFO("%s: Datapath supports recirculation", @@ -859,7 +859,7 @@ check_ufid(struct dpif_backer *backer) odp_flow_key_from_flow(&odp_parms, &key); dpif_flow_hash(backer->dpif, key.data, key.size, &ufid); - enable_ufid = dpif_probe_feature(backer->dpif, "UFID", &key, &ufid); + enable_ufid = dpif_probe_feature(backer->dpif, "UFID", &key, NULL, &ufid); if (enable_ufid) { VLOG_INFO("%s: Datapath supports unique flow ids", @@ -973,7 +973,7 @@ check_max_mpls_depth(struct dpif_backer *backer) ofpbuf_use_stack(&key, &keybuf, sizeof keybuf); odp_flow_key_from_flow(&odp_parms, &key); - if (!dpif_probe_feature(backer->dpif, "MPLS", &key, NULL)) { + if (!dpif_probe_feature(backer->dpif, "MPLS", &key, NULL, NULL)) { break; } } @@ -1166,7 +1166,7 @@ check_##NAME(struct dpif_backer *backer) \ \ ofpbuf_use_stack(&key, &keybuf, sizeof keybuf); \ odp_flow_key_from_flow(&odp_parms, &key); \ - enable = dpif_probe_feature(backer->dpif, #NAME, &key, NULL); \ + enable = dpif_probe_feature(backer->dpif, #NAME, &key, NULL, NULL); \ \ if (enable) { \ VLOG_INFO("%s: Datapath supports "#NAME, dpif_name(backer->dpif)); \