diff mbox

[ovs-dev] ofproto/bond: Simplify bond_may_recirc()

Message ID 1487988485-76248-1-git-send-email-azhou@ovn.org
State Accepted
Headers show

Commit Message

Andy Zhou Feb. 25, 2017, 2:08 a.m. UTC
The extra information passed back is no longer used outside bond.c.
Make the API simpler.

Signed-off-by: Andy Zhou <azhou@ovn.org>
---
 ofproto/bond.c               | 25 ++++++++++---------------
 ofproto/bond.h               |  3 +--
 ofproto/ofproto-dpif-xlate.c |  2 +-
 3 files changed, 12 insertions(+), 18 deletions(-)

Comments

Ben Pfaff March 8, 2017, 9:39 p.m. UTC | #1
On Fri, Feb 24, 2017 at 06:08:05PM -0800, Andy Zhou wrote:
> The extra information passed back is no longer used outside bond.c.
> Make the API simpler.
> 
> Signed-off-by: Andy Zhou <azhou@ovn.org>

Acked-by: Ben Pfaff <blp@ovn.org>
Andy Zhou March 8, 2017, 9:52 p.m. UTC | #2
On Wed, Mar 8, 2017 at 1:39 PM, Ben Pfaff <blp@ovn.org> wrote:
> On Fri, Feb 24, 2017 at 06:08:05PM -0800, Andy Zhou wrote:
>> The extra information passed back is no longer used outside bond.c.
>> Make the API simpler.
>>
>> Signed-off-by: Andy Zhou <azhou@ovn.org>
>
> Acked-by: Ben Pfaff <blp@ovn.org>

Thanks. Pushed.
diff mbox

Patch

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