* [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action @ 2019-12-10 5:23 Suanming Mou 2019-12-10 7:33 ` Andrew Rybchenko ` (2 more replies) 0 siblings, 3 replies; 11+ messages in thread From: Suanming Mou @ 2019-12-10 5:23 UTC (permalink / raw) To: Adrien Mazarguil, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko Cc: dev, shahafs, orika, matan, viacheslavo For some overlay network, such as VXLAN, the DSCP field in the new outer IP header after VXLAN decapsulation may need to be updated accordingly. This commit introduce the DSCP modify action for IPv4 and IPv6. Signed-off-by: Suanming Mou <suanmingm@mellanox.com> --- doc/guides/prog_guide/rte_flow.rst | 40 ++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_flow.h | 31 +++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a254c81..54b9250 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2558,6 +2558,46 @@ the other path depending on HW capability. | ``mask`` | bit-mask applies to "data" | +----------+----------------------------+ +Action: ``SET_IPV4_DSCP`` +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Set IPv4DSCP. + +Modify DSCP in IPv4 header. + +It must be used with RTE_FLOW_ITEM_TYPE_IPV4 in pattern. +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. + +.. _table_rte_flow_action_set_ipv4_dscp: + +.. table:: SET_IPV4_DSCP + + +-----------+---------------------------------+ + | Field | Value | + +===========+=================================+ + | ``dscp`` | DSCP in low 6 bits, rest ingore | + +-----------+---------------------------------+ + +Action: ``SET_IPV6_DSCP`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Set IPv6DSCP. + +Modify DSCP in IPv6 header. + +It must be used with RTE_FLOW_ITEM_TYPE_IPV6 in pattern. +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. + +.. _table_rte_flow_action_set_ipv6_dscp: + +.. table:: SET_IPV6_DSCP + + +-----------+---------------------------------+ + | Field | Value | + +===========+=================================+ + | ``dscp`` | DSCP in low 6 bits, rest ingore | + +-----------+---------------------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 452d359..76bf080 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -2004,6 +2004,26 @@ enum rte_flow_action_type { * See struct rte_flow_action_set_meta. */ RTE_FLOW_ACTION_TYPE_SET_META, + + /** + * Modify IPv4 DSCP in the outermost IP header. + * + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. + * + * See struct rte_flow_action_set_dscp. + */ + RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP, + + /** + * Modify IPv6 DSCP in the outermost IP header. + * + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. + * + * See struct rte_flow_action_set_dscp. + */ + RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP, }; /** @@ -2530,6 +2550,17 @@ struct rte_flow_action_set_meta { uint32_t mask; }; +/** + * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP + * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP + * + * Set the DSCP value for IPv4/IPv6 header. + * DSCP in low 6 bits, rest ignored. + */ +struct rte_flow_action_set_dscp { + uint8_t dscp; +}; + /* Mbuf dynamic field offset for metadata. */ extern int rte_flow_dynf_metadata_offs; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action 2019-12-10 5:23 [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action Suanming Mou @ 2019-12-10 7:33 ` Andrew Rybchenko 2019-12-10 8:55 ` Suanming Mou 2019-12-10 18:31 ` Stephen Hemminger 2019-12-10 9:27 ` [dpdk-dev] [RFC v2] " Suanming Mou 2019-12-16 3:42 ` [dpdk-dev] [RFC v3 1/2] " Suanming Mou 2 siblings, 2 replies; 11+ messages in thread From: Andrew Rybchenko @ 2019-12-10 7:33 UTC (permalink / raw) To: Suanming Mou, Adrien Mazarguil, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit Cc: dev, shahafs, orika, matan, viacheslavo On 12/10/19 8:23 AM, Suanming Mou wrote: > For some overlay network, such as VXLAN, the DSCP field in the new outer > IP header after VXLAN decapsulation may need to be updated accordingly. > > This commit introduce the DSCP modify action for IPv4 and IPv6. > > Signed-off-by: Suanming Mou <suanmingm@mellanox.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> as usual it requires testpmd support and a driver which supports it (I understand that it may be omitted in RFC). Few minor notes below. > --- > doc/guides/prog_guide/rte_flow.rst | 40 ++++++++++++++++++++++++++++++++++++++ > lib/librte_ethdev/rte_flow.h | 31 +++++++++++++++++++++++++++++ > 2 files changed, 71 insertions(+) > > diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst > index a254c81..54b9250 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -2558,6 +2558,46 @@ the other path depending on HW capability. > | ``mask`` | bit-mask applies to "data" | > +----------+----------------------------+ > > +Action: ``SET_IPV4_DSCP`` > +^^^^^^^^^^^^^^^^^^^^^^^^^ > + > +Set IPv4DSCP. I think it is better to have space between IPv4 and DSCP above. > + > +Modify DSCP in IPv4 header. > + > +It must be used with RTE_FLOW_ITEM_TYPE_IPV4 in pattern. > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. > + > +.. _table_rte_flow_action_set_ipv4_dscp: > + > +.. table:: SET_IPV4_DSCP > + > + +-----------+---------------------------------+ > + | Field | Value | > + +===========+=================================+ > + | ``dscp`` | DSCP in low 6 bits, rest ingore | ingore -> ignore > + +-----------+---------------------------------+ > + > +Action: ``SET_IPV6_DSCP`` > +^^^^^^^^^^^^^^^^^^^^^^^^ > + > +Set IPv6DSCP. Same. > + > +Modify DSCP in IPv6 header. > + > +It must be used with RTE_FLOW_ITEM_TYPE_IPV6 in pattern. > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. > + > +.. _table_rte_flow_action_set_ipv6_dscp: > + > +.. table:: SET_IPV6_DSCP > + > + +-----------+---------------------------------+ > + | Field | Value | > + +===========+=================================+ > + | ``dscp`` | DSCP in low 6 bits, rest ingore | ingore -> ignore > + +-----------+---------------------------------+ > + > Negative types > ~~~~~~~~~~~~~~ > > diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h > index 452d359..76bf080 100644 > --- a/lib/librte_ethdev/rte_flow.h > +++ b/lib/librte_ethdev/rte_flow.h > @@ -2004,6 +2004,26 @@ enum rte_flow_action_type { > * See struct rte_flow_action_set_meta. > */ > RTE_FLOW_ACTION_TYPE_SET_META, > + > + /** > + * Modify IPv4 DSCP in the outermost IP header. > + * > + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, > + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. > + * > + * See struct rte_flow_action_set_dscp. > + */ > + RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP, > + > + /** > + * Modify IPv6 DSCP in the outermost IP header. > + * > + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, > + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. > + * > + * See struct rte_flow_action_set_dscp. > + */ > + RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP, > }; > > /** > @@ -2530,6 +2550,17 @@ struct rte_flow_action_set_meta { > uint32_t mask; > }; > > +/** > + * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP > + * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP > + * > + * Set the DSCP value for IPv4/IPv6 header. > + * DSCP in low 6 bits, rest ignored. > + */ > +struct rte_flow_action_set_dscp { > + uint8_t dscp; > +}; > + > /* Mbuf dynamic field offset for metadata. */ > extern int rte_flow_dynf_metadata_offs; > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action 2019-12-10 7:33 ` Andrew Rybchenko @ 2019-12-10 8:55 ` Suanming Mou 2019-12-10 18:32 ` Stephen Hemminger 2019-12-10 18:31 ` Stephen Hemminger 1 sibling, 1 reply; 11+ messages in thread From: Suanming Mou @ 2019-12-10 8:55 UTC (permalink / raw) To: Andrew Rybchenko, Adrien Mazarguil, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit Cc: dev, Shahaf Shuler, Ori Kam, Matan Azrad, Slava Ovsiienko > -----Original Message----- > From: Andrew Rybchenko <arybchenko@solarflare.com> > Sent: Tuesday, December 10, 2019 3:33 PM > To: Suanming Mou <suanmingm@mellanox.com>; Adrien Mazarguil > <adrien.mazarguil@6wind.com>; John McNamara <john.mcnamara@intel.com>; > Marko Kovacevic <marko.kovacevic@intel.com>; Thomas Monjalon > <thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@intel.com> > Cc: dev@dpdk.org; Shahaf Shuler <shahafs@mellanox.com>; Ori Kam > <orika@mellanox.com>; Matan Azrad <matan@mellanox.com>; Slava Ovsiienko > <viacheslavo@mellanox.com> > Subject: Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action > > On 12/10/19 8:23 AM, Suanming Mou wrote: > > For some overlay network, such as VXLAN, the DSCP field in the new > > outer IP header after VXLAN decapsulation may need to be updated > accordingly. > > > > This commit introduce the DSCP modify action for IPv4 and IPv6. > > > > Signed-off-by: Suanming Mou <suanmingm@mellanox.com> > > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > > as usual it requires testpmd support and a driver which supports it (I understand > that it may be omitted in RFC). Thanks. Yes, it will be added later. > > Few minor notes below. Will update the second version fix these. > > > --- > > doc/guides/prog_guide/rte_flow.rst | 40 > ++++++++++++++++++++++++++++++++++++++ > > lib/librte_ethdev/rte_flow.h | 31 +++++++++++++++++++++++++++++ > > 2 files changed, 71 insertions(+) > > > > diff --git a/doc/guides/prog_guide/rte_flow.rst > > b/doc/guides/prog_guide/rte_flow.rst > > index a254c81..54b9250 100644 > > --- a/doc/guides/prog_guide/rte_flow.rst > > +++ b/doc/guides/prog_guide/rte_flow.rst > > @@ -2558,6 +2558,46 @@ the other path depending on HW capability. > > | ``mask`` | bit-mask applies to "data" | > > +----------+----------------------------+ > > > > +Action: ``SET_IPV4_DSCP`` > > +^^^^^^^^^^^^^^^^^^^^^^^^^ > > + > > +Set IPv4DSCP. > > I think it is better to have space between IPv4 and DSCP above. > > > + > > +Modify DSCP in IPv4 header. > > + > > +It must be used with RTE_FLOW_ITEM_TYPE_IPV4 in pattern. > > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. > > + > > +.. _table_rte_flow_action_set_ipv4_dscp: > > + > > +.. table:: SET_IPV4_DSCP > > + > > + +-----------+---------------------------------+ > > + | Field | Value | > > + +===========+=================================+ > > + | ``dscp`` | DSCP in low 6 bits, rest ingore | > > ingore -> ignore > > > + +-----------+---------------------------------+ > > + > > +Action: ``SET_IPV6_DSCP`` > > +^^^^^^^^^^^^^^^^^^^^^^^^ > > + > > +Set IPv6DSCP. > > Same. > > > + > > +Modify DSCP in IPv6 header. > > + > > +It must be used with RTE_FLOW_ITEM_TYPE_IPV6 in pattern. > > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. > > + > > +.. _table_rte_flow_action_set_ipv6_dscp: > > + > > +.. table:: SET_IPV6_DSCP > > + > > + +-----------+---------------------------------+ > > + | Field | Value | > > + +===========+=================================+ > > + | ``dscp`` | DSCP in low 6 bits, rest ingore | > > ingore -> ignore > > > + +-----------+---------------------------------+ > > + > > Negative types > > ~~~~~~~~~~~~~~ > > > > diff --git a/lib/librte_ethdev/rte_flow.h > > b/lib/librte_ethdev/rte_flow.h index 452d359..76bf080 100644 > > --- a/lib/librte_ethdev/rte_flow.h > > +++ b/lib/librte_ethdev/rte_flow.h > > @@ -2004,6 +2004,26 @@ enum rte_flow_action_type { > > * See struct rte_flow_action_set_meta. > > */ > > RTE_FLOW_ACTION_TYPE_SET_META, > > + > > + /** > > + * Modify IPv4 DSCP in the outermost IP header. > > + * > > + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, > > + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION > error. > > + * > > + * See struct rte_flow_action_set_dscp. > > + */ > > + RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP, > > + > > + /** > > + * Modify IPv6 DSCP in the outermost IP header. > > + * > > + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, > > + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION > error. > > + * > > + * See struct rte_flow_action_set_dscp. > > + */ > > + RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP, > > }; > > > > /** > > @@ -2530,6 +2550,17 @@ struct rte_flow_action_set_meta { > > uint32_t mask; > > }; > > > > +/** > > + * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP > > + * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP > > + * > > + * Set the DSCP value for IPv4/IPv6 header. > > + * DSCP in low 6 bits, rest ignored. > > + */ > > +struct rte_flow_action_set_dscp { > > + uint8_t dscp; > > +}; > > + > > /* Mbuf dynamic field offset for metadata. */ extern int > > rte_flow_dynf_metadata_offs; > > > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action 2019-12-10 8:55 ` Suanming Mou @ 2019-12-10 18:32 ` Stephen Hemminger 0 siblings, 0 replies; 11+ messages in thread From: Stephen Hemminger @ 2019-12-10 18:32 UTC (permalink / raw) To: Suanming Mou Cc: Andrew Rybchenko, Adrien Mazarguil, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit, dev, Shahaf Shuler, Ori Kam, Matan Azrad, Slava Ovsiienko On Tue, 10 Dec 2019 08:55:40 +0000 Suanming Mou <suanmingm@mellanox.com> wrote: > > -----Original Message----- > > From: Andrew Rybchenko <arybchenko@solarflare.com> > > Sent: Tuesday, December 10, 2019 3:33 PM > > To: Suanming Mou <suanmingm@mellanox.com>; Adrien Mazarguil > > <adrien.mazarguil@6wind.com>; John McNamara <john.mcnamara@intel.com>; > > Marko Kovacevic <marko.kovacevic@intel.com>; Thomas Monjalon > > <thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@intel.com> > > Cc: dev@dpdk.org; Shahaf Shuler <shahafs@mellanox.com>; Ori Kam > > <orika@mellanox.com>; Matan Azrad <matan@mellanox.com>; Slava Ovsiienko > > <viacheslavo@mellanox.com> > > Subject: Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action > > > > On 12/10/19 8:23 AM, Suanming Mou wrote: > > > For some overlay network, such as VXLAN, the DSCP field in the new > > > outer IP header after VXLAN decapsulation may need to be updated > > accordingly. > > > > > > This commit introduce the DSCP modify action for IPv4 and IPv6. > > > > > > Signed-off-by: Suanming Mou <suanmingm@mellanox.com> > > > > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > > > > as usual it requires testpmd support and a driver which supports it (I understand > > that it may be omitted in RFC). > > Thanks. Yes, it will be added later. Then this patch must not be applied until one or more drivers is ready to use it. Very easy to get API and semantics wrong, until it is there. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action 2019-12-10 7:33 ` Andrew Rybchenko 2019-12-10 8:55 ` Suanming Mou @ 2019-12-10 18:31 ` Stephen Hemminger 2019-12-10 19:48 ` Ori Kam 2019-12-11 1:36 ` Suanming Mou 1 sibling, 2 replies; 11+ messages in thread From: Stephen Hemminger @ 2019-12-10 18:31 UTC (permalink / raw) To: Andrew Rybchenko Cc: Suanming Mou, Adrien Mazarguil, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit, dev, shahafs, orika, matan, viacheslavo On Tue, 10 Dec 2019 10:33:28 +0300 Andrew Rybchenko <arybchenko@solarflare.com> wrote: > > For some overlay network, such as VXLAN, the DSCP field in the new outer > > IP header after VXLAN decapsulation may need to be updated accordingly. > > > > This commit introduce the DSCP modify action for IPv4 and IPv6. > > > > Signed-off-by: Suanming Mou <suanmingm@mellanox.com> > > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > > as usual it requires testpmd support and a driver which > supports it (I understand that it may be omitted in RFC). And it requires documentation and a software implementation in the flow classifier. Plus you conveniently exclude defining what happens to reserved bits. "What ever our hardware does is correct" is not a useful answer. You need to be precise and limited in what is allowed to make this usable. Sorry, to be so negative. This feature is fine in itself and a useful incremental improvement. But nobody has stepped up to address the usability of rte_flow. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action 2019-12-10 18:31 ` Stephen Hemminger @ 2019-12-10 19:48 ` Ori Kam 2019-12-11 1:36 ` Suanming Mou 1 sibling, 0 replies; 11+ messages in thread From: Ori Kam @ 2019-12-10 19:48 UTC (permalink / raw) To: Stephen Hemminger, Andrew Rybchenko Cc: Suanming Mou, Adrien Mazarguil, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit, dev, Shahaf Shuler, Matan Azrad, Slava Ovsiienko Hi Stephen, > -----Original Message----- > From: Stephen Hemminger <stephen@networkplumber.org> > Sent: Tuesday, December 10, 2019 8:32 PM > To: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Suanming Mou <suanmingm@mellanox.com>; Adrien Mazarguil > <adrien.mazarguil@6wind.com>; John McNamara > <john.mcnamara@intel.com>; Marko Kovacevic > <marko.kovacevic@intel.com>; Thomas Monjalon <thomas@monjalon.net>; > Ferruh Yigit <ferruh.yigit@intel.com>; dev@dpdk.org; Shahaf Shuler > <shahafs@mellanox.com>; Ori Kam <orika@mellanox.com>; Matan Azrad > <matan@mellanox.com>; Slava Ovsiienko <viacheslavo@mellanox.com> > Subject: Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action > > On Tue, 10 Dec 2019 10:33:28 +0300 > Andrew Rybchenko <arybchenko@solarflare.com> wrote: > > > > For some overlay network, such as VXLAN, the DSCP field in the new > outer > > > IP header after VXLAN decapsulation may need to be updated > accordingly. > > > > > > This commit introduce the DSCP modify action for IPv4 and IPv6. > > > > > > Signed-off-by: Suanming Mou <suanmingm@mellanox.com> > > > > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > > > > as usual it requires testpmd support and a driver which > > supports it (I understand that it may be omitted in RFC). > > And it requires documentation and a software implementation in the flow > classifier. > Why in the flow classifier? I don't remember any new code that was added to rte_flow was also added to flow classifier. > > Plus you conveniently exclude defining what happens to reserved bits. > "What ever our hardware does is correct" is not a useful answer. > You need to be precise and limited in what is allowed to make this usable. > The action does just what it says nothing more and nothing less. It just modify the DSCP value with a value given by the application. Reserved bits are not touched. > Sorry, to be so negative. This feature is fine in itself and a useful > incremental improvement. But nobody has stepped up to address the > usability > of rte_flow. I'm sorry but I don't understand your comment, According to my knowledge more and more applications are using rte_flow, and each new feature that is added is based on some customer need. Thanks, Ori ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action 2019-12-10 18:31 ` Stephen Hemminger 2019-12-10 19:48 ` Ori Kam @ 2019-12-11 1:36 ` Suanming Mou 1 sibling, 0 replies; 11+ messages in thread From: Suanming Mou @ 2019-12-11 1:36 UTC (permalink / raw) To: Stephen Hemminger, Andrew Rybchenko Cc: Adrien Mazarguil, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit, dev, Shahaf Shuler, Ori Kam, Matan Azrad, Slava Ovsiienko > -----Original Message----- > From: Stephen Hemminger <stephen@networkplumber.org> > Sent: Wednesday, December 11, 2019 2:32 AM > To: Andrew Rybchenko <arybchenko@solarflare.com> > Cc: Suanming Mou <suanmingm@mellanox.com>; Adrien Mazarguil > <adrien.mazarguil@6wind.com>; John McNamara <john.mcnamara@intel.com>; > Marko Kovacevic <marko.kovacevic@intel.com>; Thomas Monjalon > <thomas@monjalon.net>; Ferruh Yigit <ferruh.yigit@intel.com>; dev@dpdk.org; > Shahaf Shuler <shahafs@mellanox.com>; Ori Kam <orika@mellanox.com>; > Matan Azrad <matan@mellanox.com>; Slava Ovsiienko > <viacheslavo@mellanox.com> > Subject: Re: [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action > > On Tue, 10 Dec 2019 10:33:28 +0300 > Andrew Rybchenko <arybchenko@solarflare.com> wrote: > > > > For some overlay network, such as VXLAN, the DSCP field in the new > > > outer IP header after VXLAN decapsulation may need to be updated > accordingly. > > > > > > This commit introduce the DSCP modify action for IPv4 and IPv6. > > > > > > Signed-off-by: Suanming Mou <suanmingm@mellanox.com> > > > > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > > > > as usual it requires testpmd support and a driver which supports it (I > > understand that it may be omitted in RFC). > > And it requires documentation and a software implementation in the flow > classifier. Could you please give the previous example code which add to both of them? > > > Plus you conveniently exclude defining what happens to reserved bits. > "What ever our hardware does is correct" is not a useful answer. > You need to be precise and limited in what is allowed to make this usable. Sorry, I feel a little confused. The DSCP only use 6 bits both in IPv4 and IPv6 header. The data struct is defined by the IP protocol, it is not defined by the hardware. And the rest bits will be ignored as only 6 bits in the header. It is also added in the code comments. The action is to apply the 6 bits DSCP value to the 6 bits DSCP field in IPv4 or IPv6 header. Could you please point out the not precise part much more detail? Thank you for the comments. Will try to make it better. > > Sorry, to be so negative. This feature is fine in itself and a useful incremental > improvement. But nobody has stepped up to address the usability of rte_flow. It's hard to say, it's just like some people like meat and some like vegetables. ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [RFC v2] ethdev: add IPv4/IPv6 DSCP rewrite action 2019-12-10 5:23 [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action Suanming Mou 2019-12-10 7:33 ` Andrew Rybchenko @ 2019-12-10 9:27 ` Suanming Mou 2019-12-16 3:42 ` [dpdk-dev] [RFC v3 1/2] " Suanming Mou 2 siblings, 0 replies; 11+ messages in thread From: Suanming Mou @ 2019-12-10 9:27 UTC (permalink / raw) To: Adrien Mazarguil, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko Cc: dev, shahafs, orika, matan, viacheslavo For some overlay network, such as VXLAN, the DSCP field in the new outer IP header after VXLAN decapsulation may need to be updated accordingly. This commit introduce the DSCP modify action for IPv4 and IPv6. Signed-off-by: Suanming Mou <suanmingm@mellanox.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- v2: * Add space to IPv4/6 DSCP. * Fix typo. --- doc/guides/prog_guide/rte_flow.rst | 40 ++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_flow.h | 31 +++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a254c81..c0b6a15 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2558,6 +2558,46 @@ the other path depending on HW capability. | ``mask`` | bit-mask applies to "data" | +----------+----------------------------+ +Action: ``SET_IPV4_DSCP`` +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Set IPv4 DSCP. + +Modify DSCP in IPv4 header. + +It must be used with RTE_FLOW_ITEM_TYPE_IPV4 in pattern. +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. + +.. _table_rte_flow_action_set_ipv4_dscp: + +.. table:: SET_IPV4_DSCP + + +-----------+---------------------------------+ + | Field | Value | + +===========+=================================+ + | ``dscp`` | DSCP in low 6 bits, rest ignore | + +-----------+---------------------------------+ + +Action: ``SET_IPV6_DSCP`` +^^^^^^^^^^^^^^^^^^^^^^^^ + +Set IPv6 DSCP. + +Modify DSCP in IPv6 header. + +It must be used with RTE_FLOW_ITEM_TYPE_IPV6 in pattern. +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. + +.. _table_rte_flow_action_set_ipv6_dscp: + +.. table:: SET_IPV6_DSCP + + +-----------+---------------------------------+ + | Field | Value | + +===========+=================================+ + | ``dscp`` | DSCP in low 6 bits, rest ignore | + +-----------+---------------------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 452d359..76bf080 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -2004,6 +2004,26 @@ enum rte_flow_action_type { * See struct rte_flow_action_set_meta. */ RTE_FLOW_ACTION_TYPE_SET_META, + + /** + * Modify IPv4 DSCP in the outermost IP header. + * + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. + * + * See struct rte_flow_action_set_dscp. + */ + RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP, + + /** + * Modify IPv6 DSCP in the outermost IP header. + * + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. + * + * See struct rte_flow_action_set_dscp. + */ + RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP, }; /** @@ -2530,6 +2550,17 @@ struct rte_flow_action_set_meta { uint32_t mask; }; +/** + * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP + * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP + * + * Set the DSCP value for IPv4/IPv6 header. + * DSCP in low 6 bits, rest ignored. + */ +struct rte_flow_action_set_dscp { + uint8_t dscp; +}; + /* Mbuf dynamic field offset for metadata. */ extern int rte_flow_dynf_metadata_offs; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [RFC v3 1/2] ethdev: add IPv4/IPv6 DSCP rewrite action 2019-12-10 5:23 [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action Suanming Mou 2019-12-10 7:33 ` Andrew Rybchenko 2019-12-10 9:27 ` [dpdk-dev] [RFC v2] " Suanming Mou @ 2019-12-16 3:42 ` Suanming Mou 2019-12-16 3:42 ` [dpdk-dev] [RFC v3 2/2] net/mlx5: " Suanming Mou 2019-12-16 7:49 ` [dpdk-dev] [RFC v3 1/2] ethdev: " Ori Kam 2 siblings, 2 replies; 11+ messages in thread From: Suanming Mou @ 2019-12-16 3:42 UTC (permalink / raw) To: Adrien Mazarguil, Wenzhuo Lu, Jingjing Wu, Bernard Iremonger, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko Cc: dev, shahafs, orika, matan, viacheslavo For some overlay network, such as VXLAN, the DSCP field in the new outer IP header after VXLAN decapsulation may need to be updated accordingly. This commit introduce the DSCP modify action for IPv4 and IPv6. Signed-off-by: Suanming Mou <suanmingm@mellanox.com> Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> --- v3: * Add testpmd code. * Add one more commit support action in mlx5 pmd code. v2: * Add space to IPv4/6 DSCP. * Fix typo. --- app/test-pmd/cmdline_flow.c | 50 +++++++++++++++++++++++++++++ doc/guides/prog_guide/rte_flow.rst | 40 +++++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 +++++ lib/librte_ethdev/rte_flow.c | 2 ++ lib/librte_ethdev/rte_flow.h | 31 ++++++++++++++++++ 5 files changed, 131 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 99dade7..af94dbe 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -326,6 +326,10 @@ enum index { ACTION_SET_META, ACTION_SET_META_DATA, ACTION_SET_META_MASK, + ACTION_SET_IPV4_DSCP, + ACTION_SET_IPV4_DSCP_VALUE, + ACTION_SET_IPV6_DSCP, + ACTION_SET_IPV6_DSCP_VALUE, }; /** Maximum size for pattern in struct rte_flow_item_raw. */ @@ -1087,6 +1091,8 @@ struct parse_action_priv { ACTION_RAW_DECAP, ACTION_SET_TAG, ACTION_SET_META, + ACTION_SET_IPV4_DSCP, + ACTION_SET_IPV6_DSCP, ZERO, }; @@ -1300,6 +1306,18 @@ struct parse_action_priv { ZERO, }; +static const enum index action_set_ipv4_dscp[] = { + ACTION_SET_IPV4_DSCP_VALUE, + ACTION_NEXT, + ZERO, +}; + +static const enum index action_set_ipv6_dscp[] = { + ACTION_SET_IPV6_DSCP_VALUE, + ACTION_NEXT, + ZERO, +}; + static int parse_set_raw_encap_decap(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); @@ -3493,6 +3511,38 @@ static int comp_set_raw_index(struct context *, const struct token *, (struct rte_flow_action_set_meta, mask)), .call = parse_vc_conf, }, + [ACTION_SET_IPV4_DSCP] = { + .name = "set_ipv4_dscp", + .help = "set dscp value", + .priv = PRIV_ACTION(SET_IPV4_DSCP, + sizeof(struct rte_flow_action_set_dscp)), + .next = NEXT(action_set_ipv4_dscp), + .call = parse_vc, + }, + [ACTION_SET_IPV4_DSCP_VALUE] = { + .name = "dscp_value", + .help = "new IPv4 DSCP value to set", + .next = NEXT(action_set_ipv4_dscp, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY + (struct rte_flow_action_set_dscp, dscp)), + .call = parse_vc_conf, + }, + [ACTION_SET_IPV6_DSCP] = { + .name = "set_ipv6_dscp", + .help = "set DSCP value", + .priv = PRIV_ACTION(SET_IPV6_DSCP, + sizeof(struct rte_flow_action_set_dscp)), + .next = NEXT(action_set_ipv6_dscp), + .call = parse_vc, + }, + [ACTION_SET_IPV6_DSCP_VALUE] = { + .name = "dscp_value", + .help = "new IPv6 DSCP value to set", + .next = NEXT(action_set_ipv6_dscp, NEXT_ENTRY(UNSIGNED)), + .args = ARGS(ARGS_ENTRY + (struct rte_flow_action_set_dscp, dscp)), + .call = parse_vc_conf, + }, }; /** Remove and return last entry from argument stack. */ diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index a254c81..2f21309 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -2558,6 +2558,46 @@ the other path depending on HW capability. | ``mask`` | bit-mask applies to "data" | +----------+----------------------------+ +Action: ``SET_IPV4_DSCP`` +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Set IPv4 DSCP. + +Modify DSCP in IPv4 header. + +It must be used with RTE_FLOW_ITEM_TYPE_IPV4 in pattern. +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. + +.. _table_rte_flow_action_set_ipv4_dscp: + +.. table:: SET_IPV4_DSCP + + +-----------+---------------------------------+ + | Field | Value | + +===========+=================================+ + | ``dscp`` | DSCP in low 6 bits, rest ignore | + +-----------+---------------------------------+ + +Action: ``SET_IPV6_DSCP`` +^^^^^^^^^^^^^^^^^^^^^^^^^ + +Set IPv6 DSCP. + +Modify DSCP in IPv6 header. + +It must be used with RTE_FLOW_ITEM_TYPE_IPV6 in pattern. +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. + +.. _table_rte_flow_action_set_ipv6_dscp: + +.. table:: SET_IPV6_DSCP + + +-----------+---------------------------------+ + | Field | Value | + +===========+=================================+ + | ``dscp`` | DSCP in low 6 bits, rest ignore | + +-----------+---------------------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 10aabf5..3baaacb 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4228,6 +4228,14 @@ This section lists supported actions and their attributes, if any. - ``value {unsigned}``: Value to decrease TCP acknowledgment number by. +- ``set_ipv4_dscp``: Set IPv4 DSCP value with specified value + + - ``dscp_value {unsigned}``: The new DSCP value to be set + +- ``set_ipv6_dscp``: Set IPv6 DSCP value with specified value + + - ``dscp_value {unsigned}``: The new DSCP value to be set + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~ diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index 87a3e8c..b86aee3 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -168,6 +168,8 @@ struct rte_flow_desc_data { MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)), MK_FLOW_ACTION(SET_TAG, sizeof(struct rte_flow_action_set_tag)), MK_FLOW_ACTION(SET_META, sizeof(struct rte_flow_action_set_meta)), + MK_FLOW_ACTION(SET_IPV4_DSCP, sizeof(struct rte_flow_action_set_dscp)), + MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct rte_flow_action_set_dscp)), }; int diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h index 452d359..76bf080 100644 --- a/lib/librte_ethdev/rte_flow.h +++ b/lib/librte_ethdev/rte_flow.h @@ -2004,6 +2004,26 @@ enum rte_flow_action_type { * See struct rte_flow_action_set_meta. */ RTE_FLOW_ACTION_TYPE_SET_META, + + /** + * Modify IPv4 DSCP in the outermost IP header. + * + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV4, + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. + * + * See struct rte_flow_action_set_dscp. + */ + RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP, + + /** + * Modify IPv6 DSCP in the outermost IP header. + * + * If flow pattern does not define a valid RTE_FLOW_ITEM_TYPE_IPV6, + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION error. + * + * See struct rte_flow_action_set_dscp. + */ + RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP, }; /** @@ -2530,6 +2550,17 @@ struct rte_flow_action_set_meta { uint32_t mask; }; +/** + * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP + * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP + * + * Set the DSCP value for IPv4/IPv6 header. + * DSCP in low 6 bits, rest ignored. + */ +struct rte_flow_action_set_dscp { + uint8_t dscp; +}; + /* Mbuf dynamic field offset for metadata. */ extern int rte_flow_dynf_metadata_offs; -- 1.8.3.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [dpdk-dev] [RFC v3 2/2] net/mlx5: add IPv4/IPv6 DSCP rewrite action 2019-12-16 3:42 ` [dpdk-dev] [RFC v3 1/2] " Suanming Mou @ 2019-12-16 3:42 ` Suanming Mou 2019-12-16 7:49 ` [dpdk-dev] [RFC v3 1/2] ethdev: " Ori Kam 1 sibling, 0 replies; 11+ messages in thread From: Suanming Mou @ 2019-12-16 3:42 UTC (permalink / raw) To: Matan Azrad, Shahaf Shuler, Viacheslav Ovsiienko; +Cc: dev, orika This commit add the IPv4/IPv6 DSCP rewrite actions to the PMD code. Supported actions: RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP Signed-off-by: Suanming Mou <suanmingm@mellanox.com> --- drivers/net/mlx5/mlx5_flow.h | 6 +- drivers/net/mlx5/mlx5_flow_dv.c | 178 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 183 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 3fff5dd..88d2eb1 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -202,6 +202,8 @@ enum mlx5_feature_name { #define MLX5_FLOW_ACTION_MARK_EXT (1ull << 33) #define MLX5_FLOW_ACTION_SET_META (1ull << 34) #define MLX5_FLOW_ACTION_METER (1ull << 35) +#define MLX5_FLOW_ACTION_SET_IPV4_DSCP (1ull << 36) +#define MLX5_FLOW_ACTION_SET_IPV6_DSCP (1ull << 37) #define MLX5_FLOW_FATE_ACTIONS \ (MLX5_FLOW_ACTION_DROP | MLX5_FLOW_ACTION_QUEUE | \ @@ -238,7 +240,9 @@ enum mlx5_feature_name { MLX5_FLOW_ACTION_OF_SET_VLAN_VID | \ MLX5_FLOW_ACTION_SET_TAG | \ MLX5_FLOW_ACTION_MARK_EXT | \ - MLX5_FLOW_ACTION_SET_META) + MLX5_FLOW_ACTION_SET_META | \ + MLX5_FLOW_ACTION_SET_IPV4_DSCP | \ + MLX5_FLOW_ACTION_SET_IPV6_DSCP) #define MLX5_FLOW_VLAN_ACTIONS (MLX5_FLOW_ACTION_OF_POP_VLAN | \ MLX5_FLOW_ACTION_OF_PUSH_VLAN) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 73aaea4..105acd6 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -157,6 +157,7 @@ struct field_modify_info modify_vlan_out_first_vid[] = { }; struct field_modify_info modify_ipv4[] = { + {1, 1, MLX5_MODI_OUT_IP_DSCP}, {1, 8, MLX5_MODI_OUT_IPV4_TTL}, {4, 12, MLX5_MODI_OUT_SIPV4}, {4, 16, MLX5_MODI_OUT_DIPV4}, @@ -164,6 +165,7 @@ struct field_modify_info modify_ipv4[] = { }; struct field_modify_info modify_ipv6[] = { + {1, 0, MLX5_MODI_OUT_IP_DSCP}, {1, 7, MLX5_MODI_OUT_IPV6_HOPLIMIT}, {4, 8, MLX5_MODI_OUT_SIPV6_127_96}, {4, 12, MLX5_MODI_OUT_SIPV6_95_64}, @@ -1191,6 +1193,76 @@ struct field_modify_info modify_tcp[] = { } /** + * Convert modify-header set IPv4 DSCP action to DV specification. + * + * @param[in,out] resource + * Pointer to the modify-header resource. + * @param[in] action + * Pointer to action specification. + * @param[out] error + * Pointer to the error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +flow_dv_convert_action_modify_ipv4_dscp + (struct mlx5_flow_dv_modify_hdr_resource *resource, + const struct rte_flow_action *action, + struct rte_flow_error *error) +{ + const struct rte_flow_action_set_dscp *conf = + (const struct rte_flow_action_set_dscp *)(action->conf); + struct rte_flow_item item = { .type = RTE_FLOW_ITEM_TYPE_IPV4 }; + struct rte_flow_item_ipv4 ipv4; + struct rte_flow_item_ipv4 ipv4_mask; + + memset(&ipv4, 0, sizeof(ipv4)); + memset(&ipv4_mask, 0, sizeof(ipv4_mask)); + ipv4.hdr.type_of_service = conf->dscp; + ipv4_mask.hdr.type_of_service = 0x3f; + item.spec = &ipv4; + item.mask = &ipv4_mask; + return flow_dv_convert_modify_action(&item, modify_ipv4, NULL, resource, + MLX5_MODIFICATION_TYPE_SET, error); +} + +/** + * Convert modify-header set IPv6 DSCP action to DV specification. + * + * @param[in,out] resource + * Pointer to the modify-header resource. + * @param[in] action + * Pointer to action specification. + * @param[out] error + * Pointer to the error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +flow_dv_convert_action_modify_ipv6_dscp + (struct mlx5_flow_dv_modify_hdr_resource *resource, + const struct rte_flow_action *action, + struct rte_flow_error *error) +{ + const struct rte_flow_action_set_dscp *conf = + (const struct rte_flow_action_set_dscp *)(action->conf); + struct rte_flow_item item = { .type = RTE_FLOW_ITEM_TYPE_IPV6 }; + struct rte_flow_item_ipv6 ipv6; + struct rte_flow_item_ipv6 ipv6_mask; + + memset(&ipv6, 0, sizeof(ipv6)); + memset(&ipv6_mask, 0, sizeof(ipv6_mask)); + ipv6.hdr.vtc_flow = conf->dscp; + ipv6_mask.hdr.vtc_flow = 0x3f; + item.spec = &ipv6; + item.mask = &ipv6_mask; + return flow_dv_convert_modify_action(&item, modify_ipv6, NULL, resource, + MLX5_MODIFICATION_TYPE_SET, error); +} + +/** * Validate MARK item. * * @param[in] dev @@ -3433,6 +3505,74 @@ struct field_modify_info modify_tcp[] = { } /** + * Validate the modify-header IPv4 DSCP actions. + * + * @param[in] action_flags + * Holds the actions detected until now. + * @param[in] action + * Pointer to the modify action. + * @param[in] item_flags + * Holds the items detected. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +flow_dv_validate_action_modify_ipv4_dscp(const uint64_t action_flags, + const struct rte_flow_action *action, + const uint64_t item_flags, + struct rte_flow_error *error) +{ + int ret = 0; + + ret = flow_dv_validate_action_modify_hdr(action_flags, action, error); + if (!ret) { + if (!(item_flags & MLX5_FLOW_LAYER_L3_IPV4)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "no ipv4 item in pattern"); + } + return ret; +} + +/** + * Validate the modify-header IPv6 DSCP actions. + * + * @param[in] action_flags + * Holds the actions detected until now. + * @param[in] action + * Pointer to the modify action. + * @param[in] item_flags + * Holds the items detected. + * @param[out] error + * Pointer to error structure. + * + * @return + * 0 on success, a negative errno value otherwise and rte_errno is set. + */ +static int +flow_dv_validate_action_modify_ipv6_dscp(const uint64_t action_flags, + const struct rte_flow_action *action, + const uint64_t item_flags, + struct rte_flow_error *error) +{ + int ret = 0; + + ret = flow_dv_validate_action_modify_hdr(action_flags, action, error); + if (!ret) { + if (!(item_flags & MLX5_FLOW_LAYER_L3_IPV6)) + return rte_flow_error_set(error, EINVAL, + RTE_FLOW_ERROR_TYPE_ACTION, + NULL, + "no ipv6 item in pattern"); + } + return ret; +} + +/** * Find existing modify-header resource or create and register a new one. * * @param dev[in, out] @@ -4806,6 +4946,32 @@ struct field_modify_info modify_tcp[] = { action_flags |= MLX5_FLOW_ACTION_METER; ++actions_n; break; + case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP: + ret = flow_dv_validate_action_modify_ipv4_dscp + (action_flags, + actions, + item_flags, + error); + if (ret < 0) + return ret; + /* Count all modify-header actions as one action. */ + if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS)) + ++actions_n; + action_flags |= MLX5_FLOW_ACTION_SET_IPV4_DSCP; + break; + case RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP: + ret = flow_dv_validate_action_modify_ipv6_dscp + (action_flags, + actions, + item_flags, + error); + if (ret < 0) + return ret; + /* Count all modify-header actions as one action. */ + if (!(action_flags & MLX5_FLOW_MODIFY_HDR_ACTIONS)) + ++actions_n; + action_flags |= MLX5_FLOW_ACTION_SET_IPV6_DSCP; + break; default: return rte_flow_error_set(error, ENOTSUP, RTE_FLOW_ERROR_TYPE_ACTION, @@ -7032,6 +7198,18 @@ struct field_modify_info modify_tcp[] = { flow->meter->mfts->meter_action; action_flags |= MLX5_FLOW_ACTION_METER; break; + case RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP: + if (flow_dv_convert_action_modify_ipv4_dscp(&mhdr_res, + actions, error)) + return -rte_errno; + action_flags |= MLX5_FLOW_ACTION_SET_IPV4_DSCP; + break; + case RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP: + if (flow_dv_convert_action_modify_ipv6_dscp(&mhdr_res, + actions, error)) + return -rte_errno; + action_flags |= MLX5_FLOW_ACTION_SET_IPV6_DSCP; + break; case RTE_FLOW_ACTION_TYPE_END: actions_end = true; if (mhdr_res.actions_num) { -- 1.8.3.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [dpdk-dev] [RFC v3 1/2] ethdev: add IPv4/IPv6 DSCP rewrite action 2019-12-16 3:42 ` [dpdk-dev] [RFC v3 1/2] " Suanming Mou 2019-12-16 3:42 ` [dpdk-dev] [RFC v3 2/2] net/mlx5: " Suanming Mou @ 2019-12-16 7:49 ` Ori Kam 1 sibling, 0 replies; 11+ messages in thread From: Ori Kam @ 2019-12-16 7:49 UTC (permalink / raw) To: Suanming Mou, Adrien Mazarguil, Wenzhuo Lu, Jingjing Wu, Bernard Iremonger, John McNamara, Marko Kovacevic, Thomas Monjalon, Ferruh Yigit, Andrew Rybchenko Cc: dev, Shahaf Shuler, Matan Azrad, Slava Ovsiienko > -----Original Message----- > From: Suanming Mou <suanmingm@mellanox.com> > Sent: Monday, December 16, 2019 5:42 AM > To: Adrien Mazarguil <adrien.mazarguil@6wind.com>; Wenzhuo Lu > <wenzhuo.lu@intel.com>; Jingjing Wu <jingjing.wu@intel.com>; Bernard > Iremonger <bernard.iremonger@intel.com>; John McNamara > <john.mcnamara@intel.com>; Marko Kovacevic > <marko.kovacevic@intel.com>; Thomas Monjalon <thomas@monjalon.net>; > Ferruh Yigit <ferruh.yigit@intel.com>; Andrew Rybchenko > <arybchenko@solarflare.com> > Cc: dev@dpdk.org; Shahaf Shuler <shahafs@mellanox.com>; Ori Kam > <orika@mellanox.com>; Matan Azrad <matan@mellanox.com>; Slava > Ovsiienko <viacheslavo@mellanox.com> > Subject: [RFC v3 1/2] ethdev: add IPv4/IPv6 DSCP rewrite action > > For some overlay network, such as VXLAN, the DSCP field in the new outer > IP header after VXLAN decapsulation may need to be updated accordingly. > > This commit introduce the DSCP modify action for IPv4 and IPv6. > > Signed-off-by: Suanming Mou <suanmingm@mellanox.com> > Acked-by: Andrew Rybchenko <arybchenko@solarflare.com> > --- > > v3: > * Add testpmd code. > * Add one more commit support action in mlx5 pmd code. > > v2: > * Add space to IPv4/6 DSCP. > * Fix typo. > > --- Acked-by: Ori Kam <orika@mellanox.com> Best, Ori > app/test-pmd/cmdline_flow.c | 50 > +++++++++++++++++++++++++++++ > doc/guides/prog_guide/rte_flow.rst | 40 +++++++++++++++++++++++ > doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 +++++ > lib/librte_ethdev/rte_flow.c | 2 ++ > lib/librte_ethdev/rte_flow.h | 31 ++++++++++++++++++ > 5 files changed, 131 insertions(+) > > diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c > index 99dade7..af94dbe 100644 > --- a/app/test-pmd/cmdline_flow.c > +++ b/app/test-pmd/cmdline_flow.c > @@ -326,6 +326,10 @@ enum index { > ACTION_SET_META, > ACTION_SET_META_DATA, > ACTION_SET_META_MASK, > + ACTION_SET_IPV4_DSCP, > + ACTION_SET_IPV4_DSCP_VALUE, > + ACTION_SET_IPV6_DSCP, > + ACTION_SET_IPV6_DSCP_VALUE, > }; > > /** Maximum size for pattern in struct rte_flow_item_raw. */ > @@ -1087,6 +1091,8 @@ struct parse_action_priv { > ACTION_RAW_DECAP, > ACTION_SET_TAG, > ACTION_SET_META, > + ACTION_SET_IPV4_DSCP, > + ACTION_SET_IPV6_DSCP, > ZERO, > }; > > @@ -1300,6 +1306,18 @@ struct parse_action_priv { > ZERO, > }; > > +static const enum index action_set_ipv4_dscp[] = { > + ACTION_SET_IPV4_DSCP_VALUE, > + ACTION_NEXT, > + ZERO, > +}; > + > +static const enum index action_set_ipv6_dscp[] = { > + ACTION_SET_IPV6_DSCP_VALUE, > + ACTION_NEXT, > + ZERO, > +}; > + > static int parse_set_raw_encap_decap(struct context *, const struct token > *, > const char *, unsigned int, > void *, unsigned int); > @@ -3493,6 +3511,38 @@ static int comp_set_raw_index(struct context *, > const struct token *, > (struct rte_flow_action_set_meta, mask)), > .call = parse_vc_conf, > }, > + [ACTION_SET_IPV4_DSCP] = { > + .name = "set_ipv4_dscp", > + .help = "set dscp value", > + .priv = PRIV_ACTION(SET_IPV4_DSCP, > + sizeof(struct rte_flow_action_set_dscp)), > + .next = NEXT(action_set_ipv4_dscp), > + .call = parse_vc, > + }, > + [ACTION_SET_IPV4_DSCP_VALUE] = { > + .name = "dscp_value", > + .help = "new IPv4 DSCP value to set", > + .next = NEXT(action_set_ipv4_dscp, > NEXT_ENTRY(UNSIGNED)), > + .args = ARGS(ARGS_ENTRY > + (struct rte_flow_action_set_dscp, dscp)), > + .call = parse_vc_conf, > + }, > + [ACTION_SET_IPV6_DSCP] = { > + .name = "set_ipv6_dscp", > + .help = "set DSCP value", > + .priv = PRIV_ACTION(SET_IPV6_DSCP, > + sizeof(struct rte_flow_action_set_dscp)), > + .next = NEXT(action_set_ipv6_dscp), > + .call = parse_vc, > + }, > + [ACTION_SET_IPV6_DSCP_VALUE] = { > + .name = "dscp_value", > + .help = "new IPv6 DSCP value to set", > + .next = NEXT(action_set_ipv6_dscp, > NEXT_ENTRY(UNSIGNED)), > + .args = ARGS(ARGS_ENTRY > + (struct rte_flow_action_set_dscp, dscp)), > + .call = parse_vc_conf, > + }, > }; > > /** Remove and return last entry from argument stack. */ > diff --git a/doc/guides/prog_guide/rte_flow.rst > b/doc/guides/prog_guide/rte_flow.rst > index a254c81..2f21309 100644 > --- a/doc/guides/prog_guide/rte_flow.rst > +++ b/doc/guides/prog_guide/rte_flow.rst > @@ -2558,6 +2558,46 @@ the other path depending on HW capability. > | ``mask`` | bit-mask applies to "data" | > +----------+----------------------------+ > > +Action: ``SET_IPV4_DSCP`` > +^^^^^^^^^^^^^^^^^^^^^^^^^ > + > +Set IPv4 DSCP. > + > +Modify DSCP in IPv4 header. > + > +It must be used with RTE_FLOW_ITEM_TYPE_IPV4 in pattern. > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. > + > +.. _table_rte_flow_action_set_ipv4_dscp: > + > +.. table:: SET_IPV4_DSCP > + > + +-----------+---------------------------------+ > + | Field | Value | > + +===========+=================================+ > + | ``dscp`` | DSCP in low 6 bits, rest ignore | > + +-----------+---------------------------------+ > + > +Action: ``SET_IPV6_DSCP`` > +^^^^^^^^^^^^^^^^^^^^^^^^^ > + > +Set IPv6 DSCP. > + > +Modify DSCP in IPv6 header. > + > +It must be used with RTE_FLOW_ITEM_TYPE_IPV6 in pattern. > +Otherwise, RTE_FLOW_ERROR_TYPE_ACTION error will be returned. > + > +.. _table_rte_flow_action_set_ipv6_dscp: > + > +.. table:: SET_IPV6_DSCP > + > + +-----------+---------------------------------+ > + | Field | Value | > + +===========+=================================+ > + | ``dscp`` | DSCP in low 6 bits, rest ignore | > + +-----------+---------------------------------+ > + > Negative types > ~~~~~~~~~~~~~~ > > diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > index 10aabf5..3baaacb 100644 > --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst > +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst > @@ -4228,6 +4228,14 @@ This section lists supported actions and their > attributes, if any. > > - ``value {unsigned}``: Value to decrease TCP acknowledgment number by. > > +- ``set_ipv4_dscp``: Set IPv4 DSCP value with specified value > + > + - ``dscp_value {unsigned}``: The new DSCP value to be set > + > +- ``set_ipv6_dscp``: Set IPv6 DSCP value with specified value > + > + - ``dscp_value {unsigned}``: The new DSCP value to be set > + > Destroying flow rules > ~~~~~~~~~~~~~~~~~~~~~ > > diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c > index 87a3e8c..b86aee3 100644 > --- a/lib/librte_ethdev/rte_flow.c > +++ b/lib/librte_ethdev/rte_flow.c > @@ -168,6 +168,8 @@ struct rte_flow_desc_data { > MK_FLOW_ACTION(DEC_TCP_ACK, sizeof(rte_be32_t)), > MK_FLOW_ACTION(SET_TAG, sizeof(struct > rte_flow_action_set_tag)), > MK_FLOW_ACTION(SET_META, sizeof(struct > rte_flow_action_set_meta)), > + MK_FLOW_ACTION(SET_IPV4_DSCP, sizeof(struct > rte_flow_action_set_dscp)), > + MK_FLOW_ACTION(SET_IPV6_DSCP, sizeof(struct > rte_flow_action_set_dscp)), > }; > > int > diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h > index 452d359..76bf080 100644 > --- a/lib/librte_ethdev/rte_flow.h > +++ b/lib/librte_ethdev/rte_flow.h > @@ -2004,6 +2004,26 @@ enum rte_flow_action_type { > * See struct rte_flow_action_set_meta. > */ > RTE_FLOW_ACTION_TYPE_SET_META, > + > + /** > + * Modify IPv4 DSCP in the outermost IP header. > + * > + * If flow pattern does not define a valid > RTE_FLOW_ITEM_TYPE_IPV4, > + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION > error. > + * > + * See struct rte_flow_action_set_dscp. > + */ > + RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP, > + > + /** > + * Modify IPv6 DSCP in the outermost IP header. > + * > + * If flow pattern does not define a valid > RTE_FLOW_ITEM_TYPE_IPV6, > + * then the PMD should return a RTE_FLOW_ERROR_TYPE_ACTION > error. > + * > + * See struct rte_flow_action_set_dscp. > + */ > + RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP, > }; > > /** > @@ -2530,6 +2550,17 @@ struct rte_flow_action_set_meta { > uint32_t mask; > }; > > +/** > + * RTE_FLOW_ACTION_TYPE_SET_IPV4_DSCP > + * RTE_FLOW_ACTION_TYPE_SET_IPV6_DSCP > + * > + * Set the DSCP value for IPv4/IPv6 header. > + * DSCP in low 6 bits, rest ignored. > + */ > +struct rte_flow_action_set_dscp { > + uint8_t dscp; > +}; > + > /* Mbuf dynamic field offset for metadata. */ > extern int rte_flow_dynf_metadata_offs; > > -- > 1.8.3.1 ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2019-12-16 7:49 UTC | newest] Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-12-10 5:23 [dpdk-dev] [RFC] ethdev: add IPv4/IPv6 DSCP rewrite action Suanming Mou 2019-12-10 7:33 ` Andrew Rybchenko 2019-12-10 8:55 ` Suanming Mou 2019-12-10 18:32 ` Stephen Hemminger 2019-12-10 18:31 ` Stephen Hemminger 2019-12-10 19:48 ` Ori Kam 2019-12-11 1:36 ` Suanming Mou 2019-12-10 9:27 ` [dpdk-dev] [RFC v2] " Suanming Mou 2019-12-16 3:42 ` [dpdk-dev] [RFC v3 1/2] " Suanming Mou 2019-12-16 3:42 ` [dpdk-dev] [RFC v3 2/2] net/mlx5: " Suanming Mou 2019-12-16 7:49 ` [dpdk-dev] [RFC v3 1/2] ethdev: " Ori Kam
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).