diff mbox series

[ovs-dev,v1,1/3] netdev-dpdk: Expose flow creation/destruction calls

Message ID 1550506563-26782-2-git-send-email-ophirmu@mellanox.com
State Superseded
Headers show
Series Move offloading-code into a new file | expand

Commit Message

Ophir Munk Feb. 18, 2019, 4:16 p.m. UTC
From: Roni Bar Yanai <roniba@mellanox.com>

Before offloading-code was added to the netdev-dpdk.c file (MARK and
RSS actions) the only DPDK RTE calls in use were rte_flow_create() and
rte_flow_destroy(). In preparation for splitting the offloading-code
from the netdev-dpdk.c file to a separate file, it is required
to embed these RTE calls into a global netdev-dpdk-* API so that
they can be called from the new file. An example for this requirement
can be seen in the handling of dpdk_mutex, which should be encapsulated
inside netdev-dpdk class (netdev-dpdk.c file), and should be unknown
to the outside callers. This commit embeds the rte_flow_create() call
inside the netdev_dpdk_flow_create() API and the rte_flow_destroy()
call inside the netdev_dpdk_rte_flow_destroy() API.

Reviewed-by: Asaf Penso <asafp@mellanox.com>
Signed-off-by: Roni Bar Yanai <roniba@mellanox.com>
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
---
 lib/netdev-dpdk.c | 51 +++++++++++++++++++++++++++++++++++++++------------
 lib/netdev-dpdk.h | 14 ++++++++++++++
 2 files changed, 53 insertions(+), 12 deletions(-)

Comments

0-day Robot Feb. 18, 2019, 5:38 p.m. UTC | #1
Bleep bloop.  Greetings Ophir Munk, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Ophir Munk <ophirmu@mellanox.com>
Lines checked: 155, Warnings: 1, Errors: 0


Please check this out.  If you feel there has been an error, please email aconole@bytheb.org

Thanks,
0-day Robot
Ophir Munk Feb. 19, 2019, 4:04 p.m. UTC | #2
Ian,
Can you please update:
Signed-off-by: Ophir Munk <...>
To:
Reviewed-by: Ophir Munk <...>

Regards,
Ophir

> -----Original Message-----
> From: 0-day Robot <robot@bytheb.org>
> Sent: Monday, February 18, 2019 7:38 PM
> To: Ophir Munk <ophirmu@mellanox.com>
> Cc: dev@openvswitch.org
> Subject: Re: netdev-dpdk: Expose flow creation/destruction calls
> 
> Bleep bloop.  Greetings Ophir Munk, I am a robot and I have tried out your
> patch.
> Thanks for your contribution.
> 
> I encountered some error that I wasn't expecting.  See the details below.
> 
> 
> checkpatch:
> WARNING: Unexpected sign-offs from developers who are not authors or
> co-authors or committers: Ophir Munk <ophirmu@mellanox.com> Lines
> checked: 155, Warnings: 1, Errors: 0
> 
> 
> Please check this out.  If you feel there has been an error, please email
> aconole@bytheb.org
> 
> Thanks,
> 0-day Robot
Stokes, Ian Feb. 19, 2019, 4:23 p.m. UTC | #3
> 
> Ian,
> Can you please update:
> Signed-off-by: Ophir Munk <...>
> To:
> Reviewed-by: Ophir Munk <...>

Sure we can do this upon commit.

Ian
> 
> Regards,
> Ophir
> 
> > -----Original Message-----
> > From: 0-day Robot <robot@bytheb.org>
> > Sent: Monday, February 18, 2019 7:38 PM
> > To: Ophir Munk <ophirmu@mellanox.com>
> > Cc: dev@openvswitch.org
> > Subject: Re: netdev-dpdk: Expose flow creation/destruction calls
> >
> > Bleep bloop.  Greetings Ophir Munk, I am a robot and I have tried out
> > your patch.
> > Thanks for your contribution.
> >
> > I encountered some error that I wasn't expecting.  See the details
> below.
> >
> >
> > checkpatch:
> > WARNING: Unexpected sign-offs from developers who are not authors or
> > co-authors or committers: Ophir Munk <ophirmu@mellanox.com> Lines
> > checked: 155, Warnings: 1, Errors: 0
> >
> >
> > Please check this out.  If you feel there has been an error, please
> > email aconole@bytheb.org
> >
> > Thanks,
> > 0-day Robot
diff mbox series

Patch

diff --git a/lib/netdev-dpdk.c b/lib/netdev-dpdk.c
index f07b10c..1bf01ad 100644
--- a/lib/netdev-dpdk.c
+++ b/lib/netdev-dpdk.c
@@ -4202,6 +4202,42 @@  unlock:
     return err;
 }
 
