diff mbox series

[ovs-dev,v2] netdev-offload-dpdk: Support offload of VLAN PUSH/POP actions

Message ID 20200529063305.18641-1-sriharsha.basavapatna@broadcom.com
State Accepted
Delegated to: Ilya Maximets
Headers show
Series [ovs-dev,v2] netdev-offload-dpdk: Support offload of VLAN PUSH/POP actions | expand

Commit Message

Sriharsha Basavapatna May 29, 2020, 6:33 a.m. UTC
Parse VLAN PUSH/POP OVS datapath actions and add respective RTE actions.

Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>

---
v1->v2:
* Updated dump_flow_action() to print VLAN Push/Pop actions
* Updated NEWS, Documentation/howto/dpdk.rst files
---

 Documentation/howto/dpdk.rst |  1 +
 NEWS                         |  1 +
 lib/netdev-offload-dpdk.c    | 64 ++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+)

Comments

Eli Britstein June 1, 2020, 2:23 p.m. UTC | #1
Acked-by: Eli Britstein <elibr@mellanox.com>

On 5/29/2020 9:33 AM, Sriharsha Basavapatna wrote:
> Parse VLAN PUSH/POP OVS datapath actions and add respective RTE actions.
>
> Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> ---
> v1->v2:
> * Updated dump_flow_action() to print VLAN Push/Pop actions
> * Updated NEWS, Documentation/howto/dpdk.rst files
> ---
>
>   Documentation/howto/dpdk.rst |  1 +
>   NEWS                         |  1 +
>   lib/netdev-offload-dpdk.c    | 64 ++++++++++++++++++++++++++++++++++++
>   3 files changed, 66 insertions(+)
>
> diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
> index be950d7ce..c40fcafcb 100644
> --- a/Documentation/howto/dpdk.rst
> +++ b/Documentation/howto/dpdk.rst
> @@ -395,6 +395,7 @@ Supported actions for hardware offload are:
>   - Modification of Ethernet (mod_dl_src/mod_dl_dst).
>   - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl).
>   - Modification of TCP/UDP (mod_tp_src/mod_tp_dst).
> +- VLAN Push/Pop (push_vlan/pop_vlan).
>   
>   Further Reading
>   ---------------
> diff --git a/NEWS b/NEWS
> index 3dbd8ec0e..c1311e366 100644
> --- a/NEWS
> +++ b/NEWS
> @@ -9,6 +9,7 @@ Post-v2.13.0
>      - DPDK:
>        * Deprecated DPDK pdump packet capture support removed.
>        * Deprecated DPDK ring ports (dpdkr) are no longer supported.
> +     * Add hardware offload support for VLAN Push/Pop actions (experimental).
>      - Linux datapath:
>        * Support for kernel versions up to 5.5.x.
>      - AF_XDP:
> diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
> index f8c46bbaa..c57586a48 100644
> --- a/lib/netdev-offload-dpdk.c
> +++ b/lib/netdev-offload-dpdk.c
> @@ -420,6 +420,36 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
>           } else {
>               ds_put_format(s, "  Set-%s-tcp/udp-port = null\n", dirstr);
>           }
> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) {
> +        const struct rte_flow_action_of_push_vlan *rte_push_vlan =
> +            actions->conf;
> +        ds_put_cstr(s, "rte flow push-vlan action:\n");
> +        if (rte_push_vlan) {
> +            ds_put_format(s, "  Push-vlan: 0x%"PRIx16"\n",
> +                          ntohs(rte_push_vlan->ethertype));
> +        } else {
> +            ds_put_format(s, "  Push-vlan = null\n");
> +        }
> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) {
> +        struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp = actions->conf;
> +        ds_put_cstr(s, "rte flow set-vlan-pcp action:\n");
> +        if (rte_vlan_pcp) {
> +            ds_put_format(s, "  Set-vlan-pcp: %"PRIu8"\n",
> +                          rte_vlan_pcp->vlan_pcp);
> +        } else {
> +            ds_put_format(s, "  Set-vlan-pcp = null\n");
> +        }
> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) {
> +        struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid = actions->conf;
> +        ds_put_cstr(s, "rte flow set-vlan-vid action:\n");
> +        if (rte_vlan_vid) {
> +            ds_put_format(s, "  Set-vlan-vid: %"PRIu16"\n",
> +                          ntohs(rte_vlan_vid->vlan_vid));
> +        } else {
> +            ds_put_format(s, "  Set-vlan-vid = null\n");
> +        }
> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) {
> +        ds_put_cstr(s, "rte flow pop-vlan action\n");
>       } else {
>           ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
>       }
> @@ -970,6 +1000,33 @@ parse_set_actions(struct flow_actions *actions,
>       return 0;
>   }
>   
> +static int
> +parse_vlan_push_action(struct flow_actions *actions,
> +                       const struct ovs_action_push_vlan *vlan_push)
> +{
> +    struct rte_flow_action_of_push_vlan *rte_push_vlan;
> +    struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp;
> +    struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid;
> +
> +    rte_push_vlan = xzalloc(sizeof *rte_push_vlan);
> +    rte_push_vlan->ethertype = vlan_push->vlan_tpid;
> +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
> +                    rte_push_vlan);
> +
> +    rte_vlan_pcp = xzalloc(sizeof *rte_vlan_pcp);
> +    rte_vlan_pcp->vlan_pcp = vlan_tci_to_pcp(vlan_push->vlan_tci);
> +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
> +                    rte_vlan_pcp);
> +
> +    rte_vlan_vid = xzalloc(sizeof *rte_vlan_vid);
> +    rte_vlan_vid->vlan_vid =
> +        rte_cpu_to_be_16(vlan_tci_to_vid(vlan_push->vlan_tci));
> +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
> +                    rte_vlan_vid);
> +
> +    return 0;
> +}
> +
>   static int
>   parse_flow_actions(struct netdev *netdev,
>                      struct flow_actions *actions,
> @@ -998,6 +1055,13 @@ parse_flow_actions(struct netdev *netdev,
>                                     masked)) {
>                   return -1;
>               }
> +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
> +            const struct ovs_action_push_vlan *vlan = nl_attr_get(nla);
> +            if (parse_vlan_push_action(actions, vlan)) {
> +                return -1;
> +            }
> +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) {
> +            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
>           } else {
>               VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
>               return -1;
Sriharsha Basavapatna June 2, 2020, 4:46 p.m. UTC | #2
If there are no other comments, can this be applied to master ?

Thanks,
-Harsha

On Mon, Jun 1, 2020 at 7:54 PM Eli Britstein <elibr@mellanox.com> wrote:
>
> Acked-by: Eli Britstein <elibr@mellanox.com>
>
> On 5/29/2020 9:33 AM, Sriharsha Basavapatna wrote:
> > Parse VLAN PUSH/POP OVS datapath actions and add respective RTE actions.
> >
> > Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> > ---
> > v1->v2:
> > * Updated dump_flow_action() to print VLAN Push/Pop actions
> > * Updated NEWS, Documentation/howto/dpdk.rst files
> > ---
> >
> >   Documentation/howto/dpdk.rst |  1 +
> >   NEWS                         |  1 +
> >   lib/netdev-offload-dpdk.c    | 64 ++++++++++++++++++++++++++++++++++++
> >   3 files changed, 66 insertions(+)
> >
> > diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
> > index be950d7ce..c40fcafcb 100644
> > --- a/Documentation/howto/dpdk.rst
> > +++ b/Documentation/howto/dpdk.rst
> > @@ -395,6 +395,7 @@ Supported actions for hardware offload are:
> >   - Modification of Ethernet (mod_dl_src/mod_dl_dst).
> >   - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl).
> >   - Modification of TCP/UDP (mod_tp_src/mod_tp_dst).
> > +- VLAN Push/Pop (push_vlan/pop_vlan).
> >
> >   Further Reading
> >   ---------------
> > diff --git a/NEWS b/NEWS
> > index 3dbd8ec0e..c1311e366 100644
> > --- a/NEWS
> > +++ b/NEWS
> > @@ -9,6 +9,7 @@ Post-v2.13.0
> >      - DPDK:
> >        * Deprecated DPDK pdump packet capture support removed.
> >        * Deprecated DPDK ring ports (dpdkr) are no longer supported.
> > +     * Add hardware offload support for VLAN Push/Pop actions (experimental).
> >      - Linux datapath:
> >        * Support for kernel versions up to 5.5.x.
> >      - AF_XDP:
> > diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
> > index f8c46bbaa..c57586a48 100644
> > --- a/lib/netdev-offload-dpdk.c
> > +++ b/lib/netdev-offload-dpdk.c
> > @@ -420,6 +420,36 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
> >           } else {
> >               ds_put_format(s, "  Set-%s-tcp/udp-port = null\n", dirstr);
> >           }
> > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) {
> > +        const struct rte_flow_action_of_push_vlan *rte_push_vlan =
> > +            actions->conf;
> > +        ds_put_cstr(s, "rte flow push-vlan action:\n");
> > +        if (rte_push_vlan) {
> > +            ds_put_format(s, "  Push-vlan: 0x%"PRIx16"\n",
> > +                          ntohs(rte_push_vlan->ethertype));
> > +        } else {
> > +            ds_put_format(s, "  Push-vlan = null\n");
> > +        }
> > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) {
> > +        struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp = actions->conf;
> > +        ds_put_cstr(s, "rte flow set-vlan-pcp action:\n");
> > +        if (rte_vlan_pcp) {
> > +            ds_put_format(s, "  Set-vlan-pcp: %"PRIu8"\n",
> > +                          rte_vlan_pcp->vlan_pcp);
> > +        } else {
> > +            ds_put_format(s, "  Set-vlan-pcp = null\n");
> > +        }
> > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) {
> > +        struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid = actions->conf;
> > +        ds_put_cstr(s, "rte flow set-vlan-vid action:\n");
> > +        if (rte_vlan_vid) {
> > +            ds_put_format(s, "  Set-vlan-vid: %"PRIu16"\n",
> > +                          ntohs(rte_vlan_vid->vlan_vid));
> > +        } else {
> > +            ds_put_format(s, "  Set-vlan-vid = null\n");
> > +        }
> > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) {
> > +        ds_put_cstr(s, "rte flow pop-vlan action\n");
> >       } else {
> >           ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
> >       }
> > @@ -970,6 +1000,33 @@ parse_set_actions(struct flow_actions *actions,
> >       return 0;
> >   }
> >
> > +static int
> > +parse_vlan_push_action(struct flow_actions *actions,
> > +                       const struct ovs_action_push_vlan *vlan_push)
> > +{
> > +    struct rte_flow_action_of_push_vlan *rte_push_vlan;
> > +    struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp;
> > +    struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid;
> > +
> > +    rte_push_vlan = xzalloc(sizeof *rte_push_vlan);
> > +    rte_push_vlan->ethertype = vlan_push->vlan_tpid;
> > +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
> > +                    rte_push_vlan);
> > +
> > +    rte_vlan_pcp = xzalloc(sizeof *rte_vlan_pcp);
> > +    rte_vlan_pcp->vlan_pcp = vlan_tci_to_pcp(vlan_push->vlan_tci);
> > +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
> > +                    rte_vlan_pcp);
> > +
> > +    rte_vlan_vid = xzalloc(sizeof *rte_vlan_vid);
> > +    rte_vlan_vid->vlan_vid =
> > +        rte_cpu_to_be_16(vlan_tci_to_vid(vlan_push->vlan_tci));
> > +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
> > +                    rte_vlan_vid);
> > +
> > +    return 0;
> > +}
> > +
> >   static int
> >   parse_flow_actions(struct netdev *netdev,
> >                      struct flow_actions *actions,
> > @@ -998,6 +1055,13 @@ parse_flow_actions(struct netdev *netdev,
> >                                     masked)) {
> >                   return -1;
> >               }
> > +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
> > +            const struct ovs_action_push_vlan *vlan = nl_attr_get(nla);
> > +            if (parse_vlan_push_action(actions, vlan)) {
> > +                return -1;
> > +            }
> > +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) {
> > +            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
> >           } else {
> >               VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
> >               return -1;
Sriharsha Basavapatna June 10, 2020, 9:59 a.m. UTC | #3
Just a gentle reminder on this patch. It has already been ack'd by Eli.
Thanks,
-Harsha

On Tue, Jun 2, 2020 at 10:16 PM Sriharsha Basavapatna
<sriharsha.basavapatna@broadcom.com> wrote:
>
> If there are no other comments, can this be applied to master ?
>
> Thanks,
> -Harsha
>
> On Mon, Jun 1, 2020 at 7:54 PM Eli Britstein <elibr@mellanox.com> wrote:
> >
> > Acked-by: Eli Britstein <elibr@mellanox.com>
> >
> > On 5/29/2020 9:33 AM, Sriharsha Basavapatna wrote:
> > > Parse VLAN PUSH/POP OVS datapath actions and add respective RTE actions.
> > >
> > > Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> > > ---
> > > v1->v2:
> > > * Updated dump_flow_action() to print VLAN Push/Pop actions
> > > * Updated NEWS, Documentation/howto/dpdk.rst files
> > > ---
> > >
> > >   Documentation/howto/dpdk.rst |  1 +
> > >   NEWS                         |  1 +
> > >   lib/netdev-offload-dpdk.c    | 64 ++++++++++++++++++++++++++++++++++++
> > >   3 files changed, 66 insertions(+)
> > >
> > > diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
> > > index be950d7ce..c40fcafcb 100644
> > > --- a/Documentation/howto/dpdk.rst
> > > +++ b/Documentation/howto/dpdk.rst
> > > @@ -395,6 +395,7 @@ Supported actions for hardware offload are:
> > >   - Modification of Ethernet (mod_dl_src/mod_dl_dst).
> > >   - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl).
> > >   - Modification of TCP/UDP (mod_tp_src/mod_tp_dst).
> > > +- VLAN Push/Pop (push_vlan/pop_vlan).
> > >
> > >   Further Reading
> > >   ---------------
> > > diff --git a/NEWS b/NEWS
> > > index 3dbd8ec0e..c1311e366 100644
> > > --- a/NEWS
> > > +++ b/NEWS
> > > @@ -9,6 +9,7 @@ Post-v2.13.0
> > >      - DPDK:
> > >        * Deprecated DPDK pdump packet capture support removed.
> > >        * Deprecated DPDK ring ports (dpdkr) are no longer supported.
> > > +     * Add hardware offload support for VLAN Push/Pop actions (experimental).
> > >      - Linux datapath:
> > >        * Support for kernel versions up to 5.5.x.
> > >      - AF_XDP:
> > > diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
> > > index f8c46bbaa..c57586a48 100644
> > > --- a/lib/netdev-offload-dpdk.c
> > > +++ b/lib/netdev-offload-dpdk.c
> > > @@ -420,6 +420,36 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
> > >           } else {
> > >               ds_put_format(s, "  Set-%s-tcp/udp-port = null\n", dirstr);
> > >           }
> > > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) {
> > > +        const struct rte_flow_action_of_push_vlan *rte_push_vlan =
> > > +            actions->conf;
> > > +        ds_put_cstr(s, "rte flow push-vlan action:\n");
> > > +        if (rte_push_vlan) {
> > > +            ds_put_format(s, "  Push-vlan: 0x%"PRIx16"\n",
> > > +                          ntohs(rte_push_vlan->ethertype));
> > > +        } else {
> > > +            ds_put_format(s, "  Push-vlan = null\n");
> > > +        }
> > > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) {
> > > +        struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp = actions->conf;
> > > +        ds_put_cstr(s, "rte flow set-vlan-pcp action:\n");
> > > +        if (rte_vlan_pcp) {
> > > +            ds_put_format(s, "  Set-vlan-pcp: %"PRIu8"\n",
> > > +                          rte_vlan_pcp->vlan_pcp);
> > > +        } else {
> > > +            ds_put_format(s, "  Set-vlan-pcp = null\n");
> > > +        }
> > > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) {
> > > +        struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid = actions->conf;
> > > +        ds_put_cstr(s, "rte flow set-vlan-vid action:\n");
> > > +        if (rte_vlan_vid) {
> > > +            ds_put_format(s, "  Set-vlan-vid: %"PRIu16"\n",
> > > +                          ntohs(rte_vlan_vid->vlan_vid));
> > > +        } else {
> > > +            ds_put_format(s, "  Set-vlan-vid = null\n");
> > > +        }
> > > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) {
> > > +        ds_put_cstr(s, "rte flow pop-vlan action\n");
> > >       } else {
> > >           ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
> > >       }
> > > @@ -970,6 +1000,33 @@ parse_set_actions(struct flow_actions *actions,
> > >       return 0;
> > >   }
> > >
> > > +static int
> > > +parse_vlan_push_action(struct flow_actions *actions,
> > > +                       const struct ovs_action_push_vlan *vlan_push)
> > > +{
> > > +    struct rte_flow_action_of_push_vlan *rte_push_vlan;
> > > +    struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp;
> > > +    struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid;
> > > +
> > > +    rte_push_vlan = xzalloc(sizeof *rte_push_vlan);
> > > +    rte_push_vlan->ethertype = vlan_push->vlan_tpid;
> > > +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
> > > +                    rte_push_vlan);
> > > +
> > > +    rte_vlan_pcp = xzalloc(sizeof *rte_vlan_pcp);
> > > +    rte_vlan_pcp->vlan_pcp = vlan_tci_to_pcp(vlan_push->vlan_tci);
> > > +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
> > > +                    rte_vlan_pcp);
> > > +
> > > +    rte_vlan_vid = xzalloc(sizeof *rte_vlan_vid);
> > > +    rte_vlan_vid->vlan_vid =
> > > +        rte_cpu_to_be_16(vlan_tci_to_vid(vlan_push->vlan_tci));
> > > +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
> > > +                    rte_vlan_vid);
> > > +
> > > +    return 0;
> > > +}
> > > +
> > >   static int
> > >   parse_flow_actions(struct netdev *netdev,
> > >                      struct flow_actions *actions,
> > > @@ -998,6 +1055,13 @@ parse_flow_actions(struct netdev *netdev,
> > >                                     masked)) {
> > >                   return -1;
> > >               }
> > > +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
> > > +            const struct ovs_action_push_vlan *vlan = nl_attr_get(nla);
> > > +            if (parse_vlan_push_action(actions, vlan)) {
> > > +                return -1;
> > > +            }
> > > +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) {
> > > +            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
> > >           } else {
> > >               VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
> > >               return -1;
Sriharsha Basavapatna June 12, 2020, 3:50 a.m. UTC | #4
Hi Ilya,

Can you please apply this to master ?

Thanks,
-Harsha

On Wed, Jun 10, 2020 at 3:29 PM Sriharsha Basavapatna
<sriharsha.basavapatna@broadcom.com> wrote:
>
> Just a gentle reminder on this patch. It has already been ack'd by Eli.
> Thanks,
> -Harsha
>
> On Tue, Jun 2, 2020 at 10:16 PM Sriharsha Basavapatna
> <sriharsha.basavapatna@broadcom.com> wrote:
> >
> > If there are no other comments, can this be applied to master ?
> >
> > Thanks,
> > -Harsha
> >
> > On Mon, Jun 1, 2020 at 7:54 PM Eli Britstein <elibr@mellanox.com> wrote:
> > >
> > > Acked-by: Eli Britstein <elibr@mellanox.com>
> > >
> > > On 5/29/2020 9:33 AM, Sriharsha Basavapatna wrote:
> > > > Parse VLAN PUSH/POP OVS datapath actions and add respective RTE actions.
> > > >
> > > > Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> > > > ---
> > > > v1->v2:
> > > > * Updated dump_flow_action() to print VLAN Push/Pop actions
> > > > * Updated NEWS, Documentation/howto/dpdk.rst files
> > > > ---
> > > >
> > > >   Documentation/howto/dpdk.rst |  1 +
> > > >   NEWS                         |  1 +
> > > >   lib/netdev-offload-dpdk.c    | 64 ++++++++++++++++++++++++++++++++++++
> > > >   3 files changed, 66 insertions(+)
> > > >
> > > > diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
> > > > index be950d7ce..c40fcafcb 100644
> > > > --- a/Documentation/howto/dpdk.rst
> > > > +++ b/Documentation/howto/dpdk.rst
> > > > @@ -395,6 +395,7 @@ Supported actions for hardware offload are:
> > > >   - Modification of Ethernet (mod_dl_src/mod_dl_dst).
> > > >   - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl).
> > > >   - Modification of TCP/UDP (mod_tp_src/mod_tp_dst).
> > > > +- VLAN Push/Pop (push_vlan/pop_vlan).
> > > >
> > > >   Further Reading
> > > >   ---------------
> > > > diff --git a/NEWS b/NEWS
> > > > index 3dbd8ec0e..c1311e366 100644
> > > > --- a/NEWS
> > > > +++ b/NEWS
> > > > @@ -9,6 +9,7 @@ Post-v2.13.0
> > > >      - DPDK:
> > > >        * Deprecated DPDK pdump packet capture support removed.
> > > >        * Deprecated DPDK ring ports (dpdkr) are no longer supported.
> > > > +     * Add hardware offload support for VLAN Push/Pop actions (experimental).
> > > >      - Linux datapath:
> > > >        * Support for kernel versions up to 5.5.x.
> > > >      - AF_XDP:
> > > > diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
> > > > index f8c46bbaa..c57586a48 100644
> > > > --- a/lib/netdev-offload-dpdk.c
> > > > +++ b/lib/netdev-offload-dpdk.c
> > > > @@ -420,6 +420,36 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
> > > >           } else {
> > > >               ds_put_format(s, "  Set-%s-tcp/udp-port = null\n", dirstr);
> > > >           }
> > > > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) {
> > > > +        const struct rte_flow_action_of_push_vlan *rte_push_vlan =
> > > > +            actions->conf;
> > > > +        ds_put_cstr(s, "rte flow push-vlan action:\n");
> > > > +        if (rte_push_vlan) {
> > > > +            ds_put_format(s, "  Push-vlan: 0x%"PRIx16"\n",
> > > > +                          ntohs(rte_push_vlan->ethertype));
> > > > +        } else {
> > > > +            ds_put_format(s, "  Push-vlan = null\n");
> > > > +        }
> > > > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) {
> > > > +        struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp = actions->conf;
> > > > +        ds_put_cstr(s, "rte flow set-vlan-pcp action:\n");
> > > > +        if (rte_vlan_pcp) {
> > > > +            ds_put_format(s, "  Set-vlan-pcp: %"PRIu8"\n",
> > > > +                          rte_vlan_pcp->vlan_pcp);
> > > > +        } else {
> > > > +            ds_put_format(s, "  Set-vlan-pcp = null\n");
> > > > +        }
> > > > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) {
> > > > +        struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid = actions->conf;
> > > > +        ds_put_cstr(s, "rte flow set-vlan-vid action:\n");
> > > > +        if (rte_vlan_vid) {
> > > > +            ds_put_format(s, "  Set-vlan-vid: %"PRIu16"\n",
> > > > +                          ntohs(rte_vlan_vid->vlan_vid));
> > > > +        } else {
> > > > +            ds_put_format(s, "  Set-vlan-vid = null\n");
> > > > +        }
> > > > +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) {
> > > > +        ds_put_cstr(s, "rte flow pop-vlan action\n");
> > > >       } else {
> > > >           ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
> > > >       }
> > > > @@ -970,6 +1000,33 @@ parse_set_actions(struct flow_actions *actions,
> > > >       return 0;
> > > >   }
> > > >
> > > > +static int
> > > > +parse_vlan_push_action(struct flow_actions *actions,
> > > > +                       const struct ovs_action_push_vlan *vlan_push)
> > > > +{
> > > > +    struct rte_flow_action_of_push_vlan *rte_push_vlan;
> > > > +    struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp;
> > > > +    struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid;
> > > > +
> > > > +    rte_push_vlan = xzalloc(sizeof *rte_push_vlan);
> > > > +    rte_push_vlan->ethertype = vlan_push->vlan_tpid;
> > > > +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
> > > > +                    rte_push_vlan);
> > > > +
> > > > +    rte_vlan_pcp = xzalloc(sizeof *rte_vlan_pcp);
> > > > +    rte_vlan_pcp->vlan_pcp = vlan_tci_to_pcp(vlan_push->vlan_tci);
> > > > +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
> > > > +                    rte_vlan_pcp);
> > > > +
> > > > +    rte_vlan_vid = xzalloc(sizeof *rte_vlan_vid);
> > > > +    rte_vlan_vid->vlan_vid =
> > > > +        rte_cpu_to_be_16(vlan_tci_to_vid(vlan_push->vlan_tci));
> > > > +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
> > > > +                    rte_vlan_vid);
> > > > +
> > > > +    return 0;
> > > > +}
> > > > +
> > > >   static int
> > > >   parse_flow_actions(struct netdev *netdev,
> > > >                      struct flow_actions *actions,
> > > > @@ -998,6 +1055,13 @@ parse_flow_actions(struct netdev *netdev,
> > > >                                     masked)) {
> > > >                   return -1;
> > > >               }
> > > > +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
> > > > +            const struct ovs_action_push_vlan *vlan = nl_attr_get(nla);
> > > > +            if (parse_vlan_push_action(actions, vlan)) {
> > > > +                return -1;
> > > > +            }
> > > > +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) {
> > > > +            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
> > > >           } else {
> > > >               VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
> > > >               return -1;
Ilya Maximets June 15, 2020, 6:49 p.m. UTC | #5
On 6/12/20 5:50 AM, Sriharsha Basavapatna wrote:
> Hi Ilya,
> 
> Can you please apply this to master ?

Hi.  Sorry for delays.  And thanks for the patches and reviews!

I'm going to look at various offload related patches this week.
This one is on my list.

Best regards, Ilya Maximets.

> 
> Thanks,
> -Harsha
> 
> On Wed, Jun 10, 2020 at 3:29 PM Sriharsha Basavapatna
> <sriharsha.basavapatna@broadcom.com> wrote:
>>
>> Just a gentle reminder on this patch. It has already been ack'd by Eli.
>> Thanks,
>> -Harsha
>>
>> On Tue, Jun 2, 2020 at 10:16 PM Sriharsha Basavapatna
>> <sriharsha.basavapatna@broadcom.com> wrote:
>>>
>>> If there are no other comments, can this be applied to master ?
>>>
>>> Thanks,
>>> -Harsha
>>>
>>> On Mon, Jun 1, 2020 at 7:54 PM Eli Britstein <elibr@mellanox.com> wrote:
>>>>
>>>> Acked-by: Eli Britstein <elibr@mellanox.com>
>>>>
>>>> On 5/29/2020 9:33 AM, Sriharsha Basavapatna wrote:
>>>>> Parse VLAN PUSH/POP OVS datapath actions and add respective RTE actions.
>>>>>
>>>>> Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
>>>>> ---
>>>>> v1->v2:
>>>>> * Updated dump_flow_action() to print VLAN Push/Pop actions
>>>>> * Updated NEWS, Documentation/howto/dpdk.rst files
>>>>> ---
>>>>>
>>>>>   Documentation/howto/dpdk.rst |  1 +
>>>>>   NEWS                         |  1 +
>>>>>   lib/netdev-offload-dpdk.c    | 64 ++++++++++++++++++++++++++++++++++++
>>>>>   3 files changed, 66 insertions(+)
>>>>>
>>>>> diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
>>>>> index be950d7ce..c40fcafcb 100644
>>>>> --- a/Documentation/howto/dpdk.rst
>>>>> +++ b/Documentation/howto/dpdk.rst
>>>>> @@ -395,6 +395,7 @@ Supported actions for hardware offload are:
>>>>>   - Modification of Ethernet (mod_dl_src/mod_dl_dst).
>>>>>   - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl).
>>>>>   - Modification of TCP/UDP (mod_tp_src/mod_tp_dst).
>>>>> +- VLAN Push/Pop (push_vlan/pop_vlan).
>>>>>
>>>>>   Further Reading
>>>>>   ---------------
>>>>> diff --git a/NEWS b/NEWS
>>>>> index 3dbd8ec0e..c1311e366 100644
>>>>> --- a/NEWS
>>>>> +++ b/NEWS
>>>>> @@ -9,6 +9,7 @@ Post-v2.13.0
>>>>>      - DPDK:
>>>>>        * Deprecated DPDK pdump packet capture support removed.
>>>>>        * Deprecated DPDK ring ports (dpdkr) are no longer supported.
>>>>> +     * Add hardware offload support for VLAN Push/Pop actions (experimental).
>>>>>      - Linux datapath:
>>>>>        * Support for kernel versions up to 5.5.x.
>>>>>      - AF_XDP:
>>>>> diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
>>>>> index f8c46bbaa..c57586a48 100644
>>>>> --- a/lib/netdev-offload-dpdk.c
>>>>> +++ b/lib/netdev-offload-dpdk.c
>>>>> @@ -420,6 +420,36 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
>>>>>           } else {
>>>>>               ds_put_format(s, "  Set-%s-tcp/udp-port = null\n", dirstr);
>>>>>           }
>>>>> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) {
>>>>> +        const struct rte_flow_action_of_push_vlan *rte_push_vlan =
>>>>> +            actions->conf;
>>>>> +        ds_put_cstr(s, "rte flow push-vlan action:\n");
>>>>> +        if (rte_push_vlan) {
>>>>> +            ds_put_format(s, "  Push-vlan: 0x%"PRIx16"\n",
>>>>> +                          ntohs(rte_push_vlan->ethertype));
>>>>> +        } else {
>>>>> +            ds_put_format(s, "  Push-vlan = null\n");
>>>>> +        }
>>>>> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) {
>>>>> +        struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp = actions->conf;
>>>>> +        ds_put_cstr(s, "rte flow set-vlan-pcp action:\n");
>>>>> +        if (rte_vlan_pcp) {
>>>>> +            ds_put_format(s, "  Set-vlan-pcp: %"PRIu8"\n",
>>>>> +                          rte_vlan_pcp->vlan_pcp);
>>>>> +        } else {
>>>>> +            ds_put_format(s, "  Set-vlan-pcp = null\n");
>>>>> +        }
>>>>> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) {
>>>>> +        struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid = actions->conf;
>>>>> +        ds_put_cstr(s, "rte flow set-vlan-vid action:\n");
>>>>> +        if (rte_vlan_vid) {
>>>>> +            ds_put_format(s, "  Set-vlan-vid: %"PRIu16"\n",
>>>>> +                          ntohs(rte_vlan_vid->vlan_vid));
>>>>> +        } else {
>>>>> +            ds_put_format(s, "  Set-vlan-vid = null\n");
>>>>> +        }
>>>>> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) {
>>>>> +        ds_put_cstr(s, "rte flow pop-vlan action\n");
>>>>>       } else {
>>>>>           ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
>>>>>       }
>>>>> @@ -970,6 +1000,33 @@ parse_set_actions(struct flow_actions *actions,
>>>>>       return 0;
>>>>>   }
>>>>>
>>>>> +static int
>>>>> +parse_vlan_push_action(struct flow_actions *actions,
>>>>> +                       const struct ovs_action_push_vlan *vlan_push)
>>>>> +{
>>>>> +    struct rte_flow_action_of_push_vlan *rte_push_vlan;
>>>>> +    struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp;
>>>>> +    struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid;
>>>>> +
>>>>> +    rte_push_vlan = xzalloc(sizeof *rte_push_vlan);
>>>>> +    rte_push_vlan->ethertype = vlan_push->vlan_tpid;
>>>>> +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
>>>>> +                    rte_push_vlan);
>>>>> +
>>>>> +    rte_vlan_pcp = xzalloc(sizeof *rte_vlan_pcp);
>>>>> +    rte_vlan_pcp->vlan_pcp = vlan_tci_to_pcp(vlan_push->vlan_tci);
>>>>> +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
>>>>> +                    rte_vlan_pcp);
>>>>> +
>>>>> +    rte_vlan_vid = xzalloc(sizeof *rte_vlan_vid);
>>>>> +    rte_vlan_vid->vlan_vid =
>>>>> +        rte_cpu_to_be_16(vlan_tci_to_vid(vlan_push->vlan_tci));
>>>>> +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
>>>>> +                    rte_vlan_vid);
>>>>> +
>>>>> +    return 0;
>>>>> +}
>>>>> +
>>>>>   static int
>>>>>   parse_flow_actions(struct netdev *netdev,
>>>>>                      struct flow_actions *actions,
>>>>> @@ -998,6 +1055,13 @@ parse_flow_actions(struct netdev *netdev,
>>>>>                                     masked)) {
>>>>>                   return -1;
>>>>>               }
>>>>> +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
>>>>> +            const struct ovs_action_push_vlan *vlan = nl_attr_get(nla);
>>>>> +            if (parse_vlan_push_action(actions, vlan)) {
>>>>> +                return -1;
>>>>> +            }
>>>>> +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) {
>>>>> +            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
>>>>>           } else {
>>>>>               VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
>>>>>               return -1;
Sriharsha Basavapatna June 16, 2020, 2:20 a.m. UTC | #6
On Tue, Jun 16, 2020 at 12:19 AM Ilya Maximets <i.maximets@ovn.org> wrote:
>
> On 6/12/20 5:50 AM, Sriharsha Basavapatna wrote:
> > Hi Ilya,
> >
> > Can you please apply this to master ?
>
> Hi.  Sorry for delays.  And thanks for the patches and reviews!
>
> I'm going to look at various offload related patches this week.
> This one is on my list.
>
> Best regards, Ilya Maximets.

Ok, thanks Illya.
-Harsha

>
> >
> > Thanks,
> > -Harsha
> >
> > On Wed, Jun 10, 2020 at 3:29 PM Sriharsha Basavapatna
> > <sriharsha.basavapatna@broadcom.com> wrote:
> >>
> >> Just a gentle reminder on this patch. It has already been ack'd by Eli.
> >> Thanks,
> >> -Harsha
> >>
> >> On Tue, Jun 2, 2020 at 10:16 PM Sriharsha Basavapatna
> >> <sriharsha.basavapatna@broadcom.com> wrote:
> >>>
> >>> If there are no other comments, can this be applied to master ?
> >>>
> >>> Thanks,
> >>> -Harsha
> >>>
> >>> On Mon, Jun 1, 2020 at 7:54 PM Eli Britstein <elibr@mellanox.com> wrote:
> >>>>
> >>>> Acked-by: Eli Britstein <elibr@mellanox.com>
> >>>>
> >>>> On 5/29/2020 9:33 AM, Sriharsha Basavapatna wrote:
> >>>>> Parse VLAN PUSH/POP OVS datapath actions and add respective RTE actions.
> >>>>>
> >>>>> Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> >>>>> ---
> >>>>> v1->v2:
> >>>>> * Updated dump_flow_action() to print VLAN Push/Pop actions
> >>>>> * Updated NEWS, Documentation/howto/dpdk.rst files
> >>>>> ---
> >>>>>
> >>>>>   Documentation/howto/dpdk.rst |  1 +
> >>>>>   NEWS                         |  1 +
> >>>>>   lib/netdev-offload-dpdk.c    | 64 ++++++++++++++++++++++++++++++++++++
> >>>>>   3 files changed, 66 insertions(+)
> >>>>>
> >>>>> diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
> >>>>> index be950d7ce..c40fcafcb 100644
> >>>>> --- a/Documentation/howto/dpdk.rst
> >>>>> +++ b/Documentation/howto/dpdk.rst
> >>>>> @@ -395,6 +395,7 @@ Supported actions for hardware offload are:
> >>>>>   - Modification of Ethernet (mod_dl_src/mod_dl_dst).
> >>>>>   - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl).
> >>>>>   - Modification of TCP/UDP (mod_tp_src/mod_tp_dst).
> >>>>> +- VLAN Push/Pop (push_vlan/pop_vlan).
> >>>>>
> >>>>>   Further Reading
> >>>>>   ---------------
> >>>>> diff --git a/NEWS b/NEWS
> >>>>> index 3dbd8ec0e..c1311e366 100644
> >>>>> --- a/NEWS
> >>>>> +++ b/NEWS
> >>>>> @@ -9,6 +9,7 @@ Post-v2.13.0
> >>>>>      - DPDK:
> >>>>>        * Deprecated DPDK pdump packet capture support removed.
> >>>>>        * Deprecated DPDK ring ports (dpdkr) are no longer supported.
> >>>>> +     * Add hardware offload support for VLAN Push/Pop actions (experimental).
> >>>>>      - Linux datapath:
> >>>>>        * Support for kernel versions up to 5.5.x.
> >>>>>      - AF_XDP:
> >>>>> diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
> >>>>> index f8c46bbaa..c57586a48 100644
> >>>>> --- a/lib/netdev-offload-dpdk.c
> >>>>> +++ b/lib/netdev-offload-dpdk.c
> >>>>> @@ -420,6 +420,36 @@ dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
> >>>>>           } else {
> >>>>>               ds_put_format(s, "  Set-%s-tcp/udp-port = null\n", dirstr);
> >>>>>           }
> >>>>> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) {
> >>>>> +        const struct rte_flow_action_of_push_vlan *rte_push_vlan =
> >>>>> +            actions->conf;
> >>>>> +        ds_put_cstr(s, "rte flow push-vlan action:\n");
> >>>>> +        if (rte_push_vlan) {
> >>>>> +            ds_put_format(s, "  Push-vlan: 0x%"PRIx16"\n",
> >>>>> +                          ntohs(rte_push_vlan->ethertype));
> >>>>> +        } else {
> >>>>> +            ds_put_format(s, "  Push-vlan = null\n");
> >>>>> +        }
> >>>>> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) {
> >>>>> +        struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp = actions->conf;
> >>>>> +        ds_put_cstr(s, "rte flow set-vlan-pcp action:\n");
> >>>>> +        if (rte_vlan_pcp) {
> >>>>> +            ds_put_format(s, "  Set-vlan-pcp: %"PRIu8"\n",
> >>>>> +                          rte_vlan_pcp->vlan_pcp);
> >>>>> +        } else {
> >>>>> +            ds_put_format(s, "  Set-vlan-pcp = null\n");
> >>>>> +        }
> >>>>> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) {
> >>>>> +        struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid = actions->conf;
> >>>>> +        ds_put_cstr(s, "rte flow set-vlan-vid action:\n");
> >>>>> +        if (rte_vlan_vid) {
> >>>>> +            ds_put_format(s, "  Set-vlan-vid: %"PRIu16"\n",
> >>>>> +                          ntohs(rte_vlan_vid->vlan_vid));
> >>>>> +        } else {
> >>>>> +            ds_put_format(s, "  Set-vlan-vid = null\n");
> >>>>> +        }
> >>>>> +    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) {
> >>>>> +        ds_put_cstr(s, "rte flow pop-vlan action\n");
> >>>>>       } else {
> >>>>>           ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
> >>>>>       }
> >>>>> @@ -970,6 +1000,33 @@ parse_set_actions(struct flow_actions *actions,
> >>>>>       return 0;
> >>>>>   }
> >>>>>
> >>>>> +static int
> >>>>> +parse_vlan_push_action(struct flow_actions *actions,
> >>>>> +                       const struct ovs_action_push_vlan *vlan_push)
> >>>>> +{
> >>>>> +    struct rte_flow_action_of_push_vlan *rte_push_vlan;
> >>>>> +    struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp;
> >>>>> +    struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid;
> >>>>> +
> >>>>> +    rte_push_vlan = xzalloc(sizeof *rte_push_vlan);
> >>>>> +    rte_push_vlan->ethertype = vlan_push->vlan_tpid;
> >>>>> +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
> >>>>> +                    rte_push_vlan);
> >>>>> +
> >>>>> +    rte_vlan_pcp = xzalloc(sizeof *rte_vlan_pcp);
> >>>>> +    rte_vlan_pcp->vlan_pcp = vlan_tci_to_pcp(vlan_push->vlan_tci);
> >>>>> +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
> >>>>> +                    rte_vlan_pcp);
> >>>>> +
> >>>>> +    rte_vlan_vid = xzalloc(sizeof *rte_vlan_vid);
> >>>>> +    rte_vlan_vid->vlan_vid =
> >>>>> +        rte_cpu_to_be_16(vlan_tci_to_vid(vlan_push->vlan_tci));
> >>>>> +    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
> >>>>> +                    rte_vlan_vid);
> >>>>> +
> >>>>> +    return 0;
> >>>>> +}
> >>>>> +
> >>>>>   static int
> >>>>>   parse_flow_actions(struct netdev *netdev,
> >>>>>                      struct flow_actions *actions,
> >>>>> @@ -998,6 +1055,13 @@ parse_flow_actions(struct netdev *netdev,
> >>>>>                                     masked)) {
> >>>>>                   return -1;
> >>>>>               }
> >>>>> +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
> >>>>> +            const struct ovs_action_push_vlan *vlan = nl_attr_get(nla);
> >>>>> +            if (parse_vlan_push_action(actions, vlan)) {
> >>>>> +                return -1;
> >>>>> +            }
> >>>>> +        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) {
> >>>>> +            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
> >>>>>           } else {
> >>>>>               VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
> >>>>>               return -1;
>
Ilya Maximets June 22, 2020, 11:58 a.m. UTC | #7
On 5/29/20 8:33 AM, Sriharsha Basavapatna via dev wrote:
> Parse VLAN PUSH/POP OVS datapath actions and add respective RTE actions.
> 
> Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> 
> ---
> v1->v2:
> * Updated dump_flow_action() to print VLAN Push/Pop actions
> * Updated NEWS, Documentation/howto/dpdk.rst files
> ---
> 

Thanks!

I had to fix missed 'const' qualifiers flagged by sparse:

lib/netdev-offload-dpdk.c:434:71: error: incorrect type in initializer (different modifiers)
lib/netdev-offload-dpdk.c:434:71:    expected struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp
lib/netdev-offload-dpdk.c:434:71:    got void const *const conf
lib/netdev-offload-dpdk.c:443:71: error: incorrect type in initializer (different modifiers)
lib/netdev-offload-dpdk.c:443:71:    expected struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid
lib/netdev-offload-dpdk.c:443:71:    got void const *const conf

With this and a couple of minor style fixes applied to master.

Best regards, Ilya Maximets.
Sriharsha Basavapatna June 22, 2020, 12:40 p.m. UTC | #8
On Mon, Jun 22, 2020 at 5:28 PM Ilya Maximets <i.maximets@ovn.org> wrote:
>
> On 5/29/20 8:33 AM, Sriharsha Basavapatna via dev wrote:
> > Parse VLAN PUSH/POP OVS datapath actions and add respective RTE actions.
> >
> > Signed-off-by: Sriharsha Basavapatna <sriharsha.basavapatna@broadcom.com>
> >
> > ---
> > v1->v2:
> > * Updated dump_flow_action() to print VLAN Push/Pop actions
> > * Updated NEWS, Documentation/howto/dpdk.rst files
> > ---
> >
>
> Thanks!
>
> I had to fix missed 'const' qualifiers flagged by sparse:
>
> lib/netdev-offload-dpdk.c:434:71: error: incorrect type in initializer (different modifiers)
> lib/netdev-offload-dpdk.c:434:71:    expected struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp
> lib/netdev-offload-dpdk.c:434:71:    got void const *const conf
> lib/netdev-offload-dpdk.c:443:71: error: incorrect type in initializer (different modifiers)
> lib/netdev-offload-dpdk.c:443:71:    expected struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid
> lib/netdev-offload-dpdk.c:443:71:    got void const *const conf
>
> With this and a couple of minor style fixes applied to master.
>
> Best regards, Ilya Maximets.

Thanks Ilya.
-Harsha
diff mbox series

Patch

diff --git a/Documentation/howto/dpdk.rst b/Documentation/howto/dpdk.rst
index be950d7ce..c40fcafcb 100644
--- a/Documentation/howto/dpdk.rst
+++ b/Documentation/howto/dpdk.rst
@@ -395,6 +395,7 @@  Supported actions for hardware offload are:
 - Modification of Ethernet (mod_dl_src/mod_dl_dst).
 - Modification of IPv4 (mod_nw_src/mod_nw_dst/mod_nw_ttl).
 - Modification of TCP/UDP (mod_tp_src/mod_tp_dst).
+- VLAN Push/Pop (push_vlan/pop_vlan).
 
 Further Reading
 ---------------
diff --git a/NEWS b/NEWS
index 3dbd8ec0e..c1311e366 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@  Post-v2.13.0
    - DPDK:
      * Deprecated DPDK pdump packet capture support removed.
      * Deprecated DPDK ring ports (dpdkr) are no longer supported.
+     * Add hardware offload support for VLAN Push/Pop actions (experimental).
    - Linux datapath:
      * Support for kernel versions up to 5.5.x.
    - AF_XDP:
diff --git a/lib/netdev-offload-dpdk.c b/lib/netdev-offload-dpdk.c
index f8c46bbaa..c57586a48 100644
--- a/lib/netdev-offload-dpdk.c
+++ b/lib/netdev-offload-dpdk.c
@@ -420,6 +420,36 @@  dump_flow_action(struct ds *s, const struct rte_flow_action *actions)
         } else {
             ds_put_format(s, "  Set-%s-tcp/udp-port = null\n", dirstr);
         }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN) {
+        const struct rte_flow_action_of_push_vlan *rte_push_vlan =
+            actions->conf;
+        ds_put_cstr(s, "rte flow push-vlan action:\n");
+        if (rte_push_vlan) {
+            ds_put_format(s, "  Push-vlan: 0x%"PRIx16"\n",
+                          ntohs(rte_push_vlan->ethertype));
+        } else {
+            ds_put_format(s, "  Push-vlan = null\n");
+        }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP) {
+        struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp = actions->conf;
+        ds_put_cstr(s, "rte flow set-vlan-pcp action:\n");
+        if (rte_vlan_pcp) {
+            ds_put_format(s, "  Set-vlan-pcp: %"PRIu8"\n",
+                          rte_vlan_pcp->vlan_pcp);
+        } else {
+            ds_put_format(s, "  Set-vlan-pcp = null\n");
+        }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID) {
+        struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid = actions->conf;
+        ds_put_cstr(s, "rte flow set-vlan-vid action:\n");
+        if (rte_vlan_vid) {
+            ds_put_format(s, "  Set-vlan-vid: %"PRIu16"\n",
+                          ntohs(rte_vlan_vid->vlan_vid));
+        } else {
+            ds_put_format(s, "  Set-vlan-vid = null\n");
+        }
+    } else if (actions->type == RTE_FLOW_ACTION_TYPE_OF_POP_VLAN) {
+        ds_put_cstr(s, "rte flow pop-vlan action\n");
     } else {
         ds_put_format(s, "unknown rte flow action (%d)\n", actions->type);
     }
