From patchwork Sat Feb 25 02:08:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 732322 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 3vVWbX3VFgz9s2P for ; Sat, 25 Feb 2017 13:08:23 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 5E54D8D7; Sat, 25 Feb 2017 02:08:20 +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 B1934412 for ; Sat, 25 Feb 2017 02:08:19 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 41F0812A for ; Sat, 25 Feb 2017 02:08:19 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id s67so5055606pgb.1 for ; Fri, 24 Feb 2017 18:08:19 -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 :content-transfer-encoding; bh=vE18qMpFY85JM+RwttC3fmfuWlbqFcChMTfCGlLB52A=; b=ezgT7gkTmr22FU4EPXEgqqV0Pv74oLbx54nuYfQJdtXw0TJuqzCW5gi9GY+upwoR6c hNib/AkGg/lHWoNJ3gOcli3qyFYs/wYN+JVJoiRi7i1OqzjJ1Fs2Z9b2HJg6HkOLMqsW r70QJOjSNJXpSG688CcTjFbMAq8UbdOTQFI7SluLDydlDHEUa6+V2I07bgC8UUW8WAjY 4yNHTxo+ygsWWPsQ0acKdlkJYXzlTwLNnXC9EMBvf/TDu3DC3AeXSE9YhFOZXX1yhoA2 E5mRHyYEAryG2Q4BAaasLFaox51dWpUqi9e1I3zbOHwy1EdXCzFrNwSFSU1gGw5BNVuw CZpw== X-Gm-Message-State: AMke39kAh92F+EO0qPdcP54iQ9pwE4H6bZIU1MdWG6rAEjbiKrOSiAMW8tb3zB96XWNhPw== X-Received: by 10.99.8.4 with SMTP id 4mr7327496pgi.204.1487988498886; Fri, 24 Feb 2017 18:08:18 -0800 (PST) Received: from ubuntu.localdomain ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id y187sm17162332pfy.123.2017.02.24.18.08.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 24 Feb 2017 18:08:18 -0800 (PST) From: Andy Zhou To: dev@openvswitch.org Date: Fri, 24 Feb 2017 18:08:05 -0800 Message-Id: <1487988485-76248-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] ofproto/bond: Simplify bond_may_recirc() 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 The extra information passed back is no longer used outside bond.c. Make the API simpler. Signed-off-by: Andy Zhou Acked-by: Ben Pfaff --- ofproto/bond.c | 25 ++++++++++--------------- ofproto/bond.h | 3 +-- ofproto/ofproto-dpif-xlate.c | 2 +- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/ofproto/bond.c b/ofproto/bond.c index 5bb124bda5ad..ef65a2a3c1b4 100644 --- a/ofproto/bond.c +++ b/ofproto/bond.c @@ -927,19 +927,9 @@ bond_recirculation_account(struct bond *bond) } bool -bond_may_recirc(const struct bond *bond, uint32_t *recirc_id, - uint32_t *hash_bias) +bond_may_recirc(const struct bond *bond) { - bool may_recirc = bond->balance == BM_TCP && bond->recirc_id; - - if (recirc_id) { - *recirc_id = may_recirc ? bond->recirc_id : 0; - } - if (hash_bias) { - *hash_bias = may_recirc ? bond->basis : 0; - } - - return may_recirc; + return bond->balance == BM_TCP && bond->recirc_id; } static void @@ -971,8 +961,12 @@ bond_update_post_recirc_rules(struct bond *bond, uint32_t *recirc_id, uint32_t *hash_basis) { ovs_rwlock_wrlock(&rwlock); - if (bond_may_recirc(bond, recirc_id, hash_basis)) { + if (bond_may_recirc(bond)) { + *recirc_id = bond->recirc_id; + *hash_basis = bond->basis; bond_update_post_recirc_rules__(bond, false); + } else { + *recirc_id = *hash_basis = 0; } ovs_rwlock_unlock(&rwlock); } @@ -1159,7 +1153,7 @@ bond_rebalance(struct bond *bond) bond->next_rebalance = time_msec() + bond->rebalance_interval; use_recirc = bond->ofproto->backer->support.odp.recirc && - bond_may_recirc(bond, NULL, NULL); + bond_may_recirc(bond); if (use_recirc) { bond_recirculation_account(bond); @@ -1319,7 +1313,8 @@ bond_print_details(struct ds *ds, const struct bond *bond) ds_put_format(ds, "bond_mode: %s\n", bond_mode_to_string(bond->balance)); - may_recirc = bond_may_recirc(bond, &recirc_id, NULL); + may_recirc = bond_may_recirc(bond); + recirc_id = bond->recirc_id; ds_put_format(ds, "bond may use recirculation: %s, Recirc-ID : %d\n", may_recirc ? "yes" : "no", may_recirc ? recirc_id: -1); diff --git a/ofproto/bond.h b/ofproto/bond.h index 6e1221d2381b..d3a2256402da 100644 --- a/ofproto/bond.h +++ b/ofproto/bond.h @@ -122,6 +122,5 @@ void bond_rebalance(struct bond *); */ void bond_update_post_recirc_rules(struct bond *, uint32_t *recirc_id, uint32_t *hash_basis); -bool bond_may_recirc(const struct bond *, uint32_t *recirc_id, - uint32_t *hash_bias); +bool bond_may_recirc(const struct bond *); #endif /* bond.h */ diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c index 89fc3a44a0d1..8c16d028233b 100644 --- a/ofproto/ofproto-dpif-xlate.c +++ b/ofproto/ofproto-dpif-xlate.c @@ -1988,7 +1988,7 @@ output_normal(struct xlate_ctx *ctx, const struct xbundle *out_xbundle, struct ofport_dpif *ofport; if (ctx->xbridge->support.odp.recirc - && bond_may_recirc(out_xbundle->bond, NULL, NULL)) { + && bond_may_recirc(out_xbundle->bond)) { /* To avoid unnecessary locking, bond_may_recirc() is first * called outside of the 'rwlock'. After acquiring the lock, * bond_update_post_recirc_rules() will check again to make