[ovs-dev] [PATCH 3/3] lacp: Implement custom timing mode.
Ethan Jackson
ethan at nicira.com
Tue Apr 19 19:57:18 UTC 2011
Here is another incremental (to be applied to the previous incremental).
---
lib/lacp.c | 35 +++++++++++++++++++++++++----------
1 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/lib/lacp.c b/lib/lacp.c
index 4f950ad..7d109f8 100644
--- a/lib/lacp.c
+++ b/lib/lacp.c
@@ -49,7 +49,7 @@ struct lacp {
struct slave *key_slave; /* Slave whose ID will be the aggregation key. */
enum lacp_time lacp_time; /* Fast, Slow or Custom LACP time. */
- long long int custom_time; /* LACP_CUSTOM_TIME transmission rate. */
+ long long int custom_time; /* LACP_TIME_CUSTOM transmission rate. */
bool strict; /* True if in strict mode. */
bool negotiated; /* True if LACP negotiations were successful. */
bool update; /* True if lacp_update() needs to be called. */
@@ -84,6 +84,8 @@ static void slave_get_priority(struct slave *, struct lacp_info *priority);
static bool slave_may_tx(const struct slave *);
static struct slave *slave_lookup(const struct lacp *, const void *slave);
static bool info_tx_equal(struct lacp_info *, struct lacp_info *);
+static long long int tx_duration(const struct lacp *, bool fast);
+static long long int rx_duration(const struct lacp *, bool fast);
static void lacp_unixctl_show(struct unixctl_conn *, const char *args,
void *aux);
@@ -225,7 +227,8 @@ lacp_process_pdu(struct lacp *lacp, const void *slave_,
}
slave->status = LACP_CURRENT;
- timer_set_duration(&slave->rx, LACP_RX_MULTIPLIER * tx_rate);
+ timer_set_duration(&slave->rx,
+ rx_duration(lacp, lacp->lacp_time == LACP_TIME_FAST));
slave->ntt_actor = pdu->partner;
@@ -384,14 +387,8 @@ lacp_run(struct lacp *lacp, lacp_send_pdu *send_pdu)
compose_lacp_pdu(&actor, &slave->partner, &pdu);
send_pdu(slave->aux, &pdu);
- if (lacp->lacp_time == LACP_TIME_CUSTOM) {
- duration = lacp->custom_time;
- } else {
- duration = (slave->partner.state & LACP_STATE_TIME
- ? LACP_FAST_TIME_TX
- : LACP_SLOW_TIME_TX);
- }
-
+ duration = tx_duration(lacp,
+ slave->partner.state & LACP_STATE_TIME);
timer_set_duration(&slave->tx, duration);
}
}
@@ -634,6 +631,24 @@ info_tx_equal(struct lacp_info *a, struct lacp_info *b)
&& a->sys_priority == b->sys_priority
&& eth_addr_equals(a->sys_id, b->sys_id);
}
+
+
+static long long int
+tx_duration(const struct lacp *lacp, bool fast)
+{
+ if (lacp->lacp_time == LACP_TIME_CUSTOM) {
+ return lacp->custom_time;
+ } else {
+ return fast ? LACP_FAST_TIME_TX : LACP_SLOW_TIME_TX;
+ }
+}
+
+static long long int
+rx_duration(const struct lacp *lacp, bool fast)
+{
+ return tx_duration(lacp, fast) * LACP_RX_MULTIPLIER;
+}
+
static struct lacp *
lacp_find(const char *name)
--
1.7.4.2
More information about the dev
mailing list