diff mbox

[ovs-dev,v2,08/15] dpif-netdev: Refactor userspace action

Message ID 1461290070-63896-9-git-send-email-pshelar@ovn.org
State Superseded
Headers show

Commit Message

Pravin Shelar April 22, 2016, 1:54 a.m. UTC
Large segment support need to use this refactored function to
send individual segments.

Signed-off-by: Pravin B Shelar <pshelar@ovn.org>
---
 lib/dpif-netdev.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

Comments

Jesse Gross May 6, 2016, 9:38 p.m. UTC | #1
On Thu, Apr 21, 2016 at 6:54 PM, Pravin B Shelar <pshelar@ovn.org> wrote:
> Large segment support need to use this refactored function to
> send individual segments.
>
> Signed-off-by: Pravin B Shelar <pshelar@ovn.org>

Acked-by: Jesse Gross <jesse@kernel.org>
diff mbox

Patch

diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index f34aeae..00f130c 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -3724,6 +3724,30 @@  push_tnl_action(const struct dp_netdev *dp,
 }
 
 static void
+dp_execute_userspace_action(struct dp_netdev_pmd_thread *pmd,
+                            struct dp_packet *packet, bool may_steal,
+                            struct flow *flow, ovs_u128 *ufid,
+                            struct ofpbuf *actions,
+                            const struct nlattr *userdata)
+{
+    struct dp_packet_batch b;
+    int error;
+
+    ofpbuf_clear(actions);
+
+    error = dp_netdev_upcall(pmd, packet, flow, NULL, ufid,
+                             DPIF_UC_ACTION, userdata, actions,
+                             NULL);
+    if (!error || error == ENOSPC) {
+        packet_batch_init_packet(&b, packet);
+        dp_netdev_execute_actions(pmd, &b, may_steal,
+                                  actions->data, actions->size);
+    } else if (may_steal) {
+        dp_packet_delete(packet);
+    }
+}
+
+static void
 dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
               const struct nlattr *a, bool may_steal)
     OVS_NO_THREAD_SAFETY_ANALYSIS
@@ -3819,23 +3843,10 @@  dp_execute_cb(void *aux_, struct dp_packet_batch *packets_,
             ofpbuf_init(&actions, 0);
 
             for (i = 0; i < packets_->count; i++) {
-                int error;
-                struct dp_packet_batch b;
-
-                ofpbuf_clear(&actions);
-
                 flow_extract(packets[i], &flow);
                 dpif_flow_hash(dp->dpif, &flow, sizeof flow, &ufid);
-                error = dp_netdev_upcall(pmd, packets[i], &flow, NULL, &ufid,
-                                         DPIF_UC_ACTION, userdata,&actions,
-                                         NULL);
-                if (!error || error == ENOSPC) {
-                    packet_batch_init_packet(&b, packets[i]);
-                    dp_netdev_execute_actions(pmd, &b, may_steal,
-                                              actions.data, actions.size);
-                } else if (may_steal) {
-                    dp_packet_delete(packets[i]);
-                }
+                dp_execute_userspace_action(pmd, packets[i], may_steal, &flow,
+                                            &ufid, &actions, userdata);
             }
             ofpbuf_uninit(&actions);
             fat_rwlock_unlock(&dp->upcall_rwlock);