diff mbox series

[ovs-dev,1/3] dpif-netlink: Generate ufids for installing TC flowers

Message ID 20200518014443.1529-1-xiangxia.m.yue@gmail.com
State New
Headers show
Series [ovs-dev,1/3] dpif-netlink: Generate ufids for installing TC flowers | expand

Commit Message

Tonghao Zhang May 18, 2020, 1:44 a.m. UTC
From: Tonghao Zhang <xiangxia.m.yue@gmail.com>

To support installing the TC flowers to HW, via "ovs-appctl dpctl/add-flow"
command, there should be an ufid. This patch will check whether ufid exists,
if not, generate an ufid. Should to know that when processing upcall packets,
ufid is generated in parse_odp_packet for kernel datapath.

Configuring the max-idle/max-revalidator, may help testing this patch.

Cc: Simon Horman <simon.horman@netronome.com>
Cc: Paul Blakey <paulb@mellanox.com>
Cc: Roi Dayan <roid@mellanox.com>
Cc: Ben Pfaff <blp@ovn.org>
Cc: William Tu <u9012063@gmail.com>
Cc: Ilya Maximets <i.maximets@ovn.org>
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 lib/dpif-netlink.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)

Comments

Roi Dayan May 18, 2020, 2:37 p.m. UTC | #1
On 2020-05-18 4:44 AM, xiangxia.m.yue@gmail.com wrote:
> From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> 
> To support installing the TC flowers to HW, via "ovs-appctl dpctl/add-flow"
> command, there should be an ufid. This patch will check whether ufid exists,
> if not, generate an ufid. Should to know that when processing upcall packets,
> ufid is generated in parse_odp_packet for kernel datapath.
> 
> Configuring the max-idle/max-revalidator, may help testing this patch.
> 
> Cc: Simon Horman <simon.horman@netronome.com>
> Cc: Paul Blakey <paulb@mellanox.com>
> Cc: Roi Dayan <roid@mellanox.com>
> Cc: Ben Pfaff <blp@ovn.org>
> Cc: William Tu <u9012063@gmail.com>
> Cc: Ilya Maximets <i.maximets@ovn.org>
> Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> ---
>  lib/dpif-netlink.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
> 
> diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
> index dc642100fc58..a19ed7e53566 100644
> --- a/lib/dpif-netlink.c
> +++ b/lib/dpif-netlink.c
> @@ -2231,12 +2231,55 @@ dpif_netlink_operate_chunks(struct dpif_netlink *dpif, struct dpif_op **ops,
>      }
>  }
>  
> +static void
> +dpif_netlink_try_update_ufid__(struct dpif_op *op, ovs_u128 *ufid)
> +{
> +    switch (op->type) {
> +    case DPIF_OP_FLOW_PUT:
> +        if (!op->flow_put.ufid) {
> +            odp_flow_key_hash(op->flow_put.key, op->flow_put.key_len,
> +                              ufid);
> +            op->flow_put.ufid = ufid;
> +        }
> +        break;
> +    case DPIF_OP_FLOW_DEL:
> +        if (!op->flow_del.ufid) {
> +            odp_flow_key_hash(op->flow_del.key, op->flow_del.key_len,
> +                              ufid);
> +            op->flow_del.ufid = ufid;
> +        }
> +        break;
> +    case DPIF_OP_FLOW_GET:
> +        if (!op->flow_get.ufid) {
> +            odp_flow_key_hash(op->flow_get.key, op->flow_get.key_len,
> +                              ufid);
> +            op->flow_get.ufid = ufid;
> +        }
> +        break;
> +    case DPIF_OP_EXECUTE:
> +    default:
> +        break;
> +    }
> +}
> +
> +static void
> +dpif_netlink_try_update_ufid(struct dpif_op **ops, ovs_u128 *ufid,
> +                             size_t n_ops)
> +{
> +    int i;
> +
> +    for (i = 0; i < n_ops; i++) {
> +        dpif_netlink_try_update_ufid__(ops[i], &ufid[i]);
> +    }
> +}
> +
>  static void
>  dpif_netlink_operate(struct dpif *dpif_, struct dpif_op **ops, size_t n_ops,
>                       enum dpif_offload_type offload_type)
>  {
>      struct dpif_netlink *dpif = dpif_netlink_cast(dpif_);
>      struct dpif_op *new_ops[OPERATE_MAX_OPS];
> +    ovs_u128 ufids[OPERATE_MAX_OPS];
>      int count = 0;
>      int i = 0;
>      int err = 0;
> @@ -2246,6 +2289,8 @@ dpif_netlink_operate(struct dpif *dpif_, struct dpif_op **ops, size_t n_ops,
>          return;
>      }
>  
> +    dpif_netlink_try_update_ufid(ops, ufids, n_ops);
> +
>      if (offload_type != DPIF_OFFLOAD_NEVER && netdev_is_flow_api_enabled()) {
>          while (n_ops > 0) {
>              count = 0;
> 

Acked-by: Roi Dayan <roid@mellanox.com>
Tonghao Zhang May 26, 2020, 12:33 a.m. UTC | #2
On Mon, May 18, 2020 at 10:37 PM Roi Dayan <roid@mellanox.com> wrote:
>
>
>
> On 2020-05-18 4:44 AM, xiangxia.m.yue@gmail.com wrote:
> > From: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> >
> > To support installing the TC flowers to HW, via "ovs-appctl dpctl/add-flow"
> > command, there should be an ufid. This patch will check whether ufid exists,
> > if not, generate an ufid. Should to know that when processing upcall packets,
> > ufid is generated in parse_odp_packet for kernel datapath.
> >
> > Configuring the max-idle/max-revalidator, may help testing this patch.
> >
> > Cc: Simon Horman <simon.horman@netronome.com>
> > Cc: Paul Blakey <paulb@mellanox.com>
> > Cc: Roi Dayan <roid@mellanox.com>
> > Cc: Ben Pfaff <blp@ovn.org>
> > Cc: William Tu <u9012063@gmail.com>
> > Cc: Ilya Maximets <i.maximets@ovn.org>
> > Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
> > ---
> >  lib/dpif-netlink.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 45 insertions(+)
> >
> > diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
> > index dc642100fc58..a19ed7e53566 100644
> > --- a/lib/dpif-netlink.c
> > +++ b/lib/dpif-netlink.c
> > @@ -2231,12 +2231,55 @@ dpif_netlink_operate_chunks(struct dpif_netlink *dpif, struct dpif_op **ops,
> >      }
> >  }
> >
> > +static void
> > +dpif_netlink_try_update_ufid__(struct dpif_op *op, ovs_u128 *ufid)
> > +{
> > +    switch (op->type) {
> > +    case DPIF_OP_FLOW_PUT:
> > +        if (!op->flow_put.ufid) {
> > +            odp_flow_key_hash(op->flow_put.key, op->flow_put.key_len,
> > +                              ufid);
> > +            op->flow_put.ufid = ufid;
> > +        }
> > +        break;
> > +    case DPIF_OP_FLOW_DEL:
> > +        if (!op->flow_del.ufid) {
> > +            odp_flow_key_hash(op->flow_del.key, op->flow_del.key_len,
> > +                              ufid);
> > +            op->flow_del.ufid = ufid;
> > +        }
> > +        break;
> > +    case DPIF_OP_FLOW_GET:
> > +        if (!op->flow_get.ufid) {
> > +            odp_flow_key_hash(op->flow_get.key, op->flow_get.key_len,
> > +                              ufid);
> > +            op->flow_get.ufid = ufid;
> > +        }
> > +        break;
> > +    case DPIF_OP_EXECUTE:
> > +    default:
> > +        break;
> > +    }
> > +}
> > +
> > +static void
> > +dpif_netlink_try_update_ufid(struct dpif_op **ops, ovs_u128 *ufid,
> > +                             size_t n_ops)
> > +{
> > +    int i;
> > +
> > +    for (i = 0; i < n_ops; i++) {
> > +        dpif_netlink_try_update_ufid__(ops[i], &ufid[i]);
> > +    }
> > +}
> > +
> >  static void
> >  dpif_netlink_operate(struct dpif *dpif_, struct dpif_op **ops, size_t n_ops,
> >                       enum dpif_offload_type offload_type)
> >  {
> >      struct dpif_netlink *dpif = dpif_netlink_cast(dpif_);
> >      struct dpif_op *new_ops[OPERATE_MAX_OPS];
> > +    ovs_u128 ufids[OPERATE_MAX_OPS];
> >      int count = 0;
> >      int i = 0;
> >      int err = 0;
> > @@ -2246,6 +2289,8 @@ dpif_netlink_operate(struct dpif *dpif_, struct dpif_op **ops, size_t n_ops,
> >          return;
> >      }
> >
> > +    dpif_netlink_try_update_ufid(ops, ufids, n_ops);
> > +
> >      if (offload_type != DPIF_OFFLOAD_NEVER && netdev_is_flow_api_enabled()) {
> >          while (n_ops > 0) {
> >              count = 0;
> >
>
> Acked-by: Roi Dayan <roid@mellanox.com>
Hi maintainers
It has been 1 week. and reviewed by Roi. I want to see if more
comments, or do you have plan to push them to master. Thanks.
http://patchwork.ozlabs.org/project/openvswitch/patch/20200518014443.1529-1-xiangxia.m.yue@gmail.com/
http://patchwork.ozlabs.org/project/openvswitch/patch/20200518014443.1529-2-xiangxia.m.yue@gmail.com/
http://patchwork.ozlabs.org/project/openvswitch/patch/20200518014443.1529-3-xiangxia.m.yue@gmail.com/



--
Best regards, Tonghao
diff mbox series

Patch

diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index dc642100fc58..a19ed7e53566 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -2231,12 +2231,55 @@  dpif_netlink_operate_chunks(struct dpif_netlink *dpif, struct dpif_op **ops,
     }
 }
 
+static void
+dpif_netlink_try_update_ufid__(struct dpif_op *op, ovs_u128 *ufid)
+{
+    switch (op->type) {
+    case DPIF_OP_FLOW_PUT:
+        if (!op->flow_put.ufid) {
+            odp_flow_key_hash(op->flow_put.key, op->flow_put.key_len,
+                              ufid);
+            op->flow_put.ufid = ufid;
+        }
+        break;
+    case DPIF_OP_FLOW_DEL:
+        if (!op->flow_del.ufid) {
+            odp_flow_key_hash(op->flow_del.key, op->flow_del.key_len,
+                              ufid);
+            op->flow_del.ufid = ufid;
+        }
+        break;
+    case DPIF_OP_FLOW_GET:
+        if (!op->flow_get.ufid) {
+            odp_flow_key_hash(op->flow_get.key, op->flow_get.key_len,
+                              ufid);
+            op->flow_get.ufid = ufid;
+        }
+        break;
+    case DPIF_OP_EXECUTE:
+    default:
+        break;
+    }
+}
+
+static void
+dpif_netlink_try_update_ufid(struct dpif_op **ops, ovs_u128 *ufid,
+                             size_t n_ops)
+{
+    int i;
+
+    for (i = 0; i < n_ops; i++) {
+        dpif_netlink_try_update_ufid__(ops[i], &ufid[i]);
+    }
+}
+
 static void
 dpif_netlink_operate(struct dpif *dpif_, struct dpif_op **ops, size_t n_ops,
                      enum dpif_offload_type offload_type)
 {
     struct dpif_netlink *dpif = dpif_netlink_cast(dpif_);
     struct dpif_op *new_ops[OPERATE_MAX_OPS];
+    ovs_u128 ufids[OPERATE_MAX_OPS];
     int count = 0;
     int i = 0;
     int err = 0;
@@ -2246,6 +2289,8 @@  dpif_netlink_operate(struct dpif *dpif_, struct dpif_op **ops, size_t n_ops,
         return;
     }
 
+    dpif_netlink_try_update_ufid(ops, ufids, n_ops);
+
     if (offload_type != DPIF_OFFLOAD_NEVER && netdev_is_flow_api_enabled()) {
         while (n_ops > 0) {
             count = 0;