Add odp_put_recirc_action() helper and use it in compose_output_action__().

This is in preparation for using the same helper as part of support
for using recirculation in conjunction series of actions including
with MPLS actions that are currently not able to be translated.

Signed-off-by: Simon Horman <[email protected]>

---
v2
* Rebase
---
 lib/odp-util.c               | 13 +++++++++++++
 lib/odp-util.h               |  2 ++
 ofproto/bond.c               |  2 +-
 ofproto/ofproto-dpif-xlate.c |  8 ++------
 ofproto/ofproto-dpif.c       | 10 ++++++----
 ofproto/ofproto-dpif.h       |  1 +
 6 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/lib/odp-util.c b/lib/odp-util.c
index cc73413..9b89eb9 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -3479,6 +3479,19 @@ odp_put_tunnel_action(const struct flow_tnl *tunnel,
     tun_key_to_attr(odp_actions, tunnel);
     nl_msg_end_nested(odp_actions, offset);
 }
+
+void
+odp_put_recirc_action(uint32_t recirc_id, uint8_t  hash_alg,
+                      uint32_t hash_bias, struct ofpbuf *odp_actions)
+{
+    struct ovs_action_recirc *act_recirc;
+
+    act_recirc = nl_msg_put_unspec_uninit(odp_actions, OVS_ACTION_ATTR_RECIRC,
+                                          sizeof *act_recirc);
+    act_recirc->hash_alg = hash_alg;
+    act_recirc->hash_bias = hash_bias;
+    act_recirc->recirc_id = recirc_id;
+}
 
 /* The commit_odp_actions() function and its helpers. */
 
diff --git a/lib/odp-util.h b/lib/odp-util.h
index 7bc64c7..ed6b5b6 100644
--- a/lib/odp-util.h
+++ b/lib/odp-util.h
@@ -235,6 +235,8 @@ size_t odp_put_userspace_action(uint32_t pid,
                                 struct ofpbuf *odp_actions);
 void odp_put_tunnel_action(const struct flow_tnl *tunnel,
                            struct ofpbuf *odp_actions);
+void odp_put_recirc_action(uint32_t recirc_id, uint8_t  hash_alg,
+                           uint32_t hash_bias, struct ofpbuf *odp_actions);
 void odp_put_pkt_mark_action(const uint32_t pkt_mark,
                              struct ofpbuf *odp_actions);
 
diff --git a/ofproto/bond.c b/ofproto/bond.c
index 4d5e359..6f2e1ce 100644
--- a/ofproto/bond.c
+++ b/ofproto/bond.c
@@ -357,7 +357,7 @@ update_recirc_rules(struct bond *bond)
             ofpact_put_OUTPUT(&ofpacts)->port = pr_op->out_ofport;
             error = ofproto_dpif_add_internal_flow(bond->ofproto,
                                                    &pr_op->match,
-                                                   RECIRC_RULE_PRIORITY,
+                                                   RECIRC_RULE_PRIORITY, 0,
                                                    &ofpacts, &rule);
             if (error) {
                 char *err_s = match_to_string(&pr_op->match,
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index 6c9dbf2..b0e0260 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -1843,14 +1843,10 @@ compose_output_action__(struct xlate_ctx *ctx, 
ofp_port_t ofp_port,
                                               &ctx->xout->wc);
 
         if (ctx->xout->use_recirc) {
-            struct ovs_action_recirc *act_recirc;
             struct xlate_recirc *xr = &ctx->xout->recirc;
 
-            act_recirc = nl_msg_put_unspec_uninit(&ctx->xout->odp_actions,
-                               OVS_ACTION_ATTR_RECIRC, sizeof *act_recirc);
-            act_recirc->recirc_id = xr->recirc_id;
-            act_recirc->hash_alg = xr->hash_alg;
-            act_recirc->hash_bias = xr->hash_bias;
+            odp_put_recirc_action(xr->recirc_id, xr->hash_alg, xr->hash_bias,
+                                  &ctx->xout->odp_actions);
         } else {
             nl_msg_put_odp_port(&ctx->xout->odp_actions, 
OVS_ACTION_ATTR_OUTPUT,
                                 out_port);
diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c
index 8546504..82027c2 100644
--- a/ofproto/ofproto-dpif.c
+++ b/ofproto/ofproto-dpif.c
@@ -1185,7 +1185,8 @@ add_internal_miss_flow(struct ofproto_dpif *ofproto, int 
id,
     match_init_catchall(&match);
     match_set_reg(&match, 0, id);
 
-    error = ofproto_dpif_add_internal_flow(ofproto, &match, 0, ofpacts, &rule);
+    error = ofproto_dpif_add_internal_flow(ofproto, &match, 0, 0, ofpacts,
+                                           &rule);
     *rulep = error ? NULL : rule_dpif_cast(rule);
 
     return error;
@@ -1243,7 +1244,7 @@ add_internal_flows(struct ofproto_dpif *ofproto)
     match_init_catchall(&match);
     match_set_recirc_id(&match, 0);
 
-    error = ofproto_dpif_add_internal_flow(ofproto, &match, 2,  &ofpacts,
+    error = ofproto_dpif_add_internal_flow(ofproto, &match, 2, 0, &ofpacts,
                                            &unused_rulep);
     if (error) {
         return error;
@@ -1256,7 +1257,7 @@ add_internal_flows(struct ofproto_dpif *ofproto)
      */
     ofpbuf_clear(&ofpacts);
     match_init_catchall(&match);
-    error = ofproto_dpif_add_internal_flow(ofproto, &match, 1,  &ofpacts,
+    error = ofproto_dpif_add_internal_flow(ofproto, &match, 1, 0, &ofpacts,
                                            &unused_rulep);
 
     return error;
@@ -4771,6 +4772,7 @@ ofproto_dpif_free_recirc_id(struct ofproto_dpif *ofproto, 
uint32_t recirc_id)
 int
 ofproto_dpif_add_internal_flow(struct ofproto_dpif *ofproto,
                                struct match *match, int priority,
+                               uint16_t idle_timeout,
                                const struct ofpbuf *ofpacts,
                                struct rule **rulep)
 {
@@ -4786,7 +4788,7 @@ ofproto_dpif_add_internal_flow(struct ofproto_dpif 
*ofproto,
     fm.modify_cookie = false;
     fm.table_id = TBL_INTERNAL;
     fm.command = OFPFC_ADD;
-    fm.idle_timeout = 0;
+    fm.idle_timeout = idle_timeout;
     fm.hard_timeout = 0;
     fm.buffer_id = 0;
     fm.out_port = 0;
diff --git a/ofproto/ofproto-dpif.h b/ofproto/ofproto-dpif.h
index b8532c1..9e56558 100644
--- a/ofproto/ofproto-dpif.h
+++ b/ofproto/ofproto-dpif.h
@@ -215,6 +215,7 @@ uint32_t ofproto_dpif_alloc_recirc_id(struct ofproto_dpif 
*ofproto);
 void ofproto_dpif_free_recirc_id(struct ofproto_dpif *ofproto, uint32_t 
recirc_id);
 int ofproto_dpif_add_internal_flow(struct ofproto_dpif *,
                                    struct match *, int priority,
+                                   uint16_t idle_timeout,
                                    const struct ofpbuf *ofpacts,
                                    struct rule **rulep);
 int ofproto_dpif_delete_internal_flow(struct ofproto_dpif *, struct match *,
-- 
1.8.5.2

_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev

Reply via email to