@@ -970,6 +1000,33 @@  parse_set_actions(struct flow_actions *actions,
     return 0;
 }
 
+static int
+parse_vlan_push_action(struct flow_actions *actions,
+                       const struct ovs_action_push_vlan *vlan_push)
+{
+    struct rte_flow_action_of_push_vlan *rte_push_vlan;
+    struct rte_flow_action_of_set_vlan_pcp *rte_vlan_pcp;
+    struct rte_flow_action_of_set_vlan_vid *rte_vlan_vid;
+
+    rte_push_vlan = xzalloc(sizeof *rte_push_vlan);
+    rte_push_vlan->ethertype = vlan_push->vlan_tpid;
+    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN,
+                    rte_push_vlan);
+
+    rte_vlan_pcp = xzalloc(sizeof *rte_vlan_pcp);
+    rte_vlan_pcp->vlan_pcp = vlan_tci_to_pcp(vlan_push->vlan_tci);
+    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_PCP,
+                    rte_vlan_pcp);
+
+    rte_vlan_vid = xzalloc(sizeof *rte_vlan_vid);
+    rte_vlan_vid->vlan_vid =
+        rte_cpu_to_be_16(vlan_tci_to_vid(vlan_push->vlan_tci));
+    add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID,
+                    rte_vlan_vid);
+
+    return 0;
+}
+
 static int
 parse_flow_actions(struct netdev *netdev,
                    struct flow_actions *actions,
@@ -998,6 +1055,13 @@  parse_flow_actions(struct netdev *netdev,
                                   masked)) {
                 return -1;
             }
+        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_PUSH_VLAN) {
+            const struct ovs_action_push_vlan *vlan = nl_attr_get(nla);
+            if (parse_vlan_push_action(actions, vlan)) {
+                return -1;
+            }
+        } else if (nl_attr_type(nla) == OVS_ACTION_ATTR_POP_VLAN) {
+            add_flow_action(actions, RTE_FLOW_ACTION_TYPE_OF_POP_VLAN, NULL);
         } else {
             VLOG_DBG_RL(&rl, "Unsupported action type %d", nl_attr_type(nla));
             return -1;