+int
+netdev_dpdk_rte_flow_destroy(struct netdev *netdev,
+                             struct rte_flow *rte_flow,
+                             struct rte_flow_error *error)
+{
+    if (!is_dpdk_class(netdev->netdev_class)) {
+        return -1;
+    }
+
+    struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
+    int ret;
+
+    ovs_mutex_lock(&dev->mutex);
+    ret = rte_flow_destroy(dev->port_id, rte_flow, error);
+    ovs_mutex_unlock(&dev->mutex);
+    return ret;
+}
+
+struct rte_flow *
+netdev_dpdk_rte_flow_create(struct netdev *netdev,
+                            const struct rte_flow_attr *attr,
+                            const struct rte_flow_item *items,
+                            const struct rte_flow_action *actions,
+                            struct rte_flow_error *error)
+{
+    if (!is_dpdk_class(netdev->netdev_class)) {
+        return NULL;
+    }
+
+    struct rte_flow *flow;
+    struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
+    ovs_mutex_lock(&dev->mutex);
+    flow = rte_flow_create(dev->port_id, attr, items, actions, error);
+    ovs_mutex_unlock(&dev->mutex);
+    return flow;
+}
 
 /* Find rte_flow with @ufid */
 static struct rte_flow *
@@ -4553,7 +4589,6 @@  netdev_dpdk_add_rte_flow_offload(struct netdev *netdev,
                                  size_t actions_len OVS_UNUSED,
                                  const ovs_u128 *ufid,
                                  struct offload_info *info) {
-    struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
     const struct rte_flow_attr flow_attr = {
         .group = 0,
         .priority = 0,
@@ -4758,15 +4793,12 @@  end_proto_check:
     mark.id = info->flow_mark;
     add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_MARK, &mark);
 
-    ovs_mutex_lock(&dev->mutex);
 
     rss = add_flow_rss_action(&actions, netdev);
     add_flow_action(&actions, RTE_FLOW_ACTION_TYPE_END, NULL);
 
-    flow = rte_flow_create(dev->port_id, &flow_attr, patterns.items,
-                           actions.actions, &error);
-
-    ovs_mutex_unlock(&dev->mutex);
+    flow = netdev_dpdk_rte_flow_create(netdev, &flow_attr,patterns.items,
+                            actions.actions, &error);
 
     free(rss);
     if (!flow) {
@@ -4884,13 +4916,9 @@  static int
 netdev_dpdk_destroy_rte_flow(struct netdev *netdev,
                              const ovs_u128 *ufid,
                              struct rte_flow *rte_flow) {
-    struct netdev_dpdk *dev = netdev_dpdk_cast(netdev);
     struct rte_flow_error error;
-    int ret;
+    int ret = netdev_dpdk_rte_flow_destroy(netdev, rte_flow, &error);
 
-    ovs_mutex_lock(&dev->mutex);
-
-    ret = rte_flow_destroy(dev->port_id, rte_flow, &error);
     if (ret == 0) {
         ufid_to_rte_flow_disassociate(ufid);
         VLOG_DBG("%s: removed rte flow %p associated with ufid " UUID_FMT "\n",
@@ -4901,7 +4929,6 @@  netdev_dpdk_destroy_rte_flow(struct netdev *netdev,
                  netdev_get_name(netdev), error.type, error.message);
     }
 
-    ovs_mutex_unlock(&dev->mutex);
     return ret;
 }
 
diff --git a/lib/netdev-dpdk.h b/lib/netdev-dpdk.h
index b7d02a7..82d2828 100644
--- a/lib/netdev-dpdk.h
+++ b/lib/netdev-dpdk.h
@@ -22,11 +22,25 @@ 
 #include "openvswitch/compiler.h"
 
 struct dp_packet;
+struct netdev;
+struct rte_flow;
+struct rte_flow_error;
+struct rte_flow_attr;
+struct rte_flow_item;
+struct rte_flow_action;
 
 #ifdef DPDK_NETDEV
 
 void netdev_dpdk_register(void);
 void free_dpdk_buf(struct dp_packet *);
+int netdev_dpdk_rte_flow_destroy(struct netdev *netdev,
+                             struct rte_flow *rte_flow,
+                             struct rte_flow_error *error);
+struct rte_flow *netdev_dpdk_rte_flow_create(struct netdev *netdev,
+                            const struct rte_flow_attr *attr,
+                            const struct rte_flow_item *items,
+                            const struct rte_flow_action *actions,
+                            struct rte_flow_error *error);
 
 #else