[ovs-dev] [PATCH 5/7] ofproto-dpif-upcall: Encapsulate 'struct recirc_refs' into struct 'ukey_refs'.
Daniele Di Proietto
diproiettod at vmware.com
Sat Feb 25 02:57:59 UTC 2017
We're going to need to introduce another member in struct udpif_key very
similar to 'struct recirc_refs', so this will make next commit easier.
No functional change.
Signed-off-by: Daniele Di Proietto <diproiettod at vmware.com>
---
ofproto/ofproto-dpif-upcall.c | 43 +++++++++++++++++++++++++------------------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/ofproto/ofproto-dpif-upcall.c b/ofproto/ofproto-dpif-upcall.c
index 660383fae..35b5b7533 100644
--- a/ofproto/ofproto-dpif-upcall.c
+++ b/ofproto/ofproto-dpif-upcall.c
@@ -249,6 +249,13 @@ enum ukey_state {
};
#define N_UKEY_STATES (UKEY_DELETED + 1)
+/* Each udpif_key can hold reference to global objects in an ofproto. These
+ * references are stored here. */
+struct ukey_refs {
+ struct recirc_refs recircs; /* Action recirc IDs with references held. */
+};
+#define UKEY_REFS_INIT {RECIRC_REFS_EMPTY_INITIALIZER}
+
/* 'udpif_key's are responsible for tracking the little bit of state udpif
* needs to do flow expiration which can't be pulled directly from the
* datapath. They may be created by any handler or revalidator thread at any
@@ -294,7 +301,7 @@ struct udpif_key {
} keybuf, maskbuf;
uint32_t key_recirc_id; /* Non-zero if reference is held by the ukey. */
- struct recirc_refs recircs; /* Action recirc IDs with references held. */
+ struct ukey_refs global_refs;
};
/* Datapath operation with optional ukey attached. */
@@ -1487,10 +1494,10 @@ ukey_create__(const struct nlattr *key, size_t key_len,
ukey->xcache = NULL;
ukey->key_recirc_id = key_recirc_id;
- recirc_refs_init(&ukey->recircs);
+ recirc_refs_init(&ukey->global_refs.recircs);
if (xout) {
/* Take ownership of the action recirc id references. */
- recirc_refs_swap(&ukey->recircs, &xout->recircs);
+ recirc_refs_swap(&ukey->global_refs.recircs, &xout->recircs);
}
return ukey;
@@ -1781,7 +1788,7 @@ ukey_delete__(struct udpif_key *ukey)
if (ukey->key_recirc_id) {
recirc_free_id(ukey->key_recirc_id);
}
- recirc_refs_unref(&ukey->recircs);
+ recirc_refs_unref(&ukey->global_refs.recircs);
xlate_cache_delete(ukey->xcache);
ofpbuf_delete(ovsrcu_get(struct ofpbuf *, &ukey->actions));
ovs_mutex_destroy(&ukey->mutex);
@@ -1926,7 +1933,7 @@ populate_xcache(struct udpif *udpif, struct udpif_key *ukey,
static enum reval_result
revalidate_ukey__(struct udpif *udpif, const struct udpif_key *ukey,
uint16_t tcp_flags, struct ofpbuf *odp_actions,
- struct recirc_refs *recircs, struct xlate_cache *xcache)
+ struct ukey_refs *global_refs, struct xlate_cache *xcache)
{
struct xlate_out *xoutp;
struct netflow *netflow;
@@ -1974,7 +1981,7 @@ revalidate_ukey__(struct udpif *udpif, const struct udpif_key *ukey,
* Let's modify it in place. */
result = UKEY_MODIFY;
/* Transfer recirc action ID references to the caller. */
- recirc_refs_swap(recircs, &xoutp->recircs);
+ recirc_refs_swap(&global_refs->recircs, &xoutp->recircs);
goto exit;
}
@@ -2010,7 +2017,7 @@ static enum reval_result
revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey,
const struct dpif_flow_stats *stats,
struct ofpbuf *odp_actions, uint64_t reval_seq,
- struct recirc_refs *recircs)
+ struct ukey_refs *global_refs)
OVS_REQUIRES(ukey->mutex)
{
bool need_revalidate = ukey->reval_seq != reval_seq;
@@ -2036,7 +2043,7 @@ revalidate_ukey(struct udpif *udpif, struct udpif_key *ukey,
xlate_cache_clear(ukey->xcache);
}
result = revalidate_ukey__(udpif, ukey, push.tcp_flags,
- odp_actions, recircs, ukey->xcache);
+ odp_actions, global_refs, ukey->xcache);
} /* else delete; too expensive to revalidate */
} else if (!push.n_packets || ukey->xcache
|| !populate_xcache(udpif, ukey, push.tcp_flags)) {
@@ -2212,7 +2219,7 @@ log_unexpected_flow(const struct dpif_flow *flow, int error)
static void
reval_op_init(struct ukey_op *op, enum reval_result result,
struct udpif *udpif, struct udpif_key *ukey,
- struct recirc_refs *recircs, struct ofpbuf *odp_actions)
+ struct ukey_refs *global_refs, struct ofpbuf *odp_actions)
OVS_REQUIRES(ukey->mutex)
{
if (result == UKEY_DELETE) {
@@ -2220,9 +2227,9 @@ reval_op_init(struct ukey_op *op, enum reval_result result,
transition_ukey(ukey, UKEY_EVICTING);
} else if (result == UKEY_MODIFY) {
/* Store the new recircs. */
- recirc_refs_swap(&ukey->recircs, recircs);
+ recirc_refs_swap(&ukey->global_refs.recircs, &global_refs->recircs);
/* Release old recircs. */
- recirc_refs_unref(recircs);
+ recirc_refs_unref(&global_refs->recircs);
/* ukey->key_recirc_id remains, as the key is the same as before. */
ukey_set_actions(ukey, odp_actions);
@@ -2283,7 +2290,7 @@ revalidate(struct revalidator *revalidator)
for (f = flows; f < &flows[n_dumped]; f++) {
long long int used = f->stats.used;
- struct recirc_refs recircs = RECIRC_REFS_EMPTY_INITIALIZER;
+ struct ukey_refs global_refs = UKEY_REFS_INIT;
enum reval_result result;
struct udpif_key *ukey;
bool already_dumped;
@@ -2326,13 +2333,13 @@ revalidate(struct revalidator *revalidator)
result = UKEY_DELETE;
} else {
result = revalidate_ukey(udpif, ukey, &f->stats, &odp_actions,
- reval_seq, &recircs);
+ reval_seq, &global_refs);
}
ukey->dump_seq = dump_seq;
if (result != UKEY_KEEP) {
/* Takes ownership of 'recircs'. */
- reval_op_init(&ops[n_ops++], result, udpif, ukey, &recircs,
+ reval_op_init(&ops[n_ops++], result, udpif, ukey, &global_refs,
&odp_actions);
}
ovs_mutex_unlock(&ukey->mutex);
@@ -2392,7 +2399,7 @@ revalidator_sweep__(struct revalidator *revalidator, bool purge)
ukey_state = ukey->state;
if (ukey_state == UKEY_OPERATIONAL
|| (ukey_state == UKEY_VISIBLE && purge)) {
- struct recirc_refs recircs = RECIRC_REFS_EMPTY_INITIALIZER;
+ struct ukey_refs global_refs = UKEY_REFS_INIT;
bool seq_mismatch = (ukey->dump_seq != dump_seq
&& ukey->reval_seq != reval_seq);
enum reval_result result;
@@ -2406,12 +2413,12 @@ revalidator_sweep__(struct revalidator *revalidator, bool purge)
COVERAGE_INC(revalidate_missed_dp_flow);
memset(&stats, 0, sizeof stats);
result = revalidate_ukey(udpif, ukey, &stats, &odp_actions,
- reval_seq, &recircs);
+ reval_seq, &global_refs);
}
if (result != UKEY_KEEP) {
/* Clears 'recircs' if filled by revalidate_ukey(). */
- reval_op_init(&ops[n_ops++], result, udpif, ukey, &recircs,
- &odp_actions);
+ reval_op_init(&ops[n_ops++], result, udpif, ukey,
+ &global_refs, &odp_actions);
}
}
ovs_mutex_unlock(&ukey->mutex);
--
2.11.0
More information about the dev
mailing list